@panphora/clayjs 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
- var hypercms=(()=>{var $t=Object.defineProperty;var yi=Object.getOwnPropertyDescriptor;var vi=Object.getOwnPropertyNames;var xi=Object.prototype.hasOwnProperty;var Pt=(e,t)=>{for(var r in t)$t(e,r,{get:t[r],enumerable:!0})},wi=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of vi(t))!xi.call(e,i)&&i!==r&&$t(e,i,{get:()=>t[i],enumerable:!(n=yi(t,i))||n.enumerable});return e};var _i=e=>wi($t({},"__esModule",{value:!0}),e);var ua={};Pt(ua,{cms:()=>la,default:()=>ca});function Q(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=Q(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}var qr={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 Si(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 Ei(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 Ci(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 Ti(e,t){return(e.textContent||"").replace(/\s+/g," ").trim().slice(0,t.textHintLength)}function Ri(e,t){let r=[e.tagName];return t.includeClasses&&r.push(Ei(e)),r.push(Ci(e,t)),Si(r.join("|"))}function Oi(e){let t=e.tagName,r=1,n=e.previousElementSibling;for(;n;)n.tagName===t&&r++,n=n.previousElementSibling;return r}function Mi(e,t){return e.getAttribute?.("id")||e.getAttribute?.("role")?!0:t.landmarks.includes(e.tagName)}function Ni(e){let t=e.getAttribute?.("id");if(t)return`#${t}`;let r=e.getAttribute?.("role");return r?`@${r}`:e.tagName}function Ii(e,t){let r=[],n=e;for(;n&&n.tagName&&r.length<t.maxPathDepth;){let i=`${n.tagName}:${Oi(n)}`;if(r.unshift(i),n!==e&&Mi(n,t)){r.unshift(Ni(n));break}n=n.parentElement}return r}function ji(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:Ri(e,t),path:Ii(e,t),textHint:Ti(e,t)};return r.set(e,n),n}function Br(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 Li(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),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 p=ji(o.path,s.path)*a.pathSegment;c+=p,l.path=p;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 u=Math.abs(o.domIndex-s.domIndex),y=Math.min(u*a.positionPenalty,a.maxDriftPenalty);c-=y,l.drift=-y}return{score:c,breakdown:l}}function Dr(e,t,r,n,i){if(r.excludeIds&&e.getAttribute("id"))return null;let o=Br(t,r,n,i),s=se(e,r,n);if(typeof s.domIndex!="number"){let d=0,u=e.previousElementSibling;for(;u;)d++,u=u.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,m=0,p=null;for(let d of l){let{score:u,breakdown:y}=Bt(e,d,r,n,{candidateCount:l.length});u>m&&(m=u,c=d,p=y)}return m<r.minConfidence?null:{element:c,confidence:m,breakdown:p}}function Fi(e,t,r,n){let i=[],o=r.weights.signature+r.weights.slotMatch,s={slot:o};function a(p){if(p.children)return p.children;let d=p.childNodes;if(!d)return[];let u=[];for(let y=0;y<d.length;y++)d[y].nodeType===1&&u.push(d[y]);return u}function l(p,d){let u=a(p),y=a(d);if(u.length===y.length)for(let N=0;N<u.length;N++){let R=u[N],F=y[N];if(r.shouldIgnore?.(R)||r.shouldIgnore?.(F)||r.excludeIds&&(R.getAttribute("id")||F.getAttribute("id"))||R.tagName!==F.tagName)continue;let V=se(R,r,n).signature,te=se(F,r,n).signature;V!==te&&i.push({newEl:R,oldEl:F,score:o,breakdown:s}),l(R,F)}}function c(p,d){for(;;){if(p.tagName===d.tagName)return[p,d];let u=a(p);if(!p.tagName&&u.length===1){p=u[0];continue}let y=a(d);if(y.length===1&&y[0].tagName===p.tagName){d=y[0];continue}return null}}let m=c(e,t);return m&&l(m[0],m[1]),i}function $r(e,t,r,n,i){let o=t.querySelectorAll("*"),s=Br(e,r,n,i),a=0;for(let u of o){let y=se(u,r,n);y.domIndex=a++}let l=[],c=new Map;function m(u,y,N){let R=new Set;if(u.textHint){let z=c.get(u.signature);if(!z){z=new Map;for(let ee of y){let pe=se(ee,r,n).textHint,fe=z.get(pe);fe||(fe=[],z.set(pe,fe)),fe.push(ee)}c.set(u.signature,z)}let oe=z.get(u.textHint);if(oe)for(let ee=0;ee<oe.length&&ee<N;ee++)R.add(oe[ee])}let F=0,V=y.length;for(;F<V;){let z=F+V>>1;se(y[z],r,n).domIndex<u.domIndex?F=z+1:V=z}let te=Math.max(0,Math.min(F-(N>>1),y.length-N)),le=Math.min(te+N,y.length);for(let z=te;z<le;z++)R.add(y[z]);return[...R]}for(let u of o){if(r.shouldIgnore?.(u)||r.excludeIds&&u.getAttribute("id"))continue;let y=se(u,r,n),N=s.get(y.signature)||[],R=r.excludeIds?N.filter(te=>!te.getAttribute("id")):N,F=r.maxScoredCandidates,V=F&&R.length>F?m(y,R,F):R;for(let te of V){let{score:le,breakdown:z}=Bt(u,te,r,n,{candidateCount:R.length});le>=r.minConfidence&&l.push({newEl:u,oldEl:te,score:le,breakdown:z})}}if(r.weights.slotMatch>0){let u=Fi(t,e,r,n);for(let y of u)l.push(y)}l.sort((u,y)=>y.score-u.score);let p=new Map,d=new Set;for(let{newEl:u,oldEl:y}of l)p.has(u)||d.has(y)||(p.set(u,y),d.add(y));return p}function Pr(e,t,r,n){let i=se(e,r,n),o=se(t,r,n),{score:s,breakdown:a}=Bt(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 Ur(e={}){let t={...qr,...e,weights:{...qr.weights,...e.weights}},r=new WeakMap,n=new WeakMap;return{findMatch:(i,o)=>Dr(i,o,t,r,n),computeMatches:(i,o)=>$r(i,o,t,r,n),explain:(i,o)=>Pr(i,o,t,r),invalidate:i=>Li(i,r,n),session:()=>{let i=new WeakMap,o=new WeakMap;return{findMatch:(s,a)=>Dr(s,a,t,i,o),computeMatches:(s,a)=>$r(s,a,t,i,o),explain:(s,a)=>Pr(s,a,t,i)}},getConfig:()=>({...t})}}function Ut(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 zr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,r)=>r.length%2===0?r+'\\"':t)}var qi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Di=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ot(e){try{return JSON.parse(e)}catch{return JSON.parse($i(e))}}function $i(e){let t="",r=0,n=(i,o)=>{throw new Error(`Invalid relaxed JSON: ${i} at position ${o}`)};for(;r<e.length&&(r=Ut(e,r),!(r>=e.length));){let i=e[r];if("{}[]:".includes(i)){t+=i,r++;continue}if(i===","){let a=Ut(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=zr(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"||qi.test(s)){t+=s,r=o;continue}if(Di.test(s)){if(e[Ut(e,o)]===":"){t+='"'+s+'"',r=o;continue}n("unquoted value "+JSON.stringify(s),r)}n("invalid token "+JSON.stringify(s),r)}return t}function Hr(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 p=!1,d=s+1;for(;d<i.length&&/\s/.test(i[d]);)d++;if(d<i.length&&/[a-zA-Z_]/.test(i[d])&&(p=!0),!p){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 p=a,d=s+1;for(;d<i.length&&i[d]!==p;)i[d]==="\\"&&d++,d++;o.push({type:t.STRING,value:i.substring(s+1,d),quoted:!0,sourceQuote:p}),s=d+1;continue}let l=s,c;for(;l<i.length&&!/[{},]/.test(i[l]);)if(i[l]===":"){let p=[":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 u of p){let y=u.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 p=i[l];for(l++;l<i.length&&i[l]!==p;)i[l]==="\\"&&l++,l++}l++}l<i.length&&i[l]==="]"&&l++}else l++;c=i.substring(s,l);let m=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?m=t.NUMBER:c==="true"||c==="false"||c==="null"?m=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(m=t.SELECTOR),o.push({type:m,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=zr(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 Y=Symbol("hyper-morph-json-merge:missing"),Vr=["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 Pi(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 Wr(e,t,r,n){return be(t,r)?t:be(t,e)?r:be(r,e)?t:Ce(t)&&Ce(r)?Bi(Ce(e)?e:{},t,r,n):Array.isArray(t)&&Array.isArray(r)?Vi(Array.isArray(e)?e:[],t,r,n):r}function Kr(e,t,r,n){return t===Y&&r===Y?Y:t===Y?e===Y?r:be(r,e)?Y:r:r===Y?e===Y?t:Y:Wr(e,t,r,n)}function Bi(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=Kr(He(e,s)?e[s]:Y,He(t,s)?t[s]:Y,He(r,s)?r[s]:Y,n);a!==Y&&Pi(i,s,a)}return i}function Ui(e){return e===null||typeof e!="object"}function st(e){return typeof e+":"+String(e)}function zi(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 Hi(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(zi(s,i))return{kind:"keyed",field:s};return null}for(let s of i){let a=new Set;for(let l of s){if(!Ui(l))return null;let c=st(l);if(a.has(c))return null;a.add(c)}}return{kind:"self"}}function Vi(e,t,r,n){let i=Hi(e,t,r,n);if(!i)return r;let o=i.kind==="self"?st:u=>st(u[i.field]),s=u=>{let y=new Map;for(let N of u)y.set(o(N),N);return y},a=s(e),l=s(t),c=s(r),m=new Map,p=new Set([...a.keys(),...l.keys(),...c.keys()]);for(let u of p){let y=Kr(a.has(u)?a.get(u):Y,l.has(u)?l.get(u):Y,c.has(u)?c.get(u):Y,n);y!==Y&&m.set(u,y)}let d=[];for(let u of r){let y=o(u);m.has(y)&&d.push(y)}for(let u=0;u<t.length;u++){let y=o(t[u]);if(!m.has(y)||d.includes(y))continue;let N=0;for(let R=u-1;R>=0;R--){let F=d.indexOf(o(t[R]));if(F!==-1){N=F+1;break}}d.splice(N,0,y)}return d.map(u=>m.get(u))}function zt(e,t,r,n={}){let i=n.keyCandidates?[...n.keyCandidates,...Vr]:Vr;return Wr(e===void 0?Y:e,t,r,{keyCandidates:i})}function Ht(e,t,r,n={}){let i=n.parse||ot,o=[],s=(p,d)=>{if(typeof p!="string")return Y;try{return i(p)}catch(u){return o.push(`${d} side is not valid JSON (${u.message})`),Y}},a=s(t,"local"),l=s(r,"remote");if(a===Y)return{text:r,warnings:o};if(l===Y)return{text:t,warnings:o};let c=s(e,"base"),m=zt(c===Y?void 0:c,a,l,n);return be(m,l)?{text:r,warnings:o}:be(m,a)?{text:t,warnings:o}:{text:JSON.stringify(m,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(g){if(!(g instanceof Element))return!1;if(g.matches(t))return!0;if(g.tagName==="LINK"||g.tagName==="SCRIPT"){let T=g.getAttribute("src")||g.getAttribute("href")||"";if(T.startsWith("chrome-extension://")||T.startsWith("moz-extension://")||T.startsWith("safari-web-extension://"))return!0}return!1}function n(g){return g instanceof Element?g.closest(t)?!0:r(g):!1}let i=Ur({shouldIgnore:n});function o(g,T,E){if(E){let M=E.identityOf(g);if(M&&!E.disabled.has(M.key))return"hm-merge:"+M.key}if(T!=="smart")return g.outerHTML;let O=g.getAttribute("src"),C=g.getAttribute("type")||"text/javascript";if(O)try{let M=new URL(O,window.location.href);return`ext:${C}:${M.origin}${M.pathname}${M.search}`}catch{return`ext:${C}:${O}`}else{let M=g.textContent.trim(),v=5381;for(let A=0;A<M.length;A++)v=(v<<5)+v^M.charCodeAt(A);return`inline:${C}:${Math.abs(v).toString(36)}`}}let s="http://www.w3.org/1999/xhtml";function a(g){return g instanceof Element&&g.tagName==="SCRIPT"&&g.namespaceURI===s}function l(g){let T=document.createElement("div");T.innerHTML="<script><\/script>";let E=T.firstChild;for(let O of g.attributes)E.setAttribute(O.name,O.value);return E.textContent=g.textContent,E}function c(g){if(a(g))return l(g);if(g instanceof Element)for(let T of g.querySelectorAll("script"))a(T)&&T.replaceWith(l(T));return g}function m(g){let T=(g.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return T==="application/json"||T.endsWith("+json")}let p={match:g=>g.hasAttribute("merge"),identity:g=>g.getAttribute("merge")};function d(g,T,E){if(E.merge===!1)return null;let O=[p,...E.mergeTags||[]],C=new WeakMap,M=b=>{if(C.has(b))return C.get(b);let w=null;if(a(b)&&!b.getAttribute("src")&&!n(b)){let _=b;for(let j=0;j<O.length;j++)if(O[j].match(_)){if(!m(_))console.warn("[hyper-morph] merge ignored: script type is not JSON",_);else{let B=O[j].identity(_);B!=null&&B!==""&&(w={key:j+":"+B,raw:B,recognizer:O[j]})}break}}return C.set(b,w),w},v=new Set,A=b=>{let w=new Map,_=j=>{let B=M(j);B&&(w.has(B.key)?(v.add(B.key),console.warn(`[hyper-morph] merge disabled for duplicate identity "${B.raw}"`)):w.set(B.key,j))};a(b)&&_(b);for(let j of b.querySelectorAll("script"))_(j);return w},k=A(g),f=A(T.__hyperMorphRoot||T);if(k.size===0&&f.size===0)return null;let h=null;return{identityOf:M,disabled:v,oldByKey:k,newByKey:f,baseTexts:()=>{if(h)return h;h=new Map;let b=E.mergeBase;if(!b)return h;let w;typeof b=="string"?w=new DOMParser().parseFromString(b,"text/html").documentElement:b instanceof Document?w=b.documentElement:w=b;let _=j=>{let B=M(j);B&&!h.has(B.key)&&h.set(B.key,j.textContent)};a(w)&&_(w);for(let j of w.querySelectorAll("script"))_(j);return h}}}function u(g,T,E){let O=g.merge;if(!O)return!1;let C=O.identityOf(T);if(!C||O.disabled.has(C.key))return!1;let M=O.identityOf(E);if(!M||M.key!==C.key)return!1;let v=T,A=E,k=A.getAttribute("merge-key")||v.getAttribute("merge-key"),{text:f,warnings:h}=Ht(O.baseTexts().get(C.key),v.textContent,A.textContent,{parse:C.recognizer.parse,keyCandidates:k?k.split(/[\s,]+/).filter(Boolean):void 0});for(let x of h)console.warn(`[hyper-morph] merge "${C.raw}": ${x}`);return v.textContent!==f&&(v.textContent=f),!0}let y={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:g=>g.getAttribute("im-preserve")==="true",shouldReAppend:g=>g.getAttribute("im-re-append")==="true",shouldRemove:e,afterHeadMorphed:e},scripts:{handle:!0,matchMode:"outerHTML",shouldPreserve:g=>g.getAttribute("im-preserve")==="true",shouldReAppend:g=>g.getAttribute("im-re-append")==="true",shouldRemove:e,afterScriptsHandled:e},restoreFocus:!0},N={computeMatches(g,T){let{computeMatches:E}=i.session();return E(g,T)}};function R(g,T,E={}){g=gi(g);let O=Er(T),C=fi(g,O,E),M=C.scripts.handle?new Set(Array.from(g.querySelectorAll("script")).map(f=>o(f,C.scripts.matchMode,C.merge))):null,v=te(C),A=ee(C,g,O,f=>f.morphStyle==="innerHTML"?(z(f,g,O),Array.from(g.childNodes)):V(f,g,O)),k=f=>{v&&le(C,v),F(C);let h=M?Lt(f,M,C):[];return h.length>0?Promise.all(h).then(()=>f):f};return A instanceof Promise?A.then(k):k(A)}function F(g){for(let T of Array.from(g.pantry.childNodes))g.callbacks.beforeNodeRemoved(T)!==!1&&g.callbacks.afterNodeRemoved(T);g.pantry.remove()}function V(g,T,E){let O=Er(T);return z(g,O,E,T,T.nextSibling),Array.from(O.childNodes)}function te(g){if(!g.config.restoreFocus)return null;let T=document.activeElement;if(!(T instanceof HTMLInputElement||T instanceof HTMLTextAreaElement))return null;let{id:E,selectionStart:O,selectionEnd:C}=T;return{element:T,id:E,selectionStart:O,selectionEnd:C}}function le(g,T){let E=T.element;if(T.id&&T.id!==document.activeElement?.getAttribute("id")&&(E=g.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 g(f,h,x,b=null,w=null){h instanceof HTMLTemplateElement&&x instanceof HTMLTemplateElement&&(h=h.content,x=x.content),b||=h.firstChild;for(let _ of x.childNodes){if(r(_))continue;if(b&&b!=w){let B=E(f,_,b,w);if(B){B!==b&&C(f,b,B),oe(B,_,f),b=B.nextSibling;continue}}if(_ instanceof Element){let B=_.getAttribute("id");if(f.persistentIds.has(B)){let S=M(h,B,b,f);oe(S,_,f),b=S.nextSibling;continue}if(!f.idMap.has(_)){let S=f.hyperMatches.get(_);if(S&&!f.idMap.has(S)&&!k(S,h)){A(h,S,b),oe(S,_,f),b=S.nextSibling;continue}}}let j=T(h,_,b,f);j&&(b=j.nextSibling)}for(;b&&b!=w;){let _=b;b=b.nextSibling,r(_)||O(f,_)}}function T(f,h,x,b){if(b.callbacks.beforeNodeAdded(h)===!1)return null;if(b.idMap.has(h)){let w=h,_=document.createElementNS(w.namespaceURI,w.localName);return f.insertBefore(_,x),oe(_,h,b),b.callbacks.afterNodeAdded(_),_}else{let w=c(document.importNode(h,!0));return f.insertBefore(w,x),b.callbacks.afterNodeAdded(w),w}}let E=(function(){function f(b,w,_,j){let B=w instanceof Element&&!b.idMap.has(w)?b.hyperMatches.get(w):null,S=null,I=w.nextSibling,W=0,$=_;for(;$&&$!=j;){if(r($)){$=$.nextSibling;continue}if(x($,w)){if(h(b,$,w)||$===B&&!b.idMap.has($))return $;if(S===null){let K=$ instanceof Element&&b.hyperMatchedOldElements.has($);!b.idMap.has($)&&!K&&(S=$)}}if(S===null&&I&&x($,I)&&(W++,I=I.nextSibling,W>=2&&(S=void 0)),b.activeElementAndParents.includes($))break;$=$.nextSibling}return S||null}function h(b,w,_){let j=b.idMap.get(w),B=b.idMap.get(_);if(!B||!j)return!1;for(let S of j)if(B.has(S))return!0;return!1}function x(b,w){let _=b,j=w;return _.nodeType===j.nodeType&&_.tagName===j.tagName&&(!_.getAttribute?.("id")||_.getAttribute?.("id")===j.getAttribute?.("id"))}return f})();function O(f,h){let x=h instanceof Element&&f.hyperMatchedOldElements.has(h)&&!f.idMap.has(h);if(f.idMap.has(h)||x)A(f.pantry,h,null);else{if(f.callbacks.beforeNodeRemoved(h)===!1)return;h.parentNode?.removeChild(h),f.callbacks.afterNodeRemoved(h)}}function C(f,h,x){let b=h;for(;b&&b!==x;){let w=b;b=b.nextSibling,r(w)||O(f,w)}return b}function M(f,h,x,b){let w=b.target.getAttribute?.("id")===h&&b.target||b.target.querySelector(`[id="${CSS.escape(h)}"]`)||b.pantry.querySelector(`[id="${CSS.escape(h)}"]`);return v(w,b),A(f,w,x),w}function v(f,h){let x=f.getAttribute("id");for(;f=f.parentNode;){let b=h.idMap.get(f);b&&(b.delete(x),b.size||h.idMap.delete(f))}}function A(f,h,x){if(f.moveBefore)try{f.moveBefore(h,x)}catch{f.insertBefore(h,x)}else f.insertBefore(h,x)}function k(f,h){let x=h instanceof Element?h:h.realParentNode;return!!x&&f.contains(x)}return g})(),oe=(function(){function g(v,A,k){return k.ignoreActive&&v===document.activeElement?null:(k.callbacks.beforeNodeMorphed(v,A)===!1||(v instanceof HTMLHeadElement&&k.head.ignore||(v instanceof HTMLHeadElement&&k.head.style!=="morph"?fe(v,A,k):(T(v,A,k),u(k,v,A)||M(v,k)||z(k,v,A))),k.callbacks.afterNodeMorphed(v,A)),v)}function T(v,A,k){let f=A.nodeType;if(f===1){let h=v,x=A,b=h.attributes,w=x.attributes;for(let _ of w)C(_.name,h,"update",k)||h.getAttribute(_.name)!==_.value&&h.setAttribute(_.name,_.value);for(let _=b.length-1;0<=_;_--){let j=b[_];if(j&&!x.hasAttribute(j.name)){if(C(j.name,h,"remove",k))continue;h.removeAttribute(j.name)}}M(h,k)||E(h,x,k)}(f===8||f===3)&&v.nodeValue!==A.nodeValue&&(v.nodeValue=A.nodeValue)}function E(v,A,k){if(v instanceof HTMLInputElement&&A instanceof HTMLInputElement&&A.type!=="file"){let f=A.value,h=v.value;O(v,A,"checked",k),O(v,A,"disabled",k),k.formStateSync==="property"&&v.indeterminate!==A.indeterminate&&(v.indeterminate=A.indeterminate),k.formStateSync==="property"?h!==f&&(C("value",v,"update",k)||(v.value=f)):A.hasAttribute("value")?h!==f&&(C("value",v,"update",k)||(v.setAttribute("value",f),v.value=f)):C("value",v,"remove",k)||(v.value="",v.removeAttribute("value"))}else if(v instanceof HTMLOptionElement&&A instanceof HTMLOptionElement)O(v,A,"selected",k);else if(v instanceof HTMLTextAreaElement&&A instanceof HTMLTextAreaElement){let f=A.value,h=v.value;if(C("value",v,"update",k)||(f!==h&&(v.value=f),k.formStateSync==="property"))return;v.firstChild&&v.firstChild.nodeValue!==f&&(v.firstChild.nodeValue=f)}}function O(v,A,k,f){let h=A[k],x=v[k];if(h!==x){let b=C(k,v,"update",f);if(b||(v[k]=A[k]),f.formStateSync==="property")return;h?b||v.setAttribute(k,""):C(k,v,"remove",f)||v.removeAttribute(k)}}function C(v,A,k,f){return v==="value"&&f.ignoreActiveValue&&A===document.activeElement?!0:f.callbacks.beforeAttributeUpdated(v,A,k)===!1}function M(v,A){return!!A.ignoreActiveValue&&v===document.activeElement&&v!==document.body}return g})();function ee(g,T,E,O){if(g.head.block){let C=T.querySelector("head"),M=E.querySelector("head");if(C&&M){let v=fe(C,M,g);return Promise.all(v).then(()=>(g.head.block=!1,g.head.ignore=!0,O(g)))}}return O(g)}function pe(g){return g.tagName==="SCRIPT"?!!g.getAttribute("src"):g.tagName==="LINK"?(g.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet")&&!!g.getAttribute("href"):!1}function fe(g,T,E){let O=[],C=[],M=[],v=[],A=E.scripts.matchMode,k=x=>{if(x.tagName==="SCRIPT")return o(x,A,E.merge);if(x.tagName==="LINK"&&A==="smart"){let b=x.getAttribute("href");if(b)try{let w=new URL(b,window.location.href);return`link:${x.getAttribute("rel")||""}:${w.origin}${w.pathname}${w.search}`}catch{}}return x.outerHTML},f=new Map;for(let x of T.children){if(r(x))continue;let b=k(x),w=f.get(b);w||(w=[],f.set(b,w)),w.push(x)}for(let x of g.children){let b=k(x),w=f.get(b),_=!!(w&&w.length),j=E.head.shouldReAppend(x),B=E.head.shouldPreserve(x);if(_||B)if(j)C.push(x);else{if(w&&w.length){let S=w.pop();w.length||f.delete(b),u(E,x,S)}M.push(x)}else E.head.style==="append"?j&&(C.push(x),v.push(x)):E.head.shouldRemove(x)!==!1&&!r(x)&&C.push(x)}for(let x of f.values())v.push(...x);let h=[];for(let x of v){let b=document.createRange().createContextualFragment(x.outerHTML).firstChild;if(E.callbacks.beforeNodeAdded(b)!==!1){if(b instanceof Element&&pe(b)){let w,_=new Promise(function(j){w=j});b.addEventListener("load",function(){w()}),b.addEventListener("error",function(){w()}),h.push(_)}g.appendChild(b),E.callbacks.afterNodeAdded(b),O.push(b)}}for(let x of C)E.callbacks.beforeNodeRemoved(x)!==!1&&(g.removeChild(x),E.callbacks.afterNodeRemoved(x));return E.head.afterHeadMorphed(g,{added:O,kept:M,removed:C}),h}function Lt(g,T,E){if(!E.scripts.handle)return[];let O=[],C=[],M=[],v=[],A=E.scripts.matchMode,k=[];for(let h of g)if(h instanceof Element){a(h)&&k.push(h);for(let x of h.querySelectorAll("script"))a(x)&&k.push(x)}for(let h of k){if(h.closest("head")||n(h))continue;let x=o(h,A,E.merge),b=T.has(x),w=E.scripts.shouldPreserve(h),_=E.scripts.shouldReAppend(h);b||w?_?(C.push(h),v.push(h)):M.push(h):v.push(h)}let f=[];for(let h of v){if(E.callbacks.beforeNodeAdded(h)===!1)continue;let x=document.createElement("script");for(let b of h.attributes)x.setAttribute(b.name,b.value);if(x.textContent=h.textContent,x.src){let b,w=new Promise(function(_){b=_});x.addEventListener("load",function(){b()}),x.addEventListener("error",function(){b()}),f.push(w)}h.replaceWith(x),E.callbacks.afterNodeAdded(x),O.push(x)}return E.scripts.afterScriptsHandled(E.target,{added:O,kept:M,removed:C}),f}let fi=(function(){function g(k,f,h){let{persistentIds:x,idMap:b}=v(k,f),w=N.computeMatches(k,f);if(typeof h.key=="function"){let I=new Map,W=new Set,$=D=>{let L=h.key(D);L!=null&&(I.has(L)?W.add(L):I.set(L,D))};k instanceof Element&&$(k);for(let D of k.querySelectorAll("*"))$(D);for(let D of W)I.delete(D);let K=new Map;for(let[D,L]of w)K.set(L,D);let re=f.__hyperMorphRoot||f,X=new Map,J=new Set,q=D=>{let L=h.key(D);L!=null&&(X.has(L)?J.add(L):X.set(L,D))};re instanceof Element&&q(re);for(let D of re.querySelectorAll("*"))q(D);for(let D of J)X.delete(D);for(let[D,L]of X){let H=I.get(D);if(!H||H.tagName!==L.tagName)continue;let G=K.get(H);G&&G!==L&&w.delete(G);let xe=w.get(L);xe&&xe!==H&&K.delete(xe),w.set(L,H),K.set(H,L)}}let _=T(h),j=d(k,f,_.scripts);if(j){let I=new Map;for(let[W,$]of w)I.set($,W);for(let[W,$]of j.newByKey){if(j.disabled.has(W))continue;let K=j.oldByKey.get(W);if(!K)continue;let re=I.get(K);re&&re!==$&&w.delete(re);let X=w.get($);X&&X!==K&&I.delete(X),w.set($,K),I.set(K,$)}}let B=new Set;for(let I of w.values())B.add(I);let S=_.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(S))throw new Error(`Do not understand how to morph style ${S}`);return{target:k,newContent:f,config:_,morphStyle:S,ignoreActive:_.ignoreActive,ignoreActiveValue:_.ignoreActiveValue,restoreFocus:_.restoreFocus,formStateSync:_.formStateSync||"attribute",idMap:b,persistentIds:x,hyperMatches:w,hyperMatchedOldElements:B,merge:j,pantry:E(),activeElementAndParents:O(k),callbacks:_.callbacks,head:_.head,scripts:_.scripts}}function T(k){let f=Object.assign({},y);return Object.assign(f,k),f.callbacks=Object.assign({},y.callbacks,k.callbacks),f.head=Object.assign({},y.head,k.head),f.scripts=Object.assign({},y.scripts,k.scripts),f}function E(){let k=document.createElement("div");return k.hidden=!0,document.body.insertAdjacentElement("afterend",k),k}function O(k){let f=[],h=document.activeElement;if(h?.tagName!=="BODY"&&k.contains(h))for(;h&&(f.push(h),h!==k);)h=h.parentElement;return f}function C(k){let f=Array.from(k.querySelectorAll("[id]"));return k.getAttribute?.("id")&&f.push(k),f}function M(k,f,h,x){for(let b of x){let w=b.getAttribute("id");if(f.has(w)){let _=b;for(;_;){let j=k.get(_);if(j==null&&(j=new Set,k.set(_,j)),j.add(w),_===h)break;_=_.parentElement}}}}function v(k,f){let h=C(k),x=C(f),b=A(h,x),w=new Map;M(w,b,k,h);let _=f.__hyperMorphRoot||f;return M(w,b,_,x),{persistentIds:b,idMap:w}}function A(k,f){let h=new Set,x=new Map;for(let w of k){let _=w.getAttribute("id");x.has(_)?h.add(_):x.set(_,w.tagName)}let b=new Set;for(let w of f){let _=w.getAttribute("id");b.has(_)?h.add(_):x.get(_)===w.tagName&&b.add(_)}for(let w of h)b.delete(w);return b}return g})(),{normalizeElement:gi,normalizeParent:Er}=(function(){let g=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(M(v));if(g.has(v))return v;if(v instanceof Node){if(v.parentNode)return new O(v);{let A=document.createElement("div");return A.append(v),A}}else{let A=document.createElement("div");for(let k of[...v])A.append(k);return A}}class O{constructor(A){this.originalNode=A,this.realParentNode=A.parentNode,this.previousSibling=A.previousSibling,this.nextSibling=A.nextSibling}get childNodes(){let A=[],k=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;k&&k!=this.nextSibling;)A.push(k),k=k.nextSibling;return A}querySelectorAll(A){return this.childNodes.reduce((k,f)=>{if(f instanceof Element){f.matches(A)&&k.push(f);let h=f.querySelectorAll(A);for(let x=0;x<h.length;x++)k.push(h[x])}return k},[])}insertBefore(A,k){return this.realParentNode.insertBefore(A,k)}moveBefore(A,k){return this.realParentNode.moveBefore(A,k)}get __hyperMorphRoot(){return this.originalNode}}function C(v){let A=x=>`<${x}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,k=v.replace(/<!--[\s\S]*?-->/g,"");for(let x of["script","style","textarea","title"])k=k.replace(new RegExp(`${A(x)}[\\s\\S]*?</${x}\\s*>`,"gi"),"");let f=new RegExp(`${A("svg")}[\\s\\S]*?</svg\\s*>`,"gi"),h;do h=k,k=k.replace(f,"");while(k!==h);return k}function M(v){let A=new DOMParser,k=C(v);if(k.match(/<\/html>/)||k.match(/<\/head>/)||k.match(/<\/body>/)){let f=A.parseFromString(v,"text/html");if(k.match(/<\/html>/))return g.add(f),f;{let h=f.firstChild;return h&&g.add(h),h}}else{let h=A.parseFromString("<body><template>"+v+"</template></body>","text/html").body.querySelector("template").content;return g.add(h),h}}return{normalizeElement:T,normalizeParent:E}})(),Cr=Symbol("hyper-morph-duplicate-key"),Tr=[g=>g.getAttribute("data-id"),g=>g.getAttribute("id")];function Ue(g,T){return T.map(E=>{let O=new Map;for(let C of g){if(C.nodeType!==1)continue;let M=E(C);M==null||M===""||O.set(M,O.has(M)?Cr:C)}return O})}function Rr(g,T,E,O){for(let C=0;C<O.length;C++){let M=O[C](g);if(M==null||M===""||T[C].get(M)!==g)continue;let v=E[C].get(M);if(!(!v||v===Cr)&&v.tagName===g.tagName)return v}return null}function Se(g,T,E){for(let O=0;O<E.length;O++){let C=E[O](g);if(!(C==null||C==="")&&T[O].get(C)===g)return!0}return!1}function bi(g,T,E={}){let O=E.skip||(()=>!1),C=E.ignoreAttr||(()=>!1),M=E.tiers&&E.tiers.length?E.tiers:Tr,v=null;function A(){return v||(v=Ue([g,...g.querySelectorAll("*")],M)),v}let k=null;function f(){return k||(k=Ue([T,...T.querySelectorAll("*")],M)),k}function h(q){return!q.parentElement||!q.parentElement.parentElement}function x(q,D,L){return h(q)||Se(q,A(),M)?(L.push({type:"subtree",el:q,base:D}),!1):!0}function b(q,D){let L=[];for(let H of q.attributes)C(q,H.name)||D.getAttribute(H.name)!==H.value&&L.push(H.name);for(let H of D.attributes)C(q,H.name)||q.hasAttribute(H.name)||L.push(H.name);return L}function w(q){let D=[],L=null,H=()=>{L!==null&&(D.push({nodeType:3,nodeValue:L}),L=null)};for(let G of q.childNodes){if(G.nodeType===3){L=(L===null?"":L)+G.nodeValue;continue}G.nodeType===1&&O(G)||(H(),(G.nodeType===1||G.nodeType===8)&&D.push(G))}return H(),D}function _(q,D){if(q.nodeType!==D.nodeType)return!1;if(q.nodeType!==1)return!0;if(q.tagName!==D.tagName)return!1;for(let L of M){let H=L(q),G=L(D);if(H!=null&&H!==""&&G!=null&&G!==""&&H!==G)return!1}return!0}function j(q){let D="";for(let L of q)L.nodeType===3&&L.nodeValue.trim()!==""?D+="\0"+L.nodeValue:L.nodeType===8&&(D+=""+L.nodeValue);return D}function B(q,D,L){let H=w(q),G=w(D);if(H.length===G.length){let P=!0;for(let Z=0;Z<H.length;Z++)if(!_(H[Z],G[Z])){P=!1;break}if(P){for(let Z=0;Z<H.length;Z++){let Ee=H[Z];if(Ee.nodeType===1){if(S(Ee,G[Z],L))return!0}else if(Ee.nodeValue!==G[Z].nodeValue)return!0}return!1}}let xe=H.filter(P=>P.nodeType===1),Ft=G.filter(P=>P.nodeType===1);if(j(H)!==j(G))return!0;let Or=Ue(xe,M),Mr=Ue(Ft,M),qt=[],Dt=new Set,Nr=[];for(let P of xe){let Z=Rr(P,Or,Mr,M);Z&&!Dt.has(Z)?(qt.push([P,Z]),Dt.add(Z)):Nr.push(P)}let ge=[];for(let P of Nr)Se(P,Or,M)?L.push({type:"subtree",el:P,base:null}):ge.push(P);let ze=[];for(let P of Ft)Dt.has(P)||(Se(P,Mr,M)?L.push({type:"deletion",el:P}):ze.push(P));if(ge.length!==ze.length)return!0;for(let P=0;P<ge.length;P++)if(!_(ge[P],ze[P]))return!0;let Ir=new Map(qt);for(let P=0;P<ge.length;P++)Ir.set(ge[P],ze[P]);let jr=-1;for(let P of xe){let Z=Ir.get(P);if(!Z)continue;let Ee=Ft.indexOf(Z);if(Ee<jr)return!0;jr=Ee}for(let P=0;P<ge.length;P++)if(S(ge[P],ze[P],L))return!0;for(let[P,Z]of qt)if(S(P,Z,L))return!0;return!1}function S(q,D,L){if(q.tagName!==D.tagName)return x(q,D,L);let H=b(q,D),G=[];if(B(q,D,G))return x(q,D,L);if(H.length){if(!h(q)&&!Se(D,f(),M))return!0;L.push({type:"attrs",el:q,names:H,base:D})}return L.push(...G),!1}let I=[],W=b(g,T);W.length&&I.push({type:"attrs",el:g,names:W});let $=(q,D)=>Array.from(q.children).find(L=>L.tagName===D)||null,K=$(g,"HEAD"),re=$(T,"HEAD");if(K&&re){let q=[];S(K,re,q),q.length&&I.push({type:"head",el:K})}else(K||re)&&K&&I.push({type:"head",el:K});let X=$(g,"BODY"),J=$(T,"BODY");return X&&J?S(X,J,I):X&&I.push({type:"subtree",el:X,base:null}),{entries:I}}function ki(g,T,E={}){let O=E.tiers&&E.tiers.length?E.tiers:Tr,C=g.documentElement,M=[],v=0,A=S=>({ok:!1,placed:M,held:S,skippedAttrs:v});if(!C)return A(null);function k(S){let I=[S,...S.querySelectorAll("*")];return Ue(I,O)}let f=k(C),h=new Map,x=S=>{let I=S.getRootNode(),W=h.get(I);if(!W){let $=I.nodeType===9?I.documentElement:I;W=k($),h.set(I,W)}return W};function b(S){if(!S.parentElement&&S.tagName==="HTML")return C;if(S.parentElement&&!S.parentElement.parentElement&&S.parentElement.tagName==="HTML"){if(S.tagName==="BODY")return g.body||null;if(S.tagName==="HEAD")return g.head||null}return null}function w(S){let I=b(S);return I||Rr(S,x(S),f,O)}function _(S){if(!S)return null;let I=w(S);return I&&I.isConnected?I:null}function j(S){for(let I=0;I<O.length;I++){let W=O[I](S);W!=null&&W!==""&&f[I].set(W,S)}}for(let S of T){if(S.type!=="deletion")continue;let I=w(S.el);I&&I!==C&&I.remove()}let B=T.filter(S=>S.type!=="deletion").sort((S,I)=>S.el===I.el?0:S.el.compareDocumentPosition(I.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let S of B){if(S.type==="head"){let J=g.importNode(S.el,!0);g.head?g.head.replaceWith(J):C.insertBefore(J,C.firstChild),M.push({entry:S,imported:J});continue}if(S.type==="attrs"){let J=_(S.el)||_(S.base);if(!J){v++;continue}for(let q of S.names)S.el.hasAttribute(q)?J.setAttribute(q,S.el.getAttribute(q)):J.removeAttribute(q);continue}let I=S.el;if(b(I))return A(S);let W=_(I)||_(S.base);if(W){let J=g.importNode(I,!0);W.replaceWith(J),j(J),M.push({entry:S,imported:J});continue}if(S.base!=null&&!Se(S.base,x(S.base),O)||!Se(I,x(I),O))return A(S);let $=I.parentElement;if(!$)return A(S);let K=_($);if(!K)return A(S);let re=null;for(let J=I.previousElementSibling;J;J=J.previousElementSibling){let q=_(J);if(q&&q.parentNode===K){re=q;break}}let X=g.importNode(I,!0);if(re)K.insertBefore(X,re.nextSibling);else{let J=Array.prototype.indexOf.call($.children,I);K.insertBefore(X,K.children[J]||null)}j(X),M.push({entry:S,imported:X})}return{ok:!0,placed:M,held:null,skippedAttrs:v}}return{morph:R,defaults:y,findChangedRoots:bi,spliceProtected:ki,mergeJson:zt,mergeScriptText:Ht,parseJsonRelaxed:ot,parseRulesRelaxed:Hr}})();var Na=Ve.morph,Ia=Ve.defaults,ja=Ve.findChangedRoots,La=Ve.spliceProtected;var Vt=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"],Wt=new Set(at),Gr=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Jr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var lt={};Pt(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 Kt(e,t,r,{depth:0,path:[]},n)}function Kt(e,t,r,n,i){if(n.depth>Oe)throw new we(n.path);if(typeof r=="string")return Yi(e,t,r,n,i);if(Array.isArray(r)){let[o,s]=r,a=e.find(t,o,i);return Zr(i,n,a),a.map((l,c)=>Kt(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]=Kt(e,t,a,{depth:n.depth+1,path:[...n.path,s]},i);return o}return null}function Yi(e,t,r,n,i){if(r.endsWith("[]")){let a=r.slice(0,-2),l=e.find(t,a,i);return Zr(i,n,l),l.map(c=>e.text(c))}if(r.startsWith("@"))return Yr(e,t,r.slice(1));let o=Q(r);if(o!==-1){let a=r.slice(0,o),l=r.slice(o+1),c=a?e.find(t,a,i):[t];return c.length===0?null:Yr(e,c[0],l)}if(r===".")return e.text(t);let s=e.find(t,r,i);return s.length===0?null:e.text(s[0])}function Zr(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(n){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,n)}}function Yr(e,t,r){if(Wt.has(r)){let i=e.prop(t,r);return i==null?null:String(i)}let n=e.attr(t,r);return n||null}function Zi(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Xi(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var Qi={find(e,t,r={}){let n=Xi(e);if(!n||!n.querySelectorAll)return[];let i=Array.from(n.querySelectorAll(t));r.includeRulesTag||(i=i.filter(a=>!Zi(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}},ue=Qi;function Gt(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 p=!1,d=s+1;for(;d<i.length&&/\s/.test(i[d]);)d++;if(d<i.length&&/[a-zA-Z_]/.test(i[d])&&(p=!0),!p){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 p=a,d=s+1;for(;d<i.length&&i[d]!==p;)i[d]==="\\"&&d++,d++;o.push({type:t.STRING,value:i.substring(s+1,d),quoted:!0,sourceQuote:p}),s=d+1;continue}let l=s,c;for(;l<i.length&&!/[{},]/.test(i[l]);)if(i[l]===":"){let p=[":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 u of p){let y=u.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 p=i[l];for(l++;l<i.length&&i[l]!==p;)i[l]==="\\"&&l++,l++}l++}l<i.length&&i[l]==="]"&&l++}else l++;c=i.substring(s,l);let m=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?m=t.NUMBER:c==="true"||c==="false"||c==="null"?m=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(m=t.SELECTOR),o.push({type:m,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,m)=>m.length%2===0?m+'\\"':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 Qr="1",Xr=/^[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"||!Xr.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${Xr})`);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!==Qr)throw new Re(s);return{rules:Me(e.text(o)),tagNode:o}}var ml=new Function("url","return import(url)");function sn(e,t,r,n){let i=e.length,o=t.length,s=new Array(i).fill(-1);if(n){let R=new Set;for(let F=0;F<i;F++){let V=n[F];!(V>=0&&V<o)||R.has(V)||(s[F]=V,R.add(V))}}if(i===0||o===0)return s;let a=e.map(R=>nn(R,r)),l=t.map(R=>nn(R,r)),c=new Array(o).fill(!1);for(let R of s)R>=0&&(c[R]=!0);let m=new Map;l.forEach((R,F)=>{c[F]||m.set(R,m.has(R)?-1:F)});let p=new Map;a.forEach((R,F)=>{s[F]>=0||p.set(R,(p.get(R)||0)+1)}),a.forEach((R,F)=>{if(s[F]>=0||p.get(R)!==1)return;let V=m.get(R);V===void 0||V===-1||c[V]||(s[F]=V,c[V]=!0)});let d=[];for(let R=0;R<i;R++)s[R]<0&&d.push(R);let u=[];for(let R=0;R<o;R++)c[R]||u.push(R);if(d.length===0||u.length===0)return s;let y=i*o+1,N=(R,F)=>to(e[R],t[F],r)*y+Math.abs(R-F);for(let[R,F]of ro(d,u,N))s[R]=F;return s}var an=e=>typeof e=="object"&&e!==null;function nn(e,t){if(!an(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(n=>{let i=JSON.stringify(e?.[n]);return i===void 0?" undef":i}))}function to(e,t,r){if(!an(r))return e===t?0:1;let n=Object.keys(r);if(n.length===0)return 0;let i=0;for(let o of n){let s=JSON.stringify(e?.[o]),a=JSON.stringify(t?.[o]);s!==a&&i++}return i}function ro(e,t,r){return e.length<=t.length?on(e,t,r,!1):on(t,e,(n,i)=>r(i,n),!0)}function on(e,t,r,n){let i=e.length,o=t.length,s=[];for(let p=0;p<=i;p++)s.push(new Float64Array(o+1).fill(1/0));let a=[];for(let p=0;p<=i;p++)a.push(new Uint8Array(o+1));for(let p=0;p<=o;p++)s[i][p]=0;for(let p=i-1;p>=0;p--)for(let d=o-1;d>=0;d--){let u=r(e[p],t[d])+s[p+1][d+1],y=s[p][d+1];u<=y?(s[p][d]=u,a[p][d]=1):s[p][d]=y}let l=[],c=0,m=0;for(;c<i&&m<o;)a[c][m]&&(l.push(n?[t[m],e[c]]:[e[c],t[m]]),c++),m++;return l}function Yt(e,t,r,n,i,o,s,a={}){let l=e.find(t,r,a);if(i.length===0){l.forEach(z=>e.remove(z)),Jt(a,"onRowsApplied",o.path,[]);return}let c=i.length>l.length,m=l[0]||null;if(c&&!m&&(m=so(e,t,r,a),!m))throw new Ke(o.path);let p=l.map(z=>oo(e,z,n,a)),d=null;if(c&&m){d=e.clone(m),a.templateAttr&&e.removeAttr(d,a.templateAttr);let z=e.stripIds(d);z>0&&console.warn(`[hyper-html-api] stripped ${z} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let u=sn(i,p,n,no(e,l,i,o,a)),y=l[0]||m,N=e.parent(y),R=l.length>0?ln(e,N,y):0,F=ao(e,l),V=new Set,te=[],le=i.map((z,oe)=>{let ee=u[oe];if(ee>=0)return V.add(ee),te.push(!1),l[ee];te.push(!0);let pe=e.clone(d);return e.stripIds(pe),pe});l.forEach((z,oe)=>{V.has(oe)||e.remove(z)}),F?le.forEach((z,oe)=>{let ee=R+oe;e.children(N).findIndex(Lt=>e.sameNode(Lt,z))!==ee&&e.insertAt(N,z,ee)}):lo(e,le,te,N,R),io(e,le,n,i,o,s,a),Jt(a,"onRowsApplied",o.path,le)}function Jt(e,t,r,n){if(typeof e[t]=="function")try{return e[t](r.slice(),n)}catch(i){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,i);return}}function no(e,t,r,n,i){let o=Jt(i,"identifyRows",n.path,r);if(!Array.isArray(o))return null;let s=new Array(r.length).fill(-1),a=new Set;for(let l=0;l<r.length;l++)if(o[l]){for(let c=0;c<t.length;c++)if(!(a.has(c)||!e.sameNode(t[c],o[l]))){s[l]=c,a.add(c);break}}return s}function io(e,t,r,n,i,o,s){t.forEach((a,l)=>{if(r===null){let c=n[l],m=c==null?"":String(c);e.text(a)!==m&&e.text(a,m)}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 oo(e,t,r,n){return r===null?e.text(t):ke(e,t,r,n.onRowsRead?{...n,onRowsRead:void 0}:n)}function ln(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 so(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 ao(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 lo(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?ln(e,l,o)+1:s++;e.insertAt(l,t[a],c),o=t[a]}}var cn=new Set(["checked","selected","disabled","readOnly","paused"]);function Ne(e,t,r,n,i={}){let o=[];if(Zt(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 co(e,t,r,n,i,o);if(Array.isArray(r)){let[s,a]=r;return Yt(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 co(e,t,r,n,i,o){if(r.endsWith("[]")){let l=r.slice(0,-2);return Yt(e,t,l,null,n,i,ct,o),t}if(r.startsWith("@"))return dn(e,t,r.slice(1),n);let s=Q(r);if(s!==-1){let l=r.slice(0,s),c=r.slice(s+1),m=l?e.find(t,l,o):[t];return m.length===0||dn(e,m[0],c,n),t}if(r===".")return un(e,t,n),t;let a=e.find(t,r,o);return a.length===0||un(e,a[0],n),t}function un(e,t,r){let n=r==null?"":String(r);e.text(t)!==n&&e.text(t,n)}function dn(e,t,r,n){if(Jr.has(r))throw new Ge(r);if(r==="outerHTML"){let i=n==null?"":String(n);return e.replaceWith(t,i)}return Gr.has(r)?(e.prop(t,r,uo(r,n)),t):(e.attr(t,r,n==null?"":String(n)),t)}function uo(e,t){return t==null?cn.has(e)?!1:"":cn.has(e)?t==="false"?!1:!!t:t}function Zt(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:Ze([...r,o]),expected:"scalar",got:Ye(i)})}):n.push({path:Ze(r),expected:"array",got:Ye(t)});return}t!==null&&typeof t=="object"&&n.push({path:Ze(r),expected:"scalar",got:Ye(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){n.push({path:Ze(r),expected:"array",got:Ye(t)});return}let i=e[1];t.forEach((o,s)=>Zt(i,o,[...r,s],n));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){n.push({path:Ze(r),expected:"object",got:Ye(t)});return}for(let[i,o]of Object.entries(e))Zt(o,t[i],[...r,i],n)}}}function Ye(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Ze(e){return e.join(".")}function Xt(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 hn(e,t,r,n){let i=Xt(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 ne={extract:(e,t,r)=>ke(ue,e,t,r),apply:(e,t,r,n)=>Ne(ue,e,t,r,n),findRulesIn:(e,t)=>Je(ue,e,t),findRules:(e,t)=>Xt(ue,e,t),bind:(e,t,r)=>hn(ue,e,t,r),parseStrict:Gt,parseRelaxed:Me,ruleAttrIndex:Q,splitRule:it,errors:lt,DOM_PROPERTIES:at};var er={};Pt(er,{fromString:()=>me,getRuleAtPath:()=>_e,getValueAtPath:()=>So,setAtPath:()=>Qt,toString:()=>Ao});function Ao(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 So(e,t){let r=e;for(let n of t){if(r==null)return;r=r[n]}return r}function Qt(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]=Qt(o[n],i,r),o}return{...e&&typeof e=="object"?e:{},[n]:Qt((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}={}){Vt.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 Eo='<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>',tr='<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>',gn={"@scalar":`
1
+ var Do=Object.defineProperty;var Gt=(e,t)=>{for(var r in t)Do(e,r,{get:t[r],enumerable:!0})};var Ur={};Gt(Ur,{cms:()=>Vt,default:()=>Ga});function D(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=D(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}import dc from"./hyper-morph.vendor.js";var ot=["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"],Yt=new Set(ot),en=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),qe=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var st={};Gt(st,{EmptyListInsert:()=>Pe,MAX_RULE_DEPTH:()=>ye,MaxRuleDepthExceeded:()=>de,RuleTargetReadOnly:()=>$e,RulesParseError:()=>be,ShapeMismatch:()=>De,UnknownRulesVersion:()=>ke});var be=class extends Error{constructor(t,r){super(t),this.name="RulesParseError",this.cause=r}},ke=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},ye=20,de=class extends Error{constructor(t){super(`rule depth exceeded ${ye} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},De=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},Pe=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}},$e=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}};function ne(e,t,r,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Xt(e,t,r,{depth:0,path:[]},n)}function Xt(e,t,r,n,i){if(n.depth>ye)throw new de(n.path);if(typeof r=="string")return Ho(e,t,r,n,i);if(Array.isArray(r)){let[o,l]=r,s=e.find(t,o,i);return rn(i,n,s),s.map((a,d)=>Xt(e,a,l,{depth:n.depth+1,path:[...n.path,d]},i))}if(typeof r=="object"&&r!==null){let o={};for(let[l,s]of Object.entries(r))o[l]=Xt(e,t,s,{depth:n.depth+1,path:[...n.path,l]},i);return o}return null}function Ho(e,t,r,n,i){if(r.endsWith("[]")){let s=r.slice(0,-2),a=e.find(t,s,i);return rn(i,n,a),a.map(d=>e.text(d))}if(r.startsWith("@"))return tn(e,t,r.slice(1));let o=D(r);if(o!==-1){let s=r.slice(0,o),a=r.slice(o+1),d=s?e.find(t,s,i):[t];return d.length===0?null:tn(e,d[0],a)}if(r===".")return e.text(t);let l=e.find(t,r,i);return l.length===0?null:e.text(l[0])}function rn(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(n){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,n)}}function tn(e,t,r){if(Yt.has(r)){let i=e.prop(t,r);return i==null?null:String(i)}let n=e.attr(t,r);return n||null}var nn=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Vo=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),wc=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function Jt(e,t){if(!e||e.nodeType!==1)return!1;let r=e.getAttribute?.("clay");return!!(r&&r.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Wo(e,t){if(Jt(e,t))return!0;for(let[r,n]of Object.entries(Vo))if(n.includes(t)&&Jt(e,r))return!0;return!1}function ze(e){let t=nn[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(r=>[`[clay~="${r}"]`,`[${r}]`]).join(", ")}function Ko(e,t){let r=e&&e.nodeType===1?e:e?.parentElement;for(;r&&r.nodeType===1;){let n=nn[t];if(!n)throw new Error(`Unknown region capability: ${t}`);if(n.tokens.some(i=>Wo(r,i))||n.bundles.some(i=>Jt(r,i)))return r;r=r.parentElement}return null}function on(e,t){return!!Ko(e,t)}var Go=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function sn(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let r=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&r!=="checkbox"&&r!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let n=0;n<e.options.length;n++)t.options[n].selected=e.options[n].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function ln(e,t,r,n){if(n)return!!e.closest?.(t);let i=e;for(;i?.nodeType===1;){if(i.matches(t))return!0;if(i===r)break;i=i.parentElement}return!1}function an(e,t,r,n,i,o,l,s){if(e.nodeType===1&&((l?on(e,r):ln(e,n,o,!1))||i&&ln(e,i,o,l)))return null;let a=t.importNode(e,!1);s.cloneToLive.set(a,e),s.liveToClone.set(e,a);let d=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,m=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;d!==e&&(s.cloneToLive.set(m,d),s.liveToClone.set(d,m));for(let f of d.childNodes||[]){let c=an(f,t,r,n,i,o,l,s);c&&(m.appendChild(c),f.nodeType===1&&sn(f,c))}return e.nodeType===1&&sn(e,a),a}function Ue(e,{capability:t="data",exclude:r=null,inherit:n=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let o=i.implementation.createHTMLDocument(""),l=new WeakMap,s=new WeakMap,a=e.nodeType===9?e.documentElement:e;r&&o.documentElement.matches(r);let d=ze(t),m=an(a,o,t,d,r,a,n,{cloneToLive:l,liveToClone:s});e.nodeType===9&&m&&(o.replaceChild(m,o.documentElement),s.set(e,o),l.set(o,e));let f=c=>{if(Go.test(c))throw new Error(`Filtered content queries do not support stateful selector: ${c}`)};return{root:m,document:o,capability:t,selector:ze(t),cloneToLive:l,liveToClone:s,original(c){return l.get(c)||null},cloneOf(c){return s.get(c)||null},query(c,h=m){return f(c),Array.from(h.querySelectorAll(c),u=>l.get(u)||u)},text(c=m){return(c===m?m:s.get(c))?.textContent||""},html(c=m){return(c===m?m:s.get(c))?.innerHTML??""},clone(c=m){let h=c===m?m:s.get(c);return h?o.importNode(h,!0):null}}}function cn(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Yo(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var $={semanticExclude:!0,find(e,t,r={}){let n=Yo(e);if(!n||!n.querySelectorAll)return[];let i=Array.from(n.querySelectorAll(t));r.includeRulesTag||(i=i.filter(s=>!cn(s)));let o=[];r.skip&&o.push(r.skip);let l=r.templateAttr===null?null:r.templateAttr||"cms-template";if(l&&o.push("["+l+"]"),o.length){let s=o.join(", ");i=i.filter(a=>!a.closest||!a.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}};function Q(e,t={}){if(t.exclude===null)return $;let r=[ze("data"),t.exclude].filter(Boolean).join(", "),n=e.nodeType===9?e:e.ownerDocument||e,i=e.nodeType===9?e.documentElement:e;if(!t._write&&!i?.matches?.(r)&&!i?.querySelector?.(r)&&!n?.querySelector?.(r))return $;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,s=null,a=()=>s||(s=Ue(o,{capability:"data",exclude:t.exclude||null})),d=u=>{let p=a();return u===e?p.cloneOf(e):p.cloneOf(u)||u},m=u=>s?.original(u)||u,f=(u,p)=>{a().liveToClone.set(u,p),a().cloneToLive.set(p,u);let g=u.childNodes||[],b=p.childNodes||[];for(let y=0;y<Math.min(g.length,b.length);y++)f(g[y],b[y])},c=(u,p,g,b)=>{let y=Array.from(u.childNodes).filter(C=>s.cloneOf(C)),E=y[0];for(;E&&y.includes(E);)E=E.nextSibling;for(let C of y)C.remove();if(g==="innerHTML"){let C=l.createElement("template");C.innerHTML=b;for(let H of Array.from(C.content.childNodes))u.insertBefore(H,E||null)}else u.insertBefore(l.createTextNode(b),E||null);let x=Ue(u,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(x.root?.childNodes||[]));let T=C=>{let H=x.original(C);H&&(s.liveToClone.set(H,C),s.cloneToLive.set(C,H));for(let P of Array.from(C.childNodes||[]))T(P)};for(let C of Array.from(p.childNodes))T(C)},h={...$,find(u,p,g={}){let b=d(u);if(!b?.querySelectorAll)return[];let y=a().query(p,b);g.includeRulesTag||(y=y.filter(x=>!cn(x)));let w=[];g.skip&&w.push(g.skip);let E=g.templateAttr===null?null:g.templateAttr||"cms-template";if(E&&w.push(`[${E}]`),w.length){let x=w.join(", ");y=y.filter(T=>!T.closest?.(x))}return y},parent(u){let p=d(u)?.parentElement;return p?m(p):null},children(u){return Array.from(d(u)?.children||[],m)},text(u,p){if(p===void 0){let y=m(u);return!y?.matches?.(r)&&!y?.querySelector?.(r)?$.text(y):(d(u)?.textContent||"").trim()}let g=m(u);if(!g?.matches?.(r)&&!g?.querySelector?.(r)&&!s){$.text(g,p);return}let b=a().cloneOf(g);b?c(g,b,"textContent",p):$.text(g,p)},attr(u,p,g){let b=m(u);if(g===void 0)return $.attr(b,p);$.attr(b,p,g);let y=s?.cloneOf(b);y&&($.attr(y,p,g),Ue(b,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),s.liveToClone.delete(b),s.cloneToLive.delete(y)))},removeAttr(u,p){let g=m(u);$.removeAttr(g,p);let b=s?.cloneOf(g);b&&$.removeAttr(b,p)},prop(u,p,g){let b=m(u);if(g===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?$.prop(d(b),p):$.prop(b,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",w=y?a().cloneOf(b):s?.cloneOf(b);w&&y?c(b,w,p,g):($.prop(b,p,g),w&&$.prop(w,p,g))},clone(u){let p=d(u);return p===u?$.clone(u):l.importNode(p,!0)},insertAt(u,p,g){let b=m(u),w=h.children(b)[g]||(()=>{for(let T=b.children.length-1;T>=0;T--){let C=b.children[T];if(a().cloneOf(C))return C.nextElementSibling}return b.firstElementChild})(),E=m(p);b.insertBefore(E,w||null);let x=a().cloneOf(b);if(x){let T=a().cloneOf(E);T||(T=l.importNode(E,!0),f(E,T));let C=Array.from(x.children);x.insertBefore(T,C[g]||null)}},remove(u){let p=m(u),g=a().cloneOf(p);$.remove(p),g&&$.remove(g)},replaceWith(u,p){let g=m(u),b=a().cloneOf(g),y=$.replaceWith(g,p);if(b){let w=Ue(y,{capability:"data",exclude:t.exclude||null});if(!w.root)b.remove();else{b.replaceWith(w.root);let E=x=>{let T=w.original(x);T&&(s.liveToClone.set(T,x),s.cloneToLive.set(x,T));for(let C of Array.from(x.childNodes||[]))E(C)};E(w.root)}}return y}};return h}var ve=$;function Zt(e){try{return JSON.parse(e)}catch(t){throw new be(`Invalid strict JSON: ${t.message}`,t)}}function xe(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=[],l=0;for(;l<i.length;){let s=i[l];if(/\s/.test(s)){l++;continue}if("{}".includes(s)){o.push({type:s,value:s}),l++;continue}if(s==="["){let f=!1,c=l+1;for(;c<i.length&&/\s/.test(i[c]);)c++;if(c<i.length&&/[a-zA-Z_]/.test(i[c])&&(f=!0),!f){o.push({type:s,value:s}),l++;continue}}if(s==="]"){o.push({type:s,value:s}),l++;continue}if(s===":"){o.push({type:t.COLON,value:s}),l++;continue}if(s===","){o.push({type:t.COMMA,value:s}),l++;continue}if(s==='"'||s==="'"){let f=s,c=l+1;for(;c<i.length&&i[c]!==f;)i[c]==="\\"&&c++,c++;o.push({type:t.STRING,value:i.substring(l+1,c),quoted:!0,sourceQuote:f}),l=c+1;continue}let a=l,d;for(;a<i.length&&!/[{},]/.test(i[a]);)if(i[a]===":"){let f=[":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"],c=!1;for(let h of f){let u=h.substring(1);if(i.substring(a+1,a+1+u.length)===u){c=!0,a+=u.length;break}}if(!c)break}else if(i[a]==="["){for(a++;a<i.length&&i[a]!=="]";){if(i[a]==='"'||i[a]==="'"){let f=i[a];for(a++;a<i.length&&i[a]!==f;)i[a]==="\\"&&a++,a++}a++}a<i.length&&i[a]==="]"&&a++}else a++;d=i.substring(l,a);let m=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(d)?m=t.NUMBER:d==="true"||d==="false"||d==="null"?m=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(d)&&(m=t.SELECTOR),o.push({type:m,value:d,quoted:!1}),l=a}return o}function n(i){let o="";for(let l=0;l<i.length;l++){let s=i[l];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 a=i[l+1];if(a&&(a.type==="}"||a.type==="]"))continue;o+=s.value;continue}if(s.type===t.STRING&&s.quoted){let a=s.value;s.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(d,m)=>m.length%2===0?m+'\\"':d)),o+=`"${a}"`;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 be("Invalid extraction rules syntax: "+i.message,i)}}var mn="1",dn=/^[a-zA-Z0-9_-]+$/;function Be(e,t,r){let n;if(r===void 0)n="script[data-rules-name]";else{if(typeof r!="string"||!dn.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${dn})`);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],l=e.attr(o,"data-rules-version");if(l!==mn)throw new ke(l);return{rules:xe(e.text(o)),tagNode:o}}var Vc=new Function("url","return import(url)");function bn(e,t,r,n){let i=e.length,o=t.length,l=new Array(i).fill(-1);if(n){let g=new Set;for(let b=0;b<i;b++){let y=n[b];!(y>=0&&y<o)||g.has(y)||(l[b]=y,g.add(y))}}if(i===0||o===0)return l;let s=e.map(g=>fn(g,r)),a=t.map(g=>fn(g,r)),d=new Array(o).fill(!1);for(let g of l)g>=0&&(d[g]=!0);let m=new Map;a.forEach((g,b)=>{d[b]||m.set(g,m.has(g)?-1:b)});let f=new Map;s.forEach((g,b)=>{l[b]>=0||f.set(g,(f.get(g)||0)+1)}),s.forEach((g,b)=>{if(l[b]>=0||f.get(g)!==1)return;let y=m.get(g);y===void 0||y===-1||d[y]||(l[b]=y,d[y]=!0)});let c=[];for(let g=0;g<i;g++)l[g]<0&&c.push(g);let h=[];for(let g=0;g<o;g++)d[g]||h.push(g);if(c.length===0||h.length===0)return l;let u=i*o+1,p=(g,b)=>Jo(e[g],t[b],r)*u+Math.abs(g-b);for(let[g,b]of Zo(c,h,p))l[g]=b;return l}var kn=e=>typeof e=="object"&&e!==null;function fn(e,t){if(!kn(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(n=>{let i=JSON.stringify(e?.[n]);return i===void 0?" undef":i}))}function Jo(e,t,r){if(!kn(r))return e===t?0:1;let n=Object.keys(r);if(n.length===0)return 0;let i=0;for(let o of n){let l=JSON.stringify(e?.[o]),s=JSON.stringify(t?.[o]);l!==s&&i++}return i}function Zo(e,t,r){return e.length<=t.length?gn(e,t,r,!1):gn(t,e,(n,i)=>r(i,n),!0)}function gn(e,t,r,n){let i=e.length,o=t.length,l=[];for(let f=0;f<=i;f++)l.push(new Float64Array(o+1).fill(1/0));let s=[];for(let f=0;f<=i;f++)s.push(new Uint8Array(o+1));for(let f=0;f<=o;f++)l[i][f]=0;for(let f=i-1;f>=0;f--)for(let c=o-1;c>=0;c--){let h=r(e[f],t[c])+l[f+1][c+1],u=l[f][c+1];h<=u?(l[f][c]=h,s[f][c]=1):l[f][c]=u}let a=[],d=0,m=0;for(;d<i&&m<o;)s[d][m]&&(a.push(n?[t[m],e[d]]:[e[d],t[m]]),d++),m++;return a}function er(e,t,r,n,i,o,l,s={}){let a=e.find(t,r,s);if(i.length===0){a.forEach(x=>e.remove(x)),Qt(s,"onRowsApplied",o.path,[]);return}let d=i.length>a.length,m=a[0]||null;if(d&&!m&&(m=rs(e,t,r,s),!m))throw new Pe(o.path);let f=a.map(x=>ts(e,x,n,s)),c=null;if(d&&m){c=e.clone(m),s.templateAttr&&e.removeAttr(c,s.templateAttr);let x=e.stripIds(c);x>0&&console.warn(`[hyper-html-api] stripped ${x} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let h=bn(i,f,n,Qo(e,a,i,o,s)),u=a[0]||m,p=e.parent(u),g=a.length>0?yn(e,p,u):0,b=ns(e,a),y=new Set,w=[],E=i.map((x,T)=>{let C=h[T];if(C>=0)return y.add(C),w.push(!1),a[C];w.push(!0);let H=e.clone(c);return e.stripIds(H),H});a.forEach((x,T)=>{y.has(T)||e.remove(x)}),b?E.forEach((x,T)=>{let C=g+T;e.children(p).findIndex(K=>e.sameNode(K,x))!==C&&e.insertAt(p,x,C)}):is(e,E,w,p,g),es(e,E,n,i,o,l,s),Qt(s,"onRowsApplied",o.path,E)}function Qt(e,t,r,n){if(typeof e[t]=="function")try{return e[t](r.slice(),n)}catch(i){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,i);return}}function Qo(e,t,r,n,i){let o=Qt(i,"identifyRows",n.path,r);if(!Array.isArray(o))return null;let l=new Array(r.length).fill(-1),s=new Set;for(let a=0;a<r.length;a++)if(o[a]){for(let d=0;d<t.length;d++)if(!(s.has(d)||!e.sameNode(t[d],o[a]))){l[a]=d,s.add(d);break}}return l}function es(e,t,r,n,i,o,l){t.forEach((s,a)=>{if(r===null){let d=n[a],m=d==null?"":String(d);e.text(s)!==m&&e.text(s,m)}else{let d=o(e,s,r,n[a],{depth:i.depth+1,path:[...i.path,a]},l);d&&d!==s&&(t[a]=d)}})}function ts(e,t,r,n){return r===null?e.text(t):ne(e,t,r,n.onRowsRead?{...n,onRowsRead:void 0}:n)}function yn(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 rs(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 l of o)if(e.attr(l,n.templateAttr)!=null)return l;i=e.parent(i)}return null}function ns(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 l=n.findIndex(s=>e.sameNode(s,o));if(l===-1)return!1;i.push(l)}return i.sort((o,l)=>o-l),i[i.length-1]-i[0]===i.length-1}function is(e,t,r,n,i){let o=null,l=i;for(let s=0;s<t.length;s++){if(!r[s]){o=t[s];continue}let a=o?e.parent(o):n;if(!a)continue;let d=o?yn(e,a,o)+1:l++;e.insertAt(a,t[s],d),o=t[s]}}var vn=new Set(["checked","selected","disabled","readOnly","paused"]);function we(e,t,r,n,i={}){if(Object.prototype.hasOwnProperty.call(i,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let o=[];if(tr(r,n,[],o),o.length)throw new De(o);lt(e,t,r,n,{depth:0,path:[]},i)}function lt(e,t,r,n,i,o={}){if(i.depth>ye)throw new de(i.path);if(n===void 0)return t;if(typeof r=="string")return os(e,t,r,n,i,o);if(Array.isArray(r)){let[l,s]=r;return er(e,t,l,s,n,i,lt,o),t}if(typeof r=="object"&&r!==null){for(let[l,s]of Object.entries(r)){let a=lt(e,t,s,n==null?n:n[l],{depth:i.depth+1,path:[...i.path,l]},o);a&&a!==t&&(t=a)}return t}return t}function os(e,t,r,n,i,o){if(r.endsWith("[]")){let a=r.slice(0,-2);return er(e,t,a,null,n,i,lt,o),t}if(r.startsWith("@"))return wn(e,t,r.slice(1),n);let l=D(r);if(l!==-1){let a=r.slice(0,l),d=r.slice(l+1),m=a?e.find(t,a,o):[t];return m.length===0||wn(e,m[0],d,n),t}if(r===".")return xn(e,t,n),t;let s=e.find(t,r,o);return s.length===0||xn(e,s[0],n),t}function xn(e,t,r){let n=r==null?"":String(r);e.text(t)!==n&&e.text(t,n)}function wn(e,t,r,n){if(qe.has(r))throw new $e(r);if(r==="outerHTML"){let o=n==null?"":String(n);return e.replaceWith(t,o)}if(en.has(r)){let o=ss(r,n);return e.prop(t,r)!==o&&e.prop(t,r,o),t}let i=n==null?"":String(n);return e.attr(t,r)!==i&&e.attr(t,r,i),t}function ss(e,t){return t==null?vn.has(e)?!1:"":vn.has(e)?t==="false"?!1:!!t:t}function tr(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:Ve([...r,o]),expected:"scalar",got:He(i)})}):n.push({path:Ve(r),expected:"array",got:He(t)});return}t!==null&&typeof t=="object"&&n.push({path:Ve(r),expected:"scalar",got:He(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){n.push({path:Ve(r),expected:"array",got:He(t)});return}let i=e[1];t.forEach((o,l)=>tr(i,o,[...r,l],n));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){n.push({path:Ve(r),expected:"object",got:He(t)});return}for(let[i,o]of Object.entries(e))tr(o,t[i],[...r,i],n)}}}function He(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Ve(e){return e.join(".")}function rr(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 Be(e,n,r)}return null}var V={extract:(e,t,r={})=>ne(Q(e,r),e,t,r),apply:(e,t,r,n={})=>we(Q(e,{...n,_write:!0}),e,t,r,n),findRulesIn:(e,t)=>Be(ve,e,t),findRules:(e,t)=>rr(ve,e,t),bind:(e,t,r={})=>{let n=rr(ve,e,t);if(!n){let i=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${i}`)}return{...n,get:()=>ne(Q(e,r),e,n.rules,r),set:i=>we(Q(e,{...r,_write:!0}),e,n.rules,i,r)}},parseStrict:Zt,parseRelaxed:xe,ruleAttrIndex:D,splitRule:it,errors:st,DOM_PROPERTIES:ot};var ir={};Gt(ir,{fromString:()=>ee,getRuleAtPath:()=>me,getValueAtPath:()=>vs,setAtPath:()=>nr,toString:()=>ys});function ys(e){return e.map(String).join(".")}function ee(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function me(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 vs(e,t){let r=e;for(let n of t){if(r==null)return;r=r[n]}return r}function nr(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]=nr(o[n],i,r),o}return{...e&&typeof e=="object"?e:{},[n]:nr((e||{})[n],i,r)}}function We(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]=We(n);return t}return""}import xs from"./hyper-morph.vendor.js";function at(e,t,{ignoreActiveValue:r=!0}={}){xs.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:r,restoreFocus:!0,formStateSync:"property",policy:"raw"})}import{morph as Rn}from"./hyper-morph.vendor.js";var An=new WeakMap,or=e=>e.map(String).join(".");function ws(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function En(e,t){if(!e||!e.querySelector)return null;let r=e.querySelector(`[data-hcms-path="${ws(t)}"]`),n=r&&r.querySelector(".hcms-array-items");return n?Array.from(n.children).filter(i=>i.matches&&i.matches("[data-hcms-card], [data-hcms-array-item]")):null}function Sn(e,t,r){let n=En(e,t);!n||n.length!==r.length||n.forEach((i,o)=>{r[o]&&An.set(i,r[o])})}function ct(){let e=new Map;return{hooks:{onRowsRead(t,r){e.set(or(t),r)}},seed(t){for(let[r,n]of e)Sn(t,r,n);e.clear()}}}function Tn(e){return{identifyRows(t,r){let n=En(e,or(t));return!n||n.length!==r.length?null:n.map(i=>An.get(i)||null)},onRowsApplied(t,r){Sn(e,or(t),r)}}}var Cn={skip:"[data-hcms-shell]",templateAttr:"cms-template"},sr="data-hcms-rollback-ui",_s=0;function On(e,t,r,n={}){return As(e,t,r,n)}function As(e,t,r,n){let{shellRoot:i,structural:o,structuralPath:l,formRoot:s}=n,a=s?{...Cn,...Tn(s)}:Cn;if(!o)try{return V.apply(e,t,r,a),{ok:!0}}catch(c){return{ok:!1,error:c}}let d=Es(e,t,l),m=d?Ts(d):null,f=d?null:Rs(e,i);try{return V.apply(e,t,r,a),{ok:!0}}catch(c){return m?Cs(d,m):f&&Os(e,i,f),{ok:!1,error:c}}}function Es(e,t,r){if(!r||!e)return null;let n=ee(r),i=[],o=t;for(let l of n){if(typeof o=="string"||o==null||Array.isArray(o))break;if(typeof o=="object"&&l in o){if(i.push(l),o=o[l],Array.isArray(o)||typeof o=="string"&&o.endsWith("[]"))break}else return null}return!Array.isArray(o)&&!(typeof o=="string"&&o.endsWith("[]"))?null:Ss(e,t,i)}function Ss(e,t,r){if(r.length===0)return null;let n=e,i=t;for(let o=0;o<r.length;o++){let l=r[o];if(!i||typeof i!="object"||Array.isArray(i))return null;let s=i[l];if(s==null)return null;if(o===r.length-1){if(Array.isArray(s)){let[a]=s;return n.querySelector?.(a)?.parentElement||null}if(typeof s=="string"&&s.endsWith("[]")){let a=s.slice(0,-2);return n.querySelector?.(a)?.parentElement||null}return null}i=s}return null}function Ts(e){let t=[],r=[];for(let n of Array.from(e.childNodes))t.push(lr(n,r));return{nodes:t,retained:r}}function Cs(e,t){let r=e.cloneNode(!1);for(let n of t.nodes)r.appendChild(n);Rn(e,Array.from(r.childNodes),Nn()),Ln(e,t.retained)}function Rs(e,t){let r=[],n=[];for(let i of Array.from(e.childNodes))i===t||t&&i.contains?.(t)||r.push(lr(i,n));return{nodes:r,retained:n}}function Os(e,t,r){let n=e.cloneNode(!1);for(let i of r.nodes)n.appendChild(i);Rn(e,Array.from(n.childNodes),Nn()),Ln(e,r.retained)}function lr(e,t){let r=e.cloneNode(!1);if(e.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]')){let o=String(++_s);r.setAttribute(sr,o),t.push({id:o,node:e})}let n=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,i=r.nodeType===1&&r.tagName==="TEMPLATE"?r.content:r;for(let o of Array.from(n.childNodes||[]))i.appendChild(lr(o,t));return r}function Ln(e,t){for(let{id:r,node:n}of t){let i=e.querySelector(`[${sr}="${r}"]`);i===n?n.removeAttribute(sr):n.isConnected?i?.remove():i?.replaceWith(n)}}function Nn(){return{morphStyle:"innerHTML",policy:"raw",restoreFocus:!1,scripts:{handle:!1,merge:!1}}}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 Ls='<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>',ar='<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>',Fn={"@scalar":`
3
2
  <label class="hcms-field" data-hcms-shape="scalar">
4
3
  <span class="hcms-label" data-hcms-label></span>
5
4
  <textarea class="mirk-textarea" rows="1" data-hcms-field></textarea>
@@ -39,13 +38,13 @@ var hypercms=(()=>{var $t=Object.defineProperty;var yi=Object.getOwnPropertyDesc
39
38
  </section>
40
39
  `,"@object-array-item":`
41
40
  <article class="hcms-card mirk-sortable__item" draggable="true">
42
- ${Eo}
41
+ ${Ls}
43
42
  <div class="hcms-card-body mirk-sortable__body">
44
43
  <div class="hcms-card-fields"></div>
45
44
  <div class="hcms-card-controls">
46
45
  <button type="button" class="hcms-move hcms-move-up hcms-sr-only" data-hcms-action="move-up" aria-label="Move up">\u2191</button>
47
46
  <button type="button" class="hcms-move hcms-move-down hcms-sr-only" data-hcms-action="move-down" aria-label="Move down">\u2193</button>
48
- <button type="button" class="hcms-remove hcms-remove--card" data-hcms-action="remove" aria-label="Remove">${tr}</button>
47
+ <button type="button" class="hcms-remove hcms-remove--card" data-hcms-action="remove" aria-label="Remove">${ar}</button>
49
48
  </div>
50
49
  </div>
51
50
  <div class="hcms-error" hidden></div>
@@ -59,7 +58,7 @@ var hypercms=(()=>{var $t=Object.defineProperty;var yi=Object.getOwnPropertyDesc
59
58
  <span class="mirk-button__label">Choose</span>
60
59
  </label>
61
60
  <a class="mirk-file__name" data-hcms-field></a>
62
- <button type="button" class="hcms-upload-clear" data-hcms-action="clear-upload" aria-label="Remove file">${tr}</button>
61
+ <button type="button" class="hcms-upload-clear" data-hcms-action="clear-upload" aria-label="Remove file">${ar}</button>
63
62
  </div>
64
63
  <div class="hcms-error" hidden></div>
65
64
  </div>
@@ -73,7 +72,7 @@ var hypercms=(()=>{var $t=Object.defineProperty;var yi=Object.getOwnPropertyDesc
73
72
  </label>
74
73
  <figure class="mirk-image__thumb">
75
74
  <span class="mirk-image__frame"><img class="mirk-image__preview" data-hcms-field alt="" /></span>
76
- <button type="button" class="hcms-upload-clear hcms-upload-clear--badge" data-hcms-action="clear-upload" aria-label="Remove image">${tr}</button>
75
+ <button type="button" class="hcms-upload-clear hcms-upload-clear--badge" data-hcms-action="clear-upload" aria-label="Remove image">${ar}</button>
77
76
  </figure>
78
77
  </div>
79
78
  <div class="hcms-error" hidden></div>
@@ -147,11 +146,11 @@ var hypercms=(()=>{var $t=Object.defineProperty;var yi=Object.getOwnPropertyDesc
147
146
  <input class="hcms-chip-field" data-hcms-field aria-label="Item" placeholder="\u2026" />
148
147
  <button type="button" class="hcms-remove" data-hcms-action="remove" aria-label="Remove">\xD7</button>
149
148
  </span>
150
- `},Co=["@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 Co)vn(e,t,r)}function rr(e,t){if(!gn[t])return null;let r=e&&(e.head||e.documentElement);return r?vn(e,r,t):null}var pn={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"},To=new Set([...Object.values(dt),"@chips","@chips-item"]);function Qe(e,t,r,n){if(typeof e!="string")return"@scalar";let i=Q(e),o=gt(e,i,r,n),s=bt(o,t,"data-hcms-component");if(s&&dt[s]){let a=dt[s],l=Array.isArray(r)&&r.some(c=>c==="*"||typeof c=="number");return a==="@number"&&!fn(e,i,t,l,o).every(Oo)||(a==="@checkbox"||a==="@toggle")&&(i<0||e.slice(i+1)!=="checked")&&!fn(e,i,t,l,o).every(Mo)?"@scalar":a}if(i>=0){let a=e.slice(i+1);if(pn[a])return pn[a]}return"@scalar"}function bn(e,t,r,n){if(typeof e!="string")return null;let i=Q(e),o=bt(gt(e,i,r,n),t,"data-hcms-component");return o&&dt[o]||null}var Ro=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function Oo(e){return e==null||e===""?!0:Ro.test(String(e))}function Mo(e){return e==null||e===""||e==="true"||e==="false"}function fn(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 kn(e,t,r,n){if(typeof e!="string")return null;let i=Q(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 yn(e,t,r,n){if(typeof e!="string")return null;let i=Q(e);return bt(gt(e,i,r,n),t,"data-hcms-crop")}function No(e,t){return t>=0?e.slice(0,t):e}function gt(e,t,r,n){let i=No(e,t);return i&&i!=="."?i:Io(n,r)}function Io(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);To.has(s)&&rr(e,s);return}if(o==="scalar-array"){let s=pt(n,e);s&&(rr(e,s.array),rr(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 vn(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=gn[r].trim(),t.appendChild(i),i}function ce(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${jo(t)}"]`)}function jo(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 xn={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":xn[t]?xn[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function wn(e,t){let r=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),i=yt(e),s=`${An(r,n)}[data-hcms-field="${je(t)}"]`;return r==="INPUT"&&n==="radio"?`${s}:checked@value`:i?`${s}@${i}`:s}function Lo(e){let t=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),n=yt(e),o=`${An(t,r)}[data-hcms-field]`;return t==="INPUT"&&r==="radio"?`${o}:checked@value`:n?`${o}@${n}`:o}function An(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 je(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var _n=new Set(["__proto__","constructor","prototype"]);function vt(e,t){return r(e,[]);function r(c,m){let p=Ae(c);if(p==="scalar")return n(c,m);if(p==="scalar-array")return i(c,m);if(p==="object-array")return o(c,m);if(p==="object"){let d=Object.create(null);for(let[u,y]of Object.entries(c)){if(_n.has(u))throw new Error(`hypercms: rule key "${u}" is forbidden at "${m.join(".")||"<root>"}"`);d[u]=r(y,[...m,u])}return d}return null}function n(c,m){let p=m.length?m[m.length-1]:null,d=typeof p=="string"?p:"__value",u=l(m,d);if(u)return wn(u,d);let y=a(Qe(c,t,m,e),d);return y?wn(y,d):`input[data-hcms-field="${je(d)}"]@value`}function i(c,m){let p=ft(c,m,t),d=p&&a(p.item,null)||a("@scalar-array-item",null),u=d?Lo(d):"input[data-hcms-field]@value";return[s(m,"[data-hcms-array-item]"),u]}function o(c,m){let[,p]=c,d=[...m,"*"],u=s(m,"[data-hcms-card]");if(p&&typeof p=="object"&&!Array.isArray(p)){let y=Object.create(null);for(let[N,R]of Object.entries(p)){if(_n.has(N))throw new Error(`hypercms: rule key "${N}" is forbidden at "${d.join(".")}"`);y[N]=r(R,[...d,N])}return[u,y]}return[u,r(p,[...d,0])]}function s(c,m){let p=c.length?c[c.length-1]:"",d=c.some(N=>N==="*"),u=c.join(".");return`${d?`[data-hcms-field="${je(p)}"]`:`[data-hcms-path="${je(u)}"]`} > .hcms-array-items > ${m}`}function a(c,m){if(!t)return null;let p=ce(t,c);if(!p)return null;let d=p.content||p;if(m){let u=d.querySelector(`[data-hcms-field="${je(m)}"]`);if(u)return u}return d.querySelector("[data-hcms-field]")}function l(c,m){if(!t)return null;let p=c.map(y=>typeof y=="number"?"*":y).join("."),u=[c.join("."),p];for(let y=c.length-1;y>=0;y--){let N=c.slice(0,y).map(R=>typeof R=="number"?"*":R);N.push("*"),u.push(N.join("."))}for(let y of u){if(!y)continue;let N=ce(t,y);if(!N||!et(N))continue;let R=N.content||N,F=R.querySelector(`[data-hcms-field="${je(m)}"]`)||R.querySelector("[data-hcms-field]");if(F)return F}return null}}function nr(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=ir(e,[],r,n,e);return o&&i.appendChild(o),i}function En({shape:e,itemShape:t,pathArr:r,data:n,doc:i,itemKey:o,pageRules:s}){if(e==="object-array-item")return Tn(t,r,n,i,s);if(e==="scalar-array-item")return Rn(r,n,i,o||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function ir(e,t,r,n,i){let o=Ae(e);return o==="scalar"?Fo(e,t,r,n,i):o==="object"?Po(e,t,r,n,i):o==="object-array"?Bo(e,t,r,n,i):o==="scalar-array"?Uo(e,t,r,n):null}function Fo(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=bn(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`),Cn(s,a===o?a:null,t);let l=Le(s,n);Fe(l,t);let c=s.getAttribute?.("data-hcms-tpl");if((o==="@select"||o==="@radio")&&c===o&&qo(l,e,t,r,n,o,i),o==="@image"&&c==="@image"){let m=yn(e,n,t,i);m!=null&&!l.hasAttribute("data-hcms-crop")&&l.setAttribute("data-hcms-crop",m)}return zo(l,he(t)),wt(l,he(t)),_t(l,he(t)),jn(l,r),o==="@file"&&$o(l),l}function Cn(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 qo(e,t,r,n,i,o,s){let a=kn(t,i,r,s),l=a?[...a]:[],c=n==null?"":String(n);if(c!==""&&!l.includes(c)&&l.unshift(c),!a&&(Do(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 u of l){let y=i.createElement("option");y.value=u,y.textContent=mt(u),d.appendChild(y)}return}let m=e.querySelector(".mirk-radio");if(!m||!m.parentNode)return;let p=or(r.join("."));for(let d of l){let u=m.cloneNode(!0),y=u.querySelector('input[type="radio"]');y&&(y.value=d,y.name=p);let N=u.querySelector(".mirk-radio__label");N&&(N.textContent=mt(d)),m.parentNode.insertBefore(u,m)}m.remove()}function or(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function Do(e,t){let r=e.querySelector?e.querySelector(".hcms-error"):null;r&&(r.textContent=t,r.hidden=!1)}function $o(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=nr(t.getAttribute("href")))}function Po(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=Le(o,n);if(Fe(s,t),wt(s,he(t)),_t(s,he(t)),et(o))return Fn(s,e,t),Ln(s,e,r),s;let a=At(s,".hcms-object-fields",o,t);for(let[l,c]of Object.entries(e)){let m=r==null?null:r[l],p=ir(c,[...t,l],m,n,i);p&&a.appendChild(p)}return s}function Bo(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=Le(o,n);Fe(s,t),wt(s,he(t)),_t(s,he(t)),Mn(s,o),In(s,o,t);let a=At(s,".hcms-array-items",o,t),[,l]=e;return(Array.isArray(r)?r:[]).forEach((m,p)=>{let d=Tn(l,[...t,p],m,n,i);d&&a.appendChild(d)}),Nn(s),s}function Tn(e,t,r,n,i){let o=On(t,"object-array-item",n);if(!o)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let s=Le(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)&&(Fn(s,e,t),Ln(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 m=r==null?null:r[l],p=ir(c,[...t,l],m,n,i);p&&a.appendChild(p)}return s}function Uo(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(".")}"`);Cn(a,i?i.array:null,t);let l=Le(a,n);Fe(l,t),wt(l,he(t)),_t(l,he(t)),Mn(l,a),In(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((p,d)=>{let u=Rn([...t,d],p,n,o?o.item:null);u&&c.appendChild(u)}),Nn(l),l}function Rn(e,t,r,n){let i=On(e,"scalar-array-item",r,n);if(!i)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let o=Le(i,r);return o.setAttribute("data-hcms-array-item",""),o.classList.contains("hcms-array-item")||o.classList.add("hcms-array-item"),Fe(o,e),jn(o,t),o}function On(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 Le(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 zo(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 Mn(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 Nn(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=Sn(e,"data-hcms-max-items"),o=Sn(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((m,p)=>{let d=m.querySelector('[data-hcms-action="remove"]');d&&(d.hidden=a||o!=null&&n<=o);let u=m.querySelector('[data-hcms-action="move-up"]');u&&(u.hidden=l||p===0);let y=m.querySelector('[data-hcms-action="move-down"]');y&&(y.hidden=l||p===n-1)})}function Sn(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function In(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 jn(e,t){let r=Ho(e);if(r.length!==0)for(let n of r)qn(n,t)}function Ho(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&Vo(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 Vo(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function Ln(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];qn(i,s)})}function Fn(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 qn(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 Dn=new WeakMap,sr=e=>e.map(String).join(".");function Wo(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function $n(e,t){if(!e||!e.querySelector)return null;let r=e.querySelector(`[data-hcms-path="${Wo(t)}"]`),n=r&&r.querySelector(".hcms-array-items");return n?Array.from(n.children).filter(i=>i.matches&&i.matches("[data-hcms-card], [data-hcms-array-item]")):null}function Pn(e,t,r){let n=$n(e,t);!n||n.length!==r.length||n.forEach((i,o)=>{r[o]&&Dn.set(i,r[o])})}function St(){let e=new Map;return{hooks:{onRowsRead(t,r){e.set(sr(t),r)}},seed(t){for(let[r,n]of e)Pn(t,r,n);e.clear()}}}function Bn(e){return{identifyRows(t,r){let n=$n(e,sr(t));return!n||n.length!==r.length?null:n.map(i=>Dn.get(i)||null)},onRowsApplied(t,r){Pn(e,sr(t),r)}}}var Un={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function zn(e,t,r,n={}){let{observerHandle:i,shellRoot:o,structural:s,structuralPath:a,formRoot:l}=n,c=l?{...Un,...Bn(l)}:Un;i?.pause?.();try{if(!s)try{return ne.apply(e,t,r,c),{ok:!0}}catch(u){return{ok:!1,error:u}}let m=Ko(e,t,a),p=m?Jo(m):null,d=m?null:Zo(e,o);try{return ne.apply(e,t,r,c),{ok:!0}}catch(u){return p?Yo(m,p):d&&Xo(e,o,d),{ok:!1,error:u}}}finally{i?.resume?.()}}function Ko(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:Go(e,t,i)}function Go(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 Yo(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);for(let r of t)e.appendChild(r)}function Zo(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 Xo(e,t,r){for(let i of Array.from(e.childNodes))i===t||t&&i.contains?.(t)||e.removeChild(i);let n=Qo(e,t);for(let i of r)e.insertBefore(i,n||null)}function Qo(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 es={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?rs(t.uploadFileBasic):null)},ts={402:"payment-required",413:"too-large",415:"unsupported-type",401:"unauthorized",403:"forbidden",404:"not-found"},ar=()=>({ok:!1,msg:"Upload cancelled",msgType:"skipped",code:"aborted",uploads:[]});function rs(e){return async function(r,{onProgress:n,signal:i}={}){if(i?.aborted)return ar();try{let o=await e(r,{onProgress:a=>{n?.({loaded:null,total:null,percent:a})}});if(i?.aborted)return ar();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 ar();let s={};try{s=JSON.parse(o?.response||"{}")}catch{s={}}let a=s.code||ts[o?.status]||"error";return{ok:!1,msg:o&&o.message||"Upload failed",msgType:"error",code:a,uploads:[]}}}}function ie(e,t){let r=es[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 Hn=["clay:mutation-ready","hyperclay:mutation-ready"],Vn=["clay:sync-applied","hyperclay:livesync-applied"];function lr(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 Et(e,t){if(!t||e==null)return e;return r(e);function r(n){if(typeof n=="string"){if(n.endsWith("[]")||Q(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 cr(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(cr);let r=t&&t.defaultView||(typeof window<"u"?window:null),n=r&&r.richclay&&r.richclay.RichClay||ie("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 ur=new WeakSet;function Pe(e,t){let r=ie("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 Rt(e){let t=ie("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function Yn(e){let{formRoot:t}=e;if(!t||ur.has(t))return;ur.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"&&cr(a),!a.matches('input[type="file"]')&&(!a.closest("[data-hcms-field]")&&!a.hasAttribute?.("data-hcms-field")||Wn(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]')){us(a,e);return}a.matches('input[type="checkbox"], input[type="radio"], select')&&Wn(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 m=l.closest("[data-hcms-path]");if(!m)return;let p=m.getAttribute("data-hcms-path");mr(p,e)}else if(c==="remove"){let m=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!m)return;ys(m,e)}else if(c==="move-up"||c==="move-down"){let m=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!m)return;bs(m,c==="move-up"?-1:1,e)}else c==="clear-upload"?ps(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),ur.delete(t)}}var ns=new Set(["value","checked"]);function is(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=ne.ruleAttrIndex(n);if(i===-1)return null;let o=n.slice(i+1);if(!ns.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 Wn(e,t){let n=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",i=is(t,n);if(de(ae(t),{path:n,structural:!1},t),i){let o=ie("undo");o&&typeof o.recordValue=="function"&&o.recordValue(i.el,{prop:i.prop,oldValue:i.oldValue,newValue:i.el[i.prop]})}}var os={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function ss(e,t){let r=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(r==null)return{file:e};let n=ie("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:as(r),modal:i,...os});return o===null?null:{file:ls(o.blob,e.name),dataURL:o.dataURL}}catch(i){return $e(t,i&&i.message||"Crop failed"),null}}function as(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 ls(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 cs=new Set(["unsupported","payment-required"]);async function us(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 ss(r,n);if(!o||t.closed){ye(e);return}let s=o.file,a=o.dataURL||null,l=ie("upload");if(typeof l!="function")return dr(e,n,t,i,await Kn(s,a,n),s);Xn(n,a),Gn(n,0);let c=ms(t),m;try{m=await l(s,{signal:c?.signal,onProgress:({percent:d})=>Gn(n,d)})}finally{hs(t,c),gs(n)}if(t.closed){ye(e);return}if(m.code==="aborted"){ye(e);return}if(m.ok)return dr(e,n,t,i,m.uploads[0].url,s);if(!cs.has(m.code)){$e(n,m.msg||"Upload failed"),t.dispatch?.("hcms:error",{error:new Error(m.msg||"Upload failed"),code:m.code,path:i}),ye(e);return}let p=m.code==="payment-required"?"This file is stored in the page. Add a paid plan to upload files.":null;return dr(e,n,t,i,await Kn(s,a,n),s,p)}function dr(e,t,r,n,i,o,s=null){if(r.closed){ye(e);return}if(Xn(t,null),$e(t,null),!i){ye(e);return}Zn(t,i,o.name),de(ae(r),{path:n,structural:!1},r),s&&$e(t,s,"info"),ye(e)}async function Kn(e,t,r){return t||await ds(e,r)}function ds(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 ms(e){if(typeof AbortController!="function")return null;let t=new AbortController;return(e.uploads||(e.uploads=new Set)).add(t),t}function hs(e,t){t&&e.uploads?.delete(t)}function ps(e,t){let r=e.closest("[data-hcms-path]");if(!r)return;let n=r.getAttribute("data-hcms-path")||"";Zn(r,"","");let i=r.querySelector('input[type="file"][data-hcms-upload]');i&&ye(i),$e(r,null),de(ae(t),{path:n,structural:!1},t)}function fs(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function Zn(e,t,r){let n=fs(e);if(!n)return;let i=(n.tagName||"").toUpperCase();i==="IMG"?n.src=t||"":i==="A"&&(n.href=t||"",n.textContent=t?r||nr(t):"")}function ye(e){try{e.value=""}catch{}}function Xn(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 Gn(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 gs(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 mr(e,t){let{formRoot:r,pageRules:n}=t,i=r.querySelector(`[data-hcms-path="${Es(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=_s(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 m=Tt(i,"data-hcms-max-items"),p=o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(i.hasAttribute("data-hcms-no-add")||m!=null&&p.length>=m)return;let d=p.length,u=l?a[1]:a.replace(/\[\]$/,""),y=Xe(l?u:"string"),N=En({shape:l?"object-array-item":"scalar-array-item",itemShape:u,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),pr(i),Pe(`Add ${e}`,()=>de(ae(t),{path:e,structural:!0},t))}function bs(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),gr(i),pr(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")||""}`,()=>de(ae(r),{path:n.getAttribute("data-hcms-path")||"",structural:!0},r))}var Ct="Delete this item?";function ks(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||Ct;let n=t&&t.confirmRemove;return n===!1?null:typeof n=="string"?n||Ct:n===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?Ct:null}function ys(e,t){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),n=ks(r,t);if(n==null)return De(e,t);let i=ie("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=Tt(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&&gr(n),i&&pr(i),Pe(`Remove ${r}`,()=>de(ae(t),{path:r,structural:!0},t))}}function de(e,t,r){let n=tt(e);if(!t.structural&&n===r.lastFingerprint)return{ok:!0,skipped:!0};let i=zn(r.pageRoot,r.pageRules,e,{observerHandle:r.observerHandle,shellRoot:r.shellRoot,structural:!!t.structural,structuralPath:t.path||null,formRoot:r.formRoot});return i.ok?(r.lastFingerprint=n,r.lastData=e,Jn(r,null),r.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),r.onChange?.(e,t)):(Jn(r,ws(i.error,t.path)),r.dispatch?.("hcms:error",{error:i.error,attemptedData:e}),r.onError?.(i.error)),i}function ae(e){let t=ne.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 Jn(e,t){e.lastErrors=t&&t.length?t:null,hr(e)}function hr(e){if(vs(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=xs(e.formRoot,n);if(i){i.textContent=i.textContent?`${i.textContent}
149
+ `},Ns=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function ut(e){let t=e.head||e.documentElement;if(t)for(let r of Ns)Pn(e,t,r)}function cr(e,t){if(!Fn[t])return null;let r=e&&(e.head||e.documentElement);return r?Pn(e,r,t):null}var Mn={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"},Ms=new Set([...Object.values(dt),"@chips","@chips-item"]);function Ke(e,t,r,n){if(typeof e!="string")return"@scalar";let i=D(e),o=ft(e,i,r,n),l=gt(o,t,"data-hcms-component");if(l&&dt[l]){let s=dt[l],a=Array.isArray(r)&&r.some(d=>d==="*"||typeof d=="number");return s==="@number"&&!jn(e,i,t,a,o).every(Fs)||(s==="@checkbox"||s==="@toggle")&&(i<0||e.slice(i+1)!=="checked")&&!jn(e,i,t,a,o).every(Is)?"@scalar":s}if(i>=0){let s=e.slice(i+1);if(Mn[s])return Mn[s]}return"@scalar"}function In(e,t,r,n){if(typeof e!="string")return null;let i=D(e),o=gt(ft(e,i,r,n),t,"data-hcms-component");return o&&dt[o]||null}var js=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function Fs(e){return e==null||e===""?!0:js.test(String(e))}function Is(e){return e==null||e===""||e==="true"||e==="false"}function jn(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 l=t>=0?e.slice(t+1):null,s=[];for(let a of o)if(!(a.closest&&a.closest("[cms-template], [data-hcms-shell]"))&&(l?l==="value"&&"value"in a?s.push(a.value):s.push(a.getAttribute?a.getAttribute(l):null):s.push((a.textContent||"").trim()),!n))break;return s}function ht(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 _e(e,t,r){let n=e.join("."),i=e.map(o=>typeof o=="number"?"*":o).join(".");return n&&J(r,n)||i&&i!==n&&J(r,i)||J(r,t)}function pt(e,t,r){let n=ht(e,r);if(!n)return null;let i=_e(t,n.array,r);return i&&i.getAttribute("data-hcms-tpl")===n.array?n:null}function qn(e,t,r,n){if(typeof e!="string")return null;let i=D(e),o=gt(ft(e,i,r,n),t,"data-hcms-options");if(o==null)return null;let l=o.trim().split(/\s+/).filter(Boolean);return l.length?l:null}function Dn(e,t,r,n){if(typeof e!="string")return null;let i=D(e);return gt(ft(e,i,r,n),t,"data-hcms-crop")}function qs(e,t){return t>=0?e.slice(0,t):e}function ft(e,t,r,n){let i=qs(e,t);return i&&i!=="."?i:Ds(n,r)}function Ds(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 gt(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 bt(e,t){if(!e||t==null)return;r(t,[]);function r(n,i){let o=ue(n);if(o==="scalar"){let l=Ke(n,e,i,t);Ms.has(l)&&cr(e,l);return}if(o==="scalar-array"){let l=ht(n,e);l&&(cr(e,l.array),cr(e,l.item));return}if(o==="object"){for(let[l,s]of Object.entries(n))r(s,[...i,l]);return}if(o==="object-array"){let l=n[1],s=[...i,"*"];if(l&&typeof l=="object"&&!Array.isArray(l))for(let[a,d]of Object.entries(l))r(d,[...s,a]);else r(l,s)}}}function Pn(e,t,r){let n=J(e,r);if(n)return n;let i=e.createElement("template");return i.setAttribute("data-hcms-tpl",r),i.setAttribute("save-remove",""),i.innerHTML=Fn[r].trim(),t.appendChild(i),i}function J(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${Ps(t)}"]`)}function Ps(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function ue(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function Ge(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var $n={IMG:"src",A:"href"};function kt(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":$n[t]?$n[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function zn(e,t){let r=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),i=kt(e),l=`${Bn(r,n)}[data-hcms-field="${Ae(t)}"]`;return r==="INPUT"&&n==="radio"?`${l}:checked@value`:i?`${l}@${i}`:l}function $s(e){let t=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),n=kt(e),o=`${Bn(t,r)}[data-hcms-field]`;return t==="INPUT"&&r==="radio"?`${o}:checked@value`:n?`${o}@${n}`:o}function Bn(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 Ae(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Un=new Set(["__proto__","constructor","prototype"]);function yt(e,t){return r(e,[]);function r(d,m){let f=ue(d);if(f==="scalar")return n(d,m);if(f==="scalar-array")return i(d,m);if(f==="object-array")return o(d,m);if(f==="object"){let c=Object.create(null);for(let[h,u]of Object.entries(d)){if(Un.has(h))throw new Error(`hypercms: rule key "${h}" is forbidden at "${m.join(".")||"<root>"}"`);c[h]=r(u,[...m,h])}return c}return null}function n(d,m){let f=m.length?m[m.length-1]:null,c=typeof f=="string"?f:"__value",h=a(m,c);if(h)return zn(h,c);let u=s(Ke(d,t,m,e),c);return u?zn(u,c):`input[data-hcms-field="${Ae(c)}"]@value`}function i(d,m){let f=pt(d,m,t),c=f&&s(f.item,null)||s("@scalar-array-item",null),h=c?$s(c):"input[data-hcms-field]@value";return[l(m,"[data-hcms-array-item]"),h]}function o(d,m){let[,f]=d,c=[...m,"*"],h=l(m,"[data-hcms-card]");if(f&&typeof f=="object"&&!Array.isArray(f)){let u=Object.create(null);for(let[p,g]of Object.entries(f)){if(Un.has(p))throw new Error(`hypercms: rule key "${p}" is forbidden at "${c.join(".")}"`);u[p]=r(g,[...c,p])}return[h,u]}return[h,r(f,[...c,0])]}function l(d,m){let f=d.length?d[d.length-1]:"",c=d.some(p=>p==="*"),h=d.join(".");return`${c?`[data-hcms-field="${Ae(f)}"]`:`[data-hcms-path="${Ae(h)}"]`} > .hcms-array-items > ${m}`}function s(d,m){if(!t)return null;let f=J(t,d);if(!f)return null;let c=f.content||f;if(m){let h=c.querySelector(`[data-hcms-field="${Ae(m)}"]`);if(h)return h}return c.querySelector("[data-hcms-field]")}function a(d,m){if(!t)return null;let f=d.map(u=>typeof u=="number"?"*":u).join("."),h=[d.join("."),f];for(let u=d.length-1;u>=0;u--){let p=d.slice(0,u).map(g=>typeof g=="number"?"*":g);p.push("*"),h.push(p.join("."))}for(let u of h){if(!u)continue;let p=J(t,u);if(!p||!Ge(p))continue;let g=p.content||p,b=g.querySelector(`[data-hcms-field="${Ae(m)}"]`)||g.querySelector("[data-hcms-field]");if(b)return b}return null}}function dr(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],r=t.split("/").pop()||t;try{return decodeURIComponent(r)}catch{return r}}function Ee({pageRules:e,formRules:t,data:r,doc:n}){let i=n.createDocumentFragment(),o=mr(e,[],r,n,e);return o&&i.appendChild(o),i}function Vn({shape:e,itemShape:t,pathArr:r,data:n,doc:i,itemKey:o,pageRules:l}){if(e==="object-array-item")return Kn(t,r,n,i,l);if(e==="scalar-array-item")return Gn(r,n,i,o||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function mr(e,t,r,n,i){let o=ue(e);return o==="scalar"?zs(e,t,r,n,i):o==="object"?Vs(e,t,r,n,i):o==="object-array"?Ws(e,t,r,n,i):o==="scalar-array"?Ks(e,t,r,n):null}function zs(e,t,r,n,i){let o=Ke(e,n,t,i),l=_e(t,o,n);if(!l)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let s=In(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`),Wn(l,s===o?s:null,t);let a=Se(l,n);Te(a,t);let d=l.getAttribute?.("data-hcms-tpl");if((o==="@select"||o==="@radio")&&d===o&&Us(a,e,t,r,n,o,i),o==="@image"&&d==="@image"){let m=Dn(e,n,t,i);m!=null&&!a.hasAttribute("data-hcms-crop")&&a.setAttribute("data-hcms-crop",m)}return Gs(a,te(t)),vt(a,te(t)),xt(a,te(t)),Qn(a,r),o==="@file"&&Hs(a),a}function Wn(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 Us(e,t,r,n,i,o,l){let s=qn(t,i,r,l),a=s?[...s]:[],d=n==null?"":String(n);if(d!==""&&!a.includes(d)&&a.unshift(d),!s&&(Bs(e,"data-hcms-options required (space-separated values)"),a.length===0)){e.querySelector(".mirk-radio")?.remove();return}if(o==="@select"){let c=e.querySelector("select[data-hcms-field]");if(!c)return;for(let h of a){let u=i.createElement("option");u.value=h,u.textContent=mt(h),c.appendChild(u)}return}let m=e.querySelector(".mirk-radio");if(!m||!m.parentNode)return;let f=ur(r.join("."));for(let c of a){let h=m.cloneNode(!0),u=h.querySelector('input[type="radio"]');u&&(u.value=c,u.name=f);let p=h.querySelector(".mirk-radio__label");p&&(p.textContent=mt(c)),m.parentNode.insertBefore(h,m)}m.remove()}function ur(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function Bs(e,t){let r=e.querySelector?e.querySelector(".hcms-error"):null;r&&(r.textContent=t,r.hidden=!1)}function Hs(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=dr(t.getAttribute("href")))}function Vs(e,t,r,n,i){let o=_e(t,"@object",n);if(!o)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let l=Se(o,n);if(Te(l,t),vt(l,te(t)),xt(l,te(t)),Ge(o))return ti(l,e,t),ei(l,e,r),l;let s=wt(l,".hcms-object-fields",o,t);for(let[a,d]of Object.entries(e)){let m=r==null?null:r[a],f=mr(d,[...t,a],m,n,i);f&&s.appendChild(f)}return l}function Ws(e,t,r,n,i){let o=_e(t,"@object-array",n);if(!o)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let l=Se(o,n);Te(l,t),vt(l,te(t)),xt(l,te(t)),Xn(l,o),Zn(l,o,t);let s=wt(l,".hcms-array-items",o,t),[,a]=e;return(Array.isArray(r)?r:[]).forEach((m,f)=>{let c=Kn(a,[...t,f],m,n,i);c&&s.appendChild(c)}),Jn(l),l}function Kn(e,t,r,n,i){let o=Yn(t,"object-array-item",n);if(!o)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let l=Se(o,n);if(l.setAttribute("data-hcms-card",""),l.classList.contains("hcms-card")||l.classList.add("hcms-card"),Te(l,t),Ge(o))return e&&typeof e=="object"&&!Array.isArray(e)&&(ti(l,e,t),ei(l,e,r)),l;let s=wt(l,".hcms-card-fields",o,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[a,d]of Object.entries(e)){let m=r==null?null:r[a],f=mr(d,[...t,a],m,n,i);f&&s.appendChild(f)}return l}function Ks(e,t,r,n){let i=ht(e,n),o=pt(e,t,n),l=i?i.array:"@scalar-array",s=_e(t,l,n);if(!s)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);Wn(s,i?i.array:null,t);let a=Se(s,n);Te(a,t),vt(a,te(t)),xt(a,te(t)),Xn(a,s),Zn(a,s,t),o&&a.setAttribute("data-hcms-item-tpl",o.item);let d=wt(a,".hcms-array-items",s,t);return(Array.isArray(r)?r:[]).forEach((f,c)=>{let h=Gn([...t,c],f,n,o?o.item:null);h&&d.appendChild(h)}),Jn(a),a}function Gn(e,t,r,n){let i=Yn(e,"scalar-array-item",r,n);if(!i)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let o=Se(i,r);return o.setAttribute("data-hcms-array-item",""),o.classList.contains("hcms-array-item")||o.classList.add("hcms-array-item"),Te(o,e),Qn(o,t),o}function Yn(e,t,r,n){let i=e.map(o=>typeof o=="number"?"*":o).join(".");return J(r,i)||n&&J(r,n)||J(r,"@"+t)}function Se(e,t){let r=e.content||e,n=t.createElement("div");return n.appendChild(r.cloneNode(!0)),n.firstElementChild||n}function Te(e,t){e.setAttribute("data-hcms-path",t.join("."))}function Gs(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 vt(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function xt(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 Jn(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=Hn(e,"data-hcms-max-items"),o=Hn(e,"data-hcms-min-items"),l=e.hasAttribute("data-hcms-no-add"),s=e.hasAttribute("data-hcms-no-remove"),a=e.hasAttribute("data-hcms-no-reorder"),d=e.querySelector('[data-hcms-action="add"]');d&&(d.hidden=l||i!=null&&n>=i),r.forEach((m,f)=>{let c=m.querySelector('[data-hcms-action="remove"]');c&&(c.hidden=s||o!=null&&n<=o);let h=m.querySelector('[data-hcms-action="move-up"]');h&&(h.hidden=a||f===0);let u=m.querySelector('[data-hcms-action="move-down"]');u&&(u.hidden=a||f===n-1)})}function Hn(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function Zn(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 te(e){return e.length?e[e.length-1]:null}function Qn(e,t){let r=Ys(e);if(r.length!==0)for(let n of r)ri(n,t)}function Ys(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&Xs(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 Xs(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function ei(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 l=r==null?null:r[o];ri(i,l)})}function ti(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 l=[...r,o].join(".");i.setAttribute("data-hcms-path",l)})}function wt(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 ri(e,t){let r=kt(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 Js={Mutation:(e,t)=>e?.Mutation??t?.Mutation,undo:(e,t)=>e?.undo??t?.undo,onPrepareForSave:(e,t)=>e?.addDocumentTransform??t?.onPrepareForSave,onSnapshot:(e,t)=>e?.onSnapshot??t?.onSnapshot,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?Qs(t.uploadFileBasic):null)},Zs={402:"payment-required",413:"too-large",415:"unsupported-type",401:"unauthorized",403:"forbidden",404:"not-found"},hr=()=>({ok:!1,msg:"Upload cancelled",msgType:"skipped",code:"aborted",uploads:[]});function Qs(e){return async function(r,{onProgress:n,signal:i}={}){if(i?.aborted)return hr();try{let o=await e(r,{onProgress:s=>{n?.({loaded:null,total:null,percent:s})}});if(i?.aborted)return hr();let l=o&&o.uploads||[];return typeof l[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:l}}catch(o){if(i?.aborted)return hr();let l={};try{l=JSON.parse(o?.response||"{}")}catch{l={}}let s=l.code||Zs[o?.status]||"error";return{ok:!1,msg:o&&o.message||"Upload failed",msgType:"error",code:s,uploads:[]}}}}function z(e,t){let r=Js[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 ni=["clay:mutation-ready","hyperclay:mutation-ready"],ii=["clay:sync-applied","hyperclay:livesync-applied"],oi=["clay:ready","hyperclay:ready"];function Ce(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)}}var Z="data-hcms-bound",ie="data-hcms-bound-id",pr=new Map;function si(e,t){pr.set(e,t)}function li(e){pr.delete(e)}function ai(e){let t=e.getAttribute(ie);if(!t)return null;let r=pr.get(t);return!r||!r.restorable()?null:r.originalHTML}var he="data-hcms-owns-richclay";function Re(e){return e&&e.richclay&&e.richclay.RichClay||z("RichClay",e)||(e&&typeof e.RichClay=="function"?e.RichClay:null)}function ci(e,t,r){!e||typeof e.setAttribute!="function"||(e.setAttribute(Z,t?"rich":"plain"),r&&e.setAttribute(he,"true"))}function di(e,t){if(!e||typeof e.querySelectorAll!="function")return;let r=e.querySelectorAll(`[${Z}]`);if(!r.length)return;let n=Re(t);if(n&&typeof n.stripFromClone=="function")try{n.stripFromClone(e)}catch(i){console.warn("[hypercms] richclay strip failed; editor state may reach the save",i)}for(let i of r)i.getAttribute(he)==="true"&&i.removeAttribute("data-richclay"),i.removeAttribute(he),i.removeAttribute(Z)}function mi(e,t){if(!e||typeof e.removeAttribute!="function")return;let r=Re(t);if(r&&typeof r.stripElement=="function")try{r.stripElement(e)}catch(n){console.warn("[hypercms] richclay element strip failed; the clone stays editable",n)}else e.removeAttribute("contenteditable"),e.removeAttribute("no-undo");e.getAttribute(he)==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute(he),e.removeAttribute(Z),e.removeAttribute(ie)}function ui(e,t){if(!t||e==null)return e;return r(e);function r(n){if(typeof n=="string"){if(n.endsWith("[]")||D(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,l]of Object.entries(n))i[o]=r(l);return i}return n}}function hi(e,t){if(!t||e==null)return e;return r(e,[t]);function r(n,i){if(typeof n=="string")return n.endsWith("[]")||D(n)!==-1?n:i.some(o=>el(o,n))?n+"@innerHTML":n;if(Array.isArray(n)){let[o,l]=n;if(typeof o!="string"||!o)return n;let s=tl(t,o);return s.length?[o,r(l,s)]:n}if(n&&typeof n=="object"){let o=Object.create(null);for(let[l,s]of Object.entries(n))o[l]=r(s,i);return o}return n}}function el(e,t){let r=null;try{r=e.querySelector(t)}catch{return!1}return r?r.hasAttribute(Z)?r.getAttribute(Z)==="rich":r.children.length>0:!1}function tl(e,t){try{return[...e.querySelectorAll(t)]}catch{return[]}}function Oe(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 oe(e,t,r=!0){if(!e||!e.querySelectorAll||(e.querySelectorAll("textarea[data-hcms-field]").forEach(Oe),r===!1))return;let n=t&&t.defaultView||(typeof window<"u"?window:null),i=Re(n);i&&e.querySelectorAll("[contenteditable][data-hcms-field]").forEach(o=>{if(o.__hcmsRichclay)return;let l;try{l=new i(o,{inline:!0,hyperclay:!1,toolbar:["bold","italic","link","undo","redo"]})}catch(a){console.warn("[hypercms] richclay activation failed; field stays plain contenteditable",a);return}o.__hcmsRichclay=l;let s=l&&l.squire;s&&typeof s.addEventListener=="function"&&s.addEventListener("input",()=>{let a=n&&n.Event||Event;o.dispatchEvent(new a("input",{bubbles:!0}))})})}var fr=new WeakSet;function pe(e,t){let r=z("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 re(e){let t=z("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function Et(e){let{formRoot:t}=e;if(!t||fr.has(t))return;fr.add(t);let r=l=>{let s=l.target;!s||!s.closest||s.closest("[data-hcms-form-root]")&&s.matches("input, textarea, select, [contenteditable][data-hcms-field]")&&(s.tagName==="TEXTAREA"&&Oe(s),!s.matches('input[type="file"]')&&(!s.closest("[data-hcms-field]")&&!s.hasAttribute?.("data-hcms-field")||pi(s,e)))},n=l=>{let s=l.target;if(!(!s||!s.closest)&&s.closest("[data-hcms-form-root]")){if(s.matches('input[type="file"][data-hcms-upload]')){cl(s,e);return}s.matches('input[type="checkbox"], input[type="radio"], select')&&pi(s,e)}},i=l=>{let s=l.target;if(!s||!s.closest)return;let a=s.closest("[data-hcms-action]");if(!a)return;let d=a.getAttribute("data-hcms-action");if(d==="add"||d==="remove"||d==="move-up"||d==="move-down"||d==="clear-upload"){if(!a.closest("[data-hcms-form-root]"))return}else if(d==="close"&&!a.closest("[data-hcms-shell]"))return;if(d==="add"){let m=a.closest("[data-hcms-path]");if(!m)return;let f=m.getAttribute("data-hcms-path");Ye(f,e)}else if(d==="remove"){let m=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!m)return;kr(m,e)}else if(d==="move-up"||d==="move-down"){let m=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!m)return;br(m,d==="move-up"?-1:1,e)}else d==="clear-upload"?hl(a,e):d==="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),fr.delete(t)}}var rl=new Set(["value","checked"]);function nl(e,t){if(!t)return null;let r=ee(t);if(r.some(a=>typeof a=="number"||a==="*"))return null;let n=me(e.pageRules,r);if(typeof n!="string")return null;let i=V.ruleAttrIndex(n);if(i===-1)return null;let o=n.slice(i+1);if(!rl.has(o))return null;let l=n.slice(0,i),s=l?e.pageRoot.querySelector(l):e.pageRoot;return s?{el:s,prop:o,oldValue:s[o]}:null}function pi(e,t){let n=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",i=nl(t,n);if(G(W(t),{path:n,structural:!1},t),i){let o=z("undo");o&&typeof o.recordValue=="function"&&o.recordValue(i.el,{prop:i.prop,oldValue:i.oldValue,newValue:i.el[i.prop]})}}var il={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function ol(e,t){let r=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(r==null)return{file:e};let n=z("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:sl(r),modal:i,...il});return o===null?null:{file:ll(o.blob,e.name),dataURL:o.dataURL}}catch(i){return Ne(t,i&&i.message||"Crop failed"),null}}function sl(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 ll(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 al=new Set(["unsupported","payment-required"]);async function cl(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")||"";Ne(n,null);let o=await ol(r,n);if(!o||t.closed){se(e);return}let l=o.file,s=o.dataURL||null,a=z("upload");if(typeof a!="function")return gr(e,n,t,i,await fi(l,s,n),l);yi(n,s),gi(n,0);let d=ml(t),m;try{m=await a(l,{signal:d?.signal,onProgress:({percent:c})=>gi(n,c)})}finally{ul(t,d),fl(n)}if(t.closed){se(e);return}if(m.code==="aborted"){se(e);return}if(m.ok)return gr(e,n,t,i,m.uploads[0].url,l);if(!al.has(m.code)){Ne(n,m.msg||"Upload failed"),t.dispatch?.("hcms:error",{error:new Error(m.msg||"Upload failed"),code:m.code,path:i}),se(e);return}let f=m.code==="payment-required"?"This file is stored in the page. Add a paid plan to upload files.":null;return gr(e,n,t,i,await fi(l,s,n),l,f)}function gr(e,t,r,n,i,o,l=null){if(r.closed){se(e);return}if(yi(t,null),Ne(t,null),!i){se(e);return}ki(t,i,o.name),G(W(r),{path:n,structural:!1},r),l&&Ne(t,l,"info"),se(e)}async function fi(e,t,r){return t||await dl(e,r)}function dl(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 ml(e){if(typeof AbortController!="function")return null;let t=new AbortController;return(e.uploads||(e.uploads=new Set)).add(t),t}function ul(e,t){t&&e.uploads?.delete(t)}function hl(e,t){let r=e.closest("[data-hcms-path]");if(!r)return;let n=r.getAttribute("data-hcms-path")||"";ki(r,"","");let i=r.querySelector('input[type="file"][data-hcms-upload]');i&&se(i),Ne(r,null),G(W(t),{path:n,structural:!1},t)}function pl(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function ki(e,t,r){let n=pl(e);if(!n)return;let i=(n.tagName||"").toUpperCase();i==="IMG"?n.src=t||"":i==="A"&&(n.href=t||"",n.textContent=t?r||dr(t):"")}function se(e){try{e.value=""}catch{}}function yi(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 gi(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 fl(e){e.removeAttribute("data-hcms-uploading"),e.style?.removeProperty?.("--hcms-upload-progress")}function Ne(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 Ye(e,t){let{formRoot:r,pageRules:n}=t,i=r.querySelector(`[data-hcms-path="${Me(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 l=ee(e),s=vl(n,l),a=Array.isArray(s),d=typeof s=="string"&&s.endsWith("[]");if(!a&&!d)throw new Error(`hypercms: path "${e}" is not an array`);let m=At(i,"data-hcms-max-items"),f=o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(i.hasAttribute("data-hcms-no-add")||m!=null&&f.length>=m)return;let c=f.length,h=a?s[1]:s.replace(/\[\]$/,""),u=We(a?h:"string"),p=Vn({shape:a?"object-array-item":"scalar-array-item",itemShape:h,pathArr:[...l,c],data:u,doc:t.doc,itemKey:i.getAttribute("data-hcms-item-tpl")||null,pageRules:n});return o.appendChild(p),oe(p,t.doc,t.view?.enhanceFormRichText!==!1),vr(i),pe(`Add ${e}`,()=>G(W(t),{path:e,structural:!0},t))}function br(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]")),l=o.indexOf(e);if(l<0)return;let s=l+t;if(s<0||s>=o.length)return;let a=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),xr(i),vr(n),a&&typeof a.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),pe(`Reorder ${n.getAttribute("data-hcms-path")||""}`,()=>G(W(r),{path:n.getAttribute("data-hcms-path")||"",structural:!0},r))}var _t="Delete this item?";function gl(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||_t;let n=t&&t.confirmRemove;return n===!1?null:typeof n=="string"?n||_t:n===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?_t:null}function kr(e,t){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),n=gl(r,t);if(n==null)return Le(e,t);let i=z("consent")||typeof window<"u"&&window.consent;typeof i=="function"?Promise.resolve(i(n)).then(()=>{t.closed||Le(e,t)},()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(n)&&Le(e,t):Le(e,t)}function Le(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=At(i,"data-hcms-min-items"),l=i.querySelector(".hcms-array-items"),s=l?l.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]").length:0;if(o!=null&&s<=o)return}return e.remove(),n&&xr(n),i&&vr(i),pe(`Remove ${r}`,()=>G(W(t),{path:r,structural:!0},t))}}function G(e,t,r){if(r.closed)return{ok:!1,skipped:!0,closed:!0};let n=Xe(e);if(!t.structural&&n===r.lastFingerprint)return{ok:!0,skipped:!0};let i=Object.hasOwn(r,"writeRules")?r.writeRules:r.pageRules,o=On(r.pageRoot,i,e,{shellRoot:r.shellRoot,structural:!!t.structural,structuralPath:t.path||null,formRoot:r.formRoot});return o.ok?(r.lastFingerprint=n,r.lastData=e,bi(r,null),r.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),r.onChange?.(e,t)):(bi(r,yl(o.error,t.path)),r.dispatch?.("hcms:error",{error:o.error,attemptedData:e}),r.onError?.(o.error)),o}function St(e,t){let r=Me(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 Tt(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 l=Me(n),s=r.querySelectorAll(`[data-hcms-path="${l}"][data-hcms-field][type="radio"], [data-hcms-path="${l}"] [data-hcms-field][type="radio"]`);s.length?s.forEach(a=>{a.checked=String(a.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)}function W(e){let t=V.extract(e.formRoot,e.formRules,{exclude:null});return le(t,e.formRules)}function le(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=>le(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]=le(e[n],i);return r}return e}function bi(e,t){e.lastErrors=t&&t.length?t:null,yr(e)}function yr(e){if(bl(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=kl(e.formRoot,n);if(i){i.textContent=i.textContent?`${i.textContent}
151
150
  ${r}`:r,i.hidden=!1;continue}}t.push(r)}t.length&&e.errorEl&&(e.errorEl.textContent=t.join(`
152
- `),e.errorEl.hidden=!1)}function vs(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function xs(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 ws(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 _s(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 Tt(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function pr(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=Tt(e,"data-hcms-max-items"),o=Tt(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((m,p)=>{let d=m.querySelector('[data-hcms-action="remove"]');d&&(d.hidden=a||o!=null&&n<=o);let u=m.querySelector('[data-hcms-action="move-up"]');u&&(u.hidden=l||p===0);let y=m.querySelector('[data-hcms-action="move-down"]');y&&(y.hidden=l||p===n-1)})}function fr(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>gr(t))}function gr(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&&As(n,i,s),r++}for(let[n,i]of t)n.checked!==i&&(n.checked=i)}function As(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))}Ss(e)}function Ss(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=or(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 Es(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Is={},Ot="hcms-shell-styles",Cs="hcms-bundled-styles-installed",Ts='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,br="";function ei(e){br=e}var Rs=0;function Qn(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}function ti({mountTo:e,side:t="right",overlay:r=!1,showSaveButton:n=!1,title:i="Page content",eyebrow:o="Edit",theme:s=null,doc:a}){ri(a);let l=`hcms-shell-title-${++Rs}`,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 m=s==="dark"?" dark":s==="light"?" light":"";c.className="hcms-shell pixel-quiet hcms-side-"+t+(r?" hcms-overlay":"")+m;let p=Qn(i),d=Qn(o);c.innerHTML=`
151
+ `),e.errorEl.hidden=!1)}function bl(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function kl(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,l=>"\\"+l),o=e.querySelector(`[data-hcms-path="${i}"]`);if(o){for(let l of o.children)if(l.classList&&l.classList.contains("hcms-error"))return l}r.pop()}return null}function yl(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 vl(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 At(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function vr(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=At(e,"data-hcms-max-items"),o=At(e,"data-hcms-min-items"),l=e.hasAttribute("data-hcms-no-add"),s=e.hasAttribute("data-hcms-no-remove"),a=e.hasAttribute("data-hcms-no-reorder"),d=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');d&&(d.hidden=l||i!=null&&n>=i),r.forEach((m,f)=>{let c=m.querySelector('[data-hcms-action="remove"]');c&&(c.hidden=s||o!=null&&n<=o);let h=m.querySelector('[data-hcms-action="move-up"]');h&&(h.hidden=a||f===0);let u=m.querySelector('[data-hcms-action="move-down"]');u&&(u.hidden=a||f===n-1)})}function Ct(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>xr(t))}function xr(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 l=o.join(".");l!==i&&xl(n,i,l),r++}for(let[n,i]of t)n.checked!==i&&(n.checked=i)}function xl(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))}wl(e)}function wl(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=ur(r.getAttribute("data-hcms-path")))}}function Xe(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 Me(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Rt="hcms-shell-styles",_l="hcms-bundled-styles-installed",Ot="hcms-session-open",Al='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',je=new WeakSet,wr="";function xi(e){wr=e}function Je(e){e?.body?.classList.add(Ot)}function _r(e){e?.body?.classList.remove(Ot)}var El=0;function vi(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}function wi({mountTo:e,side:t="right",overlay:r=!1,showSaveButton:n=!1,title:i="Page content",eyebrow:o="Edit",theme:l=null,doc:s}){_i(s);let a=`hcms-shell-title-${++El}`,d=s.createElement("div");d.setAttribute("data-hcms-shell",""),d.setAttribute("editor-ui",""),d.setAttribute("save-remove",""),d.setAttribute("save-ignore",""),d.setAttribute("tabindex","-1"),d.setAttribute("role","dialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby",a);let m=l==="dark"?" dark":l==="light"?" light":"";d.className="hcms-shell pixel-quiet hcms-panel hcms-side-"+t+(r?" hcms-overlay":"")+m;let f=vi(i),c=vi(o);d.innerHTML=`
153
152
  <div class="hcms-shell-minibar" aria-hidden="true">
154
- <span class="hcms-shell-minibar-title">${p}</span>
153
+ <span class="hcms-shell-minibar-title">${f}</span>
155
154
  <button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
156
155
  <span class="mirk-button__label">\xD7</span>
157
156
  </button>
@@ -159,8 +158,8 @@ ${r}`:r,i.hidden=!1;continue}}t.push(r)}t.length&&e.errorEl&&(e.errorEl.textCont
159
158
  <div class="hcms-shell-body">
160
159
  <header class="hcms-shell-header">
161
160
  <div class="hcms-shell-heading">
162
- <div class="hcms-shell-eyebrow">${d}</div>
163
- <h2 class="hcms-shell-title" id="${l}">${p}</h2>
161
+ <div class="hcms-shell-eyebrow">${c}</div>
162
+ <h2 class="hcms-shell-title" id="${a}">${f}</h2>
164
163
  </div>
165
164
  <button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
166
165
  <span class="mirk-button__label">\xD7</span>
@@ -175,21 +174,133 @@ ${r}`:r,i.hidden=!1;continue}}t.push(r)}t.length&&e.errorEl&&(e.errorEl.textCont
175
174
  </button>
176
175
  </footer>
177
176
  </div>
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=Ns(c,a),R=Ms(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(),R.detach(),c.remove(),y.classList.remove("hcms-open","hcms-overlay","hcms-side-left")},restoreChrome(){Os(a),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(Ot)||e.querySelector("style[data-hcms-bundled-styles]")||(Be.delete(e),ri(e)))}function ri(e){if(e&&!Be.has(e)){if(e[Cs]){Be.add(e);return}if(e.getElementById(Ot)||e.querySelector("style[data-hcms-bundled-styles]")){Be.add(e);return}if(br){let t=e.createElement("style");t.id=Ot,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=br,(e.head||e.documentElement).appendChild(t),Be.add(e);return}try{let t=new URL("./theme.generated.css",Is.url).href,r=e.createElement("link");r.rel="stylesheet",r.id=Ot,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 Ms(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 Ns(e,t){function r(n){if(n.key!=="Tab"||!e.contains(t.activeElement))return;let i=Array.from(e.querySelectorAll(Ts));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 js="[hypercms]",ni={skip:"[data-hcms-shell]",templateAttr:"cms-template"},ii={skip:"[data-hcms-shell]",templateAttr:null},kr=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 Nt(e,t){let r=[],n=[];return yr(e,t,[],r,n),{missing:Ds(r),twins:$s(n)}}function yr(e,t,r,n,i){if(typeof t=="string"){let o=Ls(t);if(!o)return;let s=Mt(e,o,ni,r);if(t.endsWith("[]")){s.length===0&&Mt(e,o,ii,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=Mt(e,o,ni,r);if(a.length===0){Mt(e,o,ii,r).length===0&&n.push(rt(r));return}for(let l of a)yr(l,s,[...r,"*"],n,i);return}if(t&&typeof t=="object")for(let[o,s]of Object.entries(t))yr(e,s,[...r,o],n,i)}function Mt(e,t,r,n){try{return ue.find(e,t,r)}catch(i){throw new kr(rt(n),t,i)}}function Ls(e){if(e==="."||e.startsWith("@"))return null;if(e.endsWith("[]"))return e.slice(0,-2)||null;let t=Q(e);return(t===-1?e:e.slice(0,t))||null}function It(e){Fs(e),qs(e)}function Fs(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 qs(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(`${js} "${n}" matches ${i} elements; edits go to the first one.`)}}function Ds(e){return[...new Set(e)]}function $s(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 Ps={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function jt(e,{ignoreActiveValue:t}={}){let r=ne.findRules(e.doc,e.rulesSource||"cms");r&&(e.pageRules=e.richText?Et(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=Nt(e.pageRoot,e.pageRules);let n=St(),i=ve(ne.extract(e.pageRoot,e.pageRules,{...Ps,...n.hooks}),e.pageRules),o=xt({pageRules:e.pageRules,formRules:e.formRules,data:i,doc:e.doc});ut(e.formRoot,o,{ignoreActiveValue:t}),n.seed(e.formRoot),qe(e.formRoot,e.doc),hr(e),It(e),e.updateFingerprint&&e.updateFingerprint()}function oi({debounce:e=100,onRefresh:t}){let r=ie("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 Bs="[hypercms]";function si(e,t){if(!e||!e.querySelectorAll||!t)return;let r=Us(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(i=>{let o=i.getAttribute("data-hcms-tpl");o&&(o.startsWith("@")||r.has(o)||console.warn(`${Bs} template "${o}" doesn't match any rule path; ignored`))})}function Us(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(m=>typeof m=="number"?"*":m).join(".");if(t.add(c),a==="object-array"){let m=i[1];if(m&&typeof m=="object"&&!Array.isArray(m))for(let[p,d]of Object.entries(m))r([...l,p],d)}}}}var ai="hcms-toggle",li="hcms-toggle-style",zs=`
179
- #hcms-toggle {
180
- position: fixed; right: 16px; bottom: 16px; z-index: 2147482900;
181
- display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
182
- border: 1px solid #3a3f58; background: #14161f; color: #f2f3f7;
183
- font: 500 13px/1 system-ui, sans-serif; border-radius: 999px; cursor: pointer;
184
- box-shadow: 0 10px 28px -12px rgba(0, 0, 0, .55);
185
- }
186
- #hcms-toggle:hover { background: #1d2030; }
187
- #hcms-toggle .hcms-toggle__close { display: none; }
188
- body.hcms-open #hcms-toggle .hcms-toggle__open { display: none; }
189
- body.hcms-open #hcms-toggle .hcms-toggle__close { display: inline; }
190
- body.hcms-open:not(.hcms-overlay):not(.hcms-side-left) #hcms-toggle { right: calc(380px + 16px); }
191
- body.hcms-open.hcms-overlay #hcms-toggle { display: none; }
192
- `;function Hs({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 Vs({open:e,close:t,isOpen:r},n=document){let i=n.getElementById(ai);if(i)return i;if(!n.getElementById(li)){let s=n.createElement("style");s.id=li,s.setAttribute("snapshot-remove",""),s.textContent=zs,n.head.appendChild(s)}let o=n.createElement("button");return o.type="button",o.id=ai,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 ci(e){if(typeof window>"u"||typeof document>"u")return;let t=window.__hyperclayEditMode!=null?window.__hyperclayEditMode:null;if(!Hs({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 mi(e){ei(e)}var U={isOpen:!1,ctx:null,shell:null,opts:null};function ui(e,t){if(U.ctx!==e)return;let r=t==="livesync";t==="livesync"&&U.shell?.restoreChrome?.(),jt(e,{ignoreActiveValue:r})}var di=!1;function Ws(){if(di)return;let e=ie("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")}),di=!0)}function wr(e={}){if(U.isOpen){console.warn("cms.open() called while already open; ignoring");return}Ws();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=ne.findRules(r,n);if(!i){let y=typeof n=="string"?`data-rules-name~="${n}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${y}`)}let o=e.richText!==!1,s=o?Et(i.rules,t):i.rules,a=i.tagNode;ht(r),kt(r,s),si(r,s);let l=vt(s,r),c=Nt(t,s),m=St(),p=ve(ne.extract(t,s,{skip:"[data-hcms-shell]",templateAttr:"cms-template",...m.hooks}),s),d=Rt(()=>ti({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:s,formRules:l,rulesTagNode:a,rulesSource:n,richText:o,formRoot:d.formRoot,shellRoot:d.root,errorEl:d.errorEl,noticeEl:d.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(y,N){let R=r.defaultView&&r.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!R)return;let F=new R(y,{bubbles:!0,cancelable:y==="hcms:change",detail:N});d.root.dispatchEvent(F)},onCloseRequested(){_r()}};u.updateFingerprint=()=>{u.lastFingerprint=tt(ae(u))};try{let y=xt({pageRules:s,formRules:l,data:p,doc:r});d.formRoot.appendChild(y),m.seed(d.formRoot),qe(d.formRoot,r),It(u),Yn(u),u.updateFingerprint(),u.observerHandle=oi({onRefresh:()=>jt(u)});let N=ie("undo");if(N&&typeof N.on=="function"){let F=()=>{if(U.ctx!==u)return;ui(u,"undo");let V=ve(ne.extract(u.pageRoot,u.pageRules,{skip:"[data-hcms-shell]",templateAttr:"cms-template"}),u.pageRules);tt(V)!==tt(u.lastData)&&(u.lastData=V,u.onChange?.(V,{path:"",structural:!1}))};N.on("undo",F),N.on("redo",F),u.undoUnsub=()=>{N.off("undo",F),N.off("redo",F)}}let R=()=>ui(u,"livesync");u.livesyncUnsub=lr(r,Vn,R),nt.ctx=u,Gs(r),Ks(d.root),U.isOpen=!0,U.ctx=u,U.shell=d,U.opts=e,u.dispatch("hcms:open",{pageRoot:t})}catch(y){throw u.observerHandle?.unsubscribe?.(),u.undoUnsub?.(),u.livesyncUnsub?.(),u.detachEvents?.(),nt.ctx===u&&(nt.ctx=null),Rt(()=>d.destroy()),U.isOpen=!1,U.ctx=null,U.shell=null,U.opts=null,y}}function Ks(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 Gs(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let r=function(){let i=nt.ctx;if(i)return fr(i.formRoot),Pe("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 xr="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(xr)!=="true"?t:(i.set(xr,"false"),"?"+i.toString())}function Ys(e){let t=typeof e=="string"?e:"",r=t.indexOf("?"),n=r===-1?t:t.slice(r+1);return n?new URLSearchParams(n).get(xr)==="true":!1}function Zs(){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 _r(){if(!U.isOpen)return;let{ctx:e,shell:t}=U;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),Zs(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),Rt(()=>t.destroy()),U.isOpen=!1,U.ctx=null,U.shell=null,U.opts=null,nt.ctx=null,r&&typeof r.focus=="function")try{r.focus()}catch{}}function hi(){U.isOpen&&jt(U.ctx)}function Xs(){return U.isOpen}var Qs={getData(){return U.isOpen?ae(U.ctx):null},setValue(e,t){if(!U.isOpen)throw new Error("hypercms: cms is not open");let r=U.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=ea(r.formRoot,e);if(!o)throw new Error(`hypercms: no field element at path "${e}"`);ta(o,t,r.formRoot,e),de(ae(r),{path:e,structural:!1},r)},addItem(e){if(!U.isOpen)throw new Error("hypercms: cms is not open");mr(e,U.ctx)},removeItem(e){if(!U.isOpen)throw new Error("hypercms: cms is not open");let t=U.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="${Sr(e)}"]`);if(!s)throw new Error(`hypercms: no element at path "${e}"`);De(s,t)},refresh:hi,_commit(){if(!U.isOpen)return;let e=U.ctx;return fr(e.formRoot),Pe("Update",()=>de(ae(e),{path:"",structural:!0},e))}};function ea(e,t){let r=Sr(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 ta(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=Sr(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 ra=250,na=1e4;function ia(){typeof window>"u"||typeof document>"u"||Ys(window.location?window.location.search:"")&&(U.isOpen||oa(()=>{if(!U.isOpen)try{wr()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function vr(){return!!document.body&&!!ie("Mutation")}function oa(e){if(vr()){queueMicrotask(e);return}let t=Date.now()+na,r=!1,n=null,i=null,o=()=>{r||(r=!0,n!==null&&clearInterval(n),i&&i())};function s(){if(U.isOpen){o();return}vr()&&(o(),e())}i=lr(document,Hn,s),n=setInterval(()=>{if(U.isOpen){o();return}if(vr()){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."))},ra)}ia();ci({open:wr,close:_r,isOpen:Xs,hasRules:e=>!!ne.findRules(e,"cms")});var Ar={open:wr,close:_r,refresh:hi,api:Qs,get isOpen(){return U.isOpen},path:er,scaffold:Xe,morphForm:ut};function Sr(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var pi=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
177
+ `,(e||s.body).appendChild(d);let u=s.body;u.classList.add("hcms-open"),Je(s),r&&u.classList.add("hcms-overlay"),t==="left"&&u.classList.add("hcms-side-left");let p=Tl(d,s),g=Sl(d);return{root:d,formRoot:d.querySelector("[data-hcms-form-root]"),noticeEl:d.querySelector(".hcms-shell-notice"),errorEl:d.querySelector(".hcms-shell-error"),saveButton:d.querySelector(".hcms-shell-save"),destroy(){p.detach(),g.detach(),d.remove(),u.classList.remove("hcms-open","hcms-overlay","hcms-side-left"),_r(s)},restoreChrome(){ae(s),u.classList.add("hcms-open"),Je(s),r&&u.classList.add("hcms-overlay"),t==="left"&&u.classList.add("hcms-side-left")}}}function ae(e){e&&(e.getElementById(Rt)||e.querySelector("style[data-hcms-bundled-styles]")||(je.delete(e),_i(e)))}function _i(e){if(e&&!je.has(e)){if(e[_l]){je.add(e);return}if(e.getElementById(Rt)||e.querySelector("style[data-hcms-bundled-styles]")){je.add(e);return}if(wr){let t=e.createElement("style");t.id=Rt,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=wr,(e.head||e.documentElement).appendChild(t),je.add(e);return}try{let t=new URL("./theme.generated.css",import.meta.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),je.add(e)}catch{let r=()=>{link.isConnected&&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.")};e.defaultView?.queueMicrotask?e.defaultView.queueMicrotask(r):r()}}}function Sl(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 Tl(e,t){function r(n){if(n.key!=="Tab"||!e.contains(t.activeElement))return;let i=Array.from(e.querySelectorAll(Al));if(i.length===0)return;let o=i[0],l=i[i.length-1];n.shiftKey&&t.activeElement===o?(n.preventDefault(),l.focus()):!n.shiftKey&&t.activeElement===l&&(n.preventDefault(),o.focus())}return t.addEventListener("keydown",r),{detach:()=>t.removeEventListener("keydown",r)}}var Cl="[hypercms]",Ai={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Ei={skip:"[data-hcms-shell]",templateAttr:null},Ar=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 Nt(e,t){let r=[],n=[],i=[];return Sr(Q(e),e,t,[],r,n,i),{missing:Si(r),twins:Ml(n),readOnly:Si(i)}}function Mt(e){return Er(e)}function Er(e){if(typeof e=="string")return Ti(e)?void 0:e;if(Array.isArray(e)){let[t,r]=e;return[t,Er(r)]}if(e&&typeof e=="object"){let t={};for(let[r,n]of Object.entries(e)){let i=Er(n);i!==void 0&&(t[r]=i)}return t}return e}function Sr(e,t,r,n,i,o,l){if(typeof r=="string"){let s=Rl(r),a=s?Lt(e,t,s,Ai,n):[];if(Ti(r)){l.push(Fe(n));return}if(!s)return;if(r.endsWith("[]")){a.length===0&&Lt(e,t,s,Ei,n).length===0&&i.push(Fe(n));return}a.length===0?i.push(Fe(n)):a.length>1&&o.push({path:Fe(n),count:a.length});return}if(Array.isArray(r)){let[s,a]=r;if(typeof s!="string"||!s)return;let d=Lt(e,t,s,Ai,n);if(d.length===0){Lt(e,t,s,Ei,n).length===0&&i.push(Fe(n));return}for(let m of d)Sr(e,m,a,[...n,"*"],i,o,l);return}if(r&&typeof r=="object")for(let[s,a]of Object.entries(r))Sr(e,t,a,[...n,s],i,o,l)}function Lt(e,t,r,n,i){try{return e.find(t,r,n)}catch(o){throw new Ar(Fe(i),r,o)}}function Rl(e){if(e==="."||e.startsWith("@"))return null;if(e.endsWith("[]"))return e.slice(0,-2)||null;let t=D(e);return(t===-1?e:e.slice(0,t))||null}function Ol(e){if(e.endsWith("[]"))return null;let t=D(e);return t===-1?null:e.slice(t+1)||null}function Ti(e){let t=Ol(e);return t!=null&&qe.has(t)}function Ie(e){Ll(e),Nl(e)}function Ll(e){let t=e.noticeEl;if(!t)return;let r=e.unresolved&&e.unresolved.missing||[],n=e.unresolved&&e.unresolved.readOnly||[];if(r.length===0&&n.length===0){t.textContent="",t.hidden=!0;return}let i=[];if(r.length){let o=r.length===1?"1 field no longer matches this page":`${r.length} fields no longer match this page`;i.push(`${o}: ${r.join(", ")}`)}if(n.length){let o=n.length===1?"1 field reads a property the browser will not let anything write":`${n.length} fields read properties the browser will not let anything write`;i.push(`${o}: ${n.join(", ")}`)}t.textContent=i.join(`
178
+ `),t.hidden=!1}function Nl(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(`${Cl} "${n}" matches ${i} elements; edits go to the first one.`)}}function Si(e){return[...new Set(e)]}function Ml(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 Fe(e){return e.length?e.join("."):"(whole page)"}var jl={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function ce(e,{ignoreActiveValue:t}={}){return Fl(e,{ignoreActiveValue:t})}function Fl(e,{ignoreActiveValue:t}){let r=V.findRules(e.doc,e.rulesSource||"cms");r&&(e.pageRules=e.view.prepareRules(r.rules),e.rulesTagNode=r.tagNode),ut(e.doc),bt(e.doc,e.pageRules),e.formRules=yt(e.pageRules,e.doc),e.writeRules=Mt(e.pageRules),e.unresolved=Nt(e.pageRoot,e.pageRules);let n=ct(),i=le(V.extract(e.pageRoot,e.pageRules,{...jl,...n.hooks}),e.pageRules),o=Ee({pageRules:e.pageRules,formRules:e.formRules,data:i,doc:e.doc});at(e.formRoot,o,{ignoreActiveValue:t}),n.seed(e.formRoot),oe(e.formRoot,e.doc,e.view?.enhanceFormRichText!==!1),yr(e),Ie(e),e.updateFingerprint&&e.updateFingerprint()}function Ci({debounce:e=100,onRefresh:t}){let r=z("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=r.onAnyChange({debounce:e},i=>{t(i)});return{unsubscribe:typeof n=="function"?n:()=>{}}}var Il='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])';function Ri({doc:e,pageRoot:t,opts:r={}}){let n=r.richText!==!1,i=null;return{name:"sidebar",richText:n,enhanceFormRichText:!0,ctx:null,root:null,formRoot:null,errorEl:null,noticeEl:null,prepareRules(o){return n?ui(o,t):o},mount(o){let l=this.ctx;i=re(()=>wi({mountTo:r.mountTo||e.body,side:r.side||"right",overlay:!!r.overlay,showSaveButton:!!r.showSaveButton,title:r.title,eyebrow:r.eyebrow,theme:r.theme,doc:e})),this.root=i.root,this.formRoot=i.formRoot,this.errorEl=i.errorEl,this.noticeEl=i.noticeEl;let s=Ee({pageRules:l.pageRules,formRules:l.formRules,data:o,doc:e});i.formRoot.appendChild(s),l.seeder.seed(i.formRoot),oe(i.formRoot,e),Ie(l),Et(l)},refresh(o){if(o==="livesync"){i?.restoreChrome?.(),ce(this.ctx,{ignoreActiveValue:!0});return}if(o==="undo"){ce(this.ctx,{ignoreActiveValue:!1});return}ce(this.ctx)},focusOnOpen(){let o=this.root&&this.root.querySelector(Il);o&&typeof o.focus=="function"&&o.focus()},destroy(){i?.destroy(),i=null}}}var ql="[cms-template], [data-hcms-shell]";function Ze(e){if(!e||typeof e.getBoundingClientRect!="function"||typeof e.closest=="function"&&e.closest(ql))return!1;let t=e.getBoundingClientRect();return t.width>=8&&t.height>=8}var Dl={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Pl={skip:"[data-hcms-shell]",templateAttr:null},$l="text",zl="native",Oi="handle",Ul=new Set(["INPUT","TEXTAREA","SELECT"]),Mi=new Set(["IMG","INPUT","TEXTAREA","SELECT","OPTION","BR","HR","VIDEO","AUDIO","IFRAME","EMBED","OBJECT","CANVAS","SOURCE","TRACK","AREA","COL","PARAM","BUTTON"]);function Cr(e,t){return Bl(e,t)}function Bl(e,t){let r=[],n=[],i=Q(e);return Tr(i,e,t,[],r,n),{targets:r,lists:n}}function Tr(e,t,r,n,i,o){if(typeof r=="string"){if(r.endsWith("[]")){let m=r.slice(0,-2);if(!m)return;let f=jt(e,t,m);f.forEach((c,h)=>{i.push(Ni([...n,h],c,r,null))}),o.push(Li(e,t,n,m,f,!0));return}let l=D(r),s=l===-1?null:r.slice(l+1),a=l===-1?r:r.slice(0,l),d=!a||a==="."?t:jt(e,t,a)[0];d&&i.push(Ni(n,d,r,s));return}if(Array.isArray(r)){let[l,s]=r;if(typeof l!="string"||!l)return;let a=jt(e,t,l);a.forEach((d,m)=>Tr(e,d,s,[...n,m],i,o)),o.push(Li(e,t,n,l,a,typeof s=="string"));return}if(r&&typeof r=="object")for(let[l,s]of Object.entries(r))Tr(e,t,s,[...n,l],i,o)}function Li(e,t,r,n,i,o){let l=i[0]?i[0].parentElement:null;if(!l){let s=jt(e,t,n,Pl)[0];l=s?s.parentElement:null}return{path:r,items:i,container:l,scalar:o}}function Ni(e,t,r,n){return{path:e,el:t,rule:r,attr:n,kind:Hl(t,n),icon:Wl(t,n)}}function Hl(e,t){let r=(e.tagName||"").toUpperCase();return!t||t==="innerHTML"?Mi.has(r)?Oi:$l:t==="value"&&Ul.has(r)&&!e.readOnly&&!Vl(e)?zl:Oi}function Vl(e){return e.disabled?!0:typeof e.matches=="function"&&e.matches(":disabled")}function Wl(e,t){let r=(e.tagName||"").toUpperCase();return(!t||t==="innerHTML")&&!Mi.has(r)?null:r==="IMG"||t==="srcset"?"camera":r==="A"&&t==="href"?"paperclip":"pencil"}function jt(e,t,r,n=Dl){try{return e.find(t,r,n)}catch{return[]}}var ji=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Kl=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Wm=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function Rr(e,t){if(!e||e.nodeType!==1)return!1;let r=e.getAttribute?.("clay");return!!(r&&r.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Gl(e,t){if(Rr(e,t))return!0;for(let[r,n]of Object.entries(Kl))if(n.includes(t)&&Rr(e,r))return!0;return!1}function Qe(e){let t=ji[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(r=>[`[clay~="${r}"]`,`[${r}]`]).join(", ")}function Yl(e,t){let r=e&&e.nodeType===1?e:e?.parentElement;for(;r&&r.nodeType===1;){let n=ji[t];if(!n)throw new Error(`Unknown region capability: ${t}`);if(n.tokens.some(i=>Gl(r,i))||n.bundles.some(i=>Rr(r,i)))return r;r=r.parentElement}return null}function Fi(e,t){return!!Yl(e,t)}var Xl=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Ii(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let r=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&r!=="checkbox"&&r!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let n=0;n<e.options.length;n++)t.options[n].selected=e.options[n].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function qi(e,t,r,n){if(n)return!!e.closest?.(t);let i=e;for(;i?.nodeType===1;){if(i.matches(t))return!0;if(i===r)break;i=i.parentElement}return!1}function Di(e,t,r,n,i,o,l,s){if(e.nodeType===1&&((l?Fi(e,r):qi(e,n,o,!1))||i&&qi(e,i,o,l)))return null;let a=t.importNode(e,!1);s.cloneToLive.set(a,e),s.liveToClone.set(e,a);let d=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,m=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;d!==e&&(s.cloneToLive.set(m,d),s.liveToClone.set(d,m));for(let f of d.childNodes||[]){let c=Di(f,t,r,n,i,o,l,s);c&&(m.appendChild(c),f.nodeType===1&&Ii(f,c))}return e.nodeType===1&&Ii(e,a),a}function Or(e,{capability:t="data",exclude:r=null,inherit:n=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let o=i.implementation.createHTMLDocument(""),l=new WeakMap,s=new WeakMap,a=e.nodeType===9?e.documentElement:e;r&&o.documentElement.matches(r);let d=Qe(t),m=Di(a,o,t,d,r,a,n,{cloneToLive:l,liveToClone:s});e.nodeType===9&&m&&(o.replaceChild(m,o.documentElement),s.set(e,o),l.set(o,e));let f=c=>{if(Xl.test(c))throw new Error(`Filtered content queries do not support stateful selector: ${c}`)};return{root:m,document:o,capability:t,selector:Qe(t),cloneToLive:l,liveToClone:s,original(c){return l.get(c)||null},cloneOf(c){return s.get(c)||null},query(c,h=m){return f(c),Array.from(h.querySelectorAll(c),u=>l.get(u)||u)},text(c=m){return(c===m?m:s.get(c))?.textContent||""},html(c=m){return(c===m?m:s.get(c))?.innerHTML??""},clone(c=m){let h=c===m?m:s.get(c);return h?o.importNode(h,!0):null}}}import{morph as oa}from"./hyper-morph.vendor.js";var Jl=[16,8,0],U=8,Zl=4;function Pi({anchor:e,bar:t,rail:r=t,viewport:n,current:i=null}){let o=c=>i===c?Zl:0;if(e.bottom<=0||e.top>=n.height||e.right<=0||e.left>=n.width)return{mode:"hidden",x:0,y:0};let l=c=>Math.max(U,Math.min(e.left,n.width-c-U)),s=e.top-16-t.height;if(s>=U-o("above"))return{mode:"above",x:l(t.width),y:s};let a=e.bottom+16;if(a+t.height<=n.height-U+o("below"))return{mode:"below",x:l(t.width),y:a};let d=n.width-e.right-U,m=e.left-U,f=d>=m?[["rail-right",d],["rail-left",m]]:[["rail-left",m],["rail-right",d]];for(let[c,h]of f)for(let u of Jl){if(r.width+u>h+o(c))continue;let p=c==="rail-right"?Math.min(e.right+u,n.width-r.width-U):Math.max(e.left-u-r.width,U),g=Math.min(e.bottom,n.height-U)-r.height,b=Math.max(U,Math.min(Math.max(e.top,U),g));return{mode:c,x:p,y:b,gap:u}}return{mode:"pinned",x:l(t.width),y:U}}function Lr({anchor:e,handle:t,viewport:r,inset:n=6,prefer:i="auto"}){let o=e.height>=t.height*1.5&&e.width>=t.width*2;if(i==="corner"||o){let c=Math.max(U,Math.min(e.right-t.width+n,r.width-t.width-U)),h=Math.max(U,Math.min(e.top-n,r.height-t.height-U));return{x:c,y:h,mode:"over"}}let l=4,s=e.right+l+t.width<=r.width-U,a=s?e.right+l:e.left-l-t.width,d=Math.max(U,a),m=e.top+e.height/2-t.height/2,f=Math.max(U,Math.min(m,r.height-t.height-U));return{x:d,y:f,mode:s?"beside-right":"beside-left"}}var It=!1;function $i(){if(It)return;let e=z("onPrepareForSave");typeof e=="function"&&(e(t=>{Ui(t),zi(t)}),It=!0)}function zi(e){let t=e&&e.querySelector&&e.querySelector("body");t&&t.classList.remove("hcms-open","hcms-overlay","hcms-side-left",Ot)}function Ui(e){if(!(!e||typeof e.querySelectorAll!="function"))for(let t of e.querySelectorAll(`[${ie}]`)){let r=ai(t);r!==null&&(t.innerHTML=r),t.removeAttribute(ie)}}var qt=!1;function Dt(){if(qt)return;let e=z("onSnapshot");typeof e=="function"&&(e(t=>{Ui(t),di(t,typeof window<"u"?window:null),zi(t)}),qt=!0)}function Bi(){$i(),Dt(),(!It||!qt)&&Ql()}var Ft=null;function Ql(){if(Ft||typeof document>"u")return;Ft=Ce(document,oi,()=>{$i(),Dt(),It&&qt&&(Ft?.(),Ft=null)})}var ea={edit:"M8 10h2v6H8zm2 4h4v2h-4zm0-6h2v2h-2zm2-2h2v2h-2zm2-2h2v2h-2zm2-2h2v2h-2zm2 2h2v2h-2zm2 2h2v2h-2zm-2 2h2v2h-2zm-2 2h2v2h-2zm-2 2h2v2h-2zm-4 0h2v2h-2z","move-up":"M11 4h2v2h2v2h2v2h2v2h-4v-2h-2v10h-2V10H9v2H5v-2h2V8h2V6h2z","move-down":"M11 4h2v10h2v-2h4v2h-2v2h-2v2h-2v2h-2v-2H9v-2H7v-2H5v-2h4v2h2z",remove:"M5 5h3v3h3v3h2V8h3V5h3v3h-3v3h-3v2h3v3h3v3h-3v-3h-3v-3h-2v3H8v3H5v-3h3v-3h3v-2H8V8H5z",add:"M10 4h4v6h6v4h-6v6h-4v-6H4v-4h6z"};function fe(e){let t=e==="edit"?"6 0 18 18":"0 0 24 24",r=e==="settings"?'<circle cx="6" cy="12" r="1.5"/><circle cx="12" cy="12" r="1.5"/><circle cx="18" cy="12" r="1.5"/>':`<path d="${ea[e]}"/>`;return`<svg class="hcms-inline-icon" xmlns="http://www.w3.org/2000/svg" viewBox="${t}" width="24" height="24" fill="currentColor" aria-hidden="true" focusable="false">${r}</svg>`}var Hi="data-hcms-ghost",ta=Qe("history");function ra(e){let t=e.container,r=null;for(;t&&(t.namespaceURI!=="http://www.w3.org/1999/xhtml"||["SELECT","OPTGROUP","DATALIST"].includes(t.tagName));)r=t,t=t.parentElement;return{parent:t,anchor:r}}function Vi({doc:e,themeRoot:t,onAdd:r,onResize:n}){let i=e.defaultView,o=[],l=!1,s=null,a=new Map;function d(h,u,p){h.style[u]!==p&&(h.style[u]=p)}function m(){let h=new Set(o.map(u=>u.node.parentElement));for(let[u,p]of a)h.has(u)&&i?.Sortable?.get(u)===p.instance||(p.instance.option("draggable")===p.selector&&p.instance.option("draggable",p.original),a.delete(u));for(let u of h){let p=i?.Sortable?.get(u);if(!p)continue;let g=p.option("draggable");if(a.get(u)?.selector===g)continue;let b=g,w=`${b.trim().startsWith(">")?"> ":""}:is(${b.trim().replace(/^>\s*/,"")}):not(${ta})`;p.option("draggable",w),a.set(u,{instance:p,original:b,selector:w})}}function f(){for(let h of o){let{node:u,slot:p,list:g}=h,b=g.items.filter(y=>y.isConnected).map(y=>y.getBoundingClientRect()).filter(y=>y.width>0&&y.height>0);b.length&&(h.width=b.reduce((y,w)=>y+w.width,0)/b.length,h.height=b.reduce((y,w)=>y+w.height,0)/b.length),d(u,"width",h.width?`${Math.round(h.width)}px`:"100%"),d(p,"height",`${Math.max(48,Math.round(h.height||64))}px`),p!==u&&(p.colSpan=Math.max(1,...g.items.map(y=>[...y.children].reduce((w,E)=>w+(E.colSpan||1),0)))),u.hidden!==l&&(u.hidden=l)}m()}function c(h,u){let p=u.tagName,g=["TBODY","THEAD","TFOOT","TABLE"].includes(p),b=e.createElement(g?"tr":["UL","OL","MENU"].includes(p)?"li":"div");for(let x of[Hi,"data-hcms-shell","editor-ui","no-watch","no-save","save-remove","snapshot-remove"])b.setAttribute(x,"");b.setAttribute("draggable","false"),b.setAttribute("contenteditable","false"),b.className="hcms-shell pixel-quiet hcms-inline-ghost";for(let x of["light","dark"])b.classList.toggle(x,!!t?.classList.contains(x));let y=g?e.createElement("td"):b;y!==b&&(y.className="hcms-inline-ghost-cell",b.appendChild(y));let w=e.createElement("button");w.type="button",w.className="hcms-inline-list-button hcms-inline-list-add mirk-button mirk-button--small",w.setAttribute("data-hcms-list-action","add"),w.innerHTML=`<span class="mirk-button__label">${fe("add")}<span>Add</span></span>`,y.appendChild(w);let E={node:b,slot:y,button:w,list:h,width:0,height:0};w.addEventListener("click",x=>{x.preventDefault(),x.stopPropagation(),r(E.list)});for(let x of["pointerdown","mousedown","touchstart","click"])b.addEventListener(x,T=>T.stopPropagation());return b.addEventListener("dragstart",x=>{x.preventDefault(),x.stopPropagation()}),E}return{setLists(h){let u=new Set(o),p=[],g=new Set(o.map(y=>y.node)),b=new Set;for(let y of h||[]){if(!y.container||!y.container.isConnected)continue;let{parent:w,anchor:E}=ra(y);if(!w)continue;if(!b.has(w)){for(let C of w.querySelectorAll(`:scope > [${Hi}]`))g.has(C)||C.remove();b.add(w)}let x=o.find(C=>u.has(C)&&C.list.container===y.container&&C.list.path.join(".")===y.path.join("."))||c(y,w);u.delete(x),x.list=y,x.button.setAttribute("data-hcms-list",y.path.join(".")),x.button.setAttribute("aria-label",`Add to ${y.path.join(".")||"the list"}`);let T=E||y.items.filter(C=>C.parentElement===w).at(-1);T?T.nextSibling!==x.node&&T.after(x.node):x.node.parentElement!==w&&w.appendChild(x.node),p.push(x)}for(let y of u)y.node.remove();o=p,s?.disconnect(),!s&&typeof i?.ResizeObserver=="function"&&(s=new i.ResizeObserver(()=>{f(),n?.()}));for(let y of o)for(let w of y.list.items)s?.observe(w);f()},update:f,setHidden(h){l=!!h,f()},destroy(){s?.disconnect();for(let h of o)h.node.remove();o=[],m()}}}var Wi=[["move-up","Move up"],["move-down","Move down"]],na={prefer:"corner",inset:0};function ia(e,t){return t.width<=e.width&&t.height<=e.height}function Ki({doc:e,layerEl:t,onActivate:r,onListAction:n}){let i=e.defaultView,o=[],l=new Map,s=0,a=new Map,d=null,m=new Set,f=0,c=!1,h=null,u=null,p=null,g=null,b=new Map,y=!1,w=null,E=Vi({doc:e,themeRoot:t.closest("[data-hcms-shell]"),onResize:T,onAdd:k=>n?.({action:"add",list:k,index:k.items.length})}),x=e.createElement("div");x.className="hcms-inline-highlight",x.hidden=!0,x.setAttribute("aria-hidden","true"),t.appendChild(x);function T(){if(!(f||!i)){if(typeof i.requestAnimationFrame!="function")return H();f=i.requestAnimationFrame(()=>{f=0,H()})}}let C=()=>p||g;function H(){if(!i)return;E.update();let k={width:i.innerWidth,height:i.innerHeight},v=C();for(let _ of o){if(!_.visible){_.node.hidden=!0;continue}for(let M of _.members)M.node.hidden=y&&M.kind!=="handle";_.node.hidden=!1;let R=_.el.getBoundingClientRect(),S=_.node.getBoundingClientRect(),O=S.width,I=_.kind==="row"&&!ia(R,S);if(I&&_.el!==v){for(let M of _.members)M.kind==="row"&&(M.node.hidden=!0);S=_.node.getBoundingClientRect()}if(_.members.every(M=>M.node.hidden)){_.node.hidden=!0;continue}let q=_.kind==="handle"?null:na,{x:X,y:N}=Lr({anchor:R,handle:S,viewport:k,...q}),B=_.members.find(M=>M.kind==="handle");if(I&&B){let M=B.node.getBoundingClientRect(),Jr=Lr({anchor:R,handle:M,viewport:k}),Io=_.members.slice(_.members.indexOf(B)+1).filter(Kt=>!Kt.node.hidden).reduce((Kt,qo)=>Kt+qo.node.getBoundingClientRect().width+2,0);X=Math.max(8+O,Math.min(k.width-8,Jr.x+M.width+Io))-S.width,N=Jr.y}_.node.style.transform=`translate(${Math.round(X)}px, ${Math.round(N)}px)`}if(w)if(!w.node.isConnected||w.node.closest("[hidden]"))Y();else{let _=w.button.getBoundingClientRect(),R=w.menu.getBoundingClientRect();w.menu.style.left=`${Math.max(8,_.right-R.width)-_.left}px`,w.menu.style.right="auto",w.menu.style.top=_.bottom+6+R.height>k.height-8?"auto":"calc(100% + 6px)",w.menu.style.bottom=_.bottom+6+R.height>k.height-8?"calc(100% + 6px)":"auto"}j(),h?.()}function P(k){if(k?.closest?.("[data-hcms-ghost]"))return null;for(let v=k;v&&v.nodeType===1;v=v.parentElement){let _=b.get(v);if(_)return _}return null}function K(k){w&&!w.node.contains(k.target)&&Y();let v=C();g=P(k.target),g&&t.contains(k.target)&&(p=null),C()!==v&&T()}function A(k){if(k.relatedTarget||!g)return;let v=C();g=null,C()!==v&&T()}function j(){if(!u||x.hidden)return;let k=u.getBoundingClientRect();x.style.width=`${Math.round(k.width)}px`,x.style.height=`${Math.round(k.height)}px`,x.style.transform=`translate(${Math.round(k.left)}px, ${Math.round(k.top)}px)`}function ge(){if(!i||typeof i.IntersectionObserver!="function"){for(let v of o)v.visible=!0;return}d||(d=new i.IntersectionObserver(v=>{let _=!1;for(let R of v)for(let S of l.get(R.target)||[])S.visible!==R.isIntersecting&&(S.visible=R.isIntersecting,_=!0);_&&T()},{threshold:0}));let k=new Set(l.keys());for(let v of m)k.has(v)||d.unobserve(v);for(let v of k)m.has(v)||d.observe(v);m=k}function Eo(){c||!i||(i.addEventListener("scroll",T,{passive:!0,capture:!0}),i.addEventListener("resize",T,{passive:!0}),e.addEventListener("focusin",K),e.addEventListener("focusout",A),e.addEventListener("pointerdown",Gr,!0),e.addEventListener("keydown",Yr,!0),c=!0)}function So(){!c||!i||(i.removeEventListener("scroll",T,{capture:!0}),i.removeEventListener("resize",T),e.removeEventListener("focusin",K),e.removeEventListener("focusout",A),e.removeEventListener("pointerdown",Gr,!0),e.removeEventListener("keydown",Yr,!0),c=!1)}function Br(k){return`${k.kind}\0${k.attr||""}`}function Hr(k,v){return k.container===v.container&&k.scalar===v.scalar}function To(k,v){return k.kind!==v.kind?!1:k.kind==="handle"?Br(k.target)===Br(v.target):k.kind==="row"?k.row===v.row&&Hr(k.list,v.list):Hr(k.list,v.list)}function Vr(k,v){k.target=v;let _=v.path.join(".");k.node.setAttribute("data-hcms-target",_),v.icon?k.node.setAttribute("data-hcms-icon",v.icon):k.node.removeAttribute("data-hcms-icon"),k.node.setAttribute("aria-label",`Edit ${_}`)}function Co(k){let v=e.createElement("button");v.type="button",v.className="hcms-inline-handle mirk-button mirk-button--small",v.innerHTML=`<span class="mirk-button__label">${fe("edit")}</span>`;let _={node:v,kind:"handle",target:k};return Vr(_,k),v.addEventListener("click",R=>{R.preventDefault(),R.stopPropagation(),r?.(_.target,v)}),_}function Wr(k,v){let _=e.createElement("button");return _.type="button",_.className="hcms-inline-list-button mirk-button mirk-button--small",_.setAttribute("data-hcms-list-action",k),_.setAttribute("aria-label",v),_.innerHTML=`<span class="mirk-button__label">${fe(k)}${k==="add"?"<span>Add</span>":""}</span>`,_}function Kr(k,{list:v,row:_,rowIndex:R,count:S}){let O=v.path.join(".");k.list=v,k.row=_,k.index=R,k.count=S,k.node.setAttribute("data-hcms-list",O),k.node.setAttribute("data-hcms-row",String(R));for(let I of k.node.querySelectorAll("[data-hcms-list-action]")){let q=I.getAttribute("data-hcms-list-action"),X=Wi.find(([N])=>N===q)?.[1]||q;I.setAttribute("aria-label",`${X} ${O}.${R}`),I.disabled=q==="move-up"&&R===0||q==="move-down"&&R===S-1}}function Ro(k,v,_,R){let S=e.createElement("div");S.className="hcms-inline-row-controls";let O={node:S,kind:"row",list:k,row:v,index:_,count:R};for(let[I,q]of Wi){let X=Wr(I,q);X.addEventListener("click",N=>{N.preventDefault(),N.stopPropagation(),!X.disabled&&n?.({action:I,list:O.list,index:O.index,row:O.row})}),S.appendChild(X)}return Kr(O,{list:k,row:v,rowIndex:_,count:R}),O}function Y(k=!1){if(!w)return;let v=w;w=null,v.menu.hidden=!0,v.button.setAttribute("aria-expanded","false"),v.node.parentElement?.classList.remove("has-open-settings"),k&&v.button.isConnected&&v.button.focus({preventScroll:!0})}function Gr(k){w&&!w.node.contains(k.target)&&Y()}function Yr(k){w&&(k.key==="Escape"?(k.preventDefault(),k.stopPropagation(),Y(!0)):k.key==="Tab"?Y(!0):["ArrowDown","ArrowUp","Home","End"].includes(k.key)&&w.menu.contains(k.target)&&(k.preventDefault(),w.menu.querySelector('[role="menuitem"]').focus({preventScroll:!0})))}function Xr(k,{list:v,row:_,rowIndex:R}){Object.assign(k,{list:v,row:_,index:R}),k.node.setAttribute("data-hcms-list",v.path.join(".")),k.node.setAttribute("data-hcms-row",String(R)),k.button.setAttribute("aria-label",`Settings ${v.path.join(".")}.${R}`)}function Oo(k){let v=e.createElement("div");v.className="hcms-inline-settings";let _=Wr("settings","Settings");_.setAttribute("aria-haspopup","menu"),_.setAttribute("aria-expanded","false");let R=e.createElement("div");R.className="hcms-inline-settings-menu",R.setAttribute("role","menu"),R.setAttribute("aria-label","Item settings"),R.hidden=!0;let S=e.createElement("button");S.type="button",S.setAttribute("role","menuitem"),S.setAttribute("data-hcms-list-action","remove"),S.textContent="Delete",R.appendChild(S),v.append(_,R);let O={node:v,button:_,menu:R,kind:"settings"};Xr(O,k);let I=()=>{Y(),w=O,R.hidden=!1,_.setAttribute("aria-expanded","true"),v.parentElement.classList.add("has-open-settings"),S.focus({preventScroll:!0}),T()};return _.addEventListener("click",q=>{q.preventDefault(),q.stopPropagation(),w===O?Y(!0):I()}),_.addEventListener("keydown",q=>{(q.key==="ArrowDown"||q.key==="ArrowUp")&&(q.preventDefault(),I())}),S.addEventListener("click",q=>{q.preventDefault(),q.stopPropagation(),Y(!0),n?.({action:"remove",list:O.list,index:O.index,row:O.row})}),O}function Lo(k,v){k.kind==="handle"?Vr(k,v.target):k.kind==="row"?Kr(k,v):k.kind==="settings"&&Xr(k,v)}function Wt(k,v,_,R,S){let O=v.get(_)?.find(I=>I.category===S);if(!O){O={el:_,category:S,members:[]},k.push(O);let I=v.get(_);I?I.push(O):v.set(_,[O])}O.members.push(R)}function No(k,v,_){let R=_.items||[];R.forEach((S,O)=>{Ze(S)&&(Wt(k,v,S,{kind:"row",list:_,row:S,rowIndex:O,count:R.length},"item"),Wt(k,v,S,{kind:"settings",list:_,row:S,rowIndex:O},"item"))})}function Mo(k,v){let _=new Set(k.members),R=[];for(let S of v){let O=k.members.find(I=>_.has(I)&&To(I,S))||(S.kind==="handle"?Co(S.target):S.kind==="row"?Ro(S.list,S.row,S.rowIndex,S.count):Oo(S));_.delete(O),Lo(O,S),y&&O.kind!=="handle"&&(O.node.hidden=!0),R.push(O)}for(let S of _)S===w&&Y(),S.node.remove();R.sort((S,O)=>["row","handle","settings"].indexOf(S.kind)-["row","handle","settings"].indexOf(O.kind)),R.forEach((S,O)=>{k.node.children[O]!==S.node&&k.node.insertBefore(S.node,k.node.children[O]||null)}),k.members=R}function jo(k,v){let _=[],R=new Map,S=new Map,O=0;for(let N of k||[])S.has(N.el)||S.set(N.el,N),!(N.kind!=="handle"||!Ze(N.el))&&(Wt(_,R,N.el,{kind:"handle",target:N},"item"),O++);for(let N of v||[])No(_,R,N);let I=new Set(o),q=new Map;for(let N of o)q.has(N.el)||q.set(N.el,N.visible);let X=[];for(let N of _){let B=o.find(M=>I.has(M)&&M.el===N.el&&M.category===N.category);if(!B){let M=e.createElement("div");M.className="hcms-inline-item-controls",M.setAttribute("role","group"),B={el:N.el,node:M,category:N.category,kind:N.category==="add"?"add":"handle",members:[],visible:q.get(N.el)??!1},t.appendChild(M)}I.delete(B),B.el=N.el,B.category=N.category,Mo(B,N.members),B.kind=B.members.some(M=>M.kind==="row")?"row":B.members.some(M=>M.kind==="handle")?"handle":"add",B.node.setAttribute("aria-label",B.category==="add"?"List controls":"Item controls"),X.push(B)}for(let N of I)N.node.remove();o=X,l=new Map,b=new Map;for(let N of o){let B=l.get(N.el);B?B.push(N):l.set(N.el,[N]);for(let M of N.members)M.kind!=="row"&&M.kind!=="settings"||(b.set(M.row,M.row),b.set(M.node,M.row),b.set(N.node,M.row))}p&&!b.has(p)&&(p=null),g&&!b.has(g)&&(g=null),a=S,s=O}function Fo(){Y(),d?.disconnect(),d=null,m=new Set;for(let k of o)k.node.remove();o=[],l=new Map,a=new Map,b=new Map,s=0}return{setTargets(k,v){jo(k,v),E.setLists(v),ge(),Eo(),T()},refresh:T,get count(){return s},get controlsHidden(){return y},setControlsHidden(k){if(y=!!k,E.setHidden(y),y){Y();for(let v of o){for(let _ of v.members)_.kind!=="handle"&&(_.node.hidden=!0);v.members.every(_=>_.node.hidden)&&(v.node.hidden=!0)}}T()},elementToTarget(k){if(k?.closest?.("[data-hcms-ghost]"))return null;for(let v=k;v&&v.nodeType===1;v=v.parentElement){let _=a.get(v);if(_)return _}return null},setHoveredRow(k){let v=C();p=k?P(k):null,C()!==v&&T()},showHighlight(k){k&&(u=k,x.hidden=!1,j())},hideHighlight(){u=null,x.hidden=!0},setFollower(k){h=typeof k=="function"?k:null},destroy(){E.destroy(),f&&i&&i.cancelAnimationFrame(f),f=0,h=null,u=null,p=null,g=null,x.remove(),So(),Fo()}}}var sa="hypercms-inline",rt="is-hcms-inline-active",Nr="is-hcms-inline-onpath",Gi='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])',la=["bold","italic","link","undo","redo"],aa=/^H[1-6]$/,ca=0;function Ji({doc:e,pageRoot:t,opts:r={}}){let n=r.richText!==!1,i=null,o=null,l=null,s=new Map,a=null,d=null,m=null;function f(c,h,u,p,g){let b=Re(e.defaultView);if(typeof b!="function")return null;let y=g||{},w=y.originalHTML??Or(h,{capability:"history"}).html(),E=y.richClayIsOurs??!h.hasAttribute("data-richclay"),x=y.adopted??h.getAttribute("data-richclay-active")==="true",T=et(h,p,"history"),C=da(c,b,h,p,E);if(!C)return null;ci(h,p==="innerHTML",E);let H=String(++ca);h.setAttribute(ie,H),Dt();let P={el:h,editor:C,path:u,prop:p,boundId:H,originalHTML:w,oldValue:T,richClayIsOurs:E,adopted:x,dirty:!1,written:!1,restorable(){return!this.adopted&&!this.dirty&&!this.written},lastEdited:void 0};s.set(h,P),si(H,P);let K=C.squire;if(K&&typeof K.addEventListener=="function"){let j=()=>{P.dirty=!0,P.lastEdited=et(h,P.prop,"history"),ma(c,P)};K.addEventListener("input",j),P.detachInput=()=>K.removeEventListener?.("input",j)}let A=()=>Zi(P);return h.addEventListener("blur",A),P.detachBlur=()=>h.removeEventListener("blur",A),P}return{name:"inline",richText:n,ctx:null,root:null,formRoot:null,errorEl:null,noticeEl:null,handoffEl:null,handoffCountEl:null,popEl:null,enhanceFormRichText:!1,prepareRules(c){return n?hi(c,t):c},bindText(c,h,u,p){return f(this.ctx,c,h,u,p)},mount(c){let h=this.ctx;i=ga(e,r.theme),this.root=i.root,this.formRoot=i.formRoot,this.errorEl=i.errorEl,this.noticeEl=i.noticeEl,this.handoffEl=i.handoffEl,this.handoffCountEl=i.handoffCountEl,this.popEl=i.popEl,re(()=>Je(e));let u=Ee({pageRules:h.pageRules,formRules:h.formRules,data:c,doc:e});i.formRoot.appendChild(u),h.seeder.seed(i.formRoot),oe(i.formRoot,e,this.enhanceFormRichText),Ie(h),Et(h),o=Ki({doc:e,layerEl:i.layerEl,onActivate:(p,g)=>this.activate(p,g),onListAction:p=>this.listAction(p)}),o.setFollower(()=>this.placePopover()),i.closeEl.addEventListener("click",()=>this.deactivate()),i.toggleEl.addEventListener("click",p=>{p.preventDefault(),p.stopPropagation(),this.toggleControls()}),i.handoffEl.querySelector("[data-hcms-open-view]").addEventListener("click",p=>{p.preventDefault(),p.stopPropagation(),h.onViewRequested?.("sidebar")}),this.bindPage(),this.syncTargets()},listAction({action:c,list:h,index:u,row:p}){let g=this.ctx,b=h.path.join("."),y=g.formRoot.querySelector(`[data-hcms-path="${Me(b)}"]`);if(!y)return;if(c==="add"){Ye(b,g);return}let w=p?ka(g,b,p):u;if(w===-1)return;let E=ba(y,w);if(E){if(c==="remove"){kr(E,g),this.syncTargets();return}br(E,c==="move-up"?-1:1,g),this.syncTargets()}},toggleControls(){if(!o||!i)return;let c=!o.controlsHidden;o.setControlsHidden(c),i.toggleEl.setAttribute("aria-pressed",String(c));let h=i.toggleEl.querySelector(".mirk-button__label");h&&(h.textContent=c?"Show controls":"Hide controls")},bindPage(){let c=this.ctx.pageRoot,h=i.root,u=E=>{let x=o&&o.elementToTarget(E.target);x?o.showHighlight(x.el):o?.hideHighlight(),o?.setHoveredRow(E.target)},p=()=>{o?.hideHighlight(),o?.setHoveredRow(null)},g=E=>{if(h.contains(E.target))return;let x=o&&o.elementToTarget(E.target);!x||x.kind!=="text"||s.has(x.el)||f(this.ctx,x.el,x.path.join("."),$t(x))},b=E=>{if(h.contains(E.target))return;let x=o&&o.elementToTarget(E.target);if(!x){this.deactivate();return}(typeof E.target.closest=="function"&&E.target.closest("a[href]")||x.kind!=="text")&&E.preventDefault(),this.activate(x)},y=E=>{E.key==="Escape"&&this.deactivate()},w=E=>{let x=E.detail;if(!(!x||x.pageRoot!==this.ctx.pageRoot||!x.path))for(let T of s.values())T.path===x.path&&(T.written=!0)};c.addEventListener("pointerover",u),c.addEventListener("pointerleave",p),c.addEventListener("pointerdown",g),c.addEventListener("click",b),h.addEventListener("keydown",y),e.addEventListener("hcms:change",w),l=()=>{c.removeEventListener("pointerover",u),c.removeEventListener("pointerleave",p),c.removeEventListener("pointerdown",g),c.removeEventListener("click",b),h.removeEventListener("keydown",y),e.removeEventListener("hcms:change",w)}},activate(c,h){if(!c||!i||c.kind==="text"&&this.activateText(c))return;let u=Yi(this,i,c.path.join("."));if(!u){this.deactivate();return}a=c,d=h||null,m=null,i.popEl.hidden=!1,i.formRoot.querySelectorAll(`.${rt}`).forEach(Xi),this.placePopover(),fa(u)},activateText(c){let h=c.el,u=s.get(h);if(u)return Pt(u),!0;let p=f(this.ctx,h,c.path.join("."),$t(c));return p?(Pt(p),!0):!1},placePopover(){if(!i||!a||i.popEl.hidden)return;let c=e.defaultView;if(!c)return;let h={width:c.innerWidth,height:c.innerHeight},u=a.el.getBoundingClientRect(),p=i.popEl.getBoundingClientRect(),{mode:g,x:b,y}=Pi({anchor:u,bar:p,viewport:h,current:m});m=g,i.popEl.style.transform=`translate(${Math.round(b)}px, ${Math.round(y)}px)`},deactivate(){if(!i||!a&&i.popEl.hidden)return;i.popEl.hidden=!0,eo(i.root);let c=d;if(a=null,d=null,m=null,c&&e.contains(c)&&typeof c.focus=="function")try{c.focus({preventScroll:!0})}catch{c.focus()}},syncTargets(){if(!o)return;let c=this.ctx,{targets:h,lists:u}=Cr(c.pageRoot,c.pageRules);o.setTargets(h,u);let p=ua(this,s,h,e);if(a){let b=p.get(a.el)||[],y=b.find(w=>ha(w,a))||b.find(w=>w.path.join(".")===a.path.join("."))||(b.length===1?b[0]:null);y?a=y:this.deactivate()}pa(this.ctx,s,e);let g=h.reduce((b,y)=>b+(Ze(y.el)?0:1),0);this.handoffEl&&(this.handoffCountEl.textContent=g===0?"":`${g} ${g===1?"field isn't":"fields aren't"} visible right now.`,this.handoffEl.hidden=g===0)},refresh(c,h){c==="livesync"?(ae(e),Je(e),ce(this.ctx,{ignoreActiveValue:!0})):c==="undo"?ce(this.ctx,{ignoreActiveValue:!1}):ce(this.ctx),this.syncTargets(),(c==="livesync"||c==="undo")&&this.rebindText(c),this.restoreActive()},rebindText(c){let h=c!=="undo";for(let[u,p]of[...s]){if(!e.contains(u)){tt(this.ctx,p,{restore:!1,record:h}),s.delete(u);continue}if(u.hasAttribute(Z)){let y=et(u,p.prop);y!==p.lastEdited&&(p.oldValue=y,p.lastEdited=void 0);continue}let g=e.activeElement===u;tt(this.ctx,p,{restore:!1,record:h}),s.delete(u);let b=f(this.ctx,u,p.path,p.prop,{richClayIsOurs:p.richClayIsOurs,adopted:p.adopted});b&&g&&Pt(b)}},restoreActive(){if(!i||!a||i.popEl.hidden)return;if(!e.contains(a.el)){this.deactivate();return}if(!Yi(this,i,a.path.join("."))){this.deactivate();return}i.formRoot.querySelectorAll(`.${rt}`).forEach(Xi),this.placePopover()},focusOnOpen(){if(this.root&&typeof this.root.focus=="function")try{this.root.focus({preventScroll:!0})}catch{this.root.focus()}},destroy(){d=null,this.deactivate();for(let c of s.values())tt(this.ctx,c);s.clear(),l?.(),l=null,o?.destroy(),o=null,i?.destroy(),i=null,_r(e),this.popEl=null,this.handoffEl=null,this.handoffCountEl=null}}}function da(e,t,r,n,i){return re(()=>{let o=null;try{o=new t(r,{inline:!0,hyperclay:!1,toolbar:n==="innerHTML"?la:!1,...aa.test(r.tagName)?{singleLine:!0}:null})}catch(l){return console.warn("[hypercms] richclay activation failed; the field falls back to the popover",l),null}if(o.unsupported||!o.active){if(i)try{o.destroy()}catch{}return null}return typeof o.reattach=="function"&&o.reattach(),o})}function ma(e,{path:t,el:r,prop:n}){let i=St(e.formRoot,t);i&&(Tt(i,et(r,n),e.formRoot,t),G(W(e),{path:t,structural:!1},e))}function et(e,t,r="data"){let n=Or(e,{capability:r});return t==="innerHTML"?n.html():n.text().trim()}function Zi(e){let{el:t,prop:r,oldValue:n,lastEdited:i}=e,o=i;if(o===void 0||o===n)return;e.oldValue=o;let l=z("undo");if(!l||typeof l.recordValue!="function")return;let s={prop:r,oldValue:n,newValue:o,read:a=>et(a,r,"history"),write:(a,d)=>Qi(a,r,d)};l.isPaused?queueMicrotask(()=>{t.isConnected&&l.recordValue(t,s)}):l.recordValue(t,s)}function Qi(e,t,r){let n=e.cloneNode(!1);t==="innerHTML"?n.innerHTML=r:n.textContent=r,oa(e,Array.from(n.childNodes),{morphStyle:"innerHTML",policy:"history",restoreFocus:!1,scripts:{handle:!1,merge:!1}})}function tt(e,t,{restore:r=!0,record:n=!0}={}){n&&Zi(t),t.detachInput?.(),t.detachBlur?.(),re(()=>{if(!t.adopted){try{t.editor.destroy()}catch(i){console.warn("[hypercms] richclay teardown failed; editor state may reach the save",i)}t.richClayIsOurs&&t.el.removeAttribute("data-richclay")}t.el.removeAttribute(Z),t.el.removeAttribute(he),t.el.removeAttribute(ie),li(t.boundId),r&&t.restorable()&&Qi(t.el,"innerHTML",t.originalHTML)})}function Pt(e){let{editor:t,el:r}=e;if(r.ownerDocument.activeElement!==r)try{typeof t.focus=="function"?t.focus():r.focus()}catch{}}function ua(e,t,r,n){let i=new Map;for(let o of r){let l=i.get(o.el);l?l.push(o):i.set(o.el,[o])}for(let[o,l]of[...t]){let s=i.get(o)||[],a=s.find(c=>$t(c)===l.prop)||s[0];if(!a){tt(e.ctx,l,{restore:!0}),t.delete(o);continue}l.path=a.path.join(".");let d=$t(a);if(d===l.prop)continue;let m=n.activeElement===o;tt(e.ctx,l,{restore:!1}),t.delete(o);let f=e.bindText(o,l.path,d,{richClayIsOurs:l.richClayIsOurs,adopted:l.adopted,originalHTML:l.originalHTML});f&&m&&Pt(f)}return i}function ha(e,t){return e.el===t.el&&e.kind===t.kind&&e.attr===t.attr}function $t(e){return e.attr==="innerHTML"?"innerHTML":"textContent"}function pa(e,t,r){for(let n of e.pageRoot.querySelectorAll(`[${Z}]`))t.has(n)||re(()=>mi(n,r.defaultView))}function Yi(e,t,r){let n=e.formRoot&&e.formRoot.querySelector(`[data-hcms-path="${Me(r)}"]`);if(eo(t.root),!n)return null;let i=n.closest("[data-hcms-card]"),o=i?[...i.querySelectorAll('[data-hcms-shape="scalar"][data-hcms-path]')].filter(l=>l.closest("[data-hcms-card]")===i&&l.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]')===i.parentElement.closest('[data-hcms-shape="object-array"]')):[n];o.includes(n)||o.push(n);for(let l of o){l.classList.add(rt),l.removeAttribute("draggable");for(let s=l.parentElement;s&&(s.classList.add(Nr),s.removeAttribute("draggable"),s!==e.formRoot);s=s.parentElement);}return n}function eo(e){if(e)for(let t of e.querySelectorAll(`.${rt}, .${Nr}`))t.classList.remove(rt,Nr)}function Xi(e){e.tagName==="TEXTAREA"&&Oe(e),e.querySelectorAll?.("textarea").forEach(Oe)}function fa(e){let t=e.matches?.(Gi)?e:e.querySelector?.(Gi);if(!(!t||typeof t.focus!="function"))try{t.focus({preventScroll:!0})}catch{t.focus()}}function ga(e,t){ae(e);let r=e.createElement(sa),n=t==="dark"?" dark":t==="light"?" light":"";return r.className="hcms-shell pixel-quiet hcms-inline"+n,r.setAttribute("data-hcms-shell",""),r.setAttribute("editor-ui",""),r.setAttribute("no-save",""),r.setAttribute("save-remove",""),r.setAttribute("snapshot-remove",""),r.setAttribute("no-watch",""),r.setAttribute("tabindex","-1"),r.innerHTML=`
179
+ <div class="hcms-inline-bar">
180
+ <div class="hcms-inline-handoff" hidden>
181
+ <span class="hcms-inline-handoff-count"></span>
182
+ <button type="button" class="hcms-inline-handoff-open mirk-button mirk-button--small" data-hcms-open-view="sidebar">
183
+ <span class="mirk-button__label">Edit in the sidebar</span>
184
+ </button>
185
+ </div>
186
+ <button type="button" class="hcms-inline-toggle mirk-button mirk-button--small" data-hcms-controls-toggle aria-pressed="false" hidden>
187
+ <span class="mirk-button__label">Hide controls</span>
188
+ </button>
189
+ <div class="hcms-inline-notice" role="status" hidden></div>
190
+ <div class="hcms-inline-error" role="alert" hidden></div>
191
+ </div>
192
+ <div class="hcms-inline-layer"></div>
193
+ <div class="hcms-inline-pop" role="dialog" aria-label="Edit content" hidden>
194
+ <div class="hcms-inline-pop-header">
195
+ <span>Edit content</span>
196
+ <button type="button" class="hcms-inline-pop-close mirk-button mirk-button--small" aria-label="Close field editor">
197
+ <span class="mirk-button__label">${fe("remove")}</span>
198
+ </button>
199
+ </div>
200
+ <div data-hcms-form-root class="hcms-form"></div>
201
+ </div>
202
+ `,e.body.appendChild(r),{root:r,formRoot:r.querySelector("[data-hcms-form-root]"),noticeEl:r.querySelector(".hcms-inline-notice"),errorEl:r.querySelector(".hcms-inline-error"),handoffEl:r.querySelector(".hcms-inline-handoff"),handoffCountEl:r.querySelector(".hcms-inline-handoff-count"),layerEl:r.querySelector(".hcms-inline-layer"),popEl:r.querySelector(".hcms-inline-pop"),closeEl:r.querySelector(".hcms-inline-pop-close"),toggleEl:r.querySelector("[data-hcms-controls-toggle]"),destroy(){r.remove()}}}function ba(e,t){let r=e.querySelector(".hcms-array-items");return r&&r.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")[t]||null}function ka(e,t,r){let{lists:n}=Cr(e.pageRoot,e.pageRules),i=n.find(o=>o.path.join(".")===t);return i?i.items.indexOf(r):-1}var ya="[hypercms]";function to(e,t){if(!e||!e.querySelectorAll||!t)return;let r=va(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(i=>{let o=i.getAttribute("data-hcms-tpl");o&&(o.startsWith("@")||r.has(o)||console.warn(`${ya} template "${o}" doesn't match any rule path; ignored`))})}function va(e){let t=new Set;return r([],e),t;function r(n,i){let o=n.join("."),l=n.map(a=>typeof a=="number"?"*":a).join(".");o&&t.add(o),l&&t.add(l);let s=ue(i);if(s==="object")for(let[a,d]of Object.entries(i))r([...n,a],d);else if(s==="object-array"||s==="scalar-array"){let a=[...n,"*"],d=a.map(m=>typeof m=="number"?"*":m).join(".");if(t.add(d),s==="object-array"){let m=i[1];if(m&&typeof m=="object"&&!Array.isArray(m))for(let[f,c]of Object.entries(m))r([...a,f],c)}}}}var no={skip:"[data-hcms-shell]",templateAttr:"cms-template"},L={isOpen:!1,ctx:null,opts:null};function io({view:e,doc:t,pageRoot:r,opts:n={},onCloseRequested:i,onViewRequested:o}){let l=n.rules!==void 0?n.rules:"cms",s=V.findRules(t,l);if(!s){let g=typeof l=="string"?`data-rules-name~="${l}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${g}`)}let a=e.prepareRules(s.rules),d=s.tagNode;ut(t),bt(t,a),to(t,a);let m=yt(a,t),f=Mt(a),c=Nt(r,a),h=ct(),u=le(V.extract(r,a,{...no,...h.hooks}),a),p={doc:t,pageRoot:r,pageRules:a,writeRules:f,formRules:m,rulesTagNode:d,rulesSource:l,richText:e.richText,view:e,seeder:h,initialData:u,get formRoot(){return e.formRoot},get shellRoot(){return e.root},get errorEl(){return e.errorEl},get noticeEl(){return e.noticeEl},unresolved:c,lastTwinSignature:null,lastFingerprint:null,lastData:null,observerHandle:null,undoUnsub:null,livesyncUnsub:null,onChange:n.onChange,onError:n.onError,confirmRemove:n.confirmRemove,previouslyFocused:t.activeElement,dispatch(g,b){let y=t.defaultView&&t.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!y)return;let w={...b||{},pageRoot:r,view:e.name},E=new y(g,{bubbles:!0,cancelable:g==="hcms:change",detail:w});(e.root&&e.root.isConnected!==!1?e.root:r).dispatchEvent(E)},onCloseRequested:i,onViewRequested:o};return p.updateFingerprint=()=>{p.lastFingerprint=Xe(W(p))},e.ctx=p,p}function oo(e){e.updateFingerprint(),e.observerHandle=Ci({onRefresh:n=>e.view.refresh("observer",n)});let t=z("undo");if(t&&typeof t.on=="function"){let n=()=>{if(L.ctx!==e)return;ro(e,"undo");let i=le(V.extract(e.pageRoot,e.pageRules,no),e.pageRules);Xe(i)!==Xe(e.lastData)&&(e.lastData=i,e.onChange?.(i,{path:"",structural:!1}))};t.on("undo",n),t.on("redo",n),e.undoUnsub=()=>{t.off("undo",n),t.off("redo",n)}}let r=()=>ro(e,"livesync");e.livesyncUnsub=Ce(e.doc,ii,r),jr.ctx=e,wa(e.doc)}function ro(e,t){L.ctx===e&&e.view.refresh(t)}function zt(e,{dispatch:t=!0,restoreFocus:r=!0,updateUrl:n=!0,reason:i="close"}={}){if(!e||e.closed)return;e.closed=!0;for(let l of e.uploads||[])try{l.abort()}catch{}e.uploads?.clear();let o=e.previouslyFocused;if(t&&e.dispatch("hcms:close",{reason:i}),n&&_a(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),re(()=>e.view.destroy()),xa(),r&&typeof o?.focus=="function")try{o.focus()}catch{}}function xa(){L.isOpen=!1,L.ctx=null,L.opts=null,jr.ctx=null}var jr={ctx:null};function wa(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let r=function(){let i=jr.ctx;if(i)return Ct(i.formRoot),pe("Reorder",()=>G(W(i),{path:"",structural:!0},i))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=r),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=r)}var Mr="cms";function so(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(Mr)!=="true"?t:(i.set(Mr,"false"),"?"+i.toString())}function lo(e){let t=typeof e=="string"?e:"",r=t.indexOf("?"),n=r===-1?t:t.slice(r+1);return n?new URLSearchParams(n).get(Mr)==="true":!1}function _a(){if(typeof window>"u"||!window.location||!window.history||typeof window.history.replaceState!="function")return;let e=window.location.search,t=so(e);t!==e&&window.history.replaceState(window.history.state,"",t+window.location.hash)}var ao="hcms-toggle",F="data-hcms-toggle-host",co="hcms-toggle-style",mo="data-hcms-toggle-style",Ut="data-hcms-session",ko="data-hcms-split",yo="hcms.view",Bt=["sidebar","inline"],Aa={sidebar:"In the sidebar",inline:"On the page"},qr="var(--hcms-toggle-bg, var(--hcms-toggle-_surface))";function uo(e){try{let t=e&&e.localStorage?e.localStorage.getItem(yo):null;return Bt.includes(t)?t:null}catch{return null}}function Ea(e,t){if(Bt.includes(t))try{e?.localStorage?.setItem(yo,t)}catch{}}var Sa="#fafafa",Ta="#0a0a0a",Ca=`
203
+ [${F}] {
204
+ all: unset;
205
+ box-sizing: border-box;
206
+ display: var(--hcms-toggle-display, inline-flex);
207
+ font-family: 'Departure Mono', ui-monospace, Menlo, monospace;
208
+ --hcms-toggle-_surface: ${Sa};
209
+ }
210
+ [${F}][data-hcms-surface="dark"] {
211
+ --hcms-toggle-_surface: ${Ta};
212
+ }
213
+ [${F}] .hcms-toggle__main,
214
+ [${F}] .hcms-toggle__arrow {
215
+ all: unset;
216
+ box-sizing: border-box;
217
+ display: inline-flex;
218
+ align-items: center;
219
+ gap: 7px;
220
+ padding: 0 14px;
221
+ min-height: 40px;
222
+ font-family: inherit;
223
+ font-weight: 400;
224
+ line-height: 1.5;
225
+ font-size: 14px;
226
+ color: var(--hcms-toggle-color, currentColor);
227
+ border: 2px solid;
228
+ border-color: var(--mirk-bevel-tl, #F0E7D8) var(--mirk-bevel-br, #E2D4BF) var(--mirk-bevel-br, #E2D4BF) var(--mirk-bevel-tl, #F0E7D8);
229
+ border-radius: 0;
230
+ cursor: pointer;
231
+ box-shadow: none;
232
+ }
233
+ [${F}] .hcms-toggle__main:hover,
234
+ [${F}] .hcms-toggle__arrow:hover {
235
+ border-color: var(--mirk-focus-color, #C7AE93);
236
+ box-shadow: none;
237
+ }
238
+ [${F}] .hcms-toggle__main:active,
239
+ [${F}] .hcms-toggle__arrow:active {
240
+ border-color: var(--mirk-bevel-br, #E2D4BF) var(--mirk-bevel-tl, #F0E7D8) var(--mirk-bevel-tl, #F0E7D8) var(--mirk-bevel-br, #E2D4BF);
241
+ }
242
+ [${F}] .hcms-toggle__main:focus-visible,
243
+ [${F}] .hcms-toggle__arrow:focus-visible {
244
+ outline: 2px solid currentColor;
245
+ outline-offset: -5px;
246
+ }
247
+ [${F}] .hcms-toggle__close { display: none; }
248
+ [${F}][${Ut}="open"] .hcms-toggle__open { display: none; }
249
+ [${F}][${Ut}="open"] .hcms-toggle__close { display: inline; }
250
+ [${F}][${ko}] .hcms-toggle__main {
251
+ border-radius: 0;
252
+ padding-right: 12px;
253
+ }
254
+ [${F}] .hcms-toggle__arrow {
255
+ gap: 0;
256
+ padding: 0 10px;
257
+ border-radius: 0;
258
+ border-left-width: 0;
259
+ }
260
+ [${F}] .hcms-toggle__menu {
261
+ all: unset;
262
+ box-sizing: border-box;
263
+ min-width: 180px;
264
+ padding: 4px;
265
+ font-family: inherit;
266
+ font-size: 14px;
267
+ line-height: 1.5;
268
+ color: var(--hcms-toggle-color, currentColor);
269
+ background: ${qr};
270
+ border: 1px solid var(--mirk-input-border, #D8C8AF);
271
+ border-radius: var(--mirk-radius, 5px);
272
+ box-shadow: 0 14px 34px -14px rgba(0, 0, 0, .45);
273
+ }
274
+ [${F}] .hcms-toggle__item {
275
+ all: unset;
276
+ box-sizing: border-box;
277
+ display: block;
278
+ width: 100%;
279
+ padding: 9px 10px;
280
+ border-radius: 0;
281
+ cursor: pointer;
282
+ }
283
+ [${F}] .hcms-toggle__item::before {
284
+ content: "\u25CB";
285
+ margin-right: 8px;
286
+ opacity: .55;
287
+ }
288
+ [${F}] .hcms-toggle__item[aria-checked="true"]::before {
289
+ content: "\u25CF";
290
+ opacity: 1;
291
+ }
292
+ [${F}] .hcms-toggle__item:hover {
293
+ background: color-mix(in srgb, currentColor 12%, transparent);
294
+ }
295
+ [${F}] .hcms-toggle__item:focus-visible {
296
+ outline: 2px solid currentColor;
297
+ outline-offset: -3px;
298
+ }
299
+ @media (pointer: coarse) {
300
+ [${F}] .hcms-toggle__main,
301
+ [${F}] .hcms-toggle__arrow { min-height: 44px; }
302
+ }
303
+ `;function Ra({search:e="",cookie:t="",forced:r=null}={}){let n=typeof e=="string"?e:"",i=n.indexOf("?"),o=i===-1?n:n.slice(i+1),l=new URLSearchParams(o).get("editmode");return l?l==="true":r!=null?!!r:/(?:^|;\s*)isAdminOfCurrentResource=[^;]/.test(t)}var Fr=new WeakMap;function vo(e,t){try{e.globalCompositeOperation="copy",e.fillStyle=t,e.fillRect(0,0,1,1);let r=e.getImageData(0,0,1,1).data;return{r:r[0],g:r[1],b:r[2],a:r[3]/255}}catch{return null}}function Oa(e){if(Fr.has(e))return Fr.get(e);let t=null;try{let r=e.createElement("canvas");if(r.width=r.height=1,t=r.getContext?r.getContext("2d",{willReadFrequently:!0}):null,t){let n=vo(t,"rgb(1, 2, 3)");(!n||n.r!==1||n.g!==2||n.b!==3||n.a!==1)&&(t=null)}}catch{t=null}return Fr.set(e,t),t}function La(e,t){let r=String(e??"").trim();if(!r)return null;let n=Na(r);if(n)return n;let i=t&&t.defaultView;if(!i||!i.CSS||typeof i.CSS.supports!="function"||!i.CSS.supports("color",r))return null;let o=Oa(t);return o?vo(o,r):null}function Na(e){let t=/rgba?\(([^)]+)\)/.exec(String(e??""));if(!t)return null;let r=t[1].split(/[\s,/]+/).filter(Boolean);if(r.length<3)return null;let n=r.slice(0,3).map(Number);if(n.some(Number.isNaN))return null;let i=r[3],o=i===void 0?1:i.endsWith("%")?Number(i.slice(0,-1))/100:Number(i);return{r:n[0],g:n[1],b:n[2],a:Number.isNaN(o)?1:o}}function ho({r:e,g:t,b:r}){let n=i=>{let o=i/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*n(e)+.7152*n(t)+.0722*n(r)}function po(e,t){let r=ho(e),n=ho(t);return(Math.max(r,n)+.05)/(Math.min(r,n)+.05)}var fo={r:10,g:10,b:10},go={r:250,g:250,b:250};function bo(e,t){let r=e.a==null?1:e.a;return{r:e.r*r+t.r*(1-r),g:e.g*r+t.g*(1-r),b:e.b*r+t.b*(1-r)}}function Ma(e){if(!e)return"light";let t=po(bo(e,fo),fo),r=po(bo(e,go),go);return t>r?"dark":"light"}function nt(e,t){for(let[r,n]of Object.entries(t))e.style.setProperty(r,n,"important")}function Ir(e){let t=e.ownerDocument&&e.ownerDocument.defaultView,r=e.querySelector(".hcms-toggle__main");if(!t||!r||typeof t.getComputedStyle!="function")return;let n=La(t.getComputedStyle(r).color,e.ownerDocument);e.setAttribute("data-hcms-surface",Ma(n))}function ja(e){Ir(e);let t=e.ownerDocument,r=t&&t.defaultView;if(!r)return;let n=0,i=()=>{if(!n){if(typeof r.requestAnimationFrame!="function")return e.isConnected?Ir(e):s();n=r.requestAnimationFrame(()=>{if(n=0,!e.isConnected)return s();Ir(e)})}};typeof r.requestAnimationFrame=="function"&&i(),t.readyState!=="complete"&&r.addEventListener("load",i,{once:!0});let o=typeof r.MutationObserver=="function"?new r.MutationObserver(i):null;o&&(o.observe(t.documentElement,{attributes:!0}),t.body&&o.observe(t.body,{attributes:!0}));let l=typeof r.matchMedia=="function"?r.matchMedia("(prefers-color-scheme: dark)"):null;l&&typeof l.addEventListener=="function"&&l.addEventListener("change",i);function s(){o&&o.disconnect(),l&&typeof l.removeEventListener=="function"&&l.removeEventListener("change",i)}}function Fa({open:e,close:t,isOpen:r,getTheme:n=()=>null,views:i=Bt},o=document){let l=o.querySelector(`[${F}]`);if(l)return l;if(!o.querySelector(`[${mo}]`)){let A=o.createElement("style");A.setAttribute(mo,""),A.setAttribute("editor-ui",""),o.getElementById(co)||(A.id=co),A.setAttribute("no-save",""),A.setAttribute("snapshot-remove",""),A.setAttribute("save-ignore",""),A.textContent=Ca,o.head.insertBefore(A,o.head.firstChild)}let s=o.createElement("hypercms-toggle");s.className="hcms-shell pixel-quiet",o.getElementById(ao)||(s.id=ao),s.setAttribute(F,""),s.setAttribute("editor-ui",""),s.setAttribute("no-save",""),s.setAttribute("snapshot-remove",""),s.setAttribute("save-ignore",""),s.innerHTML='<button type="button" class="hcms-toggle__main mirk-button"><span class="hcms-toggle__open">Edit content</span><span class="hcms-toggle__close">Close editor</span></button>';let a=o.defaultView,d=s.querySelector(".hcms-toggle__main"),m=Bt.filter(A=>i.includes(A)),f=m.length>1,c=f?Ia(o):null,h=f?qa(o,m):null;f&&(s.setAttribute(ko,""),s.appendChild(c),s.appendChild(h)),nt(s,{position:"fixed",right:"calc(var(--hcms-toggle-offset, 16px) + var(--hcms-toggle-shift, 0px))",bottom:"calc(var(--hcms-toggle-offset, 16px) + env(safe-area-inset-bottom, 0px))","z-index":"var(--hcms-toggle-z, 2147482900)"}),nt(d,{background:qr}),c&&nt(c,{background:qr}),h&&nt(h,{position:"absolute",right:"0",bottom:"calc(100% + 8px)","z-index":"var(--hcms-toggle-z, 2147482900)",display:"none"});let u=()=>h?[...h.querySelectorAll('[role="menuitemradio"]')]:[];function p(A){if(!(!A||typeof A.focus!="function"))try{A.focus({preventScroll:!0})}catch{A.focus()}}function g(A){let j=u();j.length&&p(j[(A+j.length)%j.length])}function b(){let A=uo(a);for(let j of u())j.setAttribute("aria-checked",String(j.getAttribute("data-hcms-view")===A))}function y(A){s.contains(A.target)||x()}function w(A){h&&(h.hidden=!A,nt(h,{display:A?"block":"none"}),c.setAttribute("aria-expanded",String(A)),A?(b(),o.addEventListener("pointerdown",y,!0)):o.removeEventListener("pointerdown",y,!0))}function E(A=0){w(!0),g(A)}function x({focusArrow:A=!1}={}){!h||h.hidden||(w(!1),A&&p(c))}function T(){let A=uo(a);return A&&m.includes(A)?A:null}async function C(A){await e({view:A}),Ea(a,A)}async function H(){if(r()){t();return}let A=T();return A?e({view:A}):f?E():e(m[0]?{view:m[0]}:{})}async function P(A){try{await A()}catch(j){console.warn("hypercms: toggle failed to open the CMS",j)}}s.addEventListener("click",async A=>{c&&c.contains(A.target)||h&&h.contains(A.target)||await P(H)}),c&&(c.addEventListener("click",A=>{A.preventDefault(),h.hidden?E():x({focusArrow:!0})}),c.addEventListener("keydown",A=>{if(A.key==="ArrowUp"){A.preventDefault(),E(-1);return}(A.key==="ArrowDown"||A.key==="Enter"||A.key===" ")&&(A.preventDefault(),E(0))}),h.addEventListener("click",A=>{let j=A.target.closest?.('[role="menuitemradio"]');j&&(A.preventDefault(),x(),P(()=>C(j.getAttribute("data-hcms-view"))))}),h.addEventListener("keydown",A=>{let j=u(),ge=j.indexOf(o.activeElement);switch(A.key){case"ArrowDown":A.preventDefault(),g(ge+1);break;case"ArrowUp":A.preventDefault(),g(ge-1);break;case"Home":A.preventDefault(),g(0);break;case"End":A.preventDefault(),g(j.length-1);break;case"Enter":case" ":if(A.preventDefault(),ge===-1)break;x(),P(()=>C(j[ge].getAttribute("data-hcms-view")));break;case"Escape":A.preventDefault(),x({focusArrow:!0});break;case"Tab":x();break}}));let K=A=>{let j=n();s.classList.toggle("light",j==="light"),s.classList.toggle("dark",j==="dark"),A?s.setAttribute(Ut,"open"):s.removeAttribute(Ut)};return K(r()),o.addEventListener("hcms:open",()=>K(!0)),o.addEventListener("hcms:close",()=>K(!1)),o.body.appendChild(s),ae(o),ja(s),s}function Ia(e){let t=e.createElement("button");return t.type="button",t.className="hcms-toggle__arrow mirk-button",t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-label","Choose where to edit"),t.textContent="\u25BE",t}function qa(e,t){let r=e.createElement("div");r.className="hcms-toggle__menu",r.setAttribute("role","menu"),r.setAttribute("aria-label","Where to edit"),r.hidden=!0;for(let n of t){let i=e.createElement("button");i.type="button",i.className="hcms-toggle__item",i.setAttribute("role","menuitemradio"),i.setAttribute("aria-checked","false"),i.setAttribute("data-hcms-view",n),i.tabIndex=-1,i.textContent=Aa[n],r.appendChild(i)}return r}function xo(e){if(typeof window>"u"||typeof document>"u")return;let t=window.__hyperclayEditMode!=null?window.__hyperclayEditMode:null;if(!Ra({search:window.location.search,cookie:document.cookie,forced:t}))return;let r=()=>{document.body&&e.hasRules(document)&&Fa(e)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r,{once:!0}):r()}function wo(e){if(xi(e),typeof document<"u"){let t=document.getElementById("hcms-shell-styles");t?.tagName==="LINK"&&t.remove(),ae(document)}}var Pr={sidebar:Ri,inline:Ji};function Ht(e={}){let t=e.view||(L.isOpen?L.ctx.view.name:"sidebar"),r=Pr[t];if(!r)throw new Error(`hypercms: unknown view "${t}" (expected ${Object.keys(Pr).join(" or ")})`);let n=L.isOpen?{...L.opts,...e,view:t}:e,i=n.pageRoot||(typeof document<"u"?document.body:null);if(!i)throw new Error("hypercms: no pageRoot available");let o=i.ownerDocument||(typeof document<"u"?document:null);if(!o)throw new Error("hypercms: no document available");let l=null,s=null;if(L.isOpen){if(L.ctx.view.name===t)return;l=L.ctx.previouslyFocused,s=L.ctx.view.name,zt(L.ctx,{restoreFocus:!1,updateUrl:!1,reason:"switch"})}Bi();let a=r({doc:o,pageRoot:i,opts:n}),d=io({view:a,doc:o,pageRoot:i,opts:n,onCloseRequested:()=>$r(),onViewRequested:m=>Ht({view:m})});l&&(d.previouslyFocused=l);try{a.mount(d.initialData),oo(d),a.focusOnOpen(),L.isOpen=!0,L.ctx=d,L.opts=n,d.dispatch("hcms:open",{pageRoot:i,previous:s})}catch(m){throw zt(d,{dispatch:!1,restoreFocus:!!l,updateUrl:!1}),m}}function $r(){L.isOpen&&zt(L.ctx)}function _o(){L.isOpen&&L.ctx.view.refresh("api")}function Da(){return L.isOpen}function Pa(){return L.isOpen&&L.ctx?L.ctx.view.name:null}var $a={getData(){return L.isOpen?W(L.ctx):null},setValue(e,t){if(!L.isOpen)throw new Error("hypercms: cms is not open");let r=L.ctx,n=ee(e),i=me(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=St(r.formRoot,e);if(!o)throw new Error(`hypercms: no field element at path "${e}"`);Tt(o,t,r.formRoot,e),G(W(r),{path:e,structural:!1},r)},addItem(e){if(!L.isOpen)throw new Error("hypercms: cms is not open");Ye(e,L.ctx)},removeItem(e){if(!L.isOpen)throw new Error("hypercms: cms is not open");let t=L.ctx,r=ee(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=me(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 l=t.formRoot.querySelector(`[data-hcms-path="${Va(e)}"]`);if(!l)throw new Error(`hypercms: no element at path "${e}"`);Le(l,t)},refresh:_o,_commit(){if(!L.isOpen)return;let e=L.ctx;return Ct(e.formRoot),pe("Update",()=>G(W(e),{path:"",structural:!0},e))}},za=250,Ua=1e4;function Ba(){typeof window>"u"||typeof document>"u"||lo(window.location?window.location.search:"")&&(L.isOpen||Ha(()=>{if(!L.isOpen)try{Ht()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function Dr(){return!!document.body&&!!z("Mutation")}function Ha(e){if(Dr()){queueMicrotask(e);return}let t=Date.now()+Ua,r=!1,n=null,i=null,o=()=>{r||(r=!0,n!==null&&clearInterval(n),i&&i())};function l(){if(L.isOpen){o();return}Dr()&&(o(),e())}i=Ce(document,ni,l),n=setInterval(()=>{if(L.isOpen){o();return}if(Dr()){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."))},za)}Ba();xo({open:Ht,close:$r,isOpen:Da,getTheme:()=>L.opts?.theme,views:Object.keys(Pr),hasRules:e=>!!V.findRules(e,"cms")});var zr={open:Ht,close:$r,refresh:_o,api:$a,get isOpen(){return L.isOpen},currentView:Pa,path:ir,scaffold:We,morphForm:at};function Va(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Ao=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
193
304
  Source of truth: mirk-interface/mirk.css + src/theme/pixel-quiet.overrides.css.
194
305
  Regenerate with: npm run build:theme */
195
306
 
@@ -1203,7 +1314,7 @@ body.hcms-open.hcms-overlay #hcms-toggle { display: none; }
1203
1314
  /* =====================================================================
1204
1315
  Pixel Quiet \u2014 hypercms theme overrides (hypercms-owned).
1205
1316
 
1206
- Adapted from cms-sidebar/pixel-quiet/overrides.css. Two jobs:
1317
+ Adapted from ARCHIVE_PROJECTS/cms-sidebar/pixel-quiet/overrides.css. Two jobs:
1207
1318
  1. Retune --mirk-* tokens, scoped to .hcms-shell.pixel-quiet (never :root).
1208
1319
  2. Author the panel geometry + the functional chrome the static mockup
1209
1320
  doesn't have (error banner, add/remove/move controls, the engine's
@@ -1314,13 +1425,13 @@ body.hcms-open.hcms-overlay #hcms-toggle { display: none; }
1314
1425
  position: fixed makes the shell a containing block so the absolute
1315
1426
  minibar anchors to it; flex column so the body owns the scroll.
1316
1427
  ============================================================ */
1317
- .hcms-shell.pixel-quiet {
1428
+ .hcms-shell.pixel-quiet.hcms-panel {
1318
1429
  box-sizing: border-box;
1319
1430
  position: fixed;
1320
1431
  top: 0;
1321
1432
  right: 0;
1322
1433
  bottom: 0;
1323
- width: 380px;
1434
+ width: var(--hcms-shell-width, 380px);
1324
1435
  max-width: 100vw;
1325
1436
  z-index: 2147483000;
1326
1437
  display: flex;
@@ -1330,7 +1441,7 @@ body.hcms-open.hcms-overlay #hcms-toggle { display: none; }
1330
1441
  border-left: 1px solid var(--mirk-input-border);
1331
1442
  box-shadow: -16px 0 48px -28px rgba(43, 36, 27, 0.45);
1332
1443
  }
1333
- .hcms-shell.pixel-quiet.dark {
1444
+ .hcms-shell.pixel-quiet.hcms-panel.dark {
1334
1445
  box-shadow: -16px 0 48px -28px rgba(0, 0, 0, 0.6);
1335
1446
  }
1336
1447
 
@@ -1342,13 +1453,20 @@ body.hcms-open.hcms-overlay #hcms-toggle { display: none; }
1342
1453
  box-shadow: 16px 0 48px -28px rgba(43, 36, 27, 0.45);
1343
1454
  }
1344
1455
 
1345
- /* Push the page over so docked content is never hidden underneath. */
1346
- body.hcms-open:not(.hcms-overlay) { padding-right: 380px; }
1347
- body.hcms-open.hcms-side-left:not(.hcms-overlay) { padding-right: 0; padding-left: 380px; }
1348
- body.hcms-open.hcms-overlay { overflow: hidden; }
1456
+ /* Push the page over so docked content is never hidden underneath, and publish
1457
+ the geometry the floating toggle has to compose with. --hcms-toggle-shift is
1458
+ the distance the toggle moves left, which is the shell width only while the
1459
+ shell is docked on the right; docked left, as an overlay, or full-viewport it
1460
+ is zero. */
1461
+ body.hcms-open { --hcms-shell-width: 380px; }
1462
+ body.hcms-open:not(.hcms-overlay) { padding-right: var(--hcms-shell-width); }
1463
+ body.hcms-open:not(.hcms-overlay):not(.hcms-side-left) { --hcms-toggle-shift: var(--hcms-shell-width); }
1464
+ body.hcms-open.hcms-side-left:not(.hcms-overlay) { padding-right: 0; padding-left: var(--hcms-shell-width); }
1465
+ body.hcms-open.hcms-overlay { overflow: hidden; --hcms-toggle-display: none; }
1349
1466
 
1350
1467
  @media (max-width: 799px) {
1351
- .hcms-shell.pixel-quiet { width: 100vw; }
1468
+ body.hcms-open { --hcms-shell-width: 100vw; }
1469
+ body.hcms-open:not(.hcms-overlay):not(.hcms-side-left) { --hcms-toggle-shift: 0px; }
1352
1470
  body.hcms-open:not(.hcms-overlay),
1353
1471
  body.hcms-open.hcms-side-left:not(.hcms-overlay) { padding-right: 0; padding-left: 0; }
1354
1472
  body.hcms-open { overflow: hidden; }
@@ -1725,6 +1843,7 @@ body.hcms-open.hcms-overlay { overflow: hidden; }
1725
1843
  .hcms-shell-notice {
1726
1844
  font-size: 12px;
1727
1845
  line-height: 1.45;
1846
+ white-space: pre-line;
1728
1847
  color: var(--mirk-mark-fg);
1729
1848
  background: var(--mirk-bevel-bg);
1730
1849
  border: 1px solid var(--mirk-input-border);
@@ -1791,16 +1910,290 @@ body.hcms-open.hcms-overlay { overflow: hidden; }
1791
1910
  cursor: pointer;
1792
1911
  }
1793
1912
  .hcms-sr-only[hidden] { display: none; }
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)})})})();mi(pi);var la=Ar,ca={cms:Ar};return _i(ua);})();
1795
1913
 
1796
- // Auto-export to window unless suppressed by loader.
1797
- // Per hypercms plan locked decision 3: flatten to hyperclay.hypercms.open(),
1798
- // not hyperclay.hypercms.cms.open().
1799
- if (!window.__hyperclayNoAutoExport) {
1800
- window.hyperclay = window.hyperclay || {};
1801
- window.hyperclay.hypercms = hypercms.cms;
1802
- window.h = window.hyperclay;
1914
+ /* ============================================================
1915
+ INLINE VIEW GEOMETRY \u2014 not a panel. A transparent full-viewport
1916
+ host whose children are the only interactive surfaces, so the page
1917
+ underneath stays fully usable while the editor is open.
1918
+ ============================================================ */
1919
+ .hcms-shell.pixel-quiet.hcms-inline {
1920
+ position: fixed;
1921
+ inset: 0;
1922
+ z-index: 2147483000;
1923
+ /* The host must never intercept a click meant for the page. Each child
1924
+ re-enables pointer events for itself. */
1925
+ pointer-events: none;
1926
+ background: none;
1927
+ border: 0;
1928
+ box-shadow: none;
1929
+ color: var(--mirk-fg);
1930
+ }
1931
+ .hcms-inline > *,
1932
+ .hcms-inline-layer > * { pointer-events: auto; }
1933
+ .hcms-inline-layer { position: absolute; inset: 0; pointer-events: none; }
1934
+
1935
+ .hcms-inline-bar {
1936
+ position: absolute;
1937
+ left: 50%;
1938
+ bottom: 16px;
1939
+ transform: translateX(-50%);
1940
+ max-width: min(560px, calc(100vw - 32px));
1941
+ display: flex;
1942
+ flex-direction: column;
1943
+ gap: 6px;
1803
1944
  }
1804
1945
 
1805
- export const cms = hypercms.cms;
1806
- export default hypercms;
1946
+ .hcms-inline-notice,
1947
+ .hcms-inline-error {
1948
+ padding: 8px 12px;
1949
+ border-radius: 8px;
1950
+ font-size: 14px;
1951
+ line-height: 1.4;
1952
+ border: 1px solid var(--mirk-input-border);
1953
+ background: var(--mirk-bg);
1954
+ color: var(--mirk-fg);
1955
+ box-shadow: 0 12px 32px -20px rgba(43, 36, 27, 0.5);
1956
+ }
1957
+ .hcms-inline-notice { white-space: pre-line; }
1958
+ .hcms-inline-error { border-color: var(--mirk-destructive); color: var(--mirk-destructive); }
1959
+ .hcms-inline-notice[hidden],
1960
+ .hcms-inline-error[hidden] { display: none; }
1961
+
1962
+ .hcms-inline-pop {
1963
+ position: absolute;
1964
+ top: 0;
1965
+ left: 0;
1966
+ box-sizing: border-box;
1967
+ width: min(340px, calc(100vw - 24px));
1968
+ max-height: calc(100dvh - 24px);
1969
+ overflow: auto;
1970
+ padding: 16px;
1971
+ border-radius: 8px;
1972
+ border: 1px solid var(--mirk-input-border);
1973
+ background: var(--mirk-bg);
1974
+ color: var(--mirk-fg);
1975
+ box-shadow: 0 16px 40px -22px rgba(43, 36, 27, 0.55);
1976
+ /* Above the handles. They are positioned with z-index: 1 while the popover
1977
+ sat at auto, so a handle painted over the very field it had just opened
1978
+ and covered the text in it. The popover is what someone is using; a handle
1979
+ is only an offer to open one. */
1980
+ z-index: 2;
1981
+ }
1982
+ .hcms-inline-pop[hidden] { display: none; }
1983
+ .hcms-inline-pop-header {
1984
+ display: flex;
1985
+ align-items: center;
1986
+ justify-content: space-between;
1987
+ gap: 16px;
1988
+ margin-bottom: 16px;
1989
+ font-size: 14px;
1990
+ }
1991
+ .hcms-shell .hcms-inline-pop-close {
1992
+ display: inline-flex;
1993
+ align-items: center;
1994
+ justify-content: center;
1995
+ min-width: 36px;
1996
+ min-height: 36px;
1997
+ padding: 4px;
1998
+ }
1999
+
2000
+ .hcms-inline-item-controls {
2001
+ position: absolute;
2002
+ top: 0;
2003
+ left: 0;
2004
+ z-index: 1;
2005
+ will-change: transform;
2006
+ display: flex;
2007
+ align-items: center;
2008
+ gap: 2px;
2009
+ }
2010
+ .hcms-inline-item-controls[hidden],
2011
+ .hcms-inline-handle[hidden] { display: none; }
2012
+ .hcms-inline-item-controls.has-open-settings { z-index: 3; }
2013
+ .hcms-inline-settings { position: relative; display: flex; flex: none; }
2014
+ .hcms-inline-settings[hidden],
2015
+ .hcms-inline-settings-menu[hidden] { display: none; }
2016
+ .hcms-inline-settings-menu {
2017
+ position: absolute;
2018
+ top: calc(100% + 6px);
2019
+ right: 0;
2020
+ min-width: 120px;
2021
+ padding: 4px;
2022
+ border: 1px solid var(--mirk-input-border);
2023
+ border-radius: 5px;
2024
+ background: var(--mirk-bg);
2025
+ box-shadow: 0 8px 24px #0003;
2026
+ }
2027
+ .hcms-inline-settings-menu button {
2028
+ display: block;
2029
+ box-sizing: border-box;
2030
+ width: 100%;
2031
+ padding: 10px 12px;
2032
+ border: 0;
2033
+ background: transparent;
2034
+ color: var(--mirk-destructive);
2035
+ font: inherit;
2036
+ text-align: left;
2037
+ cursor: pointer;
2038
+ }
2039
+ .hcms-inline-settings-menu button:hover,
2040
+ .hcms-inline-settings-menu button:focus-visible {
2041
+ background: var(--mirk-bevel-bg);
2042
+ outline: 1px solid var(--mirk-focus-color);
2043
+ }
2044
+
2045
+ /* Buttons flow within the positioned item container. */
2046
+ .hcms-inline-row-controls {
2047
+ display: flex;
2048
+ gap: 2px;
2049
+ }
2050
+ .hcms-inline-row-controls[hidden] { display: none; }
2051
+
2052
+ .hcms-inline-list-add[hidden] { display: none; }
2053
+
2054
+ .hcms-shell.hcms-inline-ghost {
2055
+ box-sizing: border-box;
2056
+ position: relative;
2057
+ display: flex;
2058
+ align-items: center;
2059
+ justify-content: center;
2060
+ flex: none;
2061
+ max-width: 100%;
2062
+ min-width: 0;
2063
+ margin: 8px 0 0;
2064
+ padding: 0;
2065
+ border: 1px dashed color-mix(in srgb, currentColor 25%, transparent);
2066
+ border-radius: 3px;
2067
+ background: color-mix(in srgb, currentColor 3%, transparent);
2068
+ color: inherit;
2069
+ list-style: none;
2070
+ }
2071
+ .hcms-shell.hcms-inline-ghost[hidden] { display: none; }
2072
+ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
2073
+ .hcms-inline-ghost-cell { padding: 0; text-align: center; vertical-align: middle; }
2074
+
2075
+ .hcms-shell .hcms-inline-handle,
2076
+ .hcms-shell .hcms-inline-list-button {
2077
+ display: inline-flex;
2078
+ align-items: center;
2079
+ justify-content: center;
2080
+ min-width: 36px;
2081
+ min-height: 36px;
2082
+ padding: 4px;
2083
+ line-height: 1;
2084
+ }
2085
+ .hcms-inline-handle .mirk-button__label,
2086
+ .hcms-inline-list-button .mirk-button__label {
2087
+ display: inline-flex;
2088
+ align-items: center;
2089
+ gap: 6px;
2090
+ line-height: 1;
2091
+ }
2092
+ .hcms-inline-icon { display: block; width: 24px; height: 24px; flex: none; }
2093
+ .hcms-inline-handle .hcms-inline-icon { width: 20.4px; height: 20.4px; transform: translateY(-1px); }
2094
+ .hcms-inline-list-add .hcms-inline-icon { width: 16.8px; height: 16.8px; }
2095
+ .hcms-shell .hcms-inline-list-add { padding-inline: 10px; }
2096
+
2097
+ .hcms-inline-list-button {
2098
+ flex: none;
2099
+ }
2100
+ .hcms-inline-list-button[hidden] { display: none; }
2101
+ .hcms-shell .hcms-inline-list-button:disabled {
2102
+ opacity: 1;
2103
+ color: #626B96;
2104
+ background: var(--mirk-bevel-bg);
2105
+ border-color: var(--mirk-bevel-tl) var(--mirk-bevel-br) var(--mirk-bevel-br) var(--mirk-bevel-tl);
2106
+ }
2107
+ .hcms-shell .hcms-inline-list-button:disabled .mirk-button__label { translate: none; }
2108
+
2109
+ /* A finger is not a mouse pointer: on touch the same three controls get the
2110
+ 44px target the platform guidelines ask for. */
2111
+ @media (pointer: coarse) {
2112
+ .hcms-shell .hcms-inline-handle,
2113
+ .hcms-shell .hcms-inline-list-button {
2114
+ min-width: 44px;
2115
+ min-height: 44px;
2116
+ }
2117
+ }
2118
+
2119
+ .hcms-inline-toggle { align-self: center; }
2120
+ .hcms-inline-toggle[hidden] { display: none; }
2121
+
2122
+ /* Fields with no visible anchor can still be edited through the sidebar. */
2123
+ .hcms-inline-handoff {
2124
+ display: flex;
2125
+ align-items: center;
2126
+ gap: 10px;
2127
+ padding: 6px 6px 6px 12px;
2128
+ border-radius: 999px;
2129
+ font-size: 13px;
2130
+ border: 1px solid var(--mirk-input-border);
2131
+ background: var(--mirk-bg);
2132
+ color: var(--mirk-fg);
2133
+ align-self: center;
2134
+ }
2135
+ .hcms-inline-handoff[hidden] { display: none; }
2136
+
2137
+ /* Selected fields only. Scoped to the inline host: [data-hcms-shell] is on BOTH
2138
+ hosts, so an unscoped rule hides the sidebar's whole form too. */
2139
+ .hcms-inline .hcms-form [data-hcms-path] { display: none; }
2140
+ .hcms-inline .hcms-form [data-hcms-path].is-hcms-inline-onpath,
2141
+ .hcms-inline .hcms-form [data-hcms-path].is-hcms-inline-active { display: block; }
2142
+
2143
+ .hcms-inline .hcms-form .is-hcms-inline-onpath,
2144
+ .hcms-inline .hcms-form {
2145
+ margin: 0;
2146
+ padding: 0;
2147
+ border: 0;
2148
+ border-radius: 0;
2149
+ box-shadow: none;
2150
+ background: transparent;
2151
+ min-width: 0;
2152
+ min-height: 0;
2153
+ width: 100%;
2154
+ }
2155
+ .hcms-inline-pop .hcms-object-title,
2156
+ .hcms-inline-pop .hcms-array-header,
2157
+ .hcms-inline-pop .hcms-drag-handle,
2158
+ .hcms-inline-pop [data-hcms-action="add"],
2159
+ .hcms-inline-pop [data-hcms-action="remove"],
2160
+ .hcms-inline-pop [data-hcms-action="move-up"],
2161
+ .hcms-inline-pop [data-hcms-action="move-down"],
2162
+ .hcms-inline-pop .hcms-card-controls { display: none; }
2163
+ .hcms-inline .hcms-form .hcms-field.is-hcms-inline-active {
2164
+ display: flex;
2165
+ gap: 8px;
2166
+ padding: 0;
2167
+ margin: 0 0 16px;
2168
+ border: 0;
2169
+ min-width: min(260px, 100%);
2170
+ }
2171
+ .hcms-inline .hcms-form .hcms-field.is-hcms-inline-active:last-child { margin-bottom: 0; }
2172
+ .hcms-shell.pixel-quiet .hcms-inline-pop .mirk-input,
2173
+ .hcms-shell.pixel-quiet .hcms-inline-pop .mirk-textarea {
2174
+ box-sizing: border-box;
2175
+ width: 100%;
2176
+ min-width: min(260px, 100%);
2177
+ min-height: 42px;
2178
+ padding: 10px 12px;
2179
+ border: 1px solid var(--mirk-input-border);
2180
+ background: var(--mirk-input-bg);
2181
+ }
2182
+ .hcms-inline-pop .mirk-input:focus-visible,
2183
+ .hcms-inline-pop .mirk-textarea:focus-visible {
2184
+ outline: 2px solid var(--mirk-focus-color);
2185
+ outline-offset: 2px;
2186
+ }
2187
+
2188
+ .hcms-inline-highlight {
2189
+ position: absolute;
2190
+ top: 0;
2191
+ left: 0;
2192
+ pointer-events: none;
2193
+ border: 2px solid var(--mirk-focus-color);
2194
+ border-radius: 4px;
2195
+ box-sizing: border-box;
2196
+ will-change: transform;
2197
+ }
2198
+ .hcms-inline-highlight[hidden] { display: none; }
2199
+ `;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 l=n.files[0],s=document.createElement("a");if(s.className="mirk-file__name",s.dataset.filled="",s.href=URL.createObjectURL(l),s.target="_blank",s.rel="noopener",s.textContent=l.name,o.replaceWith(s),!i.querySelector(".mirk-file__remove")){let a=document.createElement("button");a.type="button",a.className="mirk-file__remove",a.setAttribute("aria-label","Remove file"),a.innerHTML=e,s.after(a)}}),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 l=i.querySelector(".mirk-image__placeholder"),s=new FileReader;s.onload=a=>{o.src=a.target.result,o.removeAttribute("hidden"),l&&l.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"),l=o?.querySelector(".mirk-file__input"),s=o?.querySelector(".mirk-file__name");if(l&&(l.value=""),s){let a=document.createElement("span");a.className="mirk-file__name",a.textContent="No file chosen",s.replaceWith(a)}n.remove();return}let i=r.target.closest(".mirk-image__remove");if(i){let o=i.closest(".mirk-image"),l=o?.querySelector(".mirk-image__input"),s=o?.querySelector(".mirk-image__preview");l&&(l.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 l=document.createElement("button");l.type="button",l.className="mirk-tags__remove",l.textContent="\xD7";let s=document.createElement("span");if(s.className="mirk-tags__chip",n){let a=document.createElement("span");a.className="mirk-tags__chip-inner",a.append(i,o,l),s.append(a)}else s.append(i,o,l);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(a=>a.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 a=n.textContent;n.textContent="copied",n.dataset.copied="",setTimeout(()=>{n.textContent=a,delete n.dataset.copied},1200)}).catch(()=>{n.textContent="error",setTimeout(()=>{n.textContent="copy"},1200)})})})();wo(Ao);var Vt=zr,Ga={cms:zr};typeof window<"u"&&!window.__hyperclayNoAutoExport&&(window.hyperclay=window.hyperclay||{},window.hyperclay.hypercms=Vt,window.h=window.hyperclay);var nh=Vt,ih=Ur;export{nh as cms,ih as default};