@panphora/clayjs 0.6.0 → 0.6.1

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.
@@ -1,5 +1,5 @@
1
- var hypercms=(()=>{var Dt=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var ni=Object.getOwnPropertyNames;var ii=Object.prototype.hasOwnProperty;var $t=(e,t)=>{for(var r in t)Dt(e,r,{get:t[r],enumerable:!0})},oi=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ni(t))!ii.call(e,i)&&i!==r&&Dt(e,i,{get:()=>t[i],enumerable:!(n=ri(t,i))||n.enumerable});return e};var si=e=>oi(Dt({},"__esModule",{value:!0}),e);var $s={};$t($s,{cms:()=>qs,default:()=>Ds});function Z(e){let t=0,r=null,n=-1;for(let i=0;i<e.length;i++){let o=e[i];o==="\\"?i++:r?o===r&&(r=null):o==='"'||o==="'"?r=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(n=i)}return n}function it(e){let t=Z(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}var Nr={includeClasses:!0,includeAttributes:["href","src","name","type","role","aria-label","alt","title"],excludeAttributePrefixes:["data-morph-","data-hyper-","data-im-"],textHintLength:64,excludeIds:!0,maxPathDepth:4,landmarks:["HEADER","NAV","MAIN","ASIDE","FOOTER","SECTION","ARTICLE"],weights:{signature:100,pathSegment:10,textMatch:20,textMismatch:25,uniqueCandidate:50,positionPenalty:1,maxDriftPenalty:19,slotMatch:30},minConfidence:101,maxScoredCandidates:16};function li(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t^e.charCodeAt(r);return Math.abs(t).toString(36)}function ci(e){if(e.classList&&e.classList.length>0)return Array.from(e.classList).sort().join(" ");let t=e.getAttribute?.("class");return t?t.split(/\s+/).filter(Boolean).sort().join(" "):""}function ui(e,t){let r=[];for(let n of e.attributes||[]){let i=n.name;i==="id"||i==="class"||t.excludeAttributePrefixes.some(o=>i.startsWith(o))||t.includeAttributes.includes(i)&&r.push(`${i}=${n.value}`)}return r.sort().join("|")}function di(e,t){return(e.textContent||"").replace(/\s+/g," ").trim().slice(0,t.textHintLength)}function mi(e,t){let r=[e.tagName];return t.includeClasses&&r.push(ci(e)),r.push(ui(e,t)),li(r.join("|"))}function hi(e){let t=e.tagName,r=1,n=e.previousElementSibling;for(;n;)n.tagName===t&&r++,n=n.previousElementSibling;return r}function pi(e,t){return e.getAttribute?.("id")||e.getAttribute?.("role")?!0:t.landmarks.includes(e.tagName)}function fi(e){let t=e.getAttribute?.("id");if(t)return`#${t}`;let r=e.getAttribute?.("role");return r?`@${r}`:e.tagName}function gi(e,t){let r=[],n=e;for(;n&&n.tagName&&r.length<t.maxPathDepth;){let i=`${n.tagName}:${hi(n)}`;if(r.unshift(i),n!==e&&pi(n,t)){r.unshift(fi(n));break}n=n.parentElement}return r}function bi(e,t){let r=0,n=e.length-1,i=t.length-1;for(;n>=0&&i>=0&&e[n]===t[i];)r++,n--,i--;return r}function se(e,t,r){if(r.has(e))return r.get(e);let n={signature:mi(e,t),path:gi(e,t),textHint:di(e,t)};return r.set(e,n),n}function Fr(e,t,r,n){if(n.has(e))return n.get(e);let i=new Map,o=e.querySelectorAll("*"),a=0;for(let s of o){let l=se(s,t,r);l.domIndex=a++,!t.shouldIgnore?.(s)&&(i.has(l.signature)||i.set(l.signature,[]),i.get(l.signature).push(s))}return n.set(e,i),i}function ki(e,t,r){r.delete(e),t.delete(e);let n=e.querySelectorAll("*");for(let i of n)t.delete(i)}function Bt(e,t,r,n,i){let o=se(e,r,n),a=se(t,r,n),s=r.weights,l={},c=0;if(o.signature!==a.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};c+=s.signature,l.signature=s.signature;let b=bi(o.path,a.path)*s.pathSegment;c+=b,l.path=b;let u=!0;if(o.textHint&&a.textHint?o.textHint===a.textHint?(c+=s.textMatch,l.text=s.textMatch):(c-=s.textMismatch,l.text=-s.textMismatch,u=!1):o.textHint!==a.textHint&&(c-=s.textMismatch,l.text=-s.textMismatch,u=!1),i.candidateCount===1&&u&&(c+=s.uniqueCandidate,l.unique=s.uniqueCandidate),typeof o.domIndex=="number"&&typeof a.domIndex=="number"){let k=Math.abs(o.domIndex-a.domIndex),y=Math.min(k*s.positionPenalty,s.maxDriftPenalty);c-=y,l.drift=-y}return{score:c,breakdown:l}}function Ir(e,t,r,n,i){if(r.excludeIds&&e.getAttribute("id"))return null;let o=Fr(t,r,n,i),a=se(e,r,n);if(typeof a.domIndex!="number"){let u=0,k=e.previousElementSibling;for(;k;)u++,k=k.previousElementSibling;a.domIndex=u}let s=o.get(a.signature)||[],l=r.excludeIds?s.filter(u=>!u.getAttribute("id")):s;if(l.length===0)return null;let c=null,d=0,b=null;for(let u of l){let{score:k,breakdown:y}=Bt(e,u,r,n,{candidateCount:l.length});k>d&&(d=k,c=u,b=y)}return d<r.minConfidence?null:{element:c,confidence:d,breakdown:b}}function yi(e,t,r,n){let i=[],o=r.weights.signature+r.weights.slotMatch,a={slot:o};function s(b){if(b.children)return b.children;let u=b.childNodes;if(!u)return[];let k=[];for(let y=0;y<u.length;y++)u[y].nodeType===1&&k.push(u[y]);return k}function l(b,u){let k=s(b),y=s(u);if(k.length===y.length)for(let N=0;N<k.length;N++){let q=k[N],H=y[N];if(r.shouldIgnore?.(q)||r.shouldIgnore?.(H)||r.excludeIds&&(q.getAttribute("id")||H.getAttribute("id"))||q.tagName!==H.tagName)continue;let oe=se(q,r,n).signature,ee=se(H,r,n).signature;oe!==ee&&i.push({newEl:q,oldEl:H,score:o,breakdown:a}),l(q,H)}}function c(b,u){for(;;){if(b.tagName===u.tagName)return[b,u];let k=s(b);if(!b.tagName&&k.length===1){b=k[0];continue}let y=s(u);if(y.length===1&&y[0].tagName===b.tagName){u=y[0];continue}return null}}let d=c(e,t);return d&&l(d[0],d[1]),i}function Lr(e,t,r,n,i){let o=t.querySelectorAll("*"),a=Fr(e,r,n,i),s=0;for(let k of o){let y=se(k,r,n);y.domIndex=s++}let l=[],c=new Map;function d(k,y,N){let q=new Set;if(k.textHint){let z=c.get(k.signature);if(!z){z=new Map;for(let Q of y){let pe=se(Q,r,n).textHint,fe=z.get(pe);fe||(fe=[],z.set(pe,fe)),fe.push(Q)}c.set(k.signature,z)}let ie=z.get(k.textHint);if(ie)for(let Q=0;Q<ie.length&&Q<N;Q++)q.add(ie[Q])}let H=0,oe=y.length;for(;H<oe;){let z=H+oe>>1;se(y[z],r,n).domIndex<k.domIndex?H=z+1:oe=z}let ee=Math.max(0,Math.min(H-(N>>1),y.length-N)),le=Math.min(ee+N,y.length);for(let z=ee;z<le;z++)q.add(y[z]);return[...q]}for(let k of o){if(r.shouldIgnore?.(k)||r.excludeIds&&k.getAttribute("id"))continue;let y=se(k,r,n),N=a.get(y.signature)||[],q=r.excludeIds?N.filter(ee=>!ee.getAttribute("id")):N,H=r.maxScoredCandidates,oe=H&&q.length>H?d(y,q,H):q;for(let ee of oe){let{score:le,breakdown:z}=Bt(k,ee,r,n,{candidateCount:q.length});le>=r.minConfidence&&l.push({newEl:k,oldEl:ee,score:le,breakdown:z})}}if(r.weights.slotMatch>0){let k=yi(t,e,r,n);for(let y of k)l.push(y)}l.sort((k,y)=>y.score-k.score);let b=new Map,u=new Set;for(let{newEl:k,oldEl:y}of l)b.has(k)||u.has(y)||(b.set(k,y),u.add(y));return b}function jr(e,t,r,n){let i=se(e,r,n),o=se(t,r,n),{score:a,breakdown:s}=Bt(e,t,r,n,{candidateCount:1});return{matches:a>=r.minConfidence,score:a,breakdown:s,newMeta:{signature:i.signature,path:i.path,textHint:i.textHint},oldMeta:{signature:o.signature,path:o.path,textHint:o.textHint}}}function qr(e={}){let t={...Nr,...e,weights:{...Nr.weights,...e.weights}},r=new WeakMap,n=new WeakMap;return{findMatch:(i,o)=>Ir(i,o,t,r,n),computeMatches:(i,o)=>Lr(i,o,t,r,n),explain:(i,o)=>jr(i,o,t,r),invalidate:i=>ki(i,r,n),session:()=>{let i=new WeakMap,o=new WeakMap;return{findMatch:(a,s)=>Ir(a,s,t,i,o),computeMatches:(a,s)=>Lr(a,s,t,i,o),explain:(a,s)=>jr(a,s,t,i)}},getConfig:()=>({...t})}}function Pt(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
2
- `;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let r=e.indexOf("*/",t+2);if(r===-1)return e.length;t=r+2;continue}return t}}function Dr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,r)=>r.length%2===0?r+'\\"':t)}var vi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,xi=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ot(e){try{return JSON.parse(e)}catch{return JSON.parse(wi(e))}}function wi(e){let t="",r=0,n=(i,o)=>{throw new Error(`Invalid relaxed JSON: ${i} at position ${o}`)};for(;r<e.length&&(r=Pt(e,r),!(r>=e.length));){let i=e[r];if("{}[]:".includes(i)){t+=i,r++;continue}if(i===","){let s=Pt(e,r+1);if(e[s]==="}"||e[s]==="]"){r++;continue}t+=i,r++;continue}if(i==='"'||i==="'"){let s=r+1;for(;s<e.length&&e[s]!==i;)e[s]==="\\"&&s++,s++;s>=e.length&&n("unterminated string",r);let l=e.slice(r+1,s);i==="'"&&(l=Dr(l)),t+='"'+l+'"',r=s+1;continue}let o=r;for(;o<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[o]);)o++;o===r&&n("unexpected character "+JSON.stringify(i),r);let a=e.slice(r,o);if(a==="true"||a==="false"||a==="null"||vi.test(a)){t+=a,r=o;continue}if(xi.test(a)){if(e[Pt(e,o)]===":"){t+='"'+a+'"',r=o;continue}n("unquoted value "+JSON.stringify(a),r)}n("invalid token "+JSON.stringify(a),r)}return t}function $r(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(i){let o=[],a=0;for(;a<i.length;){let s=i[a];if(/\s/.test(s)){a++;continue}if("{}".includes(s)){o.push({type:s,value:s}),a++;continue}if(s==="["){let b=!1,u=a+1;for(;u<i.length&&/\s/.test(i[u]);)u++;if(u<i.length&&/[a-zA-Z_]/.test(i[u])&&(b=!0),!b){o.push({type:s,value:s}),a++;continue}}if(s==="]"){o.push({type:s,value:s}),a++;continue}if(s===":"){o.push({type:t.COLON,value:s}),a++;continue}if(s===","){o.push({type:t.COMMA,value:s}),a++;continue}if(s==='"'||s==="'"){let b=s,u=a+1;for(;u<i.length&&i[u]!==b;)i[u]==="\\"&&u++,u++;o.push({type:t.STRING,value:i.substring(a+1,u),quoted:!0,sourceQuote:b}),a=u+1;continue}let l=a,c;for(;l<i.length&&!/[{},]/.test(i[l]);)if(i[l]===":"){let b=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],u=!1;for(let k of b){let y=k.substring(1);if(i.substring(l+1,l+1+y.length)===y){u=!0,l+=y.length;break}}if(!u)break}else if(i[l]==="["){for(l++;l<i.length&&i[l]!=="]";){if(i[l]==='"'||i[l]==="'"){let b=i[l];for(l++;l<i.length&&i[l]!==b;)i[l]==="\\"&&l++,l++}l++}l<i.length&&i[l]==="]"&&l++}else l++;c=i.substring(a,l);let d=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?d=t.NUMBER:c==="true"||c==="false"||c==="null"?d=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(d=t.SELECTOR),o.push({type:d,value:c,quoted:!1}),a=l}return o}function n(i){let o="";for(let a=0;a<i.length;a++){let s=i[a];if("{}".includes(s.type)||"[]".includes(s.type)){o+=s.value;continue}if(s.type===t.COLON){o+=s.value;continue}if(s.type===t.COMMA){let l=i[a+1];if(l&&(l.type==="}"||l.type==="]"))continue;o+=s.value;continue}if(s.type===t.STRING){let l=s.value;s.sourceQuote==="'"&&(l=Dr(l)),o+=`"${l}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){o+=s.value;continue}o+=`"${s.value}"`}return o}try{let i=r(e),o=n(i);return JSON.parse(o)}catch(i){throw new Error("Invalid extraction rules syntax: "+i.message)}}var J=Symbol("hyper-morph-json-merge:missing"),Br=["id","_id","uuid","key","slug","code","name"];function Ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ue(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function _i(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0})}function be(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!be(e[r],t[r]))return!1;return!0}if(Ce(e)&&Ce(t)){let r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n of r)if(!Ue(t,n)||!be(e[n],t[n]))return!1;return!0}return!1}function Pr(e,t,r,n){return be(t,r)?t:be(t,e)?r:be(r,e)?t:Ce(t)&&Ce(r)?Ai(Ce(e)?e:{},t,r,n):Array.isArray(t)&&Array.isArray(r)?Ti(Array.isArray(e)?e:[],t,r,n):r}function zr(e,t,r,n){return t===J&&r===J?J:t===J?e===J?r:be(r,e)?J:r:r===J?e===J?t:J:Pr(e,t,r,n)}function Ai(e,t,r,n){let i={},o=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(r)]);for(let a of o){let s=zr(Ue(e,a)?e[a]:J,Ue(t,a)?t[a]:J,Ue(r,a)?r[a]:J,n);s!==J&&_i(i,a,s)}return i}function Si(e){return e===null||typeof e!="object"}function st(e){return typeof e+":"+String(e)}function Ei(e,t){for(let r of t){let n=new Set;for(let i of r){if(!Ue(i,e))return!1;let o=i[e];if(typeof o!="string"&&typeof o!="number")return!1;let a=st(o);if(n.has(a))return!1;n.add(a)}}return!0}function Ci(e,t,r,n){let i=[e,t,r],o=!0;for(let a of i)for(let s of a)Ce(s)||(o=!1);if(o){for(let a of n.keyCandidates)if(Ei(a,i))return{kind:"keyed",field:a};return null}for(let a of i){let s=new Set;for(let l of a){if(!Si(l))return null;let c=st(l);if(s.has(c))return null;s.add(c)}}return{kind:"self"}}function Ti(e,t,r,n){let i=Ci(e,t,r,n);if(!i)return r;let o=i.kind==="self"?st:k=>st(k[i.field]),a=k=>{let y=new Map;for(let N of k)y.set(o(N),N);return y},s=a(e),l=a(t),c=a(r),d=new Map,b=new Set([...s.keys(),...l.keys(),...c.keys()]);for(let k of b){let y=zr(s.has(k)?s.get(k):J,l.has(k)?l.get(k):J,c.has(k)?c.get(k):J,n);y!==J&&d.set(k,y)}let u=[];for(let k of r){let y=o(k);d.has(y)&&u.push(y)}for(let k=0;k<t.length;k++){let y=o(t[k]);if(!d.has(y)||u.includes(y))continue;let N=0;for(let q=k-1;q>=0;q--){let H=u.indexOf(o(t[q]));if(H!==-1){N=H+1;break}}u.splice(N,0,y)}return u.map(k=>d.get(k))}function zt(e,t,r,n={}){let i=n.keyCandidates?[...n.keyCandidates,...Br]:Br;return Pr(e===void 0?J:e,t,r,{keyCandidates:i})}function Ut(e,t,r,n={}){let i=n.parse||ot,o=[],a=(b,u)=>{if(typeof b!="string")return J;try{return i(b)}catch(k){return o.push(`${u} side is not valid JSON (${k.message})`),J}},s=a(t,"local"),l=a(r,"remote");if(s===J)return{text:r,warnings:o};if(l===J)return{text:t,warnings:o};let c=a(e,"base"),d=zt(c===J?void 0:c,s,l,n);return be(d,l)?{text:r,warnings:o}:be(d,s)?{text:t,warnings:o}:{text:JSON.stringify(d,null,2),warnings:o}}var He=(function(){"use strict";let e=()=>{},t='[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]';function r(p){if(!(p instanceof Element))return!1;if(p.matches(t))return!0;if(p.tagName==="LINK"||p.tagName==="SCRIPT"){let T=p.getAttribute("src")||p.getAttribute("href")||"";if(T.startsWith("chrome-extension://")||T.startsWith("moz-extension://")||T.startsWith("safari-web-extension://"))return!0}return!1}function n(p){return p instanceof Element?p.closest(t)?!0:r(p):!1}let i=qr({shouldIgnore:n});function o(p,T,E){if(E){let O=E.identityOf(p);if(O&&!E.disabled.has(O.key))return"hm-merge:"+O.key}if(T!=="smart")return p.outerHTML;let R=p.getAttribute("src"),C=p.getAttribute("type")||"text/javascript";if(R)try{let O=new URL(R,window.location.href);return`ext:${C}:${O.origin}${O.pathname}${O.search}`}catch{return`ext:${C}:${R}`}else{let O=p.textContent.trim(),v=5381;for(let A=0;A<O.length;A++)v=(v<<5)+v^O.charCodeAt(A);return`inline:${C}:${Math.abs(v).toString(36)}`}}let a="http://www.w3.org/1999/xhtml";function s(p){return p instanceof Element&&p.tagName==="SCRIPT"&&p.namespaceURI===a}function l(p){let T=document.createElement("div");T.innerHTML="<script><\/script>";let E=T.firstChild;for(let R of p.attributes)E.setAttribute(R.name,R.value);return E.textContent=p.textContent,E}function c(p){if(s(p))return l(p);if(p instanceof Element)for(let T of p.querySelectorAll("script"))s(T)&&T.replaceWith(l(T));return p}function d(p){let T=(p.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return T==="application/json"||T.endsWith("+json")}let b={match:p=>p.hasAttribute("merge"),identity:p=>p.getAttribute("merge")};function u(p,T,E){if(E.merge===!1)return null;let R=[b,...E.mergeTags||[]],C=new WeakMap,O=f=>{if(C.has(f))return C.get(f);let w=null;if(s(f)&&!f.getAttribute("src")&&!n(f)){let _=f;for(let I=0;I<R.length;I++)if(R[I].match(_)){if(!d(_))console.warn("[hyper-morph] merge ignored: script type is not JSON",_);else{let B=R[I].identity(_);B!=null&&B!==""&&(w={key:I+":"+B,raw:B,recognizer:R[I]})}break}}return C.set(f,w),w},v=new Set,A=f=>{let w=new Map,_=I=>{let B=O(I);B&&(w.has(B.key)?(v.add(B.key),console.warn(`[hyper-morph] merge disabled for duplicate identity "${B.raw}"`)):w.set(B.key,I))};s(f)&&_(f);for(let I of f.querySelectorAll("script"))_(I);return w},g=A(p),h=A(T.__hyperMorphRoot||T);if(g.size===0&&h.size===0)return null;let m=null;return{identityOf:O,disabled:v,oldByKey:g,newByKey:h,baseTexts:()=>{if(m)return m;m=new Map;let f=E.mergeBase;if(!f)return m;let w;typeof f=="string"?w=new DOMParser().parseFromString(f,"text/html").documentElement:f instanceof Document?w=f.documentElement:w=f;let _=I=>{let B=O(I);B&&!m.has(B.key)&&m.set(B.key,I.textContent)};s(w)&&_(w);for(let I of w.querySelectorAll("script"))_(I);return m}}}function k(p,T,E){let R=p.merge;if(!R)return!1;let C=R.identityOf(T);if(!C||R.disabled.has(C.key))return!1;let O=R.identityOf(E);if(!O||O.key!==C.key)return!1;let v=T,A=E,g=A.getAttribute("merge-key")||v.getAttribute("merge-key"),{text:h,warnings:m}=Ut(R.baseTexts().get(C.key),v.textContent,A.textContent,{parse:C.recognizer.parse,keyCandidates:g?g.split(/[\s,]+/).filter(Boolean):void 0});for(let x of m)console.warn(`[hyper-morph] merge "${C.raw}": ${x}`);return v.textContent!==h&&(v.textContent=h),!0}let y={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:p=>p.getAttribute("im-preserve")==="true",shouldReAppend:p=>p.getAttribute("im-re-append")==="true",shouldRemove:e,afterHeadMorphed:e},scripts:{handle:!0,matchMode:"outerHTML",shouldPreserve:p=>p.getAttribute("im-preserve")==="true",shouldReAppend:p=>p.getAttribute("im-re-append")==="true",shouldRemove:e,afterScriptsHandled:e},restoreFocus:!0},N={computeMatches(p,T){let{computeMatches:E}=i.session();return E(p,T)}};function q(p,T,E={}){p=Qn(p);let R=xr(T),C=Zn(p,R,E),O=C.scripts.handle?new Set(Array.from(p.querySelectorAll("script")).map(h=>o(h,C.scripts.matchMode,C.merge))):null,v=ee(C),A=Q(C,p,R,h=>h.morphStyle==="innerHTML"?(z(h,p,R),Array.from(p.childNodes)):oe(h,p,R)),g=h=>{v&&le(C,v),H(C);let m=O?Lt(h,O,C):[];return m.length>0?Promise.all(m).then(()=>h):h};return A instanceof Promise?A.then(g):g(A)}function H(p){for(let T of Array.from(p.pantry.childNodes))p.callbacks.beforeNodeRemoved(T)!==!1&&p.callbacks.afterNodeRemoved(T);p.pantry.remove()}function oe(p,T,E){let R=xr(T);return z(p,R,E,T,T.nextSibling),Array.from(R.childNodes)}function ee(p){if(!p.config.restoreFocus)return null;let T=document.activeElement;if(!(T instanceof HTMLInputElement||T instanceof HTMLTextAreaElement))return null;let{id:E,selectionStart:R,selectionEnd:C}=T;return{element:T,id:E,selectionStart:R,selectionEnd:C}}function le(p,T){let E=T.element;if(T.id&&T.id!==document.activeElement?.getAttribute("id")&&(E=p.target.querySelector(`[id="${CSS.escape(T.id)}"]`),E?.focus()),E&&!E.selectionEnd&&T.selectionEnd!=null)try{E.setSelectionRange(T.selectionStart,T.selectionEnd)}catch{}}let z=(function(){function p(h,m,x,f=null,w=null){m instanceof HTMLTemplateElement&&x instanceof HTMLTemplateElement&&(m=m.content,x=x.content),f||=m.firstChild;for(let _ of x.childNodes){if(r(_))continue;if(f&&f!=w){let B=E(h,_,f,w);if(B){B!==f&&C(h,f,B),ie(B,_,h),f=B.nextSibling;continue}}if(_ instanceof Element){let B=_.getAttribute("id");if(h.persistentIds.has(B)){let S=O(m,B,f,h);ie(S,_,h),f=S.nextSibling;continue}if(!h.idMap.has(_)){let S=h.hyperMatches.get(_);if(S&&!h.idMap.has(S)&&!g(S,m)){A(m,S,f),ie(S,_,h),f=S.nextSibling;continue}}}let I=T(m,_,f,h);I&&(f=I.nextSibling)}for(;f&&f!=w;){let _=f;f=f.nextSibling,r(_)||R(h,_)}}function T(h,m,x,f){if(f.callbacks.beforeNodeAdded(m)===!1)return null;if(f.idMap.has(m)){let w=m,_=document.createElementNS(w.namespaceURI,w.localName);return h.insertBefore(_,x),ie(_,m,f),f.callbacks.afterNodeAdded(_),_}else{let w=c(document.importNode(m,!0));return h.insertBefore(w,x),f.callbacks.afterNodeAdded(w),w}}let E=(function(){function h(f,w,_,I){let B=w instanceof Element&&!f.idMap.has(w)?f.hyperMatches.get(w):null,S=null,M=w.nextSibling,V=0,D=_;for(;D&&D!=I;){if(r(D)){D=D.nextSibling;continue}if(x(D,w)){if(m(f,D,w)||D===B&&!f.idMap.has(D))return D;if(S===null){let W=D instanceof Element&&f.hyperMatchedOldElements.has(D);!f.idMap.has(D)&&!W&&(S=D)}}if(S===null&&M&&x(D,M)&&(V++,M=M.nextSibling,V>=2&&(S=void 0)),f.activeElementAndParents.includes(D))break;D=D.nextSibling}return S||null}function m(f,w,_){let I=f.idMap.get(w),B=f.idMap.get(_);if(!B||!I)return!1;for(let S of I)if(B.has(S))return!0;return!1}function x(f,w){let _=f,I=w;return _.nodeType===I.nodeType&&_.tagName===I.tagName&&(!_.getAttribute?.("id")||_.getAttribute?.("id")===I.getAttribute?.("id"))}return h})();function R(h,m){let x=m instanceof Element&&h.hyperMatchedOldElements.has(m)&&!h.idMap.has(m);if(h.idMap.has(m)||x)A(h.pantry,m,null);else{if(h.callbacks.beforeNodeRemoved(m)===!1)return;m.parentNode?.removeChild(m),h.callbacks.afterNodeRemoved(m)}}function C(h,m,x){let f=m;for(;f&&f!==x;){let w=f;f=f.nextSibling,r(w)||R(h,w)}return f}function O(h,m,x,f){let w=f.target.getAttribute?.("id")===m&&f.target||f.target.querySelector(`[id="${CSS.escape(m)}"]`)||f.pantry.querySelector(`[id="${CSS.escape(m)}"]`);return v(w,f),A(h,w,x),w}function v(h,m){let x=h.getAttribute("id");for(;h=h.parentNode;){let f=m.idMap.get(h);f&&(f.delete(x),f.size||m.idMap.delete(h))}}function A(h,m,x){if(h.moveBefore)try{h.moveBefore(m,x)}catch{h.insertBefore(m,x)}else h.insertBefore(m,x)}function g(h,m){let x=m instanceof Element?m:m.realParentNode;return!!x&&h.contains(x)}return p})(),ie=(function(){function p(v,A,g){return g.ignoreActive&&v===document.activeElement?null:(g.callbacks.beforeNodeMorphed(v,A)===!1||(v instanceof HTMLHeadElement&&g.head.ignore||(v instanceof HTMLHeadElement&&g.head.style!=="morph"?fe(v,A,g):(T(v,A,g),k(g,v,A)||O(v,g)||z(g,v,A))),g.callbacks.afterNodeMorphed(v,A)),v)}function T(v,A,g){let h=A.nodeType;if(h===1){let m=v,x=A,f=m.attributes,w=x.attributes;for(let _ of w)C(_.name,m,"update",g)||m.getAttribute(_.name)!==_.value&&m.setAttribute(_.name,_.value);for(let _=f.length-1;0<=_;_--){let I=f[_];if(I&&!x.hasAttribute(I.name)){if(C(I.name,m,"remove",g))continue;m.removeAttribute(I.name)}}O(m,g)||E(m,x,g)}(h===8||h===3)&&v.nodeValue!==A.nodeValue&&(v.nodeValue=A.nodeValue)}function E(v,A,g){if(v instanceof HTMLInputElement&&A instanceof HTMLInputElement&&A.type!=="file"){let h=A.value,m=v.value;R(v,A,"checked",g),R(v,A,"disabled",g),g.formStateSync==="property"&&v.indeterminate!==A.indeterminate&&(v.indeterminate=A.indeterminate),g.formStateSync==="property"?m!==h&&(C("value",v,"update",g)||(v.value=h)):A.hasAttribute("value")?m!==h&&(C("value",v,"update",g)||(v.setAttribute("value",h),v.value=h)):C("value",v,"remove",g)||(v.value="",v.removeAttribute("value"))}else if(v instanceof HTMLOptionElement&&A instanceof HTMLOptionElement)R(v,A,"selected",g);else if(v instanceof HTMLTextAreaElement&&A instanceof HTMLTextAreaElement){let h=A.value,m=v.value;if(C("value",v,"update",g)||(h!==m&&(v.value=h),g.formStateSync==="property"))return;v.firstChild&&v.firstChild.nodeValue!==h&&(v.firstChild.nodeValue=h)}}function R(v,A,g,h){let m=A[g],x=v[g];if(m!==x){let f=C(g,v,"update",h);if(f||(v[g]=A[g]),h.formStateSync==="property")return;m?f||v.setAttribute(g,""):C(g,v,"remove",h)||v.removeAttribute(g)}}function C(v,A,g,h){return v==="value"&&h.ignoreActiveValue&&A===document.activeElement?!0:h.callbacks.beforeAttributeUpdated(v,A,g)===!1}function O(v,A){return!!A.ignoreActiveValue&&v===document.activeElement&&v!==document.body}return p})();function Q(p,T,E,R){if(p.head.block){let C=T.querySelector("head"),O=E.querySelector("head");if(C&&O){let v=fe(C,O,p);return Promise.all(v).then(()=>(p.head.block=!1,p.head.ignore=!0,R(p)))}}return R(p)}function pe(p){return p.tagName==="SCRIPT"?!!p.getAttribute("src"):p.tagName==="LINK"?(p.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet")&&!!p.getAttribute("href"):!1}function fe(p,T,E){let R=[],C=[],O=[],v=[],A=E.scripts.matchMode,g=x=>{if(x.tagName==="SCRIPT")return o(x,A,E.merge);if(x.tagName==="LINK"&&A==="smart"){let f=x.getAttribute("href");if(f)try{let w=new URL(f,window.location.href);return`link:${x.getAttribute("rel")||""}:${w.origin}${w.pathname}${w.search}`}catch{}}return x.outerHTML},h=new Map;for(let x of T.children){if(r(x))continue;let f=g(x),w=h.get(f);w||(w=[],h.set(f,w)),w.push(x)}for(let x of p.children){let f=g(x),w=h.get(f),_=!!(w&&w.length),I=E.head.shouldReAppend(x),B=E.head.shouldPreserve(x);if(_||B)if(I)C.push(x);else{if(w&&w.length){let S=w.pop();w.length||h.delete(f),k(E,x,S)}O.push(x)}else E.head.style==="append"?I&&(C.push(x),v.push(x)):E.head.shouldRemove(x)!==!1&&!r(x)&&C.push(x)}for(let x of h.values())v.push(...x);let m=[];for(let x of v){let f=document.createRange().createContextualFragment(x.outerHTML).firstChild;if(E.callbacks.beforeNodeAdded(f)!==!1){if(f instanceof Element&&pe(f)){let w,_=new Promise(function(I){w=I});f.addEventListener("load",function(){w()}),f.addEventListener("error",function(){w()}),m.push(_)}p.appendChild(f),E.callbacks.afterNodeAdded(f),R.push(f)}}for(let x of C)E.callbacks.beforeNodeRemoved(x)!==!1&&(p.removeChild(x),E.callbacks.afterNodeRemoved(x));return E.head.afterHeadMorphed(p,{added:R,kept:O,removed:C}),m}function Lt(p,T,E){if(!E.scripts.handle)return[];let R=[],C=[],O=[],v=[],A=E.scripts.matchMode,g=[];for(let m of p)if(m instanceof Element){s(m)&&g.push(m);for(let x of m.querySelectorAll("script"))s(x)&&g.push(x)}for(let m of g){if(m.closest("head")||n(m))continue;let x=o(m,A,E.merge),f=T.has(x),w=E.scripts.shouldPreserve(m),_=E.scripts.shouldReAppend(m);f||w?_?(C.push(m),v.push(m)):O.push(m):v.push(m)}let h=[];for(let m of v){if(E.callbacks.beforeNodeAdded(m)===!1)continue;let x=document.createElement("script");for(let f of m.attributes)x.setAttribute(f.name,f.value);if(x.textContent=m.textContent,x.src){let f,w=new Promise(function(_){f=_});x.addEventListener("load",function(){f()}),x.addEventListener("error",function(){f()}),h.push(w)}m.replaceWith(x),E.callbacks.afterNodeAdded(x),R.push(x)}return E.scripts.afterScriptsHandled(E.target,{added:R,kept:O,removed:C}),h}let Zn=(function(){function p(g,h,m){let{persistentIds:x,idMap:f}=v(g,h),w=N.computeMatches(g,h);if(typeof m.key=="function"){let M=new Map,V=new Set,D=F=>{let L=m.key(F);L!=null&&(M.has(L)?V.add(L):M.set(L,F))};g instanceof Element&&D(g);for(let F of g.querySelectorAll("*"))D(F);for(let F of V)M.delete(F);let W=new Map;for(let[F,L]of w)W.set(L,F);let te=h.__hyperMorphRoot||h,X=new Map,G=new Set,j=F=>{let L=m.key(F);L!=null&&(X.has(L)?G.add(L):X.set(L,F))};te instanceof Element&&j(te);for(let F of te.querySelectorAll("*"))j(F);for(let F of G)X.delete(F);for(let[F,L]of X){let U=M.get(F);if(!U||U.tagName!==L.tagName)continue;let K=W.get(U);K&&K!==L&&w.delete(K);let ve=w.get(L);ve&&ve!==U&&W.delete(ve),w.set(L,U),W.set(U,L)}}let _=T(m),I=u(g,h,_.scripts);if(I){let M=new Map;for(let[V,D]of w)M.set(D,V);for(let[V,D]of I.newByKey){if(I.disabled.has(V))continue;let W=I.oldByKey.get(V);if(!W)continue;let te=M.get(W);te&&te!==D&&w.delete(te);let X=w.get(D);X&&X!==W&&M.delete(X),w.set(D,W),M.set(W,D)}}let B=new Set;for(let M of w.values())B.add(M);let S=_.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(S))throw new Error(`Do not understand how to morph style ${S}`);return{target:g,newContent:h,config:_,morphStyle:S,ignoreActive:_.ignoreActive,ignoreActiveValue:_.ignoreActiveValue,restoreFocus:_.restoreFocus,formStateSync:_.formStateSync||"attribute",idMap:f,persistentIds:x,hyperMatches:w,hyperMatchedOldElements:B,merge:I,pantry:E(),activeElementAndParents:R(g),callbacks:_.callbacks,head:_.head,scripts:_.scripts}}function T(g){let h=Object.assign({},y);return Object.assign(h,g),h.callbacks=Object.assign({},y.callbacks,g.callbacks),h.head=Object.assign({},y.head,g.head),h.scripts=Object.assign({},y.scripts,g.scripts),h}function E(){let g=document.createElement("div");return g.hidden=!0,document.body.insertAdjacentElement("afterend",g),g}function R(g){let h=[],m=document.activeElement;if(m?.tagName!=="BODY"&&g.contains(m))for(;m&&(h.push(m),m!==g);)m=m.parentElement;return h}function C(g){let h=Array.from(g.querySelectorAll("[id]"));return g.getAttribute?.("id")&&h.push(g),h}function O(g,h,m,x){for(let f of x){let w=f.getAttribute("id");if(h.has(w)){let _=f;for(;_;){let I=g.get(_);if(I==null&&(I=new Set,g.set(_,I)),I.add(w),_===m)break;_=_.parentElement}}}}function v(g,h){let m=C(g),x=C(h),f=A(m,x),w=new Map;O(w,f,g,m);let _=h.__hyperMorphRoot||h;return O(w,f,_,x),{persistentIds:f,idMap:w}}function A(g,h){let m=new Set,x=new Map;for(let w of g){let _=w.getAttribute("id");x.has(_)?m.add(_):x.set(_,w.tagName)}let f=new Set;for(let w of h){let _=w.getAttribute("id");f.has(_)?m.add(_):x.get(_)===w.tagName&&f.add(_)}for(let w of m)f.delete(w);return f}return p})(),{normalizeElement:Qn,normalizeParent:xr}=(function(){let p=new WeakSet;function T(v){return v instanceof Document?v.documentElement:v}function E(v){if(v==null)return document.createElement("div");if(typeof v=="string")return E(O(v));if(p.has(v))return v;if(v instanceof Node){if(v.parentNode)return new R(v);{let A=document.createElement("div");return A.append(v),A}}else{let A=document.createElement("div");for(let g of[...v])A.append(g);return A}}class R{constructor(A){this.originalNode=A,this.realParentNode=A.parentNode,this.previousSibling=A.previousSibling,this.nextSibling=A.nextSibling}get childNodes(){let A=[],g=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;g&&g!=this.nextSibling;)A.push(g),g=g.nextSibling;return A}querySelectorAll(A){return this.childNodes.reduce((g,h)=>{if(h instanceof Element){h.matches(A)&&g.push(h);let m=h.querySelectorAll(A);for(let x=0;x<m.length;x++)g.push(m[x])}return g},[])}insertBefore(A,g){return this.realParentNode.insertBefore(A,g)}moveBefore(A,g){return this.realParentNode.moveBefore(A,g)}get __hyperMorphRoot(){return this.originalNode}}function C(v){let A=x=>`<${x}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,g=v.replace(/<!--[\s\S]*?-->/g,"");for(let x of["script","style","textarea","title"])g=g.replace(new RegExp(`${A(x)}[\\s\\S]*?</${x}\\s*>`,"gi"),"");let h=new RegExp(`${A("svg")}[\\s\\S]*?</svg\\s*>`,"gi"),m;do m=g,g=g.replace(h,"");while(g!==m);return g}function O(v){let A=new DOMParser,g=C(v);if(g.match(/<\/html>/)||g.match(/<\/head>/)||g.match(/<\/body>/)){let h=A.parseFromString(v,"text/html");if(g.match(/<\/html>/))return p.add(h),h;{let m=h.firstChild;return m&&p.add(m),m}}else{let m=A.parseFromString("<body><template>"+v+"</template></body>","text/html").body.querySelector("template").content;return p.add(m),m}}return{normalizeElement:T,normalizeParent:E}})(),wr=Symbol("hyper-morph-duplicate-key"),_r=[p=>p.getAttribute("data-id"),p=>p.getAttribute("id")];function Pe(p,T){return T.map(E=>{let R=new Map;for(let C of p){if(C.nodeType!==1)continue;let O=E(C);O==null||O===""||R.set(O,R.has(O)?wr:C)}return R})}function Ar(p,T,E,R){for(let C=0;C<R.length;C++){let O=R[C](p);if(O==null||O===""||T[C].get(O)!==p)continue;let v=E[C].get(O);if(!(!v||v===wr)&&v.tagName===p.tagName)return v}return null}function Se(p,T,E){for(let R=0;R<E.length;R++){let C=E[R](p);if(!(C==null||C==="")&&T[R].get(C)===p)return!0}return!1}function ei(p,T,E={}){let R=E.skip||(()=>!1),C=E.ignoreAttr||(()=>!1),O=E.tiers&&E.tiers.length?E.tiers:_r,v=null;function A(){return v||(v=Pe([p,...p.querySelectorAll("*")],O)),v}let g=null;function h(){return g||(g=Pe([T,...T.querySelectorAll("*")],O)),g}function m(j){return!j.parentElement||!j.parentElement.parentElement}function x(j,F,L){return m(j)||Se(j,A(),O)?(L.push({type:"subtree",el:j,base:F}),!1):!0}function f(j,F){let L=[];for(let U of j.attributes)C(j,U.name)||F.getAttribute(U.name)!==U.value&&L.push(U.name);for(let U of F.attributes)C(j,U.name)||j.hasAttribute(U.name)||L.push(U.name);return L}function w(j){let F=[],L=null,U=()=>{L!==null&&(F.push({nodeType:3,nodeValue:L}),L=null)};for(let K of j.childNodes){if(K.nodeType===3){L=(L===null?"":L)+K.nodeValue;continue}K.nodeType===1&&R(K)||(U(),(K.nodeType===1||K.nodeType===8)&&F.push(K))}return U(),F}function _(j,F){if(j.nodeType!==F.nodeType)return!1;if(j.nodeType!==1)return!0;if(j.tagName!==F.tagName)return!1;for(let L of O){let U=L(j),K=L(F);if(U!=null&&U!==""&&K!=null&&K!==""&&U!==K)return!1}return!0}function I(j){let F="";for(let L of j)L.nodeType===3&&L.nodeValue.trim()!==""?F+="\0"+L.nodeValue:L.nodeType===8&&(F+=""+L.nodeValue);return F}function B(j,F,L){let U=w(j),K=w(F);if(U.length===K.length){let $=!0;for(let Y=0;Y<U.length;Y++)if(!_(U[Y],K[Y])){$=!1;break}if($){for(let Y=0;Y<U.length;Y++){let Ee=U[Y];if(Ee.nodeType===1){if(S(Ee,K[Y],L))return!0}else if(Ee.nodeValue!==K[Y].nodeValue)return!0}return!1}}let ve=U.filter($=>$.nodeType===1),jt=K.filter($=>$.nodeType===1);if(I(U)!==I(K))return!0;let Sr=Pe(ve,O),Er=Pe(jt,O),Ft=[],qt=new Set,Cr=[];for(let $ of ve){let Y=Ar($,Sr,Er,O);Y&&!qt.has(Y)?(Ft.push([$,Y]),qt.add(Y)):Cr.push($)}let ge=[];for(let $ of Cr)Se($,Sr,O)?L.push({type:"subtree",el:$,base:null}):ge.push($);let ze=[];for(let $ of jt)qt.has($)||(Se($,Er,O)?L.push({type:"deletion",el:$}):ze.push($));if(ge.length!==ze.length)return!0;for(let $=0;$<ge.length;$++)if(!_(ge[$],ze[$]))return!0;let Tr=new Map(Ft);for(let $=0;$<ge.length;$++)Tr.set(ge[$],ze[$]);let Rr=-1;for(let $ of ve){let Y=Tr.get($);if(!Y)continue;let Ee=jt.indexOf(Y);if(Ee<Rr)return!0;Rr=Ee}for(let $=0;$<ge.length;$++)if(S(ge[$],ze[$],L))return!0;for(let[$,Y]of Ft)if(S($,Y,L))return!0;return!1}function S(j,F,L){if(j.tagName!==F.tagName)return x(j,F,L);let U=f(j,F),K=[];if(B(j,F,K))return x(j,F,L);if(U.length){if(!m(j)&&!Se(F,h(),O))return!0;L.push({type:"attrs",el:j,names:U,base:F})}return L.push(...K),!1}let M=[],V=f(p,T);V.length&&M.push({type:"attrs",el:p,names:V});let D=(j,F)=>Array.from(j.children).find(L=>L.tagName===F)||null,W=D(p,"HEAD"),te=D(T,"HEAD");if(W&&te){let j=[];S(W,te,j),j.length&&M.push({type:"head",el:W})}else(W||te)&&W&&M.push({type:"head",el:W});let X=D(p,"BODY"),G=D(T,"BODY");return X&&G?S(X,G,M):X&&M.push({type:"subtree",el:X,base:null}),{entries:M}}function ti(p,T,E={}){let R=E.tiers&&E.tiers.length?E.tiers:_r,C=p.documentElement,O=[],v=0,A=S=>({ok:!1,placed:O,held:S,skippedAttrs:v});if(!C)return A(null);function g(S){let M=[S,...S.querySelectorAll("*")];return Pe(M,R)}let h=g(C),m=new Map,x=S=>{let M=S.getRootNode(),V=m.get(M);if(!V){let D=M.nodeType===9?M.documentElement:M;V=g(D),m.set(M,V)}return V};function f(S){if(!S.parentElement&&S.tagName==="HTML")return C;if(S.parentElement&&!S.parentElement.parentElement&&S.parentElement.tagName==="HTML"){if(S.tagName==="BODY")return p.body||null;if(S.tagName==="HEAD")return p.head||null}return null}function w(S){let M=f(S);return M||Ar(S,x(S),h,R)}function _(S){if(!S)return null;let M=w(S);return M&&M.isConnected?M:null}function I(S){for(let M=0;M<R.length;M++){let V=R[M](S);V!=null&&V!==""&&h[M].set(V,S)}}for(let S of T){if(S.type!=="deletion")continue;let M=w(S.el);M&&M!==C&&M.remove()}let B=T.filter(S=>S.type!=="deletion").sort((S,M)=>S.el===M.el?0:S.el.compareDocumentPosition(M.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let S of B){if(S.type==="head"){let G=p.importNode(S.el,!0);p.head?p.head.replaceWith(G):C.insertBefore(G,C.firstChild),O.push({entry:S,imported:G});continue}if(S.type==="attrs"){let G=_(S.el)||_(S.base);if(!G){v++;continue}for(let j of S.names)S.el.hasAttribute(j)?G.setAttribute(j,S.el.getAttribute(j)):G.removeAttribute(j);continue}let M=S.el;if(f(M))return A(S);let V=_(M)||_(S.base);if(V){let G=p.importNode(M,!0);V.replaceWith(G),I(G),O.push({entry:S,imported:G});continue}if(S.base!=null&&!Se(S.base,x(S.base),R)||!Se(M,x(M),R))return A(S);let D=M.parentElement;if(!D)return A(S);let W=_(D);if(!W)return A(S);let te=null;for(let G=M.previousElementSibling;G;G=G.previousElementSibling){let j=_(G);if(j&&j.parentNode===W){te=j;break}}let X=p.importNode(M,!0);if(te)W.insertBefore(X,te.nextSibling);else{let G=Array.prototype.indexOf.call(D.children,M);W.insertBefore(X,W.children[G]||null)}I(X),O.push({entry:S,imported:X})}return{ok:!0,placed:O,held:null,skippedAttrs:v}}return{morph:q,defaults:y,findChangedRoots:ei,spliceProtected:ti,mergeJson:zt,mergeScriptText:Ut,parseJsonRelaxed:ot,parseRulesRelaxed:$r}})();var aa=He.morph,la=He.defaults,ca=He.findChangedRoots,ua=He.spliceProtected;var Ht=He;var at=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Vt=new Set(at),Ur=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Hr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var lt={};$t(lt,{EmptyListInsert:()=>We,MAX_RULE_DEPTH:()=>Oe,MaxRuleDepthExceeded:()=>xe,RuleTargetReadOnly:()=>Ke,RulesParseError:()=>Te,ShapeMismatch:()=>Ve,UnknownRulesVersion:()=>Re});var Te=class extends Error{constructor(t,r){super(t),this.name="RulesParseError",this.cause=r}},Re=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},Oe=20,xe=class extends Error{constructor(t){super(`rule depth exceeded ${Oe} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},Ve=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},We=class extends Error{constructor(t){super(`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},Ke=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}};function ke(e,t,r,n={}){return Wt(e,t,r,{depth:0,path:[]},n)}function Wt(e,t,r,n,i){if(n.depth>Oe)throw new xe(n.path);if(typeof r=="string")return Ii(e,t,r,i);if(Array.isArray(r)){let[o,a]=r;return e.find(t,o,i).map((l,c)=>Wt(e,l,a,{depth:n.depth+1,path:[...n.path,c]},i))}if(typeof r=="object"&&r!==null){let o={};for(let[a,s]of Object.entries(r))o[a]=Wt(e,t,s,{depth:n.depth+1,path:[...n.path,a]},i);return o}return null}function Ii(e,t,r,n){if(r.endsWith("[]")){let a=r.slice(0,-2);return e.find(t,a,n).map(s=>e.text(s))}if(r.startsWith("@"))return Vr(e,t,r.slice(1));let i=Z(r);if(i!==-1){let a=r.slice(0,i),s=r.slice(i+1),l=a?e.find(t,a,n):[t];return l.length===0?null:Vr(e,l[0],s)}if(r===".")return e.text(t);let o=e.find(t,r,n);return o.length===0?null:e.text(o[0])}function Vr(e,t,r){if(Vt.has(r)){let i=e.prop(t,r);return i==null?null:String(i)}let n=e.attr(t,r);return n||null}function Li(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function ji(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var Fi={find(e,t,r={}){let n=ji(e);if(!n||!n.querySelectorAll)return[];let i=Array.from(n.querySelectorAll(t));r.includeRulesTag||(i=i.filter(s=>!Li(s)));let o=[];r.skip&&o.push(r.skip);let a=r.templateAttr===null?null:r.templateAttr||"cms-template";if(a&&o.push("["+a+"]"),o.length){let s=o.join(", ");i=i.filter(l=>!l.closest||!l.closest(s))}return i},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,r){if(r===void 0){let n=e?e[t]:void 0;return n!==void 0?n:null}e[t]=r},clone(e){return e.cloneNode(!0)},insertAt(e,t,r){let n=e.children[r]||null;e.insertBefore(t,n)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let n=e.ownerDocument.createElement("template");n.innerHTML=t;let i=n.content.firstElementChild;if(!i)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(i,e),i},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(n=>{n.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}},ue=Fi;function Kt(e){try{return JSON.parse(e)}catch(t){throw new Te(`Invalid strict JSON: ${t.message}`,t)}}function Me(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(i){let o=[],a=0;for(;a<i.length;){let s=i[a];if(/\s/.test(s)){a++;continue}if("{}".includes(s)){o.push({type:s,value:s}),a++;continue}if(s==="["){let b=!1,u=a+1;for(;u<i.length&&/\s/.test(i[u]);)u++;if(u<i.length&&/[a-zA-Z_]/.test(i[u])&&(b=!0),!b){o.push({type:s,value:s}),a++;continue}}if(s==="]"){o.push({type:s,value:s}),a++;continue}if(s===":"){o.push({type:t.COLON,value:s}),a++;continue}if(s===","){o.push({type:t.COMMA,value:s}),a++;continue}if(s==='"'||s==="'"){let b=s,u=a+1;for(;u<i.length&&i[u]!==b;)i[u]==="\\"&&u++,u++;o.push({type:t.STRING,value:i.substring(a+1,u),quoted:!0,sourceQuote:b}),a=u+1;continue}let l=a,c;for(;l<i.length&&!/[{},]/.test(i[l]);)if(i[l]===":"){let b=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],u=!1;for(let k of b){let y=k.substring(1);if(i.substring(l+1,l+1+y.length)===y){u=!0,l+=y.length;break}}if(!u)break}else if(i[l]==="["){for(l++;l<i.length&&i[l]!=="]";){if(i[l]==='"'||i[l]==="'"){let b=i[l];for(l++;l<i.length&&i[l]!==b;)i[l]==="\\"&&l++,l++}l++}l<i.length&&i[l]==="]"&&l++}else l++;c=i.substring(a,l);let d=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?d=t.NUMBER:c==="true"||c==="false"||c==="null"?d=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(d=t.SELECTOR),o.push({type:d,value:c,quoted:!1}),a=l}return o}function n(i){let o="";for(let a=0;a<i.length;a++){let s=i[a];if("{}".includes(s.type)||"[]".includes(s.type)){o+=s.value;continue}if(s.type===t.COLON){o+=s.value;continue}if(s.type===t.COMMA){let l=i[a+1];if(l&&(l.type==="}"||l.type==="]"))continue;o+=s.value;continue}if(s.type===t.STRING&&s.quoted){let l=s.value;s.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(c,d)=>d.length%2===0?d+'\\"':c)),o+=`"${l}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){o+=s.value;continue}if(s.type===t.SELECTOR||s.type===t.IDENTIFIER){o+=`"${s.value}"`;continue}o+=`"${s.value}"`}return o}try{let i=r(e),o=n(i);return JSON.parse(o)}catch(i){throw new Te("Invalid extraction rules syntax: "+i.message,i)}}var Kr="1",Wr=/^[a-zA-Z0-9_-]+$/;function Ge(e,t,r){let n;if(r===void 0)n="script[data-rules-name]";else{if(typeof r!="string"||!Wr.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${Wr})`);n=`script[data-rules-name~="${r}"]`}let i=e.find(t,n,{includeRulesTag:!0});if(i.length===0)return null;r!==void 0&&i.length>1&&console.warn(`hyper-html-api: ${i.length} rules tags match data-rules-name~="${r}"; using the first.`);let o=i[0],a=e.attr(o,"data-rules-version");if(a!==Kr)throw new Re(a);return{rules:Me(e.text(o)),tagNode:o}}var Pa=new Function("url","return import(url)");var Di=.5;function Gt(e,t,r,n,i,o,a,s={}){let l=e.find(t,r,s);if(i.length===0){l.forEach(z=>e.remove(z));return}let c=i.length>l.length,d=l[0]||null;if(c&&!d&&(d=zi(e,t,r,s),!d))throw new We(o.path);let b=l.map(z=>$i(e,z,n,s)),u=null;if(d){u=e.clone(d),s.templateAttr&&e.removeAttr(u,s.templateAttr);let z=e.stripIds(u);z>0&&console.warn(`[hyper-html-api] stripped ${z} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let k=Bi(i,b,n),y=l[0]||d,N=e.parent(y),q=l.length>0?Zr(e,N,y):0,H=Ui(e,l),oe=new Set,ee=[],le=i.map((z,ie)=>{let Q=k[ie];if(Q>=0)return oe.add(Q),ee.push(!1),l[Q];ee.push(!0);let pe=e.clone(u);return e.stripIds(pe),pe});if(l.forEach((z,ie)=>{oe.has(ie)||e.remove(z)}),H){le.forEach((z,ie)=>{let Q=q+ie;e.children(N).findIndex(Lt=>e.sameNode(Lt,z))!==Q&&e.insertAt(N,z,Q)}),Xr(e,le,n,i,o,a,s);return}Hi(e,le,ee,N,q),Xr(e,le,n,i,o,a,s)}function Xr(e,t,r,n,i,o,a){t.forEach((s,l)=>{if(r===null){let c=n[l],d=c==null?"":String(c);e.text(s)!==d&&e.text(s,d)}else{let c=o(e,s,r,n[l],{depth:i.depth+1,path:[...i.path,l]},a);c&&c!==s&&(t[l]=c)}})}function $i(e,t,r,n){return r===null?e.text(t):ke(e,t,r,n)}function Bi(e,t,r){let n=new Array(e.length).fill(-1),i=new Set;return e.forEach((o,a)=>{let s=-1,l=-1;t.forEach((c,d)=>{if(i.has(d))return;let b=Pi(o,c,r),u=b===l&&s>=0?Math.abs(d-a)<Math.abs(s-a):!1;(b>l||u)&&(l=b,s=d)}),l>=Di&&(n[a]=s,i.add(s))}),n}function Pi(e,t,r){if(r===null)return e===t?1:0;let n=Object.keys(r||{});if(n.length===0)return 0;let i=0;for(let o of n)JSON.stringify(e?.[o])===JSON.stringify(t?.[o])&&i++;return i/n.length}function Zr(e,t,r){let n=e.children(t);for(let i=0;i<n.length;i++)if(e.sameNode(n[i],r))return i;return-1}function zi(e,t,r,n){if(!n.templateAttr)return null;let i=t;for(;i;){let o=e.find(i,r,{includeRulesTag:!1,templateAttr:null});for(let a of o)if(e.attr(a,n.templateAttr)!=null)return a;i=e.parent(i)}return null}function Ui(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let n=e.children(r),i=[];for(let o of t){let a=n.findIndex(s=>e.sameNode(s,o));if(a===-1)return!1;i.push(a)}return i.sort((o,a)=>o-a),i[i.length-1]-i[0]===i.length-1}function Hi(e,t,r,n,i){let o=null,a=i;for(let s=0;s<t.length;s++){if(!r[s]){o=t[s];continue}let l=o?e.parent(o):n;if(!l)continue;let c=o?Zr(e,l,o)+1:a++;e.insertAt(l,t[s],c),o=t[s]}}var Qr=new Set(["checked","selected","disabled","readOnly","paused"]);function Ne(e,t,r,n,i={}){let o=[];if(Jt(r,n,[],o),o.length)throw new Ve(o);ct(e,t,r,n,{depth:0,path:[]},i)}function ct(e,t,r,n,i,o={}){if(i.depth>Oe)throw new xe(i.path);if(n===void 0)return t;if(typeof r=="string")return Vi(e,t,r,n,i,o);if(Array.isArray(r)){let[a,s]=r;return Gt(e,t,a,s,n,i,ct,o),t}if(typeof r=="object"&&r!==null){for(let[a,s]of Object.entries(r)){let l=ct(e,t,s,n==null?n:n[a],{depth:i.depth+1,path:[...i.path,a]},o);l&&l!==t&&(t=l)}return t}return t}function Vi(e,t,r,n,i,o){if(r.endsWith("[]")){let l=r.slice(0,-2);return Gt(e,t,l,null,n,i,ct,o),t}if(r.startsWith("@"))return en(e,t,r.slice(1),n);let a=Z(r);if(a!==-1){let l=r.slice(0,a),c=r.slice(a+1),d=l?e.find(t,l,o):[t];return d.length===0||en(e,d[0],c,n),t}if(r===".")return e.text(t,n==null?"":String(n)),t;let s=e.find(t,r,o);return s.length===0||e.text(s[0],n==null?"":String(n)),t}function en(e,t,r,n){if(Hr.has(r))throw new Ke(r);if(r==="outerHTML"){let i=n==null?"":String(n);return e.replaceWith(t,i)}return Ur.has(r)?(e.prop(t,r,Wi(r,n)),t):(e.attr(t,r,n==null?"":String(n)),t)}function Wi(e,t){return t==null?Qr.has(e)?!1:"":Qr.has(e)?t==="false"?!1:!!t:t}function Jt(e,t,r,n){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((i,o)=>{typeof i=="object"&&i!==null&&n.push({path:Ye([...r,o]),expected:"scalar",got:Je(i)})}):n.push({path:Ye(r),expected:"array",got:Je(t)});return}t!==null&&typeof t=="object"&&n.push({path:Ye(r),expected:"scalar",got:Je(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){n.push({path:Ye(r),expected:"array",got:Je(t)});return}let i=e[1];t.forEach((o,a)=>Jt(i,o,[...r,a],n));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){n.push({path:Ye(r),expected:"object",got:Je(t)});return}for(let[i,o]of Object.entries(e))Jt(o,t[i],[...r,i],n)}}}function Je(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Ye(e){return e.join(".")}function Yt(e,t,r){if(r&&typeof r=="object")return{rules:r,tagNode:null};if(typeof r=="string"){let n=t&&t.ownerDocument?t.ownerDocument:t;return Ge(e,n,r)}return null}function rn(e,t,r,n){let i=Yt(e,t,r);if(!i){let s=typeof r=="string"?`data-rules-name~="${r}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${s}`)}let{rules:o,tagNode:a}=i;return{rules:o,tagNode:a,get:()=>ke(e,t,o,n),set:s=>Ne(e,t,o,s,n)}}var re={extract:(e,t,r)=>ke(ue,e,t,r),apply:(e,t,r,n)=>Ne(ue,e,t,r,n),findRulesIn:(e,t)=>Ge(ue,e,t),findRules:(e,t)=>Yt(ue,e,t),bind:(e,t,r)=>rn(ue,e,t,r),parseStrict:Kt,parseRelaxed:Me,ruleAttrIndex:Z,splitRule:it,errors:lt,DOM_PROPERTIES:at};var Zt={};$t(Zt,{fromString:()=>me,getRuleAtPath:()=>we,getValueAtPath:()=>so,setAtPath:()=>Xt,toString:()=>oo});function oo(e){return e.map(String).join(".")}function me(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function we(e,t){let r=e;for(let n of t){if(r==null)return;if(typeof r=="string"){if(r.endsWith("[]")&&(typeof n=="number"||n==="*")){r=r.slice(0,-2);continue}return}if(Array.isArray(r)){if(typeof n!="number"&&n!=="*")return;r=r[1];continue}if(typeof r=="object"){if(typeof n=="number"||!(n in r))return;r=r[n];continue}return}return r}function so(e,t){let r=e;for(let n of t){if(r==null)return;r=r[n]}return r}function Xt(e,t,r){if(t.length===0)return r;let[n,...i]=t;if(typeof n=="number"){let o=Array.isArray(e)?[...e]:[];return o[n]=Xt(o[n],i,r),o}return{...e&&typeof e=="object"?e:{},[n]:Xt((e||{})[n],i,r)}}function Xe(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[r,n]of Object.entries(e))t[r]=Xe(n);return t}return""}function ut(e,t,{ignoreActiveValue:r=!0}={}){Ht.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:r,restoreFocus:!0,formStateSync:"property"})}function mt(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[-_]/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}var ao='<div class="hcms-drag-handle mirk-sortable__grip" aria-hidden="true"><div class="mirk-sortable__dots"><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span></div></div>',Qt='<svg class="hcms-x" viewBox="0 0 16 16" shape-rendering="crispEdges" aria-hidden="true"><path d="M4 4 L12 12 M12 4 L4 12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square"></path></svg>',sn={"@scalar":`
1
+ var hypercms=(()=>{var Dt=Object.defineProperty;var ai=Object.getOwnPropertyDescriptor;var li=Object.getOwnPropertyNames;var ci=Object.prototype.hasOwnProperty;var $t=(e,t)=>{for(var r in t)Dt(e,r,{get:t[r],enumerable:!0})},di=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of li(t))!ci.call(e,i)&&i!==r&&Dt(e,i,{get:()=>t[i],enumerable:!(n=ai(t,i))||n.enumerable});return e};var ui=e=>di(Dt({},"__esModule",{value:!0}),e);var Ys={};$t(Ys,{cms:()=>Gs,default:()=>Js});function Z(e){let t=0,r=null,n=-1;for(let i=0;i<e.length;i++){let o=e[i];o==="\\"?i++:r?o===r&&(r=null):o==='"'||o==="'"?r=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(n=i)}return n}function it(e){let t=Z(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}var Lr={includeClasses:!0,includeAttributes:["href","src","name","type","role","aria-label","alt","title"],excludeAttributePrefixes:["data-morph-","data-hyper-","data-im-"],textHintLength:64,excludeIds:!0,maxPathDepth:4,landmarks:["HEADER","NAV","MAIN","ASIDE","FOOTER","SECTION","ARTICLE"],weights:{signature:100,pathSegment:10,textMatch:20,textMismatch:25,uniqueCandidate:50,positionPenalty:1,maxDriftPenalty:19,slotMatch:30},minConfidence:101,maxScoredCandidates:16};function hi(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t^e.charCodeAt(r);return Math.abs(t).toString(36)}function pi(e){if(e.classList&&e.classList.length>0)return Array.from(e.classList).sort().join(" ");let t=e.getAttribute?.("class");return t?t.split(/\s+/).filter(Boolean).sort().join(" "):""}function fi(e,t){let r=[];for(let n of e.attributes||[]){let i=n.name;i==="id"||i==="class"||t.excludeAttributePrefixes.some(o=>i.startsWith(o))||t.includeAttributes.includes(i)&&r.push(`${i}=${n.value}`)}return r.sort().join("|")}function gi(e,t){return(e.textContent||"").replace(/\s+/g," ").trim().slice(0,t.textHintLength)}function bi(e,t){let r=[e.tagName];return t.includeClasses&&r.push(pi(e)),r.push(fi(e,t)),hi(r.join("|"))}function ki(e){let t=e.tagName,r=1,n=e.previousElementSibling;for(;n;)n.tagName===t&&r++,n=n.previousElementSibling;return r}function yi(e,t){return e.getAttribute?.("id")||e.getAttribute?.("role")?!0:t.landmarks.includes(e.tagName)}function vi(e){let t=e.getAttribute?.("id");if(t)return`#${t}`;let r=e.getAttribute?.("role");return r?`@${r}`:e.tagName}function xi(e,t){let r=[],n=e;for(;n&&n.tagName&&r.length<t.maxPathDepth;){let i=`${n.tagName}:${ki(n)}`;if(r.unshift(i),n!==e&&yi(n,t)){r.unshift(vi(n));break}n=n.parentElement}return r}function wi(e,t){let r=0,n=e.length-1,i=t.length-1;for(;n>=0&&i>=0&&e[n]===t[i];)r++,n--,i--;return r}function se(e,t,r){if(r.has(e))return r.get(e);let n={signature:bi(e,t),path:xi(e,t),textHint:gi(e,t)};return r.set(e,n),n}function Dr(e,t,r,n){if(n.has(e))return n.get(e);let i=new Map,o=e.querySelectorAll("*"),s=0;for(let a of o){let l=se(a,t,r);l.domIndex=s++,!t.shouldIgnore?.(a)&&(i.has(l.signature)||i.set(l.signature,[]),i.get(l.signature).push(a))}return n.set(e,i),i}function _i(e,t,r){r.delete(e),t.delete(e);let n=e.querySelectorAll("*");for(let i of n)t.delete(i)}function Pt(e,t,r,n,i){let o=se(e,r,n),s=se(t,r,n),a=r.weights,l={},c=0;if(o.signature!==s.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};c+=a.signature,l.signature=a.signature;let g=wi(o.path,s.path)*a.pathSegment;c+=g,l.path=g;let d=!0;if(o.textHint&&s.textHint?o.textHint===s.textHint?(c+=a.textMatch,l.text=a.textMatch):(c-=a.textMismatch,l.text=-a.textMismatch,d=!1):o.textHint!==s.textHint&&(c-=a.textMismatch,l.text=-a.textMismatch,d=!1),i.candidateCount===1&&d&&(c+=a.uniqueCandidate,l.unique=a.uniqueCandidate),typeof o.domIndex=="number"&&typeof s.domIndex=="number"){let k=Math.abs(o.domIndex-s.domIndex),y=Math.min(k*a.positionPenalty,a.maxDriftPenalty);c-=y,l.drift=-y}return{score:c,breakdown:l}}function jr(e,t,r,n,i){if(r.excludeIds&&e.getAttribute("id"))return null;let o=Dr(t,r,n,i),s=se(e,r,n);if(typeof s.domIndex!="number"){let d=0,k=e.previousElementSibling;for(;k;)d++,k=k.previousElementSibling;s.domIndex=d}let a=o.get(s.signature)||[],l=r.excludeIds?a.filter(d=>!d.getAttribute("id")):a;if(l.length===0)return null;let c=null,u=0,g=null;for(let d of l){let{score:k,breakdown:y}=Pt(e,d,r,n,{candidateCount:l.length});k>u&&(u=k,c=d,g=y)}return u<r.minConfidence?null:{element:c,confidence:u,breakdown:g}}function Ai(e,t,r,n){let i=[],o=r.weights.signature+r.weights.slotMatch,s={slot:o};function a(g){if(g.children)return g.children;let d=g.childNodes;if(!d)return[];let k=[];for(let y=0;y<d.length;y++)d[y].nodeType===1&&k.push(d[y]);return k}function l(g,d){let k=a(g),y=a(d);if(k.length===y.length)for(let N=0;N<k.length;N++){let q=k[N],H=y[N];if(r.shouldIgnore?.(q)||r.shouldIgnore?.(H)||r.excludeIds&&(q.getAttribute("id")||H.getAttribute("id"))||q.tagName!==H.tagName)continue;let oe=se(q,r,n).signature,ee=se(H,r,n).signature;oe!==ee&&i.push({newEl:q,oldEl:H,score:o,breakdown:s}),l(q,H)}}function c(g,d){for(;;){if(g.tagName===d.tagName)return[g,d];let k=a(g);if(!g.tagName&&k.length===1){g=k[0];continue}let y=a(d);if(y.length===1&&y[0].tagName===g.tagName){d=y[0];continue}return null}}let u=c(e,t);return u&&l(u[0],u[1]),i}function Fr(e,t,r,n,i){let o=t.querySelectorAll("*"),s=Dr(e,r,n,i),a=0;for(let k of o){let y=se(k,r,n);y.domIndex=a++}let l=[],c=new Map;function u(k,y,N){let q=new Set;if(k.textHint){let U=c.get(k.signature);if(!U){U=new Map;for(let Q of y){let pe=se(Q,r,n).textHint,fe=U.get(pe);fe||(fe=[],U.set(pe,fe)),fe.push(Q)}c.set(k.signature,U)}let ie=U.get(k.textHint);if(ie)for(let Q=0;Q<ie.length&&Q<N;Q++)q.add(ie[Q])}let H=0,oe=y.length;for(;H<oe;){let U=H+oe>>1;se(y[U],r,n).domIndex<k.domIndex?H=U+1:oe=U}let ee=Math.max(0,Math.min(H-(N>>1),y.length-N)),le=Math.min(ee+N,y.length);for(let U=ee;U<le;U++)q.add(y[U]);return[...q]}for(let k of o){if(r.shouldIgnore?.(k)||r.excludeIds&&k.getAttribute("id"))continue;let y=se(k,r,n),N=s.get(y.signature)||[],q=r.excludeIds?N.filter(ee=>!ee.getAttribute("id")):N,H=r.maxScoredCandidates,oe=H&&q.length>H?u(y,q,H):q;for(let ee of oe){let{score:le,breakdown:U}=Pt(k,ee,r,n,{candidateCount:q.length});le>=r.minConfidence&&l.push({newEl:k,oldEl:ee,score:le,breakdown:U})}}if(r.weights.slotMatch>0){let k=Ai(t,e,r,n);for(let y of k)l.push(y)}l.sort((k,y)=>y.score-k.score);let g=new Map,d=new Set;for(let{newEl:k,oldEl:y}of l)g.has(k)||d.has(y)||(g.set(k,y),d.add(y));return g}function qr(e,t,r,n){let i=se(e,r,n),o=se(t,r,n),{score:s,breakdown:a}=Pt(e,t,r,n,{candidateCount:1});return{matches:s>=r.minConfidence,score:s,breakdown:a,newMeta:{signature:i.signature,path:i.path,textHint:i.textHint},oldMeta:{signature:o.signature,path:o.path,textHint:o.textHint}}}function $r(e={}){let t={...Lr,...e,weights:{...Lr.weights,...e.weights}},r=new WeakMap,n=new WeakMap;return{findMatch:(i,o)=>jr(i,o,t,r,n),computeMatches:(i,o)=>Fr(i,o,t,r,n),explain:(i,o)=>qr(i,o,t,r),invalidate:i=>_i(i,r,n),session:()=>{let i=new WeakMap,o=new WeakMap;return{findMatch:(s,a)=>jr(s,a,t,i,o),computeMatches:(s,a)=>Fr(s,a,t,i,o),explain:(s,a)=>qr(s,a,t,i)}},getConfig:()=>({...t})}}function Bt(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
2
+ `;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let r=e.indexOf("*/",t+2);if(r===-1)return e.length;t=r+2;continue}return t}}function Pr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,r)=>r.length%2===0?r+'\\"':t)}var Si=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Ei=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ot(e){try{return JSON.parse(e)}catch{return JSON.parse(Ci(e))}}function Ci(e){let t="",r=0,n=(i,o)=>{throw new Error(`Invalid relaxed JSON: ${i} at position ${o}`)};for(;r<e.length&&(r=Bt(e,r),!(r>=e.length));){let i=e[r];if("{}[]:".includes(i)){t+=i,r++;continue}if(i===","){let a=Bt(e,r+1);if(e[a]==="}"||e[a]==="]"){r++;continue}t+=i,r++;continue}if(i==='"'||i==="'"){let a=r+1;for(;a<e.length&&e[a]!==i;)e[a]==="\\"&&a++,a++;a>=e.length&&n("unterminated string",r);let l=e.slice(r+1,a);i==="'"&&(l=Pr(l)),t+='"'+l+'"',r=a+1;continue}let o=r;for(;o<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[o]);)o++;o===r&&n("unexpected character "+JSON.stringify(i),r);let s=e.slice(r,o);if(s==="true"||s==="false"||s==="null"||Si.test(s)){t+=s,r=o;continue}if(Ei.test(s)){if(e[Bt(e,o)]===":"){t+='"'+s+'"',r=o;continue}n("unquoted value "+JSON.stringify(s),r)}n("invalid token "+JSON.stringify(s),r)}return t}function Br(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(i){let o=[],s=0;for(;s<i.length;){let a=i[s];if(/\s/.test(a)){s++;continue}if("{}".includes(a)){o.push({type:a,value:a}),s++;continue}if(a==="["){let g=!1,d=s+1;for(;d<i.length&&/\s/.test(i[d]);)d++;if(d<i.length&&/[a-zA-Z_]/.test(i[d])&&(g=!0),!g){o.push({type:a,value:a}),s++;continue}}if(a==="]"){o.push({type:a,value:a}),s++;continue}if(a===":"){o.push({type:t.COLON,value:a}),s++;continue}if(a===","){o.push({type:t.COMMA,value:a}),s++;continue}if(a==='"'||a==="'"){let g=a,d=s+1;for(;d<i.length&&i[d]!==g;)i[d]==="\\"&&d++,d++;o.push({type:t.STRING,value:i.substring(s+1,d),quoted:!0,sourceQuote:g}),s=d+1;continue}let l=s,c;for(;l<i.length&&!/[{},]/.test(i[l]);)if(i[l]===":"){let g=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let k of g){let y=k.substring(1);if(i.substring(l+1,l+1+y.length)===y){d=!0,l+=y.length;break}}if(!d)break}else if(i[l]==="["){for(l++;l<i.length&&i[l]!=="]";){if(i[l]==='"'||i[l]==="'"){let g=i[l];for(l++;l<i.length&&i[l]!==g;)i[l]==="\\"&&l++,l++}l++}l<i.length&&i[l]==="]"&&l++}else l++;c=i.substring(s,l);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?u=t.NUMBER:c==="true"||c==="false"||c==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(u=t.SELECTOR),o.push({type:u,value:c,quoted:!1}),s=l}return o}function n(i){let o="";for(let s=0;s<i.length;s++){let a=i[s];if("{}".includes(a.type)||"[]".includes(a.type)){o+=a.value;continue}if(a.type===t.COLON){o+=a.value;continue}if(a.type===t.COMMA){let l=i[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;o+=a.value;continue}if(a.type===t.STRING){let l=a.value;a.sourceQuote==="'"&&(l=Pr(l)),o+=`"${l}"`;continue}if(a.type===t.NUMBER||a.type===t.BOOLEAN){o+=a.value;continue}o+=`"${a.value}"`}return o}try{let i=r(e),o=n(i);return JSON.parse(o)}catch(i){throw new Error("Invalid extraction rules syntax: "+i.message)}}var J=Symbol("hyper-morph-json-merge:missing"),Ur=["id","_id","uuid","key","slug","code","name"];function Ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function He(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ti(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0})}function be(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!be(e[r],t[r]))return!1;return!0}if(Ce(e)&&Ce(t)){let r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n of r)if(!He(t,n)||!be(e[n],t[n]))return!1;return!0}return!1}function zr(e,t,r,n){return be(t,r)?t:be(t,e)?r:be(r,e)?t:Ce(t)&&Ce(r)?Ri(Ce(e)?e:{},t,r,n):Array.isArray(t)&&Array.isArray(r)?Ii(Array.isArray(e)?e:[],t,r,n):r}function Hr(e,t,r,n){return t===J&&r===J?J:t===J?e===J?r:be(r,e)?J:r:r===J?e===J?t:J:zr(e,t,r,n)}function Ri(e,t,r,n){let i={},o=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(r)]);for(let s of o){let a=Hr(He(e,s)?e[s]:J,He(t,s)?t[s]:J,He(r,s)?r[s]:J,n);a!==J&&Ti(i,s,a)}return i}function Oi(e){return e===null||typeof e!="object"}function st(e){return typeof e+":"+String(e)}function Mi(e,t){for(let r of t){let n=new Set;for(let i of r){if(!He(i,e))return!1;let o=i[e];if(typeof o!="string"&&typeof o!="number")return!1;let s=st(o);if(n.has(s))return!1;n.add(s)}}return!0}function Ni(e,t,r,n){let i=[e,t,r],o=!0;for(let s of i)for(let a of s)Ce(a)||(o=!1);if(o){for(let s of n.keyCandidates)if(Mi(s,i))return{kind:"keyed",field:s};return null}for(let s of i){let a=new Set;for(let l of s){if(!Oi(l))return null;let c=st(l);if(a.has(c))return null;a.add(c)}}return{kind:"self"}}function Ii(e,t,r,n){let i=Ni(e,t,r,n);if(!i)return r;let o=i.kind==="self"?st:k=>st(k[i.field]),s=k=>{let y=new Map;for(let N of k)y.set(o(N),N);return y},a=s(e),l=s(t),c=s(r),u=new Map,g=new Set([...a.keys(),...l.keys(),...c.keys()]);for(let k of g){let y=Hr(a.has(k)?a.get(k):J,l.has(k)?l.get(k):J,c.has(k)?c.get(k):J,n);y!==J&&u.set(k,y)}let d=[];for(let k of r){let y=o(k);u.has(y)&&d.push(y)}for(let k=0;k<t.length;k++){let y=o(t[k]);if(!u.has(y)||d.includes(y))continue;let N=0;for(let q=k-1;q>=0;q--){let H=d.indexOf(o(t[q]));if(H!==-1){N=H+1;break}}d.splice(N,0,y)}return d.map(k=>u.get(k))}function Ut(e,t,r,n={}){let i=n.keyCandidates?[...n.keyCandidates,...Ur]:Ur;return zr(e===void 0?J:e,t,r,{keyCandidates:i})}function zt(e,t,r,n={}){let i=n.parse||ot,o=[],s=(g,d)=>{if(typeof g!="string")return J;try{return i(g)}catch(k){return o.push(`${d} side is not valid JSON (${k.message})`),J}},a=s(t,"local"),l=s(r,"remote");if(a===J)return{text:r,warnings:o};if(l===J)return{text:t,warnings:o};let c=s(e,"base"),u=Ut(c===J?void 0:c,a,l,n);return be(u,l)?{text:r,warnings:o}:be(u,a)?{text:t,warnings:o}:{text:JSON.stringify(u,null,2),warnings:o}}var Ve=(function(){"use strict";let e=()=>{},t='[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]';function r(p){if(!(p instanceof Element))return!1;if(p.matches(t))return!0;if(p.tagName==="LINK"||p.tagName==="SCRIPT"){let T=p.getAttribute("src")||p.getAttribute("href")||"";if(T.startsWith("chrome-extension://")||T.startsWith("moz-extension://")||T.startsWith("safari-web-extension://"))return!0}return!1}function n(p){return p instanceof Element?p.closest(t)?!0:r(p):!1}let i=$r({shouldIgnore:n});function o(p,T,E){if(E){let O=E.identityOf(p);if(O&&!E.disabled.has(O.key))return"hm-merge:"+O.key}if(T!=="smart")return p.outerHTML;let R=p.getAttribute("src"),C=p.getAttribute("type")||"text/javascript";if(R)try{let O=new URL(R,window.location.href);return`ext:${C}:${O.origin}${O.pathname}${O.search}`}catch{return`ext:${C}:${R}`}else{let O=p.textContent.trim(),v=5381;for(let A=0;A<O.length;A++)v=(v<<5)+v^O.charCodeAt(A);return`inline:${C}:${Math.abs(v).toString(36)}`}}let s="http://www.w3.org/1999/xhtml";function a(p){return p instanceof Element&&p.tagName==="SCRIPT"&&p.namespaceURI===s}function l(p){let T=document.createElement("div");T.innerHTML="<script><\/script>";let E=T.firstChild;for(let R of p.attributes)E.setAttribute(R.name,R.value);return E.textContent=p.textContent,E}function c(p){if(a(p))return l(p);if(p instanceof Element)for(let T of p.querySelectorAll("script"))a(T)&&T.replaceWith(l(T));return p}function u(p){let T=(p.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return T==="application/json"||T.endsWith("+json")}let g={match:p=>p.hasAttribute("merge"),identity:p=>p.getAttribute("merge")};function d(p,T,E){if(E.merge===!1)return null;let R=[g,...E.mergeTags||[]],C=new WeakMap,O=f=>{if(C.has(f))return C.get(f);let w=null;if(a(f)&&!f.getAttribute("src")&&!n(f)){let _=f;for(let I=0;I<R.length;I++)if(R[I].match(_)){if(!u(_))console.warn("[hyper-morph] merge ignored: script type is not JSON",_);else{let P=R[I].identity(_);P!=null&&P!==""&&(w={key:I+":"+P,raw:P,recognizer:R[I]})}break}}return C.set(f,w),w},v=new Set,A=f=>{let w=new Map,_=I=>{let P=O(I);P&&(w.has(P.key)?(v.add(P.key),console.warn(`[hyper-morph] merge disabled for duplicate identity "${P.raw}"`)):w.set(P.key,I))};a(f)&&_(f);for(let I of f.querySelectorAll("script"))_(I);return w},b=A(p),h=A(T.__hyperMorphRoot||T);if(b.size===0&&h.size===0)return null;let m=null;return{identityOf:O,disabled:v,oldByKey:b,newByKey:h,baseTexts:()=>{if(m)return m;m=new Map;let f=E.mergeBase;if(!f)return m;let w;typeof f=="string"?w=new DOMParser().parseFromString(f,"text/html").documentElement:f instanceof Document?w=f.documentElement:w=f;let _=I=>{let P=O(I);P&&!m.has(P.key)&&m.set(P.key,I.textContent)};a(w)&&_(w);for(let I of w.querySelectorAll("script"))_(I);return m}}}function k(p,T,E){let R=p.merge;if(!R)return!1;let C=R.identityOf(T);if(!C||R.disabled.has(C.key))return!1;let O=R.identityOf(E);if(!O||O.key!==C.key)return!1;let v=T,A=E,b=A.getAttribute("merge-key")||v.getAttribute("merge-key"),{text:h,warnings:m}=zt(R.baseTexts().get(C.key),v.textContent,A.textContent,{parse:C.recognizer.parse,keyCandidates:b?b.split(/[\s,]+/).filter(Boolean):void 0});for(let x of m)console.warn(`[hyper-morph] merge "${C.raw}": ${x}`);return v.textContent!==h&&(v.textContent=h),!0}let y={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:p=>p.getAttribute("im-preserve")==="true",shouldReAppend:p=>p.getAttribute("im-re-append")==="true",shouldRemove:e,afterHeadMorphed:e},scripts:{handle:!0,matchMode:"outerHTML",shouldPreserve:p=>p.getAttribute("im-preserve")==="true",shouldReAppend:p=>p.getAttribute("im-re-append")==="true",shouldRemove:e,afterScriptsHandled:e},restoreFocus:!0},N={computeMatches(p,T){let{computeMatches:E}=i.session();return E(p,T)}};function q(p,T,E={}){p=ii(p);let R=_r(T),C=ni(p,R,E),O=C.scripts.handle?new Set(Array.from(p.querySelectorAll("script")).map(h=>o(h,C.scripts.matchMode,C.merge))):null,v=ee(C),A=Q(C,p,R,h=>h.morphStyle==="innerHTML"?(U(h,p,R),Array.from(p.childNodes)):oe(h,p,R)),b=h=>{v&&le(C,v),H(C);let m=O?Lt(h,O,C):[];return m.length>0?Promise.all(m).then(()=>h):h};return A instanceof Promise?A.then(b):b(A)}function H(p){for(let T of Array.from(p.pantry.childNodes))p.callbacks.beforeNodeRemoved(T)!==!1&&p.callbacks.afterNodeRemoved(T);p.pantry.remove()}function oe(p,T,E){let R=_r(T);return U(p,R,E,T,T.nextSibling),Array.from(R.childNodes)}function ee(p){if(!p.config.restoreFocus)return null;let T=document.activeElement;if(!(T instanceof HTMLInputElement||T instanceof HTMLTextAreaElement))return null;let{id:E,selectionStart:R,selectionEnd:C}=T;return{element:T,id:E,selectionStart:R,selectionEnd:C}}function le(p,T){let E=T.element;if(T.id&&T.id!==document.activeElement?.getAttribute("id")&&(E=p.target.querySelector(`[id="${CSS.escape(T.id)}"]`),E?.focus()),E&&!E.selectionEnd&&T.selectionEnd!=null)try{E.setSelectionRange(T.selectionStart,T.selectionEnd)}catch{}}let U=(function(){function p(h,m,x,f=null,w=null){m instanceof HTMLTemplateElement&&x instanceof HTMLTemplateElement&&(m=m.content,x=x.content),f||=m.firstChild;for(let _ of x.childNodes){if(r(_))continue;if(f&&f!=w){let P=E(h,_,f,w);if(P){P!==f&&C(h,f,P),ie(P,_,h),f=P.nextSibling;continue}}if(_ instanceof Element){let P=_.getAttribute("id");if(h.persistentIds.has(P)){let S=O(m,P,f,h);ie(S,_,h),f=S.nextSibling;continue}if(!h.idMap.has(_)){let S=h.hyperMatches.get(_);if(S&&!h.idMap.has(S)&&!b(S,m)){A(m,S,f),ie(S,_,h),f=S.nextSibling;continue}}}let I=T(m,_,f,h);I&&(f=I.nextSibling)}for(;f&&f!=w;){let _=f;f=f.nextSibling,r(_)||R(h,_)}}function T(h,m,x,f){if(f.callbacks.beforeNodeAdded(m)===!1)return null;if(f.idMap.has(m)){let w=m,_=document.createElementNS(w.namespaceURI,w.localName);return h.insertBefore(_,x),ie(_,m,f),f.callbacks.afterNodeAdded(_),_}else{let w=c(document.importNode(m,!0));return h.insertBefore(w,x),f.callbacks.afterNodeAdded(w),w}}let E=(function(){function h(f,w,_,I){let P=w instanceof Element&&!f.idMap.has(w)?f.hyperMatches.get(w):null,S=null,M=w.nextSibling,V=0,D=_;for(;D&&D!=I;){if(r(D)){D=D.nextSibling;continue}if(x(D,w)){if(m(f,D,w)||D===P&&!f.idMap.has(D))return D;if(S===null){let W=D instanceof Element&&f.hyperMatchedOldElements.has(D);!f.idMap.has(D)&&!W&&(S=D)}}if(S===null&&M&&x(D,M)&&(V++,M=M.nextSibling,V>=2&&(S=void 0)),f.activeElementAndParents.includes(D))break;D=D.nextSibling}return S||null}function m(f,w,_){let I=f.idMap.get(w),P=f.idMap.get(_);if(!P||!I)return!1;for(let S of I)if(P.has(S))return!0;return!1}function x(f,w){let _=f,I=w;return _.nodeType===I.nodeType&&_.tagName===I.tagName&&(!_.getAttribute?.("id")||_.getAttribute?.("id")===I.getAttribute?.("id"))}return h})();function R(h,m){let x=m instanceof Element&&h.hyperMatchedOldElements.has(m)&&!h.idMap.has(m);if(h.idMap.has(m)||x)A(h.pantry,m,null);else{if(h.callbacks.beforeNodeRemoved(m)===!1)return;m.parentNode?.removeChild(m),h.callbacks.afterNodeRemoved(m)}}function C(h,m,x){let f=m;for(;f&&f!==x;){let w=f;f=f.nextSibling,r(w)||R(h,w)}return f}function O(h,m,x,f){let w=f.target.getAttribute?.("id")===m&&f.target||f.target.querySelector(`[id="${CSS.escape(m)}"]`)||f.pantry.querySelector(`[id="${CSS.escape(m)}"]`);return v(w,f),A(h,w,x),w}function v(h,m){let x=h.getAttribute("id");for(;h=h.parentNode;){let f=m.idMap.get(h);f&&(f.delete(x),f.size||m.idMap.delete(h))}}function A(h,m,x){if(h.moveBefore)try{h.moveBefore(m,x)}catch{h.insertBefore(m,x)}else h.insertBefore(m,x)}function b(h,m){let x=m instanceof Element?m:m.realParentNode;return!!x&&h.contains(x)}return p})(),ie=(function(){function p(v,A,b){return b.ignoreActive&&v===document.activeElement?null:(b.callbacks.beforeNodeMorphed(v,A)===!1||(v instanceof HTMLHeadElement&&b.head.ignore||(v instanceof HTMLHeadElement&&b.head.style!=="morph"?fe(v,A,b):(T(v,A,b),k(b,v,A)||O(v,b)||U(b,v,A))),b.callbacks.afterNodeMorphed(v,A)),v)}function T(v,A,b){let h=A.nodeType;if(h===1){let m=v,x=A,f=m.attributes,w=x.attributes;for(let _ of w)C(_.name,m,"update",b)||m.getAttribute(_.name)!==_.value&&m.setAttribute(_.name,_.value);for(let _=f.length-1;0<=_;_--){let I=f[_];if(I&&!x.hasAttribute(I.name)){if(C(I.name,m,"remove",b))continue;m.removeAttribute(I.name)}}O(m,b)||E(m,x,b)}(h===8||h===3)&&v.nodeValue!==A.nodeValue&&(v.nodeValue=A.nodeValue)}function E(v,A,b){if(v instanceof HTMLInputElement&&A instanceof HTMLInputElement&&A.type!=="file"){let h=A.value,m=v.value;R(v,A,"checked",b),R(v,A,"disabled",b),b.formStateSync==="property"&&v.indeterminate!==A.indeterminate&&(v.indeterminate=A.indeterminate),b.formStateSync==="property"?m!==h&&(C("value",v,"update",b)||(v.value=h)):A.hasAttribute("value")?m!==h&&(C("value",v,"update",b)||(v.setAttribute("value",h),v.value=h)):C("value",v,"remove",b)||(v.value="",v.removeAttribute("value"))}else if(v instanceof HTMLOptionElement&&A instanceof HTMLOptionElement)R(v,A,"selected",b);else if(v instanceof HTMLTextAreaElement&&A instanceof HTMLTextAreaElement){let h=A.value,m=v.value;if(C("value",v,"update",b)||(h!==m&&(v.value=h),b.formStateSync==="property"))return;v.firstChild&&v.firstChild.nodeValue!==h&&(v.firstChild.nodeValue=h)}}function R(v,A,b,h){let m=A[b],x=v[b];if(m!==x){let f=C(b,v,"update",h);if(f||(v[b]=A[b]),h.formStateSync==="property")return;m?f||v.setAttribute(b,""):C(b,v,"remove",h)||v.removeAttribute(b)}}function C(v,A,b,h){return v==="value"&&h.ignoreActiveValue&&A===document.activeElement?!0:h.callbacks.beforeAttributeUpdated(v,A,b)===!1}function O(v,A){return!!A.ignoreActiveValue&&v===document.activeElement&&v!==document.body}return p})();function Q(p,T,E,R){if(p.head.block){let C=T.querySelector("head"),O=E.querySelector("head");if(C&&O){let v=fe(C,O,p);return Promise.all(v).then(()=>(p.head.block=!1,p.head.ignore=!0,R(p)))}}return R(p)}function pe(p){return p.tagName==="SCRIPT"?!!p.getAttribute("src"):p.tagName==="LINK"?(p.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet")&&!!p.getAttribute("href"):!1}function fe(p,T,E){let R=[],C=[],O=[],v=[],A=E.scripts.matchMode,b=x=>{if(x.tagName==="SCRIPT")return o(x,A,E.merge);if(x.tagName==="LINK"&&A==="smart"){let f=x.getAttribute("href");if(f)try{let w=new URL(f,window.location.href);return`link:${x.getAttribute("rel")||""}:${w.origin}${w.pathname}${w.search}`}catch{}}return x.outerHTML},h=new Map;for(let x of T.children){if(r(x))continue;let f=b(x),w=h.get(f);w||(w=[],h.set(f,w)),w.push(x)}for(let x of p.children){let f=b(x),w=h.get(f),_=!!(w&&w.length),I=E.head.shouldReAppend(x),P=E.head.shouldPreserve(x);if(_||P)if(I)C.push(x);else{if(w&&w.length){let S=w.pop();w.length||h.delete(f),k(E,x,S)}O.push(x)}else E.head.style==="append"?I&&(C.push(x),v.push(x)):E.head.shouldRemove(x)!==!1&&!r(x)&&C.push(x)}for(let x of h.values())v.push(...x);let m=[];for(let x of v){let f=document.createRange().createContextualFragment(x.outerHTML).firstChild;if(E.callbacks.beforeNodeAdded(f)!==!1){if(f instanceof Element&&pe(f)){let w,_=new Promise(function(I){w=I});f.addEventListener("load",function(){w()}),f.addEventListener("error",function(){w()}),m.push(_)}p.appendChild(f),E.callbacks.afterNodeAdded(f),R.push(f)}}for(let x of C)E.callbacks.beforeNodeRemoved(x)!==!1&&(p.removeChild(x),E.callbacks.afterNodeRemoved(x));return E.head.afterHeadMorphed(p,{added:R,kept:O,removed:C}),m}function Lt(p,T,E){if(!E.scripts.handle)return[];let R=[],C=[],O=[],v=[],A=E.scripts.matchMode,b=[];for(let m of p)if(m instanceof Element){a(m)&&b.push(m);for(let x of m.querySelectorAll("script"))a(x)&&b.push(x)}for(let m of b){if(m.closest("head")||n(m))continue;let x=o(m,A,E.merge),f=T.has(x),w=E.scripts.shouldPreserve(m),_=E.scripts.shouldReAppend(m);f||w?_?(C.push(m),v.push(m)):O.push(m):v.push(m)}let h=[];for(let m of v){if(E.callbacks.beforeNodeAdded(m)===!1)continue;let x=document.createElement("script");for(let f of m.attributes)x.setAttribute(f.name,f.value);if(x.textContent=m.textContent,x.src){let f,w=new Promise(function(_){f=_});x.addEventListener("load",function(){f()}),x.addEventListener("error",function(){f()}),h.push(w)}m.replaceWith(x),E.callbacks.afterNodeAdded(x),R.push(x)}return E.scripts.afterScriptsHandled(E.target,{added:R,kept:O,removed:C}),h}let ni=(function(){function p(b,h,m){let{persistentIds:x,idMap:f}=v(b,h),w=N.computeMatches(b,h);if(typeof m.key=="function"){let M=new Map,V=new Set,D=F=>{let L=m.key(F);L!=null&&(M.has(L)?V.add(L):M.set(L,F))};b instanceof Element&&D(b);for(let F of b.querySelectorAll("*"))D(F);for(let F of V)M.delete(F);let W=new Map;for(let[F,L]of w)W.set(L,F);let te=h.__hyperMorphRoot||h,X=new Map,G=new Set,j=F=>{let L=m.key(F);L!=null&&(X.has(L)?G.add(L):X.set(L,F))};te instanceof Element&&j(te);for(let F of te.querySelectorAll("*"))j(F);for(let F of G)X.delete(F);for(let[F,L]of X){let z=M.get(F);if(!z||z.tagName!==L.tagName)continue;let K=W.get(z);K&&K!==L&&w.delete(K);let xe=w.get(L);xe&&xe!==z&&W.delete(xe),w.set(L,z),W.set(z,L)}}let _=T(m),I=d(b,h,_.scripts);if(I){let M=new Map;for(let[V,D]of w)M.set(D,V);for(let[V,D]of I.newByKey){if(I.disabled.has(V))continue;let W=I.oldByKey.get(V);if(!W)continue;let te=M.get(W);te&&te!==D&&w.delete(te);let X=w.get(D);X&&X!==W&&M.delete(X),w.set(D,W),M.set(W,D)}}let P=new Set;for(let M of w.values())P.add(M);let S=_.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(S))throw new Error(`Do not understand how to morph style ${S}`);return{target:b,newContent:h,config:_,morphStyle:S,ignoreActive:_.ignoreActive,ignoreActiveValue:_.ignoreActiveValue,restoreFocus:_.restoreFocus,formStateSync:_.formStateSync||"attribute",idMap:f,persistentIds:x,hyperMatches:w,hyperMatchedOldElements:P,merge:I,pantry:E(),activeElementAndParents:R(b),callbacks:_.callbacks,head:_.head,scripts:_.scripts}}function T(b){let h=Object.assign({},y);return Object.assign(h,b),h.callbacks=Object.assign({},y.callbacks,b.callbacks),h.head=Object.assign({},y.head,b.head),h.scripts=Object.assign({},y.scripts,b.scripts),h}function E(){let b=document.createElement("div");return b.hidden=!0,document.body.insertAdjacentElement("afterend",b),b}function R(b){let h=[],m=document.activeElement;if(m?.tagName!=="BODY"&&b.contains(m))for(;m&&(h.push(m),m!==b);)m=m.parentElement;return h}function C(b){let h=Array.from(b.querySelectorAll("[id]"));return b.getAttribute?.("id")&&h.push(b),h}function O(b,h,m,x){for(let f of x){let w=f.getAttribute("id");if(h.has(w)){let _=f;for(;_;){let I=b.get(_);if(I==null&&(I=new Set,b.set(_,I)),I.add(w),_===m)break;_=_.parentElement}}}}function v(b,h){let m=C(b),x=C(h),f=A(m,x),w=new Map;O(w,f,b,m);let _=h.__hyperMorphRoot||h;return O(w,f,_,x),{persistentIds:f,idMap:w}}function A(b,h){let m=new Set,x=new Map;for(let w of b){let _=w.getAttribute("id");x.has(_)?m.add(_):x.set(_,w.tagName)}let f=new Set;for(let w of h){let _=w.getAttribute("id");f.has(_)?m.add(_):x.get(_)===w.tagName&&f.add(_)}for(let w of m)f.delete(w);return f}return p})(),{normalizeElement:ii,normalizeParent:_r}=(function(){let p=new WeakSet;function T(v){return v instanceof Document?v.documentElement:v}function E(v){if(v==null)return document.createElement("div");if(typeof v=="string")return E(O(v));if(p.has(v))return v;if(v instanceof Node){if(v.parentNode)return new R(v);{let A=document.createElement("div");return A.append(v),A}}else{let A=document.createElement("div");for(let b of[...v])A.append(b);return A}}class R{constructor(A){this.originalNode=A,this.realParentNode=A.parentNode,this.previousSibling=A.previousSibling,this.nextSibling=A.nextSibling}get childNodes(){let A=[],b=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;b&&b!=this.nextSibling;)A.push(b),b=b.nextSibling;return A}querySelectorAll(A){return this.childNodes.reduce((b,h)=>{if(h instanceof Element){h.matches(A)&&b.push(h);let m=h.querySelectorAll(A);for(let x=0;x<m.length;x++)b.push(m[x])}return b},[])}insertBefore(A,b){return this.realParentNode.insertBefore(A,b)}moveBefore(A,b){return this.realParentNode.moveBefore(A,b)}get __hyperMorphRoot(){return this.originalNode}}function C(v){let A=x=>`<${x}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,b=v.replace(/<!--[\s\S]*?-->/g,"");for(let x of["script","style","textarea","title"])b=b.replace(new RegExp(`${A(x)}[\\s\\S]*?</${x}\\s*>`,"gi"),"");let h=new RegExp(`${A("svg")}[\\s\\S]*?</svg\\s*>`,"gi"),m;do m=b,b=b.replace(h,"");while(b!==m);return b}function O(v){let A=new DOMParser,b=C(v);if(b.match(/<\/html>/)||b.match(/<\/head>/)||b.match(/<\/body>/)){let h=A.parseFromString(v,"text/html");if(b.match(/<\/html>/))return p.add(h),h;{let m=h.firstChild;return m&&p.add(m),m}}else{let m=A.parseFromString("<body><template>"+v+"</template></body>","text/html").body.querySelector("template").content;return p.add(m),m}}return{normalizeElement:T,normalizeParent:E}})(),Ar=Symbol("hyper-morph-duplicate-key"),Sr=[p=>p.getAttribute("data-id"),p=>p.getAttribute("id")];function Ue(p,T){return T.map(E=>{let R=new Map;for(let C of p){if(C.nodeType!==1)continue;let O=E(C);O==null||O===""||R.set(O,R.has(O)?Ar:C)}return R})}function Er(p,T,E,R){for(let C=0;C<R.length;C++){let O=R[C](p);if(O==null||O===""||T[C].get(O)!==p)continue;let v=E[C].get(O);if(!(!v||v===Ar)&&v.tagName===p.tagName)return v}return null}function Se(p,T,E){for(let R=0;R<E.length;R++){let C=E[R](p);if(!(C==null||C==="")&&T[R].get(C)===p)return!0}return!1}function oi(p,T,E={}){let R=E.skip||(()=>!1),C=E.ignoreAttr||(()=>!1),O=E.tiers&&E.tiers.length?E.tiers:Sr,v=null;function A(){return v||(v=Ue([p,...p.querySelectorAll("*")],O)),v}let b=null;function h(){return b||(b=Ue([T,...T.querySelectorAll("*")],O)),b}function m(j){return!j.parentElement||!j.parentElement.parentElement}function x(j,F,L){return m(j)||Se(j,A(),O)?(L.push({type:"subtree",el:j,base:F}),!1):!0}function f(j,F){let L=[];for(let z of j.attributes)C(j,z.name)||F.getAttribute(z.name)!==z.value&&L.push(z.name);for(let z of F.attributes)C(j,z.name)||j.hasAttribute(z.name)||L.push(z.name);return L}function w(j){let F=[],L=null,z=()=>{L!==null&&(F.push({nodeType:3,nodeValue:L}),L=null)};for(let K of j.childNodes){if(K.nodeType===3){L=(L===null?"":L)+K.nodeValue;continue}K.nodeType===1&&R(K)||(z(),(K.nodeType===1||K.nodeType===8)&&F.push(K))}return z(),F}function _(j,F){if(j.nodeType!==F.nodeType)return!1;if(j.nodeType!==1)return!0;if(j.tagName!==F.tagName)return!1;for(let L of O){let z=L(j),K=L(F);if(z!=null&&z!==""&&K!=null&&K!==""&&z!==K)return!1}return!0}function I(j){let F="";for(let L of j)L.nodeType===3&&L.nodeValue.trim()!==""?F+="\0"+L.nodeValue:L.nodeType===8&&(F+=""+L.nodeValue);return F}function P(j,F,L){let z=w(j),K=w(F);if(z.length===K.length){let $=!0;for(let Y=0;Y<z.length;Y++)if(!_(z[Y],K[Y])){$=!1;break}if($){for(let Y=0;Y<z.length;Y++){let Ee=z[Y];if(Ee.nodeType===1){if(S(Ee,K[Y],L))return!0}else if(Ee.nodeValue!==K[Y].nodeValue)return!0}return!1}}let xe=z.filter($=>$.nodeType===1),jt=K.filter($=>$.nodeType===1);if(I(z)!==I(K))return!0;let Cr=Ue(xe,O),Tr=Ue(jt,O),Ft=[],qt=new Set,Rr=[];for(let $ of xe){let Y=Er($,Cr,Tr,O);Y&&!qt.has(Y)?(Ft.push([$,Y]),qt.add(Y)):Rr.push($)}let ge=[];for(let $ of Rr)Se($,Cr,O)?L.push({type:"subtree",el:$,base:null}):ge.push($);let ze=[];for(let $ of jt)qt.has($)||(Se($,Tr,O)?L.push({type:"deletion",el:$}):ze.push($));if(ge.length!==ze.length)return!0;for(let $=0;$<ge.length;$++)if(!_(ge[$],ze[$]))return!0;let Or=new Map(Ft);for(let $=0;$<ge.length;$++)Or.set(ge[$],ze[$]);let Mr=-1;for(let $ of xe){let Y=Or.get($);if(!Y)continue;let Ee=jt.indexOf(Y);if(Ee<Mr)return!0;Mr=Ee}for(let $=0;$<ge.length;$++)if(S(ge[$],ze[$],L))return!0;for(let[$,Y]of Ft)if(S($,Y,L))return!0;return!1}function S(j,F,L){if(j.tagName!==F.tagName)return x(j,F,L);let z=f(j,F),K=[];if(P(j,F,K))return x(j,F,L);if(z.length){if(!m(j)&&!Se(F,h(),O))return!0;L.push({type:"attrs",el:j,names:z,base:F})}return L.push(...K),!1}let M=[],V=f(p,T);V.length&&M.push({type:"attrs",el:p,names:V});let D=(j,F)=>Array.from(j.children).find(L=>L.tagName===F)||null,W=D(p,"HEAD"),te=D(T,"HEAD");if(W&&te){let j=[];S(W,te,j),j.length&&M.push({type:"head",el:W})}else(W||te)&&W&&M.push({type:"head",el:W});let X=D(p,"BODY"),G=D(T,"BODY");return X&&G?S(X,G,M):X&&M.push({type:"subtree",el:X,base:null}),{entries:M}}function si(p,T,E={}){let R=E.tiers&&E.tiers.length?E.tiers:Sr,C=p.documentElement,O=[],v=0,A=S=>({ok:!1,placed:O,held:S,skippedAttrs:v});if(!C)return A(null);function b(S){let M=[S,...S.querySelectorAll("*")];return Ue(M,R)}let h=b(C),m=new Map,x=S=>{let M=S.getRootNode(),V=m.get(M);if(!V){let D=M.nodeType===9?M.documentElement:M;V=b(D),m.set(M,V)}return V};function f(S){if(!S.parentElement&&S.tagName==="HTML")return C;if(S.parentElement&&!S.parentElement.parentElement&&S.parentElement.tagName==="HTML"){if(S.tagName==="BODY")return p.body||null;if(S.tagName==="HEAD")return p.head||null}return null}function w(S){let M=f(S);return M||Er(S,x(S),h,R)}function _(S){if(!S)return null;let M=w(S);return M&&M.isConnected?M:null}function I(S){for(let M=0;M<R.length;M++){let V=R[M](S);V!=null&&V!==""&&h[M].set(V,S)}}for(let S of T){if(S.type!=="deletion")continue;let M=w(S.el);M&&M!==C&&M.remove()}let P=T.filter(S=>S.type!=="deletion").sort((S,M)=>S.el===M.el?0:S.el.compareDocumentPosition(M.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let S of P){if(S.type==="head"){let G=p.importNode(S.el,!0);p.head?p.head.replaceWith(G):C.insertBefore(G,C.firstChild),O.push({entry:S,imported:G});continue}if(S.type==="attrs"){let G=_(S.el)||_(S.base);if(!G){v++;continue}for(let j of S.names)S.el.hasAttribute(j)?G.setAttribute(j,S.el.getAttribute(j)):G.removeAttribute(j);continue}let M=S.el;if(f(M))return A(S);let V=_(M)||_(S.base);if(V){let G=p.importNode(M,!0);V.replaceWith(G),I(G),O.push({entry:S,imported:G});continue}if(S.base!=null&&!Se(S.base,x(S.base),R)||!Se(M,x(M),R))return A(S);let D=M.parentElement;if(!D)return A(S);let W=_(D);if(!W)return A(S);let te=null;for(let G=M.previousElementSibling;G;G=G.previousElementSibling){let j=_(G);if(j&&j.parentNode===W){te=j;break}}let X=p.importNode(M,!0);if(te)W.insertBefore(X,te.nextSibling);else{let G=Array.prototype.indexOf.call(D.children,M);W.insertBefore(X,W.children[G]||null)}I(X),O.push({entry:S,imported:X})}return{ok:!0,placed:O,held:null,skippedAttrs:v}}return{morph:q,defaults:y,findChangedRoots:oi,spliceProtected:si,mergeJson:Ut,mergeScriptText:zt,parseJsonRelaxed:ot,parseRulesRelaxed:Br}})();var ka=Ve.morph,ya=Ve.defaults,va=Ve.findChangedRoots,xa=Ve.spliceProtected;var Ht=Ve;var at=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Vt=new Set(at),Vr=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Wr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var lt={};$t(lt,{EmptyListInsert:()=>Ke,MAX_RULE_DEPTH:()=>Oe,MaxRuleDepthExceeded:()=>we,RuleTargetReadOnly:()=>Ge,RulesParseError:()=>Te,ShapeMismatch:()=>We,UnknownRulesVersion:()=>Re});var Te=class extends Error{constructor(t,r){super(t),this.name="RulesParseError",this.cause=r}},Re=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},Oe=20,we=class extends Error{constructor(t){super(`rule depth exceeded ${Oe} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},We=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},Ke=class extends Error{constructor(t){super(`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},Ge=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}};function ke(e,t,r,n={}){return Wt(e,t,r,{depth:0,path:[]},n)}function Wt(e,t,r,n,i){if(n.depth>Oe)throw new we(n.path);if(typeof r=="string")return Di(e,t,r,i);if(Array.isArray(r)){let[o,s]=r;return e.find(t,o,i).map((l,c)=>Wt(e,l,s,{depth:n.depth+1,path:[...n.path,c]},i))}if(typeof r=="object"&&r!==null){let o={};for(let[s,a]of Object.entries(r))o[s]=Wt(e,t,a,{depth:n.depth+1,path:[...n.path,s]},i);return o}return null}function Di(e,t,r,n){if(r.endsWith("[]")){let s=r.slice(0,-2);return e.find(t,s,n).map(a=>e.text(a))}if(r.startsWith("@"))return Kr(e,t,r.slice(1));let i=Z(r);if(i!==-1){let s=r.slice(0,i),a=r.slice(i+1),l=s?e.find(t,s,n):[t];return l.length===0?null:Kr(e,l[0],a)}if(r===".")return e.text(t);let o=e.find(t,r,n);return o.length===0?null:e.text(o[0])}function Kr(e,t,r){if(Vt.has(r)){let i=e.prop(t,r);return i==null?null:String(i)}let n=e.attr(t,r);return n||null}function $i(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Pi(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var Bi={find(e,t,r={}){let n=Pi(e);if(!n||!n.querySelectorAll)return[];let i=Array.from(n.querySelectorAll(t));r.includeRulesTag||(i=i.filter(a=>!$i(a)));let o=[];r.skip&&o.push(r.skip);let s=r.templateAttr===null?null:r.templateAttr||"cms-template";if(s&&o.push("["+s+"]"),o.length){let a=o.join(", ");i=i.filter(l=>!l.closest||!l.closest(a))}return i},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,r){if(r===void 0){let n=e?e[t]:void 0;return n!==void 0?n:null}e[t]=r},clone(e){return e.cloneNode(!0)},insertAt(e,t,r){let n=e.children[r]||null;e.insertBefore(t,n)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let n=e.ownerDocument.createElement("template");n.innerHTML=t;let i=n.content.firstElementChild;if(!i)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(i,e),i},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(n=>{n.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}},de=Bi;function Kt(e){try{return JSON.parse(e)}catch(t){throw new Te(`Invalid strict JSON: ${t.message}`,t)}}function Me(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(i){let o=[],s=0;for(;s<i.length;){let a=i[s];if(/\s/.test(a)){s++;continue}if("{}".includes(a)){o.push({type:a,value:a}),s++;continue}if(a==="["){let g=!1,d=s+1;for(;d<i.length&&/\s/.test(i[d]);)d++;if(d<i.length&&/[a-zA-Z_]/.test(i[d])&&(g=!0),!g){o.push({type:a,value:a}),s++;continue}}if(a==="]"){o.push({type:a,value:a}),s++;continue}if(a===":"){o.push({type:t.COLON,value:a}),s++;continue}if(a===","){o.push({type:t.COMMA,value:a}),s++;continue}if(a==='"'||a==="'"){let g=a,d=s+1;for(;d<i.length&&i[d]!==g;)i[d]==="\\"&&d++,d++;o.push({type:t.STRING,value:i.substring(s+1,d),quoted:!0,sourceQuote:g}),s=d+1;continue}let l=s,c;for(;l<i.length&&!/[{},]/.test(i[l]);)if(i[l]===":"){let g=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let k of g){let y=k.substring(1);if(i.substring(l+1,l+1+y.length)===y){d=!0,l+=y.length;break}}if(!d)break}else if(i[l]==="["){for(l++;l<i.length&&i[l]!=="]";){if(i[l]==='"'||i[l]==="'"){let g=i[l];for(l++;l<i.length&&i[l]!==g;)i[l]==="\\"&&l++,l++}l++}l<i.length&&i[l]==="]"&&l++}else l++;c=i.substring(s,l);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?u=t.NUMBER:c==="true"||c==="false"||c==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(u=t.SELECTOR),o.push({type:u,value:c,quoted:!1}),s=l}return o}function n(i){let o="";for(let s=0;s<i.length;s++){let a=i[s];if("{}".includes(a.type)||"[]".includes(a.type)){o+=a.value;continue}if(a.type===t.COLON){o+=a.value;continue}if(a.type===t.COMMA){let l=i[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;o+=a.value;continue}if(a.type===t.STRING&&a.quoted){let l=a.value;a.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(c,u)=>u.length%2===0?u+'\\"':c)),o+=`"${l}"`;continue}if(a.type===t.NUMBER||a.type===t.BOOLEAN){o+=a.value;continue}if(a.type===t.SELECTOR||a.type===t.IDENTIFIER){o+=`"${a.value}"`;continue}o+=`"${a.value}"`}return o}try{let i=r(e),o=n(i);return JSON.parse(o)}catch(i){throw new Te("Invalid extraction rules syntax: "+i.message,i)}}var Jr="1",Gr=/^[a-zA-Z0-9_-]+$/;function Je(e,t,r){let n;if(r===void 0)n="script[data-rules-name]";else{if(typeof r!="string"||!Gr.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${Gr})`);n=`script[data-rules-name~="${r}"]`}let i=e.find(t,n,{includeRulesTag:!0});if(i.length===0)return null;r!==void 0&&i.length>1&&console.warn(`hyper-html-api: ${i.length} rules tags match data-rules-name~="${r}"; using the first.`);let o=i[0],s=e.attr(o,"data-rules-version");if(s!==Jr)throw new Re(s);return{rules:Me(e.text(o)),tagNode:o}}var Za=new Function("url","return import(url)");var zi=.5;function Gt(e,t,r,n,i,o,s,a={}){let l=e.find(t,r,a);if(i.length===0){l.forEach(U=>e.remove(U));return}let c=i.length>l.length,u=l[0]||null;if(c&&!u&&(u=Ki(e,t,r,a),!u))throw new Ke(o.path);let g=l.map(U=>Hi(e,U,n,a)),d=null;if(u){d=e.clone(u),a.templateAttr&&e.removeAttr(d,a.templateAttr);let U=e.stripIds(d);U>0&&console.warn(`[hyper-html-api] stripped ${U} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let k=Vi(i,g,n),y=l[0]||u,N=e.parent(y),q=l.length>0?en(e,N,y):0,H=Gi(e,l),oe=new Set,ee=[],le=i.map((U,ie)=>{let Q=k[ie];if(Q>=0)return oe.add(Q),ee.push(!1),l[Q];ee.push(!0);let pe=e.clone(d);return e.stripIds(pe),pe});if(l.forEach((U,ie)=>{oe.has(ie)||e.remove(U)}),H){le.forEach((U,ie)=>{let Q=q+ie;e.children(N).findIndex(Lt=>e.sameNode(Lt,U))!==Q&&e.insertAt(N,U,Q)}),Qr(e,le,n,i,o,s,a);return}Ji(e,le,ee,N,q),Qr(e,le,n,i,o,s,a)}function Qr(e,t,r,n,i,o,s){t.forEach((a,l)=>{if(r===null){let c=n[l],u=c==null?"":String(c);e.text(a)!==u&&e.text(a,u)}else{let c=o(e,a,r,n[l],{depth:i.depth+1,path:[...i.path,l]},s);c&&c!==a&&(t[l]=c)}})}function Hi(e,t,r,n){return r===null?e.text(t):ke(e,t,r,n)}function Vi(e,t,r){let n=new Array(e.length).fill(-1),i=new Set;return e.forEach((o,s)=>{let a=-1,l=-1;t.forEach((c,u)=>{if(i.has(u))return;let g=Wi(o,c,r),d=g===l&&a>=0?Math.abs(u-s)<Math.abs(a-s):!1;(g>l||d)&&(l=g,a=u)}),l>=zi&&(n[s]=a,i.add(a))}),n}function Wi(e,t,r){if(r===null)return e===t?1:0;let n=Object.keys(r||{});if(n.length===0)return 0;let i=0;for(let o of n)JSON.stringify(e?.[o])===JSON.stringify(t?.[o])&&i++;return i/n.length}function en(e,t,r){let n=e.children(t);for(let i=0;i<n.length;i++)if(e.sameNode(n[i],r))return i;return-1}function Ki(e,t,r,n){if(!n.templateAttr)return null;let i=t;for(;i;){let o=e.find(i,r,{includeRulesTag:!1,templateAttr:null});for(let s of o)if(e.attr(s,n.templateAttr)!=null)return s;i=e.parent(i)}return null}function Gi(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let n=e.children(r),i=[];for(let o of t){let s=n.findIndex(a=>e.sameNode(a,o));if(s===-1)return!1;i.push(s)}return i.sort((o,s)=>o-s),i[i.length-1]-i[0]===i.length-1}function Ji(e,t,r,n,i){let o=null,s=i;for(let a=0;a<t.length;a++){if(!r[a]){o=t[a];continue}let l=o?e.parent(o):n;if(!l)continue;let c=o?en(e,l,o)+1:s++;e.insertAt(l,t[a],c),o=t[a]}}var tn=new Set(["checked","selected","disabled","readOnly","paused"]);function Ne(e,t,r,n,i={}){let o=[];if(Jt(r,n,[],o),o.length)throw new We(o);ct(e,t,r,n,{depth:0,path:[]},i)}function ct(e,t,r,n,i,o={}){if(i.depth>Oe)throw new we(i.path);if(n===void 0)return t;if(typeof r=="string")return Yi(e,t,r,n,i,o);if(Array.isArray(r)){let[s,a]=r;return Gt(e,t,s,a,n,i,ct,o),t}if(typeof r=="object"&&r!==null){for(let[s,a]of Object.entries(r)){let l=ct(e,t,a,n==null?n:n[s],{depth:i.depth+1,path:[...i.path,s]},o);l&&l!==t&&(t=l)}return t}return t}function Yi(e,t,r,n,i,o){if(r.endsWith("[]")){let l=r.slice(0,-2);return Gt(e,t,l,null,n,i,ct,o),t}if(r.startsWith("@"))return rn(e,t,r.slice(1),n);let s=Z(r);if(s!==-1){let l=r.slice(0,s),c=r.slice(s+1),u=l?e.find(t,l,o):[t];return u.length===0||rn(e,u[0],c,n),t}if(r===".")return e.text(t,n==null?"":String(n)),t;let a=e.find(t,r,o);return a.length===0||e.text(a[0],n==null?"":String(n)),t}function rn(e,t,r,n){if(Wr.has(r))throw new Ge(r);if(r==="outerHTML"){let i=n==null?"":String(n);return e.replaceWith(t,i)}return Vr.has(r)?(e.prop(t,r,Xi(r,n)),t):(e.attr(t,r,n==null?"":String(n)),t)}function Xi(e,t){return t==null?tn.has(e)?!1:"":tn.has(e)?t==="false"?!1:!!t:t}function Jt(e,t,r,n){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((i,o)=>{typeof i=="object"&&i!==null&&n.push({path:Xe([...r,o]),expected:"scalar",got:Ye(i)})}):n.push({path:Xe(r),expected:"array",got:Ye(t)});return}t!==null&&typeof t=="object"&&n.push({path:Xe(r),expected:"scalar",got:Ye(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){n.push({path:Xe(r),expected:"array",got:Ye(t)});return}let i=e[1];t.forEach((o,s)=>Jt(i,o,[...r,s],n));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){n.push({path:Xe(r),expected:"object",got:Ye(t)});return}for(let[i,o]of Object.entries(e))Jt(o,t[i],[...r,i],n)}}}function Ye(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Xe(e){return e.join(".")}function Yt(e,t,r){if(r&&typeof r=="object")return{rules:r,tagNode:null};if(typeof r=="string"){let n=t&&t.ownerDocument?t.ownerDocument:t;return Je(e,n,r)}return null}function on(e,t,r,n){let i=Yt(e,t,r);if(!i){let a=typeof r=="string"?`data-rules-name~="${r}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${a}`)}let{rules:o,tagNode:s}=i;return{rules:o,tagNode:s,get:()=>ke(e,t,o,n),set:a=>Ne(e,t,o,a,n)}}var re={extract:(e,t,r)=>ke(de,e,t,r),apply:(e,t,r,n)=>Ne(de,e,t,r,n),findRulesIn:(e,t)=>Je(de,e,t),findRules:(e,t)=>Yt(de,e,t),bind:(e,t,r)=>on(de,e,t,r),parseStrict:Kt,parseRelaxed:Me,ruleAttrIndex:Z,splitRule:it,errors:lt,DOM_PROPERTIES:at};var Zt={};$t(Zt,{fromString:()=>me,getRuleAtPath:()=>_e,getValueAtPath:()=>mo,setAtPath:()=>Xt,toString:()=>uo});function uo(e){return e.map(String).join(".")}function me(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function _e(e,t){let r=e;for(let n of t){if(r==null)return;if(typeof r=="string"){if(r.endsWith("[]")&&(typeof n=="number"||n==="*")){r=r.slice(0,-2);continue}return}if(Array.isArray(r)){if(typeof n!="number"&&n!=="*")return;r=r[1];continue}if(typeof r=="object"){if(typeof n=="number"||!(n in r))return;r=r[n];continue}return}return r}function mo(e,t){let r=e;for(let n of t){if(r==null)return;r=r[n]}return r}function Xt(e,t,r){if(t.length===0)return r;let[n,...i]=t;if(typeof n=="number"){let o=Array.isArray(e)?[...e]:[];return o[n]=Xt(o[n],i,r),o}return{...e&&typeof e=="object"?e:{},[n]:Xt((e||{})[n],i,r)}}function Ze(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[r,n]of Object.entries(e))t[r]=Ze(n);return t}return""}function dt(e,t,{ignoreActiveValue:r=!0}={}){Ht.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:r,restoreFocus:!0,formStateSync:"property"})}function mt(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[-_]/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}var ho='<div class="hcms-drag-handle mirk-sortable__grip" aria-hidden="true"><div class="mirk-sortable__dots"><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span></div></div>',Qt='<svg class="hcms-x" viewBox="0 0 16 16" shape-rendering="crispEdges" aria-hidden="true"><path d="M4 4 L12 12 M12 4 L4 12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square"></path></svg>',ln={"@scalar":`
3
3
  <label class="hcms-field" data-hcms-shape="scalar">
4
4
  <span class="hcms-label" data-hcms-label></span>
5
5
  <textarea class="mirk-textarea" rows="1" data-hcms-field></textarea>
@@ -39,7 +39,7 @@ var hypercms=(()=>{var Dt=Object.defineProperty;var ri=Object.getOwnPropertyDesc
39
39
  </section>
40
40
  `,"@object-array-item":`
41
41
  <article class="hcms-card mirk-sortable__item" draggable="true">
42
- ${ao}
42
+ ${ho}
43
43
  <div class="hcms-card-body mirk-sortable__body">
44
44
  <div class="hcms-card-fields"></div>
45
45
  <div class="hcms-card-controls">
@@ -147,11 +147,11 @@ var hypercms=(()=>{var Dt=Object.defineProperty;var ri=Object.getOwnPropertyDesc
147
147
  <input class="hcms-chip-field" data-hcms-field aria-label="Item" placeholder="\u2026" />
148
148
  <button type="button" class="hcms-remove" data-hcms-action="remove" aria-label="Remove">\xD7</button>
149
149
  </span>
150
- `},lo=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function ht(e){let t=e.head||e.documentElement;if(t)for(let r of lo)un(e,t,r)}function er(e,t){if(!sn[t])return null;let r=e&&(e.head||e.documentElement);return r?un(e,r,t):null}var nn={src:"@image",checked:"@checkbox",innerHTML:"@richtext"},dt={image:"@image",file:"@file",checkbox:"@checkbox",toggle:"@toggle",select:"@select",radio:"@radio",textarea:"@textarea",number:"@number",richtext:"@richtext"},co=new Set([...Object.values(dt),"@chips","@chips-item"]);function Ze(e,t,r,n){if(typeof e!="string")return"@scalar";let i=Z(e),o=gt(e,i,r,n),a=bt(o,t,"data-hcms-component");if(a&&dt[a]){let s=dt[a],l=Array.isArray(r)&&r.some(c=>c==="*"||typeof c=="number");return s==="@number"&&!on(e,i,t,l,o).every(mo)||(s==="@checkbox"||s==="@toggle")&&(i<0||e.slice(i+1)!=="checked")&&!on(e,i,t,l,o).every(ho)?"@scalar":s}if(i>=0){let s=e.slice(i+1);if(nn[s])return nn[s]}return"@scalar"}function an(e,t,r,n){if(typeof e!="string")return null;let i=Z(e),o=bt(gt(e,i,r,n),t,"data-hcms-component");return o&&dt[o]||null}var uo=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function mo(e){return e==null||e===""?!0:uo.test(String(e))}function ho(e){return e==null||e===""||e==="true"||e==="false"}function on(e,t,r,n,i){if(!r||!r.querySelectorAll)return[];if(!i||i===".")return[];let o=null;try{o=r.querySelectorAll(i)}catch{return[]}let a=t>=0?e.slice(t+1):null,s=[];for(let l of o)if(!(l.closest&&l.closest("[cms-template], [data-hcms-shell]"))&&(a?a==="value"&&"value"in l?s.push(l.value):s.push(l.getAttribute?l.getAttribute(a):null):s.push((l.textContent||"").trim()),!n))break;return s}function pt(e,t){if(typeof e!="string"||!e.endsWith("[]")||!t||!t.querySelector)return null;let r=e.slice(0,-2).trim();if(!r)return null;let n=null;try{n=t.querySelector(r)}catch{return null}let i=n&&n.closest?n.closest("[data-hcms-component]"):null;return(i&&i.getAttribute?i.getAttribute("data-hcms-component"):null)==="chips"?{array:"@chips",item:"@chips-item"}:null}function Ie(e,t,r){let n=e.join("."),i=e.map(o=>typeof o=="number"?"*":o).join(".");return n&&ce(r,n)||i&&i!==n&&ce(r,i)||ce(r,t)}function ft(e,t,r){let n=pt(e,r);if(!n)return null;let i=Ie(t,n.array,r);return i&&i.getAttribute("data-hcms-tpl")===n.array?n:null}function ln(e,t,r,n){if(typeof e!="string")return null;let i=Z(e),o=bt(gt(e,i,r,n),t,"data-hcms-options");if(o==null)return null;let a=o.trim().split(/\s+/).filter(Boolean);return a.length?a:null}function cn(e,t,r,n){if(typeof e!="string")return null;let i=Z(e);return bt(gt(e,i,r,n),t,"data-hcms-crop")}function po(e,t){return t>=0?e.slice(0,t):e}function gt(e,t,r,n){let i=po(e,t);return i&&i!=="."?i:fo(n,r)}function fo(e,t){if(e==null||!Array.isArray(t))return"";let r=[],n=e;for(let i of t){if(n==null||typeof n=="string")break;if(Array.isArray(n)){if(typeof n[0]!="string"||i!=="*"&&typeof i!="number")return"";r.push(n[0]),n=n[1];continue}if(typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,i))return"";n=n[i]}return r.join(" ")}function bt(e,t,r){if(!t||!t.querySelector||!e||e===".")return null;let n=null;try{n=t.querySelector(e)}catch{return null}return n&&n.getAttribute?n.getAttribute(r):null}function kt(e,t){if(!e||t==null)return;r(t,[]);function r(n,i){let o=_e(n);if(o==="scalar"){let a=Ze(n,e,i,t);co.has(a)&&er(e,a);return}if(o==="scalar-array"){let a=pt(n,e);a&&(er(e,a.array),er(e,a.item));return}if(o==="object"){for(let[a,s]of Object.entries(n))r(s,[...i,a]);return}if(o==="object-array"){let a=n[1],s=[...i,"*"];if(a&&typeof a=="object"&&!Array.isArray(a))for(let[l,c]of Object.entries(a))r(c,[...s,l]);else r(a,s)}}}function un(e,t,r){let n=ce(e,r);if(n)return n;let i=e.createElement("template");return i.setAttribute("data-hcms-tpl",r),i.setAttribute("save-remove",""),i.innerHTML=sn[r].trim(),t.appendChild(i),i}function ce(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${go(t)}"]`)}function go(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function _e(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function Qe(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var dn={IMG:"src",A:"href"};function yt(e){if(!e)return"value";let t=(e.tagName||"").toUpperCase();return t==="INPUT"?(e.getAttribute("type")||"text").toLowerCase()==="checkbox"?"checked":"value":t==="TEXTAREA"||t==="SELECT"?"value":dn[t]?dn[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function mn(e,t){let r=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),i=yt(e),a=`${pn(r,n)}[data-hcms-field="${Le(t)}"]`;return r==="INPUT"&&n==="radio"?`${a}:checked@value`:i?`${a}@${i}`:a}function bo(e){let t=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),n=yt(e),o=`${pn(t,r)}[data-hcms-field]`;return t==="INPUT"&&r==="radio"?`${o}:checked@value`:n?`${o}@${n}`:o}function pn(e,t){return e==="INPUT"?t?`input[type="${t}"]`:"input":e==="TEXTAREA"?"textarea":e==="SELECT"?"select":e==="IMG"?"img":e==="A"?"a":':not([data-hcms-shape="scalar"]):not([data-hcms-shape="object"]):not([data-hcms-shape="object-array"]):not([data-hcms-shape="scalar-array"])'}function Le(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var hn=new Set(["__proto__","constructor","prototype"]);function vt(e,t){return r(e,[]);function r(c,d){let b=_e(c);if(b==="scalar")return n(c,d);if(b==="scalar-array")return i(c,d);if(b==="object-array")return o(c,d);if(b==="object"){let u=Object.create(null);for(let[k,y]of Object.entries(c)){if(hn.has(k))throw new Error(`hypercms: rule key "${k}" is forbidden at "${d.join(".")||"<root>"}"`);u[k]=r(y,[...d,k])}return u}return null}function n(c,d){let b=d.length?d[d.length-1]:null,u=typeof b=="string"?b:"__value",k=l(d,u);if(k)return mn(k,u);let y=s(Ze(c,t,d,e),u);return y?mn(y,u):`input[data-hcms-field="${Le(u)}"]@value`}function i(c,d){let b=ft(c,d,t),u=b&&s(b.item,null)||s("@scalar-array-item",null),k=u?bo(u):"input[data-hcms-field]@value";return[a(d,"[data-hcms-array-item]"),k]}function o(c,d){let[,b]=c,u=[...d,"*"],k=a(d,"[data-hcms-card]");if(b&&typeof b=="object"&&!Array.isArray(b)){let y=Object.create(null);for(let[N,q]of Object.entries(b)){if(hn.has(N))throw new Error(`hypercms: rule key "${N}" is forbidden at "${u.join(".")}"`);y[N]=r(q,[...u,N])}return[k,y]}return[k,r(b,[...u,0])]}function a(c,d){let b=c.length?c[c.length-1]:"",u=c.some(N=>N==="*"),k=c.join(".");return`${u?`[data-hcms-field="${Le(b)}"]`:`[data-hcms-path="${Le(k)}"]`} > .hcms-array-items > ${d}`}function s(c,d){if(!t)return null;let b=ce(t,c);if(!b)return null;let u=b.content||b;if(d){let k=u.querySelector(`[data-hcms-field="${Le(d)}"]`);if(k)return k}return u.querySelector("[data-hcms-field]")}function l(c,d){if(!t)return null;let b=c.map(y=>typeof y=="number"?"*":y).join("."),k=[c.join("."),b];for(let y=c.length-1;y>=0;y--){let N=c.slice(0,y).map(q=>typeof q=="number"?"*":q);N.push("*"),k.push(N.join("."))}for(let y of k){if(!y)continue;let N=ce(t,y);if(!N||!Qe(N))continue;let q=N.content||N,H=q.querySelector(`[data-hcms-field="${Le(d)}"]`)||q.querySelector("[data-hcms-field]");if(H)return H}return null}}function tr(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],r=t.split("/").pop()||t;try{return decodeURIComponent(r)}catch{return r}}function xt({pageRules:e,formRules:t,data:r,doc:n}){let i=n.createDocumentFragment(),o=rr(e,[],r,n,e);return o&&i.appendChild(o),i}function gn({shape:e,itemShape:t,pathArr:r,data:n,doc:i,itemKey:o,pageRules:a}){if(e==="object-array-item")return kn(t,r,n,i,a);if(e==="scalar-array-item")return yn(r,n,i,o||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function rr(e,t,r,n,i){let o=_e(e);return o==="scalar"?ko(e,t,r,n,i):o==="object"?wo(e,t,r,n,i):o==="object-array"?_o(e,t,r,n,i):o==="scalar-array"?Ao(e,t,r,n):null}function ko(e,t,r,n,i){let o=Ze(e,n,t,i),a=Ie(t,o,n);if(!a)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let s=an(e,n,t,i);s==="@number"&&o==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "@number" but its value isn't a plain number; rendering a text input so the value is preserved`),(s==="@checkbox"||s==="@toggle")&&o==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "${s}" but its value isn't true/false; rendering a text input so the value is preserved`),bn(a,s===o?s:null,t);let l=je(a,n);Fe(l,t);let c=a.getAttribute?.("data-hcms-tpl");if((o==="@select"||o==="@radio")&&c===o&&yo(l,e,t,r,n,o,i),o==="@image"&&c==="@image"){let d=cn(e,n,t,i);d!=null&&!l.hasAttribute("data-hcms-crop")&&l.setAttribute("data-hcms-crop",d)}return So(l,he(t)),wt(l,he(t)),_t(l,he(t)),An(l,r),o==="@file"&&xo(l),l}function bn(e,t,r){if(!t)return;let n=e.getAttribute?.("data-hcms-tpl");n&&n!==t&&console.info(`[hypercms] field "${r.join(".")}" declares component "${t}" but custom template "${n}" wins`)}function yo(e,t,r,n,i,o,a){let s=ln(t,i,r,a),l=s?[...s]:[],c=n==null?"":String(n);if(c!==""&&!l.includes(c)&&l.unshift(c),!s&&(vo(e,"data-hcms-options required (space-separated values)"),l.length===0)){e.querySelector(".mirk-radio")?.remove();return}if(o==="@select"){let u=e.querySelector("select[data-hcms-field]");if(!u)return;for(let k of l){let y=i.createElement("option");y.value=k,y.textContent=mt(k),u.appendChild(y)}return}let d=e.querySelector(".mirk-radio");if(!d||!d.parentNode)return;let b=nr(r.join("."));for(let u of l){let k=d.cloneNode(!0),y=k.querySelector('input[type="radio"]');y&&(y.value=u,y.name=b);let N=k.querySelector(".mirk-radio__label");N&&(N.textContent=mt(u)),d.parentNode.insertBefore(k,d)}d.remove()}function nr(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function vo(e,t){let r=e.querySelector?e.querySelector(".hcms-error"):null;r&&(r.textContent=t,r.hidden=!1)}function xo(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=tr(t.getAttribute("href")))}function wo(e,t,r,n,i){let o=Ie(t,"@object",n);if(!o)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let a=je(o,n);if(Fe(a,t),wt(a,he(t)),_t(a,he(t)),Qe(o))return En(a,e,t),Sn(a,e,r),a;let s=At(a,".hcms-object-fields",o,t);for(let[l,c]of Object.entries(e)){let d=r==null?null:r[l],b=rr(c,[...t,l],d,n,i);b&&s.appendChild(b)}return a}function _o(e,t,r,n,i){let o=Ie(t,"@object-array",n);if(!o)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let a=je(o,n);Fe(a,t),wt(a,he(t)),_t(a,he(t)),xn(a,o),_n(a,o,t);let s=At(a,".hcms-array-items",o,t),[,l]=e;return(Array.isArray(r)?r:[]).forEach((d,b)=>{let u=kn(l,[...t,b],d,n,i);u&&s.appendChild(u)}),wn(a),a}function kn(e,t,r,n,i){let o=vn(t,"object-array-item",n);if(!o)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let a=je(o,n);if(a.setAttribute("data-hcms-card",""),a.classList.contains("hcms-card")||a.classList.add("hcms-card"),Fe(a,t),Qe(o))return e&&typeof e=="object"&&!Array.isArray(e)&&(En(a,e,t),Sn(a,e,r)),a;let s=At(a,".hcms-card-fields",o,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[l,c]of Object.entries(e)){let d=r==null?null:r[l],b=rr(c,[...t,l],d,n,i);b&&s.appendChild(b)}return a}function Ao(e,t,r,n){let i=pt(e,n),o=ft(e,t,n),a=i?i.array:"@scalar-array",s=Ie(t,a,n);if(!s)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);bn(s,i?i.array:null,t);let l=je(s,n);Fe(l,t),wt(l,he(t)),_t(l,he(t)),xn(l,s),_n(l,s,t),o&&l.setAttribute("data-hcms-item-tpl",o.item);let c=At(l,".hcms-array-items",s,t);return(Array.isArray(r)?r:[]).forEach((b,u)=>{let k=yn([...t,u],b,n,o?o.item:null);k&&c.appendChild(k)}),wn(l),l}function yn(e,t,r,n){let i=vn(e,"scalar-array-item",r,n);if(!i)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let o=je(i,r);return o.setAttribute("data-hcms-array-item",""),o.classList.contains("hcms-array-item")||o.classList.add("hcms-array-item"),Fe(o,e),An(o,t),o}function vn(e,t,r,n){let i=e.map(o=>typeof o=="number"?"*":o).join(".");return ce(r,i)||n&&ce(r,n)||ce(r,"@"+t)}function je(e,t){let r=e.content||e,n=t.createElement("div");return n.appendChild(r.cloneNode(!0)),n.firstElementChild||n}function Fe(e,t){e.setAttribute("data-hcms-path",t.join("."))}function So(e,t){let r=t==null?"":String(t);if(e.matches&&e.matches("[data-hcms-field]")){e.getAttribute("data-hcms-field")||e.setAttribute("data-hcms-field",r);return}(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(i=>{i.getAttribute("data-hcms-field")||i.setAttribute("data-hcms-field",r)})}function wt(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function _t(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(n=>{(n.textContent||"").trim()===""&&(n.textContent=mt(String(t)))})}function xn(e,t){["data-hcms-no-add","data-hcms-no-remove","data-hcms-no-reorder"].forEach(r=>{t.hasAttribute(r)&&e.setAttribute(r,"")}),["data-hcms-min-items","data-hcms-max-items"].forEach(r=>{t.hasAttribute(r)&&e.setAttribute(r,t.getAttribute(r))})}function wn(e){let t=e.querySelector?e.querySelector(".hcms-array-items"):null;if(!t)return;let r=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),n=r.length,i=fn(e,"data-hcms-max-items"),o=fn(e,"data-hcms-min-items"),a=e.hasAttribute("data-hcms-no-add"),s=e.hasAttribute("data-hcms-no-remove"),l=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector('[data-hcms-action="add"]');c&&(c.hidden=a||i!=null&&n>=i),r.forEach((d,b)=>{let u=d.querySelector('[data-hcms-action="remove"]');u&&(u.hidden=s||o!=null&&n<=o);let k=d.querySelector('[data-hcms-action="move-up"]');k&&(k.hidden=l||b===0);let y=d.querySelector('[data-hcms-action="move-down"]');y&&(y.hidden=l||b===n-1)})}function fn(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function _n(e,t,r){if(e.hasAttribute("data-hcms-no-reorder")||t.hasAttribute("data-hcms-no-reorder"))return;let n=e.querySelector(".hcms-array-items");if(!n)return;let i="hcms-"+r.join(".");n.setAttribute("sortable",i),n.setAttribute("onsorted","hypercmsCommit && hypercmsCommit()")}function he(e){return e.length?e[e.length-1]:null}function An(e,t){let r=Eo(e);if(r.length!==0)for(let n of r)Cn(n,t)}function Eo(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&Co(e)&&t.push(e),(e.querySelectorAll?e.querySelectorAll("input[data-hcms-field], textarea[data-hcms-field], select[data-hcms-field], img[data-hcms-field], a[data-hcms-field], [contenteditable][data-hcms-field]"):[]).forEach(n=>t.push(n)),t}function Co(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function Sn(e,t,r){(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(i=>{let o=i.getAttribute("data-hcms-field");if(!o)return;if(!t||typeof t!="object"||!(o in t)){console.warn(`[hypercms] inline template field "${o}" is not in the rule shape; ignoring`);return}let a=r==null?null:r[o];Cn(i,a)})}function En(e,t,r){if(!e.querySelectorAll)return;e.querySelectorAll("[data-hcms-field]").forEach(i=>{let o=i.getAttribute("data-hcms-field");if(!o||t&&typeof t=="object"&&!(o in t))return;let a=[...r,o].join(".");i.setAttribute("data-hcms-path",a)})}function At(e,t,r,n){if(!e.querySelector)return e;let i=e.querySelector(t);if(i)return i;let o=r?.getAttribute?.("data-hcms-tpl")||n.join(".");throw new Error(`hypercms: template "${o}" is in slotted mode but has no ${t} element`)}function Cn(e,t){let r=yt(e),n=(e.tagName||"").toUpperCase(),i=(e.getAttribute("type")||"").toLowerCase();if(n==="INPUT"&&i==="radio"){e.checked=e.value!=null&&String(e.value)===String(t??"");return}if(r==="checked"){e.checked=t===!0||t==="true";return}if(r){e[r]=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var Tn={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function Rn(e,t,r,n={}){let{observerHandle:i,shellRoot:o,structural:a,structuralPath:s}=n;i?.pause?.();try{if(!a)try{return re.apply(e,t,r,Tn),{ok:!0}}catch(b){return{ok:!1,error:b}}let l=To(e,t,s),c=l?Oo(l):null,d=l?null:No(e,o);try{return re.apply(e,t,r,Tn),{ok:!0}}catch(b){return c?Mo(l,c):d&&Io(e,o,d),{ok:!1,error:b}}}finally{i?.resume?.()}}function To(e,t,r){if(!r||!e)return null;let n=me(r),i=[],o=t;for(let a of n){if(typeof o=="string"||o==null||Array.isArray(o))break;if(typeof o=="object"&&a in o){if(i.push(a),o=o[a],Array.isArray(o)||typeof o=="string"&&o.endsWith("[]"))break}else return null}return!Array.isArray(o)&&!(typeof o=="string"&&o.endsWith("[]"))?null:Ro(e,t,i)}function Ro(e,t,r){if(r.length===0)return null;let n=e,i=t;for(let o=0;o<r.length;o++){let a=r[o];if(!i||typeof i!="object"||Array.isArray(i))return null;let s=i[a];if(s==null)return null;if(o===r.length-1){if(Array.isArray(s)){let[l]=s;return n.querySelector?.(l)?.parentElement||null}if(typeof s=="string"&&s.endsWith("[]")){let l=s.slice(0,-2);return n.querySelector?.(l)?.parentElement||null}return null}i=s}return null}function Oo(e){let t=[];for(let r of Array.from(e.childNodes))t.push(r.cloneNode(!0));return t}function Mo(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);for(let r of t)e.appendChild(r)}function No(e,t){let r=[];for(let n of Array.from(e.childNodes))n===t||t&&n.contains?.(t)||r.push(n.cloneNode(!0));return r}function Io(e,t,r){for(let i of Array.from(e.childNodes))i===t||t&&i.contains?.(t)||e.removeChild(i);let n=Lo(e,t);for(let i of r)e.insertBefore(i,n||null)}function Lo(e,t){if(!t)return null;for(let r of Array.from(e.childNodes))if(r===t||r.contains?.(t))return r;return null}var jo={Mutation:(e,t)=>e?.Mutation??t?.Mutation,undo:(e,t)=>e?.undo??t?.undo,onPrepareForSave:(e,t)=>e?.addDocumentTransform??t?.onPrepareForSave,consent:(e,t)=>e?.confirm??t?.consent,RichClay:(e,t)=>e?.RichClay??t?.RichClay,quickcrop:(e,t)=>e?.quickcrop??t?.quickcrop,uploadFileBasic:(e,t)=>e?.uploadFileBasic??t?.uploadFileBasic};function ne(e,t){let r=jo[e];if(!r)throw new Error(`hypercms: unknown platform capability "${e}"`);let n=t||(typeof window<"u"?window:null);return n&&r(n.clay,n.hyperclay)||null}var On=["clay:mutation-ready","hyperclay:mutation-ready"],Mn=["clay:sync-applied","hyperclay:livesync-applied"];function ir(e,t,r){let n=null,i=o=>{n!==null&&n!==o.type||(n=o.type,queueMicrotask(()=>{n=null}),r(o))};for(let o of t)e.addEventListener(o,i);return()=>{for(let o of t)e.removeEventListener(o,i)}}function St(e,t){if(!t||e==null)return e;return r(e);function r(n){if(typeof n=="string"){if(n.endsWith("[]")||Z(n)!==-1)return n;let i=null;try{i=t.querySelector(n)}catch{return n}return i&&i.children.length>0?n+"@innerHTML":n}if(Array.isArray(n))return n;if(n&&typeof n=="object"){let i=Object.create(null);for(let[o,a]of Object.entries(n))i[o]=r(a);return i}return n}}function or(e){if(!e||e.tagName!=="TEXTAREA")return;let t=e.ownerDocument.defaultView||(typeof window<"u"?window:null);t&&t.CSS&&t.CSS.supports&&t.CSS.supports("field-sizing: content")||(e.style.height="auto",e.style.height=e.scrollHeight+"px")}function qe(e,t){if(!e||!e.querySelectorAll)return;e.querySelectorAll("textarea[data-hcms-field]").forEach(or);let r=t&&t.defaultView||(typeof window<"u"?window:null),n=r&&r.richclay&&r.richclay.RichClay||ne("RichClay",r)||(r&&typeof r.RichClay=="function"?r.RichClay:null);n&&e.querySelectorAll("[contenteditable][data-hcms-field]").forEach(i=>{if(i.__hcmsRichclay)return;let o;try{o=new n(i,{inline:!0,hyperclay:!1,toolbar:["bold","italic","link","undo","redo"]})}catch(s){console.warn("[hypercms] richclay activation failed; field stays plain contenteditable",s);return}i.__hcmsRichclay=o;let a=o&&o.squire;a&&typeof a.addEventListener=="function"&&a.addEventListener("input",()=>{let s=r&&r.Event||Event;i.dispatchEvent(new s("input",{bubbles:!0}))})})}var sr=new WeakSet;function $e(e,t){let r=ne("undo");if(!r)return t();r.pause();try{let n=t();return n&&n.ok?r.commitCaptured(e):r.discardCaptured(),n}finally{r.resume()}}function Tt(e){let t=ne("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function Ln(e){let{formRoot:t}=e;if(!t||sr.has(t))return;sr.add(t);let r=a=>{let s=a.target;!s||!s.closest||s.closest("[data-hcms-form-root]")&&s.matches("input, textarea, select, [contenteditable][data-hcms-field]")&&(s.tagName==="TEXTAREA"&&or(s),!s.matches('input[type="file"]')&&(!s.closest("[data-hcms-field]")&&!s.hasAttribute?.("data-hcms-field")||Nn(s,e)))},n=a=>{let s=a.target;if(!(!s||!s.closest)&&s.closest("[data-hcms-form-root]")){if(s.matches('input[type="file"][data-hcms-upload]')){zo(s,e);return}s.matches('input[type="checkbox"], input[type="radio"], select')&&Nn(s,e)}},i=a=>{let s=a.target;if(!s||!s.closest)return;let l=s.closest("[data-hcms-action]");if(!l)return;let c=l.getAttribute("data-hcms-action");if(c==="add"||c==="remove"||c==="move-up"||c==="move-down"||c==="clear-upload"){if(!l.closest("[data-hcms-form-root]"))return}else if(c==="close"&&!l.closest("[data-hcms-shell]"))return;if(c==="add"){let d=l.closest("[data-hcms-path]");if(!d)return;let b=d.getAttribute("data-hcms-path");ar(b,e)}else if(c==="remove"){let d=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!d)return;Go(d,e)}else if(c==="move-up"||c==="move-down"){let d=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!d)return;Wo(d,c==="move-up"?-1:1,e)}else c==="clear-upload"?Uo(l,e):c==="close"&&e.onCloseRequested?.()},o=t.ownerDocument;o.addEventListener("input",r,!0),o.addEventListener("change",n,!0),o.addEventListener("click",i,!0),e.detachEvents=()=>{o.removeEventListener("input",r,!0),o.removeEventListener("change",n,!0),o.removeEventListener("click",i,!0),sr.delete(t)}}var Fo=new Set(["value","checked"]);function qo(e,t){if(!t)return null;let r=me(t);if(r.some(l=>typeof l=="number"||l==="*"))return null;let n=we(e.pageRules,r);if(typeof n!="string")return null;let i=re.ruleAttrIndex(n);if(i===-1)return null;let o=n.slice(i+1);if(!Fo.has(o))return null;let a=n.slice(0,i),s=a?e.pageRoot.querySelector(a):e.pageRoot;return s?{el:s,prop:o,oldValue:s[o]}:null}function Nn(e,t){let n=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",i=qo(t,n);if(de(ae(t),{path:n,structural:!1},t),i){let o=ne("undo");o&&typeof o.recordValue=="function"&&o.recordValue(i.el,{prop:i.prop,oldValue:i.oldValue,newValue:i.el[i.prop]})}}var Do={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function $o(e,t){let r=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(r==null)return{file:e};let n=ne("quickcrop");if(typeof n!="function")return{file:e};try{let i=await n(e,{aspect:Bo(r),...Do});return i===null?null:{file:Po(i.blob,e.name),dataURL:i.dataURL}}catch(i){return et(t,i&&i.message||"Crop failed"),null}}function Bo(e){let t=String(e??"").trim().toLowerCase();if(t===""||t==="free")return null;let r=t.match(/^(\d+(?:\.\d+)?)\s*[:/]\s*(\d+(?:\.\d+)?)$/);if(!r)return null;let n=parseFloat(r[1]),i=parseFloat(r[2]);return!n||!i?null:n/i}function Po(e,t){let r=e.type==="image/webp"?".webp":e.type==="image/jpeg"?".jpg":".png",n=String(t||"image").replace(/\.[^.]+$/,"");try{return new File([e],n+r,{type:e.type})}catch{return e}}async function zo(e,t){let r=e.files&&e.files[0];if(!r)return;let n=e.closest("[data-hcms-path]");if(!n)return;let i=n.getAttribute("data-hcms-path")||"";et(n,null);let o=await $o(r,n);if(!o||t.closed){Ae(e);return}let a=o.file,s=o.dataURL||null,l=ne("uploadFileBasic"),c=null;if(typeof l=="function")try{let d=await l(a);c=d&&d.uploads&&d.uploads[0]&&d.uploads[0].url}catch(d){if(t.closed){Ae(e);return}et(n,d&&d.message||"Upload failed"),t.dispatch?.("hcms:error",{error:d,path:i}),Ae(e);return}if(t.closed){Ae(e);return}if(c||(c=s||Vo(a)),!c){Ae(e);return}et(n,null),jn(n,c,a.name),de(ae(t),{path:i,structural:!1},t),Ae(e)}function Uo(e,t){let r=e.closest("[data-hcms-path]");if(!r)return;let n=r.getAttribute("data-hcms-path")||"";jn(r,"","");let i=r.querySelector('input[type="file"][data-hcms-upload]');i&&Ae(i),et(r,null),de(ae(t),{path:n,structural:!1},t)}function Ho(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function jn(e,t,r){let n=Ho(e);if(!n)return;let i=(n.tagName||"").toUpperCase();i==="IMG"?n.src=t||"":i==="A"&&(n.href=t||"",n.textContent=t?r||tr(t):"")}function Ae(e){try{e.value=""}catch{}}function Vo(e){let t=typeof URL<"u"&&URL.createObjectURL?URL:null;if(!t)return"";try{return t.createObjectURL(e)}catch{return""}}function et(e,t){let r=e.querySelector?e.querySelector(":scope > .hcms-error"):null;r&&(t?(r.textContent=t,r.hidden=!1):(r.textContent="",r.hidden=!0))}function ar(e,t){let{formRoot:r,pageRules:n}=t,i=r.querySelector(`[data-hcms-path="${ts(e)}"]`);if(!i)throw new Error(`hypercms: no element at path "${e}"`);let o=i.querySelector(".hcms-array-items");if(!o)throw new Error(`hypercms: array container missing .hcms-array-items at "${e}"`);let a=me(e),s=Zo(n,a),l=Array.isArray(s),c=typeof s=="string"&&s.endsWith("[]");if(!l&&!c)throw new Error(`hypercms: path "${e}" is not an array`);let d=Ct(i,"data-hcms-max-items"),b=o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(i.hasAttribute("data-hcms-no-add")||d!=null&&b.length>=d)return;let u=b.length,k=l?s[1]:s.replace(/\[\]$/,""),y=Xe(l?k:"string"),N=gn({shape:l?"object-array-item":"scalar-array-item",itemShape:k,pathArr:[...a,u],data:y,doc:t.doc,itemKey:i.getAttribute("data-hcms-item-tpl")||null,pageRules:n});return o.appendChild(N),qe(N,t.doc),cr(i),$e(`Add ${e}`,()=>de(ae(t),{path:e,structural:!0},t))}function Wo(e,t,r){let n=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!n||n.hasAttribute("data-hcms-no-reorder"))return;let i=n.querySelector(".hcms-array-items");if(!i)return;let o=Array.from(i.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),a=o.indexOf(e);if(a<0)return;let s=a+t;if(s<0||s>=o.length)return;let l=e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`);return t<0?i.insertBefore(e,o[s]):i.insertBefore(e,o[s].nextSibling),dr(i),cr(n),l&&typeof l.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),$e(`Reorder ${n.getAttribute("data-hcms-path")||""}`,()=>de(ae(r),{path:n.getAttribute("data-hcms-path")||"",structural:!0},r))}var Et="Delete this item?";function Ko(e,t){let r=e&&e.getAttribute("data-hcms-confirm-remove");if(r!=null)return/^(off|false|no|0)$/i.test(r.trim())?null:r||Et;let n=t&&t.confirmRemove;return n===!1?null:typeof n=="string"?n||Et:n===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?Et:null}function Go(e,t){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),n=Ko(r,t);if(n==null)return De(e,t);let i=ne("consent")||typeof window<"u"&&window.consent;typeof i=="function"?Promise.resolve(i(n)).then(()=>De(e,t),()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(n)&&De(e,t):De(e,t)}function De(e,t){let r=e.getAttribute("data-hcms-path")||"",n=e.parentElement,i=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!i?.hasAttribute("data-hcms-no-remove")){if(i){let o=Ct(i,"data-hcms-min-items"),a=i.querySelector(".hcms-array-items"),s=a?a.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]").length:0;if(o!=null&&s<=o)return}return e.remove(),n&&dr(n),i&&cr(i),$e(`Remove ${r}`,()=>de(ae(t),{path:r,structural:!0},t))}}function de(e,t,r){let n=tt(e);if(n===r.lastFingerprint)return{ok:!0,skipped:!0};let i=Rn(r.pageRoot,r.pageRules,e,{observerHandle:r.observerHandle,shellRoot:r.shellRoot,structural:!!t.structural,structuralPath:t.path||null});return i.ok?(r.lastFingerprint=n,r.lastData=e,In(r,null),r.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),r.onChange?.(e,t)):(In(r,Xo(i.error,t.path)),r.dispatch?.("hcms:error",{error:i.error,attemptedData:e}),r.onError?.(i.error)),i}function ae(e){let t=re.extract(e.formRoot,e.formRules);return ye(t,e.formRules)}function ye(e,t){if(t==null||e==null)return e;if(typeof t=="string")return t.endsWith("@checked")?e===!0||e==="true":e;if(Array.isArray(t)){if(!Array.isArray(e))return e;let[,r]=t;return e.map(n=>ye(n,r))}if(typeof t=="object"){if(typeof e!="object"||Array.isArray(e))return e;let r={};for(let[n,i]of Object.entries(t))r[n]=ye(e[n],i);return r}return e}function In(e,t){e.lastErrors=t&&t.length?t:null,lr(e)}function lr(e){if(Jo(e),e.errorEl&&(e.errorEl.textContent="",e.errorEl.hidden=!0),!e.lastErrors)return;let t=[];for(let{message:r,path:n}of e.lastErrors){if(n!=null&&n!==""){let i=Yo(e.formRoot,n);if(i){i.textContent=i.textContent?`${i.textContent}
150
+ `},po=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function ht(e){let t=e.head||e.documentElement;if(t)for(let r of po)mn(e,t,r)}function er(e,t){if(!ln[t])return null;let r=e&&(e.head||e.documentElement);return r?mn(e,r,t):null}var sn={src:"@image",checked:"@checkbox",innerHTML:"@richtext"},ut={image:"@image",file:"@file",checkbox:"@checkbox",toggle:"@toggle",select:"@select",radio:"@radio",textarea:"@textarea",number:"@number",richtext:"@richtext"},fo=new Set([...Object.values(ut),"@chips","@chips-item"]);function Qe(e,t,r,n){if(typeof e!="string")return"@scalar";let i=Z(e),o=gt(e,i,r,n),s=bt(o,t,"data-hcms-component");if(s&&ut[s]){let a=ut[s],l=Array.isArray(r)&&r.some(c=>c==="*"||typeof c=="number");return a==="@number"&&!an(e,i,t,l,o).every(bo)||(a==="@checkbox"||a==="@toggle")&&(i<0||e.slice(i+1)!=="checked")&&!an(e,i,t,l,o).every(ko)?"@scalar":a}if(i>=0){let a=e.slice(i+1);if(sn[a])return sn[a]}return"@scalar"}function cn(e,t,r,n){if(typeof e!="string")return null;let i=Z(e),o=bt(gt(e,i,r,n),t,"data-hcms-component");return o&&ut[o]||null}var go=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function bo(e){return e==null||e===""?!0:go.test(String(e))}function ko(e){return e==null||e===""||e==="true"||e==="false"}function an(e,t,r,n,i){if(!r||!r.querySelectorAll)return[];if(!i||i===".")return[];let o=null;try{o=r.querySelectorAll(i)}catch{return[]}let s=t>=0?e.slice(t+1):null,a=[];for(let l of o)if(!(l.closest&&l.closest("[cms-template], [data-hcms-shell]"))&&(s?s==="value"&&"value"in l?a.push(l.value):a.push(l.getAttribute?l.getAttribute(s):null):a.push((l.textContent||"").trim()),!n))break;return a}function pt(e,t){if(typeof e!="string"||!e.endsWith("[]")||!t||!t.querySelector)return null;let r=e.slice(0,-2).trim();if(!r)return null;let n=null;try{n=t.querySelector(r)}catch{return null}let i=n&&n.closest?n.closest("[data-hcms-component]"):null;return(i&&i.getAttribute?i.getAttribute("data-hcms-component"):null)==="chips"?{array:"@chips",item:"@chips-item"}:null}function Ie(e,t,r){let n=e.join("."),i=e.map(o=>typeof o=="number"?"*":o).join(".");return n&&ce(r,n)||i&&i!==n&&ce(r,i)||ce(r,t)}function ft(e,t,r){let n=pt(e,r);if(!n)return null;let i=Ie(t,n.array,r);return i&&i.getAttribute("data-hcms-tpl")===n.array?n:null}function dn(e,t,r,n){if(typeof e!="string")return null;let i=Z(e),o=bt(gt(e,i,r,n),t,"data-hcms-options");if(o==null)return null;let s=o.trim().split(/\s+/).filter(Boolean);return s.length?s:null}function un(e,t,r,n){if(typeof e!="string")return null;let i=Z(e);return bt(gt(e,i,r,n),t,"data-hcms-crop")}function yo(e,t){return t>=0?e.slice(0,t):e}function gt(e,t,r,n){let i=yo(e,t);return i&&i!=="."?i:vo(n,r)}function vo(e,t){if(e==null||!Array.isArray(t))return"";let r=[],n=e;for(let i of t){if(n==null||typeof n=="string")break;if(Array.isArray(n)){if(typeof n[0]!="string"||i!=="*"&&typeof i!="number")return"";r.push(n[0]),n=n[1];continue}if(typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,i))return"";n=n[i]}return r.join(" ")}function bt(e,t,r){if(!t||!t.querySelector||!e||e===".")return null;let n=null;try{n=t.querySelector(e)}catch{return null}return n&&n.getAttribute?n.getAttribute(r):null}function kt(e,t){if(!e||t==null)return;r(t,[]);function r(n,i){let o=Ae(n);if(o==="scalar"){let s=Qe(n,e,i,t);fo.has(s)&&er(e,s);return}if(o==="scalar-array"){let s=pt(n,e);s&&(er(e,s.array),er(e,s.item));return}if(o==="object"){for(let[s,a]of Object.entries(n))r(a,[...i,s]);return}if(o==="object-array"){let s=n[1],a=[...i,"*"];if(s&&typeof s=="object"&&!Array.isArray(s))for(let[l,c]of Object.entries(s))r(c,[...a,l]);else r(s,a)}}}function mn(e,t,r){let n=ce(e,r);if(n)return n;let i=e.createElement("template");return i.setAttribute("data-hcms-tpl",r),i.setAttribute("save-remove",""),i.innerHTML=ln[r].trim(),t.appendChild(i),i}function ce(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${xo(t)}"]`)}function xo(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function Ae(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function et(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var hn={IMG:"src",A:"href"};function yt(e){if(!e)return"value";let t=(e.tagName||"").toUpperCase();return t==="INPUT"?(e.getAttribute("type")||"text").toLowerCase()==="checkbox"?"checked":"value":t==="TEXTAREA"||t==="SELECT"?"value":hn[t]?hn[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function pn(e,t){let r=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),i=yt(e),s=`${gn(r,n)}[data-hcms-field="${Le(t)}"]`;return r==="INPUT"&&n==="radio"?`${s}:checked@value`:i?`${s}@${i}`:s}function wo(e){let t=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),n=yt(e),o=`${gn(t,r)}[data-hcms-field]`;return t==="INPUT"&&r==="radio"?`${o}:checked@value`:n?`${o}@${n}`:o}function gn(e,t){return e==="INPUT"?t?`input[type="${t}"]`:"input":e==="TEXTAREA"?"textarea":e==="SELECT"?"select":e==="IMG"?"img":e==="A"?"a":':not([data-hcms-shape="scalar"]):not([data-hcms-shape="object"]):not([data-hcms-shape="object-array"]):not([data-hcms-shape="scalar-array"])'}function Le(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var fn=new Set(["__proto__","constructor","prototype"]);function vt(e,t){return r(e,[]);function r(c,u){let g=Ae(c);if(g==="scalar")return n(c,u);if(g==="scalar-array")return i(c,u);if(g==="object-array")return o(c,u);if(g==="object"){let d=Object.create(null);for(let[k,y]of Object.entries(c)){if(fn.has(k))throw new Error(`hypercms: rule key "${k}" is forbidden at "${u.join(".")||"<root>"}"`);d[k]=r(y,[...u,k])}return d}return null}function n(c,u){let g=u.length?u[u.length-1]:null,d=typeof g=="string"?g:"__value",k=l(u,d);if(k)return pn(k,d);let y=a(Qe(c,t,u,e),d);return y?pn(y,d):`input[data-hcms-field="${Le(d)}"]@value`}function i(c,u){let g=ft(c,u,t),d=g&&a(g.item,null)||a("@scalar-array-item",null),k=d?wo(d):"input[data-hcms-field]@value";return[s(u,"[data-hcms-array-item]"),k]}function o(c,u){let[,g]=c,d=[...u,"*"],k=s(u,"[data-hcms-card]");if(g&&typeof g=="object"&&!Array.isArray(g)){let y=Object.create(null);for(let[N,q]of Object.entries(g)){if(fn.has(N))throw new Error(`hypercms: rule key "${N}" is forbidden at "${d.join(".")}"`);y[N]=r(q,[...d,N])}return[k,y]}return[k,r(g,[...d,0])]}function s(c,u){let g=c.length?c[c.length-1]:"",d=c.some(N=>N==="*"),k=c.join(".");return`${d?`[data-hcms-field="${Le(g)}"]`:`[data-hcms-path="${Le(k)}"]`} > .hcms-array-items > ${u}`}function a(c,u){if(!t)return null;let g=ce(t,c);if(!g)return null;let d=g.content||g;if(u){let k=d.querySelector(`[data-hcms-field="${Le(u)}"]`);if(k)return k}return d.querySelector("[data-hcms-field]")}function l(c,u){if(!t)return null;let g=c.map(y=>typeof y=="number"?"*":y).join("."),k=[c.join("."),g];for(let y=c.length-1;y>=0;y--){let N=c.slice(0,y).map(q=>typeof q=="number"?"*":q);N.push("*"),k.push(N.join("."))}for(let y of k){if(!y)continue;let N=ce(t,y);if(!N||!et(N))continue;let q=N.content||N,H=q.querySelector(`[data-hcms-field="${Le(u)}"]`)||q.querySelector("[data-hcms-field]");if(H)return H}return null}}function tr(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],r=t.split("/").pop()||t;try{return decodeURIComponent(r)}catch{return r}}function xt({pageRules:e,formRules:t,data:r,doc:n}){let i=n.createDocumentFragment(),o=rr(e,[],r,n,e);return o&&i.appendChild(o),i}function kn({shape:e,itemShape:t,pathArr:r,data:n,doc:i,itemKey:o,pageRules:s}){if(e==="object-array-item")return vn(t,r,n,i,s);if(e==="scalar-array-item")return xn(r,n,i,o||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function rr(e,t,r,n,i){let o=Ae(e);return o==="scalar"?_o(e,t,r,n,i):o==="object"?Co(e,t,r,n,i):o==="object-array"?To(e,t,r,n,i):o==="scalar-array"?Ro(e,t,r,n):null}function _o(e,t,r,n,i){let o=Qe(e,n,t,i),s=Ie(t,o,n);if(!s)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let a=cn(e,n,t,i);a==="@number"&&o==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "@number" but its value isn't a plain number; rendering a text input so the value is preserved`),(a==="@checkbox"||a==="@toggle")&&o==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "${a}" but its value isn't true/false; rendering a text input so the value is preserved`),yn(s,a===o?a:null,t);let l=je(s,n);Fe(l,t);let c=s.getAttribute?.("data-hcms-tpl");if((o==="@select"||o==="@radio")&&c===o&&Ao(l,e,t,r,n,o,i),o==="@image"&&c==="@image"){let u=un(e,n,t,i);u!=null&&!l.hasAttribute("data-hcms-crop")&&l.setAttribute("data-hcms-crop",u)}return Oo(l,he(t)),wt(l,he(t)),_t(l,he(t)),En(l,r),o==="@file"&&Eo(l),l}function yn(e,t,r){if(!t)return;let n=e.getAttribute?.("data-hcms-tpl");n&&n!==t&&console.info(`[hypercms] field "${r.join(".")}" declares component "${t}" but custom template "${n}" wins`)}function Ao(e,t,r,n,i,o,s){let a=dn(t,i,r,s),l=a?[...a]:[],c=n==null?"":String(n);if(c!==""&&!l.includes(c)&&l.unshift(c),!a&&(So(e,"data-hcms-options required (space-separated values)"),l.length===0)){e.querySelector(".mirk-radio")?.remove();return}if(o==="@select"){let d=e.querySelector("select[data-hcms-field]");if(!d)return;for(let k of l){let y=i.createElement("option");y.value=k,y.textContent=mt(k),d.appendChild(y)}return}let u=e.querySelector(".mirk-radio");if(!u||!u.parentNode)return;let g=nr(r.join("."));for(let d of l){let k=u.cloneNode(!0),y=k.querySelector('input[type="radio"]');y&&(y.value=d,y.name=g);let N=k.querySelector(".mirk-radio__label");N&&(N.textContent=mt(d)),u.parentNode.insertBefore(k,u)}u.remove()}function nr(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function So(e,t){let r=e.querySelector?e.querySelector(".hcms-error"):null;r&&(r.textContent=t,r.hidden=!1)}function Eo(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=tr(t.getAttribute("href")))}function Co(e,t,r,n,i){let o=Ie(t,"@object",n);if(!o)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let s=je(o,n);if(Fe(s,t),wt(s,he(t)),_t(s,he(t)),et(o))return Tn(s,e,t),Cn(s,e,r),s;let a=At(s,".hcms-object-fields",o,t);for(let[l,c]of Object.entries(e)){let u=r==null?null:r[l],g=rr(c,[...t,l],u,n,i);g&&a.appendChild(g)}return s}function To(e,t,r,n,i){let o=Ie(t,"@object-array",n);if(!o)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let s=je(o,n);Fe(s,t),wt(s,he(t)),_t(s,he(t)),_n(s,o),Sn(s,o,t);let a=At(s,".hcms-array-items",o,t),[,l]=e;return(Array.isArray(r)?r:[]).forEach((u,g)=>{let d=vn(l,[...t,g],u,n,i);d&&a.appendChild(d)}),An(s),s}function vn(e,t,r,n,i){let o=wn(t,"object-array-item",n);if(!o)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let s=je(o,n);if(s.setAttribute("data-hcms-card",""),s.classList.contains("hcms-card")||s.classList.add("hcms-card"),Fe(s,t),et(o))return e&&typeof e=="object"&&!Array.isArray(e)&&(Tn(s,e,t),Cn(s,e,r)),s;let a=At(s,".hcms-card-fields",o,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[l,c]of Object.entries(e)){let u=r==null?null:r[l],g=rr(c,[...t,l],u,n,i);g&&a.appendChild(g)}return s}function Ro(e,t,r,n){let i=pt(e,n),o=ft(e,t,n),s=i?i.array:"@scalar-array",a=Ie(t,s,n);if(!a)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);yn(a,i?i.array:null,t);let l=je(a,n);Fe(l,t),wt(l,he(t)),_t(l,he(t)),_n(l,a),Sn(l,a,t),o&&l.setAttribute("data-hcms-item-tpl",o.item);let c=At(l,".hcms-array-items",a,t);return(Array.isArray(r)?r:[]).forEach((g,d)=>{let k=xn([...t,d],g,n,o?o.item:null);k&&c.appendChild(k)}),An(l),l}function xn(e,t,r,n){let i=wn(e,"scalar-array-item",r,n);if(!i)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let o=je(i,r);return o.setAttribute("data-hcms-array-item",""),o.classList.contains("hcms-array-item")||o.classList.add("hcms-array-item"),Fe(o,e),En(o,t),o}function wn(e,t,r,n){let i=e.map(o=>typeof o=="number"?"*":o).join(".");return ce(r,i)||n&&ce(r,n)||ce(r,"@"+t)}function je(e,t){let r=e.content||e,n=t.createElement("div");return n.appendChild(r.cloneNode(!0)),n.firstElementChild||n}function Fe(e,t){e.setAttribute("data-hcms-path",t.join("."))}function Oo(e,t){let r=t==null?"":String(t);if(e.matches&&e.matches("[data-hcms-field]")){e.getAttribute("data-hcms-field")||e.setAttribute("data-hcms-field",r);return}(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(i=>{i.getAttribute("data-hcms-field")||i.setAttribute("data-hcms-field",r)})}function wt(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function _t(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(n=>{(n.textContent||"").trim()===""&&(n.textContent=mt(String(t)))})}function _n(e,t){["data-hcms-no-add","data-hcms-no-remove","data-hcms-no-reorder"].forEach(r=>{t.hasAttribute(r)&&e.setAttribute(r,"")}),["data-hcms-min-items","data-hcms-max-items"].forEach(r=>{t.hasAttribute(r)&&e.setAttribute(r,t.getAttribute(r))})}function An(e){let t=e.querySelector?e.querySelector(".hcms-array-items"):null;if(!t)return;let r=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),n=r.length,i=bn(e,"data-hcms-max-items"),o=bn(e,"data-hcms-min-items"),s=e.hasAttribute("data-hcms-no-add"),a=e.hasAttribute("data-hcms-no-remove"),l=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector('[data-hcms-action="add"]');c&&(c.hidden=s||i!=null&&n>=i),r.forEach((u,g)=>{let d=u.querySelector('[data-hcms-action="remove"]');d&&(d.hidden=a||o!=null&&n<=o);let k=u.querySelector('[data-hcms-action="move-up"]');k&&(k.hidden=l||g===0);let y=u.querySelector('[data-hcms-action="move-down"]');y&&(y.hidden=l||g===n-1)})}function bn(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function Sn(e,t,r){if(e.hasAttribute("data-hcms-no-reorder")||t.hasAttribute("data-hcms-no-reorder"))return;let n=e.querySelector(".hcms-array-items");if(!n)return;let i="hcms-"+r.join(".");n.setAttribute("sortable",i),n.setAttribute("onsorted","hypercmsCommit && hypercmsCommit()")}function he(e){return e.length?e[e.length-1]:null}function En(e,t){let r=Mo(e);if(r.length!==0)for(let n of r)Rn(n,t)}function Mo(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&No(e)&&t.push(e),(e.querySelectorAll?e.querySelectorAll("input[data-hcms-field], textarea[data-hcms-field], select[data-hcms-field], img[data-hcms-field], a[data-hcms-field], [contenteditable][data-hcms-field]"):[]).forEach(n=>t.push(n)),t}function No(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function Cn(e,t,r){(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(i=>{let o=i.getAttribute("data-hcms-field");if(!o)return;if(!t||typeof t!="object"||!(o in t)){console.warn(`[hypercms] inline template field "${o}" is not in the rule shape; ignoring`);return}let s=r==null?null:r[o];Rn(i,s)})}function Tn(e,t,r){if(!e.querySelectorAll)return;e.querySelectorAll("[data-hcms-field]").forEach(i=>{let o=i.getAttribute("data-hcms-field");if(!o||t&&typeof t=="object"&&!(o in t))return;let s=[...r,o].join(".");i.setAttribute("data-hcms-path",s)})}function At(e,t,r,n){if(!e.querySelector)return e;let i=e.querySelector(t);if(i)return i;let o=r?.getAttribute?.("data-hcms-tpl")||n.join(".");throw new Error(`hypercms: template "${o}" is in slotted mode but has no ${t} element`)}function Rn(e,t){let r=yt(e),n=(e.tagName||"").toUpperCase(),i=(e.getAttribute("type")||"").toLowerCase();if(n==="INPUT"&&i==="radio"){e.checked=e.value!=null&&String(e.value)===String(t??"");return}if(r==="checked"){e.checked=t===!0||t==="true";return}if(r){e[r]=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var On={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function Mn(e,t,r,n={}){let{observerHandle:i,shellRoot:o,structural:s,structuralPath:a}=n;i?.pause?.();try{if(!s)try{return re.apply(e,t,r,On),{ok:!0}}catch(g){return{ok:!1,error:g}}let l=Io(e,t,a),c=l?jo(l):null,u=l?null:qo(e,o);try{return re.apply(e,t,r,On),{ok:!0}}catch(g){return c?Fo(l,c):u&&Do(e,o,u),{ok:!1,error:g}}}finally{i?.resume?.()}}function Io(e,t,r){if(!r||!e)return null;let n=me(r),i=[],o=t;for(let s of n){if(typeof o=="string"||o==null||Array.isArray(o))break;if(typeof o=="object"&&s in o){if(i.push(s),o=o[s],Array.isArray(o)||typeof o=="string"&&o.endsWith("[]"))break}else return null}return!Array.isArray(o)&&!(typeof o=="string"&&o.endsWith("[]"))?null:Lo(e,t,i)}function Lo(e,t,r){if(r.length===0)return null;let n=e,i=t;for(let o=0;o<r.length;o++){let s=r[o];if(!i||typeof i!="object"||Array.isArray(i))return null;let a=i[s];if(a==null)return null;if(o===r.length-1){if(Array.isArray(a)){let[l]=a;return n.querySelector?.(l)?.parentElement||null}if(typeof a=="string"&&a.endsWith("[]")){let l=a.slice(0,-2);return n.querySelector?.(l)?.parentElement||null}return null}i=a}return null}function jo(e){let t=[];for(let r of Array.from(e.childNodes))t.push(r.cloneNode(!0));return t}function Fo(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);for(let r of t)e.appendChild(r)}function qo(e,t){let r=[];for(let n of Array.from(e.childNodes))n===t||t&&n.contains?.(t)||r.push(n.cloneNode(!0));return r}function Do(e,t,r){for(let i of Array.from(e.childNodes))i===t||t&&i.contains?.(t)||e.removeChild(i);let n=$o(e,t);for(let i of r)e.insertBefore(i,n||null)}function $o(e,t){if(!t)return null;for(let r of Array.from(e.childNodes))if(r===t||r.contains?.(t))return r;return null}var Po={Mutation:(e,t)=>e?.Mutation??t?.Mutation,undo:(e,t)=>e?.undo??t?.undo,onPrepareForSave:(e,t)=>e?.addDocumentTransform??t?.onPrepareForSave,consent:(e,t)=>e?.confirm??t?.consent,RichClay:(e,t)=>e?.RichClay??t?.RichClay,quickcrop:(e,t)=>e?.quickcrop??t?.quickcrop,upload:(e,t)=>e?.upload??(t?.uploadFileBasic?Uo(t.uploadFileBasic):null)},Bo={402:"payment-required",413:"too-large",415:"unsupported-type",401:"unauthorized",403:"forbidden",404:"not-found"},ir=()=>({ok:!1,msg:"Upload cancelled",msgType:"skipped",code:"aborted",uploads:[]});function Uo(e){return async function(r,{onProgress:n,signal:i}={}){if(i?.aborted)return ir();try{let o=await e(r,{onProgress:a=>{n?.({loaded:null,total:null,percent:a})}});if(i?.aborted)return ir();let s=o&&o.uploads||[];return typeof s[0]?.url!="string"?{ok:!1,msg:"The host accepted the file but did not say where it put it",msgType:"error",code:"bad-response",uploads:[]}:{ok:!0,msg:o.msg||"Uploaded",msgType:o.msgType||"success",code:o.code||null,uploads:s}}catch(o){if(i?.aborted)return ir();let s={};try{s=JSON.parse(o?.response||"{}")}catch{s={}}let a=s.code||Bo[o?.status]||"error";return{ok:!1,msg:o&&o.message||"Upload failed",msgType:"error",code:a,uploads:[]}}}}function ne(e,t){let r=Po[e];if(!r)throw new Error(`hypercms: unknown platform capability "${e}"`);let n=t||(typeof window<"u"?window:null);return n&&r(n.clay,n.hyperclay)||null}var Nn=["clay:mutation-ready","hyperclay:mutation-ready"],In=["clay:sync-applied","hyperclay:livesync-applied"];function or(e,t,r){let n=null,i=o=>{n!==null&&n!==o.type||(n=o.type,queueMicrotask(()=>{n=null}),r(o))};for(let o of t)e.addEventListener(o,i);return()=>{for(let o of t)e.removeEventListener(o,i)}}function St(e,t){if(!t||e==null)return e;return r(e);function r(n){if(typeof n=="string"){if(n.endsWith("[]")||Z(n)!==-1)return n;let i=null;try{i=t.querySelector(n)}catch{return n}return i&&i.children.length>0?n+"@innerHTML":n}if(Array.isArray(n))return n;if(n&&typeof n=="object"){let i=Object.create(null);for(let[o,s]of Object.entries(n))i[o]=r(s);return i}return n}}function sr(e){if(!e||e.tagName!=="TEXTAREA")return;let t=e.ownerDocument.defaultView||(typeof window<"u"?window:null);t&&t.CSS&&t.CSS.supports&&t.CSS.supports("field-sizing: content")||(e.style.height="auto",e.style.height=e.scrollHeight+"px")}function qe(e,t){if(!e||!e.querySelectorAll)return;e.querySelectorAll("textarea[data-hcms-field]").forEach(sr);let r=t&&t.defaultView||(typeof window<"u"?window:null),n=r&&r.richclay&&r.richclay.RichClay||ne("RichClay",r)||(r&&typeof r.RichClay=="function"?r.RichClay:null);n&&e.querySelectorAll("[contenteditable][data-hcms-field]").forEach(i=>{if(i.__hcmsRichclay)return;let o;try{o=new n(i,{inline:!0,hyperclay:!1,toolbar:["bold","italic","link","undo","redo"]})}catch(a){console.warn("[hypercms] richclay activation failed; field stays plain contenteditable",a);return}i.__hcmsRichclay=o;let s=o&&o.squire;s&&typeof s.addEventListener=="function"&&s.addEventListener("input",()=>{let a=r&&r.Event||Event;i.dispatchEvent(new a("input",{bubbles:!0}))})})}var ar=new WeakSet;function Pe(e,t){let r=ne("undo");if(!r)return t();r.pause();try{let n=t();return n&&n.ok?r.commitCaptured(e):r.discardCaptured(),n}finally{r.resume()}}function Tt(e){let t=ne("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function Dn(e){let{formRoot:t}=e;if(!t||ar.has(t))return;ar.add(t);let r=s=>{let a=s.target;!a||!a.closest||a.closest("[data-hcms-form-root]")&&a.matches("input, textarea, select, [contenteditable][data-hcms-field]")&&(a.tagName==="TEXTAREA"&&sr(a),!a.matches('input[type="file"]')&&(!a.closest("[data-hcms-field]")&&!a.hasAttribute?.("data-hcms-field")||Ln(a,e)))},n=s=>{let a=s.target;if(!(!a||!a.closest)&&a.closest("[data-hcms-form-root]")){if(a.matches('input[type="file"][data-hcms-upload]')){Yo(a,e);return}a.matches('input[type="checkbox"], input[type="radio"], select')&&Ln(a,e)}},i=s=>{let a=s.target;if(!a||!a.closest)return;let l=a.closest("[data-hcms-action]");if(!l)return;let c=l.getAttribute("data-hcms-action");if(c==="add"||c==="remove"||c==="move-up"||c==="move-down"||c==="clear-upload"){if(!l.closest("[data-hcms-form-root]"))return}else if(c==="close"&&!l.closest("[data-hcms-shell]"))return;if(c==="add"){let u=l.closest("[data-hcms-path]");if(!u)return;let g=u.getAttribute("data-hcms-path");cr(g,e)}else if(c==="remove"){let u=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!u)return;os(u,e)}else if(c==="move-up"||c==="move-down"){let u=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!u)return;ns(u,c==="move-up"?-1:1,e)}else c==="clear-upload"?es(l,e):c==="close"&&e.onCloseRequested?.()},o=t.ownerDocument;o.addEventListener("input",r,!0),o.addEventListener("change",n,!0),o.addEventListener("click",i,!0),e.detachEvents=()=>{o.removeEventListener("input",r,!0),o.removeEventListener("change",n,!0),o.removeEventListener("click",i,!0),ar.delete(t)}}var zo=new Set(["value","checked"]);function Ho(e,t){if(!t)return null;let r=me(t);if(r.some(l=>typeof l=="number"||l==="*"))return null;let n=_e(e.pageRules,r);if(typeof n!="string")return null;let i=re.ruleAttrIndex(n);if(i===-1)return null;let o=n.slice(i+1);if(!zo.has(o))return null;let s=n.slice(0,i),a=s?e.pageRoot.querySelector(s):e.pageRoot;return a?{el:a,prop:o,oldValue:a[o]}:null}function Ln(e,t){let n=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",i=Ho(t,n);if(ue(ae(t),{path:n,structural:!1},t),i){let o=ne("undo");o&&typeof o.recordValue=="function"&&o.recordValue(i.el,{prop:i.prop,oldValue:i.oldValue,newValue:i.el[i.prop]})}}var Vo={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function Wo(e,t){let r=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(r==null)return{file:e};let n=ne("quickcrop");if(typeof n!="function")return{file:e};try{let i=typeof window<"u"&&(window.clay?.modal??window.themodal)||"auto",o=await n(e,{aspect:Ko(r),modal:i,...Vo});return o===null?null:{file:Go(o.blob,e.name),dataURL:o.dataURL}}catch(i){return $e(t,i&&i.message||"Crop failed"),null}}function Ko(e){let t=String(e??"").trim().toLowerCase();if(t===""||t==="free")return null;let r=t.match(/^(\d+(?:\.\d+)?)\s*[:/]\s*(\d+(?:\.\d+)?)$/);if(!r)return null;let n=parseFloat(r[1]),i=parseFloat(r[2]);return!n||!i?null:n/i}function Go(e,t){let r=e.type==="image/webp"?".webp":e.type==="image/jpeg"?".jpg":".png",n=String(t||"image").replace(/\.[^.]+$/,"");try{return new File([e],n+r,{type:e.type})}catch{return e}}var Jo=new Set(["unsupported","payment-required"]);async function Yo(e,t){let r=e.files&&e.files[0];if(!r)return;let n=e.closest("[data-hcms-path]");if(!n)return;let i=n.getAttribute("data-hcms-path")||"";$e(n,null);let o=await Wo(r,n);if(!o||t.closed){ye(e);return}let s=o.file,a=o.dataURL||null,l=ne("upload");if(typeof l!="function")return lr(e,n,t,i,await jn(s,a,n),s);Pn(n,a),Fn(n,0);let c=Zo(t),u;try{u=await l(s,{signal:c?.signal,onProgress:({percent:d})=>Fn(n,d)})}finally{Qo(t,c),rs(n)}if(t.closed){ye(e);return}if(u.code==="aborted"){ye(e);return}if(u.ok)return lr(e,n,t,i,u.uploads[0].url,s);if(!Jo.has(u.code)){$e(n,u.msg||"Upload failed"),t.dispatch?.("hcms:error",{error:new Error(u.msg||"Upload failed"),code:u.code,path:i}),ye(e);return}let g=u.code==="payment-required"?"This file is stored in the page. Add a paid plan to upload files.":null;return lr(e,n,t,i,await jn(s,a,n),s,g)}function lr(e,t,r,n,i,o,s=null){if(r.closed){ye(e);return}if(Pn(t,null),$e(t,null),!i){ye(e);return}$n(t,i,o.name),ue(ae(r),{path:n,structural:!1},r),s&&$e(t,s,"info"),ye(e)}async function jn(e,t,r){return t||await Xo(e,r)}function Xo(e,t){let r=t?.ownerDocument?.defaultView?.FileReader||globalThis.FileReader;return r?new Promise(n=>{let i=new r;i.onload=()=>n(typeof i.result=="string"?i.result:""),i.onerror=()=>n("");try{i.readAsDataURL(e)}catch{n("")}}):Promise.resolve("")}function Zo(e){if(typeof AbortController!="function")return null;let t=new AbortController;return(e.uploads||(e.uploads=new Set)).add(t),t}function Qo(e,t){t&&e.uploads?.delete(t)}function es(e,t){let r=e.closest("[data-hcms-path]");if(!r)return;let n=r.getAttribute("data-hcms-path")||"";$n(r,"","");let i=r.querySelector('input[type="file"][data-hcms-upload]');i&&ye(i),$e(r,null),ue(ae(t),{path:n,structural:!1},t)}function ts(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function $n(e,t,r){let n=ts(e);if(!n)return;let i=(n.tagName||"").toUpperCase();i==="IMG"?n.src=t||"":i==="A"&&(n.href=t||"",n.textContent=t?r||tr(t):"")}function ye(e){try{e.value=""}catch{}}function Pn(e,t){let r=e.querySelector?e.querySelector(".mirk-image__frame"):null;r&&(t?r.style.backgroundImage=`url("${t.replace(/"/g,"%22")}")`:r.style.removeProperty("background-image"))}function Fn(e,t){let r=Math.max(0,Math.min(100,Number(t)||0));e.setAttribute("data-hcms-uploading",""),e.style?.setProperty?.("--hcms-upload-progress",`${r}%`)}function rs(e){e.removeAttribute("data-hcms-uploading"),e.style?.removeProperty?.("--hcms-upload-progress")}function $e(e,t,r="error"){let n=e.querySelector?e.querySelector(":scope > .hcms-error"):null;n&&(n.classList.toggle("hcms-error--info",!!t&&r==="info"),t?(n.textContent=t,n.hidden=!1):(n.textContent="",n.hidden=!0))}function cr(e,t){let{formRoot:r,pageRules:n}=t,i=r.querySelector(`[data-hcms-path="${ms(e)}"]`);if(!i)throw new Error(`hypercms: no element at path "${e}"`);let o=i.querySelector(".hcms-array-items");if(!o)throw new Error(`hypercms: array container missing .hcms-array-items at "${e}"`);let s=me(e),a=cs(n,s),l=Array.isArray(a),c=typeof a=="string"&&a.endsWith("[]");if(!l&&!c)throw new Error(`hypercms: path "${e}" is not an array`);let u=Ct(i,"data-hcms-max-items"),g=o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(i.hasAttribute("data-hcms-no-add")||u!=null&&g.length>=u)return;let d=g.length,k=l?a[1]:a.replace(/\[\]$/,""),y=Ze(l?k:"string"),N=kn({shape:l?"object-array-item":"scalar-array-item",itemShape:k,pathArr:[...s,d],data:y,doc:t.doc,itemKey:i.getAttribute("data-hcms-item-tpl")||null,pageRules:n});return o.appendChild(N),qe(N,t.doc),ur(i),Pe(`Add ${e}`,()=>ue(ae(t),{path:e,structural:!0},t))}function ns(e,t,r){let n=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!n||n.hasAttribute("data-hcms-no-reorder"))return;let i=n.querySelector(".hcms-array-items");if(!i)return;let o=Array.from(i.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),s=o.indexOf(e);if(s<0)return;let a=s+t;if(a<0||a>=o.length)return;let l=e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`);return t<0?i.insertBefore(e,o[a]):i.insertBefore(e,o[a].nextSibling),hr(i),ur(n),l&&typeof l.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),Pe(`Reorder ${n.getAttribute("data-hcms-path")||""}`,()=>ue(ae(r),{path:n.getAttribute("data-hcms-path")||"",structural:!0},r))}var Et="Delete this item?";function is(e,t){let r=e&&e.getAttribute("data-hcms-confirm-remove");if(r!=null)return/^(off|false|no|0)$/i.test(r.trim())?null:r||Et;let n=t&&t.confirmRemove;return n===!1?null:typeof n=="string"?n||Et:n===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?Et:null}function os(e,t){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),n=is(r,t);if(n==null)return De(e,t);let i=ne("consent")||typeof window<"u"&&window.consent;typeof i=="function"?Promise.resolve(i(n)).then(()=>De(e,t),()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(n)&&De(e,t):De(e,t)}function De(e,t){let r=e.getAttribute("data-hcms-path")||"",n=e.parentElement,i=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!i?.hasAttribute("data-hcms-no-remove")){if(i){let o=Ct(i,"data-hcms-min-items"),s=i.querySelector(".hcms-array-items"),a=s?s.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]").length:0;if(o!=null&&a<=o)return}return e.remove(),n&&hr(n),i&&ur(i),Pe(`Remove ${r}`,()=>ue(ae(t),{path:r,structural:!0},t))}}function ue(e,t,r){let n=tt(e);if(n===r.lastFingerprint)return{ok:!0,skipped:!0};let i=Mn(r.pageRoot,r.pageRules,e,{observerHandle:r.observerHandle,shellRoot:r.shellRoot,structural:!!t.structural,structuralPath:t.path||null});return i.ok?(r.lastFingerprint=n,r.lastData=e,qn(r,null),r.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),r.onChange?.(e,t)):(qn(r,ls(i.error,t.path)),r.dispatch?.("hcms:error",{error:i.error,attemptedData:e}),r.onError?.(i.error)),i}function ae(e){let t=re.extract(e.formRoot,e.formRules);return ve(t,e.formRules)}function ve(e,t){if(t==null||e==null)return e;if(typeof t=="string")return t.endsWith("@checked")?e===!0||e==="true":e;if(Array.isArray(t)){if(!Array.isArray(e))return e;let[,r]=t;return e.map(n=>ve(n,r))}if(typeof t=="object"){if(typeof e!="object"||Array.isArray(e))return e;let r={};for(let[n,i]of Object.entries(t))r[n]=ve(e[n],i);return r}return e}function qn(e,t){e.lastErrors=t&&t.length?t:null,dr(e)}function dr(e){if(ss(e),e.errorEl&&(e.errorEl.textContent="",e.errorEl.hidden=!0),!e.lastErrors)return;let t=[];for(let{message:r,path:n}of e.lastErrors){if(n!=null&&n!==""){let i=as(e.formRoot,n);if(i){i.textContent=i.textContent?`${i.textContent}
151
151
  ${r}`:r,i.hidden=!1;continue}}t.push(r)}t.length&&e.errorEl&&(e.errorEl.textContent=t.join(`
152
- `),e.errorEl.hidden=!1)}function Jo(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function Yo(e,t){if(!e)return null;let r=t.split(".");for(;r.length>0;){let n=r.join("."),i=typeof CSS<"u"&&CSS.escape?CSS.escape(n):n.replace(/[^a-zA-Z0-9_\-.*]/g,a=>"\\"+a),o=e.querySelector(`[data-hcms-path="${i}"]`);if(o){for(let a of o.children)if(a.classList&&a.classList.contains("hcms-error"))return a}r.pop()}return null}function Xo(e,t){return e?e.name==="EmptyListInsert"?[{message:"Add a seed item in HTML first.",path:t}]:e.name==="ShapeMismatch"&&Array.isArray(e.mismatches)&&e.mismatches.length?e.mismatches.map(r=>({message:`Shape mismatch: expected ${r.expected}, got ${r.got}`,path:r.path})):[{message:e.message||String(e),path:t}]:[{message:"unknown error",path:t}]}function Zo(e,t){let r=e;for(let n of t){if(r==null||typeof r=="string")return;if(Array.isArray(r)){if(typeof n!="number"&&n!=="*")return;r=r[1];continue}if(typeof r=="object"){if(typeof n=="number"||!(n in r))return;r=r[n];continue}return}return r}function Ct(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function cr(e){if(!e)return;let t=e.querySelector(".hcms-array-items");if(!t)return;let r=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),n=r.length,i=Ct(e,"data-hcms-max-items"),o=Ct(e,"data-hcms-min-items"),a=e.hasAttribute("data-hcms-no-add"),s=e.hasAttribute("data-hcms-no-remove"),l=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');c&&(c.hidden=a||i!=null&&n>=i),r.forEach((d,b)=>{let u=d.querySelector('[data-hcms-action="remove"]');u&&(u.hidden=s||o!=null&&n<=o);let k=d.querySelector('[data-hcms-action="move-up"]');k&&(k.hidden=l||b===0);let y=d.querySelector('[data-hcms-action="move-down"]');y&&(y.hidden=l||b===n-1)})}function ur(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>dr(t))}function dr(e){let t=e.querySelectorAll?Array.from(e.querySelectorAll('input[type="radio"][data-hcms-field]'),n=>[n,n.checked]):[],r=0;for(let n of e.children){if(!n.matches?.("[data-hcms-card], [data-hcms-array-item]"))continue;let i=n.getAttribute("data-hcms-path");if(!i)continue;let o=i.split(".");o[o.length-1]=String(r);let a=o.join(".");a!==i&&Qo(n,i,a),r++}for(let[n,i]of t)n.checked!==i&&(n.checked=i)}function Qo(e,t,r){let n=e.querySelectorAll("[data-hcms-path]");e.setAttribute("data-hcms-path",r);for(let i of n){let o=i.getAttribute("data-hcms-path");o===t?i.setAttribute("data-hcms-path",r):o&&o.startsWith(t+".")&&i.setAttribute("data-hcms-path",r+o.slice(t.length))}es(e)}function es(e){for(let t of e.querySelectorAll('input[type="radio"][data-hcms-field]')){if(!t.name||!t.name.startsWith("hcms-"))continue;let r=t.closest("[data-hcms-path]");r&&(t.name=nr(r.getAttribute("data-hcms-path")))}}function tt(e){return JSON.stringify(e,(t,r)=>{if(r&&typeof r=="object"&&!Array.isArray(r)){let n=Object.create(null);for(let i of Object.keys(r).sort())n[i]=r[i];return n}return r})}function ts(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var ls={},Rt="hcms-shell-styles",rs="hcms-bundled-styles-installed",ns='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',Be=new WeakSet,mr="";function qn(e){mr=e}var is=0;function Fn(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}function Dn({mountTo:e,side:t="right",overlay:r=!1,showSaveButton:n=!1,title:i="Page content",eyebrow:o="Edit",theme:a=null,doc:s}){$n(s);let l=`hcms-shell-title-${++is}`,c=s.createElement("div");c.setAttribute("data-hcms-shell",""),c.setAttribute("save-remove",""),c.setAttribute("save-ignore",""),c.setAttribute("tabindex","-1"),c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby",l);let d=a==="dark"?" dark":a==="light"?" light":"";c.className="hcms-shell pixel-quiet hcms-side-"+t+(r?" hcms-overlay":"")+d;let b=Fn(i),u=Fn(o);c.innerHTML=`
152
+ `),e.errorEl.hidden=!1)}function ss(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function as(e,t){if(!e)return null;let r=t.split(".");for(;r.length>0;){let n=r.join("."),i=typeof CSS<"u"&&CSS.escape?CSS.escape(n):n.replace(/[^a-zA-Z0-9_\-.*]/g,s=>"\\"+s),o=e.querySelector(`[data-hcms-path="${i}"]`);if(o){for(let s of o.children)if(s.classList&&s.classList.contains("hcms-error"))return s}r.pop()}return null}function ls(e,t){return e?e.name==="EmptyListInsert"?[{message:"Add a seed item in HTML first.",path:t}]:e.name==="ShapeMismatch"&&Array.isArray(e.mismatches)&&e.mismatches.length?e.mismatches.map(r=>({message:`Shape mismatch: expected ${r.expected}, got ${r.got}`,path:r.path})):[{message:e.message||String(e),path:t}]:[{message:"unknown error",path:t}]}function cs(e,t){let r=e;for(let n of t){if(r==null||typeof r=="string")return;if(Array.isArray(r)){if(typeof n!="number"&&n!=="*")return;r=r[1];continue}if(typeof r=="object"){if(typeof n=="number"||!(n in r))return;r=r[n];continue}return}return r}function Ct(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function ur(e){if(!e)return;let t=e.querySelector(".hcms-array-items");if(!t)return;let r=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),n=r.length,i=Ct(e,"data-hcms-max-items"),o=Ct(e,"data-hcms-min-items"),s=e.hasAttribute("data-hcms-no-add"),a=e.hasAttribute("data-hcms-no-remove"),l=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');c&&(c.hidden=s||i!=null&&n>=i),r.forEach((u,g)=>{let d=u.querySelector('[data-hcms-action="remove"]');d&&(d.hidden=a||o!=null&&n<=o);let k=u.querySelector('[data-hcms-action="move-up"]');k&&(k.hidden=l||g===0);let y=u.querySelector('[data-hcms-action="move-down"]');y&&(y.hidden=l||g===n-1)})}function mr(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>hr(t))}function hr(e){let t=e.querySelectorAll?Array.from(e.querySelectorAll('input[type="radio"][data-hcms-field]'),n=>[n,n.checked]):[],r=0;for(let n of e.children){if(!n.matches?.("[data-hcms-card], [data-hcms-array-item]"))continue;let i=n.getAttribute("data-hcms-path");if(!i)continue;let o=i.split(".");o[o.length-1]=String(r);let s=o.join(".");s!==i&&ds(n,i,s),r++}for(let[n,i]of t)n.checked!==i&&(n.checked=i)}function ds(e,t,r){let n=e.querySelectorAll("[data-hcms-path]");e.setAttribute("data-hcms-path",r);for(let i of n){let o=i.getAttribute("data-hcms-path");o===t?i.setAttribute("data-hcms-path",r):o&&o.startsWith(t+".")&&i.setAttribute("data-hcms-path",r+o.slice(t.length))}us(e)}function us(e){for(let t of e.querySelectorAll('input[type="radio"][data-hcms-field]')){if(!t.name||!t.name.startsWith("hcms-"))continue;let r=t.closest("[data-hcms-path]");r&&(t.name=nr(r.getAttribute("data-hcms-path")))}}function tt(e){return JSON.stringify(e,(t,r)=>{if(r&&typeof r=="object"&&!Array.isArray(r)){let n=Object.create(null);for(let i of Object.keys(r).sort())n[i]=r[i];return n}return r})}function ms(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var ys={},Rt="hcms-shell-styles",hs="hcms-bundled-styles-installed",ps='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',Be=new WeakSet,pr="";function Un(e){pr=e}var fs=0;function Bn(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}function zn({mountTo:e,side:t="right",overlay:r=!1,showSaveButton:n=!1,title:i="Page content",eyebrow:o="Edit",theme:s=null,doc:a}){Hn(a);let l=`hcms-shell-title-${++fs}`,c=a.createElement("div");c.setAttribute("data-hcms-shell",""),c.setAttribute("save-remove",""),c.setAttribute("save-ignore",""),c.setAttribute("tabindex","-1"),c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby",l);let u=s==="dark"?" dark":s==="light"?" light":"";c.className="hcms-shell pixel-quiet hcms-side-"+t+(r?" hcms-overlay":"")+u;let g=Bn(i),d=Bn(o);c.innerHTML=`
153
153
  <div class="hcms-shell-minibar" aria-hidden="true">
154
- <span class="hcms-shell-minibar-title">${b}</span>
154
+ <span class="hcms-shell-minibar-title">${g}</span>
155
155
  <button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
156
156
  <span class="mirk-button__label">\xD7</span>
157
157
  </button>
@@ -159,8 +159,8 @@ ${r}`:r,i.hidden=!1;continue}}t.push(r)}t.length&&e.errorEl&&(e.errorEl.textCont
159
159
  <div class="hcms-shell-body">
160
160
  <header class="hcms-shell-header">
161
161
  <div class="hcms-shell-heading">
162
- <div class="hcms-shell-eyebrow">${u}</div>
163
- <h2 class="hcms-shell-title" id="${l}">${b}</h2>
162
+ <div class="hcms-shell-eyebrow">${d}</div>
163
+ <h2 class="hcms-shell-title" id="${l}">${g}</h2>
164
164
  </div>
165
165
  <button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
166
166
  <span class="mirk-button__label">\xD7</span>
@@ -175,7 +175,7 @@ ${r}`:r,i.hidden=!1;continue}}t.push(r)}t.length&&e.errorEl&&(e.errorEl.textCont
175
175
  </button>
176
176
  </footer>
177
177
  </div>
178
- `,(e||s.body).appendChild(c);let y=s.body;y.classList.add("hcms-open"),r&&y.classList.add("hcms-overlay"),t==="left"&&y.classList.add("hcms-side-left");let N=as(c,s),q=ss(c);return{root:c,formRoot:c.querySelector("[data-hcms-form-root]"),noticeEl:c.querySelector(".hcms-shell-notice"),errorEl:c.querySelector(".hcms-shell-error"),saveButton:c.querySelector(".hcms-shell-save"),destroy(){N.detach(),q.detach(),c.remove(),y.classList.remove("hcms-open","hcms-overlay","hcms-side-left")},restoreChrome(){os(s),y.classList.add("hcms-open"),r&&y.classList.add("hcms-overlay"),t==="left"&&y.classList.add("hcms-side-left")}}}function os(e){e&&(e.getElementById(Rt)||e.querySelector("style[data-hcms-bundled-styles]")||(Be.delete(e),$n(e)))}function $n(e){if(e&&!Be.has(e)){if(e[rs]){Be.add(e);return}if(e.getElementById(Rt)||e.querySelector("style[data-hcms-bundled-styles]")){Be.add(e);return}if(mr){let t=e.createElement("style");t.id=Rt,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=mr,(e.head||e.documentElement).appendChild(t),Be.add(e);return}try{let t=new URL("./theme.generated.css",ls.url).href,r=e.createElement("link");r.rel="stylesheet",r.id=Rt,r.setAttribute("save-remove",""),r.setAttribute("save-ignore",""),r.href=t,(e.head||e.documentElement).appendChild(r),Be.add(e)}catch{console.warn("hypercms: shell stylesheet not applied \u2014 cssText is empty and the co-located theme fallback is unavailable. Call installStyles(themeText) before opening the CMS.")}}}function ss(e){let t=e.querySelector(".hcms-shell-body"),r=e.querySelector(".hcms-shell-header");if(!t||!r||typeof t.addEventListener!="function")return{detach(){}};let n=()=>{let i=(r.offsetHeight||0)-12;e.classList.toggle("is-condensed",t.scrollTop>i)};return t.addEventListener("scroll",n,{passive:!0}),n(),{detach(){t.removeEventListener("scroll",n)}}}function as(e,t){function r(n){if(n.key!=="Tab"||!e.contains(t.activeElement))return;let i=Array.from(e.querySelectorAll(ns));if(i.length===0)return;let o=i[0],a=i[i.length-1];n.shiftKey&&t.activeElement===o?(n.preventDefault(),a.focus()):!n.shiftKey&&t.activeElement===a&&(n.preventDefault(),o.focus())}return t.addEventListener("keydown",r),{detach:()=>t.removeEventListener("keydown",r)}}var cs="[hypercms]",Bn={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Pn={skip:"[data-hcms-shell]",templateAttr:null},hr=class extends Error{constructor(t,r,n){super(`hypercms: rule at "${t}" has an invalid CSS selector: "${r}"`),this.name="InvalidRuleSelector",this.path=t,this.selector=r,this.cause=n}};function Mt(e,t){let r=[],n=[];return pr(e,t,[],r,n),{missing:hs(r),twins:ps(n)}}function pr(e,t,r,n,i){if(typeof t=="string"){let o=us(t);if(!o)return;let a=Ot(e,o,Bn,r);if(t.endsWith("[]")){a.length===0&&Ot(e,o,Pn,r).length===0&&n.push(rt(r));return}a.length===0?n.push(rt(r)):a.length>1&&i.push({path:rt(r),count:a.length});return}if(Array.isArray(t)){let[o,a]=t;if(typeof o!="string"||!o)return;let s=Ot(e,o,Bn,r);if(s.length===0){Ot(e,o,Pn,r).length===0&&n.push(rt(r));return}for(let l of s)pr(l,a,[...r,"*"],n,i);return}if(t&&typeof t=="object")for(let[o,a]of Object.entries(t))pr(e,a,[...r,o],n,i)}function Ot(e,t,r,n){try{return ue.find(e,t,r)}catch(i){throw new hr(rt(n),t,i)}}function us(e){if(e==="."||e.startsWith("@"))return null;if(e.endsWith("[]"))return e.slice(0,-2)||null;let t=Z(e);return(t===-1?e:e.slice(0,t))||null}function Nt(e){ds(e),ms(e)}function ds(e){let t=e.noticeEl;if(!t)return;let r=e.unresolved&&e.unresolved.missing||[];if(r.length===0){t.textContent="",t.hidden=!0;return}let n=r.length===1?"1 field no longer matches this page":`${r.length} fields no longer match this page`;t.textContent=`${n}: ${r.join(", ")}`,t.hidden=!1}function ms(e){let t=e.unresolved&&e.unresolved.twins||[],r=t.map(n=>`${n.path}:${n.count}`).join("|");if(r!==e.lastTwinSignature){e.lastTwinSignature=r;for(let{path:n,count:i}of t)console.warn(`${cs} "${n}" matches ${i} elements; edits go to the first one.`)}}function hs(e){return[...new Set(e)]}function ps(e){let t=new Map;for(let r of e){let n=t.get(r.path);(!n||r.count>n.count)&&t.set(r.path,r)}return[...t.values()]}function rt(e){return e.length?e.join("."):"(whole page)"}var fs={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function It(e,{ignoreActiveValue:t}={}){let r=re.findRules(e.doc,e.rulesSource||"cms");r&&(e.pageRules=e.richText?St(r.rules,e.pageRoot):r.rules,e.rulesTagNode=r.tagNode),ht(e.doc),kt(e.doc,e.pageRules),e.formRules=vt(e.pageRules,e.doc),e.unresolved=Mt(e.pageRoot,e.pageRules);let n=ye(re.extract(e.pageRoot,e.pageRules,fs),e.pageRules),i=xt({pageRules:e.pageRules,formRules:e.formRules,data:n,doc:e.doc});ut(e.formRoot,i,{ignoreActiveValue:t}),qe(e.formRoot,e.doc),lr(e),Nt(e),e.updateFingerprint&&e.updateFingerprint()}function zn({debounce:e=100,onRefresh:t}){let r=ne("Mutation");if(!r||typeof r.onAnyChange!="function")throw new Error("hypercms: a mutation hub is required (clay.Mutation or hyperclay.Mutation). Load clayjs or hyperclayjs, or just the mutation utility, before initializing hypercms.");let n=0,i=r.onAnyChange({debounce:e},()=>{n>0||t()});return{unsubscribe:typeof i=="function"?i:()=>{},pause(){n++},resume(){n=Math.max(0,n-1)}}}var gs="[hypercms]";function Un(e,t){if(!e||!e.querySelectorAll||!t)return;let r=bs(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(i=>{let o=i.getAttribute("data-hcms-tpl");o&&(o.startsWith("@")||r.has(o)||console.warn(`${gs} template "${o}" doesn't match any rule path; ignored`))})}function bs(e){let t=new Set;return r([],e),t;function r(n,i){let o=n.join("."),a=n.map(l=>typeof l=="number"?"*":l).join(".");o&&t.add(o),a&&t.add(a);let s=_e(i);if(s==="object")for(let[l,c]of Object.entries(i))r([...n,l],c);else if(s==="object-array"||s==="scalar-array"){let l=[...n,"*"],c=l.map(d=>typeof d=="number"?"*":d).join(".");if(t.add(c),s==="object-array"){let d=i[1];if(d&&typeof d=="object"&&!Array.isArray(d))for(let[b,u]of Object.entries(d))r([...l,b],u)}}}}var Hn="hcms-toggle",Vn="hcms-toggle-style",ks=`
178
+ `,(e||a.body).appendChild(c);let y=a.body;y.classList.add("hcms-open"),r&&y.classList.add("hcms-overlay"),t==="left"&&y.classList.add("hcms-side-left");let N=ks(c,a),q=bs(c);return{root:c,formRoot:c.querySelector("[data-hcms-form-root]"),noticeEl:c.querySelector(".hcms-shell-notice"),errorEl:c.querySelector(".hcms-shell-error"),saveButton:c.querySelector(".hcms-shell-save"),destroy(){N.detach(),q.detach(),c.remove(),y.classList.remove("hcms-open","hcms-overlay","hcms-side-left")},restoreChrome(){gs(a),y.classList.add("hcms-open"),r&&y.classList.add("hcms-overlay"),t==="left"&&y.classList.add("hcms-side-left")}}}function gs(e){e&&(e.getElementById(Rt)||e.querySelector("style[data-hcms-bundled-styles]")||(Be.delete(e),Hn(e)))}function Hn(e){if(e&&!Be.has(e)){if(e[hs]){Be.add(e);return}if(e.getElementById(Rt)||e.querySelector("style[data-hcms-bundled-styles]")){Be.add(e);return}if(pr){let t=e.createElement("style");t.id=Rt,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=pr,(e.head||e.documentElement).appendChild(t),Be.add(e);return}try{let t=new URL("./theme.generated.css",ys.url).href,r=e.createElement("link");r.rel="stylesheet",r.id=Rt,r.setAttribute("save-remove",""),r.setAttribute("save-ignore",""),r.href=t,(e.head||e.documentElement).appendChild(r),Be.add(e)}catch{console.warn("hypercms: shell stylesheet not applied \u2014 cssText is empty and the co-located theme fallback is unavailable. Call installStyles(themeText) before opening the CMS.")}}}function bs(e){let t=e.querySelector(".hcms-shell-body"),r=e.querySelector(".hcms-shell-header");if(!t||!r||typeof t.addEventListener!="function")return{detach(){}};let n=()=>{let i=(r.offsetHeight||0)-12;e.classList.toggle("is-condensed",t.scrollTop>i)};return t.addEventListener("scroll",n,{passive:!0}),n(),{detach(){t.removeEventListener("scroll",n)}}}function ks(e,t){function r(n){if(n.key!=="Tab"||!e.contains(t.activeElement))return;let i=Array.from(e.querySelectorAll(ps));if(i.length===0)return;let o=i[0],s=i[i.length-1];n.shiftKey&&t.activeElement===o?(n.preventDefault(),s.focus()):!n.shiftKey&&t.activeElement===s&&(n.preventDefault(),o.focus())}return t.addEventListener("keydown",r),{detach:()=>t.removeEventListener("keydown",r)}}var vs="[hypercms]",Vn={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Wn={skip:"[data-hcms-shell]",templateAttr:null},fr=class extends Error{constructor(t,r,n){super(`hypercms: rule at "${t}" has an invalid CSS selector: "${r}"`),this.name="InvalidRuleSelector",this.path=t,this.selector=r,this.cause=n}};function Mt(e,t){let r=[],n=[];return gr(e,t,[],r,n),{missing:As(r),twins:Ss(n)}}function gr(e,t,r,n,i){if(typeof t=="string"){let o=xs(t);if(!o)return;let s=Ot(e,o,Vn,r);if(t.endsWith("[]")){s.length===0&&Ot(e,o,Wn,r).length===0&&n.push(rt(r));return}s.length===0?n.push(rt(r)):s.length>1&&i.push({path:rt(r),count:s.length});return}if(Array.isArray(t)){let[o,s]=t;if(typeof o!="string"||!o)return;let a=Ot(e,o,Vn,r);if(a.length===0){Ot(e,o,Wn,r).length===0&&n.push(rt(r));return}for(let l of a)gr(l,s,[...r,"*"],n,i);return}if(t&&typeof t=="object")for(let[o,s]of Object.entries(t))gr(e,s,[...r,o],n,i)}function Ot(e,t,r,n){try{return de.find(e,t,r)}catch(i){throw new fr(rt(n),t,i)}}function xs(e){if(e==="."||e.startsWith("@"))return null;if(e.endsWith("[]"))return e.slice(0,-2)||null;let t=Z(e);return(t===-1?e:e.slice(0,t))||null}function Nt(e){ws(e),_s(e)}function ws(e){let t=e.noticeEl;if(!t)return;let r=e.unresolved&&e.unresolved.missing||[];if(r.length===0){t.textContent="",t.hidden=!0;return}let n=r.length===1?"1 field no longer matches this page":`${r.length} fields no longer match this page`;t.textContent=`${n}: ${r.join(", ")}`,t.hidden=!1}function _s(e){let t=e.unresolved&&e.unresolved.twins||[],r=t.map(n=>`${n.path}:${n.count}`).join("|");if(r!==e.lastTwinSignature){e.lastTwinSignature=r;for(let{path:n,count:i}of t)console.warn(`${vs} "${n}" matches ${i} elements; edits go to the first one.`)}}function As(e){return[...new Set(e)]}function Ss(e){let t=new Map;for(let r of e){let n=t.get(r.path);(!n||r.count>n.count)&&t.set(r.path,r)}return[...t.values()]}function rt(e){return e.length?e.join("."):"(whole page)"}var Es={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function It(e,{ignoreActiveValue:t}={}){let r=re.findRules(e.doc,e.rulesSource||"cms");r&&(e.pageRules=e.richText?St(r.rules,e.pageRoot):r.rules,e.rulesTagNode=r.tagNode),ht(e.doc),kt(e.doc,e.pageRules),e.formRules=vt(e.pageRules,e.doc),e.unresolved=Mt(e.pageRoot,e.pageRules);let n=ve(re.extract(e.pageRoot,e.pageRules,Es),e.pageRules),i=xt({pageRules:e.pageRules,formRules:e.formRules,data:n,doc:e.doc});dt(e.formRoot,i,{ignoreActiveValue:t}),qe(e.formRoot,e.doc),dr(e),Nt(e),e.updateFingerprint&&e.updateFingerprint()}function Kn({debounce:e=100,onRefresh:t}){let r=ne("Mutation");if(!r||typeof r.onAnyChange!="function")throw new Error("hypercms: a mutation hub is required (clay.Mutation or hyperclay.Mutation). Load clayjs or hyperclayjs, or just the mutation utility, before initializing hypercms.");let n=0,i=r.onAnyChange({debounce:e},()=>{n>0||t()});return{unsubscribe:typeof i=="function"?i:()=>{},pause(){n++},resume(){n=Math.max(0,n-1)}}}var Cs="[hypercms]";function Gn(e,t){if(!e||!e.querySelectorAll||!t)return;let r=Ts(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(i=>{let o=i.getAttribute("data-hcms-tpl");o&&(o.startsWith("@")||r.has(o)||console.warn(`${Cs} template "${o}" doesn't match any rule path; ignored`))})}function Ts(e){let t=new Set;return r([],e),t;function r(n,i){let o=n.join("."),s=n.map(l=>typeof l=="number"?"*":l).join(".");o&&t.add(o),s&&t.add(s);let a=Ae(i);if(a==="object")for(let[l,c]of Object.entries(i))r([...n,l],c);else if(a==="object-array"||a==="scalar-array"){let l=[...n,"*"],c=l.map(u=>typeof u=="number"?"*":u).join(".");if(t.add(c),a==="object-array"){let u=i[1];if(u&&typeof u=="object"&&!Array.isArray(u))for(let[g,d]of Object.entries(u))r([...l,g],d)}}}}var Jn="hcms-toggle",Yn="hcms-toggle-style",Rs=`
179
179
  #hcms-toggle {
180
180
  position: fixed; right: 16px; bottom: 16px; z-index: 2147482900;
181
181
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
@@ -189,7 +189,7 @@ body.hcms-open #hcms-toggle .hcms-toggle__open { display: none; }
189
189
  body.hcms-open #hcms-toggle .hcms-toggle__close { display: inline; }
190
190
  body.hcms-open:not(.hcms-overlay):not(.hcms-side-left) #hcms-toggle { right: calc(380px + 16px); }
191
191
  body.hcms-open.hcms-overlay #hcms-toggle { display: none; }
192
- `;function ys({search:e="",cookie:t="",forced:r=null}={}){let n=typeof e=="string"?e:"",i=n.indexOf("?"),o=i===-1?n:n.slice(i+1),a=new URLSearchParams(o).get("editmode");return a?a==="true":r!=null?!!r:/(?:^|;\s*)isAdminOfCurrentResource=[^;]/.test(t)}function vs({open:e,close:t,isOpen:r},n=document){let i=n.getElementById(Hn);if(i)return i;if(!n.getElementById(Vn)){let a=n.createElement("style");a.id=Vn,a.setAttribute("snapshot-remove",""),a.textContent=ks,n.head.appendChild(a)}let o=n.createElement("button");return o.type="button",o.id=Hn,o.setAttribute("no-save",""),o.setAttribute("snapshot-remove",""),o.setAttribute("save-ignore",""),o.setAttribute("aria-label","Toggle content editor"),o.innerHTML='<span class="hcms-toggle__open">Edit content</span><span class="hcms-toggle__close">Close editor</span>',o.addEventListener("click",async()=>{try{r()?t():await e()}catch(a){console.warn("hypercms: toggle failed to open the CMS",a)}}),n.body.appendChild(o),o}function Wn(e){if(typeof window>"u"||typeof document>"u")return;let t=window.__hyperclayEditMode!=null?window.__hyperclayEditMode:null;if(!ys({search:window.location.search,cookie:document.cookie,forced:t}))return;let r=()=>{document.body&&e.hasRules(document)&&vs(e)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r,{once:!0}):r()}function Jn(e){qn(e)}var P={isOpen:!1,ctx:null,shell:null,opts:null};function Kn(e,t){if(P.ctx!==e)return;let r=t==="livesync";t==="livesync"&&P.shell?.restoreChrome?.(),It(e,{ignoreActiveValue:r})}var Gn=!1;function xs(){if(Gn)return;let e=ne("onPrepareForSave");typeof e=="function"&&(e(t=>{let r=t&&t.querySelector&&t.querySelector("body");r&&r.classList.remove("hcms-open","hcms-overlay","hcms-side-left")}),Gn=!0)}function br(e={}){if(P.isOpen){console.warn("cms.open() called while already open; ignoring");return}xs();let t=e.pageRoot||(typeof document<"u"?document.body:null);if(!t)throw new Error("hypercms: no pageRoot available");let r=t.ownerDocument||(typeof document<"u"?document:null);if(!r)throw new Error("hypercms: no document available");let n=e.rules!==void 0?e.rules:"cms",i=re.findRules(r,n);if(!i){let k=typeof n=="string"?`data-rules-name~="${n}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${k}`)}let o=e.richText!==!1,a=o?St(i.rules,t):i.rules,s=i.tagNode;ht(r),kt(r,a),Un(r,a);let l=vt(a,r),c=Mt(t,a),d=ye(re.extract(t,a,{skip:"[data-hcms-shell]",templateAttr:"cms-template"}),a),b=Tt(()=>Dn({mountTo:e.mountTo||r.body,side:e.side||"right",overlay:!!e.overlay,showSaveButton:!!e.showSaveButton,title:e.title,eyebrow:e.eyebrow,theme:e.theme,doc:r})),u={doc:r,pageRoot:t,pageRules:a,formRules:l,rulesTagNode:s,rulesSource:n,richText:o,formRoot:b.formRoot,shellRoot:b.root,errorEl:b.errorEl,noticeEl:b.noticeEl,unresolved:c,lastTwinSignature:null,lastFingerprint:null,lastData:null,observerHandle:null,undoUnsub:null,livesyncUnsub:null,onChange:e.onChange,onError:e.onError,confirmRemove:e.confirmRemove,previouslyFocused:r.activeElement,dispatch(k,y){let N=r.defaultView&&r.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!N)return;let q=new N(k,{bubbles:!0,cancelable:k==="hcms:change",detail:y});b.root.dispatchEvent(q)},onCloseRequested(){kr()}};u.updateFingerprint=()=>{u.lastFingerprint=tt(ae(u))};try{let k=xt({pageRules:a,formRules:l,data:d,doc:r});b.formRoot.appendChild(k),qe(b.formRoot,r),Nt(u),Ln(u),u.updateFingerprint(),u.observerHandle=zn({onRefresh:()=>It(u)});let y=ne("undo");if(y&&typeof y.on=="function"){let q=()=>{if(P.ctx!==u)return;Kn(u,"undo");let H=ye(re.extract(u.pageRoot,u.pageRules,{skip:"[data-hcms-shell]",templateAttr:"cms-template"}),u.pageRules);tt(H)!==tt(u.lastData)&&(u.lastData=H,u.onChange?.(H,{path:"",structural:!1}))};y.on("undo",q),y.on("redo",q),u.undoUnsub=()=>{y.off("undo",q),y.off("redo",q)}}let N=()=>Kn(u,"livesync");u.livesyncUnsub=ir(r,Mn,N),nt.ctx=u,_s(r),ws(b.root),P.isOpen=!0,P.ctx=u,P.shell=b,P.opts=e,u.dispatch("hcms:open",{pageRoot:t})}catch(k){throw u.observerHandle?.unsubscribe?.(),u.undoUnsub?.(),u.livesyncUnsub?.(),u.detachEvents?.(),nt.ctx===u&&(nt.ctx=null),Tt(()=>b.destroy()),P.isOpen=!1,P.ctx=null,P.shell=null,P.opts=null,k}}function ws(e){let r=e.querySelector('input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])');r&&typeof r.focus=="function"&&r.focus()}var nt={ctx:null};function _s(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let r=function(){let i=nt.ctx;if(i)return ur(i.formRoot),$e("Reorder",()=>de(ae(i),{path:"",structural:!0},i))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=r),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=r)}var gr="cms";function As(e){let t=typeof e=="string"?e:"",r=t.indexOf("?"),n=r===-1?t:t.slice(r+1);if(!n)return t;let i=new URLSearchParams(n);return i.get(gr)!=="true"?t:(i.set(gr,"false"),"?"+i.toString())}function Ss(e){let t=typeof e=="string"?e:"",r=t.indexOf("?"),n=r===-1?t:t.slice(r+1);return n?new URLSearchParams(n).get(gr)==="true":!1}function Es(){if(typeof window>"u"||!window.location||!window.history||typeof window.history.replaceState!="function")return;let e=window.location.search,t=As(e);t!==e&&window.history.replaceState(window.history.state,"",t+window.location.hash)}function kr(){if(!P.isOpen)return;let{ctx:e,shell:t}=P;e.closed=!0;let r=e.previouslyFocused;if(e.dispatch("hcms:close",null),Es(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),Tt(()=>t.destroy()),P.isOpen=!1,P.ctx=null,P.shell=null,P.opts=null,nt.ctx=null,r&&typeof r.focus=="function")try{r.focus()}catch{}}function Yn(){P.isOpen&&It(P.ctx)}function Cs(){return P.isOpen}var Ts={getData(){return P.isOpen?ae(P.ctx):null},setValue(e,t){if(!P.isOpen)throw new Error("hypercms: cms is not open");let r=P.ctx,n=me(e),i=we(r.pageRules,n);if(i===void 0)throw new Error(`hypercms: no rule at path "${e}"`);if(typeof i!="string"||i.endsWith("[]"))throw new Error(`hypercms: setValue requires a leaf scalar path; "${e}" is not a leaf`);let o=Rs(r.formRoot,e);if(!o)throw new Error(`hypercms: no field element at path "${e}"`);Os(o,t,r.formRoot,e),de(ae(r),{path:e,structural:!1},r)},addItem(e){if(!P.isOpen)throw new Error("hypercms: cms is not open");ar(e,P.ctx)},removeItem(e){if(!P.isOpen)throw new Error("hypercms: cms is not open");let t=P.ctx,r=me(e);if(typeof r[r.length-1]!="number")throw new Error(`hypercms: removeItem requires an item path; "${e}" is not an array index`);let i=we(t.pageRules,r.slice(0,-1));if(!(Array.isArray(i)||typeof i=="string"&&i.endsWith("[]")))throw new Error(`hypercms: removeItem requires an item path; parent of "${e}" is not an array`);let a=t.formRoot.querySelector(`[data-hcms-path="${vr(e)}"]`);if(!a)throw new Error(`hypercms: no element at path "${e}"`);De(a,t)},refresh:Yn,_commit(){if(!P.isOpen)return;let e=P.ctx;return ur(e.formRoot),$e("Update",()=>de(ae(e),{path:"",structural:!0},e))}};function Rs(e,t){let r=vr(t),n=`[data-hcms-path="${r}"] input[data-hcms-field], [data-hcms-path="${r}"] textarea[data-hcms-field], [data-hcms-path="${r}"] select[data-hcms-field], [data-hcms-path="${r}"] img[data-hcms-field], [data-hcms-path="${r}"] a[data-hcms-field], [data-hcms-path="${r}"] [contenteditable][data-hcms-field], input[data-hcms-path="${r}"][data-hcms-field], textarea[data-hcms-path="${r}"][data-hcms-field], select[data-hcms-path="${r}"][data-hcms-field], img[data-hcms-path="${r}"][data-hcms-field], a[data-hcms-path="${r}"][data-hcms-field], [contenteditable][data-hcms-path="${r}"][data-hcms-field]`;return e.querySelector(n)}function Os(e,t,r,n){let i=(e.tagName||"").toUpperCase(),o=(e.getAttribute("type")||"").toLowerCase();if(i==="INPUT"&&o==="checkbox"){e.checked=t===!0||t==="true";return}if(i==="INPUT"&&o==="radio"){let a=vr(n),s=r.querySelectorAll(`[data-hcms-path="${a}"][data-hcms-field][type="radio"], [data-hcms-path="${a}"] [data-hcms-field][type="radio"]`);s.length?s.forEach(l=>{l.checked=String(l.value)===String(t??"")}):e.checked=String(e.value)===String(t??"");return}if(i==="IMG"){e.src=t==null?"":String(t);return}if(i==="A"){e.href=t==null?"":String(t);return}if(e.hasAttribute&&e.hasAttribute("contenteditable")){e.innerHTML=t==null?"":String(t);return}if("value"in e){e.value=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var Ms=250,Ns=1e4;function Is(){typeof window>"u"||typeof document>"u"||Ss(window.location?window.location.search:"")&&(P.isOpen||Ls(()=>{if(!P.isOpen)try{br()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function fr(){return!!document.body&&!!ne("Mutation")}function Ls(e){if(fr()){queueMicrotask(e);return}let t=Date.now()+Ns,r=!1,n=null,i=null,o=()=>{r||(r=!0,n!==null&&clearInterval(n),i&&i())};function a(){if(P.isOpen){o();return}fr()&&(o(),e())}i=ir(document,On,a),n=setInterval(()=>{if(P.isOpen){o();return}if(fr()){o(),e();return}Date.now()>=t&&(o(),console.warn("hypercms: ?cms=true auto-open gave up \u2014 no mutation hub appeared. Load clayjs or hyperclayjs (or just the mutation utility) so the CMS can initialize."))},Ms)}Is();Wn({open:br,close:kr,isOpen:Cs,hasRules:e=>!!re.findRules(e,"cms")});var yr={open:br,close:kr,refresh:Yn,api:Ts,get isOpen(){return P.isOpen},path:Zt,scaffold:Xe,morphForm:ut};function vr(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Xn=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
192
+ `;function Os({search:e="",cookie:t="",forced:r=null}={}){let n=typeof e=="string"?e:"",i=n.indexOf("?"),o=i===-1?n:n.slice(i+1),s=new URLSearchParams(o).get("editmode");return s?s==="true":r!=null?!!r:/(?:^|;\s*)isAdminOfCurrentResource=[^;]/.test(t)}function Ms({open:e,close:t,isOpen:r},n=document){let i=n.getElementById(Jn);if(i)return i;if(!n.getElementById(Yn)){let s=n.createElement("style");s.id=Yn,s.setAttribute("snapshot-remove",""),s.textContent=Rs,n.head.appendChild(s)}let o=n.createElement("button");return o.type="button",o.id=Jn,o.setAttribute("no-save",""),o.setAttribute("snapshot-remove",""),o.setAttribute("save-ignore",""),o.setAttribute("aria-label","Toggle content editor"),o.innerHTML='<span class="hcms-toggle__open">Edit content</span><span class="hcms-toggle__close">Close editor</span>',o.addEventListener("click",async()=>{try{r()?t():await e()}catch(s){console.warn("hypercms: toggle failed to open the CMS",s)}}),n.body.appendChild(o),o}function Xn(e){if(typeof window>"u"||typeof document>"u")return;let t=window.__hyperclayEditMode!=null?window.__hyperclayEditMode:null;if(!Os({search:window.location.search,cookie:document.cookie,forced:t}))return;let r=()=>{document.body&&e.hasRules(document)&&Ms(e)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r,{once:!0}):r()}function ei(e){Un(e)}var B={isOpen:!1,ctx:null,shell:null,opts:null};function Zn(e,t){if(B.ctx!==e)return;let r=t==="livesync";t==="livesync"&&B.shell?.restoreChrome?.(),It(e,{ignoreActiveValue:r})}var Qn=!1;function Ns(){if(Qn)return;let e=ne("onPrepareForSave");typeof e=="function"&&(e(t=>{let r=t&&t.querySelector&&t.querySelector("body");r&&r.classList.remove("hcms-open","hcms-overlay","hcms-side-left")}),Qn=!0)}function yr(e={}){if(B.isOpen){console.warn("cms.open() called while already open; ignoring");return}Ns();let t=e.pageRoot||(typeof document<"u"?document.body:null);if(!t)throw new Error("hypercms: no pageRoot available");let r=t.ownerDocument||(typeof document<"u"?document:null);if(!r)throw new Error("hypercms: no document available");let n=e.rules!==void 0?e.rules:"cms",i=re.findRules(r,n);if(!i){let k=typeof n=="string"?`data-rules-name~="${n}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${k}`)}let o=e.richText!==!1,s=o?St(i.rules,t):i.rules,a=i.tagNode;ht(r),kt(r,s),Gn(r,s);let l=vt(s,r),c=Mt(t,s),u=ve(re.extract(t,s,{skip:"[data-hcms-shell]",templateAttr:"cms-template"}),s),g=Tt(()=>zn({mountTo:e.mountTo||r.body,side:e.side||"right",overlay:!!e.overlay,showSaveButton:!!e.showSaveButton,title:e.title,eyebrow:e.eyebrow,theme:e.theme,doc:r})),d={doc:r,pageRoot:t,pageRules:s,formRules:l,rulesTagNode:a,rulesSource:n,richText:o,formRoot:g.formRoot,shellRoot:g.root,errorEl:g.errorEl,noticeEl:g.noticeEl,unresolved:c,lastTwinSignature:null,lastFingerprint:null,lastData:null,observerHandle:null,undoUnsub:null,livesyncUnsub:null,onChange:e.onChange,onError:e.onError,confirmRemove:e.confirmRemove,previouslyFocused:r.activeElement,dispatch(k,y){let N=r.defaultView&&r.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!N)return;let q=new N(k,{bubbles:!0,cancelable:k==="hcms:change",detail:y});g.root.dispatchEvent(q)},onCloseRequested(){vr()}};d.updateFingerprint=()=>{d.lastFingerprint=tt(ae(d))};try{let k=xt({pageRules:s,formRules:l,data:u,doc:r});g.formRoot.appendChild(k),qe(g.formRoot,r),Nt(d),Dn(d),d.updateFingerprint(),d.observerHandle=Kn({onRefresh:()=>It(d)});let y=ne("undo");if(y&&typeof y.on=="function"){let q=()=>{if(B.ctx!==d)return;Zn(d,"undo");let H=ve(re.extract(d.pageRoot,d.pageRules,{skip:"[data-hcms-shell]",templateAttr:"cms-template"}),d.pageRules);tt(H)!==tt(d.lastData)&&(d.lastData=H,d.onChange?.(H,{path:"",structural:!1}))};y.on("undo",q),y.on("redo",q),d.undoUnsub=()=>{y.off("undo",q),y.off("redo",q)}}let N=()=>Zn(d,"livesync");d.livesyncUnsub=or(r,In,N),nt.ctx=d,Ls(r),Is(g.root),B.isOpen=!0,B.ctx=d,B.shell=g,B.opts=e,d.dispatch("hcms:open",{pageRoot:t})}catch(k){throw d.observerHandle?.unsubscribe?.(),d.undoUnsub?.(),d.livesyncUnsub?.(),d.detachEvents?.(),nt.ctx===d&&(nt.ctx=null),Tt(()=>g.destroy()),B.isOpen=!1,B.ctx=null,B.shell=null,B.opts=null,k}}function Is(e){let r=e.querySelector('input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])');r&&typeof r.focus=="function"&&r.focus()}var nt={ctx:null};function Ls(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let r=function(){let i=nt.ctx;if(i)return mr(i.formRoot),Pe("Reorder",()=>ue(ae(i),{path:"",structural:!0},i))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=r),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=r)}var kr="cms";function js(e){let t=typeof e=="string"?e:"",r=t.indexOf("?"),n=r===-1?t:t.slice(r+1);if(!n)return t;let i=new URLSearchParams(n);return i.get(kr)!=="true"?t:(i.set(kr,"false"),"?"+i.toString())}function Fs(e){let t=typeof e=="string"?e:"",r=t.indexOf("?"),n=r===-1?t:t.slice(r+1);return n?new URLSearchParams(n).get(kr)==="true":!1}function qs(){if(typeof window>"u"||!window.location||!window.history||typeof window.history.replaceState!="function")return;let e=window.location.search,t=js(e);t!==e&&window.history.replaceState(window.history.state,"",t+window.location.hash)}function vr(){if(!B.isOpen)return;let{ctx:e,shell:t}=B;e.closed=!0;for(let n of e.uploads||[])try{n.abort()}catch{}e.uploads?.clear();let r=e.previouslyFocused;if(e.dispatch("hcms:close",null),qs(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),Tt(()=>t.destroy()),B.isOpen=!1,B.ctx=null,B.shell=null,B.opts=null,nt.ctx=null,r&&typeof r.focus=="function")try{r.focus()}catch{}}function ti(){B.isOpen&&It(B.ctx)}function Ds(){return B.isOpen}var $s={getData(){return B.isOpen?ae(B.ctx):null},setValue(e,t){if(!B.isOpen)throw new Error("hypercms: cms is not open");let r=B.ctx,n=me(e),i=_e(r.pageRules,n);if(i===void 0)throw new Error(`hypercms: no rule at path "${e}"`);if(typeof i!="string"||i.endsWith("[]"))throw new Error(`hypercms: setValue requires a leaf scalar path; "${e}" is not a leaf`);let o=Ps(r.formRoot,e);if(!o)throw new Error(`hypercms: no field element at path "${e}"`);Bs(o,t,r.formRoot,e),ue(ae(r),{path:e,structural:!1},r)},addItem(e){if(!B.isOpen)throw new Error("hypercms: cms is not open");cr(e,B.ctx)},removeItem(e){if(!B.isOpen)throw new Error("hypercms: cms is not open");let t=B.ctx,r=me(e);if(typeof r[r.length-1]!="number")throw new Error(`hypercms: removeItem requires an item path; "${e}" is not an array index`);let i=_e(t.pageRules,r.slice(0,-1));if(!(Array.isArray(i)||typeof i=="string"&&i.endsWith("[]")))throw new Error(`hypercms: removeItem requires an item path; parent of "${e}" is not an array`);let s=t.formRoot.querySelector(`[data-hcms-path="${wr(e)}"]`);if(!s)throw new Error(`hypercms: no element at path "${e}"`);De(s,t)},refresh:ti,_commit(){if(!B.isOpen)return;let e=B.ctx;return mr(e.formRoot),Pe("Update",()=>ue(ae(e),{path:"",structural:!0},e))}};function Ps(e,t){let r=wr(t),n=`[data-hcms-path="${r}"] input[data-hcms-field], [data-hcms-path="${r}"] textarea[data-hcms-field], [data-hcms-path="${r}"] select[data-hcms-field], [data-hcms-path="${r}"] img[data-hcms-field], [data-hcms-path="${r}"] a[data-hcms-field], [data-hcms-path="${r}"] [contenteditable][data-hcms-field], input[data-hcms-path="${r}"][data-hcms-field], textarea[data-hcms-path="${r}"][data-hcms-field], select[data-hcms-path="${r}"][data-hcms-field], img[data-hcms-path="${r}"][data-hcms-field], a[data-hcms-path="${r}"][data-hcms-field], [contenteditable][data-hcms-path="${r}"][data-hcms-field]`;return e.querySelector(n)}function Bs(e,t,r,n){let i=(e.tagName||"").toUpperCase(),o=(e.getAttribute("type")||"").toLowerCase();if(i==="INPUT"&&o==="checkbox"){e.checked=t===!0||t==="true";return}if(i==="INPUT"&&o==="radio"){let s=wr(n),a=r.querySelectorAll(`[data-hcms-path="${s}"][data-hcms-field][type="radio"], [data-hcms-path="${s}"] [data-hcms-field][type="radio"]`);a.length?a.forEach(l=>{l.checked=String(l.value)===String(t??"")}):e.checked=String(e.value)===String(t??"");return}if(i==="IMG"){e.src=t==null?"":String(t);return}if(i==="A"){e.href=t==null?"":String(t);return}if(e.hasAttribute&&e.hasAttribute("contenteditable")){e.innerHTML=t==null?"":String(t);return}if("value"in e){e.value=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var Us=250,zs=1e4;function Hs(){typeof window>"u"||typeof document>"u"||Fs(window.location?window.location.search:"")&&(B.isOpen||Vs(()=>{if(!B.isOpen)try{yr()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function br(){return!!document.body&&!!ne("Mutation")}function Vs(e){if(br()){queueMicrotask(e);return}let t=Date.now()+zs,r=!1,n=null,i=null,o=()=>{r||(r=!0,n!==null&&clearInterval(n),i&&i())};function s(){if(B.isOpen){o();return}br()&&(o(),e())}i=or(document,Nn,s),n=setInterval(()=>{if(B.isOpen){o();return}if(br()){o(),e();return}Date.now()>=t&&(o(),console.warn("hypercms: ?cms=true auto-open gave up \u2014 no mutation hub appeared. Load clayjs or hyperclayjs (or just the mutation utility) so the CMS can initialize."))},Us)}Hs();Xn({open:yr,close:vr,isOpen:Ds,hasRules:e=>!!re.findRules(e,"cms")});var xr={open:yr,close:vr,refresh:ti,api:$s,get isOpen(){return B.isOpen},path:Zt,scaffold:Ze,morphForm:dt};function wr(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var ri=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
193
193
  Source of truth: mirk-interface/mirk.css + src/theme/pixel-quiet.overrides.css.
194
194
  Regenerate with: npm run build:theme */
195
195
 
@@ -1653,6 +1653,41 @@ body.hcms-open.hcms-overlay { overflow: hidden; }
1653
1653
  color: var(--mirk-placeholder-color);
1654
1654
  }
