@extended-mark/cli-linux-arm64 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,638 @@
1
+ var Ck=Object.create;var bl=Object.defineProperty;var Ik=Object.getOwnPropertyDescriptor;var Rk=Object.getOwnPropertyNames;var Ok=Object.getPrototypeOf,Mk=Object.prototype.hasOwnProperty;var V=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Lk=(t,e)=>{for(var n in e)bl(t,n,{get:e[n],enumerable:!0})},jk=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Rk(e))!Mk.call(t,i)&&i!==n&&bl(t,i,{get:()=>e[i],enumerable:!(r=Ik(e,i))||r.enumerable});return t};var Li=(t,e,n)=>(n=t!=null?Ck(Ok(t)):{},jk(e||!t||!t.__esModule?bl(n,"default",{value:t,enumerable:!0}):n,t));var ye=V(et=>{"use strict";var xc=Symbol.for("yaml.alias"),Th=Symbol.for("yaml.document"),Ro=Symbol.for("yaml.map"),Dh=Symbol.for("yaml.pair"),Ec=Symbol.for("yaml.scalar"),Oo=Symbol.for("yaml.seq"),vn=Symbol.for("yaml.node.type"),u0=t=>!!t&&typeof t=="object"&&t[vn]===xc,f0=t=>!!t&&typeof t=="object"&&t[vn]===Th,p0=t=>!!t&&typeof t=="object"&&t[vn]===Ro,h0=t=>!!t&&typeof t=="object"&&t[vn]===Dh,Nh=t=>!!t&&typeof t=="object"&&t[vn]===Ec,d0=t=>!!t&&typeof t=="object"&&t[vn]===Oo;function Ch(t){if(t&&typeof t=="object")switch(t[vn]){case Ro:case Oo:return!0}return!1}function m0(t){if(t&&typeof t=="object")switch(t[vn]){case xc:case Ro:case Ec:case Oo:return!0}return!1}var g0=t=>(Nh(t)||Ch(t))&&!!t.anchor;et.ALIAS=xc;et.DOC=Th;et.MAP=Ro;et.NODE_TYPE=vn;et.PAIR=Dh;et.SCALAR=Ec;et.SEQ=Oo;et.hasAnchor=g0;et.isAlias=u0;et.isCollection=Ch;et.isDocument=f0;et.isMap=p0;et.isNode=m0;et.isPair=h0;et.isScalar=Nh;et.isSeq=d0});var Ji=V(Sc=>{"use strict";var We=ye(),ht=Symbol("break visit"),Ih=Symbol("skip children"),an=Symbol("remove node");function Mo(t,e){let n=Rh(e);We.isDocument(t)?Kr(null,t.contents,n,Object.freeze([t]))===an&&(t.contents=null):Kr(null,t,n,Object.freeze([]))}Mo.BREAK=ht;Mo.SKIP=Ih;Mo.REMOVE=an;function Kr(t,e,n,r){let i=Oh(t,e,n,r);if(We.isNode(i)||We.isPair(i))return Mh(t,r,i),Kr(t,i,n,r);if(typeof i!="symbol"){if(We.isCollection(e)){r=Object.freeze(r.concat(e));for(let s=0;s<e.items.length;++s){let o=Kr(s,e.items[s],n,r);if(typeof o=="number")s=o-1;else{if(o===ht)return ht;o===an&&(e.items.splice(s,1),s-=1)}}}else if(We.isPair(e)){r=Object.freeze(r.concat(e));let s=Kr("key",e.key,n,r);if(s===ht)return ht;s===an&&(e.key=null);let o=Kr("value",e.value,n,r);if(o===ht)return ht;o===an&&(e.value=null)}}return i}async function Lo(t,e){let n=Rh(e);We.isDocument(t)?await Yr(null,t.contents,n,Object.freeze([t]))===an&&(t.contents=null):await Yr(null,t,n,Object.freeze([]))}Lo.BREAK=ht;Lo.SKIP=Ih;Lo.REMOVE=an;async function Yr(t,e,n,r){let i=await Oh(t,e,n,r);if(We.isNode(i)||We.isPair(i))return Mh(t,r,i),Yr(t,i,n,r);if(typeof i!="symbol"){if(We.isCollection(e)){r=Object.freeze(r.concat(e));for(let s=0;s<e.items.length;++s){let o=await Yr(s,e.items[s],n,r);if(typeof o=="number")s=o-1;else{if(o===ht)return ht;o===an&&(e.items.splice(s,1),s-=1)}}}else if(We.isPair(e)){r=Object.freeze(r.concat(e));let s=await Yr("key",e.key,n,r);if(s===ht)return ht;s===an&&(e.key=null);let o=await Yr("value",e.value,n,r);if(o===ht)return ht;o===an&&(e.value=null)}}return i}function Rh(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function Oh(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(We.isMap(e))return n.Map?.(t,e,r);if(We.isSeq(e))return n.Seq?.(t,e,r);if(We.isPair(e))return n.Pair?.(t,e,r);if(We.isScalar(e))return n.Scalar?.(t,e,r);if(We.isAlias(e))return n.Alias?.(t,e,r)}function Mh(t,e,n){let r=e[e.length-1];if(We.isCollection(r))r.items[t]=n;else if(We.isPair(r))t==="key"?r.key=n:r.value=n;else if(We.isDocument(r))r.contents=n;else{let i=We.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}Sc.visit=Mo;Sc.visitAsync=Lo});var Ac=V(jh=>{"use strict";var Lh=ye(),y0=Ji(),k0={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},b0=t=>t.replace(/[!,[\]{}]/g,e=>k0[e]),Zi=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[s,o]=r;return this.tags[s]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[s]=r;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;{let o=/^\d+\.\d+$/.test(s);return n(6,`Unsupported YAML version ${s}`,o),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,r,i]=e.match(/^(.*!)([^!]*)$/s);i||n(`The ${e} tag has no suffix`);let s=this.tags[r];if(s)try{return s+decodeURIComponent(i)}catch(o){return n(String(o)),null}return r==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,r]of Object.entries(this.tags))if(e.startsWith(r))return n+b0(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),i;if(e&&r.length>0&&Lh.isNode(e.contents)){let s={};y0.visit(e.contents,(o,a)=>{Lh.isNode(a)&&a.tag&&(s[a.tag]=!0)}),i=Object.keys(s)}else i=[];for(let[s,o]of r)s==="!!"&&o==="tag:yaml.org,2002:"||(!e||i.some(a=>a.startsWith(o)))&&n.push(`%TAG ${s} ${o}`);return n.join(`
2
+ `)}};Zi.defaultYaml={explicit:!1,version:"1.2"};Zi.defaultTags={"!!":"tag:yaml.org,2002:"};jh.Directives=Zi});var jo=V(Qi=>{"use strict";var Ph=ye(),w0=Ji();function $0(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function _h(t){let e=new Set;return w0.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function qh(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function v0(t,e){let n=[],r=new Map,i=null;return{onAnchor:s=>{n.push(s),i||(i=_h(t));let o=qh(e,i);return i.add(o),o},setAnchors:()=>{for(let s of n){let o=r.get(s);if(typeof o=="object"&&o.anchor&&(Ph.isScalar(o.node)||Ph.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=s,a}}},sourceObjects:r}}Qi.anchorIsValid=$0;Qi.anchorNames=_h;Qi.createNodeAnchors=v0;Qi.findNewAnchor=qh});var Tc=V(Fh=>{"use strict";function Xi(t,e,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let i=0,s=r.length;i<s;++i){let o=r[i],a=Xi(t,r,String(i),o);a===void 0?delete r[i]:a!==o&&(r[i]=a)}else if(r instanceof Map)for(let i of Array.from(r.keys())){let s=r.get(i),o=Xi(t,r,i,s);o===void 0?r.delete(i):o!==s&&r.set(i,o)}else if(r instanceof Set)for(let i of Array.from(r)){let s=Xi(t,r,i,i);s===void 0?r.delete(i):s!==i&&(r.delete(i),r.add(s))}else for(let[i,s]of Object.entries(r)){let o=Xi(t,r,i,s);o===void 0?delete r[i]:o!==s&&(r[i]=o)}return t.call(e,n,r)}Fh.applyReviver=Xi});var qn=V(Vh=>{"use strict";var x0=ye();function Bh(t,e,n){if(Array.isArray(t))return t.map((r,i)=>Bh(r,String(i),n));if(t&&typeof t.toJSON=="function"){if(!n||!x0.hasAnchor(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=s=>{r.res=s,delete n.onCreate};let i=t.toJSON(e,n);return n.onCreate&&n.onCreate(i),i}return typeof t=="bigint"&&!n?.keep?Number(t):t}Vh.toJS=Bh});var Po=V(Uh=>{"use strict";var E0=Tc(),zh=ye(),S0=qn(),Dc=class{constructor(e){Object.defineProperty(this,zh.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:s}={}){if(!zh.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=S0.toJS(this,"",o);if(typeof i=="function")for(let{count:l,res:c}of o.anchors.values())i(c,l);return typeof s=="function"?E0.applyReviver(s,{"":a},"",a):a}};Uh.NodeBase=Dc});var es=V(Hh=>{"use strict";var A0=jo(),Wh=Ji(),_o=ye(),T0=Po(),D0=qn(),Nc=class extends T0.NodeBase{constructor(e){super(_o.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e){let n;return Wh.visit(e,{Node:(r,i)=>{if(i===this)return Wh.visit.BREAK;i.anchor===this.source&&(n=i)}}),n}toJSON(e,n){if(!n)return{source:this.source};let{anchors:r,doc:i,maxAliasCount:s}=n,o=this.resolve(i);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=r.get(o);if(a||(D0.toJS(o,null,n),a=r.get(o)),!a||a.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(s>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=qo(i,o,r)),a.count*a.aliasCount>s)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(A0.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(s)}if(e.implicitKey)return`${i} `}return i}};function qo(t,e,n){if(_o.isAlias(e)){let r=e.resolve(t),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(_o.isCollection(e)){let r=0;for(let i of e.items){let s=qo(t,i,n);s>r&&(r=s)}return r}else if(_o.isPair(e)){let r=qo(t,e.key,n),i=qo(t,e.value,n);return Math.max(r,i)}return 1}Hh.Alias=Nc});var qe=V(Cc=>{"use strict";var N0=ye(),C0=Po(),I0=qn(),R0=t=>!t||typeof t!="function"&&typeof t!="object",Fn=class extends C0.NodeBase{constructor(e){super(N0.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:I0.toJS(this.value,e,n)}toString(){return String(this.value)}};Fn.BLOCK_FOLDED="BLOCK_FOLDED";Fn.BLOCK_LITERAL="BLOCK_LITERAL";Fn.PLAIN="PLAIN";Fn.QUOTE_DOUBLE="QUOTE_DOUBLE";Fn.QUOTE_SINGLE="QUOTE_SINGLE";Cc.Scalar=Fn;Cc.isScalarValue=R0});var ts=V(Kh=>{"use strict";var O0=es(),dr=ye(),Gh=qe(),M0="tag:yaml.org,2002:";function L0(t,e,n){if(e){let r=n.filter(s=>s.tag===e),i=r.find(s=>!s.format)??r[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return n.find(r=>r.identify?.(t)&&!r.format)}function j0(t,e,n){if(dr.isDocument(t)&&(t=t.contents),dr.isNode(t))return t;if(dr.isPair(t)){let f=n.schema[dr.MAP].createNode?.(n.schema,null,n);return f.items.push(t),f}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:s,schema:o,sourceObjects:a}=n,l;if(r&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor||(l.anchor=i(t)),new O0.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=M0+e.slice(2));let c=L0(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let f=new Gh.Scalar(t);return l&&(l.node=f),f}c=t instanceof Map?o[dr.MAP]:Symbol.iterator in Object(t)?o[dr.SEQ]:o[dr.MAP]}s&&(s(c),delete n.onTagObj);let u=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new Gh.Scalar(t);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}Kh.createNode=j0});var Bo=V(Fo=>{"use strict";var P0=ts(),ln=ye(),_0=Po();function Ic(t,e,n){let r=n;for(let i=e.length-1;i>=0;--i){let s=e[i];if(typeof s=="number"&&Number.isInteger(s)&&s>=0){let o=[];o[s]=r,r=o}else r=new Map([[s,r]])}return P0.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Yh=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Rc=class extends _0.NodeBase{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(r=>ln.isNode(r)||ln.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(Yh(e))this.add(n);else{let[r,...i]=e,s=this.get(r,!0);if(ln.isCollection(s))s.addIn(i,n);else if(s===void 0&&this.schema)this.set(r,Ic(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(e){let[n,...r]=e;if(r.length===0)return this.delete(n);let i=this.get(n,!0);if(ln.isCollection(i))return i.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(e,n){let[r,...i]=e,s=this.get(r,!0);return i.length===0?!n&&ln.isScalar(s)?s.value:s:ln.isCollection(s)?s.getIn(i,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!ln.isPair(n))return!1;let r=n.value;return r==null||e&&ln.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[n,...r]=e;if(r.length===0)return this.has(n);let i=this.get(n,!0);return ln.isCollection(i)?i.hasIn(r):!1}setIn(e,n){let[r,...i]=e;if(i.length===0)this.set(r,n);else{let s=this.get(r,!0);if(ln.isCollection(s))s.setIn(i,n);else if(s===void 0&&this.schema)this.set(r,Ic(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}};Fo.Collection=Rc;Fo.collectionFromPath=Ic;Fo.isEmptyPath=Yh});var ns=V(Vo=>{"use strict";var q0=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Oc(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var F0=(t,e,n)=>t.endsWith(`
3
+ `)?Oc(n,e):n.includes(`
4
+ `)?`
5
+ `+Oc(n,e):(t.endsWith(" ")?"":" ")+n;Vo.indentComment=Oc;Vo.lineComment=F0;Vo.stringifyComment=q0});var Zh=V(rs=>{"use strict";var B0="flow",Mc="block",zo="quoted";function V0(t,e,n="flow",{indentAtStart:r,lineWidth:i=80,minContentWidth:s=20,onFold:o,onOverflow:a}={}){if(!i||i<0)return t;i<s&&(s=0);let l=Math.max(1+s,1+i-e.length);if(t.length<=l)return t;let c=[],u={},f=i-e.length;typeof r=="number"&&(r>i-Math.max(2,s)?c.push(0):f=i-r);let p,h,d=!1,m=-1,g=-1,y=-1;n===Mc&&(m=Jh(t,m,e.length),m!==-1&&(f=m+l));for(let b;b=t[m+=1];){if(n===zo&&b==="\\"){switch(g=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}y=m}if(b===`
6
+ `)n===Mc&&(m=Jh(t,m,e.length)),f=m+e.length+l,p=void 0;else{if(b===" "&&h&&h!==" "&&h!==`
7
+ `&&h!==" "){let k=t[m+1];k&&k!==" "&&k!==`
8
+ `&&k!==" "&&(p=m)}if(m>=f)if(p)c.push(p),f=p+l,p=void 0;else if(n===zo){for(;h===" "||h===" ";)h=b,b=t[m+=1],d=!0;let k=m>y+1?m-2:g-1;if(u[k])return t;c.push(k),u[k]=!0,f=k+l,p=void 0}else d=!0}h=b}if(d&&a&&a(),c.length===0)return t;o&&o();let $=t.slice(0,c[0]);for(let b=0;b<c.length;++b){let k=c[b],w=c[b+1]||t.length;k===0?$=`
9
+ ${e}${t.slice(0,w)}`:(n===zo&&u[k]&&($+=`${t[k]}\\`),$+=`
10
+ ${e}${t.slice(k+1,w)}`)}return $}function Jh(t,e,n){let r=e,i=e+1,s=t[i];for(;s===" "||s===" ";)if(e<i+n)s=t[++e];else{do s=t[++e];while(s&&s!==`
11
+ `);r=e,i=e+1,s=t[i]}return r}rs.FOLD_BLOCK=Mc;rs.FOLD_FLOW=B0;rs.FOLD_QUOTED=zo;rs.foldFlowLines=V0});var ss=V(Qh=>{"use strict";var Vt=qe(),Bn=Zh(),Wo=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Ho=t=>/^(%|---|\.\.\.)/m.test(t);function z0(t,e,n){if(!e||e<0)return!1;let r=e-n,i=t.length;if(i<=r)return!1;for(let s=0,o=0;s<i;++s)if(t[s]===`
12
+ `){if(s-o>r)return!0;if(o=s+1,i-o<=r)return!1}return!0}function is(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,i=e.options.doubleQuotedMinMultiLineLength,s=e.indent||(Ho(t)?" ":""),o="",a=0;for(let l=0,c=n[l];c;c=n[++l])if(c===" "&&n[l+1]==="\\"&&n[l+2]==="n"&&(o+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(n[l+1]){case"u":{o+=n.slice(a,l);let u=n.substr(l+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(r||n[l+2]==='"'||n.length<i)l+=1;else{for(o+=n.slice(a,l)+`
13
+
14
+ `;n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"';)o+=`
15
+ `,l+=2;o+=s,n[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+n.slice(a):n,r?o:Bn.foldFlowLines(o,s,Bn.FOLD_QUOTED,Wo(e,!1))}function Lc(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
16
+ `)||/[ \t]\n|\n[ \t]/.test(t))return is(t,e);let n=e.indent||(Ho(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
17
+ ${n}`)+"'";return e.implicitKey?r:Bn.foldFlowLines(r,n,Bn.FOLD_FLOW,Wo(e,!1))}function Jr(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=is;else{let i=t.includes('"'),s=t.includes("'");i&&!s?r=Lc:s&&!i?r=is:r=n?Lc:is}return r(t,e)}var jc;try{jc=new RegExp(`(^|(?<!
18
+ ))
19
+ +(?!
20
+ |$)`,"g")}catch{jc=/\n+(?!\n|$)/g}function Uo({comment:t,type:e,value:n},r,i,s){let{blockQuote:o,commentString:a,lineWidth:l}=r.options;if(!o||/\n[\t ]+$/.test(n)||/^\s*$/.test(n))return Jr(n,r);let c=r.indent||(r.forceBlockIndent||Ho(n)?" ":""),u=o==="literal"?!0:o==="folded"||e===Vt.Scalar.BLOCK_FOLDED?!1:e===Vt.Scalar.BLOCK_LITERAL?!0:!z0(n,l,c.length);if(!n)return u?`|
21
+ `:`>
22
+ `;let f,p;for(p=n.length;p>0;--p){let w=n[p-1];if(w!==`
23
+ `&&w!==" "&&w!==" ")break}let h=n.substring(p),d=h.indexOf(`
24
+ `);d===-1?f="-":n===h||d!==h.length-1?(f="+",s&&s()):f="",h&&(n=n.slice(0,-h.length),h[h.length-1]===`
25
+ `&&(h=h.slice(0,-1)),h=h.replace(jc,`$&${c}`));let m=!1,g,y=-1;for(g=0;g<n.length;++g){let w=n[g];if(w===" ")m=!0;else if(w===`
26
+ `)y=g;else break}let $=n.substring(0,y<g?y+1:g);$&&(n=n.substring($.length),$=$.replace(/\n+/g,`$&${c}`));let k=(m?c?"2":"1":"")+f;if(t&&(k+=" "+a(t.replace(/ ?[\r\n]+/g," ")),i&&i()),!u){let w=n.replace(/\n+/g,`
27
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),v=!1,D=Wo(r,!0);o!=="folded"&&e!==Vt.Scalar.BLOCK_FOLDED&&(D.onOverflow=()=>{v=!0});let I=Bn.foldFlowLines(`${$}${w}${h}`,c,Bn.FOLD_BLOCK,D);if(!v)return`>${k}
28
+ ${c}${I}`}return n=n.replace(/\n+/g,`$&${c}`),`|${k}
29
+ ${c}${$}${n}${h}`}function U0(t,e,n,r){let{type:i,value:s}=t,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:u}=e;if(a&&s.includes(`
30
+ `)||u&&/[[\]{},]/.test(s))return Jr(s,e);if(!s||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return a||u||!s.includes(`
31
+ `)?Jr(s,e):Uo(t,e,n,r);if(!a&&!u&&i!==Vt.Scalar.PLAIN&&s.includes(`
32
+ `))return Uo(t,e,n,r);if(Ho(s)){if(l==="")return e.forceBlockIndent=!0,Uo(t,e,n,r);if(a&&l===c)return Jr(s,e)}let f=s.replace(/\n+/g,`$&
33
+ ${l}`);if(o){let p=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(f),{compat:h,tags:d}=e.doc.schema;if(d.some(p)||h?.some(p))return Jr(s,e)}return a?f:Bn.foldFlowLines(f,l,Bn.FOLD_FLOW,Wo(e,!1))}function W0(t,e,n,r){let{implicitKey:i,inFlow:s}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==Vt.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Vt.Scalar.QUOTE_DOUBLE);let l=u=>{switch(u){case Vt.Scalar.BLOCK_FOLDED:case Vt.Scalar.BLOCK_LITERAL:return i||s?Jr(o.value,e):Uo(o,e,n,r);case Vt.Scalar.QUOTE_DOUBLE:return is(o.value,e);case Vt.Scalar.QUOTE_SINGLE:return Lc(o.value,e);case Vt.Scalar.PLAIN:return U0(o,e,n,r);default:return null}},c=l(a);if(c===null){let{defaultKeyType:u,defaultStringType:f}=e.options,p=i&&u||f;if(c=l(p),c===null)throw new Error(`Unsupported default string type ${p}`)}return c}Qh.stringifyString=W0});var os=V(Pc=>{"use strict";var H0=jo(),Vn=ye(),G0=ns(),K0=ss();function Y0(t,e){let n=Object.assign({blockQuote:!0,commentString:G0.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function J0(t,e){if(e.tag){let i=t.filter(s=>s.tag===e.tag);if(i.length>0)return i.find(s=>s.format===e.format)??i[0]}let n,r;if(Vn.isScalar(e)){r=e.value;let i=t.filter(s=>s.identify?.(r));if(i.length>1){let s=i.filter(o=>o.test);s.length>0&&(i=s)}n=i.find(s=>s.format===e.format)??i.find(s=>!s.format)}else r=e,n=t.find(i=>i.nodeClass&&r instanceof i.nodeClass);if(!n){let i=r?.constructor?.name??typeof r;throw new Error(`Tag not resolved for ${i} value`)}return n}function Z0(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let i=[],s=(Vn.isScalar(t)||Vn.isCollection(t))&&t.anchor;s&&H0.anchorIsValid(s)&&(n.add(s),i.push(`&${s}`));let o=t.tag?t.tag:e.default?null:e.tag;return o&&i.push(r.directives.tagString(o)),i.join(" ")}function Q0(t,e,n,r){if(Vn.isPair(t))return t.toString(e,n,r);if(Vn.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let i,s=Vn.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>i=l});i||(i=J0(e.doc.schema.tags,s));let o=Z0(s,i,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof i.stringify=="function"?i.stringify(s,e,n,r):Vn.isScalar(s)?K0.stringifyString(s,e,n,r):s.toString(e,n,r);return o?Vn.isScalar(s)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
34
+ ${e.indent}${a}`:a}Pc.createStringifyContext=Y0;Pc.stringify=Q0});var nd=V(td=>{"use strict";var xn=ye(),Xh=qe(),ed=os(),as=ns();function X0({key:t,value:e},n,r,i){let{allNullValues:s,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:u,simpleKeys:f}}=n,p=xn.isNode(t)&&t.comment||null;if(f){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(xn.isCollection(t)||!xn.isNode(t)&&typeof t=="object"){let D="With simple keys, collection cannot be used as a key value";throw new Error(D)}}let h=!f&&(!t||p&&e==null&&!n.inFlow||xn.isCollection(t)||(xn.isScalar(t)?t.type===Xh.Scalar.BLOCK_FOLDED||t.type===Xh.Scalar.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!h&&(f||!s),indent:a+l});let d=!1,m=!1,g=ed.stringify(t,n,()=>d=!0,()=>m=!0);if(!h&&!n.inFlow&&g.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(n.inFlow){if(s||e==null)return d&&r&&r(),g===""?"?":h?`? ${g}`:g}else if(s&&!f||e==null&&h)return g=`? ${g}`,p&&!d?g+=as.lineComment(g,n.indent,c(p)):m&&i&&i(),g;d&&(p=null),h?(p&&(g+=as.lineComment(g,n.indent,c(p))),g=`? ${g}
35
+ ${a}:`):(g=`${g}:`,p&&(g+=as.lineComment(g,n.indent,c(p))));let y,$,b;xn.isNode(e)?(y=!!e.spaceBefore,$=e.commentBefore,b=e.comment):(y=!1,$=null,b=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!h&&!p&&xn.isScalar(e)&&(n.indentAtStart=g.length+1),m=!1,!u&&l.length>=2&&!n.inFlow&&!h&&xn.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let k=!1,w=ed.stringify(e,n,()=>k=!0,()=>m=!0),v=" ";if(p||y||$){if(v=y?`
36
+ `:"",$){let D=c($);v+=`
37
+ ${as.indentComment(D,n.indent)}`}w===""&&!n.inFlow?v===`
38
+ `&&(v=`
39
+
40
+ `):v+=`
41
+ ${n.indent}`}else if(!h&&xn.isCollection(e)){let D=w[0],I=w.indexOf(`
42
+ `),L=I!==-1,T=n.inFlow??e.flow??e.items.length===0;if(L||!T){let G=!1;if(L&&(D==="&"||D==="!")){let R=w.indexOf(" ");D==="&"&&R!==-1&&R<I&&w[R+1]==="!"&&(R=w.indexOf(" ",R+1)),(R===-1||I<R)&&(G=!0)}G||(v=`
43
+ ${n.indent}`)}}else(w===""||w[0]===`
44
+ `)&&(v="");return g+=v+w,n.inFlow?k&&r&&r():b&&!k?g+=as.lineComment(g,n.indent,c(b)):m&&i&&i(),g}td.stringifyPair=X0});var qc=V(_c=>{"use strict";function ev(t,...e){t==="debug"&&console.log(...e)}function tv(t,e){(t==="debug"||t==="warn")&&(typeof process<"u"&&process.emitWarning?process.emitWarning(e):console.warn(e))}_c.debug=ev;_c.warn=tv});var Jo=V(Yo=>{"use strict";var ls=ye(),rd=qe(),Go="<<",Ko={identify:t=>t===Go||typeof t=="symbol"&&t.description===Go,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new rd.Scalar(Symbol(Go)),{addToJSMap:id}),stringify:()=>Go},nv=(t,e)=>(Ko.identify(e)||ls.isScalar(e)&&(!e.type||e.type===rd.Scalar.PLAIN)&&Ko.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===Ko.tag&&n.default);function id(t,e,n){if(n=t&&ls.isAlias(n)?n.resolve(t.doc):n,ls.isSeq(n))for(let r of n.items)Fc(t,e,r);else if(Array.isArray(n))for(let r of n)Fc(t,e,r);else Fc(t,e,n)}function Fc(t,e,n){let r=t&&ls.isAlias(n)?n.resolve(t.doc):n;if(!ls.isMap(r))throw new Error("Merge sources must be maps or map aliases");let i=r.toJSON(null,t,Map);for(let[s,o]of i)e instanceof Map?e.has(s)||e.set(s,o):e instanceof Set?e.add(s):Object.prototype.hasOwnProperty.call(e,s)||Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}Yo.addMergeToJSMap=id;Yo.isMergeKey=nv;Yo.merge=Ko});var Vc=V(ad=>{"use strict";var rv=qc(),sd=Jo(),iv=os(),od=ye(),Bc=qn();function sv(t,e,{key:n,value:r}){if(od.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(sd.isMergeKey(t,n))sd.addMergeToJSMap(t,e,r);else{let i=Bc.toJS(n,"",t);if(e instanceof Map)e.set(i,Bc.toJS(r,i,t));else if(e instanceof Set)e.add(i);else{let s=ov(n,i,t),o=Bc.toJS(r,s,t);s in e?Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[s]=o}}return e}function ov(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(od.isNode(t)&&n?.doc){let r=iv.createStringifyContext(n.doc,{});r.anchors=new Set;for(let s of n.anchors.keys())r.anchors.add(s.anchor);r.inFlow=!0,r.inStringifyKey=!0;let i=t.toString(r);if(!n.mapKeyWarned){let s=JSON.stringify(i);s.length>40&&(s=s.substring(0,36)+'..."'),rv.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${s}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return i}return JSON.stringify(e)}ad.addPairToJSMap=sv});var zn=V(zc=>{"use strict";var ld=ts(),av=nd(),lv=Vc(),Zo=ye();function cv(t,e,n){let r=ld.createNode(t,void 0,n),i=ld.createNode(e,void 0,n);return new Qo(r,i)}var Qo=class t{constructor(e,n=null){Object.defineProperty(this,Zo.NODE_TYPE,{value:Zo.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return Zo.isNode(n)&&(n=n.clone(e)),Zo.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return lv.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?av.stringifyPair(this,e,n,r):JSON.stringify(this)}};zc.Pair=Qo;zc.createPair=cv});var Uc=V(ud=>{"use strict";var mr=ye(),cd=os(),Xo=ns();function uv(t,e,n){return(e.inFlow??t.flow?pv:fv)(t,e,n)}function fv({comment:t,items:e},n,{blockItemPrefix:r,flowChars:i,itemIndent:s,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,u=Object.assign({},n,{indent:s,type:null}),f=!1,p=[];for(let d=0;d<e.length;++d){let m=e[d],g=null;if(mr.isNode(m))!f&&m.spaceBefore&&p.push(""),ea(n,p,m.commentBefore,f),m.comment&&(g=m.comment);else if(mr.isPair(m)){let $=mr.isNode(m.key)?m.key:null;$&&(!f&&$.spaceBefore&&p.push(""),ea(n,p,$.commentBefore,f))}f=!1;let y=cd.stringify(m,u,()=>g=null,()=>f=!0);g&&(y+=Xo.lineComment(y,s,c(g))),f&&g&&(f=!1),p.push(r+y)}let h;if(p.length===0)h=i.start+i.end;else{h=p[0];for(let d=1;d<p.length;++d){let m=p[d];h+=m?`
45
+ ${l}${m}`:`
46
+ `}}return t?(h+=`
47
+ `+Xo.indentComment(c(t),l),a&&a()):f&&o&&o(),h}function pv({items:t},e,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:s,flowCollectionPadding:o,options:{commentString:a}}=e;r+=s;let l=Object.assign({},e,{indent:r,inFlow:!0,type:null}),c=!1,u=0,f=[];for(let d=0;d<t.length;++d){let m=t[d],g=null;if(mr.isNode(m))m.spaceBefore&&f.push(""),ea(e,f,m.commentBefore,!1),m.comment&&(g=m.comment);else if(mr.isPair(m)){let $=mr.isNode(m.key)?m.key:null;$&&($.spaceBefore&&f.push(""),ea(e,f,$.commentBefore,!1),$.comment&&(c=!0));let b=mr.isNode(m.value)?m.value:null;b?(b.comment&&(g=b.comment),b.commentBefore&&(c=!0)):m.value==null&&$?.comment&&(g=$.comment)}g&&(c=!0);let y=cd.stringify(m,l,()=>g=null);d<t.length-1&&(y+=","),g&&(y+=Xo.lineComment(y,r,a(g))),!c&&(f.length>u||y.includes(`
48
+ `))&&(c=!0),f.push(y),u=f.length}let{start:p,end:h}=n;if(f.length===0)return p+h;if(!c){let d=f.reduce((m,g)=>m+g.length+2,2);c=e.options.lineWidth>0&&d>e.options.lineWidth}if(c){let d=p;for(let m of f)d+=m?`
49
+ ${s}${i}${m}`:`
50
+ `;return`${d}
51
+ ${i}${h}`}else return`${p}${o}${f.join(" ")}${o}${h}`}function ea({indent:t,options:{commentString:e}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,"")),r){let s=Xo.indentComment(e(r),t);n.push(s.trimStart())}}ud.stringifyCollection=uv});var Wn=V(Hc=>{"use strict";var hv=Uc(),dv=Vc(),mv=Bo(),Un=ye(),ta=zn(),gv=qe();function cs(t,e){let n=Un.isScalar(e)?e.value:e;for(let r of t)if(Un.isPair(r)&&(r.key===e||r.key===n||Un.isScalar(r.key)&&r.key.value===n))return r}var Wc=class extends mv.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Un.MAP,e),this.items=[]}static from(e,n,r){let{keepUndefined:i,replacer:s}=r,o=new this(e),a=(l,c)=>{if(typeof s=="function")c=s.call(n,l,c);else if(Array.isArray(s)&&!s.includes(l))return;(c!==void 0||i)&&o.items.push(ta.createPair(l,c,r))};if(n instanceof Map)for(let[l,c]of n)a(l,c);else if(n&&typeof n=="object")for(let l of Object.keys(n))a(l,n[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,n){let r;Un.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new ta.Pair(e,e?.value):r=new ta.Pair(e.key,e.value);let i=cs(this.items,r.key),s=this.schema?.sortMapEntries;if(i){if(!n)throw new Error(`Key ${r.key} already set`);Un.isScalar(i.value)&&gv.isScalarValue(r.value)?i.value.value=r.value:i.value=r.value}else if(s){let o=this.items.findIndex(a=>s(r,a)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let n=cs(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let i=cs(this.items,e)?.value;return(!n&&Un.isScalar(i)?i.value:i)??void 0}has(e){return!!cs(this.items,e)}set(e,n){this.add(new ta.Pair(e,n),!0)}toJSON(e,n,r){let i=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(i);for(let s of this.items)dv.addPairToJSMap(n,i,s);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let i of this.items)if(!Un.isPair(i))throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),hv.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};Hc.YAMLMap=Wc;Hc.findPair=cs});var Zr=V(pd=>{"use strict";var yv=ye(),fd=Wn(),kv={collection:"map",default:!0,nodeClass:fd.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return yv.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>fd.YAMLMap.from(t,e,n)};pd.map=kv});var Hn=V(hd=>{"use strict";var bv=ts(),wv=Uc(),$v=Bo(),ra=ye(),vv=qe(),xv=qn(),Gc=class extends $v.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ra.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=na(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=na(e);if(typeof r!="number")return;let i=this.items[r];return!n&&ra.isScalar(i)?i.value:i}has(e){let n=na(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=na(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let i=this.items[r];ra.isScalar(i)&&vv.isScalarValue(n)?i.value=n:this.items[r]=n}toJSON(e,n){let r=[];n?.onCreate&&n.onCreate(r);let i=0;for(let s of this.items)r.push(xv.toJS(s,String(i++),n));return r}toString(e,n,r){return e?wv.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,s=new this(e);if(n&&Symbol.iterator in Object(n)){let o=0;for(let a of n){if(typeof i=="function"){let l=n instanceof Set?a:String(o++);a=i.call(n,l,a)}s.items.push(bv.createNode(a,void 0,r))}}return s}};function na(t){let e=ra.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}hd.YAMLSeq=Gc});var Qr=V(md=>{"use strict";var Ev=ye(),dd=Hn(),Sv={collection:"seq",default:!0,nodeClass:dd.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Ev.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>dd.YAMLSeq.from(t,e,n)};md.seq=Sv});var us=V(gd=>{"use strict";var Av=ss(),Tv={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,r){return e=Object.assign({actualString:!0},e),Av.stringifyString(t,e,n,r)}};gd.string=Tv});var ia=V(bd=>{"use strict";var yd=qe(),kd={identify:t=>t==null,createNode:()=>new yd.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new yd.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&kd.test.test(t)?t:e.options.nullStr};bd.nullTag=kd});var Kc=V($d=>{"use strict";var Dv=qe(),wd={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new Dv.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&wd.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};$d.boolTag=wd});var Xr=V(vd=>{"use strict";function Nv({format:t,minFractionDigits:e,tag:n,value:r}){if(typeof r=="bigint")return String(r);let i=typeof r=="number"?r:Number(r);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let s=JSON.stringify(r);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^\d/.test(s)){let o=s.indexOf(".");o<0&&(o=s.length,s+=".");let a=e-(s.length-o-1);for(;a-- >0;)s+="0"}return s}vd.stringifyNumber=Nv});var Jc=V(sa=>{"use strict";var Cv=qe(),Yc=Xr(),Iv={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Yc.stringifyNumber},Rv={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Yc.stringifyNumber(t)}},Ov={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new Cv.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:Yc.stringifyNumber};sa.float=Ov;sa.floatExp=Rv;sa.floatNaN=Iv});var Qc=V(aa=>{"use strict";var xd=Xr(),oa=t=>typeof t=="bigint"||Number.isInteger(t),Zc=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function Ed(t,e,n){let{value:r}=t;return oa(r)&&r>=0?n+r.toString(e):xd.stringifyNumber(t)}var Mv={identify:t=>oa(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Zc(t,2,8,n),stringify:t=>Ed(t,8,"0o")},Lv={identify:oa,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Zc(t,0,10,n),stringify:xd.stringifyNumber},jv={identify:t=>oa(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Zc(t,2,16,n),stringify:t=>Ed(t,16,"0x")};aa.int=Lv;aa.intHex=jv;aa.intOct=Mv});var Ad=V(Sd=>{"use strict";var Pv=Zr(),_v=ia(),qv=Qr(),Fv=us(),Bv=Kc(),Xc=Jc(),eu=Qc(),Vv=[Pv.map,qv.seq,Fv.string,_v.nullTag,Bv.boolTag,eu.intOct,eu.int,eu.intHex,Xc.floatNaN,Xc.floatExp,Xc.float];Sd.schema=Vv});var Nd=V(Dd=>{"use strict";var zv=qe(),Uv=Zr(),Wv=Qr();function Td(t){return typeof t=="bigint"||Number.isInteger(t)}var la=({value:t})=>JSON.stringify(t),Hv=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:la},{identify:t=>t==null,createNode:()=>new zv.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:la},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:la},{identify:Td,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>Td(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:la}],Gv={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Kv=[Uv.map,Wv.seq].concat(Hv,Gv);Dd.schema=Kv});var nu=V(Cd=>{"use strict";var tu=qe(),Yv=ss(),Jv={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof Buffer=="function")return Buffer.from(t,"base64");if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},r,i,s){let o=n,a;if(typeof Buffer=="function")a=o instanceof Buffer?o.toString("base64"):Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e||(e=tu.Scalar.BLOCK_LITERAL),e!==tu.Scalar.QUOTE_DOUBLE){let l=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),c=Math.ceil(a.length/l),u=new Array(c);for(let f=0,p=0;f<c;++f,p+=l)u[f]=a.substr(p,l);a=u.join(e===tu.Scalar.BLOCK_LITERAL?`
52
+ `:" ")}return Yv.stringifyString({comment:t,type:e,value:a},r,i,s)}};Cd.binary=Jv});var fa=V(ua=>{"use strict";var ca=ye(),ru=zn(),Zv=qe(),Qv=Hn();function Id(t,e){if(ca.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!ca.isPair(r)){if(ca.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let i=r.items[0]||new ru.Pair(new Zv.Scalar(null));if(r.commentBefore&&(i.key.commentBefore=i.key.commentBefore?`${r.commentBefore}
53
+ ${i.key.commentBefore}`:r.commentBefore),r.comment){let s=i.value??i.key;s.comment=s.comment?`${r.comment}
54
+ ${s.comment}`:r.comment}r=i}t.items[n]=ca.isPair(r)?r:new ru.Pair(r)}}else e("Expected a sequence for this tag");return t}function Rd(t,e,n){let{replacer:r}=n,i=new Qv.YAMLSeq(t);i.tag="tag:yaml.org,2002:pairs";let s=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof r=="function"&&(o=r.call(e,String(s++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;i.items.push(ru.createPair(a,l,n))}return i}var Xv={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Id,createNode:Rd};ua.createPairs=Rd;ua.pairs=Xv;ua.resolvePairs=Id});var ou=V(su=>{"use strict";var Od=ye(),iu=qn(),fs=Wn(),ex=Hn(),Md=fa(),gr=class t extends ex.YAMLSeq{constructor(){super(),this.add=fs.YAMLMap.prototype.add.bind(this),this.delete=fs.YAMLMap.prototype.delete.bind(this),this.get=fs.YAMLMap.prototype.get.bind(this),this.has=fs.YAMLMap.prototype.has.bind(this),this.set=fs.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let r=new Map;n?.onCreate&&n.onCreate(r);for(let i of this.items){let s,o;if(Od.isPair(i)?(s=iu.toJS(i.key,"",n),o=iu.toJS(i.value,s,n)):s=iu.toJS(i,"",n),r.has(s))throw new Error("Ordered maps must not include duplicate keys");r.set(s,o)}return r}static from(e,n,r){let i=Md.createPairs(e,n,r),s=new this;return s.items=i.items,s}};gr.tag="tag:yaml.org,2002:omap";var tx={collection:"seq",identify:t=>t instanceof Map,nodeClass:gr,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Md.resolvePairs(t,e),r=[];for(let{key:i}of n.items)Od.isScalar(i)&&(r.includes(i.value)?e(`Ordered maps must not include duplicate keys: ${i.value}`):r.push(i.value));return Object.assign(new gr,n)},createNode:(t,e,n)=>gr.from(t,e,n)};su.YAMLOMap=gr;su.omap=tx});var qd=V(au=>{"use strict";var Ld=qe();function jd({value:t,source:e},n){return e&&(t?Pd:_d).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Pd={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ld.Scalar(!0),stringify:jd},_d={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ld.Scalar(!1),stringify:jd};au.falseTag=_d;au.trueTag=Pd});var Fd=V(pa=>{"use strict";var nx=qe(),lu=Xr(),rx={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:lu.stringifyNumber},ix={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():lu.stringifyNumber(t)}},sx={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new nx.Scalar(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let r=t.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:lu.stringifyNumber};pa.float=sx;pa.floatExp=ix;pa.floatNaN=rx});var Vd=V(hs=>{"use strict";var Bd=Xr(),ps=t=>typeof t=="bigint"||Number.isInteger(t);function ha(t,e,n,{intAsBigInt:r}){let i=t[0];if((i==="-"||i==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return i==="-"?BigInt(-1)*o:o}let s=parseInt(t,n);return i==="-"?-1*s:s}function cu(t,e,n){let{value:r}=t;if(ps(r)){let i=r.toString(e);return r<0?"-"+n+i.substr(1):n+i}return Bd.stringifyNumber(t)}var ox={identify:ps,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>ha(t,2,2,n),stringify:t=>cu(t,2,"0b")},ax={identify:ps,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>ha(t,1,8,n),stringify:t=>cu(t,8,"0")},lx={identify:ps,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>ha(t,0,10,n),stringify:Bd.stringifyNumber},cx={identify:ps,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>ha(t,2,16,n),stringify:t=>cu(t,16,"0x")};hs.int=lx;hs.intBin=ox;hs.intHex=cx;hs.intOct=ax});var fu=V(uu=>{"use strict";var ga=ye(),da=zn(),ma=Wn(),yr=class t extends ma.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;ga.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new da.Pair(e.key,null):n=new da.Pair(e,null),ma.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=ma.findPair(this.items,e);return!n&&ga.isPair(r)?ga.isScalar(r.key)?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=ma.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new da.Pair(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(e,n,r){let{replacer:i}=r,s=new this(e);if(n&&Symbol.iterator in Object(n))for(let o of n)typeof i=="function"&&(o=i.call(n,o,o)),s.items.push(da.createPair(o,null,r));return s}};yr.tag="tag:yaml.org,2002:set";var ux={collection:"map",identify:t=>t instanceof Set,nodeClass:yr,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>yr.from(t,e,n),resolve(t,e){if(ga.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new yr,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};uu.YAMLSet=yr;uu.set=ux});var hu=V(ya=>{"use strict";var fx=Xr();function pu(t,e){let n=t[0],r=n==="-"||n==="+"?t.substring(1):t,i=o=>e?BigInt(o):Number(o),s=r.replace(/_/g,"").split(":").reduce((o,a)=>o*i(60)+i(a),i(0));return n==="-"?i(-1)*s:s}function zd(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return fx.stringifyNumber(t);let r="";e<0&&(r="-",e*=n(-1));let i=n(60),s=[e%i];return e<60?s.unshift(0):(e=(e-s[0])/i,s.unshift(e%i),e>=60&&(e=(e-s[0])/i,s.unshift(e))),r+s.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var px={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>pu(t,n),stringify:zd},hx={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>pu(t,!1),stringify:zd},Ud={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(Ud.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,i,s,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,r-1,i,s||0,o||0,a||0,l),u=e[8];if(u&&u!=="Z"){let f=pu(u,!1);Math.abs(f)<30&&(f*=60),c-=6e4*f}return new Date(c)},stringify:({value:t})=>t.toISOString().replace(/(T00:00:00)?\.000Z$/,"")};ya.floatTime=hx;ya.intTime=px;ya.timestamp=Ud});var Gd=V(Hd=>{"use strict";var dx=Zr(),mx=ia(),gx=Qr(),yx=us(),kx=nu(),Wd=qd(),du=Fd(),ka=Vd(),bx=Jo(),wx=ou(),$x=fa(),vx=fu(),mu=hu(),xx=[dx.map,gx.seq,yx.string,mx.nullTag,Wd.trueTag,Wd.falseTag,ka.intBin,ka.intOct,ka.int,ka.intHex,du.floatNaN,du.floatExp,du.float,kx.binary,bx.merge,wx.omap,$x.pairs,vx.set,mu.intTime,mu.floatTime,mu.timestamp];Hd.schema=xx});var rm=V(ku=>{"use strict";var Zd=Zr(),Ex=ia(),Qd=Qr(),Sx=us(),Ax=Kc(),gu=Jc(),yu=Qc(),Tx=Ad(),Dx=Nd(),Xd=nu(),ds=Jo(),em=ou(),tm=fa(),Kd=Gd(),nm=fu(),ba=hu(),Yd=new Map([["core",Tx.schema],["failsafe",[Zd.map,Qd.seq,Sx.string]],["json",Dx.schema],["yaml11",Kd.schema],["yaml-1.1",Kd.schema]]),Jd={binary:Xd.binary,bool:Ax.boolTag,float:gu.float,floatExp:gu.floatExp,floatNaN:gu.floatNaN,floatTime:ba.floatTime,int:yu.int,intHex:yu.intHex,intOct:yu.intOct,intTime:ba.intTime,map:Zd.map,merge:ds.merge,null:Ex.nullTag,omap:em.omap,pairs:tm.pairs,seq:Qd.seq,set:nm.set,timestamp:ba.timestamp},Nx={"tag:yaml.org,2002:binary":Xd.binary,"tag:yaml.org,2002:merge":ds.merge,"tag:yaml.org,2002:omap":em.omap,"tag:yaml.org,2002:pairs":tm.pairs,"tag:yaml.org,2002:set":nm.set,"tag:yaml.org,2002:timestamp":ba.timestamp};function Cx(t,e,n){let r=Yd.get(e);if(r&&!t)return n&&!r.includes(ds.merge)?r.concat(ds.merge):r.slice();let i=r;if(!i)if(Array.isArray(t))i=[];else{let s=Array.from(Yd.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${s} or define customTags array`)}if(Array.isArray(t))for(let s of t)i=i.concat(s);else typeof t=="function"&&(i=t(i.slice()));return n&&(i=i.concat(ds.merge)),i.reduce((s,o)=>{let a=typeof o=="string"?Jd[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Jd).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return s.includes(a)||s.push(a),s},[])}ku.coreKnownTags=Nx;ku.getTags=Cx});var $u=V(im=>{"use strict";var bu=ye(),Ix=Zr(),Rx=Qr(),Ox=us(),wa=rm(),Mx=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,wu=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:i,schema:s,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?wa.getTags(e,"compat"):e?wa.getTags(null,e):null,this.name=typeof s=="string"&&s||"core",this.knownTags=i?wa.coreKnownTags:{},this.tags=wa.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,bu.MAP,{value:Ix.map}),Object.defineProperty(this,bu.SCALAR,{value:Ox.string}),Object.defineProperty(this,bu.SEQ,{value:Rx.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Mx:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};im.Schema=wu});var om=V(sm=>{"use strict";var Lx=ye(),vu=os(),ms=ns();function jx(t,e){let n=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let l=t.directives.toString(t);l?(n.push(l),r=!0):t.directives.docStart&&(r=!0)}r&&n.push("---");let i=vu.createStringifyContext(t,e),{commentString:s}=i.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=s(t.commentBefore);n.unshift(ms.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(Lx.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let u=s(t.contents.commentBefore);n.push(ms.indentComment(u,""))}i.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=vu.stringify(t.contents,i,()=>a=null,l);a&&(c+=ms.lineComment(c,"",s(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(vu.stringify(t.contents,i));if(t.directives?.docEnd)if(t.comment){let l=s(t.comment);l.includes(`
55
+ `)?(n.push("..."),n.push(ms.indentComment(l,""))):n.push(`... ${l}`)}else n.push("...");else{let l=t.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&n[n.length-1]!==""&&n.push(""),n.push(ms.indentComment(s(l),"")))}return n.join(`
56
+ `)+`
57
+ `}sm.stringifyDocument=jx});var gs=V(am=>{"use strict";var Px=es(),ei=Bo(),Ct=ye(),_x=zn(),qx=qn(),Fx=$u(),Bx=om(),xu=jo(),Vx=Tc(),zx=ts(),Eu=Ac(),Su=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Ct.NODE_TYPE,{value:Ct.DOC});let i=null;typeof n=="function"||Array.isArray(n)?i=n:r===void 0&&n&&(r=n,n=void 0);let s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=s;let{version:o}=s;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Eu.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,i,r)}clone(){let e=Object.create(t.prototype,{[Ct.NODE_TYPE]:{value:Ct.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=Ct.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){ti(this.contents)&&this.contents.add(e)}addIn(e,n){ti(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=xu.anchorNames(this);e.anchor=!n||r.has(n)?xu.findNewAnchor(n||"a",r):n}return new Px.Alias(e.anchor)}createNode(e,n,r){let i;if(typeof n=="function")e=n.call({"":e},"",e),i=n;else if(Array.isArray(n)){let g=$=>typeof $=="number"||$ instanceof String||$ instanceof Number,y=n.filter(g).map(String);y.length>0&&(n=n.concat(y)),i=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:s,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:u}=r??{},{onAnchor:f,setAnchors:p,sourceObjects:h}=xu.createNodeAnchors(this,o||"a"),d={aliasDuplicateObjects:s??!0,keepUndefined:l??!1,onAnchor:f,onTagObj:c,replacer:i,schema:this.schema,sourceObjects:h},m=zx.createNode(e,u,d);return a&&Ct.isCollection(m)&&(m.flow=!0),p(),m}createPair(e,n,r={}){let i=this.createNode(e,null,r),s=this.createNode(n,null,r);return new _x.Pair(i,s)}delete(e){return ti(this.contents)?this.contents.delete(e):!1}deleteIn(e){return ei.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):ti(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return Ct.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return ei.isEmptyPath(e)?!n&&Ct.isScalar(this.contents)?this.contents.value:this.contents:Ct.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return Ct.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return ei.isEmptyPath(e)?this.contents!==void 0:Ct.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=ei.collectionFromPath(this.schema,[e],n):ti(this.contents)&&this.contents.set(e,n)}setIn(e,n){ei.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=ei.collectionFromPath(this.schema,Array.from(e),n):ti(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Eu.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Eu.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let i=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(r)this.schema=new Fx.Schema(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:r,maxAliasCount:i,onAnchor:s,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},l=qx.toJS(this.contents,n??"",a);if(typeof s=="function")for(let{count:c,res:u}of a.anchors.values())s(u,c);return typeof o=="function"?Vx.applyReviver(o,{"":l},"",l):l}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return Bx.stringifyDocument(this,e)}};function ti(t){if(Ct.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}am.Document=Su});var bs=V(ks=>{"use strict";var ys=class extends Error{constructor(e,n,r,i){super(),this.name=e,this.code=r,this.message=i,this.pos=n}},Au=class extends ys{constructor(e,n,r){super("YAMLParseError",e,n,r)}},Tu=class extends ys{constructor(e,n,r){super("YAMLWarning",e,n,r)}},Ux=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let s=i-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(s>=60&&o.length>80){let a=Math.min(s-39,o.length-79);o="\u2026"+o.substring(a),s-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(o.substring(0,s))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
58
+ `),o=a+o}if(/[^ ]/.test(o)){let a=1,l=n.linePos[1];l&&l.line===r&&l.col>i&&(a=Math.max(1,Math.min(l.col-i,80-s)));let c=" ".repeat(s)+"^".repeat(a);n.message+=`:
59
+
60
+ ${o}
61
+ ${c}
62
+ `}};ks.YAMLError=ys;ks.YAMLParseError=Au;ks.YAMLWarning=Tu;ks.prettifyError=Ux});var ws=V(lm=>{"use strict";function Wx(t,{flow:e,indicator:n,next:r,offset:i,onError:s,parentIndent:o,startOnNewline:a}){let l=!1,c=a,u=a,f="",p="",h=!1,d=!1,m=null,g=null,y=null,$=null,b=null,k=null,w=null;for(let I of t)switch(d&&(I.type!=="space"&&I.type!=="newline"&&I.type!=="comma"&&s(I.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),d=!1),m&&(c&&I.type!=="comment"&&I.type!=="newline"&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),I.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&I.source.includes(" ")&&(m=I),u=!0;break;case"comment":{u||s(I,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let L=I.source.substring(1)||" ";f?f+=p+L:f=L,p="",c=!1;break}case"newline":c?f?f+=I.source:l=!0:p+=I.source,c=!0,h=!0,(g||y)&&($=I),u=!0;break;case"anchor":g&&s(I,"MULTIPLE_ANCHORS","A node can have at most one anchor"),I.source.endsWith(":")&&s(I.offset+I.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=I,w===null&&(w=I.offset),c=!1,u=!1,d=!0;break;case"tag":{y&&s(I,"MULTIPLE_TAGS","A node can have at most one tag"),y=I,w===null&&(w=I.offset),c=!1,u=!1,d=!0;break}case n:(g||y)&&s(I,"BAD_PROP_ORDER",`Anchors and tags must be after the ${I.source} indicator`),k&&s(I,"UNEXPECTED_TOKEN",`Unexpected ${I.source} in ${e??"collection"}`),k=I,c=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(e){b&&s(I,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=I,c=!1,u=!1;break}default:s(I,"UNEXPECTED_TOKEN",`Unexpected ${I.type} token`),c=!1,u=!1}let v=t[t.length-1],D=v?v.offset+v.source.length:i;return d&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&s(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:k,spaceBefore:l,comment:f,hasNewline:h,anchor:g,tag:y,newlineAfterProp:$,end:D,start:w??D}}lm.resolveProps=Wx});var $a=V(cm=>{"use strict";function Du(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
63
+ `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(Du(e.key)||Du(e.value))return!0}return!1;default:return!0}}cm.containsNewline=Du});var Nu=V(um=>{"use strict";var Hx=$a();function Gx(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&Hx.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}um.flowIndentCheck=Gx});var Cu=V(pm=>{"use strict";var fm=ye();function Kx(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let i=typeof r=="function"?r:(s,o)=>s===o||fm.isScalar(s)&&fm.isScalar(o)&&s.value===o.value;return e.some(s=>i(s.key,n))}pm.mapIncludes=Kx});var km=V(ym=>{"use strict";var hm=zn(),Yx=Wn(),dm=ws(),Jx=$a(),mm=Nu(),Zx=Cu(),gm="All mapping items must start at the same column";function Qx({composeNode:t,composeEmptyNode:e},n,r,i,s){let o=s?.nodeClass??Yx.YAMLMap,a=new o(n.schema);n.atRoot&&(n.atRoot=!1);let l=r.offset,c=null;for(let u of r.items){let{start:f,key:p,sep:h,value:d}=u,m=dm.resolveProps(f,{indicator:"explicit-key-ind",next:p??h?.[0],offset:l,onError:i,parentIndent:r.indent,startOnNewline:!0}),g=!m.found;if(g){if(p&&(p.type==="block-seq"?i(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==r.indent&&i(l,"BAD_INDENT",gm)),!m.anchor&&!m.tag&&!h){c=m.end,m.comment&&(a.comment?a.comment+=`
64
+ `+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||Jx.containsNewline(p))&&i(p??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==r.indent&&i(l,"BAD_INDENT",gm);n.atKey=!0;let y=m.end,$=p?t(n,p,m,i):e(n,y,f,null,m,i);n.schema.compat&&mm.flowIndentCheck(r.indent,p,i),n.atKey=!1,Zx.mapIncludes(n,a.items,$)&&i(y,"DUPLICATE_KEY","Map keys must be unique");let b=dm.resolveProps(h??[],{indicator:"map-value-ind",next:d,offset:$.range[2],onError:i,parentIndent:r.indent,startOnNewline:!p||p.type==="block-scalar"});if(l=b.end,b.found){g&&(d?.type==="block-map"&&!b.hasNewline&&i(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<b.found.offset-1024&&i($.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=d?t(n,d,b,i):e(n,l,h,null,b,i);n.schema.compat&&mm.flowIndentCheck(r.indent,d,i),l=k.range[2];let w=new hm.Pair($,k);n.options.keepSourceTokens&&(w.srcToken=u),a.items.push(w)}else{g&&i($.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&($.comment?$.comment+=`
65
+ `+b.comment:$.comment=b.comment);let k=new hm.Pair($);n.options.keepSourceTokens&&(k.srcToken=u),a.items.push(k)}}return c&&c<l&&i(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,l,c??l],a}ym.resolveBlockMap=Qx});var wm=V(bm=>{"use strict";var Xx=Hn(),e1=ws(),t1=Nu();function n1({composeNode:t,composeEmptyNode:e},n,r,i,s){let o=s?.nodeClass??Xx.YAMLSeq,a=new o(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=r.offset,c=null;for(let{start:u,value:f}of r.items){let p=e1.resolveProps(u,{indicator:"seq-item-ind",next:f,offset:l,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!p.found)if(p.anchor||p.tag||f)f&&f.type==="block-seq"?i(p.end,"BAD_INDENT","All sequence items must start at the same column"):i(l,"MISSING_CHAR","Sequence item without - indicator");else{c=p.end,p.comment&&(a.comment=p.comment);continue}let h=f?t(n,f,p,i):e(n,p.end,u,null,p,i);n.schema.compat&&t1.flowIndentCheck(r.indent,f,i),l=h.range[2],a.items.push(h)}return a.range=[r.offset,l,c??l],a}bm.resolveBlockSeq=n1});var ni=V($m=>{"use strict";function r1(t,e,n,r){let i="";if(t){let s=!1,o="";for(let a of t){let{source:l,type:c}=a;switch(c){case"space":s=!0;break;case"comment":{n&&!s&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=l.substring(1)||" ";i?i+=o+u:i=u,o="";break}case"newline":i&&(o+=l),s=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:i,offset:e}}$m.resolveEnd=r1});var Sm=V(Em=>{"use strict";var i1=ye(),s1=zn(),vm=Wn(),o1=Hn(),a1=ni(),xm=ws(),l1=$a(),c1=Cu(),Iu="Block collections are not allowed within flow collections",Ru=t=>t&&(t.type==="block-map"||t.type==="block-seq");function u1({composeNode:t,composeEmptyNode:e},n,r,i,s){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=s?.nodeClass??(o?vm.YAMLMap:o1.YAMLSeq),c=new l(n.schema);c.flow=!0;let u=n.atRoot;u&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let f=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let y=r.items[g],{start:$,key:b,sep:k,value:w}=y,v=xm.resolveProps($,{flow:a,indicator:"explicit-key-ind",next:b??k?.[0],offset:f,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!v.found){if(!v.anchor&&!v.tag&&!k&&!w){g===0&&v.comma?i(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<r.items.length-1&&i(v.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),v.comment&&(c.comment?c.comment+=`
66
+ `+v.comment:c.comment=v.comment),f=v.end;continue}!o&&n.options.strict&&l1.containsNewline(b)&&i(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)v.comma&&i(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(v.comma||i(v.start,"MISSING_CHAR",`Missing , between ${a} items`),v.comment){let D="";e:for(let I of $)switch(I.type){case"comma":case"space":break;case"comment":D=I.source.substring(1);break e;default:break e}if(D){let I=c.items[c.items.length-1];i1.isPair(I)&&(I=I.value??I.key),I.comment?I.comment+=`
67
+ `+D:I.comment=D,v.comment=v.comment.substring(D.length+1)}}if(!o&&!k&&!v.found){let D=w?t(n,w,v,i):e(n,v.end,k,null,v,i);c.items.push(D),f=D.range[2],Ru(w)&&i(D.range,"BLOCK_IN_FLOW",Iu)}else{n.atKey=!0;let D=v.end,I=b?t(n,b,v,i):e(n,D,$,null,v,i);Ru(b)&&i(I.range,"BLOCK_IN_FLOW",Iu),n.atKey=!1;let L=xm.resolveProps(k??[],{flow:a,indicator:"map-value-ind",next:w,offset:I.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(L.found){if(!o&&!v.found&&n.options.strict){if(k)for(let R of k){if(R===L.found)break;if(R.type==="newline"){i(R,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}v.start<L.found.offset-1024&&i(L.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else w&&("source"in w&&w.source&&w.source[0]===":"?i(w,"MISSING_CHAR",`Missing space after : in ${a}`):i(L.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let T=w?t(n,w,L,i):L.found?e(n,L.end,k,null,L,i):null;T?Ru(w)&&i(T.range,"BLOCK_IN_FLOW",Iu):L.comment&&(I.comment?I.comment+=`
68
+ `+L.comment:I.comment=L.comment);let G=new s1.Pair(I,T);if(n.options.keepSourceTokens&&(G.srcToken=y),o){let R=c;c1.mapIncludes(n,R.items,I)&&i(D,"DUPLICATE_KEY","Map keys must be unique"),R.items.push(G)}else{let R=new vm.YAMLMap(n.schema);R.flow=!0,R.items.push(G);let j=(T??I).range;R.range=[I.range[0],j[1],j[2]],c.items.push(R)}f=T?T.range[2]:L.end}}let p=o?"}":"]",[h,...d]=r.end,m=f;if(h&&h.source===p)m=h.offset+h.source.length;else{let g=a[0].toUpperCase()+a.substring(1),y=u?`${g} must end with a ${p}`:`${g} in block collection must be sufficiently indented and end with a ${p}`;i(f,u?"MISSING_CHAR":"BAD_INDENT",y),h&&h.source.length!==1&&d.unshift(h)}if(d.length>0){let g=a1.resolveEnd(d,m,n.options.strict,i);g.comment&&(c.comment?c.comment+=`
69
+ `+g.comment:c.comment=g.comment),c.range=[r.offset,m,g.offset]}else c.range=[r.offset,m,m];return c}Em.resolveFlowCollection=u1});var Tm=V(Am=>{"use strict";var f1=ye(),p1=qe(),h1=Wn(),d1=Hn(),m1=km(),g1=wm(),y1=Sm();function Ou(t,e,n,r,i,s){let o=n.type==="block-map"?m1.resolveBlockMap(t,e,n,r,s):n.type==="block-seq"?g1.resolveBlockSeq(t,e,n,r,s):y1.resolveFlowCollection(t,e,n,r,s),a=o.constructor;return i==="!"||i===a.tagName?(o.tag=a.tagName,o):(i&&(o.tag=i),o)}function k1(t,e,n,r,i){let s=r.tag,o=s?e.directives.tagName(s.source,p=>i(s,"TAG_RESOLVE_FAILED",p)):null;if(n.type==="block-seq"){let{anchor:p,newlineAfterProp:h}=r,d=p&&s?p.offset>s.offset?p:s:p??s;d&&(!h||h.offset<d.offset)&&i(d,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!s||!o||o==="!"||o===h1.YAMLMap.tagName&&a==="map"||o===d1.YAMLSeq.tagName&&a==="seq")return Ou(t,e,n,i,o);let l=e.schema.tags.find(p=>p.tag===o&&p.collection===a);if(!l){let p=e.schema.knownTags[o];if(p&&p.collection===a)e.schema.tags.push(Object.assign({},p,{default:!1})),l=p;else return p?.collection?i(s,"BAD_COLLECTION_TYPE",`${p.tag} used for ${a} collection, but expects ${p.collection}`,!0):i(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Ou(t,e,n,i,o)}let c=Ou(t,e,n,i,o,l),u=l.resolve?.(c,p=>i(s,"TAG_RESOLVE_FAILED",p),e.options)??c,f=f1.isNode(u)?u:new p1.Scalar(u);return f.range=c.range,f.tag=o,l?.format&&(f.format=l.format),f}Am.composeCollection=k1});var Lu=V(Dm=>{"use strict";var Mu=qe();function b1(t,e,n){let r=e.offset,i=w1(e,t.options.strict,n);if(!i)return{value:"",type:null,comment:"",range:[r,r,r]};let s=i.mode===">"?Mu.Scalar.BLOCK_FOLDED:Mu.Scalar.BLOCK_LITERAL,o=e.source?$1(e.source):[],a=o.length;for(let m=o.length-1;m>=0;--m){let g=o[m][1];if(g===""||g==="\r")a=m;else break}if(a===0){let m=i.chomp==="+"&&o.length>0?`
70
+ `.repeat(Math.max(1,o.length-1)):"",g=r+i.length;return e.source&&(g+=e.source.length),{value:m,type:s,comment:i.comment,range:[r,g,g]}}let l=e.indent+i.indent,c=e.offset+i.length,u=0;for(let m=0;m<a;++m){let[g,y]=o[m];if(y===""||y==="\r")i.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&n(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),i.indent===0&&(l=g.length),u=m,l===0&&!t.atRoot&&n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+y.length+1}for(let m=o.length-1;m>=a;--m)o[m][0].length>l&&(a=m+1);let f="",p="",h=!1;for(let m=0;m<u;++m)f+=o[m][0].slice(l)+`
71
+ `;for(let m=u;m<a;++m){let[g,y]=o[m];c+=g.length+y.length+1;let $=y[y.length-1]==="\r";if($&&(y=y.slice(0,-1)),y&&g.length<l){let k=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;n(c-y.length-($?2:1),"BAD_INDENT",k),g=""}s===Mu.Scalar.BLOCK_LITERAL?(f+=p+g.slice(l)+y,p=`
72
+ `):g.length>l||y[0]===" "?(p===" "?p=`
73
+ `:!h&&p===`
74
+ `&&(p=`
75
+
76
+ `),f+=p+g.slice(l)+y,p=`
77
+ `,h=!0):y===""?p===`
78
+ `?f+=`
79
+ `:p=`
80
+ `:(f+=p+y,p=" ",h=!1)}switch(i.chomp){case"-":break;case"+":for(let m=a;m<o.length;++m)f+=`
81
+ `+o[m][0].slice(l);f[f.length-1]!==`
82
+ `&&(f+=`
83
+ `);break;default:f+=`
84
+ `}let d=r+i.length+e.source.length;return{value:f,type:s,comment:i.comment,range:[r,d,d]}}function w1({offset:t,props:e},n,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:i}=e[0],s=i[0],o=0,a="",l=-1;for(let p=1;p<i.length;++p){let h=i[p];if(!a&&(h==="-"||h==="+"))a=h;else{let d=Number(h);!o&&d?o=d:l===-1&&(l=t+p)}}l!==-1&&r(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,u="",f=i.length;for(let p=1;p<e.length;++p){let h=e[p];switch(h.type){case"space":c=!0;case"newline":f+=h.source.length;break;case"comment":n&&!c&&r(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=h.source.length,u=h.source.substring(1);break;case"error":r(h,"UNEXPECTED_TOKEN",h.message),f+=h.source.length;break;default:{let d=`Unexpected token in block scalar header: ${h.type}`;r(h,"UNEXPECTED_TOKEN",d);let m=h.source;m&&typeof m=="string"&&(f+=m.length)}}}return{mode:s,indent:o,chomp:a,comment:u,length:f}}function $1(t){let e=t.split(/\n( *)/),n=e[0],r=n.match(/^( *)/),s=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let o=1;o<e.length;o+=2)s.push([e[o],e[o+1]]);return s}Dm.resolveBlockScalar=b1});var Pu=V(Cm=>{"use strict";var ju=qe(),v1=ni();function x1(t,e,n){let{offset:r,type:i,source:s,end:o}=t,a,l,c=(p,h,d)=>n(r+p,h,d);switch(i){case"scalar":a=ju.Scalar.PLAIN,l=E1(s,c);break;case"single-quoted-scalar":a=ju.Scalar.QUOTE_SINGLE,l=S1(s,c);break;case"double-quoted-scalar":a=ju.Scalar.QUOTE_DOUBLE,l=A1(s,c);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[r,r+s.length,r+s.length]}}let u=r+s.length,f=v1.resolveEnd(o,u,e,n);return{value:l,type:a,comment:f.comment,range:[r,u,f.offset]}}function E1(t,e){let n="";switch(t[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),Nm(t)}function S1(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Nm(t.slice(1,-1)).replace(/''/g,"'")}function Nm(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
85
+ `,"sy"),n=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
86
+ `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(t);if(!r)return t;let i=r[1],s=" ",o=e.lastIndex;for(n.lastIndex=o;r=n.exec(t);)r[1]===""?s===`
87
+ `?i+=s:s=`
88
+ `:(i+=s+r[1],s=" "),o=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,r=a.exec(t),i+s+(r?.[1]??"")}function A1(t,e){let n="";for(let r=1;r<t.length-1;++r){let i=t[r];if(!(i==="\r"&&t[r+1]===`
89
+ `))if(i===`
90
+ `){let{fold:s,offset:o}=T1(t,r);n+=s,r=o}else if(i==="\\"){let s=t[++r],o=D1[s];if(o)n+=o;else if(s===`
91
+ `)for(s=t[r+1];s===" "||s===" ";)s=t[++r+1];else if(s==="\r"&&t[r+1]===`
92
+ `)for(s=t[++r+1];s===" "||s===" ";)s=t[++r+1];else if(s==="x"||s==="u"||s==="U"){let a={x:2,u:4,U:8}[s];n+=N1(t,r+1,a,e),r+=a}else{let a=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(i===" "||i===" "){let s=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
93
+ `&&!(o==="\r"&&t[r+2]===`
94
+ `)&&(n+=r>s?t.slice(s,r+1):i)}else n+=i}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function T1(t,e){let n="",r=t[e+1];for(;(r===" "||r===" "||r===`
95
+ `||r==="\r")&&!(r==="\r"&&t[e+2]!==`
96
+ `);)r===`
97
+ `&&(n+=`
98
+ `),e+=1,r=t[e+1];return n||(n=" "),{fold:n,offset:e}}var D1={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
+ `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function N1(t,e,n,r){let i=t.substr(e,n),o=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(o)){let a=t.substr(e-2,n+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}Cm.resolveFlowScalar=x1});var Om=V(Rm=>{"use strict";var kr=ye(),Im=qe(),C1=Lu(),I1=Pu();function R1(t,e,n,r){let{value:i,type:s,comment:o,range:a}=e.type==="block-scalar"?C1.resolveBlockScalar(t,e,r):I1.resolveFlowScalar(e,t.options.strict,r),l=n?t.directives.tagName(n.source,f=>r(n,"TAG_RESOLVE_FAILED",f)):null,c;t.options.stringKeys&&t.atKey?c=t.schema[kr.SCALAR]:l?c=O1(t.schema,i,l,n,r):e.type==="scalar"?c=M1(t,i,e,r):c=t.schema[kr.SCALAR];let u;try{let f=c.resolve(i,p=>r(n??e,"TAG_RESOLVE_FAILED",p),t.options);u=kr.isScalar(f)?f:new Im.Scalar(f)}catch(f){let p=f instanceof Error?f.message:String(f);r(n??e,"TAG_RESOLVE_FAILED",p),u=new Im.Scalar(i)}return u.range=a,u.source=i,s&&(u.type=s),l&&(u.tag=l),c.format&&(u.format=c.format),o&&(u.comment=o),u}function O1(t,e,n,r,i){if(n==="!")return t[kr.SCALAR];let s=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)s.push(a);else return a;for(let a of s)if(a.test?.test(e))return a;let o=t.knownTags[n];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[kr.SCALAR])}function M1({atKey:t,directives:e,schema:n},r,i,s){let o=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(r))||n[kr.SCALAR];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(r))??n[kr.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),u=`Value may be parsed as either ${l} or ${c}`;s(i,"TAG_RESOLVE_FAILED",u,!0)}}return o}Rm.composeScalar=R1});var Lm=V(Mm=>{"use strict";function L1(t,e,n){if(e){n===null&&(n=e.length);for(let r=n-1;r>=0;--r){let i=e[r];switch(i.type){case"space":case"comment":case"newline":t-=i.source.length;continue}for(i=e[++r];i?.type==="space";)t+=i.source.length,i=e[++r];break}}return t}Mm.emptyScalarPosition=L1});var _m=V(qu=>{"use strict";var j1=es(),P1=ye(),_1=Tm(),jm=Om(),q1=ni(),F1=Lm(),B1={composeNode:Pm,composeEmptyNode:_u};function Pm(t,e,n,r){let i=t.atKey,{spaceBefore:s,comment:o,anchor:a,tag:l}=n,c,u=!0;switch(e.type){case"alias":c=V1(t,e,r),(a||l)&&r(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=jm.composeScalar(t,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=_1.composeCollection(B1,t,e,n,r),a&&(c.anchor=a.source.substring(1));break;default:{let f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",f),c=_u(t,e.offset,void 0,null,n,r),u=!1}}return a&&c.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),i&&t.options.stringKeys&&(!P1.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&r(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),s&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),t.options.keepSourceTokens&&u&&(c.srcToken=e),c}function _u(t,e,n,r,{spaceBefore:i,comment:s,anchor:o,tag:a,end:l},c){let u={type:"scalar",offset:F1.emptyScalarPosition(e,n,r),indent:-1,source:""},f=jm.composeScalar(t,u,a,c);return o&&(f.anchor=o.source.substring(1),f.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(f.spaceBefore=!0),s&&(f.comment=s,f.range[2]=l),f}function V1({options:t},{offset:e,source:n,end:r},i){let s=new j1.Alias(n.substring(1));s.source===""&&i(e,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&i(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+n.length,a=q1.resolveEnd(r,o,t.strict,i);return s.range=[e,o,a.offset],a.comment&&(s.comment=a.comment),s}qu.composeEmptyNode=_u;qu.composeNode=Pm});var Bm=V(Fm=>{"use strict";var z1=gs(),qm=_m(),U1=ni(),W1=ws();function H1(t,e,{offset:n,start:r,value:i,end:s},o){let a=Object.assign({_directives:e},t),l=new z1.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=W1.resolveProps(r,{indicator:"doc-start",next:i??s?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(l.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=i?qm.composeNode(c,i,u,o):qm.composeEmptyNode(c,u.end,r,null,u,o);let f=l.contents.range[2],p=U1.resolveEnd(s,f,!1,o);return p.comment&&(l.comment=p.comment),l.range=[n,f,p.offset],l}Fm.composeDoc=H1});var Bu=V(Um=>{"use strict";var G1=Ac(),K1=gs(),$s=bs(),Vm=ye(),Y1=Bm(),J1=ni();function vs(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function zm(t){let e="",n=!1,r=!1;for(let i=0;i<t.length;++i){let s=t[i];switch(s[0]){case"#":e+=(e===""?"":r?`
100
+
101
+ `:`
102
+ `)+(s.substring(1)||" "),n=!0,r=!1;break;case"%":t[i+1]?.[0]!=="#"&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var Fu=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,i,s)=>{let o=vs(n);s?this.warnings.push(new $s.YAMLWarning(o,r,i)):this.errors.push(new $s.YAMLParseError(o,r,i))},this.directives=new G1.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:i}=zm(this.prelude);if(r){let s=e.contents;if(n)e.comment=e.comment?`${e.comment}
103
+ ${r}`:r;else if(i||e.directives.docStart||!s)e.commentBefore=r;else if(Vm.isCollection(s)&&!s.flow&&s.items.length>0){let o=s.items[0];Vm.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${r}
104
+ ${a}`:r}else{let o=s.commentBefore;s.commentBefore=o?`${r}
105
+ ${o}`:r}}n?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:zm(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,r=-1){for(let i of e)yield*this.next(i);yield*this.end(n,r)}*next(e){switch(process.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,i)=>{let s=vs(e);s[0]+=n,this.onError(s,"BAD_DIRECTIVE",r,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=Y1.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new $s.YAMLParseError(vs(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new $s.YAMLParseError(vs(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=J1.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
106
+ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new $s.YAMLParseError(vs(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),i=new K1.Document(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),i.range=[0,n,n],this.decorate(i,!1),yield i}}};Um.Composer=Fu});var Gm=V(va=>{"use strict";var Z1=Lu(),Q1=Pu(),X1=bs(),Wm=ss();function e2(t,e=!0,n){if(t){let r=(i,s,o)=>{let a=typeof i=="number"?i:Array.isArray(i)?i[0]:i.offset;if(n)n(a,s,o);else throw new X1.YAMLParseError([a,a+1],s,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Q1.resolveFlowScalar(t,e,r);case"block-scalar":return Z1.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function t2(t,e){let{implicitKey:n=!1,indent:r,inFlow:i=!1,offset:s=-1,type:o="PLAIN"}=e,a=Wm.stringifyString({type:o,value:t},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),l=e.end??[{type:"newline",offset:-1,indent:r,source:`
107
+ `}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
108
+ `),u=a.substring(0,c),f=a.substring(c+1)+`
109
+ `,p=[{type:"block-scalar-header",offset:s,indent:r,source:u}];return Hm(p,l)||p.push({type:"newline",offset:-1,indent:r,source:`
110
+ `}),{type:"block-scalar",offset:s,indent:r,props:p,source:f}}case'"':return{type:"double-quoted-scalar",offset:s,indent:r,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:s,indent:r,source:a,end:l};default:return{type:"scalar",offset:s,indent:r,source:a,end:l}}}function n2(t,e,n={}){let{afterKey:r=!1,implicitKey:i=!1,inFlow:s=!1,type:o}=n,a="indent"in t?t.indent:null;if(r&&typeof a=="number"&&(a+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=t.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=Wm.stringifyString({type:o,value:e},{implicitKey:i||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":r2(t,l);break;case'"':Vu(t,l,"double-quoted-scalar");break;case"'":Vu(t,l,"single-quoted-scalar");break;default:Vu(t,l,"scalar")}}function r2(t,e){let n=e.indexOf(`
111
+ `),r=e.substring(0,n),i=e.substring(n+1)+`
112
+ `;if(t.type==="block-scalar"){let s=t.props[0];if(s.type!=="block-scalar-header")throw new Error("Invalid block scalar header");s.source=r,t.source=i}else{let{offset:s}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:s,indent:o,source:r}];Hm(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
113
+ `});for(let l of Object.keys(t))l!=="type"&&l!=="offset"&&delete t[l];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:i})}}function Hm(t,e){if(e)for(let n of e)switch(n.type){case"space":case"comment":t.push(n);break;case"newline":return t.push(n),!0}return!1}function Vu(t,e,n){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=n,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),i=e.length;t.props[0].type==="block-scalar-header"&&(i-=t.props[0].source.length);for(let s of r)s.offset+=i;delete t.props,Object.assign(t,{type:n,source:e,end:r});break}case"block-map":case"block-seq":{let i={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
114
+ `};delete t.items,Object.assign(t,{type:n,source:e,end:[i]});break}default:{let r="indent"in t?t.indent:-1,i="end"in t&&Array.isArray(t.end)?t.end.filter(s=>s.type==="space"||s.type==="comment"||s.type==="newline"):[];for(let s of Object.keys(t))s!=="type"&&s!=="offset"&&delete t[s];Object.assign(t,{type:n,indent:r,source:e,end:i})}}}va.createScalarToken=t2;va.resolveAsScalar=e2;va.setScalarValue=n2});var Ym=V(Km=>{"use strict";var i2=t=>"type"in t?Ea(t):xa(t);function Ea(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=Ea(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=xa(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=xa(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=xa(t);if(t.end)for(let n of t.end)e+=n.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let n of t.end)e+=n.source;return e}}}function xa({start:t,key:e,sep:n,value:r}){let i="";for(let s of t)i+=s.source;if(e&&(i+=Ea(e)),n)for(let s of n)i+=s.source;return r&&(i+=Ea(r)),i}Km.stringify=i2});var Xm=V(Qm=>{"use strict";var zu=Symbol("break visit"),s2=Symbol("skip children"),Jm=Symbol("remove item");function br(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Zm(Object.freeze([]),t,e)}br.BREAK=zu;br.SKIP=s2;br.REMOVE=Jm;br.itemAtPath=(t,e)=>{let n=t;for(let[r,i]of e){let s=n?.[r];if(s&&"items"in s)n=s.items[i];else return}return n};br.parentCollection=(t,e)=>{let n=br.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],i=n?.[r];if(i&&"items"in i)return i;throw new Error("Parent collection not found")};function Zm(t,e,n){let r=n(e,t);if(typeof r=="symbol")return r;for(let i of["key","value"]){let s=e[i];if(s&&"items"in s){for(let o=0;o<s.items.length;++o){let a=Zm(Object.freeze(t.concat([[i,o]])),s.items[o],n);if(typeof a=="number")o=a-1;else{if(a===zu)return zu;a===Jm&&(s.items.splice(o,1),o-=1)}}typeof r=="function"&&i==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Qm.visit=br});var Sa=V(dt=>{"use strict";var Uu=Gm(),o2=Ym(),a2=Xm(),Wu="\uFEFF",Hu="",Gu="",Ku="",l2=t=>!!t&&"items"in t,c2=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function u2(t){switch(t){case Wu:return"<BOM>";case Hu:return"<DOC>";case Gu:return"<FLOW_END>";case Ku:return"<SCALAR>";default:return JSON.stringify(t)}}function f2(t){switch(t){case Wu:return"byte-order-mark";case Hu:return"doc-mode";case Gu:return"flow-error-end";case Ku:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
+ `:case`\r
116
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}dt.createScalarToken=Uu.createScalarToken;dt.resolveAsScalar=Uu.resolveAsScalar;dt.setScalarValue=Uu.setScalarValue;dt.stringify=o2.stringify;dt.visit=a2.visit;dt.BOM=Wu;dt.DOCUMENT=Hu;dt.FLOW_END=Gu;dt.SCALAR=Ku;dt.isCollection=l2;dt.isScalar=c2;dt.prettyToken=u2;dt.tokenType=f2});var Zu=V(tg=>{"use strict";var xs=Sa();function zt(t){switch(t){case void 0:case" ":case`
117
+ `:case"\r":case" ":return!0;default:return!1}}var eg=new Set("0123456789ABCDEFabcdef"),p2=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Aa=new Set(",[]{}"),h2=new Set(` ,[]{}
118
+ \r `),Yu=t=>!t||h2.has(t),Ju=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
119
+ `?!0:n==="\r"?this.buffer[e+1]===`
120
+ `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let n=this.buffer[e];if(this.indentNext>0){let r=0;for(;n===" ";)n=this.buffer[++r+e];if(n==="\r"){let i=this.buffer[r+e+1];if(i===`
121
+ `||!i&&!this.atEnd)return e+r+1}return n===`
122
+ `||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&zt(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
123
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===xs.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,r=e.indexOf("#");for(;r!==-1;){let s=e[r-1];if(s===" "||s===" "){n=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let s=e[n-1];if(s===" "||s===" ")n-=1;else break}let i=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-i),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield xs.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&zt(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!zt(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&zt(n)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Yu),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,r=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let i=this.getLine();if(i===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&i[0]!=="#"||r===0&&(i.startsWith("---")||i.startsWith("..."))&&zt(i[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield xs.FLOW_END,yield*this.parseLineStart();let s=0;for(;i[s]===",";)s+=yield*this.pushCount(1),s+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(s+=yield*this.pushIndicators(),i[s]){case void 0:return"flow";case"#":return yield*this.pushCount(i.length-s),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Yu),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||zt(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let s=0;for(;this.buffer[n-1-s]==="\\";)s+=1;if(s%2===0)break;n=this.buffer.indexOf('"',n+1)}let r=this.buffer.substring(0,n),i=r.indexOf(`
124
+ `,this.pos);if(i!==-1){for(;i!==-1;){let s=this.continueScalar(i+1);if(s===-1)break;i=r.indexOf(`
125
+ `,s)}i!==-1&&(n=i-(r[i-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>zt(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,r;e:for(let s=this.pos;r=this.buffer[s];++s)switch(r){case" ":n+=1;break;case`
126
+ `:e=s,n=0;break;case"\r":{let o=this.buffer[s+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
127
+ `)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let s=this.continueScalar(e+1);if(s===-1)break;e=this.buffer.indexOf(`
128
+ `,s)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let i=e+1;for(r=this.buffer[i];r===" ";)r=this.buffer[++i];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
129
+ `;)r=this.buffer[++i];e=i-1}else if(!this.blockScalarKeep)do{let s=e-1,o=this.buffer[s];o==="\r"&&(o=this.buffer[--s]);let a=s;for(;o===" ";)o=this.buffer[--s];if(o===`
130
+ `&&s>=this.pos&&s+1+n>a)e=s;else break}while(!0);return yield xs.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,r=this.pos-1,i;for(;i=this.buffer[++r];)if(i===":"){let s=this.buffer[r+1];if(zt(s)||e&&Aa.has(s))break;n=r}else if(zt(i)){let s=this.buffer[r+1];if(i==="\r"&&(s===`
131
+ `?(r+=1,i=`
132
+ `,s=this.buffer[r+1]):n=r),s==="#"||e&&Aa.has(s))break;if(i===`
133
+ `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Aa.has(i))break;n=r}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield xs.SCALAR,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Yu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(zt(n)||e&&Aa.has(n))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!zt(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(p2.has(n))n=this.buffer[++e];else if(n==="%"&&eg.has(this.buffer[e+1])&&eg.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
134
+ `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
135
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let i=n-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=n),i}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};tg.Lexer=Ju});var Xu=V(ng=>{"use strict";var Qu=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,r=this.lineStarts.length;for(;n<r;){let s=n+r>>1;this.lineStarts[s]<e?n=s+1:r=s}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let i=this.lineStarts[n-1];return{line:n,col:e-i+1}}}};ng.LineCounter=Qu});var tf=V(ag=>{"use strict";var rg=Sa(),d2=Zu();function wr(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function ig(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function og(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Ta(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function ri(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function sg(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!wr(e.start,"explicit-key-ind")&&!wr(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,og(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}var ef=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new d2.Lexer,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,n))yield*this.next(r);n||(yield*this.end())}*next(e){if(this.source=e,process.env.LOG_TOKENS&&console.log("|",rg.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=rg.tokenType(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&(!e||e.type!=="doc-end")){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let r=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in r?r.indent:0:n.type==="flow-collection"&&r.type==="document"&&(n.indent=0),n.type==="flow-collection"&&sg(n),r.type){case"document":r.value=n;break;case"block-scalar":r.props.push(n);break;case"block-map":{let i=r.items[r.items.length-1];if(i.value){r.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=n;else{Object.assign(i,{key:n,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{let i=r.items[r.items.length-1];i.value?r.items.push({start:[],value:n}):i.value=n;break}case"flow-collection":{let i=r.items[r.items.length-1];!i||i.value?r.items.push({start:[],key:n,sep:[]}):i.sep?i.value=n:Object.assign(i,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let i=n.items[n.items.length-1];i&&!i.sep&&!i.value&&i.start.length>0&&ig(i.start)===-1&&(n.indent===0||i.start.every(s=>s.type!=="comment"||s.indent<n.indent))&&(r.type==="document"?r.end=i.start:r.items.push({start:i.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{ig(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=Ta(this.peek(2)),r=ri(n),i;e.end?(i=e.end,i.push(this.sourceToken),delete e.end):i=[this.sourceToken];let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
136
+ `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
137
+ `,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,n.start),i.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,i=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",s=[];if(i&&n.sep&&!n.value){let o=[];for(let a=0;a<n.sep.length;++a){let l=n.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(s=n.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":i||n.value?(s.push(this.sourceToken),e.items.push({start:s}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):i||n.value?(s.push(this.sourceToken),e.items.push({start:s,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(wr(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});else if(og(n.key)&&!wr(n.sep,"newline")){let o=ri(n.start),a=n.key,l=n.sep;l.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else s.length>0?n.sep=n.sep.concat(s,this.sourceToken):n.sep.push(this.sourceToken);else if(wr(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=ri(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||i?e.items.push({start:s,key:null,sep:[this.sourceToken]}):wr(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);i||n.value?(e.items.push({start:s,key:o,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(o):(Object.assign(n,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){r&&o.type!=="block-seq"&&e.items.push({start:s}),this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,n.start),i.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||wr(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r&&r.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:i,sep:[]}):n.sep?this.stack.push(i):Object.assign(n,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let i=Ta(r),s=ri(i);sg(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
138
+ `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
139
+ `,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=Ta(e),r=ri(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=Ta(e),r=ri(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};ag.Parser=ef});var pg=V(Ss=>{"use strict";var lg=Bu(),m2=gs(),Es=bs(),g2=qc(),y2=ye(),k2=Xu(),cg=tf();function ug(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new k2.LineCounter||null,prettyErrors:e}}function b2(t,e={}){let{lineCounter:n,prettyErrors:r}=ug(e),i=new cg.Parser(n?.addNewLine),s=new lg.Composer(e),o=Array.from(s.compose(i.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(Es.prettifyError(t,n)),a.warnings.forEach(Es.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},s.streamInfo())}function fg(t,e={}){let{lineCounter:n,prettyErrors:r}=ug(e),i=new cg.Parser(n?.addNewLine),s=new lg.Composer(e),o=null;for(let a of s.compose(i.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Es.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(Es.prettifyError(t,n)),o.warnings.forEach(Es.prettifyError(t,n))),o}function w2(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let i=fg(t,n);if(!i)return null;if(i.warnings.forEach(s=>g2.warn(i.options.logLevel,s)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function $2(t,e,n){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let i=Math.round(n);n=i<1?void 0:i>8?{indent:8}:{indent:i}}if(t===void 0){let{keepUndefined:i}=n??e??{};if(!i)return}return y2.isDocument(t)&&!r?t.toString(n):new m2.Document(t,r,n).toString(n)}Ss.parse=w2;Ss.parseAllDocuments=b2;Ss.parseDocument=fg;Ss.stringify=$2});var As=V(ve=>{"use strict";var v2=Bu(),x2=gs(),E2=$u(),nf=bs(),S2=es(),Gn=ye(),A2=zn(),T2=qe(),D2=Wn(),N2=Hn(),C2=Sa(),I2=Zu(),R2=Xu(),O2=tf(),Da=pg(),hg=Ji();ve.Composer=v2.Composer;ve.Document=x2.Document;ve.Schema=E2.Schema;ve.YAMLError=nf.YAMLError;ve.YAMLParseError=nf.YAMLParseError;ve.YAMLWarning=nf.YAMLWarning;ve.Alias=S2.Alias;ve.isAlias=Gn.isAlias;ve.isCollection=Gn.isCollection;ve.isDocument=Gn.isDocument;ve.isMap=Gn.isMap;ve.isNode=Gn.isNode;ve.isPair=Gn.isPair;ve.isScalar=Gn.isScalar;ve.isSeq=Gn.isSeq;ve.Pair=A2.Pair;ve.Scalar=T2.Scalar;ve.YAMLMap=D2.YAMLMap;ve.YAMLSeq=N2.YAMLSeq;ve.CST=C2;ve.Lexer=I2.Lexer;ve.LineCounter=R2.LineCounter;ve.Parser=O2.Parser;ve.parse=Da.parse;ve.parseAllDocuments=Da.parseAllDocuments;ve.parseDocument=Da.parseDocument;ve.stringify=Da.stringify;ve.visit=hg.visit;ve.visitAsync=hg.visitAsync});var xr=V(tt=>{"use strict";function nE(t,e,n){if(n===void 0&&(n=Array.prototype),t&&typeof n.find=="function")return n.find.call(t,e);for(var r=0;r<t.length;r++)if(vr(t,r)){var i=t[r];if(e.call(void 0,i,r,t))return i}}function ci(t,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(t=e.create(null,e.getOwnPropertyDescriptors(t))),e&&typeof e.freeze=="function"?e.freeze(t):t}function vr(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function rE(t,e){if(t===null||typeof t!="object")throw new TypeError("target is not an object");for(var n in e)vr(e,n)&&(t[n]=e[n]);return t}var Rg=ci({allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,default:!0,defer:!0,disabled:!0,formnovalidate:!0,hidden:!0,ismap:!0,itemscope:!0,loop:!0,multiple:!0,muted:!0,nomodule:!0,novalidate:!0,open:!0,playsinline:!0,readonly:!0,required:!0,reversed:!0,selected:!0});function iE(t){return vr(Rg,t.toLowerCase())}var Og=ci({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function sE(t){return vr(Og,t.toLowerCase())}var Is=ci({script:!1,style:!1,textarea:!0,title:!0});function oE(t){var e=t.toLowerCase();return vr(Is,e)&&!Is[e]}function aE(t){var e=t.toLowerCase();return vr(Is,e)&&Is[e]}function Mg(t){return t===Rs.HTML}function lE(t){return Mg(t)||t===Rs.XML_XHTML_APPLICATION}var Rs=ci({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),cE=Object.keys(Rs).map(function(t){return Rs[t]});function uE(t){return cE.indexOf(t)>-1}var fE=ci({HTML:"http://www.w3.org/1999/xhtml",SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});tt.assign=rE;tt.find=nE;tt.freeze=ci;tt.HTML_BOOLEAN_ATTRIBUTES=Rg;tt.HTML_RAW_TEXT_ELEMENTS=Is;tt.HTML_VOID_ELEMENTS=Og;tt.hasDefaultHTMLNamespace=lE;tt.hasOwn=vr;tt.isHTMLBooleanAttribute=iE;tt.isHTMLRawTextElement=oE;tt.isHTMLEscapableRawTextElement=aE;tt.isHTMLMimeType=Mg;tt.isHTMLVoidElement=sE;tt.isValidMimeType=uE;tt.MIME_TYPE=Rs;tt.NAMESPACE=fE});var Ps=V(js=>{"use strict";var pE=xr();function jg(t,e){t.prototype=Object.create(Error.prototype,{constructor:{value:t},name:{value:t.name,enumerable:!0,writable:e}})}var Ms=pE.freeze({Error:"Error",IndexSizeError:"IndexSizeError",DomstringSizeError:"DomstringSizeError",HierarchyRequestError:"HierarchyRequestError",WrongDocumentError:"WrongDocumentError",InvalidCharacterError:"InvalidCharacterError",NoDataAllowedError:"NoDataAllowedError",NoModificationAllowedError:"NoModificationAllowedError",NotFoundError:"NotFoundError",NotSupportedError:"NotSupportedError",InUseAttributeError:"InUseAttributeError",InvalidStateError:"InvalidStateError",SyntaxError:"SyntaxError",InvalidModificationError:"InvalidModificationError",NamespaceError:"NamespaceError",InvalidAccessError:"InvalidAccessError",ValidationError:"ValidationError",TypeMismatchError:"TypeMismatchError",SecurityError:"SecurityError",NetworkError:"NetworkError",AbortError:"AbortError",URLMismatchError:"URLMismatchError",QuotaExceededError:"QuotaExceededError",TimeoutError:"TimeoutError",InvalidNodeTypeError:"InvalidNodeTypeError",DataCloneError:"DataCloneError",EncodingError:"EncodingError",NotReadableError:"NotReadableError",UnknownError:"UnknownError",ConstraintError:"ConstraintError",DataError:"DataError",TransactionInactiveError:"TransactionInactiveError",ReadOnlyError:"ReadOnlyError",VersionError:"VersionError",OperationError:"OperationError",NotAllowedError:"NotAllowedError",OptOutError:"OptOutError"}),Pg=Object.keys(Ms);function _g(t){return typeof t=="number"&&t>=1&&t<=25}function hE(t){return typeof t=="string"&&t.substring(t.length-Ms.Error.length)===Ms.Error}function Ls(t,e){_g(t)?(this.name=Pg[t],this.message=e||""):(this.message=t,this.name=hE(e)?e:Ms.Error),Error.captureStackTrace&&Error.captureStackTrace(this,Ls)}jg(Ls,!0);Object.defineProperties(Ls.prototype,{code:{enumerable:!0,get:function(){var t=Pg.indexOf(this.name);return _g(t)?t:0}}});var qg={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25},bf=Object.entries(qg);for(Os=0;Os<bf.length;Os++)Lg=bf[Os][0],Ls[Lg]=bf[Os][1];var Lg,Os;function wf(t,e){this.message=t,this.locator=e,Error.captureStackTrace&&Error.captureStackTrace(this,wf)}jg(wf);js.DOMException=Ls;js.DOMExceptionName=Ms;js.ExceptionCode=qg;js.ParseError=wf});var Tf=V(oe=>{"use strict";function Hg(t){try{typeof t!="function"&&(t=RegExp);var e=new t("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var Vs=Hg();function Er(t){if(t.source[0]!=="[")throw new Error(t+" can not be used with chars");return t.source.slice(1,t.source.lastIndexOf("]"))}function ui(t,e){if(t.source[0]!=="[")throw new Error("/"+t.source+"/ can not be used with chars_without");if(!e||typeof e!="string")throw new Error(JSON.stringify(e)+" is not a valid search");if(t.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+t.source+"/");if(e==="-"&&t.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+t.source+"/");return new RegExp(t.source.replace(e,""),Vs?"u":"")}function he(t){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(n){var r=typeof n=="string";if(r&&e===void 0&&n==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return r?n:n.source}).join(""),Vs?"mu":"m")}function ee(t){if(arguments.length===0)throw new Error("no parameters provided");return he.apply(ee,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var dE="\uFFFD",Sr=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;Vs&&(Sr=he("[",Er(Sr),"\\u{10000}-\\u{10FFFF}","]"));var vf=/[\x20\x09\x0D\x0A]/,mE=Er(vf),xe=he(vf,"+"),Re=he(vf,"*"),_s=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;Vs&&(_s=he("[",Er(_s),"\\u{10000}-\\u{10FFFF}","]"));var gE=Er(_s),xf=he("[",gE,Er(/[-.0-9\xB7]/),Er(/[\u0300-\u036F\u203F-\u2040]/),"]"),It=he(_s,xf,"*"),Fg=he(xf,"+"),yE=he("&",It,";"),kE=ee(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),qs=ee(yE,"|",kE),Fs=he("%",It,";"),Ef=ee(he('"',ee(/[^%&"]/,"|",Fs,"|",qs),"*",'"'),"|",he("'",ee(/[^%&']/,"|",Fs,"|",qs),"*","'")),bE=ee('"',ee(/[^<&"]/,"|",qs),"*",'"',"|","'",ee(/[^<&']/,"|",qs),"*","'"),wE=ui(_s,":"),$E=ui(xf,":"),Bg=he(wE,$E,"*"),zs=he(Bg,ee(":",Bg),"?"),vE=he("^",zs,"$"),xE=he("(",zs,")"),Bs=ee(/"[^"]*"|'[^']*'/),EE=he(/^<\?/,"(",It,")",ee(xe,"(",Sr,"*?)"),"?",/\?>/),Vg=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,Pa=ee('"',Vg,'*"',"|","'",ui(Vg,"'"),"*'"),Gg="<!--",Kg="-->",SE=he(Gg,ee(ui(Sr,"-"),"|",he("-",ui(Sr,"-"))),"*",Kg),zg="#PCDATA",AE=ee(he(/\(/,Re,zg,ee(Re,/\|/,Re,zs),"*",Re,/\)\*/),"|",he(/\(/,Re,zg,Re,/\)/)),TE=/[?*+]?/,DE=he(/\([^>]+\)/,TE),NE=ee("EMPTY","|","ANY","|",AE,"|",DE),CE="<!ELEMENT",IE=he(CE,xe,ee(zs,"|",Fs),xe,ee(NE,"|",Fs),Re,">"),RE=he("NOTATION",xe,/\(/,Re,It,ee(Re,/\|/,Re,It),"*",Re,/\)/),OE=he(/\(/,Re,Fg,ee(Re,/\|/,Re,Fg),"*",Re,/\)/),ME=ee(RE,"|",OE),LE=ee(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",ME),jE=ee(/#REQUIRED|#IMPLIED/,"|",ee(ee("#FIXED",xe),"?",bE)),PE=ee(xe,It,xe,LE,xe,jE),_E="<!ATTLIST",qE=he(_E,xe,It,PE,"*",Re,">"),$f="about:legacy-compat",FE=ee('"'+$f+'"',"|","'"+$f+"'"),Sf="SYSTEM",_a="PUBLIC",qa=ee(ee(Sf,xe,Bs),"|",ee(_a,xe,Pa,xe,Bs)),BE=he("^",ee(ee(Sf,xe,"(?<SystemLiteralOnly>",Bs,")"),"|",ee(_a,xe,"(?<PubidLiteral>",Pa,")",xe,"(?<SystemLiteral>",Bs,")"))),VE=ee(xe,"NDATA",xe,It),zE=ee(Ef,"|",ee(qa,VE,"?")),Yg="<!ENTITY",UE=he(Yg,xe,It,xe,zE,Re,">"),WE=ee(Ef,"|",qa),HE=he(Yg,xe,"%",xe,It,xe,WE,Re,">"),GE=ee(UE,"|",HE),KE=he(_a,xe,Pa),YE=he("<!NOTATION",xe,It,xe,ee(qa,"|",KE),Re,">"),Af=he(Re,"=",Re),Ug=/1[.]\d+/,JE=he(xe,"version",Af,ee("'",Ug,"'","|",'"',Ug,'"')),Wg=/[A-Za-z][-A-Za-z0-9._]*/,ZE=ee(xe,"encoding",Af,ee('"',Wg,'"',"|","'",Wg,"'")),QE=ee(xe,"standalone",Af,ee("'",ee("yes","|","no"),"'","|",'"',ee("yes","|","no"),'"')),XE=he(/^<\?xml/,JE,ZE,"?",QE,"?",Re,/\?>/),eS="<!DOCTYPE",tS="<![CDATA[",nS="]]>",rS=/<!\[CDATA\[/,iS=/\]\]>/,sS=he(Sr,"*?",iS),oS=he(rS,sS);oe.chars=Er;oe.chars_without=ui;oe.detectUnicodeSupport=Hg;oe.reg=he;oe.regg=ee;oe.ABOUT_LEGACY_COMPAT=$f;oe.ABOUT_LEGACY_COMPAT_SystemLiteral=FE;oe.AttlistDecl=qE;oe.CDATA_START=tS;oe.CDATA_END=nS;oe.CDSect=oS;oe.Char=Sr;oe.Comment=SE;oe.COMMENT_START=Gg;oe.COMMENT_END=Kg;oe.DOCTYPE_DECL_START=eS;oe.elementdecl=IE;oe.EntityDecl=GE;oe.EntityValue=Ef;oe.ExternalID=qa;oe.ExternalID_match=BE;oe.Name=It;oe.NotationDecl=YE;oe.Reference=qs;oe.PEReference=Fs;oe.PI=EE;oe.PUBLIC=_a;oe.PubidLiteral=Pa;oe.QName=zs;oe.QName_exact=vE;oe.QName_group=xE;oe.S=xe;oe.SChar_s=mE;oe.S_OPT=Re;oe.SYSTEM=Sf;oe.SystemLiteral=Bs;oe.UNICODE_REPLACEMENT_CHARACTER=dE;oe.UNICODE_SUPPORT=Vs;oe.XMLDecl=XE});var Of=V(je=>{"use strict";var Rt=xr(),pn=Rt.find,aS=Rt.hasDefaultHTMLNamespace,pi=Rt.hasOwn,lS=Rt.isHTMLMimeType,cS=Rt.isHTMLRawTextElement,uS=Rt.isHTMLVoidElement,Us=Rt.MIME_TYPE,hn=Rt.NAMESPACE,ut=Symbol(),ny=Ps(),X=ny.DOMException,fS=ny.DOMExceptionName,fn=Tf();function gt(t){if(t!==ut)throw new TypeError("Illegal constructor")}function pS(t){return t!==""}function hS(t){return t?t.split(/[\t\n\f\r ]+/).filter(pS):[]}function dS(t,e){return pi(t,e)||(t[e]=!0),t}function Jg(t){if(!t)return[];var e=hS(t);return Object.keys(e.reduce(dS,{}))}function mS(t){return function(e){return t&&t.indexOf(e)!==-1}}function ry(t){if(!fn.QName_exact.test(t))throw new X(X.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+t+'"')}function Nf(t,e){ry(e),t=t||null;var n=null,r=e;if(e.indexOf(":")>=0){var i=e.split(":");n=i[0],r=i[1]}if(n!==null&&t===null)throw new X(X.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(n==="xml"&&t!==Rt.NAMESPACE.XML)throw new X(X.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((n==="xmlns"||e==="xmlns")&&t!==Rt.NAMESPACE.XMLNS)throw new X(X.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(t===Rt.NAMESPACE.XMLNS&&n!=="xmlns"&&e!=="xmlns")throw new X(X.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[t,n,r]}function mi(t,e){for(var n in t)pi(t,n)&&(e[n]=t[n])}function yt(t,e){var n=t.prototype;if(!(n instanceof e)){let r=function(){};r.prototype=e.prototype,r=new r,mi(n,r),t.prototype=n=r}n.constructor!=t&&(typeof t!="function"&&console.error("unknown Class:"+t),n.constructor=t)}var kt={},Gt=kt.ELEMENT_NODE=1,hi=kt.ATTRIBUTE_NODE=2,Fa=kt.TEXT_NODE=3,iy=kt.CDATA_SECTION_NODE=4,sy=kt.ENTITY_REFERENCE_NODE=5,gS=kt.ENTITY_NODE=6,oy=kt.PROCESSING_INSTRUCTION_NODE=7,ay=kt.COMMENT_NODE=8,Hs=kt.DOCUMENT_NODE=9,ly=kt.DOCUMENT_TYPE_NODE=10,Zn=kt.DOCUMENT_FRAGMENT_NODE=11,yS=kt.NOTATION_NODE=12,Me=Rt.freeze({DOCUMENT_POSITION_DISCONNECTED:1,DOCUMENT_POSITION_PRECEDING:2,DOCUMENT_POSITION_FOLLOWING:4,DOCUMENT_POSITION_CONTAINS:8,DOCUMENT_POSITION_CONTAINED_BY:16,DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:32});function cy(t,e){if(e.length<t.length)return cy(e,t);var n=null;for(var r in t){if(t[r]!==e[r])return n;n=t[r]}return n}function Zg(t){return t.guid||(t.guid=Math.random()),t.guid}function He(){}He.prototype={length:0,item:function(t){return t>=0&&t<this.length?this[t]:null},toString:function(t){for(var e=[],n=0;n<this.length;n++)fi(this[n],e,t);return e.join("")},filter:function(t){return Array.prototype.filter.call(this,t)},indexOf:function(t){return Array.prototype.indexOf.call(this,t)}};He.prototype[Symbol.iterator]=function(){var t=this,e=0;return{next:function(){return e<t.length?{value:t[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Ar(t,e){this._node=t,this._refresh=e,Va(this)}function Va(t){var e=t._node._inc||t._node.ownerDocument._inc;if(t._inc!==e){var n=t._refresh(t._node);if($y(t,"length",n.length),!t.$$length||n.length<t.$$length)for(var r=n.length;r in t;r++)pi(t,r)&&delete t[r];mi(n,t),t._inc=e}}Ar.prototype.item=function(t){return Va(this),this[t]||null};yt(Ar,He);function di(){}function uy(t,e){for(var n=0;n<t.length;){if(t[n]===e)return n;n++}}function kS(t,e,n,r){if(r?e[uy(e,r)]=n:(e[e.length]=n,e.length++),t){n.ownerElement=t;var i=t.ownerDocument;i&&(r&&hy(i,t,r),bS(i,t,n))}}function Qg(t,e,n){var r=uy(e,n);if(r>=0){for(var i=e.length-1;r<=i;)e[r]=e[++r];if(e.length=i,t){var s=t.ownerDocument;s&&hy(s,t,n),n.ownerElement=null}}}di.prototype={length:0,item:He.prototype.item,getNamedItem:function(t){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase());for(var e=0;e<this.length;){var n=this[e];if(n.nodeName===t)return n;e++}return null},setNamedItem:function(t){var e=t.ownerElement;if(e&&e!==this._ownerElement)throw new X(X.INUSE_ATTRIBUTE_ERR);var n=this.getNamedItemNS(t.namespaceURI,t.localName);return n===t?t:(kS(this._ownerElement,this,t,n),n)},setNamedItemNS:function(t){return this.setNamedItem(t)},removeNamedItem:function(t){var e=this.getNamedItem(t);if(!e)throw new X(X.NOT_FOUND_ERR,t);return Qg(this._ownerElement,this,e),e},removeNamedItemNS:function(t,e){var n=this.getNamedItemNS(t,e);if(!n)throw new X(X.NOT_FOUND_ERR,t?t+" : "+e:e);return Qg(this._ownerElement,this,n),n},getNamedItemNS:function(t,e){t||(t=null);for(var n=0;n<this.length;){var r=this[n];if(r.localName===e&&r.namespaceURI===t)return r;n++}return null}};di.prototype[Symbol.iterator]=function(){var t=this,e=0;return{next:function(){return e<t.length?{value:t[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function fy(){}fy.prototype={hasFeature:function(t,e){return!0},createDocument:function(t,e,n){var r=Us.XML_APPLICATION;t===hn.HTML?r=Us.XML_XHTML_APPLICATION:t===hn.SVG&&(r=Us.XML_SVG_IMAGE);var i=new Qn(ut,{contentType:r});if(i.implementation=this,i.childNodes=new He,i.doctype=n||null,n&&i.appendChild(n),e){var s=i.createElementNS(t,e);i.appendChild(s)}return i},createDocumentType:function(t,e,n,r){ry(t);var i=new Wa(ut);return i.name=t,i.nodeName=t,i.publicId=e||"",i.systemId=n||"",i.internalSubset=r||"",i.childNodes=new He,i},createHTMLDocument:function(t){var e=new Qn(ut,{contentType:Us.HTML});if(e.implementation=this,e.childNodes=new He,t!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var n=e.createElement("html");e.appendChild(n);var r=e.createElement("head");if(n.appendChild(r),typeof t=="string"){var i=e.createElement("title");i.appendChild(e.createTextNode(t)),r.appendChild(i)}n.appendChild(e.createElement("body"))}return e}};function ke(t){gt(t)}ke.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,parentNode:null,get parentElement(){return this.parentNode&&this.parentNode.nodeType===this.ELEMENT_NODE?this.parentNode:null},childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,baseURI:"about:blank",get isConnected(){var t=this.getRootNode();return t&&t.nodeType===t.DOCUMENT_NODE},contains:function(t){if(!t)return!1;var e=t;do{if(this===e)return!0;e=t.parentNode}while(e);return!1},getRootNode:function(t){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(t){if(!t||this.nodeType!==t.nodeType)return!1;switch(this.nodeType){case this.DOCUMENT_TYPE_NODE:if(this.name!==t.name||this.publicId!==t.publicId||this.systemId!==t.systemId)return!1;break;case this.ELEMENT_NODE:if(this.namespaceURI!==t.namespaceURI||this.prefix!==t.prefix||this.localName!==t.localName||this.attributes.length!==t.attributes.length)return!1;for(var e=0;e<this.attributes.length;e++){var n=this.attributes.item(e);if(!n.isEqualNode(t.getAttributeNodeNS(n.namespaceURI,n.localName)))return!1}break;case this.ATTRIBUTE_NODE:if(this.namespaceURI!==t.namespaceURI||this.localName!==t.localName||this.value!==t.value)return!1;break;case this.PROCESSING_INSTRUCTION_NODE:if(this.target!==t.target||this.data!==t.data)return!1;break;case this.TEXT_NODE:case this.COMMENT_NODE:if(this.data!==t.data)return!1;break}if(this.childNodes.length!==t.childNodes.length)return!1;for(var e=0;e<this.childNodes.length;e++)if(!this.childNodes[e].isEqualNode(t.childNodes[e]))return!1;return!0},isSameNode:function(t){return this===t},insertBefore:function(t,e){return Ba(this,t,e)},replaceChild:function(t,e){Ba(this,t,e,yy),e&&this.removeChild(e)},removeChild:function(t){return my(this,t)},appendChild:function(t){return this.insertBefore(t,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(t){return Cf(this.ownerDocument||this,this,t)},normalize:function(){for(var t=this.firstChild;t;){var e=t.nextSibling;e&&e.nodeType==Fa&&t.nodeType==Fa?(this.removeChild(e),t.appendData(e.data)):(t.normalize(),t=e)}},isSupported:function(t,e){return this.ownerDocument.implementation.hasFeature(t,e)},lookupPrefix:function(t){for(var e=this;e;){var n=e._nsMap;if(n){for(var r in n)if(pi(n,r)&&n[r]===t)return r}e=e.nodeType==hi?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(t){for(var e=this;e;){var n=e._nsMap;if(n&&pi(n,t))return n[t];e=e.nodeType==hi?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(t){var e=this.lookupPrefix(t);return e==null},compareDocumentPosition:function(t){if(this===t)return 0;var e=t,n=this,r=null,i=null;if(e instanceof Tr&&(r=e,e=r.ownerElement),n instanceof Tr&&(i=n,n=i.ownerElement,r&&e&&n===e))for(var s=0,o;o=n.attributes[s];s++){if(o===r)return Me.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+Me.DOCUMENT_POSITION_PRECEDING;if(o===i)return Me.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+Me.DOCUMENT_POSITION_FOLLOWING}if(!e||!n||n.ownerDocument!==e.ownerDocument)return Me.DOCUMENT_POSITION_DISCONNECTED+Me.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(Zg(n.ownerDocument)>Zg(e.ownerDocument)?Me.DOCUMENT_POSITION_FOLLOWING:Me.DOCUMENT_POSITION_PRECEDING);if(i&&e===n)return Me.DOCUMENT_POSITION_CONTAINS+Me.DOCUMENT_POSITION_PRECEDING;if(r&&e===n)return Me.DOCUMENT_POSITION_CONTAINED_BY+Me.DOCUMENT_POSITION_FOLLOWING;for(var a=[],l=e.parentNode;l;){if(!i&&l===n)return Me.DOCUMENT_POSITION_CONTAINED_BY+Me.DOCUMENT_POSITION_FOLLOWING;a.push(l),l=l.parentNode}a.reverse();for(var c=[],u=n.parentNode;u;){if(!r&&u===e)return Me.DOCUMENT_POSITION_CONTAINS+Me.DOCUMENT_POSITION_PRECEDING;c.push(u),u=u.parentNode}c.reverse();var f=cy(a,c);for(var p in f.childNodes){var h=f.childNodes[p];if(h===n)return Me.DOCUMENT_POSITION_FOLLOWING;if(h===e)return Me.DOCUMENT_POSITION_PRECEDING;if(c.indexOf(h)>=0)return Me.DOCUMENT_POSITION_FOLLOWING;if(a.indexOf(h)>=0)return Me.DOCUMENT_POSITION_PRECEDING}return 0}};function py(t){return t=="<"&&"&lt;"||t==">"&&"&gt;"||t=="&"&&"&amp;"||t=='"'&&"&quot;"||"&#"+t.charCodeAt()+";"}mi(kt,ke);mi(kt,ke.prototype);mi(Me,ke);mi(Me,ke.prototype);function Ws(t,e){if(e(t))return!0;if(t=t.firstChild)do if(Ws(t,e))return!0;while(t=t.nextSibling)}function Qn(t,e){gt(t);var n=e||{};this.ownerDocument=this,this.contentType=n.contentType||Us.XML_APPLICATION,this.type=lS(this.contentType)?"html":"xml"}function bS(t,e,n){t&&t._inc++;var r=n.namespaceURI;r===hn.XMLNS&&(e._nsMap[n.prefix?n.localName:""]=n.value)}function hy(t,e,n,r){t&&t._inc++;var i=n.namespaceURI;i===hn.XMLNS&&delete e._nsMap[n.prefix?n.localName:""]}function dy(t,e,n){if(t&&t._inc){t._inc++;var r=e.childNodes;if(n&&!n.nextSibling)r[r.length++]=n;else{for(var i=e.firstChild,s=0;i;)r[s++]=i,i=i.nextSibling;r.length=s,delete r[r.length]}}}function my(t,e){if(t!==e.parentNode)throw new X(X.NOT_FOUND_ERR,"child's parent is not parent");var n=e.previousSibling,r=e.nextSibling;return n?n.nextSibling=r:t.firstChild=r,r?r.previousSibling=n:t.lastChild=n,dy(t.ownerDocument,t),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function wS(t){return t&&(t.nodeType===ke.DOCUMENT_NODE||t.nodeType===ke.DOCUMENT_FRAGMENT_NODE||t.nodeType===ke.ELEMENT_NODE)}function $S(t){return t&&(t.nodeType===ke.CDATA_SECTION_NODE||t.nodeType===ke.COMMENT_NODE||t.nodeType===ke.DOCUMENT_FRAGMENT_NODE||t.nodeType===ke.DOCUMENT_TYPE_NODE||t.nodeType===ke.ELEMENT_NODE||t.nodeType===ke.PROCESSING_INSTRUCTION_NODE||t.nodeType===ke.TEXT_NODE)}function Xn(t){return t&&t.nodeType===ke.DOCUMENT_TYPE_NODE}function Tn(t){return t&&t.nodeType===ke.ELEMENT_NODE}function gy(t){return t&&t.nodeType===ke.TEXT_NODE}function Xg(t,e){var n=t.childNodes||[];if(pn(n,Tn)||Xn(e))return!1;var r=pn(n,Xn);return!(e&&r&&n.indexOf(r)>n.indexOf(e))}function ey(t,e){var n=t.childNodes||[];function r(s){return Tn(s)&&s!==e}if(pn(n,r))return!1;var i=pn(n,Xn);return!(e&&i&&n.indexOf(i)>n.indexOf(e))}function vS(t,e,n){if(!wS(t))throw new X(X.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+t.nodeType);if(n&&n.parentNode!==t)throw new X(X.NOT_FOUND_ERR,"child not in parent");if(!$S(e)||Xn(e)&&t.nodeType!==ke.DOCUMENT_NODE)throw new X(X.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+t.nodeType)}function xS(t,e,n){var r=t.childNodes||[],i=e.childNodes||[];if(e.nodeType===ke.DOCUMENT_FRAGMENT_NODE){var s=i.filter(Tn);if(s.length>1||pn(i,gy))throw new X(X.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!Xg(t,n))throw new X(X.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(Tn(e)&&!Xg(t,n))throw new X(X.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(Xn(e)){if(pn(r,Xn))throw new X(X.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=pn(r,Tn);if(n&&r.indexOf(o)<r.indexOf(n))throw new X(X.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!n&&o)throw new X(X.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function yy(t,e,n){var r=t.childNodes||[],i=e.childNodes||[];if(e.nodeType===ke.DOCUMENT_FRAGMENT_NODE){var s=i.filter(Tn);if(s.length>1||pn(i,gy))throw new X(X.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!ey(t,n))throw new X(X.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(Tn(e)&&!ey(t,n))throw new X(X.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(Xn(e)){if(pn(r,function(l){return Xn(l)&&l!==n}))throw new X(X.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=pn(r,Tn);if(n&&r.indexOf(o)<r.indexOf(n))throw new X(X.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function Ba(t,e,n,r){vS(t,e,n),t.nodeType===ke.DOCUMENT_NODE&&(r||xS)(t,e,n);var i=e.parentNode;if(i&&i.removeChild(e),e.nodeType===Zn){var s=e.firstChild;if(s==null)return e;var o=e.lastChild}else s=o=e;var a=n?n.previousSibling:t.lastChild;s.previousSibling=a,o.nextSibling=n,a?a.nextSibling=s:t.firstChild=s,n==null?t.lastChild=o:n.previousSibling=o;do s.parentNode=t;while(s!==o&&(s=s.nextSibling));return dy(t.ownerDocument||t,t,e),e.nodeType==Zn&&(e.firstChild=e.lastChild=null),e}Qn.prototype={implementation:null,nodeName:"#document",nodeType:Hs,doctype:null,documentElement:null,_inc:1,insertBefore:function(t,e){if(t.nodeType===Zn){for(var n=t.firstChild;n;){var r=n.nextSibling;this.insertBefore(n,e),n=r}return t}return Ba(this,t,e),t.ownerDocument=this,this.documentElement===null&&t.nodeType===Gt&&(this.documentElement=t),t},removeChild:function(t){var e=my(this,t);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(t,e){Ba(this,t,e,yy),t.ownerDocument=this,e&&this.removeChild(e),Tn(t)&&(this.documentElement=t)},importNode:function(t,e){return wy(this,t,e)},getElementById:function(t){var e=null;return Ws(this.documentElement,function(n){if(n.nodeType==Gt&&n.getAttribute("id")==t)return e=n,!0}),e},createElement:function(t){var e=new er(ut);e.ownerDocument=this,this.type==="html"&&(t=t.toLowerCase()),aS(this.contentType)&&(e.namespaceURI=hn.HTML),e.nodeName=t,e.tagName=t,e.localName=t,e.childNodes=new He;var n=e.attributes=new di;return n._ownerElement=e,e},createDocumentFragment:function(){var t=new Ks(ut);return t.ownerDocument=this,t.childNodes=new He,t},createTextNode:function(t){var e=new Gs(ut);return e.ownerDocument=this,e.childNodes=new He,e.appendData(t),e},createComment:function(t){var e=new za(ut);return e.ownerDocument=this,e.childNodes=new He,e.appendData(t),e},createCDATASection:function(t){var e=new Ua(ut);return e.ownerDocument=this,e.childNodes=new He,e.appendData(t),e},createProcessingInstruction:function(t,e){var n=new Ga(ut);return n.ownerDocument=this,n.childNodes=new He,n.nodeName=n.target=t,n.nodeValue=n.data=e,n},createAttribute:function(t){if(!fn.QName_exact.test(t))throw new X(X.INVALID_CHARACTER_ERR,'invalid character in name "'+t+'"');return this.type==="html"&&(t=t.toLowerCase()),this._createAttribute(t)},_createAttribute:function(t){var e=new Tr(ut);return e.ownerDocument=this,e.childNodes=new He,e.name=t,e.nodeName=t,e.localName=t,e.specified=!0,e},createEntityReference:function(t){if(!fn.Name.test(t))throw new X(X.INVALID_CHARACTER_ERR,'not a valid xml name "'+t+'"');if(this.type==="html")throw new X("document is an html document",fS.NotSupportedError);var e=new Ha(ut);return e.ownerDocument=this,e.childNodes=new He,e.nodeName=t,e},createElementNS:function(t,e){var n=Nf(t,e),r=new er(ut),i=r.attributes=new di;return r.childNodes=new He,r.ownerDocument=this,r.nodeName=e,r.tagName=e,r.namespaceURI=n[0],r.prefix=n[1],r.localName=n[2],i._ownerElement=r,r},createAttributeNS:function(t,e){var n=Nf(t,e),r=new Tr(ut);return r.ownerDocument=this,r.childNodes=new He,r.nodeName=e,r.name=e,r.specified=!0,r.namespaceURI=n[0],r.prefix=n[1],r.localName=n[2],r}};yt(Qn,ke);function er(t){gt(t),this._nsMap=Object.create(null)}er.prototype={nodeType:Gt,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===hn.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(t){return!!this.getAttributeNode(t)},getAttribute:function(t){var e=this.getAttributeNode(t);return e?e.value:null},getAttributeNode:function(t){return this._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase()),this.attributes.getNamedItem(t)},setAttribute:function(t,e){this._isInHTMLDocumentAndNamespace()&&(t=t.toLowerCase());var n=this.getAttributeNode(t);n?n.value=n.nodeValue=""+e:(n=this.ownerDocument._createAttribute(t),n.value=n.nodeValue=""+e,this.setAttributeNode(n))},removeAttribute:function(t){var e=this.getAttributeNode(t);e&&this.removeAttributeNode(e)},setAttributeNode:function(t){return this.attributes.setNamedItem(t)},setAttributeNodeNS:function(t){return this.attributes.setNamedItemNS(t)},removeAttributeNode:function(t){return this.attributes.removeNamedItem(t.nodeName)},removeAttributeNS:function(t,e){var n=this.getAttributeNodeNS(t,e);n&&this.removeAttributeNode(n)},hasAttributeNS:function(t,e){return this.getAttributeNodeNS(t,e)!=null},getAttributeNS:function(t,e){var n=this.getAttributeNodeNS(t,e);return n?n.value:null},setAttributeNS:function(t,e,n){var r=Nf(t,e),i=r[2],s=this.getAttributeNodeNS(t,i);s?s.value=s.nodeValue=""+n:(s=this.ownerDocument.createAttributeNS(t,e),s.value=s.nodeValue=""+n,this.setAttributeNode(s))},getAttributeNodeNS:function(t,e){return this.attributes.getNamedItemNS(t,e)},getElementsByClassName:function(t){var e=Jg(t);return new Ar(this,function(n){var r=[];return e.length>0&&Ws(n,function(i){if(i!==n&&i.nodeType===Gt){var s=i.getAttribute("class");if(s){var o=t===s;if(!o){var a=Jg(s);o=e.every(mS(a))}o&&r.push(i)}}}),r})},getElementsByTagName:function(t){var e=(this.nodeType===Hs?this:this.ownerDocument).type==="html",n=t.toLowerCase();return new Ar(this,function(r){var i=[];return Ws(r,function(s){if(!(s===r||s.nodeType!==Gt))if(t==="*")i.push(s);else{var o=s.getQualifiedName(),a=e&&s.namespaceURI===hn.HTML?n:t;o===a&&i.push(s)}}),i})},getElementsByTagNameNS:function(t,e){return new Ar(this,function(n){var r=[];return Ws(n,function(i){i!==n&&i.nodeType===Gt&&(t==="*"||i.namespaceURI===t)&&(e==="*"||i.localName==e)&&r.push(i)}),r})}};Qn.prototype.getElementsByClassName=er.prototype.getElementsByClassName;Qn.prototype.getElementsByTagName=er.prototype.getElementsByTagName;Qn.prototype.getElementsByTagNameNS=er.prototype.getElementsByTagNameNS;yt(er,ke);function Tr(t){gt(t),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}Tr.prototype.nodeType=hi;yt(Tr,ke);function gi(t){gt(t)}gi.prototype={data:"",substringData:function(t,e){return this.data.substring(t,t+e)},appendData:function(t){t=this.data+t,this.nodeValue=this.data=t,this.length=t.length},insertData:function(t,e){this.replaceData(t,0,e)},deleteData:function(t,e){this.replaceData(t,e,"")},replaceData:function(t,e,n){var r=this.data.substring(0,t),i=this.data.substring(t+e);n=r+n+i,this.nodeValue=this.data=n,this.length=n.length}};yt(gi,ke);function Gs(t){gt(t)}Gs.prototype={nodeName:"#text",nodeType:Fa,splitText:function(t){var e=this.data,n=e.substring(t);e=e.substring(0,t),this.data=this.nodeValue=e,this.length=e.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}};yt(Gs,gi);function za(t){gt(t)}za.prototype={nodeName:"#comment",nodeType:ay};yt(za,gi);function Ua(t){gt(t)}Ua.prototype={nodeName:"#cdata-section",nodeType:iy};yt(Ua,Gs);function Wa(t){gt(t)}Wa.prototype.nodeType=ly;yt(Wa,ke);function If(t){gt(t)}If.prototype.nodeType=yS;yt(If,ke);function Rf(t){gt(t)}Rf.prototype.nodeType=gS;yt(Rf,ke);function Ha(t){gt(t)}Ha.prototype.nodeType=sy;yt(Ha,ke);function Ks(t){gt(t)}Ks.prototype.nodeName="#document-fragment";Ks.prototype.nodeType=Zn;yt(Ks,ke);function Ga(t){gt(t)}Ga.prototype.nodeType=oy;yt(Ga,gi);function ky(){}ky.prototype.serializeToString=function(t,e){return by.call(t,e)};ke.prototype.toString=by;function by(t){var e=[],n=this.nodeType===Hs&&this.documentElement||this,r=n.prefix,i=n.namespaceURI;if(i&&r==null){var r=n.lookupPrefix(i);if(r==null)var s=[{namespace:i,prefix:null}]}return fi(this,e,t,s),e.join("")}function ty(t,e,n){var r=t.prefix||"",i=t.namespaceURI;if(!i||r==="xml"&&i===hn.XML||i===hn.XMLNS)return!1;for(var s=n.length;s--;){var o=n[s];if(o.prefix===r)return o.namespace!==i}return!0}function Df(t,e,n){t.push(" ",e,'="',n.replace(/[<>&"\t\n\r]/g,py),'"')}function fi(t,e,n,r){r||(r=[]);var i=t.nodeType===Hs?t:t.ownerDocument,s=i.type==="html";if(n)if(t=n(t),t){if(typeof t=="string"){e.push(t);return}}else return;switch(t.nodeType){case Gt:var o=t.attributes,a=o.length,b=t.firstChild,l=t.tagName,c=l;if(!s&&!t.prefix&&t.namespaceURI){for(var u,f=0;f<o.length;f++)if(o.item(f).name==="xmlns"){u=o.item(f).value;break}if(!u)for(var p=r.length-1;p>=0;p--){var h=r[p];if(h.prefix===""&&h.namespace===t.namespaceURI){u=h.namespace;break}}if(u!==t.namespaceURI)for(var p=r.length-1;p>=0;p--){var h=r[p];if(h.namespace===t.namespaceURI){h.prefix&&(c=h.prefix+":"+l);break}}}e.push("<",c);for(var d=0;d<a;d++){var m=o.item(d);m.prefix=="xmlns"?r.push({prefix:m.localName,namespace:m.value}):m.nodeName=="xmlns"&&r.push({prefix:"",namespace:m.value})}for(var d=0;d<a;d++){var m=o.item(d);if(ty(m,s,r)){var g=m.prefix||"",y=m.namespaceURI;Df(e,g?"xmlns:"+g:"xmlns",y),r.push({prefix:g,namespace:y})}fi(m,e,n,r)}if(l===c&&ty(t,s,r)){var g=t.prefix||"",y=t.namespaceURI;Df(e,g?"xmlns:"+g:"xmlns",y),r.push({prefix:g,namespace:y})}var $=!b;if($&&(s||t.namespaceURI===hn.HTML)&&($=uS(l)),$)e.push("/>");else{if(e.push(">"),s&&cS(l))for(;b;)b.data?e.push(b.data):fi(b,e,n,r.slice()),b=b.nextSibling;else for(;b;)fi(b,e,n,r.slice()),b=b.nextSibling;e.push("</",c,">")}return;case Hs:case Zn:for(var b=t.firstChild;b;)fi(b,e,n,r.slice()),b=b.nextSibling;return;case hi:return Df(e,t.name,t.value);case Fa:return e.push(t.data.replace(/[<&>]/g,py));case iy:return e.push(fn.CDATA_START,t.data,fn.CDATA_END);case ay:return e.push(fn.COMMENT_START,t.data,fn.COMMENT_END);case ly:var k=t.publicId,w=t.systemId;e.push(fn.DOCTYPE_DECL_START," ",t.name),k?(e.push(" ",fn.PUBLIC," ",k),w&&w!=="."&&e.push(" ",w)):w&&w!=="."&&e.push(" ",fn.SYSTEM," ",w),t.internalSubset&&e.push(" [",t.internalSubset,"]"),e.push(">");return;case oy:return e.push("<?",t.target," ",t.data,"?>");case sy:return e.push("&",t.nodeName,";");default:e.push("??",t.nodeName)}}function wy(t,e,n){var r;switch(e.nodeType){case Gt:r=e.cloneNode(!1),r.ownerDocument=t;case Zn:break;case hi:n=!0;break}if(r||(r=e.cloneNode(!1)),r.ownerDocument=t,r.parentNode=null,n)for(var i=e.firstChild;i;)r.appendChild(wy(t,i,n)),i=i.nextSibling;return r}function Cf(t,e,n){var r=new e.constructor(ut);for(var i in e)if(pi(e,i)){var s=e[i];typeof s!="object"&&s!=r[i]&&(r[i]=s)}switch(e.childNodes&&(r.childNodes=new He),r.ownerDocument=t,r.nodeType){case Gt:var o=e.attributes,a=r.attributes=new di,l=o.length;a._ownerElement=r;for(var c=0;c<l;c++)r.setAttributeNode(Cf(t,o.item(c),!0));break;case hi:n=!0}if(n)for(var u=e.firstChild;u;)r.appendChild(Cf(t,u,n)),u=u.nextSibling;return r}function $y(t,e,n){t[e]=n}try{if(Object.defineProperty){let t=function(e){switch(e.nodeType){case Gt:case Zn:var n=[];for(e=e.firstChild;e;)e.nodeType!==7&&e.nodeType!==8&&n.push(t(e)),e=e.nextSibling;return n.join("");default:return e.nodeValue}};Object.defineProperty(Ar.prototype,"length",{get:function(){return Va(this),this.$$length}}),Object.defineProperty(ke.prototype,"textContent",{get:function(){return t(this)},set:function(e){switch(this.nodeType){case Gt:case Zn:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),$y=function(e,n,r){e["$$"+n]=r}}}catch{}je._updateLiveList=Va;je.Attr=Tr;je.CDATASection=Ua;je.CharacterData=gi;je.Comment=za;je.Document=Qn;je.DocumentFragment=Ks;je.DocumentType=Wa;je.DOMImplementation=fy;je.Element=er;je.Entity=Rf;je.EntityReference=Ha;je.LiveNodeList=Ar;je.NamedNodeMap=di;je.Node=ke;je.NodeList=He;je.Notation=If;je.Text=Gs;je.ProcessingInstruction=Ga;je.XMLSerializer=ky});var xy=V(Ys=>{"use strict";var vy=xr().freeze;Ys.XML_ENTITIES=vy({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});Ys.HTML_ENTITIES=vy({Aacute:"\xC1",aacute:"\xE1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223E",acd:"\u223F",acE:"\u223E\u0333",Acirc:"\xC2",acirc:"\xE2",acute:"\xB4",Acy:"\u0410",acy:"\u0430",AElig:"\xC6",aelig:"\xE6",af:"\u2061",Afr:"\u{1D504}",afr:"\u{1D51E}",Agrave:"\xC0",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03B1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2A3F",AMP:"&",amp:"&",And:"\u2A53",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",Aogon:"\u0104",aogon:"\u0105",Aopf:"\u{1D538}",aopf:"\u{1D552}",ap:"\u2248",apacir:"\u2A6F",apE:"\u2A70",ape:"\u224A",apid:"\u224B",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224A",Aring:"\xC5",aring:"\xE5",Ascr:"\u{1D49C}",ascr:"\u{1D4B6}",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224D",Atilde:"\xC3",atilde:"\xE3",Auml:"\xC4",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",Backslash:"\u2216",Barv:"\u2AE7",barvee:"\u22BD",Barwed:"\u2306",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",Because:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",Bernoullis:"\u212C",Beta:"\u0392",beta:"\u03B2",beth:"\u2136",between:"\u226C",Bfr:"\u{1D505}",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bNot:"\u2AED",bnot:"\u2310",Bopf:"\u{1D539}",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxbox:"\u29C9",boxDL:"\u2557",boxDl:"\u2556",boxdL:"\u2555",boxdl:"\u2510",boxDR:"\u2554",boxDr:"\u2553",boxdR:"\u2552",boxdr:"\u250C",boxH:"\u2550",boxh:"\u2500",boxHD:"\u2566",boxHd:"\u2564",boxhD:"\u2565",boxhd:"\u252C",boxHU:"\u2569",boxHu:"\u2567",boxhU:"\u2568",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxUL:"\u255D",boxUl:"\u255C",boxuL:"\u255B",boxul:"\u2518",boxUR:"\u255A",boxUr:"\u2559",boxuR:"\u2558",boxur:"\u2514",boxV:"\u2551",boxv:"\u2502",boxVH:"\u256C",boxVh:"\u256B",boxvH:"\u256A",boxvh:"\u253C",boxVL:"\u2563",boxVl:"\u2562",boxvL:"\u2561",boxvl:"\u2524",boxVR:"\u2560",boxVr:"\u255F",boxvR:"\u255E",boxvr:"\u251C",bprime:"\u2035",Breve:"\u02D8",breve:"\u02D8",brvbar:"\xA6",Bscr:"\u212C",bscr:"\u{1D4B7}",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",Bumpeq:"\u224E",bumpeq:"\u224F",Cacute:"\u0106",cacute:"\u0107",Cap:"\u22D2",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",CapitalDifferentialD:"\u2145",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",Cayleys:"\u212D",ccaps:"\u2A4D",Ccaron:"\u010C",ccaron:"\u010D",Ccedil:"\xC7",ccedil:"\xE7",Ccirc:"\u0108",ccirc:"\u0109",Cconint:"\u2230",ccups:"\u2A4C",ccupssm:"\u2A50",Cdot:"\u010A",cdot:"\u010B",cedil:"\xB8",Cedilla:"\xB8",cemptyv:"\u29B2",cent:"\xA2",CenterDot:"\xB7",centerdot:"\xB7",Cfr:"\u212D",cfr:"\u{1D520}",CHcy:"\u0427",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",Chi:"\u03A7",chi:"\u03C7",cir:"\u25CB",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",CircleDot:"\u2299",circledR:"\xAE",circledS:"\u24C8",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",cirE:"\u29C3",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",clubs:"\u2663",clubsuit:"\u2663",Colon:"\u2237",colon:":",Colone:"\u2A74",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",Congruent:"\u2261",Conint:"\u222F",conint:"\u222E",ContourIntegral:"\u222E",Copf:"\u2102",copf:"\u{1D554}",coprod:"\u2210",Coproduct:"\u2210",COPY:"\xA9",copy:"\xA9",copysr:"\u2117",CounterClockwiseContourIntegral:"\u2233",crarr:"\u21B5",Cross:"\u2A2F",cross:"\u2717",Cscr:"\u{1D49E}",cscr:"\u{1D4B8}",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",Cup:"\u22D3",cup:"\u222A",cupbrcap:"\u2A48",CupCap:"\u224D",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",Dagger:"\u2021",dagger:"\u2020",daleth:"\u2138",Darr:"\u21A1",dArr:"\u21D3",darr:"\u2193",dash:"\u2010",Dashv:"\u2AE4",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",Dcaron:"\u010E",dcaron:"\u010F",Dcy:"\u0414",dcy:"\u0434",DD:"\u2145",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",DDotrahd:"\u2911",ddotseq:"\u2A77",deg:"\xB0",Del:"\u2207",Delta:"\u0394",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",Dfr:"\u{1D507}",dfr:"\u{1D521}",dHar:"\u2965",dharl:"\u21C3",dharr:"\u21C2",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",diam:"\u22C4",Diamond:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",DifferentialD:"\u2146",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",DJcy:"\u0402",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",Dopf:"\u{1D53B}",dopf:"\u{1D555}",Dot:"\xA8",dot:"\u02D9",DotDot:"\u20DC",doteq:"\u2250",doteqdot:"\u2251",DotEqual:"\u2250",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",Downarrow:"\u21D3",downarrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",Dscr:"\u{1D49F}",dscr:"\u{1D4B9}",DScy:"\u0405",dscy:"\u0455",dsol:"\u29F6",Dstrok:"\u0110",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",DZcy:"\u040F",dzcy:"\u045F",dzigrarr:"\u27FF",Eacute:"\xC9",eacute:"\xE9",easter:"\u2A6E",Ecaron:"\u011A",ecaron:"\u011B",ecir:"\u2256",Ecirc:"\xCA",ecirc:"\xEA",ecolon:"\u2255",Ecy:"\u042D",ecy:"\u044D",eDDot:"\u2A77",Edot:"\u0116",eDot:"\u2251",edot:"\u0117",ee:"\u2147",efDot:"\u2252",Efr:"\u{1D508}",efr:"\u{1D522}",eg:"\u2A9A",Egrave:"\xC8",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",Element:"\u2208",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",Emacr:"\u0112",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",EmptySmallSquare:"\u25FB",emptyv:"\u2205",EmptyVerySmallSquare:"\u25AB",emsp:"\u2003",emsp13:"\u2004",emsp14:"\u2005",ENG:"\u014A",eng:"\u014B",ensp:"\u2002",Eogon:"\u0118",eogon:"\u0119",Eopf:"\u{1D53C}",eopf:"\u{1D556}",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",Epsilon:"\u0395",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",Equal:"\u2A75",equals:"=",EqualTilde:"\u2242",equest:"\u225F",Equilibrium:"\u21CC",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erarr:"\u2971",erDot:"\u2253",Escr:"\u2130",escr:"\u212F",esdot:"\u2250",Esim:"\u2A73",esim:"\u2242",Eta:"\u0397",eta:"\u03B7",ETH:"\xD0",eth:"\xF0",Euml:"\xCB",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",Exists:"\u2203",expectation:"\u2130",ExponentialE:"\u2147",exponentiale:"\u2147",fallingdotseq:"\u2252",Fcy:"\u0424",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",Ffr:"\u{1D509}",ffr:"\u{1D523}",filig:"\uFB01",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",Fopf:"\u{1D53D}",fopf:"\u{1D557}",ForAll:"\u2200",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",Fouriertrf:"\u2131",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",Fscr:"\u2131",fscr:"\u{1D4BB}",gacute:"\u01F5",Gamma:"\u0393",gamma:"\u03B3",Gammad:"\u03DC",gammad:"\u03DD",gap:"\u2A86",Gbreve:"\u011E",gbreve:"\u011F",Gcedil:"\u0122",Gcirc:"\u011C",gcirc:"\u011D",Gcy:"\u0413",gcy:"\u0433",Gdot:"\u0120",gdot:"\u0121",gE:"\u2267",ge:"\u2265",gEl:"\u2A8C",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",Gfr:"\u{1D50A}",gfr:"\u{1D524}",Gg:"\u22D9",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",GJcy:"\u0403",gjcy:"\u0453",gl:"\u2277",gla:"\u2AA5",glE:"\u2A92",glj:"\u2AA4",gnap:"\u2A8A",gnapprox:"\u2A8A",gnE:"\u2269",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",Gopf:"\u{1D53E}",gopf:"\u{1D558}",grave:"`",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\u{1D4A2}",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",Gt:"\u226B",GT:">",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",Hacek:"\u02C7",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",HARDcy:"\u042A",hardcy:"\u044A",hArr:"\u21D4",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",Hat:"^",hbar:"\u210F",Hcirc:"\u0124",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",Hfr:"\u210C",hfr:"\u{1D525}",HilbertSpace:"\u210B",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",Hopf:"\u210D",hopf:"\u{1D559}",horbar:"\u2015",HorizontalLine:"\u2500",Hscr:"\u210B",hscr:"\u{1D4BD}",hslash:"\u210F",Hstrok:"\u0126",hstrok:"\u0127",HumpDownHump:"\u224E",HumpEqual:"\u224F",hybull:"\u2043",hyphen:"\u2010",Iacute:"\xCD",iacute:"\xED",ic:"\u2063",Icirc:"\xCE",icirc:"\xEE",Icy:"\u0418",icy:"\u0438",Idot:"\u0130",IEcy:"\u0415",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",Ifr:"\u2111",ifr:"\u{1D526}",Igrave:"\xCC",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",IJlig:"\u0132",ijlig:"\u0133",Im:"\u2111",Imacr:"\u012A",imacr:"\u012B",image:"\u2111",ImaginaryI:"\u2148",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",Implies:"\u21D2",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",Int:"\u222C",int:"\u222B",intcal:"\u22BA",integers:"\u2124",Integral:"\u222B",intercal:"\u22BA",Intersection:"\u22C2",intlarhk:"\u2A17",intprod:"\u2A3C",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",IOcy:"\u0401",iocy:"\u0451",Iogon:"\u012E",iogon:"\u012F",Iopf:"\u{1D540}",iopf:"\u{1D55A}",Iota:"\u0399",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",Iscr:"\u2110",iscr:"\u{1D4BE}",isin:"\u2208",isindot:"\u22F5",isinE:"\u22F9",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",Itilde:"\u0128",itilde:"\u0129",Iukcy:"\u0406",iukcy:"\u0456",Iuml:"\xCF",iuml:"\xEF",Jcirc:"\u0134",jcirc:"\u0135",Jcy:"\u0419",jcy:"\u0439",Jfr:"\u{1D50D}",jfr:"\u{1D527}",jmath:"\u0237",Jopf:"\u{1D541}",jopf:"\u{1D55B}",Jscr:"\u{1D4A5}",jscr:"\u{1D4BF}",Jsercy:"\u0408",jsercy:"\u0458",Jukcy:"\u0404",jukcy:"\u0454",Kappa:"\u039A",kappa:"\u03BA",kappav:"\u03F0",Kcedil:"\u0136",kcedil:"\u0137",Kcy:"\u041A",kcy:"\u043A",Kfr:"\u{1D50E}",kfr:"\u{1D528}",kgreen:"\u0138",KHcy:"\u0425",khcy:"\u0445",KJcy:"\u040C",kjcy:"\u045C",Kopf:"\u{1D542}",kopf:"\u{1D55C}",Kscr:"\u{1D4A6}",kscr:"\u{1D4C0}",lAarr:"\u21DA",Lacute:"\u0139",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",Lambda:"\u039B",lambda:"\u03BB",Lang:"\u27EA",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",Laplacetrf:"\u2112",laquo:"\xAB",Larr:"\u219E",lArr:"\u21D0",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",lAtail:"\u291B",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lBarr:"\u290E",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",Lcaron:"\u013D",lcaron:"\u013E",Lcedil:"\u013B",lcedil:"\u013C",lceil:"\u2308",lcub:"{",Lcy:"\u041B",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",lE:"\u2266",le:"\u2264",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",Leftarrow:"\u21D0",leftarrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",leftarrowtail:"\u21A2",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",LeftRightArrow:"\u2194",Leftrightarrow:"\u21D4",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",leftthreetimes:"\u22CB",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",lEg:"\u2A8B",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",lessgtr:"\u2276",LessLess:"\u2AA1",lesssim:"\u2272",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",lfisht:"\u297C",lfloor:"\u230A",Lfr:"\u{1D50F}",lfr:"\u{1D529}",lg:"\u2276",lgE:"\u2A91",lHar:"\u2962",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",LJcy:"\u0409",ljcy:"\u0459",Ll:"\u22D8",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",Lleftarrow:"\u21DA",llhard:"\u296B",lltri:"\u25FA",Lmidot:"\u013F",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnap:"\u2A89",lnapprox:"\u2A89",lnE:"\u2268",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",LongLeftArrow:"\u27F5",Longleftarrow:"\u27F8",longleftarrow:"\u27F5",LongLeftRightArrow:"\u27F7",Longleftrightarrow:"\u27FA",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",LongRightArrow:"\u27F6",Longrightarrow:"\u27F9",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",Lopf:"\u{1D543}",lopf:"\u{1D55D}",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",Lscr:"\u2112",lscr:"\u{1D4C1}",Lsh:"\u21B0",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",Lstrok:"\u0141",lstrok:"\u0142",Lt:"\u226A",LT:"<",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",ltrPar:"\u2996",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",Map:"\u2905",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",Mcy:"\u041C",mcy:"\u043C",mdash:"\u2014",mDDot:"\u223A",measuredangle:"\u2221",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\u{1D510}",mfr:"\u{1D52A}",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",MinusPlus:"\u2213",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",Mopf:"\u{1D544}",mopf:"\u{1D55E}",mp:"\u2213",Mscr:"\u2133",mscr:"\u{1D4C2}",mstpos:"\u223E",Mu:"\u039C",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nabla:"\u2207",Nacute:"\u0143",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",Ncaron:"\u0147",ncaron:"\u0148",Ncedil:"\u0145",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",Ncy:"\u041D",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",nearhk:"\u2924",neArr:"\u21D7",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
140
+ `,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlArr:"\u21CD",nlarr:"\u219A",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nLeftarrow:"\u21CD",nleftarrow:"\u219A",nLeftrightarrow:"\u21CE",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",nopf:"\u{1D55F}",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nRightarrow:"\u21CF",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nVDash:"\u22AF",nVdash:"\u22AE",nvDash:"\u22AD",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwArr:"\u21D6",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",Ocirc:"\xD4",ocirc:"\xF4",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u0153",ofcir:"\u29BF",Ofr:"\u{1D512}",ofr:"\u{1D52C}",ogon:"\u02DB",Ograve:"\xD2",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",Omacr:"\u014C",omacr:"\u014D",Omega:"\u03A9",omega:"\u03C9",Omicron:"\u039F",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",Oopf:"\u{1D546}",oopf:"\u{1D560}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",Or:"\u2A54",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",Oscr:"\u{1D4AA}",oscr:"\u2134",Oslash:"\xD8",oslash:"\xF8",osol:"\u2298",Otilde:"\xD5",otilde:"\xF5",Otimes:"\u2A37",otimes:"\u2297",otimesas:"\u2A36",Ouml:"\xD6",ouml:"\xF6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",PartialD:"\u2202",Pcy:"\u041F",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",Pfr:"\u{1D513}",pfr:"\u{1D52D}",Phi:"\u03A6",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",Pi:"\u03A0",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",PlusMinus:"\xB1",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",Poincareplane:"\u210C",pointint:"\u2A15",Popf:"\u2119",popf:"\u{1D561}",pound:"\xA3",Pr:"\u2ABB",pr:"\u227A",prap:"\u2AB7",prcue:"\u227C",prE:"\u2AB3",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",Prime:"\u2033",prime:"\u2032",primes:"\u2119",prnap:"\u2AB9",prnE:"\u2AB5",prnsim:"\u22E8",prod:"\u220F",Product:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",Proportion:"\u2237",Proportional:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",Pscr:"\u{1D4AB}",pscr:"\u{1D4C5}",Psi:"\u03A8",psi:"\u03C8",puncsp:"\u2008",Qfr:"\u{1D514}",qfr:"\u{1D52E}",qint:"\u2A0C",Qopf:"\u211A",qopf:"\u{1D562}",qprime:"\u2057",Qscr:"\u{1D4AC}",qscr:"\u{1D4C6}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",QUOT:'"',quot:'"',rAarr:"\u21DB",race:"\u223D\u0331",Racute:"\u0154",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",Rang:"\u27EB",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",Rarr:"\u21A0",rArr:"\u21D2",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",Rarrtl:"\u2916",rarrtl:"\u21A3",rarrw:"\u219D",rAtail:"\u291C",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",RBarr:"\u2910",rBarr:"\u290F",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",Rcaron:"\u0158",rcaron:"\u0159",Rcedil:"\u0156",rcedil:"\u0157",rceil:"\u2309",rcub:"}",Rcy:"\u0420",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",Re:"\u211C",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",REG:"\xAE",reg:"\xAE",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",rfisht:"\u297D",rfloor:"\u230B",Rfr:"\u211C",rfr:"\u{1D52F}",rHar:"\u2964",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",Rho:"\u03A1",rho:"\u03C1",rhov:"\u03F1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",Rightarrow:"\u21D2",rightarrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",rightarrowtail:"\u21A3",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",rightthreetimes:"\u22CC",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",Ropf:"\u211D",ropf:"\u{1D563}",roplus:"\u2A2E",rotimes:"\u2A35",RoundImplies:"\u2970",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",Rrightarrow:"\u21DB",rsaquo:"\u203A",Rscr:"\u211B",rscr:"\u{1D4C7}",Rsh:"\u21B1",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",RuleDelayed:"\u29F4",ruluhar:"\u2968",rx:"\u211E",Sacute:"\u015A",sacute:"\u015B",sbquo:"\u201A",Sc:"\u2ABC",sc:"\u227B",scap:"\u2AB8",Scaron:"\u0160",scaron:"\u0161",sccue:"\u227D",scE:"\u2AB4",sce:"\u2AB0",Scedil:"\u015E",scedil:"\u015F",Scirc:"\u015C",scirc:"\u015D",scnap:"\u2ABA",scnE:"\u2AB6",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",Scy:"\u0421",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",searhk:"\u2925",seArr:"\u21D8",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",Sfr:"\u{1D516}",sfr:"\u{1D530}",sfrown:"\u2322",sharp:"\u266F",SHCHcy:"\u0429",shchcy:"\u0449",SHcy:"\u0428",shcy:"\u0448",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",shortmid:"\u2223",shortparallel:"\u2225",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",shy:"\xAD",Sigma:"\u03A3",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",SmallCircle:"\u2218",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",SOFTcy:"\u042C",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",Sopf:"\u{1D54A}",sopf:"\u{1D564}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",Sqrt:"\u221A",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",Square:"\u25A1",square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",Sscr:"\u{1D4AE}",sscr:"\u{1D4C8}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",Star:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",Sub:"\u22D0",sub:"\u2282",subdot:"\u2ABD",subE:"\u2AC5",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",Subset:"\u22D0",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",SubsetEqual:"\u2286",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",SuchThat:"\u220B",Sum:"\u2211",sum:"\u2211",sung:"\u266A",Sup:"\u22D1",sup:"\u2283",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",supdot:"\u2ABE",supdsub:"\u2AD8",supE:"\u2AC6",supe:"\u2287",supedot:"\u2AC4",Superset:"\u2283",SupersetEqual:"\u2287",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",Supset:"\u22D1",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swarhk:"\u2926",swArr:"\u21D9",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",Tab:" ",target:"\u2316",Tau:"\u03A4",tau:"\u03C4",tbrk:"\u23B4",Tcaron:"\u0164",tcaron:"\u0165",Tcedil:"\u0162",tcedil:"\u0163",Tcy:"\u0422",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",Tfr:"\u{1D517}",tfr:"\u{1D531}",there4:"\u2234",Therefore:"\u2234",therefore:"\u2234",Theta:"\u0398",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",ThickSpace:"\u205F\u200A",thinsp:"\u2009",ThinSpace:"\u2009",thkap:"\u2248",thksim:"\u223C",THORN:"\xDE",thorn:"\xFE",Tilde:"\u223C",tilde:"\u02DC",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",Topf:"\u{1D54B}",topf:"\u{1D565}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",TRADE:"\u2122",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",TripleDot:"\u20DB",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",Tscr:"\u{1D4AF}",tscr:"\u{1D4C9}",TScy:"\u0426",tscy:"\u0446",TSHcy:"\u040B",tshcy:"\u045B",Tstrok:"\u0166",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",Uacute:"\xDA",uacute:"\xFA",Uarr:"\u219F",uArr:"\u21D1",uarr:"\u2191",Uarrocir:"\u2949",Ubrcy:"\u040E",ubrcy:"\u045E",Ubreve:"\u016C",ubreve:"\u016D",Ucirc:"\xDB",ucirc:"\xFB",Ucy:"\u0423",ucy:"\u0443",udarr:"\u21C5",Udblac:"\u0170",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",Ufr:"\u{1D518}",ufr:"\u{1D532}",Ugrave:"\xD9",ugrave:"\xF9",uHar:"\u2963",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",Umacr:"\u016A",umacr:"\u016B",uml:"\xA8",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",uogon:"\u0173",Uopf:"\u{1D54C}",uopf:"\u{1D566}",UpArrow:"\u2191",Uparrow:"\u21D1",uparrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",Updownarrow:"\u21D5",updownarrow:"\u2195",UpEquilibrium:"\u296E",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",upsi:"\u03C5",upsih:"\u03D2",Upsilon:"\u03A5",upsilon:"\u03C5",UpTee:"\u22A5",UpTeeArrow:"\u21A5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",Uring:"\u016E",uring:"\u016F",urtri:"\u25F9",Uscr:"\u{1D4B0}",uscr:"\u{1D4CA}",utdot:"\u22F0",Utilde:"\u0168",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",Uuml:"\xDC",uuml:"\xFC",uwangle:"\u29A7",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",vArr:"\u21D5",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",Vbar:"\u2AEB",vBar:"\u2AE8",vBarv:"\u2AE9",Vcy:"\u0412",vcy:"\u0432",VDash:"\u22AB",Vdash:"\u22A9",vDash:"\u22A8",vdash:"\u22A2",Vdashl:"\u2AE6",Vee:"\u22C1",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",Verbar:"\u2016",verbar:"|",Vert:"\u2016",vert:"|",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\u{1D519}",vfr:"\u{1D533}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",Vopf:"\u{1D54D}",vopf:"\u{1D567}",vprop:"\u221D",vrtri:"\u22B3",Vscr:"\u{1D4B1}",vscr:"\u{1D4CB}",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",Vvdash:"\u22AA",vzigzag:"\u299A",Wcirc:"\u0174",wcirc:"\u0175",wedbar:"\u2A5F",Wedge:"\u22C0",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",Wfr:"\u{1D51A}",wfr:"\u{1D534}",Wopf:"\u{1D54E}",wopf:"\u{1D568}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",Wscr:"\u{1D4B2}",wscr:"\u{1D4CC}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",Xfr:"\u{1D51B}",xfr:"\u{1D535}",xhArr:"\u27FA",xharr:"\u27F7",Xi:"\u039E",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",Xopf:"\u{1D54F}",xopf:"\u{1D569}",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",Xscr:"\u{1D4B3}",xscr:"\u{1D4CD}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",Yacute:"\xDD",yacute:"\xFD",YAcy:"\u042F",yacy:"\u044F",Ycirc:"\u0176",ycirc:"\u0177",Ycy:"\u042B",ycy:"\u044B",yen:"\xA5",Yfr:"\u{1D51C}",yfr:"\u{1D536}",YIcy:"\u0407",yicy:"\u0457",Yopf:"\u{1D550}",yopf:"\u{1D56A}",Yscr:"\u{1D4B4}",yscr:"\u{1D4CE}",YUcy:"\u042E",yucy:"\u044E",Yuml:"\u0178",yuml:"\xFF",Zacute:"\u0179",zacute:"\u017A",Zcaron:"\u017D",zcaron:"\u017E",Zcy:"\u0417",zcy:"\u0437",Zdot:"\u017B",zdot:"\u017C",zeetrf:"\u2128",ZeroWidthSpace:"\u200B",Zeta:"\u0396",zeta:"\u03B6",Zfr:"\u2128",zfr:"\u{1D537}",ZHcy:"\u0416",zhcy:"\u0436",zigrarr:"\u21DD",Zopf:"\u2124",zopf:"\u{1D56B}",Zscr:"\u{1D4B5}",zscr:"\u{1D4CF}",zwj:"\u200D",zwnj:"\u200C"});Ys.entityMap=Ys.HTML_ENTITIES});var My=V(Ya=>{"use strict";var wi=xr(),ie=Tf(),Dy=Ps(),ES=wi.isHTMLEscapableRawTextElement,SS=wi.isHTMLMimeType,AS=wi.isHTMLRawTextElement,Xs=wi.hasOwn,Ey=wi.NAMESPACE,Sy=Dy.ParseError,TS=Dy.DOMException,Js=0,tr=1,yi=2,Zs=3,ki=4,bi=5,Qs=6,Ka=7;function Ny(){}Ny.prototype={parse:function(t,e,n){var r=this.domBuilder;r.startDocument(),Cy(e,e=Object.create(null)),DS(t,e,n,r,this.errorHandler),r.endDocument()}};var Mf=/&#?\w+;?/g;function DS(t,e,n,r,i){var s=SS(r.mimeType);t.indexOf(ie.UNICODE_REPLACEMENT_CHARACTER)>=0&&i.warning("Unicode replacement character detected, source encoding issues?");function o(q){if(q>65535){q-=65536;var x=55296+(q>>10),ge=56320+(q&1023);return String.fromCharCode(x,ge)}else return String.fromCharCode(q)}function a(q){var x=q[q.length-1]===";"?q:q+";";if(!s&&x!==q)return i.error("EntityRef: expecting ;"),q;var ge=ie.Reference.exec(x);if(!ge||ge[0].length!==x.length)return i.error("entity not matching Reference production: "+q),q;var Ee=x.slice(1,-1);return Xs(n,Ee)?n[Ee]:Ee.charAt(0)==="#"?o(parseInt(Ee.substring(1).replace("x","0x"))):(i.error("entity not found:"+q),q)}function l(q){if(q>g){var x=t.substring(g,q).replace(Mf,a);p&&h(g),r.characters(x,0,q-g),g=q}}var c=0,u=0,f=/\r\n?|\n|$/g,p=r.locator;function h(q,x){for(;q>=u&&(x=f.exec(t));)c=u,u=x.index+x[0].length,p.lineNumber++;p.columnNumber=q-c+1}for(var d=[{currentNSMap:e}],m=[],g=0;;){try{var y=t.indexOf("<",g);if(y<0){if(!s&&m.length>0)return i.fatalError("unclosed xml tag(s): "+m.join(", "));if(!t.substring(g).match(/^\s*$/)){var $=r.doc,b=$.createTextNode(t.substring(g));if($.documentElement)return i.error("Extra content at the end of the document");$.appendChild(b),r.currentElement=b}return}if(y>g){var k=t.substring(g,y);!s&&m.length===0&&(k=k.replace(new RegExp(ie.S_OPT.source,"g"),""),k&&i.error("Unexpected content outside root element: '"+k+"'")),l(y)}switch(t.charAt(y+1)){case"/":var O=t.indexOf(">",y+2),w=t.substring(y+2,O>0?O:void 0);if(!w)return i.fatalError("end tag name missing");var v=O>0&&ie.reg("^",ie.QName_group,ie.S_OPT,"$").exec(w);if(!v)return i.fatalError('end tag name contains invalid characters: "'+w+'"');if(!r.currentElement&&!r.doc.documentElement)return;var D=m[m.length-1]||r.currentElement.tagName||r.doc.documentElement.tagName||"";if(D!==v[1]){var I=v[1].toLowerCase();if(!s||D.toLowerCase()!==I)return i.fatalError('Opening and ending tag mismatch: "'+D+'" != "'+w+'"')}var L=d.pop();m.pop();var T=L.localNSMap;if(r.endElement(L.uri,L.localName,D),T)for(var G in T)Xs(T,G)&&r.endPrefixMapping(G);O++;break;case"?":p&&h(y),O=RS(t,y,r,i);break;case"!":p&&h(y),O=Ry(t,y,r,i,s);break;default:p&&h(y);var R=new Oy,j=d[d.length-1].currentNSMap,O=NS(t,y,R,j,a,i,s),A=R.length;if(R.closed||(s&&wi.isHTMLVoidElement(R.tagName)?R.closed=!0:m.push(R.tagName)),p&&A){for(var _=Ay(p,{}),W=0;W<A;W++){var Y=R[W];h(Y.offset),Y.locator=Ay(p,{})}r.locator=_,Ty(R,r,j)&&d.push(R),r.locator=p}else Ty(R,r,j)&&d.push(R);s&&!R.closed?O=CS(t,O,R.tagName,a,r):O++}}catch(q){if(q instanceof Sy)throw q;if(q instanceof TS)throw new Sy(q.name+": "+q.message,r.locator,q);i.error("element parse error: "+q),O=-1}O>g?g=O:l(Math.max(y,g)+1)}}function Ay(t,e){return e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber,e}function NS(t,e,n,r,i,s,o){function a(h,d,m){if(Xs(n.attributeNames,h))return s.fatalError("Attribute "+h+" redefined");if(!o&&d.indexOf("<")>=0)return s.fatalError("Unescaped '<' not allowed in attributes values");n.addValue(h,d.replace(/[\t\n\r]/g," ").replace(Mf,i),m)}for(var l,c,u=++e,f=Js;;){var p=t.charAt(u);switch(p){case"=":if(f===tr)l=t.slice(e,u),f=Zs;else if(f===yi)f=Zs;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(f===Zs||f===tr)if(f===tr&&(s.warning('attribute value must after "="'),l=t.slice(e,u)),e=u+1,u=t.indexOf(p,e),u>0)c=t.slice(e,u),a(l,c,e-1),f=bi;else throw new Error("attribute value no end '"+p+"' match");else if(f==ki)c=t.slice(e,u),a(l,c,e),s.warning('attribute "'+l+'" missed start quot('+p+")!!"),e=u+1,f=bi;else throw new Error('attribute value must after "="');break;case"/":switch(f){case Js:n.setTagName(t.slice(e,u));case bi:case Qs:case Ka:f=Ka,n.closed=!0;case ki:case tr:break;case yi:n.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),f==Js&&n.setTagName(t.slice(e,u)),u;case">":switch(f){case Js:n.setTagName(t.slice(e,u));case bi:case Qs:case Ka:break;case ki:case tr:c=t.slice(e,u),c.slice(-1)==="/"&&(n.closed=!0,c=c.slice(0,-1));case yi:f===yi&&(c=l),f==ki?(s.warning('attribute "'+c+'" missed quot(")!'),a(l,c,e)):(o||s.warning('attribute "'+c+'" missed value!! "'+c+'" instead!!'),a(c,c,e));break;case Zs:if(!o)return s.fatalError(`AttValue: ' or " expected`)}return u;case"\x80":p=" ";default:if(p<=" ")switch(f){case Js:n.setTagName(t.slice(e,u)),f=Qs;break;case tr:l=t.slice(e,u),f=yi;break;case ki:var c=t.slice(e,u);s.warning('attribute "'+c+'" missed quot(")!!'),a(l,c,e);case bi:f=Qs;break}else switch(f){case yi:o||s.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),a(l,l,e),e=u,f=tr;break;case bi:s.warning('attribute space is required"'+l+'"!!');case Qs:f=tr,e=u;break;case Zs:f=ki,e=u;break;case Ka:throw new Error("elements closed character '/' and '>' must be connected to")}}u++}}function Ty(t,e,n){for(var r=t.tagName,i=null,f=t.length;f--;){var s=t[f],o=s.qName,a=s.value,p=o.indexOf(":");if(p>0)var l=s.prefix=o.slice(0,p),c=o.slice(p+1),u=l==="xmlns"&&c;else c=o,l=null,u=o==="xmlns"&&"";s.localName=c,u!==!1&&(i==null&&(i=Object.create(null),Cy(n,n=Object.create(null))),n[u]=i[u]=a,s.uri=Ey.XMLNS,e.startPrefixMapping(u,a))}for(var f=t.length;f--;)s=t[f],s.prefix&&(s.prefix==="xml"&&(s.uri=Ey.XML),s.prefix!=="xmlns"&&(s.uri=n[s.prefix]));var p=r.indexOf(":");p>0?(l=t.prefix=r.slice(0,p),c=t.localName=r.slice(p+1)):(l=null,c=t.localName=r);var h=t.uri=n[l||""];if(e.startElement(h,c,r,t),t.closed){if(e.endElement(h,c,r),i)for(l in i)Xs(i,l)&&e.endPrefixMapping(l)}else return t.currentNSMap=n,t.localNSMap=i,!0}function CS(t,e,n,r,i){var s=ES(n);if(s||AS(n)){var o=t.indexOf("</"+n+">",e),a=t.substring(e+1,o);return s&&(a=a.replace(Mf,r)),i.characters(a,0,a.length),o}return e+1}function Cy(t,e){for(var n in t)Xs(t,n)&&(e[n]=t[n])}function Iy(t,e){var n=e;function r(u){return u=u||0,t.charAt(n+u)}function i(u){u=u||1,n+=u}function s(){for(var u=0;n<t.length;){var f=r();if(f!==" "&&f!==`
141
+ `&&f!==" "&&f!=="\r")return u;u++,i()}return-1}function o(){return t.substring(n)}function a(u){return t.substring(n,n+u.length)===u}function l(u){return t.substring(n,n+u.length).toUpperCase()===u.toUpperCase()}function c(u){var f=ie.reg("^",u),p=f.exec(o());return p?(i(p[0].length),p[0]):null}return{char:r,getIndex:function(){return n},getMatch:c,getSource:function(){return t},skip:i,skipBlanks:s,substringFromIndex:o,substringStartsWith:a,substringStartsWithCaseInsensitive:l}}function IS(t,e){function n(a,l){var c=ie.PI.exec(a.substringFromIndex());return c?c[1].toLowerCase()==="xml"?l.fatalError("xml declaration is only allowed at the start of the document, but found at position "+a.getIndex()):(a.skip(c[0].length),c[0]):l.fatalError("processing instruction is not well-formed at position "+a.getIndex())}var r=t.getSource();if(t.char()==="["){t.skip(1);for(var i=t.getIndex();t.getIndex()<r.length;){if(t.skipBlanks(),t.char()==="]"){var s=r.substring(i,t.getIndex());return t.skip(1),s}var o=null;if(t.char()==="<"&&t.char(1)==="!")switch(t.char(2)){case"E":t.char(3)==="L"?o=t.getMatch(ie.elementdecl):t.char(3)==="N"&&(o=t.getMatch(ie.EntityDecl));break;case"A":o=t.getMatch(ie.AttlistDecl);break;case"N":o=t.getMatch(ie.NotationDecl);break;case"-":o=t.getMatch(ie.Comment);break}else if(t.char()==="<"&&t.char(1)==="?")o=n(t,e);else if(t.char()==="%")o=t.getMatch(ie.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!o)return e.fatalError("Error in internal subset at position "+t.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}function Ry(t,e,n,r,i){var s=Iy(t,e);switch(i?s.char(2).toUpperCase():s.char(2)){case"-":var o=s.getMatch(ie.Comment);return o?(n.comment(o,ie.COMMENT_START.length,o.length-ie.COMMENT_START.length-ie.COMMENT_END.length),s.getIndex()):r.fatalError("comment is not well-formed at position "+s.getIndex());case"[":var a=s.getMatch(ie.CDSect);return a?!i&&!n.currentElement?r.fatalError("CDATA outside of element"):(n.startCDATA(),n.characters(a,ie.CDATA_START.length,a.length-ie.CDATA_START.length-ie.CDATA_END.length),n.endCDATA(),s.getIndex()):r.fatalError("Invalid CDATA starting at position "+e);case"D":{if(n.doc&&n.doc.documentElement)return r.fatalError("Doctype not allowed inside or after documentElement at position "+s.getIndex());if(i?!s.substringStartsWithCaseInsensitive(ie.DOCTYPE_DECL_START):!s.substringStartsWith(ie.DOCTYPE_DECL_START))return r.fatalError("Expected "+ie.DOCTYPE_DECL_START+" at position "+s.getIndex());if(s.skip(ie.DOCTYPE_DECL_START.length),s.skipBlanks()<1)return r.fatalError("Expected whitespace after "+ie.DOCTYPE_DECL_START+" at position "+s.getIndex());var l={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(l.name=s.getMatch(ie.Name),!l.name)return r.fatalError("doctype name missing or contains unexpected characters at position "+s.getIndex());if(i&&l.name.toLowerCase()!=="html"&&r.warning("Unexpected DOCTYPE in HTML document at position "+s.getIndex()),s.skipBlanks(),s.substringStartsWith(ie.PUBLIC)||s.substringStartsWith(ie.SYSTEM)){var c=ie.ExternalID_match.exec(s.substringFromIndex());if(!c)return r.fatalError("doctype external id is not well-formed at position "+s.getIndex());c.groups.SystemLiteralOnly!==void 0?l.systemId=c.groups.SystemLiteralOnly:(l.systemId=c.groups.SystemLiteral,l.publicId=c.groups.PubidLiteral),s.skip(c[0].length)}else if(i&&s.substringStartsWithCaseInsensitive(ie.SYSTEM)){if(s.skip(ie.SYSTEM.length),s.skipBlanks()<1)return r.fatalError("Expected whitespace after "+ie.SYSTEM+" at position "+s.getIndex());if(l.systemId=s.getMatch(ie.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return r.fatalError("Expected "+ie.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+ie.SYSTEM+" at position "+s.getIndex())}return i&&l.systemId&&!ie.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&r.warning("Unexpected doctype.systemId in HTML document at position "+s.getIndex()),i||(s.skipBlanks(),l.internalSubset=IS(s,r)),s.skipBlanks(),s.char()!==">"?r.fatalError("doctype not terminated with > at position "+s.getIndex()):(s.skip(1),n.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),n.endDTD(),s.getIndex())}default:return r.fatalError('Not well-formed XML starting with "<!" at position '+e)}}function RS(t,e,n,r){var i=t.substring(e).match(ie.PI);if(!i)return r.fatalError("Invalid processing instruction starting at position "+e);if(i[1].toLowerCase()==="xml"){if(e>0)return r.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!ie.XMLDecl.test(t.substring(e)))return r.fatalError("xml declaration is not well-formed")}return n.processingInstruction(i[1],i[2]),e+i[0].length}function Oy(){this.attributeNames=Object.create(null)}Oy.prototype={setTagName:function(t){if(!ie.QName_exact.test(t))throw new Error("invalid tagName:"+t);this.tagName=t},addValue:function(t,e,n){if(!ie.QName_exact.test(t))throw new Error("invalid attribute:"+t);this.attributeNames[t]=this.length,this[this.length++]={qName:t,value:e,offset:n}},length:0,getLocalName:function(t){return this[t].localName},getLocator:function(t){return this[t].locator},getQName:function(t){return this[t].qName},getURI:function(t){return this[t].uri},getValue:function(t){return this[t].value}};Ya.XMLReader=Ny;Ya.parseUtils=Iy;Ya.parseDoctypeCommentOrCData=Ry});var By=V(vi=>{"use strict";var Dr=xr(),OS=Of(),MS=Ps(),Ly=xy(),LS=My(),jS=OS.DOMImplementation,PS=Dr.hasDefaultHTMLNamespace,_S=Dr.isHTMLMimeType,qS=Dr.isValidMimeType,_y=Dr.MIME_TYPE,Lf=Dr.NAMESPACE,jy=MS.ParseError,FS=LS.XMLReader;function qy(t){return t.replace(/\r[\n\u0085]/g,`
142
+ `).replace(/[\r\u0085\u2028\u2029]/g,`
143
+ `)}function Fy(t){if(t=t||{},t.locator===void 0&&(t.locator=!0),this.assign=t.assign||Dr.assign,this.domHandler=t.domHandler||Za,this.onError=t.onError||t.errorHandler,t.errorHandler&&typeof t.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");t.errorHandler&&t.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=t.normalizeLineEndings||qy,this.locator=!!t.locator,this.xmlns=this.assign(Object.create(null),t.xmlns)}Fy.prototype.parseFromString=function(t,e){if(!qS(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var n=this.assign(Object.create(null),this.xmlns),r=Ly.XML_ENTITIES,i=n[""]||null;PS(e)?(r=Ly.HTML_ENTITIES,i=Lf.HTML):e===_y.XML_SVG_IMAGE&&(i=Lf.SVG),n[""]=i,n.xml=n.xml||Lf.XML;var s=new this.domHandler({mimeType:e,defaultNamespace:i,onError:this.onError}),o=this.locator?{}:void 0;this.locator&&s.setDocumentLocator(o);var a=new FS;a.errorHandler=s,a.domBuilder=s;var l=!Dr.isHTMLMimeType(e);return l&&typeof t!="string"&&a.errorHandler.fatalError("source is not a string"),a.parse(this.normalizeLineEndings(String(t)),n,r),s.doc.documentElement||a.errorHandler.fatalError("missing root element"),s.doc};function Za(t){var e=t||{};this.mimeType=e.mimeType||_y.XML_APPLICATION,this.defaultNamespace=e.defaultNamespace||null,this.cdata=!1,this.currentElement=void 0,this.doc=void 0,this.locator=void 0,this.onError=e.onError}function $i(t,e){e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber}Za.prototype={startDocument:function(){var t=new jS;this.doc=_S(this.mimeType)?t.createHTMLDocument(!1):t.createDocument(this.defaultNamespace,"")},startElement:function(t,e,n,r){var i=this.doc,s=i.createElementNS(t,n||e),o=r.length;Ja(this,s),this.currentElement=s,this.locator&&$i(this.locator,s);for(var a=0;a<o;a++){var t=r.getURI(a),l=r.getValue(a),n=r.getQName(a),c=i.createAttributeNS(t,n);this.locator&&$i(r.getLocator(a),c),c.value=c.nodeValue=l,s.setAttributeNode(c)}},endElement:function(t,e,n){this.currentElement=this.currentElement.parentNode},startPrefixMapping:function(t,e){},endPrefixMapping:function(t){},processingInstruction:function(t,e){var n=this.doc.createProcessingInstruction(t,e);this.locator&&$i(this.locator,n),Ja(this,n)},ignorableWhitespace:function(t,e,n){},characters:function(t,e,n){if(t=Py.apply(this,arguments),t){if(this.cdata)var r=this.doc.createCDATASection(t);else var r=this.doc.createTextNode(t);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(t)&&this.doc.appendChild(r),this.locator&&$i(this.locator,r)}},skippedEntity:function(t){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(t){t&&(t.lineNumber=0),this.locator=t},comment:function(t,e,n){t=Py.apply(this,arguments);var r=this.doc.createComment(t);this.locator&&$i(this.locator,r),Ja(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(t,e,n,r){var i=this.doc.implementation;if(i&&i.createDocumentType){var s=i.createDocumentType(t,e,n,r);this.locator&&$i(this.locator,s),Ja(this,s),this.doc.doctype=s}},reportError:function(t,e){if(typeof this.onError=="function")try{this.onError(t,e,this)}catch(n){throw new jy("Reporting "+t+' "'+e+'" caused '+n,this.locator)}else console.error("[xmldom "+t+"] "+e,BS(this.locator))},warning:function(t){this.reportError("warning",t)},error:function(t){this.reportError("error",t)},fatalError:function(t){throw this.reportError("fatalError",t),new jy(t,this.locator)}};function BS(t){if(t)return`
144
+ @#[line:`+t.lineNumber+",col:"+t.columnNumber+"]"}function Py(t,e,n){return typeof t=="string"?t.substr(e,n):t.length>=e+n||e?new java.lang.String(t,e,n)+"":t}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(t){Za.prototype[t]=function(){return null}});function Ja(t,e){t.currentElement?t.currentElement.appendChild(e):t.doc.appendChild(e)}function VS(t){if(t==="error")throw"onErrorStopParsing"}function zS(){throw"onWarningStopParsing"}vi.__DOMHandler=Za;vi.DOMParser=Fy;vi.normalizeLineEndings=qy;vi.onErrorStopParsing=VS;vi.onWarningStopParsing=zS});var Vy=V(be=>{"use strict";var xi=xr();be.assign=xi.assign;be.hasDefaultHTMLNamespace=xi.hasDefaultHTMLNamespace;be.isHTMLMimeType=xi.isHTMLMimeType;be.isValidMimeType=xi.isValidMimeType;be.MIME_TYPE=xi.MIME_TYPE;be.NAMESPACE=xi.NAMESPACE;var Qa=Ps();be.DOMException=Qa.DOMException;be.DOMExceptionName=Qa.DOMExceptionName;be.ExceptionCode=Qa.ExceptionCode;be.ParseError=Qa.ParseError;var Ge=Of();be.Attr=Ge.Attr;be.CDATASection=Ge.CDATASection;be.CharacterData=Ge.CharacterData;be.Comment=Ge.Comment;be.Document=Ge.Document;be.DocumentFragment=Ge.DocumentFragment;be.DocumentType=Ge.DocumentType;be.DOMImplementation=Ge.DOMImplementation;be.Element=Ge.Element;be.Entity=Ge.Entity;be.EntityReference=Ge.EntityReference;be.LiveNodeList=Ge.LiveNodeList;be.NamedNodeMap=Ge.NamedNodeMap;be.Node=Ge.Node;be.NodeList=Ge.NodeList;be.Notation=Ge.Notation;be.ProcessingInstruction=Ge.ProcessingInstruction;be.Text=Ge.Text;be.XMLSerializer=Ge.XMLSerializer;var Xa=By();be.DOMParser=Xa.DOMParser;be.normalizeLineEndings=Xa.normalizeLineEndings;be.onErrorStopParsing=Xa.onErrorStopParsing;be.onWarningStopParsing=Xa.onWarningStopParsing});var At=require("node:fs"),Cn=require("node:path");var K=class extends Error{diagnostic;constructor(e,n,r,i){super(n),this.diagnostic={severity:"error",code:e,message:n,pos:r,path:i}}};function op(t){let n=`${t.pos?`${t.pos.file}:${t.pos.line}:${t.pos.col} `:""}${t.severity} ${t.code}: ${t.message}`;return t.path&&t.path.length?`${n}
145
+ ${t.path.join(" \u203A ")}`:n}var Tt=class{items=[];error(e,n,r,i){this.items.push({severity:"error",code:e,message:n,pos:r,path:i})}warn(e,n,r,i){this.items.push({severity:"warning",code:e,message:n,pos:r,path:i})}add(e){this.items.push(e)}get errors(){return this.items.filter(e=>e.severity==="error")}get warnings(){return this.items.filter(e=>e.severity==="warning")}get ok(){return this.errors.length===0}};function ue(t,e){let n,r=1/0;for(let i of e){let s=Pk(t,i);s<r&&(r=s,n=i)}return n!==void 0&&r<=Math.max(1,Math.floor(t.length/3))?n:void 0}function Pk(t,e){let n=Array.from({length:t.length+1},(r,i)=>[i,...Array(e.length).fill(0)]);for(let r=0;r<=e.length;r++)n[0][r]=r;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++)n[r][i]=Math.min(n[r-1][i]+1,n[r][i-1]+1,n[r-1][i-1]+(t[r-1]===e[i-1]?0:1)),r>1&&i>1&&t[r-1]===e[i-2]&&t[r-2]===e[i-1]&&(n[r][i]=Math.min(n[r][i],n[r-2][i-2]+1));return n[t.length][e.length]}function Ie(t,e){let n=ue(t,e);return n?` (did you mean "${n}"?)`:""}var _k={};function wl(t,e){let n=e||_k,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return lp(t,r,i)}function lp(t,e,n){if(qk(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return ap(t.children,e,n)}return Array.isArray(t)?ap(t,e,n):""}function ap(t,e,n){let r=[],i=-1;for(;++i<t.length;)r[i]=lp(t[i],e,n);return r.join("")}function qk(t){return!!(t&&typeof t=="object")}var $l={AElig:"\xC6",AMP:"&",Aacute:"\xC1",Abreve:"\u0102",Acirc:"\xC2",Acy:"\u0410",Afr:"\u{1D504}",Agrave:"\xC0",Alpha:"\u0391",Amacr:"\u0100",And:"\u2A53",Aogon:"\u0104",Aopf:"\u{1D538}",ApplyFunction:"\u2061",Aring:"\xC5",Ascr:"\u{1D49C}",Assign:"\u2254",Atilde:"\xC3",Auml:"\xC4",Backslash:"\u2216",Barv:"\u2AE7",Barwed:"\u2306",Bcy:"\u0411",Because:"\u2235",Bernoullis:"\u212C",Beta:"\u0392",Bfr:"\u{1D505}",Bopf:"\u{1D539}",Breve:"\u02D8",Bscr:"\u212C",Bumpeq:"\u224E",CHcy:"\u0427",COPY:"\xA9",Cacute:"\u0106",Cap:"\u22D2",CapitalDifferentialD:"\u2145",Cayleys:"\u212D",Ccaron:"\u010C",Ccedil:"\xC7",Ccirc:"\u0108",Cconint:"\u2230",Cdot:"\u010A",Cedilla:"\xB8",CenterDot:"\xB7",Cfr:"\u212D",Chi:"\u03A7",CircleDot:"\u2299",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",Colon:"\u2237",Colone:"\u2A74",Congruent:"\u2261",Conint:"\u222F",ContourIntegral:"\u222E",Copf:"\u2102",Coproduct:"\u2210",CounterClockwiseContourIntegral:"\u2233",Cross:"\u2A2F",Cscr:"\u{1D49E}",Cup:"\u22D3",CupCap:"\u224D",DD:"\u2145",DDotrahd:"\u2911",DJcy:"\u0402",DScy:"\u0405",DZcy:"\u040F",Dagger:"\u2021",Darr:"\u21A1",Dashv:"\u2AE4",Dcaron:"\u010E",Dcy:"\u0414",Del:"\u2207",Delta:"\u0394",Dfr:"\u{1D507}",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",Diamond:"\u22C4",DifferentialD:"\u2146",Dopf:"\u{1D53B}",Dot:"\xA8",DotDot:"\u20DC",DotEqual:"\u2250",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",Downarrow:"\u21D3",Dscr:"\u{1D49F}",Dstrok:"\u0110",ENG:"\u014A",ETH:"\xD0",Eacute:"\xC9",Ecaron:"\u011A",Ecirc:"\xCA",Ecy:"\u042D",Edot:"\u0116",Efr:"\u{1D508}",Egrave:"\xC8",Element:"\u2208",Emacr:"\u0112",EmptySmallSquare:"\u25FB",EmptyVerySmallSquare:"\u25AB",Eogon:"\u0118",Eopf:"\u{1D53C}",Epsilon:"\u0395",Equal:"\u2A75",EqualTilde:"\u2242",Equilibrium:"\u21CC",Escr:"\u2130",Esim:"\u2A73",Eta:"\u0397",Euml:"\xCB",Exists:"\u2203",ExponentialE:"\u2147",Fcy:"\u0424",Ffr:"\u{1D509}",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",Fopf:"\u{1D53D}",ForAll:"\u2200",Fouriertrf:"\u2131",Fscr:"\u2131",GJcy:"\u0403",GT:">",Gamma:"\u0393",Gammad:"\u03DC",Gbreve:"\u011E",Gcedil:"\u0122",Gcirc:"\u011C",Gcy:"\u0413",Gdot:"\u0120",Gfr:"\u{1D50A}",Gg:"\u22D9",Gopf:"\u{1D53E}",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\u{1D4A2}",Gt:"\u226B",HARDcy:"\u042A",Hacek:"\u02C7",Hat:"^",Hcirc:"\u0124",Hfr:"\u210C",HilbertSpace:"\u210B",Hopf:"\u210D",HorizontalLine:"\u2500",Hscr:"\u210B",Hstrok:"\u0126",HumpDownHump:"\u224E",HumpEqual:"\u224F",IEcy:"\u0415",IJlig:"\u0132",IOcy:"\u0401",Iacute:"\xCD",Icirc:"\xCE",Icy:"\u0418",Idot:"\u0130",Ifr:"\u2111",Igrave:"\xCC",Im:"\u2111",Imacr:"\u012A",ImaginaryI:"\u2148",Implies:"\u21D2",Int:"\u222C",Integral:"\u222B",Intersection:"\u22C2",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",Iogon:"\u012E",Iopf:"\u{1D540}",Iota:"\u0399",Iscr:"\u2110",Itilde:"\u0128",Iukcy:"\u0406",Iuml:"\xCF",Jcirc:"\u0134",Jcy:"\u0419",Jfr:"\u{1D50D}",Jopf:"\u{1D541}",Jscr:"\u{1D4A5}",Jsercy:"\u0408",Jukcy:"\u0404",KHcy:"\u0425",KJcy:"\u040C",Kappa:"\u039A",Kcedil:"\u0136",Kcy:"\u041A",Kfr:"\u{1D50E}",Kopf:"\u{1D542}",Kscr:"\u{1D4A6}",LJcy:"\u0409",LT:"<",Lacute:"\u0139",Lambda:"\u039B",Lang:"\u27EA",Laplacetrf:"\u2112",Larr:"\u219E",Lcaron:"\u013D",Lcedil:"\u013B",Lcy:"\u041B",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",LeftRightArrow:"\u2194",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",Leftarrow:"\u21D0",Leftrightarrow:"\u21D4",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",LessLess:"\u2AA1",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",Lfr:"\u{1D50F}",Ll:"\u22D8",Lleftarrow:"\u21DA",Lmidot:"\u013F",LongLeftArrow:"\u27F5",LongLeftRightArrow:"\u27F7",LongRightArrow:"\u27F6",Longleftarrow:"\u27F8",Longleftrightarrow:"\u27FA",Longrightarrow:"\u27F9",Lopf:"\u{1D543}",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",Lscr:"\u2112",Lsh:"\u21B0",Lstrok:"\u0141",Lt:"\u226A",Map:"\u2905",Mcy:"\u041C",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\u{1D510}",MinusPlus:"\u2213",Mopf:"\u{1D544}",Mscr:"\u2133",Mu:"\u039C",NJcy:"\u040A",Nacute:"\u0143",Ncaron:"\u0147",Ncedil:"\u0145",Ncy:"\u041D",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
146
+ `,Nfr:"\u{1D511}",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",Not:"\u2AEC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",Nscr:"\u{1D4A9}",Ntilde:"\xD1",Nu:"\u039D",OElig:"\u0152",Oacute:"\xD3",Ocirc:"\xD4",Ocy:"\u041E",Odblac:"\u0150",Ofr:"\u{1D512}",Ograve:"\xD2",Omacr:"\u014C",Omega:"\u03A9",Omicron:"\u039F",Oopf:"\u{1D546}",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",Or:"\u2A54",Oscr:"\u{1D4AA}",Oslash:"\xD8",Otilde:"\xD5",Otimes:"\u2A37",Ouml:"\xD6",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",PartialD:"\u2202",Pcy:"\u041F",Pfr:"\u{1D513}",Phi:"\u03A6",Pi:"\u03A0",PlusMinus:"\xB1",Poincareplane:"\u210C",Popf:"\u2119",Pr:"\u2ABB",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",Prime:"\u2033",Product:"\u220F",Proportion:"\u2237",Proportional:"\u221D",Pscr:"\u{1D4AB}",Psi:"\u03A8",QUOT:'"',Qfr:"\u{1D514}",Qopf:"\u211A",Qscr:"\u{1D4AC}",RBarr:"\u2910",REG:"\xAE",Racute:"\u0154",Rang:"\u27EB",Rarr:"\u21A0",Rarrtl:"\u2916",Rcaron:"\u0158",Rcedil:"\u0156",Rcy:"\u0420",Re:"\u211C",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",Rfr:"\u211C",Rho:"\u03A1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",Rightarrow:"\u21D2",Ropf:"\u211D",RoundImplies:"\u2970",Rrightarrow:"\u21DB",Rscr:"\u211B",Rsh:"\u21B1",RuleDelayed:"\u29F4",SHCHcy:"\u0429",SHcy:"\u0428",SOFTcy:"\u042C",Sacute:"\u015A",Sc:"\u2ABC",Scaron:"\u0160",Scedil:"\u015E",Scirc:"\u015C",Scy:"\u0421",Sfr:"\u{1D516}",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",Sigma:"\u03A3",SmallCircle:"\u2218",Sopf:"\u{1D54A}",Sqrt:"\u221A",Square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",Sscr:"\u{1D4AE}",Star:"\u22C6",Sub:"\u22D0",Subset:"\u22D0",SubsetEqual:"\u2286",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",SuchThat:"\u220B",Sum:"\u2211",Sup:"\u22D1",Superset:"\u2283",SupersetEqual:"\u2287",Supset:"\u22D1",THORN:"\xDE",TRADE:"\u2122",TSHcy:"\u040B",TScy:"\u0426",Tab:" ",Tau:"\u03A4",Tcaron:"\u0164",Tcedil:"\u0162",Tcy:"\u0422",Tfr:"\u{1D517}",Therefore:"\u2234",Theta:"\u0398",ThickSpace:"\u205F\u200A",ThinSpace:"\u2009",Tilde:"\u223C",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",Topf:"\u{1D54B}",TripleDot:"\u20DB",Tscr:"\u{1D4AF}",Tstrok:"\u0166",Uacute:"\xDA",Uarr:"\u219F",Uarrocir:"\u2949",Ubrcy:"\u040E",Ubreve:"\u016C",Ucirc:"\xDB",Ucy:"\u0423",Udblac:"\u0170",Ufr:"\u{1D518}",Ugrave:"\xD9",Umacr:"\u016A",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",Uopf:"\u{1D54C}",UpArrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",UpEquilibrium:"\u296E",UpTee:"\u22A5",UpTeeArrow:"\u21A5",Uparrow:"\u21D1",Updownarrow:"\u21D5",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",Upsilon:"\u03A5",Uring:"\u016E",Uscr:"\u{1D4B0}",Utilde:"\u0168",Uuml:"\xDC",VDash:"\u22AB",Vbar:"\u2AEB",Vcy:"\u0412",Vdash:"\u22A9",Vdashl:"\u2AE6",Vee:"\u22C1",Verbar:"\u2016",Vert:"\u2016",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\u{1D519}",Vopf:"\u{1D54D}",Vscr:"\u{1D4B1}",Vvdash:"\u22AA",Wcirc:"\u0174",Wedge:"\u22C0",Wfr:"\u{1D51A}",Wopf:"\u{1D54E}",Wscr:"\u{1D4B2}",Xfr:"\u{1D51B}",Xi:"\u039E",Xopf:"\u{1D54F}",Xscr:"\u{1D4B3}",YAcy:"\u042F",YIcy:"\u0407",YUcy:"\u042E",Yacute:"\xDD",Ycirc:"\u0176",Ycy:"\u042B",Yfr:"\u{1D51C}",Yopf:"\u{1D550}",Yscr:"\u{1D4B4}",Yuml:"\u0178",ZHcy:"\u0416",Zacute:"\u0179",Zcaron:"\u017D",Zcy:"\u0417",Zdot:"\u017B",ZeroWidthSpace:"\u200B",Zeta:"\u0396",Zfr:"\u2128",Zopf:"\u2124",Zscr:"\u{1D4B5}",aacute:"\xE1",abreve:"\u0103",ac:"\u223E",acE:"\u223E\u0333",acd:"\u223F",acirc:"\xE2",acute:"\xB4",acy:"\u0430",aelig:"\xE6",af:"\u2061",afr:"\u{1D51E}",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",alpha:"\u03B1",amacr:"\u0101",amalg:"\u2A3F",amp:"&",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",aogon:"\u0105",aopf:"\u{1D552}",ap:"\u2248",apE:"\u2A70",apacir:"\u2A6F",ape:"\u224A",apid:"\u224B",apos:"'",approx:"\u2248",approxeq:"\u224A",aring:"\xE5",ascr:"\u{1D4B6}",ast:"*",asymp:"\u2248",asympeq:"\u224D",atilde:"\xE3",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",bNot:"\u2AED",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",barvee:"\u22BD",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",beta:"\u03B2",beth:"\u2136",between:"\u226C",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bnot:"\u2310",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxDL:"\u2557",boxDR:"\u2554",boxDl:"\u2556",boxDr:"\u2553",boxH:"\u2550",boxHD:"\u2566",boxHU:"\u2569",boxHd:"\u2564",boxHu:"\u2567",boxUL:"\u255D",boxUR:"\u255A",boxUl:"\u255C",boxUr:"\u2559",boxV:"\u2551",boxVH:"\u256C",boxVL:"\u2563",boxVR:"\u2560",boxVh:"\u256B",boxVl:"\u2562",boxVr:"\u255F",boxbox:"\u29C9",boxdL:"\u2555",boxdR:"\u2552",boxdl:"\u2510",boxdr:"\u250C",boxh:"\u2500",boxhD:"\u2565",boxhU:"\u2568",boxhd:"\u252C",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxuL:"\u255B",boxuR:"\u2558",boxul:"\u2518",boxur:"\u2514",boxv:"\u2502",boxvH:"\u256A",boxvL:"\u2561",boxvR:"\u255E",boxvh:"\u253C",boxvl:"\u2524",boxvr:"\u251C",bprime:"\u2035",breve:"\u02D8",brvbar:"\xA6",bscr:"\u{1D4B7}",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",bumpeq:"\u224F",cacute:"\u0107",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",ccaps:"\u2A4D",ccaron:"\u010D",ccedil:"\xE7",ccirc:"\u0109",ccups:"\u2A4C",ccupssm:"\u2A50",cdot:"\u010B",cedil:"\xB8",cemptyv:"\u29B2",cent:"\xA2",centerdot:"\xB7",cfr:"\u{1D520}",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",chi:"\u03C7",cir:"\u25CB",cirE:"\u29C3",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledR:"\xAE",circledS:"\u24C8",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",clubs:"\u2663",clubsuit:"\u2663",colon:":",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",conint:"\u222E",copf:"\u{1D554}",coprod:"\u2210",copy:"\xA9",copysr:"\u2117",crarr:"\u21B5",cross:"\u2717",cscr:"\u{1D4B8}",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",cup:"\u222A",cupbrcap:"\u2A48",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",dArr:"\u21D3",dHar:"\u2965",dagger:"\u2020",daleth:"\u2138",darr:"\u2193",dash:"\u2010",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",dcaron:"\u010F",dcy:"\u0434",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",ddotseq:"\u2A77",deg:"\xB0",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",dfr:"\u{1D521}",dharl:"\u21C3",dharr:"\u21C2",diam:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",dopf:"\u{1D555}",dot:"\u02D9",doteq:"\u2250",doteqdot:"\u2251",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",downarrow:"\u2193",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",dscr:"\u{1D4B9}",dscy:"\u0455",dsol:"\u29F6",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",dzcy:"\u045F",dzigrarr:"\u27FF",eDDot:"\u2A77",eDot:"\u2251",eacute:"\xE9",easter:"\u2A6E",ecaron:"\u011B",ecir:"\u2256",ecirc:"\xEA",ecolon:"\u2255",ecy:"\u044D",edot:"\u0117",ee:"\u2147",efDot:"\u2252",efr:"\u{1D522}",eg:"\u2A9A",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",emptyv:"\u2205",emsp13:"\u2004",emsp14:"\u2005",emsp:"\u2003",eng:"\u014B",ensp:"\u2002",eogon:"\u0119",eopf:"\u{1D556}",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",equals:"=",equest:"\u225F",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erDot:"\u2253",erarr:"\u2971",escr:"\u212F",esdot:"\u2250",esim:"\u2242",eta:"\u03B7",eth:"\xF0",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",expectation:"\u2130",exponentiale:"\u2147",fallingdotseq:"\u2252",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",ffr:"\u{1D523}",filig:"\uFB01",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",fopf:"\u{1D557}",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",fscr:"\u{1D4BB}",gE:"\u2267",gEl:"\u2A8C",gacute:"\u01F5",gamma:"\u03B3",gammad:"\u03DD",gap:"\u2A86",gbreve:"\u011F",gcirc:"\u011D",gcy:"\u0433",gdot:"\u0121",ge:"\u2265",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",gfr:"\u{1D524}",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",gjcy:"\u0453",gl:"\u2277",glE:"\u2A92",gla:"\u2AA5",glj:"\u2AA4",gnE:"\u2269",gnap:"\u2A8A",gnapprox:"\u2A8A",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",gopf:"\u{1D558}",grave:"`",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",hArr:"\u21D4",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",hardcy:"\u044A",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",hbar:"\u210F",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",hfr:"\u{1D525}",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",hopf:"\u{1D559}",horbar:"\u2015",hscr:"\u{1D4BD}",hslash:"\u210F",hstrok:"\u0127",hybull:"\u2043",hyphen:"\u2010",iacute:"\xED",ic:"\u2063",icirc:"\xEE",icy:"\u0438",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",ifr:"\u{1D526}",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",ijlig:"\u0133",imacr:"\u012B",image:"\u2111",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",int:"\u222B",intcal:"\u22BA",integers:"\u2124",intercal:"\u22BA",intlarhk:"\u2A17",intprod:"\u2A3C",iocy:"\u0451",iogon:"\u012F",iopf:"\u{1D55A}",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",iscr:"\u{1D4BE}",isin:"\u2208",isinE:"\u22F9",isindot:"\u22F5",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",itilde:"\u0129",iukcy:"\u0456",iuml:"\xEF",jcirc:"\u0135",jcy:"\u0439",jfr:"\u{1D527}",jmath:"\u0237",jopf:"\u{1D55B}",jscr:"\u{1D4BF}",jsercy:"\u0458",jukcy:"\u0454",kappa:"\u03BA",kappav:"\u03F0",kcedil:"\u0137",kcy:"\u043A",kfr:"\u{1D528}",kgreen:"\u0138",khcy:"\u0445",kjcy:"\u045C",kopf:"\u{1D55C}",kscr:"\u{1D4C0}",lAarr:"\u21DA",lArr:"\u21D0",lAtail:"\u291B",lBarr:"\u290E",lE:"\u2266",lEg:"\u2A8B",lHar:"\u2962",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",lambda:"\u03BB",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",laquo:"\xAB",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",lcaron:"\u013E",lcedil:"\u013C",lceil:"\u2308",lcub:"{",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",le:"\u2264",leftarrow:"\u2190",leftarrowtail:"\u21A2",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",leftthreetimes:"\u22CB",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",lessgtr:"\u2276",lesssim:"\u2272",lfisht:"\u297C",lfloor:"\u230A",lfr:"\u{1D529}",lg:"\u2276",lgE:"\u2A91",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",ljcy:"\u0459",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",llhard:"\u296B",lltri:"\u25FA",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnE:"\u2268",lnap:"\u2A89",lnapprox:"\u2A89",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",longleftarrow:"\u27F5",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",lopf:"\u{1D55D}",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",lscr:"\u{1D4C1}",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",lstrok:"\u0142",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltrPar:"\u2996",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",mDDot:"\u223A",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",mcy:"\u043C",mdash:"\u2014",measuredangle:"\u2221",mfr:"\u{1D52A}",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",mopf:"\u{1D55E}",mp:"\u2213",mscr:"\u{1D4C2}",mstpos:"\u223E",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nGg:"\u22D9\u0338",nGt:"\u226B\u20D2",nGtv:"\u226B\u0338",nLeftarrow:"\u21CD",nLeftrightarrow:"\u21CE",nLl:"\u22D8\u0338",nLt:"\u226A\u20D2",nLtv:"\u226A\u0338",nRightarrow:"\u21CF",nVDash:"\u22AF",nVdash:"\u22AE",nabla:"\u2207",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",ncaron:"\u0148",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",neArr:"\u21D7",nearhk:"\u2924",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",nexist:"\u2204",nexists:"\u2204",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",ngsim:"\u2275",ngt:"\u226F",ngtr:"\u226F",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",njcy:"\u045A",nlArr:"\u21CD",nlE:"\u2266\u0338",nlarr:"\u219A",nldr:"\u2025",nle:"\u2270",nleftarrow:"\u219A",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nlsim:"\u2274",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nmid:"\u2224",nopf:"\u{1D55F}",not:"\xAC",notin:"\u2209",notinE:"\u22F9\u0338",notindot:"\u22F5\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvDash:"\u22AD",nvHarr:"\u2904",nvap:"\u224D\u20D2",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwArr:"\u21D6",nwarhk:"\u2923",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",oS:"\u24C8",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",ocirc:"\xF4",ocy:"\u043E",odash:"\u229D",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",oelig:"\u0153",ofcir:"\u29BF",ofr:"\u{1D52C}",ogon:"\u02DB",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",omacr:"\u014D",omega:"\u03C9",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",oopf:"\u{1D560}",opar:"\u29B7",operp:"\u29B9",oplus:"\u2295",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oscr:"\u2134",oslash:"\xF8",osol:"\u2298",otilde:"\xF5",otimes:"\u2297",otimesas:"\u2A36",ouml:"\xF6",ovbar:"\u233D",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",pfr:"\u{1D52D}",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",pointint:"\u2A15",popf:"\u{1D561}",pound:"\xA3",pr:"\u227A",prE:"\u2AB3",prap:"\u2AB7",prcue:"\u227C",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",prime:"\u2032",primes:"\u2119",prnE:"\u2AB5",prnap:"\u2AB9",prnsim:"\u22E8",prod:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",pscr:"\u{1D4C5}",psi:"\u03C8",puncsp:"\u2008",qfr:"\u{1D52E}",qint:"\u2A0C",qopf:"\u{1D562}",qprime:"\u2057",qscr:"\u{1D4C6}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",quot:'"',rAarr:"\u21DB",rArr:"\u21D2",rAtail:"\u291C",rBarr:"\u290F",rHar:"\u2964",race:"\u223D\u0331",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",rarrtl:"\u21A3",rarrw:"\u219D",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",rcaron:"\u0159",rcedil:"\u0157",rceil:"\u2309",rcub:"}",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",reg:"\xAE",rfisht:"\u297D",rfloor:"\u230B",rfr:"\u{1D52F}",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",rho:"\u03C1",rhov:"\u03F1",rightarrow:"\u2192",rightarrowtail:"\u21A3",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",rightthreetimes:"\u22CC",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",ropf:"\u{1D563}",roplus:"\u2A2E",rotimes:"\u2A35",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",rsaquo:"\u203A",rscr:"\u{1D4C7}",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",ruluhar:"\u2968",rx:"\u211E",sacute:"\u015B",sbquo:"\u201A",sc:"\u227B",scE:"\u2AB4",scap:"\u2AB8",scaron:"\u0161",sccue:"\u227D",sce:"\u2AB0",scedil:"\u015F",scirc:"\u015D",scnE:"\u2AB6",scnap:"\u2ABA",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",seArr:"\u21D8",searhk:"\u2925",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",sfr:"\u{1D530}",sfrown:"\u2322",sharp:"\u266F",shchcy:"\u0449",shcy:"\u0448",shortmid:"\u2223",shortparallel:"\u2225",shy:"\xAD",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",sopf:"\u{1D564}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",square:"\u25A1",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",sscr:"\u{1D4C8}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",sub:"\u2282",subE:"\u2AC5",subdot:"\u2ABD",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",sum:"\u2211",sung:"\u266A",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",sup:"\u2283",supE:"\u2AC6",supdot:"\u2ABE",supdsub:"\u2AD8",supe:"\u2287",supedot:"\u2AC4",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swArr:"\u21D9",swarhk:"\u2926",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",target:"\u2316",tau:"\u03C4",tbrk:"\u23B4",tcaron:"\u0165",tcedil:"\u0163",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",tfr:"\u{1D531}",there4:"\u2234",therefore:"\u2234",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",thinsp:"\u2009",thkap:"\u2248",thksim:"\u223C",thorn:"\xFE",tilde:"\u02DC",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",topf:"\u{1D565}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",tscr:"\u{1D4C9}",tscy:"\u0446",tshcy:"\u045B",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",uArr:"\u21D1",uHar:"\u2963",uacute:"\xFA",uarr:"\u2191",ubrcy:"\u045E",ubreve:"\u016D",ucirc:"\xFB",ucy:"\u0443",udarr:"\u21C5",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",ufr:"\u{1D532}",ugrave:"\xF9",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",umacr:"\u016B",uml:"\xA8",uogon:"\u0173",uopf:"\u{1D566}",uparrow:"\u2191",updownarrow:"\u2195",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",upsi:"\u03C5",upsih:"\u03D2",upsilon:"\u03C5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",uring:"\u016F",urtri:"\u25F9",uscr:"\u{1D4CA}",utdot:"\u22F0",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",uuml:"\xFC",uwangle:"\u29A7",vArr:"\u21D5",vBar:"\u2AE8",vBarv:"\u2AE9",vDash:"\u22A8",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",vcy:"\u0432",vdash:"\u22A2",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",verbar:"|",vert:"|",vfr:"\u{1D533}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",vopf:"\u{1D567}",vprop:"\u221D",vrtri:"\u22B3",vscr:"\u{1D4CB}",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",vzigzag:"\u299A",wcirc:"\u0175",wedbar:"\u2A5F",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",wfr:"\u{1D534}",wopf:"\u{1D568}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",wscr:"\u{1D4CC}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",xfr:"\u{1D535}",xhArr:"\u27FA",xharr:"\u27F7",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",xopf:"\u{1D569}",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",xscr:"\u{1D4CD}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",yacute:"\xFD",yacy:"\u044F",ycirc:"\u0177",ycy:"\u044B",yen:"\xA5",yfr:"\u{1D536}",yicy:"\u0457",yopf:"\u{1D56A}",yscr:"\u{1D4CE}",yucy:"\u044E",yuml:"\xFF",zacute:"\u017A",zcaron:"\u017E",zcy:"\u0437",zdot:"\u017C",zeetrf:"\u2128",zeta:"\u03B6",zfr:"\u{1D537}",zhcy:"\u0436",zigrarr:"\u21DD",zopf:"\u{1D56B}",zscr:"\u{1D4CF}",zwj:"\u200D",zwnj:"\u200C"};var Fk={}.hasOwnProperty;function Pr(t){return Fk.call($l,t)?$l[t]:!1}function Ye(t,e,n,r){let i=t.length,s=0,o;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(e,n),t.splice(...o);else for(n&&t.splice(e,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(e,0),t.splice(...o),s+=1e4,e+=1e4}function ot(t,e){return t.length>0?(Ye(t,t.length,0,e),t):e}var cp={}.hasOwnProperty;function up(t){let e={},n=-1;for(;++n<t.length;)Bk(e,t[n]);return e}function Bk(t,e){let n;for(n in e){let i=(cp.call(t,n)?t[n]:void 0)||(t[n]={}),s=e[n],o;if(s)for(o in s){cp.call(i,o)||(i[o]=[]);let a=s[o];Vk(i[o],Array.isArray(a)?a:a?[a]:[])}}}function Vk(t,e){let n=-1,r=[];for(;++n<e.length;)(e[n].add==="after"?t:r).push(e[n]);Ye(t,0,0,r)}function so(t,e){let n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"\uFFFD":String.fromCodePoint(n)}function it(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var wt=On(/[A-Za-z]/),at=On(/[\dA-Za-z]/),fp=On(/[#-'*+\--9=?A-Z^-~]/);function ji(t){return t!==null&&(t<32||t===127)}var Pi=On(/\d/),pp=On(/[\dA-Fa-f]/),hp=On(/[!-/:-@[-`{-~]/);function B(t){return t!==null&&t<-2}function we(t){return t!==null&&(t<0||t===32)}function Z(t){return t===-2||t===-1||t===32}var dp=On(new RegExp("\\p{P}|\\p{S}","u")),mp=On(/\s/);function On(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function J(t,e,n,r){let i=r?r-1:1/0,s=0;return o;function o(l){return Z(l)?(t.enter(n),a(l)):e(l)}function a(l){return Z(l)&&s++<i?(t.consume(l),a):(t.exit(n),e(l))}}function vl(t,e,n,r,i,s){let o=0;return a;function a(u){return s>0&&Z(u)?(t.enter(r),l(u)):c(u)}function l(u){return Z(u)&&o<s?(t.consume(u),o++,l):(t.exit(r),c(u))}function c(u){return o>=i?e(u):n(u)}}var gp={tokenize:zk};function zk(t){let e=t.attempt(this.parser.constructs.contentInitial,r,i),n;return e;function r(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),J(t,e,"linePrefix")}function i(a){return t.enter("paragraph"),s(a)}function s(a){let l=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(a);return}return B(a)?(t.consume(a),t.exit("chunkText"),s):(t.consume(a),o)}}var yn=class{constructor(){this.index=new Map,this.map=[]}add(e,n,r){yp(this,e,n,r,!1)}addBefore(e,n,r){yp(this,e,n,r,!0)}consume(e){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length,r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(let s of i)e.push(s);i=r.pop()}this.map.length=0,this.index.clear()}};function yp(t,e,n,r,i){if(n===0&&r.length===0)return;let s=t.index.get(e);if(s){s[1]+=n,i?(r.push(...s[2]),s[2]=r):s[2].push(...r);return}let o=[e,n,r];t.map.push(o),t.index.set(e,o)}var bp={tokenize:Uk},kp={tokenize:Wk};function Uk(t){let e=this,n=[],r=0,i,s,o;return a;function a(b){if(r<n.length){let k=n[r];return e.containerState=k[1],t.attempt(k[0].continuation,l,c)(b)}return c(b)}function l(b){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&$();let k=e.events.length,w=k,v;for(;w--;)if(e.events[w][0]==="exit"&&e.events[w][1].type==="chunkFlow"){v=e.events[w][1].end;break}y(r);let D=k;for(;D<e.events.length;)e.events[D][1].end={...v},D++;let I=new yn;return I.add(w+1,0,e.events.slice(k)),I.add(k,D-k,[]),I.consume(e.events),c(b)}return a(b)}function c(b){if(r===n.length){if(!i)return p(b);if(i.currentConstruct&&i.currentConstruct.concrete)return d(b);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(kp,u,f)(b)}function u(b){return i&&$(),y(r),p(b)}function f(b){return e.parser.lazy[e.now().line]=r!==n.length,o=e.now().offset,d(b)}function p(b){return e.containerState={},t.attempt(kp,h,d)(b)}function h(b){return r++,n.push([e.currentConstruct,e.containerState]),p(b)}function d(b){if(b===null){i&&$(),y(0),t.consume(b);return}return i=i||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),m(b)}function m(b){if(b===null){g(t.exit("chunkFlow"),!0),y(0),t.consume(b);return}return B(b)?(t.consume(b),g(t.exit("chunkFlow")),r=0,e.interrupt=void 0,a):(t.consume(b),m)}function g(b,k){let w=e.sliceStream(b);if(k&&w.push(null),b.previous=s,s&&(s.next=b),s=b,i.defineSkip(b.start),i.write(w),e.parser.lazy[b.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<o&&(!i.events[v][1].end||i.events[v][1].end.offset>o))return;let D=e.events.length,I=D,L,T;for(;I--;)if(e.events[I][0]==="exit"&&e.events[I][1].type==="chunkFlow"){if(L){T=e.events[I][1].end;break}L=!0}for(y(r),v=D;v<e.events.length;)e.events[v][1].end={...T},v++;let G=new yn;G.add(I+1,0,e.events.slice(D)),G.add(D,v-D,[]),G.consume(e.events)}}function y(b){let k=n.length;for(;k-- >b;){let w=n[k];e.containerState=w[1],w[0].exit.call(e,t)}n.length=b}function $(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function Wk(t,e,n){return J(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function _r(t){if(t===null||we(t)||mp(t))return 1;if(dp(t))return 2}function Mn(t,e,n){let r=[],i=-1;for(;++i<t.length;){let s=t[i].resolveAll;s&&!r.includes(s)&&(e=s(e,n),r.push(s))}return e}var _i={name:"attention",resolveAll:Hk,tokenize:Gk};function Hk(t,e){let n=-1,r;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){let i=n;for(;i--;)if(t[i][0]==="exit"&&t[i][1].type==="attentionSequence"&&t[i][1]._open&&e.sliceSerialize(t[i][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[i][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[i][1].end.offset-t[i][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;let s=t[i][1].end.offset-t[i][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1,o={...t[i][1].end},a={...t[n][1].start};wp(o,-s),wp(a,s);let l={type:s>1?"strongSequence":"emphasisSequence",start:o,end:{...t[i][1].end}},c={type:s>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:a},u={type:s>1?"strongText":"emphasisText",start:{...t[i][1].end},end:{...t[n][1].start}},f={type:s>1?"strong":"emphasis",start:{...l.start},end:{...c.end}};t[i][1].end={...l.start},t[n][1].start={...c.end},r=[],t[i][1].end.offset-t[i][1].start.offset&&(r=ot(r,[["enter",t[i][1],e],["exit",t[i][1],e]])),r=ot(r,[["enter",f,e],["enter",l,e],["exit",l,e],["enter",u,e]]),r=ot(r,Mn(e.parser.constructs.insideSpan.null,t.slice(i+1,n),e)),r=ot(r,[["exit",u,e],["enter",c,e],["exit",c,e],["exit",f,e]]);let p=0;t[n][1].end.offset-t[n][1].start.offset&&(p=2,r=ot(r,[["enter",t[n][1],e],["exit",t[n][1],e]])),Ye(t,i-1,n-i+3,r),n=i+r.length-p-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function Gk(t,e){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=_r(r),s;return o;function o(l){return s=l,t.enter("attentionSequence"),a(l)}function a(l){if(l===s)return t.consume(l),a;let c=t.exit("attentionSequence"),u=_r(l),f=!u||u===2&&i||n.includes(l)&&l!==42&&l!==95,p=!i||i===2&&u||n.includes(r)&&r!==42&&r!==95;return c._open=!!(s===42?f:f&&(i||!p)),c._close=!!(s===42?p:p&&(u||!f)),e(l)}}function wp(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}var xl={name:"autolink",tokenize:Kk};function Kk(t,e,n){let r=0;return i;function i(h){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),s}function s(h){return wt(h)?(t.consume(h),o):h===64?n(h):c(h)}function o(h){return h===43||h===45||h===46||at(h)?(r=1,a(h)):c(h)}function a(h){return h===58?(t.consume(h),r=0,l):(h===43||h===45||h===46||at(h))&&r++<32?(t.consume(h),a):(r=0,c(h))}function l(h){return h===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.exit("autolink"),e):h===null||h===32||h===60||ji(h)?n(h):(t.consume(h),l)}function c(h){return h===64?(t.consume(h),u):fp(h)?(t.consume(h),c):n(h)}function u(h){return at(h)?f(h):n(h)}function f(h){return h===46?(t.consume(h),r=0,u):h===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.exit("autolink"),e):p(h)}function p(h){if((h===45||at(h))&&r++<63){let d=h===45?p:f;return t.consume(h),d}return n(h)}}var Xt={partial:!0,tokenize:Yk};function Yk(t,e,n){return r;function r(s){return Z(s)?J(t,i,"linePrefix")(s):i(s)}function i(s){return s===null||B(s)?e(s):n(s)}}var oo={continuation:{tokenize:Zk},exit:Qk,name:"blockQuote",tokenize:Jk};function Jk(t,e,n){let r=this;return i;function i(o){if(o===62){let a=r.containerState;return a.open||(t.enter("blockQuote",{_container:!0}),a.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(o),t.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Z(o)?(t.enter("blockQuotePrefixWhitespace"),t.consume(o),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(o))}}function Zk(t,e,n){let r=this;return i;function i(o){return Z(o)?J(t,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return t.attempt(oo,e,n)(o)}}function Qk(t){t.exit("blockQuote")}var ao={name:"characterEscape",tokenize:Xk};function Xk(t,e,n){return r;function r(s){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(s),t.exit("escapeMarker"),i}function i(s){return hp(s)?(t.enter("characterEscapeValue"),t.consume(s),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(s)}}var lo={name:"characterReference",tokenize:eb};function eb(t,e,n){let r=this,i=0,s,o;return a;function a(f){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(f),t.exit("characterReferenceMarker"),l}function l(f){return f===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(f),t.exit("characterReferenceMarkerNumeric"),c):(t.enter("characterReferenceValue"),s=31,o=at,u(f))}function c(f){return f===88||f===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(f),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),s=6,o=pp,u):(t.enter("characterReferenceValue"),s=7,o=Pi,u(f))}function u(f){if(f===59&&i){let p=t.exit("characterReferenceValue");return o===at&&!Pr(r.sliceSerialize(p))?n(f):(t.enter("characterReferenceMarker"),t.consume(f),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return o(f)&&i++<s?(t.consume(f),u):n(f)}}var qi={partial:!0,tokenize:tb};function tb(t,e,n){let r=this;return i;function i(o){return o===null?n(o):(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):e(o)}}var co={concrete:!0,name:"codeFenced",tokenize:nb};function nb(t,e,n){let r=this,i={partial:!0,tokenize:w},s=0,o=0,a;return l;function l(v){return c(v)}function c(v){let D=r.events[r.events.length-1];return s=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,a=v,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),u(v)}function u(v){return v===a?(o++,t.consume(v),u):o<3?n(v):(t.exit("codeFencedFenceSequence"),Z(v)?J(t,f,"whitespace")(v):f(v))}function f(v){return v===null||B(v)?(t.exit("codeFencedFence"),r.interrupt?e(v):t.check(qi,m,k)(v)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),p(v))}function p(v){return v===null||B(v)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),f(v)):Z(v)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),J(t,h,"whitespace")(v)):v===96&&v===a?n(v):(t.consume(v),p)}function h(v){return v===null||B(v)?f(v):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),d(v))}function d(v){return v===null||B(v)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),f(v)):v===96&&v===a?n(v):(t.consume(v),d)}function m(v){return t.attempt(i,k,g)(v)}function g(v){return t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),y}function y(v){return s>0&&Z(v)?J(t,$,"linePrefix",s+1)(v):$(v)}function $(v){return v===null||B(v)?t.check(qi,m,k)(v):(t.enter("codeFlowValue"),b(v))}function b(v){return v===null||B(v)?(t.exit("codeFlowValue"),$(v)):(t.consume(v),b)}function k(v){return t.exit("codeFenced"),e(v)}function w(v,D,I){let L=0;return T;function T(A){return v.enter("lineEnding"),v.consume(A),v.exit("lineEnding"),G}function G(A){return v.enter("codeFencedFence"),Z(A)?J(v,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):R(A)}function R(A){return A===a?(v.enter("codeFencedFenceSequence"),j(A)):I(A)}function j(A){return A===a?(L++,v.consume(A),j):L>=o?(v.exit("codeFencedFenceSequence"),Z(A)?J(v,O,"whitespace")(A):O(A)):I(A)}function O(A){return A===null||B(A)?(v.exit("codeFencedFence"),D(A)):I(A)}}}var Fi={name:"codeIndented",tokenize:ib},rb={partial:!0,tokenize:sb};function ib(t,e,n){return r;function r(a){return t.enter("codeIndented"),vl(t,i,n,"linePrefix",4,4)(a)}function i(a){return a===null?o(a):B(a)?t.attempt(rb,i,o)(a):(t.enter("codeFlowValue"),s(a))}function s(a){return a===null||B(a)?(t.exit("codeFlowValue"),i(a)):(t.consume(a),s)}function o(a){return t.exit("codeIndented"),e(a)}}function sb(t,e,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):B(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),i):vl(t,e,s,"linePrefix",4,4)(o)}function s(o){return B(o)?i(o):n(o)}}var El={name:"codeText",previous:ab,resolve:ob,tokenize:lb};function ob(t){let e=t.length-4,n=3,r,i;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(r=n;++r<e;)if(t[r][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(r=n-1,e++;++r<=e;)i===void 0?r!==e&&t[r][1].type!=="lineEnding"&&(i=r):(r===e||t[r][1].type==="lineEnding")&&(t[i][1].type="codeTextData",r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return t}function ab(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function lb(t,e,n){let r=this,i=0,s,o;return a;function a(p){return t.enter("codeText"),t.enter("codeTextSequence"),l(p)}function l(p){return p===96?(t.consume(p),i++,l):(t.exit("codeTextSequence"),c(p))}function c(p){return p===null?n(p):p===32?(t.enter("space"),t.consume(p),t.exit("space"),c):p===96?(o=t.enter("codeTextSequence"),s=0,f(p)):B(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),c):(t.enter("codeTextData"),u(p))}function u(p){return p===null||p===32||p===96||B(p)?(t.exit("codeTextData"),c(p)):(t.consume(p),u)}function f(p){return p===96?(t.consume(p),s++,f):s===i?(t.exit("codeTextSequence"),t.exit("codeText"),e(p)):(o.type="codeTextData",u(p))}}var uo=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){let r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,n,r){let i=n||0;this.setCursor(Math.trunc(e));let s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Bi(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Bi(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Bi(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let n=this.left.splice(e,Number.POSITIVE_INFINITY);Bi(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Bi(this.left,n.reverse())}}};function Bi(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function fo(t){let e={},n=-1,r,i,s,o,a,l,c,u=new uo(t);for(;++n<u.length;){for(;n in e;)n=e[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,cb(u,n)),n=e[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return Ye(t,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function cb(t,e){let n=t.get(e)[1],r=t.get(e)[2],i=e-1,s=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let a=o.events,l=[],c={},u,f,p=-1,h=n,d=0,m=0,g=[m];for(;h;){for(;t.get(++i)[1]!==h;);s.push(i),h._tokenizer||(u=r.sliceStream(h),h.next||u.push(null),f&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(m=p+1,g.push(m),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):g.pop(),p=g.length;p--;){let y=a.slice(g[p],g[p+1]),$=s.pop();l.push([$,$+y.length-1]),t.splice($,2,y)}for(l.reverse(),p=-1;++p<l.length;)c[d+l[p][0]]=d+l[p][1],d+=l[p][1]-l[p][0]-1;return c}var Sl={resolve:fb,tokenize:pb},ub={partial:!0,tokenize:hb};function fb(t){return fo(t),t}function pb(t,e){let n;return r;function r(a){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):B(a)?t.check(ub,o,s)(a):(t.consume(a),i)}function s(a){return t.exit("chunkContent"),t.exit("content"),e(a)}function o(a){return t.consume(a),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function hb(t,e,n){let r=this;return i;function i(o){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),J(t,s,"linePrefix")}function s(o){if(o===null||B(o))return n(o);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):t.interrupt(r.parser.constructs.flow,n,e)(o)}}function po(t,e,n,r,i,s,o,a,l){let c=l||Number.POSITIVE_INFINITY,u=0;return f;function f(y){return y===60?(t.enter(r),t.enter(i),t.enter(s),t.consume(y),t.exit(s),p):y===null||y===32||y===41||ji(y)?n(y):(t.enter(r),t.enter(o),t.enter(a),t.enter("chunkString",{contentType:"string"}),m(y))}function p(y){return y===62?(t.enter(s),t.consume(y),t.exit(s),t.exit(i),t.exit(r),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===62?(t.exit("chunkString"),t.exit(a),p(y)):y===null||y===60||B(y)?n(y):(t.consume(y),y===92?d:h)}function d(y){return y===60||y===62||y===92?(t.consume(y),h):h(y)}function m(y){return!u&&(y===null||y===41||we(y))?(t.exit("chunkString"),t.exit(a),t.exit(o),t.exit(r),e(y)):u<c&&y===40?(t.consume(y),u++,m):y===41?(t.consume(y),u--,m):y===null||y===32||y===40||ji(y)?n(y):(t.consume(y),y===92?g:m)}function g(y){return y===40||y===41||y===92?(t.consume(y),m):m(y)}}function ho(t,e,n,r,i,s){let o=this,a=0,l;return c;function c(h){return t.enter(r),t.enter(i),t.consume(h),t.exit(i),t.enter(s),u}function u(h){return a>999||h===null||h===91||h===93&&!l||h===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(h):h===93?(t.exit(s),t.enter(i),t.consume(h),t.exit(i),t.exit(r),e):B(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),u):(t.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||B(h)||a++>999?(t.exit("chunkString"),u(h)):(t.consume(h),l||(l=!Z(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(t.consume(h),a++,f):f(h)}}function mo(t,e,n,r,i,s){let o;return a;function a(p){return p===34||p===39||p===40?(t.enter(r),t.enter(i),t.consume(p),t.exit(i),o=p===40?41:p,l):n(p)}function l(p){return p===o?(t.enter(i),t.consume(p),t.exit(i),t.exit(r),e):(t.enter(s),c(p))}function c(p){return p===o?(t.exit(s),l(o)):p===null?n(p):B(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),J(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),u(p))}function u(p){return p===o||p===null||B(p)?(t.exit("chunkString"),c(p)):(t.consume(p),p===92?f:u)}function f(p){return p===o||p===92?(t.consume(p),u):u(p)}}function or(t,e){let n;return r;function r(i){return B(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n=!0,r):Z(i)?J(t,r,n?"linePrefix":"lineSuffix")(i):e(i)}}var Al={name:"definition",tokenize:mb},db={partial:!0,tokenize:gb};function mb(t,e,n){let r=this,i;return s;function s(h){return t.enter("definition"),o(h)}function o(h){return ho.call(r,t,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function a(h){return i=it(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),l):n(h)}function l(h){return we(h)?or(t,c)(h):c(h)}function c(h){return po(t,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function u(h){return t.attempt(db,f,f)(h)}function f(h){return Z(h)?J(t,p,"whitespace")(h):p(h)}function p(h){return h===null||B(h)?(t.exit("definition"),r.parser.defined.push(i),e(h)):n(h)}}function gb(t,e,n){return r;function r(a){return we(a)?or(t,i)(a):n(a)}function i(a){return mo(t,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Z(a)?J(t,o,"whitespace")(a):o(a)}function o(a){return a===null||B(a)?e(a):n(a)}}var Tl={name:"hardBreakEscape",tokenize:yb};function yb(t,e,n){return r;function r(s){return t.enter("hardBreakEscape"),t.consume(s),i}function i(s){return B(s)?(t.exit("hardBreakEscape"),e(s)):n(s)}}var Dl={name:"headingAtx",resolve:kb,tokenize:bb};function kb(t,e){let n=t.length-2,r=3;if(t[r][1].type==="whitespace"&&(r+=2),n-2>r&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&t[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r){let i={type:"atxHeadingText",start:t[r][1].start,end:t[n][1].end},s={type:"chunkText",start:t[r][1].start,end:t[n][1].end,contentType:"text"};Ye(t,r,n-r+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])}return t}function bb(t,e,n){let r=0;return i;function i(u){return t.enter("atxHeading"),s(u)}function s(u){return t.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(t.consume(u),o):u===null||we(u)?(t.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(t.enter("atxHeadingSequence"),l(u)):u===null||B(u)?(t.exit("atxHeading"),e(u)):Z(u)?J(t,a,"whitespace")(u):(t.enter("atxHeadingText"),c(u))}function l(u){return u===35?(t.consume(u),l):(t.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||we(u)?(t.exit("atxHeadingText"),a(u)):(t.consume(u),c)}}var $p=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Nl=["pre","script","style","textarea"];var Cl={concrete:!0,name:"htmlFlow",resolveTo:$b,tokenize:vb},wb={partial:!0,tokenize:xb};function $b(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function vb(t,e,n){let r=this,i,s,o,a,l;return c;function c(S){return u(S)}function u(S){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(S),f}function f(S){return S===33?(t.consume(S),p):S===47?(t.consume(S),s=!0,m):S===63?(t.consume(S),i=3,r.interrupt?e:x):wt(S)?(t.consume(S),o=String.fromCharCode(S),g):n(S)}function p(S){return S===45?(t.consume(S),i=2,h):S===91?(t.consume(S),i=5,a=0,d):wt(S)?(t.consume(S),i=4,r.interrupt?e:x):n(S)}function h(S){return S===45?(t.consume(S),r.interrupt?e:x):n(S)}function d(S){let pe="CDATA[";return S===pe.charCodeAt(a++)?(t.consume(S),a===pe.length?r.interrupt?e:R:d):n(S)}function m(S){return wt(S)?(t.consume(S),o=String.fromCharCode(S),g):n(S)}function g(S){if(S===null||S===47||S===62||we(S)){let pe=S===47,rt=o.toLowerCase();return!pe&&!s&&Nl.includes(rt)?(i=1,r.interrupt?e(S):R(S)):$p.includes(o.toLowerCase())?(i=6,pe?(t.consume(S),y):r.interrupt?e(S):R(S)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(S):s?$(S):b(S))}return S===45||at(S)?(t.consume(S),o+=String.fromCharCode(S),g):n(S)}function y(S){return S===62?(t.consume(S),r.interrupt?e:R):n(S)}function $(S){return Z(S)?(t.consume(S),$):T(S)}function b(S){return S===47?(t.consume(S),T):S===58||S===95||wt(S)?(t.consume(S),k):Z(S)?(t.consume(S),b):T(S)}function k(S){return S===45||S===46||S===58||S===95||at(S)?(t.consume(S),k):w(S)}function w(S){return S===61?(t.consume(S),v):Z(S)?(t.consume(S),w):b(S)}function v(S){return S===null||S===60||S===61||S===62||S===96?n(S):S===34||S===39?(t.consume(S),l=S,D):Z(S)?(t.consume(S),v):I(S)}function D(S){return S===l?(t.consume(S),l=null,L):S===null||B(S)?n(S):(t.consume(S),D)}function I(S){return S===null||S===34||S===39||S===47||S===60||S===61||S===62||S===96||we(S)?w(S):(t.consume(S),I)}function L(S){return S===47||S===62||Z(S)?b(S):n(S)}function T(S){return S===62?(t.consume(S),G):n(S)}function G(S){return S===null||B(S)?R(S):Z(S)?(t.consume(S),G):n(S)}function R(S){return S===45&&i===2?(t.consume(S),_):S===60&&i===1?(t.consume(S),W):S===62&&i===4?(t.consume(S),ge):S===63&&i===3?(t.consume(S),x):S===93&&i===5?(t.consume(S),q):B(S)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(wb,Ee,j)(S)):S===null||B(S)?(t.exit("htmlFlowData"),j(S)):(t.consume(S),R)}function j(S){return t.check(qi,O,Ee)(S)}function O(S){return t.enter("lineEnding"),t.consume(S),t.exit("lineEnding"),A}function A(S){return S===null||B(S)?j(S):(t.enter("htmlFlowData"),R(S))}function _(S){return S===45?(t.consume(S),x):R(S)}function W(S){return S===47?(t.consume(S),o="",Y):R(S)}function Y(S){if(S===62){let pe=o.toLowerCase();return Nl.includes(pe)?(t.consume(S),ge):R(S)}return wt(S)&&o.length<8?(t.consume(S),o+=String.fromCharCode(S),Y):R(S)}function q(S){return S===93?(t.consume(S),x):R(S)}function x(S){return S===62?(t.consume(S),ge):S===45&&i===2?(t.consume(S),x):R(S)}function ge(S){return S===null||B(S)?(t.exit("htmlFlowData"),Ee(S)):(t.consume(S),ge)}function Ee(S){return t.exit("htmlFlow"),e(S)}}function xb(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(Xt,e,n)}}var Il={name:"htmlText",tokenize:Eb};function Eb(t,e,n){let r=this,i,s,o;return a;function a(x){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(x),l}function l(x){return x===33?(t.consume(x),c):x===47?(t.consume(x),w):x===63?(t.consume(x),b):wt(x)?(t.consume(x),I):n(x)}function c(x){return x===45?(t.consume(x),u):x===91?(t.consume(x),s=0,d):wt(x)?(t.consume(x),$):n(x)}function u(x){return x===45?(t.consume(x),h):n(x)}function f(x){return x===null?n(x):x===45?(t.consume(x),p):B(x)?(o=f,W(x)):(t.consume(x),f)}function p(x){return x===45?(t.consume(x),h):f(x)}function h(x){return x===62?_(x):x===45?p(x):f(x)}function d(x){let ge="CDATA[";return x===ge.charCodeAt(s++)?(t.consume(x),s===ge.length?m:d):n(x)}function m(x){return x===null?n(x):x===93?(t.consume(x),g):B(x)?(o=m,W(x)):(t.consume(x),m)}function g(x){return x===93?(t.consume(x),y):m(x)}function y(x){return x===62?_(x):x===93?(t.consume(x),y):m(x)}function $(x){return x===null||x===62?_(x):B(x)?(o=$,W(x)):(t.consume(x),$)}function b(x){return x===null?n(x):x===63?(t.consume(x),k):B(x)?(o=b,W(x)):(t.consume(x),b)}function k(x){return x===62?_(x):b(x)}function w(x){return wt(x)?(t.consume(x),v):n(x)}function v(x){return x===45||at(x)?(t.consume(x),v):D(x)}function D(x){return B(x)?(o=D,W(x)):Z(x)?(t.consume(x),D):_(x)}function I(x){return x===45||at(x)?(t.consume(x),I):x===47||x===62||we(x)?L(x):n(x)}function L(x){return x===47?(t.consume(x),_):x===58||x===95||wt(x)?(t.consume(x),T):B(x)?(o=L,W(x)):Z(x)?(t.consume(x),L):_(x)}function T(x){return x===45||x===46||x===58||x===95||at(x)?(t.consume(x),T):G(x)}function G(x){return x===61?(t.consume(x),R):B(x)?(o=G,W(x)):Z(x)?(t.consume(x),G):L(x)}function R(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(t.consume(x),i=x,j):B(x)?(o=R,W(x)):Z(x)?(t.consume(x),R):(t.consume(x),O)}function j(x){return x===i?(t.consume(x),i=void 0,A):x===null?n(x):B(x)?(o=j,W(x)):(t.consume(x),j)}function O(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||we(x)?L(x):(t.consume(x),O)}function A(x){return x===47||x===62||we(x)?L(x):n(x)}function _(x){return x===62?(t.consume(x),t.exit("htmlTextData"),t.exit("htmlText"),e):n(x)}function W(x){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(x),t.exit("lineEnding"),Y}function Y(x){return Z(x)?J(t,q,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):q(x)}function q(x){return t.enter("htmlTextData"),o(x)}}var ar={name:"labelEnd",resolveAll:Db,resolveTo:Nb,tokenize:Cb},Sb={tokenize:Ib},Ab={tokenize:Rb},Tb={tokenize:Ob};function Db(t){let e=-1,n=[];for(;++e<t.length;){let r=t[e][1];if(n.push(t[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){let i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return t.length!==n.length&&Ye(t,0,t.length,n),t}function Nb(t,e){let n=t.length,r=0,i,s,o;for(;n--;){let u=t[n][1];if(i){if(u.type==="link"||u.type==="labelLink"&&u._inactive)break;t[n][0]==="enter"&&u.type==="labelLink"&&(u._inactive=!0)}else if(s){if(t[n][0]==="enter"&&(u.type==="labelImage"||u.type==="labelLink")&&!u._balanced&&(i=n,u.type!=="labelLink")){r=2;break}}else u.type==="labelEnd"&&(s=n)}let a={type:t[i][1].type==="labelLink"?"link":"image",start:{...t[i][1].start},end:{...t[t.length-1][1].end}},l={type:"label",start:{...t[i][1].start},end:{...t[s][1].end}},c={type:"labelText",start:{...t[i+r+2][1].end},end:{...t[s-2][1].start}};return o=[["enter",a,e],["enter",l,e]],o=ot(o,t.slice(i+1,i+r+3)),o=ot(o,[["enter",c,e]]),o=ot(o,Mn(e.parser.constructs.insideSpan.null,t.slice(i+r+4,s-3),e)),o=ot(o,[["exit",c,e],t[s-2],t[s-1],["exit",l,e]]),o=ot(o,t.slice(s+1)),o=ot(o,[["exit",a,e]]),Ye(t,i,t.length,o),t}function Cb(t,e,n){let r=this,i=r._labelStarts,s,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();s=i[i.length-1]}return a;function a(p){return s?s._inactive?f(p):(o=r.parser.defined.includes(it(r.sliceSerialize({start:s.end,end:r.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(p),t.exit("labelMarker"),t.exit("labelEnd"),l):n(p)}function l(p){return p===40?t.attempt(Sb,u,o?u:f)(p):p===91?t.attempt(Ab,u,o?c:f)(p):o?u(p):f(p)}function c(p){return t.attempt(Tb,u,f)(p)}function u(p){return i.pop(),e(p)}function f(p){return s._balanced=!0,n(p)}}function Ib(t,e,n){return r;function r(f){return t.enter("resource"),t.enter("resourceMarker"),t.consume(f),t.exit("resourceMarker"),i}function i(f){return we(f)?or(t,s)(f):s(f)}function s(f){return f===41?u(f):po(t,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return we(f)?or(t,l)(f):u(f)}function a(f){return n(f)}function l(f){return f===34||f===39||f===40?mo(t,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):u(f)}function c(f){return we(f)?or(t,u)(f):u(f)}function u(f){return f===41?(t.enter("resourceMarker"),t.consume(f),t.exit("resourceMarker"),t.exit("resource"),e):n(f)}}function Rb(t,e,n){let r=this;return i;function i(a){return ho.call(r,t,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(it(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(a):n(a)}function o(a){return n(a)}}function Ob(t,e,n){return r;function r(s){return t.enter("reference"),t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),i}function i(s){return s===93?(t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),t.exit("reference"),e):n(s)}}var Rl={name:"labelStartImage",resolveAll:ar.resolveAll,tokenize:Mb};function Mb(t,e,n){let r=this,i;return s;function s(l){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(l),t.exit("labelImageMarker"),o}function o(l){return l===91?(t.enter("labelMarker"),t.consume(l),t.exit("labelMarker"),i=t.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),e(l))}}var Ol={name:"labelStartLink",resolveAll:ar.resolveAll,tokenize:Lb};function Lb(t,e,n){let r=this,i;return s;function s(a){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),i=t.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),e(a))}}var Vi={name:"lineEnding",tokenize:jb};function jb(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),J(t,e,"linePrefix")}}var lr={name:"thematicBreak",tokenize:Pb};function Pb(t,e,n){let r=0,i;return s;function s(c){return t.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(t.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||B(c))?(t.exit("thematicBreak"),e(c)):n(c)}function l(c){return c===i?(t.consume(c),r++,l):(t.exit("thematicBreakSequence"),Z(c)?J(t,a,"whitespace")(c):a(c))}}var st={continuation:{tokenize:Bb},exit:zb,name:"list",tokenize:Fb},_b={partial:!0,tokenize:Ub},qb={partial:!0,tokenize:Vb};function Fb(t,e,n){let r=this,i=r.events[r.events.length-1],s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(h){let d=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(d==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Pi(h)){if(r.containerState.type||(r.containerState.type=d,t.enter(d,{_container:!0})),d==="listUnordered")return t.enter("listItemPrefix"),h===42||h===45?t.check(lr,n,c)(h):c(h);if(!r.interrupt||h===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),l(h)}return n(h)}function l(h){return Pi(h)&&++o<10?(t.consume(h),l):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(t.exit("listItemValue"),c(h)):n(h)}function c(h){return t.enter("listItemMarker"),t.consume(h),t.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,t.check(Xt,r.interrupt?n:u,t.attempt(_b,p,f))}function u(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function f(h){return Z(h)?(t.enter("listItemPrefixWhitespace"),t.consume(h),t.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=s+r.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(h)}}function Bb(t,e,n){let r=this;return r.containerState._closeFlow=void 0,t.check(Xt,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,J(t,e,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Z(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,t.attempt(qb,e,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,J(t,t.attempt(st,e,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Vb(t,e,n){let r=this;return J(t,i,"listItemIndent",r.containerState.size+1);function i(s){let o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?e(s):n(s)}}function zb(t){t.exit(this.containerState.type)}function Ub(t,e,n){let r=this;return J(t,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){let o=r.events[r.events.length-1];return!Z(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):n(s)}}var go={name:"setextUnderline",resolveTo:Wb,tokenize:Hb};function Wb(t,e){let n=new yn,r=t.length,i,s,o;for(;r--;)if(t[r][0]==="enter"){if(t[r][1].type==="content"){i=r;break}t[r][1].type==="paragraph"&&(s=r)}else t[r][1].type==="content"&&n.add(r,1,[]),!o&&t[r][1].type==="definition"&&(o=r);let a={type:"setextHeading",start:{...t[i][1].start},end:{...t[t.length-1][1].end}};return t[s][1].type="setextHeadingText",o?(n.add(s,0,[["enter",a,e]]),n.add(o+1,0,[["exit",t[i][1],e]]),t[i][1].end={...t[o][1].end}):t[i][1]=a,n.add(t.length,0,[["exit",a,e]]),n.consume(t),t}function Hb(t,e,n){let r=this,i;return s;function s(c){let u=r.events.length,f;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){f=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(t.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return t.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(t.consume(c),a):(t.exit("setextHeadingLineSequence"),Z(c)?J(t,l,"lineSuffix")(c):l(c))}function l(c){return c===null||B(c)?(t.exit("setextHeadingLine"),e(c)):n(c)}}var vp={tokenize:Gb};function Gb(t){let e=this,n=t.attempt(Xt,r,t.attempt(this.parser.constructs.flowInitial,i,J(t,t.attempt(this.parser.constructs.flow,i,t.attempt(Sl,i)),"linePrefix")));return n;function r(s){if(s===null){t.consume(s);return}return t.enter("lineEndingBlank"),t.consume(s),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function i(s){if(s===null){t.consume(s);return}return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),e.currentConstruct=void 0,n}}var xp={resolveAll:Tp()},Ep=Ap("string"),Sp=Ap("text");function Ap(t){return{resolveAll:Tp(t==="text"?Kb:void 0),tokenize:e};function e(n){let r=this,i=this.parser.constructs[t],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;let f=i[u],p=-1;if(f)for(;++p<f.length;){let h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Tp(t){return e;function e(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return t?t(n,r):n}}function Kb(t,e){let n=new yn,r=0;for(;++r<=t.length;)if((r===t.length||t[r][1].type==="lineEnding")&&t[r-1][1].type==="data"){let i=t[r-1][1],s=e.sliceStream(i),o=s.length,a=-1,l=0,c;for(;o--;){let u=s[o];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)c=!0,l++;else if(u!==-1){o++;break}}if(e._contentTypeTextTrailing&&r===t.length&&(l=0),l){let u={type:r===t.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:i.start._bufferIndex+a,_index:i.start._index+o,line:i.end.line,column:i.end.column-l,offset:i.end.offset-l},end:{...i.end}};i.end={...u.start},i.start.offset===i.end.offset?Object.assign(i,u):n.add(r,0,[["enter",u,e],["exit",u,e]])}r++}return n.consume(t),t}var Ml={};Lk(Ml,{attentionMarkers:()=>nw,contentInitial:()=>Jb,disable:()=>rw,document:()=>Yb,flow:()=>Qb,flowInitial:()=>Zb,insideSpan:()=>tw,string:()=>Xb,text:()=>ew});var Yb={42:st,43:st,45:st,48:st,49:st,50:st,51:st,52:st,53:st,54:st,55:st,56:st,57:st,62:oo},Jb={91:Al},Zb={[-2]:Fi,[-1]:Fi,32:Fi},Qb={35:Dl,42:lr,45:[go,lr],60:Cl,61:go,95:lr,96:co,126:co},Xb={38:lo,92:ao},ew={[-5]:Vi,[-4]:Vi,[-3]:Vi,33:Rl,38:lo,42:_i,60:[xl,Il],91:Ol,92:[Tl,ao],93:ar,95:_i,96:El},tw={null:[_i,xp]},nw={null:[42,95]},rw={null:[]};function Dp(t,e,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},s=[],o=[],a=[],l=!0,c={attempt:L(D),check:L(I),consume:k,enter:w,exit:v,interrupt:L(I,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:g,parser:t,previous:null,sliceSerialize:d,sliceStream:m,write:h},f=e.tokenize.call(u,c),p;return e.resolveAll&&s.push(e),u;function h(j){return o=ot(o,j),$(),o[o.length-1]!==null?[]:(T(e,0),u.events=Mn(s,u.events,u),u.events)}function d(j,O){return sw(m(j),O)}function m(j){return iw(o,j)}function g(){let{_bufferIndex:j,_index:O,line:A,column:_,offset:W}=r;return{_bufferIndex:j,_index:O,line:A,column:_,offset:W}}function y(j){i[j.line]=j.column,R()}function $(){for(;r._index<o.length;){let j=o[r._index];if(typeof j=="string"){let O=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===O&&r._bufferIndex<j.length;)b(j.charCodeAt(r._bufferIndex))}else b(j)}}function b(j){l=void 0,p=j,f=f(j)}function k(j){B(j)?(r.line++,r.column=1,r.offset+=j===-3?2:1,R()):j!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=j,l=!0}function w(j,O){let A=O||{};return A.type=j,A.start=g(),u.events.push(["enter",A,u]),a.push(A),A}function v(j){let O=a.pop();return O.end=g(),u.events.push(["exit",O,u]),O}function D(j,O){T(j,O.from)}function I(j,O){O.restore()}function L(j,O){return A;function A(_,W,Y){let q,x,ge,Ee;return Array.isArray(_)?pe(_):"tokenize"in _?pe([_]):S(_);function S(Pe){return Rn;function Rn(Mt){let Qt=Mt!==null&&Pe[Mt],dn=Mt!==null&&Pe.null,Lr=[...Array.isArray(Qt)?Qt:Qt?[Qt]:[],...Array.isArray(dn)?dn:dn?[dn]:[]];return pe(Lr)(Mt)}}function pe(Pe){return q=Pe,x=0,Pe.length===0?Y:rt(Pe[x])}function rt(Pe){return Rn;function Rn(Mt){return Ee=G(),ge=Pe,Pe.partial||(u.currentConstruct=Pe),Pe.name&&u.parser.constructs.disable.null.includes(Pe.name)?In(Mt):Pe.tokenize.call(O?Object.assign(Object.create(u),O):u,c,Zt,In)(Mt)}}function Zt(Pe){return l=!0,j(ge,Ee),W}function In(Pe){return l=!0,Ee.restore(),++x<q.length?rt(q[x]):Y}}}function T(j,O){j.resolveAll&&!s.includes(j)&&s.push(j),j.resolve&&Ye(u.events,O,u.events.length-O,j.resolve(u.events.slice(O),u)),j.resolveTo&&(u.events=j.resolveTo(u.events,u))}function G(){let j=g(),O=u.previous,A=u.currentConstruct,_=u.events.length,W=Array.from(a);return{from:_,restore:Y};function Y(){r=j,u.previous=O,u.currentConstruct=A,u.events.length=_,a=W,R()}}function R(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function iw(t,e){let n=e.start._index,r=e.start._bufferIndex,i=e.end._index,s=e.end._bufferIndex,o;if(n===i)o=[t[n].slice(r,s)];else{if(o=t.slice(n,i),r>-1){let a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(t[i].slice(0,s))}return o}function sw(t,e){let n=-1,r=[],i;for(;++n<t.length;){let s=t[n],o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
147
+ `;break}case-3:{o=`\r
148
+ `;break}case-2:{o=e?" ":" ";break}case-1:{if(!e&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function Ll(t){let r={constructs:up([Ml,...(t||{}).extensions||[]]),content:i(gp),defined:[],document:i(bp),flow:i(vp),lazy:{},string:i(Ep),text:i(Sp)};return r;function i(s){return o;function o(a){return Dp(r,s,a)}}}function jl(t){for(;!fo(t););return t}var Np=/[\0\t\n\r]/g;function Pl(){let t=1,e="",n=!0,r;return i;function i(s,o,a){s=e+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s));let l=[],c=0;for(e="",n&&(s.charCodeAt(0)===65279&&c++,n=void 0);c<s.length;){Np.lastIndex=c;let u=Np.exec(s),f=u&&u.index!==void 0?u.index:s.length,p=s.charCodeAt(f);if(!u){e=s.slice(c);break}if(p===10&&c===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),c<f&&(l.push(s.slice(c,f)),t+=f-c),p){case 0:{l.push(65533),t++;break}case 9:{let h=Math.ceil(t/4)*4;for(l.push(-2);t++<h;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:r=!0,t=1}c=f+1}return a&&(r&&l.push(-5),e&&l.push(e),l.push(null)),l}}var ow=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Cp(t){return t.replace(ow,aw)}function aw(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){let i=n.charCodeAt(1),s=i===120||i===88;return so(n.slice(s?2:1),s?16:10)}return Pr(n)||t}function qr(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?Ip(t.position):"start"in t||"end"in t?Ip(t):"line"in t||"column"in t?_l(t):""}function _l(t){return Rp(t&&t.line)+":"+Rp(t&&t.column)}function Ip(t){return _l(t&&t.start)+"-"+_l(t&&t.end)}function Rp(t){return t&&typeof t=="number"?t:1}var Mp={}.hasOwnProperty;function ql(t,e,n){return typeof e!="string"&&(n=e,e=void 0),lw(n)(jl(Ll(n).document().write(Pl()(t,e,!0))))}function lw(t){let e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(ip),autolinkProtocol:L,autolinkEmail:L,atxHeading:s(tp),blockQuote:s(Mt),characterEscape:L,characterReference:L,codeFenced:s(Qt),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Qt,o),codeText:s(dn,o),codeTextData:L,data:L,codeFlowValue:L,definition:s(Lr),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(xk),hardBreakEscape:s(np),hardBreakTrailing:s(np),htmlFlow:s(rp,o),htmlFlowData:L,htmlText:s(rp,o),htmlTextData:L,image:s(Ek),label:o,link:s(ip),listItem:s(Sk),listItemValue:p,listOrdered:s(sp,f),listUnordered:s(sp),paragraph:s(Ak),reference:S,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(tp),strong:s(Tk),thematicBreak:s(Nk)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:Rn,autolinkProtocol:Pe,blockQuote:l(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:rt,characterReferenceMarkerNumeric:rt,characterReferenceValue:Zt,characterReference:In,codeFenced:l(g),codeFencedFence:m,codeFencedFenceInfo:h,codeFencedFenceMeta:d,codeFlowValue:T,codeIndented:l(y),codeText:l(A),codeTextData:T,data:T,definition:l(),definitionDestinationString:k,definitionLabelString:$,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(j),htmlFlowData:T,htmlText:l(O),htmlTextData:T,image:l(W),label:q,labelText:Y,lineEnding:G,link:l(_),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:pe,resourceDestinationString:x,resourceTitleString:ge,resource:Ee,setextHeading:l(I),setextHeadingLineSequence:D,setextHeadingText:v,strong:l(),thematicBreak:l()}};Lp(e,(t||{}).mdastExtensions||[]);let n={};return r;function r(M){let z={type:"root",children:[]},re={stack:[z],tokenStack:[],config:e,enter:a,exit:c,buffer:o,resume:u,data:n},me=[],Se=-1;for(;++Se<M.length;)if(M[Se][1].type==="listOrdered"||M[Se][1].type==="listUnordered")if(M[Se][0]==="enter")me.push(Se);else{let Lt=me.pop();Se=i(M,Lt,Se)}for(Se=-1;++Se<M.length;){let Lt=e[M[Se][0]];Mp.call(Lt,M[Se][1].type)&&Lt[M[Se][1].type].call(Object.assign({sliceSerialize:M[Se][2].sliceSerialize},re),M[Se][1])}if(re.tokenStack.length>0){let Lt=re.tokenStack[re.tokenStack.length-1];(Lt[1]||Op).call(re,void 0,Lt[0])}for(z.position={start:Ln(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:Ln(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},Se=-1;++Se<e.transforms.length;)z=e.transforms[Se](z)||z;return z}function i(M,z,re){let me=z-1,Se=-1,Lt=!1,sr,mn,Oi,Mi;for(;++me<=re;){let bt=M[me];switch(bt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{bt[0]==="enter"?Se++:Se--,Mi=void 0;break}case"lineEndingBlank":{bt[0]==="enter"&&(sr&&!Mi&&!Se&&!Oi&&(Oi=me),Mi=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Mi=void 0}if(!Se&&bt[0]==="enter"&&bt[1].type==="listItemPrefix"||Se===-1&&bt[0]==="exit"&&(bt[1].type==="listUnordered"||bt[1].type==="listOrdered")){if(sr){let jr=me;for(mn=void 0;jr--;){let gn=M[jr];if(gn[1].type==="lineEnding"||gn[1].type==="lineEndingBlank"){if(gn[0]==="exit")continue;mn&&(M[mn][1].type="lineEndingBlank",Lt=!0),gn[1].type="lineEnding",mn=jr}else if(!(gn[1].type==="linePrefix"||gn[1].type==="blockQuotePrefix"||gn[1].type==="blockQuotePrefixWhitespace"||gn[1].type==="blockQuoteMarker"||gn[1].type==="listItemIndent"))break}Oi&&(!mn||Oi<mn)&&(sr._spread=!0),sr.end=Object.assign({},mn?M[mn][1].start:bt[1].end),M.splice(mn||me,0,["exit",sr,bt[2]]),me++,re++}if(bt[1].type==="listItemPrefix"){let jr={type:"listItem",_spread:!1,start:Object.assign({},bt[1].start),end:void 0};sr=jr,M.splice(me,0,["enter",jr,bt[2]]),me++,re++,Oi=void 0,Mi=!0}}}return M[z][1]._spread=Lt,re}function s(M,z){return re;function re(me){a.call(this,M(me),me),z&&z.call(this,me)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(M,z,re){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([z,re||void 0]),M.position={start:Ln(z.start),end:void 0}}function l(M){return z;function z(re){M&&M.call(this,re),c.call(this,re)}}function c(M,z){let re=this.stack.pop(),me=this.tokenStack.pop();if(me)me[0].type!==M.type&&(z?z.call(this,M,me[0]):(me[1]||Op).call(this,M,me[0]));else throw new Error("Cannot close `"+M.type+"` ("+qr({start:M.start,end:M.end})+"): it\u2019s not open");re.position.end=Ln(M.end)}function u(){return wl(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(M){if(this.data.expectingFirstListItemValue){let z=this.stack[this.stack.length-2];z.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function h(){let M=this.resume(),z=this.stack[this.stack.length-1];z.lang=M}function d(){let M=this.resume(),z=this.stack[this.stack.length-1];z.meta=M}function m(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let M=this.resume(),z=this.stack[this.stack.length-1];z.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){let M=this.resume(),z=this.stack[this.stack.length-1];z.value=M.replace(/(\r?\n|\r)$/g,"")}function $(M){let z=this.resume(),re=this.stack[this.stack.length-1];re.label=z,re.identifier=it(this.sliceSerialize(M)).toLowerCase()}function b(){let M=this.resume(),z=this.stack[this.stack.length-1];z.title=M}function k(){let M=this.resume(),z=this.stack[this.stack.length-1];z.url=M}function w(M){let z=this.stack[this.stack.length-1];if(!z.depth){let re=this.sliceSerialize(M).length;z.depth=re}}function v(){this.data.setextHeadingSlurpLineEnding=!0}function D(M){let z=this.stack[this.stack.length-1];z.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function I(){this.data.setextHeadingSlurpLineEnding=void 0}function L(M){let re=this.stack[this.stack.length-1].children,me=re[re.length-1];(!me||me.type!=="text")&&(me=Dk(),me.position={start:Ln(M.start),end:void 0},re.push(me)),this.stack.push(me)}function T(M){let z=this.stack.pop();z.value+=this.sliceSerialize(M),z.position.end=Ln(M.end)}function G(M){let z=this.stack[this.stack.length-1];if(this.data.atHardBreak){let re=z.children[z.children.length-1];re.position.end=Ln(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(z.type)&&(L.call(this,M),T.call(this,M))}function R(){this.data.atHardBreak=!0}function j(){let M=this.resume(),z=this.stack[this.stack.length-1];z.value=M}function O(){let M=this.resume(),z=this.stack[this.stack.length-1];z.value=M}function A(){let M=this.resume(),z=this.stack[this.stack.length-1];z.value=M}function _(){let M=this.stack[this.stack.length-1];if(this.data.inReference){let z=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=z,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function W(){let M=this.stack[this.stack.length-1];if(this.data.inReference){let z=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=z,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function Y(M){let z=this.sliceSerialize(M),re=this.stack[this.stack.length-2];re.label=Cp(z),re.identifier=it(z).toLowerCase()}function q(){let M=this.stack[this.stack.length-1],z=this.resume(),re=this.stack[this.stack.length-1];if(this.data.inReference=!0,re.type==="link"){let me=M.children;re.children=me}else re.alt=z}function x(){let M=this.resume(),z=this.stack[this.stack.length-1];z.url=M}function ge(){let M=this.resume(),z=this.stack[this.stack.length-1];z.title=M}function Ee(){this.data.inReference=void 0}function S(){this.data.referenceType="collapsed"}function pe(M){let z=this.resume(),re=this.stack[this.stack.length-1];re.label=z,re.identifier=it(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function rt(M){this.data.characterReferenceType=M.type}function Zt(M){let z=this.sliceSerialize(M),re=this.data.characterReferenceType,me;re?(me=so(z,re==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):me=Pr(z);let Se=this.stack[this.stack.length-1];Se.value+=me}function In(M){let z=this.stack.pop();z.position.end=Ln(M.end)}function Pe(M){T.call(this,M);let z=this.stack[this.stack.length-1];z.url=this.sliceSerialize(M)}function Rn(M){T.call(this,M);let z=this.stack[this.stack.length-1];z.url="mailto:"+this.sliceSerialize(M)}function Mt(){return{type:"blockquote",children:[]}}function Qt(){return{type:"code",lang:null,meta:null,value:""}}function dn(){return{type:"inlineCode",value:""}}function Lr(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function xk(){return{type:"emphasis",children:[]}}function tp(){return{type:"heading",depth:0,children:[]}}function np(){return{type:"break"}}function rp(){return{type:"html",value:""}}function Ek(){return{type:"image",title:null,url:"",alt:null}}function ip(){return{type:"link",title:null,url:"",children:[]}}function sp(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function Sk(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function Ak(){return{type:"paragraph",children:[]}}function Tk(){return{type:"strong",children:[]}}function Dk(){return{type:"text",value:""}}function Nk(){return{type:"thematicBreak"}}}function Ln(t){return{line:t.line,column:t.column,offset:t.offset}}function Lp(t,e){let n=-1;for(;++n<e.length;){let r=e[n];Array.isArray(r)?Lp(t,r):cw(t,r)}}function cw(t,e){let n;for(n in e)if(Mp.call(e,n))switch(n){case"canContainEols":{let r=e[n];r&&t[n].push(...r);break}case"transforms":{let r=e[n];r&&t[n].push(...r);break}case"enter":case"exit":{let r=e[n];r&&Object.assign(t[n],r);break}}}function Op(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+qr({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+qr({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+qr({start:e.start,end:e.end})+") is still open")}var uw={tokenize:yw,partial:!0};function Fl(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:dw,continuation:{tokenize:mw},exit:gw}},text:{91:{name:"gfmFootnoteCall",tokenize:hw},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:fw,resolveTo:pw}}}}function fw(t,e,n){let r=this,i=r.events.length,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);let c=it(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function pw(t,e){let n=t.length,r;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){r=t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";let i={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;let o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},t[t.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},l=[t[n+1],t[n+2],["enter",i,e],t[n+3],t[n+4],["enter",s,e],["exit",s,e],["enter",o,e],["enter",a,e],["exit",a,e],["exit",o,e],t[t.length-2],t[t.length-1],["exit",i,e]];return t.splice(n,t.length-n+1,...l),t}function hw(t,e,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),s=0,o;return a;function a(f){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(t.enter("gfmFootnoteCallMarker"),t.consume(f),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(f){if(s>999||f===93&&!o||f===null||f===91||we(f))return n(f);if(f===93){t.exit("chunkString");let p=t.exit("gfmFootnoteCallString");return i.includes(it(r.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(f)}return we(f)||(o=!0),s++,t.consume(f),f===92?u:c}function u(f){return f===91||f===92||f===93?(t.consume(f),s++,c):c(f)}}function dw(t,e,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),s,o=0,a;return l;function l(d){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(d),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(d){return d===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(d),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",u):n(d)}function u(d){if(o>999||d===93&&!a||d===null||d===91||we(d))return n(d);if(d===93){t.exit("chunkString");let m=t.exit("gfmFootnoteDefinitionLabelString");return s=it(r.sliceSerialize(m)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(d),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return we(d)||(a=!0),o++,t.consume(d),d===92?f:u}function f(d){return d===91||d===92||d===93?(t.consume(d),o++,u):u(d)}function p(d){return d===58?(t.enter("definitionMarker"),t.consume(d),t.exit("definitionMarker"),i.includes(s)||i.push(s),J(t,h,"gfmFootnoteDefinitionWhitespace")):n(d)}function h(d){return e(d)}}function mw(t,e,n){return t.check(Xt,e,t.attempt(uw,e,n))}function gw(t){t.exit("gfmFootnoteDefinition")}function yw(t,e,n){let r=this;return J(t,i,"gfmFootnoteDefinitionIndent",5);function i(s){let o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(s):n(s)}}Aw.peek=Tw;function Bl(){return{enter:{gfmFootnoteDefinition:kw,gfmFootnoteDefinitionLabelString:bw,gfmFootnoteCall:vw,gfmFootnoteCallString:xw},exit:{gfmFootnoteDefinition:$w,gfmFootnoteDefinitionLabelString:ww,gfmFootnoteCall:Sw,gfmFootnoteCallString:Ew}}}function kw(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function bw(){this.buffer()}function ww(t){let e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=e,n.identifier=it(this.sliceSerialize(t)).toLowerCase()}function $w(t){this.exit(t)}function vw(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function xw(){this.buffer()}function Ew(t){let e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=e,n.identifier=it(this.sliceSerialize(t)).toLowerCase()}function Sw(t){this.exit(t)}function Aw(t,e,n,r){let i=n.createTracker(r),s=i.move("[^"),o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(t),{...i.current(),before:s,after:"]"})),a(),o(),s+=i.move("]"),s}function Tw(){return"["}function Vl(t){let n=(t||{}).singleTilde,r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";let u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},f={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",f,a]],h=a.parser.constructs.insideSpan.null;h&&Ye(p,p.length,0,Mn(h,o.slice(c+1,l),a)),Ye(p,p.length,0,[["exit",f,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),Ye(o,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){let c=this.previous,u=this.events,f=0;return p;function p(d){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(d):(o.enter("strikethroughSequenceTemporary"),h(d))}function h(d){let m=_r(c);if(d===126)return f>1?l(d):(o.consume(d),f++,h);if(f<2&&!n)return l(d);let g=o.exit("strikethroughSequenceTemporary"),y=_r(d);return g._open=!y||y===2&&!!m,g._close=!m||m===2&&!!y,a(d)}}}Cw.peek=Iw;function zl(){return{canContainEols:["delete"],enter:{strikethrough:Dw},exit:{strikethrough:Nw}}}function Dw(t){this.enter({type:"delete",children:[]},t)}function Nw(t){this.exit(t)}function Cw(t,e,n,r){let i=n.createTracker(r),s=n.enter("strikethrough"),o=i.move("~~");return o+=n.containerPhrasing(t,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function Iw(){return"~"}var yo=class{constructor(){this.map=[]}add(e,n,r){Rw(this,e,n,r)}consume(e){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length,r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(let s of i)e.push(s);i=r.pop()}this.map.length=0}};function Rw(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function jp(t,e){let n=!1,r=[];for(;e<t.length;){let i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){let s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function Ul(){return{flow:{null:{name:"table",tokenize:Ow,resolveAll:Mw}}}}function Ow(t,e,n){let r=this,i=0,s=0,o;return a;function a(T){let G=r.events.length-1;for(;G>-1;){let O=r.events[G][1].type;if(O==="lineEnding"||O==="linePrefix")G--;else break}let R=G>-1?r.events[G][1].type:null,j=R==="tableHead"||R==="tableRow"?v:l;return j===v&&r.parser.lazy[r.now().line]?n(T):j(T)}function l(T){return t.enter("tableHead"),t.enter("tableRow"),c(T)}function c(T){return T===124||(o=!0,s+=1),u(T)}function u(T){return T===null?n(T):B(T)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),h):n(T):Z(T)?J(t,u,"whitespace")(T):(s+=1,o&&(o=!1,i+=1),T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),o=!0,u):(t.enter("data"),f(T)))}function f(T){return T===null||T===124||we(T)?(t.exit("data"),u(T)):(t.consume(T),T===92?p:f)}function p(T){return T===92||T===124?(t.consume(T),f):f(T)}function h(T){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(T):(t.enter("tableDelimiterRow"),o=!1,Z(T)?J(t,d,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):d(T))}function d(T){return T===45||T===58?g(T):T===124?(o=!0,t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),m):w(T)}function m(T){return Z(T)?J(t,g,"whitespace")(T):g(T)}function g(T){return T===58?(s+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(T),t.exit("tableDelimiterMarker"),y):T===45?(s+=1,y(T)):T===null||B(T)?k(T):w(T)}function y(T){return T===45?(t.enter("tableDelimiterFiller"),$(T)):w(T)}function $(T){return T===45?(t.consume(T),$):T===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(T),t.exit("tableDelimiterMarker"),b):(t.exit("tableDelimiterFiller"),b(T))}function b(T){return Z(T)?J(t,k,"whitespace")(T):k(T)}function k(T){return T===124?d(T):T===null||B(T)?!o||i!==s?w(T):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(T)):w(T)}function w(T){return n(T)}function v(T){return t.enter("tableRow"),D(T)}function D(T){return T===124?(t.enter("tableCellDivider"),t.consume(T),t.exit("tableCellDivider"),D):T===null||B(T)?(t.exit("tableRow"),e(T)):Z(T)?J(t,D,"whitespace")(T):(t.enter("data"),I(T))}function I(T){return T===null||T===124||we(T)?(t.exit("data"),D(T)):(t.consume(T),T===92?L:I)}function L(T){return T===92||T===124?(t.consume(T),I):I(T)}}function Mw(t,e){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,f,p=new yo;for(;++n<t.length;){let h=t[n],d=h[1];h[0]==="enter"?d.type==="tableHead"?(a=!1,l!==0&&(Pp(p,e,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},d.start),end:Object.assign({},d.end)},p.add(n,0,[["enter",c,e]])):d.type==="tableRow"||d.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},d.start),end:Object.assign({},d.end)},p.add(n,0,[["enter",u,e]])),i=d.type==="tableDelimiterRow"?2:u?3:1):i&&(d.type==="data"||d.type==="tableDelimiterMarker"||d.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],f=ko(p,e,s,i,void 0,f),s=[0,0,0,0]),o[2]=n)):d.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],f=ko(p,e,s,i,void 0,f)),s=o,o=[s[1],n,0,0])):d.type==="tableHead"?(a=!0,l=n):d.type==="tableRow"||d.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],f=ko(p,e,s,i,n,f)):o[1]!==0&&(f=ko(p,e,o,i,n,f)),i=0):i&&(d.type==="data"||d.type==="tableDelimiterMarker"||d.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Pp(p,e,l,c,u),p.consume(e.events),n=-1;++n<e.events.length;){let h=e.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=jp(e.events,n))}return t}function ko(t,e,n,r,i,s){let o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Fr(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));let l=Fr(e.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){let c=Fr(e.events,n[2]),u=Fr(e.events,n[3]),f={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(t.add(n[2],0,[["enter",f,e]]),r!==2){let p=e.events[n[2]],h=e.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){let d=n[2]+1,m=n[3]-n[2]-1;t.add(d,m,[])}}t.add(n[3]+1,0,[["exit",f,e]])}return i!==void 0&&(s.end=Object.assign({},Fr(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function Pp(t,e,n,r,i){let s=[],o=Fr(e.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,e])),r.end=Object.assign({},o),s.push(["exit",r,e]),t.add(n+1,0,s)}function Fr(t,e){let n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}function Hl(){return{enter:{table:Lw,tableData:_p,tableHeader:_p,tableRow:Pw},exit:{codeText:_w,table:jw,tableData:Wl,tableHeader:Wl,tableRow:Wl}}}function Lw(t){let e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function jw(t){this.exit(t),this.data.inTable=void 0}function Pw(t){this.enter({type:"tableRow",children:[]},t)}function Wl(t){this.exit(t)}function _p(t){this.enter({type:"tableCell",children:[]},t)}function _w(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,qw));let n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function qw(t,e){return e==="|"?e:t}var Fw={name:"tasklistCheck",tokenize:Bw};function Gl(){return{text:{91:Fw}}}function Bw(t,e,n){let r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),s)}function s(l){return we(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),a):n(l)}function a(l){return B(l)?e(l):Z(l)?t.check({tokenize:Vw},e,n)(l):n(l)}}function Vw(t,e,n){return J(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Kl(){return{exit:{taskListCheckValueChecked:qp,taskListCheckValueUnchecked:qp,paragraph:zw}}}function qp(t){let e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function zw(t){let e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){let n=this.stack[this.stack.length-1];n.type;let r=n.children[0];if(r&&r.type==="text"){let i=e.children,s=-1,o;for(;++s<i.length;){let a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}var Bp={tokenize:Uw,concrete:!0,name:"mathFlow"},Fp={tokenize:Ww,partial:!0};function Uw(t,e,n){let r=this,i=r.events[r.events.length-1],s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a($){return t.enter("mathFlow"),t.enter("mathFlowFence"),t.enter("mathFlowFenceSequence"),l($)}function l($){return $===36?(t.consume($),o++,l):o<2?n($):(t.exit("mathFlowFenceSequence"),J(t,c,"whitespace")($))}function c($){return $===null||B($)?f($):(t.enter("mathFlowFenceMeta"),t.enter("chunkString",{contentType:"string"}),u($))}function u($){return $===null||B($)?(t.exit("chunkString"),t.exit("mathFlowFenceMeta"),f($)):$===36?n($):(t.consume($),u)}function f($){return t.exit("mathFlowFence"),r.interrupt?e($):t.attempt(Fp,p,g)($)}function p($){return t.attempt({tokenize:y,partial:!0},g,h)($)}function h($){return(s?J(t,d,"linePrefix",s+1):d)($)}function d($){return $===null?g($):B($)?t.attempt(Fp,p,g)($):(t.enter("mathFlowValue"),m($))}function m($){return $===null||B($)?(t.exit("mathFlowValue"),d($)):(t.consume($),m)}function g($){return t.exit("mathFlow"),e($)}function y($,b,k){let w=0;return J($,v,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function v(L){return $.enter("mathFlowFence"),$.enter("mathFlowFenceSequence"),D(L)}function D(L){return L===36?(w++,$.consume(L),D):w<o?k(L):($.exit("mathFlowFenceSequence"),J($,I,"whitespace")(L))}function I(L){return L===null||B(L)?($.exit("mathFlowFence"),b(L)):k(L)}}}function Ww(t,e,n){let r=this;return i;function i(o){return o===null?e(o):(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):e(o)}}function Vp(t){let n=(t||{}).singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:Hw,previous:Gw,name:"mathText"};function r(i,s,o){let a=this,l=0,c,u;return f;function f(g){return i.enter("mathText"),i.enter("mathTextSequence"),p(g)}function p(g){return g===36?(i.consume(g),l++,p):l<2&&!n?o(g):(i.exit("mathTextSequence"),h(g))}function h(g){return g===null?o(g):g===36?(u=i.enter("mathTextSequence"),c=0,m(g)):g===32?(i.enter("space"),i.consume(g),i.exit("space"),h):B(g)?(i.enter("lineEnding"),i.consume(g),i.exit("lineEnding"),h):(i.enter("mathTextData"),d(g))}function d(g){return g===null||g===32||g===36||B(g)?(i.exit("mathTextData"),h(g)):(i.consume(g),d)}function m(g){return g===36?(i.consume(g),c++,m):c===l?(i.exit("mathTextSequence"),i.exit("mathText"),s(g)):(u.type="mathTextData",d(g))}}}function Hw(t){let e=t.length-4,n=3,r,i;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(r=n;++r<e;)if(t[r][1].type==="mathTextData"){t[e][1].type="mathTextPadding",t[n][1].type="mathTextPadding",n+=2,e-=2;break}}for(r=n-1,e++;++r<=e;)i===void 0?r!==e&&t[r][1].type!=="lineEnding"&&(i=r):(r===e||t[r][1].type==="lineEnding")&&(t[i][1].type="mathTextData",r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return t}function Gw(t){return t!==36||this.events[this.events.length-1][1].type==="characterEscape"}function Yl(t){return{flow:{36:Bp},text:{36:Vp(t)}}}function Jl(){return{enter:{mathFlow:t,mathFlowFenceMeta:e,mathText:s},exit:{mathFlow:i,mathFlowFence:r,mathFlowFenceMeta:n,mathFlowValue:a,mathText:o,mathTextData:a}};function t(l){let c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},l)}function e(){this.buffer()}function n(){let l=this.resume(),c=this.stack[this.stack.length-1];c.type,c.meta=l}function r(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(l){let c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c;let f=u.data.hChildren[0];f.type,f.tagName,f.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function s(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function o(l){let c=this.resume(),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c,u.data.hChildren.push({type:"text",value:c})}function a(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}function Kw(t){return ql(t,{extensions:[Ul(),Vl(),Gl(),Fl(),Yl()],mdastExtensions:[Hl(),zl(),Kl(),Bl(),Jl()]})}var Yw=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i;function Zl(t,e=1,n=[]){let r=Kw(t),i=l=>t.slice(l.position.start.offset,l.position.end.offset),s=l=>[e+l.position.start.line-1,l.position.start.column],o=l=>{let c=l.children??[];return c.length?t.slice(c[0].position.start.offset,c[c.length-1].position.end.offset).replace(/\n[ \t]*(?:>[ \t]?)*/g,`
149
+ `):""},a=l=>{let c=s(l);switch(l.type){case"heading":return[{node:"heading",def:"core:heading@1",props:{level:{lit:l.depth},text:{text:o(l)}},pos:c}];case"paragraph":{let u=l.children?.length===1&&l.children[0].type==="inlineMath"?l.children[0]:null,f=o(l).trim();return u&&/^\$\$[\s\S]*\$\$$/.test(f)?[{node:"math",def:"core:math@1",props:{tex:{tex:u.value??"",display:!0}},pos:c}]:[{node:"paragraph",def:"core:paragraph@1",props:{text:{text:o(l)}},pos:c}]}case"thematicBreak":return[{node:"divider",def:"core:divider@1",props:{},pos:c}];case"code":return[{node:"code",def:"core:code@1",props:{src:{text:l.value??""},lang:{text:l.lang??""}},pos:c}];case"math":return[{node:"math",def:"core:math@1",props:{tex:{tex:l.value??"",display:!0}},pos:c}];case"blockquote":{let u=l.children??[],f="none",p=u.flatMap(a),h=u[0];if(h&&h.type==="paragraph"){let d=o(h),m=Yw.exec(d);if(m){f=m[1].toLowerCase();let g=d.slice(m[0].length);p=[...g.trim()?[{node:"paragraph",def:"core:paragraph@1",props:{text:{text:g}},pos:s(h)}]:[],...u.slice(1).flatMap(a)]}}return[{node:"quote",def:"core:quote@1",props:{alert:{lit:f}},children:p,pos:c}]}case"list":{let u=(l.children??[]).map(f=>({node:"$record",record:"item",input:"items",props:{checked:{lit:f.checked===!0?"yes":f.checked===!1?"no":"none"}},children:(f.children??[]).flatMap(a),pos:s(f)}));return[{node:"list",def:"core:list@1",props:{ordered:{lit:!!l.ordered},start:{lit:l.start??1}},records:u,pos:c}]}case"table":{let u=(l.children??[]).map(p=>(p.children??[]).map(h=>o(h))),f=(l.align??[]).map(p=>p??"none");return[{node:"table",def:"core:table@1",props:{head:{lit:u[0]??[]},rows:{lit:u.slice(1)},align:{lit:f}},pos:c}]}case"footnoteDefinition":return[{node:"footnote",def:"core:footnote@1",props:{label:{text:String(l.label??l.identifier??"")}},children:(l.children??[]).flatMap(a),pos:c}];case"html":if(/^\s*<!--[\s\S]*-->\s*$/.test(i(l)))return[];{let u=i(l).trim().split(`
150
+ `)[0];n.push({line:c[0],message:`raw HTML is shown as plain text, since MKP content has no HTML; found ${u.length>60?u.slice(0,57)+"\u2026":u}. Write it as Markdown (**bold**, *italic*, [text](url)), or use a widget for anything more`})}return[{node:"paragraph",def:"core:paragraph@1",props:{text:{text:Jw(i(l))}},pos:c}];case"definition":return n.push({line:c[0],message:`link reference definitions like [${String(l.label??l.identifier??"")}]: ${String(l.url??"")} are not supported, so links that use them stay plain text. Write each link inline instead: [text](${String(l.url??"url")}), and remove this line`}),[];default:return[]}};return(r.children??[]).flatMap(a)}function Jw(t){return t.replace(/([\\`*_{}[\]<>#|])/g,"\\$1")}var kn=class{constructor(e,n){this.file=e;this.segs=n}at(e){let n=this.segs[0];for(let r of this.segs)r.at<=e&&(n=r);return{file:this.file,line:n.line,col:n.col+(e-n.at)}}},Xl=/^# mkp \d+(?:\.\d+)* ir \d+[ \t]*$/;function zp(t,e,n){let r=t.replace(/\r\n?/g,`
151
+ `).split(`
152
+ `),i=[],s=[],o=0;for(;o<r.length;){let a=r[o],l=o+1;if(o++,/^\s*$/.test(a))continue;if(a.search(/^[ ]*\t/)>=0){let d=a.indexOf(" ")+1;n.error("mkp.tab",`this line is indented with a tab, but MKP indents with spaces only; found a tab at column ${d}. Replace the tab with spaces, two for each level of nesting`,{file:e,line:l,col:d});continue}let u=a.length-a.trimStart().length,f=a.slice(u);if(f.startsWith("#")){if(!i.length&&!s.length&&u===0&&Xl.test(f))continue;s.push(f.slice(1).trim());continue}let p=f,h=[{at:0,line:l,col:u+1}];for(;;){let d=t$(p);if(d.longOpen>=0){let m=[],g=!1,y="";for(;o<r.length;){let b=r[o];o++;let k=b.trim();if(k.startsWith('"""')){g=!0,y=k.slice(3);break}m.push(b)}g||n.error("mkp.unclosed-text",'the long text opened with """ on this line is never closed; found the end of the block before a closing """. Add a line holding only """ where the text ends',{file:e,line:l,col:u+d.longOpen+1});let $=e$(Xw(m));p=p.slice(0,d.longOpen)+$+y;continue}if(d.depth>0&&o<r.length){let m=r[o],g=m.length-m.trimStart().length;h.push({at:p.length+1,line:o+1,col:g+1}),p=p+" "+m.trim(),o++;continue}if(d.depth>0){let m=d.open[d.open.length-1],g=Qw[m.ch],y=new kn(e,h).at(m.at);n.error("mkp.unclosed-bracket",`the \`${m.ch}\` here is never closed, so every line after it was read as part of this one; found no matching \`${g}\` before the end of the block. Add \`${g}\` where the bracketed part ends`,y)}break}i.push({indent:u,text:p,segs:h,comments:s,children:[],line:l}),s=[]}return Zw(i,e,n)}function Zw(t,e,n){let r={indent:-2,text:"",segs:[],comments:[],children:[],line:0},i=[r];for(let s of t){for(;i.length>1&&i[i.length-1].indent>=s.indent;)i.pop();let o=i[i.length-1],a=o.indent+2;s.indent!==a&&!(o===r&&s.indent===0)&&(o===r?n.error("mkp.indent",`this line is indented ${s.indent} spaces, but it is not under any line, so it must start at the margin; found ${s.indent} spaces. Remove the indentation, or indent the line above it less`,{file:e,line:s.line,col:1}):s.indent>a?n.error("mkp.indent",`this line is indented ${s.indent} spaces, but a line goes at most two spaces deeper than the line it sits under (\`${Ql(o)}\`, at ${o.indent}); found ${s.indent}. Indent it ${a} spaces to put it under \`${Ql(o)}\`, or ${o.indent} to line it up with it`,{file:e,line:s.line,col:1}):s.indent%2!==0&&n.error("mkp.indent",`indentation must be a multiple of two spaces; found ${s.indent} spaces on this line. Indent it ${s.indent-1} spaces, or ${a} to put it under \`${Ql(o)}\``,{file:e,line:s.line,col:1})),o.children.push(s),i.push(s)}return r.children}var Qw={"(":")","[":"]","{":"}"};function Ql(t){let e=t.text.trim();return e.length>30?`${e.slice(0,27)}\u2026`:e}function Xw(t){let e=t.filter(r=>r.trim()!==""),n=e.length?Math.min(...e.map(r=>r.length-r.trimStart().length)):0;return t.map(r=>r.slice(n).replace(/\s+$/,"")).join(`
153
+ `).replace(/^\n+|\n+$/g,"")}function e$(t){let e='"',n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(i==="\\"&&r+1<t.length){e+=i+t[r+1],r++;continue}i==="$"&&(n=!n),i===`
154
+ `?e+=n?" ":"\\n":i==='"'?e+='\\"':e+=i}return e+'"'}function t$(t){let e=0,n=[],r=0;for(;r<t.length;){let i=t[r];if(i==='"'){if(t.startsWith('"""',r)){let s=t.indexOf('"""',r+3);if(s<0)return{depth:e,longOpen:r,open:n};r=s+3;continue}r=Br(t,r);continue}if(i==="$"){r=bn(t,r);continue}i==="("||i==="["||i==="{"?(e++,n.push({ch:i,at:r})):(i===")"||i==="]"||i==="}")&&(e=Math.max(0,e-1),n.pop()),r++}return{depth:e,longOpen:-1,open:n}}function Br(t,e){let n=e+1;for(;n<t.length;){let r=t[n];if(r==="\\"){n+=2;continue}if(r==='"')return n+1;n++}return n}function bn(t,e){let n=t.startsWith("$$",e),r=e+(n?2:1);for(;r<t.length;){let i=t[r];if(i==="\\"){r+=2;continue}if(i==="$")if(n){if(t.startsWith("$$",r))return r+2}else return r+1;r++}return r}function jn(t){let e=t.slice(1,t.endsWith('"')&&t.length>1?-1:void 0),n="",r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(s==="\\"&&i+1<e.length){let o=e[i+1];if(!r&&(o==='"'||o==="\\")){n+=o,i++;continue}if(!r&&o==="n"){n+=`
155
+ `,i++;continue}n+=s+o,i++;continue}s==="$"&&(r=!r),n+=s}return n}function Oe(t){let e='"',n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(i==="$"&&!(r>0&&t[r-1]==="\\")&&(n=!n),n){e+=i;continue}if(i==='"')e+='\\"';else if(i===`
156
+ `)e+="\\n";else if(i==="\\"){let s=t[r+1];s==='"'||s==="\\"||s==="n"?e+="\\\\":e+="\\"}else e+=i}return e+'"'}function Xe(t,e=0){let n=[],r=e,i=-1,s=0;for(;r<t.length;){let o=t[r];if(i<0&&o!==" "&&(i=r),o==='"'){r=Br(t,r);continue}if(o==="$"){r=bn(t,r);continue}o==="("||o==="["||o==="{"?s++:o===")"||o==="]"||o==="}"?s=Math.max(0,s-1):o===" "&&s===0&&i>=0&&(n.push({text:t.slice(i,r),at:i}),i=-1),r++}return i>=0&&i<t.length&&n.push({text:t.slice(i),at:i}),n}var n$=["=>","==","!=","<=",">=","..","<",">","+","-","*","/","^","(",")","[","]","{","}",",",":",".","=","|","@","#"];function bo(t,e,n){let r=[],i=e,s=!0;for(;i<n;){let o=t[i];if(o===" "||o===`
157
+ `||o===" "){s=!0,i++;continue}let a=i;if(/[0-9]/.test(o)||o==="."&&/[0-9]/.test(t[i+1]??"")&&t[i-1]!=="."){let l=i;for(;l<n&&/[0-9]/.test(t[l]);)l++;if(t[l]==="."&&/[0-9]/.test(t[l+1]??""))for(l++;l<n&&/[0-9]/.test(t[l]);)l++;if((t[l]==="e"||t[l]==="E")&&(/[0-9]/.test(t[l+1]??"")||/[+-]/.test(t[l+1]??"")&&/[0-9]/.test(t[l+2]??"")))for(l+=2;l<n&&/[0-9]/.test(t[l]);)l++;let c=t.slice(i,l);r.push({k:"num",v:c,at:a,sp:s,num:Number(c)}),i=l}else if(/[A-Za-z_]/.test(o)){let l=i;for(;l<n&&/[A-Za-z0-9_]/.test(t[l]);)l++;r.push({k:"id",v:t.slice(i,l),at:a,sp:s}),i=l}else if(o==='"'){let l=Math.min(Br(t,i),n);r.push({k:"str",v:jn(t.slice(i,l)),at:a,sp:s}),i=l}else if(o==="$"){let l=Math.min(bn(t,i),n),c=t.startsWith("$$",i),u=c?2:1;r.push({k:"tex",v:t.slice(i+u,Math.max(i+u,l-u)),at:a,sp:s,display:c}),i=l}else{let l=n$.find(c=>t.startsWith(c,i));l?(r.push({k:"op",v:l,at:a,sp:s}),i+=l.length):(r.push({k:"op",v:o,at:a,sp:s}),i++)}s=!1}return r.push({k:"eof",v:"",at:n,sp:!0}),r}function Up(t){let e="",n=0,r=!1;for(;n<t.length;){let i=t[n];if(i==='"'){let s=Br(t,n);r&&e&&!/[([{]$/.test(e)&&(e+=" "),r=!1,e+=t.slice(n,s),n=s;continue}if(i==="$"){let s=bn(t,n);r&&e&&!/[([{]$/.test(e)&&(e+=" "),r=!1,e+=t.slice(n,s),n=s;continue}if(i===" "||i===`
158
+ `||i===" "){r=!0,n++;continue}r&&e&&!/[([{]$/.test(e)&&!/[)\]},]/.test(i)&&(e+=" "),r=!1,e+=i,n++}return e}var ec=new Set(["and","or","not"]),Wp=new Set(["==","!=","<","<=",">",">="]);function en(t){if(t.k==="eof")return"the end of the expression";let e=t.k==="str"?`"${t.v}"`:t.k==="tex"?t.display?`$$${t.v}$$`:`$${t.v}$`:t.v;return`\`${e.length>40?`${e.slice(0,37)}\u2026`:e}\``}function zi(t,e=40){let n=t.trim().replace(/\s+/g," ");return n.length>e?`\u2026${n.slice(n.length-e+1)}`:n}var Ui={")":"(","]":"[","}":"{"},tn=class t{constructor(e,n,r,i){this.text=e;this.from=n;this.map=i;this.toks=bo(e,n,r)}i=0;toks;static parse(e,n,r,i){let s=new t(e,n,r,i),o=s.expr(),a=s.peek();return a.k!=="eof"&&s.trailing(a),o}before(e){return zi(this.text.slice(this.from,e.at))}trailing(e){let n=this.before(e);e.k==="op"&&Ui[e.v]&&this.fail(e,`the expression has a \`${e.v}\` with no \`${Ui[e.v]}\` to match it; found \`${e.v}\` after \`${n}\`. Remove the \`${e.v}\`, or add the \`${Ui[e.v]}\` it closes`),e.k==="op"&&e.v==="="&&this.fail(e,`an expression can't hold \`=\`; found \`=\` after \`${n}\`. To compare two values, write \`==\`; to set a value, use \`set name=(\u2026)\` in an event`),e.k==="op"&&e.v===","&&this.fail(e,`the expression \`${n}\` is followed by a comma, which only separates items inside brackets; found \`,\`. Remove it, or bracket the items: \`[a, b]\` for a list, \`(x, y)\` for a point`);let r=e.k==="str"||e.k==="tex"?"To join texts, put `+` between them":"Put an operator between them (`+`, `*`, `and`, \u2026)";this.fail(e,`the expression \`${n}\` is complete, so ${en(e)} can't follow it; found ${en(e)} after it. ${r}, or remove ${en(e)}`)}peek(e=0){return this.toks[Math.min(this.i+e,this.toks.length-1)]}next(){return this.toks[this.i++]}pos(e){return this.map.at(e.at)}fail(e,n){throw new K("mkp.syntax",n,this.pos(e))}isOp(e,n=0){let r=this.peek(n);return r.k==="op"&&r.v===e}expect(e,n,r){let i=this.next();return(i.k!=="op"||i.v!==e)&&this.fail(i.k==="eof"&&r?r:i,n(en(i))),i}expr(){let e=this.tryLambda();return e||this.or()}tryLambda(){let e=this.peek();if(e.k==="id"&&!ec.has(e.v)&&this.isOp("=>",1))return this.i+=2,{k:"lam",params:[e.v],body:this.expr(),p:this.pos(e)};if(this.isOp("(")){let n=1,r=[];for(;;){let i=this.peek(n);if(i.k!=="id")return null;if(r.push(i.v),n++,this.isOp(",",n)){n++;continue}return this.isOp(")",n)&&this.isOp("=>",n+1)?(this.i+=n+2,{k:"lam",params:r,body:this.expr(),p:this.pos(e)}):null}}return null}or(){let e=this.and();for(;this.peek().k==="id"&&this.peek().v==="or";){let n=this.next();e={k:"bin",op:"or",a:e,b:this.and(),p:this.pos(n)}}return e}and(){let e=this.not();for(;this.peek().k==="id"&&this.peek().v==="and";){let n=this.next();e={k:"bin",op:"and",a:e,b:this.not(),p:this.pos(n)}}return e}not(){let e=this.peek();return e.k==="id"&&e.v==="not"?(this.next(),{k:"not",a:this.not(),p:this.pos(e)}):this.cmp()}cmp(){let e=this.peek(),n=this.sum(),r=this.peek();if(r.k==="op"&&Wp.has(r.v)){this.next();let i=this.sum(),s=this.peek();return s.k==="op"&&Wp.has(s.v)&&this.chained(e,r,s),{k:"bin",op:r.v,a:n,b:i,p:this.pos(r)}}return n}chained(e,n,r){let i=this.text.slice(e.at,n.at).trim(),s=this.text.slice(n.at+n.v.length,r.at).trim(),o="\u2026";try{this.next(),this.sum(),o=this.text.slice(r.at+r.v.length,this.peek().at).trim()||"\u2026"}catch{}let a=zi(`${i} ${n.v} ${s}`);this.fail(r,`comparisons can't be chained; found a second \`${r.v}\` after \`${a}\`. Write two comparisons joined with \`and\`: \`${zi(`${i} ${n.v} ${s} and ${s} ${r.v} ${o}`,60)}\``)}sum(){let e=this.product();for(;;){let n=this.peek();if(n.k==="op"&&(n.v==="+"||n.v==="-"))this.next(),e={k:"bin",op:n.v,a:e,b:this.product(),p:this.pos(n)};else return e}}product(){let e=this.juxt();for(;;){let n=this.peek();if(n.k==="op"&&(n.v==="*"||n.v==="/"))this.next(),e={k:"bin",op:n.v,a:e,b:this.juxt(),p:this.pos(n)};else return e}}juxt(){let e=this.unary();for(;this.startsAtom();){let n=this.peek();e={k:"bin",op:"*",a:e,b:this.power(),juxt:!0,p:this.pos(n)}}return e}startsAtom(){let e=this.peek();return e.k==="num"?!0:e.k==="id"?!ec.has(e.v)&&!this.isOp("=>",1):e.k==="op"&&e.v==="("?this.tryLambdaAhead()===!1:!1}tryLambdaAhead(){let e=1;for(;;){if(this.peek(e).k!=="id")return!1;if(e++,this.isOp(",",e)){e++;continue}return this.isOp(")",e)&&this.isOp("=>",e+1)}}unary(){let e=this.peek();return e.k==="op"&&e.v==="-"?(this.next(),{k:"neg",a:this.unary(),p:this.pos(e)}):this.power()}power(){let e=this.postfix(),n=this.peek();return n.k==="op"&&n.v==="^"?(this.next(),{k:"bin",op:"^",a:e,b:this.unary(),p:this.pos(n)}):e}postfix(){let e=this.isOp("("),n=this.atom(),r=0;for(;;){let i=this.peek();if(i.k==="op"&&i.v==="("&&!i.sp&&n.k!=="num"&&!(e&&r===0&&n.k!=="lam")){this.next();let s=this.list(")",`the arguments of ${n.k==="id"?`${n.name}(\u2026)`:"the call"}`,"argument");n=n.k==="id"?{k:"call",f:n.name,args:s,p:n.p}:{k:"apply",f:n,args:s,p:this.pos(i)},r++}else if(i.k==="op"&&i.v==="["&&!i.sp){this.next();let s=this.expr();this.expect("]",o=>`the index opened with \`[\` is not closed; found ${o} where \`]\` should end it. Add \`]\` after the index, e.g. \`xs[i]\``),n={k:"index",o:n,i:s,p:this.pos(i)}}else if(i.k==="op"&&i.v==="."&&!i.sp){this.next();let s=this.next();if(s.k!=="id"){let o=this.before(i);this.fail(s,`\`.\` after \`${o}\` must be followed by a field name; found ${en(s)}. Write the field's name, e.g. \`${o}.x\` (a point's parts are \`.x\` and \`.y\`), or use \`${o}[i]\` for an item of a list`)}n={k:"field",o:n,name:s.v,p:this.pos(i)}}else return n}}list(e,n,r){let i=[];if(this.isOp(e))return this.next(),i;for(;;){if(i.push(this.expr()),this.isOp(",")){this.next();continue}return this.expect(e,s=>`${n} must be separated by \`,\` and end with \`${e}\`; found ${s} after ${r} ${i.length}. Add \`,\` before the next ${r}, or \`${e}\` to end the list there`),i}}atom(){let e=this.next(),n=this.pos(e);switch(e.k){case"num":return{k:"num",v:e.num,p:n};case"str":return{k:"str",v:e.v,p:n};case"tex":return{k:"tex",v:e.v,display:!!e.display,p:n};case"id":return ec.has(e.v)&&this.keywordAsValue(e),{k:"id",name:e.v,p:n};case"op":if(e.v==="("){let r=this.expr();if(this.isOp(",")){this.next();let i=this.expr();return this.expect(")",s=>this.peek(-1).v===","?"a point `(x, y)` has exactly two parts; found a third after the second comma. Remove it, or write a list in square brackets: `[a, b, c]`":`the point opened with \`(\` is not closed; found ${s} after its second part. Add \`)\` after it: \`(x, y)\``),{k:"point",x:r,y:i,p:n}}return this.expect(")",i=>`the bracket \`(\` opened before \`${zi(this.text.slice(e.at+1,this.peek(-1).at),30)}\` is not closed; found ${i} where \`)\` should be. Add \`)\` where the bracketed part ends`,e),r}if(e.v==="[")return{k:"list",items:this.list("]","the items of a list","item"),p:n};if(e.v==="{"){let r=[];if(this.isOp("}"))return this.next(),{k:"rec",fields:r,p:n};for(;;){let i=this.next();i.k!=="id"&&i.k!=="str"&&(i.k==="op"&&i.v==="}"&&r.length&&this.fail(i,"a record can't end with a comma; found `,` before `}`. Remove the last comma, e.g. `{a: 1, b: 2}`"),this.fail(i,`a record field's name must be a word or a quoted text; found ${en(i)}. Write e.g. \`{a: \u2026}\`${i.k==="num"?`, or quote it: \`{"${i.v}": \u2026}\``:""}`));let s=i.k==="str"?`"${i.v}"`:i.v;if(this.expect(":",o=>{let a=this.peek(-1),l=a.k==="num"||a.k==="id"?a.v:"\u2026";return`the record field \`${s}\` needs \`:\` between its name and its value; found ${o}. Write \`{${s}: ${l}}\``}),r.push([i.v,this.expr()]),this.isOp(",")){this.next();continue}return this.expect("}",o=>`the fields of a record must be separated by \`,\` and end with \`}\`; found ${o} after the field \`${s}\`. Add \`,\` before the next field, or \`}\` to end the record: \`{a: 1, b: 2}\``),{k:"rec",fields:r,p:n}}}return e.v==="|"&&this.fail(e,"MKP has no `|x|` for absolute value; found `|`. Write `abs(x)` instead, e.g. `abs(n - 3)`"),this.needValue(e);default:return this.needValue(e)}}keywordAsValue(e){let n=this.before(e),r=n?`after \`${n}\``:"at the start of the expression";e.v==="not"&&this.fail(e,`a value is needed ${r}; found \`not\`, which can't sit inside arithmetic without brackets. Bracket it, e.g. \`(not done)\``),this.fail(e,`a value is needed ${r}; found \`${e.v}\`, which only joins two conditions (\`a ${e.v} b\`). Put a value here, such as a number or a name, or remove the \`${e.v}\``)}needValue(e){let n=this.before(e),r=this.peek(-2);if(e.k==="eof"){n||this.fail(e,"the expression is empty; found nothing where a value should be. Write a value, such as a number, a name or a quoted text");let o=this.toks[this.i-2]??e;this.fail(o,`the expression \`${n}\` stops before its last value; found the end of the expression after ${en(o)}. Finish it, e.g. \`${zi(n,30)} ${o.v==="not"?"done":"1"}\`, or remove the trailing ${en(o)}`)}let i=n?`after \`${n}\``:"at the start of the expression",s;e.k==="op"&&Ui[e.v]?s=r?.k==="op"&&r.v===","?`Remove the comma before \`${e.v}\``:`Put a value before \`${e.v}\`, or remove the brackets`:e.v===","?s="Remove the extra comma, or put a value before it":e.v==="="?s="To compare two values, write `==`":e.v===".."?s="A range has a start and an end: `0..10`":e.v==="=>"?s="A function value names its parameter first: `x => x + 1`":e.v==="."?s="A field is read from a value: `p.x`":["*","/","^","+","<",">","<=",">=","==","!="].includes(e.v)?s=r&&r.k==="op"&&!Ui[r.v]&&r.v!=="("?"Remove one of the two operators":`\`${e.v}\` goes between two values: write one before it, e.g. \`2 ${e.v} 3\``:s=`Remove ${en(e)}`,this.fail(e,`a value is needed ${i}, such as a number, a name, a quoted text or a bracket; found ${en(e)}. ${s}`)}};function Hp(t){let e=[],n=t.indexOf("\\val{");for(;n>=0;){let r=1,i=n+5;for(;i<t.length&&r>0;)t[i]==="{"?r++:t[i]==="}"&&r--,i++;e.push({at:n,end:i,src:t.slice(n+5,i-1)}),n=t.indexOf("\\val{",i)}return e}var ft={budget:1e6,depth:64,steps:1e4,list:1e4},Le=class extends Error{constructor(n,r,i){super(r);this.code=n;this.where=i}},_e={ops:0,limit:ft.budget,depth:0};function H(t=1){if(_e.ops+=t,_e.ops>_e.limit)throw new Le("mkp.budget",`ran out of budget (${_e.limit.toLocaleString("en")} operations)${_e.where?` in ${_e.where}`:""}; simplify it or raise the definition's budget`,_e.where)}function Wi(t){if(t.length>ft.list)throw new Le("mkp.list-size",`a list grew to ${t.length} items; at most ${ft.list}`,_e.where);return t}function wo(t){let e=Object.create(null);for(let[n,r]of t)e[n]=r;return e}function Vr(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function cr(t,e){if(t===e)return!0;if(typeof t=="number"&&typeof e=="number")return t===e;if(Array.isArray(t)&&Array.isArray(e))return t.length===e.length&&t.every((n,r)=>cr(n,e[r]));if(t&&e&&typeof t=="object"&&typeof e=="object"&&!Array.isArray(t)&&!Array.isArray(e)){let n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(i=>Vr(e,i)&&cr(t[i],e[i]))}return!1}function Gp(t,e){if(typeof t=="number"&&typeof e=="number"||typeof t=="string"&&typeof e=="string")return t<e?-1:t>e?1:0;if(typeof t=="boolean"&&typeof e=="boolean")return Number(t)-Number(e);if(Array.isArray(t)&&Array.isArray(e)){for(let n=0;n<Math.min(t.length,e.length);n++){let r=Gp(t[n],e[n]);if(r)return r}return t.length-e.length}return 0}function $t(t,e=!1){if(Number.isNaN(t))return e?"\\text{\u2014}":"\u2014";if(!Number.isFinite(t))return t>0?e?"\\infty":"\u221E":e?"-\\infty":"\u2212\u221E";if(t===0)return"0";let n=Math.abs(t);if(n>=1e6||n<1e-4){let[r,i]=t.toExponential(3).split("e"),s=String(Number(r)),o=Number(i);return e?`${s} \\times 10^{${o}}`:`${s}e${o}`}return String(Number(t.toPrecision(4)))}function r$(t,e,n){switch(e){case"num":case"int":return $t(t,n);case"bool":return t?"true":"false";case"point":{let r=t;return`(${$t(r[0],n)}, ${$t(r[1],n)})`}case"list":return`[${t.map(r=>typeof r=="number"?$t(r,n):String(r)).join(", ")}]`;case"latex":return n?t:`$${t}$`;default:return typeof t=="number"?$t(t,n):String(t)}}var zr=class t{constructor(e,n,r,i){this.vars=e;this.parent=n;this.inst=r;this.prog=i}local(e){let n=this;for(;n;){if(n.vars&&Vr(n.vars,e))return n.vars[e];n=n.parent}if(this.inst)return this.inst.get(e);throw new Le("mkp.unbound",`"${e}" has no value here`)}instVar(e){return this.inst?this.inst.get(e):this.local(e)}child(e){return new t(e,this,this.inst,this.prog)}root(){return new t(null,null,this.inst,this.prog)}};var de=t=>t;function De(t){switch(t.t){case"num":{let e=t.v;return()=>e}case"bool":{let e=t.v;return()=>e}case"str":{let e=t.v;return()=>e}case"var":{let e=t.name;return t.from==="const"?n=>n.prog.constValue(e):t.from==="inst"?n=>(H(),n.instVar(e)):n=>(H(),n.local(e))}case"list":{let e=t.items.map(De);return n=>(H(e.length),Wi(e.map(r=>r(n))))}case"rec":{let e=t.fields.map(([n,r])=>[n,De(r)]);return n=>{H(e.length);let r=Object.create(null);for(let[i,s]of e)r[i]=s(n);return r}}case"dict0":return()=>Object.create(null);case"point":{let e=De(t.x),n=De(t.y);return r=>(H(),[e(r),n(r)])}case"field":{let e=De(t.o),n=t.name;return r=>{H();let i=e(r);if(Array.isArray(i)){if(n==="x")return i[0];if(n==="y")return i[1]}if(i&&typeof i=="object"&&Vr(i,n))return i[n];throw new Le("mkp.missing-key",`no field "${n}" here`,_e.where)}}case"index":{let e=De(t.o),n=De(t.i);return r=>{H();let i=e(r),s=n(r);if(Array.isArray(i)){let o=s;if(!Number.isInteger(o)||o<0||o>=i.length)throw new Le("mkp.index",`index ${String(s)} is out of range (0..${i.length-1}); use at(xs, i, default)`,_e.where);return i[o]}if(i&&typeof i=="object"&&Vr(i,String(s)))return i[String(s)];throw new Le("mkp.missing-key",`no key "${String(s)}"; use get(d, key, default)`,_e.where)}}case"not":{let e=De(t.a);return n=>(H(),!e(n))}case"and":{let e=De(t.a),n=De(t.b);return r=>(H(),e(r)&&n(r))}case"or":{let e=De(t.a),n=De(t.b);return r=>(H(),e(r)||n(r))}case"if":{let e=De(t.c),n=De(t.a),r=De(t.b);return i=>(H(),e(i)?n(i):r(i))}case"lam":{let e=t.params,n=De(t.body);return r=>{let i=(...s)=>{let o=Object.create(null);for(let a=0;a<e.length;a++)o[e[a]]=s[a];return n(r.child(o))};return i.__mkpFn=!0,i}}case"apply":{let e=De(t.f),n=t.args.map(De);return r=>{H();let i=e(r);if(typeof i!="function")throw new Le("mkp.not-fn","this value is not a function",_e.where);return i(...n.map(s=>s(r)))}}case"call":{let e=t.fn,n=t.args.map(De);return r=>(H(),r.prog.call(e,n.map(i=>i(r)),r))}case"fnref":{let e=t.fn;return n=>n.prog.fnValue(e,n)}case"tmpl":{let e=t.holes.map(De),n=t.v.split(/\\val\{(\d+)\}/),r=t.show,i=t.modes,s=t.kinds;return o=>{let a="";for(let l=0;l<n.length;l++){if(l%2===0){a+=n[l];continue}let c=Number(n[l]),u=e[c](o),f=i[c]==="tex";if(r[c]){let p=o.prog.call(r[c],[u],o);a+=f?p:`$${p}$`}else a+=r$(u,s[c],f)}return a}}case"builtin":return i$(t.fn,t.args.map(De))}}var tc={exp:Math.exp,ln:Math.log,sqrt:Math.sqrt,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,abs:Math.abs,floor:Math.floor,ceil:Math.ceil,round:t=>Math.floor(t+.5),sign:t=>t>0?1:t<0?-1:0,step:t=>t>=0?1:0,fact:t=>{if(!Number.isInteger(t)||t<0)return NaN;if(t>170)return 1/0;let e=1;for(let n=2;n<=t;n++)e*=n;return e},neg:t=>-t},nc={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"^":Math.pow,pow:Math.pow,atan2:Math.atan2,mod:(t,e)=>(t%e+e)%e,min:Math.min,max:Math.max};function ic(t,e){let n=(Math.imul((t|0)^2654435769,2246822507)^Math.imul((e|0)+1663821227,3266489909))>>>0;return n^=n>>>16,n=Math.imul(n,2146121005)>>>0,n^=n>>>15,n=Math.imul(n,2221713035)>>>0,n^=n>>>16,(n>>>0)/4294967296}function i$(t,e){let[n,r,i,s,o]=e;if(t in tc){let a=tc[t];return l=>(H(),a(de(n(l))))}if(t in nc){let a=nc[t];return l=>(H(),a(de(n(l)),de(r(l))))}switch(t){case"inf":return()=>1/0;case"nan":return()=>NaN;case"log":return e.length===2?a=>(H(),Math.log(de(n(a)))/Math.log(de(r(a)))):a=>(H(),Math.log10(de(n(a))));case"rand":return a=>(H(),ic(de(n(a)),de(r(a))));case"==":return a=>(H(),cr(n(a),r(a)));case"!=":return a=>(H(),!cr(n(a),r(a)));case"<":return a=>(H(),n(a)<r(a));case"<=":return a=>(H(),n(a)<=r(a));case">":return a=>(H(),n(a)>r(a));case">=":return a=>(H(),n(a)>=r(a));case"cat":return a=>{H();let l=n(a),c=r(a);return(typeof l=="number"?$t(l):String(l))+(typeof c=="number"?$t(c):String(c))};case"lcat":return a=>(H(),Wi([...n(a),...r(a)]));case"p+":return a=>{H();let l=n(a),c=r(a);return[l[0]+c[0],l[1]+c[1]]};case"p-":return a=>{H();let l=n(a),c=r(a);return[l[0]-c[0],l[1]-c[1]]};case"p*":return a=>{H();let l=n(a),c=de(r(a));return[l[0]*c,l[1]*c]};case"p/":return a=>{H();let l=n(a),c=de(r(a));return[l[0]/c,l[1]/c]};case"ps*":return a=>{H();let l=de(n(a)),c=r(a);return[c[0]*l,c[1]*l]};case"pneg":return a=>{H();let l=n(a);return[-l[0],-l[1]]};case"dist":return a=>{H();let l=n(a),c=r(a);return Math.hypot(l[0]-c[0],l[1]-c[1])};case"tex2text":return a=>`$${n(a)}$`;case"len":return a=>{H();let l=n(a);return Array.isArray(l)||typeof l=="string"?l.length:Object.keys(l).length};case"map":return a=>{let l=n(a),c=r(a);return H(l.length),l.map(u=>c(u))};case"filter":return a=>{let l=n(a),c=r(a);return H(l.length),l.filter(u=>c(u))};case"find":return a=>{let l=n(a),c=r(a);H(l.length);for(let u of l)if(c(u))return u;if(i)return i(a);throw new Le("mkp.not-found","find found nothing; give it a default: find(xs, f, default)",_e.where)};case"sort":return a=>{let l=n(a),c=r?r(a):null;H(l.length*Math.max(1,Math.ceil(Math.log2(l.length+1))));let u=l.map((f,p)=>({e:f,k:c?c(f):f,i:p}));return u.sort((f,p)=>Gp(f.k,p.k)||f.i-p.i),u.map(f=>f.e)};case"reverse":return a=>{let l=n(a);return H(l.length),[...l].reverse()};case"fold":return a=>{let l=n(a),c=r(a),u=i(a);H(l.length);for(let f of l)c=u(c,f);return c};case"group":return a=>{let l=n(a),c=r(a);H(l.length);let u=Object.create(null);for(let f of l){let p=String(c(f));(u[p]??=[]).push(f)}return u};case"index":return a=>{let l=n(a),c=r(a);H(l.length);let u=Object.create(null);for(let f of l)u[String(c(f))]=f;return u};case"indexof":return a=>{let l=n(a),c=r(a);H(l.length);for(let u=0;u<l.length;u++)if(cr(l[u],c))return u;return-1};case"range":return a=>{let l=Math.ceil(de(n(a))),c=Math.floor(de(r(a))),u=Math.max(0,c-l+1);if(u>ft.list)throw new Le("mkp.list-size",`range(${l}, ${c}) has ${u} items; at most ${ft.list}`,_e.where);return H(u),Array.from({length:u},(f,p)=>l+p)};case"zip":return a=>{let l=n(a),c=r(a),u=Math.min(l.length,c.length);return H(u),Array.from({length:u},(f,p)=>wo([["a",l[p]],["b",c[p]]]))};case"flatten":return a=>{let l=n(a);return H(l.length),Wi(l.flat())};case"at":return a=>{H();let l=n(a),c=de(r(a));if(Number.isInteger(c)&&c>=0&&c<l.length)return l[c];if(i)return i(a);throw new Le("mkp.index",`index ${de(r(a))} is out of range (0..${l.length-1}); use at(xs, i, default)`,_e.where)};case"first":return a=>{let l=n(a);return H(),l.slice(0,Math.max(0,de(r(a))))};case"last":return a=>{let l=n(a),c=Math.max(0,de(r(a)));return H(),c===0?[]:l.slice(-c)};case"slice":return a=>{let l=n(a);return H(),l.slice(de(r(a)),de(i(a)))};case"last1":return a=>{H();let l=n(a);if(!l.length)throw new Le("mkp.index","last of an empty list; use at(xs, len(xs) - 1, default)",_e.where);return l[l.length-1]};case"tslice":return a=>(H(),[...n(a)].slice(de(r(a)),de(i(a))).join(""));case"tindexof":return a=>{let l=n(a);H(l.length);let c=l.indexOf(r(a));return c<0?-1:[...l.slice(0,c)].length};case"lower":return a=>(H(),n(a).toLowerCase());case"upper":return a=>(H(),n(a).toUpperCase());case"trim":return a=>(H(),n(a).trim().replace(/\s+/g," "));case"replace":return a=>{let l=n(a);H(l.length);let c=r(a);return c?l.split(c).join(i(a)):l};case"split":return a=>{let l=n(a);H(l.length);let c=r(a),u=c?l.split(c):[...l];return Wi(u)};case"contains":return a=>(H(),n(a).includes(r(a)));case"startswith":return a=>(H(),n(a).startsWith(r(a)));case"endswith":return a=>(H(),n(a).endsWith(r(a)));case"number":return a=>{H();let l=n(a).trim().replace(/\s+/g,"").replace(/^([+-]?\d*),(\d+)$/,"$1.$2").replace(/^\+/,"");return/^-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i.test(l)?Number(l):NaN};case"lsum":return a=>{let l=n(a);H(l.length);let c=0;for(let u of l)c+=u;return c};case"mean":return a=>{let l=n(a);if(H(l.length),!l.length)return NaN;let c=0;for(let u of l)c+=u;return c/l.length};case"lmin":return a=>{let l=n(a);return H(l.length),l.length?Math.min(...l):NaN};case"lmax":return a=>{let l=n(a);return H(l.length),l.length?Math.max(...l):NaN};case"sum":case"prod":return a=>{let l=Math.ceil(de(n(a))),c=Math.floor(de(r(a))),u=i(a);if(c-l+1>ft.steps)throw new Le("mkp.steps",`${t} over ${c-l+1} terms; at most ${ft.steps}`,_e.where);let f=t==="sum"?0:1;for(let p=l;p<=c;p++)f=t==="sum"?f+de(u(p)):f*de(u(p));return f};case"sumT":case"prodT":return a=>{let l=Math.ceil(de(n(a))),c=Math.floor(de(r(a))),u=i(a),f=s(a),p=o(a);if(c-l+1>ft.steps)throw new Le("mkp.steps",`${t} over ${c-l+1} terms; at most ${ft.steps}`,_e.where);for(let h=l;h<=c;h++)p=f(p,u(h));return p};case"put":return a=>{let l=n(a),c=Object.keys(l).length;H(c+1);let u=Object.create(null);for(let f of Object.keys(l))u[f]=l[f];if(u[String(r(a))]=i(a),c+1>ft.list)throw new Le("mkp.list-size",`a dict grew past ${ft.list} keys`,_e.where);return u};case"get":return a=>{H();let l=n(a),c=String(r(a));return Vr(l,c)?l[c]:i(a)};case"keys":return a=>{let l=n(a);return H(),Object.keys(l)};case"has":return a=>(H(),Vr(n(a),String(r(a))));case"format":return a=>{H();let l=de(n(a));if(!r)return $t(l);let c=Math.max(0,Math.min(12,Math.round(de(r(a)))));return Number.isFinite(l)?l.toFixed(c):$t(l)};case"join":return a=>{let l=n(a);return H(l.length),l.map(c=>typeof c=="number"?$t(c):String(c)).join(r(a))};case"iterate":case"scan":return a=>{let l=n(a),c=de(r(a)),u=i(a);if(c>ft.steps)throw new Le("mkp.steps",`${t} for ${c} steps; at most ${ft.steps}`,_e.where);let f=t==="scan"?[l]:[];for(let p=0;p<c;p++){let h=u(l),d=cr(h,l);if(l=h,t==="scan"&&f.push(l),d)break}return t==="scan"?Wi(f):l};case"parse":return a=>{H(10);let l=r(a)??[];return a$(String(n(a)),l)};case"equivalent":return a=>(H(50),l$(String(n(a)),String(r(a)),i?.(a)??[]));case"rgb":return a=>(H(),wo([["r",Gi(de(n(a)))],["g",Gi(de(r(a)))],["b",Gi(de(i(a)))]]));case"hsl":return a=>{H();let[l,c,u]=s$(de(n(a)),de(r(a)),de(i(a)));return wo([["r",l],["g",c],["b",u]])}}throw new Le("mkp.unknown-builtin",`unknown builtin ${t}`)}function Gi(t){return Number.isNaN(t)?0:Math.min(1,Math.max(0,t))}function s$(t,e,n){t=(t%1+1)%1,e=Gi(e),n=Gi(n);let r=(1-Math.abs(2*n-1))*e,i=t*6,s=r*(1-Math.abs(i%2-1)),o=0,a=0,l=0;i<1?[o,a,l]=[r,s,0]:i<2?[o,a,l]=[s,r,0]:i<3?[o,a,l]=[0,r,s]:i<4?[o,a,l]=[0,s,r]:i<5?[o,a,l]=[s,0,r]:[o,a,l]=[r,0,s];let c=n-r/2;return[o+c,a+c,l+c]}var o$={...tc,log:Math.log10};function Hi(t,e){switch(t.k){case"num":return()=>t.v;case"id":{let n=e.indexOf(t.name);return n>=0?r=>r[n]:t.name==="pi"?()=>Math.PI:t.name==="e"?()=>Math.E:null}case"neg":{let n=Hi(t.a,e);return n&&(r=>-n(r))}case"bin":{let n=nc[t.op];if(!n)return null;let r=Hi(t.a,e),i=Hi(t.b,e);return r&&i&&(s=>n(r(s),i(s)))}case"call":{let n=o$[t.f];if(!n||t.args.length!==1)return null;let r=Hi(t.args[0],e);return r&&(i=>n(r(i)))}default:return null}}function rc(t,e){let n=t.replace(/π/g,"pi").replace(/×|·/g,"*").replace(/−/g,"-").replace(/÷/g,"/").trim();if(!n||n.length>500)return null;try{let r=new kn("<answer>",[{at:0,line:1,col:1}]);return Hi(tn.parse(n,0,n.length,r),e)}catch{return null}}function a$(t,e){let n=rc(t,e),r=(...i)=>n?n(i):NaN;return r.__mkpFn=!0,r}function l$(t,e,n){let r=rc(t,n),i=rc(e,n);if(!r||!i)return!1;let s=0;for(let o=0;o<16;o++){let a=n.map((u,f)=>-3+6*ic(7919+f,o)),l=r(a),c=i(a);if(!(Number.isNaN(l)&&Number.isNaN(c))){if(!Number.isFinite(l)||!Number.isFinite(c)){if(l!==c)return!1;continue}if(s++,Math.abs(l-c)>1e-9+1e-6*Math.max(Math.abs(l),Math.abs(c)))return!1}}return s>0||n.length===0}var c$=["color","font","space","size","radius","shadow"],E={num:{t:"num"},int:{t:"int"},bool:{t:"bool"},text:{t:"text"},latex:{t:"latex"},point:{t:"point"},duration:{t:"duration"},range:{t:"range"},slot:{t:"slot"},unknown:{t:"unknown"},any:{t:"any"},list:t=>({t:"list",of:t}),dict:t=>({t:"dict",of:t}),fn:(t,e)=>({t:"fn",params:t,ret:e})};function u$(t){return t.k==="eof"?"the end of the type":t.k==="str"?`"${t.v}"`:t.v}var f$="int, num, text, bool, list(int), dict(text) or a record such as {name: text}",sc=class{constructor(e,n,r){this.toks=e;this.map=n;this.text=r}i=0;open=[];sofar(){let e=this.open[this.open.length-1],n=this.toks[this.i-2]??this.toks[0];return e?this.text.slice(e.at,n.at+n.v.length).replace(/\s+/g," ").trim():""}peek(e=0){return this.toks[Math.min(this.i+e,this.toks.length-1)]}next(){return this.toks[this.i++]}fail(e,n){let r=this.toks[this.toks.indexOf(e)-1],i=e.k==="eof"||this.pastLine(e),s=r&&i?r.at+r.v.length:e.at,o=this.open[this.open.length-1],a=o?.close??")";if(i&&o&&!n.startsWith(`expected "${a}"`)){let l=this.text.slice(o.at,s).replace(/\s+/g," ").trim();n=`\`${l}\` is missing its closing "${a}"; found the end of the line. Add "${a}" to close ${a==="}"?"the record":`${o.name}(\u2026)`}, e.g. \`${l}${a}\``}throw new K("mkp.type-syntax",n,this.map.at(s))}pastLine(e){let n=this.toks[this.toks.indexOf(e)-1];return!!n&&this.map.at(n.at+n.v.length).line!==this.map.at(e.at).line}isOpTok(e,n){return!!e&&e.k==="op"&&e.v===n}isOp(e,n=0){let r=this.peek(n);return r.k==="op"&&r.v===e}expect(e,n){let r=this.next();if(r.k==="op"&&r.v===e)return;let i=this.open[this.open.length-1],s=this.toks[this.i-2],o=i?`\`${this.sofar()}\``:s?`\`${s.v}\``:"the type",a=n??(e===")"&&i?`Add ")" to close ${i.name}(\u2026), e.g. \`${this.sofar()})\``:`Write "${e}" there`);this.fail(r,`expected "${e}" after ${o}; found ${this.seen(r)}. ${a}`)}seen(e){return e.k!=="eof"&&this.pastLine(e)?"the end of the line":u$(e)}number(){let e=1;this.isOp("-")&&(this.next(),e=-1);let n=this.next();return n.k!=="num"&&this.fail(n,`a range in a type needs a plain number at each end, such as int 1..10; found ${this.seen(n)}. Write a number there`),e*n.num}type(){let e=this.next();if(e.k==="op"&&e.v==="{"){let n={},r=this.fieldsAfterBrace(n);return Object.keys(n).length?{t:"rec",fields:r,defaults:n}:{t:"rec",fields:r}}if(e.k!=="id"){let n=this.open[this.open.length-1];this.fail(e,`expected a type${n?` inside ${n.name}(\u2026)`:""}; found ${this.seen(e)}. Write a type such as ${f$}`)}switch(e.v){case"num":case"int":{let n={t:e.v};return(this.peek().k==="num"||this.isOp("-")&&this.peek(1).k==="num")&&(n.lo=this.number(),this.expect("..",`Write a range as lo..hi, e.g. \`${e.v} ${n.lo}..10\``),n.hi=this.number()),n}case"bool":case"text":case"latex":case"point":case"duration":case"range":case"slot":return{t:e.v};case"expr":{this.expect("(","Write the variables in brackets, e.g. `expr(x)` or `expr(t: num): point`"),this.open.push({name:"expr",at:e.at});let n=[],r;for(;!this.isOp(")");){let s=this.next();s.k==="id"&&!r&&this.pastLine(s)&&!this.isOpTok(this.toks[this.i-2],",")&&(r=s),s.k!=="id"&&r&&this.fail(r,""),s.k!=="id"&&this.fail(s,`expr(\u2026) lists the names of the variables the expression uses, e.g. expr(x) or expr(x, y), each with an optional type (expr(t: num)); found ${this.seen(s)}. Write a name such as x`);let o=E.num;this.isOp(":")&&(this.next(),o=this.type()),n.push([s.v,o]),this.isOp(",")&&this.next()}this.expect(")"),this.open.pop();let i=E.num;return this.isOp(":")&&(this.next(),i=this.type()),{t:"expr",vars:n,ret:i}}case"choice":{this.expect("(","Write the options in brackets, separated by |, e.g. `choice(low|high)`"),this.open.push({name:"choice",at:e.at});let n=[];for(;;){let r=this.next();if(r.k!=="id"&&this.fail(r,`each option of choice(\u2026) must be a word (letters, digits and _, starting with a letter), as in choice(low|high); found ${this.seen(r)}. Write a word${r.k==="num"?`, e.g. n${r.v}`:""}`),n.push(r.v),this.isOp("|")){this.next();continue}let i=this.peek();return this.expect(")",`Separate the options with | and close with ")", e.g. \`choice(${[...n,i.k==="id"?i.v:"other"].join("|")})\``),this.open.pop(),{t:"choice",opts:n}}}case"list":{if(this.expect("(","Write the item type in brackets, e.g. `list(int)`"),this.open.push({name:"list",at:e.at}),this.peek().k==="id"&&this.peek().v==="record"){this.next();let r=this.next();r.k!=="id"&&this.fail(r,`list(record \u2026) needs a name for its records after "record", e.g. list(record row {a: int}); found ${this.seen(r)}. Write a name such as row`),this.expect("{",`Write the record's fields in braces after its name, e.g. \`list(record ${r.v} {a: int})\``);let i={},s=this.fieldsAfterBrace(i),o=!1;return this.peek().k==="id"&&this.peek().v==="slot"&&(this.next(),o=!0),this.expect(")"),this.open.pop(),Object.keys(i).length?{t:"records",kind:r.v,fields:s,slot:o,defaults:i}:{t:"records",kind:r.v,fields:s,slot:o}}let n=this.type();return this.expect(")"),this.open.pop(),{t:"list",of:n}}case"dict":{this.expect("(","Write the value type in brackets, e.g. `dict(int)` (the keys are always text)"),this.open.push({name:"dict",at:e.at});let n=this.type();return this.expect(")"),this.open.pop(),{t:"dict",of:n}}case"ref":return{t:"ref",of:this.type()};case"path":{this.expect("(","Write path(record type, field type), e.g. `path(T, text)`"),this.open.push({name:"path",at:e.at});let n=this.type(),r=this.peek();this.expect(",",`path(\u2026) takes two types separated by a comma: the record and the type of the field it names, e.g. \`path(${N(n)}, ${r.k==="id"?r.v:"text"})\``);let i=this.type();return this.expect(")"),this.open.pop(),{t:"path",of:n,to:i}}default:return c$.includes(e.v)?{t:"token",kind:e.v}:{t:"named",name:e.v}}}fieldsAfterBrace(e){let n=[];if(this.isOp("}"))return this.next(),n;for(this.open.push({name:"record",at:this.toks[this.i-1].at,close:"}"});;){let r=this.next();if(r.k!=="id"&&this.fail(r,`each field of a record starts with its name, as in {title: text, count: int}; found ${this.seen(r)}. Write a name such as ${r.k==="num"?`f${r.v}`:"title"}`),this.expect(":",`Give the field a type after a colon, e.g. \`${r.v}: text\``),n.push([r.v,this.type()]),this.isOp("=")){this.next();let i=this.peek().at,s=0;for(;this.peek().k!=="eof";){let o=this.peek();if(o.k==="op"&&(o.v==="("||o.v==="["||o.v==="{")&&s++,o.k==="op"&&(o.v===")"||o.v==="]"||o.v==="}")){if(s===0)break;s--}if(o.k==="op"&&o.v===","&&s===0)break;this.next()}e&&(e[r.v]=this.text.slice(i,this.peek().at).trim())}if(this.isOp(",")){this.next();continue}return this.expect("}",'Separate the fields with commas and close the record with "}", e.g. `{a: int, b: text}`'),this.open.pop(),n}}};function ur(t,e,n,r){let i=bo(t,e,n),s=new sc(i,r,t);return{type:s.type(),end:s.peek().at}}function N(t){switch(t.t){case"num":case"int":return t.lo!==void 0?`${t.t} ${Kp(t.lo)}..${Kp(t.hi)}`:t.t;case"expr":return`expr(${t.vars.map(([e,n])=>n.t==="num"&&n.lo===void 0?e:`${e}: ${N(n)}`).join(", ")})${t.ret.t==="num"&&t.ret.lo===void 0?"":`: ${N(t.ret)}`}`;case"choice":return`choice(${t.opts.join("|")})`;case"list":return`list(${N(t.of)})`;case"dict":return`dict(${N(t.of)})`;case"rec":return t.name??`{${t.fields.map(([e,n])=>`${e}: ${N(n)}${t.defaults?.[e]!==void 0?` = ${t.defaults[e]}`:""}`).join(", ")}}`;case"named":return t.name;case"records":return`list(record ${t.kind} {${t.fields.map(([e,n])=>`${e}: ${N(n)}${t.defaults?.[e]!==void 0?` = ${t.defaults[e]}`:""}`).join(", ")}}${t.slot?" slot":""})`;case"ref":return`ref ${N(t.of)}`;case"token":return t.kind;case"fn":return`fn(${t.params.map(N).join(", ")}): ${N(t.ret)}`;case"param":return t.name;case"path":return`path(${N(t.of)}, ${N(t.to)})`;default:return t.t}}function Kp(t){return String(t)}function P(t,e){let n=t;for(let r=0;r<20&&n.t==="named";r++){let i=e(n.name);if(!i)return n;n=i.t==="rec"?{...i,name:n.name}:i}return n}function vt(t,e,n=new Set){if(t.t==="named"){if(n.has(t.name))return t;let i=P(t,e);return i.t==="named"?i:vt(i,e,new Set([...n,t.name]))}let r=([i,s])=>[i,vt(s,e,n)];switch(t.t){case"list":return{...t,of:vt(t.of,e,n)};case"dict":return{...t,of:vt(t.of,e,n)};case"ref":return{...t,of:vt(t.of,e,n)};case"rec":return{...t,fields:t.fields.map(r),...t.name?{name:t.name}:{}};case"records":return{...t,fields:t.fields.map(r)};default:return t}}function Je(t,e,n,r=new Set){if(t.t==="named"&&e.t==="named"&&t.name===e.name)return!0;let i=`${N(t)}=${N(e)}`;if(r.has(i)||(r.add(i),t=P(t,n),e=P(e,n),t.t==="any"||e.t==="any"))return!0;if((t.t==="num"||t.t==="int")&&(e.t==="num"||e.t==="int"))return t.t===e.t;if(t.t!==e.t)return!1;switch(t.t){case"list":case"dict":return Je(t.of,e.of,n,r);case"ref":return Je(t.of,e.of,n,r);case"rec":{let s=e.fields;return t.name&&e.name?t.name===e.name:t.fields.length===s.length&&t.fields.every(([o,a])=>{let l=s.find(([c])=>c===o);return!!l&&Je(a,l[1],n,r)})}case"choice":return t.opts.join("|")===e.opts.join("|");case"token":return t.kind===e.kind;case"fn":{let s=e;return t.params.length===s.params.length&&t.params.every((o,a)=>Je(o,s.params[a],n,r))&&Je(t.ret,s.ret,n,r)}case"expr":{let s=e;return t.vars.length===s.vars.length&&t.vars.every(([,o],a)=>Je(o,s.vars[a][1],n,r))&&Je(t.ret,s.ret,n,r)}case"param":return t.name===e.name;case"path":{let s=e;return Je(t.of,s.of,n,r)&&Je(t.to,s.to,n,r)}default:return!0}}function jt(t,e){switch(t.t){case"param":return e[t.name]??t;case"named":return e[t.name]??t;case"list":case"dict":case"ref":return{...t,of:jt(t.of,e)};case"rec":case"records":return{...t,fields:t.fields.map(([n,r])=>[n,jt(r,e)])};case"fn":return{t:"fn",params:t.params.map(n=>jt(n,e)),ret:jt(t.ret,e)};case"expr":return{t:"expr",vars:t.vars.map(([n,r])=>[n,jt(r,e)]),ret:jt(t.ret,e)};case"path":return{t:"path",of:jt(t.of,e),to:jt(t.to,e)};default:return t}}function nn(t){switch(t.t){case"param":return!0;case"list":case"dict":case"ref":return nn(t.of);case"rec":case"records":return t.fields.some(([,e])=>nn(e));case"fn":return t.params.some(nn)||nn(t.ret);case"expr":return t.vars.some(([,e])=>nn(e))||nn(t.ret);case"path":return nn(t.of)||nn(t.to);default:return!1}}function ae(t,e,n){return t=P(t,n),e=P(e,n),t.t==="any"||e.t==="any"||t.t==="unknown"||e.t==="unknown"||e.t==="num"&&(t.t==="num"||t.t==="int")||e.t==="int"&&t.t==="int"||e.t==="text"&&(t.t==="text"||t.t==="latex"||t.t==="choice")?!0:e.t==="ref"?ae(t.t==="ref"?t.of:t,e.of,n):t.t==="ref"?ae(t.of,e,n):e.t==="choice"&&t.t==="choice"?t.opts.every(r=>e.opts.includes(r)):e.t==="list"&&t.t==="list"||e.t==="dict"&&t.t==="dict"?ae(t.of,e.of,n):e.t==="dict"&&t.t==="rec"&&t.fields.length===0?!0:e.t==="rec"&&t.t==="rec"?e.name&&t.name?e.name===t.name:e.fields.every(([r,i])=>{let s=t.fields.find(([o])=>o===r);return!!s&&ae(s[1],i,n)})&&t.fields.every(([r])=>e.fields.some(([i])=>i===r)):e.t==="fn"&&t.t==="fn"?t.params.length===e.params.length&&ae(t.ret,e.ret,n):e.t==="expr"&&t.t==="fn"?ae(t.ret,e.ret,n):Je(t,e,n)}function Ue(t,e,n){let r=P(t,n),i=P(e,n);if(r.t==="unknown"||r.t==="any")return e;if(i.t==="unknown"||i.t==="any")return t;if(r.t==="path"&&i.t==="text"||r.t==="text"&&i.t==="path")return E.text;if((r.t==="int"||r.t==="num")&&(i.t==="int"||i.t==="num"))return r.t==="int"&&i.t==="int"?E.int:E.num;if(r.t==="choice"&&i.t==="choice")return{t:"choice",opts:[...new Set([...r.opts,...i.opts])]};if((r.t==="text"||r.t==="choice")&&(i.t==="text"||i.t==="choice"))return E.text;if(r.t==="list"&&i.t==="list"){let s=Ue(r.of,i.of,n);return s?E.list(s):null}if(r.t==="dict"&&i.t==="dict"){let s=Ue(r.of,i.of,n);return s?E.dict(s):null}if(r.t==="dict"&&i.t==="rec"&&i.fields.length===0)return t;if(i.t==="dict"&&r.t==="rec"&&r.fields.length===0)return e;if(r.t==="rec"&&i.t==="rec"&&!r.name&&!i.name&&r.fields.length===i.fields.length){let s=[];for(let[o,a]of r.fields){let l=i.fields.find(([u])=>u===o);if(!l)return null;let c=Ue(a,l[1],n);if(!c)return null;s.push([o,c])}return{t:"rec",fields:s}}return r.t==="rec"&&i.t==="rec"&&(r.name||i.name)&&ae(r,i,n)?r.name?t:e:Je(r,i,n)?t:null}function Ne(t){return t.t==="num"||t.t==="int"}function Pt(t){switch(t.t){case"unknown":return!0;case"list":case"dict":return Pt(t.of);case"rec":return t.fields.some(([,e])=>Pt(e));default:return!1}}var Yp=require("module"),p$=(0,Yp.createRequire)("/"),h$;try{h$=p$("worker_threads").Worker}catch{}var xt=Uint8Array,Ur=Uint16Array,d$=Int32Array,Jp=new xt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Zp=new xt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),m$=new xt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Qp=function(t,e){for(var n=new Ur(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];for(var i=new d$(n[30]),r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return{b:n,r:i}},Xp=Qp(Jp,2),eh=Xp.b,g$=Xp.r;eh[28]=258,g$[258]=28;var th=Qp(Zp,0),y$=th.b,HI=th.r,cc=new Ur(32768);for($e=0;$e<32768;++$e)wn=($e&43690)>>1|($e&21845)<<1,wn=(wn&52428)>>2|(wn&13107)<<2,wn=(wn&61680)>>4|(wn&3855)<<4,cc[$e]=((wn&65280)>>8|(wn&255)<<8)>>1;var wn,$e,Ki=function(t,e,n){for(var r=t.length,i=0,s=new Ur(e);i<r;++i)t[i]&&++s[t[i]-1];var o=new Ur(e);for(i=1;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(n){a=new Ur(1<<e);var l=15-e;for(i=0;i<r;++i)if(t[i])for(var c=i<<4|t[i],u=e-t[i],f=o[t[i]-1]++<<u,p=f|(1<<u)-1;f<=p;++f)a[cc[f]>>l]=c}else for(a=new Ur(r),i=0;i<r;++i)t[i]&&(a[i]=cc[o[t[i]-1]++]>>15-t[i]);return a},Yi=new xt(288);for($e=0;$e<144;++$e)Yi[$e]=8;var $e;for($e=144;$e<256;++$e)Yi[$e]=9;var $e;for($e=256;$e<280;++$e)Yi[$e]=7;var $e;for($e=280;$e<288;++$e)Yi[$e]=8;var $e,nh=new xt(32);for($e=0;$e<32;++$e)nh[$e]=5;var $e;var k$=Ki(Yi,9,1);var b$=Ki(nh,5,1),oc=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},_t=function(t,e,n){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(e&7)&n},ac=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(e&7)},w$=function(t){return(t+7)/8|0},fc=function(t,e,n){return(e==null||e<0)&&(e=0),(n==null||n>t.length)&&(n=t.length),new xt(t.subarray(e,n))};var $$=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Dt=function(t,e,n){var r=new Error(e||$$[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,Dt),!n)throw r;return r},v$=function(t,e,n,r){var i=t.length,s=r?r.length:0;if(!i||e.f&&!e.l)return n||new xt(0);var o=!n,a=o||e.i!=2,l=e.i;o&&(n=new xt(i*3));var c=function(Qt){var dn=n.length;if(Qt>dn){var Lr=new xt(Math.max(dn*2,Qt));Lr.set(n),n=Lr}},u=e.f||0,f=e.p||0,p=e.b||0,h=e.l,d=e.d,m=e.m,g=e.n,y=i*8;do{if(!h){u=_t(t,f,1);var $=_t(t,f+1,3);if(f+=3,$)if($==1)h=k$,d=b$,m=9,g=5;else if($==2){var v=_t(t,f,31)+257,D=_t(t,f+10,15)+4,I=v+_t(t,f+5,31)+1;f+=14;for(var L=new xt(I),T=new xt(19),G=0;G<D;++G)T[m$[G]]=_t(t,f+G*3,7);f+=D*3;for(var R=oc(T),j=(1<<R)-1,O=Ki(T,R,1),G=0;G<I;){var A=O[_t(t,f,j)];f+=A&15;var b=A>>4;if(b<16)L[G++]=b;else{var _=0,W=0;for(b==16?(W=3+_t(t,f,3),f+=2,_=L[G-1]):b==17?(W=3+_t(t,f,7),f+=3):b==18&&(W=11+_t(t,f,127),f+=7);W--;)L[G++]=_}}var Y=L.subarray(0,v),q=L.subarray(v);m=oc(Y),g=oc(q),h=Ki(Y,m,1),d=Ki(q,g,1)}else Dt(1);else{var b=w$(f)+4,k=t[b-4]|t[b-3]<<8,w=b+k;if(w>i){l&&Dt(0);break}a&&c(p+k),n.set(t.subarray(b,w),p),e.b=p+=k,e.p=f=w*8,e.f=u;continue}if(f>y){l&&Dt(0);break}}a&&c(p+131072);for(var x=(1<<m)-1,ge=(1<<g)-1,Ee=f;;Ee=f){var _=h[ac(t,f)&x],S=_>>4;if(f+=_&15,f>y){l&&Dt(0);break}if(_||Dt(2),S<256)n[p++]=S;else if(S==256){Ee=f,h=null;break}else{var pe=S-254;if(S>264){var G=S-257,rt=Jp[G];pe=_t(t,f,(1<<rt)-1)+eh[G],f+=rt}var Zt=d[ac(t,f)&ge],In=Zt>>4;Zt||Dt(3),f+=Zt&15;var q=y$[In];if(In>3){var rt=Zp[In];q+=ac(t,f)&(1<<rt)-1,f+=rt}if(f>y){l&&Dt(0);break}a&&c(p+131072);var Pe=p+pe;if(p<q){var Rn=s-q,Mt=Math.min(q,Pe);for(Rn+p<0&&Dt(3);p<Mt;++p)n[p]=r[Rn+p]}for(;p<Pe;++p)n[p]=n[p-q]}}e.l=h,e.p=Ee,e.b=p,e.f=u,h&&(u=1,e.m=m,e.d=d,e.n=g)}while(!u);return p!=n.length&&o?fc(n,0,p):n.subarray(0,p)};var x$=new xt(0);var rn=function(t,e){return t[e]|t[e+1]<<8},qt=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},lc=function(t,e){return qt(t,e)+qt(t,e+4)*4294967296};function E$(t,e){return v$(t,{i:2},e&&e.out,e&&e.dictionary)}var uc=typeof TextDecoder<"u"&&new TextDecoder,S$=0;try{uc.decode(x$,{stream:!0}),S$=1}catch{}var A$=function(t){for(var e="",n=0;;){var r=t[n++],i=(r>127)+(r>223)+(r>239);if(n+i>t.length)return{s:e,r:fc(t,n-1)};i?i==3?(r=((r&15)<<18|(t[n++]&63)<<12|(t[n++]&63)<<6|t[n++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?e+=String.fromCharCode((r&31)<<6|t[n++]&63):e+=String.fromCharCode((r&15)<<12|(t[n++]&63)<<6|t[n++]&63):e+=String.fromCharCode(r)}};function T$(t,e){if(e){for(var n="",r=0;r<t.length;r+=16384)n+=String.fromCharCode.apply(null,t.subarray(r,r+16384));return n}else{if(uc)return uc.decode(t);var i=A$(t),s=i.s,n=i.r;return n.length&&Dt(8),s}}var D$=function(t,e){return e+30+rn(t,e+26)+rn(t,e+28)},N$=function(t,e,n){var r=rn(t,e+28),i=T$(t.subarray(e+46,e+46+r),!(rn(t,e+8)&2048)),s=e+46+r,o=qt(t,e+20),a=n&&o==4294967295?C$(t,s):[o,qt(t,e+24),qt(t,e+42)],l=a[0],c=a[1],u=a[2];return[rn(t,e+10),l,c,i,s+rn(t,e+30)+rn(t,e+32),u]},C$=function(t,e){for(;rn(t,e)!=1;e+=4+rn(t,e+2));return[lc(t,e+12),lc(t,e+4),lc(t,e+20)]};function rh(t,e){for(var n={},r=t.length-22;qt(t,r)!=101010256;--r)(!r||t.length-r>65558)&&Dt(13);var i=rn(t,r+8);if(!i)return{};var s=qt(t,r+16),o=s==4294967295||i==65535;if(o){var a=qt(t,r-12);o=qt(t,a)==101075792,o&&(i=qt(t,a+32),s=qt(t,a+48))}for(var l=e&&e.filter,c=0;c<i;++c){var u=N$(t,s,o),f=u[0],p=u[1],h=u[2],d=u[3],m=u[4],g=u[5],y=D$(t,g);s=m,(!l||l({name:d,size:p,originalSize:h,compression:f}))&&(f?f==8?n[d]=E$(t.subarray(y,y+p),{out:new xt(h)}):Dt(14,"unknown compression type "+f):n[d]=fc(t,y,y+p))}return n}var fr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function $o(t){let e="",n=0;for(;n+2<t.length;n+=3){let r=t[n]<<16|t[n+1]<<8|t[n+2];e+=fr[r>>18]+fr[r>>12&63]+fr[r>>6&63]+fr[r&63]}if(n<t.length){let r=t[n]<<16|(t[n+1]??0)<<8;e+=fr[r>>18]+fr[r>>12&63]+(n+1<t.length?fr[r>>6&63]:"=")+"="}return e}var nR={terms:2e3,source:64*1024};var rR=(()=>{let t=new Uint32Array(256);for(let e=0;e<256;e++){let n=e;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n>>>0}return t})();var Ft=["minwidth","minheight","aspect"],Wr=t=>Ft.includes(t);function sn(t,e){let n=String(e).trim().replace(/^"(.*)"$/s,"$1").replace(/^\((.*)\)$/s,"$1").trim(),r=/^(\d+(?:\.\d+)?)\s*[/:]\s*(\d+(?:\.\d+)?)$/.exec(n),i=r?t==="aspect"?Number(r[1])/Number(r[2]):NaN:/^\d+(?:\.\d+)?$/.test(n)?Number(n):NaN;return Number.isFinite(i)&&i>0?i:void 0}function vo(t){return t==="aspect"?"a ratio of width to height, e.g. aspect=16/9 or aspect=1.6":`a number of px greater than 0, e.g. ${t}=320`}function xo(t,e){let n={...t};for(let r of Ft)Object.keys(n).length<2&&n[r]===void 0&&e?.[r]!==void 0&&(n[r]=e[r]);return n}var pc=String.raw`pack core@1 "The base set every provider implements, and the default tokens."
159
+ provides column row grid stack text image press range meter field overlay canvas paragraph heading list quote code math divider table footnote frame pane zoom icon rgb iconname track
160
+
161
+ type rgb = {r: num, g: num, b: num}
162
+ type iconname = choice(none|play|pause|prev|next|more|less|first|last|reset|check|cross|plus|minus|up|down|left|right|ban|alert|info|help|lock|unlock|eye|edit|search|user|users|file|folder|database|server|cloud|mail|clock|calendar|flag|target|gauge|layers|branch|box|square|circle|dot|star|bolt|link|key|shield|cart|chart|code|terminal|bell|home|settings|sliders|trash|copy|download|upload|expand|lightbulb|book)
163
+ type track = text
164
+
165
+ extern column@1 "Children one below another."
166
+ in align choice(start|center|end|stretch|baseline) = stretch "how children sit across it; a child's self= overrides"
167
+ in justify choice(start|center|end|between|around) = start "where the children sit down it, when it is taller than they are"
168
+ in pad space = none "inner padding"
169
+ in padx space = none "padding at the left and right, in place of pad there"
170
+ in pady space = none "padding at the top and bottom, in place of pad there"
171
+ in gap space = none "space between children"
172
+ in width choice(auto|fit|fill) = auto "fit: as wide as its widest child; fill: the whole row"
173
+ in minwidth size = none "never narrower than this; with scroll=x, what doesn't fit scrolls sideways"
174
+ in scroll choice(none|x) = none "x: scrolls sideways when narrower than its content"
175
+ in fill color = none "background"
176
+ in tint color = none "a wash of this colour behind it: a state, not a surface"
177
+ in stroke color = none "border"
178
+ in line choice(solid|dashed|dotted) = solid "the border's line"
179
+ in edge choice(all|top|right|bottom|left|x|y) = all "which sides the border is drawn on"
180
+ in weight choice(thin|normal|thick) = thin "the border's width"
181
+ in radius radius = none "corner radius"
182
+ in shadow shadow = none
183
+ in dim bool = false "faded back, while something else is in focus"
184
+ in blur bool = false "blurred past reading, until it is revealed"
185
+ in body slot
186
+ out click "a press on its background, not on a child (pointer only)"
187
+ out enter "the pointer moved onto it (pointer only: a container takes no focus)"
188
+ out leave "the pointer left it (pointer only)"
189
+
190
+ extern row@1 "Children side by side, wrapping onto more lines (or scrolling) when they don't fit."
191
+ in align choice(start|center|end|stretch|baseline) = start "how children sit across it; a child's self= overrides"
192
+ in justify choice(start|center|end|between|around) = start "where the children sit along it; center keeps its start in view when it overflows"
193
+ in wrap bool = true "false: one line, which scrolls with scroll=x"
194
+ in pad space = none "inner padding"
195
+ in padx space = none "padding at the left and right, in place of pad there"
196
+ in pady space = none "padding at the top and bottom, in place of pad there"
197
+ in gap space = none "space between children"
198
+ in width choice(auto|fit|fill) = auto "fit: as wide as its widest child; fill: the whole row"
199
+ in minwidth size = none "never narrower than this; with scroll=x, what doesn't fit scrolls sideways"
200
+ in scroll choice(none|x) = none "x: scrolls sideways when narrower than its content"
201
+ in fill color = none "background"
202
+ in tint color = none "a wash of this colour behind it: a state, not a surface"
203
+ in stroke color = none "border"
204
+ in line choice(solid|dashed|dotted) = solid "the border's line"
205
+ in edge choice(all|top|right|bottom|left|x|y) = all "which sides the border is drawn on"
206
+ in weight choice(thin|normal|thick) = thin "the border's width"
207
+ in radius radius = none "corner radius"
208
+ in shadow shadow = none
209
+ in dim bool = false "faded back, while something else is in focus"
210
+ in blur bool = false "blurred past reading, until it is revealed"
211
+ in body slot
212
+ out click "a press on its background, not on a child (pointer only)"
213
+ out enter "the pointer moved onto it (pointer only: a container takes no focus)"
214
+ out leave "the pointer left it (pointer only)"
215
+
216
+ extern grid@1 "Children in columns: a number of equal columns, or tracks such as [auto, 1fr, 6ch]."
217
+ in cols list(track) = ["1fr", "1fr"] "the column tracks: auto (its content), Nfr (a share), Nch (characters), or a size token; a number n is n equal shares"
218
+ in align choice(start|center|end|stretch|baseline) = stretch
219
+ in justify choice(start|center|end|stretch) = stretch "how a child sits in its cell, across"
220
+ in pad space = none "inner padding"
221
+ in padx space = none "padding at the left and right, in place of pad there"
222
+ in pady space = none "padding at the top and bottom, in place of pad there"
223
+ in gap space = none "space between children"
224
+ in width choice(auto|fit|fill) = auto "fit: as wide as its widest child; fill: the whole row"
225
+ in minwidth size = none "never narrower than this; with scroll=x, what doesn't fit scrolls sideways"
226
+ in scroll choice(none|x) = none "x: scrolls sideways when narrower than its content"
227
+ in fill color = none "background"
228
+ in tint color = none "a wash of this colour behind it: a state, not a surface"
229
+ in stroke color = none "border"
230
+ in line choice(solid|dashed|dotted) = solid "the border's line"
231
+ in edge choice(all|top|right|bottom|left|x|y) = all "which sides the border is drawn on"
232
+ in weight choice(thin|normal|thick) = thin "the border's width"
233
+ in radius radius = none "corner radius"
234
+ in shadow shadow = none
235
+ in dim bool = false "faded back, while something else is in focus"
236
+ in blur bool = false "blurred past reading, until it is revealed"
237
+ in body slot
238
+ out click "a press on its background, not on a child (pointer only)"
239
+ out enter "the pointer moved onto it (pointer only: a container takes no focus)"
240
+ out leave "the pointer left it (pointer only)"
241
+
242
+ extern stack@1 "Children drawn one over another, in the order written: the last is on top. As big as its biggest child."
243
+ in align choice(start|center|end|stretch) = stretch "where children sit down it; a child's self= overrides"
244
+ in justify choice(start|center|end|stretch) = stretch "where children sit across it"
245
+ in pad space = none "inner padding"
246
+ in padx space = none "padding at the left and right, in place of pad there"
247
+ in pady space = none "padding at the top and bottom, in place of pad there"
248
+ in gap space = none "space between children"
249
+ in width choice(auto|fit|fill) = auto "fit: as wide as its widest child; fill: the whole row"
250
+ in minwidth size = none "never narrower than this; with scroll=x, what doesn't fit scrolls sideways"
251
+ in scroll choice(none|x) = none "x: scrolls sideways when narrower than its content"
252
+ in fill color = none "background"
253
+ in tint color = none "a wash of this colour behind it: a state, not a surface"
254
+ in stroke color = none "border"
255
+ in line choice(solid|dashed|dotted) = solid "the border's line"
256
+ in edge choice(all|top|right|bottom|left|x|y) = all "which sides the border is drawn on"
257
+ in weight choice(thin|normal|thick) = thin "the border's width"
258
+ in radius radius = none "corner radius"
259
+ in shadow shadow = none
260
+ in dim bool = false "faded back, while something else is in focus"
261
+ in blur bool = false "blurred past reading, until it is revealed"
262
+ in body slot
263
+ out click "a press on its background, not on a child (pointer only)"
264
+ out enter "the pointer moved onto it (pointer only: a container takes no focus)"
265
+ out leave "the pointer left it (pointer only)"
266
+
267
+ extern text@1 "A styled run of inline Markdown with inline maths."
268
+ fields value
269
+ in value text = ""
270
+ in font font = body
271
+ in tone color = none "its colour; none: the colour around it (a press's, a list's)"
272
+ in weight choice(regular|medium|bold) = regular
273
+ in size choice(small|normal|large) = normal
274
+ in align choice(start|center|end) = start
275
+ in wrap bool = true
276
+ in lines int 0..24 = 0 "height kept for this many lines, so a shorter text moves nothing below it"
277
+ in clip bool = false "cut it at lines= lines, with an ellipsis"
278
+ in literal bool = false "show the value as it is, not read as inline Markdown"
279
+ in caps bool = false "in spaced capitals: a caption or a label over a column"
280
+
281
+ extern image@1 "An asset from the pack or the document's folder."
282
+ fields src alt
283
+ in src text
284
+ in alt text
285
+ in size size = none
286
+
287
+ extern press@1 "Anything clickable and focusable: a button, a tab, an option among others, an on/off toggle or switch, an answer row with a tick (check) or a dot (radio), or its content itself, such as a card (plain)."
288
+ in kind choice(button|tab|option|toggle|switch|check|radio|plain) = button
289
+ in selected bool = false
290
+ in disabled bool = false
291
+ in label text = "" "accessible name when the content has no text"
292
+ in tone color = none
293
+ in emphasis choice(low|normal|high) = normal "how much it stands out: low for one of a row of quiet buttons, high for the one to press"
294
+ in mark text = "" "an answer row's letter (A, B, C), shown in its tick or dot until it is chosen"
295
+ in body slot
296
+ out click
297
+ out enter "the pointer moved onto it, or it took focus"
298
+ out leave "the pointer left it, or it lost focus"
299
+
300
+ extern range@1 "A value on a track: drag, or use the arrow keys."
301
+ fields value min max
302
+ in value ref num
303
+ in min num = 0
304
+ in max num = 1
305
+ in step num = 0
306
+ in label text = ""
307
+ out change {value: num}
308
+
309
+ extern meter@1 "How far along something is: a bar filled to value out of max."
310
+ fields value max
311
+ in value num
312
+ in max num = 1
313
+ in label text = ""
314
+ in tone color = accent
315
+ in size size = fill
316
+
317
+ extern field@1 "Text or number entry, on one line or several."
318
+ fields value
319
+ in value ref text
320
+ in kind choice(text|number) = text
321
+ in label text = ""
322
+ in placeholder text = ""
323
+ in width size = none
324
+ in lines int 1..24 = 1 "more than 1: a box of that many lines, where Enter starts a new line and Ctrl+Enter submits"
325
+ in tone color = none "marks it right (ok) or wrong (bad)"
326
+ out change {value: text}
327
+ out submit {value: text}
328
+
329
+ extern overlay@1 "A popover, tooltip, dialog or menu anchored to its first slot. A menu's body holds press kind=option, and its anchor shows the current one."
330
+ in mode choice(popover|tooltip|dialog|menu) = popover
331
+ in label text = ""
332
+ in emphasis choice(low|normal|high) = normal "how much its anchor stands out: low for a quiet tool in a header"
333
+ in anchor slot
334
+ in body slot
335
+ out open
336
+ out close
337
+
338
+ extern canvas@1 "A 2D coordinate space with layers drawn in the order written. Lines, rectangles and curves are paths."
339
+ fields x y
340
+ in x range = -1..1
341
+ in y range = -1..1
342
+ in z range = -1..1 "3D only"
343
+ in aspect num = 0 "width over height; 0 means from the ranges"
344
+ in size size = m "its width"
345
+ in height size = none "a fixed height, so it fills a stage of that height; none: from the aspect"
346
+ in dims int 2..3 = 2 "3 needs gfx@1"
347
+ in view point = (35, 25) "3D camera: azimuth and elevation in degrees"
348
+ in label text = ""
349
+ in layers list(record layer {opacity: num = 1, clip: list(point) = [],
350
+ circles: list(record circle {c: point, r: num, px: int = 0, fill: color = none, stroke: color = none, width: num = 1, opacity: num = 1, label: text = ""}),
351
+ paths: list(record path {pts: list(point), closed: bool = false, fill: color = none, stroke: color = ink, width: num = 1, dash: bool = false, head: choice(none|arrow|dot) = none, opacity: num = 1, label: text = ""}),
352
+ labels: list(record label {at: point, text: text, tone: color = ink, anchor: choice(center|n|s|e|w|ne|nw|se|sw) = center, chip: bool = false, size: choice(small|normal|large) = normal, halo: bool = false, dx: int = 0, dy: int = 0, opacity: num = 1}),
353
+ images: list(record image {src: text, at: point, w: num, h: num = 0, alt: text = ""}),
354
+ places: list(record place {at: point} slot),
355
+ handles: list(record handle {p: ref point, tone: color = accent}),
356
+ pixels: list(record pixels {f: expr(x, y): rgb, res: int 16..1024 = 256}),
357
+ meshes: list(record mesh {f: expr(x, y), n: int 4..200 = 40, fill: color = accent})})
358
+
359
+ extern paragraph@1 "A paragraph of inline Markdown."
360
+ fields text
361
+ in text text
362
+
363
+ extern heading@1 "A heading."
364
+ fields level text
365
+ in level int 1..6 = 2
366
+ in text text
367
+
368
+ extern list@1 "A bulleted, numbered or task list."
369
+ in ordered bool = false
370
+ in start int = 1
371
+ in items list(record item {checked: choice(none|yes|no) = none} slot)
372
+
373
+ extern quote@1 "A block quote; alert makes it a note, tip, warning … callout."
374
+ in alert choice(none|note|tip|important|warning|caution) = none
375
+ in body slot
376
+
377
+ extern code@1 "A code block."
378
+ fields src lang
379
+ in src text
380
+ in lang text = ""
381
+ in line int = 0 "the current line, from 1: the lines are numbered and this one is marked"
382
+ in marks list({line: int, tone: color, note: text, from: int, to: int}) = [] "lines with a tone (or none), only in the columns from and to (from 1) when from is above 0, and a note at the end (or empty); the lines are numbered"
383
+ in pickable bool = false "the reader can press a line, which raises pick"
384
+ out pick {line: int} "a line was pressed (from 1)"
385
+
386
+ extern math@1 "A display formula. \mark{id}{…} marks a part, coloured by its entry in marks."
387
+ fields tex
388
+ in tex latex
389
+ in marks list({id: text, tone: color, note: text}) = [] "the parts written \mark{id}{…}: their tone, and a note shown under the formula"
390
+
391
+ extern divider@1 "A thematic break (Markdown's ---)."
392
+
393
+ extern table@1 "A table of inline Markdown cells."
394
+ fields head rows
395
+ in head list(text)
396
+ in rows list(list(text))
397
+ in align list(choice(none|left|center|right)) = []
398
+
399
+ extern footnote@1 "A footnote's text."
400
+ fields label
401
+ in label text
402
+ in body slot
403
+
404
+ extern frame@1 "A widget's shell: what kind of thing it is and its title above a stage, and a bar of controls along the bottom. Nothing the reader does changes its size: what doesn't fit goes in its drawers or full screen."
405
+ fields kind title
406
+ in kind text = "" "what kind of thing it is, said small before the title"
407
+ in title text = ""
408
+ in height size = none "the stage's height at rest (the reader can drag it); none: as tall as its content"
409
+ in status text = "" "one line in the bar: what is happening now"
410
+ in statuslines int = 1 "how many lines the status keeps room for (1 to 3): a verdict with its reason"
411
+ in tone color = none "tints the bar: how an answer went (ok, bad) or a note (info)"
412
+ in body slot
413
+ in actions slot "right of the title: the widget's own switches"
414
+ in bar slot "the bar: what is placed here, after the widget's own controls"
415
+ in about slot "a drawer: assumptions, and how to read it"
416
+ in details slot "a drawer: everything at once, such as the full table"
417
+
418
+ extern pane@1 "A titled column of a stage: its title stays put while its body scrolls on its own. Panes side by side are divided by a rule."
419
+ fields title
420
+ in title text = ""
421
+ in note text = "" "right of the title: a count or a remark"
422
+ in body slot
423
+ in footer slot
424
+
425
+ extern zoom@1 "A view the reader can zoom and pan once they unlock it, so scrolling the page past it is never caught by it. It starts locked; a try to zoom or pan then points at the lock. Its lock shows only when there is something to zoom or pan: what it holds was shrunk to fit, is clipped, or is a drawing or a picture."
426
+ in max num = 4 "how far it zooms in"
427
+ in fit bool = true "at rest, what is wider than the view is shrunk to fit it (never enlarged)"
428
+ in minscale num = 0.6 "it shrinks to fit no smaller than this: past it, what is wider is shown at this size from its middle, clipped, to pan once unlocked; 0 for no limit"
429
+ in minheight size = none "never shorter than this; none: room for its lock, when it shows one"
430
+ in maxheight size = l "never taller than this: what is taller is clipped, to pan once unlocked; none: as tall as its content"
431
+ in body slot
432
+
433
+ extern icon@1 "A symbol from a fixed set, drawn in the provider's own icon style."
434
+ fields name
435
+ in name iconname "which symbol; none draws nothing"
436
+ in tone color = none "its colour; none: the text's"
437
+ in size choice(small|normal|large) = normal
438
+ in label text = "" "what it means, when it stands for words"
439
+
440
+ tokens core@1 "Default tokens: every required name (spec 7)."
441
+ color surface "#ffffff" dark="#15171a"
442
+ color ink "#1a1c1f" dark="#eceef1"
443
+ color muted "#6b7280" dark="#9aa3ae"
444
+ color line "#d4d7dc" dark="#3a3f46"
445
+ color accent "#2563eb" dark="#7aa7ff"
446
+ color info "#0284c7" dark="#38bdf8"
447
+ color ok "#15803d" dark="#4ade80"
448
+ color warn "#b45309" dark="#fbbf24"
449
+ color bad "#dc2626" dark="#f87171"
450
+ color c1 "#2563eb" dark="#7aa7ff"
451
+ color c2 "#d97706" dark="#fbbf24"
452
+ color c3 "#059669" dark="#34d399"
453
+ color c4 "#9333ea" dark="#c084fc"
454
+ color c5 "#db2777" dark="#f472b6"
455
+ color c6 "#0891b2" dark="#22d3ee"
456
+ font body "system-ui, sans-serif" size=16 weight=400 line=1.5
457
+ font heading "system-ui, sans-serif" size=22 weight=650 line=1.25
458
+ font mono "ui-monospace, monospace" size=14 weight=400 line=1.45
459
+ space xs=2 s=4 m=8 l=16 xl=32
460
+ size s=160 m=320 l=480
461
+ radius card=8 pill=999
462
+ shadow raised y=1 blur=3 color="#0000001f"
463
+ `,hc={color:["surface","ink","muted","line","accent","info","ok","warn","bad","c1","c2","c3","c4","c5","c6"],font:["body","heading","mono"],space:["xs","s","m","l","xl"],size:["s","m","l"],radius:["card"],shadow:["raised"]},ah=new Set(["pixels","mesh"]);function dc(t){if(t){if(t.v==="dur")return t.ms;if(t.v==="expr"){let e=t.e;if(e.k==="num"||e.k==="str")return e.v;if(e.k==="id")return e.name;if(e.k==="neg"&&e.a.k==="num")return-e.a.v}return t.src}}var L$=/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,j$={space:"m",size:"m",radius:"card"},lh={color:'color brand "#2563eb" dark="#7aa7ff"',font:'font body "system-ui, sans-serif" size=16',shadow:"shadow raised y=1 blur=3",space:"space xs=2 s=4",size:"size s=160 m=320",radius:"radius card=8 pill=999"};function mc(t,e,n){let r={};for(let i of t.lines){let s=i.kind,o=r[s]??={};if(i.name){let a={};i.value&&(a.value=dc(i.value));for(let l of i.args)a[l.key??"value"]=dc(l.value);if(s==="color")for(let l of["value","dark"]){let c=a[l];if(c!==void 0&&(typeof c!="string"||!L$.test(c))){let u=l==="value"?i.value?.p:i.args.find(h=>(h.key??"value")===l)?.p,f=l==="value"?`the colour token ${i.name}`:`${l}= on the colour token ${i.name}`,p=l==="value"?`color ${i.name} "#2563eb"`:`${l}="#7aa7ff"`;n.error("mkp.token-value",`${f} must be a hex colour, # and 3, 4, 6 or 8 hex digits; found ${typeof c=="string"?c:String(c)}. Write it in quotes, e.g. \`${p}\``,u??i.p)}}o[i.name]=a}else for(let a of i.args){if(!a.key){if(s==="color"||s==="font"||s==="shadow")n.error("mkp.token-syntax",`a ${s} token line starts with the token's name, as in \`${lh[s]}\`; found ${a.value.src} with no name before it. Put a name first: \`${s} brand ${a.value.src}\``,a.p);else{let l=a.value.src.replace(/^"|"$/g,"").replace(/[^A-Za-z0-9_]/g,"")||"name";n.error("mkp.token-syntax",`a line of ${s} tokens is a list of name=value pairs, as in \`${lh[s]??`${s} a=1 b=2`}\`; found ${a.value.src}, which has no name. Remove ${a.value.src}, or write it as a pair: \`${/^[A-Za-z_]/.test(l)?`${l}=4`:`${j$[s]??"name"}=${a.value.src}`}\``,a.p)}continue}o[a.key]={value:dc(a.value)}}}return{name:t.name,version:t.version,pack:e,about:t.about,tokens:r}}function Eo(t){let e=new Map;for(let n of t)for(let[r,i]of Object.entries(n.tokens)){let s=e.get(r)??new Set;for(let o of Object.keys(i))s.add(o);e.set(r,s)}return e}function P$(t,e){return t==="color"?`color ${e} "#2563eb"`:t==="font"?`font ${e} "system-ui, sans-serif" size=16`:t==="shadow"?`shadow ${e} y=1 blur=3`:`${t} ${e}=8`}function ch(t,e){let n=Eo(t);for(let[r,i]of Object.entries(hc))for(let s of i)n.get(r)?.has(s)||e.error("mkp.token-missing",`no token set defines the ${r} token "${s}", which every set of tokens must have. Add a line for it to a tokens file, e.g. \`${P$(r,s)}\``)}var uh={play:"\u25B6",pause:"\u23F8",prev:"\u2039",next:"\u203A",more:"\u2228",less:"\u2227",first:"\u23EE",last:"\u23ED",reset:"\u21BA",check:"\u2713",cross:"\u2715",plus:"+",minus:"\u2212",up:"\u2191",down:"\u2193",left:"\u2190",right:"\u2192",ban:"\u2298",alert:"\u26A0",info:"\u24D8",help:"?",lock:"\u26BF",unlock:"\u26BF",eye:"\u25C9",edit:"\u270E",search:"\u2315",user:"\u263A",users:"\u263A",file:"\u25A4",folder:"\u25AD",database:"\u26C1",server:"\u25A6",cloud:"\u2601",mail:"\u2709",clock:"\u25F7",calendar:"\u25A6",flag:"\u2691",target:"\u25CE",gauge:"\u25D4",layers:"\u224B",branch:"\u2442",box:"\u25A3",square:"\u25A1",circle:"\u25CB",dot:"\u2022",star:"\u2605",bolt:"\u03DF",link:"\u26D3",key:"\u26B7",shield:"\u26C9",cart:"\u26DF",chart:"\u25A5",code:"\u2318",terminal:"\u203A_",bell:"\u266A",home:"\u2302",settings:"\u2699",sliders:"\u2630",trash:"\u232B",copy:"\u29C9",download:"\u2913",upload:"\u2912",expand:"\u2922",lightbulb:"\u263C",book:"\u25AF"},_$=Object.keys(uh);var Et="0.2.10";var gc=new Set(["requires","budget","deprecated","fields","in","out","signal","host","command","var","fn","project","implements"]);var yc=new Set(["set","play","pause","reset","reveal","hide","open","close","emit","send"]),ph=new Set(["+","-","*","/","^","==","<","from","point"]),pr=/^([A-Za-z_][A-Za-z0-9_.-]*:)?[A-Za-z_][A-Za-z0-9_.-]*$/,Bt=/^[A-Za-z_][A-Za-z0-9_]*$/,wc=["requires","depends","provides","front","attr","roles","rule","unpublished"];function F(t,e=40){let n=t.trim().replace(/\s+/g," ");return`\`${n.length>e?`${n.slice(0,e-1)}\u2026`:n}\``}function gh(t,e){let n=e?"a name starts with a letter or `_` and uses only letters, digits, `.`, `-` and `_`":"a name starts with a letter or `_` and uses only letters, digits and `_`";if(!t)return`${n}; found no name`;if(!/^[A-Za-z_]/.test(t))return`${n}; found ${t[0]==='"'?"a quoted text":`\`${t[0]}\` at its start`}`;let r=e?/[A-Za-z0-9_.-]/:/[A-Za-z0-9_]/,i=[...t].find(s=>!r.test(s));return i?`${n}; found ${i===" "?"a space":`\`${i}\``} in it`:null}function Ao(t,e){let n=/^[0-9]+/.exec(t)?.[0]??"",r=t.slice(n.length)+n;return r=r.replace(e?/[^A-Za-z0-9_.-]+/g:/[^A-Za-z0-9_]+/g,e?"-":"_").replace(/^[-_.]+|[-_.]+$/g,""),r&&/^[A-Za-z_]/.test(r)&&r!==t?r:null}function Nt(t,e,n,r){let i=Ao(e,n),s=gh(e,n)??(n?"a name uses only letters, digits, `.`, `-` and `_`":"a name uses only letters, digits and `_`");return`${F(e)} is not a valid ${t} name: ${s}. Rename it${i?`, e.g. \`${r?r(i):i}\``:""}`}function yh(t){let e=t.trim();return/^(int|num)\b/.test(e)?"0":/^(text|latex)\b/.test(e)?'""':e==="bool"?"false":/^list\b/.test(e)?"[]":/^point\b/.test(e)?"(0, 0)":"\u2026"}function kh(t,e){let n=null,r=3;for(let i of e){let s=U$(t,i);s<r&&(n=i,r=s)}return n}function U$(t,e){let n=Array.from({length:e.length+1},(r,i)=>i);for(let r=1;r<=t.length;r++){let i=n[0];n[0]=r;for(let s=1;s<=e.length;s++){let o=n[s];n[s]=Math.min(n[s]+1,n[s-1]+1,i+(t[r-1]===e[s-1]?0:1)),i=o}}return n[e.length]}var pt=class{constructor(e,n){this.line=e;this.map=new kn(n,e.segs)}map;get text(){return this.line.text}pos(e=0){return this.map.at(e)}fail(e,n=0,r="mkp.syntax"){throw new K(r,e,this.pos(n))}};function _n(t,e,n,r={}){let i=zp(t,e,n),s=[],o=null;for(let a of i){let l=new pt(a,e);try{let c=$c(a.text);if(o&&wc.includes(c)){bh(l,o);continue}let u=H$(l,n,r);u&&(s.push(u),o=u.item==="manifest"?u:null)}catch(c){on(c,n)}}return{file:e,items:s}}function on(t,e){if(t instanceof K)e.add(t.diagnostic);else throw t}function $c(t){let e=/^[^\s]+/.exec(t);return e?e[0]:""}function To(t,e,n){let r=/^([^@\s]+)@(\d+)$/.exec(e.text),i=n?`the ${n} name`:"the widget name",s=n?`${n} `:"";if(!r){e.text.startsWith('"')&&t.fail(`${i} is missing: found the description ${F(e.text)} where the name goes. Add a name with its version before it, e.g. \`${s}distance@1 ${vc(e.text)}\``,e.at);let o=e.text.split("@")[0],a=(gh(o,!0)?Ao(o,!0):o)??"name";t.fail(`${i} needs its version, written name@N (a pack's definitions are versioned); found ${F(e.text)}. Write \`${s}${a}@1\``,e.at)}return pr.test(r[1])||t.fail(Nt(n||"widget",r[1],!0,o=>`${s}${o}@${r[2]}`),e.at),{name:r[1],version:Number(r[2])}}function vc(t){return t.length>24?`${t.slice(0,20)}\u2026"`:t}function Pn(t,e){if(e){if(!e.text.startsWith('"')){let n=t.text.slice(e.at).trim(),r=n.includes('"')?`"${e.text}"`:`"${n}"`;t.fail(`a description must be quoted text; found ${F(e.text)} where it goes. Put it in double quotes, e.g. \`${r}\`, or remove it`,e.at)}return jn(e.text)}}function hh(t,e,n,r){let i=n>0?e[0].text:"",s=e[n]??t.fail(r?`\`${i}\` needs a name after it (letters, digits, \`.\`, \`-\` and \`_\`), then its description in quotes; found nothing. Write e.g. \`${i} gauge "A dial."\``:`\`${i}\` needs a name with its version after it (name@N), then its description in quotes; found nothing. Write e.g. \`${i} distance@1 "A distance."\``,t.text.length),o,a=!1;/@/.test(s.text)||!r?o=To(t,s,i):(s.text.startsWith('"')&&t.fail(`\`${i}\` needs a name before its description; found the description ${F(s.text)} where the name goes. Add a name, e.g. \`${i} gauge ${vc(s.text)}\``,s.at),s.text.includes(":")&&t.fail(`a document's own definition takes a plain name, without a \`prefix:\`; found ${F(s.text)}. Write it without the prefix, e.g. \`${s.text.slice(s.text.lastIndexOf(":")+1)}\``,s.at),pr.test(s.text)||t.fail(Nt(i||"widget",s.text,!0,p=>i?`${i} ${p}`:p),s.at),o={name:s.text,version:1},a=!0);let l=i?`${i} ${s.text}`:s.text,c=n+1,u;if(e[c]?.text==="of"){for(u=[],c++;e[c]&&!e[c].text.startsWith('"');){for(let p of e[c].text.split(",").map(h=>h.trim()).filter(Boolean)){if(!/^[A-Z][A-Za-z0-9]*$/.test(p)){let h=p.replace(/[^A-Za-z0-9]/g,"").replace(/^[0-9]+/,""),d=h?h[0].toUpperCase()+h.slice(1):"T";t.fail(`type parameters after \`of\` are single words starting with a capital letter (each stands for a type, told from what the widget is given); found ${F(p)}. Write e.g. \`${l} of ${d} "\u2026"\``,e[c].at+Math.max(0,e[c].text.indexOf(p)))}u.push(p)}c++}u.length||t.fail(`\`of\` after ${F(l)} must be followed by type parameter names (capitalised words, each standing for a type, like \`T\`); found ${e[c]?"the description":"nothing"} instead. Write e.g. \`${l} of T "\u2026"\`, or remove \`of\``,e[n+1].at)}let f=Pn(t,e[c]);if(e[c+1]){let p=e[c+1];t.fail(p.text.startsWith('"')?`${F(l)} takes one description; found a second text, ${F(p.text)}, after it. Join the two into one quoted text, or remove ${F(p.text)}`:`${F(l)} takes nothing after its description; found ${F(p.text)}. Remove it, or move it to a line of its own below, indented two spaces`,p.at)}return{...o,...u?{params:u}:{},about:f,...a?{inline:!0}:{}}}function W$(t,e,n){let r=Xe(t.text),s={item:"interface",...To(t,r[1]??t.fail('`interface` needs a name with its version after it (name@N), then its description in quotes; found nothing. Write e.g. `interface scored@1 "Something with a score."`',t.text.length),"interface"),about:Pn(t,r[2]),inputs:[],hosts:[],signals:[],outs:[],project:!1,p:t.pos(0),comments:n};for(let o of t.line.children){let a=new pt(o,t.map.file);try{let l=wh(a,e);l.m==="in"?s.inputs.push({name:l.name,type:l.type,p:l.p}):l.m==="signal"?s.signals.push({name:l.name,payload:l.payload,p:l.p}):l.m==="out"?s.outs.push({name:l.name,payload:l.payload,p:l.p}):l.m==="host"?s.hosts.push({name:l.name,type:l.type,p:l.p}):l.m==="project"?s.project=!0:a.fail(`an interface may list only \`in\`, \`host\` (data the host sets), \`signal\` and \`out\` lines, and \`project md\`; found ${kc(l,o.text)}. Remove that line: a widget that implements the interface may still have it`,0,"mkp.syntax")}catch(l){if(/^project\s+md\s*$/.test(o.text))s.project=!0;else if(/^host\s+[A-Za-z_][A-Za-z0-9_]*\s+\S/.test(o.text)&&!o.text.includes("=")){let c=Xe(o.text)[1].text;s.hosts.push({name:c,type:No(a,o.text.indexOf(c)+c.length).type,p:a.pos(0)})}else on(l,e)}}return s}function kc(t,e){return t.m==="node"?`the element ${F(t.node.head)}`:t.m==="derived"||t.m==="state"?`the line ${F(e)}`:`a \`${t.m}\` line (${F(e)})`}function H$(t,e,n={}){let r=t.text,i=Xe(r),s=i[0].text,o=t.line.comments,a=t.pos(0),l=!!n.inline;switch(s){case"extern":case"part":{s==="extern"&&l&&t.fail(`a document can't declare ${F(r.split('"')[0],30)}: an extern is a widget drawn by the app's own code, so only a pack declares one; found \`extern\` here. Remove \`extern\` to write the widget in MKP (\`${i[1]?.text??"gauge"} "\u2026"\` with its lines below), or move it to a pack`,0,"mkp.syntax");let c=hh(t,i,1,l);return{item:"def",kind:s==="extern"?"extern":"part",...c,members:mh(t,e),p:a,comments:o}}case"migrate":return l&&t.fail("a document can't declare `migrate`: it says how uses of one version of a pack's widget move to another, so only the pack declares it; found `migrate` here. Move it into a .mkp file of the pack",0,"mkp.syntax"),K$(t,e,o);case"interface":return l&&t.fail(`a document can't declare ${F(r.split('"')[0],30)}: an interface says what a host app relies on, so it is declared in the host's pack; found \`interface\` here. Move it into a .mkp file of that pack, or remove it and give the widget its \`in\` lines directly`,0,"mkp.syntax"),W$(t,e,o);case"tokens":return{item:"tokens",...To(t,i[1]??t.fail('`tokens` needs a name with its version after it (name@N); found nothing. Write e.g. `tokens brand@1 "Our colours."`',t.text.length),"tokens"),about:Pn(t,i[2]),lines:Q$(t,e),p:a,comments:o};case"pack":case"profile":{let c=To(t,i[1]??t.fail(`\`${s}\` needs a name with its version after it (name@N), then its description in quotes; found nothing. Write e.g. \`${s} units@1 "Distances in kilometres."\``,t.text.length),s),u={item:"manifest",kind:s,...c,about:Pn(t,i[2]),requires:[],depends:[],provides:[],front:[],attrs:[],roles:[],rules:[],p:a,comments:o};for(let f of t.line.children)try{bh(new pt(f,t.map.file),u)}catch(p){on(p,e)}return u}case"type":{let c=r.indexOf("=");if(c<0){let p=r.slice(4).trim()||"Name";t.fail(`${F(`type ${p}`)} needs \`=\` and the type it names; found no \`=\`. Write e.g. \`type ${p} = {value: num}\` (a record of fields and their types)`,r.length)}let u=r.slice(4,c).trim();Bt.test(u)||t.fail(Nt("type",u,!1,p=>`type ${p} = \u2026`),Math.max(5,r.indexOf(u,4)));let{type:f}=ur(r,c+1,r.length,t.map);return{item:"type",name:u,type:f,p:a,comments:o}}case"fn":return{item:"fn",...bc(t,3,o)};case"op":{let c=/^op\s+(\S+?)\(/.exec(r);if(!c||!ph.has(c[1])){let u=c?c[1]:r.slice(2).trim().split(/[\s(]/)[0]??"";!c&&ph.has(u)&&t.fail(`${F(`op ${u}`)} needs its parameters in brackets right after the symbol; found ${F(r.split("=")[0],30)}. Write e.g. \`op ${u}(a: vec2, b: vec2): vec2 = \u2026\``,3),t.fail(`${u?F(u):"nothing"} is not an operator you can define; found ${F(r.split("=")[0],30)}. Define one of \`+ - * / ^ == <\`, \`from\` (turns another type into this one: \`op from(n: num): vec2 = \u2026\`) or \`point\` (makes a point of it: \`op point(v: vec2): point = \u2026\`)`,3)}return{item:"op",symbol:c[1],...bc(t,3+c[1].length,o,c[1])}}case"const":{let c=Co(r,6);if(c<0){let g=r.slice(6).trim()||"limit";t.fail(`${F(`const ${g}`)} needs \`=\` and its value; found no \`=\`. Write e.g. \`const ${g} = 10\` (a type may come before \`=\`: \`const ${g}: int = 10\`)`,r.length)}let u=r.slice(6,c).trim(),f=u.indexOf(":"),p=(f>=0?u.slice(0,f):u).trim();Bt.test(p)||t.fail(Nt("constant",p,!1,g=>`const ${g} = \u2026`),Math.max(6,r.indexOf(p,5)));let h=f>=0?ur(r,6+f+1,c,t.map).type:void 0,{e:d,src:m}=Do(t,c+1,r.length);return{item:"const",name:p,type:h,e:d,src:m,p:a,comments:o}}case"macro":{let c=/^macro\s+([A-Za-z]+)\s*=\s*(\$.*)$/.exec(r);c||t.fail(G$(r),0);let u=c[2],f=bn(u,0),p=u.startsWith("$$")?2:1;return{item:"macro",name:c[1],tex:u.slice(p,f-p),p:a,comments:o}}default:{if(/^[^@\s]+@\d+$/.test(s)||l&&pr.test(s)&&(i[1]?.text.startsWith('"')||i[1]?.text==="of"))return{item:"def",kind:"widget",...hh(t,i,0,l),members:mh(t,e),p:a,comments:o};t.fail(Y$(s,i,l),0,"mkp.unknown-statement")}}}function G$(t){let e=/^macro\s*([^\s=]*)\s*(=?)\s*(.*)$/.exec(t),[,n,r,i]=e,s="(a macro names a piece of maths, written `\\R` inside $\u2026$)";return n?/^[A-Za-z]+$/.test(n)?r?`the value of ${F(`macro ${n}`)} must be maths in dollars; found ${i?F(i):"nothing"}. Write it as \`macro ${n} = $${i&&!i.startsWith("$")?i.replace(/^"|"$/g,""):"\u2026"}$\``:`${F(`macro ${n}`)} needs \`=\` and the maths it stands for ${s}; found no \`=\`. Write e.g. \`macro ${n} = $\\mathbb{${n}}$\``:`a macro's name is letters only ${s}; found ${F(n)}. Rename it, e.g. \`macro ${n.replace(/[^A-Za-z]/g,"")||"R"} = $\u2026$\``:`\`macro\` needs a name, \`=\` and its maths ${s}; found nothing after \`macro\`. Write e.g. \`macro R = $\\mathbb{R}$\``}function K$(t,e,n){let r=/^migrate\s+(\S+@\d+)\s*->\s*(\S+@\d+)\s*$/.exec(t.text),i="([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)?)";r||t.fail(`\`migrate\` names two versions of a widget: the one uses move from, then -> and the one they move to; found ${F(t.text,40)}. Write e.g. \`migrate walk@1 -> walk@2\``,7);let s={item:"migrate",from:r[1],to:r[2],lines:[],p:t.pos(0),comments:n};for(let o of t.line.children){let a=new pt(o,t.map.file);try{let l=a.text,c=a.pos(0),u;if(u=new RegExp(`^rename\\s+${i}\\s*->\\s*${i}\\s*$`).exec(l))s.lines.push({k:"rename",from:u[1],to:u[2],p:c});else if(u=new RegExp(`^drop\\s+${i}\\s+("(?:[^"\\\\]|\\\\.)*")\\s*$`).exec(l))s.lines.push({k:"drop",name:u[1],why:jn(u[2]),p:c});else if(u=new RegExp(`^map\\s+${i}\\s*:\\s*(.+)$`).exec(l)){let f=u[2].split(",").map(p=>/^\s*([^\s,]+)\s*->\s*([^\s,]+)\s*$/.exec(p));f.some(p=>!p)&&a.fail(`\`map\` pairs each old value with its new one, separated by commas; found ${F(u[2],40)}. Write e.g. \`map ${u[1]}: done -> ok, late -> bad\``,l.indexOf(":")+1),s.lines.push({k:"map",name:u[1],values:f.map(p=>[p[1].replace(/^"|"$/g,""),p[2].replace(/^"|"$/g,"")]),p:c})}else if(u=/^keep\s+([A-Za-z_]\w*)\s*=\s*(.+?)\s+("(?:[^"\\]|\\.)*")\s*$/.exec(l)){let f=l.indexOf(u[2],l.indexOf("=")+1);s.lines.push({k:"keep",name:u[1],value:St(u[2],t.map.file,c.line,c.col+f),why:jn(u[3]),p:c})}else a.fail(`under \`migrate\`, a line renames an input (or a field of a record list's items: items.name), drops one, maps its values, or keeps the old look by setting one; found ${F(l,40)}. Write \`rename from -> start\`, \`rename items.name -> rows.title\`, \`drop speed "why it went"\`, \`map items.state: done -> ok\` or \`keep look = "classic" "what it keeps"\``,0)}catch(l){on(l,e)}}return s}function Y$(t,e,n){let r=`found ${F(t)}`;return wc.includes(t)&&t!=="requires"?`\`${t}\` is a line of a pack's manifest; ${r} outside it. Move it into manifest.mkp, indented two spaces under the \`pack name@N\` line`:gc.has(t)&&t!=="fn"?`\`${t}\` lines belong inside a definition; ${r} at the top level. Indent it two spaces under the widget's own line (e.g. \`tally "A running count."\`)`:t.startsWith("@")?`the event ${F(t)} must sit under the element it handles; ${r} at the top level. Indent it under that element, inside a widget`:/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)&&e[1]?.text==="="?`${F(`${t} = \u2026`)} belongs inside a definition; ${r} at the top level. Indent it two spaces under the widget's own line, or write \`const ${t} = \u2026\` for a constant`:!n&&pr.test(t)&&e[1]?.text.startsWith('"')?`a widget in a pack needs its version after its name; ${r} with none. Write \`${t}@1 ${vc(e[1].text)}\``:n&&pr.test(t)&&e[1]&&!gc.has(t)&&(e.length>2||/^[A-Z]/.test(e[1].text))?`the description after ${F(t)} must be in double quotes; found ${F(e[1].text)}. Write \`${t} "${$n(e.slice(1).map(o=>o.text).join(" ").replace(/"/g,""))}"\``:n&&pr.test(t)&&!e[1]?`a widget's line needs its description in quotes after the name; ${r} alone. Write e.g. \`${t} "What it shows."\``:`a top-level line starts a definition; ${r}. Start it with ${n?'a widget name and its description (`tally "A running count."`)':'a widget name@N and its description (`tally@1 "A running count."`)'} or one of ${n?"`part`, `tokens`, `type`, `fn`, `op`, `const` or `macro`":"`part`, `extern`, `interface`, `tokens`, `type`, `fn`, `op`, `const`, `macro` or `pack`"}, or remove the line`}function bh(t,e){let n=t.text,r=Xe(n),i=t.pos(0);switch(r[0].text){case"requires":e.requires.push(...r.slice(1).map(s=>s.text));return;case"depends":e.depends.push(...r.slice(1).map(s=>s.text));return;case"provides":e.provides.push(...r.slice(1).map(s=>s.text));return;case"roles":e.roles.push(...r.slice(1).map(s=>s.text));return;case"unpublished":r.length>1&&t.fail(`\`unpublished\` is a bare flag (the pack may still change without a new version) and takes nothing after it; found ${F(n.slice(r[1].at))}. Write just \`unpublished\`, or remove the line once the pack is published`,r[1].at),e.unpublished=!0;return;case"front":{let s=r[1]?.text;s||t.fail('`front` declares a front-matter field, as `front name type [= default] ["about"]`; found nothing after it. Write e.g. `front title text "the lesson\'s title"`',n.length),Bt.test(s)||t.fail(Nt("front-matter field",s,!1,a=>`front ${a} text`),r[1].at);let o=No(t,r[1].at+s.length);e.front.push({name:s,type:o.type,def:o.def,about:o.about,p:i});return}case"attr":{let s=r[1]?.text;s||t.fail('`attr` declares a block attribute that a document may write on any block (`{name=value}`), as `attr name type ["about"]`; found nothing after it. Write e.g. `attr cite text "the slide this block cites"`',n.length),Bt.test(s)||t.fail(Nt("block attribute",s,!1,a=>`attr ${a} text`),r[1].at),["role","id"].includes(s)&&t.fail(`\`${s}\` can't be declared as a block attribute: \`id\` and \`role\` are built in (\`{#name}\` names a block, \`{role=\u2026}\` gives a section its role); found \`attr ${s}\`. Pick another name, e.g. \`attr audience text\``,r[1].at);let o=No(t,r[1].at+s.length);if(o.def){let a=Co(n,r[1].at+s.length),l=`${n.slice(0,a).trim()}${o.about!==void 0?` "${o.about}"`:""}`;t.fail(`the block attribute \`${s}\` can't have a default: a block that doesn't write \`{${s}=\u2026}\` simply has no value for it; found ${F(n.slice(a).split('"')[0])}. Remove it: \`${l}\``,a)}e.attrs.push({name:s,type:o.type,about:o.about,p:i});return}case"rule":{let s=r[1]?.text,o=r[2]?.text;(!s||!o)&&t.fail(`\`rule\` needs a rule name and a path (\`rule name path [args] ["message"]\`); found ${s?`only ${F(s)}`:"nothing after it"}. Rules: required, one-of, pattern, max-length, count, depth, first; paths: front.<field>, blocks.<widget>, roles.<role>. E.g. \`rule required front.title\``,r[1]?.at??n.length);let a=r.slice(3),l;a.length&&a[a.length-1].text.startsWith('"')&&(l=jn(a.pop().text)),e.rules.push({rule:s,path:o,args:a.map(c=>hr(t,c)),message:l,p:i});return}default:t.fail(Z$(r[0].text),0)}}var J$={export:"provides",exports:"provides",expose:"provides",public:"provides",publish:"provides",import:"depends",imports:"depends",include:"depends",uses:"depends",use:"depends",needs:"requires"};function Z$(t){let e="requires, depends (another pack), provides (names documents may use), front, attr, roles, rule or unpublished";if(["part","extern","interface","tokens","type","fn","op","const","macro"].includes(t)||/@\d+$/.test(t))return`a manifest holds only the pack's own lines; found the definition ${F(t)} in it. Move the definition into another .mkp file of the pack, and list its name with \`provides\``;let n=J$[t]??kh(t,wc),r=n?` Did you mean \`${n}\`?${n==="provides"?" e.g. `provides distance` makes `distance` usable from documents":""}`:"";return`${F(t)} is not a manifest line; a line under \`pack name@N\` is ${e}.${r||" Rewrite the line as one of these, or remove it"}`}function Q$(t,e){let n=[];for(let r of t.line.children){let i=new pt(r,t.map.file);try{let s=Xe(r.text),o=s[0].text,a=s.slice(1),l=i.pos(0);if(a.length&&Bt.test(a[0].text)){let c=a[0].text,u=a.slice(1),f=u.length&&!/^[A-Za-z_][A-Za-z0-9_]*=/.test(u[0].text)?Hr(i,u.shift()):void 0;n.push({kind:o,name:c,value:f,args:u.map(p=>hr(i,p)),p:l})}else n.push({kind:o,args:a.map(c=>hr(i,c)),p:l})}catch(s){on(s,e)}}return n}function Co(t,e){let n=0;for(let r=e;r<t.length;r++){let i=t[r];if(i==='"'){let s=r+1;for(;s<t.length&&t[s]!=='"';)s+=t[s]==="\\"?2:1;r=s;continue}if(i==="$"){r=bn(t,r)-1;continue}if(i==="("||i==="["||i==="{")n++;else if(i===")"||i==="]"||i==="}")n--;else if(i==="="&&n===0&&t[r+1]!=="="&&t[r+1]!==">"&&!"=!<>".includes(t[r-1]??""))return r}return-1}function Do(t,e,n){for(;e<n&&t.text[e]===" ";)e++;if(e>=n){let i=t.text.slice(0,e).trim(),s=/^project\b/.test(i)?'"\u2026"':"0";t.fail(`${F(i)} has nothing after it, where a value is needed; found the end of the line. Write the expression after it, e.g. \`${i} ${s}\``,Math.max(0,t.text.slice(0,e).trimEnd().length-1))}return{e:tn.parse(t.text,e,n,t.map),src:t.text.slice(e,n).trim()}}function bc(t,e,n,r){let i=t.text,s=i.indexOf("(",e);if(s<0){let k=i.slice(e).split(/[\s=:]/)[0]||"name";t.fail(`${F(`fn ${k}`)} needs its parameters in brackets after the name; found no \`(\`. Write e.g. \`fn ${k}(x: num): num = \u2026\` (or \`fn ${k}(): num = \u2026\` with none)`,e)}let o=r??i.slice(e,s).trim();!r&&!Bt.test(o)&&t.fail(Nt("function",o,!1,k=>`fn ${k}(\u2026)`),e);let a=r?`op ${r}`:`fn ${o}`,l=0,c=-1;for(let k=s;k<i.length;k++)if(i[k]==="(")l++;else if(i[k]===")"&&(l--,l===0)){c=k;break}c<0&&t.fail(`the parameter list of ${F(a)} opened with \`(\` is never closed; found no \`)\`. Add \`)\` after the last parameter, e.g. \`${a}(w: num, h: num): num = \u2026\``,s);let u=[],f=i.slice(s+1,c),p=0;l=0;let h=[];for(let k=0;k<=f.length;k++){let w=f[k];w==="("||w==="{"||w==="["?l++:(w===")"||w==="}"||w==="]")&&l--,(w===","&&l===0||k===f.length)&&(f.slice(p,k).trim()&&h.push([p,k]),p=k+1)}for(let[k,w]of h){let v=f.slice(k,w),D=v.indexOf(":"),I=(D>=0?v.slice(0,D):v).trim(),L=s+1+k+(v.length-v.trimStart().length);if(D<0&&/^[A-Za-z_][A-Za-z0-9_]*\s+\S/.test(I)){let[G,...R]=I.split(/\s+/);t.fail(`the parameter ${F(I)} of ${F(a)} needs \`:\` between its name and its type; found a space. Write \`${G}: ${R.join(" ")}\``,L)}Bt.test(I)||t.fail(Nt("parameter",I,!1),L);let T=D>=0?ur(i,s+1+k+D+1,s+1+w,t.map).type:void 0;u.push({name:I,type:T})}let d=Co(i,c+1),m=i.slice(0,c+1).trim();if(d<0){let k=i.slice(c+1).trim();t.fail(`${F(m)} needs \`=\` and the expression it gives; found ${k?F(k):"nothing"} after the parameters. Write the result type and body, e.g. \`${dh(m)}${k.startsWith(":")?` ${k}`:": num"} = \u2026\``,c+1)}let g=i.slice(c+1,d).trim(),y;g&&(g.startsWith(":")||t.fail(`the result type of ${F(a)} comes after \`:\`, between the parameters and \`=\`; found ${F(g)} with no \`:\`. Write \`${dh(m)}: ${g} = \u2026\``,i.indexOf(g,c+1)),y=ur(i,i.indexOf(":",c+1)+1,d,t.map).type);let{e:$,src:b}=Do(t,d+1,i.length);return{name:o,params:u,ret:y,body:$,src:b,p:t.pos(0),comments:n}}function dh(t){return t.length>40?`${t.slice(0,t.indexOf("(")+1)}\u2026)`:t}function No(t,e){let n=t.text,r=Co(n,e),i=r>=0?r:n.length,s;if(r<0){let p=Xe(n,e),h=p[p.length-1];p.length>1&&h.text.startsWith('"')&&(s=jn(h.text),i=h.at)}let{type:o,end:a}=ur(n,e,i,t.map),l,c=n.slice(a,i).trim(),u=n.slice(0,a).trim();if(c==="answer")l=!0;else if(c){let p=/^in\s/.test(u);t.fail(`after the type in ${F(u)} only ${p?"`answer` (marks the input holding the answer), ":""}\`= default\` or a "description" may follow; found ${F(c)}. Remove it, or quote it and put it last if it is the description: \`${u}${r>=0?` ${n.slice(r).trim()}`:""} "${c}"\``,n.indexOf(c,a))}let f;if(r>=0){let p=Xe(n,r+1),h=n.slice(e,r).replace(/\banswer\b/,"").trim();if(p.length||t.fail(`${F(n.slice(0,r+1))} has nothing after \`=\`; found the end of the line. Write the default value after it, e.g. \`${n.slice(0,r).trim()} = ${yh(h)}\`, or remove \`=\``,r),f=Hr(t,p[0]),p[1]?.text==="answer"&&(l=!0,p.splice(1,1)),p[1]&&(s=Pn(t,p[1])),p.length>2){let d=p[2];t.fail(d.text==="answer"?`\`answer\` must come before the description; found it after ${F(p[1].text)}. Write \`${n.slice(0,p[1].at).trim()} answer ${p[1].text}\``:d.text.startsWith('"')?`${F(n.slice(0,r).trim())} takes one description; found a second text, ${F(d.text)}, after ${F(p[1].text)}. Remove ${F(d.text)}, or join the two into one quoted text`:`nothing may follow the description of ${F(n.slice(0,r).trim())}; found ${F(d.text)}. Remove it`,d.at)}}return{type:o,def:f,about:s,...l?{answer:l}:{}}}function X$(t,e){let n=t.text,r=e;for(;n[r]===" ";)r++;let i;if(n[r]==="{"){let o=ur(n,r,n.length,t.map);i=o.type,r=o.end;let l=Xe(n,e).slice(1);return{payload:i,about:Pn(t,l[0])}}let s=Xe(n,e);return{payload:i,about:Pn(t,s[0])}}function mh(t,e){let n=[];for(let r of t.line.children){let i=new pt(r,t.map.file);try{let s=wh(i,e);n.push(s);let o=r.children[0];o&&s.m!=="node"&&s.m!=="state"&&s.m!=="command"&&new pt(o,t.map.file).fail(e0(s,r.text,o.text),0,"mkp.continuation")}catch(s){on(s,e)}}return n}function e0(t,e,n){let r=`found ${F(n)} below it`;if(t.m==="derived"||t.m==="project"){let i=e.indexOf("="),s=`${e.slice(0,i+1)} (${e.slice(i+1).trim()}`;return`${kc(t,e)} can't have lines indented under it; ${r}. Join the two lines, or bracket the expression so it may break inside: \`${$n(s)}\` then \`${$n(n)})\` on the next line`}return`${kc(t,e)} can't have lines indented under it; ${r}. Join it to the line above, or, if it is a line of its own, indent it to line up with ${F(e,20)}`}function $n(t){return t.length>36?`${t.slice(0,20)}\u2026${t.slice(-12)}`:t}function wh(t,e){let n=t.text,r=$c(n),i=t.pos(0),s=t.line.comments,o=Xe(n);if(gc.has(r))switch(r){case"requires":return{m:"requires",cap:o[1]?.text??t.fail("`requires` must name a capability (a feature the widget needs from the app) with its version; found nothing after it. Write e.g. `requires gfx@1`, or remove the line",n.length),p:i,comments:s};case"budget":{let l=Number(o[1]?.text);return(!Number.isInteger(l)||l<=0)&&t.fail(`\`budget\` takes a positive whole number: the operations one evaluation may use (1,000,000 without it, 20,000,000 at most); found ${o[1]?F(o[1].text):"nothing after it"}. Write e.g. \`budget 2000000\`, with no commas`,o[1]?.at??n.length),{m:"budget",n:l,p:i,comments:s}}case"implements":{let l=o.slice(1).map(c=>c.text);l.length||t.fail("`implements` must name an interface (what a host app relies on in this widget) with its version; found nothing after it. Write e.g. `implements scored@1`",n.length);for(let c of o.slice(1))/^[A-Za-z_][A-Za-z0-9_.:-]*@\d+$/.test(c.text)||t.fail(`\`implements\` names each interface with its version, as name@N; found ${F(c.text)}. Write \`implements ${c.text.includes("@")?c.text.split("@")[0]:c.text}@1\``,c.at);return{m:"implements",names:l,p:i,comments:s}}case"deprecated":{let l=Pn(t,o[1]);return(l===void 0||!l.trim())&&t.fail('`deprecated` needs quoted text saying what to use instead; found nothing after it. Write e.g. `deprecated "use walk@2, which takes start= instead of from="`',n.length),o.length>2&&t.fail(`\`deprecated\` takes one quoted text; found ${F(o[2].text)} after it. Put it all in the one text`,o[2].at),{m:"deprecated",text:l,p:i,comments:s}}case"fields":{let l=o.slice(1).map(c=>c.text);for(let c of o.slice(1))Bt.test(c.text)||t.fail(`${Nt("input",c.text,!1,u=>`fields ${u}`)} (\`fields\` lists the inputs that bare values after the widget's name fill, in order)`,c.at);return{m:"fields",names:l,p:i,comments:s}}case"in":case"host":case"var":{let l=o[1]?.text,c=r==="in"?"input":r==="host"?"host input":"var";l||t.fail(`\`${r}\` needs a name and a type after it; found nothing. Write e.g. \`${r} n int${r==="in"?"":" = 0"}\``,n.length),Bt.test(l)||t.fail(Nt(c,l,!1,p=>`${r} ${p} \u2026`),o[1].at);let u=No(t,o[1].at+l.length);if(r==="in")return{m:"in",name:l,...u,p:i,comments:s};let f=n.slice(o[1].at+l.length).split(/[="]/)[0].replace(/\banswer\b/,"").trim();if(u.answer){let p=/\banswer\b/.exec(n.slice(o[1].at));t.fail(`\`answer\` marks the input that holds the answer, so only an \`in\` line takes it; found it on the line ${F(`${r} ${l}`)}. Remove \`answer\`, or make it an input: \`in ${l} ${f} answer\``,p?o[1].at+p.index:0)}return u.def||t.fail(`${F(`${r} ${l} ${f}`)} needs a starting value: a ${c} always has one${r==="host"?", used until the host sets it":""}; found no \`=\`. Write \`${r} ${l} ${f} = ${yh(f)}\``,n.length,"mkp.missing-default"),{m:r,name:l,type:u.type,def:u.def,about:u.about,p:i,comments:s}}case"out":case"signal":case"command":{let l=o[1]?.text,c=r==="out"?"out answered {correct: bool}":r==="signal"?"signal changed {value: num}":"command clear";l||t.fail(`\`${r}\` needs a name after it${r==="signal"?" and its payload":""}; found nothing. Write e.g. \`${c}\``,n.length),Bt.test(l)||t.fail(Nt(r==="out"?"event":r,l,!1,p=>`${r} ${p}`),o[1].at);let u=X$(t,o[1].at+l.length);if(r==="out")return{m:"out",name:l,payload:u.payload,about:u.about,p:i,comments:s};if(r==="signal")return u.payload||t.fail(`\`signal ${l}\` needs its payload, the record of fields it sends to the host; found none. Add it in braces after the name, e.g. \`signal ${l} {value: num}\``,o[1].at+l.length),{m:"signal",name:l,payload:u.payload,about:u.about,p:i,comments:s};let f=[];for(let p of t.line.children){let h=new pt(p,t.map.file);try{f.push(...xh(h,0))}catch(d){on(d,e)}}return{m:"command",name:l,payload:u.payload,about:u.about,actions:f,p:i,comments:s}}case"fn":return{m:"fn",...bc(t,3,s)};case"project":{let l=/^project\s+(md|mermaid)\s*=/.exec(n);if(!l){let f=/^project\s*([^\s=]*)\s*(=?)\s*(.*)$/.exec(n),[,p,h,d]=f;(p==="md"||p==="mermaid")&&t.fail(`\`project ${p}\` needs \`=\` before its expression; found ${d?F(d):"nothing"} after it. Write \`project ${p} = ${d||'"\u2026"'}\``,n.length-d.length),t.fail(`\`project\` makes the widget's Markdown (\`md\`) or a Mermaid diagram (\`mermaid\`); found ${p?F(`project ${p}`):"nothing after it"}. Write \`project md = ${h&&d?d:'"\u2026"'}\` or \`project mermaid = \u2026\``,p?n.indexOf(p,7):n.length)}let{e:c,src:u}=Do(t,l[0].length,n.length);return{m:"project",target:l[1],e:c,src:u,p:i,comments:s}}}let a=/^([A-Za-z_][A-Za-z0-9_]*)\s+=\s+/.exec(n);if(a){let l=a[1],c=a[0].length,u=n.slice(c);if(/^(slider|toggle|steps|drag|clock)\b|^choice\(/.exec(u))return t0(t,l,c,e);let{e:p,src:h}=Do(t,c,n.length);return{m:"derived",name:l,e:p,src:h,p:i,comments:s}}return r.startsWith("@")&&t.fail(`the event ${F(r)} has no element to handle it: an event goes under the element or state line it reacts to; found it among the widget's own lines. Indent it two spaces under that line, e.g. under \`press label="more"\``,0,"mkp.event-placement"),{m:"node",node:$h(t,e)}}function t0(t,e,n,r){let i=t.text,s=Xe(i,n),o=s[0],a,l;if(o.text.startsWith("choice(")){a="choice";let d=/^choice\(([^)]*)\)$/.exec(o.text);if(!d){let m=o.text.slice(7).replace(/[()"' ]/g,"")||"a|b";t.fail(`\`choice(\u2026)\` lists its options as plain words separated by \`|\`; found ${F(o.text)}. Write e.g. \`${e} = choice(${m})\``,o.at)}l=d[1].split("|").map(m=>m.trim());for(let m of l)Bt.test(m)||t.fail(m?Nt("option",m,!1,g=>`choice(${l.map(y=>y===m?g:y).join("|")})`):`an option of \`choice(\u2026)\` is empty; found ${F(o.text)}. Remove the extra \`|\``,o.at+Math.max(0,o.text.indexOf(m,7)))}else a=o.text;let c=s.slice(1),u;c.length&&c[c.length-1].text.startsWith('"')&&(u=jn(c.pop().text));let f,p=[];for(let d=0;d<c.length;d++){let m=c[d];if(m.text==="="){let g=c[d+1];g||t.fail(`the starting value after \`=\` is missing in ${F(i)}; found the end of the line. Write it after \`=\`, with a space, e.g. \`${e} = ${i.slice(n).trim()} 1\``,m.at),f=Hr(t,g),d++;continue}p.push(hr(t,m))}let h=[];for(let d of t.line.children){let m=new pt(d,t.map.file);try{d.text.startsWith("@")||m.fail(`the state line ${F(i)} can have only events (\`@name action \u2026\`) indented under it; found ${F(d.text)}. Unindent it to line up with ${F(`${e} = \u2026`)}${/^(text\s+)?"/.test(d.text)?`, or, to label the control, put the text at the end of the state line: \`${$n(`${i} ${d.text.replace(/^text\s+/,"")}`)}\``:""}`,0,"mkp.event-placement"),h.push(vh(m,r))}catch(g){on(g,r)}}return{m:"state",name:e,control:a,opts:l,args:p,def:f,label:u,events:h,p:t.pos(0),comments:t.line.comments}}function $h(t,e,n){let r=Xe(t.text),i=r[0].text;if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(i)){let l=n?F(n.text):"the line above",c=n?`: \`${$n(`${n.text} ${t.text}`)}\``:"";t.fail(`${F(i)} is on a line of its own, indented under ${l}, but a line goes on to the next only inside an open bracket; found ${F(t.text)} as a line by itself. Put it at the end of the line above${c}`,0,"mkp.continuation")}if(!pr.test(i)&&i!=="else"){let l=i.startsWith('"')||i.startsWith("$")?`To show text, write \`text ${i.startsWith("$")?`"${i}"`:i}\``:`Start the line with an element's name${Ao(i,!0)?`, e.g. \`${Ao(i,!0)}\``:""}`;t.fail(`a line inside a widget starts with an element's name (like \`text\`, \`row\` or \`press\`); found ${F(i)}. ${l}`,0)}let s=r.slice(1).map(l=>hr(t,l)),o=[],a=[];for(let l of t.line.children){let c=new pt(l,t.map.file);try{l.text.startsWith("@")?a.push(vh(c,e)):o.push($h(c,e,t.line))}catch(u){on(u,e)}}return{head:i,args:s,children:o,events:a,comments:t.line.comments,p:t.pos(0)}}function vh(t,e){let n=/^@([A-Za-z_][A-Za-z0-9_]*)/.exec(t.text);if(!n){let l=$c(t.text),c=t.text.slice(l.length).trim();t.fail(`an event line is \`@\` and the event's name, then its actions; found ${l==="@"?"`@` with no name after it":F(l)}. Write e.g. \`@click ${$n(c||"set n=(n + 1)")}\` (events include @click, @change, @enter, @leave, @submit)`,0)}let r=Xe(t.text,n[0].length),i=r.filter(l=>l.text.startsWith("if=")),s=i[0],o;if(s){if(i.length>1){let l=i.map(c=>c.text.slice(3).replace(/^\((.*)\)$/,"$1"));t.fail(`an event line takes one \`if=\` condition; found a second, ${F(i[1].text)}, after ${F(s.text)}. Join them with \`and\` in one: \`if=(${l.join(" and ")})\`, or put the actions on two event lines`,i[1].at)}o=hr(t,s).value}let a=Eh(t,r.filter(l=>l!==s));for(let l of t.line.children){let c=new pt(l,t.map.file);try{a.push(...xh(c,0))}catch(u){on(u,e)}}return a.length||t.fail(`the event \`@${n[1]}\` has no actions, so it would do nothing; found nothing after it. Add an action, such as \`set name=(value)\`, \`reveal id\` or \`emit name\`, e.g. \`@${n[1]} set n=(n + 1)\`, or remove the line`,n[0].length),{name:n[1],actions:a,...o?{cond:o}:{},p:t.pos(0)}}function xh(t,e){return Eh(t,Xe(t.text,e))}function Eh(t,e){let n=[];for(let r of e){if(yc.has(r.text)){n.push({name:r.text,args:[],p:t.pos(r.at)});continue}n.length||t.fail(n0(r.text,e[e.indexOf(r)+1]?.text),r.at,"mkp.unknown-action"),n[n.length-1].args.push(hr(t,r))}return n}function n0(t,e){let n=[...yc].join(", ");if(/^([A-Za-z_][A-Za-z0-9_]*)=/.exec(t))return`${F(t)} has no action before it; found a value to set with no \`set\`. Write \`set ${$n(t)}\` (actions are ${n})`;let i=kh(t,yc),s=e&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e)?`set ${$n(e)}`:"set n=(n + 1)";return`${F(t)} is not an action; found it where an event's first action goes. Use one of ${n}${i?` (did you mean \`${i}\`?)`:""}, e.g. \`${i?`${i}${e?` ${$n(e)}`:""}`:s}\``}function hr(t,e){let n=/^([A-Za-z_][A-Za-z0-9_]*)=(?!=)/.exec(e.text);if(n){let r={text:e.text.slice(n[0].length),at:e.at+n[0].length};return r.text||t.fail(`\`${n[1]}=\` has no value after it; found ${t.text.length>e.at+e.text.length?"a space, which ends the argument":"the end of the line"}. Write the value right after \`=\`, with no space, e.g. \`${n[1]}=3\`, or \`${n[1]}=(\u2026)\` around an expression`,e.at),{key:n[1],value:Hr(t,r),p:t.pos(e.at)}}return{value:Hr(t,e),p:t.pos(e.at)}}function Hr(t,e){let n=t.pos(e.at),r=e.text,i=/^(\d+(?:\.\d+)?)(ms|s)(\/step)?$/.exec(r);if(i)return{v:"dur",ms:Number(i[1])*(i[2]==="s"?1e3:1),src:r,p:n,...i[3]?{per:!0}:{}};let s=r0(r);if(s>=0){let a=tn.parse(t.text,e.at,e.at+s,t.map),l=tn.parse(t.text,e.at+s+2,e.at+r.length,t.map);return{v:"range",lo:a,hi:l,src:r,loSrc:r.slice(0,s),hiSrc:r.slice(s+2),p:n}}return{v:"expr",e:tn.parse(t.text,e.at,e.at+r.length,t.map),src:r,p:n}}function r0(t){let e=0;for(let n=0;n<t.length-1;n++){let r=t[n];if(r==='"'||r==="$")return-1;if(r==="("||r==="["||r==="{")e++;else if(r===")"||r==="]"||r==="}")e--;else if(e===0&&r==="."&&t[n+1]===".")return n}return-1}function Gr(t,e="<expr>",n=1,r=1){let i=new kn(e,[{at:0,line:n,col:r}]);return tn.parse(t,0,t.length,i)}function St(t,e="<value>",n=1,r=1){let i={indent:0,text:t,segs:[{at:0,line:n,col:r}],comments:[],children:[],line:n},s=new pt(i,e);return Hr(s,{text:t,at:0})}var i0=new Set(["text","txt","plaintext","plain","math","latex","tex","markdown","md","mdx","sh","bash","shell","console","zsh","fish","powershell","ps1","bat","cmd","js","jsx","mjs","cjs","ts","tsx","json","jsonc","json5","yaml","yml","toml","ini","env","csv","tsv","html","xml","svg","css","scss","sass","less","vue","svelte","astro","python","py","ruby","rb","php","perl","lua","r","julia","go","rust","rs","java","kotlin","kt","scala","swift","c","h","cpp","cc","hpp","csharp","cs","fsharp","dart","elixir","erlang","haskell","hs","ocaml","clojure","lisp","scheme","zig","nim","sql","graphql","gql","proto","protobuf","dockerfile","docker","makefile","make","cmake","nginx","diff","patch","git","http","regex","mermaid","dot","graphviz","plantuml","asciidoc","rst","nix","terraform","hcl","solidity","wasm","asm","nasm"]),s0=/^(\s{0,3})(`{3,}|~{3,})\s*(.*)$/,o0=/^([A-Za-z_][A-Za-z0-9_.:-]*(?:@\d+)?)(?:\s+#([A-Za-z0-9_-]+))?\s*$/,Sh=/^(:{3,})([A-Za-z_][A-Za-z0-9_.:-]*(?:@\d+)?)(?:\s+(.*))?$/,a0=/^(:{3,})\s*$/,l0=/^\{(.*)\}\s*$/;function Io(t,e,n){let r=t.replace(/\r\n?/g,`
464
+ `).split(`
465
+ `),i=null,s=0,o=0;if(r[0]==="---"){let l=r.indexOf("---",1),c=r.indexOf("...",1),u=l<0?c:c<0?l:Math.min(l,c);u<0?n.error("mkp.front-matter","the front matter that opens with `---` on line 1 is never closed; found no line holding only `---` (or `...`) after it. Add a `---` line where the front matter ends, before the first heading or text",{file:e,line:1,col:1}):(i=r.slice(1,u).join(`
466
+ `),o=2,s=u+1)}let{items:a}=Ah(r,s,r.length,0,e,n);return{file:e,front:i,frontLine:o,items:a}}function Ah(t,e,n,r,i,s){let o=[],a=[],l=e+1,c=()=>{a.some(f=>f.trim())&&o.push({k:"md",text:a.join(`
467
+ `),line:l}),a=[]},u=e;for(;u<n;){let f=t[u],p=s0.exec(f);if(p){let m=p[2],g=p[3].trim(),y=u+1;for(;y<n&&!(t[y].trim().startsWith(m[0].repeat(m.length))&&t[y].trim().replace(new RegExp(`^${m[0]==="`"?"`":"~"}+`),"").trim()==="");)y++;let $=t.slice(u+1,y).join(`
468
+ `),b=i0.has(g.split(/\s+/)[0].toLowerCase())?null:o0.exec(g);if(g==="state"||g==="mkp"&&!p[1]){c(),o.push({k:g==="mkp"?"defs":"state",body:$,line:u+1}),u=y+1,l=u+1;continue}if(b&&!p[1]){c(),o.push({k:"block",name:b[1],id:b[2],yaml:$,line:u+1,info:g,fence:t.slice(u,Math.min(y+1,n)).join(`
469
+ `)}),u=y+1,l=u+1;continue}a.length||(l=u+1),a.push(...t.slice(u,Math.min(y+1,n))),u=y+1;continue}let h=Sh.exec(f);if(h){c();let m=h[1].length,g=0,y=u+1;for(;y<n;y++){let b=t[y],k=Sh.exec(b);k&&k[1].length===m&&g++;let w=a0.exec(b);if(w&&w[1].length===m){if(g===0)break;g--}}if(y>=n){let b=r?"the end of the container around it":"the end of the document";s.error("mkp.container",`the container \`${h[1]}${h[2]}\` opened here is never closed; found ${b} first. Add a line holding only \`${h[1]}\` (${m} colons, as many as it opens with) where the container ends`,{file:i,line:u+1,col:1})}let $=Ah(t,u+1,Math.min(y,n),m,i,s);o.push({k:"container",name:h[2],args:(h[3]??"").trim(),colons:m,items:$.items,line:u+1}),u=y+1,l=u+1;continue}let d=l0.exec(f.trim());if(d&&(a.length===0||a[a.length-1].trim()!=="")&&/^\s*(#[A-Za-z0-9_-]+|[A-Za-z_][A-Za-z0-9_]*=)/.test(d[1])){let m=c0(d[1],u+1);if(a.some(g=>g.trim()))c(),o[o.length-1].attrs=m;else if(o.length){let g=o[o.length-1];g.k!=="state"&&g.k!=="defs"&&(g.attrs=m)}else s.warn("mkp.attrs-orphan",`the attribute line \`${f.trim()}\` has no block above it to attach to (attributes apply to the block just before them); found it at the start of the ${r?"container":"document"}. Move it to the line right after its heading or block, e.g. \`# Notes\` then \`${f.trim()}\``,{file:i,line:u+1,col:1});u++,l=u+1;continue}a.length||(l=u+1),a.push(f),u++}return c(),{items:o,end:n}}function c0(t,e){let n={props:{},line:e},r=/#([A-Za-z0-9_-]+)|([A-Za-z_][A-Za-z0-9_]*)=("(?:[^"\\]|\\.)*"|\S+)/g,i;for(;i=r.exec(t);)i[1]?n.id=i[1]:n.props[i[2]]=i[3];return n}var gf=Li(As(),1);var cn=Li(As(),1);function Na(t){let e=new Map,n;try{n=cn.default.parseDocument(t,{keepSourceTokens:!0,uniqueKeys:!1})}catch{return e}let r=[0];for(let o=0;o<t.length;o++)t[o]===`
470
+ `&&r.push(o+1);let i=o=>{let a=0,l=r.length-1;for(;a<l;){let c=a+l+1>>1;r[c]<=o?a=c:l=c-1}return{line:a+1,col:o-r[a]+1}},s=(o,a)=>{if(o)if((0,cn.isMap)(o))for(let l of o.items){if(!(0,cn.isPair)(l)||!(0,cn.isScalar)(l.key))continue;let c=String(l.key.value),u=a?`${a}.${c}`:c;l.key.range&&e.set(u,i(l.key.range[0])),s(l.value,u)}else(0,cn.isSeq)(o)&&o.items.forEach((l,c)=>{let u=`${a}[${c}]`,f=l?.range;f&&e.set(u,i(f[0])),s(l,u)})};return s(n.contents,""),e}function M2(t){for(;;){if(!t.startsWith("(")||!t.endsWith(")"))return t;let e=0,n=!0,r=!1;for(let i=0;i<t.length;i++){let s=t[i];if(s==='"'){i=Br(t,i)-1;continue}if(s==="$"){i=bn(t,i)-1;continue}s==="("||s==="["||s==="{"?e++:s===")"||s==="]"||s==="}"?(e--,e===0&&i<t.length-1&&(n=!1)):s===","&&e===1&&(r=!0)}if(!n||r)return t;t=t.slice(1,-1).trim()}}function En(t){return M2(Up(t).trim())}var An=class t{constructor(e=null){this.parent=e}vars=new Map;fns=new Map;set(e,n){this.vars.set(e,n)}has(e){return this.vars.has(e)}get(e){return this.vars.get(e)??this.parent?.get(e)}localFns(e){return this.fns.get(e)??this.parent?.localFns(e)??[]}child(){return new t(this)}names(){return[...this.vars.keys(),...this.parent?.names()??[]]}choiceTypes(){let e=[];for(let n of this.vars.values())n.type.t==="choice"&&e.push(n.type);return[...e,...this.parent?.choiceTypes()??[]]}},rf={pi:[E.num,{t:"num",v:Math.PI}],tau:[E.num,{t:"num",v:2*Math.PI}],e:[E.num,{t:"num",v:Math.E}],inf:[E.num,{t:"builtin",fn:"inf",args:[]}],nan:[E.num,{t:"builtin",fn:"nan",args:[]}],true:[E.bool,{t:"bool",v:!0}],false:[E.bool,{t:"bool",v:!1}]},cf=["exp","ln","sqrt","sin","cos","tan","asin","acos","atan","sinh","cosh","tanh","abs","floor","ceil","round","sign","step","fact"],uf=["atan2","mod","min","max","pow"],L2=new Set(["floor","ceil","round","sign","step"]),dg={t:"rec",name:"rgb",fields:[["r",E.num],["g",E.num],["b",E.num]]},j2={t:"choice",opts:["narrow","medium","wide"]},P2={t:"choice",opts:["light","dark"]},si={width:j2,theme:P2,answers:E.bool},Ia=class t{constructor(e,n,r,i,s=[],o){this.prog=e;this.pack=n;this.localSink=r;this.file=i;let a=e.typeEnv(n);this.env=pf(o?.size?l=>a(l)??o.get(l):a,s),this.tokenNames=e.tokenNames}get inProgress(){return this.prog.fnsInProgress}env;depth=0;tokenNames;fail(e,n,r="mkp.type"){throw new K(r,n,e)}r(e){return P(e,this.env)}nameOf(e,n){for(let r of new Set(e.names())){if(r.startsWith("$"))continue;let i=e.get(r);if(i&&n(this.r(i.type)))return r}}sample(e){return Ra(e,this.env)}noFieldHint(e,n,r){let i=Q(e);return["len","length","size","count"].includes(r)&&["list","text","dict","records","choice"].includes(n.t)?`Write \`len(${i})\` for its length`:n.t==="point"?`A point has only \`.x\` and \`.y\`: write \`${i}.x\``:n.t==="list"||n.t==="records"?`Read one item first, e.g. \`${i}[0].${r}\`, or all of them with \`map(${i}, it => it.${r})\``:n.t==="dict"?`Read a key with \`get(${i}, "${r}", default)\` or \`${i}["${r}"]\``:`Remove \`.${r}\`, or read it from a record`}check(e,n,r){++this.depth>200&&this.fail(e.p,"this expression nests more than 200 levels deep (operators, brackets or calls inside each other), too deep to check. Split it into named steps, e.g. `a = \u2026` then `r = a + \u2026`","mkp.limit");try{return this.check1(e,n,r)}finally{this.depth--}}check1(e,n,r){let i=r?this.r(r):void 0;switch(e.k){case"num":return{ast:{t:"num",v:e.v},type:Number.isInteger(e.v)?E.int:E.num};case"str":return this.template(e.v,!1,e.p,n);case"tex":return this.template(e.v,!0,e.p,n);case"id":return this.ident(e.name,e.p,n,i);case"list":{let s=i&&i.t==="list"?i.of:void 0,o=e.items.map(l=>this.check(l,n,s));if(s&&!Pt(s)&&o.length)return{ast:{t:"list",items:o.map((l,c)=>this.coerce(l,s,e.items[c].p).ast)},type:E.list(s)};let a=E.unknown;return o.forEach((l,c)=>{let u=Ue(a,l.type,this.env);u||this.fail(e.items[c].p,`the items of a list must all have one type; item ${c+1}, ${Ae(e.items[c],l.type)}, differs from the ${N(a)} items before it. Make every item ${N(a)} (e.g. \`${this.sample(a)}\`), or every item ${N(l.type)}`),a=u}),s&&!Pt(s)&&o.length?{ast:{t:"list",items:o.map(l=>this.coerce(l,s,e.p).ast)},type:E.list(s)}:{ast:{t:"list",items:o.map(l=>l.ast)},type:E.list(a)}}case"rec":{if(e.fields.length===0)return i&&i.t==="rec"&&i.fields.length&&this.fail(e.p,`expected ${i.name?`a ${i.name}`:"a"} record with ${i.fields.map(([a,l])=>`${a} (${N(l)})`).join(", ")}; found \`{}\`, an empty record. Write its fields, e.g. \`${this.sample(i)}\``),{ast:{t:"dict0"},type:i&&i.t==="dict"?i:E.dict(E.unknown)};let s=[],o=[];for(let[a,l]of e.fields){let c=i&&i.t==="rec"?i.fields.find(f=>f[0]===a)?.[1]:i&&i.t==="dict"?i.of:void 0,u=this.check(l,n,c);c&&!Pt(c)&&(u=this.coerce(u,c,l.p)),s.push([a,u.ast]),o.push([a,u.type])}if(i&&i.t==="rec"&&i.defaults)for(let[a,l]of i.fields){if(e.fields.some(([f])=>f===a)||i.defaults[a]===void 0)continue;let c=this.check(Gr(i.defaults[a],this.file,e.p.line,e.p.col),new An,l),u=Pt(l)?c:this.coerce(c,l,e.p);s.push([a,u.ast]),o.push([a,l])}return i&&i.t==="rec"&&i.name&&ae({t:"rec",fields:o},{...i,name:void 0},this.env)?{ast:{t:"rec",fields:s},type:r}:{ast:{t:"rec",fields:s},type:{t:"rec",fields:o}}}case"point":{let s=this.coerce(this.check(e.x,n,E.num),E.num,e.x.p),o=this.coerce(this.check(e.y,n,E.num),E.num,e.y.p);return{ast:{t:"point",x:s.ast,y:o.ast},type:E.point}}case"field":{let s=this.check(e.o,n),o=this.r(s.type);if(o.t==="point"&&(e.name==="x"||e.name==="y"))return{ast:{t:"field",o:s.ast,name:e.name},type:E.num};if(o.t==="rec"||o.t==="records"){let a=o.fields.find(l=>l[0]===e.name);if(!a){let l=o.fields.map(p=>p[0]),c=Q(e.o),u=ue(e.name,l),f=u?`Write \`${c}.${u}\``:l.length?`Read one of them, e.g. \`${c}.${l[0]}\``:"Add the field to its type";this.fail(e.p,`\`${c}\` is ${o.t==="records"?`a ${o.kind} record`:`${lt(s.type)}`}, which has no field "${e.name}"${Ie(e.name,l)}; its fields are ${l.join(", ")||"none"}. ${f}`,"mkp.unknown-field")}return{ast:{t:"field",o:s.ast,name:e.name},type:a[1]}}return o.t==="any"?{ast:{t:"field",o:s.ast,name:e.name},type:E.any}:this.fail(e.p,`\`${Q(e.o)}\` is ${N(s.type)}, which has no fields, so \`.${e.name}\` can't be read from it. ${this.noFieldHint(e.o,o,e.name)}`,"mkp.unknown-field")}case"index":{let s=this.check(e.o,n),o=this.r(s.type);if(o.t==="param"||o.t==="rec"){let c=this.check(e.i,n),u=this.r(c.type);if(u.t!=="path"){let f=Q(e.o),p=o.t==="param"?`a ${o.name} (a type parameter: the records the widget is given)`:`${lt(s.type)} record`,h=o.t==="rec"&&o.fields.length?`Read a field by name, e.g. \`${f}.${o.fields[0][0]}\`, or declare an input naming one of its fields, \`in f path(${N(s.type)}, ${N(o.fields[0][1])})\`, and write \`${f}[f]\``:`Declare an input naming one of its fields, e.g. \`in f path(${N(s.type)}, text)\`, and write \`${f}[f]\``;this.fail(e.i.p,`\`${f}\` is ${p}, so [ ] needs a path (an input of type path(\u2026) that names one of its fields); found ${Ae(e.i,c.type)}. ${h}`)}return!Je(u.of,s.type,this.env)&&!ae(s.type,u.of,this.env)&&this.fail(e.i.p,`the path \`${Q(e.i)}\` names a field of ${N(u.of)}, but \`${Q(e.o)}\` is ${lt(s.type)}. Declare the path as path(${N(s.type)}, ${N(u.to)}) and give it ${lt(s.type)} field, or use it on ${lt(u.of)} value`),{ast:{t:"index",o:s.ast,i:c.ast},type:u.to}}if(o.t==="list"){let c=this.coerce(this.check(e.i,n,E.int),E.num,e.i.p);return{ast:{t:"index",o:s.ast,i:c.ast},type:o.of}}if(o.t==="dict"){let c=this.check(e.i,n,E.text);if(!ae(c.type,E.text,this.env)){let u=Ne(this.r(c.type))?`, or turn the number into text with \`${Q(e.o)}[format(${Q(e.i)})]\``:"";this.fail(e.i.p,`the keys of the dict \`${Q(e.o)}\` are text; found the key ${Ae(e.i,c.type)}. Index it with text, e.g. \`${Q(e.o)}["a"]\`${u}`)}return{ast:{t:"index",o:s.ast,i:c.ast},type:o.of}}if(o.t==="any")return{ast:{t:"index",o:s.ast,i:this.check(e.i,n).ast},type:E.any};if(o.t==="range")return{ast:{t:"index",o:s.ast,i:this.coerce(this.check(e.i,n,E.int),E.num,e.i.p).ast},type:E.num};let l=o.t==="text"||o.t==="choice"||o.t==="latex"?`To take part of a text, write \`slice(${Q(e.o)}, 0, 1)\` (characters count from 0)`:"Index a list or a dict instead, or remove the [ ]";return this.fail(e.p,`only lists and dicts can be indexed with [ ]; found ${Ae(e.o,s.type)}. ${l}`)}case"neg":{let s=this.check(e.a,n),o=this.r(s.type);if(Ne(o))return{ast:{t:"builtin",fn:"neg",args:[s.ast]},type:o.t==="int"?E.int:E.num};if(o.t==="point")return{ast:{t:"builtin",fn:"pneg",args:[s.ast]},type:E.point};let a=this.prog.opCandidates("-",this.pack).filter(c=>c.syn.params.length===1),l=this.dispatch(a,[s],e.p,"op -");return l||this.binary("-",{ast:{t:"num",v:0},type:E.int},s,e.p,void 0,e.a)}case"not":{let s=this.check(e.a,n,E.bool);return this.r(s.type).t!=="bool"&&this.fail(e.a.p,`\`not\` needs a bool (true or false) after it; found ${Ae(e.a,s.type)}. ${ff(Q(e.a),this.r(s.type),o=>`not (${o})`)}`),{ast:{t:"not",a:s.ast},type:E.bool}}case"bin":{if(e.op==="and"||e.op==="or"){let l=this.check(e.a,n,E.bool),c=this.check(e.b,n,E.bool);for(let[u,f,p]of[[l,e.a,"left"],[c,e.b,"right"]])if(this.r(u.type).t!=="bool"){let h=e.op,d=m=>p==="left"?`(${m}) ${h} \u2026`:`\u2026 ${h} (${m})`;this.fail(f.p,`both sides of \`${h}\` must be bools (true or false); the ${p} side is ${Ae(f,u.type)}. ${ff(Q(f),this.r(u.type),d)}`)}return{ast:{t:e.op,a:l.ast,b:c.ast},type:E.bool}}if((e.op==="=="||e.op==="!=")&&(e.a.k==="id"||e.b.k==="id")){let l=this.tryCheck(e.a,n),c=this.tryCheck(e.b,n);if(l&&!c)return this.binary(e.op,l,this.check(e.b,n,l.type),e.p,e.a,e.b);if(c&&!l)return this.binary(e.op,this.check(e.a,n,c.type),c,e.p,e.a,e.b)}let s=this.check(e.a,n),o=this.r(s.type),a=this.check(e.b,n,e.op==="+"&&o.t==="list"&&this.r(o.of).t!=="int"?s.type:void 0);return this.binary(e.op,s,a,e.p,e.a,e.b)}case"lam":{if(!i||i.t!=="fn"&&i.t!=="expr"){let c=i&&i.t!=="unknown"&&i.t!=="any"?`, where ${N(i)} is expected`:"";this.fail(e.p,`a function written with => can only be passed to a call that takes one (map, filter, sort, fold, \u2026); found \`${Q(e)}\` on its own${c}. Pass it to a call, e.g. \`map(xs, ${Q(e)})\`, or declare a fn: \`fn step(x: num): num = \u2026\``)}let s=i.t==="fn"?i.params:i.vars.map(c=>c[1]),o=(i.t==="fn",i.ret);if(s.length!==e.params.length){let c=Array.from({length:s.length},(f,p)=>e.params[p]??["x","y","z","w"][p]??`p${p+1}`),u=c.length===1?c[0]:`(${c.join(", ")})`;this.fail(e.p,`the function here is given ${Kn(s.length,"value")} each time, so it must take ${Kn(s.length,"parameter")}; found \`${Q(e)}\`, which takes ${e.params.length}. Write it as \`${u} => \u2026\``)}let a=n.child();e.params.forEach((c,u)=>a.set(c,{type:s[u],from:"local",kind:"param"}));let l=this.check(e.body,a,o.t==="unknown"||o.t==="any"?void 0:o);return o.t!=="unknown"&&o.t!=="any"&&!Pt(o)&&(l=this.coerce(l,o,e.body.p)),{ast:{t:"lam",params:e.params,body:l.ast},type:E.fn(s,l.type)}}case"call":return this.call(e.f,e.args,e.p,n,i);case"apply":{let s=this.check(e.f,n);return this.applyValue(s,e.args,e.p,n,e.f.k==="bin"||e.f.k==="lam"?`(${Q(e.f)})`:Q(e.f))}}}tryCheck(e,n){return e.k!=="id"?this.check(e,n):n.get(e.name)||e.name in rf||si[e.name]||this.prog.constCandidates(e.name,this.pack).length?this.check(e,n):null}ident(e,n,r,i){let s=r.get(e);if(!s&&si[e])return{ast:{t:"var",name:`$${e}`,from:"inst"},type:si[e]};if(i&&i.t==="token"&&i.kind!=="color"&&this.tokenNames?.(i.kind).has(e))return{ast:{t:"str",v:e},type:i};if(!s&&e==="none"&&i&&i.t==="token")return{ast:{t:"str",v:"none"},type:i};if(s&&i&&i.t==="choice"&&i.opts.includes(e)&&this.r(s.type).t!=="choice")return{ast:{t:"str",v:e},type:i};if(s)return s.from==="const"?{ast:{t:"var",name:s.id,from:"const"},type:s.type}:{ast:{t:"var",name:e,from:s.from},type:s.type.t==="ref"?s.type.of:s.type};if(i&&i.t==="choice"&&i.opts.includes(e))return{ast:{t:"str",v:e},type:i};if(i&&i.t==="token"&&this.tokenNames?.(i.kind).has(e))return{ast:{t:"str",v:e},type:i};if(e in rf){let[p,h]=rf[e];return{ast:h,type:p}}let o=this.prog.constCandidates(e,this.pack);if(o.length===1){let p=o[0],h=this.constType(p.id);return{ast:{t:"var",name:p.id,from:"const"},type:h}}if(o.length>1){let p=o.map(d=>d.pack),h=p.length===2?`${p[0]} and ${p[1]}`:p.join(", ");this.fail(n,`"${e}" is a constant in more than one pack (${h}), so it is unclear which is meant. Rename the constant in all but one of those packs, or, in a pack, list only one of them under \`depends\``,"mkp.ambiguous")}let a=r.choiceTypes().filter(p=>p.t==="choice"&&p.opts.includes(e));if(a.length)return{ast:{t:"str",v:e},type:a[0]};let l=[...r.localFns(e),...this.prog.fnCandidates(e,this.pack)];if(l.length===1&&l[0].sig){let p=l[0];return{ast:{t:"fnref",fn:this.ensureFn(p)},type:E.fn(p.sig,p.syn.ret??E.any)}}let c=[...new Set(r.names())].filter(p=>!p.startsWith("$")),u=ue(e,c),f=u?`Write \`${u}\``:`Declare it before using it (an input such as \`in ${e} int = 1\`, a var, or \`const ${e}: int = 1\` at the top), or use a defined name${c.length?`: ${c.slice(0,8).join(", ")}${c.length>8?", \u2026":""}`:""}`;return this.fail(n,`"${e}" is not defined here${Ie(e,c)}. ${f}`,"mkp.unknown-name")}constType(e){let[,n]=e.split(":"),r=(this.prog.consts.get(n)??[]).find(a=>a.id===e);if(r.checked)return r.checked.type;r.checking&&this.fail(r.syn.p,`the constant ${n} uses itself in its own value (directly or through other constants), so it has no value. Give it a value that does not use ${n}, e.g. \`const ${n}${r.type?`: ${N(r.type)}`:""} = ${r.type?Ra(r.type,this.prog.typeEnv(r.pack)):"10"}\``),r.checking=!0;let i=new t(this.prog,r.pack,null,r.file),s=this.prog.typeEnv(r.pack),o=i.check(r.syn.e,new An,r.type);return r.type&&(ae(o.type,r.type,s)||(o=i.coerce(o,r.type,r.syn.p)),o={...o,type:r.type}),r.checked={expr:r.syn.src,ast:o.ast,type:o.type},this.prog.irConsts[e]=r.checked,r.checking=!1,o.type}coerce(e,n,r,i=!0){let s=this.r(e.type),o=this.r(n);if(o.t==="text"&&s.t==="latex")return{ast:{t:"builtin",fn:"tex2text",args:[e.ast]},type:E.text};if(ae(e.type,n,this.env))return e;if(o.t==="point"&&i){let f=this.prog.opCandidates("point",this.pack).find(p=>p.sig&&p.sig.length===1&&ae(e.type,p.sig[0],this.env));if(f)return{ast:{t:"call",fn:this.ensureFn(f),args:[e.ast]},type:E.point}}let a=this.promotion(e.type,n);if(a)return{ast:{t:"call",fn:a,args:[e.ast]},type:n};if(o.t==="list"&&s.t==="list"){let f=this.coerceType(s.of,o.of);if(f)return{ast:{t:"builtin",fn:"map",args:[e.ast,{t:"lam",params:["_x"],body:f({t:"var",name:"_x",from:"local"})}]},type:n}}let l=sf(e.ast),u=B2(l??"it",s,o)||`Give ${lt(n)} value here, or change the declared type to ${N(e.type)}`;return this.fail(r,`expected ${N(n)} here; found ${l?`\`${l}\` (${N(e.type)})`:`${lt(e.type)} value`}. ${u}`,"mkp.type")}coerceType(e,n){if(ae(e,n,this.env))return i=>i;if(this.r(n).t==="point"){let i=this.prog.opCandidates("point",this.pack).find(s=>s.sig&&s.sig.length===1&&ae(e,s.sig[0],this.env));if(i){let s=this.ensureFn(i);return o=>({t:"call",fn:s,args:[o]})}}let r=this.promotion(e,n);return r?i=>({t:"call",fn:r,args:[i]}):null}promotion(e,n){for(let r of this.prog.opCandidates("from",this.pack)){if(!r.sig||r.sig.length!==1)continue;let i=r.syn.ret;if(i&&ae(e,r.sig[0],this.env)&&Je(i,n,this.env))return this.ensureFn(r)}return null}binary(e,n,r,i,s,o){let a=this.r(n.type),l=this.r(r.type),c=s?Q(s):sf(n.ast)??`${lt(n.type)}`,u=o?Q(o):sf(r.ast)??`${lt(r.type)}`,f=`\`${c}\` (${N(n.type)}) and \`${u}\` (${N(r.type)})`,p=Ne(a)&&Ne(l),h=["==","!=","<","<=",">",">="].includes(e);if(p){if(h)return{ast:{t:"builtin",fn:e,args:[n.ast,r.ast]},type:E.bool};let $=a.t==="int"&&l.t==="int"&&e!=="/"&&e!=="^";return{ast:{t:"builtin",fn:e,args:[n.ast,r.ast]},type:$?E.int:E.num}}let d=e==="!="?"==":e===">"||e==="<="||e===">="?"<":e,m=this.prog.opCandidates(d,this.pack).filter($=>$.syn.params.length===2);if(m.length){let $=e===">"||e==="<="?[r,n]:[n,r],b=this.dispatch(m,$,i,`op ${d}`,!0);if(b)return e==="!="||e===">="||e==="<="?{ast:{t:"not",a:b.ast},type:E.bool}:b}if(e==="=="||e==="!="){if(!Ue(n.type,r.type,this.env)&&!(a.t==="choice"&&l.t==="choice")){let $=Ne(a)&&l.t==="text"?`, or turn the number into text: \`format(${c}) ${e} ${u}\``:a.t==="text"&&Ne(l)?`, or turn the number into text: \`${c} ${e} format(${u})\``:"";this.fail(i,`\`${e}\` compares two values of the same type; found ${f}. Compare it with ${lt(n.type)} value, e.g. \`${c} ${e} ${this.sample(n.type)}\`${$}`)}return{ast:{t:"builtin",fn:e,args:[n.ast,r.ast]},type:E.bool}}if(h&&(a.t==="text"||a.t==="choice")&&(l.t==="text"||l.t==="choice"))return{ast:{t:"builtin",fn:e,args:[n.ast,r.ast]},type:E.bool};if(e==="+"){if((a.t==="text"||a.t==="choice"||a.t==="latex")&&(l.t==="text"||l.t==="choice"||Ne(l)||l.t==="latex")){let $=a.t==="latex"&&l.t==="latex"?E.latex:E.text;return{ast:{t:"builtin",fn:"cat",args:[n.ast,r.ast]},type:$}}if(Ne(a)&&(l.t==="text"||l.t==="choice"))return{ast:{t:"builtin",fn:"cat",args:[n.ast,r.ast]},type:E.text};if(a.t==="list"&&l.t==="list"){let $=Ue(a.of,l.of,this.env);return $||this.fail(i,`\`+\` joins two lists only when their items have the same type; found ${f}. Make the items match, e.g. \`${c} + ${this.sample(n.type)}\``),{ast:{t:"builtin",fn:"lcat",args:[n.ast,r.ast]},type:E.list($)}}}if(a.t==="point"&&l.t==="point"&&(e==="+"||e==="-"))return{ast:{t:"builtin",fn:"p"+e,args:[n.ast,r.ast]},type:E.point};if(e==="*"&&Ne(a)&&l.t==="point")return{ast:{t:"builtin",fn:"ps*",args:[n.ast,r.ast]},type:E.point};if((e==="*"||e==="/")&&a.t==="point"&&Ne(l))return{ast:{t:"builtin",fn:"p"+e,args:[n.ast,r.ast]},type:E.point};if(l.t==="unknown"||a.t==="unknown"||a.t==="any"||l.t==="any")return{ast:{t:"builtin",fn:e,args:[n.ast,r.ast]},type:h?E.bool:E.any};if(!s&&e==="-"&&o){let $=l.t==="rec"||l.t==="named";return this.fail(i,`\`-\` can't make ${N(r.type)} negative; found \`-${u}\`. ${$?`Add \`op -(a: ${N(r.type)}): ${N(r.type)} = \u2026\` to the type's pack`:"Negate a number or a point instead"}`,"mkp.no-operator")}let g=(a.t==="text"||l.t==="text")&&(Ne(a)||Ne(l)),y;return a.t==="list"&&e==="+"&&ae(r.type,a.of,this.env)?y=`To add an item to the list, write \`${c} + [${u}]\``:g&&mg.has(e)?y=`Compare like with like: turn the text into a number with \`number(${a.t==="text"?c:u})\`, or the number into text with \`format(${a.t==="text"?u:c})\``:g?y=`Only \`+\` works on text (it joins); for arithmetic turn the text into a number with \`number(${a.t==="text"?c:u})\``:a.t==="named"||a.t==="rec"||l.t==="named"||l.t==="rec"?y=`Define it in the type's pack: \`op ${e}(a: ${N(n.type)}, b: ${N(r.type)}): \u2026 = \u2026\``:y=`Use values that \`${e}\` works on: ${e==="+"?"two numbers, two texts, two lists or two points":mg.has(e)?"two numbers or two texts":"numbers (points also take + and -, and * or / by a number)"}`,this.fail(i,`there is no \`${e}\` for ${N(n.type)} and ${N(r.type)}; found ${f}. ${y}`,"mkp.no-operator")}dispatch(e,n,r,i,s=!1){let o=[];for(let u of e){if(!u.sig||u.sig.length!==n.length)continue;let f=0,p=[],h=!0;for(let d=0;d<n.length;d++){if(ae(n[d].type,u.sig[d],this.env)&&!(this.r(u.sig[d]).t!=="any"&&this.r(n[d].type).t==="any")){p.push(null);continue}let m=this.promotion(n[d].type,u.sig[d]);if(m){p.push(m),f++;continue}h=!1;break}h&&o.push({f:u,cost:f,conv:p})}if(!o.length)return null;if(o.sort((u,f)=>u.cost-f.cost),o.length>1&&o[0].cost===o[1].cost){let u=i.startsWith("op ")?i.slice(3):i,f=o.filter(h=>h.cost===o[0].cost).map(h=>`${i}(${h.f.sig.map(N).join(", ")}) at ${h.f.file===this.file?"":`${h.f.file}:`}line ${h.f.syn.p.line}`),p=`(${n.map(h=>N(h.type)).join(", ")})`;this.fail(r,`\`${u}\` called with ${p} fits more than one definition equally well: ${f.join(" and ")}. Remove one of them, or change their parameter types so only one fits ${p}`,"mkp.ambiguous")}let a=o[0],l=this.ensureFn(a.f),c=n.map((u,f)=>a.conv[f]?{t:"call",fn:a.conv[f],args:[u.ast]}:u.ast);return{ast:{t:"call",fn:l,args:c},type:a.f.syn.ret??this.fnRet(a.f)}}fnRet(e){return(e.syn.local?this.localSink?.[e.id]:this.prog.irFns[e.id])?.ret??E.any}ensureFn(e){let n=e.id.startsWith("local:"),r=n?this.localSink:this.prog.irFns;if(r[e.id]||this.inProgress.has(e.id)||!e.sig)return e.id;this.inProgress.set(e.id,e.syn.ret);try{let i=n?this:new t(this.prog,e.pack,null,e.file),s=n?e.scope.child():new An;e.syn.params.forEach((a,l)=>s.set(a.name,{type:e.sig[l],from:"local",kind:"param"}));let o=i.check(e.syn.body,s,e.syn.ret);e.syn.ret&&(o=i.coerce(o,e.syn.ret,e.syn.body.p)),r[e.id]={name:e.syn.name,params:e.syn.params.map(a=>a.name),types:e.sig,ret:e.syn.ret??o.type,body:o.ast,src:En(e.syn.src),local:n||void 0,op:e.op,pos:[e.syn.p.line,e.syn.p.col],file:this.prog.stableFile(e.pack,e.file)}}finally{this.inProgress.delete(e.id)}return e.id}specialise(e,n,r){let i=e.id.startsWith("local:"),s=i?this.localSink:this.prog.irFns,o=e.syn.params.map((c,u)=>c.type??n[u].type),a=`${e.id}<${o.map(c=>N(c)).join(",")}>`;if(this.inProgress.has(a)){let c=this.inProgress.get(a);return c||this.fail(r,`${e.syn.name} calls itself, so the type of its result can't be worked out from its body. Declare the result type after the parameters, e.g. \`fn ${e.syn.name}(${e.syn.params.map(u=>`${u.name}: num`).join(", ")}): num = \u2026\``,"mkp.recursive-untyped"),{ast:{t:"call",fn:a,args:n.map(u=>u.ast)},type:c}}if(!s[a]){this.inProgress.set(a,e.syn.ret);try{let c=i?this:new t(this.prog,e.pack,null,e.file),u=i?e.scope.child():new An;e.syn.params.forEach((p,h)=>u.set(p.name,{type:o[h],from:"local",kind:"param"}));let f=c.check(e.syn.body,u,e.syn.ret);e.syn.ret&&(f=c.coerce(f,e.syn.ret,e.syn.body.p)),s[a]={name:e.syn.name,params:e.syn.params.map(p=>p.name),types:o,ret:e.syn.ret??f.type,body:f.ast,src:En(e.syn.src),local:i||void 0,generic:e.id,pos:[e.syn.p.line,e.syn.p.col],file:this.prog.stableFile(e.pack,e.file)}}finally{this.inProgress.delete(a)}}let l=n.map((c,u)=>e.syn.params[u].type?this.coerce(c,e.syn.params[u].type,r).ast:c.ast);return{ast:{t:"call",fn:a,args:l},type:s[a].ret}}applyValue(e,n,r,i,s){let o=this.r(e.type),a=`${s}(${n.map(l=>Q(l,24)).join(", ")})`;if(o.t==="fn"){o.params.length!==n.length&&this.fail(r,`\`${s}\` is a function that takes ${Kn(o.params.length,"argument")}; found ${n.length} in \`${a}\`. Write \`${s}(${o.params.map(c=>this.sample(c)).join(", ")})\``);let l=n.map((c,u)=>this.coerce(this.check(c,i,o.params[u]),o.params[u],c.p).ast);return{ast:{t:"apply",f:e.ast,args:l},type:o.ret}}if(o.t==="expr"){if(o.vars.length!==n.length){let c=o.vars.map(u=>u[0]);this.fail(r,`\`${s}\` is an expression in ${c.join(", ")} (a value of type ${N(e.type)}), so a call gives it one value per variable, ${c.length} in all; found ${n.length} in \`${a}\`. Write \`${s}(${o.vars.map(u=>this.sample(u[1])).join(", ")})\``)}let l=n.map((c,u)=>this.coerce(this.check(c,i,o.vars[u][1]),o.vars[u][1],c.p).ast);return{ast:{t:"apply",f:e.ast,args:l},type:o.ret}}return o.t==="any"?{ast:{t:"apply",f:e.ast,args:n.map(l=>this.check(l,i).ast)},type:E.any}:this.fail(r,`\`${s}\` is ${N(e.type)}, not a function, so it can't be called; found \`${a}\`. Remove the brackets after \`${s}\`${Ne(o)&&n.length===1?`, or multiply with \`*\`: \`${s} * (${Q(n[0],24)})\``:""}`)}call(e,n,r,i,s){let o=i.get(e);if(o&&(this.r(o.type).t==="fn"||this.r(o.type).t==="expr"||this.r(o.type).t==="any"))return this.applyValue({ast:{t:"var",name:e,from:o.from==="const"?"const":o.from},type:o.type},n,r,i,e);if(o){let $=this.r(o.type),b=o.kind&&o.kind!=="derived"?`an ${o.kind==="input"?"input":o.kind==="const"?"constant":o.kind==="param"?"parameter":o.kind} of type ${N(o.type)}`:`a value of type ${N(o.type)}`,k=`${e}(${n.map(I=>Q(I,24)).join(", ")})`,w=Ne($)&&n.length===1?`, or multiply with \`*\`: \`${e} * (${Q(n[0],24)})\``:"",D=e in of||cf.includes(e)||uf.includes(e)||this.prog.fnCandidates(e,this.pack).length?`Rename \`${e}\` so the function ${e}(\u2026) can be called`:`Remove the brackets after \`${e}\`${w}`;this.fail(r,`\`${e}\` is ${b.replace(/^an ([^aeiou])/,"a $1")}, not a function, so it can't be called; found \`${k}\`. ${D}`)}let a=i.localFns(e),l=this.prog.fnCandidates(e,this.pack),c=[...a,...l],u=of[e];if(u&&!c.length)return u(this,n,r,i,s);let f=c.filter($=>$.sig),p=Ca(e,n.length);if(f.length||p){let $=!p&&f.filter(O=>O.sig.length===n.length),b=n.map((O,A)=>this.check(O,i,$&&$.length===1?$[0].sig[A]:void 0)),k=[...f];if(p&&b.every((A,_)=>ae(A.type,p[_],this.env))){let A=p.length===1&&L2.has(e)?E.int:e==="abs"&&this.r(b[0].type).t==="int"?E.int:e==="mod"||e==="min"||e==="max"?b.every(W=>this.r(W.type).t==="int")?E.int:E.num:E.num;if(!f.filter(W=>W.sig.every((Y,q)=>ae(b[q].type,Y,this.env))).length)return{ast:{t:"builtin",fn:e,args:b.map(W=>W.ast)},type:A}}let w=this.dispatch(k,b,r,e);if(w)return w;let v=c.filter(O=>!O.sig&&O.syn.params.length===n.length);if(v.length===1)return this.specialise(v[0],b,r);if(u)return u(this,n,r,i,s);let D=[...k.map(O=>O.sig),...[1,2].map(O=>Ca(e,O)).filter(O=>!!O)],I=D.map(O=>`${e}(${O.map(N).join(", ")})`).join(", "),L=`${e}(${n.map(O=>Q(O,24)).join(", ")})`,T=D.find(O=>O.length===n.length),G=T?b.findIndex((O,A)=>!ae(O.type,T[A],this.env)):-1,R=T&&G>=0?`: argument ${G+1}, ${Ae(n[G],b[G].type)}, is not ${N(T[G])}`:T?"":` (${n.length} given)`,j=T?`Pass arguments of those types, e.g. \`${e}(${T.map(O=>this.sample(O)).join(", ")})\``:D.length?`Pass ${Kn(D[0].length,"argument")}, e.g. \`${e}(${D[0].map(O=>this.sample(O)).join(", ")})\``:"Check the arguments";this.fail(r,`no definition of ${e} takes (${b.map(O=>N(O.type)).join(", ")}); found \`${L}\`${R}. ${e} is defined as ${I||"nothing that fits"}. ${j}`,"mkp.no-overload")}let h=c.filter($=>$.syn.params.length===n.length);if(h.length===1){let $=n.map((b,k)=>this.check(b,i,h[0].syn.params[k].type));return this.specialise(h[0],$,r)}if(h.length>1){let $=Array.from({length:n.length},(b,k)=>`${h[0].syn.params[k]?.name??`p${k+1}`}: int`).join(", ");this.fail(r,`${e} is defined ${h.length} times with ${Kn(n.length,"parameter")} and no parameter types, so a call can't tell which one is meant. Give each definition parameter types that differ, e.g. \`fn ${e}(${$}): int = \u2026\`, or rename one of them`,"mkp.ambiguous")}if(c.length){let $=c[0].syn.params;this.fail(r,`${e} takes ${Kn($.length,"argument")} (${$.map(b=>b.name).join(", ")}); found ${n.length} in \`${e}(${n.map(b=>Q(b,24)).join(", ")})\`. Pass ${$.length===1?"one":$.length===2?"both":`all ${$.length}`}: \`${e}(${$.map(b=>b.type?this.sample(b.type):"\u2026").join(", ")})\``)}let d=[1,2,3].filter($=>Ca(e,$));if(d.length){let $=d.length===1?Kn(d[0],"argument"):`${d.join(" or ")} arguments`,b=d.map(k=>`\`${e}(${Ca(e,k).map(()=>"1.5").join(", ")})\``).join(" or ");return this.fail(r,`${e} takes ${$}; found ${n.length} in \`${e}(${n.map(k=>Q(k,24)).join(", ")})\`. Call it as ${b}`,"mkp.unknown-function")}let m=[...Object.keys(of),...cf,...uf,"log","rand",...this.prog.fns.keys()],g=ue(e,m),y=g?`Write \`${g}(\u2026)\``:`Fix the name, or declare the function first, e.g. \`fn ${e}(x: num): num = \u2026\``;return this.fail(r,`there is no function "${e}"${Ie(e,m)}. ${y}`,"mkp.unknown-function")}template(e,n,r,i){let s=Hp(e),o=n?E.latex:E.text;if(!s.length)return{ast:{t:"str",v:e},type:o};let a="",l=0,c=[],u=[],f=[],p=[];return s.forEach((h,d)=>{a+=e.slice(l,h.at)+`\\val{${d}}`,l=h.end;let m=Gr(h.src,r.file,r.line,r.col),g=this.check(m,i);c.push(g.ast);let y=this.showFn(g.type,r);u.push(y);let $=this.r(g.type),b=["num","int","bool","text","latex","choice","point","list"].includes($.t)?$.t:"other";if(b==="other"&&!y){let k=$.t==="rec"&&$.fields.length?$.fields.find(([,D])=>["text","num","int"].includes(this.r(D).t))?.[0]??$.fields[0][0]:void 0,w=N(g.type),v=k?`Show one of its fields, e.g. \`\\val{${h.src}.${k}}\`, or declare`:"Declare";this.fail(r,`\`\\val{${h.src}}\` shows a ${w}, which has no text form, so it can't be written into the text. ${v} \`fn show(v: ${w}): text = \u2026\` so \\val can write any ${w}`,"mkp.type")}p.push(b),f.push(n||_2(e,h.at)?"tex":"text")}),a+=e.slice(l),{ast:{t:"tmpl",v:a,tex:n,holes:c,show:u,modes:f,kinds:p},type:o}}showFn(e,n){let r=this.r(e);if(["num","int","bool","text","latex","choice","point","list","any","unknown","dict"].includes(r.t))return null;let i=this.prog.fnCandidates("show",this.pack).filter(s=>s.sig&&s.sig.length===1&&ae(e,s.sig[0],this.env));return i.length?this.ensureFn(i[0]):null}};function pf(t,e){return e.length?n=>e.includes(n)?{t:"param",name:n}:t(n):t}function _2(t,e){let n=!1;for(let r=0;r<e;r++){if(t[r]==="\\"){r++;continue}t[r]==="$"&&(n=!n)}return n}function Q(t,e=48){let n=Ut(t);return n.length>e?n.slice(0,e-1)+"\u2026":n}function Ut(t){let e=n=>n.k==="bin"||n.k==="lam"?`(${Ut(n)})`:Ut(n);switch(t.k){case"num":return String(t.v);case"str":return JSON.stringify(t.v);case"tex":return t.display?`$$${t.v}$$`:`$${t.v}$`;case"id":return t.name;case"list":return`[${t.items.map(Ut).join(", ")}]`;case"rec":return`{${t.fields.map(([n,r])=>`${n}: ${Ut(r)}`).join(", ")}}`;case"point":return`(${Ut(t.x)}, ${Ut(t.y)})`;case"call":return`${t.f}(${t.args.map(Ut).join(", ")})`;case"apply":return`${e(t.f)}(${t.args.map(Ut).join(", ")})`;case"field":return`${e(t.o)}.${t.name}`;case"index":return`${e(t.o)}[${Ut(t.i)}]`;case"neg":return`-${e(t.a)}`;case"not":return`not ${e(t.a)}`;case"bin":return t.juxt?`${e(t.a)}${e(t.b)}`:`${e(t.a)} ${t.op} ${e(t.b)}`;case"lam":return`${t.params.length===1?t.params[0]:`(${t.params.join(", ")})`} => ${Ut(t.body)}`}}function Ae(t,e){return`\`${Q(t)}\` (${N(e)})`}function lt(t){let e=N(t);return`${/^[aeiou]/.test(e)?"an":"a"} ${e}`}function Kn(t,e){return`${t} ${e}${t===1?"":"s"}`}var mg=new Set(["==","!=","<","<=",">",">="]),q2={color:"accent",font:"body",space:"m",size:"m",radius:"card",shadow:"raised"};function Ra(t,e,n=0){let r=P(t,e);switch(r.t){case"int":return r.lo!==void 0?String(r.lo):"1";case"num":return r.lo!==void 0?String(r.lo):"1.5";case"bool":return"true";case"text":return'"a"';case"latex":return"$x$";case"choice":return r.opts[0];case"point":return"(0, 0)";case"list":return n>1?"[]":`[${Ra(r.of,e,n+1)}]`;case"dict":return"{}";case"rec":return n>1||!r.fields.length?"{}":`{${r.fields.slice(0,2).map(([i,s])=>`${i}: ${Ra(s,e,n+1)}`).join(", ")}}`;case"token":return q2[r.kind]??"\u2026";default:return"\u2026"}}var F2={len:"len(xs)",map:"map(xs, x => \u2026)",filter:"filter(xs, x => \u2026)",find:"find(xs, x => \u2026) or find(xs, x => \u2026, default)",sort:"sort(xs) or sort(xs, x => key)",reverse:"reverse(xs)",fold:"fold(xs, start, (acc, x) => \u2026)",group:"group(xs, x => key)",index:"index(xs, x => key)",indexof:"indexof(xs, x)",range:"range(lo, hi)",zip:"zip(xs, ys)",flatten:"flatten(xss)",first:"first(xs) or first(xs, n)",last:"last(xs) or last(xs, n)",slice:"slice(xs, from, to)",at:"at(xs, i) or at(xs, i, default)",sum:"sum(xs) or sum(lo, hi, k => \u2026)",prod:"prod(lo, hi, k => \u2026)",mean:"mean(xs)",min:"min(xs) or min(a, b)",max:"max(xs) or max(a, b)",if:"if(condition, then, else)",put:"put(d, key, value)",get:"get(d, key, default)",keys:"keys(d)",has:"has(d, key)",format:"format(x) or format(x, digits)",join:"join(xs, separator)",iterate:"iterate(start, n, x => next)",scan:"scan(start, n, x => next)",parse:'parse(text) or parse(text, ["x"])',equivalent:'equivalent(a, b) or equivalent(a, b, ["x"])',lower:"lower(t)",upper:"upper(t)",trim:"trim(t)",number:"number(t)",replace:"replace(t, find, with)",split:"split(t, separator)",contains:"contains(t, part)",startswith:"startswith(t, part)",endswith:"endswith(t, part)",rgb:"rgb(r, g, b)",hsl:"hsl(h, s, l)",dist:"dist(p, q)"};function wg(t){return(F2[t]??`${t}(\u2026)`).split(" or ").map(e=>`\`${e}\``).join(" or ")}function B2(t,e,n){let r=i=>i.t==="num"||i.t==="int";return n.t==="int"&&e.t==="num"?`Round it with \`round(${t})\` (or \`floor\`/\`ceil\`), or declare the type as num`:r(n)&&(e.t==="text"||e.t==="choice")?`To read a number from text, write \`number(${t})\`${n.t==="int"?` (and \`round(number(${t}))\` for an int)`:""}`:n.t==="text"&&r(e)?`To show a number as text, write \`format(${t})\``:n.t==="bool"&&r(e)?`Compare it to get true or false, e.g. \`${t} > 0\``:n.t==="bool"&&e.t==="text"?`Compare it to get true or false, e.g. \`${t} != ""\``:n.t==="list"&&!["list","records"].includes(e.t)?`Wrap it in a list: \`[${t}]\``:""}function ff(t,e,n){return e.t==="num"||e.t==="int"?`Compare it to get true or false, e.g. \`${n(`${t} > 0`)}\``:e.t==="text"?`Compare it to get true or false, e.g. \`${n(`${t} != ""`)}\``:e.t==="choice"?`Compare it with an option, e.g. \`${n(`${t} == ${e.opts[0]}`)}\``:"Use a comparison or another true/false value there"}function sf(t){let e=t;if(e.t==="var"&&typeof e.name=="string")return e.name.startsWith("$")?e.name.slice(1):e.name.includes(":")?e.name.split(":").pop():e.name;if(e.t==="num"||e.t==="bool")return String(e.v);if(e.t==="str"&&typeof e.v=="string")return e.v.length>30?void 0:JSON.stringify(e.v)}function Ca(t,e){return e===1&&cf.includes(t)?[E.num]:e===2&&uf.includes(t)?[E.num,E.num]:t==="log"&&(e===1||e===2)?e===1?[E.num]:[E.num,E.num]:t==="rand"&&e===2?[E.num,E.num]:null}function le(t,e,n,r,...i){if(i.includes(n.length))return;let s=i.length===1?Kn(i[0],"argument"):`${i.slice(0,-1).join(", ")} or ${i[i.length-1]} arguments`,o=`${e}(${n.map(a=>Q(a,24)).join(", ")})`;t.fail(r,`${e} takes ${s}; found ${n.length} in \`${o}\`. Call it as ${wg(e)}`,"mkp.arity")}function Fe(t,e,n,r){let i=t.r(e.type);if(i.t==="list")return i.of;if(i.t==="records")return{t:"rec",fields:i.fields};if(i.t==="any")return E.any;let o=(i.t==="text"||i.t==="choice")&&r!=="join"?`To get a list of its characters or words, write \`split(${Q(n)}, "")\` or \`split(${Q(n)}, " ")\``:`Pass a list (an input of type list(\u2026), or one written out like [1, 2, 3]): ${wg(r)}`;return t.fail(n.p,`${r} needs a list here; found ${Ae(n,e.type)}. ${o}`)}function ne(t,e){return{t:"builtin",fn:t,args:e}}function Wt(t,e,n,r,i=E.unknown){return t.check(e,n,E.fn(r,i))}function Sn(t){return t.type.t==="fn"?t.type.ret:E.any}var of={len(t,e,n,r){le(t,"len",e,n,1);let i=t.check(e[0],r),s=t.r(i.type);return s.t!=="list"&&s.t!=="text"&&s.t!=="dict"&&s.t!=="records"&&s.t!=="any"?t.fail(e[0].p,`len counts the items of a list, the characters of a text or the keys of a dict; found ${Ae(e[0],i.type)}. Pass one of those, e.g. \`len(${t.nameOf(r,o=>o.t==="list")??"[1, 2, 3]"})\``):{ast:ne("len",[i.ast]),type:E.int}},map(t,e,n,r,i){le(t,"map",e,n,2);let s=t.check(e[0],r),o=Fe(t,s,e[0],"map"),a=i&&t.r(i).t==="list"?t.r(i).of:E.unknown,l=Wt(t,e[1],r,[o],Pt(a)?E.unknown:a);return{ast:ne("map",[s.ast,l.ast]),type:E.list(Sn(l))}},filter(t,e,n,r){le(t,"filter",e,n,2);let i=t.check(e[0],r),s=Fe(t,i,e[0],"filter"),o=Wt(t,e[1],r,[s],E.bool);return t.r(Sn(o)).t!=="bool"?t.fail(e[1].p,`filter keeps the items its function says true for, so the function must return a bool; found \`${Q(e[1])}\`, which returns ${N(Sn(o))}. Give a test, e.g. \`filter(${Q(e[0],24)}, x => x > 1)\``):{ast:ne("filter",[i.ast,o.ast]),type:E.list(s)}},find(t,e,n,r){le(t,"find",e,n,2,3);let i=t.check(e[0],r),s=Fe(t,i,e[0],"find"),o=Wt(t,e[1],r,[s],E.bool),a=[i.ast,o.ast];return e[2]&&a.push(t.coerce(t.check(e[2],r,s),s,e[2].p).ast),{ast:ne("find",a),type:s}},sort(t,e,n,r){le(t,"sort",e,n,1,2);let i=t.check(e[0],r),s=Fe(t,i,e[0],"sort");if(e.length===1)return{ast:ne("sort",[i.ast]),type:E.list(s)};let o=Wt(t,e[1],r,[s]);return{ast:ne("sort",[i.ast,o.ast]),type:E.list(s)}},reverse(t,e,n,r){le(t,"reverse",e,n,1);let i=t.check(e[0],r);return{ast:ne("reverse",[i.ast]),type:E.list(Fe(t,i,e[0],"reverse"))}},fold(t,e,n,r){le(t,"fold",e,n,3);let i=t.check(e[0],r),s=Fe(t,i,e[0],"fold"),o=t.check(e[1],r),a=o.type,l=Wt(t,e[2],r,[a,s]),c=Ue(a,Sn(l),t.env);return c?((Pt(a)||!Je(c,a,t.env))&&(a=c,l=Wt(t,e[2],r,[a,s],a)),{ast:ne("fold",[i.ast,o.ast,l.ast]),type:a}):t.fail(e[2].p,`fold's function gets the running total and an item and must return the new total, of the same type as the start value \`${Q(e[1],24)}\` (${N(a)}); found \`${Q(e[2])}\`, which returns ${N(Sn(l))}. Return ${lt(a)}, e.g. \`(acc, x) => acc + x\``)},group(t,e,n,r){le(t,"group",e,n,2);let i=t.check(e[0],r),s=Fe(t,i,e[0],"group"),o=Wt(t,e[1],r,[s]);return{ast:ne("group",[i.ast,o.ast]),type:E.dict(E.list(s))}},index(t,e,n,r){le(t,"index",e,n,2);let i=t.check(e[0],r),s=Fe(t,i,e[0],"index"),o=Wt(t,e[1],r,[s]);return{ast:ne("index",[i.ast,o.ast]),type:E.dict(s)}},indexof(t,e,n,r){le(t,"indexof",e,n,2);let i=t.check(e[0],r);if(gg(t,i))return{ast:ne("tindexof",[i.ast,ii(t,e[1],r)]),type:E.int};let s=Fe(t,i,e[0],"indexof"),o=t.check(e[1],r,s);return{ast:ne("indexof",[i.ast,o.ast]),type:E.int}},range(t,e,n,r){le(t,"range",e,n,2);let i=t.coerce(t.check(e[0],r,E.int),E.num,e[0].p),s=t.coerce(t.check(e[1],r,E.int),E.num,e[1].p);return{ast:ne("range",[i.ast,s.ast]),type:E.list(E.int)}},zip(t,e,n,r){le(t,"zip",e,n,2);let i=t.check(e[0],r),s=t.check(e[1],r);return{ast:ne("zip",[i.ast,s.ast]),type:E.list({t:"rec",fields:[["a",Fe(t,i,e[0],"zip")],["b",Fe(t,s,e[1],"zip")]]})}},flatten(t,e,n,r){le(t,"flatten",e,n,1);let i=t.check(e[0],r),s=t.r(Fe(t,i,e[0],"flatten"));return s.t!=="list"?t.fail(e[0].p,`flatten needs a list of lists, such as [[1], [2, 3]]; found ${Ae(e[0],i.type)}. Pass a list whose items are lists, or drop flatten if the list is already flat`):{ast:ne("flatten",[i.ast]),type:E.list(s.of)}},first(t,e,n,r){le(t,"first",e,n,1,2);let i=t.check(e[0],r),s=Fe(t,i,e[0],"first");if(e.length===1)return{ast:ne("at",[i.ast,{t:"num",v:0}]),type:s};let o=t.coerce(t.check(e[1],r),E.num,e[1].p);return{ast:ne("first",[i.ast,o.ast]),type:E.list(s)}},last(t,e,n,r){le(t,"last",e,n,1,2);let i=t.check(e[0],r),s=Fe(t,i,e[0],"last");if(e.length===1)return{ast:ne("last1",[i.ast]),type:s};let o=t.coerce(t.check(e[1],r),E.num,e[1].p);return{ast:ne("last",[i.ast,o.ast]),type:E.list(s)}},slice(t,e,n,r){le(t,"slice",e,n,3);let i=t.check(e[0],r);if(gg(t,i))return{ast:ne("tslice",[i.ast,t.coerce(t.check(e[1],r),E.num,e[1].p).ast,t.coerce(t.check(e[2],r),E.num,e[2].p).ast]),type:E.text};let s=Fe(t,i,e[0],"slice"),o=t.coerce(t.check(e[1],r),E.num,e[1].p),a=t.coerce(t.check(e[2],r),E.num,e[2].p);return{ast:ne("slice",[i.ast,o.ast,a.ast]),type:E.list(s)}},at(t,e,n,r){le(t,"at",e,n,2,3);let i=t.check(e[0],r),s=Fe(t,i,e[0],"at"),o=t.coerce(t.check(e[1],r),E.num,e[1].p),a=[i.ast,o.ast];return e[2]&&a.push(t.coerce(t.check(e[2],r,s),s,e[2].p).ast),{ast:ne("at",a),type:s}},sum(t,e,n,r){return yg(t,"sum",e,n,r)},prod(t,e,n,r){return yg(t,"prod",e,n,r)},mean(t,e,n,r){le(t,"mean",e,n,1);let i=t.check(e[0],r);return Ne(t.r(Fe(t,i,e[0],"mean")))?{ast:ne("mean",[i.ast]),type:E.num}:t.fail(e[0].p,`mean needs a list of numbers; found ${Ae(e[0],i.type)}. Pass numbers, e.g. \`mean(${t.nameOf(r,s=>s.t==="list"&&Ne(t.r(s.of)))??"[1, 2, 3]"})\``)},min(t,e,n,r){return kg(t,"min",e,n,r)},max(t,e,n,r){return kg(t,"max",e,n,r)},if(t,e,n,r,i){le(t,"if",e,n,3);let s=t.check(e[0],r,E.bool);if(t.r(s.type).t!=="bool")return t.fail(e[0].p,`the condition of if (its first argument) must be a bool (true or false); found ${Ae(e[0],s.type)}. ${ff(Q(e[0],24),t.r(s.type),p=>`if(${p}, \u2026, \u2026)`)}`);let o=p=>p.k==="id"&&!r.get(p.name)&&!si[p.name],a,l;!i&&o(e[1])&&!o(e[2])?(l=t.check(e[2],r),a=t.check(e[1],r,l.type)):(a=t.check(e[1],r,i),l=t.check(e[2],r,i??a.type));let c=Ue(a.type,l.type,t.env),u=a.ast,f=l.ast;if(!c){let p=t.promotion(a.type,l.type),h=t.promotion(l.type,a.type);h?(f={t:"call",fn:h,args:[f]},c=a.type):p?(u={t:"call",fn:p,args:[u]},c=l.type):t.fail(n,`the two results of if must have the same type; found ${Ae(e[1],a.type)} when true and ${Ae(e[2],l.type)} when false. Change \`${Q(e[2],24)}\` to ${lt(a.type)} (e.g. \`${t.sample(a.type)}\`), or \`${Q(e[1],24)}\` to ${lt(l.type)}`)}return{ast:{t:"if",c:s.ast,a:u,b:f},type:c}},put(t,e,n,r){le(t,"put",e,n,3);let i=t.check(e[0],r),s=t.r(i.type);if(s.t!=="dict")return t.fail(e[0].p,`put needs a dict (text keys to values) as its first argument; found ${Ae(e[0],i.type)}. Pass a dict, e.g. \`put(${t.nameOf(r,c=>c.t==="dict")??"{}"}, "a", 1)\``);let o=t.check(e[1],r,E.text);if(!ae(o.type,E.text,t.env))return t.fail(e[1].p,`the keys of a dict are text; found the key ${Ae(e[1],o.type)} in put. Pass text, e.g. "a"${Ne(t.r(o.type))?`, or turn the number into text with \`format(${Q(e[1],24)})\``:""}`);let a=t.check(e[2],r,s.of.t==="unknown"?void 0:s.of),l=Ue(s.of,a.type,t.env);return l?{ast:ne("put",[i.ast,o.ast,a.ast]),type:E.dict(l)}:t.fail(e[2].p,`\`${Q(e[0],24)}\` holds ${N(s.of)} values, so put can't store ${Ae(e[2],a.type)} in it. Pass ${lt(s.of)} as the value, e.g. \`put(${Q(e[0],24)}, ${Q(e[1],24)}, ${t.sample(s.of)})\``)},get(t,e,n,r){le(t,"get",e,n,3);let i=t.check(e[0],r),s=t.r(i.type);if(s.t!=="dict")return t.fail(e[0].p,`get needs a dict (text keys to values) as its first argument; found ${Ae(e[0],i.type)}. Pass a dict, e.g. \`get(${t.nameOf(r,c=>c.t==="dict")??"d"}, "a", 0)\`${t.r(i.type).t==="list"?`; to read an item of a list, write \`at(${Q(e[0],24)}, i, default)\``:""}`);let o=t.check(e[1],r,E.text),a=t.check(e[2],r,s.of),l=Ue(s.of,a.type,t.env)??t.fail(e[2].p,`get's third argument is the default it returns when the key is missing, so it must be ${N(s.of)} like the dict's values; found ${Ae(e[2],a.type)}. Write e.g. \`get(${Q(e[0],24)}, ${Q(e[1],24)}, ${t.sample(s.of)})\``);return{ast:ne("get",[i.ast,o.ast,a.ast]),type:l}},keys(t,e,n,r){le(t,"keys",e,n,1);let i=t.check(e[0],r);return t.r(i.type).t!=="dict"?t.fail(e[0].p,`keys lists the keys of a dict; found ${Ae(e[0],i.type)}. Pass a dict, e.g. \`keys(${t.nameOf(r,s=>s.t==="dict")??"d"})\`${t.r(i.type).t==="list"?`; a list's positions are \`range(0, len(${Q(e[0],24)}) - 1)\``:""}`):{ast:ne("keys",[i.ast]),type:E.list(E.text)}},has(t,e,n,r){le(t,"has",e,n,2);let i=t.check(e[0],r);if(t.r(i.type).t!=="dict")return t.fail(e[0].p,`has checks whether a dict has a key; found ${Ae(e[0],i.type)}. Pass a dict, e.g. \`has(${t.nameOf(r,o=>o.t==="dict")??"d"}, "a")\`${t.r(i.type).t==="list"?`; to test a list, write \`indexof(${Q(e[0],24)}, x) >= 0\``:""}`);let s=t.check(e[1],r,E.text);return{ast:ne("has",[i.ast,s.ast]),type:E.bool}},format(t,e,n,r){le(t,"format",e,n,1,2);let i=t.check(e[0],r),s=[t.coerce(i,E.num,e[0].p).ast];return e[1]&&s.push(t.coerce(t.check(e[1],r),E.num,e[1].p).ast),{ast:ne("format",s),type:E.text}},join(t,e,n,r){le(t,"join",e,n,2);let i=t.check(e[0],r),s=t.r(Fe(t,i,e[0],"join"));if(!["text","choice","num","int","latex","unknown"].includes(s.t))return t.fail(e[0].p,`join needs a list of text or numbers to join into one text; found ${Ae(e[0],i.type)}. Pass such a list, e.g. \`join(["a", "b"], ", ")\`${s.t==="list"?", or flatten a list of lists first with `flatten(\u2026)`":s.t==="rec"?", or pick a field first: `map(xs, it => it.name)`":""}`);let o=t.check(e[1],r,E.text);return{ast:ne("join",[i.ast,o.ast]),type:E.text}},iterate(t,e,n,r){return bg(t,"iterate",e,n,r)},scan(t,e,n,r){let i=bg(t,"scan",e,n,r);return{ast:i.ast,type:E.list(i.type)}},parse(t,e,n,r){le(t,"parse",e,n,1,2);let i=t.check(e[0],r,E.text),s=e[1]?t.check(e[1],r,E.list(E.text)):{ast:{t:"list",items:[]},type:E.list(E.text)},o=e[1]&&e[1].k==="list"?e[1].items.length:1;return{ast:ne("parse",[i.ast,s.ast]),type:E.fn(Array.from({length:e[1]&&e[1].k==="list"?o:0},()=>E.num),E.num)}},equivalent(t,e,n,r){le(t,"equivalent",e,n,2,3);let i=t.check(e[0],r,E.text),s=t.check(e[1],r,E.text),o=e[2]?t.check(e[2],r,E.list(E.text)):{ast:{t:"list",items:[]},type:E.list(E.text)};return{ast:ne("equivalent",[i.ast,s.ast,o.ast]),type:E.bool}},lower:af("lower"),upper:af("upper"),trim:af("trim"),number(t,e,n,r){return le(t,"number",e,n,1),{ast:ne("number",[ii(t,e[0],r)]),type:E.num}},replace(t,e,n,r){return le(t,"replace",e,n,3),{ast:ne("replace",e.map(i=>ii(t,i,r))),type:E.text}},split(t,e,n,r){return le(t,"split",e,n,2),{ast:ne("split",e.map(i=>ii(t,i,r))),type:E.list(E.text)}},contains:lf("contains"),startswith:lf("startswith"),endswith:lf("endswith"),rgb(t,e,n,r){return le(t,"rgb",e,n,3),{ast:ne("rgb",e.map(i=>t.coerce(t.check(i,r),E.num,i.p).ast)),type:dg}},hsl(t,e,n,r){return le(t,"hsl",e,n,3),{ast:ne("hsl",e.map(i=>t.coerce(t.check(i,r),E.num,i.p).ast)),type:dg}},dist(t,e,n,r){return le(t,"dist",e,n,2),{ast:ne("dist",e.map(i=>t.coerce(t.check(i,r),E.point,i.p).ast)),type:E.num}}};function gg(t,e){let n=t.r(e.type);return n.t==="text"||n.t==="choice"||n.t==="latex"}function ii(t,e,n){return t.coerce(t.check(e,n,E.text),E.text,e.p).ast}function af(t){return(e,n,r,i)=>(le(e,t,n,r,1),{ast:ne(t,[ii(e,n[0],i)]),type:E.text})}function lf(t){return(e,n,r,i)=>(le(e,t,n,r,2),{ast:ne(t,n.map(s=>ii(e,s,i))),type:E.bool})}function yg(t,e,n,r,i){if(n.length===1&&e==="sum"){let f=t.check(n[0],i),p=t.r(Fe(t,f,n[0],"sum"));return Ne(p)?{ast:ne("lsum",[f.ast]),type:p.t==="int"?E.int:E.num}:t.fail(n[0].p,`sum needs a list of numbers; found ${Ae(n[0],f.type)}. Pass numbers, e.g. \`sum(${t.nameOf(i,h=>h.t==="list"&&Ne(t.r(h.of)))??"[1, 2, 3]"})\`, or add up a function over a range with \`sum(lo, hi, k => \u2026)\``)}e==="sum"?le(t,e,n,r,1,3):le(t,e,n,r,3);let s=t.coerce(t.check(n[0],i),E.num,n[0].p),o=t.coerce(t.check(n[1],i),E.num,n[1].p),a=Wt(t,n[2],i,[E.int]),l=t.r(Sn(a));if(Ne(l))return{ast:ne(e,[s.ast,o.ast,a.ast]),type:l.t==="int"?E.int:E.num};let c=t.prog.opCandidates(e==="sum"?"+":"*",t.pack).find(f=>f.sig&&f.sig.length===2&&ae(l,f.sig[0],t.env)&&ae(l,f.sig[1],t.env)),u=t.promotion(E.int,l);if(!c||!u){let f=e==="sum"?"+":"*",p=N(Sn(a)),h=l.t==="rec"||l.t==="named",d=[c?"":`\`op ${f}(a: ${p}, b: ${p}): ${p}\``,u?"":`\`op from(n: num): ${p}\` (to start from ${e==="sum"?0:1})`].filter(Boolean).join(" and "),m=h?`Add ${d} to the type's pack`:`Return a number from the function, e.g. \`${e}(${Q(n[0],12)}, ${Q(n[1],12)}, k => k * 2)\``;return t.fail(n[2].p,`${e}(lo, hi, k => \u2026) ${e==="sum"?"adds":"multiplies"} the function's results for each whole k from lo to hi, so they must be numbers${h?` or a type with ${f} and from`:""}; found \`${Q(n[2])}\`, which returns ${p}. ${m}`)}return{ast:ne(e+"T",[s.ast,o.ast,a.ast,{t:"fnref",fn:t.ensureFn(c)},{t:"call",fn:u,args:[{t:"num",v:e==="sum"?0:1}]}]),type:l}}function kg(t,e,n,r,i){if(n.length===1){let c=t.check(n[0],i),u=t.r(Fe(t,c,n[0],e));return!Ne(u)&&u.t!=="unknown"?t.fail(n[0].p,`${e} of a list needs a list of numbers; found ${Ae(n[0],c.type)}. Pass numbers, e.g. \`${e}([1, 2, 3])\`, or two numbers: \`${e}(a, b)\``):{ast:ne("l"+e,[c.ast]),type:u.t==="int"?E.int:E.num}}le(t,e,n,r,1,2);let s=t.check(n[0],i),o=t.check(n[1],i),a=t.r(s.type),l=t.r(o.type);if(!(Ne(a)||a.t==="any")||!(Ne(l)||l.t==="any")){let[c,u]=Ne(a)||a.t==="any"?[n[1],o.type]:[n[0],s.type];return t.fail(c.p,`${e} takes two numbers, or one list of numbers; found ${Ae(n[0],s.type)} and ${Ae(n[1],o.type)}. Replace ${Ae(c,u)} with a number, e.g. \`${e}(${c===n[0]?`1, ${Q(n[1],24)}`:`${Q(n[0],24)}, 1`})\``)}return{ast:ne(e,[s.ast,o.ast]),type:a.t==="int"&&l.t==="int"?E.int:E.num}}function bg(t,e,n,r,i){le(t,e,n,r,3);let s=t.check(n[0],i),o=t.coerce(t.check(n[1],i),E.num,n[1].p),a=s.type,l=Wt(t,n[2],i,[a]),c=Ue(a,Sn(l),t.env);return c?((!Je(c,a,t.env)||Pt(a))&&(a=c,l=Wt(t,n[2],i,[a],a)),{ast:ne(e,[s.ast,o.ast,l.ast]),type:a}):t.fail(n[2].p,`${e}'s step function gets the current value and must return the next one, of the same type as the start value \`${Q(n[0],24)}\` (${N(a)}); found \`${Q(n[2])}\`, which returns ${N(Sn(l))}. Return ${lt(a)}, e.g. \`v => v + 1\``)}var Ht={nesting:12,children:32,elements:300,defDepth:12,eachItems:1e4,nodes:5e3,listSize:1e4,budget:1e6,budgetMax:2e7,steps:1e4,recursion:64,pixelsTerms:2e3},$g={t:"choice",opts:["arrow","hollow","one","many","dot","ring","cross","none"]},Oa={tone:{t:"token",kind:"color"},line:{t:"choice",opts:["solid","dashed","dotted"]},head:$g,tail:$g,dim:E.bool,bold:E.bool,layer:{t:"choice",opts:["front","behind"]},opacity:{t:"num",lo:0,hi:1},corner:{t:"choice",opts:["none","s","m"]},lanes:{t:"choice",opts:["full","turn"]},hop:{t:"choice",opts:["auto","none"]}},V2=new Set(["id","if","basis","span","self","keep",...Ft]),z2=new Set(["hidden","grow"]),U2=new Set(["circle","path"]),Ma=["enter","leave","click"],W2={t:"choice",opts:["start","center","end","stretch"]},H2=/^(auto|fit|\d+(\.\d+)?(fr|ch)|xs|s|m|l|xl)$/,G2=new Set(["change","end"]);function Ds(t,e){let n=t.typeEnv(e.pack),r=new Map,i=[],s=[],o=new Map,a=new Map,l=[],c=[];for(let p of e.syn.members)if(p.m==="in"){r.set(p.name,{type:p.type,hasDefault:!!p.def||p.type.t==="slot"||p.type.t==="records",about:p.about}),i.push(p.name);let h=P(p.type,n);h.t==="records"&&a.set(h.kind,{input:p.name,type:h}),h.t==="slot"&&l.push(p.name)}else p.m==="fields"?s=p.names:p.m==="out"?o.set(p.name,p.payload):p.m==="requires"&&c.push(p.cap);let u=e.syn.members.find(p=>p.m==="deprecated"),f={};for(let p of e.syn.members)p.m==="in"&&Wr(p.name)&&p.def?.v==="expr"&&(f[p.name]=sn(p.name,p.def.src));for(let p of Ft)f[p]===void 0&&delete f[p];return{id:e.id,kind:e.syn.kind,name:e.syn.name,version:e.syn.version,pack:e.pack,inputs:r,order:i,fields:s,outs:o,records:a,slots:l,requires:c,...e.syn.params?.length?{params:e.syn.params}:{},...u?{deprecated:u.text}:{},...Object.keys(f).length?{sizes:f}:{}}}function Eg(t,e,n,r,i){let s=La(t,e,n,r,i);return s?Sg(s):null}function Sg(t,e=""){return`${t.param} stands for one type in every input that uses it, but it is ${N(t.prev)} in one place and ${N(t.got)} in another${e}. Give values of one type, e.g. all numbers or all text`}function La(t,e,n,r,i){if((t.t==="named"||t.t==="param")&&n.includes(t.name)){let o=r[t.name];if(!o)return r[t.name]=e,null;let a=Ue(o,e,i);return a?(r[t.name]=a,null):{param:t.name,prev:o,got:e}}let s=P(e,i);if((t.t==="list"||t.t==="dict")&&s.t===t.t)return La(t.of,s.of,n,r,i);if(t.t==="rec"&&s.t==="rec")for(let[o,a]of t.fields){let l=s.fields.find(([c])=>c===o);if(l){let c=La(a,l[1],n,r,i);if(c)return c}}return null}function ai(t,e,n=!0){if(typeof t=="number")return Number.isInteger(t)?E.int:E.num;if(typeof t=="boolean")return E.bool;if(typeof t=="string")return E.text;if(Array.isArray(t)){if(!t.length&&!n)return E.list(E.unknown);if(!t.length)throw new Error(`${e} is an empty list, so the type of its items can't be worked out. Give at least one item, e.g. - name: First`);let r=ai(t[0],`${e}[0]`,!1);for(let i=1;i<t.length;i++){let s=ai(t[i],`${e}[${i}]`,!1),o=Ue(r,s,()=>{});if(!o)throw new Error(`${e}[${i}] is ${N(s)}, but the items before it are ${N(r)}; every item must have the same fields, of the same types. Give it the same fields as the others`);r=o}return E.list(r)}if(t&&typeof t=="object")return{t:"rec",fields:Object.entries(t).map(([r,i])=>[r,ai(i,`${e}.${r}`,!1)])};throw new Error(`${e} has no value. Write one after its colon, or remove ${e}`)}function mf(t,e){let n=new Map([...t.inputs].map(([i,s])=>[i,{...s,type:jt(s.type,e)}])),r=new Map([...t.records].map(([i,s])=>[i,{input:s.input,type:jt(s.type,e)}]));return{...t,inputs:n,records:r,params:void 0}}var un=class{constructor(e,n,r,i){this.prog=e;this.entry=n;this.diags=r;this.opts=i;let s=n.syn,o=new Map;for(let c of s.members){if(c.m!=="in")continue;let u=f=>{f.t==="records"?(o.set(f.kind,{t:"rec",name:f.kind,fields:f.slot?[...f.fields,["slot",E.slot]]:f.fields,...f.defaults?{defaults:f.defaults}:{}}),f.fields.forEach(([,p])=>u(p))):f.t==="list"&&u(f.of)};u(c.type)}let a=e.typeEnv(n.pack),l=o.size?c=>a(c)??o.get(c):a;this.env=pf(l,s.params??[]),this.x=new Ia(e,n.pack,this.localFns,n.file,s.params??[],o),this.x.tokenNames=i.tokenNames,this.ir={ir:1,kind:s.kind,id:n.id,name:s.name,version:s.version,pack:n.pack,file:this.prog.stableFile(n.pack,n.file),about:s.about,inputs:[],pos:Ze(s.p)},s.params?.length&&(this.ir.params=s.params);for(let c of s.members){let u=c.m==="state"&&c.opts?c.opts:c.m==="in"||c.m==="var"||c.m==="host"?P(c.type,this.env).t==="choice"?P(c.type,this.env).opts:[]:[];for(let f of u)this.options.has(f)||this.options.set(f,c.m==="state"||c.m==="in"||c.m==="var"||c.m==="host"?c.name:"")}s.comments.length&&(this.ir.comment=s.comments),this.path.push(`${s.name}@${s.version}`)}ir;x;env;scope=new An;localFns={};staticIds=new Map;elementCount=0;path=[];usesGfx=new Set;gfxAt=new Map;declaredAt=new Map;uses=new Set;outs=new Map;signals=new Map;controlNames=new Map;stateNames=new Map;options=new Map;err(e){if(e instanceof K)this.diags.add({...e.diagnostic,path:e.diagnostic.path??[...this.path]});else throw e}fail(e,n,r="mkp.check"){throw new K(r,n,e,[...this.path])}get label(){let e=this.entry.syn;return this.entry.pack==="$doc"?e.name:`${e.name}@${e.version}`}parentHead(e=1){let n=this.path[this.path.length-1-e];return n===void 0||this.path.length-1-e===0?this.label:`"${n}"`}check(){let e=this.entry.syn,n=this.ir;this.checkSizes();for(let s of e.members)try{switch(s.m){case"requires":if((n.requires??=[]).push(s.cap),!/^[a-z0-9-]+@\d+$/.test(s.cap)){let o=s.cap.replace(/@.*$/,"").toLowerCase().replace(/[^a-z0-9-]/g,"")||"gfx";this.fail(s.p,`requires names a capability with its version, written name@N; found "${s.cap}". Write requires ${o}@1`)}break;case"deprecated":n.deprecated=s.text;break;case"budget":s.n>Ht.budgetMax&&this.fail(s.p,`budget may be at most ${Ht.budgetMax.toLocaleString("en")} operations (the work one evaluation may do); found ${s.n.toLocaleString("en")}. Write budget ${Ht.budgetMax} or less, or make the widget do less work`,"mkp.limit"),n.budget=s.n;break;case"fields":n.fields=s.names;break;case"out":s.payload&&this.checkType(s.payload,s.p),this.outs.set(s.name,s.payload),(n.outs??=[]).push($r({name:s.name,payload:s.payload,about:s.about,comment:s.comments.length?s.comments:void 0}));break;case"signal":this.checkType(s.payload,s.p),s.name==="error"&&this.fail(s.p,`the signal name "error" is reserved: every widget already sends an error signal to the host when it fails; found signal error. Rename it, e.g. signal problem ${N(s.payload)}`,"mkp.reserved"),this.signals.set(s.name,s.payload),(n.signals??=[]).push($r({name:s.name,payload:s.payload,about:s.about,comment:s.comments.length?s.comments:void 0}));break}}catch(o){this.err(o)}if(e.kind==="extern")for(let s of e.members){if(s.m!=="node"&&s.m!=="derived"&&s.m!=="state"&&s.m!=="var")continue;let o=s.m==="node"?`the view line "${s.node.head}"`:s.m==="state"?`the control ${s.name} = ${s.control}`:s.m==="var"?`var ${s.name}`:`the value ${s.name} = \u2026`;this.err(new K("mkp.extern-view",`an extern is drawn by its provider's own code, so it declares only inputs, outs, signals and requires, with no view, controls or values; found ${o}. Remove this line, or drop "extern" to write ${e.name} as a widget in MKP`,"p"in s?s.p:s.node.p))}for(let s of e.members)if(s.m==="in")try{this.input(s)}catch(o){this.err(o)}if(n.fields){let s=e.members.find(o=>o.m==="fields")?.p??e.p;for(let o of n.fields)n.inputs.some(a=>a.name===o)||this.err(new K("mkp.unknown-field",`fields lists "${o}", which is not an input of ${this.label}${Ie(o,n.inputs.map(a=>a.name))}; fields names the inputs that values written without a name fill, in order. Declare it (in ${o} text = "") or remove it from fields`,s,[...this.path]))}let r=[];for(let s of e.members)try{switch(s.m){case"host":{this.checkType(s.type,s.p);let o=this.staticValue(s.def,s.type,s.p,s.name);this.scope.set(s.name,{type:s.type,from:"inst",kind:"host"}),r.push($r({k:"host",name:s.name,type:s.type,default:o,about:s.about,pos:Ze(s.p),comment:Ts(s.comments)}));break}case"var":{this.checkType(s.type,s.p);let o=this.value(s.def,s.type,this.scope,s.p,!0,s.name);this.declare(s.name,s.p,"a var"),this.scope.set(s.name,{type:s.type,from:"inst",kind:"var"}),this.stateNames.set(s.name,{settable:!0,type:s.type}),r.push($r({k:"var",name:s.name,type:s.type,default:o,about:s.about,pos:Ze(s.p),comment:Ts(s.comments)}));break}case"state":r.push(this.state(s));break;case"derived":{this.declare(s.name,s.p,"a value");let o=this.x.check(s.e,this.scope);this.scope.set(s.name,{type:o.type,from:"inst",kind:"derived"}),r.push($r({k:"derived",name:s.name,value:this.irExpr(o,s.src,s.p),pos:Ze(s.p),comment:Ts(s.comments)}));break}case"fn":{let o=s.params.filter(f=>!f.type).map(f=>f.name);if(o.length||!s.ret){let f=`fn ${s.name}(${s.params.map(d=>`${d.name}: ${d.type?N(d.type):"num"}`).join(", ")}): ${s.ret?N(s.ret):"num"} = \u2026`,p=`${o.length>1?"parameters":"parameter"} ${o.join(", ")}`,h=o.length&&!s.ret?`no type on its ${p} or on its result`:o.length?`no type on its ${p}`:"no result type";this.fail(s.p,`fn ${s.name} has ${h}; every fn says what it takes and what it gives. Write the types after colons, e.g. ${f} (num is an example: use the real types)`,"mkp.untyped")}this.shadow(s.name,s.p);let a=this.scope.fns.get(s.name)??[],l=`local:${this.entry.id}:${s.name}#${a.length}`,c=s.params.every(f=>f.type)?s.params.map(f=>f.type):void 0,u={id:l,pack:this.entry.pack,file:this.entry.file,syn:s,sig:c,scope:this.scope};a.push(u),this.scope.fns.set(s.name,a),c&&this.x.ensureFn(u),r.push($r({k:"fn",name:s.name,fn:l,params:s.params.map(f=>f.type?{name:f.name,type:f.type}:{name:f.name}),ret:s.ret,body:xg(s.src),pos:Ze(s.p),comment:Ts(s.comments)}));break}}}catch(o){this.err(o)}r.length&&(n.values=r);for(let s of e.members)s.m==="node"&&this.collectIds(s.node);for(let s of e.members)if(s.m==="command")try{s.payload&&this.checkType(s.payload,s.p);let o=this.scope.child(),a=s.payload?P(s.payload,this.env):void 0;if(a&&a.t==="rec")for(let[c,u]of a.fields)o.set(c,{type:u,from:"local",kind:"field"});let l=s.actions.flatMap(c=>this.action(c,o));(n.commands??=[]).push($r({name:s.name,payload:s.payload,about:s.about,actions:l,comment:Ts(s.comments)}))}catch(o){this.err(o)}let i=[];for(let s of e.members)if(s.m==="node")try{i.push(...this.nodes([s.node],{kind:"view"},this.scope,1))}catch(o){this.err(o)}i.length&&(n.view=i),this.elementCount>Ht.elements&&this.err(new K("mkp.limit",`${this.label} has ${this.elementCount} elements, more than the ${Ht.elements} one definition may have. Repeat a line with each (each r in 1..16 key=r) instead of writing every copy out, or move part of the view into a part of its own`,e.p,[...this.path]));for(let s of e.members)if(s.m==="project")try{let o=this.x.coerce(this.x.check(s.e,this.scope,E.text),E.text,s.p);(n.project??={})[s.target]=this.irExpr(o,s.src,s.p)}catch(o){this.err(o)}if(this.answerLeaks(),this.implementsCheck(),Object.keys(this.localFns).length&&(n.fns=this.localFns),this.usesGfx.size&&!e.about&&e.kind!=="extern"&&this.err(new K("mkp.no-fallback",`${this.label} draws with gfx@1 (${[...this.usesGfx].join(", ")}) but has no about text, which readers without gfx@1 see in its place. Add one in quotes after the name: ${this.label} "A map of heights."`,e.p,[...this.path])),this.usesGfx.size&&!(n.requires??[]).includes("gfx@1")){let s=[...this.usesGfx].map(o=>this.gfxAt.has(o)?`${o} (line ${this.gfxAt.get(o).line})`:o);this.err(new K("mkp.requires-gfx",`${s.join(", ")} ${s.length>1?"draw":"draws"} with the gfx@1 capability, but ${this.label} doesn't declare it. Add the line requires gfx@1 under the ${this.label} line`,e.p,[...this.path]))}return n}answerLeaks(){let e=this.ir,n=new Set(e.inputs.filter(i=>i.answer).map(i=>i.name));if(!n.size||!e.project)return;let r=(i,s,o)=>{if(!i||typeof i!="object")return!1;if(i.t==="if"&&i.c.t==="var"&&i.c.name==="$answers")return r(i.b,s,o)||!s&&!1;if(i.t==="var"&&i.from==="inst"&&n.has(i.name))return!s;if(i.t==="call"&&this.localFns[i.fn]&&!o.has(i.fn)&&(o.add(i.fn),r(this.localFns[i.fn].body,s,o)))return!0;for(let a of Object.values(i))if(Array.isArray(a)){for(let l of a)if(l&&typeof l=="object"&&"t"in l&&r(l,s,o))return!0}else if(a&&typeof a=="object"&&"t"in a&&r(a,s,o))return!0;return!1};for(let i of e.values??[])i.k==="derived"&&r(i.value.ast,!1,new Set)&&n.add(i.name);for(let[i,s]of Object.entries(e.project))s&&r(s.ast,!1,new Set)&&this.err(new K("mkp.answer-leak",`project ${i} shows ${[...n].join(", ")}, which ${n.size>1?"hold":"holds"} the answer (an input marked answer), outside if(answers, \u2026), so Markdown built without answers would still give it away. Wrap that part in if(answers, \u2026, ""), e.g. project ${i} = prompt + if(answers, "Answer: " + \u2026, "")`,{file:this.entry.file,line:s.pos?.[0]??this.entry.syn.p.line,col:s.pos?.[1]??1},[...this.path]))}implementsCheck(){let e=this.ir;for(let n of this.entry.syn.members)if(n.m==="implements")for(let r of n.names)try{let i=this.prog.lookupIface(r,this.entry.pack);i||this.fail(n.p,`implements names ${r}, but no loaded pack declares an interface by that name${Ie(r,[...this.prog.ifaces.values()].map(l=>`${l.syn.name}@${l.syn.version}`))}; interfaces come from a host's pack. Check the name and version, load the pack that declares it, or remove implements ${r}`,"mkp.unknown-interface");let s=i.syn,o=(l,c)=>Je(l,c,this.env)||ae(l,c,this.env)&&ae(c,l,this.env),a=[];for(let l of s.inputs){let c=e.inputs.find(u=>u.name===l.name);c?o(c.type,l.type)||a.push([`its in ${l.name} is ${N(c.type)}, not ${N(l.type)}`,`change it to in ${l.name} ${N(l.type)}`]):a.push([`has no in ${l.name} ${N(l.type)}`,`add in ${l.name} ${N(l.type)}`])}for(let l of s.hosts){let c=(e.values??[]).find(u=>u.k==="host"&&u.name===l.name);c?o(c.type,l.type)||a.push([`its host ${l.name} is ${N(c.type)}, not ${N(l.type)}`,`change it to host ${l.name} ${N(l.type)}`]):a.push([`has no host ${l.name} ${N(l.type)}`,`add host ${l.name} ${N(l.type)} = \u2026`])}for(let l of s.signals){let c=e.signals?.find(p=>p.name===l.name),u=P(l.payload,this.env),f=c?P(c.payload,this.env):void 0;if(!c||!f||f.t!=="rec"||u.t!=="rec")a.push([`has no signal ${l.name} ${N(l.payload)}`,`add signal ${l.name} ${N(l.payload)}, and send it from an event (@click send ${l.name} \u2026)`]);else for(let[p,h]of u.fields){let d=f.fields.find(([m])=>m===p);(!d||!o(d[1],h))&&a.push([`its signal ${l.name} has no field ${p}: ${N(h)}`,`add ${p}: ${N(h)} to signal ${l.name}`])}}for(let l of s.outs)e.outs?.some(c=>c.name===l.name)||a.push([`has no out ${l.name}`,`add out ${l.name}`]);if(s.project&&!e.project?.md&&a.push(["has no project md","add project md = \u2026"]),a.length){let l=a.map(c=>c[1]).join("; ");this.fail(n.p,`${this.label} implements ${r} but ${a.map(c=>c[0]).join("; ")}, which the interface asks for. ${l[0].toUpperCase()}${l.slice(1)}; or remove implements ${r}`,"mkp.interface")}(e.implements??=[]).push(i.id)}catch(i){this.err(i)}}shadow(e,n){try{this.shadow1(e,n)}catch(r){this.err(r)}}shadow1(e,n){if(this.prog.packs.get(this.entry.pack)?.builtin)return;let r=`${e[0].toUpperCase()}${e.slice(1)}`;if(si[e]){let s=e==="width"?"the reader's width (narrow, medium or wide)":e==="theme"?"the reader's theme (light or dark)":"the answers switch (true when the Markdown includes the answers)";this.fail(n,`"${e}" is already ${s}, which every definition can read, so it can't be declared here too. Rename it, e.g. "${e==="width"?"boxWidth":e==="theme"?"look":"given"}"`,"mkp.shadow")}vg.has(e)&&this.fail(n,`"${e}" is a built-in value (as are ${[...vg].filter(s=>s!==e).join(", ")}), so it can't be a name here. Rename it, e.g. "${e}Value"`,"mkp.shadow");for(let s of["color"])this.opts.tokenNames(s).has(e)&&this.fail(n,`"${e}" is a colour token, so it can't be a name here: tone=${e} or if(\u2026, ${e}, \u2026) could then mean either the colour or this. Rename it, e.g. "is${r}" or "${e}2"`,"mkp.shadow");let i=this.options.get(e);i!==void 0&&i!==e&&this.fail(n,`"${e}" is one of the options ${i||"a choice here"} can take, so it can't also be a name: ${i||"the choice"} == ${e} could then mean either. Rename it, e.g. "is${r}"`,"mkp.shadow")}checkType(e,n){let r=i=>{switch(i.t){case"param":break;case"path":r(i.of),r(i.to);break;case"named":if(this.entry.syn.params?.includes(i.name)||P(i,this.env).t!=="named")break;this.prog.lookupType(i.name,this.entry.pack)||this.fail(n,`there is no type "${i.name}"${Ie(i.name,[...this.prog.types.values()].map(s=>s.name))}. Use a built-in type (num, int, text, bool, list(text), \u2026) or declare it at the top level: type ${i.name} = {\u2026}`,"mkp.unknown-type");break;case"list":case"dict":case"ref":r(i.of);break;case"rec":case"records":i.fields.forEach(s=>r(s[1]));break;case"expr":i.vars.forEach(s=>r(s[1])),r(i.ret);break;default:break}};r(e)}declare(e,n,r="a value"){if(this.scope.has(e)){let i=this.declaredAt.get(e);this.fail(n,`"${e}" is declared twice in ${this.label}${i?`: first as ${i.what} on line ${i.p.line}, again here`:""}. Rename one of them, e.g. "${e}2", or remove this line`,"mkp.duplicate")}this.declaredAt.set(e,{p:n,what:r}),this.shadow(e,n)}scopeType(e){let n=P(e,this.env);return n.t==="records"?E.list({t:"rec",fields:n.slot?[...n.fields,["slot",E.slot]]:n.fields}):e}input(e){this.checkType(e.type,e.p),this.declare(e.name,e.p,"an input");let n={name:e.name,type:e.type,pos:Ze(e.p)};e.answer&&(n.answer=!0),e.about&&(n.about=e.about),e.comments.length&&(n.comment=e.comments);let r=K2(e.type,this.env)==="records"&&e.def?.v==="expr"&&e.def.e.k==="list"&&!e.def.e.items.length;e.def&&!r&&(n.default=this.staticValue(e.def,e.type,e.p,e.name)),this.ir.inputs.push(n);let i=P(e.type,this.env);this.scope.set(e.name,{type:this.scopeType(e.type),from:"inst",kind:i.t==="ref"?"ref":"input"}),i.t==="ref"&&this.stateNames.set(e.name,{settable:!0,type:i.of})}staticValue(e,n,r,i){return this.value(e,n,new An,r,!0,i)}state(e){this.declare(e.name,e.p,`a ${e.control}`);let n={},r=E.num,i,s,o=e.args.filter(d=>!d.key),a=new Map(e.args.filter(d=>d.key).map(d=>[d.key,d])),l=d=>{let m=a.get(d);return a.delete(d),m},c=l("play"),u=!1;c&&(c.value.v!=="dur"&&this.fail(c.p,`play takes a duration, how long ${e.name} takes to play through; found play=${c.value.src}. Write e.g. play=8s, or play=500ms/step for a pace per step`),i=c.value.ms,u=!!c.value.per);let f=l("loop");if(f){let d=f.value.v==="expr"&&f.value.e.k==="id"?f.value.e.name:"";["once","repeat","bounce"].includes(d)||this.fail(f.p,`loop takes once, repeat or bounce; found loop=${f.value.src}${Ie(f.value.src,["once","repeat","bounce"])}. Write e.g. loop=repeat to start again from the beginning, or loop=bounce to play back and forth`),s=d}switch(e.control){case"slider":{let d=o.shift();(!d||d.value.v!=="range")&&this.fail(d?.p??e.p,`a slider needs its range first, written lo..hi; found ${d?d.value.src:"no range"}. Write e.g. ${e.name} = slider 0..10${e.label!==void 0?` "${e.label}"`:""}`);let m=this.x.coerce(this.x.check(d.value.lo,this.scope),E.num,d.p),g=this.x.coerce(this.x.check(d.value.hi,this.scope),E.num,d.p);n.min=this.constOrExpr(m,d.value.loSrc,d.p),n.max=this.constOrExpr(g,d.value.hiSrc,d.p);let y=l("step"),$=!1;if(y){let b=this.value(y.value,E.num,this.scope,y.p);n.step=b,$=y.value.v==="expr"&&y.value.e.k==="num"&&Number.isInteger(y.value.e.v)}r=$&&P(m.type,this.env).t==="int"?E.int:E.num;break}case"choice":r={t:"choice",opts:e.opts},n.opts={lit:e.opts};break;case"toggle":r=E.bool;break;case"steps":{let d=o.shift();d||this.fail(e.p,`steps needs its number of steps first; found none. Write e.g. ${e.name} = steps 4${e.label!==void 0?` "${e.label}"`:""}, or steps (len(items)) for one step per item`),n.n=this.value(d.value,E.int,this.scope,d.p);for(let m of["none","track"]){let g=l(m);if(g){let y=this.value(g.value,E.bool,this.scope,g.p);"lit"in y||this.fail(g.p,`${m} on steps must be written as true or false, since it is fixed when the widget is built; found ${m}=${g.value.src}. Write ${m}=true (${m==="none"?"start at no step":"show a track"}) or ${m}=false`),n[m]=y}}r=E.int;break}case"clock":r=E.num,i&&this.fail(c?.p??e.p,`a clock counts seconds on its own, so it takes no play=; found play=${c?.value.src}. Remove play=\u2026, and start or stop it from an event with play ${e.name} or pause ${e.name}`);break;case"drag":{for(let d of["x","y"]){let m=l(d);(!m||m.value.v!=="range")&&this.fail(m?.p??e.p,`drag needs a range for ${d}, written ${d}=lo..hi; found ${m?`${d}=${m.value.src}`:`no ${d}=`}. Write e.g. ${e.name} = drag x=0..1 y=0..1`),n[d]=this.value(m.value,E.range,this.scope,m.p)}r=E.point;break}}if(o.length){let d=o[0].value.src,m={slider:`Remove it (a slider takes one range), or give it by name, e.g. step=${d}`,steps:"Remove it (steps takes one count), or give it by name: none=true, track=true, play=\u2026",toggle:`Write it bare (${e.name} = toggle "label"), with = true before the label to start it on`,choice:`Write only its options, e.g. ${e.name} = choice(a|b) "label", with = a before the label to start on a`,clock:`Write it bare: ${e.name} = clock "label"`,drag:`Give its ranges by name: ${e.name} = drag x=0..1 y=0..1`};this.fail(o[0].p,`${e.control} takes ${e.control==="slider"||e.control==="steps"?"no more values":"no value"} here; found ${d}. ${m[e.control][0].toUpperCase()}${m[e.control].slice(1)}`)}let p={slider:["step","play","loop"],steps:["none","track","play","loop"],drag:["x","y"],clock:["loop"],toggle:["play","loop"],choice:["play","loop"]};for(let[d,m]of a){let g=p[e.control]??[];this.fail(m.p,`${e.control} has no setting "${d}"${Ie(d,g)}; found ${d}=${m.value.src}. ${g.length?`It takes ${g.map(y=>`${y}=`).join(", ")}; remove ${d}=\u2026 or use one of those`:`Remove ${d}=\u2026`}`,"mkp.unknown-prop")}e.control==="drag"&&i&&this.fail(c?.p??e.p,`a drag control is moved by the reader, so it can't play; found play=${c?.value.src}. Remove play=\u2026 from ${e.name}`);let h={k:"state",name:e.name,control:e.control,type:r,args:n,pos:Ze(e.p)};if(i&&(h.play=i),u&&(h.playPer=!0),s&&(h.loop=s),e.def&&(h.default=this.value(e.def,r,this.scope,e.def.p)),e.label&&(h.label=e.label),e.comments.length&&(h.comment=e.comments),this.scope.set(e.name,{type:r,from:"inst",kind:"state",control:e.control}),this.stateNames.set(e.name,{control:e.control,settable:!0,type:r}),this.controlNames.set(e.name,e.control),e.events.length){h.on={};for(let d of e.events)try{let m=e.control==="slider"||e.control==="steps";G2.has(d.name)||this.fail(d.p,`a ${e.control} raises only @change${m?" and @end":""}; found @${d.name}. Write @change \u2026 to act when ${e.name} changes${m?", or @end \u2026 when it reaches its end":""}`,"mkp.unknown-event"),d.name==="end"&&!m&&this.fail(d.p,`only a slider or steps reaches an end, so a ${e.control} has no @end; found @end under ${e.name}. Use @change instead, or make ${e.name} a slider or steps`),this.deferred.push(()=>{h.on[d.name]=[...h.on[d.name]??[],...this.actions(d,this.scope)]})}catch(m){this.err(m)}}return h}deferred=[];collectIds(e){for(let n of e.args)if(n.key==="id"&&n.value.v==="expr"&&n.value.e.k==="id"&&!n.value.src.startsWith("(")){let r=n.value.e.name,i=e.args.some(o=>!o.key&&o.value.v==="expr"&&o.value.e.k==="id"&&o.value.e.name==="hidden"),s=this.staticIds.get(r);s&&this.err(new K("mkp.duplicate-id",`the id "${r}" is used twice in ${this.label} (first on line ${s.p.line}); every id in a definition names one element. Rename this one, e.g. id=${r}2`,n.p,[...this.path])),this.staticIds.set(r,{hidden:i,overlay:e.head==="overlay",p:n.p})}for(let n of e.children)this.collectIds(n)}irExpr(e,n,r){let i={expr:xg(n),ast:e.ast,type:e.type,pos:Ze(r)};return df(e.ast,this.scope)&&(i.static=!0),i}takes(e){let n=P(e,this.env);return n.t==="token"?`a ${n.kind} token: ${["none",...this.opts.tokenNames(n.kind),...n.kind==="size"?["fill"]:[]].join(", ")}`:n.t==="choice"?`one of ${n.opts.join(", ")}`:n.t==="bool"?"true or false":(n.t==="int"||n.t==="num")&&n.lo!==void 0&&n.hi!==void 0?`${n.t==="int"?"a whole number":"a number"} from ${n.lo} to ${n.hi}`:n.t==="int"?"a whole number (int)":n.t==="num"?"a number":n.t==="range"?"a range, written lo..hi":n.t==="duration"?"a duration such as 2s or 500ms":N(e)}example(e){let n=P(e,this.env);switch(n.t){case"token":{let r=[...this.opts.tokenNames(n.kind)];return n.kind==="color"&&r.includes("accent")?"accent":r[0]??"none"}case"choice":return n.opts[0];case"bool":return"true";case"int":return String(n.lo??1);case"num":return String(n.lo??1.5);case"text":return'"\u2026"';case"latex":return"$x^2$";case"range":return"0..1";case"duration":return"2s";case"list":return"[\u2026]";default:return"\u2026"}}value(e,n,r,i,s=!1,o){let a=o??"this value",l=f=>o?`${o}=${f}`:f,c=e.v==="range"?`${e.src}, a range`:e.v==="dur"?`${e.src}, a duration`:e.src;if(n.t==="list"&&n.of.t==="named"&&n.of.name==="track")return this.tracks(e,r,i);let u=P(n,this.env);switch(u.t){case"range":{e.v!=="range"&&this.fail(i,`${a} takes a range, written lo..hi; found ${c}. Write e.g. ${l(e.v==="expr"&&e.e.k==="num"?`0..${e.src}`:"0..1")}`);let f=this.x.coerce(this.x.check(e.lo,r),E.num,i),p=this.x.coerce(this.x.check(e.hi,r),E.num,i);return{range:[this.constOrExpr(f,e.loSrc,i),this.constOrExpr(p,e.hiSrc,i)]}}case"duration":return e.v!=="dur"&&this.fail(i,`${a} takes a duration, written with its unit; found ${c}. Write e.g. ${l(e.v==="expr"&&e.e.k==="num"?`${e.src}s`:"6s")} (or 500ms)`),{ms:e.ms};case"ref":{s&&this.fail(i,`${a} is a ref input, so it can't have a default: each widget that uses this one passes its own var or control, which the ref then changes; found = ${e.src}. Remove = ${e.src}`),(e.v!=="expr"||e.e.k!=="id")&&this.fail(i,`${a} is a ref, so it takes the name of a var or control of the widget using it, which it can then change; found ${c}. Declare one there and pass its name, e.g. var total ${N(u.of)} = \u2026, then ${l("total")}`);let f=this.stateNames.get(e.e.name)??this.refInScope(e.e.name,r);if(!f){let h=r.get(e.e.name);this.fail(i,`${a} is a ref and needs a var, control or ref input it can change, but "${e.e.name}" ${h?`is ${h.kind==="input"?"an input":`a ${h.kind}`}, which can't be changed`:"is not declared here"}${Ie(e.e.name,this.stateNames.keys())}. Declare it (var ${e.e.name} ${N(u.of)} = \u2026) or pass one that exists`,"mkp.not-state")}return!(P(u.of,this.env).t==="num"&&P(f.type,this.env).t==="int")&&(!ae(f.type,u.of,this.env)||!ae(u.of,f.type,this.env))&&this.fail(i,`${a} is a ref to ${N(u.of)}, but ${e.e.name} is ${N(f.type)}; a ref and what it changes have the same type. Pass a ${N(u.of)} var or control, or make the input ref ${N(f.type)}`),{ref:e.e.name}}case"token":{if(e.v==="expr"&&e.e.k==="id"){let h=e.e.name;if(h==="none"||this.opts.tokenNames(u.kind).has(h)||u.kind==="size"&&h==="fill")return{tok:h,kind:u.kind};let d=r.get(h);if(d&&P(d.type,this.env).t==="token")return this.irExpr({ast:{t:"var",name:h,from:d.from==="const"?"const":d.from},type:d.type},h,i);let m=ue(h,this.opts.tokenNames(u.kind));this.fail(i,`"${h}" is not a ${u.kind} token${m?` (did you mean "${m}"?)`:""}; ${a} takes ${this.takes(u)}. Write ${m?l(m):"one of those names"}`,"mkp.unknown-token")}if(e.v!=="expr")return this.fail(i,`${a} takes ${this.takes(u)}; found ${c}. Write a token name, e.g. ${l(this.example(u))}`,"mkp.style-token");e.e.k==="str"&&!this.opts.tokenNames(u.kind).has(e.e.v)&&e.e.v!=="none"&&this.fail(i,`${a} takes a ${u.kind} token by name${u.kind==="color"?", never a written-out colour, so themes and dark mode can change it":""}; found ${e.src}. Write one of ${["none",...this.opts.tokenNames(u.kind)].join(", ")}, e.g. ${l(this.example(u))}`,"mkp.style-token");let f=this.x.check(e.e,r,u),p=P(f.type,this.env);return p.t==="token"||p.t==="text"||p.t==="choice"?this.irExpr({ast:f.ast,type:u},e.src,i):this.fail(i,`${a} takes ${this.takes(u)}; found ${e.src}, which gives ${N(f.type)}. Write a token name, or an expression that gives one, e.g. ${l(u.kind==="color"?"(if(done, ok, muted))":this.example(u))}`,"mkp.style-token")}case"path":{let f=P(u.of,this.env),p=f.t==="rec"?f.fields.filter(([,g])=>ae(g,u.to,this.env)).map(([g])=>g):[],h=p[0]??(f.t==="rec"?f.fields[0]?.[0]:void 0)??"city";e.v!=="expr"&&this.fail(i,`${a} takes the name of a field of the items${p.length?` (${p.join(", ")})`:""}; found ${c}. Write e.g. ${l(h)}`);let d=e.e.k==="id"?e.e.name:e.e.k==="str"&&!e.e.v.includes("\\val{")?e.e.v:null;if(d==="")return{lit:""};if(d!==null&&f.t==="rec")return this.pathTo(d,u,i,this.env,o);let m=this.x.check(e.e,r,u);return ae(m.type,u,this.env)||this.fail(i,`${a} takes the name of a field of the items holding ${N(u.to)}${p.length?` (${p.join(", ")})`:""}; found ${e.src}, which gives ${N(m.type)}. Write a field name, e.g. ${l(h)}`,"mkp.type"),this.irExpr(m,e.src,i)}case"param":s&&this.fail(i,`${a} has type ${N(u)}, a type parameter that each use of ${this.label} fixes, so a default can't be checked here; found = ${e.src}. Remove the default and pass ${a} where ${this.label} is used`,"mkp.type"),this.fail(i,`${a} has type ${N(u)}, a type parameter that each use of ${this.label} fixes, so ${e.src} can't be checked against it here. Pass the value where ${this.label} is used instead`,"mkp.type");break;case"expr":{let f=u.vars.map(m=>m[0]);if(e.v!=="expr"){let m=P(u.ret,this.env).t,g=m==="bool"?`(${f[0]} > 1)`:m==="num"||m==="int"?`(${f[0]} + 1)`:"(\u2026)";this.fail(i,`${a} takes an expression in ${f.join(", ")}, worked out again for each ${f.join(", ")}; found ${c}. Write one in brackets, e.g. ${l(f.length?g:"(\u2026)")}`)}let p=r.child();for(let[m,g]of u.vars)p.set(m,{type:g,from:"local",kind:"param"});let h=this.x.check(e.e,p,u.ret);h=this.x.coerce(h,u.ret,i);let d={t:"lam",params:u.vars.map(m=>m[0]),body:h.ast};return this.irExpr({ast:d,type:u},e.src,i)}case"slot":return s?this.fail(i,`${a} is a slot, filled by the lines indented under each use of the widget, so it can't have a default; found = ${e.src}. Remove the default: in ${a} slot`):this.fail(i,`${a} is a slot, filled by the lines indented under the widget, not by a value; found ${l(e.src)}. Remove it and write the content on its own lines under the widget`);case"records":{let f=u.fields.filter(([,p])=>P(p,this.env).t!=="records").slice(0,2).map(([p])=>`${p}=\u2026`).join(" ");return this.fail(i,`${a} is a list of ${u.kind} records, written as indented "${u.kind} \u2026" lines under the widget, not as a value; found ${l(e.src)}. Write one line per record instead, e.g. ${u.kind} ${f}`)}case"text":{e.v!=="expr"&&this.fail(i,`${a} takes text; found ${c}. Write it in quotes, e.g. ${l('"\u2026"')}`);let f=e.e;if(f.k==="tex"&&(f={k:"str",v:f.display?`$$${f.v}$$`:`$${f.v}$`,p:f.p}),f.k==="str"&&!f.v.includes("\\val{"))return{text:f.v};let p=this.x.coerce(this.x.check(f,r,E.text),E.text,i);return this.constOrExpr(p,e.src,i)}case"latex":{if(e.v!=="expr"&&this.fail(i,`${a} takes maths written in $\u2026$; found ${c}. Write e.g. ${l("$x^2$")}`),e.e.k==="tex"&&!e.e.v.includes("\\val{"))return e.e.display?{tex:e.e.v,display:!0}:{tex:e.e.v};let f=this.x.check(e.e,r,E.latex);return P(f.type,this.env).t!=="latex"&&this.fail(i,`${a} takes maths ($\u2026$, or an expression that gives latex); found ${e.src}, which gives ${N(f.type)}. Write it in $\u2026$, with \\val{\u2026} for a live value, e.g. ${l("$\\val{n}$")}`),this.irExpr(f,e.src,i)}case"choice":{if(e.v==="expr"&&e.e.k==="id"&&u.opts.includes(e.e.name)&&!r.get(e.e.name))return{lit:e.e.name};if(e.v!=="expr"&&this.fail(i,`${a} takes one of ${u.opts.join(", ")}; found ${c}. Write one of those words, e.g. ${l(u.opts[0])}`,"mkp.enum"),e.e.k==="id"&&!r.get(e.e.name)&&!this.prog.constCandidates(e.e.name,this.entry.pack).length){let p=ue(e.e.name,u.opts);this.fail(i,`${a} takes one of ${u.opts.join(", ")}; found ${e.e.name}${p?` (did you mean "${p}"?)`:""}. Write ${p?l(p):`one of those words, e.g. ${l(u.opts[0])}`}`,"mkp.enum")}let f=this.x.check(e.e,r,u);return ae(f.type,u,this.env)||this.fail(i,`${a} takes one of ${u.opts.join(", ")}; found ${e.src}, which gives ${N(f.type)}. Write one of those words, e.g. ${l(u.opts[0])}`,"mkp.enum"),this.constOrExpr(f,e.src,i)}default:{e.v!=="expr"&&this.fail(i,`${a} takes ${this.takes(n)}; found ${c}. Write ${u.t==="int"||u.t==="num"||u.t==="bool"?`one value, e.g. ${l(this.example(u))}`:`a value of type ${N(n)}`}`);let f=this.x.check(e.e,r,n);return f=this.x.coerce(f,n,i),(u.t==="num"||u.t==="int")&&this.checkNumRange(f,u,i,a,o),this.constOrExpr(f,e.src,i)}}}tracks(e,n,r){e.v!=="expr"&&this.fail(r,`cols takes a number of equal columns (cols=3) or a list of column tracks (cols=[auto, 1fr, 6ch]); found ${e.src}. Write one of those`);let i=e.src.trim();if(i.startsWith("[")&&i.endsWith("]")){let l=i.slice(1,-1).split(",").map(c=>c.trim().replace(/^"(.*)"$/,"$1")).filter(Boolean);for(let c of l)H2.test(c)||this.fail(r,`"${c}" is not a column track; a track is auto (as wide as its content), fit, Nfr (a share of the free space, e.g. 1fr), Nch (N characters wide, e.g. 6ch) or a size token (xs, s, m, l, xl); found cols=${i}. Write e.g. cols=[auto, 1fr]`,"mkp.input-type");return l.length||this.fail(r,`a grid needs at least one column; found cols=${i}. Write e.g. cols=[1fr] or cols=1`,"mkp.input-type"),{lit:l}}let s=this.x.check(e.e,n),o=P(s.type,this.env);if(o.t==="list"&&P(o.of,this.env).t==="text")return this.irExpr(s,e.src,r);if(o.t!=="int"&&this.fail(r,`cols takes a whole number of equal columns or a list of tracks such as [auto, 1fr]; found ${i}, which gives ${N(s.type)}. Write e.g. cols=2`,"mkp.input-type"),s.ast.t==="num")return s.ast.v<1&&this.fail(r,`a grid needs at least one column; found cols=${i}. Write cols=1 or more`,"mkp.input-range"),{lit:Array.from({length:s.ast.v},()=>"1fr")};let a={t:"builtin",fn:"map",args:[{t:"builtin",fn:"range",args:[{t:"num",v:1},s.ast]},{t:"lam",params:["_c"],body:{t:"str",v:"1fr"}}]};return this.irExpr({ast:a,type:E.list(E.text)},e.src,r)}pathTo(e,n,r,i=this.env,s){if(e==="")return{lit:""};let o=s??"this path",a=P(n.of,i);a.t!=="rec"&&this.fail(r,`"${e}" names a field, but the items it reads are ${N(n.of)}, not records with fields. Write the items as records with that field, e.g. {${e}: \u2026}`,"mkp.type");let l=a.fields.map(([u])=>u),c=a.fields.find(([u])=>u===e);if(!c){let u=ue(e,l),f=s?`${s}=`:"";this.fail(r,`"${e}" isn't a field of the items${u?` (did you mean "${u}"?)`:""}; their fields are ${l.join(", ")||"none"}. ${l.length?`Write ${f}${u??l[0]}${u?"":" or another of those"}, or add ${e} to the items`:`Give the items a ${e} field`}`,"mkp.unknown-field")}if(!ae(c[1],n.to,i)){let u=a.fields.filter(([,p])=>ae(p,n.to,i)).map(([p])=>p),f=P(n.to,i).t==="text"&&["int","num","bool"].includes(P(c[1],i).t);this.fail(r,`${o} needs a field holding ${N(n.to)}, but "${e}" holds ${N(c[1])}. ${f?`Quote its values to make them text (${e}: "3")`:`Give ${e} ${N(n.to)} values`}${u.length?`, or name a field that holds ${N(n.to)}: ${u.join(", ")}`:""}`,"mkp.type")}return{lit:e}}instantiateUse(e,n,r,i){let s=e.params,o={},a=this.prog.typeEnv(e.pack),l=e.fields.slice(),c={};for(let f of n){let p=f.key??(f.value.v==="expr"&&f.value.e.k==="id"&&e.inputs.has(f.value.e.name)?null:l.shift());if(!p)continue;f.key&&l.splice(l.indexOf(f.key)>>>0,l.includes(f.key)?1:0);let h=e.inputs.get(p);if(!h||!oi(h.type,s)||P(h.type,a).t==="path"||f.value.v!=="expr")continue;let d=this.x.check(f.value.e,r),m=La(h.type,d.type,s,o,a);m&&this.fail(f.p,Sg(m,c[m.param]?` (${c[m.param]} gives ${N(m.prev)}, ${p}=${f.value.src} gives ${N(m.got)})`:""),"mkp.type");for(let g of s)o[g]&&!c[g]&&(c[g]=p)}let u=s.filter(f=>!o[f]);if(u.length){let f=[...e.inputs].filter(([,h])=>oi(h.type,u)&&P(h.type,a).t!=="path").map(([h,d])=>`${h} (${N(d.type)})`),p=u.join(" and ");this.fail(i,`${e.name} can't tell what type ${p} ${u.length>1?"are":"is"} here: ${p} is read from the value of an input that uses it, and none is given. ${f.length?`Pass ${f.join(" or ")}, e.g. ${f[0].split(" ")[0]}=[{city: "Oslo"}] for a list of records`:`Pass the inputs of type ${p}`}`,"mkp.type")}return mf(e,o)}refInScope(e,n){let r=n.get(e);if(r&&(r.kind==="state"||r.kind==="var"||r.kind==="ref"))return{type:r.type}}checkNumRange(e,n,r,i="this value",s){if(e.ast.t!=="num"&&!(e.ast.t==="builtin"&&e.ast.fn==="neg"&&e.ast.args[0].t==="num"))return;let o=e.ast.t==="num"?e.ast.v:-e.ast.args[0].v,a=l=>s?`${s}=${l}`:String(l);n.t==="int"&&!Number.isInteger(o)&&this.fail(r,`${i} takes a whole number; found ${o}. Write e.g. ${a(Math.round(o))}`,"mkp.input-type"),n.lo!==void 0&&(o<n.lo||o>n.hi)&&this.fail(r,`${i} takes ${this.takes(n)}; found ${o}. Write a value in that range, e.g. ${a(o<n.lo?n.lo:n.hi)}`,"mkp.input-range")}constOrExpr(e,n,r){let i=e.ast;if(i.t==="num"||i.t==="bool"||i.t==="str")return{lit:i.v};if(i.t==="builtin"&&i.fn==="neg"&&i.args[0].t==="num")return{lit:-i.args[0].v};let s=hf(i);return s!==void 0&&(i.t==="list"||i.t==="rec")&&!JSON.stringify(e.type).includes('"choice"')?{lit:s}:this.irExpr(e,n,r)}nodes(e,n,r,i){e.length>Ht.children&&this.err(new K("mkp.limit",`${this.parentHead(0)} has ${e.length} lines directly under it, more than the ${Ht.children} one element may hold (this is number ${Ht.children+1}). Group them into nested rows or columns, or write one line and repeat it with each`,e[Ht.children].p,[...this.path]));let s=[];for(let o of e)try{let a=this.node(o,n,r,i);a&&s.push(a)}catch(a){this.err(a)}return s}node(e,n,r,i){i>Ht.nesting&&this.fail(e.p,`"${e.head}" here is nested ${i} levels deep, past the ${Ht.nesting} levels one definition may nest. Use fewer containers inside containers (each, switch and case are not counted), or move the inner part into a part of its own`,"mkp.limit"),this.path.push(e.head);try{return this.node1(e,n,r,i)}finally{this.path.pop()}}node1(e,n,r,i){let s=e.head;switch(s){case"each":return this.each(e,n,r,i);case"switch":return this.switch(e,n,r,i);case"slot":{let o=e.args[0],a=e.args.slice(1),l=a.length===1&&a[0].key==="if"?a[0]:void 0;if(!o||o.key||o.value.v!=="expr"||a.length&&!l){let f=this.ir.inputs.filter(p=>P(p.type,this.env).t==="slot").map(p=>p.name);this.fail(e.p,`slot places one slot input of ${this.label} where it stands, and may take if=; found ${e.args.length?`slot ${e.args.map(p=>(p.key?`${p.key}=`:"")+p.value.src).join(" ")}`:"slot with no name"}. Write slot and the slot's name, e.g. slot ${f[0]??"body"}${f.length?"":" (declared as in body slot)"}, or slot ${f[0]??"body"} if=(open)`)}let c=this.x.check(o.value.e,r);P(c.type,this.env).t!=="slot"&&this.fail(o.p,`slot places a slot input, but ${o.value.src} is ${N(c.type)}; found slot ${o.value.src}. ${P(c.type,this.env).t==="text"?`Show text with text ${o.value.src}, or declare`:"Declare"} ${o.value.src} as a slot (in ${o.value.src} slot) and fill it with lines indented under the widget`),this.elementCount++;let u={node:"slot",value:this.irExpr(c,o.value.src,o.p),pos:Ze(e.p)};if(l){let f={};this.meta(l,f,r),u.meta=f}return u}case"controls":{let o=[...this.controlNames].filter(([,c])=>c!=="drag").map(([c])=>c),a=o.length?`its controls are ${o.join(", ")}`:"it declares none (name = slider \u2026, toggle, choice(\u2026), steps \u2026 or clock)",l=e.args.map(c=>c.value.v==="expr"&&c.value.e.k==="id"?c.value.e.name:this.fail(c.p,`controls takes the bare names of ${this.label}'s controls; found ${c.value.src}. Write e.g. controls ${o[0]??"level"}`));for(let c of l)this.controlNames.get(c)==="drag"&&this.fail(e.p,`"${c}" is a drag control, moved on the canvas, so controls can't place it in the bar. Remove ${c} from controls`,"mkp.unknown-control"),this.controlNames.has(c)||this.fail(e.p,`"${c}" is not a control of ${this.label}${Ie(c,o)}; ${a}. ${o.length?`Write e.g. controls ${ue(c,o)??o[0]}`:"Declare a control first"}`,"mkp.unknown-control");return{node:"controls",names:l,pos:Ze(e.p)}}case"arrow":return this.arrow(e,r);case"fill":this.fail(e.p,`fill must sit directly under the widget whose slot it fills; found it under ${this.parentHead()}. Move the fill line up so it is directly under the widget line, and put the each or other lines inside the fill`);break;case"case":case"else":this.fail(e.p,`${s} must sit directly under a switch on=\u2026 line; found it under ${this.parentHead()}. Put a switch above it, e.g. switch on=n, and indent ${s==="case"?"case 3":"else"} under it`)}if(n.kind==="use"||n.kind==="record"){let o=n.kind==="use"?null:n.type;if(n.kind==="use"?n.sig.inputs.has(s)&&P(n.sig.inputs.get(s).type,this.env).t!=="records":o.fields.some(c=>c[0]===s&&P(c[1],this.env).t!=="records"))return{node:"$prop",record:s,...this.propLine(e,n,r),pos:Ze(e.p)};let l=this.findRecord(s,n);if(l)return this.record(e,l,n.sig,r,i)}return this.element(e,r,i)}propLine(e,n,r){let i=e.head,s=n.kind==="use"?n.sig.inputs.get(i).type:n.type.fields.find(o=>o[0]===i)[1];if(e.args.length!==1||e.args[0].key){let o=e.args.length?`${i} ${e.args.map(a=>a.key?`${a.key}=${a.value.src}`:a.value.src).join(" ")}`:`${i} with no value`;this.fail(e.p,`the prop line "${i}" sets one value, written ${i} <value>; found ${o}. Write one value, e.g. ${i} ${e.args[0]&&!e.args[0].key?e.args[0].value.src:this.example(s)}`)}if(e.children.length||e.events.length){let o=e.children[0]??e.events[0];this.fail(o.p,`the prop line "${i}" sets a value and can't have lines indented under it; found ${e.children.length?`"${e.children[0].head}"`:`@${e.events[0].name}`} under it. Move that line out from under ${i}`)}return{props:{[i]:this.value(e.args[0].value,s,r,e.args[0].p,!1,i)}}}findRecord(e,n){if(n.kind==="use")return n.sig.records.get(e);for(let[r,i]of n.type.fields){let s=P(i,this.env);if(s.t==="records"&&s.kind===e)return{input:r,type:s}}}record(e,n,r,i,s){let o=n.type,a=new Map(o.fields.map(([p,h])=>[p,vt(h,this.prog.typeEnv(r.pack))])),l=o.fields.filter(([,p])=>P(p,this.env).t!=="records").map(([p])=>p),{props:c,meta:u}=this.fillArgs(e.args,a,l,i,`${o.kind} record`,new Set);for(let[p,h]of o.fields){if(c[p]!==void 0||P(h,this.env).t==="records")continue;let d=o.defaults?.[p];if(d!==void 0){c[p]=this.staticValue(St(d,this.entry.file,e.p.line,e.p.col),vt(h,this.prog.typeEnv(r.pack)),e.p);continue}e.children.some(m=>m.head===p)||this.fail(e.p,`the ${o.kind} record needs ${p}, ${this.takes(h)}; found ${o.kind} with no ${p}. Add it, e.g. ${o.kind} ${p}=${this.example(h)}`,"mkp.missing-input")}for(let[p,h]of Object.entries(c))h!==void 0&&this.gfxCheck(o.kind,p);ah.has(o.kind)&&this.gfx(o.kind,e.p);let f={node:"$record",record:o.kind,input:n.input,props:c,pos:Ze(e.p)};if(Object.keys(u).length&&(f.meta=u),e.comments.length&&((f.meta??={}).comment=e.comments),e.events.length&&(r.name==="canvas"&&r.pack==="core"&&U2.has(o.kind)?this.shapeEvents(e,o.kind,f,i):this.fail(e.events[0].p,`a ${o.kind} record is data for ${r.name}, so it can't take events; found @${e.events[0].name}. Remove the @${e.events[0].name} line${r.name==="canvas"&&r.pack==="core"?", or point at a circle or a path instead":""}`)),e.children.length)if(o.slot){let p=[],h=[];for(let m of e.children)(a.has(m.head)||this.findRecord(m.head,{kind:"record",type:o,sig:r})?p:h).push(m);let d=this.nodes(p,{kind:"record",type:o,sig:r},i,s+1);this.mergeOwn(f,d),f.children=this.nodes(h,{kind:"view"},i,s+1)}else{let p=this.nodes(e.children,{kind:"record",type:o,sig:r},i,s+1);this.mergeOwn(f,p)}return f}shapeEvents(e,n,r,i){r.on={};let s=r.on;for(let o of e.events)try{Ma.includes(o.name)||this.fail(o.p,`a ${n} raises no "${o.name}" event${Ie(o.name,Ma)}; it raises ${Ma.join(", ")}. Write @${ue(o.name,Ma)??"click"} \u2026, or remove the @${o.name} line`,"mkp.unknown-event");let a=r.props?.label;o.name==="click"&&(!a||a.lit===""||a.text==="")&&this.fail(o.p,`a ${n} that takes @click is a control, so a screen reader needs its name; found no label=. Add one, e.g. ${n} \u2026 label="Rent"`,"mkp.missing-input");let l=i.child();this.deferred.push(()=>{s[o.name]=[...s[o.name]??[],...this.actions(o,l)]})}catch(a){this.err(a)}}mergeOwn(e,n){for(let r of n)r.node==="$prop"?Object.assign(e.props??={},r.props):(e.records??=[]).push(r)}gfx(e,n){this.usesGfx.add(e),this.gfxAt.has(e)||this.gfxAt.set(e,n)}gfxCheck(e,n){}element(e,n,r){this.elementCount++;let i=this.resolveDef(e.head,e.p);i.params?.length&&(i=this.instantiateUse(i,e.args,n,e.p)),this.uses.add(i.id),i.kind==="widget"||i.kind==="part"||i.kind;let s=i.fields.length?i.fields:[],{props:o,meta:a}=this.fillArgs(e.args,new Map([...i.inputs].map(([d,m])=>[d,m.type])),s,n,i.name,new Set(i.slots));if(i.name==="canvas"&&i.pack==="core"){let d=o.dims;d&&d.lit===3&&this.gfx("canvas dims=3",e.p)}for(let d of i.requires)d==="gfx@1"&&this.gfx(i.name,e.p);let l={node:i.name,def:i.id,props:o,pos:Ze(e.p)};Object.keys(a).length&&(l.meta=a),e.comments.length&&((l.meta??={}).comment=e.comments);let c=[],u=[],f=[];for(let d of e.children)d.head==="fill"?f.push(d):i.inputs.has(d.head)&&P(i.inputs.get(d.head).type,this.env).t!=="records"||i.records.has(d.head)||(d.head==="each"||d.head==="switch")&&this.recordsInside(d,i)?c.push(d):u.push(d);let p=this.nodes(c,{kind:"use",sig:i},n,r+1),h=new Set(Object.keys(l.props));for(let d of p)if(d.node==="$prop"){for(let[m,g]of Object.entries(d.props??{})){let y=d.pos?{file:this.entry.file,line:d.pos[0],col:d.pos[1]}:e.p;l.props[m]!==void 0&&this.fail(y,`${m} is set twice on ${i.name}: ${h.has(m)?`on the ${i.name} line`:"by an earlier prop line"}, and again by the prop line here. Remove one of them`,"mkp.duplicate-prop"),l.props[m]=g}delete d.pos}else(l.records??=[]).push(d);if(u.length){if(!i.slots.length){let d=u[0],m=[...i.inputs.keys(),...i.records.keys()];this.fail(d.p,`${i.name} has no slot, so lines can't be indented under it, and "${d.head}" is not one of its inputs or records${Ie(d.head,m)}; found "${d.head}" under ${i.name}. Remove the line or move it out from under ${i.name}${i.pack===this.entry.pack?`, or give ${i.name} a slot (in body slot) to hold it`:""}`,"mkp.unknown-prop")}l.children=this.nodes(u,{kind:"view"},n,r+1)}for(let d of f){let m=d.args[0],g=i.slots.length?`its slots are ${i.slots.join(", ")}`:"it has no slots",y=m&&m.value.v==="expr"&&m.value.e.k==="id"?m.value.e.name:this.fail(d.p,`fill takes the name of the ${i.name} slot it fills; found ${m?`fill ${m.value.src}`:"fill with no name"}. ${i.slots.length>1?`Write e.g. fill ${i.slots[1]}`:`${g[0].toUpperCase()}${g.slice(1)}`}`);i.slots.includes(y)||this.fail(d.p,`${i.name} has no slot "${y}"${Ie(y,i.slots)}; ${g}. ${i.slots.length>1?`Write e.g. fill ${ue(y,i.slots.slice(1))??i.slots[1]}`:i.slots.length?`Its one slot takes the lines under ${i.name} directly, with no fill`:"Remove the fill"}`,"mkp.unknown-slot"),y===i.slots[0]&&this.fail(d.p,`${y} is the first slot of ${i.name}, so its lines go straight under ${i.name}, with no fill; found fill ${y}. Remove the fill ${y} line and indent its lines two spaces less`),(l.fills??={})[y]=this.nodes(d.children,{kind:"view"},n,r+1)}for(let[d,m]of i.inputs)m.hasDefault||l.props[d]!==void 0||this.fail(e.p,`${i.name} needs ${d}: ${this.takes(m.type)}. Add it, e.g. ${i.name} ${d}=${this.example(m.type)}`,"mkp.missing-input");if(e.events.length){l.on={};for(let d of e.events)try{if(!i.outs.has(d.name)){let $=[...i.outs.keys()];this.fail(d.p,i.outs.size?`${i.name} raises no "${d.name}" event${Ie(d.name,$)}; it raises ${$.join(", ")}. Write @${ue(d.name,$)??$[0]} \u2026, or remove the @${d.name} line`:`${i.name} raises no events, so @${d.name} can never run. Remove the @${d.name} line, or put it on an element that raises ${d.name}`,"mkp.unknown-event")}let m=n.child(),g=i.outs.get(d.name);g&&m.set(d.name,{type:g,from:"local",kind:"payload"});let y=l.on;this.deferred.push(()=>{y[d.name]=[...y[d.name]??[],...this.actions(d,m)]})}catch(m){this.err(m)}}return l}recordsInside(e,n){return e.children.some(r=>n.records.has(r.head)||(r.head==="each"||r.head==="switch"||r.head==="case"||r.head==="else")&&this.recordsInside(r,n))}resolveDef(e,n){let r=/^(.+?)(?:@(\d+))?$/.exec(e),i=r[1],s=r[2]?Number(r[2]):void 0,o=this.prog.lookupDefs(i,this.entry.pack);if(!o.length){let f=[...this.prog.defs.values()].map(p=>p.syn.name);this.fail(n,`there is no widget or part "${i}"${Ie(i,f)}. Check the spelling, define ${i} first (${i} "what it shows"), or, if a pack provides it, make that pack available (depends in a pack's manifest)`,"mkp.unknown-widget")}let a=new Set(o.map(f=>f.pack));a.size>1&&!i.includes(":")&&(o.filter(p=>p.pack===this.entry.pack).length||this.fail(n,`"${i}" is provided by several packs (${[...a].join(", ")}), so the bare name could mean either. Write it with its pack's name in front: ${[...a].map(p=>`${p}:${i}`).join(" or ")}`,"mkp.ambiguous"));let l=s===void 0?this.opts.locked?.(i):void 0,c=s!==void 0?o.find(f=>f.syn.version===s):l&&o.find(f=>f.id===l)||o[0];if(!c){let f=o.map(p=>p.syn.version).sort((p,h)=>p-h);this.fail(n,`there is no ${i}@${s}; the versions of ${i} are ${f.join(", ")}. Write ${i}@${f[f.length-1]}, or ${i} for the locked one`,"mkp.unknown-version")}let u=this.opts.sigs.get(c.id);return u||(u=Ds(this.prog,c),this.opts.sigs.set(c.id,u)),u.deprecated!==void 0&&u.id!==this.ir.id&&this.diags.warn("mkp.deprecated",`${u.name}@${u.version} is deprecated, and a later version of its pack may remove it: ${u.deprecated}. Move this use as it says (mkp migrate does it when the pack declares how)`,n,[...this.path]),u}fillArgs(e,n,r,i,s,o){let a={},l={},c=(h,d,m)=>{a[h]!==void 0&&this.fail(m,`${h} is set twice on ${s}, and this is the second time. Remove one of them`,"mkp.duplicate-prop"),a[h]=d},u=h=>h.why==="a flag"?`the flag ${h.k}`:h.why==="a token"?`a token for ${h.k}`:`an option of ${h.k}`,f=[];for(let h of e){if(h.key){if(V2.has(h.key)&&!n.has(h.key)){this.meta(h,l,i);continue}let m=n.get(h.key);if(m&&o.has(h.key)&&this.fail(h.p,`${h.key} is a slot of ${s}, filled by the lines indented under it, not by ${h.key}=\u2026; found ${h.key}=${h.value.src}. Remove it and write the content on its own lines under ${s}`,"mkp.unknown-prop"),!m){let g=[...n.keys()].filter($=>!o.has($)),y=g.length>20?`${g.slice(0,20).join(", ")}, \u2026`:g.join(", ");this.fail(h.p,`${s} has no prop "${h.key}"${Ie(h.key,g)}; found ${h.key}=${h.value.src}. ${g.length?`Its props are ${y}; remove ${h.key}=\u2026 or use one of those`:`It takes no props; remove ${h.key}=\u2026`}`,"mkp.unknown-prop")}c(h.key,this.value(h.value,m,i,h.p,!1,h.key),h.p);continue}let d=h.value.v==="expr"&&h.value.e.k==="id"?h.value.e.name:null;if(d){let m=[],g=n.get(d);g&&P(g,this.env).t==="bool"&&m.push({k:d,v:{lit:!0},why:"a flag"});let y=[...n].filter(([k,w])=>{let v=P(w,this.env);return v.t==="choice"&&v.opts.includes(d)&&a[k]===void 0});y.length===1?m.push({k:y[0][0],v:{lit:d},why:`a ${y[0][0]} option`}):y.length>1&&this.fail(h.p,`"${d}" is an option of both ${y.map(k=>k[0]).join(" and ")}, so the bare word could set either. Write it with its prop: ${y.map(k=>`${k[0]}=${d}`).join(" or ")}`,"mkp.ambiguous-arg");let $=[...n].filter(([k,w])=>{let v=P(w,this.env);return v.t==="token"&&a[k]===void 0&&this.opts.tokenNames(v.kind).has(d)});if($.length===1?m.push({k:$[0][0],v:{tok:d,kind:P($[0][1],this.env).kind},why:"a token"}):$.length>1&&this.fail(h.p,`"${d}" is a token that fits both ${$.map(k=>k[0]).join(" and ")}, so the bare word could set either. Write it with its prop: ${$.map(k=>`${k[0]}=${d}`).join(" or ")}`,"mkp.ambiguous-arg"),z2.has(d)&&!n.has(d)){m.length&&this.fail(h.p,`"${d}" could be the ${d} flag (${d==="hidden"?"the element starts hidden":"it takes the free space"}) or ${m.map(u).join(" and ")}, so the bare word is ambiguous. Write ${m.map(k=>`${k.k}=${d}`).join(" or ")} to set ${m.length>1?"one of those":m[0].k}`,"mkp.ambiguous-arg"),d==="hidden"?l.hidden=!0:l.grow=!0;continue}let b=!!i.get(d);if((m.length>1||m.length===1&&b&&m[0].why!=="a flag")&&this.fail(h.p,`"${d}" could be ${[...m.map(u),...b?[`the value of ${d} declared here`]:[]].join(" or ")}, so the bare word is ambiguous. Write it with its key: ${m.map(k=>`${k.k}=${d}`).join(" or ")}`,"mkp.ambiguous-arg"),m.length===1){c(m[0].k,m[0].v,h.p);continue}}f.push(h)}let p=r.filter(h=>a[h]===void 0&&!o.has(h));for(let h of f){let d=p.shift();if(!d){let m=[...n.keys()].filter(y=>!o.has(y)&&a[y]===void 0),g=m.length?`Name it, e.g. ${m[0]}=${h.value.src}`:"Remove it";this.fail(h.p,r.length?`${s} takes ${r.length} value${r.length>1?"s":""} without a name (${r.join(" ")}, in that order), and they are all given; found another, ${h.value.src}. ${g}, or remove it`:`${s} takes no values without a name, only key=value; found ${h.value.src}. ${g}`,"mkp.extra-arg")}c(d,this.value(h.value,n.get(d),i,h.p,!1,d),h.p)}return{props:a,meta:l}}meta(e,n,r){switch(e.key){case"id":{if(e.value.v==="expr"&&e.value.e.k==="id"&&!e.value.src.startsWith("("))n.id=e.value.e.name;else if(e.value.v==="expr"){let i=this.x.coerce(this.x.check(e.value.e,r),E.text,e.p);n.id=this.irExpr(i,e.value.src,e.p)}else this.fail(e.p,`id takes a name (id=box) or an expression in brackets (id=("box" + k)); found id=${e.value.src}. Write e.g. id=box`);break}case"if":{e.value.v!=="expr"&&this.fail(e.p,`if= takes a true-or-false expression in brackets; found if=${e.value.src}. Write e.g. if=(n > 1)`);let i=this.x.check(e.value.e,r,E.bool);P(i.type,this.env).t!=="bool"&&this.fail(e.p,`if= needs true or false; found ${e.value.src}, which gives ${N(i.type)}. Write a comparison, e.g. if=(n > 1)`),n.if=this.irExpr(i,e.value.src,e.p);break}case"basis":n.basis=this.value(e.value,{t:"token",kind:"size"},r,e.p,!1,"basis").tok;break;case"span":n.span=this.value(e.value,{t:"int",lo:1,hi:64},r,e.p,!1,"span");break;case"self":{let i=this.value(e.value,W2,r,e.p,!1,"self");"lit"in i||this.fail(e.p,`self is fixed when the widget is built, so it takes one of start, center, end or stretch written as a word, not worked out; found self=${e.value.src}. Write one word, e.g. self=start, or use two elements, each with its own if=(\u2026)`,"mkp.enum"),n.self=i.lit;break}case"keep":n.keep=this.value(e.value,E.bool,r,e.p,!1,"keep");break;case"minwidth":case"minheight":case"aspect":{let i=sn(e.key,e.value.src);i===void 0&&this.fail(e.p,`${e.key} takes ${vo(e.key)}, written as it is (a first paint reads it before anything runs); found ${e.key}=${e.value.src}. Write e.g. ${e.key==="aspect"?"aspect=16/9":`${e.key}=320`}`,"mkp.size"),n[e.key]=i;break}}}checkSizes(){if(this.entry.syn.kind==="part"||this.entry.pack==="core")return;let e=this.entry.syn.members.filter(r=>r.m==="in"&&Wr(r.name)&&r.def?.v==="expr"&&sn(r.name,r.def.src)!==void 0),n=this.entry.syn.name;if(e.length===3&&this.fail(e[2].p,`${n} gives itself minwidth, minheight and aspect, which can disagree: two of them fix its size before it is drawn. Remove one default, e.g. keep minheight and aspect`,"mkp.size"),e.length===1){let r=e[0].name,i=Ft.filter(s=>s!==r).join(" or ");this.diags.warn("mkp.size",`${n} gives itself ${r} alone, so its box before it is drawn is ${r==="minwidth"?"only as wide as that, with a height guessed":r==="minheight"?"that tall, as wide as the column":"that shape, as wide as the column"}, and may move once when drawn. Give ${i} a default as well, so its box is fixed; a use can still give its own`,e[0].p,[...this.path])}}each(e,n,r,i){let s=e.args,o=s[0],a=s[1],l=s[2];if(!o||o.value.v!=="expr"||o.value.e.k!=="id"||!a||a.value.v!=="expr"||a.value.e.k!=="id"||a.value.e.name!=="in"||!l){let g=s.map(y=>y.key?`${y.key}=${y.value.src}`:y.value.src).join(" ");this.fail(e.p,`each is written each x in list key=\u2026 or each x in lo..hi, naming the loop variable before in; found each${g?` ${g}`:""}. Write e.g. each name in names key=name`)}let c=o.value.e.name;this.shadow(c,o.p);let u,f;if(l.value.v==="range"){let g=this.x.coerce(this.x.check(l.value.lo,r),E.num,l.p),y=this.x.coerce(this.x.check(l.value.hi,r),E.num,l.p);u=P(g.type,this.env).t==="int"?E.int:E.num,f={range:[this.constOrExpr(g,l.value.loSrc,l.p),this.constOrExpr(y,l.value.hiSrc,l.p)]}}else if(l.value.v==="expr"){let g=this.x.check(l.value.e,r),y=P(g.type,this.env);y.t==="records"?u={t:"rec",fields:y.slot?[...y.fields,["slot",E.slot]]:y.fields}:y.t!=="list"?this.fail(l.p,`each needs a list or a range to go through; found ${l.value.src}, which is ${N(g.type)}. Loop over a list (each x in items key=x) or a range (each k in 0..(n - 1))`):u=y.of,f=this.irExpr(g,l.value.src,l.p)}else this.fail(l.p,`each needs a list or a range to go through; found ${l.value.src}, a duration. Loop over a list (each x in items key=x) or a range (each k in 0..(n - 1))`);let p=r.child();p.set(c,{type:u,from:"local",kind:"each"});let h={node:"each",var:c,in:f,pos:Ze(e.p)},d=l.value.v==="range";for(let g of s.slice(3))g.key==="key"&&g.value.v==="expr"?(h.key=this.irExpr(this.x.check(g.value.e,p),g.value.src,g.p),d=!0):this.fail(g.p,`each takes only key=\u2026 after its list; found ${g.key?`${g.key}=${g.value.src}`:g.value.src}. Remove it, or write key=(\u2026) with a value unique to each item`);if(!d){let g=P(u,this.env),y=g.t==="rec"&&g.fields.length?`${c}.${g.fields[0][0]}`:c;this.diags.warn("mkp.each-unkeyed",`each over ${l.value.src} has no key=, so it tells items apart by position and they lose their state when the list changes. Add key= with a value unique to each ${c}, e.g. each ${c} in ${l.value.src} key=${y}`,e.p,[...this.path])}e.events.length&&this.fail(e.events[0].p,`each can't take events; found @${e.events[0].name} under each. Move the @${e.events[0].name} line under the element inside the each that should react`);let m=this.nodes(e.children,n,p,i);return this.placeChildren(h,m,"each",e.p),h}placeChildren(e,n,r,i){for(let s of n)if(s.node==="$record"||(s.node==="each"||s.node==="switch")&&s.records)(e.records??=[]).push(s);else if(s.node==="$prop"){let o=Object.keys(s.props??{})[0]??String(s.record),a=s.pos?{file:this.entry.file,line:s.pos[0],col:s.pos[1]}:i,l=r==="each"?"which would set it once per item":`which would set it only in that ${r}`;this.fail(a,`the prop line "${o}" sits under ${r}, ${l}, but a prop is set once. Move it out from under the ${r}, onto the widget, and choose its value there with if(\u2026), e.g. ${o}=(if(\u2026, a, b))`)}else(e.children??=[]).push(s)}switch(e,n,r,i){let s=e.args.find(u=>u.key==="on");if(!s||s.value.v!=="expr"||e.args.length!==1){let u=e.args.map(f=>f.key?`${f.key}=${f.value.src}`:f.value.src).join(" ");this.fail(e.p,`switch is written switch on=<value>, with nothing else on the line; found switch${u?` ${u}`:""}. Write e.g. switch on=${e.args.find(f=>!f.key)?.value.src??"n"}`)}let o=this.x.check(s.value.e,r),a={node:"switch",subject:this.irExpr(o,s.value.src,s.p),cases:[],pos:Ze(e.p)},l=new Map,c=0;for(let u of e.children)try{if(u.head==="case"){u.args.length!==1&&this.fail(u.p,`case takes one value; found case ${u.args.map(m=>m.value.src).join(" ")||"with no value"}. Write one case line per value, e.g. case ${u.args[0]?.value.src??"1"}, then case ${u.args[1]?.value.src??"2"} on its own line`);let f=this.value(u.args[0].value,o.type,r,u.args[0].p),p=JSON.stringify(f);l.has(p)?this.diags.warn("mkp.case-unreachable",`case ${u.args[0].value.src} repeats the case on line ${l.get(p)}, so it can never be chosen. Change its value or remove it`,u.p,[...this.path]):l.set(p,u.p.line);let h=P(o.type,this.env);h.t==="int"&&h.lo!==void 0&&"lit"in f&&typeof f.lit=="number"&&(f.lit<h.lo||f.lit>h.hi)&&this.diags.warn("mkp.case-unreachable",`case ${f.lit} can't happen: the switch's value ${s.value.src} is ${this.takes(o.type)}. Change the case to a value in that range, or remove it`,u.p,[...this.path]);let d={node:"case"};this.placeChildren(d,this.nodes(u.children,n,r,i),"case",u.p),a.cases.push({value:f,children:[...d.children??[],...d.records??[]]}),d.records&&(a.records=[])}else if(u.head==="else"){a.else&&this.fail(u.p,`switch may have one else, and this is a second (the first is on line ${c}). Merge the two, or remove this one`),c=u.p.line;let f={node:"else"};this.placeChildren(f,this.nodes(u.children,n,r,i),"else",u.p),a.else=[...f.children??[],...f.records??[]],f.records&&(a.records=[])}else this.fail(u.p,`under switch, only case and else lines may go; found "${u.head}". Put it under a case or else, or move it out from under the switch`)}catch(f){this.err(f)}return a}arrow(e,n){let r={node:"arrow",pos:Ze(e.p)};for(let i of e.args)if(i.key==="from"||i.key==="to")r[i.key]=this.idValue(i,n);else if(!i.key&&i.value.v==="expr"&&i.value.e.k==="id"&&i.value.e.name==="curve")r.curve=!0;else if(!i.key&&i.value.v==="expr"&&i.value.e.k!=="id")r.label=this.value(i.value,E.text,n,i.p);else if(i.key==="label")r.label=this.value(i.value,E.text,n,i.p,!1,"label");else if(i.key==="via")r.via=this.value(i.value,E.list(E.text),n,i.p,!1,"via");else if(i.key==="route")r.route=this.value(i.value,{t:"choice",opts:["down","right"]},n,i.p,!1,"route");else if(i.key&&Oa[i.key])(r.look??={})[i.key]=this.value(i.value,Oa[i.key],n,i.p,!1,i.key);else if(i.key==="if"){let s={};this.meta(i,s,n),r.meta=s}else{let s=["from","to","label","via","route","if",...Object.keys(Oa)],o=!i.key&&i.value.v==="expr"&&i.value.e.k==="id"?i.value.e.name:void 0,a=o?Object.entries(Oa).find(([,u])=>u.t==="choice"&&u.opts.includes(o))?.[0]:void 0,l=i.key?["colour","color"].includes(i.key)?"tone":ue(i.key,s):void 0,c=a?`Write ${a}=${o}`:l?`Write ${l}=${i.value.src}`:"Remove it or use one of those";this.fail(i.p,`arrow has no ${i.key?`prop "${i.key}"`:`setting "${i.value.src}"`}; found ${i.key?`${i.key}=${i.value.src}`:i.value.src}. It takes from=id to=id, an optional "label", via=(ids), route=down|right, curve, tone=, line=, head=, tail=, dim=, bold=, layer=, opacity=, corner=, lanes= and hop=. ${c}`,"mkp.unknown-prop")}if(!r.from||!r.to){let i=[r.from?"":"from=",r.to?"":"to="].filter(Boolean).join(" and ");this.fail(e.p,`arrow needs from= and to=, the ids of the two elements it joins; found no ${i}. Add ${i.replace(/=/g,"=<id>")}, e.g. arrow from=a to=b`)}return r}idValue(e,n){if(e.value.v==="expr"&&e.value.e.k==="id")return{lit:e.value.e.name};e.value.v!=="expr"&&this.fail(e.p,`${e.key??"an id"}= takes an element's id: a name (${e.key}=box) or an expression in brackets (${e.key}=("box" + k)); found ${e.key}=${e.value.src}. Write e.g. ${e.key}=box`);let r=this.x.coerce(this.x.check(e.value.e,n),E.text,e.p);return this.irExpr(r,e.value.src,e.p)}runDeferred(){for(let e of this.deferred.splice(0))try{e()}catch(n){this.err(n)}}actions(e,n){let r=e.actions.flatMap(s=>this.action(s,n));if(!e.cond)return r;e.cond.v!=="expr"&&this.fail(e.cond.p,`if= on an event line takes a true-or-false expression in brackets; found if=${e.cond.src}. Write e.g. if=(n > 1)`);let i=this.x.check(e.cond.e,n,E.bool);return P(i.type,this.env).t!=="bool"&&this.fail(e.cond.p,`if= on an event line needs true or false; found ${e.cond.src}, which gives ${N(i.type)}. Write a comparison, e.g. if=(n > 1)`),[{a:"when",cond:this.irExpr(i,e.cond.src,e.cond.p),actions:r}]}action(e,n){try{let r=this.action1(e,n);return Array.isArray(r)?r:[r]}catch(r){return this.err(r),[]}}action1(e,n){let r=[...this.controlNames].filter(([,o])=>o==="slider"||o==="steps"||o==="clock").map(([o])=>o),i={reset:[...this.stateNames.keys()][0],play:r[0],pause:r[0],emit:[...this.outs.keys()][0],send:[...this.signals.keys()][0]},s=o=>o.value.v==="expr"&&o.value.e.k==="id"&&!o.key?o.value.e.name:this.fail(o.p,`${e.name} takes bare names here; found ${o.key?`${o.key}=${o.value.src}`:o.value.src}. Write e.g. ${e.name} ${i[e.name]??"name"}`);switch(e.name){case"set":{if(!e.args.length||e.args.some(o=>!o.key)){let a=e.args.find(l=>!l.key)?.value.src??[...this.stateNames.keys()][0]??"n";this.fail(e.p,`set takes name=value pairs; found set${e.args.length?` ${e.args.map(l=>l.key?`${l.key}=${l.value.src}`:l.value.src).join(" ")}`:" with nothing after it"}. Write e.g. set ${a}=(${a} + 1)`)}return e.args.map(o=>this.setOne(o,n))}case"play":case"pause":{let o=`Write e.g. ${e.name} ${r[0]??"level"}${r.length>1?`, and ${e.name} ${r[1]} as another action`:""}`;e.args.length!==1&&this.fail(e.p,`${e.name} takes exactly one slider, steps or clock name; found ${e.args.length?`${e.name} ${e.args.map(c=>c.value.src).join(" ")}`:"none"}. ${o}`,"mkp.extra-arg");let a=s(e.args[0]??this.fail(e.p,`${e.name} takes the name of a slider, steps or clock; found none. ${o}`)),l=this.controlNames.get(a);if(l!=="slider"&&l!=="steps"&&l!=="clock"){let c=this.scope.get(a),u=l?`a ${l}`:c?c.kind==="input"?"an input":`a ${c.kind}`:"not declared here";this.fail(e.p,`"${a}" is ${u}, not a slider, steps or clock of ${this.label}, so it can't ${e.name}; ${r.length?`its playable controls are ${r.join(", ")}. Write e.g. ${e.name} ${ue(a,r)??r[0]}`:'it has none. Declare one, e.g. t = slider 0..1 play=4s "turn"'}`,"mkp.not-playable")}return{a:e.name,name:a}}case"reset":{let o=e.args.map(s);for(let a of o){if(this.stateNames.has(a))continue;let l=[...this.stateNames.keys()];this.fail(e.p,`reset puts a control, var or ref input back to its start, and "${a}" is none of these in ${this.label}${Ie(a,l)}. ${l.length?`Write e.g. reset ${ue(a,l)??l[0]}`:"Declare one first, e.g. var n int = 0"}`,"mkp.not-state")}return{a:"reset",names:o}}case"reveal":case"hide":case"open":case"close":{let o=e.args[0];if(!o||e.args.length>1){let l=[...this.staticIds.keys()];this.fail(e.p,o?`${e.name} takes one id; found ${e.name} ${e.args.map(c=>c.value.src).join(" ")}. Write one action per id, e.g. ${e.name} ${e.args[0].value.src} ${e.name} ${e.args[1].value.src}`:`${e.name} needs the id of the element to ${e.name}; found ${e.name} with nothing after it. Write ${e.name} <id>, e.g. ${e.name} ${l[0]??"help"} (each action takes its own id: reveal a hide b)`)}if(o.value.v==="expr"&&o.value.e.k==="id"&&!o.key){let l=o.value.e.name,c=this.staticIds.get(l);if(!c){let u=[...this.staticIds.keys()];this.fail(o.p,`there is no element with id=${l} in ${this.label}${Ie(l,u)}; ${u.length?`its ids are ${u.join(", ")}`:"no element in it has an id"}. Add id=${l} to the element to ${e.name}, or name one that exists`,"mkp.unknown-id")}return(e.name==="open"||e.name==="close")&&!c.overlay&&this.fail(o.p,`${l} is not an overlay, so ${e.name} can't ${e.name} it; found ${e.name} ${l}. Use ${e.name==="open"?"reveal":"hide"} ${l} for a plain element${e.name==="open"?" (with hidden on it, so it starts hidden)":""}, or make ${l} an overlay`,"mkp.not-overlay"),(e.name==="reveal"||e.name==="hide")&&!c.hidden&&e.name==="reveal"&&this.diags.warn("mkp.reveal-visible",`${l} is not hidden, so reveal ${l} does nothing. Add hidden to the element with id=${l} (line ${c.p.line}) so it starts hidden, or remove reveal ${l}`,o.p,[...this.path]),{a:e.name,id:l}}let a=this.x.coerce(this.x.check(o.value.e,n),E.text,o.p);return{a:e.name,id:this.irExpr(a,o.value.src,o.p)}}case"emit":case"send":{let o=e.name==="emit",a=[...(o?this.outs:this.signals).keys()],l=o?"out":"signal",c=s(e.args[0]??this.fail(e.p,`${e.name} takes the name of ${o?"an out (an event for the widget using this one)":"a signal (a message to the host)"} of ${this.label}; found ${e.name} with nothing after it. ${a.length?`Write e.g. ${e.name} ${a[0]}`:`Declare one first, e.g. ${l} done {score: int}`}`)),u=o?this.outs.get(c):this.signals.get(c);if(o&&!this.outs.has(c)||!o&&!u){let h=a.length?`; its ${l}s are ${a.join(", ")}`:"";this.fail(e.p,`${this.label} declares no ${l} "${c}"${Ie(c,a)}${h}. Declare it under the ${this.label} line (${l} ${c}${o?"":" {field: type}"})${a.length?` or ${e.name} one that exists`:""}`,o?"mkp.unknown-out":"mkp.unknown-signal")}let f=u?P(u,this.env).fields:[],p=[];for(let h of e.args.slice(1)){(!h.key||h.value.v!=="expr")&&this.fail(h.p,`${e.name} ${c} takes its fields as field=value; found ${h.key?`${h.key}=${h.value.src}`:h.value.src}. Write e.g. ${h.key??h.value.src}=${h.key?"(\u2026)":"true"}`);let d=f.find(g=>g[0]===h.key);if(!d){let g=f.map(([y])=>y);this.fail(h.p,`${c} has no field "${h.key}"${Ie(h.key,g)}; ${g.length?`its fields are ${g.join(", ")}. Remove ${h.key}=\u2026 or use one of those`:`it carries no fields. Remove ${h.key}=\u2026`}`,"mkp.unknown-field")}let m=this.x.coerce(this.x.check(h.value.e,n,d[1]),d[1],h.p);p.push([h.key,this.irExpr(m,h.value.src,h.p)])}for(let[h,d]of f)p.some(m=>m[0]===h)||this.fail(e.p,`${e.name} ${c} must give every field of ${c}, and ${h}, ${this.takes(d)}, is missing. Add ${h}=\u2026, e.g. ${e.name} ${c} ${f.map(([m,g])=>`${m}=${p.find(y=>y[0]===m)?.[1].expr??this.example(g)}`).join(" ")}`,"mkp.missing-field");return{a:e.name,name:c,payload:p}}}return this.fail(e.p,`"${e.name}" is not an action; the actions are set, play, pause, reset, reveal, hide, open, close, emit and send${Ie(e.name,["set","play","pause","reset","reveal","hide","open","close","emit","send"])}`)}setOne(e,n){let r=this.stateNames.get(e.key);if(!r){let o=this.scope.get(e.key),a=[...this.stateNames.keys()],l=o?`is ${o.kind==="input"?"an input":`a ${o.kind}`} of ${this.label}, which set can't change`:`is not declared in ${this.label}${Ie(e.key,a)}`;this.fail(e.p,`set changes a var, control or ref input, and "${e.key}" ${l}. ${o?`Declare a var to change instead (var ${e.key}2 ${N(o.type)} = \u2026)`:`Declare it (var ${e.key} int = 0)`}${a.length?` or set one that exists: ${a.join(", ")}`:""}`,"mkp.not-state")}e.value.v!=="expr"&&this.fail(e.p,`set ${e.key}= takes one value or expression; found ${e.key}=${e.value.src}${e.value.v==="range"?", a range":", a duration"}. Write e.g. set ${e.key}=${this.example(r.type)}`);let i=this.x.coerce(this.x.check(e.value.e,n,r.type),r.type,e.p),s=this.scope.get(e.key)?.kind;return{a:"set",name:e.key,target:s==="ref"?"ref":s==="var"?"var":"state",value:this.irExpr(i,e.value.src,e.p)}}},vg=new Set(["none","true","false","pi","tau","inf","nan"]);function oi(t,e){if(nn(t))return!0;switch(t.t){case"named":return e.includes(t.name);case"list":case"dict":case"ref":return oi(t.of,e);case"rec":case"records":return t.fields.some(([,n])=>oi(n,e));case"path":return oi(t.of,e)||oi(t.to,e);default:return!1}}function hf(t){switch(t.t){case"num":case"bool":case"str":return t.v;case"builtin":return t.fn==="neg"&&t.args[0].t==="num"?-t.args[0].v:void 0;case"list":{let e=t.items.map(hf);return e.every(n=>n!==void 0)?e:void 0}case"rec":{let e={};for(let[n,r]of t.fields){let i=hf(r);if(i===void 0)return;e[n]=i}return e}default:return}}function K2(t,e){return P(t,e).t}function Ze(t){return[t.line,t.col]}function Ts(t){return t.length?t:void 0}function $r(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function xg(t){return En(t)}function df(t,e){switch(t.t){case"var":{if(t.from==="const")return!0;let n=e.get(t.name);return!!n&&(n.kind==="input"||n.kind==="const")}case"num":case"bool":case"str":case"dict0":case"fnref":return!0;case"lam":return!1;default:{for(let n of Object.values(t))if(n&&typeof n=="object"){if(Array.isArray(n)){for(let r of n)if(r&&typeof r=="object"&&"t"in r&&!df(r,e))return!1}else if("t"in n&&!df(n,e))return!1}return!0}}}function Y2(t,e,n){try{return De(t.ast)(new zr(null,null,null,{}))}catch{let r=e.lastIndexOf("."),i=e.slice(r+1),s=r>0?e.slice(0,r):"the block";throw new K("mkp.missing-field",`${e} is left out, and its default ${t.expr} is a calculation that YAML data can't work out. Write ${i} yourself in ${s}, e.g. {\u2026, ${i}: 4}, or make the default a plain value in the type`,n)}}function Jn(t){if(t==null)return"nothing";let e=typeof t=="string"?JSON.stringify(t):Array.isArray(t)||typeof t=="object"?JSON.stringify(t).replace(/"([A-Za-z_][\w]*)":/g,"$1: "):String(t);return e.length>60?e.slice(0,57)+"\u2026":e}function li(t){return t==null?"nothing":Array.isArray(t)?"a list":typeof t=="object"?"a mapping":typeof t=="string"?`the text ${Jn(t)}`:typeof t=="boolean"?`${t}`:`the number ${t}`}function Ns(t,e=12){let n=[...t];return n.length>e?n.slice(0,e).join(", ")+", \u2026":n.join(", ")}function ct(t,e){let n=P(t,e);switch(n.t){case"num":case"int":{let r=n.t==="int"?"a whole number":"a number";return n.lo!==void 0&&n.hi!==void 0?`${r} from ${n.lo} to ${n.hi}`:r}case"bool":return"true or false";case"text":return"text";case"latex":return"maths";case"choice":return`one of ${n.opts.join(", ")}`;case"token":return`a ${n.kind} token`;case"point":return"a point [x, y]";case"duration":return"a duration such as 6s";case"range":return"a range [a, b]";case"slot":return"Markdown";case"list":return`a list of ${ct(n.of,e).replace(/^an? /,"")}`;case"ref":return`a reference to ${ct(n.of,e).replace(/^an? /,"")} state`;case"records":return`a list of ${n.kind} records`;case"rec":return n.name?`a ${n.name}`:`a record {${n.fields.map(r=>r[0]).join(", ")}}`;default:return N(t)}}function mt(t,e,n,r=!1,i=0){let s=P(t,e);switch(s.t){case"num":case"int":return String(s.lo??1);case"bool":return"true";case"text":return r?'"Some text"':"Some text";case"latex":return"'$x^2$'";case"choice":return s.opts[0];case"token":return[...n(s.kind)][0]??"none";case"point":return"[0, 1]";case"duration":return"6s";case"range":return"[0, 10]";case"slot":return r?'"Some words."':"Some words.";case"records":case"rec":{if(i>1)return"{\u2026}";let o=s.fields.filter(([l])=>s.defaults?.[l]===void 0),a=`{${(o.length?o:s.fields).map(([l,c])=>`${l}: ${mt(c,e,n,!1,i+1)}`).join(", ")}}`;return s.t==="records"?`[${a}]`:a}case"list":return i>1?"[\u2026]":`[${mt(s.of,e,n,!1,i+1)}]`;case"ref":return"{ref: name}";default:return"\u2026"}}function Yn(t,e){return/[.[]/.test(t)?e:`${t}: ${e}`}function Ag(t,e){let n=P(t,e);return n.t==="bool"?"toggle":n.t==="choice"?`choice(${n.opts.join("|")})`:n.t==="num"||n.t==="int"?`slider ${n.lo??0}..${n.hi??10}`:"slider 0..10"}function Tg(t,e,n,r,i){let s=t,a=String(s.message??t).split(`
471
+ `)[0].replace(/ at line \d+, column \d+:?$/,""),l=e.split(`
472
+ `),c=s.linePos?.[0]?.line??1,u=s.linePos?.[0]?.col??1,f=m=>l[m-1]??"",p=()=>f(c).trim(),h=m=>/^\s*(?:-\s+)?([^\s:#'"][^:]*?|"[^"]*"|'[^']*'):(?:\s|$)/.exec(m)?.[1],d;if(s.code==="BLOCK_AS_IMPLICIT_KEY"&&/Nested mappings/.test(a)){let m=f(c),g=h(m),y=m.slice(u-1).trim();g&&/:(\s|$)/.test(y)?d=`${i} has a value with ": " (a colon and a space) in it, which YAML reads as a second key; found ${g}: ${y}. Quote the value: ${g}: "${y.replace(/"/g,'\\"')}"`:d=`${i} has a line indented under ${g??"a key"}: ${y}, which YAML reads as a nested key inside that value. Indent it like the lines around it, or quote the value if the colon is part of the text`}else if(s.code==="BLOCK_AS_IMPLICIT_KEY")d=`${i} has a list item where YAML expects key: value; found ${p()}. Indent the item under the key it belongs to, e.g. items: and then ${p()} on the next line`;else if(s.code==="DUPLICATE_KEY"){let m=/^["']?([^:"',}\s]+)/.exec(f(c).slice(u-1))?.[1]??"a key";d=`${i} gives ${m} twice, and each key may appear once; found a second ${m}: here. Remove one of them, or rename it`}else if(s.code==="MISSING_CHAR"&&/^Missing closing ["']quote/.test(a)){let m=a.includes('"')?'"':"'";for(let g=1;g<=Math.min(c,l.length);g++)if((m==='"'?(f(g).match(/(?<!\\)"/g)??[]).length:(f(g).replace(/''/g,"").match(/'/g)??[]).length)%2){c=g,u=f(g).indexOf(m)+1;break}d=`${i} has a value that opens with ${m} but never closes it; found ${p()}. Add the closing ${m} at the end of the value, e.g. ${p()}${m}`}else if(s.code==="BAD_INDENT"&&/^Flow (sequence|map)/.test(a)){let m=a.startsWith("Flow sequence")?"[":"{",g=m==="["?"]":"}";for(let y=c-1;y>=1;y--)if(f(y).includes(m)){c=y,u=f(y).indexOf(m)+1;break}d=`${i} opens a ${m==="["?"list":"mapping"} with ${m} that is never closed; found ${p()}. Close it with ${g} on the same line, e.g. ${p()}${g}`}else if(s.code==="BAD_INDENT")d=`${i} has a line indented differently from the ${/sequence/.test(a)?"list items":"keys"} around it; found ${p()}. Line it up with the others, using the same number of spaces`;else if(s.code==="BAD_DQ_ESCAPE"){let m=/sequence (\S+)/.exec(a)?.[1]??"a backslash",g=f(c).trim().replace(/"((?:[^"\\]|\\.)*)"/,(y,$)=>`'${$.replace(/'/g,"''")}'`);d=`${i} has ${m} inside "double quotes", where a backslash starts an escape and ${m} is not one. Write LaTeX in 'single quotes': ${g}`}else if(s.code==="TAB_AS_INDENT")d=`${i} indents a line with a tab; found a tab before ${f(c).trim()||"an empty line"}. Replace the tab with spaces: YAML indents with spaces only`;else if(s.code==="BAD_SCALAR_START"){let m=f(c),g=m.slice(u-1).trim(),y=h(m);d=`${i} has a value starting with ${g[0]}, which YAML reserves; found ${g}. Quote it: ${y?`${y}: `:""}'${g.replace(/'/g,"''")}'`}else if(s.code==="MULTILINE_IMPLICIT_KEY"||/^Implicit map keys need/.test(a))d=`${i} has a line that is not key: value; found ${p()}. Write it as key: value, or indent it under the key above if it continues that value`;else if(s.code==="UNEXPECTED_TOKEN"&&/at node end/.test(a)){let m=f(c).slice(u-1).trim();d=`${i} has text after a value has ended; found ${m} after ${f(c).slice(0,u-1).trim()}. Remove it, or quote the whole value`}else if(s.code==="MISSING_CHAR"&&/^Missing ,/.test(a))d=`${i} has two items in [ \u2026 ] or { \u2026 } with no comma between them; found ${p()}. Add a comma between the items, or quote an item that holds a colon`;else if(s.code==="MISSING_CHAR"&&/^Comments must be separated/.test(a))d=`${i} has a # straight after other text; found ${p()}. Quote the value if # is part of it, or put a space before the # of a comment`;else if(/^Unresolved alias/.test(a)){let m=/: (\S+)$/.exec(a)?.[1]??"",g=l.findIndex(y=>y.includes("*"+m));g>=0&&(c=g+1,u=l[g].indexOf("*"+m)+1),d=`${i} has *${m}, which YAML reads as a reference to an anchor &${m} that isn't set. Quote the value if it is text, e.g. '*${m}'`}else d=`${i} is not valid YAML here: ${a.replace(/\.$/,"")}; found ${p()||"an empty line"}. Check the quoting on this line: quote a value that holds : # [ ] { } or starts with a special character`;return{message:d,pos:{file:r,line:n+c-1,col:u}}}var Qe="$doc",Dg=800;function Ng(t){let e=[];for(let n of t)n.k==="defs"&&e.push(n),n.k==="container"&&e.push(...Ng(n.items));return e}var J2=new Set(["document"]);function Z2(t,e,n,r,i,s){let o=Ng(e.items);if(!o.length&&!s.docFile)return{prog:t,defs:[],sigs:s.sigs};let a=[],l=0;if(o.length){let y=n.split(`
473
+ `).length,$=Array.from({length:y},()=>"");for(let b of o){let k=b.body.split(`
474
+ `);k.forEach((w,v)=>$[b.line+v]=w),l+=k.filter(w=>w.trim()).length}a.push(_n($.join(`
475
+ `),r,i,{inline:!0}))}s.docFile&&(a.push(_n(s.docFile.text,s.docFile.file,i,{inline:!0})),l+=s.docFile.text.split(`
476
+ `).filter(y=>y.trim()).length);let c=y=>y??{file:r,line:o[0]?.line??1,col:1};if(l>Dg){let y=[o.length?"its mkp fences":"",s.docFile?s.docFile.file.split("/").pop():""].filter(Boolean).join(" and ");i.error("mkp.doc-size",`the document's own definitions (${y}, blank lines not counted) are ${l} lines, over the limit of ${Dg}. Move the larger definitions into a pack and use them from there, or shorten them`,c())}let u=new Set;for(let y of a){y.items=y.items.filter($=>{if($.item==="def"||$.item==="type"||$.item==="fn"||$.item==="op"||$.item==="const")return!0;let b=$.item==="manifest"?"a manifest":$.item==="tokens"?"a tokens set":$.item==="macro"?"a maths macro":"an interface",k=$.name;return i.error("mkp.doc-item",`a document's mkp fence may define widgets, parts, types, fns and consts, but not ${b}; found ${$.item}${k?" "+k:""}. Move it into a pack, or Remove it from the fence`,c($.p)),!1});for(let $ of y.items){let b="symbol"in $?$.symbol:$.name;if($.item!=="op"&&u.add(b),$.item!=="def"&&$.item!=="type")continue;if(J2.has(b)){i.error("mkp.shadow",`the name "${b}" is reserved for the document itself, so this ${$.item==="type"?"type":"definition"} can't use it. Rename it, e.g. my_${b}, and use the new name in its blocks too`,$.p);continue}let k=$.item==="def"?t.lookupDefs(b,Qe)[0]:t.lookupType(b,Qe);if(k){let w=$.item==="def",v=w?"widget":"type",D=k.pack==="core"?`a base ${v}`:`a ${v} of the pack ${k.pack}`,I=w?`; to change the existing one, copy it under a new name with mkp show ${b} --source --as my_${b}`:"";i.error("mkp.shadow",`${b} is already ${D}, so this ${v} needs a name of its own. Rename it, e.g. my_${b}${I}`,$.p)}}}let f={name:Qe,version:1,kind:"pack",requires:["core@1"],depends:[],provides:u,manifest:{item:"manifest",kind:"pack",name:Qe,version:1,requires:["core@1"],depends:[],provides:[...u],front:[],attrs:[],roles:[],rules:[],p:{file:r,line:1,col:1},comments:[]},files:a,fixtures:[],assets:new Map,documents:[],digest:""},p=t.overlay(i);p.addPack(f);let h=new Map(s.sigs),d=[...p.defs.values()].filter(y=>y.pack===Qe);for(let y of d)h.set(y.id,Ds(p,y));let m=[],g=[];for(let y of d){let $=new un(p,y,i,{...s,sigs:h});try{let b=$.check();b.inline=!0;let k=b.inputs.some(w=>w.type.t==="slot"||w.type.t==="records"&&w.type.slot);if(y.syn.kind==="widget"&&!b.project?.md&&!k){let w=b.inputs.find(v=>v.type.t==="text")?.name??'"what it shows"';i.error("mkp.no-project",`${y.syn.name} has no project md line, which every widget defined in a document needs: it is the Markdown readers without MKP see in its place. Add one at the end of the definition, e.g. project md = ${w}`,y.syn.p)}m.push(b),g.push($)}catch(b){$.err(b)}}for(let y of g)y.runDeferred();return{prog:p,defs:m,sigs:h}}function Cs(t,e,n,r,i){let s=Io(e,n,r);i.privateOf&&(t=t.overlay(r),t.privateFor=i.privateOf);let o=Z2(t,s,e,n,r,i),a=o.prog;i={...i,sigs:o.sigs};let l=[],c=k=>{for(let w of k)w.k==="state"&&l.push({line:w.line,body:w.body}),w.k==="container"&&c(w.items)};c(s.items);let u=['document@1 "the document"'];for(let k of l){for(;u.length<k.line;)u.push("");for(let w of k.body.split(`
477
+ `))u.push(w.trim()?" "+w:"")}let p=_n(u.join(`
478
+ `),n,r).items[0]??{item:"def",kind:"widget",name:"document",version:1,members:[],p:{file:n,line:1,col:1},comments:[]};for(let k of p.members)if(k.m!=="state"&&k.m!=="var"){let w=k.m==="node"?k.node.p:k.p,v=k.m==="node"?"a widget line":k.m==="derived"?"a derived value":k.m==="fn"?"a fn":k.m==="in"?"an input":k.m==="project"?"a project line":`a ${k.m} line`,D=(u[w.line-1]??"").trim();r.error("mkp.doc-state",`a state block holds only var lines and state lines, name = control (slider, toggle, choice, steps, drag or clock), e.g. n = slider 0..10 "how many"; found ${v}${D?`, ${D}`:""}. Move it out of the state block, or Remove it`,w)}p.members=p.members.filter(k=>k.m==="state"||k.m==="var");let h={id:`${Qe}:document@1`,pack:Qe,file:n,syn:p},d=new un(a,h,r,i),m=d.check(),g=new yf(a,d,r,n);g.declaredState=l.flatMap(k=>Cg(k.body));let y=g.items(s.items,!0);d.runDeferred(),Q2(y,n,r);let $=s.front!==null?Na(s.front):new Map,b=k=>{let w=$.get(k);return w?{file:n,line:s.frontLine+w.line-1,col:w.col}:void 0};return{file:n,front:g.front(s),body:y,def:m,uses:d.uses,prog:a,defs:o.defs,frontAt:b}}function Q2(t,e,n){let r=new Map,i=s=>{for(let o of s){let a=o.meta?.anchor,l=o.pos?.[0]??1;if(a){let c=r.get(a);c===void 0?r.set(a,l):n.error("mkp.duplicate-anchor",`#${a} is already the anchor of the block on line ${c}, and an anchor names one block only; found {#${a}} again here. Rename this one, e.g. {#${a}-2}`,{file:e,line:l,col:o.pos?.[1]??1})}i(o.children??[]);for(let c of Object.values(o.fills??{}))i(c)}};i(t)}function Cg(t){return t.split(`
479
+ `).map(e=>/^\s*(?:var\s+)?([A-Za-z_][A-Za-z0-9_]*)\s+(?:=|[a-z(])/.exec(e)?.[1]).filter(e=>!!e)}var yf=class{constructor(e,n,r,i){this.prog=e;this.dc=n;this.diags=r;this.file=i}yamlAt=null;declaredState=[];p(e,n=1){return{file:this.file,line:e,col:n}}at(e,n){let r=this.yamlAt;if(!r)return n;let i=r.map.get(e)??r.map.get(e.replace(/^[^.[]+\./,""));return i?this.p(r.line+i.line-1,i.col):n}front(e){if(e.front===null)return{};let n;try{n=gf.default.parse(e.front,{strict:!0,uniqueKeys:!0})}catch(i){let{message:s,pos:o}=Tg(i,e.front,e.frontLine,this.file,"the front matter");return this.diags.error("mkp.front-matter",s,o),{}}if(n==null)return{};if(typeof n!="object"||Array.isArray(n))return this.diags.error("mkp.front-matter",`the front matter must be a YAML mapping of key: value lines; found ${li(n)}. Write each entry as key: value, e.g. title: Notes`,this.p(e.frontLine)),{};let r=Na(e.front);try{this.guard(n,this.p(e.frontLine),"the front matter",i=>{let s=r.get(i);return s?this.p(e.frontLine+s.line-1,s.col):this.p(e.frontLine)})}catch(i){let s=i.diagnostic;if(!s)throw i;return this.diags.error("mkp.front-matter",s.message,s.pos),{}}return n}guard(e,n,r,i=()=>n,s=""){if(typeof e=="string"){let o=/[\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f]/.exec(e);if(o){let a={" ":["tab","\\t"],"\b":["backspace","\\b"],"\f":["form feed","\\f"],"\v":["vertical tab","\\v"],"\r":["carriage return","\\r"],"\x07":["bell","\\a"],"\x1B":["escape","\\e"]},[l,c]=a[o[0]]??["control character",`U+${o[0].charCodeAt(0).toString(16).padStart(4,"0")}`],u=e;for(let[p,[,h]]of Object.entries(a))u=u.split(p).join(h);u.length>50&&(u=u.slice(0,47)+"\u2026");let f=`'${u.replace(/'/g,"''")}'`;throw new K("mkp.yaml-control-char",`${r} has a ${l} (${c})${s?` in ${s}`:""}, where a backslash was meant: in "double quotes" ${c} is an escape, so the backslash is lost. Write LaTeX in 'single quotes' instead: ${s?Yn(s,f):f}`,i(s))}}else Array.isArray(e)?e.forEach((o,a)=>this.guard(o,n,r,i,`${s}[${a}]`)):e&&typeof e=="object"&&Object.entries(e).forEach(([o,a])=>this.guard(a,n,r,i,s?`${s}.${o}`:o))}items(e,n){let r=[],i=0,s=0;for(let o of e)try{switch(o.k){case"md":{let a=[],l=Zl(o.text,o.line,a);for(let c of a)this.diags.warn("mkp.markdown",c.message,this.p(c.line));this.valInProse(o.text,o.line),o.attrs&&l.length&&this.applyAttrs(l[l.length-1],o.attrs.id,o.attrs.props,o.attrs.line,null),r.push(...l);break}case"state":{let a=this.stateNames(o.body);r.push({node:"controls",names:a,pos:[o.line,1],...n?{meta:{place:s++}}:{}});break}case"defs":break;case"block":{let a=this.block(o);a&&((a.meta??={}).block=n?i++:void 0,a.meta.block===void 0&&delete a.meta.block,n&&(a.meta.place=s++),r.push(a));break}case"container":{let a=this.container(o);a&&(n&&((a.meta??={}).place=s++),r.push(a));break}}}catch(a){this.dc.err(a)}return r}stateNames(e){return Cg(e)}widgetSig(e,n){let r=this.dc.resolveDef(e,n);if(r.kind==="part"&&!this.dc.opts.allowParts)throw new K("mkp.part-in-document",`${r.name} is a part, which only other definitions can use, so it can't be a block in a document. Use it inside a widget in an mkp fence, or drop "part" from its definition (and give it a project md) to use it here`,n);return this.dc.uses.add(r.id),r}block(e){let n=this.p(e.line),r=e.name.replace(/@\d+$/,"");if(!this.prog.lookupDefs(r,Qe).length){if(e.id||e.name.includes("@")||/[.:]/.test(e.name)===!1&&this.looksLikeWidget(e.yaml)){let u=ue(r,[...this.prog.defs.values()].filter(p=>p.syn.kind!=="part").map(p=>p.syn.name)),f=u?`Did you mean "${u}"? Write \`\`\`${u}`:"Correct the name after the opening ```, or define the widget in an mkp fence";return this.diags.error("mkp.unknown-widget",`the fence names a widget "${r}", but no widget of that name is defined in this document or its packs. ${f}`,n),null}return{node:"code",def:"core:code@1",props:{src:{text:e.yaml},lang:{text:e.info}},pos:[e.line,1]}}let i=this.widgetSig(e.name,n),s;try{s=e.yaml.trim()?gf.default.parse(e.yaml,{strict:!0,uniqueKeys:!0}):{}}catch(u){let{message:f,pos:p}=Tg(u,e.yaml,e.line+1,this.file,`the ${i.name} block`);throw new K("mkp.yaml",f,p)}if(s==null&&(s={}),this.yamlAt={line:e.line+1,map:Na(e.yaml)},typeof s!="object"||Array.isArray(s)){let u=i.order.find(p=>i.inputs.has(p))??[...i.inputs.keys()][0],f=u?`${u}: ${mt(i.inputs.get(u).type,this.prog.typeEnv(i.pack),this.dc.opts.tokenNames)}`:"summary: What it shows.";throw new K("mkp.yaml",`the ${i.name} block must be a YAML mapping of its inputs, one name: value line each; found ${li(s)}. Write each input on its own line, e.g. ${f}`,this.p(e.line+1))}let o=s;this.guard(o,this.p(e.line+1),`the ${i.name} block`,u=>this.at(u,this.p(e.line+1))),i.params?.length&&(i=this.bindYaml(i,o,e));let a={node:i.name,def:i.id,props:{},pos:[e.line,1]},l=o.summary;if(typeof l!="string"||!l.trim()){let u=l===void 0?"no summary: line":l===null||typeof l=="string"?"an empty summary":`summary: ${Jn(l)}, which is not a sentence`,f=l===void 0?n:this.at("summary",n);this.diags.error("mkp.missing-summary",`the ${i.name} block needs a summary: line, one sentence of what it shows, for readers without the widget and for Markdown output; found ${u}. Add one, e.g. summary: A short sentence on what it shows.`,f)}else(a.meta??={}).summary=l;e.id&&((a.meta??={}).anchor=e.id);let c=new Set;for(let[u,f]of Object.entries(o))if(u!=="summary")try{this.setProp(a,i,u,f,this.p(this.lineOf(e,u)))}catch(p){c.add(u),this.dc.err(p)}return e.attrs&&this.applyAttrs(a,e.attrs.id,e.attrs.props,e.attrs.line,i),this.requireInputs(a,i,n,c),this.checkSize(a,i,n),this.yamlAt=null,a}bindYaml(e,n,r){let i=e.params,s={},o=this.prog.typeEnv(e.pack),a=(h,d)=>(h.t==="named"||h.t==="param")&&i.includes(h.name)?d===void 0||h.name===d:h.t==="list"||h.t==="dict"?a(h.of,d):h.t==="rec"?h.fields.some(([,m])=>a(m,d)):!1,l=h=>a(h),c=(h,d,m)=>{if((h.t==="named"||h.t==="param")&&h.name===m)return d;let g=P(d,o);if((h.t==="list"||h.t==="dict")&&g.t===h.t)return c(h.of,g.of,m);if(h.t==="rec"&&g.t==="rec")for(let[y,$]of h.fields){let b=g.fields.find(([w])=>w===y),k=b&&c($,b[1],m);if(k)return k}},u={},f=h=>`${h} stands for the kind of items it holds, read from the data`;for(let[h,d]of Object.entries(n)){let m=e.inputs.get(h);if(!m||!l(m.type))continue;let g;try{g=ai(d,h)}catch(b){throw this.shapeProblem(d,h,!0,e)??new K("mkp.input-type",b.message,this.p(this.lineOf(r,h)))}let y={...s},$=Eg(m.type,g,i,s,o);if($){let b=i.find(k=>y[k]&&c(m.type,g,k)&&!Ue(y[k],c(m.type,g,k),o));if(b&&u[b]){let k=u[b];throw new K("mkp.input-type",`${h} and ${k} must hold the same kind of items, since ${e.name} uses one type ${b} for both (${f(b)}); found ${N(c(m.type,g,b))} in ${h} but ${N(y[b])} in ${k}. Give the items of both the same fields with the same kinds of value`,this.p(this.lineOf(r,h)))}throw new K("mkp.input-type",$,this.p(this.lineOf(r,h)))}for(let b of i)s[b]&&!y[b]&&(u[b]=h)}let p=i.filter(h=>!s[h]);if(p.length){let h=[...e.inputs].filter(([,b])=>p.some(k=>a(b.type,k))),d=Object.keys(n).filter(b=>b!=="summary"),m=h.length?`${h[0][0]}: ${P(h[0][1].type,o).t==="list"?"[{city: Lisbon}]":"{city: Lisbon}"}`:"",g=p.join(" and "),y=p.length>1?"are":"is",$=h.length?`Add ${Ns(h.map(([b,k])=>`${b} (${N(k.type)})`))}, e.g. ${m}`:`Give the inputs that hold ${p.length>1?"them":"it"}`;throw new K("mkp.input-type",`${e.name} can't tell what ${g} ${y} (${g} ${p.length>1?"stand":"stands"} for the kind of items it holds, read from the data), since no input that holds ${g} is given; found ${d.length?`only ${d.join(", ")}`:"no inputs"}. ${$}`,this.p(r.line))}return mf(e,s)}shapeProblem(e,n,r,i){let s=o=>this.at(o,this.p(this.yamlAt?.line??1));if(e==null)return new K("mkp.input-type",`${n} has no value; found an empty entry. Write a value after it, or Remove it`,s(n));if(Array.isArray(e)){if(!e.length&&r)return new K("mkp.input-type",`${n} is an empty list, so ${i.name} can't tell what kind of items it holds; found []. Give at least one item, e.g. ${n}: [{city: Lisbon}]`,s(n));let o=null;for(let a=0;a<e.length;a++){let l;try{l=ai(e[a],`${n}[${a}]`,!1)}catch{return this.shapeProblem(e[a],`${n}[${a}]`,!1,i)}if(o){let c=Ue(o,l,()=>{});if(!c)return new K("mkp.input-type",`${n}[${a}] is not like the items before it: ${this.shapeDiff(o,l,n)}`,s(`${n}[${a}]`));o=c}else o=l}return null}if(typeof e=="object")for(let[o,a]of Object.entries(e)){let l=this.shapeProblem(a,`${n}.${o}`,!1,i);if(l)return l}return null}shapeDiff(e,n,r){let i=()=>{};if(e.t==="rec"&&n.t==="rec"){let s=e.fields.map(c=>c[0]),o=n.fields.map(c=>c[0]),a=s.filter(c=>!o.includes(c)),l=o.filter(c=>!s.includes(c));if(a.length||l.length){let c=[a.length?`Add ${a.join(", ")}`:"",l.length?`${a.length?"remove":"Remove"} ${l.join(", ")}`:""].filter(Boolean).join(" and ");return`it has the fields ${o.join(", ")||"none"}, where the items before it have ${s.join(", ")}; every item of ${r} needs the same fields. ${c}, or give the others the same fields`}for(let[c,u]of e.fields){let f=n.fields.find(p=>p[0]===c)[1];if(!Ue(u,f,i))return`its ${c} is ${ct(f,i)}, but in the items before it ${c} is ${ct(u,i)}. Write ${c} as ${ct(u,i)} here too, or as ${ct(f,i)} in every item`}}return`it is ${ct(n,i)}, but the items before it are ${ct(e,i)}. Write it like the others`}looksLikeWidget(e){return/^summary:/m.test(e)}lineOf(e,n){let r=this.yamlAt?.map.get(n);if(r)return e.line+r.line;let i=e.yaml.split(`
480
+ `).findIndex(s=>s.startsWith(n+":"));return e.line+1+Math.max(0,i)}requireInputs(e,n,r,i=new Set,s){let o=this.prog.typeEnv(n.pack);for(let[a,l]of n.inputs){if(l.hasDefault||e.props?.[a]!==void 0||i.has(a))continue;let c=P(l.type,o);if(c.t==="records"&&e.records?.length)continue;let u=this.takes(l.type,n.pack);if(s===void 0)this.diags.error("mkp.missing-input",`the ${n.name} block is missing ${a}, which takes ${u}. Add a line ${a}: ${mt(l.type,o,this.dc.opts.tokenNames)}`,r);else if(c.t==="records"){let f=mt(E.text,o,this.dc.opts.tokenNames,!0);this.diags.error("mkp.missing-input",`the :::${n.name} container is missing ${a}, which takes ${u}. Add ${c.kind} records inside it, e.g. a :::${c.kind} ${f} line, its Markdown, and a closing :::`,r)}else this.diags.error("mkp.missing-input",`the :::${n.name} container is missing ${a}, which takes ${u}. Add it to the ::: line, e.g. ${s} ${a}=${mt(l.type,o,this.dc.opts.tokenNames,!0)}`,r)}}fieldList(e){return Ns([...e.fields.map(n=>n[0]),...e.slot?["slot"]:[]])}unknownInput(e,n,r,i,s){let o=ue(n,[...e.inputs.keys(),"summary"]),a=[...e.inputs.keys()],l=a.length?`its inputs are ${Ns(a)}`:"it takes no inputs";return new K("mkp.unknown-prop",`${e.name} has no input "${n}"; found ${r}${o?`. Did you mean "${o}"? ${i.replace(/ to one of them/,"")}`:`, and ${l}. ${i}`}`,s)}setProp(e,n,r,i,s){let o=n.inputs.get(r);if(!o&&Wr(r))return this.setSize(e,r,typeof i=="number"||typeof i=="string"?i:Jn(i),s);if(!o)throw this.unknownInput(n,r,`${r}: ${typeof i=="string"&&i.length<40?i:Jn(i)}`,"Rename the key to one of them, or Remove the line",s);let a=this.prog.typeEnv(n.pack),l=P(o.type,a);if(l.t==="slot"){let c=n.slots[0]===r?`:::${n.name} \u2026 :::`:`:::${n.name} with :::fill ${r} \u2026 ::: inside it`;throw new K("mkp.slot-in-yaml",`${r} is a slot, so its content is written between ::: lines, not in the YAML block; found ${r}: ${typeof i=="string"&&i.length<40?JSON.stringify(i):li(i)}. Write the widget as ${c}, put its other inputs on the ::: line (e.g. :::${n.name} title="\u2026"), and the content on the lines between`,s)}if(l.t==="records"){if(!Array.isArray(i))throw new K("mkp.input-type",`${r} is a list of ${l.kind} records, each written as its fields (${this.fieldList(l)}); found ${li(i)}. Write it as a YAML list, e.g. ${r}: ${mt(l,a,this.dc.opts.tokenNames)}`,s);i.forEach((c,u)=>e.records=[...e.records??[],this.yamlRecord(c,l,n,this.at(`${r}[${u}]`,s),r,`${r}[${u}]`)]);return}e.props[r]=this.yamlValue(i,o.type,n.pack,s,r)}yamlRecord(e,n,r,i,s,o=s){let a=this.prog.typeEnv(r.pack);if(!e||typeof e!="object"||Array.isArray(e))throw new K("mkp.input-type",`${o} must be one ${n.kind} record, written as its fields (${this.fieldList(n)}); found ${li(e)}. Write it as - ${mt({...n,t:"rec"},a,this.dc.opts.tokenNames)}`,i);let l=e,c={},u={node:"$record",record:n.kind,input:s,props:c,pos:[i.line,i.col]};for(let[f,p]of Object.entries(l)){if(f==="slot"&&n.slot){let m=[...r.records].find(([,g])=>g.input===s)?.[0]??n.kind;throw new K("mkp.slot-in-yaml",`slot in ${o} is the ${n.kind}'s content, which is written between ::: lines, not in YAML. Write ${s} as :::${r.name} \u2026 ::: holding one :::${m} "\u2026" \u2026 ::: for each ${n.kind}, with its fields on the ::: line and its content on the lines between`,this.at(`${o}.slot`,i))}let h=n.fields.find(m=>m[0]===f);if(!h){let m=ue(f,n.fields.map(g=>g[0]).filter(g=>!(g in l)));throw new K("mkp.unknown-field",`${o} has no field "${f}"; a ${n.kind}'s fields are ${this.fieldList(n)}${m?`. Did you mean "${m}"? Rename it`:". Rename it to one of them, or Remove it"}`,this.at(`${o}.${f}`,i))}let d=P(h[1],this.prog.typeEnv(r.pack));if(d.t==="records"){if(!Array.isArray(p))throw new K("mkp.input-type",`${f} in ${o} is a list of ${d.kind} records, each written as its fields (${this.fieldList(d)}); found ${li(p)}. Write it as a YAML list, e.g. ${f}: ${mt(d,a,this.dc.opts.tokenNames)}`,this.at(`${o}.${f}`,i));p.forEach((m,g)=>(u.records??=[]).push(this.yamlRecord(m,d,r,this.at(`${o}.${f}[${g}]`,i),f,`${o}.${f}[${g}]`)));continue}c[f]=this.yamlValue(p,h[1],r.pack,this.at(`${o}.${f}`,i),`${o}.${f}`)}for(let[f,p]of n.fields){if(c[f]!==void 0||P(p,this.prog.typeEnv(r.pack)).t==="records")continue;let h=n.defaults?.[f];if(h===void 0){let d=Object.keys(l);throw new K("mkp.missing-input",`${o} (a ${n.kind}) is missing ${f}, which takes ${this.takes(p,r.pack)}; found ${d.length?`only ${d.join(", ")}`:"no fields"}. Add it, e.g. ${f}: ${mt(p,a,this.dc.opts.tokenNames)}`,i)}c[f]=this.dc.staticValue(St(h,this.file,i.line,i.col),vt(p,this.prog.typeEnv(r.pack)),i)}return u}takes(e,n){let r=P(e,this.prog.typeEnv(n));return r.t==="token"?this.dc.takes(r):ct(r,this.prog.typeEnv(n))}wrong(e,n,r,i,s){let o=typeof n=="string"&&/^-?\d+(\.\d+)?$/.test(n)&&/^a (whole )?number/.test(r)?" (a number in quotes is text: remove the quotes)":"";throw new K("mkp.input-type",`${e} takes ${r}; found ${Jn(n)}${o}. Replace it, e.g. with ${Yn(e,o?String(n):i)}`,this.at(e,s))}outside(e,n,r,i,s){return new K("mkp.input-range",`${e} must be from ${r} to ${i}; found ${n}. Write a number in that range, e.g. ${Yn(e,String(n<r?r:i))}`,this.at(e,s))}badToken(e,n,r,i){let s=ue(String(n),this.dc.opts.tokenNames(r.kind)),o=this.dc.opts.tokenNames(r.kind),a=s??(o.has("accent")?"accent":[...o][0]??"none");return new K("mkp.unknown-token",`${e} takes ${this.dc.takes(r)}; found ${Jn(n)}, which is not a ${r.kind} token name. ${s?`Did you mean ${s}? `:""}Write one of those names, e.g. ${Yn(e,a)}`,this.at(e,i))}yamlValue(e,n,r,i,s){let o=this.prog.typeEnv(r),a=P(n,o),l=(c,u)=>this.wrong(s,e,c,u??mt(a,o,this.dc.opts.tokenNames),i);switch(a.t){case"num":case"int":{if(typeof e!="number")return l(this.dc.takes(a));if(a.t==="int"&&!Number.isInteger(e))return l(this.dc.takes(a),String(Math.round(e)));if(a.lo!==void 0&&(e<a.lo||e>a.hi))throw this.outside(s,e,a.lo,a.hi,i);return{lit:e}}case"bool":if(typeof e=="string"&&/^(yes|no|on|off|y|n)$/i.test(e)){let c=/^(yes|on|y)$/i.test(e)?"true":"false";throw new K("mkp.input-type",`${s} takes true or false; found ${e}, which YAML 1.2 reads as text, not as yes or no. Write ${Yn(s,c)}`,this.at(s,i))}return typeof e=="boolean"?{lit:e}:l("true or false");case"text":return typeof e=="number"?{text:String(e)}:typeof e=="string"?{text:e}:l("text");case"latex":{if(typeof e!="string")return l("maths");let c=/^\$\$?([\s\S]*?)\$?\$$/.exec(e.trim());return{tex:c?c[1]:e}}case"choice":if(typeof e=="string"&&a.opts.includes(e))return{lit:e};{let c=ue(String(e),a.opts);throw new K("mkp.enum",`${s} takes one of ${a.opts.join(", ")}; found ${Jn(e)}. ${c?`Did you mean ${c}? Write ${Yn(s,c)}`:`Write one of them, e.g. ${Yn(s,a.opts[0])}`}`,this.at(s,i))}case"point":return Array.isArray(e)&&e.length===2&&e.every(c=>typeof c=="number")?{lit:e}:l("a point [x, y]");case"duration":{let c=typeof e=="string"?/^(\d+(?:\.\d+)?)(ms|s)$/.exec(e):null;return c?{ms:Number(c[1])*(c[2]==="s"?1e3:1)}:l("a duration such as 6s")}case"range":{if(Array.isArray(e)&&e.length===2&&e.every(c=>typeof c=="number"))return{range:[{lit:e[0]},{lit:e[1]}]};if(typeof e=="string"&&/^-?[\d.]+\.\.-?[\d.]+$/.test(e)){let[c,u]=e.split("..").map(Number);return{range:[{lit:c},{lit:u}]}}return l('a range [a, b] or "a..b"')}case"token":if(typeof e=="string"&&(e==="none"||this.dc.opts.tokenNames(a.kind).has(e)))return{tok:e,kind:a.kind};throw this.badToken(s,e,a,i);case"ref":{let c=e,u=this.declaredState.filter(h=>this.dc.scope.get(h)),f=u[0]??"name";if(!c||typeof c!="object"||typeof c.ref!="string")return l(`a reference to ${ct(a.of,o).replace(/^an? /,"")} state, written {ref: name} with the name of a line in a state block`,`{ref: ${f}}`);let p=this.dc.scope.get(c.ref);if(!p||p.kind!=="state"&&p.kind!=="var"){let h=`${c.ref} = ${Ag(a.of,o)} "${c.ref}"`,d=u.length?`; the state declared here is ${Ns(u)}`:"",m=ue(c.ref,u);throw new K("mkp.not-state",`${s} refers to the state "${c.ref}", but no state block of this document declares it${d}. ${m?`Did you mean {ref: ${m}}? Or declare`:"Declare"} it in a \`\`\`state block, e.g. ${h}`,this.at(s,i))}if(!ae(p.type,a.of,o)){let h=ct(a.of,o);throw new K("mkp.input-type",`${s} takes state that is ${h}, but the state ${c.ref} is ${ct(p.type,o)}. Refer to state that is ${h}, or declare ${c.ref} with another control, e.g. ${c.ref} = ${Ag(a.of,o)} "${c.ref}"`,this.at(s,i))}return{ref:c.ref}}case"path":return typeof e!="string"?l("the name of a field of the items","name"):this.dc.pathTo(e,a,this.at(s,i),o);case"expr":{if(typeof e!="string"&&typeof e!="number")return l(`an expression${a.vars.length?` in ${a.vars.map(u=>u[0]).join(", ")}`:""}, written as text`,`"${a.vars[0]?.[0]??"x"} * 2"`);let c=Gr(String(e),this.file,i.line,i.col);return this.dc.value({v:"expr",e:c,src:String(e),p:i},n,this.dc.scope,i)}case"list":return Array.isArray(e)?{lit:e.map((u,f)=>this.yamlData(u,a.of,o,i,`${s}[${f}]`))}:l(ct(a,o));default:return{lit:this.yamlData(e,n,o,i,s)}}}yamlData(e,n,r,i,s){let o=P(n,r),a=(l,c)=>this.wrong(s,e,l,c??mt(o,r,this.dc.opts.tokenNames),i);switch(o.t){case"num":case"int":if(typeof e!="number"||o.t==="int"&&!Number.isInteger(e))return a(this.dc.takes(o),typeof e=="number"?String(Math.round(e)):void 0);if(o.lo!==void 0&&(e<o.lo||e>o.hi))throw this.outside(s,e,o.lo,o.hi,i);return e;case"bool":return typeof e=="boolean"?e:a("true or false");case"text":case"latex":return typeof e=="string"?e:typeof e=="number"?String(e):a("text");case"choice":return typeof e=="string"&&o.opts.includes(e)?e:a(`one of ${o.opts.join(", ")}`,ue(String(e),o.opts)??o.opts[0]);case"token":if(typeof e=="string"&&(e==="none"||this.dc.opts.tokenNames(o.kind).has(e)))return e;throw this.badToken(s,e,o,i);case"point":return Array.isArray(e)&&e.length===2&&e.every(l=>typeof l=="number")?e:a("a point [x, y]");case"list":return Array.isArray(e)?e.map((l,c)=>this.yamlData(l,o.of,r,i,`${s}[${c}]`)):a(ct(o,r));case"dict":{if(!e||typeof e!="object"||Array.isArray(e))return a("a mapping of name: value pairs","{a: \u2026, b: \u2026}");let l={};for(let[c,u]of Object.entries(e))l[c]=this.yamlData(u,o.of,r,i,`${s}.${c}`);return l}case"rec":{if(!e||typeof e!="object"||Array.isArray(e))return a(`a record with the fields ${o.fields.map(u=>u[0]).join(", ")}`);let l={},c=e;for(let u of Object.keys(c)){if(o.fields.some(h=>h[0]===u))continue;let f=ue(u,o.fields.map(h=>h[0]).filter(h=>!(h in c))),p=o.fields.map(h=>h[0]).join(", ");throw new K("mkp.unknown-field",`${s} has no field "${u}"; its fields are ${p}${f?`. Did you mean "${f}"? Rename it`:". Rename it to one of them, or Remove it"}`,this.at(`${s}.${u}`,this.at(s,i)))}for(let[u,f]of o.fields){if(!(u in c)){let p=o.defaults?.[u];if(p!==void 0){let m=this.dc.staticValue(St(p),vt(f,r),i);l[u]="lit"in m?m.lit:"text"in m?m.text:"tex"in m?m.tex:"tok"in m?m.tok:"ms"in m?m.ms:"ast"in m?Y2(m,`${s}.${u}`,this.at(s,i)):m.lit;continue}let h=Object.keys(c),d=h.map(m=>`${m}: ${typeof c[m]=="string"||typeof c[m]=="number"?String(c[m]):"\u2026"}`);throw new K("mkp.missing-field",`${s} is missing the field ${u}, which takes ${ct(f,r)}; found only ${h.length?h.join(", "):"an empty record"}. Add it, e.g. ${Yn(s,`{${[`${u}: ${mt(f,r,this.dc.opts.tokenNames)}`,...d].join(", ")}}`)}`,this.at(s,i))}l[u]=this.yamlData(c[u],f,r,i,`${s}.${u}`)}return l}default:throw new K("mkp.input-type",`${s} takes ${N(n)}, which a value written in YAML can't be; found ${Jn(e)}. Pass ${s} from a widget definition instead, or give it a type YAML can write (text, a number, a list, a record)`,this.at(s,i))}}valInProse(e,n){let r=null;e.split(`
481
+ `).forEach((i,s)=>{let o=/^\s*(`{3,}|~{3,})/.exec(i);if(o&&(!r||o[1].startsWith(r))){r=r?null:o[1];return}if(r)return;let a=/\\val\{([^}]*)\}/.exec(i.replace(/(`+)[\s\S]*?\1/g,l=>" ".repeat(l.length)));a&&this.diags.warn("mkp.val-in-prose",`\\val{${a[1]}} in the document's text is shown as written, not as a value: live values work in a widget's text only; found ${a[0]} here. Show it with a widget, e.g. a block of your own whose view is text "\u2026 \\val{${a[1]}} \u2026", or write the value out`,this.p(n+s,a.index+1))})}setSize(e,n,r,i){let s=sn(n,r);if(s===void 0)throw new K("mkp.size",`${n} takes ${vo(n)}, written as it is (a first paint reads it before anything runs); found ${n}: ${r}. Write e.g. ${n==="aspect"?"aspect: 16/9":`${n}: 320`}`,i);(e.meta??={})[n]=s}checkSize(e,n,r){let i={};for(let a of Ft){let l=e.meta?.[a]??(e.props?.[a]&&"lit"in e.props[a]?sn(a,e.props[a].lit):e.props?.[a]&&"expr"in e.props[a]?sn(a,e.props[a].expr):void 0);l!==void 0&&(i[a]=l)}let s=Object.keys(i);if(s.length===3)throw new K("mkp.size",`${n.name} is given minwidth, minheight and aspect, which can disagree: two of them fix its size before it is drawn. Remove one, e.g. keep minwidth and aspect`,r);let o=Object.keys(xo(i,n.sizes));if(s.length&&o.length===1){let a=o[0],l=Ft.filter(c=>c!==a).join(" or ");this.diags.warn("mkp.size",`${n.name} has ${a} alone, so its box before it is drawn is ${a==="minwidth"?"only as wide as that, with a height guessed":a==="minheight"?"that tall, as wide as the column":"that shape, as wide as the column"}, and may move once when drawn. Give ${l} as well, so its box is fixed`,r)}}container(e){let n=this.p(e.line),r=this.widgetSig(e.name,n),i=this.args(e.args,e.line,e.name.length+e.colons+1),{props:s,meta:o}=this.dc.fillArgs(i,new Map([...r.inputs].map(([u,f])=>[u,f.type])),r.fields,this.dc.scope,r.name,new Set(r.slots)),a={node:r.name,def:r.id,props:s,pos:[e.line,1]};Object.keys(o).length&&(a.meta=o);let l=[];for(let u of e.items){if(u.k==="container"&&u.name==="fill"){let p=u.args.trim();if(!r.slots.includes(p)){let h=ue(p,r.slots.slice(1))??ue(p,r.slots),d=h??r.slots[1]??r.slots[0],m=r.slots.length?`${r.name} has no slot "${p}"; its slots are ${r.slots.join(", ")} (the Markdown written straight inside :::${r.name} goes to ${r.slots[0]}). ${h?`Did you mean "${h}"? `:""}Write :::fill ${d}`:`${r.name} has no slots, so :::fill ${p} has nothing to fill. Remove the :::fill container, or use a widget that holds Markdown`;throw new K("mkp.unknown-slot",m,this.p(u.line))}(a.fills??={})[p]=this.items(u.items,!1);continue}let f=u.k==="container"?r.records.get(u.name):void 0;if(f&&u.k==="container"){let p=this.args(u.args,u.line,u.name.length+u.colons+1),h=f.type,d=h.fields.filter(([,y])=>P(y,this.prog.typeEnv(r.pack)).t!=="records").map(([y])=>y),m=this.dc.fillArgs(p,new Map(h.fields.map(([y,$])=>[y,vt($,this.prog.typeEnv(r.pack))])),d,this.dc.scope,`${h.kind} record`,new Set);for(let[y,$]of h.fields){if(m.props[y]!==void 0||P($,this.prog.typeEnv(r.pack)).t==="records")continue;let b=h.defaults?.[y];if(b===void 0){let k=`:::${u.name}${u.args.trim()?" "+u.args.trim():""}`,w=this.prog.typeEnv(r.pack);throw new K("mkp.missing-input",`the ${k} record is missing ${y}, which takes ${this.takes($,r.pack)}; its fields, in order, are ${d.join(", ")}. Add it on the ::: line, by position or by name, e.g. ${k} ${y}=${mt($,w,this.dc.opts.tokenNames,!0)}`,this.p(u.line))}m.props[y]=this.dc.staticValue(St(b),vt($,this.prog.typeEnv(r.pack)),this.p(u.line))}let g={node:"$record",record:h.kind,input:f.input,props:m.props,pos:[u.line,1]};Object.keys(m.meta).length&&(g.meta=m.meta),h.slot&&(g.children=this.items(u.items,!1)),(a.records??=[]).push(g);continue}l.push(u)}let c=this.items(l,!1);if(c.length){if(!r.slots.length){let f=l.find(h=>h.k==="md")?.text.split(`
482
+ `).find(h=>h.trim())?.trim(),p=f?`found ${JSON.stringify(f.length>40?f.slice(0,37)+"\u2026":f)}`:"found content";throw new K("mkp.no-slot",`${r.name} has no slot, so the Markdown inside :::${r.name} \u2026 ::: has nowhere to go; ${p}. Remove the Markdown between the ::: lines, or write the widget as a \`\`\`${r.name} block instead`,n)}a.children=c}return e.attrs&&this.applyAttrs(a,e.attrs.id,e.attrs.props,e.attrs.line,r),this.requireInputs(a,r,n,new Set,`:::${e.name}${e.args.trim()?" "+e.args.trim():""}`),this.checkSize(a,r,n),a}args(e,n,r){return e.trim()?Xe(e).map(i=>{let s=this.p(n,r+i.at),o=/^([A-Za-z_][A-Za-z0-9_]*)=(?!=)/.exec(i.text);return o?{key:o[1],value:St(i.text.slice(o[0].length),this.file,n,r+i.at+o[0].length),p:s}:{value:St(i.text,this.file,n,r+i.at),p:s}}):[]}applyAttrs(e,n,r,i,s){n&&((e.meta??={}).anchor=n);for(let[o,a]of Object.entries(r)){let l=this.p(i);if(this.dc.opts.blockAttrs?.has(o)&&!s?.inputs.has(o)){((e.meta??={}).attrs??={})[o]=a.replace(/^"(.*)"$/s,"$1");continue}if(!s){if(o==="role"&&e.node==="heading"){(e.meta??={}).role=a.replace(/^"|"$/g,"");continue}let u=[...this.dc.opts.blockAttrs??[]],f=`an anchor {#id}, role= on a heading${u.length?`, and this profile's block attributes ${Ns(u)}`:""}`;this.diags.warn("mkp.attrs",`the attribute ${o}=${a} on a Markdown block is ignored; a Markdown block takes only ${f}. Remove it, or move it to a widget block that has a ${o} input`,l);continue}let c=s.inputs.get(o);if(!c&&Wr(o)){this.setSize(e,o,a,l);continue}if(!c)throw this.unknownInput(s,o,`{${o}=${a}} under the block`,"Rename the attribute to one of them, or Remove it",l);e.props[o]=this.dc.value(St(a,this.file,i,1),c.type,this.dc.scope,l)}}};var ja=class t{constructor(e){this.diags=e}packs=new Map;stableFile(e,n){let r=this.packs.get(e)?.label;return r!==void 0&&n.startsWith(`${r}/`)?`${e}/${n.slice(r.length+1)}`:n}ifaces=new Map;tokenNames;privateFor;defs=new Map;types=new Map;fns=new Map;ops=new Map;consts=new Map;macros=new Map;tokenSets=[];irFns={};irConsts={};fnsInProgress=new Map;placeOf(e,n,r){let i=this.packs.get(e)?.label;return`${i!==void 0&&n.startsWith(`${i}/`)?n.slice(i.length+1):n}:${r}`}addPack(e){if(this.packs.has(e.name)){let n=this.packs.get(e.name);if(n.version===e.version){let r=n.label===e.label?`from ${e.label} both times`:`from ${n.label??n.name} and ${e.label??e.name}`;this.diags.error("mkp.pack-duplicate",`pack ${e.name}@${e.version} is given to this build twice; found it ${r}. Give it once (remove one --pack), or, if they are different packs, give one a new name or version (pack ${e.name}@${e.version+1})`,{...e.manifest.p,col:1});return}if(n.version>e.version)return}this.packs.set(e.name,e);for(let n of e.files)for(let r of n.items)switch(r.item){case"def":{let i=`${e.name}:${r.name}@${r.version}`,s=this.defs.get(i);s&&this.diags.error("mkp.duplicate-definition",`${r.name}@${r.version} is defined twice in pack ${e.name}; found a second definition here, the first is at ${this.placeOf(e.name,s.file,s.syn.p.line)}. Remove one of them, or give this one another name or a new version (${r.name}@${r.version+1})`,r.p),this.defs.set(i,{id:i,pack:e.name,file:n.file,syn:r});break}case"type":{let i=`${e.name}:${r.name}`,s=this.types.get(i);s&&this.diags.error("mkp.duplicate-type",`type ${r.name} is defined twice in pack ${e.name}; found a second type ${r.name} here, the first is at ${this.placeOf(e.name,s.p.file,s.p.line)}. Remove one of them, or rename this one`,r.p);let o=r.type.t==="rec"?{...r.type,name:r.name}:r.type;this.types.set(i,{pack:e.name,name:r.name,type:o,p:r.p});break}case"fn":case"op":{let i=r.item==="op",s=i?this.ops:this.fns,o=i?r.symbol:r.name,a=s.get(o)??[],l=r.params.every(m=>m.type)?r.params.map(m=>m.type):void 0,c=r.params.find(m=>m.type)?.type,u=m=>m?N(m):c&&i?N(c):"num",f=`${i?"op":"fn"} ${o}(${r.params.map(m=>`${m.name}: ${u(m.type)}`).join(", ")}): ${r.ret?N(r.ret):u(void 0)} = \u2026`,p=r.params.filter(m=>!m.type).map(m=>m.name),h=p.length?`${p.join(", ")} with no type`:"";if(i&&!l)this.diags.error("mkp.op-untyped",`op ${o} must give every parameter a type, since the types of the arguments decide which op ${o} is used; found ${h}. Write each as name: type, e.g. ${f}`,r.p);else if(!e.builtin&&(!l||!r.ret)){let m=[h,r.ret?"":"no result type"].filter(Boolean).join(", and ");this.diags.error("mkp.untyped",`${i?"op":"fn"} ${o} must give a type to every parameter and to its result (after the closing bracket); found ${m}. Write it as ${f}`,r.p)}let d=`${e.name}:${i?"op":""}${o}#${a.length}`;a.push({id:d,pack:e.name,file:n.file,syn:r,op:i?o:void 0,sig:l}),s.set(o,a);break}case"const":{let i=this.consts.get(r.name)??[];i.push({id:`${e.name}:${r.name}`,pack:e.name,file:n.file,name:r.name,type:r.type,syn:r}),this.consts.set(r.name,i);break}case"macro":this.macros.set(r.name,{pack:e.name,tex:r.tex});break;case"tokens":this.tokenSets.push({pack:e.name,syn:r});break;case"interface":{let i=`${e.name}:${r.name}@${r.version}`,s=this.ifaces.get(i);s&&this.diags.error("mkp.duplicate-definition",`interface ${r.name}@${r.version} is defined twice in pack ${e.name}; found a second interface ${r.name}@${r.version} here, the first is at ${this.placeOf(e.name,s.file,s.syn.p.line)}. Remove one of them, or give this one a new version (${r.name}@${r.version+1})`,r.p),this.ifaces.set(i,{id:i,pack:e.name,file:n.file,syn:r});break}case"manifest":break}}visible(e,n,r){if(e===r)return!0;let i=this.packs.get(e);if(r==="$doc"&&e===this.privateFor)return!0;if(!i||!(i.builtin||i.provides.has(n)))return!1;if(i.builtin||r==="$doc"||r==="$none")return!0;let s=this.packs.get(r);return!s||s.depends.some(o=>o.replace(/@\d+$/,"")===e)}overlay(e){let n=new t(e);for(let[r,i]of this.packs)n.packs.set(r,i);for(let[r,i]of this.defs)n.defs.set(r,i);for(let[r,i]of this.types)n.types.set(r,i);for(let[r,i]of this.ifaces)n.ifaces.set(r,i);for(let[r,i]of this.fns)n.fns.set(r,[...i]);for(let[r,i]of this.ops)n.ops.set(r,[...i]);for(let[r,i]of this.consts)n.consts.set(r,[...i]);for(let[r,i]of this.macros)n.macros.set(r,i);return n.tokenSets.push(...this.tokenSets),Object.setPrototypeOf(n.irFns,this.irFns),Object.setPrototypeOf(n.irConsts,this.irConsts),n.tokenNames=this.tokenNames,n}lookupIface(e,n){let r=e.lastIndexOf("@"),i=e.slice(0,r),s=Number(e.slice(r+1));for(let o of this.ifaces.values())if(o.syn.name===i&&o.syn.version===s&&this.visible(o.pack,i,n))return o}typeEnv(e){return n=>this.lookupType(n,e)?.type}lookupType(e,n){let r=this.types.get(`${n}:${e}`);if(r)return r;if(e.includes(":")){let s=this.types.get(e);return s&&this.visible(s.pack,s.name,n)?s:void 0}return[...this.types.values()].filter(s=>s.name===e&&this.visible(s.pack,e,n))[0]}lookupDefs(e,n){let r,i=e,s=e.indexOf(":");s>=0&&(r=e.slice(0,s),i=e.slice(s+1));let o=[];for(let a of this.defs.values())a.syn.name===i&&(r&&a.pack!==r||this.visible(a.pack,i,n)&&o.push(a));return o.sort((a,l)=>l.syn.version-a.syn.version)}fnCandidates(e,n){return(this.fns.get(e)??[]).filter(r=>this.visible(r.pack,e,n))}opCandidates(e,n){return(this.ops.get(e)??[]).filter(r=>{if(r.pack===n)return!0;let i=this.packs.get(r.pack);return i?i.builtin?!0:[...r.sig??[],...r.syn.ret?[r.syn.ret]:[]].filter(o=>o.t==="named").map(o=>o.name).some(o=>i.provides.has(o)):!1})}constCandidates(e,n){return(this.consts.get(e)??[]).filter(r=>this.visible(r.pack,e,n))}};var X2=Li(As(),1);function kf(t,e){let n=[];for(let r of t.prog.packs.values())if(!r.builtin)for(let i of r.files)for(let s of i.items){if(s.item!=="migrate")continue;let o=s,a=(A=o.p)=>A,l=`${r.name}:${o.from}`,c=o.to.includes(":")?o.to:`${r.name}:${o.to}`,u=c.split(":")[0],f=t.defs.get(l),p=t.defs.get(c),h=(A,_)=>[...t.defs.values()].filter(W=>W.pack===A&&W.name===_).map(W=>`${W.name}@${W.version}`);if(o.from.includes(":")){e.error("mkp.migrate-pack",`a migrate block moves uses of this pack's own widgets; found ${o.from}. Write it in the pack that defines it, as migrate ${o.from.split(":")[1]} -> \u2026`,a());continue}if(u!==r.name&&!r.depends.some(A=>A.replace(/@\d+$/,"")===u)){e.error("mkp.migrate-pack",`migrate moves uses to ${o.to}, from pack ${u}, which pack ${r.name} doesn't depend on; found no ${u} under its depends. Add \`depends ${u}@1\` to its manifest, or move them to one of its own widgets`,a());continue}if(!f||!p){let[A,_]=f?[u,c.split(":")[1]]:[r.name,o.from];e.error("mkp.migrate-pack",`migrate names ${f?o.to:o.from}, which pack ${A} doesn't define; the versions it has are ${h(A,_.split("@")[0]).join(", ")||"none"}. A migrate block moves uses from one widget to a later version of it, or to another widget`,a());continue}if(l===c||f.pack===p.pack&&f.name===p.name&&p.version<=f.version){e.error("mkp.migrate-pack",`migrate moves uses of one widget to a later version of it, or to another widget; found ${o.from} -> ${o.to}. Write e.g. migrate ${f.name}@${f.version} -> ${f.name}@${f.version+1}`,a());continue}let d=t.prog.typeEnv(f.pack),m=t.prog.typeEnv(p.pack),g=new Map(f.inputs.map(A=>[A.name,A])),y=new Map(p.inputs.map(A=>[A.name,A])),$=(A,_)=>{let W=A?P(A,_):null;return W?.t==="records"?W:null},b={pack:r.name,from:l,to:c,rename:{},drop:[],keep:[],fields:{},map:{},records:{},pos:o.p},k=new Set,w=new Map,v=(A,_)=>void(w.get(A)??w.set(A,new Set).get(A)).add(_),D=A=>b.fields[A]??={rename:{},drop:[]},I=(A,_,W)=>{let[Y,q]=A.split(".");if(!g.has(Y))return e.error("mkp.migrate-pack",`${o.from} has no input ${Y}${W}; its inputs are ${[...g.keys()].join(", ")}`,a(_)),null;if(q===void 0)return{inp:Y};let x=$(g.get(Y).type,d);return x?x.fields.some(([ge])=>ge===q)?{inp:Y,field:q,rec:x}:(e.error("mkp.migrate-pack",`the items of ${o.from}'s ${Y} have no field ${q}${W}; their fields are ${x.fields.map(([ge])=>ge).join(", ")}`,a(_)),null):(e.error("mkp.migrate-pack",`${o.from}'s ${Y} isn't a record list, so it has no field ${q}; found ${A}. A dotted name reaches a field of each item of a record list (items.name)`,a(_)),null)},L=A=>b.rename[A]??A,T=[...o.lines].sort((A,_)=>Number(Ig(A).includes("."))-Number(Ig(_).includes(".")));for(let A of T)if(A.k==="rename"){if(A.from.includes(".")!==A.to.includes(".")){e.error("mkp.migrate-pack",`a rename moves an input to an input, or a record list's field to a field; found ${A.from} -> ${A.to}. Write e.g. rename items -> rows, then rename items.name -> rows.title`,a(A.p));continue}let _=I(A.from,A.p,", so it can't be renamed");if(!_)continue;if(_.field===void 0){k.add(_.inp),y.has(A.to)?b.rename[A.from]=A.to:e.error("mkp.migrate-pack",`${o.to} has no input ${A.to} for ${A.from} to become; its inputs are ${[...y.keys()].join(", ")}`,a(A.p));continue}v(_.inp,_.field);let[W,Y]=A.to.split(".");if(W!==L(_.inp)){e.error("mkp.migrate-pack",`${_.inp}'s items become ${L(_.inp)}'s, so its field ${_.field} becomes a field of ${L(_.inp)}; found ${A.to}. Write rename ${A.from} -> ${L(_.inp)}.${Y}${W!==_.inp&&!b.rename[_.inp]?`, after rename ${_.inp} -> ${W}`:""}`,a(A.p));continue}let q=$(y.get(W)?.type,m);q?q.fields.some(([x])=>x===Y)?D(_.inp).rename[_.field]=Y:e.error("mkp.migrate-pack",`the items of ${o.to}'s ${W} have no field ${Y} for ${A.from} to become; their fields are ${q.fields.map(([x])=>x).join(", ")}`,a(A.p)):e.error("mkp.migrate-pack",`${o.to}'s ${W} isn't a record list, so ${A.from} has no field there to become; found ${A.to}`,a(A.p))}else if(A.k==="drop"){let _=I(A.name,A.p," to drop");if(!_)continue;_.field===void 0?(b.drop.push({name:A.name,why:A.why}),k.add(A.name)):(D(_.inp).drop.push({name:_.field,why:A.why}),v(_.inp,_.field))}else if(A.k==="map"){let _=I(A.name,A.p," to map the values of");if(!_)continue;let W=_.field===void 0?g.get(_.inp).type:_.rec.fields.find(([ge])=>ge===_.field)[1],Y=P(W,d);if(Y.t!=="choice"&&Y.t!=="text"){e.error("mkp.migrate-pack",`map changes a choice's or a text's values, one for one; ${A.name} in ${o.from} takes ${Y.t}`,a(A.p));continue}let q=Y.t==="choice"?Y.opts:null,x=q?A.values.filter(([ge])=>!q.includes(ge)).map(([ge])=>ge):[];q&&x.length&&e.error("mkp.migrate-pack",`${A.name} in ${o.from} is one of ${q.join(", ")}; found ${x.join(", ")} on the left of map`,a(A.p)),b.map[A.name]=Object.fromEntries(A.values)}else{let _=y.get(A.name);if(!_){e.error("mkp.migrate-pack",`${o.to} has no input ${A.name} to keep the old look with; its inputs are ${[...y.keys()].join(", ")}`,a(A.p));continue}let W=t.prog.defs.get(c),Y=W?new un(t.prog,W,e,{tokenNames:t.tokenNameFn(),sigs:t.sigs,locked:t.lockedFn()}):null;try{Y&&b.keep.push({name:A.name,value:Y.staticValue(A.value,_.type,A.p,A.name),why:A.why})}catch(q){Y?.err(q)}}for(let A of g.keys())!k.has(A)&&!y.has(A)&&e.error("mkp.migrate-pack",`${o.from}'s input ${A} isn't in ${o.to}, and the migrate block doesn't say where it goes; found no rename or drop for it. Add \`rename ${A} -> \u2026\` or \`drop ${A} "why"\``,a());let G=new Set([...[...g.keys()].filter(A=>!k.has(A)),...Object.values(b.rename),...b.keep.map(A=>A.name)]);for(let A of p.inputs)!A.default&&!G.has(A.name)&&P(A.type,m).t!=="slot"&&P(A.type,m).t!=="records"&&e.error("mkp.migrate-pack",`${o.to} needs ${A.name}, which a use of ${o.from} doesn't give and the migrate block doesn't set; found no input of ${o.from} that becomes it. Add \`rename \u2026 -> ${A.name}\`, or give ${A.name} a default in ${o.to}`,a());let R=t.prog.defs.get(c),j=R?new un(t.prog,R,new Tt,{tokenNames:t.tokenNameFn(),sigs:t.sigs,locked:t.lockedFn()}):null;for(let[A,_]of g){let W=$(_.type,d);if(!W||b.drop.some(pe=>pe.name===A))continue;let Y=$(y.get(L(A))?.type,m);if(!Y){y.has(L(A))&&e.error("mkp.migrate-pack",`${o.from}'s ${A} is a record list, and ${o.to}'s ${L(A)} isn't; found ${A} -> ${L(A)}. Drop it, or move it to a record list`,a());continue}let q=b.fields[A]??{rename:{},drop:[]},x=w.get(A)??new Set,ge=new Set(Y.fields.map(([pe])=>pe));for(let[pe]of W.fields)!x.has(pe)&&!ge.has(pe)&&e.error("mkp.migrate-pack",`the items of ${o.from}'s ${A} have a field ${pe} that those of ${o.to}'s ${L(A)} don't, and the migrate block doesn't say where it goes. Add \`rename ${A}.${pe} -> ${L(A)}.\u2026\` or \`drop ${A}.${pe} "why"\``,a());let Ee=new Set([...W.fields.map(([pe])=>pe).filter(pe=>!x.has(pe)),...Object.values(q.rename)]),S={};for(let[pe,rt]of Y.fields){if(Ee.has(pe)||$(rt,m))continue;let Zt=Y.defaults?.[pe];if(Zt===void 0){e.error("mkp.migrate-pack",`the items of ${o.to}'s ${L(A)} need ${pe}, which those of ${o.from}'s ${A} don't give; found no field that becomes it. Add \`rename ${A}.\u2026 -> ${L(A)}.${pe}\`, or give ${pe} a default in ${o.to}`,a());continue}try{j&&(S[pe]=j.staticValue(St(Zt),rt,o.p))}catch{}}b.records[L(A)]={kind:Y.kind,fill:S}}let O=[];for(let[A,_]of g){if(k.has(A)&&!b.rename[A])continue;O.push([A,_.type,y.get(L(A))?.type]);let W=$(_.type,d),Y=$(y.get(L(A))?.type,m);if(!W||!Y)continue;let q=b.fields[A]??{rename:{},drop:[]};for(let[x,ge]of W.fields)q.drop.some(Ee=>Ee.name===x)||O.push([`${A}.${x}`,ge,Y.fields.find(([Ee])=>Ee===(q.rename[x]??x))?.[1]])}for(let[A,_,W]of O){if(!W)continue;let Y=P(_,d),q=P(W,m),x=b.map[A]??{};if(q.t==="choice"&&(Y.t==="choice"||b.map[A])){let Ee=(Y.t==="choice"?Y.opts:Object.keys(x)).filter(S=>!q.opts.includes(x[S]??S));Ee.length&&e.error("mkp.migrate-pack",`${A} in ${o.to} is one of ${q.opts.join(", ")}, so ${Ee.map(S=>x[S]??S).join(", ")} from ${o.from} has nowhere to go. Add \`map ${A}: ${Ee.map(S=>`${S} -> ${q.opts[0]}`).join(", ")}\` with the values it becomes`,a())}}n.push(b)}return n}var Ig=t=>t.k==="rename"?t.from:t.name;var el=Li(Vy(),1);function Nr(t){if(t===null)return"null";switch(typeof t){case"number":if(!Number.isFinite(t))throw new Error("canonical JSON has no NaN or infinity");return Object.is(t,-0)?"0":JSON.stringify(t);case"boolean":return t?"true":"false";case"string":return JSON.stringify(t);case"object":{if(Array.isArray(t))return"["+t.map(r=>r===void 0?"null":Nr(r)).join(",")+"]";let e=t;return"{"+Object.keys(e).filter(r=>e[r]!==void 0).sort((r,i)=>r<i?-1:r>i?1:0).map(r=>JSON.stringify(r)+":"+Nr(e[r])).join(",")+"}"}default:throw new Error(`canonical JSON can't hold a ${typeof t}`)}}var US=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function eo(t){let e=[];for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);if(r>=55296&&r<56320&&n+1<t.length){let i=t.charCodeAt(n+1);i>=56320&&i<57344&&(r=65536+(r-55296<<10)+(i-56320),n++)}r<128?e.push(r):r<2048?e.push(192|r>>6,128|r&63):r<65536?e.push(224|r>>12,128|r>>6&63,128|r&63):e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}return new Uint8Array(e)}function Cr(t){let e=typeof t=="string"?eo(t):t,n=e.length,r=n+9+63>>6<<6,i=new Uint8Array(r);i.set(e),i[n]=128;let s=n*8,o=new DataView(i.buffer);o.setUint32(r-4,s>>>0),o.setUint32(r-8,Math.floor(s/4294967296));let a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),l=new Uint32Array(64);for(let u=0;u<r;u+=64){for(let b=0;b<16;b++)l[b]=o.getUint32(u+b*4);for(let b=16;b<64;b++){let k=l[b-15],w=l[b-2],v=(k>>>7|k<<25)^(k>>>18|k<<14)^k>>>3,D=(w>>>17|w<<15)^(w>>>19|w<<13)^w>>>10;l[b]=l[b-16]+v+l[b-7]+D>>>0}let f=a[0],p=a[1],h=a[2],d=a[3],m=a[4],g=a[5],y=a[6],$=a[7];for(let b=0;b<64;b++){let k=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),w=m&g^~m&y,v=$+k+w+US[b]+l[b]>>>0,D=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),I=f&p^f&h^p&h,L=D+I>>>0;$=y,y=g,g=m,m=d+v>>>0,d=h,h=p,p=f,f=v+L>>>0}a[0]=a[0]+f>>>0,a[1]=a[1]+p>>>0,a[2]=a[2]+h>>>0,a[3]=a[3]+d>>>0,a[4]=a[4]+m>>>0,a[5]=a[5]+g>>>0,a[6]=a[6]+y>>>0,a[7]=a[7]+$>>>0}let c="";for(let u of a)c+=u.toString(16).padStart(8,"0");return c}var Si={pack:25*1024*1024,file:10*1024*1024},WS=new Set(["png","jpg","jpeg","webp","svg","woff2"]);function HS(t){let e=/\.([A-Za-z0-9]+)$/.exec(t);return e?e[1].toLowerCase():""}function Uy(t){if(!t)return"an empty name";if(t.startsWith("/")||t.startsWith("\\"))return"an absolute path (it starts with a slash)";if(/^[A-Za-z]:/.test(t))return"an absolute path (it starts with a drive letter)";if(t.includes("\\"))return"a path with a backslash (packs use / between folders)";let e=t.split("/");return e.includes("..")?'a path that goes up out of the pack with ".."':e.includes(".")?'a path with a "." folder in it':null}function Wy(t){return t.replace(/^[A-Za-z]:/,"").split(/[\\/]+/).filter(n=>n&&n!=="."&&n!=="..").join("/")||"name.mkp"}var GS=1024*1024;function Ai(t){return`${(t/GS).toFixed(1)} MB`}function Hy(t){return[...t].sort((e,n)=>n[1]-e[1]).slice(0,3).map(([e,n])=>`${e} (${Ai(n)})`).join(", ")}var zy=".mkp, .mkp.md and .fixture.json files and png, jpg, webp, svg or woff2 assets";function jf(t){return!t||t.startsWith("/")||t.startsWith("\\")||/^[A-Za-z]:/.test(t)||t.includes("\\")||t.split("/").some(n=>n===".."||n===".")?null:t}function Pf(t,e,n){let r={file:e,line:1,col:1};if(t.length>Si.pack)return n.error("mkp.pack-size",`${e} is larger than a pack may be (at most 25 MB); found ${Ai(t.length)}. Remove or shrink its largest files (images, fonts) and zip the pack again`,r),null;let i=new DataView(t.buffer,t.byteOffset,t.byteLength),s=-1;for(let d=t.length-22;d>=Math.max(0,t.length-65557);d--)if(i.getUint32(d,!0)===101010256){s=d;break}if(s<0){let d=new TextDecoder().decode(t.subarray(0,200)),m=t.length>0&&!/[\x00-\x08\x0e-\x1f\ufffd]/.test(d),g=d.split(`
483
+ `).find($=>$.trim())?.trim()??"",y=t.length?m?`plain text starting "${g.length>40?g.slice(0,40)+"\u2026":g}"`:"no zip directory at its end":"an empty file";return n.error("mkp.pack-zip",`${e} is not a zip file, and a .mkpack must be one; found ${y}. Zip the pack folder's files (manifest.mkp at the top), e.g. with mkp pack <folder>, or give the folder itself instead of the .mkpack`,r),null}let o=i.getUint16(s+10,!0),a=i.getUint32(s+16,!0),l=0,c=new Set,u=!0,f=[];for(let d=0;d<o;d++){if(a+46>t.length||i.getUint32(a,!0)!==33639248)return n.error("mkp.pack-zip",`${e} is a damaged zip: its list of files (the central directory) breaks off; found ${a+46>t.length?"the file ending":"bytes that are not a file entry"} at entry ${d+1} of ${o}. Make the .mkpack again from the pack folder (mkp pack <folder>)`,r),null;let m=i.getUint16(a+4,!0),g=i.getUint32(a+24,!0),y=i.getUint16(a+28,!0),$=i.getUint16(a+30,!0),b=i.getUint16(a+32,!0),k=i.getUint32(a+38,!0),w=new TextDecoder().decode(t.subarray(a+46,a+46+y));if(a+=46+y+$+b,!w.endsWith("/")){if(!jf(w)){n.error("mkp.pack-path",`${e}: every file in a pack must sit inside it, at a relative path; found "${w}", ${Uy(w)}. Move the file into the pack folder (e.g. as ${Wy(w)}) and zip the pack again`,r),u=!1;continue}if(m>>8===3&&(k>>>16&61440)===40960){n.error("mkp.pack-symlink",`${e}: a pack may hold only real files, not links; found "${w}", a symbolic link. Replace it with a copy of the file it points to, and zip the pack again`,{...r,file:`${e}/${w}`}),u=!1;continue}if(g>Si.file){n.error("mkp.pack-size",`${e}: a file in a pack may be at most 10 MB; found "${w}" at ${Ai(g)} unpacked. Shrink it (e.g. compress the image or lower its resolution) or remove it`,{...r,file:`${e}/${w}`}),u=!1;continue}l+=g,f.push([w,g]),c.add(w)}}if(l>Si.pack)return n.error("mkp.pack-size",`${e} unpacks to more than a pack may hold (at most 25 MB in all, however well it compresses); found ${Ai(l)} unpacked, mostly ${Hy(f)}. Remove or shrink some of those files`,r),null;if(!u)return null;let p=new Map,h=rh(t,{filter:d=>c.has(d.name)&&d.originalSize<=Si.file});for(let[d,m]of Object.entries(h))p.set(d,m);return{label:e,origin:"zip",files:p}}function Gy(t){if(/<!DOCTYPE|<!ENTITY/i.test(t))return null;let e;try{e=new el.DOMParser({onError:()=>{}}).parseFromString(t,"image/svg+xml")}catch{return null}let n=e.documentElement;if(!n||n.nodeName.toLowerCase()!=="svg")return null;let r=i=>{for(let s of Array.from(i.childNodes)){if(s.nodeType!==1)continue;let o=s.nodeName.toLowerCase();if(o==="script"||o==="foreignobject"||o==="iframe"||o==="embed"||o==="object"){i.removeChild(s);continue}for(let a of Array.from(s.attributes??[])){let l=a.name.toLowerCase(),c=a.value.trim().toLowerCase();(l.startsWith("on")||(l==="href"||l==="xlink:href"||l==="src")&&!c.startsWith("#")||l==="style"&&/url\(|expression\(|javascript:/.test(c))&&s.removeAttribute(a.name)}r(s)}};for(let i of Array.from(n.attributes??[]))i.name.toLowerCase().startsWith("on")&&n.removeAttribute(i.name);return r(n),new el.XMLSerializer().serializeToString(e)}var Ei=new TextDecoder;function KS(t){let e=s=>s<0?1:t.slice(0,s).split(`
484
+ `).length,n=t.search(/<!DOCTYPE/i);if(n>=0)return{found:"a <!DOCTYPE \u2026> line",fix:"Remove the <!DOCTYPE \u2026> line; an SVG needs none",line:e(n)};let r=t.search(/<!ENTITY/i);if(r>=0)return{found:"an <!ENTITY \u2026> declaration",fix:"Remove the <!ENTITY \u2026> declarations and write their text out where they are used",line:e(r)};let i=/<([A-Za-z][\w:.-]*)/.exec(t.replace(/<\?[\s\S]*?\?>|<!--[\s\S]*?-->/g,s=>" ".repeat(s.length)));return i&&i[1].toLowerCase()!=="svg"?{found:`an outer element <${i[1]}> rather than <svg>`,fix:"Save it as a plain SVG whose outer element is <svg>",line:e(i.index)}:{found:i?"markup that does not read as XML":"no <svg> element at all",fix:"Save it again from an editor as a plain SVG, and check that its tags are closed",line:1}}function YS(t,e){let n=/line (\d+) column (\d+)/.exec(e),r=/at position (\d+)/.exec(e),i=r?Number(r[1]):-1,s=1,o=1;if(n)s=Number(n[1]),o=Number(n[2]),i<0&&(i=t.split(`
485
+ `).slice(0,s-1).reduce((h,d)=>h+d.length+1,0)+o-1);else if(i>=0){let h=t.slice(0,i).split(`
486
+ `);s=h.length,o=h[h.length-1].length+1}let a=e.replace(/\s*(in JSON )?at position \d+.*$/,"").replace(/\s*\(line \d+ column \d+\)/,"").replace(/^JSON\.parse: /,"").trim()||"a mistake",l=i>0?t.slice(0,i).trimEnd().slice(-1):"",c=i>=0?t.slice(i).trimStart()[0]:void 0,u="Fix the JSON there: keys and text need double quotes, and nothing may follow the last item of a list or object";l===","&&(c==="}"||c==="]")?u="Remove that comma: JSON allows none after the last item":c==="'"?u='Use double quotes ("\u2026"), not single quotes':i>=t.trimEnd().length&&(u="The file ends too soon: close every { and [ it opens");let f=a.charAt(0).toLowerCase()+a.slice(1);return{why:`${l===","&&(c==="}"||c==="]")?`a comma just before \`${c}\``:c==="'"?"a single quote":c?`\`${c}\``:"the end of the file"} at line ${s} column ${o} (${f})`,line:s,col:o,fix:u}}function tl(t,e){let n=t.files.get("manifest.mkp"),r={file:`${t.label}/manifest.mkp`,line:1,col:1};if(!n){let f=[...t.files.keys()].filter(p=>p.endsWith("/manifest.mkp")).sort((p,h)=>p.length-h.length)[0];if(f){let p=f.slice(0,-13),h=t.origin==="zip"?`Zip the contents of the ${p} folder, not the folder itself, so manifest.mkp is at the top`:`Give ${t.label}/${p} as the pack instead, or move manifest.mkp to the top of ${t.label}`;e.error("mkp.pack-manifest",`${t.label} has no manifest.mkp at its top, the file that names a pack; found one in a folder inside it, at ${f}. ${h}`,{file:`${t.label}/${f}`,line:1,col:1})}else{let p=[...t.files.keys()].sort(),h=p.length?`only ${p.slice(0,3).join(", ")}${p.length>3?", \u2026":""}`:"no files at all";e.error("mkp.pack-manifest",`${t.label} has no manifest.mkp, the file that names a pack and what it provides; found ${h}. Add manifest.mkp at the top of the pack, e.g. pack notes@1 "What the pack holds." and, under it, requires core@1`,{file:`${t.label}/manifest.mkp`,line:1,col:1})}return null}let i=Ei.decode(n),o=_n(i,`${t.label}/manifest.mkp`,e).items.find(f=>f.item==="manifest");if(!o){let f=i.split(`
487
+ `),p=f.findIndex(g=>g.trim()&&!g.trim().startsWith("#")),h=p>=0?f[p].trim():"",d=h.length>60?h.slice(0,60)+"\u2026":h,m=/^[A-Za-z_][\w.-]*@\d+/.test(h)?`Add the word pack before it: pack ${d}`:/^(pack|profile)\b/.test(h)?'Write the name with its version, e.g. pack notes@1 "What the pack holds."':'Make the first line name the pack, e.g. pack notes@1 "What the pack holds."';return e.error("mkp.pack-manifest",`manifest.mkp must start with a line "pack name@N" (or "profile name@N" for a profile); found ${h?d:"no line at all"}. ${m}`,{...r,line:p>=0?p+1:1}),null}let a={name:o.name,version:o.version,about:o.about,kind:o.kind,requires:o.requires,depends:o.depends,provides:new Set(o.provides),manifest:o,files:[],fixtures:[],assets:new Map,documents:[],digest:"",label:t.label,manifestText:i};o.name!=="core"&&!o.requires.some(f=>f.startsWith("core@"))&&e.warn("mkp.pack-requires",`the manifest of pack ${o.name} should say requires core@1, since every pack builds on the base set; found ${o.requires.length?`requires ${o.requires.join(" ")}`:"no requires line"}. Add requires core@1 on the line under pack ${o.name}@${o.version}`,r);let l={},c=0,u=[];for(let[f,p]of[...t.files].sort(([h],[d])=>h<d?-1:1)){let h={file:`${t.label}/${f}`,line:1,col:1};if(!jf(f)){e.error("mkp.pack-path",`every file in a pack must sit inside it, at a relative path; found "${f}", ${Uy(f)}. Use a path inside the pack with / between folders, e.g. ${Wy(f)}`,h);continue}if(p.length>Si.file){e.error("mkp.pack-size",`a file in a pack may be at most 10 MB; found ${f} at ${Ai(p.length)}. Shrink it (e.g. compress the image or lower its resolution) or remove it from the pack`,h);continue}if(c+=p.length,u.push([f,p.length]),l[f]=Cr(f.endsWith(".mkp")?JS(p):p),f==="manifest.mkp")continue;let d=HS(f);if(f.endsWith(".fixture.json")){let m=Ei.decode(p);try{a.fixtures.push({path:f,json:JSON.parse(m)})}catch(g){let y=YS(m,g.message);e.error("mkp.fixture-json",`${f} is not valid JSON; found ${y.why}. ${y.fix}`,{...h,line:y.line,col:y.col})}}else if(f.endsWith(".mkp.md"))a.documents.push({path:f,text:Ei.decode(p)});else if(d==="mkp")a.files.push(_n(Ei.decode(p),`${t.label}/${f}`,e));else if(WS.has(d))if(d==="svg"){let m=Ei.decode(p),g=Gy(m);if(g===null){let y=KS(m);e.error("mkp.pack-svg",`${f} can't be used: a pack takes only plain SVGs, with an <svg> root and no DOCTYPE or entities; found ${y.found}. ${y.fix}`,{...h,line:y.line});continue}a.assets.set(f,eo(g))}else a.assets.set(f,p);else t.origin==="zip"?e.error("mkp.pack-file-type",`${f} can't go in a pack, which holds only ${zy}; found ${d?`a .${d} file`:"a file with no extension"}. Remove it from the zip`,h):/(^|\/)(README|LICENSE|CHANGELOG)(\.md|\.txt)?$/i.test(f)||e.warn("mkp.pack-file-type",`${f} is left out of the pack, which holds only ${zy} (and a README, LICENSE or CHANGELOG); found ${d?`a .${d} file`:"a file with no extension"}. Move it out of the pack folder, or leave it if it is only for you`,h)}return c>Si.pack&&e.error("mkp.pack-size",`${t.label} holds more than a pack may (at most 25 MB in all); found ${Ai(c)}, mostly ${Hy(u)}. Remove or shrink some of those files`,r),a.digest="sha256:"+Cr(Nr(l)),a}function Ky(t,e){let n=new Map([["manifest.mkp",eo(t.split(`
488
+
489
+ `)[0]+`
490
+ `)],["core.mkp",eo(t.split(`
491
+ `).slice(t.split(`
492
+
493
+ `)[0].split(`
494
+ `).length).join(`
495
+ `))]]),r=tl({label:"core",origin:"folder",files:n},e);return r.builtin=!0,r}function JS(t){let n=Ei.decode(t).split(`
496
+ `),r=n.findIndex(i=>i.trim()!=="");return r<0||!Xl.test(n[r].replace(/\r$/,""))?t:(n.splice(r,1),new TextEncoder().encode(n.join(`
497
+ `)))}var _f=["required","one-of","pattern","max-length","count","depth","first"];function Ir(t){let e=t.value.e;return e&&(e.k==="str"||e.k==="num")?String(e.v):e&&e.k==="id"?String(e.name):t.value.src}function Jy(t,e){switch(e.t){case"text":case"latex":return typeof t=="string";case"num":return typeof t=="number"&&(e.lo===void 0||t>=e.lo&&t<=e.hi);case"int":return typeof t=="number"&&Number.isInteger(t)&&(e.lo===void 0||t>=e.lo&&t<=e.hi);case"bool":return typeof t=="boolean";case"choice":return typeof t=="string"&&e.opts.includes(t);case"list":return Array.isArray(t)&&t.every(n=>Jy(n,e.of));default:return!0}}function to(t){return t==null?"nothing":typeof t=="string"?t===""?'""':t:Array.isArray(t)?t.length?`[${t.map(e=>typeof e=="string"?e:JSON.stringify(e)).join(", ")}]`:"[] (an empty list)":JSON.stringify(t)}function nl(t){switch(t.t){case"text":return"text";case"latex":return"LaTeX text";case"int":return t.lo!==void 0?`a whole number from ${t.lo} to ${t.hi}`:"a whole number";case"num":return t.lo!==void 0?`a number from ${t.lo} to ${t.hi}`:"a number";case"bool":return"true or false";case"choice":return`one of ${t.opts.join(", ")}`;case"list":return`a list of ${nl(t.of)}`;default:return N(t)}}function rl(t){switch(t.t){case"text":case"latex":return'"Some text"';case"int":return String(t.lo??2);case"num":return String(t.lo??1.5);case"bool":return"true";case"choice":return t.opts[0]??"\u2026";case"list":return`[${rl(t.of)}]`;default:return"\u2026"}}function qf(t){return t.length<2?t.join(""):`${t.slice(0,-1).join(", ")} or ${t[t.length-1]}`}function Ti(t){let[e,...n]=t.split("."),r=n.join(".");return e==="front"?`front matter ${r}`:e==="blocks"?`${r} blocks`:e==="roles"?`sections with {role=${r}}`:t}function Ot(t,e,n=`${e}s`){return`${t} ${t===1?e:n}`}function Yy(t){return t.node==="heading"?`the heading ${"#".repeat(Number(t.props?.level?.lit??1))} ${Zy(t)}`:t.node==="paragraph"?"a paragraph":t.node==="list"?"a list":t.node==="code"?"a code block":`a ${t.node} block`}function Zy(t){return t.props?.text?.text??"\u2026"}function Qy(t,e,n,r,i,s=()=>{}){let o=t.opts.profile,a=t.prog.packs.get(o),l={file:r,line:1,col:1},c=b=>(b.startsWith("front.")?s(b.slice(6)):void 0)??l;if(!a||a.kind!=="profile"){let b=[...t.prog.packs.values()].filter(v=>v.kind==="profile").map(v=>v.name),k=ue(o,b)??b[0],w=k?`or ask for a profile that was given (--profile ${k})`:"or check the document without --profile";a?i.error("mkp.profile",`${o} is a pack, not a profile, so a document can't be checked against it; found pack ${o}@${a.version} at the top of its manifest. Give the build the profile you mean (a pack whose manifest starts with "profile name@N"), ${w}`,l):i.error("mkp.profile",`the profile ${o} is not among the packs given to this build; found ${b.length?`only the profiles ${b.join(", ")}`:"no profile among them"}. Give the build the pack whose manifest starts with "profile ${o}@1" (--pack <its folder>), ${w}`,l);return}let u=a.manifest,f=t.prog.typeEnv(a.name);for(let b of u.front){if(!(b.name in e)){if(b.def){let w=b.def.e;e[b.name]=w?.k==="id"?w.name:w?.v}continue}let k=P(b.type,f);if(!Jy(e[b.name],k)){let w=e[b.name],v=(k.t==="text"||k.t==="latex")&&(typeof w=="number"||typeof w=="boolean")?`Quote it so it is read as text: ${b.name}: "${w}"`:`Write ${nl(k)}, e.g. ${b.name}: ${rl(k)}`,D=nl(k)===N(b.type)?"":` (the ${o} profile declares it ${N(b.type)})`;i.error("mkp.front-type",`front matter ${b.name} must be ${nl(k)}${D}; found ${to(w)}. ${v}`,s(b.name)??l)}}let p=u.front.map(b=>b.name);for(let b of Object.keys(e)){if(p.includes(b))continue;let k=ue(b,p);i.error("mkp.front-unknown",`the ${o} profile has no front-matter field ${b}; found ${b}: ${to(e[b])}. ${k?`Rename it to ${k} if that is what you meant, or remove the line`:"Remove the line"}, or declare the field in the profile's manifest (front ${b} text). Its fields are ${p.join(", ")||"none"}`,s(b)??l)}let h=[],d=new Map,m=new Map,g=new Map,y=b=>{for(let k of b){let w=k.pos?.[0]??1,v=k.meta?.role;if(v){if(!u.roles.includes(v)){let D=ue(v,u.roles)??u.roles[0],I=u.roles.length?`the section role ${v} is not one of the ${o} profile's roles (${u.roles.join(", ")}); found {role=${v}}. Write one of them, e.g. {role=${D}}, or add ${v} to the profile's roles line`:`the ${o} profile declares no section roles; found {role=${v}}. Remove {role=${v}}, or add a line "roles ${v}" to the profile's manifest`;i.error("mkp.role",I,{file:r,line:w,col:1})}h.push(v),d.set(v,[...d.get(v)??[],w])}k.meta?.summary!==void 0&&(m.set(k.node,(m.get(k.node)??0)+1),g.set(k.node,[...g.get(k.node)??[],w]));for(let[D,I]of Object.entries(k.meta?.attrs??{})){let L=P(u.attrs.find(T=>T.name===D).type,f);if(L.t==="choice"&&!L.opts.includes(I)){let T=ue(I,L.opts),G=T?`Write {${D}=${T}}`:L.opts.length<=3?`Write ${qf(L.opts.map(R=>`{${D}=${R}}`))}`:`Write one of them, e.g. {${D}=${L.opts[0]}}`;i.error("mkp.attr-type",`the block attribute ${D} takes one of ${L.opts.join(", ")}; found {${D}=${I}}. ${G}`,{file:r,line:w,col:1})}}k.children&&y(k.children)}};y(n);let $=b=>{let[k,w]=[b.split(".")[0],b.split(".").slice(1).join(".")];if(k==="front")return e[w];if(k==="blocks")return m.get(w)??0;if(k==="roles")return h.filter(v=>v===w).length};for(let b of u.rules){let k=$(b.path),[w,...v]=b.path.split("."),D=v.join("."),I=w==="front"?u.front.find(R=>R.name===D)?.type:void 0,L=`profile rule: ${b.rule} ${b.path}${b.args.length?" "+b.args.map(Ir).join(" "):""}`,T=(R,j,O,A=c(b.path))=>i.error(`mkp.rule.${b.rule}`,`${b.message??R} (${L}); found ${j}. ${O}`,A),G=R=>({file:r,line:R,col:1});switch(b.rule){case"depth":{let R=Number(b.args[0]?Ir(b.args[0]):NaN);for(let j of n){let O=Number(j.props?.level?.lit??2);if(j.node!=="heading"||!(O>R))continue;let A=Zy(j);T(`headings may go at most ${R} levels deep`,`${"#".repeat(O)} ${A}, a level-${O} heading`,`Use at most ${R} # (${"#".repeat(R)} ${A}), or make it bold text (**${A}**)`,G(j.pos?.[0]??1))}break}case"first":{let R=b.args[0]?Ir(b.args[0]):"heading",j=n.find(O=>O.node!=="controls");if(j&&j.node!==R){let O=n.find(_=>_.node===R),A=O?`Move ${Yy(O)} (line ${O.pos?.[0]??"?"}) above it, or add a ${R} at the top`:R==="heading"?`Add a heading at the top, e.g. # ${typeof e.title=="string"?e.title:"Title"}`:`Put a ${R} block at the top`;T(`the document must start with a ${R}`,`${Yy(j)} first`,A,G(j.pos?.[0]??1))}break}case"required":{if(!(k==null||k===""||Array.isArray(k)&&!k.length||k===0))break;let j=k==null?w==="front"?`no ${D} in the front matter`:"nothing":Array.isArray(k)?`${D}: [] (an empty list)`:k===""?`${D}: "" (empty)`:`no ${Ti(b.path)}`,O=w==="front"?Array.isArray(k)?`Give at least one item, e.g. ${D}: ${I?rl(P(I,f)):"[\u2026]"}`:`Add it to the front matter, e.g. ${D}: ${I?rl(P(I,f)):"\u2026"}`:w==="roles"?`Add a section with {role=${D}}: a heading, then {role=${D}} on the line under it`:w==="blocks"?`Add a \`\`\`${D} block to the document`:`Give ${b.path} a value`;T(`${Ti(b.path)} is required`,j,O);break}case"one-of":{let R=b.args.map(Ir);if(k!==void 0&&!R.includes(String(k))){let j=ue(String(k),R),O=w==="front"?`${D}: `:"",A=j?`Write ${O}${j}`:R.length<=3?`Write ${qf(R.map(_=>O+_))}`:`Write one of ${R.join(", ")}, e.g. ${O}${R[0]}`;T(`${Ti(b.path)} must be ${qf(R)}`,to(k),A)}break}case"pattern":{let R=b.args[0]?Ir(b.args[0]):"",j=null;try{j=new RegExp(R)}catch(O){let A=String(O.message).replace(/^.*: /,"");i.error("mkp.profile",`the pattern rule on ${b.path} in the ${o} profile is not a valid regular expression; found "${R}" (${A.toLowerCase()}). Correct the pattern on that rule line, e.g. rule pattern ${b.path} "^[a-z-]+$"`,b.p??l)}if(j&&k!==void 0){let O=(Array.isArray(k)?k:[k]).find(A=>!j.test(String(A)));if(O!==void 0){let A=String(O).trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),_=w==="front"?`${D}: `:"",W=A&&A!==String(O)&&j.test(A)?`Change it so it matches ${R}, e.g. ${_}${A}`:`Change it so it matches the pattern ${R}`;T(`${Ti(b.path)} must match the pattern ${R}`,`${to(O)}, which does not match`,W)}}break}case"max-length":{let R=Number(b.args[0]?Ir(b.args[0]):NaN),j=typeof k=="string"||Array.isArray(k)?k.length:0;if(j>R){let O=Array.isArray(k)?`${Ot(j,"item")} in ${D}`:`${to(k)}, ${Ot(j,"character")} long`,A=Array.isArray(k)?`Remove ${Ot(j-R,"item")} so at most ${R} remain`:`Shorten it to ${Ot(R,"character")} or fewer`;T(`${Ti(b.path)} may be at most ${Array.isArray(k)?Ot(R,"item"):Ot(R,"character")} long`,O,A)}break}case"count":{let R=b.args[0],j=typeof k=="number"?k:Array.isArray(k)?k.length:k===void 0?0:1,O,A;if(R&&R.value.v==="range")O=Number(R.value.lo.v??0),A=Number(R.value.hi.v??1/0);else if(R)O=A=Number(Ir(R));else break;if(j>=O&&j<=A)break;let _=O===A?`exactly ${O}`:A===1/0?`at least ${O}`:`${O} to ${A}`,W=w==="roles"?d.get(D)??[]:w==="blocks"?g.get(D)??[]:[],Y,q=c(b.path);if(j<O){let x=O-j;Y=w==="roles"?`Add ${Ot(x,"more section")} with {role=${D}}: a heading, then {role=${D}} on the line under it`:w==="blocks"?`Add ${Ot(x,`more \`\`\`${D} block`)}`:`Add ${Ot(x,"more item")} to ${D}`,W.length&&(q=G(W[W.length-1]))}else{let x=j-A;Y=w==="roles"?`Remove {role=${D}} from ${Ot(x,"section")}`:w==="blocks"?`Remove ${Ot(x,`\`\`\`${D} block`)}`:`Remove ${Ot(x,"item")} from ${D}`,W[A]!==void 0&&(q=G(W[A]))}T(`the document needs ${_} ${Ti(b.path)}`,String(j),Y,q);break}default:{let R=ue(b.rule,_f)??_f.find(j=>j.includes(b.rule)||b.rule.includes(j));i.error("mkp.profile",`the ${o} profile has a rule named ${b.rule}, which MKP does not know; found rule ${b.rule} ${b.path}. ${R?`Write rule ${R} ${b.path} \u2026 instead, or use`:"Use"} one of ${_f.join(", ")}`,b.p??l)}}}}var ZS=Li(As(),1);var Ff=/^[A-Za-z_][A-Za-z0-9_]*$/,QS={t:"bool"};function Rr(t){let e=0;for(let n=0;n<t.length;n++){let r=t[n];if(r==='"'||r==="$"){let i=r;for(n++;n<t.length&&t[n]!==i;)n+=t[n]==="\\"?2:1;continue}if(r==="("||r==="["||r==="{")e++;else if(r===")"||r==="]"||r==="}")e--;else if(r===" "&&e===0)return`(${t})`}return t.startsWith("-")&&!/^-[\d.]+$/.test(t)?`(${t})`:t}function Di(t,e=!1,n,r){let i=n&&r?P(n,r):n;if(typeof t=="number")return Number.isFinite(t)?String(t):Number.isNaN(t)?"nan":t>0?"inf":"-inf";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return(i?.t==="token"||i?.t==="choice")&&Ff.test(t)?t:Oe(t);if(Array.isArray(t)){if((e||i?.t==="point")&&t.length===2&&t.every(o=>typeof o=="number"))return`(${Di(t[0])}, ${Di(t[1])})`;let s=i?.t==="list"?i.of:void 0;return`[${t.map(o=>Di(o,!1,s,r)).join(", ")}]`}if(t&&typeof t=="object"){let s=Object.entries(t),o=i?.t==="rec"?i.fields:void 0;return s.length?`{${s.map(([a,l])=>`${a}: ${Di(l,!1,o?.find(c=>c[0]===a)?.[1]??(i?.t==="dict"?i.of:void 0),r)}`).join(", ")}}`:"{}"}return"0"}function ek(t){return t%1e3===0?`${t/1e3}s`:`${t}ms`}function Xy(t){return"ast"in t&&"expr"in t}function Te(t,e,n){if("lit"in t)return typeof t.lit=="string"&&(e?.t==="choice"||!e&&Ff.test(t.lit))?t.lit:e?.t==="text"&&typeof t.lit=="string"?Oe(t.lit):e?.t==="list"&&e.of.t==="named"&&e.of.name==="track"&&Array.isArray(t.lit)?`[${t.lit.join(", ")}]`:Di(t.lit,e?.t==="point",e,n);if(Xy(t))return Rr(t.expr);if("text"in t)return Oe(t.text);if("tex"in t)return t.display?`$$${t.tex}$$`:`$${t.tex}$`;if("tok"in t)return t.tok;if("ref"in t)return t.ref;if("ms"in t)return ek(t.ms);if("range"in t){let r=i=>{let s="lit"in i?Di(i.lit):Xy(i)?i.expr:Te(i);return/^-?[\d.]+(e-?\d+)?$/.test(s)?s:`(${s})`};return`${r(t.range[0])}..${r(t.range[1])}`}return""}function Dn(t,e){return(t??[]).map(n=>`${e}# ${n}`.trimEnd())}var no=class{constructor(e){this.ctx=e}def(e){let n=[...Dn(e.comment,"")],r=e.kind==="widget"?"":`${e.kind} `,i=e.params?.length?` of ${e.params.join(", ")}`:"";n.push(`${r}${e.name}${e.inline?"":`@${e.version}`}${i}${e.about!==void 0?" "+Oe(e.about):""}`);let s=" ";e.implements?.length&&n.push(`${s}implements ${e.implements.map(o=>o.slice(o.indexOf(":")+1)).join(" ")}`);for(let o of e.requires??[])n.push(`${s}requires ${o}`);e.budget&&n.push(`${s}budget ${e.budget}`),e.deprecated!==void 0&&n.push(`${s}deprecated ${Oe(e.deprecated)}`),e.fields?.length&&n.push(`${s}fields ${e.fields.join(" ")}`);for(let o of e.inputs)n.push(...Dn(o.comment,s)),n.push(`${s}in ${o.name} ${N(o.type)}${o.answer?" answer":""}${o.default?` = ${Te(o.default,o.type.t==="list"&&o.type.of.t==="named"&&o.type.of.name==="track"?o.type:P(o.type,this.ctx.env),this.ctx.env)}`:""}${o.about!==void 0?" "+Oe(o.about):""}`);for(let o of e.outs??[])n.push(...Dn(o.comment,s),`${s}out ${o.name}${o.payload?" "+N(o.payload):""}${o.about!==void 0?" "+Oe(o.about):""}`);for(let o of e.signals??[])n.push(...Dn(o.comment,s),`${s}signal ${o.name} ${N(o.payload)}${o.about!==void 0?" "+Oe(o.about):""}`);for(let o of e.values??[])n.push(...this.value(o,s));for(let o of e.commands??[]){n.push(...Dn(o.comment,s),`${s}command ${o.name}${o.payload?" "+N(o.payload):""}${o.about!==void 0?" "+Oe(o.about):""}`);for(let a of o.actions)n.push(`${s} ${this.action(a)}`)}for(let o of e.view??[])n.push(...this.node(o,s,null));return e.project?.md&&n.push(`${s}project md = ${e.project.md.expr}`),e.project?.mermaid&&n.push(`${s}project mermaid = ${e.project.mermaid.expr}`),n.join(`
498
+ `)}value(e,n){let r=Dn(e.comment,n);switch(e.k){case"host":return[...r,`${n}host ${e.name} ${N(e.type)} = ${Te(e.default,P(e.type,this.ctx.env))}${e.about!==void 0?" "+Oe(e.about):""}`];case"var":return[...r,`${n}var ${e.name} ${N(e.type)} = ${Te(e.default,P(e.type,this.ctx.env))}${e.about!==void 0?" "+Oe(e.about):""}`];case"derived":return[...r,`${n}${e.name} = ${e.value.expr}`];case"fn":return[...r,`${n}fn ${e.name}(${e.params.map(i=>i.type?`${i.name}: ${N(i.type)}`:i.name).join(", ")})${e.ret?": "+N(e.ret):""} = ${e.body}`];case"state":return[...r,...this.state(e,n)]}}state(e,n){let r=[];switch(e.control){case"slider":r.push("slider",Te({range:[e.args.min,e.args.max]})),e.args.step&&r.push(`step=${Te(e.args.step)}`);break;case"choice":r.push(`choice(${(e.args.opts.lit??[]).join("|")})`);break;case"toggle":r.push("toggle");break;case"steps":r.push("steps",Te(e.args.n)),e.args.none&&"lit"in e.args.none&&e.args.none.lit&&r.push("none=true"),e.args.track&&"lit"in e.args.track&&e.args.track.lit&&r.push("track=true");break;case"clock":r.push("clock");break;case"drag":r.push("drag",`x=${Te(e.args.x)}`,`y=${Te(e.args.y)}`);break}e.play&&r.push(`play=${ek(e.play)}${e.playPer?"/step":""}`),e.loop&&r.push(`loop=${e.loop}`),e.default&&r.push("=",Te(e.default,e.type)),e.label!==void 0&&r.push(Oe(e.label));let i=[`${n}${e.name} = ${r.join(" ")}`];for(let[s,o]of Object.entries(e.on??{}))i.push(...this.eventLines(s,o,`${n} `));return i}action(e){let n=r=>typeof r=="string"?r:`(${r.expr})`;switch(e.a){case"set":return`set ${e.name}=${Rr(e.value.expr)}`;case"play":case"pause":return`${e.a} ${e.name}`;case"reset":return["reset",...e.names].join(" ");case"reveal":case"hide":case"open":case"close":return`${e.a} ${n(e.id)}`;case"emit":case"send":return[e.a,e.name,...e.payload.map(([r,i])=>`${r}=${Rr(i.expr)}`)].join(" ");case"when":return`${e.actions.map(r=>this.action(r)).join(" ")} if=${Rr(e.cond.expr)}`}}eventLines(e,n,r){let i=[],s=[],o=()=>{s.length&&i.push(`${r}@${e} ${s.map(a=>this.action(a)).join(" ")}`),s=[]};for(let a of n)a.a==="when"?(o(),i.push(`${r}@${e} ${this.action(a)}`)):s.push(a);return o(),i}sigOf(e){return e.def?this.ctx.defs[e.def]:void 0}recordTypes(e){let n=new Map;for(let r of e?.inputs??[]){let i=P(r.type,this.ctx.env);i.t==="records"&&n.set(i.kind,i)}return n}args(e,n,r,i){let s=[],o={...e??{}};if(i)for(let[a,l]of Object.entries(i))o[a]&&Te(o[a],r.get(a))===l.trim()&&delete o[a];for(let a of n){let l=o[a];if(!l)break;let c=r.get(a)?P(r.get(a),this.ctx.env):void 0;if("tok"in l||"ref"in l||c?.t==="bool"||c?.t==="choice")break;let u=Te(l,c,this.ctx.env);Ff.test(u)&&(u=`(${u})`),s.push(u),delete o[a]}for(let[a,l]of Object.entries(o)){let c=r.get(a),u=c&&!(c.t==="list"&&c.of.t==="named"&&c.of.name==="track")?P(c,this.ctx.env):c;s.push(`${a}=${Te(l,u,this.ctx.env)}`)}return s}meta(e){let n=e.meta;if(!n)return[];let r=[];return n.id!==void 0&&r.push(typeof n.id=="string"?`id=${n.id}`:`id=(${n.id.expr})`),n.if&&r.push(`if=(${n.if.expr})`),n.hidden&&r.push("hidden"),n.grow&&r.push("grow"),n.basis&&r.push(`basis=${n.basis}`),n.span&&r.push(`span=${Te(n.span)}`),n.self&&r.push(`self=${n.self}`),n.keep&&r.push(`keep=${Te(n.keep,QS)}`),r}node(e,n,r){let i=[...Dn(e.meta?.comment,n)],s=f=>`${n}${f.filter(Boolean).join(" ")}`,o=(f,p)=>(f??[]).flatMap(h=>this.node(h,n+" ",p));switch(e.node){case"each":return i.push(s(["each",e.var,"in",Te(e.in),e.key?`key=${Rr(e.key.expr)}`:""])),i.push(...o(e.records,r),...o(e.children,r)),i;case"switch":{i.push(s(["switch",`on=${Rr(e.subject.expr)}`]));for(let f of e.cases??[])i.push(`${n} case ${Te(f.value,e.subject.type)}`),i.push(...f.children.flatMap(p=>this.node(p,n+" ",r)));return e.else&&(i.push(`${n} else`),i.push(...e.else.flatMap(f=>this.node(f,n+" ",r)))),i}case"slot":return i.push(s(["slot",Rr(e.value.expr)])),i;case"controls":return i.push(s(["controls",...e.names??[]])),i;case"arrow":return i.push(s(["arrow",`from=${Te(e.from)}`,`to=${Te(e.to)}`,e.label?"text"in e.label&&!("ast"in e.label)?Te(e.label,{t:"text"}):`label=${Te(e.label,{t:"text"})}`:"",e.via?`via=${Te(e.via)}`:"",e.route?`route=${Te(e.route)}`:"",...Object.entries(e.look??{}).map(([f,p])=>`${f}=${Te(p)}`),e.curve?"curve":"",...this.meta(e)])),i;case"$record":{let f=r?.get(e.record),p=new Map(f?.fields??[]),h=(f?.fields??[]).filter(([,m])=>P(m,this.ctx.env).t!=="records").map(([m])=>m);i.push(s([e.record,...this.args(e.props,h,p,f?.defaults),...this.meta(e)]));let d=new Map;for(let[,m]of f?.fields??[]){let g=P(m,this.ctx.env);g.t==="records"&&d.set(g.kind,g)}return i.push(...o(e.records,d),...o(e.children,null)),i}}let a=this.sigOf(e),l=new Map((a?.inputs??[]).map(f=>[f.name,f.type])),c=a&&a.version>1?`${e.node}@${a.version}`:e.node;i.push(s([c,...this.args(e.props,a?.fields??[],l),...this.meta(e)]));let u=this.recordTypes(a);i.push(...o(e.records,u),...o(e.children,null));for(let[f,p]of Object.entries(e.fills??{}))i.push(`${n} fill ${f}`),i.push(...p.flatMap(h=>this.node(h,n+" ",null)));for(let[f,p]of Object.entries(e.on??{}))i.push(...this.eventLines(f,p,`${n} `));return i}};function il(t,e,n,r){let i=En,s=o=>o.length?{comment:o}:{};return t.items.map(o=>{switch(o.item){case"def":return{def:e.get(`${n}:${o.name}@${o.version}`)};case"type":return{type:o.name,of:o.type,...s(o.comments)};case"fn":case"op":return{fn:o.item==="op"?o.symbol:o.name,params:o.params.map(a=>a.type?{name:a.name,type:a.type}:{name:a.name}),ret:o.ret,body:i(o.src),op:o.item==="op"||void 0,...s(o.comments)};case"const":return{const:o.name,type:o.type,expr:i(o.src),...s(o.comments)};case"macro":return{macro:o.name,tex:o.tex,...s(o.comments)};case"tokens":return{tokens:r(o.name),...s(o.comments)};case"interface":return{iface:o};case"migrate":return{migrate:{from:o.from,to:o.to,lines:o.lines.map(a=>a.k==="rename"?{k:a.k,from:a.from,to:a.to}:a.k==="drop"?{k:a.k,name:a.name,why:a.why}:a.k==="map"?{k:a.k,name:a.name,values:a.values}:{k:a.k,name:a.name,value:a.value.src,why:a.why})},...s(o.comments)};case"manifest":return{pack:{kind:o.kind,name:o.name,version:o.version,about:o.about,requires:o.requires,depends:o.depends,provides:o.provides,front:o.front.map(a=>({name:a.name,type:a.type,def:a.def?.src,about:a.about})),attrs:o.attrs.map(a=>({name:a.name,type:a.type,about:a.about})),roles:o.roles,rules:o.rules.map(a=>({rule:a.rule,path:a.path,args:a.args.map(l=>l.value.src),message:a.message})),...o.unpublished?{unpublished:!0}:{}},...s(o.comments)}}})}function XS(t){let e=[],n=r=>typeof r=="string"?Oe(r):String(r);for(let[r,i]of Object.entries(t.tokens)){let s=Object.entries(i);if(s.every(([,a])=>Object.keys(a).length===1&&"value"in a&&typeof a.value!="string")&&r!=="color"&&r!=="font"&&r!=="shadow"){e.push(` ${r} ${s.map(([a,l])=>`${a}=${n(l.value)}`).join(" ")}`);continue}for(let[a,l]of s){let c=Object.entries(l).filter(([u])=>u!=="value").map(([u,f])=>`${u}=${n(f)}`);e.push(` ${r} ${a}${"value"in l?" "+n(l.value):""}${c.length?" "+c.join(" "):""}`)}}return e}function Bf(t,e){let n=new no(e);return t.map(i=>{let s="comment"in i&&i.comment?Dn(i.comment,""):[];if("def"in i)return n.def(i.def);if("const"in i)return[...s,`const ${i.const}${i.type?": "+N(i.type):""} = ${i.expr}`].join(`
499
+ `);if("fn"in i)return[...s,`${i.op?"op":"fn"} ${i.fn}(${i.params.map(l=>l.type?`${l.name}: ${N(l.type)}`:l.name).join(", ")})${i.ret?": "+N(i.ret):""} = ${i.body}`].join(`
500
+ `);if("type"in i)return[...s,`type ${i.type} = ${N(i.of)}`].join(`
501
+ `);if("macro"in i)return[...s,`macro ${i.macro} = $${i.tex}$`].join(`
502
+ `);if("tokens"in i)return[...s,`tokens ${i.tokens.name}@${i.tokens.version}${i.tokens.about!==void 0?" "+Oe(i.tokens.about):""}`,...XS(i.tokens)].join(`
503
+ `);if("migrate"in i){let l=i.migrate;return[...s,`migrate ${l.from} -> ${l.to}`,...l.lines.map(c=>c.k==="rename"?` rename ${c.from} -> ${c.to}`:c.k==="drop"?` drop ${c.name} ${Oe(c.why)}`:c.k==="map"?` map ${c.name}: ${c.values.map(([u,f])=>`${u} -> ${f}`).join(", ")}`:` keep ${c.name} = ${c.value} ${Oe(c.why)}`)].join(`
504
+ `)}if("iface"in i){let l=i.iface,c=[...Dn(l.comments,""),`interface ${l.name}@${l.version}${l.about!==void 0?" "+Oe(l.about):""}`];for(let u of l.inputs)c.push(` in ${u.name} ${N(u.type)}`);for(let u of l.hosts)c.push(` host ${u.name} ${N(u.type)}`);for(let u of l.signals)c.push(` signal ${u.name} ${N(u.payload)}`);for(let u of l.outs)c.push(` out ${u.name}${u.payload?" "+N(u.payload):""}`);return l.project&&c.push(" project md"),c.join(`
505
+ `)}let o=i.pack,a=[...s,`${o.kind} ${o.name}@${o.version}${o.about!==void 0?" "+Oe(o.about):""}`];o.requires.length&&a.push(` requires ${o.requires.join(" ")}`),o.depends.length&&a.push(` depends ${o.depends.join(" ")}`),o.provides.length&&a.push(` provides ${o.provides.join(" ")}`);for(let l of o.front)a.push(` front ${l.name} ${N(l.type)}${l.def?" = "+l.def:""}${l.about!==void 0?" "+Oe(l.about):""}`);for(let l of o.attrs)a.push(` attr ${l.name} ${N(l.type)}${l.about!==void 0?" "+Oe(l.about):""}`);o.roles.length&&a.push(` roles ${o.roles.join(" ")}`);for(let l of o.rules)a.push(` rule ${l.rule} ${l.path}${l.args.length?" "+l.args.join(" "):""}${l.message!==void 0?" "+Oe(l.message):""}`);return o.unpublished&&a.push(" unpublished"),a.join(`
506
+ `)}).join(`
507
+
508
+ `)+`
509
+ `}var tk=new Set(["each","switch","case","else","slot","fill","controls","arrow"]);function Vf(t,e,n){let r={...t.manifest.p,col:1},i=(t.manifestText??"").split(`
510
+ `);for(let s=0;s<i.length;s++){let o=[...i[s].matchAll(/\S+/g)];if(o[0]?.[0]!==e)continue;let a=n===void 0?o[0]:o.slice(1).find(l=>l[0]===n);if(a)return{file:r.file,line:s+1,col:(a.index??0)+1}}return r}function nk(t){return t.slice(t.indexOf(":")+1).replace(/@\d+$/,"")}var sl=class{constructor(e,n,r){this.prog=e;this.diags=n;this.opts=r}defs=new Map;sigs=new Map;tokens=[];lock={packs:[],defs:{}};moves=[];lockedFn(){let e=Object.keys(this.opts.lock?.defs??{});return n=>{let r=n.includes(":")?n.slice(n.indexOf(":")+1):n,i=e.filter(s=>s.slice(s.indexOf(":")+1).replace(/@\d+$/,"")===r&&(!n.includes(":")||s.startsWith(n.slice(0,n.indexOf(":")+1))));return i.length===1?i[0]:void 0}}tokenNameFn(){let e=Eo(this.tokens);return n=>e.get(n)??new Set}document(e,n,r=this.diags,i={}){let s=r.errors.length,o=this.opts.profile?this.prog.packs.get(this.opts.profile):void 0,a=new Set(o?.kind==="profile"?o.manifest.attrs.map(f=>f.name):[]),l=Cs(this.prog,e,n,r,{tokenNames:this.tokenNameFn(),sigs:this.sigs,allowParts:i.allowParts,locked:this.lockedFn(),blockAttrs:a,docFile:i.docFile,privateOf:i.privateOf});if(this.opts.profile&&Qy(this,l.front,l.body,n,r,l.frontAt),r.errors.length>s)return null;let c={file:n,front:l.front,body:l.body};c.digest=ol({front:c.front,body:Ni(c.body)});let u=new Map(l.defs.map(f=>[f.id,f]));ik(u);for(let f of u.values())f.digest=ol(Ni({...f,fns:f.fns}));return this.bundle(c,l.def,{prog:l.prog,defs:u})}documentDefs(e,n,r={}){let i=new Tt,s=Cs(this.prog,e,n,i,{tokenNames:this.tokenNameFn(),sigs:this.sigs,locked:this.lockedFn(),docFile:r.docFile}),o=s.prog.packs.get(Qe);if(!i.ok||!o||o===this.prog.packs.get(Qe)||!o.files.length)return null;let a=new Map([...this.defs,...s.defs.map(c=>[c.id,c])]),l={defs:Object.fromEntries(a),env:s.prog.typeEnv(Qe)};return o.files.map(c=>Bf(il(c,a,Qe,()=>{}),l)).join(`
511
+ `)}documentItems(e,n,r={}){let i=new Tt,s=Cs(this.prog,e,n,i,{tokenNames:this.tokenNameFn(),sigs:this.sigs,locked:this.lockedFn(),docFile:r.docFile}),o=s.prog.packs.get(Qe);if(!i.ok||!o||o===this.prog.packs.get(Qe)||!o.files.length)return null;let a=new Map([...this.defs,...s.defs.map(l=>[l.id,l])]);return{items:o.files.map(l=>il(l,a,Qe,()=>{})),defs:a,env:s.prog.typeEnv(Qe)}}bundle(e,n,r){let i=r?.prog??this.prog,s=w=>r?.defs.get(w)??this.defs.get(w),o={},a={},l={},c=[],u=new Set,f=w=>{if(!(!w||typeof w!="object")){if((w.t==="call"||w.t==="fnref")&&!u.has(w.fn)){u.add(w.fn);let v=i.irFns[w.fn];v&&(a[w.fn]=v,f(v.body))}if(w.t==="var"&&w.from==="const"&&!l[w.name]){let v=i.irConsts[w.name];v&&(l[w.name]=v,f(v.ast))}if(w.t==="tmpl")for(let v of w.show)v&&!u.has(v)&&f({t:"fnref",fn:v});for(let v of Object.values(w))Array.isArray(v)?v.forEach(D=>D&&typeof D=="object"&&f(D)):v&&typeof v=="object"&&"t"in v&&f(v)}},p=w=>{if(!w||typeof w!="object")return;if(Array.isArray(w))return w.forEach(p);let v=w;"ast"in v&&v.ast&&typeof v.ast=="object"&&f(v.ast),typeof v.def=="string"&&!o[v.def]&&s(v.def)&&c.push(v.def);for(let D of Object.values(v))D&&typeof D=="object"&&p(D)};for(p(e.body),p(n);c.length;){let w=c.pop();if(o[w])continue;let v=s(w);o[w]=v,p(v);for(let D of Object.values(v.fns??{}))f(D.body)}o[n.id]=n,rk(e.body,o);for(let w of Object.values(n.fns??{}))f(w.body);let h={};for(let[w,v]of i.types)h[w]=v.type;let d=new Set(["core@1"]),m={signals:[],hosts:[],commands:[],implements:[]};for(let w of Object.values(o)){for(let v of w.requires??[])d.add(v);for(let v of w.signals??[])m.signals.push({def:w.id,name:v.name,payload:v.payload});for(let v of w.values??[])v.k==="host"&&m.hosts.push({def:w.id,name:v.name,type:v.type,default:v.default});for(let v of w.commands??[])m.commands.push({def:w.id,name:v.name,payload:v.payload});for(let v of w.implements??[])m.implements.push({def:w.id,iface:v})}nA(e.body,o);let g={};for(let[w,v]of i.macros)g[w]=v.tex;let y={};for(let w of Object.keys(o))this.lock.defs[w]&&(y[w]=this.lock.defs[w]);let $=new Set(Object.values(o).map(w=>w.pack)),b=tA(i,$,[e.body,...Object.values(o)]),k=Object.fromEntries(Object.entries(b).map(([w,v])=>[w,v.digest]));return{ir:1,mkp:Et,level:"bundle",doc:e,defs:o,fns:a,consts:l,types:h,tokens:this.tokens,macros:g,capabilities:[...d].sort(),interface:m,lock:{mkp:Et,packs:this.lock.packs.filter(w=>$.has(w.pack)||w.pack==="core"),defs:y,...Object.keys(k).length?{assets:k}:{}},profile:this.opts.profile,...Object.keys(b).length?{assets:b}:{}}}},eA={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp"};function tA(t,e,n){let r=new Set,i=o=>{if(typeof o=="string")r.add(o);else if(Array.isArray(o))o.forEach(i);else if(o&&typeof o=="object")for(let a of Object.values(o))i(a)};n.forEach(i);let s={};for(let o of[...e].sort())for(let[a,l]of[...t.packs.get(o)?.assets??[]].sort(([c],[u])=>c<u?-1:1)){let c=eA[a.slice(a.lastIndexOf(".")+1).toLowerCase()];if(!c||!r.has(a))continue;let u=c==="image/svg+xml";s[`${o}/${a}`]={type:c,digest:"sha256:"+Cr(l),data:u?new TextDecoder().decode(l):$o(l),...u?{}:{base64:!0}}}return s}function ol(t){return"sha256:"+Cr(Nr(t))}function Ni(t){if(Array.isArray(t))return t.map(Ni);if(!t||typeof t!="object")return t;let e={};for(let[n,r]of Object.entries(t))n==="pos"||n==="file"||n==="digest"||(e[n]=Ni(r));return e}function zf(t){let e=new Tt,n=new ja(e),r=Ky(pc,e);n.addPack(r);let i=[];for(let u of t.packs)try{let f=u.zip?Pf(u.zip,u.label,e):{label:u.label,origin:"folder",files:u.files??new Map};if(!f)continue;let p=tl(f,e);if(!p)continue;if(p.name==="core"){e.error("mkp.pack-reserved",`the pack name core is taken by MKP's own base set of widgets; found pack core@${p.version} in its manifest. Rename the pack, e.g. pack mywidgets@${p.version}, and keep its requires core@1 line`,{...p.manifest.p,col:1});continue}i.push(p),n.addPack(p)}catch(f){if(f instanceof K)e.add(f.diagnostic);else throw f}let s=new sl(n,e,t),o=new Set(t.capabilities??["core@1","gfx@1"]);for(let u of n.packs.values()){for(let p of u.depends){let h=Vf(u,"depends",p),d=/^(.+)@(\d+)$/.exec(p),m=d&&n.packs.get(d[1]);d?m?m.version<Number(d[2])&&e.error("mkp.pack-depends",`pack ${u.name} depends on ${p}, but the ${m.name} pack given to this build is ${m.name}@${m.version}; found depends ${p}. Give the build ${p} or later, or write depends ${m.name}@${m.version} if ${u.name} works with it`,h):e.error("mkp.pack-depends",`pack ${u.name} depends on ${p}, which is not among the packs given to this build; found depends ${p}. Give the build the ${d[1]} pack too (--pack <its folder>), or remove ${p} from the depends line if ${u.name} does not use it`,h):e.error("mkp.pack-depends",`pack ${u.name} must name each pack it depends on as name@N; found depends ${p}. Write the version it needs, e.g. depends ${p}@1`,h)}for(let p of u.requires){if(/^(core|gfx)@1$/.test(p))continue;let h=/^(core|gfx)(@\d+)?$/.test(p)?`Write ${p.replace(/@\d+$/,"")}@1`:`Remove ${p} from the requires line`;e.error("mkp.capability",`pack ${u.name} requires ${p}, which is not a capability MKP knows (a feature the page's provider must have: core@1, or gfx@1 for pixels and 3D); found requires ${p}. ${h}`,Vf(u,"requires",p))}let f=[...[...n.defs.values()].filter(p=>p.pack===u.name).map(p=>p.syn.name),...[...n.ifaces.values()].filter(p=>p.pack===u.name).map(p=>p.syn.name),...[...n.types.values()].filter(p=>p.pack===u.name).map(p=>p.name),...[...n.fns.entries()].filter(([,p])=>p.some(h=>h.pack===u.name)).map(([p])=>p),...[...n.consts.entries()].filter(([,p])=>p.some(h=>h.pack===u.name)).map(([p])=>p),...n.tokenSets.filter(p=>p.pack===u.name).map(p=>p.syn.name)];for(let p of u.provides){if(f.includes(p))continue;let h=p.replace(/,+$/,""),d=h!==p&&(f.includes(h)||!h)?`Separate the names with spaces, not commas: provides ${[...u.provides].map(g=>g.replace(/,+$/,"")).filter(Boolean).join(" ")}`:ue(p,f)?`Correct it to ${ue(p,f)}, or remove it from the provides line`:`Remove ${p} from the provides line, or add a definition named ${p} to the pack, e.g. ${p}@1 "What it shows."`,m=/^[A-Za-z_][\w.-]*$/.test(p)?p:`"${p}"`;e.error("mkp.pack-provides",`pack ${u.name} provides ${m}, but nothing in the pack has that name (no widget, part, interface, type, fn, constant or token set); found provides ${m}. ${d}`,Vf(u,"provides",p))}}let a=new Map;for(let u of n.packs.values())if(!u.builtin)for(let f of u.provides)!n.defs.has(`${u.name}:${f}@1`)&&![...n.defs.values()].some(p=>p.pack===u.name&&p.syn.name===f)||a.set(f,[...a.get(f)??[],u.name]);let l=(u,f)=>[...n.defs.values()].find(p=>p.pack===u&&p.syn.name===f);for(let[u,f]of a){let p=l(f[0],u);if(f.length>1){let d=f.length===2?`two packs, ${f.join(" and ")}`:`${f.length} packs, ${f.join(", ")}`;e.warn("mkp.name-clash",`${u} is provided by ${d}, so a bare ${u} could mean either; found provides ${u} in each manifest. Wherever ${u} is used, write its pack before it, e.g. ${f[0]}:${u} (a block opens with \`\`\`${f[0]}:${u}), or rename one of them`,l(f[f.length-1],u)?.syn.p)}let h=`${u}@${p?.syn.version??1} in pack ${f.join(", ")}`;n.lookupDefs(u,"$none").some(d=>d.pack==="core")&&e.error("mkp.reserved",`${u} is the name of a base widget, so a pack's widget may not be called ${u}; found ${h}. Rename the widget and its provides entry, e.g. my${u}@1 and provides my${u}`,p?.syn.p),tk.has(u)&&e.error("mkp.reserved",`${u} is a word MKP itself uses in views (${[...tk].join(", ")}), so a widget may not be called ${u}; found ${h}. Rename the widget and its provides entry, e.g. my${u}@1 and provides my${u}`,p?.syn.p)}s.tokens=n.tokenSets.map(u=>mc(u.syn,u.pack,e)),ch(s.tokens,e),n.tokenNames=s.tokenNameFn();let c=[];for(let u of n.defs.values())s.sigs.set(u.id,Ds(n,u));for(let u of n.defs.values()){let f=new un(n,u,e,{tokenNames:s.tokenNameFn(),sigs:s.sigs,locked:s.lockedFn()});try{let p=f.check();s.defs.set(u.id,p),c.push(f);for(let h of p.requires??[]){if(o.has(h))continue;let m=/^(core|gfx)@1$/.test(h)?`which the target provider lacks (it has ${[...o].join(", ")})`:"which is not a capability MKP knows (core@1, gfx@1)";e.warn("mkp.capability-fallback",`${u.syn.name} requires ${h}, ${m}, so the page shows the block's summary: text in its place; found requires ${h}. Remove that line if ${u.syn.name} works without it, or give every use a summary that says what it shows`,u.syn.p)}}catch(p){f.err(p)}}for(let u of c)u.runDeferred();rA(s,c,e),ik(s.defs);for(let u of s.defs.values())u.digest=ol(Ni({...u,fns:u.fns}));return s.moves=kf(s,e),s.lock=iA(s,t.lock,e),s}function nA(t,e){let n=new Map,r=(s,o)=>{let a=n.get(s);if(a)return a;let l=new Set;if(o.has(s))return l;o.add(s);let c=u=>{for(let f of u??[]){if(f.def&&e[f.def]&&f.def!==s){for(let p of e[f.def].implements??[])l.add(p);for(let p of r(f.def,o))l.add(p)}c(f.children),c(f.records);for(let p of f.cases??[])c(p.children);c(f.else);for(let p of Object.values(f.fills??{}))c(p)}};return c(e[s]?.view),o.delete(s),n.set(s,l),l},i=s=>{for(let o of s??[]){let a=o.def?e[o.def]:void 0;if(a&&a.kind!=="extern"){a.implements?.length&&((o.meta??={}).implements=[...a.implements]);let l=[...r(a.id,new Set)];l.length&&((o.meta??={}).within=l.sort())}i(o.children);for(let l of Object.values(o.fills??{}))i(l)}};i(t)}function rk(t,e){let n=i=>{if(i.node==="canvas"&&i.props?.dims&&"lit"in i.props.dims&&i.props.dims.lit===3)return!0;let s=o=>(o??[]).some(a=>a.record==="pixels"||a.record==="mesh"||s(a.records)||s(a.children));return s(i.records)},r=(i,s)=>{for(let o of i??[]){let a=o.def?e[o.def]:void 0,l=o.meta?.summary??s??a?.about;a&&(a.requires??[]).includes("gfx@1")?o.fallback={summary:l??a.about??a.name}:n(o)&&(o.fallback={summary:l??"figure"}),r(o.children,l);for(let c of Object.values(o.fills??{}))r(c,l)}};r(t,void 0)}function ik(t){let e=Object.fromEntries(t);for(let n of t.values())(n.requires??[]).includes("gfx@1")&&n.view&&rk(n.view,e)}function rA(t,e,n){let r=new Map(e.map(a=>[a.entry.id,[...a.uses]])),i=new Map,s=(a,l)=>{if(i.has(a))return i.get(a);if(l.has(a))return 0;l.add(a);let c=1;for(let u of r.get(a)??[])u.startsWith("core:")||(c=Math.max(c,1+s(u,l)));return l.delete(a),i.set(a,c),c},o=a=>{let l=[a];for(let c=a;l.length<=64;){let u=(r.get(c)??[]).filter(f=>!f.startsWith("core:")&&i.has(f)&&!l.includes(f)).sort((f,p)=>i.get(p)-i.get(f))[0];if(!u)break;l.push(u),c=u}return l.map(nk)};for(let a of e){let l=s(a.entry.id,new Set);if(l>12){let c=o(a.entry.id),u=c.length>4?`${c[0]} \u2192 ${c[1]} \u2192 \u2026 \u2192 ${c[c.length-1]}`:c.join(" \u2192 "),[f,p]=[c[c.length-1],c[c.length-2]??c[0]];n.error("mkp.limit",`definitions may be nested at most 12 deep, one using the next; found ${a.entry.syn.name} nesting ${l} deep (${u}). Shorten the chain: write ${f}'s view straight into ${p} instead of using ${f} there`,a.entry.syn.p)}}}function iA(t,e,n){let r=[...t.prog.packs.values()].map(s=>({pack:s.name,version:s.version,digest:s.digest})).sort((s,o)=>s.pack<o.pack?-1:1),i={};for(let[s,o]of t.defs)i[s]=o.digest;if(e){for(let s of e.packs){let o=r.find(a=>a.pack===s.pack&&a.version===s.version);if(o&&o.digest!==s.digest&&s.pack!=="core"){let a=t.prog.packs.get(s.pack);n.warn("mkp.pack-changed",`pack ${s.pack}@${s.version} has changed since mkp.lock was written; found files that differ from the locked ones (one added, removed or edited), and a published version must not change. Undo the change, publish it as ${s.pack}@${s.version+1}, or rebuild with --relock if it is unpublished`,a?{...a.manifest.p,col:1}:void 0)}}for(let[s,o]of Object.entries(e.defs))if(!t.prog.packs.get(s.slice(0,s.indexOf(":")))?.manifest.unpublished&&!s.startsWith("core:")&&i[s]&&i[s]!==o&&!s.startsWith(`${Qe}:`)){let a=t.prog.defs.get(s),l=Number(/@(\d+)$/.exec(s)?.[1]??1);n.error("mkp.version-changed",`${s} has changed since mkp.lock recorded it; found a definition that differs from the locked one, and a locked version must keep its behaviour. Undo the change, or give it a new version (${nk(s)}@${l+1}); while the pack is unpublished, add unpublished to its manifest or rebuild with --relock`,a?.syn.p)}}return{mkp:Et,packs:r,defs:i}}var Ke="https://mkp.dev/schema",Ci="https://json-schema.org/draft/2020-12/schema",sk={type:"array",items:{type:"integer"},minItems:2,maxItems:2},Mj={$id:`${Ke}/ir/type`,description:"An MKP type (spec 6.5).",type:"object",required:["t"],properties:{t:{enum:["num","int","bool","text","latex","point","duration","range","expr","choice","list","rec","named","dict","records","slot","ref","token","fn","unknown","any"]}}},Lj={$schema:Ci,$id:`${Ke}/ir/expr`,title:"MKP expression",description:"An expression: its canonical source and its resolved tree. Operator calls name their declarations, so consumers need an evaluator but no parser.",type:"object",required:["expr","ast","type"],properties:{expr:{type:"string"},ast:{$ref:"#/$defs/ast"},type:{$ref:`${Ke}/ir/type`},pos:sk,static:{type:"boolean"}},$defs:{ast:{type:"object",required:["t"],properties:{t:{enum:["num","bool","str","tmpl","var","list","rec","dict0","point","builtin","call","apply","field","index","not","and","or","if","lam","fnref"]},fn:{type:"string"},name:{type:"string"},from:{enum:["local","inst","const"]},args:{type:"array",items:{$ref:"#/$defs/ast"}},items:{type:"array",items:{$ref:"#/$defs/ast"}},holes:{type:"array",items:{$ref:"#/$defs/ast"}},params:{type:"array",items:{type:"string"}}}}}},aA={description:"A prop value: a literal, an expression, typed text or maths, a token, a ref to state, a range, a duration.",anyOf:[{type:"object",required:["lit"]},{$ref:`${Ke}/ir/expr`},{type:"object",required:["text"],properties:{text:{type:"string"},maths:{type:"array"}}},{type:"object",required:["tex"],properties:{tex:{type:"string"},display:{type:"boolean"},svg:{type:"string"},speech:{type:"string"}}},{type:"object",required:["tok","kind"],properties:{tok:{type:"string"},kind:{type:"string"}}},{type:"object",required:["ref"],properties:{ref:{type:"string"}}},{type:"object",required:["range"],properties:{range:{type:"array",minItems:2,maxItems:2}}},{type:"object",required:["ms"],properties:{ms:{type:"number"}}}]},lA={type:"object",required:["a"],properties:{a:{enum:["set","play","pause","reset","reveal","hide","open","close","emit","send"]}}},jj={$schema:Ci,$id:`${Ke}/ir/node`,title:"MKP node",description:"An element, record, built-in or (expanded IR) instance. Nodes are {node, props, records, children, meta, on}.",type:"object",required:["node"],properties:{node:{type:"string"},def:{type:"string",pattern:"^[^:]+:[^@]+@\\d+$"},props:{type:"object",additionalProperties:{$ref:"#/$defs/val"}},records:{type:"array",items:{$ref:"#"}},children:{type:"array",items:{$ref:"#"}},fills:{type:"object",additionalProperties:{type:"array",items:{$ref:"#"}}},meta:{type:"object",properties:{id:{},if:{$ref:`${Ke}/ir/expr`},hidden:{type:"boolean"},grow:{type:"boolean"},basis:{type:"string"},comment:{type:"array",items:{type:"string"}},summary:{type:"string"},block:{type:"integer"},place:{type:"integer"},minwidth:{type:"number",exclusiveMinimum:0},minheight:{type:"number",exclusiveMinimum:0},aspect:{type:"number",exclusiveMinimum:0},anchor:{type:"string"},role:{type:"string"},attrs:{type:"object",additionalProperties:{type:"string"}}}},on:{type:"object",additionalProperties:{type:"array",items:lA}},pos:sk,record:{type:"string"},input:{type:"string"},var:{type:"string"},cases:{type:"array",items:{type:"object",required:["value","children"],properties:{children:{type:"array",items:{$ref:"#"}}}}},else:{type:"array",items:{$ref:"#"}},inst:{type:"object",required:["def","inputs","view"],properties:{view:{type:"array",items:{$ref:"#"}}}}},$defs:{val:aA}},Pj={$schema:Ci,$id:`${Ke}/ir/definition`,title:"MKP definition",description:"One name@N: inputs, fields, record lists, outs, state, derived values, fns, view and projections (spec 13).",type:"object",required:["ir","kind","id","name","version","pack","inputs"],properties:{ir:{const:1},kind:{enum:["widget","part","extern"]},id:{type:"string"},name:{type:"string",pattern:"^[A-Za-z_][A-Za-z0-9_.-]*$"},version:{type:"integer",minimum:1},pack:{type:"string"},about:{type:"string"},requires:{type:"array",items:{type:"string"}},budget:{type:"integer",maximum:2e7},fields:{type:"array",items:{type:"string"}},inputs:{type:"array",items:{type:"object",required:["name","type"],properties:{name:{type:"string"},type:{$ref:`${Ke}/ir/type`}}}},outs:{type:"array"},signals:{type:"array"},commands:{type:"array"},values:{type:"array",items:{type:"object",required:["k","name"],properties:{k:{enum:["state","var","derived","fn","host"]}}}},fns:{type:"object"},view:{type:"array",items:{$ref:`${Ke}/ir/node`}},project:{type:"object",properties:{md:{$ref:`${Ke}/ir/expr`},mermaid:{$ref:`${Ke}/ir/expr`}}},digest:{type:"string",pattern:"^sha256:[0-9a-f]{64}$"}}},_j={$schema:Ci,$id:`${Ke}/ir/tokens`,title:"MKP token set",description:"A pack's token defaults per kind and name; color tokens carry a dark value. Providers map the names or fall back to these.",type:"object",required:["name","version","pack","tokens"],properties:{name:{type:"string"},version:{type:"integer"},pack:{type:"string"},tokens:{type:"object",additionalProperties:{type:"object",additionalProperties:{type:"object"}}}}},qj={$schema:Ci,$id:`${Ke}/ir/bundle`,title:"MKP bundle",description:"A document's IR plus the definitions it uses, the base-set signatures, the tokens and the lock: one self-contained JSON (spec 13).",type:"object",required:["ir","level","doc","defs","fns","consts","types","tokens","capabilities","interface","lock"],properties:{ir:{const:1},mkp:{type:"string",pattern:"^\\d+(\\.\\d+)*$",description:"the MKP release that made it; none means 0.2.1"},level:{enum:["bundle","expanded"]},doc:{type:"object",required:["file","front","body"],properties:{body:{type:"array",items:{$ref:`${Ke}/ir/node`}},digest:{type:"string"}}},defs:{type:"object",additionalProperties:{$ref:`${Ke}/ir/definition`}},fns:{type:"object"},consts:{type:"object",additionalProperties:{$ref:`${Ke}/ir/expr`}},types:{type:"object",additionalProperties:{$ref:`${Ke}/ir/type`}},tokens:{type:"array",items:{$ref:`${Ke}/ir/tokens`}},macros:{type:"object",additionalProperties:{type:"string"}},capabilities:{type:"array",items:{type:"string"}},interface:{type:"object",required:["signals","hosts","commands"]},lock:{type:"object",required:["packs","defs"],properties:{assets:{type:"object",additionalProperties:{type:"string"}}}},assets:{type:"object",description:"images the bundle carries, by pack/path: drawn from here, never fetched",additionalProperties:{type:"object",required:["type","digest","data"],properties:{type:{enum:["image/svg+xml","image/png","image/jpeg","image/webp"]},digest:{type:"string",pattern:"^sha256:[0-9a-f]{64}$"},data:{type:"string"},base64:{type:"boolean"}},additionalProperties:!1}}}},cA={$schema:Ci,$id:`${Ke}/fixture`,title:"MKP fixture file (name.fixture.json)",type:"object",required:["widget","cases"],additionalProperties:!1,properties:{widget:{type:"string",pattern:"^[A-Za-z_][A-Za-z0-9_.:-]*@\\d+$"},cases:{type:"object",additionalProperties:{type:"object",additionalProperties:!1,properties:{props:{type:"object"},summary:{type:"string"},hosts:{type:"object"},play:{type:"array",items:{type:"object",minProperties:1,additionalProperties:!1,properties:{press:{type:"string"},set:{type:"object"},command:{type:"string"},args:{type:"object"},wait:{type:"number",minimum:0}}}},expect:{type:"object",additionalProperties:!1,properties:{errors:{type:"array",items:{type:"string"}},md:{type:"object",additionalProperties:{type:"string"}},values:{type:"object"},visible:{type:"array",items:{type:"string"}},tolerance:{type:"number",exclusiveMinimum:0,maximum:.001}}}}}}}};var C={num:t=>({k:"num",v:String(t)}),bool:t=>({k:"bool",v:!!t}),text:(...t)=>({k:"text",parts:t}),dur:t=>({k:"dur",ms:t}),name:t=>({k:"name",n:t}),state:t=>({k:"state",n:t}),case:(t,e,n)=>({k:"case",type:t,name:e,args:n}),none:()=>({k:"case",type:"opt",name:"NONE"}),rec:(t,e)=>({k:"rec",type:t,fields:e}),list:(t,e=!1)=>({k:"list",items:t,multiline:e}),field:(t,e)=>({k:"field",o:t,n:e}),index:(t,e)=>({k:"index",o:t,i:e}),method:(t,e,n=[])=>({k:"method",o:t,n:e,args:n}),call:(t,e=[])=>({k:"call",fn:t,args:e}),bin:(t,e,n)=>({k:"bin",op:t,a:e,b:n}),un:(t,e)=>({k:"un",op:t,a:e}),cond:(t,e,n)=>({k:"cond",c:t,a:e,b:n}),range:(t,e)=>({k:"range",lo:t,hi:e}),lambda:(t,e)=>({k:"lambda",params:t,body:e}),view:t=>({k:"view",call:t})};function Wf(t,e=[],n=null){return e.length||n?{k:"noted",e:t,before:e,after:n}:t}var cl=(t,e)=>t.map(n=>`${e}// ${n}`.trimEnd()).join(`
512
+ `)+(t.length?`
513
+ `:""),ok=t=>t?.k==="noted"&&t.after?` // ${t.after}`:"",ak=t=>t?.k==="noted"?t.e:t,al=t=>t?.k==="noted",lk={"||":2,"&&":3,"==":4,"!=":4,"<":5,"<=":5,">":5,">=":5,in:5,"+":6,"-":6,"*":7,"/":7,"%":7},uA=new Set(["==","!=","<","<=",">",">=","in"]);function fA(t){switch(t.k){case"cond":return 1;case"bin":return lk[t.op];case"un":return 8;case"num":return t.v.startsWith("-")?8:10;case"range":case"lambda":return 0;default:return 10}}function pA(t,e){return t.map(n=>typeof n=="string"?n.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g,r=>`\\u{${r.charCodeAt(0).toString(16)}}`):`\\{${ce(n,e)}}`).join("")}var te=" ";function ce(t,e=""){let n=(r,i)=>fA(r)<i?`(${ce(r,e)})`:ce(r,e);switch(t.k){case"num":return t.v;case"bool":return t.v?"true":"false";case"text":return`"${pA(t.parts,e)}"`;case"dur":return t.ms%1e3===0&&t.ms!==0?`${t.ms/1e3}s`:`${t.ms}ms`;case"name":return t.n;case"state":return`$state.${t.n}`;case"case":return`${t.type}.${t.name}${t.args?`(${t.args.map(r=>ce(r,e)).join(", ")})`:""}`;case"rec":return`${t.type?t.type+" ":""}{ ${t.fields.map(([r,i])=>`${r} = ${ce(i,e)}`).join(", ")}${t.fields.length?" ":""}}`;case"list":return t.items.length?t.multiline||t.items.some(al)?`[
514
+ ${t.items.map(r=>`${al(r)?cl(r.before,e+te):""}${e}${te}${ce(ak(r),e+te)},${ok(r)}
515
+ `).join("")}${e}]`:`[${t.items.map(r=>ce(r,e)).join(", ")}]`:"[]";case"noted":return ce(t.e,e);case"field":return`${n(t.o,9)}.${t.n}`;case"index":return`${n(t.o,9)}[${ce(t.i,e)}]`;case"method":return`${n(t.o,9)}.${t.n}(${t.args.map(r=>ce(r,e)).join(", ")})`;case"call":return`${t.fn}(${t.args.map(r=>ce(r,e)).join(", ")})`;case"bin":{let r=lk[t.op],i=uA.has(t.op)?r+1:r;return`${n(t.a,i)} ${t.op} ${n(t.b,r+1)}`}case"un":return`${t.op}${n(t.a,8)}`;case"cond":return`${n(t.c,2)} ? ${n(t.a,1)} : ${n(t.b,1)}`;case"range":{let r=i=>i.k==="num"||i.k==="name"?ce(i,e):`(${ce(i,e)})`;return`${r(t.lo)}..${r(t.hi)}`}case"lambda":{let r=t.params.map(i=>Array.isArray(i)?`${i[0]}: ${i[1]}`:i).join(", ");return t.body.length===1&&t.body[0].k!=="comment"?`fn(${r}) { ${ck(t.body[0],e).trim()} }`:`fn(${r}) {
516
+ ${Kt(t.body,e+te)}${e}}`}case"view":return Hf(t.call,e)}throw new Error(`tree: no printer for expression ${t.k}`)}var fe={call:(t,e=[],n=null,r=null)=>({k:"call",name:t,args:e,children:n,slots:r}),if:(t,e=null)=>({k:"if",branches:t,otherwise:e}),for:(t,e,n,r=null,i=!1)=>({k:"for",name:t,over:e,body:n,key:r,mut:i}),match:(t,e)=>({k:"match",subject:t,cases:e}),let:(t,e,n)=>({k:"let",name:t,type:e,value:n}),mut:(t,e,n)=>({k:"mutvar",name:t,type:e,value:n}),assign:(t,e)=>({k:"assign",place:t,value:e}),expr:t=>({k:"expr",e:t}),ret:t=>({k:"return",e:t}),invoke:(t,e=[])=>({k:"invoke",name:t,args:e}),comment:t=>({k:"comment",text:t}),blank:()=>({k:"blank"})};function Hf(t,e){let n=t.args.map(([s,o])=>`${s} = ${ce(ak(o),e+te)}`),r=n.join(", ");return n.length?!t.args.some(([,s])=>al(s))&&!r.includes(`
517
+ `)&&r.length+e.length+t.name.length<100?`@${t.name}(${r})`:`@${t.name}(
518
+ ${t.args.map(([,s],o)=>`${al(s)?cl(s.before,e+te):""}${e}${te}${n[o]},${ok(s)}
519
+ `).join("")}${e})`:`@${t.name}`}function ck(t,e){switch(t.k){case"let":return`${e}let ${t.name}: ${t.type} = ${ce(t.value,e)};`;case"mutvar":return`${e}mut ${t.name}: ${t.type} = ${ce(t.value,e)};`;case"assign":return`${e}${ce(t.place,e)} = ${ce(t.value,e)};`;case"expr":return`${e}${ce(t.e,e)};`;case"return":return`${e}return${t.e?" "+ce(t.e,e):""};`;case"invoke":return`${e}invoke ${t.name}(${t.args.map(n=>ce(n,e)).join(", ")});`;case"comment":return t.text.split(`
520
+ `).map(n=>`${e}// ${n}`.trimEnd()).join(`
521
+ `);case"blank":return""}return Gf(t,e).replace(/\n$/,"")}function Uf(t,e){return t.k==="open"?`let ${t.name}: ${t.type} = ${ce(t.value,e)}`:ce(t,e)}function Gf(t,e){switch(t.k){case"call":{let n=`${e}${Hf(t,e)}`;return t.slots?.length?`${n} {
522
+ ${t.slots.map(([r,i])=>`${e}${te}${r} {
523
+ ${Kt(i,e+te+te)}${e}${te}}
524
+ `).join("")}${e}}
525
+ `:t.children?`${n} {
526
+ ${Kt(t.children,e+te)}${e}}
527
+ `:`${n};
528
+ `}case"if":{let n=`${e}if (${Uf(t.branches[0][0],e)}) {
529
+ ${Kt(t.branches[0][1],e+te)}${e}}`;for(let[r,i]of t.branches.slice(1))n+=` else if (${Uf(r,e)}) {
530
+ ${Kt(i,e+te)}${e}}`;return t.otherwise&&(n+=` else {
531
+ ${Kt(t.otherwise,e+te)}${e}}`),n+`
532
+ `}case"for":return`${e}${t.mut?"mut ":""}for (${t.key?t.key+", ":""}${t.name} in ${ce(t.over,e)}) {
533
+ ${Kt(t.body,e+te)}${e}}
534
+ `;case"match":return`${e}match (${ce(t.subject,e)}) {
535
+ ${t.cases.map(([n,r])=>`${e}${te}case ${n.join(", ")} {
536
+ ${Kt(r,e+te+te)}${e}${te}}
537
+ `).join("")}${e}}
538
+ `}return ck(t,e)+`
539
+ `}function Kt(t,e){return t.map(n=>n.k==="blank"?`
540
+ `:Gf(n,e)).join("")}var Be={import:t=>({k:"import",name:t}),comment:t=>({k:"comment",text:t}),enum:(t,e,n)=>({k:"enum",name:t,cases:e,about:n}),record:(t,e,n)=>({k:"record",name:t,fields:e,about:n}),state:t=>({k:"state",fields:t}),let:(t,e,n,r)=>({k:"let",name:t,type:e,value:n,about:r}),fn:(t,e,n,r,i)=>({k:"fn",name:t,params:e,ret:n,body:r,about:i}),widget:t=>({k:"widget",...t}),pack:(t,e,n,r)=>({k:"pack",name:t,version:e,uses:n,provides:r})};function ro(t,e=[]){let n=[];if(t)for(let r of t.split(`
541
+ `))n.push(`//@about ${r}`.trimEnd());for(let r of e)r.about&&n.push(`//@param ${r.name} ${r.about.replace(/\n/g," ")}`);return n}function ll(t,e){return`${t.mut?"mut ":""}${t.name}: ${t.type}${t.default?` = ${ce(t.default,e)}`:""}`}function hA(t,e){let n=t.map(r=>ll(r,te)).join(", ");return n.length+e.length<96&&!t.some(r=>r.comments?.length||r.trailing)?`${e}(${n})`:`${e}(
542
+ ${t.map(r=>`${cl(r.comments??[],te)}${te}${ll(r,te)},${r.trailing?` // ${r.trailing}`:""}
543
+ `).join("")})`}function uk(t){switch(t.k){case"import":return`import ${t.name};`;case"comment":return t.text.split(`
544
+ `).map(e=>`// ${e}`.trimEnd()).join(`
545
+ `);case"enum":return[...ro(t.about),`enum ${t.name} { ${t.cases.join(", ")} }`].join(`
546
+ `);case"record":return[...ro(t.about),`record ${t.name} {`,...t.fields.map(e=>`${te}${ll(e,te)};`),"}"].join(`
547
+ `);case"state":return["$state {",...t.fields.flatMap(e=>[...(e.comments??[]).map(n=>`${te}// ${n}`.trimEnd()),`${te}${ll(e,te)};`]),"}"].join(`
548
+ `);case"let":return[...ro(t.about),`let ${t.name}: ${t.type} = ${ce(t.value,"")};`].join(`
549
+ `);case"fn":return[...ro(t.about),`fn ${t.name}(${t.params.map(([e,n])=>n?`${e}: ${n}`:e).join(", ")})${t.ret?`: ${t.ret}`:""} {`,Kt(t.body,te).trimEnd(),"}"].join(`
550
+ `);case"pack":return[`pack ${t.name}@${t.version} {`,`${te}uses ${t.uses.join(", ")};`,`${te}provides ${t.provides.join(", ")};`,"}"].join(`
551
+ `);case"widget":return dA(t)}throw new Error(`tree: no printer for declaration ${t.k}`)}function dA(t){let e=[...(t.comments??[]).map(i=>`// ${i}`.trimEnd()),...ro(t.about,t.params)],n=hA(t.params,`${t.extern?"extern ":""}widget ${t.name}`),r=[];if(t.slots?.length&&r.push(t.slots.map(([i,s])=>`${te}slot ${i}: ${s};`).join(`
552
+ `)),t.events?.length&&r.push(t.events.map(i=>typeof i=="string"?`${te}event ${i}();`:`${cl(i.comments??[],te)}${te}event ${i.name}();`).join(`
553
+ `)),t.body?.length){let i=[[]];for(let s of t.body)s.k==="blank"?i.push([]):i[i.length-1].push(s.k==="fndecl"?mA(s,te):Gf(s,te).trimEnd());for(let s of i)s.length&&r.push(s.join(`
554
+ `))}return t.view&&r.push(`${te}view {
555
+ ${Kt(t.view,te+te)}${te}}`),t.markdown&&r.push(`${te}markdown {
556
+ ${Or(t.markdown,te+te)}
557
+ ${te}}`),r.length?[...e,`${n} {`,r.join(`
558
+
559
+ `),"}"].join(`
560
+ `):[...e,`${n};`].join(`
561
+ `)}function mA(t,e){let n=t.params.map(([r,i])=>`${r}: ${i}`).join(", ");return[...(t.comments??[]).map(r=>`${e}// ${r}`.trimEnd()),...t.about?[`${e}//@about ${t.about}`]:[],`${e}fn ${t.name}(${n})${t.ret?`: ${t.ret}`:""} {`,Kt(t.body,e+te).trimEnd(),`${e}}`].join(`
562
+ `)}var se={md:t=>({k:"md",text:t}),call:(t,e=[],n=null,r=null)=>({k:"call",name:t,args:e,body:n,slots:r}),for:(t,e,n)=>({k:"for",name:t,over:e,body:n}),if:(t,e,n=null)=>({k:"if",c:t,then:e,otherwise:n})};function gA(t,e,n){switch(t.k){case"md":return t.text.split(`
563
+ `).map(r=>r?e+r:"").join(`
564
+ `);case"call":{let r=e+Hf(t,e);return t.slots?.length?`${r} {
565
+ ${t.slots.map(([i,s])=>`${e}@slot ${i} {
566
+ ${Or(s,e,n)}
567
+ ${e}}`).join(`
568
+ `)}
569
+ ${e}}`:t.body?`${r} {
570
+ ${Or(t.body,e,n)}
571
+ ${e}}`:`${r};`}case"for":return`${e}@for (${t.name} in ${ce(t.over,e)}) {
572
+ ${Or(t.body,e,!0)}
573
+ ${e}}`;case"if":return`${e}@if (${Uf(t.c,e)}) {
574
+ ${Or(t.then,e,!0)}
575
+ ${e}}${t.otherwise?` else {
576
+ ${Or(t.otherwise,e,!0)}
577
+ ${e}}`:""}`}throw new Error(`tree: no printer for prose ${t.k}`)}function Or(t,e="",n=!1){return t.map(r=>gA(r,e,n)).join(n?`
578
+ `:`
579
+
580
+ `)}function fk({front:t,decls:e,body:n}){let r=[];t&&r.push(t.trimEnd());let i=e.map(uk).join(`
581
+
582
+ `);return i&&r.push(i+`
583
+ @@@`),r.push(Or(n)),r.join(`
584
+ `)+`
585
+ `}function pk(t,e){return`package ${t};
586
+
587
+ ${e.map(uk).join(`
588
+
589
+ `)}
590
+ `}function hk(t){let e=t.split(`
591
+ `),n=[],r=new Map,i=new Map,s=0,o=null;if(e[0]==="---"){let l=e.indexOf("---",1);l>0&&(o=e.slice(0,l+1).join(`
592
+ `)+`
593
+ `,s=l+1)}let a=[];for(;s<e.length;s++){let l=e[s],c=/^ {0,3}(`{3,}|~{3,})(.*)$/.exec(l);if(c){let f=c[1],p=s,h=s+1;for(;h<e.length&&!new RegExp(`^ {0,3}${f[0]==="`"?"`":"~"}{${f.length},}\\s*$`).test(e[h]);)h++;let d=c[2].trim().split(/\s+/)[0]??"";d&&d!=="mkp"&&d!=="state"&&r.set(p+1,yA(e.slice(p+1,h))),s=h;continue}let u=/^(:{3,})\s*([A-Za-z].*)?$/.exec(l);if(u){if(u[2])a.push([u[1].length,s+1]);else for(let f=a.length-1;f>=0;f--)if(a[f][0]===u[1].length){i.set(a[f][1],s+1),a.splice(f);break}continue}if(/^ {0,3}<!--/.test(l)){let f=s;for(;f<e.length&&!e[f].includes("-->");)f++;n.push({kind:"html",line:s+1,end:f+1,text:e.slice(s,f+1).join(`
594
+ `)}),s=f;continue}/^ {0,3}\[[^\]^][^\]]*\]:\s*\S/.test(l)&&n.push({kind:"linkref",line:s+1,end:s+1,text:l.trim()})}return{prose:n,yaml:r,ends:i,front:o}}function yA(t){let e={order:[],keys:new Map,items:new Map,fields:new Map,count:0},n=[],r=null,i=-1,s=()=>({before:[],after:null});for(let o of t){let a=/^\s*#\s?(.*)$/.exec(o);if(a){n.push(a[1]),e.count++;continue}let[l,c]=kA(o);if(c!==null&&e.count++,!l.trim())continue;let u=/^([A-Za-z_][\w-]*):/.exec(l);if(u){r=u[1],i=-1,e.order.push(r);let h=e.keys.get(r)??s();h.before.push(...n),h.after=c??h.after,e.keys.set(r,h),n=[];continue}if(/^(\s*)-\s?(.*)$/.exec(l)&&r){i++;let h=e.items.get(r)??[];h[i]={before:n,after:c},e.items.set(r,h),n=[];continue}let p=/^\s+([A-Za-z_][\w-]*):/.exec(l);if(p&&r&&i>=0&&(n.length||c!==null)){let h=e.fields.get(r)??[];(h[i]??=new Map).set(p[1],{before:n,after:c}),e.fields.set(r,h),n=[]}}return n.length&&r&&(e.keys.get(r).after=[e.keys.get(r).after,...n].filter(Boolean).join(" ")),e}function kA(t){let e=null;for(let n=0;n<t.length;n++){let r=t[n];if(e){r===e&&t[n-1]!=="\\"&&(e=null);continue}if(r==='"'||r==="'")e=r;else if(r==="#"&&(n===0||/\s/.test(t[n-1])))return[t.slice(0,n),t.slice(n+1).trim()]}return[t,null]}var U=class extends Error{constructor(e){super(e),this.what=e}},bA=new Set("package import enum record type interface implements widget extern expose fn pack tokens mut let event invoke view markdown require if else for in match case return only step void any param slot try with self true false as token".split(" ")),nr=new Set(`shown same ordered numeric scaled literal int map date moment template hole latex can_draw_tex md block list_item rich_text segment part marks
595
+ point region pi euler color_value font_value shadow_value color space size radius font shadow stroke align justify weight text_size press_kind
596
+ edge overlay_mode axis anchor head width theme track cols glyph page flex grid cell sizing plane spot paragraph heading bullets item quote code
597
+ math table footnote divider cell_align label image icon press field slider overlay canvas layer shape circle path place handle pixel shade rect
598
+ grow shrink basis min_size max_size aspect column row stack meter frame pane blocks number bool text duration list opt range view`.split(/\s+/)),wA=new Set(["pi","euler","page","can_draw_tex"]),ul=class{constructor(e,n={}){this.b=e,this.opts=n,this.notes=[],this.packs=new Map,this.failedFns=new Set}note(e,n,r){this.notes.some(i=>i.kind===e&&i.line===n&&i.what===r)||this.notes.push({kind:e,line:n??null,what:r})}todo(e,n){this.note("todo",e,n)}lossy(e,n){this.note("lossy",e,n)}fallback(e,n){this.note("fallback",e,n)}safe(e,n=wA){let r=e.replace(/-/g,"_").toLowerCase();return/^[a-z]/.test(r)||(r="x_"+r),(bA.has(r)||n.has(r))&&(r=r+"_"),r}caseName(e){let n=String(e).replace(/[^A-Za-z0-9]+/g,"_").toUpperCase();return/^[A-Z]/.test(n)||(n="N"+n),n}def(e){return e?this.b.defs[e]:void 0}named(e,n){let r=this.b.types??{},i=r[`${n}:${e}`]??r[`core:${e}`]??Object.entries(r).find(([s])=>s.endsWith(`:${e}`))?.[1];if(i)return i;for(let s of Object.values(this.b.defs))if(s.pack===n){for(let o of s.inputs??[])if(o.type?.t==="records"&&o.type.kind===e)return{t:"rec",name:e,fields:o.type.fields,defaults:o.type.defaults}}}};function ze(t,e,n){let r=0;for(;e?.t==="named"&&r++<8;){if(e.name==="iconname")return{t:"icon"};let i=t.named(e.name,n);if(!i)return e;e=i.t==="choice"?{...i,name:e.name}:i}return e}function dk(t,e){return t!==void 0&&e!==void 0?` ${fl(t)}..${fl(e)}`:t!==void 0?` ${fl(t)}...`:e!==void 0?` ...${fl(e)}`:""}function fl(t){return t===1/0?"1e308":String(t)}function Ve(t,e,n){switch(e=ze(t,e,n.pack),e.t){case"num":return{src:"number"+dk(e.lo,e.hi)};case"int":return{src:"int"+dk(e.lo,e.hi)};case"bool":return{src:"bool"};case"text":return{src:n.rich?"rich_text":"text"};case"latex":return{src:"latex"};case"point":return{src:"point"};case"duration":return{src:"duration"};case"range":return{src:"range<number>"};case"icon":return{src:"glyph",none:!0,icon:!0};case"token":return{src:e.kind,none:!0,token:e.kind};case"choice":{let r=n.sink.enumFor(e.name,e.opts,n.hint);return{src:r,enum:r}}case"list":{let r=Ve(t,e.of,{...n,hint:n.hint+"_item"});return{src:`list<${r.none?`opt<${r.src}>`:r.src}>`}}case"dict":{let r=Ve(t,e.of,n);return t.lossy(n.line,`a dict(${r.src}) became core's map<${r.src}>, which is a record of keys and values, not a built-in`),{src:`map<${r.src}>`}}case"rec":return{src:n.sink.recordFor(e.name,e.fields,e.defaults,n)};case"records":{if(e.slot)throw new U("a list of records with content is a list slot in 0.3; handled by the widget");return{src:`list<${n.sink.recordFor(e.kind,e.fields,e.defaults,n)}>`}}case"slot":return{src:"view",slot:!0};case"ref":return t.lossy(n.line,"a `ref` input became a `mut` input: the caller passes a variable, as $state.name"),{...Ve(t,e.of,n),mut:!0};case"fn":return{src:`fn(${e.params.map((i,s)=>`${"abcdefgh"[s]}: ${Ve(t,i,n).src}`).join(", ")}): ${Ve(t,e.ret,n).src}`};case"expr":return{src:`fn(${e.vars.map(([i,s])=>`${i}: ${Ve(t,s,n).src}`).join(", ")}): ${Ve(t,e.ret,n).src}`};case"param":return{src:e.name.toUpperCase()};case"named":throw new U(`the type ${e.name} has no 0.3 equivalent here`);default:throw new U(`the 0.2 type ${e.t} has no 0.3 equivalent`)}}function pl(t,e,n,r){if(n==="none")return C.none();if(e==="size"&&n==="fill")throw new U("size=fill has no 0.3 token: a box that fills is @grow");return C.case(e,t.caseName(n))}function Yt(t,e,n,r,i=null){let s=n?ze(t,n,r.pack):void 0;if(e==null)throw new U("a value with nothing in it");if("ref"in e)return C.state(e.ref);if("tok"in e)return pl(t,e.kind,e.tok,r.line);if("ms"in e)return C.dur(e.ms);if("range"in e)return C.range(Yt(t,e.range[0],{t:"num"},r,i),Yt(t,e.range[1],{t:"num"},r,i));if("ast"in e&&"expr"in e){if(!i)throw new U(`an expression (${e.expr}) where no scope can read it`);return Ce(t,e.ast,i,r,n??e.type)}if("tex"in e)return C.text(e.tex);if("text"in e){if(e.vals?.length)throw new U("a text with \\val holes outside a definition");return C.text(e.text)}if("slot"in e)throw new U("slot content as a value");if("lit"in e)return rr(t,e.lit,s,r);throw new U(`a 0.2 value of the shape ${Object.keys(e).join(",")}`)}function rr(t,e,n,r){if(n?.t==="icon")return e==="none"?C.none():C.case("glyph",t.caseName(e));if(n?.t==="choice")return C.case(n.core??r.sink.enumFor(n.name,n.opts,r.hint),t.caseName(e));if(n?.t==="token")return pl(t,n.kind,e,r.line);if(n?.t==="list"||Array.isArray(e)){if(!Array.isArray(e))throw new U("a list value that is not a list");let i=n?.t==="list"?ze(t,n.of,r.pack):void 0;return C.list(e.map(s=>rr(t,s,i,r)),e.length>4)}if(typeof e=="boolean")return C.bool(e);if(typeof e=="number")return C.num(e);if(typeof e=="string")return C.text(e);if(e&&typeof e=="object"){if(n?.t==="rec"||n?.t==="point"){let i=n.t==="point"?[["x",{t:"num"}],["y",{t:"num"}]]:n.fields,s=n.t==="point"?"point":r.sink.recordFor(n.name,n.fields,n.defaults,r);return C.rec(s,i.filter(([o])=>o in e).map(([o,a])=>[t.safe(o),rr(t,e[o],ze(t,a,r.pack),r)]))}throw new U("a record value of no known record type")}throw new U(`the literal ${JSON.stringify(e)}`)}function ir(t={}){return{inst:new Map,locals:new Map,consts:new Map,fns:new Map,types:new Map,rewrite:[],...t}}function Nn(t,e){let n=new Map(t.types),r=new Map(t.locals);for(let[i,s]of e)Array.isArray(s)?(r.set(i,s[0]),s[1]?n.set(i,s[1]):n.delete(i)):(r.set(i,s),n.delete(i));return{...t,locals:r,types:n}}var Kf={"+":"+","-":"-","*":"*","/":"/",mod:"%","==":"==","!=":"!=","<":"<","<=":"<=",">":">",">=":">="},Yf={len:"len",trim:"trim",lower:"lower",upper:"upper",floor:"floor",ceil:"ceil",round:"round",abs:"abs",sin:"sin",cos:"cos",tan:"tan",atan:"atan",exp:"exp",sign:"sign",reverse:"reversed",sort:"sorted",first:"first",last:"last"},mk={sqrt:"sqrt",ln:"ln",asin:"asin",acos:"acos",number:"number"},Jf={startswith:"starts",endswith:"ends",contains:"has",split:"split",join:"join",atan2:"atan2",min:"min",max:"max",indexof:"position",slice:"slice"};function $A(t,e){return JSON.stringify(t)===JSON.stringify(e)}function nt(t,e,n,r=n.pack??"$doc"){let i=s=>s?ze(t,s,r):void 0;switch(e.t){case"num":return{t:"num"};case"bool":return{t:"bool"};case"str":case"tmpl":return{t:"text"};case"var":return e.name==="$width"||e.name==="width"&&e.from!=="local"&&!n.types.has("width")?{t:"choice",opts:["narrow","medium","wide"],core:"width"}:e.name==="$theme"||e.name==="theme"&&e.from!=="local"&&!n.types.has("theme")?{t:"choice",opts:["light","dark"],core:"theme"}:i(n.types.get(e.name));case"field":{let s=nt(t,e.o,n,r),o=s?.t==="rec"||s?.t==="records"?s.fields:s?.t==="point"?[["x",{t:"num"}],["y",{t:"num"}]]:null;return i(o?.find(([a])=>a===e.name)?.[1])}case"index":return i(Mr(nt(t,e.o,n,r)));case"call":{let s=t.b.fns?.[e.fn]??n.fnDefs?.get(e.fn);return i(s?.ret)}case"if":return nt(t,e.a,n,r)??nt(t,e.b,n,r);case"not":case"and":case"or":return{t:"bool"};case"builtin":return["==","!=","<","<=",">",">=","startswith","endswith","contains"].includes(e.fn)?{t:"bool"}:["cat","format","join","lower","upper","trim"].includes(e.fn)?{t:"text"}:["len","floor","ceil","round"].includes(e.fn)?{t:"int"}:["+","-","*","/","neg","min","max","abs","lsum","mod"].includes(e.fn)?nt(t,e.args[0],n,r)??{t:"num"}:e.fn==="filter"||e.fn==="reverse"||e.fn==="sort"?nt(t,e.args[0],n,r):void 0}}function Mr(t){if(t?.t==="list")return t.of;if(t?.t==="records")return{t:"rec",name:t.kind,fields:t.fields,defaults:t.defaults}}function Ce(t,e,n,r,i){let s=i?ze(t,i,r.pack??"$doc"):void 0,o=(a,l,c=n)=>Ce(t,a,c,r,l);for(let[a,l]of n.rewrite)if($A(e,a))return l;switch(e.t){case"num":return e.v<0?C.un("-",C.num(-e.v)):C.num(e.v);case"bool":return C.bool(e.v);case"str":return s&&(s.t==="choice"||s.t==="token"||s.t==="icon")?rr(t,e.v,s,{...r,sink:r.sink}):C.text(e.v);case"tmpl":{let a=[],l=/\\val\{(\d+)\}/g,c=0;for(let u;u=l.exec(e.v);){a.push(e.v.slice(c,u.index));let f=e.holes[Number(u[1])],p=e.show?.[Number(u[1])];a.push(p?C.method(o(f),"fmt",[C.num(String(p).replace(/\D/g,"")||0)]):o(f)),c=l.lastIndex}return a.push(e.v.slice(c)),C.text(...a.filter(u=>u!==""))}case"var":{if(e.from==="local"&&n.locals.has(e.name))return n.locals.get(e.name);if(e.from==="inst"&&n.inst.has(e.name))return n.inst.get(e.name);if(n.locals.has(e.name))return n.locals.get(e.name);if(n.inst.has(e.name))return n.inst.get(e.name);if(e.name==="$width"||e.name==="width"&&e.from!=="local")return C.field(C.name("page"),"width");if(e.name==="$theme"||e.name==="theme"&&e.from!=="local")return C.field(C.name("page"),"theme");if(e.from==="const"||n.consts.has(e.name)){if(n.consts.has(e.name))return n.consts.get(e.name);if(e.name==="pi")return C.name("pi");if(e.name==="e")return C.name("euler");if(e.name==="tau")return C.bin("*",C.num(2),C.name("pi"));if(e.name==="true"||e.name==="false")return C.bool(e.name==="true");if(e.name==="width")return C.field(C.name("page"),"width");if(e.name==="theme")return C.field(C.name("page"),"theme")}throw new U(`the name ${e.name} (${e.from}) is not visible in 0.3 here`)}case"list":return C.list(e.items.map(a=>o(a,s?.t==="list"?s.of:void 0)));case"rec":{let a=s?.t==="rec"?new Map(s.fields):new Map,l=s?.t==="rec"?r.sink?.recordFor(s.name,s.fields,s.defaults,{...r,pack:r.pack??"$doc"})??"":"";return C.rec(l,e.fields.map(([c,u])=>[t.safe(c),o(u,a.get(c))]))}case"point":return C.rec("point",[["x",o(e.x)],["y",o(e.y)]]);case"field":return C.field(o(e.o),t.safe(e.name));case"index":throw t.lossy(r.line,"xs[i] gives an opt in 0.3; the migration only rewrites xs[k] inside a walk over xs"),new U(`indexing (${JSON.stringify(e).slice(0,60)}\u2026) outside a walk over the same list`);case"not":return C.un("!",o(e.a,{t:"bool"}));case"and":return C.bin("&&",o(e.a,{t:"bool"}),o(e.b,{t:"bool"}));case"or":return C.bin("||",o(e.a,{t:"bool"}),o(e.b,{t:"bool"}));case"if":return C.cond(o(e.c,{t:"bool"}),o(e.a,i),o(e.b,i));case"lam":{let a=s?.t==="fn"?s.params:[],l=new Map(e.params.map((c,u)=>[c,[C.name(t.safe(c)),a[u]]]));return C.lambda(e.params.map(c=>t.safe(c)),[fe.ret(o(e.body,s?.t==="fn"?s.ret:void 0,Nn(n,l)))])}case"fnref":case"call":{if(t.failedFns.has(e.fn))throw new U(`it calls ${t.b.fns?.[e.fn]?.name??e.fn}, a fn that did not migrate`);let a=n.fns.get(e.fn)??(t.b.fns?.[e.fn]?t.safe(t.b.fns[e.fn].name):void 0);if(!a)throw new U(`a call to the fn ${e.fn}, which this migration has no 0.3 name for`);let l=t.b.fns?.[e.fn]??n.fnDefs?.get(e.fn);return e.t==="fnref"?C.name(a):C.call(a,e.args.map((c,u)=>o(c,l?.types?.[u])))}case"apply":{let a=Ce(t,e.f,n,r);if(a.k!=="name")throw new U("a call of a computed fn");return C.call(a.n,e.args.map(l=>o(l)))}case"builtin":return vA(t,e,n,r,s)}throw new U(`the 0.2 expression ${e.t}`)}function vA(t,e,n,r,i){let s=(f,p)=>Ce(t,f,n,r,p),[o,a,l]=e.args,c=e.fn;if(c==="=="||c==="!="||c==="<"||c==="<="||c===">"||c===">="){let f=nt(t,o,n),p=nt(t,a,n),h=(d,m)=>d.t==="str"&&d.v==="none"&&m&&(m.t==="token"||m.t==="icon");if(h(a,f)||h(o,p)){let d=h(a,f)?o:a,m=h(a,f)?f:p;return C.bin(c==="=="?"==":"!=",s(d,m),C.none())}return C.bin(Kf[c],s(o,p),s(a,f))}if(c in Kf)return C.bin(Kf[c],s(o,i),s(a,i));if(c==="neg")return C.un("-",s(o,i));if(c==="cat"){let f=[],p=h=>h.t==="builtin"&&h.fn==="cat"?h.args.forEach(p):f.push(h);return e.args.forEach(p),C.text(...f.map(h=>h.t==="str"?h.v:s(h)).filter(h=>h!==""))}if(c==="format")return a?C.method(s(o),"fmt",[s(a)]):C.text(s(o));let u=f=>nt(t,f,n)?.t==="choice"?C.method(s(f),"show"):s(f);if(["trim","lower","upper"].includes(c)&&e.args.length===1)return C.method(u(o),Yf[c]);if(["startswith","endswith","contains","split"].includes(c)&&e.args.length===2)return C.method(u(o),Jf[c],[s(a)]);if(c in Yf&&e.args.length===1)return C.method(s(o),Yf[c]);if(c in mk&&e.args.length===1)return t.lossy(r.line,`${c}() gives an opt in 0.3 (no answer for some inputs); the migration falls back to 0`),C.method(C.method(s(o),mk[c]),"or",[C.num(0)]);if(c in Jf&&e.args.length===2)return C.method(s(o),Jf[c],[s(a)]);if(c==="^")return t.lossy(r.line,"a ^ b gives an opt in 0.3 (a.pow(b)); the migration falls back to 0"),C.method(C.method(s(o),"pow",[s(a)]),"or",[C.num(0)]);if(c==="lsum"||c==="sum")return C.method(C.method(s(o),"sum"),"or",[C.num(0)]);if(c==="map"||c==="filter"||c==="find"){if(o.t==="builtin"&&o.fn==="range")throw new U(`${c} over range(a, b): a 0.3 range is walked by for, and is not a list`);let f=Mr(nt(t,o,n)),p=a.t==="lam"?xA(t,a,f,n,r):s(a);return C.method(s(o),c,[p])}if(c==="at"&&e.args.length===3)return C.method(C.method(s(o),"at",[s(a)]),"or",[s(l,Mr(nt(t,o,n)))]);if(c==="range"&&e.args.length===2)return C.range(s(o),s(a));if(c==="len")return C.method(s(o),"len");throw new U(`the 0.2 builtin ${c}(${e.args.length} args) has no 0.3 translation here`)}function xA(t,e,n,r,i){let s=new Map(e.params.map((o,a)=>[o,[C.name(t.safe(o)),a===0?n:void 0]]));return C.lambda(e.params.map(o=>t.safe(o)),[fe.ret(Ce(t,e.body,Nn(r,s),i))])}var Ii=class{constructor(e,n){this.m=e,this.pack=n,this.enums=new Map,this.records=new Map,this.names=new Map,this.used=new Set(nr),this.shows=new Map}name(e,n){let r=`${n}:${e}`;if(this.names.has(r))return this.names.get(r);let i=this.m.safe(e,this.used);for(;this.used.has(i);)i+="_";return this.used.add(i),this.names.set(r,i),i}enumFor(e,n,r){let i=e?`enum:${e}`:`enum-of:${n.join("|")}`;if(this.names.has(i))return this.names.get(i);let s=this.name(e??r??"choice","enum");return this.names.set(i,s),this.enums.set(s,Be.enum(s,n.map(o=>this.m.caseName(o)))),this.shows.set(s,Be.fn(`${s}.show`,[["self",null]],"text",[fe.match(C.name("self"),n.map(o=>[[`${s}.${this.m.caseName(o)}`],[fe.ret(C.text(o))]]))])),s}recordFor(e,n,r,i){let s=e?`record:${e}`:`record-of:${JSON.stringify(n)}`;if(this.names.has(s))return this.names.get(s);let o=this.name(e??i.hint??"fields","record");return this.names.set(s,o),this.records.set(o,null),this.records.set(o,Be.record(o,n.map(([a,l])=>this.field(a,l,r?.[a],{...i,hint:`${o}_${a}`})))),o}field(e,n,r,i){let s=this.m,o={...i,sink:this,pack:this.pack},a=Ve(s,n,o),l={name:s.safe(e),type:a.src},c=null;return r!==void 0&&(c=typeof r=="string"?SA(s,r,ze(s,n,this.pack),o):EA(s,r,ze(s,n,this.pack),o)),a.none&&(l.type=`opt<${a.src}>`,c===null&&r!==void 0&&(c=C.none())),c&&(l.default=c),a.mut&&(l.mut=!0),l}decls(){return[...this.enums.values(),...this.shows.values(),...[...this.records.values()].filter(Boolean)]}};function EA(t,e,n,r){if("lit"in e)return rr(t,e.lit,n,r);if("text"in e)return C.text(e.text);if("tok"in e)return pl(t,e.kind,e.tok,r.line);if("ms"in e)return C.dur(e.ms);throw new U("a default that is an expression")}function SA(t,e,n,r){let i=e.trim();if(i==="none"&&n?.t!=="choice")return C.none();if(i==="true"||i==="false")return C.bool(i==="true");if(/^-?\d+(\.\d+)?$/.test(i))return C.num(i);if(/^"([^"\\]|\\.)*"$/.test(i))return C.text(JSON.parse(i));if(i==="[]")return C.list([]);if(/^[a-z][a-z0-9_]*$/.test(i))return rr(t,i,n,r);try{return rr(t,JSON.parse(i),n,r)}catch{throw new U(`the default ${i}`)}}function Jt(t){let e="",n=0,r=t.length,i=!0;for(;n<r;){if(i){i=!1;let o=/^( {0,3})(@|\}[ \t]*(?:\n|$))/.exec(t.slice(n));o&&(e+=o[1]+"\\",n+=o[1].length)}let s=t[n];if(s===`
599
+ `){e+=s,n++,i=!0;continue}if(s==="`"){let o=/^`+/.exec(t.slice(n))[0],l=t.indexOf(o,n+o.length);for(;l!==-1&&t[l+o.length]==="`";)l=t.indexOf(o,l+1);if(l!==-1){e+=t.slice(n,l+o.length),n=l+o.length;continue}e+=o,n+=o.length;continue}if(s==="\\"){let o=t[n+1];if(o==="{"){e+="{",n+=2;continue}if(o===void 0||o===`
600
+ `){e+=s,n++;continue}e+=s+o,n+=2;continue}if(s==="$"&&t[n+1]!=="$"&&t[n+1]&&!/\s/.test(t[n+1])){let o=n+1,a=-1;for(;o<r&&t[o]!==`
601
+ `;o++){if(t[o]==="\\"){o++;continue}if(t[o]==="$"&&!/\s/.test(t[o-1])&&!/\d/.test(t[o+1]??"")){a=o;break}}if(a!==-1){e+="$"+gk(t.slice(n+1,a))+"$",n=a+1;continue}}e+=s,n++}return e}function gk(t){return t.replace(/(^|[^\\])((?:\\\\)*)\\\{/g,"$1$2\\\\{")}var hl=class{constructor(e,n,r=null){this.m=e,this.widgets=n,this.pending=r?[...r.prose]:[],this.moved=[]}flush(e,n){let r=[];for(;this.pending.length&&this.pending[0].line<e;){let i=this.pending.shift();i.kind==="linkref"?(r.push(se.md(i.text)),this.m.lossy(i.line,`the link reference definition ${i.text.split(":")[0]} is kept: 0.3 reads it, so a link written [text]${i.text.split(":")[0]} is a link now, where 0.2 showed it as text`)):this.m.opts.htmlComments==="inline"?r.push(se.md(i.text)):this.m.opts.htmlComments==="header"?this.moved.push({...i,before:n?AA(n):"at the end"}):r.push(se.md(TA(i.text)))}return r}blocks(e,n=null,r=null){let i=[];for(let s of e)s.pos&&i.push(...this.flush(s.pos[0],s)),i.push(...this.block(s));return n&&i.push(...this.flush(n,r?{end:r}:null)),i}mdOf(e){let n=[];for(let r of e){let i=this.block(r);if(i.some(s=>s.k!=="md"))return null;n.push(...i.map(s=>s.text))}return n.join(`
602
+
603
+ `)}block(e){let n=this.m,r=e.props??{},i=e.pos?.[0];switch(e.node){case"paragraph":return[se.md(Jt(r.text?.text??""))];case"heading":return[se.md(`${"#".repeat(r.level?.lit??2)} ${Jt(r.text?.text??"")}`)];case"divider":return[se.md("---")];case"code":{let s=r.src?.text??"",o="```";for(;s.includes(o);)o+="`";return[se.md(`${o}${r.lang?.text??""}
604
+ ${s}
605
+ ${o}`)]}case"math":return[se.md(`$$
606
+ ${gk(r.tex?.tex??"")}
607
+ $$`)];case"quote":{let s=r.alert?.lit;s&&s!=="none"&&n.lossy(i,`a GitHub alert (> [!${s.toUpperCase()}]) is a plain quote in 0.3; its [!${s.toUpperCase()}] line is kept as text`);let o=this.mdOf(e.children??[]);if(o===null)throw new U("a quote holding a widget");let a=s&&s!=="none"?`[!${s.toUpperCase()}]
608
+ ${o}`:o;return[se.md(a.split(`
609
+ `).map(l=>l?`> ${l}`:">").join(`
610
+ `))]}case"list":{let s=!!r.ordered?.lit,o=Number(r.start?.lit??1),a=[],l=!1;for(let c of e.records??[]){let u=s?`${o++}.`:"-",f=c.props?.checked?.lit,p=f==="yes"?"[x] ":f==="no"?"[ ] ":"",h=this.mdOf(c.children??[]);if(h===null)throw new U("a list item holding a widget");(c.children??[]).length>1&&(l=!0);let d=" ".repeat(u.length+1);a.push(`${u} ${p}${h.split(`
611
+ `).map((m,g)=>g&&m?d+m:m).join(`
612
+ `)}`)}return[se.md(a.join(l?`
613
+
614
+ `:`
615
+ `))]}case"table":{let s=r.head?.lit??[],o=r.rows?.lit??[],a=r.align?.lit??[],l=s.map((u,f)=>a[f]==="center"?":---:":a[f]==="right"?"---:":a[f]==="left"?":---":"---"),c=u=>`| ${u.map(f=>Jt(f)).join(" | ")} |`;return[se.md([c(s),`| ${l.join(" | ")} |`,...o.map(c)].join(`
616
+ `))]}case"footnote":{let s=this.mdOf(e.children??[]);if(s===null)throw new U("a footnote holding a widget");return[se.md(`[^${r.label?.text}]: ${s.split(`
617
+ `).join(`
618
+ `)}`)]}}return this.widgets(e)}};function io(t,e,n,r){return Yt(t,e,n,r,ir())}function Qf(t,e,n,r=()=>[]){let i=e.node,s=[],o=e.meta?.summary;s.push(se.md(`**${i}**${o?`: ${Jt(o)}`:""}`));let a={};for(let[l,c]of Object.entries(e.props??{}))a[l]=Zf(c);for(let l of e.records??[])(a[l.input]??=[]).push(Object.fromEntries(Object.entries(l.props??{}).map(([c,u])=>[c,Zf(u)])));Object.keys(a).length&&s.push(se.md("```yaml\n"+yk(a)+"\n```"));for(let l of e.records??[]){if(!l.children?.length)continue;let c=Object.values(l.props??{}).map(Zf).find(u=>typeof u=="string"&&u);c&&s.push(se.md(`**${Jt(c)}**`)),s.push(...r(l.children))}for(let l of Object.values(e.fills??{}))s.push(...r(l));return e.children?.length&&s.push(...r(e.children)),t.fallback(e.pos?.[0],`the ${i} block was kept as Markdown (its summary, its inputs as YAML, and what it held): ${n}`),s}function Zf(t){return!t||typeof t!="object"?t:"lit"in t?t.lit:"text"in t?t.text:"tok"in t?t.tok:"tex"in t?t.tex:"expr"in t?t.expr:"ref"in t?`ref ${t.ref}`:"ms"in t?`${t.ms}ms`:JSON.stringify(t)}function yk(t,e=""){return Array.isArray(t)?t.map(n=>`${e}- ${n&&typeof n=="object"&&!Array.isArray(n)?`{${Object.entries(n).map(([r,i])=>`${r}: ${JSON.stringify(i)}`).join(", ")}}`:JSON.stringify(n)}`).join(`
619
+ `):Object.entries(t).map(([n,r])=>Array.isArray(r)&&r.some(i=>i&&typeof i=="object")?`${e}${n}:
620
+ ${yk(r,e+" ")}`:`${e}${n}: ${JSON.stringify(r)}`).join(`
621
+ `)}function AA(t){if(t.end)return`at the end of the ${t.end.node}${t.end.record?` ${t.end.record}`:""} block`;let e=n=>{let r=String(n??"").replace(/\s+/g," ").trim();return r.length>40?r.slice(0,37)+"\u2026":r};return t.node==="heading"?`before the heading "${e(t.props?.text?.text)}"`:t.node==="paragraph"?`before "${e(t.props?.text?.text)}"`:`before the ${t.node} block`}function TA(t){let e=t.replace(/^\s*<!--[ \t]?/,"").replace(/[ \t]?-->\s*$/,"").split(`
622
+ `);for(;e.length>1&&!e[0].trim();)e.shift();for(;e.length>1&&!e[e.length-1].trim();)e.pop();return e.map(n=>`@// ${n.trim()}`.trimEnd()).join(`
623
+ `)}var dl={props:["align","justify","gap","pad","fill","stroke","edge","radius","shadow"],enums:{align:"align",justify:"justify",edge:"edge"},default02:{align:"start"}},kk={column:{to:"column",...dl,slot:"children"},row:{to:"row",...dl,props:[...dl.props,"wrap"],slot:"children"},grid:{to:"grid",...dl,slot:"children",grid:!0},stack:{to:"stack",props:["align","justify","pad"],enums:{align:"align",justify:"justify"},default02:{},slot:"children"},icon:{to:"icon",props:["name","tone","size","label"],enums:{size:"text_size"},glyph:["name"],default02:{}},press:{to:"press",props:["label","kind","selected","disabled","tone"],enums:{kind:"press_kind"},default02:{},slot:"content",events:{click:"click"}},meter:{to:"meter",props:["value","max","label","tone"],default02:{}},image:{to:"image",props:["src","alt"],default02:{}},frame:{to:"frame",props:["title"],default02:{},slot:"body"},pane:{to:"pane",props:["title","note"],default02:{},slot:"body"},heading:{to:"heading",props:["level","text"],rename:{text:"value"},default02:{}},paragraph:{to:"paragraph",props:["text"],rename:{text:"value"},default02:{}},code:{to:"code",props:["src","lang"],default02:{}},math:{to:"math",props:["tex"],default02:{}},divider:{to:"divider",props:[],default02:{}}},Ri=class{constructor(e,n,r){this.m=e,this.decls=n,this.names=r,this.pack=n.pack}at(e){return{line:e?.[0],pack:this.pack,sink:this.decls}}widget(e){let n=this.m,r=this.names.get(e.id).name,i=ir({pack:this.pack}),s=[],o=[],a=[];for(let g of e.inputs){let y=ze(n,g.type,this.pack),$=n.safe(g.name,y.t==="slot"?nr:void 0);if(y.t==="slot"){o.push([$,"view"]),i.inst.set(g.name,C.name($)),i.types.set(g.name,g.type);continue}let b=this.decls.field(g.name,g.type,g.default,{...this.at(g.pos),hint:`${r}_${g.name}`});g.about&&(b.about=g.about),g.comment?.length&&(b.comments=g.comment),s.push(b),i.inst.set(g.name,C.name(b.name)),i.types.set(g.name,g.type)}for(let g of e.outs??[]){if(g.payload)throw new U(`the out ${g.name} carries a payload`);a.push({k:"event",name:n.safe(g.name),comments:g.comment})}let l=null,c=(g,y)=>{let $=(g.pos?.[0]??0)-(g.comment?.length??0);l!==null&&$-l>1&&a.push(fe.blank()),g.comment?.length&&a.push(fe.comment(g.comment.join(`
624
+ `))),a.push(...y),l=g.pos?.[0]??l};if(e.signals?.length||e.commands?.length)throw new U("signals and commands (an extern channel in 0.3)");for(let g of e.values??[]){let y=n.safe(g.name),$=this.at(g.pos);if(g.k==="var"||g.k==="state"&&g.control==="slider"){let b=Ve(n,g.type,{...$,hint:`${r}_${g.name}`}),k="ast"in(g.default??{})?Ce(n,g.default.ast,i,$,g.type):Yt(n,g.default,g.type,$,i);c(g,[fe.mut(y,b.none?`opt<${b.src}>`:b.src,k)]),g.k==="state"&&n.todo($.line,`${g.name}'s slider in the widget's control bar has no 0.3 bar: place @slider(value = ${y}, \u2026) in the view`)}else if(g.k==="derived"){let b=Ve(n,g.value.type,{...$,hint:`${r}_${g.name}`});c(g,[fe.let(y,b.src,Ce(n,g.value.ast,i,$,g.value.type))])}else{if(g.k==="fn")continue;throw new U(`a widget's ${g.k}${g.control?" "+g.control:""} value`)}i.inst.set(g.name,C.name(y)),i.types.set(g.name,g.k==="derived"?g.value.type:g.type)}i.fnDefs=new Map(Object.entries(e.fns??{}));for(let[g,y]of Object.entries(e.fns??{}))i.fns.set(g,n.safe(y.name));let u=new Map((e.values??[]).filter(g=>g.k==="fn").map(g=>[g.fn,g.comment])),f=Object.entries(e.fns??{}).map(([g,y])=>({...this.fn(y,i),comments:u.get(g)})),p=this.nodes(e.view??[],i),h=e.project?.md?this.markdown(e.project.md,i,e):null,d=a.filter(g=>g.k==="event").map(g=>g.comments?.length?{name:g.name,comments:g.comments}:g.name),m=a.filter(g=>g.k!=="event");return{name:r,comments:e.comment,about:e.about,params:s,slots:o,events:d,body:f.length&&m.length?[...m,fe.blank(),...f]:[...m,...f],view:p,markdown:h}}fn(e,n){let r=this.m;if(!e.types)throw new U(`the fn ${e.name} has no parameter types`);let i=this.at(e.pos),s=new Map(e.params.map((l,c)=>[l,[C.name(r.safe(l)),e.types[c]]])),o=e.params.map((l,c)=>[r.safe(l),bk(Ve(r,e.types[c],i))]),a=e.ret?Ve(r,e.ret,i):null;return{k:"fndecl",name:r.safe(e.name),params:o,ret:a?a.none?`opt<${a.src}>`:a.src:null,body:[fe.ret(Ce(r,e.body,Nn(n,s),i,e.ret))]}}markdown(e,n,r){let i=this.m,s=this.at(e.pos),o=(l,c)=>`\\{${ce(Ce(i,l,c,s),"")}}`,a=(l,c)=>{if(l.t==="str")return[se.md(Jt(l.v))];if(l.t==="builtin"&&l.fn==="cat"){let u=[],f=p=>p.t==="builtin"&&p.fn==="cat"?p.args.forEach(f):u.push(p);return l.args.forEach(f),[se.md(u.map(p=>p.t==="str"?Jt(p.v):o(p,c)).join(""))]}if(l.t==="if")return[se.if(Ce(i,l.c,c,s,{t:"bool"}),a(l.a,c),a(l.b,c))];if(l.t==="builtin"&&l.fn==="join"&&l.args[0].t==="builtin"&&l.args[0].fn==="map"&&l.args[0].args[1].t==="lam"){let[u,f]=l.args[0].args,p=i.safe(f.params[0]),h=nt(i,u,c);return[se.for(p,Ce(i,u,c,s),a(f.body,Nn(c,new Map([[f.params[0],[C.name(p),Mr(h)]]]))))]}return[se.md(o(l,c))]};try{return a(e.ast,n)}catch(l){if(!(l instanceof U))throw l;return i.lossy(s.line,`${r.name}'s project md was left out (${l.what}); 0.3 builds a document widget's Markdown from its view`),null}}nodes(e,n){let r=[],i=null;for(let s of e){let o=s.meta?.comment??[],a=(s.pos?.[0]??0)-o.length;i!==null&&s.pos&&a-i>1&&r.push(fe.blank()),o.length&&r.push(fe.comment(o.join(`
625
+ `))),r.push(...this.node(s,n)),i=wk(s)??i}return r}node(e,n){let r=this.m,i=this.at(e.pos),s=this.bare(e,n,i),o=e.meta??{};if(o.id&&r.lossy(i.line,`the element id ${typeof o.id=="string"?o.id:"(computed)"} was dropped: 0.3 has no ids`),o.hidden||o.keep||o.span||o.basis||o.self)throw new U("hidden, keep, span, basis or self on an element");return o.grow&&(s=[fe.call("grow",[],s)]),o.if&&(s=[fe.if([[Ce(r,o.if.ast,n,i,{t:"bool"}),s]])]),s}bare(e,n,r){let i=this.m;switch(e.node){case"each":return this.each(e,n,r);case"switch":{let s=Ce(i,e.subject.ast,n,r),o=ze(i,e.subject.type,this.pack),a=e.cases.map(l=>[[this.pattern(l.value,o,r)],this.nodes(l.children,n)]);return e.else?a.push([["else"],this.nodes(e.else,n)]):o.t!=="choice"&&a.push([["else"],[]]),[fe.match(s,a)]}case"slot":{let s=e.value?.ast;if(s?.t==="var"&&n.inst.has(s.name))return[fe.expr(C.view({name:n.inst.get(s.name).n,args:[]}))];throw new U(`a slot placed from a list (slot ${e.value?.expr??"\u2026"})`)}case"text":return[this.text(e,n,r)];case"range":return[this.slider(e,n,r)];case"field":return[this.field(e,n,r)];case"overlay":return[this.overlay(e,n,r)]}if(kk[e.node]&&e.def?.startsWith("core:"))return[this.base(e,n,r)];if(e.def&&this.names.has(e.def))return[this.use(e,n,r)];throw new U(`the 0.2 ${e.node} element`)}pattern(e,n,r){if("lit"in e)return n.t==="choice"?`${this.decls.enumFor(n.name,n.opts,r.hint)}.${this.m.caseName(e.lit)}`:typeof e.lit=="string"?JSON.stringify(e.lit):String(e.lit);if("text"in e)return JSON.stringify(e.text);throw new U("a case pattern that is not a literal")}each(e,n,r){let i=this.m,s=i.safe(e.var),o=e.in?.ast??e.in,a=u=>u?.t==="builtin"&&u.fn==="range"&&u.args[0].t==="num"&&u.args[0].v===0&&u.args[1].t==="builtin"&&u.args[1].fn==="-"&&u.args[1].args[1].t==="num"&&u.args[1].args[1].v===1&&u.args[1].args[0].t==="builtin"&&u.args[1].args[0].fn==="len",l=e.in?.range?{lo:e.in.range[0],hi:e.in.range[1]}:null,c=null;if(a(o)?c=o.args[1].args[0].args[0]:l&&"ast"in l.hi&&l.hi.ast.t==="builtin"&&l.hi.ast.fn==="-"&&l.hi.ast.args[0].fn==="len"&&l.lo.lit===0&&(c=l.hi.ast.args[0].args[0]),c){let u=i.safe(`${e.var}_item`),f=nt(i,c,n),p=Nn(n,new Map([[e.var,[C.name(s),{t:"int"}]]]));return p.rewrite=[...n.rewrite,[{t:"index",o:c,i:{t:"var",name:e.var,from:"local"}},C.name(u)]],p.types.set(`${e.var}_item`,Mr(f)),[fe.for(u,Ce(i,c,n,r),this.nodes(e.children??[],p),s)]}if(l){let u=Yt(i,l.lo,{t:"int"},r,n),f=Yt(i,l.hi,{t:"int"},r,n);return[fe.for(s,C.range(u,f),this.nodes(e.children??[],Nn(n,new Map([[e.var,[C.name(s),{t:"int"}]]]))))]}if(e.in&&"ast"in e.in){let u=nt(i,e.in.ast,n)??ze(i,e.in.type??{t:"unknown"},this.pack),f=Mr(u);return[fe.for(s,Ce(i,e.in.ast,n,r),this.nodes(e.children??[],Nn(n,new Map([[e.var,[C.name(s),f]]]))))]}throw new U("an each over something other than a list or a range")}arg(e,n,r,i){return Yt(this.m,e,n,i,r)}input02(e,n){return this.m.def(e.def)?.inputs.find(r=>r.name===n)}base(e,n,r){let i=this.m,s=kk[e.node],o=[],a={...e.props??{}};for(let[f,p]of Object.entries(s.default02??{}))f in a||(a[f]={lit:p});(e.node==="column"||e.node==="row")&&("tint"in a&&!("fill"in a)&&(a.fill=a.tint,i.lossy(r.line,"tint (a wash of a colour) became fill")),("padx"in a||"pady"in a)&&!("pad"in a)&&(a.pad=a.padx??a.pady,i.lossy(r.line,"padx/pady became one pad: 0.3 pads all sides alike")));for(let[f,p]of Object.entries(a)){if(f==="tint"||f==="padx"||f==="pady"||f==="cols")continue;if(!s.props.includes(f)){i.lossy(r.line,`${e.node} ${f}=\u2026 has no 0.3 input and was dropped`);continue}let h=this.input02(e,f),d;if(s.enums?.[f]&&"lit"in p)d=C.case(s.enums[f],i.caseName(p.lit));else if(s.glyph?.includes(f)&&"lit"in p){if(p.lit==="none")continue;d=C.case("glyph",i.caseName(p.lit))}else d=this.arg(p,h?.type,n,r);d.k==="case"&&d.type==="opt"||o.push([s.rename?.[f]??f,d])}if(s.grid){let f=a.cols;if(!f)throw new U("a grid with no cols");if("lit"in f&&typeof f.lit=="number")o.unshift(["cols",C.case("cols","EQUAL",[C.num(f.lit)])]);else if("ast"in f&&["num","int"].includes(f.type?.t??nt(i,f.ast,n)?.t))o.unshift(["cols",C.case("cols","EQUAL",[Ce(i,f.ast,n,r)])]);else throw new U("grid cols as tracks")}if(e.node==="press"&&!o.some(([f])=>f==="label")){let f=(e.children??[]).find(p=>p.node==="text")?.props?.value;o.unshift(["label",f?this.arg(f,{t:"text"},n,r):C.text("")])}let l=this.events(e,n,r,s.events??{click:"click"});o.push(...l);let c=this.nodes(e.children??[],n);if(e.fills)throw new U(`fill on a ${e.node}`);if((e.node==="icon"&&e.props?.name&&"ast"in e.props.name?nt(i,e.props.name.ast,n):null)?.t==="icon"){let f=i.safe("glyph_"),p=o.find(([h])=>h==="name")[1];return fe.if([[{k:"open",name:f,type:"glyph",value:p},[fe.call(s.to,o.map(([h,d])=>[h,h==="name"?C.name(f):d]),c.length?c:null)]]])}return fe.call(s.to,o,c.length?c:null)}text(e,n,r){let i=this.m,s=e.props?.value??{text:""},o=f=>/[*_`[\]$\\]/.test(f),a="text"in s?s.text:s.ast?.t==="tmpl"?s.ast.v.replace(/\\val\{\d+\}/g,""):s.ast?.t==="str"?s.ast.v:"",l=[],c=this.arg(s,{t:"text"},n,r);if(o(a)&&("text"in s||s.ast?.t==="tmpl"||s.ast?.t==="str"))return i.lossy(r.line,"a text with inline Markdown became a paragraph (0.3 labels are plain)"),fe.call("paragraph",[["value",c]]);l.push(["value",c]);let u=e.props??{};if(u.tone){let f=this.arg(u.tone,{t:"token",kind:"color"},n,r);f.k==="case"&&f.type==="opt"||l.push(["tone",f])}u.size&&"lit"in u.size&&l.push(["size",C.case("text_size",i.caseName(u.size.lit))]),u.weight&&"lit"in u.weight&&l.push(["weight",C.case("weight",i.caseName(u.weight.lit))]),u.font&&"tok"in u.font&&u.font.tok!=="body"&&l.push(["font",C.case("font",i.caseName(u.font.tok))]),u.align&&"lit"in u.align&&l.push(["align",C.case("align",i.caseName(u.align.lit))]),u.wrap&&"lit"in u.wrap&&l.push(["wrap",C.bool(u.wrap.lit)]),u.clip&&"lit"in u.clip&&l.push(["clip",C.bool(u.clip.lit)]);for(let f of Object.keys(u))["value","tone","size","weight","font","align","wrap","clip"].includes(f)||i.lossy(r.line,`text ${f}=\u2026 has no 0.3 label input and was dropped`);return fe.call("label",l)}slider(e,n,r){let i=this.m,s=e.props??{};if(!s.value||!("ast"in s.value)||s.value.ast.t!=="var")throw new U("a range whose value is not a variable");let o=[["value",Ce(i,s.value.ast,n,r)],["label",s.label?this.arg(s.label,{t:"text"},n,r):C.text("")]];if(s.min&&s.max&&o.push(["range",C.range(this.arg(s.min,{t:"num"},n,r),this.arg(s.max,{t:"num"},n,r))]),e.on&&Object.keys(e.on).length)throw new U("a range with @change actions");return fe.call("slider",o)}field(e,n,r){let i=this.m,s=e.props??{};if(!s.value||!("ast"in s.value)||s.value.ast.t!=="var")throw new U("a field whose value is not a variable");if(s.kind&&s.kind.lit==="number")throw new U("a number field (0.3 fields hold text)");let o=[["value",Ce(i,s.value.ast,n,r)],["label",s.label?this.arg(s.label,{t:"text"},n,r):C.text("")]];return s.placeholder&&o.push(["placeholder",this.arg(s.placeholder,{t:"text"},n,r)]),o.push(...this.events(e,n,r,{submit:"submit"})),fe.call("field",o)}overlay(e,n,r){let i=e.props??{},s=[["label",i.label?this.arg(i.label,{t:"text"},n,r):C.text("")]];i.mode&&"lit"in i.mode&&s.push(["mode",C.case("overlay_mode",this.m.caseName(i.mode.lit))]);let o=this.nodes(e.children??[],n),a=this.nodes(e.fills?.body??[],n);return fe.call("overlay",s,null,[["anchor",o],["body",a]])}events(e,n,r,i){let s=[];for(let[o,a]of Object.entries(e.on??{})){let l=i[o];if(!l)throw new U(`the event @${o} on ${e.node}`);s.push([l,C.lambda([],this.actions(a,n,r))])}return s}actions(e,n,r){let i=this.m;return e.flatMap(s=>{switch(s.a){case"set":{let o=s.target==="state"?C.state(s.name):n.inst.get(s.name)??C.name(i.safe(s.name));return[fe.assign(o,Ce(i,s.value.ast,n,r,n.types.get(s.name)??s.value.type))]}case"emit":if(s.payload?.length)throw new U("an emit with a payload");return[fe.invoke(i.safe(s.name))];case"when":return[fe.if([[Ce(i,s.cond.ast,n,r,{t:"bool"}),this.actions(s.actions,n,r)]])];default:throw new U(`the action ${s.a}`)}})}use(e,n,r){let i=this.m,{name:s}=this.names.get(e.def),o=i.def(e.def);this.decls.want?.(e.def);let a=[];for(let[c,u]of Object.entries(e.props??{})){let f=o.inputs.find(p=>p.name===c);if(!f)throw new U(`${o.name} has no input ${c}`);a.push([i.safe(c),this.arg(u,f.type,n,r)])}if(e.records?.length)throw new U("record lines in a use inside a view");a.push(...this.events(e,n,r,Object.fromEntries((o.outs??[]).map(c=>[c.name,i.safe(c.name)]))));let l=this.nodes(e.children??[],n);return fe.call(s,a,l.length?l:null)}};function ml(t,e,n,r=ir({pack:n})){for(let i=0;i<4;i++){let s=t.failedFns.size,o=DA(t,e,n,r);if(t.failedFns.size===s)return o}return[]}function DA(t,e,n,r){let i=[];for(let[s,o]of Object.entries(t.b.fns??{})){if(t.failedFns.has(s)||!s.startsWith(`${n}:`)||o.generic)continue;let a={line:o.pos?.[0],pack:n,sink:e};try{if(o.op)throw new U(`an operator (op ${o.op}): 0.3 joins a type to an operator through an interface`);if(!o.types)throw new U("a fn without parameter types");let l=o.params.map((f,p)=>[t.safe(f),bk(Ve(t,o.types[p],a))]);if(l.some(([,f])=>/^[A-Z]/.test(f)))throw new U("a generic fn");let c=new Map(o.params.map((f,p)=>[f,[C.name(t.safe(f)),o.types[p]]])),u=o.ret?Ve(t,o.ret,a):null;i.push(Be.fn(t.safe(o.name),l,u?u.none?`opt<${u.src}>`:u.src:null,[fe.ret(Ce(t,o.body,Nn(r,c),a,o.ret))]))}catch(l){if(!(l instanceof U))throw l;t.failedFns.add(s),t.todo(a.line,`the fn ${o.name} was not migrated: ${l.what}`)}}return i}function bk(t){return t.none?`opt<${t.src}>`:t.src}function wk(t){let e=t.pos?.[0]??null,n=[...t.children??[],...t.records??[],...t.else??[],...(t.cases??[]).flatMap(r=>r.children),...Object.values(t.fills??{}).flat()];for(let r of n){let i=wk(r);i!==null&&(e===null||i>e)&&(e=i)}for(let r of Object.values(t.on??{}).flat())r.value?.pos?.[0]>(e??0)&&(e=r.value.pos[0]);return e}var gl=class extends Ii{constructor(e,n,r){super(e,n),this.version=r,this.widgets=new Map,this.real=!!e.opts.packWidgets,this.rich=!this.real,this.defNames=new Map(Object.values(e.b.defs).filter(i=>i.pack===n).map(i=>[i.id,{name:this.name(i.name,"widget")}])),this.written=0,this.fns=this.real?ml(e,this,n):[]}want(e){this.defNames.has(e)&&this.widget(e)}widget(e){if(this.widgets.has(e))return this.widgets.get(e);let n=this.m,r=n.def(e),i={line:r.pos?.[0],pack:this.pack,sink:this,rich:this.rich},s=this.defNames.get(e)?.name??this.name(r.name,"widget"),o={name:s,id:e,params:[],slots:[],kids:new Map,inputs:new Map,def:r};this.widgets.set(e,o);let a=[];for(let c of r.inputs){let u=ze(n,c.type,this.pack);if(u.t==="slot"){o.slots.push([this.slotName(c.name),"view",c.name]);continue}if(u.t==="records"&&u.slot){let f=this.kid(u,r,i);o.kids.set(u.kind,f),o.slots.push([this.slotName(c.name),`list<${f.name}>`,c.name]);continue}try{let f=this.field(c.name,c.type,c.default,{...i,hint:`${s}_${c.name}`});c.about&&(f.about=c.about),c.comment?.length&&(f.comments=c.comment),o.params.push(f),o.inputs.set(c.name,{f,t:c.type}),u.t==="records"&&a.push([f.name,u])}catch(f){if(!(f instanceof U))throw f;n.todo(i.line,`${r.name}'s input ${c.name} was left out of the 0.3 shim: ${f.what}`)}}o.inputs.has("summary")||o.params.push({name:"summary",type:"text",default:C.text(""),about:"the 0.2 block's summary: one sentence for readers without the widget"});let l=this.markdown(o,a);if(o.decl=Be.widget({name:s,extern:!0,comments:r.comment,about:r.about??void 0,params:o.params,slots:o.slots.map(([c,u])=>[c,u]),markdown:l}),this.real&&r.kind!=="extern")try{let c=new Ri(n,this,this.defNames).widget(r),u=[...c.params,...o.params.filter(f=>!c.params.some(p=>p.name===f.name))];o.decl=Be.widget({...c,params:u,markdown:c.markdown??l}),this.written++}catch(c){if(!(c instanceof U))throw c;n.todo(i.line,`${this.pack}'s ${r.name} stays an extern widget with a markdown block: its view did not migrate (${c.what})`)}return o}slotName(e){let n=this.m.safe(e,nr);return(this.used.has(n)||[...this.widgets.values()].some(r=>r.name===n))&&(n=`${n}_slot`),n}kid(e,n,r){let i=this.name(e.kind,"widget"),s=[];for(let[u,f]of e.fields)try{s.push(this.field(u,f,e.defaults?.[u],{...r,hint:`${i}_${u}`}))}catch(p){if(!(p instanceof U))throw p;this.m.todo(r.line,`${n.name}'s ${e.kind} field ${u} was left out: ${p.what}`)}let o=s.find(u=>/^(rich_)?text$/.test(u.type)),a=[...o?[se.md(`**\\{${o.name}}**`)]:[],se.md("\\{body}")],l=Be.widget({name:i,extern:!0,about:`One ${e.kind} of ${n.name}.`,params:s,slots:[["body","view"]],markdown:a}),c={name:i,params:s,decl:l,fields:new Map(e.fields.map(([u,f])=>[u,{f:s.find(p=>p.name===this.m.safe(u)),t:f}]))};return this.extraDecls??=[],this.extraDecls.push(l),c}markdown(e,n){let r=[se.md("\\{summary}")];for(let[i,s]of n){let a=(this.records.get(this.names.get(`record:${s.kind}`))?.fields??[]).filter(c=>/^(rich_)?text$|^(int|number)\b/.test(c.type)).slice(0,3);if(!a.length)continue;let l="x";r.push(se.for(l,C.name(i),[se.md(`- ${a.map(c=>`\\{${l}.${c.name}}`).join(" \u2014 ")}`)]))}for(let[i,s]of e.slots)r.push(s==="view"?se.md(`\\{${i}}`):se.for("k",C.name(i),[se.md("\\{k}")]));return r}file(){let e=this.fns,n=[...this.widgets.values()].map(r=>r.name);for(let r of this.extraDecls??[])n.push(r.name);for(let r of[...this.decls(),...e])r.name.includes(".")||n.push(r.name);return[Be.comment(`The ${this.pack}@${this.version} pack's interface, migrated from MKP 0.2 by tools/migrate-0.2.
626
+ Each widget is an extern with a markdown block: a 0.3 pack draws it with a view instead.`),Be.pack(this.pack,this.version,["core@1"],[...new Set(n)]),...this.decls(),...e,...this.extraDecls??[],...[...this.widgets.values()].map(r=>r.decl)]}};function $k(t,e={}){if(t.ir!==1||t.level!=="bundle")throw new Error(`expected a 0.2 bundle (ir 1, level bundle); found ir ${t.ir}, level ${t.level}`);let n=new ul(t,e);n.src=e.source?hk(e.source):null;let r=new Ii(n,"$doc"),i={blocks:0,widgets:0,fallbacks:0,defs:0,defsMigrated:0},s=[],o=ir();for(let[k,w]of Object.entries(t.consts??{}))try{let v={line:w.pos?.[0],pack:"$doc",sink:r};s.push(Be.let(n.safe(k),Ve(n,w.type,v).src,Ce(n,w.ast,o,v,w.type))),o.consts.set(k,C.name(n.safe(k)))}catch(v){if(!(v instanceof U))throw v;n.todo(w.pos?.[0],`the constant ${k} was not migrated: ${v.what}`)}s.push(...ml(n,r,"$doc",o));let a=Object.values(t.defs).filter(k=>k.pack==="$doc"&&k.name!=="document"),l=new Map(a.map(k=>[k.id,{name:r.name(k.name,"widget")}])),c=new Ri(n,r,l),u=[];for(let k of a){i.defs++;try{let w=c.widget(k);l.get(k.id).w=w,u.push(Be.widget(w)),i.defsMigrated++}catch(w){if(!(w instanceof U))throw w;let v=RA(n,r,k,l.get(k.id).name,w.what,e.source);l.get(k.id).w=v.w,u.push(v.decl)}}let f=t.defs["$doc:document@1"],p=[],h=[],d=ir();for(let k of f?.values??[]){let w={line:k.pos?.[0],pack:"$doc",sink:r,hint:k.name};try{if(k.k==="state"||k.k==="var"){if(!k.default)throw new U(`${k.name} has no starting value`);let v=Ve(n,k.type,w),D=Yt(n,k.default,k.type,w,d),I=k.k==="state"&&k.args?.step&&"lit"in k.args.step?` step ${k.args.step.lit}`:"",L=k.control==="slider"&&k.args?.min&&k.args?.max?` ${k.args.min.lit}..${k.args.max.lit}`:"";p.push({name:n.safe(k.name),type:v.src+(v.src==="number"?L+I:""),default:D,comments:[...k.comment??[],...k.label?[k.label]:[]]}),d.inst.set(k.name,C.state(n.safe(k.name))),d.types.set(k.name,k.type)}else if(k.k==="derived"){let v=Ve(n,k.value.type,w);h.push(Be.let(n.safe(k.name),v.src,Ce(n,k.value.ast,d,w,k.value.type))),d.inst.set(k.name,C.name(n.safe(k.name))),d.types.set(k.name,k.value.type)}else throw new U(`a document ${k.k}`)}catch(v){if(!(v instanceof U))throw v;n.todo(w.line,`the document value ${k.name} was not migrated: ${v.what}`)}}let m=new hl(n,k=>{i.blocks++;try{let w=MA(n,k,{doc:r,names:l,writer:c,pw:m,docDef:f,docScope:d});return i.widgets++,w}catch(w){if(!(w instanceof U))throw w;return i.fallbacks++,Qf(n,k,w.what,v=>m.blocks(v))}},n.src),g=[];for(let k of t.doc.body)try{k.pos&&g.push(...m.flush(k.pos[0],k)),g.push(...m.block(k))}catch(w){if(!(w instanceof U))throw w;i.fallbacks++,g.push(...Qf(n,k,w.what,v=>m.blocks(v)))}g.push(...m.flush(1/0,null)),n.moved=m.moved;let y=[];for(let k of[...n.packs.keys()].sort())y.push(Be.import(k));y.push(Be.comment(IA(n))),y.push(...r.decls()),p.length&&y.push(Be.state(p)),y.push(...s,...h,...u);let $=NA(n,n.src?.front??(Object.keys(t.doc.front??{}).length?CA(null,t.doc.front):null)),b=new Map([...n.packs].map(([k,w])=>[k,pk(k,w.file())]));return i.packWidgets=[...n.packs.values()].reduce((k,w)=>k+w.widgets.size,0),i.packWidgetsWritten=[...n.packs.values()].reduce((k,w)=>k+w.written,0),{doc:fk({front:$,decls:y,body:g}),packs:b,notes:n.notes,counts:i}}function NA(t,e){if(!e)return e;let n=e.split(`
627
+ `),r=n.filter((i,s)=>s===0||!/^(mkp|ir):\s/.test(i));return r.length!==n.length&&t.lossy(1,`0.2's stamp (${n.filter(i=>/^(mkp|ir):\s/.test(i)).map(i=>i.trim()).join(", ")}) was taken out of the front matter: 0.3 passes front matter to the app untouched`),r.filter(i=>i.trim()).length<=2?null:r.join(`
628
+ `)}function CA(t,e){let n=t&&/^---\n[\s\S]*?\n---\n/.exec(t);return n?n[0]:`---
629
+ ${Object.entries(e).map(([r,i])=>`${r}: ${JSON.stringify(i)}`).join(`
630
+ `)}
631
+ ---
632
+ `}function IA(t){let e=["Migrated from MKP 0.2 by tools/migrate-0.2, from the 0.2 IR. Lines below are lines of the 0.2 source."],n={todo:0,fallback:1,lossy:2,info:3},r=[...t.notes].sort((i,s)=>n[i.kind]-n[s.kind]||(i.line??0)-(s.line??0));r.length||e.push("Nothing to finish by hand.");for(let i of r)e.push(`${i.kind==="todo"?"TODO":i.kind==="fallback"?"TODO (kept as Markdown)":i.kind==="lossy"?"CHANGED":"NOTE"}${i.line?` line ${i.line}`:""}: ${i.what}`);if(t.moved?.length){e.push("","Comments from the 0.2 prose (0.3 would show them as text), each with where it stood:");for(let i of t.moved)e.push(`line ${i.line}, ${i.before}:`,...i.text.split(`
633
+ `).map(s=>` ${s}`))}return e.join(`
634
+ `)}function RA(t,e,n,r,i,s){t.todo(n.pos?.[0],`the definition ${n.name} was not migrated (${i}); a stand-in with its inputs shows its name, and its 0.2 source is kept above it`);let o=[],a=[];for(let c of n.inputs)try{ze(t,c.type,"$doc").t==="slot"?a.push([t.safe(c.name,nr),"opt<view>"]):o.push(e.field(c.name,c.type,c.default,{line:c.pos?.[0],hint:`${r}_${c.name}`}))}catch(u){if(!(u instanceof U))throw u}let l=OA(s,n)??`${n.name} "${n.about??""}" (inputs: ${n.inputs.map(c=>c.name).join(", ")})`;return{w:{name:r,params:o,slots:a},decl:Be.widget({name:r,comments:[...n.comment??[],`TODO: ${n.name} was not migrated: ${i}.`,"Its 0.2 definition:",...l.split(`
635
+ `).map(c=>` ${c}`)],about:n.about,params:o,slots:a,view:[fe.call("label",[["value",C.text(`${n.name}: not migrated from MKP 0.2 yet`)],["tone",C.case("color","MUTED")]])],markdown:[se.md(Jt(n.about??n.name))]})}}function OA(t,e){if(!t||!e.pos)return null;let n=t.split(`
636
+ `),r=[];for(let i=e.pos[0]-1;i<n.length&&!(/^```/.test(n[i])||i>e.pos[0]-1&&/^\S/.test(n[i])&&!/^(#|""")/.test(n[i]));i++)r.push(n[i]);return r.join(`
637
+ `).trimEnd()}function MA(t,e,n){if(e.node==="controls")return qA(t,e,n);let r=t.def(e.def);if(!r)throw new U(`the block ${e.node} names no definition`);return e.meta?.anchor&&t.lossy(e.pos?.[0],`the block's id #${e.meta.anchor} was dropped: 0.3 has no ids`),r.pack==="core"?LA(t,e,n):r.pack==="$doc"?jA(t,e,n):PA(t,e,r,n)}function LA(t,e,n){let r=n.writer.node({...e,children:[]},n.docScope);if(r.length!==1||r[0].k!=="call")throw new U(`the base widget ${e.node} as a document block`);let i=e.children?.length?n.pw.blocks(e.children,yl(t,e),e):null;return[se.call(r[0].name,r[0].args,i)]}function jA(t,e,n){let r=n.names.get(e.def),i=t.def(e.def),s=r.w;if(!s)throw new U(`${i.name} was not migrated, so its use can't be either`);let o=[];for(let[l,c]of Object.entries(e.props??{})){let u=i.inputs.find(h=>h.name===l),f=s.params.find(h=>h.name===t.safe(l));if(!u||!f)throw new U(`${i.name} has no input ${l}`);let p=io(t,c,u.type,{line:e.pos?.[0],pack:"$doc",sink:n.doc});f.default&&ce(f.default)===ce(p)||o.push([f.name,p,l])}if(e.records?.length){let l=new Map;for(let c of e.records)(l.get(c.input)??l.set(c.input,[]).get(c.input)).push(c);for(let[c,u]of l){let f=i.inputs.find(h=>h.name===c),p=ze(t,f.type,"$doc");if(p.t!=="records"||p.slot)throw new U(`${i.name}'s ${c} records with content`);o.push([t.safe(c),Xf(t,u,p,n.doc,"$doc",e.pos?.[0],ep(t,e),c),c])}}e.meta?.summary&&t.lossy(e.pos?.[0],`the summary of this ${i.name} block was dropped: 0.3 builds a document widget's Markdown from the widget ("${e.meta.summary.slice(0,60)}")`);let a=e.children?.length?n.pw.blocks(e.children,yl(t,e),e):null;if(a&&!s.slots.length)throw new U(`content for ${i.name}, which has no slot`);return[se.call(r.name,vk(t,e,o),a)]}function Xf(t,e,n,r,i,s,o=null,a=null){let l=r.recordFor(n.kind,n.fields,n.defaults,{line:s,pack:i,sink:r,rich:!!r.rich}),c=r.records.get(l),u=new Map(n.fields),f=o?.items.get(a)??[],p=o?.fields.get(a)??[],h=e.map((d,m)=>{let g=[],y=[...Object.keys(d.props??{}),...n.fields.map(([k])=>k).filter(k=>!(k in(d.props??{})))];for(let k of y){let w=u.get(k);if(!w)continue;let v=c.fields.find(L=>L.name===t.safe(k)),D=ze(t,w,i),I;if(D.t==="records"){let L=(d.records??[]).filter(T=>T.input===k);if(!L.length)continue;I=Xf(t,L,D,r,i,s)}else{let L=d.props?.[k];if(L===void 0)continue;I=io(t,L,w,{line:d.pos?.[0]??s,pack:i,sink:r,hint:`${l}_${k}`})}v?.default&&ce(v.default)===ce(I)||I.k==="case"&&I.type==="opt"&&!v?.default||g.push([v?.name??t.safe(k),I])}let $=f[m],b=[...p[m]??new Map].flatMap(([k,w])=>[...w.before.map(v=>`${k}: ${v}`),...w.after?[`${k}: ${w.after}`]:[]]);return Wf(C.rec(l,g),[...$?.before??[],...b],$?.after??null)});return C.list(h,!0)}function ep(t,e){return e.pos?t.src?.yaml.get(e.pos[0])??null:null}function yl(t,e){return e.pos?t.src?.ends.get(e.pos[0])??null:null}function vk(t,e,n){let r=ep(t,e);if(!r)return n.map(([s,o])=>[s,o]);let i=s=>r.order.includes(s)?r.order.indexOf(s):r.order.length;return[...n].sort((s,o)=>i(s[2])-i(o[2])).map(([s,o,a])=>{let l=r.keys.get(a);return[s,l?Wf(o,l.before,l.after):o]})}function PA(t,e,n,r){let i=t.packs.get(n.pack);i||t.packs.set(n.pack,i=new gl(t,n.pack,n.version));let s=i.widget(n.id),o=e.pos?.[0],a={line:o,pack:n.pack,sink:i,rich:!0},l=[];for(let[h,d]of Object.entries(e.props??{})){let m=s.inputs.get(h);if(!m){t.todo(o,`${n.name}'s ${h} has no input in the 0.3 shim and was left out`);continue}let g=io(t,d,m.t,{...a,hint:`${s.name}_${h}`});m.f.default&&ce(m.f.default)===ce(g)||g.k==="case"&&g.type==="opt"||l.push([m.f.name,g,h])}let c=new Map;for(let h of e.records??[])(c.get(h.input)??c.set(h.input,[]).get(h.input)).push(h);let u=new Map;for(let[h,d]of c){let m=n.inputs.find($=>$.name===h),g=ze(t,m.type,n.pack);if(g.t==="records"&&g.slot){let $=s.kids.get(g.kind);u.set(h,d.map(b=>se.call($.name,_A(t,b,$,a),r.pw.blocks(b.children??[],yl(t,b),b))));continue}let y=s.inputs.get(h)?.f;l.push([y?.name??t.safe(h),Xf(t,d,g,i,n.pack,o,ep(t,e),h),h])}e.meta?.summary&&l.push(["summary",C.text(e.meta.summary),"summary"]);let f=[];for(let[h,d,m]of s.slots)if(d==="view"){let g=s.slots.find(([,$])=>$==="view")[0]===h,y=e.fills?.[m]??(g?e.children:null);y?.length&&f.push([h,r.pw.blocks(y,yl(t,e),e)])}else u.has(m)&&f.push([h,u.get(m)]);if(e.fills){for(let h of Object.keys(e.fills))if(!s.slots.some(([,,d])=>d===h))throw new U(`:::fill ${h} names no slot of ${n.name}`)}if(!s.slots.length&&e.children?.length)throw new U(`content inside ${n.name}, which has no slot`);let p=vk(t,e,l);return s.slots.length===1?[se.call(s.name,p,f[0]?.[1]??(s.slots[0][1]==="view"&&e.children?[]:null))]:[se.call(s.name,p,null,f.length?f:null)]}function _A(t,e,n,r){let i=[];for(let[s,{f:o,t:a}]of n.fields){let l=e.props?.[s];if(l===void 0||!o)continue;let c=io(t,l,a,{...r,hint:`${n.name}_${s}`});o.default&&ce(o.default)===ce(c)||i.push([o.name,c])}return i}function qA(t,e,n){let r=[];for(let i of e.names??[]){let s=(n.docDef?.values??[]).find(l=>l.name===i),o=C.state(t.safe(i)),a=C.text(s?.label??i);if(s?.k==="state"&&s.control==="slider"){let l=[["value",o],["label",a]];s.args?.min&&s.args?.max&&l.push(["range",C.range(C.num(s.args.min.lit),C.num(s.args.max.lit))]),r.push(se.call("slider",l))}else s?.k==="state"&&s.control==="toggle"?r.push(se.call("press",[["label",a],["kind",C.case("press_kind","SWITCH")],["selected",o],["click",C.lambda([],[fe.assign(o,C.un("!",o))])]])):(t.todo(e.pos?.[0],`the ${s?.control??s?.k??""} control for ${i} has no 0.3 widget here (play, steps, drag and clock need a timer or a canvas); $state.${t.safe(i)} keeps its value`),r.push(se.md(`*${Jt(s?.label??i)}*: \\{$state.${t.safe(i)}}`)))}return r}function FA(t){let e=new Map,n=r=>{for(let i of(0,At.readdirSync)(r)){if(i==="node_modules"||i.startsWith("."))continue;let s=(0,Cn.join)(r,i),o=(0,At.statSync)(s,{throwIfNoEntry:!1});if(o){if(o.isSymbolicLink())throw new Error(`${s} is a symlink; packs may not hold links`);o.isDirectory()?n(s):e.set((0,Cn.relative)(t,s).split("\\").join("/"),new Uint8Array((0,At.readFileSync)(s)))}}};return n(t),e}function BA(t){let e=(0,Cn.resolve)(t);if(!(0,At.existsSync)(e))throw new Error(`no pack at ${t}`);return(0,At.statSync)(e).isDirectory()?{label:(0,Cn.relative)(process.cwd(),e)||".",files:FA(e)}:{label:(0,Cn.basename)(e),zip:new Uint8Array((0,At.readFileSync)(e))}}function VA(t){let e=[],n;for(let f=0;f<t.length;f++)t[f]==="--pack"?e.push(t[++f]):n=t[f];if(!n)return{release:Et,error:"usage: node migrate-0.2.cjs <doc.mkp.md> [--pack <0.2 pack>]\u2026"};let r=(0,At.readFileSync)(n,"utf8"),i=zf({packs:e.map(BA)}),s=new Tt;for(let f of i.diags.items)s.items.push(f);let o=n.replace(/\.mkp\.md$/,".mkp"),a=o!==n&&(0,At.existsSync)(o)?{text:(0,At.readFileSync)(o,"utf8"),file:o}:void 0,l=i.document(r,n,s,{docFile:a}),c=s.items.map(f=>op(f));if(!l||!s.ok)return{release:Et,error:`${Et} doesn't build it`,diagnostics:c};let u=$k(l,{source:r});return{release:Et,doc:u.doc,packs:Object.fromEntries(u.packs),notes:u.notes,counts:u.counts,diagnostics:c}}var kl;try{kl=VA(process.argv.slice(2))}catch(t){kl={release:Et,error:t?.message??String(t)}}process.stdout.write(JSON.stringify(kl)+`
638
+ `);process.exitCode=kl.error?1:0;