claude-do-it 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +143 -13
- package/bin/daemon.js +14 -2211
- package/bin/do-it.js +13 -1206
- package/package.json +2 -2
- package/skill/SKILL.md +367 -61
- package/web/assets/index-D1yk8ubK.css +2 -0
- package/web/assets/index-DVWNl8ep.js +169 -0
- package/web/index.html +23 -10
- package/web/assets/index-6QftMBqY.css +0 -2
- package/web/assets/index-Bey8I5te.js +0 -130
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},t={pipe(){return e(this,arguments)}},n=function(){function e(){}return e.prototype=t,e}(),r=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},i=e=>e,a=e=>()=>e,o=a(!0),s=a(!1),c=a(null),l=a(void 0),u=l;function d(t,...n){return e(t,n)}function f(e,t,n,r,i,a,o,s,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return a(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return o(a(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return s(o(a(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(s(o(a(i(r(n(t(e.apply(this,arguments)))))))))}}}function p(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i}}function m(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i!==n&&t.set(i,i),i}}var h=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},g=new WeakSet,_=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),v=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,y=e=>{try{return new Uint8Array(e)}catch{return}},ee=0,te=()=>{ee++};function ne(e){return typeof e==`string`}function re(e){return typeof e==`number`}function ie(e){return typeof e==`boolean`}function ae(e){return typeof e==`symbol`}function oe(e){return ne(e)||re(e)||ae(e)}function se(e){return typeof e==`function`}function ce(e){return e===void 0}function le(e){return e!==void 0}function ue(e){return e===null}function de(e){return e!==null}function fe(e){return e!=null}function pe(e){return!1}function me(e){return!0}function he(e){return typeof e==`object`&&!!e}function ge(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _e(e){return typeof e==`object`&&!!e||se(e)}var b=r(2,(e,t)=>_e(e)&&t in e),ve=r(2,(e,t)=>b(e,`_tag`)&&e._tag===t);function ye(e){return e instanceof Error}var be=`~effect/Hash`,x=e=>{switch(typeof e){case`number`:return De(e);case`bigint`:return Oe(e.toString(10));case`string`:return Oe(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?Oe(`Invalid Date`):Oe(e.toISOString());if(e instanceof RegExp)return Oe(e.toString());{if(g.has(e))return xe(e);let t=Le.get(e);if(t!==void 0)return t;if(Re.has(e))return te(),Oe(`[Circular]`);Re.add(e);let n=ee,r;try{if(Te(e))r=e[be]();else if(typeof e==`function`)r=xe(e);else if(v(e)){let t=y(e);r=t===void 0?xe(e):Me(t)}else r=e instanceof DataView?Me(_(e)):Array.isArray(e)||ArrayBuffer.isView(e)?Me(e):e instanceof Map?Ne(e):e instanceof Set?Fe(e):Ae(e)}finally{Re.delete(e)}return n===ee&&Le.set(e,r),r}}return we(Se(Oe(String(e))))},xe=e=>(Ie.has(e)||Ie.set(e,we(Math.random()*4294967296|0)),Ie.get(e)),Se=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),Ce=r(2,(e,t)=>Se(Math.imul(e,2654435761)+Math.imul(t,2246822507))),we=e=>e&3221225471|e>>>1&1073741824,Te=e=>b(e,`~effect/Hash`)&&typeof e[`~effect/Hash`]==`function`,Ee=new DataView(new ArrayBuffer(8)),De=e=>{let t=e|0;return t===e?we(t):(Ee.setFloat64(0,e===e?e:NaN),we(Ce(Ee.getInt32(0),Ee.getInt32(4))))},Oe=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return we(t)},ke=(e,t)=>{let n=12289;for(let r of t)n^=Ce(x(r),x(e[r]));return we(n)},Ae=e=>ke(e,h(e)),je=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return we(r)},Me=e=>{let t=6151;for(let n of e)t=Ce(t,x(n));return we(t)},Ne=je(Oe(`Map`),([e,t])=>Ce(x(e),x(t))),Pe=Oe(`Set`),Fe=je(Pe,e=>Ce(Pe,x(e))),Ie=new WeakMap,Le=new WeakMap,Re=new WeakSet,ze=`~effect/Equal`;function Be(){return arguments.length===1?e=>Ve(e,arguments[0]):Ve(arguments[0],arguments[1])}function Ve(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||g.has(e)||g.has(t)?!1:He(e,t):!1}function He(e,t){let n=We.length;for(let r=n;r-->0;)if(We[r]===e&&Ge[r]===t)return!0;if(n)return Ue(e,t);let r=Ke.get(e);r||Ke.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=Ue(e,t)),i}function Ue(e,t){We.push(e),Ge.push(t);try{return qe(e,t)}finally{We.pop(),Ge.pop()}}var We=[],Ge=[],Ke=new WeakMap;function qe(e,t){if(x(e)!==x(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),r=t.getTime();return n===r||Number.isNaN(n)&&Number.isNaN(r)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let n=rt(e);if(n!==rt(t)||typeof e==`function`&&!n)return!1;if(n)return e[ze](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:Je(e,t);if(v(e)){if(!v(t)||e instanceof ArrayBuffer!=t instanceof ArrayBuffer)return!1;let n=y(e),r=y(t);return n!==void 0&&r!==void 0&&Ye(n,r)}if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?Ye(_(e),_(t)):Ye(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:Ze(e,t,Qe,$e):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:Ze(e,t,x,Ve):Xe(e,t)}function Je(e,t){for(let n=0;n<e.length;n++)if(!Ve(e[n],t[n]))return!1;return!0}function Ye(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Xe(e,t){let n=h(e),r=h(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!Ve(e[i],t[i]))return!1;return!0}function Ze(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop(),a--;continue outer}}return!1}return a===0}var Qe=e=>x(e[0]),$e=(e,t)=>Ve(e[0],t[0])&&Ve(e[1],t[1]),et=()=>0;function tt(e,t){return nt((n,r)=>e(n[0],r[0])&&t(n[1],r[1]))}function nt(e){return function(t,n){return Ze(t,n,et,e)}}var rt=e=>b(e,`~effect/Equal`)&&typeof e[`~effect/Equal`]==`function`,it=()=>Be,at=Symbol.for(`~effect/Redactable`),ot=e=>b(e,at);function st(e){return ot(e)?ct(e):e}function ct(e){return e[at](globalThis[`~effect/Fiber/currentFiber`]?.context??dt)}var lt=`~effect/Fiber/currentFiber`,ut=new Map,dt={"~effect/Context":{},base:ut,depth:0,mapUnsafe:ut,pipe(){return e(this,arguments)}};function ft(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(e,n=0){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return pt;r.add(e);let l;if(at in e)l=c(ct(e),n);else if(Array.isArray(e))l=!i||e.length<=1?`[${e.map(e=>c(e,n)).join(`,`)}]`:`[\n${a(n+1)}${e.map(e=>c(e,n+1)).join(`,
|
|
2
|
-
`+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=gt(e);else if(!t?.ignoreToString&&b(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=_t(e);l=e instanceof Error&&e.cause!==void 0?`${t} (cause: ${c(e.cause,n)})`:t}else if(Symbol.iterator in e)l=`${e.constructor.name}(${c(Array.from(e),n)})`;else{let t=s(e);if(!i||t.length<=1){let r=`{${t.map(t=>`${mt(t)}:${c(vt(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${mt(t)}: ${c(vt(e,t),n+1)}`).join(`,
|
|
3
|
-
`)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}var pt=`[Circular]`;function mt(e){return typeof e==`string`?JSON.stringify(e):String(e)}function ht(e){return e.map(e=>`[${mt(e)}]`).join(``)}function gt(e){try{return e.toISOString()}catch{return`Invalid Date`}}function _t(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function vt(e,t){try{return e[t]}catch{return`[property access threw]`}}function yt(e,t){let n=[],r=new WeakMap;return JSON.stringify(e,function(e,t){let i=Object.getOwnPropertyDescriptor(r.get(this)??this,e)?.value,a=b(i,at)?st(i):st(t);if(typeof a==`bigint`)return ft(a);if(typeof a!=`object`||!a)return a;let o=a instanceof Error&&!b(a,`toJSON`)?{...a,name:a.name,message:a.message}:a;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(a))return;if(n.push(a),o!==a&&n.push(o),!bt(o)||St(o))return o;let s=xt(o);return r.set(s,o),n.push(s),s},t?.space)??`null`}function bt(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function xt(e){let t=Array.isArray(e)?[]:{},n=Array.isArray(e)?Array.from({length:e.length},(e,t)=>String(t)):Object.keys(e);for(let r of n)Object.defineProperty(t,r,{enumerable:!0,get:()=>{let t=Reflect.get(e,r);return Object.getOwnPropertyDescriptor(e,r)?.get===void 0?t:st(t)}});return t}function St(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}var Ct=Symbol.for(`nodejs.util.inspect.custom`),wt=e=>{try{return e=st(e),b(e,`toJSON`)&&se(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(wt):e}catch{return`[toJSON threw]`}},Tt=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?yt(e,{space:t}):ft(e,{space:t})}catch{return String(e)}},Et={toJSON(){return wt(this)},[Ct](){return this.toJSON()},toString(){return ft(this.toJSON())}},Dt=class{[Ct](){return this.toJSON()}toString(){return ft(this.toJSON())}},Ot=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),kt=()=>Error.stackTraceLimit,At=e=>{Ot&&(Error.stackTraceLimit=e)},jt=class{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}},Mt=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}},r=kt();if(r===0)return n[e];At(2);let i=t[e](()=>Error());return At(r),i.stack?.includes(e)===!0?t[e]:n[e]})();function Nt(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function Pt(e,t){if(!Object.hasOwn(t,`__proto__`))Object.assign(e,t);else for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&Nt(e,n,t[n])}var Ft=`~effect/Effect`,It=`~effect/Exit`,Lt={_A:i,_E:i,_R:i},Rt=`${Ft}/identifier`,S=`${Ft}/args`,zt=`${Ft}/evaluate`,Bt=`${Ft}/successCont`,Vt=`${Ft}/failureCont`,Ht=`${Ft}/ensureCont`,Ut=Symbol.for(`effect/Effect/Yield`),Wt={pipe(){return e(this,arguments)},toJSON(){return{...this}},toString(){return ft(this.toJSON(),{ignoreToString:!0,space:2})},[Ct](){return this.toJSON()}},Gt={[Ft]:Lt,...Wt,[Symbol.iterator](){return new jt(this)},toJSON(){return{_id:`Effect`,op:this[Rt],...`~effect/Effect/args`in this?{args:this[S]}:void 0}}},Kt=e=>b(e,Ft),qt=e=>b(e,It),Jt=`~effect/Cause`,Yt=`~effect/Cause/Reason`,Xt=e=>b(e,Jt),Zt=e=>b(e,Yt),Qt=class{constructor(e){this[Jt]=Jt,this.reasons=e}pipe(){return e(this,arguments)}toJSON(){return{_id:`Cause`,reasons:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${ft(this.reasons)})`}[Ct](){return this.toJSON()}[ze](e){return Xt(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>Be(t,e.reasons[n]))}[be](){return Me(this.reasons)}},$t=new WeakMap,en=class{[Yt];annotations;_tag;constructor(e,t,n){if(this[Yt]=Yt,this._tag=e,t!==tn&&typeof n==`object`&&n&&t.size>0){let e=$t.get(n);e&&(t=new Map([...e,...t])),$t.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);if(e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)}),t?.overwrite!==!0&&n.size===this.annotations.size)return this;let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return e(this,arguments)}toString(){return ft(this)}[Ct](){return this.toString()}},tn=new Map,nn=class extends en{constructor(e,t=tn){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${ft(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[ze](e){return pn(e)&&Be(this.error,e.error)&&Be(this.annotations,e.annotations)}[be](){return Ce(Oe(this._tag))(Ce(x(this.error))(x(this.annotations)))}},rn=e=>new Qt(e),an=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=x(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>Be(e,i)))continue;else t.push(i);r.push(i)}return r},on=r(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new Qt(an(e.reasons,t.reasons));return Be(e,n)?e:n}),sn=(e,t)=>{let n=e.reasons.slice();for(let e of t.reasons)hn(e)&&!n.some(t=>hn(t)&&t.fiberId===e.fiberId&&t.annotations===e.annotations)&&n.push(e);return n.length===e.reasons.length?e:new Qt(n)},cn=new Qt([]),ln=e=>new Qt([new nn(e)]),un=class extends en{constructor(e,t=tn){super(`Die`,t,e),this.defect=e}toString(){return`Die(${ft(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[ze](e){return mn(e)&&Be(this.defect,e.defect)&&Be(this.annotations,e.annotations)}[be](){return Ce(Oe(this._tag))(Ce(x(this.defect))(x(this.annotations)))}},dn=e=>new Qt([new un(e)]),fn=r(e=>Xt(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new Qt(e.reasons.map(e=>e.annotate(t,n)))),pn=e=>e._tag===`Fail`,mn=e=>e._tag===`Die`,hn=e=>e._tag===`Interrupt`;function gn(e){return Tn(`Effect.evaluate: Not implemented`)}var _n=e=>({...Gt,[Rt]:e.op,[zt]:e[`~effect/Effect/evaluate`]??gn,[Bt]:e[Bt],[Vt]:e[Vt],[Ht]:e[Ht]}),vn=e=>{let t=_n(e),n=function(e){this[S]=e};return n.prototype=t,function(e){return new n(e)}},yn=e=>{let t={[It]:It,_tag:e.op,get[e.prop](){return this[S]},..._n(e),toString(){return`${e.op}(${ft(this[S])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[S]}},[ze](e){return qt(e)&&e._tag===this._tag&&Be(this[`~effect/Effect/args`],e[`~effect/Effect/args`])},[be](){return Ce(Oe(e.op),x(this[S]))}},n=function(e){this[S]=e};return n.prototype=t,function(e){return new n(e)}},bn=yn({op:`Success`,prop:`value`,[zt](e){let t=e.getCont(Bt);return t?t[Bt](this[S],e,this):e.yieldWith(this)}}),xn={key:`effect/Cause/StackTrace`},Sn={key:`effect/Cause/InterruptorStackTrace`},Cn=yn({op:`Failure`,prop:`cause`,[zt](e){let t=this[S],n=!1;e.cache.stackFrame&&(t=fn(t,{mapUnsafe:new Map([[xn.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(Vt),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;r&&e.interruptible;)a||=Rt in r,r=e.getCont(Vt);a&&(t=rn(t.reasons.filter(e=>e._tag!==`Fail`))),t=sn(t,i),n=!0}return r?r[Vt](t,e,n?void 0:this):e.yieldWith(n?Cn(t):this)}}),wn=e=>Cn(ln(e)),Tn=e=>Cn(dn(e)),C=vn({op:`WithFiber`,[zt](e){return this[S](e)}}),En=function(){class e extends globalThis.Error{}let t=_n({op:`YieldableError`,[zt](){return wn(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Dn=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends En{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(Pt(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),On=e=>{class t extends Dn{_tag=e}return t.prototype.name=e,t},kn=`~effect/Cause/Done`,An=e=>b(e,kn),jn={[kn]:kn,_tag:`Done`,value:void 0},Mn=e=>e===void 0?jn:{[kn]:kn,_tag:`Done`,value:e},Nn=wn(jn),Pn=e=>e===void 0?Nn:wn(Mn(e)),Fn=e=>_n({op:e.label,[zt]:e.evaluate}),In=e=>(t,n)=>t===n||e(t,n),Ln=(e,t)=>e===t,Rn=()=>Ln;function zn(e){return In((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e[r](t[r],n[r]))return!1;return!0})}function Bn(e){return In((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var Vn=`~effect/Option`,Hn={[Vn]:{_A:e=>e},...Wt,[Symbol.iterator](){return new jt(this)}},Un=Object.defineProperty(Object.assign(Object.create(Hn),{_tag:`Some`,_op:`Some`,[ze](e){return Kn(e)&&Jn(e)&&Be(this.value,e.value)},[be](){return Ce(x(this._tag))(x(this.value))},toString(){return`some(${ft(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:wt(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),Wn=x(`None`),Gn=Object.assign(Object.create(Hn),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[ze](e){return Kn(e)&&qn(e)},[be](){return Wn},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),Kn=e=>b(e,Vn),qn=e=>e._tag===`None`,Jn=e=>e._tag===`Some`,Yn=Object.create(Gn),Xn=function(e){this.value=e};Xn.prototype=Un;var Zn=e=>new Xn(e),Qn=`~effect/Result`,$n={[Qn]:{_A:e=>e,_E:e=>e},...Wt,[Symbol.iterator](){return new jt(this)}},er=Object.assign(Object.create($n),{_tag:`Success`,_op:`Success`,[ze](e){return nr(e)&&ir(e)&&Be(this.success,e.success)},[be](){return Ce(x(this._tag))(x(this.success))},toString(){return`success(${ft(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:wt(this.success)}}}),tr=Object.assign(Object.create($n),{_tag:`Failure`,_op:`Failure`,[ze](e){return nr(e)&&rr(e)&&Be(this.failure,e.failure)},[be](){return Ce(x(this._tag))(x(this.failure))},toString(){return`failure(${ft(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:wt(this.failure)}}}),nr=e=>b(e,Qn),rr=e=>e._tag===`Failure`,ir=e=>e._tag===`Success`,ar=function(e){this.failure=e};ar.prototype=tr;var or=e=>new ar(e),sr=function(e){this.success=e};sr.prototype=er;var cr=e=>new sr(e);function lr(e){return(t,n)=>t===n?0:e(t,n)}var ur=lr((e,t)=>e<t?-1:1),dr=lr((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),fr=r(2,(e,t)=>lr((n,r)=>e(t(n),t(r)))),pr=e=>r(2,(t,n)=>e(t,n)===-1),mr=e=>r(2,(t,n)=>e(t,n)===1),hr=e=>r(2,(t,n)=>e(t,n)!==1),gr=e=>r(2,(t,n)=>e(t,n)!==-1),w=()=>Yn,T=Zn,_r=Kn,E=qn,D=Jn,O=r(2,(e,{onNone:t,onSome:n})=>E(e)?t():n(e.value)),vr=r(2,(e,t)=>E(e)?t():e.value),yr=r(2,(e,t)=>E(e)?t():e),br=e=>e==null?w():T(e),xr=vr(c),Sr=vr(l),Cr=r(2,(e,t)=>{if(D(e))return e.value;throw t()})(()=>Error(`getOrThrow called on a None`)),wr=r(2,(e,t)=>E(e)?w():T(t(e.value))),Tr=r(2,(e,t)=>E(e)?w():t(e.value)),Er=r(2,(e,t)=>E(e)?w():br(t(e.value))),Dr=e=>{if(Symbol.iterator in e){let t=[];for(let n of e){if(E(n))return w();t.push(n.value)}return T(t)}let t={};for(let n of Object.keys(e)){let r=e[n];if(E(r))return w();Nt(t,n,r.value)}return T(t)},Or=e=>E(e)?[]:[e.value],kr=r(2,(e,t)=>E(e)?w():t(e.value)?T(e.value):w()),Ar=r(2,(e,t)=>t(e)?T(e):w()),jr=r(2,(e,t)=>!E(e)&&t(e.value)),Mr=`~effect/Context/Service`,Nr=function(){function e(){}let t=e;Object.setPrototypeOf(t,Pr);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[Ir]=Ir,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&Fr.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},Pr={[Mr]:Mr,...Fn({label:`Service`,evaluate(e){return bn(ii(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return Qr(this,e)},use(e){return C(t=>e(ii(t.context,this)))},useSync(e){return C(t=>bn(e(ii(t.context,this))))}},Fr=new Set,Ir=`~effect/Context/Reference`,Lr=`~effect/Context`,Rr=8,zr=(e,t,n,r,i)=>{let a=Object.create(Kr);return a.cacheRoot=e??a,a.base=t,a.overlay=n,a.depth=r,a._flat=void 0,a.baseHits=0,a.maxDepth=i,a},Br=(e,t)=>{t&&(Br(e,t.parent),e.set(t.key,t.value))},Vr=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return Br(t,e.overlay),e._flat=t},Hr=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),zr(void 0,n,void 0,0,e.maxDepth)},Ur=Symbol(),Wr=(e,t)=>{let n=e;for(let e=n.overlay;e;e=e.parent)if(e.key===t)return e.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Ur:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=Rr&&(n.base=Vr(n),n.overlay=void 0,n.depth=0),r)},Gr=(e,t)=>{let n=t?.maxDepth;return zr(void 0,e,void 0,0,Number.isInteger(n)&&n>=0?n:8)},Kr={get mapUnsafe(){return Vr(this)},...Wt,[Lr]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[ze](e){if(!Jr(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[e,r]of t)if(!n.has(e)||!Be(r,n.get(e)))return!1;return!0},[be](){return De(this.mapUnsafe.size)}},qr=(e,t)=>e.cacheRoot===t.cacheRoot,Jr=e=>b(e,Lr),Yr=e=>!!e[Ir],Xr=()=>Zr,Zr=Gr(new Map),Qr=(e,t)=>Gr(new Map([[e.key,t]])),$r=r(3,(e,t,n)=>ei(e,t.key,n)),ei=(e,t,n)=>{let r=e,i=Fr.has(t)?void 0:r.cacheRoot;if(r.depth>=r.maxDepth){let e=new Map(r._flat??r.base);return r._flat||Br(e,r.overlay),e.set(t,n),zr(i,e,void 0,0,r.maxDepth)}return zr(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1,r.maxDepth)},ti=r(2,(e,t)=>ni(e,t.key)),ni=(e,t)=>{let n=Wr(e,t);return n===Ur?void 0:n},ri=r(2,(e,t)=>{let n=Wr(e,t.key);if(n===Ur){if(Yr(t))return oi(t);throw si(t)}return n}),ii=ri,ai=`~effect/Context/defaultValue`,oi=e=>ai in e?e[ai]:e[ai]=e.defaultValue(),si=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
|
|
4
|
-
`);e.splice(1,3),t.stack=e.join(`
|
|
5
|
-
`)}return t},ci=r(2,(e,t)=>{let n=Wr(e,t.key);return n===Ur?Yr(t)?T(oi(t)):w():T(n)}),li=r(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:Hr(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),ui=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return Gr(t)},k=Nr,di=e=>e.length>0,fi=e=>e>0?Math.floor(e):0,pi=e=>Math.max(1,fi(e)),mi=cr,hi=or,gi=hi(void 0),_i=e=>{if(se(e))try{return mi(e())}catch(e){return hi(e)}try{return mi(e.try())}catch(t){return hi(e.catch(t))}},vi=nr,yi=rr,bi=ir,xi=(...e)=>e,Si=zn,Ci=e=>{let t=e[Symbol.iterator]().next();if(t.done)throw Error(`headUnsafe: empty iterable`);return t.value},wi=r(2,(e,t)=>{let n=0;for(let r of e){let e=t(r,n);if(ie(e)){if(e)return T(r)}else if(D(e))return e;n++}return w()}),Ti=r(2,(e,t)=>{let n=[];for(let r of Ai(e))n.push(t(r,e[r]));return n}),Ei=Ti((e,t)=>[e,t]),Di=r(2,(e,t)=>Object.hasOwn(e,t)),Oi=r(2,(e,t)=>Object.hasOwn(e,t)?T(e[t]):w()),ki=r(2,(e,t)=>{let n={...e};for(let r of Ai(e))Nt(n,r,t(e[r],r));return n}),Ai=e=>Object.keys(e),ji=e=>Ti(e,(e,t)=>t),Mi=e=>r(2,(t,n)=>{for(let r of Ai(t))if(!Di(n,r)||!e(t[r],n[r]))return!1;return!0}),Ni=e=>{let t=Mi(e);return(e,n)=>t(e,n)&&t(n,e)},Pi=globalThis.Array,Fi=r(2,(e,t)=>{let n=pi(e),r=new Pi(n);for(let e=0;e<n;e++)r[e]=t(e);return r}),Ii=(e,t)=>e<=t?Fi(t-e+1,t=>e+t):[e],Li=e=>Pi.isArray(e)?e:Pi.from(e),Ri=r(2,(e,{onEmpty:t,onNonEmpty:n})=>Wi(e)?n(e):t()),zi=r(2,(e,t)=>[...e,t]),Bi=r(2,(e,t)=>Li(e).concat(Li(t))),Vi=Pi.isArray,Hi=e=>e.length===0,Ui=di,Wi=di,Gi=e=>e.length;function Ki(e,t){return!Number.isFinite(e)||e<0||e>=t.length}var qi=r(2,(e,t)=>{let n=Math.floor(t);return Ki(n,e)?w():T(e[n])}),Ji=r(2,(e,t)=>{let n=Math.floor(t);if(Ki(n,e))throw Error(`Index out of bounds: ${n}`);return e[n]}),Yi=e=>[ea(e),$i(e)],Xi=qi(0),Zi=Ji(0),Qi=e=>Wi(e)?T($i(e)):w(),$i=e=>e[e.length-1],ea=e=>e.slice(0,-1),ta=(e,t)=>Math.min(fi(e),t),na=r(2,(e,t)=>{let n=Li(e);return n.slice(0,ta(t,n.length))}),ra=r(2,(e,t)=>{let n=Li(e);return n.slice(ta(t,n.length),n.length)}),ia=r(2,(e,t)=>{let n=Li(e),r=0;for(;r<n.length&&t(n[r],r);)r++;return n.slice(r)}),aa=r(2,(e,t)=>{let n=0;for(let r of e){if(t(r,n))return T(n);n++}return w()}),oa=wi,sa=r(3,(e,t,n)=>{let r=Pi.from(e),i=Math.floor(t);if(Ki(i,r))return w();let a=r;return a[i]=n(r[i]),T(a)}),ca=e=>Pi.from(e).reverse(),la=r(2,(e,t)=>ua(e,t,xi)),ua=r(3,(e,t,n)=>{let r=Li(e),i=Li(t);if(Wi(r)&&Wi(i)){let e=[n(Zi(r),Zi(i))],t=Math.min(r.length,i.length);for(let a=1;a<t;a++)e[a]=n(r[a],i[a]);return e}return[]}),da=r(2,(e,t)=>zi(ea(e),t($i(e)))),fa=(e=>r(2,(t,n)=>{for(let r of t)if(e(n,r))return!0;return!1}))(it()),pa=(e,t)=>{let n=x(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let e of r)if(Be(e,t))return!1;return r.push(t),!0},ma=()=>[],ha=e=>[e],ga=r(2,(e,t)=>e.map(t)),_a=e=>{let t=[];for(let n of e)D(n)&&t.push(n.value);return t},va=r(2,(e,t)=>{let n=Li(e),r=[];for(let e=0;e<n.length;e++){let i=t(n[e],e);bi(i)&&r.push(i.success)}return r}),ya=r(2,(e,t)=>{let n=Li(e),r=[];for(let e=0;e<n.length;e++)t(n[e],e)&&r.push(n[e]);return r}),ba=r(3,(e,t,n)=>Li(e).reduce((e,t,r)=>n(e,t,r),t)),xa=r(2,(e,t)=>e.every(t)),Sa=r(2,(e,t)=>e.some(t)),Ca=(e,t)=>{let n=[],r=e;for(;;){let e=t(r);if(E(e))break;let[i,a]=e.value;n.push(i),r=a}return n},wa=Bn,Ta=r(2,(e,t)=>Li(e).forEach((e,n)=>t(e,n))),Ea=e=>{let t=Li(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let e of t)pa(n,e)&&r.push(e);return r},Da=r(2,(e,t)=>Li(e).join(t)),Oa=`~effect/Duration`,ka=BigInt(0),Aa=BigInt(1),ja=BigInt(2),Ma=BigInt(10),Na=BigInt(24),Pa=BigInt(60),Fa=BigInt(1e3),Ia=BigInt(1e6),La=BigInt(1e9),Ra=BigInt(6e10),za=BigInt(36e11),Ba=BigInt(864e11),Va=BigInt(6048e11),Ha=e=>BigInt(Math.sign(e)*Math.round(Math.abs(e))),Ua=e=>Number.isInteger(e)?BigInt(e)*Ia:Ha(e*1e6),Wa=e=>io(Number.isFinite(e)?Ha(e):e),Ga=(e,t)=>{let n=Number(e);if(Number.isFinite(n))return n/t;let r=BigInt(t);return Number(e/r)+Number(e%r)/t},Ka=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=Ma**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t;return qa(r?-o:o,a)},qa=(e,t)=>{let n=e<ka?-e:e,r=n/t+(n%t*ja>=t?Aa:ka);return e<ka?-r:r},Ja=(e,t)=>{let n=Number(e)*t;if(!Number.isFinite(n))return io(n);let r=Ka(e,BigInt(t)*Ia);return io(Number.isInteger(n)&&BigInt(n)*Ia===r?n:r)},Ya=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,Xa=e=>{switch(typeof e){case`number`:return mo(e);case`bigint`:return po(e);case`string`:{if(e===`Infinity`)return uo;if(e===`-Infinity`)return fo;let t=Ya.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return po(Ka(r,Aa));if(i===`micro`||i===`micros`)return po(Ka(r,Fa));switch(i){case`milli`:case`millis`:return Ja(r,1);case`second`:case`seconds`:return Ja(r,1e3);case`minute`:case`minutes`:return Ja(r,6e4);case`hour`:case`hours`:return Ja(r,36e5);case`day`:case`days`:return Ja(r,864e5);case`week`:case`weeks`:return Ja(r,6048e5)}break}case`object`:{if(e===null)break;if(Oa in e)return e;if(Array.isArray(e)){if(e.length!==2||!e.every(re))return $a(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return lo;if(e[0]===-1/0||e[1]===-1/0)return fo;if(e[0]===1/0||e[1]===1/0)return uo;let t=e[0]*1e9+e[1];return Number.isFinite(t)&&Number.isInteger(e[0])&&Number.isInteger(e[1])?io(BigInt(e[0])*La+BigInt(e[1])):Wa(t)}let t=e,n=0;if(t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds){if(!Number.isFinite(n))return io(n);let e=Qa(t);return e===void 0||BigInt(n)*Ia===e?io(n):io(e)}let r=n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0),i=Number.isFinite(r)?Qa(t):void 0;return i===void 0?Wa(r):io(i)}}return $a(e)},Za=e=>!e||Number.isInteger(e),Qa=e=>{if(!Za(e.weeks)||!Za(e.days)||!Za(e.hours)||!Za(e.minutes)||!Za(e.seconds)||!Za(e.milliseconds)||!Za(e.microseconds)||!Za(e.nanoseconds))return;let t=ka;return e.weeks&&(t+=BigInt(e.weeks)*Va),e.days&&(t+=BigInt(e.days)*Ba),e.hours&&(t+=BigInt(e.hours)*za),e.minutes&&(t+=BigInt(e.minutes)*Ra),e.seconds&&(t+=BigInt(e.seconds)*La),e.milliseconds&&(t+=BigInt(e.milliseconds)*Ia),e.microseconds&&(t+=BigInt(e.microseconds)*Fa),e.nanoseconds&&(t+=BigInt(e.nanoseconds)),t},$a=e=>{throw Error(`Invalid Input: ${e}`)},eo={_tag:`Millis`,millis:0},to={_tag:`Infinity`},no={_tag:`NegativeInfinity`},ro={[Oa]:Oa,[be](){switch(this.value._tag){case`Millis`:return x(Ua(this.value.millis));case`Nanos`:return x(this.value.nanos);default:return Ae(this.value)}},[ze](e){return ao(e)&&xo(this,e)},toString(){switch(this.value._tag){case`Infinity`:return`Infinity`;case`NegativeInfinity`:return`-Infinity`;case`Nanos`:return`${this.value.nanos} nanos`;case`Millis`:return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,nanos:String(this.value.nanos)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`};case`NegativeInfinity`:return{_id:`Duration`,_tag:`NegativeInfinity`}}},[Ct](){return this.toJSON()},pipe(){return e(this,arguments)}},io=e=>{let t=Object.create(ro);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?eo:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:Ua(e)}:e>0?to:no:e===ka?eo:{_tag:`Nanos`,nanos:e},t},ao=e=>b(e,Oa),oo=e=>{switch(e.value._tag){case`Millis`:return e.value.millis===0;case`Nanos`:return e.value.nanos===ka;case`Infinity`:case`NegativeInfinity`:return!1}},so=e=>{switch(e.value._tag){case`Millis`:return e.value.millis<0;case`Nanos`:return e.value.nanos<ka;case`NegativeInfinity`:return!0;case`Infinity`:return!1}},co=e=>{switch(e.value._tag){case`Infinity`:case`NegativeInfinity`:return uo;case`Millis`:return e.value.millis<0?io(-e.value.millis):e;case`Nanos`:return e.value.nanos<ka?io(-e.value.nanos):e}},lo=io(0),uo=io(1/0),fo=io(-1/0),po=e=>io(e),mo=e=>io(e),ho=e=>io(e*1e3),go=e=>vo(Xa(e),{onMillis:i,onNanos:e=>Ga(e,1e6),onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),_o=e=>{let t=Xa(e);switch(t.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return Ua(t.value.millis)}},vo=r(2,(e,t)=>{switch(e.value._tag){case`Millis`:return t.onMillis(e.value.millis);case`Nanos`:return t.onNanos(e.value.nanos);case`Infinity`:return t.onInfinity();case`NegativeInfinity`:return(t.onNegativeInfinity??t.onInfinity)()}}),yo=r(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(_o(e),t.value.nanos):n.onNanos(e.value.nanos,_o(t))),bo=(e,t)=>yo(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),xo=r(2,(e,t)=>bo(e,t)),So=e=>{if(e.value._tag===`Infinity`)return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};if(e.value._tag===`NegativeInfinity`)return{days:-1/0,hours:-1/0,minutes:-1/0,seconds:-1/0,millis:-1/0,nanos:-1/0};let t=_o(e),n=t<ka,r=n?-t:t,i=r/Ia,a=i/Fa,o=a/Pa,s=o/Pa,c=s/Na,l=n?-1:1;return{days:l*Number(c),hours:l*Number(s%Na),minutes:l*Number(o%Pa),seconds:l*Number(a%Pa),millis:l*Number(i%Fa),nanos:l*Number(r%Ia)}},Co=e=>{if(e.value._tag===`Infinity`)return`Infinity`;if(e.value._tag===`NegativeInfinity`)return`-Infinity`;if(oo(e))return`0`;if(so(e))return`-`+Co(co(e));let t=So(e),n=[];return t.days!==0&&n.push(`${t.days}d`),t.hours!==0&&n.push(`${t.hours}h`),t.minutes!==0&&n.push(`${t.minutes}m`),t.seconds!==0&&n.push(`${t.seconds}s`),t.millis!==0&&n.push(`${t.millis}ms`),t.nanos!==0&&n.push(`${t.nanos}ns`),n.join(` `)},wo=e=>t=>{let n=e(t);return yi(n)?w():T(n.success)},To=k(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new Ao}),Eo=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},Do=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},Oo=e=>{try{return Do(e)}catch{return Eo(e)}},ko=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},Ao=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?Eo:Oo)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new jo(this.setImmediate)}},jo=class{tasks=new ko;running=void 0;setImmediate;constructor(e=Oo){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},Mo=k(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),No=k(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),Po=class extends n{constructor(e){super(),e&&Pt(this,e)}},Fo=()=>new Proxy({},{get(e,t,n){return t===`$is`?ve:t===`$match`?Io:e=>({...e,_tag:t})}});function Io(){if(arguments.length===1){let e=arguments[0];return function(t){return e[t._tag](t)}}let e=arguments[0];return arguments[1][e._tag](e)}var Lo=On,Ro=e=>{switch(e){case 16:return Vo();case 32:return Ho();default:{let t=``;for(let n=e>>>3;n>0;n--)t+=Bo();return t}}},A=Uint8Array.from(`0123456789abcdef`,e=>e.charCodeAt(0)),zo=()=>Math.random()*4294967296>>>0,Bo=()=>{let e=zo();return String.fromCharCode(A[e>>>28],A[e>>>24&15],A[e>>>20&15],A[e>>>16&15],A[e>>>12&15],A[e>>>8&15],A[e>>>4&15],A[e&15])},Vo=()=>{let e=zo(),t=zo();return String.fromCharCode(A[e>>>28],A[e>>>24&15],A[e>>>20&15],A[e>>>16&15],A[e>>>12&15],A[e>>>8&15],A[e>>>4&15],A[e&15],A[t>>>28],A[t>>>24&15],A[t>>>20&15],A[t>>>16&15],A[t>>>12&15],A[t>>>8&15],A[t>>>4&15],A[t&15])},Ho=()=>{let e=zo(),t=zo(),n=zo(),r=zo();return String.fromCharCode(A[e>>>28],A[e>>>24&15],A[e>>>20&15],A[e>>>16&15],A[e>>>12&15],A[e>>>8&15],A[e>>>4&15],A[e&15],A[t>>>28],A[t>>>24&15],A[t>>>20&15],A[t>>>16&15],A[t>>>12&15],A[t>>>8&15],A[t>>>4&15],A[t&15],A[n>>>28],A[n>>>24&15],A[n>>>20&15],A[n>>>16&15],A[n>>>12&15],A[n>>>8&15],A[n>>>4&15],A[n&15],A[r>>>28],A[r>>>24&15],A[r>>>20&15],A[r>>>16&15],A[r>>>12&15],A[r>>>8&15],A[r>>>4&15],A[r&15])},Uo=`effect/Tracer/ParentSpan`,Wo=class extends Nr()(Uo,{fiberCached:!0}){},Go=e=>e,Ko=k(`effect/Tracer/DisablePropagation`,{defaultValue:s}),qo=k(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),Jo=k(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),Yo=`effect/Tracer`,Xo=Go({span:e=>new Zo(e)}),Zo=class{_tag=`Span`;sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:`Started`,startTime:e.startTime}}get traceId(){return this._traceId??=Sr(this.parent)?.traceId??Ro(32)}get spanId(){return this._spanId??=Ro(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){this.status._tag!==`Ended`&&(this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime})}attribute(e,t){this.status._tag!==`Ended`&&this.attributes.set(e,t)}event(e,t,n){this.status._tag!==`Ended`&&this.events.push([e,t,n??{}])}addLinks(e){this.status._tag!==`Ended`&&this.links.push(...e)}},Qo=`effect/Metric/FiberRuntimeMetrics`,$o=k(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:l}),es=k(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:o}),ts=k(`effect/References/TracerTimingEnabled`,{defaultValue:o}),ns=k(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),rs=k(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),is=k(`effect/References/CurrentLogAnnotations`,{defaultValue:()=>({})}),as=k(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),os=k(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),ss=k(`effect/References/UnhandledLogLevel`,{defaultValue:()=>`Error`}),cs=k(`effect/References/CurrentLogSpans`,{defaultValue:()=>[]}),ls=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=kt();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};At(3);let n=Error();return At(t),{...e,captureStackTrace:us(()=>n.stack)}},us=(e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
|
|
6
|
-
`);if(i[e]!==void 0)return n=i[e].trim(),n}})(3),ds=class extends en{constructor(e,t=tn){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[ze](e){return hn(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[be](){return Oe(`${this._tag}:${this.fiberId}`)}},fs=e=>new ds(e),ps=e=>new Qt([new ds(e)]),ms=e=>e.reasons.some(pn),hs=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return mi(n.error)}return hi(e)},gs=wo(hs),_s=e=>e.reasons.some(mn),vs=e=>_s(e)&&ms(e)?rn(e.reasons.map(e=>e._tag===`Fail`&&!An(e.error)?new un(e.error,e.annotations):e)):e,ys=e=>_s(e)?hi(vs(e)):hs(e),bs=e=>e.reasons.some(hn),xs=e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag===`Interrupt`&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?mi(t):hi(e)},Ss=e=>{let t=xs(e);return yi(t)?Cs:t.success},Cs=new Set,ws=e=>e.reasons.length>0&&e.reasons.every(hn),Ts=r(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>pn(e)?(n=!0,new nn(t(e.error),e.annotations)):e);return n?rn(r):e}),Es=e=>{let t;for(let n of e.reasons){if(n._tag===`Fail`)return n.error;n._tag===`Die`&&(t??=n)}return t===void 0?e.reasons.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`):t.defect},Ds=(e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let i=kt();i!==0&&At(1);try{for(let i of e.reasons)i._tag===`Interrupt`?r.push(i):n.push(Os(i._tag===`Die`?i.defect:i.error,i.annotations,t));if(n.length===0){let e=Error(`The fiber was interrupted by:`);e.name=`InterruptCause`,e.stack=Ns(e,r);let i=new globalThis.Error(`All fibers interrupted without error`,{cause:e});i.name=`InterruptError`,i.stack=`${i.name}: ${i.message}`,n.push(Os(i,r[0].annotations,t))}}finally{i!==0&&At(i)}return n},Os=(e,t,n,r=new Set)=>{let i=typeof e,a;if(e&&i===`object`){r.add(e);let i=e.cause;if(a=new globalThis.Error(ks(e),{cause:i!==void 0&&!r.has(i)?Os(i,void 0,void 0,r):void 0}),typeof e.name==`string`&&(a.name=e.name),typeof e.stack==`string`)a.stack=js(e.stack,a,t);else{let e=`${a.name}: ${a.message}`;a.stack=t?Ms(e,t):e}n?.includeCauseInStack&&(a.stack=Is(a));for(let t of Object.keys(e))t in a||(a[t]=e[t])}else{a=new globalThis.Error(e?i===`string`?e:yt(e):`Unknown error: ${e}`);let n=`${a.name}: ${a.message}`;a.stack=t?Ms(n,t):n}return a},ks=e=>{if(typeof e.message==`string`)return e.message;if(typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return yt(e)},As=/\((.*)\)/g,js=(e,t,n)=>{let r=`${t.name}: ${t.message}`,i=(e.startsWith(r)?e.slice(r.length):e).split(`
|
|
7
|
-
`),a=[r];for(let e=1;e<i.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(i[e]);e++)a.push(i[e]);return n?Ms(a.join(`
|
|
8
|
-
`),n):a.join(`
|
|
9
|
-
`)},Ms=(e,t)=>{let n=t?.get(xn.key);return n&&(e=`${e}\n${Ps(n)}`),e},Ns=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let e of t){let t=e.fiberId===void 0?`unknown`:`#${e.fiberId}`,r=e.annotations.get(Sn.key);n.push(` at fiber (${t})`),r&&n.push(Ps(r))}return n.join(`
|
|
10
|
-
`)},Ps=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(As),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
|
|
11
|
-
`)},Fs=e=>Ds(e).map(Is).join(`
|
|
12
|
-
`),Is=e=>e.cause?`${e.stack} {\n${Ls(e.cause,` `)}\n}`:e.stack,Ls=(e,t)=>{let n=e.stack.split(`
|
|
13
|
-
`),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${Ls(e.cause,`${t} `)}\n${t}}`),r},Rs=`~effect/Fiber`,zs={_A:i,_E:i},Bs={id:0},Vs=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),Hs=()=>Vs===void 0?void 0:new Vs(`effect/Fiber`),Us=()=>globalThis[lt],Ws=class{constructor(e,t=!0){this.setContext(e),this.id=++Bs.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[Rs](){return zs}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return ii(this.context,e)}addObserver(e){return this._exit?(e(this._exit),u):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let n=ps(e);this.cache.stackFrame&&(n=fn(n,Qr(xn,this.cache.stackFrame))),t&&(n=fn(n,t)),this._interruptedCause=this._interruptedCause?sn(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(ic(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._asyncContext!==void 0){let t=this._asyncContext;this._asyncContext=void 0;try{return t.runInAsyncScope(this.evaluate,this,e)}finally{t.emitDestroy()}}else if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Ut){this._asyncContext=Hs();return}let n=Js.interruptChildren&&Js.interruptChildren(this);if(n!==void 0)return this.evaluate(Uc(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=Xr();let r=this.cache;(r.span!==void 0||r.stackFrame!==void 0)&&(this.cache={...r,span:void 0,stackFrame:void 0})}runLoop(e){let t=globalThis[lt];globalThis[lt]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,i=ic(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=Uc(cc,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[zt](this),i===Ut){let e=this._yielded;if(`~effect/Exit`in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return Ut}}catch(e){if(!b(i,`~effect/Effect/evaluate`))return Tn(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=Tn(e)}}finally{this._running=n,globalThis[lt]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,Ks;for(;;){let t=this._stack.pop();if(!t)return;let n=t[Ht];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}succeedWith(e){if(!(++this.currentOpCount&qs-1))return bn(e);let t=this.getCont(Bt);return t?t[Bt](e,this):this.yieldWith(bn(e))}yieldWith(e){return this._yielded=e,Ut}children(){return this._children??=new Set}pipe(){return e(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&qr(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=Gs(e);this.cache?.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}},Gs=e=>{let t=ni(e,Yo);return{scheduler:ii(e,To),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:ii(e,es),span:ni(e,Uo),logLevel:ii(e,as),minimumLogLevel:ii(e,os),stackFrame:ii(e,$o),runtimeMetrics:ni(e,Qo),maxOpsBeforeYield:ii(e,Mo),preventYield:ii(e,No)}},Ks={[Bt](e,t){return ic(t._interruptedCause)},[Vt](e,t){return ic(t._interruptedCause)}},qs=32,Js={interruptChildren:void 0},Ys=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Sn.key,e.cache.stackFrame),Gr(t)},Xs=e=>{if(e._children!==void 0&&e._children.size!==0)return nc(e._children)},Zs=e=>{let t=e;return t._exit?rc(t._exit):_c(n=>t._exit?n(rc(t._exit)):oc(e.addObserver(e=>n(rc(e)))))},Qs=e=>_c(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;)if(e.value._exit)r.push(e.value._exit),e=n.next();else{i=e.value.addObserver(e=>{r.push(e),a()});return}t(rc(r))}return a(),oc(()=>i?.())}),$s=e=>{let t=e;return t._exit?t._exit:_c(n=>t._exit?n(t._exit):oc(e.addObserver(n)))},ec=e=>C(t=>tc(e,t.id)),tc=r(e=>b(e[0],Rs),(e,t,n)=>C(r=>{let i=Ys(r);return i=i&&n?li(i,n):i??n,e.interruptUnsafe(t,i),Bc(Zs(e))})),nc=e=>C(t=>{let n=Ys(t),r=ma();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return Bc(Qs(r))}),rc=bn,ic=Cn,ac=wn,oc=vn({op:`Sync`,[zt](e){let t=this[S],n=t(),r=e.getCont(Bt);return r?r[Bt](n,e):e.yieldWith(bn(n))}}),sc=vn({op:`Suspend`,[zt](e){let t=this[S];return t()}}),cc=vn({op:`Yield`,[zt](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(tl)},this[`~effect/Effect/args`]??0),e.yieldWith(()=>{t=!0})}})(0),lc=rc(w()),uc=e=>sc(()=>ic(e())),dc=e=>Tn(e),fc=rc(void 0),pc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Ed(e,`An error occurred in Effect.try`):e.catch;return sc(()=>{try{return rc(t())}catch(e){return ac(n(e))}})},eee=e=>hc(function(t,n){e(n).then(e=>t(rc(e)),e=>t(dc(e)))},e.length!==0),mc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Ed(e,`An error occurred in Effect.tryPromise`):e.catch;return hc(function(e,r){let i=e=>sc(()=>{try{return ac(Mt(()=>n(e)))}catch(e){return dc(e)}});try{t(r).then(t=>e(rc(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},hc=function(){let e=_n({op:`Async`,[zt](e){let t=!1,n=!1,r=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,r=>{t||(t=!0,n?e.evaluate(r):n=r)},r?.signal);return n===!1?(n=!0,e.yieldWith(()=>{t=!0}),r===void 0&&i===void 0||e._stack.push(gc(()=>(t=!0,r?.abort(),i??tl))),Ut):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),gc=vn({op:`AsyncFinalizer`,[Ht](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Cu))},[Vt](e,t){return bs(e)?Uc(Kl(Cn(e),this[S]()),()=>ic(e)):ic(e)}}),_c=e=>hc(e,e.length>=2),vc=_c(u),yc=(...e)=>{if(e.length===1){let t=e[0];return sc(()=>Tc(t()))}let[t,n]=e;return sc(()=>Tc(n.call(t.self)))},bc=(e,t)=>typeof e==`function`?e:t.shift().bind(e.self),xc=(e,...t)=>{let n=bc(e,t),r=t.length===0?function(){return sc(()=>Tc(n.apply(this,arguments)))}:function(){let e=sc(()=>Tc(n.apply(this,arguments)));for(let n=0;n<t.length;n++)e=t[n](e,...arguments);return e};return Sc(n.length,r)},Sc=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),Cc=(e,...t)=>{let n=bc(e,t);return Sc(n.length,t.length===0?function(){return wc(()=>n.apply(this,arguments))}:function(){let e=wc(()=>n.apply(this,arguments));for(let n of t)e=n(e,...arguments);return e})},wc=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return rc(r.value);let i=r.value;if(i&&i._tag===`Success`)n=i.value;else{if(i&&i._tag===`Failure`)return r.value;{let n=!0;return sc(()=>n?(n=!1,Uc(r.value,e=>Tc(t,e))):sc(()=>Tc(e())))}}}}catch(e){return dc(e)}},Tc=function(){let e=_n({op:`Iterator`,[Bt](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return rc(r.value);if(!Wc(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[zt](e){return this[Bt](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),Ec=r(2,(e,t)=>new kc(e,Ac,rc(t))),Dc=function(e){return e._stack.push(this),this[S]},Oc=_n({op:`OnSuccess`,[zt]:Dc}),kc=function(e,t,n){this[S]=e,this[Bt]=t,this.payload=n};kc.prototype=Oc;var Ac=function(){return this.payload},jc=function(e,t){return t.succeedWith(this.payload)},Mc=(()=>{let e=kt();if(e===0)return!1;let t=`~effect/Effect/stackProbe`,n={[t]:function(){return Error()}};At(1);let r=n[t]();return At(e),r.stack?.includes(`[as `+t+`]`)===!0})(),Nc=function(e,t){let n=this.payload;return t.succeedWith(Mc?n(e):Mt(()=>n(e)))},Pc=function(e){let t=this.payload;return t(e)},Fc=function(e){let t=this.payload;return new kc(t(e),jc,e)},Ic=function(e){return new kc(this.payload,jc,e)},Lc=e=>qc(e,T),Rc=r(2,(e,t)=>new kc(e,Kt(t)?Ac:Pc,t)),zc=r(2,(e,t)=>new kc(e,Kt(t)?Ic:Fc,t)),Bc=e=>new kc(e,Ac,tl),Vc=(e,t)=>C(n=>{let r=new Set;return uu(n,()=>r.size===0?void 0:nc(r)),_c(i=>{let a=!1,o=0;for(let s of e){if(a)break;let e=o++,c=Ru(n,s,!0,!0,!1);r.add(c),c.addObserver(o=>{r.delete(c);let s=!a;a=!0,i(o),s&&t?.onWinner&&t.onWinner({fiber:c,index:e,parentFiber:n})})}})}),Hc=r(e=>Kt(e[1]),(e,t,n)=>Vc([e,t],n)),Uc=r(2,(e,t)=>new kc(e,Pc,t)),Wc=e=>e[It]!==void 0,Gc=r(2,(e,t)=>Wc(e)?e._tag===`Success`?t(e.value):e:Uc(e,t)),Kc=e=>Uc(e,i),qc=r(2,(e,t)=>new kc(e,Nc,t)),Jc=r(2,(e,t)=>Wc(e)?nl(e,t):qc(e,t)),Yc=r(2,(e,t)=>Wc(e)?rl(e,t):Tl(e,t)),Xc=e=>Cn(ps(e)),Zc=e=>e._tag===`Success`,Qc=e=>e._tag===`Failure`,$c=e=>e._tag===`Failure`?mi(e.cause):hi(e),el=e=>e._tag===`Failure`&&bs(e.cause),tl=bn(void 0),nl=r(2,(e,t)=>e._tag===`Success`?bn(t(e.value)):e),rl=r(2,(e,t)=>e._tag===`Success`?bn(t.onSuccess(e.value)):Cn(Ts(e.cause,t.onFailure))),il=r(2,(e,t)=>Zc(e)?t:e),al=r(2,(e,t)=>Zc(e)?t.onSuccess(e.value):t.onFailure(e.cause)),ol=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?tl:Cn(rn(t))},sl=r(2,(e,t)=>C(n=>{let r=n.context,i=t(r);return r===i||(n.setContext(i),uu(n,()=>{n.setContext(r)})),e})),cl=r(3,(e,t,n)=>sl(e,e=>{let r=ri(e,t),i=n(r);return r===i?e:$r(e,t,i)})),ll=()=>ul,ul=C(e=>rc(e.context)),dl=e=>C(t=>e(t.context)),fl=r(2,(e,t)=>Wc(e)?e:sl(e,li(t))),pl=function(){return arguments.length===1?r(2,(e,t)=>ml(e,arguments[0],t)):r(3,(e,t,n)=>ml(e,t,n)).apply(this,arguments)},ml=(e,t,n)=>sl(e,$r(t,n)),hl=r(2,(e,t)=>Uc(t,t=>t?Lc(e):lc)),gl=r(e=>Kt(e[0]),(e,t)=>ku({while:o,body:a(t?.disableYield?e:Uc(e,e=>cc)),step:u})),_l=r(2,(e,t)=>new yl(e,t.length===1?t:e=>t(e))),vl=_n({op:`OnFailure`,[zt]:Dc}),yl=function(e,t){this[S]=e,this[Vt]=t};yl.prototype=vl;var bl=r(3,(e,t,n)=>_l(e,e=>t(e)?n(e):ic(e))),xl=r(3,(e,t,n)=>_l(e,e=>{let r=t(e);return yi(r)?ic(r.failure):n(r.success,e)})),Sl=r(2,(e,t)=>xl(e,ys,e=>t(e))),Cl=r(2,(e,t)=>_l(e,e=>Rc(t(e),ic(e)))),wl=r(2,(e,t)=>_l(e,e=>ic(Ts(e,t)))),Tl=r(2,(e,t)=>Al(e,{onFailure:e=>ic(Ts(e,t.onFailure)),onSuccess:e=>oc(()=>t.onSuccess(e))})),El=e=>Sl(e,dc),Dl=e=>e===`Unhandled`?(...e)=>C(t=>{let n=t.getRef(ss);return n===void 0?fc:Fd(n)(...e)}):Fd(e===!0?void 0:e),Ol=r(e=>Kt(e[0]),(e,t)=>{if(!t?.log)return Nl(e,{onFailure:e=>fc,onSuccess:e=>fc});let n=Dl(t.log);return Al(e,{onFailure(e){let r=ys(e);return yi(r)?ic(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>fc})}),kl=r(e=>Kt(e[0]),(e,t)=>{if(!t?.log)return Al(e,{onFailure:e=>fc,onSuccess:e=>fc});let n=Dl(t.log);return Al(e,{onFailure:e=>t.message===void 0?n(e):n(t.message,e),onSuccess:e=>fc})}),Al=r(2,(e,t)=>new Ml(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),jl=_n({op:`OnSuccessAndFailure`,[zt]:Dc}),Ml=function(e,t,n){this[S]=e,this[Bt]=t,this[Vt]=n};Ml.prototype=jl;var Nl=r(2,(e,t)=>Al(e,{onFailure:e=>{let n=ys(e);return yi(n)?ic(n.failure):t.onFailure(n.success)},onSuccess:t.onSuccess})),Pl=e=>Wc(e)?bn(e):Fl(e),Fl=vn({op:`Exit`,[zt](e){return e._stack.push(this),this[S]},[Bt](e,t,n){return t.succeedWith(n??bn(e))},[Vt](e,t,n){return t.succeedWith(n??Cn(e))}}),Il=r(2,(e,t)=>Uc(zl(e,t.duration),e=>E(e)?t.orElse():rc(e.value))),Ll=e=>new Sd(`Operation timed out after '${Co(e)}'`),Rl=r(2,(e,t)=>{let n=Xa(t);return Il(e,{duration:n,orElse:()=>ac(Ll(n))})}),zl=r(2,(e,t)=>Hc(Lc(e),Ec(bd(t),w()))),Bl=`~effect/Scope`,Vl=`~effect/Scope/Closeable`,Hl=Nr(`effect/Scope`),Ul=(e,t)=>C(n=>(Eu(n),Wl(e,t)??fc)),Wl=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&Ql(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return Gl(n.finalizer,t);let r=n.finalizers;return r.size===1?Gl(r.values().next().value,t):ql(e,r,t)},Gl=(e,t)=>{try{return e(t)}catch(e){return Tn(e)}},Kl=(e,t)=>Zc(e)?t:_l(t,t=>ic(vs(on(e.cause,t)))),ql=xc(function*(e,t,n){let r=[],i=[],a=Array.from(t),o=Us();for(let t=a.length-1;t>=0;t--){let[s,c]=a[t];e.strategy===`sequential`?r.push(yield*Pl(Gl(c,n))):s!==o&&i.push(Ru(o,Gl(c,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*Qs(i)),yield*ol(r)}),Jl=(e,t)=>{let n=eu(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(Zl(e,n,e=>Ul(n,e)),n)},Yl=(e,t)=>sc(()=>e.state._tag===`Closed`?t(e.state.exit):(Zl(e,{},t),fc)),Xl=(e,t)=>Yl(e,a(t)),Zl=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0||(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0),r.finalizers.set(t,n)}},Ql=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=tu:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=tu))},$l=e=>eu(e,void 0),eu=(e=`sequential`,t)=>({[Vl]:Vl,[Bl]:Bl,strategy:e,parent:t,state:tu}),tu={_tag:`Empty`},nu=Hl,ru=pl(Hl),iu=e=>C(t=>{let n=t.context,r=$l();return t.setContext($r(t.context,Hl,r)),uu(t,e=>(t.setContext(n),Wl(r,e))),e}),au=e=>sc(()=>{let t=$l();return du(e(t),e=>sc(()=>Wl(t,e)??fc))}),ou=(e,t,n)=>dl(r=>Ou(i=>Uc(nu,a=>zc(n?.interruptible?i(e):e,e=>Yl(a,n=>fl(t(e,n),r)))))),su=e=>Uc(nu,t=>dl(n=>Yl(t,t=>fl(e(t),n)))),cu=function(){let e=_n({op:`OnExit`,[zt](e){return e._stack.push(this),this.effect},[Ht](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(Cu),e.interruptible=!1)},[Bt](e,t,n){n??=bn(e);let r;try{r=this.onExit(n)}catch(e){r=Tn(e)}return r?Uc(r,e=>n):n},[Vt](e,t,n){n??=Cn(e);let r;try{r=this.onExit(n)}catch(e){r=Tn(e)}return r?Uc(Kl(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),lu=(e,t,n)=>new cu(e,t,n),uu=(e,t)=>{e._stack.push(new cu(void 0,t,void 0))},du=r(2,lu),fu=r(2,(e,t)=>du(e,e=>t)),pu=r(3,(e,t,n)=>du(e,e=>{let r=t(e);return yi(r)?fc:n(r.success,e)})),mu=r(2,(e,t)=>pu(e,$c,t)),hu=r(3,(e,t,n)=>du(e,e=>{if(e._tag!==`Failure`)return fc;let r=t(e.cause);return yi(r)?fc:n(r.success,e.cause)})),gu=r(2,(e,t)=>hu(xs,t)(e)),_u=a(1/0),vu=(e,t)=>{let n=0,r,i,a=(e,t)=>(t.awaiters++,uu(e,()=>{if(!(--t.awaiters>0||t.done))return i===t&&(i=void 0),ec(t.fiber)}),$s(t.fiber));return[C(o=>{if(i!==void 0)return o===i.fiber?$s(i.fiber):a(o,i);if(r!==void 0&&(n===1/0||o.getRef(pd).currentTimeMillisUnsafe()<n))return r;r=void 0;let s=o.getRef(pd),c={fiber:new Ws(o.context),awaiters:0,done:!1};i=c;let l=a(o,c);return c.fiber.evaluate(lu(e,e=>{if(c.done=!0,i!==c||(i=void 0,el(e)))return;let a=t(e);n=a===1/0?1/0:s.currentTimeMillisUnsafe()+a,r=e})),c.fiber._exit??l}),oc(()=>{i=void 0,r=void 0})]},yu=e=>oc(()=>vu(e,_u)[0]),bu=C(e=>ic(ps(e.id))),xu=e=>C(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(Cu)),e)),Su=vn({op:`SetInterruptible`,[Ht](e){if(e.interruptible=this[S],e._interruptedCause&&e.interruptible)return()=>ic(e._interruptedCause)}}),Cu=Su(!0),wu=Su(!1),Tu=e=>{if(e.interruptible=!0,e._stack.push(wu),e._interruptedCause)return ic(e._interruptedCause)},Eu=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(Cu))},Du=e=>C(t=>t.interruptible?e:Tu(t)??e),Ou=e=>C(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Cu),e(Du)):e(i)),ku=vn({op:`While`,[Bt](e,t){return this[S].step(e),this[`~effect/Effect/args`].while()?(t._stack.push(this),this[S].body()):tl},[zt](e){return this[`~effect/Effect/args`].while()?(e._stack.push(this),this[S].body()):tl}}),Au=r(e=>typeof e[1]==`function`,(e,t,n)=>sc(()=>{let r=Mu(n?.concurrency);if(r===1)return ju(e,t,n);let i=Li(e),a=i.length;if(a===0)return n?.discard?fc:rc([]);let o=n?.discard?void 0:Array(a),s=Iu({f:t,out:o},i,{concurrency:r});return s?Ec(s,o):rc(o)})),ju=(e,t,n)=>sc(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return Ec(ku({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Mu=e=>e===`unbounded`?1/0:Math.max(1,e??1),Nu=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>Uc(Pl(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??fc),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!Wc(c))return r(e,i,a,o,c);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return i},Pu=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f,p,m=e=>{let t=Tn(e);return f=t,c=!0,u&&u.size>0?Uc(xu(nc(Array.from(u))),()=>f??t):t},h=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],g=p??t(e,o,a);if(Wc(g)){if(f=n(e,o,g,a),f)break}else if(l){p=void 0;let t=Ru(l,g,!0,!0,`inherit`);if(t._exit){if(f=n(e,o,t._exit,a),f)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(f){if(a._tag===`Failure`){let e=a.cause.reasons.filter(e=>e._tag!==`Interrupt`);if(e.length>0){let t=rn(e);f=Cn(f._tag===`Failure`?vs(on(f.cause,t)):t)}}}else{let t=n(e,o,a,r);t&&(f=t,h())}if(i){let e=h();e&&d(e)}else c&&u.size===0&&d(f??fc)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return _c(e=>{l=Us(),u=new Set,p=g,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):sc(()=>(f??=tl,Uc(u?nc(u):fc,()=>f?._tag===`Failure`?f:fc)))})}if(c=!0,f){if(u&&u.size>0){let e=Ys(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||f._tag===`Failure`)return f}else if(d){if(u)u.size===0&&d(fc);else return tl}};return h()}},Fu=()=>e=>Pu(e),Iu=Pu({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),Lu=r(e=>Kt(e[0]),(e,t)=>C(n=>(Bd(),rc(Ru(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),Ru=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Ws(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=Hs(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},zu=e=>()=>C(t=>t===e?fc:ec(e)),Bu=r(e=>Kt(e[0]),(e,t,n)=>C(r=>{let i=t.state._tag===`Closed`?new Ws(r.context):Ru(r,e,n?.startImmediately,!0,n?.uninterruptible);return i._exit||(t.state._tag===`Closed`?i.interruptUnsafe(r.id,Ys(r)):(Zl(t,i,zu(i)),i.addObserver(()=>Ql(t,i)))),rc(i)})),Vu=r(e=>Kt(e[0]),(e,t)=>Uc(nu,n=>Bu(e,n,t))),Hu=e=>(t,n)=>{let r=new Ws(n?.scheduler?$r(e,To,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Uu=r(2,(e,t)=>e._exit?e:t.state._tag===`Closed`?(e.interruptUnsafe(e.id),e):(Ql(t,e),Zl(t,e,zu(e)),e.addObserver(()=>Ql(t,e)),e)),Wu=Hu(Xr()),Gu=e=>{let t=Hu(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},Ku=(e=>{let t=Gu(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw Es(e.cause);return e.value})})(Xr()),qu=e=>{let t=Hu(e);return e=>{if(Wc(e))return e;let n=new Ao(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??Tn(new wd(r))}},Ju=qu(Xr()),Yu=(e=>{let t=qu(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw Es(n.cause);return n.value}})(Xr()),Xu=rc(!0),Zu=rc(!1),Qu=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return Xu;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],Xu}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](tl)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](tl)}open=C(e=>this._isOpen?Zu:(this._isOpen=!0,this.scheduleUnsafe(e)));release=C(e=>this._isOpen?Zu:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=_c(e=>this._isOpen?e(fc):(this.waiters.push(e),oc(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=oc(()=>this.closeUnsafe());whenOpen=e=>Uc(this.await,()=>e);isOpen(){return this._isOpen}},$u=e=>new Qu(e??!1),ed=e=>oc(()=>$u(e)),td=BigInt(0),nd={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:td,endTime:td,exit:tl},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},rd=e=>Object.assign(Object.create(nd),e),id=e=>e?ii(e.annotations,Ko)?e._tag===`Span`?id(Sr(e.parent)):w():T(e):w(),ad=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&ii(n.annotations,Ko),i=n?.parent===void 0?n?.root?w():id(e.cache.span):T(n.parent),a;if(r)a=rd({name:t,parent:i,annotations:$r(n?.annotations??Xr(),Ko,!0)});else{let r=e.cache.tracer??Xo,o=e.getRef(pd),s=e.getRef(ts),c=e.getRef(ns),l=e.getRef(rs),u=n?.level??e.getRef(qo),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??Xr(),links:d,startTime:s?o.currentTimeNanosUnsafe():td,kind:n?.kind??`internal`,root:n?.root??!1,sampled:n?.sampled??(D(i)&&i.value.sampled===!1?!1:!Od(e.getRef(Jo),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},od=(e,t)=>xu(C(n=>{let r=ri(n.context,Hl),i=ad(n,e,t??{}),a=n.getRef(pd),o=n.getRef(ts);return Ec(Yl(r,e=>cd(i,e,a,o)),i)})),sd=(e,t)=>(t=typeof t==`function`?t:l,cl($o,n=>({name:e,stack:t,parent:n}))),cd=(e,t,n,r)=>oc(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():td,t)}),ld=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return C(t=>{let i=ad(t,e,n),a=t.getRef(pd),o=t.getRef(ts);return uu(t,e=>cd(i,e,a,o)),r(i)})},ud=pl(Wo),dd=function(){let e=Kt(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=i;return t._tag===`Span`&&(n=ls(n),r=sd(t.name,n?.captureStackTrace)),e?ud(r(arguments[0]),t):e=>ud(r(e),t)},fd=function(){let e=typeof arguments[0]!=`string`,t=e?arguments[1]:arguments[0],n=ls(arguments[2]);if(e){let e=arguments[0];return ld(t,arguments[2],t=>dd(e,t,n))}let r=typeof arguments[1]==`function`?arguments[1]:void 0,i=r?void 0:arguments[1];return(e,...a)=>ld(t,r?r(...a):i,t=>dd(e,t,n))},pd=k(`effect/Clock`,{defaultValue:()=>new hd}),md=2**31-1,hd=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=oc(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return vd()}currentTimeNanos=oc(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return _d()}monotonicTimeNanos=oc(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(go(e))}sleepMillis(e){return e<=0?cc:Number.isFinite(e)?_c(t=>{let n=e>md?this.sleepMillis(e-md):fc,r=setTimeout(()=>t(n),Math.min(e,md));return oc(()=>clearTimeout(r))}):vc}},gd=BigInt(1e6),_d=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*gd;return e>t&&(t=e),t}}(),vd=function(){let e=BigInt(1e9),t;return()=>{let n=_d(),r=BigInt(Date.now())*gd;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),yd=e=>C(t=>e(t.getRef(pd))),bd=e=>yd(t=>t.sleep(Xa(e))),xd=`~effect/Cause/TimeoutError`,Sd=class extends On(`TimeoutError`){[xd]=xd;constructor(e){super({message:e})}},Cd=`~effect/Cause/AsyncFiberError`,wd=class extends On(`AsyncFiberError`){[Cd]=Cd;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Td=`~effect/Cause/UnknownError`,Ed=class extends On(`UnknownError`){[Td]=Td;constructor(e,t){super({message:t,cause:e})}},Dd=k(`effect/Console`,{defaultValue:()=>globalThis.console}),Od=mr(fr(dr,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),kd=k(`effect/Logger/CurrentLoggers`,{defaultValue:()=>new Set([Rd,zd])}),Ad=k(`effect/Logger/LogToStderr`,{defaultValue:s}),jd={"~effect/Logger":{_Message:i,_Output:i},pipe(){return e(this,arguments)}},Md=e=>{let t=Object.create(jd);return t.log=e,t},Nd=e=>e.replace(/[\s="]/g,`_`),Pd=(e,t)=>`${Nd(e[0])}=${t-e[1]}ms`,Fd=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];Xt(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?rn(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=cn),C(r=>{let i=e??r.cache.logLevel;if(Od(r.cache.minimumLogLevel,i))return fc;let a=r.getRef(pd),o=r.getRef(kd);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return fc})},Id={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Id.gray,Id.blue,Id.green,Id.yellow,Id.red,Id.bgBrightRed,Id.black;var Ld=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,Rd=Md(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(Fs(e));let o=t.getTime(),s=n.getRef(cs),c=``;for(let e of s)c+=` ${Pd(e,o)}`;let l=n.getRef(is);Object.keys(l).length>0&&a.push(l);let u=n.getRef(Dd);(n.getRef(Ad)?u.error:u.log)(`[${Ld(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),zd=Md(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(pd),a=t.getRef(is),o=t.cache.span;if(o===void 0||o._tag===`ExternalSpan`||o.status._tag===`Ended`)return;let s={};for(let[e,t]of Object.entries(a))Nt(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=Fs(e)),o.event(Tt(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)});function Bd(){Js.interruptChildren??=Xs}var Vd=Xt,Hd=Zt,Ud=pn,Wd=rn,Gd=dn,Kd=e=>new nn(e),qd=e=>new un(e),Jd=fs,Yd=ws,Xd=Ts,Zd=on,Qd=Es,$d=gs,ef=bs,tf=Ss,nf=An,rf=Pn,af=qt,of=bn,sf=Cn,cf=wn,lf=Tn,uf=Xc,df=tl,ff=Zc,pf=Qc,mf=el,hf=al,gf=ol,_f={"~effect/Deferred":{_A:i,_E:i},pipe(){return e(this,arguments)}},vf=function(){this.resumes=void 0,this.effect=void 0};vf.prototype=_f;var yf=()=>new vf,bf=e=>_c(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),oc(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),xf=r(2,(e,t)=>oc(()=>Ef(e,t))),Sf=r(2,(e,t)=>xf(e,Cn(t))),Cf=r(2,(e,t)=>Sf(e,ps(t))),wf=e=>e.effect!==void 0,Tf=r(2,(e,t)=>xf(e,bn(t))),Ef=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},Df=ts,Of=Hl,kf=$l,Af=ru,jf=Yl,Mf=Xl,Nf=Jl,Pf=Ul,Ff=`~effect/Layer`,If=`~effect/Layer/MemoMap`,Lf=(e,t)=>{let n={observers:0,deferred:yf(),scope:kf(),finalizer:r=>sc(()=>--n.observers>0?fc:(e.map.delete(t),Pf(n.scope,r)))};return n},Rf=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,Zl(t,{},e.finalizer),!0),zf={[Ff]:{_ROut:i,_E:i,_RIn:i},pipe(){return e(this,arguments)}},Bf=e=>{let t=Object.create(zf);return t.build=e,t},Vf=e=>Bf((t,n)=>{let r=Nf(n);return du(e(t,r),e=>e._tag===`Failure`?Pf(r,e):fc)}),Hf=e=>{let t=Vf((n,r)=>n.getOrElseMemoize(t,r,e));return t},Uf=class{get[If](){return If}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(Rf(n,t),n.deferred.effect??bf(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return sc(()=>{let r;return lu(sc(()=>{let i=this.get(e,t);if(i)return i;let a=Lf(this,e);return Rf(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&Ef(r,e)})})}},Wf=()=>new Uf,Gf=e=>new Uf(e),Kf=class e extends Nr()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=ti(t,e);return n?Gf(n):Wf()}},qf=r(3,(e,t,n)=>pl(qc(sc(()=>e.build(t,n)),$r(Kf,t)),Kf,t)),Jf=r(2,(e,t)=>C(n=>qf(e,Kf.forkOrCreate(n.context),t))),Yf=function(){return arguments.length===1?e=>Xf(Qr(arguments[0],e)):Xf(Qr(arguments[0],arguments[1]))},Xf=e=>Bf(a(rc(e))),Zf=Xf(Xr()),Qf=function(){return arguments.length===1?e=>$f(arguments[0],e):$f(arguments[0],arguments[1])},$f=(e,t)=>ep(qc(t,t=>Qr(e,t))),ep=e=>Hf((t,n)=>Af(e,n)),tp=(e,t,n)=>{let r=Nf(n,`parallel`);return Au(e,e=>e.build(t,Nf(r,`sequential`)),{concurrency:e.length}).pipe(qc(e=>ui(...e)))},np=(...e)=>Hf((t,n)=>tp(e,t,n)),rp=r(2,(e,t)=>np(e,...Array.isArray(t)?t:[t])),ip=(e,t,n)=>Hf((r,i)=>Uc(Array.isArray(t)?tp(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(fl(t),qc(e=>n(e,t))))),ap=r(2,(e,t)=>ip(e,t,i)),op=pd,sp=`~effect/DateTime`,cp=`~effect/DateTime/TimeZone`,lp={[sp]:sp,pipe(){return e(this,arguments)},[Ct](){return this.toString()},toJSON(){return vp(this).toJSON()}},up={...lp,_tag:`Utc`,[be](){return De(this.epochMilliseconds)},[ze](e){return _p(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${vp(this).toJSON()})`}},dp={...lp,_tag:`Zoned`,[be](){return Ce(De(this.epochMilliseconds))(x(this.zone))},[ze](e){return _p(e)&&e._tag===`Zoned`&&this.epochMilliseconds===e.epochMilliseconds&&Be(this.zone,e.zone)},toString(){return`DateTime.Zoned(${ree(this)})`}},fp={[cp]:cp,[Ct](){return this.toString()}};({...fp}),{...fp};var pp={value:void 0,enumerable:!1,writable:!0},mp=new WeakMap,hp=(e,t)=>({get(){return Object.isExtensible(this)?void 0:mp.get(this)?.[e]},set(n){if(Object.isExtensible(this)){for(let e of t)Object.defineProperty(this,e,pp);this[e]=n}else{let t=mp.get(this);t===void 0&&(t={},mp.set(this,t)),t[e]=n}}}),gp=[`partsUtc`,`adjustedEpochMilliseconds`,`partsAdjusted`];Object.defineProperty(up,"partsUtc",hp(`partsUtc`,[`partsUtc`])),Object.defineProperties(dp,{partsUtc:hp(`partsUtc`,gp),adjustedEpochMilliseconds:hp(`adjustedEpochMilliseconds`,gp),partsAdjusted:hp(`partsAdjusted`,gp)});var _p=e=>b(e,sp),vp=e=>new Date(e.epochMilliseconds),yp=e=>{if(e._tag===`Utc`)return new Date(e.epochMilliseconds);if(e.zone._tag===`Offset`)return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=!1,n=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>e.type===`era`?(t=e.value===`BC`,!1):e.type!==`literal`),r=Number(n[2].value),i=new Date(0);return i.setUTCFullYear(t?1-r:r,Number(n[0].value)-1,Number(n[1].value)),i.setUTCHours(Number(n[3].value),Number(n[4].value),Number(n[5].value),n[6]?.type===`fractionalSecond`?Number(n[6].value):(e.epochMilliseconds%1e3+1e3)%1e3),e.adjustedEpochMilliseconds=i.getTime(),i},bp=e=>yp(e).getTime()-nee(e),xp=e=>{let t=Math.abs(e),n=Math.floor(t/36e5),r=Math.round(t%36e5/6e4);return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},tee=e=>xp(bp(e)),nee=e=>e.epochMilliseconds,Sp=e=>{let t=yp(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${tee(e)}`},ree=e=>e.zone._tag===`Offset`?Sp(e):`${Sp(e)}[${e.zone.id}]`;globalThis.Number;var Cp=e=>e+1,wp=e=>e-1,iee=gr(dr);globalThis.String;var Tp=e=>e.toLowerCase(),Ep=e=>e.trim(),aee=(e,t)=>n=>n.slice(e,t),Dp=e=>e.length===0,oee=e=>e.length>0,Op=r(2,(e,t)=>{let n=e.split(t);return di(n)?n:[e]}),see=(e,t)=>n=>n.startsWith(e,t),cee=e=>t=>kr(T(t.lastIndexOf(e)),iee(0)),kp=r(2,(e,t)=>xl(e,Np,e=>t(e))),Ap=e=>e.reasons.some(jp),jp=e=>e._tag===`Fail`&&nf(e.error),Mp=e=>{let t,n=!1;for(let r of e.reasons)jp(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?hi(e):n?hi(Wd(e.reasons.filter(e=>!jp(e)))):mi(t)},Np=e=>{let t=Mp(e);return yi(t)?t:mi(t.success.value)},Pp=e=>{let t=Mp(e);return yi(t)?sf(t.failure):of(t.success.value)},Fp=(e,t,n)=>au(r=>Uc(n?.local?qf(t,Wf(),r):Jf(t,r),t=>fl(e,t))),Ip=r(e=>Kt(e[0]),(e,t,n)=>Jr(t)?fl(e,t):Fp(e,Array.isArray(t)?np(...t):t,n)),Lp=Kt,Rp=Au,zp=ku,Bp=eee,Vp=mc,j=rc,Hp=lc,Up=sc,M=oc,N=fc,Wp=_c,Gp=vc,P=yc,Kp=ac,qp=ic,Jp=uc,Yp=dc,Xp=pc,Zp=cc,Qp=C,F=Uc,$p=Kc,em=Rc,tm=zc,nm=Pl,rm=qc,im=Ec,am=Bc,om=Sl,sm=_l,cm=bl,lm=wl,um=El,dm=Cl,fm=Ol,pm=kl,mm=Rl,hm=bd,gm=Hc,_m=hl,vm=Al,ym=ll,bm=dl,xm=Ip,Sm=fl,Cm=sl,wm=pl,Tm=nu,Em=iu,Dm=ou,Om=su,km=fu,Am=mu,jm=lu,Mm=du,Nm=yu,Pm=bu,Fm=Du,Im=gu,Lm=xu,Rm=Ou,zm=gl,Bm=od,Vm=ld,Hm=fd,Um=dd,Wm=Lu,Gm=Bu,Km=Vu,qm=Wu,Jm=Hu,Ym=Ku,Xm=Yu,Zm=Ju,Qm=xc,$m=Fd(`Error`),eh=Jc,th=Yc,nh=Gc,rh=Cc,ih=$s,ah=ec,oh=nc,sh=Us,ch=Uu,lh=Symbol.for(`effect/MutableList/Empty`),uh=()=>({head:void 0,tail:void 0,length:0}),dh=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},fh=()=>({array:[],mutable:!0,offset:0,next:void 0}),ph=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=fh(),e.tail=e.tail.next):e.head=e.tail=fh(),e.tail.array.push(t),e.length++},mh=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||=e.head,e.length++},hh=(e,t)=>gh(e,Array.from(t),!0),gh=(e,t,n=!1)=>{if(t.length===0)return 0;let r={array:t,mutable:n,offset:0,next:void 0};return e.head?e.tail=e.tail.next=r:e.head=e.tail=r,e.length+=t.length,t.length},_h=e=>{e.head=e.tail=void 0,e.length=0},vh=(e,t)=>{if(t=fi(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return _h(e),t}let n=Array(t),r=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(n[r++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,r===t)return e.head=i.offset===i.array.length&&i.next?i.next:i,e.length-=t,e.length===0?_h(e):dh(e),n;i=i.next}return _h(e),n},yh=e=>vh(e,e.length),bh=e=>{if(!e.head)return lh;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:_h(e):dh(e),t},xh=(e,t)=>{let n=[],r=e.head,i=0;for(;r;){for(let e=r.offset;e<r.array.length;e++)t(r.array[e],i++)&&n.push(r.array[e]);r=r.next}n.length===0?_h(e):(e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length)},Sh=(e,t)=>xh(e,e=>e!==t),Ch=`~effect/Queue`,wh=`~effect/Queue/Enqueue`,Th=`~effect/Queue/Dequeue`,Eh={_A:i,_E:i},Dh={[Ch]:Eh,[wh]:Eh,[Th]:Eh,...Wt,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:Uh(this)}}},Oh=e=>C(t=>{let n=Object.create(Dh);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=uh(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},rc(n)}),kh=e=>Oh({capacity:e}),Ah=r(2,(e,t)=>sc(()=>jh(e,t)?Gh:e.state._tag===`Open`&&e.strategy===`suspend`?eg(e,t):Wh)),jh=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(bh(e.messages),ph(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(ph(e.messages,t),Jh(e),!0):(ph(e.messages,t),Yh(e),!0):!1,Mh=r(2,(e,t)=>_c(n=>{let r=Nh(e,t);return r.length===0||e.strategy===`dropping`?n(bn(r)):tg(e,{_tag:`Array`,remaining:r,offset:0,resume:n})})),Nh=(e,t)=>{if(e.state._tag!==`Open`)return Li(t);if(e.capacity===1/0||e.strategy===`sliding`)return hh(e.messages,t),e.strategy===`sliding`&&vh(e.messages,e.messages.length-e.capacity),Yh(e),[];let n=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(n===0)return Li(t);let r=[],i=0;for(let a of t)i<n?ph(e.messages,a):r.push(a),i++;return Yh(e),r},Ph=r(2,(e,t)=>oc(()=>Fh(e,t))),Fh=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=il(Cn(t),Kh);return e.state.offers.size===0&&e.messages.length===0?(ag(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},Yh(e),!0)},Ih=e=>Ph(e,ln(Mn())),Lh=e=>oc(()=>Rh(e)),Rh=e=>{if(e.state._tag===`Done`)return!1;_h(e.messages);let t=e.state.offers;ag(e,e.state._tag===`Open`?qh:e.state.exit);for(let e of t)ng(e);return!0},zh=e=>Bh(e,1,1/0),Bh=r(3,(e,t,n)=>(t=fi(t),n=fi(n),Zh(()=>Xh(e,t,n)??Rc($h(e,()=>Qh(e,t)),Bh(e,t,n))))),Vh=e=>Zh(()=>Hh(e)??Rc($h(e,()=>Qh(e,1)),Vh(e))),Hh=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=bh(e.messages);return ig(e),bn(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=rg(e.state.offers);return ig(e),bn(t)}},Uh=e=>e.state._tag===`Done`?0:e.messages.length,Wh=bn(!1),Gh=bn(!0),Kh=wn(Mn()),qh=Xc(),Jh=e=>{if(e.state._tag!==`Done`&&e.state.takers.size!==0){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(tl),e.messages.length===0))break}},Yh=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,Jh(e)},0))},Xh=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return bn([]);if(!Qh(e,t))return;let r=e.messages.length>0?vh(e.messages,n):[rg(e.state.offers)];return ig(e),bn(r)},Zh=vn({op:`QueueTake`,[zt](e){let t=this[S]();return qt(t)?t[zt](e):t}}),Qh=(e,t)=>e.messages.length>=(e.state._tag===`Closing`?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!==`Done`&&e.state.offers.size>0,$h=(e,t)=>_c(n=>{if(e.state._tag===`Done`)return n(e.state.exit);if(t())return n(tl);let r={ready:t,resume:n};return e.state.takers.add(r),oc(()=>{e.state._tag!==`Done`&&e.state.takers.delete(r)})}),eg=(e,t)=>_c(n=>jh(e,t)?n(Gh):tg(e,{_tag:`Single`,message:t,resume:n})),tg=(e,t)=>{if(e.state._tag!==`Open`)return ng(t);let n=e.state.offers;return n.add(t),oc(()=>{e.state._tag!==`Done`&&(n.delete(t),e.state._tag===`Closing`&&n.size===0&&e.messages.length===0&&ag(e,e.state.exit))})},ng=e=>e._tag===`Single`?e.resume(Wh):e.resume(bn(e.remaining.slice(e.offset))),rg=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume(Gh),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(bn([]))),n},ig=e=>{if(e.state._tag===`Done`)return Ap(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0&&(ag(e,e.state.exit),Ap(e.state.exit.cause));for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;if(t._tag===`Single`)ph(e.messages,t.message),e.state.offers.delete(t),t.resume(Gh);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;ph(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(bn([]))}let r=e.state;if(r._tag===`Done`)return Ap(r.exit.cause)}return!1},ag=(e,t)=>{if(e.state._tag===`Done`)return;let n=e.state;e.state={_tag:`Done`,exit:t};for(let e of n.takers)e.resume(t);n.takers.clear();for(let e of n.awaiters)e(t);n.awaiters.clear()},og=e=>new lg(e),sg=e=>{for(let t of e.waiters)if(t.permits<=e.free)return t},cg=(e,t,n,r=i)=>C(i=>{if(e.free>=t&&sg(e)===void 0)return e.taken+=t,n();let a={permits:t,resume:void 0},o=()=>{e.waiters.delete(a)&&e.releaseUnsafe(i,0)};e.waiters.add(a),uu(i,o);let s=Uc(r(_c(t=>{sg(e)===a?t(fc):a.resume=t})),()=>sg(e)===a?(e.taken+=t,o(),n()):s);return s}),lg=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){return cg(this,e,()=>rc(e))}takeScoped(e){return Ou(t=>Uc(nu,n=>cg(this,e,()=>Xl(n,this.release(e)),t)))}takeIfAvailable(e){return sc(()=>this.free<e?rc(!1):(this.taken+=e,rc(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.free;for(let t of Array.from(this.waiters)){if(!this.waiters.has(t)||t.permits>e)continue;e-=t.permits;let n=t.resume;t.resume=void 0,n?.(fc)}},0),this.free}resize(e){return C(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),fc))}release(e){return C(t=>rc(this.releaseUnsafe(t,e)))}get releaseAll(){return C(e=>rc(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>Ou(n=>cg(this,e,()=>lu(n(t),()=>{this.releaseUnsafe(Us(),e)},!0),n))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>Ou(n=>this.free<e?lc:(this.taken+=e,lu(n(Lc(t)),()=>{this.releaseUnsafe(Us(),e)},!0)))}},ug=`~effect/BigDecimal`,dg={[ug]:ug,[be](){let e=yg(this);return Ce(Oe(String(e.value)),De(e.scale))},[ze](e){return fg(e)&&Tg(this,e)===0},toString(){return`BigDecimal(${Dg(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[Ct](){return this.toJSON()},pipe(){return e(this,arguments)}},fg=e=>b(e,ug),pg=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(dg);return n.value=e,n.scale=t,n},mg=(e,t)=>{let n=pg(e,t);return n.normalized=n,n},hg=BigInt(0),gg=BigInt(1),_g=BigInt(10),vg=mg(hg,0),yg=e=>{if(e.normalized===void 0){if(e.value===hg)e.normalized=vg;else{let t=`${e.value}`,n=bg(t);e.normalized=mg(BigInt(t.slice(0,t.length-n)),e.scale-n)}}return e.normalized},bg=e=>{let t=e.length;for(;e[t-1]===`0`;)t--;return e.length-t},xg=100,Sg=[gg],Cg=(e,t)=>e===t?0:e<t?-1:1,wg=(e,t)=>{let n=`${e.value<hg?-e.value:e.value}`,r=`${t.value<hg?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==hg)return i<hg?-1:1;let a=Math.max(n.length,r.length);return ur(n.padEnd(a,`0`),r.padEnd(a,`0`))},Tg=(e,t)=>{if(e.scale===t.scale)return Cg(e.value,t.value);let n=Eg(e),r=Eg(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>xg)return n===-1?wg(t,e):wg(e,t);let o=Sg[a]??=_g**BigInt(a);return i>0?Cg(e.value,t.value*o):Cg(e.value*o,t.value)},Eg=e=>e.value===hg?0:e.value<hg?-1:1,Dg=e=>{let t=yg(e);if(Math.abs(t.scale)>=16)return Og(t);let n=t.value<hg,r=`${n?-t.value:t.value}`,i=t.scale>0?r.padStart(t.scale+1,`0`):r.padEnd(r.length-t.scale,`0`),a=i.length-t.scale,o=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return n?`-${o}`:o},Og=e=>{if(kg(e))return`0e+0`;let t=yg(e),n=`${t.value}`,r=t.value<hg?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},kg=e=>e.value===hg,Ag=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,jg=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)jg[Ag.charCodeAt(e)]=e;jg[61]=0;var Mg=`~effect/HashMap`,Ng=5,Pg=32,Fg=Pg/4,Ig=Pg/2,Lg=31,Rg=e=>(e-=e>>>1&1431655765,e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),zg=(e,t)=>e>>>t&Lg,Bg=(e,t)=>1<<zg(e,t),Vg=(e,t)=>Rg(e&t-1);function Hg(e,t,n,r,i,a){if(t>32)throw Error(`HashMap: max depth exceeded`);let o=Bg(n,t),s=Bg(i,t);return o===s?new Xg(e,o,[Hg(e,t+Ng,n,r,i,a)]):new Xg(e,o|s,o>>>0<s>>>0?[r,a]:[a,r])}var Ug=Oe(`HashMap`),Wg=(e,t)=>Ce(x(e),x(t)),Gg=e=>{let t=0;for(let n=0;n<e.length;n++){let r=e[n];r&&(t^=r.subtreeHash())}return t},Kg=class{canEdit(e){return this.edit===e}subtreeHash(){let e=this._hash;if(e===void 0){let t=ee;e=this.computeHash(),t===ee&&(this._hash=e)}return e}},qg=class extends Kg{_tag=`EmptyNode`;edit=0;get size(){return 0}get(e,t,n){return w()}has(e,t,n){return!1}set(e,t,n,r,i,a){return a.value=!0,new Jg(e,n,r,i)}remove(e,t,n,r,i){return this}canEdit(e){return!1}computeHash(){return 0}},Jg=class e extends Kg{_tag=`LeafNode`;edit;hash;key;value;constructor(e,t,n,r){super(),this.edit=e,this.hash=t,this.key=n,this.value=r}get size(){return 1}get(e,t,n){return this.hash===t&&Be(this.key,n)?T(this.value):w()}has(e,t,n){return this.hash===t&&Be(this.key,n)}set(t,n,r,i,a,o){if(this.canEdit(t)&&(this._hash=void 0),this.hash===r&&Be(this.key,i))return Object.is(this.value,a)?this:this.canEdit(t)?(this.value=a,this):new e(t,r,i,a);if(o.value=!0,this.hash===r)return new Yg(t,r,[[this.key,this.value],[i,a]]);let s=Bg(r,n),c=Bg(this.hash,n);return s===c?new Xg(t,s,[this.set(t,n+Ng,r,i,a,o)]):new Xg(t,s|c,s>>>0<c>>>0?[new e(t,r,i,a),this]:[this,new e(t,r,i,a)])}remove(e,t,n,r,i){if(this.hash===n&&Be(this.key,r))i.value=!0;else return this}computeHash(){return Wg(this.key,this.value)}},Yg=class e extends Kg{_tag=`CollisionNode`;edit;hash;entries;constructor(e,t,n){super(),this.edit=e,this.hash=t,this.entries=n}get size(){return this.entries.length}get(e,t,n){if(this.hash!==t)return w();for(let[e,t]of this.entries)if(Be(e,n))return T(t);return w()}has(e,t,n){if(this.hash!==t)return!1;for(let[e]of this.entries)if(Be(e,n))return!0;return!1}set(t,n,r,i,a,o){if(this.canEdit(t)&&(this._hash=void 0),this.hash!==r)return o.value=!0,Hg(t,n,this.hash,this,r,new Jg(t,r,i,a));for(let n=0;n<this.entries.length;n++)if(Be(this.entries[n][0],i)){if(Object.is(this.entries[n][1],a))return this;if(this.canEdit(t))return this.entries[n]=[i,a],this;let r=[...this.entries];return r[n]=[i,a],new e(t,this.hash,r)}return o.value=!0,this.canEdit(t)?(this.entries.push([i,a]),this):new e(t,this.hash,[...this.entries,[i,a]])}remove(t,n,r,i,a){if(this.canEdit(t)&&(this._hash=void 0),this.hash!==r)return this;let o=this.entries.findIndex(([e])=>Be(e,i));if(o===-1)return this;if(a.value=!0,this.entries.length===1)return;if(this.entries.length===2){let e=this.entries[+(o===0)];return new Jg(t,this.hash,e[0],e[1])}if(this.canEdit(t))return this.entries.splice(o,1),this;let s=[...this.entries];return s.splice(o,1),new e(t,this.hash,s)}computeHash(){let e=0,t=this.entries;for(let n=0;n<t.length;n++)e^=Wg(t[n][0],t[n][1]);return e}},Xg=class e extends Kg{_tag=`IndexedNode`;edit;_size;bitmap;children;constructor(e,t,n){super(),this.edit=e,this.bitmap=t,this.children=n}get size(){return this._size===void 0&&(this._size=this.children.reduce((e,t)=>e+t.size,0)),this._size}get(e,t,n){let r=Bg(t,e);if((this.bitmap&r)===0)return w();let i=Vg(this.bitmap,r);return this.children[i].get(e+Ng,t,n)}has(e,t,n){let r=Bg(t,e);if((this.bitmap&r)===0)return!1;let i=Vg(this.bitmap,r);return this.children[i].has(e+Ng,t,n)}set(t,n,r,i,a,o){this.canEdit(t)&&(this._hash=void 0);let s=Bg(r,n),c=Vg(this.bitmap,s);if((this.bitmap&s)!==0){let s=this.children[c],l=s.set(t,n+Ng,r,i,a,o);if(s===l)return this;if(this.canEdit(t))return this.children[c]=l,this;let u=[...this.children];return u[c]=l,new e(t,this.bitmap,u)}{o.value=!0;let n=new Jg(t,r,i,a),l=this.bitmap|s;if(this.canEdit(t))return this.children.splice(c,0,n),this.bitmap=l,this._size=void 0,this.children.length>Ig?this.expand(t,l,this.children):this;let u=[...this.children];return u.splice(c,0,n),u.length>Ig?this.expand(t,l,u):new e(t,l,u)}}remove(t,n,r,i,a){this.canEdit(t)&&(this._hash=void 0);let o=Bg(r,n);if((this.bitmap&o)===0)return this;let s=Vg(this.bitmap,o),c=this.children[s],l=c.remove(t,n+Ng,r,i,a);if(!a.value)return this;if(l===void 0){let n=this.bitmap^o;if(n===0)return;if(this.children.length===2){let e=this.children[+(s===0)];if(e._tag===`LeafNode`)return e}if(this.canEdit(t))return this.children.splice(s,1),this.bitmap=n,this._size=void 0,this;let r=[...this.children];return r.splice(s,1),new e(t,n,r)}if(c===l)return this;if(this.canEdit(t))return this.children[s]=l,this;let u=[...this.children];return u[s]=l,new e(t,this.bitmap,u)}expand(e,t,n){let r=new globalThis.Array(Pg),i=0;for(let e=0;e<Pg;e++)t&1<<e&&(r[e]=n[i++]);return new Zg(e,n.length,r)}computeHash(){return Gg(this.children)}},Zg=class e extends Kg{_tag=`ArrayNode`;edit;_size;count;children;constructor(e,t,n){super(),this.edit=e,this.count=t,this.children=n}get size(){return this._size===void 0&&(this._size=this.children.reduce((e,t)=>e+(t?.size??0),0)),this._size}get(e,t,n){let r=zg(t,e),i=this.children[r];return i?i.get(e+Ng,t,n):w()}has(e,t,n){let r=zg(t,e),i=this.children[r];return i?i.has(e+Ng,t,n):!1}set(t,n,r,i,a,o){this.canEdit(t)&&(this._hash=void 0);let s=zg(r,n),c=this.children[s];if(c){let l=c.set(t,n+Ng,r,i,a,o);if(c===l)return this;if(this.canEdit(t))return this.children[s]=l,this;let u=[...this.children];return u[s]=l,new e(t,this.count,u)}{o.value=!0;let n=new Jg(t,r,i,a);if(this.canEdit(t))return this.children[s]=n,this.count++,this._size=void 0,this;let c=[...this.children];return c[s]=n,new e(t,this.count+1,c)}}remove(t,n,r,i,a){this.canEdit(t)&&(this._hash=void 0);let o=zg(r,n),s=this.children[o];if(!s)return this;let c=s.remove(t,n+Ng,r,i,a);if(!a.value)return this;let l=this.count-+!c;if(l<Fg)return this.pack(t,o,c);if(s===c)return this;if(this.canEdit(t))return this.children[o]=c,c||(this.count=l),this._size=void 0,this;let u=[...this.children];return u[o]=c,new e(t,l,u)}pack(e,t,n){let r=[],i=0,a=1;for(let e=0;e<this.children.length;e++){let o=e===t?n:this.children[e];o&&(r.push(o),i|=a),a<<=1}return new Xg(e,i,r)}computeHash(){return Gg(this.children)}},Qg=class{stack;project;entries=[];index=0;constructor(e,t){this.stack=[e],this.project=t}next(){for(;;){if(this.index<this.entries.length){let e=this.entries[this.index++];return{done:!1,value:this.project(e[0],e[1])}}if(this.stack.length===0)return{done:!0,value:void 0};let e=this.stack.pop();switch(e._tag){case`LeafNode`:{let t=e;return{done:!1,value:this.project(t.key,t.value)}}case`CollisionNode`:this.entries=e.entries,this.index=0;break;case`IndexedNode`:case`ArrayNode`:{let t=e.children;for(let e=t.length-1;e>=0;e--){let n=t[e];n&&this.stack.push(n)}}}}}[Symbol.iterator](){return this}},$g=(e,t)=>[e,t],e_=class{[Mg]=Mg;_editable;_edit;_root;_size;constructor(e,t,n,r){this._editable=e,this._edit=t,this._root=n,this._size=r}get size(){return this._size}[Symbol.iterator](){return new Qg(this._root,$g)}[ze](e){if(n_(e)){let t=e;if(this.size!==t.size)return!1;for(let[t,n]of this){let r=d(e,o_(t));if(E(r)||!Be(n,r.value))return!1}return!0}return!1}[be](){return we(Ug^this._root.subtreeHash())}[Ct](){return wt(this)}toString(){return`HashMap(${ft(Array.from(this))})`}toJSON(){return{_id:`HashMap`,values:Array.from(this).map(([e,t])=>[wt(e),wt(t)])}}pipe(){return e(this,arguments)}},t_=new qg,n_=e=>b(e,Mg),r_=()=>new e_(!1,0,t_,0),i_=(...e)=>a_(e),a_=e=>{let t=t_,n=0,r={value:!1};for(let[i,a]of e){let e=x(i);r.value=!1,t=t.set(NaN,0,e,i,a,r),r.value&&n++}return new e_(!1,0,t,n)},o_=r(2,(e,t)=>e._root.get(0,x(t),t)),s_=r(2,(e,t)=>e._root.has(0,x(t),t)),c_=(e,t,n,r)=>{let i=e,a={value:!1},o=i._editable?i._edit:NaN,s=i._root.set(o,0,n,t,r,a);return i._editable?(i._root=s,a.value&&i._size++,e):i._root===s?e:new e_(!1,i._edit,s,i._size+ +!!a.value)},l_=r(3,(e,t,n)=>c_(e,t,x(t),n)),u_=e=>new Qg(e._root,i),d_=e=>e.size,f_=(e,t,n)=>{let r=e,i={value:!1},a=r._editable?r._edit:NaN,o=r._root.remove(a,0,n,t,i);return i.value?r._editable?(r._root=o??t_,r._size--,e):o===void 0?r_():new e_(!1,r._edit,o,r._size-1):e},p_=r(2,(e,t)=>f_(e,t,x(t))),m_=r_,h_=i_,g_=o_,__=s_,v_=l_,y_=p_,b_=`~effect/HashSet`,x_=Oe(b_),S_={[be](){return we(Ce(x_,x(T_(this))))},[ze](e){return w_(e)&&k_(this)===k_(e)&&A_(this,t=>O_(e,t))},[Symbol.iterator](){return u_(T_(this))},toString(){return`HashSet(${ft(Array.from(this))})`},toJSON(){return{_id:`HashSet`,values:wt(Array.from(this))}},[Ct](){return this.toJSON()},pipe(){return e(this,arguments)}},C_=e=>{let t=Object.create(S_);return t[b_]=b_,t.keyMap=e,t},w_=e=>b(e,b_),T_=e=>e.keyMap,E_=()=>C_(r_()),D_=e=>{let t=r_();for(let n of e)t=l_(t,n,!0);return C_(t)},O_=(e,t)=>s_(T_(e),t),k_=e=>d_(T_(e)),A_=(e,t)=>{for(let n of e)if(!t(n))return!1;return!0},j_=E_,M_=D_,N_=k_,P_=`~effect/http/Cookies`,F_=`~effect/http/Cookies/Cookie`,I_={[P_]:P_,...Et,toJSON(){return{_id:`effect/Cookies`,cookies:ki(this.cookies,e=>e.toJSON())}},pipe(){return e(this,arguments)}},L_=e=>{let t=Object.create(I_);return t.cookies=e,t},R_=e=>{let t={};for(let n of e)Nt(t,n.name,n);return L_(t)},z_=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=B_(e.trim());t&&n.push(t)}return R_(n)};function B_(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n).replace(H_,``);if(!V_.test(r))return;let i=t[0].slice(n+1).replace(H_,``),a=G_(i);if(t.length===1)return Object.assign(Object.create(W_),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:if(a===void 0||!U_.test(a))break;o.maxAge=ho(parseInt(a,10));break;case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`}}}return Object.assign(Object.create(W_),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var V_=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,H_=/^[\t ]+|[\t ]+$/g,U_=/^-?[0-9]+$/,W_={[F_]:F_,...Et,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},G_=e=>{try{return decodeURIComponent(e)}catch{return e}},K_=new WeakMap,q_=e=>{if(K_.has(e))return K_.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},J_=`~effect/Redacted`,Y_=e=>b(e,J_),X_=(e,t)=>{let n=Object.create(Z_);return t?.label&&(n.label=t.label),K_.set(n,e),n},Z_={[J_]:{_A:e=>e},label:void 0,...Wt,toJSON(){return this.toString()},toString(){return`<redacted${ne(this.label)?`:`+this.label:``}>`},[be](){return x(K_.get(this))},[ze](e){return Y_(e)&&Be(K_.get(this),K_.get(e))}},Q_=q_,$_=Symbol.for(`~effect/http/Headers`),ev=Object.defineProperties(Object.create(null),{[$_]:{value:$_},[at]:{value(e){return uv(this,ii(e,fv))}},toJSON:{value(){return st(this)}},[ze]:{value(e){return nv(this,e)}},[be]:{value(){return Ae(this)}},toString:{value:Et.toString},[Ct]:{value:Et[Ct]}}),tv=e=>Object.assign(Object.create(ev),e),nv=Ni(Rn()),rv=Object.create(ev),iv=e=>{if(e===void 0)return rv;if(Symbol.iterator in e){let t=Object.create(ev);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(ev);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},av=e=>Object.setPrototypeOf(e,ev),ov=r(3,(e,t,n)=>{let r=tv(e);return r[t.toLowerCase()]=n,r}),sv=r(2,(e,t)=>tv({...e,...iv(t)})),cv=r(2,(e,t)=>{let n=tv(e);return Object.assign(n,t),n}),lv=r(2,(e,t)=>{let n=tv(e);return delete n[t.toLowerCase()],n}),uv=r(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=X_(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=X_(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),dv=(e,t)=>{let n=e.toLowerCase();for(let r=0;r<t.length;r++){let i=t[r];if(typeof i==`string`){if(i.toLowerCase()===n)return!0}else if(e.search(i)!==-1)return!0}return!1},fv=k(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),pv=e=>typeof e==`string`?e:Q_(e),mv=new TextDecoder(`utf-8`,{ignoreBOM:!0}),hv=e=>new URLSearchParams(mv.decode(e).replace(/^\?/,`%3F`)),gv=`~effect/http/UrlParams`,_v=e=>b(e,gv),vv={...Wt,[gv]:gv,[Symbol.iterator](){return this.params[Symbol.iterator]()},[at](e){return{_id:`UrlParams`,params:Object.fromEntries(Dv(this,ii(e,Lv)))}},toJSON(){return st(this)},[ze](e){return Cv(this,e)},[be](){return Me(this.params.flat())}},yv=e=>{let t=Object.create(vv);return t.params=e,t},bv=e=>{if(_v(e))return e;let t=xv(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return yv(n)},xv=e=>{let t=typeof e[Symbol.iterator]==`function`?Li(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,Sv(r[t])]);else if(typeof r==`object`&&r&&!Y_(r)){let t=xv(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,Sv(r)]);return n},Sv=e=>Y_(e)?e:String(e),Cv=In((e,t)=>wv(e.params,t.params)),wv=wa(Si([Rn(),it()])),Tv=yv([]),Ev=r(2,(e,t)=>{let n=bv(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return yv(n)}),Dv=r(2,(e,t)=>{let n=Array.isArray(t)?t:[t];return e.params.map(([e,t])=>[e,typeof t==`string`&&Ov(e,n)?X_(t):t])}),Ov=dv,kv=(e,t=Iv())=>{e.includes(`@`)&&(e=Nv(e));let n=e.indexOf(`?`);if(n===-1||t.length===0)return e;let r=e.indexOf(`#`);if(r!==-1&&r<n)return e;let i=r===-1?e.length:r;return e.slice(0,n+1)+Pv(e.slice(n+1,i),t)+e.slice(i)},Av=/^(?:(https?|ftp|wss?):[/\\]*|[a-z][a-z\d+.-]*:\/\/|[/\\]{2,})/i,jv=/[/\\?#]/,Mv=/[/?#]/,Nv=e=>{let t=``,n=[];for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i===9||i===10||i===13||t===``&&i<=32||(t+=e[r],n.push(r))}let r=Av.exec(t);if(r===null)return e;let i=r[0].length,a=r[1]!==void 0||!r[0].includes(`:`),o=t.slice(i),s=o.search(a?jv:Mv),c=(s===-1?o:o.slice(0,s)).lastIndexOf(`@`);return c===-1?e:e.slice(0,n[i])+`REDACTED:REDACTED`+e.slice(n[i+c])},Pv=(e,t)=>e.split(`&`).map(e=>{let n=e.indexOf(`=`);return n!==-1&&Ov(Fv(e.slice(0,n)),t)?e.slice(0,n+1)+`REDACTED`:e}).join(`&`),Fv=e=>{if(!e.includes(`%`)&&!e.includes(`+`))return e;try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}},Iv=()=>ii(globalThis[`~effect/Fiber/currentFiber`]?.context??Xr(),Lv),Lv=k(`effect/http/UrlParams/CurrentRedactedNames`,{defaultValue:()=>[`X-Amz-Signature`,`X-Amz-Credential`,`X-Amz-Security-Token`,`AWSAccessKeyId`,`Signature`,`sig`,`X-Goog-Signature`]});function Rv(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var zv=`~structural`,Bv=`~sentinels`,Vv=`~constructor`,Hv=p(e=>{let t=Rv(e)?.identifier;return typeof t==`string`?t:e.getExpected(Hv)}),I=Symbol(),Uv=of,Wv=Uv(I),Gv=Uv(I),Kv=e=>e===I?w():T(e),qv=e=>e._tag===`None`?Wv:Uv(e.value),Jv=`~effect/SchemaIssue/Issue`;function Yv(e){return b(e,Jv)&&e[Jv]===Jv}function Xv(e){return Object.hasOwn(e,`input`)}var Zv=class{[Jv]=Jv;constructor(e,t){t?.reportInput===!0&&e!==I&&(this.input=e)}},Qv=class extends Zv{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},$v=class extends Zv{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},ey=class extends Zv{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},ty=class extends Zv{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},ny=class extends Zv{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},ry=class extends Zv{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},iy=class extends Zv{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},ay=class extends Zv{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function oy(e,t,n,r,i){return new ry(e,[new ey([t],n)],r,i)}var sy=class extends Zv{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},cy=class extends Zv{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function ly(e,t,n){if(Yv(e))return e;if(typeof e==`string`)return new ay({message:e},t,n);let r=typeof e.issue==`string`?new ay({message:e.issue},t,n):e.issue;return new ey(e.path,r)}function uy(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new ay(void 0,t,n):ly(e,t,n)}function dy(e,t,n,r){return Array.isArray(t)?Wi(t)?t.length===1?ly(t[0],n,r):new ry(e,ga(t,e=>ly(e,n,r)),n,r):void 0:uy(t,n,r)}var fy=e=>{let t=Sy(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return gy(Hv(e.ast),e);case`InvalidValue`:{let t=hy(e);if(t!==void 0)return gy(t,e);let n=my(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=my(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=my(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},py=e=>Sy(e)??Sy(e.issue);function my(e){return Xv(e)?ft(e.input):void 0}function hy(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function gy(e,t){let n=my(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function _y(e,t){let n=t(e);if(n!==void 0||e.issue._tag!==`InvalidValue`)return n;let r=hy(e.issue);return r===void 0?gy(vy(e.filter),e):gy(r,e.issue)}function vy(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>vy(e)).join(` & `)}}function yy(){return e=>xy(e,``)}var by=yy();function xy(e,t,n){let r;switch(e._tag){case`Filter`:return xy(e.issue,t,n??_y(e,py));case`Encoding`:return xy(e.issue,t,n);case`Pointer`:return xy(e.issue,t+ht(e.path),n);case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>xy(e,t,n)).join(`
|
|
14
|
-
`);r=n??Sy(e)??gy(Hv(e.ast),e);break;default:r=n??fy(e)}return t?`${r}\n at ${t}`:r}function Sy(e){if(e._tag===`Pointer`||e._tag===`Composite`)return;if(e._tag===`Encoding`)return Sy(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function Cy(e){let t;for(let n of e.reasons){if(!Ud(n)||!Yv(n.error))return;t??=n.error}return t}function wy(e,t){let n=Cy(e);if(n===void 0)throw Error(t,{cause:e});return n}var Ty=e=>Object.assign(Object.create(t),e),Ey=Ty({_tag:`Passthrough`});function Dy(){return Ey}function Oy(e){return Ty({_tag:`Transform`,transform:e})}function ky(e){return Ty({_tag:`TransformEffect`,transform:e})}function Ay(){return Oy(globalThis.String)}function jy(){return Oy(globalThis.Number)}function My(e){return ky((t,n)=>Xp({try:()=>JSON.parse(t,e?.reviver),catch:()=>new ay({expected:`a valid JSON string`},t,n)}))}function Ny(e){return ky((t,n)=>Xp({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new ay({expected:`a JSON-serializable value`},t,n)}))}var Py=Symbol.for(`~effect/Schema/content`);function Fy(e,t){return Object.defineProperty(e,Py,{value:t}),e}var Iy=class extends n{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Iy(this.encode,this.decode)}},Ly=`~effect/SchemaTransformation/Transformation`,Ry=class extends n{[Ly]=Ly;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Ry(this.encode,this.decode)}};function zy(e){return b(e,Ly)&&e[Ly]===Ly}var By=e=>zy(e)?e:new Ry(e.decode,e.encode);function Vy(e){return new Ry(ky(e.decode),ky(e.encode))}function Hy(e){return new Ry(Oy(e.decode),Oy(e.encode))}var Uy=new Ry(Dy(),Dy());function Wy(){return Uy}var Gy=new Ry(jy(),Ay()),Ky=e=>ge(e)&&typeof e.message==`string`,qy=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:Zy(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},Jy=e=>{try{let t=yt(e);return t===void 0?ft(e):JSON.parse(t)}catch{return ft(e)}},Yy=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},Xy=e=>{let t=new WeakSet,n=r=>{if(ye(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=Yy(r,e,n);return t.delete(r),i}return Jy(r)};return n},Zy=e=>Ky(e)?qy(e):e,Qy=e=>Hy({decode:Zy,encode:Xy(e)});function $y(e){return new Ry(My(e??{}),Fy(Ny(e),{mediaType:`application/json`,preserveSchema:e?.reviver===void 0&&e?.replacer===void 0}))}function eb(e){return t=>t._tag===e}var tb=eb(`Declaration`),nb=eb(`Never`),rb=eb(`Literal`),ib=eb(`UniqueSymbol`),ab=eb(`Arrays`),ob=eb(`Objects`),sb=eb(`Union`),cb=eb(`Suspend`),lb=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},ub={},db=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},fb=`~effect/Schema`,pb=class{[fb]=fb;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},mb=class extends pb{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>{if(t===I)return Wv;e??=this.run(this.typeParameters);try{return e(t,this,n)}catch(e){return Yp(e)}}}_rebuild(e,t,n,r,i){let a=Ix(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new mb(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},hb=new class extends pb{_tag=`Null`;getParser(){return Zx(this,null)}getExpected(){return`null`}},gb=class extends pb{_tag=`Undefined`;getParser(){return Zx(this,void 0)}toCodecJson(){return wx(this,[_b])}getExpected(){return`undefined`}},_b=new lb(hb,new Ry(Oy(()=>void 0),Oy(()=>null))),vb=new gb,yb=new class extends pb{_tag=`Void`;getParser(){let e=Uv(void 0);return t=>t===I?Wv:e}toCodecJson(){return wx(this,[_b])}getExpected(){return`void`}},bb=new class extends pb{_tag=`Never`;getParser(){return Qx(this,pe)}getExpected(){return`never`}},xb=new class extends pb{_tag=`Unknown`;getParser(){return Qx(this,me)}getExpected(){return`unknown`}},Sb=class extends pb{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${ft(e)}`);this.literal=e}getParser(){return Zx(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Cb(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Cb(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Cb(e){let t=globalThis.String(e.literal);return wx(e,[new lb(new Sb(t),new Ry(Oy(()=>e.literal),Oy(()=>t)))])}var wb=new class extends pb{_tag=`String`;getParser(){return Qx(this,ne)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&sS(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},Tb=class extends pb{_tag=`Number`;getParser(){return Qx(this,re)}matchKey(e,t){return this._match(nS,e,t)}matchPart(e,t){return this._match(tS,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:sS(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(Eb(this.checks,`effect/schema/isFinite`)||Eb(this.checks,`effect/schema/isInt`))?this:wx(this,[yx])}toCodecStringTree(){return this.toCodecJson()===this?wx(this,[aS]):wx(this,[oS])}getExpected(){return`number`}};function Eb(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&Eb(e.checks,t))}var Db=new Tb,Ob=new class extends pb{_tag=`Boolean`;getParser(){return Qx(this,ie)}getExpected(){return`boolean`}},kb=class extends pb{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(Ux(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(Ux(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new ny(n,t[o],i),a=new ey([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return Kp(new ry(n,[a],t,i))}return e.issues?Kp(new ry(n,e.issues,t,i)):Uv(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:[],issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:Mu(t.concurrency),f=d===1?Mb(i,e,0,u):Nb(i,e,{concurrency:d,end:u});if(!f)return c(i);if(Wc(f))return nh(f,()=>c(i));let p=!0;return Up(()=>p?(p=!1,F(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===I)return Wv;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):Kp(new iy(n,e,a))}catch(e){return Yp(e)}}}_rebuild(e,t,n){let r=Ix(this.elements,e),i=Ix(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new kb(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function Ab(e,t,n,r){if(n._tag===`Failure`)return Pb(e,e.ast,r,n);let i=n===Gv?t:n[S];if(i!==I)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(Ux(t.ast))return;let n=new ey([r],new ty(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return cf(new ry(e.ast,[n],e.input,e.options))}}var jb={onItem(e,t,n){let r=n<e.len?t:I;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:Ab},Mb=Nu()(jb),Nb=Fu()(jb),Pb=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Cy(r.cause);if(i===void 0)return sf(Xd(r.cause,r=>new ry(t,[new ey([n],r)],e.input,e.options)));let a=new ey([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return cf(new ry(t,[a],e.input,e.options))},Fb=`[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?`;function Ib(e,t,n=ub){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a($x(Jx(t)))}var Lb=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Rb(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Rb);default:return!1}}function zb(e){let t=Ex(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(zb);default:return!1}}function Bb(e){return Rb(e)&&zb(e)}var Vb=class{parameter;type;constructor(e,t){if(!Bb(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Ux(t)||t.encoding!==void 0&&Ux(Jx(t)))throw Error("Cannot use `Schema.optionalKey` or `Schema.optional` with index signatures. Index signatures already allow keys to be absent; use `Schema.UndefinedOr` to allow `undefined` values.")}},Hb=class extends pb{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return Qx(n,fe);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e($x(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return Pb(t,n,i,s)??df;let c=s===Gv?o:s[S];if(a!==I&&c!==I){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return df;Nt(t.out,a,c)}return df},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!Wc(t))return F(nm(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return Pb(e,n,r,a)??df;let o=a===Gv?r:a[S],s=e.input[r],l=i.parserValue(s,e.options);return Wc(l)?t(e,r,o,s,l):F(nm(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return Wc(a)?t(e,n,n,i,a):F(nm(a),r=>t(e,n,n,i,r))},u=i?Fu()({onItem:(e,[t,n])=>n.is.parameter===wb?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return rh(function*(t,d){if(t===I)return I;if(typeof t!=`object`||!t||Array.isArray(t))return yield*Kp(new iy(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,g=d.onExcessProperty===`error`,_=d.concurrency===void 0?1:Mu(d.concurrency),v=i&&g?n.indexSignatures.map(e=>Ib(f,e.parameter,d)):void 0;if(g){let r=v?new Set(e):e;if(v)for(let e of v)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new ny(n,f[a],d),r=new ey([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*Kp(new ry(n,[r],t,d))}}}if(r){let e=_===1?Gb(m,a):Kb(m,a,{concurrency:_});e&&(yield*e)}if(i&&_===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===wb?l:c,r=v?.[e]??(t.is.parameter===wb?Object.keys(f):Ib(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!Wc(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=ma();for(let t=0;t<i;t++){let n=o[t],r=v?.[t]??(n.is.parameter===wb?Object.keys(f):Ib(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:_});t&&(yield*t)}return m.issues?yield*Kp(new ry(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return F(nm(n),n=>{let i={...e,out:{...e.out}},o=Ub(i,r,n);if(o)return o;let s=()=>Uv(i.out),c=Gb(i,a.slice(t+1));return c?nh(c,s):s()})};return(e,t)=>{if(e===I)return Wv;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&Mu(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return Kp(new iy(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=rx(i,s),l=c?i[s]:I,d=n.parser(l,t);if(!Wc(d))return u(o,e,d);if(d===Gv){c&&Nt(a,s,l);continue}let f=Ub(o,n,d);if(f)return f}}catch(e){return Yp(e)}return Uv(a)}}_rebuild(e,t,n,r){let i=Ix(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new Lb(t.name,n)}),a=Ix(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new Vb(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Hb(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function Ub(e,t,n){if(n._tag===`Failure`)return Pb(e,e.ast,t.name,n);if(n===Gv)return;let r=n[S];if(r!==I)Nt(e.out,t.name,r);else if(delete e.out[t.name],!Ux(t.type)){let n=new ey([t.name],new ty(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return cf(new ry(e.ast,[n],e.input,e.options))}}var Wb={onItem(e,t){if(!rx(e.input,t.name))return t.parser(I,e.options);let n=e.input[t.name];return Nt(e.out,t.name,n),t.parser(n,e.options)},step:Ub},Gb=Nu()(Wb),Kb=Fu()(Wb);function qb(e,t){return e?t?[...e,...t]:e:t}function Jb(e,t,n){return new Hb(Reflect.ownKeys(e).map(t=>new Lb(t,e[t].ast)),[],n,t)}function Yb(e){return e.ast}function Xb(e,t,n){return new ax(e.map(Yb),t,void 0,n)}var Zb=m(e=>{for(;;){if(cb(e))return xb;let t=e.encoding;if(!t)return e.recur?.(Zb,i)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==i))return xb;e=t[t.length-1].to}});function Qb(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(Qb)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function $b(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Bv];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!Ux(t)){if(rb(t))return[{key:e.name,literal:t.literal}];if(ib(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!Ux(e)){if(rb(e))return[{key:t,literal:e.literal}];if(ib(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>$b(Zb(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return $b(e.thunk())}}var ex=new WeakMap,tx=Object.freeze([]),nx=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,rx=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function ix(e){let t=ex.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=Zb(c);if(nb(l))continue;if(rb(l)||ib(l)){a??=new Map;let e=rb(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=$b(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=Qb(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??tx);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??tx;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(_e(e)){let n=rx(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??tx;if(t)return o}return tx}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=nx(t);if(!_e(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=rx(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=rx(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=rx(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(nx(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return ex.set(e,t),t}var ax=class extends pb{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===I)return Wv;let i=(o??=ix(n.types))(e,r);if(i.length===0)return Kp(new sy(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:Wc(r)?ox(n,r.cause,e,t):sx(n,r,e,t)}return cx(n,a,i,e,t)}}_rebuild(e,t,n){let r=Ix(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new ax(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=Jx(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(rb);if(t.length>0)return`${fx(n.isMutable)}[ ${t.map(t=>e(t)+px(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>rb(e.type));if(t.length>0)return`{ ${t.map(t=>`${fx(t.type.context?.isMutable)}${mt(t.name)}${px(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function ox(e,t,n,r){let i=Cy(t);return i?cf(new sy(e,[i],n,r)):sf(t)}function sx(e,t,n,r){return sm(t,t=>ox(e,t,n,r))}function cx(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=ux(a,n);if(!o)return a.out?a.out:Kp(new sy(e,a.issues??[],r,i));if(Wc(o))return lx(o,a);let s=!0;return Up(()=>s?(s=!1,lx(o,a)):cx(e,t,n,r,i))}function lx(e,t){return nh(e,e=>t.out===Gv?j(t.input):t.out?t.out:Kp(new sy(t.ast,t.issues??[],t.input,t.options)))}var ux=Nu()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Cy(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),cf(new cy(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return df}}}),dx=new ax([new Sb(`Infinity`),new Sb(`-Infinity`),new Sb(`NaN`)]);function fx(e){return e?``:`readonly `}function px(e){return e?`?`:``}var mx=class extends n{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new mx(this.run,{...this.annotations,...e},this.aborted)}abort(){return new mx(this.run,this.annotations,!0)}and(e,t){return new hx([this,e],t)}},hx=class extends n{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new hx(this.checks,{...this.annotations,...e})}and(e,t){return new hx([this,e],t)}};function gx(e,t,n=!1){return new mx((t,n,r)=>dy(n,e(t,n,r),t,r),t,n)}function _x(e){return gx(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var vx=kx(Db,[_x()]),yx=new lb(new ax([vx,dx]),new Ry(jy(),Oy(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function bx(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return gx(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var xx=new WeakMap;function Sx(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&xx.set(n,Cx(e)),n}function Cx(e){let t=xx.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return xx.set(e,n),n}function wx(e,t){return e.encoding===t?e:Sx(e,{encoding:t})}function Tx(e,t){if(e.context===t)return e;let n=Cx(e);return n.context===t&&n.encoding===e.encoding?n:Sx(e,{context:t})}function Ex(e){return e.encoding?Ex(e.encoding[e.encoding.length-1].to):e}function Dx(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Ox(e,zi(e.checks.slice(0,-1),n.annotate(t)))}return Sx(e,{annotations:{...e.annotations,...t}})}function Ox(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:Sx(e,{checks:t})}function kx(e,t){return Ox(e,qb(e.checks,t))}function Ax(e,t){let n=t(e.to);return n===e.to?e:new lb(n,e.transformation)}function jx(e,t){let n=e,r=n[n.length-1],i=Ax(r,t);return i===r?e:zi(e.slice(0,e.length-1),i)}function Mx(e){return t=>t.encoding?wx(t,jx(t.encoding,e)):t}function Nx(e,t){return Mx(e=>Tx(e,t))(e)}function Px(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:wx(r,jx(r.encoding,n))}return e(r)}return m(n)}function Fx(e,t,n){let r=new lb(e,t);return wx(n,n.encoding?[...n.encoding,r]:[r])}function Ix(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function Lx(e,t){return Tx(e,e.context?new db(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new db(!1,!1,void 0,t))}var Rx=m(e=>zx(Tx(e,e.context?e.context.isOptional===!1?new db(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new db(!0,!1)))),zx=Mx(Rx),Bx=p(e=>Rx(new ax([e,vb])));function Vx(e,t){return Tx(e,e.context?new db(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new db(!1,!1,t))}function Hx(e,t,n){return Fx(e,n,t)}function Ux(e){return e.context?.isOptional??!1}function Wx(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(Wx)}function Gx(e){function t(e){return Wx(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Ui(n)?n:void 0}function Kx(e){let t=!0;function n(e){return t=t&&!e.encoding&&!cb(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var qx=m(e=>{let t=Cx(e);if(t!==e){let n=qx(t);return n===t&&e.encoding===void 0?e:Tx(n,e.context)}let n=`recur`in e?e.recur(qx):e;if(`encodingChecks`in n&&n.encodingChecks){let t=Kx(e)?n.encodingChecks:ab(n)||ob(n)||tb(n)&&n.typeParameters.length>0?Gx(n.encodingChecks):void 0;return Sx(n,{encodingChecks:void 0,checks:qb(n.checks,t)})}return n}),Jx=m(e=>qx(Xx(e)));function Yx(e,t){let n=t,r=n.length,i=n[r-1],a=[new lb(Xx(wx(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new lb(Xx(n[e-1].to),n[e].transformation.flip()));let o=Xx(i.to);return o.encoding?wx(o,[...o.encoding,...a]):wx(o,a)}var Xx=p(e=>{if(e.encoding)return Yx(e,e.encoding);let t=Cx(e);if(t!==e){let n=Xx(t);return n===t?e:Tx(n,e.context)}return`flip`in e?e.flip(Xx):`recur`in e?e.recur(Xx):e});function Zx(e,t){let n=t===0?Gv:Uv(t);return(r,i)=>r===I?Wv:r===t?n:Kp(new iy(e,r,i))}function Qx(e,t){return(n,r)=>n===I?Wv:t(n)?Gv:Kp(new iy(e,n,r))}var $x=Px(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur($x)}}),eS=Px(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(eS)}}),tS=new globalThis.RegExp(`^${Fb}$`),nS=new globalThis.RegExp(`^(?:${Fb}|Infinity|-Infinity|NaN)$`);function rS(e){return bx(tS,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:tS.source}),...e})}var iS=kx(wb,[rS()]),aS=new lb(iS,Gy),oS=new lb(new ax([iS,dx]),Gy);function sS(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=sS(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new Qv(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function cS(e){if(!tb(e))return;let t=e.annotations?.[Vv];return se(t)?t(e.typeParameters):void 0}function lS(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function uS(e){return e===void 0||typeof e==`string`}function dS(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function fS(e){return dS(e,lS)}var pS=new mb([],()=>(e,t,n)=>fS(e)?Gv:Kp(new iy(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>_S}),mS=new lb(pS,Wy()),hS=new lb(new ax([new kb(!1,[],[pS]),new Hb([],[new Vb(wb,pS)])]),Wy());function gS(e){return dS(e,uS)}var _S=new lb(new mb([],()=>(e,t,n)=>gS(e)?Gv:Kp(new iy(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),Wy()),vS=(e,t,n)=>e===Gv?n(t):nh(e,n);function yS(e){let t=bS(e);return(e,n,r)=>{try{return t(e,n,r)}catch(e){return Yp(e)}}}function bS(e){if(e._tag===`Middleware`)return(t,n,r)=>xS(t===Gv?e.decode(Uv(Kv(n)),r):e.decode(eh(t,Kv),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===Gv?Uv(t):e;case`Transform`:{let e=e=>e===I?Wv:Uv(t.transform(e));return(t,n)=>vS(t,n,e)}case`TransformOptional`:{let e=e=>qv(t.transform(Kv(e)));return(t,n)=>vS(t,n,e)}case`TransformEffect`:return(e,n,r)=>vS(e,n,e=>e===I?Wv:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>vS(e,n,e=>xS(t.transform(Kv(e),r)))}}var xS=e=>nh(e,qv),SS=(e,t,n,r)=>sm(r,r=>Jp(()=>Xd(r,r=>new $v(e,r,t,n))));function CS(e,t){let n=yS(e.link.transformation),r;return(i,a)=>{if(i===I)return Wv;if(e.isConstructed(i))return Gv;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function wS(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==I&&r!==void 0)return t(r,i);let a=n;if(Wc(a)&&a._tag===`Success`){let e=t(a[S],i);return e===Gv?a:e}return nh(SS(e,r,i,a),e=>{let n=t(e,i);return n===Gv?Uv(e):n})}}function TS(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:wS(e,n)}function ES(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?cS(e):void 0,o=a?CS(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>yS(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);try{if(u&&!n.disableChecks){if(Wc(r)){if(r._tag===`Success`){let i=r===Gv?t:r[S];if(t!==I&&i!==I){let i=sS(u,t,void 0,e,n);i&&(r=Kp(new ry(e,i,t,n)))}}}else r=F(r,r=>{if(t!==I&&r!==I){let r=sS(u,t,void 0,e,n);if(r)return Kp(new ry(e,r,t,n))}return j(r)})}if(s&&!n.disableChecks){if(Wc(r)){if(r._tag===`Success`){let i=r===Gv?t:r[S];if(i===I)return r;let a=sS(s,i,void 0,e,n);a&&(r=Kp(new ry(e,a,i,n)))}}else r=F(r,t=>{if(t!==I){let r=sS(s,t,void 0,e,n);if(r)return Kp(new ry(e,r,t,n))}return j(t)})}return r}catch(e){return Yp(e)}},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[S],o=t(a,r)):o=nh(o,e=>{let n=t(e,r);return n===Gv?Uv(e):n})}if(o._tag===`Success`){let e=o[S],t=p(e,r);return t===Gv?o:t}return o=SS(e,n,r,o),nh(o,e=>{let t=p(e,r);return t===Gv?Uv(e):t})}:p}var DS=Symbol(),OS=new WeakMap,kS=e=>NS(e).parser,AS=e=>NS(e).makeEffect,jS=e=>TS(e,AS),MS=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=ES(this.ast,kS)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=ES(this.ast,AS,jS)}};function NS(e){let t=OS.get(e);if(t!==void 0)return t;let n=new MS(e);return OS.set(e,n),n}function PS(e){let t=e.ast,n;return(e,r)=>(n??=YS(aC,qx(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function FS(e){let t=PS(e);return(e,n)=>{let r=Zm(t(e,n));return ff(r)?T(r.value):(wy(r.cause,`Option adapter can only return none for schema issues`),w())}}function IS(e){return tC(qx(e.ast))}function LS(e){return zS(e.ast)}function RS(e){{let t=XS(qS(e));return e=>{let n=t(e,ub);return ff(n)?!0:(wy(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function zS(e){let t=qx(e),n=e=>(n=RS(t),n(e));return e=>n(e)}function BS(e,t){let n=qS(e.ast);return t===void 0?n:(e,r)=>n(e,GS(t,r))}function VS(e,t){return XS(BS(e,t))}function HS(e,t){return ZS(BS(e,t))}var US=HS;function WS(e,t){let n=qS(Xx(e.ast));return t===void 0?n:(e,r)=>n(e,GS(t,r))}var GS=(e,t)=>t?{...e,...t}:e,KS=e=>e===I?Kp(new ay):j(e);function qS(e){return YS(iC,e)}function JS(e,t){return e===Gv?j(t):Wc(e)?e[`~effect/Effect/args`]===I?KS(I):e:nh(e,KS)}function YS(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??ub);return a===Gv?j(r):Wc(a)?a[`~effect/Effect/args`]===I?KS(I):a:nh(a,KS)}}function XS(e){return(t,n)=>Zm(e(t,n))}function ZS(e){let t=XS(e);return(e,n)=>{let r=t(e,n);return ff(r)?T(r.value):(wy(r.cause,`Option adapter can only return none for schema issues`),w())}}function QS(e,t){let n=Zm(e);if(ff(n))return n.value;let r=wy(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}var $S=`Constructor adapter can only throw schema issues`;function eC(e){throw Error($S,{cause:Gd(e)})}function tC(e){let t;return(n,r)=>nC(t??=NS(e),n,r)}function nC(e,t,n){let r=n?.disableChecks?n.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions??ub,i=e.make;if(i!==void 0&&t!==I){let e;try{e=i(t,r)}catch(e){eC(e)}if(e!==DS&&e!==I)return e}return QS(JS(e.makeEffect(t,r),t),$S)}function rC(e,t,n,r){let i=NS(e),a=cS(e);if(a===void 0||i.make!==void 0||i.compiledMakeEffect!==void 0)return nC(i,t,n);if(a.isConstructed(t))return t;let o=nC((i.resolve??NS)(a.link.to),t,n);try{return r(o)}catch(e){eC(e)}}var iC=e=>NS(e).parser,aC=e=>NS(e).makeEffect,oC=`~effect/Schema/Schema`,sC=Symbol(),cC={[oC]:oC,get make(){let e=IS(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=PS(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=FS(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return e(this,arguments)},annotate(e){return this.rebuild(Dx(this.ast,e))},annotateKey(e){return this.rebuild(Lx(this.ast,e))},check(...e){return this.rebuild(kx(this.ast,e))},rebuild(e){return lC(e,this[sC])}};function lC(e,t){function n(){}let r=Object.setPrototypeOf(n,cC);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[sC]=t,r.ast=e,r}function uC(e){return lC(dC(e.ast),{schema:e})}var dC=fC(_C);function fC(e,t){let n=p(t=>{let n=Tx(t,void 0),i=e(n,r);return i===n?null:i}),r=Px(e=>{let t=n(Cx(e));if(t===null)return e;let r=Tx(t,e.context);return e.context===void 0?r:Nx(r,pC(e.context))},t);return r}function pC(e){return e.constructorDefault===void 0?e:new db(e.isOptional,e.isMutable,void 0,e.annotations)}function mC(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function hC(e){return t=>{let n=[...t].sort((t,n)=>e(Jx(t))-e(Jx(n)));return n.some((e,n)=>e!==t[n])?n:t}}var gC=hC(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function _C(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!se(n))return wx(e,[mS]);let r=n(e.typeParameters.map(e=>lC(Jx(e))));return r===void 0?e:wx(e,[Ax(r,t)])}case`Unknown`:return wx(e,[mS]);case`ObjectKeyword`:return wx(e,[hS]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return mC(e),e.recur(t,eS);case`Union`:{let n=gC(e.types);return n===e.types?e.recur(t):new ax(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var vC=p(e=>yC(e));function yC(e){let t=Rv(e)?.toEquivalence;if(t)return t(tb(e)?e.typeParameters.map(yC):[]);switch(e._tag){case`Never`:return Rn();case`Declaration`:return bC(e);case`Null`:case`Undefined`:case`Void`:case`Unknown`:case`Any`:case`String`:case`Number`:case`Boolean`:case`BigInt`:case`Symbol`:case`Literal`:case`UniqueSymbol`:case`ObjectKeyword`:case`Enum`:case`TemplateLiteral`:return Be;case`Arrays`:{let t=e.elements.map(yC),n=e.rest.map(yC),[r,...i]=n,a=i.length;return In((o,s)=>{if(!Array.isArray(o)||!Array.isArray(s))return!1;let c=o.length;if(c!==s.length)return!1;let l=0;for(;l<Math.min(c,e.elements.length);l++)if(!t[l](o[l],s[l]))return!1;if(n.length>0){for(;l<c-a;l++)if(!r(o[l],s[l]))return!1;for(let e=0;e<a;e++)if(!i[e](o[l+e],s[l+e]))return!1}return!0})}case`Objects`:{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return Be;let t=e.propertySignatures.map(e=>yC(e.type)),n=e.indexSignatures.map(e=>yC(e.type));return In((r,i)=>{if(!ge(r)||!ge(i))return!1;for(let n=0;n<t.length;n++){let a=e.propertySignatures[n],o=a.name,s=Object.hasOwn(r,o),c=Object.hasOwn(i,o);if(Ux(a.type)&&s!==c||s&&c&&!t[n](r[o],i[o]))return!1}for(let t=0;t<n.length;t++){let a=e.indexSignatures[t],o=Ib(r,a.parameter),s=Ib(i,a.parameter);if(o.length!==s.length)return!1;for(let e=0;e<o.length;e++){let a=o[e];if(!Object.hasOwn(i,a)||!n[t](r[a],i[a]))return!1}}return!0})}case`Union`:{let t=qx(e).types,n=ix(t),r=t.map((t,n)=>[zS(t),yC(e.types[n])]);return In((e,t)=>{let i=n(e,!1);for(let n=0;n<i.length;n++){let[a,o]=r[i[n]];if(a(e)&&a(t))return o(e,t)}return!1})}case`Suspend`:{let t;return In((n,r)=>(t??=vC(e.thunk()))(n,r))}}}function bC(e){let t=e.annotations?.representation;if(t===void 0)return Be;switch(t.id){case`effect/schema/Option`:{let[t]=xC(e);return(e,n)=>e._tag===n._tag&&(e._tag===`None`||t(e.value,n.value))}case`effect/schema/Result`:{let[t,n]=xC(e);return(e,r)=>e._tag===r._tag&&(e._tag===`Success`?t(e.success,r.success):n(e.failure,r.failure))}case`effect/schema/CauseReason`:{let[t,n]=xC(e);return SC(t,n)}case`effect/schema/Cause`:{let[t,n]=xC(e);return CC(t,n)}case`effect/schema/Exit`:{let[t,n,r]=xC(e),i=CC(n,r);return(e,n)=>e._tag===n._tag&&(e._tag===`Success`?t(e.value,n.value):i(e.cause,n.cause))}case`effect/schema/ReadonlyMap`:{let[t,n]=xC(e);return tt(t,n)}case`effect/schema/ReadonlySet`:return nt(xC(e)[0]);case`effect/schema/RegExp`:return(e,t)=>e.source===t.source&&e.flags===t.flags;case`effect/schema/URL`:return(e,t)=>e.toString()===t.toString();default:return Be}}function xC(e){return e.typeParameters.map(yC)}function SC(e,t){return(n,r)=>{if(n._tag!==r._tag)return!1;switch(n._tag){case`Fail`:return e(n.error,r.error);case`Die`:return t(n.defect,r.defect);case`Interrupt`:return n.fiberId===r.fiberId}}}function CC(e,t){let n=Bn(SC(e,t));return(e,t)=>n(e.reasons,t.reasons)}var wC=r(2,(e,t)=>EC(e,(e,n)=>[e,Object.hasOwn(t,e)?t[e](n):n])),TC=e=>e;function EC(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let i=t(r,e[r]);if(i){let[e,t]=i;Nt(n,e,t)}}return n}var DC=`~effect/Schema/SchemaError`;function OC(e){return b(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}({...Et}),{...Et},{...Et},{...Et},{...Et},{...Et},{...Et},{...Et};var kC=oC;function AC(){return(e,t,n)=>JC(new mb(e.map(Yb),e=>t(e.map(e=>JC(e))),n))}function jC(e,t){return AC()([],()=>(t,n,r)=>e(t)?j(t):Kp(new iy(n,t,r)),t)}var MC=class extends Lo(`SchemaError`){[DC]=DC;constructor(e){let t=kt();At(0);try{super({issue:e})}finally{At(t)}}get message(){return by(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Ct](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function NC(e){return OC(e)}function PC(e){return Wc(e)?FC(e):sm(e,e=>Jp(()=>Xd(e,e=>new MC(e))))}function FC(e){return ff(e)?e:sf(Xd(e.cause,e=>new MC(e)))}function IC(e,t){let n;for(let r of e.reasons){if(!Ud(r)||!NC(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function LC(e){let t=Zm(e);if(ff(t))return t.value;throw IC(t.cause,`Sync adapter can only throw schema errors`)}var RC=LS;function zC(e,t){let n=BS(e,t);return(e,t)=>PC(n(e,t))}function BC(e,t){let n=VS(e,t);return(e,t)=>FC(n(e,t))}var VC=HS,HC=US;function UC(e,t){let n=zC(e,t);return(e,t)=>LC(n(e,t))}var WC=UC;function GC(e,t){let n=WS(e,t);return(e,t)=>PC(n(e,t))}var KC=GC;function qC(e,t){let n=GC(e,t);return(e,t)=>LC(n(e,t))}var JC=lC;function YC(e){return b(e,kC)&&e[kC]===kC}var XC=TC(e=>JC(Rx(e.ast),{schema:e})),ZC=TC(e=>{let t=pw(e);return JC(Bx(e.ast),{schema:t})}),QC=TC(e=>JC(qx(e.ast),{schema:e}));function $C(e){let t=JC(new Sb(e),{literal:e,transform(n){return t.pipe(hw($C(n),{decode:Oy(()=>n),encode:Oy(()=>e)}))}});return t}var ew=JC(bb),tw=JC(xb),nw=JC(hb),rw=JC(vb),L=JC(wb),R=JC(Db),iw=JC(Ob),aw=JC(yb);function ow(e,t){return JC(e,{fields:t,mapFields(e,t){let n=e(this.fields);return ow(Jb(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function z(e){return ow(Jb(e,void 0),e)}var sw=TC(e=>JC(new kb(!1,[],[e.ast]),{value:e})),cw=TC(e=>JC(new kb(!1,[e.ast],[e.ast]),{value:e}));function lw(e,t){return JC(e,{members:t,mapMembers(e,t){let n=e(this.members);return lw(Xb(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function uw(e,t){return lw(Xb(e,t,void 0),e)}function dw(e){let t=e.map($C);return JC(Xb(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return uw(e(this.members))},pick(e){return dw(e)},transform(e){return uw(t.map((t,n)=>t.transform(e[n])))}})}var fw=TC(e=>uw([e,nw])),pw=TC(e=>uw([e,rw]));function mw(...e){return t=>t.check(...e)}function hw(e,t){return n=>JC(Hx(n.ast,e.ast,t?By(t):Wy()),{from:n,to:e})}function gw(e){return t=>JC(Vx(t.ast,e),{schema:t})}function _w(e){return $C(e).pipe(gw(j(e)))}function vw(e,t){return z({_tag:_w(e),...t})}function yw(e){return t=>{let n={},r=[],i=new Set,a={};return o(t),Object.assign(t,{tag:e,cases:n,discriminants:r,isAnyOf:t=>n=>t.includes(n[e]),guards:a,match:s,matchOrElse:c});function o(t){let s=t.ast;if(sb(s)&&`members`in t&&globalThis.Array.isArray(t.members)&&t.members.every(YC))return t.members.forEach(o);let c=$b(s);if(c.length>0){let o=c.find(t=>t.key===e)?.literal;if(oe(o)){let e=typeof o==`number`?globalThis.String(o):o;if(i.has(e))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(o)}`);i.add(e),r.push(o),Nt(n,o,t),Nt(a,o,LS(QC(t)));return}}throw new globalThis.Error(`No literal or unique symbol found`)}function s(){if(arguments.length===1){let t=arguments[0];return function(n){let r=n[e];return(Object.hasOwn(t,r)?t[r]:void 0)(n)}}let t=arguments[0],n=arguments[1],r=t[e];return(Object.hasOwn(n,r)?n[r]:void 0)(t)}function c(){if(arguments.length===2){let t=arguments[0],n=arguments[1];return function(r){let i=r[e];return(Object.hasOwn(t,i)?t[i]??n:n)(r)}}let t=arguments[0],n=arguments[1],r=arguments[2],i=t[e];return(Object.hasOwn(n,i)?n[i]??r:r)(t)}}}function bw(e){let t={},n=[];for(let r of Object.keys(e)){let i=vw(r,e[r]);Nt(t,r,i),n.push(i)}let r=uw(n),{tag:i,guards:a,isAnyOf:o,match:s,matchOrElse:c}=yw(`_tag`)(r);return JC(r.ast,{tag:i,cases:t,isAnyOf:o,guards:a,match:s,matchOrElse:c})}function xw(){return(e,t)=>new lb(e.ast,By(t))}var Sw=gx;function Cw(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new globalThis.RegExp(${ft(n)})`:`new globalThis.RegExp(${ft(n)}, ${ft(r)})`;return bx(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var ww=JC(vx);function Tw(e){let t=mr(e.order),n=e.formatter??ft;return(r,i)=>Sw(e=>t(e,r),{expected:`a value greater than ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r,exclusiveMinimum:!0},...e.annotate?.(r),...i})}function Ew(e){let t=gr(e.order),n=mr(e.order),r=hr(e.order),i=pr(e.order),a=e.formatter??ft;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return Sw(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function Dw(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${ft(e)}`);return e}var Ow=Tw({order:dr,annotate:e=>({representation:{id:`effect/schema/isGreaterThan`,payload:{exclusiveMinimum:Dw(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${ft(e)})`})})}),kw=Ew({order:dr,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:Dw(e.minimum),maximum:Dw(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${ft(e.minimum)}, maximum: ${ft(e.maximum)}, exclusiveMinimum: ${ft(t)}, exclusiveMaximum: ${ft(n)} })`})}}});function Aw(e){return Sw(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`,minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}var jw=R.check(Aw());function Mw(e,t){return e=Pw(e),Sw(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`string`?e===0?{maxLength:e}:[{maxLength:e},!0]:t===`array`?{maxItems:e}:t===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[zv]:!0,arbitraryConstraint:{maxLength:e},...t})}function Nw(e,t,n){return e=Pw(e),t=Pw(t),Sw(n=>n.length>=e&&n.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:`effect/schema/isBetweenLength`,payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n===`string`?t===0||Math.ceil(e/2)>t?{minLength:Math.ceil(e/2),maxLength:t}:[{minLength:Math.ceil(e/2),maxLength:t},!0]:n===`array`?{minItems:e,maxItems:t}:n===void 0?[{minLength:Math.ceil(e/2),maxLength:t,minItems:e,maxItems:t},!0]:[{},!0],toCode:()=>({runtime:`Schema.isBetweenLength(${e}, ${t})`}),[zv]:!0,arbitraryConstraint:{minLength:e,maxLength:t},...n})}function Pw(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var Fw=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),Iw=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},Lw=[];function Rw(e){let t=Fw(e),n=Lw[t];if(n!==void 0)return n;let r=iT.pipe(hw(tw,Qy(Iw(t))));return Lw[t]=r,r}globalThis.RegExp,globalThis.URL;var zw=L.annotate({expected:`a string that will be decoded as JSON`});function Bw(e,t){return zw.pipe(hw(e,$y(t)))}globalThis.File,globalThis.URLSearchParams,globalThis.Uint8Array;function Vw(e,t){return JC(AC()([e,t],([e,t])=>(n,r,i)=>{if(!Hd(n))return Kp(new iy(r,n,i));switch(n._tag){case`Fail`:return th(BS(e)(n.error,i),{onSuccess:Kd,onFailure:e=>oy(r,`error`,e,n,i)});case`Die`:return th(BS(t)(n.defect,i),{onSuccess:qd,onFailure:e=>oy(r,`defect`,e,n,i)});case`Interrupt`:return j(n)}},{representation:{id:`effect/schema/CauseReason`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.CauseReason(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Failure<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause.Failure`,toCodec:([e,t])=>xw()(uw([z({_tag:$C(`Fail`),error:e}),z({_tag:$C(`Die`),defect:t}),z({_tag:$C(`Interrupt`),fiberId:pw(ww)})]),Hy({decode:e=>{switch(e._tag){case`Fail`:return Kd(e.error);case`Die`:return qd(e.defect);case`Interrupt`:return Jd(e.fiberId)}},encode:e=>{switch(e._tag){case`Fail`:return{_tag:`Fail`,error:e.error};case`Die`:return{_tag:`Die`,defect:e.defect};case`Interrupt`:return{_tag:`Interrupt`,fiberId:e.fiberId}}}}))}).ast,{error:e,defect:t})}function Hw(e,t){return JC(AC()([e,t],([e,t])=>{let n=sw(Vw(e,t));return(e,t,r)=>Vd(e)?th(BS(n)(e.reasons,r),{onSuccess:Wd,onFailure:n=>oy(t,`reasons`,n,e,r)}):Kp(new iy(t,e,r))},{representation:{id:`effect/schema/Cause`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Cause(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Cause<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause`,toCodec:([e,t])=>xw()(sw(Vw(e,t)),Hy({decode:Wd,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}function Uw(e,t,n){return JC(AC()([e,t,n],([e,t,n])=>{let r=Hw(t,n);return(t,n,i)=>{if(!af(t))return Kp(new iy(n,t,i));switch(t._tag){case`Success`:return th(BS(e)(t.value,i),{onSuccess:of,onFailure:e=>oy(n,`value`,e,t,i)});case`Failure`:return th(BS(r)(t.cause,i),{onSuccess:sf,onFailure:e=>oy(n,`cause`,e,t,i)})}}},{representation:{id:`effect/schema/Exit`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Exit(${e[0].runtime}, ${e[1].runtime}, ${e[2].runtime})`,Type:`Exit.Exit<${e[0].Type}, ${e[1].Type}, ${e[2].Type}>`,importDeclarations:[`import * as Exit from "effect/Exit"`]}),expected:`Exit`,toCodec:([e,t,n])=>xw()(uw([z({_tag:$C(`Success`),value:e}),z({_tag:$C(`Failure`),cause:Hw(t,n)})]),Hy({decode:e=>e._tag===`Success`?of(e.value):sf(e.cause),encode:e=>ff(e)?{_tag:`Success`,value:e.value}:{_tag:`Failure`,cause:e.cause}}))}).ast,{value:e,error:t,defect:n})}function Ww(e){return JC(AC()([e],([e])=>(t,n,r)=>_r(t)?E(t)?Hp:th(BS(e)(t.value,r),{onSuccess:T,onFailure:e=>oy(n,`value`,e,t,r)}):Kp(new iy(n,t,r)),{representation:{id:`effect/schema/Option`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Option(${e[0].runtime})`,Type:`Option.Option<${e[0].Type}>`,importDeclarations:[`import * as Option from "effect/Option"`]}),expected:`Option`,toCodec:([e])=>xw()(uw([z({_tag:$C(`Some`),value:e}),z({_tag:$C(`None`)})]),Hy({decode:e=>e._tag===`None`?w():T(e.value),encode:e=>D(e)?{_tag:`Some`,value:e.value}:{_tag:`None`}}))}).ast,{value:e})}var Gw=globalThis.Symbol.for(`immer-draftable`),Kw={};function qw(t,n,r,i,a){let o=Zw(r,n,i),s=Xw(n),c=class extends t{constructor(...[e,t]){let n=t?.[`~payload`],i=n?.token===Kw?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:Kw,value:i}})}static[kC]=kC;get[s](){return s}static[Gw]=!0;static identifier=n;static fields=r.fields;static get ast(){return o(this).ast}static pipe(){return e(this,arguments)}static rebuild(e){return o(this).rebuild(e)}static make(e,t){return rC(qx(o(this).ast),e??{},t,e=>Jw(this,e))}static makeOption(e,t){return FS(o(this))(e??{},t)}static makeEffect(e,t){return o(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Dx(this.ast,e))}static annotateKey(e){return this.rebuild(Lx(this.ast,e))}static check(...e){return this.rebuild(kx(this.ast,e))}static extend(e){return(t,n)=>{let i=Qw(t)?t:z(t),o={...r.fields,...i.fields},s=Jb(o,r.ast.checks,{identifier:e});return qw(this,e,ow(kx(s,i.ast.checks),o),n,a)}}static mapFields(e,t){return r.mapFields(e,t)}};return a!==void 0&&Object.assign(c.prototype,a(n)),c}function Jw(e,t){return new e(t,{"~payload":{token:Kw,value:t}})}function Yw(e){return new Ry(Oy(t=>Jw(e,t)),Dy())}function Xw(e){return`~effect/Schema/Class/${e}`}function Zw(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=Xw(t),o=e=>e instanceof i||b(e,a),s=Yw(i);return r=hw(JC(new mb([e.ast],()=>(e,t,n)=>o(e)?j(e):Kp(new iy(t,e,n)),{identifier:t,[Vv]:([e])=>({isConstructed:o,link:new lb(e,s)}),toCodec:([e])=>new lb(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Bv]:$b(e.ast),...n})),s)(e)}}function Qw(e){return YC(e)}var $w=e=>(t,n)=>qw(Po,e,Qw(t)?t:z(t),n,e=>({toString(){return`${e}(${ft({...this})})`}})),eT=e=>(t,n)=>qw(Dn,e,Qw(t)?t:z(t),n,e=>({name:e})),tT=e=>(t,n,r)=>{let i=Qw(n)?n.mapFields(e=>({_tag:_w(t),...e}),{unsafePreserveChecks:!0}):vw(t,n);return eT(e??t)(i,r)};function nT(e){return vC(e.ast)}var rT=uC,iT=JC(Dx(pS,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),aT=$u,oT=ed,sT=`~effect/MutableRef`,cT={[sT]:sT,...Wt,toJSON(){return{_id:`MutableRef`,current:wt(this.current)}}},lT=e=>{let t=Object.create(cT);return t.current=e,t},uT=r(2,(e,t)=>(e.current=t,e)),dT=`~effect/PubSub`,fT=`~effect/PubSub/Subscription`,pT=e=>M(()=>kT(e.atomicPubSub(),new Map,kf(),aT(!1),lT(!1),e.strategy(),lT(w()))),mT=e=>pT({atomicPubSub:()=>hT(e),strategy:()=>new AT}),hT=e=>{let t=e?.replay;return new TT(t&&t>0?new NT(Math.ceil(t)):void 0)},gT=r(2,(e,t)=>e.shutdownFlag.current||D(e.ended.current)?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),_T=e=>Lm(bm(t=>{let n=ii(t,Of),r=Nf(e.scope),i=wT(e.pubsub,e.subscribers,e.strategy,e.ended);return Mf(r,vT(i)).pipe(em(jf(n,e=>Pf(r,e))),im(i))})),vT=e=>Lm(Qp(t=>(uT(e.shutdownFlag,!0),Rp(yh(e.pollers),e=>Cf(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(tm(()=>M(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),_m(e.shutdownHook.open),am)))),yT=e=>Up(function t(n){if(e.shutdownFlag.current)return Pm;let r=e.pollers.length===0?e.subscription.pollUpTo(1/0):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?j(e.replayWindow.takeAll().concat(r)):Ui(r)?j(r):F(bT(e),e=>t([e]))}),bT=e=>Wp(t=>{if(e.shutdownFlag.current)return t(Pm);if(D(e.ended.current)){let n=e.pollers.length===0?e.subscription.poll():lh;return n===lh?t(j(e.ended.current.value)):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),t(j(n)))}let n=yf(),r=e.subscribers.get(e.subscription);return r||(r=new Set,e.subscribers.set(e.subscription,r)),r.add(e.pollers),ph(e.pollers,n),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),n.effect?t(n.effect):(n.resumes=[t],M(()=>Sh(e.pollers,n)))}),xT=Symbol.for(`effect/PubSub/AbsentValue`),ST=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)},CT=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.delete(n),r.size===0&&e.delete(t)},wT=(e,t,n,r)=>new DT(e,t,e.subscribe(),uh(),aT(!1),lT(!1),n,e.replayWindow(),r),TT=class{publisherHead={value:xT,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=2**53-1;replayBuffer;constructor(e){this.replayBuffer=e}replayWindow(){return this.replayBuffer?new PT(this.replayBuffer):FT}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(e){let t=this.replayBuffer?.offer(e),n=this.publisherTail.subscribers;if(n!==0){let r={value:e,replayIndex:t,subscribers:n,next:null};this.publisherTail.next=r,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(e){if(this.publisherTail.subscribers!==0)for(let t of e)this.publish(t);else this.replayBuffer&&this.replayBuffer.offerAll(e);return[]}slide(){if(this.publisherHead!==this.publisherTail){let e=this.publisherHead.next,t=e.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=xT,this.subscribersIndex+=1,this.replayBuffer?.slide(t,e.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new ET(this,this.publisherTail,this.publisherIndex,!1)}},ET=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(e,t,n,r){this.self=e,this.subscriberHead=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){if(this.unsubscribed)return!0;let e=!0,t=!0;for(;t;)this.subscriberHead===this.self.publisherTail?t=!1:this.subscriberHead.next.value===xT?(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1):(e=!1,t=!1);return e}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return lh;let e=!0,t=lh;for(;e;)if(this.subscriberHead===this.self.publisherTail)e=!1;else{let n=this.subscriberHead.next.value;n!==xT&&(t=n,--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=xT,this.self.subscribersIndex+=1),e=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return t}pollUpTo(e){e=fi(e);let t=[],n=0;for(;n!==e;){let r=this.poll();r===lh?n=e:(t.push(r),n+=1)}return t}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,--this.self.publisherTail.subscribers;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==xT&&(--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=xT,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},DT=class{[fT]={_A:i};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;ended;constructor(e,t,n,r,i,a,o,s,c){this.pubsub=e,this.subscribers=t,this.subscription=n,this.pollers=r,this.shutdownHook=i,this.shutdownFlag=a,this.strategy=o,this.replayWindow=s,this.ended=c}pipe(){return e(this,arguments)}},OT=class{[dT]={_A:i};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;ended;constructor(e,t,n,r,i,a,o){this.pubsub=e,this.subscribers=t,this.scope=n,this.shutdownHook=r,this.shutdownFlag=i,this.strategy=a,this.ended=o}pipe(){return e(this,arguments)}},kT=(e,t,n,r,i,a,o)=>new OT(e,t,n,r,i,a,o),AT=class{get shutdown(){return N}handleSurplus(e,t,n,r){return j(!1)}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return jT(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return MT(this,e,t)}},jT=(e,t,n,r,i)=>{let a=!0;for(;a&&!r.isEmpty();){let o=bh(i);if(o===lh)CT(n,r,i),i.length===0?a=!1:ST(n,r,i);else{let a=r.poll();a===lh?mh(i,o):(Ef(o,of(a)),e.onPubSubEmptySpaceUnsafe(t,n))}}},MT=(e,t,n)=>{for(let[r,i]of n)for(let a of i)e.completePollersUnsafe(t,n,r,a)},NT=class{capacity;head={value:xT,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(e){this.capacity=e}slide(e,t){this.slideValues[this.index%this.capacity]={value:e,index:t},this.index++}offer(e){let t=this.publisherIndex++;if(this.tail.value=e,this.tail.index=t,this.tail.next={value:xT,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity){let e=this.head;this.head=e.next,e.next=null,e.value=xT}else this.size+=1;return t}offerAll(e){for(let t of e)this.offer(t)}},PT=class{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(e){this.buffer=e,this.remaining=e.size,this.slideIndex=e.index,this.values=Array(this.remaining);let t=e.head;for(let e=0;e<this.remaining;e++)this.values[e]=t.value,this.newestIndex=t.index,t=t.next}close(){this.values.length=0,this.remaining=0}sync(){let e=this.buffer.index-this.slideIndex;if(e===0||this.remaining===0)return;let t=Math.min(e,this.buffer.capacity),n=this.buffer.index-t;for(let e=0;e<t;e++){let t=this.buffer.slideValues[(n+e)%this.buffer.capacity];t.index>this.newestIndex&&(this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=t.value,this.newestIndex=t.index)}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let e=this.values[this.index];return this.values[this.index]=xT,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),e}takeN(e){e=fi(e);let t=Math.min(e,this.remaining),n=Array(t);for(let e=0;e<t;e++)n[e]=this.take();return n}takeAll(){return this.takeN(this.remaining)}},FT={remaining:0,take:()=>void 0,takeN:()=>[],takeAll:()=>[],close:()=>void 0},IT=`~effect/Channel`,LT=e=>b(e,IT),RT={[IT]:{_Env:i,_InErr:i,_InElem:i,_OutErr:i,_OutElem:i},pipe(){return e(this,arguments)}},zT=e=>{let t=Object.create(RT);return t.transform=(t,n)=>sm(e(t,n),e=>j(qp(e))),t},BT=(e,t)=>zT((n,r)=>F(UT(e)(n,r),e=>t(e,r))),VT=e=>zT((t,n)=>e),HT=e=>zT(Qm(function*(t,n){let r=Nf(n),i=e=>Pf(r,Pp(e));return Am(yield*Am(e(t,n,r),i),i)})),UT=e=>e.transform,WT=(e,t,n)=>Oh({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(tm(t=>Mf(e,Lh(t))),tm(n=>Af(t(n),e).pipe(sm(e=>Ph(n,e)),Gm(e,{startImmediately:!0})))),GT=(e,t)=>zT((n,r)=>rm(WT(r,e,t),zh)),KT=e=>zT((t,n)=>Up(()=>UT(e())(t,n))),qT=e=>VT(M(()=>{let t=e();return Up(()=>{let e=t.next();return e.done?rf(e.value):j(e.value)})})),JT=e=>eE(j(e)),YT=VT(j(rf())),XT=VT(j(Gp)),ZT=e=>VT(j(Kp(e))),QT=e=>VT(qp(e)),$T=e=>QT(Gd(e)),eE=e=>VT(M(()=>{let t=!1;return Up(()=>t?rf():(t=!0,e))})),tE=e=>VT(j(zh(e))),nE=e=>VT(j(Im(yT(e),()=>rf()))),rE=e=>SE(rm(_T(e),nE)),iE=e=>zT((t,n)=>aE({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),aE=e=>{let t=e.readable.getReader(),n=e.exit??lT(void 0),r=Up(()=>n.current?n.current:vm(Vp({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??qp(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?rf():j(ha(t))}));return im(Mf(e.scope,e.releaseLockOnEnd?M(()=>t.releaseLock()):Bp(()=>t.cancel().catch(e=>t.closed.then(()=>Promise.reject(e),u))).pipe(km(M(()=>t.releaseLock())))),r)},oE=r(2,(e,t)=>BT(e,e=>M(()=>{let n=0;return rm(e,e=>t(e,n++))}))),sE=e=>e===void 0||e!==`unbounded`&&e<=1,cE=r(e=>LT(e[0]),(e,t,n)=>sE(n?.concurrency)?lE(e,t):uE(e,t,n)),lE=(e,t)=>zT((n,r)=>{let i=0;return rm(UT(e)(n,r),F(e=>t(e,i++)))}),uE=(e,t,n)=>HT(Qm(function*(r,i,o){let s=0,c=yield*UT(e)(r,i),l=n.concurrency===`unbounded`?2**53-1:Math.min(n.concurrency,2**53-1),u=yield*kh(0);yield*Mf(o,Lh(u));let d=Jm(yield*ym()),f=ch(o);if(n.unordered){let e=og(l),n=a(e.release(1)),r=vm({onFailure:e=>F(Ph(u,e),n),onSuccess:e=>F(Ah(u,e),n)});yield*e.take(1).pipe(F(()=>c),F(e=>{let n=s++;return f(d(r(Up(()=>t(e,n))))),N}),zm({disableYield:!0}),sm(t=>e.withPermits(l-1)(Ph(u,t))),Gm(o))}else{let e=yield*kh(l-2);yield*Mf(o,Lh(e)),yield*Vh(e).pipe($p,F(e=>Ah(u,e)),zm({disableYield:!0}),sm(e=>Ph(u,e)),Gm(o));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,Fh(u,e.cause))};yield*c.pipe(F(i=>{if(n)return qp(n);let a=s++,o=d(Up(()=>t(i,a)));return f(o),o.addObserver(r),Ah(e,ih(o))}),zm({disableYield:!0}),sm(t=>Ah(e,sf(t)).pipe(em(Ph(e,t)))),Gm(o))}return Vh(u)})),dE=r(e=>LT(e[0]),(e,t,n)=>sE(n?.concurrency)?fE(e,t):pE(e,t,n)),fE=(e,t)=>zT((n,r)=>rm(UT(e)(n,r),e=>{let i,a,o=F(e,e=>(a??=Nf(r),nh(UT(t(e))(n,a),e=>(i=s(e),i)))),s=kp(e=>{if(i=void 0,a.state._tag===`Empty`)return o;let t=Pf(a,df);return a=void 0,F(t,()=>o)});return Up(()=>i??o)})),pE=(e,t,n)=>e.pipe(oE(t),bE(n)),mE=e=>dE(e,i),hE=e=>BT(e,e=>{let t,n=0;return j(Up(function r(){if(t===void 0)return F(e,e=>{switch(e.length){case 0:return r();case 1:return j(e[0]);default:return t=e,j(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),j(i)}))}),gE=r(2,(e,t)=>zT((n,r)=>{let i=Nf(r);return rm(UT(e)(n,i),e=>{let a=e.pipe(sm(e=>{if(Ap(e))return qp(e);let o=i;return i=Nf(r),Pf(o,sf(e)).pipe(em(UT(t(e))(n,i)),F(e=>(a=e,e)))}));return Up(()=>a)})})),_E=r(3,(e,t,n)=>gE(e,e=>{let r=t(e);return yi(r)?QT(r.failure):n(r.success,e)})),vE=r(2,(e,t)=>_E(e,ys,e=>t(e))),yE=r(e=>LT(e[0]),(e,t,n)=>e.pipe(oE(t),bE({...n,concurrency:n?.concurrency??1,switch:!0}))),bE=r(2,(e,{bufferSize:t=16,concurrency:n,switch:r=!1})=>HT(Qm(function*(i,a,o){let s=n===`unbounded`?2**53-1:Math.max(1,n),c=r?void 0:og(s),l=yield*oT(!0),u=new Map,d=yield*kh(t);yield*Mf(o,Lh(d));let f=yield*UT(e)(i,a);return yield*P(function*(){for(;;){let e;c&&(u.size<s?yield*c.take(1):(e=yield*Wm(f),yield*gm(c.take(1),em(ih(e),Gp))));let t=e===void 0?yield*f:yield*ih(e),n=Nf(o),r=yield*UT(t)(i,n);for(;u.size>=s;){let[e,t]=Ci(u);u.delete(e),u.size===0&&(yield*l.open),yield*ah(e),yield*pm(Pf(t,uf()))}let a=yield*r.pipe(tm(()=>Zp),F(e=>Ah(d,e)),zm({disableYield:!0}),Am(Qm(function*(e){let t=Pp(e),r=yield*nm(Pf(n,t));if(!u.has(a))return;let i=gf([t,r]);pf(i)&&(yield*Ph(d,i.cause)),u.delete(a),c&&(yield*c.release(1)),u.size===0&&(yield*l.open)})),Wm);l.closeUnsafe(),u.set(a,n)}}).pipe(sm(e=>bi(Mp(e))?l.whenOpen(Ph(d,e)):Ph(d,e)),Gm(o)),Vh(d)}))),xE=r(e=>LT(e[0])&<(e[1]),(e,t,n)=>HT(Qm(function*(r,i,a){let o=n?.haltStrategy??`both`,s=yield*kh(0);yield*Mf(a,Lh(s));let c=0;function l(e,t){if(c++,!Ap(t))return Ph(s,t);switch(o){case`both`:return c===2?Ph(s,t):N;case`left`:case`right`:return e===o?Ph(s,t):N;case`either`:return Ph(s,t)}}let u=(e,t,n)=>UT(t)(r,n).pipe(F(e=>e.pipe(F(e=>Ah(s,e)),zm)),Am(t=>jm(Pp(t),e=>Pf(n,e)).pipe(vm({onFailure:t=>l(e,t),onSuccess:()=>l(e,t)}))),Gm(a));return yield*u(`left`,e,Nf(a)),yield*u(`right`,t,Nf(a)),Vh(s)}))),SE=e=>zT((t,n)=>{let r;return j(Up(()=>r||e.pipe(Af(n),F(e=>UT(e)(t,n)),F(e=>r=e))))}),CE=e=>HT((t,n,r)=>rm(Af(UT(e)(t,n),r),Af(r))),wE=r(2,(e,t)=>xE(e,VT(j(F(t,rf))),{haltStrategy:`either`})),TE=r(2,(e,t)=>HT((n,r,i)=>jf(i,t).pipe(em(UT(e)(n,r))))),EE=r(2,(e,t)=>TE(e,e=>t)),DE=(e,t,n)=>Up(()=>{let r=kf();return kp(F(UT(e)(rf(),r),t),n||j).pipe(Mm(e=>Pf(r,e)))}),OE=r(2,(e,t)=>zT((n,r)=>rm(Sm(UT(e)(n,r),t),Sm(t)))),kE=r(2,(e,t)=>DE(e,e=>zm(F(e,t),{disableYield:!0}))),AE=e=>rm(jE(e,()=>({bytes:0,arrays:[]}),(e,t)=>{for(let n=0;n<t.length;n++)e.bytes+=t[n].length,e.arrays.push(t[n]);return e}),({arrays:e,bytes:t})=>{let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}),jE=r(3,(e,t,n)=>Up(()=>{let r=t();return DE(e,e=>zp({while:o,body:()=>e,step:e=>{r=n(r,e)}}),()=>j(r))})),ME=(e,t)=>UT(e)(rf(),t),NE=`~effect/Stream`,PE={_R:i,_E:i,_A:i},FE=function(e){this.channel=e};FE.prototype={[NE]:PE,pipe(){return e(this,arguments)}};var IE=e=>new FE(e),LE=`~effect/Stream`,RE=e=>b(e,LE),zE=IE,BE=e=>zE(eE(rm(e,ha))),VE=(e,t)=>zE(zT((n,r)=>F(ME(e.channel,r),e=>t(e,r)))),HE=e=>e.channel,UE=(e,t)=>zE(GT(e,t)),WE=zE(YT),GE=e=>zE(JT(ha(e))),KE=(...e)=>ZE(e),qE=e=>{let t=zE(KT(()=>e().channel));return JE.set(t,e),t},JE=new WeakMap,YE=e=>zE(ZT(e)),XE=e=>zE($T(e)),ZE=e=>Wi(e)?zE(JT(e)):WE,lee=e=>zE(tE(e)),QE=e=>zE(rE(e)),$E=e=>zE(iE(e)),eD=e=>zE(nE(e)),tD=zE(XT),nD=e=>zE(SE(rm(e,HE))),rD=e=>zE(CE(e.channel)),iD=r(2,(e,t)=>qE(()=>{let n=0;return zE(oE(e.channel,ga(e=>t(e,n++))))})),aD=r(e=>RE(e[0]),(e,t,n)=>e.channel.pipe(hE,cE(t,n),oE(ha),zE)),oD=r(e=>RE(e[0]),(e,t,n)=>e.channel.pipe(hE,dE(e=>t(e).channel,n),zE)),sD=r(e=>RE(e[0]),(e,t,n)=>e.channel.pipe(hE,yE(e=>t(e).channel,n),zE)),cD=r(2,(e,t)=>{let n=zE(mE(qT(()=>uD(e,t))));return lD.set(n,[e,t]),n}),lD=new WeakMap;function*uD(e,t){let n=[t,e];for(;n.length>0;){let e=n.pop(),t=lD.get(e);if(t!==void 0){n.push(t[1],t[0]);continue}let r=JE.get(e);if(r===void 0)yield e.channel;else{try{n.push(r())}catch(e){n.push(XE(e))}yield YT}}}var dD=r(2,(e,t)=>e.channel.pipe(gE(e=>t(e).channel),zE)),fD=r(2,(e,t)=>zE(vE(e.channel,e=>t(e).channel))),pD=e=>mD(e,Be),mD=r(2,(e,t)=>VE(e,(e,n)=>M(()=>{let n=!0,r;return F(e,function i(a){let o=[],s=0;for(n&&(n=!1,r=a[0],s=1,o.push(r));s<a.length;s++){let e=a[s];t(e,r)||(r=e,o.push(e))}return Ui(o)?j(o):F(e,i)})}))),hD=r(2,(e,t)=>zE(wE(e.channel,t))),gD=r(2,(e,t)=>zE(EE(e.channel,t))),_D=r(2,(e,t)=>zE(OE(e.channel,t))),vD=r(2,(e,t)=>kE(e.channel,e=>{let n=0;return zp({while:()=>n<e.length,body:()=>t(e[n++]),step:u})})),yD=r(2,(e,t)=>kE(e.channel,t)),bD=e=>rm(AE(e.channel),e=>e.buffer),xD=r(e=>RE(e[0]),(e,t,n)=>{let r,i,a=!1,o=aT(!1),s=n?.signal,c=()=>i.interruptUnsafe();return new ReadableStream({start(n){i=qm(Sm(kE(BT(e.channel,e=>j(o.whenOpen(e))),e=>M(()=>{o.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0})),t)),i.addObserver(e=>{s?.removeEventListener(`abort`,c),a||(e._tag===`Failure`&&s?.aborted!==!0?n.error(Qd(e.cause)):n.close())}),s!==void 0&&i.pollUnsafe()===void 0&&(s.aborted?c():s.addEventListener(`abort`,c,{once:!0}))},pull(){return new Promise(e=>{r=e,o.openUnsafe()})},cancel(){if(i)return a=!0,Ym(am(ah(i)))}},n?.strategy)}),SD=r(e=>RE(e[0]),(e,t)=>rm(ym(),n=>xD(e,n,t))),CD=`~effect/PrimaryKey`,wD={"~effect/Match/Matcher":{_input:i,_filters:i,_result:i,_return:i,_flavor:i},_tag:`ValueMatcher`,add(e){return bi(this.value)?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?TD(this.provided,mi(e.evaluate(this.provided))):this},pipe(){return e(this,arguments)}};function TD(e,t){let n=Object.create(wD);return n.provided=e,n.value=t,n}var ED=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),DD=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(DD),n=t.length;return e=>{if(!Array.isArray(e)||e.length<n)return!1;for(let r=0;r<n;r++)if(t[r](e[r])===!1)return!1;return!0}}if(typeof e==`object`&&e){let t=Reflect.ownKeys(e).map(t=>[t,DD(e[t])]),n=t.length;return e=>{if(typeof e!=`object`||!e)return!1;for(let r=0;r<n;r++){let[n,i]=t[r];if(!(n in e)||i(e[n])===!1)return!1}return!0}}return t=>t===e},OD=e=>TD(e,hi(e)),kD=()=>e=>e,AD=(e,t)=>n=>n.add(ED(DD(e),t)),jD=e=>(...t)=>{let n=t[t.length-1],r=t.slice(0,-1),i=r.length===1?t=>t!=null&&t[e]===r[0]:t=>t!=null&&r.includes(t[e]);return e=>e.add(ED(i,n))},MD=e=>t=>{let n=ED(n=>n!=null&&Object.hasOwn(t,n[e]),n=>t[n[e]](n));return e=>e.add(n)},ND=e=>t=>{let n=MD(e)(t);return e=>zD(n(e))},PD=jD(`_tag`),FD=ND(`_tag`),ID=e=>t=>{let n=LD(t);return vi(n)?n._tag===`Success`?n.success:e(n.failure):(...t)=>{let r=n(...t);return bi(r)?r.success:e(r.failure,...t)}},LD=e=>{if(e._tag===`ValueMatcher`)return e.value;let t=e.cases.length;if(t===1){let t=e.cases[0];return(...n)=>{let r=e.select(...n);return t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1?mi(t.evaluate(r,...n)):hi(r)}}return(...n)=>{let r=e.select(...n);for(let i=0;i<t;i++){let t=e.cases[i];if(t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1)return mi(t.evaluate(r,...n))}return hi(r)}},RD=`effect/match/Match/exhaustive: absurd`,zD=e=>{let t=LD(e);if(vi(t)){if(bi(t))return t.success;throw Error(RD)}return(...e)=>{let n=t(...e);if(bi(n))return n.success;throw Error(RD)}},BD=OD,VD=kD,HD=AD,UD=PD,WD=FD,GD=ID,KD=zD,qD={"~effect/Ref":{_A:i},...Wt,toJSON(){return{_id:`Ref`,ref:this.ref}}},JD=e=>{let t=Object.create(qD);return t.ref=lT(e),t},YD=e=>M(()=>JD(e)),XD=e=>M(()=>e.ref.current),ZD=r(2,(e,t)=>M(()=>uT(e.ref,t))),QD=r(2,(e,t)=>M(()=>{let n=e.ref.current;return e.ref.current=t,n})),$D=e=>e.ref.current,eO=(e,t)=>ff(e)?t(0):Yd(e.cause)?t(130):t(rO(Qd(e.cause))),tO=e=>r(e=>Lp(e[0]),(t,n)=>{let r=n?.disableErrorReporting===!0?t:dm(t,e=>Yd(e)?N:aO(Qd(e))?$m(e):N),i=n?.teardown??eO;qm(Qp(t=>{try{let e=globalThis.setInterval(u,2147483647);t.addObserver(()=>{clearInterval(e)})}catch{}return e({fiber:t,teardown:i}),r}))}),nO=`~effect/Runtime/errorExitCode`,rO=e=>{if(typeof e==`object`&&e&&`~effect/Runtime/errorExitCode`in e){let t=e[nO];if(typeof t==`number`)return t}return 1},iO=`~effect/Runtime/errorReported`,aO=e=>{if(typeof e==`object`&&e&&`~effect/Runtime/errorReported`in e){let t=e[iO];if(typeof t==`boolean`)return t}return!0},oO=`~effect/SubscriptionRef`,sO={...Wt,[oO]:{_A:i},toJSON(){return{_id:`SubscriptionRef`,value:this.value}}},cO=e=>rm(mT({replay:1}),t=>{let n=Object.create(sO);return n.semaphore=og(1),n.value=e,n.pubsub=t,gT(n.pubsub,e),n}),lO=e=>e.value,uO=e=>M(()=>e.value),dO=(e,t)=>{e.value=t,gT(e.pubsub,t)},fO=r(2,(e,t)=>e.semaphore.withPermit(M(()=>{let[n,r]=t(e.value);return dO(e,r),n}))),pO=r(2,(e,t)=>e.semaphore.withPermit(M(()=>dO(e,t(e.value))))),mO=(e,t,n)=>{t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n},hO=e=>{try{return e()}catch(e){throw Error(`Constructor adapter can only throw schema issues`,{cause:Gd(e)})}},gO=e=>e.checks!==void 0||e.encoding!==void 0||e.context!==void 0?!1:BD(e).pipe(VD(),WD({Declaration:()=>!1,Null:()=>!0,Undefined:()=>!0,Void:()=>!0,Never:()=>!0,Unknown:()=>!0,Any:()=>!0,String:()=>!0,Number:()=>!0,Boolean:()=>!0,BigInt:()=>!0,Symbol:()=>!0,Literal:()=>!0,UniqueSymbol:()=>!0,ObjectKeyword:()=>!0,Enum:()=>!0,TemplateLiteral:({parts:e})=>e.every(gO),Arrays:()=>!1,Objects:()=>!1,Union:({options:e,types:t})=>e?.mode!==`oneOf`&&t.every(gO),Suspend:()=>!1})),_O=e=>{let t=[];for(let{name:n,type:r}of e){if(n!==`_tag`&&!gO(qx(r)))return;t.push(n)}return t},vO=(e,t)=>{let n=vw(e,t),r=Object.hasOwn(t,`_tag`)?void 0:_O(n.ast.propertySignatures),i=e=>n.make(e??{}),a=r===void 0?i:t=>{let n=t??{};if(Object(n)!==n)return i(t);let a={};for(let o of r){let r=hO(()=>(o===`__proto__`?Object.hasOwn(n,o):Reflect.has(n,o))?n[o]:void 0);if(o===`_tag`){if(r!==void 0&&r!==e)return i(t);hO(()=>mO(a,o,e))}else hO(()=>mO(a,o,r))}return a};return new Proxy(function(){},{apply(e,t,n){return a(n[0])},get(e,t){return Reflect.get(n,t)},has(e,t){return Reflect.has(n,t)},getPrototypeOf(){return Reflect.getPrototypeOf(n)}})},yO=new Set([`members`,`subset`]),bO=new Set([`Rebuild`,`~type.parameters`,`Type`,`Encoded`,`DecodingServices`,`EncodingServices`,`~type.make.in`,`~type.make`,`~type.constructor.default`,`Iso`,`~type.mutability`,`~type.optionality`,`~encoded.mutability`,`~encoded.optionality`]),xO=(e,t)=>{let n=bw(t),r=ya(Object.keys(t),e=>Reflect.has(n,e)||bO.has(e)||yO.has(e));if(Ui(r))throw Error(`${e} names conflict with union properties: ${r.join(`, `)}`);let i={};for(let[e,n]of Object.entries(t))i[e]=vO(e,n);return Object.assign(n,i,{members:Object.values(i),subset:e=>{let t=[];for(let n of e){let e=i[n];if(!Object.hasOwn(i,n)||e===void 0)throw Error(`Union subset contains an unknown variant: ${n}`);t.push(e)}return uw(t)}})};function SO(e){return xO(`Message variant`,e)}function CO(e){return xO(`Variant`,e)}var wO=new Set(`accentColor alignContent alignItems alignSelf alignmentBaseline all anchorName anchorScope
|
|
15
|
-
animation animationComposition animationDelay animationDirection animationDuration animationFillMode
|
|
16
|
-
animationIterationCount animationName animationPlayState animationRange animationRangeEnd
|
|
17
|
-
animationRangeStart animationTimeline animationTimingFunction appearance aspectRatio backdropFilter
|
|
18
|
-
backfaceVisibility background backgroundAttachment backgroundBlendMode backgroundClip backgroundColor
|
|
19
|
-
backgroundImage backgroundOrigin backgroundPosition backgroundPositionX backgroundPositionY
|
|
20
|
-
backgroundRepeat backgroundSize baselineShift baselineSource blockSize border borderBlock
|
|
21
|
-
borderBlockColor borderBlockEnd borderBlockEndColor borderBlockEndStyle borderBlockEndWidth
|
|
22
|
-
borderBlockStart borderBlockStartColor borderBlockStartStyle borderBlockStartWidth borderBlockStyle
|
|
23
|
-
borderBlockWidth borderBottom borderBottomColor borderBottomLeftRadius borderBottomRightRadius
|
|
24
|
-
borderBottomStyle borderBottomWidth borderCollapse borderColor borderEndEndRadius borderEndStartRadius
|
|
25
|
-
borderImage borderImageOutset borderImageRepeat borderImageSlice borderImageSource borderImageWidth
|
|
26
|
-
borderInline borderInlineColor borderInlineEnd borderInlineEndColor borderInlineEndStyle
|
|
27
|
-
borderInlineEndWidth borderInlineStart borderInlineStartColor borderInlineStartStyle
|
|
28
|
-
borderInlineStartWidth borderInlineStyle borderInlineWidth borderLeft borderLeftColor borderLeftStyle
|
|
29
|
-
borderLeftWidth borderRadius borderRight borderRightColor borderRightStyle borderRightWidth
|
|
30
|
-
borderSpacing borderStartEndRadius borderStartStartRadius borderStyle borderTop borderTopColor
|
|
31
|
-
borderTopLeftRadius borderTopRightRadius borderTopStyle borderTopWidth borderWidth bottom
|
|
32
|
-
boxDecorationBreak boxShadow boxSizing breakAfter breakBefore breakInside captionSide caretColor clear
|
|
33
|
-
clip clipPath clipRule color colorInterpolation colorInterpolationFilters colorScheme columnCount
|
|
34
|
-
columnFill columnGap columnRule columnRuleColor columnRuleStyle columnRuleWidth columnSpan columnWidth
|
|
35
|
-
columns contain containIntrinsicBlockSize containIntrinsicHeight containIntrinsicInlineSize
|
|
36
|
-
containIntrinsicSize containIntrinsicWidth container containerName containerType content
|
|
37
|
-
contentVisibility counterIncrement counterReset counterSet cssFloat cursor cx cy d direction display
|
|
38
|
-
dominantBaseline dynamicRangeLimit emptyCells fieldSizing fill fillOpacity fillRule filter flex
|
|
39
|
-
flexBasis flexDirection flexFlow flexGrow flexShrink flexWrap float floodColor floodOpacity font
|
|
40
|
-
fontFamily fontFeatureSettings fontKerning fontLanguageOverride fontOpticalSizing fontPalette fontSize
|
|
41
|
-
fontSizeAdjust fontStretch fontStyle fontSynthesis fontSynthesisSmallCaps fontSynthesisStyle
|
|
42
|
-
fontSynthesisWeight fontVariant fontVariantAlternates fontVariantCaps fontVariantEastAsian
|
|
43
|
-
fontVariantEmoji fontVariantLigatures fontVariantNumeric fontVariantPosition fontVariationSettings
|
|
44
|
-
fontWeight forcedColorAdjust gap grid gridArea gridAutoColumns gridAutoFlow gridAutoRows gridColumn
|
|
45
|
-
gridColumnEnd gridColumnGap gridColumnStart gridGap gridRow gridRowEnd gridRowGap gridRowStart
|
|
46
|
-
gridTemplate gridTemplateAreas gridTemplateColumns gridTemplateRows height hyphenateCharacter
|
|
47
|
-
hyphenateLimitChars hyphens imageOrientation imageRendering inlineSize inset insetBlock insetBlockEnd
|
|
48
|
-
insetBlockStart insetInline insetInlineEnd insetInlineStart isolation justifyContent justifyItems
|
|
49
|
-
justifySelf left letterSpacing lightingColor lineBreak lineHeight listStyle listStyleImage
|
|
50
|
-
listStylePosition listStyleType margin marginBlock marginBlockEnd marginBlockStart marginBottom
|
|
51
|
-
marginInline marginInlineEnd marginInlineStart marginLeft marginRight marginTop marker markerEnd markerMid
|
|
52
|
-
markerStart mask maskClip maskComposite maskImage maskMode maskOrigin maskPosition maskRepeat maskSize
|
|
53
|
-
maskType mathDepth mathShift mathStyle maxBlockSize maxHeight maxInlineSize maxWidth minBlockSize
|
|
54
|
-
minHeight minInlineSize minWidth mixBlendMode objectFit objectPosition offset offsetAnchor
|
|
55
|
-
offsetDistance offsetPath offsetPosition offsetRotate opacity order orphans outline outlineColor
|
|
56
|
-
outlineOffset outlineStyle outlineWidth overflow overflowAnchor overflowBlock overflowClipMargin
|
|
57
|
-
overflowInline overflowWrap overflowX overflowY overscrollBehavior overscrollBehaviorBlock
|
|
58
|
-
overscrollBehaviorInline overscrollBehaviorX overscrollBehaviorY padding paddingBlock paddingBlockEnd
|
|
59
|
-
paddingBlockStart paddingBottom paddingInline paddingInlineEnd paddingInlineStart paddingLeft paddingRight
|
|
60
|
-
paddingTop page pageBreakAfter pageBreakBefore pageBreakInside paintOrder perspective perspectiveOrigin
|
|
61
|
-
placeContent placeItems placeSelf pointerEvents position positionAnchor positionArea positionTry
|
|
62
|
-
positionTryFallbacks positionTryOrder positionVisibility printColorAdjust quotes r resize right rotate
|
|
63
|
-
rowGap rubyAlign rubyPosition rx ry scale scrollBehavior scrollMargin scrollMarginBlock
|
|
64
|
-
scrollMarginBlockEnd scrollMarginBlockStart scrollMarginBottom scrollMarginInline scrollMarginInlineEnd
|
|
65
|
-
scrollMarginInlineStart scrollMarginLeft scrollMarginRight scrollMarginTop scrollPadding
|
|
66
|
-
scrollPaddingBlock scrollPaddingBlockEnd scrollPaddingBlockStart scrollPaddingBottom scrollPaddingInline
|
|
67
|
-
scrollPaddingInlineEnd scrollPaddingInlineStart scrollPaddingLeft scrollPaddingRight scrollPaddingTop
|
|
68
|
-
scrollSnapAlign scrollSnapStop scrollSnapType scrollTimeline scrollTimelineAxis scrollTimelineName
|
|
69
|
-
scrollbarColor scrollbarGutter scrollbarWidth shapeImageThreshold shapeMargin shapeOutside
|
|
70
|
-
shapeRendering stopColor stopOpacity stroke strokeDasharray strokeDashoffset strokeLinecap
|
|
71
|
-
strokeLinejoin strokeMiterlimit strokeOpacity strokeWidth tabSize tableLayout textAlign textAlignLast
|
|
72
|
-
textAnchor textAutospace textBox textBoxEdge textBoxTrim textCombineUpright textDecoration
|
|
73
|
-
textDecorationColor textDecorationLine textDecorationSkipInk textDecorationStyle
|
|
74
|
-
textDecorationThickness textEmphasis textEmphasisColor textEmphasisPosition textEmphasisStyle
|
|
75
|
-
textIndent textJustify textOrientation textOverflow textRendering textShadow textTransform
|
|
76
|
-
textUnderlineOffset textUnderlinePosition textWrap textWrapMode textWrapStyle timelineScope top
|
|
77
|
-
touchAction transform transformBox transformOrigin transformStyle transition transitionBehavior
|
|
78
|
-
transitionDelay transitionDuration transitionProperty transitionTimingFunction translate unicodeBidi
|
|
79
|
-
userSelect vectorEffect verticalAlign viewTimeline viewTimelineAxis viewTimelineInset viewTimelineName
|
|
80
|
-
viewTransitionClass viewTransitionName visibility webkitAlignContent webkitAlignItems webkitAlignSelf
|
|
81
|
-
webkitAnimation webkitAnimationDelay webkitAnimationDirection webkitAnimationDuration
|
|
82
|
-
webkitAnimationFillMode webkitAnimationIterationCount webkitAnimationName webkitAnimationPlayState
|
|
83
|
-
webkitAnimationTimingFunction webkitAppearance webkitBackfaceVisibility webkitBackgroundClip
|
|
84
|
-
webkitBackgroundOrigin webkitBackgroundSize webkitBorderBottomLeftRadius
|
|
85
|
-
webkitBorderBottomRightRadius webkitBorderRadius webkitBorderTopLeftRadius
|
|
86
|
-
webkitBorderTopRightRadius webkitBoxAlign webkitBoxFlex webkitBoxOrdinalGroup webkitBoxOrient
|
|
87
|
-
webkitBoxPack webkitBoxShadow webkitBoxSizing webkitFilter webkitFlex webkitFlexBasis
|
|
88
|
-
webkitFlexDirection webkitFlexFlow webkitFlexGrow webkitFlexShrink webkitFlexWrap
|
|
89
|
-
webkitJustifyContent webkitLineClamp webkitMask webkitMaskBoxImage webkitMaskBoxImageOutset
|
|
90
|
-
webkitMaskBoxImageRepeat webkitMaskBoxImageSlice webkitMaskBoxImageSource webkitMaskBoxImageWidth
|
|
91
|
-
webkitMaskClip webkitMaskComposite webkitMaskImage webkitMaskOrigin webkitMaskPosition webkitMaskRepeat
|
|
92
|
-
webkitMaskSize webkitOrder webkitPerspective webkitPerspectiveOrigin webkitTextFillColor
|
|
93
|
-
webkitTextSizeAdjust webkitTextStroke webkitTextStrokeColor webkitTextStrokeWidth webkitTransform
|
|
94
|
-
webkitTransformOrigin webkitTransformStyle webkitTransition webkitTransitionDelay
|
|
95
|
-
webkitTransitionDuration webkitTransitionProperty webkitTransitionTimingFunction webkitUserSelect
|
|
96
|
-
whiteSpace whiteSpaceCollapse widows width willChange wordBreak wordSpacing wordWrap writingMode x y
|
|
97
|
-
zIndex zoom`.split(/\s+/)),TO=new Set([`autofocus`,`autoplay`,`checked`,`controls`,`disabled`,`formNoValidate`,`hidden`,`inert`,`isMap`,`loop`,`multiple`,`muted`,`noValidate`,`open`,`playsInline`,`readOnly`,`required`,`reversed`,`selected`]),EO={colSpan:`colspan`,dateTime:`datetime`,formAction:`formaction`,formEnctype:`formenctype`,formMethod:`formmethod`,formNoValidate:`formnovalidate`,formTarget:`formtarget`,htmlFor:`for`,isMap:`ismap`,maxLength:`maxlength`,minLength:`minlength`,noValidate:`novalidate`,playsInline:`playsinline`,readOnly:`readonly`,rowSpan:`rowspan`,tabIndex:`tabindex`},DO=new Set(`accept.action.alt.autocomplete.cite.cols.dir.download.enctype.high.href.id.label.lang.low.max.method.min.name.optimum.pattern.placeholder.poster.preload.rel.rows.size.span.src.start.step.target.title.type.value.wrap`.split(`.`)),OO=new Set([`autofocus`,`id`,`title`,`lang`,`dir`,`tabIndex`,`hidden`,`inert`,`draggable`]),kO=new Set([`autofocus`,`id`,`tabIndex`]),AO=e=>{let t=EO[e];if(t!==void 0)return t;if(TO.has(e)||DO.has(e)||e===`draggable`)return e},jO=/[A-Z]/g,MO=e=>e.replace(jO,e=>e.toLowerCase()),NO={attributename:`attributeName`,attributetype:`attributeType`,basefrequency:`baseFrequency`,baseprofile:`baseProfile`,calcmode:`calcMode`,clippathunits:`clipPathUnits`,diffuseconstant:`diffuseConstant`,edgemode:`edgeMode`,filterunits:`filterUnits`,glyphref:`glyphRef`,gradienttransform:`gradientTransform`,gradientunits:`gradientUnits`,kernelmatrix:`kernelMatrix`,kernelunitlength:`kernelUnitLength`,keypoints:`keyPoints`,keysplines:`keySplines`,keytimes:`keyTimes`,lengthadjust:`lengthAdjust`,limitingconeangle:`limitingConeAngle`,markerheight:`markerHeight`,markerunits:`markerUnits`,markerwidth:`markerWidth`,maskcontentunits:`maskContentUnits`,maskunits:`maskUnits`,numoctaves:`numOctaves`,pathlength:`pathLength`,patterncontentunits:`patternContentUnits`,patterntransform:`patternTransform`,patternunits:`patternUnits`,pointsatx:`pointsAtX`,pointsaty:`pointsAtY`,pointsatz:`pointsAtZ`,preservealpha:`preserveAlpha`,preserveaspectratio:`preserveAspectRatio`,primitiveunits:`primitiveUnits`,refx:`refX`,refy:`refY`,repeatcount:`repeatCount`,repeatdur:`repeatDur`,requiredextensions:`requiredExtensions`,requiredfeatures:`requiredFeatures`,specularconstant:`specularConstant`,specularexponent:`specularExponent`,spreadmethod:`spreadMethod`,startoffset:`startOffset`,stddeviation:`stdDeviation`,stitchtiles:`stitchTiles`,surfacescale:`surfaceScale`,systemlanguage:`systemLanguage`,tablevalues:`tableValues`,targetx:`targetX`,targety:`targetY`,textlength:`textLength`,viewbox:`viewBox`,viewtarget:`viewTarget`,xchannelselector:`xChannelSelector`,ychannelselector:`yChannelSelector`,zoomandpan:`zoomAndPan`},PO=(e,t)=>{let n=MO(t);return e===`http://www.w3.org/2000/svg`?NO[n]??n:e===`http://www.w3.org/1998/Math/MathML`&&n===`definitionurl`?`definitionURL`:n},FO={accept:new Set([`input`]),action:new Set([`form`]),alt:new Set([`area`,`img`,`input`]),autocomplete:new Set([`form`,`input`,`select`,`textarea`]),autoplay:new Set([`audio`,`video`]),checked:new Set([`input`]),cite:new Set([`blockquote`,`del`,`ins`,`q`]),cols:new Set([`textarea`]),colSpan:new Set([`td`,`th`]),controls:new Set([`audio`,`video`]),dateTime:new Set([`del`,`ins`,`time`]),disabled:new Set([`button`,`fieldset`,`input`,`link`,`optgroup`,`option`,`select`,`textarea`]),download:new Set([`a`,`area`]),enctype:new Set([`form`]),formAction:new Set([`button`,`input`]),formEnctype:new Set([`button`,`input`]),formMethod:new Set([`button`,`input`]),formNoValidate:new Set([`button`,`input`]),formTarget:new Set([`button`,`input`]),high:new Set([`meter`]),href:new Set([`a`,`area`,`base`,`link`]),htmlFor:new Set([`label`,`output`,`script`]),isMap:new Set([`img`]),label:new Set([`optgroup`,`option`,`track`]),loop:new Set([`audio`,`video`]),low:new Set([`meter`]),max:new Set([`input`,`meter`,`progress`]),maxLength:new Set([`input`,`textarea`]),method:new Set([`form`]),min:new Set([`input`,`meter`]),minLength:new Set([`input`,`textarea`]),multiple:new Set([`input`,`select`]),muted:new Set([`audio`,`video`]),name:new Set([`a`,`button`,`details`,`embed`,`fieldset`,`form`,`iframe`,`img`,`input`,`map`,`meta`,`object`,`output`,`param`,`select`,`slot`,`textarea`]),noValidate:new Set([`form`]),open:new Set([`details`,`dialog`]),optimum:new Set([`meter`]),pattern:new Set([`input`]),placeholder:new Set([`input`,`textarea`]),playsInline:new Set([`video`]),poster:new Set([`video`]),preload:new Set([`audio`,`video`]),readOnly:new Set([`input`,`textarea`]),rel:new Set([`a`,`area`,`form`,`link`]),required:new Set([`input`,`select`,`textarea`]),reversed:new Set([`ol`]),rows:new Set([`textarea`]),rowSpan:new Set([`td`,`th`]),selected:new Set([`option`]),size:new Set([`hr`,`input`,`select`]),span:new Set([`col`,`colgroup`]),src:new Set([`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]),start:new Set([`ol`]),step:new Set([`input`]),target:new Set([`a`,`area`,`base`,`form`,`link`]),type:new Set([`a`,`button`,`embed`,`input`,`li`,`link`,`object`,`ol`,`param`,`script`,`source`,`style`,`ul`]),value:new Set([`button`,`data`,`input`,`li`,`meter`,`option`,`output`,`param`,`progress`,`select`,`textarea`]),wrap:new Set([`textarea`])},IO=(e,t)=>OO.has(t)||Object.hasOwn(FO,t)&&FO[t]?.has(e.toLowerCase())===!0,LO={li:new Set([`value`]),meter:new Set([`high`,`low`,`max`,`min`,`optimum`,`value`]),progress:new Set([`max`,`value`])},RO=(e,t,n)=>{let r=e.toLowerCase();return r===`textarea`&&t===`cols`&&n===0?`20`:r===`textarea`&&t===`rows`&&n===0?`2`:LO[r]?.has(t)===!0?String(Number(n)):String(n)},zO=new Set([`delayed`,`destroy`,`remove`]),BO=/^--(?:[A-Za-z0-9_-]|[^\u0000-\u007f])+$/,VO=/^-?[A-Za-z_][A-Za-z0-9_-]*$/,HO=e=>e.startsWith(`Webkit`)?`webkit${e.slice(6)}`:e,UO=e=>{if(e.startsWith(`--`))return e;if(e===`cssFloat`)return`float`;let t=HO(e).replace(jO,e=>`-${e}`).toLowerCase();return t.startsWith(`webkit-`)||t.startsWith(`ms-`)?`-${t}`:t},WO=new Set(Array.from(wO,UO)),GO=e=>{let t,n=0,r=!1;for(let i=0;i<e.length;i+=1){let a=e.charAt(i),o=e.charAt(i+1);if(r)a===`*`&&o===`/`&&(r=!1,i+=1);else if(a===`\\`){if(o===``)return!0;i+=1}else if(t!==void 0)a===t&&(t=void 0);else if(a===`/`&&o===`*`)r=!0,i+=1;else if(a===`"`||a===`'`)t=a;else if(a===`(`)n+=1;else if(a===`)`){if(n===0)return!0;--n}else if(n===0&&(a===`;`||a===`!`))return!0}return t!==void 0||n!==0||r},KO=e=>{let t=new Map;for(let n of Object.keys(e)){if(zO.has(n))throw Error(`[foldkit] h.Style property ${JSON.stringify(n)} is a Snabbdom lifecycle control rather than a CSS property. Foldkit h.Style accepts only declarations applied while the element exists.`);if(n===`cssText`||(n.startsWith(`--`)?!BO.test(n):!VO.test(n)))throw Error(`[foldkit] h.Style property ${JSON.stringify(n)} cannot be represented as one inline CSS declaration. Use a CSS property name without declaration delimiters.`);let r=HO(n);if(!n.startsWith(`--`)&&!wO.has(r)&&!WO.has(n))throw Error(`[foldkit] h.Style property ${JSON.stringify(n)} is not a CSSStyleDeclaration property supported by Foldkit. Use a known camel-case or declaration name, or a custom property beginning --.`);let i=UO(n),a=t.get(i);if(a!==void 0)throw Error(`[foldkit] h.Style properties ${JSON.stringify(a)} and ${JSON.stringify(n)} both name the ${JSON.stringify(i)} CSS declaration. Keep one spelling so the server, fresh client, and hydration have one owner for it.`);t.set(i,n);let o=e[n];if(typeof o!=`string`)throw Error(`[foldkit] h.Style value for ${JSON.stringify(n)} must be a string. Browser CSSOM assignment coerces other values while server serialization cannot preserve the same authored declaration.`);if(GO(o))throw Error(`[foldkit] h.Style value for ${JSON.stringify(n)} contains a unsafe CSS declaration syntax. Assigning one DOM style property rejects that value, while serializing it into a style attribute could activate additional or !important declarations. Keep the value to one declaration.`)}},qO=e=>UO(e),JO=e=>(KO(e),Object.fromEntries(Object.entries(e).map(([e,t])=>[UO(e),String(t)]))),YO=(e,t)=>{if(e===void 0)return;let n;for(let r of Object.keys(e))MO(r)===t&&(n=e[r]);return n},XO=Symbol(`foldkit/trusted-inner-html`),ZO=Symbol(`foldkit/client-only-properties`),QO=e=>e,$O=(e,t)=>{let n=QO(e);n[XO]=t,n[ZO]?.delete(`innerHTML`)},ek=(e,t)=>{let n=QO(e);(n[ZO]??=new Set).add(t),t===`innerHTML`&&Reflect.deleteProperty(n,XO)},tk=(e,t)=>{QO(e)[ZO]?.delete(t)},nk=e=>{if(e===void 0)return!1;let t=QO(e),n=t.innerHTML;return typeof n==`string`&&t[XO]===n},rk=(e,t)=>e!==void 0&&QO(e)[ZO]?.has(t)===!0,ik=e=>{let t=e.indexOf(`#`),n=e.indexOf(`.`),r=t>0?t:e.length,i=n>0?n:e.length;return e.slice(0,Math.min(r,i))},ak=e=>e.namespaceURI===null||e.namespaceURI===`http://www.w3.org/1999/xhtml`?e.localName:void 0,ok=(e,t,n)=>{n&&!e.hasAttribute(t)?e.setAttribute(t,``):!n&&e.hasAttribute(t)&&e.removeAttribute(t)},sk=(e,t,n)=>{let r=ak(e);if(t===`value`&&(r===`input`||r===`textarea`||r===`output`)){let t=String(n);Reflect.get(e,`defaultValue`)!==t&&Reflect.set(e,`defaultValue`,t),r===`input`&&e.getAttribute(`value`)!==t&&e.setAttribute(`value`,t)}else if(t===`checked`&&r===`input`){let t=!!n;Reflect.get(e,`defaultChecked`)!==t&&Reflect.set(e,`defaultChecked`,t),ok(e,`checked`,t)}else if(t===`selected`&&r===`option`){let t=!!n;Reflect.get(e,`defaultSelected`)!==t&&Reflect.set(e,`defaultSelected`,t),ok(e,`selected`,t)}else if(t===`muted`&&(r===`audio`||r===`video`)){let t=!!n;Reflect.get(e,`defaultMuted`)!==t&&Reflect.set(e,`defaultMuted`,t),ok(e,`muted`,t)}else if(t===`value`&&r===`select`){Reflect.set(e,`value`,n);for(let t of e.querySelectorAll(`option`))t.defaultSelected!==t.selected&&(t.defaultSelected=t.selected),ok(t,`selected`,t.selected)}},ck=(e,t)=>{let n=ak(e);if(t===`value`&&(n===`input`||n===`textarea`||n===`output`))Reflect.set(e,`defaultValue`,``),n===`input`?(e.removeAttribute(`value`),Reflect.set(e,`value`,``)):n===`output`&&Reflect.set(e,`value`,``);else if(t===`checked`&&n===`input`)Reflect.set(e,`defaultChecked`,!1),e.removeAttribute(`checked`),Reflect.set(e,`checked`,!1);else if(t===`selected`&&n===`option`)Reflect.set(e,`defaultSelected`,!1),e.removeAttribute(`selected`),Reflect.set(e,`selected`,!1);else if(t===`muted`&&(n===`audio`||n===`video`))Reflect.set(e,`defaultMuted`,!1),e.removeAttribute(`muted`),Reflect.set(e,`muted`,!1);else if(t===`value`&&n===`select`)for(let t of e.querySelectorAll(`option`))t.defaultSelected=!1,t.removeAttribute(`selected`)},lk=e=>{let t=e.data?.props,n=t!==void 0&&Object.hasOwn(t,`selected`),r=rk(t,`selected`),i=YO(e.data?.attrs,`selected`)!==void 0;return{defaultSelected:n&&!r?!!t.selected:i,selected:n?!!t.selected:void 0}},uk=(e,t)=>{if(e.sel!==void 0&&ik(e.sel).toLowerCase()===`option`)t.push(lk(e));else for(let n of e.children??[])typeof n!=`string`&&uk(n,t)},dk=(e,t)=>{let n=t.data?.props!==void 0&&Object.hasOwn(t.data.props,`innerHTML`),r=[];if(!n){uk(t,r);let n=r.values();for(let t of Array.from(e.options)){let e=n.next().value?.defaultSelected??!1;t.defaultSelected!==e&&(t.defaultSelected=e),ok(t,`selected`,e)}}let i=e.cloneNode(!0);if(!(i instanceof HTMLSelectElement))return;for(let t=0;t<e.options.length;t+=1){let n=e.options.item(t),r=i.options.item(t);n!==null&&r!==null&&(n.selected=r.selected)}let a=r.values();for(let t of Array.from(e.options)){let e=a.next().value?.selected;e!==void 0&&(t.selected=e)}},fk=(e,t)=>{e instanceof HTMLTextAreaElement?e.value=e.defaultValue:e instanceof HTMLOutputElement?e.defaultValue=e.textContent??``:e instanceof HTMLSelectElement&&dk(e,t)},pk=(e,t)=>{let n=ak(e);if(t===`value`&&n===`input`){let t=Reflect.get(e,`defaultValue`);Reflect.set(e,`value`,Reflect.get(e,`type`)===`file`?``:t)}else t===`checked`&&n===`input`?Reflect.set(e,`checked`,Reflect.get(e,`defaultChecked`)):t===`selected`&&n===`option`?Reflect.set(e,`selected`,Reflect.get(e,`defaultSelected`)):t===`muted`&&(n===`audio`||n===`video`)&&Reflect.set(e,`muted`,Reflect.get(e,`defaultMuted`))},mk=229,hk=e=>e.isComposing||e.keyCode===mk,gk=class extends Nr()(`@foldkit/MountTracker`){},_k=dw([`Live`,`Paused`]),vk=class extends Nr()(`@foldkit/MountRuntime`){},yk=Symbol.for(`foldkit/MountDefinition`),bk=(e,t)=>{Object.defineProperty(e,"name",{value:t,configurable:!0}),Object.defineProperty(e,yk,{value:yk})},xk=cD(KE(_k.make(`Live`)),tD),Sk=e=>(t,n)=>UE(r=>P(function*(){return jh(r,yield*e(t,n)),yield*Gp}));function Ck(e,t){if(le(t.args)){let n=n=>({name:e,args:n,f:Sk((e,r)=>t.execute({...n,element:e,viewStateChanges:r}))});return bk(n,e),n}{let n=()=>({name:e,f:Sk((e,n)=>t.execute({element:e,viewStateChanges:n}))});return bk(n,e),n}}function wk(e,t){if(le(t.args)){let n=n=>({name:e,args:n,f:(e,r)=>t.execute({...n,element:e,viewStateChanges:r})});return bk(n,e),n}{let n=()=>({name:e,f:(e,n)=>t.execute({element:e,viewStateChanges:n})});return bk(n,e),n}}r(2,(e,t)=>({...e,f:(n,r)=>e.f(n,r).pipe(iD(t))}));var Tk=Symbol(`foldkit/vnode-data-mask`),Ek={Attrs:1,Class:2,Dataset:4,On:8,Props:16,Style:32,OnUnmount:64};function Dk(e,t,n,r,i){return{sel:e,data:t,children:n,text:r,elm:i,key:t===void 0?void 0:t.key}}var Ok=`http://www.w3.org/1999/xlink`,kk=`http://www.w3.org/2000/xmlns/`,Ak=`http://www.w3.org/XML/1998/namespace`,jk=`http://www.w3.org/1999/xhtml`,Mk={"xlink:actuate":Ok,"xlink:arcrole":Ok,"xlink:href":Ok,"xlink:role":Ok,"xlink:show":Ok,"xlink:title":Ok,"xlink:type":Ok,"xml:base":Ak,"xml:lang":Ak,"xml:space":Ak,xmlns:kk,"xmlns:xlink":kk},Nk=(e,t)=>{if(e!==null&&e!==jk)return Mk[t]},Pk=(e,t)=>{let n=new Map;for(let r of Object.keys(e))n.set(PO(t,r),e[r]);return n},Fk=(e,t,n)=>{let r=Nk(e.namespaceURI,t);if(n===!0)r===void 0?e.setAttribute(t,``):e.setAttributeNS(r,t,``);else if(n===!1){if(r===void 0)e.removeAttribute(t);else{let n=t.indexOf(`:`),i=n===-1?t:t.slice(n+1);e.removeAttributeNS(r,i)}}else r===void 0?e.setAttribute(t,n):e.setAttributeNS(r,t,n)};function Ik(e,t){let n=t.elm,r=e.data.attrs,i=t.data.attrs;if(!r&&!i||r===i)return;r||={},i||={};let a=Pk(r,n.namespaceURI),o=Pk(i,n.namespaceURI);for(let[e,t]of o)a.get(e)!==t&&Fk(n,e,t);for(let e of a.keys())o.has(e)||Fk(n,e,!1)}var Lk={dataMask:Ek.Attrs,create:Ik,update:Ik},Rk={_tag:`Absent`},zk=/[\t\n\f\r ]+/,Bk=(e,t)=>{let n=e.data.attrs;if(n===void 0)return Rk;let r=Rk;for(let e of Object.keys(n))PO(t,e)===`class`&&(r={_tag:`Present`,value:n[e]});return r},Vk=(e,t)=>e._tag===`Absent`?t._tag===`Absent`:t._tag===`Present`&&e.value===t.value,Hk=e=>{let t=new Set;if(e._tag===`Absent`||typeof e.value==`boolean`)return t;for(let n of String(e.value).split(zk))n!==``&&t.add(n);return t};function Uk(e,t){let n,r,i=t.elm,a=e.data.class,o=t.data.class,s=e.data.attrs,c=t.data.attrs;if(!a&&!o||a===o&&s===c)return;let l=Bk(e,i.namespaceURI),u=Bk(t,i.namespaceURI);if(a===o&&Vk(l,u))return;if(a||={},o||={},a===o){for(r in o)o[r]&&!i.classList.contains(r)&&i.classList.add(r);return}let d=Hk(u);for(r in a)a[r]&&o[r]!==!0&&!d.has(r)&&i.classList.remove(r);for(r in o)n=o[r],n&&!i.classList.contains(r)?i.classList.add(r):n!==a[r]&&!d.has(r)&&i.classList.remove(r)}var Wk={dataMask:Ek.Class,create:Uk,update:Uk},Gk=/[A-Z]/g;function Kk(e,t){let n=t.elm,r=e.data.dataset,i=t.data.dataset,a;if(!r&&!i||r===i)return;r||={},i||={};let o=n.dataset;for(a in r)a in i||(o?a in o&&delete o[a]:n.removeAttribute(`data-`+a.replace(Gk,`-$&`).toLowerCase()));for(a in i)r[a]!==i[a]&&(o?o[a]=i[a]:n.setAttribute(`data-`+a.replace(Gk,`-$&`).toLowerCase(),i[a]))}var qk={dataMask:Ek.Dataset,create:Kk,update:Kk};function Jk(e,t,n){if(typeof e==`function`)e.call(t,n,t);else if(typeof e==`object`)for(let r=0;r<e.length;r++)Jk(e[r],t,n)}function Yk(e,t){let n=e.type,r=t.data.on;r&&r[n]&&Jk(r[n],t,e)}function Xk(){return function e(t){Yk(t,e.vnode)}}function Zk(e,t){let n=e.data.on,r=e.listener,i=e.elm,a=t&&t.data.on,o=t&&t.elm,s;if(n===a)a&&r&&t&&(t.listener=r,r.vnode=t);else{if(n&&r){if(a)for(s in n)a[s]||i.removeEventListener(s,r,!1);else for(s in n)i.removeEventListener(s,r,!1)}if(a){let r=t.listener=e.listener||Xk();if(r.vnode=t,n)for(s in a)n[s]||o.addEventListener(s,r,!1);else for(s in a)o.addEventListener(s,r,!1)}}}var Qk={dataMask:Ek.On,create:Zk,update:Zk,destroy:Zk},$k=Array.isArray;function eA(e){return typeof e==`string`||typeof e==`number`||e instanceof String||e instanceof Number}var tA=`http://www.w3.org/2000/svg`,nA=`http://www.w3.org/1998/Math/MathML`,rA=new Set([`foreignObject`,`desc`,`title`]),iA=new Set([`mi`,`mo`,`mn`,`ms`,`mtext`]),aA=new Set([`mglyph`,`malignmark`]),oA=new Set([`text/html`,`application/xhtml+xml`]),sA=(e,t,n,r,i)=>{if(e.ns=r,(n===void 0||!i.has(n))&&t!==void 0)for(let e=0;e<t.length;++e){let n=t[e];if(typeof n==`string`)continue;let a=n.data;a!==void 0&&sA(a,n.children,n.sel,r,i)}};function cA(e,t,n){sA(e,t,n,tA,rA)}var lA=e=>{let t=e?.attrs;if(t==null)return!1;for(let e of Object.keys(t))if(e.toLowerCase()===`encoding`){let n=t[e];return typeof n==`string`&&oA.has(n.toLowerCase())}return!1},uA=(e,t,n)=>{if(e.ns=nA,t===void 0)return;let r=n===void 0?void 0:ik(n);if(r===`annotation-xml`&&lA(e))return;let i=r!==void 0&&iA.has(r);for(let e=0;e<t.length;++e){let n=t[e];if(typeof n==`string`)continue;let r=n.data;if(r!==void 0){if(i){let e=n.sel===void 0?void 0:ik(n.sel);if(e===void 0||!aA.has(e))continue}uA(r,n.children,n.sel)}}};function dA(e,t,n){uA(e,t,n)}function fA(e,t,n){let r={},i,a,o;if(n===void 0?t!=null&&($k(t)?i=t:eA(t)?a=t.toString():t&&t.sel?i=[t]:r=t):(t!==null&&(r=t),$k(n)?i=n:eA(n)?a=n.toString():n&&n.sel&&(i=[n])),i!==void 0)for(o=0;o<i.length;++o)eA(i[o])&&(i[o]=Dk(void 0,void 0,void 0,i[o],void 0));return e.startsWith(`svg`)&&(e.length===3||e[3]===`.`||e[3]===`#`)?cA(r,i,e):e.startsWith(`math`)&&(e.length===4||e[4]===`.`||e[4]===`#`)&&dA(r,i,e),Dk(e,r,i,a,void 0)}function pA(e,t){return document.createElement(e,t)}function mA(e,t,n){return document.createElementNS(e,t,n)}function hA(){return AA(document.createDocumentFragment())}function gA(e){return document.createTextNode(e)}function _A(e){return document.createComment(e)}function vA(e,t,n){if(kA(e)){let t=e;for(;t&&kA(t);)t=AA(t).parent;e=t??e}kA(t)&&(t=AA(t,e)),n&&kA(n)&&(n=AA(n).firstChildNode),e.insertBefore(t,n)}function yA(e,t){e.removeChild(t)}function bA(e,t){kA(t)&&(t=AA(t,e)),e.appendChild(t)}function xA(e){if(kA(e)){for(;e&&kA(e);)e=AA(e).parent;return e??null}return e.parentNode}function SA(e){if(kA(e)){let t=AA(e),n=xA(t);if(n&&t.lastChildNode){let e=Array.from(n.childNodes);return e[e.indexOf(t.lastChildNode)+1]??null}return null}return e.nextSibling}function CA(e){return e.tagName}function wA(e,t){e.textContent=t}function TA(e){return e.textContent}function EA(e){return e.nodeType===1}function DA(e){return e.nodeType===3}function OA(e){return e.nodeType===8}function kA(e){return e.nodeType===11}function AA(e,t){let n=e;return n.parent??=t??null,n.firstChildNode??=e.firstChild,n.lastChildNode??=e.lastChild,n}var jA={createElement:pA,createElementNS:mA,createTextNode:gA,createDocumentFragment:hA,createComment:_A,insertBefore:vA,removeChild:yA,appendChild:bA,parentNode:xA,nextSibling:SA,tagName:CA,setTextContent:wA,getTextContent:TA,isElement:EA,isText:DA,isComment:OA,isDocumentFragment:kA},MA=Dk(``,{},[],void 0,void 0);function NA(e,t){return e===t?!0:e.sel!==t.sel||e.key!==t.key||e.identity!==t.identity||e.data?.is!==t.data?.is?!1:e.sel!==void 0||typeof e.text==typeof t.text}function PA(){throw Error(`The document fragment is not supported on this platform.`)}function FA(e,t){return e.isElement(t)}function IA(e,t){return e.isDocumentFragment?.(t)??!1}function LA(e,t,n){let r=new Map;for(let i=t;i<=n;++i){let t=e[i]?.key;t!==void 0&&r.set(t,i)}return r}var RA=[`create`,`update`,`remove`,`destroy`,`pre`,`post`],zA=void 0,BA=()=>zA??!1;function VA(e,t,n){let r={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},i={create:[],update:[],destroy:[]},a=t===void 0?jA:t,o=!1;for(let t of RA)for(let n of e){let e=n[t];e!==void 0&&(r[t].push(e),(t===`create`||t===`update`||t===`destroy`)&&i[t].push(n.dataMask))}let s=i.create.every(e=>e!==void 0),c=i.update.every(e=>e!==void 0),l=i.destroy.every(e=>e!==void 0);function u(e){let t=e.id?`#`+e.id:``,n=e.getAttribute(`class`),r=n?`.`+n.split(` `).join(`.`):``;return Dk(a.tagName(e).toLowerCase()+t+r,{},[],void 0,e)}function d(e){return Dk(void 0,{},[],void 0,e)}function f(e,t){return function(){if(--t===0){let t=a.parentNode(e);t!==null&&a.removeChild(t,e)}}}function p(e,t){let o=e.data,c=o?.hook;c?.init?.(e);let l=e.children,u=e.sel;if(u===`!`)e.text??=``,e.elm=a.createComment(e.text);else if(u===``)e.elm=a.createTextNode(e.text);else if(u!==void 0){let n=u.indexOf(`#`),d=u.indexOf(`.`,n),f=n>0?n:u.length,m=d>0?d:u.length,h=n!==-1||d!==-1?u.slice(0,Math.min(f,m)):u,g=o?.ns,_=g===void 0?a.createElement(h,o):a.createElementNS(g,h,o);e.elm=_,f<m&&_.setAttribute(`id`,u.slice(f+1,m)),d>0&&_.setAttribute(`class`,u.slice(m+1).replace(/\./g,` `));let v=o?.[Tk];if(!s||v===void 0||v!==0)for(let t=0;t<r.create.length;++t){let n=i.create[t];(n===void 0||v===void 0||(v&n)!==0)&&r.create[t](MA,e)}if(eA(e.text)&&(!$k(l)||l.length===0)&&a.appendChild(_,a.createTextNode(e.text)),$k(l))for(let e=0;e<l.length;++e){let n=l[e];n!=null&&a.appendChild(_,p(n,t))}c!==void 0&&(c.create?.(MA,e),c.insert!==void 0&&t.push(e))}else if(n?.experimental?.fragments&&e.children){e.elm=(a.createDocumentFragment??PA)();let n=o?.[Tk];if(!s||n===void 0||n!==0)for(let t=0;t<r.create.length;++t){let a=i.create[t];(a===void 0||n===void 0||(n&a)!==0)&&r.create[t](MA,e)}for(let n=0;n<e.children.length;++n){let r=e.children[n];r!=null&&a.appendChild(e.elm,p(r,t))}}else e.elm=a.createTextNode(e.text);return e.elm}function m(e,t){return a.parentNode(t)===e||(a.isDocumentFragment?.(e)??!1)}function h(e,t,n,r){for(;n<=r;++n){let r=t[n]?.elm;if(r!==void 0&&m(e,r))return r}return null}function g(e,t,n,r){return m(e,t)?a.nextSibling(t):h(e,n,r+1,n.length-1)}function _(e,t,n,r,i,a){return h(e,t,n,r)??h(e,i,a+1,i.length-1)}function v(e,t,n,r,i,o){for(;r<=i;++r){let i=n[r];i!=null&&a.insertBefore(e,p(i,o),t)}}function y(e){let t=e.data;if(t!==void 0){t?.hook?.destroy?.(e);let n=t[Tk];if(!l||n===void 0||n!==0)for(let t=0;t<r.destroy.length;++t){let a=i.destroy[t];(a===void 0||n===void 0||(n&a)!==0)&&r.destroy[t](e)}if(e.children!==void 0)for(let t=0;t<e.children.length;++t){let n=e.children[t];n!=null&&typeof n!=`string`&&y(n)}t?.hook?.postdestroy?.(e)}}function ee(e,t,n,i){for(;n<=i;++n){let i,o=t[n];if(o!=null){if(o.sel!==void 0){y(o),i=r.remove.length+1;let e=f(o.elm,i);for(let t=0;t<r.remove.length;++t)r.remove[t](o,e);let t=o.data?.hook?.remove;t===void 0?e():t(o,e)}else o.children?(y(o),ee(e,o.children,0,o.children.length-1)):a.removeChild(e,o.elm)}}}function te(e,t,n,r){if(!BA()||o)return;let i=new Set;for(let s=t;s<=n;++s){let t=e[s]?.key;if(t!==void 0){if(i.has(t)){o=!0;let e=a.isElement(r)?a.tagName(r).toLowerCase():String(r.nodeName).toLowerCase();console.warn(`[foldkit] Duplicate key "${String(t)}" among children of <${e}>. Keys must be unique among siblings; duplicates make sibling matching ambiguous and can patch the wrong element.`);return}i.add(t)}}}function ne(e,t,n,r){if(t.length===0&&n.length===0)return;te(n,0,n.length-1,e);let i=0,o=0,s=t.length-1,c=n.length-1;for(;i<=s&&o<=c&&t[i]===n[o];)i+=1,o+=1;for(;i<=s&&o<=c&&t[s]===n[c];)--s,--c;let l=t[i],u=t[s],d=n[o],f=n[c],y,ne,ie;for(;i<=s&&o<=c;)if(l==null)l=t[++i];else if(u==null)u=t[--s];else if(d==null)d=n[++o];else if(f==null)f=n[--c];else if(NA(l,d))re(l,d,r),l=t[++i],d=n[++o];else if(NA(u,f))re(u,f,r),u=t[--s],f=n[--c];else if(NA(l,f))re(l,f,r),m(e,l.elm)&&a.insertBefore(e,l.elm,g(e,u.elm,n,c)),l=t[++i],f=n[--c];else if(NA(u,d))re(u,d,r),m(e,u.elm)&&a.insertBefore(e,u.elm,_(e,t,i,s-1,n,c)),u=t[--s],d=n[++o];else{y===void 0&&(y=LA(t,i,s),te(t,i,s,e));let l=d.key;ne=l===void 0?void 0:y.get(l),ne===void 0?(a.insertBefore(e,p(d,r),_(e,t,i,s,n,c)),d=n[++o]):f.key===void 0||y.get(f.key)===void 0?(a.insertBefore(e,p(f,r),g(e,u.elm,n,c)),f=n[--c]):(ie=t[ne],NA(ie,d)?(re(ie,d,r),t[ne]=void 0,m(e,ie.elm)&&a.insertBefore(e,ie.elm,_(e,t,i,s,n,c))):a.insertBefore(e,p(d,r),_(e,t,i,s,n,c)),d=n[++o])}o<=c&&v(e,h(e,n,c+1,n.length-1),n,o,c,r),i<=s&&ee(e,t,i,s)}function re(e,t,n){if(e===t)return;let o=t.data?.hook;o?.prepatch?.(e,t);let s=t.elm=e.elm;if(t.data!==void 0||t.text!==void 0&&t.text!==e.text){t.data??={},e.data??={};let n=e.data[Tk],a=t.data[Tk];if(!c||n===void 0||a===void 0||(n|a)!==0)for(let o=0;o<r.update.length;++o){let s=i.update[o];(s===void 0||n===void 0||a===void 0||((n|a)&s)!==0)&&r.update[o](e,t)}t.data?.hook?.update?.(e,t)}let l=e.children,u=t.children;t.text===void 0?l!==void 0&&u!==void 0?l!==u&&ne(s,l,u,n):u===void 0?l===void 0?e.text!==void 0&&a.setTextContent(s,``):ee(s,l,0,l.length-1):(e.text!==void 0&&a.setTextContent(s,``),v(s,null,u,0,u.length-1,n)):e.text!==t.text&&(l!==void 0&&ee(s,l,0,l.length-1),a.setTextContent(s,t.text)),o?.postpatch?.(e,t)}return function(e,t,n){let i=[];o=!1;for(let e=0;e<r.pre.length;++e)r.pre[e]();if(FA(a,e)?e=u(e):IA(a,e)&&(e=d(e)),NA(e,t))re(e,t,i);else{let n=e.elm,r=a.parentNode(n);p(t,i),r!==null&&(a.insertBefore(r,t.elm,a.nextSibling(n)),ee(r,[e],0,0))}n?.(t);for(let e=0;e<i.length;++e)i[e].data.hook.insert(i[e]);for(let e=0;e<r.post.length;++e)r.post[e]();return t}}var HA=typeof window<`u`&&typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame.bind(window):setTimeout,UA=function(e){HA(function(){HA(e)})},WA=!1;function GA(e,t,n){e.setProperty(qO(t),String(n))}function KA(e,t){e.removeProperty(qO(t))}function qA(e,t,n){UA(function(){GA(e,t,n)})}function JA(e,t){let n=t.elm,r=t.data.style;if(!r)return;for(let e of Object.keys(r))e!==`delayed`&&e!==`destroy`&&e!==`remove`&&GA(n.style,e,r[e]);let i=Object.hasOwn(r,`delayed`)?r.delayed:void 0;if(typeof i==`object`&&i)for(let e of Object.keys(i))qA(n.style,e,i[e])}function YA(e,t){let n,r,i=t.elm,a=e.data.style,o=t.data.style;if(!a&&!o||a===o||o===void 0&&YO(t.data.attrs,`style`)!==void 0)return;a||={},o||={};let s=Object.hasOwn(a,`delayed`);for(r of Object.keys(a))r!==`delayed`&&r!==`destroy`&&r!==`remove`&&!Object.hasOwn(o,r)&&KA(i.style,r);for(r of Object.keys(o))if(n=o[r],r===`delayed`&&typeof o.delayed==`object`&&o.delayed!==null)for(let e of Object.keys(o.delayed))n=o.delayed[e],s&&n===a.delayed[e]||qA(i.style,e,n);else r!==`destroy`&&r!==`remove`&&n!==a[r]&&GA(i.style,r,n)}function XA(e){let t,n,r=e.elm,i=e.data.style;if(i&&Object.hasOwn(i,`destroy`)&&(t=i.destroy))for(n of Object.keys(t))GA(r.style,n,t[n])}function ZA(e,t){let n=e.data.style;if(!n||!Object.hasOwn(n,`remove`)||!n.remove){t();return}WA||=(e.elm.offsetLeft,!0);let r,i=e.elm,a=0,o=n.remove,s=0,c=[];for(r of Object.keys(o)){let e=qO(r);c.push(e),GA(i.style,r,o[r])}let l=getComputedStyle(i)[`transition-property`].split(`, `);for(;a<l.length;++a)c.indexOf(l[a])!==-1&&s++;i.addEventListener(`transitionend`,function(e){e.target===i&&--s,s===0&&t()})}function QA(){WA=!1}var $A={dataMask:Ek.Style,pre:QA,create:JA,update:YA,destroy:XA,remove:ZA};function ej(e){return e.slice(5).replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function tj(e,t){let n=t===void 0?jA:t,r;if(n.isElement(e)){let r=e.id?`#`+e.id:``,i=e.getAttribute(`class`)?.match(/[^\t\r\n\f ]+/g),a=i?`.`+i.join(`.`):``,o=n.tagName(e).toLowerCase()+r+a,s={},c={},l={},u=[],d,f,p,m=e.attributes,h=e.childNodes;for(f=0,p=m.length;f<p;f++)d=m[f].name,d.startsWith(`data-`)?c[ej(d)]=m[f].value||``:d!==`id`&&d!==`class`&&(s[d]=m[f].value);for(f=0,p=h.length;f<p;f++)u.push(tj(h[f],t));return Object.keys(s).length>0&&(l.attrs=s),Object.keys(c).length>0&&(l.dataset=c),o.startsWith(`svg`)&&(o.length===3||o[3]===`.`||o[3]===`#`)?cA(l,u,o):o.startsWith(`math`)&&(o.length===4||o[4]===`.`||o[4]===`#`)&&dA(l,u,o),Dk(o,l,u,void 0,e)}return n.isText(e)?(r=n.getTextContent(e),Dk(void 0,void 0,void 0,r,e)):n.isComment(e)?(r=n.getTextContent(e),Dk(`!`,{},[],r,e)):Dk(``,{},[],void 0,e)}var nj=`foldkitOnUnmount`,rj=!1,ij=new Map,aj=e=>e.data?.[nj],oj=(e,t)=>{e[nj]=t,e[Tk]=(e[Tk]??0)|Ek.OnUnmount},sj=()=>{ij.clear(),rj=!0},cj=()=>{rj=!1,ij.clear()},lj=(e,t)=>{let n=rj?`Replay`:`Live`,r=e[nj];oj(e,{dispatches:r?.owner===n?[...r.dispatches,t]:[t],owner:n})},uj=()=>{if(!rj)return;let e=globalThis.Array.from(ij.values());ij.clear();for(let t of e)for(let e of t)e()},dj={dataMask:Ek.OnUnmount,update:(e,t)=>{let n=aj(e);if(!rj||n?.owner!==`Live`)return;let r=t.data===void 0?{}:{...t.data};t.data=r,oj(r,n)},destroy:e=>{let t=aj(e);if(t?.owner===`Live`){if(rj)e.elm!==void 0&&ij.set(e.elm,t.dispatches);else for(let e of t.dispatches)e()}}},fj=`|`,pj=(e,t)=>{if(t.includes(fj))throw Error(`Foldkit: h.submodel slotId cannot contain the boundary separator "${fj}". Got ${JSON.stringify(t)}.`);return e===``?t:`${e}${fj}${t}`},mj=e=>e===``?[]:e.split(fj),hj=()=>({wraps:new Map,boundaryDispatches:new WeakMap,mountWraps:new WeakMap,mountWrapOwners:new Map,seenThisRender:new Map,lazyTrackingStack:[],boundaryWrapTransactionLog:[],activeBoundaryWrapTransaction:void 0,dedupeSeen:new Set}),gj=()=>{let e=(Error().stack??``).split(`
|
|
98
|
-
`);for(let t of e){let e=t.trim(),n=/[/\\]html[/\\]lazy\.[cm]?[jt]s/.test(e);if(!(e.length===0||e.startsWith(`Error`)||e.includes(`captureCallSite`)||e.includes(`assertBoundaryNotSeen`)||e.includes(`registerBoundaryWrap`)||e.includes(`restoreBoundaryWrapsForLazyHit`)||n||e.includes(`at submodel`)))return e}return`(call site unavailable)`},_j=(e,t)=>{let n=e.seenThisRender.get(t);if(n!==void 0){let e=t.includes(fj)?t.slice(t.lastIndexOf(fj)+1):t,r=gj();throw Error(`Foldkit: duplicate h.submodel slotId "${e}" at boundary "${t}".\n First registration: ${n}\n Second registration: ${r}\nEach h.submodel call inside the same parent boundary must use a unique \`slotId\`. The slotId is DOM-slot identity, not model identity. If the same model is rendered in two locations (desktop + mobile, master + detail), each slot needs its own id (e.g. "desktop-foo", "mobile-foo"). For lists, use a stable per-item identifier.`)}},vj=(e,t,n,r)=>{_j(e,t),yj(e,t,n,r,gj())},yj=(e,t,n,r,i)=>{let a=e.wraps.get(t),o=e.mountWraps.get(r),s=o?.get(t);e.activeBoundaryWrapTransaction!==void 0&&e.boundaryWrapTransactionLog.push({_tag:`Registration`,boundaryId:t,descriptor:n,mountOuterDispatch:r,previousDescriptor:a,previousMountDescriptor:s}),e.wraps.set(t,n);let c=o;c===void 0&&(c=new Map,e.mountWraps.set(r,c)),c.set(t,n);let l=e.mountWrapOwners.get(t);l===void 0&&(l=new Set,e.mountWrapOwners.set(t,l)),l.add(r),e.seenThisRender.set(t,i);for(let a of e.lazyTrackingStack)a.set(t,{callSite:i,descriptor:n,mountOuterDispatch:r})},bj=(e,t,n,r)=>{if(e.wraps.get(t)===n){e.wraps.delete(t);let n=e.mountWrapOwners.get(t);if(n!==void 0){for(let r of n)e.mountWraps.get(r)?.delete(t);e.mountWrapOwners.delete(t)}return}let i=e.mountWraps.get(r);if(i?.get(t)===n){i.delete(t);let n=e.mountWrapOwners.get(t);n?.delete(r),n?.size===0&&e.mountWrapOwners.delete(t)}},xj=(e,t,n,r,i,a)=>{e.wraps.get(t)===n&&(i===void 0?e.wraps.delete(t):e.wraps.set(t,i));let o=e.mountWraps.get(r);if(o?.get(t)===n){if(a===void 0){o.delete(t);let n=e.mountWrapOwners.get(t);n?.delete(r),n?.size===0&&e.mountWrapOwners.delete(t)}else o.set(t,a)}},Sj=e=>{let t={parent:e.activeBoundaryWrapTransaction,startIndex:e.boundaryWrapTransactionLog.length};return e.activeBoundaryWrapTransaction=t,t},Cj=(e,t)=>{if(e.activeBoundaryWrapTransaction!==t)throw Error(`Foldkit: boundary wrap transactions must commit in order.`);e.activeBoundaryWrapTransaction=t.parent,t.parent===void 0&&(e.boundaryWrapTransactionLog.length=0)},wj=(e,t)=>{if(e.activeBoundaryWrapTransaction!==t)throw Error(`Foldkit: boundary wrap transactions must roll back in order.`);let n=e.boundaryWrapTransactionLog.splice(t.startIndex);n.reverse();for(let t of n)t._tag===`Registration`?xj(e,t.boundaryId,t.descriptor,t.mountOuterDispatch,t.previousDescriptor,t.previousMountDescriptor):t.rollback();e.activeBoundaryWrapTransaction=t.parent},Tj=e=>{try{if(typeof e==`object`&&e&&`_tag`in e){let t=Reflect.get(e,`_tag`);if(typeof t==`string`)return`\`${t}\``}}catch{return`the Message`}return`the Message`},Ej=(e,t,n)=>{try{return e.toParentMessage(n)}catch(e){throw Error(`Foldkit: a Message dispatched from inside Submodel boundary "${t}" could not be lifted into its parent's Message type. Its \`toParentMessage\` rejected ${Tj(n)}, which means that Message is not part of the Submodel's own Message union. The usual cause is a shared view helper building an app-level Message inside a Submodel's view: a handler's dispatcher is chosen by where the element is built, not by the Message it carries, so the boundary tried to wrap a Message the Submodel does not own. Either move the Message into the Submodel's union, or have the parent supply the element through a \`viewInputs\` slot callback so it is built in the parent's boundary.`,{cause:e})}},Dj=(e,t,n)=>Error(e===`Dispatch`?`Foldkit: dispatchAcrossBoundary missing wrap for ancestor "${t}" of boundary "${n}". The Submodel's wrap was absent from the registry at dispatch time. A known cause: a slot callback (an h.submodel \`viewInputs\` function value) was invoked from a deferred context (setTimeout, Promise.then, a stored callback) after the parent Submodel unmounted. Slot callbacks must be invoked synchronously inside the render that created them. It can also mean foldkit was loaded as more than one instance (a bundler split foldkit and @foldkit/ui), so the wrap was registered in one copy and read from another.`:e===`OnUnmount`?`Foldkit: resolveBoundaryDispatchThunk missing wrap for ancestor "${t}" of boundary "${n}" while resolving an OnUnmount message. The Submodel's wrap was absent from the registry at resolve time, which should not happen during a live render.`:e===`Scene`?`Foldkit: boundaryMappers missing wrap for ancestor "${t}" of boundary "${n}" while snapshotting an OnMount lift. The Submodel's wrap was absent from the registry during render, which should not happen for a live boundary.`:`Foldkit: Mount dispatch missing wrap for ancestor "${t}" of boundary "${n}". The Submodel's wrap was absent from the Mount's render owner.`),Oj=(e,t,n,r,i)=>{let a=r,o=mj(t);for(let r=o.length;r>0;r--){let s=o.slice(0,r).join(fj),c=e.get(s);if(c===void 0)throw Dj(n,s,t);a=i(a,c,s)}return a},kj=(e,t,n)=>Ej(t,n,e),Aj=(e,t)=>(e.push(t.toParentMessage),e),jj=(e,t,n,r)=>{t(Oj(e.wraps,n,`Dispatch`,r,kj))},Mj=(e,t,n,r)=>{if(n===``)return()=>t(r);let i=Oj(e.wraps,n,`OnUnmount`,r,kj);return()=>t(i)},Nj=(e,t)=>Oj(e.wraps,t,`Scene`,[],Aj),Pj=(e,t,n)=>{if(n===``)return t;let r=e.boundaryDispatches.get(t);r===void 0&&(r=new Map,e.boundaryDispatches.set(t,r));let i=r.get(n);if(i!==void 0)return i;let a=r=>{jj(e,t,n,r)};return r.set(n,a),a},Fj=(e,t,n)=>n===``?t:r=>{let i=e.mountWraps.get(t);if(i===void 0)throw Error(`Foldkit: Mount dispatch missing wraps for boundary "${n}". The Mount's render owner has no registered Submodel boundaries.`);t(Oj(i,n,`Mount`,r,kj))},Ij=e=>{e.seenThisRender.clear(),e.dedupeSeen.clear()},Lj=[],Rj=()=>{let e=Lj[Lj.length-1];if(e===void 0)throw Error(`Foldkit: html element constructors must be called inside a runtime-driven render. The element was built outside a view, or foldkit was loaded as more than one instance (a bundler split foldkit and @foldkit/ui into separate copies).`);return e},zj=(e,t,n=hj(),r=`Live`)=>{Lj.push({outerDispatch:e,mountOuterDispatch:e,mountRenderOwner:r,runtimeContext:t,boundaryRegistry:n,boundaryId:``})},Bj=e=>{let t=Lj[Lj.length-1];if(t===void 0)throw Error(`Foldkit: pushBoundary called without an active runtime frame`);Lj.push({outerDispatch:t.outerDispatch,mountOuterDispatch:t.mountOuterDispatch,mountRenderOwner:t.mountRenderOwner,runtimeContext:t.runtimeContext,boundaryRegistry:t.boundaryRegistry,boundaryId:e})},Vj=e=>{Lj.push(e)},Hj=()=>{if(Lj.length===0)throw Error("Foldkit: clearRuntime called on an empty runtime stack. This means a `pushBoundary` or `setRuntime` was not paired with `clearRuntime` (or vice versa) upstream. Likely a bug in a custom Submodel integration or view-time helper.");Lj.pop()},Uj=()=>{let e=Rj();return Pj(e.boundaryRegistry,e.outerDispatch,e.boundaryId)},Wj=()=>{let e=Rj();return t=>Mj(e.boundaryRegistry,e.outerDispatch,e.boundaryId,t)},Gj=()=>{let e=Lj[Lj.length-1];return e===void 0?[]:Nj(e.boundaryRegistry,e.boundaryId)},Kj=()=>{let e=Rj();return{owner:e.mountRenderOwner,resolve:()=>Fj(e.boundaryRegistry,e.mountOuterDispatch,e.boundaryId)}},qj=()=>Rj().runtimeContext,Jj=()=>{let e=Lj[Lj.length-1];if(e===void 0)throw Error(`Foldkit: getCurrentFrame called without an active runtime frame`);return e},Yj=`__childAttribute`,Xj=e=>typeof e==`object`&&!!e&&Yj in e,Zj=new WeakMap,Qj=e=>{let t=Zj.get(e);if(t!==void 0)return t;let n={targets:new Set,pendingEmptyCheck:!1};return Zj.set(e,n),n},$j=(e,t)=>{for(let n of t)n instanceof Node&&e.contains(n)||t.delete(n)},eM=(e,t,n)=>{$j(t,e.targets);let r=e.targets.size>0||e.pendingEmptyCheck;return e.targets.add(n??t),!r},tM=(e,t,n)=>(e.targets.delete(n??t),$j(t,e.targets),e.targets.size>0||e.pendingEmptyCheck?`done`:(e.pendingEmptyCheck=!0,`schedule`)),nM=e=>(e.pendingEmptyCheck=!1,e.targets.size===0),rM=e=>{let t=Zj.get(e);t!==void 0&&(t.targets.clear(),t.pendingEmptyCheck=!1)},iM=e=>{let t=(e.ownerDocument.defaultView?.Element??globalThis.Element).prototype;for(;t!==null;){let e=Object.getOwnPropertyDescriptor(t,`innerHTML`);if(e?.get!==void 0&&e.set!==void 0)return e;t=Object.getPrototypeOf(t)}throw Error(`[foldkit] The browser does not expose Element.innerHTML.`)},aM=e=>{let t=iM(e).get?.call(e);return typeof t==`string`?t:``},oM=(e,t)=>{iM(e).set?.call(e,t)},sM=(e,t,n)=>{if(t===`__proto__`)Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0});else{let r=e;r[t]=n}},cM=e=>(e.namespaceURI===null||e.namespaceURI===`http://www.w3.org/1999/xhtml`)&&e.localName.includes(`-`),lM=(e,t,n)=>cM(e)&&OO.has(n)&&!rk(t,n),uM=(e,t,n)=>{let r=AO(t);r!==void 0&&(t===`draggable`?e.setAttribute(r,String(n)):n===!0?e.setAttribute(r,``):n===!1?e.removeAttribute(r):e.setAttribute(r,String(n)))},dM=(e,t,n)=>{t===`__proto__`?Reflect.deleteProperty(e,t):typeof n==`boolean`?sM(e,t,!1):typeof n==`string`?sM(e,t,``):typeof n==`number`&&sM(e,t,0)};function fM(e,t){let n=t.elm,r=e.data?.props,i=t.data?.props;if((r||i)&&r!==i){if(r??={},i??={},n instanceof Element)for(let e of Object.keys(r))if(e===`innerHTML`&&Object.hasOwn(i,e)&&nk(r)!==nk(i)&&(nk(r)?oM(n,``):dM(n,e,r[e])),Object.hasOwn(i,e)&&!rk(r,e)&&rk(i,e)){if(ck(n,e),lM(n,r,e)){let t=AO(e);t!==void 0&&n.removeAttribute(t)}}else Object.hasOwn(i,e)&&rk(r,e)&&!rk(i,e)&&lM(n,i,e)&&dM(n,e,r[e]);for(let e of Object.keys(i)){let t=i[e],a=r[e],o=rk(r,e)!==rk(i,e);a===t&&!o||e===`value`&&n[e]===t||(e===`innerHTML`&&n instanceof Element&&nk(i)?oM(n,String(t)):n instanceof Element&&lM(n,i,e)?uM(n,e,t):sM(n,e,t))}for(let e of Object.keys(r))if(!Object.hasOwn(i,e)){let a=r[e];if(e===`innerHTML`&&n instanceof Element&&nk(r)){oM(n,``);continue}if(n instanceof Element&&lM(n,r,e)){let t=AO(e);t!==void 0&&n.removeAttribute(t);continue}if(n instanceof Element&&e===`value`&&(n.localName===`select`||n.localName===`textarea`||n.localName===`output`)){Object.hasOwn(i,`innerHTML`)||ck(n,e);continue}let o=AO(e);if(o!==void 0&&!rk(r,e)&&n instanceof Element){if(YO(t.data?.attrs,o)!==void 0){pk(n,e);continue}ck(n,e),n.removeAttribute(o);continue}n instanceof Element&&ck(n,e),dM(n,e,a)}}}var pM=VA([Lk,Wk,qk,Qk,dj,{dataMask:Ek.Props,create:fM,update:fM},$A]),mM=new WeakSet,hM=(e,t)=>{let n;for(let r=0;r<e.length;r++){let i=e[r],a=typeof i==`string`?i:gM(i,t);a!==i&&(n===void 0&&(n=e.slice()),n[r]=a)}return n},gM=(e,t)=>{let n=t.has(e);if(!n&&mM.has(e))return t.add(e),e;let r=n||e.elm!=null?{...e,elm:void 0}:e;if(t.add(e),r.children===void 0)return r;let i=hM(r.children,t);return i===void 0?r:r===e?{...e,children:i}:(r.children=i,r)},_M=(e,t=new Set)=>gM(e,t),vM=(e,t,n)=>{let r=e.parentNode;if(r===null)return pM(tj(e),t,n);let i=e.ownerDocument.createComment(``);return r.replaceChild(i,e),pM(tj(i),t,n)},yM=(e,t,n,r,i)=>{let a=t===null?fA(`!`):_M(t,r);return E(e)?vM(n,a,i):pM(e.value,a,i)},bM=e=>{let t=e.elm,n=pM(e,fA(`!`));return n.elm!==t&&t?.parentNode&&t.parentNode.removeChild(t),n},xM=e=>typeof e==`object`&&!!e&&!Array.isArray(e),SM=e=>{for(let t of Object.keys(e)){let n=e[t];CM(n)||(xM(n)||Array.isArray(n))&&wM(n,[t])}},CM=e=>Xj(e),wM=(e,t)=>{let n=(e,n)=>{let r=[...t,n];if(typeof e==`function`)throw Error(`Foldkit: h.submodel \`viewInputs\` may only contain functions at the top level. Found a function at \`viewInputs.${r.join(`.`)}\`. Lift it to the top level of \`viewInputs\` so it can be auto-scoped to the parent boundary, or pass the value as primitive data.`);CM(e)||(xM(e)||Array.isArray(e))&&wM(e,r)};if(Array.isArray(e))e.forEach((e,t)=>n(e,`[${t}]`));else if(xM(e))for(let t of Object.keys(e))n(e[t],t)},TM=(e,t)=>{if(!xM(e))return e;SM(e);let n={};for(let r of Object.keys(e)){let i=e[r];n[r]=typeof i==`function`?(...e)=>{Vj(t);try{return i(...e)}finally{Hj()}}:i}return n},EM=(e,t,n,r,i)=>{let a=e.data??{},o=a.hook??{},s=o.postdestroy,c=e=>{bj(t,n,r,i),s!==void 0&&s(e)},l={...e,data:{...a,hook:{...o,postdestroy:c}}};return mM.has(e)&&mM.add(l),l},DM=(e,t)=>{let n=Jj(),r=n.boundaryRegistry,i=pj(n.boundaryId,e.slotId),a={toParentMessage:e.toParentMessage},o=Sj(r);try{vj(r,i,a,n.mountOuterDispatch);let s=t,c;Bj(i);try{if(Object.hasOwn(e,`viewInputs`)){let t=TM(e.viewInputs,n),r=e.view;c=r(e.model,t,s)}else{let t=e.view;c=t(e.model,s)}}finally{Hj()}if(c===null)return wj(r,o),null;let l=EM(c,r,i,a,n.mountOuterDispatch);return Cj(r,o),l}catch(e){throw wj(r,o),e}},OM=zj,kM=Hj,AM=Symbol.for(`foldkit/html/fileHandler`),jM=(e,t)=>(e[AM]=t,e),MM=e=>({shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}),NM=e=>t=>{hk(t)||e(t)},PM=e=>b(e,`value`)&&ne(e.value)?e.value:b(e,`innerText`)&&ne(e.innerText)?e.innerText:b(e,`textContent`)&&ne(e.textContent)?e.textContent:``,FM=e=>e.target===e.currentTarget,IM=e=>e instanceof Element&&e.id===`foldkit-devtools`,LM=e=>e.currentTarget instanceof Element&&e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget),RM=dw([`Allow`,`Prevent`]),zM=dw([`Bubble`,`Stop`]);z({defaultAction:ZC(RM),propagation:ZC(zM),focusSelector:ZC(L)}),dw([`Ltr`,`Rtl`,`Auto`]);var BM={Ltr:`ltr`,Rtl:`rtl`,Auto:`auto`},VM=e=>BM[e],HM=new WeakMap,uee=sj,dee=cj,fee=uj,pee=`foldkitMount`,{Key:mee,Class:hee,Id:gee,Title:_ee,Lang:vee,Dir:yee,Tabindex:bee,Hidden:xee,Contenteditable:See,Draggable:Cee,Accesskey:wee,Translate:Tee,Inert:Eee,Popover:Dee,Popovertarget:Oee,Popovertargetaction:kee,OnClick:Aee,OnDoubleClick:jee,OnMouseDown:Mee,OnMouseUp:Nee,OnMouseEnter:Pee,OnMouseLeave:Fee,OnMouseOver:Iee,OnMouseOut:Lee,OnMouseMove:Ree,OnPointerMove:zee,OnPointerLeave:Bee,OnPointerDown:Vee,OnPointerUp:Hee,OnKeyDown:Uee,OnKeyDownPreventDefault:Wee,OnKeyDownSelf:Gee,OnKeyDownSelfPreventDefault:Kee,OnKeyDownFocus:qee,OnKeyUp:Jee,OnKeyUpPreventDefault:Yee,OnKeyPress:Xee,OnFocus:Zee,OnBlur:Qee,OnFocusEnter:$ee,OnFocusLeave:ete,OnInput:tte,OnChange:nte,OnBeforeInput:rte,OnBeforeInputPreventDefault:ite,OnFileChange:UM,OnSubmit:WM,OnReset:GM,OnScroll:KM,OnWheel:qM,OnCopy:JM,OnCut:YM,OnPaste:XM,OnPastePreventDefault:ZM,OnCopyText:QM,OnCutText:$M,OnCancel:eN,OnCancelPreventDefault:tN,OnToggle:nN,OnContextMenu:rN,OnDragStart:iN,OnDrag:aN,OnDragEnd:oN,OnDragEnter:sN,OnDragLeave:cN,OnDragOver:lN,AllowDrop:uN,OnDrop:dN,OnDropFiles:fN,OnTouchStart:pN,OnTouchEnd:mN,OnTouchMove:hN,OnTouchCancel:gN,OnAnimationStart:_N,OnAnimationEnd:vN,OnAnimationIteration:yN,OnTransitionEnd:bN,OnLoad:xN,OnError:SN,OnPlay:CN,OnPause:wN,OnEnded:TN,OnTimeUpdate:EN,OnVolumeChange:DN,OnSelect:ON,Value:kN,Checked:AN,Selected:jN,Open:MN,Placeholder:NN,Name:PN,Disabled:FN,Readonly:IN,Required:LN,Autofocus:RN,Spellcheck:zN,Autocorrect:BN,Autocapitalize:VN,InputMode:HN,EnterKeyHint:UN,Multiple:WN,Type:GN,Accept:KN,Autocomplete:qN,Pattern:JN,Maxlength:YN,Minlength:XN,Size:ZN,Cols:QN,Rows:$N,Max:eP,Min:tP,Step:nP,For:rP,Href:iP,Src:aP,Alt:oP,Target:sP,Rel:cP,Download:lP,Action:uP,Method:dP,Enctype:fP,Novalidate:pP,Formaction:mP,Formmethod:hP,Formnovalidate:gP,Formtarget:_P,Formenctype:vP,Colspan:yP,Rowspan:bP,Scope:xP,Headers:SP,Span:CP,Start:wP,Reversed:TP,CiteAttr:EP,Datetime:DP,Wrap:OP,List:kP,FormAttr:AP,LabelAttr:jP,ContentAttr:MP,Charset:NP,HttpEquiv:PP,Srcset:FP,Sizes:IP,Loading:LP,Decoding:RP,Fetchpriority:zP,Crossorigin:BP,Referrerpolicy:VP,Integrity:HP,Hreflang:UP,Ping:WP,Sandbox:GP,Allow:KP,Srcdoc:qP,Autoplay:JP,Controls:YP,Loop:XP,Muted:ZP,Poster:QP,Preload:$P,Playsinline:eF,High:tF,Low:nF,Optimum:rF,Usemap:iF,Ismap:aF,Role:oF,AriaLabel:sF,AriaLabelledBy:cF,AriaDescribedBy:lF,AriaHidden:uF,AriaExpanded:dF,AriaSelected:fF,AriaChecked:pF,AriaDisabled:mF,AriaRequired:hF,AriaInvalid:gF,AriaLive:_F,AriaControls:vF,AriaCurrent:yF,AriaOrientation:bF,AriaPressed:xF,AriaHasPopup:SF,AriaActiveDescendant:CF,AriaSort:wF,AriaMultiSelectable:TF,AriaModal:EF,AriaBusy:DF,AriaErrorMessage:OF,AriaRoleDescription:kF,AriaAtomic:AF,AriaAutocomplete:jF,AriaColcount:MF,AriaColindex:NF,AriaColspan:PF,AriaDescription:FF,AriaDetails:IF,AriaFlowto:LF,AriaKeyshortcuts:RF,AriaLevel:zF,AriaOwns:BF,AriaPlaceholder:VF,AriaPosinset:HF,AriaReadonly:UF,AriaRelevant:WF,AriaRowcount:GF,AriaRowindex:KF,AriaRowspan:qF,AriaSetsize:JF,AriaValuemax:YF,AriaValuemin:XF,AriaValuenow:ZF,AriaValuetext:QF,Attribute:$F,DataAttribute:eI,Style:tI,InnerHTML:nI,ViewBox:rI,Xmlns:iI,Fill:aI,FillRule:oI,ClipRule:sI,Stroke:cI,StrokeWidth:lI,StrokeLinecap:uI,StrokeLinejoin:dI,D:fI,Cx:pI,Cy:mI,R:hI,X:gI,Y:_I,Width:vI,Height:yI,X1:bI,Y1:xI,X2:SI,Y2:CI,Points:wI,Transform:TI,Opacity:EI,StrokeDasharray:DI,StrokeDashoffset:OI,Dx:kI,Dy:AI,Rotate:jI,TextAnchor:MI,DominantBaseline:NI,AlignmentBaseline:PI,BaselineShift:FI,TextLength:II,LengthAdjust:LI,FontFamily:RI,FontSize:zI,FontWeight:BI,FontStyle:VI,LetterSpacing:HI,WordSpacing:UI,TextDecoration:WI,WritingMode:GI,Rx:KI,Ry:qI,PathLength:JI,FillOpacity:YI,StrokeOpacity:XI,StrokeMiterlimit:ZI,PaintOrder:QI,VectorEffect:$I,Color:eL,Visibility:tL,Display:nL,Overflow:rL,PointerEvents:iL,Cursor:aL,ShapeRendering:oL,TextRendering:sL,ImageRendering:cL,ClipPath:lL,Mask:uL,Filter:dL,ClipPathUnits:fL,MaskUnits:pL,MaskContentUnits:mL,FilterUnits:hL,PrimitiveUnits:gL,Offset:_L,StopColor:vL,StopOpacity:yL,GradientUnits:bL,GradientTransform:xL,SpreadMethod:SL,Fx:CL,Fy:wL,Fr:TL,PatternUnits:EL,PatternContentUnits:DL,PatternTransform:OL,MarkerStart:kL,MarkerMid:AL,MarkerEnd:jL,MarkerWidth:ML,MarkerHeight:NL,MarkerUnits:PL,RefX:FL,RefY:IL,Orient:LL,PreserveAspectRatio:RL,Prop:ate,OnCustomEvent:ote,OnMount:zL,OnUnmount:BL}=Fo(),VL=(e,t,n)=>{e.data[t]=n},HL=(e,t)=>{e.data[Tk]=(e.data[Tk]??0)|t},UL=(e,t,n,r)=>{e.data[t]=n,HL(e,r)},WL=(e,t,n)=>{let r=e.data.props??={};return t===`__proto__`?Object.defineProperty(r,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):r[t]=n,HL(e,Ek.Props),r},B=(e,t,n)=>{tk(WL(e,t,n),t)},GL=(e,t,n)=>{ek(WL(e,t,n),t)},KL=(e,t)=>{$O(WL(e,`innerHTML`,t),t)},V=(e,t,n)=>{let r=e.data.attrs??={};r[t]=n,HL(e,Ek.Attrs)},H=(e,t,n)=>{let r=e.data.on??={};HL(e,Ek.On);let i=r[t];if(i===void 0)r[t]=n;else{let e=i;r[t]=(...t)=>{e(...t),n(...t)}}},U=(e,t)=>{if(HL(e,Ek.On),e.data.on===void 0){e.data.on=t;return}let n=e.data.on;for(let e of Object.keys(t)){let r=n[e],i=t[e];n[e]=r===void 0?i:(...e)=>{r(...e),i(...e)}}},qL=2147483647,JL=-2147483648,YL={cols:{minimum:0,maximum:qL},colSpan:{minimum:0,maximum:qL},maxLength:{minimum:0,maximum:qL},minLength:{minimum:0,maximum:qL},rows:{minimum:0,maximum:qL},rowSpan:{minimum:0,maximum:qL},size:{minimum:0,maximum:qL},span:{minimum:0,maximum:qL},start:{minimum:JL,maximum:qL},tabIndex:{minimum:JL,maximum:qL}},XL=(e,t)=>`[foldkit] ${e} was given ${String(t)}, which a browser reads differently depending on whether it arrives as parsed markup or as a property assignment, and which can throw outright when assigned. `,ZL=(e,t,n)=>{let r=YL[t];if(r!==void 0&&!(Number.isInteger(n)&&n>=r.minimum&&n<=r.maximum))throw Error(XL(t,n)+`Use an integer from ${String(r.minimum)} to ${String(r.maximum)}.`);B(e,t,n)},QL=(e,t,n)=>{if(!Number.isFinite(n))throw Error(XL(t,n)+`Use a finite number.`);B(e,t,n)},$L=(e,t,n)=>{B(e,t,n),e.getPostpatchProps().push({propName:t,value:n})},eR=1e4,tR=new Map,nR=e=>{let t=tR.get(e);if(t!==void 0)return t;let n={};for(let t of e.split(/\s+/))t!==``&&(n[t]=!0);return tR.size>=eR&&tR.clear(),tR.set(e,n),n},rR=new Set([`javascript`,`vbscript`]),iR=/[\u0000-\u001F\u007F-\u009F]/g,aR=/^\s*([a-zA-Z][a-zA-Z0-9+.-]*)\s*:/,oR=e=>{let t=aR.exec(e.replace(iR,``));if(t!==null){let e=t[1];if(e!==void 0&&rR.has(e.toLowerCase()))return``}return e},sR={Key:({value:e},t)=>VL(t,`key`,e),Class:({value:e},t)=>UL(t,`class`,nR(e),Ek.Class),Id:({value:e},t)=>B(t,`id`,e),Title:({value:e},t)=>B(t,`title`,e),Lang:({value:e},t)=>B(t,`lang`,e),Dir:({value:e},t)=>B(t,`dir`,e),Tabindex:({value:e},t)=>ZL(t,`tabIndex`,e),Hidden:({value:e},t)=>B(t,`hidden`,e),Contenteditable:({value:e},t)=>V(t,`contenteditable`,e),Draggable:({value:e},t)=>B(t,`draggable`,e),Accesskey:({value:e},t)=>V(t,`accesskey`,e),Translate:({value:e},t)=>V(t,`translate`,e),Inert:({value:e},t)=>B(t,`inert`,e),Popover:({value:e},t)=>V(t,`popover`,e),Popovertarget:({value:e},t)=>V(t,`popovertarget`,e),Popovertargetaction:({value:e},t)=>V(t,`popovertargetaction`,e),OnClick:({message:e,options:t},n)=>H(n,`click`,r=>{t?.defaultAction===`Prevent`&&r.preventDefault(),t?.propagation===`Stop`&&r.stopPropagation();let i=t?.focusSelector;if(i!==void 0){let e=document.querySelector(i);e instanceof HTMLElement&&e.focus()}n.dispatch(e)}),OnDoubleClick:({message:e},t)=>H(t,`dblclick`,()=>t.dispatch(e)),OnMouseDown:({message:e},t)=>H(t,`mousedown`,()=>t.dispatch(e)),OnMouseUp:({message:e},t)=>H(t,`mouseup`,()=>t.dispatch(e)),OnMouseEnter:({message:e},t)=>H(t,`mouseenter`,()=>t.dispatch(e)),OnMouseLeave:({message:e},t)=>H(t,`mouseleave`,()=>t.dispatch(e)),OnMouseOver:({message:e},t)=>H(t,`mouseover`,()=>t.dispatch(e)),OnMouseOut:({message:e},t)=>H(t,`mouseout`,()=>t.dispatch(e)),OnMouseMove:({message:e},t)=>H(t,`mousemove`,()=>t.dispatch(e)),OnPointerMove:({f:e},t)=>U(t,{pointermove:n=>{let r=e(n.screenX,n.screenY,n.pointerType);D(r)&&t.dispatch(r.value)}}),OnPointerLeave:({f:e},t)=>U(t,{pointerleave:n=>{let r=e(n.pointerType);D(r)&&t.dispatch(r.value)}}),OnPointerDown:({f:e},t)=>U(t,{pointerdown:n=>{let r=e(n.pointerType,n.button,n.screenX,n.screenY,n.timeStamp,n.clientX,n.clientY,n.pointerId,n.target);D(r)&&t.dispatch(r.value)}}),OnPointerUp:({f:e},t)=>U(t,{pointerup:n=>{let r=e(n.screenX,n.screenY,n.pointerType,n.timeStamp);D(r)&&t.dispatch(r.value)}}),OnKeyDown:({f:e},t)=>U(t,{keydown:NM(n=>{t.dispatch(e(n.key,MM(n)))})}),OnKeyDownPreventDefault:({f:e},t)=>U(t,{keydown:NM(n=>{let r=e(n.key,MM(n));D(r)&&(n.preventDefault(),t.dispatch(r.value))})}),OnKeyDownSelf:({f:e},t)=>U(t,{keydown:NM(n=>{FM(n)&&t.dispatch(e(n.key,MM(n)))})}),OnKeyDownSelfPreventDefault:({f:e},t)=>U(t,{keydown:NM(n=>{if(!FM(n))return;let r=e(n.key,MM(n));D(r)&&(n.preventDefault(),t.dispatch(r.value))})}),OnKeyDownFocus:({f:e},t)=>U(t,{keydown:NM(n=>{let r=e(n.key,MM(n));if(D(r)){n.preventDefault();let{focusSelector:e,message:i}=r.value,a=document.querySelector(e);a instanceof HTMLElement&&a.focus(),t.dispatch(i)}})}),OnKeyUp:({f:e},t)=>U(t,{keyup:n=>t.dispatch(e(n.key,MM(n)))}),OnKeyUpPreventDefault:({f:e},t)=>U(t,{keyup:n=>{let r=e(n.key,MM(n));D(r)&&(n.preventDefault(),t.dispatch(r.value))}}),OnKeyPress:({f:e},t)=>U(t,{keypress:n=>t.dispatch(e(n.key,MM(n)))}),OnFocus:({message:e},t)=>H(t,`focus`,()=>t.dispatch(e)),OnBlur:({message:e},t)=>U(t,{blur:n=>{IM(n.relatedTarget)||t.dispatch(e)}}),OnFocusEnter:({message:e},t)=>U(t,{focusin:n=>{LM(n)||t.dispatch(e)}}),OnFocusLeave:({message:e},t)=>U(t,{focusout:n=>{LM(n)||t.dispatch(e)}}),OnInput:({f:e},t)=>U(t,{input:n=>t.dispatch(e(PM(n.target)))}),OnChange:({f:e},t)=>U(t,{change:n=>t.dispatch(e(PM(n.target)))}),OnBeforeInput:({f:e},t)=>U(t,{beforeinput:n=>t.dispatch(e(n.inputType,br(n.data)))}),OnBeforeInputPreventDefault:({f:e},t)=>U(t,{beforeinput:n=>{if(!n.cancelable)return;let r=e(n.inputType,br(n.data));D(r)&&(n.preventDefault(),t.dispatch(r.value))}}),OnFileChange:({f:e},t)=>U(t,{change:jM(n=>{let r=n.target,i=r.files?Li(r.files):ma();r.value=``,t.dispatch(e(i))},`OnFileChange`)}),OnSubmit:({message:e},t)=>U(t,{submit:n=>{n.preventDefault(),t.dispatch(e)}}),OnReset:({message:e},t)=>H(t,`reset`,()=>t.dispatch(e)),OnScroll:({f:e},t)=>U(t,{scroll:n=>t.dispatch(e(n.target.scrollTop))}),OnWheel:({message:e},t)=>H(t,`wheel`,()=>t.dispatch(e)),OnCopy:({message:e},t)=>H(t,`copy`,()=>t.dispatch(e)),OnCut:({message:e},t)=>H(t,`cut`,()=>t.dispatch(e)),OnPaste:({message:e},t)=>H(t,`paste`,()=>t.dispatch(e)),OnPastePreventDefault:({f:e},t)=>U(t,{paste:n=>{let r=e(n.clipboardData?.getData(`text/plain`)??``);D(r)&&(n.preventDefault(),t.dispatch(r.value))}}),OnCopyText:({text:e},t)=>U(t,{copy:t=>{t.clipboardData&&(t.clipboardData.setData(`text/plain`,e),t.preventDefault())}}),OnCutText:({text:e,message:t},n)=>U(n,{cut:r=>{r.clipboardData&&(r.clipboardData.setData(`text/plain`,e),r.preventDefault(),n.dispatch(t))}}),OnCancel:({message:e},t)=>U(t,{cancel:n=>{n.preventDefault(),t.dispatch(e)}}),OnCancelPreventDefault:({maybeCustomEventMessage:e},t)=>U(t,{cancel:n=>{n.preventDefault(),n instanceof CustomEvent&&D(e)&&t.dispatch(e.value)}}),OnToggle:({f:e},t)=>U(t,{toggle:n=>t.dispatch(e(n.target.open))}),OnContextMenu:({message:e},t)=>U(t,{contextmenu:n=>{n.preventDefault(),t.dispatch(e)}}),OnDragStart:({message:e},t)=>H(t,`dragstart`,()=>t.dispatch(e)),OnDrag:({message:e},t)=>H(t,`drag`,()=>t.dispatch(e)),OnDragEnd:({message:e},t)=>H(t,`dragend`,()=>t.dispatch(e)),OnDragEnter:({message:e},t)=>U(t,{dragenter:n=>{n.preventDefault();let r=n.currentTarget;r instanceof Element?eM(Qj(r),r,n.target)&&t.dispatch(e):t.dispatch(e)}}),OnDragLeave:({message:e},t)=>U(t,{dragleave:n=>{let r=n.currentTarget;if(!(r instanceof Element)){t.dispatch(e);return}let i=Qj(r);tM(i,r,n.target)===`schedule`&&queueMicrotask(()=>{nM(i)&&t.dispatch(e)})}}),OnDragOver:({message:e},t)=>U(t,{dragover:n=>{n.preventDefault(),t.dispatch(e)}}),AllowDrop:(e,t)=>U(t,{dragover:e=>{e.preventDefault()}}),OnDrop:({message:e},t)=>U(t,{drop:n=>{n.preventDefault();let r=n.currentTarget;r instanceof Element&&rM(r),t.dispatch(e)}}),OnDropFiles:({f:e},t)=>U(t,{drop:jM(n=>{n.preventDefault();let r=n,i=r.currentTarget;i instanceof Element&&rM(i);let a=r.dataTransfer?.files?Li(r.dataTransfer.files):ma();t.dispatch(e(a))},`OnDropFiles`)}),OnTouchStart:({message:e},t)=>H(t,`touchstart`,()=>t.dispatch(e)),OnTouchEnd:({message:e},t)=>H(t,`touchend`,()=>t.dispatch(e)),OnTouchMove:({message:e},t)=>H(t,`touchmove`,()=>t.dispatch(e)),OnTouchCancel:({message:e},t)=>H(t,`touchcancel`,()=>t.dispatch(e)),OnAnimationStart:({message:e},t)=>H(t,`animationstart`,()=>t.dispatch(e)),OnAnimationEnd:({message:e},t)=>H(t,`animationend`,()=>t.dispatch(e)),OnAnimationIteration:({message:e},t)=>H(t,`animationiteration`,()=>t.dispatch(e)),OnTransitionEnd:({message:e},t)=>H(t,`transitionend`,()=>t.dispatch(e)),OnLoad:({message:e},t)=>H(t,`load`,()=>t.dispatch(e)),OnError:({message:e},t)=>H(t,`error`,()=>t.dispatch(e)),OnPlay:({message:e},t)=>H(t,`play`,()=>t.dispatch(e)),OnPause:({message:e},t)=>H(t,`pause`,()=>t.dispatch(e)),OnEnded:({message:e},t)=>H(t,`ended`,()=>t.dispatch(e)),OnTimeUpdate:({message:e},t)=>H(t,`timeupdate`,()=>t.dispatch(e)),OnVolumeChange:({message:e},t)=>H(t,`volumechange`,()=>t.dispatch(e)),OnSelect:({message:e},t)=>H(t,`select`,()=>t.dispatch(e)),Value:({value:e},t)=>$L(t,`value`,e),Checked:({value:e},t)=>$L(t,`checked`,e),Selected:({value:e},t)=>$L(t,`selected`,e),Open:({value:e},t)=>$L(t,`open`,e),Placeholder:({value:e},t)=>B(t,`placeholder`,e),Name:({value:e},t)=>B(t,`name`,e),Disabled:({value:e},t)=>B(t,`disabled`,e),Readonly:({value:e},t)=>B(t,`readOnly`,e),Required:({value:e},t)=>B(t,`required`,e),Autofocus:({value:e},t)=>B(t,`autofocus`,e),Spellcheck:({value:e},t)=>V(t,`spellcheck`,e.toString()),Autocorrect:({value:e},t)=>V(t,`autocorrect`,e),Autocapitalize:({value:e},t)=>V(t,`autocapitalize`,e),InputMode:({value:e},t)=>V(t,`inputmode`,e),EnterKeyHint:({value:e},t)=>V(t,`enterkeyhint`,e),Multiple:({value:e},t)=>B(t,`multiple`,e),Type:({value:e},t)=>B(t,`type`,e),Accept:({value:e},t)=>B(t,`accept`,e),Autocomplete:({value:e},t)=>B(t,`autocomplete`,e),Pattern:({value:e},t)=>B(t,`pattern`,e),Maxlength:({value:e},t)=>ZL(t,`maxLength`,e),Minlength:({value:e},t)=>ZL(t,`minLength`,e),Size:({value:e},t)=>ZL(t,`size`,e),Cols:({value:e},t)=>ZL(t,`cols`,e),Rows:({value:e},t)=>ZL(t,`rows`,e),Max:({value:e},t)=>B(t,`max`,e),Min:({value:e},t)=>B(t,`min`,e),Step:({value:e},t)=>B(t,`step`,e),For:({value:e},t)=>B(t,`htmlFor`,e),Href:({value:e},t)=>B(t,`href`,oR(e)),Src:({value:e},t)=>B(t,`src`,oR(e)),Alt:({value:e},t)=>B(t,`alt`,e),Target:({value:e},t)=>B(t,`target`,e),Rel:({value:e},t)=>B(t,`rel`,e),Download:({value:e},t)=>B(t,`download`,e),Action:({value:e},t)=>B(t,`action`,oR(e)),Method:({value:e},t)=>B(t,`method`,e),Enctype:({value:e},t)=>B(t,`enctype`,e),Novalidate:({value:e},t)=>B(t,`noValidate`,e),Formaction:({value:e},t)=>B(t,`formAction`,oR(e)),Formmethod:({value:e},t)=>B(t,`formMethod`,e),Formnovalidate:({value:e},t)=>B(t,`formNoValidate`,e),Formtarget:({value:e},t)=>B(t,`formTarget`,e),Formenctype:({value:e},t)=>B(t,`formEnctype`,e),Colspan:({value:e},t)=>ZL(t,`colSpan`,e),Rowspan:({value:e},t)=>ZL(t,`rowSpan`,e),Scope:({value:e},t)=>V(t,`scope`,e),Headers:({value:e},t)=>V(t,`headers`,e),Span:({value:e},t)=>ZL(t,`span`,e),Start:({value:e},t)=>ZL(t,`start`,e),Reversed:({value:e},t)=>B(t,`reversed`,e),CiteAttr:({value:e},t)=>B(t,`cite`,e),Datetime:({value:e},t)=>B(t,`dateTime`,e),Wrap:({value:e},t)=>B(t,`wrap`,e),List:({value:e},t)=>V(t,`list`,e),FormAttr:({value:e},t)=>V(t,`form`,e),LabelAttr:({value:e},t)=>B(t,`label`,e),ContentAttr:({value:e},t)=>V(t,`content`,e),Charset:({value:e},t)=>V(t,`charset`,e),HttpEquiv:({value:e},t)=>V(t,`http-equiv`,e),Srcset:({value:e},t)=>V(t,`srcset`,e),Sizes:({value:e},t)=>V(t,`sizes`,e),Loading:({value:e},t)=>V(t,`loading`,e),Decoding:({value:e},t)=>V(t,`decoding`,e),Fetchpriority:({value:e},t)=>V(t,`fetchpriority`,e),Crossorigin:({value:e},t)=>V(t,`crossorigin`,e),Referrerpolicy:({value:e},t)=>V(t,`referrerpolicy`,e),Integrity:({value:e},t)=>V(t,`integrity`,e),Hreflang:({value:e},t)=>V(t,`hreflang`,e),Ping:({value:e},t)=>V(t,`ping`,e),Sandbox:({value:e},t)=>V(t,`sandbox`,e),Allow:({value:e},t)=>V(t,`allow`,e),Srcdoc:({value:e},t)=>V(t,`srcdoc`,e),Autoplay:({value:e},t)=>B(t,`autoplay`,e),Controls:({value:e},t)=>B(t,`controls`,e),Loop:({value:e},t)=>B(t,`loop`,e),Muted:({value:e},t)=>$L(t,`muted`,e),Poster:({value:e},t)=>B(t,`poster`,e),Preload:({value:e},t)=>B(t,`preload`,e),Playsinline:({value:e},t)=>B(t,`playsInline`,e),High:({value:e},t)=>QL(t,`high`,e),Low:({value:e},t)=>QL(t,`low`,e),Optimum:({value:e},t)=>QL(t,`optimum`,e),Usemap:({value:e},t)=>V(t,`usemap`,e),Ismap:({value:e},t)=>B(t,`isMap`,e),Role:({value:e},t)=>V(t,`role`,e),AriaLabel:({value:e},t)=>V(t,`aria-label`,e),AriaLabelledBy:({value:e},t)=>V(t,`aria-labelledby`,e),AriaDescribedBy:({value:e},t)=>V(t,`aria-describedby`,e),AriaHidden:({value:e},t)=>V(t,`aria-hidden`,e.toString()),AriaExpanded:({value:e},t)=>V(t,`aria-expanded`,e.toString()),AriaSelected:({value:e},t)=>V(t,`aria-selected`,e.toString()),AriaChecked:({value:e},t)=>V(t,`aria-checked`,e.toString()),AriaDisabled:({value:e},t)=>V(t,`aria-disabled`,e.toString()),AriaRequired:({value:e},t)=>V(t,`aria-required`,e.toString()),AriaInvalid:({value:e},t)=>V(t,`aria-invalid`,e.toString()),AriaLive:({value:e},t)=>V(t,`aria-live`,e),AriaControls:({value:e},t)=>V(t,`aria-controls`,e),AriaCurrent:({value:e},t)=>V(t,`aria-current`,e),AriaOrientation:({value:e},t)=>V(t,`aria-orientation`,e),AriaPressed:({value:e},t)=>V(t,`aria-pressed`,e),AriaHasPopup:({value:e},t)=>V(t,`aria-haspopup`,e),AriaActiveDescendant:({value:e},t)=>V(t,`aria-activedescendant`,e),AriaSort:({value:e},t)=>V(t,`aria-sort`,e),AriaMultiSelectable:({value:e},t)=>V(t,`aria-multiselectable`,e.toString()),AriaModal:({value:e},t)=>V(t,`aria-modal`,e.toString()),AriaBusy:({value:e},t)=>V(t,`aria-busy`,e.toString()),AriaErrorMessage:({value:e},t)=>V(t,`aria-errormessage`,e),AriaRoleDescription:({value:e},t)=>V(t,`aria-roledescription`,e),AriaAtomic:({value:e},t)=>V(t,`aria-atomic`,e.toString()),AriaAutocomplete:({value:e},t)=>V(t,`aria-autocomplete`,e),AriaColcount:({value:e},t)=>V(t,`aria-colcount`,e.toString()),AriaColindex:({value:e},t)=>V(t,`aria-colindex`,e.toString()),AriaColspan:({value:e},t)=>V(t,`aria-colspan`,e.toString()),AriaDescription:({value:e},t)=>V(t,`aria-description`,e),AriaDetails:({value:e},t)=>V(t,`aria-details`,e),AriaFlowto:({value:e},t)=>V(t,`aria-flowto`,e),AriaKeyshortcuts:({value:e},t)=>V(t,`aria-keyshortcuts`,e),AriaLevel:({value:e},t)=>V(t,`aria-level`,e.toString()),AriaOwns:({value:e},t)=>V(t,`aria-owns`,e),AriaPlaceholder:({value:e},t)=>V(t,`aria-placeholder`,e),AriaPosinset:({value:e},t)=>V(t,`aria-posinset`,e.toString()),AriaReadonly:({value:e},t)=>V(t,`aria-readonly`,e.toString()),AriaRelevant:({value:e},t)=>V(t,`aria-relevant`,e),AriaRowcount:({value:e},t)=>V(t,`aria-rowcount`,e.toString()),AriaRowindex:({value:e},t)=>V(t,`aria-rowindex`,e.toString()),AriaRowspan:({value:e},t)=>V(t,`aria-rowspan`,e.toString()),AriaSetsize:({value:e},t)=>V(t,`aria-setsize`,e.toString()),AriaValuemax:({value:e},t)=>V(t,`aria-valuemax`,e.toString()),AriaValuemin:({value:e},t)=>V(t,`aria-valuemin`,e.toString()),AriaValuenow:({value:e},t)=>V(t,`aria-valuenow`,e.toString()),AriaValuetext:({value:e},t)=>V(t,`aria-valuetext`,e),Attribute:({key:e,value:t},n)=>V(n,e,t),DataAttribute:({key:e,value:t},n)=>V(n,`data-${e}`,t),Style:({value:e},t)=>UL(t,`style`,JO(e),Ek.Style),InnerHTML:({value:e},t)=>KL(t,e),ViewBox:({value:e},t)=>V(t,`viewBox`,e),Xmlns:({value:e},t)=>V(t,`xmlns`,e),Fill:({value:e},t)=>V(t,`fill`,e),FillRule:({value:e},t)=>V(t,`fill-rule`,e),ClipRule:({value:e},t)=>V(t,`clip-rule`,e),Stroke:({value:e},t)=>V(t,`stroke`,e),StrokeWidth:({value:e},t)=>V(t,`stroke-width`,e),StrokeLinecap:({value:e},t)=>V(t,`stroke-linecap`,e),StrokeLinejoin:({value:e},t)=>V(t,`stroke-linejoin`,e),D:({value:e},t)=>V(t,`d`,e),Cx:({value:e},t)=>V(t,`cx`,e),Cy:({value:e},t)=>V(t,`cy`,e),R:({value:e},t)=>V(t,`r`,e),X:({value:e},t)=>V(t,`x`,e),Y:({value:e},t)=>V(t,`y`,e),Width:({value:e},t)=>V(t,`width`,e),Height:({value:e},t)=>V(t,`height`,e),X1:({value:e},t)=>V(t,`x1`,e),Y1:({value:e},t)=>V(t,`y1`,e),X2:({value:e},t)=>V(t,`x2`,e),Y2:({value:e},t)=>V(t,`y2`,e),Points:({value:e},t)=>V(t,`points`,e),Transform:({value:e},t)=>V(t,`transform`,e),Opacity:({value:e},t)=>V(t,`opacity`,e),StrokeDasharray:({value:e},t)=>V(t,`stroke-dasharray`,e),StrokeDashoffset:({value:e},t)=>V(t,`stroke-dashoffset`,e),Dx:({value:e},t)=>V(t,`dx`,e),Dy:({value:e},t)=>V(t,`dy`,e),Rotate:({value:e},t)=>V(t,`rotate`,e),TextAnchor:({value:e},t)=>V(t,`text-anchor`,e),DominantBaseline:({value:e},t)=>V(t,`dominant-baseline`,e),AlignmentBaseline:({value:e},t)=>V(t,`alignment-baseline`,e),BaselineShift:({value:e},t)=>V(t,`baseline-shift`,e),TextLength:({value:e},t)=>V(t,`textLength`,e),LengthAdjust:({value:e},t)=>V(t,`lengthAdjust`,e),FontFamily:({value:e},t)=>V(t,`font-family`,e),FontSize:({value:e},t)=>V(t,`font-size`,e),FontWeight:({value:e},t)=>V(t,`font-weight`,e),FontStyle:({value:e},t)=>V(t,`font-style`,e),LetterSpacing:({value:e},t)=>V(t,`letter-spacing`,e),WordSpacing:({value:e},t)=>V(t,`word-spacing`,e),TextDecoration:({value:e},t)=>V(t,`text-decoration`,e),WritingMode:({value:e},t)=>V(t,`writing-mode`,e),Rx:({value:e},t)=>V(t,`rx`,e),Ry:({value:e},t)=>V(t,`ry`,e),PathLength:({value:e},t)=>V(t,`pathLength`,e),FillOpacity:({value:e},t)=>V(t,`fill-opacity`,e),StrokeOpacity:({value:e},t)=>V(t,`stroke-opacity`,e),StrokeMiterlimit:({value:e},t)=>V(t,`stroke-miterlimit`,e),PaintOrder:({value:e},t)=>V(t,`paint-order`,e),VectorEffect:({value:e},t)=>V(t,`vector-effect`,e),Color:({value:e},t)=>V(t,`color`,e),Visibility:({value:e},t)=>V(t,`visibility`,e),Display:({value:e},t)=>V(t,`display`,e),Overflow:({value:e},t)=>V(t,`overflow`,e),PointerEvents:({value:e},t)=>V(t,`pointer-events`,e),Cursor:({value:e},t)=>V(t,`cursor`,e),ShapeRendering:({value:e},t)=>V(t,`shape-rendering`,e),TextRendering:({value:e},t)=>V(t,`text-rendering`,e),ImageRendering:({value:e},t)=>V(t,`image-rendering`,e),ClipPath:({value:e},t)=>V(t,`clip-path`,e),Mask:({value:e},t)=>V(t,`mask`,e),Filter:({value:e},t)=>V(t,`filter`,e),ClipPathUnits:({value:e},t)=>V(t,`clipPathUnits`,e),MaskUnits:({value:e},t)=>V(t,`maskUnits`,e),MaskContentUnits:({value:e},t)=>V(t,`maskContentUnits`,e),FilterUnits:({value:e},t)=>V(t,`filterUnits`,e),PrimitiveUnits:({value:e},t)=>V(t,`primitiveUnits`,e),Offset:({value:e},t)=>V(t,`offset`,e),StopColor:({value:e},t)=>V(t,`stop-color`,e),StopOpacity:({value:e},t)=>V(t,`stop-opacity`,e),GradientUnits:({value:e},t)=>V(t,`gradientUnits`,e),GradientTransform:({value:e},t)=>V(t,`gradientTransform`,e),SpreadMethod:({value:e},t)=>V(t,`spreadMethod`,e),Fx:({value:e},t)=>V(t,`fx`,e),Fy:({value:e},t)=>V(t,`fy`,e),Fr:({value:e},t)=>V(t,`fr`,e),PatternUnits:({value:e},t)=>V(t,`patternUnits`,e),PatternContentUnits:({value:e},t)=>V(t,`patternContentUnits`,e),PatternTransform:({value:e},t)=>V(t,`patternTransform`,e),MarkerStart:({value:e},t)=>V(t,`marker-start`,e),MarkerMid:({value:e},t)=>V(t,`marker-mid`,e),MarkerEnd:({value:e},t)=>V(t,`marker-end`,e),MarkerWidth:({value:e},t)=>V(t,`markerWidth`,e),MarkerHeight:({value:e},t)=>V(t,`markerHeight`,e),MarkerUnits:({value:e},t)=>V(t,`markerUnits`,e),RefX:({value:e},t)=>V(t,`refX`,e),RefY:({value:e},t)=>V(t,`refY`,e),Orient:({value:e},t)=>V(t,`orient`,e),PreserveAspectRatio:({value:e},t)=>V(t,`preserveAspectRatio`,e),Prop:({key:e,value:t},n)=>GL(n,e,t),OnCustomEvent:({name:e,f:t},n)=>U(n,{[e]:e=>{if(e instanceof CustomEvent){let r=t(e);D(r)&&n.dispatch(r.value)}}}),OnMount:({action:e},t)=>{let n=t.getCapturedContext(),r=ci(n,gk),i=ci(n,vk),a=t.resolveMountDispatch??pR(),o=D(r)?()=>r.value.started(e.name,e.args):u,s=D(r)?()=>r.value.ended(e.name,e.args):u,c=e.args===void 0?{name:e.name}:{name:e.name,args:e.args},l=t.boundaryMappers,d=Hi(l)?c:{...c,messageMappers:l};t.data[pee]=d;let f=t.data.hook?.destroy;t.data.hook={...t.data.hook,insert:e=>{if(e.elm instanceof Element){let t=e.elm;m(t)}},postpatch:(e,t)=>{if(t.elm instanceof Element){let e=HM.get(t.elm);e?.owner===`Replay`&&a.owner===`Live`&&(p(e),m(t.elm,e.fiber))}},destroy:e=>{if(f!==void 0&&f(e),e.elm instanceof Element){let t=HM.get(e.elm);t&&(p(t),qm(ah(t.fiber)),HM.delete(e.elm))}}};function p(e){e.lifecycle.isActive=!1,e.lifecycle.isStarted&&(e.lifecycle.isStarted=!1,e.owner===`Live`&&e.notifyEnded())}function m(t,r){let c={isActive:!0,isStarted:!0},l=a.resolve(),u=O(i,{onNone:()=>xk,onSome:e=>e.captureViewStateChanges()});o();let d=Up(()=>c.isActive?vD(e.f(t,u),e=>M(()=>l(e))):N).pipe(sm(t=>M(()=>{console.error(`[OnMount ${e.name}] unhandled failure`,t)}))),f=r===void 0?d:ah(r).pipe(em(d)),p=Jm(n)(f);HM.set(t,{fiber:p,lifecycle:c,notifyEnded:s,owner:a.owner})}},OnUnmount:({message:e},t)=>{let n=t.resolveUnmount(e);lj(t.data,n)}},cR=(e,t)=>{let n=sR[e._tag];n(e,t)},lR=()=>{throw Error(`Foldkit: an event-bearing Html attribute fired without an active runtime frame. This typically means an Html element with event handlers (OnClick, OnInput, etc.) was constructed at module top level outside of a view function.`)},uR=()=>()=>{throw Error(`Foldkit: an OnUnmount attribute fired without an active runtime frame. This typically means an Html element with OnUnmount was constructed at module top level outside of a view function.`)},dR=()=>{try{return Uj()}catch{return lR}},fR=()=>{try{return Wj()}catch{return uR}},pR=()=>{try{return Kj()}catch{return{owner:`Live`,resolve:()=>lR}}},mR=()=>{try{return qj()}catch{return Xr()}},hR=(e,t)=>{e.elm&&Ta(t,({propName:t,value:n})=>{(e.elm instanceof Element&&e.elm.localName===`output`&&t===`value`||e.elm[t]!==n)&&(e.elm[t]=n),e.elm instanceof Element&&sk(e.elm,t,n)})},gR=(e,t)=>{let n=e.hook?.insert,r=e.hook?.postpatch;e.hook={...e.hook,insert:e=>{hR(e,t),n?.(e)},postpatch:(e,n)=>{hR(n,t),r?.(e,n)}}},_R=e=>{let t=e.hook?.postpatch;e.hook={...e.hook,postpatch:(e,n)=>{t?.(e,n);let r=e.data?.props,i=n.data?.props;r!==void 0&&Object.hasOwn(r,`value`)&&(i===void 0||!Object.hasOwn(i,`value`))&&n.elm instanceof Element&&fk(n.elm,n)}}},vR=e=>{let t={[Tk]:0};if(e.length===0)return t;let n,r,i,a=()=>i??=[];for(let i of e)if(Xj(i)){r??=new Map;let e=r.get(i.dispatch);(e===void 0||i.resolveMountDispatch!==void 0&&e.resolveMountDispatch!==i.resolveMountDispatch)&&(e={data:t,getPostpatchProps:a,dispatch:i.dispatch,resolveUnmount:i.resolveUnmount,boundaryMappers:i.boundaryMappers,...i.resolveMountDispatch!==void 0&&{resolveMountDispatch:i.resolveMountDispatch},getCapturedContext:mR},r.set(i.dispatch,e)),cR(i.attribute,e)}else n===void 0&&(n={data:t,getPostpatchProps:a,dispatch:dR(),resolveUnmount:fR(),boundaryMappers:Gj(),getCapturedContext:mR}),cR(i,n);return i!==void 0&&Wi(i)&&gR(t,i),t},yR=e=>{let t=[];for(let n=0;n<e.length;n++){let r=e[n];r!=null&&t.push(r)}return t},bR=new Set([`output`,`select`,`textarea`]),xR=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),SR=(e,t,n)=>{let r=e.toLowerCase();if((r===`textarea`||r===`output`)&&t.props?.value!==void 0&&n.length>0)throw Error(`[foldkit] <${r}> was given both a controlled value and children. Both own the element content, so a property assignment replaces the child nodes the differ expects to patch. Keep one owner.`);let i=t.props;if(i===void 0||!Object.hasOwn(i,`innerHTML`))return;let a=nk(i)?`h.InnerHTML`:`a client-only innerHTML property`;if(r===`textarea`)throw Error(`[foldkit] <textarea> was given ${a}. Textarea content must use h.Value because innerHTML stops updating the live value after the browser marks the field dirty. Remove the innerHTML owner.`);if(n.length>0)throw Error(`[foldkit] <${r}> was given both ${a} and children. innerHTML owns the whole of an element’s content, so the two cannot both describe it: server rendering emits the raw HTML alone for h.InnerHTML, while a browser property assignment replaces the nodes the differ expects to patch. Keep one content owner.`);if(bR.has(r)&&t.props?.value!==void 0)throw Error(`[foldkit] <${r}> was given both ${a} and a controlled value. Both own this element’s content, and they disagree once the client reasserts the value. Keep one of them.`);if(xR.has(r))throw Error(`[foldkit] <${r}> cannot hold content, so ${a} on it has no representation in served HTML. A browser can still build child nodes from the property, which no server render reproduces. Remove the innerHTML value.`)},CR=e=>{if(e.style!==void 0&&YO(e.attrs,`style`)!==void 0)throw Error(`[foldkit] An element was given both h.Style and a raw h.Attribute('style', ...). They are two owners of one declaration block, and CSS parsing can make one swallow or override the other. Keep all inline declarations in one of them.`)},wR=/^-?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?$/,TR=/^-?[0-9]+$/,ER={meter:new Set([`high`,`low`,`max`,`min`,`optimum`,`value`]),progress:new Set([`max`,`value`])},DR={li:new Set([`value`])},OR=(e,t,n)=>{if(!(typeof n==`number`?Number.isFinite(n):typeof n==`string`&&wR.test(n)&&Number.isFinite(Number(n))))throw Error(`[foldkit] <${e}> reads ${t} as a number, and ${JSON.stringify(n)} is not one a browser reads the same way from markup and from a property assignment. Use a finite decimal number.`)},kR=(e,t,n)=>{let r=typeof n==`number`?n:typeof n==`string`&&TR.test(n)?Number(n):NaN;if(!Number.isInteger(r)||r<JL||r>qL)throw Error(`[foldkit] <${e}> reads ${t} as an integer, and ${JSON.stringify(n)} is not one a browser reads the same way from markup and from a property assignment. Use an integer from ${String(JL)} to ${String(qL)}.`)},AR=e=>{let t=e.props?.type;if(typeof t==`string`)return t.toLowerCase();let n=YO(e.attrs,`type`);return typeof n==`string`?n.toLowerCase():void 0},jR=(e,t)=>{let n=t.props;if(n===void 0)return;let r=e.toLowerCase(),i=ER[r],a=DR[r];for(let e of Object.keys(n)){let o=n[e];if(o===void 0||e===`innerHTML`)continue;if(i?.has(e)===!0&&OR(r,e,o),a?.has(e)===!0&&kR(r,e,o),r===`input`&&e===`size`&&o===0)throw Error(XL(e,o)+`Use an integer from 1 to ${String(qL)} on an input.`);let s=AO(e);if(s!==void 0&&!rk(n,e)&&YO(t.attrs,s)!==void 0)throw Error(`[foldkit] <${r}> was given both a typed ${e} and a raw h.Attribute('${s}', ...). They are two owners of one attribute, and the state they describe together has no spelling in served HTML: the property decides what is served while a fresh render parses the attribute as the default too. Keep one of them.`)}if(r===`input`&&AR(t)===`file`){let e=n.value;if(typeof e==`string`&&e!==``)throw Error(`[foldkit] <input type="file"> was given a value. A file input takes no value from markup or from the Model: the served attribute is ignored and assigning the property throws InvalidStateError, so the view crashes on a fresh render and on hydration. Drop the value.`)}},MR=(e,t)=>{let n=t.props;if(n!==void 0)for(let t of Object.keys(n))AO(t)!==void 0&&!IO(e,t)&&ek(n,t)},NR=e=>{let t=e.data;if(t===void 0||t.ns===void 0)return;let n=t.props;if(n!==void 0){for(let t of Object.keys(n))if(!(n[t]===void 0||t===`innerHTML`||kO.has(t)||AO(t)===void 0))throw Error(`[foldkit] <${ik(e.sel??``)}> is in the SVG or MathML namespace, where ${t} is not a property the element has. Assigning it on the client sets a value no attribute reflects, or throws outright, while server rendering writes the attribute, so the two disagree. Write it as h.Attribute('${t}', ...), which foreign content reads the same way on both sides.`)}for(let t of e.children??[])typeof t!=`string`&&NR(t)},PR=(e,t,n)=>{let r=yR(n);MR(e,t),SR(e,t,r),CR(t),t.style!==void 0&&KO(t.style),jR(e,t),(e.toLowerCase()===`select`||e.toLowerCase()===`textarea`||e.toLowerCase()===`output`)&&_R(t);let i=fA(e,t,r);return NR(i),i},FR=(e,t=[],n=[])=>PR(e,vR(t),n),IR=()=>e=>(t=[],n=[])=>FR(e,t,n),LR=()=>e=>(t=[])=>FR(e,t,[]),RR=()=>e=>(t,n=[],r=[])=>{let i=vR(n);return i.key=t,PR(e,i,r)},zR=()=>{let e=IR(),t=LR();return{a:e(`a`),abbr:e(`abbr`),address:e(`address`),area:t(`area`),article:e(`article`),aside:e(`aside`),audio:e(`audio`),b:e(`b`),base:t(`base`),bdi:e(`bdi`),bdo:e(`bdo`),blockquote:e(`blockquote`),body:e(`body`),br:t(`br`),button:e(`button`),canvas:e(`canvas`),caption:e(`caption`),cite:e(`cite`),code:e(`code`),col:t(`col`),colgroup:e(`colgroup`),data:e(`data`),datalist:e(`datalist`),dd:e(`dd`),del:e(`del`),details:e(`details`),dfn:e(`dfn`),dialog:e(`dialog`),div:e(`div`),dl:e(`dl`),dt:e(`dt`),em:e(`em`),embed:t(`embed`),fieldset:e(`fieldset`),figcaption:e(`figcaption`),figure:e(`figure`),footer:e(`footer`),form:e(`form`),h1:e(`h1`),h2:e(`h2`),h3:e(`h3`),h4:e(`h4`),h5:e(`h5`),h6:e(`h6`),head:e(`head`),header:e(`header`),hgroup:e(`hgroup`),hr:t(`hr`),html:e(`html`),i:e(`i`),iframe:e(`iframe`),img:t(`img`),input:t(`input`),ins:e(`ins`),kbd:e(`kbd`),label:e(`label`),legend:e(`legend`),li:e(`li`),link:t(`link`),main:e(`main`),map:e(`map`),mark:e(`mark`),menu:e(`menu`),meta:t(`meta`),meter:e(`meter`),nav:e(`nav`),noscript:e(`noscript`),object:e(`object`),ol:e(`ol`),optgroup:e(`optgroup`),option:e(`option`),output:e(`output`),p:e(`p`),picture:e(`picture`),portal:e(`portal`),pre:e(`pre`),progress:e(`progress`),q:e(`q`),rp:e(`rp`),rt:e(`rt`),ruby:e(`ruby`),s:e(`s`),samp:e(`samp`),script:e(`script`),search:e(`search`),section:e(`section`),select:e(`select`),slot:e(`slot`),small:e(`small`),source:t(`source`),span:e(`span`),strong:e(`strong`),style:e(`style`),sub:e(`sub`),summary:e(`summary`),sup:e(`sup`),table:e(`table`),tbody:e(`tbody`),td:e(`td`),template:e(`template`),textarea:e(`textarea`),tfoot:e(`tfoot`),th:e(`th`),thead:e(`thead`),time:e(`time`),title:e(`title`),tr:e(`tr`),track:t(`track`),u:e(`u`),ul:e(`ul`),var:e(`var`),video:e(`video`),wbr:t(`wbr`),svg:e(`svg`),animate:e(`animate`),animateMotion:e(`animateMotion`),animateTransform:e(`animateTransform`),circle:e(`circle`),clipPath:e(`clipPath`),defs:e(`defs`),desc:e(`desc`),ellipse:e(`ellipse`),feBlend:e(`feBlend`),feColorMatrix:e(`feColorMatrix`),feComponentTransfer:e(`feComponentTransfer`),feComposite:e(`feComposite`),feConvolveMatrix:e(`feConvolveMatrix`),feDiffuseLighting:e(`feDiffuseLighting`),feDisplacementMap:e(`feDisplacementMap`),feDistantLight:e(`feDistantLight`),feDropShadow:e(`feDropShadow`),feFlood:e(`feFlood`),feFuncA:e(`feFuncA`),feFuncB:e(`feFuncB`),feFuncG:e(`feFuncG`),feFuncR:e(`feFuncR`),feGaussianBlur:e(`feGaussianBlur`),feImage:e(`feImage`),feMerge:e(`feMerge`),feMergeNode:e(`feMergeNode`),feMorphology:e(`feMorphology`),feOffset:e(`feOffset`),fePointLight:e(`fePointLight`),feSpecularLighting:e(`feSpecularLighting`),feSpotLight:e(`feSpotLight`),feTile:e(`feTile`),feTurbulence:e(`feTurbulence`),filter:e(`filter`),foreignObject:e(`foreignObject`),g:e(`g`),image:e(`image`),line:e(`line`),linearGradient:e(`linearGradient`),marker:e(`marker`),mask:e(`mask`),metadata:e(`metadata`),mpath:e(`mpath`),path:e(`path`),pattern:e(`pattern`),polygon:e(`polygon`),polyline:e(`polyline`),radialGradient:e(`radialGradient`),rect:e(`rect`),set:e(`set`),stop:e(`stop`),switch:e(`switch`),symbol:e(`symbol`),text:e(`text`),textPath:e(`textPath`),tspan:e(`tspan`),use:e(`use`),view:e(`view`),math:e(`math`),annotation:e(`annotation`),"annotation-xml":e(`annotation-xml`),maction:e(`maction`),menclose:e(`menclose`),merror:e(`merror`),mfenced:e(`mfenced`),mfrac:e(`mfrac`),mglyph:e(`mglyph`),mi:e(`mi`),mlabeledtr:e(`mlabeledtr`),mlongdiv:e(`mlongdiv`),mmultiscripts:e(`mmultiscripts`),mn:e(`mn`),mo:e(`mo`),mover:e(`mover`),mpadded:e(`mpadded`),mphantom:e(`mphantom`),mprescripts:e(`mprescripts`),mroot:e(`mroot`),mrow:e(`mrow`),ms:e(`ms`),mscarries:e(`mscarries`),mscarry:e(`mscarry`),msgroup:e(`msgroup`),msline:e(`msline`),mspace:e(`mspace`),msqrt:e(`msqrt`),msrow:e(`msrow`),mstack:e(`mstack`),mstyle:e(`mstyle`),msub:e(`msub`),msubsup:e(`msubsup`),msup:e(`msup`),mtable:e(`mtable`),mtd:e(`mtd`),mtext:e(`mtext`),mtr:e(`mtr`),munder:e(`munder`),munderover:e(`munderover`),semantics:e(`semantics`)}},BR=()=>({Key:e=>mee({value:e}),Class:e=>hee({value:e}),Id:e=>gee({value:e}),Title:e=>_ee({value:e}),Lang:e=>vee({value:e}),Dir:e=>yee({value:e}),Tabindex:e=>bee({value:e}),Hidden:e=>xee({value:e}),Contenteditable:e=>See({value:e}),Draggable:e=>Cee({value:e}),Accesskey:e=>wee({value:e}),Translate:e=>Tee({value:e}),Inert:e=>Eee({value:e}),Popover:e=>Dee({value:e}),Popovertarget:e=>Oee({value:e}),Popovertargetaction:e=>kee({value:e}),OnClick:(e,t)=>Aee(t===void 0?{message:e}:{message:e,options:t}),OnDoubleClick:e=>jee({message:e}),OnMouseDown:e=>Mee({message:e}),OnMouseUp:e=>Nee({message:e}),OnMouseEnter:e=>Pee({message:e}),OnMouseLeave:e=>Fee({message:e}),OnMouseOver:e=>Iee({message:e}),OnMouseOut:e=>Lee({message:e}),OnMouseMove:e=>Ree({message:e}),OnPointerMove:e=>zee({f:e}),OnPointerLeave:e=>Bee({f:e}),OnPointerDown:e=>Vee({f:e}),OnPointerUp:e=>Hee({f:e}),OnKeyDown:e=>Uee({f:e}),OnKeyDownPreventDefault:e=>Wee({f:e}),OnKeyDownSelf:e=>Gee({f:e}),OnKeyDownSelfPreventDefault:e=>Kee({f:e}),OnKeyDownFocus:e=>qee({f:e}),OnKeyUp:e=>Jee({f:e}),OnKeyUpPreventDefault:e=>Yee({f:e}),OnKeyPress:e=>Xee({f:e}),OnFocus:e=>Zee({message:e}),OnBlur:e=>Qee({message:e}),OnFocusEnter:e=>$ee({message:e}),OnFocusLeave:e=>ete({message:e}),OnInput:e=>tte({f:e}),OnChange:e=>nte({f:e}),OnBeforeInput:e=>rte({f:e}),OnBeforeInputPreventDefault:e=>ite({f:e}),OnFileChange:e=>UM({f:e}),OnSubmit:e=>WM({message:e}),OnReset:e=>GM({message:e}),OnScroll:e=>KM({f:e}),OnWheel:e=>qM({message:e}),OnCopy:e=>JM({message:e}),OnCut:e=>YM({message:e}),OnPaste:e=>XM({message:e}),OnPastePreventDefault:e=>ZM({f:e}),OnCopyText:e=>QM({text:e}),OnCutText:(e,t)=>$M({text:e,message:t}),OnCancel:e=>eN({message:e}),OnCancelPreventDefault:e=>tN({maybeCustomEventMessage:br(e)}),OnToggle:e=>nN({f:e}),OnContextMenu:e=>rN({message:e}),OnDragStart:e=>iN({message:e}),OnDrag:e=>aN({message:e}),OnDragEnd:e=>oN({message:e}),OnDragEnter:e=>sN({message:e}),OnDragLeave:e=>cN({message:e}),OnDragOver:e=>lN({message:e}),AllowDrop:()=>uN(),OnDrop:e=>dN({message:e}),OnDropFiles:e=>fN({f:e}),OnTouchStart:e=>pN({message:e}),OnTouchEnd:e=>mN({message:e}),OnTouchMove:e=>hN({message:e}),OnTouchCancel:e=>gN({message:e}),OnAnimationStart:e=>_N({message:e}),OnAnimationEnd:e=>vN({message:e}),OnAnimationIteration:e=>yN({message:e}),OnTransitionEnd:e=>bN({message:e}),OnLoad:e=>xN({message:e}),OnError:e=>SN({message:e}),OnPlay:e=>CN({message:e}),OnPause:e=>wN({message:e}),OnEnded:e=>TN({message:e}),OnTimeUpdate:e=>EN({message:e}),OnVolumeChange:e=>DN({message:e}),OnSelect:e=>ON({message:e}),Value:e=>kN({value:e}),Checked:e=>AN({value:e}),Selected:e=>jN({value:e}),Open:e=>MN({value:e}),Placeholder:e=>NN({value:e}),Name:e=>PN({value:e}),Disabled:e=>FN({value:e}),Readonly:e=>IN({value:e}),Required:e=>LN({value:e}),Autofocus:e=>RN({value:e}),Spellcheck:e=>zN({value:e}),Autocorrect:e=>BN({value:e}),Autocapitalize:e=>VN({value:e}),InputMode:e=>HN({value:e}),EnterKeyHint:e=>UN({value:e}),Multiple:e=>WN({value:e}),Type:e=>GN({value:e}),Accept:e=>KN({value:e}),Autocomplete:e=>qN({value:e}),Pattern:e=>JN({value:e}),Maxlength:e=>YN({value:e}),Minlength:e=>XN({value:e}),Size:e=>ZN({value:e}),Cols:e=>QN({value:e}),Rows:e=>$N({value:e}),Max:e=>eP({value:e}),Min:e=>tP({value:e}),Step:e=>nP({value:e}),For:e=>rP({value:e}),Href:e=>iP({value:e}),Src:e=>aP({value:e}),Alt:e=>oP({value:e}),Target:e=>sP({value:e}),Rel:e=>cP({value:e}),Download:e=>lP({value:e}),Action:e=>uP({value:e}),Method:e=>dP({value:e}),Enctype:e=>fP({value:e}),Novalidate:e=>pP({value:e}),Formaction:e=>mP({value:e}),Formmethod:e=>hP({value:e}),Formnovalidate:e=>gP({value:e}),Formtarget:e=>_P({value:e}),Formenctype:e=>vP({value:e}),Colspan:e=>yP({value:e}),Rowspan:e=>bP({value:e}),Scope:e=>xP({value:e}),Headers:e=>SP({value:e}),Span:e=>CP({value:e}),Start:e=>wP({value:e}),Reversed:e=>TP({value:e}),CiteAttr:e=>EP({value:e}),Datetime:e=>DP({value:e}),Wrap:e=>OP({value:e}),List:e=>kP({value:e}),FormAttr:e=>AP({value:e}),LabelAttr:e=>jP({value:e}),ContentAttr:e=>MP({value:e}),Charset:e=>NP({value:e}),HttpEquiv:e=>PP({value:e}),Srcset:e=>FP({value:e}),Sizes:e=>IP({value:e}),Loading:e=>LP({value:e}),Decoding:e=>RP({value:e}),Fetchpriority:e=>zP({value:e}),Crossorigin:e=>BP({value:e}),Referrerpolicy:e=>VP({value:e}),Integrity:e=>HP({value:e}),Hreflang:e=>UP({value:e}),Ping:e=>WP({value:e}),Sandbox:e=>GP({value:e}),Allow:e=>KP({value:e}),Srcdoc:e=>qP({value:e}),Autoplay:e=>JP({value:e}),Controls:e=>YP({value:e}),Loop:e=>XP({value:e}),Muted:e=>ZP({value:e}),Poster:e=>QP({value:e}),Preload:e=>$P({value:e}),Playsinline:e=>eF({value:e}),High:e=>tF({value:e}),Low:e=>nF({value:e}),Optimum:e=>rF({value:e}),Usemap:e=>iF({value:e}),Ismap:e=>aF({value:e}),Role:e=>oF({value:e}),AriaLabel:e=>sF({value:e}),AriaLabelledBy:e=>cF({value:e}),AriaDescribedBy:e=>lF({value:e}),AriaHidden:e=>uF({value:e}),AriaExpanded:e=>dF({value:e}),AriaSelected:e=>fF({value:e}),AriaChecked:e=>pF({value:e}),AriaDisabled:e=>mF({value:e}),AriaRequired:e=>hF({value:e}),AriaInvalid:e=>gF({value:e}),AriaLive:e=>_F({value:e}),AriaControls:e=>vF({value:e}),AriaCurrent:e=>yF({value:e}),AriaOrientation:e=>bF({value:e}),AriaPressed:e=>xF({value:e}),AriaHasPopup:e=>SF({value:e}),AriaActiveDescendant:e=>CF({value:e}),AriaSort:e=>wF({value:e}),AriaMultiSelectable:e=>TF({value:e}),AriaModal:e=>EF({value:e}),AriaBusy:e=>DF({value:e}),AriaErrorMessage:e=>OF({value:e}),AriaRoleDescription:e=>kF({value:e}),AriaAtomic:e=>AF({value:e}),AriaAutocomplete:e=>jF({value:e}),AriaColcount:e=>MF({value:e}),AriaColindex:e=>NF({value:e}),AriaColspan:e=>PF({value:e}),AriaDescription:e=>FF({value:e}),AriaDetails:e=>IF({value:e}),AriaFlowto:e=>LF({value:e}),AriaKeyshortcuts:e=>RF({value:e}),AriaLevel:e=>zF({value:e}),AriaOwns:e=>BF({value:e}),AriaPlaceholder:e=>VF({value:e}),AriaPosinset:e=>HF({value:e}),AriaReadonly:e=>UF({value:e}),AriaRelevant:e=>WF({value:e}),AriaRowcount:e=>GF({value:e}),AriaRowindex:e=>KF({value:e}),AriaRowspan:e=>qF({value:e}),AriaSetsize:e=>JF({value:e}),AriaValuemax:e=>YF({value:e}),AriaValuemin:e=>XF({value:e}),AriaValuenow:e=>ZF({value:e}),AriaValuetext:e=>QF({value:e}),Attribute:(e,t)=>$F({key:e,value:t}),DataAttribute:(e,t)=>eI({key:e,value:t}),Style:e=>tI({value:e}),InnerHTML:e=>nI({value:e}),ViewBox:e=>rI({value:e}),Xmlns:e=>iI({value:e}),Fill:e=>aI({value:e}),FillRule:e=>oI({value:e}),ClipRule:e=>sI({value:e}),Stroke:e=>cI({value:e}),StrokeWidth:e=>lI({value:e}),StrokeLinecap:e=>uI({value:e}),StrokeLinejoin:e=>dI({value:e}),D:e=>fI({value:e}),Cx:e=>pI({value:e}),Cy:e=>mI({value:e}),R:e=>hI({value:e}),X:e=>gI({value:e}),Y:e=>_I({value:e}),Width:e=>vI({value:e}),Height:e=>yI({value:e}),X1:e=>bI({value:e}),Y1:e=>xI({value:e}),X2:e=>SI({value:e}),Y2:e=>CI({value:e}),Points:e=>wI({value:e}),Transform:e=>TI({value:e}),Opacity:e=>EI({value:e}),StrokeDasharray:e=>DI({value:e}),StrokeDashoffset:e=>OI({value:e}),Dx:e=>kI({value:e}),Dy:e=>AI({value:e}),Rotate:e=>jI({value:e}),TextAnchor:e=>MI({value:e}),DominantBaseline:e=>NI({value:e}),AlignmentBaseline:e=>PI({value:e}),BaselineShift:e=>FI({value:e}),TextLength:e=>II({value:e}),LengthAdjust:e=>LI({value:e}),FontFamily:e=>RI({value:e}),FontSize:e=>zI({value:e}),FontWeight:e=>BI({value:e}),FontStyle:e=>VI({value:e}),LetterSpacing:e=>HI({value:e}),WordSpacing:e=>UI({value:e}),TextDecoration:e=>WI({value:e}),WritingMode:e=>GI({value:e}),Rx:e=>KI({value:e}),Ry:e=>qI({value:e}),PathLength:e=>JI({value:e}),FillOpacity:e=>YI({value:e}),StrokeOpacity:e=>XI({value:e}),StrokeMiterlimit:e=>ZI({value:e}),PaintOrder:e=>QI({value:e}),VectorEffect:e=>$I({value:e}),Color:e=>eL({value:e}),Visibility:e=>tL({value:e}),Display:e=>nL({value:e}),Overflow:e=>rL({value:e}),PointerEvents:e=>iL({value:e}),Cursor:e=>aL({value:e}),ShapeRendering:e=>oL({value:e}),TextRendering:e=>sL({value:e}),ImageRendering:e=>cL({value:e}),ClipPath:e=>lL({value:e}),Mask:e=>uL({value:e}),Filter:e=>dL({value:e}),ClipPathUnits:e=>fL({value:e}),MaskUnits:e=>pL({value:e}),MaskContentUnits:e=>mL({value:e}),FilterUnits:e=>hL({value:e}),PrimitiveUnits:e=>gL({value:e}),Offset:e=>_L({value:e}),StopColor:e=>vL({value:e}),StopOpacity:e=>yL({value:e}),GradientUnits:e=>bL({value:e}),GradientTransform:e=>xL({value:e}),SpreadMethod:e=>SL({value:e}),Fx:e=>CL({value:e}),Fy:e=>wL({value:e}),Fr:e=>TL({value:e}),PatternUnits:e=>EL({value:e}),PatternContentUnits:e=>DL({value:e}),PatternTransform:e=>OL({value:e}),MarkerStart:e=>kL({value:e}),MarkerMid:e=>AL({value:e}),MarkerEnd:e=>jL({value:e}),MarkerWidth:e=>ML({value:e}),MarkerHeight:e=>NL({value:e}),MarkerUnits:e=>PL({value:e}),RefX:e=>FL({value:e}),RefY:e=>IL({value:e}),Orient:e=>LL({value:e}),PreserveAspectRatio:e=>RL({value:e}),OnMount:e=>zL({action:e}),OnUnmount:e=>BL({message:e})}),VR={...zR(),...BR(),empty:null,keyed:RR(),submodel:e=>DM(e,VR)},HR=()=>VR,UR=HR(),WR=Symbol.for(`foldkit/CommandDefinition`),GR=(e,t)=>{Object.defineProperty(e,"name",{value:t,configurable:!0}),Object.defineProperty(e,WR,{value:WR})},KR=CO({Interrupted:{},NotFound:{}}),qR=()=>{let e=new Map,t=t=>O(br(e.get(t)),{onNone:()=>[],onSome:e=>Li(e)});return{lookup:t,register:(t,n)=>{O(br(e.get(t)),{onNone:()=>{e.set(t,new Set([n]))},onSome:e=>{e.add(n)}})},release:(t,n)=>{let r=br(e.get(t));D(r)&&(r.value.delete(n),r.value.size===0&&e.delete(t))},interrupt:e=>Up(()=>Ri(t(e),{onEmpty:()=>j(KR.NotFound()),onNonEmpty:e=>rm(oh(e),()=>KR.Interrupted())}))}},JR=k(`foldkit/Command/Interruptible/CurrentRegistry`,{defaultValue:qR}),YR=(e,t)=>Qp(n=>P(function*(){let r=yield*JR;return yield*Rm(i=>Up(()=>(r.register(e,n),i(t).pipe(km(M(()=>r.release(e,n)))))))})),XR=(e,t)=>P(function*(){return t(yield*(yield*JR).interrupt(e))}),ZR=(e,t)=>{let n=`${e}.Interrupt`,r=e=>({name:n,interruptsKey:t,effect:XR(t,e),messageMappers:[]});return GR(r,n),r},QR=(e,t)=>{let n=`${e}.Interrupt`,r=(e,r)=>{let i=t(e);return{name:n,args:e,interruptsKey:i,effect:XR(i,r),messageMappers:[]}};return GR(r,n),r},$R=(e,t)=>Up(()=>e.execute(t));function ez(e,t){let n=le(t.args),r=br(t.interrupt);if(E(r)){if(n){let n=n=>({name:e,args:n,effect:$R(t,n),messageMappers:[]});return GR(n,e),n}{let n=()=>({name:e,effect:t.execute,messageMappers:[]});return GR(n,e),n}}let{value:i}=r,a=ge(i)&&b(i,`toKey`)&&se(i.toKey)?T(i.toKey):w();if(!n){let n=()=>({name:e,key:e,effect:YR(e,t.execute),messageMappers:[]});return GR(n,e),Object.defineProperty(n,"Interrupt",{value:ZR(e,e)}),n}if(E(a)){let n=n=>({name:e,args:n,key:e,effect:YR(e,$R(t,n)),messageMappers:[]});return GR(n,e),Object.defineProperty(n,"Interrupt",{value:ZR(e,e)}),n}let{value:o}=a,s=t=>`${e}:${o(t)}`,c=n=>{let r=s(n);return{name:e,args:n,key:r,effect:YR(r,$R(t,n)),messageMappers:[]}};return GR(c,e),Object.defineProperty(c,"Interrupt",{value:QR(e,s)}),c}r(2,(e,t)=>({...e,effect:t(e.effect)}));var tz=r(2,(e,t)=>{let n=e;return{...n,effect:rm(e.effect,t),messageMappers:[...n.messageMappers??[],t]}});r(2,(e,t)=>ga(e??[],e=>tz(e,t)));var nz=class extends Nr()(`@foldkit/RenderCommit`){},rz=()=>{let e=!1,t=new Set;return{service:{isCommitPending:()=>e,onNextCommit:e=>(t.add(e),()=>{t.delete(e)})},markCommitPending:()=>{e=!0},notifyCommitted:()=>{e=!1;let n=Li(t);t.clear(),n.forEach(e=>e())}}},iz=class extends Nr()(`@foldkit/DialogRuntime`){},az={originals:new Map,counts:new Map,cleanups:new Map,requests:new Map},oz=e=>{let t=az.counts.get(e)??0;return az.counts.set(e,Cp(t)),t===0&&(az.originals.set(e,{ariaHidden:e.getAttribute(`aria-hidden`),inert:e.inert}),e.setAttribute(`aria-hidden`,`true`),e.inert=!0),()=>sz(e)},sz=e=>{let t=az.counts.get(e)??1;if(t===1){let t=az.originals.get(e);t&&(ue(t.ariaHidden)?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,t.ariaHidden),e.inert=t.inert,az.originals.delete(e)),az.counts.delete(e)}else az.counts.set(e,wp(t))},cz=(e,t)=>{let n=az.originals.get(e);n!==void 0&&(t===`aria-hidden`?az.originals.set(e,{...n,ariaHidden:e.getAttribute(`aria-hidden`)}):az.originals.set(e,{...n,inert:e.inert}))},lz=e=>Ca(e.parentElement,e=>de(e)?T([e,e===document.body?null:e.parentElement]):w()),uz=(e,t)=>d(e.children,Li,va(e=>e instanceof HTMLElement&&!Sa(t,t=>e.contains(t))?mi(e):gi)),dz=e=>{let t=new Set;for(let n of e)for(let r of lz(n))for(let n of uz(r,e))t.add(n);return t},fz=()=>{let e=new Map;return{update:t=>{let n=dz(t);for(let[t,r]of e)n.has(t)||(r(),e.delete(t));for(let t of n)e.has(t)?(t.getAttribute(`aria-hidden`)!==`true`&&t.setAttribute(`aria-hidden`,`true`),t.inert||=!0):e.set(t,oz(t))},contains:t=>e.has(t),recordAttributeMutation:(t,n)=>{e.has(t)&&cz(t,n)},dispose:()=>{for(let t of e.values())t();e.clear()}}},pz={count:0,overflow:``,paddingRight:``},mz=()=>{let{platform:e,maxTouchPoints:t}=window.navigator,n=/iPhone/gi.test(e),r=/Mac/gi.test(e)&&t>0;return n||r},hz=e=>{let t=window.getComputedStyle(e).overflowY;return(t===`auto`||t===`scroll`)&&e.scrollHeight>e.clientHeight},gz=e=>{let t=e;for(;t&&t!==document.documentElement;){if(hz(t))return t;t=t.parentElement}return null},_z=e=>{let t=e.composedPath()[0];return t instanceof Element?t:null},vz=e=>{let t=_z(e);t&&!gz(t)&&e.preventDefault()};M(()=>{let{documentElement:e,documentElement:{style:t}}=document;if(pz.count===0){pz.overflow=t.overflow,pz.paddingRight=t.paddingRight;let n=window.innerWidth-e.clientWidth;t.overflow=`hidden`,t.paddingRight=n>0?`${n}px`:t.paddingRight,mz()&&document.addEventListener(`touchmove`,vz,{passive:!1})}pz.count++});var yz=M(()=>{if(pz.count=Math.max(0,wp(pz.count)),pz.count===0){let{documentElement:{style:e}}=document;e.overflow=pz.overflow,e.paddingRight=pz.paddingRight,document.removeEventListener(`touchmove`,vz)}}),bz=0,xz=new Map,Sz=[],Cz,wz,Tz=[],Ez=[],Dz=[],Oz=new Set,kz=e=>e instanceof Element||e instanceof DocumentFragment?Sa(Dz,t=>{try{return e instanceof Element&&e.matches(t)||e.querySelector(t)!==null}catch{return!1}}):!1,Az=e=>Sa(Tz,t=>e.contains(t)),jz=e=>{if(e.type===`attributes`&&(e.attributeName===`aria-hidden`||e.attributeName===`inert`))return e.target instanceof HTMLElement&&Cz?.contains(e.target)===!0;if(e.type===`attributes`)return Sa(Ez,t=>e.target.contains(t))||kz(e.target);let t=[...Li(e.addedNodes),...Li(e.removedNodes)];return e.target instanceof HTMLElement&&Oz.has(e.target)&&Sa(t,e=>e instanceof Element)?!0:Sa(t,e=>Az(e)||kz(e))},Mz=e=>{let t=new Set;for(let n of e){let e=n.parentElement;for(;e!==null&&(t.add(e),e!==document.body);)e=e.parentElement}return t},Nz=e=>{for(let t of e)t.type===`attributes`&&t.target instanceof HTMLElement&&(t.attributeName===`aria-hidden`||t.attributeName===`inert`)&&Cz?.recordAttributeMutation(t.target,t.attributeName)},Pz=()=>{wz!==void 0&&Nz(wz.takeRecords()),wz?.disconnect();let e=Qi(ya(Sz,e=>e.isModal));if(E(e)){wz?.disconnect(),wz=void 0,Cz?.dispose(),Cz=void 0,Tz=[],Ez=[],Dz=[],Oz=new Set;return}let{allowedOutsideSelectors:t}=e.value,n=ia(Sz,t=>t!==e.value),r=va(t,e=>{try{let t=document.querySelector(e);return t instanceof HTMLElement?mi(t):gi}catch{return gi}}),i=[...ga(n,e=>e.element),...r];Cz??=fz(),Cz.update(i),Tz=i,Ez=r,Dz=t,Oz=Mz(i),wz??=new MutationObserver(e=>{Sa(e,jz)&&(Nz(e),Pz())}),wz.observe(document.body,{childList:!0,subtree:!0,attributes:!0})};Da([`a[href]:not([tabindex="-1"])`,`button:not([disabled]):not([tabindex="-1"])`,`input:not([disabled]):not([tabindex="-1"])`,`select:not([disabled]):not([tabindex="-1"])`,`textarea:not([disabled]):not([tabindex="-1"])`,`[tabindex]:not([tabindex="-1"])`],`, `);var Fz=e=>e.closest(`[hidden], [inert]`)===null&&e.checkVisibility({visibilityProperty:!0}),Iz=e=>!(e instanceof HTMLElement)||e.matches(`:disabled`)||e instanceof HTMLInputElement&&e.type===`hidden`||e.tabIndex<0&&!e.hasAttribute(`tabindex`)?!1:Fz(e),Lz=e=>document.contains(e)?e instanceof HTMLDialogElement?e.open&&Fz(e):Iz(e):!1,Rz=e=>{let t=xz.get(e);if(t===void 0)return!1;let n=oa(Sz,t=>t.id===e),r=jr(Qi(Sz),t=>t.id===e);if(D(n))for(let r of Sz){if(r.id===e)continue;let i=xz.get(r.id),a=i?.returnFocus;i!==void 0&&a!==void 0&&n.value.element.contains(a)&&xz.set(r.id,{...i,returnFocus:t.returnFocus})}Sz=ya(Sz,t=>t.id!==e),Pz(),bz=Math.max(0,wp(bz)),t.removeKeydownListener(),xz.delete(e),t.unregisterOwner?.();let{returnFocus:i}=t;return r&&i!==void 0&&Lz(i)&&i.focus(),!0},zz=e=>Up(()=>Rz(e)?im(yz,!0):j(!1)),Bz=ho(1),Vz=/Mac|iPhone|iPad|iPod/,Hz=[`alt`,`altgraph`,`capslock`,`control`,`fn`,`fnlock`,`hyper`,`meta`,`numlock`,`os`,`scrolllock`,`shift`,`super`,`symbol`,`symbollock`],Uz=[`alt`,`control`,`meta`,`mod`,`shift`],Wz=[`cmd`,`command`,`ctrl`,`option`],Gz=e=>e===` `?e:BD(d(e,Ep,Tp)).pipe(VD(),HD(`space`,()=>` `),HD(`plus`,()=>`+`),GD(e=>e)),Kz=e=>BD(e).pipe(VD(),HD(` `,()=>`space`),HD(`+`,()=>`plus`),GD(e=>e)),qz=(e,t)=>Ar(t,()=>e),Jz=(e,t)=>{let n=e.isModRequired&&t===void 0,r=e.isControlRequired||e.isModRequired&&t===`Control`,i=e.isMetaRequired||e.isModRequired&&t===`Meta`;return d([qz(n,`mod`),qz(r,`control`),qz(i,`meta`),qz(e.isAltRequired,`alt`),qz(e.isShiftRequired,`shift`),T(Kz(e.key))],_a,Da(`+`))},Yz=(e,t)=>{throw Error(`Invalid key binding "${e}": ${t}`)},Xz=e=>Gi(Ea(e))!==Gi(e),Zz=e=>{let t=d(e,Op(`+`),ga(e=>d(e,Ep,Tp)));if(Sa(t,Dp))return Yz(e,`each modifier and key must be named; use "Plus" for the + key`);let n=oa(t,e=>fa(Wz,e));if(D(n))return Yz(e,`unknown modifier "${n.value}"`);let[r,i]=Yi(t),a=Gz(i);if(fa(Uz,i)||fa(Hz,a))return Yz(e,`a non-modifier key is required`);let o=oa(r,e=>!fa(Uz,e));if(D(o))return Yz(e,`unknown modifier "${o.value}"`);if(Xz(r))return Yz(e,`a modifier is repeated`);let s=fa(r,`mod`),c=fa(r,`control`),l=fa(r,`meta`);if(s&&(c||l))return Yz(e,`Mod cannot be combined with Control or Meta`);let u={key:a,isAltRequired:fa(r,`alt`),isControlRequired:c,isMetaRequired:l,isModRequired:s,isShiftRequired:fa(r,`shift`)};return{...u,identifier:Jz(u)}},Qz=e=>{if(!ne(e.keys)&&Gi(e.keys)<2)throw Error(`A key binding sequence requires at least two key presses`);return{presses:ne(e.keys)?ha(Zz(e.keys)):ga(e.keys,Zz),mapEvent:e.mapEvent,whileTyping:e.whileTyping??`Suppress`,preventDefault:e.preventDefault??!0,whenRepeated:e.whenRepeated??`Ignore`}},$z=e=>d(e.presses,ga(e=>e.identifier),Da(` `)),eB=(e,t,n)=>Jz(e,n)===Jz(t,n),tB=(e,t,n)=>Gi(e.presses)>Gi(t.presses)?!1:xa(la(e.presses,t.presses),([e,t])=>eB(e,t,n)),nB=(e,t,n)=>eB(Zi(e.presses),Zi(t.presses),n),rB=(e,t,n)=>{let r=tB(e,t,n),i=tB(t,e,n);if(r||i){let n=Gi(e.presses)===Gi(t.presses)?`duplicates`:`overlaps as a complete binding and a sequence prefix`;throw Error(`Key binding "${$z(e)}" ${n} "${$z(t)}"`)}if(nB(e,t,n)&&e.preventDefault!==t.preventDefault)throw Error(`Key binding sequences beginning with the same key must use the same preventDefault setting: "${$z(e)}" and "${$z(t)}"`)},iB=(e,t)=>{Ta(e,(n,r)=>{Ta(ra(e,r+1),e=>{rB(n,e,t)})})},aB=e=>d(e,ya(e=>e.isEnabled!==!1),ga(Qz)),oB=e=>Gi(e.presses)>1,sB=e=>fa(Hz,Gz(e.key)),cB=(e,t)=>b(e,t)&&ne(e[t]),lB=(e,t)=>b(e,t)&&ie(e[t]),uB=(e,t)=>b(e,t)&&se(e[t]),dB=e=>{if(!cB(e,`tagName`)||!lB(e,`isContentEditable`))return!1;let t=Tp(e.tagName);return t===`input`||t===`textarea`||t===`select`||e.isContentEditable},fB=e=>Sa(e.composedPath(),dB),pB=e=>cB(e,`key`)&&lB(e,`altKey`)&&lB(e,`ctrlKey`)&&lB(e,`metaKey`)&&lB(e,`shiftKey`)&&lB(e,`repeat`)&&lB(e,`isComposing`),mB=(e,t)=>!t||e.whileTyping===`Allow`,hB=(e,t)=>e===void 0?Vz.test(t)?`Meta`:`Control`:e,gB=(e,t,n)=>{let r=e.isControlRequired||e.isModRequired&&n===`Control`,i=e.isMetaRequired||e.isModRequired&&n===`Meta`;return e.key===Gz(t.key)&&e.isAltRequired===t.altKey&&r===t.ctrlKey&&i===t.metaKey&&e.isShiftRequired===t.shiftKey},_B=(e,t,n)=>gB(Zi(e.presses),t,n),vB=(e,t,n,r)=>jr(qi(e.presses,t),e=>gB(e,n,r)),yB=e=>se(e)?e():e??document,bB=(e,t)=>e===void 0?t===void 0?typeof navigator>`u`?w():T(hB(void 0,navigator.userAgent)):se(t)?w():wr(NB(t),e=>hB(void 0,e.navigator.userAgent)):T(e),xB=e=>{let t=aB(e.bindings),n=go(e.sequenceTimeout??Bz);if(!globalThis.Number.isFinite(n)||n<=0)throw Error(`sequenceTimeout must be a finite duration above zero`);let r=bB(e.modKey,e.target);return D(r)&&iB(t,r.value),{bindings:t,modKey:e.modKey,sequenceTimeout:n,target:e.target}},SB=e=>{let t={maybeSequence:w()},n=()=>{D(t.maybeSequence)&&clearTimeout(t.maybeSequence.value.timeout),t.maybeSequence=w()};return{clearSequence:n,readSequence:()=>t.maybeSequence,setSequence:r=>{n(),t.maybeSequence=T({...r,timeout:setTimeout(n,e)})}}},CB=(e,t,n)=>{e.sequenceController.clearSequence(),t.preventDefault&&n.preventDefault(),e.emitMessage(t.mapEvent(n))},wB=(e,t,n)=>r=>!oB(r)&&mB(r,n)&&(!e.repeat||r.whenRepeated===`Allow`)&&_B(r,e,t),TB=(e,t)=>{let n=fB(t),r=oa(e.bindings,wB(t,e.modKey,n));if(D(r)){CB(e,r.value,t);return}if(t.repeat)return;let i=ya(e.bindings,r=>oB(r)&&mB(r,n)&&_B(r,t,e.modKey));if(Ui(i)){let n=Zi(i);e.sequenceController.setSequence({bindings:i,matchedPressCount:1}),n.preventDefault&&t.preventDefault()}},EB=(e,t,n)=>{let r=fB(n),i=ya(t.bindings,i=>mB(i,r)&&vB(i,t.matchedPressCount,n,e.modKey));if(!Wi(i)){e.sequenceController.clearSequence(),TB(e,n);return}let a=Zi(i),o=Cp(t.matchedPressCount),s=oa(i,e=>Gi(e.presses)===o);D(s)?CB(e,s.value,n):(e.sequenceController.setSequence({bindings:i,matchedPressCount:o}),a.preventDefault&&n.preventDefault())},DB=(e,t)=>{if(!pB(t))return;if(t.defaultPrevented||hk(t)){e.sequenceController.clearSequence();return}if(sB(t))return;let n=e.sequenceController.readSequence();t.repeat&&D(n)||O(n,{onNone:()=>TB(e,t),onSome:n=>EB(e,n,t)})},OB=e=>{let t=SB(e.sequenceTimeout),n={bindings:e.bindings,emitMessage:e.emitMessage,modKey:e.modKey,sequenceController:t};return{clearSequence:t.clearSequence,handleEvent:e=>DB(n,e)}},kB=e=>uB(e,`addEventListener`)&&uB(e,`removeEventListener`),AB=e=>kB(e)&&b(e,`defaultView`),jB=e=>kB(e)&&b(e,`document`)&&AB(e.document)&&b(e,`navigator`)&&cB(e.navigator,`userAgent`),MB=e=>AB(e)&&(e.defaultView===null||jB(e.defaultView)),NB=e=>jB(e)?T(e):MB(e)?br(e.defaultView):b(e,`ownerDocument`)&&MB(e.ownerDocument)?br(e.ownerDocument.defaultView):w(),PB=e=>MB(e)?e:b(e,`ownerDocument`)&&MB(e.ownerDocument)?e.ownerDocument:b(e,`document`)&&MB(e.document)?e.document:document,FB=(e,t)=>{let n=yB(e.target),r=PB(n),i=r.defaultView??window,a=hB(e.modKey,i.navigator.userAgent);iB(e.bindings,a);let o=OB({bindings:e.bindings,emitMessage:t,modKey:a,sequenceTimeout:e.sequenceTimeout});return n.addEventListener(`keydown`,o.handleEvent),i.addEventListener(`blur`,o.clearSequence),r.addEventListener(`visibilitychange`,o.clearSequence),{...o,ownerDocument:r,ownerWindow:i,target:n}},IB=e=>{e.target.removeEventListener(`keydown`,e.handleEvent),e.ownerWindow.removeEventListener(`blur`,e.clearSequence),e.ownerDocument.removeEventListener(`visibilitychange`,e.clearSequence),e.clearSequence()},LB=e=>UE(t=>{let n=e=>{jh(t,e)};return Dm(M(()=>FB(e,n)),e=>M(()=>IB(e)))}),RB=e=>LB(xB(e)),zB=`~effect/http/HttpBody`,BB=class{[zB];constructor(){this[zB]=zB}[Ct](){return this.toJSON()}toString(){return ft(this,{ignoreToString:!0})}},VB=new class extends BB{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},HB=class extends BB{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=KB(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},UB=(e,t)=>new HB(e,t??`application/octet-stream`,e.length),WB=new TextEncoder,GB=globalThis.Buffer,KB=GB===void 0?e=>WB.encode(e):e=>GB.from(e,`utf8`),qB=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),GB!==void 0)return new HB(void 0,t??`text/plain`,GB.byteLength(e,`utf8`),e);let n=WB.encode(e);return new HB(n,t??`text/plain`,n.length,e)},JB=`~effect/http/HttpClientError`,YB=class extends Lo(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[JB]=JB;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},XB=e=>e.endsWith(`Error`)?e.slice(0,-5):e,ZB=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,QB=e=>`${e.method} ${kv(e.url)}`,$B=(e,t)=>({...t,request:{_id:`HttpClientRequest`,method:e.request.method,url:kv(e.request.url)},...`response`in e?{response:{_id:`HttpClientResponse`,status:e.response.status}}:void 0}),eV=class extends Lo(`TransportError`){get methodAndUrl(){return QB(this.request)}get message(){return ZB(XB(this._tag),this.description,this.methodAndUrl)}toJSON(){return $B(this,super.toJSON())}},tV=class extends Lo(`EncodeError`){get methodAndUrl(){return QB(this.request)}get message(){return ZB(XB(this._tag),this.description,this.methodAndUrl)}toJSON(){return $B(this,super.toJSON())}},nV=class extends Lo(`InvalidUrlError`){get methodAndUrl(){return QB(this.request)}get message(){return ZB(XB(this._tag),this.description,this.methodAndUrl)}toJSON(){return $B(this,super.toJSON())}},rV=class extends Lo(`StatusCodeError`){get methodAndUrl(){return QB(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return ZB(XB(this._tag),this.description,e)}toJSON(){return $B(this,super.toJSON())}},iV=class extends Lo(`DecodeError`){get methodAndUrl(){return QB(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return ZB(XB(this._tag),this.description,e)}toJSON(){return $B(this,super.toJSON())}},aV=class extends Lo(`EmptyBodyError`){get methodAndUrl(){return QB(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return ZB(XB(this._tag),this.description,e)}toJSON(){return $B(this,super.toJSON())}},oV=class e extends eT(JB)({_tag:_w(`HttpError`),kind:dw([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:ZC(Rw())}){static fromHttpClientError(t){return new e({_tag:`HttpError`,kind:t.reason._tag,cause:t.reason})}},sV=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],cV=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?lv(lv(e,`content-type`),`content-length`):(e=t.contentType===void 0?lv(e,`content-type`):ov(e,`content-type`,t.contentType),lV(e,t)),lV=(e,t)=>{let n=t._tag===`Empty`||t._tag===`FormData`?void 0:t.contentLength;return n===void 0?lv(e,`content-length`):ov(e,`content-length`,n.toString())},uV=class extends Lo(`UrlError`){},dV=(e,t,n)=>_i({try:()=>{let r=new URL(e,fV());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,pv(i))}return n!==void 0&&(r.hash=n),r},catch:e=>new uV({cause:e})}),fV=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0){let e=location.origin+location.pathname;try{return new URL(e).href}catch{return}}},pV=`~effect/http/HttpClientRequest`,mV={[pV]:pV,...Et,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:kv(this.url),urlParams:this.urlParams,hash:this.hash,headers:st(this.headers),body:this.body.toJSON()}},pipe(){return e(this,arguments)}};function hV(e,t,n,r,i,a){let o=Object.create(mV);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var gV=hV(`GET`,``,Tv,w(),rv,VB),_V=e=>(t,n)=>vV(gV,{method:e,url:t,...n??void 0}),vV=r(2,(e,t)=>{let n=e;return t.method&&(n=yV(n,t.method)),t.url&&(n=wV(n,t.url)),t.headers&&(n=xV(n,t.headers)),t.urlParams&&(n=DV(n,t.urlParams)),t.hash&&(n=OV(n,t.hash)),t.body&&(n=kV(n,t.body)),t.accept&&(n=SV(n,t.accept)),t.acceptJson&&(n=CV(n)),n}),yV=r(2,(e,t)=>hV(t,e.url,e.urlParams,e.hash,e.headers,e.body)),bV=r(3,(e,t,n)=>hV(e.method,e.url,e.urlParams,e.hash,ov(e.headers,t,n),e.body)),xV=r(2,(e,t)=>hV(e.method,e.url,e.urlParams,e.hash,sv(e.headers,t),e.body)),SV=r(2,(e,t)=>bV(e,`Accept`,t)),CV=SV(`application/json`),wV=r(2,(e,t)=>{if(typeof t==`string`)return hV(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=bv(n.searchParams),i=br(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,hV(e.method,n.toString(),r,i,e.headers,e.body)}),TV=r(2,(e,t)=>t===``?e:hV(e.method,EV(t,e.url),e.urlParams,e.hash,e.headers,e.body)),EV=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},DV=r(2,(e,t)=>hV(e.method,e.url,Ev(e.urlParams,t),e.hash,e.headers,e.body)),OV=r(2,(e,t)=>hV(e.method,e.url,e.urlParams,T(t),e.headers,e.body)),kV=r(2,(e,t)=>hV(e.method,e.url,e.urlParams,e.hash,cV(e.headers,t),t));function AV(e){let t=dV(e.url,e.urlParams,Sr(e.hash));return bi(t)?T(t.success):w()}var jV=`~effect/http/HttpIncomingMessage`,MV=(e,t)=>({...t,headers:st(e.headers),remoteAddress:e.remoteAddress}),NV=`~effect/http/HttpClientResponse/WebSource`,PV=e=>e[NV]?.(),FV=`~effect/http/HttpClientResponse`,IV=(e,t)=>new LV(e,t),LV=class extends Dt{[jV];[FV];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[jV]=jV,this[FV]=FV}toJSON(){return MV(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=AV(this.request);return E(e)?``:(e.value.hash=``,e.value.href)}get headers(){return iv(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=z_(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return w()}[NV](){return this.source}get stream(){return this.source.body?$E({evaluate:()=>this.source.body,onError:e=>new YB({reason:new iV({request:this.request,response:this,cause:e})})}):YE(new YB({reason:new aV({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return F(this.text,e=>Xp({try:()=>e===``?null:JSON.parse(e),catch:e=>new YB({reason:new iV({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=rm(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return F(this.arrayBuffer,e=>Xp({try:()=>bv(hv(e)),catch:e=>new YB({reason:new iV({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=Vp({try:()=>this.source.formData(),catch:e=>new YB({reason:new iV({request:this.request,response:this,cause:e})})}).pipe(Nm,Xm)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=Vp({try:()=>this.source.arrayBuffer(),catch:e=>new YB({reason:new iV({request:this.request,response:this,cause:e})})}).pipe(Nm,Xm),this.arrayBufferBody}get upgrade(){return Kp(new YB({reason:new rV({request:this.request,response:this,description:`fetch cannot hand over the connection of an HTTP upgrade`})}))}pipe(){return e(this,arguments)}},RV=e=>av({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${O(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId.padStart(32,`0`)}-${e.spanId}-${e.sampled?`01`:`00`}`}),zV={"http:":80,"https:":443,"ws:":80,"wss:":443},BV=(e,t,n)=>{let r=kv(t.search,n).slice(1);if(e.attribute(`url.full`,kv(t.href,n)),e.attribute(`url.path`,t.pathname),r!==``&&e.attribute(`url.query`,r),e.attribute(`url.scheme`,t.protocol.slice(0,-1)),t.hostname!==``){e.attribute(`server.address`,t.hostname.startsWith(`[`)?t.hostname.slice(1,-1):t.hostname);let n=t.port===``?zV[t.protocol]:Number(t.port);n!==void 0&&e.attribute(`server.port`,n)}},VV=(e,t)=>{let n=e.params.filter(([,e])=>typeof e!=`string`).map(([e])=>e);return n.length===0?t:[...t,...new URLSearchParams(n.map(e=>[e,``])).keys()]},HV=(e,t,n,r,i)=>{for(let a in n)r(a,t)&&e.attribute(`http.${t}.header.${a}`,dv(a,i)?`<redacted>`:n[a])},UV=`~effect/http/HttpClient`,WV=Nr(`effect/HttpClient`),GV=r(2,(e,t)=>KV(n=>t(e.postprocess(n)),e.preprocess)),KV=(e,t)=>{let n=Object.create(qV);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},qV={[UV]:UV,pipe(){return e(this,arguments)},...Et,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(sV.map(([e,t])=>[t,function(t,n){return this.execute(_V(e)(t,n))}]))},JV=e=>KV(t=>F(t,t=>Qp(n=>{let r=rH.get(t),i=r??new AbortController,a=dV(t.url,t.urlParams,Sr(t.hash));if(yi(a))return Kp(new YB({reason:new nV({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(Ko)||n.getRef(ZV)(t)){let a=e(t,o,i.signal,n);return r?rm(a,e=>aH(e,i,!0)):Rm(e=>vm(e(a),{onSuccess(e){return j(aH(e,i,!1))},onFailure(e){return ef(e)&&i.abort(),qp(e)}}))}return Vm(n.getRef(eH)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method);let s=n.getRef(fv);BV(a,o,VV(t.urlParams,n.getRef(Lv)));let c=n.getRef(QV);return HV(a,`request`,t.headers,c,s),t=n.getRef($V)?xV(t,RV(a)):t,Rm(l=>l(e(t,o,i.signal,n)).pipe(Um(a,{captureStackTrace:!1}),vm({onSuccess:e=>(a.attribute(`http.response.status_code`,e.status),HV(a,`response`,e.headers,c,s),e.status>=400&&e.status<600&&(a.attribute(`error.type`,String(e.status)),YV(n,a,t,e)),j(aH(e,i,r!==void 0))),onFailure(e){return!r&&ef(e)&&i.abort(),qp(e)}})))})})),j),YV=(e,t,n,r)=>{let i=kt();At(0);let a;try{a=cf(new YB({reason:new rV({request:n,response:r})}))}finally{At(i)}t.end(e.getRef(Df)?e.getRef(op).currentTimeNanosUnsafe():BigInt(0),a)},XV=r(2,(e,t)=>KV(e.postprocess,n=>rm(e.preprocess(n),t))),ZV=k(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>s}),QV=k(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>s}),$V=k(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:o}),eH=k(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>e.method}),tH=e=>Qf(WV)(bm(t=>rm(e,e=>GV(e,Cm(e=>li(t,e)))))),nH=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{try{e.abort()}catch{}});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new WeakMap;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),rH=new WeakMap,iH=new WeakMap,aH=(e,t,n)=>(n||(nH.register(e,t),e=new oH(e,t)),iH.set(e,t),e),oH=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[FV]=FV;[jV]=jV;applyInterrupt(e){return Up(()=>(nH.unregister(this.original),Im(e,()=>M(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get upgrade(){return this.applyInterrupt(this.original.upgrade)}[NV](){let e=PV(this.original);return e!==void 0&&nH.unregister(this.original),e}get stream(){return qE(()=>(nH.unregister(this.original),gD(this.original.stream,M(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Ct](){return this.original[Ct]()}pipe(){return e(this,arguments)}},sH=k(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),cH=k(`effect/http/FetchHttpClient/StreamBodyFallback`,{defaultValue:()=>`error`}),lH=class extends Nr()(`effect/http/FetchHttpClient/RequestInit`){},uH,dH=()=>{try{let e=!1,t=new ReadableStream,n=new Request(`https://example.com`,{method:`POST`,body:t,get duplex(){return e=!0,`half`}});return(e||n.body===t)&&!n.headers.has(`Content-Type`)}catch{return!1}},fH=tH(j(JV((e,t,n,r)=>{if(e.headers.upgrade!==void 0)return Kp(new YB({reason:new eV({request:e,description:`fetch cannot send an HTTP upgrade request`})}));let i=r.getRef(sH),a=ti(r.context,lH)??{},o=a.headers?cv(iv(a.headers),e.headers):e.headers;o[`content-length`]&&(o=lv(o,`content-length`));let s,c=M(()=>s?.abort()),l=r=>rm(Vp({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:s?AbortSignal.any([n,s.signal]):n}),catch:t=>new YB({reason:new eV({request:e,cause:t})})}),t=>{let n=IV(e,t);return s?(t.body===null&&s.abort(),Object.create(n,{...Object.fromEntries([`arrayBuffer`,`text`,`json`,`formData`,`urlParamsBody`].map(e=>[e,{get:()=>km(n[e],c)}])),stream:{get:()=>gD(n.stream,c)}})):n}).pipe(Am(()=>c));switch(e.body._tag){case`Raw`:case`Uint8Array`:return l(e.body.body);case`FormData`:return l(e.body.formData);case`Stream`:if(uH??=dH(),uH){s=new AbortController;let t=AbortSignal.any([n,s.signal]),r=Wp(e=>{let n=()=>e(Pm);if(t.aborted)n();else return t.addEventListener(`abort`,n,{once:!0}),M(()=>t.removeEventListener(`abort`,n))});return F(SD(hD(e.body.stream,r)),l)}return r.getRef(cH)===`error`?Kp(new YB({reason:new tV({request:e,description:`Streaming request bodies are not supported in this runtime`})})):bD(e.body.stream).pipe(lm(t=>new YB({reason:new tV({request:e,cause:t})})),F(l))}return l(void 0)}))),pH=`~effect/socket/Socket/SocketError`,mH=e=>b(e,pH),hH=uw([class extends eT(`effect/socket/Socket/SocketReadError`)({_tag:_w(`SocketReadError`),cause:Rw()}){message=`An error occurred during Read`},class extends eT(`effect/socket/Socket/SocketWriteError`)({_tag:_w(`SocketWriteError`),cause:Rw()}){message=`An error occurred during Write`},class extends eT(`effect/socket/Socket/SocketOpenError`)({_tag:_w(`SocketOpenError`),kind:dw([`Unknown`,`Timeout`]),cause:Rw()}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},class e extends eT(`effect/socket/Socket/SocketUpgradeError`)({_tag:_w(`SocketUpgradeError`),cause:ZC(Rw())}){static unsupported=()=>Kp(new gH({reason:new e({})}));get message(){return this.cause===void 0?`Socket does not support TLS upgrade`:`An error occurred during TLS upgrade`}},class extends eT(`effect/socket/Socket/SocketCloseError`)({_tag:_w(`SocketCloseError`),code:jw,closeReason:ZC(L)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}}]),gH=class extends tT(pH)(`SocketError`,{_tag:_w(`SocketError`),reason:hH}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[pH]=pH;static is(e){return mH(e)}message=this.reason.message},_H=Ar(oee);r(2,(e,t)=>Ar(t,()=>e));var vH=e=>f(Ar(see(e)),wr(aee(e.length))),yH=e=>f(vH(e),Tr(_H)),bH=z({protocol:L,host:L,port:Ww(L),pathname:L,search:Ww(L),hash:Ww(L)}),xH=z({href:L,location:z({protocol:L,host:L,port:L})}),SH=L.pipe(hw(xH,Vy({decode:e=>Xp({try:()=>{let t=new URL(e);return{href:`${t.pathname}${t.search}${t.hash}`,location:{protocol:t.protocol,host:t.hostname,port:t.port}}},catch:()=>new ay({message:`Invalid URL: ${e}`})}),encode:({href:e,location:t})=>{let n=t.port?`:${t.port}`:``;return j(`${t.protocol}//${t.host}${n}${e}`)}}))),CH=xH.pipe(hw(bH,Hy({decode:({href:e,location:t})=>{let[n,r]=Op(e,`#`),[i,a]=Op(n,`?`);return{protocol:t.protocol,host:t.host,port:_H(t.port),pathname:i||`/`,search:_H(a||``),hash:_H(r||``)}},encode:e=>{let t=O(e.search,{onNone:()=>``,onSome:e=>`?${e}`}),n=O(e.hash,{onNone:()=>``,onSome:e=>`#${e}`});return{href:`${e.pathname}${t}${n}`,location:{protocol:e.protocol,host:e.host,port:vr(e.port,()=>``)}}}}))),wH=SH.pipe(hw(CH)),TH=e=>HC(wH)(e),EH=CO({Internal:{url:bH},External:{href:L}}),DH=()=>e=>e(((e,t)=>({dependenciesSchema:z(e),...t}))),OH=e=>({dependenciesSchema:z({}),modelToDependencies:()=>({}),dependenciesToStream:()=>e}),kH={isConfigured:!1,lookupInbound:()=>w(),lookupOutbound:()=>w()},AH=k(`foldkit/Port/CurrentPortChannels`,{defaultValue:()=>kH}),jH=()=>{let e=new Set,t=T([]);return{deliver:n=>{e.size>0?e.forEach(e=>e(n)):D(t)&&t.value.push(n)},attach:n=>{if(e.add(n),D(t)){let{value:e}=t;t=w(),e.forEach(n)}return()=>{e.delete(n)}}}},MH=class extends Nr()(`@foldkit/Dispatch`){},NH=`data-foldkit-build`,PH=`data-foldkit-app`,FH=`data-foldkit-flags`,IH=class extends Lo(`FlagsPayloadDecodeFailed`){},LH=(e,t)=>{let n=e.getAttribute(`data-foldkit-app`)??``;return{root:e,runtimeId:n,flagsScripts:d(Li(document.querySelectorAll(`script[${FH}]`)),ya(e=>e.getAttribute(FH)===n)),isFlagsRequired:t}},RH=e=>{let t=new Set;for(let n of e){let e=n.getAttribute(`data-foldkit-app`)??``;if(e===``)throw XH(n.ownerDocument),Error(`[foldkit] Found a server-rendered root with an empty \`${PH}\` stamp. A hydratable root must carry a nonempty runtime id so the runtime can scope its Flags, Model, and scroll preservation.`);if(!n.ownerDocument.body?.contains(n))throw XH(n.ownerDocument),Error(`[foldkit] Found a server-rendered root outside the document body. Runtime.hydrate supports one page-owning application in the document light DOM. Do not hydrate a root in the head, a shadow tree, or a detached subtree.`);if(t.has(e))throw XH(n.ownerDocument),Error(`[foldkit] Found more than one server-rendered root stamped "${e}". A runtime id names one application for the whole page: it pairs a root with its Flags payload and keys the preserved Model and scroll position, so two roots sharing one would take each other's state. Remove the duplicate root. Foldkit hydrates one page-owning application per document.`);t.add(e)}},zH=e=>{if(e.length>1)throw XH(document),Error(`[foldkit] Found more than one page-owning application stamped with \`${PH}\`. Hydrating multiple applications in one document is not supported: each application owns the document metadata and installs document-wide navigation listeners. Render one application per page.`)},BH=(e,t,n)=>{if(!ne(t)||t===``)return Error("[foldkit] Runtime.hydrate has no build id. Hydration compares the id the server stamped on the root with this client’s own before it adopts any DOM, and without one a page from any deployment would be adopted as this one. Build the client with @foldkit/vite-plugin, or pass the same nonempty `buildId` explicitly to `Runtime.hydrate` and `renderToString`.");let r=e.getAttribute(NH);if(r!==t)return Error(`[foldkit] Runtime.hydrate found application "${n}" served by ${r===null?`no known deployment`:`deployment "${r}"`}, but this client belongs to deployment "${t}". Startup stops here rather than reading a handoff written by other code: the Flags in the page are that deployment’s, and this build could accept them while every value in them means something else. Serve the page from the running deployment, and keep stale HTML out of shared caches.`)},VH=`data-foldkit-refused`,HH=`data-foldkit-refusal-shield`,UH=new WeakMap,WH=[`auxclick`,`click`,`contextmenu`,`dblclick`,`keydown`,`keypress`,`keyup`,`mousedown`,`mouseup`,`pointerdown`,`pointerup`,`touchend`,`touchstart`],GH=[`keydown`,`keypress`,`keyup`],KH=e=>{e.preventDefault(),e.stopImmediatePropagation()},qH=e=>{if(typeof e.showModal!=`function`)return!1;try{return e.showModal(),!0}catch{return!1}},JH=e=>{e.inert=!0,e.setAttribute(`inert`,``),e.open&&typeof e.close==`function`&&e.close(),qH(e)||e.setAttribute(`open`,``),e.inert=!1,e.removeAttribute(`inert`),e.focus({preventScroll:!0})},YH=e=>{let t=UH.get(e);if(t!==void 0&&t.isConnected){JH(t);return}let n=e.createElement(`dialog`);n.setAttribute(HH,``),n.setAttribute(`aria-label`,`Page unavailable`),n.setAttribute(`aria-modal`,`true`),n.setAttribute(`closedby`,`none`),n.tabIndex=-1,n.textContent=`This page could not start safely. Reload to get the current version.`,n.style.alignItems=`center`,n.style.background=`rgba(15, 23, 42, 0.96)`,n.style.border=`0`,n.style.boxSizing=`border-box`,n.style.color=`white`,n.style.font=`600 1rem/1.5 system-ui, sans-serif`,n.style.display=`grid`,n.style.height=`100vh`,n.style.inset=`0`,n.style.margin=`0`,n.style.maxHeight=`none`,n.style.maxWidth=`none`,n.style.overflow=`hidden`,n.style.padding=`2rem`,n.style.position=`fixed`,n.style.touchAction=`none`,n.style.userSelect=`none`,n.style.width=`100vw`,n.addEventListener(`cancel`,KH);for(let e of WH)n.addEventListener(e,KH,{capture:!0,passive:!1});for(let t of GH)e.addEventListener(t,KH,{capture:!0,passive:!1});e.documentElement.appendChild(n),UH.set(e,n),JH(n)},XH=e=>{let t=e.body??e.documentElement;t.inert=!0,t.setAttribute(`inert`,``),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(VH,``),YH(e)},ZH=e=>e.querySelector(`[${PH}], [${NH}], [${FH}]`)!==null,QH=(e,t)=>{let n=Li(document.querySelectorAll(`[${PH}]`));if(RH(n),zH(n),e!==null){let r=e.closest(`[${PH}]`);if(e.hasAttribute(`data-foldkit-app`)){if(!O(Xi(n),{onNone:()=>!1,onSome:t=>t===e}))throw XH(e.ownerDocument),Error(`[foldkit] Runtime.hydrate received a stamped container that is not the single server root in the document light DOM. Hydration supports one page-owning application under the document body. Do not hydrate a root in a shadow tree or detached subtree.`);return LH(e,t)}return Ri(n,{onEmpty:()=>{if(r!==null)throw XH(e.ownerDocument),Error(`[foldkit] Runtime.hydrate received a container under a stamped root outside the document body light DOM. Do not hydrate a root in a shadow tree, detached subtree, or another document.`)},onNonEmpty:n=>{let i=Zi(n);if(r===i)return LH(i,t);throw XH(e.ownerDocument),Error(`[foldkit] Runtime.hydrate received a container outside the document's server-rendered application root. A page-owning application must adopt that single root rather than boot beside server markup it does not own.`)}})}return O(Xi(n),{onNone:()=>void 0,onSome:e=>LH(e,t)})},$H=({bootMode:e,hydration:t,bootFlags:n,configuredFlags:r,isFlagsRequired:i,FlagsCodec:a,preservedModel:o,container:s,buildId:c,provideResources:l})=>P(function*(){let u=O(yr(br(n),()=>r),{onNone:()=>i?Yp(Error(`[foldkit] This application declares Flags. Pass its Flags Effect to Runtime.run or Runtime.embed.`)):j(void 0),onSome:l}),f=(e,t,n)=>(XH(e.ownerDocument),Yp(n===void 0?Error(t):Error(t,{cause:n}))),p=(e,t,n)=>Xp({try:()=>{let t=JSON.parse(e);return d(rT(a),UC,e=>e(t))},catch:e=>new IH({cause:e})}).pipe(om(e=>f(n,`[foldkit] Runtime.hydrate could not decode the server Flags payload for application "${t}". The HTML and client bundle must use the same Flags Schema.`,e))),m=e===`Hydrate`?br(t):w();if(e===`Hydrate`&&E(m))return XH(s===null?document:s.ownerDocument),yield*Yp(Error(`[foldkit] Runtime.hydrate could not find a server-rendered root stamped with \`${PH}\`. Use Runtime.run for a fresh client boot.`));if(D(m)){let e=BH(m.value.root,c,m.value.runtimeId);if(e!==void 0)return XH(m.value.root.ownerDocument),yield*Yp(e)}return{maybeHydrationRoot:ce(o)?wr(m,e=>e.root):w(),resolveFlags:O(yield*O(m,{onNone:()=>j(w()),onSome:e=>rm(e.isFlagsRequired?Ri(e.flagsScripts,{onEmpty:()=>f(e.root,`[foldkit] Runtime.hydrate found application "${e.runtimeId}" but its server Flags payload is missing.`),onNonEmpty:([t,...n])=>Ui(n)?f(e.root,`[foldkit] Runtime.hydrate found multiple server Flags payloads for application "${e.runtimeId}".`):p(t.textContent??``,e.runtimeId,e.root)}):j(void 0),T)}),{onNone:()=>u,onSome:j})}}),eU=(e,t)=>{let n=tU(e,t),r=nU(e,t),i=rU(e,t);return()=>{n(),r(),i()}},tU=(e,t)=>{let n=()=>{e(t.onUrlChange(aU()))};return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n)}},nU=(e,t)=>{let n=n=>{let r=n.button!==0,i=n.metaKey||n.ctrlKey||n.shiftKey||n.altKey,a=n.defaultPrevented;if(r||i||a)return;let o=n.target;if(!(o instanceof Element))return;let s=br(o.closest(`a`));if(E(s))return;let{value:c}=s,{href:l}=c;if(Dp(l))return;let u=!Dp(c.target)&&c.target!==`_self`,d=c.hasAttribute(`download`);if(u||d)return;n.preventDefault();let f=new URL(l),p=new URL(window.location.href);f.origin===p.origin?e(t.onUrlRequest(EH.Internal({url:iU(f)}))):e(t.onUrlRequest(EH.External({href:l})))};return document.addEventListener(`click`,n),()=>{document.removeEventListener(`click`,n)}},rU=(e,t)=>{let n=()=>{e(t.onUrlChange(aU()))};return window.addEventListener(`foldkit:urlchange`,n),()=>{window.removeEventListener(`foldkit:urlchange`,n)}},iU=e=>{let{protocol:t,hostname:n,port:r,pathname:i,search:a,hash:o}=e;return{protocol:t,host:n,port:_H(r),pathname:i,search:yH(`?`)(a),hash:yH(`#`)(o)}},aU=()=>iU(new URL(window.location.href)),oU=e=>typeof e!=`object`||!e||Object.isFrozen(e)?e:Vi(e)?(Object.freeze(e),e.forEach(oU),e):_r(e)?(D(e)&&oU(e.value),e):(sU(e)&&(Object.freeze(e),ji(e).forEach(oU)),e),sU=e=>{if(!ge(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},W=wC,cU=31,lU=100,uU={changedPaths:j_(),affectedPaths:j_()},dU=he,fU=(e,t)=>{let n=new Set,r=(e,t,r)=>{e!==t&&(!dU(t)||!dU(e)?n.add(r):Vi(t)&&Vi(e)?a(e,t,r):ge(t)&&ge(e)?i(e,t,r):n.add(r))},i=(e,t,i)=>{d(t,Ai,Ta(a=>{let o=`${i}.${a}`;Di(e,a)?r(e[a],t[a],o):n.add(o)})),d(e,Ai,Ta(e=>{Di(t,e)||n.add(`${i}.${e}`)}))},a=(e,t,i)=>{t.forEach((t,a)=>{let o=`${i}.${a}`;a<e.length?r(e[a],t,o):n.add(o)}),e.length>t.length&&d(Ii(t.length,e.length-1),Ta(e=>n.add(`${i}.${e}`)))};r(e,t,`root`);let o=new Set(n),s=e=>{d(e,cee(`.`),wr(t=>e.substring(0,t)),kr(e=>!o.has(e)),wr(e=>{o.add(e),s(e)}))};return n.forEach(s),{changedPaths:M_(n),affectedPaths:M_(o)}},pU={entries:[],keyframes:m_(),maybeInitModel:w(),initCommands:[],initMountStarts:[],startIndex:0,isPaused:!1,pausedAtIndex:0,maybeLatestModel:w()},mU=e=>Ri(e.entries,{onEmpty:()=>-1,onNonEmpty:t=>e.startIndex+t.length-1}),hU=e=>e.startIndex+e.entries.length,gU=(e,t={})=>P(function*(){let n=t.maxEntries??lU,r=t.keyframeInterval??cU,i=yield*cO(pU),a=(t,n)=>{let i=g_(t.keyframes,n+1);if(D(i))return i.value;let a=Math.floor(n/r)*r,o=__(t.keyframes,a)?a:t.startIndex;return d(t.keyframes,g_(o),wr(r=>d(t.entries,ra(o-t.startIndex),na(n-o+1),ba(r,(t,n)=>e.replay(t,n.message)))),Cr)},o=(e,t)=>n=>e%r===0?v_(n,e,t):n,s=e=>{let t=e.startIndex+r,n=e.pausedAtIndex>=t||e.pausedAtIndex===-1;return W(e,{entries:ra(r),keyframes:y_(e.startIndex),startIndex:()=>t,isPaused:e=>e&&n})},c=(e,t,n=[])=>pO(i,r=>W(r,{maybeInitModel:()=>T(e),initCommands:()=>t,initMountStarts:()=>n,keyframes:v_(0,e),maybeLatestModel:()=>T(e)})),l=(t,r,a,c,l)=>P(function*(){(yield*fO(i,e=>{let i=hU(e),u=l?fU(r,a):uU,d=N_(u.changedPaths)>0,f=W(e,{entries:zi({tag:t._tag,message:t,commands:c,mountStarts:[],mountEnds:[],timestamp:performance.now(),isModelChanged:d,diff:u}),keyframes:o(i+1,a),maybeLatestModel:()=>T(a)}),p=f.entries.length>n?s(f):f;return[e.isPaused&&!p.isPaused,p]}))&&(yield*e.markRenderPending)}),u=(e,t)=>pO(i,n=>{let r=n=>d(n,aa(t=>t.id===e),Tr(e=>sa(n,e,e=>W(e,{maybeSubmodelPath:()=>T(t)})))),i=r(n.initCommands);if(D(i))return W(n,{initCommands:()=>i.value});let a=aa(n.entries,t=>Sa(t.commands,t=>t.id===e));return E(a)?n:O(sa(n.entries,a.value,e=>O(r(e.commands),{onNone:()=>e,onSome:t=>W(e,{commands:()=>t})})),{onNone:()=>n,onSome:e=>W(n,{entries:()=>e})})}),f=(e,t)=>pO(i,n=>Hi(e)&&Hi(t)?n:Ri(n.entries,{onEmpty:()=>W(n,{initMountStarts:Bi(e)}),onNonEmpty:r=>W(n,{entries:()=>da(r,n=>W(n,{mountStarts:Bi(e),mountEnds:Bi(t)}))})})),p=(e,t)=>BD(t).pipe(HD(-1,()=>Cr(e.maybeInitModel)),HD(mU(e),()=>Cr(e.maybeLatestModel)),GD(()=>a(e,t)));return{recordInit:c,recordMessage:l,recordResolvedCommand:u,updateLatestModel:e=>pO(i,W({maybeLatestModel:()=>T(e)})),attachRenderedMounts:f,getModelAtIndex:e=>d(i,uO,rm(t=>p(t,e))),getMessageAtIndex:e=>P(function*(){if(e===-1)return w();let t=yield*uO(i);return d(t.entries,qi(e-t.startIndex),wr(({message:e})=>e))}),getDiffAtIndex:e=>P(function*(){if(e===-1)return uU;let t=yield*uO(i);return d(t.entries,qi(e-t.startIndex),O({onNone:()=>uU,onSome:({diff:e})=>e}))}),jumpTo:t=>P(function*(){let n=yield*uO(i),r=p(n,t);return yield*e.render(r),(yield*fO(i,e=>t===-1||t>=e.startIndex&&t<=mU(e)?[!1,W(e,{isPaused:()=>!0,pausedAtIndex:()=>t})]:[!0,W(e,{isPaused:()=>!1})]))&&(yield*e.markRenderPending),r}),resume:P(function*(){yield*pO(i,e=>W(e,{isPaused:()=>!1})),yield*e.markRenderPending}),clear:pO(i,e=>e.isPaused?e:W(e,{entries:()=>[],startIndex:()=>0,pausedAtIndex:()=>0,keyframes:()=>O(e.maybeInitModel,{onNone:()=>m_(),onSome:e=>h_([0,e])}),maybeLatestModel:()=>e.maybeInitModel})),stateRef:i}}),_U=/^Got.+Message$/,vU=RC(z({_tag:L})),yU=(e,t)=>{if(!_U.test(e))return{submodelPath:[],maybeLeafTag:w()};let n=[e],r=t?.message;for(;vU(r)&&_U.test(r._tag);)n.push(r._tag),r=r?.message;return{submodelPath:n,maybeLeafTag:d(r,Ar(vU),wr(({_tag:e})=>e))}},bU=(e,t)=>BD(e).pipe(HD(`Always`,()=>!0),HD(`Development`,()=>t),KD),xU,SU=`Development`,CU=`BottomRight`,wU=`TimeTravel`,TU=e=>typeof e==`string`?e:e.production,EU=20,DU=500,OU=1,kU=e=>(window.self,window.top,d(e??{},Ar(e=>e!==!1),kr(e=>bU(e.show??SU,!1)),wr(e=>({position:e.position??CU,mode:TU(e.mode??wU),maybeBanner:br(e.banner),maybeOverlay:br(xU)})))),AU=e=>d(e??{},Ar(e=>e!==!1),Er(e=>e.excludeFromHistory),O({onNone:()=>new Set,onSome:e=>new Set(e)})),jU=e=>d(e??{},Ar(e=>e!==!1),Er(e=>e.maxEntries),O({onNone:()=>void 0,onSome:e=>Math.max(EU,Math.min(DU,e))})),MU=e=>d(e??{},Ar(e=>e!==!1),Er(e=>e.keyframeInterval),O({onNone:()=>void 0,onSome:e=>Math.max(OU,Math.floor(e))})),NU=({id:e,command:t})=>t.args===void 0?{id:e,name:t.name,maybeSubmodelPath:w()}:{id:e,name:t.name,args:t.args,maybeSubmodelPath:w()},PU=({devTools:e,update:t,maybeFreezeModel:n,enqueueMessageEffect:r})=>P(function*(){let r=kU(e),i=AU(e),a=jU(e),o=MU(e),s=`Live`,c=D(r)?T(yield*mT({replay:1})):w(),l=O(c,{onNone:()=>xk,onSome:e=>(gT(e,s),QE(e))}),u=e=>{e!==s&&(s=e,D(c)&&gT(c.value,e))},d=()=>s,f=null,p=vk.of({captureViewStateChanges:()=>cD(KE(s),l).pipe(pD)}),m=()=>f!==null&&lO(f.stateRef).isPaused,h=[],g=[],_={started:(e,t)=>{f!==null&&h.push(t===void 0?{name:e}:{name:e,args:t})},ended:(e,t)=>{f!==null&&g.push(t===void 0?{name:e}:{name:e,args:t})}},v=()=>{let e=h.slice(),t=g.slice();return h.length=0,g.length=0,{starts:e,ends:t}},y=({renderReplay:e,markRenderPending:s})=>O(r,{onNone:()=>N,onSome:({position:r,mode:c,maybeBanner:l,maybeOverlay:u})=>P(function*(){let d=i.size>0,p=yield*gU({replay:(e,r)=>n(t(e,r).model),render:e,markRenderPending:s},{...o!==void 0&&{keyframeInterval:o},...a!==void 0&&{maxEntries:a},...d&&{keyframeInterval:1}});f=p,yield*O(u,{onNone:()=>N,onSome:e=>e(p,r,c,l)})})}),ee=(e,t)=>P(function*(){let n=v();f!==null&&(yield*f.recordInit(e,ga(t,NU),n.starts))}),te=()=>{if(f!==null){let e=v();qm(f.attachRenderedMounts(e.starts,e.ends))}},ne=(e,t,n,r)=>{if(f!==null){let a=f,o=e._tag,s=t!==n;i.has(o)?s&&qm(a.updateLatestModel(n)):qm(a.recordMessage(e,t,n,ga(r,NU),s))}},re=(e,t)=>{if(f===null)return;let n=vU(t)?yU(t._tag,t).submodelPath:[];qm(f.recordResolvedCommand(e,n))},ie=Up(()=>f===null?N:f.resume);return{isRecordingCommands:D(r),mountTracker:_,mountRuntime:p,drainMountEvents:v,readViewState:d,setViewState:u,isPausedNow:m,installDevToolsStore:y,resumeDevTools:ie,recordInit:ee,recordMessage:ne,recordCommandResult:re,attachRenderedMounts:te}}),FU=(e,t)=>{let n=new Map;Object.values(e.inbound??{}).forEach(e=>{n.set(e,jH())});let r=new Set(Object.values(e.outbound??{}));return{channels:{isConfigured:!0,lookupInbound:e=>br(n.get(e)),lookupOutbound:e=>r.has(e)?T(n=>O(t,{onNone:u,onSome:t=>t.deliverOutbound(e,n)})):w()},deliverInbound:(e,t)=>{O(br(n.get(e)),{onNone:u,onSome:e=>e.deliver(t)})}}},IU=e=>{let t=Object.entries(e.inbound??{}),n=Object.entries(e.outbound??{}),r=new Set(t.map(([e])=>e));n.forEach(([e])=>{if(r.has(e))throw Error(`[foldkit] Port name "${e}" appears in both inbound and outbound. Port names share one namespace on the EmbedHandle, so each name must be unique across both records.`)});let i=new Set;[...t,...n].forEach(([e,t])=>{if(i.has(t))throw Error(`[foldkit] The Port registered as "${e}" is also registered under another name. Each entry in the ports record needs its own Port.inbound or Port.outbound value.`);i.add(t)})},LU=({managedResourceRefs:e,initModel:t,modelPubSub:n,runtimeScope:r,enqueueMessageEffect:i,crashWith:a})=>{let o=(e,t)=>n=>{if(_r(n)&&E(n))return WE;let r=_r(n)?Cr(n):n;return d(rD(BE(Dm(P(function*(){let n=yield*e.acquire(r);return yield*ZD(t,T(n)),n}),n=>P(function*(){yield*e.release(n).pipe(sm(()=>N)),yield*ZD(t,w()),yield*i(e.onReleased())})))),oD(t=>cD(KE(e.onAcquired(t)),tD)),iD(j),fD(t=>KE(j(e.onAcquireError(t)))))};return Rp(e,({config:e,ref:s})=>P(function*(){let c=yield*_T(n).pipe(wm(Of,r)),l=cD(KE(t),eD(c)),u=nT(e.schema);yield*Gm(r)(l.pipe(iD(e.modelToMaybeRequirements),mD(u),sD(o(e,s)),vD(F(i)),sm(e=>a(e,w()))))}),{concurrency:`unbounded`,discard:!0})},RU=5,zU=({status:e,processMessage:t,crashWith:n})=>P(function*(){let r=[],i=!1,a=!1,o=t=>{e.isRuntimeDisposed||e.isCrashed||(r.push(t),a&&!e.isRenderingFrame&&m())},s=e=>M(()=>o(e)),c=w(),l=0,u=0,d=!1,f=null,p=()=>{f===null&&(f=new MessageChannel,f.port2.onmessage=()=>{d=!1,l=0,m()}),d=!0,f.port1.postMessage(null)};yield*Om(()=>M(()=>{f!==null&&(f.port1.close(),f.port2.close(),f=null)}));let m=()=>{if(!a||i||e.isRenderingFrame||d||e.isRuntimeDisposed||e.isCrashed)return;let o=performance.now();if(o-u>RU&&(l=0),l>RU)p();else{i=!0;try{for(;r.length>0;){let e=r;r=[];for(let n=0;n<e.length;n++){let i=e[n];if(c=T(i),t(i),(n+1<e.length||r.length>0)&&l+(performance.now()-o)>RU){r=e.slice(n+1).concat(r),p();return}}}}catch(e){qm(n(Gd(e),c))}finally{let e=performance.now();l+=e-o,u=e,i=!1}}};return{enqueueMessage:o,enqueueMessageEffect:s,drainPendingMessages:m,resetDrainBudget:()=>{l=0},isAnyMessageDeferred:()=>d&&r.length>0,completeBoot:()=>{a=!0,m()}}}),BU=z({id:L,model:tw,isReloadFlush:ZC(iw)}),VU=z({id:L}),HU=z({id:L,model:ZC(tw)});qC(BU),qC(VU),BC(HU);var UU=e=>j(void 0),WU=(e,t)=>P(function*(){let n=yield*Tm,r=yield*YD(w()),i=yield*YD(w()),a=P(function*(){yield*O(yield*XD(i),{onNone:()=>N,onSome:ah}),yield*ZD(i,w())}),o=e=>P(function*(){yield*O(yield*QD(r,w()),{onNone:()=>N,onSome:e})});return{schedule:s=>P(function*(){yield*ZD(r,T(s)),yield*a;let c=yield*Gm(P(function*(){yield*hm(t),yield*o(e.onDebounce)}),n);yield*ZD(i,T(c))}),flush:o(e.onFlush),cancel:P(function*(){yield*a,yield*ZD(r,w())})}}),GU=`data-foldkit-key`,KU=`data-foldkit-identity`,qU=16777619,JU=2166136261,YU=1099511628,XU=e=>{let t=JU,n=YU;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r),a=i&255,o=i>>>8;t=Math.imul(t^a,qU),t=Math.imul(t^o,qU),n=Math.imul(n^o,qU),n=Math.imul(n^a,qU)}return(t>>>0).toString(16).padStart(8,`0`)+(n>>>0).toString(16).padStart(8,`0`)},ZU=e=>{if(typeof e==`string`)return XU(`s:${e}`);if(typeof e==`number`)return Number.isNaN(e)?void 0:XU(`n:${e}`)},QU=e=>XU(`i:${e}`),$U=`http://www.w3.org/1999/xhtml`,eW=`data-foldkit-app`,tW=e=>{let t={};for(let n of Array.from(e.classList))t[n]=!0;return t},nW=e=>{let t={};if(`style`in e&&e.style instanceof CSSStyleDeclaration){let n=e.style;for(let e=0;e<n.length;e+=1){let r=n.item(e),i=n.getPropertyValue(r),a=n.getPropertyPriority(r);t[r]=a===``?i:`${i} !${a}`}}return t},rW=(e,t,n,r)=>{if(!n)return{};if(!r)return tW(e);let i={};for(let n of Object.keys(t.data?.class??{}))i[n]=e.classList.contains(n);return i},iW=(e,t,n,r)=>{if(!n)return{};let i=t.data?.style??{},a=Object.fromEntries(Object.entries(i).flatMap(([e,t])=>typeof t==`string`?[[qO(e),t]]:[])),o=Reflect.get(e,`style`);if(!(o instanceof CSSStyleDeclaration))return{};let s=r?{}:nW(e),c=e.ownerDocument.createElement(`span`).style,l=new Set;for(let[t,n]of Object.entries(a)){c.setProperty(t,n);let r=e.ownerDocument.createElement(`span`).style;r.setProperty(t,n),l.add(t);for(let e=0;e<r.length;e+=1)l.add(r.item(e))}for(let e of l)delete s[e];return Object.keys(a).every(e=>o.getPropertyValue(e)===c.getPropertyValue(e)&&o.getPropertyPriority(e)===c.getPropertyPriority(e))&&Object.assign(s,a),s},aW=e=>{let t=e.ownerDocument.implementation.createHTMLDocument(),n=t.createElement(`base`);return n.href=e.ownerDocument.baseURI,t.head.appendChild(n),e.namespaceURI===null||e.namespaceURI===$U?t.createElement(e.localName):t.createElementNS(e.namespaceURI,e.localName)},oW=e=>{let t=e.data?.props;return t===void 0?[]:Object.keys(t).filter(e=>!rk(t,e)&&AO(e)!==void 0)},sW=(e,t,n)=>TO.has(t)?n===!0?``:null:n===!1?t===`draggable`?`false`:String(n):t===`draggable`?n===!0?`true`:`false`:RO(e,t,n),cW=(e,t)=>{let n=e.localName;return t===`value`&&(n===`input`||n===`textarea`||n===`output`||n===`select`)||t===`checked`&&n===`input`||t===`selected`&&n===`option`||t===`muted`&&(n===`audio`||n===`video`)},lW=Symbol(`foldkit/stale-reflected-property`),uW=-1,dW=(e,t,n)=>{let r=t.data?.props,i=r?.value;if(!(e instanceof HTMLSelectElement)||typeof i!=`string`||rk(r,`value`))return;let a=Array.from(e.options),o=a.find(e=>e.value===i);for(let e of a)n.controlledOptionSelection.set(e,e===o);n.controlledSelectState.set(e,{selectedIndex:o?.index??uW,value:o?.value??``})},fW=(e,t)=>{let n=t.controlledSelectState.get(e);n!==void 0&&(Reflect.get(e,`value`)!==n.value||Reflect.get(e,`selectedIndex`)!==n.selectedIndex)&&hW(t);let r=t.controlledOptionSelection.get(e);r!==void 0&&(Reflect.get(e,`selected`)!==r||Reflect.get(e,`defaultSelected`)!==r)&&hW(t)},pW=(e,t,n,r,i)=>{let a=t.data?.props;if(a===void 0||n.length===0)return{};let o={};for(let t of n){let n=a[t],s=AO(t);s!==void 0&&(t===`value`&&i.controlledSelectState.has(e)||t===`selected`&&i.controlledOptionSelection.has(e)||(!r&&cW(e,t)?Object.is(Reflect.get(e,t),n):e.getAttribute(s)===sW(e.localName,t,n))?o[t]=n:(o[t]=lW,hW(i)))}return o},mW=(e,t,n,r,i)=>{fW(e,r);let a=t.data?.class!==void 0&&YO(t.data?.attrs,`class`)===void 0,o=t.data?.style!==void 0&&YO(t.data?.attrs,`style`)===void 0,s=oW(t),c=new Set(s.flatMap(t=>{let n=AO(t);return n===void 0?[]:[PO(e.namespaceURI,n)]})),l=new Map(Object.keys(t.data?.dataset??{}).map(e=>[`data-${e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`,e])),u=i?new Set(Object.keys(t.data?.attrs??{}).map(e=>e.toLowerCase())):void 0,d={};for(let t of Array.from(e.attributes)){let e=t.name;e!==eW&&(e===`class`&&a||e===`style`&&o||c.has(e)||l.has(e)||(u===void 0||u.has(e.toLowerCase()))&&(d[e]=t.value))}let f=rW(e,t,a,i),p=iW(e,t,o,i),m=pW(e,t,s,i,r),h={};for(let[t,n]of l){let r=e.getAttribute(t);r!==null&&(h[n]=r)}n.data={...n.data,...Object.keys(d).length>0?{attrs:d}:{},...Object.keys(f).length>0?{class:f}:{},...Object.keys(p).length>0?{style:p}:{},...Object.keys(m).length>0?{props:{...n.data?.props,...m}}:{},...Object.keys(h).length>0?{dataset:h}:{}}},hW=e=>{e.isMismatchDetected=!0},gW=e=>e.nodeType===Node.TEXT_NODE,_W=e=>e.nodeType===Node.COMMENT_NODE,vW=e=>e.nodeType===Node.ELEMENT_NODE,yW=e=>{let t=e.firstChild;return t===null||t.nextSibling===null&&gW(t)},bW=(e,t)=>{let n=ik(t.sel??``),r=t.data?.ns===void 0?n.toLowerCase():n;return e.localName===r},xW=e=>typeof e.data?.ns==`string`?e.data.ns:$U,SW=(e,t)=>(e.namespaceURI??$U)===xW(t),CW=(e,t)=>{let n=e.getAttribute(GU);if(t.key===void 0)return n===null;let r=ZU(t.key);return r!==void 0&&n===r},wW=(e,t)=>CW(e,t)?e.getAttribute(KU)===(t.identity===void 0?null:QU(t.identity)):!1,TW=(e,t)=>{let n={sel:e.sel,data:e.data?.is===void 0?{}:{is:e.data.is},children:void 0,elm:t,text:void 0,key:e.key};return e.identity!==void 0&&(n.identity=e.identity),n},EW=e=>(e.namespaceURI===null||e.namespaceURI===$U)&&e.localName.includes(`-`),DW=e=>e.text!==void 0||e.children!==void 0&&e.children.length>0||nk(e.data?.props),OW=(e,t)=>EW(e)&&DW(t),kW=(e,t)=>{let n=e.children;if(n!==void 0)for(let e of n)typeof e!=`string`&&kW(e,t);let r=e.data?.hook?.insert;r!==void 0&&t.push({vnode:e,insert:r})},AW=(e,t)=>{let n=[];kW(e,n);for(let{vnode:e}of n){let t=e.data?.hook;t!==void 0&&delete t.insert}try{return t()}finally{for(let{vnode:e,insert:t}of n){let n=e.data?.hook;n!==void 0&&(n.insert=t)}}},jW=(e,t)=>{let n=e.ownerDocument,r=e.parentNode??n.createDocumentFragment();e.parentNode===null&&r.appendChild(e);let i=n.createComment(``);return r.replaceChild(i,e),AW(t,()=>pM(tj(i),t))},MW=e=>typeof e==`string`?{sel:void 0,data:void 0,children:void 0,elm:void 0,text:e,key:void 0}:e,NW=e=>{let t=e.elm;if(t===void 0)throw Error(`[foldkit] A prepared hydration vnode has no DOM node.`);let n=TW(e,t);n.data={...n.data,...e.data?.on===void 0?{}:{on:e.data.on},...e.data?.props===void 0?{}:{props:e.data.props}},n.text=e.text;let r=e.children;if(r!==void 0){let e=[],i=t.firstChild;for(let t of r){let n=MW(t);n.elm===void 0&&(n.elm=i??void 0),e.push(NW(n)),i=n.elm?.nextSibling??null}n.children=e}return n},PW=e=>{e.textContent=``},FW=(e,t,n)=>{if(t!==null&&gW(t)){let e=t.data;return e===n?T({adoptedNode:t,nextDomChild:t.nextSibling}):e.startsWith(n)?(t.splitText(n.length),T({adoptedNode:t,nextDomChild:t.nextSibling})):w()}if(n===``){let n=e.ownerDocument.createTextNode(``);return e.insertBefore(n,t),T({adoptedNode:n,nextDomChild:t})}return w()},IW=(e,t,n)=>{if(OW(e,t))return NW(jW(e,t));let r=TW(t,e);dW(e,t,n),e.removeAttribute(GU),e.removeAttribute(KU);let i=EW(e),a=()=>i?(mW(e,t,r,n,!0),AW(t,()=>pM(r,t)),NW(t)):r;if((e.tagName===`TEXTAREA`||e.tagName===`OUTPUT`)&&t.data?.props?.value!==void 0)return r.children=[],a();let o=t.data?.props?.innerHTML,s=o!==void 0&&nk(t.data?.props),c=t.children;if(s){if(typeof o==`string`){let t=aW(e);oM(t,o);let i=aM(e);aM(t)!==i&&(hW(n),oM(e,o));let a={...r.data?.props,innerHTML:o};$O(a,a.innerHTML),r.data={...r.data,props:a}}else{let t={...r.data?.props,innerHTML:aM(e)};$O(t,t.innerHTML),r.data={...r.data,props:t}}return r.children=[],a()}if(c===void 0||c.length===0)return t.text===void 0?!i&&e.firstChild!==null&&(hW(n),PW(e),r.children=[]):yW(e)?(r.text=e.textContent??``,r.text!==t.text&&hW(n)):hW(n),a();let l=[],u=e.firstChild;for(let t of c){let i=MW(t);if(i.sel===void 0||i.sel===``){let t=i.text??``,o=FW(e,u,t);if(E(o)){if(hW(n),u===null)break;return PW(e),r.children=[],a()}let s=o.value,c=TW(i,s.adoptedNode);c.text=t,l.push(c),u=s.nextDomChild;continue}if(u===null){hW(n);break}if(i.sel===`!`){if(!_W(u))return hW(n),PW(e),r.children=[],a();let t=TW(i,u);t.text=u.data,l.push(t),u=u.nextSibling;continue}if(!vW(u)||!bW(u,i)||!SW(u,i)||!wW(u,i))return hW(n),PW(e),r.children=[],a();let o=u.nextSibling;l.push(IW(u,i,n)),u=o}for(;u!==null;){hW(n);let t=u.nextSibling;e.removeChild(u),u=t}return r.children=l,a()},LW=(e,t,n)=>{let r=e.elm;r!==void 0&&vW(r)?(mW(r,t,e,n,EW(r)),t.text!==void 0&&(e.text=yW(r)?r.textContent??``:void 0)):r!==void 0&&(gW(r)||_W(r))&&(e.text=r.data);let i=e.children,a=t.children;if(i===void 0||a===void 0)return;let o=a.values();for(let e of i){let t=o.next();if(t.done)return;LW(MW(e),MW(t.value),n)}},RW=(e,t)=>{let n=[];kW(t,n);for(let{vnode:e}of n){let t=e.data?.hook;t!==void 0&&delete t.insert}let r;try{r=pM(e,t)}finally{for(let{vnode:e,insert:t}of n){let n=e.data?.hook;n!==void 0&&(n.insert=t)}}for(let{vnode:e,insert:t}of n)t(e);return r},zW=(e,t)=>{let n=e.ownerDocument,r=e.parentNode??n.createDocumentFragment();e.parentNode===null&&r.appendChild(e);let i=n.createComment(``);return r.replaceChild(i,e),pM(tj(i),t)},BW=(e,t,n,r)=>{let i=t===null?fA(`!`):_M(t,n),a={isMismatchDetected:!1,adoptedSignatures:new Map,controlledOptionSelection:new Map,controlledSelectState:new Map},o=e.getAttribute(NH),s=r!==``&&o===r;if(e.removeAttribute(NH),!s||i.sel===void 0||i.sel===``||i.sel===`!`||!bW(e,i)||!SW(e,i)||!wW(e,i))return hW(a),zW(e,i);if(OW(e,i))return zW(e,i);let c=IW(e,i,a);return LW(c,i,a),RW(c,i)},VW={field:`canonical`,tagName:`link`,identityAttribute:`rel`,identityValue:`canonical`,valueAttribute:`href`},HW={field:`ogUrl`,tagName:`meta`,identityAttribute:`property`,identityValue:`og:url`,valueAttribute:`content`},UW=new WeakMap,WW=e=>{let t=document.head;return e.observe(t,{attributes:!0,attributeFilter:[`rel`,`href`,`property`,`content`],childList:!0,characterData:!0,subtree:!0}),e.observe(document.documentElement,{attributes:!0,attributeFilter:[`lang`,`dir`]}),t},GW=()=>{let e=UW.get(document);if(e!==void 0)return e;let t={isInvalidated:!0},n=new MutationObserver(()=>{t.isInvalidated=!0}),r={elements:{},observer:n,invalidation:t,observedHead:WW(n)};return UW.set(document,r),r},KW=(e,t)=>{let{elements:n}=e,r=n[t.field];if(r!==void 0&&r.element.parentNode===document.head)return r.element;let i=document.head.querySelector(`${t.tagName}[${t.identityAttribute}="${t.identityValue}"]`);if(i!==null)return n[t.field]={_tag:`Found`,element:i,servedValue:i.getAttribute(t.valueAttribute)??void 0},i;let a=document.head.appendChild(document.createElement(t.tagName));return n[t.field]={_tag:`Created`,element:a},a},qW=(e,t)=>{let n=e.elements[t.field];if(n===void 0||n.element.parentNode!==document.head)return;if(n._tag===`Created`){n.element.remove();return}let{valueAttribute:r}=t;n.servedValue===void 0?n.element.removeAttribute(r):n.element.getAttribute(r)!==n.servedValue&&n.element.setAttribute(r,n.servedValue)},JW=(e,t,n)=>{if(n===void 0){qW(e,t),delete e.elements[t.field];return}let r=KW(e,t);r.getAttribute(t.identityAttribute)!==t.identityValue&&r.setAttribute(t.identityAttribute,t.identityValue),r.getAttribute(t.valueAttribute)!==n&&r.setAttribute(t.valueAttribute,n)},YW=e=>{e.observer.disconnect(),e.observedHead=WW(e.observer),e.invalidation.isInvalidated=!0},XW=(e,t)=>{document.title!==t.title&&(document.title=t.title);let{documentElement:n}=document;t.lang!==void 0&&n.lang!==t.lang&&(n.lang=t.lang),t.dirAttribute!==void 0&&n.dir!==t.dirAttribute&&(n.dir=t.dirAttribute),JW(e,VW,t.canonical),JW(e,HW,t.ogUrl),e.lastApplied=t,e.invalidation.isInvalidated=!1,e.observer.takeRecords()},ZW=(e,t)=>{if(!t||!document.body.contains(t))return;let n=GW();n.observedHead!==document.head&&YW(n);let r=e.ogUrl??e.canonical,i=e.dir===void 0?void 0:VM(e.dir);Ui(n.observer.takeRecords())&&(n.invalidation.isInvalidated=!0);let a=n.lastApplied;(n.invalidation.isInvalidated||a===void 0||a.title!==e.title||a.lang!==e.lang||a.dirAttribute!==i||a.canonical!==e.canonical||a.ogUrl!==r)&&XW(n,{title:e.title,lang:e.lang,dirAttribute:i,canonical:e.canonical,ogUrl:r})},QW={dispatchAsync:e=>N,dispatchSync:e=>{}},$W={bg:`#f9fafb`,cardBg:`#ffffff`,border:`#e5e7eb`,errorAccent:`#dc2626`,textPrimary:`#111827`,textSecondary:`#6b7280`,codeBg:`#f3f4f6`,buttonBg:`#18181b`,buttonText:`#ffffff`},eG=`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,tG=`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace`,nG=(e,t)=>{let n=UR.Style({fontFamily:tG,color:$W.textPrimary,margin:`0`,fontSize:`0.9375rem`,lineHeight:`1.5`,backgroundColor:$W.codeBg,padding:`0.75rem 1rem`,borderRadius:`0.375rem`}),r=UR.Style({color:$W.textSecondary,margin:`0 0 0.5rem 0`,fontSize:`0.875rem`,fontWeight:`500`}),i=UR.Style({fontFamily:tG,backgroundColor:$W.codeBg,padding:`0.125rem 0.375rem`,borderRadius:`0.25rem`}),a=t instanceof Error?t.message:String(t),o=t?[`Your custom `,UR.span([i],[`crash.view`]),` threw an error while rendering.`]:[`Foldkit encountered an unrecoverable error while running your application.`],s=t?[UR.div([UR.Style({margin:`0 0 1rem 0`})],[UR.p([r],[`Original error`]),UR.p([n],[e.error.message])]),UR.div([UR.Style({margin:`0 0 1.25rem 0`})],[UR.p([r],[`crash.view error`]),UR.p([n],[a])])]:[UR.p([UR.Style({fontFamily:tG,color:$W.textPrimary,margin:`0 0 1.25rem 0`,fontSize:`0.9375rem`,lineHeight:`1.5`,backgroundColor:$W.codeBg,padding:`0.75rem 1rem`,borderRadius:`0.375rem`})],[e.error.message])],c=t?[]:[UR.p([UR.Style({color:$W.textSecondary,margin:`1.5rem 0 0 0`,fontSize:`0.875rem`,lineHeight:`1.5`,borderTop:`1px solid ${$W.border}`,paddingTop:`1rem`})],[`This is the default crash view. You can customize it by providing a `,UR.span([i],[`crash.view`]),` function.`])];return{title:`Application Crash`,body:UR.div([UR.Style({fontFamily:eG,padding:`2rem`,minHeight:`100vh`,backgroundColor:$W.bg,display:`flex`,alignItems:`center`,justifyContent:`center`})],[UR.div([UR.Style({width:`100%`,maxWidth:`960px`,margin:`0 auto`,backgroundColor:$W.cardBg,borderRadius:`0 0.5rem 0.5rem 0`,border:`1px solid ${$W.border}`,borderLeft:`4px solid ${$W.errorAccent}`,padding:`1.5rem`})],[UR.h1([UR.Style({color:$W.errorAccent,margin:`0 0 0.75rem 0`,fontSize:`1.25rem`,fontWeight:`600`,lineHeight:`1.5`})],[`Application Crash`]),UR.p([UR.Style({color:$W.textPrimary,margin:`0 0 1rem 0`,fontSize:`1rem`,lineHeight:`1.625`})],o),...s,UR.p([UR.Style({color:$W.textPrimary,margin:`0 0 1.5rem 0`,fontSize:`1rem`,lineHeight:`1.5`})],[`→ Check the browser console for the full stack trace with source-mapped line numbers.`]),UR.button([UR.Style({fontFamily:eG,backgroundColor:$W.buttonBg,color:$W.buttonText,border:`none`,padding:`0.5rem 1rem`,borderRadius:`0.375rem`,fontSize:`0.875rem`,fontWeight:`500`,cursor:`pointer`}),UR.Attribute(`onclick`,`location.reload()`)],[`Reload`]),...c])])}},rG=(e,t,n,r,i)=>{if(console.error(`[foldkit] Application crash:`,e.error),t?.report)try{t.report(e)}catch(e){console.error(`[foldkit] crash.report failed:`,e)}let a=Qr(MH,QW).pipe($r(gk,{started:()=>{},ended:()=>{}}));try{OM(QW.dispatchSync,a);let o;try{o=t?.view?t.view(e,HR()):nG(e)}finally{kM()}let s=yM(r.maybeCurrentVNode,o.body,n);r.maybeCurrentVNode=T(s),i&&ZW(o,s.elm)}catch(t){console.error(`[foldkit] crash.view failed:`,t);let o=t instanceof Error?t:Error(String(t));OM(QW.dispatchSync,a);let s;try{s=nG(e,o)}finally{kM()}let c=yM(r.maybeCurrentVNode,s.body,n);r.maybeCurrentVNode=T(c),i&&ZW(s,c.elm)}};dw([`Update`,`View`,`Patch`,`SubscriptionDependencies`]);var iG=`Development`,aG=16,oG=4,sG=8,cG=2,lG=[`Update`,`View`,`Patch`,`SubscriptionDependencies`],uG=(e,t,n)=>Ar({thresholdMs:t,onSlow:n},()=>e),dG=(e,t)=>d(BD(e).pipe(VD(),HD(!1,()=>w()),HD(ce,()=>T({})),GD(e=>T(e))),kr(e=>t(e.show??iG)),wr(e=>{let t=e.onSlow??_G,n=e.measuredPhases??lG,r=e=>fa(n,e);return{view:uG(r(`View`),e.thresholdOverrides?.View??aG,t),update:uG(r(`Update`),e.thresholdOverrides?.Update??oG,t),patch:uG(r(`Patch`),e.thresholdOverrides?.Patch??sG,t),subscriptionDependencies:uG(r(`SubscriptionDependencies`),e.thresholdOverrides?.SubscriptionDependencies??cG,t)}})),fG=(e,t)=>{if(D(e)){let e=performance.now();return[t(),T(performance.now()-e)]}return[t(),w()]},pG=(e,t,n)=>{if(D(e)){let{thresholdMs:r,onSlow:i}=e.value,a=kr(t,e=>e>r);D(a)&&i(n(a.value,r))}},mG=e=>d(e,Ar(ge),Tr(Oi(`_tag`)),O({onNone:()=>`unknown`,onSome:String})),hG=e=>O(e,{onNone:()=>`init`,onSome:mG}),gG=`Set slow.thresholdOverrides to change budgets or pass slow: false to disable warnings.`,_G=e=>{let{durationMs:t,thresholdMs:n}=e,r=t.toFixed(1),i=BD(e).pipe(WD({View:({message:e})=>`Slow view: ${r}ms (budget: ${n}ms), triggered by ${hG(e)}. Keep render-only work in the view path and memoize expensive subtrees with createLazy or createKeyedLazy.`,Update:({message:e})=>`Slow update: ${r}ms (budget: ${n}ms), triggered by ${mG(e)}. Inspect the triggering Message branch; move render-only derivations to memoized views and keep update focused on state transitions.`,Patch:({message:e})=>`Slow patch: ${r}ms (budget: ${n}ms), triggered by ${hG(e)}. Key mapped lists by stable ids, split large views, or memoize stable subtrees with createLazy.`,SubscriptionDependencies:({subscriptionKey:e})=>`Slow subscription dependencies: ${r}ms (budget: ${n}ms) for subscription "${e}". Keep modelToDependencies a cheap projection from modeled fields; avoid scans, sorting, serialization, and large dependency objects.`})),a=BD(e).pipe(VD(),WD({Update:({message:e})=>T(e),View:({message:e})=>e,Patch:({message:e})=>e,SubscriptionDependencies:()=>w()}));console.warn(`[foldkit] ${i} ${gG}`,e,...Or(a))},vG=e=>{let t=()=>{};e.ready?.catch(t),e.finished?.catch(t),e.updateCallbackDone.catch(t)},yG=()=>{if(typeof document.startViewTransition!=`function`)return w();let e=typeof ViewTransition<`u`&&`types`in ViewTransition.prototype;return T((t,n)=>d(n,kr(()=>e),O({onNone:()=>document.startViewTransition(t),onSome:e=>document.startViewTransition({update:t,types:[...e]})})))},bG=(e,t)=>BD(e(t)).pipe(VD(),HD(!1,()=>w()),HD(!0,()=>T({maybeTypes:w()})),GD(({types:e})=>T({maybeTypes:T(e)}))),xG=({status:e,container:t,view:n,htmlBuilder:r,manageDocument:i,crash:a,buildId:o,initModel:s,maybeHydrationRoot:c,maybeSlowView:l,maybeSlowPatch:u,duplicateIdScanner:d,maybeResolvedViewTransition:f,commitNotifier:p,runtimeContext:m,readLiveModel:h,messageQueue:g,devToolsIntegration:_})=>P(function*(){let{enqueueMessage:d,enqueueMessageEffect:v,drainPendingMessages:y,resetDrainBudget:ee,isAnyMessageDeferred:te}=g,{mountTracker:ne,mountRuntime:re,drainMountEvents:ie,readViewState:ae,setViewState:oe,isPausedNow:se,resumeDevTools:ce,attachRenderedMounts:le}=_,ue=()=>{p.service.isCommitPending()&&p.notifyCommitted()},de=!1,fe=!1,pe=s,me=w(),he=()=>{if(D(me)){let{value:e}=me;me=w(),e.update.isInvalidated=!0;try{e.handle.skipTransition()}catch{}}},ge={maybeCurrentVNode:w()},_e=(e,n,r)=>{try{return yM(e,n,t,r,e=>{ge.maybeCurrentVNode=T(e)})}catch(e){try{let e=ge.maybeCurrentVNode;D(e)&&(ge.maybeCurrentVNode=T(bM(e.value)))}finally{fee()}throw e}},b=xr(c);yield*Om(e=>P(function*(){if(!mf(e))return;let n=ge.maybeCurrentVNode;yield*O(n,{onNone:()=>N,onSome:e=>M(()=>{let n=yM(T(e),null,t).elm;n&&n.parentNode&&(n.parentNode.replaceChild(t,n),t.replaceChildren())})})}));let ve=(n,r)=>M(()=>{if(e.isCrashed)return;e.isCrashed=!0,he();let o=h(),s=Qd(n);rG({error:s instanceof Error?s:Error(String(s)),model:o,message:r},a,t,ge,i),ue()}),ye=w(),be=e=>{ye=T(e)},x={dispatchAsync:e=>v(e),dispatchSync:e=>{d(e)}},xe=hj(),Se=(e,t,a,s,c)=>{let d=Ar(c,e=>e===`Live`),f=Tr(d,()=>l),p=Tr(d,()=>u),[m,h]=fG(f,()=>{Ij(xe),OM(a.dispatchSync,s,xe,c);try{return n(e,r)}finally{kM()}}),{body:g}=m;pG(f,h,(n,r)=>({_tag:`View`,model:e,message:t,durationMs:n,thresholdMs:r}));let{maybeCurrentVNode:_}=ge,[v,y]=fG(p,()=>{if(E(_)&&b!==null){let e=b;return b=null,e.removeAttribute(PH),BW(e,g,xe.dedupeSeen,o??``)}return _e(_,g,xe.dedupeSeen)});ge.maybeCurrentVNode=T(v),pG(p,y,(n,r)=>({_tag:`Patch`,model:e,message:t,durationMs:n,thresholdMs:r})),i&&ZW(m,v.elm)},Ce=(t,n,r=x,i=`Live`)=>P(function*(){e.isRenderingFrame=!0;let a=yield*ym();i===`Replay`&&uee(),Se(t,n,r,a,i)}).pipe(km(M(()=>{e.isRenderingFrame=!1,dee(),y()})),wm(MH,r),wm(gk,ne),wm(vk,re)),we=$r($r($r(m,MH,x),gk,ne),vk,re),Te=()=>te()&&!e.isRuntimeDisposed&&!e.isCrashed,Ee=()=>{e.isRenderingFrame=!0;let t=h();ae()===`Paused`&&(ye=w());try{Se(h(),ye,x,we,`Live`),pe=t,oe(`Live`),le()}catch(e){qm(ve(Gd(e),ye))}finally{e.isRenderingFrame=!1}y(),ue()},De=t=>{if(ae()===`Paused`||t.reducedMotionQuery.matches||E(ye))return!1;let n=bG(t.decide,{previousModel:pe,model:h(),message:ye.value});if(E(n))return!1;he();try{let r={isInvalidated:!1,didRun:!1},i=t.startViewTransition(()=>{r.isInvalidated||r.didRun||(r.didRun=!0,Te()?(he(),ke()):e.isRuntimeDisposed||e.isCrashed||se()||ae()===`Paused`?ue():Ee())},n.value.maybeTypes);return me=T({handle:i,update:r}),vG(i),!0}catch{return!1}},Oe=()=>{if(Te()){requestAnimationFrame(Oe);return}de=!1;let t=fe;fe=!1,e.isRuntimeDisposed?ue():(ee(),e.isCrashed||se()||ae()===`Paused`&&!t?ue():E(f)?Ee():De(f.value)||Ee())},ke=(e=!1)=>{e&&(fe=!0),de||(de=!0,p.markCommitPending(),requestAnimationFrame(Oe))};return{crashWith:ve,render:Ce,setLastDirtyMessage:be,scheduleRenderFrame:ke,skipPendingViewTransition:he,devToolsRenderBridge:{renderReplay:e=>P(function*(){let t=e,n=pe;oe(`Paused`),he();let r=yield*nm(Ce(t,w(),QW,`Replay`));if(pf(r)){if(ie(),se()){let e=yield*nm(Ce(n,w(),QW,`Replay`));ie(),pf(e)&&(yield*ce)}else yield*M(()=>ke(!0));return yield*qp(r.cause)}ie(),pe=t,ye=w()}),markRenderPending:M(()=>ke(!0))}}}),SG=({resources:e,managedResources:t,runtimeScope:n,maybePortChannels:r})=>P(function*(){let i=yield*O(br(e),{onNone:()=>j(w()),onSome:e=>rm(Nm(Lm(Jf(e,n))),T)}),a=yield*Rp(t?Ei(t):[],([e,t])=>YD(w()).pipe(rm(e=>({config:t,ref:e})))),o=(e,{config:t,ref:n})=>rp(e,Yf(t.resource._tag,n)),s=Ri(a,{onEmpty:()=>w(),onNonEmpty:e=>T(ba(e,Zf,o))}),c=qR();return{managedResourceRefs:a,provideAllResources:e=>{let t=O(i,{onNone:()=>e,onSome:t=>F(t,t=>Sm(e,t))}),n=O(s,{onNone:()=>t,onSome:e=>xm(t,e)});return wm(O(r,{onNone:()=>n,onSome:e=>wm(n,AH,e.channels)}),JR,c)},provideResources:e=>O(i,{onNone:()=>e,onSome:t=>vm(t,{onFailure:t=>Yd(t)?qp(t):sm(Sm(e,Xr()),e=>Yd(e)?qp(e):qp(Zd(t,e))),onSuccess:t=>Sm(e,t)})})}}),CG=()=>({isRuntimeDisposed:!1,isRenderingFrame:!1,isCrashed:!1}),wG=Bw(z({x:R,y:R}));qC(wG);var TG=VC(wG),EG=e=>`foldkit:scroll:${e}`,DG=e=>{try{let t=EG(e),n=br(window.sessionStorage.getItem(t));return window.sessionStorage.removeItem(t),Tr(n,TG)}catch{return w()}},OG=e=>M(()=>{let t=DG(e);if(D(t)){let{x:e,y:n}=t.value;window.scrollTo({left:e,top:n,behavior:`instant`})}}),kG=({subscriptions:e,initModel:t,modelPubSub:n,runtimeScope:r,maybeSlowSubscriptionDependencies:i,enqueueMessageEffect:a,provideAllResources:o,crashWith:s})=>d(e,Ei,Rp(([e,{dependenciesSchema:c,modelToDependencies:l,keepAliveEquivalence:u,dependenciesToStream:d}])=>P(function*(){let f=u??nT(c),[p,m]=fG(i,()=>l(t));pG(i,m,(n,r)=>({_tag:`SubscriptionDependencies`,subscriptionKey:e,model:t,durationMs:n,thresholdMs:r}));let h=yield*YD(p),g=eD(yield*_T(n).pipe(wm(Of,r))).pipe(aD(t=>P(function*(){let[n,r]=fG(i,()=>l(t));return pG(i,r,(n,r)=>({_tag:`SubscriptionDependencies`,subscriptionKey:e,model:t,durationMs:n,thresholdMs:r})),yield*ZD(h,n),n})));yield*Gm(r)(cD(KE(p),g).pipe(mD(f),sD(e=>d(e,()=>$D(h))),vD(e=>a(e)),o,sm(e=>s(e,w()))))}),{concurrency:`unbounded`,discard:!0})),AG=new WeakMap,jG=({ports:e,kind:t,Model:n,Flags:r,configuredFlags:i,isFlagsRequired:a,init:o,update:s,view:c,manageDocument:l,subscriptions:u,container:f,hydration:p,routing:m,crash:h,slow:g,viewTransition:_,freezeModel:v,preserveScroll:y,resources:ee,managedResources:te,devTools:ne})=>{let re=e=>bU(e,!1),ie=HR(),ae=dG(g,re),oe=Tr(ae,({view:e})=>e),se=Tr(ae,({update:e})=>e),ce=Tr(ae,({patch:e})=>e),ue=Tr(ae,({subscriptionDependencies:e})=>e),de=d(br(_),Tr(e=>wr(yG(),t=>({decide:e,startViewTransition:t,reducedMotionQuery:window.matchMedia(`(prefers-reduced-motion: reduce)`)})))),fe=v!==!1&&!1,pe=y!==!1&&l&&!1,me=e=>fe?oU(e):e;le(e)&&IU(e);let he=p!==void 0&&p.runtimeId!==``?p.runtimeId:f?.id??``,ge=(t,g,_=`Fresh`,v,y)=>{let re=rz(),ae=new Set;return Em(P(function*(){if(he===``)return yield*Yp(Error('[foldkit] Runtime container must have an `id` for Model preservation across reloads. Set `container.id = "app"` (or any unique string) before passing it to makeApplication or makeElement. On a server-rendered page the id comes from the `data-foldkit-app` root stamp instead.'));let le=yield*Tm,fe=d(br(e),wr(e=>FU(e,t)));yield*O(Dr({connector:t,portChannels:fe}),{onNone:()=>N,onSome:({connector:e,portChannels:t})=>Dm(M(()=>e.bind(t.deliverInbound)),()=>M(()=>e.unbind()))});let{managedResourceRefs:ge,provideAllResources:_e,provideResources:b}=yield*SG({resources:ee,managedResources:te,runtimeScope:le,maybePortChannels:fe}),{maybeHydrationRoot:ve,resolveFlags:ye}=yield*$H({bootMode:_,hydration:p,bootFlags:v,configuredFlags:i,isFlagsRequired:a,FlagsCodec:r,preservedModel:g,container:f,buildId:y,provideResources:b}),be=rT(n),x=BC(be),xe=qC(be),Se=br(m).pipe(Tr(()=>TH(window.location.href))),Ce=rm(ye,e=>o(e,Sr(Se))),we=yield*g===void 0?Ce:hf(x(g),{onFailure:()=>Ce,onSuccess:e=>j({model:e})}),Te=we.model,Ee=we.commands??[];yield*WU({onDebounce:e=>M(()=>(xe(e),void 0)),onFlush:e=>M(()=>(xe(e),void 0))},mo(200));let De=CG(),Oe=yield*zU({status:De,processMessage:e=>Ze(e),crashWith:(e,t)=>We(e,t)}),{enqueueMessage:ke,enqueueMessageEffect:Ae,completeBoot:je}=Oe,Me=me(Te),Ne=yield*mT(),Pe=yield*PU({devTools:ne,update:s,maybeFreezeModel:me,enqueueMessageEffect:Ae}),{isRecordingCommands:Fe,installDevToolsStore:Ie,recordInit:Le,recordMessage:Re,recordCommandResult:ze}=Pe,Be=0,Ve=e=>ga(e,e=>({id:Be++,command:e}));m&&(yield*Dm(M(()=>eU(ke,m)),e=>M(()=>e())));let He=Me,Ue=yield*ym(),{crashWith:We,render:Ge,setLastDirtyMessage:Ke,scheduleRenderFrame:qe,skipPendingViewTransition:Je,devToolsRenderBridge:Ye}=yield*xG({status:De,container:f,view:c,htmlBuilder:ie,manageDocument:l,crash:h,buildId:y,initModel:Me,maybeHydrationRoot:ve,maybeSlowView:oe,maybeSlowPatch:ce,duplicateIdScanner:void 0,maybeResolvedViewTransition:de,commitNotifier:re,runtimeContext:Ue,readLiveModel:()=>He,messageQueue:Oe,devToolsIntegration:Pe});yield*Om(()=>Rp(d(ae,Li,ca),zz,{discard:!0}));let Xe=(e,t,n)=>{queueMicrotask(()=>{if(De.isRuntimeDisposed||De.isCrashed)return;let r=e.effect.pipe(Hm(e.name,{attributes:e.args??{}}),_e),i=n===void 0?r:r.pipe(tm(e=>M(()=>ze(n,e))));Jm(Ue)(Gm(le)(i.pipe(F(Ae),sm(e=>We(e,t)))))})},Ze=e=>{let t=He,[n,r]=fG(se,()=>s(t,e)),i=n.model,a=n.commands??[],o=me(i);if(pG(se,r,(n,r)=>({_tag:`Update`,previousModel:t,nextModel:o,message:e,durationMs:n,thresholdMs:r})),t!==o&&(He=o,Ke(e),gT(Ne,o),qe()),Fe){let n=Ve(a);for(let{command:t,id:r}of n)Xe(t,T(e),r);Re(e,t,o,n)}else for(let t of a)Xe(t,T(e))};yield*Ie(Ye);let Qe=yield*nm(Ge(Me,w()));if(pf(Qe))return yield*We(Qe.cause,w()),yield*Gp;pe&&(yield*OG(he));let $e=Fe?Ve(Ee):[];if(Fe&&(yield*Le(Me,$e)),u&&(yield*kG({subscriptions:u,initModel:Me,modelPubSub:Ne,runtimeScope:le,maybeSlowSubscriptionDependencies:ue,enqueueMessageEffect:Ae,provideAllResources:_e,crashWith:We})),yield*LU({managedResourceRefs:ge,initModel:Me,modelPubSub:Ne,runtimeScope:le,enqueueMessageEffect:Ae,crashWith:We}),yield*Om(()=>M(()=>{De.isRuntimeDisposed=!0,Je()})),Fe)for(let{command:e,id:t}of $e)Xe(e,w(),t);else for(let e of Ee)Xe(e,w());return je(),yield*Gp})).pipe(wm(nz,re.service),wm(iz,{register:e=>{ae.add(e)},unregister:e=>{ae.delete(e)}}))},_e={runtimeId:he,start:e=>ge(w(),e,`Fresh`),ports:e};return AG.set(_e,{startWith:(e,t,n,r,i)=>ge(e,t,n,r,i),kind:t,isEmbedActive:!1,maybeActiveFiber:w()}),_e};function MG(e){let{container:t}=e,n=`routing`in e,r=`Flags`in e,i=QH(t,r),a=i?.root??t;if(a===null)throw ZH(document)&&XH(document),Error('[foldkit] Container is null. Make sure the element exists in the DOM before calling makeApplication (e.g. that your <div id="root"></div> has rendered, and your script runs after it). On a server-rendered page the runtime instead finds the root by its `data-foldkit-app` stamp.');let o=n?Cr(TH(window.location.href)):void 0,s={kind:`Application`,Model:e.Model,update:e.update,view:e.view,manageDocument:!0,ports:e.ports,...e.subscriptions&&{subscriptions:e.subscriptions},container:a,...i&&{hydration:i},...n&&{routing:e.routing},...e.crash&&{crash:e.crash},...le(e.slow)&&{slow:e.slow},...le(e.viewTransition)&&{viewTransition:e.viewTransition},...le(e.freezeModel)&&{freezeModel:e.freezeModel},...le(e.preserveScroll)&&{preserveScroll:e.preserveScroll},...e.resources&&{resources:e.resources},...e.managedResources&&{managedResources:e.managedResources},...le(e.devTools)&&{devTools:e.devTools}};return jG(r&&n?{...s,Flags:e.Flags,configuredFlags:w(),isFlagsRequired:!0,init:(t,n)=>e.init(t,n??o)}:n?{...s,Flags:aw,configuredFlags:w(),isFlagsRequired:!1,init:(t,n)=>e.init(n??o)}:r?{...s,Flags:e.Flags,configuredFlags:w(),isFlagsRequired:!0,init:t=>e.init(t)}:{...s,Flags:aw,configuredFlags:w(),isFlagsRequired:!1,init:()=>e.init()})}var NG=tO(({fiber:e,teardown:t})=>{function n(t){t.persisted||e.interruptUnsafe(e.id)}globalThis.addEventListener(`pagehide`,n),e.addObserver(e=>{globalThis.removeEventListener(`pagehide`,n),t(e,()=>{})})}),PG=uw([class extends eT(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:_w(`WorkerSpawnError`),message:L,cause:ZC(Rw())}){},class extends eT(`effect/workers/WorkerError/WorkerSendError`)({_tag:_w(`WorkerSendError`),message:L,cause:ZC(Rw())}){},class extends eT(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:_w(`WorkerReceiveError`),message:L,cause:ZC(Rw())}){},class extends eT(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:_w(`WorkerUnknownError`),message:L,cause:ZC(Rw())}){}]),FG=new Ao(`async`,e=>{let t=!1;return queueMicrotask(()=>{t||e()}),()=>{t=!0}}),IG=e=>xm(e,Yf(To,FG)),LG=(e,t,n,r,i)=>{let a=AG.get(e);return ce(a)?Yp(Error(`[foldkit] Runtime boot expects a program created by makeApplication or makeElement.`)):n===`Hydrate`&&a.kind!==`Application`?Yp(Error(`[foldkit] Runtime.hydrate expects a program created by makeApplication.`)):a.startWith(w(),t,n,r,i)},RG=e=>Yd(e)?N:aO(Qd(e))?$m(e):N,zG=e=>dm(e,RG),BG=(e,t,n,r)=>{NG(zG(IG(F(UU(e.runtimeId),i=>LG(e,i,t,n,r)))),{disableErrorReporting:!0})};function VG(e,t){BG(e,`Fresh`,t?.flags)}var HG=e=>typeof e==`object`&&!!e&&`sel`in e&&typeof e.sel==`string`&&`data`in e&&`children`in e&&`text`in e&&`elm`in e&&`key`in e,UG=(e,t)=>{e.identity===void 0&&(e.identity=t)},G=(e,t)=>{if(HG(e))UG(e,t);else if(Array.isArray(e))for(let n of e)HG(n)&&UG(n,t);return e},WG=[{command:`newTask`,mac:[`Cmd-Enter`,`Cmd-i`],other:[`Ctrl-Enter`,`Ctrl-i`]},{command:`toggleDone`,mac:[`Cmd-d`,`Cmd-Shift-Enter`],other:[`Ctrl-d`,`Ctrl-Shift-Enter`]},{command:`toggleCancelled`,mac:[`Ctrl-c`,`Cmd-Alt-Enter`],other:[`Alt-c`,`Ctrl-Alt-Enter`]},{command:`archive`,mac:[`Cmd-Shift-a`,`Cmd-Alt-a`],other:[`Ctrl-Shift-a`,`Ctrl-Alt-a`]},{command:`moveUp`,mac:[`Cmd-Ctrl-ArrowUp`,`Alt-ArrowUp`],other:[`Ctrl-Shift-ArrowUp`,`Alt-ArrowUp`]},{command:`moveDown`,mac:[`Cmd-Ctrl-ArrowDown`,`Alt-ArrowDown`],other:[`Ctrl-Shift-ArrowDown`,`Alt-ArrowDown`]},{command:`openLink`,mac:[`Cmd-Shift-u`,`Alt-Enter`],other:[`Alt-Enter`]},{command:`editLink`,mac:[`Cmd-k`],other:[`Ctrl-k`]},{command:`gotoProject`,mac:[`Cmd-p`],other:[`Ctrl-p`]},{command:`commandPalette`,mac:[`Cmd-Shift-p`,`F1`],other:[`Ctrl-Shift-p`,`F1`]},{command:`find`,mac:[`Cmd-f`],other:[`Ctrl-f`]},{command:`indent`,mac:[`Cmd-]`],other:[`Ctrl-]`]},{command:`outdent`,mac:[`Cmd-[`,`Shift-Tab`],other:[`Ctrl-[`,`Shift-Tab`]},{command:`tab`,mac:[`Tab`],other:[`Tab`]},{command:`continueTask`,mac:[`Enter`],other:[`Enter`]},{command:`showShortcuts`,mac:[`Cmd-/`],other:[`Ctrl-/`]}],GG=[{command:`newTask`,title:`New task`,description:`Create a new task`,inPalette:!0},{command:`toggleDone`,title:`Toggle done`,description:`Mark the task done or open`,inPalette:!0},{command:`toggleCancelled`,title:`Toggle cancelled`,description:`Cancel or reopen the task`,inPalette:!0},{command:`archive`,title:`Archive resolved tasks`,description:`Archive completed and cancelled tasks`,inPalette:!0},{command:`moveUp`,title:`Move task up`,description:`Move the task up`,inPalette:!0},{command:`moveDown`,title:`Move task down`,description:`Move the task down`,inPalette:!0},{command:`openLink`,title:`Open link`,description:`Open the link under the caret`,inPalette:!0},{command:`editLink`,title:`Edit link`,description:`Edit the link under the caret, or link the selected text`,inPalette:!0},{command:`gotoProject`,title:`Go to project`,description:`Jump to a project`,inPalette:!0},{command:`commandPalette`,title:`Command palette`,description:`Open the command palette`,inPalette:!1},{command:`find`,title:`Find`,description:`Find text in the document`,inPalette:!0},{command:`indent`,title:`Indent`,description:`Indent the selected task block`,inPalette:!0},{command:`outdent`,title:`Outdent`,description:`Outdent the selected task block`,inPalette:!0},{command:`tab`,title:`Tag or indent`,description:`Add a tag or indent the current task`,inPalette:!1},{command:`continueTask`,title:`Continue task`,description:`Continue the current task`,inPalette:!1},{command:`showShortcuts`,title:`Keyboard shortcuts`,description:`Show keyboard shortcuts`,inPalette:!0}],KG=[{command:`newTask`,label:`New task`},{command:`toggleDone`,label:`Done`},{command:`toggleCancelled`,label:`Cancel`},{command:`archive`,label:`Archive`},{command:`moveUp`,label:`Move`},{command:`commandPalette`,label:`Commands`},{command:`showShortcuts`,label:`Help`}],qG=(e,t)=>G(WG.find(e=>G(e.command===t,`src/editor/keymap.ts#anonymous`))?.[e]??[],`src/editor/keymap.ts#keysFor`),JG={Ctrl:`⌃`,Control:`⌃`,Alt:`⌥`,Option:`⌥`,Shift:`⇧`,Cmd:`⌘`,Command:`⌘`},YG={Ctrl:`Ctrl`,Control:`Ctrl`,Alt:`Alt`,Option:`Alt`,Shift:`Shift`,Cmd:`Cmd`,Command:`Cmd`},XG=[`Ctrl`,`Control`,`Alt`,`Option`,`Shift`,`Cmd`,`Command`],ZG=(e,t)=>{if(e===`mac`){if(t===`ArrowUp`)return G(`↑`,`src/editor/keymap.ts#keyName`);if(t===`ArrowDown`)return G(`↓`,`src/editor/keymap.ts#keyName`);if(t===`ArrowLeft`)return G(`←`,`src/editor/keymap.ts#keyName`);if(t===`ArrowRight`)return G(`→`,`src/editor/keymap.ts#keyName`);if(t===`Enter`)return G(`↩`,`src/editor/keymap.ts#keyName`)}else{if(t===`ArrowUp`)return G(`Up`,`src/editor/keymap.ts#keyName`);if(t===`ArrowDown`)return G(`Down`,`src/editor/keymap.ts#keyName`);if(t===`ArrowLeft`)return G(`Left`,`src/editor/keymap.ts#keyName`);if(t===`ArrowRight`)return G(`Right`,`src/editor/keymap.ts#keyName`);if(t===`Enter`)return G(`Enter`,`src/editor/keymap.ts#keyName`)}return G(/^[a-z]$/i.test(t)?t.toUpperCase():t,`src/editor/keymap.ts#keyName`)},QG=(e,t)=>{let n=t.split(`-`),r=n.pop()??``,i=n.filter(t=>G(e===`mac`?JG[t]!==void 0:YG[t]!==void 0,`src/editor/keymap.ts#anonymous~2`)).sort((e,t)=>G(XG.indexOf(e)-XG.indexOf(t),`src/editor/keymap.ts#anonymous~3`));return G(e===`mac`?`${i.map(e=>G(JG[e],`src/editor/keymap.ts#anonymous~4`)).join(``)}${ZG(e,r)}`:[...i.map(e=>G(YG[e],`src/editor/keymap.ts#anonymous~5`)),ZG(e,r)].join(`+`),`src/editor/keymap.ts#keyLabel`)},$G=(e,t)=>{let n=`${e} ${t}`.toLowerCase();return G(/mac|iphone|ipad/.test(n)?`mac`:`other`,`src/editor/keymap.ts#detectPlatform`)},eK=2097152,tK=4096,nK=L.pipe(mw(Mw(eK))),rK=L.pipe(mw(Mw(tK))),iK=L.pipe(mw(Sw(e=>G(e.length>0&&e.startsWith(`/`)?void 0:`an absolute, non-empty path is required`,`../protocol/src/schema.ts#anonymous`)),Mw(eK))),aK=jw.pipe(mw(Ow(0))),oK=uw([vw(`User`,{}),vw(`Agent`,{name:L.pipe(mw(Nw(1,64),Cw(/^[A-Za-z0-9._-]+$/)))}),vw(`File`,{})]),sK=dw([`open`,`done`,`cancelled`]),cK=z({number:R,line:R,state:sK,text:rK,indent:R,section:fw(nK)}),lK=z({kind:dw([`added`,`removed`,`checked`,`unchecked`,`cancelled`,`uncancelled`,`edited`]),number:R,text:rK,line:R,oldLine:R}),uK=z({id:nK,title:nK,level:dw([1,2,3]),line:R}),dK=z({since:aK,diff:fw(nK)}),fK=uw([vw(`Replace`,{old:nK,new:nK}),vw(`Append`,{text:nK}),vw(`TodoAdd`,{text:rK}),vw(`TodoSet`,{target:uw([R,nK]),state:sK}),vw(`TodoStart`,{target:uw([R,nK])})]),pK=ZC(nK),mK=z({}),hK=z({pid:R,appVersion:nK,port:R,startedAt:R,documents:sw(z({path:iK,version:aK,watchers:R}))}),gK=z({}),_K=z({}),vK=z({path:iK,create:iw}),yK=z({path:iK,version:aK,url:nK,created:iw}),bK=z({path:iK,section:pK}),xK=z({version:aK,text:nK}),SK=z({path:iK}),CK=z({version:aK,sections:sw(uK)}),wK=z({path:iK,section:pK}),TK=z({version:aK,todos:sw(cK)}),EK=z({path:iK,author:oK,version:aK,section:pK,op:fK}),DK=z({version:aK,changed:iw,section:fw(nK),others:fw(dK)}),OK=z({path:iK,base:aK,text:nK}),kK=z({version:aK,text:nK}),AK=z({path:iK,since:aK,wait:R.pipe(mw(kw({minimum:0,maximum:600})))}),jK=z({from:aK,to:aK,by:sw(oK),diff:fw(nK),todos:sw(lK)}),MK=z({path:iK,since:ZC(aK),section:pK,text:iw}),NK=uw([vw(`Watching`,{version:aK,text:XC(nK)}),vw(`Change`,{from:aK,to:aK,by:sw(oK),diff:fw(nK),todos:sw(lK),text:XC(nK)}),vw(`Resync`,{version:aK,text:XC(nK)}),vw(`Deleted`,{})]),PK=class extends tT()(`VersionMismatch`,{latest:aK,since:aK,diff:fw(nK),forgotten:iw}){},FK=dw([`not-found`,`ambiguous`,`too-large`,`invalid`]),IK=uw([PK,class extends tT()(`Refused`,{code:FK,message:nK}){},class extends tT()(`Forgotten`,{latest:aK}){},class extends tT()(`NothingYet`,{}){},class extends tT()(`DocumentGone`,{path:iK}){},class extends tT()(`Unauthorized`,{}){}]),LK=`~effect/rpc/RpcSchema/StreamSchema`;function RK(e){return b(e,LK)}function zK(e){return RK(e)?T({success:e.success,error:e.error}):w()}var BK=jC(RE);function VK(e,t){return JC(BK.ast,{[LK]:LK,success:e,error:t})}var HK=`~effect/rpc/Rpc`,UK={[HK]:HK,pipe(){return e(this,arguments)},setSuccess(e){return WK({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return WK({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return WK({_tag:this._tag,payloadSchema:YC(e)?e:z(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return WK({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return WK({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return WK({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:$r(this.annotations,e,t)})},annotateMerge(e){return WK({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:li(this.annotations,e)})}},WK=e=>{function t(){}return Object.setPrototypeOf(t,UK),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},GK=(e,t)=>{let n=t?.success??aw,r=t?.error??ew,i=t?.defect??Rw(),a;return a=t?.primaryKey?class extends $w(`effect/rpc/Rpc/${e}`)(t.payload){[CD](){return t.primaryKey(this)}}:YC(t?.payload)?t?.payload:t?.payload?z(t?.payload):aw,WK({_tag:e,payloadSchema:a,successSchema:t?.stream?VK(n,r):n,errorSchema:t?.stream?ew:r,defectSchema:i,annotations:Xr(),middlewares:new Set})},KK=new WeakMap,qK=e=>{if(KK.has(e))return KK.get(e);let t=e,n=new Set([t.errorSchema]),r=zK(t.successSchema);D(r)&&n.add(r.value.error);for(let e of t.middlewares)n.add(e.error);let i=Uw(D(r)?aw:t.successSchema,uw([...n]),t.defectSchema);return KK.set(e,i),i},JK=k(`effect/rpc/Rpc/ParseOptions`,{defaultValue:()=>ub}),YK=`~effect/rpc/Rpc/Wrapper`,XK=e=>YK in e,ZK=class extends Nr()(`effect/workers/Transferable/Collector`){},QK=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return ZK.of({addAllUnsafe:t,addAll:e=>M(()=>t(e)),readUnsafe:n,read:M(n),clearUnsafe:r,clear:M(r)})},$K=(e,t)=>e===void 0?t:`${e}.${t}`,eq=(e,t)=>({"rpc.system.name":`effect_rpc`,"rpc.method":e,...t}),tq=`~effect/rpc/RpcClientError`,nq=class extends eT(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:_w(`RpcClientDefect`),message:L,cause:Rw()}){},rq=class extends eT(tq)({_tag:_w(`RpcClientError`),reason:uw([PG,hH,oV,nq])}){[tq]=tq;get message(){return`${this.reason._tag}: ${this.reason.message}`}},iq=e=>e,aq=e=>{switch(e._tag){case`Exit`:case`Defect`:case`ClientProtocolError`:return!0;default:return!1}},oq=rT,sq=class extends Nr()(`effect/rpc/RpcSerialization`){},cq=class extends Lo(`MaxBufferSizeExceeded`){get message(){return`RPC serialization buffer exceeded the maximum size of ${this.maxBufferSize}`}},lq=class extends Lo(`NdjsonDecodeError`){},uq=16777216,dq=(e,t)=>t!==`unbounded`&&e>t,fq=(e=>{let t=e?.maxBufferSize??uq;return sq.of({contentType:`application/x-ndjson`,includesFraming:!0,codecFor:oq,makeUnsafe:()=>{let e,n=``,r=e=>{throw n=``,new cq({maxBufferSize:e})};return{decode:i=>{n+=typeof i==`string`?i:(e??=new TextDecoder).decode(i,{stream:!0});let a=0,o=n.indexOf(`
|
|
99
|
-
`,a),s=[];for(;o!==-1;){dq(o-a,t)&&r(t);let e=n.slice(a,n[o-1]===`\r`?o-1:o);if(a=o+1,e.length>0)try{s.push(JSON.parse(e))}catch(e){throw n=``,new lq({cause:e})}o=n.indexOf(`
|
|
100
|
-
`,a)}return n=n.slice(a),dq(n.length,t)&&r(t),s},encode:e=>{if(Array.isArray(e)){if(e.length===0)return;let t=``;for(let n=0;n<e.length;n++)t+=JSON.stringify(e[n])+`
|
|
101
|
-
`;return t}return JSON.stringify(e)+`
|
|
102
|
-
`}}}})})(),pq=Yf(sq)(fq),mq=e=>Up(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>bm(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),N});return rm(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return P(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*Sm(Up(()=>i(e)),t)}return yield*Mm(Gp,()=>(t.delete(e),r.delete(e),N))})}}))}),hq=e=>ve(e,`RpcClientError`),gq=0,_q=Qm(function*(e,t){let n=t.spanPrefix,r=t?.supportsAck??!0,a=t?.disableTracing??!1,o=t?.generateRequestId??(()=>gq++),s=yield*ym(),c=ii(s,Of),l=new Map,u=!1;yield*Mf(c,Qp(e=>(u=!0,d(uf(e.id)))));let d=Qm(function*(e){let t=Array.from(l.values());l.clear();for(let n of t)n._tag===`Queue`?yield*e._tag===`Success`?Ih(n.queue):Ph(n.queue,e.cause):n.resume(e)},Lm),f=e=>{let r=RK(e.successSchema),i=h(e);return(o,s)=>{let c=s?.headers?iv(s.headers):rv,l=s?.context??Xr();if(!r){let r=t=>p(e,i,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return a?r(void 0):Vm($K(n,e._tag),{kind:`client`,attributes:eq(e._tag,t.spanAttributes)},r)}let u=m(e,i,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:nD(rm(u,lee))}},p=(e,n,r,a,s,c,d)=>Qp(f=>{if(u)return Pm;let p=o(),m=n(e=>t.onFromClient({message:e,context:c}),{_tag:`Request`,id:p,tag:e._tag,payload:a,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:cv(f.getRef(xq),s),...d?{discard:!0}:{}}),h;return Im(Wp(t=>{let n=!1,a={_tag:`Effect`,rpc:e,context:c,resume(e){d&&e._tag===`Success`?(n=!0,h?.pollUnsafe()&&t(df)):(t(e),h&&!h.pollUnsafe()&&f.currentDispatcher.scheduleTask(()=>{h.interruptUnsafe(f.id)},0))}};l.set(p,a),h=m.pipe(r?Um(r,{captureStackTrace:!1}):i,Jm(f.context)),h.addObserver(e=>{if(e._tag===`Failure`)return l.delete(p),t(e);if(n)return t(df)})}),e=>(l.delete(p),em(ah(h),g(p,Array.from(e),c))))}),m=Qm(function*(e,r,s,c,d,f){if(u)return yield*Pm;let p=a?void 0:yield*Bm($K(n,e._tag),{kind:`client`,attributes:eq(e._tag,t.spanAttributes)}),m=sh(),h=o(),_=ri(m.context,Of),v=yield*kh(d);return yield*jf(_,e=>(Rh(v),l.has(h)?(l.delete(h),g(h,pf(e)?Array.from(tf(e.cause)):[],f)):N)),l.set(h,{_tag:`Queue`,rpc:e,queue:v,scope:_,context:f}),yield*r(e=>t.onFromClient({message:e,context:f}),{_tag:`Request`,id:h,tag:e._tag,payload:s,...p?{traceId:p.traceId,spanId:p.spanId,sampled:p.sampled}:{},headers:cv(m.getRef(xq),c)}).pipe(p?Um(p,{captureStackTrace:!1}):i,Am(e=>(Yd(e)||l.delete(h),Ph(v,e))),Fm,Gm(_,{startImmediately:!0})),v}),h=e=>{let t=[];for(let n of e.middlewares.values()){let e=ni(s,`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},g=(e,n,r)=>Wp(i=>{let a=sh();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r}).pipe(mm(1e3),Jm(a.context)).addObserver(()=>{i(N)})}),_=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,a=l.get(n);return!a||a._tag!==`Queue`?N:Mh(a.queue,e.values).pipe(r?F(n=>n.length>0?N:t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:a.context})):i,sm(e=>Ph(a.queue,e)))}case`Exit`:{let t=e.requestId,n=l.get(t);return n?(l.delete(t),n._tag===`Effect`?(n.resume(e.exit),N):e.exit._tag===`Success`?Ih(n.queue):Ph(n.queue,e.exit.cause)):N}case`Defect`:return d(lf(e.defect));case`ClientEnd`:return N}},v;if(t.flatten){let t=new Map;v=function(n,r,i){let a=t.get(n);return a||(a=f(e.requests.get(n)),t.set(n,a)),a(r,i)}}else v={},e.requests.forEach(e=>{Nt(v,e._tag,f(e))});return{client:v,write:_}}),vq=0,yq=Qm(function*(e,t){let n=vq++,{codecFor:r,run:i,send:a,supportsAck:o,supportsTransferables:s}=yield*Sq,c=bq(r),l=WC(r(Rw())),u=new Map,d=yf(),f=e=>u.has(e)?(u.delete(e),a(n,{_tag:`Interrupt`,requestId:e})):N,{client:p,write:m}=yield*_q(e,{...t,supportsAck:o,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),i=s?QK():void 0,o=sh(),l={rpc:r,context:i?$r(o.context,ZK,i):o.context,schemas:c(r),discard:t.discard===!0};return u.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(Sm(l.context),um,F(e=>wf(d)?(u.delete(t.id),Pm):a(n,{...t,id:t.id,payload:e,headers:Object.entries(t.headers)},i&&i.readUnsafe())),Am(e=>Yd(e)?N:M(()=>u.delete(t.id))))}case`Ack`:return u.get(t.requestId)?a(n,{_tag:`Ack`,requestId:t.requestId}):N;case`Interrupt`:return f(t.requestId);case`Eof`:return N}}});return yield*i(n,e=>{switch(e._tag){case`Chunk`:{let t=iq(e.requestId),n=u.get(t);if(!n||E(n.schemas.decodeChunk))return N;let r=n.schemas.decodeChunk.value;return Rm(i=>i(r(e.values).pipe(Sm(n.context),um,F(e=>m({_tag:`Chunk`,clientId:0,requestId:t,values:e})))).pipe(Am(e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:sf(e)}).pipe(em(ef(e)?N:gm(fm(f(t)),bf(d))))),cm(e=>!ef(e),()=>N)))}case`Exit`:{let t=iq(e.requestId),n=u.get(t);return n?(u.delete(t),n.discard&&e.exit._tag===`Success`?m({_tag:`Exit`,clientId:0,requestId:t,exit:df}):(n.discard?n.schemas.decodeDiscardExit:n.schemas.decodeExit)(e.exit).pipe(Sm(n.context),um,vm({onSuccess:e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>m({_tag:`Exit`,clientId:0,requestId:t,exit:sf(e)})}))):N}case`Defect`:return u.clear(),m({_tag:`Defect`,clientId:0,defect:l(e.defect)});case`ClientProtocolError`:{let t=cf(e.error),n=e.requestIds===void 0?Array.from(u.keys()):e.requestIds.map(iq).filter(e=>u.has(e));for(let e of n)u.delete(e);return Rp(n,e=>m({_tag:`Exit`,clientId:0,requestId:e,exit:t})).pipe(Lm)}default:return N}}).pipe(sm($m),Fm,Km),yield*Om(()=>Tf(d,void 0)),p}),bq=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=zK(n.successSchema),a=ii(n.annotations,JK),o=qK(n),s;return r={decodeChunk:wr(i,t=>zC(e(cw(t.success)),a)),encodePayload:KC(e(n.payloadSchema),a),decodeExit:zC(e(o),a),decodeDiscardExit:t=>(s??=zC(e(Uw(aw,o.error,o.defect)),a))(t)},t.set(n,r),r}},xq=k(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>rv}),Sq=class extends Nr()(`effect/rpc/RpcClient/Protocol`){static make=mq},Cq=(e,t)=>t?.batch?Tq(e,t.batch):wq(e),wq=e=>Sq.make(Qm(function*(t){let n=yield*sq,r=Eq(e,n,t);return{send:(e,t)=>t._tag===`Request`?F(r.send(e,[t]),e=>r.requestExit(t,e)):N,supportsAck:!1,supportsTransferables:!1,codecFor:n.codecFor}})),Tq=Qm(function*(e,t){let{maxSize:n,window:r}=t,i=new Map,a=e=>{let t=i.get(e);return t===void 0?N:(i.delete(e),Pf(t,df))},o=yield*Sq.make(Qm(function*(t){let a=yield*sq,o=Eq(e,a,t),s=new Map,c=(e,t)=>{s.get(e)===t&&s.delete(e)},l=(e,t)=>gm(hm(r),t.full.await).pipe(em(Up(()=>(c(e,t),o.send(e,t.requests)))),Mm(n=>(c(e,t),xf(t.done,n)))),u=Qm(function*(e,t){let r=s.get(e);if(r===void 0){r={requests:[t],full:aT(),done:yf()},s.set(e,r);let n=i.get(e);n===void 0&&(n=kf(),i.set(e,n)),yield*Gm(l(e,r),n,{startImmediately:!0})}else r.requests.push(t);return r.requests.length===n&&(c(e,r),r.full.openUnsafe()),yield*o.requestExit(t,yield*bf(r.done))});return{send:(e,t)=>t._tag===`Request`?u(e,t):N,supportsAck:!1,supportsTransferables:!1,codecFor:a.codecFor}}));return Sq.of({...o,run:(e,t)=>Mm(o.run(e,t),()=>a(e))})}),Eq=(e,t,n)=>{let r=t.includesFraming,i=e=>new rq({reason:oV.fromHttpClientError(e)}),a=(e,t)=>new rq({reason:new nq({message:e,cause:t})});return{send:Qm(function*(o,s){let c=t.makeUnsafe(),l=c.encode(s.length===1?s[0]:s),d=typeof l==`string`?qB(l,t.contentType):UB(l,t.contentType),f=yield*e.post(``,{body:d}).pipe(lm(i)),p=new Set;for(let e=0;e<s.length;e++)p.add(String(s[e].id));let m=e=>(e._tag===`Exit`?p.delete(String(e.requestId)):aq(e)&&p.clear(),n(o,e));if(!r){let e=yield*f.text.pipe(lm(i)),t=yield*Xp({try:()=>c.decode(e),catch:e=>a(`Error decoding HTTP response`,e)});if(!Array.isArray(t))return yield*a(`Expected an array of responses`,t);if(t.length===0)return;for(let e=0;e<t.length;e++)yield*m(t[e]);return p}let h=!1;return yield*yD(f.stream,e=>Xp({try:()=>e.flatMap(c.decode),catch:e=>a(`Error decoding HTTP response`,e)}).pipe(F(e=>{if(e.length===0)return N;h=!0;let t=0;return zp({while:()=>t<e.length,body:()=>m(e[t++]),step:u})}))).pipe(lm(e=>hq(e)?e:i(e))),h?p:void 0}),requestExit:(e,t)=>t===void 0?cf(a(`Received empty HTTP response from RPC server`,e)):t.has(String(e.id))?cf(a(`HTTP response ended before RPC request completed`,e)):df}},Dq=e=>Qf(Sq)(F(WV,t=>(t=XV(t,TV(e.url)),Cq(e.transformClient?e.transformClient(t):t,{batch:e.batch})))),Oq={add(...e){let t=new Map(this.requests);for(let n of e)t.set(n._tag,n);return kq({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),n=new Map(this.annotations.mapUnsafe);for(let r of e){for(let[e,n]of r.requests)t.set(e,n);for(let[e,t]of r.annotations.mapUnsafe)n.set(e,t)}return kq({requests:t,annotations:Gr(n)})},omit(...e){let t=new Map(this.requests);for(let n of e)t.delete(n);return kq({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.middleware(e));return kq({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return P(function*(){let n=yield*ym(),r=Lp(e)?yield*e:e,i=new Map;return t.requests.forEach((e,t)=>{i.set(e.key,{tag:e._tag,handler:r[t],context:n})}),Gr(i)})},prefix(e){let t=new Map;for(let n of this.requests.values()){let r=n.prefix(e);t.set(r._tag,r)}return kq({requests:t,annotations:this.annotations})},toLayer(e){return ep(this.toHandlers(e))},of:i,toLayerHandler(e,t){let n=this;return ep(P(function*(){let r=yield*ym(),i=Lp(t)?yield*t:t,a=new Map,o=n.requests.get(e);return a.set(o.key,{handler:i,context:r}),Gr(a)}))},accessHandler(e){return bm(t=>{let n=this.requests.get(e),{handler:r,context:i}=ni(t,n.key);return j((e,t)=>{t.rpc=n;let a=r(e,t),o=XK(a)?a.value:a;return Lp(o)?xm(o,i):_D(o,i)})})},annotate(e,t){return kq({requests:this.requests,annotations:$r(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(Qr(e,t))},annotateMerge(e){return kq({requests:this.requests,annotations:li(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[n,r]of this.requests)t.set(n,r.annotateMerge(li(e,r.annotations)));return kq({requests:t,annotations:this.annotations})}},kq=e=>Object.assign(function(){},Oq,{requests:e.requests,annotations:e.annotations}),Aq=((...e)=>kq({requests:new Map(e.map(e=>[e._tag,e])),annotations:Xr()}))(GK(`status`,{payload:mK,success:hK,error:IK}),GK(`stop`,{payload:gK,success:_K,error:IK}),GK(`open`,{payload:vK,success:yK,error:IK}),GK(`read`,{payload:bK,success:xK,error:IK}),GK(`sections`,{payload:SK,success:CK,error:IK}),GK(`todos`,{payload:wK,success:TK,error:IK}),GK(`edit`,{payload:EK,success:DK,error:IK}),GK(`sync`,{payload:OK,success:kK,error:IK}),GK(`diff`,{payload:AK,success:jK,error:IK}),GK(`watch`,{payload:MK,success:NK,error:IK,stream:!0})),jq=e=>{switch(e._tag){case`User`:return G(`the user`,`../protocol/src/format.ts#describeAuthor`);case`Agent`:return G(e.name,`../protocol/src/format.ts#describeAuthor`);case`File`:return G(`file`,`../protocol/src/format.ts#describeAuthor`)}},Mq=e=>G(`${e.kind} ${e.number}. ${e.text}`,`../protocol/src/format.ts#formatTodoChange`),Nq=(e,t,n)=>{let r=e===t||t===e+1?`Version ${t}`:`Versions ${e+1}-${t}`;return G(n.length===0?r:`${r} by ${n.map(jq).join(`, `)}`,`../protocol/src/format.ts#formatVersionHeader`)},Pq=dw([`mac`,`other`]),Fq=uw([dw([`newTask`,`toggleDone`,`toggleCancelled`,`archive`,`moveUp`,`moveDown`,`continueTask`,`indent`,`outdent`,`tab`]),dw([`openLink`,`editLink`,`gotoProject`,`commandPalette`,`find`,`showShortcuts`])]),Iq=z({anchor:R,head:R}),Lq=z({version:aK,text:L}),Rq=z({base:aK,text:L}),zq=z({version:aK,text:L,resync:iw}),Bq=z({token:R,version:aK,to:L,resync:iw}),Vq=CO({Live:{},Reconnecting:{awaitingResync:iw}}),Hq=z({path:L,session:L,base:Lq,draft:L,draftRevision:R,selection:Iq,inFlight:Ww(Rq),pendingRemote:Ww(Bq),latestRemote:Ww(zq),nextToken:R,retryAttempt:R,watchKey:R,resumeFrom:Ww(aK),reconnectAttempt:R,connection:Vq}),Uq=CO({NoPath:{},Connecting:{path:L,watchKey:R,resumeFrom:Ww(aK),reconnectAttempt:R},Ready:{document:Hq},Deleted:{path:L},Unauthorized:{path:L}}),Wq=CO({Closed:{},Open:{kind:dw([`Commands`,`Projects`,`Shortcuts`]),query:L,active:R}}),Gq=z({document:Uq,activity:sw(z({from:aK,to:aK,by:sw(oK),todos:sw(lK)})),activityOpen:iw,platform:Pq,palette:Wq,notice:Ww(L)}),Kq=(e,t=`other`)=>G({document:e.length===0?Uq.NoPath():Uq.Connecting({path:e,watchKey:0,resumeFrom:w(),reconnectAttempt:0}),activity:[],activityOpen:!1,platform:t,palette:Wq.Closed(),notice:w()},`src/model.ts#makeInitialModel`),qq=e=>G(e.connection._tag===`Reconnecting`?`Reconnecting`:e.draft!==e.base.text||D(e.inFlight)||D(e.pendingRemote)?`Saving`:`Saved`,`src/model.ts#saveStatus`),Jq=dw([`Unauthorized`,`Forgotten`,`DocumentGone`,`Transient`]),K=SO({SucceededMountEditor:{session:L},UpdatedEditor:{session:L,text:L,anchor:R,head:R,origin:dw([`Input`,`Action`,`Remote`]),token:fw(R)},MovedEditorSelection:{session:L,anchor:R,head:R},PressedEditorCommand:{command:Fq,link:XC(L)},ShowedEditorNotice:{text:L},OpenedEditorLink:{url:L},ClickedCommands:{},PressedHelpKey:{},ClickedActivity:{},UpdatedPaletteQuery:{query:L},PressedPaletteKey:{key:dw([`ArrowUp`,`ArrowDown`,`Enter`,`Escape`])},ClickedPaletteItem:{index:R},CompletedFocusPaletteInput:{},CompletedFocusEditor:{},CompletedRunEditorAction:{},CompletedRevealEditorPosition:{},CompletedOpenEditorLink:{},CompletedApplyRemoteText:{token:R},FailedApplyRemoteText:{token:R,reason:L},CompletedWaitBeforeRemoteRetry:{session:L,token:R},ReceivedWatchEvent:{event:NK},WatchEnded:{},FailedWatch:{unauthorized:iw},CompletedWaitBeforeReconnect:{},CompletedWaitBeforeSync:{session:L,revision:R},CompletedWaitBeforeSyncRetry:{session:L,attempt:R},SucceededSync:{request:Rq,version:R,text:L},FailedSync:{request:Rq,kind:Jq}}),Yq=[],Xq=[];(()=>{let e=`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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Xq:Yq).push(n+=e[t])})();function Zq(e){if(e<768)return!1;for(let t=0,n=Yq.length;;){let r=t+n>>1;if(e<Yq[r])n=r;else if(e>=Xq[r])t=r+1;else return!0;if(t==n)return!1}}function Qq(e){return e>=127462&&e<=127487}var $q=8205;function eJ(e,t,n=!0,r=!0){return(n?tJ:nJ)(e,t,r)}function tJ(e,t,n){if(t==e.length)return t;t&&iJ(e.charCodeAt(t))&&aJ(e.charCodeAt(t-1))&&t--;let r=rJ(e,t);for(t+=oJ(r);t<e.length;){let i=rJ(e,t);if(r==$q||i==$q||n&&Zq(i))t+=oJ(i),r=i;else if(Qq(i)){let n=0,r=t-2;for(;r>=0&&Qq(rJ(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function nJ(e,t,n){for(;t>1;){let r=tJ(e,t-2,n);if(r<t)return r;t--}return 0}function rJ(e,t){let n=e.charCodeAt(t);if(!aJ(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return iJ(r)?(n-55296<<10)+(r-56320)+65536:n}function iJ(e){return e>=56320&&e<57344}function aJ(e){return e>=55296&&e<56320}function oJ(e){return e<65536?1:2}var sJ=class e{lineAt(e){if(e<0||e>this.length)throw 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 RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=_J(this,e,t);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),lJ.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=_J(this,e,t);let n=[];return this.decompose(e,t,n,0),lJ.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 pJ(this),i=new pJ(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new pJ(this,e)}iterRange(e,t=this.length){return new mJ(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{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 hJ(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new cJ(t):lJ.from(cJ.split(t,[]))}},cJ=class e extends sJ{constructor(e,t=uJ(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 i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new gJ(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(fJ(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=dJ(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=_J(this,t,n);let i=dJ(this.text,dJ(r.text,fJ(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):lJ.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
103
|
-
`){[e,t]=_J(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},lJ=class e extends sJ{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=_J(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
104
|
-
`){[e,t]=_J(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new cJ(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof cJ&&c&&(n=u[u.length-1])instanceof cJ&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new cJ(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};sJ.empty=new cJ([``],0);function uJ(e){let t=-1;for(let n of e)t+=n.length+1;return t}function dJ(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function fJ(e,t,n){return dJ(e,[``],t,n)}var pJ=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof cJ?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],i=this.offsets[n],a=i>>1,o=r instanceof cJ?r.text.length:r.children.length;if(a==(t>0?o: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((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
105
|
-
`,this;e--}else if(r instanceof cJ){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof cJ?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},mJ=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new pJ(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!=``}},hJ=class{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.afterBreak?(this.value=``,this.afterBreak=!1):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`&&(sJ.prototype[Symbol.iterator]=function(){return this.iter()},pJ.prototype[Symbol.iterator]=mJ.prototype[Symbol.iterator]=hJ.prototype[Symbol.iterator]=function(){return this});var gJ=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function _J(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function vJ(e,t,n=!0,r=!0){return eJ(e,t,n,r)}function yJ(e){return e>=56320&&e<57344}function bJ(e){return e>=55296&&e<56320}function xJ(e,t){let n=e.charCodeAt(t);if(!bJ(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return yJ(r)?(n-55296<<10)+(r-56320)+65536:n}function SJ(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function CJ(e){return e<65536?1:2}var wJ=/\r\n?|\n/,TJ=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(TJ||={}),EJ=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){AJ(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:MJ(this,e)}mapDesc(e,t=!1){return e.empty?this:jJ(this,e,t)}mapPos(e,t=-1,n=TJ.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=TJ.Simple&&c>=e&&(n==TJ.TrackDel&&r<e&&c>e||n==TJ.TrackBefore&&r<e||n==TJ.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},DJ=class e extends EJ{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return AJ(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return jJ(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(sJ.empty);r.push(a?t.slice(i,i+a):sJ.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:MJ(this,e,!0)}map(e,t=!1){return e.empty?this:jJ(this,e,t,!0)}iterChanges(e,t=!1){AJ(this,e,t)}get desc(){return EJ.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new NJ(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);OJ(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;OJ(n,e,t),t>0&&kJ(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);OJ(n,e,-1),OJ(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:EJ.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&OJ(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?sJ.of(l.split(r||wJ)):l:sJ.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&OJ(i,e-o,-1),OJ(i,s-e,d),kJ(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(sJ.empty);r[e]=sJ.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function OJ(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function kJ(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(sJ.empty);e.push(n)}}function AJ(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=sJ.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function jJ(e,t,n,r=!1){let i=[],a=r?[]:null,o=new NJ(e),s=new NJ(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);OJ(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(OJ(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(OJ(i,0,o.ins),a&&kJ(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;OJ(i,t,e<o.i?o.ins:0),a&&e<o.i&&kJ(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?DJ.createSet(i,a):EJ.create(i);else throw Error(`Mismatched change set lengths`)}function MJ(e,t,n=!1){let r=[],i=n?[]:null,a=new NJ(e),o=new NJ(t);for(let e=!1;;)if(a.done&&o.done)return i?DJ.createSet(r,i):EJ.create(r);else if(a.ins==0)OJ(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)OJ(r,0,o.ins,e),i&&kJ(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;OJ(r,t,n,e),i&&n&&kJ(i,r,o.text)}else o.ins==-1?(OJ(r,a.off?0:a.len,t,e),i&&kJ(i,r,a.textBit(t))):(OJ(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&kJ(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var NJ=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?sJ.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?sJ.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)}},PJ=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return q.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return q.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return q.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},q=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>PJ.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return PJ.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,i){let a=r==null?7:Math.min(6,r);return!i&&e!=t&&(i=t<e?1:-1),i&&(a|=i<0?8:16),t<e?PJ.create(t,e,a|32,n):PJ.create(e,t,a,n)}static undirectionalRange(e,t){return PJ.create(e,t,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function FJ(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var IJ=0,J=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=IJ++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:LJ),!!t.static,t.enables)}of(e){return new RJ([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new RJ(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new RJ(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function LJ(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var RJ=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=IJ++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||BJ(e,c)){let r=t(e);if(a?!zJ(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=$J(o,c);if(this.dependencies.every(t=>t instanceof J?o.facet(t)===e.facet(t):t instanceof UJ?o.field(t,!1)==e.field(t,!1):!0)||(a?zJ(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function zJ(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function BJ(e,t){let n=!1;for(let r of t)QJ(e,r)&1&&(n=!0);return n}function VJ(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=$J(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)QJ(e,t);return e.values[o]=s(e),1},update(e,n){if(!BJ(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=BJ(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&LJ(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var HJ=J.define({static:!0}),UJ=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(IJ++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(HJ).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(HJ),i=n.facet(HJ),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,HJ.of({field:this,create:e})]}get extension(){return this}},WJ={lowest:4,low:3,default:2,high:1,highest:0};function GJ(e){return t=>new qJ(t,e)}var KJ={highest:GJ(WJ.highest),high:GJ(WJ.high),default:GJ(WJ.default),low:GJ(WJ.low),lowest:GJ(WJ.lowest)},qJ=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},JJ=class e{of(e){return new YJ(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},YJ=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},XJ=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of ZJ(t,n,o))e instanceof UJ?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,LJ(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>VJ(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function ZJ(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof YJ&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof YJ){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof qJ)a(e.inner,e.prec);else if(e instanceof UJ)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof RJ)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,WJ.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,WJ.default),r.reduce((e,t)=>e.concat(t))}function QJ(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function $J(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var eY=J.define(),tY=J.define({combine:e=>e.some(e=>e),static:!0}),nY=J.define({combine:e=>e.length?e[0]:void 0,static:!0}),rY=J.define(),iY=J.define(),aY=J.define(),oY=J.define({combine:e=>e.length?e[0]:!1}),sY=class{constructor(e,t){this.type=e,this.value=t}static define(){return new cY}},cY=class{of(e){return new sY(this,e)}},lY=class{constructor(e){this.map=e}of(e){return new uY(this,e)}},uY=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new lY(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};uY.reconfigure=uY.define(),uY.appendConfig=uY.define();var dY=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&FJ(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return 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(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};dY.time=sY.define(),dY.userEvent=sY.define(),dY.addToHistory=sY.define(),dY.remote=sY.define();function fY(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function pY(e,t,n){let r,i,a;return n?(r=t.changes,i=DJ.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:uY.mapEffects(e.effects,r).concat(uY.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function mY(e,t,n){let r=t.selection,i=yY(t.annotations);return t.userEvent&&(i=i.concat(dY.userEvent.of(t.userEvent))),{changes:t.changes instanceof DJ?t.changes:DJ.of(t.changes||[],n,e.facet(nY)),selection:r&&(r instanceof q?r:q.single(r.anchor,r.head)),effects:yY(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function hY(e,t,n){let r=mY(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=pY(r,mY(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=dY.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return _Y(n?gY(i):i)}function gY(e){let t=e.startState,n=!0;for(let r of t.facet(rY)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:fY(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=DJ.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=dY.create(t,r,e.selection&&e.selection.map(i),uY.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(iY);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof dY?i:Array.isArray(i)&&i.length==1&&i[0]instanceof dY?i[0]:hY(t,yY(i),!1)}return e}function _Y(e){let t=e.startState,n=t.facet(aY),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=pY(r,mY(t,a,e.changes.newLength),!0))}return r==e?e:dY.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var vY=[];function yY(e){return e==null?vY:Array.isArray(e)?e:[e]}var bY=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(bY||={}),xY=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,SY;try{SY=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function CY(e){if(SY)return SY.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||xY.test(n)))return!0}return!1}function wY(e){return t=>{if(!/\S/.test(t))return bY.Space;if(CY(t))return bY.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return bY.Word;return bY.Other}}var TY=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)QJ(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`)}else return QJ(this,n),$J(this,n)}update(...e){return hY(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(JJ.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(uY.reconfigure)?(n=null,r=e.value):e.is(uY.appendConfig)&&(n=null,r=yY(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=XJ.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(tY)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:q.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=yY(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=uY.mapEffects(a,c).concat(uY.mapEffects(yY(o.effects),l))}return{changes:r,selection:q.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof DJ?t:DJ.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return sJ.of(t.split(this.facet(e.lineSeparator)||wJ))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(QJ(this,t),$J(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof UJ&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:q.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=XJ.resolve(t.extensions||[],new Map),r=t.doc instanceof sJ?t.doc:sJ.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||wJ)),i=t.selection?t.selection instanceof q?t.selection:q.single(t.selection.anchor,t.selection.head):q.single(0);return FJ(i,r.length),n.staticFacet(tY)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
|
106
|
-
`}get readOnly(){return this.facet(oY)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(eY))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return wY(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=vJ(t,a,!1);if(i(t.slice(e,a))!=bY.Word)break;a=e}for(;o<r;){let e=vJ(t,o);if(i(t.slice(o,e))!=bY.Word)break;o=e}return a==o?null:q.range(a+n,o+n)}};TY.allowMultipleSelections=tY,TY.tabSize=J.define({combine:e=>e.length?e[0]:4}),TY.lineSeparator=nY,TY.readOnly=oY,TY.phrases=J.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),TY.languageData=eY,TY.changeFilter=rY,TY.transactionFilter=iY,TY.transactionExtender=aY,JJ.reconfigure=uY.define();function EY(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(a!==i&&i!==void 0){if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}var DY=class{eq(e){return this==e}range(e,t=e){return kY.create(e,t,this)}};DY.prototype.startSide=DY.prototype.endSide=0,DY.prototype.point=!1,DY.prototype.mapMode=TJ.TrackDel;function OY(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var kY=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function AY(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var jY=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return NY(this.to)}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);i<a;i++)if(r(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(t,n,r,i,a){let o=[],s=[],c=[],l=-1,u=-1;iter:for(let e=0;e<this.value.length;e++){let d=this.value[e],f=this.from[e]+t,p=this.to[e]+t,m,h;if(f==p){let e=n.mapPos(f,d.startSide,d.mapMode);if(e==null||(m=h=e,d.startSide!=d.endSide&&(h=n.mapPos(f,d.endSide),h<m)))continue}else if(m=n.mapPos(f,d.startSide),h=n.mapPos(p,d.endSide),m>h||m==h&&d.startSide>0&&d.endSide<=0)continue;if(!((h-m||d.endSide-d.startSide)<0)){if(l<0&&(l=m),d.point&&(u=Math.max(u,h-m)),(m-r||d.startSide-i)>=0)o.push(d),s.push(m-l),c.push(h-l),r=h,i=d.endSide;else{if(m==h)for(let e=o.length;e>0;e--){if((m-(c[e-1]+l)||d.startSide-o[e-1].endSide)>=0){o.splice(e,0,d),s.splice(e,0,m-l),c.splice(e,0,h-l);continue iter}if((m-(s[e-1]+l)||d.endSide-o[e-1].startSide)>0)break}a(m,h,d)}}}return{mapped:o.length?new e(s,c,o,u):null,pos:l}}},MY=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,n,r,i)}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(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(AY)),this.isEmpty)return n.length?e.of(n):this;let s=new LY(this,null,-1).goto(0),c=0,l=[],u=new FY;for(;s.value||c<n.length;)if(c<n.length&&(s.from-n[c].from||s.startSide-n[c].value.startSide)>=0){let e=n[c++];u.addInner(e.from,e.to,e.value,!1)||l.push(e)}else s.rangeIndex==1&&s.chunkIndex<this.chunk.length&&(c==n.length||this.chunkEnd(s.chunkIndex)<n[c].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||a<this.chunkPos[s.chunkIndex])&&u.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||a<s.from||o(s.from,s.to,s.value))&&(u.addInner(s.from,s.to,s.value,!1)||l.push(kY.create(s.from,s.to,s.value))),s.next());return u.finishInner(this.nextLayer.isEmpty&&!l.length?e.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:a}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1,a,o=(e,t,n)=>{a||=new FY,a.addRange(e,t,n,!1)};for(let e=0;e<this.chunk.length;e++){let a=this.chunkPos[e],s=this.chunk[e],c=t.touchesRange(a,a+s.length);if(c===!1)i=Math.max(i,s.maxPoint),n.push(s),r.push(t.mapPos(a));else if(c===!0){let[e,c]=n.length?[NY(r)+NY(n).length,NY(NY(n).value).endSide]:[-1,-1],{mapped:l,pos:u}=s.map(a,t,e,c,o);l&&(i=Math.max(i,l.maxPoint),n.push(l),r.push(u))}}let s=this.nextLayer.map(t);return a&&(s=a.finishInner(s)),n.length==0?s:new e(r,n,s||e.empty,i)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],a=this.chunk[r];if(t>=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return RY.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return RY.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=IY(a,o,n),c=new BY(a,s,i),l=new BY(o,s,i);n.iterGaps((e,t,n)=>VY(c,e,l,t,n,r)),n.empty&&n.length==0&&VY(c,0,l,0,0,r)}static eq(e,t,n=0,r){r??=1e9-1;let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=IY(i,a),s=new BY(i,o,0).goto(n),c=new BY(a,o,0).goto(n);for(;;){if(s.to!=c.to||!HY(s.active,c.active)||s.point&&(!c.point||!OY(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new BY(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFrom<t?n.length+1:a.point.startSide<0?n.length:Math.min(n.length,s);r.point(o,e,a.point,n,i,a.pointRank),s=Math.min(a.openEnd(e),n.length)}else e>o&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new FY;for(let r of e instanceof kY?[e]:t?PY(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=NY(t);for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};MY.empty=new MY([],[],null,-1);function NY(e){return e[e.length-1]}function PY(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(AY(t,r)>0)return e.slice().sort(AY);t=r}return e}MY.empty.nextLayer=MY.empty;var FY=class e{finishChunk(e){this.chunks.push(new jY(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.addRange(e,t,n,!0)}addRange(t,n,r,i){this.addInner(t,n,r,i)||(this.nextLayer||=new e).addRange(t,n,r,i)}addInner(e,t,n,r){let i=e-this.lastTo||n.startSide-this.last.endSide;if(r&&i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw Error("Ranges must be added sorted by `from` position and `startSide`");return i<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(MY.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=MY.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function IY(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let a=r.get(e.chunk[t]);a!=null&&(n?n.mapPos(a):a)==e.chunkPos[t]&&!n?.touchesRange(a,a+e.chunk[t].length)&&i.add(e.chunk[t])}return i}var LY=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},RY=class e{constructor(e){this.heap=e}static from(t,n=null,r=-1){let i=[];for(let e=0;e<t.length;e++)for(let a=t[e];!a.isEmpty;a=a.nextLayer)a.maxPoint>=r&&i.push(new LY(a,n,r,e));return i.length==1?i[0]:new e(i)}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 e=this.heap.length>>1;e>=0;e--)zY(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)zY(this.heap,e);(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(),zY(this.heap,0)}}};function zY(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var BY=class{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=RY.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){UY(this.active,e),UY(this.activeTo,e),UY(this.activeRank,e),this.minActive=GY(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;WY(this.active,t,n),WY(this.activeTo,t,r),WY(this.activeRank,t,i),e&&WY(e,t,this.cursor.from),this.minActive=GY(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-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&&UY(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[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 VY(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&OY(e.point,n.point)&&HY(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&=(a.boundChange(s),!1),d>s&&!HY(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&d<o&&(r||e.openEnd(u)!=n.openEnd(u))&&(t=!0)),u>o)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function HY(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!OY(e[n],t[n]))return!1;return!0}function UY(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function WY(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function GY(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function KY(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)e.charCodeAt(i)==9?(r+=t-r%t,i++):(r++,i=vJ(e,i));return r}function qY(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=vJ(e,r)}return r===!0?-1:e.length}Lo(`DocError`);var JY=new TextEncoder;function YY(e){return G(JY.encode(e).length,`../doc/src/edit.ts#utf8Length`)}var XY=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r)setTimeout(function(){r(e)},0);else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h)d[r]=void 0;else{if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},ZY=new class extends XY{};function QY(e,t,n){return ZY.diff(e,t,n)}function $Y(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function eX(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function tX(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function nX(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function rX(e,t){return tX(e,t,``)}function iX(e,t){return nX(e,t,``)}function aX(e,t){return t.slice(0,oX(e,t))}function oX(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function sX(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function cX(e,t){if(t)return uX(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function lX(e,t){if(t)return uX(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function uX(e,t){if(!t)return[lX(e),cX(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=sX(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var dX=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,fX=RegExp(`[${dX}]+|\\s+|[^${dX}]`,`ug`);new class extends XY{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=sX(e,r)}else n=e.match(fX)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&pX(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&pX(n,i,r,null,t.intlSegmenter),e}};function pX(e,t,n,r,i){if(t&&n){let[a,o]=uX(t.value,i),[s,c]=uX(n.value,i);if(e){let r=$Y(a,s);e.value=nX(e.value,s,r),t.value=rX(t.value,r),n.value=rX(n.value,r)}if(r){let e=eX(o,c);r.value=tX(r.value,c,e),t.value=iX(t.value,e),n.value=iX(n.value,e)}}else if(n){if(e){let e=lX(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=lX(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=lX(r.value,i),[a,o]=uX(t.value,i),s=$Y(n,a);t.value=rX(t.value,s);let c=eX(rX(n,s),o);t.value=iX(t.value,c),r.value=tX(r.value,n,c),e.value=nX(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=lX(r.value,i),n=aX(cX(t.value,i),e);t.value=iX(t.value,n)}else if(e){let n=aX(cX(e.value,i),lX(t.value,i));t.value=rX(t.value,n)}}new class extends XY{tokenize(e){let t=RegExp(`(\\r?\\n)|[${dX}]+|[^\\S\\n\\r]+|[^${dX}]`,`ug`);return e.match(t)||[]}},new class extends XY{constructor(){super(...arguments),this.tokenize=mX}equals(e,t,n){return n.ignoreWhitespace?(n.newlineIsToken&&e.includes(`
|
|
107
|
-
`)||(e=e.trim()),n.newlineIsToken&&t.includes(`
|
|
108
|
-
`)||(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
109
|
-
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
110
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function mX(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
111
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function hX(e){return e==`.`||e==`!`||e==`?`}new class extends XY{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(hX(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends XY{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends XY{constructor(){super(...arguments),this.tokenize=mX}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(gX(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function gX(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a=0;for(;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=gX(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=gX(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}var _X=new class extends XY{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function vX(e,t,n){return _X.diff(e,t,n)}var yX=16384,bX=250;function xX(e,t=0){let n=[],r=t,i=r,a=[];function o(){(i!==r||a.length)&&n.push({from:i,to:r,insert:a.join(``)}),a=[]}for(let t of e)t.added?a.push(t.value):t.removed?r+=t.value.length:(o(),r+=t.value.length,i=r);return o(),G(n,`../doc/src/diff.ts#replacements`)}function SX(e,t){if(e===t)return G([],`../doc/src/diff.ts#edits`);let n=performance.now()+bX,r=e.match(/[^\n]*\n|[^\n]+$/g)??[],i=t.match(/[^\n]*\n|[^\n]+$/g)??[],a=n-performance.now(),o=a>0?vX(r,i,{timeout:a}):void 0;if(!o)return G([{from:0,to:e.length,insert:t}],`../doc/src/diff.ts#edits`);let s=xX(o.map(e=>G({...e,value:e.value.join(``)},`../doc/src/diff.ts#anonymous`))),c=[];for(let t of s){let r=e.slice(t.from,t.to),i=n-performance.now();if(!r||!t.insert||i<=0||YY(r)>yX||YY(t.insert)>yX){c.push(t);continue}let a=QY(r,t.insert,{timeout:Math.min(bX/4,i)});a?c.push(...xX(a,t.from)):c.push(t)}return G(c,`../doc/src/diff.ts#edits`)}function CX(e){let t=[],n=null,r=0;for(;;){let i=e.indexOf(`
|
|
112
|
-
`,r),a=i===-1?e.length:i,o=a>r&&e[a-1]===`\r`?a-1:a,s=e.slice(r,o),c=/^[ \t]*/.exec(s)[0],l=s.slice(c.length),u=r+c.length,d={from:r,to:o,indent:c.length,depth:[...c].reduce((e,t)=>G(e+(t===` `?4:1),`../doc/src/markdown.ts#anonymous`),0),content:u,kind:`paragraph`};if(n){let e=0;for(;l[e]===n.marker;)e++;e>=n.count&&!l.slice(e).trim()?(d.kind=`fence`,n=null):d.kind=`code`}else{let e=/^(`{3,}|~{3,})(.*)$/.exec(l),t=/^(#{1,6})(?: |$)/.exec(l),r=/^(?:[-*+]|[0-9]{1,9}[.)])(?:[ \t]|$)/.exec(l);if(e&&(e[1][0]===`~`||!e[2].includes("`")))n={marker:e[1][0],count:e[1].length},d.kind=`fence`;else if(!l)d.kind=`blank`;else if(t)d.kind=`heading`,d.level=t[1].length,d.content=u+t[0].length;else if(/^(?:-(?: *-){2,}|\*(?: *\*){2,}|_(?: *_){2,})\s*$/.test(l))d.kind=`rule`;else if(l.startsWith(`>`))d.kind=`quote`;else if(r){d.kind=`item`,d.content=u+r[0].length;let e=/^\[([ xX-])\](?:[ \t]|$)/.exec(l.slice(r[0].length));e&&(d.checkbox=d.content,d.content+=e[0].length,d.state=e[1]===` `?`open`:e[1]===`-`?`cancelled`:`done`)}}if(t.push(d),i===-1)return G(t,`../doc/src/markdown.ts#lines`);r=a+1}}function wX(e,t){let n=e[t].depth,r=t+1;for(let t=r;t<e.length;t++){let i=e[t];if(i.kind!==`blank`){if(i.depth<=n||i.kind===`heading`)break;r=t+1}}return G(r,`../doc/src/markdown.ts#blockEnd`)}function TX(e){return G(e.toLowerCase().replace(/[^\p{L}\p{N} _-]/gu,``).replace(/ /g,`-`),`../doc/src/section.ts#slug`)}function EX(e){let t=[],n=new Map;for(let[r,i]of CX(e).entries()){if(i.kind!==`heading`||i.level>3)continue;let a=e.slice(i.content,i.to).trim().replace(/#+$/,``).trim(),o=TX(a),s=n.get(o)??0;n.set(o,s+1);let c=t.at(-1);c&&(c.to=i.from),t.push({id:s?`${o}-${s}`:o,title:a,level:i.level,line:r,from:i.from,to:e.length})}return G(t,`../doc/src/section.ts#sections`)}var DX=`started|done|cancelled`;function OX(e){return G(RegExp(`(?:^|[ \\t]+)@(?:${e??DX})(?![A-Za-z0-9_])(?:[ \\t]*\\([^()\\r\\n]*\\))?`,`g`),`../doc/src/stamp.ts#stampPattern`)}function kX(e,t){return G(e.replace(OX(t),``),`../doc/src/stamp.ts#removeStamp`)}function AX(e,t){return G(OX(t).test(e),`../doc/src/stamp.ts#hasStamp`)}function jX(e,t){let n=CX(e)[t.line];return!n||n.state===void 0?G(null,`../doc/src/stamp.ts#taskLabel`):G({from:n.content,to:n.to,body:e.slice(n.content,n.to)},`../doc/src/stamp.ts#taskLabel`)}function MX(e,t){let n=/[ \t]*$/.exec(e),r=e.slice(0,n.index),i=/[ \t]+@project(?:[ \t]*\([^()\r\n]*\))?$/.exec(r),a=(i?r.slice(0,i.index):r).trimEnd();return G(`${a?`${a} ${t}`:t}${i?.[0]??``}${n[0]}`,`../doc/src/stamp.ts#stampText`)}function NX(e,t,n){let r=jX(e,t);if(!r)return G([],`../doc/src/stamp.ts#labelEdit`);let i=n(r.body);return G(i===r.body?[]:[{from:r.from,to:r.to,insert:i}],`../doc/src/stamp.ts#labelEdit`)}function PX(e,t){let n=IX(t);return G(e===`started`?`@${e}(${n})`:`@${e} (${n})`,`../doc/src/stamp.ts#stampTextFor`)}function FX(e,t,n){let r=CX(e)[t.line];if(!r||r.checkbox===void 0||r.state===n)return G([],`../doc/src/stamp.ts#checkboxEdit`);let i=n===`done`?`[x]`:n===`cancelled`?`[-]`:`[ ]`;return G([{from:r.checkbox,to:r.checkbox+3,insert:i}],`../doc/src/stamp.ts#checkboxEdit`)}function IX(e){let t=e=>G(String(e).padStart(2,`0`),`../doc/src/stamp.ts#two`);return G(`${t(e.getFullYear()%100)}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`,`../doc/src/stamp.ts#formatStamp`)}function LX(e,t,n,r){let i=CX(e)[t.line]?.state,a=FX(e,t,n),o=n===`done`?`done`:n===`cancelled`?`cancelled`:null,s=NX(e,t,e=>{let t=e;return t=n===`done`?kX(t,`cancelled`):n===`cancelled`?kX(t,`done`):kX(kX(t,`done`),`cancelled`),o&&(i!==n||!AX(t,o))&&(t=MX(kX(t,o),PX(o,r))),G(t,`../doc/src/stamp.ts#anonymous~3`)});return G([...a,...s].sort((e,t)=>G(e.from-t.from||e.to-t.to,`../doc/src/stamp.ts#anonymous~4`)),`../doc/src/stamp.ts#setTodoStateStamped`)}function RX(e){let t=[],n=null,r=new Map(EX(e).map(e=>G([e.line,e.id],`../doc/src/todo.ts#anonymous`)));for(let[i,a]of CX(e).entries()){let o=r.get(i);o!==void 0&&(n=o),a.state!==void 0&&t.push({number:t.length+1,line:i,state:a.state,text:e.slice(a.content,a.to).trim(),indent:a.depth,section:n})}return G(t,`../doc/src/todo.ts#todos`)}for(var zX=(e,t,n)=>{let r=SX(e,t),i=SX(e,n),a=e=>G(`${e.from}:${e.to}:${e.insert}`,`src/editor/changes.ts#key`),o=new Set(i.map(a)),s=r.filter(e=>G(o.has(a(e)),`src/editor/changes.ts#anonymous`)),c=new Set(s.map(a)),l=e=>G(c.has(a(e)),`src/editor/changes.ts#isShared`),u=DJ.of(s,e.length,`
|
|
113
|
-
`),d=DJ.of(r.filter(e=>G(!l(e),`src/editor/changes.ts#anonymous~2`)),e.length,`
|
|
114
|
-
`).map(u),f=DJ.of(i.filter(e=>G(!l(e),`src/editor/changes.ts#anonymous~3`)),e.length,`
|
|
115
|
-
`).map(u);return G(d.map(f,!0),`src/editor/changes.ts#rebaseRemote`)},BX=`ͼ`,VX=typeof Symbol>`u`?`__ͼ`:Symbol.for(BX),HX=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),UX=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},WX=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(`
|
|
116
|
-
`)}static newName(){let e=UX[VX]||1;return UX[VX]=e+1,BX+e.toString(36)}static mount(e,t,n){let r=e[HX],i=n&&n.nonce;r?i&&r.setNonce(i):r=new KX(e,i),r.mount(Array.isArray(t)?t:[t],e)}},GX=new Map,KX=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=GX.get(n);if(t)return e[HX]=t;this.sheet=new r.CSSStyleSheet,GX.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[HX]=this}mount(e,t){let n=this.sheet,r=0,i=0,a=!1;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),a=!0,i--,s=-1),s==-1){if(this.modules.splice(i++,0,o),a=!0,n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],r++)}else{for(;i<s;)r+=this.modules[i++].rules.length;r+=o.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{if(a){let e=``;for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+`
|
|
117
|
-
`;this.styleTag.textContent=e}let e=t.head||t;this.styleTag.parentNode!=e&&e.insertBefore(this.styleTag,e.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},qX={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},JX={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},YX=typeof navigator<`u`&&/Mac/.test(navigator.platform),XX=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ZX=0;ZX<10;ZX++)qX[48+ZX]=qX[96+ZX]=String(ZX);for(var ZX=1;ZX<=24;ZX++)qX[ZX+111]=`F`+ZX;for(var ZX=65;ZX<=90;ZX++)qX[ZX]=String.fromCharCode(ZX+32),JX[ZX]=String.fromCharCode(ZX);for(var QX in qX)JX.hasOwnProperty(QX)||(JX[QX]=qX[QX]);function $X(e){var t=!(YX&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||XX&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?JX:qX)[e.keyCode]||e.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 eZ(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n==`object`&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i==`string`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t<arguments.length;t++)tZ(e,arguments[t]);return e}function tZ(e,t){if(typeof t==`string`)e.appendChild(document.createTextNode(t));else if(t!=null){if(t.nodeType!=null)e.appendChild(t);else if(Array.isArray(t))for(var n=0;n<t.length;n++)tZ(e,t[n]);else throw RangeError(`Unsupported child node: `+t)}}var nZ=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},rZ=typeof document<`u`?document:{documentElement:{style:{}}},iZ=/Edge\/(\d+)/.exec(nZ.userAgent),aZ=/MSIE \d/.test(nZ.userAgent),oZ=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nZ.userAgent),sZ=!!(aZ||oZ||iZ),cZ=!sZ&&/gecko\/(\d+)/i.test(nZ.userAgent),lZ=!sZ&&/Chrome\/(\d+)/.exec(nZ.userAgent),uZ=`webkitFontSmoothing`in rZ.documentElement.style,dZ=!sZ&&/Apple Computer/.test(nZ.vendor),fZ=dZ&&(/Mobile\/\w+/.test(nZ.userAgent)||nZ.maxTouchPoints>2),Y={mac:fZ||/Mac/.test(nZ.platform),windows:/Win/.test(nZ.platform),linux:/Linux|X11/.test(nZ.platform),ie:sZ,ie_version:aZ?rZ.documentMode||6:oZ?+oZ[1]:iZ?+iZ[1]:0,gecko:cZ,gecko_version:cZ?+(/Firefox\/(\d+)/.exec(nZ.userAgent)||[0,0])[1]:0,chrome:!!lZ,chrome_version:lZ?+lZ[1]:0,ios:fZ,android:/Android\b/.test(nZ.userAgent),webkit:uZ,webkit_version:uZ?+(/\bAppleWebKit\/(\d+)/.exec(nZ.userAgent)||[0,0])[1]:0,safari:dZ,safari_version:dZ?+(/\bVersion\/(\d+(\.\d+)?)/.exec(nZ.userAgent)||[0,0])[1]:0,tabSize:rZ.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function pZ(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var mZ=Object.create(null);function hZ(e,t,n){if(e==t)return!0;e||=mZ,t||=mZ;let r=Object.keys(e),i=Object.keys(t);if(r.length-0!=i.length-0)return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function gZ(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function _Z(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function vZ(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var yZ=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},bZ=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(bZ||={}),xZ=class extends DY{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new SZ(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new wZ(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:i,end:a}=TZ(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new wZ(e,n,r,t,e.widget||null,!0)}static line(e){return new CZ(e)}static set(e,t=!1){return MY.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};xZ.none=MY.empty;var SZ=class e extends xZ{constructor(e){let{start:t,end:n}=TZ(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?pZ(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||mZ}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&hZ(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};SZ.prototype.point=!1;var CZ=class e extends xZ{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&hZ(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};CZ.prototype.mapMode=TJ.TrackBefore,CZ.prototype.point=!0;var wZ=class e extends xZ{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?TJ.TrackBefore:TJ.TrackAfter:TJ.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?bZ.WidgetBefore:bZ.WidgetAfter:bZ.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&EZ(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};wZ.prototype.point=!0;function TZ(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function EZ(e,t){return e==t||!!(e&&t&&e.compare(t))}function DZ(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var OZ=class e extends DY{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&hZ(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||mZ,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return MY.of(e,t)}};OZ.prototype.startSide=OZ.prototype.endSide=-1;var kZ=e=>e.nodeType==1,AZ=e=>e.nodeType==3;function jZ(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function MZ(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function NZ(e,t){if(!t.anchorNode)return!1;try{return MZ(e,t.anchorNode)}catch{return!1}}function PZ(e){return AZ(e)?ZZ(e,0,e.nodeValue.length).getClientRects():kZ(e)?e.getClientRects():[]}function FZ(e,t,n,r){return n?RZ(e,t,n,r,-1)||RZ(e,t,n,r,1):!1}function IZ(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function LZ(e){return kZ(e)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function RZ(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:zZ(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||!kZ(n))return!1;t=IZ(e)+(i<0?0:1),e=n}else if(kZ(e)){if(e=e.childNodes[t+(i<0?-1:0)],kZ(e)&&(e.nodeName==`IMG`||e.nodeName==`BR`||e.contentEditable==`false`))return!1;t=i<0?zZ(e):0}else return!1}}function zZ(e){return AZ(e)?e.nodeValue.length:e.childNodes.length}function BZ(e,t){let{left:n,right:r}=e;if(n==r)return e;let i=t?n:r;return{left:i,right:i,top:e.top,bottom:e.bottom}}function VZ(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function HZ(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function UZ(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(kZ(u)){let e,f=u==c.body,p=1,m=1,h=!0,g=!0;if(f)e=VZ(l);else{let t=getComputedStyle(u);if(/^(fixed|sticky)$/.test(t.position)&&(d=!0),(u.scrollHeight<=u.clientHeight||!/auto|scroll/.test(t.overflowY))&&(g=!1),(u.scrollWidth<=u.clientWidth||!/auto|scroll/.test(t.overflowX))&&(h=!1),!h&&!g){u=u.assignedSlot||u.parentNode;continue}let n=u.getBoundingClientRect();({scaleX:p,scaleY:m}=HZ(u,n)),e={left:n.left,right:n.left+u.clientWidth*p,top:n.top,bottom:n.top+u.clientHeight*m}}let _=0,v=0;if(g){if(i==`nearest`)t.top<e.top+o?(v=t.top-(e.top+o),n>0&&t.bottom>e.bottom+v&&(v=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(v=t.bottom-e.bottom+o,n<0&&t.top-v<e.top&&(v=t.top-(e.top+o)));else{let r=t.bottom-t.top,a=e.bottom-e.top;v=(i==`center`&&r<=a?t.top+r/2-a/2:i==`start`||i==`center`&&n<0?t.top-o:t.bottom-a+o)-e.top}}if(h&&(r==`nearest`?t.left<e.left+a?(_=t.left-(e.left+a),n>0&&t.right>e.right+_&&(_=t.right-e.right+a)):t.right>e.right-a&&(_=t.right-e.right+a,n<0&&t.left<e.left+_&&(_=t.left-(e.left+a))):_=(r==`center`?t.left+(t.right-t.left)/2-(e.right-e.left)/2:r==`start`==s?t.left-a:t.right-(e.right-e.left)+a)-e.left),_||v){if(f)l.scrollBy(_,v);else{let e=0,n=0;if(v){let e=u.scrollTop;u.scrollTop+=v/m,n=(u.scrollTop-e)*m}if(_){let t=u.scrollLeft;u.scrollLeft+=_/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-_)<1&&(r=`nearest`),n&&Math.abs(n-v)<1&&(i=`nearest`)}}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function WZ(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(kZ(a))!i&&a.scrollHeight>a.clientHeight&&/scroll|auto/.test(getComputedStyle(a).overflowY)&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&/scroll|auto/.test(getComputedStyle(a).overflowX)&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var GZ=class{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?zZ(t):0),n,Math.min(e.focusOffset,n?zZ(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function KZ(e){let t=[];for(let n=e;n;n=n.nodeType==11?n.host:n.parentNode)kZ(n)&&t.push({node:n,left:n.scrollLeft,top:n.scrollTop});return t}function qZ(e,t=!0){for(let{node:n,left:r,top:i}of e)t&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}var JZ=null;Y.safari&&Y.safari_version>=26&&(JZ=!1);function YZ(e){if(e.setActive)return e.setActive();if(JZ)return e.focus(JZ);let t=KZ(e);e.focus(JZ==null?{get preventScroll(){return JZ={preventScroll:!0},!0}}:void 0),JZ||(JZ=!1,qZ(t))}var XZ;function ZZ(e,t,n=t){let r=XZ||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function QZ(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function $Z(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function eQ(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,zZ(n));;)if(r){if(!kZ(n))return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=zZ(n))}else if(n==e)return!0;else r=IZ(n),n=n.parentNode}function tQ(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function nQ(e,t){for(let n=e,r=t;;)if(AZ(n)&&r>0)return{node:n,offset:r};else if(kZ(n)&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=zZ(n)}else if(n.parentNode&&!LZ(n))r=IZ(n),n=n.parentNode;else return null}function rQ(e,t){for(let n=e,r=t;;)if(AZ(n)&&r<n.nodeValue.length)return{node:n,offset:r};else if(kZ(n)&&r<n.childNodes.length){if(n.contentEditable==`false`)return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!LZ(n))r=IZ(n)+1,n=n.parentNode;else return null}var iQ=class e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(t,n){return new e(t.parentNode,IZ(t),n)}static after(t,n){return new e(t.parentNode,IZ(t)+1,n)}},aQ=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(aQ||={}),oQ=aQ.LTR,sQ=aQ.RTL;function cQ(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var lQ=cQ(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),uQ=cQ(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),dQ=Object.create(null),fQ=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);dQ[t]=n,dQ[n]=-t}function pQ(e){return e<=247?lQ[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?uQ[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var mQ=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,hQ=class{get dir(){return this.level%2?sQ:oQ}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.from<t:o.to>t))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function gQ(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!gQ(r.inner,i.inner))return!1}return!0}var _Q=[];function vQ(e,t,n,r,i){for(let a=0;a<=r.length;a++){let o=a?r[a-1].to:t,s=a<r.length?r[a].from:n,c=a?256:i;for(let t=o,n=c,r=c;t<s;t++){let i=pQ(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),_Q[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=_Q[e];if(i==128)e<s-1&&t==_Q[e+1]&&t&24?i=_Q[e]=t:_Q[e]=256;else if(i==64){let i=e+1;for(;i<s&&_Q[i]==64;)i++;let a=e&&t==8||i<n&&_Q[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)_Q[t]=a;e=i-1}else i==8&&r==1&&(_Q[e]=1);t=i,i&7&&(r=i)}}}function yQ(e,t,n,r,i){let a=i==1?2:1;for(let o=0,s=0,c=0;o<=r.length;o++){let l=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let t=l,n,r,o;t<u;t++)if(r=dQ[n=e.charCodeAt(t)]){if(r<0){for(let e=s-3;e>=0;e-=3)if(fQ[e+1]==-r){let n=fQ[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(_Q[t]=_Q[fQ[e]]=r),s=e;break}}else if(fQ.length==189)break;else fQ[s++]=t,fQ[s++]=n,fQ[s++]=c}else if((o=_Q[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=fQ[t+2];if(n&2)break;if(e)fQ[t+2]|=2;else{if(n&4)break;fQ[t+2]|=4}}}}}function bQ(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=i<n.length?n[i].from:t;for(let c=o;c<s;){let o=_Q[c];if(o==256){let o=c+1;for(;;)if(o==s){if(i==n.length)break;o=n[i++].to,s=i<n.length?n[i].from:t}else if(_Q[o]==256)o++;else break;let l=a==1,u=l==((o<t?_Q[o]:r)==1)?l?1:2:r;for(let t=o,r=i,a=r?n[r-1].to:e;t>c;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),_Q[--t]=u;c=o}else a=o,c++}}}function xQ(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;c<n;){let t=!0,u=!1;if(l==a.length||c<a[l].from){let e=_Q[c];e!=s&&(t=!1,u=e==16)}let d=!t&&s==1?[]:null,f=t?r:r+1,p=c;run:for(;;)if(l<a.length&&p==a[l].from){if(u)break run;let m=a[l];if(!t)for(let e=m.to,t=l+1;;){if(e==n)break run;if(t<a.length&&a[t].from==e)e=a[t++].to;else if(_Q[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new hQ(c,m.from,f)),SQ(e,m.direction==oQ==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?_Q[p]!=s:_Q[p]==s))break;else p++;d?xQ(e,c,p,r+1,i,d,o):c<p&&o.push(new hQ(c,p,f)),c=p}else for(let c=n,l=a.length;c>t;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=_Q[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(_Q[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new hQ(m.to,c,f)),SQ(e,m.direction==oQ==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?_Q[p-1]!=s:_Q[p-1]==s))break;else p--;d?xQ(e,p,c,r+1,i,d,o):p<c&&o.push(new hQ(p,c,f)),c=p}}function SQ(e,t,n,r,i,a,o){let s=t%2?2:1;vQ(e,i,a,r,s),yQ(e,i,a,r,s),bQ(i,a,r,s),xQ(e,i,a,t,n,r,o)}function CQ(e,t,n){if(!e)return[new hQ(0,0,+(t==sQ))];if(t==oQ&&!n.length&&!mQ.test(e))return wQ(e.length);if(n.length)for(;e.length>_Q.length;)_Q[_Q.length]=256;let r=[],i=t==oQ?0:1;return SQ(e,i,i,n,0,e.length,r),r}function wQ(e){return[new hQ(0,e,0)]}var TQ=``;function EQ(e,t,n,r,i){if(!e.length)return null;let a=r.head-e.from,o;if(r.head==e.from&&r.assoc<0){if(!i)return null;a=t[o=0].side(!1,n)}else if(r.head==e.to&&r.assoc>0){if(i)return null;a=t[o=t.length-1].side(!0,n)}else o=hQ.find(t,a,r.bidiLevel??-1,r.assoc);let s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=vJ(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),TQ=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];if(l==c){if(!u)return i?q.cursor(e.to,1):q.cursor(e.from,-1);if(u.level+ +!i<s.level)return q.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level)}return q.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function DQ(e,t,n){for(let r=t;r<n;r++){let t=pQ(e.charCodeAt(r));if(t==1)return oQ;if(t==2||t==4)return sQ}}var OQ=J.define(),kQ=J.define(),AQ=J.define(),jQ=J.define(),MQ=J.define(),NQ=J.define(),PQ=J.define(),FQ=J.define(),IQ=J.define(),LQ=J.define({combine:e=>e.some(e=>e)}),RQ=J.define({combine:e=>e.some(e=>e)}),zQ=J.define(),BQ=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(q.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},VQ=uY.define({map:(e,t)=>e.map(t)}),HQ=uY.define();function UQ(e,t,n){let r=e.facet(jQ);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var WQ=J.define({combine:e=>!e.length||e[0]}),GQ=0,KQ=J.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),qQ=class e{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(KQ.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(KQ.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(GQ++,t,r,i,e=>{let t=[];return o&&t.push(ZQ.of(t=>{let n=t.plugin(e);return n?o(n):xZ.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},JQ=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){UQ(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(UQ(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){UQ(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},YQ=J.define(),XQ=J.define(),ZQ=J.define(),QQ=J.define(),$Q=J.define(),e$=J.define(),t$=J.define();function n$(e,t){let n=e.state.facet(t$);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return MY.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let t=r[e].spec.bidiIsolate,n;if(a>0&&c.length&&(n=c[c.length-1]).to==o&&n.direction==t)n.to=s,c=n.inner;else{let e={from:o,to:s,direction:t,inner:[]};c.push(e),c=e.inner}}}}),r$(t.text,i)}function r$(e,t){for(let n of t){if(n.direction==null){for(let t=n.from,r=0;t<n.to;r++){let i=r<n.inner.length?n.inner[r]:null,a=DQ(e,t,i?i.from:n.to);if(a){n.direction=a;break}if(!i)break;t=i.to}n.direction??=aQ.LTR}r$(e,n.inner)}return t}var i$=J.define();function a$(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(i$)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var o$=J.define(),s$=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.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.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,a=0,o=0;;){let s=i<t.length?t[i].fromB:1e9,c=a<n.length?n[a]:1e9,l=Math.min(s,c);if(l==1e9)break;let u=l+o,d=l,f=u;for(;;)if(a<n.length&&n[a]<=d){let e=n[a+1];a+=2,d=Math.max(d,e);for(let e=i;e<t.length&&t[e].fromB<=d;e++)o=t[e].toA-t[e].toB;f=Math.max(f,e+o)}else if(i<t.length&&t[i].fromB<=d){let e=t[i++];d=Math.max(d,e.toB),f=Math.max(f,e.toA),o=e.toA-e.toB}else break;r.push(new e(u,f,l,d))}return r}},c$=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=DJ.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new s$(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>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}},l$=[],u$=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return l$}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&gZ(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,n){return null}domPosFor(e,t){let n=IZ(this.dom),r=this.length?e>0:t>0;return new iQ(this.parent.dom,n+ +!!r,e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof p$)return e;return null}static get(e){return e.cmTile}},d$=class extends u${constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=f$(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=f$(r);this.length=a}};function f$(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var p$=class extends d${constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=u$.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof m$)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(s<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-s),(c>e||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},m$=class e extends d${constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},h$=class e extends d${constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return n&&r||(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n=!1){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l<e.children.length&&u<=c;l++){let d=e.children[l],f=u+d.length;f>=c&&(d.isComposite()?s(d,c-u):(!a||n&&a.isHidden&&(t>0&&!(a.flags&32)||n&&_$(a,d)))&&(f>c||d.flags&32&&t<=1)?(a=d,o=c-u):(u<c||d.flags&16&&!(n&&d.isHidden)&&t>=-1)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t,n){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,n):g$(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new iQ(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new iQ(e.dom,0);e==n.tile&&(a=!0)}}return new iQ(this.dom,0)}};function g$(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=PZ(t);return n[n.length-1]||null}function _$(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var v$=class e extends d${constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},y$=class e extends u${constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,n){let r=this.dom.nodeValue.length;e>r&&(e=r);let i=e,a=e,o=0;e==0&&t<0||e==r&&t>=0?Y.chrome||Y.gecko||(e?(i--,o=1):a<r&&(a++,o=-1)):t<0?i--:a<r&&a++;let s=ZZ(this.dom,i,a).getClientRects();if(!s.length)return null;let c=s[(o?o<0:t>=0)?0:s.length-1];return Y.safari&&!o&&c.width==0&&(c=Array.prototype.find.call(s,e=>e.width)||c),n==null?c:BZ(c,(o?o>0:t<0)==n)}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},b$=class e extends u${constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return BZ(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return BZ(n,!r)}}get overrideDOMText(){if(!this.length)return sJ.empty;let{root:e}=this;if(!e)return sJ.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,a){return a||(a=t.toDOM(n),t.editable||(a.contentEditable=`false`)),new e(a,r,t,i)}},x$=class extends u${constructor(e){let t=document.createElement(`img`);t.className=`cm-widgetBuffer`,t.setAttribute(`aria-hidden`,`true`),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return sJ.empty}coordsIn(e,t,n){let r=this.dom.getBoundingClientRect();return n==null?r:BZ(r,t>0==n)}},S$=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite()){let t=r.length;if(i<t&&e){let a=Math.min(e,t-i);n&&n.skip(r,i,i+a),e-=a,i+=a}if(i==t)a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(!e)break}else if(a){if(!e)break;n&&n.break(),e--,a=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let s=r.children[i],c=s.breakAfter;(t>0?s.length<=e:s.length<e)&&(!n||n.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!c,i++,e-=s.length):(o.push({tile:r,index:i}),r=s,i=0,n&&s.isComposite()&&n.enter(s))}return this.tile=r,this.index=i,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},C$=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},w$=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){this.flushBuffer();let i=this.ensureMarks(t,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let t=i.children[i.children.length-1]=new y$(a.dom,a.text+e);t.parent=i}else i.append(r||y$.of(e,this.cache.find(y$)?.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?P$(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof v$&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(P$(n.dom)),r=i;else{let{dom:e}=n;this.cache.reused.get(n)&&u$.get(n.dom)&&(e=P$(n.dom));let t=v$.of(n.mark,e);r.append(t),r=t}this.cache.reused.set(n,2)}let i=u$.get(e.text);i&&this.cache.reused.set(i,2);let a=new y$(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=j$;let n=h$.start(e,t||this.cache.find(h$)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof v$&&a.mark.eq(i))n=a,t--;else{let e=v$.of(i,this.cache.find(v$,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!k$(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(Y.ios&&k$(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(I$,0,32)||new b$(I$.toDOM(),0,I$,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new C$(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.from<this.pos&&n instanceof m$&&n.wrapper.eq(t.wrapper))e=n;else{let n=m$.of(t.wrapper,this.cache.find(m$,e=>e.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(x$,void 0,1);return n&&(n.flags=t),n||new x$(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},T$=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},E$=[b$,h$,y$,v$,x$,m$,p$];for(let e=0;e<E$.length;e++)E$[e].bucket=e;var D$=class{constructor(e){this.view=e,this.buckets=E$.map(()=>[]),this.index=E$.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=0;e<i.length;e++){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o<a&&this.index[r]--,this.reused.set(s,n),s}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,a=0;;i++){if(i==r.length){if(a)return null;a=1,i=0}let o=r[i];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new b$(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},O$=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new D$(e),this.text=new T$(e.state.doc),this.builder=new w$(this.cache,new p$(e,e.contentDOM),MY.iter(n)),this.cache.reused.set(t,2),this.old=new S$(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=a<e.length?e[a++]:null,s=o?o.fromA:this.old.root.length;if(s>r){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=N$(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget()){if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t<e.length?b$.of(e.widget,this.view,n-t,e.flags&496,this.cache.maybeReuse(e)):this.cache.reuse(e);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,r,i),i=r.length)}}else if(e.isText())this.builder.ensureLine(null),!t&&n==e.length&&!this.cache.reused.has(e)?this.builder.addText(e.text,r,i,this.cache.reuse(e)):(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof x$)this.cache.add(e);else if(e instanceof v$)this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length;else return!1;this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof v$&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof v$&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=-1,a=MY.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof wZ){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?F$.block:F$.inline),c=A$(a),l=this.cache.findWidget(i,t-e,c)||b$.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=M$(n,a);t>e&&this.text.skip(t-e)},span:(e,t,a,o)=>{for(let i=e;i<t;){let s=this.text.next(Math.min(512,t-i));s==null?(r.addLineStartIfNotCovered(n),r.addBreak(),i++):(r.ensureLine(n),r.addText(s,a,i==e?o:a.length),i+=s.length),n=null}i=a.length}});i>-1&&(this.openWidget=a>i),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=u$.get(r);if(r==this.view.contentDOM)break;e instanceof v$?t.push(e):e?.isLine()?n=e:e instanceof m$||(r.nodeName==`DIV`&&!n?n=new h$(r,j$):n||t.push(v$.of(new SZ({tagName:r.nodeName.toLowerCase(),attributes:vZ(r)}),r)))}return n?{line:n,marks:t}:null}};function k$(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function A$(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var j$={class:`cm-line`};function M$(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||={class:`cm-line`},n&&pZ(n,e),r&&(e.class+=` `+r)),e}function N$(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof v$&&t.push(r.mark)}return t}function P$(e){let t=u$.get(e);return t&&t.setDOM(e.cloneNode()),e}var F$=class extends yZ{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}};F$.inline=new F$(`span`),F$.block=new F$(`div`);var I$=new class extends yZ{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},L$=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=xZ.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new p$(e,e.contentDOM),this.updateInner([new s$(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!J$(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?V$(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new s$(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Y.ie||Y.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=W$(i,this.decorations,e.changes);o.length&&(t=s$.extendWithRanges(t,o));let s=K$(a,this.blockWrappers,e.changes);return s.length&&(t=s$.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new O$(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&u$.get(t.text)&&r.cache.reused.set(u$.get(t.text),2),this.tile=r.run(e,t),R$(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=Y.chrome||Y.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof Y$&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(HQ)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,a=!i&&!(this.view.state.facet(WQ)||n.tabIndex>-1)&&NZ(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),Y.gecko&&s.empty&&!this.hasComposition&&z$(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new iQ(e,0),o=!0}let u=this.view.observer.selectionRange;!o&&u.focusNode&&(FZ(c.node,c.offset,u.anchorNode,u.anchorOffset)&&FZ(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,s))||(this.view.observer.ignore(()=>{Y.android&&Y.chrome&&n.contains(u.focusNode)&&q$(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=jZ(this.view.root);if(e){if(s.empty){if(Y.gecko){let e=H$(c.node,c.offset);if(e&&e!=3){let t=(e==1?nQ:rQ)(c.node,c.offset);t&&(c=new iQ(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new iQ(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new iQ(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&FZ(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=jZ(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=zZ(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!u$.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(r,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l<e),l>=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Y$?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,t,n)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&t<e.length){let n=vJ(e.text,t);if(n==t)return null;let r=ZZ(e.dom,t,n).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,a=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==aQ.LTR,c=0,l=(e,u,d)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof m$)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?PZ(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?aQ.RTL:aQ.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=PZ(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=PZ(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(xZ.replace({widget:new Y$(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return xZ.set(e)}updateDeco(){let e=1,t=this.view.state.facet(ZQ).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet($Q).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(MY.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(QQ).map(e=>typeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(zQ))try{if(t(this.view,e.range,e))return!0}catch(e){UQ(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc||(t.head>t.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 i=a$(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(UZ(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,s),-s),this.view.textDirection==aQ.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(t.head,1);if(e){let t=KZ(e.dom);e.dom.scrollIntoView({block:`nearest`}),qZ(t,!1)}}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){R$(this.tile)}};function R$(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)R$(n,t)}}function z$(e){return kZ(e.node)&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function B$(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=nQ(n.focusNode,n.focusOffset),i=rQ(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=u$.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=u$.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function V$(e,t,n){let r=B$(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new s$(c.mapPos(a),c.mapPos(o),a,o),text:i}}function H$(e,t){return kZ(e)?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable==`false`?2:0):0}var U$=class{constructor(){this.changes=[]}compareRange(e,t){DZ(e,t,this.changes)}comparePoint(e,t){DZ(e,t,this.changes)}boundChange(e){DZ(e,e,this.changes)}};function W$(e,t,n){let r=new U$;return MY.compare(e,t,n,r),r.changes}var G$=class{constructor(){this.changes=[]}compareRange(e,t){DZ(e,t,this.changes)}comparePoint(){}boundChange(e){DZ(e,e,this.changes)}};function K$(e,t,n){let r=new G$;return MY.compare(e,t,n,r),r.changes}function q$(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(kZ(n)&&n.contentEditable==`false`)return!0;return!1}function J$(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var Y$=class extends yZ{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function X$(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return q.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=vJ(i.text,a,!1):s=vJ(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=vJ(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=vJ(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return q.undirectionalRange(o+i.from,s+i.from)}function Z$(e,t,n,r,i){let a=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+qY(o,a,e.state.tabSize)}function Q$(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==bZ.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function $$(e,t,n,r){let i=Q$(e,t.head,t.assoc||-1),a=!r||i.type!=bZ.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAndSideAtCoords({x:n==(r==aQ.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o)return q.cursor(o.pos,o.assoc)}return q.cursor(n?i.to:i.from,n?1:-1)}function e1(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=EQ(i,a,o,s,n),l=TQ;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`
|
|
118
|
-
`,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=n?q.cursor(i.from,-1):q.cursor(i.to,1)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function t1(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==bY.Space&&(i=t),i==t}}function n1(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return q.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=s1(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return q.cursor(i.pos,i.assoc);let l=e.coordsAtPos(i.pos,i.assoc),u=l?(l.top+l.bottom)/2:0;if(!l||(n?u>s:u<s))return q.cursor(i.pos,i.assoc,void 0,o)}}function r1(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,a)=>{if(t>e&&t<i){let a=r||n||(t-e<i-t?-1:1);t=a<0?e:i,r=a}});if(!r)return t}}function i1(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],a=null;if(i.empty){let t=r1(e,i.from,0);t!=i.from&&(a=q.cursor(t,-1))}else{let t=r1(e,i.from,-1),n=r1(e,i.to,1);(t!=i.from||n!=i.to)&&(a=i.undirectional?q.undirectionalRange(i.from,i.to):q.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?q.create(n,t.mainIndex):t}function a1(e,t,n){let r=r1(e.state.facet(e$).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:q.cursor(r,r<n.from?1:-1)}var o1=class{constructor(e,t){this.pos=e,this.assoc=t}};function s1(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),a=i.top+e.viewState.paddingTop,{x:o,y:s}=t,c=s-a,l;for(;;){if(c<0)return new o1(0,1);if(c>e.viewState.docHeight)return new o1(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==bZ.Text){if(r<0?l.to<e.viewport.from:l.from>e.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==bZ.Text){let t=Z$(e,i,l,o,s);return new o1(t,t==l.from?1:-1)}}if(l.type!=bZ.Text)return c<(l.top+l.bottom)/2?new o1(l.from,1):new o1(l.to,-1);let u=e.docView.lineAt(l.from,2);return u&&u.length==l.length||(u=e.docView.lineAt(l.from,-2)),new c1(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var c1=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[hQ.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[hQ.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,i=e.length-1,a=new Set,o=this.bidiIn(e[0],e[i]),s,c,l=-1,u=1e9,d;search:for(;r<i;){let n=i-r,f=r+i>>1;adjust:if(a.has(f)){for(let e=1;e<n;e++){let t=f+e;if(t>=i&&(t-=n),!a.has(t)){f=t;break adjust}}break search}a.add(f);let p=t(f),m=0;if(p)for(let e=0;e<p.length;e++){let t=p[e];if(!(t.width==0&&p.length>1)){if(t.bottom<this.y)(!s||s.bottom<t.bottom)&&(s=t),m=1;else if(t.top>this.y)(!c||c.top>t.top)&&(c=t),m=-1;else{let e=t.left>this.x?this.x-t.left:t.right<this.x?this.x-t.right:0,n=Math.abs(e);n<u&&(l=f,u=n,d=t),e&&(m=e<0==(this.baseDir==aQ.LTR)?-1:1)}}}m==-1&&(!o||this.baseDirAt(e[f],1))?i=f:m==1&&(!o||this.baseDirAt(e[f+1],-1))&&(r=f+1)}if(!d){if(!c&&!s)return{i:0,after:!1};let n=s&&(!c||this.y-s.bottom<c.top-this.y)?s:c;return this.y=(n.top+n.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:n,bottom:r}=d;if(s&&s.bottom>(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==aQ.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=vJ(e.text,r))n.push(t+r);n.push(t+e.length);let r=this.scan(n,r=>{let i=n[r]-t,a=n[r+1]-t;return ZZ(e.dom,i,a).getClientRects()});return r.after?new o1(n[r.i+1],-1):new o1(n[r.i],1)}scanTile(e,t){if(!e.length)return new o1(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r<e.children.length;r++)n.push(i+=e.children[r].length);let r=this.scan(n,t=>{let n=e.children[t];return n.flags&48?null:(kZ(n.dom)?n.dom:ZZ(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new o1(n[r.i+1],-1):new o1(a,1)}},l1=``,u1=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(TY.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=l1}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=u$.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=u$.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:LZ(r))||LZ(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!f1(a,t)&&this.lineBreak(),r=a}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 i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=u$.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else AZ(e)?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():kZ(e)&&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)(AZ(e)?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(d1(e,n.node,n.offset)?t:0))}};function d1(e,t,n){for(;;){if(!t||n<zZ(t))return!1;if(t==e)return!0;n=IZ(t)+1,t=t.parentNode}}function f1(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=u$.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var p1=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},m1=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=h1(e.docView.tile,t,n,0))){let t=i||a?[]:b1(e),n=new u1(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=x1(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!MZ(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!MZ(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((Y.ios||Y.chrome)&&n!=r&&Math.min(n,r)<=o.main.from&&Math.max(n,r)>=o.main.to&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),a=s.from-t,o=s.to-i;a!=0&&a!=1&&t!=0||o!=0&&o!=-1&&i!=e.state.doc.length||(n=0,r=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(q.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=q.create([q.cursor(n,r)])}else this.newSel=q.single(r,n)}}};function h1(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;c<e.children.length;c++){let r=e.children[c],d=l+r.length;if(l<t&&d>n)return h1(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function g1(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||Y.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,l1),u,d;!a.empty&&a.from>=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:sJ.of(t.text.slice(a.from-e,u).split(l1))}:(d=y1(l,t.text,s-e,c))&&(Y.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==``&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:sJ.of(t.text.slice(d.from,d.toB).split(l1))})}else r&&(!e.hasFocus&&i.facet(WQ)||S1(r,a))&&(r=null);if(!n&&!r)return!1;if((Y.mac||Y.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=q.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:sJ.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).to<a.to&&e.docView.lineHasWidget(a.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:Y.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
|
|
119
|
-
`&&e.lineWrapping&&(r&&=q.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:sJ.of([` `])}),n)return _1(e,n,r,o);if(r&&!S1(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=i1(i.facet(e$).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function _1(e,t,n,r=-1){if(Y.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(Y.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&QZ(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&QZ(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&QZ(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=v1(e,t,n);return e.state.facet(NQ).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function v1(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.from<a.from||t.from>a.to){let n=t.from<a.from?-1:1,r=n<0?a.from:a.to,s=r1(i.facet(e$).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:q.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.from<t.from?i.sliceDoc(a.from,t.from):``,o=a.to>t.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&B$(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?q.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function y1(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e.charCodeAt(a)==t.charCodeAt(a);)a++;if(a==i&&e.length==t.length)return null;let o=e.length,s=t.length;for(;o>0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o<a&&e.length<t.length){let e=n<=a&&n>=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s<a){let e=n<=a&&n>=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function b1(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new p1(n,r)),(i!=n||a!=r)&&t.push(new p1(i,a))),t}function x1(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n<0||r<0?null:n==r?q.create([q.cursor(r+t,-1)]):q.single(n+t,r+t)}function S1(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var C1=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Y.safari&&e.contentDOM.addEventListener(`input`,()=>null),Y.gecko&&o0(e.contentDOM.ownerDocument)}handleEvent(e){L1(this.view,e)&&!this.ignoreDuringComposition(e)&&(e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e))))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=E1(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&k1.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Y.android&&Y.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Y.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(D1.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||O1.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&Y.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&w1(this.view.win)&&(t.shiftKey=!1);let n=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==n&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,QZ(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Y.safari&&!Y.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function w1(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function T1(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){UQ(n.state,e)}}}function E1(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(T1(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(T1(t.value,r))}}for(let e in R1)n(e).handlers.push(R1[e]);for(let e in z1)n(e).observers.push(z1[e]);return t}var D1=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],O1=`dthko`,k1=[16,17,18,20,91,92,224,225],A1=6;function j1(e){return Math.max(0,e)*.7+8}function M1(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var N1=class{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.scrollParents=WZ(e.contentDOM),this.atoms=e.state.facet(e$).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(TY.allowMultipleSelections)&&P1(e,t),this.dragging=I1(e,t)&&Y1(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&M1(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=a$(this.view);e.clientX-s.left<=r+A1?t=-j1(r-e.clientX):e.clientX+s.right>=a-A1&&(t=j1(e.clientX-a)),e.clientY-s.top<=i+A1?n=-j1(i-e.clientY):e.clientY+s.bottom>=o-A1&&(n=j1(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??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=this.view.inputState.draggedContent=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(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=i1(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function P1(e,t){let n=e.state.facet(OQ);return n.length?n[0](t):Y.mac?t.metaKey:t.ctrlKey}function F1(e,t){let n=e.state.facet(kQ);return n.length?n[0](t):Y.mac?!t.altKey:!t.ctrlKey}function I1(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=jZ(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function L1(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=u$.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var R1=Object.create(null),z1=Object.create(null),B1=Y.ie&&Y.ie_version<15||Y.ios&&Y.webkit_version<604;function V1(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),U1(e,n.value)},50)}function H1(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function U1(e,t){t=H1(e.state,FQ,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(t0!=null&&n.selection.ranges.every(e=>e.empty)&&t0==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:q.cursor(r.from+c.length,-1)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:q.cursor(e.from+t.length,-1)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}z1.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,Y.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())},z1.wheel=z1.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},R1.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),z1.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},z1.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},z1.touchend=(e,t)=>{e.inputState.touchActive=!1},R1.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(AQ))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=X1(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new N1(e,t,n,r)),r&&e.observer.ignore(()=>{YZ(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function W1(e,t,n,r){if(r==1)return q.cursor(t,n);if(r==2)return X$(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,q.undirectionalRange(a,o)}}var G1=Y.ie&&Y.ie_version<=11,K1=null,q1=0,J1=0;function Y1(e){if(!G1)return e.detail;let t=K1,n=J1;return K1=e,J1=Date.now(),q1=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(q1+1)%3:1}function X1(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=Y1(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=W1(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=W1(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?q.range(i,a,l.assoc):q.range(a,i,l.assoc)}return a?i.replaceRange(i.main.extend(l.from,l.to,l.assoc)):o&&r==1&&i.ranges.length>1&&(c=Z1(i,s.pos))?c:o?i.addRange(l):q.create([l])}}}function Z1(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return q.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}R1.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=q.undirectionalRange(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,H1(e.state,IQ,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},R1.dragend=e=>(e.inputState.draggedContent=null,!1);function Q1(e,t,n,r){if(n=H1(e.state,FQ,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&F1(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}R1.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&Q1(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=a,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData(`Text`);if(n)return Q1(e,t,n,!0),!0}return!1},R1.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=B1?null:t.clipboardData;return n?(U1(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(V1(e),!1)};function $1(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function e0(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:H1(e,IQ,t.join(e.lineBreak)),ranges:n,linewise:r}}var t0=null;R1.copy=R1.cut=(e,t)=>{if(!NZ(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=e0(e.state);if(!n&&!i)return!1;t0=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=B1?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):($1(e,n),!1)};var n0=sY.define();function r0(e,t){let n=[];for(let r of e.facet(PQ)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:n0.of(!0)}):null}function i0(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=r0(e.state,t);n?e.dispatch(n):e.update([])}},10)}z1.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),i0(e)},z1.blur=e=>{e.observer.clearSelectionRange(),i0(e)},z1.compositionstart=z1.compositionupdate=(e,t)=>{if(!e.observer.editContext&&(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0)){let{main:t}=e.state.selection;!t.empty&&e.lineBlockAt(t.from).from!=e.lineBlockAt(t.to).from&&!e.state.readOnly&&e.dispatch({changes:e.state.selection.ranges.filter(e=>!e.empty).map(e=>({from:e.from,to:e.to})),userEvent:`input`}),e.inputState.composing=0}},z1.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Y.chrome&&Y.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},z1.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},R1.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return _1(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(Y.chrome&&Y.android&&(n=D1.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Y.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),Y.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>z1.compositionend(e,t),20),!1};var a0=new Set;function o0(e){a0.has(e)||(a0.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var s0=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],c0=!1;function l0(){c0=!1}var u0=class{constructor(e){this.lineWrapping=e,this.doc=sJ.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}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)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return s0.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,a){let o=s0.indexOf(e)>-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e<a.length;e++){let t=a[e];t<0?e++:this.heightSamples[Math.floor(t*10)]=!0}}return s}},d0=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},f0=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?bZ.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof wZ?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},p0=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(p0||={}),m0=.001,h0=class e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>m0&&(c0=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,p0.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,p0.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,s<d.from&&(d=i.lineAt(s,p0.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=w0.build(n.setDoc(a),e,l,u);i=g0(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new y0(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,a=0;for(;;)if(n==r){if(i>a*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break}else if(i<a){let e=t[n++];e&&(i+=e.size)}else{let e=t[--r];e&&(a+=e.size)}let o=!1;return t[n-1]==null?(o=!0,n--):t[n]??(o=!0,r++),new x0(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function g0(e,t){return e==t?e:(e.constructor!=t.constructor&&(c0=!0),t)}h0.prototype.size=1;var _0=xZ.replace({}),v0=class extends h0{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new f0(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new f0(r,0,n,this.spaceAbove,_0):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let a=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(a):a}forEachLine(e,t,n,r,i,a){e<=i+this.length&&t>=i&&a(this.lineAt(0,p0.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},y0=class e extends v0{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new f0(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof b0&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof b0?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):h0.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(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:``})`}},b0=class e extends h0{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),a=t.doc.lineAt(i),c=o+a.length*s,l=Math.max(n,e-c/2);return new f0(a.from,a.length,l,c,0)}{let r=Math.max(0,Math.min(a-i,Math.floor((e-n)/o))),{from:s,length:c}=t.doc.line(i+r);return new f0(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==p0.ByHeight)return this.blockAt(e,n,r,i);if(t==p0.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new f0(t,r-t,0,0,0)}let{firstLine:a,perLine:o,perChar:s}=this.heightMetrics(n,i),c=n.doc.lineAt(e),l=o+c.length*s,u=c.number-a,d=r+o*u+s*(c.from-i-u);return new f0(c.from,c.length,Math.max(r,Math.min(d,r+this.height-l)),l,0)}forEachLine(e,t,n,r,i,a){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:s,perChar:c}=this.heightMetrics(n,i);for(let l=e,u=r;l<=t;){let t=n.doc.lineAt(l);if(l==e){let n=t.number-o;u+=s*n+c*(e-i-n)}let r=s+c*t.length;a(new f0(t.from,t.length,u,r,0)),u+=r,l=t.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return h0.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=m0&&(s=-2);let c=new y0(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=h0.of(r);return(s<0||Math.abs(c.height-this.height)>=m0||Math.abs(s-this.heightMetrics(t,n).perLine)>=m0)&&(c0=!0),g0(this,c)}return(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}},x0=class extends h0{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 i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let a=r+this.left.height,o=i+this.left.length+this.break,s=t==p0.ByHeight?e<a:e<o,c=s?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,a,o);if(this.break||(s?c.to<o:c.from>o))return c;let l=t==p0.ByPosNoHeight?p0.ByPosNoHeight:p0.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,t,n,r,i,a),t>=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,p0.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,Math.min(t,c.from-1),n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(Math.max(e,c.to+1),t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&S0(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),S0(i,e)}return h0.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=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);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?h0.of(this.break?[e,null,t]:[e,t]):(this.left=g0(this.left,e),this.right=g0(this.right,t),this.setHeight(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:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function S0(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof b0&&(r=e[t+1])instanceof b0&&e.splice(t-1,3,new b0(n.length+1+r.length))}var C0=5,w0=class e{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 e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof y0?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new y0(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new v0(a,r,n)):(a||i||r>=C0)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new y0(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new b0(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 y0)return e;let t=new y0(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(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+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof y0)&&!this.isCovered?this.nodes.push(new y0(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let e of this.nodes)e instanceof y0&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(t,n,r,i){let a=new e(r,t);return MY.spans(n,r,i,a,0),a.finish(r)}};function T0(e,t,n){let r=new E0;return MY.compare(e,t,n,r,0),r.changes}var E0=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&DZ(e,t,this.changes,5)}};function D0(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,a=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),s=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(kZ(t)){let n=window.getComputedStyle(t);if((t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&n.overflow!=`visible`){let n=t.getBoundingClientRect();a=Math.max(a,n.left),o=Math.min(o,n.right),s=Math.max(s,n.top),c=Math.min(t==e.parentNode?i.innerHeight:c,n.bottom)}t=n.position==`absolute`||n.position==`fixed`?t.offsetParent:t.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function O0(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function k0(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var A0=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return xZ.replace({widget:new j0(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},j0=class extends yZ{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement(`div`);return this.vertical?e.style.height=this.size+`px`:(e.style.width=this.size+`px`,e.style.height=`2px`,e.style.display=`inline-block`),e}get estimatedHeight(){return this.vertical?this.size:-1}},M0=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=R0,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=aQ.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(XQ).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new u0(n),this.stateDeco=z0(t),this.heightMap=h0.empty().applyChanges(this.stateDeco,sJ.empty,this.heightOracle.setDoc(t.doc),[new s$(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=xZ.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,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:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new N0(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?R0:B0.get(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(V0(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=z0(this.state);let r=e.changedRanges,i=s$.extendWithRanges(r,T0(n,this.stateDeco,e?e.changes:DJ.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);l0(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||c0)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<s.from||t.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&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(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(RQ)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?aQ.RTL:aQ.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=HZ(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=WZ(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=tQ(this.scrollParent||e.win);let m=(this.printing?k0:D0)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!O0(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),l0();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?h0.empty().applyChanges(this.stateDeco,sJ.empty,this.heightOracle,[new s$(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new d0(n.from,i))}c0&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}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,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new N0(r.lineAt(a-n*1e3,p0.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,p0.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<s.from||e>s.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,p0.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e<s.from?a.top:a.bottom-n,s=new N0(r.lineAt(o-500,p0.ByHeight,i,0,0).from,r.lineAt(o+n+500,p0.ByHeight,i,0,0).to)}}return s}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new N0(this.heightMap.lineAt(n,p0.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,p0.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,p0.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,p0.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>a-2e3&&i<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new A0(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,a=r<<1;if(this.defaultTextDirection!=aQ.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-r<i)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>r&&e<a){s(r,e-10,c,l),s(e+10,a,c,l);return}let f=L0(e,e=>e.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-a)<i&&!d.some(t=>e.from<t&&e.to>t));if(!f){if(a<c.to&&t&&n&&t.visibleRanges.some(e=>e.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(q.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new A0(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=bZ.Text)return;let i=P0(t.from,t.to,this.stateDeco);if(i.total<a)return;let o=this.scrollTarget?this.scrollTarget.range.head:null,c,l;if(n){let e=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,n,a;if(o!=null){let r=I0(i,o),s=((this.visibleBottom-this.visibleTop)/2+e)/t.height;n=r-s,a=r+s}else n=(this.visibleTop-t.top-e)/t.height,a=(this.visibleBottom-t.top+e)/t.height;c=F0(i,n),l=F0(i,a)}else{let n=i.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth,s=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+s<this.pixelViewport.left&&(s=n.size-n.displaySize);let u=this.pixelViewport.left+s,d=this.pixelViewport.right+s,f,p;if(o!=null){let e=I0(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=F0(i,f),l=F0(i,p)}c>t.from&&s(t.from,c,t,i),l<t.to&&s(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(c):c(e);return o}gapSize(e,t,n,r){let i=I0(r,n)-I0(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){A0.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=xZ.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];MY.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(r&8);t++){let i=this.visibleRanges[t],a=n[t];(i.from!=a.from||i.to!=a.to)&&(r|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||V0(this.heightMap.lineAt(e,p0.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||V0(this.heightMap.lineAt(this.scaler.fromDOM(e),p0.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+12-this.paddingTop);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return V0(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}},N0=class{constructor(e,t){this.from=e,this.to=t}};function P0(e,t,n){let r=[],i=e,a=0;return MY.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),a+=t-i),{total:a,ranges:r}}function F0({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function I0(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function L0(e,t){for(let n of e)if(t(n))return n}var R0={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function z0(e){let t=e.facet(ZQ).filter(e=>typeof e!=`function`),n=e.facet($Q).filter(e=>typeof e!=`function`);return n.length&&t.push(MY.join(n)),t}var B0=class e{constructor(e,t){this.scale=e,this.viewports=t}static get(t,n,r){let i=0,a=0,o=0,s=r.map(({from:e,to:r})=>{let a=n.lineAt(e,p0.ByPos,t,0,0).top,o=n.lineAt(r,p0.ByPos,t,0,0).bottom;return i+=o-a,{from:e,to:r,top:a,bottom:o,domTop:0,domBottom:0}});if(n.height-i<10)return R0;let c=(7e6-i)/(n.height-i);for(let e of s)e.domTop=o+(e.top-a)*c,o=e.domBottom=e.domTop+(e.bottom-e.top),a=e.bottom;return new e(c,s)}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(t){return t instanceof e&&this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to)}};function V0(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new f0(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>V0(e,t)):e._content)}var H0=J.define({combine:e=>e.join(` `)}),U0=J.define({combine:e=>e.indexOf(!0)>-1}),W0=WX.newName(),G0=WX.newName(),K0=WX.newName(),q0={"&light":`.`+G0,"&dark":`.`+K0};function J0(e,t,n){return new WX(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var Y0=J0(`.`+W0,{"&":{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,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,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":{userSelect:`none`,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:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&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`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},".cm-panels-top":{top:`0`},".cm-panels-bottom":{bottom:`0`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".cm-tab":{display:`inline-block`,overflow:`hidden`,verticalAlign:`bottom`},".cm-widgetBuffer":{verticalAlign:`baseline`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{background:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat`,backgroundSize:`.4em`,backgroundPosition:`calc(min(50%, 0px)) center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,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`}},q0),X0={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Z0=Y.ie&&Y.ie_version<=11,Q0=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GZ,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.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(Y.ie&&Y.ie_version<=11||Y.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Y.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Y.chrome&&Y.chrome_version<126)&&(this.editContext=new n2(e),e.state.facet(WQ)&&(e.contentDOM.editContext=this.editContext.editContext)),Z0&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver==`function`&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent(`Event`))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(this.pendingRecords().length>0),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type!=`change`&&e.type||e.matches)&&(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(WQ)?n.root.activeElement!=this.dom:!NZ(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(Y.ie&&Y.ie_version<=11||Y.android&&Y.chrome)&&!n.state.selection.main.empty&&r.focusNode&&FZ(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=jZ(e.root);if(!t)return!1;let n=Y.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&t2(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=NZ(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&eQ(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(kZ(n))!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||=this.scrollTargets.slice(0,e),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener(`scroll`,this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||=(this.observer.observe(this.dom,X0),Z0&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Z0&&this.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&QZ(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&e!=`Enter`||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!this.delayedAndroidKey?.force})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{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 i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&NZ(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new m1(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=g1(this.view,n);return this.view.state==r&&(n.domChanged||t)&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=$0(t,e.previousSibling||e.target.previousSibling,-1),r=$0(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}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),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):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),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(WQ)!=e.state.facet(WQ)&&(e.view.contentDOM.editContext=e.state.facet(WQ)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function $0(e,t,n){for(;t;){let r=u$.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function e2(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return FZ(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function t2(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return e2(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?e2(e,n):null}var n2=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&i<this.from?o=i:s==this.to&&i>this.to&&(s=i);let l=y1(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=q.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));S1(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:sJ.of(n.text.slice(l.from,l.toB).split(`
|
|
120
|
-
`))};if((Y.mac||Y.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:sJ.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);_1(e,u,q.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(xZ.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:HQ.of(xZ.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{let t=jZ(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to){if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}r=null,this.revertPending(e.state)}if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},X=class e{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}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.clearAnnouncement=-1,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.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||$Z(e.parent)||document,this.viewState=new M0(this,e.state||TY.create(e)),e.scrollTo&&e.scrollTo.is(VQ)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(KQ).map(e=>new JQ(e));for(let e of this.plugins)e.update(this);this.observer=new Q0(this),this.inputState=new C1(this),this.inputState.ensureHandlers(this.plugins),this.docView=new L$(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof dY?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(n0))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=r0(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(TY.phrases)!=this.state.facet(TY.phrases))return this.setState(a);i=c$.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new BQ(t.empty?t:q.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(VQ)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=a2.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(o$)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(H0)!=i.state.facet(H0)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(MQ))try{e(i)}catch(e){UQ(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!g1(this,u)&&l.force&&QZ(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw 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 e of this.plugins)e.destroy(this);this.viewState=new M0(this,e),this.plugins=e.facet(KQ).map(e=>new JQ(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new L$(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(KQ),n=e.state.facet(KQ);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new JQ(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){UQ(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a,scaleY:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0){if(tQ(n||this.win))i=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}o=this.viewState.scaleY}this.updateState=1;let s=this.viewState.measure();if(!s&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let c=[];s&4||([this.measureRequests,c]=[c,this.measureRequests]);let l=c.map(e=>{try{return e.read(this)}catch(e){return UQ(this.state,e),i2}}),u=c$.create(this,this.state,[]),d=!1;u.flags|=s,t?t.flags|=s:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let e=0;e<c.length;e++)if(l[e]!=i2)try{let t=c[e];t.write&&t.write(l[e],this)}catch(e){UQ(this.state,e)}if(d&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}{let e=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)/this.viewState.scaleY-a/o;if((e>1||e<-1)&&!(Y.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?i<0?n.scrollTop=n.scrollHeight:n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(MQ))e(t)}get themeClasses(){return W0+` `+(this.state.facet(U0)?K0:G0)+` `+this.state.facet(H0)}updateAttrs(){let e=o2(this,YQ,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(WQ)?`true`:`false`,class:`cm-content`,style:`${Y.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),o2(this,XQ,t);let n=this.observer.ignore(()=>{let n=_Z(this.contentDOM,this.contentAttrs,t),r=_Z(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&=(this.announceDOM.textContent=``,this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=`\xA0`},200),!1);let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(o$);let t=this.state.facet(e.cspNonce);WX.mount(this.root,this.styleModules.concat(Y0).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw 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;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==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}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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 a1(this,e,e1(this,e,t,n))}moveByGroup(e,t){return a1(this,e,e1(this,e,t,t=>t1(this,e.head,t)))}visualLineSide(e,t){return t?q.cursor(e.to,1):q.cursor(e.from,-1)}moveToLineBoundary(e,t,n=!0){return $$(this,e,t,n)}moveVertically(e,t,n){return a1(this,e,n1(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=s1(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),s1(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),i=r[hQ.find(r,e-n.from,-1,t)];return n.length&&(e==n.from&&t<0||e==n.to&&t>0)&&i.dir!=this.textDirectionAt(n.from)&&(e==n.to?(e=n.from+i.from,t=1):(e=n.from+i.to,t=-1)),this.docView.coordsAt(e,t,i.dir==aQ.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(LQ)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>r2)return wQ(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||gQ(r.isolates,n=n$(this,e))))return r.order;n||=n$(this,e);let r=CQ(e.text,t,n);return this.bidiCache.push(new a2(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||Y.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{YZ(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(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return VQ.of(new BQ(typeof e==`number`?q.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return VQ.of(new BQ(q.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return qQ.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return qQ.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=WX.newName(),r=[H0.of(n),o$.of(J0(`.${n}`,e))];return t&&t.dark&&r.push(U0.of(!0)),r}static baseTheme(e){return KJ.lowest(o$.of(J0(`.`+W0,e,q0)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&u$.get(t)||u$.get(e))?.root?.view||null}};X.styleModule=o$,X.inputHandler=NQ,X.clipboardInputFilter=FQ,X.clipboardOutputFilter=IQ,X.scrollHandler=zQ,X.focusChangeEffect=PQ,X.perLineTextDirection=LQ,X.exceptionSink=jQ,X.updateListener=MQ,X.editable=WQ,X.mouseSelectionStyle=AQ,X.dragMovesSelection=kQ,X.clickAddsSelectionRange=OQ,X.decorations=ZQ,X.blockWrappers=QQ,X.outerDecorations=$Q,X.atomicRanges=e$,X.bidiIsolatedRanges=t$,X.cursorScrollMargin=J.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),X.scrollMargins=i$,X.darkTheme=U0,X.cspNonce=J.define({combine:e=>e.length?e[0]:``}),X.contentAttributes=XQ,X.editorAttributes=YQ,X.lineWrapping=X.contentAttributes.of({class:`cm-lineWrapping`}),X.announce=uY.define();var r2=4096,i2={},a2=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:aQ.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function o2(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&pZ(a,n)}return n}var s2=Y.mac?`mac`:Y.windows?`win`:Y.linux?`linux`:`key`;function c2(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function l2(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var u2=KJ.default(X.domEventHandlers({keydown(e,t){return y2(p2(t.state),e,t,`editor`)}})),d2=J.define({enables:u2}),f2=new WeakMap;function p2(e){let t=e.facet(d2),n=f2.get(t);return n||f2.set(t,n=_2(t.reduce((e,t)=>e.concat(t),[]))),n}function m2(e,t,n){return y2(p2(e.state),t,e,n)}var h2=null,g2=4e3;function _2(e,t=s2){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>c2(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=h2={view:t,prefix:n,scope:e};return setTimeout(()=>{h2==r&&(h2=null)},g2),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,v2))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var v2=null;function y2(e,t,n,r){v2=t;let i=$X(t),a=CJ(xJ(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;h2&&h2.view==n&&h2.scope==r&&(o=h2.prefix+` `,k1.indexOf(t.keyCode)<0&&(c=!0,h2=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+l2(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Y.windows&&t.ctrlKey&&t.altKey)&&!(Y.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=qX[t.keyCode])&&p!=i?(d(f[o+l2(p,t,!0)])||t.shiftKey&&(m=JX[t.keyCode])!=i&&m!=p&&d(f[o+l2(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+l2(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),v2=null,s}var b2=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(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(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=x2(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}return C2(t,n,r)}};function x2(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==aQ.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function S2(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function C2(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==aQ.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=x2(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=Q$(e,r,1),m=Q$(e,i,-1),h=p.type==bZ.Text?p:null,g=m.type==bZ.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=S2(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=S2(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):ee(p,!1),r=g?y(null,n.to,g):ee(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(_(d,t.bottom,f,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==bZ.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new b2(t,e-c.left,n-c.top,Math.max(0,r-e),i-n)}function v({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(_(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,o=-1e9,s=[];function c(t,n,c,l,u){let p=e.coordsAtPos(t,t==r.to?-2:2),m=e.coordsAtPos(c,c==r.from?2:-2);p&&m&&(i=Math.min(p.top,m.top,i),o=Math.max(p.bottom,m.bottom,o),u==aQ.LTR?s.push(a&&n?d:p.left,a&&l?f:m.right):s.push(!a&&l?d:m.left,!a&&n?f:p.right))}let l=t??r.from,u=n??r.to;for(let r of e.visibleRanges)if(r.to>l&&r.from<u)for(let i=Math.max(r.from,l),a=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let o of e.bidiSpans(r)){let e=o.from+r.from,s=o.to+r.from;if(e>=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function ee(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function w2(e,t){return e.constructor==t.constructor&&e.eq(t)}var T2=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,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.scale(),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(E2)!=e.state.facet(E2)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(E2);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!w2(e,this.drawn[t]))){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 e=t.nextSibling;t.remove(),t=e}this.drawn=e,Y.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},E2=J.define();function D2(e){return[qQ.define(t=>new T2(t,e)),E2.of(e)]}var O2=!Y.ios,k2=J.define({combine(e){return EY(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function A2(e={}){return[k2.of(e),M2,P2,I2,RQ.of(!0)]}function j2(e){return e.startState.facet(k2)!=e.state.facet(k2)}var M2=D2({above:!0,markers(e){let{state:t}=e,n=t.facet(k2),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&Y.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:q.cursor(i.head,i.assoc);for(let i of b2.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=j2(e);return n&&N2(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){N2(t.state,e)},class:`cm-cursorLayer`});function N2(e,t){t.style.animationDuration=e.facet(k2).cursorBlinkRate+`ms`}var P2=D2({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let i of r)if(!i.empty&&(O2||i!=n))for(let n of b2.forRange(e,`cm-selectionBackground`,i))t.push(n);if(Y.ios&&!n.empty&&e.state.facet(k2).iosSelectionHandles){for(let r of b2.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,q.cursor(n.from,1)))t.push(r);for(let r of b2.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,q.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||j2(e)},class:`cm-selectionLayer`}),F2=Y.gecko&&Y.gecko_version==153?`#ffffff01`:`transparent`,I2=KJ.highest(X.theme({".cm-line":{...O2?{"& ::selection, &::selection":{backgroundColor:`${F2} !important`}}:{},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,...O2?{"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}:{}}}}));/x/.unicode;function L2(){return z2}var R2=xZ.line({class:`cm-activeLine`}),z2=qQ.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(R2.range(i.from)),t=i.from)}return xZ.set(n)}},{decorations:e=>e.decorations}),B2=`-10000px`,V2=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function H2(e){let t=e.dom.ownerDocument.documentElement,n=t.clientWidth,r=getComputedStyle(t);if(!/stable/.test(r.scrollbarGutter||``))return{left:0,right:n};let i=t.getBoundingClientRect(),a=e.win.scrollX;return{left:Math.max(0,i.left+a-parseFloat(r.marginLeft)),right:Math.min(n,i.right+a+parseFloat(r.marginRight))}}function U2(e){let{left:t,right:n}=H2(e);return{top:0,left:t,right:n,bottom:e.dom.ownerDocument.documentElement.clientHeight}}var W2=J.define({combine:e=>({position:Y.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||U2})}),G2=new WeakMap,K2=qQ.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(W2);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new V2(e,X2,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(W2);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=B2,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1,r=0;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(Y.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`){if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}else r=H2(this.view).left;let i=this.view.scrollDOM.getBoundingClientRect(),a=a$(this.view);return{visible:{left:i.left+a.left,top:i.top+a.top,right:i.right-a.right,bottom:i.bottom-a.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),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(W2).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n,fixedLeft:r}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=B2;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=G2.get(c)??d.bottom-d.top,g=c.offset||Y2,_=this.view.textDirection==aQ.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let ee=(y?u.top-n.top:n.bottom-u.bottom)-p;if(ee<h&&c.resize!==!1){if(ee<this.view.defaultLineHeight){l.style.top=B2;continue}G2.set(c,h),l.style.height=(h=ee)/i+`px`}else l.style.height&&(l.style.height=``);let te=y?u.top-h-p-g.y:u.bottom+p+g.y,ne=v+m;if(c.overlap!==!0)for(let e of a)e.left<ne&&e.right>v&&e.top<te+h&&e.bottom>te&&(te=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(te-e.parent.top)/i+`px`,q2(l,(v-e.parent.left)/r)):(l.style.top=te/i+`px`,q2(l,(v-e.fixedLeft)/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:te,right:ne,bottom:te+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=B2}},{eventObservers:{scroll(){this.maybeMeasure()}}});function q2(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var J2=X.baseTheme({".cm-tooltip":{zIndex:500,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:`14px`,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`}}}),Y2={x:0,y:0},X2=J.define({enables:[K2,J2]}),Z2=J.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function Q2(e,t){let n=e.plugin($2),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var $2=qQ.fromClass(class{constructor(e){this.input=e.state.facet(n4),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(Z2);this.top=new e4(e,!0,t.topContainer),this.bottom=new e4(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(Z2);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new e4(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new e4(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(n4);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>X.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),e4=class{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(),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`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=t4(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=t4(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 t4(e){let t=e.nextSibling;return e.remove(),t}var n4=J.define({enables:$2});function r4(e,t){let n,r=new Promise(e=>n=e),i=e=>c4(e,t,n);e.state.field(a4,!1)?e.dispatch({effects:o4.of(i)}):e.dispatch({effects:uY.appendConfig.of(a4.init(()=>[i]))});let a=s4.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(a4).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}function i4(e,t){let n=e.state.field(a4,!1)||[];for(let r of n){let n=Q2(e,r);if(n&&n.dom.classList.contains(t))return n}return null}var a4=UJ.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(o4)?e=[n.value].concat(e):n.is(s4)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>n4.computeN([e],t=>t.field(e))}),o4=uY.define(),s4=uY.define();function c4(e,t,n){let r=t.content?t.content(e,()=>s(null)):null;if(!r){if(r=eZ(`form`),t.input){let e=eZ(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(eZ(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(eZ(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),s(null)):e.keyCode==13&&(e.preventDefault(),s(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),s(t)})}let a=eZ(`div`,r,eZ(`button`,{onclick:()=>s(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);let o=typeof t.focus==`string`?r.querySelector(t.focus):t.focus?r.querySelector(`input`)||r.querySelector(`button`):null;function s(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{o&&(`select`in o?o.select():`focus`in o&&o.focus())},destroy:()=>n(null)}}var l4=class extends DY{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};l4.prototype.elementClass=``,l4.prototype.toDOM=void 0,l4.prototype.mapMode=TJ.TrackBefore,l4.prototype.startSide=l4.prototype.endSide=-1,l4.prototype.point=!0;var u4=1024,d4=0,f4=class{constructor(e,t){this.from=e,this.to=t}},Z=class{constructor(e={}){this.id=d4++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=h4.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};Z.closedBy=new Z({deserialize:e=>e.split(` `)}),Z.openedBy=new Z({deserialize:e=>e.split(` `)}),Z.group=new Z({deserialize:e=>e.split(` `)}),Z.isolate=new Z({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),Z.contextHash=new Z({perNode:!0}),Z.lookAhead=new Z({perNode:!0}),Z.mounted=new Z({perNode:!0});var p4=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[Z.mounted.id]}},m4=Object.create(null),h4=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):m4,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(Z.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(Z.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};h4.none=new h4(``,Object.create(null),0,8);var g4=new WeakMap,_4=new WeakMap,v4;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(v4||={});var y4=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=p4.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new N4(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new N4(g4.get(this)||this.topNode);return r.moveTo(e,t),g4.set(this,r._tree),r}get topNode(){return new T4(this,0,0,null)}resolve(e,t=0){let n=C4(g4.get(this)||this.topNode,e,t,!1);return g4.set(this,n),n}resolveInner(e,t=0){let n=C4(_4.get(this)||this.topNode,e,t,!0);return _4.set(this,n),n}resolveStack(e,t=0){return M4(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&v4.IncludeAnonymous)>0;for(let e=this.cursor(a|v4.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:R4(h4.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(h4.none,t,n,r)))}static build(e){return F4(e)}};y4.empty=new y4(h4.none,[],[],0);var b4=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},x4=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return h4.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(S4(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function S4(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function C4(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof T4&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:v4.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof T4&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var w4=class{cursor(e=0){return new N4(this,e)}getChild(e,t=null,n=null){let r=E4(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return E4(this,e,t,n)}resolve(e,t=0){return C4(this,e,t,!1)}resolveInner(e,t=0){return C4(this,e,t,!0)}matchContext(e){return D4(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},T4=class e extends w4{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&v4.EnterBracketed&&l instanceof y4&&(d=p4.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||S4(i,r,u,u+l.length)){if(l instanceof x4){if(a&v4.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new k4(new O4(o,l,t,u),null,e)}else if(a&v4.IncludeAnonymous||!l.type.isAnonymous||P4(l)){let s;if(!(a&v4.IgnoreMounts)&&(s=p4.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&v4.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&v4.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&v4.IgnoreOverlays)&&(i=p4.get(this._tree))&&i.overlay){let a=t-this.from,o=r&v4.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function E4(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function D4(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var O4=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},k4=class e extends w4{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&v4.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new y4(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function A4(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof T4&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new j4(i,n)}var j4=class{constructor(e,t){this.heads=e,this.node=t}get next(){return A4(this.heads)}};function M4(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof T4?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=p4.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new T4(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(C4(o,t,n,!1))}}return i?A4(i):r}var N4=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~v4.EnterBracketed,e instanceof T4)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof T4?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&v4.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&v4.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&v4.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&v4.IncludeAnonymous||e instanceof x4||!e.type.isAnonymous||P4(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new k4(this.buffer,t,this.stack[e]);return this.bufferNode=new k4(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return D4(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return D4(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function P4(e){return e.children.some(e=>e instanceof x4||!e.type.isAnonymous||P4(e))}function F4(e){let{buffer:t,nodeSet:n,maxBufferLength:r=u4,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new b4(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,ee){let{id:te,start:ne,end:re,size:ie}=o,ae=l,oe=c;if(ie<0){if(o.next(),ie==-1){let t=i[te];_.push(t),v.push(ne-e);return}if(ie==-3){c=te;return}if(ie==-4){l=te;return}throw RangeError(`Unrecognized record size: ${ie}`)}let se=s[te],ce,le,ue=ne-e;if(re-ne<=r&&(le=h(o.pos-t,y))){let t=new Uint16Array(le.size-le.skip),r=o.pos-le.size,i=t.length;for(;o.pos>r;)i=g(le.start,t,i);ce=new x4(t,re-le.start,n),ue=le.start-e}else{let e=o.pos-ie;o.next();let t=[],s=[],c=te>=a?te:-1,h=0,g=re,_=ae;for(;o.pos>e;)c>=0&&o.id==c&&o.size>=0?(o.end<=g-r&&(p(t,s,ne,h,o.end,g,c,_,oe),h=t.length,g=o.end,_=l),o.next()):ee>2500?d(ne,e,t,s):(c>=0&&o.size==-1&&i[o.id].type==n.types[c]&&(h<t.length&&p(t,s,ne,h,o.end,g,c,_,oe),h=t.length+1,g=o.start,_=l),u(ne,e,t,s,c,ee+1));if(c>=0&&h>0&&h<t.length&&p(t,s,ne,h,ne,g,c,_,oe),t.reverse(),s.reverse(),c>-1&&h>0){let e=f(se,oe);ce=R4(se,t,s,0,t.length,0,re-ne,e,e)}else ce=m(se,t,s,re-ne,ae-re,oe)}_.push(ce),v.push(ue)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new x4(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof y4){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(Z.lookAhead))&&(a=r[o]+s.length+c-i)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[Z.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[Z.lookAhead,i];o=o?[e].concat(o):[e]}return new y4(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new y4(s[e.topID],_.reverse(),v.reverse(),y)}var I4=new WeakMap;function L4(e,t){if(!e.isAnonymous||t instanceof x4||t.type!=e)return 1;let n=I4.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof y4)){n=1;break}n+=L4(e,r)}I4.set(t,n)}return n}function R4(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=L4(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=L4(e,t[s]);for(s++;s<i;s++){let n=L4(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(R4(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var z4=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},B4=class{startParse(e,t,n){return typeof e==`string`&&(e=new V4(e)),n=n?n.length?n.map(e=>new f4(e.from,e.to)):[new f4(0,0)]:[new f4(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},V4=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new Z({perNode:!0});var H4=0,U4=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=H4++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new G4(e);return e=>e.modified.indexOf(t)>-1?e:G4.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},W4=0,G4=class e{constructor(e){this.name=e,this.instances=[],this.id=W4++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&K4(n,e.modified));if(r)return r;let i=[],a=new U4(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=q4(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function K4(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function q4(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function J4(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new X4(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Y4.add(t)}var Y4=new Z({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new X4(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),X4=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};X4.empty=new X4([],2,null);function Z4(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}var Q=U4.define,Q4=Q(),$4=Q(),e3=Q($4),t3=Q($4),n3=Q(),r3=Q(n3),i3=Q(n3),a3=Q(),o3=Q(a3),s3=Q(),c3=Q(),l3=Q(),u3=Q(l3),d3=Q(),$={comment:Q4,lineComment:Q(Q4),blockComment:Q(Q4),docComment:Q(Q4),name:$4,variableName:Q($4),typeName:e3,tagName:Q(e3),propertyName:t3,attributeName:Q(t3),className:Q($4),labelName:Q($4),namespace:Q($4),macroName:Q($4),literal:n3,string:r3,docString:Q(r3),character:Q(r3),attributeValue:Q(r3),number:i3,integer:Q(i3),float:Q(i3),bool:Q(n3),regexp:Q(n3),escape:Q(n3),color:Q(n3),url:Q(n3),keyword:s3,self:Q(s3),null:Q(s3),atom:Q(s3),unit:Q(s3),modifier:Q(s3),operatorKeyword:Q(s3),controlKeyword:Q(s3),definitionKeyword:Q(s3),moduleKeyword:Q(s3),operator:c3,derefOperator:Q(c3),arithmeticOperator:Q(c3),logicOperator:Q(c3),bitwiseOperator:Q(c3),compareOperator:Q(c3),updateOperator:Q(c3),definitionOperator:Q(c3),typeOperator:Q(c3),controlOperator:Q(c3),punctuation:l3,separator:Q(l3),bracket:u3,angleBracket:Q(u3),squareBracket:Q(u3),paren:Q(u3),brace:Q(u3),content:a3,heading:o3,heading1:Q(o3),heading2:Q(o3),heading3:Q(o3),heading4:Q(o3),heading5:Q(o3),heading6:Q(o3),contentSeparator:Q(a3),list:Q(a3),quote:Q(a3),emphasis:Q(a3),strong:Q(a3),link:Q(a3),monospace:Q(a3),strikethrough:Q(a3),inserted:Q(),deleted:Q(),changed:Q(),invalid:Q(),meta:d3,documentMeta:Q(d3),annotation:Q(d3),processingInstruction:Q(d3),definition:U4.defineModifier(`definition`),constant:U4.defineModifier(`constant`),function:U4.defineModifier(`function`),standard:U4.defineModifier(`standard`),local:U4.defineModifier(`local`),special:U4.defineModifier(`special`)};for(let e in $){let t=$[e];t instanceof U4&&(t.name=e)}Z4([{tag:$.link,class:`tok-link`},{tag:$.heading,class:`tok-heading`},{tag:$.emphasis,class:`tok-emphasis`},{tag:$.strong,class:`tok-strong`},{tag:$.keyword,class:`tok-keyword`},{tag:$.atom,class:`tok-atom`},{tag:$.bool,class:`tok-bool`},{tag:$.url,class:`tok-url`},{tag:$.labelName,class:`tok-labelName`},{tag:$.inserted,class:`tok-inserted`},{tag:$.deleted,class:`tok-deleted`},{tag:$.literal,class:`tok-literal`},{tag:$.string,class:`tok-string`},{tag:$.number,class:`tok-number`},{tag:[$.regexp,$.escape,$.special($.string)],class:`tok-string2`},{tag:$.variableName,class:`tok-variableName`},{tag:$.local($.variableName),class:`tok-variableName tok-local`},{tag:$.definition($.variableName),class:`tok-variableName tok-definition`},{tag:$.special($.variableName),class:`tok-variableName2`},{tag:$.definition($.propertyName),class:`tok-propertyName tok-definition`},{tag:$.typeName,class:`tok-typeName`},{tag:$.namespace,class:`tok-namespace`},{tag:$.className,class:`tok-className`},{tag:$.macroName,class:`tok-macroName`},{tag:$.propertyName,class:`tok-propertyName`},{tag:$.operator,class:`tok-operator`},{tag:$.comment,class:`tok-comment`},{tag:$.meta,class:`tok-meta`},{tag:$.invalid,class:`tok-invalid`},{tag:$.punctuation,class:`tok-punctuation`}]);var f3=new Z,p3=new Z,m3=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,TY.prototype.hasOwnProperty(`tree`)||Object.defineProperty(TY.prototype,"tree",{get(){return g3(this)}}),this.parser=t,this.extension=[T3.of(this),TY.languageData.of((e,t,n)=>{let r=h3(e,t,n),i=r.type.prop(f3);if(!i)return[];let a=e.facet(i),o=r.type.prop(p3);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return h3(e,t,n).type.prop(f3)==this.data}findRegions(e){let t=e.facet(T3);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(f3)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(Z.mounted);if(i){if(i.tree.prop(f3)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof y4&&r(i,e.positions[n]+t)}};return r(g3(e),0),n}get allowsNesting(){return!0}};m3.setState=uY.define();function h3(e,t,n){let r=e.facet(T3),i=g3(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,v4.ExcludeBuffers|v4.EnterBracketed))e.type.isTop&&(i=e);return i}function g3(e){let t=e.field(m3.state,!1);return t?t.tree:y4.empty}var _3=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},v3=null,y3=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],y4.empty,0,r,[],null)}startParse(){return this.parser.startParse(new _3(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=y4.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(z4.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(z4.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=v3;v3=this;try{return e()}finally{v3=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=b3(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=z4.applyChanges(r,e),i=y4.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=b3(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends B4{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=v3;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new y4(h4.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return v3}};function b3(e,t,n){return z4.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var x3=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=y3.create(t.facet(T3).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};m3.state=UJ.define({create:x3.init,update(e,t){for(let e of t.effects)if(e.is(m3.setState))return e.value;return t.startState.facet(T3)==t.state.facet(T3)?e.apply(t):x3.init(t.state)}});var S3=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(S3=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var C3=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,w3=qQ.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(m3.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(m3.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=S3(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(m3.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!C3?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>C3&&C3()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:m3.setState.of(new x3(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>UQ(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),T3=J.define({combine(e){return e.length?e[0]:null},enables:e=>[m3.state,w3,X.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),E3=J.define(),D3=J.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function O3(e){let t=e.facet(D3);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function k3(e,t){let n=``,r=e.tabSize,i=e.facet(D3)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function A3(e,t){e instanceof TY&&(e=new j3(e));for(let n of e.state.facet(E3)){let r=n(e,t);if(r!==void 0)return r}let n=g3(e.state);return n.length>=t?N3(e,n,t):null}var j3=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=O3(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return KY(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},M3=new Z;function N3(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return P3(r,e,n)}function P3(e,t,n){for(let r=e;r;r=r.next){let e=I3(r.node);if(e)return e(R3.create(t,n,r))}return 0}function F3(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function I3(e){let t=e.type.prop(M3);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Z.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>V3(e,!0,1,void 0,n&&!F3(e)?t.from:void 0)}return e.parent==null?L3:null}function L3(){return 0}var R3=class e extends j3{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(z3(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return P3(this.context.next,this.base,this.pos)}};function z3(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function B3(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function V3(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?B3(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}$.meta,$.link,$.heading,$.emphasis,$.strong,$.strikethrough,$.keyword,$.atom,$.bool,$.url,$.contentSeparator,$.labelName,$.literal,$.inserted,$.string,$.deleted,$.regexp,$.escape,$.string,$.variableName,$.variableName,$.typeName,$.namespace,$.className,$.variableName,$.macroName,$.propertyName,$.comment,$.invalid;var H3=1e4,U3=`()[]{}`,W3=new Z;function G3(e,t,n){let r=e.prop(t<0?Z.openedBy:Z.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function K3(e){let t=e.type.prop(W3);return t?t(e.node):e}function q3(e,t,n,r={}){let i=r.maxScanDistance||H3,a=r.brackets||U3,o=g3(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=G3(r.type,n,a);if(i&&r.from<r.to){let o=K3(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return J3(e,t,n,r,o,i,a)}}return Y3(e,t,n,o,s.type,i,a)}function J3(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=K3(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(G3(u.type,n,o))l++;else if(G3(u.type,-n,o)){if(l==0){let e=K3(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function Y3(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var X3=Object.create(null),Z3=[h4.none],Q3=[],$3=Object.create(null),e6=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])e6[e]=n6(X3,t);function t6(e,t){Q3.indexOf(e)>-1||(Q3.push(e),console.warn(t))}function n6(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||$[n];r?typeof r==`function`?t.length?t=t.map(r):t6(n,`Modifier ${n} used at start of tag`):t.length?t6(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:t6(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=$3[i];if(a)return a.id;let o=$3[i]=h4.define({id:Z3.length,name:r,props:[J4({[r]:n})]});return Z3.push(o),o.id}aQ.RTL,aQ.LTR;var r6=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=c6(e.state,n.from);return r.line?a6(e):r.block?s6(e):!1};function i6(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var a6=i6(p6,0),o6=i6(f6,0),s6=i6((e,t)=>f6(e,t,d6(t)),0);function c6(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var l6=50;function u6(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-l6,r),o=e.sliceDoc(i,i+l6),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+l6),d=e.sliceDoc(i-l6,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function d6(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function f6(e,t,n=t.selection.ranges){let r=n.map(e=>c6(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>u6(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function p6(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=c6(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var m6=sY.define(),h6=sY.define(),g6=J.define(),_6=J.define({combine(e){return EY(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),v6=UJ.define({create(){return L6.empty},update(e,t){let n=t.state.facet(_6),r=t.annotation(m6);if(r){let i=T6.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?E6(o,o.length,n.minDepth,i):M6(o,t.startState.selection),new L6(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(h6);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(dY.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=T6.fromTransaction(t),o=t.annotation(dY.time),s=t.annotation(dY.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new L6(e.done.map(T6.fromJSON),e.undone.map(T6.fromJSON))}});function y6(e={}){return[v6,_6.of(e),X.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?x6:e.inputType==`historyRedo`?S6:null;return n?(e.preventDefault(),n(t)):!1}})]}function b6(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(v6,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var x6=b6(0,!1),S6=b6(1,!1),C6=b6(0,!0),w6=b6(1,!0),T6=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&DJ.fromJSON(t.changes),[],t.mapped&&EJ.fromJSON(t.mapped),t.startSelection&&q.fromJSON(t.startSelection),t.selectionsAfter.map(q.fromJSON))}static fromTransaction(t,n){let r=A6;for(let e of t.startState.facet(g6)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,A6)}static selection(t){return new e(void 0,A6,void 0,void 0,t)}};function E6(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function D6(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function O6(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function k6(e,t){return e.length?t.length?e.concat(t):e:t}var A6=[],j6=200;function M6(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-j6));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),E6(e,e.length-1,1e9,n.setSelAfter(r)))}return[T6.selection([t])]}function N6(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function P6(e,t){if(!e.length)return e;let n=e.length,r=A6;for(;n;){let i=F6(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[T6.selection(r)]:A6}function F6(e,t,n){let r=k6(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):A6,n);if(!e.changes)return T6.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new T6(i,uY.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var I6=/^(input\.type|delete)($|\.)/,L6=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||I6.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,D6(s.changes,t.changes))||r==`input.type.compose`)?E6(o,o.length-1,i.minDepth,new T6(t.changes.compose(s.changes),k6(uY.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,A6)):E6(o,o.length,i.minDepth,t),new e(o,A6,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:A6;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&O6(a[a.length-1],t)?this:new e(M6(this.done,t),this.undone,n,r)}addMapping(t){return new e(P6(this.done,t),P6(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:m6.of({side:e,rest:N6(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?A6:r.slice(0,r.length-1);return i.mapped&&(n=P6(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:m6.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};L6.empty=new L6(A6,A6);var R6=[{key:`Mod-z`,run:x6,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:S6,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:S6,preventDefault:!0},{key:`Mod-u`,run:C6,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:w6,preventDefault:!0}];function z6(e,t){return q.create(e.ranges.map(t),e.mainIndex)}function B6(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function V6({state:e,dispatch:t},n){let r=z6(e.selection,n);return!r.eq(e.selection,!0)&&(t(B6(e,r)),!0)}function H6(e,t){return q.cursor(t?e.to:e.from)}function U6(e,t){return V6(e,n=>n.empty?e.moveByChar(n,t):H6(n,t))}function W6(e){return e.textDirectionAt(e.state.selection.main.head)==aQ.LTR}var G6=e=>U6(e,!W6(e)),K6=e=>U6(e,W6(e));function q6(e,t){return V6(e,n=>n.empty?e.moveByGroup(n,t):H6(n,t))}var J6=e=>q6(e,!W6(e)),Y6=e=>q6(e,W6(e));typeof Intl<`u`&&Intl.Segmenter;function X6(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Z6(e,t,n){let r=g3(e).resolveInner(t.head),i=n?Z.closedBy:Z.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;X6(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?q3(e,r.from,1):q3(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,q.cursor(s,n?-1:1)}var Q6=e=>V6(e,t=>Z6(e.state,t,!W6(e))),$6=e=>V6(e,t=>Z6(e.state,t,W6(e)));function e8(e,t){return V6(e,n=>{if(!n.empty)return H6(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var t8=e=>e8(e,!1),n8=e=>e8(e,!0);function r8(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(X.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function i8(e,t){let n=r8(e),{state:r}=e,i=z6(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):H6(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=X.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(B6(r,i),{effects:a}),!0}var a8=e=>i8(e,!1),o8=e=>i8(e,!0);function s8(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=q.cursor(r.from+n))}return i}var c8=e=>V6(e,t=>s8(e,t,!0)),l8=e=>V6(e,t=>s8(e,t,!1)),u8=e=>V6(e,t=>s8(e,t,!W6(e))),d8=e=>V6(e,t=>s8(e,t,W6(e))),f8=e=>V6(e,t=>e.moveToLineBoundary(t,!1,!1)),p8=e=>V6(e,t=>e.moveToLineBoundary(t,!0,!1));function m8(e,t,n){let r=!1,i=z6(e.selection,t=>{let i=q3(e,t.head,-1)||q3(e,t.head,1)||t.head>0&&q3(e,t.head-1,1)||t.head<e.doc.length&&q3(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?q.range(t.anchor,a):q.cursor(a)});return r?(t(B6(e,i)),!0):!1}var h8=({state:e,dispatch:t})=>m8(e,t,!1);function g8(e,t,n){let r=z6(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=q.range(e.head,e.anchor));let r=n(e);return q.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(B6(e.state,r)),!0)}function _8(e,t){return g8(e,t,n=>e.moveByChar(n,t))}var v8=e=>_8(e,!W6(e)),y8=e=>_8(e,W6(e));function b8(e,t){return g8(e,t,n=>e.moveByGroup(n,t))}var x8=e=>b8(e,!W6(e)),S8=e=>b8(e,W6(e)),C8=e=>{let t=!W6(e);return g8(e,t,n=>Z6(e.state,n,t))},w8=e=>{let t=W6(e);return g8(e,t,n=>Z6(e.state,n,t))};function T8(e,t){return g8(e,t,n=>e.moveVertically(n,t))}var E8=e=>T8(e,!1),D8=e=>T8(e,!0);function O8(e,t){return g8(e,t,n=>e.moveVertically(n,t,r8(e).height))}var k8=e=>O8(e,!1),A8=e=>O8(e,!0),j8=e=>g8(e,!0,t=>s8(e,t,!0)),M8=e=>g8(e,!1,t=>s8(e,t,!1)),N8=e=>{let t=!W6(e);return g8(e,t,n=>s8(e,n,t))},P8=e=>{let t=W6(e);return g8(e,t,n=>s8(e,n,t))},F8=e=>g8(e,!1,t=>q.cursor(e.lineBlockAt(t.head).from)),I8=e=>g8(e,!0,t=>q.cursor(e.lineBlockAt(t.head).to)),L8=({state:e,dispatch:t})=>(t(B6(e,{anchor:0})),!0),R8=({state:e,dispatch:t})=>(t(B6(e,{anchor:e.doc.length})),!0),z8=({state:e,dispatch:t})=>(t(B6(e,{anchor:e.selection.main.anchor,head:0})),!0),B8=({state:e,dispatch:t})=>(t(B6(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),V8=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),H8=({state:e,dispatch:t})=>{let n=s5(e).map(({from:t,to:n})=>q.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:q.create(n),userEvent:`select`})),!0},U8=({state:e,dispatch:t})=>{let n=z6(e.selection,t=>{let n=g3(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return q.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(B6(e,n)),!0)};function W8(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(B6(n,q.create(i,i.length-1))),!0)}var G8=e=>W8(e,!1),K8=e=>W8(e,!0),q8=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=q.create([n.main]):n.main.empty||(r=q.create([q.cursor(n.main.head)])),r?(t(B6(e,r)),!0):!1};function J8(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Y8(e,o,!1)):o>i&&(n=`delete.forward`,o=Y8(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Y8(e,i,!1),a=Y8(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:q.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?X.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Y8(e,t,n){if(e instanceof X)for(let r of e.state.facet(X.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var X8=(e,t,n)=>J8(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=KY(s,a.tabSize)%O3(a)||O3(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=vJ(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=vJ(o.text,c-o.from,!1,!1)+o.from);return c}),Z8=e=>X8(e,!1,!0),Q8=e=>X8(e,!0,!1),$8=(e,t)=>J8(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=vJ(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),e5=e=>$8(e,!1),t5=e=>$8(e,!0),n5=e=>J8(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),r5=e=>J8(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),i5=e=>J8(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),a5=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:sJ.of([``,``])},range:q.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},o5=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:vJ(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:vJ(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:q.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function s5(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function c5(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of s5(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(q.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(q.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:q.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var l5=({state:e,dispatch:t})=>c5(e,t,!1),u5=({state:e,dispatch:t})=>c5(e,t,!0);function d5(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of s5(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var f5=({state:e,dispatch:t})=>d5(e,t,!1),p5=({state:e,dispatch:t})=>d5(e,t,!0),m5=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(s5(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=z6(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function h5(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=g3(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Z.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var g5=v5(!1),_5=v5(!0);function v5(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&h5(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new j3(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=A3(s,r);for(c??=KY(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,k3(t,c)];return o&&l.push(k3(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:sJ.of(l)},range:q.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function y5(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:q.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var b5=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new j3(e,{overrideIndentation:e=>n[e]??-1}),i=y5(e,(t,i,a)=>{let o=A3(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=k3(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},x5=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(y5(e,(t,n)=>{n.push({from:t.from,insert:e.facet(D3)})}),{userEvent:`input.indent`})),!0),S5=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(y5(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=KY(r,e.tabSize),a=0,o=k3(e,Math.max(0,i-O3(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),C5=e=>(e.setTabFocusMode(),!0),w5=e=>(e.setTabFocusMode(2e3),!0),T5=[{key:`Ctrl-b`,run:G6,shift:v8,preventDefault:!0},{key:`Ctrl-f`,run:K6,shift:y8},{key:`Ctrl-p`,run:t8,shift:E8},{key:`Ctrl-n`,run:n8,shift:D8},{key:`Ctrl-a`,run:f8,shift:F8},{key:`Ctrl-e`,run:p8,shift:I8},{key:`Ctrl-d`,run:Q8},{key:`Ctrl-h`,run:Z8},{key:`Ctrl-k`,run:n5},{key:`Ctrl-Alt-h`,run:e5},{key:`Ctrl-o`,run:a5},{key:`Ctrl-t`,run:o5},{key:`Ctrl-v`,run:o8}],E5=[{key:`ArrowLeft`,run:G6,shift:v8,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:J6,shift:x8,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:u8,shift:N8,preventDefault:!0},{key:`ArrowRight`,run:K6,shift:y8,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Y6,shift:S8,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:d8,shift:P8,preventDefault:!0},{key:`ArrowUp`,run:t8,shift:E8,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:L8,shift:z8},{mac:`Ctrl-ArrowUp`,run:a8,shift:k8},{key:`ArrowDown`,run:n8,shift:D8,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:R8,shift:B8},{mac:`Ctrl-ArrowDown`,run:o8,shift:A8},{key:`PageUp`,run:a8,shift:k8},{key:`PageDown`,run:o8,shift:A8},{key:`Home`,run:l8,shift:M8,preventDefault:!0},{key:`Mod-Home`,run:L8,shift:z8},{key:`End`,run:c8,shift:j8,preventDefault:!0},{key:`Mod-End`,run:R8,shift:B8},{key:`Enter`,run:g5,shift:g5},{key:`Mod-a`,run:V8},{key:`Backspace`,run:Z8,shift:Z8,preventDefault:!0},{key:`Delete`,run:Q8,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:e5,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:t5,preventDefault:!0},{mac:`Mod-Backspace`,run:r5,preventDefault:!0},{mac:`Mod-Delete`,run:i5,preventDefault:!0}].concat(T5.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),D5=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Q6,shift:C8},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:$6,shift:w8},{key:`Alt-ArrowUp`,run:l5},{key:`Shift-Alt-ArrowUp`,run:f5},{key:`Alt-ArrowDown`,run:u5},{key:`Shift-Alt-ArrowDown`,run:p5},{key:`Mod-Alt-ArrowUp`,run:G8},{key:`Mod-Alt-ArrowDown`,run:K8},{key:`Escape`,run:q8},{key:`Mod-Enter`,run:_5},{key:`Alt-l`,mac:`Ctrl-l`,run:H8},{key:`Mod-i`,run:U8,preventDefault:!0},{key:`Mod-[`,run:S5},{key:`Mod-]`,run:x5},{key:`Mod-Alt-\\`,run:b5},{key:`Shift-Mod-k`,run:m5},{key:`Shift-Mod-\\`,run:h8},{key:`Mod-/`,run:r6},{key:`Alt-A`,mac:`Ctrl-A`,run:o6},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:C5}].concat(E5),O5=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,k5=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(O5(e)):O5,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return xJ(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=SJ(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=CJ(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(k5.prototype[Symbol.iterator]=function(){return this});var A5={from:-1,to:-1,match:/.*/.exec(``),precise:!0},j5=`gm`+(/x/.unicode==null?``:`u`),M5=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=A5,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new F5(e,t,n,r,i);this.re=new RegExp(t,j5+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=L5(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=L5(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},N5=new WeakMap,P5=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=N5.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return N5.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),N5.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},F5=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=A5,this.matchPos=L5(e,r),this.re=new RegExp(t,j5+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=P5.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=L5(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=P5.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(M5.prototype[Symbol.iterator]=F5.prototype[Symbol.iterator]=function(){return this});function I5(e){try{return new RegExp(e,j5),!0}catch{return!1}}function L5(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var R5=e=>{let t=i4(e,`cm-goto-line`);if(t){let e=t.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:i,result:a}=r4(e,{class:`cm-goto-line`,label:n.phrase(`Go to line`),input:{type:`text`,name:`line`,value:r},focus:!0,submitLabel:n.phrase(`go`)});return a.then(t=>{let r=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!r){e.dispatch({effects:i});return}let a=n.doc.lineAt(n.selection.main.head),[,o,s,c,l]=r,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/n.doc.lines),d=Math.round(n.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=n.doc.line(Math.max(1,Math.min(n.doc.lines,d))),p=q.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[i,X.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},z5=({state:e,dispatch:t})=>{let{selection:n}=e,r=q.create(n.ranges.map(t=>e.wordAt(t.head)||q.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function B5(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new k5(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new k5(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var V5=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return z5({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=B5(e,r);return i?(t(e.update({selection:e.selection.addRange(q.range(i.from,i.to),!1),effects:X.scrollIntoView(i.to)})),!0):!1},H5=J.define({combine(e){return EY(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new C7(e),scrollToMatch:e=>X.scrollIntoView(e)})}});function U5(e){return e?[H5.of(e),k7]:k7}var W5=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||I5(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
121
|
-
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new t7(this):new Y5(this)}getCursor(e,t=0,n){let r=e.doc?e:TY.create({doc:e});return n??=r.doc.length,this.regexp?Z5(this,r,t,n):q5(this,r,t,n)}},G5=class{constructor(e){this.spec=e}};function K5(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function q5(e,t,n,r){let i;return e.wholeWord&&(i=J5(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=K5(e.test,t,i)),new k5(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function J5(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(Q5(i,n-a))!=bY.Word||t($5(i,n-a))!=bY.Word)&&(t($5(i,r-a))!=bY.Word||t(Q5(i,r-a))!=bY.Word))}var Y5=class extends G5{constructor(e){super(e)}nextMatch(e,t,n){let r=q5(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=q5(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=q5(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=q5(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=q5(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function X5(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function Z5(e,t,n,r){let i;return e.wholeWord&&(i=e7(t.charCategorizer(t.selection.main.head))),e.test&&(i=X5(e.test,t,i)),new M5(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function Q5(e,t){return e.slice(vJ(e,t,!1),t)}function $5(e,t){return e.slice(t,vJ(e,t))}function e7(e){return(t,n,r)=>!r[0].length||(e(Q5(r.input,r.index))!=bY.Word||e($5(r.input,r.index))!=bY.Word)&&(e($5(r.input,r.index+r[0].length))!=bY.Word||e(Q5(r.input,r.index+r[0].length))!=bY.Word)}var t7=class extends G5{nextMatch(e,t,n){let r=Z5(this.spec,e,n,e.doc.length).next();return r.done&&(r=Z5(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=Z5(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=Z5(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=Z5(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},n7=uY.define(),r7=uY.define(),i7=UJ.define({create(e){return new a7(_7(e).create(),null)},update(e,t){for(let n of t.effects)n.is(n7)?e=new a7(n.value.create(),e.panel):n.is(r7)&&(e=new a7(e.query,n.value?g7:null));return e},provide:e=>n4.from(e,e=>e.panel)}),a7=class{constructor(e,t){this.query=e,this.panel=t}},o7=xZ.mark({class:`cm-searchMatch`}),s7=xZ.mark({class:`cm-searchMatch cm-searchMatch-selected`}),c7=qQ.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(i7))}update(e){let t=e.state.field(i7);(t!=e.startState.field(i7)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return xZ.none;let{view:n}=this,r=new FY;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?s7:o7)})}return r.finish()}},{decorations:e=>e.decorations});function l7(e){return t=>{let n=t.state.field(i7,!1);return n&&n.query.spec.valid?e(t,n):b7(t)}}var u7=l7((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=q.single(r.from,r.to),a=e.state.facet(H5);return e.dispatch({selection:i,effects:[D7(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),y7(e),!0}),d7=l7((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=q.single(i.from,i.to),o=e.state.facet(H5);return e.dispatch({selection:a,effects:[D7(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),y7(e),!0}),f7=l7((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:q.create(n.map(e=>q.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),p7=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new k5(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(q.range(t.value.from,t.value.to))}return t(e.update({selection:q.create(a,o),userEvent:`select.search.matches`})),!0},m7=l7((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(X.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=q.single(o.from,o.to).map(d),u.push(D7(e,o)),u.push(n.facet(H5).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),h7=l7((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:X.announce.of(r),userEvent:`input.replace.all`}),!0});function g7(e){return e.state.facet(H5).createPanel(e)}function _7(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(H5);return new W5({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function v7(e){let t=Q2(e,g7);return t&&t.dom.querySelector(`[main-field]`)}function y7(e){let t=v7(e);t&&t==e.root.activeElement&&t.select()}var b7=e=>{let t=e.state.field(i7,!1);if(t&&t.panel){let n=v7(e);if(n&&n!=e.root.activeElement){let r=_7(e.state,t.query.spec);r.valid&&e.dispatch({effects:n7.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[r7.of(!0),t?n7.of(_7(e.state,t.query.spec)):uY.appendConfig.of(k7)]});return!0},x7=e=>{let t=e.state.field(i7,!1);if(!t||!t.panel)return!1;let n=Q2(e,g7);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:r7.of(!1)}),!0},S7=[{key:`Mod-f`,run:b7,scope:`editor search-panel`},{key:`F3`,run:u7,shift:d7,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:u7,shift:d7,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:x7,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:p7},{key:`Mod-Alt-g`,run:R5},{key:`Mod-d`,run:V5,preventDefault:!0}],C7=class{constructor(e){this.view=e;let t=this.query=e.state.field(i7).query.spec;this.commit=this.commit.bind(this),this.searchField=eZ(`input`,{value:t.search,placeholder:w7(e,`Find`),"aria-label":w7(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=eZ(`input`,{value:t.replace,placeholder:w7(e,`Replace`),"aria-label":w7(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=eZ(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=eZ(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=eZ(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return eZ(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=eZ(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>u7(e),[w7(e,`next`)]),n(`prev`,()=>d7(e),[w7(e,`previous`)]),n(`select`,()=>f7(e),[w7(e,`all`)]),eZ(`label`,null,[this.caseField,w7(e,`match case`)]),eZ(`label`,null,[this.reField,w7(e,`regexp`)]),eZ(`label`,null,[this.wordField,w7(e,`by word`)]),...e.state.readOnly?[]:[eZ(`br`),this.replaceField,n(`replace`,()=>m7(e),[w7(e,`replace`)]),n(`replaceAll`,()=>h7(e),[w7(e,`replace all`)])],eZ(`button`,{name:`close`,onclick:()=>x7(e),"aria-label":w7(e,`close`),type:`button`},[`×`])])}commit(){let e=new W5({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:n7.of(e)}))}keydown(e){m2(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?d7:u7)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),m7(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(n7)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(H5).top}};function w7(e,t){return e.state.phrase(t)}var T7=30,E7=/[\s\.,:;?!]/;function D7(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-T7),o=Math.min(i,n+T7),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<T7;e++)if(!E7.test(s[e+1])&&E7.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-T7;e--)if(!E7.test(s[e-1])&&E7.test(s[e])){s=s.slice(0,e);break}}return X.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var O7=X.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),k7=[i7,KJ.low(c7),O7],A7=`No task on this line`,j7=(e,t,n,r)=>{try{let i=M7(e),a=N7(e,t),o=r??new Date;switch(n){case`newTask`:return G(cte(i,a),`src/editor/actions.ts#runAction`);case`toggleDone`:return G(e9(i,a,`done`,o),`src/editor/actions.ts#runAction`);case`toggleCancelled`:return G(e9(i,a,`cancelled`,o),`src/editor/actions.ts#runAction`);case`archive`:return G(hte(i,a),`src/editor/actions.ts#runAction`);case`moveUp`:return G(r9(i,a,`up`),`src/editor/actions.ts#runAction`);case`moveDown`:return G(r9(i,a,`down`),`src/editor/actions.ts#runAction`);case`continueTask`:return G(Tte(i,a),`src/editor/actions.ts#runAction`);case`indent`:return G(a9(i,a,!1),`src/editor/actions.ts#runAction`);case`outdent`:return G(a9(i,a,!0),`src/editor/actions.ts#runAction`);case`tab`:return G(Dte(i,a,o),`src/editor/actions.ts#runAction`);default:return G(F7(`Unknown action`),`src/editor/actions.ts#runAction`)}}catch{return G(F7(`Action unavailable`),`src/editor/actions.ts#runAction`)}};function M7(e){let t=CX(e),n=`
|
|
122
|
-
`;for(let r=0;r+1<t.length;r++){let i=t[r],a=t[r+1];if(i!==void 0&&a!==void 0){let t=e.slice(i.to,a.from);if(t.includes(`
|
|
123
|
-
`)){n=t;break}}}return G({text:e,lines:t,newline:n},`src/editor/actions.ts#documentView`)}function N7(e,t){let n=(Array.isArray(t.ranges)?t.ranges:[]).map(t=>G({anchor:P7(e,t.anchor),head:P7(e,t.head)},`src/editor/actions.ts#anonymous`)),r=Number.isFinite(t.main)?Math.trunc(t.main):0;return G({ranges:n,main:n.length===0?0:Math.min(Math.max(r,0),n.length-1)},`src/editor/actions.ts#normalizeSelection`)}function P7(e,t){return G(Number.isFinite(t)?Math.min(Math.max(Math.trunc(t),0),e.length):0,`src/editor/actions.ts#clampOffset`)}function F7(e){return G({_tag:`Unavailable`,reason:e},`src/editor/actions.ts#unavailable`)}function I7(e,t){let n=P7(e.text,t);for(let t=0;t<e.lines.length;t++){let r=e.lines[t],i=e.lines[t+1];if(r!==void 0&&(n>=r.from&&n<=r.to||i!==void 0&&n>r.to&&n<i.from))return G(t,`src/editor/actions.ts#lineAt`)}return G(Math.max(e.lines.length-1,0),`src/editor/actions.ts#lineAt`)}function L7(e){return G(e.anchor<=e.head?{from:e.anchor,to:e.head}:{from:e.head,to:e.anchor},`src/editor/actions.ts#rangeBounds`)}function R7(e,t){let n=L7(e);return t.from<t.to?G(n.from<t.to&&n.to>t.from,`src/editor/actions.ts#intersectsLine`):G(n.from<=t.from&&n.to>t.from,`src/editor/actions.ts#intersectsLine`)}function z7(e,t){let n=new Set;for(let r of t.ranges)if(r.anchor===r.head)n.add(I7(e,r.head));else for(let t=0;t<e.lines.length;t++){let i=e.lines[t];i!==void 0&&R7(r,i)&&n.add(t)}return G([...n].sort((e,t)=>G(e-t,`src/editor/actions.ts#anonymous~2`)),`src/editor/actions.ts#selectedLines`)}function B7(e){return G(e.kind===`item`||e.kind===`paragraph`,`src/editor/actions.ts#isOwnableLine`)}function V7(e,t){if(e.lines[t]===void 0)return G(void 0,`src/editor/actions.ts#containingTask`);for(let n=t-1;n>=0;n--)if(e.lines[n]?.state!==void 0&&wX(e.lines,n)>t)return G(n,`src/editor/actions.ts#containingTask`);return G(void 0,`src/editor/actions.ts#containingTask`)}function H7(e,t){let n=e.lines[t];return n?.state===void 0?n===void 0||!B7(n)?G(void 0,`src/editor/actions.ts#ownerForLine`):G(V7(e,t),`src/editor/actions.ts#ownerForLine`):G(t,`src/editor/actions.ts#ownerForLine`)}function U7(e,t,n,r=n){let i=new Set;for(let a of t.ranges)if(a.anchor===a.head){let t=I7(e,a.head),r=n?H7(e,t):e.lines[t]?.state===void 0?void 0:t;r!==void 0&&i.add(r)}else for(let t of z7(e,{ranges:[a],main:0}))if(e.lines[t]?.state!==void 0)i.add(t);else if(r){let n=H7(e,t);n!==void 0&&i.add(n)}return G([...i].sort((e,t)=>G(e-t,`src/editor/actions.ts#anonymous~3`)),`src/editor/actions.ts#taskTargets`)}function W7(e,t){return G(t.filter(n=>G(!t.some(t=>G(t<n&&wX(e.lines,t)>n,`src/editor/actions.ts#anonymous~5`)),`src/editor/actions.ts#anonymous~4`)),`src/editor/actions.ts#maximalRoots`)}function G7(e,t){let n=e.lines[t],r=e.text.slice(n.from,n.from+n.indent),i=e.text[n.from+n.indent];return G({text:`${r}${i===`-`||i===`*`||i===`+`?i:`-`} [ ] `},`src/editor/actions.ts#taskPrefix`)}function K7(e,t){return G(Math.max(wX(e.lines,t)-1,t),`src/editor/actions.ts#taskBlockLast`)}function q7(e,t){return G(e.lines[K7(e,t)]?.to??e.text.length,`src/editor/actions.ts#taskBlockEndOffset`)}function J7(e,t){return G(t.filter(t=>G(t.from>=0&&t.to>=t.from&&t.to<=e.text.length&&e.text.slice(t.from,t.to)!==t.insert,`src/editor/actions.ts#anonymous~6`)).sort((e,t)=>G(e.from-t.from||e.to-t.to,`src/editor/actions.ts#anonymous~7`)),`src/editor/actions.ts#filterEdits`)}function Y7(e,t){let n=[...t].sort((e,t)=>G(e.from-t.from||e.to-t.to,`src/editor/actions.ts#anonymous~8`)),r=0,i=[];for(let t of n)i.push(e.slice(r,t.from),t.insert),r=t.to;return i.push(e.slice(r)),G(i.join(``),`src/editor/actions.ts#applyRaw`)}function X7(e,t){let n=0;for(let r of t){if(r.from>e)break;if(r.to>e)return G(r.from+n+r.insert.length,`src/editor/actions.ts#mapOffset`);n+=r.insert.length-(r.to-r.from)}return G(e+n,`src/editor/actions.ts#mapOffset`)}function Z7(e,t){return G({ranges:e.ranges.map(e=>G({anchor:X7(e.anchor,t),head:X7(e.head,t)},`src/editor/actions.ts#anonymous~9`)),main:e.main},`src/editor/actions.ts#mapSelection`)}function ste(e,t){let n=e=>{let n=0;for(let r of t){if(e<r.from)break;if(e<r.to)return G(r.from+n+Math.min(e-r.from,r.insert.length),`src/editor/actions.ts#mapEndpoint`);n+=r.insert.length-(r.to-r.from)}return G(e+n,`src/editor/actions.ts#mapEndpoint`)};return G({ranges:e.ranges.map(e=>G({anchor:n(e.anchor),head:n(e.head)},`src/editor/actions.ts#anonymous~10`)),main:e.main},`src/editor/actions.ts#mapSelectionPreservingReplacements`)}function Q7(e,t){let n=0;for(let r of t){if(r.from>e)break;(r.from!==e||r.to!==e)&&r.to<=e&&(n+=r.insert.length-(r.to-r.from))}return G(e+n,`src/editor/actions.ts#insertionDestination`)}function $7(e,t,n,r){let i=Z7(e,t),a=i.ranges.map((e,r)=>{let i=n.get(r);if(i===void 0)return G(e,`src/editor/actions.ts#anonymous~11`);let a=Q7(i.at,t)+i.relative;return G({anchor:a,head:a},`src/editor/actions.ts#anonymous~11`)});if(r!==void 0){let e=Q7(r.at,t)+r.relative;a[i.main]={anchor:e,head:e}}return G({ranges:a,main:i.main},`src/editor/actions.ts#withCarets`)}function cte(e,t){let n=[],r=new Map,i=z7(e,t);if(t.ranges.some(e=>G(e.anchor!==e.head,`src/editor/actions.ts#anonymous~12`))){let a=i.filter(t=>{let n=e.lines[t];return G(n!==void 0&&n.state===void 0&&(n.kind===`item`||n.kind===`paragraph`||n.kind===`blank`),`src/editor/actions.ts#anonymous~13`)});if(a.length>0){for(let t of a){let r=e.lines[t],i=e.text.slice(r.from,r.from+r.indent);r.kind===`blank`?n.push({from:r.content,to:r.content,insert:`- [ ] `}):n.push({from:r.from,to:r.content,insert:`${i}- [ ] `})}let r=J7(e,n);return G(r.length===0?F7(`No task can be created on this line`):{_tag:`Applied`,edits:r,selection:Z7(t,r)},`src/editor/actions.ts#newTask`)}let o=U7(e,t,!0),s=i.every(t=>{let n=e.lines[t];return n?.state===void 0?n?.kind===`blank`?G(V7(e,t)!==void 0,`src/editor/actions.ts#anonymous~14`):G(n!==void 0&&H7(e,t)!==void 0,`src/editor/actions.ts#anonymous~14`):G(!0,`src/editor/actions.ts#anonymous~14`)});if(o.length>0&&s){let i=W7(e,o).at(-1);if(i!==void 0){let a=q7(e,i),o=G7(e,i).text,s=`${e.newline}${o}`,c={from:a,to:a,insert:s};n.push(c);let l={at:a,relative:s.length},u=J7(e,n);return G({_tag:`Applied`,edits:u,selection:$7(t,u,r,l)},`src/editor/actions.ts#newTask`)}}return G(F7(`No task can be created on this line`),`src/editor/actions.ts#newTask`)}let a=t.ranges[t.main];if(a===void 0)return G(F7(`No task can be created on this line`),`src/editor/actions.ts#newTask`);let o=I7(e,a.head),s=e.lines[o];if(s===void 0)return G(F7(`No task can be created on this line`),`src/editor/actions.ts#newTask`);let c=s.state===void 0?H7(e,o):o;if(c!==void 0){let i=q7(e,c),a=`${e.newline}${G7(e,c).text}`;n.push({from:i,to:i,insert:a}),r.set(t.main,{at:i,relative:a.length})}else if(s.kind===`heading`){let i=`${e.newline}- [ ] `;n.push({from:s.to,to:s.to,insert:i}),r.set(t.main,{at:s.to,relative:i.length})}else if(s.kind===`blank`)n.push({from:s.content,to:s.content,insert:`- [ ] `}),r.set(t.main,{at:s.content,relative:6});else if(s.kind===`item`||s.kind===`paragraph`){let t=e.text.slice(s.from,s.from+s.indent);n.push({from:s.from,to:s.content,insert:`${t}- [ ] `})}else return G(F7(`No task can be created on this line`),`src/editor/actions.ts#newTask`);let l=J7(e,n);return G(l.length===0?F7(`No task can be created on this line`):{_tag:`Applied`,edits:l,selection:$7(t,l,r)},`src/editor/actions.ts#newTask`)}function e9(e,t,n,r){let i=U7(e,t,!0,!1);if(i.length===0)return G(F7(A7),`src/editor/actions.ts#toggle`);if(n===`cancelled`&&i.every(t=>G(e.lines[t]?.state===`done`,`src/editor/actions.ts#anonymous~15`)))return G(F7(`Reopen completed tasks before cancelling`),`src/editor/actions.ts#toggle`);let a=[],o=RX(e.text);for(let t of i){let i=e.lines[t];if(i?.checkbox===void 0||i.state===void 0)continue;let s=o.find(e=>G(e.line===t,`src/editor/actions.ts#anonymous~16`));if(s===void 0)continue;let c=n===`done`?i.state===`done`?`open`:`done`:i.state===`cancelled`?`open`:i.state===`done`?`done`:`cancelled`;a.push(...LX(e.text,s,c,r))}let s=J7(e,a);return G(s.length===0?F7(A7):{_tag:`Applied`,edits:s,selection:ste(t,s)},`src/editor/actions.ts#toggle`)}function lte(e,t){let n=e.lines[t];return G(n?.kind===`heading`&&n.level===2&&n.depth===0&&e.text.slice(n.content,n.to).trim()===`Archive`,`src/editor/actions.ts#isArchiveHeading`)}function ute(e){let t=[];for(let n=0;n<e.lines.length;n++){if(!lte(e,n))continue;let r=e.lines.length;for(let t=n+1;t<e.lines.length;t++){let n=e.lines[t];if(n?.kind===`heading`&&n.depth===0&&(n.level===1||n.level===2)){r=t;break}}t.push({start:n,end:r})}return G(t,`src/editor/actions.ts#archiveRegions`)}function dte(e,t){return G(t.some(t=>G(e>=t.start&&e<t.end,`src/editor/actions.ts#anonymous~17`)),`src/editor/actions.ts#inArchive`)}function fte(e,t){for(let n=t-1;n>=0;n--){let t=e.lines[n];if(t?.kind===`heading`)return G(e.text.slice(t.content,t.to).trim().replace(/#+$/,``).trim(),`src/editor/actions.ts#nearestHeadingTitle`)}return G(void 0,`src/editor/actions.ts#nearestHeadingTitle`)}function pte(e){return G(/(?:^|[ \t])@project(?:[ \t]*\([^()\r\n]*\))?(?=$|[ \t])/.test(e),`src/editor/actions.ts#hasProjectTag`)}function mte(e,t){let n=e.lines[t],r=e.text.slice(n.content,n.to),i=fte(e,t);if(!i||pte(r))return G(e.text.slice(n.from,n.to),`src/editor/actions.ts#archiveTaskLine`);let a=/[ \t]*$/.exec(r),o=r.slice(0,a.index);return G(`${e.text.slice(n.from,n.content)}${o} @project(${i})${a[0]}`,`src/editor/actions.ts#archiveTaskLine`)}function hte(e,t){let n=ute(e),r=t.ranges.some(e=>G(e.anchor!==e.head,`src/editor/actions.ts#anonymous~18`))?new Set(z7(e,t)):void 0,i=W7(e,e.lines.map((e,t)=>G({line:e,index:t},`src/editor/actions.ts#anonymous~19`)).filter(e=>G((e.line.state===`done`||e.line.state===`cancelled`)&&!dte(e.index,n),`src/editor/actions.ts#anonymous~20`)).filter(t=>G(e.text.slice(t.line.content,t.line.to).trim()!==``,`src/editor/actions.ts#anonymous~21`)).filter(t=>{let n=wX(e.lines,t.index);for(let r=t.index+1;r<n;r++)if(e.lines[r]?.state===`open`)return G(!1,`src/editor/actions.ts#anonymous~22`);return G(!0,`src/editor/actions.ts#anonymous~22`)}).filter(e=>G(r===void 0||r.has(e.index),`src/editor/actions.ts#anonymous~23`)).map(e=>G(e.index,`src/editor/actions.ts#anonymous~24`)));if(i.length===0)return G(F7(`No completed or cancelled tasks to archive`),`src/editor/actions.ts#archive`);let a=[...i.map(t=>{let n=K7(e,t),r=e.text.slice(e.lines[t].from,e.lines[n].to);return G({index:t,raw:`${mte(e,t)}${e.text.slice(e.lines[t].to,e.lines[n].to)}`,sourceRaw:r},`src/editor/actions.ts#anonymous~25`)})].reverse(),o=a.map(t=>G(t9(t.raw,e.lines[t.index].depth),`src/editor/actions.ts#anonymous~26`)).join(e.newline),s=_te(i.map(t=>G(gte(e,t),`src/editor/actions.ts#anonymous~27`))).map(e=>G({from:e.from,to:e.to,insert:``},`src/editor/actions.ts#anonymous~28`)),c=Y7(e.text,s),l=n[0],u,d,f;if(l===void 0){u=e.text.length;let t=c.replace(/\r?\n/g,``).trim()===``,n=/(?:\r?\n){2}$/.test(c),r=t||n?``:c.endsWith(`
|
|
124
|
-
`)?e.newline:`${e.newline}${e.newline}`,i=e.text.endsWith(`
|
|
125
|
-
`)?e.newline:``,a=`${r}## Archive${e.newline}${e.newline}`;d=`${a}${o}${i}`,f=a.length}else u=e.lines[l.start]?.to??e.text.length,d=`${e.newline}${o}`,f=e.newline.length;let p={from:u,to:u,insert:d},m=J7(e,[...s,p]);if(m.length===0)return G(F7(`No completed or cancelled tasks to archive`),`src/editor/actions.ts#archive`);let h=Q7(u,s),g=[],_=h+f;for(let t of a){let n=t9(t.raw,e.lines[t.index].depth);g.push({from:e.lines[t.index].from,to:e.lines[K7(e,t.index)].to,offsetMap:vte(t.sourceRaw,t.raw,e.lines[t.index].depth,e.lines[t.index].to-e.lines[t.index].from),destination:_}),_+=n.length+e.newline.length}return G({_tag:`Applied`,edits:m,selection:yte(t,m,g)},`src/editor/actions.ts#archive`)}function gte(e,t){let n=K7(e,t),r=e.lines[t].from,i=e.lines[n].to,a=n+1,o=e.lines[a];if(o!==void 0&&(i=o.from,o.kind===`blank`)){let n=e.lines[t-1],o=e.lines[a+1];n?.kind===`blank`?r=n.from:n===void 0&&(i=o?.from??e.text.length)}return G({from:r,to:i},`src/editor/actions.ts#archiveDeletionRange`)}function _te(e){let t=[...e].sort((e,t)=>G(e.from-t.from||e.to-t.to,`src/editor/actions.ts#anonymous~29`)),n=[];for(let e of t){let t=n.at(-1);t!==void 0&&e.from<=t.to?t.to=Math.max(t.to,e.to):n.push({from:e.from,to:e.to})}return G(n,`src/editor/actions.ts#mergeRanges`)}function t9(e,t){return G(n9(e,t).text,`src/editor/actions.ts#dedent`)}function vte(e,t,n,r){let i=n9(t,n).offsetMap,a=t.length-e.length;return G(Array.from({length:e.length+1},(e,t)=>{let n=t<=r?t:t+a;return G(i[n]??i[i.length-1]??0,`src/editor/actions.ts#anonymous~30`)}),`src/editor/actions.ts#archiveOffsetMap`)}function n9(e,t){let n=``,r=!0,i=0,a=[0];for(let o=0;o<e.length;o++){let s=e[o];r&&i<t&&(s===` `||s===` `)?(i+=s===` `?4:1,a[o+1]=n.length):(n+=s,a[o+1]=n.length,s===`
|
|
126
|
-
`?(r=!0,i=0):r=!1)}return G({text:n,offsetMap:a},`src/editor/actions.ts#dedentWithMap`)}function yte(e,t,n){let r=e=>{for(let t of n)if(e>=t.from&&e<=t.to){let n=Math.min(Math.max(e-t.from,0),t.offsetMap.length-1);return G(t.destination+(t.offsetMap[n]??0),`src/editor/actions.ts#endpoint`)}return G(X7(e,t),`src/editor/actions.ts#endpoint`)};return G({ranges:e.ranges.map(e=>{let t=L7(e),i=n.some(e=>G(t.from<e.to&&t.to>e.from,`src/editor/actions.ts#anonymous~32`)),a=n.some(t=>G(e.anchor>=t.from&&e.anchor<=t.to&&e.head>=t.from&&e.head<=t.to,`src/editor/actions.ts#anonymous~33`));if(i&&!a){let t=r(e.head);return G({anchor:t,head:t},`src/editor/actions.ts#anonymous~31`)}return G({anchor:r(e.anchor),head:r(e.head)},`src/editor/actions.ts#anonymous~31`)}),main:e.main},`src/editor/actions.ts#mapArchiveSelection`)}function bte(e,t){if(e.lines[t]?.state!==void 0)return G({start:t,end:wX(e.lines,t)},`src/editor/actions.ts#moveUnitForLine`);let n=V7(e,t);return G(n===void 0?{start:t,end:t+1}:{start:n,end:wX(e.lines,n)},`src/editor/actions.ts#moveUnitForLine`)}function xte(e,t){let n=t.ranges.some(e=>G(e.anchor!==e.head,`src/editor/actions.ts#anonymous~34`))?z7(e,t):t.ranges[t.main]===void 0?[]:[I7(e,t.ranges[t.main].head)];if(n.length===0)return G(void 0,`src/editor/actions.ts#selectedMoveUnit`);let r=e.lines.length,i=0;for(let t of n){let n=bte(e,t);r=Math.min(r,n.start),i=Math.max(i,n.end)}return G(r<i?{start:r,end:i}:void 0,`src/editor/actions.ts#selectedMoveUnit`)}function Ste(e,t,n){let r;for(let i=0;i<t;i++){let a=e.lines[i];a?.state===void 0||a.depth>n||wX(e.lines,i)===t&&(r={start:i,end:t})}return G(r,`src/editor/actions.ts#taskBlockEndingAt`)}function Cte(e,t,n){if(n===`down`){let n=e.lines[t.end];return G(n===void 0?void 0:n.state===void 0?{start:t.end,end:t.end+1}:{start:t.end,end:wX(e.lines,t.end)},`src/editor/actions.ts#moveNeighbor`)}let r=e.lines[t.start],i=t.start-1;return G(r===void 0||i<0?void 0:Ste(e,t.start,r.depth)??{start:i,end:t.start},`src/editor/actions.ts#moveNeighbor`)}function r9(e,t,n){let r=xte(e,t);if(r===void 0)return G(F7(n===`up`?`Already at the top`:`Already at the bottom`),`src/editor/actions.ts#move`);let i=Cte(e,r,n);if(i===void 0)return G(F7(n===`up`?`Already at the top`:`Already at the bottom`),`src/editor/actions.ts#move`);let a=n===`up`?i9(e,i,r,`up`):i9(e,r,i,`down`),o=J7(e,[{from:a.from,to:a.to,insert:a.insert}]);return o.length===0?G(F7(n===`up`?`Already at the top`:`Already at the bottom`),`src/editor/actions.ts#move`):G({_tag:`Applied`,edits:o,selection:wte(t,o,[a])},`src/editor/actions.ts#move`)}function i9(e,t,n,r){let i=e.lines[t.start].from,a=e.lines[t.end-1].to,o=e.lines[n.start].from,s=e.lines[n.end-1].to,c=e.text.slice(i,a),l=e.text.slice(a,o),u=e.text.slice(o,s),d={from:i,to:a,destination:u.length+l.length,block:!0},f={from:o,to:s,destination:0,block:!0},p={from:a,to:o,destination:u.length,block:!1};return G({from:i,to:s,insert:`${u}${l}${c}`,pieces:[f,p,d],moving:r===`up`?f:d},`src/editor/actions.ts#makeMoveOperation`)}function wte(e,t,n){let r=[...n].sort((e,t)=>G(e.from-t.from,`src/editor/actions.ts#anonymous~35`)),i=e=>{let t=0;for(let n of r){if(n.from>=e.from)break;t+=n.insert.length-(n.to-n.from)}return G(t,`src/editor/actions.ts#beforeShift`)},a=e=>{for(let t of r){if(e<t.from||e>t.to)continue;let n=[...t.pieces].sort((e,t)=>G(Number(t.block)-Number(e.block)||e.from-t.from,`src/editor/actions.ts#anonymous~36`)),r=n.find(t=>G(e>=t.from&&e<=t.to,`src/editor/actions.ts#anonymous~37`))??n.find(t=>G(e>t.from&&e<t.to,`src/editor/actions.ts#anonymous~38`));if(r!==void 0)return G(t.from+i(t)+r.destination+(e-r.from),`src/editor/actions.ts#endpoint~2`)}return G(X7(e,t),`src/editor/actions.ts#endpoint~2`)},o=(e,t,n,r)=>{let i=L7(t),o=n.moving;if(e===o.from)return G(n.from+r+o.destination,`src/editor/actions.ts#endpointForRange`);if(e===o.to)return G(n.from+r+o.destination+(o.to-o.from),`src/editor/actions.ts#endpointForRange`);let s=n.pieces.find(e=>G(!e.block,`src/editor/actions.ts#anonymous~39`));return s!==void 0&&e===s.from&&i.to<=s.from?G(n.from+r+o.destination+(o.to-o.from),`src/editor/actions.ts#endpointForRange`):G(a(e),`src/editor/actions.ts#endpointForRange`)},s=e=>{let t=0;for(let n of r){if(n.from>=e.from)break;t+=n.insert.length-(n.to-n.from)}return G(t,`src/editor/actions.ts#shiftFor`)};return G({ranges:e.ranges.map(e=>{let t=r.find(t=>G(L7(e).from<=t.to&&L7(e).to>=t.from,`src/editor/actions.ts#anonymous~41`));return G(t===void 0?{anchor:a(e.anchor),head:a(e.head)}:{anchor:o(e.anchor,e,t,s(t)),head:o(e.head,e,t,s(t))},`src/editor/actions.ts#anonymous~40`)}),main:e.main},`src/editor/actions.ts#mapMoveSelection`)}function Tte(e,t){if(t.ranges.length!==1)return G(F7(`Not a task`),`src/editor/actions.ts#continueTask`);let n=t.ranges[0];if(n===void 0||n.anchor!==n.head)return G(F7(`Not a task`),`src/editor/actions.ts#continueTask`);let r=I7(e,n.head),i=e.lines[r];if(i?.state===void 0||i.content>n.head||n.head>i.to)return G(F7(`Not a task`),`src/editor/actions.ts#continueTask`);let a=G7(e,r).text;if(i.content===i.to)return G({_tag:`Applied`,edits:J7(e,[{from:i.from+i.indent,to:i.content,insert:``}]),selection:{ranges:[{anchor:i.from+i.indent,head:i.from+i.indent}],main:0}},`src/editor/actions.ts#continueTask`);let o=n.head,s=e.text.slice(o,i.to),c=o===i.to?q7(e,r):o,l=`${e.newline}${a}${s}`,u={from:c,to:o===i.to&&c!==o?c:i.to,insert:l},d=J7(e,[u]),f=Q7(u.from,d)+e.newline.length+a.length;return G({_tag:`Applied`,edits:d,selection:{ranges:[{anchor:f,head:f}],main:0}},`src/editor/actions.ts#continueTask`)}function Ete(e,t){let n=IX(t);switch(e){case`s`:return G({insert:`@started`,caret:8},`src/editor/actions.ts#tabSnippet`);case`t`:return G({insert:`@today`,caret:6},`src/editor/actions.ts#tabSnippet`);case`c`:return G({insert:`@critical`,caret:9},`src/editor/actions.ts#tabSnippet`);case`h`:return G({insert:`@high`,caret:5},`src/editor/actions.ts#tabSnippet`);case`l`:return G({insert:`@low`,caret:4},`src/editor/actions.ts#tabSnippet`);case`cr`:return G({insert:`@created`,caret:8},`src/editor/actions.ts#tabSnippet`);case`d`:return G({insert:`@due( )`,caret:6},`src/editor/actions.ts#tabSnippet`);case`@s`:return G({insert:`@started(${n})`,caret:`@started(${n})`.length},`src/editor/actions.ts#tabSnippet`);case`@started`:case`@created`:{let e=`(${n})`;return G({insert:e,caret:e.length},`src/editor/actions.ts#tabSnippet`)}default:return G(void 0,`src/editor/actions.ts#tabSnippet`)}}function Dte(e,t,n){if(t.ranges.length===1){let r=t.ranges[0];if(r!==void 0&&r.anchor===r.head){let t=I7(e,r.head),i=e.lines[t];if(i!==void 0&&i.kind!==`code`&&i.kind!==`fence`&&r.head<=i.to){let t=e.text.slice(i.from,r.head),a=/(?:^|[ \t(])(@?[A-Za-z]+)$/.exec(t)?.[1];if(a!==void 0){let t=Ete(a,n),i=e.text[r.head]===`(`,o=a===`@started`||a===`@created`;if(t!==void 0&&(!o||!i)){let n=o?r.head:r.head-a.length,i=J7(e,[{from:n,to:r.head,insert:t.insert}]);if(i.length>0){let e=n+t.caret;return G({_tag:`Applied`,edits:i,selection:{ranges:[{anchor:e,head:e}],main:0}},`src/editor/actions.ts#tab`)}}}}}}return G(a9(e,t,!1),`src/editor/actions.ts#tab`)}function a9(e,t,n){let r=new Set;for(let n of t.ranges){let t=n.anchor===n.head?[I7(e,n.head)]:z7(e,{ranges:[n],main:0});for(let n of t)if(e.lines[n]?.state!==void 0){let t=wX(e.lines,n);for(let e=n;e<t;e++)r.add(e)}else r.add(n)}let i=[];for(let t of[...r].sort((e,t)=>G(e-t,`src/editor/actions.ts#anonymous~42`))){let r=e.lines[t];if(r!==void 0&&r.kind!==`code`&&r.kind!==`fence`){if(!n)i.push({from:r.from,to:r.from,insert:` `});else if(e.text[r.from]===` `)i.push({from:r.from,to:r.from+1,insert:``});else{let t=0;for(;t<2&&e.text[r.from+t]===` `;)t++;t>0&&i.push({from:r.from,to:r.from+t,insert:``})}}}let a=J7(e,i);return G(a.length===0?F7(`Nothing to change`):{_tag:`Applied`,edits:a,selection:Z7(t,a)},`src/editor/actions.ts#indent`)}var o9=sY.define(),s9=uY.define(),c9=J.define({combine:e=>G((t=>{for(let n of e)n(t)}),`src/editor/facts.ts#combine`)}),l9=new Set([`project`,`task`,`status`,`note`,`prose`,`quote`]),Ote=(e,t,n)=>{let r=t,i=n;for(;r<i&&/\s/.test(e[r]);)r+=1;for(;i>r&&/\s/.test(e[i-1]);)--i;return G({from:r,to:i},`src/editor/lines.ts#trimRange`)},kte=e=>{let t=e.length;for(;t>0&&/[.,!?;:]/.test(e[t-1]);)--t;let n=0;for(let r=0;r<t;r+=1)e[r]===`(`?n+=1:e[r]===`)`&&--n;for(;t>0&&e[t-1]===`)`&&n<0;)--t,n+=1;return G(e.slice(0,t),`src/editor/lines.ts#trimBareUrlEnd`)},u9=(e,t,n)=>{let r=e.slice(t,n),i=[];for(let e of r.matchAll(/\[([^\[\]\r\n]*)\]\(([^()\s]+)\)/g)){let n=e[0],r=e[2],a=t+e.index;i.push({from:a,to:a+n.length,target:r,label:{from:a+1,to:a+1+e[1].length}})}for(let e of r.matchAll(/<((?:https?:\/\/|mailto:)[^<>\s]+)>/gi)){let n=e[0],r=e[1],a=t+e.index;i.push({from:a,to:a+n.length,target:r,label:{from:a+1,to:a+n.length-1}})}for(let e of r.matchAll(/(?:https?:\/\/|mailto:)[^\s<>\[\]]+/gi)){let n=e[0],r=kte(n);if(!r)continue;let a=t+e.index;i.push({from:a,to:a+r.length,target:r,label:{from:a,to:a+r.length}})}return G(i,`src/editor/lines.ts#linkCandidates`)},Ate=(e,t)=>{let n=[];for(let r of e.matchAll(/@([\p{L}\p{N}_-]+)(?:[ \t]?\([^()\r\n]*\))?/gu)){let i=r.index,a=e[i-1];if(i>0&&a!==void 0&&!/[\s(]/u.test(a))continue;let o=t+i;n.push({from:o,to:o+r[0].length,spans:[{from:o,to:o+r[0].length,kind:`tag`,name:r[1].toLowerCase()}]})}return G(n,`src/editor/lines.ts#tagCandidates`)},jte=(e,t,n)=>{let r=e.slice(t,n),i=[];for(let r of u9(e,t,n)){let e=[];r.from<r.label.from&&e.push({from:r.from,to:r.label.from,kind:`linkMark`}),r.label.from<r.label.to&&e.push({...r.label,kind:`link`}),r.label.to<r.to&&e.push({from:r.label.to,to:r.to,kind:`linkMark`}),i.push({from:r.from,to:r.to,spans:e})}let a=(e,t,n,r,a)=>{i.push({from:e,to:t,spans:[{from:e,to:e+n,kind:a},{from:e+n,to:t-n,kind:r},{from:t-n,to:t,kind:a}]})};for(let[e,n,i,o]of[[/(\*\*|__)([^\r\n]+?)\1/g,2,`strong`,`strongMark`],[/~~([^~\r\n]+)~~/g,2,`strike`,`strikeMark`],[/`([^`\r\n]+)`/g,1,`code`,`codeMark`]])for(let s of r.matchAll(e)){let e=t+s.index;a(e,e+s[0].length,n,i,o)}i.push(...Ate(r,t));let o;for(let e=0;e<r.length;e+=1){if(r[e]!==`*`||r[e-1]===`*`||r[e+1]===`*`)continue;let n=r[e-1]??``,i=r[e+1]??``,s=!n||/\s/.test(n),c=!i||/\s/.test(i),l=/[\p{P}\p{S}]/u.test(n),u=/[\p{P}\p{S}]/u.test(i);/[\p{L}\p{N}]/u.test(n)&&/[\p{L}\p{N}]/u.test(i)||(!s&&(!l||c||u)&&o!==void 0?(a(t+o,t+e+1,1,`em`,`emMark`),o=void 0):!c&&(!u||s||l)&&(o=e))}return G(i,`src/editor/lines.ts#inlineCandidates`)},Mte=(e,t)=>{if(!l9.has(t.kind))return G([],`src/editor/lines.ts#inlineSpans`);let n=jte(e,t.label?.from??t.quoteMark?.to??t.from,t.to).sort((e,t)=>G(e.from-t.from||t.to-t.from-(e.to-e.from),`src/editor/lines.ts#anonymous`)),r=[],i=t.from;for(let e of n)e.from<i||(r.push(...e.spans),i=e.to);return G(r,`src/editor/lines.ts#inlineSpans`)},Nte=(e,t)=>G(Ote(e,t.content,t.to),`src/editor/lines.ts#headingTitleRange`),Pte=(e,t)=>{let n=0;for(let r=t.from;r<t.from+t.indent;r+=1)n+=e[r]===` `?4-n%4:1;return G(n,`src/editor/lines.ts#indentationColumns`)},Fte=(e,t)=>{let n=e.findIndex(e=>G(e.kind===`heading`&&e.level===2&&e.depth===0&&t.slice(e.content,e.to).trim()===`Archive`,`src/editor/lines.ts#anonymous~2`));if(n===-1)return G(new Set,`src/editor/lines.ts#archivedLines`);let r=e.length;for(let t=n+1;t<e.length;t+=1){let n=e[t];if(n.kind===`heading`&&(n.level===1||n.level===2)){r=t;break}}return G(new Set(Array.from({length:r-n},(e,t)=>G(n+t,`src/editor/lines.ts#anonymous~3`))),`src/editor/lines.ts#archivedLines`)},d9=e=>{let t=CX(e),n=Fte(t,e),r={done:0,cancelled:0,open:0,total:0},i=[],a=[],o=0;return G({lines:t.map((s,c)=>{if((c>=o||s.kind===`heading`)&&(a.length=0),s.kind!==`blank`)for(;a.length&&t[a[a.length-1]].depth>=s.depth;)a.pop();let l=a[a.length-1],u=s.kind===`item`&&s.state!==void 0&&s.checkbox!==void 0;u&&(a.length||(o=wX(t,c)),a.push(c));let d;d=s.kind===`heading`?`project`:u?`task`:s.kind===`item`&&l!==void 0?`status`:s.kind===`paragraph`&&l!==void 0?`note`:s.kind===`paragraph`||s.kind===`item`?`prose`:s.kind===`blank`?`blank`:s.kind===`code`?`code`:s.kind===`fence`?`fence`:s.kind===`quote`?`quote`:`rule`;let f={index:c,from:s.from,to:s.to,kind:d,depth:s.depth,hang:Pte(e,s)+(u?4:d===`status`?2:0),empty:u&&e.slice(s.content,s.to).trim().length===0,alwaysHidden:[],previewHidden:[],inline:[],archived:n.has(c)};if(s.level!==void 0&&(f.level=s.level),s.state!==void 0&&(f.state=s.state),l!==void 0&&(d===`status`||d===`note`)&&(f.owner=l),d===`project`){let t=Nte(e,s);f.marks={from:s.from+s.indent,to:s.content},f.label=t,i.push({title:e.slice(t.from,t.to),level:s.level,line:c,from:t.from})}else if(d===`task`)f.bullet={from:s.from+s.indent,to:s.checkbox},f.checkbox={from:s.checkbox,to:s.checkbox+3},f.label={from:s.content,to:s.to},!f.archived&&!f.empty&&(r.total+=1,s.state===`done`?r.done+=1:s.state===`cancelled`?r.cancelled+=1:r.open+=1);else if(d===`status`)f.bullet={from:s.from+s.indent,to:s.content},f.hiddenBullet=f.bullet,f.label={from:s.content,to:s.to};else if(d===`note`)f.label={from:s.content,to:s.to};else if(d===`quote`){let t=s.from+s.indent;f.quoteMark={from:t,to:t+(e[t+1]===` `?2:1)}}else d===`prose`&&s.kind===`item`&&(f.bullet={from:s.from+s.indent,to:s.content},f.label={from:s.content,to:s.to},/[-*+]/.test(e[f.bullet.from])&&(f.dot={from:f.bullet.from,to:f.bullet.from+1}));f.inline=Mte(e,f),d===`task`&&f.bullet&&f.bullet.from<f.bullet.to&&(f.alwaysHidden=[f.bullet]);let p=[],m=f.marks??f.quoteMark;m&&m.from<m.to&&p.push(m);for(let e of f.inline)e.kind.endsWith(`Mark`)&&p.push({from:e.from,to:e.to});return f.previewHidden=p,G(f,`src/editor/lines.ts#anonymous~4`)}),projects:i,stats:r},`src/editor/lines.ts#classifyDocument`)},f9=(e,t,n)=>{if(!l9.has(t.kind)||n<t.from||n>t.to)return G(void 0,`src/editor/lines.ts#linkRangeOn`);for(let r of u9(e,t.from,t.to))if(!(n<r.from||n>r.to)&&t.inline.some(e=>G((e.kind===`link`||e.kind===`linkMark`)&&e.from>=r.from&&e.to<=r.to,`src/editor/lines.ts#anonymous~5`)))return G({from:r.from,to:r.to,label:r.label,target:r.target},`src/editor/lines.ts#linkRangeOn`);return G(void 0,`src/editor/lines.ts#linkRangeOn`)},p9=(e,t,n)=>{for(let r of e.lines){if(n<r.from)break;let e=f9(t,r,n);if(e)return G(e,`src/editor/lines.ts#linkRangeAt`)}return G(void 0,`src/editor/lines.ts#linkRangeAt`)},Ite=(e,t)=>G(p9(d9(e),e,t)?.target,`src/editor/lines.ts#linkAt`),Lte=(e,t)=>{let n=t.trim().replace(/\s/g,`%20`).replace(/\(/g,`%28`).replace(/\)/g,`%29`),r=e.replace(/[\[\]\r\n]/g,``).trim();return G(n?`[${r||n}](${n})`:r,`src/editor/lines.ts#linkMarkdown`)},Rte=e=>G(`${e.done+e.cancelled}/${e.total} done`,`src/editor/lines.ts#formatStats`),m9=uY.define(),h9=uY.define(),zte=(e,t=d9(e.doc.toString()))=>{let{from:n,to:r,head:i}=e.selection.main,a=e.doc.toString(),o=p9(t,a,i);if(o&&(n===r||n>=o.from&&r<=o.to))return G({from:o.from,to:o.to,label:a.slice(o.label.from,o.label.to),target:o.target},`src/editor/link-popover.ts#linkTargetAt`);let s=Math.min(r,e.doc.lineAt(n).to);return G({from:n,to:s,label:a.slice(n,s),target:``},`src/editor/link-popover.ts#linkTargetAt`)},g9=(e,t,n)=>{let r=Lte(t,n);return G({changes:{from:e.from,to:e.to,insert:r},selection:q.cursor(e.from+r.length),effects:h9.of(null),userEvent:`input.link`,annotations:h6.of(`full`),scrollIntoView:!0},`src/editor/link-popover.ts#linkEditSpec`)},_9=UJ.define({create:()=>G(null,`src/editor/link-popover.ts#create`),update:(e,t)=>{for(let e of t.effects){if(e.is(h9))return G(null,`src/editor/link-popover.ts#update`);if(e.is(m9)){let{target:t,focus:n}=e.value;return G({...t,focus:n,tooltip:{pos:t.from,above:!1,create:Ute}},`src/editor/link-popover.ts#update`)}}if(!e)return G(e,`src/editor/link-popover.ts#update`);let n=e;if(t.docChanged){if(t.annotation(o9)===void 0||t.changes.touchesRange(e.from,e.to))return G(null,`src/editor/link-popover.ts#update`);let r=t.changes.mapPos(e.from,1),i=t.changes.mapPos(e.to,-1);(r!==e.from||i!==e.to)&&(n={...e,from:r,to:i})}if(t.selection&&t.annotation(o9)===void 0){let e=t.state.selection.main.head;if(e<n.from||e>n.to)return G(null,`src/editor/link-popover.ts#update`)}return G(n,`src/editor/link-popover.ts#update`)},provide:e=>G(X2.compute([e],t=>G(t.field(e)?.tooltip??null,`src/editor/link-popover.ts#anonymous`)),`src/editor/link-popover.ts#provide`)}),v9=(e,t,n)=>{e.dispatch({effects:m9.of({target:t,focus:n})})},Bte=e=>(v9(e,zte(e.state),!0),G(!0,`src/editor/link-popover.ts#editLink`)),Vte=e=>e.state.field(_9,!1)?(e.dispatch({effects:h9.of(null)}),G(!0,`src/editor/link-popover.ts#closeLinkEditor`)):G(!1,`src/editor/link-popover.ts#closeLinkEditor`),Hte={left:-1e4,right:-1e4,top:-1e4,bottom:-1e4};function Ute(e){let t=e.dom.ownerDocument,n=e.state.field(_9),r=()=>G(e.state.field(_9,!1)??null,`src/editor/link-popover.ts#current`),i=(e,n,r)=>{let i=t.createElement(e);return i.className=n,r!==void 0&&(i.textContent=r),G(i,`src/editor/link-popover.ts#element`)},a=i(`form`,`pt-link-popover`);a.setAttribute(`aria-label`,`Edit link`);let o=(e,t,n)=>{let r=i(`label`,`pt-link-popover-field`),o=i(`input`,`pt-link-popover-input`);return o.type=`text`,o.value=t,o.placeholder=n,o.spellcheck=!1,o.autocomplete=`off`,r.append(i(`span`,`pt-link-popover-caption`,e),o),a.append(r),G(o,`src/editor/link-popover.ts#field`)},s=o(`Text`,n.label,`Link text`),c=o(`Link`,n.target,`https://`),l=i(`div`,`pt-link-popover-actions`),u=(e,t)=>{let n=i(`button`,`pt-link-popover-button`,e);return n.type=t,l.append(n),G(n,`src/editor/link-popover.ts#button`)};u(`Save`,`submit`);let d=u(`Open`,`button`),f=n.target?u(`Remove link`,`button`):void 0;a.append(l);let p=t=>{r()&&(e.dispatch(t??{effects:h9.of(null)}),e.focus())};return a.addEventListener(`submit`,e=>{e.preventDefault();let t=r();if(!t)return;let n=s.value===t.label&&c.value.trim()===t.target;p(n?void 0:g9(t,s.value,c.value))}),a.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p())}),d.addEventListener(`click`,()=>{let t=c.value.trim();e.state.facet(c9)(t?K.PressedEditorCommand({command:`openLink`,link:t}):K.ShowedEditorNotice({text:`No link here`}))}),f?.addEventListener(`click`,()=>{let e=r();e&&p(g9(e,s.value||e.label,``))}),G({dom:a,getCoords:t=>G(e.coordsAtPos(r()?.from??t)??Hte,`src/editor/link-popover.ts#getCoords`),mount:()=>{if(!n.focus)return;let e=n.label?c:s;e.focus(),e.select()}},`src/editor/link-popover.ts#linkPanel`)}var y9=e=>G({ranges:e.state.selection.ranges.map(({anchor:e,head:t})=>G({anchor:e,head:t},`src/editor/extensions.ts#anonymous`)),main:e.state.selection.mainIndex},`src/editor/extensions.ts#selectionOf`),b9=(e,t,n=y9(e),r=!1,i=!1)=>{let a=j7(e.state.doc.toString(),n,t,new Date);if(a._tag===`Unavailable`)return t===`continueTask`||t===`tab`||i?G(!1,`src/editor/extensions.ts#runEditorAction`):(e.state.facet(c9)(K.ShowedEditorNotice({text:a.reason})),G(!0,`src/editor/extensions.ts#runEditorAction`));try{let t=DJ.of(a.edits,e.state.doc.length,`
|
|
127
|
-
`),n=r?e.state.selection.map(t):q.create(a.selection.ranges.map(({anchor:e,head:t})=>G(q.range(e,t),`src/editor/extensions.ts#anonymous~2`)),a.selection.main);e.dispatch({changes:t,selection:n,userEvent:`input.action`,annotations:h6.of(`full`),scrollIntoView:!r})}catch{e.state.facet(c9)(K.ShowedEditorNotice({text:`Could not apply that action`}))}return G(!0,`src/editor/extensions.ts#runEditorAction`)},x9=(e,t,n=!1)=>{switch(t){case`find`:return G(b7(e),`src/editor/extensions.ts#runEditorCommand`);case`commandPalette`:case`gotoProject`:case`showShortcuts`:return e.state.facet(c9)(K.PressedEditorCommand({command:t})),G(!0,`src/editor/extensions.ts#runEditorCommand`);case`openLink`:return e.state.facet(c9)(K.PressedEditorCommand({command:t,link:Ite(e.state.doc.toString(),e.state.selection.main.head)})),G(!0,`src/editor/extensions.ts#runEditorCommand`);case`editLink`:return G(Bte(e),`src/editor/extensions.ts#runEditorCommand`);default:return G(b9(e,t,y9(e),!1,n),`src/editor/extensions.ts#runEditorCommand`)}},S9={strong:`pt-strong`,strongMark:`pt-strong-mark`,code:`pt-code`,codeMark:`pt-code-mark`,link:`pt-link`,em:`pt-em`,emMark:`pt-em-mark`,strike:`pt-strike`,strikeMark:`pt-strike-mark`,linkMark:`pt-link-mark`,tag:`pt-tag`},Wte=e=>G(e.toLowerCase().replace(/[^a-z0-9-]/g,`-`),`src/editor/extensions.ts#sanitizeTagName`),Gte=class extends yZ{eq(){return G(!0,`src/editor/extensions.ts#eq`)}ignoreEvent(){return G(!1,`src/editor/extensions.ts#ignoreEvent`)}toDOM(e){let t=e.dom.ownerDocument.createElement(`span`);return t.className=`pt-bullet-dot`,t.textContent=`•`,G(t,`src/editor/extensions.ts#toDOM`)}},Kte={open:`☐`,done:`✔`,cancelled:`✘`},qte=class extends yZ{state;empty;constructor(e,t){super(),this.state=e,this.empty=t}eq(e){return G(e.state===this.state&&e.empty===this.empty,`src/editor/extensions.ts#eq~2`)}ignoreEvent(){return G(!1,`src/editor/extensions.ts#ignoreEvent~2`)}toDOM(e){let t=e.dom.ownerDocument,n=t.createElement(`span`);n.className=`pt-marker pt-marker-${this.state}${this.empty?` pt-marker-empty`:``}`,n.setAttribute(`aria-label`,this.state===`done`?`Done`:this.state===`cancelled`?`Cancelled`:`Open`);let r=t.createElement(`span`);return r.className=`pt-marker-symbol`,r.textContent=Kte[this.state]??`☐`,n.append(r),G(n,`src/editor/extensions.ts#toDOM~2`)}},C9=e=>G(e.kind===`task`||e.kind===`status`,`src/editor/extensions.ts#alwaysRendered`),w9=(e,t)=>{let n=[];for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from).number,a=e.doc.lineAt(r.to).number;for(let e=Math.max(i,(n[n.length-1]??0)+1);e<=a;e+=1){let r=t.lines[e-1];r&&C9(r)||n.push(e)}}return G(n,`src/editor/extensions.ts#editingLines`)},Jte=(e,t)=>G(e.length===t.length&&e.every((e,n)=>G(e===t[n],`src/editor/extensions.ts#anonymous~3`)),`src/editor/extensions.ts#sameNumbers`),T9=(e,t)=>{let n=[],r=[],i=new Set(t),a=(e,t)=>{e&&e.from<e.to&&n.push(xZ.mark({class:t}).range(e.from,e.to))},o=(e,t)=>{let i=xZ.replace(t?{widget:t}:{}).range(e.from,e.to);r.push(i),n.push(i)};for(let t of e.lines){let e=i.has(t.index+1),r=[];switch(t.kind){case`project`:r.push(`pt-line-project`,`pt-level-${t.level??1}`);break;case`task`:r.push(`pt-line-task`,`pt-line-task-${t.state??`open`}`);break;case`status`:r.push(`pt-line-status`);break;case`note`:r.push(`pt-line-note`);break;case`prose`:r.push(`pt-line-prose`);break;case`fence`:case`code`:r.push(`pt-line-code`);break;case`quote`:r.push(`pt-line-quote`);break;case`rule`:r.push(`pt-line-rule`)}t.archived&&r.push(`pt-line-archived`),e&&r.push(`pt-line-editing`);let s=t.kind===`task`||t.kind===`status`||t.kind===`note`;s&&r.push(`pt-hang`),r.length&&n.push(xZ.line({class:r.join(` `),attributes:s?{style:`--pt-hang: ${t.hang}`}:void 0}).range(t.from));for(let e of t.alwaysHidden)o(e);if(t.checkbox&&o(t.checkbox,new qte(t.state??`open`,t.empty)),t.kind===`status`&&a(t.hiddenBullet,`pt-bullet-hidden`),e)a(t.marks,`pt-heading-marks`);else{for(let e of t.previewHidden)o(e);t.dot&&o(t.dot,new Gte)}t.kind===`status`||t.alwaysHidden.length||!e&&t.dot||a(t.bullet,`pt-bullet`),t.kind===`project`?a(t.label,`pt-heading-title`):t.kind===`task`&&a(t.label,`pt-label`);for(let n of t.inline)(e||!n.kind.endsWith(`Mark`))&&a(n,n.kind===`tag`?`${S9.tag} pt-tag-${Wte(n.name??``)}`:S9[n.kind])}return G({decorations:xZ.set(n,!0),atomicRanges:MY.of(r,!0)},`src/editor/extensions.ts#lineDecorations`)},E9=UJ.define({create:e=>{let t=d9(e.doc.toString()),n=w9(e,t);return G({classified:t,editing:n,...T9(t,n)},`src/editor/extensions.ts#create`)},update:(e,t)=>{if(!t.docChanged&&!t.selection)return G(e,`src/editor/extensions.ts#update`);let n=t.docChanged?d9(t.newDoc.toString()):e.classified,r=w9(t.state,n);return!t.docChanged&&Jte(e.editing,r)?G(e,`src/editor/extensions.ts#update`):G({classified:n,editing:r,...T9(n,r)},`src/editor/extensions.ts#update`)},provide:e=>G([X.decorations.from(e,e=>G(e.decorations,`src/editor/extensions.ts#anonymous~4`)),X.atomicRanges.of(t=>G(t.state.field(e).atomicRanges,`src/editor/extensions.ts#anonymous~5`))],`src/editor/extensions.ts#provide`)}),Yte=TY.transactionFilter.of(e=>{if(!e.isUserEvent(`select`)||e.annotation(o9)!==void 0)return G(e,`src/editor/extensions.ts#anonymous~6`);let t=e.isUserEvent(`select.pointer`),n=e.docChanged?d9(e.newDoc.toString()):e.startState.field(E9).classified,r=!1,i=e.newSelection.ranges.map((i,a)=>{if(!i.empty)return G(i,`src/editor/extensions.ts#anonymous~7`);let o=n.lines[e.newDoc.lineAt(i.head).number-1];if(o?.kind!==`task`||!o.bullet||!o.label||i.head<o.bullet.from||i.head>=o.label.from)return G(i,`src/editor/extensions.ts#anonymous~7`);if(r=!0,t)return G(q.cursor(o.label.from),`src/editor/extensions.ts#anonymous~7`);let s=e.startState.selection.ranges[a],c=s===void 0?void 0:e.changes.mapPos(s.head);return c!==void 0&&c>=o.label.from&&e.newDoc.lineAt(c).from===o.from?G(q.cursor(o.index===0?o.from:e.newDoc.line(o.index).to),`src/editor/extensions.ts#anonymous~7`):G(q.cursor(o.label.from),`src/editor/extensions.ts#anonymous~7`)});return G(r?[e,{selection:q.create(i,e.newSelection.mainIndex),sequential:!0}]:e,`src/editor/extensions.ts#anonymous~6`)}),Xte=({state:e,dispatch:t})=>{let n=e.field(E9).classified,r=[];for(let t of e.selection.ranges){let i=n.lines[e.doc.lineAt(t.head).number-1];if(i?.kind!==`task`||!i.label)return G(!1,`src/editor/extensions.ts#moveToTaskLabel`);r.push(q.cursor(i.label.from))}return t(e.update({selection:q.create(r,e.selection.mainIndex),userEvent:`select`,scrollIntoView:!0})),G(!0,`src/editor/extensions.ts#moveToTaskLabel`)},Zte=({state:e,dispatch:t})=>{let n=e.field(E9).classified,r=[];for(let t of e.selection.ranges){let i=n.lines[e.doc.lineAt(t.head).number-1];if(!t.empty||!i?.empty||!i.bullet||!i.label||t.head!==i.label.from)return G(!1,`src/editor/extensions.ts#deleteEmptyTaskPrefix`);r.push({from:i.bullet.from,to:i.label.from})}let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i),userEvent:`delete.backward`,scrollIntoView:!0})),G(!0,`src/editor/extensions.ts#deleteEmptyTaskPrefix`)},Qte=UJ.define({create:()=>G(xZ.none,`src/editor/extensions.ts#create~2`),update:(e,t)=>{let n=e.map(t.changes);if(t.effects.some(e=>G(e.is(s9),`src/editor/extensions.ts#anonymous~8`))&&(n=xZ.none),t.annotation(o9)!==void 0){let e=[];t.changes.iterChanges((t,n,r,i)=>{r<i&&e.push(xZ.mark({class:`pt-remote-highlight`}).range(r,i))}),n=n.update({add:e,sort:!0})}return G(n,`src/editor/extensions.ts#update~2`)},provide:e=>G(X.decorations.from(e),`src/editor/extensions.ts#provide~2`)}),$te=qQ.fromClass(class{view;timer;constructor(e){this.view=e}update(e){e.transactions.some(e=>G(e.annotation(o9)!==void 0,`src/editor/extensions.ts#anonymous~10`))&&(this.timer!==void 0&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.view.dispatch({effects:s9.of(null)})},3e3))}destroy(){this.timer!==void 0&&clearTimeout(this.timer)}}),D9=qQ.fromClass(class{ignoreKey=!1},{eventHandlers:{keydown(e){return this.ignoreKey=e.isComposing||e.keyCode===229||e.key===`Dead`||e.getModifierState(`AltGraph`),G(!1,`src/editor/extensions.ts#keydown`)}}}),ene=e=>G([TY.lineSeparator.of(`
|
|
128
|
-
`),TY.tabSize.of(4),TY.allowMultipleSelections.of(!0),y6(),A2(),L2(),X.lineWrapping,X.contentAttributes.of({"aria-label":`Todo document`}),KJ.highest(D9),KJ.highest(d2.of([{key:`Escape`,run:Vte},{key:`Backspace`,run:e=>G(e.composing||e.plugin(D9)?.ignoreKey?!1:Zte(e),`src/editor/extensions.ts#run`)},{key:`Home`,run:e=>G(e.composing||e.plugin(D9)?.ignoreKey?!1:Xte(e),`src/editor/extensions.ts#run~2`)}])),KJ.highest(d2.of(WG.flatMap(t=>G(t[e].map(e=>G({key:e,run:n=>G(n.composing||n.plugin(D9)?.ignoreKey?!1:x9(n,t.command,e===`Shift-Tab`&&t.command===`outdent`),`src/editor/extensions.ts#run~3`),stopPropagation:!0},`src/editor/extensions.ts#anonymous~13`)),`src/editor/extensions.ts#anonymous~12`)))),d2.of([...D5,...R6,...S7,{key:`Escape`,run:w5}]),U5({top:!0}),E9,Yte,Qte,$te,_9,X.domEventHandlers({mousedown(e,t){let n=e.target;if(!(n instanceof Element)||t.composing)return G(!1,`src/editor/extensions.ts#mousedown`);let r=n.closest(`.pt-marker`);if(!r||!t.contentDOM.contains(r))return G(!1,`src/editor/extensions.ts#mousedown`);e.preventDefault();let i=t.posAtDOM(r),a=t.state.doc.lineAt(i),o=t.state.field(E9).classified.lines[a.number-1]?.checkbox;return o&&(b9(t,e.altKey?`toggleCancelled`:`toggleDone`,{ranges:[{anchor:o.from,head:o.from}],main:0},!0),t.focus()),G(!0,`src/editor/extensions.ts#mousedown`)},click(e,t){let n=e.target;if(!(n instanceof Element)||t.composing||e.button!==0||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return G(!1,`src/editor/extensions.ts#click`);let r=n.closest(`.pt-link`);if(!r||!t.contentDOM.contains(r)||!t.state.selection.main.empty)return G(!1,`src/editor/extensions.ts#click`);let i=t.posAtDOM(r),a=t.state.field(E9).classified.lines[t.state.doc.lineAt(i).number-1];if(!a||!C9(a))return G(!1,`src/editor/extensions.ts#click`);let o=t.state.doc.toString(),s=f9(o,a,i);return s&&v9(t,{from:s.from,to:s.to,label:o.slice(s.label.from,s.label.to),target:s.target},!1),G(!1,`src/editor/extensions.ts#click`)}})],`src/editor/extensions.ts#editorExtensions`),O9=new Map,tne=(e,t)=>{O9.set(e,t)},k9=e=>G(br(O9.get(e)),`src/editor/host.ts#getEditor`),nne=(e,t)=>{try{t.destroy()}finally{O9.get(e)===t&&O9.delete(e)}},A9=class extends Nr()(`DoItClient`){},rne=Dq({url:`/rpc`}).pipe(ap(np(fH,pq,Yf(lH,{credentials:`same-origin`})))),ine=Qf(A9,yq(Aq)).pipe(ap(rne)),j9=e=>typeof e!=`object`||!e?G(!1,`src/rpc.ts#isUnauthorized`):`_tag`in e&&e._tag===`Unauthorized`?G(!0,`src/rpc.ts#isUnauthorized`):`reason`in e&&typeof e.reason==`object`&&e.reason!==null?G(`message`in e.reason&&String(e.reason.message).includes(`401`),`src/rpc.ts#isUnauthorized`):G(!1,`src/rpc.ts#isUnauthorized`),M9=ez(`WaitBeforeReconnect`,{args:{attempt:R},messages:[K.CompletedWaitBeforeReconnect],execute:({attempt:e})=>G(hm(mo(Math.min(500*2**Math.max(0,e-1),5e3))).pipe(im(K.CompletedWaitBeforeReconnect())),`src/command.ts#execute`)}),ane=ez(`WaitBeforeSync`,{args:{session:L,revision:R},messages:[K.CompletedWaitBeforeSync],execute:e=>G(hm(`400 millis`).pipe(im(K.CompletedWaitBeforeSync(e))),`src/command.ts#execute~2`)}),one=ez(`WaitBeforeSyncRetry`,{args:{session:L,attempt:R},messages:[K.CompletedWaitBeforeSyncRetry],execute:e=>G(hm(`2 seconds`).pipe(im(K.CompletedWaitBeforeSyncRetry(e))),`src/command.ts#execute~3`)}),sne=ez(`WaitBeforeRemoteRetry`,{args:{session:L,token:R},messages:[K.CompletedWaitBeforeRemoteRetry],execute:e=>G(hm(`500 millis`).pipe(im(K.CompletedWaitBeforeRemoteRetry(e))),`src/command.ts#execute~4`)}),cne=e=>{if(j9(e))return G(`Unauthorized`,`src/command.ts#syncFailureKind`);switch(e._tag){case`Forgotten`:return G(`Forgotten`,`src/command.ts#syncFailureKind`);case`DocumentGone`:return G(`DocumentGone`,`src/command.ts#syncFailureKind`);case`VersionMismatch`:return G(e.forgotten?`Forgotten`:`Transient`,`src/command.ts#syncFailureKind`);default:return G(`Transient`,`src/command.ts#syncFailureKind`)}},lne=ez(`SyncDraft`,{args:{path:L,base:R,text:L},messages:[K.SucceededSync,K.FailedSync],execute:({path:e,base:t,text:n})=>G(P(function*(){let r=yield*(yield*A9).sync({path:e,base:t,text:n});return G(K.SucceededSync({request:{base:t,text:n},version:r.version,text:r.text}),`src/command.ts#anonymous`)}).pipe(om(e=>G(j(K.FailedSync({request:{base:t,text:n},kind:cne(e)})),`src/command.ts#anonymous~2`))),`src/command.ts#execute~5`)}),une=ez(`ApplyRemoteText`,{args:{session:L,token:R,from:L,to:L},messages:[K.CompletedApplyRemoteText,K.FailedApplyRemoteText],execute:({session:e,token:t,from:n,to:r})=>G(Wp(i=>{let a=k9(e);if(E(a)){i(j(K.FailedApplyRemoteText({token:t,reason:`Editor is not mounted`})));return}let o=a.value,s=o.dom.ownerDocument.defaultView,c=!1,l,u,d=()=>{l!==void 0&&clearTimeout(l),u!==void 0&&s?.cancelAnimationFrame(u),o.contentDOM.removeEventListener(`compositionend`,m)},f=e=>{c||(c=!0,d(),i(j(e)))},p=()=>{if(c)return;let i=k9(e);if(E(i)||i.value!==o)f(K.FailedApplyRemoteText({token:t,reason:`Editor is no longer mounted`}));else if(!o.composing)try{o.dispatch({changes:zX(n,r,o.state.doc.toString()),annotations:[dY.addToHistory.of(!1),o9.of(t)]}),f(K.CompletedApplyRemoteText({token:t}))}catch{f(K.FailedApplyRemoteText({token:t,reason:`Could not apply the remote text`}))}};function m(){!c&&s&&(u!==void 0&&s.cancelAnimationFrame(u),u=s.requestAnimationFrame(()=>{u=void 0,p()}))}return o.composing?(o.contentDOM.addEventListener(`compositionend`,m),l=setTimeout(()=>G(f(K.FailedApplyRemoteText({token:t,reason:`Composition did not finish in time`})),`src/command.ts#anonymous~5`),2e3)):p(),G(M(()=>{c=!0,d()}),`src/command.ts#anonymous~3`)}),`src/command.ts#execute~6`)}),dne=ez(`FocusEditor`,{args:{session:L},messages:[K.CompletedFocusEditor],execute:({session:e})=>G(M(()=>{let t=k9(e);return D(t)&&t.value.focus(),G(K.CompletedFocusEditor(),`src/command.ts#anonymous~7`)}),`src/command.ts#execute~7`)}),N9=ez(`RunEditorAction`,{args:{session:L,action:Fq},messages:[K.CompletedRunEditorAction,K.ShowedEditorNotice],execute:({session:e,action:t})=>G(Xp(()=>{let n=k9(e);if(E(n))return G(K.ShowedEditorNotice({text:`Editor is not mounted`}),`src/command.ts#anonymous~8`);let r=n.value;return r.focus(),x9(r,t),G(K.CompletedRunEditorAction(),`src/command.ts#anonymous~8`)}).pipe(om(()=>G(j(K.ShowedEditorNotice({text:`Could not run this command`})),`src/command.ts#anonymous~9`))),`src/command.ts#execute~8`)}),P9=(e,t)=>{let n=Math.max(0,Math.min(t,e.state.doc.length));e.dispatch({selection:{anchor:n},scrollIntoView:!0}),e.focus()},fne=ez(`RevealEditorPosition`,{args:{session:L,offset:R},messages:[K.CompletedRevealEditorPosition],execute:({session:e,offset:t})=>G(M(()=>{let n=k9(e);return D(n)&&P9(n.value,t),G(K.CompletedRevealEditorPosition(),`src/command.ts#anonymous~10`)}),`src/command.ts#execute~9`)}),F9=ez(`OpenEditorLink`,{args:{session:L,url:L},messages:[K.CompletedOpenEditorLink,K.ShowedEditorNotice],execute:({session:e,url:t})=>G(Xp(()=>{if(/^(https?:|mailto:)/i.test(t))return G(window.open(t,`_blank`,`noopener,noreferrer`)?K.CompletedOpenEditorLink():K.ShowedEditorNotice({text:t}),`src/command.ts#anonymous~11`);if(t.startsWith(`#`)){let n=k9(e);if(D(n)){let e=n.value,r=EX(e.state.doc.toString()).find(e=>G(e.id===decodeURIComponent(t.slice(1)),`src/command.ts#anonymous~12`));if(r)return P9(e,r.from),G(K.CompletedOpenEditorLink(),`src/command.ts#anonymous~11`)}return G(K.ShowedEditorNotice({text:`Project not found`}),`src/command.ts#anonymous~11`)}return G(K.ShowedEditorNotice({text:`This link cannot be opened here`}),`src/command.ts#anonymous~11`)}).pipe(om(()=>G(j(K.ShowedEditorNotice({text:`Could not open this link`})),`src/command.ts#anonymous~13`))),`src/command.ts#execute~10`)}),pne=wk(`MountEditor`,{args:{session:L,text:L,selection:Iq,platform:Pq},messages:[K.SucceededMountEditor,K.UpdatedEditor,K.MovedEditorSelection,K.PressedEditorCommand,K.ShowedEditorNotice,K.OpenedEditorLink],execute:({element:e,session:t,text:n,selection:r,platform:i})=>G(UE(a=>G(P(function*(){let o=e=>{jh(a,e)};return yield*Dm(Xp(()=>{let a=new X({parent:e,state:TY.create({doc:n,selection:r,extensions:[ene(i),c9.of(e=>{e._tag===`PressedEditorCommand`&&e.command===`openLink`?o(e.link===void 0?K.ShowedEditorNotice({text:`No link here`}):K.OpenedEditorLink({url:e.link})):o(e)}),X.updateListener.of(e=>{for(let n of e.transactions){let e=n.annotation(o9),{anchor:r,head:i}=n.newSelection.main;n.docChanged||e!==void 0?o(K.UpdatedEditor({session:t,text:n.newDoc.toString(),anchor:r,head:i,origin:e===void 0?n.isUserEvent(`input.action`)?`Action`:`Input`:`Remote`,token:e??null})):n.startState.selection.eq(n.newSelection)||o(K.MovedEditorSelection({session:t,anchor:r,head:i}))}})]})});return tne(t,a),G(a,`src/mount.ts#anonymous~3`)}),e=>G(M(()=>G(nne(t,e),`src/mount.ts#anonymous~7`)),`src/mount.ts#anonymous~6`)),o(K.SucceededMountEditor({session:t})),G(yield*Gp,`src/mount.ts#anonymous~2`)}).pipe(om(()=>G(M(()=>{jh(a,K.ShowedEditorNotice({text:`Could not open the editor`}))}),`src/mount.ts#anonymous~8`))),`src/mount.ts#anonymous`)),`src/mount.ts#execute`)}),mne=Ck(`FocusPaletteInput`,{messages:[K.CompletedFocusPaletteInput],execute:({element:e})=>G(M(()=>(e instanceof HTMLInputElement&&e.focus({preventScroll:!0}),G(K.CompletedFocusPaletteInput(),`src/mount.ts#anonymous~10`))),`src/mount.ts#execute~2`)}),hne=(e,t)=>{let n=e.toLowerCase(),r=0;for(let e of t.toLowerCase()){let t=n.indexOf(e,r);if(t===-1)return G(!1,`src/view/palette.ts#matchesSubsequence`);r=t+e.length}return G(!0,`src/view/palette.ts#matchesSubsequence`)},I9=(e,t)=>{let n=e.palette;return n._tag===`Open`?G((n.kind===`Projects`?d9(t).projects.map(e=>G({kind:`Project`,title:e.title,detail:`Heading ${e.level}, line ${e.line+1}`,keys:[],offset:e.from},`src/view/palette.ts#anonymous`)):GG.filter(e=>G(n.kind===`Shortcuts`||e.inPalette,`src/view/palette.ts#anonymous~2`)).map(t=>G({kind:`Command`,title:t.title,detail:t.description,command:t.command,keys:qG(e.platform,t.command).map(t=>G(QG(e.platform,t),`src/view/palette.ts#anonymous~4`))},`src/view/palette.ts#anonymous~3`))).filter(e=>G(hne(e.title,n.query),`src/view/palette.ts#anonymous~5`)),`src/view/palette.ts#paletteItems`):G([],`src/view/palette.ts#paletteItems`)},gne=(e,t,n)=>{let r=e.palette;if(r._tag===`Closed`)return G(n.div([]),`src/view/palette.ts#paletteView`);let i=I9(e,t),a=i.length?Math.min(r.active,i.length-1):0;return G(n.keyed(`div`)(`palette`,[n.Class(`pt-palette-backdrop`)],[n.div([n.Class(`pt-palette`),n.Role(`dialog`),n.AriaModal(!0),n.AriaLabel(r.kind)],[n.keyed(`input`)(r.kind,[n.Class(`pt-palette-input`),n.Type(`text`),n.Value(r.query),n.Placeholder(r.kind===`Projects`?`Go to project`:r.kind===`Shortcuts`?`Keyboard shortcuts`:`Search commands`),n.AriaLabel(`Filter ${r.kind.toLowerCase()}`),n.Role(`combobox`),n.AriaExpanded(!0),n.AriaControls(`pt-palette-list`),...i.length?[n.Attribute(`aria-activedescendant`,`pt-palette-item-${a}`)]:[],n.OnInput(e=>G(K.UpdatedPaletteQuery({query:e}),`src/view/palette.ts#anonymous~6`)),n.OnKeyDownPreventDefault(e=>G(e===`ArrowUp`||e===`ArrowDown`||e===`Enter`||e===`Escape`?T(K.PressedPaletteKey({key:e})):w(),`src/view/palette.ts#anonymous~7`)),n.OnMount(mne())]),n.ul([n.Class(`pt-palette-list`),n.Id(`pt-palette-list`),n.Role(`listbox`),n.AriaLabel(r.kind)],i.length?i.map((e,t)=>G(n.li([n.Role(`presentation`)],[n.button([n.Class(`pt-palette-item${t===a?` pt-palette-item-active`:``}`),n.Type(`button`),n.Role(`option`),n.AriaSelected(t===a),n.Id(`pt-palette-item-${t}`),n.Attribute(`tabindex`,`-1`),n.OnClick(K.ClickedPaletteItem({index:t}))],[n.span([],[n.span([n.Class(`pt-palette-title`)],[e.title]),n.span([n.Class(`pt-palette-detail`)],[e.detail])]),n.span([n.Class(`pt-palette-keys`)],(r.kind===`Shortcuts`?e.keys:e.keys.slice(0,1)).map(e=>G(n.kbd([n.Class(`pt-palette-key`)],[e]),`src/view/palette.ts#anonymous~9`)))])]),`src/view/palette.ts#anonymous~8`)):[n.li([n.Class(`pt-palette-empty`)],[`No matches`])]),...r.kind===`Shortcuts`?[n.p([n.Class(`pt-palette-detail`)],[e.platform===`mac`?`Type ? outside the editor, or Cmd / inside it`:`Type ? outside the editor, or Ctrl / inside it`]),n.p([n.Class(`pt-palette-detail`)],[`Esc then Tab leaves the editor`]),n.p([n.Class(`pt-palette-detail`)],[`Tab indents or adds a tag, Shift-Tab outdents`]),n.p([n.Class(`pt-palette-detail`)],[e.platform===`mac`?`Toggle Tab focus mode: Alt Shift M`:`Toggle Tab focus mode: Ctrl M`]),n.p([n.Class(`pt-palette-detail`)],[`Browser shortcuts kept: reload, hard reload, tab search`])]:[]])]),`src/view/palette.ts#paletteView`)},L9=e=>G(e.draft!==e.base.text,`src/update.ts#isDirty`),R9=e=>G(D(e.inFlight)||D(e.pendingRemote),`src/update.ts#isBusy`),z9=(e,t)=>G(W(e,{document:()=>G(Uq.Ready({document:t}),`src/update.ts#document`)}),`src/update.ts#withDocument`),B9=(e,t)=>G(Uq.matchOrElse(e.document,{Ready:({document:e})=>G(t(e),`src/update.ts#Ready`)},()=>G({model:e},`src/update.ts#anonymous`)),`src/update.ts#whenReady`),V9=(e,t)=>G(D(e.inFlight)&&e.inFlight.value.base===t.base&&e.inFlight.value.text===t.text,`src/update.ts#matchesRequest`),H9=(e,t)=>E(e)?G(T(t),`src/update.ts#keepNewest`):t.version>e.value.version||t.version===e.value.version?G(T({...t,resync:t.resync||e.value.resync}),`src/update.ts#keepNewest`):G(T({...e.value,resync:e.value.resync||t.resync}),`src/update.ts#keepNewest`),U9=(e,t)=>{let n=t.connection._tag===`Reconnecting`&&t.connection.awaitingResync;if(!L9(t)||R9(t)||n)return G({model:z9(e,t)},`src/update.ts#startSync`);let r={base:t.base.version,text:t.draft};return G({model:z9(e,W(t,{inFlight:()=>G(T(r),`src/update.ts#inFlight`)})),commands:[lne({path:t.path,...r})]},`src/update.ts#startSync`)},W9=(e,t,n,r)=>{let i=t.nextToken;return G({model:z9(e,W(t,{pendingRemote:()=>G(T({token:i,version:n.version,to:n.text,resync:n.resync}),`src/update.ts#pendingRemote`),nextToken:e=>G(e+1,`src/update.ts#nextToken`)})),commands:[une({session:t.session,token:i,from:r,to:n.text})]},`src/update.ts#applyRemote`)},G9=(e,t,n)=>!n.resync&&n.version<=t.base.version?G({model:z9(e,t)},`src/update.ts#receiveRemote`):R9(t)?G({model:z9(e,W(t,{latestRemote:e=>G(H9(e,n),`src/update.ts#latestRemote`)}))},`src/update.ts#receiveRemote`):n.resync||!L9(t)?G(W9(e,t,n,t.base.text),`src/update.ts#receiveRemote`):G(U9(e,W(t,{latestRemote:e=>G(H9(e,n),`src/update.ts#latestRemote~2`)})),`src/update.ts#receiveRemote`),K9=(e,t)=>{if(R9(t))return G({model:z9(e,t)},`src/update.ts#settle`);if(D(t.latestRemote)){let n=t.latestRemote.value,r=W(t,{latestRemote:()=>G(w(),`src/update.ts#latestRemote~3`)});return n.resync||n.version>t.base.version?G(G9(e,r,n),`src/update.ts#settle`):G(U9(e,r),`src/update.ts#settle`)}return G(U9(e,t),`src/update.ts#settle`)},q9=(e,t,n,r)=>G(Uq.matchOrElse(e.document,{Connecting:({path:r,watchKey:i,resumeFrom:a})=>G({model:z9(e,{path:r,session:`${r}:${i}`,base:{version:t,text:n},draft:n,draftRevision:0,selection:{anchor:0,head:0},inFlight:w(),pendingRemote:w(),latestRemote:w(),nextToken:1,retryAttempt:0,watchKey:i,resumeFrom:a,reconnectAttempt:0,connection:Vq.Live()})},`src/update.ts#Connecting`),Ready:({document:i})=>{if(!r&&i.connection._tag===`Reconnecting`&&i.connection.awaitingResync)return G({model:z9(e,W(i,{latestRemote:e=>G(H9(e,{version:t,text:n,resync:!1}),`src/update.ts#latestRemote~4`)}))},`src/update.ts#Ready~2`);let a=W(i,{connection:e=>G(e._tag===`Reconnecting`&&e.awaitingResync?e:Vq.Live(),`src/update.ts#connection`),reconnectAttempt:()=>G(0,`src/update.ts#reconnectAttempt`)});return!r&&t<=i.base.version?G({model:z9(e,a)},`src/update.ts#Ready~2`):G(G9(e,a,{version:t,text:n,resync:r}),`src/update.ts#Ready~2`)}},()=>G({model:e},`src/update.ts#anonymous~2`)),`src/update.ts#readyFromWatching`),J9=e=>G(Uq.matchOrElse(e.document,{Ready:({document:t})=>{let n=t.reconnectAttempt+1;return G({model:z9(e,W(t,{connection:()=>G(Vq.Reconnecting({awaitingResync:t.connection._tag===`Reconnecting`&&t.connection.awaitingResync}),`src/update.ts#connection~2`),reconnectAttempt:()=>G(n,`src/update.ts#reconnectAttempt~2`)})),commands:[M9({attempt:n})]},`src/update.ts#Ready~3`)},Connecting:t=>{let n=t.reconnectAttempt+1;return G({model:W(e,{document:()=>G(W(t,{reconnectAttempt:()=>G(n,`src/update.ts#reconnectAttempt~3`)}),`src/update.ts#document~2`)}),commands:[M9({attempt:n})]},`src/update.ts#Connecting~2`)}},()=>G({model:e},`src/update.ts#anonymous~3`)),`src/update.ts#reconnect`),Y9=(e,t)=>G(Uq.matchOrElse(e.document,{Ready:({document:n})=>G({model:W(e,{document:()=>G(Uq[t]({path:n.path}),`src/update.ts#document~3`),palette:()=>G(Wq.Closed(),`src/update.ts#palette`)})},`src/update.ts#Ready~4`),Connecting:({path:n})=>G({model:W(e,{document:()=>G(Uq[t]({path:n}),`src/update.ts#document~4`)})},`src/update.ts#Connecting~3`)},()=>G({model:e},`src/update.ts#anonymous~4`)),`src/update.ts#terminal`),X9=(e,t)=>G(B9(e,()=>G({model:W(e,{palette:()=>G(Wq.Open({kind:t,query:``,active:0}),`src/update.ts#palette~2`)})},`src/update.ts#anonymous~5`)),`src/update.ts#openPalette`),Z9=e=>G(B9(e,t=>G({model:W(e,{palette:()=>G(Wq.Closed(),`src/update.ts#palette~3`)}),commands:[dne({session:t.session})]},`src/update.ts#anonymous~6`)),`src/update.ts#closePalette`),Q9=(e,t)=>G(B9(e,n=>{let r=I9(e,n.draft),i=r[Math.max(0,Math.min(t,r.length-1))];if(!i)return G({model:e},`src/update.ts#anonymous~7`);let a=W(e,{palette:()=>G(Wq.Closed(),`src/update.ts#palette~4`)});return i.kind===`Project`?G({model:a,commands:[fne({session:n.session,offset:i.offset})]},`src/update.ts#anonymous~7`):i.command===`gotoProject`?G(X9(e,`Projects`),`src/update.ts#anonymous~7`):i.command===`showShortcuts`?G(X9(e,`Shortcuts`),`src/update.ts#anonymous~7`):i.command===`commandPalette`?G(X9(e,`Commands`),`src/update.ts#anonymous~7`):G({model:a,commands:[N9({session:n.session,action:i.command})]},`src/update.ts#anonymous~7`)}),`src/update.ts#choosePalette`),_ne=(e,t)=>G(K.match(t,{UpdatedEditor:t=>G(B9(e,n=>{if(t.session!==n.session)return G({model:e},`src/update.ts#anonymous~8`);if(t.origin===`Remote`){if(E(n.pendingRemote)||t.token!==n.pendingRemote.value.token)return G({model:e},`src/update.ts#anonymous~8`);let r=n.pendingRemote.value;return G(K9(W(e,{notice:()=>G(w(),`src/update.ts#notice`)}),W(n,{base:()=>G({version:r.version,text:r.to},`src/update.ts#base`),draft:()=>G(t.text,`src/update.ts#draft`),selection:()=>G({anchor:t.anchor,head:t.head},`src/update.ts#selection`),pendingRemote:()=>G(w(),`src/update.ts#pendingRemote~2`),connection:e=>G(r.resync?Vq.Live():e,`src/update.ts#connection~3`)})),`src/update.ts#anonymous~8`)}let r=W(n,{draft:()=>G(t.text,`src/update.ts#draft~2`),draftRevision:e=>G(e+1,`src/update.ts#draftRevision`),selection:()=>G({anchor:t.anchor,head:t.head},`src/update.ts#selection~2`)}),i=W(e,{notice:()=>G(w(),`src/update.ts#notice~2`)});return G(t.origin===`Action`?U9(i,r):{model:z9(i,r),commands:[ane({session:n.session,revision:r.draftRevision})]},`src/update.ts#anonymous~8`)}),`src/update.ts#UpdatedEditor`),MovedEditorSelection:({session:t,anchor:n,head:r})=>G(B9(e,i=>G({model:t===i.session?z9(e,W(i,{selection:()=>G({anchor:n,head:r},`src/update.ts#selection~3`)})):e},`src/update.ts#anonymous~9`)),`src/update.ts#MovedEditorSelection`),CompletedWaitBeforeSync:({session:t,revision:n})=>G(B9(e,r=>G(t===r.session&&n===r.draftRevision?U9(e,r):{model:e},`src/update.ts#anonymous~10`)),`src/update.ts#CompletedWaitBeforeSync`),SucceededSync:({request:t,version:n,text:r})=>G(B9(e,i=>{if(!V9(i,t))return G({model:e},`src/update.ts#anonymous~11`);let a=W(e,{notice:()=>G(w(),`src/update.ts#notice~3`)}),o=W(i,{inFlight:()=>G(w(),`src/update.ts#inFlight~2`),retryAttempt:()=>G(0,`src/update.ts#retryAttempt`)});return r===t.text?G(K9(a,W(o,{base:()=>G({version:n,text:r},`src/update.ts#base~2`)})),`src/update.ts#anonymous~11`):G(W9(a,o,{version:n,text:r,resync:!1},t.text),`src/update.ts#anonymous~11`)}),`src/update.ts#SucceededSync`),FailedSync:({request:t,kind:n})=>G(B9(e,r=>{if(!V9(r,t))return G({model:e},`src/update.ts#anonymous~12`);let i=W(r,{inFlight:()=>G(w(),`src/update.ts#inFlight~3`)});if(n===`Unauthorized`||n===`DocumentGone`)return G(Y9(e,n===`Unauthorized`?`Unauthorized`:`Deleted`),`src/update.ts#anonymous~12`);if(n===`Forgotten`)return G({model:z9(e,W(i,{watchKey:e=>G(e+1,`src/update.ts#watchKey`),resumeFrom:()=>G(T(r.base.version),`src/update.ts#resumeFrom`),connection:()=>G(Vq.Reconnecting({awaitingResync:!0}),`src/update.ts#connection~4`)}))},`src/update.ts#anonymous~12`);let a=r.retryAttempt+1,o=W(i,{retryAttempt:()=>G(a,`src/update.ts#retryAttempt~2`)}),s=W(e,{notice:()=>G(T(a<=5?`Sync interrupted, retrying`:`Sync interrupted, edit to try again`),`src/update.ts#notice~4`)}),c=D(o.latestRemote)&&(o.latestRemote.value.resync||!L9(o))?K9(s,o):{model:z9(s,o)};return G(a<=5?{model:c.model,commands:[...c.commands??[],one({session:r.session,attempt:a})]}:c,`src/update.ts#anonymous~12`)}),`src/update.ts#FailedSync`),CompletedWaitBeforeSyncRetry:({session:t,attempt:n})=>G(B9(e,r=>G(t===r.session&&n===r.retryAttempt&&n<=5?K9(e,r):{model:e},`src/update.ts#anonymous~13`)),`src/update.ts#CompletedWaitBeforeSyncRetry`),FailedApplyRemoteText:({token:t,reason:n})=>G(B9(e,r=>{if(E(r.pendingRemote)||r.pendingRemote.value.token!==t)return G({model:e},`src/update.ts#anonymous~14`);let i=r.pendingRemote.value;return G({model:z9(W(e,{notice:()=>G(T(n),`src/update.ts#notice~5`)}),W(r,{pendingRemote:()=>G(w(),`src/update.ts#pendingRemote~3`),latestRemote:e=>G(H9(e,{version:i.version,text:i.to,resync:i.resync}),`src/update.ts#latestRemote~5`)})),commands:[sne({session:r.session,token:t})]},`src/update.ts#anonymous~14`)}),`src/update.ts#FailedApplyRemoteText`),CompletedWaitBeforeRemoteRetry:({session:t,token:n})=>G(B9(e,r=>G(t===r.session&&n===r.nextToken-1?K9(e,r):{model:e},`src/update.ts#anonymous~15`)),`src/update.ts#CompletedWaitBeforeRemoteRetry`),ReceivedWatchEvent:({event:t})=>G(BD(t).pipe(UD(`Watching`,({version:t,text:n})=>G(n===void 0?{model:e}:q9(e,t,n,!1),`src/update.ts#anonymous~16`)),UD(`Resync`,({version:t,text:n})=>G(n===void 0?{model:e}:q9(e,t,n,!0),`src/update.ts#anonymous~17`)),UD(`Change`,t=>{let n=W(e,{activity:e=>G([{from:t.from,to:t.to,by:t.by,todos:t.todos},...e].slice(0,20),`src/update.ts#activity`)});return G(B9(n,e=>G(t.text===void 0?{model:n}:G9(n,e,{version:t.to,text:t.text,resync:!1}),`src/update.ts#anonymous~19`)),`src/update.ts#anonymous~18`)}),UD(`Deleted`,()=>G(Y9(e,`Deleted`),`src/update.ts#anonymous~20`)),KD),`src/update.ts#ReceivedWatchEvent`),WatchEnded:()=>G(J9(e),`src/update.ts#WatchEnded`),FailedWatch:({unauthorized:t})=>G(t?Y9(e,`Unauthorized`):J9(e),`src/update.ts#FailedWatch`),CompletedWaitBeforeReconnect:()=>G(Uq.matchOrElse(e.document,{Ready:({document:t})=>G({model:z9(e,W(t,{watchKey:e=>G(e+1,`src/update.ts#watchKey~2`),resumeFrom:()=>G(T(t.base.version),`src/update.ts#resumeFrom~2`)}))},`src/update.ts#Ready~5`),Connecting:t=>G({model:W(e,{document:()=>G(W(t,{watchKey:e=>G(e+1,`src/update.ts#watchKey~3`)}),`src/update.ts#document~5`)})},`src/update.ts#Connecting~4`)},()=>G({model:e},`src/update.ts#anonymous~21`)),`src/update.ts#CompletedWaitBeforeReconnect`),ClickedActivity:()=>G({model:W(e,{activityOpen:e=>G(!e,`src/update.ts#activityOpen`)})},`src/update.ts#ClickedActivity`),ClickedCommands:()=>G(e.palette._tag===`Open`?Z9(e):X9(e,`Commands`),`src/update.ts#ClickedCommands`),PressedHelpKey:()=>G(e.palette._tag===`Open`?Z9(e):X9(e,`Shortcuts`),`src/update.ts#PressedHelpKey`),UpdatedPaletteQuery:({query:t})=>G({model:W(e,{palette:e=>G(Wq.match(e,{Closed:()=>G(e,`src/update.ts#Closed`),Open:e=>G(W(e,{query:()=>G(t,`src/update.ts#query`),active:()=>G(0,`src/update.ts#active`)}),`src/update.ts#Open`)}),`src/update.ts#palette~5`)})},`src/update.ts#UpdatedPaletteQuery`),PressedPaletteKey:({key:t})=>{let n=e.palette;if(n._tag!==`Open`)return G({model:e},`src/update.ts#PressedPaletteKey`);if(t===`Escape`)return G(Z9(e),`src/update.ts#PressedPaletteKey`);if(t===`Enter`)return G(Q9(e,n.active),`src/update.ts#PressedPaletteKey`);let r=e.document._tag===`Ready`?I9(e,e.document.document.draft).length:0,i=r?(n.active+(t===`ArrowDown`?1:r-1))%r:0;return G({model:W(e,{palette:()=>G(Wq.Open({...n,active:i}),`src/update.ts#palette~6`)})},`src/update.ts#PressedPaletteKey`)},ClickedPaletteItem:({index:t})=>G(Q9(e,t),`src/update.ts#ClickedPaletteItem`),PressedEditorCommand:({command:t,link:n})=>G(t===`commandPalette`?X9(e,`Commands`):t===`gotoProject`?X9(e,`Projects`):t===`showShortcuts`?X9(e,`Shortcuts`):t===`openLink`&&n===void 0?{model:W(e,{notice:()=>G(T(`No link here`),`src/update.ts#notice~6`)})}:B9(e,r=>G({model:e,commands:[t===`openLink`&&n!==void 0?F9({session:r.session,url:n}):N9({session:r.session,action:t})]},`src/update.ts#anonymous~22`)),`src/update.ts#PressedEditorCommand`),OpenedEditorLink:({url:t})=>G(B9(e,n=>G({model:e,commands:[F9({session:n.session,url:t})]},`src/update.ts#anonymous~23`)),`src/update.ts#OpenedEditorLink`),ShowedEditorNotice:({text:t})=>G({model:W(e,{notice:()=>G(T(t),`src/update.ts#notice~7`)})},`src/update.ts#ShowedEditorNotice`),SucceededMountEditor:()=>G({model:e},`src/update.ts#SucceededMountEditor`),CompletedApplyRemoteText:()=>G({model:e},`src/update.ts#CompletedApplyRemoteText`),CompletedFocusPaletteInput:()=>G({model:e},`src/update.ts#CompletedFocusPaletteInput`),CompletedFocusEditor:()=>G({model:e},`src/update.ts#CompletedFocusEditor`),CompletedRunEditorAction:()=>G({model:e},`src/update.ts#CompletedRunEditorAction`),CompletedRevealEditorPosition:()=>G({model:e},`src/update.ts#CompletedRevealEditorPosition`),CompletedOpenEditorLink:()=>G({model:e},`src/update.ts#CompletedOpenEditorLink`)}),`src/update.ts#update`),vne=e=>G(e.split(`/`).at(-1)??e,`src/view/editor.ts#fileNameFor`),yne=new Intl.Segmenter(void 0,{granularity:`grapheme`}),bne=(e,t)=>{let n=e.slice(0,Math.max(0,Math.min(t,e.length))),r=n.split(`
|
|
129
|
-
`).length;return G(`Ln ${r}, Col ${Array.from(yne.segment(n.slice(n.lastIndexOf(`
|
|
130
|
-
`)+1))).length+1}`,`src/view/editor.ts#cursorLabel`)},xne=(e,t)=>G(t.keyed(`aside`)(`activity`,[t.Class(`pt-activity`),t.AriaLabel(`Activity`)],[t.h2([t.Class(`pt-activity-title`)],[`Activity`]),e.activity.length===0?t.p([t.Class(`pt-activity-empty`)],[`Waiting for changes`]):t.ol([t.Class(`pt-activity-list`)],e.activity.map(e=>G(t.li([t.Class(`pt-activity-item`)],[t.div([t.Class(`pt-activity-header`)],[Nq(e.from,e.to,e.by)]),...e.todos.length===0?[t.div([t.Class(`pt-activity-line`)],[`edited`])]:e.todos.map(e=>G(t.div([t.Class(`pt-activity-line`)],[Mq(e)]),`src/view/editor.ts#anonymous~2`))]),`src/view/editor.ts#anonymous`)))]),`src/view/editor.ts#activityView`),Sne=(e,t,n)=>{let r=d9(t.draft).stats,i=qq(t);return G(n.div([n.Class(`pt-shell`)],[n.header([n.Class(`pt-header`)],[n.h1([n.Class(`pt-file-name`),n.Title(t.path)],[vne(t.path)]),n.div([n.Class(`pt-header-actions`)],[n.button([n.Class(`pt-header-button${e.palette._tag===`Open`?` pt-header-button-active`:``}`),n.Type(`button`),n.OnClick(K.ClickedCommands()),n.AriaExpanded(e.palette._tag===`Open`)],[`Commands`,n.kbd([n.Class(`pt-header-key`)],[QG(e.platform,qG(e.platform,`commandPalette`)[0]??``)])]),n.button([n.Class(`pt-header-button${e.palette._tag===`Open`&&e.palette.kind===`Shortcuts`?` pt-header-button-active`:``}`),n.Type(`button`),n.OnClick(K.PressedHelpKey()),n.AriaExpanded(e.palette._tag===`Open`)],[`Help`,n.kbd([n.Class(`pt-header-key`)],[`?`])]),n.button([n.Class(`pt-header-button${e.activityOpen?` pt-header-button-active`:``}`),n.Type(`button`),n.OnClick(K.ClickedActivity()),n.AriaExpanded(e.activityOpen)],[`Activity`])])]),n.main([n.Class(`pt-workspace${e.activityOpen?` pt-workspace-with-activity`:``}`)],[n.keyed(`div`)(`editor:${t.session}`,[n.Class(`pt-editor-host`),n.OnMount(pne({session:t.session,text:t.draft,selection:t.selection,platform:e.platform}))]),...e.activityOpen?[xne(e,n)]:[]]),n.footer([n.Class(`pt-status-bar`)],[n.div([n.Class(`pt-status-left`)],[n.span([n.Class(`pt-status-item`),n.Title(`${r.done} completed, ${r.cancelled} cancelled, ${r.open} open`)],[Rte(r)]),n.span([n.Class(`pt-notice`),n.Role(`status`),n.Attribute(`aria-live`,`polite`)],O(e.notice,{onNone:()=>G([],`src/view/editor.ts#onNone`),onSome:e=>G(/^(https?:|mailto:)/i.test(e)?[n.a([n.Href(e),n.Attribute(`target`,`_blank`),n.Attribute(`rel`,`noopener noreferrer`)],[e])]:[e],`src/view/editor.ts#onSome`)}))]),n.div([n.Class(`pt-status-center`)],KG.map(t=>G(n.span([n.Class(`pt-hint`)],[n.kbd([n.Class(`pt-hint-key`)],[QG(e.platform,qG(e.platform,t.command)[0]??``)]),n.span([n.Class(`pt-hint-label`)],[t.label])]),`src/view/editor.ts#anonymous~3`))),n.div([n.Class(`pt-status-right`)],[n.span([n.Class(`pt-status-item`)],[bne(t.draft,t.selection.head)]),n.span([n.Class(`pt-status-item`)],[`Version ${t.base.version}`]),n.span([n.Class(`pt-status-item${i===`Saving`?` pt-status-saving`:i===`Reconnecting`?` pt-status-reconnecting`:``}`)],[i])])]),...e.palette._tag===`Open`?[gne(e,t.draft,n)]:[]]),`src/view/editor.ts#editorView`)},Cne=e=>G(e.main([e.Class(`empty-shell`)],[e.div([e.Class(`empty-mark`)],[`do it`]),e.h1([e.Class(`empty-title`)],[`Open a todo`]),e.p([e.Class(`empty-copy`)],[`Run do-it open FILE to start editing a Markdown todo here.`])]),`src/view/editor.ts#emptyView`),$9=(e,t,n,r)=>G(r.main([r.Class(`message-shell`)],[r.div([r.Class(`eyebrow`)],[`DO IT`]),r.h1([r.Class(`file-name`)],[e.split(`/`).at(-1)??e]),r.div([r.Class(`file-path`)],[e]),r.span([r.Class(`connection-status connection-${t.toLowerCase()}`)],[t]),r.h2([r.Class(`message-title`)],[n])]),`src/view/index.ts#terminalView`),wne=(e,t)=>G({title:`do it`,body:Uq.match(e.document,{NoPath:()=>G(Cne(t),`src/view/index.ts#NoPath`),Connecting:({path:e})=>G(t.main([t.Class(`loading-shell`)],[t.div([t.Class(`eyebrow`)],[`DO IT`]),t.h1([t.Class(`loading-title`)],[e.split(`/`).at(-1)??e]),t.p([t.Class(`loading-copy`)],[`Connecting to the live document…`])]),`src/view/index.ts#Connecting`),Ready:({document:n})=>G(Sne(e,n,t),`src/view/index.ts#Ready`),Deleted:({path:e})=>G($9(e,`Deleted`,`This file was deleted or moved`,t),`src/view/index.ts#Deleted`),Unauthorized:({path:e})=>G($9(e,`Reconnecting`,`Session expired: run do-it open again`,t),`src/view/index.ts#Unauthorized`)})},`src/view/index.ts#view`),Tne=z({path:L,platform:Pq}),Ene=M(()=>G({path:new URL(window.location.href).searchParams.get(`path`)??``,platform:$G(navigator.platform,navigator.userAgent)},`src/main.ts#anonymous`));VG(MG({Model:Gq,Flags:Tne,init:e=>G({model:Kq(e.path,e.platform)},`src/main.ts#init`),update:_ne,view:wne,subscriptions:DH()(e=>G({watch:e({maybeWatch:Ww(z({path:L,watchKey:R,resumeFrom:Ww(R)}))},{modelToDependencies:e=>G({maybeWatch:Uq.match(e.document,{NoPath:()=>G(w(),`src/subscription.ts#NoPath`),Deleted:()=>G(w(),`src/subscription.ts#Deleted`),Unauthorized:()=>G(w(),`src/subscription.ts#Unauthorized`),Connecting:({path:e,watchKey:t,resumeFrom:n})=>G(T({path:e,watchKey:t,resumeFrom:n}),`src/subscription.ts#Connecting`),Ready:({document:e})=>G(T({path:e.path,watchKey:e.watchKey,resumeFrom:e.resumeFrom}),`src/subscription.ts#Ready`)})},`src/subscription.ts#modelToDependencies`),dependenciesToStream:({maybeWatch:e})=>G(O(e,{onNone:()=>G(WE,`src/subscription.ts#onNone`),onSome:({path:e,resumeFrom:t})=>G(P(function*(){return G((yield*A9).watch({path:e,text:!0,...D(t)?{since:t.value}:{}}).pipe(iD(e=>G(K.ReceivedWatchEvent({event:e}),`src/subscription.ts#anonymous~3`)),cD(GE(K.WatchEnded())),dD(e=>G(GE(K.FailedWatch({unauthorized:O($d(e),{onNone:()=>G(!1,`src/subscription.ts#onNone~2`),onSome:j9})})),`src/subscription.ts#anonymous~4`))),`src/subscription.ts#anonymous~2`)}).pipe(nD),`src/subscription.ts#onSome`)}),`src/subscription.ts#dependenciesToStream`)}),keyboard:OH(RB({bindings:[{keys:`?`,mapEvent:()=>G(K.PressedHelpKey(),`src/subscription.ts#mapEvent`)},{keys:`Shift+?`,mapEvent:()=>G(K.PressedHelpKey(),`src/subscription.ts#mapEvent~2`)}]}))},`src/subscription.ts#anonymous`)),resources:ine,container:document.getElementById(`root`),devTools:{Message:K}}),{flags:Ene});
|