1655
1655
 
1656
+ /* ---------- UPLOADING (spec \xA79) ----------
1657
+ One attribute, [data-hcms-uploading], set on the field for as long as the host
1658
+ has the bytes, plus --hcms-upload-progress carrying the percent. No markup of
1659
+ its own: the templates keep their exact shape, so a half-finished upload cannot
1660
+ leave an orphan node behind in the form. The at-upload-time picture is painted
1661
+ on the frame as a background, never assigned to the bound <img>, because that
1662
+ img IS the field's value and a commit landing mid-upload would write a
1663
+ two-megabyte data URL straight into the live page. */
1664
+ .hcms-upload[data-hcms-uploading] .mirk-image__frame {
1665
+ background-size: cover;
1666
+ background-position: center;
1667
+ }
1668
+ /* The empty state hides the thumb, so an upload into an empty field would have
1669
+ nowhere to show. Uploading reveals it, preview or not. */
1670
+ .hcms-upload--image[data-hcms-uploading] .mirk-image__thumb { display: inline-block; }
1671
+ .hcms-upload--image[data-hcms-uploading] .mirk-image__upload { display: none; }
1672
+ /* No \xD7 mid-flight: clearing writes the leaf empty, which says nothing about the
1673
+ request still running and reads as a cancel that is not one. */
1674
+ .hcms-upload[data-hcms-uploading] .hcms-upload-clear { display: none; }
1675
+
1676
+ .hcms-upload[data-hcms-uploading] .mirk-image__frame::after,
1677
+ .hcms-upload--file[data-hcms-uploading] .mirk-file::after {
1678
+ content: "";
1679
+ position: absolute;
1680
+ left: 0;
1681
+ bottom: 0;
1682
+ height: 3px;
1683
+ width: var(--hcms-upload-progress, 0%);
1684
+ background: var(--mirk-bevel-fg);
1685
+ transition: width 120ms linear;
1686
+ }
1687
+ /* The @file row has no frame to hang the bar on, so it becomes the positioning
1688
+ context itself. */
1689
+ .hcms-upload--file[data-hcms-uploading] .mirk-file { position: relative; }
1690
+
1656
1691
  /* clear-\xD7 (vendored-inert; data-hcms-action, never .mirk-*__remove). Bare \xD7 for
1657
1692
  @file, a pinned corner badge for @image \u2014 mirroring .hcms-remove / --card. */
