@uniweb/runtime 0.9.10 → 0.10.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,59 @@
1
+ import{Y as j,i as Dt,a as W,b as jt,s as at,S as A,m as D,o as Te,p as Ne,c as Ce,M as Ft,d as B,e as Kt,f as Ut,g as ee,h as xe,j as Fe,l as qt,N as Ke,D as Ue,k as ae,n as Vt,q as Ht,A as ot,r as zt,t as O,P as oe,u as te,v as Y,w as qe,x as Gt,y as Wt,z as Yt,B as lt,L as Jt,C as Xt,E as Qt,F as ge,G as Zt,H as es}from"./index-n0uF7vTr.js";import"./shade-generator-BBzWo1IN.js";import{n as Ve}from"./normalize-DbApPPeG.js";const U={collection:"map",default:!0,nodeClass:j,tag:"tag:yaml.org,2002:map",resolve(n,e){return Dt(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>j.from(n,e,t)},q={collection:"seq",default:!0,nodeClass:W,tag:"tag:yaml.org,2002:seq",resolve(n,e){return jt(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>W.from(n,e,t)},le={identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify(n,e,t,s){return e=Object.assign({actualString:!0},e),at(n,e,t,s)}},ce={identify:n=>n==null,createNode:()=>new A(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new A(null),stringify:({source:n},e)=>typeof n=="string"&&ce.test.test(n)?n:e.options.nullStr},$e={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new A(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&$e.test.test(n)){const s=n[0]==="t"||n[0]==="T";if(e===s)return n}return e?t.options.trueStr:t.options.falseStr}};function N({format:n,minFractionDigits:e,tag:t,value:s}){if(typeof s=="bigint")return String(s);const i=typeof s=="number"?s:Number(s);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let r=Object.is(s,-0)?"-0":JSON.stringify(s);if(!n&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^\d/.test(r)){let a=r.indexOf(".");a<0&&(a=r.length,r+=".");let o=e-(r.length-a-1);for(;o-- >0;)r+="0"}return r}const ct={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:N},ut={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n),stringify(n){const e=Number(n.value);return isFinite(e)?e.toExponential():N(n)}},ft={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(n){const e=new A(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:N},ue=n=>typeof n=="bigint"||Number.isInteger(n),Oe=(n,e,t,{intAsBigInt:s})=>s?BigInt(n):parseInt(n.substring(e),t);function ht(n,e,t){const{value:s}=n;return ue(s)&&s>=0?t+s.toString(e):N(n)}const dt={identify:n=>ue(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>Oe(n,2,8,t),stringify:n=>ht(n,8,"0o")},pt={identify:ue,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>Oe(n,0,10,t),stringify:N},gt={identify:n=>ue(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>Oe(n,2,16,t),stringify:n=>ht(n,16,"0x")},ts=[U,q,le,ce,$e,dt,pt,gt,ct,ut,ft];function He(n){return typeof n=="bigint"||Number.isInteger(n)}const se=({value:n})=>JSON.stringify(n),ss=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:se},{identify:n=>n==null,createNode:()=>new A(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:se},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:se},{identify:He,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(n,e,{intAsBigInt:t})=>t?BigInt(n):parseInt(n,10),stringify:({value:n})=>He(n)?n.toString():JSON.stringify(n)},{identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:n=>parseFloat(n),stringify:se}],ns={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},is=[U,q].concat(ss,ns),Be={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof atob=="function"){const t=atob(n.replace(/[\n\r]/g,"")),s=new Uint8Array(t.length);for(let i=0;i<t.length;++i)s[i]=t.charCodeAt(i);return s}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),n},stringify({comment:n,type:e,value:t},s,i,r){if(!t)return"";const a=t;let o;if(typeof btoa=="function"){let l="";for(let c=0;c<a.length;++c)l+=String.fromCharCode(a[c]);o=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=A.BLOCK_LITERAL),e!==A.QUOTE_DOUBLE){const l=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(o.length/l),u=new Array(c);for(let f=0,h=0;f<c;++f,h+=l)u[f]=o.substr(h,l);o=u.join(e===A.BLOCK_LITERAL?`
2
+ `:" ")}return at({comment:n,type:e,value:o},s,i,r)}};function mt({value:n,source:e},t){return e&&(n?yt:bt).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}const yt={identify:n=>n===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new A(!0),stringify:mt},bt={identify:n=>n===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new A(!1),stringify:mt},rs={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:N},as={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n.replace(/_/g,"")),stringify(n){const e=Number(n.value);return isFinite(e)?e.toExponential():N(n)}},os={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(n){const e=new A(parseFloat(n.replace(/_/g,""))),t=n.indexOf(".");if(t!==-1){const s=n.substring(t+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:N},Q=n=>typeof n=="bigint"||Number.isInteger(n);function fe(n,e,t,{intAsBigInt:s}){const i=n[0];if((i==="-"||i==="+")&&(e+=1),n=n.substring(e).replace(/_/g,""),s){switch(t){case 2:n=`0b${n}`;break;case 8:n=`0o${n}`;break;case 16:n=`0x${n}`;break}const a=BigInt(n);return i==="-"?BigInt(-1)*a:a}const r=parseInt(n,t);return i==="-"?-1*r:r}function Ee(n,e,t){const{value:s}=n;if(Q(s)){const i=s.toString(e);return s<0?"-"+t+i.substr(1):t+i}return N(n)}const ls={identify:Q,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>fe(n,2,2,t),stringify:n=>Ee(n,2,"0b")},cs={identify:Q,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>fe(n,1,8,t),stringify:n=>Ee(n,8,"0")},us={identify:Q,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>fe(n,0,10,t),stringify:N},fs={identify:Q,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>fe(n,2,16,t),stringify:n=>Ee(n,16,"0x")};function Pe(n,e){const t=n[0],s=t==="-"||t==="+"?n.substring(1):n,i=a=>e?BigInt(a):Number(a),r=s.replace(/_/g,"").split(":").reduce((a,o)=>a*i(60)+i(o),i(0));return t==="-"?i(-1)*r:r}function kt(n){let{value:e}=n,t=a=>a;if(typeof e=="bigint")t=a=>BigInt(a);else if(isNaN(e)||!isFinite(e))return N(n);let s="";e<0&&(s="-",e*=t(-1));const i=t(60),r=[e%i];return e<60?r.unshift(0):(e=(e-r[0])/i,r.unshift(e%i),e>=60&&(e=(e-r[0])/i,r.unshift(e))),s+r.map(a=>String(a).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const vt={identify:n=>typeof n=="bigint"||Number.isInteger(n),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(n,e,{intAsBigInt:t})=>Pe(n,t),stringify:kt},wt={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:n=>Pe(n,!1),stringify:kt},he={identify:n=>n 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(n){const e=n.match(he.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,t,s,i,r,a,o]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0;let c=Date.UTC(t,s-1,i,r||0,a||0,o||0,l);const u=e[8];if(u&&u!=="Z"){let f=Pe(u,!1);Math.abs(f)<30&&(f*=60),c-=6e4*f}return new Date(c)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},ze=[U,q,le,ce,yt,bt,ls,cs,us,fs,rs,as,os,Be,D,Te,Ne,Ce,vt,wt,he],Ge=new Map([["core",ts],["failsafe",[U,q,le]],["json",is],["yaml11",ze],["yaml-1.1",ze]]),We={binary:Be,bool:$e,float:ft,floatExp:ut,floatNaN:ct,floatTime:wt,int:pt,intHex:gt,intOct:dt,intTime:vt,map:U,merge:D,null:ce,omap:Te,pairs:Ne,seq:q,set:Ce,timestamp:he},hs={"tag:yaml.org,2002:binary":Be,"tag:yaml.org,2002:merge":D,"tag:yaml.org,2002:omap":Te,"tag:yaml.org,2002:pairs":Ne,"tag:yaml.org,2002:set":Ce,"tag:yaml.org,2002:timestamp":he};function me(n,e,t){const s=Ge.get(e);if(s&&!n)return t&&!s.includes(D)?s.concat(D):s.slice();let i=s;if(!i)if(Array.isArray(n))i=[];else{const r=Array.from(Ge.keys()).filter(a=>a!=="yaml11").map(a=>JSON.stringify(a)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${r} or define customTags array`)}if(Array.isArray(n))for(const r of n)i=i.concat(r);else typeof n=="function"&&(i=n(i.slice()));return t&&(i=i.concat(D)),i.reduce((r,a)=>{const o=typeof a=="string"?We[a]:a;if(!o){const l=JSON.stringify(a),c=Object.keys(We).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(o)||r.push(o),r},[])}const ds=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0;class Me{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:i,schema:r,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?me(e,"compat"):e?me(null,e):null,this.name=typeof r=="string"&&r||"core",this.knownTags=i?hs:{},this.tags=me(t,this.name,s),this.toStringOptions=o??null,Object.defineProperty(this,Ft,{value:U}),Object.defineProperty(this,B,{value:le}),Object.defineProperty(this,Kt,{value:q}),this.sortMapEntries=typeof a=="function"?a:a===!0?ds:null}clone(){const e=Object.create(Me.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}function ps(n,e){const t=[];let s=e.directives===!0;if(e.directives!==!1&&n.directives){const l=n.directives.toString(n);l?(t.push(l),s=!0):n.directives.docStart&&(s=!0)}s&&t.push("---");const i=Ut(n,e),{commentString:r}=i.options;if(n.commentBefore){t.length!==1&&t.unshift("");const l=r(n.commentBefore);t.unshift(ee(l,""))}let a=!1,o=null;if(n.contents){if(xe(n.contents)){if(n.contents.spaceBefore&&s&&t.push(""),n.contents.commentBefore){const u=r(n.contents.commentBefore);t.push(ee(u,""))}i.forceBlockIndent=!!n.comment,o=n.contents.comment}const l=o?void 0:()=>a=!0;let c=Fe(n.contents,i,()=>o=null,l);o&&(c+=qt(c,"",r(o))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(Fe(n.contents,i));if(n.directives?.docEnd)if(n.comment){const l=r(n.comment);l.includes(`
3
+ `)?(t.push("..."),t.push(ee(l,""))):t.push(`... ${l}`)}else t.push("...");else{let l=n.comment;l&&a&&(l=l.replace(/^\n+/,"")),l&&((!a||o)&&t[t.length-1]!==""&&t.push(""),t.push(ee(r(l),"")))}return t.join(`
4
+ `)+`
5
+ `}class de{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Ke,{value:Ue});let i=null;typeof t=="function"||Array.isArray(t)?i=t:s===void 0&&t&&(s=t,t=void 0);const r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=r;let{version:a}=r;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new ae({version:a}),this.setSchema(a,s),this.contents=e===void 0?null:this.createNode(e,i,s)}clone(){const e=Object.create(de.prototype,{[Ke]:{value:Ue}});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=xe(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){E(this.contents)&&this.contents.add(e)}addIn(e,t){E(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const s=Vt(this);e.anchor=!t||s.has(t)?Ht(t||"a",s):t}return new ot(e.anchor)}createNode(e,t,s){let i;if(typeof t=="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){const g=v=>typeof v=="number"||v instanceof String||v instanceof Number,k=t.filter(g).map(String);k.length>0&&(t=t.concat(k)),i=t}else s===void 0&&t&&(s=t,t=void 0);const{aliasDuplicateObjects:r,anchorPrefix:a,flow:o,keepUndefined:l,onTagObj:c,tag:u}=s??{},{onAnchor:f,setAnchors:h,sourceObjects:p}=Yt(this,a||"a"),m={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:f,onTagObj:c,replacer:i,schema:this.schema,sourceObjects:p},d=zt(e,u,m);return o&&O(d)&&(d.flow=!0),h(),d}createPair(e,t,s={}){const i=this.createNode(e,null,s),r=this.createNode(t,null,s);return new oe(i,r)}delete(e){return E(this.contents)?this.contents.delete(e):!1}deleteIn(e){return te(e)?this.contents==null?!1:(this.contents=null,!0):E(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return O(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return te(e)?!t&&Y(this.contents)?this.contents.value:this.contents:O(this.contents)?this.contents.getIn(e,t):void 0}has(e){return O(this.contents)?this.contents.has(e):!1}hasIn(e){return te(e)?this.contents!==void 0:O(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=qe(this.schema,[e],t):E(this.contents)&&this.contents.set(e,t)}setIn(e,t){te(e)?this.contents=t:this.contents==null?this.contents=qe(this.schema,Array.from(e),t):E(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let s;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new ae({version:"1.1"}),s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new ae({version:e}),s={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{const i=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(s)this.schema=new Me(Object.assign(s,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:i,onAnchor:r,reviver:a}={}){const o={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},l=Gt(this.contents,t??"",o);if(typeof r=="function")for(const{count:c,res:u}of o.anchors.values())r(u,c);return typeof a=="function"?Wt(a,{"":l},"",l):l}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}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)){const t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return ps(this,e)}}function E(n){if(O(n))return!0;throw new Error("Expected a YAML collection as document contents")}class It extends Error{constructor(e,t,s,i){super(),this.name=e,this.code=s,this.message=i,this.pos=t}}class z extends It{constructor(e,t,s){super("YAMLParseError",e,t,s)}}class gs extends It{constructor(e,t,s){super("YAMLWarning",e,t,s)}}const Ye=(n,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(o=>e.linePos(o));const{line:s,col:i}=t.linePos[0];t.message+=` at line ${s}, column ${i}`;let r=i-1,a=n.substring(e.lineStarts[s-1],e.lineStarts[s]).replace(/[\n\r]+$/,"");if(r>=60&&a.length>80){const o=Math.min(r-39,a.length-79);a="…"+a.substring(o),r-=o-1}if(a.length>80&&(a=a.substring(0,79)+"…"),s>1&&/^ *$/.test(a.substring(0,r))){let o=n.substring(e.lineStarts[s-2],e.lineStarts[s-1]);o.length>80&&(o=o.substring(0,79)+`…
6
+ `),a=o+a}if(/[^ ]/.test(a)){let o=1;const l=t.linePos[1];l?.line===s&&l.col>i&&(o=Math.max(1,Math.min(l.col-i,80-r)));const c=" ".repeat(r)+"^".repeat(o);t.message+=`:
7
+
8
+ ${a}
9
+ ${c}
10
+ `}};function F(n,{flow:e,indicator:t,next:s,offset:i,onError:r,parentIndent:a,startOnNewline:o}){let l=!1,c=o,u=o,f="",h="",p=!1,m=!1,d=null,g=null,k=null,v=null,S=null,I=null,w=null;for(const y of n)switch(m&&(y.type!=="space"&&y.type!=="newline"&&y.type!=="comma"&&r(y.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),d&&(c&&y.type!=="comment"&&y.type!=="newline"&&r(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),d=null),y.type){case"space":!e&&(t!=="doc-start"||s?.type!=="flow-collection")&&y.source.includes(" ")&&(d=y),u=!0;break;case"comment":{u||r(y,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const L=y.source.substring(1)||" ";f?f+=h+L:f=L,h="",c=!1;break}case"newline":c?f?f+=y.source:(!I||t!=="seq-item-ind")&&(l=!0):h+=y.source,c=!0,p=!0,(g||k)&&(v=y),u=!0;break;case"anchor":g&&r(y,"MULTIPLE_ANCHORS","A node can have at most one anchor"),y.source.endsWith(":")&&r(y.offset+y.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=y,w??(w=y.offset),c=!1,u=!1,m=!0;break;case"tag":{k&&r(y,"MULTIPLE_TAGS","A node can have at most one tag"),k=y,w??(w=y.offset),c=!1,u=!1,m=!0;break}case t:(g||k)&&r(y,"BAD_PROP_ORDER",`Anchors and tags must be after the ${y.source} indicator`),I&&r(y,"UNEXPECTED_TOKEN",`Unexpected ${y.source} in ${e??"collection"}`),I=y,c=t==="seq-item-ind"||t==="explicit-key-ind",u=!1;break;case"comma":if(e){S&&r(y,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),S=y,c=!1,u=!1;break}default:r(y,"UNEXPECTED_TOKEN",`Unexpected ${y.type} token`),c=!1,u=!1}const b=n[n.length-1],_=b?b.offset+b.source.length:i;return m&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!=="")&&r(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),d&&(c&&d.indent<=a||s?.type==="block-map"||s?.type==="block-seq")&&r(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:S,found:I,spaceBefore:l,comment:f,hasNewline:p,anchor:g,tag:k,newlineAfterProp:v,end:_,start:w??_}}function J(n){if(!n)return null;switch(n.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(n.source.includes(`
11
+ `))return!0;if(n.end){for(const e of n.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(const e of n.items){for(const t of e.start)if(t.type==="newline")return!0;if(e.sep){for(const t of e.sep)if(t.type==="newline")return!0}if(J(e.key)||J(e.value))return!0}return!1;default:return!0}}function Ie(n,e,t){if(e?.type==="flow-collection"){const s=e.end[0];s.indent===n&&(s.source==="]"||s.source==="}")&&J(e)&&t(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function St(n,e,t){const{uniqueKeys:s}=n.options;if(s===!1)return!1;const i=typeof s=="function"?s:(r,a)=>r===a||Y(r)&&Y(a)&&r.value===a.value;return e.some(r=>i(r.key,t))}const Je="All mapping items must start at the same column";function ms({composeNode:n,composeEmptyNode:e},t,s,i,r){const a=r?.nodeClass??j,o=new a(t.schema);t.atRoot&&(t.atRoot=!1);let l=s.offset,c=null;for(const u of s.items){const{start:f,key:h,sep:p,value:m}=u,d=F(f,{indicator:"explicit-key-ind",next:h??p?.[0],offset:l,onError:i,parentIndent:s.indent,startOnNewline:!0}),g=!d.found;if(g){if(h&&(h.type==="block-seq"?i(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in h&&h.indent!==s.indent&&i(l,"BAD_INDENT",Je)),!d.anchor&&!d.tag&&!p){c=d.end,d.comment&&(o.comment?o.comment+=`
12
+ `+d.comment:o.comment=d.comment);continue}(d.newlineAfterProp||J(h))&&i(h??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else d.found?.indent!==s.indent&&i(l,"BAD_INDENT",Je);t.atKey=!0;const k=d.end,v=h?n(t,h,d,i):e(t,k,f,null,d,i);t.schema.compat&&Ie(s.indent,h,i),t.atKey=!1,St(t,o.items,v)&&i(k,"DUPLICATE_KEY","Map keys must be unique");const S=F(p??[],{indicator:"map-value-ind",next:m,offset:v.range[2],onError:i,parentIndent:s.indent,startOnNewline:!h||h.type==="block-scalar"});if(l=S.end,S.found){g&&(m?.type==="block-map"&&!S.hasNewline&&i(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&d.start<S.found.offset-1024&&i(v.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const I=m?n(t,m,S,i):e(t,l,p,null,S,i);t.schema.compat&&Ie(s.indent,m,i),l=I.range[2];const w=new oe(v,I);t.options.keepSourceTokens&&(w.srcToken=u),o.items.push(w)}else{g&&i(v.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),S.comment&&(v.comment?v.comment+=`
13
+ `+S.comment:v.comment=S.comment);const I=new oe(v);t.options.keepSourceTokens&&(I.srcToken=u),o.items.push(I)}}return c&&c<l&&i(c,"IMPOSSIBLE","Map comment with trailing content"),o.range=[s.offset,l,c??l],o}function ys({composeNode:n,composeEmptyNode:e},t,s,i,r){const a=r?.nodeClass??W,o=new a(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let l=s.offset,c=null;for(const{start:u,value:f}of s.items){const h=F(u,{indicator:"seq-item-ind",next:f,offset:l,onError:i,parentIndent:s.indent,startOnNewline:!0});if(!h.found)if(h.anchor||h.tag||f)f?.type==="block-seq"?i(h.end,"BAD_INDENT","All sequence items must start at the same column"):i(l,"MISSING_CHAR","Sequence item without - indicator");else{c=h.end,h.comment&&(o.comment=h.comment);continue}const p=f?n(t,f,h,i):e(t,h.end,u,null,h,i);t.schema.compat&&Ie(s.indent,f,i),l=p.range[2],o.items.push(p)}return o.range=[s.offset,l,c??l],o}function Z(n,e,t,s){let i="";if(n){let r=!1,a="";for(const o of n){const{source:l,type:c}=o;switch(c){case"space":r=!0;break;case"comment":{t&&!r&&s(o,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const u=l.substring(1)||" ";i?i+=a+u:i=u,a="";break}case"newline":i&&(a+=l),r=!0;break;default:s(o,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:i,offset:e}}const ye="Block collections are not allowed within flow collections",be=n=>n&&(n.type==="block-map"||n.type==="block-seq");function bs({composeNode:n,composeEmptyNode:e},t,s,i,r){const a=s.start.source==="{",o=a?"flow map":"flow sequence",l=r?.nodeClass??(a?j:W),c=new l(t.schema);c.flow=!0;const u=t.atRoot;u&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let f=s.offset+s.start.source.length;for(let g=0;g<s.items.length;++g){const k=s.items[g],{start:v,key:S,sep:I,value:w}=k,b=F(v,{flow:o,indicator:"explicit-key-ind",next:S??I?.[0],offset:f,onError:i,parentIndent:s.indent,startOnNewline:!1});if(!b.found){if(!b.anchor&&!b.tag&&!I&&!w){g===0&&b.comma?i(b.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${o}`):g<s.items.length-1&&i(b.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${o}`),b.comment&&(c.comment?c.comment+=`
14
+ `+b.comment:c.comment=b.comment),f=b.end;continue}!a&&t.options.strict&&J(S)&&i(S,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)b.comma&&i(b.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${o}`);else if(b.comma||i(b.start,"MISSING_CHAR",`Missing , between ${o} items`),b.comment){let _="";e:for(const y of v)switch(y.type){case"comma":case"space":break;case"comment":_=y.source.substring(1);break e;default:break e}if(_){let y=c.items[c.items.length-1];lt(y)&&(y=y.value??y.key),y.comment?y.comment+=`
15
+ `+_:y.comment=_,b.comment=b.comment.substring(_.length+1)}}if(!a&&!I&&!b.found){const _=w?n(t,w,b,i):e(t,b.end,I,null,b,i);c.items.push(_),f=_.range[2],be(w)&&i(_.range,"BLOCK_IN_FLOW",ye)}else{t.atKey=!0;const _=b.end,y=S?n(t,S,b,i):e(t,_,v,null,b,i);be(S)&&i(y.range,"BLOCK_IN_FLOW",ye),t.atKey=!1;const L=F(I??[],{flow:o,indicator:"map-value-ind",next:w,offset:y.range[2],onError:i,parentIndent:s.indent,startOnNewline:!1});if(L.found){if(!a&&!b.found&&t.options.strict){if(I)for(const T of I){if(T===L.found)break;if(T.type==="newline"){i(T,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}b.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?.[0]===":"?i(w,"MISSING_CHAR",`Missing space after : in ${o}`):i(L.start,"MISSING_CHAR",`Missing , or : between ${o} items`));const x=w?n(t,w,L,i):L.found?e(t,L.end,I,null,L,i):null;x?be(w)&&i(x.range,"BLOCK_IN_FLOW",ye):L.comment&&(y.comment?y.comment+=`
16
+ `+L.comment:y.comment=L.comment);const V=new oe(y,x);if(t.options.keepSourceTokens&&(V.srcToken=k),a){const T=c;St(t,T.items,y)&&i(_,"DUPLICATE_KEY","Map keys must be unique"),T.items.push(V)}else{const T=new j(t.schema);T.flow=!0,T.items.push(V);const je=(x??y).range;T.range=[y.range[0],je[1],je[2]],c.items.push(T)}f=x?x.range[2]:L.end}}const h=a?"}":"]",[p,...m]=s.end;let d=f;if(p?.source===h)d=p.offset+p.source.length;else{const g=o[0].toUpperCase()+o.substring(1),k=u?`${g} must end with a ${h}`:`${g} in block collection must be sufficiently indented and end with a ${h}`;i(f,u?"MISSING_CHAR":"BAD_INDENT",k),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){const g=Z(m,d,t.options.strict,i);g.comment&&(c.comment?c.comment+=`
17
+ `+g.comment:c.comment=g.comment),c.range=[s.offset,d,g.offset]}else c.range=[s.offset,d,d];return c}function ke(n,e,t,s,i,r){const a=t.type==="block-map"?ms(n,e,t,s,r):t.type==="block-seq"?ys(n,e,t,s,r):bs(n,e,t,s,r),o=a.constructor;return i==="!"||i===o.tagName?(a.tag=o.tagName,a):(i&&(a.tag=i),a)}function ks(n,e,t,s,i){const r=s.tag,a=r?e.directives.tagName(r.source,h=>i(r,"TAG_RESOLVE_FAILED",h)):null;if(t.type==="block-seq"){const{anchor:h,newlineAfterProp:p}=s,m=h&&r?h.offset>r.offset?h:r:h??r;m&&(!p||p.offset<m.offset)&&i(m,"MISSING_CHAR","Missing newline after block sequence props")}const o=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!r||!a||a==="!"||a===j.tagName&&o==="map"||a===W.tagName&&o==="seq")return ke(n,e,t,i,a);let l=e.schema.tags.find(h=>h.tag===a&&h.collection===o);if(!l){const h=e.schema.knownTags[a];if(h?.collection===o)e.schema.tags.push(Object.assign({},h,{default:!1})),l=h;else return h?i(r,"BAD_COLLECTION_TYPE",`${h.tag} used for ${o} collection, but expects ${h.collection??"scalar"}`,!0):i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${a}`,!0),ke(n,e,t,i,a)}const c=ke(n,e,t,i,a,l),u=l.resolve?.(c,h=>i(r,"TAG_RESOLVE_FAILED",h),e.options)??c,f=xe(u)?u:new A(u);return f.range=c.range,f.tag=a,l?.format&&(f.format=l.format),f}function vs(n,e,t){const s=e.offset,i=ws(e,n.options.strict,t);if(!i)return{value:"",type:null,comment:"",range:[s,s,s]};const r=i.mode===">"?A.BLOCK_FOLDED:A.BLOCK_LITERAL,a=e.source?Is(e.source):[];let o=a.length;for(let d=a.length-1;d>=0;--d){const g=a[d][1];if(g===""||g==="\r")o=d;else break}if(o===0){const d=i.chomp==="+"&&a.length>0?`
18
+ `.repeat(Math.max(1,a.length-1)):"";let g=s+i.length;return e.source&&(g+=e.source.length),{value:d,type:r,comment:i.comment,range:[s,g,g]}}let l=e.indent+i.indent,c=e.offset+i.length,u=0;for(let d=0;d<o;++d){const[g,k]=a[d];if(k===""||k==="\r")i.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&t(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=d,l===0&&!n.atRoot&&t(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+k.length+1}for(let d=a.length-1;d>=o;--d)a[d][0].length>l&&(o=d+1);let f="",h="",p=!1;for(let d=0;d<u;++d)f+=a[d][0].slice(l)+`
19
+ `;for(let d=u;d<o;++d){let[g,k]=a[d];c+=g.length+k.length+1;const v=k[k.length-1]==="\r";if(v&&(k=k.slice(0,-1)),k&&g.length<l){const I=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;t(c-k.length-(v?2:1),"BAD_INDENT",I),g=""}r===A.BLOCK_LITERAL?(f+=h+g.slice(l)+k,h=`
20
+ `):g.length>l||k[0]===" "?(h===" "?h=`
21
+ `:!p&&h===`
22
+ `&&(h=`
23
+
24
+ `),f+=h+g.slice(l)+k,h=`
25
+ `,p=!0):k===""?h===`
26
+ `?f+=`
27
+ `:h=`
28
+ `:(f+=h+k,h=" ",p=!1)}switch(i.chomp){case"-":break;case"+":for(let d=o;d<a.length;++d)f+=`
29
+ `+a[d][0].slice(l);f[f.length-1]!==`
30
+ `&&(f+=`
31
+ `);break;default:f+=`
32
+ `}const m=s+i.length+e.source.length;return{value:f,type:r,comment:i.comment,range:[s,m,m]}}function ws({offset:n,props:e},t,s){if(e[0].type!=="block-scalar-header")return s(e[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:i}=e[0],r=i[0];let a=0,o="",l=-1;for(let h=1;h<i.length;++h){const p=i[h];if(!o&&(p==="-"||p==="+"))o=p;else{const m=Number(p);!a&&m?a=m:l===-1&&(l=n+h)}}l!==-1&&s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,u="",f=i.length;for(let h=1;h<e.length;++h){const p=e[h];switch(p.type){case"space":c=!0;case"newline":f+=p.source.length;break;case"comment":t&&!c&&s(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=p.source.length,u=p.source.substring(1);break;case"error":s(p,"UNEXPECTED_TOKEN",p.message),f+=p.source.length;break;default:{const m=`Unexpected token in block scalar header: ${p.type}`;s(p,"UNEXPECTED_TOKEN",m);const d=p.source;d&&typeof d=="string"&&(f+=d.length)}}}return{mode:r,indent:a,chomp:o,comment:u,length:f}}function Is(n){const e=n.split(/\n( *)/),t=e[0],s=t.match(/^( *)/),r=[s?.[1]?[s[1],t.slice(s[1].length)]:["",t]];for(let a=1;a<e.length;a+=2)r.push([e[a],e[a+1]]);return r}function Ss(n,e,t){const{offset:s,type:i,source:r,end:a}=n;let o,l;const c=(h,p,m)=>t(s+h,p,m);switch(i){case"scalar":o=A.PLAIN,l=_s(r,c);break;case"single-quoted-scalar":o=A.QUOTE_SINGLE,l=As(r,c);break;case"double-quoted-scalar":o=A.QUOTE_DOUBLE,l=Ls(r,c);break;default:return t(n,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[s,s+r.length,s+r.length]}}const u=s+r.length,f=Z(a,u,e,t);return{value:l,type:o,comment:f.comment,range:[s,u,f.offset]}}function _s(n,e){let t="";switch(n[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${n[0]}`;break}case"@":case"`":{t=`reserved character ${n[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),_t(n)}function As(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),_t(n.slice(1,-1)).replace(/''/g,"'")}function _t(n){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
33
+ `,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
34
+ `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let s=e.exec(n);if(!s)return n;let i=s[1],r=" ",a=e.lastIndex;for(t.lastIndex=a;s=t.exec(n);)s[1]===""?r===`
35
+ `?i+=r:r=`
36
+ `:(i+=r+s[1],r=" "),a=t.lastIndex;const o=/[ \t]*(.*)/sy;return o.lastIndex=a,s=o.exec(n),i+r+(s?.[1]??"")}function Ls(n,e){let t="";for(let s=1;s<n.length-1;++s){const i=n[s];if(!(i==="\r"&&n[s+1]===`
37
+ `))if(i===`
38
+ `){const{fold:r,offset:a}=Ts(n,s);t+=r,s=a}else if(i==="\\"){let r=n[++s];const a=Ns[r];if(a)t+=a;else if(r===`
39
+ `)for(r=n[s+1];r===" "||r===" ";)r=n[++s+1];else if(r==="\r"&&n[s+1]===`
40
+ `)for(r=n[++s+1];r===" "||r===" ";)r=n[++s+1];else if(r==="x"||r==="u"||r==="U"){const o={x:2,u:4,U:8}[r];t+=Cs(n,s+1,o,e),s+=o}else{const o=n.substr(s-1,2);e(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${o}`),t+=o}}else if(i===" "||i===" "){const r=s;let a=n[s+1];for(;a===" "||a===" ";)a=n[++s+1];a!==`
41
+ `&&!(a==="\r"&&n[s+2]===`
42
+ `)&&(t+=s>r?n.slice(r,s+1):i)}else t+=i}return(n[n.length-1]!=='"'||n.length===1)&&e(n.length,"MISSING_CHAR",'Missing closing "quote'),t}function Ts(n,e){let t="",s=n[e+1];for(;(s===" "||s===" "||s===`
43
+ `||s==="\r")&&!(s==="\r"&&n[e+2]!==`
44
+ `);)s===`
45
+ `&&(t+=`
46
+ `),e+=1,s=n[e+1];return t||(t=" "),{fold:t,offset:e}}const Ns={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
47
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Cs(n,e,t,s){const i=n.substr(e,t),a=i.length===t&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){const o=n.substr(e-2,t+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${o}`),o}return String.fromCodePoint(a)}function At(n,e,t,s){const{value:i,type:r,comment:a,range:o}=e.type==="block-scalar"?vs(n,e,s):Ss(e,n.options.strict,s),l=t?n.directives.tagName(t.source,f=>s(t,"TAG_RESOLVE_FAILED",f)):null;let c;n.options.stringKeys&&n.atKey?c=n.schema[B]:l?c=xs(n.schema,i,l,t,s):e.type==="scalar"?c=$s(n,i,e,s):c=n.schema[B];let u;try{const f=c.resolve(i,h=>s(t??e,"TAG_RESOLVE_FAILED",h),n.options);u=Y(f)?f:new A(f)}catch(f){const h=f instanceof Error?f.message:String(f);s(t??e,"TAG_RESOLVE_FAILED",h),u=new A(i)}return u.range=o,u.source=i,r&&(u.type=r),l&&(u.tag=l),c.format&&(u.format=c.format),a&&(u.comment=a),u}function xs(n,e,t,s,i){if(t==="!")return n[B];const r=[];for(const o of n.tags)if(!o.collection&&o.tag===t)if(o.default&&o.test)r.push(o);else return o;for(const o of r)if(o.test?.test(e))return o;const a=n.knownTags[t];return a&&!a.collection?(n.tags.push(Object.assign({},a,{default:!1,test:void 0})),a):(i(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),n[B])}function $s({atKey:n,directives:e,schema:t},s,i,r){const a=t.tags.find(o=>(o.default===!0||n&&o.default==="key")&&o.test?.test(s))||t[B];if(t.compat){const o=t.compat.find(l=>l.default&&l.test?.test(s))??t[B];if(a.tag!==o.tag){const l=e.tagString(a.tag),c=e.tagString(o.tag),u=`Value may be parsed as either ${l} or ${c}`;r(i,"TAG_RESOLVE_FAILED",u,!0)}}return a}function Os(n,e,t){if(e){t??(t=e.length);for(let s=t-1;s>=0;--s){let i=e[s];switch(i.type){case"space":case"comment":case"newline":n-=i.source.length;continue}for(i=e[++s];i?.type==="space";)n+=i.source.length,i=e[++s];break}}return n}const Bs={composeNode:Lt,composeEmptyNode:Re};function Lt(n,e,t,s){const i=n.atKey,{spaceBefore:r,comment:a,anchor:o,tag:l}=t;let c,u=!0;switch(e.type){case"alias":c=Es(n,e,s),(o||l)&&s(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=At(n,e,l,s),o&&(c.anchor=o.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=ks(Bs,n,e,t,s),o&&(c.anchor=o.source.substring(1))}catch(f){const h=f instanceof Error?f.message:String(f);s(e,"RESOURCE_EXHAUSTION",h)}break;default:{const f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;s(e,"UNEXPECTED_TOKEN",f),u=!1}}return c??(c=Re(n,e.offset,void 0,null,t,s)),o&&c.anchor===""&&s(o,"BAD_ALIAS","Anchor cannot be an empty string"),i&&n.options.stringKeys&&(!Y(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&s(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),r&&(c.spaceBefore=!0),a&&(e.type==="scalar"&&e.source===""?c.comment=a:c.commentBefore=a),n.options.keepSourceTokens&&u&&(c.srcToken=e),c}function Re(n,e,t,s,{spaceBefore:i,comment:r,anchor:a,tag:o,end:l},c){const u={type:"scalar",offset:Os(e,t,s),indent:-1,source:""},f=At(n,u,o,c);return a&&(f.anchor=a.source.substring(1),f.anchor===""&&c(a,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(f.spaceBefore=!0),r&&(f.comment=r,f.range[2]=l),f}function Es({options:n},{offset:e,source:t,end:s},i){const r=new ot(t.substring(1));r.source===""&&i(e,"BAD_ALIAS","Alias cannot be an empty string"),r.source.endsWith(":")&&i(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const a=e+t.length,o=Z(s,a,n.strict,i);return r.range=[e,a,o.offset],o.comment&&(r.comment=o.comment),r}function Ps(n,e,{offset:t,start:s,value:i,end:r},a){const o=Object.assign({_directives:e},n),l=new de(void 0,o),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=F(s,{indicator:"doc-start",next:i??r?.[0],offset:t,onError:a,parentIndent:0,startOnNewline:!0});u.found&&(l.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!u.hasNewline&&a(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=i?Lt(c,i,u,a):Re(c,u.end,s,null,u,a);const f=l.contents.range[2],h=Z(r,f,!1,a);return h.comment&&(l.comment=h.comment),l.range=[t,f,h.offset],l}function H(n){if(typeof n=="number")return[n,n+1];if(Array.isArray(n))return n.length===2?n:[n[0],n[1]];const{offset:e,source:t}=n;return[e,e+(typeof t=="string"?t.length:1)]}function Xe(n){let e="",t=!1,s=!1;for(let i=0;i<n.length;++i){const r=n[i];switch(r[0]){case"#":e+=(e===""?"":s?`
48
+
49
+ `:`
50
+ `)+(r.substring(1)||" "),t=!0,s=!1;break;case"%":n[i+1]?.[0]!=="#"&&(i+=1),t=!1;break;default:t||(s=!0),t=!1}}return{comment:e,afterEmptyLine:s}}class Ms{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,i,r)=>{const a=H(t);r?this.warnings.push(new gs(a,s,i)):this.errors.push(new z(a,s,i))},this.directives=new ae({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:s,afterEmptyLine:i}=Xe(this.prelude);if(s){const r=e.contents;if(t)e.comment=e.comment?`${e.comment}
51
+ ${s}`:s;else if(i||e.directives.docStart||!r)e.commentBefore=s;else if(O(r)&&!r.flow&&r.items.length>0){let a=r.items[0];lt(a)&&(a=a.key);const o=a.commentBefore;a.commentBefore=o?`${s}
52
+ ${o}`:s}else{const a=r.commentBefore;r.commentBefore=a?`${s}
53
+ ${a}`:s}}t?(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:Xe(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(const i of e)yield*this.next(i);yield*this.end(t,s)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,s,i)=>{const r=H(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",s,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=Ps(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{const t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,s=new z(H(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(s):this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){const s="Unexpected doc-end without preceding document";this.errors.push(new z(H(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;const t=Z(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const s=this.doc.comment;this.doc.comment=s?`${s}
54
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new z(H(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){const s=Object.assign({_directives:this.directives},this.options),i=new de(void 0,s);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),i.range=[0,t,t],this.decorate(i,!1),yield i}}}class Rs{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,s=this.lineStarts.length;for(;t<s;){const r=t+s>>1;this.lineStarts[r]<e?t=r+1:s=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};const i=this.lineStarts[t-1];return{line:t,col:e-i+1}}}}function $(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function Qe(n){for(let e=0;e<n.length;++e)switch(n[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Tt(n){switch(n?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function ne(n){switch(n.type){case"document":return n.start;case"block-map":{const e=n.items[n.items.length-1];return e.sep??e.start}case"block-seq":return n.items[n.items.length-1].start;default:return[]}}function P(n){if(n.length===0)return[];let e=n.length;e:for(;--e>=0;)switch(n[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;n[++e]?.type==="space";);return n.splice(e,n.length)}function Ze(n){if(n.start.type==="flow-seq-start")for(const e of n.items)e.sep&&!e.value&&!$(e.start,"explicit-key-ind")&&!$(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Tt(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)}class Ds{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 Jt,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(const s of this.lexer.lex(e,t))yield*this.next(s);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}const t=Xt(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){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{const s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,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(){const e=this.peek(1);if(this.type==="doc-end"&&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){const t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{const s=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in s?s.indent:0:t.type==="flow-collection"&&s.type==="document"&&(t.indent=0),t.type==="flow-collection"&&Ze(t),s.type){case"document":s.value=t;break;case"block-scalar":s.props.push(t);break;case"block-map":{const i=s.items[s.items.length-1];if(i.value){s.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=t;else{Object.assign(i,{key:t,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{const i=s.items[s.items.length-1];i.value?s.items.push({start:[],value:t}):i.value=t;break}case"flow-collection":{const i=s.items[s.items.length-1];!i||i.value?s.items.push({start:[],key:t,sep:[]}):i.sep?i.value=t:Object.assign(i,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){const i=t.items[t.items.length-1];i&&!i.sep&&!i.value&&i.start.length>0&&Qe(i.start)===-1&&(t.indent===0||i.start.every(r=>r.type!=="comment"||r.indent<t.indent))&&(s.type==="document"?s.end=i.start:s.items.push({start:i.start}),t.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":{const 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":{Qe(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}const t=this.startBlockValue(e);t?this.stack.push(t):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"){const t=ne(this.peek(2)),s=P(t);let i;e.end?(i=e.end,i.push(this.sourceToken),delete e.end):i=[this.sourceToken];const r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}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 t=this.source.indexOf(`
55
+ `)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
56
+ `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const s=!this.onKeyLine&&this.indent===e.indent,i=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind";let r=[];if(i&&t.sep&&!t.value){const a=[];for(let o=0;o<t.sep.length;++o){const l=t.sep[o];switch(l.type){case"newline":a.push(o);break;case"space":break;case"comment":l.indent>e.indent&&(a.length=0);break;default:a.length=0}}a.length>=2&&(r=t.sep.splice(a[1]))}switch(this.type){case"anchor":case"tag":i||t.value?(r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):i||t.value?(r.push(this.sourceToken),e.items.push({start:r,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(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if($(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(Tt(t.key)&&!$(t.sep,"newline")){const a=P(t.start),o=t.key,l=t.sep;l.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:o,sep:l}]})}else r.length>0?t.sep=t.sep.concat(r,this.sourceToken):t.sep.push(this.sourceToken);else if($(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const a=P(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||i?e.items.push({start:r,key:null,sep:[this.sourceToken]}):$(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const a=this.flowScalar(this.type);i||t.value?(e.items.push({start:r,key:a,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(a):(Object.assign(t,{key:a,sep:[]}),this.onKeyLine=!0);return}default:{const a=this.startBlockValue(e);if(a){if(a.type==="block-seq"){if(!t.explicitKey&&t.sep&&!$(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else s&&e.items.push({start:r});this.stack.push(a);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){const s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){const i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||$(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){const s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const i=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:i,sep:[]}):t.sep?this.stack.push(i):Object.assign(t,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}const s=this.startBlockValue(e);s?this.stack.push(s):(yield*this.pop(),yield*this.step())}else{const s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){const i=ne(s),r=P(i);Ze(e);const a=e.end.splice(1,e.end.length);a.push(this.sourceToken);const o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:a}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
57
+ `)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
58
+ `,t)+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;const t=ne(e),s=P(t);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const t=ne(e),s=P(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(s=>s.type==="newline"||s.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;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function js(n){const e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new Rs||null,prettyErrors:e}}function Fs(n,e={}){const{lineCounter:t,prettyErrors:s}=js(e),i=new Ds(t?.addNewLine),r=new Ms(e);let a=null;for(const o of r.compose(i.parse(n),!0,n.length))if(!a)a=o;else if(a.options.logLevel!=="silent"){a.errors.push(new z(o.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&t&&(a.errors.forEach(Ye(n,t)),a.warnings.forEach(Ye(n,t))),a}function Ks(n,e,t){let s;const i=Fs(n,t);if(!i)return null;if(i.warnings.forEach(r=>Qt(i.options.logLevel,r)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:s},t))}function Us(n){return String(n).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function qs(n,e){const{language:t,tag:s,data:i}=e||{};if(!s)return n;if(i!==void 0)return i;const r=(t||"").toLowerCase();if(r==="json")try{return JSON.parse(n)}catch{return n}if(r==="yaml"||r==="yml")try{return Ks(n)}catch{return n}return n}function X(n){return n.type==="UniwebIcon"||n.type==="image"&&n.attrs?.role==="icon"}function M(n,e={}){const t=[];return Vs(n,t,e),t}function Vs(n,e,t){n.content&&Array.isArray(n.content)&&n.content?.forEach(s=>{const i=Hs(s,t);i&&(Array.isArray(i)?e.push(...i):e.push(i))})}function Hs(n,e={}){const t=n.attrs,s=n.content,i=sn(n);if(i)return{type:"link",attrs:i};const r=nn(n);if(r)return r;const a=rn(n);if(a)return a;switch(n.type){case"heading":return{type:"heading",level:n.attrs.level,text:R(s,e),children:G(s),attrs:t};case"paragraph":return{type:"paragraph",text:R(s,e),children:G(s),attrs:t};case"blockquote":return{type:"blockquote",children:M({content:s}),attrs:t};case"inset_block":{const{component:l,...c}=t||{};return{type:"inset_block",component:l,params:c,children:M({content:s})}}case"concept_block":return{type:"concept_block",tag:t?.tag,children:M({content:s},e)};case"dataBlock":return{type:"dataBlock",data:t.data,tag:t.tag};case"codeBlock":{const l=R(s,e);return t?.tag?{type:"dataBlock",tag:t.tag,data:qs(l,t)}:{type:"codeBlock",text:l,attrs:t}}case"inset_placeholder":return{type:"inset",refId:t.refId};case"math_display":return{type:"math",display:!0,id:n.attrs?.id||null,latex:n.attrs?.latex||"",mathml:n.attrs?.mathml||"",attrs:t};case"ImageBlock":return{type:"image",attrs:Se(t)};case"image":return t?.role==="video"?{type:"video",attrs:Ct(t)}:{type:"image",attrs:Se(t||{})};case"Video":return{type:"video",attrs:tn(t)};case"bulletList":case"orderedList":{const l=s.map(c=>c.type==="listItem"&&c.content?c.content:null).filter(Boolean);return{type:"list",style:n.type==="bulletList"?"bullet":"ordered",children:l.map(c=>M({content:c})),attrs:t}}case"table":return{type:"table",rows:(s||[]).filter(c=>c.type==="tableRow").map(c=>({cells:(c.content||[]).filter(u=>u.type==="tableCell").map(u=>({children:M({content:u.content},e),header:u.attrs?.header===!0,align:u.attrs?.align||null,colspan:u.attrs?.colspan||1,rowspan:u.attrs?.rowspan||1}))})),attrs:t};case"divider":case"DividerBlock":case"horizontalRule":return{type:"divider",attrs:t};case"card-group":return{type:"card-group",cards:n.content?.filter(l=>l.type==="card"&&!l.attrs?.hidden).map(l=>Qs(l.attrs))||[]};case"document-group":return{type:"document-group",documents:n.content?.filter(l=>l.type==="document").map(l=>Zs(l.attrs))||[]};case"StructuredContent":case"FormBlock":let o=t?.data;if(typeof o=="string")try{o=JSON.parse(o)}catch{}return{type:"form",schemaId:t?.activeSchemaId||null,data:o,attrs:t};case"button":{let l=R(s,e);return l?{type:"button",text:l,children:G(s),attrs:t}:null}case"UniwebIcon":return{type:"icon",attrs:pe(t)};case"Icon":return{type:"icon",attrs:en(t)};default:return{type:n.type,content:R(s,e)}}}const zs=["pdf","doc","docx","xls","xlsx","ppt","pptx","jpg","jpeg","png","webp","gif","svg","mp4","mp3","wav","mov","zip"];function Gs(n){return(n?.marks||[]).find(e=>e.type==="link")||null}function Ws(n,e){return!n||!e?!1:JSON.stringify(n.attrs||{})===JSON.stringify(e.attrs||{})}function Ys(n,e){const t=e.attrs.href,s=e.attrs.target||"_self",i=t.split(".").pop()?.toLowerCase(),r=zs.includes(i);return`<a href="${t}" target="${s}"${r?" download":""}>${n}</a>`}function R(n,e={}){if(!n)return"";const t=[];for(const s of n){const i=s?.type==="text"?Gs(s):null,r=t[t.length-1];i&&r?.link&&Ws(r.link,i)?r.nodes.push(s):t.push({link:i,nodes:[s]})}return t.reduce((s,i)=>{const r=i.nodes.reduce((a,o)=>a+Js(o),"");return!r&&!i.link?s:s+(i.link?Ys(r,i.link):r)},"").trim()}function Js(n){return[n].reduce((e,t)=>{const{type:s,marks:i=[],text:r}=t;if(s==="text"){let a=r||"";if(i.some(o=>o.type==="textStyle")){const o=i.find(l=>l.type==="textStyle")?.attrs?.color;o&&(a=`<span style="color: var(--${o})">${a}</span>`)}if(i.some(o=>o.type==="highlight")&&(a=`<span style="background-color: var(--highlight)">${a}</span>`),i.some(o=>o.type==="span")){const l=i.find(h=>h.type==="span")?.attrs||{},c=[],u=[];l.class&&c.push(`class="${l.class}"`),l.id&&c.push(`id="${l.id}"`);for(const[h,p]of Object.entries(l))h==="class"||h==="id"||(h==="color"?u.push(`color: ${p}`):h==="bg"?u.push(`background: ${p}`):c.push(`${h}="${p}"`));u.length>0&&c.push(`style="${u.join("; ")}"`),a=`<span${c.length>0?` ${c.join(" ")}`:""}>${a}</span>`}return i.some(o=>o.type==="code")&&(a=`<code>${a}</code>`),i.some(o=>o.type==="bold")&&(a=`<strong>${a}</strong>`),i.some(o=>o.type==="italic")&&(a=`<em>${a}</em>`),e+a}else if(s==="math_inline"){const a=Us(t.attrs?.latex||""),o=t.attrs?.mathml||"";return e+`<span data-type="math" data-latex="${a}" data-display="false">${o}</span>`}else if(s==="inset_placeholder"){const a=t.attrs?.refId;return a?e+`<uniweb-inset data-ref-id="${a}"></uniweb-inset>`:e}else return s==="hardBreak"?e+"<br>":e},"")}function G(n){if(!n)return[];const e=[];for(const t of n)if(X(t))e.push({type:"icon",attrs:pe(t.attrs)});else if(t.type==="image"||t.type==="ImageBlock"){const s=t.attrs?.role==="video";e.push({type:s?"video":"image",attrs:s?Ct(t.attrs):Se(t.attrs||{})})}else if(t.type==="math-inline"||t.type==="math_inline")e.push(t);else if(t.type==="inset_placeholder")e.push({type:"inset",refId:t.attrs?.refId,embedKind:t.attrs?.embedKind||"visual"});else if(t.type==="text"&&t.marks){const s=t.marks.find(i=>i.type==="link");s&&e.push({type:"link",attrs:{...s.attrs,label:t.text||""}})}return e}const Xs="https://assets.uniweb.app/";function Nt(n){if(!n||typeof n!="string")return"";const[e,t]=n.split("/");if(!t)return"";const s=t.substring(t.lastIndexOf(".")+1);return`${Xs}dist/${e}/base.${s}`}function K(n){const e=n?.src||n?.url||"";return e||(n?.identifier?Nt(n.identifier):"")}function Qs(n){const{address:e,...t}=n;let s=null;try{e&&(s=JSON.parse(e))}catch{}const{coverImg:i=null,icon:r}=t;return r&&(t.icon=pe(r)),{...t,address:s,coverImg:K(i)}}function Zs(n){const{src:e,info:t={},coverImg:s=null,...i}=n;let r={...i,coverImg:K(s)};if(e)r.href=e;else{const{identifier:a=""}=t;a&&(r.downloadUrl=Nt(a))}return r}function pe(n){const{svg:e,url:t,src:s,size:i,color:r,preserveColors:a,href:o,target:l,library:c,name:u}=n||{},f={};e&&(f.svg=e),(t||s)&&(f.url=t||s),i&&(f.size=i),r&&(f.color=r),a&&(f.preserveColors=a),o&&(f.href=o),l&&(f.target=l);let h=c,p=u;if(!h&&typeof u=="string"&&u.includes(":")){const[m,...d]=u.split(":");h=m,p=d.join(":")}return h&&(f.library=h),p&&(f.name=p),f}function en(n){const{svg:e,theme:t}=n||{},s={};return e&&(s.svg=e),t&&(s.theme=t),s}function Se(n){let{info:e,targetId:t,caption:s="",direction:i,filter:r,alt:a="",src:o,url:l,href:c="",target:u="",theme:f,role:h,credit:p="",id:m,width:d,height:g,loading:k,fit:v,position:S,preview:I,author:w,description:b}=n,{contentType:_,viewType:y,contentId:L,identifier:x}=e||{};const V={center:"basic",wide:"lg",fill:"full"};return s=xt(s),x?l=K(e):!l&&o&&(l=o),{contentType:_,viewType:y,contentId:t||L,url:l,value:x||"",alt:a||s,caption:s,direction:i,filter:r,imgPos:i==="left"||i==="right"?i:"",size:V[i]||"basic",href:c,target:u,theme:f,role:h,credit:p,id:m||void 0,...d!=null&&{width:d},...g!=null&&{height:g},...k&&{loading:k},...v&&{fit:v},...S&&{position:S},...I&&{preview:I},...w&&{author:w},...b&&{description:b}}}function Ct(n){const{src:e,url:t,info:s,poster:i,alt:r="",caption:a="",autoplay:o,muted:l,loop:c,controls:u,href:f="",target:h="",role:p,id:m}=n||{},d={src:K({src:t||e,...s}),alt:r,caption:xt(a),role:p,href:f,target:h};return i&&(d.poster=i),o!==void 0&&(d.autoplay=o),l!==void 0&&(d.muted=l),c!==void 0&&(d.loop=c),u!==void 0&&(d.controls=u),m&&(d.id=m),d}function tn(n){let{src:e,caption:t="",direction:s,info:i={},coverImg:r={},alt:a,href:o="",target:l=""}=n;return{src:K({src:e,...i}),caption:t,direction:s,coverImg:K(r),alt:a,href:o,target:l}}function xt(n){return!n||typeof n!="string"?"":n.replace(/<[^>]*>/g,"").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&apos;/g,"'").replace(/&nbsp;/g," ").replace(/&#(\d+);/g,(t,s)=>String.fromCharCode(Number(s))).replace(/&#x([0-9a-fA-F]+);/g,(t,s)=>String.fromCharCode(parseInt(s,16)))}function sn(n){if(["paragraph","heading"].includes(n.type)){const e=n?.content||[],t=e.filter(s=>X(s)?!1:s.type==="text"?(s.text||"").trim()!=="":!0);if(t.length===1){let s=t[0],i=s?.marks||[];for(let r=0;r<i.length;r++){let a=i[r];if(a?.type==="link"){const o=e.findIndex(u=>u.type==="text"&&u.text===s.text);let l=null,c=null;for(let u=0;u<e.length;u++)if(X(e[u])){const f=pe(e[u].attrs);u<o?l=f:u>o&&(c||(c=f))}return{...a?.attrs,label:s?.text||"",iconBefore:l,iconAfter:c,children:G(e)}}}}}return!1}function nn(n){if(n.type!=="paragraph")return!1;const e=n?.content||[];if(!e.length)return!1;const t=e.filter(i=>!(X(i)||i.type==="text"&&!(i.text||"").trim()));return t.length<2||!t.every(i=>i.type!=="text"?!1:i.marks?.some(a=>a.type==="link"))?!1:t.map(i=>({type:"link",attrs:{...i.marks.find(a=>a.type==="link")?.attrs,label:i.text||""}}))}function rn(n){if(!["paragraph","heading"].includes(n.type))return!1;let e=n?.content||[];if(!e.length)return!1;e=e.filter(o=>!X(o));let t=e[0]?.marks?.find(o=>o.type==="link"&&o.attrs);if(!t||!e.every(o=>o?.marks?.some(l=>l.type==="link"&&l.attrs?.href===t.attrs?.href)||!1))return!1;const{href:s,target:i}=t.attrs,r=e.map(o=>{const l=o.marks?.filter(c=>c.type!=="link")||[];return{...o,marks:l}});let a=R(r);return a?{type:"paragraph",children:G(n.content),text:`<a target="${i}" href="${s}">${a}</a>`,attrs:n.attrs}:!1}function et(n){if(!n)return null;const e={title:n.header.title||"",pretitle:n.header.pretitle||"",subtitle:n.header.subtitle||"",paragraphs:n.body.paragraphs||[],links:n.body.links||[],images:n.body.images||[],icons:n.body.icons||[],lists:n.body.lists||[],videos:n.body.videos||[],insets:n.body.insets||[],snippets:n.body.snippets||[],data:n.body.data||{},quotes:n.body.quotes||[],headings:n.body.headings||[]};return n.body.math&&n.body.math.length&&(e.math=n.body.math),n.body.tables&&n.body.tables.length&&(e.tables=n.body.tables),e}function $t(n,e={}){if(!n.length)return{title:"",pretitle:"",subtitle:"",paragraphs:[],links:[],images:[],icons:[],lists:[],videos:[],insets:[],snippets:[],data:{},quotes:[],headings:[],items:[]};const s=an(n,e).map(c=>_e(c));let i=null,r=[];(e.alwaysItems?!1:un(s))?(i=s[0],r=s.slice(1)):r=s;const o=et(i)||{title:"",pretitle:"",subtitle:"",paragraphs:[],links:[],images:[],icons:[],lists:[],videos:[],insets:[],data:{},quotes:[],headings:[]},l=r.map(et);return{...o,items:l}}function an(n,e={}){const t=[];let s=[];for(let i=0;i<n.length;i++){const r=n[i];if(r.type==="divider"){s.length>0&&(t.push(s),s=[]);continue}if(r.type==="heading"){const a=i===1&&ln(n,0);s.length>0&&!a&&(t.push(s),s=[]);const o=cn(n,i,e);s.push(...o),i+=o.length-1}else s.push(r)}return s.length>0&&t.push(s),t}function on(n,e){return e+1<n.length&&n[e].type==="heading"&&n[e+1].type==="heading"&&n[e].level>n[e+1].level}function ln(n,e){return e+1<n.length&&n[e].type==="image"&&(n[e].role==="banner"||n[e+1].type==="heading")}function cn(n,e,t={}){const s=[n[e]];let i=!1;for(let r=e+1;r<n.length;r++){const a=n[r],o=s[s.length-1];if(a.type!=="heading")break;if(a.level-o.level===1){i=!0,s.push(a);continue}if(s.length===1&&a.level<o.level){s.push(a);continue}if(a.level===o.level&&!i&&!t.alwaysItems){s.push(a);continue}break}return s}function _e(n){const e={pretitle:"",title:"",subtitle:""},t={images:[],icons:[],videos:[],insets:[],snippets:[],paragraphs:[],links:[],lists:[],data:{},quotes:[],headings:[]},s={level:null,contentTypes:new Set};if(!n)return{header:e,body:t,metadata:s};let i=null,r=null;for(let a=0;a<n.length;a++){on(n,a)&&!e.pretitle&&(e.pretitle=n[a].text,a++);const o=n[a];if(o.type==="heading"){if(o.children&&Array.isArray(o.children)&&ve(o.children,t),s.level??=o.level,r!==null&&o.level===r&&i){const l=e[i];Array.isArray(l)?l.push(o.text):e[i]=[l,o.text]}else e.title?e.subtitle?(t.headings.push(o.text),i=null):(e.subtitle=o.text,i="subtitle"):(e.title=o.text,i="title");r=o.level}else if(o.type==="list"){const l=o.children;t.lists.push(l.map(c=>_e(c).body))}else{let l={...o.attrs};switch(o.type){case"paragraph":o.children&&Array.isArray(o.children)&&ve(o.children,t),o.text&&t.paragraphs.push(o.text);break;case"image":o.attrs?.role==="icon"?t.icons.push(o.attrs):t.images.push(l);break;case"video":t.videos.push(l);break;case"link":o.children&&Array.isArray(o.children)&&ve(o.children,t),t.links.push(l);break;case"icon":t.icons.push(o.attrs);break;case"button":t.links.push({href:o.attrs?.href||"",label:o.text||"",role:o.attrs?.variant?`button-${o.attrs.variant}`:"button",variant:o.attrs?.variant||"primary",size:o.attrs?.size,icon:o.attrs?.icon,target:o.attrs?.target,class:o.attrs?.class});break;case"blockquote":const c=_e(o.children);t.quotes.push(c.body);break;case"concept_block":{const u=o.children||[];t.data[o.tag]={items:$t(u,{alwaysItems:!0}).items,sequence:u};break}case"dataBlock":t.data[o.tag]=o.data;break;case"codeBlock":t.snippets.push({language:o.attrs?.language||"",code:typeof o.text=="string"?o.text:""});break;case"math":(t.math||=[]).push({id:o.id||null,latex:o.latex||"",mathml:o.mathml||""});break;case"table":(t.tables||=[]).push({rows:o.rows||[],attrs:o.attrs||{}});break;case"inset":t.insets.push({refId:o.refId});break;case"form":{const u=o.data||o.attrs,f=o.schemaId||"form";t.data[f]=u}break;case"card-group":(o.cards||[]).forEach(u=>{const f=u.cardType||"card";t.data[f]||(t.data[f]=[]);const{cardType:h,...p}=u;t.data[f].push(p)});break;case"document-group":o.documents.forEach(u=>{t.links.push({href:u.href||u.downloadUrl||"",label:u.title||"",role:"document",download:!0,preview:u.coverImg,fileType:u.fileType})});break}}}return{header:e,body:t,metadata:s}}function un(n){if(n.length===0)return!1;if(n.length===1)return!0;const e=n[0].metadata.level,t=n[1].metadata.level;return!!(e&&(!t||e<t)||!e&&t)}function ve(n,e){n.forEach(t=>{t.type==="icon"?e.icons.push(t.attrs):t.type==="image"?t.attrs?.role==="icon"?e.icons.push(t.attrs):e.images.push(t.attrs):t.type==="video"?e.videos.push(t.attrs):t.type==="link"&&e.links.push(t.attrs)})}function fn(n,e={}){const t={...e},s=M(n,t),i=$t(s,t);return{raw:n,sequence:s,...i}}function hn(n){if(!n||!Array.isArray(n.content))return{content:n,refs:[]};const e=[],t=i=>{let r=!1;const a=i.map(o=>{if(!o)return o;if(o.type==="inset_block"){const{component:l,...c}=o.attrs||{},u=`container_${e.length}`;return e.push({refId:u,type:l,params:c,content:{type:"doc",content:o.content||[]}}),r=!0,{type:"inset_placeholder",attrs:{refId:u,embedKind:"block"}}}if(Array.isArray(o.content)){const l=t(o.content);if(l!==o.content)return r=!0,{...o,content:l}}return o});return r?a:i},s=t(n.content);return s===n.content?{content:n,refs:e}:{content:{...n,content:s},refs:e}}class C{constructor(e,t,s){this.id=t,this.stableId=e.stableId||null,this.page=s,this.website=s.website,this.type=e.type||this.website.getDefaultBlockType(),this.Component=null;const i=hn(e.content);this.rawContent=i.content||{},this.parsedContent=this.parseContent(i.content),e.parsedContent?.data&&(this.parsedContent.data={...this.parsedContent.data||{},...e.parsedContent.data}),this.items=this.parsedContent.items||[];const r=e.params||e.config||{};this.preset=e.preset;const a=r.theme;if(a&&typeof a=="object"){const{mode:c,...u}=a;if(this.themeName=c||"",Object.keys(u).length>0){for(const f of Object.keys(u))u[f]=Ve(u[f]);this.contextOverrides=u}else this.contextOverrides=null}else this.themeName=a??"",this.contextOverrides=null;this.standardOptions=r.standardOptions||{},this.properties=r.properties||r,this.properties.theme&&typeof this.properties.theme=="object"&&(this.properties={...this.properties,theme:this.themeName});const o=r.background;o&&!this.standardOptions.background&&(this.standardOptions={...this.standardOptions,background:C.normalizeBackground(o)}),this.childBlocks=e.subsections?e.subsections.map((c,u)=>new C(c,`${t}_${u}`,this.page)):[],this.insets=[];const l=e.insets;if(l?.length>0)for(let c=0;c<l.length;c++){const u=l[c],f=u.title||"",h=new C({type:u.type,params:u.params||{},content:{title:f},stableId:u.refId,refId:u.refId},`${t}_inset_${c}`,this.page);this.insets.push(h)}for(let c=0;c<i.refs.length;c++){const u=i.refs[c];this.insets.push(new C({type:u.type,params:u.params||{},content:u.content,stableId:u.refId,refId:u.refId},`${t}_container_${c}`,this.page))}this.fetch=e.fetch||null,this.dataLoading=!1,this.hasBackground=!1,this.refId=e.refId||null,this.dynamicContext=e.dynamicContext||null,this.startState=null,this.state=null,this.resetStateHook=null,this.context=null,this.componentVars=null,Object.seal(this)}get path(){return this.page.getNavRoute()}get key(){return`${this.path}-${this.id}`}get parentPath(){return this.dynamicContext?.templateRoute?this.dynamicContext.templateRoute.split("/").slice(0,-1).join("/")||"/":this.path.split("/").slice(0,-1).join("/")||"/"}parseContent(e){return e?.groups?e.groups:e?.type==="doc"?this.extractFromProseMirror(e):e?.doc?.type==="doc"?this.extractFromProseMirror(e.doc):e&&typeof e=="object"&&!Array.isArray(e)?e:{title:"",paragraphs:[],items:[],sequence:[]}}extractFromProseMirror(e){try{return fn(e)}catch(t){return console.warn("[Block] Semantic parser error, using fallback:",t.message),this.extractFromProseMirrorFallback(e)}}extractFromProseMirrorFallback(e){const t={title:"",pretitle:"",subtitle:"",paragraphs:[],links:[],images:[],lists:[],icons:[],items:[],sequence:[]};if(!e.content)return t;for(const s of e.content)if(s.type==="heading"){const i=this.extractText(s);s.attrs?.level===1?t.title=i:s.attrs?.level===2&&(t.subtitle=i)}else if(s.type==="paragraph"){const i=this.extractText(s);t.paragraphs.push(i)}return t}extractText(e){return e.content?e.content.filter(t=>t.type==="text").map(t=>t.text).join(""):""}initComponent(){if(this.Component)return this.Component;if(this.Component=globalThis.uniweb?.getComponent(this.type),!this.Component)return console.warn(`[Block] Component not found: ${this.type}`),null;const e=globalThis.uniweb?.getComponentMeta(this.type)||{},t=e.initialState;return this.startState=t?{...t}:null,this.initState(),this.context=e.context?{...e.context}:null,e.vars&&(this.componentVars=C.mergeComponentVars(e.vars,this.properties.vars)),this.Component}getBlockProperties(){return this.properties}getInset(e){return this.insets.find(t=>t.refId===e)||null}getChildBlockRenderer(){return globalThis.uniweb.childBlockRenderer}getBlockLinks(e={}){const t=globalThis.uniweb?.activeWebsite,s=this.parsedContent||{};if(e.nested){const a=(s.lists||[])[0];return C.parseNestedLinks(a,t)}return(s.links||[]).map(r=>({route:t?.makeHref(r.href)||r.href,label:r.label}))}initState(){this.state=this.startState,this.resetStateHook&&this.resetStateHook()}getIndex(){return this.page?this.page.getBlockIndex(this):-1}getBlockInfo(){return{type:this.type,theme:this.themeName,contextOverrides:this.contextOverrides,state:this.state,context:this.context}}getNextBlockInfo(){const e=this.website?.activePage;if(e&&e!==this.page)return e.getFirstBodyBlockInfo();const t=this.getIndex();return t<0||!this.page?null:this.page.getBlockInfo(t+1)}getPrevBlockInfo(){const e=this.website?.activePage;if(e&&e!==this.page)return e.getLastBodyBlockInfo();const t=this.getIndex();return t<=0||!this.page?null:this.page.getBlockInfo(t-1)}useBlockState(e,t){t!==void 0&&this.startState===null?(this.startState=t,this.state=t):t=this.startState;const[s,i]=e(t);return this.resetStateHook=()=>i(t),[s,r=>i(this.state=r)]}getDynamicContext(){return this.dynamicContext}static mergeComponentVars(e,t={}){const s={};for(const[i,r]of Object.entries(e)){const a=typeof r=="string"?r:r?.default;a!=null&&(s[i]=a)}if(t&&typeof t=="object")for(const[i,r]of Object.entries(t))r!=null&&i in e&&(s[i]=String(r));return Object.keys(s).length>0?s:null}static normalizeBackground(e){if(typeof e=="string"){if(/^(\/|\.\/|\.\.\/|https?:\/\/)/.test(e)||/\.(jpe?g|png|webp|gif|svg|avif|mp4|webm|ogv|ogg)$/i.test(e)){const t=e.split(".").pop()?.toLowerCase();return["mp4","webm","ogv","ogg"].includes(t)?{mode:"video",video:{src:e}}:{mode:"image",image:{src:e}}}return/^(linear|radial|conic)-gradient\(/.test(e)?{mode:"gradient",gradient:e}:{mode:"color",color:Ve(e)}}if(e.mode)return e;if(typeof e.overlay=="number"&&(e={...e,overlay:{enabled:!0,type:"dark",opacity:e.overlay}}),e.video||e.sources)return{mode:"video",...e};if(e.image||e.src){if(e.src){const{src:t,position:s,size:i,lazy:r,...a}=e;return{mode:"image",image:{src:t,position:s,size:i,lazy:r},...a}}if(typeof e.image=="string"){const{image:t,...s}=e;return{mode:"image",image:{src:t},...s}}return{mode:"image",...e}}return e.gradient?{mode:"gradient",...e}:e.color?{mode:"color",...e}:e}static parseNestedLinks(e,t){const s=[];if(!e?.length)return s;for(const i of e){const{links:r=[],lists:a=[],paragraphs:o=[]}=i,l=r[0],c=a[0],u=o[0];let f="",h="",p=[],m=!0;l?(f=l.label,h=l.href,c&&(p=C.parseNestedLinks(c,t))):(f=u,m=!1,c&&(p=C.parseNestedLinks(c,t))),s.push({label:f,route:t?.makeHref(h)||h,child_items:p,hasData:m})}return s}}class Ot{constructor(){this._values=new Map,this._keyListeners=new Map,Object.seal(this)}get(e){return this._values.get(e)}has(e){return this._values.has(e)}set(e,t){this._values.has(e)&&this._values.get(e)===t||(this._values.set(e,t),this._notify(e))}delete(e){return this._values.has(e)?(this._values.delete(e),this._notify(e),!0):!1}subscribe(e,t){let s=this._keyListeners.get(e);return s||(s=new Set,this._keyListeners.set(e,s)),s.add(t),()=>{s.delete(t),s.size===0&&this._keyListeners.delete(e)}}_notify(e){const t=this._keyListeners.get(e);if(t)for(const s of t)s()}}function Bt(n){const e=n||{};return{noindex:e.noindex||!1,image:e.image||null,ogTitle:e.ogTitle||null,ogDescription:e.ogDescription||null,canonical:e.canonical||null,changefreq:e.changefreq||null,priority:e.priority||null}}function dn(n){const e=[],t=new Set,s=r=>{typeof r=="string"&&r&&!t.has(r)&&(t.add(r),e.push(r))},i=n.hideIn;return Array.isArray(i)?i.forEach(s):s(i),n.hideInHeader&&s("header"),n.hideInFooter&&s("footer"),e}class ie{constructor(e,t,s){this.id=t,this.stableId=e.id||null,this.route=e.route,this.sourcePath=e.sourcePath||null,this.isIndex=e.isIndex||!1,this.parentRoute=e.parent||null,this.title=e.title||"",this.description=e.description||"",this.label=e.label||null,this.keywords=e.keywords||null,this.lastModified=e.lastModified||null,this.redirect=e.redirect||null,this.rewrite=e.rewrite||null,this.hidden=e.hidden||!1,this.hideIn=dn(e),this.hideInHeader=this.hideIn.includes("header"),this.hideInFooter=this.hideIn.includes("footer"),this.layout={name:e.layout?.name||null,hide:e.layout?.hide||[],params:e.layout?.params||{}},this.seo=Bt(e.seo),this.parent=null,this.children=[],this.website=s,this.scrollY=0,this.fetch=e.fetch||null,this.dynamicContext=e.dynamicContext||null,this.version=e.version||null,this.versionMeta=e.versionMeta||null,this.versionScope=e.versionScope||null,this._hasContent=e.hasContent??e.sections?.length>0,this._bodySections=e.sections,this._bodyBlocks=null,this._loadingContent=null,this._state=null,Object.seal(this)}get state(){return this._state||(this._state=new Ot),this._state}get bodyBlocks(){if(!this._bodyBlocks){if(this._bodySections===void 0)return[];this._bodyBlocks=(this._bodySections||[]).map((e,t)=>new C(e,t,this))}return this._bodyBlocks}getHeadMeta(){const e=this.getTitle(),t=this.website?.seo||{},s=this.website?.keywords||null;return{title:e,description:this.description,keywords:this.keywords||s,canonical:this.seo.canonical,robots:this.seo.noindex||t.noindex?"noindex, nofollow":null,og:{title:this.seo.ogTitle||e||t.ogTitle,description:this.seo.ogDescription||this.description||t.ogDescription,image:this.seo.image||t.image,url:this.route}}}isDynamicPage(){return this.dynamicContext!==null}getDynamicContext(){return this.dynamicContext}getDynamicParam(){return this.dynamicContext?.paramValue||null}getLayoutName(){return this.layout.name||this.website?.getDefaultLayoutName()||null}getBlockGroups(){return{body:this.bodyBlocks,...this.getLayoutAreas()}}getBlockIndex(e){return this.getPageBlocks().indexOf(e)}getBlockInfo(e){return this.getPageBlocks()[e]?.getBlockInfo()||null}getFirstBodyBlockInfo(){return this.bodyBlocks?.[0]?.getBlockInfo()||null}getLastBodyBlockInfo(){const e=this.bodyBlocks;return e?.[e.length-1]?.getBlockInfo()||null}getPageBlocks(){const e=[],t=this.getLayoutAreas(),s=t.header,i=t.footer;return s&&e.push(...s),e.push(...this.bodyBlocks),i&&e.push(...i),e}getBodyBlocks(){return this.bodyBlocks}getAreaBlocks(e){return this.layout.hide.includes(e)?null:this.website.getAreaBlocks(e,this.getLayoutName())}getLayoutAreas(){const e=this.website.getLayoutAreas(this.getLayoutName()),t={};for(const[s,i]of Object.entries(e))this.layout.hide.includes(s)||(t[s]=i);return t}getLayoutParams(){return this.layout.params}resetBlockStates(){const e=this.getLayoutAreas(),t=[...this.bodyBlocks,...Object.values(e).flat()];for(const s of t)typeof s.initState=="function"&&s.initState()}getNavRoute(){return this.isIndex&&this.route.endsWith("/index")?this.route.slice(0,-6)||"/":this.route}getTitle(){if(this.isIndex&&this.route.endsWith("/index")){const e=this.title?.trim();if(!e||e.toLowerCase()==="index")return this.parent?.title||e||""}return this.title}getLabel(){return this.label||this.getTitle()}isHidden(){return this.hidden}showInNav(e){return!this.hidden&&!this.hideIn.includes("*")&&!this.hideIn.includes(e)}showInHeader(){return this.showInNav("header")}showInFooter(){return this.showInNav("footer")}hasChildren(){return this.children.length>0}hasContent(){return this._hasContent}isContentLoaded(){return this._bodySections!==void 0}async loadContent(){if(this._bodySections===void 0)return this._loadingContent?this._loadingContent:(this._loadingContent=(async()=>{try{const e=this.website.basePath||"",t=this.website.activeLocale,s=this.website.defaultLocale,r=this.website.config?.pageHashes?.[t]?.[this.route];let a;if(r)a=`${e}${r}`;else{const c=t!==s?`/${t}`:"",u=this.route==="/"?"/index":this.route;a=`${e}${c}/_pages${u}.json`}const o=await fetch(a);if(o.status===404&&pn(r)){window.location.reload();return}if(!o.ok){console.warn(`[Page] Failed to load content for ${this.route}: ${o.status}`),this._bodySections=[];return}const l=await o.json();this._bodySections=l.sections||[],this._bodyBlocks=null,typeof sessionStorage<"u"&&sessionStorage.removeItem("uniwebReloadCount")}finally{this._loadingContent=null}})(),this._loadingContent)}getNavigableRoute(){if(this.hasContent())return this.route;const e=this.children||[];if(e.find(s=>s.isIndex))return this.route;for(const s of e){const i=s.getNavigableRoute();if(i)return i}return this.route}getRenderableSelf(){return this.hasContent()?this:this.children?.find(t=>t.isIndex)||this}getNormalizedRoute(){return this.website.normalizeRoute(this.route)}isActiveFor(e){return this.website.isRouteActive(this.route,e)}isActiveOrAncestor(e){if(this.website.isRouteActive(this.route,e))return!0;const t=this.sourcePath||this.route;return this.website.isRouteActiveOrAncestor(t,e)}isVersioned(){return this.version!==null}getVersion(){return this.version}getVersions(){return this.versionMeta?.versions||[]}isLatestVersion(){return this.version?.latest===!0}isDeprecatedVersion(){return this.version?.deprecated===!0}getVersionUrl(e){return this.isVersioned()?this.website.getVersionUrl(e,this.route):null}}function pn(n){if(!n||typeof sessionStorage>"u"||typeof window>"u"||!window.location)return!1;try{const e=parseInt(sessionStorage.getItem("uniwebReloadCount")||"0",10)||0;return e>=2?!1:(sessionStorage.setItem("uniwebReloadCount",String(e+1)),!0)}catch{return!1}}const Et="data",De=`/${Et}/`;function Mn(n){return`${De}${n}.json`}function gn(n,e){return`${De}${n}/${e}.json`}function Rn(n){return typeof n!="string"?"":n.replace(new RegExp(`^/?${Et}/`),"").replace(/\.json$/i,"")}function mn(n){return typeof n=="string"&&n.startsWith(De)}function yn(n){return n?.refine===!0||n?.inherit===!0}function bn(n,e,t){return!n.path||!e||e===t||!mn(n.path)?n:{...n,path:`/${e}${n.path}`}}function kn(n,e){if(n.detail!==void 0)return n;const t=n.schema;if(!t||!e)return n;const s=e[t];if(!s||typeof s!="object")return n;const i=Array.isArray(s.deferred)?s.deferred:null;if(!i||i.length===0)return n;const r=typeof s.detailUrl=="string"?s.detailUrl:gn(t,"{slug}");return{...n,detail:r}}function vn(n,e={}){const{schemas:t=[],locale:s=null,defaultLocale:i=null,collections:r=null}=e,a=new Map,o=t.length===0;for(const l of n){if(!l)continue;const c=Array.isArray(l)?l:[l];for(const u of c){if(!u?.schema||a.has(u.schema)||!o&&!t.includes(u.schema))continue;const f=bn(u,s,i);a.set(u.schema,kn(f,r))}}return a}const re=yn;let tt=!1;function wn(n){tt||(tt=!0,console.warn(`[uniweb] 'fetch: { inherit: true }' is deprecated; rename to 'fetch: { refine: true }'. Accepted for one release; will be removed in the next minor. First seen on block ${n?.id??"(unknown)"} of page ${n?.page?.route??"(unknown)"}.`))}class In{constructor({website:e}){this.website=e,Object.seal(this)}_shouldInheritDetail(e,t){const s=t?.fetch;return re(s)&&s?.detail!==void 0?s.detail!==!1:e?e.inheritDetail!==!1:!0}_inheritLimit(e,t){const s=t?.fetch;return re(s)&&s?.limit>0?s.limit:e?.inheritLimit>0?e.inheritLimit:null}_inheritOrder(e){const t=e?.fetch;return re(t)&&t?.order?.orderBy?t.order:null}_sortItems(e,t){if(!t?.orderBy||!Array.isArray(e)||e.length===0)return e;const{orderBy:s,sortOrder:i="ASC"}=t,r=i==="DESC";return[...e].sort((a,o)=>{const l=a[s]??"",c=o[s]??"",u=typeof l=="string"&&typeof c=="string"?l.localeCompare(c):l>c?1:l<c?-1:0;return r?-u:u})}_getRequestedSchemas(e){return e?e.inheritData===!1?null:[]:[]}_findFetchConfigs(e,t){e.fetch?.inherit===!0&&e.fetch?.refine!==!0&&wn(e);const s=e.page,i=e.website;return vn([e.fetch&&!re(e.fetch)?e.fetch:null,s?.fetch,s?.parent?.fetch,i?.config?.fetch],{schemas:t,locale:i?.getActiveLocale?.()??null,defaultLocale:i?.getDefaultLocale?.()??null,collections:i?.config?.collections??null})}_applyDetailRoutes(e,t,s){if(!(!e||!s?.resolveDetailPageTemplate))for(const[i,r]of t){if(!r.detailPage)continue;const a=e[i];if(!Array.isArray(a)||a.length===0)continue;const o=s.resolveDetailPageTemplate(r.detailPage);o&&(e[i]=a.map(l=>Sn(l,o)))}}_buildDetailConfig(e,t){const{detail:s}=e;if(!s)return null;const{paramName:i,paramValue:r}=t;if(!i||r===void 0)return null;const a=e.url||e.path;if(!a)return null;const o=!!e.path&&!e.url;if(s&&typeof s=="object"){const c={...o?{path:a}:{url:a},schema:e.schema,transform:e.transform};return e.method&&(c.method=e.method),s.body!==void 0?c.body=ge(s.body,{[i]:r},{encode:!1}):e.body!==void 0&&(c.body=ge(e.body,{[i]:r},{encode:!1})),s.envelope&&(c.envelope=s.envelope),c}let l;if(s==="rest"){const[c,u]=a.split("?"),f=c.replace(/\/$/,"");l=u?`${f}/${encodeURIComponent(r)}?${u}`:`${f}/${encodeURIComponent(r)}`}else if(s==="query"){const c=a.includes("?")?"&":"?";l=`${a}${c}${i}=${encodeURIComponent(r)}`}else l=ge(s,{[i]:r});return{...o?{path:l}:{url:l},schema:e.schema,transform:e.transform}}_ctx(e,t={}){return{website:this.website,page:e?.page||null,block:e||null,signal:t.signal}}resolve(e,t){const s=this.website?.fetcher;let i=this._getRequestedSchemas(t);if(i===null&&e.fetch){const d=(Array.isArray(e.fetch)?e.fetch:[e.fetch]).filter(g=>g.schema).map(g=>g.schema);d.length>0&&(i=d)}if(i===null)return{status:"none",data:null};const r=this._findFetchConfigs(e,i);if(r.size===0)return{status:"none",data:null};const a=e.dynamicContext||e.page?.dynamicContext,o=this._shouldInheritDetail(t,e),l=this._inheritLimit(t,e),c=this._inheritOrder(e),u=this._ctx(e),f={};let h=!0;const p=a?.schema;for(const[m,d]of r){const g=a&&m===p;if(g&&!o){const k=s?.peek(d,u);if(k){const{paramName:v,paramValue:S}=a,I=k.data;let w=Array.isArray(I)?I.filter(b=>String(b[v])!==String(S)):I;c&&(w=this._sortItems(w,c)),f[m]=l&&Array.isArray(w)?w.slice(0,l):w}else h=!1}else if(g){const k=s?.peek(d,u);if(k){const{paramName:v,paramValue:S}=a,I=k.data,w=Array.isArray(I)?I.find(b=>String(b[v])===String(S)):null;if(!w)f[m]=[];else if(d.detail){const b=this._buildDetailConfig(d,a),_=b?s?.peek(b,u):null;b&&_?f[m]=[_.data]:b?h=!1:f[m]=[w]}else f[m]=[w]}else h=!1}else{const k=s?.peek(d,u);if(k){const v=k.data;f[m]=c?this._sortItems(v,c):v}else h=!1}}return h?(this._applyDetailRoutes(f,r,e.website),{status:"ready",data:f}):{status:"pending",data:null}}async fetch(e,t,{signal:s}={}){const i=this.website?.fetcher;if(!i)return{data:null};let r=this._getRequestedSchemas(t);if(r===null&&e.fetch){const g=(Array.isArray(e.fetch)?e.fetch:[e.fetch]).filter(k=>k.schema).map(k=>k.schema);g.length>0&&(r=g)}if(r===null)return{data:null};const a=this._findFetchConfigs(e,r);if(a.size===0)return{data:null};const o=e.dynamicContext||e.page?.dynamicContext,l=this._shouldInheritDetail(t,e),c=this._inheritLimit(t,e),u=this._inheritOrder(e),f=this._ctx(e,{signal:s}),h={},p=[],m=o?.schema;for(const[d,g]of a){const k=o&&d===m;if(k&&!l){let v=st(i,g,f);if(v===null){const b=await i.dispatch(g,f);v=Array.isArray(b?.data)?b.data:null}const{paramName:S,paramValue:I}=o;let w=Array.isArray(v)?v.filter(b=>String(b[S])!==String(I)):v??[];u&&(w=this._sortItems(w,u)),h[d]=c&&Array.isArray(w)?w.slice(0,c):w}else if(k){const{paramName:v,paramValue:S}=o;let I=st(i,g,f);if(I===null){const b=await i.dispatch(g,f);I=Array.isArray(b?.data)?b.data:null}const w=I?.find(b=>String(b[v])===String(S))??null;if(!w){h[d]=[];continue}if(g.detail){const b=this._buildDetailConfig(g,o);b?p.push(i.dispatch(b,f).then(_=>{const y=_?.data!==void 0&&_?.data!==null?_.data:w;h[d]=[y]})):h[d]=[w]}else h[d]=[w]}else p.push(i.dispatch(g,f).then(v=>{v?.data!==void 0&&v?.data!==null&&(h[d]=v.data)}))}return p.length>0&&await Promise.all(p),this._applyDetailRoutes(h,a,e.website),{data:h}}}function st(n,e,t){const s=n.peek(e,t);return s&&Array.isArray(s.data)?s.data:null}function Sn(n,e){if(!n||typeof n!="object"||n.route!==void 0)return n;let t=!1;const s=e.replace(/:(\w+)/g,(i,r)=>{const a=n[r];return a==null?(t=!0,""):encodeURIComponent(String(a))});return t?n:{...n,route:s}}function nt(n){return n?n.default&&typeof n.default=="object"?n.default:typeof n=="object"?n:null:null}function Pt(n){return!!n&&typeof n.resolve=="function"}function it(n,{source:e,dev:t}){const s=new Map;if(!n)return s;let i;try{i=n.capabilities?.transports}catch(r){return t&&console.warn(`[FetcherDispatcher] ${e} transports getter threw:`,r),s}if(!i||typeof i!="object"||Array.isArray(i))return s;for(const r of Object.keys(i)){let a;try{a=i[r]}catch(o){t&&console.warn(`[FetcherDispatcher] ${e} transport "${r}" getter threw:`,o);continue}if(!Pt(a)){t&&console.warn(`[FetcherDispatcher] ${e} transport "${r}" missing resolve(); skipped.`);continue}s.set(r,a)}return s}class rt{constructor({foundation:e,extensions:t=[],dataStore:s,defaultFetcher:i=null,transport:r=null,dev:a=!1}){if(!s)throw new Error("FetcherDispatcher: dataStore is required");this._dataStore=s,this._defaultFetcher=i,this._transportOverride=Pt(r)?r:null,this._dev=!!a;const o=new Map,l=it(nt(e),{source:"primary foundation",dev:this._dev});for(const[c,u]of l)o.set(c,u);for(const c of t){let u;try{u=it(nt(c),{source:"extension",dev:this._dev})}catch(f){this._dev&&console.warn("[FetcherDispatcher] extension transports collection threw:",f);continue}for(const[f,h]of u){if(o.has(f)){this._dev&&console.warn(`[FetcherDispatcher] extension transport "${f}" ignored — primary foundation already provides it.`);continue}o.set(f,h)}}this._namedTransports=o,Object.freeze(this)}_selectFetcher(e,t){if(this._transportOverride)return this._transportOverride;const s=t?.website?.config?.fetcher?.transports;if(s&&typeof s=="object"){const i=e?.schema,r=i&&s[i]||s.default;if(r){const a=this._namedTransports.get(r);if(a)return a;this._dev&&console.warn(`[FetcherDispatcher] site selected transport "${r}" for schema "${i??"(none)"}" but no foundation or extension registered it; falling back to the framework default.`)}}return this._defaultFetcher}_cacheKey(e,t){if(e&&typeof e.cacheKey=="function")try{return String(e.cacheKey(t))}catch(s){console.warn("[FetcherDispatcher] fetcher.cacheKey threw:",s)}return Zt(t)}peek(e,t={}){const s=this._selectFetcher(e,t),i=this._cacheKey(s,e);return this._dataStore.get(i)}async dispatch(e,t={}){const s=this._selectFetcher(e,t);if(!s)return{data:[],error:"FetcherDispatcher: no fetcher selected and no default configured"};const i=this._cacheKey(s,e),r=this._dataStore.get(i);if(r)return{data:r.data,meta:r.meta};const a=this._dataStore.inflight.get(i);if(a)return this._attachSignal(a,t.signal),a.promise;const o=typeof AbortController<"u"?new AbortController:null,l={promise:null,master:o,signals:new Set,everAttached:!1};this._attachSignal(l,t.signal),this._dataStore.inflight.set(i,l);const c=o?{...t,signal:o.signal}:t;return l.promise=this._runFetcher(s,e,c,i,l),l.promise}_attachSignal(e,t){if(!t||!e.master)return;if(e.everAttached=!0,t.aborted){this._maybeAbortMaster(e);return}e.signals.add(t);const s=()=>{e.signals.delete(t),this._maybeAbortMaster(e)};t.addEventListener("abort",s,{once:!0})}_maybeAbortMaster(e){e.master&&(e.master.signal.aborted||e.everAttached&&(e.signals.size>0||e.master.abort()))}async _runFetcher(e,t,s,i,r){try{const a=await e.resolve(t,s);if(this._dataStore.inflight.get(i)===r&&this._dataStore.inflight.delete(i),!a||typeof a!="object")return this._dev&&console.warn("[FetcherDispatcher] Fetcher returned a non-object; expected { data, error?, meta? }.",{request:t,result:a}),{data:[],error:"Fetcher returned a non-object"};const{data:o,error:l,meta:c}=a;if(this._dev&&this._validateReturnShape(a,t),l)return{data:o??[],error:l,meta:c};if(o==null)return{data:o??[],meta:c};const u=c!==void 0?{data:o,meta:c}:{data:o};return this._dataStore.set(i,u),{data:o,meta:c}}catch(a){return this._dataStore.inflight.get(i)===r&&this._dataStore.inflight.delete(i),{data:[],error:String(a?.message||a)}}}_validateReturnShape(e,t){const s=new Set(["data","error","meta"]),i=Object.keys(e).filter(r=>!s.has(r));i.length>0&&console.warn(`[FetcherDispatcher] Fetcher return has unexpected keys: ${i.join(", ")}. Expected { data, error?, meta? }.`,{request:t,result:e})}}function Mt(n){return typeof n=="string"&&n.trim()&&n.trim()!=="*"?n.trim():n&&typeof n=="object"&&typeof n.code=="string"&&n.code.trim()?n.code.trim():null}function _n(n){return n==="*"||Array.isArray(n)&&n.includes("*")}function Ae(n){if(!Array.isArray(n))return[];const e=new Set,t=[];for(const s of n){const i=Mt(s);!i||e.has(i)||(e.add(i),t.push(i))}return t}function Le(n={}){return typeof n?.defaultLanguage=="string"&&n.defaultLanguage.trim()?n.defaultLanguage.trim():Ae(n?.languages)[0]||"en"}function An(n={}){const e=Ae(n?.languages),t=n?.publishLanguages;if(t==null)return{publishable:e,dangling:[],explicit:!1};const s=Ae(t);if(_n(n?.languages))return{publishable:s,dangling:[],explicit:!0};const i=new Set(e),r=new Set(s);return{publishable:e.filter(a=>r.has(a)),dangling:s.filter(a=>!i.has(a)),explicit:!0}}function Dn(n={}){const e=[],t=[],s=(o,l,c)=>{if(o==null||o==="*")return;if(!Array.isArray(o)){t.push({code:c,message:`${l} must be a list of locale codes (got ${typeof o}) — ignored`});return}const u=new Set;for(const f of o){if(f==="*")continue;const h=Mt(f);if(!h){t.push({code:c,message:`${l} entry ${JSON.stringify(f)} is not a locale code string — dropped`});continue}typeof f!="string"&&t.push({code:c,message:`${l} entry for '${h}' uses the legacy object form — use the plain string '${h}'`}),u.has(h)&&t.push({code:"duplicate-language",message:`${l} lists '${h}' more than once — deduped`}),u.add(h)}};s(n?.languages,"languages","invalid-language-entry"),s(n?.publishLanguages,"publishLanguages","invalid-publish-language-entry");const{publishable:i,dangling:r,explicit:a}=An(n);for(const o of r)t.push({code:"dangling-publish-language",message:`publishLanguages lists '${o}' but languages does not declare it — ignored at publish (kept in the file so a re-declared language keeps its publish intent)`});if(a&&i.length===0)e.push({code:"nothing-publishable",message:"publishLanguages leaves no publishable language (empty list, or nothing it lists is declared) — a publishable default language is required"});else if(a){const o=Le(n);i.includes(o)||e.push({code:"default-not-publishable",message:`the default language '${o}' is not in publishLanguages — the effective default must be publishable`})}return{errors:e,warnings:t}}const Ln="[A-Za-z0-9_-]+",Tn=/[.*+?^${}()|[\]\\]/g;function Rt(n){return typeof n!="string"||n===""||n==="/"?"/":n.replace(/\/+$/,"")||"/"}function Nn(n){const e=[],t=Rt(n).replace(Tn,"\\$&").replace(new RegExp(`:(${Ln})`,"g"),(s,i)=>(e.push(i),"([^/]+)"));return{regex:new RegExp(`^${t}$`),paramNames:e}}function Cn(n,e){const{regex:t,paramNames:s}=Nn(n),i=Rt(e).match(t);if(!i)return null;const r={};return s.forEach((a,o)=>{r[a]=decodeURIComponent(i[o+1])}),{params:r}}class xn{constructor({content:e={},foundation:t=null,extensions:s=[],defaultFetcher:i=null,transport:r=null,dev:a=!1}={}){this._foundation=t,this._extensions=s,this._defaultFetcher=i,this._transport=r,this._dev=a,this.dataStore=new es,this.fetcher=new rt({foundation:t,extensions:s,dataStore:this.dataStore,defaultFetcher:i,transport:r,dev:a}),this.entityStore=new In({website:this}),this._state=null,this.name="",this.description="",this.url="",this._layoutSets={},this.notFoundPage=null,this._dynamicPageData=new Map,this._dynamicPageCache=new Map,this.pages=[],this.activePage=null,this.pageRoutes=[],this.themeData={},this.config={},this.seo={},this.keywords=null,this.siteDefaultLocale="en",this.defaultLocale="en",this.activeLocale="en",this.locales=[],this.activeLang="en",this.langs=[],this._routeTranslations={},this.basePath="",this.versionedScopes={},this.assets={},this._pageIdMap=new Map,this._applyContent(e),Object.seal(this)}_applyContent(e){const{pages:t=[],theme:s={},config:i={},layouts:r,notFound:a,versionedScopes:o={},assets:l={}}=e||{};if(this.name=i.name||"",this.description=i.description||"",this.url=i.url||"",this._layoutSets={},r&&typeof r=="object")for(const[f,h]of Object.entries(r)){this._layoutSets[f]={};for(const[p,m]of Object.entries(h))m&&(this._layoutSets[f][p]=new ie(m,`layout-${f}-${p}`,this))}const c=a||t.find(f=>f.route==="/404")||null;this.notFoundPage=c?new ie(c,"notFound",this):null;const u=t.filter(f=>f.route!=="/404");this._dynamicPageData=new Map;for(const f of u)(f.isDynamic||f.route?.includes(":"))&&this._dynamicPageData.set(f.route,f);this._dynamicPageCache=new Map,this.pages=u.map((f,h)=>new ie(f,h,this)),this.buildPageHierarchy(),this.activePage=this.pages.find(f=>f.isIndex&&f.getNavRoute()==="/")||this.pages[0]||null,this.pageRoutes=this.pages.map(f=>f.route),this.themeData=s,this.config=i,this.seo=Bt(i.seo),this.keywords=i.keywords||null,this.siteDefaultLocale=Le(i),this.defaultLocale=i.domainLocale||this.siteDefaultLocale,this.activeLocale=i.activeLocale||this.defaultLocale,this.locales=this.buildLocalesList(i),this.activeLang=this.activeLocale,this.langs=this.locales.map(f=>({label:f.label||f.code,value:f.code})),this._routeTranslations=this._buildRouteTranslations(i),this.versionedScopes=o,this.assets=l}rebuild({content:e,foundation:t,extensions:s}={}){const i=t!==void 0,r=s!==void 0;return i&&(this._foundation=t),r&&(this._extensions=s),(i||r)&&(this.fetcher=new rt({foundation:this._foundation,extensions:this._extensions,dataStore:this.dataStore,defaultFetcher:this._defaultFetcher,transport:this._transport,dev:this._dev})),e!==void 0&&this._applyContent(e),this}get state(){return this._state||(this._state=new Ot),this._state}buildLocalesList(e){const t=Le(e),s=e.languages||[],i=a=>typeof a=="string"?{code:a}:{code:a.code,...a.label&&{label:a.label}},r=new Map;r.set(t,{code:t});for(const a of s){const o=i(a);if(r.has(o.code)){const l=r.get(o.code);r.set(o.code,{...l,...o})}else r.set(o.code,o)}return Array.from(r.values()).map(a=>({...a,isDefault:a.code===t}))}_buildRouteTranslations(e){const t=e.i18n?.routeTranslations||{},s={};for(const[i,r]of Object.entries(t)){const a=new Map,o=new Map;for(const[l,c]of Object.entries(r))a.set(l,c),o.set(c,l);s[i]={forward:a,reverse:o}}return s}translateRoute(e,t=this.activeLocale){if(!t||t===this.siteDefaultLocale)return e;const s=this._routeTranslations[t];if(!s)return e;const i=s.forward.get(e);if(i)return i;for(const[r,a]of s.forward)if(e.startsWith(r+"/"))return a+e.slice(r.length);return e}reverseTranslateRoute(e,t=this.activeLocale){if(!t||t===this.siteDefaultLocale)return e;const s=this._routeTranslations[t];if(!s)return e;const i=s.reverse.get(e);if(i)return i;for(const[r,a]of s.reverse)if(e.startsWith(r+"/"))return a+e.slice(r.length);return e}buildPageHierarchy(){const e=new Map;for(const t of this.pages)e.set(t.route,t);for(const t of this.pages)if(t.parentRoute){const s=e.get(t.parentRoute);s&&(s.children.push(t),t.parent=s)}for(const t of this.pages){if(t.parent||t.route==="/")continue;const s=t.route.replace(/\/[^/]+$/,"");if(!s||s==="/"||s===t.route)continue;const i=e.get(s);i&&(i.children.push(t),t.parent=i)}this._pageIdMap=new Map;for(const t of this.pages){t.stableId&&this._pageIdMap.set(t.stableId,t);const s=this.normalizeRoute(t.route);if(s&&!this._pageIdMap.has(s)&&this._pageIdMap.set(s,t),t.sourcePath){const i=t.sourcePath.replace(/^\//,"").replace(/\/$/,"");i&&!this._pageIdMap.has(i)&&this._pageIdMap.set(i,t)}}}getPage(e){let t=e;if(this.activeLocale&&this.activeLocale!==this.defaultLocale){const l=`/${this.activeLocale}`;t===l||t===`${l}/`?t="/":t.startsWith(`${l}/`)&&(t=t.slice(l.length))}const s=t==="/"?"/":t.replace(/\/$/,""),i=this.pages.find(l=>l.route===s);if(i){const l=i.children.find(c=>c.isIndex);return l||i}t=this.reverseTranslateRoute(t);const r=t==="/"?"/":t.replace(/\/$/,""),a=this.pages.find(l=>l.route===r);if(a){const l=a.children.find(c=>c.isIndex);return l||a}const o=this.pages.find(l=>l.isIndex&&l.getNavRoute()===r);if(o)return o;if(this._dynamicPageCache.has(r))return this._dynamicPageCache.get(r);for(const l of this.pages){if(!l.route.includes(":"))continue;const c=this._matchDynamicRoute(l.route,r);if(c){const u=this._createDynamicPage(l,r,c.params);if(u){const{page:f,collectionLoaded:h}=u;return h&&this._dynamicPageCache.set(r,f),f}}}}_matchDynamicRoute(e,t){return Cn(e,t)}_createDynamicPage(e,t,s){const i=this._dynamicPageData.get(e.route);if(!i)return null;const r=JSON.parse(JSON.stringify(i));r.route=t,r.isDynamic=!1;const a=Object.keys(s)[0],o=Object.values(s)[0],l=i.parentSchema;if(r.dynamicContext={templateRoute:e.route,params:s,paramName:a,paramValue:o,schema:l},r.sections&&Array.isArray(r.sections))for(const h of r.sections)h.dynamicContext=r.dynamicContext;const c=e.route.replace(/\/:[\w]+$/,"")||"/",u=this.pages.find(h=>h.route===c||h.getNavRoute()===c);if(u&&l){const h=u.fetch;let p=[];if(h&&this.fetcher){const d=Array.isArray(h)?h.find(g=>g.schema===l):h.schema===l?h:null;if(d){const g=this.fetcher.peek(d,{website:this});p=Array.isArray(g?.data)?g.data:[]}}const m=p.find(d=>String(d[a])===String(o));m?(m.title&&(r.title=m.title),(m.description||m.excerpt)&&(r.description=m.description||m.excerpt)):p.length>0&&(r.title="Not found",r.notFound=!0),r._collectionLoaded=p.length>0}const f=new ie(r,`dynamic-${t}`,this);return f.parent=e.parent,{page:f,collectionLoaded:r._collectionLoaded??!0}}setActivePage(e){const t=this.getPage(e);t&&(this.activePage=t)}setBasePath(e){!e||e==="/"?this.basePath="":this.basePath=e.endsWith("/")?e.slice(0,-1):e}getRemoteLayout(e){const t=globalThis.uniweb?.foundationConfig;return t?.layouts&&e&&t.layouts[e]?t.layouts[e]:null}getDefaultLayoutName(){return globalThis.uniweb?.foundationConfig?.defaultLayout||null}getDefaultBlockType(){return globalThis.uniweb?.foundationConfig?.defaultSection||"Section"}getAreaBlocks(e,t){return t&&this._layoutSets[t]?this._layoutSets[t][e]?.bodyBlocks||null:this._layoutSets.default&&this._layoutSets.default[e]?.bodyBlocks||null}getLayoutAreas(e){const t=e||"default",s=this._layoutSets[t]||this._layoutSets.default;if(!s)return{};const i={};for(const[r,a]of Object.entries(s))a?.bodyBlocks&&(i[r]=a.bodyBlocks);return i}getLayoutMeta(e){return globalThis.uniweb?.foundationConfig?.layoutMeta?.[e]||null}get viewTransitions(){return globalThis.uniweb.foundationConfig?.viewTransitions!==!1}getRemoteProps(){return globalThis.uniweb?.foundationConfig?.props||null}getRoutingComponents(){return globalThis.uniweb?.routingComponents||{}}makeHref(e){if(!e)return e;let t;if(e.startsWith("page:"))t=e.slice(5);else if(e.startsWith("topic:"))t=e.slice(6);else return e;const[s,i]=t.split("#"),r=this._pageIdMap?.get(s);if(!r)return e;let a=r.route;return i&&(a+=`#section-${i}`),a}resolveDetailPageTemplate(e){if(!e||typeof e!="string")return null;const t=e.startsWith("page:")?e.slice(5):e,s=this._pageIdMap?.get(t);return!s||!s.route?null:this.translateRoute(s.route)}getLanguages(){return this.langs}getLanguage(){return this.activeLang}getLocales(){return this.locales}getActiveLocale(){return this.activeLocale}getDefaultLocale(){return this.defaultLocale}hasMultipleLocales(){return this.locales.length>1}setActiveLocale(e){this.locales.find(s=>s.code===e)&&(this.activeLocale=e,this.activeLang=e)}getLocaleUrl(e,t=null){let s=t||this.activePage.getNavRoute();if(this.activeLocale&&this.activeLocale!==this.defaultLocale){const a=`/${this.activeLocale}`;s===a||s===`${a}/`?s="/":s.startsWith(`${a}/`)&&(s=s.slice(a.length))}s=this.reverseTranslateRoute(s);const i=this.config?.domainLocales;if(i){const a=Object.entries(i).find(([,o])=>o===e);if(a){const o=a[0],l=this.translateRoute(s,e);return`https://${o}${l==="/"?"/":l}`}}if(e===this.defaultLocale)return s;const r=this.translateRoute(s,e);return r==="/"?`/${e}/`:`/${e}${r}`}getLocale(e){return this.locales.find(t=>t.code===e)}localize(e,t="",s="",i=!1){const r=s||this.activeLang,a=this.langs[0]?.value||"en";if(typeof e=="object"&&!Array.isArray(e))return i?e?.[r]||e?.[a]||t:e?.[r]||t;if(typeof e=="string"){if(!e.startsWith("{")&&!e.startsWith('"'))return e;try{const o=JSON.parse(e);return typeof o=="object"?i?o?.[r]||o?.[a]||t:o?.[r]||t:o}catch{return e}}return t}isSearchEnabled(){return this.config?.search?.enabled!==!1}getSearchConfig(){const e=this.config?.search||{};return{enabled:this.isSearchEnabled(),provider:e.provider||"index",endpoint:e.endpoint,indexUrl:this.getSearchIndexUrl(),locale:this.getActiveLocale(),include:{pages:e.include?.pages!==!1,sections:e.include?.sections!==!1,headings:e.include?.headings!==!1,paragraphs:e.include?.paragraphs!==!1,links:e.include?.links!==!1,lists:e.include?.lists!==!1},exclude:{routes:e.exclude?.routes||[],components:e.exclude?.components||[]}}}getSearchIndexUrl(){const e=this.getActiveLocale(),s=e===this.getDefaultLocale()?"/search-index.json":`/${e}/search-index.json`;return`${this.basePath||""}${s}`}getSearchData(){return this.pages.map(e=>({id:e.id,title:e.title,href:e.route,route:e.route,description:e.description,content:e.getPageBlocks().map(t=>t.title).filter(Boolean).join(`
59
+ `)}))}getPageHierarchy(e={}){const{nested:t=!0,for:s,includeHidden:i=!1,filter:r,sort:a}=e,o=u=>!(u.route.includes(":")||u.isIndex&&u.route.endsWith("/index")||!i&&(u.hidden||u.hideIn?.includes("*")||s&&u.hideIn?.includes(s))||!u.hasContent()&&!u.children?.some(h=>h.isIndex)&&!u.children?.some(o)||r&&!r(u));let l=this.pages.filter(o);t&&(l=l.filter(u=>!u.parent&&!u.parentRoute)),a&&l.sort(a);const c=u=>{const f=u.getNavRoute();return{id:u.id,route:f,navigableRoute:u.getNavigableRoute(),translatedRoute:this.translateRoute(f),title:u.getTitle(),label:u.getLabel(),description:u.description,hasContent:u.hasContent(),version:u.version||null,children:t&&u.hasChildren()?u.children.filter(o).map(c):[]}};return l.map(c)}getBranchHierarchy({route:e="",for:t,includeHidden:s=!1}={}){const i=l=>(l||"").replace(/^\/+/,"").replace(/\/+$/,""),r=this.getPageHierarchy({for:t,includeHidden:s}),a=i(e).split("/")[0];if(!a)return r;const o=r.find(l=>i(l.route)===a);return o?o.children?.length?o.children:[o]:r}getHeaderPages(){return this.getPageHierarchy({for:"header"})}getFooterPages(){return this.getPageHierarchy({for:"footer"})}getAllPages(e=!1){return this.getPageHierarchy({nested:!1,includeHidden:e})}getNotFoundPage(){return this.notFoundPage}getActiveRoute(){return this.activePage.getNormalizedRoute()}getActiveRootSegment(){return this.getActiveRoute().split("/")[0]}normalizeRoute(e){let t=(e||"").replace(/^\/+/,"").replace(/\/+$/,"");if(this.activeLocale&&this.activeLocale!==this.defaultLocale){const r=this.activeLocale;t===r?t="":t.startsWith(`${r}/`)&&(t=t.slice(r.length+1))}const s="/"+t;return t=this.reverseTranslateRoute(s).replace(/^\//,""),t}isRouteActive(e,t){return this.normalizeRoute(e)===this.normalizeRoute(t)}isRouteActiveOrAncestor(e,t){const s=this.normalizeRoute(e),i=this.normalizeRoute(t);return s===i?!0:s===""?!1:i.startsWith(s+"/")}getVersionedScopes(){return this.versionedScopes}hasVersionedContent(){return Object.keys(this.versionedScopes).length>0}getVersionScope(e){const t=e||"";for(const s of Object.keys(this.versionedScopes)){if(t===s)return s;if(s==="/"){if(t.startsWith("/")||t==="")return s}else if(t.startsWith(s+"/"))return s}return null}isVersionedRoute(e){return this.getVersionScope(e)!==null}getVersionMeta(e){return this.versionedScopes[e]||null}getPageVersion(e){return e?.version||null}getVersionsForRoute(e){const t=this.getVersionScope(e);return t?this.versionedScopes[t]?.versions||[]:[]}getVersionUrl(e,t){const s=this.getVersionScope(t);if(!s)return null;const i=this.versionedScopes[s];if(!i)return null;const r=i.versions.find(l=>l.id===e);if(!r)return null;const a=s==="/"?t:t.slice(s.length);let o=a;for(const l of i.versions){const c=`/${l.id}`;if(a.startsWith(c+"/")||a===c){o=a.slice(c.length);break}}return r.latest?s==="/"?o:s+o:s==="/"?"/"+e+o:s+"/"+e+o}getLatestVersion(e){return this.versionedScopes[e]?.latestId||null}}const we=typeof window<"u"&&typeof document<"u";class $n{constructor(e={}){this.endpoint=e.endpoint||null,this.flushInterval=e.flushInterval||5e3,this.maxQueueSize=e.maxQueueSize||10,this.debug=e.debug||!1,this.queue=[],this.scrollMilestones=new Set,this.sessionId=this.generateSessionId(),this.sessionStart=Date.now(),this.flushIntervalId=null,we&&this.isEnabled()&&(this.setupFlushInterval(),this.setupUnloadHandler()),Object.seal(this)}isEnabled(){return!!this.endpoint}generateSessionId(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}setupFlushInterval(){this.flushIntervalId=setInterval(()=>{this.flush()},this.flushInterval)}setupUnloadHandler(){const e=()=>{this.flush(!0)};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&e()}),window.addEventListener("pagehide",e)}addToQueue(e,t){if(!this.isEnabled()||!we)return;const s={type:e,data:t,timestamp:Date.now(),sessionId:this.sessionId,url:window.location.href,referrer:document.referrer||null};this.queue.push(s),this.debug&&console.log("[Analytics] Event queued:",s),this.queue.length>=this.maxQueueSize&&this.flush()}trackPageView(e,t,s={}){this.scrollMilestones.clear(),this.addToQueue("pageview",{path:e,title:t,...s})}trackEvent(e,t={}){this.addToQueue("event",{name:e,...t})}trackScrollDepth(e){[25,50,75,100].includes(e)&&(this.scrollMilestones.has(e)||(this.scrollMilestones.add(e),this.addToQueue("scroll_depth",{depth:e})))}flush(e=!1){if(!this.isEnabled()||!we||this.queue.length===0)return;const t=[...this.queue];this.queue=[];const s=JSON.stringify({events:t,sessionId:this.sessionId,sessionDuration:Date.now()-this.sessionStart});if(this.debug&&console.log("[Analytics] Flushing",t.length,"events"),e&&navigator.sendBeacon){const i=new Blob([s],{type:"application/json"});!navigator.sendBeacon(this.endpoint,i)&&this.debug&&console.warn("[Analytics] sendBeacon failed, events may be lost");return}fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(i=>{this.debug&&console.warn("[Analytics] Flush failed:",i),this.queue.unshift(...t)})}destroy(){this.flushIntervalId&&clearInterval(this.flushIntervalId),this.flush(!0)}}class On{constructor({content:e={},foundation:t=null,extensions:s=[],defaultFetcher:i=null,transport:r=null,dev:a=!1}={}){this.activeWebsite=new xn({content:e,foundation:t,extensions:s,defaultFetcher:i,transport:r,dev:a}),this.foundation=t,this.foundationConfig={},this.meta=t?.default?.meta||{},this.extensions=[],t?.default?.capabilities&&(this.foundationConfig={...t.default.capabilities}),t?.default?.layoutMeta&&(this.foundationConfig.layoutMeta=t.default.layoutMeta),t?.default?.handlers&&(this.foundationConfig.handlers=t.default.handlers),t?.default?.viewTransitions!==void 0&&(this.foundationConfig.viewTransitions=t.default.viewTransitions);for(const o of s)this._wireExtension(o);this.childBlockRenderer=null,this.routingComponents={},this.language="en",this.defaultInsets=null,this.iconResolver=null,this.iconCache=new Map,this.analytics=new $n(e?.analytics||e?.config?.analytics||{}),Object.seal(this)}_wireExtension(e){const t=e?.default?.meta||{};this.extensions.push({foundation:e,meta:t})}async resolveIcon(e,t){return this.iconResolver?this.iconResolver(e,t):(console.warn("[Uniweb] No icon resolver configured"),null)}getIconSync(e,t){return this.iconCache.get(`${e}:${t}`)||null}getComponentMeta(e){const t=this.meta[e];if(t)return t;for(const s of this.extensions){const i=s.meta[e];if(i)return i}return null}getComponentDefaults(e){return this.getComponentMeta(e)?.defaults||{}}getComponent(e){if(!this.foundation){console.warn("[Runtime] No foundation loaded");return}const t=this.foundation[e];if(t)return t;for(const s of this.extensions){const i=s.foundation[e];if(i)return i}if(this.defaultInsets&&this.defaultInsets[e])return this.defaultInsets[e]}listComponents(){const e=new Set;if(this.foundation)for(const t of Object.keys(this.foundation))t!=="default"&&e.add(t);for(const t of this.extensions)for(const s of Object.keys(t.foundation))s!=="default"&&e.add(s);return[...e]}}function jn(n){return!n||typeof n!="object"?!1:!!(Array.isArray(n.fields)||n.isComposite===!0||n.childSchema&&typeof n.childSchema=="object")}function Fn(n){if(!n||typeof n!="object"||Array.isArray(n))return null;if(Array.isArray(n.fields)||n.isComposite===!0||n.childSchema)return n;if(n.sections!==void 0)return null;const e=i=>Object.entries(i).map(([r,a])=>typeof a=="string"?{id:r,type:a}:{id:r,...a});if(n.fields&&typeof n.fields=="object"){const{fields:i,...r}=n;return{...r,fields:e(i)}}const t=Object.entries(n);if(!t.length)return null;const s=([,i])=>i&&typeof i=="object"&&!Array.isArray(i)&&i.type!==void 0;return t.every(s)?{fields:e(n)}:null}function Kn(){return globalThis.uniweb}function Un(n,e=null,t=[],{defaultFetcher:s=null,transport:i=null,dev:r=!1}={}){const a=new On({content:n,foundation:e,extensions:t,defaultFetcher:s,transport:i,dev:r});return globalThis.uniweb=a,a}export{C as B,Et as D,In as E,rt as F,Ot as O,ie as P,On as U,xn as W,De as a,Rn as b,Mn as c,Un as d,jn as e,_n as f,Kn as g,Fn as h,mn as i,Le as j,An as k,Ae as n,gn as r,Dn as v};