@panphora/hyper-cms 0.11.2 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- var hypercms=(()=>{var ws=Object.defineProperty;var iu=Object.getOwnPropertyDescriptor;var lu=Object.getOwnPropertyNames;var au=Object.prototype.hasOwnProperty;var As=(e,t)=>{for(var n in t)ws(e,n,{get:t[n],enumerable:!0})},cu=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of lu(t))!au.call(e,o)&&o!==n&&ws(e,o,{get:()=>t[o],enumerable:!(r=iu(t,o))||r.enumerable});return e};var uu=e=>cu(ws({},"__esModule",{value:!0}),e);var Om={};As(Om,{cms:()=>Em,default:()=>_m});function Vt(e){let t=0,n=null,r=-1;for(let o=0;o<e.length;o++){let s=e[o];s==="\\"?o++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:s==="@"&&t===0&&(r=o)}return r}function To(e){let t=Vt(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function Eo(e,t){if(typeof e=="string"){let n=t&&t.defaultView,r=n&&n.DOMParser||globalThis.DOMParser;return new r().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Ss(e){let t=new Map;return(n,r)=>{if(typeof r!="string")return Eo(r,e);let o=t.get(n);if(o&&o.text===r)return o.doc;let s=Eo(r,e);return t.set(n,{text:r,doc:s}),s}}function Xi(e,t){let n=t.doctype;if(!n)return!1;let r=e.doctype;if(r&&r.name===n.name&&r.publicId===n.publicId&&r.systemId===n.systemId)return!1;let o=e.implementation.createDocumentType(n.name,n.publicId,n.systemId);return r?e.replaceChild(o,r):e.insertBefore(o,e.documentElement),!0}var Ts=()=>!1;function Es(e,t=[]){if(typeof e!="function")return Ts;let n=new WeakMap,r=new Set(t);return o=>{if(!o||o.nodeType!==1)return!1;let s=n.get(o);if(s!==void 0)return s;let i=[],l=o,a=!1;for(;l&&l.nodeType===1;){let u=n.get(l);if(u!==void 0){a=u;break}if(i.push(l),e(l,r.has(l))){a=!0;break}if(r.has(l))break;l=l.parentElement}for(let u of i)n.set(u,a);return a}}var Vm=Object.freeze(["root-tag","equal","root-attrs","root-level","not-in-body","ignored-ancestor","remote-wins-ancestor","form-ancestor","script-or-template","no-live-twin","live-detached","ancestor-live","sibling-live","outside-id-changed","chain-unpaired"]);function Un(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function _s(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let r=t["~"],o=typeof r=="string"?r.split(",").map(Number):null,s=o&&typeof t["^"]=="string"?t["^"].split(","):null,i=h=>Number.isInteger(h)&&h>=0,l=0,a=!1,u=h=>{let f=h;for(;f>0;){let p=o[l++];if(l>o.length||!i(p))return!1;f+=p-1}return!0},d=(h,f)=>{if(a)return;if(o){let v=l++,m=o[v];if(v>=o.length||!i(m)){a=!0;return}let g=!s||s[v]===h.tagName.toLowerCase();if(!g||m!==h.children.length){let y=g&&t[f];typeof y=="string"&&y&&n.set(h,y),u(m)||(a=!0);return}}let p=t[f];typeof p=="string"&&p&&n.set(h,p);let b=h.children;for(let v=0;v<b.length;v++)d(b[v],f===""?String(v):`${f}.${v}`)};return d(e,""),n}function Ji(e){return t=>{for(let n of e){let r=n(t);if(typeof r=="string"&&r!=="")return r}return null}}var bn=Ji([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function _o(e,t,n,r=null){let o=new Map,s=new Set,i=l=>{if(n(l))return;let a=t(l);a&&(o.has(a)?s.add(a):o.set(a,l))};if(r){let l=a=>{for(let u of a.querySelectorAll(r))i(u);for(let u of a.querySelectorAll("template"))u.content&&l(u.content)};i(e),l(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let l=a=>{i(a);let u=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let d=0;d<u.length;d++)l(u[d])};l(e)}for(let l of s)o.delete(l),Os(l);return o}function Os(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var du=new Set(["href","src","name","type","role"]),Qi=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function pr(e,t=5381){let n=t;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return n>>>0}function Zi(e){return e.replace(/\s+/g," ")}var hu=0;function el({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let r=new WeakMap,o=new WeakMap;function s(H){let z=H.attributes,ae=z.length;if(ae===0)return{all:"",sig:H.tagName+"|"};let me=[],Q="",L=[];for(let Ee=0;Ee<ae;Ee++){let xe=z[Ee],se=xe.name;t(H,se)||me.push(se+"="+xe.value),se==="class"?Q=xe.value.indexOf(" ")<0?xe.value:xe.value.split(/\s+/).filter(Boolean).sort().join(" "):du.has(se)&&L.push(se+"="+xe.value)}return me.length>1&&me.sort(),L.length>1&&L.sort(),{all:me.join(""),sig:H.tagName+"|"+Q+(L.length?"|"+L.join("|"):"")}}function i(H){return H.nodeType===1&&H.tagName==="TEMPLATE"&&H.content?H.content.childNodes:H.childNodes}function l(H){let z=r.get(H);if(z)return z;if(H.nodeType===3)z={hash:"T"+pr(H.nodeValue),hint:Zi(H.nodeValue).slice(0,64),sig:null,tok:null};else if(H.nodeType===8)z={hash:"C"+pr(H.nodeValue),hint:"",sig:null,tok:null};else if(H.nodeType===1){let ae=s(H),me=pr(H.tagName+""+ae.all),Q="";for(let L of u(H))if(L.nodeType===1){let Ee=l(L);me=pr(Ee.hash,me),Q.length<64&&(Q+=" "+Ee.hint)}else me=pr(d(L),me),L.kind==="text"&&Q.length<64&&(Q+=L.value.slice(0,64));z={hash:"E"+me,hint:Zi(Q).trim().slice(0,64),sig:ae.sig,tok:null}}else z={hash:"N"+H.nodeType,hint:"",sig:null,tok:null};return r.set(H,z),z}function a(H){if(!H.tok){H.tok=new Set;for(let z of H.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))z&&H.tok.add(z)}return H.tok}function u(H){let z=o.get(H);if(z)return z;z=[];let ae=null,me=()=>{ae&&(ae.value=ae.nodes.map(Q=>Q.nodeValue).join(""),z.push(ae),ae=null)};for(let Q of i(H)){if(Q.nodeType===3){ae||(ae={kind:"text",nodes:[],value:"",parent:H,hash:void 0}),ae.nodes.push(Q);continue}me(),Q.nodeType===8?z.push({kind:"comment",nodes:[Q],value:Q.nodeValue,parent:H,hash:void 0}):Q.nodeType===1&&!e(Q)&&z.push(Q)}return me(),o.set(H,z),z}function d(H){return H.nodeType===1?l(H).hash:(H.hash===void 0&&(H.hash=(H.kind==="text"?"T":"C")+pr(H.value)),H.hash)}function h(H,z){let ae=a(l(H)),me=a(l(z));if(ae.size===0&&me.size===0)return{coef:1,share:1};if(ae.size===0||me.size===0)return null;let Q=0;for(let L of ae)me.has(L)&&Q++;return{coef:Q/Math.min(ae.size,me.size),share:Q/Math.max(ae.size,me.size)}}function f(H,z){let ae=h(H,z);return!!ae&&ae.coef>=.5}let p=new WeakMap;function b(H){let z=p.get(H);if(z)return z;z=[];for(let ae of H.attributes)t(H,ae.name)||z.push([ae.namespaceURI||"",ae.localName,ae.value]);return z.sort((ae,me)=>ae[0]<me[0]?-1:ae[0]>me[0]?1:ae[1]<me[1]?-1:ae[1]>me[1]?1:0),p.set(H,z),z}let v=new WeakMap;function m(H,z){if(H===z)return!0;if(d(H)!==d(z))return!1;let ae=v.get(H);if(ae&&ae.has(z))return ae.get(z);let me=v.get(z);if(me&&me.has(H))return me.get(H);let Q=g(H,z),L=Q===!0;return Q===!1&&n&&n.hashRejected++,ae||v.set(H,ae=new WeakMap),ae.set(z,L),L}function g(H,z){if(H.nodeType===1){if(z.nodeType!==1||H.tagName!==z.tagName||H.namespaceURI!==z.namespaceURI)return!1;let ae=b(H),me=b(z);if(ae.length!==me.length)return!1;for(let Ee=0;Ee<ae.length;Ee++)if(ae[Ee][0]!==me[Ee][0]||ae[Ee][1]!==me[Ee][1]||ae[Ee][2]!==me[Ee][2])return!1;let Q=u(H),L=u(z);if(Q.length!==L.length)return!1;for(let Ee=0;Ee<Q.length;Ee++){if(d(Q[Ee])!==d(L[Ee]))return!1;if(!m(Q[Ee],L[Ee]))return hu}return!0}return z.nodeType===1?!1:H.kind===z.kind&&H.value===z.value}let y=new WeakMap,I=new Map,Y=0;function $(H){let z=y.get(H);if(z)return z;let ae=d(H),me=I.get(ae);me||I.set(ae,me=[]);let Q=me.find(L=>m(L.unit,H));return z=Q?Q.key:"K"+Y++,Q||me.push({unit:H,key:z}),y.set(H,z),z}return{meta:l,unitsOf:u,unitHash:d,similar:f,score:h,childrenOf:i,equalUnits:m,exactUnitKey:$,ignored:e}}var tl=16,mu=2e3,pu=3,Ns={align:0,certifyVisited:0,certifyScheduled:0};function Cs(e,t,n){let{meta:r,unitsOf:o,unitHash:s,similar:i,score:l,childrenOf:a,equalUnits:u,ignored:d}=n.analyzer,h=n.baseId||(()=>null),f=n.sideId||(()=>null),p=n.stats||null,b=p?new Set:null,v=p?new Set:null,m=new Map,g=new Map,y=new Set,I=new Map,Y=new Set,$=new Set,H=new Set,z=[],ae=[],me=[],Q=[],L=mu,Ee=new Map,xe=new Map,se=(x,A)=>{m.set(x,A),g.set(A,x)},V=new Set,Se=new Set,ve=null,Me=x=>{let A=x.nodeType?x.parentNode:x.parent;if(!A||A.nodeType!==11)return A;if(!ve){ve=new WeakMap;let j=G=>{for(let q of G.querySelectorAll("template"))q.content&&(ve.set(q.content,q),j(q.content))};for(let G of[e,t])j(G.tagName==="TEMPLATE"&&G.content?G.content:G)}return ve.get(A)||null},He=(x,A)=>{for(let j=Me(x);j&&!V.has(j);j=Me(j))V.add(j);for(let j=Me(A);j&&!Se.has(j);j=Me(j))Se.add(j)},Ve=x=>{for(let A=Me(x);A;A=Me(A))if(m.has(A))return $.has(A);return!1},it=x=>{for(let A=Me(x);A;A=Me(A)){let j=g.get(A);if(j!==void 0)return $.has(j)}return!1},le=x=>!!x&&x.nodeType===1,yt=(x,A)=>{let j=I.get(x);return!!j&&j.has(A)},et=x=>Qi.has(x.tagName),Oe=n.comparisons||n.scope,_=(x,A)=>{if(Oe){if(Oe.same.get(x)===A)return!0;if(Oe.differ.get(x)===A)return!1}if(!x.isEqualNode(A))return!1;if(x.tagName==="TEMPLATE")return u(x,A);let j=x.getElementsByTagName("template");if(j.length===0)return!0;let G=A.getElementsByTagName("template");if(j.length!==G.length)return!1;for(let q=0;q<j.length;q++)if(!u(j[q],G[q]))return!1;return!0},B=(x,A)=>{let j=h(x);if(!j)return!0;let G=f(A);return!G||j===G},fe=globalThis.__hyperMorphProfile,Ae=fe?performance.now():0;fe&&!n.scope&&(r(e),r(t),fe.meta=(fe.meta||0)+(performance.now()-Ae),Ae=performance.now()),se(e,t);let pe=new Set;for(let[x,A]of n.baseIndex){let j=n.sideIndex.get(x);j&&j.tagName===A.tagName&&!m.has(A)&&!g.has(j)&&(se(A,j),He(A,j),pe.add(A))}if(pe.size){let x=[];if(n.scope)for(let q of n.scope.chain)pe.has(q)&&x.push(q);let A=[n.scope?n.scope.root:e];for(;A.length;){let q=A.pop();pe.has(q)&&x.push(q);let X=a(q);for(let O=X.length-1;O>=0;O--)X[O].nodeType===1&&A.push(X[O])}let j=new Set;for(let q=x.length-1;q>=0;q--){let X=x[q];n.scope&&n.scope.onChain.has(X)?j.add(X):kt(X,m.get(X),j)?($.add(X),H.add(X),p&&p.certificationPairs++):j.add(X)}let G=new Set;for(let q of x)$.has(q)&&!G.has(q)&&Qe(q,G)}n.scope&&n.scope.head&&ht(n.scope.head[0],n.scope.head[1]);function Qe(x,A){let j=[x];for(;j.length;){let G=j.pop();if(!A.has(G)){A.add(G),T(G);for(let q of o(G))le(q)&&m.has(q)&&j.push(q)}}}Q.push([e,t]);for(let[x,A]of m)le(x)&&x!==e&&Q.push([x,A]);return ee(),qe(),fe&&(fe.align=(fe.align||0)+(performance.now()-Ae)),{map:m,reverse:g,moved:Y,identical:$,pairIdenticalChildren:T,weak:y,unpair:rt,rematch:qe,insertedByHash:lt,refused:v,identityPaired:pe};function qe(){P(),ee();for(let x=0;x<me.length;){let A=me.length;Ue(x,A),x=A,ee(),P(),ee()}}function rt(x){let A=m.get(x);if(!A)return;I.has(x)||I.set(x,new Set),I.get(x).add(A);let j=(q,X)=>{m.delete(q),g.delete(X),Y.delete(q),$.delete(q),y.delete(q),H.delete(q)},G=(q,X)=>{for(let O of o(q)){let C=m.get(O);!C||pe.has(O)||!(le(C)?X.contains(C):X.contains(C.nodes[0]))||(j(O,C),le(O)&&G(O,C))}};j(x,A),le(x)&&G(x,A),z.push(x),ae.push(A)}function lt(){let x=new Map;for(let A of new Set(ae)){if(g.has(A))continue;let j=r(A).hash;x.has(j)||x.set(j,[]),x.get(j).push(A)}return x}function ee(){for(;Q.length;){let[x,A]=Q.shift();m.get(x)!==A||H.has(x)||$.has(x)||ge(x,A)}}function ce(x,A){if(!et(x))for(let j of o(x))le(j)&&(A.push(j),ce(j,A))}function ge(x,A){H.add(x);let j=o(x),G=o(A);Ns.align+=j.length+G.length,Ee=new Map,xe=new Map;for(let Z=0;Z<j.length;Z++)Ee.set(j[Z],Z);for(let Z=0;Z<G.length;Z++)xe.set(G[Z],Z);if(x.tagName==="HTML")for(let Z of["HEAD","BODY"]){let ye=j.find(k=>le(k)&&k.tagName===Z),Re=G.find(k=>le(k)&&k.tagName===Z);ye&&Re&&!m.has(ye)&&!g.has(Re)&&se(ye,Re)}for(let Z=0;Z<j.length&&Z<G.length;Z++){let ye=j[Z],Re=G[Z];m.has(ye)||g.has(Re)||(le(ye)?le(Re)&&ye.tagName===Re.tagName&&_(ye,Re)&&ht(ye,Re):!le(Re)&&ye.kind===Re.kind&&ye.value===Re.value&&ht(ye,Re))}E(j,G);let q=j.filter(Z=>!m.has(Z)),X=G.filter(Z=>!g.has(Z));q.length&&X.length&&(Je(q,X),re(q,X),oe(q,X,j,G),he(j,G));let O=!1,C=!1;for(let Z of j){if(!m.has(Z)){le(Z)&&(z.push(Z),ce(Z,z),O=!0);continue}le(Z)&&!$.has(Z)&&Q.push([Z,m.get(Z)])}for(let Z of G)!g.has(Z)&&le(Z)&&(ae.push(Z),ce(Z,ae),C=!0);O&&C&&me.push([x,A])}function Ue(x,A){for(let j=x;j<A;j++){let[G,q]=me[j];if(m.get(G)!==q)continue;let X=o(G),O=o(q),C=new Map,Z=new Map,ye=null;for(let Re of X)le(Re)&&(m.has(Re)?ye=Re:(C.has(ye)||C.set(ye,[]),C.get(ye).push(Re)));ye=null;for(let Re of O)le(Re)&&(g.has(Re)?ye=g.get(Re):(Z.has(ye)||Z.set(ye,[]),Z.get(ye).push(Re)));for(let[Re,k]of C){let N=Z.get(Re);if(!(!N||k.length!==N.length)&&k.every((D,U)=>N[U].tagName===D.tagName&&B(D,N[U])&&!yt(D,N[U])))for(let D=0;D<k.length;D++)ke(k[D],N[D])}}}function ke(x,A){se(x,A),y.add(x),Q.push([x,A]),ee()}function Je(x,A){let j=gr(x,s),G=gr(A,s),q=new Map;for(let X of A){let O=s(X);G.get(O)===1&&q.set(O,X)}for(let X of x){if(m.has(X))continue;let O=s(X);if(j.get(O)!==1)continue;let C=q.get(O);C&&!g.has(C)&&u(X,C)&&ht(X,C)}}function kt(x,A,j){let G=[[x,A]];for(;G.length;){let[q,X]=G.pop();if(Ns.certifyVisited++,p&&p.certificationVisited++,q.nodeType!==X.nodeType)return!1;if(q.nodeType===3||q.nodeType===8){if(q.nodeValue!==X.nodeValue)return!1;continue}if(q.nodeType!==1){if(!q.isEqualNode(X))return!1;continue}if(q.tagName!==X.tagName||q.namespaceURI!==X.namespaceURI||d(q)!==d(X))return!1;let O=q.attributes,C=X.attributes;if(O.length!==C.length)return!1;for(let N=0;N<O.length;N++){let D=O[N];if(X.getAttributeNS(D.namespaceURI,D.localName)!==D.value)return!1}let Z=m.get(q);if(Z!==void 0&&Z!==X)return!1;let ye=g.get(X);if(ye!==void 0&&ye!==q)return!1;if(q!==x){if($.has(q))continue;if(j.has(q))return!1}let Re=a(q),k=a(X);if(Re.length!==k.length)return!1;Ns.certifyScheduled+=Re.length;for(let N=Re.length-1;N>=0;N--)G.push([Re[N],k[N]])}return!0}function ht(x,A){if(le(x)&&(V.has(x)||Se.has(A))){let j=ze(x,A);if(!j){se(x,A),Q.push([x,A]);return}for(let G=0;G<j.length;G+=2){let q=j[G],X=j[G+1],O=m.get(q);O!==void 0&&O!==X&&wt(q,O);let C=g.get(X);C!==void 0&&C!==q&&wt(C,X),m.get(q)===X&&(Y.delete(q),y.delete(q),$.add(q),H.add(q))}}Ot(x,A)}function wt(x,A){m.delete(x),g.delete(A),Y.delete(x),$.delete(x),y.delete(x),H.delete(x)}function ze(x,A){let j=[x,A,!1],G=[];for(;j.length;){let q=j.pop(),X=j.pop(),O=j.pop(),C=m.get(O),Z=g.get(X);if(O!==x&&(C!==void 0&&C!==X&&pe.has(O)||Z!==void 0&&Z!==O&&pe.has(Z)))return null;if(!(C===X&&$.has(O))&&((C!==void 0||Z!==void 0)&&G.push(O,X),!!le(O))){if(q||C!==void 0&&C!==X||Z!==void 0&&Z!==O){let ye=o(O),Re=o(X);for(let k=0;k<ye.length&&k<Re.length;k++)j.push(ye[k],Re[k],!0)}else if(V.has(O)||Se.has(X)){let ye=O.tagName==="TEMPLATE"?O.content:O,Re=X.tagName==="TEMPLATE"?X.content:X;for(let k=ye.firstElementChild,N=Re.firstElementChild;k&&N;){if(d(k)){k=k.nextElementSibling;continue}if(d(N)){N=N.nextElementSibling;continue}(m.has(k)||g.has(N)||V.has(k)||Se.has(N))&&j.push(k,N,!1),k=k.nextElementSibling,N=N.nextElementSibling}}}}return G}function Ot(x,A){se(x,A),$.add(x),le(x)&&H.add(x)}function T(x){let A=m.get(x);if(!A||!le(x))return;let j=o(x),G=o(A);for(let q=0;q<j.length&&q<G.length;q++)m.has(j[q])||Ot(j[q],G[q])}function re(x,A){let j=O=>le(O)&&!et(O)?r(O).sig+""+r(O).hint:null,G=gr(x,j),q=gr(A,j),X=new Map;for(let O of A){let C=j(O);C!=null&&q.get(C)===1&&X.set(C,O)}for(let O of x){if(m.has(O))continue;let C=j(O);if(C==null||G.get(C)!==1)continue;let Z=X.get(C);Z&&!g.has(Z)&&B(O,Z)&&se(O,Z)}}function oe(x,A,j,G){let q=new Map;for(let O of A){if(!le(O)||g.has(O)||et(O))continue;let C=r(O).sig;q.has(C)||q.set(C,[]),q.get(C).push({el:O,index:xe.get(O)})}let X=[];for(let O of x){if(m.has(O)||!le(O)||et(O))continue;let C=q.get(r(O).sig);if(!C||!C.length)continue;let Z=Ee.get(O),ye=C.filter(Re=>!g.has(Re.el)).map(Re=>({c:Re,d:Math.abs(Re.index-Z)}));ye.sort((Re,k)=>Re.d-k.d),ye.length>tl&&(ye=ye.slice(0,tl));for(let{c:Re,d:k}of ye){if(!B(O,Re.el))continue;let N=l(O,Re.el);N&&N.coef>=.5&&X.push({b:O,s:Re.el,coef:N.coef,share:N.share,d:k,bi:Z})}}if(X.sort((O,C)=>C.coef-O.coef||C.share-O.share||O.d-C.d||O.bi-C.bi),p&&X.length>1){let O=new Map;for(let C of X){let Z=O.get(C.b);Z?Z.coef===C.coef&&(Z.share===C.share?Z.strict++:Z.loose++):O.set(C.b,{coef:C.coef,share:C.share,strict:0,loose:0})}for(let[C,Z]of O)b.has(C)||!(Z.strict||Z.loose)||(b.add(C),Z.strict?p.similarTiesStrict++:p.similarTiesLoose++)}for(let O of X)!m.has(O.b)&&!g.has(O.s)&&se(O.b,O.s)}function de(x,A){return le(x)!==le(A)?!1:le(x)?x.tagName!==A.tagName||!B(x,A)?!1:et(x)||r(x).hint===""||r(A).hint===""?!0:i(x,A):x.kind===A.kind}function ie(x,A){let j=(q,X)=>{let O=X===null?-1:q===A?xe.get(X):Ee.get(X),C=q[O+1];return C&&!le(C)?C:null},G=null;for(let q of x){if(le(q)){G=q;continue}if(m.has(q))continue;let X=G===null?null:m.get(G);if(G!==null&&!X)continue;let O=j(A,X);O&&!g.has(O)&&O.kind===q.kind&&se(q,O)}}function he(x,A){ie(x,A);let j=w(x,A),G=(X,O)=>le(X)&&r(X).hint!==""&&r(O).hint===""&&!!O.querySelector("br")&&!j(X,O),q=0;for(let X of x){if(m.has(X)){let C=xe.get(m.get(X));C!==void 0&&C>=q&&(q=C+1);continue}let O=0;for(let C=q;C<A.length&&O<pu;C++){let Z=A[C];if(!g.has(Z)&&(O++,de(X,Z)&&!yt(X,Z)&&!G(X,Z))){se(X,Z),le(X)&&(r(X).hint===""||r(Z).hint==="")&&y.add(X),q=C+1;break}}}E(x,A)}function w(x,A){let j=(G,q,X)=>{for(let O=q-1;O>=0;O--)if(le(G[O])&&X(G[O]))return G[O];return null};return(G,q)=>{let X=Ee.get(G),O=xe.get(q);if(X===O)return!0;let C=j(x,X,ye=>m.has(ye)),Z=j(A,O,ye=>g.has(ye));return C?m.get(C)===Z:!Z}}function E(x,A){let j=x.filter(C=>le(C)&&!m.has(C)),G=A.filter(C=>le(C)&&!g.has(C));if(!j.length||!G.length)return;let q=gr(j,C=>C.tagName),X=gr(G,C=>C.tagName),O=w(x,A);for(let C of j){let Z=C.tagName;if(q.get(Z)!==1||X.get(Z)!==1)continue;let ye=G.find(Re=>Re.tagName===Z);ye&&!g.has(ye)&&O(C,ye)&&B(C,ye)&&!yt(C,ye)&&(u(C,ye)?ht(C,ye):(se(C,ye),y.add(C)))}}function P(){let x=new Map;for(let C of y)if(le(C)&&le(m.get(C))){let Z=r(C).hash;x.has(Z)||x.set(Z,[]),x.get(Z).push(C)}if(x.size)for(let C of ae){if(g.has(C)||!le(C)||it(C))continue;let Z=x.get(r(C).hash),ye=Z&&Z.find(Re=>y.has(Re)&&!yt(Re,C)&&B(Re,C)&&u(Re,C));ye&&(rt(ye),ht(ye,C),He(ye,C),Y.add(ye))}let A=new Map,j=new Map,G=new Map;for(let C of y){let Z=m.get(C);le(C)&&le(Z)&&G.set(Z,C)}let q=(C,Z)=>{if(!g.has(C))return!it(C);let ye=G.get(C);return ye===g.get(C)&&ye!==Z&&!ye.contains(Z)},X=C=>{if(g.has(C)){let Z=G.get(C);G.delete(C),rt(Z)}};for(let C of[...ae,...G.keys()]){if(g.has(C)&&!G.has(C))continue;let Z=r(C).hash;if(A.has(Z)||A.set(Z,[]),A.get(Z).push(C),et(C))continue;let ye=r(C).sig;j.has(ye)||j.set(ye,[]),j.get(ye).push(C)}let O=new Set;for(let C of y){let Z=m.get(C);!le(C)||!le(Z)||et(C)||r(C).hint===""||r(Z).hint===""||i(C,Z)||O.add(C)}for(let C of[...z,...O]){let Z=m.get(C);if(Z?!(y.has(C)&&O.has(C)):Ve(C))continue;let ye=U=>{Z&&rt(C),X(U)},Re=A.get(r(C).hash);if(Re){let U=Re.find(W=>W!==Z&&q(W,C)&&!yt(C,W)&&u(C,W));if(U){ye(U),ht(C,U),He(C,U),Y.add(C);continue}}if(et(C)||L<=0)continue;let k=j.get(r(C).sig);if(!k)continue;let N=null,D=0;for(let U of k)if(!(U===Z||!q(U,C)||!B(C,U)||yt(C,U))&&(L--<=0||i(C,U)&&(D++,N=U,D>1)))break;D>1&&v&&v.add(C),D===1&&(ye(N),se(C,N),He(C,N),Y.add(C),Q.push([C,N]))}}}function gr(e,t){let n=new Map;for(let r of e){let o=t(r);o!=null&&n.set(o,(n.get(o)||0)+1)}return n}var gu={diff:0},nl=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,bu=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,ku=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,yu=/\P{M}\p{M}*/gu;function Ps(e){if(e==="")return[];if(nl){let n=[];for(let r of nl.segment(e))n.push(r.segment);return n}let t=[];for(let n of e.match(ku))if(bu.test(n))for(let r of n.match(yu))t.push(r);else t.push(n);return t}var xu=/^[  ]+$/,vu=e=>xu.test(e)?" ".repeat(e.length):e,zn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),Et="",Ms=e=>e.every(t=>zn(t)||t.k===Et),wu=/^[\x00-\x7f\u00A0]*$/,Au=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Su(e){return e===""?[]:e.match(Au)}function rr(e,t=!1){return(t?Su(e):Ps(e)).map(n=>({k:vu(n),raw:n,len:n.length}))}var Oo=(...e)=>e.every(t=>wu.test(t));function Rs(e,t,n){let r=e.length,o=t.length,s=Math.min(r+o,n),i=s+1,l=new Int32Array(2*s+3),a=[],u=r===0&&o===0;for(let p=0;p<=s&&!u;p++){a.push(l.slice(i-p,i+p+1));for(let b=-p;b<=p;b+=2){let v;b===-p||b!==p&&l[i+b-1]<l[i+b+1]?v=l[i+b+1]:v=l[i+b-1]+1;let m=v-b,g=v;for(;v<r&&m<o&&e[v].k===t[m].k;)v++,m++;if(gu.diff+=1+v-g,l[i+b]=v,v>=r&&m>=o){u=!0;break}}}if(!u)return null;let d=[],h=r,f=o;for(let p=a.length-1;p>0;p--){let b=a[p],v=h-f,m=v+p,g=v===-p||v!==p&&b[m-1]<b[m+1]?v+1:v-1,y=b[g+p],I=y-g;for(;h>y&&f>I;)d.push([0,h-1,f-1]),h--,f--;h===y?(d.push([1,h,f-1]),f--):(d.push([-1,h-1,f]),h--)}for(;h>0&&f>0;)d.push([0,h-1,f-1]),h--,f--;return d.reverse(),d}function Tu(e,t,n){let r=h=>h.k===Et;if(!e.some(r)&&!t.some(r))return Rs(e,t,n);let o=[],s=[];for(let h=0;h<e.length;h++)r(e[h])||o.push(h);for(let h=0;h<t.length;h++)r(t[h])||s.push(h);let i=Rs(o.map(h=>e[h]),s.map(h=>t[h]),n);if(!i)return null;let l=[],a=0,u=0,d=(h,f)=>{for(;a<h&&u<f&&e[a].k===t[u].k;)l.push([0,a++,u++]);let p=Rs(e.slice(a,h),t.slice(u,f),n);if(!p)return!1;for(let[b,v,m]of p)l.push([b,v+a,m+u]);return a=h,u=f,!0};for(let[h,f,p]of i)if(h===0){if(!d(o[f],s[p]))return null;l.push([0,a,u]),a++,u++}return d(e.length,t.length)?l:null}function br(e,t,n=4e3){let r=[],o=0;for(;o<e.length&&o<t.length&&e[o].k===t[o].k;)e[o].raw!==t[o].raw&&r.push({bi:o,tok:t[o]}),o++;let s=0;for(;s<e.length-o&&s<t.length-o&&e[e.length-1-s].k===t[t.length-1-s].k;)e[e.length-1-s].raw!==t[t.length-1-s].raw&&r.push({bi:e.length-1-s,tok:t[t.length-1-s]}),s++;let i=e.slice(o,e.length-s),l=t.slice(o,t.length-s),a=Mu(i,l)?null:Tu(i,l,n);if(!a){let g=i.length||l.length?[{bs:o,be:o+i.length,toks:l}]:[];return{hunks:g,cosmetic:r,coarse:!0,parts:g.map(y=>({...y,gap:[],group:0})),cosmeticEq:r}}let u=[],d=(g,y)=>{i[g].raw!==l[y].raw&&r.push({bi:o+g,tok:l[y]})},h=null,f=[],p=0,b=0,v=()=>{h&&u.push(h),h=null;for(let[g,y]of f)d(g,y);f=[],p++};for(let[g,y,I]of a){if(g===0){h&&zn(i[y])&&!i[y].k.includes(`
2
- `)?f.push([y,I]):(v(),d(y,I)),b=y+1;continue}(!h||f.length)&&(h&&u.push(h),h={bs:o+b,be:o+b,toks:[],gap:f.map(([Y,$])=>({bi:o+Y,tok:l[$]})),group:p},f=[]),g===-1?(h.be=o+b+1,b=y+1):h.toks.push(l[I])}v(),Eu(u,e);let m=Is(u);return{hunks:m.hunks,cosmetic:r.concat(m.cosmetic),parts:u,cosmeticEq:r}}function Eu(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r.gap.length)continue;let o=n+1<e.length?e[n+1].bs:1/0;if(r.toks.length){if(r.bs===r.be)for(;r.bs+1<o&&r.bs<t.length&&r.toks[0].k===Et&&t[r.bs].k===Et;)r.toks=[...r.toks.slice(1),r.toks[0]],r.bs++,r.be++}else for(;r.be+1<o&&r.be<t.length&&t[r.bs].k===Et&&t[r.be].k===Et;)r.bs++,r.be++}}function Is(e,t=()=>!1){let n=[],r=[],o=null,s=-1;for(let i of e){let l=t(i);if(o&&!o.alone&&!l&&i.group===s){o.be=i.be;for(let a of i.gap)o.toks.push(a.tok);for(let a of i.toks)o.toks.push(a);continue}o&&n.push({bs:o.bs,be:o.be,toks:o.toks});for(let a of i.gap)r.push(a);o={bs:i.bs,be:i.be,toks:i.toks.slice(),alone:l},s=i.group}return o&&n.push({bs:o.bs,be:o.be,toks:o.toks}),{hunks:n,cosmetic:r}}var _u=(e,t)=>e.bs===t.bs&&e.be===t.be&&Fs(e.toks,t.toks);function Ds(e,t,n){let r=d=>h=>d.some(f=>_u(h,f)),o=Is(e.parts,r(t.parts)),s=Is(t.parts,r(e.parts)),i=e.cosmeticEq.concat(o.cosmetic),l=t.cosmeticEq.concat(s.cosmetic),[a,u]=n?Ou(o.hunks,s.hunks,n,i,l):[o.hunks,s.hunks];return{lh:a,rh:u,cosL:i,cosR:l}}function Ou(e,t,n,r,o){let s=(b,v)=>b.k===v.k&&b.raw===v.raw,i=[{list:e.map(b=>({...b})),resp:new Set(r.map(b=>b.bi)),raw:new Map(r.map(b=>[b.bi,b.tok]))},{list:t.map(b=>({...b})),resp:new Set(o.map(b=>b.bi)),raw:new Map(o.map(b=>[b.bi,b.tok]))}],l=b=>b.bs===b.be,a=(b,v,m,g)=>{let y=b.list[v];if(!l(y))return g(y)===m?y.toks:null;let I=v?b.list[v-1].be:0,Y=v+1<b.list.length?b.list[v+1].bs:n.length;if(m<I||m>Y)return null;let $=y.toks,H=y.bs;for(;H>m;){let z=$[$.length-1];if(!s(z,n[H-1])||b.resp.has(H-1))return null;$=[z,...$.slice(0,-1)],H--}for(;H<m;){if(!s($[0],n[H])||b.resp.has(H))return null;$=[...$.slice(1),$[0]],H++}return $},u=(b,v,m,g,y,I)=>{let Y=b.list[v],$=y?m.slice(m.length-g):m.slice(0,g),H=y?m.slice(0,m.length-g):m.slice(g),z={bs:I,be:I,toks:$};if(l(Y)){if(!H.length){b.list[v]=z;return}let me={bs:I,be:I,toks:H};y&&(me.lead=!0),b.list.splice(v,1,...y?[me,z]:[z,me]);return}let ae={bs:Y.bs,be:Y.be,toks:H};b.list.splice(v,1,...y?[ae,z]:[z,ae])},d=(b,v,m,g,y)=>{let I=b.list[v],Y=y?m.slice(m.length-g):m.slice(0,g),$=y?m.slice(0,m.length-g):m.slice(g),H={bs:I.bs,be:I.be,toks:Y};if(!$.length){b.list[v]=H;return}let z=y?{bs:I.bs,be:I.bs,toks:$,lead:!0}:{bs:I.be,be:I.be,toks:$};b.list.splice(v,1,...y?[z,H]:[H,z])},h=(b,v,m,g)=>{let y=b.list[v],I=m.list[g],Y=y.be,$=I.bs;if(Y>=$||v+1<b.list.length&&b.list[v+1].bs<=I.be||g>0&&m.list[g-1].be>=y.bs)return!1;for(let ve=Y;ve<$;ve++)if(!zn(n[ve])||n[ve].k.includes(`
3
- `))return!1;let H=ve=>n.slice(Y,$).map((Me,He)=>ve.raw.get(Y+He)||Me),z=[...y.toks,...H(b)],ae=[...H(m),...I.toks],me=(ve,Me,He)=>Me>=0&&Me+He.length<=ve.length&&He.every((Ve,it)=>ve[Me+it].k===Ve.k),Q=(ve,Me,He)=>Ms(ve)&&n.slice(Me,He).some(Ve=>!zn(Ve)),L=ve=>ve.some(Me=>!zn(Me)),Ee,xe,se,V;if(l(y)&&L(y.toks)&&me(ae,0,y.toks)){let ve=ae.slice(y.toks.length);Q(ve,Y,I.be)||(Ee=Y,xe=y.toks,se=ae.slice(0,y.toks.length),V=[null,{bs:Y,be:I.be,toks:ve}])}if(Ee===void 0&&l(I)&&L(I.toks)){let ve=z.length-I.toks.length,Me=z.slice(0,ve);me(z,ve,I.toks)&&!Q(Me,y.bs,$)&&(Ee=$,xe=z.slice(ve),se=I.toks,V=[{bs:y.bs,be:$,toks:Me},null])}if(Ee===void 0)return!1;let Se=ve=>ve&&(ve.bs<ve.be||ve.toks.length);return b.list.splice(v,1,...[V[0],{bs:Ee,be:Ee,toks:xe}].filter(Se)),m.list.splice(g,1,...[{bs:Ee,be:Ee,toks:se},V[1]].filter(Se)),!0},f=i[0],p=i[1];for(let b=0;b<64;b++){let v=!1;e:for(let m=0;m<f.list.length;m++)for(let g=0;g<p.list.length;g++){let y=f.list[m],I=p.list[g];if(!(y.bs===I.bs&&y.be===I.be&&Fs(y.toks,I.toks))){for(let Y of[!0,!1]){let $=z=>Y?z.be:z.bs,H=l(y)?[$(I),y.bs]:[$(y)];for(let z of H){let ae=a(f,m,z,$),me=ae&&a(p,g,z,$);if(!me)continue;let Q=(V,Se)=>Y?V[V.length-1-Se]:V[Se],L=0;for(;L<ae.length&&L<me.length&&Q(ae,L).k===Q(me,L).k;)L++;if(!L)continue;let Ee=Y?ae.slice(0,ae.length-L):ae.slice(L),xe=Y?me.slice(0,me.length-L):me.slice(L);if(!(L<ae.length&&L<me.length&&!Ms(Ee)&&!Ms(xe)&&(l(y)&&l(I)||y.bs===I.bs&&y.be===I.be)||!(Y?ae.slice(ae.length-L):ae.slice(0,L)).some(V=>!zn(V)))){if(L===ae.length&&L===me.length&&l(y)&&l(I)){if(y.bs===z&&I.bs===z)continue;f.list[m]={bs:z,be:z,toks:ae},p.list[g]={bs:z,be:z,toks:me}}else!l(y)&&y.bs===I.bs&&y.be===I.be?(d(f,m,ae,L,Y),d(p,g,me,L,Y)):(u(f,m,ae,L,Y,z),u(p,g,me,L,Y,z));v=!0;break e}}}if(h(f,m,p,g)||h(p,g,f,m)){v=!0;break e}}}if(!v)break}return[f.list,p.list]}var Nu=48,Cu=.3;function Mu(e,t){let n=e.filter(i=>!zn(i)),r=t.filter(i=>!zn(i));if(Math.min(n.length,r.length)<Nu)return!1;let o=new Map;for(let i of n)o.set(i.k,(o.get(i.k)||0)+1);let s=0;for(let i of r){let l=o.get(i.k);l>0&&(s++,o.set(i.k,l-1))}return s/Math.min(n.length,r.length)<Cu}var Ru=(e,t)=>{let n=new Set;for(let r of e.toks)typeof r.k!="string"&&n.add(r.k.el);for(let r=e.bs;r<e.be;r++)typeof t[r].k!="string"&&n.add(t[r].k.el);return n},Fs=(e,t)=>e.length===t.length&&e.every((n,r)=>n.k===t[r].k);function rl(e,t,n,r="remote"){let o=br(e,t),s=br(e,n),{lh:i,rh:l,cosL:a,cosR:u}=Ds(o,s,e),d=_=>_.bs===_.be,h=_=>_.toks.some(B=>typeof B.k=="string"),f=_=>d(_)&&!h(_),p=(_,B)=>B.bs<_.be&&_.bs<B.be,b=(_,B)=>!p(_,B)&&B.bs<=_.be&&_.bs<=B.be&&(d(_)&&h(_)||d(B)&&h(B))&&!(d(_)&&d(B)),v=(_,B)=>_.bs===B.bs&&_.be===B.be&&Fs(_.toks,B.toks),m=[],g=new Set;for(let _ of i){let B=l.find(fe=>!g.has(fe)&&v(_,fe));B?(g.add(B),m.push({bs:_.bs,be:_.be,side:"both",l:_,r:B,toks:_.toks})):m.push({bs:_.bs,be:_.be,side:"L",l:_,toks:_.toks,lead:!!_.lead})}for(let _ of l)g.has(_)||m.push({bs:_.bs,be:_.be,side:"R",r:_,toks:_.toks,lead:!!_.lead});m.sort((_,B)=>_.bs-B.bs||_.be-B.be||B.lead-_.lead);let y=0,I=0;for(let _ of m)_.side==="both"&&(y+=_.toks.length-(_.be-_.bs));let Y=m.map((_,B)=>B),$=_=>Y[_]===_?_:Y[_]=$(Y[_]),H=(_,B)=>(_=$(_),B=$(B),_===B?!1:(Y[_]=B,!0)),z=m.map(_=>Ru({bs:_.bs,be:_.be,toks:_.toks},e)),ae={L:new Map,R:new Map};m.forEach((_,B)=>{let fe=_.side==="both"?["L","R"]:[_.side];for(let Ae of fe)for(let pe of z[B])ae[Ae].has(pe)||ae[Ae].set(pe,[]),ae[Ae].get(pe).push(B)});for(let _ of[ae.L,ae.R])for(let B of _.values())for(let fe=1;fe<B.length;fe++)H(B[0],B[fe]);for(let _=0;_<m.length;_++)for(let B=_+1;B<m.length;B++){let fe=m[_],Ae=m[B];fe.side===Ae.side&&fe.side!=="both"||fe.bs>Ae.be||(p(fe,Ae)||b(fe,Ae)?H(_,B):fe.bs===Ae.bs&&d(fe)&&d(Ae)&&I++)}let me=(_,B)=>{let fe=_==="L"?i:l;for(let Ae of fe)if(Ae.toks.some(pe=>pe.kind==="close"&&pe.k.el===B.el))return Ae.bs;for(let Ae=0;Ae<e.length;Ae++)if(e[Ae].kind==="close"&&e[Ae].k.el===B.el)return Ae;return-1};m.forEach((_,B)=>{if(!(!f(_)||_.side==="both"))for(let fe of _.toks){if(fe.kind!=="open")continue;let Ae=me(_.side,fe.k);if(Ae<=_.bs)continue;let pe=new Uint8Array(Ae-_.bs),Qe=[];if(m.forEach((qe,rt)=>{if(!(qe.side===_.side||d(qe))&&qe.bs<Ae&&qe.be>_.bs){Qe.push(rt);for(let lt=Math.max(qe.bs,_.bs);lt<Math.min(qe.be,Ae);lt++)pe[lt-_.bs]=1}}),Qe.length&&pe.every(qe=>qe===1))for(let qe of Qe)H(B,qe)}});let Q=!0;for(;Q;){Q=!1;let _=new Map;m.forEach((B,fe)=>{let Ae=$(fe),pe=_.get(Ae)||{bs:B.bs,be:B.be,L:!1,R:!1};pe.bs=Math.min(pe.bs,B.bs),pe.be=Math.max(pe.be,B.be),B.side!=="R"&&(pe.L=!0),B.side!=="L"&&(pe.R=!0),_.set(Ae,pe)}),m.forEach((B,fe)=>{for(let[Ae,pe]of _){if($(fe)===$(Ae)||!(pe.L&&pe.R))continue;let Qe=B.bs<pe.be&&B.be>pe.bs,qe=d(B)&&h(B)&&(B.bs===pe.be||B.bs===pe.bs);(Qe||qe)&&H(fe,Ae)&&(Q=!0)}})}let L=new Map;m.forEach((_,B)=>{let fe=$(B);L.has(fe)||L.set(fe,[]),L.get(fe).push(_)});let Ee=[];for(let _ of L.values()){let B=_.some(Ae=>Ae.side==="L"),fe=_.some(Ae=>Ae.side==="R");if(B&&fe){let Ae=Math.min(..._.map(rt=>rt.bs)),pe=Math.max(..._.map(rt=>rt.be)),Qe=_.filter(rt=>rt.side!=="R").map(rt=>rt.l).sort((rt,lt)=>rt.bs-lt.bs),qe=_.filter(rt=>rt.side!=="L").map(rt=>rt.r).sort((rt,lt)=>rt.bs-lt.bs);Ee.push({bs:Ae,be:pe,kind:"conflict",localHunks:Qe,remoteHunks:qe})}else for(let Ae of _)Ee.push({bs:Ae.bs,be:Ae.be,kind:Ae.side,u:Ae})}let xe=(_,B)=>{let fe=_==="L"?i:l;for(let Ae of fe)if(Ae.toks.some(pe=>pe.kind==="close"&&pe.k.el===B.el))return Ae.bs+.5;for(let Ae=0;Ae<e.length;Ae++)if(e[Ae].kind==="close"&&e[Ae].k.el===B.el)return Ae;return 1/0},se=(_,B)=>{let fe=_==="L"?i:l;for(let Ae of fe)if(Ae.toks.some(pe=>pe.kind==="open"&&pe.k.el===B.el))return Ae.bs-.5;for(let Ae=0;Ae<e.length;Ae++)if(e[Ae].kind==="open"&&e[Ae].k.el===B.el)return Ae;return-1/0},V=_=>_.kind==="R"?"R":"L",Se=_=>_.kind==="R"?1:0;Ee.sort((_,B)=>{if(_.bs!==B.bs)return _.bs-B.bs;let fe=_.bs===_.be,Ae=B.bs===B.be;if(fe!==Ae)return fe?-1:1;if(fe&&Ae&&_.kind!=="conflict"&&B.kind!=="conflict"){let Qe=_.u.toks,qe=B.u.toks,rt=ee=>ee.length&&ee.every(ce=>ce.kind==="open"),lt=ee=>ee.length&&ee.every(ce=>ce.kind==="close");if(rt(Qe)&&rt(qe)){let ee=Math.max(...Qe.map(ge=>xe(V(_),ge.k))),ce=Math.max(...qe.map(ge=>xe(V(B),ge.k)));if(ee!==ce)return ce-ee}if(lt(Qe)&&lt(qe)){let ee=Math.min(...Qe.map(ge=>se(V(_),ge.k))),ce=Math.min(...qe.map(ge=>se(V(B),ge.k)));return ee!==ce?ce-ee:Se(B)-Se(_)}}let pe=Qe=>Qe.u&&Qe.u.lead?1:0;return pe(B)-pe(_)||Se(_)-Se(B)||_.be-B.be});let ve=[],Me=[],He=0,Ve=_=>{_>He&&(ve.push({bs:He,be:_,toks:e.slice(He,_),source:"base"}),He=_)};for(let _ of Ee){if(Ve(_.bs),_.kind==="conflict"){let B=js(e,_.localHunks,_.bs,_.be),fe=js(e,_.remoteHunks,_.bs,_.be),Ae=r==="local"?B:r==="both"?B.concat(fe):fe,pe=(rt,lt)=>{let ee=0;for(let ce of rt)ce.be<=_.bs&&!lt.includes(ce)&&(ee+=ce.toks.length-(ce.be-ce.bs));return ee},Qe=_.bs+pe(i,_.localHunks),qe=_.bs+pe(l,_.remoteHunks);Me.push({bs:_.bs,be:_.be,ls:Qe,le:Qe+B.length,rs:qe,re:qe+fe.length,ms:0,me:0,base:e.slice(_.bs,_.be),local:B,remote:fe,resolved:Ae}),ve.push({bs:_.bs,be:_.be,toks:Ae,source:"conflict",localHunks:_.localHunks,localToks:B,keepsLocal:r!=="remote"})}else ve.push({bs:_.bs,be:_.be,toks:_.u.toks,source:_.kind==="R"?"remote":"local",localHunks:_.kind==="R"?[]:[_.u.l]});He=Math.max(He,_.be)}Ve(e.length);let it=0,le=0;for(let _ of ve)_.source==="conflict"&&(Me[le].ms=it,Me[le].me=it+_.toks.length,le++),it+=_.toks.length;let yt=new Map(a.map(_=>[_.bi,_.tok])),et=new Map(u.map(_=>[_.bi,_.tok])),Oe=[];for(let _ of ve){_.source==="base"&&(_.toks=_.toks.map((B,fe)=>{let Ae=_.bs+fe,pe=yt.get(Ae),Qe=et.get(Ae),qe=pe&&Qe?r==="remote"?Qe:pe:pe||Qe||B;return qe===B?B:{...qe,cosmetic:!0}}));for(let B of _.toks)Oe.push({...B,src:_.source})}return{tokens:Oe,segments:ve,conflicts:Me,localHunks:i,remoteHunks:l,collapsedDelta:y,samePoint:I,mapLocalOffset:Lu(e,i,ve)}}function js(e,t,n,r){let o=[],s=n;for(let i of t)o=o.concat(e.slice(s,i.bs),i.toks),s=i.be;return o.concat(e.slice(s,r))}var Ls=e=>e.reduce((t,n)=>t+n.len,0);function Lu(e,t,n){let r=new Int32Array(e.length+1);for(let i=0;i<e.length;i++)r[i+1]=r[i]+e[i].len;let o=t.map(i=>({bs:r[i.bs],be:r[i.be],text:i.toks.map(l=>l.raw).join(""),ref:i})),s=n.map(i=>({bs:r[i.bs],be:r[i.be],len:Ls(i.toks),source:i.source,localHunks:i.localHunks||[],localLen:i.localToks?Ls(i.localToks):0,keepsLocal:i.keepsLocal,ref:i}));return i=>{let l=null,a=null,u=0,d=0,h=0;for(let p of o){let b=p.bs-h;if(i<=d+b){l=h+(i-d);break}if(d+=b,h=p.bs,i<=d+p.text.length){a=p,u=i-d,l=p.bs;break}d+=p.text.length,h=p.be}l===null&&(l=h+(i-d));let f=0;for(let p of s){if(!a&&l<=p.bs)return f;if(!(a?p.localHunks.includes(a.ref):l<p.be)){f+=p.len;continue}if(p.source==="base")return f+(l-p.bs);if(p.source==="remote")return f+p.len;if(p.source==="local")return f+Math.min(u,p.len);if(!p.keepsLocal||!a)return f+p.len;let v=p.localHunks.indexOf(a.ref),m=Ls(js(e,p.localHunks.slice(0,v),p.ref.bs,a.ref.bs));return f+Math.min(m+u,p.localLen)}return f}}function Kr(e,t,n,r="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:g=>Math.min(g,t.length),granularity:"word"};let o=Oo(e,t,n),s=rr(e,o),i=rr(t,o),l=rr(n,o),a=s.length<=2e4&&i.length<=2e4&&l.length<=2e4?rl(s,i,l,r):null,u="word",d=s;if(!a){let g=y=>y.split(/(?<=\n)/).map(I=>({k:I,raw:I,len:I.length}));d=g(e),a=rl(d,g(t),g(n),r),u="line"}let h=g=>g.map(y=>y.raw).join(""),f=g=>{let y=[0];for(let I of g)y.push(y[y.length-1]+I.len);return y},p=f(d),b=null,v=null,m=null;if(a.conflicts.length){let g=y=>y.split(/(?<=\n)/).map(I=>({k:I,raw:I,len:I.length}));b=f(u==="line"?g(t):i),v=f(u==="line"?g(n):l),m=f(a.tokens)}return{text:h(a.tokens),conflicts:a.conflicts.map(g=>({bs:p[g.bs],be:p[g.be],ls:b[g.ls],le:b[g.le],rs:v[g.rs],re:v[g.re],ms:m[g.ms],me:m[g.me],base:h(g.base),local:h(g.local),remote:h(g.remote),resolved:h(g.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:u}}function Gr(e,t,n=4e3){if(e===t)return[];let r=Oo(e,t),o=rr(e,r),s=rr(t,r),i=br(o,s,n),l=[0];for(let a of o)l.push(l[l.length-1]+a.len);return i.hunks.map(a=>({bs:l[a.bs],be:l[a.be],text:a.toks.map(u=>u.raw).join("")}))}var xr="\uFFFC";var Iu={caret:0},Mn=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),cl=new Set(["BR","WBR","IMG"]),Hs=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function or(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||cl.has(e.tagName))return!0;if(!Mn.has(e.tagName))return!Hs.has(e.tagName);if(t.remoteWins&&t.remoteWins(e))return!1;let n=t.inlineCache&&t.inlineCache.get(e);if(n!==void 0)return n;let r=!0;for(let o of e.childNodes)if(!or(o,t)){r=!1;break}return t.inlineCache&&t.inlineCache.set(e,r),r}function ju(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function In(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},r=(o,s)=>{for(let i of o){if(i.nodeType===3){let h=i.nodeValue;if(!h)continue;n.nodes.push({node:i,s:n.text.length,e:n.text.length+h.length}),n.text+=h;for(let f=0;f<h.length;f++)n.stackAt.push(s);continue}if(i.nodeType!==1)continue;if(t.ignored&&t.ignored(i)){n.pins.push({el:i,i:n.text.length});continue}if(t.skip&&t.skip.has(i))continue;let l=t.via&&t.via(i)||i;l!==i&&(n.via||(n.via=new Map)).set(l,i);let a=i.tagName;if(t.blocks&&t.blocks.has(i)){n.text.length&&n.text[n.text.length-1]!==Et&&(n.stackAt.push(s),n.text+=Et);let h={el:i,tag:a,from:n.text.length,to:-1,depth:s.length,block:!0};n.marks.push(h);let f=s.concat([h]);r(l.childNodes,f),n.stackAt.push(f),n.text+=Et,h.to=n.text.length;continue}let u=Mn.has(a)&&ju(l);if(cl.has(a)||!Mn.has(a)||t.remoteWins&&t.remoteWins(i)||t.atomize&&t.atomize(i)||u){n.atoms.push({i:n.text.length,el:i,key:u?a+":empty":a,stack:s}),n.stackAt.push(s),n.text+=xr;continue}let d={el:i,tag:a,from:n.text.length,to:-1,depth:s.length};n.marks.push(d),r(l.childNodes,s.concat([d])),d.to=n.text.length}};if(r(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&No(n).trim()===""){let o=n.atoms[0];n.placeholder=o.el,n.text=n.text.slice(0,o.i)+n.text.slice(o.i+1),n.stackAt.splice(o.i,1);for(let s of n.nodes)s.s>o.i&&(s.s--,s.e--);n.atoms=[]}return n.atomAt=new Map(n.atoms.map(o=>[o.i,o])),n}function Pu(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Du(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,"&quot;")}"`;return t+">"}function yr(e,t,n){let r="",o=[];for(let s=t;s<n;s++){let i=e.stackAt[s],l=0;for(;l<o.length&&l<i.length&&o[l]===i[l];)l++;for(;o.length>l;)r+=`</${o.pop().tag.toLowerCase()}>`;for(;o.length<i.length;){let u=i[o.length];r+=Du(u.el),o.push(u)}let a=e.atomAt.get(s);r+=a?a.el.outerHTML:e.text[s]===Et?"":Pu(e.text[s])}for(;o.length;)r+=`</${o.pop().tag.toLowerCase()}>`;return r}function Fu(e,t){let n=[...e.el.attributes].filter(r=>!t(e.el,r.name)).map(r=>r.name+"="+r.value).sort().join("");return e.tag+"|"+n}function ul(e,t){let n=[...e.attributes].filter(r=>!t(e,r.name)).map(r=>r.name+"="+r.value).sort().join("");return e.tagName+"|"+n+"|"+e.innerHTML}function ol(e,t=()=>!1){let n=new Map,r=s=>{let i=n.get(s);return i===void 0&&(i="{"+s.map(l=>Fu(l,t)).sort().join(",")+"}",n.set(s,i)),i},o="";for(let s=0;s<e.text.length;s++){let i=e.atomAt.get(s);o+=(i?"["+ul(i.el,t)+"]":e.text[s])+r(e.stackAt[s])}return e.text.length===0&&e.placeholder&&(o+="[br]"),o}function kr(e,t,n,r=o=>o.key){let o=[],s=e.text,i=0,l=a=>{if(a<=i)return;let u=s.slice(i,a);if(n)for(let d of u.split(/(?<=\n)/))o.push({k:d,raw:d,len:d.length});else for(let d of rr(u,t))o.push(d)};for(let a of e.atoms)l(a.i),o.push({k:"\0"+r(a),raw:xr,len:1,atom:!0}),i=a.i+1;return l(s.length),o}function No(e){if(!e.atoms.length)return e.text;let t="",n=0;for(let r of e.atoms)t+=e.text.slice(n,r.i),n=r.i+1;return t+e.text.slice(n)}var Bs=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n].len;return t};function sl(e,t,n,r){let o=Bs(t),s=Bs(n),i=[],l=0,a=0;for(let d of r.hunks){a+=d.bs-l;let h=a+d.toks.length;i.push({bs:o[d.bs],be:o[d.be],ss:s[a],se:s[h],text:e.text.slice(s[a],s[h]),toks:d.toks,lead:!!d.lead}),a=h,l=d.be}let u=new Map;for(let d of r.cosmetic)u.set(d.bi,d.tok.raw);return{hunks:i,respell:u}}function il(e,t,n){let r=i=>i===Et||/\s/.test(i),o=i=>i.replace(/[\u001E\s]/g,""),s=[];for(let i of e){let l=t.slice(i.bs,i.be),a=n.slice(i.ss,i.se);if(!l.includes(Et)&&!a.includes(Et)||l.includes(xr)||a.includes(xr)||o(l)!==o(a)){s.push(i);continue}let u=0,d=0;for(;;){let h=u,f=d;for(;h<l.length&&r(l[h]);)h++;for(;f<a.length&&r(a[f]);)f++;let p=u,b=d;for(;p<h&&b<f&&l[p]===a[b];)p++,b++;let v=h,m=f;for(;v>p&&m>b&&l[v-1]===a[m-1];)v--,m--;if(v>p||m>b){let g=a.slice(b,m);s.push({bs:i.bs+p,be:i.bs+v,ss:i.ss+b,se:i.ss+m,text:g,toks:[...g].map(y=>({k:y,raw:y,len:1})),lead:i.lead})}if(h>=l.length)break;u=h+1,d=f+1}}return s}function ll(e,t,n){let r=new Int32Array(t+1).fill(-1),o=new Int32Array(n+1).fill(-1),s=0,i=0,l=a=>{for(;s<a;)r[s]=i,o[i]=s,s++,i++};for(let a of e)l(a.bs),s=a.be,i=a.se;return l(t),r[t]=i,o[i]=t,{bTo:r,toB:o}}function al(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function $s(e){let{out:t,policy:n="remote",L:r,R:o}=e,s=e.provenance||new WeakMap,i=e.textMappers||new WeakMap,l=e.conflicts||[],a=e.decisions||[],u=l.length,d=e.conflict||(c=>l.push(c)),h={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},f=[],p=!!(r&&r.reverse&&r.map&&o&&o.reverse&&o.map),b={base:null,local:null,remote:null};if(p&&e.moveIn){let c=_e=>Ge=>_e.some(Te=>Te===Ge||Te.nodeType===1&&Te.contains(Ge)),S=c(e.local),R=c(e.remote),M=c(e.base),F=new Set,J=_e=>{if(!Mn.has(_e.tagName))return;let Ge=r.map.get(_e),Te=o.map.get(_e);(Ge&&!S(Ge)||Te&&!R(Te))&&F.add(_e);for(let Ie of _e.children)J(Ie)};for(let _e of e.base)_e.nodeType===1&&J(_e);let be=_e=>Ge=>{if(!Mn.has(Ge.tagName))return!1;let Te=_e.reverse.get(Ge);return!!Te&&(F.has(Te)||!M(Te))};F.size&&(b.base=_e=>F.has(_e)),b.local=be(r),b.remote=be(o)}let v={base:new Set,local:new Set,remote:new Set};if(p&&e.moveIn){let c=M=>F=>M.some(J=>J===F||J.nodeType===1&&J.contains(F)),S=c(e.local),R=c(e.remote);for(let M of In(e.base,{...e,atomize:b.base}).atoms){let F=r.map.get(M.el),J=o.map.get(M.el),be=!!F&&!S(F),_e=!!J&&!R(J);!be&&!_e||(v.base.add(M.el),F&&!be&&v.local.add(F),J&&!_e&&v.remote.add(J),S(M.el)&&v.local.add(M.el),R(M.el)&&v.remote.add(M.el))}}let m=In(e.base,{...e,atomize:b.base,skip:v.base}),g=In(e.local,{...e,atomize:b.local,skip:v.local}),y=In(e.remote,{...e,atomize:b.remote,skip:v.remote}),I=new Map(m.atoms.map(c=>[c.el,c])),Y={},$=c=>v[c].size?(Y[c]||(Y[c]=In(e[c],{...e,atomize:b[c]})),Y[c]):null,H=(c,S,R)=>{S.namespaceURI?c.setAttributeNS(S.namespaceURI,S.name,R):c.setAttribute(S.name,R)},z=(c,S,R,M)=>{if(!S&&(!R||!M)){for(let J of(R||M).attributes)H(c,J,J.value);return}let F=new Map;for(let J of[S,R,M])if(J)for(let be of J.attributes)F.set(be.name,be);for(let[J,be]of F){let _e=S?S.getAttribute(J):null,Ge=R?R.getAttribute(J):_e,Te=M?M.getAttribute(J):_e,Ie;Ge===Te?Ie=Ge:Ge===_e?(Ie=Te,a.push({kind:"attr",el:c,name:J,source:"remote"})):Te===_e?(Ie=Ge,a.push({kind:"attr",el:c,name:J,source:"local"})):(Ie=n==="local"?Ge:Te,d({kind:"attr",el:c,name:J,base:_e,local:Ge,remote:Te,resolved:Ie},{el:c,sample:be}),a.push({kind:"attr",el:c,name:J,source:"both"})),Ie!=null&&H(c,be,Ie)}},ae=(c,S,R,M)=>c&&e.mergeAttrs?e.mergeAttrs(c,S,R,M):z(M,c,S,R),me=e.mergeElement||((c,S,R)=>{let M=t.createElement(c.tagName);ae(c,S,R,M);let F=S||c,J=R||c,be=n==="local"?F.isEqualNode(c)?J:F:J.isEqualNode(c)?F:J;for(let _e of be.childNodes)M.appendChild(t.importNode(_e,!0));return s.set(M,{base:c,local:S,remote:R}),M}),Q=e.cloneUnit||((c,S)=>{let R=t.importNode(c,!0);return s.set(R,{base:null,local:S==="local"?c:null,remote:S==="remote"?c:null}),R}),L=e.atomKey||(c=>ul(c,()=>!1)),Ee=(c,S)=>{let R=new Map;for(let M of c.atoms)if(e.remoteWins&&e.remoteWins(M.el)&&Mn.has(M.el.tagName))R.set(M,"w"+M.el.tagName+"#"+(M.el.id||""));else if(!p)R.set(M,M.key);else if(c===m)R.set(M,"="+L(M.el));else{let F=S.reverse.get(M.el),J=F?I.get(F):null;J?R.set(M,"="+L(J.el)):F?R.set(M,"m"+L(M.el)):R.set(M,"="+L(M.el))}return M=>R.get(M)},xe=Ee(m,null),se=Ee(g,r),V=Ee(y,o),Se=Oo(No(m),No(g),No(y)),ve=kr(m,Se,!1,xe),Me=kr(g,Se,!1,se),He=kr(y,Se,!1,V),Ve=ve.length>2e4||Me.length>2e4||He.length>2e4;Ve&&(ve=kr(m,Se,!0,xe),Me=kr(g,Se,!0,se),He=kr(y,Se,!0,V));let it=Ds(br(ve,Me),br(ve,He),ve),le=sl(g,ve,Me,{hunks:it.lh,cosmetic:it.cosL}),yt=sl(y,ve,He,{hunks:it.rh,cosmetic:it.cosR});le.hunks=il(le.hunks,m.text,g.text),yt.hunks=il(yt.hunks,m.text,y.text);let et=ll(le.hunks,m.text.length,g.text.length),Oe=ll(yt.hunks,m.text.length,y.text.length),_=m.text.length,B=c=>new Map(c.atoms.map(S=>[S.el,S])),fe=B(g),Ae=B(y),pe=(c,S,R)=>{let M=new Set;if(!p)return M;for(let F of c.atoms){let J=I.get(S.reverse.get(F.el));J&&R.bTo[J.i]<0&&M.add(J)}return M},Qe=pe(g,r,et),qe=pe(y,o,Oe),rt=c=>!or(c,{...e,remoteWins:null}),lt=new Set;if(p)for(let c of m.atoms){if(!rt(c.el))continue;let S=r.map.get(c.el)||null,R=o.map.get(c.el)||null,M=S&&!R?S:R&&!S?R:null;M&&(fe.has(M)||Ae.has(M))&&!M.isEqualNode(c.el)&&lt.add(c)}let ee=1,ce=(c,S)=>({id:ee++,tag:c,base:null,local:null,remote:null,rank:S}),ge=new Map,Ue=[];for(let c of m.marks){let S=ce(c.tag,c.depth);S.block=!!c.block,S.base=c.el,S.baseMark=c,ge.set(c.el,S),Ue.push(S)}let ke=(c,S)=>{let R=-1,M=-1;for(let F=c.from;F<c.to;F++){let J=S[F];J>=0&&(R<0&&(R=J),M=J+1)}return R<0?null:[R,M]},Je=(c,S,R,M)=>{for(let F of c.marks){let J=R?R.reverse.get(F.el):null;J&&R.identical.has(J)&&R.pairIdenticalChildren&&R.pairIdenticalChildren(J);let be=J?ge.get(J):null;if(be&&be[S]&&(be=null),!be){let _e=ke(F,M),Ge=0;if(_e)for(let Te of Ue){if(Te.tag!==F.tag||Te[S]||!!Te.block!=!!F.block)continue;let Ie=Math.min(_e[1],Te.baseMark.to)-Math.max(_e[0],Te.baseMark.from);(Ie>Ge||Ie===Ge&&Ie>0&&Math.abs(Te.rank-F.depth)<Math.abs(be.rank-F.depth))&&(be=Te,Ge=Ie)}}be||(be=ce(F.tag,F.depth),be.block=!!F.block,be.new=S),be[S]=F.el,be[S+"Mark"]=F,ge.set(F.el,be)}};Je(g,"local",r,et.toB),Je(y,"remote",o,Oe.toB);let kt=c=>c.merged||c,ht=c=>{let S=new Set;for(let R of c)R.block||S.add(ge.get(R.el));return S},wt=new Map,ze=c=>{let S=wt.get(c);return S||(S=ht(c),wt.set(c,S)),S},Ot=(c,S)=>{let R=[],M=null;for(let F=0;F<_;F++){let J=S[F];if(J<0){M&&R.push(M),M=null;continue}let be=ze(m.stackAt[F]),_e=ze(c.stackAt[J]),Ge=new Set,Te=new Set;for(let Ie of _e)be.has(Ie)||Ge.add(Ie);for(let Ie of be)_e.has(Ie)||Te.add(Ie);if(!Ge.size&&!Te.size){M&&R.push(M),M=null;continue}if(M&&al(M.added,Ge)&&al(M.removed,Te)){M.be=F+1;continue}M&&R.push(M),M={bs:F,be:F+1,added:Ge,removed:Te}}return M&&R.push(M),R},T=Ot(g,et.bTo),re=Ot(y,Oe.bTo),oe=c=>c.be>c.bs?[c.bs,c.be-1]:[c.bs-1,c.bs],de=(c,S)=>{if(_===0)return null;let[R,M]=oe(c);for(let F of S){if(F.be<=R)continue;if(F.bs>M)break;let J=F.bs<=R&&M<F.be;return J&&c.text===""&&F.bs===c.bs&&F.be===c.be?"straddle":J?F:c.be>c.bs?"straddle":null}return null},ie=c=>c.bs===c.be,he=(c,S)=>{let R=!1;for(let M=c.bs;M<c.be;M++){let F=m.text[M];if(F===Et)R=!0;else if(!/\s/.test(F))return!1}for(let M=c.ss;M<c.se;M++){let F=S.text[M];if(F===Et)R=!0;else if(!/\s/.test(F))return!1}return R},w=(c,S)=>c.bs<S.be&&S.bs<c.be,E=(c,S)=>c.bs<=S.be&&S.bs<=c.be&&ie(c)!==ie(S),P=(c,S)=>m.text.slice(c.bs,c.be).includes(Et)||S.text.slice(c.ss,c.se).includes(Et),x=c=>{if(ie(c))return!1;let S=c.bs,R=c.be;for(;S>0&&/\s/.test(m.text[S-1]);)S--;for(;R<m.text.length&&/\s/.test(m.text[R]);)R++;return(S===0||m.text[S-1]===Et)&&(R===m.text.length||m.text[R]===Et)},A=(c,S)=>!P(c,S)&&!x(c),j=(c,S)=>w(c,S)||E(c,S)&&!(he(c,g)&&A(S,y))&&!(he(S,y)&&A(c,g)),G=(c,S)=>{if(c.bs!==S.bs||c.be!==S.be||c.toks.length!==S.toks.length)return!1;let R=c.ss,M=S.ss;for(let F=0;F<c.toks.length;F++){let J=c.toks[F],be=S.toks[F];if(J.k!==be.k||J.atom&&!g.atomAt.get(R).el.isEqualNode(y.atomAt.get(M).el))return!1;R+=J.len,M+=be.len}return!0},q=(c,S,R,M)=>{for(let F of m.atoms){if(F.i<c.bs||F.i>=c.be||M.has(F)||lt.has(F))continue;let J=S.bTo[F.i],be=J>=0?R.atomAt.get(J):null;if(be&&!be.el.isEqualNode(F.el))return!0}return!1},X=[],O=le.hunks,C=yt.hunks,Z=0,ye=0,Re=0,k=0,N=0,D=c=>{c>Re&&(X.push({src:"base",from:Re,to:c,dL:k,dR:N}),Re=c)};for(;Z<O.length||ye<C.length;){let c=O[Z],S=C[ye],R=!!c&&(!S||c.bs<S.bs||c.bs===S.bs&&c.be<=S.be&&!S.lead);if(c&&S&&c.bs===S.bs&&ie(c)&&ie(S)){let qt=he(c,g),Wr=he(S,y);qt!==Wr&&(R=Wr)}let M=R?c:S,F=R?S:c,J=!!F&&G(c,S),be=!!F&&(R?!!O[Z+1]&&G(O[Z+1],S):!!C[ye+1]&&G(c,C[ye+1])),_e=!!F&&!J&&!be&&(_===0||j(c,S)),Ge=_e,Te=de(M,R?re:T);if(Te==="straddle"&&(Ge=!0),!Ge&&M.be>M.bs&&(Ge=q(M,R?Oe:et,R?y:g,R?Qe:qe)),!Ge&&J){D(M.bs),X.push({src:"both",lfrom:c.ss,rfrom:S.ss,len:M.text.length}),Re=M.be,k+=M.text.length-(M.be-M.bs),N+=M.text.length-(M.be-M.bs),Z++,ye++;continue}if(!Ge){D(M.bs),X.push({src:R?"local":"remote",from:M.ss,to:M.se,inherit:Te&&Te!=="straddle"?Te:null}),Re=M.be,R?(k+=M.text.length-(M.be-M.bs),Z++):(N+=M.text.length-(M.be-M.bs),ye++);continue}let Ie=M.bs,gt=M.be,nt=Z,dt=ye,$t=qt=>qt.bs<gt&&qt.be>Ie||ie(qt)&&(qt.bs===Ie||qt.bs===gt);R?nt++:dt++,_e&&(Ie=Math.min(Ie,F.bs),gt=Math.max(gt,F.be),R?dt++:nt++);let Lt=!0;for(;Lt;){for(Lt=!1;nt<O.length&&$t(O[nt]);)Ie=Math.min(Ie,O[nt].bs),gt=Math.max(gt,O[nt].be),nt++,Lt=!0;for(;dt<C.length&&$t(C[dt]);)Ie=Math.min(Ie,C[dt].bs),gt=Math.max(gt,C[dt].be),dt++,Lt=!0}let hn=Ie+k,on=Ie+N,vn=gt-Ie,Tn=gt-Ie;for(let qt=Z;qt<nt;qt++)vn+=O[qt].text.length-(O[qt].be-O[qt].bs);for(let qt=ye;qt<dt;qt++)Tn+=C[qt].text.length-(C[qt].be-C[qt].bs);let Rn=hn+vn,Ln=on+Tn;D(Ie);let Yt={kind:"text",node:e.node||null,base:yr(m,Ie,gt),local:yr(g,hn,Rn),remote:yr(y,on,Ln),resolved:null,range:null,bs:Ie,be:gt,lss:hn,lse:Rn,rss:on,rse:Ln};Yt.resolved=n==="local"?Yt.local:n==="remote"?Yt.remote:Yt.local+Yt.remote,n!=="remote"&&X.push({src:"local",from:hn,to:Rn,conflict:Yt}),n!=="local"&&X.push({src:"remote",from:on,to:Ln,conflict:Yt});let So={site:"inline",fb:m,fl:g,fr:y,scope:e.scope||null,synthetic:!!e.synthetic,full:$,merged:h};f.push(So),d(Yt,So),Re=gt,k+=vn-(gt-Ie),N+=Tn-(gt-Ie),Z=nt,ye=dt}D(_);let U=m.text,W=[];if(le.respell.size||yt.respell.size){let c=Bs(ve),S=[];for(let R=0;R<ve.length;R++){let M=ve[R].raw,F=le.respell.get(R)??M,J=yt.respell.get(R)??M;(F!==M||J!==M)&&W.push([c[R],F!==M&&J!==M?"both":F!==M?"local":"remote"]),S.push(F===J?F:F===M?J:J===M||n==="local"?F:J)}U=S.join("")}let K="",te=[],ue=[],Ce=[],Pe=[];for(let c of X){let S=K.length;if(c.src==="base"){for(let R=c.from;R<c.to;R++)te.push(R),ue.push(R+c.dL),Ce.push(R+c.dR),Pe.push(c);K+=U.slice(c.from,c.to)}else if(c.src==="both"){for(let R=0;R<c.len;R++)te.push(-1),ue.push(c.lfrom+R),Ce.push(c.rfrom+R),Pe.push(c);K+=g.text.slice(c.lfrom,c.lfrom+c.len)}else{let R=c.src==="local"?g:y;for(let M=c.from;M<c.to;M++)te.push(-1),ue.push(c.src==="local"?M:-1),Ce.push(c.src==="remote"?M:-1),Pe.push(c);K+=R.text.slice(c.from,c.to)}c.ms=S,c.me=K.length,c.conflict&&(c.conflict.range||(c.conflict.range=[S,S]),c.conflict.range[1]=K.length)}let Le=K.length,at=new Int32Array(_+1).fill(-1),Be=new Int32Array(g.text.length+1).fill(-1),It=new Int32Array(y.text.length+1).fill(-1);for(let c=0;c<Le;c++)te[c]>=0&&(at[te[c]]=c),ue[c]>=0&&(Be[ue[c]]=c),Ce[c]>=0&&(It[Ce[c]]=c);let We=(c,S)=>{let R=-1,M=-1;for(let F=c.from;F<c.to;F++){let J=S[F];J>=0&&(R<0&&(R=J),M=J+1)}return R<0?null:[R,M]},St=[],mt=[];for(let c of new Set(ge.values()))c.new==="local"?St.push(c):c.new==="remote"&&mt.push(c);let tn=(c,S)=>{c.remote=S.remote,c.remoteMark=S.remoteMark,c.new="both",S.merged=c,ge.set(S.remote,c)};if(St.length&&mt.length){let c=e.idOf;for(let S of St){let R=c?c.local(S.local):null;if(!R)continue;let M=mt.find(F=>!F.merged&&F.tag===S.tag&&!!F.block==!!S.block&&c.remote(F.remote)===R);M&&tn(S,M)}for(let S of St){if(S.remote)continue;let R=We(S.localMark,Be);if(R)for(let M of mt){if(M.merged||M.tag!==S.tag||!!M.block!=!!S.block)continue;let F=We(M.remoteMark,It);if(F&&Math.min(R[1],F[1])-Math.max(R[0],F[0])>0){tn(S,M);break}}}}wt.clear();let Bt=c=>{for(let S of c)if(S.block)return kt(ge.get(S.el));return null},Qt=m.marks.some(c=>c.block)||g.marks.some(c=>c.block)||y.marks.some(c=>c.block),Dt=new Array(Le).fill(null),xt=new Set;if(Qt){let c=(Te,Ie,gt)=>{let nt=new Set([Te,Ie,gt]);nt.delete(null);let dt=[];for(let Lt of nt){let hn=Lt===Te,on=Lt===Ie,vn=Lt===gt;(on===vn?on:on===hn?vn:on)&&dt.push(Lt)}if(dt.length<=1)return dt[0]||null;let $t=n==="local"?Ie:gt;return dt.includes($t)?$t:dt[0]},S=(Te,Ie)=>Ie>=0?Bt(Te.stackAt[Ie]):null,R=new Map;for(let Te=0;Te<Le;Te++){if(K[Te]!==Et)continue;let Ie=te[Te]>=0?S(m,te[Te]):null,gt=S(g,ue[Te]),nt=S(y,Ce[Te]);R.set(Te,[Ie,te[Te]>=0?c(Ie,gt,nt):gt||nt])}let M=new Set([...R.values()].map(Te=>Te[1])),F=Te=>Te!==Et&&Te!==xr&&!/\s/.test(Te),J=(Te,Ie)=>{let gt=Te;for(;gt<Ie&&!F(K[gt]);)gt++;return gt<Ie&&te[gt]>=0?S(m,te[gt]):null},be=new Map,_e=0;for(let Te=0;Te<Le;Te++){if(K[Te]!==Et)continue;let[Ie,gt]=R.get(Te),nt=J(_e,Te),dt=gt,$t=be.get(dt)===dt&&nt===dt;dt&&be.has(dt)&&!$t&&Ie&&!be.has(Ie)&&!M.has(Ie)&&(dt=Ie),dt&&!be.has(dt)&&be.set(dt,nt);for(let Lt=_e;Lt<=Te;Lt++)Dt[Lt]=dt;_e=Te+1}let Ge=Te=>{for(let Ie=0;Ie<Te.text.length;Ie++)if(F(Te.text[Ie])&&!S(Te,Ie))return!0;return!1};if(!Ge(m)&&!Ge(g)&&!Ge(y)){let Te=[],Ie=0;for(let nt=0;nt<Le;nt++)(K[nt]===Et||nt===Le-1)&&(Te.push([Ie,nt]),Ie=nt+1);let gt=new Set(Dt);for(let nt=0;nt<Te.length;nt++){let[dt,$t]=Te[nt];if(Dt[$t])continue;let Lt=dt;for(;Lt<=$t&&!F(K[Lt]);)Lt++;if(Lt>$t)continue;let hn=S(m,te[Lt]),on=S(g,ue[Lt]),vn=S(y,Ce[Lt]),Tn=c(hn,on,vn)||on||vn||hn;if(Tn&&!gt.has(Tn)){gt.add(Tn);for(let Yt=dt;Yt<=$t;Yt++)Dt[Yt]=Tn;continue}let Rn=nt>0&&Dt[Te[nt-1][1]],Ln=nt+1<Te.length&&Dt[Te[nt+1][1]];if(Rn)xt.add(Te[nt-1][1]);else if(Ln&&K[$t]===Et)xt.add($t);else continue;for(let Yt=dt;Yt<=$t;Yt++)Dt[Yt]=Rn||Ln}}}let Rt=new Map,Mt=c=>{let S=Rt.get(c);if(S)return S;S=[1/0,-1/0];for(let[R,M]of[[c.baseMark,at],[c.localMark,Be],[c.remoteMark,It]]){let F=R&&We(R,M);F&&(S[0]=Math.min(S[0],F[0]),S[1]=Math.max(S[1],F[1]))}return Rt.set(c,S),S},zt=(c,S,R)=>{let M=-1,F=-1;for(let J=0;J<c.length;J++){let be=ge.get(c[J].el);be===S&&(M=J),be===R&&(F=J)}return M>=0&&F>=0?M-F:0},an=(c,S)=>[...c].sort((R,M)=>{for(let be of S){let _e=zt(be,R,M);if(_e)return _e}let F=Mt(R),J=Mt(M);return F[0]-J[0]||J[1]-F[1]||R.rank-M.rank||R.id-M.id}),yn=new Map,qn=new Map,Bn=c=>{let S=te[c],R=ue[c],M=Ce[c],F=Pe[c];if(S>=0){let nt=m.stackAt[S],dt=g.stackAt[R],$t=y.stackAt[M],Lt=yn.get(nt);Lt||yn.set(nt,Lt=new Map);let hn=Lt.get(dt);hn||Lt.set(dt,hn=new Map);let on=hn.get($t);if(on)return on;let vn=ze(nt),Tn=ze(dt),Rn=ze($t),Ln=new Set;for(let Yt of new Set([...vn,...Tn,...Rn])){let So=vn.has(Yt),qt=Tn.has(Yt),Wr=Rn.has(Yt);(qt===Wr?qt:qt===So?Wr:qt)&&Ln.add(Yt)}return on=an(Ln,[dt,$t,nt]),hn.set($t,on),on}if(F.src==="both"){let nt=g.stackAt[R],dt=y.stackAt[M];return an(new Set([...ze(nt),...ze(dt)]),[nt,dt])}let be=(F.src==="local"?g:y).stackAt[F.src==="local"?R:M];if(!F.inherit)return an(ze(be),[be]);let _e=qn.get(F);_e||qn.set(F,_e=new Map);let Ge=_e.get(be);if(Ge)return Ge;let Te=new Set(ze(be));for(let nt of F.inherit.added)Te.add(kt(nt));for(let nt of F.inherit.removed)Te.delete(kt(nt));let Ie=F.src==="local"?y:g,gt=(F.src==="local"?Oe.bTo:et.bTo)[F.inherit.bs];return Ge=an(Te,[be,Ie.stackAt[gt]]),_e.set(be,Ge),Ge},Nn=new Int32Array(g.text.length+1);Nn[g.text.length]=Le;for(let c=g.text.length-1;c>=0;c--)Nn[c]=Be[c]>=0?Be[c]:Nn[c+1];Iu.caret+=g.text.length;let mn=c=>c<=0?0:(c>g.text.length&&(c=g.text.length),Be[c-1]>=0?Be[c-1]+1:Nn[c]),nn=[],ne=[],De=null,Ne=[],tt="",pt=-1,$e=c=>{De?De.appendChild(c):nn.push(c)},Ye=c=>{if(!tt)return;let S=t.createTextNode(tt);$e(S),ne.push({node:S,ms:pt,me:c,local:[],u:Ne.length?Ne[Ne.length-1].u:null}),tt=""},ct=new Set,Ke=new Map,ft=new Set,cn=c=>{let S=t.createElement(c.tag);if(c.block&&Kt.add(S),!Ke.has(c)){Ke.set(c,S),ae(c.base,c.local,c.remote,S),s.set(S,{base:c.base,local:c.local,remote:c.remote});let M=(be,_e)=>p&&c[_e]&&be.reverse.get(c[_e])?_e:null,F=!c.base&&(M(r,"local")||M(o,"remote"));if(F){let be=F==="local"?r.reverse.get(c.local):o.reverse.get(c.remote),_e=s.get(S);_e.local=_e.local||r.map.get(be)||null,_e.remote=_e.remote||o.map.get(be)||null,a.push({kind:"move",el:S,source:F})}else c.base||a.push({kind:"insert",el:S,source:c.local&&c.remote?"both":c.local?"local":"remote"});let J=s.get(S);J.local&&(ft.has(J.local)?J.local=null:ft.add(J.local))}else{let M=Ke.get(c);for(let F of M.attributes)F.name!=="id"&&F.name!=="data-id"&&H(S,F,F.value);s.set(S,{base:null,local:null,remote:null})}$e(S),Ne.push({u:c,el:S}),De=S},tr=new Set,xn=new Map;for(let c of g.pins){let S=mn(c.i);xn.has(S)||xn.set(S,[]),xn.get(S).push(c)}let pn=c=>{let S=xn.get(c);if(S){Ye(c);for(let R of S){let M=R.el.namespaceURI&&R.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(R.el.namespaceURI,R.el.tagName):t.createElement(R.el.tagName);s.set(M,{base:null,local:R.el,remote:null,pinned:!0}),tr.add(M),$e(M)}}},nr=m.atoms.length||g.atoms.length||y.atoms.length,ot=c=>{if(!nr)return null;let S=te[c]>=0?m.atomAt.get(te[c]):null,R=ue[c]>=0?g.atomAt.get(ue[c]):null,M=Ce[c]>=0?y.atomAt.get(Ce[c]):null;return S||R||M?{ab:S,al:R,ar:M}:null},vt=(c,S,R,M)=>{if(!c||!p)return null;let F=I.get(S.reverse.get(c.el))||null;return!F||F===M||(M?F.el.isEqualNode(M.el):R.bTo[F.i]>=0)?null:F},we=(c,S)=>{if(!c||!p||!e.moveIn)return null;let R=S.reverse.get(c.el);return R&&!I.has(R)?R:null},je=(c,S)=>{let R=new Map;for(let M of c.atoms)R.set(S(M),(R.get(S(M))||0)+1);return R},Xe=je(m,xe),ut=je(g,se),Ze=je(y,V),Nt=c=>{let S=xe(c);return Xe.get(S)===1&&(ut.get(S)||0)<=1&&(Ze.get(S)||0)<=1},_t=new Map,Ht=new Set,en=new Set,dn=new Set;for(let c=0;c<Le;c++){let S=ot(c);if(!S)continue;let{ab:R,al:M,ar:F}=S,J=vt(F,o,Oe,R),be=vt(M,r,et,R),_e=R,Ge=null;if(J?(_e=J,Ge="remote"):be&&(_e=be,Ge="local"),_e){Ht.has(_e)?_t.set(c,{dup:_e.el}):(Ht.add(_e),_t.set(c,{bk:_e,from:Ge,al:M,ar:F}));continue}let Te=we(F,o),Ie=we(M,r),gt=Te||Ie;if(gt){en.has(gt)?_t.set(c,{dup:gt}):(en.add(gt),_t.set(c,{moveIn:gt,side:Te?"remote":"local",sideEl:Te?F.el:M.el}));continue}let nt=($t,Lt)=>$t&&p&&I.get(Lt.reverse.get($t.el))||null,dt=nt(F,o)||nt(M,r);if(dt&&(dn.add(dt),Pe[c].conflict&&Nt(dt))){if(Ht.has(dt)){_t.set(c,{dup:dt.el});continue}Ht.add(dt)}_t.set(c,{al:M,ar:F})}let jt=new Map,Hn=(c,S)=>{if(c[S]>=0)return c[S];for(let R=S-1;R>=0;R--)if(c[R]>=0)return c[R]+1;return 0};if(p)for(let c of m.atoms){if(Ht.has(c)||dn.has(c))continue;let S=r.map.get(c.el)||null,R=o.map.get(c.el)||null,M=S&&fe.get(S),F=R&&Ae.get(R);if(S&&!M||R&&!F)continue;let J=!(M&&F)&&lt.has(c);if(!J&&!(M&&F&&Nt(c)))continue;let be=n==="local"?[[M,Be],[F,It]]:[[F,It],[M,Be]],[_e,Ge]=be.find(([Ie])=>Ie),Te=Hn(Ge,_e.i);jt.has(Te)||jt.set(Te,[]),jt.get(Te).push({a:c,lt:S,rt:R,edited:J}),Ht.add(c)}if(p&&e.moveIn){let c=[[g,r,Be,"local"],[y,o,It,"remote"]];n!=="local"&&c.reverse();for(let[S,R,M,F]of c)for(let J of S.atoms){let be=we(J,R);if(!be||en.has(be))continue;en.add(be);let _e=Hn(M,J.i);jt.has(_e)||jt.set(_e,[]),jt.get(_e).push({move:be,side:F,sideEl:J.el})}}let Wt=c=>{let S=jt.get(c);if(S){if(Ye(c),S.some(R=>rt(R.move?R.sideEl:R.a.el)))for(;Ne.length;)Ne.pop(),De=Ne.length?Ne[Ne.length-1].el:null;for(let{a:R,lt:M,rt:F,edited:J,move:be,side:_e,sideEl:Ge}of S){if(be){let Ie=e.moveIn(be,_e,Ge);Ie&&$e(Ie);continue}ct.add(R);let Te=me(R.el,M,F);J&&(d({kind:"structure",el:Te,detail:"edit-beats-delete",base:R.el},{subject:R.el,deleted:M?"remote":"local"}),a.push({kind:"insert",el:Te,source:M?"local":"remote"})),$e(Te)}}},Kt=new Set,gn=l.length>u;for(let c=0;c<Le;c++){let S=ot(c),M=!!S&&rt((S.ab||S.al||S.ar).el)?[]:Dt[c]?[Dt[c],...Bn(c)]:Bn(c),F=0;for(;F<Ne.length&&F<M.length&&Ne[F].u===M[F];)F++;if(F<Ne.length)for(Ye(c);Ne.length>F;)Ne.pop(),De=Ne.length?Ne[Ne.length-1].el:null;if(pn(c),Wt(c),M.length>Ne.length)for(Ye(c);Ne.length<M.length;)cn(M[Ne.length]);if(K[c]===Et){if(xt.has(c))continue;Ye(c);let J=Ne.length;for(;J>0&&!Ne[J-1].u.block;)J--;if(J>0)for(gn&&h.breakOut.set(c,Ne[J-1].el);Ne.length>=J;)Ne.pop(),De=Ne.length?Ne[Ne.length-1].el:null;continue}if(S){Ye(c);let J=_t.get(c),be;if(J.dup){d({kind:"structure",el:null,detail:"both-moved",base:J.dup},{subject:J.dup});continue}if(J.moveIn){if(be=e.moveIn(J.moveIn,J.side,J.sideEl),!be)continue}else if(J.bk){let _e=J.bk;if(ct.add(_e),_e===S.ab)be=me(_e.el,J.al.el,J.ar.el);else{let Ge=r.map.get(_e.el)||null,Te=o.map.get(_e.el)||null;be=me(_e.el,Ge,Te),(!Ge||!Te)&&d({kind:"structure",el:null,detail:"move-beats-delete",base:_e.el},{subject:_e.el,deleted:Ge?"remote":"local"}),a.push({kind:"move",el:be,source:J.from})}}else J.al?(be=Q(J.al.el,"local"),J.ar&&(s.get(be).remote=J.ar.el),a.push({kind:"insert",el:be,source:J.ar?"both":"local"})):(be=Q(J.ar.el,"remote"),a.push({kind:"insert",el:be,source:"remote"}));gn&&h.atomOut.set(c,be),$e(be);continue}tt||(pt=c),tt+=K[c]}if(Ye(Le),(xn.has(Le)||jt.has(Le))&&(Ne.length=0,De=null,pn(Le),Wt(Le)),Le===0&&(g.placeholder||y.placeholder||m.placeholder)){let c=t.createElement("br");s.set(c,{base:m.placeholder,local:g.placeholder,remote:y.placeholder}),nn.push(c)}let An=0,wo=c=>{for(;An>0&&ne[An-1].me>=c;)An--;for(;An<ne.length&&ne[An].me<c;)An++;let S=ne[An];if(!S)return ne[ne.length-1]||null;let R=ne[An+1];return S.me===c&&R&&R.ms===c?R:S},mr=new Map,Vr={},Fe=(c,S,R)=>{let M=wo(c)||(R?Vr:null);if(!M)return;let F=mr.get(M)||{l:!1,r:!1};S!=="remote"&&(F.l=!0),S!=="local"&&(F.r=!0),mr.set(M,F)},At=c=>{if(c.conflict)return!0;let S=c.src==="local"?g.text:c.src==="remote"?y.text:"";for(let R=c.from;R<c.to;R++)if(S[R]!==xr&&S[R]!==Et)return!0;return!1};for(let c of X)c.src!=="base"&&Fe(c.ms,c.conflict?"both":c.src,At(c));for(let[c,S]of W)at[c]>=0&&Fe(at[c],S);for(let c of ne.length?ne:[Vr]){let S=mr.get(c);S&&a.push({kind:"text",node:c.node||null,source:S.l&&S.r?"both":S.l?"local":"remote"})}for(let c of Ue){if(Ke.has(c))continue;let S=!c.local&&!(p&&r.map.get(c.base)),R=!c.remote&&!(p&&o.map.get(c.base));!S&&!R||a.push({kind:"remove",source:S&&R?"both":S?"local":"remote",base:c.base})}let Pt=(c,S,R)=>{if(S<=c)return!1;for(let M=c;M<S;M++)if(R[M]>=0)return!1;return!0};for(let c of Ue)for(let S of["local","remote"]){let R=c[S+"Mark"],M=c.baseMark;if(!R)continue;let F=S==="local"?et:Oe;if(!Pt(M.from,M.to,F.bTo)||!Pt(R.from,R.to,F.toB))continue;let J=(S==="local"?O:C).find(be=>be.ss<=R.from&&R.from<be.se);J&&(J.be<=M.from||J.bs>=M.to)&&a.push({kind:"move",el:Ke.get(c)||null,source:S})}let Ct=c=>{let S=ge.get(c.node.parentNode);return S?kt(S):null};for(let c of g.nodes){let S=-1;for(let M=c.s;M<c.e;M++)if(Be[M]>=0){S=Be[M];break}let R;if(S>=0)R=wo(S);else{let M=mn(c.s),F=Ct(c);R=ne.find(J=>J.u===F&&J.me>=M)||ne.filter(J=>J.u===F).pop()}R&&R.local.push(c)}let Tt=new Map,Sn=ne[ne.length-1]||null,Gt=0;for(let c of g.nodes){let S=null;for(let R=c.s;R<=c.e;R++){let M=mn(R);for(;Gt>0&&ne[Gt-1].me>=M;)Gt--;for(;Gt<ne.length&&ne[Gt].me<M;)Gt++;let F=be=>be&&M>=be.ms&&M<=be.me&&(M<be.me||R===c.e||be===S),J=F(ne[Gt])?ne[Gt]:F(ne[Gt+1])?ne[Gt+1]:ne[Gt]||Sn;if(!J)break;if(S===J){let be=Tt.get(J);be[be.length-1].to=R-c.s;continue}S=J,Tt.has(J)||Tt.set(J,[]),Tt.get(J).push({node:c.node,from:R-c.s,to:R-c.s,flatStart:c.s})}}for(let c of ne){let S=c.local,R=!1;for(let be of S)for(let _e=be.s;_e<be.e&&!R;_e++)(Be[_e]<c.ms||Be[_e]>=c.me)&&(R=!0);s.set(c.node,{base:null,local:S.map(be=>be.node),remote:null,caret:Tt.get(c)||[],partial:R});let M=c.ms,F=c.me-c.ms,J=be=>{let _e=0,Ge=-1;for(let Te of S){let Ie=Te.e-Te.s;if(be<=_e+Ie){Ge=Te.s+(be-_e);break}_e+=Ie}return Ge<0&&(Ge=S.length?S[S.length-1].e:0),Math.max(0,Math.min(mn(Ge)-M,F))};J.flat=be=>Math.max(0,Math.min(mn(be)-M,F)),i.set(c.node,J)}function $n(){if(!g.text.includes(Et))return[{flatLocal:g.text,localNodes:g.nodes,textNodes:ne,lToM:Be,mapLocal:mn}];let c=[],S=0,R=0;for(let M=0;M<=g.text.length;M++){if(M<g.text.length&&g.text[M]!==Et)continue;let F=S,J=M;if(J>F){let be=[];for(;R<g.nodes.length&&g.nodes[R].e<=F;)R++;for(let _e=R;_e<g.nodes.length&&g.nodes[_e].s<J;_e++){let Ge=g.nodes[_e],Te=Math.max(Ge.s,F),Ie=Math.min(Ge.e,J);Te<Ie&&be.push({node:Ge.node,s:Te-F,e:Ie-F})}c.push({flatLocal:g.text.slice(F,J),localNodes:be,textNodes:ne,lToM:Be.subarray?Be.subarray(F,J+1):Be.slice(F,J+1),mapLocal:_e=>mn(F+Math.max(0,Math.min(_e,J-F)))})}S=M+1}return c}let Cn={...e,blocks:Kt,ignored:c=>tr.has(c)||(e.ignored?e.ignored(c):!1)},rn=e.ignoreAttribute||(()=>!1),Ao=ol(In(nn,Cn),rn)!==ol(y,rn);if(f.length){let c=S=>{let R=s.get(S);return R&&R.unchanged?R.remote:null};h.text=K,h.textNodes=ne,h.out=In(nn,{...Cn,via:c})}return{nodes:nn,text:K,textNodes:ne,localDiverged:Ao,mapLocal:mn,conflicts:l.slice(u),granularity:Ve?"line":"word",segments:$n(),localHunks:O,remoteHunks:C,lToM:Be}}var qu="http://www.w3.org/1999/xhtml";function Bu(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function un(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===qu}function Hu(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Co(e,t){let n=e.getAttribute("src"),r=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(n){let o=n;try{let s=new URL(n,t);o=s.origin+s.pathname+s.search}catch{}return"script|src|"+r+"|"+o}return"script|inline|"+r+"|"+Bu(e.textContent.trim())}var $u={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function vr(e,t=[],n=!1){if(!un(e)||e.hasAttribute("src"))return null;let r=[$u,...t];for(let o=0;o<r.length;o++){let s=r[o];if(!s.match(e))continue;if(!Hu(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let i=s.identity(e);return i==null||i===""?null:{key:o+":"+i,raw:i,recognizer:s}}return null}function fl(e,t,n){let r=new Set,o=s=>{un(s)&&!t(s)&&r.add(Co(s,n))};o(e);for(let s of e.querySelectorAll("script"))o(s);return r}function Yr(e,t){let n=t.createElement("div");n.innerHTML="<script><\/script>";let r=n.firstChild;for(let o of e.attributes)r.setAttribute(o.name,o.value);return r.textContent=e.textContent,r}function dl(e,t,n){let r=[],o=[],s=new Map,i=n.trackRecovery?new Set:null,l=Array.from(e.querySelectorAll("script"));un(e)&&l.unshift(e);for(let a of l){if(!un(a)||n.ignored(a)||n.skip.has(a)||t.has(Co(a,n.baseURI)))continue;let u=a.ownerDocument.createElement("script");for(let d of a.attributes)u.setAttribute(d.name,d.value);if(u.textContent=a.textContent,n.beforeNodeAdded(u)===!1){i?.add(a);continue}u.hasAttribute("src")&&o.push(new Promise(d=>{u.addEventListener("load",()=>d()),u.addEventListener("error",()=>d())})),a.replaceWith(u),s.set(a,u),n.afterNodeAdded(u),r.push(u)}return{executed:r,loads:o,swapped:s,vetoed:i}}function Uu(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function zu(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function hl(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Co(e,t);if(n==="LINK"){let r=e.getAttribute("href");return r?"link|"+(e.getAttribute("rel")||"")+"|"+zu(r,t):e.outerHTML}if(n==="META"){for(let r of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(r))return"meta|"+r+"="+e.getAttribute(r);return e.outerHTML}return n==="STYLE"?"style|"+Uu(e.textContent):e.outerHTML}function Us(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
4
- `;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);if(n===-1)return e.length;t=n+2;continue}return t}}function Vu(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var Wu=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Ku=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function zs(e){try{return JSON.parse(e)}catch{return JSON.parse(Gu(e))}}function Gu(e){let t="",n=0,r=(o,s)=>{throw new Error(`Invalid relaxed JSON: ${o} at position ${s}`)};for(;n<e.length&&(n=Us(e,n),!(n>=e.length));){let o=e[n];if("{}[]:".includes(o)){t+=o,n++;continue}if(o===","){let l=Us(e,n+1);if(e[l]==="}"||e[l]==="]"){n++;continue}t+=o,n++;continue}if(o==='"'||o==="'"){let l=n+1;for(;l<e.length&&e[l]!==o;)e[l]==="\\"&&l++,l++;l>=e.length&&r("unterminated string",n);let a=e.slice(n+1,l);o==="'"&&(a=Vu(a)),t+='"'+a+'"',n=l+1;continue}let s=n;for(;s<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[s]);)s++;s===n&&r("unexpected character "+JSON.stringify(o),n);let i=e.slice(n,s);if(i==="true"||i==="false"||i==="null"||Wu.test(i)){t+=i,n=s;continue}if(Ku.test(i)){if(e[Us(e,s)]===":"){t+='"'+i+'"',n=s;continue}r("unquoted value "+JSON.stringify(i),n)}r("invalid token "+JSON.stringify(i),n)}return t}var Ut=Symbol("hyper-morph-json-merge:missing"),ml=["id","_id","uuid","key","slug","code","name"];function wr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Yu(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function Vn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Vn(e[n],t[n]))return!1;return!0}if(wr(e)&&wr(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Xr(t,r)||!Vn(e[r],t[r]))return!1;return!0}return!1}function pl(e,t,n,r){return Vn(t,n)?t:Vn(t,e)?n:Vn(n,e)?t:wr(t)&&wr(n)?Xu(wr(e)?e:{},t,n,r):Array.isArray(t)&&Array.isArray(n)?ef(Array.isArray(e)?e:[],t,n,r):n}function gl(e,t,n,r){return t===Ut&&n===Ut?Ut:t===Ut?e===Ut?n:Vn(n,e)?Ut:n:n===Ut?e===Ut?t:Ut:pl(e,t,n,r)}function Xu(e,t,n,r){let o={},s=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let i of s){let l=gl(Xr(e,i)?e[i]:Ut,Xr(t,i)?t[i]:Ut,Xr(n,i)?n[i]:Ut,r);l!==Ut&&Yu(o,i,l)}return o}function Ju(e){return e===null||typeof e!="object"}function Mo(e){return typeof e+":"+String(e)}function Zu(e,t){for(let n of t){let r=new Set;for(let o of n){if(!Xr(o,e))return!1;let s=o[e];if(typeof s!="string"&&typeof s!="number")return!1;let i=Mo(s);if(r.has(i))return!1;r.add(i)}}return!0}function Qu(e,t,n,r){let o=[e,t,n],s=!0;for(let i of o)for(let l of i)wr(l)||(s=!1);if(s){for(let i of r.keyCandidates)if(Zu(i,o))return{kind:"keyed",field:i};return null}for(let i of o){let l=new Set;for(let a of i){if(!Ju(a))return null;let u=Mo(a);if(l.has(u))return null;l.add(u)}}return{kind:"self"}}function ef(e,t,n,r){let o=Qu(e,t,n,r);if(!o)return n;let s=o.kind==="self"?Mo:p=>Mo(p[o.field]),i=p=>{let b=new Map;for(let v of p)b.set(s(v),v);return b},l=i(e),a=i(t),u=i(n),d=new Map,h=new Set([...l.keys(),...a.keys(),...u.keys()]);for(let p of h){let b=gl(l.has(p)?l.get(p):Ut,a.has(p)?a.get(p):Ut,u.has(p)?u.get(p):Ut,r);b!==Ut&&d.set(p,b)}let f=[];for(let p of n){let b=s(p);d.has(b)&&f.push(b)}for(let p=0;p<t.length;p++){let b=s(t[p]);if(!d.has(b)||f.includes(b))continue;let v=0;for(let m=p-1;m>=0;m--){let g=f.indexOf(s(t[m]));if(g!==-1){v=g+1;break}}f.splice(v,0,b)}return f.map(p=>d.get(p))}function bl(e,t,n,r={}){let o=r.keyCandidates?[...r.keyCandidates,...ml]:ml;return pl(e===void 0?Ut:e,t,n,{keyCandidates:o})}function Vs(e,t,n,r={}){let o=r.parse||zs,s=[],i=(h,f)=>{if(typeof h!="string")return Ut;try{return o(h)}catch(p){return s.push(`${f} side is not valid JSON (${p.message})`),Ut}},l=i(t,"local"),a=i(n,"remote");if(l===Ut)return{text:n,warnings:s};if(a===Ut)return{text:t,warnings:s};let u=i(e,"base"),d=bl(u===Ut?void 0:u,l,a,r);return Vn(d,a)?{text:n,warnings:s}:Vn(d,l)?{text:t,warnings:s}:{text:JSON.stringify(d,null,2),warnings:s}}var kl=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function ir(e){if(!e)return!1;let{startContainer:t,startOffset:n,endContainer:r,endOffset:o}=e;if(!t||!r||!Number.isInteger(n)||!Number.isInteger(o)||n<0||o<0||n>kl(t)||o>kl(r)||t.getRootNode()!==r.getRootNode())return!1;let s=t.ownerDocument.createRange();return s.setStart(t,n),s.setEnd(r,o),s.startContainer===t&&s.startOffset===n}function Wn(e,t,n={}){if(!ir(e))return null;let{startContainer:r,startOffset:o,endContainer:s,endOffset:i}=e;if(r===s&&(r.nodeType===3||r.nodeType===8))return r.nodeValue.slice(o,i);if(r===s&&o===i)return"";let l=new Set;for(let m=r;m;m=m.parentNode)l.add(m);let a=s;for(;!l.has(a);)a=a.parentNode;let u=(m,g)=>{let y=a.ownerDocument.createRange(),I=a.ownerDocument.createRange();return y.setStart(m[0],m[1]),y.collapse(!0),I.setStart(g[0],g[1]),I.collapse(!0),y.compareBoundaryPoints(0,I)},d=(m,g=!1)=>[m.parentNode,Array.prototype.indexOf.call(m.parentNode.childNodes,m)+Number(g)],h=[],f;if(t==="plain"){f="";let m=g=>{if(g.nodeType===3||g.nodeType===8){let y=f.length;f+=g.nodeValue,h.push({s:y,e:f.length,a:[g,0],b:[g,g.nodeValue.length],node:g})}else for(let y of g.childNodes)m(y)};m(a)}else{let m=n.blocks;if(!m){m=new Set;let y=I=>{I!==a&&I.nodeType===1&&Hs.has(I.tagName)&&m.add(I);for(let Y of I.childNodes)y(Y)};y(a)}let g=In(Array.from(a.childNodes),{blocks:m,atomize:y=>!!n.atoms?.has(y),ignored:n.ignored});f=g.text;for(let y of g.nodes)h.push({s:y.s,e:y.e,a:[y.node,0],b:[y.node,y.e-y.s],node:y.node});for(let y of g.atoms)h.push({s:y.i,e:y.i+1,a:d(y.el),b:d(y.el,!0)});for(let y=0;y<g.text.length;y++){if(g.text[y]!==Et)continue;let I=g.marks.find($=>$.block&&$.to===y+1),Y=g.marks.find($=>$.block&&$.from===y+1);if(I)h.push({s:y,e:y+1,a:[I.el,I.el.childNodes.length],b:d(I.el,!0)});else if(Y)h.push({s:y,e:y+1,a:d(Y.el),b:[Y.el,0]});else return null}}h.sort((m,g)=>m.s-g.s);let p=m=>{if(m[0].nodeType===3||m[0].nodeType===8){let y=h.find(I=>I.node===m[0]);return y?y.s+m[1]:null}let g=0;for(let y of h){if(u(m,y.a)<=0)return y.s;if(u(m,y.b)<0)return null;g=y.e}return g},b=p([r,o]),v=p([s,i]);return b!==null&&v!==null&&b<=v?f.slice(b,v):null}function sr(e,t){let n=e;for(let r of t.path)if(n=r==="content"?n?.content:n?.childNodes[r],!n)return null;return[n,t.offset]}function yl(e,t){if(!e||!t)return null;let n=sr(e,t.start),r=sr(e,t.end);return n&&r?{startContainer:n[0],startOffset:n[1],endContainer:r[0],endOffset:r[1]}:null}var xl=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function vl(e,t,n){if(!t)return;let r=new Map,o=new Map,s=l=>{if(!l)return null;if(o.has(l))return o.get(l);let u=l.local.map(d=>sr(t.localRoot,{path:d,offset:0})?.[0]).map(d=>d&&n(d)).filter(Boolean).map(d=>({node:d,parent:d.parentNode,previous:d.previousSibling,next:d.nextSibling,fragment:xl(d)}));return o.set(l,u),u},i=l=>{let a=yl(t.localRoot,l);if(!a)return null;let u=n(a.startContainer),d=n(a.endContainer);if(!u||!d)return null;let h={...a,startContainer:u,endContainer:d};return ir(h)?h:null};for(let l of e){let a=l.recovery;if(r.has(a))continue;let u={subject:s(a.subject),span:null,scope:null,touched:new Set};if(a.text){u.span=i(a.text.local.span),u.scope=i(a.text.local.scope);let d=u.span;if(d){let h=d.startContainer.ownerDocument.createRange();h.setStart(d.startContainer,d.startOffset),h.setEnd(d.endContainer,d.endOffset);let f=p=>{if(h.intersectsNode(p)){u.touched.add(p);for(let b of p.childNodes)f(b)}};f(h.commonAncestorContainer)}}if(a.structure){for(let d of[a.structure.localPlacement])d&&(s(d.parent),d.before.forEach(s),d.after.forEach(s));for(let d of a.structure.localOrder||[])s(d)}r.set(a,u)}t.localState={states:r,refs:o}}function wl(e,t,n,r){let o=n.localState?.states.get(e);if(!o)return!1;let s=l=>{let a=l.node;if(!r(a)||a.parentNode!==l.parent)return!1;let u=d=>Array.prototype.indexOf.call(a.parentNode.childNodes,d);return!(l.previous&&r(l.previous)&&l.previous.parentNode===a.parentNode&&u(l.previous)>=u(a)||l.next&&r(l.next)&&l.next.parentNode===a.parentNode&&u(l.next)<=u(a))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!o.subject.length||!o.subject.every(s))return!1;if(e.text){let l=e.text.local,a=u=>u&&r(u.startContainer)&&r(u.endContainer);return a(o.span)&&a(o.scope)&&Wn(o.scope,e.text.encoding)===l.text&&Wn(o.span,e.text.encoding)===l.text.slice(l.start,l.end)}if(e.attribute){let l=e.attribute,a=o.subject[0].node;return(l.namespaceURI?a.getAttributeNS(l.namespaceURI,l.localName):a.getAttribute(l.qualifiedName))===t.local}let i=e.structure;if(i.localOrder){let l=-1,a=null;for(let u of i.localOrder){let d=n.localState.refs.get(u)?.[0]?.node;if(!d||!r(d)||a&&d.parentNode!==a)return!1;let h=Array.prototype.indexOf.call(d.parentNode.childNodes,d);if(h<=l)return!1;a=d.parentNode,l=h}return!0}return i.localAction==="moved"||o.subject.every(l=>xl(l.node)===l.fragment)}var tf=1,sn=e=>!!e&&e.nodeType===1,Ro=e=>sn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function lr(e,t=null,n=null){let r=new Map,o=new Map,s=d=>{if(!t){t=new WeakMap;let h=[e];for(;h.length;){let f=h.pop();Ro(f)&&(t.set(f.content,f),h.push(f.content));for(let p=f.firstChild;p;p=p.nextSibling)p.nodeType===1&&h.push(p)}}return t.get(d)||null},i=(d,h)=>{let f=o.get(d);if(!f){f=new Map;let p=0;for(let b=d.firstChild;b;b=b.nextSibling)f.set(b,p++);o.set(d,f)}return f.get(h)},l=d=>{if(!d)return null;if(n&&n.has(d))return l(n.get(d));if(d===e)return[];let h=r.get(d);if(h!==void 0)return h;let f=d.parentNode,p=null;if(f&&f.nodeType===11){let b=s(f),v=b?l(b):null;v&&(p=v.concat(["content",i(f,d)]))}else if(f){let b=l(f);b&&(p=b.concat([i(f,d)]))}return r.set(d,p),p};return{root:e,pathOf:l,logicalParent:d=>{let h=d.parentNode;return h&&h.nodeType===11?s(h):h},indexIn:i,containerPath:d=>{if(d.nodeType===11){let f=s(d),p=l(f);return p?p.concat(["content"]):null}let h=l(d);return h&&Ro(d)?h.concat(["content"]):h},ownerOf:s}}var En=e=>Ro(e)?e.content:e;function Al(e){let{L:t,R:n,unitsOf:r,provenance:o,policy:s}=e,i=[];return{note:(d,h)=>{i.push([d,h])},finish:d=>i.length?u(d):null};function u(d){let h={base:lr(e.roots.base),local:lr(e.roots.local),remote:lr(e.roots.remote)},f=w=>w==="local"?t:n,p=(w,E)=>{if(!E)return null;if(w.map.has(E))return w.map.get(E);let P=[],x=sn(E)?h.base.logicalParent(E):E.parent;for(;x&&!w.map.has(x);x=h.base.logicalParent(x))P.push(x);if(!x||!w.identical.has(x))return null;let A=w.map.get(x);for(let j=P.length-1;j>=0&&A;j--)A=En(A).childNodes[h.base.indexIn(P[j].parentNode,P[j])];return A?sn(E)?En(A).childNodes[h.base.indexIn(E.parentNode,E)]||null:r(A)[r(E.parent).indexOf(E)]||null:null},b=new Map,v=new Map,m=new WeakMap,g=0,y=(w,E)=>{let P=b.get(w);P||b.set(w,P=[]),P.push(E)};(function w(E){v.set(E,g++);let P=o.get(E);if(P&&!P.pinned){for(let x of[P.base,P.local,P.remote])if(x)if(Array.isArray(x))for(let A of x)y(A,E);else y(x,E)}if(Ro(E)){m.set(E.content,E);for(let x=E.content.firstChild;x;x=x.nextSibling)w(x)}for(let x=E.firstChild;x;x=x.nextSibling)w(x)})(d);let I=new Map;h.out=lr(d,m,I);let Y={refs:new Map,spans:new Map,anchors:new Map,via:I,outOwners:m,outRoot:d,localRoot:e.roots.local},$=w=>sn(w)?[w]:w.nodes,H=(w,E)=>{let P=h[E].logicalParent(w);if(!P)return null;for(let x of r(P))if(!sn(x)&&x.nodes.includes(w))return x;return null},z=(w,E)=>w==null?null:Array.isArray(w)?w.length?H(w[0],E):null:w,ae=w=>{let E=new Set,P=[];for(let x of w)for(let A of b.get(x)||[])E.has(A)||(E.add(A),P.push(A));return P.sort((x,A)=>v.get(x)-v.get(A))},me=new Map,Q=w=>{let E=w.b||w.l||w.r,P=me.get(E);if(P)return P;let x=[];for(let A of[w.b,w.l,w.r])A&&x.push(...$(A));return P=ae(x),me.set(E,P),P},L=w=>({b:w,l:p(t,w),r:p(n,w)}),Ee=(w,E)=>{let P=f(E).reverse.get(w);if(P)return L(P);for(let x of ae($(w))){let A=o.get(x);if(A&&!A.base&&A.local&&A.remote)return{b:null,l:z(A.local,"local"),r:z(A.remote,"remote")}}return E==="local"?{b:null,l:w,r:null}:{b:null,l:null,r:w}},xe=new Map,se=w=>{let E=o.get(w);if(!E||E.pinned)return null;let P=z(E.base,"base");if(P)return L(P);let x=z(E.local,"local"),A=z(E.remote,"remote");if(x){let j=t.reverse.get(x);if(j)return L(j)}if(A){let j=n.reverse.get(A);if(j)return L(j)}return x||A?{b:null,l:x,r:A}:null},V=w=>(xe.has(w)||xe.set(w,se(w)),xe.get(w)),Se=(w,E)=>sn(w)?h[E].logicalParent(w):w.parent,ve=new Map,Me=new Map,He=(w,E)=>(sn(w)?[h[E].pathOf(w)]:w.nodes.map(P=>h[E].pathOf(P))).filter(Boolean),Ve=w=>{let E=w.b||w.l||w.r,P=w.b?"base":w.l?"local":"remote",x=Me.get(E);if(x)return x;let A=!sn(E),j=He(E,P)[0],G=`${P[0]}:${JSON.stringify(j===void 0?null:j)}${A?":run":""}`,q=ve.get(G);if(q)return Me.set(E,q),q;let X=Q(w);return q={key:G,nodeType:sn(E)?1:E.kind==="comment"?8:3,base:w.b?He(w.b,"base"):[],local:w.l?He(w.l,"local"):[],remote:w.r?He(w.r,"remote"):[],merged:X.map(O=>h.out.pathOf(O)).filter(Boolean),live:[]},ve.set(G,q),Me.set(E,q),Y.refs.set(q,X),q},it={base:new Map,local:new Map,remote:new Map},le=new Map,yt=(w,E)=>{let P=Se(w,E);if(!P||P.nodeType!==1)return null;let x=it[E].get(P);if(!x){let j=r(P),G=q=>Ve(E==="base"?L(q):Ee(q,E));x={parent:G(P),refs:j.map(G),index:new Map(j.map((q,X)=>[q,X]))},it[E].set(P,x)}let A=x.index.get(w)??-1;return{parent:x.parent,before:x.refs.slice(A+1),after:x.refs.slice(0,Math.max(0,A)).reverse()}},et=w=>{let E=w.parentNode;if(!E)return null;let P=le.get(E);if(!P){let A=E.nodeType===11?m.get(E):E,j=A&&A.nodeType===1?V(A):null;if(!j)return null;let G=[],q=[],X=new Map;for(let C of E.childNodes){let Z=V(C),ye=Z&&Ve(Z),Re=G.length,k=G.length-1;ye&&ye!==G[k]&&(G.push(ye),k++);let N={ref:ye,group:k,after:Re};q.push(N),X.set(C,N)}let O=G.length;for(let C=q.length-1;C>=0;C--){let Z=q[C];Z.before=O,Z.ref&&(O=Z.group)}P={parent:Ve(j),refs:G,index:X},le.set(E,P)}let x=P.index.get(w);return{parent:P.parent,before:P.refs.slice(x.before),after:P.refs.slice(0,x.after).reverse()}},Oe=w=>sn(w)?w.outerHTML:w.value,_=w=>sn(w)?"element":w.kind==="comment"?"comment":"text",B=(w,E)=>({path:w,offset:E}),fe=(w,E,P)=>{if(!w)return null;let x=h[P],A=0;if(E){let j=sn(E)?E:E.nodes[E.nodes.length-1];j.parentNode&&(A=x.indexIn(j.parentNode,j)+1)}return B(x.containerPath(w),A)},Ae=(w,E)=>{let P=Se(w,"base"),x=P?p(f(E),P):null;if(!sn(x))return null;let A=r(P),j=null;for(let G=A.indexOf(w)-1;G>=0&&!j;G--){let q=p(f(E),A[G]);q&&Se(q,E)===x&&(j=q)}return fe(x,j,E)},pe=(w,E,P,x)=>{let A=h[x],j=0;for(let G=0;G<w.nodes.length;G++){let q=w.nodes[G],X=q.nodeValue.length,O=G===w.nodes.length-1;if((P==="start"?E<j+X:E<=j+X)||O)return B(A.pathOf(q),Math.max(0,Math.min(E-j,X)));j+=X}return null},Qe=(w,E)=>{let P=h[E],x=w.firstChild,A=w.lastChild;return x&&x.nodeType===3&&A.nodeType===3?{start:B(P.pathOf(x),0),end:B(P.pathOf(A),A.nodeValue.length)}:{start:B(P.pathOf(w),0),end:B(P.pathOf(w),w.childNodes.length)}},qe=(w,E,P)=>{for(let G of w.nodes)if(P==="start"?G.s<=E&&E<G.e:G.s<E&&E<=G.e)return{kind:"text",node:G.node,offset:E-G.s};let x=P==="start"?E:E-1,A=()=>{for(let G of w.nodes)if(G.s===E||G.e===E)return{kind:"text",node:G.node,offset:E-G.s};return null},j=w.atomAt.get(x);if(j)return{kind:P==="start"?"before":"after",node:j.el};if(w.text[x]===Et){let G=w.marks.find(X=>X.block&&X.to===x+1);if(G)return P==="start"?{kind:"end",node:G.el}:{kind:"after",node:G.el};let q=w.marks.find(X=>X.block&&X.from===x+1);if(q)return P==="start"?{kind:"before",node:q.el}:{kind:"startOf",node:q.el}}return A()},rt=(w,E)=>qe(w,E,"end")||qe(w,E,"start"),lt=(w,E)=>{switch(E.kind){case"text":return B(w.pathOf(E.node),E.offset);case"end":return B(w.containerPath(E.node),En(E.node).childNodes.length);case"startOf":return B(w.containerPath(E.node),0);default:{let P=E.node.parentNode;return B(w.containerPath(P),w.indexIn(P,E.node)+(E.kind==="after"?1:0))}}},ee=(w,E,P,x,A)=>{let j=qe(w,E,P);return j?lt(h[x],j):A()},ce=(w,E,P,x)=>{let A=w.textNodes.map(O=>({s:O.ms,e:O.me,start:{kind:"text",node:O.node,offset:0},end:{kind:"text",node:O.node,offset:O.me-O.ms}}));for(let[O,C]of w.atomOut)A.push({s:O,e:O+1,start:{kind:"before",node:C},end:{kind:"after",node:C}});for(let[O,C]of w.breakOut)A.push({s:O,e:O+1,start:{kind:"end",node:C},end:{kind:"after",node:C}});for(let O of A)if(O.start.kind==="text"&&O.s<E&&E<O.e)return{kind:"text",node:O.start.node,offset:E-O.s};if(P!=="empty"){let O=A.find(C=>P==="start"?C.s===E:C.e===E);if(O)return P==="start"?O.start:O.end}let j=A.find(O=>O.e===E);if(j)return j.end;let G=A.find(O=>O.s===E);if(G)return G.start;let q=null,X=null;for(let O of A)O.e<=E&&(!q||O.e>q.e)&&(q=O),O.s>=E&&(!X||O.s<X.s)&&(X=O);return q?q.end:X?X.start:x()},ge=(w,E)=>{if(!E)return null;if(E.kind==="text"){let A=w.nodes.find(j=>j.node===E.node);return A?A.s+Math.min(E.offset,A.e-A.s):null}let P=w.atoms.find(A=>A.el===E.node);if(P)return E.kind==="after"?P.i+1:P.i;let x=w.marks.find(A=>A.el===E.node);return x?E.kind==="before"&&x.block&&w.text[x.from-1]===Et&&!w.marks.some(A=>A.block&&A.to===x.from)?x.from-1:E.kind==="startOf"||E.kind==="before"?x.from:E.kind==="end"&&x.block?x.to-1:x.to:null},Ue=(w,E,P,x)=>{for(let q of w.nodes)if(P==="start"?q.s<=E&&E<q.e:q.s<E&&E<=q.e)return{kind:"text",node:q.node,offset:E-q.s};let A=P==="start"?E:E-1;if(!w.atomAt.has(A)&&w.text[A]!==Et){for(let q of w.nodes)if(q.s===E||q.e===E)return{kind:"text",node:q.node,offset:E-q.s}}let j=w.atomAt.get(A);if(j)return{kind:P==="start"?"before":"after",node:j.el};if(w.text[A]===Et){let q=w.marks.find(O=>O.block&&O.to===A+1);if(q)return P==="start"?{kind:"end",node:q.el}:{kind:"after",node:q.el};let X=w.marks.find(O=>O.block&&O.from===A+1);if(X)return P==="start"?{kind:"before",node:X.el}:{kind:"startOf",node:X.el}}let G=w.marks.find(q=>q.block&&q.from===E);return G?{kind:"startOf",node:G.el}:x?{kind:P==="start"?"startOf":"end",node:x}:null},ke=w=>{if(!w)return null;if(w.kind==="wholeStart"||w.kind==="wholeEnd"){let E=Je(w.node);return w.kind==="wholeStart"?E.start:E.end}return lt(h.out,w)},Je=w=>{let E=w.firstChild,P=w.lastChild;return E&&E.nodeType===3&&P.nodeType===3?{start:B(h.out.pathOf(E),0),end:B(h.out.pathOf(P),P.nodeValue.length)}:{start:B(h.out.pathOf(w),0),end:B(h.out.pathOf(w),w.childNodes.length)}},kt=w=>{let E=Se(w,"base"),P=E?Q(L(E))[0]:null;if(!P)return null;let x=En(P),A=r(E);for(let j=A.indexOf(w)-1;j>=0;j--){let G=Q(L(A[j])).filter(q=>q.parentNode===x);if(G.length)return{kind:"after",node:G[G.length-1]}}return{kind:"startOf",node:P}},ht=(w,E,P,x,A,j)=>({text:w,start:E,end:P,fragment:x,span:A,scope:j}),wt=(w,E,P,x,A)=>ht(w,E,P,w.slice(E,P),x,A),ze=(w,E,P,x,A)=>(Y.spans.set(w,{start:E,end:P,scopeStart:x,scopeEnd:A}),w),Ot=new Map,T=new Map,re=(w,E,P)=>{let x=`text:${w.key}:${E}:${P}`,A=T.get(x)||0;return T.set(x,A+1),`${x}:${A}`},oe=(w,E)=>{let P,x,A,j="plain",G,q,X,O,C,Z=(k,N,D,U,W)=>{if(!k){let K=Ae(W,U);return wt("",0,0,{start:K,end:K},{start:K,end:K})}return wt(k.value,N,D,{start:pe(k,N,N===D?"end":"start",U),end:pe(k,D,"end",U)},{start:pe(k,0,"start",U),end:pe(k,k.value.length,"end",U)})};if(E.site==="run"){let{bRun:k,lRun:N,rRun:D,node:U,c:W}=E;P=L(k),x=W.bs,A=W.be,G=Z(k,W.bs,W.be,"base",k),q=Z(N,W.ls,W.le,"local",k),X=Z(D,W.rs,W.re,"remote",k);let K=U?U.nodeValue:"",te=ue=>U?{kind:"text",node:U,offset:ue}:kt(k);O=ze(wt(K,W.ms,W.me,{start:ke(te(W.ms)),end:ke(te(W.me))},{start:ke(te(0)),end:ke(te(K.length))}),te(W.ms),te(W.me),te(0),te(K.length)),C=U||(kt(k)||{}).node||null}else if(E.site==="whole"){let k=E.el,N=o.get(k);P=L(N.base),x=0,A=w.base.length;let D=(W,K,te)=>{let ue=Qe(K,te);return wt(W,0,W.length,ue,ue)};G=D(w.base,N.base,"base"),q=D(w.local,N.local,"local"),X=D(w.remote,N.remote,"remote");let U=Je(k);O=ze(wt(w.resolved,0,w.resolved.length,U,U),{kind:"wholeStart",node:k},{kind:"wholeEnd",node:k},{kind:"wholeStart",node:k},{kind:"wholeEnd",node:k}),C=k}else if(E.site==="comment"){let{bRun:k,lRun:N,rRun:D,node:U}=E;P=L(k),x=0,A=w.base.length;let W=(Ce,Pe)=>{if(!Ce){let Be=Ae(k,Pe);return wt("",0,0,{start:Be,end:Be},{start:Be,end:Be})}let Le=Ce.nodes[0],at={start:B(h[Pe].pathOf(Le),0),end:B(h[Pe].pathOf(Le),Ce.value.length)};return wt(Ce.value,0,Ce.value.length,at,at)};G=W(k,"base"),q=W(N,"local"),X=W(D,"remote");let K=w.resolved,te=Ce=>U?{kind:"text",node:U,offset:Ce}:kt(k),ue={start:ke(te(0)),end:ke(te(K.length))};O=ze(wt(K,0,K.length,ue,ue),te(0),te(K.length),te(0),te(K.length)),C=U||(kt(k)||{}).node||null}else{let{fb:k,fl:N,fr:D,scope:U}=E,W=E.merged;j="html",P=U.base?L(U.base):Ee(U.local,"local"),x=w.bs,A=w.be;let K=xt=>{let Rt=U[xt];for(let Mt=U.at-1;Mt>=0;Mt--){let zt=U.units[Mt],an=xt==="base"?zt:p(f(xt),zt);if(an&&Se(an,xt)===Rt)return an}return null},te=xt=>()=>fe(U[xt],K(xt),xt),ue=(xt,Rt,Mt,zt,an)=>{let yn=$e=>$e?lt(h[an],$e):te(an)(),qn=Rt===Mt?rt(xt,Rt):qe(xt,Rt,"start"),Bn=Rt===Mt?rt(xt,Rt):qe(xt,Mt,"end"),Nn=yn(qn),mn={start:Nn,end:Rt===Mt?Nn:yn(Bn)},nn=E.full?E.full(an):null;if(!nn)return ht(xt.text,Rt,Mt,zt,mn,{start:yn(qe(xt,0,"start")),end:yn(qe(xt,xt.text.length,"end"))});let ne=qn?ge(nn,qn):null,De=Bn?ge(nn,Bn):null,Ne=ne===null?0:ne,tt=Math.max(Ne,De===null?nn.text.length:De),pt=yn(qe(nn,0,"start"));return ht(nn.text,Ne,tt,yr(nn,Ne,tt),mn,{start:pt,end:nn.text.length?yn(qe(nn,nn.text.length,"end")):pt})};G=E.synthetic?null:ue(k,w.bs,w.be,w.base,"base"),q=ue(N,w.lss,w.lse,w.local,"local"),X=ue(D,w.rss,w.rse,w.remote,"remote");let[Ce,Pe]=w.range||[0,0],Le=W.out,at=()=>{let xt=En(W.node);for(let Rt=U.at-1;Rt>=0;Rt--){let Mt=Q(L(U.units[Rt])).filter(zt=>zt.parentNode===xt);if(Mt.length)return{kind:"after",node:Mt[Mt.length-1]}}for(let Rt=U.at;Rt<U.units.length;Rt++){let Mt=Q(L(U.units[Rt])).filter(zt=>zt.parentNode===xt);if(Mt.length)return{kind:"before",node:Mt[0]}}return{kind:"startOf",node:W.node}};if(Le.via)for(let[xt,Rt]of Le.via)I.set(xt,Rt);let Be=ce(W,Ce,Ce===Pe?"empty":"start",at),It=Ce===Pe?Be:ce(W,Pe,"end",at),We=Le.text.length?Ue(Le,0,"start",W.node):at(),St=Le.text.length?Ue(Le,Le.text.length,"end",W.node):We,mt=ge(Le,Be),tn=ge(Le,It),Bt=mt===null?0:mt,Qt=Math.max(Bt,tn===null?Le.text.length:tn);O=ze(ht(Le.text,Bt,Qt,yr(Le,Bt,Qt),{start:ke(Be),end:ke(It)},{start:ke(We),end:ke(St)}),Be,It,We,St);let Dt=Y.spans.get(O);if(Dt.flat=Le,!Le.text.length){let xt=ke(We),Rt=sr(d,xt),Mt=Rt[0],zt=Rt[1];Dt.empty={parent:Mt.nodeType===11?m.get(Mt):Mt,previous:Mt.childNodes[zt-1]||null,next:Mt.childNodes[zt]||null}}C=Be?Be.node:W.node}let ye=Ve(P),Re=(E.site==="whole"||E.site==="comment"||s!=="both")&&w.resolved!==w.local;return{key:E.site==="comment"&&Ot.get(P.b||P.l||P.r)||re(ye,x,A),subject:ye,localLost:Re,anchor:C,text:{encoding:j,base:G,local:q,remote:X,merged:O,liveSpan:null,liveScope:null}}},de=(w,E)=>{let P=V(E.el),x=Ve(P),A=E.sample;return{key:`attr:${x.key}:${A.namespaceURI||""}:${A.localName}`,subject:x,localLost:w.resolved!==w.local,anchor:E.el,attribute:{namespaceURI:A.namespaceURI||null,localName:A.localName,qualifiedName:A.name}}},ie=(w,E)=>{let P=w.detail,x=E.unit||L(E.subject),A=Ve(x),j=Y.refs.get(A),G=x.l?yt(x.l,"local"):null,q=x.r?yt(x.r,"remote"):null,X=j.length?et(j[0]):null,O,C,Z,ye=null,Re=null,k=E.deleted;switch(P){case"both-reordered":{O=C="reordered";let N=new Set(E.rKept),D=E.lKept.filter(ue=>N.has(ue)&&Q(L(ue)).length),U=ue=>v.get(Q(L(ue))[0]);ye=D.map(ue=>Ve(L(ue))),Re=D.slice().sort((ue,Ce)=>U(ue)-U(Ce)).map(ue=>Ve(L(ue)));let W=ue=>!sn(ue)&&ue.kind!=="comment"&&ue.nodes.every(Ce=>!/[^\t\n\f\r ]/.test(Ce.data)),K=D.filter(ue=>!W(ue)),te=K.slice().sort((ue,Ce)=>U(ue)-U(Ce));Z=K.some((ue,Ce)=>ue!==te[Ce]);break}case"both-moved":O=C="moved",Z=!G||!j.some(N=>{let D=N===j[0]?X:et(N);return D&&D.parent===G.parent});break;case"edit-beats-delete":O=k==="local"?"deleted":"edited",C=k==="remote"?"deleted":"edited",Z=k==="local";break;case"move-beats-delete":O=k==="local"?"deleted":"moved",C=k==="remote"?"deleted":"moved",Z=k==="local";break;default:O=C="inserted",Z=E.localLost}return{key:`structure:${A.key}:${P}`,subject:A,localLost:Z,anchor:j[0]||null,structure:{localAction:O,remoteAction:C,localPlacement:G,remotePlacement:q,mergedPlacement:X,localOrder:ye,mergedOrder:Re,localFragment:P==="both-reordered"||!x.l?null:Oe(x.l),fragmentKind:_(x.b||x.l||x.r)}}};for(let[w,E]of i){if(w.kind!=="structure")continue;let P=E.unit||L(E.subject),x=P.b||P.l||P.r;!sn(x)&&x.kind==="comment"&&Ot.set(x,`structure:${Ve(P).key}:${w.detail}`)}let he=new Map;for(let[w,E]of i){if(w.kind==="structure"){let j=Ve(E.unit||L(E.subject)),G=`structure:${j.key}:${w.detail}`,q=he.get(G);if(q&&q.structure){w.recovery=q;let X=Y.refs.get(j);w.el==null&&X.length&&(w.el=sn(X[0])?X[0]:h.out.logicalParent(X[0]));continue}}let P=w.kind==="text"?oe(w,E):w.kind==="attr"?de(w,E):ie(w,E),x=he.get(P.key);x||(x={version:tf,key:P.key,localLost:P.localLost,subject:P.subject,applied:!1,unavailable:null},he.set(P.key,x),Y.anchors.set(x,P.anchor)),P.text&&(x.text=P.text),P.attribute&&(x.attribute=P.attribute),P.structure&&(x.structure=P.structure),P.text&&(x.localLost=P.localLost),w.recovery=x;let A=Y.refs.get(P.subject);w.kind==="structure"&&w.el==null&&A.length&&(w.el=sn(A[0])?A[0]:h.out.logicalParent(A[0])),w.kind==="text"&&w.node==null&&A.length&&P.subject.nodeType===8&&(w.node=A[0])}return Y}}function Sl(e,t,n){if(!t)return;let{lookup:r,vetoed:o,vetoedAttrs:s,liveAttr:i}=n,l=n.ignored||(()=>!1),a=lr(n.liveRoot),u=se=>!!se&&a.containerPath(se)!==null,d=se=>{let V=se.parentNode;return V&&V.nodeType===11?t.outOwners.get(V)||null:V},h=se=>{for(let V=se;V;V=d(V))if(t.via.has(V)&&(V=t.via.get(V)),o.has(V)||n.vetoedLive?.has(g(V)))return!0;return!1},f=se=>Array.from(En(se).children).filter(V=>!l(V)),p=(se,V)=>f(se)[f(V.parentNode).indexOf(V)],b=(se,V)=>{let Se=null,ve=null,Me=0;for(let le=V.previousSibling;le;le=le.previousSibling){if(le.nodeType===1&&!l(le)){Se=le;break}le.nodeType===3&&(Me+=le.nodeValue.length)}for(let le=V.nextSibling;le&&!ve;le=le.nextSibling)le.nodeType===1&&!l(le)&&(ve=le);let He=Se?p(se,Se):null,Ve=ve?p(se,ve):null;if(Se&&!He||ve&&!Ve)return null;let it=[];for(let le=He?He.nextSibling:En(se).firstChild;le&&le!==Ve;le=le.nextSibling)le.nodeType===3&&it.push(le);return it.length?{nodes:it,lead:Me}:null},v=se=>{let V=[],Se=se;for(;Se&&!t.via.has(Se);Se=Se.parentNode)V.push(Se);if(!Se||!V.length)return null;let ve=g(t.via.get(Se));for(let Ve=V.length-1;Ve>0&&ve;Ve--)ve=p(ve,V[Ve]);if(!ve)return null;let Me=V[0];if(Me.nodeType===3)return b(ve,Me);let He=Me.nodeType===1?p(ve,Me):null;return He?{nodes:[He],lead:0}:null},m=se=>{let V=r(se),Se=V?{nodes:Array.isArray(V)?V:[V],lead:0}:t.via.size?v(se):null;if(!Se)return null;let ve=Se.nodes.filter(u);return ve.length?{nodes:ve,lead:Se.lead}:null},g=se=>{let V=m(se);return V?V.nodes[0]:null},y=se=>{if(!se)return null;if(se.kind==="text"){let Me=m(se.node);if(!Me)return null;let He=Me.nodes,Ve=se.offset+Me.lead,it=0;for(let le=0;le<He.length;le++){let yt=He[le].nodeValue.length;if(Ve<=it+yt||le===He.length-1)return Ve>=it&&Ve<=it+yt?[He[le],Ve-it]:null;it+=yt}return null}let V=g(se.node);if(!V)return null;if(se.kind==="end")return[En(V),En(V).childNodes.length];if(se.kind==="startOf")return[En(V),0];if(se.kind==="wholeStart")return V.firstChild?[V.firstChild,0]:[V,0];if(se.kind==="wholeEnd")return V.lastChild?[V.lastChild,V.lastChild.nodeValue.length]:[V,V.childNodes.length];let Se=V.parentNode;if(!Se)return null;let ve=Array.prototype.indexOf.call(Se.childNodes,V);return[Se,se.kind==="after"?ve+1:ve]},I=se=>({blocks:new Set((se.flat?.marks||[]).filter(V=>V.block).map(V=>g(V.el)).filter(Boolean)),atoms:new Set((se.flat?.atoms||[]).map(V=>g(V.el)).filter(Boolean)),ignored:l}),Y=(se,V,Se,ve)=>{if(!se||!V||!ir(se)||!ir(V))return!1;for(let Ve of[se,V])if(!u(Ve.startContainer)||!u(Ve.endContainer))return!1;let Me=Se.merged;if(Me.start===Me.end&&(se.startContainer!==se.endContainer||se.startOffset!==se.endOffset))return!1;let He=I(ve);return Wn(V,Se.encoding,He)===Me.text&&Wn(se,Se.encoding,He)===Me.text.slice(Me.start,Me.end)},$=new Map,H=se=>{let V=se.parentNode;return V?($.has(V)||$.set(V,new Map(Array.from(V.childNodes,(Se,ve)=>[Se,ve]))),$.get(V).get(se)):-1},z=(se,V)=>{if(!V)return!1;let Se=a.logicalParent(se);if(!V.parent.live.includes(Se))return!1;let ve=H(se);for(let[Me,He]of[["before",1],["after",-1]]){let Ve=ve;for(let it of V[Me]){if(it.live.includes(se))continue;let le=it.live.filter(et=>et!==se&&et.parentNode===se.parentNode);if(!le.length)continue;let yt=He===1?Math.min(...le.map(H)):Math.max(...le.map(H));if(He*(yt-Ve)<=0)return!1;Ve=yt}}return!0},ae=se=>{let V=se.structure;if(V.mergedOrder){let Se=new Set(se.subject.live.map(En)),ve=null,Me=-1;for(let He of V.mergedOrder){let Ve=He.live.find(it=>Se.has(it.parentNode));if(!Ve||ve&&Ve.parentNode!==ve||H(Ve)<=Me)return!1;ve=Ve.parentNode,Me=H(Ve)}return se.subject.live.length>0}return se.subject.live.some(Se=>z(Se,V.mergedPlacement))},me=(se,V)=>{let Se=y(se),ve=y(V);return Se&&ve?{startContainer:Se[0],startOffset:Se[1],endContainer:ve[0],endOffset:ve[1]}:null},Q=new Set,L=se=>{if(!se||Q.has(se))return;Q.add(se);let V=[];for(let Se of t.refs.get(se)||[]){let ve=m(Se);if(ve)for(let Me of ve.nodes)V.includes(Me)||V.push(Me)}se.live=V},Ee=se=>{se&&(L(se.parent),se.before.forEach(L),se.after.forEach(L))},xe=new Set;for(let se of e){let V=se.recovery;if(!V||xe.has(V))continue;xe.add(V),L(V.subject),V.structure&&(Ee(V.structure.localPlacement),Ee(V.structure.remotePlacement),Ee(V.structure.mergedPlacement),(V.structure.localOrder||[]).forEach(L),(V.structure.mergedOrder||[]).forEach(L));let Se=t.anchors.get(V),ve=Se?g(Se):null,Me=!!ve;if(V.text){let _=t.spans.get(V.text.merged),B=_?me(_.start,_.end):null,fe=_?me(_.scopeStart,_.scopeEnd):null;if(_?.empty){let Ae=_.empty,pe=Ae.previous?{kind:"after",node:Ae.previous}:{kind:"startOf",node:Ae.parent},Qe=Ae.next?{kind:"before",node:Ae.next}:{kind:"end",node:Ae.parent},qe=me(pe,Qe);!qe||qe.startContainer!==qe.endContainer||qe.startOffset!==qe.endOffset?B=null:B=fe=qe}Y(B,fe,V.text,_)||(B=fe=null),V.text.liveSpan=B,V.text.liveScope=B?fe:null,B||(Me=!1)}V.structure&&Me&&(Me=ae(V)),V.attribute&&Me&&(Me=i(ve,V.attribute,se.resolved));let He=(!!V.attribute||!!V.text&&ve?.tagName==="TEXTAREA")&&!!s&&[Se,ve].some(_=>s.get(_)?.has(V.attribute?V.attribute.qualifiedName:"value")),Ve=t.localState?.states.get(V),it=!!V.text&&[...n.removedVetoes||[]].some(_=>Ve?.touched.has(_)),le=V.structure?.localAction==="inserted"&&[...o].some(_=>_===Se||Se?.contains(_)),yt=Se&&h(Se)||He||it||le,et=yt&&wl(V,se,t,u);et&&(it||le&&V.localLost)&&(Me=!1);let Oe=!Me&&et&&yt;V.applied=Me,V.unavailable=Me?null:Oe?"hook-veto":"missing-output",Oe&&(V.localLost=!1),!Me&&V.text&&(V.text.liveSpan=V.text.liveScope=null)}}function Lo(e,t,n){let r=lr(t),o=lr(n),s=h=>!!h&&o.containerPath(h)!==null,i=h=>{if(h===t)return n;let f=r.pathOf(h);if(f&&t!==n){let p=sr(n,{path:f,offset:0});if(p&&p[0].nodeType===h.nodeType)return p[0]}return h},l=new Set,a=h=>{!h||l.has(h)||(l.add(h),h.live=h.live.map(i).filter(s))},u=h=>{h&&(h.startContainer=i(h.startContainer),h.endContainer=i(h.endContainer))},d=new Set;for(let h of e){h.node===t&&n.tagName==="SCRIPT"&&(h.node=n),h.el===t&&h.kind==="structure"&&(h.el=n);let f=h.recovery;if(!f||d.has(f))continue;if(d.add(f),a(f.subject),f.text){u(f.text.liveSpan),u(f.text.liveScope);let b=f.text.liveSpan,v=f.text.liveScope,m=f.text.merged,g=y=>!!y&&ir(y)&&s(y.startContainer)&&s(y.endContainer);(!g(b)||!g(v)||Wn(v,f.text.encoding)!==m.text||Wn(b,f.text.encoding)!==m.text.slice(m.start,m.end))&&(f.text.liveSpan=null,f.text.liveScope=null,f.applied=!1,f.unavailable="missing-output")}let p=f.structure;if(p){for(let b of[p.localPlacement,p.remotePlacement,p.mergedPlacement])b&&(a(b.parent),b.before.forEach(a),b.after.forEach(a));(p.localOrder||[]).forEach(a),(p.mergedOrder||[]).forEach(a),f.subject.live.length||(f.applied=!1,f.unavailable="missing-output")}}}var st=e=>!!e&&e.nodeType===1,nf=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),Tl=5e4,Jr="[id],[data-id],script,head>*";function Ws(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let r=vr(n,e);if(r)return"merge:"+r.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?hl(n,t):null}}function Io(e,t,n,r){let o=r.ignored,s=r.stats||Un(),i=el({ignored:o,ignoreAttribute:r.ignoreAttribute,stats:s}),{unitsOf:l,meta:a}=i,u=r.baseURI,d=r.mergeTags!==null,h=Ws(r.mergeTags,u),f=k=>N=>{let D=h(N);return D!==null?D:k(N)},p=f(r.identity.base),b=f(r.identity.local),v=f(r.identity.remote),m=r.authored||r.identity,g=k=>k&&k.nodeType===9?k.documentElement:k,y=g(e),I=g(t),Y=g(n),$=globalThis.__hyperMorphProfile,H=$?performance.now():0,z=k=>k===bn?Jr:null,ae=r.scope||null,me=ae?ae.baseIndex:_o(y,p,o,z(r.identity.base)),Q=r.localIsBase||y===I?_l():Cs(y,I,{analyzer:i,baseIndex:me,sideIndex:_o(I,b,o,z(r.identity.local)),baseId:m.base,sideId:m.local,stats:s}),L=Cs(y,Y,{analyzer:i,baseIndex:me,sideIndex:ae?ae.remoteIndex:_o(Y,v,o,z(r.identity.remote)),baseId:m.base,sideId:m.remote,stats:s,scope:ae,comparisons:r.comparisons});if(ae){if(!ae.held(L))return null;for(let k of ae.dropped)Os(k)}let Ee=null;function xe(k){if(!Ee){Ee=new WeakMap;let N=[y];for(;N.length;){let D=N.pop();D.tagName==="TEMPLATE"&&D.content&&Ee.set(D.content,D);for(let U of i.childrenOf(D))U.nodeType===1&&N.push(U)}}return Ee.get(k)||null}let se=k=>{let N=st(k)||k.nodeType?k.parentNode:k.parent;return N&&N.nodeType===11?xe(N):N};ge(),Ue(Q,L),Ue(L,Q);for(let k of[Q,L])if(k.refused)for(let N of k.refused)k.moved.has(N)||s.ambiguousMoves++;$&&($.alignTotal=($.alignTotal||0)+(performance.now()-H),H=performance.now());let V=y.ownerDocument.implementation.createHTMLDocument(""),Se=new WeakMap,ve=new WeakMap,Me=[],He=[],Ve=new Set,it=[],le=new Set,yt=new Set,et=new Set,Oe=new WeakMap,_=r.conflicts||"remote",B=k=>Me.push(k),fe=k=>Me.push(k),Ae=Al({roots:{base:y,local:I,remote:Y},L:Q,R:L,unitsOf:l,provenance:Se,policy:_}),pe=(k,N)=>{He.push(k),N&&Ae.note(k,N)},Qe=ee(),qe=wt(y,Q.map.get(y),L.map.get(y),!!r.localIsBase,!!r.childrenOnly);qe.tagName==="HTML"?V.replaceChild(qe,V.documentElement):V.body.appendChild(qe),$&&($.build=($.build||0)+(performance.now()-H));let rt=r.childrenOnly?!q(j(qe),j(Y)):!P(qe,Y),lt=Ae.finish(qe);return{doc:V,root:qe,provenance:Se,textMappers:ve,decisions:Me,conflicts:He,recoveryLinks:lt,localDiverged:rt,mergedScripts:Ve,segments:it,remoteIdOf:r.identity.remote,customIdentity:r.identity.remote!==bn,L:Q,R:L,stats:s};function ee(){let k=new Map,N=new Set;if(r.localIsBase||!Q.insertedByHash)return{partner:k,drop:N};let D=Q.insertedByHash(),U=L.insertedByHash();if(!D.size||!U.size)return{partner:k,drop:N};let W={ignored:o,remoteWins:r.remoteWins,inlineCache:Oe},K=We=>{let St=0;for(let mt=We.parentNode;mt;mt=mt.parentNode)St++;return St},te=[],ue=We=>{let St=We.textContent.trim();return St.split(/\s+/).length>=3||St.replace(/\s/g,"").length>=12},Ce=We=>{let St=ke(Q,We),mt=ke(L,We);return St&&Q.reverse.get(St.parentNode)!==We.parentNode||mt&&L.reverse.get(mt.parentNode)!==We.parentNode},Pe=(We,St,mt)=>{for(let Bt of mt.parentNode.children){let Qt=Bt!==mt&&We.reverse.get(Bt);if(Qt&&Ce(Qt))return!0}let tn=We.reverse.get(mt.parentNode);if(tn){for(let Bt of tn.children)if(!ke(St,Bt)&&!o(Bt))return!0}return!1};for(let[We,St]of D){let mt=U.get(We);if(!mt)continue;let tn=St.length===1&&mt.length===1;for(let Bt of St)or(Bt,W)||te.push([Bt,mt,K(Bt),tn&&(ue(Bt)||Pe(Q,L,Bt)||Pe(L,Q,mt[0]))])}if(!te.length)return{partner:k,drop:N};te.sort((We,St)=>We[2]-St[2]);let Le=new Set,at=new Set,Be=We=>{for(let St of We.querySelectorAll("*"))Le.add(St)},It=(We,St)=>We.reverse.get(St.parentNode)||null;for(let[We,St,,mt]of te){if(Le.has(We))continue;let tn=It(Q,We),Bt=Dt=>!at.has(Dt)&&!Le.has(Dt)&&Dt.tagName===We.tagName&&i.equalUnits(We,Dt),Qt=St.find(Dt=>tn&&It(L,Dt)===tn&&Bt(Dt))||(mt?St.find(Bt):null);Qt&&(at.add(Qt),Be(We),Be(Qt),!(tn&&It(L,Qt)===tn)&&(k.set(We,Qt),k.set(Qt,We),N.add(_==="local"?Qt:We)))}return{partner:k,drop:N}}function ce(k,N,D){if(le.add(k),Qe.drop.has(k))return null;le.add(D);let U=N==="local"?k:D,W=N==="local"?D:k,K;return i.equalUnits(U,W)?(K=w(U,"local",!0),Se.get(K).remote=W):K=he(U,W),pe({kind:"structure",el:K,detail:"both-moved",base:null,local:U,remote:W},{unit:{b:null,l:U,r:W}}),B({kind:"insert",el:K,source:"both"}),K}function ge(){if(!Q.weak||!L.weak||!Q.weak.size||!L.weak.size||!Q.unpair)return;let k=new Map;for(let D of Q.weak){let U=ke(Q,D);st(D)&&st(U)&&k.set(i.unitHash(U),D)}let N=!1;for(let D of Array.from(L.weak)){let U=ke(L,D);if(!st(D)||!st(U))continue;let W=k.get(i.unitHash(U));if(!W||W===D||!Q.weak.has(W)||ke(Q,D)&&ke(L,W))continue;let K=ke(Q,W);K.tagName===U.tagName&&i.equalUnits(K,U)&&(Q.unpair(W),L.unpair(D),N=!0)}N&&(Q.rematch(),L.rematch())}function Ue(k,N){if(!k.weak||!k.weak.size||!N.insertedByHash)return;let D=N.insertedByHash();if(!D.size)return;let U=!1;for(let W of Array.from(k.weak)){let K=ke(k,W);if(!K)continue;let te=D.get(i.unitHash(K));te&&te.some(ue=>ue.tagName===K.tagName&&i.equalUnits(ue,K))&&(k.unpair(W),U=!0)}U&&k.rematch()}function ke(k,N){if(!N)return null;if(k.map.has(N))return k.map.get(N);let D=[],U=se(N);for(;U&&!k.map.has(U);U=se(U))D.push(U);let W=U;if(!W||!k.identical.has(W))return null;k.pairIdenticalChildren(W);for(let te=D.length-1;te>=0;te--)k.pairIdenticalChildren(D[te]);let K=k.map.get(N)||null;return K&&s.lazyTwins++,K}function Je(k,N,D){if(yt.has(k)||et.has(k))return pe({kind:"structure",el:null,detail:"both-moved",base:k},{subject:k}),yt.has(k)?null:w(D,N);let U=ke(Q,k),W=ke(L,k);(!U||!W)&&pe({kind:"structure",el:null,detail:"move-beats-delete",base:k},{subject:k,deleted:U?"remote":"local"});let K=wt(k,U,W,!1);return(N==="local"?B:fe)({kind:"move",el:K,source:N}),K}function kt(k,N,D,U){return U||!N||N===D?{el:D,asBase:!0,twin:W=>W,baseOf:W=>W,units:l(D),here:()=>!0,parentOfTwin:()=>D}:{el:N,asBase:!1,twin:W=>ke(k,W),baseOf:W=>k.reverse.get(W),units:l(N),here:W=>st(W)?W.parentNode===N||N.tagName==="TEMPLATE"&&W.parentNode===N.content:W.parent===N||N.tagName==="TEMPLATE"&&W.parent===N.content}}function ht(k,N,D){return!N||D&&D.identical.has(k)?!1:st(k)?!i.equalUnits(k,N):k.value!==N.value}function wt(k,N,D,U,W=!1){let K=U||r.remoteWins(k),te=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?V.createElementNS(k.namespaceURI,k.tagName):V.createElement(k.tagName),ue={base:k,local:N||null,remote:D||null};if(Se.set(te,ue),le.add(k),yt.add(k),N&&le.add(N),D&&le.add(D),r.skipUnchanged&&!W&&(r.localIsBase||Q.identical.has(k))&&D&&L.identical.has(k)&&!r.remoteWins(k)){ue.unchanged=!0;for(let Pe of k.attributes)Pe.namespaceURI?te.setAttributeNS(Pe.namespaceURI,Pe.name,Pe.value):te.setAttribute(Pe.name,Pe.value);return te}et.add(k),W||T(k,K?k:N,D,te);let Ce=k.tagName;if(un(k))Ot(k,K?k:N,D,te);else if(Ce==="TEXTAREA")te.textContent=ze(k.textContent,(K?k:N)?(K?k:N).textContent:k.textContent,D?D.textContent:k.textContent,te,"text");else{let Pe=E(k,N,D,K,te),Le=Ce==="TEMPLATE"&&te.content?te.content:te;for(let at of Pe)Le.appendChild(at)}return et.delete(k),te}function ze(k,N,D,U,W){if(N===D)return N;if(N===k)return D!==k&&fe({kind:W,node:U,source:"remote"}),D;if(D===k)return B({kind:W,node:U,source:"local"}),N;let K=_==="local"?N:D;return pe({kind:W,node:U,base:k,local:N,remote:D,resolved:K},{site:"whole",el:U}),Me.push({kind:W,node:U,source:"both"}),K}function Ot(k,N,D,U){let W=k.textContent,K=N?N.textContent:W,te=D?D.textContent:W,ue=d?vr(k,r.mergeTags,!0):null;if(ue&&K!==te){let Ce=D&&D.getAttribute("merge-key")||k.getAttribute("merge-key"),{text:Pe,warnings:Le}=Vs(r.localIsBase?void 0:W,K,te,{parse:ue.recognizer.parse,keyCandidates:Ce?Ce.split(/[\s,]+/).filter(Boolean):void 0});for(let at of Le)console.warn(`[hyper-morph] merge "${ue.raw}": ${at}`);U.textContent=Pe,Ve.add(U),Pe!==te?B({kind:"text",node:U,source:Pe===K?"local":"both"}):Pe!==W&&fe({kind:"text",node:U,source:"remote"});return}U.textContent=ze(W,K,te,U,"text")}function T(k,N,D,U){let W=new Map;for(let K of[k,N,D])if(K)for(let te of K.attributes)r.ignoreAttribute(K,te.name)||W.set(te.name,te);for(let[K,te]of W){let ue=k?k.getAttribute(K):null,Ce=N?N.getAttribute(K):ue,Pe=D?D.getAttribute(K):ue,Le;Ce===Pe?Le=Ce:Ce===ue?(Le=Pe,fe({kind:"attr",el:U,name:K,source:"remote"})):Pe===ue?(Le=Ce,B({kind:"attr",el:U,name:K,source:"local"})):(Le=re(K,ue,Ce,Pe),Le===void 0&&(Le=_==="local"?Ce:Pe,pe({kind:"attr",el:U,name:K,base:ue,local:Ce,remote:Pe,resolved:Le},{el:U,sample:te})),Me.push({kind:"attr",el:U,name:K,source:"both"})),Le!=null&&(te.namespaceURI?U.setAttributeNS(te.namespaceURI,te.name,Le):U.setAttribute(K,Le))}}function re(k,N,D,U){if(k==="class"){let W=Pe=>new Set((Pe||"").split(/\s+/).filter(Boolean)),K=W(N),te=W(D),ue=W(U),Ce=new Set;for(let Pe of new Set([...K,...te,...ue])){let Le=K.has(Pe),at=te.has(Pe),Be=ue.has(Pe);(at===Be?at:at===Le?Be:at)&&Ce.add(Pe)}return[...Ce].join(" ")}if(k==="style"){let W=Le=>{let at=new Map;if(!Le)return at;let Be=0,It=null,We="",St=()=>{let mt=We.indexOf(":");mt>0&&at.set(We.slice(0,mt).trim(),We.slice(mt+1).trim()),We=""};for(let mt of Le){if(It){We+=mt,mt===It&&(It=null);continue}if(mt==='"'||mt==="'"){It=mt,We+=mt;continue}if(mt==="("?Be++:mt===")"&&Be--,mt===";"&&Be===0){St();continue}We+=mt}return We.trim()&&St(),at},K=W(N),te=W(D),ue=W(U),Ce=new Map,Pe=!1;for(let Le of new Set([...K.keys(),...te.keys(),...ue.keys()])){let at=K.get(Le)??null,Be=te.get(Le)??null,It=ue.get(Le)??null,We;Be===It?We=Be:Be===at?We=It:It===at?We=Be:(We=_==="local"?Be:It,Pe=!0),We!=null&&Ce.set(Le,We)}return Pe?void 0:[...Ce].map(([Le,at])=>`${Le}: ${at}`).join("; ")}}function oe(k,N,D,U){let W=k.value,K=U?W:N?N.value:"",te=D?D.value:"";le.add(k),N&&le.add(N),D&&le.add(D);let ue=Kr(W,K,te,_),Ce=ue.text===""?null:V.createTextNode(ue.text);Ce&&(Se.set(Ce,{base:k.nodes,local:N?N.nodes:null,remote:D?D.nodes:null}),ve.set(Ce,ue.mapLocalOffset)),K!==W&&te!==W?Me.push({kind:"text",node:Ce,source:"both"}):K!==W?B({kind:"text",node:Ce,source:"local"}):te!==W&&fe({kind:"text",node:Ce,source:"remote"});for(let Pe of ue.conflicts)pe({kind:"text",node:Ce,base:W.slice(Pe.bs,Pe.be),local:Pe.local,remote:Pe.remote,resolved:Pe.resolved},{site:"run",bRun:k,lRun:N,rRun:D,node:Ce,c:Pe});return Ce}function de(k,N){return Gr(k,N).every(D=>D.bs===D.be)}function ie(k,N){let D=k?k.value:"",U=N?N.value:"",W;if(D===U||!U?W=D:D?de(D,U)?W=U:de(U,D)?W=D:(W=_==="local"?D:_==="both"?D+U:U,pe({kind:"structure",el:null,detail:"insert-collision",local:D,remote:U,resolved:W},{unit:{b:null,l:k,r:N},localLost:_==="remote"})):W=U,k&&le.add(k),N&&le.add(N),W==="")return null;let K=V.createTextNode(W);return Se.set(K,{base:null,local:k?k.nodes:null,remote:N?N.nodes:null}),D?B({kind:"insert",el:K,source:U&&D===U?"both":"local"}):fe({kind:"insert",el:K,source:"remote"}),K}function he(k,N){let D={ignored:o,remoteWins:r.remoteWins,inlineCache:Oe},U=ue=>l(ue).every(Ce=>st(Ce)?or(Ce,D):Ce.kind==="text"),W=null;if(U(k)&&U(N)){let ue=k.textContent,Ce=N.textContent;ue===Ce||de(Ce,ue)?W=N:de(ue,Ce)&&(W=k)}if(!W){let ue=_==="local",Ce=w(ue?k:N,ue?"local":"remote",!0),Pe=Se.get(Ce);return ue?Pe.remote=N:Pe.local=k,pe({kind:"structure",el:Ce,detail:"insert-collision",local:k,remote:N,resolved:ue?k:N},{unit:{b:null,l:k,r:N},localLost:!ue}),Ce}let K=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?V.createElementNS(k.namespaceURI,k.tagName):V.createElement(k.tagName);T(null,k,N,K),Se.set(K,{base:null,local:k,remote:N}),le.add(k),le.add(N);let te=$s({base:Array.from(W.childNodes),local:Array.from(k.childNodes),remote:Array.from(N.childNodes),out:V,policy:_,idOf:{local:b,remote:v},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,provenance:Se,textMappers:ve,conflicts:He,conflict:pe,scope:{base:null,local:k,remote:N,units:[],at:0},synthetic:!0,decisions:Me,node:K});it.push(...te.segments);for(let ue of te.nodes)K.appendChild(ue);return K}function w(k,N,D=!1){if(!D&&st(k)){let te=Qe.partner.get(k);if(te)return ce(k,N,te)}if(!st(k)){if(k.value==="")return null;let te=k.kind==="comment"?V.createComment(k.value):V.createTextNode(k.value);return Se.set(te,{base:null,local:N==="local"?k.nodes:null,remote:N==="remote"?k.nodes:null}),le.add(k),te}let U=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?V.createElementNS(k.namespaceURI,k.tagName):V.createElement(k.tagName);for(let te of k.attributes)te.namespaceURI?U.setAttributeNS(te.namespaceURI,te.name,te.value):U.setAttribute(te.name,te.value);Se.set(U,{base:null,local:N==="local"?k:null,remote:N==="remote"?k:null}),le.add(k);let W=k.tagName==="TEMPLATE"&&U.content?U.content:U,K=N==="local"?Q:L;for(let te of l(k)){let ue=st(te)?K.reverse.get(te):null;if(ue&&yt.has(ue)){pe({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue});continue}if(ue&&!et.has(ue)){let Pe=ke(Q,ue)||null,Le=ke(L,ue)||null;if(Pe||Le){let at=wt(ue,Pe,Le,!1);N==="local"?B({kind:"move",el:at,source:"local"}):fe({kind:"move",el:at,source:"remote"}),W.appendChild(at);continue}}let Ce=w(te,N);Ce&&W.appendChild(Ce)}return U}function E(k,N,D,U,W){N&&Q.identical.has(k)&&Q.pairIdenticalChildren(k),D&&L.identical.has(k)&&L.pairIdenticalChildren(k);let K=kt(Q,N,k,U),te=kt(L,D,k,!1),ue=l(k),Ce=new Set(ue),Pe=new Map;for(let ne=0;ne<ue.length;ne++)Pe.set(ue[ne],ne);let Le=[],at=new Set,Be=new Map,It=new Set,We=new Set,St=[];nn();let mt=ne=>{let De=[];for(let Ne of ne.units){if(We.has(Ne))continue;let tt=ne.baseOf(Ne);tt&&Ce.has(tt)&&De.push(tt)}return De},tn=ne=>mt(ne).map(De=>Pe.get(De)),Bt=ne=>ne.every((De,Ne)=>Ne===0||De>=ne[Ne-1]),Qt=!K.asBase&&!Bt(tn(K)),Dt=!te.asBase&&!Bt(tn(te));Qt&&Dt&&pe({kind:"structure",el:W,detail:"both-reordered",base:k},{subject:k,lKept:mt(K),rKept:mt(te)});let xt=Dt||!Qt?{V:te,A:L,side:"remote",other:K,otherA:Q,otherSide:"local"}:{V:K,A:Q,side:"local",other:te,otherA:L,otherSide:"remote"};Qt?B({kind:"move",el:null,source:Dt?"both":"local",base:k}):Dt&&fe({kind:"move",el:null,source:"remote",base:k});let Rt=K.asBase?[]:K.units.filter(ne=>!K.baseOf(ne)&&!We.has(ne)&&!Qe.partner.has(ne)),Mt=te.asBase?[]:te.units.filter(ne=>!te.baseOf(ne)&&!We.has(ne)&&!Qe.partner.has(ne)),zt=new Map;if(Rt.length&&Mt.length){let ne=new Map,De=new Map;for(let $e of Mt){if(st($e)){let ct=v($e);ct&&ne.set(ct,$e)}let Ye=i.unitHash($e);De.has(Ye)||De.set(Ye,[]),De.get(Ye).push($e)}let Ne=($e,Ye)=>{let ct=$e.units.indexOf(Ye);for(let Ke=ct-1;Ke>=0;Ke--){let ft=$e.baseOf($e.units[Ke]);if(ft)return ft}return"start"},tt=new Map,pt=new Map;for(let $e of Mt){let Ye=Ne(te,$e);st($e)?(pt.has(Ye)||pt.set(Ye,[]),pt.get(Ye).push($e)):$e.kind==="text"&&!tt.has(Ye)&&tt.set(Ye,$e)}for(let $e of Rt){let Ye=null;if(st($e)){let ct=b($e);ct&&ne.has(ct)&&!zt.has(ne.get(ct))&&(Ye=ne.get(ct))}else if($e.kind==="text"){let ct=tt.get(Ne(K,$e));ct&&!zt.has(ct)&&(Ye=ct)}if(!Ye){let ct=De.get(i.unitHash($e));ct&&(Ye=ct.find(Ke=>!zt.has(Ke)&&st(Ke)===st($e)&&(st(Ke)?Ke.tagName===$e.tagName:Ke.kind===$e.kind)&&i.equalUnits($e,Ke))||null)}if(!Ye&&st($e)){let ct=m.local($e),Ke=(pt.get(Ne(K,$e))||[]).filter(ft=>{let cn=m.remote(ft);return!zt.has(ft)&&ft.tagName===$e.tagName&&!(ct&&cn&&ct!==cn)&&i.similar($e,ft)});Ke.length===1&&(Ye=Ke[0])}Ye&&(zt.set(Ye,$e),zt.set($e,Ye))}}let an=ne=>{if(le.has(ne))return Be.get(ne)||null;let De=K.twin(ne),Ne=te.twin(ne),tt=De&&!K.asBase&&!K.here(De),pt=Ne&&!te.asBase&&!te.here(Ne);if(tt||pt){if((!De||!Ne)&&pe({kind:"structure",el:null,detail:"move-beats-delete",base:ne},{subject:ne,deleted:De?"remote":"local"}),!Z(ne))return le.add(ne),null;pe({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne})}if(!De&&!Ne)return le.add(ne),fe({kind:"remove",source:"both",base:ne}),null;if(!De&&!ht(ne,Ne,L))return le.add(ne),B({kind:"remove",source:"local",base:ne}),null;if(!Ne&&!ht(ne,De,Q))return le.add(ne),fe({kind:"remove",source:"remote",base:ne}),null;let $e=!De||!Ne,Ye=K.asBase?ke(Q,ne)||null:De,ct=te.asBase&&st(ne)&&(L.identityPaired.has(ne)||!m.base(ne))&&ke(L,ne)||Ne,Ke;return st(ne)?Ke=wt(ne,Ye,ct,K.asBase):ne.kind==="comment"?Ke=O(ne,Ye,Ne,K.asBase):Ke=oe(ne,Ye,Ne,K.asBase),le.add(ne),Ke&&(Be.set(ne,Ke),De&&Be.set(De,Ke),Ne&&Be.set(Ne,Ke),$e&&(pe({kind:"structure",el:Ke,detail:"edit-beats-delete",base:ne},{subject:ne,deleted:De?"remote":"local"}),De?B({kind:"insert",el:Ke,source:"local"}):fe({kind:"insert",el:Ke,source:"remote"}))),Ke},yn=(ne,De,Ne,tt)=>{if(le.has(ne))return Be.get(ne)||null;let pt=De.baseOf(ne);if(pt&&Ce.has(pt))return We.has(pt)&&!We.has(ne)?qn(pt,ne,tt):an(pt);if(pt)return Bn(pt,ne,tt);let $e=zt.get(ne);if($e){let ct=tt==="local"?ne:$e,Ke=tt==="local"?$e:ne,ft;return st(ct)?i.equalUnits(ct,Ke)?(ft=w(ct,"local"),Se.get(ft).remote=Ke):ft=he(ct,Ke):ft=ie(ct,Ke),le.add(ct),le.add(Ke),ft&&(Be.set(ct,ft),Be.set(Ke,ft),st(ct)&&B({kind:"insert",el:ft,source:"both"})),ft}let Ye=w(ne,tt);return Ye&&(Be.set(ne,Ye),tt==="local"?B({kind:"insert",el:Ye,source:"local"}):fe({kind:"insert",el:Ye,source:"remote"})),Ye},qn=(ne,De,Ne)=>{let tt;return st(ne)?(tt=Je(ne,Ne,De),tt&&le.add(De)):(tt=w(De,Ne),le.add(De),tt&&(Ne==="local"?B:fe)({kind:"insert",el:tt,source:Ne})),tt&&Be.set(De,tt),tt},Bn=(ne,De,Ne)=>{let pt=ke(Ne==="local"?L:Q,ne),$e=De,Ye=pt?ye(pt,Ne==="local"?D:N,Ne==="local"?L:Q):!1,ct=pt&&!Ye&&!Re(ne,pt);if(ct&&Ne===xt.otherSide)return pe({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne}),null;if(ct&&pe({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne}),pt||pe({kind:"structure",el:null,detail:"move-beats-delete",base:ne},{subject:ne,deleted:Ne==="local"?"remote":"local"}),et.has(ne)){pe({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne});let ft=w($e,Ne);return ft&&Be.set(De,ft),ft}let Ke=st(ne)?wt(ne,Ne==="local"?$e:ke(Q,ne)||null,Ne==="remote"?$e:ke(L,ne)||null,!1):null;return Ke&&(Be.set(ne,Ke),Be.set(De,Ke),pt&&Be.set(pt,Ke),Ne==="local"?B({kind:"move",el:Ke,source:"local"}):fe({kind:"move",el:Ke,source:"remote"})),Ke};for(let ne of xt.V.units){if(We.has(ne)){let Ne=Be.get(ne);at.has(Ne)||(Le.push(Ne),at.add(Ne));continue}if(le.has(ne)&&!(Be.get(ne)&&at.has(Be.get(ne)))){let Ne=xt.V.baseOf(ne);Ne&&!Ce.has(Ne)&&pe({kind:"structure",el:null,detail:"both-moved",base:Ne},{subject:Ne});continue}let De=yn(ne,xt.V,xt.A,xt.side);De&&!at.has(De)&&(Le.push(De),at.add(De),!xt.V.baseOf(ne)&&!zt.has(ne)&&!We.has(ne)&&It.add(De))}for(let ne of St)at.has(ne.frag)||(Le.splice(Nn(ne.at),0,ne.frag),at.add(ne.frag));if(!xt.other.asBase){let ne=xt.other,De=xt.otherSide,Ne=xt.otherA,tt=null,pt=0,$e=null;for(let Ye of ne.units){let ct=Be.get(Ye);if(ct&&at.has(ct)){tt=ct,$e=null;continue}if(le.has(Ye)){let cn=ne.baseOf(Ye);cn&&!Ce.has(cn)&&pe({kind:"structure",el:null,detail:"both-moved",base:cn},{subject:cn});continue}let Ke=yn(Ye,ne,Ne,De);if(!Ke)continue;let ft;if($e)ft=Le.indexOf($e)+1;else if(tt){if(ft=Le.indexOf(tt)+1,De==="remote")for(;ft<Le.length&&It.has(Le[ft]);)ft++}else ft=pt++;Le.splice(ft,0,Ke),at.add(Ke),$e=Ke}}for(let ne=0;ne<ue.length;ne++){let De=ue[ne];if(le.has(De))continue;let Ne=an(De);Ne&&Le.splice(Nn(ne),0,Ne)}return Le;function Nn(ne){for(let De=ne-1;De>=0;De--){let Ne=Be.get(ue[De]);if(Ne){let tt=Le.indexOf(Ne);if(tt>=0)return tt+1}}return 0}function mn(ne){let De={ignored:o,remoteWins:()=>!1},Ne=we=>ne(we)||st(we)&&r.remoteWins(we)&&Mn.has(we.tagName)&&or(we,De),tt=new Map,pt=we=>{if(!st(we)||!nf.has(we.tagName))return!1;let je=tt.get(we);return je===void 0&&(je=!o(we)&&!r.remoteWins(we)&&l(we).every(Ne),tt.set(we,je)),je},$e=we=>!st(we)&&we.kind==="text",Ye=null,ct=new Map,Ke=we=>{let je=ct.get(we);if(je)return je;let Xe=st(we)?we.textContent:we.value;je=new Set;let ut=Xe.toLowerCase();if(!(Xe.length>Tl))if(/^[\x00-\x7f]*$/.test(ut))for(let Ze of ut.split(/[^\p{L}\p{N}]+/u))Ze&&je.add(Ze);else for(let Ze of Ps(ut))/^[\s\p{P}]+$/u.test(Ze)||je.add(Ze);return ct.set(we,je),je},ft=we=>(st(we)?we.textContent:we.value).toLowerCase().replace(/\s+/g," ").trim(),cn=new Map,tr=we=>{let je=cn.get(we);if(je)return je;je=new Set(Ke(we));let Xe=Ze=>{if(Ze)for(let Nt of Ke(Ze))je.add(Nt)},ut=Ce.has(we)?we:!K.asBase&&K.baseOf(we)||!te.asBase&&te.baseOf(we);return ut&&(Xe(ut),Xe(ke(Q,ut)),Xe(ke(L,ut))),cn.set(we,je),je},xn=(we,je)=>{let Xe=ft(je),ut=Ce.has(we)?we:!K.asBase&&K.baseOf(we)||!te.asBase&&te.baseOf(we),Ze=Wt=>Xe?Wt.split(Xe).length-1:0;if(ut&&st(je)&&!Ce.has(je)){let Wt=Ze(ft(ut));for(let Kt of[ke(Q,ut),ke(L,ut)]){if(!Kt||Kt===je||Kt.ownerDocument!==je.ownerDocument)continue;let gn=ft(Kt);if(gn.length>Xe.length&&Ze(gn)>=Wt&&(gn.startsWith(Xe)||gn.endsWith(Xe)))return!1}}let Nt=Ke(je),_t=tr(we),Ht=0;for(let Wt of Nt)_t.has(Wt)&&Ht++;if(Nt.size&&Ht*2>=Nt.size)return!0;if(!Xe||Xe.length>Tl)return!1;let en=ut?[we,ut,ke(Q,ut),ke(L,ut)]:[we],dn=(Wt,Kt)=>Wt!==Kt&&(Wt.startsWith(Kt)||Wt.endsWith(Kt));if(en.some(Wt=>Wt&&dn(ft(Wt),Xe)))return!0;if(!Ce.has(je)||!ut)return!1;let jt=ft(we),Hn=ft(ut);return[ke(Q,je),ke(L,je)].some(Wt=>{let Kt=Wt&&ft(Wt);return!!Kt&&jt!==Kt&&(jt.startsWith(Kt)&&!Hn.startsWith(Kt)||jt.endsWith(Kt)&&!Hn.endsWith(Kt))})},pn=we=>{Ye||(Ye=new Set),Ye.add(we)},nr=we=>{pn(we);for(let[je,Xe]of[[Q,K],[L,te]]){if(Xe.asBase)continue;let ut=ke(je,we);ut&&Xe.here(ut)&&pn(ut)}},ot=(we,je)=>we.asBase||ue.every(Xe=>!st(Xe)||je.identical.has(Xe)&&we.here(ke(je,Xe)))&&we.units.every(Xe=>!st(Xe)||we.baseOf(Xe));if(ot(K,Q)&&ot(te,L))return null;let vt=we=>{if(we.asBase)return!1;let je=-1;for(let Xe of we.units){let ut=st(Xe)?we.baseOf(Xe):null;if(!ut||!Ce.has(ut))continue;let Ze=Pe.get(ut);if(Ze<je)return!0;je=Ze}return!1};if(vt(K)||vt(te))return null;for(let[we,je]of[[K,Q],[te,L]]){if(we.asBase||ot(we,je))continue;let Xe=we.units,ut=je===Q?m.local:m.remote,Ze=(Fe,At)=>{let Pt=st(Fe)&&m.base(Fe),Ct=st(At)&&ut(At);return!Pt||!Ct||Pt===Ct},Nt=new Map;for(let Fe=0;Fe<Xe.length;Fe++)Nt.set(Xe[Fe],Fe);let _t=Fe=>!!Fe&&(st(Fe)?we.here(Fe):Nt.has(Fe)),Ht=Fe=>{let At=we.twin(Fe);return _t(At)?At:null},en=ue.filter(Fe=>!we.twin(Fe)&&pt(Fe)),dn=Xe.filter(Fe=>!we.baseOf(Fe)&&pt(Fe)),jt=(Fe,At)=>At===ue?!!Ht(Fe):Ce.has(we.baseOf(Fe)),Hn=Fe=>{let At=new Int32Array(Fe.length),Pt=new Int32Array(Fe.length),Ct=-1;for(let Tt=0;Tt<Fe.length;Tt++)At[Tt]=Ct,jt(Fe[Tt],Fe)&&(Ct=Tt);Ct=Fe.length;for(let Tt=Fe.length-1;Tt>=0;Tt--)Pt[Tt]=Ct,jt(Fe[Tt],Fe)&&(Ct=Tt);return{prev:At,next:Pt}},Wt=Hn(Xe),Kt=Hn(ue),gn=(Fe,At)=>{nr(Fe),pn(At)};for(let Fe of dn){let At=Nt.get(Fe),Pt=Wt.prev[At],Ct=Wt.next[At],Tt=Pt>=0?we.baseOf(Xe[Pt]):null,Sn=Ct<Xe.length?we.baseOf(Xe[Ct]):null,Gt=Tt?Pe.get(Tt):-1,$n=Sn?Pe.get(Sn):ue.length;for(let Cn=Math.max(0,Gt);Cn<=Math.min($n,ue.length-1);Cn++){let rn=ue[Cn];(pt(rn)||$e(rn))&&(!Ze(rn,Fe)||!xn(rn,Fe)||($e(rn)?pn(Fe):gn(rn,Fe)))}}let An=(Fe,At,Pt)=>{for(let Ct=At+Pt;Ct>=0&&Ct<Fe.length;Ct+=Pt){let Tt=Fe[Ct];if(pt(Tt))return Tt;if(st(Tt)||Tt.value.trim())return null}return null},wo=Fe=>{let At=new Set;for(let Pt of l(Fe))if(!st(Pt)&&Pt.kind==="text")for(let Ct of Ke(Pt))At.add(Ct);return At},mr=(Fe,At)=>{let Pt=Ke(At),Ct=new Set;for(let Tt of wo(Fe))Pt.has(Tt)||Ct.add(Tt);return Ct},Vr=(Fe,At)=>{if(!Fe.size)return!1;let Pt=Ke(At),Ct=0;for(let Tt of Fe)Pt.has(Tt)&&Ct++;return Ct*2>=Fe.size};for(let Fe of ue){if(je.identical.has(Fe)||!pt(Fe))continue;let At=Ht(Fe);if(!At||!pt(At))continue;let Pt=mr(At,Fe),Ct=mr(Fe,At);for(let Tt of[-1,1]){let Sn=An(ue,Pe.get(Fe),Tt);Sn&&Vr(Pt,Sn)&&(gn(Fe,At),nr(Sn));let Gt=An(Xe,Nt.get(At)??-1,Tt);if(Gt&&Vr(Ct,Gt)){gn(Fe,At);let $n=we.baseOf(Gt);$n?gn($n,Gt):pn(Gt)}}}for(let Fe of en){let At=Pe.get(Fe),Pt=Kt.prev[At],Ct=Kt.next[At],Tt=Pt>=0?Ht(ue[Pt]):null,Sn=Ct<ue.length?Ht(ue[Ct]):null,Gt=Tt?Nt.get(Tt)??-1:-1,$n=Sn?Nt.get(Sn)??-1:Xe.length;for(let Cn=Math.max(0,Gt);Cn<=Math.min($n,Xe.length-1);Cn++){let rn=Xe[Cn];if((pt(rn)||$e(rn))&&!(!Ze(Fe,rn)||!xn(rn,Fe))&&(nr(Fe),!$e(rn))){let Ao=we.baseOf(rn);Ao?gn(Ao,rn):pn(rn)}}}}if(!Ye)return null;for(let we of Array.from(Ye))if(Ce.has(we))for(let je of[Q,L]){let Xe=ke(je,we);Xe&&!ye(Xe,je===Q?N:D,je)&&!(je===Q?K:te).asBase&&(Ye.delete(we),Ye.delete(ke(Q,we)),Ye.delete(ke(L,we)))}return Ye.size?Ye:null}function nn(){if((K.asBase||Q.identical.has(k))&&(te.asBase||L.identical.has(k)))return;let ne={ignored:o,remoteWins:r.remoteWins,inlineCache:Oe},De=ot=>st(ot)?or(ot,ne):ot.kind==="text",Ne=mn(De),tt=ot=>Ne&&Ne.has(ot)||De(ot),pt=ue.map(tt);if(!pt.includes(!0))return;let $e=ot=>{let vt=ot.units,we=new Map;for(let _t=0;_t<vt.length;_t++)we.set(vt[_t],_t);let je=[],Xe=-1;for(let _t=0;_t<ue.length;_t++){if(pt[_t])continue;let Ht=ot.twin(ue[_t]),en=Ht?we.get(Ht):void 0;en===void 0||en<=Xe||tt(Ht)||(je.push([_t,en]),Xe=en)}let ut=[],Ze=-1,Nt=-1;for(let _t=0;_t<=je.length;_t++){let[Ht,en]=_t<je.length?je[_t]:[ue.length,vt.length],dn={bLo:-1,bHi:-1,sLo:-1,sHi:-1,next:en};for(let jt=Ze+1;jt<Ht;jt++)pt[jt]&&(dn.bLo<0&&(dn.bLo=jt),dn.bHi=jt);for(let jt=Nt+1;jt<en;jt++)tt(vt[jt])&&(dn.sLo<0&&(dn.sLo=jt),dn.sHi=jt);ut.push(dn),Ze=Ht,Nt=en}return{units:vt,list:ut}},Ye=$e(K),ct=$e(te),Ke=[];for(let ot of[Ye,ct])for(let vt of ot.list)vt.bLo>=0&&Ke.push([vt.bLo,vt.bHi]);Ke.sort((ot,vt)=>ot[0]-vt[0]);let ft=[];for(let[ot,vt]of Ke){let we=ft[ft.length-1];we&&ot<=we.hi?we.hi=Math.max(we.hi,vt):ft.push({lo:ot,hi:vt})}let cn=(ot,vt)=>{let we=-1,je=-1;for(let Ze=0;Ze<ot.list.length;Ze++){let Nt=ot.list[Ze];Nt.bLo<vt.lo||Nt.bLo>vt.hi||(we<0&&(we=Ze),je=Ze)}let Xe=1/0,ut=-1;for(let Ze=we;Ze>=0&&Ze<=je;Ze++){let Nt=ot.list[Ze];Nt.sLo>=0&&(Xe=Math.min(Xe,Nt.sLo),ut=Math.max(ut,Nt.sHi)),Ze<je&&(Xe=Math.min(Xe,Nt.next),ut=Math.max(ut,Nt.next))}return ut<0?[]:ot.units.slice(Xe,ut+1)},tr=(ot,vt)=>ot.length===vt.length&&ot.every((we,je)=>i.equalUnits(we,vt[je])),xn=ot=>!st(ot)&&ot.kind==="comment",pn=ot=>{if(!ot.length)return[];let vt=(Ze,Nt)=>st(Ze)?Ze:Ze.nodes[Nt?Ze.nodes.length-1:0],we=vt(ot[0]),je=vt(ot[ot.length-1],!0),Xe=Ze=>Ze&&st(Ze)&&o(Ze);for(;Xe(we.previousSibling);)we=we.previousSibling;for(;Xe(je.nextSibling);)je=je.nextSibling;let ut=[];for(let Ze=we;Ze&&(ut.push(Ze),Ze!==je);Ze=Ze.nextSibling);return ut},nr=ot=>ot.some(vt=>st(vt)&&o(vt));for(let ot of ft){let vt=ue.slice(ot.lo,ot.hi+1),we=K.asBase?null:cn(Ye,ot),je=te.asBase?null:cn(ct,ot);if(vt.some(xn)||we&&we.some(xn)||je&&je.some(xn))continue;let Xe=pn(we||vt),ut=pn(je||vt);if((!we||tr(vt,we))&&(!je||tr(vt,je))&&!(we&&nr(Xe)))continue;let Ze=$s({base:pn(vt),local:Xe,remote:ut,out:V,policy:_,blocks:Ne,L:we?Q:El(Q,k),R:je?L:El(L,k),idOf:{local:b,remote:v},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(_t,Ht,en)=>wt(_t,Ht,en,!1),cloneUnit:w,mergeAttrs:T,atomKey:i.exactUnitKey,moveIn:Je,provenance:Se,textMappers:ve,conflicts:He,conflict:pe,scope:{base:k,local:K.asBase?null:K.el,remote:te.asBase?null:te.el,units:ue,at:ot.lo},decisions:Me,node:W});it.push(...Ze.segments);let Nt=V.createDocumentFragment();for(let _t of Ze.nodes)Nt.appendChild(_t);for(let _t of[...vt,...we||[],...je||[]])le.add(_t),We.add(_t),Be.set(_t,Nt);St.push({frag:Nt,at:ot.lo})}}}function P(k,N){let D=Se.get(k);return D&&D.unchanged?!D.remote||D.remote===N?!0:x(D.remote,N):k.tagName!==N.tagName||!G(k,N)?!1:q(j(k),j(N))}function x(k,N){return k===N?!0:k.tagName!==N.tagName||k.namespaceURI!==N.namespaceURI||!G(k,N)?!1:A(j(k),j(N))}function A(k,N){let D=X(k,o),U=X(N,o);if(D.length!==U.length)return!1;for(let W=0;W<D.length;W++){let K=D[W],te=U[W];if(typeof K=="string"||typeof te=="string"){if(K!==te)return!1}else{if(K.nodeType!==te.nodeType)return!1;if(K.nodeType===1){if(!x(K,te))return!1}else if(K.nodeValue!==te.nodeValue)return!1}}return!0}function j(k){return k.tagName==="TEMPLATE"&&k.content?k.content:k}function G(k,N){let D=0;for(let U of k.attributes)if(!r.ignoreAttribute(k,U.name)&&(D++,N.getAttribute(U.name)!==U.value))return!1;for(let U of N.attributes)r.ignoreAttribute(N,U.name)||D--;return D===0}function q(k,N){let D=X(k,W=>{let K=Se.get(W);return!!(K&&K.pinned)}),U=X(N,o);if(D.length!==U.length)return!1;for(let W=0;W<D.length;W++){let K=D[W],te=U[W];if(typeof K=="string"||typeof te=="string"){if(K!==te)return!1}else{if(K.nodeType!==te.nodeType)return!1;if(K.nodeType===1){if(!P(K,te))return!1}else if(K.nodeValue!==te.nodeValue)return!1}}return!0}function X(k,N){let D=[],U=null;for(let W=k.firstChild;W;W=W.nextSibling){if(W.nodeType===3){U=U===null?W.nodeValue:U+W.nodeValue;continue}W.nodeType===1&&N(W)||(U!==null&&(U!==""&&D.push(U),U=null),D.push(W))}return U!==null&&U!==""&&D.push(U),D}function O(k,N,D,U){let W=k.value,K=U?W:N?N.value:"",te=D?D.value:"";le.add(k),N&&le.add(N),D&&le.add(D);let ue=K===te?K:K===W?te:te===W||_==="local"?K:te,Ce={site:"comment",bRun:k,lRun:N,rRun:D,node:null};if(K!==W&&te!==W&&K!==te&&pe({kind:"text",node:null,base:W,local:K,remote:te,resolved:ue},Ce),!N&&!D)return null;let Pe=V.createComment(ue);return Ce.node=Pe,Se.set(Pe,{base:k.nodes,local:N?N.nodes:null,remote:D?D.nodes:null}),Pe}function C(k,N){let D=ke(N,k);if(!D)return null;let U=st(D)?D.parentNode:D.parent,W=st(k)?k.parentNode:k.parent;return ke(N,W)===U?null:N.reverse.get(U)||null}function Z(k){let N=new Set([k]),D=k;for(let U=0;U<64;U++){let W=C(D,Q)||C(D,L);if(!W)return!1;if(W===k||st(k)&&st(W)&&k.contains(W)||N.has(W))return!0;N.add(W),D=W}return!0}function ye(k,N,D){if(!N)return!1;let U=st(k)?k.parentNode:k.parent;return U===N||N.tagName==="TEMPLATE"&&U===N.content}function Re(k,N){let D=se(k),U=ke(Q,D);if(U&&ye(N,U,Q))return!0;let W=ke(L,D);return!!(W&&ye(N,W,L))}}function El(e,t){return e.map.get(t)?_l():{map:{get:r=>r&&r.nodeType===1&&e.map.get(r)||r,has:()=>!0},reverse:{get:r=>e.reverse.get(r)||r,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function _l(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Ol=new Set(["INPUT","OPTION","TEXTAREA"]),Ks=/[\t\n\f\r ]+/;function Nl(e,t,n,r){let o=e.ownerDocument,{provenance:s,textMappers:i}=n,l=r.hooks,a=[],u=[],d=[],h=new Set,f=[],p=[],b=new Map,v=new Set,m=new Map,g=n.conflicts.length>0,y=new Map,I=new Set,Y=new Map,$=(T,re)=>{let oe=Y.get(T);oe||Y.set(T,oe=new Set),oe.add(re)},H=g?new Set:null,z=(T,re,oe)=>{let de=l.beforeAttributeUpdated(T,re,oe);return g&&de===!1&&$(re,T),de},ae=T=>!!T&&(T===e||e.contains(T)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(T)),me=new Map,Q=new Map,L=new Map,Ee=new Set,xe=new Map;(function T(re){let oe=s.get(re);if(oe){if(re.nodeType===1){let ie=oe.local?r.toLive(oe.local):null;ie&&ae(ie)&&ie.nodeType===1&&(me.set(re,ie),Q.set(ie,re))}else if(Array.isArray(oe.local)){let ie=ve(oe.local,oe.local.map(he=>r.toLive(he)).filter(he=>he&&ae(he)&&he.nodeType===re.nodeType));if(ie.length&&(me.set(re,ie[0]),Q.set(ie[0],re),L.set(re,ie)),Array.isArray(oe.caret))for(let he of oe.caret){let w=r.toLive(he.node);if(!w||!ae(w)||w.nodeType!==3)continue;let E=xe.get(w);Array.isArray(E)||xe.set(w,E=[]),E.push({merged:re,from:he.from,to:he.to,flatStart:he.flatStart})}else{let he=0;for(let w of ie)xe.set(w,{merged:re,shift:he}),he+=w.nodeValue.length}}}let de=re.nodeType===1&&re.tagName==="TEMPLATE"&&re.content?re.content.childNodes:re.childNodes;for(let ie of de)T(ie)})(t);let se=new Set;for(let T of me.values())se.add(T);for(let T of L.values())for(let re of T)se.add(re);for(let T of n.segments||[])Me(T);let V=r.restoreFocus===!1?null:rf(o,xe);r.childrenOnly?le(He(e),He(t)):Ve(e,t);for(let{node:T,parent:re}of f)h.has(T)||!T.parentNode||T.nodeType===1&&(r.ignored(T)||yt(T))||qe(T,re);return of(o,V,xe,i,L,m,Ee),{applied:a,moved:u,replaced:d,identities:p,mergedScriptsLive:v,liveOf:me,heldBy:m,runOf:L,keptRuns:Ee,insertedLive:y,vetoed:I,vetoedAttrs:Y,removedVetoes:H};function Se(T,re){let oe=T.slice(re.bs,re.be),de=0;for(;de<oe.length&&de<re.text.length&&oe[de]===re.text[de];)de++;let ie=0;for(;ie<oe.length-de&&ie<re.text.length-de&&oe[oe.length-1-ie]===re.text[re.text.length-1-ie];)ie++;return{bs:re.bs+de,be:re.be-ie,text:re.text.slice(de,re.text.length-ie)}}function ve(T,re){if(!re.length)return re;let oe=[];for(let he of T){let w=he.parentNode;if(!w)continue;let E=b.get(w);if(!E){E=new Set;for(let P=w.firstChild;P;P=P.nextSibling)P.nodeType===3&&E.add(r.toLive(P));b.set(w,E)}oe.includes(E)||oe.push(E)}let de={has:he=>oe.some(w=>w.has(he))},ie=[];for(let he of re){ie.push(he);for(let w=he.nextSibling;w&&w.nodeType===3&&!de.has(w)&&!ie.includes(w);w=w.nextSibling)ie.push(w)}return ie}function Me(T){let re=[];for(let O of T.localNodes){let C=r.toLive(O.node);if(!C||!ae(C)||C.nodeType!==3)return;re.push(C)}let oe=ve(T.localNodes.map(O=>O.node),re);if(!oe.length)return;let de=oe.map(O=>O.nodeValue).join(""),{flatLocal:ie,lToM:he,mapLocal:w}=T;if(de===ie)return;let E=T.textNodes.map(O=>({node:O.node,ms:O.ms,me:O.me})),P=[],x=0;for(let O of oe)P.push(x),x+=O.nodeValue.length;let A=(O,C)=>oe.find((Z,ye)=>P[ye]<=O&&O+C<=P[ye]+Z.nodeValue.length)||null,j=[],G=0;for(let O of Gr(ie,de).map(C=>Se(ie,C))){let C=O.bs+G;G+=O.text.length-(O.be-O.bs);let Z,ye;if(O.be>O.bs){Z=he[O.bs];let Re=Z>=0;for(let k=O.bs;Re&&k<O.be;k++)he[k]!==Z+(k-O.bs)&&(Re=!1);if(!Re)continue;ye=Z+(O.be-O.bs)}else{let Re=O.bs>0?he[O.bs-1]:0,k=O.bs<ie.length?he[O.bs]:0;if(Re<0||k<0)continue;Z=ye=w(O.bs)}j.push({ms:Z,me:ye,text:O.text,live:ye===Z?A(C,O.text.length):null})}j.sort((O,C)=>C.ms-O.ms);let q=(O,C)=>(L.get(O.node)||[me.get(O.node)]).includes(C),X=O=>!!O&&O.nodeType===1&&Mn.has(O.tagName);for(let O of j){let C=E.find(ye=>ye.ms<=O.ms&&O.me<=ye.me&&O.ms<ye.me);if(C&&O.live&&C.ms===O.ms&&!q(C,O.live)){let ye=E.find(Re=>Re.me===O.ms&&q(Re,O.live));ye&&(C=ye)}if(!C&&O.me===O.ms){let ye=E.find(D=>D.me===O.ms),Re=E.find(D=>D.ms===O.ms),k=ye||Re;if(!k)continue;let N=k.node;for(;X(N.parentNode)&&(ye?N.parentNode.lastChild:N.parentNode.firstChild)===N;)N=N.parentNode;if(N===k.node)C=k;else{let D=N.ownerDocument.createTextNode(O.text);N.parentNode.insertBefore(D,ye?N.nextSibling:N);continue}}if(!C)continue;let Z=C.node.nodeValue;C.node.nodeValue=Z.slice(0,O.ms-C.ms)+O.text+Z.slice(O.me-C.ms),C.me+=O.text.length-(O.me-O.ms)}}function He(T){return T.nodeType===1&&T.tagName==="TEMPLATE"&&T.content?T.content:T}function Ve(T,re){h.add(T);let oe=s.get(re);if(oe&&oe.remote&&n.remoteIdOf){let ie=n.remoteIdOf(oe.remote);ie&&p.push([T,ie])}if(oe&&oe.unchanged){n.customIdentity&&oe.remote&&B(T,oe.remote),oe.remote&&_(T,oe.remote);return}if(l.beforeNodeMorphed(T,re)===!1){I.add(re);return}Ue(T,re,r.keepLiveOnly&&oe&&oe.local&&oe.local.nodeType===1&&oe.local!==T?oe.local:null);let de=T.tagName;if(un(T))T.textContent!==re.textContent&&(a.push({kind:"text",node:T,before:T.textContent,after:re.textContent}),T.textContent=re.textContent),n.mergedScripts.has(re)&&v.add(T);else if(de==="TEXTAREA")Ot(T,re,oe);else{wt(T,re,oe);let ie=de==="TEMPLATE"&&T.content?T.content:T,he=de==="TEMPLATE"&&re.content?re.content:re;r.protectFocusedValue==="subtree"&&Je(T)&&T!==o.body?it(ie):le(ie,he)}l.afterNodeMorphed(T,re)}function it(T){for(let re=T.firstChild;re;re=re.nextSibling){let oe=Q.get(re);oe&&me.get(oe.parentNode)!==T||(h.add(re),re.nodeType===1&&it(re))}}function le(T,re){let oe=pe(T.firstChild),de=new Set;for(let ie of Array.from(re.childNodes)){let he=me.get(ie);he&&h.has(he)&&!de.has(he)&&(he=null);let w=s.get(ie);if(w&&w.pinned){he&&he.nodeType===1&&((he.parentNode!==T||pe(he.nextSibling)!==oe)&&Qe(T,he,oe),h.add(he),de.add(he));continue}if(he&&he.nodeType===1){if(he!==oe){let x=he.parentNode;if(x===T&&oe&&kt(he)){let A=he.nextSibling;for(let j=oe;j&&j!==he;){let G=j.nextSibling;Qe(T,j,A),j=G}}else Qe(T,he,oe),x!==T&&(u.push(he),a.push({kind:"move",el:he,from:x,to:T}))}de.add(he),Ve(he,ie),oe=pe(he.nextSibling);continue}if(he&&he.nodeType!==1){let x=L.get(ie)||[he],A=x.map(G=>G.nodeValue).join(""),j=ie.nodeValue;if(ie.nodeType===3){let G=et(ie);G!=null&&A!==G&&(j=Kr(G,A,ie.nodeValue).text)}if(x.length>1&&A===j&&!x.includes(oe,1)&&x.every((G,q)=>G.parentNode===T&&(q===0||x[q-1].nextSibling===G))){if(he!==oe)for(let G of x)Qe(T,G,oe);l.beforeNodeMorphed(he,ie)!==!1?l.afterNodeMorphed(he,ie):g&&I.add(ie);for(let G of x)h.add(G),de.add(G);m.set(ie,he),Ee.add(ie),oe=pe(x[x.length-1].nextSibling);continue}he!==oe&&Qe(T,he,oe),l.beforeNodeMorphed(he,ie)!==!1?(he.nodeValue!==j&&(a.push({kind:"text",node:he,before:he.nodeValue,after:j}),he.nodeValue=j),l.afterNodeMorphed(he,ie)):I.add(ie),h.add(he),de.add(he),m.set(ie,he),oe=pe(he.nextSibling);continue}if(ie.nodeType===3&&oe&&oe.nodeType===3&&!h.has(oe)&&!xe.has(oe)){oe.nodeValue!==ie.nodeValue&&(a.push({kind:"text",node:oe,before:oe.nodeValue,after:ie.nodeValue}),oe.nodeValue=ie.nodeValue),h.add(oe),m.set(ie,oe),oe=pe(oe.nextSibling);continue}let E=s.get(ie),P=rt(E&&E.unchanged&&E.remote?E.remote:ie);if(l.beforeNodeAdded(P)===!1){I.add(ie);continue}T.insertBefore(P,oe),h.add(P),g&&y.set(ie,P),P.nodeType===3&&m.set(ie,P),P.nodeType===1&&(d.push(P),Ae(P,ie),n.customIdentity&&E&&E.unchanged&&E.remote&&B(P,E.remote),un(P)||lt(P,ie),r.formState==="property"&&ht(E)&&_(P,E.remote)),oe=pe(P.nextSibling),a.push({kind:"insert",node:P,parent:T}),l.afterNodeAdded(P)}for(let ie of Array.from(T.childNodes))h.has(ie)||de.has(ie)||ie.nodeType===1&&(r.ignored(ie)||yt(ie))||(se.has(ie)?f.push({node:ie,parent:T}):qe(ie,T))}function yt(T){return r.preserve&&T.parentNode&&T.parentNode.nodeType===1&&T.parentNode.tagName==="HEAD"&&r.preserve(T)===!0}function et(T){let re=s.get(T);return!re||!Array.isArray(re.local)?null:re.local.map(oe=>oe.nodeValue).join("")}function Oe(T){return s.get(T)}function _(T,re){if(!Ol.has(T.tagName)&&!T.querySelector("input,option,textarea"))return;let oe=(de,ie)=>{if(de.tagName!==ie.tagName)return;de.tagName==="TEXTAREA"?Ot(de,ie,{remote:ie}):Ol.has(de.tagName)&&wt(de,ie,{remote:ie});let he=fe(de),w=fe(ie);if(he.length===w.length)for(let E=0;E<he.length;E++)oe(he[E],w[E])};oe(T,re)}function B(T,re){let oe=fe(T),de=fe(re);if(oe.length===de.length)for(let ie=0;ie<oe.length;ie++){let he=n.remoteIdOf(de[ie]);he&&p.push([oe[ie],he]),B(oe[ie],de[ie])}}function fe(T){let re=T.tagName==="TEMPLATE"&&T.content?T.content:T;return Array.from(re.children).filter(oe=>!r.ignored(oe))}function Ae(T,re){if(!n.remoteIdOf)return;let oe=(de,ie)=>{let he=s.get(ie);if(he&&he.remote&&ie.nodeType===1){let P=n.remoteIdOf(he.remote);P&&p.push([de,P])}let w=de.childNodes,E=ie.childNodes;for(let P=0;P<w.length&&P<E.length;P++)oe(w[P],E[P])};oe(T,re)}function pe(T){for(;T&&T.nodeType===1&&r.ignored(T);)T=T.nextSibling;return T}function Qe(T,re,oe){if(typeof T.moveBefore=="function"&&re.ownerDocument===T.ownerDocument)try{T.moveBefore(re,oe);return}catch{}T.insertBefore(re,oe)}function qe(T,re){if(l.beforeNodeRemoved(T)===!1){g&&H.add(T);return}T.parentNode.removeChild(T),a.push({kind:"remove",node:T,parent:re}),l.afterNodeRemoved(T)}function rt(T){if(un(T))return Yr(T,o);let re=o.importNode(T,!0);if(re.nodeType===1)for(let oe of Array.from(re.querySelectorAll("script")))un(oe)&&oe.replaceWith(Yr(oe,o));return re}function lt(T,re){let oe=T.tagName==="TEMPLATE"&&T.content?T.content:T,de=re.tagName==="TEMPLATE"&&re.content?re.content:re,ie=Array.from(oe.childNodes),he=Array.from(de.childNodes);for(let w=0;w<he.length&&w<ie.length;w++){let E=he[w],P=ie[w],x=me.get(E);x&&h.has(x)&&(x=null);let A=s.get(E);if(A&&A.pinned){if(x&&x.nodeType===1){let j=x.parentNode;Qe(oe,x,P),j!==oe&&(u.push(x),a.push({kind:"move",el:x,from:j,to:oe})),h.add(x)}P.remove();continue}if(x){let j=x.parentNode;Qe(oe,x,P),P.remove(),x.nodeType===1?(j!==oe&&(u.push(x),a.push({kind:"move",el:x,from:j,to:oe})),Ve(x,E)):(h.add(x),m.set(E,x),x.nodeValue!==E.nodeValue&&(a.push({kind:"text",node:x,before:x.nodeValue,after:E.nodeValue}),x.nodeValue=E.nodeValue));continue}h.add(P),g&&y.set(E,P),P.nodeType===3&&m.set(E,P),A&&A.unchanged&&A.remote?(ee(P,A.remote),n.customIdentity&&B(P,A.remote)):E.nodeType===1&&!un(E)&&lt(P,E)}}function ee(T,re){let oe=T.tagName==="TEMPLATE"&&T.content?T.content:T,de=re.tagName==="TEMPLATE"&&re.content?re.content:re;for(let ie of Array.from(de.childNodes))oe.appendChild(rt(ie))}function ce(T,re){return re.namespaceURI?T.getAttributeNS(re.namespaceURI,re.localName):T.getAttribute(re.name)}function ge(T,re){let oe=new Set((re||"").split(Ks).filter(Boolean));return(T||"").split(Ks).filter(de=>de&&!oe.has(de))}function Ue(T,re,oe){for(let de of Array.from(re.attributes)){if(ke(T,de.name)||r.ignoreAttribute(T,de.name))continue;let ie=ce(T,de);if(ie===de.value||oe&&ce(oe,de)===de.value)continue;let he=de.value;if(oe&&de.name==="class"&&!de.namespaceURI){let w=de.value.split(Ks).filter(Boolean),E=ge(ie,oe.getAttribute("class")).filter(P=>!w.includes(P));E.length&&(he=[...w,...E].join(" "))}if(ie!==he){if(l.beforeAttributeUpdated(de.name,T,"update")===!1){g&&$(re,de.name);continue}de.namespaceURI?T.setAttributeNS(de.namespaceURI,de.name,he):T.setAttribute(de.name,he),a.push({kind:"attr",el:T,name:de.name,before:ie,after:he})}}for(let de of Array.from(T.attributes)){if(ke(T,de.name)||r.ignoreAttribute(T,de.name)||(de.namespaceURI?re.hasAttributeNS(de.namespaceURI,de.localName):re.hasAttribute(de.name)))continue;if(oe&&de.name==="class"&&!de.namespaceURI){let w=ge(de.value,oe.getAttribute("class"));if(w.length){let E=w.join(" ");if(E===de.value)continue;if(l.beforeAttributeUpdated("class",T,"update")===!1){g&&$(re,"class");continue}T.setAttribute("class",E),a.push({kind:"attr",el:T,name:"class",before:de.value,after:E});continue}}if(oe&&ce(oe,de)===null)continue;if(l.beforeAttributeUpdated(de.name,T,"remove")===!1){g&&$(re,de.name);continue}let he=de.value;de.namespaceURI?T.removeAttributeNS(de.namespaceURI,de.localName):T.removeAttribute(de.name),a.push({kind:"attr",el:T,name:de.name,before:he,after:null})}}function ke(T,re){let oe=T.tagName;return oe==="INPUT"?re==="value"||re==="checked"||re==="disabled":oe==="OPTION"?re==="selected":!1}function Je(T){return T===o.activeElement}function kt(T){let re=o.activeElement;return!!re&&re!==o.body&&T.contains(re)}function ht(T){let re=T&&T.remote;return re&&re.nodeType===1?re:null}function wt(T,re,oe){let de=T.tagName,ie=ht(oe),he=r.formState==="property"&&ie?ie:re;if(de==="INPUT"){let w=r.protectFocusedValue&&Je(T),E=(T.getAttribute("type")||"").toLowerCase(),P=E!=="file"&&E!=="checkbox"&&E!=="radio",x=ie&&ie.hasAttribute("value")&&ie.value!==ie.getAttribute("value")?ie.value:null;if(P&&!w)if(r.formState==="property"){let A=re.getAttribute("value"),j=T.getAttribute("value");(j!==A||T.value!==he.value)&&z("value",T,A==null?"remove":"update")!==!1&&(j!==A&&(A==null?T.removeAttribute("value"):T.setAttribute("value",A),a.push({kind:"attr",el:T,name:"value",before:j,after:A})),T.value!==he.value&&(T.value=he.value))}else if(re.hasAttribute("value")||x!=null){let A=x??re.getAttribute("value");T.getAttribute("value")!==A&&z("value",T,"update")!==!1?(T.setAttribute("value",A),T.value!==A&&(T.value=A),a.push({kind:"attr",el:T,name:"value",before:null,after:A})):T.value!==A&&T.getAttribute("value")===A&&(T.value=A)}else(T.hasAttribute("value")||T.value!=="")&&z("value",T,"remove")!==!1&&(T.removeAttribute("value"),T.value="",a.push({kind:"attr",el:T,name:"value",before:"",after:null}));if(!P&&E!=="file"){let A=re.getAttribute("value");A==null?T.hasAttribute("value")&&z("value",T,"remove")!==!1&&T.removeAttribute("value"):T.getAttribute("value")!==A&&z("value",T,"update")!==!1&&T.setAttribute("value",A)}w||(ze(T,he,"checked"),r.formState==="property"&&T.indeterminate!==he.indeterminate&&(T.indeterminate=he.indeterminate)),ze(T,he,"disabled")}else if(de==="OPTION"){let w=T.parentNode&&T.closest("select");r.protectFocusedValue&&w&&Je(w)||ze(T,he,"selected")}}function ze(T,re,oe){let de=r.formState==="property"?!!re[oe]:re.hasAttribute(oe);if(r.formState!=="property"){let ie=T.hasAttribute(oe);if(ie!==de){if(z(oe,T,de?"update":"remove")===!1)return;de?T.setAttribute(oe,""):T.removeAttribute(oe),a.push({kind:"attr",el:T,name:oe,before:ie?"":null,after:de?"":null})}}T[oe]!==de&&(T[oe]=de)}function Ot(T,re,oe){if(r.protectFocusedValue&&Je(T)||z("value",T,"update")===!1)return;let de=ht(oe),ie=re.textContent,he=de&&de.value!==de.defaultValue?de.value:ie;r.formState!=="property"&&T.textContent!==ie&&(a.push({kind:"text",node:T,before:T.textContent,after:ie}),T.textContent=ie),T.value!==he&&(T.value=he)}}function rf(e,t){let n=e.activeElement;if(!n||n===e.body||n===e.documentElement)return null;let r={el:n,id:n.getAttribute&&n.getAttribute("id"),scrollTop:n.scrollTop,scrollLeft:n.scrollLeft};if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"){try{r.selection=[n.selectionStart,n.selectionEnd,n.selectionDirection]}catch{}return r}let o=e.getSelection&&e.getSelection();if(o&&o.rangeCount){let s=o.getRangeAt(0);r.range={sc:s.startContainer,so:s.startOffset,ec:s.endContainer,eo:s.endOffset}}return r}function of(e,t,n,r,o,s,i){if(!t)return;let l=t.el;if(!l.isConnected&&t.id&&(l=e.getElementById(t.id)),!l||!l.isConnected)return;if(e.activeElement!==l)try{l.focus({preventScroll:!0})}catch{}try{l.scrollTop=t.scrollTop,l.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{l.setSelectionRange&&!l.selectionEnd&&t.selection[1]!=null&&l.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let a=(h,f)=>{let p=n.get(h);if(Array.isArray(p)){let b=p.find(y=>f>=y.from&&f<y.to)||p.find(y=>f===y.to)||p[p.length-1],v=s.get(b.merged);if(!v||!v.isConnected)return null;let m=r.get(b.merged),g=m&&m.flat?m.flat(b.flatStart+f):f;return[v,Math.max(0,Math.min(g,v.nodeValue.length))]}if(p&&!i.has(p.merged)){let b=(o.get(p.merged)||[h])[0];if(!b.isConnected)return null;let v=r.get(p.merged),m=p.shift+f,g=v?v(m):m;return[b,Math.max(0,Math.min(g,b.nodeValue.length))]}return h.isConnected?[h,Math.min(f,h.nodeType===3?h.nodeValue.length:h.childNodes.length)]:null},u=a(t.range.sc,t.range.so),d=a(t.range.ec,t.range.eo);if(!(!u||!d))try{let h=e.createRange();h.setStart(u[0],u[1]),h.setEnd(d[0],d[1]);let f=e.getSelection();f.removeAllRanges(),f.addRange(h)}catch{}}var sf={compared:0},lf=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function af(e,t,n){let r=0;for(let o of e.attributes)if(!n(e,o.name)&&(r++,t.getAttribute(o.name)!==o.value))return!1;for(let o of t.attributes)n(t,o.name)||r--;return r===0}function Gs(e,t){if(e.namespaceURI!==t.namespaceURI||e.prefix!==t.prefix||e.localName!==t.localName)return!1;let n=e.attributes;if(n.length!==t.attributes.length)return!1;for(let r of n)if(t.getAttributeNS(r.namespaceURI,r.localName)!==r.value)return!1;return!0}function Cl(e,t,n,r,o,s,i,l){let a=new Map,u=new Set,d=h=>{if(r(h))return;let f=n(h);f&&(s.add(f),o.has(f)||a.has(f)?u.add(f):a.set(f,h))};for(let h of e)d(h);d(t);for(let h of i||t.querySelectorAll("*"))d(h);for(let h of u)a.delete(h),l.add(h);return a}function Ml(e,t,n,r,o,s){let i=!1;for(let d of o)d.startsWith("merge:")&&(i=!0);if(!i)return[...r];let l=new Map,a=[],u=s===bn?Jr:"*";for(let d of[e,...e.querySelectorAll(u)]){if(n(d))continue;let h=t(d);if(!h||!(r.has(h)||o.has(h)))continue;let f=(l.get(h)||0)+1;l.set(h,f),f===2&&a.push(h)}return a}function Rl({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:r,o,identity:s,baseURI:i}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!af(e,t,o.ignoreAttribute))return{bail:"root-attrs"};let{ignored:l,remoteWins:a}=o,u=Ws(o.scripts.merge===!1?null:o.scripts.mergeTags,i),d=Oe=>{let _=u(Oe);return _!==null?_:s.base(Oe)||null},h=Oe=>{let _=u(Oe);return _!==null?_:s.remote(Oe)||null},f=[],p=[],b=new Map,v=new Map,m={same:b,differ:v},g=Oe=>({bail:Oe,comparisons:m}),y=(Oe,_,B=!0)=>{if(b.get(Oe)===_)return!0;if(v.get(Oe)===_)return!1;if(sf.compared++,B&&Oe.isEqualNode(_))return b.set(Oe,_),!0;let fe=Oe.nodeType===_.nodeType;if(fe&&Oe.nodeType===1){if(fe=Gs(Oe,_),fe){let Ae=Oe.firstChild,pe=_.firstChild;for(;Ae&&pe;Ae=Ae.nextSibling,pe=pe.nextSibling)if(!y(Ae,pe,!1)){fe=!1;break}(Ae||pe)&&(fe=!1)}}else fe&&(fe=Oe.isEqualNode(_));return(fe?b:v).set(Oe,_),fe},I=e,Y=t,$=!1,H=()=>{b.set(I,Y);for(let Oe=0;Oe<f.length;Oe++)b.set(f[Oe],p[Oe]);return g("equal")};for(;;){let Oe=I.childNodes,_=Y.childNodes;if(Oe.length!==_.length)break;let B=lt=>y(Oe[lt],_[lt])?(b.set(Oe[lt],_[lt]),!1):!0,fe=-1,Ae=-1;for(let lt=0;lt<Oe.length;lt++){if(Oe[lt].nodeType!==1)continue;let ee=0;for(let ce=Oe[lt].firstElementChild;ce;ce=ce.nextElementSibling)ee++;ee>=Ae&&(Ae=ee,fe=lt)}let pe=[],Qe=!1;for(let lt=0;lt<Oe.length&&pe.length<2;lt++)lt!==fe&&B(lt)&&pe.push(lt);if(fe>=0&&pe.length<2&&(pe.length===0&&Gs(I,Y)?(pe.push(fe),Qe=!0):B(fe)&&pe.push(fe)),pe.length!==1){if(!$&&pe.length===0&&Gs(I,Y))return H();break}let qe=Oe[pe[0]],rt=_[pe[0]];if($=$||!Qe,$&&v.set(qe,rt),qe.nodeType!==1||rt.nodeType!==1||qe.tagName!==rt.tagName)break;if(d(qe)!==h(rt)){if(!$&&y(qe,rt))return H();break}f.push(I),p.push(Y),I=qe,Y=rt}v.set(I,Y);for(let Oe=0;Oe<f.length;Oe++)v.set(f[Oe],p[Oe]);if(I===e||I.tagName==="HEAD"||I.tagName==="BODY")return g("root-level");if(f.length<2||f[1].tagName!=="BODY")return g("not-in-body");if(l(I)||l(Y))return g("ignored-ancestor");if(a(I)||a(Y))return g("remote-wins-ancestor");for(let Oe of f)if(lf.has(Oe.tagName))return g("form-ancestor");if(I.tagName==="SCRIPT"||I.getElementsByTagName("script").length||Y.getElementsByTagName("script").length)return g("script-or-template");let z=r(I);if(!z||z.nodeType!==1||z.tagName!==I.tagName)return g("no-live-twin");if(!n.contains(z))return g("live-detached");for(let Oe of f){let _=r(Oe);if(!_||_.nodeType!==1)return g("ancestor-live")}let ae=s.base===bn&&s.remote===bn&&l===Ts,me=new Set,Q=new Set,L=[],Ee=null,xe=Oe=>{Oe&&(me.has(Oe)?Q.add(Oe):me.add(Oe))},se=(Oe,_)=>{let B=u(Oe),fe=B!==null?B:s.base(Oe)||null;return fe!==(B!==null?B:s.remote(_)||null)?!1:(xe(fe),!0)},V=(Oe,_)=>{for(let B=Oe.firstElementChild,fe=_.firstElementChild;B;B=B.nextElementSibling,fe=fe.nextElementSibling){let Ae=l(B);if(Ae!==l(fe))return!1;if(!Ae&&(!se(B,fe)||!V(B,fe)))return!1}return!0},Se=Oe=>{let _=Oe+1<f.length?f[Oe+1]:I;for(let B=f[Oe].firstElementChild,fe=p[Oe].firstElementChild;B;B=B.nextElementSibling,fe=fe.nextElementSibling){if(B===_){let Qe=Oe+1<f.length?Se(Oe+1):null;if(Qe)return Qe;continue}let Ae=l(B);if(Ae!==l(fe))return"outside-id-changed";if(Ae)continue;let pe=r(B);if(!pe||pe.nodeType!==1)return"sibling-live";if(L.push([B,fe]),!ae&&(!se(B,fe)||!V(B,fe)))return"outside-id-changed";Oe===0&&B.tagName==="HEAD"&&d(B)&&(Ee=[B,fe])}return null},ve=Se(0);if(ve)return g(ve);let Me=new Set(f),He=null;if(s.base===bn){He=[];for(let Oe of e.querySelectorAll(Jr))Oe===I||Me.has(Oe)||(I.contains(Oe)?He.push(Oe):ae&&xe(d(Oe)))}let Ve=new Set,it=new Set,le=new Set,yt=Cl(f,I,d,l,me,Ve,He,it),et=Cl(p,Y,h,l,me,Ve,s.remote===bn&&Y.querySelectorAll(Jr),le);return Ee&&(Q.has(d(Ee[0]))||Ve.has(d(Ee[0])))&&(Ee=null),{scope:{chain:f,root:I,onChain:Me,baseIndex:yt,remoteIndex:et,head:Ee,same:b,differ:v,dropped:[...Ml(e,d,l,Q,it,s.base),...Ml(t,h,l,Q,le,s.remote)],held:Oe=>{for(let _=1;_<f.length;_++)if(Oe.map.get(f[_])!==p[_])return!1;for(let[_,B]of L)if(Oe.map.get(_)!==B)return!1;return!0}}}}var jp=Symbol("hyper-morph-duplicate-key");var cf='[editor-ui],[clay~="editor-ui"],[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]',uf='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',ff='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function df(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let t=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(t)}function hf(e,t,n,r){if(t==null)return;if(typeof t=="string")return t;let o=t;if(o.nodeType===9){let s=e.getAttribute("id");o=s&&o.getElementById(s)||(e.tagName==="BODY"?o.body:e.tagName==="HTML"?o.documentElement:o.body&&o.body.firstElementChild)}if((!o||o.nodeType!==1||o.tagName!==e.tagName)&&(o=mf(e,t,r)),!!o)return n?Array.from(o.childNodes):o}function mf(e,t,n){let r=t.nodeType===9?t.documentElement:t;if(!r||r.nodeType!==1)return null;let o=new Map,s=[r,...r.querySelectorAll("script")];for(let a of s){let u=vr(a,n);u&&!o.has(u.key)&&o.set(u.key,a.textContent)}if(!o.size)return null;let i=e.cloneNode(!0),l=!1;for(let a of[i,...i.querySelectorAll("script")]){let u=vr(a,n);u&&o.has(u.key)&&(a.textContent=o.get(u.key),l=!0)}return l?i:null}function Ll(e,t){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let n=t.implementation.createHTMLDocument(""),r=e.nodeType===1&&e.tagName==="HTML"?e:null;if(r)return n.replaceChild(n.adoptNode(r),n.documentElement),n;let o=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let s of o)n.body.appendChild(n.adoptNode(s));return n}function Kn(e,t,n={}){let r=n||{};if(!r.head?.block)return Il(e,t,r);try{return Il(e,t,r)}catch(o){return Promise.reject(o)}}function Il(e,t,n){let r=n.policy||"sync",o=r==="raw"?void 0:(a,u)=>df(a)||(r==="history"?!(u&&a.matches(ff))&&a.matches(uf):a.matches(cf)),s=n.callbacks||{},i={ignore:o,hooks:s,protectFocusedValue:n.ignoreActiveValue===!0?"subtree":!1,restoreFocus:n.restoreFocus!==!1,formState:n.formStateSync||"attribute",scripts:{execute:n.scripts?.handle!==!1,merge:n.scripts?.merge!==!1,mergeTags:n.scripts?.mergeTags||[]},head:{awaitLoads:!!n.head?.block,preserve:n.head?.shouldPreserve||(()=>!1)}};if(typeof n.key=="function"&&(i.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return Zr(Object.assign({},i,{live:e,base:n.scripts?.mergeBase||null,remote:Ll(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let a=Object.assign({},i,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:Ll(t,e.ownerDocument)});return Zr(a)}n.morphStyle==="innerHTML"&&(i.children=!0);let l=hf(e,n.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return l!==void 0&&(i.base=l),Ys(e,t,i)}var pf=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),wn=()=>{};function Qr(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let i of Object.keys(e))if(!pf.has(i))throw new TypeError(`unknown option "${i}"`);let n=Object.assign({beforeNodeAdded:wn,afterNodeAdded:wn,beforeNodeRemoved:wn,afterNodeRemoved:wn,beforeNodeMorphed:wn,afterNodeMorphed:wn,beforeAttributeUpdated:wn},e.hooks||{}),r=e.conflicts||"remote";if(!["remote","local","both"].includes(r))throw new TypeError("conflicts must be remote, local or both");let o=e.formState||"attribute";if(!["attribute","property"].includes(o))throw new TypeError("formState must be attribute or property");let s=e.protectFocusedValue;if(s!==void 0&&typeof s!="boolean"&&s!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");return{ignored:Es(e.ignore,t),remoteWins:Es(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:r,protectFocusedValue:s===void 0?!0:s,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:o,hooks:n,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0}}function Ar(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return bn}function Sr(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=_s(t,e.map),r=typeof e.then=="function"?e.then:bn;if(typeof e.first=="function"){let o=e.first;return s=>o(s)||n.get(s)||r(s)}return o=>n.get(o)||r(o)}return bn}function gf(e,t,n,r={}){let o=p=>p&&p.nodeType===9?p.documentElement:p,s=o(t),i=o(n),l=o(e)||s,a=Object.assign({},r);delete a.live,delete a.base,delete a.remote;let u=Qr(a,[l,s,i].filter(Boolean)),d=r.identity||{},h=Un(),f=Io(l,s,i,{identity:{base:Sr(d.base,l),local:Sr(d.local,s),remote:Sr(d.remote,i)},authored:{base:Ar(d.base),local:Ar(d.local),remote:Ar(d.remote)},skipUnchanged:u.hooks.beforeNodeMorphed===wn&&u.hooks.afterNodeMorphed===wn,ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:s.ownerDocument&&s.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:u.children,stats:h});return delete f.recoveryLinks,f}function Xs({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:r,toLive:o,options:s,identity:i,childrenOnly:l,isDocument:a}){let u=Qr(s,[e,t,n,r].filter(Boolean));if(u.ignored(e))return{report:Js(),loads:[]};let d=e.ownerDocument,h=u.scripts.execute?fl(e,u.ignored,d.baseURI):null,f=Un(),p=u.hooks.beforeNodeMorphed===wn&&u.hooks.afterNodeMorphed===wn,b={identity:{base:Sr(i.base,t||n),local:Sr(i.local,n),remote:Sr(i.remote,r)},authored:{base:Ar(i.base),local:Ar(i.local),remote:Ar(i.remote)},ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:d.baseURI,localIsBase:!t,childrenOnly:l,skipUnchanged:p},v=u.fastPath&&a&&!l&&p&&t===n,m=null,g=null;if(v){let xe=Rl({baseRoot:t,remoteRoot:r,liveRoot:e,toLive:o,o:u,identity:b.identity,baseURI:d.baseURI});b.comparisons=xe.comparisons||xe.scope,xe.bail?g=xe.bail:(m=Io(t,n,r,Object.assign({},b,{stats:f,scope:xe.scope})),m||(g="chain-unpaired",f=Un()))}m||(m=Io(t||n,n,r,Object.assign({},b,{stats:f}))),v&&(f.fastPathAttempted=1,f.fastPathTaken=g?0:1,f.fastPathFallback=g),m.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(xe=>u.hooks[xe]!==wn)&&vl(m.conflicts,m.recoveryLinks,o),u.beforeApply&&u.beforeApply(m.doc);let y=globalThis.__hyperMorphProfile,I=y?performance.now():0,Y=Nl(e,m.root,m,{toLive:o,ignored:u.ignored,ignoreAttribute:u.ignoreAttribute,formState:u.formState,protectFocusedValue:u.protectFocusedValue,restoreFocus:u.restoreFocus,preserve:u.head.preserve,hooks:u.hooks,childrenOnly:l,keepLiveOnly:u.keepLiveOnly});y&&(y.apply=(y.apply||0)+(performance.now()-I));let $=[];if(u.head.awaitLoads)for(let xe of Y.applied){if(xe.kind!=="insert"||xe.node.nodeType!==1)continue;let se=xe.node;se.tagName==="LINK"&&/\bstylesheet\b/i.test(se.getAttribute("rel")||"")&&se.getAttribute("href")&&se.closest("head")&&$.push(new Promise(Se=>{se.addEventListener("load",()=>Se()),se.addEventListener("error",()=>Se())}))}let H=null,z=null;if(h){let xe=dl(e,h,{ignored:u.ignored,skip:Y.mergedScriptsLive,baseURI:d.baseURI,beforeNodeAdded:u.hooks.beforeNodeAdded,afterNodeAdded:u.hooks.afterNodeAdded,trackRecovery:!!m.recoveryLinks});$.push(...xe.loads),H=xe.swapped,z=xe.vetoed}let ae=xe=>H&&H.get(xe)||xe,me=xe=>{if(Y.keptRuns.has(xe))return Y.runOf.get(xe);let se=Y.liveOf.get(xe)||Y.heldBy.get(xe)||Y.insertedLive.get(xe);return se?ae(se):null},Q=xe=>{let se=xe&&Y.liveOf.get(xe);return se?ae(se):null},L=xe=>{let se=xe&&me(xe);return Array.isArray(se)?se[0]:se};if(m.recoveryLinks){let xe=(se,V,Se)=>(V.namespaceURI?se.getAttributeNS(V.namespaceURI,V.localName):se.getAttribute(V.qualifiedName))===Se;Sl(m.conflicts,m.recoveryLinks,{lookup:me,vetoed:Y.vetoed,vetoedAttrs:Y.vetoedAttrs,removedVetoes:Y.removedVetoes,vetoedLive:z,liveAttr:xe,ignored:u.ignored,liveRoot:e})}return{report:{applied:Y.applied,decisions:m.decisions.map(xe=>Object.assign({},xe,{node:xe.node?Q(xe.node):null,el:xe.el?Q(xe.el):null,applied:!!(xe.node?Q(xe.node):xe.el&&Q(xe.el))})),conflicts:m.conflicts.map(xe=>Object.assign({},xe,{node:xe.node?xe.kind==="text"&&xe.recovery.subject.nodeType===8?L(xe.node):Q(xe.node):xe.node,el:xe.el?xe.kind==="structure"?L(xe.el):Q(xe.el):xe.el})),localDiverged:m.localDiverged,identities:Y.identities,moved:Y.moved,replaced:Y.replaced,stats:f},loads:$}}var jl=new WeakMap;function Js(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Un()}}function Zr(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let r=jl.get(n);r||(r=Ss(n),jl.set(n,r));let o=r("remote",t.remote),s=typeof t.base=="string"&&t.base===""?null:t.base,i=s?r("base",s):null,l=t.local?t.local.root:n.documentElement,a=t.local?t.local.toLive:h=>h;Xi(n,o);let{report:u,loads:d}=Xs({liveRoot:n.documentElement,baseRoot:i?i.documentElement:null,localRoot:l,remoteRoot:o.documentElement,toLive:a,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(d).then(()=>u)}function bf(e,t,n={}){return Zr(Object.assign({},n,{live:e,base:null,remote:t}))}function Pl(e,t){if(e==null)return{root:t.createElement("template"),first:null};if(typeof e=="string"){let r=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(r){let s=Eo(e,t),i=r[1].toLowerCase()==="html"?s.documentElement:s.body;return{root:i,first:i}}let o=t.createElement("template");return o.innerHTML=e,{root:o,first:o.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let r=t.createElement("template"),o=e.isConnected;return r.content.appendChild(o?t.importNode(e,!0):e),{root:r,first:e}}if(e.nodeType===11){let r=t.createElement("template");return r.content.appendChild(e),{root:r,first:r.content.firstElementChild}}let n=t.createElement("template");for(let r of Array.from(e))n.content.appendChild(r.parentNode?t.importNode(r,!0):r);return{root:n,first:n.content.firstElementChild}}function Ys(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let r=e.ownerDocument,{base:o,...s}=n,i=!!s.children;if(Qr(s,[e]).ignored(e))return Promise.resolve(Js());let l=Pl(t,r),a=o!=null?Pl(o,r):null,u,d=null;if(i)u=l.root,d=a?a.root:null;else{if(u=l.first,d=a?a.first:null,!u){let p=Qr(s);return p.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),p.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Un()})}if(u.tagName!==e.tagName){let p=Qr(s,[e,u]);if(p.hooks.beforeNodeMorphed(e,u)===!1)return Promise.resolve(Js());let b=Xs({liveRoot:e,baseRoot:d&&d.tagName===e.tagName?d:null,localRoot:e,remoteRoot:u,toLive:m=>m,options:s,identity:s.identity||{},childrenOnly:!0,isDocument:!1}),v=un(u)?Yr(u,r):r.importNode(u,!1);if(!un(v))for(;e.firstChild;)v.appendChild(e.firstChild);return p.hooks.beforeNodeAdded(v)===!1?(Lo(b.report.conflicts,e,e),Promise.resolve(b.report)):p.hooks.beforeNodeRemoved(e)===!1?(Lo(b.report.conflicts,e,e),Promise.resolve(b.report)):(e.replaceWith(v),Lo(b.report.conflicts,e,v),p.hooks.afterNodeRemoved(e),p.hooks.afterNodeAdded(v),p.hooks.afterNodeMorphed(e,u),b.report.replaced.push(v),b.report.applied.push({kind:"insert",node:v,parent:v.parentNode},{kind:"remove",node:e,parent:v.parentNode}),Promise.all(b.loads).then(()=>b.report))}}let{report:h,loads:f}=Xs({liveRoot:e,baseRoot:d,localRoot:e,remoteRoot:u,toLive:p=>p,options:s,identity:s.identity||{},childrenOnly:i,isDocument:!1});return Promise.all(f).then(()=>h)}var Zs={mergeDocument:Zr,morphDocument:bf,morphElement:Ys,merge3:gf,morph:Kn};var jo=["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"],Qs=new Set(jo),Dl=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),eo=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Do={};As(Do,{EmptyListInsert:()=>no,MAX_RULE_DEPTH:()=>_r,MaxRuleDepthExceeded:()=>ar,NoRulesTag:()=>ei,RuleTargetReadOnly:()=>ro,RulesParseError:()=>Tr,ShapeMismatch:()=>to,UnknownRulesVersion:()=>Er,WriteRefused:()=>Po,WriteRejected:()=>ti});var Tr=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},Er=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},_r=20,ar=class extends Error{constructor(t){super(`rule depth exceeded ${_r} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},to=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},no=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}},ro=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},Po=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}},ei=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},ti=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};function Gn(e,t,n,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return ni(e,t,n,{depth:0,path:[]},r)}function ni(e,t,n,r,o){if(r.depth>_r)throw new ar(r.path);if(typeof n=="string")return wf(e,t,n,r,o);if(Array.isArray(n)){let[s,i]=n,l=e.find(t,s,o);return ql(o,r,l),l.map((a,u)=>ni(e,a,i,{depth:r.depth+1,path:[...r.path,u]},o))}if(typeof n=="object"&&n!==null){let s={};for(let[i,l]of Object.entries(n))s[i]=ni(e,t,l,{depth:r.depth+1,path:[...r.path,i]},o);return s}return null}function wf(e,t,n,r,o){if(n.endsWith("[]")){let l=n.slice(0,-2),a=e.find(t,l,o);return ql(o,r,a),a.map(u=>e.text(u))}if(n.startsWith("@"))return Fl(e,t,n.slice(1));let s=Vt(n);if(s!==-1){let l=n.slice(0,s),a=n.slice(s+1),u=l?e.find(t,l,o):[t];return u.length===0?null:Fl(e,u[0],a)}if(n===".")return e.text(t);let i=e.find(t,n,o);return i.length===0?null:e.text(i[0])}function ql(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(r){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,r)}}function Fl(e,t,n){if(Qs.has(n)){let o=e.prop(t,n);return o==null?null:String(o)}let r=e.attr(t,n);return r||null}var Bl=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"]})}),Af=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Hl=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function ri(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Sf(e,t){if(ri(e,t))return!0;for(let[n,r]of Object.entries(Af))if(r.includes(t)&&ri(e,n))return!0;return!1}function oo(e){let t=Bl[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Tf(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=Bl[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>Sf(n,o))||r.bundles.some(o=>ri(n,o)))return n;n=n.parentElement}return null}function $l(e,t){return!!Tf(e,t)}var Ef=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Ul(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="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 r=0;r<e.options.length;r++)t.options[r].selected=e.options[r].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function zl(e,t,n,r){if(r)return!!e.closest?.(t);let o=e;for(;o?.nodeType===1;){if(o.matches(t))return!0;if(o===n)break;o=o.parentElement}return!1}function Vl(e,t,n,r,o,s,i,l){if(e.nodeType===1&&((i?$l(e,n):zl(e,r,s,!1))||o&&(i&&e!==s?e.matches(o):zl(e,o,s,i))))return null;let a=t.importNode(e,!1);l.cloneToLive.set(a,e),l.liveToClone.set(e,a);let u=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,d=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;u!==e&&(l.cloneToLive.set(d,u),l.liveToClone.set(u,d));for(let h of u.childNodes||[]){let f=Vl(h,t,n,r,o,s,i,l);f&&(d.appendChild(f),h.nodeType===1&&Ul(h,f))}return e.nodeType===1&&Ul(e,a),a}function so(e,{capability:t="data",exclude:n=null,inherit:r=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=o.implementation.createHTMLDocument(""),i=new WeakMap,l=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let u=oo(t),d=Vl(a,s,t,u,n,a,r,{cloneToLive:i,liveToClone:l});e.nodeType===9&&d&&(s.replaceChild(d,s.documentElement),l.set(e,s),i.set(s,e));let h=f=>{if(Ef.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:d,document:s,capability:t,selector:oo(t),cloneToLive:i,liveToClone:l,original(f){return i.get(f)||null},cloneOf(f){return l.get(f)||null},query(f,p=d){return h(f),Array.from(p.querySelectorAll(f),b=>i.get(b)||b)},text(f=d){return(f===d?d:l.get(f))?.textContent||""},html(f=d){return(f===d?d:l.get(f))?.innerHTML??""},clone(f=d){let p=f===d?d:l.get(f);return p?s.importNode(p,!0):null}}}function Wl(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function _f(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var Xt={semanticExclude:!0,find(e,t,n={}){let r=_f(e);if(!r||!r.querySelectorAll)return[];let o=Array.from(r.querySelectorAll(t));n.includeRulesTag||(o=o.filter(l=>!Wl(l)));let s=[];n.skip&&s.push(n.skip);let i=n.templateAttr===null?null:n.templateAttr||"cms-template";if(i&&s.push("["+i+"]"),s.length){let l=s.join(", ");o=o.filter(a=>!a.closest||!a.closest(l))}return o},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,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let r=e?e[t]:void 0;return r!==void 0?r:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let r=e.children[n]||null;e.insertBefore(t,r)},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 r=e.ownerDocument.createElement("template");r.innerHTML=t;let o=r.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function jn(e,t={}){if(t.exclude===null)return Xt;let n=[oo("data"),t.exclude].filter(Boolean).join(", "),r=e.nodeType===9?e:e.ownerDocument||e,o=e.nodeType===9?e.documentElement:e;if(!t._write&&!o?.matches?.(n)&&!o?.querySelector?.(n)&&!r?.querySelector?.(n))return Xt;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,i=e.nodeType===9?e:e.ownerDocument,l=null,a=()=>l||(l=so(s,{capability:"data",exclude:t.exclude||null})),u=b=>{let v=a();return b===e?v.cloneOf(e):v.cloneOf(b)||b},d=b=>l?.original(b)||b,h=(b,v)=>{a().liveToClone.set(b,v),a().cloneToLive.set(v,b);let m=b.childNodes||[],g=v.childNodes||[];for(let y=0;y<Math.min(m.length,g.length);y++)h(m[y],g[y])},f=(b,v,m,g)=>{let y=Array.from(b.childNodes).filter(z=>l.cloneOf(z)),Y=y[0];for(;Y&&y.includes(Y);)Y=Y.nextSibling;for(let z of y)z.remove();if(m==="innerHTML"){let z=i.createElement("template");z.innerHTML=g;for(let ae of Array.from(z.content.childNodes))b.insertBefore(ae,Y||null)}else b.insertBefore(i.createTextNode(g),Y||null);let $=so(b,{capability:"data",exclude:t.exclude||null});v.replaceChildren(...Array.from($.root?.childNodes||[]));let H=z=>{let ae=$.original(z);ae&&(l.liveToClone.set(ae,z),l.cloneToLive.set(z,ae));for(let me of Array.from(z.childNodes||[]))H(me)};for(let z of Array.from(v.childNodes))H(z)},p={...Xt,find(b,v,m={}){let g=u(b);if(!g?.querySelectorAll)return[];let y=a().query(v,g);m.includeRulesTag||(y=y.filter($=>!Wl($)));let I=[];m.skip&&I.push(m.skip);let Y=m.templateAttr===null?null:m.templateAttr||"cms-template";if(Y&&I.push(`[${Y}]`),I.length){let $=I.join(", ");y=y.filter(H=>!H.closest?.($))}return y},parent(b){let v=u(b)?.parentElement;return v?d(v):null},children(b){return Array.from(u(b)?.children||[],d)},text(b,v){if(v===void 0){let y=d(b);return!y?.matches?.(n)&&!y?.querySelector?.(n)?Xt.text(y):(u(b)?.textContent||"").trim()}let m=d(b);if(!m?.matches?.(n)&&!m?.querySelector?.(n)&&!l){Xt.text(m,v);return}let g=a().cloneOf(m);g?f(m,g,"textContent",v):Xt.text(m,v)},attr(b,v,m){let g=d(b);if(m===void 0)return Xt.attr(g,v);Xt.attr(g,v,m);let y=l?.cloneOf(g);y&&(Xt.attr(y,v,m),so(g,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(g),l.cloneToLive.delete(y)))},removeAttr(b,v){let m=d(b);Xt.removeAttr(m,v);let g=l?.cloneOf(m);g&&Xt.removeAttr(g,v)},prop(b,v,m){let g=d(b);if(m===void 0)return v==="innerHTML"||v==="outerHTML"||v==="textContent"||v==="innerText"?Xt.prop(u(g),v):Xt.prop(g,v);let y=v==="innerHTML"||v==="textContent"||v==="innerText",I=y?a().cloneOf(g):l?.cloneOf(g);I&&y?f(g,I,v,m):(Xt.prop(g,v,m),I&&Xt.prop(I,v,m))},clone(b){let v=u(b);return v===b?Xt.clone(b):i.importNode(v,!0)},insertAt(b,v,m){let g=d(b),I=p.children(g)[m]||(()=>{for(let H=g.children.length-1;H>=0;H--){let z=g.children[H];if(a().cloneOf(z))return z.nextElementSibling}return g.firstElementChild})(),Y=d(v);g.insertBefore(Y,I||null);let $=a().cloneOf(g);if($){let H=a().cloneOf(Y);H||(H=i.importNode(Y,!0),h(Y,H));let z=Array.from($.children);$.insertBefore(H,z[m]||null)}},remove(b){let v=d(b),m=a().cloneOf(v);Xt.remove(v),m&&Xt.remove(m)},replaceWith(b,v){let m=d(b),g=a().cloneOf(m),y=Xt.replaceWith(m,v);if(g){let I=so(y,{capability:"data",exclude:t.exclude||null});if(!I.root)g.remove();else{g.replaceWith(I.root);let Y=$=>{let H=I.original($);H&&(l.liveToClone.set(H,$),l.cloneToLive.set($,H));for(let z of Array.from($.childNodes||[]))Y(z)};Y(I.root)}}return y}};return p}var Or=Xt;function oi(e){try{return JSON.parse(e)}catch(t){throw new Tr(`Invalid strict JSON: ${t.message}`,t)}}function Nr(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 n(o){let s=[],i=0;for(;i<o.length;){let l=o[i];if(/\s/.test(l)){i++;continue}if("{}".includes(l)){s.push({type:l,value:l}),i++;continue}if(l==="["){let h=!1,f=i+1;for(;f<o.length&&/\s/.test(o[f]);)f++;if(f<o.length&&/[a-zA-Z_]/.test(o[f])&&(h=!0),!h){s.push({type:l,value:l}),i++;continue}}if(l==="]"){s.push({type:l,value:l}),i++;continue}if(l===":"){s.push({type:t.COLON,value:l}),i++;continue}if(l===","){s.push({type:t.COMMA,value:l}),i++;continue}if(l==='"'||l==="'"){let h=l,f=i+1;for(;f<o.length&&o[f]!==h;)o[f]==="\\"&&f++,f++;s.push({type:t.STRING,value:o.substring(i+1,f),quoted:!0,sourceQuote:h}),i=f+1;continue}let a=i,u;for(;a<o.length&&!/[{},]/.test(o[a]);)if(o[a]===":"){let h=[":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"],f=!1;for(let p of h){let b=p.substring(1);if(o.substring(a+1,a+1+b.length)===b){f=!0,a+=b.length;break}}if(!f)break}else if(o[a]==="["){for(a++;a<o.length&&o[a]!=="]";){if(o[a]==='"'||o[a]==="'"){let h=o[a];for(a++;a<o.length&&o[a]!==h;)o[a]==="\\"&&a++,a++}a++}a<o.length&&o[a]==="]"&&a++}else a++;u=o.substring(i,a);let d=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?d=t.NUMBER:u==="true"||u==="false"||u==="null"?d=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(d=t.SELECTOR),s.push({type:d,value:u,quoted:!1}),i=a}return s}function r(o){let s="";for(let i=0;i<o.length;i++){let l=o[i];if("{}".includes(l.type)||"[]".includes(l.type)){s+=l.value;continue}if(l.type===t.COLON){s+=l.value;continue}if(l.type===t.COMMA){let a=o[i+1];if(a&&(a.type==="}"||a.type==="]"))continue;s+=l.value;continue}if(l.type===t.STRING&&l.quoted){let a=l.value;l.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(u,d)=>d.length%2===0?d+'\\"':u)),s+=`"${a}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){s+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){s+=`"${l.value}"`;continue}s+=`"${l.value}"`}return s}try{let o=n(e),s=r(o);return JSON.parse(s)}catch(o){throw new Tr("Invalid extraction rules syntax: "+o.message,o)}}var Gl="1",Kl=/^[a-zA-Z0-9_-]+$/;function io(e,t,n){let r;if(n===void 0)r="script[data-rules-name]";else{if(typeof n!="string"||!Kl.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Kl})`);r=`script[data-rules-name~="${n}"]`}let o=e.find(t,r,{includeRulesTag:!0});if(o.length===0)return null;n!==void 0&&o.length>1&&console.warn(`hyper-html-api: ${o.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=o[0],i=e.attr(s,"data-rules-version");if(i!==Gl)throw new Er(i);return{rules:Nr(e.text(s)),tagNode:s}}var zg=new Function("url","return import(url)");function ea(e,t,n,r){let o=e.length,s=t.length,i=new Array(o).fill(-1);if(r){let m=new Set;for(let g=0;g<o;g++){let y=r[g];!(y>=0&&y<s)||m.has(y)||(i[g]=y,m.add(y))}}if(o===0||s===0)return i;let l=e.map(m=>Zl(m,n)),a=t.map(m=>Zl(m,n)),u=new Array(s).fill(!1);for(let m of i)m>=0&&(u[m]=!0);let d=new Map;a.forEach((m,g)=>{u[g]||d.set(m,d.has(m)?-1:g)});let h=new Map;l.forEach((m,g)=>{i[g]>=0||h.set(m,(h.get(m)||0)+1)}),l.forEach((m,g)=>{if(i[g]>=0||h.get(m)!==1)return;let y=d.get(m);y===void 0||y===-1||u[y]||(i[g]=y,u[y]=!0)});let f=[];for(let m=0;m<o;m++)i[m]<0&&f.push(m);let p=[];for(let m=0;m<s;m++)u[m]||p.push(m);if(f.length===0||p.length===0)return i;let b=o*s+1,v=(m,g)=>Nf(e[m],t[g],n)*b+Math.abs(m-g);for(let[m,g]of Cf(f,p,v))i[m]=g;return i}var ta=e=>typeof e=="object"&&e!==null;function Zl(e,t){if(!ta(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(r=>{let o=JSON.stringify(e?.[r]);return o===void 0?" undef":o}))}function Nf(e,t,n){if(!ta(n))return e===t?0:1;let r=Object.keys(n);if(r.length===0)return 0;let o=0;for(let s of r){let i=JSON.stringify(e?.[s]),l=JSON.stringify(t?.[s]);i!==l&&o++}return o}function Cf(e,t,n){return e.length<=t.length?Ql(e,t,n,!1):Ql(t,e,(r,o)=>n(o,r),!0)}function Ql(e,t,n,r){let o=e.length,s=t.length,i=[];for(let h=0;h<=o;h++)i.push(new Float64Array(s+1).fill(1/0));let l=[];for(let h=0;h<=o;h++)l.push(new Uint8Array(s+1));for(let h=0;h<=s;h++)i[o][h]=0;for(let h=o-1;h>=0;h--)for(let f=s-1;f>=0;f--){let p=n(e[h],t[f])+i[h+1][f+1],b=i[h][f+1];p<=b?(i[h][f]=p,l[h][f]=1):i[h][f]=b}let a=[],u=0,d=0;for(;u<o&&d<s;)l[u][d]&&(a.push(r?[t[d],e[u]]:[e[u],t[d]]),u++),d++;return a}function ii(e,t,n,r,o,s,i,l={}){let a=e.find(t,n,l);if(o.length===0){a.forEach($=>e.remove($)),si(l,"onRowsApplied",s.path,[]);return}let u=o.length>a.length,d=a[0]||null;if(u&&!d&&(d=If(e,t,n,l),!d))throw new no(s.path);let h=a.map($=>Lf(e,$,r,l)),f=null;if(u&&d){f=e.clone(d),l.templateAttr&&e.removeAttr(f,l.templateAttr);let $=e.stripIds(f);$>0&&console.warn(`[hyper-html-api] stripped ${$} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let p=ea(o,h,r,Mf(e,a,o,s,l)),b=a[0]||d,v=e.parent(b),m=a.length>0?na(e,v,b):0,g=jf(e,a),y=new Set,I=[],Y=o.map(($,H)=>{let z=p[H];if(z>=0)return y.add(z),I.push(!1),a[z];I.push(!0);let ae=e.clone(f);return e.stripIds(ae),ae});a.forEach(($,H)=>{y.has(H)||e.remove($)}),g?Y.forEach(($,H)=>{let z=m+H;e.children(v).findIndex(Q=>e.sameNode(Q,$))!==z&&e.insertAt(v,$,z)}):Pf(e,Y,I,v,m),Rf(e,Y,r,o,s,i,l),si(l,"onRowsApplied",s.path,Y)}function si(e,t,n,r){if(typeof e[t]=="function")try{return e[t](n.slice(),r)}catch(o){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,o);return}}function Mf(e,t,n,r,o){let s=si(o,"identifyRows",r.path,n);if(!Array.isArray(s))return null;let i=new Array(n.length).fill(-1),l=new Set;for(let a=0;a<n.length;a++)if(s[a]){for(let u=0;u<t.length;u++)if(!(l.has(u)||!e.sameNode(t[u],s[a]))){i[a]=u,l.add(u);break}}return i}function Rf(e,t,n,r,o,s,i){t.forEach((l,a)=>{if(n===null){let u=r[a],d=u==null?"":String(u);e.text(l)!==d&&e.text(l,d)}else{let u=s(e,l,n,r[a],{depth:o.depth+1,path:[...o.path,a]},i);u&&u!==l&&(t[a]=u)}})}function Lf(e,t,n,r){return n===null?e.text(t):Gn(e,t,n,r.onRowsRead?{...r,onRowsRead:void 0}:r)}function na(e,t,n){let r=e.children(t);for(let o=0;o<r.length;o++)if(e.sameNode(r[o],n))return o;return-1}function If(e,t,n,r){if(!r.templateAttr)return null;let o=t;for(;o;){let s=e.find(o,n,{includeRulesTag:!1,templateAttr:null});for(let i of s)if(e.attr(i,r.templateAttr)!=null)return i;o=e.parent(o)}return null}function jf(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let r=e.children(n),o=[];for(let s of t){let i=r.findIndex(l=>e.sameNode(l,s));if(i===-1)return!1;o.push(i)}return o.sort((s,i)=>s-i),o[o.length-1]-o[0]===o.length-1}function Pf(e,t,n,r,o){let s=null,i=o;for(let l=0;l<t.length;l++){if(!n[l]){s=t[l];continue}let a=s?e.parent(s):r;if(!a)continue;let u=s?na(e,a,s)+1:i++;e.insertAt(a,t[l],u),s=t[l]}}var ra=new Set(["checked","selected","disabled","readOnly","paused"]);function Cr(e,t,n,r,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let s=[];if(li(n,r,[],s),s.length)throw new to(s);Fo(e,t,n,r,{depth:0,path:[]},o)}function Fo(e,t,n,r,o,s={}){if(o.depth>_r)throw new ar(o.path);if(r===void 0)return t;if(typeof n=="string")return Df(e,t,n,r,o,s);if(Array.isArray(n)){let[i,l]=n;return ii(e,t,i,l,r,o,Fo,s),t}if(typeof n=="object"&&n!==null){for(let[i,l]of Object.entries(n)){let a=Fo(e,t,l,r==null?r:r[i],{depth:o.depth+1,path:[...o.path,i]},s);a&&a!==t&&(t=a)}return t}return t}function Df(e,t,n,r,o,s){if(n.endsWith("[]")){let a=n.slice(0,-2);return ii(e,t,a,null,r,o,Fo,s),t}if(n.startsWith("@"))return sa(e,t,n.slice(1),r);let i=Vt(n);if(i!==-1){let a=n.slice(0,i),u=n.slice(i+1),d=a?e.find(t,a,s):[t];return d.length===0||sa(e,d[0],u,r),t}if(n===".")return oa(e,t,r),t;let l=e.find(t,n,s);return l.length===0||oa(e,l[0],r),t}function oa(e,t,n){let r=n==null?"":String(n);e.text(t)!==r&&e.text(t,r)}function sa(e,t,n,r){if(eo.has(n)){let s=e.prop(t,n);if(s===r||s!=null&&r!=null&&String(s)===String(r))return t;throw new ro(n)}if(n==="outerHTML"){let s=r==null?"":String(r);return e.replaceWith(t,s)}if(Dl.has(n)){let s=Ff(n,r);return e.prop(t,n)!==s&&e.prop(t,n,s),t}let o=r==null?"":String(r);return e.attr(t,n)!==o&&e.attr(t,n,o),t}function Ff(e,t){return t==null?ra.has(e)?!1:"":ra.has(e)?t==="false"?!1:!!t:t}function li(e,t,n,r){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((o,s)=>{typeof o=="object"&&o!==null&&r.push({path:ao([...n,s]),expected:"scalar",got:lo(o)})}):r.push({path:ao(n),expected:"array",got:lo(t)});return}t!==null&&typeof t=="object"&&r.push({path:ao(n),expected:"scalar",got:lo(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){r.push({path:ao(n),expected:"array",got:lo(t)});return}let o=e[1];t.forEach((s,i)=>li(o,s,[...n,i],r));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){r.push({path:ao(n),expected:"object",got:lo(t)});return}for(let[o,s]of Object.entries(e))li(s,t[o],[...n,o],r)}}}function lo(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function ao(e){return e.join(".")}var Xf=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...Hl],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]});function ai(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let r=t&&t.ownerDocument?t.ownerDocument:t;return io(e,r,n)}return null}var ln={extract:(e,t,n={})=>Gn(jn(e,n),e,t,n),apply:(e,t,n,r={})=>Cr(jn(e,{...r,_write:!0}),e,t,n,r),findRulesIn:(e,t)=>io(Or,e,t),findRules:(e,t)=>ai(Or,e,t),bind:(e,t,n={})=>{let r=ai(Or,e,t);if(!r){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}return{...r,get:()=>Gn(jn(e,n),e,r.rules,n),set:o=>Cr(jn(e,{...n,_write:!0}),e,r.rules,o,n)}},parseStrict:oi,parseRelaxed:Nr,ruleAttrIndex:Vt,splitRule:To,errors:Do,DOM_PROPERTIES:jo};var ui={};As(ui,{fromString:()=>Pn,getRuleAtPath:()=>cr,getValueAtPath:()=>Qf,setAtPath:()=>ci,toString:()=>Zf});function Zf(e){return e.map(String).join(".")}function Pn(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function cr(e,t){let n=e;for(let r of t){if(n==null)return;if(typeof n=="string"){if(n.endsWith("[]")&&(typeof r=="number"||r==="*")){n=n.slice(0,-2);continue}return}if(Array.isArray(n)){if(typeof r!="number"&&r!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof r=="number"||!(r in n))return;n=n[r];continue}return}return n}function Qf(e,t){let n=e;for(let r of t){if(n==null)return;n=n[r]}return n}function ci(e,t,n){if(t.length===0)return n;let[r,...o]=t;if(typeof r=="number"){let s=Array.isArray(e)?[...e]:[];return s[r]=ci(s[r],o,n),s}return{...e&&typeof e=="object"?e:{},[r]:ci((e||{})[r],o,n)}}function co(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[n,r]of Object.entries(e))t[n]=co(r);return t}return""}function qo(e,t,{ignoreActiveValue:n=!0}={}){Zs.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:n,restoreFocus:!0,formStateSync:"property",policy:"raw"})}var la=new WeakMap,fi=e=>e.map(String).join(".");function ed(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function aa(e,t){if(!e||!e.querySelector)return null;let n=e.querySelector(`[data-hcms-path="${ed(t)}"]`),r=n&&n.querySelector(".hcms-array-items");return r?Array.from(r.children).filter(o=>o.matches&&o.matches("[data-hcms-card], [data-hcms-array-item]")):null}function ca(e,t,n){let r=aa(e,t);!r||r.length!==n.length||r.forEach((o,s)=>{n[s]&&la.set(o,n[s])})}function Bo(){let e=new Map;return{hooks:{onRowsRead(t,n){e.set(fi(t),n)}},seed(t){for(let[n,r]of e)ca(t,n,r);e.clear()}}}function ua(e){return{identifyRows(t,n){let r=aa(e,fi(t));return!r||r.length!==n.length?null:r.map(o=>la.get(o)||null)},onRowsApplied(t,n){ca(e,fi(t),n)}}}var fa={skip:"[data-hcms-shell]",templateAttr:"cms-template"},di="data-hcms-rollback-ui",td=0;function da(e,t,n,r={}){return nd(e,t,n,r)}function nd(e,t,n,r){let{shellRoot:o,structural:s,structuralPath:i,formRoot:l}=r,a=l?{...fa,...ua(l)}:fa;if(!s)try{return ln.apply(e,t,n,a),{ok:!0}}catch(f){return{ok:!1,error:f}}let u=rd(e,t,i),d=u?sd(u):null,h=u?null:ld(e,o);try{return ln.apply(e,t,n,a),{ok:!0}}catch(f){return d?id(u,d):h&&ad(e,o,h),{ok:!1,error:f}}}function rd(e,t,n){if(!n||!e)return null;let r=Pn(n),o=[],s=t;for(let i of r){if(typeof s=="string"||s==null||Array.isArray(s))break;if(typeof s=="object"&&i in s){if(o.push(i),s=s[i],Array.isArray(s)||typeof s=="string"&&s.endsWith("[]"))break}else return null}return!Array.isArray(s)&&!(typeof s=="string"&&s.endsWith("[]"))?null:od(e,t,o)}function od(e,t,n){if(n.length===0)return null;let r=e,o=t;for(let s=0;s<n.length;s++){let i=n[s];if(!o||typeof o!="object"||Array.isArray(o))return null;let l=o[i];if(l==null)return null;if(s===n.length-1){if(Array.isArray(l)){let[a]=l;return r.querySelector?.(a)?.parentElement||null}if(typeof l=="string"&&l.endsWith("[]")){let a=l.slice(0,-2);return r.querySelector?.(a)?.parentElement||null}return null}o=l}return null}function sd(e){let t=[],n=[];for(let r of Array.from(e.childNodes))t.push(hi(r,n));return{nodes:t,retained:n}}function id(e,t){let n=e.cloneNode(!1);for(let r of t.nodes)n.appendChild(r);Kn(e,Array.from(n.childNodes),ma()),ha(e,t.retained)}function ld(e,t){let n=[],r=[];for(let o of Array.from(e.childNodes))o===t||t&&o.contains?.(t)||n.push(hi(o,r));return{nodes:n,retained:r}}function ad(e,t,n){let r=e.cloneNode(!1);for(let o of n.nodes)r.appendChild(o);Kn(e,Array.from(r.childNodes),ma()),ha(e,n.retained)}function hi(e,t){let n=e.cloneNode(!1);if(e.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]')){let s=String(++td);n.setAttribute(di,s),t.push({id:s,node:e})}let r=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,o=n.nodeType===1&&n.tagName==="TEMPLATE"?n.content:n;for(let s of Array.from(r.childNodes||[]))o.appendChild(hi(s,t));return n}function ha(e,t){for(let{id:n,node:r}of t){let o=e.querySelector(`[${di}="${n}"]`);o===r?r.removeAttribute(di):r.isConnected?o?.remove():o?.replaceWith(r)}}function ma(){return{morphStyle:"innerHTML",policy:"raw",restoreFocus:!1,scripts:{handle:!1,merge:!1}}}function $o(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 cd='<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>',mi='<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>',ba={"@scalar":`
1
+ var hypercms=(()=>{var zs=Object.defineProperty;var ou=Object.getOwnPropertyDescriptor;var su=Object.getOwnPropertyNames;var iu=Object.prototype.hasOwnProperty;var Vs=(e,t)=>{for(var n in t)zs(e,n,{get:t[n],enumerable:!0})},lu=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of su(t))!iu.call(e,o)&&o!==n&&zs(e,o,{get:()=>t[o],enumerable:!(r=ou(t,o))||r.enumerable});return e};var au=e=>lu(zs({},"__esModule",{value:!0}),e);var Bp={};Vs(Bp,{cms:()=>Dp,default:()=>Fp});function rn(e){let t=0,n=null,r=-1;for(let o=0;o<e.length;o++){let s=e[o];s==="\\"?o++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:s==="@"&&t===0&&(r=o)}return r}function $o(e){let t=rn(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function Ho(e,t){if(typeof e=="string"){let n=t&&t.defaultView,r=n&&n.DOMParser||globalThis.DOMParser;return new r().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Ws(e){let t=new Map;return(n,r)=>{if(typeof r!="string")return Ho(r,e);let o=t.get(n);if(o&&o.text===r)return o.doc;let s=Ho(r,e);return t.set(n,{text:r,doc:s}),s}}function El(e,t){let n=t.doctype;if(!n)return!1;let r=e.doctype;if(r&&r.name===n.name&&r.publicId===n.publicId&&r.systemId===n.systemId)return!1;let o=e.implementation.createDocumentType(n.name,n.publicId,n.systemId);return r?e.replaceChild(o,r):e.insertBefore(o,e.documentElement),!0}var Ks=()=>!1;function Gs(e,t=[]){if(typeof e!="function")return Ks;let n=new WeakMap,r=new Set(t);return o=>{if(!o||o.nodeType!==1)return!1;let s=n.get(o);if(s!==void 0)return s;let l=[],i=o,a=!1;for(;i&&i.nodeType===1;){let c=n.get(i);if(c!==void 0){a=c;break}if(l.push(i),e(i,r.has(i))){a=!0;break}if(r.has(i))break;i=i.parentElement}for(let c of l)n.set(c,a);return a}}var ng=Object.freeze(["root-tag","equal","root-attrs","root-level","not-in-body","ignored-ancestor","remote-wins-ancestor","form-ancestor","script-or-template","no-live-twin","live-detached","ancestor-live","sibling-live","outside-id-changed","chain-unpaired"]);function nr(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Ys(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let r=t["~"],o=typeof r=="string"?r.split(",").map(Number):null,s=o&&typeof t["^"]=="string"?t["^"].split(","):null,l=u=>Number.isInteger(u)&&u>=0,i=0,a=!1,c=u=>{let f=u;for(;f>0;){let d=o[i++];if(i>o.length||!l(d))return!1;f+=d-1}return!0},h=(u,f)=>{if(a)return;if(o){let y=i++,m=o[y];if(y>=o.length||!l(m)){a=!0;return}let g=!s||s[y]===u.tagName.toLowerCase();if(!g||m!==u.children.length){let k=g&&t[f];typeof k=="string"&&k&&n.set(u,k),c(m)||(a=!0);return}}let d=t[f];typeof d=="string"&&d&&n.set(u,d);let p=u.children;for(let y=0;y<p.length;y++)h(p[y],f===""?String(y):`${f}.${y}`)};return h(e,""),n}function _l(e){return t=>{for(let n of e){let r=n(t);if(typeof r=="string"&&r!=="")return r}return null}}var Sn=_l([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function zo(e,t,n,r=null,o=null){let s=new Map,l=new Set,i=a=>{if(n(a))return;let c=t(a);c&&(s.has(c)?l.add(c):s.set(c,a))};if(r){let a=c=>{for(let h of c.querySelectorAll(r))i(h);for(let h of c.querySelectorAll("template"))h.content&&a(h.content)};i(e),a(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let a=c=>{i(c);let h=c.tagName==="TEMPLATE"&&c.content?c.content.children:c.children;for(let u=0;u<h.length;u++)a(h[u])};a(e)}for(let a of l)s.delete(a),o&&o.add(a),Xs(a);return s}function Xs(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var fu=new Set(["href","src","name","type","role"]),Nl=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function Nr(e,t=5381){let n=t;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return n>>>0}function Ol(e){return e.replace(/\s+/g," ")}var uu=0;function Cl({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let r=new WeakMap,o=new WeakMap;function s(O){let C=O.attributes,_=C.length;if(_===0)return{all:"",sig:O.tagName+"|"};let M=[],j="",I=[];for(let P=0;P<_;P++){let R=C[P],T=R.name;t(O,T)||M.push(T+"="+R.value),T==="class"?j=R.value.indexOf(" ")<0?R.value:R.value.split(/\s+/).filter(Boolean).sort().join(" "):fu.has(T)&&I.push(T+"="+R.value)}return M.length>1&&M.sort(),I.length>1&&I.sort(),{all:M.join(""),sig:O.tagName+"|"+j+(I.length?"|"+I.join("|"):"")}}function l(O){return O.nodeType===1&&O.tagName==="TEMPLATE"&&O.content?O.content.childNodes:O.childNodes}function i(O){let C=r.get(O);if(C)return C;if(O.nodeType===3)C={hash:"T"+Nr(O.nodeValue),hint:Ol(O.nodeValue).slice(0,64),sig:null,tok:null};else if(O.nodeType===8)C={hash:"C"+Nr(O.nodeValue),hint:"",sig:null,tok:null};else if(O.nodeType===1){let _=s(O),M=Nr(O.tagName+""+_.all),j="";for(let I of c(O))if(I.nodeType===1){let P=i(I);M=Nr(P.hash,M),j.length<64&&(j+=" "+P.hint)}else M=Nr(h(I),M),I.kind==="text"&&j.length<64&&(j+=I.value.slice(0,64));C={hash:"E"+M,hint:Ol(j).trim().slice(0,64),sig:_.sig,tok:null}}else C={hash:"N"+O.nodeType,hint:"",sig:null,tok:null};return r.set(O,C),C}function a(O){if(!O.tok){O.tok=new Set;for(let C of O.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))C&&O.tok.add(C)}return O.tok}function c(O){let C=o.get(O);if(C)return C;C=[];let _=null,M=()=>{_&&(_.value=_.nodes.map(j=>j.nodeValue).join(""),C.push(_),_=null)};for(let j of l(O)){if(j.nodeType===3){_||(_={kind:"text",nodes:[],value:"",parent:O,hash:void 0}),_.nodes.push(j);continue}M(),j.nodeType===8?C.push({kind:"comment",nodes:[j],value:j.nodeValue,parent:O,hash:void 0}):j.nodeType===1&&!e(j)&&C.push(j)}return M(),o.set(O,C),C}function h(O){return O.nodeType===1?i(O).hash:(O.hash===void 0&&(O.hash=(O.kind==="text"?"T":"C")+Nr(O.value)),O.hash)}function u(O,C){let _=a(i(O)),M=a(i(C));if(_.size===0&&M.size===0)return{coef:1,share:1};if(_.size===0||M.size===0)return null;let j=0;for(let I of _)M.has(I)&&j++;return{coef:j/Math.min(_.size,M.size),share:j/Math.max(_.size,M.size)}}function f(O,C){let _=u(O,C);return!!_&&_.coef>=.5}let d=new WeakMap;function p(O){let C=d.get(O);if(C)return C;C=[];for(let _ of O.attributes)t(O,_.name)||C.push([_.namespaceURI||"",_.localName,_.value]);return C.sort((_,M)=>_[0]<M[0]?-1:_[0]>M[0]?1:_[1]<M[1]?-1:_[1]>M[1]?1:0),d.set(O,C),C}let y=new WeakMap;function m(O,C){if(O===C)return!0;if(h(O)!==h(C))return!1;let _=y.get(O);if(_&&_.has(C))return _.get(C);let M=y.get(C);if(M&&M.has(O))return M.get(O);let j=g(O,C),I=j===!0;return j===!1&&n&&n.hashRejected++,_||y.set(O,_=new WeakMap),_.set(C,I),I}function g(O,C){if(O.nodeType===1){if(C.nodeType!==1||O.tagName!==C.tagName||O.namespaceURI!==C.namespaceURI)return!1;let _=p(O),M=p(C);if(_.length!==M.length)return!1;for(let P=0;P<_.length;P++)if(_[P][0]!==M[P][0]||_[P][1]!==M[P][1]||_[P][2]!==M[P][2])return!1;let j=c(O),I=c(C);if(j.length!==I.length)return!1;for(let P=0;P<j.length;P++){if(h(j[P])!==h(I[P]))return!1;if(!m(j[P],I[P]))return uu}return!0}return C.nodeType===1?!1:O.kind===C.kind&&O.value===C.value}let k=new WeakMap,S=new Map,v=0;function x(O){let C=k.get(O);if(C)return C;let _=h(O),M=S.get(_);M||S.set(_,M=[]);let j=M.find(I=>m(I.unit,O));return C=j?j.key:"K"+v++,j||M.push({unit:O,key:C}),k.set(O,C),C}return{meta:i,unitsOf:c,unitHash:h,similar:f,score:u,childrenOf:l,equalUnits:m,exactUnitKey:x,ignored:e}}var Ml=16,du=2e3,hu=3,Js={align:0,certifyVisited:0,certifyScheduled:0};function Zs(e,t,n){let{meta:r,unitsOf:o,unitHash:s,similar:l,score:i,childrenOf:a,equalUnits:c,ignored:h}=n.analyzer,u=n.baseId||(()=>null),f=n.sideId||(()=>null),d=n.baseKey||(()=>null),p=n.sideKey||(()=>null),y=n.baseDropped||new Set,m=n.sideDropped||new Set,g=n.stats||null,k=g?new Set:null,S=g?new Set:null,v=new Map,x=new Map,O=new Set,C=new Map,_=new Set,M=new Set,j=new Set,I=[],P=[],R=[],T=[],A=du,W=new Map,F=new Map,$=(B,G)=>{v.set(B,G),x.set(G,B)},Ne=new Set,Ce=new Set,Be=null,re=B=>{let G=B.nodeType?B.parentNode:B.parent;if(!G||G.nodeType!==11)return G;if(!Be){Be=new WeakMap;let he=be=>{for(let fe of be.querySelectorAll("template"))fe.content&&(Be.set(fe.content,fe),he(fe.content))};for(let be of[e,t])he(be.tagName==="TEMPLATE"&&be.content?be.content:be)}return Be.get(G)||null},Ee=(B,G)=>{for(let he=re(B);he&&!Ne.has(he);he=re(he))Ne.add(he);for(let he=re(G);he&&!Ce.has(he);he=re(he))Ce.add(he)},Ge=B=>{for(let G=re(B);G;G=re(G))if(v.has(G))return M.has(G);return!1},_e=B=>{for(let G=re(B);G;G=re(G)){let he=x.get(G);if(he!==void 0)return M.has(he)}return!1},w=B=>!!B&&B.nodeType===1,V=(B,G)=>{let he=C.get(B);return!!he&&he.has(G)},ne=B=>Nl.has(B.tagName),te=n.comparisons||n.scope,Pe=(B,G)=>{if(te){if(te.same.get(B)===G)return!0;if(te.differ.get(B)===G)return!1}if(!B.isEqualNode(G))return!1;if(B.tagName==="TEMPLATE")return c(B,G);let he=B.getElementsByTagName("template");if(he.length===0)return!0;let be=G.getElementsByTagName("template");if(he.length!==be.length)return!1;for(let fe=0;fe<he.length;fe++)if(!c(he[fe],be[fe]))return!1;return!0},ze=(B,G)=>{let he=u(B);if(!he)return!0;let be=f(G);return!be||he===be},Se=B=>{let G=d(B);return G&&n.baseIndex.get(G)===B&&!m.has(G)?G:null},it=B=>{let G=p(B);return G&&n.sideIndex.get(G)===B&&!y.has(G)?G:null},tt=(B,G)=>{let he=Se(B);if(!he)return!0;let be=it(G);return!be||he===be},Q=globalThis.__hyperMorphProfile,ce=Q?performance.now():0;Q&&!n.scope&&(r(e),r(t),Q.meta=(Q.meta||0)+(performance.now()-ce),ce=performance.now()),$(e,t);let Re=new Set;for(let[B,G]of n.baseIndex){let he=n.sideIndex.get(B);he&&he.tagName===G.tagName&&!v.has(G)&&!x.has(he)&&($(G,he),Ee(G,he),Re.add(G))}if(Re.size){let B=[];if(n.scope)for(let fe of n.scope.chain)Re.has(fe)&&B.push(fe);let G=[n.scope?n.scope.root:e];for(;G.length;){let fe=G.pop();Re.has(fe)&&B.push(fe);let we=a(fe);for(let oe=we.length-1;oe>=0;oe--)we[oe].nodeType===1&&G.push(we[oe])}let he=new Set;for(let fe=B.length-1;fe>=0;fe--){let we=B[fe];n.scope&&n.scope.onChain.has(we)?he.add(we):ie(we,v.get(we),he)?(M.add(we),j.add(we),g&&g.certificationPairs++):he.add(we)}let be=new Set;for(let fe of B)M.has(fe)&&!be.has(fe)&&Ue(fe,be)}n.scope&&n.scope.head&&ge(n.scope.head[0],n.scope.head[1]);function Ue(B,G){let he=[B];for(;he.length;){let be=he.pop();if(!G.has(be)){G.add(be),Y(be);for(let fe of o(be))w(fe)&&v.has(fe)&&he.push(fe)}}}T.push([e,t]);for(let[B,G]of v)w(B)&&B!==e&&T.push([B,G]);return kt(),qe(),Q&&(Q.align=(Q.align||0)+(performance.now()-ce)),{map:v,reverse:x,moved:_,identical:M,pairIdenticalChildren:Y,weak:O,unpair:ot,rematch:qe,insertedByHash:xt,refused:S,identityPaired:Re};function qe(){ke(),kt();for(let B=0;B<R.length;){let G=R.length;St(B,G),B=G,kt(),ke(),kt()}}function ot(B){let G=v.get(B);if(!G)return;C.has(B)||C.set(B,new Set),C.get(B).add(G);let he=(fe,we)=>{v.delete(fe),x.delete(we),_.delete(fe),M.delete(fe),O.delete(fe),j.delete(fe)},be=(fe,we)=>{for(let oe of o(fe)){let K=v.get(oe);!K||Re.has(oe)||!(w(K)?we.contains(K):we.contains(K.nodes[0]))||(he(oe,K),w(oe)&&be(oe,K))}};he(B,G),w(B)&&be(B,G),I.push(B),P.push(G)}function xt(){let B=new Map;for(let G of new Set(P)){if(x.has(G))continue;let he=r(G).hash;B.has(he)||B.set(he,[]),B.get(he).push(G)}return B}function kt(){for(;T.length;){let[B,G]=T.shift();v.get(B)!==G||j.has(B)||M.has(B)||dt(B,G)}}function Ct(B,G){if(!ne(B))for(let he of o(B))w(he)&&(G.push(he),Ct(he,G))}function dt(B,G){j.add(B);let he=o(B),be=o(G);Js.align+=he.length+be.length,W=new Map,F=new Map;for(let ue=0;ue<he.length;ue++)W.set(he[ue],ue);for(let ue=0;ue<be.length;ue++)F.set(be[ue],ue);if(B.tagName==="HTML")for(let ue of["HEAD","BODY"]){let Le=he.find(We=>w(We)&&We.tagName===ue),De=be.find(We=>w(We)&&We.tagName===ue);Le&&De&&!v.has(Le)&&!x.has(De)&&$(Le,De)}for(let ue=0;ue<he.length&&ue<be.length;ue++){let Le=he[ue],De=be[ue];v.has(Le)||x.has(De)||(w(Le)?w(De)&&Le.tagName===De.tagName&&Pe(Le,De)&&ge(Le,De):!w(De)&&Le.kind===De.kind&&Le.value===De.value&&ge(Le,De))}Ie(he,be);let fe=he.filter(ue=>!v.has(ue)),we=be.filter(ue=>!x.has(ue));fe.length&&we.length&&(H(fe,we),J(fe,we),se(fe,we,he,be),Me(he,be));let oe=!1,K=!1;for(let ue of he){if(!v.has(ue)){w(ue)&&(I.push(ue),Ct(ue,I),oe=!0);continue}w(ue)&&!M.has(ue)&&T.push([ue,v.get(ue)])}for(let ue of be)!x.has(ue)&&w(ue)&&(P.push(ue),Ct(ue,P),K=!0);oe&&K&&R.push([B,G])}function St(B,G){for(let he=B;he<G;he++){let[be,fe]=R[he];if(v.get(be)!==fe)continue;let we=o(be),oe=o(fe),K=new Map,ue=new Map,Le=null;for(let De of we)w(De)&&(v.has(De)?Le=De:(K.has(Le)||K.set(Le,[]),K.get(Le).push(De)));Le=null;for(let De of oe)w(De)&&(x.has(De)?Le=x.get(De):(ue.has(Le)||ue.set(Le,[]),ue.get(Le).push(De)));for(let[De,We]of K){let Oe=ue.get(De);if(!(!Oe||We.length!==Oe.length)&&We.every((Ze,st)=>Oe[st].tagName===Ze.tagName&&ze(Ze,Oe[st])&&!V(Ze,Oe[st])))for(let Ze=0;Ze<We.length;Ze++)ht(We[Ze],Oe[Ze])}}}function ht(B,G){$(B,G),O.add(B),T.push([B,G]),kt()}function H(B,G){let he=Cr(B,s),be=Cr(G,s),fe=new Map;for(let we of G){let oe=s(we);be.get(oe)===1&&fe.set(oe,we)}for(let we of B){if(v.has(we))continue;let oe=s(we);if(he.get(oe)!==1)continue;let K=fe.get(oe);K&&!x.has(K)&&c(we,K)&&ge(we,K)}}function ie(B,G,he){let be=[[B,G]];for(;be.length;){let[fe,we]=be.pop();if(Js.certifyVisited++,g&&g.certificationVisited++,fe.nodeType!==we.nodeType)return!1;if(fe.nodeType===3||fe.nodeType===8){if(fe.nodeValue!==we.nodeValue)return!1;continue}if(fe.nodeType!==1){if(!fe.isEqualNode(we))return!1;continue}if(fe.tagName!==we.tagName||fe.namespaceURI!==we.namespaceURI||h(fe)!==h(we))return!1;let oe=fe.attributes,K=we.attributes;if(oe.length!==K.length)return!1;for(let Oe=0;Oe<oe.length;Oe++){let Ze=oe[Oe];if(we.getAttributeNS(Ze.namespaceURI,Ze.localName)!==Ze.value)return!1}let ue=v.get(fe);if(ue!==void 0&&ue!==we)return!1;let Le=x.get(we);if(Le!==void 0&&Le!==fe)return!1;if(fe!==B){if(M.has(fe))continue;if(he.has(fe))return!1}let De=a(fe),We=a(we);if(De.length!==We.length)return!1;Js.certifyScheduled+=De.length;for(let Oe=De.length-1;Oe>=0;Oe--)be.push([De[Oe],We[Oe]])}return!0}function pe(B,G){return!w(B)||!(Ne.has(B)||Ce.has(G))?!0:!!N(B,G)||!(Se(B)||it(G))}function ge(B,G){if(w(B)&&(Ne.has(B)||Ce.has(G))){let he=N(B,G);if(!he){if(Se(B)||it(G))return;$(B,G),T.push([B,G]);return}for(let be=0;be<he.length;be+=2){let fe=he[be],we=he[be+1],oe=v.get(fe);oe!==void 0&&oe!==we&&Ae(fe,oe);let K=x.get(we);K!==void 0&&K!==fe&&Ae(K,we),v.get(fe)===we&&(_.delete(fe),O.delete(fe),M.add(fe),j.add(fe))}}D(B,G)}function Ae(B,G){v.delete(B),x.delete(G),_.delete(B),M.delete(B),O.delete(B),j.delete(B)}function N(B,G){let he=[B,G,!1],be=[];for(;he.length;){let fe=he.pop(),we=he.pop(),oe=he.pop(),K=v.get(oe),ue=x.get(we);if(oe!==B&&(K!==void 0&&K!==we&&Re.has(oe)||ue!==void 0&&ue!==oe&&Re.has(ue)))return null;if(!(K===we&&M.has(oe))&&((K!==void 0||ue!==void 0)&&be.push(oe,we),!!w(oe))){if(fe||K!==void 0&&K!==we||ue!==void 0&&ue!==oe){let Le=o(oe),De=o(we);for(let We=0;We<Le.length&&We<De.length;We++)he.push(Le[We],De[We],!0)}else if(Ne.has(oe)||Ce.has(we)){let Le=oe.tagName==="TEMPLATE"?oe.content:oe,De=we.tagName==="TEMPLATE"?we.content:we;for(let We=Le.firstElementChild,Oe=De.firstElementChild;We&&Oe;){if(h(We)){We=We.nextElementSibling;continue}if(h(Oe)){Oe=Oe.nextElementSibling;continue}(v.has(We)||x.has(Oe)||Ne.has(We)||Ce.has(Oe))&&he.push(We,Oe,!1),We=We.nextElementSibling,Oe=Oe.nextElementSibling}}}}return be}function D(B,G){$(B,G),M.add(B),w(B)&&j.add(B)}function Y(B){let G=v.get(B);if(!G||!w(B))return;let he=o(B),be=o(G);for(let fe=0;fe<he.length&&fe<be.length;fe++)v.has(he[fe])||D(he[fe],be[fe])}function J(B,G){let he=oe=>w(oe)&&!ne(oe)?r(oe).sig+""+r(oe).hint:null,be=Cr(B,he),fe=Cr(G,he),we=new Map;for(let oe of G){let K=he(oe);K!=null&&fe.get(K)===1&&we.set(K,oe)}for(let oe of B){if(v.has(oe))continue;let K=he(oe);if(K==null||be.get(K)!==1)continue;let ue=we.get(K);ue&&!x.has(ue)&&ze(oe,ue)&&$(oe,ue)}}function se(B,G,he,be){let fe=new Map;for(let oe of G){if(!w(oe)||x.has(oe)||ne(oe))continue;let K=r(oe).sig;fe.has(K)||fe.set(K,[]),fe.get(K).push({el:oe,index:F.get(oe)})}let we=[];for(let oe of B){if(v.has(oe)||!w(oe)||ne(oe))continue;let K=fe.get(r(oe).sig);if(!K||!K.length)continue;let ue=W.get(oe),Le=K.filter(De=>!x.has(De.el)).map(De=>({c:De,d:Math.abs(De.index-ue)}));Le.sort((De,We)=>De.d-We.d),Le.length>Ml&&(Le=Le.slice(0,Ml));for(let{c:De,d:We}of Le){if(!ze(oe,De.el))continue;let Oe=i(oe,De.el);Oe&&Oe.coef>=.5&&we.push({b:oe,s:De.el,coef:Oe.coef,share:Oe.share,d:We,bi:ue})}}if(we.sort((oe,K)=>K.coef-oe.coef||K.share-oe.share||oe.d-K.d||oe.bi-K.bi),g&&we.length>1){let oe=new Map;for(let K of we){let ue=oe.get(K.b);ue?ue.coef===K.coef&&(ue.share===K.share?ue.strict++:ue.loose++):oe.set(K.b,{coef:K.coef,share:K.share,strict:0,loose:0})}for(let[K,ue]of oe)k.has(K)||!(ue.strict||ue.loose)||(k.add(K),ue.strict?g.similarTiesStrict++:g.similarTiesLoose++)}for(let oe of we)!v.has(oe.b)&&!x.has(oe.s)&&$(oe.b,oe.s)}function Fe(B,G){return w(B)!==w(G)?!1:w(B)?B.tagName!==G.tagName||!ze(B,G)?!1:ne(B)||r(B).hint===""||r(G).hint===""?!0:l(B,G):B.kind===G.kind}function ee(B,G){let he=(fe,we)=>{let oe=we===null?-1:fe===G?F.get(we):W.get(we),K=fe[oe+1];return K&&!w(K)?K:null},be=null;for(let fe of B){if(w(fe)){be=fe;continue}if(v.has(fe))continue;let we=be===null?null:v.get(be);if(be!==null&&!we)continue;let oe=he(G,we);oe&&!x.has(oe)&&oe.kind===fe.kind&&$(fe,oe)}}function Me(B,G){ee(B,G);let he=Ve(B,G),be=(we,oe)=>w(we)&&r(we).hint!==""&&r(oe).hint===""&&!!oe.querySelector("br")&&!he(we,oe),fe=0;for(let we of B){if(v.has(we)){let K=F.get(v.get(we));K!==void 0&&K>=fe&&(fe=K+1);continue}let oe=0;for(let K=fe;K<G.length&&oe<hu;K++){let ue=G[K];if(!x.has(ue)&&(oe++,Fe(we,ue)&&!V(we,ue)&&!be(we,ue))){$(we,ue),w(we)&&(r(we).hint===""||r(ue).hint==="")&&O.add(we),fe=K+1;break}}}Ie(B,G)}function Ve(B,G){let he=(be,fe,we)=>{for(let oe=fe-1;oe>=0;oe--)if(w(be[oe])&&we(be[oe]))return be[oe];return null};return(be,fe)=>{let we=W.get(be),oe=F.get(fe);if(we===oe)return!0;let K=he(B,we,Le=>v.has(Le)),ue=he(G,oe,Le=>x.has(Le));return K?v.get(K)===ue:!ue}}function Ie(B,G){let he=B.filter(K=>w(K)&&!v.has(K)),be=G.filter(K=>w(K)&&!x.has(K));if(!he.length||!be.length)return;let fe=Cr(he,K=>K.tagName),we=Cr(be,K=>K.tagName),oe=Ve(B,G);for(let K of he){let ue=K.tagName;if(fe.get(ue)!==1||we.get(ue)!==1)continue;let Le=be.find(De=>De.tagName===ue);Le&&!x.has(Le)&&oe(K,Le)&&ze(K,Le)&&!V(K,Le)&&(c(K,Le)?ge(K,Le):($(K,Le),O.add(K)))}}function ke(){let B=new Map;for(let K of O)if(w(K)&&w(v.get(K))){let ue=r(K).hash;B.has(ue)||B.set(ue,[]),B.get(ue).push(K)}if(B.size)for(let K of P){if(x.has(K)||!w(K)||_e(K))continue;let ue=B.get(r(K).hash),Le=ue&&ue.find(De=>O.has(De)&&!V(De,K)&&ze(De,K)&&tt(De,K)&&c(De,K)&&pe(De,K));Le&&(ot(Le),ge(Le,K),Ee(Le,K),_.add(Le))}let G=new Map,he=new Map,be=new Map;for(let K of O){let ue=v.get(K);w(K)&&w(ue)&&be.set(ue,K)}let fe=(K,ue)=>{if(!x.has(K))return!_e(K);let Le=be.get(K);return Le===x.get(K)&&Le!==ue&&!Le.contains(ue)},we=K=>{if(x.has(K)){let ue=be.get(K);be.delete(K),ot(ue)}};for(let K of[...P,...be.keys()]){if(x.has(K)&&!be.has(K))continue;let ue=r(K).hash;if(G.has(ue)||G.set(ue,[]),G.get(ue).push(K),ne(K))continue;let Le=r(K).sig;he.has(Le)||he.set(Le,[]),he.get(Le).push(K)}let oe=new Set;for(let K of O){let ue=v.get(K);!w(K)||!w(ue)||ne(K)||r(K).hint===""||r(ue).hint===""||l(K,ue)||oe.add(K)}for(let K of[...I,...oe]){let ue=v.get(K);if(ue?!(O.has(K)&&oe.has(K)):Ge(K))continue;let Le=st=>{ue&&ot(K),we(st)},De=G.get(r(K).hash);if(De){let st=De.find(E=>E!==ue&&fe(E,K)&&!V(K,E)&&tt(K,E)&&c(K,E)&&pe(K,E));if(st){Le(st),ge(K,st),Ee(K,st),_.add(K);continue}}if(ne(K)||A<=0)continue;let We=he.get(r(K).sig);if(!We)continue;let Oe=null,Ze=0;for(let st of We)if(!(st===ue||!fe(st,K)||!ze(K,st)||!tt(K,st)||V(K,st))&&(A--<=0||l(K,st)&&(Ze++,Oe=st,Ze>1)))break;Ze>1&&S&&S.add(K),Ze===1&&(Le(Oe),$(K,Oe),Ee(K,Oe),_.add(K),T.push([K,Oe]))}}}function Cr(e,t){let n=new Map;for(let r of e){let o=t(r);o!=null&&n.set(o,(n.get(o)||0)+1)}return n}var mu={diff:0},Rl=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,pu=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,gu=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,bu=/\P{M}\p{M}*/gu;function ku(e){if(e==="")return[];if(Rl){let n=[];for(let r of Rl.segment(e))n.push(r.segment);return n}let t=[];for(let n of e.match(gu))if(pu.test(n))for(let r of n.match(bu))t.push(r);else t.push(n);return t}var yu=/^[  ]+$/,xu=e=>yu.test(e)?" ".repeat(e.length):e,rr=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),Tt="",Qs=e=>e.every(t=>rr(t)||t.k===Tt),vu=/^[\x00-\x7f\u00A0]*$/,wu=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Au(e){return e===""?[]:e.match(wu)}function hn(e,t=!1){return(t?Au(e):ku(e)).map(n=>({k:xu(n),raw:n,len:n.length}))}var Tn=(...e)=>e.every(t=>vu.test(t));function ei(e,t,n){let r=e.length,o=t.length,s=Math.min(r+o,n),l=s+1,i=new Int32Array(2*s+3),a=[],c=r===0&&o===0;for(let d=0;d<=s&&!c;d++){a.push(i.slice(l-d,l+d+1));for(let p=-d;p<=d;p+=2){let y;p===-d||p!==d&&i[l+p-1]<i[l+p+1]?y=i[l+p+1]:y=i[l+p-1]+1;let m=y-p,g=y;for(;y<r&&m<o&&e[y].k===t[m].k;)y++,m++;if(mu.diff+=1+y-g,i[l+p]=y,y>=r&&m>=o){c=!0;break}}}if(!c)return null;let h=[],u=r,f=o;for(let d=a.length-1;d>0;d--){let p=a[d],y=u-f,m=y+d,g=y===-d||y!==d&&p[m-1]<p[m+1]?y+1:y-1,k=p[g+d],S=k-g;for(;u>k&&f>S;)h.push([0,u-1,f-1]),u--,f--;u===k?(h.push([1,u,f-1]),f--):(h.push([-1,u-1,f]),u--)}for(;u>0&&f>0;)h.push([0,u-1,f-1]),u--,f--;return h.reverse(),h}function Su(e,t,n){let r=u=>u.k===Tt;if(!e.some(r)&&!t.some(r))return ei(e,t,n);let o=[],s=[];for(let u=0;u<e.length;u++)r(e[u])||o.push(u);for(let u=0;u<t.length;u++)r(t[u])||s.push(u);let l=ei(o.map(u=>e[u]),s.map(u=>t[u]),n);if(!l)return null;let i=[],a=0,c=0,h=(u,f)=>{for(;a<u&&c<f&&e[a].k===t[c].k;)i.push([0,a++,c++]);let d=ei(e.slice(a,u),t.slice(c,f),n);if(!d)return!1;for(let[p,y,m]of d)i.push([p,y+a,m+c]);return a=u,c=f,!0};for(let[u,f,d]of l)if(u===0){if(!h(o[f],s[d]))return null;i.push([0,a,c]),a++,c++}return h(e.length,t.length)?i:null}function Yn(e,t,n=4e3){let r=[],o=0;for(;o<e.length&&o<t.length&&e[o].k===t[o].k;)e[o].raw!==t[o].raw&&r.push({bi:o,tok:t[o]}),o++;let s=0;for(;s<e.length-o&&s<t.length-o&&e[e.length-1-s].k===t[t.length-1-s].k;)e[e.length-1-s].raw!==t[t.length-1-s].raw&&r.push({bi:e.length-1-s,tok:t[t.length-1-s]}),s++;let l=e.slice(o,e.length-s),i=t.slice(o,t.length-s),a=Cu(l,i)?null:Su(l,i,n);if(!a){let g=l.length||i.length?[{bs:o,be:o+l.length,toks:i}]:[];return{hunks:g,cosmetic:r,coarse:!0,parts:g.map(k=>({...k,gap:[],group:0})),cosmeticEq:r}}let c=[],h=(g,k)=>{l[g].raw!==i[k].raw&&r.push({bi:o+g,tok:i[k]})},u=null,f=[],d=0,p=0,y=()=>{u&&c.push(u),u=null;for(let[g,k]of f)h(g,k);f=[],d++};for(let[g,k,S]of a){if(g===0){u&&rr(l[k])&&!l[k].k.includes(`
2
+ `)?f.push([k,S]):(y(),h(k,S)),p=k+1;continue}(!u||f.length)&&(u&&c.push(u),u={bs:o+p,be:o+p,toks:[],gap:f.map(([v,x])=>({bi:o+v,tok:i[x]})),group:d},f=[]),g===-1?(u.be=o+p+1,p=k+1):u.toks.push(i[S])}y(),Tu(c,e);let m=ni(c);return{hunks:m.hunks,cosmetic:r.concat(m.cosmetic),parts:c,cosmeticEq:r}}function Tu(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r.gap.length)continue;let o=n+1<e.length?e[n+1].bs:1/0;if(r.toks.length){if(r.bs===r.be)for(;r.bs+1<o&&r.bs<t.length&&r.toks[0].k===Tt&&t[r.bs].k===Tt;)r.toks=[...r.toks.slice(1),r.toks[0]],r.bs++,r.be++}else for(;r.be+1<o&&r.be<t.length&&t[r.bs].k===Tt&&t[r.be].k===Tt;)r.bs++,r.be++}}function ni(e,t=()=>!1){let n=[],r=[],o=null,s=-1;for(let l of e){let i=t(l);if(o&&!o.alone&&!i&&l.group===s){o.be=l.be;for(let a of l.gap)o.toks.push(a.tok);for(let a of l.toks)o.toks.push(a);continue}o&&n.push({bs:o.bs,be:o.be,toks:o.toks});for(let a of l.gap)r.push(a);o={bs:l.bs,be:l.be,toks:l.toks.slice(),alone:i},s=l.group}return o&&n.push({bs:o.bs,be:o.be,toks:o.toks}),{hunks:n,cosmetic:r}}var Eu=(e,t)=>e.bs===t.bs&&e.be===t.be&&si(e.toks,t.toks);function oi(e,t,n){let r=h=>u=>h.some(f=>Eu(u,f)),o=ni(e.parts,r(t.parts)),s=ni(t.parts,r(e.parts)),l=e.cosmeticEq.concat(o.cosmetic),i=t.cosmeticEq.concat(s.cosmetic),[a,c]=n?_u(o.hunks,s.hunks,n,l,i):[o.hunks,s.hunks];return{lh:a,rh:c,cosL:l,cosR:i}}function _u(e,t,n,r,o){let s=(p,y)=>p.k===y.k&&p.raw===y.raw,l=[{list:e.map(p=>({...p})),resp:new Set(r.map(p=>p.bi)),raw:new Map(r.map(p=>[p.bi,p.tok]))},{list:t.map(p=>({...p})),resp:new Set(o.map(p=>p.bi)),raw:new Map(o.map(p=>[p.bi,p.tok]))}],i=p=>p.bs===p.be,a=(p,y,m,g)=>{let k=p.list[y];if(!i(k))return g(k)===m?k.toks:null;let S=y?p.list[y-1].be:0,v=y+1<p.list.length?p.list[y+1].bs:n.length;if(m<S||m>v)return null;let x=k.toks,O=k.bs;for(;O>m;){let C=x[x.length-1];if(!s(C,n[O-1])||p.resp.has(O-1))return null;x=[C,...x.slice(0,-1)],O--}for(;O<m;){if(!s(x[0],n[O])||p.resp.has(O))return null;x=[...x.slice(1),x[0]],O++}return x},c=(p,y,m,g,k,S)=>{let v=p.list[y],x=k?m.slice(m.length-g):m.slice(0,g),O=k?m.slice(0,m.length-g):m.slice(g),C={bs:S,be:S,toks:x};if(i(v)){if(!O.length){p.list[y]=C;return}let M={bs:S,be:S,toks:O};k&&(M.lead=!0),p.list.splice(y,1,...k?[M,C]:[C,M]);return}let _={bs:v.bs,be:v.be,toks:O};p.list.splice(y,1,...k?[_,C]:[C,_])},h=(p,y,m,g,k)=>{let S=p.list[y],v=k?m.slice(m.length-g):m.slice(0,g),x=k?m.slice(0,m.length-g):m.slice(g),O={bs:S.bs,be:S.be,toks:v};if(!x.length){p.list[y]=O;return}let C=k?{bs:S.bs,be:S.bs,toks:x,lead:!0}:{bs:S.be,be:S.be,toks:x};p.list.splice(y,1,...k?[C,O]:[O,C])},u=(p,y,m,g)=>{let k=p.list[y],S=m.list[g],v=k.be,x=S.bs;if(v>=x||y+1<p.list.length&&p.list[y+1].bs<=S.be||g>0&&m.list[g-1].be>=k.bs)return!1;for(let F=v;F<x;F++)if(!rr(n[F])||n[F].k.includes(`
3
+ `))return!1;let O=F=>n.slice(v,x).map(($,Ne)=>F.raw.get(v+Ne)||$),C=[...k.toks,...O(p)],_=[...O(m),...S.toks],M=(F,$,Ne)=>$>=0&&$+Ne.length<=F.length&&Ne.every((Ce,Be)=>F[$+Be].k===Ce.k),j=(F,$,Ne)=>Qs(F)&&n.slice($,Ne).some(Ce=>!rr(Ce)),I=F=>F.some($=>!rr($)),P,R,T,A;if(i(k)&&I(k.toks)&&M(_,0,k.toks)){let F=_.slice(k.toks.length);j(F,v,S.be)||(P=v,R=k.toks,T=_.slice(0,k.toks.length),A=[null,{bs:v,be:S.be,toks:F}])}if(P===void 0&&i(S)&&I(S.toks)){let F=C.length-S.toks.length,$=C.slice(0,F);M(C,F,S.toks)&&!j($,k.bs,x)&&(P=x,R=C.slice(F),T=S.toks,A=[{bs:k.bs,be:x,toks:$},null])}if(P===void 0)return!1;let W=F=>F&&(F.bs<F.be||F.toks.length);return p.list.splice(y,1,...[A[0],{bs:P,be:P,toks:R}].filter(W)),m.list.splice(g,1,...[{bs:P,be:P,toks:T},A[1]].filter(W)),!0},f=l[0],d=l[1];for(let p=0;p<64;p++){let y=!1;e:for(let m=0;m<f.list.length;m++)for(let g=0;g<d.list.length;g++){let k=f.list[m],S=d.list[g];if(!(k.bs===S.bs&&k.be===S.be&&si(k.toks,S.toks))){for(let v of[!0,!1]){let x=C=>v?C.be:C.bs,O=i(k)?[x(S),k.bs]:[x(k)];for(let C of O){let _=a(f,m,C,x),M=_&&a(d,g,C,x);if(!M)continue;let j=(A,W)=>v?A[A.length-1-W]:A[W],I=0;for(;I<_.length&&I<M.length&&j(_,I).k===j(M,I).k;)I++;if(!I)continue;let P=v?_.slice(0,_.length-I):_.slice(I),R=v?M.slice(0,M.length-I):M.slice(I);if(!(I<_.length&&I<M.length&&!Qs(P)&&!Qs(R)&&(i(k)&&i(S)||k.bs===S.bs&&k.be===S.be)||!(v?_.slice(_.length-I):_.slice(0,I)).some(A=>!rr(A)))){if(I===_.length&&I===M.length&&i(k)&&i(S)){if(k.bs===C&&S.bs===C)continue;f.list[m]={bs:C,be:C,toks:_},d.list[g]={bs:C,be:C,toks:M}}else!i(k)&&k.bs===S.bs&&k.be===S.be?(h(f,m,_,I,v),h(d,g,M,I,v)):(c(f,m,_,I,v,C),c(d,g,M,I,v,C));y=!0;break e}}}if(u(f,m,d,g)||u(d,g,f,m)){y=!0;break e}}}if(!y)break}return[f.list,d.list]}var Ou=48,Nu=.3;function Cu(e,t){let n=e.filter(l=>!rr(l)),r=t.filter(l=>!rr(l));if(Math.min(n.length,r.length)<Ou)return!1;let o=new Map;for(let l of n)o.set(l.k,(o.get(l.k)||0)+1);let s=0;for(let l of r){let i=o.get(l.k);i>0&&(s++,o.set(l.k,i-1))}return s/Math.min(n.length,r.length)<Nu}var Mu=(e,t)=>{let n=new Set;for(let r of e.toks)typeof r.k!="string"&&n.add(r.k.el);for(let r=e.bs;r<e.be;r++)typeof t[r].k!="string"&&n.add(t[r].k.el);return n},si=(e,t)=>e.length===t.length&&e.every((n,r)=>n.k===t[r].k);function Il(e,t,n,r="remote"){let o=Yn(e,t),s=Yn(e,n),{lh:l,rh:i,cosL:a,cosR:c}=oi(o,s,e),h=w=>w.bs===w.be,u=w=>w.toks.some(V=>typeof V.k=="string"),f=w=>h(w)&&!u(w),d=(w,V)=>V.bs<w.be&&w.bs<V.be,p=(w,V)=>!d(w,V)&&V.bs<=w.be&&w.bs<=V.be&&(h(w)&&u(w)||h(V)&&u(V))&&!(h(w)&&h(V)),y=(w,V)=>w.bs===V.bs&&w.be===V.be&&si(w.toks,V.toks),m=[],g=new Set;for(let w of l){let V=i.find(ne=>!g.has(ne)&&y(w,ne));V?(g.add(V),m.push({bs:w.bs,be:w.be,side:"both",l:w,r:V,toks:w.toks})):m.push({bs:w.bs,be:w.be,side:"L",l:w,toks:w.toks,lead:!!w.lead})}for(let w of i)g.has(w)||m.push({bs:w.bs,be:w.be,side:"R",r:w,toks:w.toks,lead:!!w.lead});m.sort((w,V)=>w.bs-V.bs||w.be-V.be||V.lead-w.lead);let k=0,S=0;for(let w of m)w.side==="both"&&(k+=w.toks.length-(w.be-w.bs));let v=m.map((w,V)=>V),x=w=>v[w]===w?w:v[w]=x(v[w]),O=(w,V)=>(w=x(w),V=x(V),w===V?!1:(v[w]=V,!0)),C=m.map(w=>Mu({bs:w.bs,be:w.be,toks:w.toks},e)),_={L:new Map,R:new Map};m.forEach((w,V)=>{let ne=w.side==="both"?["L","R"]:[w.side];for(let te of ne)for(let Pe of C[V])_[te].has(Pe)||_[te].set(Pe,[]),_[te].get(Pe).push(V)});for(let w of[_.L,_.R])for(let V of w.values())for(let ne=1;ne<V.length;ne++)O(V[0],V[ne]);for(let w=0;w<m.length;w++)for(let V=w+1;V<m.length;V++){let ne=m[w],te=m[V];ne.side===te.side&&ne.side!=="both"||ne.bs>te.be||(d(ne,te)||p(ne,te)?O(w,V):ne.bs===te.bs&&h(ne)&&h(te)&&S++)}let M=(w,V)=>{let ne=w==="L"?l:i;for(let te of ne)if(te.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===V.el))return te.bs;for(let te=0;te<e.length;te++)if(e[te].kind==="close"&&e[te].k.el===V.el)return te;return-1};m.forEach((w,V)=>{if(!(!f(w)||w.side==="both"))for(let ne of w.toks){if(ne.kind!=="open")continue;let te=M(w.side,ne.k);if(te<=w.bs)continue;let Pe=new Uint8Array(te-w.bs),ze=[];if(m.forEach((Se,it)=>{if(!(Se.side===w.side||h(Se))&&Se.bs<te&&Se.be>w.bs){ze.push(it);for(let tt=Math.max(Se.bs,w.bs);tt<Math.min(Se.be,te);tt++)Pe[tt-w.bs]=1}}),ze.length&&Pe.every(Se=>Se===1))for(let Se of ze)O(V,Se)}});let j=!0;for(;j;){j=!1;let w=new Map;m.forEach((V,ne)=>{let te=x(ne),Pe=w.get(te)||{bs:V.bs,be:V.be,L:!1,R:!1};Pe.bs=Math.min(Pe.bs,V.bs),Pe.be=Math.max(Pe.be,V.be),V.side!=="R"&&(Pe.L=!0),V.side!=="L"&&(Pe.R=!0),w.set(te,Pe)}),m.forEach((V,ne)=>{for(let[te,Pe]of w){if(x(ne)===x(te)||!(Pe.L&&Pe.R))continue;let ze=V.bs<Pe.be&&V.be>Pe.bs,Se=h(V)&&u(V)&&(V.bs===Pe.be||V.bs===Pe.bs);(ze||Se)&&O(ne,te)&&(j=!0)}})}let I=new Map;m.forEach((w,V)=>{let ne=x(V);I.has(ne)||I.set(ne,[]),I.get(ne).push(w)});let P=[];for(let w of I.values()){let V=w.some(te=>te.side==="L"),ne=w.some(te=>te.side==="R");if(V&&ne){let te=Math.min(...w.map(it=>it.bs)),Pe=Math.max(...w.map(it=>it.be)),ze=w.filter(it=>it.side!=="R").map(it=>it.l).sort((it,tt)=>it.bs-tt.bs),Se=w.filter(it=>it.side!=="L").map(it=>it.r).sort((it,tt)=>it.bs-tt.bs);P.push({bs:te,be:Pe,kind:"conflict",localHunks:ze,remoteHunks:Se})}else for(let te of w)P.push({bs:te.bs,be:te.be,kind:te.side,u:te})}let R=(w,V)=>{let ne=w==="L"?l:i;for(let te of ne)if(te.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===V.el))return te.bs+.5;for(let te=0;te<e.length;te++)if(e[te].kind==="close"&&e[te].k.el===V.el)return te;return 1/0},T=(w,V)=>{let ne=w==="L"?l:i;for(let te of ne)if(te.toks.some(Pe=>Pe.kind==="open"&&Pe.k.el===V.el))return te.bs-.5;for(let te=0;te<e.length;te++)if(e[te].kind==="open"&&e[te].k.el===V.el)return te;return-1/0},A=w=>w.kind==="R"?"R":"L",W=w=>w.kind==="R"?1:0;P.sort((w,V)=>{if(w.bs!==V.bs)return w.bs-V.bs;let ne=w.bs===w.be,te=V.bs===V.be;if(ne!==te)return ne?-1:1;if(ne&&te&&w.kind!=="conflict"&&V.kind!=="conflict"){let ze=w.u.toks,Se=V.u.toks,it=Q=>Q.length&&Q.every(ce=>ce.kind==="open"),tt=Q=>Q.length&&Q.every(ce=>ce.kind==="close");if(it(ze)&&it(Se)){let Q=Math.max(...ze.map(Re=>R(A(w),Re.k))),ce=Math.max(...Se.map(Re=>R(A(V),Re.k)));if(Q!==ce)return ce-Q}if(tt(ze)&&tt(Se)){let Q=Math.min(...ze.map(Re=>T(A(w),Re.k))),ce=Math.min(...Se.map(Re=>T(A(V),Re.k)));return Q!==ce?ce-Q:W(V)-W(w)}}let Pe=ze=>ze.u&&ze.u.lead?1:0;return Pe(V)-Pe(w)||W(w)-W(V)||w.be-V.be});let F=[],$=[],Ne=0,Ce=w=>{w>Ne&&(F.push({bs:Ne,be:w,toks:e.slice(Ne,w),source:"base"}),Ne=w)};for(let w of P){if(Ce(w.bs),w.kind==="conflict"){let V=ri(e,w.localHunks,w.bs,w.be),ne=ri(e,w.remoteHunks,w.bs,w.be),te=r==="local"?V:r==="both"?V.concat(ne):ne,Pe=(it,tt)=>{let Q=0;for(let ce of it)ce.be<=w.bs&&!tt.includes(ce)&&(Q+=ce.toks.length-(ce.be-ce.bs));return Q},ze=w.bs+Pe(l,w.localHunks),Se=w.bs+Pe(i,w.remoteHunks);$.push({bs:w.bs,be:w.be,ls:ze,le:ze+V.length,rs:Se,re:Se+ne.length,ms:0,me:0,base:e.slice(w.bs,w.be),local:V,remote:ne,resolved:te}),F.push({bs:w.bs,be:w.be,toks:te,source:"conflict",localHunks:w.localHunks,localToks:V,keepsLocal:r!=="remote"})}else F.push({bs:w.bs,be:w.be,toks:w.u.toks,source:w.kind==="R"?"remote":"local",localHunks:w.kind==="R"?[]:[w.u.l]});Ne=Math.max(Ne,w.be)}Ce(e.length);let Be=0,re=0;for(let w of F)w.source==="conflict"&&($[re].ms=Be,$[re].me=Be+w.toks.length,re++),Be+=w.toks.length;let Ee=new Map(a.map(w=>[w.bi,w.tok])),Ge=new Map(c.map(w=>[w.bi,w.tok])),_e=[];for(let w of F){w.source==="base"&&(w.toks=w.toks.map((V,ne)=>{let te=w.bs+ne,Pe=Ee.get(te),ze=Ge.get(te),Se=Pe&&ze?r==="remote"?ze:Pe:Pe||ze||V;return Se===V?V:{...Se,cosmetic:!0}}));for(let V of w.toks)_e.push({...V,src:w.source})}return{tokens:_e,segments:F,conflicts:$,localHunks:l,remoteHunks:i,collapsedDelta:k,samePoint:S,mapLocalOffset:Ru(e,l,F)}}function ri(e,t,n,r){let o=[],s=n;for(let l of t)o=o.concat(e.slice(s,l.bs),l.toks),s=l.be;return o.concat(e.slice(s,r))}var ti=e=>e.reduce((t,n)=>t+n.len,0);function Ru(e,t,n){let r=new Int32Array(e.length+1);for(let l=0;l<e.length;l++)r[l+1]=r[l]+e[l].len;let o=t.map(l=>({bs:r[l.bs],be:r[l.be],text:l.toks.map(i=>i.raw).join(""),ref:l})),s=n.map(l=>({bs:r[l.bs],be:r[l.be],len:ti(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?ti(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let i=null,a=null,c=0,h=0,u=0;for(let d of o){let p=d.bs-u;if(l<=h+p){i=u+(l-h);break}if(h+=p,u=d.bs,l<=h+d.text.length){a=d,c=l-h,i=d.bs;break}h+=d.text.length,u=d.be}i===null&&(i=u+(l-h));let f=0;for(let d of s){if(!a&&i<=d.bs)return f;if(!(a?d.localHunks.includes(a.ref):i<d.be)){f+=d.len;continue}if(d.source==="base")return f+(i-d.bs);if(d.source==="remote")return f+d.len;if(d.source==="local")return f+Math.min(c,d.len);if(!d.keepsLocal||!a)return f+d.len;let y=d.localHunks.indexOf(a.ref),m=ti(ri(e,d.localHunks.slice(0,y),d.ref.bs,a.ref.bs));return f+Math.min(m+c,d.localLen)}return f}}function uo(e,t,n,r="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:g=>Math.min(g,t.length),granularity:"word"};let o=Tn(e,t,n),s=hn(e,o),l=hn(t,o),i=hn(n,o),a=s.length<=2e4&&l.length<=2e4&&i.length<=2e4?Il(s,l,i,r):null,c="word",h=s;if(!a){let g=k=>k.split(/(?<=\n)/).map(S=>({k:S,raw:S,len:S.length}));h=g(e),a=Il(h,g(t),g(n),r),c="line"}let u=g=>g.map(k=>k.raw).join(""),f=g=>{let k=[0];for(let S of g)k.push(k[k.length-1]+S.len);return k},d=f(h),p=null,y=null,m=null;if(a.conflicts.length){let g=k=>k.split(/(?<=\n)/).map(S=>({k:S,raw:S,len:S.length}));p=f(c==="line"?g(t):l),y=f(c==="line"?g(n):i),m=f(a.tokens)}return{text:u(a.tokens),conflicts:a.conflicts.map(g=>({bs:d[g.bs],be:d[g.be],ls:p[g.ls],le:p[g.le],rs:y[g.rs],re:y[g.re],ms:m[g.ms],me:m[g.me],base:u(g.base),local:u(g.local),remote:u(g.remote),resolved:u(g.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:c}}function gr(e,t,n=4e3){if(e===t)return[];let r=Tn(e,t),o=hn(e,r),s=hn(t,r),l=Yn(o,s,n),i=[0];for(let a of o)i.push(i[i.length-1]+a.len);return l.hunks.map(a=>({bs:i[a.bs],be:i[a.be],text:a.toks.map(c=>c.raw).join("")}))}function Xt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Hn({base:e,side:t,retained:n,transfers:r,baseAtomKey:o=i=>i.el,sideAtomKey:s=i=>i.el,budget:l=Xt()}){let i=[],a=x=>({status:"fallback",reason:x}),c=x=>x>l.remaining?!1:(l.remaining-=x,!0);if(!c((n.length+r.length)*3))return a("work-limit");for(let[x,O]of[["retained",n],["transfer",r]])for(let C of O){let{from:_,to:M,target:j}=C;if(!Number.isInteger(_)||!Number.isInteger(M)||!Number.isInteger(j)||_<0||M<=_||M>e.text.length||j<0||j+M-_>t.text.length)return a("invalid-range");i.push({...C,kind:x})}let h=Symbol(),u=x=>(O,C)=>{if(!c(1))throw h;return l.sortComparisons++,x(O,C)},f,d;try{f=i.slice().sort(u((x,O)=>x.from-O.from||x.to-O.to)),d=i.slice().sort(u((x,O)=>x.target-O.target||x.to-x.from-(O.to-O.from)))}catch(x){if(x===h)return a("work-limit");throw x}if(!c(i.length*2))return a("work-limit");for(let x=1;x<f.length;x++)if(f[x].from<f[x-1].to)return a("source-overlap");for(let x=1;x<d.length;x++)if(d[x].target<d[x-1].target+d[x-1].to-d[x-1].from)return a("target-overlap");for(let x of f){let O=x.to-x.from;if(!c(O))return a("work-limit");for(let C=0;C<O;C++){let _=x.from+C,M=x.target+C;if(l.comparisons++,e.text[_]!==t.text[M])return a("unequal-occurrence");let j=e.atomAt.get(_),I=t.atomAt.get(M);if(!!j!=!!I||j&&o(j)!==s(I))return a("different-atom")}}let p=e.text.length+t.text.length+2,y=i.reduce((x,O)=>x+(O.to-O.from)*2,2);if(!c(p+y+i.length))return a("work-limit");let m=new Int32Array(e.text.length+1).fill(-1),g=new Int32Array(t.text.length+1).fill(-1);l.mapCells+=p,l.mapWrites+=y;let k=-1,S=!0;for(let x of f){x.target<k&&(S=!1),k=x.target+x.to-x.from;for(let O=0;O<x.to-x.from;O++)m[x.from+O]=x.target+O,g[x.target+O]=x.from+O}return m[e.text.length]=t.text.length,g[t.text.length]=e.text.length,{status:"ready",runs:f,bTo:m,toB:g,monotone:S,covers:(x,O)=>{if(!c(O-x))return null;l.coverageChecks+=O-x;for(let C=x;C<O;C++)if(e.text[C]!==Tt&&!/\s/.test(e.text[C])&&m[C]<0)return!1;return!0}}}function ii({base:e,side:t,baseOf:n=()=>null,budget:r=Xt()}){if(e.text===t.text||!e.text.includes(Tt)&&!t.text.includes(Tt))return{status:"none"};let o=(e.text.length+t.text.length)*8;if(o>r.remaining)return{status:"fallback",reason:"work-limit"};r.remaining-=o,r.boundarySteps=(r.boundarySteps||0)+o;let s=(p,y)=>y<p.length&&(p[y]===Tt||/\s/.test(p[y])),l=new Map,i=Symbol(),a=(p,y)=>{let m=p.stackAt[y]||[];if(!l.has(m)){if(m.length>r.remaining)throw i;r.remaining-=m.length,r.boundarySteps+=m.length,l.set(m,m.find(g=>g.block)?.el||null)}return l.get(m)},c=[],h=(p,y)=>{let m=a(e,p),g=a(t,y),k=m&&g&&n(g)!==m?"transfer":"retained",S=c[c.length-1];S&&S.to===p&&S.target+S.to-S.from===y&&S.kind===k&&S.destination===g?S.to++:c.push({from:p,to:p+1,target:y,destination:g,kind:k})},u=0,f=0,d=!1;try{for(;u<e.text.length||f<t.text.length;){if(u<e.text.length&&f<t.text.length&&e.text[u]===t.text[f]){let S=e.atomAt.get(u),v=t.atomAt.get(f);if(!!S!=!!v||S&&n(v.el)!==S.el)return{status:"none"};h(u++,f++);continue}if(!s(e.text,u)&&!s(t.text,f))return{status:"none"};let p=u,y=f;for(;s(e.text,u);)u++;for(;s(t.text,f);)f++;let m=e.text.slice(p,u),g=t.text.slice(y,f);(m.includes(Tt)||g.includes(Tt))&&(d=!0);let k=0;for(;k<u-p&&k<f-y&&e.text[u-k-1]===t.text[f-k-1];)k++;for(let S=k;S>0;S--)h(u-S,f-S)}}catch(p){if(p===i)return{status:"fallback",reason:"work-limit"};throw p}return d?Hn({base:e,side:t,retained:c.filter(p=>p.kind==="retained"),transfers:c.filter(p=>p.kind==="transfer"),sideAtomKey:p=>n(p.el)||p.el,budget:r}):{status:"none"}}var Ll=/\s/,Vo=/\S/;function Ln(e,t,n,r,o,s,l=-1,i=-1){if(!e.length)return-1;o(r,e.length);let a=new Int32Array(e.length),c=0;for(let d=1;d<e.length;d++){for(o(r,1);c&&(o(r,1),e[c]!==e[d]);)c=a[c-1];o(r,1),e[c]===e[d]&&c++,a[d]=c}let h=-1,u=0,f=0;c=0;for(let d=0;d<t.length;d++){for(o(r,1);c&&(o(r,1),e[c]!==t[d]);)c=a[c-1];if(o(r,1),e[c]===t[d]&&c++,c!==e.length)continue;let p=d+1-e.length,y=d+1;for(c=a[c-1];u<n.length&&n[u].from<p;)o(r,1),u++;for(;f<n.length&&n[f].to<y;)o(r,1),f++;if(o(r,6),!(u===n.length||f===n.length||n[u].from!==p||n[f].to!==y||l>=0&&p<i&&y>l)){if(!s)return p;if(h>=0)return-1;h=p}}return h}function ho(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function li(e,t,n,r){let o=null;for(let l of t)if(r(n,1),!(l.source!==e.source||l.side!==e.side))for(let i of l.runs){if(r(n,1),i.source!==e.source)continue;let a=Math.max(e.from,i.from),c=Math.min(e.to,i.to);a>=c||(o||(r(n,e.to-e.from),o=new Uint8Array(e.to-e.from)),r(n,c-a),o.fill(1,a-e.from,c-e.from))}if(!o)return!1;r(n,e.to-e.from);let s=!1;for(let l=e.from;l<e.to;l++)if(Vo.test(e.flat.text[l])){if(!o[l-e.from])return!1;s=!0}return s}function ai({source:e,side:t,views:n,eligible:r,blocked:o,baseId:s,model:l,tokensOf:i,budget:a,charge:c}){let{V:h,A:u,idOf:f}=n[t],d=n[1-t];if(e.nodeType!==1||u.identical.has(e)||d.A.identical.has(e)||o.has(e)||!r(e))return null;let p=h.twin(e),y=d.V.twin(e);if(!p||!y||u.map.get(e)!==p||u.reverse.get(p)!==e||d.A.map.get(e)!==y||d.A.reverse.get(y)!==e||!h.here(p)||!d.V.here(y)||!r(p)||!r(y))return null;let m=s(e);if(m!==f(p)||m!==d.idOf(y))return null;let g=l(e,null,a),k=l(p,u,a),S=l(y,d.A,a);if(!ho(g)||!ho(k)||!ho(S))return null;let v=g.flat.text,x=k.flat.text;if(c(a,v.length+x.length*3),!Vo.test(x)||x.length>=v.length)return null;let O=v.startsWith(x),C=v.endsWith(x);if(O===C)return null;let _=O?x.length:0,M=O?v.length:v.length-x.length,j=_,I=M;for(;j<I&&(c(a,1),!!Ll.test(v[j]));)j++;for(;I>j&&(c(a,1),!!Ll.test(v[I-1]));)I--;if(j===I)return null;let P=i(g,a),R=!1,T=!1;for(let A of P)c(a,1),A.from===j&&(R=!0),A.to===I&&(T=!0);return!R||!T?null:{source:e,side:t,flat:g.flat,from:_,to:M}}function jl({base:e,views:t,side:n,attempt:r,eligible:o,blocked:s,baseId:l,model:i,tokensOf:a,certificates:c,charge:h,exhausted:u,limit:f}){if(f<=0)return null;let d=Xt(f),{V:p,A:y,idOf:m}=t[n],g=t[1-n],[k,S,v,x]=r,O=null;try{for(let C=k;C<=S;C++){h(d,1);let _=e[C];if(_.nodeType!==1||y.identical.has(_)||g.A.identical.has(_)||s.has(_)||!o(_))continue;let M=ai({source:_,side:n,views:t,eligible:o,blocked:s,baseId:l,model:i,tokensOf:a,budget:d,charge:h});if(!M||li(M,c,d,h))continue;let{flat:j,from:I,to:P}=M;h(d,(P-I)*2);let R=j.text.slice(I,P).trim();for(let T=v;T<=x;T++){h(d,1);let A=p.units[T],W=p.baseOf(A);if(!W||W===_||W.nodeType!==1||A.nodeType!==1||W.parentNode!==_.parentNode||A.parentNode!==y.map.get(_).parentNode||y.map.get(W)!==A||y.reverse.get(A)!==W||s.has(W)||!o(W)||!o(A)||l(W)!==m(A))continue;let F=i(W,null,d),$=i(A,y,d);if(!ho(F)||!ho($))continue;let Ne=F.flat.text,Ce=$.flat.text;if(h(d,Ne.length),!Vo.test(Ne)||Ce.length<=Ne.length)continue;let Be=a($,d),re=Ln(Ne,Ce,Be,d,h,!0);if(!(re<0)&&!(Ln(R,Ce,Be,d,h,!1,re,re+Ne.length)<0)){(O||=[]).push(M);break}}}}catch(C){if(C!==u)throw C}return O}function Pl(e,t,n,r,o,s,l){if(s==="both"||n.atoms.length||r.atoms.length||o.atoms.length)return s;let i=s==="remote";if(i?l.rss!==l.rse||l.lss===l.lse||l.local===l.base:l.lss!==l.lse||l.rss===l.rse||l.remote===l.base)return s;for(let a of e){if(a.source!==t||a.side!==(i?1:0)||a.flat.text!==n.text||a.flat.nodes.length!==n.nodes.length||l.be<=a.from||l.bs>=a.to)continue;let c=!0;for(let u=0;u<n.nodes.length;u++){let f=a.flat.nodes[u],d=n.nodes[u];if(f.node!==d.node||f.s!==d.s||f.e!==d.e){c=!1;break}}if(!c)continue;let h=!1;for(let u=l.bs;u<l.be;u++)if(Vo.test(n.text[u])){if(u<a.from||u>=a.to){c=!1;break}h=!0}if(c&&h)return i?"local":"remote"}return s}var zn="\uFFFC";var Iu={caret:0},En=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),zl=new Set(["BR","WBR","IMG"]),ci=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function Vn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||zl.has(e.tagName))return!0;if(!En.has(e.tagName))return!ci.has(e.tagName);if(t.remoteWins&&t.remoteWins(e))return!1;let n=t.inlineCache&&t.inlineCache.get(e);if(n!==void 0)return n;let r=!0;for(let o of e.childNodes)if(!Vn(o,t)){r=!1;break}return t.inlineCache&&t.inlineCache.set(e,r),r}function Lu(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function on(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},r=(o,s)=>{for(let l of o){if(l.nodeType===3){let u=l.nodeValue;if(!u)continue;n.nodes.push({node:l,s:n.text.length,e:n.text.length+u.length}),n.text+=u;for(let f=0;f<u.length;f++)n.stackAt.push(s);continue}if(l.nodeType!==1)continue;if(t.ignored&&t.ignored(l)){n.pins.push({el:l,i:n.text.length});continue}if(t.skip&&t.skip.has(l))continue;let i=t.via&&t.via(l)||l;i!==l&&(n.via||(n.via=new Map)).set(i,l);let a=l.tagName;if(t.blocks&&t.blocks.has(l)){n.text.length&&n.text[n.text.length-1]!==Tt&&(n.stackAt.push(s),n.text+=Tt);let u={el:l,tag:a,from:n.text.length,to:-1,depth:s.length,block:!0};n.marks.push(u);let f=s.concat([u]);r(i.childNodes,f),n.stackAt.push(f),n.text+=Tt,u.to=n.text.length;continue}let c=En.has(a)&&Lu(i);if(zl.has(a)||!En.has(a)||t.remoteWins&&t.remoteWins(l)||t.atomize&&t.atomize(l)||c){n.atoms.push({i:n.text.length,el:l,key:c?a+":empty":a,stack:s}),n.stackAt.push(s),n.text+=zn;continue}let h={el:l,tag:a,from:n.text.length,to:-1,depth:s.length};n.marks.push(h),r(i.childNodes,s.concat([h])),h.to=n.text.length}};if(r(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&Go(n).trim()===""){let o=n.atoms[0];n.placeholder=o.el,n.text=n.text.slice(0,o.i)+n.text.slice(o.i+1),n.stackAt.splice(o.i,1);for(let s of n.nodes)s.s>o.i&&(s.s--,s.e--);n.atoms=[]}return n.atomAt=new Map(n.atoms.map(o=>[o.i,o])),n}function ju(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Pu(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,"&quot;")}"`;return t+">"}function Rr(e,t,n){let r="",o=[];for(let s=t;s<n;s++){let l=e.stackAt[s],i=0;for(;i<o.length&&i<l.length&&o[i]===l[i];)i++;for(;o.length>i;)r+=`</${o.pop().tag.toLowerCase()}>`;for(;o.length<l.length;){let c=l[o.length];r+=Pu(c.el),o.push(c)}let a=e.atomAt.get(s);r+=a?a.el.outerHTML:e.text[s]===Tt?"":ju(e.text[s])}for(;o.length;)r+=`</${o.pop().tag.toLowerCase()}>`;return r}function Du(e,t){let n=[...e.el.attributes].filter(r=>!t(e.el,r.name)).map(r=>r.name+"="+r.value).sort().join("");return e.tag+"|"+n}function Vl(e,t){let n=[...e.attributes].filter(r=>!t(e,r.name)).map(r=>r.name+"="+r.value).sort().join("");return e.tagName+"|"+n+"|"+e.innerHTML}function Dl(e,t=()=>!1){let n=new Map,r=s=>{let l=n.get(s);return l===void 0&&(l="{"+s.map(i=>Du(i,t)).sort().join(",")+"}",n.set(s,l)),l},o="";for(let s=0;s<e.text.length;s++){let l=e.atomAt.get(s);o+=(l?"["+Vl(l.el,t)+"]":e.text[s])+r(e.stackAt[s])}return e.text.length===0&&e.placeholder&&(o+="[br]"),o}function Mr(e,t,n,r=o=>o.key){let o=[],s=e.text,l=0,i=a=>{if(a<=l)return;let c=s.slice(l,a);if(n)for(let h of c.split(/(?<=\n)/))o.push({k:h,raw:h,len:h.length});else for(let h of hn(c,t))o.push(h)};for(let a of e.atoms)i(a.i),o.push({k:"\0"+r(a),raw:zn,len:1,atom:!0}),l=a.i+1;return i(s.length),o}function Go(e){if(!e.atoms.length)return e.text;let t="",n=0;for(let r of e.atoms)t+=e.text.slice(n,r.i),n=r.i+1;return t+e.text.slice(n)}var Ir=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n].len;return t};function Wo(e,t,n,r){let o=Ir(t),s=Ir(n),l=[],i=0,a=0;for(let h of r.hunks){a+=h.bs-i;let u=a+h.toks.length;l.push({bs:o[h.bs],be:o[h.be],ss:s[a],se:s[u],text:e.text.slice(s[a],s[u]),toks:h.toks,lead:!!h.lead}),a=u,i=h.be}let c=new Map;for(let h of r.cosmetic)c.set(h.bi,h.tok.raw);return{hunks:l,respell:c}}function Fl(e,t,n){let r=l=>l===Tt||/\s/.test(l),o=l=>l.replace(/[\u001E\s]/g,""),s=[];for(let l of e){let i=t.slice(l.bs,l.be),a=n.slice(l.ss,l.se);if(!i.includes(Tt)&&!a.includes(Tt)||i.includes(zn)||a.includes(zn)||o(i)!==o(a)){s.push(l);continue}let c=0,h=0;for(;;){let u=c,f=h;for(;u<i.length&&r(i[u]);)u++;for(;f<a.length&&r(a[f]);)f++;let d=c,p=h;for(;d<u&&p<f&&i[d]===a[p];)d++,p++;let y=u,m=f;for(;y>d&&m>p&&i[y-1]===a[m-1];)y--,m--;if(y>d||m>p){let g=a.slice(p,m);s.push({bs:l.bs+d,be:l.bs+y,ss:l.ss+p,se:l.ss+m,text:g,toks:[...g].map(k=>({k,raw:k,len:1})),lead:l.lead})}if(u>=i.length)break;c=u+1,h=f+1}}return s}function Bl(e,t,n){let r=new Int32Array(t+1).fill(-1),o=new Int32Array(n+1).fill(-1),s=0,l=0,i=a=>{for(;s<a;)r[s]=l,o[l]=s,s++,l++};for(let a of e)i(a.bs),s=a.be,l=a.se;return i(t),r[t]=l,o[l]=t,{bTo:r,toB:o}}function ql(e,t,n){let r=[],o=0,s=0,l=(i,a)=>{if(o===i&&s===a)return;let c=t.text.slice(s,a);r.push({bs:o,be:i,ss:s,se:a,text:c,toks:hn(c,Tn(c)),lead:!1})};for(let i of n.runs)l(i.from,i.target),o=i.to,s=i.target+i.to-i.from;return l(e.text.length,t.text.length),{hunks:r,respell:new Map}}function Ul(e,t,n,r){let o=Ir(t),s=Ir(n),l=(a,c)=>{let h=0,u=a.length;for(;h<u;){let f=h+u>>>1;a[f]<c?h=f+1:u=f}return a[h]===c?h:-1};for(let a of e.hunks)if(l(o,a.bs)<0||l(o,a.be)<0)return null;if(e.hunks.some(a=>l(s,a.ss)<0||l(s,a.se)<0)){if(!r)return null;let a=[];for(let f of e.hunks)a.push(f.ss,f.se);let c=[],h=0,u=0;for(let f of n){let d=u+f.len;for(;h<a.length&&a[h]<=u;)h++;let p=u;for(;h<a.length&&a[h]<d;){let y=a[h++];if(y>p){let m=f.raw.slice(p-u,y-u);c.push(...hn(m,Tn(m))),p=y}}if(p===u)c.push(f);else{let y=f.raw.slice(p-u);c.push(...hn(y,Tn(y)))}u=d}n=c,s=Ir(n)}let i=[];for(let a of e.hunks){let c=l(o,a.bs),h=l(o,a.be),u=l(s,a.ss),f=l(s,a.se);if(c<0||h<0||u<0||f<0)return null;i.push({bs:c,be:h,toks:n.slice(u,f),gap:[],group:i.length})}return{parts:i,cosmeticEq:[],tokens:n}}function fi(e,t,n,r={},o=null){return Wl(e,t,n,r.base,r.local,r.remote,o,{})}function Wl(e,t,n,r,o,s,l,i){let a=Tn(Go(e),Go(t),Go(n)),c=Mr(e,a,!1,r),h=Mr(t,a,!1,o),u=Mr(n,a,!1,s),f=c.length>2e4||h.length>2e4||u.length>2e4;f&&(c=Mr(e,a,!0,r),h=Mr(t,a,!0,o),u=Mr(n,a,!0,s));let d=l?.local?ql(e,t,l.local):null,p=l?.remote?ql(e,n,l.remote):null,y=d?Ul(d,c,h,!f):Yn(c,h),m=p?Ul(p,c,u,!f):Yn(c,u);d&&y&&(h=y.tokens),p&&m&&(u=m.tokens);let g,k;if(y&&m){let S=oi(y,m,c);g=Wo(t,c,h,{hunks:S.lh,cosmetic:S.cosL}),k=Wo(n,c,u,{hunks:S.rh,cosmetic:S.cosR})}else g=d||Wo(t,c,h,y),k=p||Wo(n,c,u,m);return g.hunks=Fl(g.hunks,e.text,t.text),k.hunks=Fl(k.hunks,e.text,n.text),i.base=e,i.local=t,i.remote=n,i.lines=f,i.baseTokens=c,i.localEdits=g,i.remoteEdits=k,i.localMap=Bl(g.hunks,e.text.length,t.text.length),i.remoteMap=Bl(k.hunks,e.text.length,n.text.length),i.full=null,i}function $l(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Lr=/\s/;function Ko(e,t,n){for(let r=t;r<n;r++)if(!Lr.test(e[r]))return!1;return!0}function Fu(e,t,n){let r=e.cache[n]||(e.cache[n]=new Map);if(r.has(t))return r.get(t);let o=n===0?"local":"remote",s=n===0?"remote":"local",l=t.baseMark,i=t[s+"Mark"],a=!t.block&&!t[o]&&!!i&&l.to>l.from;if(a){let c=n===0?e.ML:e.MR,h=n===0?e.MR:e.ML,u=n===0?e.fr:e.fl,f=!1;for(let d=l.from;d<l.to;d++){if(c.bTo[d]>=0){a=!1;break}h.bTo[d]<0&&!Lr.test(e.fb.text[d])&&(f=!0)}if(a&&!f){for(let d=i.from;d<i.to;d++)if(h.toB[d]<0&&!Lr.test(u.text[d])){f=!0;break}}a&&=f}return r.set(t,a),a}function Hl(e,t,n,r,o,s,l,i,a){let c=i===0?e.fl:e.fr,h=null;for(let u=n;u<r;u++){let f=t[u];if(!Ko(c.text,f.ss,f.se))return null;if(Ko(e.fb.text,f.bs,f.be)){if(f.bs<f.be&&f.ss<f.se||Lr.test(e.fb.text[f.bs-1]||"")||Lr.test(e.fb.text[f.be]||""))continue;return null}let d=!1;for(let p=f.bs;p<f.be;p++){if(Lr.test(e.fb.text[p]))continue;let y=null;for(let m of e.fb.stackAt[p]){let g=e.byEl.get(m.el);if(g&&Fu(e,g,i)){y=g;break}}if(!y)return null;(h||(h=new Set)).add(y),d=!0}if(!d)return null}if(!h){if((i===0?"local":"remote")!==a)return null;let u=i===0?e.fr:e.fl,f=!1;for(let d=s;d<l;d++){let p=o[d];if(!Ko(e.fb.text,p.bs,p.be))return null;Ko(u.text,p.ss,p.se)||(f=!0)}if(!f)return null}return h||0}function br(e){let{out:t,policy:n="remote",L:r,R:o}=e,s=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,i=e.conflicts||[],a=e.decisions||[],c=i.length,h=e.conflict||(b=>i.push(b)),u={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},f=[],d=!!(r&&r.reverse&&r.map&&o&&o.reverse&&o.map),p={base:null,local:null,remote:null};if(!e.prepared&&d&&e.moveIn){let b=Te=>Ke=>Te.some(je=>je===Ke||je.nodeType===1&&je.contains(Ke)),L=b(e.local),q=b(e.remote),U=b(e.base),X=new Set,me=Te=>{if(!En.has(Te.tagName))return;let Ke=r.map.get(Te),je=o.map.get(Te);(Ke&&!L(Ke)||je&&!q(je))&&X.add(Te);for(let Ye of Te.children)me(Ye)};for(let Te of e.base)Te.nodeType===1&&me(Te);let ve=Te=>Ke=>{if(!En.has(Ke.tagName))return!1;let je=Te.reverse.get(Ke);return!!je&&(X.has(je)||!U(je))};X.size&&(p.base=Te=>X.has(Te)),p.local=ve(r),p.remote=ve(o)}let y={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&d&&e.moveIn){let b=U=>X=>U.some(me=>me===X||me.nodeType===1&&me.contains(X)),L=b(e.local),q=b(e.remote);for(let U of on(e.base,{...e,atomize:p.base}).atoms){let X=r.map.get(U.el),me=o.map.get(U.el),ve=!!X&&!L(X),Te=!!me&&!q(me);!ve&&!Te||(ve&&e.movePlanned?.(U.el,"local",X,null),Te&&e.movePlanned?.(U.el,"remote",me,null),y.base.add(U.el),X&&!ve&&y.local.add(X),me&&!Te&&y.remote.add(me),L(U.el)&&y.local.add(U.el),q(U.el)&&y.remote.add(U.el))}}let m=e.prepared?.base||on(e.base,{...e,atomize:p.base,skip:y.base}),g=e.prepared?.local||on(e.local,{...e,atomize:p.local,skip:y.local}),k=e.prepared?.remote||on(e.remote,{...e,atomize:p.remote,skip:y.remote}),S=new Map(m.atoms.map(b=>[b.el,b])),v={},x=b=>e.prepared?e.prepared.full?.(b)||null:y[b].size?(v[b]||(v[b]=on(e[b],{...e,atomize:p[b]})),v[b]):null,O=(b,L,q)=>{L.namespaceURI?b.setAttributeNS(L.namespaceURI,L.name,q):b.setAttribute(L.name,q)},C=(b,L,q,U)=>{if(!L&&(!q||!U)){for(let me of(q||U).attributes)O(b,me,me.value);return}let X=new Map;for(let me of[L,q,U])if(me)for(let ve of me.attributes)X.set(ve.name,ve);for(let[me,ve]of X){let Te=L?L.getAttribute(me):null,Ke=q?q.getAttribute(me):Te,je=U?U.getAttribute(me):Te,Ye;Ke===je?Ye=Ke:Ke===Te?(Ye=je,a.push({kind:"attr",el:b,name:me,source:"remote"})):je===Te?(Ye=Ke,a.push({kind:"attr",el:b,name:me,source:"local"})):(Ye=n==="local"?Ke:je,h({kind:"attr",el:b,name:me,base:Te,local:Ke,remote:je,resolved:Ye},{el:b,sample:ve}),a.push({kind:"attr",el:b,name:me,source:"both"})),Ye!=null&&O(b,ve,Ye)}},_=(b,L,q,U)=>b&&e.mergeAttrs?e.mergeAttrs(b,L,q,U):C(U,b,L,q),M=e.mergeElement||((b,L,q)=>{let U=t.createElement(b.tagName);_(b,L,q,U);let X=L||b,me=q||b,ve=n==="local"?X.isEqualNode(b)?me:X:me.isEqualNode(b)?X:me;for(let Te of ve.childNodes)U.appendChild(t.importNode(Te,!0));return s.set(U,{base:b,local:L,remote:q}),U}),j=e.cloneUnit||((b,L)=>{let q=t.importNode(b,!0);return s.set(q,{base:null,local:L==="local"?b:null,remote:L==="remote"?b:null}),q}),I=e.atomKey||(b=>Vl(b,()=>!1)),P=(b,L)=>{let q=new Map;for(let U of b.atoms)if(e.remoteWins&&e.remoteWins(U.el)&&En.has(U.el.tagName))q.set(U,"w"+U.el.tagName+"#"+(U.el.id||""));else if(!d)q.set(U,U.key);else if(b===m)q.set(U,"="+I(U.el));else{let X=L.reverse.get(U.el),me=X?S.get(X):null;me?q.set(U,"="+I(me.el)):X?q.set(U,"m"+I(U.el)):q.set(U,"="+I(U.el))}return U=>q.get(U)},R=P(m,null),T=P(g,r),A=P(k,o),W=e.certifiedOrigins?e.certifiedOrigins(m,g,k,R,T,A):null;if(W?.fallback)return null;if(!W&&!e.prepared&&e.blocks){let b=Xt(),L=ii({base:m,side:g,baseOf:U=>r?.reverse?.get(U)||null,budget:b}),q=ii({base:m,side:k,baseOf:U=>o?.reverse?.get(U)||null,budget:b});(L.status==="ready"||q.status==="ready")&&(W={local:L.status==="ready"?L:null,remote:q.status==="ready"?q:null})}let F=e.prepared||Wl(m,g,k,R,T,A,W,u),$=F.lines,Ne=F.baseTokens,Ce=F.localEdits,Be=F.remoteEdits,re=F.localMap,Ee=F.remoteMap,Ge=m.text.length,_e=b=>new Map(b.atoms.map(L=>[L.el,L])),w=_e(g),V=_e(k),ne=(b,L,q)=>{let U=new Set;if(!d)return U;for(let X of b.atoms){let me=S.get(L.reverse.get(X.el));me&&q.bTo[me.i]<0&&U.add(me)}return U},te=ne(g,r,re),Pe=ne(k,o,Ee),ze=b=>!Vn(b,{...e,remoteWins:null}),Se=new Set;if(d)for(let b of m.atoms){if(!ze(b.el))continue;let L=r.map.get(b.el)||null,q=o.map.get(b.el)||null,U=L&&!q?L:q&&!L?q:null;U&&(w.has(U)||V.has(U))&&!U.isEqualNode(b.el)&&Se.add(b)}let it=1,tt=(b,L)=>({id:it++,tag:b,base:null,local:null,remote:null,rank:L}),Q=new Map,ce=[];for(let b of m.marks){let L=tt(b.tag,b.depth);L.block=!!b.block,L.base=b.el,L.baseMark=b,Q.set(b.el,L),ce.push(L)}let Re=(b,L)=>{let q=-1,U=-1;for(let X=b.from;X<b.to;X++){let me=L[X];me>=0&&(q<0&&(q=me),U=me+1)}return q<0?null:[q,U]},Ue=(b,L,q,U)=>{for(let X of b.marks){let me=q?q.reverse.get(X.el):null;me&&q.identical.has(me)&&q.pairIdenticalChildren&&q.pairIdenticalChildren(me);let ve=me?Q.get(me):null;if(ve&&ve[L]&&(ve=null),!ve){let Te=Re(X,U),Ke=0;if(Te)for(let je of ce){if(je.tag!==X.tag||je[L]||!!je.block!=!!X.block)continue;let Ye=Math.min(Te[1],je.baseMark.to)-Math.max(Te[0],je.baseMark.from);(Ye>Ke||Ye===Ke&&Ye>0&&Math.abs(je.rank-X.depth)<Math.abs(ve.rank-X.depth))&&(ve=je,Ke=Ye)}}ve||(ve=tt(X.tag,X.depth),ve.block=!!X.block,ve.new=L),ve[L]=X.el,ve[L+"Mark"]=X,Q.set(X.el,ve)}};Ue(g,"local",r,re.toB),Ue(k,"remote",o,Ee.toB);let qe=b=>b.merged||b,ot=b=>{let L=new Set;for(let q of b)q.block||L.add(Q.get(q.el));return L},xt=new Map,kt=b=>{let L=xt.get(b);return L||(L=ot(b),xt.set(b,L)),L},Ct=(b,L)=>{let q=[],U=null;for(let X=0;X<Ge;X++){let me=L[X];if(me<0){U&&q.push(U),U=null;continue}let ve=kt(m.stackAt[X]),Te=kt(b.stackAt[me]),Ke=new Set,je=new Set;for(let Ye of Te)ve.has(Ye)||Ke.add(Ye);for(let Ye of ve)Te.has(Ye)||je.add(Ye);if(!Ke.size&&!je.size){U&&q.push(U),U=null;continue}if(U&&$l(U.added,Ke)&&$l(U.removed,je)){U.be=X+1;continue}U&&q.push(U),U={bs:X,be:X+1,added:Ke,removed:je}}return U&&q.push(U),q},dt=Ct(g,re.bTo),St=Ct(k,Ee.bTo),ht=b=>b.be>b.bs?[b.bs,b.be-1]:[b.bs-1,b.bs],H=(b,L)=>{if(Ge===0)return null;let[q,U]=ht(b);for(let X of L){if(X.be<=q)continue;if(X.bs>U)break;let me=X.bs<=q&&U<X.be;return me&&b.text===""&&X.bs===b.bs&&X.be===b.be?"straddle":me?X:b.be>b.bs?"straddle":null}return null},ie=b=>b.bs===b.be,pe=(b,L,q=null)=>{let U=!1;for(let X=b.bs;X<b.be;X++){let me=m.text[X];if(me===Tt)U=!0;else if(!/\s/.test(me))return!1}for(let X=b.ss;X<b.se;X++){let me=L.text[X];if(me===Tt)U=!0;else if(!/\s/.test(me)){let ve=q&&e.scopeUnits&&ie(b)&&L.atomAt.get(X);if(!ve||!ze(ve.el)||q.ss!==q.se||q.bs>=q.be)return!1;for(let Ke=q.bs;Ke<q.be;Ke++)if(!/\s/.test(m.text[Ke]))return!1;let Te=L===g?1:2;if(!e.scopeUnits[Te].includes(ve.el)||(Te===1?r:o)?.reverse.has(ve.el))return!1;U=!0}}return U},ge=(b,L)=>b.bs<L.be&&L.bs<b.be,Ae=(b,L)=>b.bs<=L.be&&L.bs<=b.be&&ie(b)!==ie(L),N=(b,L)=>m.text.slice(b.bs,b.be).includes(Tt)||L.text.slice(b.ss,b.se).includes(Tt),D=b=>{if(ie(b))return!1;let L=b.bs,q=b.be;for(;L>0&&/\s/.test(m.text[L-1]);)L--;for(;q<m.text.length&&/\s/.test(m.text[q]);)q++;return(L===0||m.text[L-1]===Tt)&&(q===m.text.length||m.text[q]===Tt)},Y=(b,L)=>!N(b,L)&&!D(b),J=(b,L)=>ge(b,L)||Ae(b,L)&&!(b.transferIn||b.transferOut||L.transferIn||L.transferOut)&&!(pe(b,g,L)&&Y(L,k))&&!(pe(L,k,b)&&Y(b,g)),se=(b,L)=>{if(b.bs!==L.bs||b.be!==L.be||b.toks.length!==L.toks.length)return!1;let q=b.ss,U=L.ss;for(let X=0;X<b.toks.length;X++){let me=b.toks[X],ve=L.toks[X];if(me.k!==ve.k||me.atom&&!g.atomAt.get(q).el.isEqualNode(k.atomAt.get(U).el))return!1;q+=me.len,U+=ve.len}return!0},Fe=(b,L,q,U)=>{for(let X of m.atoms){if(X.i<b.bs||X.i>=b.be||U.has(X)||Se.has(X))continue;let me=L.bTo[X.i],ve=me>=0?q.atomAt.get(me):null;if(ve&&!ve.el.isEqualNode(X.el))return!0}return!1},ee=[],Me=null,Ve=null,Ie=Ce.hunks,ke=Be.hunks,B=0,G=0,he=0,be=0,fe=0,we=b=>{b>he&&(ee.push({src:"base",from:he,to:b,dL:be,dR:fe}),he=b)};for(;B<Ie.length||G<ke.length;){let b=Ie[B],L=ke[G],q=!!b&&(!L||b.bs<L.bs||b.bs===L.bs&&b.be<=L.be&&!L.lead);if(b&&L&&b.bs===L.bs&&ie(b)&&ie(L)){let Gt=pe(b,g),fo=pe(L,k);Gt!==fo&&(q=fo)}let U=q?b:L,X=q?L:b,me=!!X&&se(b,L),ve=!!X&&(q?!!Ie[B+1]&&se(Ie[B+1],L):!!ke[G+1]&&se(b,ke[G+1])),Te=!!X&&!me&&!ve&&(Ge===0||J(b,L)),Ke=Te,je=H(U,q?St:dt);if(je==="straddle"&&(Ke=!0),!Ke&&U.be>U.bs&&(Ke=Fe(U,q?Ee:re,q?k:g,q?te:Pe)),!Ke&&me){we(U.bs),ee.push({src:"both",lfrom:b.ss,rfrom:L.ss,len:U.text.length,owner:b.owner||L.owner||null,transfer:b.transferIn||L.transferIn||null}),he=U.be,be+=U.text.length-(U.be-U.bs),fe+=U.text.length-(U.be-U.bs),B++,G++;continue}if(!Ke){we(U.bs),ee.push({src:q?"local":"remote",from:U.ss,to:U.se,inherit:je&&je!=="straddle"?je:null,owner:U.owner||null,transfer:U.transferIn||null}),he=U.be,q?(be+=U.text.length-(U.be-U.bs),B++):(fe+=U.text.length-(U.be-U.bs),G++);continue}let Ye=U.bs,yt=U.be,ut=B,gt=G,Vt=Gt=>Gt.bs<yt&&Gt.be>Ye||ie(Gt)&&(Gt.bs===Ye||Gt.bs===yt);q?ut++:gt++,Te&&(Ye=Math.min(Ye,X.bs),yt=Math.max(yt,X.be),q?gt++:ut++);let $t=!0;for(;$t;){for($t=!1;ut<Ie.length&&Vt(Ie[ut]);)Ye=Math.min(Ye,Ie[ut].bs),yt=Math.max(yt,Ie[ut].be),ut++,$t=!0;for(;gt<ke.length&&Vt(ke[gt]);)Ye=Math.min(Ye,ke[gt].bs),yt=Math.max(yt,ke[gt].be),gt++,$t=!0}let kn=Ye+be,un=Ye+fe,An=yt-Ye,Cn=yt-Ye;for(let Gt=B;Gt<ut;Gt++)An+=Ie[Gt].text.length-(Ie[Gt].be-Ie[Gt].bs);for(let Gt=G;Gt<gt;Gt++)Cn+=ke[Gt].text.length-(ke[Gt].be-ke[Gt].bs);let Un=kn+An,$n=un+Cn;if(we(Ye),B<ut&&G<gt&&!W&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!m.atoms.length&&!g.atoms.length&&!k.atoms.length&&!m.pins.length&&!g.pins.length&&!k.pins.length){Me||={fb:m,fl:g,fr:k,ML:re,MR:Ee,byEl:Q,cache:[null,null]};let Gt=Hl(Me,Ie,B,ut,ke,G,gt,0,n),fo=Hl(Me,ke,G,gt,Ie,B,ut,1,n);if(Gt===null!=(fo===null)){let Hs=Gt!==null,Al=Hs?Gt:fo;if(Al){Ve||=new Map;for(let ru of Al)Ve.set(ru,Hs?"local":"remote")}ee.push(Hs?{src:"remote",from:un,to:$n}:{src:"local",from:kn,to:Un}),he=yt,be+=An-(yt-Ye),fe+=Cn-(yt-Ye),B=ut,G=gt;continue}}let nn={kind:"text",node:e.node||null,base:Rr(m,Ye,yt),local:Rr(g,kn,Un),remote:Rr(k,un,$n),resolved:null,range:null,bs:Ye,be:yt,lss:kn,lse:Un,rss:un,rse:$n},mr=e.sourceRetentions?Pl(e.sourceRetentions,e.scope?.base,m,g,k,n,nn):n;nn.resolved=mr==="local"?nn.local:mr==="remote"?nn.remote:nn.local+nn.remote,mr!=="remote"&&ee.push({src:"local",from:kn,to:Un,conflict:nn}),mr!=="local"&&ee.push({src:"remote",from:un,to:$n,conflict:nn});let pr={site:"inline",policy:mr,fb:m,fl:g,fr:k,scope:e.scope||null,synthetic:!!e.synthetic,full:x,merged:u};f.push(pr),h(nn,pr),he=yt,be+=An-(yt-Ye),fe+=Cn-(yt-Ye),B=ut,G=gt}we(Ge);let oe=m.text,K=[];if(Ce.respell.size||Be.respell.size){let b=Ir(Ne),L=[];for(let q=0;q<Ne.length;q++){let U=Ne[q].raw,X=Ce.respell.get(q)??U,me=Be.respell.get(q)??U;(X!==U||me!==U)&&K.push([b[q],X!==U&&me!==U?"both":X!==U?"local":"remote"]),L.push(X===me?X:X===U?me:me===U||n==="local"?X:me)}oe=L.join("")}let ue="",Le=[],De=[],We=[],Oe=[];for(let b of ee){let L=ue.length;if(b.src==="base"){for(let q=b.from;q<b.to;q++)Le.push(q),De.push(e.nativeTransfers?re.bTo[q]:q+b.dL),We.push(e.nativeTransfers?Ee.bTo[q]:q+b.dR),Oe.push(b);ue+=oe.slice(b.from,b.to)}else if(b.src==="both"){for(let q=0;q<b.len;q++){let U=b.transfer&&(b.transfer.side==="remote"?b.rfrom+q:b.lfrom+q);Le.push(b.transfer&&U>=b.transfer.ss&&U<b.transfer.se?b.transfer.bs+U-b.transfer.ss:-1),De.push(b.lfrom+q),We.push(b.rfrom+q),Oe.push(b)}ue+=g.text.slice(b.lfrom,b.lfrom+b.len)}else{let q=b.src==="local"?g:k,U=b.transfer&&e.nativeTransfers.byOrigin[b.src==="local"?"remote":"local"].get(b.transfer.key);for(let X=b.from;X<b.to;X++){let me=b.transfer&&X>=b.transfer.ss&&X<b.transfer.se?b.transfer.bs+X-b.transfer.ss:-1,ve=me>=0&&(!U||U.destination===b.owner)?(b.src==="local"?Ee:re).bTo[me]:-1;Le.push(me),De.push(b.src==="local"?X:ve),We.push(b.src==="remote"?X:ve),Oe.push(b)}ue+=q.text.slice(b.from,b.to)}b.ms=L,b.me=ue.length,b.conflict&&(b.conflict.range||(b.conflict.range=[L,L]),b.conflict.range[1]=ue.length)}let Ze=ue.length,st=new Int32Array(Ge+1).fill(-1),E=new Int32Array(g.text.length+1).fill(-1),z=new Int32Array(k.text.length+1).fill(-1);for(let b=0;b<Ze;b++)Le[b]>=0&&(st[Le[b]]=b),De[b]>=0&&(E[De[b]]=b),We[b]>=0&&(z[We[b]]=b);let Z=(b,L)=>{let q=-1,U=-1;for(let X=b.from;X<b.to;X++){let me=L[X];me>=0&&(q<0&&(q=me),U=me+1)}return q<0?null:[q,U]},ye=[],de=[];for(let b of new Set(Q.values()))b.new==="local"?ye.push(b):b.new==="remote"&&de.push(b);let le=(b,L)=>{b.remote=L.remote,b.remoteMark=L.remoteMark,b.new="both",L.merged=b,Q.set(L.remote,b)};if(ye.length&&de.length){let b=e.idOf;for(let L of ye){let q=b?b.local(L.local):null;if(!q)continue;let U=de.find(X=>!X.merged&&X.tag===L.tag&&!!X.block==!!L.block&&b.remote(X.remote)===q);U&&le(L,U)}for(let L of ye){if(L.remote)continue;let q=Z(L.localMark,E);if(q)for(let U of de){if(U.merged||U.tag!==L.tag||!!U.block!=!!L.block)continue;let X=Z(U.remoteMark,z);if(X&&Math.min(q[1],X[1])-Math.max(q[0],X[0])>0){le(L,U);break}}}}xt.clear();let ae=b=>{for(let L of b)if(L.block)return qe(Q.get(L.el));return null},$e=m.marks.some(b=>b.block)||g.marks.some(b=>b.block)||k.marks.some(b=>b.block),Je=new Array(Ze).fill(null),He=new Set;if(e.nativeTransfers)for(let b=0;b<Ze;b++){let L=Oe[b].owner;Je[b]=L?qe(Q.get(L)):Le[b]>=0?ae(m.stackAt[Le[b]]):null}else if($e){let b=(je,Ye,yt)=>{let ut=new Set([je,Ye,yt]);ut.delete(null);let gt=[];for(let $t of ut){let kn=$t===je,un=$t===Ye,An=$t===yt;(un===An?un:un===kn?An:un)&&gt.push($t)}if(gt.length<=1)return gt[0]||null;let Vt=n==="local"?Ye:yt;return gt.includes(Vt)?Vt:gt[0]},L=(je,Ye)=>Ye>=0?ae(je.stackAt[Ye]):null,q=new Map;for(let je=0;je<Ze;je++){if(ue[je]!==Tt)continue;let Ye=Le[je]>=0?L(m,Le[je]):null,yt=L(g,De[je]),ut=L(k,We[je]);q.set(je,[Ye,Le[je]>=0?b(Ye,yt,ut):yt||ut])}let U=new Set([...q.values()].map(je=>je[1])),X=je=>je!==Tt&&je!==zn&&!/\s/.test(je),me=(je,Ye)=>{let yt=je;for(;yt<Ye&&!X(ue[yt]);)yt++;return yt<Ye&&Le[yt]>=0?L(m,Le[yt]):null},ve=new Map,Te=0;for(let je=0;je<Ze;je++){if(ue[je]!==Tt)continue;let[Ye,yt]=q.get(je),ut=me(Te,je),gt=yt,Vt=ve.get(gt)===gt&&ut===gt;gt&&ve.has(gt)&&!Vt&&Ye&&!ve.has(Ye)&&!U.has(Ye)&&(gt=Ye),gt&&!ve.has(gt)&&ve.set(gt,ut);for(let $t=Te;$t<=je;$t++)Je[$t]=gt;Te=je+1}let Ke=je=>{for(let Ye=0;Ye<je.text.length;Ye++)if(X(je.text[Ye])&&!L(je,Ye))return!0;return!1};if(!Ke(m)&&!Ke(g)&&!Ke(k)){let je=[],Ye=0;for(let ut=0;ut<Ze;ut++)(ue[ut]===Tt||ut===Ze-1)&&(je.push([Ye,ut]),Ye=ut+1);let yt=new Set(Je);for(let ut=0;ut<je.length;ut++){let[gt,Vt]=je[ut];if(Je[Vt])continue;let $t=gt;for(;$t<=Vt&&!X(ue[$t]);)$t++;if($t>Vt)continue;let kn=L(m,Le[$t]),un=L(g,De[$t]),An=L(k,We[$t]),Cn=b(kn,un,An)||un||An||kn;if(Cn&&!yt.has(Cn)){yt.add(Cn);for(let nn=gt;nn<=Vt;nn++)Je[nn]=Cn;continue}let Un=ut>0&&Je[je[ut-1][1]],$n=ut+1<je.length&&Je[je[ut+1][1]];if(Un)He.add(je[ut-1][1]);else if($n&&ue[Vt]===Tt)He.add(Vt);else continue;for(let nn=gt;nn<=Vt;nn++)Je[nn]=Un||$n}}}let Xe=new Map,Qe=b=>{let L=Xe.get(b);if(L)return L;L=[1/0,-1/0];for(let[q,U]of[[b.baseMark,st],[b.localMark,E],[b.remoteMark,z]]){let X=q&&Z(q,U);X&&(L[0]=Math.min(L[0],X[0]),L[1]=Math.max(L[1],X[1]))}return Xe.set(b,L),L},rt=(b,L,q)=>{let U=-1,X=-1;for(let me=0;me<b.length;me++){let ve=Q.get(b[me].el);ve===L&&(U=me),ve===q&&(X=me)}return U>=0&&X>=0?U-X:0},jt=(b,L)=>[...b].sort((q,U)=>{for(let ve of L){let Te=rt(ve,q,U);if(Te)return Te}let X=Qe(q),me=Qe(U);return X[0]-me[0]||me[1]-X[1]||q.rank-U.rank||q.id-U.id}),Et=new Map,en=new Map,Pt=e.nativeTransfers?[]:null,vt=b=>{if(Pt)return Pt;let L=Le[b],q=De[b],U=We[b],X=Oe[b];if(L>=0){let ut=m.stackAt[L],gt=g.stackAt[q],Vt=k.stackAt[U],$t=Et.get(ut);$t||Et.set(ut,$t=new Map);let kn=$t.get(gt);kn||$t.set(gt,kn=new Map);let un=kn.get(Vt);if(un)return un;let An=kt(ut),Cn=kt(gt),Un=kt(Vt),$n=new Set;for(let nn of new Set([...An,...Cn,...Un])){let mr=An.has(nn),pr=Cn.has(nn),Gt=Un.has(nn);(pr===Gt?pr:pr===mr?Gt:pr)&&$n.add(nn)}return un=jt($n,[gt,Vt,ut]),kn.set(Vt,un),un}if(X.src==="both"){let ut=g.stackAt[q],gt=k.stackAt[U];return jt(new Set([...kt(ut),...kt(gt)]),[ut,gt])}let ve=(X.src==="local"?g:k).stackAt[X.src==="local"?q:U];if(!X.inherit)return jt(kt(ve),[ve]);let Te=en.get(X);Te||en.set(X,Te=new Map);let Ke=Te.get(ve);if(Ke)return Ke;let je=new Set(kt(ve));for(let ut of X.inherit.added)je.add(qe(ut));for(let ut of X.inherit.removed)je.delete(qe(ut));let Ye=X.src==="local"?k:g,yt=(X.src==="local"?Ee.bTo:re.bTo)[X.inherit.bs];return Ke=jt(je,[ve,Ye.stackAt[yt]]),Te.set(ve,Ke),Ke},At=new Int32Array(g.text.length+1);At[g.text.length]=Ze;for(let b=g.text.length-1;b>=0;b--)At[b]=E[b]>=0?E[b]:At[b+1];Iu.caret+=g.text.length;let wt=b=>b<=0?0:(b>g.text.length&&(b=g.text.length),E[b-1]>=0?E[b-1]+1:At[b]),Ft=[],mt=[],Wt=null,Mt=[],gn="",Jt=-1,Kn=b=>{Wt?Wt.appendChild(b):Ft.push(b)},Bn=b=>{if(!gn)return;let L=t.createTextNode(gn);Kn(L),mt.push({node:L,ms:Jt,me:b,local:[],u:Mt.length?Mt[Mt.length-1].u:null}),gn=""},qo=new Set,Gn=new Map,ao=new Set,$s=b=>{let L=t.createElement(b.tag);if(b.block&&Bt.add(L),!Gn.has(b)){Gn.set(b,L),_(b.base,b.local,b.remote,L),s.set(L,{base:b.base,local:b.local,remote:b.remote});let U=(ve,Te)=>d&&b[Te]&&ve.reverse.get(b[Te])?Te:null,X=!b.base&&(U(r,"local")||U(o,"remote"));if(X){let ve=X==="local"?r.reverse.get(b.local):o.reverse.get(b.remote),Te=s.get(L);Te.local=Te.local||r.map.get(ve)||null,Te.remote=Te.remote||o.map.get(ve)||null,a.push({kind:"move",el:L,source:X}),e.moveBuilt?.(ve,X,b[X],L)}else b.base||a.push({kind:"insert",el:L,source:b.local&&b.remote?"both":b.local?"local":"remote"});let me=s.get(L);me.local&&(ao.has(me.local)?me.local=null:ao.add(me.local))}else{let U=Gn.get(b);for(let X of U.attributes)X.name!=="id"&&X.name!=="data-id"&&O(L,X,X.value);s.set(L,{base:null,local:null,remote:null})}Kn(L),Mt.push({u:b,el:L}),Wt=L},xe=new Set,nt=new Map;for(let b of g.pins){let L=wt(b.i);nt.has(L)||nt.set(L,[]),nt.get(L).push(b)}let et=b=>{let L=nt.get(b);if(L){Bn(b);for(let q of L){let U=q.el.namespaceURI&&q.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(q.el.namespaceURI,q.el.tagName):t.createElement(q.el.tagName);s.set(U,{base:null,local:q.el,remote:null,pinned:!0}),xe.add(U),Kn(U)}}},_t=m.atoms.length||g.atoms.length||k.atoms.length,Ht=b=>{if(!_t)return null;let L=Le[b]>=0?m.atomAt.get(Le[b]):null,q=De[b]>=0?g.atomAt.get(De[b]):null,U=We[b]>=0?k.atomAt.get(We[b]):null;return L||q||U?{ab:L,al:q,ar:U}:null},at=(b,L,q)=>{let U=e.idOf;if(!U||!U.base)return!1;let X=U.base(b.el);return X!=null&&X===U[q](L.el)},Nt=(b,L,q,U,X)=>{if(!b||!d)return null;let me=S.get(L.reverse.get(b.el))||null;return!me||me===U||(U?me.el.isEqualNode(U.el)&&!at(me,b,X):q.bTo[me.i]>=0)?null:me},Ut=(b,L)=>{if(!b||!d||!e.moveIn)return null;let q=L.reverse.get(b.el);return q&&!S.has(q)?q:null},pt=(b,L)=>{let q=new Map;for(let U of b.atoms)q.set(L(U),(q.get(L(U))||0)+1);return q},Rt=pt(m,R),dn=pt(g,T),bn=pt(k,A),On=b=>{let L=R(b);return Rt.get(L)===1&&(dn.get(L)||0)<=1&&(bn.get(L)||0)<=1},wn=new Map,Nn=new Set,qn=new Set,Uo=new Set,ft=null;for(let b=0;b<Ze;b++){let L=Ht(b);if(!L)continue;let{ab:q,al:U,ar:X}=L,me=Nt(X,o,Ee,q,"remote"),ve=Nt(U,r,re,q,"local"),Te=q,Ke=null;if(me?(Te=me,Ke="remote"):ve&&(Te=ve,Ke="local"),Te){q&&Te!==q&&(ft||=new Map).set(q,Ke),Nn.has(Te)?wn.set(b,{dup:Te.el}):(Nn.add(Te),wn.set(b,{bk:Te,from:Ke,al:U,ar:X}));continue}let je=Ut(X,o),Ye=Ut(U,r),yt=je||Ye;if(yt){qn.has(yt)?wn.set(b,{dup:yt}):(qn.add(yt),wn.set(b,{moveIn:yt,side:je?"remote":"local",sideEl:je?X.el:U.el}));continue}let ut=(Vt,$t)=>Vt&&d&&S.get($t.reverse.get(Vt.el))||null,gt=ut(X,o)||ut(U,r);if(gt&&(Uo.add(gt),Oe[b].conflict&&(On(gt)||X&&(X.el===gt.el||o.identityPaired?.has(gt.el))&&at(gt,X,"remote")||U&&(U.el===gt.el||r.identityPaired?.has(gt.el))&&at(gt,U,"local")))){if(Nn.has(gt)){wn.set(b,{dup:gt.el});continue}Nn.add(gt)}wn.set(b,{al:U,ar:X})}let lt=new Map,qt,ct,Dt=(b,L)=>{if(b[L]>=0)return b[L];for(let q=L-1;q>=0;q--)if(b[q]>=0)return b[q]+1;return 0};if(d)for(let b of m.atoms){if(Nn.has(b)||Uo.has(b))continue;let L=r.map.get(b.el)||null,q=o.map.get(b.el)||null,U=L&&w.get(L),X=q&&V.get(q);if(L&&!U||q&&!X)continue;let me=!(U&&X)&&Se.has(b);if(!me&&!(U&&X&&(On(b)||ft?.has(b)||(U.el===b.el||r.identityPaired?.has(b.el))&&(X.el===b.el||o.identityPaired?.has(b.el))&&at(b,U,"local")&&at(b,X,"remote"))))continue;let ve=ft?.get(b),Te=n;if(ve){let ut=ve==="local"?k:g,gt=ve==="local"?o:r,Vt=ve==="local"?ct:qt;if(Vt===void 0){Vt=ut.atoms.length===m.atoms.length;for(let $t=0;Vt&&$t<m.atoms.length;$t++)Vt=gt.reverse.get(ut.atoms[$t].el)===m.atoms[$t].el;ve==="local"?ct=Vt:qt=Vt}Vt&&(Te=ve)}let Ke=Te==="local"?[[U,E],[X,z]]:[[X,z],[U,E]],[je,Ye]=Ke.find(([ut])=>ut),yt=Dt(Ye,je.i);lt.has(yt)||lt.set(yt,[]),lt.get(yt).push({a:b,lt:L,rt:q,edited:me}),Nn.add(b)}if(d&&e.moveIn){let b=[[g,r,E,"local"],[k,o,z,"remote"]];n!=="local"&&b.reverse();for(let[L,q,U,X]of b)for(let me of L.atoms){let ve=Ut(me,q);if(!ve||qn.has(ve))continue;qn.add(ve);let Te=Dt(U,me.i);lt.has(Te)||lt.set(Te,[]),lt.get(Te).push({move:ve,side:X,sideEl:me.el})}}let Zt=b=>{let L=lt.get(b);if(L){if(Bn(b),L.some(q=>ze(q.move?q.sideEl:q.a.el)))for(;Mt.length;)Mt.pop(),Wt=Mt.length?Mt[Mt.length-1].el:null;for(let{a:q,lt:U,rt:X,edited:me,move:ve,side:Te,sideEl:Ke}of L){if(ve){let Ye=e.moveIn(ve,Te,Ke);Ye&&Kn(Ye);continue}qo.add(q);let je=M(q.el,U,X);me&&(h({kind:"structure",el:je,detail:"edit-beats-delete",base:q.el},{subject:q.el,deleted:U?"remote":"local"}),a.push({kind:"insert",el:je,source:U?"local":"remote"})),Kn(je)}}},Bt=new Set,sn=i.length>c;for(let b=0;b<Ze;b++){let L=Ht(b),q=e.scopeUnits&&L&&(L.ab?.stack.some(ve=>ve.block)||L.al?.stack.some(ve=>ve.block)||L.ar?.stack.some(ve=>ve.block)),X=!!L&&ze((L.ab||L.al||L.ar).el)&&!q?[]:Je[b]?[Je[b],...vt(b)]:vt(b),me=0;for(;me<Mt.length&&me<X.length&&Mt[me].u===X[me];)me++;if(me<Mt.length)for(Bn(b);Mt.length>me;)Mt.pop(),Wt=Mt.length?Mt[Mt.length-1].el:null;if(et(b),Zt(b),X.length>Mt.length)for(Bn(b);Mt.length<X.length;)$s(X[Mt.length]);if(ue[b]===Tt){if(He.has(b))continue;Bn(b);let ve=Mt.length;for(;ve>0&&!Mt[ve-1].u.block;)ve--;if(ve>0)for(sn&&u.breakOut.set(b,Mt[ve-1].el);Mt.length>=ve;)Mt.pop(),Wt=Mt.length?Mt[Mt.length-1].el:null;continue}if(L){Bn(b);let ve=wn.get(b),Te;if(ve.dup){h({kind:"structure",el:null,detail:"both-moved",base:ve.dup},{subject:ve.dup});continue}if(ve.moveIn){if(Te=e.moveIn(ve.moveIn,ve.side,ve.sideEl),!Te)continue}else if(ve.bk){let Ke=ve.bk;if(qo.add(Ke),Ke===L.ab)Te=M(Ke.el,ve.al.el,ve.ar.el);else{let je=r.map.get(Ke.el)||null,Ye=o.map.get(Ke.el)||null;Te=M(Ke.el,je,Ye),(!je||!Ye)&&h({kind:"structure",el:null,detail:"move-beats-delete",base:Ke.el},{subject:Ke.el,deleted:je?"remote":"local"}),a.push({kind:"move",el:Te,source:ve.from})}}else ve.al?(Te=j(ve.al.el,"local"),ve.ar&&(s.get(Te).remote=ve.ar.el),a.push({kind:"insert",el:Te,source:ve.ar?"both":"local"})):(Te=j(ve.ar.el,"remote"),a.push({kind:"insert",el:Te,source:"remote"}));sn&&u.atomOut.set(b,Te),Kn(Te);continue}gn||(Jt=b),gn+=ue[b]}if(Bn(Ze),(nt.has(Ze)||lt.has(Ze))&&(Mt.length=0,Wt=null,et(Ze),Zt(Ze)),Ze===0&&(g.placeholder||k.placeholder||m.placeholder)){let b=t.createElement("br");s.set(b,{base:m.placeholder,local:g.placeholder,remote:k.placeholder}),Ft.push(b)}let Kt=0,It=b=>{for(;Kt>0&&mt[Kt-1].me>=b;)Kt--;for(;Kt<mt.length&&mt[Kt].me<b;)Kt++;let L=mt[Kt];if(!L)return mt[mt.length-1]||null;let q=mt[Kt+1];return L.me===b&&q&&q.ms===b?q:L},Ot=new Map,zt={},tn=(b,L,q)=>{let U=It(b)||(q?zt:null);if(!U)return;let X=Ot.get(U)||{l:!1,r:!1};L!=="remote"&&(X.l=!0),L!=="local"&&(X.r=!0),Ot.set(U,X)},er=b=>{if(b.conflict)return!0;let L=b.src==="local"?g.text:b.src==="remote"?k.text:"";for(let q=b.from;q<b.to;q++)if(L[q]!==zn&&L[q]!==Tt)return!0;return!1};for(let b of ee)b.src!=="base"&&tn(b.ms,b.conflict?"both":b.src,er(b));for(let[b,L]of K)st[b]>=0&&tn(st[b],L);for(let b of mt.length?mt:[zt]){let L=Ot.get(b);L&&a.push({kind:"text",node:b.node||null,source:L.l&&L.r?"both":L.l?"local":"remote"})}for(let b of ce){if(Gn.has(b))continue;let L=!b.local&&!(d&&r.map.get(b.base)),q=!b.remote&&!(d&&o.map.get(b.base));!L&&!q||a.push({kind:"remove",source:L&&q?"both":L?"local":"remote",base:b.base})}if(Ve)for(let[b,L]of Ve)Gn.has(b)&&h({kind:"structure",el:Gn.get(b),detail:"edit-beats-delete",base:b.base},{subject:b.base,deleted:L});let tr=(b,L,q)=>{if(L<=b)return!1;for(let U=b;U<L;U++)if(q[U]>=0)return!1;return!0};for(let b of ce)for(let L of["local","remote"]){let q=b[L+"Mark"],U=b.baseMark;if(!q)continue;let X=L==="local"?re:Ee;if(!tr(U.from,U.to,X.bTo)||!tr(q.from,q.to,X.toB))continue;let me=(L==="local"?Ie:ke).find(ve=>ve.ss<=q.from&&q.from<ve.se);me&&(me.be<=U.from||me.bs>=U.to)&&a.push({kind:"move",el:Gn.get(b)||null,source:L})}let Qf=b=>{let L=Q.get(b.node.parentNode);return L?qe(L):null};for(let b of g.nodes){let L=-1;for(let U=b.s;U<b.e;U++)if(E[U]>=0){L=E[U];break}let q;if(L>=0)q=It(L);else{let U=wt(b.s),X=Qf(b);q=mt.find(me=>me.u===X&&me.me>=U)||mt.filter(me=>me.u===X).pop()}q&&q.local.push(b)}let co=new Map,eu=mt[mt.length-1]||null,In=0;for(let b of g.nodes){let L=null;for(let q=b.s;q<=b.e;q++){let U=wt(q);for(;In>0&&mt[In-1].me>=U;)In--;for(;In<mt.length&&mt[In].me<U;)In++;let X=ve=>ve&&U>=ve.ms&&U<=ve.me&&(U<ve.me||q===b.e||ve===L),me=X(mt[In])?mt[In]:X(mt[In+1])?mt[In+1]:mt[In]||eu;if(!me)break;if(L===me){let ve=co.get(me);ve[ve.length-1].to=q-b.s;continue}L=me,co.has(me)||co.set(me,[]),co.get(me).push({node:b.node,from:q-b.s,to:q-b.s,flatStart:b.s})}}for(let b of mt){let L=b.local,q=!1;for(let ve of L)for(let Te=ve.s;Te<ve.e&&!q;Te++)(E[Te]<b.ms||E[Te]>=b.me)&&(q=!0);s.set(b.node,{base:null,local:L.map(ve=>ve.node),remote:null,caret:co.get(b)||[],partial:q});let U=b.ms,X=b.me-b.ms,me=ve=>{let Te=0,Ke=-1;for(let je of L){let Ye=je.e-je.s;if(ve<=Te+Ye){Ke=je.s+(ve-Te);break}Te+=Ye}return Ke<0&&(Ke=L.length?L[L.length-1].e:0),Math.max(0,Math.min(wt(Ke)-U,X))};me.flat=ve=>Math.max(0,Math.min(wt(ve)-U,X)),l.set(b.node,me)}function tu(){if(!g.text.includes(Tt))return[{flatLocal:g.text,localNodes:g.nodes,textNodes:mt,lToM:E,mapLocal:wt}];let b=[],L=0,q=0;for(let U=0;U<=g.text.length;U++){if(U<g.text.length&&g.text[U]!==Tt)continue;let X=L,me=U;if(me>X){let ve=[];for(;q<g.nodes.length&&g.nodes[q].e<=X;)q++;for(let Te=q;Te<g.nodes.length&&g.nodes[Te].s<me;Te++){let Ke=g.nodes[Te],je=Math.max(Ke.s,X),Ye=Math.min(Ke.e,me);je<Ye&&ve.push({node:Ke.node,s:je-X,e:Ye-X})}b.push({flatLocal:g.text.slice(X,me),localNodes:ve,textNodes:mt,lToM:E.subarray?E.subarray(X,me+1):E.slice(X,me+1),mapLocal:Te=>wt(X+Math.max(0,Math.min(Te,me-X)))})}L=U+1}return b}let vl={...e,blocks:Bt,ignored:b=>xe.has(b)||(e.ignored?e.ignored(b):!1)},wl=e.ignoreAttribute||(()=>!1),nu=Dl(on(Ft,vl),wl)!==Dl(k,wl);if(f.length){let b=L=>{let q=s.get(L);return q&&q.unchanged?q.remote:null};u.text=ue,u.textNodes=mt,u.out=on(Ft,{...vl,via:b})}let Or=null;if(e.scopeUnits){Or=new Map;let b=new Set(Ft),L=Te=>{for(;Te&&!b.has(Te);)Te=Te.parentNode;return Te},q=e.scopeUnits.map(Te=>{let Ke=new Map;for(let je of Te)if(je.nodeType===1)Ke.set(je,je);else for(let Ye of je.nodes)Ke.set(Ye,je);return Ke}),U=(Te,Ke)=>{for(;Te&&!Ke.has(Te);)Te=Te.parentNode;return Te?Ke.get(Te):null},X=[m,g,k].map((Te,Ke)=>{let je=new Array(Te.text.length);for(let Ye of Te.nodes){let yt=U(Ye.node,q[Ke]);yt&&je.fill(yt,Ye.s,Ye.e)}for(let Ye of Te.atoms)je[Ye.i]=U(Ye.el,q[Ke]);return je}),me=(Te,Ke)=>{if(!Te||!Ke)return;let je=Or.get(Te);je||Or.set(Te,je=new Set),je.add(Ke)};for(let Te of Ft){let Ke=s.get(Te);Ke&&(me(U(Ke.base,q[0]),Te),me(U(Ke.local,q[1]),Te),me(U(Ke.remote,q[2]),Te))}for(let Te of mt){let Ke=L(Te.node);for(let je=Te.ms;je<Te.me;je++)me(X[0][Le[je]],Ke),me(X[1][De[je]],Ke),me(X[2][We[je]],Ke)}let ve=new Map(Ft.map((Te,Ke)=>[Te,Ke]));for(let[Te,Ke]of Or)Or.set(Te,Array.from(Ke).sort((je,Ye)=>ve.get(je)-ve.get(Ye)))}return{unitOutputs:Or,nodes:Ft,text:ue,textNodes:mt,localDiverged:nu,mapLocal:wt,conflicts:i.slice(c),granularity:$?"line":"word",segments:tu(),localHunks:Ie,remoteHunks:ke,lToM:E}}function Kl(e,t,n,r,o){if(!o(e.length*8+1))return null;let s=0,l=t===0,i=!1;for(let a of hn(e,r)){if(!o(1))return null;if(s+=a.len,s===t&&(l=!0),s===n&&(i=!0),s>=n)break}return l&&i}function Bu(e,t,n,r,o,s,l){if(!l(t.length*2))return!1;let i=new Map,a=new Map,c=new Set;for(let h of t){let u=h.bs<h.be,f=u?n[h.ownerIndex].text.base:n[h.ownerIndex].text[e],d=u?h.bs:h.ss,p=u?h.be:h.se;if(!l((p-d)*4+1))return!1;for(;d<p&&/\s/.test(f[d]);)d++;for(;p>d&&/\s/.test(f[p-1]);)p--;if(d===p)continue;let y=f.slice(d,p),m=u?i:a;u&&h.text&&c.add(y),m.has(y)?m.set(y,null):m.set(y,{h,from:d,to:p})}for(let h of r){if(!l(1))return!1;if(h.side!==e)continue;let u=h.deletion,f=n[u.ownerIndex].text.base;if(!l((u.be-u.bs)*3)||c.has(f.slice(u.bs,u.be).trim()))return!1}for(let[h,u]of i){if(!l(h.length+1))return!1;let f=a.get(h);if(!u||!f)continue;let d=u.h,p=f.h;if(!d.text||d.transferOut||p.transferIn||d.owner===p.owner)continue;let y=n[d.ownerIndex],m=n[p.ownerIndex];if(!l(y.text.base.length))return!1;if(!/\S/.test(y.text.base.slice(0,d.bs)+y.text.base.slice(d.be)))continue;let g=Kl(y.text.base,u.from,u.to,s,l),k=Kl(m.text[e],f.from,f.to,s,l);if(g===null||k===null)return!1;if(!g||!k)continue;let S=`${y.index}:${u.from}:${u.to}`,v={key:S,side:e,source:d.owner,destination:p.owner,deletion:d,insertion:p,sourceOffset:u.from-d.bs,targetOffset:f.from-p.ss,length:u.to-u.from};d.transferOut=v,p.transferIn=v,o[e].set(S,v),r.push(v)}return!0}function Gl({base:e,local:t,remote:n,localTwin:r,remoteTwin:o,eligible:s,nodes:l,budget:i=Xt(2e4*32)}){let a=_=>_>i.remaining?!1:(i.remaining-=_,i.nativeSteps=(i.nativeSteps||0)+_,!0);if(e.length<2||t.length!==e.length||n.length!==e.length||!a(e.length*12))return null;for(let[_,M]of[["base",e],["local",t],["remote",n]]){let j=l[_];if(j.length!==M.length||j.some((I,P)=>I!==M[P]))return null}let c=[],h=0;for(let _=0;_<e.length;_++){let M=e[_],j=t[_],I=n[_];if(r(M)!==j||o(M)!==I)return null;let P={};for(let[R,T]of[["base",M],["local",j],["remote",I]]){if(!s(T)||T.tagName!==M.tagName||T.namespaceURI!==M.namespaceURI||!a(T.childNodes.length+1))return null;let A="";for(let W of T.childNodes){if(W.nodeType!==3||!a(W.data.length*4+1))return null;A+=W.data}if(A.includes(Tt)||(h+=A.length+1,h>2e4))return null;P[R]=A}c.push({base:M,local:j,remote:I,index:_,text:P})}let u=c.every(_=>Tn(_.text.base,_.text.local,_.text.remote)),f={local:[],remote:[]};for(let _ of c){_.hunks={local:[],remote:[]};for(let M of["local","remote"]){let j=_.text.base,I=_.text[M];if(j===I)continue;let P=j.length+I.length+4,R=P*8;if(!a(R))return null;let T=Math.floor(i.remaining/8),A=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(P*P+T)-P)/2)));if(A<1||!a(4*(A+1)*(P+A+1)))return null;let W=0;for(let F of gr(j,I,A)){if(!a(F.text.length+1))return null;let $=F.bs+W,Ne={...F,ss:$,se:$+F.text.length,toks:hn(F.text,u),owner:_.base,ownerIndex:_.index};_.hunks[M].push(Ne),f[M].push(Ne),W+=F.text.length-(F.be-F.bs)}}}let d=[],p={local:new Map,remote:new Map};for(let _ of["local","remote"]){let M=new Map,j=new Map,I=!1,P=(R,T,A)=>{R.has(T)?R.set(T,null):R.set(T,A)};for(let R of f[_]){if(!a(1))return null;let T=c[R.ownerIndex].text.base;if(R.bs<R.be&&R.text===""){let A=T.slice(R.bs,R.be);if(!a(A.length*2))return null;/\S/.test(A)&&P(M,A,R)}else if(R.bs===R.be&&/\S/.test(R.text)){if(!a(R.text.length*2))return null;P(j,R.text,R)}else R.bs<R.be&&(I=!0)}for(let[R,T]of M){if(!a(R.length+1))return null;let A=j.get(R);if(!T||!A||T.owner===A.owner)continue;let W=c[T.ownerIndex];if(!a(W.text.base.length))return null;if(!/\S/.test(W.text.base.slice(0,T.bs)+W.text.base.slice(T.be)))continue;let F=`${W.index}:${T.bs}:${T.be}`,$={key:F,side:_,source:T.owner,destination:A.owner,deletion:T,insertion:A};T.transferOut=$,A.transferIn=$,p[_].set(F,$),d.push($)}if(I&&j.size&&!Bu(_,f[_],c,d,p,u,a))return null}if(!d.length)return null;let y=(_,M)=>_.bs<M.be&&M.bs<_.be,m=_=>_.bs===_.be,g=(_,M)=>_.bs<=M.be&&M.bs<=_.be&&m(_)!==m(M),k=(_,M)=>_.bs===M.bs&&_.be===M.be&&_.text===M.text,S=(_,M)=>!!(_.transferIn||_.transferOut&&(!_.text||M.bs===_.be&&/\s/.test(M.text[0])||M.bs===_.bs&&/\s/.test(M.text[M.text.length-1])));for(let _ of d){let M=_.side==="local"?"remote":"local",j=c[_.deletion.ownerIndex];for(let I of j.hunks[M])if(!a(1)||y(_.deletion,I)&&I.transferOut?.key!==_.key)return null}for(let _ of c)for(let M of _.hunks.local)for(let j of _.hunks.remote){if(!a(1))return null;if(k(M,j)){if(M.transferIn?.key!==j.transferIn?.key)return null;continue}if(y(M,j)||g(M,j)&&!S(M,j)&&!S(j,M))return null}if(!a(h*8))return null;let v=new Set([...e,...t,...n]),x={base:on(e,{blocks:v}),local:on(t,{blocks:v}),remote:on(n,{blocks:v})},O={};for(let _ of["base","local","remote"]){let M=x[_];if(M.atoms.length||M.pins.length)return null;O[_]=new Map(M.marks.filter(j=>j.block).map(j=>[j.el,j.from]))}for(let _ of c){let M=O.base.get(_.base);if(M===void 0)return null;for(let j of["local","remote"]){let I=O[j].get(_[j]);if(I===void 0)return null;for(let P of _.hunks[j])P.bs+=M,P.be+=M,P.ss+=I,P.se+=I}}for(let _ of d)_.bs=_.deletion.bs+(_.sourceOffset||0),_.be=_.length===void 0?_.deletion.be:_.bs+_.length,_.ss=_.insertion.ss+(_.targetOffset||0),_.se=_.length===void 0?_.insertion.se:_.ss+_.length;let C={};for(let _ of["local","remote"]){let M=0,j=0,I=[];for(let R of f[_]){if(!a(1))return null;R.bs>M&&I.push({from:M,to:R.bs,target:j}),M=R.be,j=R.se}M<x.base.text.length&&I.push({from:M,to:x.base.text.length,target:j});let P=d.filter(R=>R.side===_).map(R=>({from:R.bs,to:R.be,target:R.ss,destination:R.destination}));if(C[_]=Hn({base:x.base,side:x[_],retained:I,transfers:P,budget:i}),C[_].status!=="ready")return null}return a(x.base.text.length)?{owners:c,blocks:v,transfers:d,byOrigin:p,budget:i,prepared:{base:x.base,local:x.local,remote:x.remote,lines:!1,baseTokens:hn(x.base.text,u),localEdits:{hunks:f.local,respell:new Map},remoteEdits:{hunks:f.remote,respell:new Map},localMap:C.local,remoteMap:C.remote,full:null}}:null}var ui=/\S/;function Yl({certificates:e,scopes:t,views:n,eligible:r,baseId:o,limit:s=2e4*32}){let l=Xt(s),i=Symbol(),a=[],c=u=>{if(u>l.remaining)throw i;l.remaining-=u},h=(u,f=null)=>{if(c(1),!u||u.nodeType!==1||u.parentNode?.nodeType!==1||!r(u))return null;for(let y=u.parentNode;y;y=y.parentNode)if(c(1),y.nodeType===11)return null;let d="",p=0;for(let y of u.childNodes){if(c(1),y.nodeType!==3)return null;if(c(y.data.length*4+1),f){let m=f.flat.nodes[p++];if(!m||m.node!==y||m.s!==d.length||m.e!==d.length+y.data.length)return null}d+=y.data}return c(d.length*3+1),f&&(f.flat.atoms.length||f.flat.pins?.length||p!==f.flat.nodes.length||f.flat.text!==d)?null:ui.test(d)?d:null};try{c(t[0].length+t[1].length+t[2].length+e.length);let u=t.map(d=>new Set(d)),f=new Map;for(let d of e){c(1);let p=f.get(d.source);p||f.set(d.source,p=[]),p.push(d)}for(let d of f.values()){let p=[null,null],y=[];for(let m of d){c(1);let{source:g,target:k,side:S,models:v,runs:x}=m;if(S!==0&&S!==1||!u[0].has(g)||!u[S+1].has(k))continue;let{V:O,A:C,idOf:_}=n[S],M=n[1-S],j=O.twin(g),I=M.V.twin(g),P=O.baseOf(k);if(!j||!I||!P||P===g||!u[0].has(P)||!u[S+1].has(j)||!u[2-S].has(I)||C.map.get(g)!==j||C.reverse.get(j)!==g||M.A.map.get(g)!==I||M.A.reverse.get(I)!==g||C.map.get(P)!==k||C.reverse.get(k)!==P||k.parentNode!==j.parentNode||P.parentNode!==g.parentNode||g.tagName!==j.tagName||g.tagName!==I.tagName||o(g)!==_(j)||o(g)!==M.idOf(I)||o(P)!==_(k))continue;let R=v.get(g),T=v.get(k);if(!R||!T)continue;let A=h(g,R),W=h(k,T),F=h(j),$=h(I);if(c((A?.length||0)+($?.length||0)),A===null||W===null||F===null||$===null||$===A)continue;let Ne=x.length>0,Ce=!1;for(let re of x){if(c(1),re.source!==g||re.target!==k||!Number.isInteger(re.from)||!Number.isInteger(re.to)||!Number.isInteger(re.targetFrom)||re.from<0||re.to<=re.from||re.to>A.length||re.targetFrom<0||re.targetFrom+re.to-re.from>W.length){Ne=!1;break}c((re.to-re.from)*3);for(let Ee=re.from;Ee<re.to;Ee++){if(A[Ee]!==W[re.targetFrom+Ee-re.from]){Ne=!1;break}ui.test(A[Ee])&&(Ce=!0)}if(!Ne)break}if(!Ne||!Ce)continue;let Be=p[S];Be||(c(A.length),Be=p[S]={source:g,side:S,flat:R.flat,before:A,covered:new Uint8Array(A.length)});for(let re of x)c(re.to-re.from),Be.covered.fill(1,re.from,re.to)}for(let m of p){if(!m)continue;let{source:g,side:k,flat:S,before:v,covered:x}=m;c(v.length*3+1);let O=-1,C=-1;for(let _=0;_<=v.length;_++)_<v.length&&x[_]?(O<0&&(O=_),C=_+1):(_===v.length||ui.test(v[_]))&&O>=0&&(y.push({source:g,side:k,flat:S,from:O,to:C}),O=C=-1)}c(y.length),a.push(...y)}}catch(u){if(u!==i)throw u}return{records:a,budget:l}}var qu="http://www.w3.org/1999/xhtml";function Uu(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function yn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===qu}function $u(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Xo(e,t){let n=e.getAttribute("src"),r=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(n){let o=n;try{let s=new URL(n,t);o=s.origin+s.pathname+s.search}catch{}return"script|src|"+r+"|"+o}return"script|inline|"+r+"|"+Uu(e.textContent.trim())}var Hu={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function jr(e,t=[],n=!1){if(!yn(e)||e.hasAttribute("src"))return null;let r=[Hu,...t];for(let o=0;o<r.length;o++){let s=r[o];if(!s.match(e))continue;if(!$u(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=s.identity(e);return l==null||l===""?null:{key:o+":"+l,raw:l,recognizer:s}}return null}function Xl(e,t,n){let r=new Set,o=s=>{yn(s)&&!t(s)&&r.add(Xo(s,n))};o(e);for(let s of e.querySelectorAll("script"))o(s);return r}function mo(e,t){let n=t.createElement("div");n.innerHTML="<script><\/script>";let r=n.firstChild;for(let o of e.attributes)r.setAttribute(o.name,o.value);return r.textContent=e.textContent,r}function Jl(e,t,n){let r=[],o=[],s=new Map,l=n.trackRecovery?new Set:null,i=Array.from(e.querySelectorAll("script"));yn(e)&&i.unshift(e);for(let a of i){if(!yn(a)||n.ignored(a)||n.skip.has(a)||t.has(Xo(a,n.baseURI)))continue;let c=a.ownerDocument.createElement("script");for(let h of a.attributes)c.setAttribute(h.name,h.value);if(c.textContent=a.textContent,n.beforeNodeAdded(c)===!1){l?.add(a);continue}c.hasAttribute("src")&&o.push(new Promise(h=>{c.addEventListener("load",()=>h()),c.addEventListener("error",()=>h())})),a.replaceWith(c),s.set(a,c),n.afterNodeAdded(c),r.push(c)}return{executed:r,loads:o,swapped:s,vetoed:l}}function zu(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function Vu(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function Zl(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Xo(e,t);if(n==="LINK"){let r=e.getAttribute("href");return r?"link|"+(e.getAttribute("rel")||"")+"|"+Vu(r,t):e.outerHTML}if(n==="META"){for(let r of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(r))return"meta|"+r+"="+e.getAttribute(r);return e.outerHTML}return n==="STYLE"?"style|"+zu(e.textContent):e.outerHTML}function di(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
4
+ `;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);if(n===-1)return e.length;t=n+2;continue}return t}}function Wu(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var Ku=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Gu=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function hi(e){try{return JSON.parse(e)}catch{return JSON.parse(Yu(e))}}function Yu(e){let t="",n=0,r=(o,s)=>{throw new Error(`Invalid relaxed JSON: ${o} at position ${s}`)};for(;n<e.length&&(n=di(e,n),!(n>=e.length));){let o=e[n];if("{}[]:".includes(o)){t+=o,n++;continue}if(o===","){let i=di(e,n+1);if(e[i]==="}"||e[i]==="]"){n++;continue}t+=o,n++;continue}if(o==='"'||o==="'"){let i=n+1;for(;i<e.length&&e[i]!==o;)e[i]==="\\"&&i++,i++;i>=e.length&&r("unterminated string",n);let a=e.slice(n+1,i);o==="'"&&(a=Wu(a)),t+='"'+a+'"',n=i+1;continue}let s=n;for(;s<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[s]);)s++;s===n&&r("unexpected character "+JSON.stringify(o),n);let l=e.slice(n,s);if(l==="true"||l==="false"||l==="null"||Ku.test(l)){t+=l,n=s;continue}if(Gu.test(l)){if(e[di(e,s)]===":"){t+='"'+l+'"',n=s;continue}r("unquoted value "+JSON.stringify(l),n)}r("invalid token "+JSON.stringify(l),n)}return t}var Qt=Symbol("hyper-morph-json-merge:missing"),Ql=["id","_id","uuid","key","slug","code","name"];function Pr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function po(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Xu(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function or(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!or(e[n],t[n]))return!1;return!0}if(Pr(e)&&Pr(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!po(t,r)||!or(e[r],t[r]))return!1;return!0}return!1}function ea(e,t,n,r){return or(t,n)?t:or(t,e)?n:or(n,e)?t:Pr(t)&&Pr(n)?Ju(Pr(e)?e:{},t,n,r):Array.isArray(t)&&Array.isArray(n)?td(Array.isArray(e)?e:[],t,n,r):n}function ta(e,t,n,r){return t===Qt&&n===Qt?Qt:t===Qt?e===Qt?n:or(n,e)?Qt:n:n===Qt?e===Qt?t:Qt:ea(e,t,n,r)}function Ju(e,t,n,r){let o={},s=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let l of s){let i=ta(po(e,l)?e[l]:Qt,po(t,l)?t[l]:Qt,po(n,l)?n[l]:Qt,r);i!==Qt&&Xu(o,l,i)}return o}function Zu(e){return e===null||typeof e!="object"}function Jo(e){return typeof e+":"+String(e)}function Qu(e,t){for(let n of t){let r=new Set;for(let o of n){if(!po(o,e))return!1;let s=o[e];if(typeof s!="string"&&typeof s!="number")return!1;let l=Jo(s);if(r.has(l))return!1;r.add(l)}}return!0}function ed(e,t,n,r){let o=[e,t,n],s=!0;for(let l of o)for(let i of l)Pr(i)||(s=!1);if(s){for(let l of r.keyCandidates)if(Qu(l,o))return{kind:"keyed",field:l};return null}for(let l of o){let i=new Set;for(let a of l){if(!Zu(a))return null;let c=Jo(a);if(i.has(c))return null;i.add(c)}}return{kind:"self"}}function td(e,t,n,r){let o=ed(e,t,n,r);if(!o)return n;let s=o.kind==="self"?Jo:d=>Jo(d[o.field]),l=d=>{let p=new Map;for(let y of d)p.set(s(y),y);return p},i=l(e),a=l(t),c=l(n),h=new Map,u=new Set([...i.keys(),...a.keys(),...c.keys()]);for(let d of u){let p=ta(i.has(d)?i.get(d):Qt,a.has(d)?a.get(d):Qt,c.has(d)?c.get(d):Qt,r);p!==Qt&&h.set(d,p)}let f=[];for(let d of n){let p=s(d);h.has(p)&&f.push(p)}for(let d=0;d<t.length;d++){let p=s(t[d]);if(!h.has(p)||f.includes(p))continue;let y=0;for(let m=d-1;m>=0;m--){let g=f.indexOf(s(t[m]));if(g!==-1){y=g+1;break}}f.splice(y,0,p)}return f.map(d=>h.get(d))}function na(e,t,n,r={}){let o=r.keyCandidates?[...r.keyCandidates,...Ql]:Ql;return ea(e===void 0?Qt:e,t,n,{keyCandidates:o})}function mi(e,t,n,r={}){let o=r.parse||hi,s=[],l=(u,f)=>{if(typeof u!="string")return Qt;try{return o(u)}catch(d){return s.push(`${f} side is not valid JSON (${d.message})`),Qt}},i=l(t,"local"),a=l(n,"remote");if(i===Qt)return{text:n,warnings:s};if(a===Qt)return{text:t,warnings:s};let c=l(e,"base"),h=na(c===Qt?void 0:c,i,a,r);return or(h,a)?{text:n,warnings:s}:or(h,i)?{text:t,warnings:s}:{text:JSON.stringify(h,null,2),warnings:s}}var ra=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function yr(e){if(!e)return!1;let{startContainer:t,startOffset:n,endContainer:r,endOffset:o}=e;if(!t||!r||!Number.isInteger(n)||!Number.isInteger(o)||n<0||o<0||n>ra(t)||o>ra(r)||t.getRootNode()!==r.getRootNode())return!1;let s=t.ownerDocument.createRange();return s.setStart(t,n),s.setEnd(r,o),s.startContainer===t&&s.startOffset===n}function sr(e,t,n={}){if(!yr(e))return null;let{startContainer:r,startOffset:o,endContainer:s,endOffset:l}=e;if(r===s&&(r.nodeType===3||r.nodeType===8))return r.nodeValue.slice(o,l);if(r===s&&o===l)return"";let i=new Set;for(let m=r;m;m=m.parentNode)i.add(m);let a=s;for(;!i.has(a);)a=a.parentNode;let c=(m,g)=>{let k=a.ownerDocument.createRange(),S=a.ownerDocument.createRange();return k.setStart(m[0],m[1]),k.collapse(!0),S.setStart(g[0],g[1]),S.collapse(!0),k.compareBoundaryPoints(0,S)},h=(m,g=!1)=>[m.parentNode,Array.prototype.indexOf.call(m.parentNode.childNodes,m)+Number(g)],u=[],f;if(t==="plain"){f="";let m=g=>{if(g.nodeType===3||g.nodeType===8){let k=f.length;f+=g.nodeValue,u.push({s:k,e:f.length,a:[g,0],b:[g,g.nodeValue.length],node:g})}else for(let k of g.childNodes)m(k)};m(a)}else{let m=n.blocks;if(!m){m=new Set;let k=S=>{S!==a&&S.nodeType===1&&ci.has(S.tagName)&&m.add(S);for(let v of S.childNodes)k(v)};k(a)}let g=on(Array.from(a.childNodes),{blocks:m,atomize:k=>!!n.atoms?.has(k),ignored:n.ignored});f=g.text;for(let k of g.nodes)u.push({s:k.s,e:k.e,a:[k.node,0],b:[k.node,k.e-k.s],node:k.node});for(let k of g.atoms)u.push({s:k.i,e:k.i+1,a:h(k.el),b:h(k.el,!0)});for(let k=0;k<g.text.length;k++){if(g.text[k]!==Tt)continue;let S=g.marks.find(x=>x.block&&x.to===k+1),v=g.marks.find(x=>x.block&&x.from===k+1);if(S)u.push({s:k,e:k+1,a:[S.el,S.el.childNodes.length],b:h(S.el,!0)});else if(v)u.push({s:k,e:k+1,a:h(v.el),b:[v.el,0]});else return null}}u.sort((m,g)=>m.s-g.s);let d=m=>{if(m[0].nodeType===3||m[0].nodeType===8){let k=u.find(S=>S.node===m[0]);return k?k.s+m[1]:null}let g=0;for(let k of u){if(c(m,k.a)<=0)return k.s;if(c(m,k.b)<0)return null;g=k.e}return g},p=d([r,o]),y=d([s,l]);return p!==null&&y!==null&&p<=y?f.slice(p,y):null}function kr(e,t){let n=e;for(let r of t.path)if(n=r==="content"?n?.content:n?.childNodes[r],!n)return null;return[n,t.offset]}function oa(e,t){if(!e||!t)return null;let n=kr(e,t.start),r=kr(e,t.end);return n&&r?{startContainer:n[0],startOffset:n[1],endContainer:r[0],endOffset:r[1]}:null}var sa=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function ia(e,t,n){if(!t)return;let r=new Map,o=new Map,s=i=>{if(!i)return null;if(o.has(i))return o.get(i);let c=i.local.map(h=>kr(t.localRoot,{path:h,offset:0})?.[0]).map(h=>h&&n(h)).filter(Boolean).map(h=>({node:h,parent:h.parentNode,previous:h.previousSibling,next:h.nextSibling,fragment:sa(h)}));return o.set(i,c),c},l=i=>{let a=oa(t.localRoot,i);if(!a)return null;let c=n(a.startContainer),h=n(a.endContainer);if(!c||!h)return null;let u={...a,startContainer:c,endContainer:h};return yr(u)?u:null};for(let i of e){let a=i.recovery;if(!a||r.has(a))continue;let c={subject:s(a.subject),span:null,scope:null,touched:new Set};if(a.text){c.span=l(a.text.local.span),c.scope=l(a.text.local.scope);let h=c.span;if(h){let u=h.startContainer.ownerDocument.createRange();u.setStart(h.startContainer,h.startOffset),u.setEnd(h.endContainer,h.endOffset);let f=d=>{if(u.intersectsNode(d)){c.touched.add(d);for(let p of d.childNodes)f(p)}};f(u.commonAncestorContainer)}}if(a.structure){for(let h of[a.structure.localPlacement])h&&(s(h.parent),h.before.forEach(s),h.after.forEach(s));for(let h of a.structure.localOrder||[])s(h)}r.set(a,c)}t.localState={states:r,refs:o}}function la(e,t,n,r){let o=n.localState?.states.get(e);if(!o)return!1;let s=i=>{let a=i.node;if(!r(a)||a.parentNode!==i.parent)return!1;let c=h=>Array.prototype.indexOf.call(a.parentNode.childNodes,h);return!(i.previous&&r(i.previous)&&i.previous.parentNode===a.parentNode&&c(i.previous)>=c(a)||i.next&&r(i.next)&&i.next.parentNode===a.parentNode&&c(i.next)<=c(a))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!o.subject.length||!o.subject.every(s))return!1;if(e.text){let i=e.text.local,a=c=>c&&r(c.startContainer)&&r(c.endContainer);return a(o.span)&&a(o.scope)&&sr(o.scope,e.text.encoding)===i.text&&sr(o.span,e.text.encoding)===i.text.slice(i.start,i.end)}if(e.attribute){let i=e.attribute,a=o.subject[0].node;return(i.namespaceURI?a.getAttributeNS(i.namespaceURI,i.localName):a.getAttribute(i.qualifiedName))===t.local}let l=e.structure;if(l.localOrder){let i=-1,a=null;for(let c of l.localOrder){let h=n.localState.refs.get(c)?.[0]?.node;if(!h||!r(h)||a&&h.parentNode!==a)return!1;let u=Array.prototype.indexOf.call(h.parentNode.childNodes,h);if(u<=i)return!1;a=h.parentNode,i=u}return!0}return l.localAction==="moved"||o.subject.every(i=>sa(i.node)===i.fragment)}var nd=1,mn=e=>!!e&&e.nodeType===1,Zo=e=>mn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function xr(e,t=null,n=null){let r=new Map,o=new Map,s=h=>{if(!t){t=new WeakMap;let u=[e];for(;u.length;){let f=u.pop();Zo(f)&&(t.set(f.content,f),u.push(f.content));for(let d=f.firstChild;d;d=d.nextSibling)d.nodeType===1&&u.push(d)}}return t.get(h)||null},l=(h,u)=>{let f=o.get(h);if(!f){f=new Map;let d=0;for(let p=h.firstChild;p;p=p.nextSibling)f.set(p,d++);o.set(h,f)}return f.get(u)},i=h=>{if(!h)return null;if(n&&n.has(h))return i(n.get(h));if(h===e)return[];let u=r.get(h);if(u!==void 0)return u;let f=h.parentNode,d=null;if(f&&f.nodeType===11){let p=s(f),y=p?i(p):null;y&&(d=y.concat(["content",l(f,h)]))}else if(f){let p=i(f);p&&(d=p.concat([l(f,h)]))}return r.set(h,d),d};return{root:e,pathOf:i,logicalParent:h=>{let u=h.parentNode;return u&&u.nodeType===11?s(u):u},indexIn:l,containerPath:h=>{if(h.nodeType===11){let f=s(h),d=i(f);return d?d.concat(["content"]):null}let u=i(h);return u&&Zo(h)?u.concat(["content"]):u},ownerOf:s}}var jn=e=>Zo(e)?e.content:e;function aa(e){let{L:t,R:n,unitsOf:r,provenance:o,policy:s}=e,l=[];return{note:(h,u)=>{l.push([h,u])},finish:h=>l.length?c(h):null};function c(h){let u={base:xr(e.roots.base),local:xr(e.roots.local),remote:xr(e.roots.remote)},f=N=>N==="local"?t:n,d=(N,D)=>{if(!D)return null;if(N.map.has(D))return N.map.get(D);let Y=[],J=mn(D)?u.base.logicalParent(D):D.parent;for(;J&&!N.map.has(J);J=u.base.logicalParent(J))Y.push(J);if(!J||!N.identical.has(J))return null;let se=N.map.get(J);for(let Fe=Y.length-1;Fe>=0&&se;Fe--)se=jn(se).childNodes[u.base.indexIn(Y[Fe].parentNode,Y[Fe])];return se?mn(D)?jn(se).childNodes[u.base.indexIn(D.parentNode,D)]||null:r(se)[r(D.parent).indexOf(D)]||null:null},p=new Map,y=new Map,m=new WeakMap,g=0,k=(N,D)=>{let Y=p.get(N);Y||p.set(N,Y=[]),Y.push(D)};(function N(D){y.set(D,g++);let Y=o.get(D);if(Y&&!Y.pinned){for(let J of[Y.base,Y.local,Y.remote])if(J)if(Array.isArray(J))for(let se of J)k(se,D);else k(J,D)}if(Zo(D)){m.set(D.content,D);for(let J=D.content.firstChild;J;J=J.nextSibling)N(J)}for(let J=D.firstChild;J;J=J.nextSibling)N(J)})(h);let S=new Map;u.out=xr(h,m,S);let v={refs:new Map,spans:new Map,anchors:new Map,via:S,outOwners:m,outRoot:h,localRoot:e.roots.local},x=N=>mn(N)?[N]:N.nodes,O=(N,D)=>{let Y=u[D].logicalParent(N);if(!Y)return null;for(let J of r(Y))if(!mn(J)&&J.nodes.includes(N))return J;return null},C=(N,D)=>N==null?null:Array.isArray(N)?N.length?O(N[0],D):null:N,_=N=>{let D=new Set,Y=[];for(let J of N)for(let se of p.get(J)||[])D.has(se)||(D.add(se),Y.push(se));return Y.sort((J,se)=>y.get(J)-y.get(se))},M=new Map,j=N=>{let D=N.b||N.l||N.r,Y=M.get(D);if(Y)return Y;let J=[];for(let se of[N.b,N.l,N.r])se&&J.push(...x(se));return Y=_(J),M.set(D,Y),Y},I=N=>({b:N,l:d(t,N),r:d(n,N)}),P=(N,D)=>{let Y=f(D).reverse.get(N);if(Y)return I(Y);for(let J of _(x(N))){let se=o.get(J);if(se&&!se.base&&se.local&&se.remote)return{b:null,l:C(se.local,"local"),r:C(se.remote,"remote")}}return D==="local"?{b:null,l:N,r:null}:{b:null,l:null,r:N}},R=new Map,T=N=>{let D=o.get(N);if(!D||D.pinned)return null;let Y=C(D.base,"base");if(Y)return I(Y);let J=C(D.local,"local"),se=C(D.remote,"remote");if(J){let Fe=t.reverse.get(J);if(Fe)return I(Fe)}if(se){let Fe=n.reverse.get(se);if(Fe)return I(Fe)}return J||se?{b:null,l:J,r:se}:null},A=N=>(R.has(N)||R.set(N,T(N)),R.get(N)),W=(N,D)=>mn(N)?u[D].logicalParent(N):N.parent,F=new Map,$=new Map,Ne=(N,D)=>(mn(N)?[u[D].pathOf(N)]:N.nodes.map(Y=>u[D].pathOf(Y))).filter(Boolean),Ce=N=>{let D=N.b||N.l||N.r,Y=N.b?"base":N.l?"local":"remote",J=$.get(D);if(J)return J;let se=!mn(D),Fe=Ne(D,Y)[0],ee=`${Y[0]}:${JSON.stringify(Fe===void 0?null:Fe)}${se?":run":""}`,Me=F.get(ee);if(Me)return $.set(D,Me),Me;let Ve=j(N);return Me={key:ee,nodeType:mn(D)?1:D.kind==="comment"?8:3,base:N.b?Ne(N.b,"base"):[],local:N.l?Ne(N.l,"local"):[],remote:N.r?Ne(N.r,"remote"):[],merged:Ve.map(Ie=>u.out.pathOf(Ie)).filter(Boolean),live:[]},F.set(ee,Me),$.set(D,Me),v.refs.set(Me,Ve),Me},Be={base:new Map,local:new Map,remote:new Map},re=new Map,Ee=(N,D)=>{let Y=W(N,D);if(!Y||Y.nodeType!==1)return null;let J=Be[D].get(Y);if(!J){let Fe=r(Y),ee=Me=>Ce(D==="base"?I(Me):P(Me,D));J={parent:ee(Y),refs:Fe.map(ee),index:new Map(Fe.map((Me,Ve)=>[Me,Ve]))},Be[D].set(Y,J)}let se=J.index.get(N)??-1;return{parent:J.parent,before:J.refs.slice(se+1),after:J.refs.slice(0,Math.max(0,se)).reverse()}},Ge=N=>{let D=N.parentNode;if(!D)return null;let Y=re.get(D);if(!Y){let se=D.nodeType===11?m.get(D):D,Fe=se&&se.nodeType===1?A(se):null;if(!Fe)return null;let ee=[],Me=[],Ve=new Map;for(let ke of D.childNodes){let B=A(ke),G=B&&Ce(B),he=ee.length,be=ee.length-1;G&&G!==ee[be]&&(ee.push(G),be++);let fe={ref:G,group:be,after:he};Me.push(fe),Ve.set(ke,fe)}let Ie=ee.length;for(let ke=Me.length-1;ke>=0;ke--){let B=Me[ke];B.before=Ie,B.ref&&(Ie=B.group)}Y={parent:Ce(Fe),refs:ee,index:Ve},re.set(D,Y)}let J=Y.index.get(N);return{parent:Y.parent,before:Y.refs.slice(J.before),after:Y.refs.slice(0,J.after).reverse()}},_e=N=>mn(N)?N.outerHTML:N.value,w=N=>mn(N)?"element":N.kind==="comment"?"comment":"text",V=(N,D)=>({path:N,offset:D}),ne=(N,D,Y)=>{if(!N)return null;let J=u[Y],se=0;if(D){let Fe=mn(D)?D:D.nodes[D.nodes.length-1];Fe.parentNode&&(se=J.indexIn(Fe.parentNode,Fe)+1)}return V(J.containerPath(N),se)},te=(N,D)=>{let Y=W(N,"base"),J=Y?d(f(D),Y):null;if(!mn(J))return null;let se=r(Y),Fe=null;for(let ee=se.indexOf(N)-1;ee>=0&&!Fe;ee--){let Me=d(f(D),se[ee]);Me&&W(Me,D)===J&&(Fe=Me)}return ne(J,Fe,D)},Pe=(N,D,Y,J)=>{let se=u[J],Fe=0;for(let ee=0;ee<N.nodes.length;ee++){let Me=N.nodes[ee],Ve=Me.nodeValue.length,Ie=ee===N.nodes.length-1;if((Y==="start"?D<Fe+Ve:D<=Fe+Ve)||Ie)return V(se.pathOf(Me),Math.max(0,Math.min(D-Fe,Ve)));Fe+=Ve}return null},ze=(N,D)=>{let Y=u[D],J=N.firstChild,se=N.lastChild;return J&&J.nodeType===3&&se.nodeType===3?{start:V(Y.pathOf(J),0),end:V(Y.pathOf(se),se.nodeValue.length)}:{start:V(Y.pathOf(N),0),end:V(Y.pathOf(N),N.childNodes.length)}},Se=(N,D,Y)=>{for(let ee of N.nodes)if(Y==="start"?ee.s<=D&&D<ee.e:ee.s<D&&D<=ee.e)return{kind:"text",node:ee.node,offset:D-ee.s};let J=Y==="start"?D:D-1,se=()=>{for(let ee of N.nodes)if(ee.s===D||ee.e===D)return{kind:"text",node:ee.node,offset:D-ee.s};return null},Fe=N.atomAt.get(J);if(Fe)return{kind:Y==="start"?"before":"after",node:Fe.el};if(N.text[J]===Tt){let ee=N.marks.find(Ve=>Ve.block&&Ve.to===J+1);if(ee)return Y==="start"?{kind:"end",node:ee.el}:{kind:"after",node:ee.el};let Me=N.marks.find(Ve=>Ve.block&&Ve.from===J+1);if(Me)return Y==="start"?{kind:"before",node:Me.el}:{kind:"startOf",node:Me.el}}return se()},it=(N,D)=>Se(N,D,"end")||Se(N,D,"start"),tt=(N,D)=>{switch(D.kind){case"text":return V(N.pathOf(D.node),D.offset);case"end":return V(N.containerPath(D.node),jn(D.node).childNodes.length);case"startOf":return V(N.containerPath(D.node),0);default:{let Y=D.node.parentNode;return V(N.containerPath(Y),N.indexIn(Y,D.node)+(D.kind==="after"?1:0))}}},Q=(N,D,Y,J,se)=>{let Fe=Se(N,D,Y);return Fe?tt(u[J],Fe):se()},ce=(N,D,Y,J)=>{let se=N.textNodes.map(Ie=>({s:Ie.ms,e:Ie.me,start:{kind:"text",node:Ie.node,offset:0},end:{kind:"text",node:Ie.node,offset:Ie.me-Ie.ms}}));for(let[Ie,ke]of N.atomOut)se.push({s:Ie,e:Ie+1,start:{kind:"before",node:ke},end:{kind:"after",node:ke}});for(let[Ie,ke]of N.breakOut)se.push({s:Ie,e:Ie+1,start:{kind:"end",node:ke},end:{kind:"after",node:ke}});for(let Ie of se)if(Ie.start.kind==="text"&&Ie.s<D&&D<Ie.e)return{kind:"text",node:Ie.start.node,offset:D-Ie.s};if(Y!=="empty"){let Ie=se.find(ke=>Y==="start"?ke.s===D:ke.e===D);if(Ie)return Y==="start"?Ie.start:Ie.end}let Fe=se.find(Ie=>Ie.e===D);if(Fe)return Fe.end;let ee=se.find(Ie=>Ie.s===D);if(ee)return ee.start;let Me=null,Ve=null;for(let Ie of se)Ie.e<=D&&(!Me||Ie.e>Me.e)&&(Me=Ie),Ie.s>=D&&(!Ve||Ie.s<Ve.s)&&(Ve=Ie);return Me?Me.end:Ve?Ve.start:J()},Re=(N,D)=>{if(!D)return null;if(D.kind==="text"){let se=N.nodes.find(Fe=>Fe.node===D.node);return se?se.s+Math.min(D.offset,se.e-se.s):null}let Y=N.atoms.find(se=>se.el===D.node);if(Y)return D.kind==="after"?Y.i+1:Y.i;let J=N.marks.find(se=>se.el===D.node);return J?D.kind==="before"&&J.block&&N.text[J.from-1]===Tt&&!N.marks.some(se=>se.block&&se.to===J.from)?J.from-1:D.kind==="startOf"||D.kind==="before"?J.from:D.kind==="end"&&J.block?J.to-1:J.to:null},Ue=(N,D,Y,J)=>{for(let Me of N.nodes)if(Y==="start"?Me.s<=D&&D<Me.e:Me.s<D&&D<=Me.e)return{kind:"text",node:Me.node,offset:D-Me.s};let se=Y==="start"?D:D-1;if(!N.atomAt.has(se)&&N.text[se]!==Tt){for(let Me of N.nodes)if(Me.s===D||Me.e===D)return{kind:"text",node:Me.node,offset:D-Me.s}}let Fe=N.atomAt.get(se);if(Fe)return{kind:Y==="start"?"before":"after",node:Fe.el};if(N.text[se]===Tt){let Me=N.marks.find(Ie=>Ie.block&&Ie.to===se+1);if(Me)return Y==="start"?{kind:"end",node:Me.el}:{kind:"after",node:Me.el};let Ve=N.marks.find(Ie=>Ie.block&&Ie.from===se+1);if(Ve)return Y==="start"?{kind:"before",node:Ve.el}:{kind:"startOf",node:Ve.el}}let ee=N.marks.find(Me=>Me.block&&Me.from===D);return ee?{kind:"startOf",node:ee.el}:J?{kind:Y==="start"?"startOf":"end",node:J}:null},qe=N=>{if(!N)return null;if(N.kind==="wholeStart"||N.kind==="wholeEnd"){let D=ot(N.node);return N.kind==="wholeStart"?D.start:D.end}return tt(u.out,N)},ot=N=>{let D=N.firstChild,Y=N.lastChild;return D&&D.nodeType===3&&Y.nodeType===3?{start:V(u.out.pathOf(D),0),end:V(u.out.pathOf(Y),Y.nodeValue.length)}:{start:V(u.out.pathOf(N),0),end:V(u.out.pathOf(N),N.childNodes.length)}},xt=N=>{let D=W(N,"base"),Y=D?j(I(D))[0]:null;if(!Y)return null;let J=jn(Y),se=r(D);for(let Fe=se.indexOf(N)-1;Fe>=0;Fe--){let ee=j(I(se[Fe])).filter(Me=>Me.parentNode===J);if(ee.length)return{kind:"after",node:ee[ee.length-1]}}return{kind:"startOf",node:Y}},kt=(N,D,Y,J,se,Fe)=>({text:N,start:D,end:Y,fragment:J,span:se,scope:Fe}),Ct=(N,D,Y,J,se)=>kt(N,D,Y,N.slice(D,Y),J,se),dt=(N,D,Y,J,se)=>(v.spans.set(N,{start:D,end:Y,scopeStart:J,scopeEnd:se}),N),St=new Map,ht=new Map,H=(N,D,Y)=>{let J=`text:${N.key}:${D}:${Y}`,se=ht.get(J)||0;return ht.set(J,se+1),`${J}:${se}`},ie=(N,D)=>{let Y,J,se,Fe="plain",ee,Me,Ve,Ie,ke,B=(be,fe,we,oe,K)=>{if(!be){let ue=te(K,oe);return Ct("",0,0,{start:ue,end:ue},{start:ue,end:ue})}return Ct(be.value,fe,we,{start:Pe(be,fe,fe===we?"end":"start",oe),end:Pe(be,we,"end",oe)},{start:Pe(be,0,"start",oe),end:Pe(be,be.value.length,"end",oe)})};if(D.site==="run"){let{bRun:be,lRun:fe,rRun:we,node:oe,c:K}=D;Y=I(be),J=K.bs,se=K.be,ee=B(be,K.bs,K.be,"base",be),Me=B(fe,K.ls,K.le,"local",be),Ve=B(we,K.rs,K.re,"remote",be);let ue=oe?oe.nodeValue:"",Le=De=>oe?{kind:"text",node:oe,offset:De}:xt(be);Ie=dt(Ct(ue,K.ms,K.me,{start:qe(Le(K.ms)),end:qe(Le(K.me))},{start:qe(Le(0)),end:qe(Le(ue.length))}),Le(K.ms),Le(K.me),Le(0),Le(ue.length)),ke=oe||(xt(be)||{}).node||null}else if(D.site==="whole"){let be=D.el,fe=o.get(be);Y=I(fe.base),J=0,se=N.base.length;let we=(K,ue,Le)=>{let De=ze(ue,Le);return Ct(K,0,K.length,De,De)};ee=we(N.base,fe.base,"base"),Me=we(N.local,fe.local,"local"),Ve=we(N.remote,fe.remote,"remote");let oe=ot(be);Ie=dt(Ct(N.resolved,0,N.resolved.length,oe,oe),{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be},{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be}),ke=be}else if(D.site==="comment"){let{bRun:be,lRun:fe,rRun:we,node:oe}=D;Y=I(be),J=0,se=N.base.length;let K=(We,Oe)=>{if(!We){let E=te(be,Oe);return Ct("",0,0,{start:E,end:E},{start:E,end:E})}let Ze=We.nodes[0],st={start:V(u[Oe].pathOf(Ze),0),end:V(u[Oe].pathOf(Ze),We.value.length)};return Ct(We.value,0,We.value.length,st,st)};ee=K(be,"base"),Me=K(fe,"local"),Ve=K(we,"remote");let ue=N.resolved,Le=We=>oe?{kind:"text",node:oe,offset:We}:xt(be),De={start:qe(Le(0)),end:qe(Le(ue.length))};Ie=dt(Ct(ue,0,ue.length,De,De),Le(0),Le(ue.length),Le(0),Le(ue.length)),ke=oe||(xt(be)||{}).node||null}else{let{fb:be,fl:fe,fr:we,scope:oe}=D,K=D.merged;Fe="html",Y=oe.base?I(oe.base):P(oe.local,"local"),J=N.bs,se=N.be;let ue=He=>{let Xe=oe[He];for(let Qe=oe.at-1;Qe>=0;Qe--){let rt=oe.units[Qe],jt=He==="base"?rt:d(f(He),rt);if(jt&&W(jt,He)===Xe)return jt}return null},Le=He=>()=>ne(oe[He],ue(He),He),De=(He,Xe,Qe,rt,jt)=>{let Et=Jt=>Jt?tt(u[jt],Jt):Le(jt)(),en=Xe===Qe?it(He,Xe):Se(He,Xe,"start"),Pt=Xe===Qe?it(He,Xe):Se(He,Qe,"end"),vt=Et(en),At={start:vt,end:Xe===Qe?vt:Et(Pt)},wt=D.full?D.full(jt):null;if(!wt)return kt(He.text,Xe,Qe,rt,At,{start:Et(Se(He,0,"start")),end:Et(Se(He,He.text.length,"end"))});let Ft=en?Re(wt,en):null,mt=Pt?Re(wt,Pt):null,Wt=Ft===null?0:Ft,Mt=Math.max(Wt,mt===null?wt.text.length:mt),gn=Et(Se(wt,0,"start"));return kt(wt.text,Wt,Mt,Rr(wt,Wt,Mt),At,{start:gn,end:wt.text.length?Et(Se(wt,wt.text.length,"end")):gn})};ee=D.synthetic?null:De(be,N.bs,N.be,N.base,"base"),Me=De(fe,N.lss,N.lse,N.local,"local"),Ve=De(we,N.rss,N.rse,N.remote,"remote");let[We,Oe]=N.range||[0,0],Ze=K.out,st=()=>{let He=jn(K.node);for(let Xe=oe.at-1;Xe>=0;Xe--){let Qe=j(I(oe.units[Xe])).filter(rt=>rt.parentNode===He);if(Qe.length)return{kind:"after",node:Qe[Qe.length-1]}}for(let Xe=oe.at;Xe<oe.units.length;Xe++){let Qe=j(I(oe.units[Xe])).filter(rt=>rt.parentNode===He);if(Qe.length)return{kind:"before",node:Qe[0]}}return{kind:"startOf",node:K.node}};if(Ze.via)for(let[He,Xe]of Ze.via)S.set(He,Xe);let E=ce(K,We,We===Oe?"empty":"start",st),z=We===Oe?E:ce(K,Oe,"end",st),Z=Ze.text.length?Ue(Ze,0,"start",K.node):st(),ye=Ze.text.length?Ue(Ze,Ze.text.length,"end",K.node):Z,de=Re(Ze,E),le=Re(Ze,z),ae=de===null?0:de,$e=Math.max(ae,le===null?Ze.text.length:le);Ie=dt(kt(Ze.text,ae,$e,Rr(Ze,ae,$e),{start:qe(E),end:qe(z)},{start:qe(Z),end:qe(ye)}),E,z,Z,ye);let Je=v.spans.get(Ie);if(Je.flat=Ze,!Ze.text.length){let He=qe(Z),Xe=kr(h,He),Qe=Xe[0],rt=Xe[1];Je.empty={parent:Qe.nodeType===11?m.get(Qe):Qe,previous:Qe.childNodes[rt-1]||null,next:Qe.childNodes[rt]||null}}ke=E?E.node:K.node}let G=Ce(Y),he=(D.site==="whole"||D.site==="comment"||(D.policy||s)!=="both")&&N.resolved!==N.local;return{key:D.site==="comment"&&St.get(Y.b||Y.l||Y.r)||H(G,J,se),subject:G,localLost:he,anchor:ke,text:{encoding:Fe,base:ee,local:Me,remote:Ve,merged:Ie,liveSpan:null,liveScope:null}}},pe=(N,D)=>{let Y=A(D.el),J=Ce(Y),se=D.sample;return{key:`attr:${J.key}:${se.namespaceURI||""}:${se.localName}`,subject:J,localLost:N.resolved!==N.local,anchor:D.el,attribute:{namespaceURI:se.namespaceURI||null,localName:se.localName,qualifiedName:se.name}}},ge=(N,D)=>{let Y=N.detail,J=D.unit||I(D.subject),se=Ce(J),Fe=v.refs.get(se),ee=J.l?Ee(J.l,"local"):null,Me=J.r?Ee(J.r,"remote"):null,Ve=Fe.length?Ge(Fe[0]):null,Ie,ke,B,G=null,he=null,be=D.deleted;switch(Y){case"both-reordered":{Ie=ke="reordered";let fe=new Set(D.rKept),we=D.lKept.filter(De=>fe.has(De)&&j(I(De)).length),oe=De=>y.get(j(I(De))[0]);G=we.map(De=>Ce(I(De))),he=we.slice().sort((De,We)=>oe(De)-oe(We)).map(De=>Ce(I(De)));let K=De=>!mn(De)&&De.kind!=="comment"&&De.nodes.every(We=>!/[^\t\n\f\r ]/.test(We.data)),ue=we.filter(De=>!K(De)),Le=ue.slice().sort((De,We)=>oe(De)-oe(We));B=ue.some((De,We)=>De!==Le[We]);break}case"both-moved":Ie=ke="moved",B=!ee||!Fe.some(fe=>{let we=fe===Fe[0]?Ve:Ge(fe);return we&&we.parent===ee.parent});break;case"edit-beats-delete":Ie=be==="local"?"deleted":"edited",ke=be==="remote"?"deleted":"edited",B=be==="local";break;case"move-beats-delete":Ie=be==="local"?"deleted":"moved",ke=be==="remote"?"deleted":"moved",B=be==="local";break;case"remote-wins":Ie="edited",ke="edited",B=!0;break;default:Ie=ke="inserted",B=D.localLost}return{key:`structure:${se.key}:${Y}`,subject:se,localLost:B,anchor:Fe[0]||null,structure:{localAction:Ie,remoteAction:ke,localPlacement:ee,remotePlacement:Me,mergedPlacement:Ve,localOrder:G,mergedOrder:he,localFragment:Y==="both-reordered"||!J.l?null:_e(J.l),fragmentKind:w(J.b||J.l||J.r)}}};for(let[N,D]of l){if(N.kind!=="structure")continue;let Y=D.unit||I(D.subject),J=Y.b||Y.l||Y.r;!mn(J)&&J.kind==="comment"&&St.set(J,`structure:${Ce(Y).key}:${N.detail}`)}let Ae=new Map;for(let[N,D]of l){if(N.kind==="structure"){let Fe=Ce(D.unit||I(D.subject)),ee=`structure:${Fe.key}:${N.detail}`,Me=Ae.get(ee);if(Me&&Me.structure){N.recovery=Me;let Ve=v.refs.get(Fe);N.el==null&&Ve.length&&(N.el=mn(Ve[0])?Ve[0]:u.out.logicalParent(Ve[0]));continue}}let Y=N.kind==="text"?ie(N,D):N.kind==="attr"?pe(N,D):ge(N,D),J=Ae.get(Y.key);J||(J={version:nd,key:Y.key,localLost:Y.localLost,subject:Y.subject,applied:!1,unavailable:null},Ae.set(Y.key,J),v.anchors.set(J,Y.anchor)),Y.text&&(J.text=Y.text),Y.attribute&&(J.attribute=Y.attribute),Y.structure&&(J.structure=Y.structure),Y.text&&(J.localLost=Y.localLost),N.recovery=J;let se=v.refs.get(Y.subject);N.kind==="structure"&&N.el==null&&se.length&&(N.el=mn(se[0])?se[0]:u.out.logicalParent(se[0])),N.kind==="text"&&N.node==null&&se.length&&Y.subject.nodeType===8&&(N.node=se[0])}return v}}function ca(e,t,n){if(!t)return;let{lookup:r,vetoed:o,vetoedAttrs:s,liveAttr:l}=n,i=n.ignored||(()=>!1),a=xr(n.liveRoot),c=T=>!!T&&a.containerPath(T)!==null,h=T=>{let A=T.parentNode;return A&&A.nodeType===11?t.outOwners.get(A)||null:A},u=T=>{for(let A=T;A;A=h(A))if(t.via.has(A)&&(A=t.via.get(A)),o.has(A)||n.vetoedLive?.has(g(A)))return!0;return!1},f=T=>Array.from(jn(T).children).filter(A=>!i(A)),d=(T,A)=>f(T)[f(A.parentNode).indexOf(A)],p=(T,A)=>{let W=null,F=null,$=0;for(let re=A.previousSibling;re;re=re.previousSibling){if(re.nodeType===1&&!i(re)){W=re;break}re.nodeType===3&&($+=re.nodeValue.length)}for(let re=A.nextSibling;re&&!F;re=re.nextSibling)re.nodeType===1&&!i(re)&&(F=re);let Ne=W?d(T,W):null,Ce=F?d(T,F):null;if(W&&!Ne||F&&!Ce)return null;let Be=[];for(let re=Ne?Ne.nextSibling:jn(T).firstChild;re&&re!==Ce;re=re.nextSibling)re.nodeType===3&&Be.push(re);return Be.length?{nodes:Be,lead:$}:null},y=T=>{let A=[],W=T;for(;W&&!t.via.has(W);W=W.parentNode)A.push(W);if(!W||!A.length)return null;let F=g(t.via.get(W));for(let Ce=A.length-1;Ce>0&&F;Ce--)F=d(F,A[Ce]);if(!F)return null;let $=A[0];if($.nodeType===3)return p(F,$);let Ne=$.nodeType===1?d(F,$):null;return Ne?{nodes:[Ne],lead:0}:null},m=T=>{let A=r(T),W=A?{nodes:Array.isArray(A)?A:[A],lead:0}:t.via.size?y(T):null;if(!W)return null;let F=W.nodes.filter(c);return F.length?{nodes:F,lead:W.lead}:null},g=T=>{let A=m(T);return A?A.nodes[0]:null},k=T=>{if(!T)return null;if(T.kind==="text"){let $=m(T.node);if(!$)return null;let Ne=$.nodes,Ce=T.offset+$.lead,Be=0;for(let re=0;re<Ne.length;re++){let Ee=Ne[re].nodeValue.length;if(Ce<=Be+Ee||re===Ne.length-1)return Ce>=Be&&Ce<=Be+Ee?[Ne[re],Ce-Be]:null;Be+=Ee}return null}let A=g(T.node);if(!A)return null;if(T.kind==="end")return[jn(A),jn(A).childNodes.length];if(T.kind==="startOf")return[jn(A),0];if(T.kind==="wholeStart")return A.firstChild?[A.firstChild,0]:[A,0];if(T.kind==="wholeEnd")return A.lastChild?[A.lastChild,A.lastChild.nodeValue.length]:[A,A.childNodes.length];let W=A.parentNode;if(!W)return null;let F=Array.prototype.indexOf.call(W.childNodes,A);return[W,T.kind==="after"?F+1:F]},S=T=>({blocks:new Set((T.flat?.marks||[]).filter(A=>A.block).map(A=>g(A.el)).filter(Boolean)),atoms:new Set((T.flat?.atoms||[]).map(A=>g(A.el)).filter(Boolean)),ignored:i}),v=(T,A,W,F)=>{if(!T||!A||!yr(T)||!yr(A))return!1;for(let Ce of[T,A])if(!c(Ce.startContainer)||!c(Ce.endContainer))return!1;let $=W.merged;if($.start===$.end&&(T.startContainer!==T.endContainer||T.startOffset!==T.endOffset))return!1;let Ne=S(F);return sr(A,W.encoding,Ne)===$.text&&sr(T,W.encoding,Ne)===$.text.slice($.start,$.end)},x=new Map,O=T=>{let A=T.parentNode;return A?(x.has(A)||x.set(A,new Map(Array.from(A.childNodes,(W,F)=>[W,F]))),x.get(A).get(T)):-1},C=(T,A)=>{if(!A)return!1;let W=a.logicalParent(T);if(!A.parent.live.includes(W))return!1;let F=O(T);for(let[$,Ne]of[["before",1],["after",-1]]){let Ce=F;for(let Be of A[$]){if(Be.live.includes(T))continue;let re=Be.live.filter(Ge=>Ge!==T&&Ge.parentNode===T.parentNode);if(!re.length)continue;let Ee=Ne===1?Math.min(...re.map(O)):Math.max(...re.map(O));if(Ne*(Ee-Ce)<=0)return!1;Ce=Ee}}return!0},_=T=>{let A=T.structure;if(A.mergedOrder){let W=new Set(T.subject.live.map(jn)),F=null,$=-1;for(let Ne of A.mergedOrder){let Ce=Ne.live.find(Be=>W.has(Be.parentNode));if(!Ce||F&&Ce.parentNode!==F||O(Ce)<=$)return!1;F=Ce.parentNode,$=O(Ce)}return T.subject.live.length>0}return T.subject.live.some(W=>C(W,A.mergedPlacement))},M=(T,A)=>{let W=k(T),F=k(A);return W&&F?{startContainer:W[0],startOffset:W[1],endContainer:F[0],endOffset:F[1]}:null},j=new Set,I=T=>{if(!T||j.has(T))return;j.add(T);let A=[];for(let W of t.refs.get(T)||[]){let F=m(W);if(F)for(let $ of F.nodes)A.includes($)||A.push($)}T.live=A},P=T=>{T&&(I(T.parent),T.before.forEach(I),T.after.forEach(I))},R=new Set;for(let T of e){let A=T.recovery;if(!A||R.has(A))continue;R.add(A),I(A.subject),A.structure&&(P(A.structure.localPlacement),P(A.structure.remotePlacement),P(A.structure.mergedPlacement),(A.structure.localOrder||[]).forEach(I),(A.structure.mergedOrder||[]).forEach(I));let W=t.anchors.get(A),F=W?g(W):null,$=!!F;if(A.text){let w=t.spans.get(A.text.merged),V=w?M(w.start,w.end):null,ne=w?M(w.scopeStart,w.scopeEnd):null;if(w?.empty){let te=w.empty,Pe=te.previous?{kind:"after",node:te.previous}:{kind:"startOf",node:te.parent},ze=te.next?{kind:"before",node:te.next}:{kind:"end",node:te.parent},Se=M(Pe,ze);!Se||Se.startContainer!==Se.endContainer||Se.startOffset!==Se.endOffset?V=null:V=ne=Se}v(V,ne,A.text,w)||(V=ne=null),A.text.liveSpan=V,A.text.liveScope=V?ne:null,V||($=!1)}A.structure&&$&&($=_(A)),A.attribute&&$&&($=l(F,A.attribute,T.resolved));let Ne=(!!A.attribute||!!A.text&&F?.tagName==="TEXTAREA")&&!!s&&[W,F].some(w=>s.get(w)?.has(A.attribute?A.attribute.qualifiedName:"value")),Ce=t.localState?.states.get(A),Be=!!A.text&&[...n.removedVetoes||[]].some(w=>Ce?.touched.has(w)),re=A.structure?.localAction==="inserted"&&[...o].some(w=>w===W||W?.contains(w)),Ee=W&&u(W)||Ne||Be||re,Ge=Ee&&la(A,T,t,c);Ge&&(Be||re&&A.localLost)&&($=!1);let _e=!$&&Ge&&Ee;A.applied=$,A.unavailable=$?null:_e?"hook-veto":"missing-output",_e&&(A.localLost=!1),!$&&A.text&&(A.text.liveSpan=A.text.liveScope=null)}}function Qo(e,t,n){let r=xr(t),o=xr(n),s=u=>!!u&&o.containerPath(u)!==null,l=u=>{if(u===t)return n;let f=r.pathOf(u);if(f&&t!==n){let d=kr(n,{path:f,offset:0});if(d&&d[0].nodeType===u.nodeType)return d[0]}return u},i=new Set,a=u=>{!u||i.has(u)||(i.add(u),u.live=u.live.map(l).filter(s))},c=u=>{u&&(u.startContainer=l(u.startContainer),u.endContainer=l(u.endContainer))},h=new Set;for(let u of e){u.node===t&&n.tagName==="SCRIPT"&&(u.node=n),u.el===t&&u.kind==="structure"&&(u.el=n);let f=u.recovery;if(!f||h.has(f))continue;if(h.add(f),a(f.subject),f.text){c(f.text.liveSpan),c(f.text.liveScope);let p=f.text.liveSpan,y=f.text.liveScope,m=f.text.merged,g=k=>!!k&&yr(k)&&s(k.startContainer)&&s(k.endContainer);(!g(p)||!g(y)||sr(y,f.text.encoding)!==m.text||sr(p,f.text.encoding)!==m.text.slice(m.start,m.end))&&(f.text.liveSpan=null,f.text.liveScope=null,f.applied=!1,f.unavailable="missing-output")}let d=f.structure;if(d){for(let p of[d.localPlacement,d.remotePlacement,d.mergedPlacement])p&&(a(p.parent),p.before.forEach(a),p.after.forEach(a));(d.localOrder||[]).forEach(a),(d.mergedOrder||[]).forEach(a),f.subject.live.length||(f.applied=!1,f.unavailable="missing-output")}}}var Dr=e=>e?.nodeType===1,go=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function rd({provenance:e,parentOf:t,twins:n,baseOf:r,build:o,ignored:s,remoteWins:l,discarded:i}){let a=new Map,c=new WeakMap;function h(d,p,y,m=!1){if(!Dr(d)||!Dr(y))return null;let g=a.get(d);if(g)(m||!g.selected&&p==="remote")&&(g.parent=t(y),g.port=y,g.sourceSide=p,g.selected=m);else{let k=c.get(d)||null;g={owner:d,parent:t(y),port:y,sourceSide:p,originalParent:t(d),originalPort:d,selected:m,state:k?"built":"planned",output:k,disposition:null},a.set(d,g)}return g}function u(d,p){if(!Dr(d)||!Dr(p))return;c.has(d)||c.set(d,p);let y=a.get(d);y&&y.state!=="attached"&&!y.output&&(y.output=p,y.state="built")}function f(d){if(!a.size)return;let p=new Map,y=new WeakMap,m=new WeakMap,g=new WeakSet,k=new Set,S=(P,R)=>{if(!P)return;if(Array.isArray(P)){for(let A of P)S(A,R);return}let T=p.get(P);T||p.set(P,T=[]),T.push(R)},v=(P,R)=>{if(!P)return;let T=[P];for(;T.length;){let A=T.pop();S(A,R);for(let W of go(A).childNodes)T.push(W)}};function x(P,R=null,T=!1){if(g.has(P))return;g.add(P),y.set(P,R);let A=e.get(P),W=T||!!(A&&l(A.remote||A.base));m.set(P,W);let F={node:P,kind:"node",authority:W};if(A?.pinned)v(A.local,{...F,kind:"ignored"});else if(A?.unchanged)for(let $ of[A.base,A.local,A.remote])v($,{...F,kind:"unchanged"});else if(A){for(let $ of[A.base,A.local,A.remote])S($,F);if(Dr(A.local))for(let $ of go(A.local).children)s($)&&v($,{...F,kind:"ignored"})}for(let $ of go(P).childNodes)x($,P,W)}let O=P=>{if(P.output&&g.has(P.output))return P.state="attached",P.disposition="node",!0;let{local:R,remote:T}=n(P.owner);for(let A of[P.owner,R,T]){let W=p.get(A);if(W?.length){let F=W.find($=>$.kind==="node")||W[0];return P.output=F.node,P.state="attached",P.disposition=F.kind,!0}}return!1},C=(P,R)=>(p.get(P)||[]).find(A=>A.kind==="node"&&Dr(A.node)&&(!A.authority||R.sourceSide==="remote"))?.node,_=(P,R,T)=>{let A=p.get(P)||[],W=T?[...A].reverse():A;for(let F of W){if(F.kind!=="node")continue;let $=F.node;for(;$&&y.get($)!==R;)$=y.get($);if($)return $}return null},M=(P,R,T)=>{let A=go(R);for(let W=T?.previousSibling;W;W=W.previousSibling){let F=_(W,R,!0);if(F){A.insertBefore(P,F.nextSibling);return}}for(let W=T?.nextSibling;W;W=W.nextSibling){let F=_(W,R,!1);if(F){A.insertBefore(P,F);return}}A.appendChild(P)};function j(P,R,T){let A=R==="base"?P:r(P,R),W=a.get(A);W&&W!==T&&I(W)}function I(P){if(P.state==="attached"||P.disposition==="remote-wins"||k.has(P)||O(P))return;k.add(P);let{local:R,remote:T}=n(P.owner);if(l(T||P.owner)){if(!T){P.disposition="remote-wins",i(P.owner,R),k.delete(P);return}P.parent=t(T),P.port=T,P.sourceSide="remote"}if(j(P.parent,P.sourceSide,P),O(P)){k.delete(P);return}let A=C(P.parent,P),W=P.port;if(!A){if(j(P.originalParent,"base",P),O(P)){k.delete(P);return}let $=P.originalParent;for(W=P.originalPort;$&&!A;)A=C($,P),A||(W=$,$=t($))}if(!A)throw new Error("A planned move has no allowed surviving parent");let F=P.output||o(P.owner);P.output=F,P.state="built",M(F,A,W),x(F,A,m.get(A)||!1),O(P),k.delete(P)}x(d);for(let P of a.values())I(P)}return{planned:a,has:d=>a.has(d),plan:h,produced:u,drain:f}}function Fr(e,t,n,r,o,s,l,i,a,c,h,u,f){let d=null;return rd({provenance:e,parentOf:m=>{if(!m)return null;let g=t(m);if(g||m.parentNode?.nodeType!==11)return g;if(!d){d=new WeakMap;let k=[u,f];for(;k.length;){let S=k.pop(),v=go(S);v!==S&&d.set(v,S);for(let x of v.children)k.push(x)}}return d.get(m.parentNode)||null},twins:m=>({local:o(n,m),remote:o(r,m)}),baseOf:(m,g)=>m&&(g==="local"?n:r).reverse.get(m)||null,build:m=>s(m,o(n,m),o(r,m),!1),ignored:l,remoteWins:i,discarded:(m,g)=>{g&&h(m,g,n)&&!a.some(k=>k.detail==="remote-wins"&&k.base===m)&&c({kind:"structure",el:null,detail:"remote-wins",base:m,local:g,remote:null},{subject:m})}})}function od({parent:e,base:t,views:n,eligible:r,ignored:o,remoteWins:s,budget:l=Xt(2e4*32),maxUnits:i=256,maxCharacters:a=2e4}){let c=(g,k=null)=>({status:g,reason:k,parent:e,records:[]});if(n.some(({V:g})=>g.asBase)||o(e)||s(e)||n.some(({V:g})=>!g.el||o(g.el)||s(g.el)))return c("none");let h=t.length+n[0].V.units.length+n[1].V.units.length;if(h>i)return c("fallback","unit-limit");let u=Symbol(),f=g=>{if(g>l.remaining)throw u;l.remaining-=g,l.crossParentSteps=(l.crossParentSteps||0)+g},d=new Map,p=0,y=g=>{if(f(1),d.has(g))return d.get(g);let k=g.nodeType===1?g.childNodes:g.nodes;f(k.length*4+1);let S=g.nodeType===1?Array.from(k):k,v=0;for(let C=0;C<S.length;C++){let _=S[C];if(_.nodeType!==3||C&&S[C-1].nextSibling!==_)return d.set(g,null),null;v+=_.data.length}if(v>a-p)throw u;f(v*8+1),p+=v;let x=on(S);if(x.text.includes(Tt))return d.set(g,null),null;let O={unit:g,nodes:S,flat:x};return d.set(g,O),O},m=[];try{f(h*8+1);for(let g=0;g<2;g++){let k=n[g].V,S=n[1-g].V,v=[],x=new Map;for(let O=0;O<t.length;O++){f(1);let C=t[O];if(C.kind!=="text"||k.twin(C))continue;let _=S.twin(C);if(!_||_.kind!=="text"||!S.here(_))continue;let M=y(C),j=y(_);if(!M||!j||!/\S/.test(M.flat.text))continue;f(M.flat.text.length*2+1);let I=M.flat.text;x.set(I,(x.get(I)||0)+1),v.push({source:C,opposite:_,sourceModel:M,oppositeModel:j,index:O})}for(let O of v){let{source:C,opposite:_,sourceModel:M,oppositeModel:j,index:I}=O,P=[];for(let V of[-1,1]){f(1);let ne=t[I+V];if(!ne||ne.nodeType!==1||!r(ne)||o(ne)||s(ne))continue;let te=M.nodes[0],Pe=M.nodes.at(-1);if(V===-1?te?.previousSibling!==ne:Pe?.nextSibling!==ne)continue;let ze=k.twin(ne),Se=S.twin(ne);if(!ze||!Se||!k.here(ze)||S.here(Se)||k.baseOf(ze)!==ne||S.baseOf(Se)!==ne||!r(ze)||!r(Se)||o(ze)||o(Se)||s(ze)||s(Se)||ze.tagName!==ne.tagName||Se.tagName!==ne.tagName||ze.namespaceURI!==ne.namespaceURI||Se.namespaceURI!==ne.namespaceURI)continue;let it=y(ne),tt=y(ze),Q=y(Se);if(!it||!tt||!Q||!/\S/.test(it.flat.text))continue;let ce=it.flat.text,Re=M.flat.text,Ue=tt.flat.text;if(f((ce.length+Re.length+Ue.length)*3+1),Ue.length!==ce.length+Re.length)continue;let qe=V===-1;(qe?!Ue.startsWith(ce)||!Ue.endsWith(Re):!Ue.startsWith(Re)||!Ue.endsWith(ce))||P.push({owner:ne,target:ze,moved:Se,ownerBase:it,joined:tt,ownerOther:Q,targetFrom:qe?ce.length:0,retainedFrom:qe?0:Re.length})}if(!P.length)continue;if(P.length!==1||x.get(M.flat.text)!==1)return c("fallback","ambiguous-origin");let R=P[0],{owner:T,target:A,moved:W,ownerBase:F,joined:$,ownerOther:Ne,targetFrom:Ce,retainedFrom:Be}=R;if(f(m.length+1),m.some(V=>V.owner===T))return c("fallback","ambiguous-owner");let re={source:C,target:A,from:0,to:M.flat.text.length,targetFrom:Ce},Ee=Hn({base:M.flat,side:$.flat,retained:[],transfers:[{from:re.from,to:re.to,target:Ce,destination:T}],budget:l});if(Ee.status!=="ready"||Ee.covers(re.from,re.to)!==!0)return c("fallback",Ee.reason||"work-limit");let Ge=[{unit:C,model:M,from:0,to:M.flat.text.length},null,null];Ge[g+1]={unit:A,model:$,from:Ce,to:Ce+M.flat.text.length},Ge[2-g]={unit:_,model:j,from:0,to:j.flat.text.length};let _e=[F,null,null];_e[g+1]=$,_e[2-g]=Ne;let w=[T,null,null];w[g+1]=A,w[2-g]=W,m.push({side:g,parent:e,source:C,target:A,owner:T,owners:w,ownerModels:_e,native:Ge,models:d,runs:[re],proof:Ee,retained:[{source:T,target:A,from:0,to:F.flat.text.length,targetFrom:Be}]})}}return m.length?{status:"ready",reason:null,parent:e,records:m}:c("none")}catch(g){if(g!==u)throw g;return c("fallback","work-limit")}}function fa({describe:e,parentOf:t,...n}){let r=new WeakMap,o=new WeakMap,s=n.budget||Xt(2e4*32),l=i=>{if(!i)return null;if(r.has(i))return r.get(i);r.set(i,{status:"planning",parent:i,records:[]});let a=e(i),c=a?od({...n,...a,parent:i,budget:s}):{status:"none",reason:null,parent:i,records:[]};if(r.set(i,c),c.status==="ready")for(let h of c.records)o.set(h.owner,[h]);return c};return{get:l,forOwner(i){return l(t(i))?.status==="ready"&&o.get(i)||null}}}function sd(e,t){if(e.side!==0)return null;let n=e.native[0].model,r=e.ownerModels[0],o=e.native[1].from!==0,s=(S,v)=>o?[...S.nodes,...v.nodes]:[...v.nodes,...S.nodes],l=e.ownerModels.reduce((S,v)=>S+v.flat.text.length,0)+n.flat.text.length+e.native[2].model.flat.text.length;if(l*8>t.remaining)return null;t.remaining-=l*8;let i={base:s(r,n),local:e.ownerModels[1].nodes,remote:s(e.ownerModels[2],e.native[2].model)},a=on(i.base),c=e.ownerModels[1].flat,h=on(i.remote),u=o?r.flat.text.length:0,f=o?0:n.flat.text.length,d=Hn({base:a,side:c,retained:e.retained.map(S=>({from:f+S.from,to:f+S.to,target:S.targetFrom})),transfers:e.runs.map(S=>({from:u+S.from,to:u+S.to,target:S.targetFrom,destination:e.owner})),budget:t});if(d.status!=="ready"||d.covers(0,a.text.length)!==!0)return null;let p=e.ownerModels[2].flat,y=e.native[2].model.flat,m=[];for(let[S,v,x,O]of[[r.flat,p,f,o?0:y.text.length],[n.flat,y,u,o?p.text.length:0]]){let C=fi(S,S,v).remoteMap.bTo,_=-1;for(let M=0;M<S.text.length;M++){if(C[M]<0){_=-1;continue}let j=m.at(-1);_>=0&&j.to===x+M&&j.target+j.to-j.from===O+C[M]?j.to++:(m.push({from:x+M,to:x+M+1,target:O+C[M]}),_=M)}}let g=Hn({base:a,side:h,retained:m,transfers:[],budget:t});if(g.status!=="ready")return null;let k=fi(a,c,h,{},{local:d,remote:g});return k.localEdits.hunks.length?null:(k.localMap=d,k.remoteMap=g,{nodes:i,prepared:k})}function ua({L:e,R:t,twinIn:n,unitsOf:r,view:o,parentOf:s,ignored:l,remoteWins:i,eligible:a,build:c,out:h,policy:u,provenance:f,textMappers:d,segments:p,conflicts:y,conflict:m,decisions:g}){let k=Xt(2e4*32),S=P=>{let R=0;for(let T=P;T;T=s(T))if(++R>64||T.nodeType===1&&(l(T)||i(T)))return!1;return!0},v=fa({parentOf:s,eligible:a,ignored:l,remoteWins:i,budget:k,describe(P){let R=n(e,P),T=n(t,P);return!R||!T||!S(P)||!S(R)||!S(T)?null:{base:r(P),views:[{A:e,V:o(e,R,P,!1)},{A:t,V:o(t,T,P,!1)}]}}}),x=new WeakSet,O=new WeakMap,C=new WeakSet,_=[];function M(P){if(!P||x.has(P))return;x.add(P);let R=v.get(P);if(R?.status==="ready")for(let T of R.records){if((P.tagName==="TEMPLATE"&&P.content?P.content:P).childNodes.length!==T.native[0].model.nodes.length+1||!T.owners.every(S))continue;let W=sd(T,k);if(!W)continue;let F={record:T,payload:W,state:"planned",output:null,result:null};O.set(T.owner,F),C.add(T.source),C.add(T.native[2].unit),_.push(F)}}function j(P,R){let T=O.get(P);if(!T)return!1;if(!T.result){if(T.result=br({...T.payload.nodes,prepared:T.payload.prepared,out:h,policy:u,provenance:f,textMappers:d,conflicts:y,conflict:m,decisions:g,node:R}),T.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");p.push(...T.result.segments),T.decision={kind:"text",node:R,source:"local"},g.push(T.decision)}return T.decision.node=R,R.replaceChildren(...T.result.nodes),T.output=R,T.state="built",!0}function I(P){if(!_.length)return;let R=new WeakSet,T=new WeakMap,A=new WeakMap,W=new WeakMap,F=Ee=>Ee.tagName==="TEMPLATE"&&Ee.content?Ee.content:Ee,$=(Ee,Ge)=>{if(!Ee)return;if(Array.isArray(Ee)){for(let w of Ee)$(w,Ge);return}let _e=W.get(Ee);_e||W.set(Ee,_e=[]),_e.push(Ge)},Ne=(Ee,Ge=null,_e=!1)=>{R.add(Ee),T.set(Ee,Ge);let w=f.get(Ee),V=_e||!!(w&&i(w.remote||w.base));if(A.set(Ee,V),w)for(let ne of[w.base,w.local,w.remote])$(ne,Ee);if(!(w?.pinned||w?.unchanged))for(let ne of F(Ee).childNodes)Ne(ne,Ee,V)},Ce=Ee=>(W.get(Ee)||[]).find(Ge=>Ge.nodeType===1&&!A.get(Ge)&&!f.get(Ge)?.pinned&&!f.get(Ge)?.unchanged),Be=(Ee,Ge)=>{for(let _e of W.get(Ee)||[]){let w=_e;for(;w&&T.get(w)!==Ge;)w=T.get(w);if(w)return w}return null},re=(Ee,Ge,_e)=>{let w=F(Ge);for(let V=_e.nextSibling;V;V=V.nextSibling){let ne=Be(V,Ge);if(ne){w.insertBefore(Ee,ne);return}}for(let V=_e.previousSibling;V;V=V.previousSibling){let ne=Be(V,Ge);if(ne){w.insertBefore(Ee,ne.nextSibling);return}}w.appendChild(Ee)};Ne(P);for(let Ee of _){let{record:Ge}=Ee,_e=Ce(Ge.owner)||Ce(Ge.owners[1])||Ce(Ge.owners[2]);if(_e)(!Ee.result||Ee.output!==_e||Ee.result.nodes.some(w=>!R.has(w)||T.get(w)!==_e)||_e.textContent!==Ee.result.text)&&(j(Ge.owner,_e),Ne(_e,T.get(_e),A.get(_e)));else{let w=Ge.parent,V=Ge.owner,ne=null;for(;w&&!ne;)ne=Ce(w),ne||(V=w,w=s(w));if(!ne)throw new Error("A cross-parent payload has no allowed surviving parent");_e=Ee.output||c(Ge.owner,Ge.owners[1],Ge.owners[2],!1),Ee.result||j(Ge.owner,_e),re(_e,ne,V),Ne(_e,ne,A.get(ne))}Ee.state="attached"}}return{ensureParent:M,ensureOwner(P){M(s(P))},consumes(P){return C.has(P)},render:j,drain:I}}var Mn=/\S/,da=/[\p{L}\p{N}]/u;function vr(e,t,n,r){if(e?.nodeType!==1||!t(e))return!1;for(let o=e.firstChild;o;o=o.nextSibling)if(r(n,1),o.nodeType!==3)return!1;return!!e.firstChild}function pi(e,t,n){for(let r=e.parentNode;r;r=r.parentNode)if(n(t,1),r.nodeType===11)return!1;return!0}function ha(e,t,n,r,o){let s=n(e,r),l=n(t,r),i=null,a=null,c=null,h=null;o(r,s.length+l.length);for(let u of s)da.test(u.raw)&&(i||=u,a=u);for(let u of l)da.test(u.raw)&&(c||=u,h=u);return!!(i&&c&&(i.raw===c.raw||a.raw===h.raw))}function id({base:e,V:t,A:n,source:r,original:o,current:s,edited:l,destination:i,at:a,ownLength:c,eligible:h,model:u,tokensOf:f,budget:d,charge:p}){let y=o.flat.text,m=s.flat.text,g=l.flat.text,k=i.flat.text;if(p(d,y.length+m.length+k.length),y.startsWith(m)||y.endsWith(m))return!1;let S=Mn.test(k.slice(0,a)),v=Mn.test(k.slice(a+c));if(S===v)return!1;let x=S?0:a+c,O=S?a:k.length;for(;x<O&&!Mn.test(k[x]);)x++;for(;O>x&&!Mn.test(k[O-1]);)O--;let C=k.slice(x,O);if(Ln(C,k,f(i,d),d,p,!0)!==x)return!1;let _=Ln(C,y,f(o,d),d,p,!0);if(_<0)return!1;let M=_+C.length,j=!Mn.test(y.slice(0,_)),I=!Mn.test(y.slice(M));if(j===I||Ln(C,m,f(s,d),d,p,!1)>=0)return!1;let P=j?y.slice(M):y.slice(0,_),R=j?g.length-P.length:0;if(p(d,y.length+g.length),R<0||!Mn.test(P)||Ln(P,g,f(l,d),d,p,!0)!==R||!Mn.test(j?g.slice(0,R):g.slice(P.length)))return!1;for(let T of e){if(p(d,1),T===r||!vr(T,h,d,p))continue;let A=u(T,null,d);if(Ln(C,A.flat.text,f(A,d),d,p,!1)>=0)return!1}for(let T of t.units){if(p(d,1),T===s.unit||T===i.unit||!vr(T,h,d,p))continue;let A=u(T,n,d);if(Ln(C,A.flat.text,f(A,d),d,p,!1)>=0)return!1}return!0}function ma({base:e,views:t,side:n,attempt:r,eligible:o,blocked:s,baseId:l,model:i,tokensOf:a,charge:c,exhausted:h,limit:u}){if(u<=0)return null;let f=Xt(u),{V:d,A:p,idOf:y}=t[n],m=t[1-n],[g,k,S,v]=r,x=null;try{for(let O=g;O<=k;O++){c(f,1);let C=e[O];if(C.parentNode?.nodeType!==1||s.has(C)||p.identical.has(C)||m.A.identical.has(C)||!vr(C,o,f,c)||l(C))continue;let _=d.twin(C),M=m.V.twin(C);if(!_||!M||!d.here(_)||!m.V.here(M)||p.map.get(C)!==_||p.reverse.get(_)!==C||m.A.map.get(C)!==M||m.A.reverse.get(M)!==C||y(_)||m.idOf(M)||_.tagName!==C.tagName||M.tagName!==C.tagName||!vr(_,o,f,c)||!vr(M,o,f,c)||!pi(C,f,c)||!pi(_,f,c)||!pi(M,f,c))continue;let j=i(C,null,f),I=i(_,p,f),P=i(M,m.A,f),R=j.flat.text,T=I.flat.text,A=P.flat.text;if(c(f,R.length+T.length+A.length),!Mn.test(R)||!Mn.test(T)||!Mn.test(A)||R===T||R===A||T===A||!ha(j,I,a,f,c)||!ha(j,P,a,f,c))continue;let W=null,F=!1;for(let Ce=S;Ce<=v;Ce++){c(f,1);let Be=d.units[Ce],re=d.baseOf(Be);if(!re||re===C||s.has(re)||re.parentNode!==C.parentNode||Be.parentNode!==_.parentNode||re.tagName!==C.tagName||Be.tagName!==C.tagName||p.map.get(re)!==Be||p.reverse.get(Be)!==re||l(re)!==y(Be)||!vr(re,o,f,c)||!vr(Be,o,f,c))continue;let Ee=i(re,null,f),Ge=i(Be,p,f),_e=Ee.flat.text,w=Ge.flat.text;if(c(f,_e.length),!Mn.test(_e)||w.length<=_e.length)continue;let V=a(Ge,f),ne=Ln(_e,w,V,f,c,!0);if(!(ne<0||Ln(R,w,V,f,c,!0,ne,ne+_e.length)<0&&!id({base:e,V:d,A:p,source:C,original:j,current:I,edited:P,destination:Ge,at:ne,ownLength:_e.length,eligible:o,model:i,tokensOf:a,budget:f,charge:c}))){if(W){F=!0;break}W=Be}}if(!W||F)continue;let $=n===0?_:M,Ne=n===0?M:_;(x||=[]).push({source:C,local:$,remote:Ne,models:[j,n===0?I:P,n===0?P:I]})}}catch(O){if(O!==h)throw O}return x}var Wn=/\S/,xn=/\s/,ld=/[\s\u001e]/g,gi=/[^\s\p{P}\u001e\ufffc]/u;function ad(e,t,n,r,o,s,l){let i=0;for(let a of e)l(s,1),a.nodeType===1&&!r.baseOf(a)&&i++;if(i<2)return!1;for(let a of e){if(a.nodeType!==1||r.baseOf(a))continue;let c=o.get(a).flat;if(c.atoms.length||c.pins?.length)continue;l(s,c.text.length*2+t.length+n.length);let h=new Uint8Array(c.text.length);for(let u of n)u.target===a&&h.fill(1,u.targetFrom,u.targetFrom+u.to-u.from);for(let u of t)u.target===a&&h.fill(1,u.targetFrom,u.targetFrom+u.to-u.from);for(let u=0;u<c.text.length;u++)if(!h[u]&&Wn.test(c.text[u]))return!0}return!1}function cd(e,t,n){let{source:r,models:o,retained:s,runs:l}=e,i=o.get(r).flat.text;n(t,i.length*2+s.length+l.length);let a=new Uint8Array(i.length);for(let c of s)c.source===r&&(n(t,c.to-c.from),a.fill(1,c.from,c.to));for(let c of l)n(t,c.to-c.from),a.fill(1,c.from,c.to);for(let c=0;c<i.length;c++)if(!a[c]&&Wn.test(i[c]))return!1;return!0}function fd(e,t,n,r,o,s,l,i,a,c){let h=s.get(e),u=s.get(t),f=h.flat.text,d=l.get(e);a(c,f.length*2+n.length);let p=f.length,y=0;for(let k=0;k<f.length;k++)!xn.test(f[k])&&!d[k]&&(p=Math.min(p,k),y=k+1);if(p>=y)return null;for(let k=p;k<y;k++)if(!xn.test(f[k])&&d[k])return null;let m=-1;for(let k of n)if(k.target===t&&k.from<=p&&k.to>p){m=k.targetFrom+p-k.from;break}if(m<0)return null;let g=f.slice(p,y);if(a(c,g.length*(n.length+2)),u.flat.text.slice(m,m+g.length)!==g)return null;for(let k=p;k<y;k++){if(xn.test(f[k]))continue;let S=!1;for(let v of n)if(v.target===t&&v.from<=k&&v.to>k&&v.targetFrom+k-v.from===m+k-p){S=!0;break}if(!S)return null}if(h.flat.atoms.length||u.flat.atoms.length){a(c,h.flat.atoms.length+u.flat.atoms.length);let k=0,S=u.flat.atoms;for(;k<S.length&&S[k].i<m;)k++;for(let v of h.flat.atoms){if(v.i<p||v.i>=y)continue;let x=S[k++];if(!x||x.i!==m+v.i-p||u.alignment?.reverse.get(x.el)!==v.el)return null}if(k<S.length&&S[k].i<m+y-p)return null}for(let[k,S,v]of[[r,e,p],[o,t,m]]){let x=!1;for(let O of k){let C=s.get(O),_=l.get(O),M=i(C,c);for(let j=0;j<M.length;j++){let I=M[j].from,P=I+g.length;if(a(c,g.length*2+1),C.flat.text.slice(I,P)!==g)continue;let R=j;for(;R<M.length&&M[R].to<P;)a(c,1),R++;if(R===M.length||M[R].to!==P)continue;let T=!0;for(let A=I;A<P;A++)if(!xn.test(C.flat.text[A])&&_[A]){T=!1;break}if(T){if(x||O!==S||I!==v)return null;x=!0}}}if(!x)return null}return g}function ud(e,t,n,r,o,s,l,i){if(l(i,o.length+s.length+(r.length+1)*n.length*2),!n)return!1;let a=r.indexOf(n);return a<0||r.lastIndexOf(n)!==a||!s.some(c=>c.from===a)||!s.some(c=>c.to===a+n.length)?!1:o.some(c=>c.source===e&&c.target===t&&c.from===0&&c.to===n.length&&c.targetFrom===a)}function pa({base:e,views:t,eligible:n,baseId:r,ignored:o,remoteWins:s,atomKey:l,limit:i=2e4*8}){if(i<=0)return null;let a=Symbol(),c=(v,x)=>{if(x>v.remaining)throw a;v.remaining-=x},h=[new Map,new Map];for(let v=0;v<2;v++)for(let x=0;x<t[v].V.units.length;x++)h[v].set(t[v].V.units[x],x);let u=new Int32Array(e.length),f=new Int32Array(e.length),d=v=>t.every(({V:x},O)=>{let C=x.twin(v);return C&&h[O].has(C)}),p=-1;for(let v=0;v<e.length;v++)u[v]=p,d(e[v])&&(p=v);p=e.length;for(let v=e.length-1;v>=0;v--)f[v]=p,d(e[v])&&(p=v);let y=new Map,m=(v,x)=>{if(c(x,1),y.has(v))return y.get(v);let O=v.firstChild,C=1;for(;O;){if(c(x,C*8+8),O.nodeType===3&&c(x,O.data.length*8),O.nodeType===1&&En.has(O.tagName)&&!o(O)&&!s(O)&&O.firstChild){O=O.firstChild,C++;continue}for(;O&&O!==v&&!O.nextSibling;)O=O.parentNode,C--;O=!O||O===v?null:O.nextSibling}let _=on(Array.from(v.childNodes),{ignored:o,remoteWins:s});return y.set(v,_),_},g=(v,x,O,C,_,M)=>{for(let j of v.atoms){c(M,1);let I=x.atomAt.get(j.i+O);if(!I)return!1;let P=C?.reverse.get(j.el)||l(j.el),R=_?.reverse.get(I.el)||l(I.el);if(P!==R)return!1}return!0},k=(v,x,O,C,_)=>{let M=v.text.length<=x.text.length?v:x,j=M===v?x:v;if(c(_,M.text.length+j.text.length),!M.text||!Wn.test(M.text.replaceAll(zn,"")))return!1;let I;if(M.text===j.text)I=0;else{let P=j.text.length-M.text.length;if(c(_,(P+1)*M.text.length*2),j.text.startsWith(M.text))I=0;else if(j.text.endsWith(M.text))I=P;else return!1;if(j.text.indexOf(M.text)!==I||j.text.lastIndexOf(M.text)!==I)return!1;c(_,j.text.length*2);let R=0,T=I===0,A=!1;for(let W of hn(j.text,Tn(j.text)))R+=W.len,R===I&&(T=!0),R===I+M.text.length&&(A=!0);if(!T||!A)return!1}return M===v?g(M,j,I,O,C,_):g(M,j,I,C,O,_)},S=null;for(let v=0;v<2;v++){let{V:x,A:O,idOf:C}=t[v],_=t[1-v];if(!x.asBase)for(let M=0;M<e.length;M++){let j=e[M];if(x.twin(j)||!n(j))continue;let I=_.V.twin(j);if(!I||!h[1-v].has(I)||!n(I))continue;let P={remaining:i};try{let R=u[M],T=f[M],A=0;for(let Ne=R+1;Ne<T;Ne++)c(P,1),!x.twin(e[Ne])&&_.V.twin(e[Ne])&&n(e[Ne])&&A++;if(A!==1||m(j,P).text===m(I,P).text)continue;let W=R<0?-1:h[v].get(x.twin(e[R])),F=T===e.length?x.units.length:h[v].get(x.twin(e[T]));if(W===void 0||F===void 0||W>=F)continue;let $=null;for(let Ne=W+1;Ne<F;Ne++){c(P,1);let Ce=x.units[Ne];if(x.baseOf(Ce)||!n(Ce)||Ce.tagName!==j.tagName||Ce.namespaceURI!==j.namespaceURI)continue;let Be=r(j),re=_.idOf(I),Ee=C(Ce);if(!(Be&&re&&Be!==re||Be&&Ee&&Be!==Ee||re&&Ee&&re!==Ee)&&k(m(I,P),m(Ce,P),_.A,O,P)){if($){$=null;break}$=Ce}}if(!$)continue;S||(S=[new Map,new Map]),S[v].set(j,$)}catch(R){if(R!==a)throw R}}}return S?t.map(({V:v},x)=>{let O=S[x];if(!O.size)return v;let C=new Map;for(let[_,M]of O)C.set(M,_);return{...v,twin:_=>O.get(_)||v.twin(_),baseOf:_=>C.get(_)||v.baseOf(_)}}):null}function ga({onUncertainSource:e,onUncertainOwner:t,base:n,views:r,eligible:o,ignored:s,remoteWins:l,baseId:i,atomKey:a,limit:c=2e4*32}){if(c<=0)return null;let h=new Set(n),u=new Map(n.map((R,T)=>[R,T])),f=new Map,d=[],p=null,y=null,m=null,g=new Set;for(let R of n)for(let{V:T}of r){let A=T.twin(R);A&&!T.asBase&&!T.here(A)&&g.add(R)}let k=new Set,S=Symbol(),v=(R,T)=>{if(T>R.remaining)throw S;R.remaining-=T},x=(R,T,A)=>{v(A,1);let W=f.get(R);if(W)return W;if(R.nodeType===1){let Ne=R.firstChild,Ce=1;for(;Ne;){if(v(A,Ce*8+8),Ne.nodeType===3&&v(A,Ne.data.length*8),Ne.nodeType===1&&En.has(Ne.tagName)&&!s(Ne)&&!l(Ne)&&Ne.firstChild){Ne=Ne.firstChild,Ce++;continue}for(;Ne&&Ne!==R&&!Ne.nextSibling;)Ne=Ne.parentNode,Ce--;Ne=!Ne||Ne===R?null:Ne.nextSibling}}else v(A,R.value.length*8+R.nodes.length);let F=R.nodeType===1?Array.from(R.childNodes):R.nodes,$=F.length===1&&F[0].nodeType===3?{text:F[0].data,nodes:[{node:F[0],s:0,e:F[0].data.length}],atoms:[]}:on(F,{ignored:s,remoteWins:l});return W={unit:R,flat:$,alignment:T,tokens:null},f.set(R,W),W},O=(R,T)=>{if(R.tokens)return R.tokens;v(T,R.flat.text.length*8);let{unit:A,flat:W,alignment:F}=R,$=[],Ne=Tn(W.text),Ce=0,Be=re=>{for(let Ee of hn(W.text.slice(Ce,re),Ne))Ee.from=Ce,Ee.to=Ce+Ee.len,Ee.unit=A,$.push(Ee),Ce+=Ee.len};for(let re of W.atoms){Be(re.i);let Ee=l(re.el)&&re.el.nodeType===1?"w"+re.el.tagName+"#"+(re.el.id||""):a(F?.reverse.get(re.el)||re.el);$.push({k:Ee,raw:zn,len:1,from:Ce,to:Ce+1,unit:A,atom:!0}),Ce++}return Be(W.text.length),R.tokens=$,$},C=(R,T,A,W,F)=>{if(!R.flat.atoms.length&&!T.flat.atoms.length)return!0;let $=O(R,F),Ne=O(T,F);v(F,$.length+Ne.length);let Ce=0;for(let Be of Ne){if(!Be.atom||Be.from<A||Be.from>=A+W)continue;for(;Ce<$.length&&!$[Ce].atom;)Ce++;let re=$[Ce++];if(!re||re.from!==Be.from-A||re.k!==Be.k)return!1}for(;Ce<$.length;)if($[Ce++].atom)return!1;return!0},_=(R,T,A)=>{let W=R.length+T.length+4;if(W*8>A.remaining)return null;A.remaining-=W*8;let F=Math.floor(A.remaining/8),$=Math.min(R.length+T.length,4e3,Math.floor((Math.sqrt(W*W+F)-W)/2)),Ne=4*($+1)*(W+$+1);if($<1||Ne>A.remaining)return null;A.remaining-=Ne;let Ce=Yn(R,T,$),Be=[],re=0,Ee=0;for(let Ge of Ce.hunks){for(;re<Ge.bs;)R[re].raw===T[Ee].raw&&Be.push([R[re],T[Ee]]),re++,Ee++;re=Ge.be,Ee+=Ge.toks.length}for(;re<R.length&&Ee<T.length;)R[re].raw===T[Ee].raw&&Be.push([R[re],T[Ee]]),re++,Ee++;return Be},M=(R,T,A,W,F,$,Ne)=>{if(F<=W)return;let Ce=R[R.length-1];if(Ce&&Ce.source===T&&Ce.target===A&&Ce.to<=W&&Ce.targetFrom-Ce.from===$-W){v(Ne,(W-Ce.to)*3);let Be=f.get(T).flat.text,re=f.get(A).flat.text,Ee=!0;for(let Ge=Ce.to;Ge<W;Ge++)if(!xn.test(Be[Ge])||Be[Ge]!==re[$+Ge-W]){Ee=!1;break}if(Ee){Ce.to=F;return}}R.push({source:T,target:A,from:W,to:F,targetFrom:$})},j=R=>R.replace(ld,"");for(let R=0;R<r.length;R++){let{V:T,A,idOf:W}=r[R];if(T.asBase)continue;let F=new Map(T.units.map((w,V)=>[w,V])),$=w=>{let V=T.twin(w);return V&&F.has(V)?V:null},Ne=(w,V)=>{let ne=new Int32Array(w.length),te=new Int32Array(w.length),Pe=-1;for(let ze=0;ze<w.length;ze++)ne[ze]=Pe,V(w[ze])&&(Pe=ze);Pe=w.length;for(let ze=w.length-1;ze>=0;ze--)te[ze]=Pe,V(w[ze])&&(Pe=ze);return{prev:ne,next:te}},Ce=Ne(n,w=>(w.nodeType===1||w.kind==="text"&&Wn.test(w.value))&&$(w)),Be=Ne(T.units,w=>(w.nodeType===1||w.kind==="text"&&Wn.test(w.value))&&h.has(T.baseOf(w))),re=new Map,Ee=(w,V,ne,te)=>{if(w>V||ne>te)return;let Pe=`${w}:${V}:${ne}:${te}`;re.set(Pe,[w,V,ne,te])};for(let w=0;w<T.units.length;w++){let V=T.units[w];if(T.baseOf(V)||!o(V))continue;let ne=Be.prev[w],te=Be.next[w],Pe=ne<0?0:u.get(T.baseOf(T.units[ne])),ze=te===T.units.length?n.length-1:u.get(T.baseOf(T.units[te]));Ee(Pe,ze,Math.max(0,ne),Math.min(T.units.length-1,te))}for(let w=0;w<n.length;w++){let V=n[w];if(g.has(V)||!o(V))continue;if(!T.twin(V)){let it=Ce.prev[w],tt=Ce.next[w],Q=it<0?0:F.get($(n[it])),ce=tt===n.length?T.units.length-1:F.get($(n[tt]));Ee(Math.max(0,it),Math.min(n.length-1,tt),Q,ce)}let ne=$(V);if(!ne||A.identical.has(V)||!o(ne))continue;let te=w+1;for(;te<n.length&&n[te].kind==="text"&&!n[te].value.trim();)te++;if(te>=n.length||!o(n[te]))continue;let Pe=$(n[te]);if(!Pe||A.identical.has(n[te])||!o(Pe))continue;let ze=F.get(ne),Se=F.get(Pe);ze<Se&&Ee(w,te,ze,Se)}let Ge=Array.from(re.values()),_e=new Set;if(Ge.length>1){let w=Xt(c);try{v(w,Ge.length*4);let V=Ge.slice().sort((Pe,ze)=>(v(w,1),Pe[0]-ze[0]||Pe[2]-ze[2])),ne=[],te=null;for(let Pe of V)v(w,1),te&&Pe[0]<=te[1]&&Pe[2]<=te[3]&&Pe[3]>=te[2]?(te[1]=Math.max(te[1],Pe[1]),te[2]=Math.min(te[2],Pe[2]),te[3]=Math.max(te[3],Pe[3]),te[4].push(Pe)):(te?.[4].length>1&&ne.push(te),te=[Pe[0],Pe[1],Pe[2],Pe[3],[Pe]]);te?.[4].length>1&&ne.push(te),Ge=ne.concat(Ge)}catch(V){if(V!==S)throw V}}for(let w of Ge){if(_e.has(w))continue;let[V,ne,te,Pe,ze]=w,Se=Xt(c),it=[],tt=new Set,Q=!1;try{v(Se,(ne-V+Pe-te+2)*4);let ce=n.slice(V,ne+1).filter(ee=>!A.identical.has(ee)&&o(ee)&&!g.has(ee)),Re=T.units.slice(te,Pe+1).filter(ee=>o(ee)&&(!T.baseOf(ee)||h.has(T.baseOf(ee)))&&!A.identical.has(T.baseOf(ee))&&!g.has(T.baseOf(ee))),Ue=new Set(Re),qe=!1,ot="",xt="",kt=0;for(let ee of ce){let Me=x(ee,null,Se);ot+=Me.flat.text,kt+=Me.flat.text.length}for(let ee of Re){let Me=x(ee,A,Se);xt+=Me.flat.text,kt+=Me.flat.text.length}v(Se,kt);let Ct=j(ot),dt=j(xt),St=Ct===dt;if(Q=St,ze&&!St)continue;let ht=St?null:new Map;if(ht)for(let ee of ce.concat(Re)){let Me=f.get(ee).flat.text.length;v(Se,Me*16),ht.set(ee,new Uint8Array(Me))}let H=ee=>{let Me=[];for(let Ve of ee){let Ie=f.get(Ve);Ie.flat.atoms.length?Me.push(...O(Ie,Se)):Me.push({unit:Ve,raw:Ie.flat.text,from:0})}return Me},ie=[];for(let ee of St?[]:ce){let Me=$(ee);if(!Ue.has(Me))continue;let Ve=x(ee,null,Se),Ie=x(Me,A,Se);v(Se,Ve.flat.text.length+Ie.flat.text.length);let ke=Ve.flat.text&&Ie.flat.text.startsWith(Ve.flat.text)?0:Ve.flat.text&&Ie.flat.text.endsWith(Ve.flat.text)?Ie.flat.text.length-Ve.flat.text.length:-1;if(ke>=0&&C(Ve,Ie,ke,Ve.flat.text.length,Se)){ht.get(ee).fill(1),ht.get(Me).fill(1,ke,ke+Ve.flat.text.length),M(ie,ee,Me,0,Ve.flat.text.length,ke,Se);continue}let B=_(O(Ve,Se),O(Ie,Se),Se);if(!B){qe=!0;break}for(let[G,he]of B)ht.get(ee).fill(1,G.from,G.to),ht.get(Me).fill(1,he.from,he.to),M(ie,ee,Me,G.from,G.to,he.from,Se)}if(qe)continue;let pe=null,ge=null;if(!St)for(let ee of ce){let Me=$(ee),Ve=f.get(ee);if(!Me||Ve.flat.atoms.length||!Ue.has(Me))continue;let Ie=Ve.flat.text,ke=ht.get(ee);v(Se,Ie.length*3+Re.length);let B=-1,G=-1,he=!1;for(let We=0;We<Ie.length;We++)xn.test(Ie[We])||(ke[We]?he=!0:(B<0&&(B=We),G=We+1));if(!he||B<0)continue;let be=!0;for(let We=B;We<G;We++)if(ke[We]&&!xn.test(Ie[We])){be=!1;break}if(!be)continue;let fe=j(Ie.slice(B,G)),we=null,oe=!1;for(let We of Re){if(T.baseOf(We))continue;let Oe=f.get(We);if(!Oe.flat.atoms.length&&(v(Se,Oe.flat.text.length),j(Oe.flat.text)===fe)){if(we){oe=!0;break}we=We}}if(oe){(ge||=new Set).add(ee);continue}if(!we||ge?.has(ee))continue;let K=!1;for(let We of ce){if(We===ee||!Ue.has($(We)))continue;let Oe=f.get(We);if(Oe.flat.atoms.length)continue;let Ze=ht.get(We);v(Se,Oe.flat.text.length*3);let st="",E=!1;for(let z=0;z<Oe.flat.text.length;z++)xn.test(Oe.flat.text[z])||(Ze[z]?E=!0:st+=Oe.flat.text[z]);E&&st===fe&&(ge||=new Set,ge.add(ee),ge.add(We),K=!0)}if(K)continue;let ue=f.get(we).flat.text;v(Se,G-B+ue.length);let Le=B,De=0;for(;Le<G&&De<ue.length;){for(;Le<G&&xn.test(Ie[Le]);)Le++;for(;De<ue.length&&xn.test(ue[De]);)De++;if(Le>=G||De>=ue.length)break;M(pe||=[],ee,we,Le,Le+1,De,Se),Le++,De++}ke.fill(1,B,G),ht.get(we).fill(1)}let Ae=ee=>{let Me=[];for(let Ve of ee){let Ie=x(Ve,h.has(Ve)?null:A,Se),ke=ht.get(Ve);for(let B of O(Ie,Se)){let G=B.from;for(;G<B.to;){for(;G<B.to&&ke[G];)G++;let he=G;for(;G<B.to&&!ke[G];)G++;if(G>he){let be=Ie.flat.text.slice(he,G);Wn.test(be)&&Me.push({...B,raw:be,len:G-he,k:B.atom?B.k:be,from:he,to:G})}}}}return Me},N=St?H(ce):Ae(ce),D=St?H(Re):Ae(Re),Y=St?Ct:N.map(ee=>j(ee.raw)).join(""),J=St?dt:D.map(ee=>j(ee.raw)).join("");if((!Y||!J)&&!pe)continue;let se=pe||[];if(Y&&J&&Y===J){let ee=0,Me=0,Ve=0,Ie=0;for(;ee<N.length&&Me<D.length;){let ke=N[ee],B=D[Me];for(;Ve<ke.raw.length&&xn.test(ke.raw[Ve]);)Ve++;for(;Ie<B.raw.length&&xn.test(B.raw[Ie]);)Ie++;if(Ve===ke.raw.length){ee++,Ve=0;continue}if(Ie===B.raw.length){Me++,Ie=0;continue}if((ke.atom||B.atom)&&ke.k!==B.k){qe=!0;break}M(se,ke.unit,B.unit,ke.from+Ve,ke.from+Ve+1,B.from+Ie,Se),Ve++,Ie++}}else if(Y&&J){let ee=_(N,D,Se);if(!ee)continue;for(let[Me,Ve]of ee)M(se,Me.unit,Ve.unit,Me.from,Me.to,Ve.from,Se)}if(qe)continue;let Fe=new Map;for(let ee of se)if(!ge?.has(ee.source)){if($(ee.source)===ee.target){St&&ie.push(ee);continue}Fe.has(ee.source)||Fe.set(ee.source,[]),Fe.get(ee.source).push(ee)}for(let[ee,Me]of Fe){let Ve=x(ee,null,Se),Ie=$(ee),ke=Ve.flat.text,B=[],G=new Set,he=r[1-R],be=he.V.twin(ee),fe=be&&he.V.here(be)?x(be,he.A,Se):null,we=(Oe,Ze)=>{let st=O(Oe,Se),E=O(Ze,Se);return v(Se,Oe.flat.text.length+Ze.flat.text.length+st.length+E.length),Oe.flat.text===Ze.flat.text&&st.length===E.length&&st.every((z,Z)=>z.k===E[Z].k)},oe=Ie&&fe&&fe.flat.text!==ke&&we(x(Ie,A,Se),fe);for(let Oe of new Set(Me.map(Ze=>Ze.target))){if(ee.nodeType!==1&&Oe.nodeType!==1)continue;let Ze=x(Oe,A,Se),st=T.baseOf(Oe);if(ee.nodeType!==1&&st||(v(Se,ke.length*2+Ze.flat.text.length*3+ie.length*2),Ie&&j(ke)===j(Ze.flat.text)&&x(Ie,A,Se).flat.text.trim()))continue;if(!Ie&&!st&&ee.nodeType===1&&Oe.nodeType===1){let de=i(ee),le=W(Oe);if(de&&le&&de!==le)continue}let E=Ze.flat.text,z=ke&&(E.startsWith(ke)||E.endsWith(ke)),Z=!1;if(!Ie&&fe&&st&&fe.flat.text!==ke){let de=x(st,null,Se).flat.text,le=u.get(ee)<u.get(st)?fe.flat.text:de,ae=u.get(ee)<u.get(st)?de:fe.flat.text;v(Se,le.length+ae.length+E.length),Z=!!le&&!!ae&&le.length+ae.length<=E.length&&E.startsWith(le)&&E.endsWith(ae)&&!E.slice(le.length,E.length-ae.length).trim()}let ye=!Ve.flat.atoms.length&&!fe?.flat.atoms.length&&!Ze.flat.atoms.length&&(oe&&z||Z);if(Ie&&st){let de=x(Ie,A,Se).flat.text,le=ke.startsWith(de)||ke.endsWith(de),ae=x(st,null,Se).flat.text,$e=Ze.flat.text,Je=$e.startsWith(ae)||$e.endsWith(ae),He=!r[1-R].V.twin(st)&&!ie.some(Xe=>Xe.source===st&&Wn.test(ae.slice(Xe.from,Xe.to)));if(!St&&(!le&&!ye||!Je&&!He)){let Xe=fd(ee,Oe,Me,ce,Re,f,ht,O,v,Se);if(!Xe)continue;let Qe=A.weak?.has(ee)&&!A.identityPaired?.has(ee)&&ke.trim()===Xe;if(!le&&!ye&&!Qe)continue;let rt=A.weak?.has(st)&&!A.identityPaired?.has(st)&&E.trim()===Xe&&!f.get(st).flat.atoms.length&&!ie.some(jt=>jt.source===st&&Wn.test(ae.slice(jt.from,jt.to)));if(!Je&&!He&&!rt&&!ud(st,Oe,ae,E,ie,O(Ze,Se),v,Se))continue;Qe&&G.add(Oe)}}ye&&G.add(Oe),v(Se,Me.length),B.push(...Me.filter(de=>de.target===Oe))}if(!B.length)continue;let K=new Uint8Array(ke.length);v(Se,ke.length*4+ie.length);for(let Oe of B)K.fill(1,Oe.from,Oe.to);let ue=[];for(let Oe=0;Oe<ke.length;Oe++)xn.test(ke[Oe])||ue.push(Oe);if(!ue.length)continue;let Le=new Set(B.map(Oe=>Oe.target));if(!St&&Ie&&Le.size>1&&ad(Le,se,ie,T,f,Se,v)){if(m||=new Map,m.set(ee,(m.get(ee)||0)|1<<R),e){let Oe=ai({source:ee,side:R,views:r,eligible:o,blocked:g,baseId:i,model:x,tokensOf:O,budget:Se,charge:v});if(Oe){v(Se,Oe.to-Oe.from);let Ze=!0;for(let st=Oe.from;st<Oe.to;st++)if(Wn.test(ke[st])&&!K[st]){Ze=!1;break}Ze&&(p||=[]).push(Oe)}}continue}let De=ue.filter(Oe=>gi.test(ke[Oe]));if(!B.some(Oe=>gi.test(ke.slice(Oe.from,Oe.to)))&&!ue.every(Oe=>K[Oe]))continue;if(!Ie&&!Array.from(Le).some(Oe=>G.has(Oe))&&!ue.every(Oe=>K[Oe])&&!(De.length&&K[De[0]]&&K[De[De.length-1]]&&Le.size===1)){let Oe=null,Ze=0,st=0,E=null,z=null;if(!Ie&&fe&&ee.nodeType===1&&!Ve.flat.atoms.length){let Z=O(Ve,Se).filter(ye=>gi.test(ye.raw));v(Se,Re.length+ke.length);for(let ye of Re){let de=T.baseOf(ye);if(!de||de===ee||de.nodeType!==1||ye.nodeType!==1||de.tagName!==ee.tagName||ye.tagName!==de.tagName)continue;let le=u.get(ee),ae=u.get(de),$e=!0;for(let en=Math.min(le,ae)+1;en<Math.max(le,ae);en++){let Pt=n[en];if(v(Se,Pt.nodeType===1?1:Pt.value.length+1),Pt.nodeType===1||Pt.value.trim()){$e=!1;break}}if(!$e)continue;let Je=x(de,null,Se),He=x(ye,A,Se);if(Je.flat.atoms.length||He.flat.atoms.length)continue;let Xe=Je.flat.text,Qe=He.flat.text;if(v(Se,Xe.length+Qe.length+ke.length),!Xe||!Z.length)continue;let rt=0,jt=Qe.length;if(le<ae&&Qe.endsWith(Xe))jt-=Xe.length;else if(le>ae&&Qe.startsWith(Xe))rt=Xe.length;else continue;for(;rt<jt&&xn.test(Qe[rt]);)rt++;for(;jt>rt&&xn.test(Qe[jt-1]);)jt--;let Et=Qe.slice(rt,jt);if(!(!Et||!(Et.startsWith(Z[0].raw)||Et.endsWith(Z[Z.length-1].raw)))){if(Oe){Oe=null;break}Oe=ye,Ze=rt,st=jt,E=Z[0],z=Z[Z.length-1]}}}if(v(Se,B.length),!Oe||!Le.has(Oe)||!B.some(Z=>Z.target===Oe&&(Z.from<=E.from&&Z.to>=E.to&&Z.targetFrom+E.from-Z.from===Ze||Z.from<=z.from&&Z.to>=z.to&&Z.targetFrom+z.to-Z.from===st)))continue}if(Ie&&!(ue.every(Oe=>K[Oe])&&(St||Array.from(Le).some(Oe=>G.has(Oe))))&&!ie.some(Oe=>Oe.source===ee&&Wn.test(ke.slice(Oe.from,Oe.to))))continue;let We=!1;if(St){v(Se,ie.length+ue.length);for(let Oe of ie)Oe.source===ee&&(v(Se,Oe.to-Oe.from),K.fill(1,Oe.from,Oe.to));We=!0;for(let Oe of ue)if(!K[Oe]){We=!1;break}}for(let Oe of Le){v(Se,B.length);let Ze=B.filter(E=>E.target===Oe);it.push({side:R,source:ee,target:Oe,runs:Ze,models:f,retained:ie,conservedSource:We}),ee.nodeType===1&&tt.add(ee),Oe.nodeType===1&&tt.add(Oe);let st=T.baseOf(Oe);st?.nodeType===1&&tt.add(st)}}if(d.push(...it),ze&&it.length)for(let ee of ze)_e.add(ee);for(let ee of tt)k.add(ee)}catch(ce){if(ce!==S)throw ce}finally{if(t&&!ze&&!Q){let ce=ma({base:n,views:r,side:R,attempt:w,eligible:o,blocked:g,baseId:i,model:x,tokensOf:O,charge:v,exhausted:S,limit:c});ce&&(y||=[]).push(...ce)}if(e&&!ze&&!Q){let ce=jl({base:n,views:r,side:R,attempt:w,eligible:o,blocked:g,baseId:i,model:x,tokensOf:O,certificates:d,charge:v,exhausted:S,limit:c});ce&&(p||=[]).push(...ce)}}}}let I=d.length?new Map:null;for(let R of d){let T=I.get(R.source);T||I.set(R.source,T=[]),T.push(R)}let P=null;if(I){let R=null;for(let[T,A]of I){let W=m?.get(T)||0;if(A.length<2&&!W)continue;let F=0;for(let $ of A)$.conservedSource&&(F|=1<<$.side);for(let $ of A){if($.conservedSource)continue;let Ne=1<<$.side,Ce=!0;if(F&Ne)Ce=!1;else if(W&Ne){Ce=!1;try{Ce=cd($,R||=Xt(c),v)}catch(Be){if(Be!==S)throw Be}}Ce||(P||=new Set).add($)}}}if(P){let R=0;for(let T of d)P.has(T)||(d[R++]=T);d.length=R;for(let[T,A]of I){R=0;for(let W of A)P.has(W)||(A[R++]=W);A.length=R,R||I.delete(T)}k.clear();for(let T of d){let{source:A,target:W,side:F}=T;A.nodeType===1&&k.add(A),W.nodeType===1&&k.add(W);let $=r[F].V.baseOf(W);$?.nodeType===1&&k.add($)}}if(p){let R=Xt(c),T=!1;for(let A of p){let W=!1,F=I?.get(A.source);if(F&&!T)try{W=li(A,F,R,v)}catch($){if($!==S)throw $;T=!0}W||e(A)}}if(y){let R=new Set,T=Xt(c);try{for(let A of y){if(v(T,1),R.has(A.source))continue;R.add(A.source);let W=!1;for(let F of d)if(v(T,1),F.source===A.source||F.target===A.local||F.target===A.remote){W=!0;break}W||t(A)}}catch(A){if(A!==S)throw A}}for(let R of n)if(k.has(R))for(let{V:T}of r){let A=T.twin(R);A&&T.here(A)&&k.add(A)}return d.length?{blocks:k,certificates:d,certificatesBySource:I,models:f}:null}function ba({certificates:e,scopes:t,flats:n,keys:r,limit:o=2e4*32}){let s=Symbol(),l=Xt(o),i=m=>{if(m>l.remaining)throw s;l.remaining-=m},a=t.map(m=>new Set(m)),c=new Map,h=new Map,u=(m,g)=>{let k=c.get(m);if(k||c.set(m,k=new Map),k.has(g))return k.get(g);i(m.text.length);let S=h.get(g);if(!S){i(g.nodes.length+g.atoms.length),S={nodes:new Map,atoms:new Map};for(let C of g.nodes)S.nodes.set(C.node,C);for(let C of g.atoms)S.atoms.set(C.el,C.i);h.set(g,S)}let{nodes:v,atoms:x}=S,O=new Int32Array(m.text.length).fill(-1);for(let C of m.nodes){let _=v.get(C.node);if(!(!_||C.e-C.s!==_.e-_.s)){i(C.e-C.s);for(let M=C.s;M<C.e;M++)O[M]=_.s+M-C.s}}for(let C of m.atoms){let _=x.get(C.el);_!==void 0&&(O[C.i]=_)}return k.set(g,O),O},f=(m,g,k,S,v)=>{let x=m[m.length-1];x&&x.to===g&&x.target+x.to-x.from===S&&x.kind===v?x.to=k:m.push({from:g,to:k,target:S,kind:v})},d=(m,g,k,S)=>{i((S-k)*4);let v=[],x=k,O=M=>{let j=m.text.slice(x,M);for(let I of hn(j,Tn(j)))I.from=x,I.to=x+I.len,v.push(I),x+=I.len},C=0,_=m.atoms.length;for(;C<_;){i(1);let M=C+_>>>1;m.atoms[M].i<k?C=M+1:_=M}for(let M=C;M<m.atoms.length&&m.atoms[M].i<S;M++){i(1);let j=m.atoms[M];O(j.i),v.push({k:g(j),raw:zn,len:1,from:x,to:x+1}),x++}return O(S),v},p=(m,g,k,S,v,x)=>{if(k===S||v===x)return;if(S-k===x-v){i((S-k)*4);let T=!0;for(let A=k,W=v;A<S;A++,W++){if(n[0].text[A]!==n[g].text[W]){T=!1;break}let F=n[0].atomAt.get(A),$=n[g].atomAt.get(W);if(!!F!=!!$||F&&r[0](F)!==r[g]($)){T=!1;break}}if(T){f(m,k,S,v,"retained");return}}let O=d(n[0],r[0],k,S),C=d(n[g],r[g],v,x),_=O.length+C.length+4,M=Math.min(O.length+C.length,4e3,Math.floor((Math.sqrt(_*_+l.remaining/2)-_)/2));if(M<1)throw s;i(4*(M+1)*(_+M+1));let j=Yn(O,C,M),I=0,P=0,R=()=>{let T=O[I++],A=C[P++];i(T.len),T.raw===A.raw&&f(m,T.from,T.to,A.from,"retained")};for(let T of j.hunks){for(;I<T.bs;)R();I=T.be,P+=T.toks.length}for(;I<O.length&&P<C.length;)R()},y=m=>{let g=e.filter(j=>j.side===m-1&&a[0].has(j.source)&&a[m].has(j.target));if(!g.length)return null;let k=[],S=(j,I,P)=>{if(!a[0].has(j.source)||!a[m].has(j.target))return;let R=u(I.get(j.source).flat,n[0]),T=u(I.get(j.target).flat,n[m]);i(j.to-j.from);for(let A=0;A<j.to-j.from;A++){let W=R[j.from+A],F=T[j.targetFrom+A];if(W<0||F<0)throw s;f(k,W,W+1,F,P)}},v=new Set;for(let j of g){if(!v.has(j.retained)){v.add(j.retained);for(let I of j.retained)S(I,j.models,"retained")}for(let I of j.runs)S(I,j.models,"transfer")}k.sort((j,I)=>(i(1),j.from-I.from||j.target-I.target));let x=[];for(let j of k){i(1);let I=x[x.length-1];if(I&&j.from<I.to){if(j.target-j.from!==I.target-I.from)throw s;I.to=Math.max(I.to,j.to),j.kind==="transfer"&&(I.kind="transfer")}else x.push(j)}let O=[],C=0,_=0;for(let j of x){if(j.target<_)throw s;p(O,m,C,j.from,_,j.target),O.push(j),C=j.to,_=j.target+j.to-j.from}p(O,m,C,n[0].text.length,_,n[m].text.length);let M=Hn({base:n[0],side:n[m],retained:O.filter(j=>j.kind==="retained"),transfers:O.filter(j=>j.kind==="transfer"),baseAtomKey:r[0],sideAtomKey:r[m],budget:l});if(M.status!=="ready"||!M.monotone)throw s;return M};try{let m=y(1),g=y(2);return m||g?{local:m,remote:g}:{fallback:!0}}catch(m){if(m!==s)throw m;return{fallback:!0}}}function bi(e,t,n=!1){let r=-1,o=-1;for(let l=0;l<e.list.length;l++){let i=e.list[l];i.bLo<t.lo||i.bLo>t.hi||(r<0&&(r=l),o=l)}let s=[];for(let l=r;l>=0&&l<=o;l++){let i=e.list[l],a=!n&&l===r?i.inlineStart<0?i.to:i.inlineStart:i.from,c=!n&&l===o?i.inlineEnd<0?i.from:i.inlineEnd:i.to;for(let h=a;h<c;h++)s.push(e.units[h]);l<o&&s.push(e.units[i.next])}return s}var bt=e=>!!e&&e.nodeType===1,Pn=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function ki(e){for(let t of e)if(Pn.has(t.tagName))return!0;return!1}function dd(e,t,n){let r=null;for(let o of t.childNodes)if(!(!bt(o)||!n(o)||!o.isEqualNode(e))){if(r)return null;r=o}if(!r)return null;for(let o of e.parentNode.childNodes)if(o!==e&&o.isEqualNode(e))return null;return r}var bo="[id],[data-id],script,head>*";function yi(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let r=jr(n,e);if(r)return"merge:"+r.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?Zl(n,t):null}}function es(e,t,n,r){let o=r.ignored,s=r.stats||nr(),l=Cl({ignored:o,ignoreAttribute:r.ignoreAttribute,stats:s}),{unitsOf:i,meta:a}=l,c=r.baseURI,h=r.mergeTags!==null,u=yi(r.mergeTags,c),f=E=>z=>{let Z=u(z);return Z!==null?Z:E(z)},d=f(r.identity.base),p=f(r.identity.local),y=f(r.identity.remote),m=r.authored||r.identity,g=E=>E&&E.nodeType===9?E.documentElement:E,k=g(e),S=g(t),v=g(n),x=globalThis.__hyperMorphProfile,O=x?performance.now():0,C=E=>E===Sn?bo:null,_=r.scope||null,M=_?_.baseDropped:new Set,j=new Set,I=_?_.remoteDropped:new Set,P=_?_.baseIndex:zo(k,d,o,C(r.identity.base),M),R=r.localIsBase||k===S?null:zo(S,p,o,C(r.identity.local),j),T=_?_.remoteIndex:zo(v,y,o,C(r.identity.remote),I),A=E=>{let z=bt(E)&&p(E);return z&&R?.get(z)===E&&!P.has(z)?z:null},W=E=>{let z=bt(E)&&y(E);return z&&T.get(z)===E&&!P.has(z)?z:null},F=R?Zs(k,S,{analyzer:l,baseIndex:P,sideIndex:R,baseId:m.base,sideId:m.local,baseKey:d,sideKey:p,baseDropped:M,sideDropped:j,stats:s}):ya(),$=Zs(k,v,{analyzer:l,baseIndex:P,sideIndex:T,baseId:m.base,sideId:m.remote,baseKey:d,sideKey:y,baseDropped:M,sideDropped:I,stats:s,scope:_,comparisons:r.comparisons});if(_){if(!_.held($))return null;for(let E of _.dropped)Xs(E)}let Ne=null;function Ce(E){if(!Ne){Ne=new WeakMap;let z=[k];for(;z.length;){let Z=z.pop();Z.tagName==="TEMPLATE"&&Z.content&&Ne.set(Z.content,Z);for(let ye of l.childrenOf(Z))ye.nodeType===1&&z.push(ye)}}return Ne.get(E)||null}let Be=E=>{let z=bt(E)||E.nodeType?E.parentNode:E.parent;return z&&z.nodeType===11?Ce(z):z};if($.moved.size){let E=!1;for(let z of Array.from($.moved))!bt(z)||$.identityPaired.has(z)||!m.base(z)||ge($,Be(z))||($.unpair(z),E=!0);E&&$.rematch()}ie(),pe(F,$),pe($,F);for(let E of[F,$])if(E.refused)for(let z of E.refused)E.moved.has(z)||s.ambiguousMoves++;x&&(x.alignTotal=(x.alignTotal||0)+(performance.now()-O),O=performance.now());let re=k.ownerDocument.implementation.createHTMLDocument(""),Ee=new WeakMap,Ge=new WeakMap,_e=[],w=[],V=new Set,ne=[],te=new Set,Pe=new Set,ze=new Set,Se=new WeakMap,it=null,tt=r.conflicts||"remote",Q=E=>_e.push(E),ce=E=>_e.push(E),Re=aa({roots:{base:k,local:S,remote:v},L:F,R:$,unitsOf:i,provenance:Ee,policy:tt}),Ue=(E,z)=>{w.push(E),z&&Re.note(E,z)},qe=null,ot=null,xt=ht(),kt=null,Ct=J(k,F.map.get(k),$.map.get(k),!!r.localIsBase,!!r.childrenOnly);Ct.tagName==="HTML"?re.replaceChild(Ct,re.documentElement):re.body.appendChild(Ct),qe?.drain(Ct),ot?.drain(Ct),x&&(x.build=(x.build||0)+(performance.now()-O));let dt=r.childrenOnly?!ue(oe(Ct),oe(v)):!be(Ct,v),St=Re.finish(Ct);return{doc:re,root:Ct,provenance:Ee,textMappers:Ge,decisions:_e,conflicts:w,recoveryLinks:St,localDiverged:dt,mergedScripts:V,segments:ne,remoteIdOf:r.identity.remote,customIdentity:r.identity.remote!==Sn,L:F,R:$,stats:s};function ht(){let E=new Map,z=new Set;if(r.localIsBase||!F.insertedByHash)return{partner:E,drop:z};let Z=F.insertedByHash(),ye=$.insertedByHash();if(!Z.size||!ye.size)return{partner:E,drop:z};let de={ignored:o,remoteWins:r.remoteWins,inlineCache:Se},le=vt=>{let At=0;for(let wt=vt.parentNode;wt;wt=wt.parentNode)At++;return At},ae=[],$e=vt=>{let At=vt.textContent.trim();return At.split(/\s+/).length>=3||At.replace(/\s/g,"").length>=12},Je=vt=>{let At=ge(F,vt),wt=ge($,vt);return At&&F.reverse.get(At.parentNode)!==vt.parentNode||wt&&$.reverse.get(wt.parentNode)!==vt.parentNode},He=(vt,At,wt)=>{for(let mt of wt.parentNode.children){let Wt=mt!==wt&&vt.reverse.get(mt);if(Wt&&Je(Wt))return!0}let Ft=vt.reverse.get(wt.parentNode);if(Ft){for(let mt of Ft.children)if(!ge(At,mt)&&!o(mt))return!0}return!1},Xe=new Map([[F,new Map],[$,new Map]]),Qe=(vt,At)=>{let wt=Xe.get(vt),Ft=wt.get(At);if(Ft===void 0){Ft=!1;for(let mt of At.children)if(vt.reverse.has(mt)||Qe(vt,mt)){Ft=!0;break}wt.set(At,Ft)}return Ft},rt=new Map;for(let vt of ye.values())for(let At of vt){let wt=W(At);wt&&rt.set(wt,At)}for(let vt of Z.values())for(let At of vt){let wt=A(At),Ft=wt?rt.get(wt):null;Ft&&Ft.tagName===At.tagName&&!Vn(At,de)&&!Vn(Ft,de)&&!r.remoteWins(At)&&!r.remoteWins(Ft)&&ae.push([At,[Ft],le(At),!0,!0])}for(let[vt,At]of Z){let wt=ye.get(vt);if(!wt)continue;let Ft=At.length===1&&wt.length===1;for(let mt of At)!Vn(mt,de)&&!A(mt)&&ae.push([mt,wt,le(mt),Ft&&($e(mt)||He(F,$,mt)||He($,F,wt[0]))])}if(!ae.length)return{partner:E,drop:z};ae.sort((vt,At)=>vt[2]-At[2]);let jt=new Set,Et=new Set,en=vt=>{for(let At of vt.querySelectorAll("*"))jt.add(At)},Pt=(vt,At)=>vt.reverse.get(At.parentNode)||null;for(let[vt,At,,wt,Ft]of ae){if(jt.has(vt)||Et.has(vt)||Ft&&(Qe(F,vt)||Qe($,At[0])))continue;let mt=Pt(F,vt),Wt=Jt=>!Et.has(Jt)&&!jt.has(Jt)&&(Ft||Jt.tagName===vt.tagName&&!W(Jt)&&l.equalUnits(vt,Jt)),Mt=At.find(Jt=>mt&&Pt($,Jt)===mt&&Wt(Jt))||(wt?At.find(Wt):null);if(!Mt)continue;Et.add(vt),Et.add(Mt);let gn=mt&&Pt($,Mt)===mt;(!Ft||!gn||l.equalUnits(vt,Mt))&&(en(vt),en(Mt)),!gn&&(E.set(vt,Mt),E.set(Mt,vt),z.add(tt==="local"?Mt:vt))}return{partner:E,drop:z}}function H(E,z,Z){if(te.add(E),xt.drop.has(E))return null;te.add(Z);let ye=z==="local"?E:Z,de=z==="local"?Z:E,le;return l.equalUnits(ye,de)?(le=G(ye,"local",!0),Ee.get(le).remote=de):le=B(ye,de),Ue({kind:"structure",el:le,detail:"both-moved",base:null,local:ye,remote:de},{unit:{b:null,l:ye,r:de}}),Q({kind:"insert",el:le,source:"both"}),le}function ie(){if(!F.weak||!$.weak||!F.weak.size||!$.weak.size||!F.unpair)return;let E=new Map;for(let Z of F.weak){let ye=ge(F,Z);bt(Z)&&bt(ye)&&E.set(l.unitHash(ye),Z)}let z=!1;for(let Z of Array.from($.weak)){let ye=ge($,Z);if(!bt(Z)||!bt(ye))continue;let de=E.get(l.unitHash(ye));if(!de||de===Z||!F.weak.has(de)||ge(F,Z)&&ge($,de))continue;let le=ge(F,de);le.tagName===ye.tagName&&l.equalUnits(le,ye)&&(F.unpair(de),$.unpair(Z),z=!0)}z&&(F.rematch(),$.rematch())}function pe(E,z){if(!E.weak||!E.weak.size||!z.insertedByHash)return;let Z=z.insertedByHash();if(!Z.size)return;let ye=!1;for(let de of Array.from(E.weak)){let le=ge(E,de);if(!le)continue;let ae=E===F?A(le):W(le);if(ae){let Je=(E===F?T:R)?.get(ae);Je&&Je.tagName===le.tagName&&!z.reverse.has(Je)&&(E.unpair(de),ye=!0);continue}let $e=Z.get(l.unitHash(le));$e&&$e.some(Je=>Je.tagName===le.tagName&&l.equalUnits(Je,le))&&(E.unpair(de),ye=!0)}ye&&E.rematch()}function ge(E,z){if(!z)return null;if(E.map.has(z))return E.map.get(z);let Z=[],ye=Be(z);for(;ye&&!E.map.has(ye);ye=Be(ye))Z.push(ye);let de=ye;if(!de||!E.identical.has(de))return null;E.pairIdenticalChildren(de);for(let ae=Z.length-1;ae>=0;ae--)E.pairIdenticalChildren(Z[ae]);let le=E.map.get(z)||null;return le&&s.lazyTwins++,le}function Ae(E,z,Z,ye){if(bt(E)&&Pn.has(E.tagName)&&!F.identical.has(E)&&(E.previousSibling?.nodeType===3||E.nextSibling?.nodeType===3)){let $e=Be(E),Je=ge(F,E),He=ge($,E);Je&&He&&Ze(Je,ge(F,$e),F)&&!Ze(He,ge($,$e),$)&&(ot||=ua({L:F,R:$,twinIn:ge,unitsOf:i,view:N,parentOf:Be,ignored:o,remoteWins:r.remoteWins,eligible:Xe=>bt(Xe)&&Pn.has(Xe.tagName),build:J,out:re,policy:tt,provenance:Ee,textMappers:Ge,segments:ne,conflicts:w,conflict:Ue,decisions:_e}),ot.ensureOwner(E))}if(z===null)return null;if(ye!==void 0)return qe||=Fr(Ee,Be,F,$,ge,J,o,r.remoteWins,w,Ue,D,S,v),qe.plan(E,z,Z,!!ye),ye&&(qe.produced(E,ye),Pe.add(E)),ye;if(Pe.has(E)||ze.has(E))return Ue({kind:"structure",el:null,detail:"both-moved",base:E},{subject:E}),Pe.has(E)?null:G(Z,z);qe||=Fr(Ee,Be,F,$,ge,J,o,r.remoteWins,w,Ue,D,S,v),qe.plan(E,z,Z,!0);let de=ge(F,E),le=ge($,E);(!de||!le)&&Ue({kind:"structure",el:null,detail:"move-beats-delete",base:E},{subject:E,deleted:de?"remote":"local"});let ae=J(E,de,le,!1);return(z==="local"?Q:ce)({kind:"move",el:ae,source:z}),ae}function N(E,z,Z,ye){return ye||!z||z===Z?{el:Z,asBase:!0,twin:de=>de,baseOf:de=>de,units:i(Z),here:()=>!0,parentOfTwin:()=>Z}:{el:z,asBase:!1,twin:de=>ge(E,de),baseOf:de=>E.reverse.get(de),units:i(z),here:de=>bt(de)?de.parentNode===z||z.tagName==="TEMPLATE"&&de.parentNode===z.content:de.parent===z||z.tagName==="TEMPLATE"&&de.parent===z.content}}function D(E,z,Z){return!z||Z&&Z.identical.has(E)?!1:bt(E)?!l.equalUnits(E,z)||!Y(E,z,Z):E.value!==z.value}function Y(E,z,Z){if(!Z||E===z)return!0;let ye=[[E,z]];for(;ye.length;){let[de,le]=ye.pop(),ae=i(de),$e=i(le);for(let Je=0;Je<ae.length&&Je<$e.length;Je++){let He=ae[Je],Xe=$e[Je];if(!bt(He)||!bt(Xe))continue;let Qe=Z.map.get(He);if(Qe!==void 0&&Qe!==Xe)return!1;let rt=Z.reverse.get(Xe);if(rt!==void 0&&rt!==He)return!1;ye.push([He,Xe])}}return!0}function J(E,z,Z,ye,de=!1){let le=ye||(Z?r.remoteWins(Z):r.remoteWins(E)),ae=E.namespaceURI&&E.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(E.namespaceURI,E.tagName):re.createElement(E.tagName),$e={base:E,local:z||null,remote:Z||null};if(Ee.set(ae,$e),le&&!ye&&z&&D(E,z,F)&&(!Z||!l.equalUnits(z,Z))&&Ue({kind:"structure",el:ae,detail:"remote-wins",base:E,local:z,remote:Z||null},{subject:E}),te.add(E),Pe.add(E),z&&te.add(z),Z&&te.add(Z),r.skipUnchanged&&!de&&(r.localIsBase||F.identical.has(E))&&Z&&$.identical.has(E)&&!r.remoteWins(E)){$e.unchanged=!0;for(let He of E.attributes)He.namespaceURI?ae.setAttributeNS(He.namespaceURI,He.name,He.value):ae.setAttribute(He.name,He.value);return qe?.produced(E,ae),ae}ze.add(E),de||ee(E,le?E:z,Z,ae);let Je=E.tagName;if(yn(E))Fe(E,le?E:z,Z,ae);else if(Je==="TEXTAREA")ae.textContent=se(E.textContent,(le?E:z)?(le?E:z).textContent:E.textContent,Z?Z.textContent:E.textContent,ae,"text");else if(!ot?.render(E,ae)){let He=he(E,z,Z,le,ae),Xe=Je==="TEMPLATE"&&ae.content?ae.content:ae;for(let Qe of He)Xe.appendChild(Qe)}return ze.delete(E),qe?.produced(E,ae),ae}function se(E,z,Z,ye,de){if(z===Z)return z;if(z===E)return Z!==E&&ce({kind:de,node:ye,source:"remote"}),Z;if(Z===E)return Q({kind:de,node:ye,source:"local"}),z;let le=tt==="local"?z:Z;return Ue({kind:de,node:ye,base:E,local:z,remote:Z,resolved:le},{site:"whole",el:ye}),_e.push({kind:de,node:ye,source:"both"}),le}function Fe(E,z,Z,ye){let de=E.textContent,le=z?z.textContent:de,ae=Z?Z.textContent:de,$e=h?jr(E,r.mergeTags,!0):null;if($e&&le!==ae){let Je=Z&&Z.getAttribute("merge-key")||E.getAttribute("merge-key"),{text:He,warnings:Xe}=mi(r.localIsBase?void 0:de,le,ae,{parse:$e.recognizer.parse,keyCandidates:Je?Je.split(/[\s,]+/).filter(Boolean):void 0});for(let Qe of Xe)console.warn(`[hyper-morph] merge "${$e.raw}": ${Qe}`);ye.textContent=He,V.add(ye),He!==ae?Q({kind:"text",node:ye,source:He===le?"local":"both"}):He!==de&&ce({kind:"text",node:ye,source:"remote"});return}ye.textContent=se(de,le,ae,ye,"text")}function ee(E,z,Z,ye){let de=new Map;for(let le of[E,z,Z])if(le)for(let ae of le.attributes)r.ignoreAttribute(le,ae.name)||de.set(ae.name,ae);for(let[le,ae]of de){let $e=E?E.getAttribute(le):null,Je=z?z.getAttribute(le):$e,He=Z?Z.getAttribute(le):$e,Xe;Je===He?Xe=Je:Je===$e?(Xe=He,ce({kind:"attr",el:ye,name:le,source:"remote"})):He===$e?(Xe=Je,Q({kind:"attr",el:ye,name:le,source:"local"})):(Xe=Me(le,$e,Je,He),Xe===void 0&&(Xe=tt==="local"?Je:He,Ue({kind:"attr",el:ye,name:le,base:$e,local:Je,remote:He,resolved:Xe},{el:ye,sample:ae})),_e.push({kind:"attr",el:ye,name:le,source:"both"})),Xe!=null&&(ae.namespaceURI?ye.setAttributeNS(ae.namespaceURI,ae.name,Xe):ye.setAttribute(le,Xe))}}function Me(E,z,Z,ye){if(E==="class"){let de=He=>new Set((He||"").split(/\s+/).filter(Boolean)),le=de(z),ae=de(Z),$e=de(ye),Je=new Set;for(let He of new Set([...le,...ae,...$e])){let Xe=le.has(He),Qe=ae.has(He),rt=$e.has(He);(Qe===rt?Qe:Qe===Xe?rt:Qe)&&Je.add(He)}return[...Je].join(" ")}if(E==="style"){let de=Xe=>{let Qe=new Map;if(!Xe)return Qe;let rt=0,jt=null,Et="",en=()=>{let Pt=Et.indexOf(":");Pt>0&&Qe.set(Et.slice(0,Pt).trim(),Et.slice(Pt+1).trim()),Et=""};for(let Pt of Xe){if(jt){Et+=Pt,Pt===jt&&(jt=null);continue}if(Pt==='"'||Pt==="'"){jt=Pt,Et+=Pt;continue}if(Pt==="("?rt++:Pt===")"&&rt--,Pt===";"&&rt===0){en();continue}Et+=Pt}return Et.trim()&&en(),Qe},le=de(z),ae=de(Z),$e=de(ye),Je=new Map,He=!1;for(let Xe of new Set([...le.keys(),...ae.keys(),...$e.keys()])){let Qe=le.get(Xe)??null,rt=ae.get(Xe)??null,jt=$e.get(Xe)??null,Et;rt===jt?Et=rt:rt===Qe?Et=jt:jt===Qe?Et=rt:(Et=tt==="local"?rt:jt,He=!0),Et!=null&&Je.set(Xe,Et)}return He?void 0:[...Je].map(([Xe,Qe])=>`${Xe}: ${Qe}`).join("; ")}}function Ve(E,z,Z,ye){let de=E.value,le=ye?de:z?z.value:"",ae=Z?Z.value:"";te.add(E),z&&te.add(z),Z&&te.add(Z);let $e=uo(de,le,ae,tt),Je=$e.text===""?null:re.createTextNode($e.text);Je&&(Ee.set(Je,{base:E.nodes,local:z?z.nodes:null,remote:Z?Z.nodes:null}),Ge.set(Je,$e.mapLocalOffset)),le!==de&&ae!==de?_e.push({kind:"text",node:Je,source:"both"}):le!==de?Q({kind:"text",node:Je,source:"local"}):ae!==de&&ce({kind:"text",node:Je,source:"remote"});for(let He of $e.conflicts)Ue({kind:"text",node:Je,base:de.slice(He.bs,He.be),local:He.local,remote:He.remote,resolved:He.resolved},{site:"run",bRun:E,lRun:z,rRun:Z,node:Je,c:He});return Je}function Ie(E,z){return gr(E,z).every(Z=>Z.bs===Z.be)}function ke(E,z){let Z=E?E.value:"",ye=z?z.value:"",de;if(Z===ye||!ye?de=Z:Z?Ie(Z,ye)?de=ye:Ie(ye,Z)?de=Z:(de=tt==="local"?Z:tt==="both"?Z+ye:ye,Ue({kind:"structure",el:null,detail:"insert-collision",local:Z,remote:ye,resolved:de},{unit:{b:null,l:E,r:z},localLost:tt==="remote"})):de=ye,E&&te.add(E),z&&te.add(z),de==="")return null;let le=re.createTextNode(de);return Ee.set(le,{base:null,local:E?E.nodes:null,remote:z?z.nodes:null}),Z?Q({kind:"insert",el:le,source:ye&&Z===ye?"both":"local"}):ce({kind:"insert",el:le,source:"remote"}),le}function B(E,z){let Z={ignored:o,remoteWins:r.remoteWins,inlineCache:Se},ye=$e=>i($e).every(Je=>bt(Je)?Vn(Je,Z):Je.kind==="text"),de=null;if(ye(E)&&ye(z)){let $e=E.textContent,Je=z.textContent;$e===Je||Ie(Je,$e)?de=z:Ie($e,Je)&&(de=E)}if(!de){let $e=tt==="local",Je=G($e?E:z,$e?"local":"remote",!0),He=Ee.get(Je);return $e?He.remote=z:He.local=E,Ue({kind:"structure",el:Je,detail:"insert-collision",local:E,remote:z,resolved:$e?E:z},{unit:{b:null,l:E,r:z},localLost:!$e}),Je}let le=E.namespaceURI&&E.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(E.namespaceURI,E.tagName):re.createElement(E.tagName);ee(null,E,z,le),Ee.set(le,{base:null,local:E,remote:z}),te.add(E),te.add(z);let ae=br({base:Array.from(de.childNodes),local:Array.from(E.childNodes),remote:Array.from(z.childNodes),out:re,policy:tt,idOf:{local:p,remote:y},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,provenance:Ee,textMappers:Ge,conflicts:w,conflict:Ue,scope:{base:null,local:E,remote:z,units:[],at:0},synthetic:!0,decisions:_e,node:le});ne.push(...ae.segments);for(let $e of ae.nodes)le.appendChild($e);return le}function G(E,z,Z=!1){if(!Z&&bt(E)){let ae=xt.partner.get(E);if(ae)return H(E,z,ae)}if(!bt(E)){if(E.value==="")return null;let ae=E.kind==="comment"?re.createComment(E.value):re.createTextNode(E.value);return Ee.set(ae,{base:null,local:z==="local"?E.nodes:null,remote:z==="remote"?E.nodes:null}),te.add(E),ae}let ye=E.namespaceURI&&E.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(E.namespaceURI,E.tagName):re.createElement(E.tagName);for(let ae of E.attributes)ae.namespaceURI?ye.setAttributeNS(ae.namespaceURI,ae.name,ae.value):ye.setAttribute(ae.name,ae.value);Ee.set(ye,{base:null,local:z==="local"?E:null,remote:z==="remote"?E:null}),te.add(E);let de=E.tagName==="TEMPLATE"&&ye.content?ye.content:ye,le=z==="local"?F:$;for(let ae of i(E)){let $e=bt(ae)?le.reverse.get(ae):null;if($e&&Ae($e,null,null),$e&&Pe.has($e)){Ue({kind:"structure",el:null,detail:"both-moved",base:$e},{subject:$e});continue}if($e&&!ze.has($e)){let He=ge(F,$e)||null,Xe=ge($,$e)||null;if(He||Xe){qe||=Fr(Ee,Be,F,$,ge,J,o,r.remoteWins,w,Ue,D,S,v),qe.plan($e,z,ae,!0);let Qe=J($e,He,Xe,!1);z==="local"?Q({kind:"move",el:Qe,source:"local"}):ce({kind:"move",el:Qe,source:"remote"}),de.appendChild(Qe);continue}}let Je=G(ae,z);Je&&de.appendChild(Je)}if(!Z&&xt.drop.size&&E.tagName==="DIV"&&!de.firstChild&&!E.attributes.length&&!(z==="local"?p(E):y(E))&&!le.reverse.has(E)&&!o(E)&&!r.remoteWins(E)){let ae=E.firstChild;if(ae&&ae===E.lastChild&&bt(ae)&&(xt.drop.has(ae)||kt?.has(ae)))return(kt||=new WeakSet).add(E),null}return ye}function he(E,z,Z,ye,de){z&&F.identical.has(E)&&F.pairIdenticalChildren(E),Z&&$.identical.has(E)&&$.pairIdenticalChildren(E);let le=N(F,z,E,ye),ae=N($,Z,E,!1),$e=i(E),Je=new Set($e),He=new Map;for(let xe=0;xe<$e.length;xe++)He.set($e[xe],xe);let Xe=[],Qe=new Set,rt=new Map,jt=new Set,Et=new Set,en=[],Pt=null;if(!le.asBase&&!ae.asBase&&!F.identical.has(E)&&!$.identical.has(E))for(let xe of $e){if(!bt(xe)||!Pn.has(xe.tagName))continue;let nt=le.twin(xe),et=ae.twin(xe);nt&&et&&(!le.here(nt)||!ae.here(et))&&Ae(xe,null,null)}$s();let vt=xe=>{let nt=[];for(let et of xe.units){if(Et.has(et))continue;let _t=xe.baseOf(et);_t&&Je.has(_t)&&nt.push(_t)}return nt},At=xe=>vt(xe).map(nt=>He.get(nt)),wt=xe=>xe.every((nt,et)=>et===0||nt>=xe[et-1]),Ft=!le.asBase&&!wt(At(le)),mt=!ae.asBase&&!wt(At(ae));Ft&&mt&&Ue({kind:"structure",el:de,detail:"both-reordered",base:E},{subject:E,lKept:vt(le),rKept:vt(ae)});let Wt=mt||!Ft?{V:ae,A:$,side:"remote",other:le,otherA:F,otherSide:"local"}:{V:le,A:F,side:"local",other:ae,otherA:$,otherSide:"remote"};Ft?Q({kind:"move",el:null,source:mt?"both":"local",base:E}):mt&&ce({kind:"move",el:null,source:"remote",base:E});let Mt=le.asBase?[]:le.units.filter(xe=>!le.baseOf(xe)&&!Et.has(xe)&&!xt.partner.has(xe)),gn=ae.asBase?[]:ae.units.filter(xe=>!ae.baseOf(xe)&&!Et.has(xe)&&!xt.partner.has(xe)),Jt=new Map;if(Mt.length&&gn.length){let xe=new Map,nt=new Map;for(let at of gn){if(bt(at)){let Ut=y(at);Ut&&xe.set(Ut,at)}let Nt=l.unitHash(at);nt.has(Nt)||nt.set(Nt,[]),nt.get(Nt).push(at)}let et=(at,Nt)=>{let Ut=at.units.indexOf(Nt);for(let pt=Ut-1;pt>=0;pt--){let Rt=at.baseOf(at.units[pt]);if(Rt)return Rt}return"start"},_t=new Map,Ht=new Map;for(let at of gn){let Nt=et(ae,at);bt(at)?(Ht.has(Nt)||Ht.set(Nt,[]),Ht.get(Nt).push(at)):at.kind==="text"&&!_t.has(Nt)&&_t.set(Nt,at)}for(let at of Mt){let Nt=null;if(bt(at)){let pt=p(at);pt&&xe.has(pt)&&!Jt.has(xe.get(pt))&&(Nt=xe.get(pt))}else if(at.kind==="text"){let pt=_t.get(et(le,at));pt&&!Jt.has(pt)&&(Nt=pt)}let Ut=!!A(at);if(!Nt&&!Ut){let pt=nt.get(l.unitHash(at));pt&&(Nt=pt.find(Rt=>!Jt.has(Rt)&&bt(Rt)===bt(at)&&(bt(Rt)?Rt.tagName===at.tagName&&!W(Rt):Rt.kind===at.kind)&&l.equalUnits(at,Rt))||null)}if(!Nt&&bt(at)&&!Ut){let pt=m.local(at),Rt=(Ht.get(et(le,at))||[]).filter(dn=>{let bn=m.remote(dn);return!Jt.has(dn)&&dn.tagName===at.tagName&&!W(dn)&&!(pt&&bn&&pt!==bn)&&l.similar(at,dn)});Rt.length===1&&(Nt=Rt[0])}Nt&&(Jt.set(Nt,at),Jt.set(at,Nt))}}let Kn=xe=>{if(ot?.consumes(xe))return null;if(te.has(xe)||qe?.has(xe))return rt.get(xe)||null;let nt=le.twin(xe),et=ae.twin(xe),_t=nt&&!le.asBase&&!le.here(nt),Ht=et&&!ae.asBase&&!ae.here(et);if(_t||Ht){if((!nt||!et)&&Ue({kind:"structure",el:null,detail:"move-beats-delete",base:xe},{subject:xe,deleted:nt?"remote":"local"}),!Oe(xe))return bt(xe)?(qe||=Fr(Ee,Be,F,$,ge,J,o,r.remoteWins,w,Ue,D,S,v),_t&&qe.plan(xe,"local",nt),Ht&&qe.plan(xe,"remote",et)):te.add(xe),null;Ue({kind:"structure",el:null,detail:"both-moved",base:xe},{subject:xe})}if(nt&&!et&&!le.asBase&&!ae.asBase&&bt(xe)&&Pn.has(xe.tagName)&&!r.remoteWins(xe)&&!r.remoteWins(nt)&&D(xe,nt,F)&&dd(xe,oe(ae.el),o)){let Rt={ignored:o,remoteWins:r.remoteWins,inlineCache:Se},dn=bn=>bt(bn)?Vn(bn,Rt):bn.kind==="text";if(i(xe).every(dn)&&i(nt).every(dn)){let bn=br({base:[xe],local:[nt],remote:[],blocks:new Set([xe,nt]),out:re,policy:tt,L:F,R:$,idOf:{base:d,local:p,remote:y},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(wn,Nn,qn)=>J(wn,Nn,qn,!1),cloneUnit:G,mergeAttrs:ee,atomKey:l.exactUnitKey,moveIn:Ae,moveBuilt:Ae,movePlanned:Ae,provenance:Ee,textMappers:Ge,conflicts:w,conflict:Ue,scope:{base:E,local:le.el,remote:ae.el,units:$e,at:He.get(xe)},decisions:_e,node:de});ne.push(...bn.segments),te.add(xe),te.add(nt);let On=re.createDocumentFragment();for(let wn of bn.nodes)On.appendChild(wn);return rt.set(xe,On),rt.set(nt,On),On}}if(!nt&&!et)return te.add(xe),ce({kind:"remove",source:"both",base:xe}),null;if(!nt&&!D(xe,et,$))return te.add(xe),Q({kind:"remove",source:"local",base:xe}),null;if(!et&&!D(xe,nt,F))return te.add(xe),ce({kind:"remove",source:"remote",base:xe}),null;let at=!nt||!et,Nt=le.asBase?ge(F,xe)||null:nt,Ut=ae.asBase&&bt(xe)&&($.identityPaired.has(xe)||!m.base(xe))&&ge($,xe)||et,pt;return bt(xe)?pt=J(xe,Nt,Ut,le.asBase):xe.kind==="comment"?pt=De(xe,Nt,et,le.asBase):pt=Ve(xe,Nt,et,le.asBase),te.add(xe),pt&&(rt.set(xe,pt),nt&&rt.set(nt,pt),et&&rt.set(et,pt),at&&(Ue({kind:"structure",el:pt,detail:"edit-beats-delete",base:xe},{subject:xe,deleted:nt?"remote":"local"}),nt?Q({kind:"insert",el:pt,source:"local"}):ce({kind:"insert",el:pt,source:"remote"}))),pt},Bn=(xe,nt,et,_t)=>{if(ot?.consumes(xe))return null;if(te.has(xe))return rt.get(xe)||null;let Ht=nt.baseOf(xe);if(Ht&&Je.has(Ht))return Et.has(Ht)&&!Et.has(xe)?qo(Ht,xe,_t):Kn(Ht);if(Ht)return Gn(Ht,xe,_t);let at=Jt.get(xe);if(at){let Ut=_t==="local"?xe:at,pt=_t==="local"?at:xe,Rt;return bt(Ut)?l.equalUnits(Ut,pt)?(Rt=G(Ut,"local"),Rt&&(Ee.get(Rt).remote=pt)):Rt=B(Ut,pt):Rt=ke(Ut,pt),te.add(Ut),te.add(pt),Rt&&(rt.set(Ut,Rt),rt.set(pt,Rt),bt(Ut)&&Q({kind:"insert",el:Rt,source:"both"})),Rt}let Nt=G(xe,_t);return Nt&&(rt.set(xe,Nt),_t==="local"?Q({kind:"insert",el:Nt,source:"local"}):ce({kind:"insert",el:Nt,source:"remote"})),Nt},qo=(xe,nt,et)=>{let _t;return bt(xe)?(_t=Ae(xe,et,nt),_t&&te.add(nt)):(_t=G(nt,et),te.add(nt),_t&&(et==="local"?Q:ce)({kind:"insert",el:_t,source:et})),_t&&rt.set(nt,_t),_t},Gn=(xe,nt,et)=>{Ae(xe,null,null);let Ht=ge(et==="local"?$:F,xe),at=nt,Nt=Ht?Ze(Ht,et==="local"?Z:z,et==="local"?$:F):!1,Ut=Ht&&!Nt&&!st(xe,Ht);if(Ut&&et===Wt.otherSide)return Ue({kind:"structure",el:null,detail:"both-moved",base:xe},{subject:xe}),null;if(Ut&&Ue({kind:"structure",el:null,detail:"both-moved",base:xe},{subject:xe}),Ht||Ue({kind:"structure",el:null,detail:"move-beats-delete",base:xe},{subject:xe,deleted:et==="local"?"remote":"local"}),ze.has(xe)){Ue({kind:"structure",el:null,detail:"both-moved",base:xe},{subject:xe});let Rt=G(at,et);return Rt&&rt.set(nt,Rt),Rt}bt(xe)&&(qe||=Fr(Ee,Be,F,$,ge,J,o,r.remoteWins,w,Ue,D,S,v),qe.plan(xe,et,at,!0));let pt=bt(xe)?J(xe,et==="local"?at:ge(F,xe)||null,et==="remote"?at:ge($,xe)||null,!1):null;return pt&&(rt.set(xe,pt),rt.set(nt,pt),Ht&&rt.set(Ht,pt),et==="local"?Q({kind:"move",el:pt,source:"local"}):ce({kind:"move",el:pt,source:"remote"})),pt};for(let xe of Wt.V.units){if(Et.has(xe)){if(Pt?.has(xe)){for(let _t of Pt.get(xe))Qe.has(_t)||(Xe.push(_t),Qe.add(_t));continue}let et=rt.get(xe);Qe.has(et)||(Xe.push(et),Qe.add(et));continue}if(te.has(xe)&&!(rt.get(xe)&&Qe.has(rt.get(xe)))){let et=Wt.V.baseOf(xe);et&&!Je.has(et)&&Ue({kind:"structure",el:null,detail:"both-moved",base:et},{subject:et});continue}let nt=Bn(xe,Wt.V,Wt.A,Wt.side);nt&&!Qe.has(nt)&&(Xe.push(nt),Qe.add(nt),!Wt.V.baseOf(xe)&&!Jt.has(xe)&&!Et.has(xe)&&jt.add(nt))}for(let xe of en)Qe.has(xe.frag)||(Xe.splice(xe.previous&&Qe.has(xe.previous)?Xe.indexOf(xe.previous)+1:ao(xe.at),0,xe.frag),Qe.add(xe.frag));if(!Wt.other.asBase){let xe=Wt.other,nt=Wt.otherSide,et=Wt.otherA,_t=null,Ht=0,at=null;for(let Nt of xe.units){let Ut=rt.get(Nt);if(Ut&&Qe.has(Ut)){_t=Ut,at=null;continue}if(te.has(Nt)){let dn=xe.baseOf(Nt);dn&&!Je.has(dn)&&Ue({kind:"structure",el:null,detail:"both-moved",base:dn},{subject:dn});continue}let pt=Bn(Nt,xe,et,nt);if(!pt)continue;let Rt;if(at)Rt=Xe.indexOf(at)+1;else if(_t){if(Rt=Xe.indexOf(_t)+1,nt==="remote")for(;Rt<Xe.length&&jt.has(Xe[Rt]);)Rt++}else Rt=Ht++;Xe.splice(Rt,0,pt),Qe.add(pt),at=pt}}for(let xe=0;xe<$e.length;xe++){let nt=$e[xe];if(te.has(nt))continue;let et=Kn(nt);et&&Xe.splice(ao(xe),0,et)}return Xe;function ao(xe){for(let nt=xe-1;nt>=0;nt--){let et=rt.get($e[nt]);if(et){let _t=Xe.indexOf(et);if(_t>=0)return _t+1}}return 0}function $s(){if((le.asBase||F.identical.has(E))&&(ae.asBase||$.identical.has(E)))return;let xe={ignored:o,remoteWins:r.remoteWins,inlineCache:Se},nt=ft=>bt(ft)?Vn(ft,xe):ft.kind==="text";if(!le.asBase&&!ae.asBase)for(let ft of $e){if(!bt(ft)||!Pn.has(ft.tagName))continue;let lt=le.twin(ft),qt=ae.twin(ft);if(!lt&&qt||lt&&!qt){let ct=pa({base:$e,views:[{V:le,A:F,idOf:m.local},{V:ae,A:$,idOf:m.remote}],eligible:Dt=>bt(Dt)&&Pn.has(Dt.tagName)&&!o(Dt)&&!r.remoteWins(Dt),baseId:m.base,ignored:o,remoteWins:r.remoteWins,atomKey:l.exactUnitKey});ct&&(le=ct[0],ae=ct[1]);break}}let et=!le.asBase&&!ae.asBase&&$e.length>=2&&Pn.has($e[0].tagName)&&le.units.length===$e.length&&ae.units.length===$e.length?Gl({base:$e,local:le.units,remote:ae.units,localTwin:le.twin,remoteTwin:ae.twin,eligible:ft=>bt(ft)&&Pn.has(ft.tagName)&&!o(ft)&&!r.remoteWins(ft),nodes:{base:Array.from(oe(E).childNodes),local:Array.from(oe(le.el).childNodes),remote:Array.from(oe(ae.el).childNodes)}}):null,_t=null,Ht=null;if(!et&&!le.asBase&&!ae.asBase&&(ki($e)||ki(le.units)||ki(ae.units))){let ft={ignored:o,remoteWins:()=>!1},lt=ct=>nt(ct)||bt(ct)&&r.remoteWins(ct)&&En.has(ct.tagName)&&Vn(ct,ft),qt=ct=>bt(ct)?Pn.has(ct.tagName)&&!o(ct)&&!r.remoteWins(ct)&&i(ct).every(lt):ct.kind==="text";_t=ga({onUncertainOwner:ct=>{let Dt=r.identity.local(ct.local);Dt&&Dt===r.identity.remote(ct.remote)||(Ht||=[]).push(ct)},onUncertainSource:ct=>{it||(it=new Map);let Dt=it.get(ct.source);Dt||it.set(ct.source,Dt=[]);for(let Zt of Dt)if(Zt.side===ct.side&&Zt.from===ct.from&&Zt.to===ct.to)return;Dt.push(ct)},base:$e,views:[{V:le,A:F,idOf:m.local},{V:ae,A:$,idOf:m.remote}],eligible:qt,ignored:o,remoteWins:r.remoteWins,baseId:m.base,atomKey:l.exactUnitKey})}if(Ht){Pt||=new Map;for(let ft of Ht){let{source:lt,local:qt,remote:ct}=ft,Dt={map:new Map,reverse:new Map,identical:new Set},Zt=br({base:[lt],local:[qt],remote:[ct],out:re,policy:"both",L:Dt,R:Dt,ignored:o,remoteWins:r.remoteWins,atomKey:l.exactUnitKey,cloneUnit:G,provenance:Ee,textMappers:Ge,conflicts:w,decisions:_e,conflict:(Bt,sn)=>Ue(Bt,{...sn,policy:"both"}),scope:{base:E,local:le.el,remote:ae.el,units:$e,at:He.get(lt)},node:de});ne.push(...Zt.segments);for(let Bt of[lt,qt,ct])te.add(Bt),Et.add(Bt),Pt.set(Bt,Zt.nodes),rt.set(Bt,Zt.nodes[Zt.nodes.length-1]);for(let Bt=0;Bt<Zt.nodes.length;Bt++)en.push({frag:Zt.nodes[Bt],at:He.get(lt),previous:Bt?Zt.nodes[Bt-1]:null})}}let at=et?et.blocks:null;if(_t){at=new Set;for(let ft of _t.blocks)at.add(ft)}let Nt=ft=>!ot?.consumes(ft)&&(at&&at.has(ft)||nt(ft)),Ut=$e.map(Nt);if(!Ut.includes(!0))return;let pt=ft=>{let lt=ft.units,qt=new Map;for(let Kt=0;Kt<lt.length;Kt++)qt.set(lt[Kt],Kt);let ct=[],Dt=-1;for(let Kt=0;Kt<$e.length;Kt++){if(Ut[Kt])continue;let It=ft.twin($e[Kt]),Ot=It?qt.get(It):void 0;Ot===void 0||Ot<=Dt||Nt(It)||(ct.push([Kt,Ot]),Dt=Ot)}let Zt=[],Bt=-1,sn=-1;for(let Kt=0;Kt<=ct.length;Kt++){let[It,Ot]=Kt<ct.length?ct[Kt]:[$e.length,lt.length],zt={bLo:-1,bHi:-1,from:sn+1,to:Ot,inlineStart:-1,inlineEnd:-1,next:Ot};for(let tn=Bt+1;tn<It;tn++)Ut[tn]&&(zt.bLo<0&&(zt.bLo=tn),zt.bHi=tn);for(let tn=sn+1;tn<Ot;tn++){let er=lt[tn];Nt(er)&&(zt.inlineStart<0&&(zt.inlineStart=tn),zt.inlineEnd=tn+1)}Zt.push(zt),Bt=It,sn=Ot}return{units:lt,list:Zt}},Rt=pt(le),dn=pt(ae),bn=[];for(let ft of[Rt,dn])for(let lt of ft.list)lt.bLo>=0&&bn.push([lt.bLo,lt.bHi]);bn.sort((ft,lt)=>ft[0]-lt[0]);let On=[];for(let[ft,lt]of bn){let qt=On[On.length-1];qt&&ft<=qt.hi?qt.hi=Math.max(qt.hi,lt):On.push({lo:ft,hi:lt})}let wn=(ft,lt)=>ft.length===lt.length&&ft.every((qt,ct)=>l.equalUnits(qt,lt[ct])),Nn=ft=>!bt(ft)&&ft.kind==="comment",qn=ft=>{if(!ft.length)return[];let lt=(Bt,sn)=>bt(Bt)?Bt:Bt.nodes[sn?Bt.nodes.length-1:0],qt=lt(ft[0]),ct=lt(ft[ft.length-1],!0),Dt=Bt=>Bt&&bt(Bt)&&o(Bt);for(;Dt(qt.previousSibling);)qt=qt.previousSibling;for(;Dt(ct.nextSibling);)ct=ct.nextSibling;let Zt=[];for(let Bt=qt;Bt&&(Zt.push(Bt),Bt!==ct);Bt=Bt.nextSibling);return Zt},Uo=ft=>ft.some(lt=>bt(lt)&&o(lt));for(let ft of On){let lt=$e.slice(ft.lo,ft.hi+1),qt=null;if(_t)for(let It of lt){let Ot=_t.certificatesBySource.get(It);Ot&&(qt||=[]).push(...Ot)}let ct=le.asBase?null:bi(Rt,ft),Dt=ae.asBase?null:bi(dn,ft);if(qt){let It=[new Set(ct||lt),new Set(Dt||lt)],Ot=qt.some(zt=>!It[zt.side].has(zt.target));for(let zt of lt)if(at.has(zt))for(let[tn,er]of[[0,le],[1,ae]]){let tr=er.twin(zt);tr&&er.here(tr)&&!It[tn].has(tr)&&(Ot=!0)}if(Ot)continue}if(lt.some(Nn)||ct&&ct.some(Nn)||Dt&&Dt.some(Nn))continue;let Zt=qn(ct||lt),Bt=qn(Dt||lt);if((!ct||wn(lt,ct))&&(!Dt||wn(lt,Dt))&&!(ct&&Uo(Zt)))continue;let sn=br({base:qn(lt),sourceRetentions:it?.get(E),local:Zt,remote:Bt,out:re,policy:tt,blocks:at,scopeUnits:qt?[lt,ct||lt,Dt||lt]:null,certifiedOrigins:qt?(It,Ot,zt,tn,er,tr)=>ba({certificates:qt,scopes:[lt,ct||lt,Dt||lt],flats:[It,Ot,zt],keys:[tn,er,tr]}):null,prepared:et?et.prepared:null,nativeTransfers:et,L:ct?F:ka(F,E),R:Dt?$:ka($,E),idOf:{base:d,local:p,remote:y},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(It,Ot,zt)=>J(It,Ot,zt,!1),cloneUnit:G,mergeAttrs:ee,atomKey:l.exactUnitKey,moveIn:Ae,moveBuilt:Ae,movePlanned:Ae,provenance:Ee,textMappers:Ge,conflicts:w,conflict:Ue,scope:{base:E,local:le.asBase?null:le.el,remote:ae.asBase?null:ae.el,units:$e,at:ft.lo},decisions:_e,node:de});if(!sn){if(qt){let It=Yl({certificates:qt,scopes:[lt,ct||lt,Dt||lt],views:[{V:le,A:F,idOf:m.local},{V:ae,A:$,idOf:m.remote}],eligible:Ot=>bt(Ot)&&Pn.has(Ot.tagName)&&!o(Ot)&&!r.remoteWins(Ot),baseId:m.base});for(let Ot of It.records){it||=new Map;let zt=it.get(Ot.source);zt||it.set(Ot.source,zt=[]),zt.push(Ot)}}continue}if(ne.push(...sn.segments),et){let It=new Map;for(let Ot of sn.nodes){let zt=Ee.get(Ot)?.base;if(!zt||It.has(zt))throw new Error("Invalid native transfer owner output");It.set(zt,Ot)}if(It.size!==et.owners.length)throw new Error("Incomplete native transfer owner output");for(let Ot of et.owners){let zt=It.get(Ot.base);if(!zt)throw new Error("Missing native transfer owner output");for(let tn of[Ot.base,Ot.local,Ot.remote])te.add(tn),Et.add(tn),rt.set(tn,zt);en.push({frag:zt,at:He.get(Ot.base)})}continue}if(sn.unitOutputs){Pt||=new Map;for(let It of[...lt,...ct||[],...Dt||[]]){let Ot=sn.unitOutputs.get(It)||[];te.add(It),Et.add(It),Pt.set(It,Ot),Ot.length&&rt.set(It,Ot[Ot.length-1])}for(let It=0;It<sn.nodes.length;It++)en.push({frag:sn.nodes[It],at:ft.lo,previous:It>0?sn.nodes[It-1]:null});continue}let Kt=re.createDocumentFragment();for(let It of sn.nodes)Kt.appendChild(It);for(let It of[...lt,...ct||[],...Dt||[]])te.add(It),Et.add(It),rt.set(It,Kt);en.push({frag:Kt,at:ft.lo})}}}function be(E,z){let Z=Ee.get(E);return Z&&Z.unchanged?!Z.remote||Z.remote===z?!0:fe(Z.remote,z):E.tagName!==z.tagName||!K(E,z)?!1:ue(oe(E),oe(z))}function fe(E,z){return E===z?!0:E.tagName!==z.tagName||E.namespaceURI!==z.namespaceURI||!K(E,z)?!1:we(oe(E),oe(z))}function we(E,z){let Z=Le(E,o),ye=Le(z,o);if(Z.length!==ye.length)return!1;for(let de=0;de<Z.length;de++){let le=Z[de],ae=ye[de];if(typeof le=="string"||typeof ae=="string"){if(le!==ae)return!1}else{if(le.nodeType!==ae.nodeType)return!1;if(le.nodeType===1){if(!fe(le,ae))return!1}else if(le.nodeValue!==ae.nodeValue)return!1}}return!0}function oe(E){return E.tagName==="TEMPLATE"&&E.content?E.content:E}function K(E,z){let Z=0;for(let ye of E.attributes)if(!r.ignoreAttribute(E,ye.name)&&(Z++,z.getAttribute(ye.name)!==ye.value))return!1;for(let ye of z.attributes)r.ignoreAttribute(z,ye.name)||Z--;return Z===0}function ue(E,z){let Z=Le(E,de=>{let le=Ee.get(de);return!!(le&&le.pinned)}),ye=Le(z,o);if(Z.length!==ye.length)return!1;for(let de=0;de<Z.length;de++){let le=Z[de],ae=ye[de];if(typeof le=="string"||typeof ae=="string"){if(le!==ae)return!1}else{if(le.nodeType!==ae.nodeType)return!1;if(le.nodeType===1){if(!be(le,ae))return!1}else if(le.nodeValue!==ae.nodeValue)return!1}}return!0}function Le(E,z){let Z=[],ye=null;for(let de=E.firstChild;de;de=de.nextSibling){if(de.nodeType===3){ye=ye===null?de.nodeValue:ye+de.nodeValue;continue}de.nodeType===1&&z(de)||(ye!==null&&(ye!==""&&Z.push(ye),ye=null),Z.push(de))}return ye!==null&&ye!==""&&Z.push(ye),Z}function De(E,z,Z,ye){let de=E.value,le=ye?de:z?z.value:"",ae=Z?Z.value:"";te.add(E),z&&te.add(z),Z&&te.add(Z);let $e=le===ae?le:le===de?ae:ae===de||tt==="local"?le:ae,Je={site:"comment",bRun:E,lRun:z,rRun:Z,node:null};if(le!==de&&ae!==de&&le!==ae&&Ue({kind:"text",node:null,base:de,local:le,remote:ae,resolved:$e},Je),!z&&!Z)return null;let He=re.createComment($e);return Je.node=He,Ee.set(He,{base:E.nodes,local:z?z.nodes:null,remote:Z?Z.nodes:null}),He}function We(E,z){let Z=ge(z,E);if(!Z)return null;let ye=bt(Z)?Z.parentNode:Z.parent,de=bt(E)?E.parentNode:E.parent;return ge(z,de)===ye?null:z.reverse.get(ye)||null}function Oe(E){let z=new Set([E]),Z=E;for(let ye=0;ye<64;ye++){let de=We(Z,F)||We(Z,$);if(!de)return!1;if(de===E||bt(E)&&bt(de)&&E.contains(de)||z.has(de))return!0;z.add(de),Z=de}return!0}function Ze(E,z,Z){if(!z)return!1;let ye=bt(E)?E.parentNode:E.parent;return ye===z||z.tagName==="TEMPLATE"&&ye===z.content}function st(E,z){let Z=Be(E),ye=ge(F,Z);if(ye&&Ze(z,ye,F))return!0;let de=ge($,Z);return!!(de&&Ze(z,de,$))}}function ka(e,t){return e.map.get(t)?ya():{map:{get:r=>r&&r.nodeType===1&&e.map.get(r)||r,has:()=>!0},reverse:{get:r=>e.reverse.get(r)||r,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function ya(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var xa=new Set(["INPUT","OPTION","TEXTAREA"]),xi=/[\t\n\f\r ]+/;function va(e,t,n,r){let o=e.ownerDocument,{provenance:s,textMappers:l}=n,i=r.hooks,a=[],c=[],h=[],u=new Set,f=[],d=[],p=new Map,y=new Set,m=new Map,g=n.conflicts.length>0,k=new Map,S=new Set,v=new Map,x=(H,ie)=>{let pe=v.get(H);pe||v.set(H,pe=new Set),pe.add(ie)},O=g?new Set:null,C=(H,ie,pe)=>{let ge=i.beforeAttributeUpdated(H,ie,pe);return g&&ge===!1&&x(ie,H),ge},_=H=>!!H&&(H===e||e.contains(H)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(H)),M=new Map,j=new Map,I=new Map,P=new Set,R=new Map;(function H(ie){let pe=s.get(ie);if(pe){if(ie.nodeType===1){let Ae=pe.local?r.toLive(pe.local):null;Ae&&_(Ae)&&Ae.nodeType===1&&(M.set(ie,Ae),j.set(Ae,ie))}else if(Array.isArray(pe.local)){let Ae=$(pe.local,pe.local.map(N=>r.toLive(N)).filter(N=>N&&_(N)&&N.nodeType===ie.nodeType));if(Ae.length&&(M.set(ie,Ae[0]),j.set(Ae[0],ie),I.set(ie,Ae)),Array.isArray(pe.caret))for(let N of pe.caret){let D=r.toLive(N.node);if(!D||!_(D)||D.nodeType!==3)continue;let Y=R.get(D);Array.isArray(Y)||R.set(D,Y=[]),Y.push({merged:ie,from:N.from,to:N.to,flatStart:N.flatStart})}else{let N=0;for(let D of Ae)R.set(D,{merged:ie,shift:N}),N+=D.nodeValue.length}}}let ge=ie.nodeType===1&&ie.tagName==="TEMPLATE"&&ie.content?ie.content.childNodes:ie.childNodes;for(let Ae of ge)H(Ae)})(t);let T=new Set;for(let H of M.values())T.add(H);for(let H of I.values())for(let ie of H)T.add(ie);let A=r.localRoot&&r.localRoot!==e?new Set:null;if(A){for(let H=r.localRoot.firstElementChild;H;H=H.nextElementSibling)if(H.tagName==="HEAD")for(let ie=H.firstElementChild;ie;ie=ie.nextElementSibling){let pe=r.toLive(ie);pe&&A.add(pe)}}for(let H of n.segments||[])Ne(H);let W=r.restoreFocus===!1?null:hd(o,R);r.childrenOnly?Ee(Ce(e),Ce(t)):Be(e,t);for(let{node:H,parent:ie}of f)u.has(H)||!H.parentNode||H.nodeType===1&&(r.ignored(H)||Ge(H))||it(H,ie);return md(o,W,R,l,I,m,P),{applied:a,moved:c,replaced:h,identities:d,mergedScriptsLive:y,liveOf:M,heldBy:m,runOf:I,keptRuns:P,insertedLive:k,vetoed:S,vetoedAttrs:v,removedVetoes:O};function F(H,ie){let pe=H.slice(ie.bs,ie.be),ge=0;for(;ge<pe.length&&ge<ie.text.length&&pe[ge]===ie.text[ge];)ge++;let Ae=0;for(;Ae<pe.length-ge&&Ae<ie.text.length-ge&&pe[pe.length-1-Ae]===ie.text[ie.text.length-1-Ae];)Ae++;return{bs:ie.bs+ge,be:ie.be-Ae,text:ie.text.slice(ge,ie.text.length-Ae)}}function $(H,ie){if(!ie.length)return ie;let pe=[];for(let N of H){let D=N.parentNode;if(!D)continue;let Y=p.get(D);if(!Y){Y=new Set;for(let J=D.firstChild;J;J=J.nextSibling)J.nodeType===3&&Y.add(r.toLive(J));p.set(D,Y)}pe.includes(Y)||pe.push(Y)}let ge={has:N=>pe.some(D=>D.has(N))},Ae=[];for(let N of ie){Ae.push(N);for(let D=N.nextSibling;D&&D.nodeType===3&&!ge.has(D)&&!Ae.includes(D);D=D.nextSibling)Ae.push(D)}return Ae}function Ne(H){let ie=[];for(let ke of H.localNodes){let B=r.toLive(ke.node);if(!B||!_(B)||B.nodeType!==3)return;ie.push(B)}let pe=$(H.localNodes.map(ke=>ke.node),ie);if(!pe.length)return;let ge=pe.map(ke=>ke.nodeValue).join(""),{flatLocal:Ae,lToM:N,mapLocal:D}=H;if(ge===Ae)return;let Y=H.textNodes.map(ke=>({node:ke.node,ms:ke.ms,me:ke.me})),J=[],se=0;for(let ke of pe)J.push(se),se+=ke.nodeValue.length;let Fe=(ke,B)=>pe.find((G,he)=>J[he]<=ke&&ke+B<=J[he]+G.nodeValue.length)||null,ee=[],Me=0;for(let ke of gr(Ae,ge).map(B=>F(Ae,B))){let B=ke.bs+Me;Me+=ke.text.length-(ke.be-ke.bs);let G,he;if(ke.be>ke.bs){G=N[ke.bs];let be=G>=0;for(let fe=ke.bs;be&&fe<ke.be;fe++)N[fe]!==G+(fe-ke.bs)&&(be=!1);if(!be)continue;he=G+(ke.be-ke.bs)}else{let be=ke.bs>0?N[ke.bs-1]:0,fe=ke.bs<Ae.length?N[ke.bs]:0;if(be<0||fe<0)continue;G=he=D(ke.bs)}ee.push({ms:G,me:he,text:ke.text,live:he===G?Fe(B,ke.text.length):null})}ee.sort((ke,B)=>B.ms-ke.ms);let Ve=(ke,B)=>(I.get(ke.node)||[M.get(ke.node)]).includes(B),Ie=ke=>!!ke&&ke.nodeType===1&&En.has(ke.tagName);for(let ke of ee){let B=Y.find(he=>he.ms<=ke.ms&&ke.me<=he.me&&ke.ms<he.me);if(B&&ke.live&&B.ms===ke.ms&&!Ve(B,ke.live)){let he=Y.find(be=>be.me===ke.ms&&Ve(be,ke.live));he&&(B=he)}if(!B&&ke.me===ke.ms){let he=Y.find(oe=>oe.me===ke.ms),be=Y.find(oe=>oe.ms===ke.ms),fe=he||be;if(!fe)continue;let we=fe.node;for(;Ie(we.parentNode)&&(he?we.parentNode.lastChild:we.parentNode.firstChild)===we;)we=we.parentNode;if(we===fe.node)B=fe;else{let oe=we.ownerDocument.createTextNode(ke.text);we.parentNode.insertBefore(oe,he?we.nextSibling:we);continue}}if(!B)continue;let G=B.node.nodeValue;B.node.nodeValue=G.slice(0,ke.ms-B.ms)+ke.text+G.slice(ke.me-B.ms),B.me+=ke.text.length-(ke.me-ke.ms)}}function Ce(H){return H.nodeType===1&&H.tagName==="TEMPLATE"&&H.content?H.content:H}function Be(H,ie){u.add(H);let pe=s.get(ie);if(pe&&pe.remote&&n.remoteIdOf){let Ae=n.remoteIdOf(pe.remote);Ae&&d.push([H,Ae])}if(pe&&pe.unchanged){n.customIdentity&&pe.remote&&ne(H,pe.remote),pe.remote&&V(H,pe.remote);return}if(i.beforeNodeMorphed(H,ie)===!1){S.add(ie);return}qe(H,ie,r.keepLiveOnly&&pe&&pe.local&&pe.local.nodeType===1&&pe.local!==H?pe.local:null);let ge=H.tagName;if(yn(H))H.textContent!==ie.textContent&&(a.push({kind:"text",node:H,before:H.textContent,after:ie.textContent}),H.textContent=ie.textContent),n.mergedScripts.has(ie)&&y.add(H);else if(ge==="TEXTAREA")ht(H,ie,pe);else{dt(H,ie,pe);let Ae=ge==="TEMPLATE"&&H.content?H.content:H,N=ge==="TEMPLATE"&&ie.content?ie.content:ie;r.protectFocusedValue==="subtree"&&xt(H)&&H!==o.body?re(Ae):Ee(Ae,N)}i.afterNodeMorphed(H,ie)}function re(H){for(let ie=H.firstChild;ie;ie=ie.nextSibling){let pe=j.get(ie);pe&&M.get(pe.parentNode)!==H||(u.add(ie),ie.nodeType===1&&re(ie))}}function Ee(H,ie){let pe=ze(H.firstChild),ge=new Set;for(let Ae of Array.from(ie.childNodes)){let N=M.get(Ae);N&&u.has(N)&&!ge.has(N)&&(N=null);let D=s.get(Ae);if(D&&D.pinned){N&&N.nodeType===1&&((N.parentNode!==H||ze(N.nextSibling)!==pe)&&Se(H,N,pe),u.add(N),ge.add(N));continue}if(N&&N.nodeType===1){if(N!==pe){let se=N.parentNode;if(se===H&&pe&&kt(N)){let Fe=N.nextSibling;for(let ee=pe;ee&&ee!==N;){let Me=ee.nextSibling;Se(H,ee,Fe),ee=Me}}else Se(H,N,pe),se!==H&&(c.push(N),a.push({kind:"move",el:N,from:se,to:H}))}ge.add(N),Be(N,Ae),pe=ze(N.nextSibling);continue}if(N&&N.nodeType!==1){let se=I.get(Ae)||[N],Fe=se.map(Me=>Me.nodeValue).join(""),ee=Ae.nodeValue;if(Ae.nodeType===3){let Me=_e(Ae);Me!=null&&Fe!==Me&&(ee=uo(Me,Fe,Ae.nodeValue).text)}if(se.length>1&&Fe===ee&&!se.includes(pe,1)&&se.every((Me,Ve)=>Me.parentNode===H&&(Ve===0||se[Ve-1].nextSibling===Me))){if(N!==pe)for(let Me of se)Se(H,Me,pe);i.beforeNodeMorphed(N,Ae)!==!1?i.afterNodeMorphed(N,Ae):g&&S.add(Ae);for(let Me of se)u.add(Me),ge.add(Me);m.set(Ae,N),P.add(Ae),pe=ze(se[se.length-1].nextSibling);continue}N!==pe&&Se(H,N,pe),i.beforeNodeMorphed(N,Ae)!==!1?(N.nodeValue!==ee&&(a.push({kind:"text",node:N,before:N.nodeValue,after:ee}),N.nodeValue=ee),i.afterNodeMorphed(N,Ae)):S.add(Ae),u.add(N),ge.add(N),m.set(Ae,N),pe=ze(N.nextSibling);continue}if(Ae.nodeType===3&&pe&&pe.nodeType===3&&!u.has(pe)&&!R.has(pe)){pe.nodeValue!==Ae.nodeValue&&(a.push({kind:"text",node:pe,before:pe.nodeValue,after:Ae.nodeValue}),pe.nodeValue=Ae.nodeValue),u.add(pe),m.set(Ae,pe),pe=ze(pe.nextSibling);continue}let Y=s.get(Ae),J=tt(Y&&Y.unchanged&&Y.remote?Y.remote:Ae);if(i.beforeNodeAdded(J)===!1){S.add(Ae);continue}H.insertBefore(J,pe),u.add(J),g&&k.set(Ae,J),J.nodeType===3&&m.set(Ae,J),J.nodeType===1&&(h.push(J),Pe(J,Ae),n.customIdentity&&Y&&Y.unchanged&&Y.remote&&ne(J,Y.remote),yn(J)||Q(J,Ae),r.formState==="property"&&Ct(Y)&&V(J,Y.remote)),pe=ze(J.nextSibling),a.push({kind:"insert",node:J,parent:H}),i.afterNodeAdded(J)}for(let Ae of Array.from(H.childNodes))u.has(Ae)||ge.has(Ae)||Ae.nodeType===1&&(r.ignored(Ae)||Ge(Ae))||(T.has(Ae)?f.push({node:Ae,parent:H}):it(Ae,H))}function Ge(H){return H.parentNode&&H.parentNode.nodeType===1&&H.parentNode.tagName==="HEAD"&&(A&&!A.has(H)||r.preserve&&r.preserve(H)===!0)}function _e(H){let ie=s.get(H);return!ie||!Array.isArray(ie.local)?null:ie.local.map(pe=>pe.nodeValue).join("")}function w(H){return s.get(H)}function V(H,ie){if(!xa.has(H.tagName)&&!H.querySelector("input,option,textarea"))return;let pe=(ge,Ae)=>{if(ge.tagName!==Ae.tagName)return;ge.tagName==="TEXTAREA"?ht(ge,Ae,{remote:Ae}):xa.has(ge.tagName)&&dt(ge,Ae,{remote:Ae});let N=te(ge),D=te(Ae);if(N.length===D.length)for(let Y=0;Y<N.length;Y++)pe(N[Y],D[Y])};pe(H,ie)}function ne(H,ie){let pe=te(H),ge=te(ie);if(pe.length===ge.length)for(let Ae=0;Ae<pe.length;Ae++){let N=n.remoteIdOf(ge[Ae]);N&&d.push([pe[Ae],N]),ne(pe[Ae],ge[Ae])}}function te(H){let ie=H.tagName==="TEMPLATE"&&H.content?H.content:H;return Array.from(ie.children).filter(pe=>!r.ignored(pe))}function Pe(H,ie){if(!n.remoteIdOf)return;let pe=(ge,Ae)=>{let N=s.get(Ae);if(N&&N.remote&&Ae.nodeType===1){let J=n.remoteIdOf(N.remote);J&&d.push([ge,J])}let D=ge.childNodes,Y=Ae.childNodes;for(let J=0;J<D.length&&J<Y.length;J++)pe(D[J],Y[J])};pe(H,ie)}function ze(H){for(;H&&H.nodeType===1&&r.ignored(H);)H=H.nextSibling;return H}function Se(H,ie,pe){if(typeof H.moveBefore=="function"&&ie.ownerDocument===H.ownerDocument)try{H.moveBefore(ie,pe);return}catch{}H.insertBefore(ie,pe)}function it(H,ie){if(i.beforeNodeRemoved(H)===!1){g&&O.add(H);return}H.parentNode.removeChild(H),a.push({kind:"remove",node:H,parent:ie}),i.afterNodeRemoved(H)}function tt(H){if(yn(H))return mo(H,o);let ie=o.importNode(H,!0);if(ie.nodeType===1)for(let pe of Array.from(ie.querySelectorAll("script")))yn(pe)&&pe.replaceWith(mo(pe,o));return ie}function Q(H,ie){let pe=H.tagName==="TEMPLATE"&&H.content?H.content:H,ge=ie.tagName==="TEMPLATE"&&ie.content?ie.content:ie,Ae=Array.from(pe.childNodes),N=Array.from(ge.childNodes);for(let D=0;D<N.length&&D<Ae.length;D++){let Y=N[D],J=Ae[D],se=M.get(Y);se&&u.has(se)&&(se=null);let Fe=s.get(Y);if(Fe&&Fe.pinned){if(se&&se.nodeType===1){let ee=se.parentNode;Se(pe,se,J),ee!==pe&&(c.push(se),a.push({kind:"move",el:se,from:ee,to:pe})),u.add(se)}J.remove();continue}if(se){let ee=se.parentNode;Se(pe,se,J),J.remove(),se.nodeType===1?(ee!==pe&&(c.push(se),a.push({kind:"move",el:se,from:ee,to:pe})),Be(se,Y)):(u.add(se),m.set(Y,se),se.nodeValue!==Y.nodeValue&&(a.push({kind:"text",node:se,before:se.nodeValue,after:Y.nodeValue}),se.nodeValue=Y.nodeValue));continue}u.add(J),g&&k.set(Y,J),J.nodeType===3&&m.set(Y,J),Fe&&Fe.unchanged&&Fe.remote?(ce(J,Fe.remote),n.customIdentity&&ne(J,Fe.remote)):Y.nodeType===1&&!yn(Y)&&Q(J,Y)}}function ce(H,ie){let pe=H.tagName==="TEMPLATE"&&H.content?H.content:H,ge=ie.tagName==="TEMPLATE"&&ie.content?ie.content:ie;for(let Ae of Array.from(ge.childNodes))pe.appendChild(tt(Ae))}function Re(H,ie){return ie.namespaceURI?H.getAttributeNS(ie.namespaceURI,ie.localName):H.getAttribute(ie.name)}function Ue(H,ie){let pe=new Set((ie||"").split(xi).filter(Boolean));return(H||"").split(xi).filter(ge=>ge&&!pe.has(ge))}function qe(H,ie,pe){for(let ge of Array.from(ie.attributes)){if(ot(H,ge.name)||r.ignoreAttribute(H,ge.name))continue;let Ae=Re(H,ge);if(Ae===ge.value||pe&&Re(pe,ge)===ge.value)continue;let N=ge.value;if(pe&&ge.name==="class"&&!ge.namespaceURI){let D=ge.value.split(xi).filter(Boolean),Y=Ue(Ae,pe.getAttribute("class")).filter(J=>!D.includes(J));Y.length&&(N=[...D,...Y].join(" "))}if(Ae!==N){if(i.beforeAttributeUpdated(ge.name,H,"update")===!1){g&&x(ie,ge.name);continue}ge.namespaceURI?H.setAttributeNS(ge.namespaceURI,ge.name,N):H.setAttribute(ge.name,N),a.push({kind:"attr",el:H,name:ge.name,before:Ae,after:N})}}for(let ge of Array.from(H.attributes)){if(ot(H,ge.name)||r.ignoreAttribute(H,ge.name)||(ge.namespaceURI?ie.hasAttributeNS(ge.namespaceURI,ge.localName):ie.hasAttribute(ge.name)))continue;if(pe&&ge.name==="class"&&!ge.namespaceURI){let D=Ue(ge.value,pe.getAttribute("class"));if(D.length){let Y=D.join(" ");if(Y===ge.value)continue;if(i.beforeAttributeUpdated("class",H,"update")===!1){g&&x(ie,"class");continue}H.setAttribute("class",Y),a.push({kind:"attr",el:H,name:"class",before:ge.value,after:Y});continue}}if(pe&&Re(pe,ge)===null)continue;if(i.beforeAttributeUpdated(ge.name,H,"remove")===!1){g&&x(ie,ge.name);continue}let N=ge.value;ge.namespaceURI?H.removeAttributeNS(ge.namespaceURI,ge.localName):H.removeAttribute(ge.name),a.push({kind:"attr",el:H,name:ge.name,before:N,after:null})}}function ot(H,ie){let pe=H.tagName;return pe==="INPUT"?ie==="value"||ie==="checked"||ie==="disabled":pe==="OPTION"?ie==="selected":!1}function xt(H){return H===o.activeElement}function kt(H){let ie=o.activeElement;return!!ie&&ie!==o.body&&H.contains(ie)}function Ct(H){let ie=H&&H.remote;return ie&&ie.nodeType===1?ie:null}function dt(H,ie,pe){let ge=H.tagName,Ae=Ct(pe),N=r.formState==="property"&&Ae?Ae:ie;if(ge==="INPUT"){let D=r.protectFocusedValue&&xt(H),Y=(H.getAttribute("type")||"").toLowerCase(),J=Y!=="file"&&Y!=="checkbox"&&Y!=="radio",se=Ae&&Ae.hasAttribute("value")&&Ae.value!==Ae.getAttribute("value")?Ae.value:null;if(J&&!D)if(r.formState==="property"){let Fe=ie.getAttribute("value"),ee=H.getAttribute("value");(ee!==Fe||H.value!==N.value)&&C("value",H,Fe==null?"remove":"update")!==!1&&(ee!==Fe&&(Fe==null?H.removeAttribute("value"):H.setAttribute("value",Fe),a.push({kind:"attr",el:H,name:"value",before:ee,after:Fe})),H.value!==N.value&&(H.value=N.value))}else if(ie.hasAttribute("value")||se!=null){let Fe=se??ie.getAttribute("value");H.getAttribute("value")!==Fe&&C("value",H,"update")!==!1?(H.setAttribute("value",Fe),H.value!==Fe&&(H.value=Fe),a.push({kind:"attr",el:H,name:"value",before:null,after:Fe})):H.value!==Fe&&H.getAttribute("value")===Fe&&(H.value=Fe)}else(H.hasAttribute("value")||H.value!=="")&&C("value",H,"remove")!==!1&&(H.removeAttribute("value"),H.value="",a.push({kind:"attr",el:H,name:"value",before:"",after:null}));if(!J&&Y!=="file"){let Fe=ie.getAttribute("value");Fe==null?H.hasAttribute("value")&&C("value",H,"remove")!==!1&&H.removeAttribute("value"):H.getAttribute("value")!==Fe&&C("value",H,"update")!==!1&&H.setAttribute("value",Fe)}D||(St(H,N,"checked"),r.formState==="property"&&H.indeterminate!==N.indeterminate&&(H.indeterminate=N.indeterminate)),St(H,N,"disabled")}else if(ge==="OPTION"){let D=H.parentNode&&H.closest("select");r.protectFocusedValue&&D&&xt(D)||St(H,N,"selected")}}function St(H,ie,pe){let ge=r.formState==="property"?!!ie[pe]:ie.hasAttribute(pe);if(r.formState!=="property"){let Ae=H.hasAttribute(pe);if(Ae!==ge){if(C(pe,H,ge?"update":"remove")===!1)return;ge?H.setAttribute(pe,""):H.removeAttribute(pe),a.push({kind:"attr",el:H,name:pe,before:Ae?"":null,after:ge?"":null})}}H[pe]!==ge&&(H[pe]=ge)}function ht(H,ie,pe){if(r.protectFocusedValue&&xt(H)||C("value",H,"update")===!1)return;let ge=Ct(pe),Ae=ie.textContent,N=ge&&ge.value!==ge.defaultValue?ge.value:Ae;r.formState!=="property"&&H.textContent!==Ae&&(a.push({kind:"text",node:H,before:H.textContent,after:Ae}),H.textContent=Ae),H.value!==N&&(H.value=N)}}function hd(e,t){let n=e.activeElement;if(!n||n===e.body||n===e.documentElement)return null;let r={el:n,id:n.getAttribute&&n.getAttribute("id"),scrollTop:n.scrollTop,scrollLeft:n.scrollLeft};if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"){try{r.selection=[n.selectionStart,n.selectionEnd,n.selectionDirection]}catch{}return r}let o=e.getSelection&&e.getSelection();if(o&&o.rangeCount){let s=o.getRangeAt(0);r.range={sc:s.startContainer,so:s.startOffset,ec:s.endContainer,eo:s.endOffset}}return r}function md(e,t,n,r,o,s,l){if(!t)return;let i=t.el;if(!i.isConnected&&t.id&&(i=e.getElementById(t.id)),!i||!i.isConnected)return;if(e.activeElement!==i)try{i.focus({preventScroll:!0})}catch{}try{i.scrollTop=t.scrollTop,i.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{i.setSelectionRange&&!i.selectionEnd&&t.selection[1]!=null&&i.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let a=(u,f)=>{let d=n.get(u);if(Array.isArray(d)){let p=d.find(k=>f>=k.from&&f<k.to)||d.find(k=>f===k.to)||d[d.length-1],y=s.get(p.merged);if(!y||!y.isConnected)return null;let m=r.get(p.merged),g=m&&m.flat?m.flat(p.flatStart+f):f;return[y,Math.max(0,Math.min(g,y.nodeValue.length))]}if(d&&!l.has(d.merged)){let p=(o.get(d.merged)||[u])[0];if(!p.isConnected)return null;let y=r.get(d.merged),m=d.shift+f,g=y?y(m):m;return[p,Math.max(0,Math.min(g,p.nodeValue.length))]}return u.isConnected?[u,Math.min(f,u.nodeType===3?u.nodeValue.length:u.childNodes.length)]:null},c=a(t.range.sc,t.range.so),h=a(t.range.ec,t.range.eo);if(!(!c||!h))try{let u=e.createRange();u.setStart(c[0],c[1]),u.setEnd(h[0],h[1]);let f=e.getSelection();f.removeAllRanges(),f.addRange(u)}catch{}}var pd={compared:0},gd=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function bd(e,t,n){let r=0;for(let o of e.attributes)if(!n(e,o.name)&&(r++,t.getAttribute(o.name)!==o.value))return!1;for(let o of t.attributes)n(t,o.name)||r--;return r===0}function vi(e,t){if(e.namespaceURI!==t.namespaceURI||e.prefix!==t.prefix||e.localName!==t.localName)return!1;let n=e.attributes;if(n.length!==t.attributes.length)return!1;for(let r of n)if(t.getAttributeNS(r.namespaceURI,r.localName)!==r.value)return!1;return!0}function wa(e,t,n,r,o,s,l,i){let a=new Map,c=new Set,h=u=>{if(r(u))return;let f=n(u);f&&(s.add(f),o.has(f)||a.has(f)?c.add(f):a.set(f,u))};for(let u of e)h(u);h(t);for(let u of l||t.querySelectorAll("*"))h(u);for(let u of c)a.delete(u),i.add(u);return a}function Aa(e,t,n,r,o,s){let l=!1;for(let h of o)h.startsWith("merge:")&&(l=!0);if(!l)return[...r];let i=new Map,a=[],c=s===Sn?bo:"*";for(let h of[e,...e.querySelectorAll(c)]){if(n(h))continue;let u=t(h);if(!u||!(r.has(u)||o.has(u)))continue;let f=(i.get(u)||0)+1;i.set(u,f),f===2&&a.push(u)}return a}function Sa({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:r,o,identity:s,baseURI:l}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!bd(e,t,o.ignoreAttribute))return{bail:"root-attrs"};let{ignored:i,remoteWins:a}=o,c=yi(o.scripts.merge===!1?null:o.scripts.mergeTags,l),h=_e=>{let w=c(_e);return w!==null?w:s.base(_e)||null},u=_e=>{let w=c(_e);return w!==null?w:s.remote(_e)||null},f=[],d=[],p=new Map,y=new Map,m={same:p,differ:y},g=_e=>({bail:_e,comparisons:m}),k=(_e,w,V=!0)=>{if(p.get(_e)===w)return!0;if(y.get(_e)===w)return!1;if(pd.compared++,V&&_e.isEqualNode(w))return p.set(_e,w),!0;let ne=_e.nodeType===w.nodeType;if(ne&&_e.nodeType===1){if(ne=vi(_e,w),ne){let te=_e.firstChild,Pe=w.firstChild;for(;te&&Pe;te=te.nextSibling,Pe=Pe.nextSibling)if(!k(te,Pe,!1)){ne=!1;break}(te||Pe)&&(ne=!1)}}else ne&&(ne=_e.isEqualNode(w));return(ne?p:y).set(_e,w),ne},S=e,v=t,x=!1,O=()=>{p.set(S,v);for(let _e=0;_e<f.length;_e++)p.set(f[_e],d[_e]);return g("equal")};for(;;){let _e=S.childNodes,w=v.childNodes;if(_e.length!==w.length)break;let V=tt=>k(_e[tt],w[tt])?(p.set(_e[tt],w[tt]),!1):!0,ne=-1,te=-1;for(let tt=0;tt<_e.length;tt++){if(_e[tt].nodeType!==1)continue;let Q=0;for(let ce=_e[tt].firstElementChild;ce;ce=ce.nextElementSibling)Q++;Q>=te&&(te=Q,ne=tt)}let Pe=[],ze=!1;for(let tt=0;tt<_e.length&&Pe.length<2;tt++)tt!==ne&&V(tt)&&Pe.push(tt);if(ne>=0&&Pe.length<2&&(Pe.length===0&&vi(S,v)?(Pe.push(ne),ze=!0):V(ne)&&Pe.push(ne)),Pe.length!==1){if(!x&&Pe.length===0&&vi(S,v))return O();break}let Se=_e[Pe[0]],it=w[Pe[0]];if(x=x||!ze,x&&y.set(Se,it),Se.nodeType!==1||it.nodeType!==1||Se.tagName!==it.tagName)break;if(h(Se)!==u(it)){if(!x&&k(Se,it))return O();break}f.push(S),d.push(v),S=Se,v=it}y.set(S,v);for(let _e=0;_e<f.length;_e++)y.set(f[_e],d[_e]);if(S===e||S.tagName==="HEAD"||S.tagName==="BODY")return g("root-level");if(f.length<2||f[1].tagName!=="BODY")return g("not-in-body");if(i(S)||i(v))return g("ignored-ancestor");if(a(S)||a(v))return g("remote-wins-ancestor");for(let _e of f)if(gd.has(_e.tagName))return g("form-ancestor");if(S.tagName==="SCRIPT"||S.getElementsByTagName("script").length||v.getElementsByTagName("script").length)return g("script-or-template");let C=r(S);if(!C||C.nodeType!==1||C.tagName!==S.tagName)return g("no-live-twin");if(!n.contains(C))return g("live-detached");for(let _e of f){let w=r(_e);if(!w||w.nodeType!==1)return g("ancestor-live")}let _=s.base===Sn&&s.remote===Sn&&i===Ks,M=new Set,j=new Set,I=[],P=null,R=_e=>{_e&&(M.has(_e)?j.add(_e):M.add(_e))},T=(_e,w)=>{let V=c(_e),ne=V!==null?V:s.base(_e)||null;return ne!==(V!==null?V:s.remote(w)||null)?!1:(R(ne),!0)},A=(_e,w)=>{for(let V=_e.firstElementChild,ne=w.firstElementChild;V;V=V.nextElementSibling,ne=ne.nextElementSibling){let te=i(V);if(te!==i(ne))return!1;if(!te&&(!T(V,ne)||!A(V,ne)))return!1}return!0},W=_e=>{let w=_e+1<f.length?f[_e+1]:S;for(let V=f[_e].firstElementChild,ne=d[_e].firstElementChild;V;V=V.nextElementSibling,ne=ne.nextElementSibling){if(V===w){let ze=_e+1<f.length?W(_e+1):null;if(ze)return ze;continue}let te=i(V);if(te!==i(ne))return"outside-id-changed";if(te)continue;let Pe=r(V);if(!Pe||Pe.nodeType!==1)return"sibling-live";if(I.push([V,ne]),!_&&(!T(V,ne)||!A(V,ne)))return"outside-id-changed";_e===0&&V.tagName==="HEAD"&&h(V)&&(P=[V,ne])}return null},F=W(0);if(F)return g(F);let $=new Set(f),Ne=null;if(s.base===Sn){Ne=[];for(let _e of e.querySelectorAll(bo))_e===S||$.has(_e)||(S.contains(_e)?Ne.push(_e):_&&R(h(_e)))}let Ce=new Set,Be=new Set,re=new Set,Ee=wa(f,S,h,i,M,Ce,Ne,Be),Ge=wa(d,v,u,i,M,Ce,s.remote===Sn&&v.querySelectorAll(bo),re);return P&&(j.has(h(P[0]))||Ce.has(h(P[0])))&&(P=null),{scope:{chain:f,root:S,onChain:$,baseIndex:Ee,remoteIndex:Ge,baseDropped:Be,remoteDropped:re,head:P,same:p,differ:y,dropped:[...Aa(e,h,i,j,Be,s.base),...Aa(t,u,i,j,re,s.remote)],held:_e=>{for(let w=1;w<f.length;w++)if(_e.map.get(f[w])!==d[w])return!1;for(let[w,V]of I)if(_e.map.get(w)!==V)return!1;return!0}}}}var Nb=Symbol("hyper-morph-duplicate-key");var kd='[editor-ui],[clay~="editor-ui"],[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]',yd='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',xd='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function vd(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let t=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(t)}function wd(e,t,n,r){if(t==null)return;if(typeof t=="string")return t;let o=t;if(o.nodeType===9){let s=e.getAttribute("id");o=s&&o.getElementById(s)||(e.tagName==="BODY"?o.body:e.tagName==="HTML"?o.documentElement:o.body&&o.body.firstElementChild)}if((!o||o.nodeType!==1||o.tagName!==e.tagName)&&(o=Ad(e,t,r)),!!o)return n?Array.from(o.childNodes):o}function Ad(e,t,n){let r=t.nodeType===9?t.documentElement:t;if(!r||r.nodeType!==1)return null;let o=new Map,s=[r,...r.querySelectorAll("script")];for(let a of s){let c=jr(a,n);c&&!o.has(c.key)&&o.set(c.key,a.textContent)}if(!o.size)return null;let l=e.cloneNode(!0),i=!1;for(let a of[l,...l.querySelectorAll("script")]){let c=jr(a,n);c&&o.has(c.key)&&(a.textContent=o.get(c.key),i=!0)}return i?l:null}function Ta(e,t){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let n=t.implementation.createHTMLDocument(""),r=e.nodeType===1&&e.tagName==="HTML"?e:null;if(r)return n.replaceChild(n.adoptNode(r),n.documentElement),n;let o=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let s of o)n.body.appendChild(n.adoptNode(s));return n}function ir(e,t,n={}){let r=n||{};if(!r.head?.block)return Ea(e,t,r);try{return Ea(e,t,r)}catch(o){return Promise.reject(o)}}function Ea(e,t,n){let r=n.policy||"sync",o=r==="raw"?void 0:(a,c)=>vd(a)||(r==="history"?!(c&&a.matches(xd))&&a.matches(yd):a.matches(kd)),s=n.callbacks||{},l={ignore:o,hooks:s,protectFocusedValue:n.ignoreActiveValue===!0?"subtree":!1,restoreFocus:n.restoreFocus!==!1,formState:n.formStateSync||"attribute",scripts:{execute:n.scripts?.handle!==!1,merge:n.scripts?.merge!==!1,mergeTags:n.scripts?.mergeTags||[]},head:{awaitLoads:!!n.head?.block,preserve:n.head?.shouldPreserve||(()=>!1)}};if(typeof n.key=="function"&&(l.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return ko(Object.assign({},l,{live:e,base:n.scripts?.mergeBase||null,remote:Ta(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let a=Object.assign({},l,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:Ta(t,e.ownerDocument)});return ko(a)}n.morphStyle==="innerHTML"&&(l.children=!0);let i=wd(e,n.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return i!==void 0&&(l.base=i),wi(e,t,l)}var Sd=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),Rn=()=>{};function yo(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!Sd.has(l))throw new TypeError(`unknown option "${l}"`);let n=Object.assign({beforeNodeAdded:Rn,afterNodeAdded:Rn,beforeNodeRemoved:Rn,afterNodeRemoved:Rn,beforeNodeMorphed:Rn,afterNodeMorphed:Rn,beforeAttributeUpdated:Rn},e.hooks||{}),r=e.conflicts||"remote";if(!["remote","local","both"].includes(r))throw new TypeError("conflicts must be remote, local or both");let o=e.formState||"attribute";if(!["attribute","property"].includes(o))throw new TypeError("formState must be attribute or property");let s=e.protectFocusedValue;if(s!==void 0&&typeof s!="boolean"&&s!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");return{ignored:Gs(e.ignore,t),remoteWins:Gs(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:r,protectFocusedValue:s===void 0?!0:s,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:o,hooks:n,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0}}function Br(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return Sn}function qr(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=Ys(t,e.map),r=typeof e.then=="function"?e.then:Sn;if(typeof e.first=="function"){let o=e.first;return s=>o(s)||n.get(s)||r(s)}return o=>n.get(o)||r(o)}return Sn}function Td(e,t,n,r={}){let o=d=>d&&d.nodeType===9?d.documentElement:d,s=o(t),l=o(n),i=o(e)||s,a=Object.assign({},r);delete a.live,delete a.base,delete a.remote;let c=yo(a,[i,s,l].filter(Boolean)),h=r.identity||{},u=nr(),f=es(i,s,l,{identity:{base:qr(h.base,i),local:qr(h.local,s),remote:qr(h.remote,l)},authored:{base:Br(h.base),local:Br(h.local),remote:Br(h.remote)},skipUnchanged:c.hooks.beforeNodeMorphed===Rn&&c.hooks.afterNodeMorphed===Rn,ignored:c.ignored,remoteWins:c.remoteWins,ignoreAttribute:c.ignoreAttribute,conflicts:c.conflicts,mergeTags:c.scripts.merge===!1?null:c.scripts.mergeTags,baseURI:s.ownerDocument&&s.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:c.children,stats:u});return delete f.recoveryLinks,f}function Ai({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:r,toLive:o,options:s,identity:l,childrenOnly:i,isDocument:a}){let c=yo(s,[e,t,n,r].filter(Boolean));if(c.ignored(e))return{report:Si(),loads:[]};let h=e.ownerDocument,u=c.scripts.execute?Xl(e,c.ignored,h.baseURI):null,f=nr(),d=c.hooks.beforeNodeMorphed===Rn&&c.hooks.afterNodeMorphed===Rn,p={identity:{base:qr(l.base,t||n),local:qr(l.local,n),remote:qr(l.remote,r)},authored:{base:Br(l.base),local:Br(l.local),remote:Br(l.remote)},ignored:c.ignored,remoteWins:c.remoteWins,ignoreAttribute:c.ignoreAttribute,conflicts:c.conflicts,mergeTags:c.scripts.merge===!1?null:c.scripts.mergeTags,baseURI:h.baseURI,localIsBase:!t,childrenOnly:i,skipUnchanged:d},y=c.fastPath&&a&&!i&&d&&t===n,m=null,g=null;if(y){let R=Sa({baseRoot:t,remoteRoot:r,liveRoot:e,toLive:o,o:c,identity:p.identity,baseURI:h.baseURI});p.comparisons=R.comparisons||R.scope,R.bail?g=R.bail:(m=es(t,n,r,Object.assign({},p,{stats:f,scope:R.scope})),m||(g="chain-unpaired",f=nr()))}m||(m=es(t||n,n,r,Object.assign({},p,{stats:f}))),y&&(f.fastPathAttempted=1,f.fastPathTaken=g?0:1,f.fastPathFallback=g),m.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(R=>c.hooks[R]!==Rn)&&ia(m.conflicts,m.recoveryLinks,o),c.beforeApply&&c.beforeApply(m.doc);let k=globalThis.__hyperMorphProfile,S=k?performance.now():0,v=va(e,m.root,m,{toLive:o,localRoot:n,ignored:c.ignored,ignoreAttribute:c.ignoreAttribute,formState:c.formState,protectFocusedValue:c.protectFocusedValue,restoreFocus:c.restoreFocus,preserve:c.head.preserve,hooks:c.hooks,childrenOnly:i,keepLiveOnly:c.keepLiveOnly});k&&(k.apply=(k.apply||0)+(performance.now()-S));let x=[];if(c.head.awaitLoads)for(let R of v.applied){if(R.kind!=="insert"||R.node.nodeType!==1)continue;let T=R.node;T.tagName==="LINK"&&/\bstylesheet\b/i.test(T.getAttribute("rel")||"")&&T.getAttribute("href")&&T.closest("head")&&x.push(new Promise(W=>{T.addEventListener("load",()=>W()),T.addEventListener("error",()=>W())}))}let O=null,C=null;if(u){let R=Jl(e,u,{ignored:c.ignored,skip:v.mergedScriptsLive,baseURI:h.baseURI,beforeNodeAdded:c.hooks.beforeNodeAdded,afterNodeAdded:c.hooks.afterNodeAdded,trackRecovery:!!m.recoveryLinks});x.push(...R.loads),O=R.swapped,C=R.vetoed}let _=R=>O&&O.get(R)||R,M=R=>{if(v.keptRuns.has(R))return v.runOf.get(R);let T=v.liveOf.get(R)||v.heldBy.get(R)||v.insertedLive.get(R);return T?_(T):null},j=R=>{let T=R&&v.liveOf.get(R);return T?_(T):null},I=R=>{let T=R&&M(R);return Array.isArray(T)?T[0]:T};if(m.recoveryLinks){let R=(T,A,W)=>(A.namespaceURI?T.getAttributeNS(A.namespaceURI,A.localName):T.getAttribute(A.qualifiedName))===W;ca(m.conflicts,m.recoveryLinks,{lookup:M,vetoed:v.vetoed,vetoedAttrs:v.vetoedAttrs,removedVetoes:v.removedVetoes,vetoedLive:C,liveAttr:R,ignored:c.ignored,liveRoot:e})}return{report:{applied:v.applied,decisions:m.decisions.map(R=>Object.assign({},R,{node:R.node?j(R.node):null,el:R.el?j(R.el):null,applied:!!(R.node?j(R.node):R.el&&j(R.el))})),conflicts:m.conflicts.map(R=>Object.assign({},R,{node:R.node?R.kind==="text"&&R.recovery.subject.nodeType===8?I(R.node):j(R.node):R.node,el:R.el?R.kind==="structure"?I(R.el):j(R.el):R.el})),localDiverged:m.localDiverged,identities:v.identities,moved:v.moved,replaced:v.replaced,stats:f},loads:x}}var _a=new WeakMap;function Si(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:nr()}}function ko(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let r=_a.get(n);r||(r=Ws(n),_a.set(n,r));let o=r("remote",t.remote),s=typeof t.base=="string"&&t.base===""?null:t.base,l=s?r("base",s):null,i=t.local?t.local.root:n.documentElement,a=t.local?t.local.toLive:u=>u;El(n,o);let{report:c,loads:h}=Ai({liveRoot:n.documentElement,baseRoot:l?l.documentElement:null,localRoot:i,remoteRoot:o.documentElement,toLive:a,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(h).then(()=>c)}function Ed(e,t,n={}){return ko(Object.assign({},n,{live:e,base:null,remote:t}))}function Oa(e,t){if(e==null)return{root:t.createElement("template"),first:null};if(typeof e=="string"){let r=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(r){let s=Ho(e,t),l=r[1].toLowerCase()==="html"?s.documentElement:s.body;return{root:l,first:l}}let o=t.createElement("template");return o.innerHTML=e,{root:o,first:o.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let r=t.createElement("template"),o=e.isConnected;return r.content.appendChild(o?t.importNode(e,!0):e),{root:r,first:e}}if(e.nodeType===11){let r=t.createElement("template");return r.content.appendChild(e),{root:r,first:r.content.firstElementChild}}let n=t.createElement("template");for(let r of Array.from(e))n.content.appendChild(r.parentNode?t.importNode(r,!0):r);return{root:n,first:n.content.firstElementChild}}function wi(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let r=e.ownerDocument,{base:o,...s}=n,l=!!s.children;if(yo(s,[e]).ignored(e))return Promise.resolve(Si());let i=Oa(t,r),a=o!=null?Oa(o,r):null,c,h=null;if(l)c=i.root,h=a?a.root:null;else{if(c=i.first,h=a?a.first:null,!c){let d=yo(s);return d.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),d.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:nr()})}if(c.tagName!==e.tagName){let d=yo(s,[e,c]);if(d.hooks.beforeNodeMorphed(e,c)===!1)return Promise.resolve(Si());let p=Ai({liveRoot:e,baseRoot:h&&h.tagName===e.tagName?h:null,localRoot:e,remoteRoot:c,toLive:m=>m,options:s,identity:s.identity||{},childrenOnly:!0,isDocument:!1}),y=yn(c)?mo(c,r):r.importNode(c,!1);if(!yn(y))for(;e.firstChild;)y.appendChild(e.firstChild);return d.hooks.beforeNodeAdded(y)===!1?(Qo(p.report.conflicts,e,e),Promise.resolve(p.report)):d.hooks.beforeNodeRemoved(e)===!1?(Qo(p.report.conflicts,e,e),Promise.resolve(p.report)):(e.replaceWith(y),Qo(p.report.conflicts,e,y),d.hooks.afterNodeRemoved(e),d.hooks.afterNodeAdded(y),d.hooks.afterNodeMorphed(e,c),p.report.replaced.push(y),p.report.applied.push({kind:"insert",node:y,parent:y.parentNode},{kind:"remove",node:e,parent:y.parentNode}),Promise.all(p.loads).then(()=>p.report))}}let{report:u,loads:f}=Ai({liveRoot:e,baseRoot:h,localRoot:e,remoteRoot:c,toLive:d=>d,options:s,identity:s.identity||{},childrenOnly:l,isDocument:!1});return Promise.all(f).then(()=>u)}var Ti={mergeDocument:ko,morphDocument:Ed,morphElement:wi,merge3:Td,morph:ir};var ts=["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"],Ei=new Set(ts),Na=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Ur=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var rs={};Vs(rs,{EmptyListInsert:()=>vo,MAX_RULE_DEPTH:()=>zr,MaxRuleDepthExceeded:()=>wr,NoRulesTag:()=>_i,RuleTargetReadOnly:()=>wo,RulesParseError:()=>$r,ShapeMismatch:()=>xo,UnknownRulesVersion:()=>Hr,WriteRefused:()=>ns,WriteRejected:()=>Oi});var $r=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},Hr=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},zr=20,wr=class extends Error{constructor(t){super(`rule depth exceeded ${zr} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},xo=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},vo=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}},wo=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},ns=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}},_i=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Oi=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};function lr(e,t,n,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Ni(e,t,n,{depth:0,path:[]},r)}function Ni(e,t,n,r,o){if(r.depth>zr)throw new wr(r.path);if(typeof n=="string")return Md(e,t,n,r,o);if(Array.isArray(n)){let[s,l]=n,i=e.find(t,s,o);return Ma(o,r,i),i.map((a,c)=>Ni(e,a,l,{depth:r.depth+1,path:[...r.path,c]},o))}if(typeof n=="object"&&n!==null){let s={};for(let[l,i]of Object.entries(n))s[l]=Ni(e,t,i,{depth:r.depth+1,path:[...r.path,l]},o);return s}return null}function Md(e,t,n,r,o){if(n.endsWith("[]")){let i=n.slice(0,-2),a=e.find(t,i,o);return Ma(o,r,a),a.map(c=>e.text(c))}if(n.startsWith("@"))return Ca(e,t,n.slice(1));let s=rn(n);if(s!==-1){let i=n.slice(0,s),a=n.slice(s+1),c=i?e.find(t,i,o):[t];return c.length===0?null:Ca(e,c[0],a)}if(n===".")return e.text(t);let l=e.find(t,n,o);return l.length===0?null:e.text(l[0])}function Ma(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(r){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,r)}}function Ca(e,t,n){if(Ei.has(n)){let o=e.prop(t,n);return o==null?null:String(o)}let r=e.attr(t,n);return r||null}var Ra=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"]})}),Rd=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Ia=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function Ci(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Id(e,t){if(Ci(e,t))return!0;for(let[n,r]of Object.entries(Rd))if(r.includes(t)&&Ci(e,n))return!0;return!1}function Ao(e){let t=Ra[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Ld(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=Ra[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>Id(n,o))||r.bundles.some(o=>Ci(n,o)))return n;n=n.parentElement}return null}function La(e,t){return!!Ld(e,t)}var jd=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function ja(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),e.tagName==="SELECT")for(let r=0;r<e.options.length;r++)t.options[r].selected=e.options[r].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Pa(e,t,n,r){if(r)return!!e.closest?.(t);let o=e;for(;o?.nodeType===1;){if(o.matches(t))return!0;if(o===n)break;o=o.parentElement}return!1}function Da(e,t,n,r,o,s,l,i){if(e.nodeType===1&&((l?La(e,n):Pa(e,r,s,!1))||o&&(l&&e!==s?e.matches(o):Pa(e,o,s,l))))return null;let a=t.importNode(e,!1);i.cloneToLive.set(a,e),i.liveToClone.set(e,a);let c=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,h=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;c!==e&&(i.cloneToLive.set(h,c),i.liveToClone.set(c,h));for(let u of c.childNodes||[]){let f=Da(u,t,n,r,o,s,l,i);f&&(h.appendChild(f),u.nodeType===1&&ja(u,f))}return e.nodeType===1&&ja(e,a),a}function So(e,{capability:t="data",exclude:n=null,inherit:r=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=o.implementation.createHTMLDocument(""),l=new WeakMap,i=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let c=Ao(t),h=Da(a,s,t,c,n,a,r,{cloneToLive:l,liveToClone:i});e.nodeType===9&&h&&(s.replaceChild(h,s.documentElement),i.set(e,s),l.set(s,e));let u=f=>{if(jd.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:h,document:s,capability:t,selector:Ao(t),cloneToLive:l,liveToClone:i,original(f){return l.get(f)||null},cloneOf(f){return i.get(f)||null},query(f,d=h){return u(f),Array.from(d.querySelectorAll(f),p=>l.get(p)||p)},text(f=h){return(f===h?h:i.get(f))?.textContent||""},html(f=h){return(f===h?h:i.get(f))?.innerHTML??""},clone(f=h){let d=f===h?h:i.get(f);return d?s.importNode(d,!0):null}}}function Fa(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Pd(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var an={semanticExclude:!0,find(e,t,n={}){let r=Pd(e);if(!r||!r.querySelectorAll)return[];let o=Array.from(r.querySelectorAll(t));n.includeRulesTag||(o=o.filter(i=>!Fa(i)));let s=[];n.skip&&s.push(n.skip);let l=n.templateAttr===null?null:n.templateAttr||"cms-template";if(l&&s.push("["+l+"]"),s.length){let i=s.join(", ");o=o.filter(a=>!a.closest||!a.closest(i))}return o},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,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let r=e?e[t]:void 0;return r!==void 0?r:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let r=e.children[n]||null;e.insertBefore(t,r)},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 r=e.ownerDocument.createElement("template");r.innerHTML=t;let o=r.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Xn(e,t={}){if(t.exclude===null)return an;let n=[Ao("data"),t.exclude].filter(Boolean).join(", "),r=e.nodeType===9?e:e.ownerDocument||e,o=e.nodeType===9?e.documentElement:e;if(!t._write&&!o?.matches?.(n)&&!o?.querySelector?.(n)&&!r?.querySelector?.(n))return an;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,i=null,a=()=>i||(i=So(s,{capability:"data",exclude:t.exclude||null})),c=p=>{let y=a();return p===e?y.cloneOf(e):y.cloneOf(p)||p},h=p=>i?.original(p)||p,u=(p,y)=>{a().liveToClone.set(p,y),a().cloneToLive.set(y,p);let m=p.childNodes||[],g=y.childNodes||[];for(let k=0;k<Math.min(m.length,g.length);k++)u(m[k],g[k])},f=(p,y,m,g)=>{let k=Array.from(p.childNodes).filter(C=>i.cloneOf(C)),v=k[0];for(;v&&k.includes(v);)v=v.nextSibling;for(let C of k)C.remove();if(m==="innerHTML"){let C=l.createElement("template");C.innerHTML=g;for(let _ of Array.from(C.content.childNodes))p.insertBefore(_,v||null)}else p.insertBefore(l.createTextNode(g),v||null);let x=So(p,{capability:"data",exclude:t.exclude||null});y.replaceChildren(...Array.from(x.root?.childNodes||[]));let O=C=>{let _=x.original(C);_&&(i.liveToClone.set(_,C),i.cloneToLive.set(C,_));for(let M of Array.from(C.childNodes||[]))O(M)};for(let C of Array.from(y.childNodes))O(C)},d={...an,find(p,y,m={}){let g=c(p);if(!g?.querySelectorAll)return[];let k=a().query(y,g);m.includeRulesTag||(k=k.filter(x=>!Fa(x)));let S=[];m.skip&&S.push(m.skip);let v=m.templateAttr===null?null:m.templateAttr||"cms-template";if(v&&S.push(`[${v}]`),S.length){let x=S.join(", ");k=k.filter(O=>!O.closest?.(x))}return k},parent(p){let y=c(p)?.parentElement;return y?h(y):null},children(p){return Array.from(c(p)?.children||[],h)},text(p,y){if(y===void 0){let k=h(p);return!k?.matches?.(n)&&!k?.querySelector?.(n)?an.text(k):(c(p)?.textContent||"").trim()}let m=h(p);if(!m?.matches?.(n)&&!m?.querySelector?.(n)&&!i){an.text(m,y);return}let g=a().cloneOf(m);g?f(m,g,"textContent",y):an.text(m,y)},attr(p,y,m){let g=h(p);if(m===void 0)return an.attr(g,y);an.attr(g,y,m);let k=i?.cloneOf(g);k&&(an.attr(k,y,m),So(g,{capability:"data",exclude:t.exclude||null}).root===null&&(k.remove(),i.liveToClone.delete(g),i.cloneToLive.delete(k)))},removeAttr(p,y){let m=h(p);an.removeAttr(m,y);let g=i?.cloneOf(m);g&&an.removeAttr(g,y)},prop(p,y,m){let g=h(p);if(m===void 0)return y==="innerHTML"||y==="outerHTML"||y==="textContent"||y==="innerText"?an.prop(c(g),y):an.prop(g,y);let k=y==="innerHTML"||y==="textContent"||y==="innerText",S=k?a().cloneOf(g):i?.cloneOf(g);S&&k?f(g,S,y,m):(an.prop(g,y,m),S&&an.prop(S,y,m))},clone(p){let y=c(p);return y===p?an.clone(p):l.importNode(y,!0)},insertAt(p,y,m){let g=h(p),S=d.children(g)[m]||(()=>{for(let O=g.children.length-1;O>=0;O--){let C=g.children[O];if(a().cloneOf(C))return C.nextElementSibling}return g.firstElementChild})(),v=h(y);g.insertBefore(v,S||null);let x=a().cloneOf(g);if(x){let O=a().cloneOf(v);O||(O=l.importNode(v,!0),u(v,O));let C=Array.from(x.children);x.insertBefore(O,C[m]||null)}},remove(p){let y=h(p),m=a().cloneOf(y);an.remove(y),m&&an.remove(m)},replaceWith(p,y){let m=h(p),g=a().cloneOf(m),k=an.replaceWith(m,y);if(g){let S=So(k,{capability:"data",exclude:t.exclude||null});if(!S.root)g.remove();else{g.replaceWith(S.root);let v=x=>{let O=S.original(x);O&&(i.liveToClone.set(O,x),i.cloneToLive.set(x,O));for(let C of Array.from(x.childNodes||[]))v(C)};v(S.root)}}return k}};return d}var Vr=an;function Mi(e){try{return JSON.parse(e)}catch(t){throw new $r(`Invalid strict JSON: ${t.message}`,t)}}function Wr(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 n(o){let s=[],l=0;for(;l<o.length;){let i=o[l];if(/\s/.test(i)){l++;continue}if("{}".includes(i)){s.push({type:i,value:i}),l++;continue}if(i==="["){let u=!1,f=l+1;for(;f<o.length&&/\s/.test(o[f]);)f++;if(f<o.length&&/[a-zA-Z_]/.test(o[f])&&(u=!0),!u){s.push({type:i,value:i}),l++;continue}}if(i==="]"){s.push({type:i,value:i}),l++;continue}if(i===":"){s.push({type:t.COLON,value:i}),l++;continue}if(i===","){s.push({type:t.COMMA,value:i}),l++;continue}if(i==='"'||i==="'"){let u=i,f=l+1;for(;f<o.length&&o[f]!==u;)o[f]==="\\"&&f++,f++;s.push({type:t.STRING,value:o.substring(l+1,f),quoted:!0,sourceQuote:u}),l=f+1;continue}let a=l,c;for(;a<o.length&&!/[{},]/.test(o[a]);)if(o[a]===":"){let u=[":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"],f=!1;for(let d of u){let p=d.substring(1);if(o.substring(a+1,a+1+p.length)===p){f=!0,a+=p.length;break}}if(!f)break}else if(o[a]==="["){for(a++;a<o.length&&o[a]!=="]";){if(o[a]==='"'||o[a]==="'"){let u=o[a];for(a++;a<o.length&&o[a]!==u;)o[a]==="\\"&&a++,a++}a++}a<o.length&&o[a]==="]"&&a++}else a++;c=o.substring(l,a);let h=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?h=t.NUMBER:c==="true"||c==="false"||c==="null"?h=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(h=t.SELECTOR),s.push({type:h,value:c,quoted:!1}),l=a}return s}function r(o){let s="";for(let l=0;l<o.length;l++){let i=o[l];if("{}".includes(i.type)||"[]".includes(i.type)){s+=i.value;continue}if(i.type===t.COLON){s+=i.value;continue}if(i.type===t.COMMA){let a=o[l+1];if(a&&(a.type==="}"||a.type==="]"))continue;s+=i.value;continue}if(i.type===t.STRING&&i.quoted){let a=i.value;i.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(c,h)=>h.length%2===0?h+'\\"':c)),s+=`"${a}"`;continue}if(i.type===t.NUMBER||i.type===t.BOOLEAN){s+=i.value;continue}if(i.type===t.SELECTOR||i.type===t.IDENTIFIER){s+=`"${i.value}"`;continue}s+=`"${i.value}"`}return s}try{let o=n(e),s=r(o);return JSON.parse(s)}catch(o){throw new $r("Invalid extraction rules syntax: "+o.message,o)}}var qa="1",Ba=/^[a-zA-Z0-9_-]+$/;function To(e,t,n){let r;if(n===void 0)r="script[data-rules-name]";else{if(typeof n!="string"||!Ba.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Ba})`);r=`script[data-rules-name~="${n}"]`}let o=e.find(t,r,{includeRulesTag:!0});if(o.length===0)return null;n!==void 0&&o.length>1&&console.warn(`hyper-html-api: ${o.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=o[0],l=e.attr(s,"data-rules-version");if(l!==qa)throw new Hr(l);return{rules:Wr(e.text(s)),tagNode:s}}var Fk=new Function("url","return import(url)");function Wa(e,t,n,r){let o=e.length,s=t.length,l=new Array(o).fill(-1);if(r){let m=new Set;for(let g=0;g<o;g++){let k=r[g];!(k>=0&&k<s)||m.has(k)||(l[g]=k,m.add(k))}}if(o===0||s===0)return l;let i=e.map(m=>za(m,n)),a=t.map(m=>za(m,n)),c=new Array(s).fill(!1);for(let m of l)m>=0&&(c[m]=!0);let h=new Map;a.forEach((m,g)=>{c[g]||h.set(m,h.has(m)?-1:g)});let u=new Map;i.forEach((m,g)=>{l[g]>=0||u.set(m,(u.get(m)||0)+1)}),i.forEach((m,g)=>{if(l[g]>=0||u.get(m)!==1)return;let k=h.get(m);k===void 0||k===-1||c[k]||(l[g]=k,c[k]=!0)});let f=[];for(let m=0;m<o;m++)l[m]<0&&f.push(m);let d=[];for(let m=0;m<s;m++)c[m]||d.push(m);if(f.length===0||d.length===0)return l;let p=o*s+1,y=(m,g)=>Fd(e[m],t[g],n)*p+Math.abs(m-g);for(let[m,g]of Bd(f,d,y))l[m]=g;return l}var Ka=e=>typeof e=="object"&&e!==null;function za(e,t){if(!Ka(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(r=>{let o=JSON.stringify(e?.[r]);return o===void 0?" undef":o}))}function Fd(e,t,n){if(!Ka(n))return e===t?0:1;let r=Object.keys(n);if(r.length===0)return 0;let o=0;for(let s of r){let l=JSON.stringify(e?.[s]),i=JSON.stringify(t?.[s]);l!==i&&o++}return o}function Bd(e,t,n){return e.length<=t.length?Va(e,t,n,!1):Va(t,e,(r,o)=>n(o,r),!0)}function Va(e,t,n,r){let o=e.length,s=t.length,l=[];for(let u=0;u<=o;u++)l.push(new Float64Array(s+1).fill(1/0));let i=[];for(let u=0;u<=o;u++)i.push(new Uint8Array(s+1));for(let u=0;u<=s;u++)l[o][u]=0;for(let u=o-1;u>=0;u--)for(let f=s-1;f>=0;f--){let d=n(e[u],t[f])+l[u+1][f+1],p=l[u][f+1];d<=p?(l[u][f]=d,i[u][f]=1):l[u][f]=p}let a=[],c=0,h=0;for(;c<o&&h<s;)i[c][h]&&(a.push(r?[t[h],e[c]]:[e[c],t[h]]),c++),h++;return a}function Ii(e,t,n,r,o,s,l,i={}){let a=e.find(t,n,i);if(o.length===0){a.forEach(x=>e.remove(x)),Ri(i,"onRowsApplied",s.path,[]);return}let c=o.length>a.length,h=a[0]||null;if(c&&!h&&(h=Hd(e,t,n,i),!h))throw new vo(s.path);let u=a.map(x=>$d(e,x,r,i)),f=null;if(c&&h){f=e.clone(h),i.templateAttr&&e.removeAttr(f,i.templateAttr);let x=e.stripIds(f);x>0&&console.warn(`[hyper-html-api] stripped ${x} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let d=Wa(o,u,r,qd(e,a,o,s,i)),p=a[0]||h,y=e.parent(p),m=a.length>0?Ga(e,y,p):0,g=zd(e,a),k=new Set,S=[],v=o.map((x,O)=>{let C=d[O];if(C>=0)return k.add(C),S.push(!1),a[C];S.push(!0);let _=e.clone(f);return e.stripIds(_),_});a.forEach((x,O)=>{k.has(O)||e.remove(x)}),g?v.forEach((x,O)=>{let C=m+O;e.children(y).findIndex(j=>e.sameNode(j,x))!==C&&e.insertAt(y,x,C)}):Vd(e,v,S,y,m),Ud(e,v,r,o,s,l,i),Ri(i,"onRowsApplied",s.path,v)}function Ri(e,t,n,r){if(typeof e[t]=="function")try{return e[t](n.slice(),r)}catch(o){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,o);return}}function qd(e,t,n,r,o){let s=Ri(o,"identifyRows",r.path,n);if(!Array.isArray(s))return null;let l=new Array(n.length).fill(-1),i=new Set;for(let a=0;a<n.length;a++)if(s[a]){for(let c=0;c<t.length;c++)if(!(i.has(c)||!e.sameNode(t[c],s[a]))){l[a]=c,i.add(c);break}}return l}function Ud(e,t,n,r,o,s,l){t.forEach((i,a)=>{if(n===null){let c=r[a],h=c==null?"":String(c);e.text(i)!==h&&e.text(i,h)}else{let c=s(e,i,n,r[a],{depth:o.depth+1,path:[...o.path,a]},l);c&&c!==i&&(t[a]=c)}})}function $d(e,t,n,r){return n===null?e.text(t):lr(e,t,n,r.onRowsRead?{...r,onRowsRead:void 0}:r)}function Ga(e,t,n){let r=e.children(t);for(let o=0;o<r.length;o++)if(e.sameNode(r[o],n))return o;return-1}function Hd(e,t,n,r){if(!r.templateAttr)return null;let o=t;for(;o;){let s=e.find(o,n,{includeRulesTag:!1,templateAttr:null});for(let l of s)if(e.attr(l,r.templateAttr)!=null)return l;o=e.parent(o)}return null}function zd(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let r=e.children(n),o=[];for(let s of t){let l=r.findIndex(i=>e.sameNode(i,s));if(l===-1)return!1;o.push(l)}return o.sort((s,l)=>s-l),o[o.length-1]-o[0]===o.length-1}function Vd(e,t,n,r,o){let s=null,l=o;for(let i=0;i<t.length;i++){if(!n[i]){s=t[i];continue}let a=s?e.parent(s):r;if(!a)continue;let c=s?Ga(e,a,s)+1:l++;e.insertAt(a,t[i],c),s=t[i]}}var Ya=new Set(["checked","selected","disabled","readOnly","paused"]);function Kr(e,t,n,r,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let s=[];if(Li(n,r,[],s),s.length)throw new xo(s);os(e,t,n,r,{depth:0,path:[]},o)}function os(e,t,n,r,o,s={}){if(o.depth>zr)throw new wr(o.path);if(r===void 0)return t;if(typeof n=="string")return Wd(e,t,n,r,o,s);if(Array.isArray(n)){let[l,i]=n;return Ii(e,t,l,i,r,o,os,s),t}if(typeof n=="object"&&n!==null){for(let[l,i]of Object.entries(n)){let a=os(e,t,i,r==null?r:r[l],{depth:o.depth+1,path:[...o.path,l]},s);a&&a!==t&&(t=a)}return t}return t}function Wd(e,t,n,r,o,s){if(n.endsWith("[]")){let a=n.slice(0,-2);return Ii(e,t,a,null,r,o,os,s),t}if(n.startsWith("@"))return Ja(e,t,n.slice(1),r);let l=rn(n);if(l!==-1){let a=n.slice(0,l),c=n.slice(l+1),h=a?e.find(t,a,s):[t];return h.length===0||Ja(e,h[0],c,r),t}if(n===".")return Xa(e,t,r),t;let i=e.find(t,n,s);return i.length===0||Xa(e,i[0],r),t}function Xa(e,t,n){let r=n==null?"":String(n);e.text(t)!==r&&e.text(t,r)}function Ja(e,t,n,r){if(Ur.has(n)){let s=e.prop(t,n);if(s===r||s!=null&&r!=null&&String(s)===String(r))return t;throw new wo(n)}if(n==="outerHTML"){let s=r==null?"":String(r);return e.replaceWith(t,s)}if(Na.has(n)){let s=Kd(n,r);return e.prop(t,n)!==s&&e.prop(t,n,s),t}let o=r==null?"":String(r);return e.attr(t,n)!==o&&e.attr(t,n,o),t}function Kd(e,t){return t==null?Ya.has(e)?!1:"":Ya.has(e)?t==="false"?!1:!!t:t}function Li(e,t,n,r){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((o,s)=>{typeof o=="object"&&o!==null&&r.push({path:_o([...n,s]),expected:"scalar",got:Eo(o)})}):r.push({path:_o(n),expected:"array",got:Eo(t)});return}t!==null&&typeof t=="object"&&r.push({path:_o(n),expected:"scalar",got:Eo(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){r.push({path:_o(n),expected:"array",got:Eo(t)});return}let o=e[1];t.forEach((s,l)=>Li(o,s,[...n,l],r));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){r.push({path:_o(n),expected:"object",got:Eo(t)});return}for(let[o,s]of Object.entries(e))Li(s,t[o],[...n,o],r)}}}function Eo(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function _o(e){return e.join(".")}var sh=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...Ia],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]});function ji(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let r=t&&t.ownerDocument?t.ownerDocument:t;return To(e,r,n)}return null}var pn={extract:(e,t,n={})=>lr(Xn(e,n),e,t,n),apply:(e,t,n,r={})=>Kr(Xn(e,{...r,_write:!0}),e,t,n,r),findRulesIn:(e,t)=>To(Vr,e,t),findRules:(e,t)=>ji(Vr,e,t),bind:(e,t,n={})=>{let r=ji(Vr,e,t);if(!r){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}return{...r,get:()=>lr(Xn(e,n),e,r.rules,n),set:o=>Kr(Xn(e,{...n,_write:!0}),e,r.rules,o,n)}},parseStrict:Mi,parseRelaxed:Wr,ruleAttrIndex:rn,splitRule:$o,errors:rs,DOM_PROPERTIES:ts};var Di={};Vs(Di,{fromString:()=>Jn,getRuleAtPath:()=>Ar,getValueAtPath:()=>fh,setAtPath:()=>Pi,toString:()=>ch});function ch(e){return e.map(String).join(".")}function Jn(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function Ar(e,t){let n=e;for(let r of t){if(n==null)return;if(typeof n=="string"){if(n.endsWith("[]")&&(typeof r=="number"||r==="*")){n=n.slice(0,-2);continue}return}if(Array.isArray(n)){if(typeof r!="number"&&r!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof r=="number"||!(r in n))return;n=n[r];continue}return}return n}function fh(e,t){let n=e;for(let r of t){if(n==null)return;n=n[r]}return n}function Pi(e,t,n){if(t.length===0)return n;let[r,...o]=t;if(typeof r=="number"){let s=Array.isArray(e)?[...e]:[];return s[r]=Pi(s[r],o,n),s}return{...e&&typeof e=="object"?e:{},[r]:Pi((e||{})[r],o,n)}}function Oo(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[n,r]of Object.entries(e))t[n]=Oo(r);return t}return""}function ss(e,t,{ignoreActiveValue:n=!0}={}){Ti.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:n,restoreFocus:!0,formStateSync:"property",policy:"raw"})}var Qa=new WeakMap,Fi=e=>e.map(String).join(".");function uh(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function ec(e,t){if(!e||!e.querySelector)return null;let n=e.querySelector(`[data-hcms-path="${uh(t)}"]`),r=n&&n.querySelector(".hcms-array-items");return r?Array.from(r.children).filter(o=>o.matches&&o.matches("[data-hcms-card], [data-hcms-array-item]")):null}function tc(e,t,n){let r=ec(e,t);!r||r.length!==n.length||r.forEach((o,s)=>{n[s]&&Qa.set(o,n[s])})}function is(){let e=new Map;return{hooks:{onRowsRead(t,n){e.set(Fi(t),n)}},seed(t){for(let[n,r]of e)tc(t,n,r);e.clear()}}}function nc(e){return{identifyRows(t,n){let r=ec(e,Fi(t));return!r||r.length!==n.length?null:r.map(o=>Qa.get(o)||null)},onRowsApplied(t,n){tc(e,Fi(t),n)}}}var rc={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Bi="data-hcms-rollback-ui",dh=0;function oc(e,t,n,r={}){return hh(e,t,n,r)}function hh(e,t,n,r){let{shellRoot:o,structural:s,structuralPath:l,formRoot:i}=r,a=i?{...rc,...nc(i)}:rc;if(!s)try{return pn.apply(e,t,n,a),{ok:!0}}catch(f){return{ok:!1,error:f}}let c=mh(e,t,l),h=c?gh(c):null,u=c?null:kh(e,o);try{return pn.apply(e,t,n,a),{ok:!0}}catch(f){return h?bh(c,h):u&&yh(e,o,u),{ok:!1,error:f}}}function mh(e,t,n){if(!n||!e)return null;let r=Jn(n),o=[],s=t;for(let l of r){if(typeof s=="string"||s==null||Array.isArray(s))break;if(typeof s=="object"&&l in s){if(o.push(l),s=s[l],Array.isArray(s)||typeof s=="string"&&s.endsWith("[]"))break}else return null}return!Array.isArray(s)&&!(typeof s=="string"&&s.endsWith("[]"))?null:ph(e,t,o)}function ph(e,t,n){if(n.length===0)return null;let r=e,o=t;for(let s=0;s<n.length;s++){let l=n[s];if(!o||typeof o!="object"||Array.isArray(o))return null;let i=o[l];if(i==null)return null;if(s===n.length-1){if(Array.isArray(i)){let[a]=i;return r.querySelector?.(a)?.parentElement||null}if(typeof i=="string"&&i.endsWith("[]")){let a=i.slice(0,-2);return r.querySelector?.(a)?.parentElement||null}return null}o=i}return null}function gh(e){let t=[],n=[];for(let r of Array.from(e.childNodes))t.push(qi(r,n));return{nodes:t,retained:n}}function bh(e,t){let n=e.cloneNode(!1);for(let r of t.nodes)n.appendChild(r);ir(e,Array.from(n.childNodes),ic()),sc(e,t.retained)}function kh(e,t){let n=[],r=[];for(let o of Array.from(e.childNodes))o===t||t&&o.contains?.(t)||n.push(qi(o,r));return{nodes:n,retained:r}}function yh(e,t,n){let r=e.cloneNode(!1);for(let o of n.nodes)r.appendChild(o);ir(e,Array.from(r.childNodes),ic()),sc(e,n.retained)}function qi(e,t){let n=e.cloneNode(!1);if(e.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]')){let s=String(++dh);n.setAttribute(Bi,s),t.push({id:s,node:e})}let r=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,o=n.nodeType===1&&n.tagName==="TEMPLATE"?n.content:n;for(let s of Array.from(r.childNodes||[]))o.appendChild(qi(s,t));return n}function sc(e,t){for(let{id:n,node:r}of t){let o=e.querySelector(`[${Bi}="${n}"]`);o===r?r.removeAttribute(Bi):r.isConnected?o?.remove():o?.replaceWith(r)}}function ic(){return{morphStyle:"innerHTML",policy:"raw",restoreFocus:!1,scripts:{handle:!1,merge:!1}}}function as(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 xh='<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>',Ui='<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>',cc={"@scalar":`
5
5
  <label class="hcms-field" data-hcms-shape="scalar">
6
6
  <span class="hcms-label" data-hcms-label></span>
7
7
  <textarea class="mirk-textarea" rows="1" data-hcms-field></textarea>
@@ -41,13 +41,13 @@ var hypercms=(()=>{var ws=Object.defineProperty;var iu=Object.getOwnPropertyDesc
41
41
  </section>
42
42
  `,"@object-array-item":`
43
43
  <article class="hcms-card mirk-sortable__item" draggable="true">
44
- ${cd}
44
+ ${xh}
45
45
  <div class="hcms-card-body mirk-sortable__body">
46
46
  <div class="hcms-card-fields"></div>
47
47
  <div class="hcms-card-controls">
48
48
  <button type="button" class="hcms-move hcms-move-up hcms-sr-only" data-hcms-action="move-up" aria-label="Move up">\u2191</button>
49
49
  <button type="button" class="hcms-move hcms-move-down hcms-sr-only" data-hcms-action="move-down" aria-label="Move down">\u2193</button>
50
- <button type="button" class="hcms-remove hcms-remove--card" data-hcms-action="remove" aria-label="Remove">${mi}</button>
50
+ <button type="button" class="hcms-remove hcms-remove--card" data-hcms-action="remove" aria-label="Remove">${Ui}</button>
51
51
  </div>
52
52
  </div>
53
53
  <div class="hcms-error" hidden></div>
@@ -61,7 +61,7 @@ var hypercms=(()=>{var ws=Object.defineProperty;var iu=Object.getOwnPropertyDesc
61
61
  <span class="mirk-button__label">Choose</span>
62
62
  </label>
63
63
  <a class="mirk-file__name" data-hcms-field></a>
64
- <button type="button" class="hcms-upload-clear" data-hcms-action="clear-upload" aria-label="Remove file">${mi}</button>
64
+ <button type="button" class="hcms-upload-clear" data-hcms-action="clear-upload" aria-label="Remove file">${Ui}</button>
65
65
  </div>
66
66
  <div class="hcms-error" hidden></div>
67
67
  </div>
@@ -75,7 +75,7 @@ var hypercms=(()=>{var ws=Object.defineProperty;var iu=Object.getOwnPropertyDesc
75
75
  </label>
76
76
  <figure class="mirk-image__thumb">
77
77
  <span class="mirk-image__frame"><img class="mirk-image__preview" data-hcms-field alt="" /></span>
78
- <button type="button" class="hcms-upload-clear hcms-upload-clear--badge" data-hcms-action="clear-upload" aria-label="Remove image">${mi}</button>
78
+ <button type="button" class="hcms-upload-clear hcms-upload-clear--badge" data-hcms-action="clear-upload" aria-label="Remove image">${Ui}</button>
79
79
  </figure>
80
80
  </div>
81
81
  <div class="hcms-error" hidden></div>
@@ -149,11 +149,11 @@ var hypercms=(()=>{var ws=Object.defineProperty;var iu=Object.getOwnPropertyDesc
149
149
  <input class="hcms-chip-field" data-hcms-field aria-label="Item" placeholder="\u2026" />
150
150
  <button type="button" class="hcms-remove" data-hcms-action="remove" aria-label="Remove">\xD7</button>
151
151
  </span>
152
- `},ud=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function Uo(e){let t=e.head||e.documentElement;if(t)for(let n of ud)va(e,t,n)}function pi(e,t){if(!ba[t])return null;let n=e&&(e.head||e.documentElement);return n?va(e,n,t):null}var pa={src:"@image",checked:"@checkbox",innerHTML:"@richtext"},Ho={image:"@image",file:"@file",checkbox:"@checkbox",toggle:"@toggle",select:"@select",radio:"@radio",textarea:"@textarea",number:"@number",richtext:"@richtext"},fd=new Set([...Object.values(Ho),"@chips","@chips-item"]);function uo(e,t,n,r){if(typeof e!="string")return"@scalar";let o=Vt(e),s=Wo(e,o,n,r),i=Ko(s,t,"data-hcms-component");if(i&&Ho[i]){let l=Ho[i],a=Array.isArray(n)&&n.some(u=>u==="*"||typeof u=="number");return l==="@number"&&!ga(e,o,t,a,s).every(hd)||(l==="@checkbox"||l==="@toggle")&&(o<0||e.slice(o+1)!=="checked")&&!ga(e,o,t,a,s).every(md)?"@scalar":l}if(o>=0){let l=e.slice(o+1);if(pa[l])return pa[l]}return"@scalar"}function ka(e,t,n,r){if(typeof e!="string")return null;let o=Vt(e),s=Ko(Wo(e,o,n,r),t,"data-hcms-component");return s&&Ho[s]||null}var dd=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function hd(e){return e==null||e===""?!0:dd.test(String(e))}function md(e){return e==null||e===""||e==="true"||e==="false"}function ga(e,t,n,r,o){if(!n||!n.querySelectorAll)return[];if(!o||o===".")return[];let s=null;try{s=n.querySelectorAll(o)}catch{return[]}let i=t>=0?e.slice(t+1):null,l=[];for(let a of s)if(!(a.closest&&a.closest("[cms-template], [data-hcms-shell]"))&&(i?i==="value"&&"value"in a?l.push(a.value):l.push(a.getAttribute?a.getAttribute(i):null):l.push((a.textContent||"").trim()),!r))break;return l}function zo(e,t){if(typeof e!="string"||!e.endsWith("[]")||!t||!t.querySelector)return null;let n=e.slice(0,-2).trim();if(!n)return null;let r=null;try{r=t.querySelector(n)}catch{return null}let o=r&&r.closest?r.closest("[data-hcms-component]"):null;return(o&&o.getAttribute?o.getAttribute("data-hcms-component"):null)==="chips"?{array:"@chips",item:"@chips-item"}:null}function Mr(e,t,n){let r=e.join("."),o=e.map(s=>typeof s=="number"?"*":s).join(".");return r&&_n(n,r)||o&&o!==r&&_n(n,o)||_n(n,t)}function Vo(e,t,n){let r=zo(e,n);if(!r)return null;let o=Mr(t,r.array,n);return o&&o.getAttribute("data-hcms-tpl")===r.array?r:null}function ya(e,t,n,r){if(typeof e!="string")return null;let o=Vt(e),s=Ko(Wo(e,o,n,r),t,"data-hcms-options");if(s==null)return null;let i=s.trim().split(/\s+/).filter(Boolean);return i.length?i:null}function xa(e,t,n,r){if(typeof e!="string")return null;let o=Vt(e);return Ko(Wo(e,o,n,r),t,"data-hcms-crop")}function pd(e,t){return t>=0?e.slice(0,t):e}function Wo(e,t,n,r){let o=pd(e,t);return o&&o!=="."?o:gd(r,n)}function gd(e,t){if(e==null||!Array.isArray(t))return"";let n=[],r=e;for(let o of t){if(r==null||typeof r=="string")break;if(Array.isArray(r)){if(typeof r[0]!="string"||o!=="*"&&typeof o!="number")return"";n.push(r[0]),r=r[1];continue}if(typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,o))return"";r=r[o]}return n.join(" ")}function Ko(e,t,n){if(!t||!t.querySelector||!e||e===".")return null;let r=null;try{r=t.querySelector(e)}catch{return null}return r&&r.getAttribute?r.getAttribute(n):null}function Go(e,t){if(!e||t==null)return;n(t,[]);function n(r,o){let s=ur(r);if(s==="scalar"){let i=uo(r,e,o,t);fd.has(i)&&pi(e,i);return}if(s==="scalar-array"){let i=zo(r,e);i&&(pi(e,i.array),pi(e,i.item));return}if(s==="object"){for(let[i,l]of Object.entries(r))n(l,[...o,i]);return}if(s==="object-array"){let i=r[1],l=[...o,"*"];if(i&&typeof i=="object"&&!Array.isArray(i))for(let[a,u]of Object.entries(i))n(u,[...l,a]);else n(i,l)}}}function va(e,t,n){let r=_n(e,n);if(r)return r;let o=e.createElement("template");return o.setAttribute("data-hcms-tpl",n),o.setAttribute("save-remove",""),o.innerHTML=ba[n].trim(),t.appendChild(o),o}function _n(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${bd(t)}"]`)}function bd(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function ur(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function fo(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var wa={IMG:"src",A:"href"};function Yo(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":wa[t]?wa[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function Aa(e,t){let n=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),o=Yo(e),i=`${Ta(n,r)}[data-hcms-field="${Rr(t)}"]`;return n==="INPUT"&&r==="radio"?`${i}:checked@value`:o?`${i}@${o}`:i}function kd(e){let t=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),r=Yo(e),s=`${Ta(t,n)}[data-hcms-field]`;return t==="INPUT"&&n==="radio"?`${s}:checked@value`:r?`${s}@${r}`:s}function Ta(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 Rr(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Sa=new Set(["__proto__","constructor","prototype"]);function Xo(e,t){return n(e,[]);function n(u,d){let h=ur(u);if(h==="scalar")return r(u,d);if(h==="scalar-array")return o(u,d);if(h==="object-array")return s(u,d);if(h==="object"){let f=Object.create(null);for(let[p,b]of Object.entries(u)){if(Sa.has(p))throw new Error(`hypercms: rule key "${p}" is forbidden at "${d.join(".")||"<root>"}"`);f[p]=n(b,[...d,p])}return f}return null}function r(u,d){let h=d.length?d[d.length-1]:null,f=typeof h=="string"?h:"__value",p=a(d,f);if(p)return Aa(p,f);let b=l(uo(u,t,d,e),f);return b?Aa(b,f):`input[data-hcms-field="${Rr(f)}"]@value`}function o(u,d){let h=Vo(u,d,t),f=h&&l(h.item,null)||l("@scalar-array-item",null),p=f?kd(f):"input[data-hcms-field]@value";return[i(d,"[data-hcms-array-item]"),p]}function s(u,d){let[,h]=u,f=[...d,"*"],p=i(d,"[data-hcms-card]");if(h&&typeof h=="object"&&!Array.isArray(h)){let b=Object.create(null);for(let[v,m]of Object.entries(h)){if(Sa.has(v))throw new Error(`hypercms: rule key "${v}" is forbidden at "${f.join(".")}"`);b[v]=n(m,[...f,v])}return[p,b]}return[p,n(h,[...f,0])]}function i(u,d){let h=u.length?u[u.length-1]:"",f=u.some(v=>v==="*"),p=u.join(".");return`${f?`[data-hcms-field="${Rr(h)}"]`:`[data-hcms-path="${Rr(p)}"]`} > .hcms-array-items > ${d}`}function l(u,d){if(!t)return null;let h=_n(t,u);if(!h)return null;let f=h.content||h;if(d){let p=f.querySelector(`[data-hcms-field="${Rr(d)}"]`);if(p)return p}return f.querySelector("[data-hcms-field]")}function a(u,d){if(!t)return null;let h=u.map(b=>typeof b=="number"?"*":b).join("."),p=[u.join("."),h];for(let b=u.length-1;b>=0;b--){let v=u.slice(0,b).map(m=>typeof m=="number"?"*":m);v.push("*"),p.push(v.join("."))}for(let b of p){if(!b)continue;let v=_n(t,b);if(!v||!fo(v))continue;let m=v.content||v,g=m.querySelector(`[data-hcms-field="${Rr(d)}"]`)||m.querySelector("[data-hcms-field]");if(g)return g}return null}}function gi(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],n=t.split("/").pop()||t;try{return decodeURIComponent(n)}catch{return n}}function Lr({pageRules:e,formRules:t,data:n,doc:r}){let o=r.createDocumentFragment(),s=bi(e,[],n,r,e);return s&&o.appendChild(s),o}function _a({shape:e,itemShape:t,pathArr:n,data:r,doc:o,itemKey:s,pageRules:i}){if(e==="object-array-item")return Na(t,n,r,o,i);if(e==="scalar-array-item")return Ca(n,r,o,s||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function bi(e,t,n,r,o){let s=ur(e);return s==="scalar"?yd(e,t,n,r,o):s==="object"?Ad(e,t,n,r,o):s==="object-array"?Sd(e,t,n,r,o):s==="scalar-array"?Td(e,t,n,r):null}function yd(e,t,n,r,o){let s=uo(e,r,t,o),i=Mr(t,s,r);if(!i)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let l=ka(e,r,t,o);l==="@number"&&s==="@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`),(l==="@checkbox"||l==="@toggle")&&s==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "${l}" but its value isn't true/false; rendering a text input so the value is preserved`),Oa(i,l===s?l:null,t);let a=Ir(i,r);jr(a,t);let u=i.getAttribute?.("data-hcms-tpl");if((s==="@select"||s==="@radio")&&u===s&&xd(a,e,t,n,r,s,o),s==="@image"&&u==="@image"){let d=xa(e,r,t,o);d!=null&&!a.hasAttribute("data-hcms-crop")&&a.setAttribute("data-hcms-crop",d)}return Ed(a,Dn(t)),Jo(a,Dn(t)),Zo(a,Dn(t)),ja(a,n),s==="@file"&&wd(a),a}function Oa(e,t,n){if(!t)return;let r=e.getAttribute?.("data-hcms-tpl");r&&r!==t&&console.info(`[hypercms] field "${n.join(".")}" declares component "${t}" but custom template "${r}" wins`)}function xd(e,t,n,r,o,s,i){let l=ya(t,o,n,i),a=l?[...l]:[],u=r==null?"":String(r);if(u!==""&&!a.includes(u)&&a.unshift(u),!l&&(vd(e,"data-hcms-options required (space-separated values)"),a.length===0)){e.querySelector(".mirk-radio")?.remove();return}if(s==="@select"){let f=e.querySelector("select[data-hcms-field]");if(!f)return;for(let p of a){let b=o.createElement("option");b.value=p,b.textContent=$o(p),f.appendChild(b)}return}let d=e.querySelector(".mirk-radio");if(!d||!d.parentNode)return;let h=ki(n.join("."));for(let f of a){let p=d.cloneNode(!0),b=p.querySelector('input[type="radio"]');b&&(b.value=f,b.name=h);let v=p.querySelector(".mirk-radio__label");v&&(v.textContent=$o(f)),d.parentNode.insertBefore(p,d)}d.remove()}function ki(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function vd(e,t){let n=e.querySelector?e.querySelector(".hcms-error"):null;n&&(n.textContent=t,n.hidden=!1)}function wd(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=gi(t.getAttribute("href")))}function Ad(e,t,n,r,o){let s=Mr(t,"@object",r);if(!s)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let i=Ir(s,r);if(jr(i,t),Jo(i,Dn(t)),Zo(i,Dn(t)),fo(s))return Da(i,e,t),Pa(i,e,n),i;let l=Qo(i,".hcms-object-fields",s,t);for(let[a,u]of Object.entries(e)){let d=n==null?null:n[a],h=bi(u,[...t,a],d,r,o);h&&l.appendChild(h)}return i}function Sd(e,t,n,r,o){let s=Mr(t,"@object-array",r);if(!s)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let i=Ir(s,r);jr(i,t),Jo(i,Dn(t)),Zo(i,Dn(t)),Ra(i,s),Ia(i,s,t);let l=Qo(i,".hcms-array-items",s,t),[,a]=e;return(Array.isArray(n)?n:[]).forEach((d,h)=>{let f=Na(a,[...t,h],d,r,o);f&&l.appendChild(f)}),La(i),i}function Na(e,t,n,r,o){let s=Ma(t,"object-array-item",r);if(!s)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let i=Ir(s,r);if(i.setAttribute("data-hcms-card",""),i.classList.contains("hcms-card")||i.classList.add("hcms-card"),jr(i,t),fo(s))return e&&typeof e=="object"&&!Array.isArray(e)&&(Da(i,e,t),Pa(i,e,n)),i;let l=Qo(i,".hcms-card-fields",s,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[a,u]of Object.entries(e)){let d=n==null?null:n[a],h=bi(u,[...t,a],d,r,o);h&&l.appendChild(h)}return i}function Td(e,t,n,r){let o=zo(e,r),s=Vo(e,t,r),i=o?o.array:"@scalar-array",l=Mr(t,i,r);if(!l)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);Oa(l,o?o.array:null,t);let a=Ir(l,r);jr(a,t),Jo(a,Dn(t)),Zo(a,Dn(t)),Ra(a,l),Ia(a,l,t),s&&a.setAttribute("data-hcms-item-tpl",s.item);let u=Qo(a,".hcms-array-items",l,t);return(Array.isArray(n)?n:[]).forEach((h,f)=>{let p=Ca([...t,f],h,r,s?s.item:null);p&&u.appendChild(p)}),La(a),a}function Ca(e,t,n,r){let o=Ma(e,"scalar-array-item",n,r);if(!o)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let s=Ir(o,n);return s.setAttribute("data-hcms-array-item",""),s.classList.contains("hcms-array-item")||s.classList.add("hcms-array-item"),jr(s,e),ja(s,t),s}function Ma(e,t,n,r){let o=e.map(s=>typeof s=="number"?"*":s).join(".");return _n(n,o)||r&&_n(n,r)||_n(n,"@"+t)}function Ir(e,t){let n=e.content||e,r=t.createElement("div");return r.appendChild(n.cloneNode(!0)),r.firstElementChild||r}function jr(e,t){e.setAttribute("data-hcms-path",t.join("."))}function Ed(e,t){let n=t==null?"":String(t);if(e.matches&&e.matches("[data-hcms-field]")){e.getAttribute("data-hcms-field")||e.setAttribute("data-hcms-field",n);return}(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(o=>{o.getAttribute("data-hcms-field")||o.setAttribute("data-hcms-field",n)})}function Jo(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function Zo(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(r=>{(r.textContent||"").trim()===""&&(r.textContent=$o(String(t)))})}function Ra(e,t){["data-hcms-no-add","data-hcms-no-remove","data-hcms-no-reorder"].forEach(n=>{t.hasAttribute(n)&&e.setAttribute(n,"")}),["data-hcms-min-items","data-hcms-max-items"].forEach(n=>{t.hasAttribute(n)&&e.setAttribute(n,t.getAttribute(n))})}function La(e){let t=e.querySelector?e.querySelector(".hcms-array-items"):null;if(!t)return;let n=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),r=n.length,o=Ea(e,"data-hcms-max-items"),s=Ea(e,"data-hcms-min-items"),i=e.hasAttribute("data-hcms-no-add"),l=e.hasAttribute("data-hcms-no-remove"),a=e.hasAttribute("data-hcms-no-reorder"),u=e.querySelector('[data-hcms-action="add"]');u&&(u.hidden=i||o!=null&&r>=o),n.forEach((d,h)=>{let f=d.querySelector('[data-hcms-action="remove"]');f&&(f.hidden=l||s!=null&&r<=s);let p=d.querySelector('[data-hcms-action="move-up"]');p&&(p.hidden=a||h===0);let b=d.querySelector('[data-hcms-action="move-down"]');b&&(b.hidden=a||h===r-1)})}function Ea(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function Ia(e,t,n){if(e.hasAttribute("data-hcms-no-reorder")||t.hasAttribute("data-hcms-no-reorder"))return;let r=e.querySelector(".hcms-array-items");if(!r)return;let o="hcms-"+n.join(".");r.setAttribute("sortable",o),r.setAttribute("onsorted","hypercmsCommit && hypercmsCommit()")}function Dn(e){return e.length?e[e.length-1]:null}function ja(e,t){let n=_d(e);if(n.length!==0)for(let r of n)Fa(r,t)}function _d(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&Od(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(r=>t.push(r)),t}function Od(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function Pa(e,t,n){(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(o=>{let s=o.getAttribute("data-hcms-field");if(!s)return;if(!t||typeof t!="object"||!(s in t)){console.warn(`[hypercms] inline template field "${s}" is not in the rule shape; ignoring`);return}let i=n==null?null:n[s];Fa(o,i)})}function Da(e,t,n){if(!e.querySelectorAll)return;e.querySelectorAll("[data-hcms-field]").forEach(o=>{let s=o.getAttribute("data-hcms-field");if(!s||t&&typeof t=="object"&&!(s in t))return;let i=[...n,s].join(".");o.setAttribute("data-hcms-path",i)})}function Qo(e,t,n,r){if(!e.querySelector)return e;let o=e.querySelector(t);if(o)return o;let s=n?.getAttribute?.("data-hcms-tpl")||r.join(".");throw new Error(`hypercms: template "${s}" is in slotted mode but has no ${t} element`)}function Fa(e,t){let n=Yo(e),r=(e.tagName||"").toUpperCase(),o=(e.getAttribute("type")||"").toLowerCase();if(r==="INPUT"&&o==="radio"){e.checked=e.value!=null&&String(e.value)===String(t??"");return}if(n==="checked"){e.checked=t===!0||t==="true";return}if(n){e[n]=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var Nd={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?Md(t.uploadFileBasic):null)},Cd={402:"payment-required",413:"too-large",415:"unsupported-type",401:"unauthorized",403:"forbidden",404:"not-found"},yi=()=>({ok:!1,msg:"Upload cancelled",msgType:"skipped",code:"aborted",uploads:[]});function Md(e){return async function(n,{onProgress:r,signal:o}={}){if(o?.aborted)return yi();try{let s=await e(n,{onProgress:l=>{r?.({loaded:null,total:null,percent:l})}});if(o?.aborted)return yi();let i=s&&s.uploads||[];return typeof i[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:s.msg||"Uploaded",msgType:s.msgType||"success",code:s.code||null,uploads:i}}catch(s){if(o?.aborted)return yi();let i={};try{i=JSON.parse(s?.response||"{}")}catch{i={}}let l=i.code||Cd[s?.status]||"error";return{ok:!1,msg:s&&s.message||"Upload failed",msgType:"error",code:l,uploads:[]}}}}function Jt(e,t){let n=Nd[e];if(!n)throw new Error(`hypercms: unknown platform capability "${e}"`);let r=t||(typeof window<"u"?window:null);return r&&n(r.clay,r.hyperclay)||null}var qa=["clay:mutation-ready","hyperclay:mutation-ready"],Ba=["clay:sync-applied","hyperclay:livesync-applied"],Ha=["clay:ready","hyperclay:ready"];function Pr(e,t,n){let r=null,o=s=>{r!==null&&r!==s.type||(r=s.type,queueMicrotask(()=>{r=null}),n(s))};for(let s of t)e.addEventListener(s,o);return()=>{for(let s of t)e.removeEventListener(s,o)}}var On="data-hcms-bound",Yn="data-hcms-bound-id",xi=new Map;function $a(e,t){xi.set(e,t)}function Ua(e){xi.delete(e)}function za(e){let t=e.getAttribute(Yn);if(!t)return null;let n=xi.get(t);return!n||!n.restorable()?null:n.originalHTML}var fr="data-hcms-owns-richclay";function Dr(e){return e&&e.richclay&&e.richclay.RichClay||Jt("RichClay",e)||(e&&typeof e.RichClay=="function"?e.RichClay:null)}function Va(e,t,n){!e||typeof e.setAttribute!="function"||(e.setAttribute(On,t?"rich":"plain"),n&&e.setAttribute(fr,"true"))}function Wa(e,t){if(!e||typeof e.querySelectorAll!="function")return;let n=e.querySelectorAll(`[${On}]`);if(!n.length)return;let r=Dr(t);if(r&&typeof r.stripFromClone=="function")try{r.stripFromClone(e)}catch(o){console.warn("[hypercms] richclay strip failed; editor state may reach the save",o)}for(let o of n)o.getAttribute(fr)==="true"&&o.removeAttribute("data-richclay"),o.removeAttribute(fr),o.removeAttribute(On)}function Ka(e,t){if(!e||typeof e.removeAttribute!="function")return;let n=Dr(t);if(n&&typeof n.stripElement=="function")try{n.stripElement(e)}catch(r){console.warn("[hypercms] richclay element strip failed; the clone stays editable",r)}else e.removeAttribute("contenteditable"),e.removeAttribute("no-undo");e.getAttribute(fr)==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute(fr),e.removeAttribute(On),e.removeAttribute(Yn)}function Ga(e,t){if(!t||e==null)return e;return n(e);function n(r){if(typeof r=="string"){if(r.endsWith("[]")||Vt(r)!==-1)return r;let o=null;try{o=t.querySelector(r)}catch{return r}return o&&o.children.length>0?r+"@innerHTML":r}if(Array.isArray(r))return r;if(r&&typeof r=="object"){let o=Object.create(null);for(let[s,i]of Object.entries(r))o[s]=n(i);return o}return r}}function Ya(e,t){if(!t||e==null)return e;return n(e,[t]);function n(r,o){if(typeof r=="string")return r.endsWith("[]")||Vt(r)!==-1?r:o.some(s=>Rd(s,r))?r+"@innerHTML":r;if(Array.isArray(r)){let[s,i]=r;if(typeof s!="string"||!s)return r;let l=Ld(t,s);return l.length?[s,n(i,l)]:r}if(r&&typeof r=="object"){let s=Object.create(null);for(let[i,l]of Object.entries(r))s[i]=n(l,o);return s}return r}}function Rd(e,t){let n=null;try{n=e.querySelector(t)}catch{return!1}return n?n.hasAttribute(On)?n.getAttribute(On)==="rich":n.children.length>0:!1}function Ld(e,t){try{return[...e.querySelectorAll(t)]}catch{return[]}}function Fr(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 Xn(e,t,n=!0){if(!e||!e.querySelectorAll||(e.querySelectorAll("textarea[data-hcms-field]").forEach(Fr),n===!1))return;let r=t&&t.defaultView||(typeof window<"u"?window:null),o=Dr(r);o&&e.querySelectorAll("[contenteditable][data-hcms-field]").forEach(s=>{if(s.__hcmsRichclay)return;let i;try{i=new o(s,{inline:!0,hyperclay:!1,toolbar:["bold","italic","link","undo","redo"]})}catch(a){console.warn("[hypercms] richclay activation failed; field stays plain contenteditable",a);return}s.__hcmsRichclay=i;let l=i&&i.squire;l&&typeof l.addEventListener=="function"&&l.addEventListener("input",()=>{let a=r&&r.Event||Event;s.dispatchEvent(new a("input",{bubbles:!0}))})})}var vi=new WeakSet;function dr(e,t){let n=Jt("undo");if(!n)return t();n.pause();try{let r=t();return r&&r.ok?n.commitCaptured(e):n.discardCaptured(),r}finally{n.resume()}}function Fn(e){let t=Jt("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function ns(e){let{formRoot:t}=e;if(!t||vi.has(t))return;vi.add(t);let n=i=>{let l=i.target;!l||!l.closest||l.closest("[data-hcms-form-root]")&&l.matches("input, textarea, select, [contenteditable][data-hcms-field]")&&(l.tagName==="TEXTAREA"&&Fr(l),!l.matches('input[type="file"]')&&(!l.closest("[data-hcms-field]")&&!l.hasAttribute?.("data-hcms-field")||Xa(l,e)))},r=i=>{let l=i.target;if(!(!l||!l.closest)&&l.closest("[data-hcms-form-root]")){if(l.matches('input[type="file"][data-hcms-upload]')){Hd(l,e);return}l.matches('input[type="checkbox"], input[type="radio"], select')&&Xa(l,e)}},o=i=>{let l=i.target;if(!l||!l.closest)return;let a=l.closest("[data-hcms-action]");if(!a)return;let u=a.getAttribute("data-hcms-action");if(u==="add"||u==="remove"||u==="move-up"||u==="move-down"||u==="clear-upload"){if(!a.closest("[data-hcms-form-root]"))return}else if(u==="close"&&!a.closest("[data-hcms-shell]"))return;if(u==="add"){let d=a.closest("[data-hcms-path]");if(!d)return;let h=d.getAttribute("data-hcms-path");ho(h,e)}else if(u==="remove"){let d=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!d)return;Si(d,e)}else if(u==="move-up"||u==="move-down"){let d=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!d)return;Ai(d,u==="move-up"?-1:1,e)}else u==="clear-upload"?Vd(a,e):u==="close"&&e.onCloseRequested?.()},s=t.ownerDocument;s.addEventListener("input",n,!0),s.addEventListener("change",r,!0),s.addEventListener("click",o,!0),e.detachEvents=()=>{s.removeEventListener("input",n,!0),s.removeEventListener("change",r,!0),s.removeEventListener("click",o,!0),vi.delete(t)}}var Id=new Set(["value","checked"]);function jd(e,t){if(!t)return null;let n=Pn(t);if(n.some(a=>typeof a=="number"||a==="*"))return null;let r=cr(e.pageRules,n);if(typeof r!="string")return null;let o=ln.ruleAttrIndex(r);if(o===-1)return null;let s=r.slice(o+1);if(!Id.has(s))return null;let i=r.slice(0,o),l=i?e.pageRoot.querySelector(i):e.pageRoot;return l?{el:l,prop:s,oldValue:l[s]}:null}function Xa(e,t){let r=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",o=jd(t,r);if(kn(fn(t),{path:r,structural:!1},t),o){let s=Jt("undo");s&&typeof s.recordValue=="function"&&s.recordValue(o.el,{prop:o.prop,oldValue:o.oldValue,newValue:o.el[o.prop]})}}var Pd={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function Dd(e,t){let n=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(n==null)return{file:e};let r=Jt("quickcrop");if(typeof r!="function")return{file:e};try{let o=typeof window<"u"&&(window.clay?.modal??window.themodal)||"auto",s=await r(e,{aspect:Fd(n),modal:o,...Pd});return s===null?null:{file:qd(s.blob,e.name),dataURL:s.dataURL}}catch(o){return Br(t,o&&o.message||"Crop failed"),null}}function Fd(e){let t=String(e??"").trim().toLowerCase();if(t===""||t==="free")return null;let n=t.match(/^(\d+(?:\.\d+)?)\s*[:/]\s*(\d+(?:\.\d+)?)$/);if(!n)return null;let r=parseFloat(n[1]),o=parseFloat(n[2]);return!r||!o?null:r/o}function qd(e,t){let n=e.type==="image/webp"?".webp":e.type==="image/jpeg"?".jpg":".png",r=String(t||"image").replace(/\.[^.]+$/,"");try{return new File([e],r+n,{type:e.type})}catch{return e}}var Bd=new Set(["unsupported","payment-required"]);async function Hd(e,t){let n=e.files&&e.files[0];if(!n)return;let r=e.closest("[data-hcms-path]");if(!r)return;let o=r.getAttribute("data-hcms-path")||"";Br(r,null);let s=await Dd(n,r);if(!s||t.closed){Jn(e);return}let i=s.file,l=s.dataURL||null,a=Jt("upload");if(typeof a!="function")return wi(e,r,t,o,await Ja(i,l,r),i);tc(r,l),Za(r,0);let u=Ud(t),d;try{d=await a(i,{signal:u?.signal,onProgress:({percent:f})=>Za(r,f)})}finally{zd(t,u),Kd(r)}if(t.closed){Jn(e);return}if(d.code==="aborted"){Jn(e);return}if(d.ok)return wi(e,r,t,o,d.uploads[0].url,i);if(!Bd.has(d.code)){Br(r,d.msg||"Upload failed"),t.dispatch?.("hcms:error",{error:new Error(d.msg||"Upload failed"),code:d.code,path:o}),Jn(e);return}let h=d.code==="payment-required"?"This file is stored in the page. Add a paid plan to upload files.":null;return wi(e,r,t,o,await Ja(i,l,r),i,h)}function wi(e,t,n,r,o,s,i=null){if(n.closed){Jn(e);return}if(tc(t,null),Br(t,null),!o){Jn(e);return}ec(t,o,s.name),kn(fn(n),{path:r,structural:!1},n),i&&Br(t,i,"info"),Jn(e)}async function Ja(e,t,n){return t||await $d(e,n)}function $d(e,t){let n=t?.ownerDocument?.defaultView?.FileReader||globalThis.FileReader;return n?new Promise(r=>{let o=new n;o.onload=()=>r(typeof o.result=="string"?o.result:""),o.onerror=()=>r("");try{o.readAsDataURL(e)}catch{r("")}}):Promise.resolve("")}function Ud(e){if(typeof AbortController!="function")return null;let t=new AbortController;return(e.uploads||(e.uploads=new Set)).add(t),t}function zd(e,t){t&&e.uploads?.delete(t)}function Vd(e,t){let n=e.closest("[data-hcms-path]");if(!n)return;let r=n.getAttribute("data-hcms-path")||"";ec(n,"","");let o=n.querySelector('input[type="file"][data-hcms-upload]');o&&Jn(o),Br(n,null),kn(fn(t),{path:r,structural:!1},t)}function Wd(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function ec(e,t,n){let r=Wd(e);if(!r)return;let o=(r.tagName||"").toUpperCase();o==="IMG"?r.src=t||"":o==="A"&&(r.href=t||"",r.textContent=t?n||gi(t):"")}function Jn(e){try{e.value=""}catch{}}function tc(e,t){let n=e.querySelector?e.querySelector(".mirk-image__frame"):null;n&&(t?n.style.backgroundImage=`url("${t.replace(/"/g,"%22")}")`:n.style.removeProperty("background-image"))}function Za(e,t){let n=Math.max(0,Math.min(100,Number(t)||0));e.setAttribute("data-hcms-uploading",""),e.style?.setProperty?.("--hcms-upload-progress",`${n}%`)}function Kd(e){e.removeAttribute("data-hcms-uploading"),e.style?.removeProperty?.("--hcms-upload-progress")}function Br(e,t,n="error"){let r=e.querySelector?e.querySelector(":scope > .hcms-error"):null;r&&(r.classList.toggle("hcms-error--info",!!t&&n==="info"),t?(r.textContent=t,r.hidden=!1):(r.textContent="",r.hidden=!0))}function ho(e,t){let{formRoot:n,pageRules:r}=t,o=n.querySelector(`[data-hcms-path="${Hr(e)}"]`);if(!o)throw new Error(`hypercms: no element at path "${e}"`);let s=o.querySelector(".hcms-array-items");if(!s)throw new Error(`hypercms: array container missing .hcms-array-items at "${e}"`);let i=Pn(e),l=Zd(r,i),a=Array.isArray(l),u=typeof l=="string"&&l.endsWith("[]");if(!a&&!u)throw new Error(`hypercms: path "${e}" is not an array`);let d=ts(o,"data-hcms-max-items"),h=s.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(o.hasAttribute("data-hcms-no-add")||d!=null&&h.length>=d)return;let f=h.length,p=a?l[1]:l.replace(/\[\]$/,""),b=co(a?p:"string"),v=_a({shape:a?"object-array-item":"scalar-array-item",itemShape:p,pathArr:[...i,f],data:b,doc:t.doc,itemKey:o.getAttribute("data-hcms-item-tpl")||null,pageRules:r});return s.appendChild(v),Xn(v,t.doc,t.view?.enhanceFormRichText!==!1),Ei(o),dr(`Add ${e}`,()=>kn(fn(t),{path:e,structural:!0},t))}function Ai(e,t,n){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!r||r.hasAttribute("data-hcms-no-reorder"))return;let o=r.querySelector(".hcms-array-items");if(!o)return;let s=Array.from(o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),i=s.indexOf(e);if(i<0)return;let l=i+t;if(l<0||l>=s.length)return;let a=e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`);return t<0?o.insertBefore(e,s[l]):o.insertBefore(e,s[l].nextSibling),_i(o),Ei(r),a&&typeof a.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),dr(`Reorder ${r.getAttribute("data-hcms-path")||""}`,()=>kn(fn(n),{path:r.getAttribute("data-hcms-path")||"",structural:!0},n))}var es="Delete this item?";function Gd(e,t){let n=e&&e.getAttribute("data-hcms-confirm-remove");if(n!=null)return/^(off|false|no|0)$/i.test(n.trim())?null:n||es;let r=t&&t.confirmRemove;return r===!1?null:typeof r=="string"?r||es:r===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?es:null}function Si(e,t){let n=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),r=Gd(n,t);if(r==null)return qr(e,t);let o=Jt("consent")||typeof window<"u"&&window.consent;typeof o=="function"?Promise.resolve(o(r)).then(()=>{t.closed||qr(e,t)},()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(r)&&qr(e,t):qr(e,t)}function qr(e,t){let n=e.getAttribute("data-hcms-path")||"",r=e.parentElement,o=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!o?.hasAttribute("data-hcms-no-remove")){if(o){let s=ts(o,"data-hcms-min-items"),i=o.querySelector(".hcms-array-items"),l=i?i.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]").length:0;if(s!=null&&l<=s)return}return e.remove(),r&&_i(r),o&&Ei(o),dr(`Remove ${n}`,()=>kn(fn(t),{path:n,structural:!0},t))}}function kn(e,t,n){if(n.closed)return{ok:!1,skipped:!0,closed:!0};let r=mo(e);if(!t.structural&&r===n.lastFingerprint)return{ok:!0,skipped:!0};let o=Object.hasOwn(n,"writeRules")?n.writeRules:n.pageRules,s=da(n.pageRoot,o,e,{shellRoot:n.shellRoot,structural:!!t.structural,structuralPath:t.path||null,formRoot:n.formRoot});return s.ok?(n.lastFingerprint=r,n.lastData=e,Qa(n,null),n.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),n.onChange?.(e,t)):(Qa(n,Jd(s.error,t.path)),n.dispatch?.("hcms:error",{error:s.error,attemptedData:e}),n.onError?.(s.error)),s}function rs(e,t){let n=Hr(t),r=`[data-hcms-path="${n}"] input[data-hcms-field], [data-hcms-path="${n}"] textarea[data-hcms-field], [data-hcms-path="${n}"] select[data-hcms-field], [data-hcms-path="${n}"] img[data-hcms-field], [data-hcms-path="${n}"] a[data-hcms-field], [data-hcms-path="${n}"] [contenteditable][data-hcms-field], input[data-hcms-path="${n}"][data-hcms-field], textarea[data-hcms-path="${n}"][data-hcms-field], select[data-hcms-path="${n}"][data-hcms-field], img[data-hcms-path="${n}"][data-hcms-field], a[data-hcms-path="${n}"][data-hcms-field], [contenteditable][data-hcms-path="${n}"][data-hcms-field]`;return e.querySelector(r)}function os(e,t,n,r){let o=(e.tagName||"").toUpperCase(),s=(e.getAttribute("type")||"").toLowerCase();if(o==="INPUT"&&s==="checkbox"){e.checked=t===!0||t==="true";return}if(o==="INPUT"&&s==="radio"){let i=Hr(r),l=n.querySelectorAll(`[data-hcms-path="${i}"][data-hcms-field][type="radio"], [data-hcms-path="${i}"] [data-hcms-field][type="radio"]`);l.length?l.forEach(a=>{a.checked=String(a.value)===String(t??"")}):e.checked=String(e.value)===String(t??"");return}if(o==="IMG"){e.src=t==null?"":String(t);return}if(o==="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 fn(e){let t=ln.extract(e.formRoot,e.formRules,{exclude:null});return Zn(t,e.formRules)}function Zn(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[,n]=t;return e.map(r=>Zn(r,n))}if(typeof t=="object"){if(typeof e!="object"||Array.isArray(e))return e;let n={};for(let[r,o]of Object.entries(t))n[r]=Zn(e[r],o);return n}return e}function Qa(e,t){e.lastErrors=t&&t.length?t:null,Ti(e)}function Ti(e){if(Yd(e),e.errorEl&&(e.errorEl.textContent="",e.errorEl.hidden=!0),!e.lastErrors)return;let t=[];for(let{message:n,path:r}of e.lastErrors){if(r!=null&&r!==""){let o=Xd(e.formRoot,r);if(o){o.textContent=o.textContent?`${o.textContent}
152
+ `},vh=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function cs(e){let t=e.head||e.documentElement;if(t)for(let n of vh)hc(e,t,n)}function $i(e,t){if(!cc[t])return null;let n=e&&(e.head||e.documentElement);return n?hc(e,n,t):null}var lc={src:"@image",checked:"@checkbox",innerHTML:"@richtext"},ls={image:"@image",file:"@file",checkbox:"@checkbox",toggle:"@toggle",select:"@select",radio:"@radio",textarea:"@textarea",number:"@number",richtext:"@richtext"},wh=new Set([...Object.values(ls),"@chips","@chips-item"]);function No(e,t,n,r){if(typeof e!="string")return"@scalar";let o=rn(e),s=ds(e,o,n,r),l=hs(s,t,"data-hcms-component");if(l&&ls[l]){let i=ls[l],a=Array.isArray(n)&&n.some(c=>c==="*"||typeof c=="number");return i==="@number"&&!ac(e,o,t,a,s).every(Sh)||(i==="@checkbox"||i==="@toggle")&&(o<0||e.slice(o+1)!=="checked")&&!ac(e,o,t,a,s).every(Th)?"@scalar":i}if(o>=0){let i=e.slice(o+1);if(lc[i])return lc[i]}return"@scalar"}function fc(e,t,n,r){if(typeof e!="string")return null;let o=rn(e),s=hs(ds(e,o,n,r),t,"data-hcms-component");return s&&ls[s]||null}var Ah=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function Sh(e){return e==null||e===""?!0:Ah.test(String(e))}function Th(e){return e==null||e===""||e==="true"||e==="false"}function ac(e,t,n,r,o){if(!n||!n.querySelectorAll)return[];if(!o||o===".")return[];let s=null;try{s=n.querySelectorAll(o)}catch{return[]}let l=t>=0?e.slice(t+1):null,i=[];for(let a of s)if(!(a.closest&&a.closest("[cms-template], [data-hcms-shell]"))&&(l?l==="value"&&"value"in a?i.push(a.value):i.push(a.getAttribute?a.getAttribute(l):null):i.push((a.textContent||"").trim()),!r))break;return i}function fs(e,t){if(typeof e!="string"||!e.endsWith("[]")||!t||!t.querySelector)return null;let n=e.slice(0,-2).trim();if(!n)return null;let r=null;try{r=t.querySelector(n)}catch{return null}let o=r&&r.closest?r.closest("[data-hcms-component]"):null;return(o&&o.getAttribute?o.getAttribute("data-hcms-component"):null)==="chips"?{array:"@chips",item:"@chips-item"}:null}function Gr(e,t,n){let r=e.join("."),o=e.map(s=>typeof s=="number"?"*":s).join(".");return r&&Dn(n,r)||o&&o!==r&&Dn(n,o)||Dn(n,t)}function us(e,t,n){let r=fs(e,n);if(!r)return null;let o=Gr(t,r.array,n);return o&&o.getAttribute("data-hcms-tpl")===r.array?r:null}function uc(e,t,n,r){if(typeof e!="string")return null;let o=rn(e),s=hs(ds(e,o,n,r),t,"data-hcms-options");if(s==null)return null;let l=s.trim().split(/\s+/).filter(Boolean);return l.length?l:null}function dc(e,t,n,r){if(typeof e!="string")return null;let o=rn(e);return hs(ds(e,o,n,r),t,"data-hcms-crop")}function Eh(e,t){return t>=0?e.slice(0,t):e}function ds(e,t,n,r){let o=Eh(e,t);return o&&o!=="."?o:_h(r,n)}function _h(e,t){if(e==null||!Array.isArray(t))return"";let n=[],r=e;for(let o of t){if(r==null||typeof r=="string")break;if(Array.isArray(r)){if(typeof r[0]!="string"||o!=="*"&&typeof o!="number")return"";n.push(r[0]),r=r[1];continue}if(typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,o))return"";r=r[o]}return n.join(" ")}function hs(e,t,n){if(!t||!t.querySelector||!e||e===".")return null;let r=null;try{r=t.querySelector(e)}catch{return null}return r&&r.getAttribute?r.getAttribute(n):null}function ms(e,t){if(!e||t==null)return;n(t,[]);function n(r,o){let s=Sr(r);if(s==="scalar"){let l=No(r,e,o,t);wh.has(l)&&$i(e,l);return}if(s==="scalar-array"){let l=fs(r,e);l&&($i(e,l.array),$i(e,l.item));return}if(s==="object"){for(let[l,i]of Object.entries(r))n(i,[...o,l]);return}if(s==="object-array"){let l=r[1],i=[...o,"*"];if(l&&typeof l=="object"&&!Array.isArray(l))for(let[a,c]of Object.entries(l))n(c,[...i,a]);else n(l,i)}}}function hc(e,t,n){let r=Dn(e,n);if(r)return r;let o=e.createElement("template");return o.setAttribute("data-hcms-tpl",n),o.setAttribute("save-remove",""),o.innerHTML=cc[n].trim(),t.appendChild(o),o}function Dn(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${Oh(t)}"]`)}function Oh(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function Sr(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function Co(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var mc={IMG:"src",A:"href"};function ps(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":mc[t]?mc[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function pc(e,t){let n=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),o=ps(e),l=`${bc(n,r)}[data-hcms-field="${Yr(t)}"]`;return n==="INPUT"&&r==="radio"?`${l}:checked@value`:o?`${l}@${o}`:l}function Nh(e){let t=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),r=ps(e),s=`${bc(t,n)}[data-hcms-field]`;return t==="INPUT"&&n==="radio"?`${s}:checked@value`:r?`${s}@${r}`:s}function bc(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 Yr(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var gc=new Set(["__proto__","constructor","prototype"]);function gs(e,t){return n(e,[]);function n(c,h){let u=Sr(c);if(u==="scalar")return r(c,h);if(u==="scalar-array")return o(c,h);if(u==="object-array")return s(c,h);if(u==="object"){let f=Object.create(null);for(let[d,p]of Object.entries(c)){if(gc.has(d))throw new Error(`hypercms: rule key "${d}" is forbidden at "${h.join(".")||"<root>"}"`);f[d]=n(p,[...h,d])}return f}return null}function r(c,h){let u=h.length?h[h.length-1]:null,f=typeof u=="string"?u:"__value",d=a(h,f);if(d)return pc(d,f);let p=i(No(c,t,h,e),f);return p?pc(p,f):`input[data-hcms-field="${Yr(f)}"]@value`}function o(c,h){let u=us(c,h,t),f=u&&i(u.item,null)||i("@scalar-array-item",null),d=f?Nh(f):"input[data-hcms-field]@value";return[l(h,"[data-hcms-array-item]"),d]}function s(c,h){let[,u]=c,f=[...h,"*"],d=l(h,"[data-hcms-card]");if(u&&typeof u=="object"&&!Array.isArray(u)){let p=Object.create(null);for(let[y,m]of Object.entries(u)){if(gc.has(y))throw new Error(`hypercms: rule key "${y}" is forbidden at "${f.join(".")}"`);p[y]=n(m,[...f,y])}return[d,p]}return[d,n(u,[...f,0])]}function l(c,h){let u=c.length?c[c.length-1]:"",f=c.some(y=>y==="*"),d=c.join(".");return`${f?`[data-hcms-field="${Yr(u)}"]`:`[data-hcms-path="${Yr(d)}"]`} > .hcms-array-items > ${h}`}function i(c,h){if(!t)return null;let u=Dn(t,c);if(!u)return null;let f=u.content||u;if(h){let d=f.querySelector(`[data-hcms-field="${Yr(h)}"]`);if(d)return d}return f.querySelector("[data-hcms-field]")}function a(c,h){if(!t)return null;let u=c.map(p=>typeof p=="number"?"*":p).join("."),d=[c.join("."),u];for(let p=c.length-1;p>=0;p--){let y=c.slice(0,p).map(m=>typeof m=="number"?"*":m);y.push("*"),d.push(y.join("."))}for(let p of d){if(!p)continue;let y=Dn(t,p);if(!y||!Co(y))continue;let m=y.content||y,g=m.querySelector(`[data-hcms-field="${Yr(h)}"]`)||m.querySelector("[data-hcms-field]");if(g)return g}return null}}function Hi(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],n=t.split("/").pop()||t;try{return decodeURIComponent(n)}catch{return n}}function Xr({pageRules:e,formRules:t,data:n,doc:r}){let o=r.createDocumentFragment(),s=zi(e,[],n,r,e);return s&&o.appendChild(s),o}function yc({shape:e,itemShape:t,pathArr:n,data:r,doc:o,itemKey:s,pageRules:l}){if(e==="object-array-item")return vc(t,n,r,o,l);if(e==="scalar-array-item")return wc(n,r,o,s||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function zi(e,t,n,r,o){let s=Sr(e);return s==="scalar"?Ch(e,t,n,r,o):s==="object"?Lh(e,t,n,r,o):s==="object-array"?jh(e,t,n,r,o):s==="scalar-array"?Ph(e,t,n,r):null}function Ch(e,t,n,r,o){let s=No(e,r,t,o),l=Gr(t,s,r);if(!l)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let i=fc(e,r,t,o);i==="@number"&&s==="@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`),(i==="@checkbox"||i==="@toggle")&&s==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "${i}" but its value isn't true/false; rendering a text input so the value is preserved`),xc(l,i===s?i:null,t);let a=Jr(l,r);Zr(a,t);let c=l.getAttribute?.("data-hcms-tpl");if((s==="@select"||s==="@radio")&&c===s&&Mh(a,e,t,n,r,s,o),s==="@image"&&c==="@image"){let h=dc(e,r,t,o);h!=null&&!a.hasAttribute("data-hcms-crop")&&a.setAttribute("data-hcms-crop",h)}return Dh(a,Zn(t)),bs(a,Zn(t)),ks(a,Zn(t)),_c(a,n),s==="@file"&&Ih(a),a}function xc(e,t,n){if(!t)return;let r=e.getAttribute?.("data-hcms-tpl");r&&r!==t&&console.info(`[hypercms] field "${n.join(".")}" declares component "${t}" but custom template "${r}" wins`)}function Mh(e,t,n,r,o,s,l){let i=uc(t,o,n,l),a=i?[...i]:[],c=r==null?"":String(r);if(c!==""&&!a.includes(c)&&a.unshift(c),!i&&(Rh(e,"data-hcms-options required (space-separated values)"),a.length===0)){e.querySelector(".mirk-radio")?.remove();return}if(s==="@select"){let f=e.querySelector("select[data-hcms-field]");if(!f)return;for(let d of a){let p=o.createElement("option");p.value=d,p.textContent=as(d),f.appendChild(p)}return}let h=e.querySelector(".mirk-radio");if(!h||!h.parentNode)return;let u=Vi(n.join("."));for(let f of a){let d=h.cloneNode(!0),p=d.querySelector('input[type="radio"]');p&&(p.value=f,p.name=u);let y=d.querySelector(".mirk-radio__label");y&&(y.textContent=as(f)),h.parentNode.insertBefore(d,h)}h.remove()}function Vi(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function Rh(e,t){let n=e.querySelector?e.querySelector(".hcms-error"):null;n&&(n.textContent=t,n.hidden=!1)}function Ih(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=Hi(t.getAttribute("href")))}function Lh(e,t,n,r,o){let s=Gr(t,"@object",r);if(!s)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let l=Jr(s,r);if(Zr(l,t),bs(l,Zn(t)),ks(l,Zn(t)),Co(s))return Nc(l,e,t),Oc(l,e,n),l;let i=ys(l,".hcms-object-fields",s,t);for(let[a,c]of Object.entries(e)){let h=n==null?null:n[a],u=zi(c,[...t,a],h,r,o);u&&i.appendChild(u)}return l}function jh(e,t,n,r,o){let s=Gr(t,"@object-array",r);if(!s)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let l=Jr(s,r);Zr(l,t),bs(l,Zn(t)),ks(l,Zn(t)),Sc(l,s),Ec(l,s,t);let i=ys(l,".hcms-array-items",s,t),[,a]=e;return(Array.isArray(n)?n:[]).forEach((h,u)=>{let f=vc(a,[...t,u],h,r,o);f&&i.appendChild(f)}),Tc(l),l}function vc(e,t,n,r,o){let s=Ac(t,"object-array-item",r);if(!s)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let l=Jr(s,r);if(l.setAttribute("data-hcms-card",""),l.classList.contains("hcms-card")||l.classList.add("hcms-card"),Zr(l,t),Co(s))return e&&typeof e=="object"&&!Array.isArray(e)&&(Nc(l,e,t),Oc(l,e,n)),l;let i=ys(l,".hcms-card-fields",s,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[a,c]of Object.entries(e)){let h=n==null?null:n[a],u=zi(c,[...t,a],h,r,o);u&&i.appendChild(u)}return l}function Ph(e,t,n,r){let o=fs(e,r),s=us(e,t,r),l=o?o.array:"@scalar-array",i=Gr(t,l,r);if(!i)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);xc(i,o?o.array:null,t);let a=Jr(i,r);Zr(a,t),bs(a,Zn(t)),ks(a,Zn(t)),Sc(a,i),Ec(a,i,t),s&&a.setAttribute("data-hcms-item-tpl",s.item);let c=ys(a,".hcms-array-items",i,t);return(Array.isArray(n)?n:[]).forEach((u,f)=>{let d=wc([...t,f],u,r,s?s.item:null);d&&c.appendChild(d)}),Tc(a),a}function wc(e,t,n,r){let o=Ac(e,"scalar-array-item",n,r);if(!o)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let s=Jr(o,n);return s.setAttribute("data-hcms-array-item",""),s.classList.contains("hcms-array-item")||s.classList.add("hcms-array-item"),Zr(s,e),_c(s,t),s}function Ac(e,t,n,r){let o=e.map(s=>typeof s=="number"?"*":s).join(".");return Dn(n,o)||r&&Dn(n,r)||Dn(n,"@"+t)}function Jr(e,t){let n=e.content||e,r=t.createElement("div");return r.appendChild(n.cloneNode(!0)),r.firstElementChild||r}function Zr(e,t){e.setAttribute("data-hcms-path",t.join("."))}function Dh(e,t){let n=t==null?"":String(t);if(e.matches&&e.matches("[data-hcms-field]")){e.getAttribute("data-hcms-field")||e.setAttribute("data-hcms-field",n);return}(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(o=>{o.getAttribute("data-hcms-field")||o.setAttribute("data-hcms-field",n)})}function bs(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function ks(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(r=>{(r.textContent||"").trim()===""&&(r.textContent=as(String(t)))})}function Sc(e,t){["data-hcms-no-add","data-hcms-no-remove","data-hcms-no-reorder"].forEach(n=>{t.hasAttribute(n)&&e.setAttribute(n,"")}),["data-hcms-min-items","data-hcms-max-items"].forEach(n=>{t.hasAttribute(n)&&e.setAttribute(n,t.getAttribute(n))})}function Tc(e){let t=e.querySelector?e.querySelector(".hcms-array-items"):null;if(!t)return;let n=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),r=n.length,o=kc(e,"data-hcms-max-items"),s=kc(e,"data-hcms-min-items"),l=e.hasAttribute("data-hcms-no-add"),i=e.hasAttribute("data-hcms-no-remove"),a=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector('[data-hcms-action="add"]');c&&(c.hidden=l||o!=null&&r>=o),n.forEach((h,u)=>{let f=h.querySelector('[data-hcms-action="remove"]');f&&(f.hidden=i||s!=null&&r<=s);let d=h.querySelector('[data-hcms-action="move-up"]');d&&(d.hidden=a||u===0);let p=h.querySelector('[data-hcms-action="move-down"]');p&&(p.hidden=a||u===r-1)})}function kc(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function Ec(e,t,n){if(e.hasAttribute("data-hcms-no-reorder")||t.hasAttribute("data-hcms-no-reorder"))return;let r=e.querySelector(".hcms-array-items");if(!r)return;let o="hcms-"+n.join(".");r.setAttribute("sortable",o),r.setAttribute("onsorted","hypercmsCommit && hypercmsCommit()")}function Zn(e){return e.length?e[e.length-1]:null}function _c(e,t){let n=Fh(e);if(n.length!==0)for(let r of n)Cc(r,t)}function Fh(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&Bh(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(r=>t.push(r)),t}function Bh(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function Oc(e,t,n){(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(o=>{let s=o.getAttribute("data-hcms-field");if(!s)return;if(!t||typeof t!="object"||!(s in t)){console.warn(`[hypercms] inline template field "${s}" is not in the rule shape; ignoring`);return}let l=n==null?null:n[s];Cc(o,l)})}function Nc(e,t,n){if(!e.querySelectorAll)return;e.querySelectorAll("[data-hcms-field]").forEach(o=>{let s=o.getAttribute("data-hcms-field");if(!s||t&&typeof t=="object"&&!(s in t))return;let l=[...n,s].join(".");o.setAttribute("data-hcms-path",l)})}function ys(e,t,n,r){if(!e.querySelector)return e;let o=e.querySelector(t);if(o)return o;let s=n?.getAttribute?.("data-hcms-tpl")||r.join(".");throw new Error(`hypercms: template "${s}" is in slotted mode but has no ${t} element`)}function Cc(e,t){let n=ps(e),r=(e.tagName||"").toUpperCase(),o=(e.getAttribute("type")||"").toLowerCase();if(r==="INPUT"&&o==="radio"){e.checked=e.value!=null&&String(e.value)===String(t??"");return}if(n==="checked"){e.checked=t===!0||t==="true";return}if(n){e[n]=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var qh={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?$h(t.uploadFileBasic):null)},Uh={402:"payment-required",413:"too-large",415:"unsupported-type",401:"unauthorized",403:"forbidden",404:"not-found"},Wi=()=>({ok:!1,msg:"Upload cancelled",msgType:"skipped",code:"aborted",uploads:[]});function $h(e){return async function(n,{onProgress:r,signal:o}={}){if(o?.aborted)return Wi();try{let s=await e(n,{onProgress:i=>{r?.({loaded:null,total:null,percent:i})}});if(o?.aborted)return Wi();let l=s&&s.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:s.msg||"Uploaded",msgType:s.msgType||"success",code:s.code||null,uploads:l}}catch(s){if(o?.aborted)return Wi();let l={};try{l=JSON.parse(s?.response||"{}")}catch{l={}}let i=l.code||Uh[s?.status]||"error";return{ok:!1,msg:s&&s.message||"Upload failed",msgType:"error",code:i,uploads:[]}}}}function cn(e,t){let n=qh[e];if(!n)throw new Error(`hypercms: unknown platform capability "${e}"`);let r=t||(typeof window<"u"?window:null);return r&&n(r.clay,r.hyperclay)||null}var Mc=["clay:mutation-ready","hyperclay:mutation-ready"],Rc=["clay:sync-applied","hyperclay:livesync-applied"],Ic=["clay:ready","hyperclay:ready"];function Qr(e,t,n){let r=null,o=s=>{r!==null&&r!==s.type||(r=s.type,queueMicrotask(()=>{r=null}),n(s))};for(let s of t)e.addEventListener(s,o);return()=>{for(let s of t)e.removeEventListener(s,o)}}var Fn="data-hcms-bound",ar="data-hcms-bound-id",Ki=new Map;function Lc(e,t){Ki.set(e,t)}function jc(e){Ki.delete(e)}function Pc(e){let t=e.getAttribute(ar);if(!t)return null;let n=Ki.get(t);return!n||!n.restorable()?null:n.originalHTML}var Tr="data-hcms-owns-richclay";function eo(e){return e&&e.richclay&&e.richclay.RichClay||cn("RichClay",e)||(e&&typeof e.RichClay=="function"?e.RichClay:null)}function Dc(e,t,n){!e||typeof e.setAttribute!="function"||(e.setAttribute(Fn,t?"rich":"plain"),n&&e.setAttribute(Tr,"true"))}function Fc(e,t){if(!e||typeof e.querySelectorAll!="function")return;let n=e.querySelectorAll(`[${Fn}]`);if(!n.length)return;let r=eo(t);if(r&&typeof r.stripFromClone=="function")try{r.stripFromClone(e)}catch(o){console.warn("[hypercms] richclay strip failed; editor state may reach the save",o)}for(let o of n)o.getAttribute(Tr)==="true"&&o.removeAttribute("data-richclay"),o.removeAttribute(Tr),o.removeAttribute(Fn)}function Bc(e,t){if(!e||typeof e.removeAttribute!="function")return;let n=eo(t);if(n&&typeof n.stripElement=="function")try{n.stripElement(e)}catch(r){console.warn("[hypercms] richclay element strip failed; the clone stays editable",r)}else e.removeAttribute("contenteditable"),e.removeAttribute("no-undo");e.getAttribute(Tr)==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute(Tr),e.removeAttribute(Fn),e.removeAttribute(ar)}function qc(e,t){if(!t||e==null)return e;return n(e);function n(r){if(typeof r=="string"){if(r.endsWith("[]")||rn(r)!==-1)return r;let o=null;try{o=t.querySelector(r)}catch{return r}return o&&o.children.length>0?r+"@innerHTML":r}if(Array.isArray(r))return r;if(r&&typeof r=="object"){let o=Object.create(null);for(let[s,l]of Object.entries(r))o[s]=n(l);return o}return r}}function Uc(e,t){if(!t||e==null)return e;return n(e,[t]);function n(r,o){if(typeof r=="string")return r.endsWith("[]")||rn(r)!==-1?r:o.some(s=>Hh(s,r))?r+"@innerHTML":r;if(Array.isArray(r)){let[s,l]=r;if(typeof s!="string"||!s)return r;let i=zh(t,s);return i.length?[s,n(l,i)]:r}if(r&&typeof r=="object"){let s=Object.create(null);for(let[l,i]of Object.entries(r))s[l]=n(i,o);return s}return r}}function Hh(e,t){let n=null;try{n=e.querySelector(t)}catch{return!1}return n?n.hasAttribute(Fn)?n.getAttribute(Fn)==="rich":n.children.length>0:!1}function zh(e,t){try{return[...e.querySelectorAll(t)]}catch{return[]}}function to(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 cr(e,t,n=!0){if(!e||!e.querySelectorAll||(e.querySelectorAll("textarea[data-hcms-field]").forEach(to),n===!1))return;let r=t&&t.defaultView||(typeof window<"u"?window:null),o=eo(r);o&&e.querySelectorAll("[contenteditable][data-hcms-field]").forEach(s=>{if(s.__hcmsRichclay)return;let l;try{l=new o(s,{inline:!0,hyperclay:!1,toolbar:["bold","italic","link","undo","redo"]})}catch(a){console.warn("[hypercms] richclay activation failed; field stays plain contenteditable",a);return}s.__hcmsRichclay=l;let i=l&&l.squire;i&&typeof i.addEventListener=="function"&&i.addEventListener("input",()=>{let a=r&&r.Event||Event;s.dispatchEvent(new a("input",{bubbles:!0}))})})}var Gi=new WeakSet;function Er(e,t){let n=cn("undo");if(!n)return t();n.pause();try{let r=t();return r&&r.ok?n.commitCaptured(e):n.discardCaptured(),r}finally{n.resume()}}function Qn(e){let t=cn("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function ws(e){let{formRoot:t}=e;if(!t||Gi.has(t))return;Gi.add(t);let n=l=>{let i=l.target;!i||!i.closest||i.closest("[data-hcms-form-root]")&&i.matches("input, textarea, select, [contenteditable][data-hcms-field]")&&(i.tagName==="TEXTAREA"&&to(i),!i.matches('input[type="file"]')&&(!i.closest("[data-hcms-field]")&&!i.hasAttribute?.("data-hcms-field")||$c(i,e)))},r=l=>{let i=l.target;if(!(!i||!i.closest)&&i.closest("[data-hcms-form-root]")){if(i.matches('input[type="file"][data-hcms-upload]')){Zh(i,e);return}i.matches('input[type="checkbox"], input[type="radio"], select')&&$c(i,e)}},o=l=>{let i=l.target;if(!i||!i.closest)return;let a=i.closest("[data-hcms-action]");if(!a)return;let c=a.getAttribute("data-hcms-action");if(c==="add"||c==="remove"||c==="move-up"||c==="move-down"||c==="clear-upload"){if(!a.closest("[data-hcms-form-root]"))return}else if(c==="close"&&!a.closest("[data-hcms-shell]"))return;if(c==="add"){let h=a.closest("[data-hcms-path]");if(!h)return;let u=h.getAttribute("data-hcms-path");Mo(u,e)}else if(c==="remove"){let h=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!h)return;Ji(h,e)}else if(c==="move-up"||c==="move-down"){let h=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!h)return;Xi(h,c==="move-up"?-1:1,e)}else c==="clear-upload"?nm(a,e):c==="close"&&e.onCloseRequested?.()},s=t.ownerDocument;s.addEventListener("input",n,!0),s.addEventListener("change",r,!0),s.addEventListener("click",o,!0),e.detachEvents=()=>{s.removeEventListener("input",n,!0),s.removeEventListener("change",r,!0),s.removeEventListener("click",o,!0),Gi.delete(t)}}var Vh=new Set(["value","checked"]);function Wh(e,t){if(!t)return null;let n=Jn(t);if(n.some(a=>typeof a=="number"||a==="*"))return null;let r=Ar(e.pageRules,n);if(typeof r!="string")return null;let o=pn.ruleAttrIndex(r);if(o===-1)return null;let s=r.slice(o+1);if(!Vh.has(s))return null;let l=r.slice(0,o),i=l?e.pageRoot.querySelector(l):e.pageRoot;return i?{el:i,prop:s,oldValue:i[s]}:null}function $c(e,t){let r=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",o=Wh(t,r);if(_n(vn(t),{path:r,structural:!1},t),o){let s=cn("undo");s&&typeof s.recordValue=="function"&&s.recordValue(o.el,{prop:o.prop,oldValue:o.oldValue,newValue:o.el[o.prop]})}}var Kh={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function Gh(e,t){let n=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(n==null)return{file:e};let r=cn("quickcrop");if(typeof r!="function")return{file:e};try{let o=typeof window<"u"&&(window.clay?.modal??window.themodal)||"auto",s=await r(e,{aspect:Yh(n),modal:o,...Kh});return s===null?null:{file:Xh(s.blob,e.name),dataURL:s.dataURL}}catch(o){return ro(t,o&&o.message||"Crop failed"),null}}function Yh(e){let t=String(e??"").trim().toLowerCase();if(t===""||t==="free")return null;let n=t.match(/^(\d+(?:\.\d+)?)\s*[:/]\s*(\d+(?:\.\d+)?)$/);if(!n)return null;let r=parseFloat(n[1]),o=parseFloat(n[2]);return!r||!o?null:r/o}function Xh(e,t){let n=e.type==="image/webp"?".webp":e.type==="image/jpeg"?".jpg":".png",r=String(t||"image").replace(/\.[^.]+$/,"");try{return new File([e],r+n,{type:e.type})}catch{return e}}var Jh=new Set(["unsupported","payment-required"]);async function Zh(e,t){let n=e.files&&e.files[0];if(!n)return;let r=e.closest("[data-hcms-path]");if(!r)return;let o=r.getAttribute("data-hcms-path")||"";ro(r,null);let s=await Gh(n,r);if(!s||t.closed){fr(e);return}let l=s.file,i=s.dataURL||null,a=cn("upload");if(typeof a!="function")return Yi(e,r,t,o,await Hc(l,i,r),l);Kc(r,i),zc(r,0);let c=em(t),h;try{h=await a(l,{signal:c?.signal,onProgress:({percent:f})=>zc(r,f)})}finally{tm(t,c),om(r)}if(t.closed){fr(e);return}if(h.code==="aborted"){fr(e);return}if(h.ok)return Yi(e,r,t,o,h.uploads[0].url,l);if(!Jh.has(h.code)){ro(r,h.msg||"Upload failed"),t.dispatch?.("hcms:error",{error:new Error(h.msg||"Upload failed"),code:h.code,path:o}),fr(e);return}let u=h.code==="payment-required"?"This file is stored in the page. Add a paid plan to upload files.":null;return Yi(e,r,t,o,await Hc(l,i,r),l,u)}function Yi(e,t,n,r,o,s,l=null){if(n.closed){fr(e);return}if(Kc(t,null),ro(t,null),!o){fr(e);return}Wc(t,o,s.name),_n(vn(n),{path:r,structural:!1},n),l&&ro(t,l,"info"),fr(e)}async function Hc(e,t,n){return t||await Qh(e,n)}function Qh(e,t){let n=t?.ownerDocument?.defaultView?.FileReader||globalThis.FileReader;return n?new Promise(r=>{let o=new n;o.onload=()=>r(typeof o.result=="string"?o.result:""),o.onerror=()=>r("");try{o.readAsDataURL(e)}catch{r("")}}):Promise.resolve("")}function em(e){if(typeof AbortController!="function")return null;let t=new AbortController;return(e.uploads||(e.uploads=new Set)).add(t),t}function tm(e,t){t&&e.uploads?.delete(t)}function nm(e,t){let n=e.closest("[data-hcms-path]");if(!n)return;let r=n.getAttribute("data-hcms-path")||"";Wc(n,"","");let o=n.querySelector('input[type="file"][data-hcms-upload]');o&&fr(o),ro(n,null),_n(vn(t),{path:r,structural:!1},t)}function rm(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function Wc(e,t,n){let r=rm(e);if(!r)return;let o=(r.tagName||"").toUpperCase();o==="IMG"?r.src=t||"":o==="A"&&(r.href=t||"",r.textContent=t?n||Hi(t):"")}function fr(e){try{e.value=""}catch{}}function Kc(e,t){let n=e.querySelector?e.querySelector(".mirk-image__frame"):null;n&&(t?n.style.backgroundImage=`url("${t.replace(/"/g,"%22")}")`:n.style.removeProperty("background-image"))}function zc(e,t){let n=Math.max(0,Math.min(100,Number(t)||0));e.setAttribute("data-hcms-uploading",""),e.style?.setProperty?.("--hcms-upload-progress",`${n}%`)}function om(e){e.removeAttribute("data-hcms-uploading"),e.style?.removeProperty?.("--hcms-upload-progress")}function ro(e,t,n="error"){let r=e.querySelector?e.querySelector(":scope > .hcms-error"):null;r&&(r.classList.toggle("hcms-error--info",!!t&&n==="info"),t?(r.textContent=t,r.hidden=!1):(r.textContent="",r.hidden=!0))}function Mo(e,t){let{formRoot:n,pageRules:r}=t,o=n.querySelector(`[data-hcms-path="${oo(e)}"]`);if(!o)throw new Error(`hypercms: no element at path "${e}"`);let s=o.querySelector(".hcms-array-items");if(!s)throw new Error(`hypercms: array container missing .hcms-array-items at "${e}"`);let l=Jn(e),i=cm(r,l),a=Array.isArray(i),c=typeof i=="string"&&i.endsWith("[]");if(!a&&!c)throw new Error(`hypercms: path "${e}" is not an array`);let h=vs(o,"data-hcms-max-items"),u=s.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(o.hasAttribute("data-hcms-no-add")||h!=null&&u.length>=h)return;let f=u.length,d=a?i[1]:i.replace(/\[\]$/,""),p=Oo(a?d:"string"),y=yc({shape:a?"object-array-item":"scalar-array-item",itemShape:d,pathArr:[...l,f],data:p,doc:t.doc,itemKey:o.getAttribute("data-hcms-item-tpl")||null,pageRules:r});return s.appendChild(y),cr(y,t.doc,t.view?.enhanceFormRichText!==!1),Qi(o),Er(`Add ${e}`,()=>_n(vn(t),{path:e,structural:!0},t))}function Xi(e,t,n){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!r||r.hasAttribute("data-hcms-no-reorder"))return;let o=r.querySelector(".hcms-array-items");if(!o)return;let s=Array.from(o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),l=s.indexOf(e);if(l<0)return;let i=l+t;if(i<0||i>=s.length)return;let a=e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`);return t<0?o.insertBefore(e,s[i]):o.insertBefore(e,s[i].nextSibling),el(o),Qi(r),a&&typeof a.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),Er(`Reorder ${r.getAttribute("data-hcms-path")||""}`,()=>_n(vn(n),{path:r.getAttribute("data-hcms-path")||"",structural:!0},n))}var xs="Delete this item?";function sm(e,t){let n=e&&e.getAttribute("data-hcms-confirm-remove");if(n!=null)return/^(off|false|no|0)$/i.test(n.trim())?null:n||xs;let r=t&&t.confirmRemove;return r===!1?null:typeof r=="string"?r||xs:r===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?xs:null}function Ji(e,t){let n=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),r=sm(n,t);if(r==null)return no(e,t);let o=cn("consent")||typeof window<"u"&&window.consent;typeof o=="function"?Promise.resolve(o(r)).then(()=>{t.closed||no(e,t)},()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(r)&&no(e,t):no(e,t)}function no(e,t){let n=e.getAttribute("data-hcms-path")||"",r=e.parentElement,o=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!o?.hasAttribute("data-hcms-no-remove")){if(o){let s=vs(o,"data-hcms-min-items"),l=o.querySelector(".hcms-array-items"),i=l?l.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]").length:0;if(s!=null&&i<=s)return}return e.remove(),r&&el(r),o&&Qi(o),Er(`Remove ${n}`,()=>_n(vn(t),{path:n,structural:!0},t))}}function _n(e,t,n){if(n.closed)return{ok:!1,skipped:!0,closed:!0};let r=Ro(e);if(!t.structural&&r===n.lastFingerprint)return{ok:!0,skipped:!0};let o=Object.hasOwn(n,"writeRules")?n.writeRules:n.pageRules,s=oc(n.pageRoot,o,e,{shellRoot:n.shellRoot,structural:!!t.structural,structuralPath:t.path||null,formRoot:n.formRoot});return s.ok?(n.lastFingerprint=r,n.lastData=e,Vc(n,null),n.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),n.onChange?.(e,t)):(Vc(n,am(s.error,t.path)),n.dispatch?.("hcms:error",{error:s.error,attemptedData:e}),n.onError?.(s.error)),s}function As(e,t){let n=oo(t),r=`[data-hcms-path="${n}"] input[data-hcms-field], [data-hcms-path="${n}"] textarea[data-hcms-field], [data-hcms-path="${n}"] select[data-hcms-field], [data-hcms-path="${n}"] img[data-hcms-field], [data-hcms-path="${n}"] a[data-hcms-field], [data-hcms-path="${n}"] [contenteditable][data-hcms-field], input[data-hcms-path="${n}"][data-hcms-field], textarea[data-hcms-path="${n}"][data-hcms-field], select[data-hcms-path="${n}"][data-hcms-field], img[data-hcms-path="${n}"][data-hcms-field], a[data-hcms-path="${n}"][data-hcms-field], [contenteditable][data-hcms-path="${n}"][data-hcms-field]`;return e.querySelector(r)}function Ss(e,t,n,r){let o=(e.tagName||"").toUpperCase(),s=(e.getAttribute("type")||"").toLowerCase();if(o==="INPUT"&&s==="checkbox"){e.checked=t===!0||t==="true";return}if(o==="INPUT"&&s==="radio"){let l=oo(r),i=n.querySelectorAll(`[data-hcms-path="${l}"][data-hcms-field][type="radio"], [data-hcms-path="${l}"] [data-hcms-field][type="radio"]`);i.length?i.forEach(a=>{a.checked=String(a.value)===String(t??"")}):e.checked=String(e.value)===String(t??"");return}if(o==="IMG"){e.src=t==null?"":String(t);return}if(o==="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 vn(e){let t=pn.extract(e.formRoot,e.formRules,{exclude:null});return ur(t,e.formRules)}function ur(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[,n]=t;return e.map(r=>ur(r,n))}if(typeof t=="object"){if(typeof e!="object"||Array.isArray(e))return e;let n={};for(let[r,o]of Object.entries(t))n[r]=ur(e[r],o);return n}return e}function Vc(e,t){e.lastErrors=t&&t.length?t:null,Zi(e)}function Zi(e){if(im(e),e.errorEl&&(e.errorEl.textContent="",e.errorEl.hidden=!0),!e.lastErrors)return;let t=[];for(let{message:n,path:r}of e.lastErrors){if(r!=null&&r!==""){let o=lm(e.formRoot,r);if(o){o.textContent=o.textContent?`${o.textContent}
153
153
  ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textContent=t.join(`
154
- `),e.errorEl.hidden=!1)}function Yd(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function Xd(e,t){if(!e)return null;let n=t.split(".");for(;n.length>0;){let r=n.join("."),o=typeof CSS<"u"&&CSS.escape?CSS.escape(r):r.replace(/[^a-zA-Z0-9_\-.*]/g,i=>"\\"+i),s=e.querySelector(`[data-hcms-path="${o}"]`);if(s){for(let i of s.children)if(i.classList&&i.classList.contains("hcms-error"))return i}n.pop()}return null}function Jd(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(n=>({message:`Shape mismatch: expected ${n.expected}, got ${n.got}`,path:n.path})):[{message:e.message||String(e),path:t}]:[{message:"unknown error",path:t}]}function Zd(e,t){let n=e;for(let r of t){if(n==null||typeof n=="string")return;if(Array.isArray(n)){if(typeof r!="number"&&r!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof r=="number"||!(r in n))return;n=n[r];continue}return}return n}function ts(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function Ei(e){if(!e)return;let t=e.querySelector(".hcms-array-items");if(!t)return;let n=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),r=n.length,o=ts(e,"data-hcms-max-items"),s=ts(e,"data-hcms-min-items"),i=e.hasAttribute("data-hcms-no-add"),l=e.hasAttribute("data-hcms-no-remove"),a=e.hasAttribute("data-hcms-no-reorder"),u=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');u&&(u.hidden=i||o!=null&&r>=o),n.forEach((d,h)=>{let f=d.querySelector('[data-hcms-action="remove"]');f&&(f.hidden=l||s!=null&&r<=s);let p=d.querySelector('[data-hcms-action="move-up"]');p&&(p.hidden=a||h===0);let b=d.querySelector('[data-hcms-action="move-down"]');b&&(b.hidden=a||h===r-1)})}function ss(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>_i(t))}function _i(e){let t=e.querySelectorAll?Array.from(e.querySelectorAll('input[type="radio"][data-hcms-field]'),r=>[r,r.checked]):[],n=0;for(let r of e.children){if(!r.matches?.("[data-hcms-card], [data-hcms-array-item]"))continue;let o=r.getAttribute("data-hcms-path");if(!o)continue;let s=o.split(".");s[s.length-1]=String(n);let i=s.join(".");i!==o&&Qd(r,o,i),n++}for(let[r,o]of t)r.checked!==o&&(r.checked=o)}function Qd(e,t,n){let r=e.querySelectorAll("[data-hcms-path]");e.setAttribute("data-hcms-path",n);for(let o of r){let s=o.getAttribute("data-hcms-path");s===t?o.setAttribute("data-hcms-path",n):s&&s.startsWith(t+".")&&o.setAttribute("data-hcms-path",n+s.slice(t.length))}eh(e)}function eh(e){for(let t of e.querySelectorAll('input[type="radio"][data-hcms-field]')){if(!t.name||!t.name.startsWith("hcms-"))continue;let n=t.closest("[data-hcms-path]");n&&(t.name=ki(n.getAttribute("data-hcms-path")))}}function mo(e){return JSON.stringify(e,(t,n)=>{if(n&&typeof n=="object"&&!Array.isArray(n)){let r=Object.create(null);for(let o of Object.keys(n).sort())r[o]=n[o];return r}return n})}function Hr(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var ih={},is="hcms-shell-styles",th="hcms-bundled-styles-installed",ls="hcms-session-open",nh='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',$r=new WeakSet,Oi="";function rc(e){Oi=e}function po(e){e?.body?.classList.add(ls)}function Ni(e){e?.body?.classList.remove(ls)}var rh=0;function nc(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}function oc({mountTo:e,side:t="right",overlay:n=!1,showSaveButton:r=!1,title:o="Page content",eyebrow:s="Edit",theme:i=null,doc:l}){sc(l);let a=`hcms-shell-title-${++rh}`,u=l.createElement("div");u.setAttribute("data-hcms-shell",""),u.setAttribute("editor-ui",""),u.setAttribute("save-remove",""),u.setAttribute("save-ignore",""),u.setAttribute("tabindex","-1"),u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-labelledby",a);let d=i==="dark"?" dark":i==="light"?" light":"";u.className="hcms-shell pixel-quiet hcms-panel hcms-side-"+t+(n?" hcms-overlay":"")+d;let h=nc(o),f=nc(s);u.innerHTML=`
154
+ `),e.errorEl.hidden=!1)}function im(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function lm(e,t){if(!e)return null;let n=t.split(".");for(;n.length>0;){let r=n.join("."),o=typeof CSS<"u"&&CSS.escape?CSS.escape(r):r.replace(/[^a-zA-Z0-9_\-.*]/g,l=>"\\"+l),s=e.querySelector(`[data-hcms-path="${o}"]`);if(s){for(let l of s.children)if(l.classList&&l.classList.contains("hcms-error"))return l}n.pop()}return null}function am(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(n=>({message:`Shape mismatch: expected ${n.expected}, got ${n.got}`,path:n.path})):[{message:e.message||String(e),path:t}]:[{message:"unknown error",path:t}]}function cm(e,t){let n=e;for(let r of t){if(n==null||typeof n=="string")return;if(Array.isArray(n)){if(typeof r!="number"&&r!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof r=="number"||!(r in n))return;n=n[r];continue}return}return n}function vs(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function Qi(e){if(!e)return;let t=e.querySelector(".hcms-array-items");if(!t)return;let n=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),r=n.length,o=vs(e,"data-hcms-max-items"),s=vs(e,"data-hcms-min-items"),l=e.hasAttribute("data-hcms-no-add"),i=e.hasAttribute("data-hcms-no-remove"),a=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');c&&(c.hidden=l||o!=null&&r>=o),n.forEach((h,u)=>{let f=h.querySelector('[data-hcms-action="remove"]');f&&(f.hidden=i||s!=null&&r<=s);let d=h.querySelector('[data-hcms-action="move-up"]');d&&(d.hidden=a||u===0);let p=h.querySelector('[data-hcms-action="move-down"]');p&&(p.hidden=a||u===r-1)})}function Ts(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>el(t))}function el(e){let t=e.querySelectorAll?Array.from(e.querySelectorAll('input[type="radio"][data-hcms-field]'),r=>[r,r.checked]):[],n=0;for(let r of e.children){if(!r.matches?.("[data-hcms-card], [data-hcms-array-item]"))continue;let o=r.getAttribute("data-hcms-path");if(!o)continue;let s=o.split(".");s[s.length-1]=String(n);let l=s.join(".");l!==o&&fm(r,o,l),n++}for(let[r,o]of t)r.checked!==o&&(r.checked=o)}function fm(e,t,n){let r=e.querySelectorAll("[data-hcms-path]");e.setAttribute("data-hcms-path",n);for(let o of r){let s=o.getAttribute("data-hcms-path");s===t?o.setAttribute("data-hcms-path",n):s&&s.startsWith(t+".")&&o.setAttribute("data-hcms-path",n+s.slice(t.length))}um(e)}function um(e){for(let t of e.querySelectorAll('input[type="radio"][data-hcms-field]')){if(!t.name||!t.name.startsWith("hcms-"))continue;let n=t.closest("[data-hcms-path]");n&&(t.name=Vi(n.getAttribute("data-hcms-path")))}}function Ro(e){return JSON.stringify(e,(t,n)=>{if(n&&typeof n=="object"&&!Array.isArray(n)){let r=Object.create(null);for(let o of Object.keys(n).sort())r[o]=n[o];return r}return n})}function oo(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var bm={},Es="hcms-shell-styles",dm="hcms-bundled-styles-installed",_s="hcms-session-open",hm='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',so=new WeakSet,tl="";function Yc(e){tl=e}function Io(e){e?.body?.classList.add(_s)}function nl(e){e?.body?.classList.remove(_s)}var mm=0;function Gc(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}function Xc({mountTo:e,side:t="right",overlay:n=!1,showSaveButton:r=!1,title:o="Page content",eyebrow:s="Edit",theme:l=null,doc:i}){Jc(i);let a=`hcms-shell-title-${++mm}`,c=i.createElement("div");c.setAttribute("data-hcms-shell",""),c.setAttribute("editor-ui",""),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",a);let h=l==="dark"?" dark":l==="light"?" light":"";c.className="hcms-shell pixel-quiet hcms-panel hcms-side-"+t+(n?" hcms-overlay":"")+h;let u=Gc(o),f=Gc(s);c.innerHTML=`
155
155
  <div class="hcms-shell-minibar" aria-hidden="true">
156
- <span class="hcms-shell-minibar-title">${h}</span>
156
+ <span class="hcms-shell-minibar-title">${u}</span>
157
157
  <button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
158
158
  <span class="mirk-button__label">\xD7</span>
159
159
  </button>
@@ -162,7 +162,7 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
162
162
  <header class="hcms-shell-header">
163
163
  <div class="hcms-shell-heading">
164
164
  <div class="hcms-shell-eyebrow">${f}</div>
165
- <h2 class="hcms-shell-title" id="${a}">${h}</h2>
165
+ <h2 class="hcms-shell-title" id="${a}">${u}</h2>
166
166
  </div>
167
167
  <button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
168
168
  <span class="mirk-button__label">\xD7</span>
@@ -177,8 +177,8 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
177
177
  </button>
178
178
  </footer>
179
179
  </div>
180
- `,(e||l.body).appendChild(u);let b=l.body;b.classList.add("hcms-open"),po(l),n&&b.classList.add("hcms-overlay"),t==="left"&&b.classList.add("hcms-side-left");let v=sh(u,l),m=oh(u);return{root:u,formRoot:u.querySelector("[data-hcms-form-root]"),noticeEl:u.querySelector(".hcms-shell-notice"),errorEl:u.querySelector(".hcms-shell-error"),saveButton:u.querySelector(".hcms-shell-save"),destroy(){v.detach(),m.detach(),u.remove(),b.classList.remove("hcms-open","hcms-overlay","hcms-side-left"),Ni(l)},restoreChrome(){Qn(l),b.classList.add("hcms-open"),po(l),n&&b.classList.add("hcms-overlay"),t==="left"&&b.classList.add("hcms-side-left")}}}function Qn(e){e&&(e.getElementById(is)||e.querySelector("style[data-hcms-bundled-styles]")||($r.delete(e),sc(e)))}function sc(e){if(e&&!$r.has(e)){if(e[th]){$r.add(e);return}if(e.getElementById(is)||e.querySelector("style[data-hcms-bundled-styles]")){$r.add(e);return}if(Oi){let t=e.createElement("style");t.id=is,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=Oi,(e.head||e.documentElement).appendChild(t),$r.add(e);return}try{let t=new URL("./theme.generated.css",ih.url).href,n=e.createElement("link");n.rel="stylesheet",n.id=is,n.setAttribute("save-remove",""),n.setAttribute("save-ignore",""),n.href=t,(e.head||e.documentElement).appendChild(n),$r.add(e)}catch{let n=()=>{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(n):n()}}}function oh(e){let t=e.querySelector(".hcms-shell-body"),n=e.querySelector(".hcms-shell-header");if(!t||!n||typeof t.addEventListener!="function")return{detach(){}};let r=()=>{let o=(n.offsetHeight||0)-12;e.classList.toggle("is-condensed",t.scrollTop>o)};return t.addEventListener("scroll",r,{passive:!0}),r(),{detach(){t.removeEventListener("scroll",r)}}}function sh(e,t){function n(r){if(r.key!=="Tab"||!e.contains(t.activeElement))return;let o=Array.from(e.querySelectorAll(nh));if(o.length===0)return;let s=o[0],i=o[o.length-1];r.shiftKey&&t.activeElement===s?(r.preventDefault(),i.focus()):!r.shiftKey&&t.activeElement===i&&(r.preventDefault(),s.focus())}return t.addEventListener("keydown",n),{detach:()=>t.removeEventListener("keydown",n)}}var lh="[hypercms]",ic={skip:"[data-hcms-shell]",templateAttr:"cms-template"},lc={skip:"[data-hcms-shell]",templateAttr:null},Ci=class extends Error{constructor(t,n,r){super(`hypercms: rule at "${t}" has an invalid CSS selector: "${n}"`),this.name="InvalidRuleSelector",this.path=t,this.selector=n,this.cause=r}};function cs(e,t){let n=[],r=[],o=[];return Ri(jn(e),e,t,[],n,r,o),{missing:ac(n),twins:dh(r),readOnly:ac(o)}}function us(e){return Mi(e)}function Mi(e){if(typeof e=="string")return cc(e)?void 0:e;if(Array.isArray(e)){let[t,n]=e;return[t,Mi(n)]}if(e&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e)){let o=Mi(r);o!==void 0&&(t[n]=o)}return t}return e}function Ri(e,t,n,r,o,s,i){if(typeof n=="string"){let l=ah(n),a=l?as(e,t,l,ic,r):[];if(cc(n)){i.push(Ur(r));return}if(!l)return;if(n.endsWith("[]")){a.length===0&&as(e,t,l,lc,r).length===0&&o.push(Ur(r));return}a.length===0?o.push(Ur(r)):a.length>1&&s.push({path:Ur(r),count:a.length});return}if(Array.isArray(n)){let[l,a]=n;if(typeof l!="string"||!l)return;let u=as(e,t,l,ic,r);if(u.length===0){as(e,t,l,lc,r).length===0&&o.push(Ur(r));return}for(let d of u)Ri(e,d,a,[...r,"*"],o,s,i);return}if(n&&typeof n=="object")for(let[l,a]of Object.entries(n))Ri(e,t,a,[...r,l],o,s,i)}function as(e,t,n,r,o){try{return e.find(t,n,r)}catch(s){throw new Ci(Ur(o),n,s)}}function ah(e){if(e==="."||e.startsWith("@"))return null;if(e.endsWith("[]"))return e.slice(0,-2)||null;let t=Vt(e);return(t===-1?e:e.slice(0,t))||null}function ch(e){if(e.endsWith("[]"))return null;let t=Vt(e);return t===-1?null:e.slice(t+1)||null}function cc(e){let t=ch(e);return t!=null&&eo.has(t)}function zr(e){uh(e),fh(e)}function uh(e){let t=e.noticeEl;if(!t)return;let n=e.unresolved&&e.unresolved.missing||[],r=e.unresolved&&e.unresolved.readOnly||[];if(n.length===0&&r.length===0){t.textContent="",t.hidden=!0;return}let o=[];if(n.length){let s=n.length===1?"1 field no longer matches this page":`${n.length} fields no longer match this page`;o.push(`${s}: ${n.join(", ")}`)}if(r.length){let s=r.length===1?"1 field reads a property the browser will not let anything write":`${r.length} fields read properties the browser will not let anything write`;o.push(`${s}: ${r.join(", ")}`)}t.textContent=o.join(`
181
- `),t.hidden=!1}function fh(e){let t=e.unresolved&&e.unresolved.twins||[],n=t.map(r=>`${r.path}:${r.count}`).join("|");if(n!==e.lastTwinSignature){e.lastTwinSignature=n;for(let{path:r,count:o}of t)console.warn(`${lh} "${r}" matches ${o} elements; edits go to the first one.`)}}function ac(e){return[...new Set(e)]}function dh(e){let t=new Map;for(let n of e){let r=t.get(n.path);(!r||n.count>r.count)&&t.set(n.path,n)}return[...t.values()]}function Ur(e){return e.length?e.join("."):"(whole page)"}var hh={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function er(e,{ignoreActiveValue:t}={}){return mh(e,{ignoreActiveValue:t})}function mh(e,{ignoreActiveValue:t}){let n=ln.findRules(e.doc,e.rulesSource||"cms");n&&(e.pageRules=e.view.prepareRules(n.rules),e.rulesTagNode=n.tagNode),Uo(e.doc),Go(e.doc,e.pageRules),e.formRules=Xo(e.pageRules,e.doc),e.writeRules=us(e.pageRules),e.unresolved=cs(e.pageRoot,e.pageRules);let r=Bo(),o=Zn(ln.extract(e.pageRoot,e.pageRules,{...hh,...r.hooks}),e.pageRules),s=Lr({pageRules:e.pageRules,formRules:e.formRules,data:o,doc:e.doc});qo(e.formRoot,s,{ignoreActiveValue:t}),r.seed(e.formRoot),Xn(e.formRoot,e.doc,e.view?.enhanceFormRichText!==!1),Ti(e),zr(e),e.updateFingerprint&&e.updateFingerprint()}function uc({debounce:e=100,onRefresh:t}){let n=Jt("Mutation");if(!n||typeof n.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 r=n.onAnyChange({debounce:e},o=>{t(o)});return{unsubscribe:typeof r=="function"?r:()=>{}}}var ph='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])';function fc({doc:e,pageRoot:t,opts:n={}}){let r=n.richText!==!1,o=null;return{name:"sidebar",richText:r,enhanceFormRichText:!0,ctx:null,root:null,formRoot:null,errorEl:null,noticeEl:null,prepareRules(s){return r?Ga(s,t):s},mount(s){let i=this.ctx;o=Fn(()=>oc({mountTo:n.mountTo||e.body,side:n.side||"right",overlay:!!n.overlay,showSaveButton:!!n.showSaveButton,title:n.title,eyebrow:n.eyebrow,theme:n.theme,doc:e})),this.root=o.root,this.formRoot=o.formRoot,this.errorEl=o.errorEl,this.noticeEl=o.noticeEl;let l=Lr({pageRules:i.pageRules,formRules:i.formRules,data:s,doc:e});o.formRoot.appendChild(l),i.seeder.seed(o.formRoot),Xn(o.formRoot,e),zr(i),ns(i)},refresh(s){if(s==="livesync"){o?.restoreChrome?.(),er(this.ctx,{ignoreActiveValue:!0});return}if(s==="undo"){er(this.ctx,{ignoreActiveValue:!1});return}er(this.ctx)},focusOnOpen(){let s=this.root&&this.root.querySelector(ph);s&&typeof s.focus=="function"&&s.focus()},destroy(){o?.destroy(),o=null}}}var gh="[cms-template], [data-hcms-shell]";function go(e){if(!e||typeof e.getBoundingClientRect!="function"||typeof e.closest=="function"&&e.closest(gh))return!1;let t=e.getBoundingClientRect();return t.width>=8&&t.height>=8}var bh={skip:"[data-hcms-shell]",templateAttr:"cms-template"},kh={skip:"[data-hcms-shell]",templateAttr:null},yh="text",xh="native",dc="handle",vh=new Set(["INPUT","TEXTAREA","SELECT"]),pc=new Set(["IMG","INPUT","TEXTAREA","SELECT","OPTION","BR","HR","VIDEO","AUDIO","IFRAME","EMBED","OBJECT","CANVAS","SOURCE","TRACK","AREA","COL","PARAM","BUTTON"]);function Ii(e,t){return wh(e,t)}function wh(e,t){let n=[],r=[],o=jn(e);return Li(o,e,t,[],n,r),{targets:n,lists:r}}function Li(e,t,n,r,o,s){if(typeof n=="string"){if(n.endsWith("[]")){let d=n.slice(0,-2);if(!d)return;let h=fs(e,t,d);h.forEach((f,p)=>{o.push(mc([...r,p],f,n,null))}),s.push(hc(e,t,r,d,h,!0));return}let i=Vt(n),l=i===-1?null:n.slice(i+1),a=i===-1?n:n.slice(0,i),u=!a||a==="."?t:fs(e,t,a)[0];u&&o.push(mc(r,u,n,l));return}if(Array.isArray(n)){let[i,l]=n;if(typeof i!="string"||!i)return;let a=fs(e,t,i);a.forEach((u,d)=>Li(e,u,l,[...r,d],o,s)),s.push(hc(e,t,r,i,a,typeof l=="string"));return}if(n&&typeof n=="object")for(let[i,l]of Object.entries(n))Li(e,t,l,[...r,i],o,s)}function hc(e,t,n,r,o,s){let i=o[0]?o[0].parentElement:null;if(!i){let l=fs(e,t,r,kh)[0];i=l?l.parentElement:null}return{path:n,items:o,container:i,scalar:s}}function mc(e,t,n,r){return{path:e,el:t,rule:n,attr:r,kind:Ah(t,r),icon:Th(t,r)}}function Ah(e,t){let n=(e.tagName||"").toUpperCase();return!t||t==="innerHTML"?pc.has(n)?dc:yh:t==="value"&&vh.has(n)&&!e.readOnly&&!Sh(e)?xh:dc}function Sh(e){return e.disabled?!0:typeof e.matches=="function"&&e.matches(":disabled")}function Th(e,t){let n=(e.tagName||"").toUpperCase();return(!t||t==="innerHTML")&&!pc.has(n)?null:n==="IMG"||t==="srcset"?"camera":n==="A"&&t==="href"?"paperclip":"pencil"}function fs(e,t,n,r=bh){try{return e.find(t,n,r)}catch{return[]}}var gc=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"]})}),Eh=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),iy=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function ji(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function _h(e,t){if(ji(e,t))return!0;for(let[n,r]of Object.entries(Eh))if(r.includes(t)&&ji(e,n))return!0;return!1}function bo(e){let t=gc[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Oh(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=gc[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>_h(n,o))||r.bundles.some(o=>ji(n,o)))return n;n=n.parentElement}return null}function bc(e,t){return!!Oh(e,t)}var Nh=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function kc(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="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 r=0;r<e.options.length;r++)t.options[r].selected=e.options[r].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function yc(e,t,n,r){if(r)return!!e.closest?.(t);let o=e;for(;o?.nodeType===1;){if(o.matches(t))return!0;if(o===n)break;o=o.parentElement}return!1}function xc(e,t,n,r,o,s,i,l){if(e.nodeType===1&&((i?bc(e,n):yc(e,r,s,!1))||o&&(i&&e!==s?e.matches(o):yc(e,o,s,i))))return null;let a=t.importNode(e,!1);l.cloneToLive.set(a,e),l.liveToClone.set(e,a);let u=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,d=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;u!==e&&(l.cloneToLive.set(d,u),l.liveToClone.set(u,d));for(let h of u.childNodes||[]){let f=xc(h,t,n,r,o,s,i,l);f&&(d.appendChild(f),h.nodeType===1&&kc(h,f))}return e.nodeType===1&&kc(e,a),a}function Pi(e,{capability:t="data",exclude:n=null,inherit:r=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=o.implementation.createHTMLDocument(""),i=new WeakMap,l=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let u=bo(t),d=xc(a,s,t,u,n,a,r,{cloneToLive:i,liveToClone:l});e.nodeType===9&&d&&(s.replaceChild(d,s.documentElement),l.set(e,s),i.set(s,e));let h=f=>{if(Nh.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:d,document:s,capability:t,selector:bo(t),cloneToLive:i,liveToClone:l,original(f){return i.get(f)||null},cloneOf(f){return l.get(f)||null},query(f,p=d){return h(f),Array.from(p.querySelectorAll(f),b=>i.get(b)||b)},text(f=d){return(f===d?d:l.get(f))?.textContent||""},html(f=d){return(f===d?d:l.get(f))?.innerHTML??""},clone(f=d){let p=f===d?d:l.get(f);return p?s.importNode(p,!0):null}}}var Ch=[16,8,0],Zt=8,Mh=4;function vc({anchor:e,bar:t,rail:n=t,viewport:r,current:o=null}){let s=f=>o===f?Mh:0;if(e.bottom<=0||e.top>=r.height||e.right<=0||e.left>=r.width)return{mode:"hidden",x:0,y:0};let i=f=>Math.max(Zt,Math.min(e.left,r.width-f-Zt)),l=e.top-16-t.height;if(l>=Zt-s("above"))return{mode:"above",x:i(t.width),y:l};let a=e.bottom+16;if(a+t.height<=r.height-Zt+s("below"))return{mode:"below",x:i(t.width),y:a};let u=r.width-e.right-Zt,d=e.left-Zt,h=u>=d?[["rail-right",u],["rail-left",d]]:[["rail-left",d],["rail-right",u]];for(let[f,p]of h)for(let b of Ch){if(n.width+b>p+s(f))continue;let v=f==="rail-right"?Math.min(e.right+b,r.width-n.width-Zt):Math.max(e.left-b-n.width,Zt),m=Math.min(e.bottom,r.height-Zt)-n.height,g=Math.max(Zt,Math.min(Math.max(e.top,Zt),m));return{mode:f,x:v,y:g,gap:b}}return{mode:"pinned",x:i(t.width),y:Zt}}function Di({anchor:e,handle:t,viewport:n,inset:r=6,prefer:o="auto"}){let s=e.height>=t.height*1.5&&e.width>=t.width*2;if(o==="corner"||s){let f=Math.max(Zt,Math.min(e.right-t.width+r,n.width-t.width-Zt)),p=Math.max(Zt,Math.min(e.top-r,n.height-t.height-Zt));return{x:f,y:p,mode:"over"}}let i=4,l=e.right+i+t.width<=n.width-Zt,a=l?e.right+i:e.left-i-t.width,u=Math.max(Zt,a),d=e.top+e.height/2-t.height/2,h=Math.max(Zt,Math.min(d,n.height-t.height-Zt));return{x:u,y:h,mode:l?"beside-right":"beside-left"}}var hs=!1;function wc(){if(hs)return;let e=Jt("onPrepareForSave");typeof e=="function"&&(e(t=>{Sc(t),Ac(t)}),hs=!0)}function Ac(e){let t=e&&e.querySelector&&e.querySelector("body");t&&t.classList.remove("hcms-open","hcms-overlay","hcms-side-left",ls)}function Sc(e){if(!(!e||typeof e.querySelectorAll!="function"))for(let t of e.querySelectorAll(`[${Yn}]`)){let n=za(t);n!==null&&(t.innerHTML=n),t.removeAttribute(Yn)}}var ms=!1;function ps(){if(ms)return;let e=Jt("onSnapshot");typeof e=="function"&&(e(t=>{Sc(t),Wa(t,typeof window<"u"?window:null),Ac(t)}),ms=!0)}function Tc(){wc(),ps(),(!hs||!ms)&&Rh()}var ds=null;function Rh(){if(ds||typeof document>"u")return;ds=Pr(document,Ha,()=>{wc(),ps(),hs&&ms&&(ds?.(),ds=null)})}var Lh={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 hr(e){let t=e==="edit"?"6 0 18 18":"0 0 24 24",n=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="${Lh[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">${n}</svg>`}var Ec="data-hcms-ghost",Ih=bo("history");function jh(e){let t=e.container,n=null;for(;t&&(t.namespaceURI!=="http://www.w3.org/1999/xhtml"||["SELECT","OPTGROUP","DATALIST"].includes(t.tagName));)n=t,t=t.parentElement;return{parent:t,anchor:n}}function _c({doc:e,themeRoot:t,onAdd:n,onResize:r}){let o=e.defaultView,s=[],i=!1,l=null,a=new Map;function u(p,b,v){p.style[b]!==v&&(p.style[b]=v)}function d(){let p=new Set(s.map(b=>b.node.parentElement));for(let[b,v]of a)p.has(b)&&o?.Sortable?.get(b)===v.instance||(v.instance.option("draggable")===v.selector&&v.instance.option("draggable",v.original),a.delete(b));for(let b of p){let v=o?.Sortable?.get(b);if(!v)continue;let m=v.option("draggable");if(a.get(b)?.selector===m)continue;let g=m,I=`${g.trim().startsWith(">")?"> ":""}:is(${g.trim().replace(/^>\s*/,"")}):not(${Ih})`;v.option("draggable",I),a.set(b,{instance:v,original:g,selector:I})}}function h(){for(let p of s){let{node:b,slot:v,list:m}=p,g=m.items.filter(y=>y.isConnected).map(y=>y.getBoundingClientRect()).filter(y=>y.width>0&&y.height>0);g.length&&(p.width=g.reduce((y,I)=>y+I.width,0)/g.length,p.height=g.reduce((y,I)=>y+I.height,0)/g.length),u(b,"width",p.width?`${Math.round(p.width)}px`:"100%"),u(v,"height",`${Math.max(48,Math.round(p.height||64))}px`),v!==b&&(v.colSpan=Math.max(1,...m.items.map(y=>[...y.children].reduce((I,Y)=>I+(Y.colSpan||1),0)))),b.hidden!==i&&(b.hidden=i)}d()}function f(p,b){let v=b.tagName,m=["TBODY","THEAD","TFOOT","TABLE"].includes(v),g=e.createElement(m?"tr":["UL","OL","MENU"].includes(v)?"li":"div");for(let $ of[Ec,"data-hcms-shell","editor-ui","no-watch","no-save","save-remove","snapshot-remove"])g.setAttribute($,"");g.setAttribute("draggable","false"),g.setAttribute("contenteditable","false"),g.className="hcms-shell pixel-quiet hcms-inline-ghost";for(let $ of["light","dark"])g.classList.toggle($,!!t?.classList.contains($));let y=m?e.createElement("td"):g;y!==g&&(y.className="hcms-inline-ghost-cell",g.appendChild(y));let I=e.createElement("button");I.type="button",I.className="hcms-inline-list-button hcms-inline-list-add mirk-button mirk-button--small",I.setAttribute("data-hcms-list-action","add"),I.innerHTML=`<span class="mirk-button__label">${hr("add")}<span>Add</span></span>`,y.appendChild(I);let Y={node:g,slot:y,button:I,list:p,width:0,height:0};I.addEventListener("click",$=>{$.preventDefault(),$.stopPropagation(),n(Y.list)});for(let $ of["pointerdown","mousedown","touchstart","click"])g.addEventListener($,H=>H.stopPropagation());return g.addEventListener("dragstart",$=>{$.preventDefault(),$.stopPropagation()}),Y}return{setLists(p){let b=new Set(s),v=[],m=new Set(s.map(y=>y.node)),g=new Set;for(let y of p||[]){if(!y.container||!y.container.isConnected)continue;let{parent:I,anchor:Y}=jh(y);if(!I)continue;if(!g.has(I)){for(let z of I.querySelectorAll(`:scope > [${Ec}]`))m.has(z)||z.remove();g.add(I)}let $=s.find(z=>b.has(z)&&z.list.container===y.container&&z.list.path.join(".")===y.path.join("."))||f(y,I);b.delete($),$.list=y,$.button.setAttribute("data-hcms-list",y.path.join(".")),$.button.setAttribute("aria-label",`Add to ${y.path.join(".")||"the list"}`);let H=Y||y.items.filter(z=>z.parentElement===I).at(-1);H?H.nextSibling!==$.node&&H.after($.node):$.node.parentElement!==I&&I.appendChild($.node),v.push($)}for(let y of b)y.node.remove();s=v,l?.disconnect(),!l&&typeof o?.ResizeObserver=="function"&&(l=new o.ResizeObserver(()=>{h(),r?.()}));for(let y of s)for(let I of y.list.items)l?.observe(I);h()},update:h,setHidden(p){i=!!p,h()},destroy(){l?.disconnect();for(let p of s)p.node.remove();s=[],d()}}}var Oc=[["move-up","Move up"],["move-down","Move down"]],Ph={prefer:"corner",inset:0};function Dh(e,t){return t.width<=e.width&&t.height<=e.height}function Nc({doc:e,layerEl:t,onActivate:n,onListAction:r}){let o=e.defaultView,s=[],i=new Map,l=0,a=new Map,u=null,d=new Set,h=0,f=!1,p=null,b=null,v=null,m=null,g=new Map,y=!1,I=null,Y=_c({doc:e,themeRoot:t.closest("[data-hcms-shell]"),onResize:H,onAdd:ee=>r?.({action:"add",list:ee,index:ee.items.length})}),$=e.createElement("div");$.className="hcms-inline-highlight",$.hidden=!0,$.setAttribute("aria-hidden","true"),t.appendChild($);function H(){if(!(h||!o)){if(typeof o.requestAnimationFrame!="function")return ae();h=o.requestAnimationFrame(()=>{h=0,ae()})}}let z=()=>v||m;function ae(){if(!o)return;Y.update();let ee={width:o.innerWidth,height:o.innerHeight},ce=z();for(let ge of s){if(!ge.visible){ge.node.hidden=!0;continue}for(let T of ge.members)T.node.hidden=y&&T.kind!=="handle";ge.node.hidden=!1;let Ue=ge.el.getBoundingClientRect(),ke=ge.node.getBoundingClientRect(),Je=ke.width,kt=ge.kind==="row"&&!Dh(Ue,ke);if(kt&&ge.el!==ce){for(let T of ge.members)T.kind==="row"&&(T.node.hidden=!0);ke=ge.node.getBoundingClientRect()}if(ge.members.every(T=>T.node.hidden)){ge.node.hidden=!0;continue}let ht=ge.kind==="handle"?null:Ph,{x:wt,y:ze}=Di({anchor:Ue,handle:ke,viewport:ee,...ht}),Ot=ge.members.find(T=>T.kind==="handle");if(kt&&Ot){let T=Ot.node.getBoundingClientRect(),re=Di({anchor:Ue,handle:T,viewport:ee}),oe=ge.members.slice(ge.members.indexOf(Ot)+1).filter(de=>!de.node.hidden).reduce((de,ie)=>de+ie.node.getBoundingClientRect().width+2,0);wt=Math.max(8+Je,Math.min(ee.width-8,re.x+T.width+oe))-ke.width,ze=re.y}ge.node.style.transform=`translate(${Math.round(wt)}px, ${Math.round(ze)}px)`}if(I)if(!I.node.isConnected||I.node.closest("[hidden]"))et();else{let ge=I.button.getBoundingClientRect(),Ue=I.menu.getBoundingClientRect();I.menu.style.left=`${Math.max(8,ge.right-Ue.width)-ge.left}px`,I.menu.style.right="auto",I.menu.style.top=ge.bottom+6+Ue.height>ee.height-8?"auto":"calc(100% + 6px)",I.menu.style.bottom=ge.bottom+6+Ue.height>ee.height-8?"calc(100% + 6px)":"auto"}Ee(),p?.()}function me(ee){if(ee?.closest?.("[data-hcms-ghost]"))return null;for(let ce=ee;ce&&ce.nodeType===1;ce=ce.parentElement){let ge=g.get(ce);if(ge)return ge}return null}function Q(ee){I&&!I.node.contains(ee.target)&&et();let ce=z();m=me(ee.target),m&&t.contains(ee.target)&&(v=null),z()!==ce&&H()}function L(ee){if(ee.relatedTarget||!m)return;let ce=z();m=null,z()!==ce&&H()}function Ee(){if(!b||$.hidden)return;let ee=b.getBoundingClientRect();$.style.width=`${Math.round(ee.width)}px`,$.style.height=`${Math.round(ee.height)}px`,$.style.transform=`translate(${Math.round(ee.left)}px, ${Math.round(ee.top)}px)`}function xe(){if(!o||typeof o.IntersectionObserver!="function"){for(let ce of s)ce.visible=!0;return}u||(u=new o.IntersectionObserver(ce=>{let ge=!1;for(let Ue of ce)for(let ke of i.get(Ue.target)||[])ke.visible!==Ue.isIntersecting&&(ke.visible=Ue.isIntersecting,ge=!0);ge&&H()},{threshold:0}));let ee=new Set(i.keys());for(let ce of d)ee.has(ce)||u.unobserve(ce);for(let ce of ee)d.has(ce)||u.observe(ce);d=ee}function se(){f||!o||(o.addEventListener("scroll",H,{passive:!0,capture:!0}),o.addEventListener("resize",H,{passive:!0}),e.addEventListener("focusin",Q),e.addEventListener("focusout",L),e.addEventListener("pointerdown",Oe,!0),e.addEventListener("keydown",_,!0),f=!0)}function V(){!f||!o||(o.removeEventListener("scroll",H,{capture:!0}),o.removeEventListener("resize",H),e.removeEventListener("focusin",Q),e.removeEventListener("focusout",L),e.removeEventListener("pointerdown",Oe,!0),e.removeEventListener("keydown",_,!0),f=!1)}function Se(ee){return`${ee.kind}\0${ee.attr||""}`}function ve(ee,ce){return ee.container===ce.container&&ee.scalar===ce.scalar}function Me(ee,ce){return ee.kind!==ce.kind?!1:ee.kind==="handle"?Se(ee.target)===Se(ce.target):ee.kind==="row"?ee.row===ce.row&&ve(ee.list,ce.list):ve(ee.list,ce.list)}function He(ee,ce){ee.target=ce;let ge=ce.path.join(".");ee.node.setAttribute("data-hcms-target",ge),ce.icon?ee.node.setAttribute("data-hcms-icon",ce.icon):ee.node.removeAttribute("data-hcms-icon"),ee.node.setAttribute("aria-label",`Edit ${ge}`)}function Ve(ee){let ce=e.createElement("button");ce.type="button",ce.className="hcms-inline-handle mirk-button mirk-button--small",ce.innerHTML=`<span class="mirk-button__label">${hr("edit")}</span>`;let ge={node:ce,kind:"handle",target:ee};return He(ge,ee),ce.addEventListener("click",Ue=>{Ue.preventDefault(),Ue.stopPropagation(),n?.(ge.target,ce)}),ge}function it(ee,ce){let ge=e.createElement("button");return ge.type="button",ge.className="hcms-inline-list-button mirk-button mirk-button--small",ge.setAttribute("data-hcms-list-action",ee),ge.setAttribute("aria-label",ce),ge.innerHTML=`<span class="mirk-button__label">${hr(ee)}${ee==="add"?"<span>Add</span>":""}</span>`,ge}function le(ee,{list:ce,row:ge,rowIndex:Ue,count:ke}){let Je=ce.path.join(".");ee.list=ce,ee.row=ge,ee.index=Ue,ee.count=ke,ee.node.setAttribute("data-hcms-list",Je),ee.node.setAttribute("data-hcms-row",String(Ue));for(let kt of ee.node.querySelectorAll("[data-hcms-list-action]")){let ht=kt.getAttribute("data-hcms-list-action"),wt=Oc.find(([ze])=>ze===ht)?.[1]||ht;kt.setAttribute("aria-label",`${wt} ${Je}.${Ue}`),kt.disabled=ht==="move-up"&&Ue===0||ht==="move-down"&&Ue===ke-1}}function yt(ee,ce,ge,Ue){let ke=e.createElement("div");ke.className="hcms-inline-row-controls";let Je={node:ke,kind:"row",list:ee,row:ce,index:ge,count:Ue};for(let[kt,ht]of Oc){let wt=it(kt,ht);wt.addEventListener("click",ze=>{ze.preventDefault(),ze.stopPropagation(),!wt.disabled&&r?.({action:kt,list:Je.list,index:Je.index,row:Je.row})}),ke.appendChild(wt)}return le(Je,{list:ee,row:ce,rowIndex:ge,count:Ue}),Je}function et(ee=!1){if(!I)return;let ce=I;I=null,ce.menu.hidden=!0,ce.button.setAttribute("aria-expanded","false"),ce.node.parentElement?.classList.remove("has-open-settings"),ee&&ce.button.isConnected&&ce.button.focus({preventScroll:!0})}function Oe(ee){I&&!I.node.contains(ee.target)&&et()}function _(ee){I&&(ee.key==="Escape"?(ee.preventDefault(),ee.stopPropagation(),et(!0)):ee.key==="Tab"?et(!0):["ArrowDown","ArrowUp","Home","End"].includes(ee.key)&&I.menu.contains(ee.target)&&(ee.preventDefault(),I.menu.querySelector('[role="menuitem"]').focus({preventScroll:!0})))}function B(ee,{list:ce,row:ge,rowIndex:Ue}){Object.assign(ee,{list:ce,row:ge,index:Ue}),ee.node.setAttribute("data-hcms-list",ce.path.join(".")),ee.node.setAttribute("data-hcms-row",String(Ue)),ee.button.setAttribute("aria-label",`Settings ${ce.path.join(".")}.${Ue}`)}function fe(ee){let ce=e.createElement("div");ce.className="hcms-inline-settings";let ge=it("settings","Settings");ge.setAttribute("aria-haspopup","menu"),ge.setAttribute("aria-expanded","false");let Ue=e.createElement("div");Ue.className="hcms-inline-settings-menu",Ue.setAttribute("role","menu"),Ue.setAttribute("aria-label","Item settings"),Ue.hidden=!0;let ke=e.createElement("button");ke.type="button",ke.setAttribute("role","menuitem"),ke.setAttribute("data-hcms-list-action","remove"),ke.textContent="Delete",Ue.appendChild(ke),ce.append(ge,Ue);let Je={node:ce,button:ge,menu:Ue,kind:"settings"};B(Je,ee);let kt=()=>{et(),I=Je,Ue.hidden=!1,ge.setAttribute("aria-expanded","true"),ce.parentElement.classList.add("has-open-settings"),ke.focus({preventScroll:!0}),H()};return ge.addEventListener("click",ht=>{ht.preventDefault(),ht.stopPropagation(),I===Je?et(!0):kt()}),ge.addEventListener("keydown",ht=>{(ht.key==="ArrowDown"||ht.key==="ArrowUp")&&(ht.preventDefault(),kt())}),ke.addEventListener("click",ht=>{ht.preventDefault(),ht.stopPropagation(),et(!0),r?.({action:"remove",list:Je.list,index:Je.index,row:Je.row})}),Je}function Ae(ee,ce){ee.kind==="handle"?He(ee,ce.target):ee.kind==="row"?le(ee,ce):ee.kind==="settings"&&B(ee,ce)}function pe(ee,ce,ge,Ue,ke){let Je=ce.get(ge)?.find(kt=>kt.category===ke);if(!Je){Je={el:ge,category:ke,members:[]},ee.push(Je);let kt=ce.get(ge);kt?kt.push(Je):ce.set(ge,[Je])}Je.members.push(Ue)}function Qe(ee,ce,ge){let Ue=ge.items||[];Ue.forEach((ke,Je)=>{go(ke)&&(pe(ee,ce,ke,{kind:"row",list:ge,row:ke,rowIndex:Je,count:Ue.length},"item"),pe(ee,ce,ke,{kind:"settings",list:ge,row:ke,rowIndex:Je},"item"))})}function qe(ee,ce){let ge=new Set(ee.members),Ue=[];for(let ke of ce){let Je=ee.members.find(kt=>ge.has(kt)&&Me(kt,ke))||(ke.kind==="handle"?Ve(ke.target):ke.kind==="row"?yt(ke.list,ke.row,ke.rowIndex,ke.count):fe(ke));ge.delete(Je),Ae(Je,ke),y&&Je.kind!=="handle"&&(Je.node.hidden=!0),Ue.push(Je)}for(let ke of ge)ke===I&&et(),ke.node.remove();Ue.sort((ke,Je)=>["row","handle","settings"].indexOf(ke.kind)-["row","handle","settings"].indexOf(Je.kind)),Ue.forEach((ke,Je)=>{ee.node.children[Je]!==ke.node&&ee.node.insertBefore(ke.node,ee.node.children[Je]||null)}),ee.members=Ue}function rt(ee,ce){let ge=[],Ue=new Map,ke=new Map,Je=0;for(let ze of ee||[])ke.has(ze.el)||ke.set(ze.el,ze),!(ze.kind!=="handle"||!go(ze.el))&&(pe(ge,Ue,ze.el,{kind:"handle",target:ze},"item"),Je++);for(let ze of ce||[])Qe(ge,Ue,ze);let kt=new Set(s),ht=new Map;for(let ze of s)ht.has(ze.el)||ht.set(ze.el,ze.visible);let wt=[];for(let ze of ge){let Ot=s.find(T=>kt.has(T)&&T.el===ze.el&&T.category===ze.category);if(!Ot){let T=e.createElement("div");T.className="hcms-inline-item-controls",T.setAttribute("role","group"),Ot={el:ze.el,node:T,category:ze.category,kind:ze.category==="add"?"add":"handle",members:[],visible:ht.get(ze.el)??!1},t.appendChild(T)}kt.delete(Ot),Ot.el=ze.el,Ot.category=ze.category,qe(Ot,ze.members),Ot.kind=Ot.members.some(T=>T.kind==="row")?"row":Ot.members.some(T=>T.kind==="handle")?"handle":"add",Ot.node.setAttribute("aria-label",Ot.category==="add"?"List controls":"Item controls"),wt.push(Ot)}for(let ze of kt)ze.node.remove();s=wt,i=new Map,g=new Map;for(let ze of s){let Ot=i.get(ze.el);Ot?Ot.push(ze):i.set(ze.el,[ze]);for(let T of ze.members)T.kind!=="row"&&T.kind!=="settings"||(g.set(T.row,T.row),g.set(T.node,T.row),g.set(ze.node,T.row))}v&&!g.has(v)&&(v=null),m&&!g.has(m)&&(m=null),a=ke,l=Je}function lt(){et(),u?.disconnect(),u=null,d=new Set;for(let ee of s)ee.node.remove();s=[],i=new Map,a=new Map,g=new Map,l=0}return{setTargets(ee,ce){rt(ee,ce),Y.setLists(ce),xe(),se(),H()},refresh:H,get count(){return l},get controlsHidden(){return y},setControlsHidden(ee){if(y=!!ee,Y.setHidden(y),y){et();for(let ce of s){for(let ge of ce.members)ge.kind!=="handle"&&(ge.node.hidden=!0);ce.members.every(ge=>ge.node.hidden)&&(ce.node.hidden=!0)}}H()},elementToTarget(ee){if(ee?.closest?.("[data-hcms-ghost]"))return null;for(let ce=ee;ce&&ce.nodeType===1;ce=ce.parentElement){let ge=a.get(ce);if(ge)return ge}return null},setHoveredRow(ee){let ce=z();v=ee?me(ee):null,z()!==ce&&H()},showHighlight(ee){ee&&(b=ee,$.hidden=!1,Ee())},hideHighlight(){b=null,$.hidden=!0},setFollower(ee){p=typeof ee=="function"?ee:null},destroy(){Y.destroy(),h&&o&&o.cancelAnimationFrame(h),h=0,p=null,b=null,v=null,m=null,$.remove(),V(),lt()}}}var Fh="hypercms-inline",xo="is-hcms-inline-active",Fi="is-hcms-inline-onpath",Cc='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])',qh=["bold","italic","link","undo","redo"],Bh=/^H[1-6]$/,Hh=0;function Lc({doc:e,pageRoot:t,opts:n={}}){let r=n.richText!==!1,o=null,s=null,i=null,l=new Map,a=null,u=null,d=null;function h(f,p,b,v,m){let g=Dr(e.defaultView);if(typeof g!="function")return null;let y=m||{},I=y.originalHTML??Pi(p,{capability:"history"}).html(),Y=y.richClayIsOurs??!p.hasAttribute("data-richclay"),$=y.adopted??p.getAttribute("data-richclay-active")==="true",H=ko(p,v,"history"),z=$h(f,g,p,v,Y);if(!z)return null;Va(p,v==="innerHTML",Y);let ae=String(++Hh);p.setAttribute(Yn,ae),ps();let me={el:p,editor:z,path:b,prop:v,boundId:ae,originalHTML:I,oldValue:H,richClayIsOurs:Y,adopted:$,dirty:!1,written:!1,restorable(){return!this.adopted&&!this.dirty&&!this.written},lastEdited:void 0};l.set(p,me),$a(ae,me);let Q=z.squire;if(Q&&typeof Q.addEventListener=="function"){let Ee=()=>{me.dirty=!0,me.lastEdited=ko(p,me.prop,"history"),Uh(f,me)};Q.addEventListener("input",Ee),me.detachInput=()=>Q.removeEventListener?.("input",Ee)}let L=()=>Ic(me);return p.addEventListener("blur",L),me.detachBlur=()=>p.removeEventListener("blur",L),me}return{name:"inline",richText:r,ctx:null,root:null,formRoot:null,errorEl:null,noticeEl:null,handoffEl:null,handoffCountEl:null,popEl:null,enhanceFormRichText:!1,prepareRules(f){return r?Ya(f,t):f},bindText(f,p,b,v){return h(this.ctx,f,p,b,v)},mount(f){let p=this.ctx;o=Gh(e,n.theme),this.root=o.root,this.formRoot=o.formRoot,this.errorEl=o.errorEl,this.noticeEl=o.noticeEl,this.handoffEl=o.handoffEl,this.handoffCountEl=o.handoffCountEl,this.popEl=o.popEl,Fn(()=>po(e));let b=Lr({pageRules:p.pageRules,formRules:p.formRules,data:f,doc:e});o.formRoot.appendChild(b),p.seeder.seed(o.formRoot),Xn(o.formRoot,e,this.enhanceFormRichText),zr(p),ns(p),s=Nc({doc:e,layerEl:o.layerEl,onActivate:(v,m)=>this.activate(v,m),onListAction:v=>this.listAction(v)}),s.setFollower(()=>this.placePopover()),o.closeEl.addEventListener("click",()=>this.deactivate()),o.toggleEl.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),this.toggleControls()}),o.handoffEl.querySelector("[data-hcms-open-view]").addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),p.onViewRequested?.("sidebar")}),this.bindPage(),this.syncTargets()},listAction({action:f,list:p,index:b,row:v}){let m=this.ctx,g=p.path.join("."),y=m.formRoot.querySelector(`[data-hcms-path="${Hr(g)}"]`);if(!y)return;if(f==="add"){ho(g,m);return}let I=v?Xh(m,g,v):b;if(I===-1)return;let Y=Yh(y,I);if(Y){if(f==="remove"){Si(Y,m),this.syncTargets();return}Ai(Y,f==="move-up"?-1:1,m),this.syncTargets()}},toggleControls(){if(!s||!o)return;let f=!s.controlsHidden;s.setControlsHidden(f),o.toggleEl.setAttribute("aria-pressed",String(f));let p=o.toggleEl.querySelector(".mirk-button__label");p&&(p.textContent=f?"Show controls":"Hide controls")},bindPage(){let f=this.ctx.pageRoot,p=o.root,b=Y=>{let $=s&&s.elementToTarget(Y.target);$?s.showHighlight($.el):s?.hideHighlight(),s?.setHoveredRow(Y.target)},v=()=>{s?.hideHighlight(),s?.setHoveredRow(null)},m=Y=>{if(p.contains(Y.target))return;let $=s&&s.elementToTarget(Y.target);!$||$.kind!=="text"||l.has($.el)||h(this.ctx,$.el,$.path.join("."),bs($))},g=Y=>{if(p.contains(Y.target))return;let $=s&&s.elementToTarget(Y.target);if(!$){this.deactivate();return}(typeof Y.target.closest=="function"&&Y.target.closest("a[href]")||$.kind!=="text")&&Y.preventDefault(),this.activate($)},y=Y=>{Y.key==="Escape"&&this.deactivate()},I=Y=>{let $=Y.detail;if(!(!$||$.pageRoot!==this.ctx.pageRoot||!$.path))for(let H of l.values())H.path===$.path&&(H.written=!0)};f.addEventListener("pointerover",b),f.addEventListener("pointerleave",v),f.addEventListener("pointerdown",m),f.addEventListener("click",g),p.addEventListener("keydown",y),e.addEventListener("hcms:change",I),i=()=>{f.removeEventListener("pointerover",b),f.removeEventListener("pointerleave",v),f.removeEventListener("pointerdown",m),f.removeEventListener("click",g),p.removeEventListener("keydown",y),e.removeEventListener("hcms:change",I)}},activate(f,p){if(!f||!o||f.kind==="text"&&this.activateText(f))return;let b=Mc(this,o,f.path.join("."));if(!b){this.deactivate();return}a=f,u=p||null,d=null,o.popEl.hidden=!1,o.formRoot.querySelectorAll(`.${xo}`).forEach(Rc),this.placePopover(),Kh(b)},activateText(f){let p=f.el,b=l.get(p);if(b)return gs(b),!0;let v=h(this.ctx,p,f.path.join("."),bs(f));return v?(gs(v),!0):!1},placePopover(){if(!o||!a||o.popEl.hidden)return;let f=e.defaultView;if(!f)return;let p={width:f.innerWidth,height:f.innerHeight},b=a.el.getBoundingClientRect(),v=o.popEl.getBoundingClientRect(),{mode:m,x:g,y}=vc({anchor:b,bar:v,viewport:p,current:d});d=m,o.popEl.style.transform=`translate(${Math.round(g)}px, ${Math.round(y)}px)`},deactivate(){if(!o||!a&&o.popEl.hidden)return;o.popEl.hidden=!0,Pc(o.root);let f=u;if(a=null,u=null,d=null,f&&e.contains(f)&&typeof f.focus=="function")try{f.focus({preventScroll:!0})}catch{f.focus()}},syncTargets(){if(!s)return;let f=this.ctx,{targets:p,lists:b}=Ii(f.pageRoot,f.pageRules);s.setTargets(p,b);let v=zh(this,l,p,e);if(a){let g=v.get(a.el)||[],y=g.find(I=>Vh(I,a))||g.find(I=>I.path.join(".")===a.path.join("."))||(g.length===1?g[0]:null);y?a=y:this.deactivate()}Wh(this.ctx,l,e);let m=p.reduce((g,y)=>g+(go(y.el)?0:1),0);this.handoffEl&&(this.handoffCountEl.textContent=m===0?"":`${m} ${m===1?"field isn't":"fields aren't"} visible right now.`,this.handoffEl.hidden=m===0)},refresh(f,p){f==="livesync"?(Qn(e),po(e),er(this.ctx,{ignoreActiveValue:!0})):f==="undo"?er(this.ctx,{ignoreActiveValue:!1}):er(this.ctx),this.syncTargets(),(f==="livesync"||f==="undo")&&this.rebindText(f),this.restoreActive()},rebindText(f){let p=f!=="undo";for(let[b,v]of[...l]){if(!e.contains(b)){yo(this.ctx,v,{restore:!1,record:p}),l.delete(b);continue}if(b.hasAttribute(On)){let y=ko(b,v.prop);y!==v.lastEdited&&(v.oldValue=y,v.lastEdited=void 0);continue}let m=e.activeElement===b;yo(this.ctx,v,{restore:!1,record:p}),l.delete(b);let g=h(this.ctx,b,v.path,v.prop,{richClayIsOurs:v.richClayIsOurs,adopted:v.adopted});g&&m&&gs(g)}},restoreActive(){if(!o||!a||o.popEl.hidden)return;if(!e.contains(a.el)){this.deactivate();return}if(!Mc(this,o,a.path.join("."))){this.deactivate();return}o.formRoot.querySelectorAll(`.${xo}`).forEach(Rc),this.placePopover()},focusOnOpen(){if(this.root&&typeof this.root.focus=="function")try{this.root.focus({preventScroll:!0})}catch{this.root.focus()}},destroy(){u=null,this.deactivate();for(let f of l.values())yo(this.ctx,f);l.clear(),i?.(),i=null,s?.destroy(),s=null,o?.destroy(),o=null,Ni(e),this.popEl=null,this.handoffEl=null,this.handoffCountEl=null}}}function $h(e,t,n,r,o){return Fn(()=>{let s=null;try{s=new t(n,{inline:!0,hyperclay:!1,toolbar:r==="innerHTML"?qh:!1,...Bh.test(n.tagName)?{singleLine:!0}:null})}catch(i){return console.warn("[hypercms] richclay activation failed; the field falls back to the popover",i),null}if(s.unsupported||!s.active){if(o)try{s.destroy()}catch{}return null}return typeof s.reattach=="function"&&s.reattach(),s})}function Uh(e,{path:t,el:n,prop:r}){let o=rs(e.formRoot,t);o&&(os(o,ko(n,r),e.formRoot,t),kn(fn(e),{path:t,structural:!1},e))}function ko(e,t,n="data"){let r=Pi(e,{capability:n});return t==="innerHTML"?r.html():r.text().trim()}function Ic(e){let{el:t,prop:n,oldValue:r,lastEdited:o}=e,s=o;if(s===void 0||s===r)return;e.oldValue=s;let i=Jt("undo");if(!i||typeof i.recordValue!="function")return;let l={prop:n,oldValue:r,newValue:s,read:a=>ko(a,n,"history"),write:(a,u)=>jc(a,n,u)};i.isPaused?queueMicrotask(()=>{t.isConnected&&i.recordValue(t,l)}):i.recordValue(t,l)}function jc(e,t,n){let r=e.cloneNode(!1);t==="innerHTML"?r.innerHTML=n:r.textContent=n,Kn(e,Array.from(r.childNodes),{morphStyle:"innerHTML",policy:"history",restoreFocus:!1,scripts:{handle:!1,merge:!1}})}function yo(e,t,{restore:n=!0,record:r=!0}={}){r&&Ic(t),t.detachInput?.(),t.detachBlur?.(),Fn(()=>{if(!t.adopted){try{t.editor.destroy()}catch(o){console.warn("[hypercms] richclay teardown failed; editor state may reach the save",o)}t.richClayIsOurs&&t.el.removeAttribute("data-richclay")}t.el.removeAttribute(On),t.el.removeAttribute(fr),t.el.removeAttribute(Yn),Ua(t.boundId),n&&t.restorable()&&jc(t.el,"innerHTML",t.originalHTML)})}function gs(e){let{editor:t,el:n}=e;if(n.ownerDocument.activeElement!==n)try{typeof t.focus=="function"?t.focus():n.focus()}catch{}}function zh(e,t,n,r){let o=new Map;for(let s of n){let i=o.get(s.el);i?i.push(s):o.set(s.el,[s])}for(let[s,i]of[...t]){let l=o.get(s)||[],a=l.find(f=>bs(f)===i.prop)||l[0];if(!a){yo(e.ctx,i,{restore:!0}),t.delete(s);continue}i.path=a.path.join(".");let u=bs(a);if(u===i.prop)continue;let d=r.activeElement===s;yo(e.ctx,i,{restore:!1}),t.delete(s);let h=e.bindText(s,i.path,u,{richClayIsOurs:i.richClayIsOurs,adopted:i.adopted,originalHTML:i.originalHTML});h&&d&&gs(h)}return o}function Vh(e,t){return e.el===t.el&&e.kind===t.kind&&e.attr===t.attr}function bs(e){return e.attr==="innerHTML"?"innerHTML":"textContent"}function Wh(e,t,n){for(let r of e.pageRoot.querySelectorAll(`[${On}]`))t.has(r)||Fn(()=>Ka(r,n.defaultView))}function Mc(e,t,n){let r=e.formRoot&&e.formRoot.querySelector(`[data-hcms-path="${Hr(n)}"]`);if(Pc(t.root),!r)return null;let o=r.closest("[data-hcms-card]"),s=o?[...o.querySelectorAll('[data-hcms-shape="scalar"][data-hcms-path]')].filter(i=>i.closest("[data-hcms-card]")===o&&i.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]')===o.parentElement.closest('[data-hcms-shape="object-array"]')):[r];s.includes(r)||s.push(r);for(let i of s){i.classList.add(xo),i.removeAttribute("draggable");for(let l=i.parentElement;l&&(l.classList.add(Fi),l.removeAttribute("draggable"),l!==e.formRoot);l=l.parentElement);}return r}function Pc(e){if(e)for(let t of e.querySelectorAll(`.${xo}, .${Fi}`))t.classList.remove(xo,Fi)}function Rc(e){e.tagName==="TEXTAREA"&&Fr(e),e.querySelectorAll?.("textarea").forEach(Fr)}function Kh(e){let t=e.matches?.(Cc)?e:e.querySelector?.(Cc);if(!(!t||typeof t.focus!="function"))try{t.focus({preventScroll:!0})}catch{t.focus()}}function Gh(e,t){Qn(e);let n=e.createElement(Fh),r=t==="dark"?" dark":t==="light"?" light":"";return n.className="hcms-shell pixel-quiet hcms-inline"+r,n.setAttribute("data-hcms-shell",""),n.setAttribute("editor-ui",""),n.setAttribute("no-save",""),n.setAttribute("save-remove",""),n.setAttribute("snapshot-remove",""),n.setAttribute("no-watch",""),n.setAttribute("tabindex","-1"),n.innerHTML=`
180
+ `,(e||i.body).appendChild(c);let p=i.body;p.classList.add("hcms-open"),Io(i),n&&p.classList.add("hcms-overlay"),t==="left"&&p.classList.add("hcms-side-left");let y=gm(c,i),m=pm(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(){y.detach(),m.detach(),c.remove(),p.classList.remove("hcms-open","hcms-overlay","hcms-side-left"),nl(i)},restoreChrome(){dr(i),p.classList.add("hcms-open"),Io(i),n&&p.classList.add("hcms-overlay"),t==="left"&&p.classList.add("hcms-side-left")}}}function dr(e){e&&(e.getElementById(Es)||e.querySelector("style[data-hcms-bundled-styles]")||(so.delete(e),Jc(e)))}function Jc(e){if(e&&!so.has(e)){if(e[dm]){so.add(e);return}if(e.getElementById(Es)||e.querySelector("style[data-hcms-bundled-styles]")){so.add(e);return}if(tl){let t=e.createElement("style");t.id=Es,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=tl,(e.head||e.documentElement).appendChild(t),so.add(e);return}try{let t=new URL("./theme.generated.css",bm.url).href,n=e.createElement("link");n.rel="stylesheet",n.id=Es,n.setAttribute("save-remove",""),n.setAttribute("save-ignore",""),n.href=t,(e.head||e.documentElement).appendChild(n),so.add(e)}catch{let n=()=>{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(n):n()}}}function pm(e){let t=e.querySelector(".hcms-shell-body"),n=e.querySelector(".hcms-shell-header");if(!t||!n||typeof t.addEventListener!="function")return{detach(){}};let r=()=>{let o=(n.offsetHeight||0)-12;e.classList.toggle("is-condensed",t.scrollTop>o)};return t.addEventListener("scroll",r,{passive:!0}),r(),{detach(){t.removeEventListener("scroll",r)}}}function gm(e,t){function n(r){if(r.key!=="Tab"||!e.contains(t.activeElement))return;let o=Array.from(e.querySelectorAll(hm));if(o.length===0)return;let s=o[0],l=o[o.length-1];r.shiftKey&&t.activeElement===s?(r.preventDefault(),l.focus()):!r.shiftKey&&t.activeElement===l&&(r.preventDefault(),s.focus())}return t.addEventListener("keydown",n),{detach:()=>t.removeEventListener("keydown",n)}}var km="[hypercms]",Zc={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Qc={skip:"[data-hcms-shell]",templateAttr:null},rl=class extends Error{constructor(t,n,r){super(`hypercms: rule at "${t}" has an invalid CSS selector: "${n}"`),this.name="InvalidRuleSelector",this.path=t,this.selector=n,this.cause=r}};function Ns(e,t){let n=[],r=[],o=[];return sl(Xn(e),e,t,[],n,r,o),{missing:ef(n),twins:Am(r),readOnly:ef(o)}}function Cs(e){return ol(e)}function ol(e){if(typeof e=="string")return tf(e)?void 0:e;if(Array.isArray(e)){let[t,n]=e;return[t,ol(n)]}if(e&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e)){let o=ol(r);o!==void 0&&(t[n]=o)}return t}return e}function sl(e,t,n,r,o,s,l){if(typeof n=="string"){let i=ym(n),a=i?Os(e,t,i,Zc,r):[];if(tf(n)){l.push(io(r));return}if(!i)return;if(n.endsWith("[]")){a.length===0&&Os(e,t,i,Qc,r).length===0&&o.push(io(r));return}a.length===0?o.push(io(r)):a.length>1&&s.push({path:io(r),count:a.length});return}if(Array.isArray(n)){let[i,a]=n;if(typeof i!="string"||!i)return;let c=Os(e,t,i,Zc,r);if(c.length===0){Os(e,t,i,Qc,r).length===0&&o.push(io(r));return}for(let h of c)sl(e,h,a,[...r,"*"],o,s,l);return}if(n&&typeof n=="object")for(let[i,a]of Object.entries(n))sl(e,t,a,[...r,i],o,s,l)}function Os(e,t,n,r,o){try{return e.find(t,n,r)}catch(s){throw new rl(io(o),n,s)}}function ym(e){if(e==="."||e.startsWith("@"))return null;if(e.endsWith("[]"))return e.slice(0,-2)||null;let t=rn(e);return(t===-1?e:e.slice(0,t))||null}function xm(e){if(e.endsWith("[]"))return null;let t=rn(e);return t===-1?null:e.slice(t+1)||null}function tf(e){let t=xm(e);return t!=null&&Ur.has(t)}function lo(e){vm(e),wm(e)}function vm(e){let t=e.noticeEl;if(!t)return;let n=e.unresolved&&e.unresolved.missing||[],r=e.unresolved&&e.unresolved.readOnly||[];if(n.length===0&&r.length===0){t.textContent="",t.hidden=!0;return}let o=[];if(n.length){let s=n.length===1?"1 field no longer matches this page":`${n.length} fields no longer match this page`;o.push(`${s}: ${n.join(", ")}`)}if(r.length){let s=r.length===1?"1 field reads a property the browser will not let anything write":`${r.length} fields read properties the browser will not let anything write`;o.push(`${s}: ${r.join(", ")}`)}t.textContent=o.join(`
181
+ `),t.hidden=!1}function wm(e){let t=e.unresolved&&e.unresolved.twins||[],n=t.map(r=>`${r.path}:${r.count}`).join("|");if(n!==e.lastTwinSignature){e.lastTwinSignature=n;for(let{path:r,count:o}of t)console.warn(`${km} "${r}" matches ${o} elements; edits go to the first one.`)}}function ef(e){return[...new Set(e)]}function Am(e){let t=new Map;for(let n of e){let r=t.get(n.path);(!r||n.count>r.count)&&t.set(n.path,n)}return[...t.values()]}function io(e){return e.length?e.join("."):"(whole page)"}var Sm={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function hr(e,{ignoreActiveValue:t}={}){return Tm(e,{ignoreActiveValue:t})}function Tm(e,{ignoreActiveValue:t}){let n=pn.findRules(e.doc,e.rulesSource||"cms");n&&(e.pageRules=e.view.prepareRules(n.rules),e.rulesTagNode=n.tagNode),cs(e.doc),ms(e.doc,e.pageRules),e.formRules=gs(e.pageRules,e.doc),e.writeRules=Cs(e.pageRules),e.unresolved=Ns(e.pageRoot,e.pageRules);let r=is(),o=ur(pn.extract(e.pageRoot,e.pageRules,{...Sm,...r.hooks}),e.pageRules),s=Xr({pageRules:e.pageRules,formRules:e.formRules,data:o,doc:e.doc});ss(e.formRoot,s,{ignoreActiveValue:t}),r.seed(e.formRoot),cr(e.formRoot,e.doc,e.view?.enhanceFormRichText!==!1),Zi(e),lo(e),e.updateFingerprint&&e.updateFingerprint()}function nf({debounce:e=100,onRefresh:t}){let n=cn("Mutation");if(!n||typeof n.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 r=n.onAnyChange({debounce:e},o=>{t(o)});return{unsubscribe:typeof r=="function"?r:()=>{}}}var Em='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])';function rf({doc:e,pageRoot:t,opts:n={}}){let r=n.richText!==!1,o=null;return{name:"sidebar",richText:r,enhanceFormRichText:!0,ctx:null,root:null,formRoot:null,errorEl:null,noticeEl:null,prepareRules(s){return r?qc(s,t):s},mount(s){let l=this.ctx;o=Qn(()=>Xc({mountTo:n.mountTo||e.body,side:n.side||"right",overlay:!!n.overlay,showSaveButton:!!n.showSaveButton,title:n.title,eyebrow:n.eyebrow,theme:n.theme,doc:e})),this.root=o.root,this.formRoot=o.formRoot,this.errorEl=o.errorEl,this.noticeEl=o.noticeEl;let i=Xr({pageRules:l.pageRules,formRules:l.formRules,data:s,doc:e});o.formRoot.appendChild(i),l.seeder.seed(o.formRoot),cr(o.formRoot,e),lo(l),ws(l)},refresh(s){if(s==="livesync"){o?.restoreChrome?.(),hr(this.ctx,{ignoreActiveValue:!0});return}if(s==="undo"){hr(this.ctx,{ignoreActiveValue:!1});return}hr(this.ctx)},focusOnOpen(){let s=this.root&&this.root.querySelector(Em);s&&typeof s.focus=="function"&&s.focus()},destroy(){o?.destroy(),o=null}}}var _m="[cms-template], [data-hcms-shell]";function Lo(e){if(!e||typeof e.getBoundingClientRect!="function"||typeof e.closest=="function"&&e.closest(_m))return!1;let t=e.getBoundingClientRect();return t.width>=8&&t.height>=8}var Om={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Nm={skip:"[data-hcms-shell]",templateAttr:null},Cm="text",Mm="native",of="handle",Rm=new Set(["INPUT","TEXTAREA","SELECT"]),af=new Set(["IMG","INPUT","TEXTAREA","SELECT","OPTION","BR","HR","VIDEO","AUDIO","IFRAME","EMBED","OBJECT","CANVAS","SOURCE","TRACK","AREA","COL","PARAM","BUTTON"]);function ll(e,t){return Im(e,t)}function Im(e,t){let n=[],r=[],o=Xn(e);return il(o,e,t,[],n,r),{targets:n,lists:r}}function il(e,t,n,r,o,s){if(typeof n=="string"){if(n.endsWith("[]")){let h=n.slice(0,-2);if(!h)return;let u=Ms(e,t,h);u.forEach((f,d)=>{o.push(lf([...r,d],f,n,null))}),s.push(sf(e,t,r,h,u,!0));return}let l=rn(n),i=l===-1?null:n.slice(l+1),a=l===-1?n:n.slice(0,l),c=!a||a==="."?t:Ms(e,t,a)[0];c&&o.push(lf(r,c,n,i));return}if(Array.isArray(n)){let[l,i]=n;if(typeof l!="string"||!l)return;let a=Ms(e,t,l);a.forEach((c,h)=>il(e,c,i,[...r,h],o,s)),s.push(sf(e,t,r,l,a,typeof i=="string"));return}if(n&&typeof n=="object")for(let[l,i]of Object.entries(n))il(e,t,i,[...r,l],o,s)}function sf(e,t,n,r,o,s){let l=o[0]?o[0].parentElement:null;if(!l){let i=Ms(e,t,r,Nm)[0];l=i?i.parentElement:null}return{path:n,items:o,container:l,scalar:s}}function lf(e,t,n,r){return{path:e,el:t,rule:n,attr:r,kind:Lm(t,r),icon:Pm(t,r)}}function Lm(e,t){let n=(e.tagName||"").toUpperCase();return!t||t==="innerHTML"?af.has(n)?of:Cm:t==="value"&&Rm.has(n)&&!e.readOnly&&!jm(e)?Mm:of}function jm(e){return e.disabled?!0:typeof e.matches=="function"&&e.matches(":disabled")}function Pm(e,t){let n=(e.tagName||"").toUpperCase();return(!t||t==="innerHTML")&&!af.has(n)?null:n==="IMG"||t==="srcset"?"camera":n==="A"&&t==="href"?"paperclip":"pencil"}function Ms(e,t,n,r=Om){try{return e.find(t,n,r)}catch{return[]}}var cf=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"]})}),Dm=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Zx=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function al(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Fm(e,t){if(al(e,t))return!0;for(let[n,r]of Object.entries(Dm))if(r.includes(t)&&al(e,n))return!0;return!1}function jo(e){let t=cf[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Bm(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=cf[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>Fm(n,o))||r.bundles.some(o=>al(n,o)))return n;n=n.parentElement}return null}function ff(e,t){return!!Bm(e,t)}var qm=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function uf(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),e.tagName==="SELECT")for(let r=0;r<e.options.length;r++)t.options[r].selected=e.options[r].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function df(e,t,n,r){if(r)return!!e.closest?.(t);let o=e;for(;o?.nodeType===1;){if(o.matches(t))return!0;if(o===n)break;o=o.parentElement}return!1}function hf(e,t,n,r,o,s,l,i){if(e.nodeType===1&&((l?ff(e,n):df(e,r,s,!1))||o&&(l&&e!==s?e.matches(o):df(e,o,s,l))))return null;let a=t.importNode(e,!1);i.cloneToLive.set(a,e),i.liveToClone.set(e,a);let c=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,h=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;c!==e&&(i.cloneToLive.set(h,c),i.liveToClone.set(c,h));for(let u of c.childNodes||[]){let f=hf(u,t,n,r,o,s,l,i);f&&(h.appendChild(f),u.nodeType===1&&uf(u,f))}return e.nodeType===1&&uf(e,a),a}function cl(e,{capability:t="data",exclude:n=null,inherit:r=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=o.implementation.createHTMLDocument(""),l=new WeakMap,i=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let c=jo(t),h=hf(a,s,t,c,n,a,r,{cloneToLive:l,liveToClone:i});e.nodeType===9&&h&&(s.replaceChild(h,s.documentElement),i.set(e,s),l.set(s,e));let u=f=>{if(qm.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:h,document:s,capability:t,selector:jo(t),cloneToLive:l,liveToClone:i,original(f){return l.get(f)||null},cloneOf(f){return i.get(f)||null},query(f,d=h){return u(f),Array.from(d.querySelectorAll(f),p=>l.get(p)||p)},text(f=h){return(f===h?h:i.get(f))?.textContent||""},html(f=h){return(f===h?h:i.get(f))?.innerHTML??""},clone(f=h){let d=f===h?h:i.get(f);return d?s.importNode(d,!0):null}}}var Um=[16,8,0],fn=8,$m=4;function mf({anchor:e,bar:t,rail:n=t,viewport:r,current:o=null}){let s=f=>o===f?$m:0;if(e.bottom<=0||e.top>=r.height||e.right<=0||e.left>=r.width)return{mode:"hidden",x:0,y:0};let l=f=>Math.max(fn,Math.min(e.left,r.width-f-fn)),i=e.top-16-t.height;if(i>=fn-s("above"))return{mode:"above",x:l(t.width),y:i};let a=e.bottom+16;if(a+t.height<=r.height-fn+s("below"))return{mode:"below",x:l(t.width),y:a};let c=r.width-e.right-fn,h=e.left-fn,u=c>=h?[["rail-right",c],["rail-left",h]]:[["rail-left",h],["rail-right",c]];for(let[f,d]of u)for(let p of Um){if(n.width+p>d+s(f))continue;let y=f==="rail-right"?Math.min(e.right+p,r.width-n.width-fn):Math.max(e.left-p-n.width,fn),m=Math.min(e.bottom,r.height-fn)-n.height,g=Math.max(fn,Math.min(Math.max(e.top,fn),m));return{mode:f,x:y,y:g,gap:p}}return{mode:"pinned",x:l(t.width),y:fn}}function fl({anchor:e,handle:t,viewport:n,inset:r=6,prefer:o="auto"}){let s=e.height>=t.height*1.5&&e.width>=t.width*2;if(o==="corner"||s){let f=Math.max(fn,Math.min(e.right-t.width+r,n.width-t.width-fn)),d=Math.max(fn,Math.min(e.top-r,n.height-t.height-fn));return{x:f,y:d,mode:"over"}}let l=4,i=e.right+l+t.width<=n.width-fn,a=i?e.right+l:e.left-l-t.width,c=Math.max(fn,a),h=e.top+e.height/2-t.height/2,u=Math.max(fn,Math.min(h,n.height-t.height-fn));return{x:c,y:u,mode:i?"beside-right":"beside-left"}}var Is=!1;function pf(){if(Is)return;let e=cn("onPrepareForSave");typeof e=="function"&&(e(t=>{bf(t),gf(t)}),Is=!0)}function gf(e){let t=e&&e.querySelector&&e.querySelector("body");t&&t.classList.remove("hcms-open","hcms-overlay","hcms-side-left",_s)}function bf(e){if(!(!e||typeof e.querySelectorAll!="function"))for(let t of e.querySelectorAll(`[${ar}]`)){let n=Pc(t);n!==null&&(t.innerHTML=n),t.removeAttribute(ar)}}var Ls=!1;function js(){if(Ls)return;let e=cn("onSnapshot");typeof e=="function"&&(e(t=>{bf(t),Fc(t,typeof window<"u"?window:null),gf(t)}),Ls=!0)}function kf(){pf(),js(),(!Is||!Ls)&&Hm()}var Rs=null;function Hm(){if(Rs||typeof document>"u")return;Rs=Qr(document,Ic,()=>{pf(),js(),Is&&Ls&&(Rs?.(),Rs=null)})}var zm={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 _r(e){let t=e==="edit"?"6 0 18 18":"0 0 24 24",n=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="${zm[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">${n}</svg>`}var yf="data-hcms-ghost",Vm=jo("history");function Wm(e){let t=e.container,n=null;for(;t&&(t.namespaceURI!=="http://www.w3.org/1999/xhtml"||["SELECT","OPTGROUP","DATALIST"].includes(t.tagName));)n=t,t=t.parentElement;return{parent:t,anchor:n}}function xf({doc:e,themeRoot:t,onAdd:n,onResize:r}){let o=e.defaultView,s=[],l=!1,i=null,a=new Map;function c(d,p,y){d.style[p]!==y&&(d.style[p]=y)}function h(){let d=new Set(s.map(p=>p.node.parentElement));for(let[p,y]of a)d.has(p)&&o?.Sortable?.get(p)===y.instance||(y.instance.option("draggable")===y.selector&&y.instance.option("draggable",y.original),a.delete(p));for(let p of d){let y=o?.Sortable?.get(p);if(!y)continue;let m=y.option("draggable");if(a.get(p)?.selector===m)continue;let g=m,S=`${g.trim().startsWith(">")?"> ":""}:is(${g.trim().replace(/^>\s*/,"")}):not(${Vm})`;y.option("draggable",S),a.set(p,{instance:y,original:g,selector:S})}}function u(){for(let d of s){let{node:p,slot:y,list:m}=d,g=m.items.filter(k=>k.isConnected).map(k=>k.getBoundingClientRect()).filter(k=>k.width>0&&k.height>0);g.length&&(d.width=g.reduce((k,S)=>k+S.width,0)/g.length,d.height=g.reduce((k,S)=>k+S.height,0)/g.length),c(p,"width",d.width?`${Math.round(d.width)}px`:"100%"),c(y,"height",`${Math.max(48,Math.round(d.height||64))}px`),y!==p&&(y.colSpan=Math.max(1,...m.items.map(k=>[...k.children].reduce((S,v)=>S+(v.colSpan||1),0)))),p.hidden!==l&&(p.hidden=l)}h()}function f(d,p){let y=p.tagName,m=["TBODY","THEAD","TFOOT","TABLE"].includes(y),g=e.createElement(m?"tr":["UL","OL","MENU"].includes(y)?"li":"div");for(let x of[yf,"data-hcms-shell","editor-ui","no-watch","no-save","save-remove","snapshot-remove"])g.setAttribute(x,"");g.setAttribute("draggable","false"),g.setAttribute("contenteditable","false"),g.className="hcms-shell pixel-quiet hcms-inline-ghost";for(let x of["light","dark"])g.classList.toggle(x,!!t?.classList.contains(x));let k=m?e.createElement("td"):g;k!==g&&(k.className="hcms-inline-ghost-cell",g.appendChild(k));let S=e.createElement("button");S.type="button",S.className="hcms-inline-list-button hcms-inline-list-add mirk-button mirk-button--small",S.setAttribute("data-hcms-list-action","add"),S.innerHTML=`<span class="mirk-button__label">${_r("add")}<span>Add</span></span>`,k.appendChild(S);let v={node:g,slot:k,button:S,list:d,width:0,height:0};S.addEventListener("click",x=>{x.preventDefault(),x.stopPropagation(),n(v.list)});for(let x of["pointerdown","mousedown","touchstart","click"])g.addEventListener(x,O=>O.stopPropagation());return g.addEventListener("dragstart",x=>{x.preventDefault(),x.stopPropagation()}),v}return{setLists(d){let p=new Set(s),y=[],m=new Set(s.map(k=>k.node)),g=new Set;for(let k of d||[]){if(!k.container||!k.container.isConnected)continue;let{parent:S,anchor:v}=Wm(k);if(!S)continue;if(!g.has(S)){for(let C of S.querySelectorAll(`:scope > [${yf}]`))m.has(C)||C.remove();g.add(S)}let x=s.find(C=>p.has(C)&&C.list.container===k.container&&C.list.path.join(".")===k.path.join("."))||f(k,S);p.delete(x),x.list=k,x.button.setAttribute("data-hcms-list",k.path.join(".")),x.button.setAttribute("aria-label",`Add to ${k.path.join(".")||"the list"}`);let O=v||k.items.filter(C=>C.parentElement===S).at(-1);O?O.nextSibling!==x.node&&O.after(x.node):x.node.parentElement!==S&&S.appendChild(x.node),y.push(x)}for(let k of p)k.node.remove();s=y,i?.disconnect(),!i&&typeof o?.ResizeObserver=="function"&&(i=new o.ResizeObserver(()=>{u(),r?.()}));for(let k of s)for(let S of k.list.items)i?.observe(S);u()},update:u,setHidden(d){l=!!d,u()},destroy(){i?.disconnect();for(let d of s)d.node.remove();s=[],h()}}}var vf=[["move-up","Move up"],["move-down","Move down"]],Km={prefer:"corner",inset:0};function Gm(e,t){return t.width<=e.width&&t.height<=e.height}function wf({doc:e,layerEl:t,onActivate:n,onListAction:r}){let o=e.defaultView,s=[],l=new Map,i=0,a=new Map,c=null,h=new Set,u=0,f=!1,d=null,p=null,y=null,m=null,g=new Map,k=!1,S=null,v=xf({doc:e,themeRoot:t.closest("[data-hcms-shell]"),onResize:O,onAdd:Q=>r?.({action:"add",list:Q,index:Q.items.length})}),x=e.createElement("div");x.className="hcms-inline-highlight",x.hidden=!0,x.setAttribute("aria-hidden","true"),t.appendChild(x);function O(){if(!(u||!o)){if(typeof o.requestAnimationFrame!="function")return _();u=o.requestAnimationFrame(()=>{u=0,_()})}}let C=()=>y||m;function _(){if(!o)return;v.update();let Q={width:o.innerWidth,height:o.innerHeight},ce=C();for(let Re of s){if(!Re.visible){Re.node.hidden=!0;continue}for(let ht of Re.members)ht.node.hidden=k&&ht.kind!=="handle";Re.node.hidden=!1;let Ue=Re.el.getBoundingClientRect(),qe=Re.node.getBoundingClientRect(),ot=qe.width,xt=Re.kind==="row"&&!Gm(Ue,qe);if(xt&&Re.el!==ce){for(let ht of Re.members)ht.kind==="row"&&(ht.node.hidden=!0);qe=Re.node.getBoundingClientRect()}if(Re.members.every(ht=>ht.node.hidden)){Re.node.hidden=!0;continue}let kt=Re.kind==="handle"?null:Km,{x:Ct,y:dt}=fl({anchor:Ue,handle:qe,viewport:Q,...kt}),St=Re.members.find(ht=>ht.kind==="handle");if(xt&&St){let ht=St.node.getBoundingClientRect(),H=fl({anchor:Ue,handle:ht,viewport:Q}),ie=Re.members.slice(Re.members.indexOf(St)+1).filter(pe=>!pe.node.hidden).reduce((pe,ge)=>pe+ge.node.getBoundingClientRect().width+2,0);Ct=Math.max(8+ot,Math.min(Q.width-8,H.x+ht.width+ie))-qe.width,dt=H.y}Re.node.style.transform=`translate(${Math.round(Ct)}px, ${Math.round(dt)}px)`}if(S)if(!S.node.isConnected||S.node.closest("[hidden]"))Ge();else{let Re=S.button.getBoundingClientRect(),Ue=S.menu.getBoundingClientRect();S.menu.style.left=`${Math.max(8,Re.right-Ue.width)-Re.left}px`,S.menu.style.right="auto",S.menu.style.top=Re.bottom+6+Ue.height>Q.height-8?"auto":"calc(100% + 6px)",S.menu.style.bottom=Re.bottom+6+Ue.height>Q.height-8?"calc(100% + 6px)":"auto"}P(),d?.()}function M(Q){if(Q?.closest?.("[data-hcms-ghost]"))return null;for(let ce=Q;ce&&ce.nodeType===1;ce=ce.parentElement){let Re=g.get(ce);if(Re)return Re}return null}function j(Q){S&&!S.node.contains(Q.target)&&Ge();let ce=C();m=M(Q.target),m&&t.contains(Q.target)&&(y=null),C()!==ce&&O()}function I(Q){if(Q.relatedTarget||!m)return;let ce=C();m=null,C()!==ce&&O()}function P(){if(!p||x.hidden)return;let Q=p.getBoundingClientRect();x.style.width=`${Math.round(Q.width)}px`,x.style.height=`${Math.round(Q.height)}px`,x.style.transform=`translate(${Math.round(Q.left)}px, ${Math.round(Q.top)}px)`}function R(){if(!o||typeof o.IntersectionObserver!="function"){for(let ce of s)ce.visible=!0;return}c||(c=new o.IntersectionObserver(ce=>{let Re=!1;for(let Ue of ce)for(let qe of l.get(Ue.target)||[])qe.visible!==Ue.isIntersecting&&(qe.visible=Ue.isIntersecting,Re=!0);Re&&O()},{threshold:0}));let Q=new Set(l.keys());for(let ce of h)Q.has(ce)||c.unobserve(ce);for(let ce of Q)h.has(ce)||c.observe(ce);h=Q}function T(){f||!o||(o.addEventListener("scroll",O,{passive:!0,capture:!0}),o.addEventListener("resize",O,{passive:!0}),e.addEventListener("focusin",j),e.addEventListener("focusout",I),e.addEventListener("pointerdown",_e,!0),e.addEventListener("keydown",w,!0),f=!0)}function A(){!f||!o||(o.removeEventListener("scroll",O,{capture:!0}),o.removeEventListener("resize",O),e.removeEventListener("focusin",j),e.removeEventListener("focusout",I),e.removeEventListener("pointerdown",_e,!0),e.removeEventListener("keydown",w,!0),f=!1)}function W(Q){return`${Q.kind}\0${Q.attr||""}`}function F(Q,ce){return Q.container===ce.container&&Q.scalar===ce.scalar}function $(Q,ce){return Q.kind!==ce.kind?!1:Q.kind==="handle"?W(Q.target)===W(ce.target):Q.kind==="row"?Q.row===ce.row&&F(Q.list,ce.list):F(Q.list,ce.list)}function Ne(Q,ce){Q.target=ce;let Re=ce.path.join(".");Q.node.setAttribute("data-hcms-target",Re),ce.icon?Q.node.setAttribute("data-hcms-icon",ce.icon):Q.node.removeAttribute("data-hcms-icon"),Q.node.setAttribute("aria-label",`Edit ${Re}`)}function Ce(Q){let ce=e.createElement("button");ce.type="button",ce.className="hcms-inline-handle mirk-button mirk-button--small",ce.innerHTML=`<span class="mirk-button__label">${_r("edit")}</span>`;let Re={node:ce,kind:"handle",target:Q};return Ne(Re,Q),ce.addEventListener("click",Ue=>{Ue.preventDefault(),Ue.stopPropagation(),n?.(Re.target,ce)}),Re}function Be(Q,ce){let Re=e.createElement("button");return Re.type="button",Re.className="hcms-inline-list-button mirk-button mirk-button--small",Re.setAttribute("data-hcms-list-action",Q),Re.setAttribute("aria-label",ce),Re.innerHTML=`<span class="mirk-button__label">${_r(Q)}${Q==="add"?"<span>Add</span>":""}</span>`,Re}function re(Q,{list:ce,row:Re,rowIndex:Ue,count:qe}){let ot=ce.path.join(".");Q.list=ce,Q.row=Re,Q.index=Ue,Q.count=qe,Q.node.setAttribute("data-hcms-list",ot),Q.node.setAttribute("data-hcms-row",String(Ue));for(let xt of Q.node.querySelectorAll("[data-hcms-list-action]")){let kt=xt.getAttribute("data-hcms-list-action"),Ct=vf.find(([dt])=>dt===kt)?.[1]||kt;xt.setAttribute("aria-label",`${Ct} ${ot}.${Ue}`),xt.disabled=kt==="move-up"&&Ue===0||kt==="move-down"&&Ue===qe-1}}function Ee(Q,ce,Re,Ue){let qe=e.createElement("div");qe.className="hcms-inline-row-controls";let ot={node:qe,kind:"row",list:Q,row:ce,index:Re,count:Ue};for(let[xt,kt]of vf){let Ct=Be(xt,kt);Ct.addEventListener("click",dt=>{dt.preventDefault(),dt.stopPropagation(),!Ct.disabled&&r?.({action:xt,list:ot.list,index:ot.index,row:ot.row})}),qe.appendChild(Ct)}return re(ot,{list:Q,row:ce,rowIndex:Re,count:Ue}),ot}function Ge(Q=!1){if(!S)return;let ce=S;S=null,ce.menu.hidden=!0,ce.button.setAttribute("aria-expanded","false"),ce.node.parentElement?.classList.remove("has-open-settings"),Q&&ce.button.isConnected&&ce.button.focus({preventScroll:!0})}function _e(Q){S&&!S.node.contains(Q.target)&&Ge()}function w(Q){S&&(Q.key==="Escape"?(Q.preventDefault(),Q.stopPropagation(),Ge(!0)):Q.key==="Tab"?Ge(!0):["ArrowDown","ArrowUp","Home","End"].includes(Q.key)&&S.menu.contains(Q.target)&&(Q.preventDefault(),S.menu.querySelector('[role="menuitem"]').focus({preventScroll:!0})))}function V(Q,{list:ce,row:Re,rowIndex:Ue}){Object.assign(Q,{list:ce,row:Re,index:Ue}),Q.node.setAttribute("data-hcms-list",ce.path.join(".")),Q.node.setAttribute("data-hcms-row",String(Ue)),Q.button.setAttribute("aria-label",`Settings ${ce.path.join(".")}.${Ue}`)}function ne(Q){let ce=e.createElement("div");ce.className="hcms-inline-settings";let Re=Be("settings","Settings");Re.setAttribute("aria-haspopup","menu"),Re.setAttribute("aria-expanded","false");let Ue=e.createElement("div");Ue.className="hcms-inline-settings-menu",Ue.setAttribute("role","menu"),Ue.setAttribute("aria-label","Item settings"),Ue.hidden=!0;let qe=e.createElement("button");qe.type="button",qe.setAttribute("role","menuitem"),qe.setAttribute("data-hcms-list-action","remove"),qe.textContent="Delete",Ue.appendChild(qe),ce.append(Re,Ue);let ot={node:ce,button:Re,menu:Ue,kind:"settings"};V(ot,Q);let xt=()=>{Ge(),S=ot,Ue.hidden=!1,Re.setAttribute("aria-expanded","true"),ce.parentElement.classList.add("has-open-settings"),qe.focus({preventScroll:!0}),O()};return Re.addEventListener("click",kt=>{kt.preventDefault(),kt.stopPropagation(),S===ot?Ge(!0):xt()}),Re.addEventListener("keydown",kt=>{(kt.key==="ArrowDown"||kt.key==="ArrowUp")&&(kt.preventDefault(),xt())}),qe.addEventListener("click",kt=>{kt.preventDefault(),kt.stopPropagation(),Ge(!0),r?.({action:"remove",list:ot.list,index:ot.index,row:ot.row})}),ot}function te(Q,ce){Q.kind==="handle"?Ne(Q,ce.target):Q.kind==="row"?re(Q,ce):Q.kind==="settings"&&V(Q,ce)}function Pe(Q,ce,Re,Ue,qe){let ot=ce.get(Re)?.find(xt=>xt.category===qe);if(!ot){ot={el:Re,category:qe,members:[]},Q.push(ot);let xt=ce.get(Re);xt?xt.push(ot):ce.set(Re,[ot])}ot.members.push(Ue)}function ze(Q,ce,Re){let Ue=Re.items||[];Ue.forEach((qe,ot)=>{Lo(qe)&&(Pe(Q,ce,qe,{kind:"row",list:Re,row:qe,rowIndex:ot,count:Ue.length},"item"),Pe(Q,ce,qe,{kind:"settings",list:Re,row:qe,rowIndex:ot},"item"))})}function Se(Q,ce){let Re=new Set(Q.members),Ue=[];for(let qe of ce){let ot=Q.members.find(xt=>Re.has(xt)&&$(xt,qe))||(qe.kind==="handle"?Ce(qe.target):qe.kind==="row"?Ee(qe.list,qe.row,qe.rowIndex,qe.count):ne(qe));Re.delete(ot),te(ot,qe),k&&ot.kind!=="handle"&&(ot.node.hidden=!0),Ue.push(ot)}for(let qe of Re)qe===S&&Ge(),qe.node.remove();Ue.sort((qe,ot)=>["row","handle","settings"].indexOf(qe.kind)-["row","handle","settings"].indexOf(ot.kind)),Ue.forEach((qe,ot)=>{Q.node.children[ot]!==qe.node&&Q.node.insertBefore(qe.node,Q.node.children[ot]||null)}),Q.members=Ue}function it(Q,ce){let Re=[],Ue=new Map,qe=new Map,ot=0;for(let dt of Q||[])qe.has(dt.el)||qe.set(dt.el,dt),!(dt.kind!=="handle"||!Lo(dt.el))&&(Pe(Re,Ue,dt.el,{kind:"handle",target:dt},"item"),ot++);for(let dt of ce||[])ze(Re,Ue,dt);let xt=new Set(s),kt=new Map;for(let dt of s)kt.has(dt.el)||kt.set(dt.el,dt.visible);let Ct=[];for(let dt of Re){let St=s.find(ht=>xt.has(ht)&&ht.el===dt.el&&ht.category===dt.category);if(!St){let ht=e.createElement("div");ht.className="hcms-inline-item-controls",ht.setAttribute("role","group"),St={el:dt.el,node:ht,category:dt.category,kind:dt.category==="add"?"add":"handle",members:[],visible:kt.get(dt.el)??!1},t.appendChild(ht)}xt.delete(St),St.el=dt.el,St.category=dt.category,Se(St,dt.members),St.kind=St.members.some(ht=>ht.kind==="row")?"row":St.members.some(ht=>ht.kind==="handle")?"handle":"add",St.node.setAttribute("aria-label",St.category==="add"?"List controls":"Item controls"),Ct.push(St)}for(let dt of xt)dt.node.remove();s=Ct,l=new Map,g=new Map;for(let dt of s){let St=l.get(dt.el);St?St.push(dt):l.set(dt.el,[dt]);for(let ht of dt.members)ht.kind!=="row"&&ht.kind!=="settings"||(g.set(ht.row,ht.row),g.set(ht.node,ht.row),g.set(dt.node,ht.row))}y&&!g.has(y)&&(y=null),m&&!g.has(m)&&(m=null),a=qe,i=ot}function tt(){Ge(),c?.disconnect(),c=null,h=new Set;for(let Q of s)Q.node.remove();s=[],l=new Map,a=new Map,g=new Map,i=0}return{setTargets(Q,ce){it(Q,ce),v.setLists(ce),R(),T(),O()},refresh:O,get count(){return i},get controlsHidden(){return k},setControlsHidden(Q){if(k=!!Q,v.setHidden(k),k){Ge();for(let ce of s){for(let Re of ce.members)Re.kind!=="handle"&&(Re.node.hidden=!0);ce.members.every(Re=>Re.node.hidden)&&(ce.node.hidden=!0)}}O()},elementToTarget(Q){if(Q?.closest?.("[data-hcms-ghost]"))return null;for(let ce=Q;ce&&ce.nodeType===1;ce=ce.parentElement){let Re=a.get(ce);if(Re)return Re}return null},setHoveredRow(Q){let ce=C();y=Q?M(Q):null,C()!==ce&&O()},showHighlight(Q){Q&&(p=Q,x.hidden=!1,P())},hideHighlight(){p=null,x.hidden=!0},setFollower(Q){d=typeof Q=="function"?Q:null},destroy(){v.destroy(),u&&o&&o.cancelAnimationFrame(u),u=0,d=null,p=null,y=null,m=null,x.remove(),A(),tt()}}}var Ym="hypercms-inline",Fo="is-hcms-inline-active",ul="is-hcms-inline-onpath",Af='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])',Xm=["bold","italic","link","undo","redo"],Jm=/^H[1-6]$/,Zm=0;function Ef({doc:e,pageRoot:t,opts:n={}}){let r=n.richText!==!1,o=null,s=null,l=null,i=new Map,a=null,c=null,h=null;function u(f,d,p,y,m){let g=eo(e.defaultView);if(typeof g!="function")return null;let k=m||{},S=k.originalHTML??cl(d,{capability:"history"}).html(),v=k.richClayIsOurs??!d.hasAttribute("data-richclay"),x=k.adopted??d.getAttribute("data-richclay-active")==="true",O=Po(d,y,"history"),C=Qm(f,g,d,y,v);if(!C)return null;Dc(d,y==="innerHTML",v);let _=String(++Zm);d.setAttribute(ar,_),js();let M={el:d,editor:C,path:p,prop:y,boundId:_,originalHTML:S,oldValue:O,richClayIsOurs:v,adopted:x,dirty:!1,written:!1,restorable(){return!this.adopted&&!this.dirty&&!this.written},lastEdited:void 0};i.set(d,M),Lc(_,M);let j=C.squire;if(j&&typeof j.addEventListener=="function"){let P=()=>{M.dirty=!0,M.lastEdited=Po(d,M.prop,"history"),ep(f,M)};j.addEventListener("input",P),M.detachInput=()=>j.removeEventListener?.("input",P)}let I=()=>_f(M);return d.addEventListener("blur",I),M.detachBlur=()=>d.removeEventListener("blur",I),M}return{name:"inline",richText:r,ctx:null,root:null,formRoot:null,errorEl:null,noticeEl:null,handoffEl:null,handoffCountEl:null,popEl:null,enhanceFormRichText:!1,prepareRules(f){return r?Uc(f,t):f},bindText(f,d,p,y){return u(this.ctx,f,d,p,y)},mount(f){let d=this.ctx;o=sp(e,n.theme),this.root=o.root,this.formRoot=o.formRoot,this.errorEl=o.errorEl,this.noticeEl=o.noticeEl,this.handoffEl=o.handoffEl,this.handoffCountEl=o.handoffCountEl,this.popEl=o.popEl,Qn(()=>Io(e));let p=Xr({pageRules:d.pageRules,formRules:d.formRules,data:f,doc:e});o.formRoot.appendChild(p),d.seeder.seed(o.formRoot),cr(o.formRoot,e,this.enhanceFormRichText),lo(d),ws(d),s=wf({doc:e,layerEl:o.layerEl,onActivate:(y,m)=>this.activate(y,m),onListAction:y=>this.listAction(y)}),s.setFollower(()=>this.placePopover()),o.closeEl.addEventListener("click",()=>this.deactivate()),o.toggleEl.addEventListener("click",y=>{y.preventDefault(),y.stopPropagation(),this.toggleControls()}),o.handoffEl.querySelector("[data-hcms-open-view]").addEventListener("click",y=>{y.preventDefault(),y.stopPropagation(),d.onViewRequested?.("sidebar")}),this.bindPage(),this.syncTargets()},listAction({action:f,list:d,index:p,row:y}){let m=this.ctx,g=d.path.join("."),k=m.formRoot.querySelector(`[data-hcms-path="${oo(g)}"]`);if(!k)return;if(f==="add"){Mo(g,m);return}let S=y?lp(m,g,y):p;if(S===-1)return;let v=ip(k,S);if(v){if(f==="remove"){Ji(v,m),this.syncTargets();return}Xi(v,f==="move-up"?-1:1,m),this.syncTargets()}},toggleControls(){if(!s||!o)return;let f=!s.controlsHidden;s.setControlsHidden(f),o.toggleEl.setAttribute("aria-pressed",String(f));let d=o.toggleEl.querySelector(".mirk-button__label");d&&(d.textContent=f?"Show controls":"Hide controls")},bindPage(){let f=this.ctx.pageRoot,d=o.root,p=v=>{let x=s&&s.elementToTarget(v.target);x?s.showHighlight(x.el):s?.hideHighlight(),s?.setHoveredRow(v.target)},y=()=>{s?.hideHighlight(),s?.setHoveredRow(null)},m=v=>{if(d.contains(v.target))return;let x=s&&s.elementToTarget(v.target);!x||x.kind!=="text"||i.has(x.el)||u(this.ctx,x.el,x.path.join("."),Ds(x))},g=v=>{if(d.contains(v.target))return;let x=s&&s.elementToTarget(v.target);if(!x){this.deactivate();return}(typeof v.target.closest=="function"&&v.target.closest("a[href]")||x.kind!=="text")&&v.preventDefault(),this.activate(x)},k=v=>{v.key==="Escape"&&this.deactivate()},S=v=>{let x=v.detail;if(!(!x||x.pageRoot!==this.ctx.pageRoot||!x.path))for(let O of i.values())O.path===x.path&&(O.written=!0)};f.addEventListener("pointerover",p),f.addEventListener("pointerleave",y),f.addEventListener("pointerdown",m),f.addEventListener("click",g),d.addEventListener("keydown",k),e.addEventListener("hcms:change",S),l=()=>{f.removeEventListener("pointerover",p),f.removeEventListener("pointerleave",y),f.removeEventListener("pointerdown",m),f.removeEventListener("click",g),d.removeEventListener("keydown",k),e.removeEventListener("hcms:change",S)}},activate(f,d){if(!f||!o||f.kind==="text"&&this.activateText(f))return;let p=Sf(this,o,f.path.join("."));if(!p){this.deactivate();return}a=f,c=d||null,h=null,o.popEl.hidden=!1,o.formRoot.querySelectorAll(`.${Fo}`).forEach(Tf),this.placePopover(),op(p)},activateText(f){let d=f.el,p=i.get(d);if(p)return Ps(p),!0;let y=u(this.ctx,d,f.path.join("."),Ds(f));return y?(Ps(y),!0):!1},placePopover(){if(!o||!a||o.popEl.hidden)return;let f=e.defaultView;if(!f)return;let d={width:f.innerWidth,height:f.innerHeight},p=a.el.getBoundingClientRect(),y=o.popEl.getBoundingClientRect(),{mode:m,x:g,y:k}=mf({anchor:p,bar:y,viewport:d,current:h});h=m,o.popEl.style.transform=`translate(${Math.round(g)}px, ${Math.round(k)}px)`},deactivate(){if(!o||!a&&o.popEl.hidden)return;o.popEl.hidden=!0,Nf(o.root);let f=c;if(a=null,c=null,h=null,f&&e.contains(f)&&typeof f.focus=="function")try{f.focus({preventScroll:!0})}catch{f.focus()}},syncTargets(){if(!s)return;let f=this.ctx,{targets:d,lists:p}=ll(f.pageRoot,f.pageRules);s.setTargets(d,p);let y=tp(this,i,d,e);if(a){let g=y.get(a.el)||[],k=g.find(S=>np(S,a))||g.find(S=>S.path.join(".")===a.path.join("."))||(g.length===1?g[0]:null);k?a=k:this.deactivate()}rp(this.ctx,i,e);let m=d.reduce((g,k)=>g+(Lo(k.el)?0:1),0);this.handoffEl&&(this.handoffCountEl.textContent=m===0?"":`${m} ${m===1?"field isn't":"fields aren't"} visible right now.`,this.handoffEl.hidden=m===0)},refresh(f,d){f==="livesync"?(dr(e),Io(e),hr(this.ctx,{ignoreActiveValue:!0})):f==="undo"?hr(this.ctx,{ignoreActiveValue:!1}):hr(this.ctx),this.syncTargets(),(f==="livesync"||f==="undo")&&this.rebindText(f),this.restoreActive()},rebindText(f){let d=f!=="undo";for(let[p,y]of[...i]){if(!e.contains(p)){Do(this.ctx,y,{restore:!1,record:d}),i.delete(p);continue}if(p.hasAttribute(Fn)){let k=Po(p,y.prop);k!==y.lastEdited&&(y.oldValue=k,y.lastEdited=void 0);continue}let m=e.activeElement===p;Do(this.ctx,y,{restore:!1,record:d}),i.delete(p);let g=u(this.ctx,p,y.path,y.prop,{richClayIsOurs:y.richClayIsOurs,adopted:y.adopted});g&&m&&Ps(g)}},restoreActive(){if(!o||!a||o.popEl.hidden)return;if(!e.contains(a.el)){this.deactivate();return}if(!Sf(this,o,a.path.join("."))){this.deactivate();return}o.formRoot.querySelectorAll(`.${Fo}`).forEach(Tf),this.placePopover()},focusOnOpen(){if(this.root&&typeof this.root.focus=="function")try{this.root.focus({preventScroll:!0})}catch{this.root.focus()}},destroy(){c=null,this.deactivate();for(let f of i.values())Do(this.ctx,f);i.clear(),l?.(),l=null,s?.destroy(),s=null,o?.destroy(),o=null,nl(e),this.popEl=null,this.handoffEl=null,this.handoffCountEl=null}}}function Qm(e,t,n,r,o){return Qn(()=>{let s=null;try{s=new t(n,{inline:!0,hyperclay:!1,toolbar:r==="innerHTML"?Xm:!1,...Jm.test(n.tagName)?{singleLine:!0}:null})}catch(l){return console.warn("[hypercms] richclay activation failed; the field falls back to the popover",l),null}if(s.unsupported||!s.active){if(o)try{s.destroy()}catch{}return null}return typeof s.reattach=="function"&&s.reattach(),s})}function ep(e,{path:t,el:n,prop:r}){let o=As(e.formRoot,t);o&&(Ss(o,Po(n,r),e.formRoot,t),_n(vn(e),{path:t,structural:!1},e))}function Po(e,t,n="data"){let r=cl(e,{capability:n});return t==="innerHTML"?r.html():r.text().trim()}function _f(e){let{el:t,prop:n,oldValue:r,lastEdited:o}=e,s=o;if(s===void 0||s===r)return;e.oldValue=s;let l=cn("undo");if(!l||typeof l.recordValue!="function")return;let i={prop:n,oldValue:r,newValue:s,read:a=>Po(a,n,"history"),write:(a,c)=>Of(a,n,c)};l.isPaused?queueMicrotask(()=>{t.isConnected&&l.recordValue(t,i)}):l.recordValue(t,i)}function Of(e,t,n){let r=e.cloneNode(!1);t==="innerHTML"?r.innerHTML=n:r.textContent=n,ir(e,Array.from(r.childNodes),{morphStyle:"innerHTML",policy:"history",restoreFocus:!1,scripts:{handle:!1,merge:!1}})}function Do(e,t,{restore:n=!0,record:r=!0}={}){r&&_f(t),t.detachInput?.(),t.detachBlur?.(),Qn(()=>{if(!t.adopted){try{t.editor.destroy()}catch(o){console.warn("[hypercms] richclay teardown failed; editor state may reach the save",o)}t.richClayIsOurs&&t.el.removeAttribute("data-richclay")}t.el.removeAttribute(Fn),t.el.removeAttribute(Tr),t.el.removeAttribute(ar),jc(t.boundId),n&&t.restorable()&&Of(t.el,"innerHTML",t.originalHTML)})}function Ps(e){let{editor:t,el:n}=e;if(n.ownerDocument.activeElement!==n)try{typeof t.focus=="function"?t.focus():n.focus()}catch{}}function tp(e,t,n,r){let o=new Map;for(let s of n){let l=o.get(s.el);l?l.push(s):o.set(s.el,[s])}for(let[s,l]of[...t]){let i=o.get(s)||[],a=i.find(f=>Ds(f)===l.prop)||i[0];if(!a){Do(e.ctx,l,{restore:!0}),t.delete(s);continue}l.path=a.path.join(".");let c=Ds(a);if(c===l.prop)continue;let h=r.activeElement===s;Do(e.ctx,l,{restore:!1}),t.delete(s);let u=e.bindText(s,l.path,c,{richClayIsOurs:l.richClayIsOurs,adopted:l.adopted,originalHTML:l.originalHTML});u&&h&&Ps(u)}return o}function np(e,t){return e.el===t.el&&e.kind===t.kind&&e.attr===t.attr}function Ds(e){return e.attr==="innerHTML"?"innerHTML":"textContent"}function rp(e,t,n){for(let r of e.pageRoot.querySelectorAll(`[${Fn}]`))t.has(r)||Qn(()=>Bc(r,n.defaultView))}function Sf(e,t,n){let r=e.formRoot&&e.formRoot.querySelector(`[data-hcms-path="${oo(n)}"]`);if(Nf(t.root),!r)return null;let o=r.closest("[data-hcms-card]"),s=o?[...o.querySelectorAll('[data-hcms-shape="scalar"][data-hcms-path]')].filter(l=>l.closest("[data-hcms-card]")===o&&l.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]')===o.parentElement.closest('[data-hcms-shape="object-array"]')):[r];s.includes(r)||s.push(r);for(let l of s){l.classList.add(Fo),l.removeAttribute("draggable");for(let i=l.parentElement;i&&(i.classList.add(ul),i.removeAttribute("draggable"),i!==e.formRoot);i=i.parentElement);}return r}function Nf(e){if(e)for(let t of e.querySelectorAll(`.${Fo}, .${ul}`))t.classList.remove(Fo,ul)}function Tf(e){e.tagName==="TEXTAREA"&&to(e),e.querySelectorAll?.("textarea").forEach(to)}function op(e){let t=e.matches?.(Af)?e:e.querySelector?.(Af);if(!(!t||typeof t.focus!="function"))try{t.focus({preventScroll:!0})}catch{t.focus()}}function sp(e,t){dr(e);let n=e.createElement(Ym),r=t==="dark"?" dark":t==="light"?" light":"";return n.className="hcms-shell pixel-quiet hcms-inline"+r,n.setAttribute("data-hcms-shell",""),n.setAttribute("editor-ui",""),n.setAttribute("no-save",""),n.setAttribute("save-remove",""),n.setAttribute("snapshot-remove",""),n.setAttribute("no-watch",""),n.setAttribute("tabindex","-1"),n.innerHTML=`
182
182
  <div class="hcms-inline-bar">
183
183
  <div class="hcms-inline-handoff" hidden>
184
184
  <span class="hcms-inline-handoff-count"></span>
@@ -197,24 +197,24 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
197
197
  <div class="hcms-inline-pop-header">
198
198
  <span>Edit content</span>
199
199
  <button type="button" class="hcms-inline-pop-close mirk-button mirk-button--small" aria-label="Close field editor">
200
- <span class="mirk-button__label">${hr("remove")}</span>
200
+ <span class="mirk-button__label">${_r("remove")}</span>
201
201
  </button>
202
202
  </div>
203
203
  <div data-hcms-form-root class="hcms-form"></div>
204
204
  </div>
205
- `,e.body.appendChild(n),{root:n,formRoot:n.querySelector("[data-hcms-form-root]"),noticeEl:n.querySelector(".hcms-inline-notice"),errorEl:n.querySelector(".hcms-inline-error"),handoffEl:n.querySelector(".hcms-inline-handoff"),handoffCountEl:n.querySelector(".hcms-inline-handoff-count"),layerEl:n.querySelector(".hcms-inline-layer"),popEl:n.querySelector(".hcms-inline-pop"),closeEl:n.querySelector(".hcms-inline-pop-close"),toggleEl:n.querySelector("[data-hcms-controls-toggle]"),destroy(){n.remove()}}}function Yh(e,t){let n=e.querySelector(".hcms-array-items");return n&&n.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")[t]||null}function Xh(e,t,n){let{lists:r}=Ii(e.pageRoot,e.pageRules),o=r.find(s=>s.path.join(".")===t);return o?o.items.indexOf(n):-1}var Jh="[hypercms]";function Dc(e,t){if(!e||!e.querySelectorAll||!t)return;let n=Zh(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(o=>{let s=o.getAttribute("data-hcms-tpl");s&&(s.startsWith("@")||n.has(s)||console.warn(`${Jh} template "${s}" doesn't match any rule path; ignored`))})}function Zh(e){let t=new Set;return n([],e),t;function n(r,o){let s=r.join("."),i=r.map(a=>typeof a=="number"?"*":a).join(".");s&&t.add(s),i&&t.add(i);let l=ur(o);if(l==="object")for(let[a,u]of Object.entries(o))n([...r,a],u);else if(l==="object-array"||l==="scalar-array"){let a=[...r,"*"],u=a.map(d=>typeof d=="number"?"*":d).join(".");if(t.add(u),l==="object-array"){let d=o[1];if(d&&typeof d=="object"&&!Array.isArray(d))for(let[h,f]of Object.entries(d))n([...a,h],f)}}}}var qc={skip:"[data-hcms-shell]",templateAttr:"cms-template"},bt={isOpen:!1,ctx:null,opts:null};function Bc({view:e,doc:t,pageRoot:n,opts:r={},onCloseRequested:o,onViewRequested:s}){let i=r.rules!==void 0?r.rules:"cms",l=ln.findRules(t,i);if(!l){let m=typeof i=="string"?`data-rules-name~="${i}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${m}`)}let a=e.prepareRules(l.rules),u=l.tagNode;Uo(t),Go(t,a),Dc(t,a);let d=Xo(a,t),h=us(a),f=cs(n,a),p=Bo(),b=Zn(ln.extract(n,a,{...qc,...p.hooks}),a),v={doc:t,pageRoot:n,pageRules:a,writeRules:h,formRules:d,rulesTagNode:u,rulesSource:i,richText:e.richText,view:e,seeder:p,initialData:b,get formRoot(){return e.formRoot},get shellRoot(){return e.root},get errorEl(){return e.errorEl},get noticeEl(){return e.noticeEl},unresolved:f,lastTwinSignature:null,lastFingerprint:null,lastData:null,observerHandle:null,undoUnsub:null,livesyncUnsub:null,onChange:r.onChange,onError:r.onError,confirmRemove:r.confirmRemove,previouslyFocused:t.activeElement,dispatch(m,g){let y=t.defaultView&&t.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!y)return;let I={...g||{},pageRoot:n,view:e.name},Y=new y(m,{bubbles:!0,cancelable:m==="hcms:change",detail:I});(e.root&&e.root.isConnected!==!1?e.root:n).dispatchEvent(Y)},onCloseRequested:o,onViewRequested:s};return v.updateFingerprint=()=>{v.lastFingerprint=mo(fn(v))},e.ctx=v,v}function Hc(e){e.updateFingerprint(),e.observerHandle=uc({onRefresh:r=>e.view.refresh("observer",r)});let t=Jt("undo");if(t&&typeof t.on=="function"){let r=()=>{if(bt.ctx!==e)return;Fc(e,"undo");let o=Zn(ln.extract(e.pageRoot,e.pageRules,qc),e.pageRules);mo(o)!==mo(e.lastData)&&(e.lastData=o,e.onChange?.(o,{path:"",structural:!1}))};t.on("undo",r),t.on("redo",r),e.undoUnsub=()=>{t.off("undo",r),t.off("redo",r)}}let n=()=>Fc(e,"livesync");e.livesyncUnsub=Pr(e.doc,Ba,n),Bi.ctx=e,em(e.doc)}function Fc(e,t){bt.ctx===e&&e.view.refresh(t)}function ks(e,{dispatch:t=!0,restoreFocus:n=!0,updateUrl:r=!0,reason:o="close"}={}){if(!e||e.closed)return;e.closed=!0;for(let i of e.uploads||[])try{i.abort()}catch{}e.uploads?.clear();let s=e.previouslyFocused;if(t&&e.dispatch("hcms:close",{reason:o}),r&&tm(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),Fn(()=>e.view.destroy()),Qh(),n&&typeof s?.focus=="function")try{s.focus()}catch{}}function Qh(){bt.isOpen=!1,bt.ctx=null,bt.opts=null,Bi.ctx=null}var Bi={ctx:null};function em(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let n=function(){let o=Bi.ctx;if(o)return ss(o.formRoot),dr("Reorder",()=>kn(fn(o),{path:"",structural:!0},o))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=n),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=n)}var qi="cms";function $c(e){let t=typeof e=="string"?e:"",n=t.indexOf("?"),r=n===-1?t:t.slice(n+1);if(!r)return t;let o=new URLSearchParams(r);return o.get(qi)!=="true"?t:(o.set(qi,"false"),"?"+o.toString())}function Uc(e){let t=typeof e=="string"?e:"",n=t.indexOf("?"),r=n===-1?t:t.slice(n+1);return r?new URLSearchParams(r).get(qi)==="true":!1}function tm(){if(typeof window>"u"||!window.location||!window.history||typeof window.history.replaceState!="function")return;let e=window.location.search,t=$c(e);t!==e&&window.history.replaceState(window.history.state,"",t+window.location.hash)}var zc="hcms-toggle",Ft="data-hcms-toggle-host",Vc="hcms-toggle-style",Wc="data-hcms-toggle-style",ys="data-hcms-session",Qc="data-hcms-split",eu="hcms.view",xs=["sidebar","inline"],nm={sidebar:"In the sidebar",inline:"On the page"},Ui="var(--hcms-toggle-bg, var(--hcms-toggle-_surface))";function Kc(e){try{let t=e&&e.localStorage?e.localStorage.getItem(eu):null;return xs.includes(t)?t:null}catch{return null}}function rm(e,t){if(xs.includes(t))try{e?.localStorage?.setItem(eu,t)}catch{}}var om="#fafafa",sm="#0a0a0a",im=`
206
- [${Ft}] {
205
+ `,e.body.appendChild(n),{root:n,formRoot:n.querySelector("[data-hcms-form-root]"),noticeEl:n.querySelector(".hcms-inline-notice"),errorEl:n.querySelector(".hcms-inline-error"),handoffEl:n.querySelector(".hcms-inline-handoff"),handoffCountEl:n.querySelector(".hcms-inline-handoff-count"),layerEl:n.querySelector(".hcms-inline-layer"),popEl:n.querySelector(".hcms-inline-pop"),closeEl:n.querySelector(".hcms-inline-pop-close"),toggleEl:n.querySelector("[data-hcms-controls-toggle]"),destroy(){n.remove()}}}function ip(e,t){let n=e.querySelector(".hcms-array-items");return n&&n.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")[t]||null}function lp(e,t,n){let{lists:r}=ll(e.pageRoot,e.pageRules),o=r.find(s=>s.path.join(".")===t);return o?o.items.indexOf(n):-1}var ap="[hypercms]";function Cf(e,t){if(!e||!e.querySelectorAll||!t)return;let n=cp(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(o=>{let s=o.getAttribute("data-hcms-tpl");s&&(s.startsWith("@")||n.has(s)||console.warn(`${ap} template "${s}" doesn't match any rule path; ignored`))})}function cp(e){let t=new Set;return n([],e),t;function n(r,o){let s=r.join("."),l=r.map(a=>typeof a=="number"?"*":a).join(".");s&&t.add(s),l&&t.add(l);let i=Sr(o);if(i==="object")for(let[a,c]of Object.entries(o))n([...r,a],c);else if(i==="object-array"||i==="scalar-array"){let a=[...r,"*"],c=a.map(h=>typeof h=="number"?"*":h).join(".");if(t.add(c),i==="object-array"){let h=o[1];if(h&&typeof h=="object"&&!Array.isArray(h))for(let[u,f]of Object.entries(h))n([...a,u],f)}}}}var Rf={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Lt={isOpen:!1,ctx:null,opts:null};function If({view:e,doc:t,pageRoot:n,opts:r={},onCloseRequested:o,onViewRequested:s}){let l=r.rules!==void 0?r.rules:"cms",i=pn.findRules(t,l);if(!i){let m=typeof l=="string"?`data-rules-name~="${l}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${m}`)}let a=e.prepareRules(i.rules),c=i.tagNode;cs(t),ms(t,a),Cf(t,a);let h=gs(a,t),u=Cs(a),f=Ns(n,a),d=is(),p=ur(pn.extract(n,a,{...Rf,...d.hooks}),a),y={doc:t,pageRoot:n,pageRules:a,writeRules:u,formRules:h,rulesTagNode:c,rulesSource:l,richText:e.richText,view:e,seeder:d,initialData:p,get formRoot(){return e.formRoot},get shellRoot(){return e.root},get errorEl(){return e.errorEl},get noticeEl(){return e.noticeEl},unresolved:f,lastTwinSignature:null,lastFingerprint:null,lastData:null,observerHandle:null,undoUnsub:null,livesyncUnsub:null,onChange:r.onChange,onError:r.onError,confirmRemove:r.confirmRemove,previouslyFocused:t.activeElement,dispatch(m,g){let k=t.defaultView&&t.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!k)return;let S={...g||{},pageRoot:n,view:e.name},v=new k(m,{bubbles:!0,cancelable:m==="hcms:change",detail:S});(e.root&&e.root.isConnected!==!1?e.root:n).dispatchEvent(v)},onCloseRequested:o,onViewRequested:s};return y.updateFingerprint=()=>{y.lastFingerprint=Ro(vn(y))},e.ctx=y,y}function Lf(e){e.updateFingerprint(),e.observerHandle=nf({onRefresh:r=>e.view.refresh("observer",r)});let t=cn("undo");if(t&&typeof t.on=="function"){let r=()=>{if(Lt.ctx!==e)return;Mf(e,"undo");let o=ur(pn.extract(e.pageRoot,e.pageRules,Rf),e.pageRules);Ro(o)!==Ro(e.lastData)&&(e.lastData=o,e.onChange?.(o,{path:"",structural:!1}))};t.on("undo",r),t.on("redo",r),e.undoUnsub=()=>{t.off("undo",r),t.off("redo",r)}}let n=()=>Mf(e,"livesync");e.livesyncUnsub=Qr(e.doc,Rc,n),hl.ctx=e,up(e.doc)}function Mf(e,t){Lt.ctx===e&&e.view.refresh(t)}function Fs(e,{dispatch:t=!0,restoreFocus:n=!0,updateUrl:r=!0,reason:o="close"}={}){if(!e||e.closed)return;e.closed=!0;for(let l of e.uploads||[])try{l.abort()}catch{}e.uploads?.clear();let s=e.previouslyFocused;if(t&&e.dispatch("hcms:close",{reason:o}),r&&dp(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),Qn(()=>e.view.destroy()),fp(),n&&typeof s?.focus=="function")try{s.focus()}catch{}}function fp(){Lt.isOpen=!1,Lt.ctx=null,Lt.opts=null,hl.ctx=null}var hl={ctx:null};function up(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let n=function(){let o=hl.ctx;if(o)return Ts(o.formRoot),Er("Reorder",()=>_n(vn(o),{path:"",structural:!0},o))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=n),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=n)}var dl="cms";function jf(e){let t=typeof e=="string"?e:"",n=t.indexOf("?"),r=n===-1?t:t.slice(n+1);if(!r)return t;let o=new URLSearchParams(r);return o.get(dl)!=="true"?t:(o.set(dl,"false"),"?"+o.toString())}function Pf(e){let t=typeof e=="string"?e:"",n=t.indexOf("?"),r=n===-1?t:t.slice(n+1);return r?new URLSearchParams(r).get(dl)==="true":!1}function dp(){if(typeof window>"u"||!window.location||!window.history||typeof window.history.replaceState!="function")return;let e=window.location.search,t=jf(e);t!==e&&window.history.replaceState(window.history.state,"",t+window.location.hash)}var Df="hcms-toggle",Yt="data-hcms-toggle-host",Ff="hcms-toggle-style",Bf="data-hcms-toggle-style",Bs="data-hcms-session",Wf="data-hcms-split",Kf="hcms.view",qs=["sidebar","inline"],hp={sidebar:"In the sidebar",inline:"On the page"},gl="var(--hcms-toggle-bg, var(--hcms-toggle-_surface))";function qf(e){try{let t=e&&e.localStorage?e.localStorage.getItem(Kf):null;return qs.includes(t)?t:null}catch{return null}}function mp(e,t){if(qs.includes(t))try{e?.localStorage?.setItem(Kf,t)}catch{}}var pp="#fafafa",gp="#0a0a0a",bp=`
206
+ [${Yt}] {
207
207
  all: unset;
208
208
  box-sizing: border-box;
209
209
  display: var(--hcms-toggle-display, inline-flex);
210
210
  font-family: 'Departure Mono', ui-monospace, Menlo, monospace;
211
- --hcms-toggle-_surface: ${om};
211
+ --hcms-toggle-_surface: ${pp};
212
212
  }
213
- [${Ft}][data-hcms-surface="dark"] {
214
- --hcms-toggle-_surface: ${sm};
213
+ [${Yt}][data-hcms-surface="dark"] {
214
+ --hcms-toggle-_surface: ${gp};
215
215
  }
216
- [${Ft}] .hcms-toggle__main,
217
- [${Ft}] .hcms-toggle__arrow {
216
+ [${Yt}] .hcms-toggle__main,
217
+ [${Yt}] .hcms-toggle__arrow {
218
218
  all: unset;
219
219
  box-sizing: border-box;
220
220
  display: inline-flex;
@@ -233,34 +233,34 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
233
233
  cursor: pointer;
234
234
  box-shadow: none;
235
235
  }
236
- [${Ft}] .hcms-toggle__main:hover,
237
- [${Ft}] .hcms-toggle__arrow:hover {
236
+ [${Yt}] .hcms-toggle__main:hover,
237
+ [${Yt}] .hcms-toggle__arrow:hover {
238
238
  border-color: var(--mirk-focus-color, #C7AE93);
239
239
  box-shadow: none;
240
240
  }
241
- [${Ft}] .hcms-toggle__main:active,
242
- [${Ft}] .hcms-toggle__arrow:active {
241
+ [${Yt}] .hcms-toggle__main:active,
242
+ [${Yt}] .hcms-toggle__arrow:active {
243
243
  border-color: var(--mirk-bevel-br, #E2D4BF) var(--mirk-bevel-tl, #F0E7D8) var(--mirk-bevel-tl, #F0E7D8) var(--mirk-bevel-br, #E2D4BF);
244
244
  }
245
- [${Ft}] .hcms-toggle__main:focus-visible,
246
- [${Ft}] .hcms-toggle__arrow:focus-visible {
245
+ [${Yt}] .hcms-toggle__main:focus-visible,
246
+ [${Yt}] .hcms-toggle__arrow:focus-visible {
247
247
  outline: 2px solid currentColor;
248
248
  outline-offset: -5px;
249
249
  }
250
- [${Ft}] .hcms-toggle__close { display: none; }
251
- [${Ft}][${ys}="open"] .hcms-toggle__open { display: none; }
252
- [${Ft}][${ys}="open"] .hcms-toggle__close { display: inline; }
253
- [${Ft}][${Qc}] .hcms-toggle__main {
250
+ [${Yt}] .hcms-toggle__close { display: none; }
251
+ [${Yt}][${Bs}="open"] .hcms-toggle__open { display: none; }
252
+ [${Yt}][${Bs}="open"] .hcms-toggle__close { display: inline; }
253
+ [${Yt}][${Wf}] .hcms-toggle__main {
254
254
  border-radius: 0;
255
255
  padding-right: 12px;
256
256
  }
257
- [${Ft}] .hcms-toggle__arrow {
257
+ [${Yt}] .hcms-toggle__arrow {
258
258
  gap: 0;
259
259
  padding: 0 10px;
260
260
  border-radius: 0;
261
261
  border-left-width: 0;
262
262
  }
263
- [${Ft}] .hcms-toggle__menu {
263
+ [${Yt}] .hcms-toggle__menu {
264
264
  all: unset;
265
265
  box-sizing: border-box;
266
266
  min-width: 180px;
@@ -269,12 +269,12 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
269
269
  font-size: 14px;
270
270
  line-height: 1.5;
271
271
  color: var(--hcms-toggle-color, currentColor);
272
- background: ${Ui};
272
+ background: ${gl};
273
273
  border: 1px solid var(--mirk-input-border, #D8C8AF);
274
274
  border-radius: var(--mirk-radius, 5px);
275
275
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, .45);
276
276
  }
277
- [${Ft}] .hcms-toggle__item {
277
+ [${Yt}] .hcms-toggle__item {
278
278
  all: unset;
279
279
  box-sizing: border-box;
280
280
  display: block;
@@ -283,27 +283,27 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
283
283
  border-radius: 0;
284
284
  cursor: pointer;
285
285
  }
286
- [${Ft}] .hcms-toggle__item::before {
286
+ [${Yt}] .hcms-toggle__item::before {
287
287
  content: "\u25CB";
288
288
  margin-right: 8px;
289
289
  opacity: .55;
290
290
  }
291
- [${Ft}] .hcms-toggle__item[aria-checked="true"]::before {
291
+ [${Yt}] .hcms-toggle__item[aria-checked="true"]::before {
292
292
  content: "\u25CF";
293
293
  opacity: 1;
294
294
  }
295
- [${Ft}] .hcms-toggle__item:hover {
295
+ [${Yt}] .hcms-toggle__item:hover {
296
296
  background: color-mix(in srgb, currentColor 12%, transparent);
297
297
  }
298
- [${Ft}] .hcms-toggle__item:focus-visible {
298
+ [${Yt}] .hcms-toggle__item:focus-visible {
299
299
  outline: 2px solid currentColor;
300
300
  outline-offset: -3px;
301
301
  }
302
302
  @media (pointer: coarse) {
303
- [${Ft}] .hcms-toggle__main,
304
- [${Ft}] .hcms-toggle__arrow { min-height: 44px; }
303
+ [${Yt}] .hcms-toggle__main,
304
+ [${Yt}] .hcms-toggle__arrow { min-height: 44px; }
305
305
  }
306
- `;function lm({search:e="",cookie:t="",forced:n=null}={}){let r=typeof e=="string"?e:"",o=r.indexOf("?"),s=o===-1?r:r.slice(o+1),i=new URLSearchParams(s).get("editmode");return i?i==="true":n!=null?!!n:/(?:^|;\s*)isAdminOfCurrentResource=[^;]/.test(t)}var Hi=new WeakMap;function tu(e,t){try{e.globalCompositeOperation="copy",e.fillStyle=t,e.fillRect(0,0,1,1);let n=e.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2],a:n[3]/255}}catch{return null}}function am(e){if(Hi.has(e))return Hi.get(e);let t=null;try{let n=e.createElement("canvas");if(n.width=n.height=1,t=n.getContext?n.getContext("2d",{willReadFrequently:!0}):null,t){let r=tu(t,"rgb(1, 2, 3)");(!r||r.r!==1||r.g!==2||r.b!==3||r.a!==1)&&(t=null)}}catch{t=null}return Hi.set(e,t),t}function cm(e,t){let n=String(e??"").trim();if(!n)return null;let r=um(n);if(r)return r;let o=t&&t.defaultView;if(!o||!o.CSS||typeof o.CSS.supports!="function"||!o.CSS.supports("color",n))return null;let s=am(t);return s?tu(s,n):null}function um(e){let t=/rgba?\(([^)]+)\)/.exec(String(e??""));if(!t)return null;let n=t[1].split(/[\s,/]+/).filter(Boolean);if(n.length<3)return null;let r=n.slice(0,3).map(Number);if(r.some(Number.isNaN))return null;let o=n[3],s=o===void 0?1:o.endsWith("%")?Number(o.slice(0,-1))/100:Number(o);return{r:r[0],g:r[1],b:r[2],a:Number.isNaN(s)?1:s}}function Gc({r:e,g:t,b:n}){let r=o=>{let s=o/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function Yc(e,t){let n=Gc(e),r=Gc(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var Xc={r:10,g:10,b:10},Jc={r:250,g:250,b:250};function Zc(e,t){let n=e.a==null?1:e.a;return{r:e.r*n+t.r*(1-n),g:e.g*n+t.g*(1-n),b:e.b*n+t.b*(1-n)}}function fm(e){if(!e)return"light";let t=Yc(Zc(e,Xc),Xc),n=Yc(Zc(e,Jc),Jc);return t>n?"dark":"light"}function vo(e,t){for(let[n,r]of Object.entries(t))e.style.setProperty(n,r,"important")}function $i(e){let t=e.ownerDocument&&e.ownerDocument.defaultView,n=e.querySelector(".hcms-toggle__main");if(!t||!n||typeof t.getComputedStyle!="function")return;let r=cm(t.getComputedStyle(n).color,e.ownerDocument);e.setAttribute("data-hcms-surface",fm(r))}function dm(e){$i(e);let t=e.ownerDocument,n=t&&t.defaultView;if(!n)return;let r=0,o=()=>{if(!r){if(typeof n.requestAnimationFrame!="function")return e.isConnected?$i(e):l();r=n.requestAnimationFrame(()=>{if(r=0,!e.isConnected)return l();$i(e)})}};typeof n.requestAnimationFrame=="function"&&o(),t.readyState!=="complete"&&n.addEventListener("load",o,{once:!0});let s=typeof n.MutationObserver=="function"?new n.MutationObserver(o):null;s&&(s.observe(t.documentElement,{attributes:!0}),t.body&&s.observe(t.body,{attributes:!0}));let i=typeof n.matchMedia=="function"?n.matchMedia("(prefers-color-scheme: dark)"):null;i&&typeof i.addEventListener=="function"&&i.addEventListener("change",o);function l(){s&&s.disconnect(),i&&typeof i.removeEventListener=="function"&&i.removeEventListener("change",o)}}function hm({open:e,close:t,isOpen:n,getTheme:r=()=>null,views:o=xs},s=document){let i=s.querySelector(`[${Ft}]`);if(i)return i;if(!s.querySelector(`[${Wc}]`)){let L=s.createElement("style");L.setAttribute(Wc,""),L.setAttribute("editor-ui",""),s.getElementById(Vc)||(L.id=Vc),L.setAttribute("no-save",""),L.setAttribute("snapshot-remove",""),L.setAttribute("save-ignore",""),L.textContent=im,s.head.insertBefore(L,s.head.firstChild)}let l=s.createElement("hypercms-toggle");l.className="hcms-shell pixel-quiet",s.getElementById(zc)||(l.id=zc),l.setAttribute(Ft,""),l.setAttribute("editor-ui",""),l.setAttribute("no-save",""),l.setAttribute("snapshot-remove",""),l.setAttribute("save-ignore",""),l.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=s.defaultView,u=l.querySelector(".hcms-toggle__main"),d=xs.filter(L=>o.includes(L)),h=d.length>1,f=h?mm(s):null,p=h?pm(s,d):null;h&&(l.setAttribute(Qc,""),l.appendChild(f),l.appendChild(p)),vo(l,{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)"}),vo(u,{background:Ui}),f&&vo(f,{background:Ui}),p&&vo(p,{position:"absolute",right:"0",bottom:"calc(100% + 8px)","z-index":"var(--hcms-toggle-z, 2147482900)",display:"none"});let b=()=>p?[...p.querySelectorAll('[role="menuitemradio"]')]:[];function v(L){if(!(!L||typeof L.focus!="function"))try{L.focus({preventScroll:!0})}catch{L.focus()}}function m(L){let Ee=b();Ee.length&&v(Ee[(L+Ee.length)%Ee.length])}function g(){let L=Kc(a);for(let Ee of b())Ee.setAttribute("aria-checked",String(Ee.getAttribute("data-hcms-view")===L))}function y(L){l.contains(L.target)||$()}function I(L){p&&(p.hidden=!L,vo(p,{display:L?"block":"none"}),f.setAttribute("aria-expanded",String(L)),L?(g(),s.addEventListener("pointerdown",y,!0)):s.removeEventListener("pointerdown",y,!0))}function Y(L=0){I(!0),m(L)}function $({focusArrow:L=!1}={}){!p||p.hidden||(I(!1),L&&v(f))}function H(){let L=Kc(a);return L&&d.includes(L)?L:null}async function z(L){await e({view:L}),rm(a,L)}async function ae(){if(n()){t();return}let L=H();return L?e({view:L}):h?Y():e(d[0]?{view:d[0]}:{})}async function me(L){try{await L()}catch(Ee){console.warn("hypercms: toggle failed to open the CMS",Ee)}}l.addEventListener("click",async L=>{f&&f.contains(L.target)||p&&p.contains(L.target)||await me(ae)}),f&&(f.addEventListener("click",L=>{L.preventDefault(),p.hidden?Y():$({focusArrow:!0})}),f.addEventListener("keydown",L=>{if(L.key==="ArrowUp"){L.preventDefault(),Y(-1);return}(L.key==="ArrowDown"||L.key==="Enter"||L.key===" ")&&(L.preventDefault(),Y(0))}),p.addEventListener("click",L=>{let Ee=L.target.closest?.('[role="menuitemradio"]');Ee&&(L.preventDefault(),$(),me(()=>z(Ee.getAttribute("data-hcms-view"))))}),p.addEventListener("keydown",L=>{let Ee=b(),xe=Ee.indexOf(s.activeElement);switch(L.key){case"ArrowDown":L.preventDefault(),m(xe+1);break;case"ArrowUp":L.preventDefault(),m(xe-1);break;case"Home":L.preventDefault(),m(0);break;case"End":L.preventDefault(),m(Ee.length-1);break;case"Enter":case" ":if(L.preventDefault(),xe===-1)break;$(),me(()=>z(Ee[xe].getAttribute("data-hcms-view")));break;case"Escape":L.preventDefault(),$({focusArrow:!0});break;case"Tab":$();break}}));let Q=L=>{let Ee=r();l.classList.toggle("light",Ee==="light"),l.classList.toggle("dark",Ee==="dark"),L?l.setAttribute(ys,"open"):l.removeAttribute(ys)};return Q(n()),s.addEventListener("hcms:open",()=>Q(!0)),s.addEventListener("hcms:close",()=>Q(!1)),s.body.appendChild(l),Qn(s),dm(l),l}function mm(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 pm(e,t){let n=e.createElement("div");n.className="hcms-toggle__menu",n.setAttribute("role","menu"),n.setAttribute("aria-label","Where to edit"),n.hidden=!0;for(let r of t){let o=e.createElement("button");o.type="button",o.className="hcms-toggle__item",o.setAttribute("role","menuitemradio"),o.setAttribute("aria-checked","false"),o.setAttribute("data-hcms-view",r),o.tabIndex=-1,o.textContent=nm[r],n.appendChild(o)}return n}function nu(e){if(typeof window>"u"||typeof document>"u")return;let t=window.__hyperclayEditMode!=null?window.__hyperclayEditMode:null;if(!lm({search:window.location.search,cookie:document.cookie,forced:t}))return;let n=()=>{document.body&&e.hasRules(document)&&hm(e)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n,{once:!0}):n()}function ru(e){if(rc(e),typeof document<"u"){let t=document.getElementById("hcms-shell-styles");t?.tagName==="LINK"&&t.remove(),Qn(document)}}var Vi={sidebar:fc,inline:Lc};function vs(e={}){let t=e.view||(bt.isOpen?bt.ctx.view.name:"sidebar"),n=Vi[t];if(!n)throw new Error(`hypercms: unknown view "${t}" (expected ${Object.keys(Vi).join(" or ")})`);let r=bt.isOpen?{...bt.opts,...e,view:t}:e,o=r.pageRoot||(typeof document<"u"?document.body:null);if(!o)throw new Error("hypercms: no pageRoot available");let s=o.ownerDocument||(typeof document<"u"?document:null);if(!s)throw new Error("hypercms: no document available");let i=null,l=null;if(bt.isOpen){if(bt.ctx.view.name===t)return;i=bt.ctx.previouslyFocused,l=bt.ctx.view.name,ks(bt.ctx,{restoreFocus:!1,updateUrl:!1,reason:"switch"})}Tc();let a=n({doc:s,pageRoot:o,opts:r}),u=Bc({view:a,doc:s,pageRoot:o,opts:r,onCloseRequested:()=>Wi(),onViewRequested:d=>vs({view:d})});i&&(u.previouslyFocused=i);try{a.mount(u.initialData),Hc(u),a.focusOnOpen(),bt.isOpen=!0,bt.ctx=u,bt.opts=r,u.dispatch("hcms:open",{pageRoot:o,previous:l})}catch(d){throw ks(u,{dispatch:!1,restoreFocus:!!i,updateUrl:!1}),d}}function Wi(){bt.isOpen&&ks(bt.ctx)}function ou(){bt.isOpen&&bt.ctx.view.refresh("api")}function gm(){return bt.isOpen}function bm(){return bt.isOpen&&bt.ctx?bt.ctx.view.name:null}var km={getData(){return bt.isOpen?fn(bt.ctx):null},setValue(e,t){if(!bt.isOpen)throw new Error("hypercms: cms is not open");let n=bt.ctx,r=Pn(e),o=cr(n.pageRules,r);if(o===void 0)throw new Error(`hypercms: no rule at path "${e}"`);if(typeof o!="string"||o.endsWith("[]"))throw new Error(`hypercms: setValue requires a leaf scalar path; "${e}" is not a leaf`);let s=rs(n.formRoot,e);if(!s)throw new Error(`hypercms: no field element at path "${e}"`);os(s,t,n.formRoot,e),kn(fn(n),{path:e,structural:!1},n)},addItem(e){if(!bt.isOpen)throw new Error("hypercms: cms is not open");ho(e,bt.ctx)},removeItem(e){if(!bt.isOpen)throw new Error("hypercms: cms is not open");let t=bt.ctx,n=Pn(e);if(typeof n[n.length-1]!="number")throw new Error(`hypercms: removeItem requires an item path; "${e}" is not an array index`);let o=cr(t.pageRules,n.slice(0,-1));if(!(Array.isArray(o)||typeof o=="string"&&o.endsWith("[]")))throw new Error(`hypercms: removeItem requires an item path; parent of "${e}" is not an array`);let i=t.formRoot.querySelector(`[data-hcms-path="${Am(e)}"]`);if(!i)throw new Error(`hypercms: no element at path "${e}"`);qr(i,t)},refresh:ou,_commit(){if(!bt.isOpen)return;let e=bt.ctx;return ss(e.formRoot),dr("Update",()=>kn(fn(e),{path:"",structural:!0},e))}},ym=250,xm=1e4;function vm(){typeof window>"u"||typeof document>"u"||Uc(window.location?window.location.search:"")&&(bt.isOpen||wm(()=>{if(!bt.isOpen)try{vs()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function zi(){return!!document.body&&!!Jt("Mutation")}function wm(e){if(zi()){queueMicrotask(e);return}let t=Date.now()+xm,n=!1,r=null,o=null,s=()=>{n||(n=!0,r!==null&&clearInterval(r),o&&o())};function i(){if(bt.isOpen){s();return}zi()&&(s(),e())}o=Pr(document,qa,i),r=setInterval(()=>{if(bt.isOpen){s();return}if(zi()){s(),e();return}Date.now()>=t&&(s(),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."))},ym)}vm();nu({open:vs,close:Wi,isOpen:gm,getTheme:()=>bt.opts?.theme,views:Object.keys(Vi),hasRules:e=>!!ln.findRules(e,"cms")});var Ki={open:vs,close:Wi,refresh:ou,api:km,get isOpen(){return bt.isOpen},currentView:bm,path:ui,scaffold:co,morphForm:qo};function Am(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var su=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
306
+ `;function kp({search:e="",cookie:t="",forced:n=null}={}){let r=typeof e=="string"?e:"",o=r.indexOf("?"),s=o===-1?r:r.slice(o+1),l=new URLSearchParams(s).get("editmode");return l?l==="true":n!=null?!!n:/(?:^|;\s*)isAdminOfCurrentResource=[^;]/.test(t)}var ml=new WeakMap;function Gf(e,t){try{e.globalCompositeOperation="copy",e.fillStyle=t,e.fillRect(0,0,1,1);let n=e.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2],a:n[3]/255}}catch{return null}}function yp(e){if(ml.has(e))return ml.get(e);let t=null;try{let n=e.createElement("canvas");if(n.width=n.height=1,t=n.getContext?n.getContext("2d",{willReadFrequently:!0}):null,t){let r=Gf(t,"rgb(1, 2, 3)");(!r||r.r!==1||r.g!==2||r.b!==3||r.a!==1)&&(t=null)}}catch{t=null}return ml.set(e,t),t}function xp(e,t){let n=String(e??"").trim();if(!n)return null;let r=vp(n);if(r)return r;let o=t&&t.defaultView;if(!o||!o.CSS||typeof o.CSS.supports!="function"||!o.CSS.supports("color",n))return null;let s=yp(t);return s?Gf(s,n):null}function vp(e){let t=/rgba?\(([^)]+)\)/.exec(String(e??""));if(!t)return null;let n=t[1].split(/[\s,/]+/).filter(Boolean);if(n.length<3)return null;let r=n.slice(0,3).map(Number);if(r.some(Number.isNaN))return null;let o=n[3],s=o===void 0?1:o.endsWith("%")?Number(o.slice(0,-1))/100:Number(o);return{r:r[0],g:r[1],b:r[2],a:Number.isNaN(s)?1:s}}function Uf({r:e,g:t,b:n}){let r=o=>{let s=o/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function $f(e,t){let n=Uf(e),r=Uf(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var Hf={r:10,g:10,b:10},zf={r:250,g:250,b:250};function Vf(e,t){let n=e.a==null?1:e.a;return{r:e.r*n+t.r*(1-n),g:e.g*n+t.g*(1-n),b:e.b*n+t.b*(1-n)}}function wp(e){if(!e)return"light";let t=$f(Vf(e,Hf),Hf),n=$f(Vf(e,zf),zf);return t>n?"dark":"light"}function Bo(e,t){for(let[n,r]of Object.entries(t))e.style.setProperty(n,r,"important")}function pl(e){let t=e.ownerDocument&&e.ownerDocument.defaultView,n=e.querySelector(".hcms-toggle__main");if(!t||!n||typeof t.getComputedStyle!="function")return;let r=xp(t.getComputedStyle(n).color,e.ownerDocument);e.setAttribute("data-hcms-surface",wp(r))}function Ap(e){pl(e);let t=e.ownerDocument,n=t&&t.defaultView;if(!n)return;let r=0,o=()=>{if(!r){if(typeof n.requestAnimationFrame!="function")return e.isConnected?pl(e):i();r=n.requestAnimationFrame(()=>{if(r=0,!e.isConnected)return i();pl(e)})}};typeof n.requestAnimationFrame=="function"&&o(),t.readyState!=="complete"&&n.addEventListener("load",o,{once:!0});let s=typeof n.MutationObserver=="function"?new n.MutationObserver(o):null;s&&(s.observe(t.documentElement,{attributes:!0}),t.body&&s.observe(t.body,{attributes:!0}));let l=typeof n.matchMedia=="function"?n.matchMedia("(prefers-color-scheme: dark)"):null;l&&typeof l.addEventListener=="function"&&l.addEventListener("change",o);function i(){s&&s.disconnect(),l&&typeof l.removeEventListener=="function"&&l.removeEventListener("change",o)}}function Sp({open:e,close:t,isOpen:n,getTheme:r=()=>null,views:o=qs},s=document){let l=s.querySelector(`[${Yt}]`);if(l)return l;if(!s.querySelector(`[${Bf}]`)){let I=s.createElement("style");I.setAttribute(Bf,""),I.setAttribute("editor-ui",""),s.getElementById(Ff)||(I.id=Ff),I.setAttribute("no-save",""),I.setAttribute("snapshot-remove",""),I.setAttribute("save-ignore",""),I.textContent=bp,s.head.insertBefore(I,s.head.firstChild)}let i=s.createElement("hypercms-toggle");i.className="hcms-shell pixel-quiet",s.getElementById(Df)||(i.id=Df),i.setAttribute(Yt,""),i.setAttribute("editor-ui",""),i.setAttribute("no-save",""),i.setAttribute("snapshot-remove",""),i.setAttribute("save-ignore",""),i.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=s.defaultView,c=i.querySelector(".hcms-toggle__main"),h=qs.filter(I=>o.includes(I)),u=h.length>1,f=u?Tp(s):null,d=u?Ep(s,h):null;u&&(i.setAttribute(Wf,""),i.appendChild(f),i.appendChild(d)),Bo(i,{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)"}),Bo(c,{background:gl}),f&&Bo(f,{background:gl}),d&&Bo(d,{position:"absolute",right:"0",bottom:"calc(100% + 8px)","z-index":"var(--hcms-toggle-z, 2147482900)",display:"none"});let p=()=>d?[...d.querySelectorAll('[role="menuitemradio"]')]:[];function y(I){if(!(!I||typeof I.focus!="function"))try{I.focus({preventScroll:!0})}catch{I.focus()}}function m(I){let P=p();P.length&&y(P[(I+P.length)%P.length])}function g(){let I=qf(a);for(let P of p())P.setAttribute("aria-checked",String(P.getAttribute("data-hcms-view")===I))}function k(I){i.contains(I.target)||x()}function S(I){d&&(d.hidden=!I,Bo(d,{display:I?"block":"none"}),f.setAttribute("aria-expanded",String(I)),I?(g(),s.addEventListener("pointerdown",k,!0)):s.removeEventListener("pointerdown",k,!0))}function v(I=0){S(!0),m(I)}function x({focusArrow:I=!1}={}){!d||d.hidden||(S(!1),I&&y(f))}function O(){let I=qf(a);return I&&h.includes(I)?I:null}async function C(I){await e({view:I}),mp(a,I)}async function _(){if(n()){t();return}let I=O();return I?e({view:I}):u?v():e(h[0]?{view:h[0]}:{})}async function M(I){try{await I()}catch(P){console.warn("hypercms: toggle failed to open the CMS",P)}}i.addEventListener("click",async I=>{f&&f.contains(I.target)||d&&d.contains(I.target)||await M(_)}),f&&(f.addEventListener("click",I=>{I.preventDefault(),d.hidden?v():x({focusArrow:!0})}),f.addEventListener("keydown",I=>{if(I.key==="ArrowUp"){I.preventDefault(),v(-1);return}(I.key==="ArrowDown"||I.key==="Enter"||I.key===" ")&&(I.preventDefault(),v(0))}),d.addEventListener("click",I=>{let P=I.target.closest?.('[role="menuitemradio"]');P&&(I.preventDefault(),x(),M(()=>C(P.getAttribute("data-hcms-view"))))}),d.addEventListener("keydown",I=>{let P=p(),R=P.indexOf(s.activeElement);switch(I.key){case"ArrowDown":I.preventDefault(),m(R+1);break;case"ArrowUp":I.preventDefault(),m(R-1);break;case"Home":I.preventDefault(),m(0);break;case"End":I.preventDefault(),m(P.length-1);break;case"Enter":case" ":if(I.preventDefault(),R===-1)break;x(),M(()=>C(P[R].getAttribute("data-hcms-view")));break;case"Escape":I.preventDefault(),x({focusArrow:!0});break;case"Tab":x();break}}));let j=I=>{let P=r();i.classList.toggle("light",P==="light"),i.classList.toggle("dark",P==="dark"),I?i.setAttribute(Bs,"open"):i.removeAttribute(Bs)};return j(n()),s.addEventListener("hcms:open",()=>j(!0)),s.addEventListener("hcms:close",()=>j(!1)),s.body.appendChild(i),dr(s),Ap(i),i}function Tp(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 Ep(e,t){let n=e.createElement("div");n.className="hcms-toggle__menu",n.setAttribute("role","menu"),n.setAttribute("aria-label","Where to edit"),n.hidden=!0;for(let r of t){let o=e.createElement("button");o.type="button",o.className="hcms-toggle__item",o.setAttribute("role","menuitemradio"),o.setAttribute("aria-checked","false"),o.setAttribute("data-hcms-view",r),o.tabIndex=-1,o.textContent=hp[r],n.appendChild(o)}return n}function Yf(e){if(typeof window>"u"||typeof document>"u")return;let t=window.__hyperclayEditMode!=null?window.__hyperclayEditMode:null;if(!kp({search:window.location.search,cookie:document.cookie,forced:t}))return;let n=()=>{document.body&&e.hasRules(document)&&Sp(e)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n,{once:!0}):n()}function Xf(e){if(Yc(e),typeof document<"u"){let t=document.getElementById("hcms-shell-styles");t?.tagName==="LINK"&&t.remove(),dr(document)}}var kl={sidebar:rf,inline:Ef};function Us(e={}){let t=e.view||(Lt.isOpen?Lt.ctx.view.name:"sidebar"),n=kl[t];if(!n)throw new Error(`hypercms: unknown view "${t}" (expected ${Object.keys(kl).join(" or ")})`);let r=Lt.isOpen?{...Lt.opts,...e,view:t}:e,o=r.pageRoot||(typeof document<"u"?document.body:null);if(!o)throw new Error("hypercms: no pageRoot available");let s=o.ownerDocument||(typeof document<"u"?document:null);if(!s)throw new Error("hypercms: no document available");let l=null,i=null;if(Lt.isOpen){if(Lt.ctx.view.name===t)return;l=Lt.ctx.previouslyFocused,i=Lt.ctx.view.name,Fs(Lt.ctx,{restoreFocus:!1,updateUrl:!1,reason:"switch"})}kf();let a=n({doc:s,pageRoot:o,opts:r}),c=If({view:a,doc:s,pageRoot:o,opts:r,onCloseRequested:()=>yl(),onViewRequested:h=>Us({view:h})});l&&(c.previouslyFocused=l);try{a.mount(c.initialData),Lf(c),a.focusOnOpen(),Lt.isOpen=!0,Lt.ctx=c,Lt.opts=r,c.dispatch("hcms:open",{pageRoot:o,previous:i})}catch(h){throw Fs(c,{dispatch:!1,restoreFocus:!!l,updateUrl:!1}),h}}function yl(){Lt.isOpen&&Fs(Lt.ctx)}function Jf(){Lt.isOpen&&Lt.ctx.view.refresh("api")}function _p(){return Lt.isOpen}function Op(){return Lt.isOpen&&Lt.ctx?Lt.ctx.view.name:null}var Np={getData(){return Lt.isOpen?vn(Lt.ctx):null},setValue(e,t){if(!Lt.isOpen)throw new Error("hypercms: cms is not open");let n=Lt.ctx,r=Jn(e),o=Ar(n.pageRules,r);if(o===void 0)throw new Error(`hypercms: no rule at path "${e}"`);if(typeof o!="string"||o.endsWith("[]"))throw new Error(`hypercms: setValue requires a leaf scalar path; "${e}" is not a leaf`);let s=As(n.formRoot,e);if(!s)throw new Error(`hypercms: no field element at path "${e}"`);Ss(s,t,n.formRoot,e),_n(vn(n),{path:e,structural:!1},n)},addItem(e){if(!Lt.isOpen)throw new Error("hypercms: cms is not open");Mo(e,Lt.ctx)},removeItem(e){if(!Lt.isOpen)throw new Error("hypercms: cms is not open");let t=Lt.ctx,n=Jn(e);if(typeof n[n.length-1]!="number")throw new Error(`hypercms: removeItem requires an item path; "${e}" is not an array index`);let o=Ar(t.pageRules,n.slice(0,-1));if(!(Array.isArray(o)||typeof o=="string"&&o.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="${Lp(e)}"]`);if(!l)throw new Error(`hypercms: no element at path "${e}"`);no(l,t)},refresh:Jf,_commit(){if(!Lt.isOpen)return;let e=Lt.ctx;return Ts(e.formRoot),Er("Update",()=>_n(vn(e),{path:"",structural:!0},e))}},Cp=250,Mp=1e4;function Rp(){typeof window>"u"||typeof document>"u"||Pf(window.location?window.location.search:"")&&(Lt.isOpen||Ip(()=>{if(!Lt.isOpen)try{Us()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function bl(){return!!document.body&&!!cn("Mutation")}function Ip(e){if(bl()){queueMicrotask(e);return}let t=Date.now()+Mp,n=!1,r=null,o=null,s=()=>{n||(n=!0,r!==null&&clearInterval(r),o&&o())};function l(){if(Lt.isOpen){s();return}bl()&&(s(),e())}o=Qr(document,Mc,l),r=setInterval(()=>{if(Lt.isOpen){s();return}if(bl()){s(),e();return}Date.now()>=t&&(s(),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."))},Cp)}Rp();Yf({open:Us,close:yl,isOpen:_p,getTheme:()=>Lt.opts?.theme,views:Object.keys(kl),hasRules:e=>!!pn.findRules(e,"cms")});var xl={open:Us,close:yl,refresh:Jf,api:Np,get isOpen(){return Lt.isOpen},currentView:Op,path:Di,scaffold:Oo,morphForm:ss};function Lp(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Zf=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
307
307
  Source of truth: mirk-interface/mirk.css + src/theme/pixel-quiet.overrides.css.
308
308
  Regenerate with: npm run build:theme */
309
309
 
@@ -2199,4 +2199,4 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
2199
2199
  will-change: transform;
2200
2200
  }
2201
2201
  .hcms-inline-highlight[hidden] { display: none; }
2202
- `;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",n=>{let r=n.target.closest(".mirk-number__step");if(!r)return;let o=r.closest(".mirk-number").querySelector("input[type=number]");o&&(r.dataset.step==="up"?o.stepUp():o.stepDown(),o.dispatchEvent(new Event("change",{bubbles:!0})))}),document.addEventListener("input",n=>{let r=n.target.closest(".mirk-slider__input");r&&r.closest(".mirk-slider").style.setProperty("--mirk-value",`${r.value}%`)}),document.addEventListener("change",n=>{let r=n.target.closest(".mirk-file__input");if(!r||!r.files.length)return;let o=r.closest(".mirk-file"),s=o.querySelector(".mirk-file__name");if(!s)return;let i=r.files[0],l=document.createElement("a");if(l.className="mirk-file__name",l.dataset.filled="",l.href=URL.createObjectURL(i),l.target="_blank",l.rel="noopener",l.textContent=i.name,s.replaceWith(l),!o.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,l.after(a)}}),document.addEventListener("change",n=>{let r=n.target.closest(".mirk-image__input");if(!r||!r.files.length)return;let o=r.closest(".mirk-image"),s=o.querySelector(".mirk-image__preview");if(!s)return;let i=o.querySelector(".mirk-image__placeholder"),l=new FileReader;l.onload=a=>{s.src=a.target.result,s.removeAttribute("hidden"),i&&i.setAttribute("hidden",""),o.querySelector(".mirk-image__thumb")?.removeAttribute("hidden"),o.querySelector(".mirk-image__upload")?.setAttribute("hidden","")},l.readAsDataURL(r.files[0])}),document.addEventListener("click",n=>{let r=n.target.closest(".mirk-file__remove");if(r){let s=r.closest(".mirk-file"),i=s?.querySelector(".mirk-file__input"),l=s?.querySelector(".mirk-file__name");if(i&&(i.value=""),l){let a=document.createElement("span");a.className="mirk-file__name",a.textContent="No file chosen",l.replaceWith(a)}r.remove();return}let o=n.target.closest(".mirk-image__remove");if(o){let s=o.closest(".mirk-image"),i=s?.querySelector(".mirk-image__input"),l=s?.querySelector(".mirk-image__preview");i&&(i.value=""),l&&(l.removeAttribute("src"),l.setAttribute("hidden","")),s?.querySelector(".mirk-image__thumb")?.setAttribute("hidden",""),s?.querySelector(".mirk-image__upload")?.removeAttribute("hidden")}});function t(n,r){let o=document.createElement("span");o.textContent=n;let s=document.createElement("input");s.type="hidden",s.name="tags[]",s.value=n;let i=document.createElement("button");i.type="button",i.className="mirk-tags__remove",i.textContent="\xD7";let l=document.createElement("span");if(l.className="mirk-tags__chip",r){let a=document.createElement("span");a.className="mirk-tags__chip-inner",a.append(o,s,i),l.append(a)}else l.append(o,s,i);return l}document.addEventListener("keydown",n=>{let r=n.target.closest(".mirk-tags__input");if(!r)return;let o=r.closest(".mirk-tags");if(n.key==="Enter"||n.key===","){let s=r.value.trim();if(!s)return;n.preventDefault(),r.before(t(s,o.classList.contains("mirk-tags--round"))),r.value=""}else if(n.key==="Backspace"&&!r.value){let s=o.querySelectorAll(".mirk-tags__chip");s[s.length-1]?.remove()}}),document.addEventListener("click",n=>{let r=n.target.closest(".mirk-tags__remove");if(r){r.closest(".mirk-tags__chip").remove();return}let o=n.target.closest(".mirk-tags");o&&n.target===o&&o.querySelector(".mirk-tags__input")?.focus()}),document.addEventListener("click",n=>{let r=n.target.closest("[data-mirk-chip]");if(!r)return;let o=r.getAttribute("data-mirk-chip");if(o==="open")r.closest(".mirk-chip")?.classList.add("mirk-chip--open");else if(o==="collapse")r.closest(".mirk-chip")?.classList.remove("mirk-chip--open");else if(o==="changes"){let s=r.closest(".mirk-chip__panel")?.classList.toggle("is-changes");r.textContent=s?"(hide changes)":"(view changes)"}}),document.addEventListener("click",n=>{let r=n.target.closest("[data-copy-btn]");if(!r)return;let o=r.closest("[data-copy]");if(!o)return;let s=o.cloneNode(!0);s.querySelectorAll("[data-copy-btn]").forEach(a=>a.remove());let l=o.getAttribute("data-copy")==="text"?s.textContent.replace(/^\s+|\s+$/g,""):s.innerHTML.replace(/\s+data-copy(="[^"]*")?/g,"").replace(/^\s*\n/gm,"").trim();navigator.clipboard.writeText(l).then(()=>{let a=r.textContent;r.textContent="copied",r.dataset.copied="",setTimeout(()=>{r.textContent=a,delete r.dataset.copied},1200)}).catch(()=>{r.textContent="error",setTimeout(()=>{r.textContent="copy"},1200)})})})();ru(su);var Em=Ki,_m={cms:Ki};return uu(Om);})();
2202
+ `;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",n=>{let r=n.target.closest(".mirk-number__step");if(!r)return;let o=r.closest(".mirk-number").querySelector("input[type=number]");o&&(r.dataset.step==="up"?o.stepUp():o.stepDown(),o.dispatchEvent(new Event("change",{bubbles:!0})))}),document.addEventListener("input",n=>{let r=n.target.closest(".mirk-slider__input");r&&r.closest(".mirk-slider").style.setProperty("--mirk-value",`${r.value}%`)}),document.addEventListener("change",n=>{let r=n.target.closest(".mirk-file__input");if(!r||!r.files.length)return;let o=r.closest(".mirk-file"),s=o.querySelector(".mirk-file__name");if(!s)return;let l=r.files[0],i=document.createElement("a");if(i.className="mirk-file__name",i.dataset.filled="",i.href=URL.createObjectURL(l),i.target="_blank",i.rel="noopener",i.textContent=l.name,s.replaceWith(i),!o.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,i.after(a)}}),document.addEventListener("change",n=>{let r=n.target.closest(".mirk-image__input");if(!r||!r.files.length)return;let o=r.closest(".mirk-image"),s=o.querySelector(".mirk-image__preview");if(!s)return;let l=o.querySelector(".mirk-image__placeholder"),i=new FileReader;i.onload=a=>{s.src=a.target.result,s.removeAttribute("hidden"),l&&l.setAttribute("hidden",""),o.querySelector(".mirk-image__thumb")?.removeAttribute("hidden"),o.querySelector(".mirk-image__upload")?.setAttribute("hidden","")},i.readAsDataURL(r.files[0])}),document.addEventListener("click",n=>{let r=n.target.closest(".mirk-file__remove");if(r){let s=r.closest(".mirk-file"),l=s?.querySelector(".mirk-file__input"),i=s?.querySelector(".mirk-file__name");if(l&&(l.value=""),i){let a=document.createElement("span");a.className="mirk-file__name",a.textContent="No file chosen",i.replaceWith(a)}r.remove();return}let o=n.target.closest(".mirk-image__remove");if(o){let s=o.closest(".mirk-image"),l=s?.querySelector(".mirk-image__input"),i=s?.querySelector(".mirk-image__preview");l&&(l.value=""),i&&(i.removeAttribute("src"),i.setAttribute("hidden","")),s?.querySelector(".mirk-image__thumb")?.setAttribute("hidden",""),s?.querySelector(".mirk-image__upload")?.removeAttribute("hidden")}});function t(n,r){let o=document.createElement("span");o.textContent=n;let s=document.createElement("input");s.type="hidden",s.name="tags[]",s.value=n;let l=document.createElement("button");l.type="button",l.className="mirk-tags__remove",l.textContent="\xD7";let i=document.createElement("span");if(i.className="mirk-tags__chip",r){let a=document.createElement("span");a.className="mirk-tags__chip-inner",a.append(o,s,l),i.append(a)}else i.append(o,s,l);return i}document.addEventListener("keydown",n=>{let r=n.target.closest(".mirk-tags__input");if(!r)return;let o=r.closest(".mirk-tags");if(n.key==="Enter"||n.key===","){let s=r.value.trim();if(!s)return;n.preventDefault(),r.before(t(s,o.classList.contains("mirk-tags--round"))),r.value=""}else if(n.key==="Backspace"&&!r.value){let s=o.querySelectorAll(".mirk-tags__chip");s[s.length-1]?.remove()}}),document.addEventListener("click",n=>{let r=n.target.closest(".mirk-tags__remove");if(r){r.closest(".mirk-tags__chip").remove();return}let o=n.target.closest(".mirk-tags");o&&n.target===o&&o.querySelector(".mirk-tags__input")?.focus()}),document.addEventListener("click",n=>{let r=n.target.closest("[data-mirk-chip]");if(!r)return;let o=r.getAttribute("data-mirk-chip");if(o==="open")r.closest(".mirk-chip")?.classList.add("mirk-chip--open");else if(o==="collapse")r.closest(".mirk-chip")?.classList.remove("mirk-chip--open");else if(o==="changes"){let s=r.closest(".mirk-chip__panel")?.classList.toggle("is-changes");r.textContent=s?"(hide changes)":"(view changes)"}}),document.addEventListener("click",n=>{let r=n.target.closest("[data-copy-btn]");if(!r)return;let o=r.closest("[data-copy]");if(!o)return;let s=o.cloneNode(!0);s.querySelectorAll("[data-copy-btn]").forEach(a=>a.remove());let i=o.getAttribute("data-copy")==="text"?s.textContent.replace(/^\s+|\s+$/g,""):s.innerHTML.replace(/\s+data-copy(="[^"]*")?/g,"").replace(/^\s*\n/gm,"").trim();navigator.clipboard.writeText(i).then(()=>{let a=r.textContent;r.textContent="copied",r.dataset.copied="",setTimeout(()=>{r.textContent=a,delete r.dataset.copied},1200)}).catch(()=>{r.textContent="error",setTimeout(()=>{r.textContent="copy"},1200)})})})();Xf(Zf);var Dp=xl,Fp={cms:xl};return au(Bp);})();