1658
1693
  .hcms-upload-clear {
@@ -1713,6 +1748,13 @@ body.hcms-open.hcms-overlay { overflow: hidden; }
1713
1748
  .hcms-shell-error[hidden],
1714
1749
  .hcms-error[hidden] { display: none; }
1715
1750
 
1751
+ /* A note, not a refusal: the file WAS stored, in the page, and this says why it
1752
+ is not on the host. Same slot, so there is one place a field ever speaks. */
1753
+ .hcms-error--info {
1754
+ color: var(--mirk-mark-fg);
1755
+ border-color: var(--mirk-input-border);
1756
+ }
1757
+
1716
1758
  /* ---------- SAVE (sits at the end of the scrolling form, not pinned) ---------- */
1717
1759
  .hcms-shell-footer {
1718
1760
  display: flex;
@@ -1749,7 +1791,7 @@ body.hcms-open.hcms-overlay { overflow: hidden; }
1749
1791
  cursor: pointer;
1750
1792
  }
1751
1793
  .hcms-sr-only[hidden] { display: none; }
1752
- `;typeof window<"u"&&typeof document<"u"&&(function(){if(window.__mirk)return;window.__mirk=!0;let e='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4 12 12M12 4 4 12" stroke="currentColor" stroke-width="2" stroke-linecap="square" fill="none"/></svg>';document.addEventListener("click",r=>{let n=r.target.closest(".mirk-number__step");if(!n)return;let i=n.closest(".mirk-number").querySelector("input[type=number]");i&&(n.dataset.step==="up"?i.stepUp():i.stepDown(),i.dispatchEvent(new Event("change",{bubbles:!0})))}),document.addEventListener("input",r=>{let n=r.target.closest(".mirk-slider__input");n&&n.closest(".mirk-slider").style.setProperty("--mirk-value",`${n.value}%`)}),document.addEventListener("change",r=>{let n=r.target.closest(".mirk-file__input");if(!n||!n.files.length)return;let i=n.closest(".mirk-file"),o=i.querySelector(".mirk-file__name");if(!o)return;let a=n.files[0],s=document.createElement("a");if(s.className="mirk-file__name",s.dataset.filled="",s.href=URL.createObjectURL(a),s.target="_blank",s.rel="noopener",s.textContent=a.name,o.replaceWith(s),!i.querySelector(".mirk-file__remove")){let l=document.createElement("button");l.type="button",l.className="mirk-file__remove",l.setAttribute("aria-label","Remove file"),l.innerHTML=e,s.after(l)}}),document.addEventListener("change",r=>{let n=r.target.closest(".mirk-image__input");if(!n||!n.files.length)return;let i=n.closest(".mirk-image"),o=i.querySelector(".mirk-image__preview");if(!o)return;let a=i.querySelector(".mirk-image__placeholder"),s=new FileReader;s.onload=l=>{o.src=l.target.result,o.removeAttribute("hidden"),a&&a.setAttribute("hidden",""),i.querySelector(".mirk-image__thumb")?.removeAttribute("hidden"),i.querySelector(".mirk-image__upload")?.setAttribute("hidden","")},s.readAsDataURL(n.files[0])}),document.addEventListener("click",r=>{let n=r.target.closest(".mirk-file__remove");if(n){let o=n.closest(".mirk-file"),a=o?.querySelector(".mirk-file__input"),s=o?.querySelector(".mirk-file__name");if(a&&(a.value=""),s){let l=document.createElement("span");l.className="mirk-file__name",l.textContent="No file chosen",s.replaceWith(l)}n.remove();return}let i=r.target.closest(".mirk-image__remove");if(i){let o=i.closest(".mirk-image"),a=o?.querySelector(".mirk-image__input"),s=o?.querySelector(".mirk-image__preview");a&&(a.value=""),s&&(s.removeAttribute("src"),s.setAttribute("hidden","")),o?.querySelector(".mirk-image__thumb")?.setAttribute("hidden",""),o?.querySelector(".mirk-image__upload")?.removeAttribute("hidden")}});function t(r,n){let i=document.createElement("span");i.textContent=r;let o=document.createElement("input");o.type="hidden",o.name="tags[]",o.value=r;let a=document.createElement("button");a.type="button",a.className="mirk-tags__remove",a.textContent="\xD7";let s=document.createElement("span");if(s.className="mirk-tags__chip",n){let l=document.createElement("span");l.className="mirk-tags__chip-inner",l.append(i,o,a),s.append(l)}else s.append(i,o,a);return s}document.addEventListener("keydown",r=>{let n=r.target.closest(".mirk-tags__input");if(!n)return;let i=n.closest(".mirk-tags");if(r.key==="Enter"||r.key===","){let o=n.value.trim();if(!o)return;r.preventDefault(),n.before(t(o,i.classList.contains("mirk-tags--round"))),n.value=""}else if(r.key==="Backspace"&&!n.value){let o=i.querySelectorAll(".mirk-tags__chip");o[o.length-1]?.remove()}}),document.addEventListener("click",r=>{let n=r.target.closest(".mirk-tags__remove");if(n){n.closest(".mirk-tags__chip").remove();return}let i=r.target.closest(".mirk-tags");i&&r.target===i&&i.querySelector(".mirk-tags__input")?.focus()}),document.addEventListener("click",r=>{let n=r.target.closest("[data-mirk-chip]");if(!n)return;let i=n.getAttribute("data-mirk-chip");if(i==="open")n.closest(".mirk-chip")?.classList.add("mirk-chip--open");else if(i==="collapse")n.closest(".mirk-chip")?.classList.remove("mirk-chip--open");else if(i==="changes"){let o=n.closest(".mirk-chip__panel")?.classList.toggle("is-changes");n.textContent=o?"(hide changes)":"(view changes)"}}),document.addEventListener("click",r=>{let n=r.target.closest("[data-copy-btn]");if(!n)return;let i=n.closest("[data-copy]");if(!i)return;let o=i.cloneNode(!0);o.querySelectorAll("[data-copy-btn]").forEach(l=>l.remove());let s=i.getAttribute("data-copy")==="text"?o.textContent.replace(/^\s+|\s+$/g,""):o.innerHTML.replace(/\s+data-copy(="[^"]*")?/g,"").replace(/^\s*\n/gm,"").trim();navigator.clipboard.writeText(s).then(()=>{let l=n.textContent;n.textContent="copied",n.dataset.copied="",setTimeout(()=>{n.textContent=l,delete n.dataset.copied},1200)}).catch(()=>{n.textContent="error",setTimeout(()=>{n.textContent="copy"},1200)})})})();Jn(Xn);var qs=yr,Ds={cms:yr};return si($s);})();
1794
+ `;typeof window<"u"&&typeof document<"u"&&(function(){if(window.__mirk)return;window.__mirk=!0;let e='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4 12 12M12 4 4 12" stroke="currentColor" stroke-width="2" stroke-linecap="square" fill="none"/></svg>';document.addEventListener("click",r=>{let n=r.target.closest(".mirk-number__step");if(!n)return;let i=n.closest(".mirk-number").querySelector("input[type=number]");i&&(n.dataset.step==="up"?i.stepUp():i.stepDown(),i.dispatchEvent(new Event("change",{bubbles:!0})))}),document.addEventListener("input",r=>{let n=r.target.closest(".mirk-slider__input");n&&n.closest(".mirk-slider").style.setProperty("--mirk-value",`${n.value}%`)}),document.addEventListener("change",r=>{let n=r.target.closest(".mirk-file__input");if(!n||!n.files.length)return;let i=n.closest(".mirk-file"),o=i.querySelector(".mirk-file__name");if(!o)return;let s=n.files[0],a=document.createElement("a");if(a.className="mirk-file__name",a.dataset.filled="",a.href=URL.createObjectURL(s),a.target="_blank",a.rel="noopener",a.textContent=s.name,o.replaceWith(a),!i.querySelector(".mirk-file__remove")){let l=document.createElement("button");l.type="button",l.className="mirk-file__remove",l.setAttribute("aria-label","Remove file"),l.innerHTML=e,a.after(l)}}),document.addEventListener("change",r=>{let n=r.target.closest(".mirk-image__input");if(!n||!n.files.length)return;let i=n.closest(".mirk-image"),o=i.querySelector(".mirk-image__preview");if(!o)return;let s=i.querySelector(".mirk-image__placeholder"),a=new FileReader;a.onload=l=>{o.src=l.target.result,o.removeAttribute("hidden"),s&&s.setAttribute("hidden",""),i.querySelector(".mirk-image__thumb")?.removeAttribute("hidden"),i.querySelector(".mirk-image__upload")?.setAttribute("hidden","")},a.readAsDataURL(n.files[0])}),document.addEventListener("click",r=>{let n=r.target.closest(".mirk-file__remove");if(n){let o=n.closest(".mirk-file"),s=o?.querySelector(".mirk-file__input"),a=o?.querySelector(".mirk-file__name");if(s&&(s.value=""),a){let l=document.createElement("span");l.className="mirk-file__name",l.textContent="No file chosen",a.replaceWith(l)}n.remove();return}let i=r.target.closest(".mirk-image__remove");if(i){let o=i.closest(".mirk-image"),s=o?.querySelector(".mirk-image__input"),a=o?.querySelector(".mirk-image__preview");s&&(s.value=""),a&&(a.removeAttribute("src"),a.setAttribute("hidden","")),o?.querySelector(".mirk-image__thumb")?.setAttribute("hidden",""),o?.querySelector(".mirk-image__upload")?.removeAttribute("hidden")}});function t(r,n){let i=document.createElement("span");i.textContent=r;let o=document.createElement("input");o.type="hidden",o.name="tags[]",o.value=r;let s=document.createElement("button");s.type="button",s.className="mirk-tags__remove",s.textContent="\xD7";let a=document.createElement("span");if(a.className="mirk-tags__chip",n){let l=document.createElement("span");l.className="mirk-tags__chip-inner",l.append(i,o,s),a.append(l)}else a.append(i,o,s);return a}document.addEventListener("keydown",r=>{let n=r.target.closest(".mirk-tags__input");if(!n)return;let i=n.closest(".mirk-tags");if(r.key==="Enter"||r.key===","){let o=n.value.trim();if(!o)return;r.preventDefault(),n.before(t(o,i.classList.contains("mirk-tags--round"))),n.value=""}else if(r.key==="Backspace"&&!n.value){let o=i.querySelectorAll(".mirk-tags__chip");o[o.length-1]?.remove()}}),document.addEventListener("click",r=>{let n=r.target.closest(".mirk-tags__remove");if(n){n.closest(".mirk-tags__chip").remove();return}let i=r.target.closest(".mirk-tags");i&&r.target===i&&i.querySelector(".mirk-tags__input")?.focus()}),document.addEventListener("click",r=>{let n=r.target.closest("[data-mirk-chip]");if(!n)return;let i=n.getAttribute("data-mirk-chip");if(i==="open")n.closest(".mirk-chip")?.classList.add("mirk-chip--open");else if(i==="collapse")n.closest(".mirk-chip")?.classList.remove("mirk-chip--open");else if(i==="changes"){let o=n.closest(".mirk-chip__panel")?.classList.toggle("is-changes");n.textContent=o?"(hide changes)":"(view changes)"}}),document.addEventListener("click",r=>{let n=r.target.closest("[data-copy-btn]");if(!n)return;let i=n.closest("[data-copy]");if(!i)return;let o=i.cloneNode(!0);o.querySelectorAll("[data-copy-btn]").forEach(l=>l.remove());let a=i.getAttribute("data-copy")==="text"?o.textContent.replace(/^\s+|\s+$/g,""):o.innerHTML.replace(/\s+data-copy(="[^"]*")?/g,"").replace(/^\s*\n/gm,"").trim();navigator.clipboard.writeText(a).then(()=>{let l=n.textContent;n.textContent="copied",n.dataset.copied="",setTimeout(()=>{n.textContent=l,delete n.dataset.copied},1200)}).catch(()=>{n.textContent="error",setTimeout(()=>{n.textContent="copy"},1200)})})})();ei(ri);var Gs=xr,Js={cms:xr};return ui(Ys);})();
1753
1795
 
1754
1796
  // Auto-export to window unless suppressed by loader.
1755
1797
  // Per hypercms plan locked decision 3: flatten to hyperclay.hypercms.open(),