@panphora/hyper-cms 0.11.4 → 0.11.6
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.
- package/dist/hypercms.min.js +23 -23
- package/package.json +3 -3
package/dist/hypercms.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var hypercms=(()=>{var ri=Object.defineProperty;var vu=Object.getOwnPropertyDescriptor;var wu=Object.getOwnPropertyNames;var Au=Object.prototype.hasOwnProperty;var oi=(e,t)=>{for(var n in t)ri(e,n,{get:t[n],enumerable:!0})},Su=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of wu(t))!Au.call(e,o)&&o!==n&&ri(e,o,{get:()=>t[o],enumerable:!(r=vu(t,o))||r.enumerable});return e};var Tu=e=>Su(ri({},"__esModule",{value:!0}),e);var mg={};oi(mg,{cms:()=>dg,default:()=>hg});function sn(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 Jo(e){let t=sn(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function Zo(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 si(e){let t=new Map;return(n,r)=>{if(typeof r!="string")return Zo(r,e);let o=t.get(n);if(o&&o.text===r)return o.doc;let s=Zo(r,e);return t.set(n,{text:r,doc:s}),s}}function Ul(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 ii=()=>!1;function li(e,t=[]){if(typeof e!="function")return ii;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 c=n.get(l);if(c!==void 0){a=c;break}if(i.push(l),e(l,r.has(l))){a=!0;break}if(r.has(l))break;l=l.parentElement}for(let c of i)n.set(c,a);return a}}var Mg=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 ar(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function ai(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=u=>Number.isInteger(u)&&u>=0,l=0,a=!1,c=u=>{let f=u;for(;f>0;){let p=o[l++];if(l>o.length||!i(p))return!1;f+=p-1}return!0},h=(u,f)=>{if(a)return;if(o){let y=l++,g=o[y];if(y>=o.length||!i(g)){a=!0;return}let d=!s||s[y]===u.tagName.toLowerCase();if(!d||g!==u.children.length){let k=d&&t[f];typeof k=="string"&&k&&n.set(u,k),c(g)||(a=!0);return}}let p=t[f];typeof p=="string"&&p&&n.set(u,p);let m=u.children;for(let y=0;y<m.length;y++)h(m[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 _n=$l([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Qo(e,t,n,r=null,o=null){let s=new Map,i=new Set,l=a=>{if(n(a))return;let c=t(a);c&&(s.has(c)?i.add(c):s.set(c,a))};if(r){let a=c=>{for(let h of c.querySelectorAll(r))l(h);for(let h of c.querySelectorAll("template"))h.content&&a(h.content)};l(e),a(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let a=c=>{l(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 i)s.delete(a),o&&o.add(a),ci(a);return s}function ci(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var Ou=new Set(["href","src","name","type","role"]),zl=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function Lr(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 Hl(e){return e.replace(/\s+/g," ")}var _u=0;function Vl({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let r=new WeakMap,o=new WeakMap;function s(E){let N=E.attributes,_=N.length;if(_===0)return{all:"",sig:E.tagName+"|"};let M=[],j="",R=[];for(let D=0;D<_;D++){let F=N[D],S=F.name;t(E,S)||M.push(S+"="+F.value),S==="class"?j=F.value.indexOf(" ")<0?F.value:F.value.split(/\s+/).filter(Boolean).sort().join(" "):Ou.has(S)&&R.push(S+"="+F.value)}return M.length>1&&M.sort(),R.length>1&&R.sort(),{all:M.join(""),sig:E.tagName+"|"+j+(R.length?"|"+R.join("|"):"")}}function i(E){return E.nodeType===1&&E.tagName==="TEMPLATE"&&E.content?E.content.childNodes:E.childNodes}function l(E){let N=r.get(E);if(N)return N;if(E.nodeType===3)N={hash:"T"+Lr(E.nodeValue),hint:Hl(E.nodeValue).slice(0,64),sig:null,tok:null};else if(E.nodeType===8)N={hash:"C"+Lr(E.nodeValue),hint:"",sig:null,tok:null};else if(E.nodeType===1){let _=s(E),M=Lr(E.tagName+""+_.all),j="";for(let R of c(E))if(R.nodeType===1){let D=l(R);M=Lr(D.hash,M),j.length<64&&(j+=" "+D.hint)}else M=Lr(h(R),M),R.kind==="text"&&j.length<64&&(j+=R.value.slice(0,64));N={hash:"E"+M,hint:Hl(j).trim().slice(0,64),sig:_.sig,tok:null}}else N={hash:"N"+E.nodeType,hint:"",sig:null,tok:null};return r.set(E,N),N}function a(E){if(!E.tok){E.tok=new Set;for(let N of E.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))N&&E.tok.add(N)}return E.tok}function c(E){let N=o.get(E);if(N)return N;N=[];let _=null,M=()=>{_&&(_.value=_.nodes.map(j=>j.nodeValue).join(""),N.push(_),_=null)};for(let j of i(E)){if(j.nodeType===3){_||(_={kind:"text",nodes:[],value:"",parent:E,hash:void 0}),_.nodes.push(j);continue}M(),j.nodeType===8?N.push({kind:"comment",nodes:[j],value:j.nodeValue,parent:E,hash:void 0}):j.nodeType===1&&!e(j)&&N.push(j)}return M(),o.set(E,N),N}function h(E){return E.nodeType===1?l(E).hash:(E.hash===void 0&&(E.hash=(E.kind==="text"?"T":"C")+Lr(E.value)),E.hash)}function u(E,N){let _=a(l(E)),M=a(l(N));if(_.size===0&&M.size===0)return{coef:1,share:1};if(_.size===0||M.size===0)return null;let j=0;for(let R of _)M.has(R)&&j++;return{coef:j/Math.min(_.size,M.size),share:j/Math.max(_.size,M.size)}}function f(E,N){let _=u(E,N);return!!_&&_.coef>=.5}let p=new WeakMap;function m(E){let N=p.get(E);if(N)return N;N=[];for(let _ of E.attributes)t(E,_.name)||N.push([_.namespaceURI||"",_.localName,_.value]);return N.sort((_,M)=>_[0]<M[0]?-1:_[0]>M[0]?1:_[1]<M[1]?-1:_[1]>M[1]?1:0),p.set(E,N),N}let y=new WeakMap;function g(E,N){if(E===N)return!0;if(h(E)!==h(N))return!1;let _=y.get(E);if(_&&_.has(N))return _.get(N);let M=y.get(N);if(M&&M.has(E))return M.get(E);let j=d(E,N),R=j===!0;return j===!1&&n&&n.hashRejected++,_||y.set(E,_=new WeakMap),_.set(N,R),R}function d(E,N){if(E.nodeType===1){if(N.nodeType!==1||E.tagName!==N.tagName||E.namespaceURI!==N.namespaceURI)return!1;let _=m(E),M=m(N);if(_.length!==M.length)return!1;for(let D=0;D<_.length;D++)if(_[D][0]!==M[D][0]||_[D][1]!==M[D][1]||_[D][2]!==M[D][2])return!1;let j=c(E),R=c(N);if(j.length!==R.length)return!1;for(let D=0;D<j.length;D++){if(h(j[D])!==h(R[D]))return!1;if(!g(j[D],R[D]))return _u}return!0}return N.nodeType===1?!1:E.kind===N.kind&&E.value===N.value}let k=new WeakMap,A=new Map,w=0;function v(E){let N=k.get(E);if(N)return N;let _=h(E),M=A.get(_);M||A.set(_,M=[]);let j=M.find(R=>g(R.unit,E));return N=j?j.key:"K"+w++,j||M.push({unit:E,key:N}),k.set(E,N),N}return{meta:l,unitsOf:c,unitHash:h,similar:f,score:u,childrenOf:i,equalUnits:g,exactUnitKey:v,ignored:e}}var Wl=16,Nu=2e3,Cu=3,fi={align:0,certifyVisited:0,certifyScheduled:0};function ui(e,t,n){let{meta:r,unitsOf:o,unitHash:s,similar:i,score:l,childrenOf:a,equalUnits:c,ignored:h}=n.analyzer,u=n.baseId||(()=>null),f=n.sideId||(()=>null),p=n.baseKey||(()=>null),m=n.sideKey||(()=>null),y=n.baseDropped||new Set,g=n.sideDropped||new Set,d=n.stats||null,k=d?new Set:null,A=d?new Set:null,w=new Map,v=new Map,E=new Set,N=new Map,_=new Set,M=new Set,j=new Set,R=[],D=[],F=[],S=[],T=Nu,J=new Map,q=new Map,V=(U,Y)=>{w.set(U,Y),v.set(Y,U)},Ce=new Set,Me=new Set,Be=null,ce=U=>{let Y=U.nodeType?U.parentNode:U.parent;if(!Y||Y.nodeType!==11)return Y;if(!Be){Be=new WeakMap;let pe=ke=>{for(let me of ke.querySelectorAll("template"))me.content&&(Be.set(me.content,me),pe(me.content))};for(let ke of[e,t])pe(ke.tagName==="TEMPLATE"&&ke.content?ke.content:ke)}return Be.get(Y)||null},Ae=(U,Y)=>{for(let pe=ce(U);pe&&!Ce.has(pe);pe=ce(pe))Ce.add(pe);for(let pe=ce(Y);pe&&!Me.has(pe);pe=ce(pe))Me.add(pe)},Ue=U=>{for(let Y=ce(U);Y;Y=ce(Y))if(w.has(Y))return M.has(Y);return!1},Ne=U=>{for(let Y=ce(U);Y;Y=ce(Y)){let pe=v.get(Y);if(pe!==void 0)return M.has(pe)}return!1},O=U=>!!U&&U.nodeType===1,X=(U,Y)=>{let pe=N.get(U);return!!pe&&pe.has(Y)},le=U=>zl.has(U.tagName),re=n.comparisons||n.scope,Pe=(U,Y)=>{if(re){if(re.same.get(U)===Y)return!0;if(re.differ.get(U)===Y)return!1}if(!U.isEqualNode(Y))return!1;if(U.tagName==="TEMPLATE")return c(U,Y);let pe=U.getElementsByTagName("template");if(pe.length===0)return!0;let ke=Y.getElementsByTagName("template");if(pe.length!==ke.length)return!1;for(let me=0;me<pe.length;me++)if(!c(pe[me],ke[me]))return!1;return!0},Fe=(U,Y)=>{let pe=u(U);if(!pe)return!0;let ke=f(Y);return!ke||pe===ke},Te=U=>{let Y=p(U);return Y&&n.baseIndex.get(Y)===U&&!g.has(Y)?Y:null},ot=U=>{let Y=m(U);return Y&&n.sideIndex.get(Y)===U&&!y.has(Y)?Y:null},et=(U,Y)=>{let pe=Te(U);if(!pe)return!0;let ke=ot(Y);return!ke||pe===ke},ae=globalThis.__hyperMorphProfile,de=ae?performance.now():0;ae&&!n.scope&&(r(e),r(t),ae.meta=(ae.meta||0)+(performance.now()-de),de=performance.now()),V(e,t);let Ee=new Set;for(let[U,Y]of n.baseIndex){let pe=n.sideIndex.get(U);pe&&pe.tagName===Y.tagName&&!w.has(Y)&&!v.has(pe)&&(V(Y,pe),Ae(Y,pe),Ee.add(Y))}if(Ee.size){let U=[];if(n.scope)for(let me of n.scope.chain)Ee.has(me)&&U.push(me);let Y=[n.scope?n.scope.root:e];for(;Y.length;){let me=Y.pop();Ee.has(me)&&U.push(me);let ee=a(me);for(let te=ee.length-1;te>=0;te--)ee[te].nodeType===1&&Y.push(ee[te])}let pe=new Set;for(let me=U.length-1;me>=0;me--){let ee=U[me];n.scope&&n.scope.onChain.has(ee)?pe.add(ee):Bt(ee,w.get(ee),pe)?(M.add(ee),j.add(ee),d&&d.certificationPairs++):pe.add(ee)}let ke=new Set;for(let me of U)M.has(me)&&!ke.has(me)&&Ge(me,ke)}n.scope&&n.scope.head&&Yt(n.scope.head[0],n.scope.head[1]);function Ge(U,Y){let pe=[U];for(;pe.length;){let ke=pe.pop();if(!Y.has(ke)){Y.add(ke),C(ke);for(let me of o(ke))O(me)&&w.has(me)&&pe.push(me)}}}S.push([e,t]);for(let[U,Y]of w)O(U)&&U!==e&&S.push([U,Y]);return pt(),Ve(),ae&&(ae.align=(ae.align||0)+(performance.now()-de)),{map:w,reverse:v,moved:_,identical:M,pairIdenticalChildren:C,weak:E,unpair:ze,rematch:Ve,insertedByHash:lt,refused:A,identityPaired:Ee};function Ve(){_e(),pt();for(let U=0;U<F.length;){let Y=F.length;vt(U,Y),U=Y,pt(),_e(),pt()}}function ze(U){let Y=w.get(U);if(!Y)return;N.has(U)||N.set(U,new Set),N.get(U).add(Y);let pe=(me,ee)=>{w.delete(me),v.delete(ee),_.delete(me),M.delete(me),E.delete(me),j.delete(me)},ke=(me,ee)=>{for(let te of o(me)){let W=w.get(te);!W||Ee.has(te)||!(O(W)?ee.contains(W):ee.contains(W.nodes[0]))||(pe(te,W),O(te)&&ke(te,W))}};pe(U,Y),O(U)&&ke(U,Y),R.push(U),D.push(Y)}function lt(){let U=new Map;for(let Y of new Set(D)){if(v.has(Y))continue;let pe=r(Y).hash;U.has(pe)||U.set(pe,[]),U.get(pe).push(Y)}return U}function pt(){for(;S.length;){let[U,Y]=S.shift();w.get(U)!==Y||j.has(U)||M.has(U)||dt(U,Y)}}function Rt(U,Y){if(!le(U))for(let pe of o(U))O(pe)&&(Y.push(pe),Rt(pe,Y))}function dt(U,Y){j.add(U);let pe=o(U),ke=o(Y);fi.align+=pe.length+ke.length,J=new Map,q=new Map;for(let ne=0;ne<pe.length;ne++)J.set(pe[ne],ne);for(let ne=0;ne<ke.length;ne++)q.set(ke[ne],ne);if(U.tagName==="HTML")for(let ne of["HEAD","BODY"]){let we=pe.find(je=>O(je)&&je.tagName===ne),Ie=ke.find(je=>O(je)&&je.tagName===ne);we&&Ie&&!w.has(we)&&!v.has(Ie)&&V(we,Ie)}for(let ne=0;ne<pe.length&&ne<ke.length;ne++){let we=pe[ne],Ie=ke[ne];w.has(we)||v.has(Ie)||(O(we)?O(Ie)&&we.tagName===Ie.tagName&&Pe(we,Ie)&&Yt(we,Ie):!O(Ie)&&we.kind===Ie.kind&&we.value===Ie.value&&Yt(we,Ie))}ie(pe,ke);let me=pe.filter(ne=>!w.has(ne)),ee=ke.filter(ne=>!v.has(ne));me.length&&ee.length&&(yn(me,ee),L(me,ee),$(me,ee,pe,ke),he(pe,ke));let te=!1,W=!1;for(let ne of pe){if(!w.has(ne)){O(ne)&&(R.push(ne),Rt(ne,R),te=!0);continue}O(ne)&&!M.has(ne)&&S.push([ne,w.get(ne)])}for(let ne of ke)!v.has(ne)&&O(ne)&&(D.push(ne),Rt(ne,D),W=!0);te&&W&&F.push([U,Y])}function vt(U,Y){for(let pe=U;pe<Y;pe++){let[ke,me]=F[pe];if(w.get(ke)!==me)continue;let ee=o(ke),te=o(me),W=new Map,ne=new Map,we=null;for(let Ie of ee)O(Ie)&&(w.has(Ie)?we=Ie:(W.has(we)||W.set(we,[]),W.get(we).push(Ie)));we=null;for(let Ie of te)O(Ie)&&(v.has(Ie)?we=v.get(Ie):(ne.has(we)||ne.set(we,[]),ne.get(we).push(Ie)));for(let[Ie,je]of W){let Se=ne.get(Ie);if(!(!Se||je.length!==Se.length)&&je.every((Je,nt)=>Se[nt].tagName===Je.tagName&&Fe(Je,Se[nt])&&!X(Je,Se[nt])))for(let Je=0;Je<je.length;Je++)gt(je[Je],Se[Je])}}}function gt(U,Y){V(U,Y),E.add(U),S.push([U,Y]),pt()}function yn(U,Y){let pe=Pr(U,s),ke=Pr(Y,s),me=new Map;for(let ee of Y){let te=s(ee);ke.get(te)===1&&me.set(te,ee)}for(let ee of U){if(w.has(ee))continue;let te=s(ee);if(pe.get(te)!==1)continue;let W=me.get(te);W&&!v.has(W)&&c(ee,W)&&Yt(ee,W)}}function Bt(U,Y,pe){let ke=[[U,Y]];for(;ke.length;){let[me,ee]=ke.pop();if(fi.certifyVisited++,d&&d.certificationVisited++,me.nodeType!==ee.nodeType)return!1;if(me.nodeType===3||me.nodeType===8){if(me.nodeValue!==ee.nodeValue)return!1;continue}if(me.nodeType!==1){if(!me.isEqualNode(ee))return!1;continue}if(me.tagName!==ee.tagName||me.namespaceURI!==ee.namespaceURI||h(me)!==h(ee))return!1;let te=me.attributes,W=ee.attributes;if(te.length!==W.length)return!1;for(let Se=0;Se<te.length;Se++){let Je=te[Se];if(ee.getAttributeNS(Je.namespaceURI,Je.localName)!==Je.value)return!1}let ne=w.get(me);if(ne!==void 0&&ne!==ee)return!1;let we=v.get(ee);if(we!==void 0&&we!==me)return!1;if(me!==U){if(M.has(me))continue;if(pe.has(me))return!1}let Ie=a(me),je=a(ee);if(Ie.length!==je.length)return!1;fi.certifyScheduled+=Ie.length;for(let Se=Ie.length-1;Se>=0;Se--)ke.push([Ie[Se],je[Se]])}return!0}function Qt(U,Y){return!O(U)||!(Ce.has(U)||Me.has(Y))?!0:!!K(U,Y)||!(Te(U)||ot(Y))}function Yt(U,Y){if(O(U)&&(Ce.has(U)||Me.has(Y))){let pe=K(U,Y);if(!pe){if(Te(U)||ot(Y))return;V(U,Y),S.push([U,Y]);return}for(let ke=0;ke<pe.length;ke+=2){let me=pe[ke],ee=pe[ke+1],te=w.get(me);te!==void 0&&te!==ee&&gn(me,te);let W=v.get(ee);W!==void 0&&W!==me&&gn(W,ee),w.get(me)===ee&&(_.delete(me),E.delete(me),M.add(me),j.add(me))}}b(U,Y)}function gn(U,Y){w.delete(U),v.delete(Y),_.delete(U),M.delete(U),E.delete(U),j.delete(U)}function K(U,Y){let pe=[U,Y,!1],ke=[];for(;pe.length;){let me=pe.pop(),ee=pe.pop(),te=pe.pop(),W=w.get(te),ne=v.get(ee);if(te!==U&&(W!==void 0&&W!==ee&&Ee.has(te)||ne!==void 0&&ne!==te&&Ee.has(ne)))return null;if(!(W===ee&&M.has(te))&&((W!==void 0||ne!==void 0)&&ke.push(te,ee),!!O(te))){if(me||W!==void 0&&W!==ee||ne!==void 0&&ne!==te){let we=o(te),Ie=o(ee);for(let je=0;je<we.length&&je<Ie.length;je++)pe.push(we[je],Ie[je],!0)}else if(Ce.has(te)||Me.has(ee)){let we=te.tagName==="TEMPLATE"?te.content:te,Ie=ee.tagName==="TEMPLATE"?ee.content:ee;for(let je=we.firstElementChild,Se=Ie.firstElementChild;je&&Se;){if(h(je)){je=je.nextElementSibling;continue}if(h(Se)){Se=Se.nextElementSibling;continue}(w.has(je)||v.has(Se)||Ce.has(je)||Me.has(Se))&&pe.push(je,Se,!1),je=je.nextElementSibling,Se=Se.nextElementSibling}}}}return ke}function b(U,Y){V(U,Y),M.add(U),O(U)&&j.add(U)}function C(U){let Y=w.get(U);if(!Y||!O(U))return;let pe=o(U),ke=o(Y);for(let me=0;me<pe.length&&me<ke.length;me++)w.has(pe[me])||b(pe[me],ke[me])}function L(U,Y){let pe=te=>O(te)&&!le(te)?r(te).sig+""+r(te).hint:null,ke=Pr(U,pe),me=Pr(Y,pe),ee=new Map;for(let te of Y){let W=pe(te);W!=null&&me.get(W)===1&&ee.set(W,te)}for(let te of U){if(w.has(te))continue;let W=pe(te);if(W==null||ke.get(W)!==1)continue;let ne=ee.get(W);ne&&!v.has(ne)&&Fe(te,ne)&&V(te,ne)}}function $(U,Y,pe,ke){let me=new Map;for(let te of Y){if(!O(te)||v.has(te)||le(te))continue;let W=r(te).sig;me.has(W)||me.set(W,[]),me.get(W).push({el:te,index:q.get(te)})}let ee=[];for(let te of U){if(w.has(te)||!O(te)||le(te))continue;let W=me.get(r(te).sig);if(!W||!W.length)continue;let ne=J.get(te),we=W.filter(Ie=>!v.has(Ie.el)).map(Ie=>({c:Ie,d:Math.abs(Ie.index-ne)}));we.sort((Ie,je)=>Ie.d-je.d),we.length>Wl&&(we=we.slice(0,Wl));for(let{c:Ie,d:je}of we){if(!Fe(te,Ie.el))continue;let Se=l(te,Ie.el);Se&&Se.coef>=.5&&ee.push({b:te,s:Ie.el,coef:Se.coef,share:Se.share,d:je,bi:ne})}}if(ee.sort((te,W)=>W.coef-te.coef||W.share-te.share||te.d-W.d||te.bi-W.bi),d&&ee.length>1){let te=new Map;for(let W of ee){let ne=te.get(W.b);ne?ne.coef===W.coef&&(ne.share===W.share?ne.strict++:ne.loose++):te.set(W.b,{coef:W.coef,share:W.share,strict:0,loose:0})}for(let[W,ne]of te)k.has(W)||!(ne.strict||ne.loose)||(k.add(W),ne.strict?d.similarTiesStrict++:d.similarTiesLoose++)}for(let te of ee)!w.has(te.b)&&!v.has(te.s)&&V(te.b,te.s)}function Q(U,Y){return O(U)!==O(Y)?!1:O(U)?U.tagName!==Y.tagName||!Fe(U,Y)?!1:le(U)||r(U).hint===""||r(Y).hint===""?!0:i(U,Y):U.kind===Y.kind}function B(U,Y){let pe=(me,ee)=>{let te=ee===null?-1:me===Y?q.get(ee):J.get(ee),W=me[te+1];return W&&!O(W)?W:null},ke=null;for(let me of U){if(O(me)){ke=me;continue}if(w.has(me))continue;let ee=ke===null?null:w.get(ke);if(ke!==null&&!ee)continue;let te=pe(Y,ee);te&&!v.has(te)&&te.kind===me.kind&&V(me,te)}}function he(U,Y){B(U,Y);let pe=ye(U,Y),ke=(ee,te)=>O(ee)&&r(ee).hint!==""&&r(te).hint===""&&!!te.querySelector("br")&&!pe(ee,te),me=0;for(let ee of U){if(w.has(ee)){let W=q.get(w.get(ee));W!==void 0&&W>=me&&(me=W+1);continue}let te=0;for(let W=me;W<Y.length&&te<Cu;W++){let ne=Y[W];if(!v.has(ne)&&(te++,Q(ee,ne)&&!X(ee,ne)&&!ke(ee,ne))){V(ee,ne),O(ee)&&(r(ee).hint===""||r(ne).hint==="")&&E.add(ee),me=W+1;break}}}ie(U,Y)}function ye(U,Y){let pe=(ke,me,ee)=>{for(let te=me-1;te>=0;te--)if(O(ke[te])&&ee(ke[te]))return ke[te];return null};return(ke,me)=>{let ee=J.get(ke),te=q.get(me);if(ee===te)return!0;let W=pe(U,ee,we=>w.has(we)),ne=pe(Y,te,we=>v.has(we));return W?w.get(W)===ne:!ne}}function ie(U,Y){let pe=U.filter(W=>O(W)&&!w.has(W)),ke=Y.filter(W=>O(W)&&!v.has(W));if(!pe.length||!ke.length)return;let me=Pr(pe,W=>W.tagName),ee=Pr(ke,W=>W.tagName),te=ye(U,Y);for(let W of pe){let ne=W.tagName;if(me.get(ne)!==1||ee.get(ne)!==1)continue;let we=ke.find(Ie=>Ie.tagName===ne);we&&!v.has(we)&&te(W,we)&&Fe(W,we)&&!X(W,we)&&(c(W,we)?Yt(W,we):(V(W,we),E.add(W)))}}function _e(){let U=new Map;for(let W of E)if(O(W)&&O(w.get(W))){let ne=r(W).hash;U.has(ne)||U.set(ne,[]),U.get(ne).push(W)}if(U.size)for(let W of D){if(v.has(W)||!O(W)||Ne(W))continue;let ne=U.get(r(W).hash),we=ne&&ne.find(Ie=>E.has(Ie)&&!X(Ie,W)&&Fe(Ie,W)&&et(Ie,W)&&c(Ie,W)&&Qt(Ie,W));we&&(ze(we),Yt(we,W),Ae(we,W),_.add(we))}let Y=new Map,pe=new Map,ke=new Map;for(let W of E){let ne=w.get(W);O(W)&&O(ne)&&ke.set(ne,W)}let me=(W,ne)=>{if(!v.has(W))return!Ne(W);let we=ke.get(W);return we===v.get(W)&&we!==ne&&!we.contains(ne)},ee=W=>{if(v.has(W)){let ne=ke.get(W);ke.delete(W),ze(ne)}};for(let W of[...D,...ke.keys()]){if(v.has(W)&&!ke.has(W))continue;let ne=r(W).hash;if(Y.has(ne)||Y.set(ne,[]),Y.get(ne).push(W),le(W))continue;let we=r(W).sig;pe.has(we)||pe.set(we,[]),pe.get(we).push(W)}let te=new Set;for(let W of E){let ne=w.get(W);!O(W)||!O(ne)||le(W)||r(W).hint===""||r(ne).hint===""||i(W,ne)||te.add(W)}for(let W of[...R,...te]){let ne=w.get(W);if(ne?!(E.has(W)&&te.has(W)):Ue(W))continue;let we=nt=>{ne&&ze(W),ee(nt)},Ie=Y.get(r(W).hash);if(Ie){let nt=Ie.find(st=>st!==ne&&me(st,W)&&!X(W,st)&&et(W,st)&&c(W,st)&&Qt(W,st));if(nt){we(nt),Yt(W,nt),Ae(W,nt),_.add(W);continue}}if(le(W)||T<=0)continue;let je=pe.get(r(W).sig);if(!je)continue;let Se=null,Je=0;for(let nt of je)if(!(nt===ne||!me(nt,W)||!Fe(W,nt)||!et(W,nt)||X(W,nt))&&(T--<=0||i(W,nt)&&(Je++,Se=nt,Je>1)))break;Je>1&&A&&A.add(W),Je===1&&(we(Se),V(W,Se),Ae(W,Se),_.add(W),S.push([W,Se]))}}}function Pr(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},Kl=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,Ru=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,Iu=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,Lu=/\P{M}\p{M}*/gu;function Pu(e){if(e==="")return[];if(Kl){let n=[];for(let r of Kl.segment(e))n.push(r.segment);return n}let t=[];for(let n of e.match(Iu))if(Ru.test(n))for(let r of n.match(Lu))t.push(r);else t.push(n);return t}var ju=/^[ ]+$/,Du=e=>ju.test(e)?" ".repeat(e.length):e,cr=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),Ot="",di=e=>e.every(t=>cr(t)||t.k===Ot),Bu=/^[\x00-\x7f\u00A0]*$/,Fu=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function qu(e){return e===""?[]:e.match(Fu)}function pn(e,t=!1){return(t?qu(e):Pu(e)).map(n=>({k:Du(n),raw:n,len:n.length}))}var Nn=(...e)=>e.every(t=>Bu.test(t));function hi(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=[],c=r===0&&o===0;for(let p=0;p<=s&&!c;p++){a.push(l.slice(i-p,i+p+1));for(let m=-p;m<=p;m+=2){let y;m===-p||m!==p&&l[i+m-1]<l[i+m+1]?y=l[i+m+1]:y=l[i+m-1]+1;let g=y-m,d=y;for(;y<r&&g<o&&e[y].k===t[g].k;)y++,g++;if(Mu.diff+=1+y-d,l[i+m]=y,y>=r&&g>=o){c=!0;break}}}if(!c)return null;let h=[],u=r,f=o;for(let p=a.length-1;p>0;p--){let m=a[p],y=u-f,g=y+p,d=y===-p||y!==p&&m[g-1]<m[g+1]?y+1:y-1,k=m[d+p],A=k-d;for(;u>k&&f>A;)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 Uu(e,t,n){let r=u=>u.k===Ot;if(!e.some(r)&&!t.some(r))return hi(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 i=hi(o.map(u=>e[u]),s.map(u=>t[u]),n);if(!i)return null;let l=[],a=0,c=0,h=(u,f)=>{for(;a<u&&c<f&&e[a].k===t[c].k;)l.push([0,a++,c++]);let p=hi(e.slice(a,u),t.slice(c,f),n);if(!p)return!1;for(let[m,y,g]of p)l.push([m,y+a,g+c]);return a=u,c=f,!0};for(let[u,f,p]of i)if(u===0){if(!h(o[f],s[p]))return null;l.push([0,a,c]),a++,c++}return h(e.length,t.length)?l:null}function Zn(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=Ku(i,l)?null:Uu(i,l,n);if(!a){let d=i.length||l.length?[{bs:o,be:o+i.length,toks:l}]:[];return{hunks:d,cosmetic:r,coarse:!0,parts:d.map(k=>({...k,gap:[],group:0})),cosmeticEq:r}}let c=[],h=(d,k)=>{i[d].raw!==l[k].raw&&r.push({bi:o+d,tok:l[k]})},u=null,f=[],p=0,m=0,y=()=>{u&&c.push(u),u=null;for(let[d,k]of f)h(d,k);f=[],p++};for(let[d,k,A]of a){if(d===0){u&&cr(i[k])&&!i[k].k.includes(`
|
|
2
|
-
`)?f.push([
|
|
3
|
-
`))return!1;let E=q=>n.slice(w,v).map((V,Ce)=>q.raw.get(w+Ce)||V),N=[...k.toks,...E(m)],_=[...E(g),...A.toks],M=(q,V,Ce)=>V>=0&&V+Ce.length<=q.length&&Ce.every((Me,Be)=>q[V+Be].k===Me.k),j=(q,V,Ce)=>di(q)&&n.slice(V,Ce).some(Me=>!cr(Me)),R=q=>q.some(V=>!cr(V)),D,F,S,T;if(l(k)&&R(k.toks)&&M(_,0,k.toks)){let q=_.slice(k.toks.length);j(q,w,A.be)||(D=w,F=k.toks,S=_.slice(0,k.toks.length),T=[null,{bs:w,be:A.be,toks:q}])}if(D===void 0&&l(A)&&R(A.toks)){let q=N.length-A.toks.length,V=N.slice(0,q);M(N,q,A.toks)&&!j(V,k.bs,v)&&(D=v,F=N.slice(q),S=A.toks,T=[{bs:k.bs,be:v,toks:V},null])}if(D===void 0)return!1;let J=q=>q&&(q.bs<q.be||q.toks.length);return m.list.splice(y,1,...[T[0],{bs:D,be:D,toks:F}].filter(J)),g.list.splice(d,1,...[{bs:D,be:D,toks:S},T[1]].filter(J)),!0},f=i[0],p=i[1];for(let m=0;m<64;m++){let y=!1;e:for(let g=0;g<f.list.length;g++)for(let d=0;d<p.list.length;d++){let k=f.list[g],A=p.list[d];if(!(k.bs===A.bs&&k.be===A.be&&ki(k.toks,A.toks))){for(let w of[!0,!1]){let v=N=>w?N.be:N.bs,E=l(k)?[v(A),k.bs]:[v(k)];for(let N of E){let _=a(f,g,N,v),M=_&&a(p,d,N,v);if(!M)continue;let j=(T,J)=>w?T[T.length-1-J]:T[J],R=0;for(;R<_.length&&R<M.length&&j(_,R).k===j(M,R).k;)R++;if(!R)continue;let D=w?_.slice(0,_.length-R):_.slice(R),F=w?M.slice(0,M.length-R):M.slice(R);if(!(R<_.length&&R<M.length&&!di(D)&&!di(F)&&(l(k)&&l(A)||k.bs===A.bs&&k.be===A.be)||!(w?_.slice(_.length-R):_.slice(0,R)).some(T=>!cr(T)))){if(R===_.length&&R===M.length&&l(k)&&l(A)){if(k.bs===N&&A.bs===N)continue;f.list[g]={bs:N,be:N,toks:_},p.list[d]={bs:N,be:N,toks:M}}else!l(k)&&k.bs===A.bs&&k.be===A.be?(h(f,g,_,R,w),h(p,d,M,R,w)):(c(f,g,_,R,w,N),c(p,d,M,R,w,N));y=!0;break e}}}if(u(f,g,p,d)||u(p,d,f,g)){y=!0;break e}}}if(!y)break}return[f.list,p.list]}var Vu=48,Wu=.3;function Ku(e,t){let n=e.filter(i=>!cr(i)),r=t.filter(i=>!cr(i));if(Math.min(n.length,r.length)<Vu)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)<Wu}var Gu=(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},ki=(e,t)=>e.length===t.length&&e.every((n,r)=>n.k===t[r].k);function Gl(e,t,n,r="remote"){let o=Zn(e,t),s=Zn(e,n),{lh:i,rh:l,cosL:a,cosR:c}=bi(o,s,e),h=O=>O.bs===O.be,u=O=>O.toks.some(X=>typeof X.k=="string"),f=O=>h(O)&&!u(O),p=(O,X)=>X.bs<O.be&&O.bs<X.be,m=(O,X)=>!p(O,X)&&X.bs<=O.be&&O.bs<=X.be&&(h(O)&&u(O)||h(X)&&u(X))&&!(h(O)&&h(X)),y=(O,X)=>O.bs===X.bs&&O.be===X.be&&ki(O.toks,X.toks),g=[],d=new Set;for(let O of i){let X=l.find(le=>!d.has(le)&&y(O,le));X?(d.add(X),g.push({bs:O.bs,be:O.be,side:"both",l:O,r:X,toks:O.toks})):g.push({bs:O.bs,be:O.be,side:"L",l:O,toks:O.toks,lead:!!O.lead})}for(let O of l)d.has(O)||g.push({bs:O.bs,be:O.be,side:"R",r:O,toks:O.toks,lead:!!O.lead});g.sort((O,X)=>O.bs-X.bs||O.be-X.be||X.lead-O.lead);let k=0,A=0;for(let O of g)O.side==="both"&&(k+=O.toks.length-(O.be-O.bs));let w=g.map((O,X)=>X),v=O=>w[O]===O?O:w[O]=v(w[O]),E=(O,X)=>(O=v(O),X=v(X),O===X?!1:(w[O]=X,!0)),N=g.map(O=>Gu({bs:O.bs,be:O.be,toks:O.toks},e)),_={L:new Map,R:new Map};g.forEach((O,X)=>{let le=O.side==="both"?["L","R"]:[O.side];for(let re of le)for(let Pe of N[X])_[re].has(Pe)||_[re].set(Pe,[]),_[re].get(Pe).push(X)});for(let O of[_.L,_.R])for(let X of O.values())for(let le=1;le<X.length;le++)E(X[0],X[le]);for(let O=0;O<g.length;O++)for(let X=O+1;X<g.length;X++){let le=g[O],re=g[X];le.side===re.side&&le.side!=="both"||le.bs>re.be||(p(le,re)||m(le,re)?E(O,X):le.bs===re.bs&&h(le)&&h(re)&&A++)}let M=(O,X)=>{let le=O==="L"?i:l;for(let re of le)if(re.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===X.el))return re.bs;for(let re=0;re<e.length;re++)if(e[re].kind==="close"&&e[re].k.el===X.el)return re;return-1};g.forEach((O,X)=>{if(!(!f(O)||O.side==="both"))for(let le of O.toks){if(le.kind!=="open")continue;let re=M(O.side,le.k);if(re<=O.bs)continue;let Pe=new Uint8Array(re-O.bs),Fe=[];if(g.forEach((Te,ot)=>{if(!(Te.side===O.side||h(Te))&&Te.bs<re&&Te.be>O.bs){Fe.push(ot);for(let et=Math.max(Te.bs,O.bs);et<Math.min(Te.be,re);et++)Pe[et-O.bs]=1}}),Fe.length&&Pe.every(Te=>Te===1))for(let Te of Fe)E(X,Te)}});let j=!0;for(;j;){j=!1;let O=new Map;g.forEach((X,le)=>{let re=v(le),Pe=O.get(re)||{bs:X.bs,be:X.be,L:!1,R:!1};Pe.bs=Math.min(Pe.bs,X.bs),Pe.be=Math.max(Pe.be,X.be),X.side!=="R"&&(Pe.L=!0),X.side!=="L"&&(Pe.R=!0),O.set(re,Pe)}),g.forEach((X,le)=>{for(let[re,Pe]of O){if(v(le)===v(re)||!(Pe.L&&Pe.R))continue;let Fe=X.bs<Pe.be&&X.be>Pe.bs,Te=h(X)&&u(X)&&(X.bs===Pe.be||X.bs===Pe.bs);(Fe||Te)&&E(le,re)&&(j=!0)}})}let R=new Map;g.forEach((O,X)=>{let le=v(X);R.has(le)||R.set(le,[]),R.get(le).push(O)});let D=[];for(let O of R.values()){let X=O.some(re=>re.side==="L"),le=O.some(re=>re.side==="R");if(X&&le){let re=Math.min(...O.map(ot=>ot.bs)),Pe=Math.max(...O.map(ot=>ot.be)),Fe=O.filter(ot=>ot.side!=="R").map(ot=>ot.l).sort((ot,et)=>ot.bs-et.bs),Te=O.filter(ot=>ot.side!=="L").map(ot=>ot.r).sort((ot,et)=>ot.bs-et.bs);D.push({bs:re,be:Pe,kind:"conflict",localHunks:Fe,remoteHunks:Te})}else for(let re of O)D.push({bs:re.bs,be:re.be,kind:re.side,u:re})}let F=(O,X)=>{let le=O==="L"?i:l;for(let re of le)if(re.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===X.el))return re.bs+.5;for(let re=0;re<e.length;re++)if(e[re].kind==="close"&&e[re].k.el===X.el)return re;return 1/0},S=(O,X)=>{let le=O==="L"?i:l;for(let re of le)if(re.toks.some(Pe=>Pe.kind==="open"&&Pe.k.el===X.el))return re.bs-.5;for(let re=0;re<e.length;re++)if(e[re].kind==="open"&&e[re].k.el===X.el)return re;return-1/0},T=O=>O.kind==="R"?"R":"L",J=O=>O.kind==="R"?1:0;D.sort((O,X)=>{if(O.bs!==X.bs)return O.bs-X.bs;let le=O.bs===O.be,re=X.bs===X.be;if(le!==re)return le?-1:1;if(le&&re&&O.kind!=="conflict"&&X.kind!=="conflict"){let Fe=O.u.toks,Te=X.u.toks,ot=ae=>ae.length&&ae.every(de=>de.kind==="open"),et=ae=>ae.length&&ae.every(de=>de.kind==="close");if(ot(Fe)&&ot(Te)){let ae=Math.max(...Fe.map(Ee=>F(T(O),Ee.k))),de=Math.max(...Te.map(Ee=>F(T(X),Ee.k)));if(ae!==de)return de-ae}if(et(Fe)&&et(Te)){let ae=Math.min(...Fe.map(Ee=>S(T(O),Ee.k))),de=Math.min(...Te.map(Ee=>S(T(X),Ee.k)));return ae!==de?de-ae:J(X)-J(O)}}let Pe=Fe=>Fe.u&&Fe.u.lead?1:0;return Pe(X)-Pe(O)||J(O)-J(X)||O.be-X.be});let q=[],V=[],Ce=0,Me=O=>{O>Ce&&(q.push({bs:Ce,be:O,toks:e.slice(Ce,O),source:"base"}),Ce=O)};for(let O of D){if(Me(O.bs),O.kind==="conflict"){let X=gi(e,O.localHunks,O.bs,O.be),le=gi(e,O.remoteHunks,O.bs,O.be),re=r==="local"?X:r==="both"?X.concat(le):le,Pe=(ot,et)=>{let ae=0;for(let de of ot)de.be<=O.bs&&!et.includes(de)&&(ae+=de.toks.length-(de.be-de.bs));return ae},Fe=O.bs+Pe(i,O.localHunks),Te=O.bs+Pe(l,O.remoteHunks);V.push({bs:O.bs,be:O.be,ls:Fe,le:Fe+X.length,rs:Te,re:Te+le.length,ms:0,me:0,base:e.slice(O.bs,O.be),local:X,remote:le,resolved:re}),q.push({bs:O.bs,be:O.be,toks:re,source:"conflict",localHunks:O.localHunks,localToks:X,keepsLocal:r!=="remote"})}else q.push({bs:O.bs,be:O.be,toks:O.u.toks,source:O.kind==="R"?"remote":"local",localHunks:O.kind==="R"?[]:[O.u.l]});Ce=Math.max(Ce,O.be)}Me(e.length);let Be=0,ce=0;for(let O of q)O.source==="conflict"&&(V[ce].ms=Be,V[ce].me=Be+O.toks.length,ce++),Be+=O.toks.length;let Ae=new Map(a.map(O=>[O.bi,O.tok])),Ue=new Map(c.map(O=>[O.bi,O.tok])),Ne=[];for(let O of q){O.source==="base"&&(O.toks=O.toks.map((X,le)=>{let re=O.bs+le,Pe=Ae.get(re),Fe=Ue.get(re),Te=Pe&&Fe?r==="remote"?Fe:Pe:Pe||Fe||X;return Te===X?X:{...Te,cosmetic:!0}}));for(let X of O.toks)Ne.push({...X,src:O.source})}return{tokens:Ne,segments:q,conflicts:V,localHunks:i,remoteHunks:l,collapsedDelta:k,samePoint:A,mapLocalOffset:Yu(e,i,q)}}function gi(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 mi=e=>e.reduce((t,n)=>t+n.len,0);function Yu(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:mi(i.toks),source:i.source,localHunks:i.localHunks||[],localLen:i.localToks?mi(i.localToks):0,keepsLocal:i.keepsLocal,ref:i}));return i=>{let l=null,a=null,c=0,h=0,u=0;for(let p of o){let m=p.bs-u;if(i<=h+m){l=u+(i-h);break}if(h+=m,u=p.bs,i<=h+p.text.length){a=p,c=i-h,l=p.bs;break}h+=p.text.length,u=p.be}l===null&&(l=u+(i-h));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(c,p.len);if(!p.keepsLocal||!a)return f+p.len;let y=p.localHunks.indexOf(a.ref),g=mi(gi(e,p.localHunks.slice(0,y),p.ref.bs,a.ref.bs));return f+Math.min(g+c,p.localLen)}return f}}function ko(e,t,n,r="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:d=>Math.min(d,t.length),granularity:"word"};let o=Nn(e,t,n),s=pn(e,o),i=pn(t,o),l=pn(n,o),a=s.length<=2e4&&i.length<=2e4&&l.length<=2e4?Gl(s,i,l,r):null,c="word",h=s;if(!a){let d=k=>k.split(/(?<=\n)/).map(A=>({k:A,raw:A,len:A.length}));h=d(e),a=Gl(h,d(t),d(n),r),c="line"}let u=d=>d.map(k=>k.raw).join(""),f=d=>{let k=[0];for(let A of d)k.push(k[k.length-1]+A.len);return k},p=f(h),m=null,y=null,g=null;if(a.conflicts.length){let d=k=>k.split(/(?<=\n)/).map(A=>({k:A,raw:A,len:A.length}));m=f(c==="line"?d(t):i),y=f(c==="line"?d(n):l),g=f(a.tokens)}return{text:u(a.tokens),conflicts:a.conflicts.map(d=>({bs:p[d.bs],be:p[d.be],ls:m[d.ls],le:m[d.le],rs:y[d.rs],re:y[d.re],ms:g[d.ms],me:g[d.me],base:u(d.base),local:u(d.local),remote:u(d.remote),resolved:u(d.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:c}}function vr(e,t,n=4e3){if(e===t)return[];let r=Nn(e,t),o=pn(e,r),s=pn(t,r),i=Zn(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(c=>c.raw).join("")}))}function Zt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Gn({base:e,side:t,retained:n,transfers:r,baseAtomKey:o=l=>l.el,sideAtomKey:s=l=>l.el,budget:i=Zt()}){let l=[],a=v=>({status:"fallback",reason:v}),c=v=>v>i.remaining?!1:(i.remaining-=v,!0);if(!c((n.length+r.length)*3))return a("work-limit");for(let[v,E]of[["retained",n],["transfer",r]])for(let N of E){let{from:_,to:M,target:j}=N;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");l.push({...N,kind:v})}let h=Symbol(),u=v=>(E,N)=>{if(!c(1))throw h;return i.sortComparisons++,v(E,N)},f,p;try{f=l.slice().sort(u((v,E)=>v.from-E.from||v.to-E.to)),p=l.slice().sort(u((v,E)=>v.target-E.target||v.to-v.from-(E.to-E.from)))}catch(v){if(v===h)return a("work-limit");throw v}if(!c(l.length*2))return a("work-limit");for(let v=1;v<f.length;v++)if(f[v].from<f[v-1].to)return a("source-overlap");for(let v=1;v<p.length;v++)if(p[v].target<p[v-1].target+p[v-1].to-p[v-1].from)return a("target-overlap");for(let v of f){let E=v.to-v.from;if(!c(E))return a("work-limit");for(let N=0;N<E;N++){let _=v.from+N,M=v.target+N;if(i.comparisons++,e.text[_]!==t.text[M])return a("unequal-occurrence");let j=e.atomAt.get(_),R=t.atomAt.get(M);if(!!j!=!!R||j&&o(j)!==s(R))return a("different-atom")}}let m=e.text.length+t.text.length+2,y=l.reduce((v,E)=>v+(E.to-E.from)*2,2);if(!c(m+y+l.length))return a("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),d=new Int32Array(t.text.length+1).fill(-1);i.mapCells+=m,i.mapWrites+=y;let k=-1,A=!0;for(let v of f){v.target<k&&(A=!1),k=v.target+v.to-v.from;for(let E=0;E<v.to-v.from;E++)g[v.from+E]=v.target+E,d[v.target+E]=v.from+E}return g[e.text.length]=t.text.length,d[t.text.length]=e.text.length,{status:"ready",runs:f,bTo:g,toB:d,monotone:A,covers:(v,E)=>{if(!c(E-v))return null;i.coverageChecks+=E-v;for(let N=v;N<E;N++)if(e.text[N]!==Ot&&!/\s/.test(e.text[N])&&g[N]<0)return!1;return!0}}}function yi({base:e,side:t,baseOf:n=()=>null,budget:r=Zt()}){if(e.text===t.text||!e.text.includes(Ot)&&!t.text.includes(Ot))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=(m,y)=>y<m.length&&(m[y]===Ot||/\s/.test(m[y])),i=new Map,l=Symbol(),a=(m,y)=>{let g=m.stackAt[y]||[];if(!i.has(g)){if(g.length>r.remaining)throw l;r.remaining-=g.length,r.boundarySteps+=g.length,i.set(g,g.find(d=>d.block)?.el||null)}return i.get(g)},c=[],h=(m,y)=>{let g=a(e,m),d=a(t,y),k=g&&d&&n(d)!==g?"transfer":"retained",A=c[c.length-1];A&&A.to===m&&A.target+A.to-A.from===y&&A.kind===k&&A.destination===d?A.to++:c.push({from:m,to:m+1,target:y,destination:d,kind:k})},u=0,f=0,p=!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 A=e.atomAt.get(u),w=t.atomAt.get(f);if(!!A!=!!w||A&&n(w.el)!==A.el)return{status:"none"};h(u++,f++);continue}if(!s(e.text,u)&&!s(t.text,f))return{status:"none"};let m=u,y=f;for(;s(e.text,u);)u++;for(;s(t.text,f);)f++;let g=e.text.slice(m,u),d=t.text.slice(y,f);(g.includes(Ot)||d.includes(Ot))&&(p=!0);let k=0;for(;k<u-m&&k<f-y&&e.text[u-k-1]===t.text[f-k-1];)k++;for(let A=k;A>0;A--)h(u-A,f-A)}}catch(m){if(m===l)return{status:"fallback",reason:"work-limit"};throw m}return p?Gn({base:e,side:t,retained:c.filter(m=>m.kind==="retained"),transfers:c.filter(m=>m.kind==="transfer"),sideAtomKey:m=>n(m.el)||m.el,budget:r}):{status:"none"}}var Yl=/\s/,es=/\S/;function Bn(e,t,n,r,o,s,i=-1,l=-1){if(!e.length)return-1;o(r,e.length);let a=new Int32Array(e.length),c=0;for(let p=1;p<e.length;p++){for(o(r,1);c&&(o(r,1),e[c]!==e[p]);)c=a[c-1];o(r,1),e[c]===e[p]&&c++,a[p]=c}let h=-1,u=0,f=0;c=0;for(let p=0;p<t.length;p++){for(o(r,1);c&&(o(r,1),e[c]!==t[p]);)c=a[c-1];if(o(r,1),e[c]===t[p]&&c++,c!==e.length)continue;let m=p+1-e.length,y=p+1;for(c=a[c-1];u<n.length&&n[u].from<m;)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!==m||n[f].to!==y||i>=0&&m<l&&y>i)){if(!s)return m;if(h>=0)return-1;h=m}}return h}function yo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function xi(e,t,n,r){let o=null;for(let i of t)if(r(n,1),!(i.source!==e.source||i.side!==e.side))for(let l of i.runs){if(r(n,1),l.source!==e.source)continue;let a=Math.max(e.from,l.from),c=Math.min(e.to,l.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 i=e.from;i<e.to;i++)if(es.test(e.flat.text[i])){if(!o[i-e.from])return!1;s=!0}return s}function vi({source:e,side:t,views:n,eligible:r,blocked:o,baseId:s,model:i,tokensOf:l,budget:a,charge:c}){let{V:h,A:u,idOf:f}=n[t],p=n[1-t];if(e.nodeType!==1||u.identical.has(e)||p.A.identical.has(e)||o.has(e)||!r(e))return null;let m=h.twin(e),y=p.V.twin(e);if(!m||!y||u.map.get(e)!==m||u.reverse.get(m)!==e||p.A.map.get(e)!==y||p.A.reverse.get(y)!==e||!h.here(m)||!p.V.here(y)||!r(m)||!r(y))return null;let g=s(e);if(g!==f(m)||g!==p.idOf(y))return null;let d=i(e,null,a),k=i(m,u,a),A=i(y,p.A,a);if(!yo(d)||!yo(k)||!yo(A))return null;let w=d.flat.text,v=k.flat.text;if(c(a,w.length+v.length*3),!es.test(v)||v.length>=w.length)return null;let E=w.startsWith(v),N=w.endsWith(v);if(E===N)return null;let _=E?v.length:0,M=E?w.length:w.length-v.length,j=_,R=M;for(;j<R&&(c(a,1),!!Yl.test(w[j]));)j++;for(;R>j&&(c(a,1),!!Yl.test(w[R-1]));)R--;if(j===R)return null;let D=l(d,a),F=!1,S=!1;for(let T of D)c(a,1),T.from===j&&(F=!0),T.to===R&&(S=!0);return!F||!S?null:{source:e,side:t,flat:d.flat,from:_,to:M}}function Xl({base:e,views:t,side:n,attempt:r,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,certificates:c,charge:h,exhausted:u,limit:f}){if(f<=0)return null;let p=Zt(f),{V:m,A:y,idOf:g}=t[n],d=t[1-n],[k,A,w,v]=r,E=null;try{for(let N=k;N<=A;N++){h(p,1);let _=e[N];if(_.nodeType!==1||y.identical.has(_)||d.A.identical.has(_)||s.has(_)||!o(_))continue;let M=vi({source:_,side:n,views:t,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,budget:p,charge:h});if(!M||xi(M,c,p,h))continue;let{flat:j,from:R,to:D}=M;h(p,(D-R)*2);let F=j.text.slice(R,D).trim();for(let S=w;S<=v;S++){h(p,1);let T=m.units[S],J=m.baseOf(T);if(!J||J===_||J.nodeType!==1||T.nodeType!==1||J.parentNode!==_.parentNode||T.parentNode!==y.map.get(_).parentNode||y.map.get(J)!==T||y.reverse.get(T)!==J||s.has(J)||!o(J)||!o(T)||i(J)!==g(T))continue;let q=l(J,null,p),V=l(T,y,p);if(!yo(q)||!yo(V))continue;let Ce=q.flat.text,Me=V.flat.text;if(h(p,Ce.length),!es.test(Ce)||Me.length<=Ce.length)continue;let Be=a(V,p),ce=Bn(Ce,Me,Be,p,h,!0);if(!(ce<0)&&!(Bn(F,Me,Be,p,h,!1,ce,ce+Ce.length)<0)){(E||=[]).push(M);break}}}}catch(N){if(N!==u)throw N}return E}function Jl(e,t,n,r,o,s,i){if(s==="both"||n.atoms.length||r.atoms.length||o.atoms.length)return s;let l=s==="remote";if(l?i.rss!==i.rse||i.lss===i.lse||i.local===i.base:i.lss!==i.lse||i.rss===i.rse||i.remote===i.base)return s;for(let a of e){if(a.source!==t||a.side!==(l?1:0)||a.flat.text!==n.text||a.flat.nodes.length!==n.nodes.length||i.be<=a.from||i.bs>=a.to)continue;let c=!0;for(let u=0;u<n.nodes.length;u++){let f=a.flat.nodes[u],p=n.nodes[u];if(f.node!==p.node||f.s!==p.s||f.e!==p.e){c=!1;break}}if(!c)continue;let h=!1;for(let u=i.bs;u<i.be;u++)if(es.test(n.text[u])){if(u<a.from||u>=a.to){c=!1;break}h=!0}if(c&&h)return l?"local":"remote"}return s}var Yn="\uFFFC";var Xu={caret:0},Cn=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(" ")),sa=new Set(["BR","WBR","IMG"]),wi=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 Xn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||sa.has(e.tagName))return!0;if(!Cn.has(e.tagName))return!wi.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(!Xn(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 an(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 u=i.nodeValue;if(!u)continue;n.nodes.push({node:i,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(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]!==Ot&&(n.stackAt.push(s),n.text+=Ot);let u={el:i,tag:a,from:n.text.length,to:-1,depth:s.length,block:!0};n.marks.push(u);let f=s.concat([u]);r(l.childNodes,f),n.stackAt.push(f),n.text+=Ot,u.to=n.text.length;continue}let c=Cn.has(a)&&Ju(l);if(sa.has(a)||!Cn.has(a)||t.remoteWins&&t.remoteWins(i)||t.atomize&&t.atomize(i)||c){n.atoms.push({i:n.text.length,el:i,key:c?a+":empty":a,stack:s}),n.stackAt.push(s),n.text+=Yn;continue}let h={el:i,tag:a,from:n.text.length,to:-1,depth:s.length};n.marks.push(h),r(l.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&&rs(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 Zu(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function Qu(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,""")}"`;return t+">"}function Dr(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 c=i[o.length];r+=Qu(c.el),o.push(c)}let a=e.atomAt.get(s);r+=a?a.el.outerHTML:e.text[s]===Ot?"":Zu(e.text[s])}for(;o.length;)r+=`</${o.pop().tag.toLowerCase()}>`;return r}function ed(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 ia(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 Zl(e,t=()=>!1){let n=new Map,r=s=>{let i=n.get(s);return i===void 0&&(i="{"+s.map(l=>ed(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?"["+ia(i.el,t)+"]":e.text[s])+r(e.stackAt[s])}return e.text.length===0&&e.placeholder&&(o+="[br]"),o}function jr(e,t,n,r=o=>o.key){let o=[],s=e.text,i=0,l=a=>{if(a<=i)return;let c=s.slice(i,a);if(n)for(let h of c.split(/(?<=\n)/))o.push({k:h,raw:h,len:h.length});else for(let h of pn(c,t))o.push(h)};for(let a of e.atoms)l(a.i),o.push({k:"\0"+r(a),raw:Yn,len:1,atom:!0}),i=a.i+1;return l(s.length),o}function rs(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 Br=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 ts(e,t,n,r){let o=Br(t),s=Br(n),i=[],l=0,a=0;for(let h of r.hunks){a+=h.bs-l;let u=a+h.toks.length;i.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,l=h.be}let c=new Map;for(let h of r.cosmetic)c.set(h.bi,h.tok.raw);return{hunks:i,respell:c}}function Ql(e,t,n){let r=i=>i===Ot||/\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(Ot)&&!a.includes(Ot)||l.includes(Yn)||a.includes(Yn)||o(l)!==o(a)){s.push(i);continue}let c=0,h=0;for(;;){let u=c,f=h;for(;u<l.length&&r(l[u]);)u++;for(;f<a.length&&r(a[f]);)f++;let p=c,m=h;for(;p<u&&m<f&&l[p]===a[m];)p++,m++;let y=u,g=f;for(;y>p&&g>m&&l[y-1]===a[g-1];)y--,g--;if(y>p||g>m){let d=a.slice(m,g);s.push({bs:i.bs+p,be:i.bs+y,ss:i.ss+m,se:i.ss+g,text:d,toks:[...d].map(k=>({k,raw:k,len:1})),lead:i.lead})}if(u>=l.length)break;c=u+1,h=f+1}}return s}function ea(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 ta(e,t,n){let r=[],o=0,s=0,i=(l,a)=>{if(o===l&&s===a)return;let c=t.text.slice(s,a);r.push({bs:o,be:l,ss:s,se:a,text:c,toks:pn(c,Nn(c)),lead:!1})};for(let l of n.runs)i(l.from,l.target),o=l.to,s=l.target+l.to-l.from;return i(e.text.length,t.text.length),{hunks:r,respell:new Map}}function na(e,t,n,r){let o=Br(t),s=Br(n),i=(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(i(o,a.bs)<0||i(o,a.be)<0)return null;if(e.hunks.some(a=>i(s,a.ss)<0||i(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 p=u+f.len;for(;h<a.length&&a[h]<=u;)h++;let m=u;for(;h<a.length&&a[h]<p;){let y=a[h++];if(y>m){let g=f.raw.slice(m-u,y-u);c.push(...pn(g,Nn(g))),m=y}}if(m===u)c.push(f);else{let y=f.raw.slice(m-u);c.push(...pn(y,Nn(y)))}u=p}n=c,s=Br(n)}let l=[];for(let a of e.hunks){let c=i(o,a.bs),h=i(o,a.be),u=i(s,a.ss),f=i(s,a.se);if(c<0||h<0||u<0||f<0)return null;l.push({bs:c,be:h,toks:n.slice(u,f),gap:[],group:l.length})}return{parts:l,cosmeticEq:[],tokens:n}}function Ai(e,t,n,r={},o=null){return la(e,t,n,r.base,r.local,r.remote,o,{})}function la(e,t,n,r,o,s,i,l){let a=Nn(rs(e),rs(t),rs(n)),c=jr(e,a,!1,r),h=jr(t,a,!1,o),u=jr(n,a,!1,s),f=c.length>2e4||h.length>2e4||u.length>2e4;f&&(c=jr(e,a,!0,r),h=jr(t,a,!0,o),u=jr(n,a,!0,s));let p=i?.local?ta(e,t,i.local):null,m=i?.remote?ta(e,n,i.remote):null,y=p?na(p,c,h,!f):Zn(c,h),g=m?na(m,c,u,!f):Zn(c,u);p&&y&&(h=y.tokens),m&&g&&(u=g.tokens);let d,k;if(y&&g){let A=bi(y,g,c);d=ts(t,c,h,{hunks:A.lh,cosmetic:A.cosL}),k=ts(n,c,u,{hunks:A.rh,cosmetic:A.cosR})}else d=p||ts(t,c,h,y),k=m||ts(n,c,u,g);return d.hunks=Ql(d.hunks,e.text,t.text),k.hunks=Ql(k.hunks,e.text,n.text),l.base=e,l.local=t,l.remote=n,l.lines=f,l.baseTokens=c,l.localEdits=d,l.remoteEdits=k,l.localMap=ea(d.hunks,e.text.length,t.text.length),l.remoteMap=ea(k.hunks,e.text.length,n.text.length),l.full=null,l}function ra(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Fr=/\s/;function ns(e,t,n){for(let r=t;r<n;r++)if(!Fr.test(e[r]))return!1;return!0}function td(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",i=t.baseMark,l=t[s+"Mark"],a=!t.block&&!t[o]&&!!l&&i.to>i.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 p=i.from;p<i.to;p++){if(c.bTo[p]>=0){a=!1;break}h.bTo[p]<0&&!Fr.test(e.fb.text[p])&&(f=!0)}if(a&&!f){for(let p=l.from;p<l.to;p++)if(h.toB[p]<0&&!Fr.test(u.text[p])){f=!0;break}}a&&=f}return r.set(t,a),a}function oa(e,t,n,r,o,s,i,l,a){let c=l===0?e.fl:e.fr,h=null;for(let u=n;u<r;u++){let f=t[u];if(!ns(c.text,f.ss,f.se))return null;if(ns(e.fb.text,f.bs,f.be)){if(f.bs<f.be&&f.ss<f.se||Fr.test(e.fb.text[f.bs-1]||"")||Fr.test(e.fb.text[f.be]||""))continue;return null}let p=!1;for(let m=f.bs;m<f.be;m++){if(Fr.test(e.fb.text[m]))continue;let y=null;for(let g of e.fb.stackAt[m]){let d=e.byEl.get(g.el);if(d&&td(e,d,l)){y=d;break}}if(!y)return null;(h||(h=new Set)).add(y),p=!0}if(!p)return null}if(!h){if((l===0?"local":"remote")!==a)return null;let u=l===0?e.fr:e.fl,f=!1;for(let p=s;p<i;p++){let m=o[p];if(!ns(e.fb.text,m.bs,m.be))return null;ns(u.text,m.ss,m.se)||(f=!0)}if(!f)return null}return h||0}function os(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||[],c=l.length,h=e.conflict||(x=>l.push(x)),u={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),m={base:null,local:null,remote:null};if(!e.prepared&&p&&e.moveIn){let x=Oe=>qe=>Oe.some(Le=>Le===qe||Le.nodeType===1&&Le.contains(qe)),P=x(e.local),H=x(e.remote),z=x(e.base),Z=new Set,ge=Oe=>{if(!Cn.has(Oe.tagName))return;let qe=r.map.get(Oe),Le=o.map.get(Oe);(qe&&!P(qe)||Le&&!H(Le))&&Z.add(Oe);for(let $e of Oe.children)ge($e)};for(let Oe of e.base)Oe.nodeType===1&&ge(Oe);let ve=Oe=>qe=>{if(!Cn.has(qe.tagName))return!1;let Le=Oe.reverse.get(qe);return!!Le&&(Z.has(Le)||!z(Le))};Z.size&&(m.base=Oe=>Z.has(Oe)),m.local=ve(r),m.remote=ve(o)}let y={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&p&&e.moveIn){let x=z=>Z=>z.some(ge=>ge===Z||ge.nodeType===1&&ge.contains(Z)),P=x(e.local),H=x(e.remote);for(let z of an(e.base,{...e,atomize:m.base}).atoms){let Z=r.map.get(z.el),ge=o.map.get(z.el),ve=!!Z&&!P(Z),Oe=!!ge&&!H(ge);!ve&&!Oe||(ve&&e.movePlanned?.(z.el,"local",Z,null),Oe&&e.movePlanned?.(z.el,"remote",ge,null),y.base.add(z.el),Z&&!ve&&y.local.add(Z),ge&&!Oe&&y.remote.add(ge),P(z.el)&&y.local.add(z.el),H(z.el)&&y.remote.add(z.el))}}let g=e.prepared?.base||an(e.base,{...e,atomize:m.base,skip:y.base}),d=e.prepared?.local||an(e.local,{...e,atomize:m.local,skip:y.local}),k=e.prepared?.remote||an(e.remote,{...e,atomize:m.remote,skip:y.remote}),A=new Map(g.atoms.map(x=>[x.el,x])),w={},v=x=>e.prepared?e.prepared.full?.(x)||null:y[x].size?(w[x]||(w[x]=an(e[x],{...e,atomize:m[x]})),w[x]):null,E=(x,P,H)=>{P.namespaceURI?x.setAttributeNS(P.namespaceURI,P.name,H):x.setAttribute(P.name,H)},N=(x,P,H,z)=>{if(!P&&(!H||!z)){for(let ge of(H||z).attributes)E(x,ge,ge.value);return}let Z=new Map;for(let ge of[P,H,z])if(ge)for(let ve of ge.attributes)Z.set(ve.name,ve);for(let[ge,ve]of Z){let Oe=P?P.getAttribute(ge):null,qe=H?H.getAttribute(ge):Oe,Le=z?z.getAttribute(ge):Oe,$e;qe===Le?$e=qe:qe===Oe?($e=Le,a.push({kind:"attr",el:x,name:ge,source:"remote"})):Le===Oe?($e=qe,a.push({kind:"attr",el:x,name:ge,source:"local"})):($e=n==="local"?qe:Le,h({kind:"attr",el:x,name:ge,base:Oe,local:qe,remote:Le,resolved:$e},{el:x,sample:ve}),a.push({kind:"attr",el:x,name:ge,source:"both"})),$e!=null&&E(x,ve,$e)}},_=(x,P,H,z)=>x&&e.mergeAttrs?e.mergeAttrs(x,P,H,z):N(z,x,P,H),M=e.mergeElement||((x,P,H)=>{let z=t.createElement(x.tagName);_(x,P,H,z);let Z=P||x,ge=H||x,ve=n==="local"?Z.isEqualNode(x)?ge:Z:ge.isEqualNode(x)?Z:ge;for(let Oe of ve.childNodes)z.appendChild(t.importNode(Oe,!0));return s.set(z,{base:x,local:P,remote:H}),z}),j=e.cloneUnit||((x,P)=>{let H=t.importNode(x,!0);return s.set(H,{base:null,local:P==="local"?x:null,remote:P==="remote"?x:null}),H}),R=e.atomKey||(x=>ia(x,()=>!1)),D=(x,P)=>{let H=new Map;for(let z of x.atoms)if(e.remoteWins&&e.remoteWins(z.el)&&Cn.has(z.el.tagName))H.set(z,"w"+z.el.tagName+"#"+(z.el.id||""));else if(!p)H.set(z,z.key);else if(x===g)H.set(z,"="+R(z.el));else{let Z=P.reverse.get(z.el),ge=Z?A.get(Z):null;ge?H.set(z,"="+R(ge.el)):Z?H.set(z,"m"+R(z.el)):H.set(z,"="+R(z.el))}return z=>H.get(z)},F=D(g,null),S=D(d,r),T=D(k,o),J=e.certifiedOrigins?e.certifiedOrigins(g,d,k,F,S,T):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let x=Zt(),P=yi({base:g,side:d,baseOf:z=>r?.reverse?.get(z)||null,budget:x}),H=yi({base:g,side:k,baseOf:z=>o?.reverse?.get(z)||null,budget:x});(P.status==="ready"||H.status==="ready")&&(J={local:P.status==="ready"?P:null,remote:H.status==="ready"?H:null})}let q=e.prepared||la(g,d,k,F,S,T,J,u),V=q.lines,Ce=q.baseTokens,Me=q.localEdits,Be=q.remoteEdits,ce=q.localMap,Ae=q.remoteMap,Ue=g.text.length,Ne=x=>new Map(x.atoms.map(P=>[P.el,P])),O=Ne(d),X=Ne(k),le=(x,P,H)=>{let z=new Set;if(!p)return z;for(let Z of x.atoms){let ge=A.get(P.reverse.get(Z.el));ge&&H.bTo[ge.i]<0&&z.add(ge)}return z},re=le(d,r,ce),Pe=le(k,o,Ae),Fe=x=>!Xn(x,{...e,remoteWins:null}),Te=new Set;if(p)for(let x of g.atoms){if(!Fe(x.el))continue;let P=r.map.get(x.el)||null,H=o.map.get(x.el)||null,z=P&&!H?P:H&&!P?H:null;z&&(O.has(z)||X.has(z))&&!z.isEqualNode(x.el)&&Te.add(x)}let ot=1,et=(x,P)=>({id:ot++,tag:x,base:null,local:null,remote:null,rank:P}),ae=new Map,de=[];for(let x of g.marks){let P=et(x.tag,x.depth);P.block=!!x.block,P.base=x.el,P.baseMark=x,ae.set(x.el,P),de.push(P)}let Ee=(x,P)=>{let H=-1,z=-1;for(let Z=x.from;Z<x.to;Z++){let ge=P[Z];ge>=0&&(H<0&&(H=ge),z=ge+1)}return H<0?null:[H,z]},Ge=(x,P,H,z)=>{for(let Z of x.marks){let ge=H?H.reverse.get(Z.el):null;ge&&H.identical.has(ge)&&H.pairIdenticalChildren&&H.pairIdenticalChildren(ge);let ve=ge?ae.get(ge):null;if(ve&&ve[P]&&(ve=null),!ve){let Oe=Ee(Z,z),qe=0;if(Oe)for(let Le of de){if(Le.tag!==Z.tag||Le[P]||!!Le.block!=!!Z.block)continue;let $e=Math.min(Oe[1],Le.baseMark.to)-Math.max(Oe[0],Le.baseMark.from);($e>qe||$e===qe&&$e>0&&Math.abs(Le.rank-Z.depth)<Math.abs(ve.rank-Z.depth))&&(ve=Le,qe=$e)}}ve||(ve=et(Z.tag,Z.depth),ve.block=!!Z.block,ve.new=P),ve[P]=Z.el,ve[P+"Mark"]=Z,ae.set(Z.el,ve)}};Ge(d,"local",r,ce.toB),Ge(k,"remote",o,Ae.toB);let Ve=x=>x.merged||x,ze=x=>{let P=new Set;for(let H of x)H.block||P.add(ae.get(H.el));return P},lt=new Map,pt=x=>{let P=lt.get(x);return P||(P=ze(x),lt.set(x,P)),P},Rt=(x,P)=>{let H=[],z=null;for(let Z=0;Z<Ue;Z++){let ge=P[Z];if(ge<0){z&&H.push(z),z=null;continue}let ve=pt(g.stackAt[Z]),Oe=pt(x.stackAt[ge]),qe=new Set,Le=new Set;for(let $e of Oe)ve.has($e)||qe.add($e);for(let $e of ve)Oe.has($e)||Le.add($e);if(!qe.size&&!Le.size){z&&H.push(z),z=null;continue}if(z&&ra(z.added,qe)&&ra(z.removed,Le)){z.be=Z+1;continue}z&&H.push(z),z={bs:Z,be:Z+1,added:qe,removed:Le}}return z&&H.push(z),H},dt=Rt(d,ce.bTo),vt=Rt(k,Ae.bTo),gt=x=>x.be>x.bs?[x.bs,x.be-1]:[x.bs-1,x.bs],yn=(x,P)=>{if(Ue===0)return null;let[H,z]=gt(x);for(let Z of P){if(Z.be<=H)continue;if(Z.bs>z)break;let ge=Z.bs<=H&&z<Z.be;return ge&&x.text===""&&Z.bs===x.bs&&Z.be===x.be?"straddle":ge?Z:x.be>x.bs?"straddle":null}return null},Bt=x=>x.bs===x.be,Qt=(x,P,H=null)=>{let z=!1;for(let Z=x.bs;Z<x.be;Z++){let ge=g.text[Z];if(ge===Ot)z=!0;else if(!/\s/.test(ge))return!1}for(let Z=x.ss;Z<x.se;Z++){let ge=P.text[Z];if(ge===Ot)z=!0;else if(!/\s/.test(ge)){let ve=H&&e.scopeUnits&&Bt(x)&&P.atomAt.get(Z);if(!ve||!Fe(ve.el)||H.ss!==H.se||H.bs>=H.be)return!1;for(let qe=H.bs;qe<H.be;qe++)if(!/\s/.test(g.text[qe]))return!1;let Oe=P===d?1:2;if(!e.scopeUnits[Oe].includes(ve.el)||(Oe===1?r:o)?.reverse.has(ve.el))return!1;z=!0}}return z},Yt=(x,P)=>x.bs<P.be&&P.bs<x.be,gn=(x,P)=>x.bs<=P.be&&P.bs<=x.be&&Bt(x)!==Bt(P),K=(x,P)=>g.text.slice(x.bs,x.be).includes(Ot)||P.text.slice(x.ss,x.se).includes(Ot),b=x=>{if(Bt(x))return!1;let P=x.bs,H=x.be;for(;P>0&&/\s/.test(g.text[P-1]);)P--;for(;H<g.text.length&&/\s/.test(g.text[H]);)H++;return(P===0||g.text[P-1]===Ot)&&(H===g.text.length||g.text[H]===Ot)},C=(x,P)=>!K(x,P)&&!b(x),L=(x,P)=>Yt(x,P)||gn(x,P)&&!(x.transferIn||x.transferOut||P.transferIn||P.transferOut)&&!(Qt(x,d,P)&&C(P,k))&&!(Qt(P,k,x)&&C(x,d)),$=(x,P)=>{if(x.bs!==P.bs||x.be!==P.be||x.toks.length!==P.toks.length)return!1;let H=x.ss,z=P.ss;for(let Z=0;Z<x.toks.length;Z++){let ge=x.toks[Z],ve=P.toks[Z];if(ge.k!==ve.k||ge.atom&&!d.atomAt.get(H).el.isEqualNode(k.atomAt.get(z).el))return!1;H+=ge.len,z+=ve.len}return!0},Q=(x,P,H,z)=>{for(let Z of g.atoms){if(Z.i<x.bs||Z.i>=x.be||z.has(Z)||Te.has(Z))continue;let ge=P.bTo[Z.i],ve=ge>=0?H.atomAt.get(ge):null;if(ve&&!ve.el.isEqualNode(Z.el))return!0}return!1},B=[],he=null,ye=null,ie=Me.hunks,_e=Be.hunks,U=0,Y=0,pe=0,ke=0,me=0,ee=x=>{x>pe&&(B.push({src:"base",from:pe,to:x,dL:ke,dR:me}),pe=x)};for(;U<ie.length||Y<_e.length;){let x=ie[U],P=_e[Y],H=!!x&&(!P||x.bs<P.bs||x.bs===P.bs&&x.be<=P.be&&!P.lead);if(x&&P&&x.bs===P.bs&&Bt(x)&&Bt(P)){let Gt=Qt(x,d),bo=Qt(P,k);Gt!==bo&&(H=bo)}let z=H?x:P,Z=H?P:x,ge=!!Z&&$(x,P),ve=!!Z&&(H?!!ie[U+1]&&$(ie[U+1],P):!!_e[Y+1]&&$(x,_e[Y+1])),Oe=!!Z&&!ge&&!ve&&(Ue===0||L(x,P)),qe=Oe,Le=yn(z,H?vt:dt);if(Le==="straddle"&&(qe=!0),!qe&&z.be>z.bs&&(qe=Q(z,H?Ae:ce,H?k:d,H?re:Pe)),!qe&&ge){ee(z.bs),B.push({src:"both",lfrom:x.ss,rfrom:P.ss,len:z.text.length,owner:x.owner||P.owner||null,transfer:x.transferIn||P.transferIn||null}),pe=z.be,ke+=z.text.length-(z.be-z.bs),me+=z.text.length-(z.be-z.bs),U++,Y++;continue}if(!qe){ee(z.bs),B.push({src:H?"local":"remote",from:z.ss,to:z.se,inherit:Le&&Le!=="straddle"?Le:null,owner:z.owner||null,transfer:z.transferIn||null}),pe=z.be,H?(ke+=z.text.length-(z.be-z.bs),U++):(me+=z.text.length-(z.be-z.bs),Y++);continue}let $e=z.bs,St=z.be,mt=U,xt=Y,Ht=Gt=>Gt.bs<St&&Gt.be>$e||Bt(Gt)&&(Gt.bs===$e||Gt.bs===St);H?mt++:xt++,Oe&&($e=Math.min($e,Z.bs),St=Math.max(St,Z.be),H?xt++:mt++);let qt=!0;for(;qt;){for(qt=!1;mt<ie.length&&Ht(ie[mt]);)$e=Math.min($e,ie[mt].bs),St=Math.max(St,ie[mt].be),mt++,qt=!0;for(;xt<_e.length&&Ht(_e[xt]);)$e=Math.min($e,_e[xt].bs),St=Math.max(St,_e[xt].be),xt++,qt=!0}let An=$e+ke,mn=$e+me,On=St-$e,Ln=St-$e;for(let Gt=U;Gt<mt;Gt++)On+=ie[Gt].text.length-(ie[Gt].be-ie[Gt].bs);for(let Gt=Y;Gt<xt;Gt++)Ln+=_e[Gt].text.length-(_e[Gt].be-_e[Gt].bs);let Wn=An+On,Kn=mn+Ln;if(ee($e),U<mt&&Y<xt&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!d.atoms.length&&!k.atoms.length&&!g.pins.length&&!d.pins.length&&!k.pins.length){he||={fb:g,fl:d,fr:k,ML:ce,MR:Ae,byEl:ae,cache:[null,null]};let Gt=oa(he,ie,U,mt,_e,Y,xt,0,n),bo=oa(he,_e,Y,xt,ie,U,mt,1,n);if(Gt===null!=(bo===null)){let ni=Gt!==null,Bl=ni?Gt:bo;if(Bl){ye||=new Map;for(let xu of Bl)ye.set(xu,ni?"local":"remote")}B.push(ni?{src:"remote",from:mn,to:Kn}:{src:"local",from:An,to:Wn}),pe=St,ke+=On-(St-$e),me+=Ln-(St-$e),U=mt,Y=xt;continue}}let on={kind:"text",node:e.node||null,base:Dr(g,$e,St),local:Dr(d,An,Wn),remote:Dr(k,mn,Kn),resolved:null,range:null,bs:$e,be:St,lss:An,lse:Wn,rss:mn,rse:Kn},yr=e.sourceRetentions?Jl(e.sourceRetentions,e.scope?.base,g,d,k,n,on):n;on.resolved=yr==="local"?on.local:yr==="remote"?on.remote:on.local+on.remote,yr!=="remote"&&B.push({src:"local",from:An,to:Wn,conflict:on}),yr!=="local"&&B.push({src:"remote",from:mn,to:Kn,conflict:on});let xr={site:"inline",policy:yr,fb:g,fl:d,fr:k,scope:e.scope||null,synthetic:!!e.synthetic,full:v,merged:u};f.push(xr),h(on,xr),pe=St,ke+=On-(St-$e),me+=Ln-(St-$e),U=mt,Y=xt}ee(Ue);let te=g.text,W=[];if(Me.respell.size||Be.respell.size){let x=Br(Ce),P=[];for(let H=0;H<Ce.length;H++){let z=Ce[H].raw,Z=Me.respell.get(H)??z,ge=Be.respell.get(H)??z;(Z!==z||ge!==z)&&W.push([x[H],Z!==z&&ge!==z?"both":Z!==z?"local":"remote"]),P.push(Z===ge?Z:Z===z?ge:ge===z||n==="local"?Z:ge)}te=P.join("")}let ne="",we=[],Ie=[],je=[],Se=[];for(let x of B){let P=ne.length;if(x.src==="base"){for(let H=x.from;H<x.to;H++)we.push(H),Ie.push(e.nativeTransfers?ce.bTo[H]:H+x.dL),je.push(e.nativeTransfers?Ae.bTo[H]:H+x.dR),Se.push(x);ne+=te.slice(x.from,x.to)}else if(x.src==="both"){for(let H=0;H<x.len;H++){let z=x.transfer&&(x.transfer.side==="remote"?x.rfrom+H:x.lfrom+H);we.push(x.transfer&&z>=x.transfer.ss&&z<x.transfer.se?x.transfer.bs+z-x.transfer.ss:-1),Ie.push(x.lfrom+H),je.push(x.rfrom+H),Se.push(x)}ne+=d.text.slice(x.lfrom,x.lfrom+x.len)}else{let H=x.src==="local"?d:k,z=x.transfer&&e.nativeTransfers.byOrigin[x.src==="local"?"remote":"local"].get(x.transfer.key);for(let Z=x.from;Z<x.to;Z++){let ge=x.transfer&&Z>=x.transfer.ss&&Z<x.transfer.se?x.transfer.bs+Z-x.transfer.ss:-1,ve=ge>=0&&(!z||z.destination===x.owner)?(x.src==="local"?Ae:ce).bTo[ge]:-1;we.push(ge),Ie.push(x.src==="local"?Z:ve),je.push(x.src==="remote"?Z:ve),Se.push(x)}ne+=H.text.slice(x.from,x.to)}x.ms=P,x.me=ne.length,x.conflict&&(x.conflict.range||(x.conflict.range=[P,P]),x.conflict.range[1]=ne.length)}let Je=ne.length,nt=new Int32Array(Ue+1).fill(-1),st=new Int32Array(d.text.length+1).fill(-1),$t=new Int32Array(k.text.length+1).fill(-1);for(let x=0;x<Je;x++)we[x]>=0&&(nt[we[x]]=x),Ie[x]>=0&&(st[Ie[x]]=x),je[x]>=0&&($t[je[x]]=x);let Ft=(x,P)=>{let H=-1,z=-1;for(let Z=x.from;Z<x.to;Z++){let ge=P[Z];ge>=0&&(H<0&&(H=ge),z=ge+1)}return H<0?null:[H,z]},I=[],G=[];for(let x of new Set(ae.values()))x.new==="local"?I.push(x):x.new==="remote"&&G.push(x);let se=(x,P)=>{x.remote=P.remote,x.remoteMark=P.remoteMark,x.new="both",P.merged=x,ae.set(P.remote,x)};if(I.length&&G.length){let x=e.idOf;for(let P of I){let H=x?x.local(P.local):null;if(!H)continue;let z=G.find(Z=>!Z.merged&&Z.tag===P.tag&&!!Z.block==!!P.block&&x.remote(Z.remote)===H);z&&se(P,z)}for(let P of I){if(P.remote)continue;let H=Ft(P.localMark,st);if(H)for(let z of G){if(z.merged||z.tag!==P.tag||!!z.block!=!!P.block)continue;let Z=Ft(z.remoteMark,$t);if(Z&&Math.min(H[1],Z[1])-Math.max(H[0],Z[0])>0){se(P,z);break}}}}lt.clear();let be=x=>{for(let P of x)if(P.block)return Ve(ae.get(P.el));return null},xe=g.marks.some(x=>x.block)||d.marks.some(x=>x.block)||k.marks.some(x=>x.block),fe=new Array(Je).fill(null),oe=new Set;if(e.nativeTransfers)for(let x=0;x<Je;x++){let P=Se[x].owner;fe[x]=P?Ve(ae.get(P)):we[x]>=0?be(g.stackAt[we[x]]):null}else if(xe){let x=(Le,$e,St)=>{let mt=new Set([Le,$e,St]);mt.delete(null);let xt=[];for(let qt of mt){let An=qt===Le,mn=qt===$e,On=qt===St;(mn===On?mn:mn===An?On:mn)&&xt.push(qt)}if(xt.length<=1)return xt[0]||null;let Ht=n==="local"?$e:St;return xt.includes(Ht)?Ht:xt[0]},P=(Le,$e)=>$e>=0?be(Le.stackAt[$e]):null,H=new Map;for(let Le=0;Le<Je;Le++){if(ne[Le]!==Ot)continue;let $e=we[Le]>=0?P(g,we[Le]):null,St=P(d,Ie[Le]),mt=P(k,je[Le]);H.set(Le,[$e,we[Le]>=0?x($e,St,mt):St||mt])}let z=new Set([...H.values()].map(Le=>Le[1])),Z=Le=>Le!==Ot&&Le!==Yn&&!/\s/.test(Le),ge=(Le,$e)=>{let St=Le;for(;St<$e&&!Z(ne[St]);)St++;return St<$e&&we[St]>=0?P(g,we[St]):null},ve=new Map,Oe=0;for(let Le=0;Le<Je;Le++){if(ne[Le]!==Ot)continue;let[$e,St]=H.get(Le),mt=ge(Oe,Le),xt=St,Ht=ve.get(xt)===xt&&mt===xt;xt&&ve.has(xt)&&!Ht&&$e&&!ve.has($e)&&!z.has($e)&&(xt=$e),xt&&!ve.has(xt)&&ve.set(xt,mt);for(let qt=Oe;qt<=Le;qt++)fe[qt]=xt;Oe=Le+1}let qe=Le=>{for(let $e=0;$e<Le.text.length;$e++)if(Z(Le.text[$e])&&!P(Le,$e))return!0;return!1};if(!qe(g)&&!qe(d)&&!qe(k)){let Le=[],$e=0;for(let mt=0;mt<Je;mt++)(ne[mt]===Ot||mt===Je-1)&&(Le.push([$e,mt]),$e=mt+1);let St=new Set(fe);for(let mt=0;mt<Le.length;mt++){let[xt,Ht]=Le[mt];if(fe[Ht])continue;let qt=xt;for(;qt<=Ht&&!Z(ne[qt]);)qt++;if(qt>Ht)continue;let An=P(g,we[qt]),mn=P(d,Ie[qt]),On=P(k,je[qt]),Ln=x(An,mn,On)||mn||On||An;if(Ln&&!St.has(Ln)){St.add(Ln);for(let on=xt;on<=Ht;on++)fe[on]=Ln;continue}let Wn=mt>0&&fe[Le[mt-1][1]],Kn=mt+1<Le.length&&fe[Le[mt+1][1]];if(Wn)oe.add(Le[mt-1][1]);else if(Kn&&ne[Ht]===Ot)oe.add(Ht);else continue;for(let on=xt;on<=Ht;on++)fe[on]=Wn||Kn}}}let Re=new Map,De=x=>{let P=Re.get(x);if(P)return P;P=[1/0,-1/0];for(let[H,z]of[[x.baseMark,nt],[x.localMark,st],[x.remoteMark,$t]]){let Z=H&&Ft(H,z);Z&&(P[0]=Math.min(P[0],Z[0]),P[1]=Math.max(P[1],Z[1]))}return Re.set(x,P),P},We=(x,P,H)=>{let z=-1,Z=-1;for(let ge=0;ge<x.length;ge++){let ve=ae.get(x[ge].el);ve===P&&(z=ge),ve===H&&(Z=ge)}return z>=0&&Z>=0?z-Z:0},Ye=(x,P)=>[...x].sort((H,z)=>{for(let ve of P){let Oe=We(ve,H,z);if(Oe)return Oe}let Z=De(H),ge=De(z);return Z[0]-ge[0]||ge[1]-Z[1]||H.rank-z.rank||H.id-z.id}),wt=new Map,at=new Map,Wt=e.nativeTransfers?[]:null,zt=x=>{if(Wt)return Wt;let P=we[x],H=Ie[x],z=je[x],Z=Se[x];if(P>=0){let mt=g.stackAt[P],xt=d.stackAt[H],Ht=k.stackAt[z],qt=wt.get(mt);qt||wt.set(mt,qt=new Map);let An=qt.get(xt);An||qt.set(xt,An=new Map);let mn=An.get(Ht);if(mn)return mn;let On=pt(mt),Ln=pt(xt),Wn=pt(Ht),Kn=new Set;for(let on of new Set([...On,...Ln,...Wn])){let yr=On.has(on),xr=Ln.has(on),Gt=Wn.has(on);(xr===Gt?xr:xr===yr?Gt:xr)&&Kn.add(on)}return mn=Ye(Kn,[xt,Ht,mt]),An.set(Ht,mn),mn}if(Z.src==="both"){let mt=d.stackAt[H],xt=k.stackAt[z];return Ye(new Set([...pt(mt),...pt(xt)]),[mt,xt])}let ve=(Z.src==="local"?d:k).stackAt[Z.src==="local"?H:z];if(!Z.inherit)return Ye(pt(ve),[ve]);let Oe=at.get(Z);Oe||at.set(Z,Oe=new Map);let qe=Oe.get(ve);if(qe)return qe;let Le=new Set(pt(ve));for(let mt of Z.inherit.added)Le.add(Ve(mt));for(let mt of Z.inherit.removed)Le.delete(Ve(mt));let $e=Z.src==="local"?k:d,St=(Z.src==="local"?Ae.bTo:ce.bTo)[Z.inherit.bs];return qe=Ye(Le,[ve,$e.stackAt[St]]),Oe.set(ve,qe),qe},bn=new Int32Array(d.text.length+1);bn[d.text.length]=Je;for(let x=d.text.length-1;x>=0;x--)bn[x]=st[x]>=0?st[x]:bn[x+1];Xu.caret+=d.text.length;let Tt=x=>x<=0?0:(x>d.text.length&&(x=d.text.length),st[x-1]>=0?st[x-1]+1:bn[x]),ht=[],Qe=[],Mt=null,bt=[],Ut="",En=-1,cn=x=>{Mt?Mt.appendChild(x):ht.push(x)},xn=x=>{if(!Ut)return;let P=t.createTextNode(Ut);cn(P),Qe.push({node:P,ms:En,me:x,local:[],u:bt.length?bt[bt.length-1].u:null}),Ut=""},en=new Set,Hn=new Map,Rr=new Set,zn=x=>{let P=t.createElement(x.tag);if(x.block&&Rn.add(P),!Hn.has(x)){Hn.set(x,P),_(x.base,x.local,x.remote,P),s.set(P,{base:x.base,local:x.local,remote:x.remote});let z=(ve,Oe)=>p&&x[Oe]&&ve.reverse.get(x[Oe])?Oe:null,Z=!x.base&&(z(r,"local")||z(o,"remote"));if(Z){let ve=Z==="local"?r.reverse.get(x.local):o.reverse.get(x.remote),Oe=s.get(P);Oe.local=Oe.local||r.map.get(ve)||null,Oe.remote=Oe.remote||o.map.get(ve)||null,a.push({kind:"move",el:P,source:Z}),e.moveBuilt?.(ve,Z,x[Z],P)}else x.base||a.push({kind:"insert",el:P,source:x.local&&x.remote?"both":x.local?"local":"remote"});let ge=s.get(P);ge.local&&(Rr.has(ge.local)?ge.local=null:Rr.add(ge.local))}else{let z=Hn.get(x);for(let Z of z.attributes)Z.name!=="id"&&Z.name!=="data-id"&&E(P,Z,Z.value);s.set(P,{base:null,local:null,remote:null})}cn(P),bt.push({u:x,el:P}),Mt=P},mo=new Set,or=new Map;for(let x of d.pins){let P=Tt(x.i);or.has(P)||or.set(P,[]),or.get(P).push(x)}let Yo=x=>{let P=or.get(x);if(P){xn(x);for(let H of P){let z=H.el.namespaceURI&&H.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(H.el.namespaceURI,H.el.tagName):t.createElement(H.el.tagName);s.set(z,{base:null,local:H.el,remote:null,pinned:!0}),mo.add(z),cn(z)}}},ti=g.atoms.length||d.atoms.length||k.atoms.length,Xo=x=>{if(!ti)return null;let P=we[x]>=0?g.atomAt.get(we[x]):null,H=Ie[x]>=0?d.atomAt.get(Ie[x]):null,z=je[x]>=0?k.atomAt.get(je[x]):null;return P||H||z?{ab:P,al:H,ar:z}:null},sr=(x,P,H)=>{let z=e.idOf;if(!z||!z.base)return!1;let Z=z.base(x.el);return Z!=null&&Z===z[H](P.el)},po=(x,P,H,z,Z)=>{if(!x||!p)return null;let ge=A.get(P.reverse.get(x.el))||null;return!ge||ge===z||(z?ge.el.isEqualNode(z.el)&&!sr(ge,x,Z):H.bTo[ge.i]>=0)?null:ge},Ir=(x,P)=>{if(!x||!p||!e.moveIn)return null;let H=P.reverse.get(x.el);return H&&!A.has(H)?H:null},go=(x,P)=>{let H=new Map;for(let z of x.atoms)H.set(P(z),(H.get(P(z))||0)+1);return H},ue=go(g,F),Ke=go(d,S),He=go(k,T),it=x=>{let P=F(x);return ue.get(P)===1&&(Ke.get(P)||0)<=1&&(He.get(P)||0)<=1},Et=new Map,Xe=new Set,Ze=new Set,_t=new Set,tt=null;for(let x=0;x<Je;x++){let P=Xo(x);if(!P)continue;let{ab:H,al:z,ar:Z}=P,ge=po(Z,o,Ae,H,"remote"),ve=po(z,r,ce,H,"local"),Oe=H,qe=null;if(ge?(Oe=ge,qe="remote"):ve&&(Oe=ve,qe="local"),Oe){H&&Oe!==H&&(tt||=new Map).set(H,qe),Xe.has(Oe)?Et.set(x,{dup:Oe.el}):(Xe.add(Oe),Et.set(x,{bk:Oe,from:qe,al:z,ar:Z}));continue}let Le=Ir(Z,o),$e=Ir(z,r),St=Le||$e;if(St){Ze.has(St)?Et.set(x,{dup:St}):(Ze.add(St),Et.set(x,{moveIn:St,side:Le?"remote":"local",sideEl:Le?Z.el:z.el}));continue}let mt=(Ht,qt)=>Ht&&p&&A.get(qt.reverse.get(Ht.el))||null,xt=mt(Z,o)||mt(z,r);if(xt&&(_t.add(xt),Se[x].conflict&&(it(xt)||Z&&(Z.el===xt.el||o.identityPaired?.has(xt.el))&&sr(xt,Z,"remote")||z&&(z.el===xt.el||r.identityPaired?.has(xt.el))&&sr(xt,z,"local")))){if(Xe.has(xt)){Et.set(x,{dup:xt.el});continue}Xe.add(xt)}Et.set(x,{al:z,ar:Z})}let ft=new Map,kt,Vt,Pt=(x,P)=>{if(x[P]>=0)return x[P];for(let H=P-1;H>=0;H--)if(x[H]>=0)return x[H]+1;return 0};if(p)for(let x of g.atoms){if(Xe.has(x)||_t.has(x))continue;let P=r.map.get(x.el)||null,H=o.map.get(x.el)||null,z=P&&O.get(P),Z=H&&X.get(H);if(P&&!z||H&&!Z)continue;let ge=!(z&&Z)&&Te.has(x);if(!ge&&!(z&&Z&&(it(x)||tt?.has(x)||(z.el===x.el||r.identityPaired?.has(x.el))&&(Z.el===x.el||o.identityPaired?.has(x.el))&&sr(x,z,"local")&&sr(x,Z,"remote"))))continue;let ve=tt?.get(x),Oe=n;if(ve){let mt=ve==="local"?k:d,xt=ve==="local"?o:r,Ht=ve==="local"?Vt:kt;if(Ht===void 0){Ht=mt.atoms.length===g.atoms.length;for(let qt=0;Ht&&qt<g.atoms.length;qt++)Ht=xt.reverse.get(mt.atoms[qt].el)===g.atoms[qt].el;ve==="local"?Vt=Ht:kt=Ht}Ht&&(Oe=ve)}let qe=Oe==="local"?[[z,st],[Z,$t]]:[[Z,$t],[z,st]],[Le,$e]=qe.find(([mt])=>mt),St=Pt($e,Le.i);ft.has(St)||ft.set(St,[]),ft.get(St).push({a:x,lt:P,rt:H,edited:ge}),Xe.add(x)}if(p&&e.moveIn){let x=[[d,r,st,"local"],[k,o,$t,"remote"]];n!=="local"&&x.reverse();for(let[P,H,z,Z]of x)for(let ge of P.atoms){let ve=Ir(ge,H);if(!ve||Ze.has(ve))continue;Ze.add(ve);let Oe=Pt(z,ge.i);ft.has(Oe)||ft.set(Oe,[]),ft.get(Oe).push({move:ve,side:Z,sideEl:ge.el})}}let nn=x=>{let P=ft.get(x);if(P){if(xn(x),P.some(H=>Fe(H.move?H.sideEl:H.a.el)))for(;bt.length;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;for(let{a:H,lt:z,rt:Z,edited:ge,move:ve,side:Oe,sideEl:qe}of P){if(ve){let $e=e.moveIn(ve,Oe,qe);$e&&cn($e);continue}en.add(H);let Le=M(H.el,z,Z);ge&&(h({kind:"structure",el:Le,detail:"edit-beats-delete",base:H.el},{subject:H.el,deleted:z?"remote":"local"}),a.push({kind:"insert",el:Le,source:z?"local":"remote"})),cn(Le)}}},Rn=new Set,ir=l.length>c;for(let x=0;x<Je;x++){let P=Xo(x),H=e.scopeUnits&&P&&(P.ab?.stack.some(ve=>ve.block)||P.al?.stack.some(ve=>ve.block)||P.ar?.stack.some(ve=>ve.block)),Z=!!P&&Fe((P.ab||P.al||P.ar).el)&&!H?[]:fe[x]?[fe[x],...zt(x)]:zt(x),ge=0;for(;ge<bt.length&&ge<Z.length&&bt[ge].u===Z[ge];)ge++;if(ge<bt.length)for(xn(x);bt.length>ge;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;if(Yo(x),nn(x),Z.length>bt.length)for(xn(x);bt.length<Z.length;)zn(Z[bt.length]);if(ne[x]===Ot){if(oe.has(x))continue;xn(x);let ve=bt.length;for(;ve>0&&!bt[ve-1].u.block;)ve--;if(ve>0)for(ir&&u.breakOut.set(x,bt[ve-1].el);bt.length>=ve;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;continue}if(P){xn(x);let ve=Et.get(x),Oe;if(ve.dup){h({kind:"structure",el:null,detail:"both-moved",base:ve.dup},{subject:ve.dup});continue}if(ve.moveIn){if(Oe=e.moveIn(ve.moveIn,ve.side,ve.sideEl),!Oe)continue}else if(ve.bk){let qe=ve.bk;if(en.add(qe),qe===P.ab)Oe=M(qe.el,ve.al.el,ve.ar.el);else{let Le=r.map.get(qe.el)||null,$e=o.map.get(qe.el)||null;Oe=M(qe.el,Le,$e),(!Le||!$e)&&h({kind:"structure",el:null,detail:"move-beats-delete",base:qe.el},{subject:qe.el,deleted:Le?"remote":"local"}),a.push({kind:"move",el:Oe,source:ve.from})}}else ve.al?(Oe=j(ve.al.el,"local"),ve.ar&&(s.get(Oe).remote=ve.ar.el),a.push({kind:"insert",el:Oe,source:ve.ar?"both":"local"})):(Oe=j(ve.ar.el,"remote"),a.push({kind:"insert",el:Oe,source:"remote"}));ir&&u.atomOut.set(x,Oe),cn(Oe);continue}Ut||(En=x),Ut+=ne[x]}if(xn(Je),(or.has(Je)||ft.has(Je))&&(bt.length=0,Mt=null,Yo(Je),nn(Je)),Je===0&&(d.placeholder||k.placeholder||g.placeholder)){let x=t.createElement("br");s.set(x,{base:g.placeholder,local:d.placeholder,remote:k.placeholder}),ht.push(x)}let Vn=0,yt=x=>{for(;Vn>0&&Qe[Vn-1].me>=x;)Vn--;for(;Vn<Qe.length&&Qe[Vn].me<x;)Vn++;let P=Qe[Vn];if(!P)return Qe[Qe.length-1]||null;let H=Qe[Vn+1];return P.me===x&&H&&H.ms===x?H:P},rt=new Map,jt={},ct=(x,P,H)=>{let z=yt(x)||(H?jt:null);if(!z)return;let Z=rt.get(z)||{l:!1,r:!1};P!=="remote"&&(Z.l=!0),P!=="local"&&(Z.r=!0),rt.set(z,Z)},Lt=x=>{if(x.conflict)return!0;let P=x.src==="local"?d.text:x.src==="remote"?k.text:"";for(let H=x.from;H<x.to;H++)if(P[H]!==Yn&&P[H]!==Ot)return!0;return!1};for(let x of B)x.src!=="base"&&ct(x.ms,x.conflict?"both":x.src,Lt(x));for(let[x,P]of W)nt[x]>=0&&ct(nt[x],P);for(let x of Qe.length?Qe:[jt]){let P=rt.get(x);P&&a.push({kind:"text",node:x.node||null,source:P.l&&P.r?"both":P.l?"local":"remote"})}for(let x of de){if(Hn.has(x))continue;let P=!x.local&&!(p&&r.map.get(x.base)),H=!x.remote&&!(p&&o.map.get(x.base));!P&&!H||a.push({kind:"remove",source:P&&H?"both":P?"local":"remote",base:x.base})}if(ye)for(let[x,P]of ye)Hn.has(x)&&h({kind:"structure",el:Hn.get(x),detail:"edit-beats-delete",base:x.base},{subject:x.base,deleted:P});let tn=(x,P,H)=>{if(P<=x)return!1;for(let z=x;z<P;z++)if(H[z]>=0)return!1;return!0};for(let x of de)for(let P of["local","remote"]){let H=x[P+"Mark"],z=x.baseMark;if(!H)continue;let Z=P==="local"?ce:Ae;if(!tn(z.from,z.to,Z.bTo)||!tn(H.from,H.to,Z.toB))continue;let ge=(P==="local"?ie:_e).find(ve=>ve.ss<=H.from&&H.from<ve.se);ge&&(ge.be<=z.from||ge.bs>=z.to)&&a.push({kind:"move",el:Hn.get(x)||null,source:P})}let Dt=x=>{let P=ae.get(x.node.parentNode);return P?Ve(P):null};for(let x of d.nodes){let P=-1;for(let z=x.s;z<x.e;z++)if(st[z]>=0){P=st[z];break}let H;if(P>=0)H=yt(P);else{let z=Tt(x.s),Z=Dt(x);H=Qe.find(ge=>ge.u===Z&&ge.me>=z)||Qe.filter(ge=>ge.u===Z).pop()}H&&H.local.push(x)}let Kt=new Map,ln=Qe[Qe.length-1]||null,Nt=0;for(let x of d.nodes){let P=null;for(let H=x.s;H<=x.e;H++){let z=Tt(H);for(;Nt>0&&Qe[Nt-1].me>=z;)Nt--;for(;Nt<Qe.length&&Qe[Nt].me<z;)Nt++;let Z=ve=>ve&&z>=ve.ms&&z<=ve.me&&(z<ve.me||H===x.e||ve===P),ge=Z(Qe[Nt])?Qe[Nt]:Z(Qe[Nt+1])?Qe[Nt+1]:Qe[Nt]||ln;if(!ge)break;if(P===ge){let ve=Kt.get(ge);ve[ve.length-1].to=H-x.s;continue}P=ge,Kt.has(ge)||Kt.set(ge,[]),Kt.get(ge).push({node:x.node,from:H-x.s,to:H-x.s,flatStart:x.s})}}for(let x of Qe){let P=x.local,H=!1;for(let ve of P)for(let Oe=ve.s;Oe<ve.e&&!H;Oe++)(st[Oe]<x.ms||st[Oe]>=x.me)&&(H=!0);s.set(x.node,{base:null,local:P.map(ve=>ve.node),remote:null,caret:Kt.get(x)||[],partial:H});let z=x.ms,Z=x.me-x.ms,ge=ve=>{let Oe=0,qe=-1;for(let Le of P){let $e=Le.e-Le.s;if(ve<=Oe+$e){qe=Le.s+(ve-Oe);break}Oe+=$e}return qe<0&&(qe=P.length?P[P.length-1].e:0),Math.max(0,Math.min(Tt(qe)-z,Z))};ge.flat=ve=>Math.max(0,Math.min(Tt(ve)-z,Z)),i.set(x.node,ge)}function At(){if(!d.text.includes(Ot))return[{flatLocal:d.text,localNodes:d.nodes,textNodes:Qe,lToM:st,mapLocal:Tt}];let x=[],P=0,H=0;for(let z=0;z<=d.text.length;z++){if(z<d.text.length&&d.text[z]!==Ot)continue;let Z=P,ge=z;if(ge>Z){let ve=[];for(;H<d.nodes.length&&d.nodes[H].e<=Z;)H++;for(let Oe=H;Oe<d.nodes.length&&d.nodes[Oe].s<ge;Oe++){let qe=d.nodes[Oe],Le=Math.max(qe.s,Z),$e=Math.min(qe.e,ge);Le<$e&&ve.push({node:qe.node,s:Le-Z,e:$e-Z})}x.push({flatLocal:d.text.slice(Z,ge),localNodes:ve,textNodes:Qe,lToM:st.subarray?st.subarray(Z,ge+1):st.slice(Z,ge+1),mapLocal:Oe=>Tt(Z+Math.max(0,Math.min(Oe,ge-Z)))})}P=z+1}return x}let It={...e,blocks:Rn,ignored:x=>mo.has(x)||(e.ignored?e.ignored(x):!1)},rn=e.ignoreAttribute||(()=>!1),lr=Zl(an(ht,It),rn)!==Zl(k,rn);if(f.length){let x=P=>{let H=s.get(P);return H&&H.unchanged?H.remote:null};u.text=ne,u.textNodes=Qe,u.out=an(ht,{...It,via:x})}let In=null;if(e.scopeUnits){In=new Map;let x=new Set(ht),P=Oe=>{for(;Oe&&!x.has(Oe);)Oe=Oe.parentNode;return Oe},H=e.scopeUnits.map(Oe=>{let qe=new Map;for(let Le of Oe)if(Le.nodeType===1)qe.set(Le,Le);else for(let $e of Le.nodes)qe.set($e,Le);return qe}),z=(Oe,qe)=>{for(;Oe&&!qe.has(Oe);)Oe=Oe.parentNode;return Oe?qe.get(Oe):null},Z=[g,d,k].map((Oe,qe)=>{let Le=new Array(Oe.text.length);for(let $e of Oe.nodes){let St=z($e.node,H[qe]);St&&Le.fill(St,$e.s,$e.e)}for(let $e of Oe.atoms)Le[$e.i]=z($e.el,H[qe]);return Le}),ge=(Oe,qe)=>{if(!Oe||!qe)return;let Le=In.get(Oe);Le||In.set(Oe,Le=new Set),Le.add(qe)};for(let Oe of ht){let qe=s.get(Oe);qe&&(ge(z(qe.base,H[0]),Oe),ge(z(qe.local,H[1]),Oe),ge(z(qe.remote,H[2]),Oe))}for(let Oe of Qe){let qe=P(Oe.node);for(let Le=Oe.ms;Le<Oe.me;Le++)ge(Z[0][we[Le]],qe),ge(Z[1][Ie[Le]],qe),ge(Z[2][je[Le]],qe)}let ve=new Map(ht.map((Oe,qe)=>[Oe,qe]));for(let[Oe,qe]of In)In.set(Oe,Array.from(qe).sort((Le,$e)=>ve.get(Le)-ve.get($e)))}return{unitOutputs:In,nodes:ht,text:ne,textNodes:Qe,localDiverged:lr,mapLocal:Tt,conflicts:l.slice(c),granularity:V?"line":"word",segments:At(),localHunks:ie,remoteHunks:_e,lToM:st}}var Si=Symbol("lost");function ca(){return{links:new Map,removed:new Set,consumed:new Set,link(e,t){this.links.set(e,t)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let t of e.nodes)this.removed.add(t)},consume(e){for(let t of e)this.consumed.add(t)}}}var aa=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function fa({locals:e,rec:t,root:n,provenance:r,segments:o,ignored:s}){let i=new Map,l=(w,v)=>{let E=i.get(w);E||i.set(w,E=new Set),E.add(v)},a=new Set,c=new Set;for(let w of o){let v=w.textNodes;for(let E of v)a.add(E.node);for(let E of w.localNodes){c.add(E.node);let N=0,_=null;for(let M=E.s;M<E.e;M++){let j=w.lToM[M];if(j<0)continue;for((!v[N]||j<v[N].ms)&&(N=0);N<v.length&&v[N].me<=j;)N++;let R=v[N]&&v[N].ms<=j?v[N].node:Si;R!==_&&l(E.node,R),_=R}}}let h=new Set,u=new Map,f=new Set;(function w(v){h.add(v);let E=r.get(v);if(v.nodeType===1)E&&E.local&&E.local.nodeType===1&&(l(E.local,v),E.unchanged&&f.add(E.local)),v.tagName==="TEMPLATE"&&v.content&&u.set(v.content,v);else if(E&&Array.isArray(E.local)&&!a.has(v))for(let N of E.local)l(N,v);for(let N=aa(v).firstChild;N;N=N.nextSibling)w(N)})(n);let p=new Set;for(let[w,v]of t.links)l(w,v),p.add(w);let m=w=>{let v=w.parentNode;return v&&v.nodeType===11?u.get(v)||null:v},y=(w,v)=>{for(let E=w;E;E=m(E))if(E===v)return!0;return!1},g=w=>t.removed.has(w)||t.consumed.has(w),d=w=>{for(let v=w.parentNode;v&&v.nodeType===1;v=v.parentNode){if(f.has(v))return"kept";if(g(v))return"decided";if(i.has(v))return null}return null},k=new Map;for(let w of e)k.set(w,A(w));return k;function A(w){let v=i.get(w);if(v&&(v.size!==1||v.has(Si)))return{kind:"unknown",reason:"several-outputs"};let E=v?v.values().next().value:null;if(E&&(E.nodeType!==1||!h.has(E)))return{kind:"unknown",reason:"output-not-placed"};if(!E){let j=g(w)?"decided":d(w);if(j==="kept")return{kind:"untouched"};if(j!=="decided")return{kind:"unknown",reason:"unmapped"}}let N=[],_=M(w,!!E&&(f.has(w)||p.has(w)),!E||g(w));if(_)return{kind:"unknown",reason:_};return E?{kind:"single",output:E,owned:N,carried:p.has(w)}:{kind:"removed"};function M(j,R,D){for(let F=aa(j).firstChild;F;F=F.nextSibling){if(F.nodeType===1?s(F):F.nodeType!==3&&F.nodeType!==8)continue;let S=i.get(F);if(S)for(let T of S){if(T===Si||!h.has(T))return"output-not-placed";if(!E)return"survives-elsewhere";if(!y(T,E))return"escaped";N.push(T)}else if(!R&&!D&&!g(F)&&!c.has(F))return"unmapped";if(F.nodeType===1){let T=M(F,R||f.has(F)||p.has(F),D||g(F));if(T)return T}}return null}}}function ua(e,t){if(!t)return!1;let n=t.nodeType===1&&t.tagName==="TEMPLATE"?[t,...t.querySelectorAll("template")]:[...t.querySelectorAll("template")];for(let r of n)if(r.content.contains(e)||ua(e,r.content))return!0;return!1}function da(e,t){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let n=[],r=new Set;for(let o of Array.from(e.elements)){if(!o||o.nodeType!==1||o.ownerDocument!==t&&!ua(o,t.documentElement))throw new TypeError("lineage.elements must be elements of the live document");r.has(o)||(r.add(o),n.push(o))}return n}var ha=new WeakMap;function ma(e){let t=new Map;for(let n of e){let r=[],o=!1;(function s(i){i.nodeType===1&&i.namespaceURI==="http://www.w3.org/1999/xhtml"&&i.localName==="template"&&(o=!0);for(let l=i.firstChild;l;l=l.nextSibling)r.push(l),l.nodeType===1&&s(l)})(n),t.set(n,{nodes:r,opaque:o})}return t}function Ti(e,t,n){if(e.lineage===void 0)return n(e);if(!t||t.nodeType!==1)throw new TypeError("lineage requires an element root");let r=e.lineage,o=da(r,t.ownerDocument),s=!1,i={...e,lineage:{elements:o,onResult(l,a){if(!s)return s=!0,r.onResult(l,a)}}};try{return ha.set(i.lineage,ma(o)),n(i)}catch(l){if(!s){s=!0;try{r.onResult({version:1,root:t,status:"incomplete",entries:o.map(Pn)},null)}catch{}}throw l}}function Ei(e,{liveRoot:t,localRoot:n,toLive:r}){let o=da(e,t.ownerDocument),s=c=>c===t||t.contains(c),i=new Map,l=new Set(o.filter(s));if(l.size&&n===t)for(let c of l)i.set(c,c);else l.size&&(function c(h){let u=r(h);l.delete(u)&&i.set(u,h);for(let f=h.firstElementChild;f&&l.size;f=f.nextElementSibling)c(f)})(n);return{spec:e,watched:o,root:t,locals:Array.from(new Set(i.values())),before:ha.get(e)||ma(o),delivered:!1,result:null,finish(c,h){return this.resolve=h,this.plans=c,this.result={version:1,root:this.root,status:"complete",entries:o.map(u=>nd(u,i.get(u),c,h,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(c,h){this.root=h;let u=this.resolve,f=m=>{let y=u(m);return y===c?h:y};return this.finish(this.plans,f)},deliver(c){this.delivered||(this.delivered=!0,e.onResult(this.result,c))}}}var Pn=e=>({from:e,to:[],kind:"unknown",complete:!1});function nd(e,t,n,r,o){let s=o.root,i=f=>!!f&&(f===s||s.contains(f)),l=t&&n?n.get(t):null;if(!l||l.kind==="unknown")return Pn(e);let a=o.before.get(e);if(!a||a.opaque)return Pn(e);let c=a.nodes,h=f=>i(f)||!!(f&&f.ownerDocument===s.ownerDocument&&s.ownerDocument.documentElement?.contains(f));if(l.kind==="untouched"){if(!i(e))return Pn(e);for(let f of c)if(h(f)&&!e.contains(f))return Pn(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(l.kind==="removed")return h(e)||c.some(h)?Pn(e):{from:e,to:[],kind:"removed",complete:!0};let u=r(l.output);if(!u||u.nodeType!==1||!i(u)||u!==e&&h(e))return Pn(e);for(let f of c)if(h(f)&&!u.contains(f))return Pn(e);for(let f of l.owned){let p=r(f),m=Array.isArray(p)?p:[p];for(let y of m)if(!y||!i(y)||!u.contains(y))return Pn(e)}return l.carried&&!pa(u,l.output,r)?Pn(e):{from:e,to:[u],kind:u===e?"retained":"replaced",complete:!0}}function pa(e,t,n){for(let r=t.firstChild;r;r=r.nextSibling){let o=n(r),s=Array.isArray(o)?o:[o];for(let i of s)if(!i||!e.contains(i))return!1;if(r.nodeType===1&&!pa(e,r,n))return!1}return!0}function xo(e,t,n){let r=Ei(e,{liveRoot:t,localRoot:t,toLive:o=>o});return r.result={version:1,root:t,status:"complete",entries:r.watched.map(o=>Pn(o))},n.lineage=r.result,r}function ga(e,t,n,r,o){if(!o(e.length*8+1))return null;let s=0,i=t===0,l=!1;for(let a of pn(e,r)){if(!o(1))return null;if(s+=a.len,s===t&&(i=!0),s===n&&(l=!0),s>=n)break}return i&&l}function rd(e,t,n,r,o,s,i){if(!i(t.length*2))return!1;let l=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],p=u?h.bs:h.ss,m=u?h.be:h.se;if(!i((m-p)*4+1))return!1;for(;p<m&&/\s/.test(f[p]);)p++;for(;m>p&&/\s/.test(f[m-1]);)m--;if(p===m)continue;let y=f.slice(p,m),g=u?l:a;u&&h.text&&c.add(y),g.has(y)?g.set(y,null):g.set(y,{h,from:p,to:m})}for(let h of r){if(!i(1))return!1;if(h.side!==e)continue;let u=h.deletion,f=n[u.ownerIndex].text.base;if(!i((u.be-u.bs)*3)||c.has(f.slice(u.bs,u.be).trim()))return!1}for(let[h,u]of l){if(!i(h.length+1))return!1;let f=a.get(h);if(!u||!f)continue;let p=u.h,m=f.h;if(!p.text||p.transferOut||m.transferIn||p.owner===m.owner)continue;let y=n[p.ownerIndex],g=n[m.ownerIndex];if(!i(y.text.base.length))return!1;if(!/\S/.test(y.text.base.slice(0,p.bs)+y.text.base.slice(p.be)))continue;let d=ga(y.text.base,u.from,u.to,s,i),k=ga(g.text[e],f.from,f.to,s,i);if(d===null||k===null)return!1;if(!d||!k)continue;let A=`${y.index}:${u.from}:${u.to}`,w={key:A,side:e,source:p.owner,destination:m.owner,deletion:p,insertion:m,sourceOffset:u.from-p.bs,targetOffset:f.from-m.ss,length:u.to-u.from};p.transferOut=w,m.transferIn=w,o[e].set(A,w),r.push(w)}return!0}function ba({base:e,local:t,remote:n,localTwin:r,remoteTwin:o,eligible:s,nodes:i,budget:l=Zt(2e4*32)}){let a=_=>_>l.remaining?!1:(l.remaining-=_,l.nativeSteps=(l.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=i[_];if(j.length!==M.length||j.some((R,D)=>R!==M[D]))return null}let c=[],h=0;for(let _=0;_<e.length;_++){let M=e[_],j=t[_],R=n[_];if(r(M)!==j||o(M)!==R)return null;let D={};for(let[F,S]of[["base",M],["local",j],["remote",R]]){if(!s(S)||S.tagName!==M.tagName||S.namespaceURI!==M.namespaceURI||!a(S.childNodes.length+1))return null;let T="";for(let J of S.childNodes){if(J.nodeType!==3||!a(J.data.length*4+1))return null;T+=J.data}if(T.includes(Ot)||(h+=T.length+1,h>2e4))return null;D[F]=T}c.push({base:M,local:j,remote:R,index:_,text:D})}let u=c.every(_=>Nn(_.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,R=_.text[M];if(j===R)continue;let D=j.length+R.length+4,F=D*8;if(!a(F))return null;let S=Math.floor(l.remaining/8),T=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(D*D+S)-D)/2)));if(T<1||!a(4*(T+1)*(D+T+1)))return null;let J=0;for(let q of vr(j,R,T)){if(!a(q.text.length+1))return null;let V=q.bs+J,Ce={...q,ss:V,se:V+q.text.length,toks:pn(q.text,u),owner:_.base,ownerIndex:_.index};_.hunks[M].push(Ce),f[M].push(Ce),J+=q.text.length-(q.be-q.bs)}}}let p=[],m={local:new Map,remote:new Map};for(let _ of["local","remote"]){let M=new Map,j=new Map,R=!1,D=(F,S,T)=>{F.has(S)?F.set(S,null):F.set(S,T)};for(let F of f[_]){if(!a(1))return null;let S=c[F.ownerIndex].text.base;if(F.bs<F.be&&F.text===""){let T=S.slice(F.bs,F.be);if(!a(T.length*2))return null;/\S/.test(T)&&D(M,T,F)}else if(F.bs===F.be&&/\S/.test(F.text)){if(!a(F.text.length*2))return null;D(j,F.text,F)}else F.bs<F.be&&(R=!0)}for(let[F,S]of M){if(!a(F.length+1))return null;let T=j.get(F);if(!S||!T||S.owner===T.owner)continue;let J=c[S.ownerIndex];if(!a(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,S.bs)+J.text.base.slice(S.be)))continue;let q=`${J.index}:${S.bs}:${S.be}`,V={key:q,side:_,source:S.owner,destination:T.owner,deletion:S,insertion:T};S.transferOut=V,T.transferIn=V,m[_].set(q,V),p.push(V)}if(R&&j.size&&!rd(_,f[_],c,p,m,u,a))return null}if(!p.length)return null;let y=(_,M)=>_.bs<M.be&&M.bs<_.be,g=_=>_.bs===_.be,d=(_,M)=>_.bs<=M.be&&M.bs<=_.be&&g(_)!==g(M),k=(_,M)=>_.bs===M.bs&&_.be===M.be&&_.text===M.text,A=(_,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 p){let M=_.side==="local"?"remote":"local",j=c[_.deletion.ownerIndex];for(let R of j.hunks[M])if(!a(1)||y(_.deletion,R)&&R.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)||d(M,j)&&!A(M,j)&&!A(j,M))return null}if(!a(h*8))return null;let w=new Set([...e,...t,...n]),v={base:an(e,{blocks:w}),local:an(t,{blocks:w}),remote:an(n,{blocks:w})},E={};for(let _ of["base","local","remote"]){let M=v[_];if(M.atoms.length||M.pins.length)return null;E[_]=new Map(M.marks.filter(j=>j.block).map(j=>[j.el,j.from]))}for(let _ of c){let M=E.base.get(_.base);if(M===void 0)return null;for(let j of["local","remote"]){let R=E[j].get(_[j]);if(R===void 0)return null;for(let D of _.hunks[j])D.bs+=M,D.be+=M,D.ss+=R,D.se+=R}}for(let _ of p)_.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 N={};for(let _ of["local","remote"]){let M=0,j=0,R=[];for(let F of f[_]){if(!a(1))return null;F.bs>M&&R.push({from:M,to:F.bs,target:j}),M=F.be,j=F.se}M<v.base.text.length&&R.push({from:M,to:v.base.text.length,target:j});let D=p.filter(F=>F.side===_).map(F=>({from:F.bs,to:F.be,target:F.ss,destination:F.destination}));if(N[_]=Gn({base:v.base,side:v[_],retained:R,transfers:D,budget:l}),N[_].status!=="ready")return null}return a(v.base.text.length)?{owners:c,blocks:w,transfers:p,byOrigin:m,budget:l,prepared:{base:v.base,local:v.local,remote:v.remote,lines:!1,baseTokens:pn(v.base.text,u),localEdits:{hunks:f.local,respell:new Map},remoteEdits:{hunks:f.remote,respell:new Map},localMap:N.local,remoteMap:N.remote,full:null}}:null}var Oi=/\S/;function ka({certificates:e,scopes:t,views:n,eligible:r,baseId:o,limit:s=2e4*32}){let i=Zt(s),l=Symbol(),a=[],c=u=>{if(u>i.remaining)throw l;i.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 p="",m=0;for(let y of u.childNodes){if(c(1),y.nodeType!==3)return null;if(c(y.data.length*4+1),f){let g=f.flat.nodes[m++];if(!g||g.node!==y||g.s!==p.length||g.e!==p.length+y.data.length)return null}p+=y.data}return c(p.length*3+1),f&&(f.flat.atoms.length||f.flat.pins?.length||m!==f.flat.nodes.length||f.flat.text!==p)?null:Oi.test(p)?p:null};try{c(t[0].length+t[1].length+t[2].length+e.length);let u=t.map(p=>new Set(p)),f=new Map;for(let p of e){c(1);let m=f.get(p.source);m||f.set(p.source,m=[]),m.push(p)}for(let p of f.values()){let m=[null,null],y=[];for(let g of p){c(1);let{source:d,target:k,side:A,models:w,runs:v}=g;if(A!==0&&A!==1||!u[0].has(d)||!u[A+1].has(k))continue;let{V:E,A:N,idOf:_}=n[A],M=n[1-A],j=E.twin(d),R=M.V.twin(d),D=E.baseOf(k);if(!j||!R||!D||D===d||!u[0].has(D)||!u[A+1].has(j)||!u[2-A].has(R)||N.map.get(d)!==j||N.reverse.get(j)!==d||M.A.map.get(d)!==R||M.A.reverse.get(R)!==d||N.map.get(D)!==k||N.reverse.get(k)!==D||k.parentNode!==j.parentNode||D.parentNode!==d.parentNode||d.tagName!==j.tagName||d.tagName!==R.tagName||o(d)!==_(j)||o(d)!==M.idOf(R)||o(D)!==_(k))continue;let F=w.get(d),S=w.get(k);if(!F||!S)continue;let T=h(d,F),J=h(k,S),q=h(j),V=h(R);if(c((T?.length||0)+(V?.length||0)),T===null||J===null||q===null||V===null||V===T)continue;let Ce=v.length>0,Me=!1;for(let ce of v){if(c(1),ce.source!==d||ce.target!==k||!Number.isInteger(ce.from)||!Number.isInteger(ce.to)||!Number.isInteger(ce.targetFrom)||ce.from<0||ce.to<=ce.from||ce.to>T.length||ce.targetFrom<0||ce.targetFrom+ce.to-ce.from>J.length){Ce=!1;break}c((ce.to-ce.from)*3);for(let Ae=ce.from;Ae<ce.to;Ae++){if(T[Ae]!==J[ce.targetFrom+Ae-ce.from]){Ce=!1;break}Oi.test(T[Ae])&&(Me=!0)}if(!Ce)break}if(!Ce||!Me)continue;let Be=m[A];Be||(c(T.length),Be=m[A]={source:d,side:A,flat:F.flat,before:T,covered:new Uint8Array(T.length)});for(let ce of v)c(ce.to-ce.from),Be.covered.fill(1,ce.from,ce.to)}for(let g of m){if(!g)continue;let{source:d,side:k,flat:A,before:w,covered:v}=g;c(w.length*3+1);let E=-1,N=-1;for(let _=0;_<=w.length;_++)_<w.length&&v[_]?(E<0&&(E=_),N=_+1):(_===w.length||Oi.test(w[_]))&&E>=0&&(y.push({source:d,side:k,flat:A,from:E,to:N}),E=N=-1)}c(y.length),a.push(...y)}}catch(u){if(u!==l)throw u}return{records:a,budget:i}}var od="http://www.w3.org/1999/xhtml";function sd(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 vn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===od}function id(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function is(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+"|"+sd(e.textContent.trim())}var ld={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function qr(e,t=[],n=!1){if(!vn(e)||e.hasAttribute("src"))return null;let r=[ld,...t];for(let o=0;o<r.length;o++){let s=r[o];if(!s.match(e))continue;if(!id(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 ya(e,t,n){let r=new Set,o=s=>{vn(s)&&!t(s)&&r.add(is(s,n))};o(e);for(let s of e.querySelectorAll("script"))o(s);return r}function vo(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 xa(e,t,n){let r=[],o=[],s=new Map,i=n.trackRecovery?new Set:null,l=Array.from(e.querySelectorAll("script"));vn(e)&&l.unshift(e);for(let a of l){if(!vn(a)||n.ignored(a)||n.skip.has(a)||t.has(is(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){i?.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:i}}function ad(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 cd(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function va(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return is(e,t);if(n==="LINK"){let r=e.getAttribute("href");return r?"link|"+(e.getAttribute("rel")||"")+"|"+cd(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|"+ad(e.textContent):e.outerHTML}function _i(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
|
|
1
|
+
var hypercms=(()=>{var si=Object.defineProperty;var Mu=Object.getOwnPropertyDescriptor;var Ru=Object.getOwnPropertyNames;var Iu=Object.prototype.hasOwnProperty;var ii=(e,t)=>{for(var n in t)si(e,n,{get:t[n],enumerable:!0})},Lu=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ru(t))!Iu.call(e,o)&&o!==n&&si(e,o,{get:()=>t[o],enumerable:!(r=Mu(t,o))||r.enumerable});return e};var Pu=e=>Lu(si({},"__esModule",{value:!0}),e);var Cg={};ii(Cg,{cms:()=>Ng,default:()=>_g});var Qo=["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"],ko=new Set(Qo),li=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Pr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),zl=new Set(["checked","selected","disabled","readOnly","paused"]);function ai(e,t){return t==null?zl.has(e)?!1:"":zl.has(e)?t==="false"?!1:!!t:t}function nn(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 xo(e){let t=nn(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function ci(e){let t=0,n=null,r=-1,o=!1;for(let s=0;s<e.length;s++){let i=e[s];i==="\\"?s++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:t===0&&i===">"?r=s:t===0&&i===","&&(o=!0)}return o||r===-1||!ju(e,r+1)?null:e.slice(0,r).trim()||null}function ju(e,t){let n=t,r=e.replace(/\s+$/,"").length;for(;n<r&&/\s/.test(e[n]);)n++;let o=0,s=null;for(;n<r;n++){let i=e[n];if(i==="\\")n++;else if(s)i===s&&(s=null);else if(i==='"'||i==="'")s=i;else if(i==="["||i==="(")o++;else if(i==="]"||i===")")o>0&&o--;else if(o===0&&(i==="+"||i==="~"||/\s/.test(i)))return!1}return!0}function es(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 fi(e){let t=new Map;return(n,r)=>{if(typeof r!="string")return es(r,e);let o=t.get(n);if(o&&o.text===r)return o.doc;let s=es(r,e);return t.set(n,{text:r,doc:s}),s}}function Wl(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 ui=()=>!1;function di(e,t=[]){if(typeof e!="function")return ui;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 c=n.get(l);if(c!==void 0){a=c;break}if(i.push(l),e(l,r.has(l))){a=!0;break}if(r.has(l))break;l=l.parentElement}for(let c of i)n.set(c,a);return a}}var Xg=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 ar(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function hi(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=u=>Number.isInteger(u)&&u>=0,l=0,a=!1,c=u=>{let f=u;for(;f>0;){let p=o[l++];if(l>o.length||!i(p))return!1;f+=p-1}return!0},d=(u,f)=>{if(a)return;if(o){let k=l++,g=o[k];if(k>=o.length||!i(g)){a=!0;return}let h=!s||s[k]===u.tagName.toLowerCase();if(!h||g!==u.children.length){let y=h&&t[f];typeof y=="string"&&y&&n.set(u,y),c(g)||(a=!0);return}}let p=t[f];typeof p=="string"&&p&&n.set(u,p);let m=u.children;for(let k=0;k<m.length;k++)d(m[k],f===""?String(k):`${f}.${k}`)};return d(e,""),n}function Kl(e){return t=>{for(let n of e){let r=n(t);if(typeof r=="string"&&r!=="")return r}return null}}var Nn=Kl([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function ts(e,t,n,r=null,o=null){let s=new Map,i=new Set,l=a=>{if(n(a))return;let c=t(a);c&&(s.has(c)?i.add(c):s.set(c,a))};if(r){let a=c=>{for(let d of c.querySelectorAll(r))l(d);for(let d of c.querySelectorAll("template"))d.content&&a(d.content)};l(e),a(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let a=c=>{l(c);let d=c.tagName==="TEMPLATE"&&c.content?c.content.children:c.children;for(let u=0;u<d.length;u++)a(d[u])};a(e)}for(let a of i)s.delete(a),o&&o.add(a),mi(a);return s}function mi(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"]),Yl=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function jr(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 Gl(e){return e.replace(/\s+/g," ")}var Bu=0;function Xl({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let r=new WeakMap,o=new WeakMap;function s(E){let N=E.attributes,_=N.length;if(_===0)return{all:"",sig:E.tagName+"|"};let M=[],j="",R=[];for(let D=0;D<_;D++){let B=N[D],S=B.name;t(E,S)||M.push(S+"="+B.value),S==="class"?j=B.value.indexOf(" ")<0?B.value:B.value.split(/\s+/).filter(Boolean).sort().join(" "):Fu.has(S)&&R.push(S+"="+B.value)}return M.length>1&&M.sort(),R.length>1&&R.sort(),{all:M.join(""),sig:E.tagName+"|"+j+(R.length?"|"+R.join("|"):"")}}function i(E){return E.nodeType===1&&E.tagName==="TEMPLATE"&&E.content?E.content.childNodes:E.childNodes}function l(E){let N=r.get(E);if(N)return N;if(E.nodeType===3)N={hash:"T"+jr(E.nodeValue),hint:Gl(E.nodeValue).slice(0,64),sig:null,tok:null};else if(E.nodeType===8)N={hash:"C"+jr(E.nodeValue),hint:"",sig:null,tok:null};else if(E.nodeType===1){let _=s(E),M=jr(E.tagName+""+_.all),j="";for(let R of c(E))if(R.nodeType===1){let D=l(R);M=jr(D.hash,M),j.length<64&&(j+=" "+D.hint)}else M=jr(d(R),M),R.kind==="text"&&j.length<64&&(j+=R.value.slice(0,64));N={hash:"E"+M,hint:Gl(j).trim().slice(0,64),sig:_.sig,tok:null}}else N={hash:"N"+E.nodeType,hint:"",sig:null,tok:null};return r.set(E,N),N}function a(E){if(!E.tok){E.tok=new Set;for(let N of E.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))N&&E.tok.add(N)}return E.tok}function c(E){let N=o.get(E);if(N)return N;N=[];let _=null,M=()=>{_&&(_.value=_.nodes.map(j=>j.nodeValue).join(""),N.push(_),_=null)};for(let j of i(E)){if(j.nodeType===3){_||(_={kind:"text",nodes:[],value:"",parent:E,hash:void 0}),_.nodes.push(j);continue}M(),j.nodeType===8?N.push({kind:"comment",nodes:[j],value:j.nodeValue,parent:E,hash:void 0}):j.nodeType===1&&!e(j)&&N.push(j)}return M(),o.set(E,N),N}function d(E){return E.nodeType===1?l(E).hash:(E.hash===void 0&&(E.hash=(E.kind==="text"?"T":"C")+jr(E.value)),E.hash)}function u(E,N){let _=a(l(E)),M=a(l(N));if(_.size===0&&M.size===0)return{coef:1,share:1};if(_.size===0||M.size===0)return null;let j=0;for(let R of _)M.has(R)&&j++;return{coef:j/Math.min(_.size,M.size),share:j/Math.max(_.size,M.size)}}function f(E,N){let _=u(E,N);return!!_&&_.coef>=.5}let p=new WeakMap;function m(E){let N=p.get(E);if(N)return N;N=[];for(let _ of E.attributes)t(E,_.name)||N.push([_.namespaceURI||"",_.localName,_.value]);return N.sort((_,M)=>_[0]<M[0]?-1:_[0]>M[0]?1:_[1]<M[1]?-1:_[1]>M[1]?1:0),p.set(E,N),N}let k=new WeakMap;function g(E,N){if(E===N)return!0;if(d(E)!==d(N))return!1;let _=k.get(E);if(_&&_.has(N))return _.get(N);let M=k.get(N);if(M&&M.has(E))return M.get(E);let j=h(E,N),R=j===!0;return j===!1&&n&&n.hashRejected++,_||k.set(E,_=new WeakMap),_.set(N,R),R}function h(E,N){if(E.nodeType===1){if(N.nodeType!==1||E.tagName!==N.tagName||E.namespaceURI!==N.namespaceURI)return!1;let _=m(E),M=m(N);if(_.length!==M.length)return!1;for(let D=0;D<_.length;D++)if(_[D][0]!==M[D][0]||_[D][1]!==M[D][1]||_[D][2]!==M[D][2])return!1;let j=c(E),R=c(N);if(j.length!==R.length)return!1;for(let D=0;D<j.length;D++){if(d(j[D])!==d(R[D]))return!1;if(!g(j[D],R[D]))return Bu}return!0}return N.nodeType===1?!1:E.kind===N.kind&&E.value===N.value}let y=new WeakMap,A=new Map,w=0;function v(E){let N=y.get(E);if(N)return N;let _=d(E),M=A.get(_);M||A.set(_,M=[]);let j=M.find(R=>g(R.unit,E));return N=j?j.key:"K"+w++,j||M.push({unit:E,key:N}),y.set(E,N),N}return{meta:l,unitsOf:c,unitHash:d,similar:f,score:u,childrenOf:i,equalUnits:g,exactUnitKey:v,ignored:e}}var Jl=16,qu=2e3,Uu=3,pi={align:0,certifyVisited:0,certifyScheduled:0};function gi(e,t,n){let{meta:r,unitsOf:o,unitHash:s,similar:i,score:l,childrenOf:a,equalUnits:c,ignored:d}=n.analyzer,u=n.baseId||(()=>null),f=n.sideId||(()=>null),p=n.baseKey||(()=>null),m=n.sideKey||(()=>null),k=n.baseDropped||new Set,g=n.sideDropped||new Set,h=n.stats||null,y=h?new Set:null,A=h?new Set:null,w=new Map,v=new Map,E=new Set,N=new Map,_=new Set,M=new Set,j=new Set,R=[],D=[],B=[],S=[],T=qu,J=new Map,q=new Map,V=(U,Y)=>{w.set(U,Y),v.set(Y,U)},Ce=new Set,Me=new Set,Fe=null,ce=U=>{let Y=U.nodeType?U.parentNode:U.parent;if(!Y||Y.nodeType!==11)return Y;if(!Fe){Fe=new WeakMap;let pe=ye=>{for(let me of ye.querySelectorAll("template"))me.content&&(Fe.set(me.content,me),pe(me.content))};for(let ye of[e,t])pe(ye.tagName==="TEMPLATE"&&ye.content?ye.content:ye)}return Fe.get(Y)||null},Ae=(U,Y)=>{for(let pe=ce(U);pe&&!Ce.has(pe);pe=ce(pe))Ce.add(pe);for(let pe=ce(Y);pe&&!Me.has(pe);pe=ce(pe))Me.add(pe)},Ue=U=>{for(let Y=ce(U);Y;Y=ce(Y))if(w.has(Y))return M.has(Y);return!1},_e=U=>{for(let Y=ce(U);Y;Y=ce(Y)){let pe=v.get(Y);if(pe!==void 0)return M.has(pe)}return!1},O=U=>!!U&&U.nodeType===1,X=(U,Y)=>{let pe=N.get(U);return!!pe&&pe.has(Y)},le=U=>Yl.has(U.tagName),re=n.comparisons||n.scope,Pe=(U,Y)=>{if(re){if(re.same.get(U)===Y)return!0;if(re.differ.get(U)===Y)return!1}if(!U.isEqualNode(Y))return!1;if(U.tagName==="TEMPLATE")return c(U,Y);let pe=U.getElementsByTagName("template");if(pe.length===0)return!0;let ye=Y.getElementsByTagName("template");if(pe.length!==ye.length)return!1;for(let me=0;me<pe.length;me++)if(!c(pe[me],ye[me]))return!1;return!0},Be=(U,Y)=>{let pe=u(U);if(!pe)return!0;let ye=f(Y);return!ye||pe===ye},Te=U=>{let Y=p(U);return Y&&n.baseIndex.get(Y)===U&&!g.has(Y)?Y:null},ot=U=>{let Y=m(U);return Y&&n.sideIndex.get(Y)===U&&!k.has(Y)?Y:null},et=(U,Y)=>{let pe=Te(U);if(!pe)return!0;let ye=ot(Y);return!ye||pe===ye},ae=globalThis.__hyperMorphProfile,de=ae?performance.now():0;ae&&!n.scope&&(r(e),r(t),ae.meta=(ae.meta||0)+(performance.now()-de),de=performance.now()),V(e,t);let Ee=new Set;for(let[U,Y]of n.baseIndex){let pe=n.sideIndex.get(U);pe&&pe.tagName===Y.tagName&&!w.has(Y)&&!v.has(pe)&&(V(Y,pe),Ae(Y,pe),Ee.add(Y))}if(Ee.size){let U=[];if(n.scope)for(let me of n.scope.chain)Ee.has(me)&&U.push(me);let Y=[n.scope?n.scope.root:e];for(;Y.length;){let me=Y.pop();Ee.has(me)&&U.push(me);let ee=a(me);for(let te=ee.length-1;te>=0;te--)ee[te].nodeType===1&&Y.push(ee[te])}let pe=new Set;for(let me=U.length-1;me>=0;me--){let ee=U[me];n.scope&&n.scope.onChain.has(ee)?pe.add(ee):Ft(ee,w.get(ee),pe)?(M.add(ee),j.add(ee),h&&h.certificationPairs++):pe.add(ee)}let ye=new Set;for(let me of U)M.has(me)&&!ye.has(me)&&Ge(me,ye)}n.scope&&n.scope.head&&Yt(n.scope.head[0],n.scope.head[1]);function Ge(U,Y){let pe=[U];for(;pe.length;){let ye=pe.pop();if(!Y.has(ye)){Y.add(ye),C(ye);for(let me of o(ye))O(me)&&w.has(me)&&pe.push(me)}}}S.push([e,t]);for(let[U,Y]of w)O(U)&&U!==e&&S.push([U,Y]);return pt(),Ve(),ae&&(ae.align=(ae.align||0)+(performance.now()-de)),{map:w,reverse:v,moved:_,identical:M,pairIdenticalChildren:C,weak:E,unpair:ze,rematch:Ve,insertedByHash:lt,refused:A,identityPaired:Ee};function Ve(){Ne(),pt();for(let U=0;U<B.length;){let Y=B.length;vt(U,Y),U=Y,pt(),Ne(),pt()}}function ze(U){let Y=w.get(U);if(!Y)return;N.has(U)||N.set(U,new Set),N.get(U).add(Y);let pe=(me,ee)=>{w.delete(me),v.delete(ee),_.delete(me),M.delete(me),E.delete(me),j.delete(me)},ye=(me,ee)=>{for(let te of o(me)){let W=w.get(te);!W||Ee.has(te)||!(O(W)?ee.contains(W):ee.contains(W.nodes[0]))||(pe(te,W),O(te)&&ye(te,W))}};pe(U,Y),O(U)&&ye(U,Y),R.push(U),D.push(Y)}function lt(){let U=new Map;for(let Y of new Set(D)){if(v.has(Y))continue;let pe=r(Y).hash;U.has(pe)||U.set(pe,[]),U.get(pe).push(Y)}return U}function pt(){for(;S.length;){let[U,Y]=S.shift();w.get(U)!==Y||j.has(U)||M.has(U)||dt(U,Y)}}function Rt(U,Y){if(!le(U))for(let pe of o(U))O(pe)&&(Y.push(pe),Rt(pe,Y))}function dt(U,Y){j.add(U);let pe=o(U),ye=o(Y);pi.align+=pe.length+ye.length,J=new Map,q=new Map;for(let ne=0;ne<pe.length;ne++)J.set(pe[ne],ne);for(let ne=0;ne<ye.length;ne++)q.set(ye[ne],ne);if(U.tagName==="HTML")for(let ne of["HEAD","BODY"]){let we=pe.find(je=>O(je)&&je.tagName===ne),Ie=ye.find(je=>O(je)&&je.tagName===ne);we&&Ie&&!w.has(we)&&!v.has(Ie)&&V(we,Ie)}for(let ne=0;ne<pe.length&&ne<ye.length;ne++){let we=pe[ne],Ie=ye[ne];w.has(we)||v.has(Ie)||(O(we)?O(Ie)&&we.tagName===Ie.tagName&&Pe(we,Ie)&&Yt(we,Ie):!O(Ie)&&we.kind===Ie.kind&&we.value===Ie.value&&Yt(we,Ie))}ie(pe,ye);let me=pe.filter(ne=>!w.has(ne)),ee=ye.filter(ne=>!v.has(ne));me.length&&ee.length&&(kn(me,ee),L(me,ee),$(me,ee,pe,ye),he(pe,ye));let te=!1,W=!1;for(let ne of pe){if(!w.has(ne)){O(ne)&&(R.push(ne),Rt(ne,R),te=!0);continue}O(ne)&&!M.has(ne)&&S.push([ne,w.get(ne)])}for(let ne of ye)!v.has(ne)&&O(ne)&&(D.push(ne),Rt(ne,D),W=!0);te&&W&&B.push([U,Y])}function vt(U,Y){for(let pe=U;pe<Y;pe++){let[ye,me]=B[pe];if(w.get(ye)!==me)continue;let ee=o(ye),te=o(me),W=new Map,ne=new Map,we=null;for(let Ie of ee)O(Ie)&&(w.has(Ie)?we=Ie:(W.has(we)||W.set(we,[]),W.get(we).push(Ie)));we=null;for(let Ie of te)O(Ie)&&(v.has(Ie)?we=v.get(Ie):(ne.has(we)||ne.set(we,[]),ne.get(we).push(Ie)));for(let[Ie,je]of W){let Se=ne.get(Ie);if(!(!Se||je.length!==Se.length)&&je.every((Je,nt)=>Se[nt].tagName===Je.tagName&&Be(Je,Se[nt])&&!X(Je,Se[nt])))for(let Je=0;Je<je.length;Je++)gt(je[Je],Se[Je])}}}function gt(U,Y){V(U,Y),E.add(U),S.push([U,Y]),pt()}function kn(U,Y){let pe=Dr(U,s),ye=Dr(Y,s),me=new Map;for(let ee of Y){let te=s(ee);ye.get(te)===1&&me.set(te,ee)}for(let ee of U){if(w.has(ee))continue;let te=s(ee);if(pe.get(te)!==1)continue;let W=me.get(te);W&&!v.has(W)&&c(ee,W)&&Yt(ee,W)}}function Ft(U,Y,pe){let ye=[[U,Y]];for(;ye.length;){let[me,ee]=ye.pop();if(pi.certifyVisited++,h&&h.certificationVisited++,me.nodeType!==ee.nodeType)return!1;if(me.nodeType===3||me.nodeType===8){if(me.nodeValue!==ee.nodeValue)return!1;continue}if(me.nodeType!==1){if(!me.isEqualNode(ee))return!1;continue}if(me.tagName!==ee.tagName||me.namespaceURI!==ee.namespaceURI||d(me)!==d(ee))return!1;let te=me.attributes,W=ee.attributes;if(te.length!==W.length)return!1;for(let Se=0;Se<te.length;Se++){let Je=te[Se];if(ee.getAttributeNS(Je.namespaceURI,Je.localName)!==Je.value)return!1}let ne=w.get(me);if(ne!==void 0&&ne!==ee)return!1;let we=v.get(ee);if(we!==void 0&&we!==me)return!1;if(me!==U){if(M.has(me))continue;if(pe.has(me))return!1}let Ie=a(me),je=a(ee);if(Ie.length!==je.length)return!1;pi.certifyScheduled+=Ie.length;for(let Se=Ie.length-1;Se>=0;Se--)ye.push([Ie[Se],je[Se]])}return!0}function Qt(U,Y){return!O(U)||!(Ce.has(U)||Me.has(Y))?!0:!!K(U,Y)||!(Te(U)||ot(Y))}function Yt(U,Y){if(O(U)&&(Ce.has(U)||Me.has(Y))){let pe=K(U,Y);if(!pe){if(Te(U)||ot(Y))return;V(U,Y),S.push([U,Y]);return}for(let ye=0;ye<pe.length;ye+=2){let me=pe[ye],ee=pe[ye+1],te=w.get(me);te!==void 0&&te!==ee&&gn(me,te);let W=v.get(ee);W!==void 0&&W!==me&&gn(W,ee),w.get(me)===ee&&(_.delete(me),E.delete(me),M.add(me),j.add(me))}}b(U,Y)}function gn(U,Y){w.delete(U),v.delete(Y),_.delete(U),M.delete(U),E.delete(U),j.delete(U)}function K(U,Y){let pe=[U,Y,!1],ye=[];for(;pe.length;){let me=pe.pop(),ee=pe.pop(),te=pe.pop(),W=w.get(te),ne=v.get(ee);if(te!==U&&(W!==void 0&&W!==ee&&Ee.has(te)||ne!==void 0&&ne!==te&&Ee.has(ne)))return null;if(!(W===ee&&M.has(te))&&((W!==void 0||ne!==void 0)&&ye.push(te,ee),!!O(te))){if(me||W!==void 0&&W!==ee||ne!==void 0&&ne!==te){let we=o(te),Ie=o(ee);for(let je=0;je<we.length&&je<Ie.length;je++)pe.push(we[je],Ie[je],!0)}else if(Ce.has(te)||Me.has(ee)){let we=te.tagName==="TEMPLATE"?te.content:te,Ie=ee.tagName==="TEMPLATE"?ee.content:ee;for(let je=we.firstElementChild,Se=Ie.firstElementChild;je&&Se;){if(d(je)){je=je.nextElementSibling;continue}if(d(Se)){Se=Se.nextElementSibling;continue}(w.has(je)||v.has(Se)||Ce.has(je)||Me.has(Se))&&pe.push(je,Se,!1),je=je.nextElementSibling,Se=Se.nextElementSibling}}}}return ye}function b(U,Y){V(U,Y),M.add(U),O(U)&&j.add(U)}function C(U){let Y=w.get(U);if(!Y||!O(U))return;let pe=o(U),ye=o(Y);for(let me=0;me<pe.length&&me<ye.length;me++)w.has(pe[me])||b(pe[me],ye[me])}function L(U,Y){let pe=te=>O(te)&&!le(te)?r(te).sig+""+r(te).hint:null,ye=Dr(U,pe),me=Dr(Y,pe),ee=new Map;for(let te of Y){let W=pe(te);W!=null&&me.get(W)===1&&ee.set(W,te)}for(let te of U){if(w.has(te))continue;let W=pe(te);if(W==null||ye.get(W)!==1)continue;let ne=ee.get(W);ne&&!v.has(ne)&&Be(te,ne)&&V(te,ne)}}function $(U,Y,pe,ye){let me=new Map;for(let te of Y){if(!O(te)||v.has(te)||le(te))continue;let W=r(te).sig;me.has(W)||me.set(W,[]),me.get(W).push({el:te,index:q.get(te)})}let ee=[];for(let te of U){if(w.has(te)||!O(te)||le(te))continue;let W=me.get(r(te).sig);if(!W||!W.length)continue;let ne=J.get(te),we=W.filter(Ie=>!v.has(Ie.el)).map(Ie=>({c:Ie,d:Math.abs(Ie.index-ne)}));we.sort((Ie,je)=>Ie.d-je.d),we.length>Jl&&(we=we.slice(0,Jl));for(let{c:Ie,d:je}of we){if(!Be(te,Ie.el))continue;let Se=l(te,Ie.el);Se&&Se.coef>=.5&&ee.push({b:te,s:Ie.el,coef:Se.coef,share:Se.share,d:je,bi:ne})}}if(ee.sort((te,W)=>W.coef-te.coef||W.share-te.share||te.d-W.d||te.bi-W.bi),h&&ee.length>1){let te=new Map;for(let W of ee){let ne=te.get(W.b);ne?ne.coef===W.coef&&(ne.share===W.share?ne.strict++:ne.loose++):te.set(W.b,{coef:W.coef,share:W.share,strict:0,loose:0})}for(let[W,ne]of te)y.has(W)||!(ne.strict||ne.loose)||(y.add(W),ne.strict?h.similarTiesStrict++:h.similarTiesLoose++)}for(let te of ee)!w.has(te.b)&&!v.has(te.s)&&V(te.b,te.s)}function Q(U,Y){return O(U)!==O(Y)?!1:O(U)?U.tagName!==Y.tagName||!Be(U,Y)?!1:le(U)||r(U).hint===""||r(Y).hint===""?!0:i(U,Y):U.kind===Y.kind}function F(U,Y){let pe=(me,ee)=>{let te=ee===null?-1:me===Y?q.get(ee):J.get(ee),W=me[te+1];return W&&!O(W)?W:null},ye=null;for(let me of U){if(O(me)){ye=me;continue}if(w.has(me))continue;let ee=ye===null?null:w.get(ye);if(ye!==null&&!ee)continue;let te=pe(Y,ee);te&&!v.has(te)&&te.kind===me.kind&&V(me,te)}}function he(U,Y){F(U,Y);let pe=ke(U,Y),ye=(ee,te)=>O(ee)&&r(ee).hint!==""&&r(te).hint===""&&!!te.querySelector("br")&&!pe(ee,te),me=0;for(let ee of U){if(w.has(ee)){let W=q.get(w.get(ee));W!==void 0&&W>=me&&(me=W+1);continue}let te=0;for(let W=me;W<Y.length&&te<Uu;W++){let ne=Y[W];if(!v.has(ne)&&(te++,Q(ee,ne)&&!X(ee,ne)&&!ye(ee,ne))){V(ee,ne),O(ee)&&(r(ee).hint===""||r(ne).hint==="")&&E.add(ee),me=W+1;break}}}ie(U,Y)}function ke(U,Y){let pe=(ye,me,ee)=>{for(let te=me-1;te>=0;te--)if(O(ye[te])&&ee(ye[te]))return ye[te];return null};return(ye,me)=>{let ee=J.get(ye),te=q.get(me);if(ee===te)return!0;let W=pe(U,ee,we=>w.has(we)),ne=pe(Y,te,we=>v.has(we));return W?w.get(W)===ne:!ne}}function ie(U,Y){let pe=U.filter(W=>O(W)&&!w.has(W)),ye=Y.filter(W=>O(W)&&!v.has(W));if(!pe.length||!ye.length)return;let me=Dr(pe,W=>W.tagName),ee=Dr(ye,W=>W.tagName),te=ke(U,Y);for(let W of pe){let ne=W.tagName;if(me.get(ne)!==1||ee.get(ne)!==1)continue;let we=ye.find(Ie=>Ie.tagName===ne);we&&!v.has(we)&&te(W,we)&&Be(W,we)&&!X(W,we)&&(c(W,we)?Yt(W,we):(V(W,we),E.add(W)))}}function Ne(){let U=new Map;for(let W of E)if(O(W)&&O(w.get(W))){let ne=r(W).hash;U.has(ne)||U.set(ne,[]),U.get(ne).push(W)}if(U.size)for(let W of D){if(v.has(W)||!O(W)||_e(W))continue;let ne=U.get(r(W).hash),we=ne&&ne.find(Ie=>E.has(Ie)&&!X(Ie,W)&&Be(Ie,W)&&et(Ie,W)&&c(Ie,W)&&Qt(Ie,W));we&&(ze(we),Yt(we,W),Ae(we,W),_.add(we))}let Y=new Map,pe=new Map,ye=new Map;for(let W of E){let ne=w.get(W);O(W)&&O(ne)&&ye.set(ne,W)}let me=(W,ne)=>{if(!v.has(W))return!_e(W);let we=ye.get(W);return we===v.get(W)&&we!==ne&&!we.contains(ne)},ee=W=>{if(v.has(W)){let ne=ye.get(W);ye.delete(W),ze(ne)}};for(let W of[...D,...ye.keys()]){if(v.has(W)&&!ye.has(W))continue;let ne=r(W).hash;if(Y.has(ne)||Y.set(ne,[]),Y.get(ne).push(W),le(W))continue;let we=r(W).sig;pe.has(we)||pe.set(we,[]),pe.get(we).push(W)}let te=new Set;for(let W of E){let ne=w.get(W);!O(W)||!O(ne)||le(W)||r(W).hint===""||r(ne).hint===""||i(W,ne)||te.add(W)}for(let W of[...R,...te]){let ne=w.get(W);if(ne?!(E.has(W)&&te.has(W)):Ue(W))continue;let we=nt=>{ne&&ze(W),ee(nt)},Ie=Y.get(r(W).hash);if(Ie){let nt=Ie.find(st=>st!==ne&&me(st,W)&&!X(W,st)&&et(W,st)&&c(W,st)&&Qt(W,st));if(nt){we(nt),Yt(W,nt),Ae(W,nt),_.add(W);continue}}if(le(W)||T<=0)continue;let je=pe.get(r(W).sig);if(!je)continue;let Se=null,Je=0;for(let nt of je)if(!(nt===ne||!me(nt,W)||!Be(W,nt)||!et(W,nt)||X(W,nt))&&(T--<=0||i(W,nt)&&(Je++,Se=nt,Je>1)))break;Je>1&&A&&A.add(W),Je===1&&(we(Se),V(W,Se),Ae(W,Se),_.add(W),S.push([W,Se]))}}}function Dr(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 $u={diff:0},Zl=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,Hu=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,zu=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,Vu=/\P{M}\p{M}*/gu;function Wu(e){if(e==="")return[];if(Zl){let n=[];for(let r of Zl.segment(e))n.push(r.segment);return n}let t=[];for(let n of e.match(zu))if(Hu.test(n))for(let r of n.match(Vu))t.push(r);else t.push(n);return t}var Ku=/^[ ]+$/,Gu=e=>Ku.test(e)?" ".repeat(e.length):e,cr=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),Ot="",bi=e=>e.every(t=>cr(t)||t.k===Ot),Yu=/^[\x00-\x7f\u00A0]*$/,Xu=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Ju(e){return e===""?[]:e.match(Xu)}function pn(e,t=!1){return(t?Ju(e):Wu(e)).map(n=>({k:Gu(n),raw:n,len:n.length}))}var _n=(...e)=>e.every(t=>Yu.test(t));function yi(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=[],c=r===0&&o===0;for(let p=0;p<=s&&!c;p++){a.push(l.slice(i-p,i+p+1));for(let m=-p;m<=p;m+=2){let k;m===-p||m!==p&&l[i+m-1]<l[i+m+1]?k=l[i+m+1]:k=l[i+m-1]+1;let g=k-m,h=k;for(;k<r&&g<o&&e[k].k===t[g].k;)k++,g++;if($u.diff+=1+k-h,l[i+m]=k,k>=r&&g>=o){c=!0;break}}}if(!c)return null;let d=[],u=r,f=o;for(let p=a.length-1;p>0;p--){let m=a[p],k=u-f,g=k+p,h=k===-p||k!==p&&m[g-1]<m[g+1]?k+1:k-1,y=m[h+p],A=y-h;for(;u>y&&f>A;)d.push([0,u-1,f-1]),u--,f--;u===y?(d.push([1,u,f-1]),f--):(d.push([-1,u-1,f]),u--)}for(;u>0&&f>0;)d.push([0,u-1,f-1]),u--,f--;return d.reverse(),d}function Zu(e,t,n){let r=u=>u.k===Ot;if(!e.some(r)&&!t.some(r))return yi(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 i=yi(o.map(u=>e[u]),s.map(u=>t[u]),n);if(!i)return null;let l=[],a=0,c=0,d=(u,f)=>{for(;a<u&&c<f&&e[a].k===t[c].k;)l.push([0,a++,c++]);let p=yi(e.slice(a,u),t.slice(c,f),n);if(!p)return!1;for(let[m,k,g]of p)l.push([m,k+a,g+c]);return a=u,c=f,!0};for(let[u,f,p]of i)if(u===0){if(!d(o[f],s[p]))return null;l.push([0,a,c]),a++,c++}return d(e.length,t.length)?l:null}function Zn(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=od(i,l)?null:Zu(i,l,n);if(!a){let h=i.length||l.length?[{bs:o,be:o+i.length,toks:l}]:[];return{hunks:h,cosmetic:r,coarse:!0,parts:h.map(y=>({...y,gap:[],group:0})),cosmeticEq:r}}let c=[],d=(h,y)=>{i[h].raw!==l[y].raw&&r.push({bi:o+h,tok:l[y]})},u=null,f=[],p=0,m=0,k=()=>{u&&c.push(u),u=null;for(let[h,y]of f)d(h,y);f=[],p++};for(let[h,y,A]of a){if(h===0){u&&cr(i[y])&&!i[y].k.includes(`
|
|
2
|
+
`)?f.push([y,A]):(k(),d(y,A)),m=y+1;continue}(!u||f.length)&&(u&&c.push(u),u={bs:o+m,be:o+m,toks:[],gap:f.map(([w,v])=>({bi:o+w,tok:l[v]})),group:p},f=[]),h===-1?(u.be=o+m+1,m=y+1):u.toks.push(l[A])}k(),Qu(c,e);let g=xi(c);return{hunks:g.hunks,cosmetic:r.concat(g.cosmetic),parts:c,cosmeticEq:r}}function Qu(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===Ot&&t[r.bs].k===Ot;)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===Ot&&t[r.be].k===Ot;)r.bs++,r.be++}}function xi(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 ed=(e,t)=>e.bs===t.bs&&e.be===t.be&&Ai(e.toks,t.toks);function wi(e,t,n){let r=d=>u=>d.some(f=>ed(u,f)),o=xi(e.parts,r(t.parts)),s=xi(t.parts,r(e.parts)),i=e.cosmeticEq.concat(o.cosmetic),l=t.cosmeticEq.concat(s.cosmetic),[a,c]=n?td(o.hunks,s.hunks,n,i,l):[o.hunks,s.hunks];return{lh:a,rh:c,cosL:i,cosR:l}}function td(e,t,n,r,o){let s=(m,k)=>m.k===k.k&&m.raw===k.raw,i=[{list:e.map(m=>({...m})),resp:new Set(r.map(m=>m.bi)),raw:new Map(r.map(m=>[m.bi,m.tok]))},{list:t.map(m=>({...m})),resp:new Set(o.map(m=>m.bi)),raw:new Map(o.map(m=>[m.bi,m.tok]))}],l=m=>m.bs===m.be,a=(m,k,g,h)=>{let y=m.list[k];if(!l(y))return h(y)===g?y.toks:null;let A=k?m.list[k-1].be:0,w=k+1<m.list.length?m.list[k+1].bs:n.length;if(g<A||g>w)return null;let v=y.toks,E=y.bs;for(;E>g;){let N=v[v.length-1];if(!s(N,n[E-1])||m.resp.has(E-1))return null;v=[N,...v.slice(0,-1)],E--}for(;E<g;){if(!s(v[0],n[E])||m.resp.has(E))return null;v=[...v.slice(1),v[0]],E++}return v},c=(m,k,g,h,y,A)=>{let w=m.list[k],v=y?g.slice(g.length-h):g.slice(0,h),E=y?g.slice(0,g.length-h):g.slice(h),N={bs:A,be:A,toks:v};if(l(w)){if(!E.length){m.list[k]=N;return}let M={bs:A,be:A,toks:E};y&&(M.lead=!0),m.list.splice(k,1,...y?[M,N]:[N,M]);return}let _={bs:w.bs,be:w.be,toks:E};m.list.splice(k,1,...y?[_,N]:[N,_])},d=(m,k,g,h,y)=>{let A=m.list[k],w=y?g.slice(g.length-h):g.slice(0,h),v=y?g.slice(0,g.length-h):g.slice(h),E={bs:A.bs,be:A.be,toks:w};if(!v.length){m.list[k]=E;return}let N=y?{bs:A.bs,be:A.bs,toks:v,lead:!0}:{bs:A.be,be:A.be,toks:v};m.list.splice(k,1,...y?[N,E]:[E,N])},u=(m,k,g,h)=>{let y=m.list[k],A=g.list[h],w=y.be,v=A.bs;if(w>=v||k+1<m.list.length&&m.list[k+1].bs<=A.be||h>0&&g.list[h-1].be>=y.bs)return!1;for(let q=w;q<v;q++)if(!cr(n[q])||n[q].k.includes(`
|
|
3
|
+
`))return!1;let E=q=>n.slice(w,v).map((V,Ce)=>q.raw.get(w+Ce)||V),N=[...y.toks,...E(m)],_=[...E(g),...A.toks],M=(q,V,Ce)=>V>=0&&V+Ce.length<=q.length&&Ce.every((Me,Fe)=>q[V+Fe].k===Me.k),j=(q,V,Ce)=>bi(q)&&n.slice(V,Ce).some(Me=>!cr(Me)),R=q=>q.some(V=>!cr(V)),D,B,S,T;if(l(y)&&R(y.toks)&&M(_,0,y.toks)){let q=_.slice(y.toks.length);j(q,w,A.be)||(D=w,B=y.toks,S=_.slice(0,y.toks.length),T=[null,{bs:w,be:A.be,toks:q}])}if(D===void 0&&l(A)&&R(A.toks)){let q=N.length-A.toks.length,V=N.slice(0,q);M(N,q,A.toks)&&!j(V,y.bs,v)&&(D=v,B=N.slice(q),S=A.toks,T=[{bs:y.bs,be:v,toks:V},null])}if(D===void 0)return!1;let J=q=>q&&(q.bs<q.be||q.toks.length);return m.list.splice(k,1,...[T[0],{bs:D,be:D,toks:B}].filter(J)),g.list.splice(h,1,...[{bs:D,be:D,toks:S},T[1]].filter(J)),!0},f=i[0],p=i[1];for(let m=0;m<64;m++){let k=!1;e:for(let g=0;g<f.list.length;g++)for(let h=0;h<p.list.length;h++){let y=f.list[g],A=p.list[h];if(!(y.bs===A.bs&&y.be===A.be&&Ai(y.toks,A.toks))){for(let w of[!0,!1]){let v=N=>w?N.be:N.bs,E=l(y)?[v(A),y.bs]:[v(y)];for(let N of E){let _=a(f,g,N,v),M=_&&a(p,h,N,v);if(!M)continue;let j=(T,J)=>w?T[T.length-1-J]:T[J],R=0;for(;R<_.length&&R<M.length&&j(_,R).k===j(M,R).k;)R++;if(!R)continue;let D=w?_.slice(0,_.length-R):_.slice(R),B=w?M.slice(0,M.length-R):M.slice(R);if(!(R<_.length&&R<M.length&&!bi(D)&&!bi(B)&&(l(y)&&l(A)||y.bs===A.bs&&y.be===A.be)||!(w?_.slice(_.length-R):_.slice(0,R)).some(T=>!cr(T)))){if(R===_.length&&R===M.length&&l(y)&&l(A)){if(y.bs===N&&A.bs===N)continue;f.list[g]={bs:N,be:N,toks:_},p.list[h]={bs:N,be:N,toks:M}}else!l(y)&&y.bs===A.bs&&y.be===A.be?(d(f,g,_,R,w),d(p,h,M,R,w)):(c(f,g,_,R,w,N),c(p,h,M,R,w,N));k=!0;break e}}}if(u(f,g,p,h)||u(p,h,f,g)){k=!0;break e}}}if(!k)break}return[f.list,p.list]}var nd=48,rd=.3;function od(e,t){let n=e.filter(i=>!cr(i)),r=t.filter(i=>!cr(i));if(Math.min(n.length,r.length)<nd)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)<rd}var sd=(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},Ai=(e,t)=>e.length===t.length&&e.every((n,r)=>n.k===t[r].k);function Ql(e,t,n,r="remote"){let o=Zn(e,t),s=Zn(e,n),{lh:i,rh:l,cosL:a,cosR:c}=wi(o,s,e),d=O=>O.bs===O.be,u=O=>O.toks.some(X=>typeof X.k=="string"),f=O=>d(O)&&!u(O),p=(O,X)=>X.bs<O.be&&O.bs<X.be,m=(O,X)=>!p(O,X)&&X.bs<=O.be&&O.bs<=X.be&&(d(O)&&u(O)||d(X)&&u(X))&&!(d(O)&&d(X)),k=(O,X)=>O.bs===X.bs&&O.be===X.be&&Ai(O.toks,X.toks),g=[],h=new Set;for(let O of i){let X=l.find(le=>!h.has(le)&&k(O,le));X?(h.add(X),g.push({bs:O.bs,be:O.be,side:"both",l:O,r:X,toks:O.toks})):g.push({bs:O.bs,be:O.be,side:"L",l:O,toks:O.toks,lead:!!O.lead})}for(let O of l)h.has(O)||g.push({bs:O.bs,be:O.be,side:"R",r:O,toks:O.toks,lead:!!O.lead});g.sort((O,X)=>O.bs-X.bs||O.be-X.be||X.lead-O.lead);let y=0,A=0;for(let O of g)O.side==="both"&&(y+=O.toks.length-(O.be-O.bs));let w=g.map((O,X)=>X),v=O=>w[O]===O?O:w[O]=v(w[O]),E=(O,X)=>(O=v(O),X=v(X),O===X?!1:(w[O]=X,!0)),N=g.map(O=>sd({bs:O.bs,be:O.be,toks:O.toks},e)),_={L:new Map,R:new Map};g.forEach((O,X)=>{let le=O.side==="both"?["L","R"]:[O.side];for(let re of le)for(let Pe of N[X])_[re].has(Pe)||_[re].set(Pe,[]),_[re].get(Pe).push(X)});for(let O of[_.L,_.R])for(let X of O.values())for(let le=1;le<X.length;le++)E(X[0],X[le]);for(let O=0;O<g.length;O++)for(let X=O+1;X<g.length;X++){let le=g[O],re=g[X];le.side===re.side&&le.side!=="both"||le.bs>re.be||(p(le,re)||m(le,re)?E(O,X):le.bs===re.bs&&d(le)&&d(re)&&A++)}let M=(O,X)=>{let le=O==="L"?i:l;for(let re of le)if(re.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===X.el))return re.bs;for(let re=0;re<e.length;re++)if(e[re].kind==="close"&&e[re].k.el===X.el)return re;return-1};g.forEach((O,X)=>{if(!(!f(O)||O.side==="both"))for(let le of O.toks){if(le.kind!=="open")continue;let re=M(O.side,le.k);if(re<=O.bs)continue;let Pe=new Uint8Array(re-O.bs),Be=[];if(g.forEach((Te,ot)=>{if(!(Te.side===O.side||d(Te))&&Te.bs<re&&Te.be>O.bs){Be.push(ot);for(let et=Math.max(Te.bs,O.bs);et<Math.min(Te.be,re);et++)Pe[et-O.bs]=1}}),Be.length&&Pe.every(Te=>Te===1))for(let Te of Be)E(X,Te)}});let j=!0;for(;j;){j=!1;let O=new Map;g.forEach((X,le)=>{let re=v(le),Pe=O.get(re)||{bs:X.bs,be:X.be,L:!1,R:!1};Pe.bs=Math.min(Pe.bs,X.bs),Pe.be=Math.max(Pe.be,X.be),X.side!=="R"&&(Pe.L=!0),X.side!=="L"&&(Pe.R=!0),O.set(re,Pe)}),g.forEach((X,le)=>{for(let[re,Pe]of O){if(v(le)===v(re)||!(Pe.L&&Pe.R))continue;let Be=X.bs<Pe.be&&X.be>Pe.bs,Te=d(X)&&u(X)&&(X.bs===Pe.be||X.bs===Pe.bs);(Be||Te)&&E(le,re)&&(j=!0)}})}let R=new Map;g.forEach((O,X)=>{let le=v(X);R.has(le)||R.set(le,[]),R.get(le).push(O)});let D=[];for(let O of R.values()){let X=O.some(re=>re.side==="L"),le=O.some(re=>re.side==="R");if(X&&le){let re=Math.min(...O.map(ot=>ot.bs)),Pe=Math.max(...O.map(ot=>ot.be)),Be=O.filter(ot=>ot.side!=="R").map(ot=>ot.l).sort((ot,et)=>ot.bs-et.bs),Te=O.filter(ot=>ot.side!=="L").map(ot=>ot.r).sort((ot,et)=>ot.bs-et.bs);D.push({bs:re,be:Pe,kind:"conflict",localHunks:Be,remoteHunks:Te})}else for(let re of O)D.push({bs:re.bs,be:re.be,kind:re.side,u:re})}let B=(O,X)=>{let le=O==="L"?i:l;for(let re of le)if(re.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===X.el))return re.bs+.5;for(let re=0;re<e.length;re++)if(e[re].kind==="close"&&e[re].k.el===X.el)return re;return 1/0},S=(O,X)=>{let le=O==="L"?i:l;for(let re of le)if(re.toks.some(Pe=>Pe.kind==="open"&&Pe.k.el===X.el))return re.bs-.5;for(let re=0;re<e.length;re++)if(e[re].kind==="open"&&e[re].k.el===X.el)return re;return-1/0},T=O=>O.kind==="R"?"R":"L",J=O=>O.kind==="R"?1:0;D.sort((O,X)=>{if(O.bs!==X.bs)return O.bs-X.bs;let le=O.bs===O.be,re=X.bs===X.be;if(le!==re)return le?-1:1;if(le&&re&&O.kind!=="conflict"&&X.kind!=="conflict"){let Be=O.u.toks,Te=X.u.toks,ot=ae=>ae.length&&ae.every(de=>de.kind==="open"),et=ae=>ae.length&&ae.every(de=>de.kind==="close");if(ot(Be)&&ot(Te)){let ae=Math.max(...Be.map(Ee=>B(T(O),Ee.k))),de=Math.max(...Te.map(Ee=>B(T(X),Ee.k)));if(ae!==de)return de-ae}if(et(Be)&&et(Te)){let ae=Math.min(...Be.map(Ee=>S(T(O),Ee.k))),de=Math.min(...Te.map(Ee=>S(T(X),Ee.k)));return ae!==de?de-ae:J(X)-J(O)}}let Pe=Be=>Be.u&&Be.u.lead?1:0;return Pe(X)-Pe(O)||J(O)-J(X)||O.be-X.be});let q=[],V=[],Ce=0,Me=O=>{O>Ce&&(q.push({bs:Ce,be:O,toks:e.slice(Ce,O),source:"base"}),Ce=O)};for(let O of D){if(Me(O.bs),O.kind==="conflict"){let X=vi(e,O.localHunks,O.bs,O.be),le=vi(e,O.remoteHunks,O.bs,O.be),re=r==="local"?X:r==="both"?X.concat(le):le,Pe=(ot,et)=>{let ae=0;for(let de of ot)de.be<=O.bs&&!et.includes(de)&&(ae+=de.toks.length-(de.be-de.bs));return ae},Be=O.bs+Pe(i,O.localHunks),Te=O.bs+Pe(l,O.remoteHunks);V.push({bs:O.bs,be:O.be,ls:Be,le:Be+X.length,rs:Te,re:Te+le.length,ms:0,me:0,base:e.slice(O.bs,O.be),local:X,remote:le,resolved:re}),q.push({bs:O.bs,be:O.be,toks:re,source:"conflict",localHunks:O.localHunks,localToks:X,keepsLocal:r!=="remote"})}else q.push({bs:O.bs,be:O.be,toks:O.u.toks,source:O.kind==="R"?"remote":"local",localHunks:O.kind==="R"?[]:[O.u.l]});Ce=Math.max(Ce,O.be)}Me(e.length);let Fe=0,ce=0;for(let O of q)O.source==="conflict"&&(V[ce].ms=Fe,V[ce].me=Fe+O.toks.length,ce++),Fe+=O.toks.length;let Ae=new Map(a.map(O=>[O.bi,O.tok])),Ue=new Map(c.map(O=>[O.bi,O.tok])),_e=[];for(let O of q){O.source==="base"&&(O.toks=O.toks.map((X,le)=>{let re=O.bs+le,Pe=Ae.get(re),Be=Ue.get(re),Te=Pe&&Be?r==="remote"?Be:Pe:Pe||Be||X;return Te===X?X:{...Te,cosmetic:!0}}));for(let X of O.toks)_e.push({...X,src:O.source})}return{tokens:_e,segments:q,conflicts:V,localHunks:i,remoteHunks:l,collapsedDelta:y,samePoint:A,mapLocalOffset:id(e,i,q)}}function vi(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 ki=e=>e.reduce((t,n)=>t+n.len,0);function id(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:ki(i.toks),source:i.source,localHunks:i.localHunks||[],localLen:i.localToks?ki(i.localToks):0,keepsLocal:i.keepsLocal,ref:i}));return i=>{let l=null,a=null,c=0,d=0,u=0;for(let p of o){let m=p.bs-u;if(i<=d+m){l=u+(i-d);break}if(d+=m,u=p.bs,i<=d+p.text.length){a=p,c=i-d,l=p.bs;break}d+=p.text.length,u=p.be}l===null&&(l=u+(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(c,p.len);if(!p.keepsLocal||!a)return f+p.len;let k=p.localHunks.indexOf(a.ref),g=ki(vi(e,p.localHunks.slice(0,k),p.ref.bs,a.ref.bs));return f+Math.min(g+c,p.localLen)}return f}}function vo(e,t,n,r="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:h=>Math.min(h,t.length),granularity:"word"};let o=_n(e,t,n),s=pn(e,o),i=pn(t,o),l=pn(n,o),a=s.length<=2e4&&i.length<=2e4&&l.length<=2e4?Ql(s,i,l,r):null,c="word",d=s;if(!a){let h=y=>y.split(/(?<=\n)/).map(A=>({k:A,raw:A,len:A.length}));d=h(e),a=Ql(d,h(t),h(n),r),c="line"}let u=h=>h.map(y=>y.raw).join(""),f=h=>{let y=[0];for(let A of h)y.push(y[y.length-1]+A.len);return y},p=f(d),m=null,k=null,g=null;if(a.conflicts.length){let h=y=>y.split(/(?<=\n)/).map(A=>({k:A,raw:A,len:A.length}));m=f(c==="line"?h(t):i),k=f(c==="line"?h(n):l),g=f(a.tokens)}return{text:u(a.tokens),conflicts:a.conflicts.map(h=>({bs:p[h.bs],be:p[h.be],ls:m[h.ls],le:m[h.le],rs:k[h.rs],re:k[h.re],ms:g[h.ms],me:g[h.me],base:u(h.base),local:u(h.local),remote:u(h.remote),resolved:u(h.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:c}}function wr(e,t,n=4e3){if(e===t)return[];let r=_n(e,t),o=pn(e,r),s=pn(t,r),i=Zn(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(c=>c.raw).join("")}))}function Zt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Gn({base:e,side:t,retained:n,transfers:r,baseAtomKey:o=l=>l.el,sideAtomKey:s=l=>l.el,budget:i=Zt()}){let l=[],a=v=>({status:"fallback",reason:v}),c=v=>v>i.remaining?!1:(i.remaining-=v,!0);if(!c((n.length+r.length)*3))return a("work-limit");for(let[v,E]of[["retained",n],["transfer",r]])for(let N of E){let{from:_,to:M,target:j}=N;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");l.push({...N,kind:v})}let d=Symbol(),u=v=>(E,N)=>{if(!c(1))throw d;return i.sortComparisons++,v(E,N)},f,p;try{f=l.slice().sort(u((v,E)=>v.from-E.from||v.to-E.to)),p=l.slice().sort(u((v,E)=>v.target-E.target||v.to-v.from-(E.to-E.from)))}catch(v){if(v===d)return a("work-limit");throw v}if(!c(l.length*2))return a("work-limit");for(let v=1;v<f.length;v++)if(f[v].from<f[v-1].to)return a("source-overlap");for(let v=1;v<p.length;v++)if(p[v].target<p[v-1].target+p[v-1].to-p[v-1].from)return a("target-overlap");for(let v of f){let E=v.to-v.from;if(!c(E))return a("work-limit");for(let N=0;N<E;N++){let _=v.from+N,M=v.target+N;if(i.comparisons++,e.text[_]!==t.text[M])return a("unequal-occurrence");let j=e.atomAt.get(_),R=t.atomAt.get(M);if(!!j!=!!R||j&&o(j)!==s(R))return a("different-atom")}}let m=e.text.length+t.text.length+2,k=l.reduce((v,E)=>v+(E.to-E.from)*2,2);if(!c(m+k+l.length))return a("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),h=new Int32Array(t.text.length+1).fill(-1);i.mapCells+=m,i.mapWrites+=k;let y=-1,A=!0;for(let v of f){v.target<y&&(A=!1),y=v.target+v.to-v.from;for(let E=0;E<v.to-v.from;E++)g[v.from+E]=v.target+E,h[v.target+E]=v.from+E}return g[e.text.length]=t.text.length,h[t.text.length]=e.text.length,{status:"ready",runs:f,bTo:g,toB:h,monotone:A,covers:(v,E)=>{if(!c(E-v))return null;i.coverageChecks+=E-v;for(let N=v;N<E;N++)if(e.text[N]!==Ot&&!/\s/.test(e.text[N])&&g[N]<0)return!1;return!0}}}function Si({base:e,side:t,baseOf:n=()=>null,budget:r=Zt()}){if(e.text===t.text||!e.text.includes(Ot)&&!t.text.includes(Ot))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=(m,k)=>k<m.length&&(m[k]===Ot||/\s/.test(m[k])),i=new Map,l=Symbol(),a=(m,k)=>{let g=m.stackAt[k]||[];if(!i.has(g)){if(g.length>r.remaining)throw l;r.remaining-=g.length,r.boundarySteps+=g.length,i.set(g,g.find(h=>h.block)?.el||null)}return i.get(g)},c=[],d=(m,k)=>{let g=a(e,m),h=a(t,k),y=g&&h&&n(h)!==g?"transfer":"retained",A=c[c.length-1];A&&A.to===m&&A.target+A.to-A.from===k&&A.kind===y&&A.destination===h?A.to++:c.push({from:m,to:m+1,target:k,destination:h,kind:y})},u=0,f=0,p=!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 A=e.atomAt.get(u),w=t.atomAt.get(f);if(!!A!=!!w||A&&n(w.el)!==A.el)return{status:"none"};d(u++,f++);continue}if(!s(e.text,u)&&!s(t.text,f))return{status:"none"};let m=u,k=f;for(;s(e.text,u);)u++;for(;s(t.text,f);)f++;let g=e.text.slice(m,u),h=t.text.slice(k,f);(g.includes(Ot)||h.includes(Ot))&&(p=!0);let y=0;for(;y<u-m&&y<f-k&&e.text[u-y-1]===t.text[f-y-1];)y++;for(let A=y;A>0;A--)d(u-A,f-A)}}catch(m){if(m===l)return{status:"fallback",reason:"work-limit"};throw m}return p?Gn({base:e,side:t,retained:c.filter(m=>m.kind==="retained"),transfers:c.filter(m=>m.kind==="transfer"),sideAtomKey:m=>n(m.el)||m.el,budget:r}):{status:"none"}}var ea=/\s/,ns=/\S/;function Fn(e,t,n,r,o,s,i=-1,l=-1){if(!e.length)return-1;o(r,e.length);let a=new Int32Array(e.length),c=0;for(let p=1;p<e.length;p++){for(o(r,1);c&&(o(r,1),e[c]!==e[p]);)c=a[c-1];o(r,1),e[c]===e[p]&&c++,a[p]=c}let d=-1,u=0,f=0;c=0;for(let p=0;p<t.length;p++){for(o(r,1);c&&(o(r,1),e[c]!==t[p]);)c=a[c-1];if(o(r,1),e[c]===t[p]&&c++,c!==e.length)continue;let m=p+1-e.length,k=p+1;for(c=a[c-1];u<n.length&&n[u].from<m;)o(r,1),u++;for(;f<n.length&&n[f].to<k;)o(r,1),f++;if(o(r,6),!(u===n.length||f===n.length||n[u].from!==m||n[f].to!==k||i>=0&&m<l&&k>i)){if(!s)return m;if(d>=0)return-1;d=m}}return d}function wo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function Ti(e,t,n,r){let o=null;for(let i of t)if(r(n,1),!(i.source!==e.source||i.side!==e.side))for(let l of i.runs){if(r(n,1),l.source!==e.source)continue;let a=Math.max(e.from,l.from),c=Math.min(e.to,l.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 i=e.from;i<e.to;i++)if(ns.test(e.flat.text[i])){if(!o[i-e.from])return!1;s=!0}return s}function Ei({source:e,side:t,views:n,eligible:r,blocked:o,baseId:s,model:i,tokensOf:l,budget:a,charge:c}){let{V:d,A:u,idOf:f}=n[t],p=n[1-t];if(e.nodeType!==1||u.identical.has(e)||p.A.identical.has(e)||o.has(e)||!r(e))return null;let m=d.twin(e),k=p.V.twin(e);if(!m||!k||u.map.get(e)!==m||u.reverse.get(m)!==e||p.A.map.get(e)!==k||p.A.reverse.get(k)!==e||!d.here(m)||!p.V.here(k)||!r(m)||!r(k))return null;let g=s(e);if(g!==f(m)||g!==p.idOf(k))return null;let h=i(e,null,a),y=i(m,u,a),A=i(k,p.A,a);if(!wo(h)||!wo(y)||!wo(A))return null;let w=h.flat.text,v=y.flat.text;if(c(a,w.length+v.length*3),!ns.test(v)||v.length>=w.length)return null;let E=w.startsWith(v),N=w.endsWith(v);if(E===N)return null;let _=E?v.length:0,M=E?w.length:w.length-v.length,j=_,R=M;for(;j<R&&(c(a,1),!!ea.test(w[j]));)j++;for(;R>j&&(c(a,1),!!ea.test(w[R-1]));)R--;if(j===R)return null;let D=l(h,a),B=!1,S=!1;for(let T of D)c(a,1),T.from===j&&(B=!0),T.to===R&&(S=!0);return!B||!S?null:{source:e,side:t,flat:h.flat,from:_,to:M}}function ta({base:e,views:t,side:n,attempt:r,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,certificates:c,charge:d,exhausted:u,limit:f}){if(f<=0)return null;let p=Zt(f),{V:m,A:k,idOf:g}=t[n],h=t[1-n],[y,A,w,v]=r,E=null;try{for(let N=y;N<=A;N++){d(p,1);let _=e[N];if(_.nodeType!==1||k.identical.has(_)||h.A.identical.has(_)||s.has(_)||!o(_))continue;let M=Ei({source:_,side:n,views:t,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,budget:p,charge:d});if(!M||Ti(M,c,p,d))continue;let{flat:j,from:R,to:D}=M;d(p,(D-R)*2);let B=j.text.slice(R,D).trim();for(let S=w;S<=v;S++){d(p,1);let T=m.units[S],J=m.baseOf(T);if(!J||J===_||J.nodeType!==1||T.nodeType!==1||J.parentNode!==_.parentNode||T.parentNode!==k.map.get(_).parentNode||k.map.get(J)!==T||k.reverse.get(T)!==J||s.has(J)||!o(J)||!o(T)||i(J)!==g(T))continue;let q=l(J,null,p),V=l(T,k,p);if(!wo(q)||!wo(V))continue;let Ce=q.flat.text,Me=V.flat.text;if(d(p,Ce.length),!ns.test(Ce)||Me.length<=Ce.length)continue;let Fe=a(V,p),ce=Fn(Ce,Me,Fe,p,d,!0);if(!(ce<0)&&!(Fn(B,Me,Fe,p,d,!1,ce,ce+Ce.length)<0)){(E||=[]).push(M);break}}}}catch(N){if(N!==u)throw N}return E}function na(e,t,n,r,o,s,i){if(s==="both"||n.atoms.length||r.atoms.length||o.atoms.length)return s;let l=s==="remote";if(l?i.rss!==i.rse||i.lss===i.lse||i.local===i.base:i.lss!==i.lse||i.rss===i.rse||i.remote===i.base)return s;for(let a of e){if(a.source!==t||a.side!==(l?1:0)||a.flat.text!==n.text||a.flat.nodes.length!==n.nodes.length||i.be<=a.from||i.bs>=a.to)continue;let c=!0;for(let u=0;u<n.nodes.length;u++){let f=a.flat.nodes[u],p=n.nodes[u];if(f.node!==p.node||f.s!==p.s||f.e!==p.e){c=!1;break}}if(!c)continue;let d=!1;for(let u=i.bs;u<i.be;u++)if(ns.test(n.text[u])){if(u<a.from||u>=a.to){c=!1;break}d=!0}if(c&&d)return l?"local":"remote"}return s}var Yn="\uFFFC";var ld={caret:0},Cn=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(" ")),fa=new Set(["BR","WBR","IMG"]),Oi=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 Xn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||fa.has(e.tagName))return!0;if(!Cn.has(e.tagName))return!Oi.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(!Xn(o,t)){r=!1;break}return t.inlineCache&&t.inlineCache.set(e,r),r}function ad(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function an(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 u=i.nodeValue;if(!u)continue;n.nodes.push({node:i,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(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]!==Ot&&(n.stackAt.push(s),n.text+=Ot);let u={el:i,tag:a,from:n.text.length,to:-1,depth:s.length,block:!0};n.marks.push(u);let f=s.concat([u]);r(l.childNodes,f),n.stackAt.push(f),n.text+=Ot,u.to=n.text.length;continue}let c=Cn.has(a)&&ad(l);if(fa.has(a)||!Cn.has(a)||t.remoteWins&&t.remoteWins(i)||t.atomize&&t.atomize(i)||c){n.atoms.push({i:n.text.length,el:i,key:c?a+":empty":a,stack:s}),n.stackAt.push(s),n.text+=Yn;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&&ss(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 cd(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function fd(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,""")}"`;return t+">"}function Br(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 c=i[o.length];r+=fd(c.el),o.push(c)}let a=e.atomAt.get(s);r+=a?a.el.outerHTML:e.text[s]===Ot?"":cd(e.text[s])}for(;o.length;)r+=`</${o.pop().tag.toLowerCase()}>`;return r}function ud(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 ua(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 ra(e,t=()=>!1){let n=new Map,r=s=>{let i=n.get(s);return i===void 0&&(i="{"+s.map(l=>ud(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?"["+ua(i.el,t)+"]":e.text[s])+r(e.stackAt[s])}return e.text.length===0&&e.placeholder&&(o+="[br]"),o}function Fr(e,t,n,r=o=>o.key){let o=[],s=e.text,i=0,l=a=>{if(a<=i)return;let c=s.slice(i,a);if(n)for(let d of c.split(/(?<=\n)/))o.push({k:d,raw:d,len:d.length});else for(let d of pn(c,t))o.push(d)};for(let a of e.atoms)l(a.i),o.push({k:"\0"+r(a),raw:Yn,len:1,atom:!0}),i=a.i+1;return l(s.length),o}function ss(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 qr=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 rs(e,t,n,r){let o=qr(t),s=qr(n),i=[],l=0,a=0;for(let d of r.hunks){a+=d.bs-l;let u=a+d.toks.length;i.push({bs:o[d.bs],be:o[d.be],ss:s[a],se:s[u],text:e.text.slice(s[a],s[u]),toks:d.toks,lead:!!d.lead}),a=u,l=d.be}let c=new Map;for(let d of r.cosmetic)c.set(d.bi,d.tok.raw);return{hunks:i,respell:c}}function oa(e,t,n){let r=i=>i===Ot||/\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(Ot)&&!a.includes(Ot)||l.includes(Yn)||a.includes(Yn)||o(l)!==o(a)){s.push(i);continue}let c=0,d=0;for(;;){let u=c,f=d;for(;u<l.length&&r(l[u]);)u++;for(;f<a.length&&r(a[f]);)f++;let p=c,m=d;for(;p<u&&m<f&&l[p]===a[m];)p++,m++;let k=u,g=f;for(;k>p&&g>m&&l[k-1]===a[g-1];)k--,g--;if(k>p||g>m){let h=a.slice(m,g);s.push({bs:i.bs+p,be:i.bs+k,ss:i.ss+m,se:i.ss+g,text:h,toks:[...h].map(y=>({k:y,raw:y,len:1})),lead:i.lead})}if(u>=l.length)break;c=u+1,d=f+1}}return s}function sa(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 ia(e,t,n){let r=[],o=0,s=0,i=(l,a)=>{if(o===l&&s===a)return;let c=t.text.slice(s,a);r.push({bs:o,be:l,ss:s,se:a,text:c,toks:pn(c,_n(c)),lead:!1})};for(let l of n.runs)i(l.from,l.target),o=l.to,s=l.target+l.to-l.from;return i(e.text.length,t.text.length),{hunks:r,respell:new Map}}function la(e,t,n,r){let o=qr(t),s=qr(n),i=(a,c)=>{let d=0,u=a.length;for(;d<u;){let f=d+u>>>1;a[f]<c?d=f+1:u=f}return a[d]===c?d:-1};for(let a of e.hunks)if(i(o,a.bs)<0||i(o,a.be)<0)return null;if(e.hunks.some(a=>i(s,a.ss)<0||i(s,a.se)<0)){if(!r)return null;let a=[];for(let f of e.hunks)a.push(f.ss,f.se);let c=[],d=0,u=0;for(let f of n){let p=u+f.len;for(;d<a.length&&a[d]<=u;)d++;let m=u;for(;d<a.length&&a[d]<p;){let k=a[d++];if(k>m){let g=f.raw.slice(m-u,k-u);c.push(...pn(g,_n(g))),m=k}}if(m===u)c.push(f);else{let k=f.raw.slice(m-u);c.push(...pn(k,_n(k)))}u=p}n=c,s=qr(n)}let l=[];for(let a of e.hunks){let c=i(o,a.bs),d=i(o,a.be),u=i(s,a.ss),f=i(s,a.se);if(c<0||d<0||u<0||f<0)return null;l.push({bs:c,be:d,toks:n.slice(u,f),gap:[],group:l.length})}return{parts:l,cosmeticEq:[],tokens:n}}function Ni(e,t,n,r={},o=null){return da(e,t,n,r.base,r.local,r.remote,o,{})}function da(e,t,n,r,o,s,i,l){let a=_n(ss(e),ss(t),ss(n)),c=Fr(e,a,!1,r),d=Fr(t,a,!1,o),u=Fr(n,a,!1,s),f=c.length>2e4||d.length>2e4||u.length>2e4;f&&(c=Fr(e,a,!0,r),d=Fr(t,a,!0,o),u=Fr(n,a,!0,s));let p=i?.local?ia(e,t,i.local):null,m=i?.remote?ia(e,n,i.remote):null,k=p?la(p,c,d,!f):Zn(c,d),g=m?la(m,c,u,!f):Zn(c,u);p&&k&&(d=k.tokens),m&&g&&(u=g.tokens);let h,y;if(k&&g){let A=wi(k,g,c);h=rs(t,c,d,{hunks:A.lh,cosmetic:A.cosL}),y=rs(n,c,u,{hunks:A.rh,cosmetic:A.cosR})}else h=p||rs(t,c,d,k),y=m||rs(n,c,u,g);return h.hunks=oa(h.hunks,e.text,t.text),y.hunks=oa(y.hunks,e.text,n.text),l.base=e,l.local=t,l.remote=n,l.lines=f,l.baseTokens=c,l.localEdits=h,l.remoteEdits=y,l.localMap=sa(h.hunks,e.text.length,t.text.length),l.remoteMap=sa(y.hunks,e.text.length,n.text.length),l.full=null,l}function aa(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Ur=/\s/;function os(e,t,n){for(let r=t;r<n;r++)if(!Ur.test(e[r]))return!1;return!0}function dd(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",i=t.baseMark,l=t[s+"Mark"],a=!t.block&&!t[o]&&!!l&&i.to>i.from;if(a){let c=n===0?e.ML:e.MR,d=n===0?e.MR:e.ML,u=n===0?e.fr:e.fl,f=!1;for(let p=i.from;p<i.to;p++){if(c.bTo[p]>=0){a=!1;break}d.bTo[p]<0&&!Ur.test(e.fb.text[p])&&(f=!0)}if(a&&!f){for(let p=l.from;p<l.to;p++)if(d.toB[p]<0&&!Ur.test(u.text[p])){f=!0;break}}a&&=f}return r.set(t,a),a}function ca(e,t,n,r,o,s,i,l,a){let c=l===0?e.fl:e.fr,d=null;for(let u=n;u<r;u++){let f=t[u];if(!os(c.text,f.ss,f.se))return null;if(os(e.fb.text,f.bs,f.be)){if(f.bs<f.be&&f.ss<f.se||Ur.test(e.fb.text[f.bs-1]||"")||Ur.test(e.fb.text[f.be]||""))continue;return null}let p=!1;for(let m=f.bs;m<f.be;m++){if(Ur.test(e.fb.text[m]))continue;let k=null;for(let g of e.fb.stackAt[m]){let h=e.byEl.get(g.el);if(h&&dd(e,h,l)){k=h;break}}if(!k)return null;(d||(d=new Set)).add(k),p=!0}if(!p)return null}if(!d){if((l===0?"local":"remote")!==a)return null;let u=l===0?e.fr:e.fl,f=!1;for(let p=s;p<i;p++){let m=o[p];if(!os(e.fb.text,m.bs,m.be))return null;os(u.text,m.ss,m.se)||(f=!0)}if(!f)return null}return d||0}function is(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||[],c=l.length,d=e.conflict||(x=>l.push(x)),u={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),m={base:null,local:null,remote:null};if(!e.prepared&&p&&e.moveIn){let x=Oe=>qe=>Oe.some(Le=>Le===qe||Le.nodeType===1&&Le.contains(qe)),P=x(e.local),H=x(e.remote),z=x(e.base),Z=new Set,ge=Oe=>{if(!Cn.has(Oe.tagName))return;let qe=r.map.get(Oe),Le=o.map.get(Oe);(qe&&!P(qe)||Le&&!H(Le))&&Z.add(Oe);for(let $e of Oe.children)ge($e)};for(let Oe of e.base)Oe.nodeType===1&&ge(Oe);let ve=Oe=>qe=>{if(!Cn.has(qe.tagName))return!1;let Le=Oe.reverse.get(qe);return!!Le&&(Z.has(Le)||!z(Le))};Z.size&&(m.base=Oe=>Z.has(Oe)),m.local=ve(r),m.remote=ve(o)}let k={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&p&&e.moveIn){let x=z=>Z=>z.some(ge=>ge===Z||ge.nodeType===1&&ge.contains(Z)),P=x(e.local),H=x(e.remote);for(let z of an(e.base,{...e,atomize:m.base}).atoms){let Z=r.map.get(z.el),ge=o.map.get(z.el),ve=!!Z&&!P(Z),Oe=!!ge&&!H(ge);!ve&&!Oe||(ve&&e.movePlanned?.(z.el,"local",Z,null),Oe&&e.movePlanned?.(z.el,"remote",ge,null),k.base.add(z.el),Z&&!ve&&k.local.add(Z),ge&&!Oe&&k.remote.add(ge),P(z.el)&&k.local.add(z.el),H(z.el)&&k.remote.add(z.el))}}let g=e.prepared?.base||an(e.base,{...e,atomize:m.base,skip:k.base}),h=e.prepared?.local||an(e.local,{...e,atomize:m.local,skip:k.local}),y=e.prepared?.remote||an(e.remote,{...e,atomize:m.remote,skip:k.remote}),A=new Map(g.atoms.map(x=>[x.el,x])),w={},v=x=>e.prepared?e.prepared.full?.(x)||null:k[x].size?(w[x]||(w[x]=an(e[x],{...e,atomize:m[x]})),w[x]):null,E=(x,P,H)=>{P.namespaceURI?x.setAttributeNS(P.namespaceURI,P.name,H):x.setAttribute(P.name,H)},N=(x,P,H,z)=>{if(!P&&(!H||!z)){for(let ge of(H||z).attributes)E(x,ge,ge.value);return}let Z=new Map;for(let ge of[P,H,z])if(ge)for(let ve of ge.attributes)Z.set(ve.name,ve);for(let[ge,ve]of Z){let Oe=P?P.getAttribute(ge):null,qe=H?H.getAttribute(ge):Oe,Le=z?z.getAttribute(ge):Oe,$e;qe===Le?$e=qe:qe===Oe?($e=Le,a.push({kind:"attr",el:x,name:ge,source:"remote"})):Le===Oe?($e=qe,a.push({kind:"attr",el:x,name:ge,source:"local"})):($e=n==="local"?qe:Le,d({kind:"attr",el:x,name:ge,base:Oe,local:qe,remote:Le,resolved:$e},{el:x,sample:ve}),a.push({kind:"attr",el:x,name:ge,source:"both"})),$e!=null&&E(x,ve,$e)}},_=(x,P,H,z)=>x&&e.mergeAttrs?e.mergeAttrs(x,P,H,z):N(z,x,P,H),M=e.mergeElement||((x,P,H)=>{let z=t.createElement(x.tagName);_(x,P,H,z);let Z=P||x,ge=H||x,ve=n==="local"?Z.isEqualNode(x)?ge:Z:ge.isEqualNode(x)?Z:ge;for(let Oe of ve.childNodes)z.appendChild(t.importNode(Oe,!0));return s.set(z,{base:x,local:P,remote:H}),z}),j=e.cloneUnit||((x,P)=>{let H=t.importNode(x,!0);return s.set(H,{base:null,local:P==="local"?x:null,remote:P==="remote"?x:null}),H}),R=e.atomKey||(x=>ua(x,()=>!1)),D=(x,P)=>{let H=new Map;for(let z of x.atoms)if(e.remoteWins&&e.remoteWins(z.el)&&Cn.has(z.el.tagName))H.set(z,"w"+z.el.tagName+"#"+(z.el.id||""));else if(!p)H.set(z,z.key);else if(x===g)H.set(z,"="+R(z.el));else{let Z=P.reverse.get(z.el),ge=Z?A.get(Z):null;ge?H.set(z,"="+R(ge.el)):Z?H.set(z,"m"+R(z.el)):H.set(z,"="+R(z.el))}return z=>H.get(z)},B=D(g,null),S=D(h,r),T=D(y,o),J=e.certifiedOrigins?e.certifiedOrigins(g,h,y,B,S,T):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let x=Zt(),P=Si({base:g,side:h,baseOf:z=>r?.reverse?.get(z)||null,budget:x}),H=Si({base:g,side:y,baseOf:z=>o?.reverse?.get(z)||null,budget:x});(P.status==="ready"||H.status==="ready")&&(J={local:P.status==="ready"?P:null,remote:H.status==="ready"?H:null})}let q=e.prepared||da(g,h,y,B,S,T,J,u),V=q.lines,Ce=q.baseTokens,Me=q.localEdits,Fe=q.remoteEdits,ce=q.localMap,Ae=q.remoteMap,Ue=g.text.length,_e=x=>new Map(x.atoms.map(P=>[P.el,P])),O=_e(h),X=_e(y),le=(x,P,H)=>{let z=new Set;if(!p)return z;for(let Z of x.atoms){let ge=A.get(P.reverse.get(Z.el));ge&&H.bTo[ge.i]<0&&z.add(ge)}return z},re=le(h,r,ce),Pe=le(y,o,Ae),Be=x=>!Xn(x,{...e,remoteWins:null}),Te=new Set;if(p)for(let x of g.atoms){if(!Be(x.el))continue;let P=r.map.get(x.el)||null,H=o.map.get(x.el)||null,z=P&&!H?P:H&&!P?H:null;z&&(O.has(z)||X.has(z))&&!z.isEqualNode(x.el)&&Te.add(x)}let ot=1,et=(x,P)=>({id:ot++,tag:x,base:null,local:null,remote:null,rank:P}),ae=new Map,de=[];for(let x of g.marks){let P=et(x.tag,x.depth);P.block=!!x.block,P.base=x.el,P.baseMark=x,ae.set(x.el,P),de.push(P)}let Ee=(x,P)=>{let H=-1,z=-1;for(let Z=x.from;Z<x.to;Z++){let ge=P[Z];ge>=0&&(H<0&&(H=ge),z=ge+1)}return H<0?null:[H,z]},Ge=(x,P,H,z)=>{for(let Z of x.marks){let ge=H?H.reverse.get(Z.el):null;ge&&H.identical.has(ge)&&H.pairIdenticalChildren&&H.pairIdenticalChildren(ge);let ve=ge?ae.get(ge):null;if(ve&&ve[P]&&(ve=null),!ve){let Oe=Ee(Z,z),qe=0;if(Oe)for(let Le of de){if(Le.tag!==Z.tag||Le[P]||!!Le.block!=!!Z.block)continue;let $e=Math.min(Oe[1],Le.baseMark.to)-Math.max(Oe[0],Le.baseMark.from);($e>qe||$e===qe&&$e>0&&Math.abs(Le.rank-Z.depth)<Math.abs(ve.rank-Z.depth))&&(ve=Le,qe=$e)}}ve||(ve=et(Z.tag,Z.depth),ve.block=!!Z.block,ve.new=P),ve[P]=Z.el,ve[P+"Mark"]=Z,ae.set(Z.el,ve)}};Ge(h,"local",r,ce.toB),Ge(y,"remote",o,Ae.toB);let Ve=x=>x.merged||x,ze=x=>{let P=new Set;for(let H of x)H.block||P.add(ae.get(H.el));return P},lt=new Map,pt=x=>{let P=lt.get(x);return P||(P=ze(x),lt.set(x,P)),P},Rt=(x,P)=>{let H=[],z=null;for(let Z=0;Z<Ue;Z++){let ge=P[Z];if(ge<0){z&&H.push(z),z=null;continue}let ve=pt(g.stackAt[Z]),Oe=pt(x.stackAt[ge]),qe=new Set,Le=new Set;for(let $e of Oe)ve.has($e)||qe.add($e);for(let $e of ve)Oe.has($e)||Le.add($e);if(!qe.size&&!Le.size){z&&H.push(z),z=null;continue}if(z&&aa(z.added,qe)&&aa(z.removed,Le)){z.be=Z+1;continue}z&&H.push(z),z={bs:Z,be:Z+1,added:qe,removed:Le}}return z&&H.push(z),H},dt=Rt(h,ce.bTo),vt=Rt(y,Ae.bTo),gt=x=>x.be>x.bs?[x.bs,x.be-1]:[x.bs-1,x.bs],kn=(x,P)=>{if(Ue===0)return null;let[H,z]=gt(x);for(let Z of P){if(Z.be<=H)continue;if(Z.bs>z)break;let ge=Z.bs<=H&&z<Z.be;return ge&&x.text===""&&Z.bs===x.bs&&Z.be===x.be?"straddle":ge?Z:x.be>x.bs?"straddle":null}return null},Ft=x=>x.bs===x.be,Qt=(x,P,H=null)=>{let z=!1;for(let Z=x.bs;Z<x.be;Z++){let ge=g.text[Z];if(ge===Ot)z=!0;else if(!/\s/.test(ge))return!1}for(let Z=x.ss;Z<x.se;Z++){let ge=P.text[Z];if(ge===Ot)z=!0;else if(!/\s/.test(ge)){let ve=H&&e.scopeUnits&&Ft(x)&&P.atomAt.get(Z);if(!ve||!Be(ve.el)||H.ss!==H.se||H.bs>=H.be)return!1;for(let qe=H.bs;qe<H.be;qe++)if(!/\s/.test(g.text[qe]))return!1;let Oe=P===h?1:2;if(!e.scopeUnits[Oe].includes(ve.el)||(Oe===1?r:o)?.reverse.has(ve.el))return!1;z=!0}}return z},Yt=(x,P)=>x.bs<P.be&&P.bs<x.be,gn=(x,P)=>x.bs<=P.be&&P.bs<=x.be&&Ft(x)!==Ft(P),K=(x,P)=>g.text.slice(x.bs,x.be).includes(Ot)||P.text.slice(x.ss,x.se).includes(Ot),b=x=>{if(Ft(x))return!1;let P=x.bs,H=x.be;for(;P>0&&/\s/.test(g.text[P-1]);)P--;for(;H<g.text.length&&/\s/.test(g.text[H]);)H++;return(P===0||g.text[P-1]===Ot)&&(H===g.text.length||g.text[H]===Ot)},C=(x,P)=>!K(x,P)&&!b(x),L=(x,P)=>Yt(x,P)||gn(x,P)&&!(x.transferIn||x.transferOut||P.transferIn||P.transferOut)&&!(Qt(x,h,P)&&C(P,y))&&!(Qt(P,y,x)&&C(x,h)),$=(x,P)=>{if(x.bs!==P.bs||x.be!==P.be||x.toks.length!==P.toks.length)return!1;let H=x.ss,z=P.ss;for(let Z=0;Z<x.toks.length;Z++){let ge=x.toks[Z],ve=P.toks[Z];if(ge.k!==ve.k||ge.atom&&!h.atomAt.get(H).el.isEqualNode(y.atomAt.get(z).el))return!1;H+=ge.len,z+=ve.len}return!0},Q=(x,P,H,z)=>{for(let Z of g.atoms){if(Z.i<x.bs||Z.i>=x.be||z.has(Z)||Te.has(Z))continue;let ge=P.bTo[Z.i],ve=ge>=0?H.atomAt.get(ge):null;if(ve&&!ve.el.isEqualNode(Z.el))return!0}return!1},F=[],he=null,ke=null,ie=Me.hunks,Ne=Fe.hunks,U=0,Y=0,pe=0,ye=0,me=0,ee=x=>{x>pe&&(F.push({src:"base",from:pe,to:x,dL:ye,dR:me}),pe=x)};for(;U<ie.length||Y<Ne.length;){let x=ie[U],P=Ne[Y],H=!!x&&(!P||x.bs<P.bs||x.bs===P.bs&&x.be<=P.be&&!P.lead);if(x&&P&&x.bs===P.bs&&Ft(x)&&Ft(P)){let Gt=Qt(x,h),yo=Qt(P,y);Gt!==yo&&(H=yo)}let z=H?x:P,Z=H?P:x,ge=!!Z&&$(x,P),ve=!!Z&&(H?!!ie[U+1]&&$(ie[U+1],P):!!Ne[Y+1]&&$(x,Ne[Y+1])),Oe=!!Z&&!ge&&!ve&&(Ue===0||L(x,P)),qe=Oe,Le=kn(z,H?vt:dt);if(Le==="straddle"&&(qe=!0),!qe&&z.be>z.bs&&(qe=Q(z,H?Ae:ce,H?y:h,H?re:Pe)),!qe&&ge){ee(z.bs),F.push({src:"both",lfrom:x.ss,rfrom:P.ss,len:z.text.length,owner:x.owner||P.owner||null,transfer:x.transferIn||P.transferIn||null}),pe=z.be,ye+=z.text.length-(z.be-z.bs),me+=z.text.length-(z.be-z.bs),U++,Y++;continue}if(!qe){ee(z.bs),F.push({src:H?"local":"remote",from:z.ss,to:z.se,inherit:Le&&Le!=="straddle"?Le:null,owner:z.owner||null,transfer:z.transferIn||null}),pe=z.be,H?(ye+=z.text.length-(z.be-z.bs),U++):(me+=z.text.length-(z.be-z.bs),Y++);continue}let $e=z.bs,St=z.be,mt=U,xt=Y,Ht=Gt=>Gt.bs<St&&Gt.be>$e||Ft(Gt)&&(Gt.bs===$e||Gt.bs===St);H?mt++:xt++,Oe&&($e=Math.min($e,Z.bs),St=Math.max(St,Z.be),H?xt++:mt++);let qt=!0;for(;qt;){for(qt=!1;mt<ie.length&&Ht(ie[mt]);)$e=Math.min($e,ie[mt].bs),St=Math.max(St,ie[mt].be),mt++,qt=!0;for(;xt<Ne.length&&Ht(Ne[xt]);)$e=Math.min($e,Ne[xt].bs),St=Math.max(St,Ne[xt].be),xt++,qt=!0}let An=$e+ye,mn=$e+me,On=St-$e,Ln=St-$e;for(let Gt=U;Gt<mt;Gt++)On+=ie[Gt].text.length-(ie[Gt].be-ie[Gt].bs);for(let Gt=Y;Gt<xt;Gt++)Ln+=Ne[Gt].text.length-(Ne[Gt].be-Ne[Gt].bs);let Wn=An+On,Kn=mn+Ln;if(ee($e),U<mt&&Y<xt&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!h.atoms.length&&!y.atoms.length&&!g.pins.length&&!h.pins.length&&!y.pins.length){he||={fb:g,fl:h,fr:y,ML:ce,MR:Ae,byEl:ae,cache:[null,null]};let Gt=ca(he,ie,U,mt,Ne,Y,xt,0,n),yo=ca(he,Ne,Y,xt,ie,U,mt,1,n);if(Gt===null!=(yo===null)){let oi=Gt!==null,$l=oi?Gt:yo;if($l){ke||=new Map;for(let Cu of $l)ke.set(Cu,oi?"local":"remote")}F.push(oi?{src:"remote",from:mn,to:Kn}:{src:"local",from:An,to:Wn}),pe=St,ye+=On-(St-$e),me+=Ln-(St-$e),U=mt,Y=xt;continue}}let sn={kind:"text",node:e.node||null,base:Br(g,$e,St),local:Br(h,An,Wn),remote:Br(y,mn,Kn),resolved:null,range:null,bs:$e,be:St,lss:An,lse:Wn,rss:mn,rse:Kn},xr=e.sourceRetentions?na(e.sourceRetentions,e.scope?.base,g,h,y,n,sn):n;sn.resolved=xr==="local"?sn.local:xr==="remote"?sn.remote:sn.local+sn.remote,xr!=="remote"&&F.push({src:"local",from:An,to:Wn,conflict:sn}),xr!=="local"&&F.push({src:"remote",from:mn,to:Kn,conflict:sn});let vr={site:"inline",policy:xr,fb:g,fl:h,fr:y,scope:e.scope||null,synthetic:!!e.synthetic,full:v,merged:u};f.push(vr),d(sn,vr),pe=St,ye+=On-(St-$e),me+=Ln-(St-$e),U=mt,Y=xt}ee(Ue);let te=g.text,W=[];if(Me.respell.size||Fe.respell.size){let x=qr(Ce),P=[];for(let H=0;H<Ce.length;H++){let z=Ce[H].raw,Z=Me.respell.get(H)??z,ge=Fe.respell.get(H)??z;(Z!==z||ge!==z)&&W.push([x[H],Z!==z&&ge!==z?"both":Z!==z?"local":"remote"]),P.push(Z===ge?Z:Z===z?ge:ge===z||n==="local"?Z:ge)}te=P.join("")}let ne="",we=[],Ie=[],je=[],Se=[];for(let x of F){let P=ne.length;if(x.src==="base"){for(let H=x.from;H<x.to;H++)we.push(H),Ie.push(e.nativeTransfers?ce.bTo[H]:H+x.dL),je.push(e.nativeTransfers?Ae.bTo[H]:H+x.dR),Se.push(x);ne+=te.slice(x.from,x.to)}else if(x.src==="both"){for(let H=0;H<x.len;H++){let z=x.transfer&&(x.transfer.side==="remote"?x.rfrom+H:x.lfrom+H);we.push(x.transfer&&z>=x.transfer.ss&&z<x.transfer.se?x.transfer.bs+z-x.transfer.ss:-1),Ie.push(x.lfrom+H),je.push(x.rfrom+H),Se.push(x)}ne+=h.text.slice(x.lfrom,x.lfrom+x.len)}else{let H=x.src==="local"?h:y,z=x.transfer&&e.nativeTransfers.byOrigin[x.src==="local"?"remote":"local"].get(x.transfer.key);for(let Z=x.from;Z<x.to;Z++){let ge=x.transfer&&Z>=x.transfer.ss&&Z<x.transfer.se?x.transfer.bs+Z-x.transfer.ss:-1,ve=ge>=0&&(!z||z.destination===x.owner)?(x.src==="local"?Ae:ce).bTo[ge]:-1;we.push(ge),Ie.push(x.src==="local"?Z:ve),je.push(x.src==="remote"?Z:ve),Se.push(x)}ne+=H.text.slice(x.from,x.to)}x.ms=P,x.me=ne.length,x.conflict&&(x.conflict.range||(x.conflict.range=[P,P]),x.conflict.range[1]=ne.length)}let Je=ne.length,nt=new Int32Array(Ue+1).fill(-1),st=new Int32Array(h.text.length+1).fill(-1),$t=new Int32Array(y.text.length+1).fill(-1);for(let x=0;x<Je;x++)we[x]>=0&&(nt[we[x]]=x),Ie[x]>=0&&(st[Ie[x]]=x),je[x]>=0&&($t[je[x]]=x);let Bt=(x,P)=>{let H=-1,z=-1;for(let Z=x.from;Z<x.to;Z++){let ge=P[Z];ge>=0&&(H<0&&(H=ge),z=ge+1)}return H<0?null:[H,z]},I=[],G=[];for(let x of new Set(ae.values()))x.new==="local"?I.push(x):x.new==="remote"&&G.push(x);let se=(x,P)=>{x.remote=P.remote,x.remoteMark=P.remoteMark,x.new="both",P.merged=x,ae.set(P.remote,x)};if(I.length&&G.length){let x=e.idOf;for(let P of I){let H=x?x.local(P.local):null;if(!H)continue;let z=G.find(Z=>!Z.merged&&Z.tag===P.tag&&!!Z.block==!!P.block&&x.remote(Z.remote)===H);z&&se(P,z)}for(let P of I){if(P.remote)continue;let H=Bt(P.localMark,st);if(H)for(let z of G){if(z.merged||z.tag!==P.tag||!!z.block!=!!P.block)continue;let Z=Bt(z.remoteMark,$t);if(Z&&Math.min(H[1],Z[1])-Math.max(H[0],Z[0])>0){se(P,z);break}}}}lt.clear();let be=x=>{for(let P of x)if(P.block)return Ve(ae.get(P.el));return null},xe=g.marks.some(x=>x.block)||h.marks.some(x=>x.block)||y.marks.some(x=>x.block),fe=new Array(Je).fill(null),oe=new Set;if(e.nativeTransfers)for(let x=0;x<Je;x++){let P=Se[x].owner;fe[x]=P?Ve(ae.get(P)):we[x]>=0?be(g.stackAt[we[x]]):null}else if(xe){let x=(Le,$e,St)=>{let mt=new Set([Le,$e,St]);mt.delete(null);let xt=[];for(let qt of mt){let An=qt===Le,mn=qt===$e,On=qt===St;(mn===On?mn:mn===An?On:mn)&&xt.push(qt)}if(xt.length<=1)return xt[0]||null;let Ht=n==="local"?$e:St;return xt.includes(Ht)?Ht:xt[0]},P=(Le,$e)=>$e>=0?be(Le.stackAt[$e]):null,H=new Map;for(let Le=0;Le<Je;Le++){if(ne[Le]!==Ot)continue;let $e=we[Le]>=0?P(g,we[Le]):null,St=P(h,Ie[Le]),mt=P(y,je[Le]);H.set(Le,[$e,we[Le]>=0?x($e,St,mt):St||mt])}let z=new Set([...H.values()].map(Le=>Le[1])),Z=Le=>Le!==Ot&&Le!==Yn&&!/\s/.test(Le),ge=(Le,$e)=>{let St=Le;for(;St<$e&&!Z(ne[St]);)St++;return St<$e&&we[St]>=0?P(g,we[St]):null},ve=new Map,Oe=0;for(let Le=0;Le<Je;Le++){if(ne[Le]!==Ot)continue;let[$e,St]=H.get(Le),mt=ge(Oe,Le),xt=St,Ht=ve.get(xt)===xt&&mt===xt;xt&&ve.has(xt)&&!Ht&&$e&&!ve.has($e)&&!z.has($e)&&(xt=$e),xt&&!ve.has(xt)&&ve.set(xt,mt);for(let qt=Oe;qt<=Le;qt++)fe[qt]=xt;Oe=Le+1}let qe=Le=>{for(let $e=0;$e<Le.text.length;$e++)if(Z(Le.text[$e])&&!P(Le,$e))return!0;return!1};if(!qe(g)&&!qe(h)&&!qe(y)){let Le=[],$e=0;for(let mt=0;mt<Je;mt++)(ne[mt]===Ot||mt===Je-1)&&(Le.push([$e,mt]),$e=mt+1);let St=new Set(fe);for(let mt=0;mt<Le.length;mt++){let[xt,Ht]=Le[mt];if(fe[Ht])continue;let qt=xt;for(;qt<=Ht&&!Z(ne[qt]);)qt++;if(qt>Ht)continue;let An=P(g,we[qt]),mn=P(h,Ie[qt]),On=P(y,je[qt]),Ln=x(An,mn,On)||mn||On||An;if(Ln&&!St.has(Ln)){St.add(Ln);for(let sn=xt;sn<=Ht;sn++)fe[sn]=Ln;continue}let Wn=mt>0&&fe[Le[mt-1][1]],Kn=mt+1<Le.length&&fe[Le[mt+1][1]];if(Wn)oe.add(Le[mt-1][1]);else if(Kn&&ne[Ht]===Ot)oe.add(Ht);else continue;for(let sn=xt;sn<=Ht;sn++)fe[sn]=Wn||Kn}}}let Re=new Map,De=x=>{let P=Re.get(x);if(P)return P;P=[1/0,-1/0];for(let[H,z]of[[x.baseMark,nt],[x.localMark,st],[x.remoteMark,$t]]){let Z=H&&Bt(H,z);Z&&(P[0]=Math.min(P[0],Z[0]),P[1]=Math.max(P[1],Z[1]))}return Re.set(x,P),P},We=(x,P,H)=>{let z=-1,Z=-1;for(let ge=0;ge<x.length;ge++){let ve=ae.get(x[ge].el);ve===P&&(z=ge),ve===H&&(Z=ge)}return z>=0&&Z>=0?z-Z:0},Ye=(x,P)=>[...x].sort((H,z)=>{for(let ve of P){let Oe=We(ve,H,z);if(Oe)return Oe}let Z=De(H),ge=De(z);return Z[0]-ge[0]||ge[1]-Z[1]||H.rank-z.rank||H.id-z.id}),wt=new Map,at=new Map,Wt=e.nativeTransfers?[]:null,zt=x=>{if(Wt)return Wt;let P=we[x],H=Ie[x],z=je[x],Z=Se[x];if(P>=0){let mt=g.stackAt[P],xt=h.stackAt[H],Ht=y.stackAt[z],qt=wt.get(mt);qt||wt.set(mt,qt=new Map);let An=qt.get(xt);An||qt.set(xt,An=new Map);let mn=An.get(Ht);if(mn)return mn;let On=pt(mt),Ln=pt(xt),Wn=pt(Ht),Kn=new Set;for(let sn of new Set([...On,...Ln,...Wn])){let xr=On.has(sn),vr=Ln.has(sn),Gt=Wn.has(sn);(vr===Gt?vr:vr===xr?Gt:vr)&&Kn.add(sn)}return mn=Ye(Kn,[xt,Ht,mt]),An.set(Ht,mn),mn}if(Z.src==="both"){let mt=h.stackAt[H],xt=y.stackAt[z];return Ye(new Set([...pt(mt),...pt(xt)]),[mt,xt])}let ve=(Z.src==="local"?h:y).stackAt[Z.src==="local"?H:z];if(!Z.inherit)return Ye(pt(ve),[ve]);let Oe=at.get(Z);Oe||at.set(Z,Oe=new Map);let qe=Oe.get(ve);if(qe)return qe;let Le=new Set(pt(ve));for(let mt of Z.inherit.added)Le.add(Ve(mt));for(let mt of Z.inherit.removed)Le.delete(Ve(mt));let $e=Z.src==="local"?y:h,St=(Z.src==="local"?Ae.bTo:ce.bTo)[Z.inherit.bs];return qe=Ye(Le,[ve,$e.stackAt[St]]),Oe.set(ve,qe),qe},bn=new Int32Array(h.text.length+1);bn[h.text.length]=Je;for(let x=h.text.length-1;x>=0;x--)bn[x]=st[x]>=0?st[x]:bn[x+1];ld.caret+=h.text.length;let Tt=x=>x<=0?0:(x>h.text.length&&(x=h.text.length),st[x-1]>=0?st[x-1]+1:bn[x]),ht=[],Qe=[],Mt=null,bt=[],Ut="",En=-1,cn=x=>{Mt?Mt.appendChild(x):ht.push(x)},xn=x=>{if(!Ut)return;let P=t.createTextNode(Ut);cn(P),Qe.push({node:P,ms:En,me:x,local:[],u:bt.length?bt[bt.length-1].u:null}),Ut=""},en=new Set,Hn=new Map,Ir=new Set,zn=x=>{let P=t.createElement(x.tag);if(x.block&&Rn.add(P),!Hn.has(x)){Hn.set(x,P),_(x.base,x.local,x.remote,P),s.set(P,{base:x.base,local:x.local,remote:x.remote});let z=(ve,Oe)=>p&&x[Oe]&&ve.reverse.get(x[Oe])?Oe:null,Z=!x.base&&(z(r,"local")||z(o,"remote"));if(Z){let ve=Z==="local"?r.reverse.get(x.local):o.reverse.get(x.remote),Oe=s.get(P);Oe.local=Oe.local||r.map.get(ve)||null,Oe.remote=Oe.remote||o.map.get(ve)||null,a.push({kind:"move",el:P,source:Z}),e.moveBuilt?.(ve,Z,x[Z],P)}else x.base||a.push({kind:"insert",el:P,source:x.local&&x.remote?"both":x.local?"local":"remote"});let ge=s.get(P);ge.local&&(Ir.has(ge.local)?ge.local=null:Ir.add(ge.local))}else{let z=Hn.get(x);for(let Z of z.attributes)Z.name!=="id"&&Z.name!=="data-id"&&E(P,Z,Z.value);s.set(P,{base:null,local:null,remote:null})}cn(P),bt.push({u:x,el:P}),Mt=P},po=new Set,or=new Map;for(let x of h.pins){let P=Tt(x.i);or.has(P)||or.set(P,[]),or.get(P).push(x)}let Jo=x=>{let P=or.get(x);if(P){xn(x);for(let H of P){let z=H.el.namespaceURI&&H.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(H.el.namespaceURI,H.el.tagName):t.createElement(H.el.tagName);s.set(z,{base:null,local:H.el,remote:null,pinned:!0}),po.add(z),cn(z)}}},ri=g.atoms.length||h.atoms.length||y.atoms.length,Zo=x=>{if(!ri)return null;let P=we[x]>=0?g.atomAt.get(we[x]):null,H=Ie[x]>=0?h.atomAt.get(Ie[x]):null,z=je[x]>=0?y.atomAt.get(je[x]):null;return P||H||z?{ab:P,al:H,ar:z}:null},sr=(x,P,H)=>{let z=e.idOf;if(!z||!z.base)return!1;let Z=z.base(x.el);return Z!=null&&Z===z[H](P.el)},go=(x,P,H,z,Z)=>{if(!x||!p)return null;let ge=A.get(P.reverse.get(x.el))||null;return!ge||ge===z||(z?ge.el.isEqualNode(z.el)&&!sr(ge,x,Z):H.bTo[ge.i]>=0)?null:ge},Lr=(x,P)=>{if(!x||!p||!e.moveIn)return null;let H=P.reverse.get(x.el);return H&&!A.has(H)?H:null},bo=(x,P)=>{let H=new Map;for(let z of x.atoms)H.set(P(z),(H.get(P(z))||0)+1);return H},ue=bo(g,B),Ke=bo(h,S),He=bo(y,T),it=x=>{let P=B(x);return ue.get(P)===1&&(Ke.get(P)||0)<=1&&(He.get(P)||0)<=1},Et=new Map,Xe=new Set,Ze=new Set,Nt=new Set,tt=null;for(let x=0;x<Je;x++){let P=Zo(x);if(!P)continue;let{ab:H,al:z,ar:Z}=P,ge=go(Z,o,Ae,H,"remote"),ve=go(z,r,ce,H,"local"),Oe=H,qe=null;if(ge?(Oe=ge,qe="remote"):ve&&(Oe=ve,qe="local"),Oe){H&&Oe!==H&&(tt||=new Map).set(H,qe),Xe.has(Oe)?Et.set(x,{dup:Oe.el}):(Xe.add(Oe),Et.set(x,{bk:Oe,from:qe,al:z,ar:Z}));continue}let Le=Lr(Z,o),$e=Lr(z,r),St=Le||$e;if(St){Ze.has(St)?Et.set(x,{dup:St}):(Ze.add(St),Et.set(x,{moveIn:St,side:Le?"remote":"local",sideEl:Le?Z.el:z.el}));continue}let mt=(Ht,qt)=>Ht&&p&&A.get(qt.reverse.get(Ht.el))||null,xt=mt(Z,o)||mt(z,r);if(xt&&(Nt.add(xt),Se[x].conflict&&(it(xt)||Z&&(Z.el===xt.el||o.identityPaired?.has(xt.el))&&sr(xt,Z,"remote")||z&&(z.el===xt.el||r.identityPaired?.has(xt.el))&&sr(xt,z,"local")))){if(Xe.has(xt)){Et.set(x,{dup:xt.el});continue}Xe.add(xt)}Et.set(x,{al:z,ar:Z})}let ft=new Map,yt,Vt,Pt=(x,P)=>{if(x[P]>=0)return x[P];for(let H=P-1;H>=0;H--)if(x[H]>=0)return x[H]+1;return 0};if(p)for(let x of g.atoms){if(Xe.has(x)||Nt.has(x))continue;let P=r.map.get(x.el)||null,H=o.map.get(x.el)||null,z=P&&O.get(P),Z=H&&X.get(H);if(P&&!z||H&&!Z)continue;let ge=!(z&&Z)&&Te.has(x);if(!ge&&!(z&&Z&&(it(x)||tt?.has(x)||(z.el===x.el||r.identityPaired?.has(x.el))&&(Z.el===x.el||o.identityPaired?.has(x.el))&&sr(x,z,"local")&&sr(x,Z,"remote"))))continue;let ve=tt?.get(x),Oe=n;if(ve){let mt=ve==="local"?y:h,xt=ve==="local"?o:r,Ht=ve==="local"?Vt:yt;if(Ht===void 0){Ht=mt.atoms.length===g.atoms.length;for(let qt=0;Ht&&qt<g.atoms.length;qt++)Ht=xt.reverse.get(mt.atoms[qt].el)===g.atoms[qt].el;ve==="local"?Vt=Ht:yt=Ht}Ht&&(Oe=ve)}let qe=Oe==="local"?[[z,st],[Z,$t]]:[[Z,$t],[z,st]],[Le,$e]=qe.find(([mt])=>mt),St=Pt($e,Le.i);ft.has(St)||ft.set(St,[]),ft.get(St).push({a:x,lt:P,rt:H,edited:ge}),Xe.add(x)}if(p&&e.moveIn){let x=[[h,r,st,"local"],[y,o,$t,"remote"]];n!=="local"&&x.reverse();for(let[P,H,z,Z]of x)for(let ge of P.atoms){let ve=Lr(ge,H);if(!ve||Ze.has(ve))continue;Ze.add(ve);let Oe=Pt(z,ge.i);ft.has(Oe)||ft.set(Oe,[]),ft.get(Oe).push({move:ve,side:Z,sideEl:ge.el})}}let rn=x=>{let P=ft.get(x);if(P){if(xn(x),P.some(H=>Be(H.move?H.sideEl:H.a.el)))for(;bt.length;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;for(let{a:H,lt:z,rt:Z,edited:ge,move:ve,side:Oe,sideEl:qe}of P){if(ve){let $e=e.moveIn(ve,Oe,qe);$e&&cn($e);continue}en.add(H);let Le=M(H.el,z,Z);ge&&(d({kind:"structure",el:Le,detail:"edit-beats-delete",base:H.el},{subject:H.el,deleted:z?"remote":"local"}),a.push({kind:"insert",el:Le,source:z?"local":"remote"})),cn(Le)}}},Rn=new Set,ir=l.length>c;for(let x=0;x<Je;x++){let P=Zo(x),H=e.scopeUnits&&P&&(P.ab?.stack.some(ve=>ve.block)||P.al?.stack.some(ve=>ve.block)||P.ar?.stack.some(ve=>ve.block)),Z=!!P&&Be((P.ab||P.al||P.ar).el)&&!H?[]:fe[x]?[fe[x],...zt(x)]:zt(x),ge=0;for(;ge<bt.length&&ge<Z.length&&bt[ge].u===Z[ge];)ge++;if(ge<bt.length)for(xn(x);bt.length>ge;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;if(Jo(x),rn(x),Z.length>bt.length)for(xn(x);bt.length<Z.length;)zn(Z[bt.length]);if(ne[x]===Ot){if(oe.has(x))continue;xn(x);let ve=bt.length;for(;ve>0&&!bt[ve-1].u.block;)ve--;if(ve>0)for(ir&&u.breakOut.set(x,bt[ve-1].el);bt.length>=ve;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;continue}if(P){xn(x);let ve=Et.get(x),Oe;if(ve.dup){d({kind:"structure",el:null,detail:"both-moved",base:ve.dup},{subject:ve.dup});continue}if(ve.moveIn){if(Oe=e.moveIn(ve.moveIn,ve.side,ve.sideEl),!Oe)continue}else if(ve.bk){let qe=ve.bk;if(en.add(qe),qe===P.ab)Oe=M(qe.el,ve.al.el,ve.ar.el);else{let Le=r.map.get(qe.el)||null,$e=o.map.get(qe.el)||null;Oe=M(qe.el,Le,$e),(!Le||!$e)&&d({kind:"structure",el:null,detail:"move-beats-delete",base:qe.el},{subject:qe.el,deleted:Le?"remote":"local"}),a.push({kind:"move",el:Oe,source:ve.from})}}else ve.al?(Oe=j(ve.al.el,"local"),ve.ar&&(s.get(Oe).remote=ve.ar.el),a.push({kind:"insert",el:Oe,source:ve.ar?"both":"local"})):(Oe=j(ve.ar.el,"remote"),a.push({kind:"insert",el:Oe,source:"remote"}));ir&&u.atomOut.set(x,Oe),cn(Oe);continue}Ut||(En=x),Ut+=ne[x]}if(xn(Je),(or.has(Je)||ft.has(Je))&&(bt.length=0,Mt=null,Jo(Je),rn(Je)),Je===0&&(h.placeholder||y.placeholder||g.placeholder)){let x=t.createElement("br");s.set(x,{base:g.placeholder,local:h.placeholder,remote:y.placeholder}),ht.push(x)}let Vn=0,kt=x=>{for(;Vn>0&&Qe[Vn-1].me>=x;)Vn--;for(;Vn<Qe.length&&Qe[Vn].me<x;)Vn++;let P=Qe[Vn];if(!P)return Qe[Qe.length-1]||null;let H=Qe[Vn+1];return P.me===x&&H&&H.ms===x?H:P},rt=new Map,jt={},ct=(x,P,H)=>{let z=kt(x)||(H?jt:null);if(!z)return;let Z=rt.get(z)||{l:!1,r:!1};P!=="remote"&&(Z.l=!0),P!=="local"&&(Z.r=!0),rt.set(z,Z)},Lt=x=>{if(x.conflict)return!0;let P=x.src==="local"?h.text:x.src==="remote"?y.text:"";for(let H=x.from;H<x.to;H++)if(P[H]!==Yn&&P[H]!==Ot)return!0;return!1};for(let x of F)x.src!=="base"&&ct(x.ms,x.conflict?"both":x.src,Lt(x));for(let[x,P]of W)nt[x]>=0&&ct(nt[x],P);for(let x of Qe.length?Qe:[jt]){let P=rt.get(x);P&&a.push({kind:"text",node:x.node||null,source:P.l&&P.r?"both":P.l?"local":"remote"})}for(let x of de){if(Hn.has(x))continue;let P=!x.local&&!(p&&r.map.get(x.base)),H=!x.remote&&!(p&&o.map.get(x.base));!P&&!H||a.push({kind:"remove",source:P&&H?"both":P?"local":"remote",base:x.base})}if(ke)for(let[x,P]of ke)Hn.has(x)&&d({kind:"structure",el:Hn.get(x),detail:"edit-beats-delete",base:x.base},{subject:x.base,deleted:P});let tn=(x,P,H)=>{if(P<=x)return!1;for(let z=x;z<P;z++)if(H[z]>=0)return!1;return!0};for(let x of de)for(let P of["local","remote"]){let H=x[P+"Mark"],z=x.baseMark;if(!H)continue;let Z=P==="local"?ce:Ae;if(!tn(z.from,z.to,Z.bTo)||!tn(H.from,H.to,Z.toB))continue;let ge=(P==="local"?ie:Ne).find(ve=>ve.ss<=H.from&&H.from<ve.se);ge&&(ge.be<=z.from||ge.bs>=z.to)&&a.push({kind:"move",el:Hn.get(x)||null,source:P})}let Dt=x=>{let P=ae.get(x.node.parentNode);return P?Ve(P):null};for(let x of h.nodes){let P=-1;for(let z=x.s;z<x.e;z++)if(st[z]>=0){P=st[z];break}let H;if(P>=0)H=kt(P);else{let z=Tt(x.s),Z=Dt(x);H=Qe.find(ge=>ge.u===Z&&ge.me>=z)||Qe.filter(ge=>ge.u===Z).pop()}H&&H.local.push(x)}let Kt=new Map,ln=Qe[Qe.length-1]||null,_t=0;for(let x of h.nodes){let P=null;for(let H=x.s;H<=x.e;H++){let z=Tt(H);for(;_t>0&&Qe[_t-1].me>=z;)_t--;for(;_t<Qe.length&&Qe[_t].me<z;)_t++;let Z=ve=>ve&&z>=ve.ms&&z<=ve.me&&(z<ve.me||H===x.e||ve===P),ge=Z(Qe[_t])?Qe[_t]:Z(Qe[_t+1])?Qe[_t+1]:Qe[_t]||ln;if(!ge)break;if(P===ge){let ve=Kt.get(ge);ve[ve.length-1].to=H-x.s;continue}P=ge,Kt.has(ge)||Kt.set(ge,[]),Kt.get(ge).push({node:x.node,from:H-x.s,to:H-x.s,flatStart:x.s})}}for(let x of Qe){let P=x.local,H=!1;for(let ve of P)for(let Oe=ve.s;Oe<ve.e&&!H;Oe++)(st[Oe]<x.ms||st[Oe]>=x.me)&&(H=!0);s.set(x.node,{base:null,local:P.map(ve=>ve.node),remote:null,caret:Kt.get(x)||[],partial:H});let z=x.ms,Z=x.me-x.ms,ge=ve=>{let Oe=0,qe=-1;for(let Le of P){let $e=Le.e-Le.s;if(ve<=Oe+$e){qe=Le.s+(ve-Oe);break}Oe+=$e}return qe<0&&(qe=P.length?P[P.length-1].e:0),Math.max(0,Math.min(Tt(qe)-z,Z))};ge.flat=ve=>Math.max(0,Math.min(Tt(ve)-z,Z)),i.set(x.node,ge)}function At(){if(!h.text.includes(Ot))return[{flatLocal:h.text,localNodes:h.nodes,textNodes:Qe,lToM:st,mapLocal:Tt}];let x=[],P=0,H=0;for(let z=0;z<=h.text.length;z++){if(z<h.text.length&&h.text[z]!==Ot)continue;let Z=P,ge=z;if(ge>Z){let ve=[];for(;H<h.nodes.length&&h.nodes[H].e<=Z;)H++;for(let Oe=H;Oe<h.nodes.length&&h.nodes[Oe].s<ge;Oe++){let qe=h.nodes[Oe],Le=Math.max(qe.s,Z),$e=Math.min(qe.e,ge);Le<$e&&ve.push({node:qe.node,s:Le-Z,e:$e-Z})}x.push({flatLocal:h.text.slice(Z,ge),localNodes:ve,textNodes:Qe,lToM:st.subarray?st.subarray(Z,ge+1):st.slice(Z,ge+1),mapLocal:Oe=>Tt(Z+Math.max(0,Math.min(Oe,ge-Z)))})}P=z+1}return x}let It={...e,blocks:Rn,ignored:x=>po.has(x)||(e.ignored?e.ignored(x):!1)},on=e.ignoreAttribute||(()=>!1),lr=ra(an(ht,It),on)!==ra(y,on);if(f.length){let x=P=>{let H=s.get(P);return H&&H.unchanged?H.remote:null};u.text=ne,u.textNodes=Qe,u.out=an(ht,{...It,via:x})}let In=null;if(e.scopeUnits){In=new Map;let x=new Set(ht),P=Oe=>{for(;Oe&&!x.has(Oe);)Oe=Oe.parentNode;return Oe},H=e.scopeUnits.map(Oe=>{let qe=new Map;for(let Le of Oe)if(Le.nodeType===1)qe.set(Le,Le);else for(let $e of Le.nodes)qe.set($e,Le);return qe}),z=(Oe,qe)=>{for(;Oe&&!qe.has(Oe);)Oe=Oe.parentNode;return Oe?qe.get(Oe):null},Z=[g,h,y].map((Oe,qe)=>{let Le=new Array(Oe.text.length);for(let $e of Oe.nodes){let St=z($e.node,H[qe]);St&&Le.fill(St,$e.s,$e.e)}for(let $e of Oe.atoms)Le[$e.i]=z($e.el,H[qe]);return Le}),ge=(Oe,qe)=>{if(!Oe||!qe)return;let Le=In.get(Oe);Le||In.set(Oe,Le=new Set),Le.add(qe)};for(let Oe of ht){let qe=s.get(Oe);qe&&(ge(z(qe.base,H[0]),Oe),ge(z(qe.local,H[1]),Oe),ge(z(qe.remote,H[2]),Oe))}for(let Oe of Qe){let qe=P(Oe.node);for(let Le=Oe.ms;Le<Oe.me;Le++)ge(Z[0][we[Le]],qe),ge(Z[1][Ie[Le]],qe),ge(Z[2][je[Le]],qe)}let ve=new Map(ht.map((Oe,qe)=>[Oe,qe]));for(let[Oe,qe]of In)In.set(Oe,Array.from(qe).sort((Le,$e)=>ve.get(Le)-ve.get($e)))}return{unitOutputs:In,nodes:ht,text:ne,textNodes:Qe,localDiverged:lr,mapLocal:Tt,conflicts:l.slice(c),granularity:V?"line":"word",segments:At(),localHunks:ie,remoteHunks:Ne,lToM:st}}var _i=Symbol("lost");function ma(){return{links:new Map,removed:new Set,consumed:new Set,link(e,t){this.links.set(e,t)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let t of e.nodes)this.removed.add(t)},consume(e){for(let t of e)this.consumed.add(t)}}}var ha=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function pa({locals:e,rec:t,root:n,provenance:r,segments:o,ignored:s}){let i=new Map,l=(w,v)=>{let E=i.get(w);E||i.set(w,E=new Set),E.add(v)},a=new Set,c=new Set;for(let w of o){let v=w.textNodes;for(let E of v)a.add(E.node);for(let E of w.localNodes){c.add(E.node);let N=0,_=null;for(let M=E.s;M<E.e;M++){let j=w.lToM[M];if(j<0)continue;for((!v[N]||j<v[N].ms)&&(N=0);N<v.length&&v[N].me<=j;)N++;let R=v[N]&&v[N].ms<=j?v[N].node:_i;R!==_&&l(E.node,R),_=R}}}let d=new Set,u=new Map,f=new Set;(function w(v){d.add(v);let E=r.get(v);if(v.nodeType===1)E&&E.local&&E.local.nodeType===1&&(l(E.local,v),E.unchanged&&f.add(E.local)),v.tagName==="TEMPLATE"&&v.content&&u.set(v.content,v);else if(E&&Array.isArray(E.local)&&!a.has(v))for(let N of E.local)l(N,v);for(let N=ha(v).firstChild;N;N=N.nextSibling)w(N)})(n);let p=new Set;for(let[w,v]of t.links)l(w,v),p.add(w);let m=w=>{let v=w.parentNode;return v&&v.nodeType===11?u.get(v)||null:v},k=(w,v)=>{for(let E=w;E;E=m(E))if(E===v)return!0;return!1},g=w=>t.removed.has(w)||t.consumed.has(w),h=w=>{for(let v=w.parentNode;v&&v.nodeType===1;v=v.parentNode){if(f.has(v))return"kept";if(g(v))return"decided";if(i.has(v))return null}return null},y=new Map;for(let w of e)y.set(w,A(w));return y;function A(w){let v=i.get(w);if(v&&(v.size!==1||v.has(_i)))return{kind:"unknown",reason:"several-outputs"};let E=v?v.values().next().value:null;if(E&&(E.nodeType!==1||!d.has(E)))return{kind:"unknown",reason:"output-not-placed"};if(!E){let j=g(w)?"decided":h(w);if(j==="kept")return{kind:"untouched"};if(j!=="decided")return{kind:"unknown",reason:"unmapped"}}let N=[],_=M(w,!!E&&(f.has(w)||p.has(w)),!E||g(w));if(_)return{kind:"unknown",reason:_};return E?{kind:"single",output:E,owned:N,carried:p.has(w)}:{kind:"removed"};function M(j,R,D){for(let B=ha(j).firstChild;B;B=B.nextSibling){if(B.nodeType===1?s(B):B.nodeType!==3&&B.nodeType!==8)continue;let S=i.get(B);if(S)for(let T of S){if(T===_i||!d.has(T))return"output-not-placed";if(!E)return"survives-elsewhere";if(!k(T,E))return"escaped";N.push(T)}else if(!R&&!D&&!g(B)&&!c.has(B))return"unmapped";if(B.nodeType===1){let T=M(B,R||f.has(B)||p.has(B),D||g(B));if(T)return T}}return null}}}function ga(e,t){if(!t)return!1;let n=t.nodeType===1&&t.tagName==="TEMPLATE"?[t,...t.querySelectorAll("template")]:[...t.querySelectorAll("template")];for(let r of n)if(r.content.contains(e)||ga(e,r.content))return!0;return!1}function ba(e,t){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let n=[],r=new Set;for(let o of Array.from(e.elements)){if(!o||o.nodeType!==1||o.ownerDocument!==t&&!ga(o,t.documentElement))throw new TypeError("lineage.elements must be elements of the live document");r.has(o)||(r.add(o),n.push(o))}return n}var ya=new WeakMap;function ka(e){let t=new Map;for(let n of e){let r=[],o=!1;(function s(i){i.nodeType===1&&i.namespaceURI==="http://www.w3.org/1999/xhtml"&&i.localName==="template"&&(o=!0);for(let l=i.firstChild;l;l=l.nextSibling)r.push(l),l.nodeType===1&&s(l)})(n),t.set(n,{nodes:r,opaque:o})}return t}function Ci(e,t,n){if(e.lineage===void 0)return n(e);if(!t||t.nodeType!==1)throw new TypeError("lineage requires an element root");let r=e.lineage,o=ba(r,t.ownerDocument),s=!1,i={...e,lineage:{elements:o,onResult(l,a){if(!s)return s=!0,r.onResult(l,a)}}};try{return ya.set(i.lineage,ka(o)),n(i)}catch(l){if(!s){s=!0;try{r.onResult({version:1,root:t,status:"incomplete",entries:o.map(Pn)},null)}catch{}}throw l}}function Mi(e,{liveRoot:t,localRoot:n,toLive:r}){let o=ba(e,t.ownerDocument),s=c=>c===t||t.contains(c),i=new Map,l=new Set(o.filter(s));if(l.size&&n===t)for(let c of l)i.set(c,c);else l.size&&(function c(d){let u=r(d);l.delete(u)&&i.set(u,d);for(let f=d.firstElementChild;f&&l.size;f=f.nextElementSibling)c(f)})(n);return{spec:e,watched:o,root:t,locals:Array.from(new Set(i.values())),before:ya.get(e)||ka(o),delivered:!1,result:null,finish(c,d){return this.resolve=d,this.plans=c,this.result={version:1,root:this.root,status:"complete",entries:o.map(u=>hd(u,i.get(u),c,d,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(c,d){this.root=d;let u=this.resolve,f=m=>{let k=u(m);return k===c?d:k};return this.finish(this.plans,f)},deliver(c){this.delivered||(this.delivered=!0,e.onResult(this.result,c))}}}var Pn=e=>({from:e,to:[],kind:"unknown",complete:!1});function hd(e,t,n,r,o){let s=o.root,i=f=>!!f&&(f===s||s.contains(f)),l=t&&n?n.get(t):null;if(!l||l.kind==="unknown")return Pn(e);let a=o.before.get(e);if(!a||a.opaque)return Pn(e);let c=a.nodes,d=f=>i(f)||!!(f&&f.ownerDocument===s.ownerDocument&&s.ownerDocument.documentElement?.contains(f));if(l.kind==="untouched"){if(!i(e))return Pn(e);for(let f of c)if(d(f)&&!e.contains(f))return Pn(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(l.kind==="removed")return d(e)||c.some(d)?Pn(e):{from:e,to:[],kind:"removed",complete:!0};let u=r(l.output);if(!u||u.nodeType!==1||!i(u)||u!==e&&d(e))return Pn(e);for(let f of c)if(d(f)&&!u.contains(f))return Pn(e);for(let f of l.owned){let p=r(f),m=Array.isArray(p)?p:[p];for(let k of m)if(!k||!i(k)||!u.contains(k))return Pn(e)}return l.carried&&!xa(u,l.output,r)?Pn(e):{from:e,to:[u],kind:u===e?"retained":"replaced",complete:!0}}function xa(e,t,n){for(let r=t.firstChild;r;r=r.nextSibling){let o=n(r),s=Array.isArray(o)?o:[o];for(let i of s)if(!i||!e.contains(i))return!1;if(r.nodeType===1&&!xa(e,r,n))return!1}return!0}function Ao(e,t,n){let r=Mi(e,{liveRoot:t,localRoot:t,toLive:o=>o});return r.result={version:1,root:t,status:"complete",entries:r.watched.map(o=>Pn(o))},n.lineage=r.result,r}function va(e,t,n,r,o){if(!o(e.length*8+1))return null;let s=0,i=t===0,l=!1;for(let a of pn(e,r)){if(!o(1))return null;if(s+=a.len,s===t&&(i=!0),s===n&&(l=!0),s>=n)break}return i&&l}function md(e,t,n,r,o,s,i){if(!i(t.length*2))return!1;let l=new Map,a=new Map,c=new Set;for(let d of t){let u=d.bs<d.be,f=u?n[d.ownerIndex].text.base:n[d.ownerIndex].text[e],p=u?d.bs:d.ss,m=u?d.be:d.se;if(!i((m-p)*4+1))return!1;for(;p<m&&/\s/.test(f[p]);)p++;for(;m>p&&/\s/.test(f[m-1]);)m--;if(p===m)continue;let k=f.slice(p,m),g=u?l:a;u&&d.text&&c.add(k),g.has(k)?g.set(k,null):g.set(k,{h:d,from:p,to:m})}for(let d of r){if(!i(1))return!1;if(d.side!==e)continue;let u=d.deletion,f=n[u.ownerIndex].text.base;if(!i((u.be-u.bs)*3)||c.has(f.slice(u.bs,u.be).trim()))return!1}for(let[d,u]of l){if(!i(d.length+1))return!1;let f=a.get(d);if(!u||!f)continue;let p=u.h,m=f.h;if(!p.text||p.transferOut||m.transferIn||p.owner===m.owner)continue;let k=n[p.ownerIndex],g=n[m.ownerIndex];if(!i(k.text.base.length))return!1;if(!/\S/.test(k.text.base.slice(0,p.bs)+k.text.base.slice(p.be)))continue;let h=va(k.text.base,u.from,u.to,s,i),y=va(g.text[e],f.from,f.to,s,i);if(h===null||y===null)return!1;if(!h||!y)continue;let A=`${k.index}:${u.from}:${u.to}`,w={key:A,side:e,source:p.owner,destination:m.owner,deletion:p,insertion:m,sourceOffset:u.from-p.bs,targetOffset:f.from-m.ss,length:u.to-u.from};p.transferOut=w,m.transferIn=w,o[e].set(A,w),r.push(w)}return!0}function wa({base:e,local:t,remote:n,localTwin:r,remoteTwin:o,eligible:s,nodes:i,budget:l=Zt(2e4*32)}){let a=_=>_>l.remaining?!1:(l.remaining-=_,l.nativeSteps=(l.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=i[_];if(j.length!==M.length||j.some((R,D)=>R!==M[D]))return null}let c=[],d=0;for(let _=0;_<e.length;_++){let M=e[_],j=t[_],R=n[_];if(r(M)!==j||o(M)!==R)return null;let D={};for(let[B,S]of[["base",M],["local",j],["remote",R]]){if(!s(S)||S.tagName!==M.tagName||S.namespaceURI!==M.namespaceURI||!a(S.childNodes.length+1))return null;let T="";for(let J of S.childNodes){if(J.nodeType!==3||!a(J.data.length*4+1))return null;T+=J.data}if(T.includes(Ot)||(d+=T.length+1,d>2e4))return null;D[B]=T}c.push({base:M,local:j,remote:R,index:_,text:D})}let u=c.every(_=>_n(_.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,R=_.text[M];if(j===R)continue;let D=j.length+R.length+4,B=D*8;if(!a(B))return null;let S=Math.floor(l.remaining/8),T=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(D*D+S)-D)/2)));if(T<1||!a(4*(T+1)*(D+T+1)))return null;let J=0;for(let q of wr(j,R,T)){if(!a(q.text.length+1))return null;let V=q.bs+J,Ce={...q,ss:V,se:V+q.text.length,toks:pn(q.text,u),owner:_.base,ownerIndex:_.index};_.hunks[M].push(Ce),f[M].push(Ce),J+=q.text.length-(q.be-q.bs)}}}let p=[],m={local:new Map,remote:new Map};for(let _ of["local","remote"]){let M=new Map,j=new Map,R=!1,D=(B,S,T)=>{B.has(S)?B.set(S,null):B.set(S,T)};for(let B of f[_]){if(!a(1))return null;let S=c[B.ownerIndex].text.base;if(B.bs<B.be&&B.text===""){let T=S.slice(B.bs,B.be);if(!a(T.length*2))return null;/\S/.test(T)&&D(M,T,B)}else if(B.bs===B.be&&/\S/.test(B.text)){if(!a(B.text.length*2))return null;D(j,B.text,B)}else B.bs<B.be&&(R=!0)}for(let[B,S]of M){if(!a(B.length+1))return null;let T=j.get(B);if(!S||!T||S.owner===T.owner)continue;let J=c[S.ownerIndex];if(!a(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,S.bs)+J.text.base.slice(S.be)))continue;let q=`${J.index}:${S.bs}:${S.be}`,V={key:q,side:_,source:S.owner,destination:T.owner,deletion:S,insertion:T};S.transferOut=V,T.transferIn=V,m[_].set(q,V),p.push(V)}if(R&&j.size&&!md(_,f[_],c,p,m,u,a))return null}if(!p.length)return null;let k=(_,M)=>_.bs<M.be&&M.bs<_.be,g=_=>_.bs===_.be,h=(_,M)=>_.bs<=M.be&&M.bs<=_.be&&g(_)!==g(M),y=(_,M)=>_.bs===M.bs&&_.be===M.be&&_.text===M.text,A=(_,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 p){let M=_.side==="local"?"remote":"local",j=c[_.deletion.ownerIndex];for(let R of j.hunks[M])if(!a(1)||k(_.deletion,R)&&R.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(y(M,j)){if(M.transferIn?.key!==j.transferIn?.key)return null;continue}if(k(M,j)||h(M,j)&&!A(M,j)&&!A(j,M))return null}if(!a(d*8))return null;let w=new Set([...e,...t,...n]),v={base:an(e,{blocks:w}),local:an(t,{blocks:w}),remote:an(n,{blocks:w})},E={};for(let _ of["base","local","remote"]){let M=v[_];if(M.atoms.length||M.pins.length)return null;E[_]=new Map(M.marks.filter(j=>j.block).map(j=>[j.el,j.from]))}for(let _ of c){let M=E.base.get(_.base);if(M===void 0)return null;for(let j of["local","remote"]){let R=E[j].get(_[j]);if(R===void 0)return null;for(let D of _.hunks[j])D.bs+=M,D.be+=M,D.ss+=R,D.se+=R}}for(let _ of p)_.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 N={};for(let _ of["local","remote"]){let M=0,j=0,R=[];for(let B of f[_]){if(!a(1))return null;B.bs>M&&R.push({from:M,to:B.bs,target:j}),M=B.be,j=B.se}M<v.base.text.length&&R.push({from:M,to:v.base.text.length,target:j});let D=p.filter(B=>B.side===_).map(B=>({from:B.bs,to:B.be,target:B.ss,destination:B.destination}));if(N[_]=Gn({base:v.base,side:v[_],retained:R,transfers:D,budget:l}),N[_].status!=="ready")return null}return a(v.base.text.length)?{owners:c,blocks:w,transfers:p,byOrigin:m,budget:l,prepared:{base:v.base,local:v.local,remote:v.remote,lines:!1,baseTokens:pn(v.base.text,u),localEdits:{hunks:f.local,respell:new Map},remoteEdits:{hunks:f.remote,respell:new Map},localMap:N.local,remoteMap:N.remote,full:null}}:null}var Ri=/\S/;function Aa({certificates:e,scopes:t,views:n,eligible:r,baseId:o,limit:s=2e4*32}){let i=Zt(s),l=Symbol(),a=[],c=u=>{if(u>i.remaining)throw l;i.remaining-=u},d=(u,f=null)=>{if(c(1),!u||u.nodeType!==1||u.parentNode?.nodeType!==1||!r(u))return null;for(let k=u.parentNode;k;k=k.parentNode)if(c(1),k.nodeType===11)return null;let p="",m=0;for(let k of u.childNodes){if(c(1),k.nodeType!==3)return null;if(c(k.data.length*4+1),f){let g=f.flat.nodes[m++];if(!g||g.node!==k||g.s!==p.length||g.e!==p.length+k.data.length)return null}p+=k.data}return c(p.length*3+1),f&&(f.flat.atoms.length||f.flat.pins?.length||m!==f.flat.nodes.length||f.flat.text!==p)?null:Ri.test(p)?p:null};try{c(t[0].length+t[1].length+t[2].length+e.length);let u=t.map(p=>new Set(p)),f=new Map;for(let p of e){c(1);let m=f.get(p.source);m||f.set(p.source,m=[]),m.push(p)}for(let p of f.values()){let m=[null,null],k=[];for(let g of p){c(1);let{source:h,target:y,side:A,models:w,runs:v}=g;if(A!==0&&A!==1||!u[0].has(h)||!u[A+1].has(y))continue;let{V:E,A:N,idOf:_}=n[A],M=n[1-A],j=E.twin(h),R=M.V.twin(h),D=E.baseOf(y);if(!j||!R||!D||D===h||!u[0].has(D)||!u[A+1].has(j)||!u[2-A].has(R)||N.map.get(h)!==j||N.reverse.get(j)!==h||M.A.map.get(h)!==R||M.A.reverse.get(R)!==h||N.map.get(D)!==y||N.reverse.get(y)!==D||y.parentNode!==j.parentNode||D.parentNode!==h.parentNode||h.tagName!==j.tagName||h.tagName!==R.tagName||o(h)!==_(j)||o(h)!==M.idOf(R)||o(D)!==_(y))continue;let B=w.get(h),S=w.get(y);if(!B||!S)continue;let T=d(h,B),J=d(y,S),q=d(j),V=d(R);if(c((T?.length||0)+(V?.length||0)),T===null||J===null||q===null||V===null||V===T)continue;let Ce=v.length>0,Me=!1;for(let ce of v){if(c(1),ce.source!==h||ce.target!==y||!Number.isInteger(ce.from)||!Number.isInteger(ce.to)||!Number.isInteger(ce.targetFrom)||ce.from<0||ce.to<=ce.from||ce.to>T.length||ce.targetFrom<0||ce.targetFrom+ce.to-ce.from>J.length){Ce=!1;break}c((ce.to-ce.from)*3);for(let Ae=ce.from;Ae<ce.to;Ae++){if(T[Ae]!==J[ce.targetFrom+Ae-ce.from]){Ce=!1;break}Ri.test(T[Ae])&&(Me=!0)}if(!Ce)break}if(!Ce||!Me)continue;let Fe=m[A];Fe||(c(T.length),Fe=m[A]={source:h,side:A,flat:B.flat,before:T,covered:new Uint8Array(T.length)});for(let ce of v)c(ce.to-ce.from),Fe.covered.fill(1,ce.from,ce.to)}for(let g of m){if(!g)continue;let{source:h,side:y,flat:A,before:w,covered:v}=g;c(w.length*3+1);let E=-1,N=-1;for(let _=0;_<=w.length;_++)_<w.length&&v[_]?(E<0&&(E=_),N=_+1):(_===w.length||Ri.test(w[_]))&&E>=0&&(k.push({source:h,side:y,flat:A,from:E,to:N}),E=N=-1)}c(k.length),a.push(...k)}}catch(u){if(u!==l)throw u}return{records:a,budget:i}}var pd="http://www.w3.org/1999/xhtml";function gd(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 vn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===pd}function bd(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function as(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+"|"+gd(e.textContent.trim())}var yd={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function $r(e,t=[],n=!1){if(!vn(e)||e.hasAttribute("src"))return null;let r=[yd,...t];for(let o=0;o<r.length;o++){let s=r[o];if(!s.match(e))continue;if(!bd(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 Sa(e,t,n){let r=new Set,o=s=>{vn(s)&&!t(s)&&r.add(as(s,n))};o(e);for(let s of e.querySelectorAll("script"))o(s);return r}function So(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 Ta(e,t,n){let r=[],o=[],s=new Map,i=n.trackRecovery?new Set:null,l=Array.from(e.querySelectorAll("script"));vn(e)&&l.unshift(e);for(let a of l){if(!vn(a)||n.ignored(a)||n.skip.has(a)||t.has(as(a,n.baseURI)))continue;let c=a.ownerDocument.createElement("script");for(let d of a.attributes)c.setAttribute(d.name,d.value);if(c.textContent=a.textContent,n.beforeNodeAdded(c)===!1){i?.add(a);continue}c.hasAttribute("src")&&o.push(new Promise(d=>{c.addEventListener("load",()=>d()),c.addEventListener("error",()=>d())})),a.replaceWith(c),s.set(a,c),n.afterNodeAdded(c),r.push(c)}return{executed:r,loads:o,swapped:s,vetoed:i}}function kd(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 xd(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function Ea(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return as(e,t);if(n==="LINK"){let r=e.getAttribute("href");return r?"link|"+(e.getAttribute("rel")||"")+"|"+xd(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|"+kd(e.textContent):e.outerHTML}function Ii(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 vd(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var wd=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Ad=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Li(e){try{return JSON.parse(e)}catch{return JSON.parse(Sd(e))}}function Sd(e){let t="",n=0,r=(o,s)=>{throw new Error(`Invalid relaxed JSON: ${o} at position ${s}`)};for(;n<e.length&&(n=Ii(e,n),!(n>=e.length));){let o=e[n];if("{}[]:".includes(o)){t+=o,n++;continue}if(o===","){let l=Ii(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=vd(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"||wd.test(i)){t+=i,n=s;continue}if(Ad.test(i)){if(e[Ii(e,s)]===":"){t+='"'+i+'"',n=s;continue}r("unquoted value "+JSON.stringify(i),n)}r("invalid token "+JSON.stringify(i),n)}return t}var Xt=Symbol("hyper-morph-json-merge:missing"),Td=["id","_id","uuid","key","slug","code","name"];function Hr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function To(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ed(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}var Od=/^[A-Za-z_$][\w$]*$/;function Nd(e,t){return Od.test(t)?e===""?t:e+"."+t:e+"["+JSON.stringify(t)+"]"}function _d(e,t){return e===""?t:e+"."+t}function cs(e,t,n,r,o,s){if(e.onConflict){let i=l=>l===Xt?void 0:l;e.onConflict({path:t,base:i(n),local:i(r),remote:i(o),resolved:i(s)})}return s}function Qn(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(!Qn(e[n],t[n]))return!1;return!0}if(Hr(e)&&Hr(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!To(t,r)||!Qn(e[r],t[r]))return!1;return!0}return!1}function Pi(e,t,n,r,o,s){return Qn(t,n)?t:Qn(t,e)?n:Qn(n,e)?t:Hr(t)&&Hr(n)?Cd(Hr(e)?e:{},t,n,r,o,s):Array.isArray(t)&&Array.isArray(n)?Ld(e,t,n,r,o,s):cs(r,o,e,t,n,n)}function Oa(e,t,n,r,o,s){return t===Xt&&n===Xt?Xt:t===Xt?e===Xt?n:Qn(n,e)?Xt:cs(r,o,e,t,n,n):n===Xt?e===Xt?t:Qn(t,e)?Xt:cs(r,o,e,t,n,Xt):Pi(e,t,n,r,o,s)}function Cd(e,t,n,r,o,s){let i={},l=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let a of l){let c=Oa(To(e,a)?e[a]:Xt,To(t,a)?t[a]:Xt,To(n,a)?n[a]:Xt,r,Nd(o,a),_d(s,a));c!==Xt&&Ed(i,a,c)}return i}function Md(e){return e===null||typeof e!="object"}function fs(e){return typeof e+":"+String(e)}function Rd(e,t){for(let n of t){let r=new Set;for(let o of n){if(!To(o,e))return!1;let s=o[e];if(typeof s!="string"&&typeof s!="number")return!1;let i=fs(s);if(r.has(i))return!1;r.add(i)}}return!0}function Id(e,t,n,r,o){let s=[e,t,n],i=!0;for(let l of s)for(let a of l)Hr(a)||(i=!1);if(i){let l=r.keyPaths.get(o),a=l!==void 0?[l]:r.keyCandidates;for(let c of a)if(Rd(c,s))return{kind:"keyed",field:c};return null}for(let l of s){let a=new Set;for(let c of l){if(!Md(c))return null;let d=fs(c);if(a.has(d))return null;a.add(d)}}return{kind:"self"}}function Ld(e,t,n,r,o,s){let i=Array.isArray(e)?e:[],l=Id(i,t,n,r,s),a=Array.isArray(e)&&e.length===t.length&&e.length===n.length;if(!l||l.kind==="self"&&a)return a?t.map((A,w)=>Pi(e[w],A,n[w],r,o+"["+w+"]",s)):cs(r,o,e,t,n,n);let c=l.kind==="self"?fs:A=>fs(A[l.field]),d=A=>l.kind==="self"?o+"["+JSON.stringify(A)+"]":o+"["+l.field+"="+JSON.stringify(A[l.field])+"]",u=new Map,f=A=>{let w=new Map;for(let v of A){let E=c(v);w.set(E,v),u.has(E)||u.set(E,d(v))}return w},p=f(i),m=f(t),k=f(n),g=new Map,h=new Set([...p.keys(),...m.keys(),...k.keys()]);for(let A of h){let w=Oa(p.has(A)?p.get(A):Xt,m.has(A)?m.get(A):Xt,k.has(A)?k.get(A):Xt,r,u.get(A),s);w!==Xt&&g.set(A,w)}let y=[];for(let A of n){let w=c(A);g.has(w)&&y.push(w)}for(let A=0;A<t.length;A++){let w=c(t[A]);if(!g.has(w)||y.includes(w))continue;let v=0;for(let E=A-1;E>=0;E--){let N=y.indexOf(c(t[E]));if(N!==-1){v=N+1;break}}y.splice(v,0,w)}return y.map(A=>g.get(A))}function Pd(e){let t=new Map,n=[];for(let r of e.keyCandidates||[]){let o=r.lastIndexOf(":");o>=0?t.set(r.slice(0,o),r.slice(o+1)):n.push(r)}return{keyCandidates:[...n,...Td],keyPaths:t,onConflict:e.onConflict||null}}function Na(e,t,n,r={}){return Pi(e===void 0?Xt:e,t,n,Pd(r),"","")}function jd(e,t){let n=/^\s*/.exec(t)[0],r=/\s*$/.exec(t.slice(n.length))[0],o=t.slice(n.length,t.length-r.length),s=n.slice(n.lastIndexOf(`
|
|
5
5
|
`)+1),i=/\n([ \t]+)\S/.exec(o),l;if(!i)l=JSON.stringify(e);else{let a=i[1],c=a.length>s.length&&a.startsWith(s)?a.slice(s.length):" ";l=JSON.stringify(e,null,c).replace(/\n/g,`
|
|
6
|
-
`+s)}return n+l.replace(/</g,"\\u003c")+r}function Mi(e,t,n,r={}){let o=r.parse||Ni,s=[],i=[],l=(f,p)=>{if(typeof f!="string")return Xt;try{return o(f)}catch(m){return s.push(`${p} side is not valid JSON (${m.message})`),Xt}},a=l(t,"local"),c=l(n,"remote");if(a===Xt)return{text:n,warnings:s,conflicts:i};if(c===Xt)return{text:t,warnings:s,conflicts:i};let h=l(e,"base"),u=Aa(h===Xt?void 0:h,a,c,{...r,onConflict:f=>{i.push(f),r.onConflict?.(f)}});return Qn(u,c)?{text:n,warnings:s,conflicts:i}:Qn(u,a)?{text:t,warnings:s,conflicts:i}:{text:Td(u,n),warnings:s,conflicts:i}}var Sa=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Ar(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>Sa(t)||o>Sa(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 fr(e,t,n={}){if(!Ar(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 g=r;g;g=g.parentNode)l.add(g);let a=s;for(;!l.has(a);)a=a.parentNode;let c=(g,d)=>{let k=a.ownerDocument.createRange(),A=a.ownerDocument.createRange();return k.setStart(g[0],g[1]),k.collapse(!0),A.setStart(d[0],d[1]),A.collapse(!0),k.compareBoundaryPoints(0,A)},h=(g,d=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(d)],u=[],f;if(t==="plain"){f="";let g=d=>{if(d.nodeType===3||d.nodeType===8){let k=f.length;f+=d.nodeValue,u.push({s:k,e:f.length,a:[d,0],b:[d,d.nodeValue.length],node:d})}else for(let k of d.childNodes)g(k)};g(a)}else{let g=n.blocks;if(!g){g=new Set;let k=A=>{A!==a&&A.nodeType===1&&wi.has(A.tagName)&&g.add(A);for(let w of A.childNodes)k(w)};k(a)}let d=an(Array.from(a.childNodes),{blocks:g,atomize:k=>!!n.atoms?.has(k),ignored:n.ignored});f=d.text;for(let k of d.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 d.atoms)u.push({s:k.i,e:k.i+1,a:h(k.el),b:h(k.el,!0)});for(let k=0;k<d.text.length;k++){if(d.text[k]!==Ot)continue;let A=d.marks.find(v=>v.block&&v.to===k+1),w=d.marks.find(v=>v.block&&v.from===k+1);if(A)u.push({s:k,e:k+1,a:[A.el,A.el.childNodes.length],b:h(A.el,!0)});else if(w)u.push({s:k,e:k+1,a:h(w.el),b:[w.el,0]});else return null}}u.sort((g,d)=>g.s-d.s);let p=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let k=u.find(A=>A.node===g[0]);return k?k.s+g[1]:null}let d=0;for(let k of u){if(c(g,k.a)<=0)return k.s;if(c(g,k.b)<0)return null;d=k.e}return d},m=p([r,o]),y=p([s,i]);return m!==null&&y!==null&&m<=y?f.slice(m,y):null}function wr(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 Ta(e,t){if(!e||!t)return null;let n=wr(e,t.start),r=wr(e,t.end);return n&&r?{startContainer:n[0],startOffset:n[1],endContainer:r[0],endOffset:r[1]}:null}var Ea=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Oa(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 c=l.local.map(h=>wr(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:Ea(h)}));return o.set(l,c),c},i=l=>{let a=Ta(t.localRoot,l);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 Ar(u)?u:null};for(let l of e){let a=l.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=i(a.text.local.span),c.scope=i(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=p=>{if(u.intersectsNode(p)){c.touched.add(p);for(let m of p.childNodes)f(m)}};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 _a(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 c=h=>Array.prototype.indexOf.call(a.parentNode.childNodes,h);return!(l.previous&&r(l.previous)&&l.previous.parentNode===a.parentNode&&c(l.previous)>=c(a)||l.next&&r(l.next)&&l.next.parentNode===a.parentNode&&c(l.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 l=e.text.local,a=c=>c&&r(c.startContainer)&&r(c.endContainer);return a(o.span)&&a(o.scope)&&fr(o.scope,e.text.encoding)===l.text&&fr(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 c of i.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<=l)return!1;a=h.parentNode,l=u}return!0}return i.localAction==="moved"||o.subject.every(l=>Ea(l.node)===l.fragment)}var Ed=1,kn=e=>!!e&&e.nodeType===1,cs=e=>kn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function Sr(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();cs(f)&&(t.set(f.content,f),u.push(f.content));for(let p=f.firstChild;p;p=p.nextSibling)p.nodeType===1&&u.push(p)}}return t.get(h)||null},i=(h,u)=>{let f=o.get(h);if(!f){f=new Map;let p=0;for(let m=h.firstChild;m;m=m.nextSibling)f.set(m,p++);o.set(h,f)}return f.get(u)},l=h=>{if(!h)return null;if(n&&n.has(h))return l(n.get(h));if(h===e)return[];let u=r.get(h);if(u!==void 0)return u;let f=h.parentNode,p=null;if(f&&f.nodeType===11){let m=s(f),y=m?l(m):null;y&&(p=y.concat(["content",i(f,h)]))}else if(f){let m=l(f);m&&(p=m.concat([i(f,h)]))}return r.set(h,p),p};return{root:e,pathOf:l,logicalParent:h=>{let u=h.parentNode;return u&&u.nodeType===11?s(u):u},indexIn:i,containerPath:h=>{if(h.nodeType===11){let f=s(h),p=l(f);return p?p.concat(["content"]):null}let u=l(h);return u&&cs(h)?u.concat(["content"]):u},ownerOf:s}}var Fn=e=>cs(e)?e.content:e;function Na(e){let{L:t,R:n,unitsOf:r,provenance:o,policy:s}=e,i=[];return{note:(h,u)=>{i.push([h,u])},finish:h=>i.length?c(h):null};function c(h){let u={base:Sr(e.roots.base),local:Sr(e.roots.local),remote:Sr(e.roots.remote)},f=K=>K==="local"?t:n,p=(K,b)=>{if(!b)return null;if(K.map.has(b))return K.map.get(b);let C=[],L=kn(b)?u.base.logicalParent(b):b.parent;for(;L&&!K.map.has(L);L=u.base.logicalParent(L))C.push(L);if(!L||!K.identical.has(L))return null;let $=K.map.get(L);for(let Q=C.length-1;Q>=0&&$;Q--)$=Fn($).childNodes[u.base.indexIn(C[Q].parentNode,C[Q])];return $?kn(b)?Fn($).childNodes[u.base.indexIn(b.parentNode,b)]||null:r($)[r(b.parent).indexOf(b)]||null:null},m=new Map,y=new Map,g=new WeakMap,d=0,k=(K,b)=>{let C=m.get(K);C||m.set(K,C=[]),C.push(b)};(function K(b){y.set(b,d++);let C=o.get(b);if(C&&!C.pinned){for(let L of[C.base,C.local,C.remote])if(L)if(Array.isArray(L))for(let $ of L)k($,b);else k(L,b)}if(cs(b)){g.set(b.content,b);for(let L=b.content.firstChild;L;L=L.nextSibling)K(L)}for(let L=b.firstChild;L;L=L.nextSibling)K(L)})(h);let A=new Map;u.out=Sr(h,g,A);let w={refs:new Map,spans:new Map,anchors:new Map,via:A,outOwners:g,outRoot:h,localRoot:e.roots.local},v=K=>kn(K)?[K]:K.nodes,E=(K,b)=>{let C=u[b].logicalParent(K);if(!C)return null;for(let L of r(C))if(!kn(L)&&L.nodes.includes(K))return L;return null},N=(K,b)=>K==null?null:Array.isArray(K)?K.length?E(K[0],b):null:K,_=K=>{let b=new Set,C=[];for(let L of K)for(let $ of m.get(L)||[])b.has($)||(b.add($),C.push($));return C.sort((L,$)=>y.get(L)-y.get($))},M=new Map,j=K=>{let b=K.b||K.l||K.r,C=M.get(b);if(C)return C;let L=[];for(let $ of[K.b,K.l,K.r])$&&L.push(...v($));return C=_(L),M.set(b,C),C},R=K=>({b:K,l:p(t,K),r:p(n,K)}),D=(K,b)=>{let C=f(b).reverse.get(K);if(C)return R(C);for(let L of _(v(K))){let $=o.get(L);if($&&!$.base&&$.local&&$.remote)return{b:null,l:N($.local,"local"),r:N($.remote,"remote")}}return b==="local"?{b:null,l:K,r:null}:{b:null,l:null,r:K}},F=new Map,S=K=>{let b=o.get(K);if(!b||b.pinned)return null;let C=N(b.base,"base");if(C)return R(C);let L=N(b.local,"local"),$=N(b.remote,"remote");if(L){let Q=t.reverse.get(L);if(Q)return R(Q)}if($){let Q=n.reverse.get($);if(Q)return R(Q)}return L||$?{b:null,l:L,r:$}:null},T=K=>(F.has(K)||F.set(K,S(K)),F.get(K)),J=(K,b)=>kn(K)?u[b].logicalParent(K):K.parent,q=new Map,V=new Map,Ce=(K,b)=>(kn(K)?[u[b].pathOf(K)]:K.nodes.map(C=>u[b].pathOf(C))).filter(Boolean),Me=K=>{let b=K.b||K.l||K.r,C=K.b?"base":K.l?"local":"remote",L=V.get(b);if(L)return L;let $=!kn(b),Q=Ce(b,C)[0],B=`${C[0]}:${JSON.stringify(Q===void 0?null:Q)}${$?":run":""}`,he=q.get(B);if(he)return V.set(b,he),he;let ye=j(K);return he={key:B,nodeType:kn(b)?1:b.kind==="comment"?8:3,base:K.b?Ce(K.b,"base"):[],local:K.l?Ce(K.l,"local"):[],remote:K.r?Ce(K.r,"remote"):[],merged:ye.map(ie=>u.out.pathOf(ie)).filter(Boolean),live:[]},q.set(B,he),V.set(b,he),w.refs.set(he,ye),he},Be={base:new Map,local:new Map,remote:new Map},ce=new Map,Ae=(K,b)=>{let C=J(K,b);if(!C||C.nodeType!==1)return null;let L=Be[b].get(C);if(!L){let Q=r(C),B=he=>Me(b==="base"?R(he):D(he,b));L={parent:B(C),refs:Q.map(B),index:new Map(Q.map((he,ye)=>[he,ye]))},Be[b].set(C,L)}let $=L.index.get(K)??-1;return{parent:L.parent,before:L.refs.slice($+1),after:L.refs.slice(0,Math.max(0,$)).reverse()}},Ue=K=>{let b=K.parentNode;if(!b)return null;let C=ce.get(b);if(!C){let $=b.nodeType===11?g.get(b):b,Q=$&&$.nodeType===1?T($):null;if(!Q)return null;let B=[],he=[],ye=new Map;for(let _e of b.childNodes){let U=T(_e),Y=U&&Me(U),pe=B.length,ke=B.length-1;Y&&Y!==B[ke]&&(B.push(Y),ke++);let me={ref:Y,group:ke,after:pe};he.push(me),ye.set(_e,me)}let ie=B.length;for(let _e=he.length-1;_e>=0;_e--){let U=he[_e];U.before=ie,U.ref&&(ie=U.group)}C={parent:Me(Q),refs:B,index:ye},ce.set(b,C)}let L=C.index.get(K);return{parent:C.parent,before:C.refs.slice(L.before),after:C.refs.slice(0,L.after).reverse()}},Ne=K=>kn(K)?K.outerHTML:K.value,O=K=>kn(K)?"element":K.kind==="comment"?"comment":"text",X=(K,b)=>({path:K,offset:b}),le=(K,b,C)=>{if(!K)return null;let L=u[C],$=0;if(b){let Q=kn(b)?b:b.nodes[b.nodes.length-1];Q.parentNode&&($=L.indexIn(Q.parentNode,Q)+1)}return X(L.containerPath(K),$)},re=(K,b)=>{let C=J(K,"base"),L=C?p(f(b),C):null;if(!kn(L))return null;let $=r(C),Q=null;for(let B=$.indexOf(K)-1;B>=0&&!Q;B--){let he=p(f(b),$[B]);he&&J(he,b)===L&&(Q=he)}return le(L,Q,b)},Pe=(K,b,C,L)=>{let $=u[L],Q=0;for(let B=0;B<K.nodes.length;B++){let he=K.nodes[B],ye=he.nodeValue.length,ie=B===K.nodes.length-1;if((C==="start"?b<Q+ye:b<=Q+ye)||ie)return X($.pathOf(he),Math.max(0,Math.min(b-Q,ye)));Q+=ye}return null},Fe=(K,b)=>{let C=u[b],L=K.firstChild,$=K.lastChild;return L&&L.nodeType===3&&$.nodeType===3?{start:X(C.pathOf(L),0),end:X(C.pathOf($),$.nodeValue.length)}:{start:X(C.pathOf(K),0),end:X(C.pathOf(K),K.childNodes.length)}},Te=(K,b,C)=>{for(let B of K.nodes)if(C==="start"?B.s<=b&&b<B.e:B.s<b&&b<=B.e)return{kind:"text",node:B.node,offset:b-B.s};let L=C==="start"?b:b-1,$=()=>{for(let B of K.nodes)if(B.s===b||B.e===b)return{kind:"text",node:B.node,offset:b-B.s};return null},Q=K.atomAt.get(L);if(Q)return{kind:C==="start"?"before":"after",node:Q.el};if(K.text[L]===Ot){let B=K.marks.find(ye=>ye.block&&ye.to===L+1);if(B)return C==="start"?{kind:"end",node:B.el}:{kind:"after",node:B.el};let he=K.marks.find(ye=>ye.block&&ye.from===L+1);if(he)return C==="start"?{kind:"before",node:he.el}:{kind:"startOf",node:he.el}}return $()},ot=(K,b)=>Te(K,b,"end")||Te(K,b,"start"),et=(K,b)=>{switch(b.kind){case"text":return X(K.pathOf(b.node),b.offset);case"end":return X(K.containerPath(b.node),Fn(b.node).childNodes.length);case"startOf":return X(K.containerPath(b.node),0);default:{let C=b.node.parentNode;return X(K.containerPath(C),K.indexIn(C,b.node)+(b.kind==="after"?1:0))}}},ae=(K,b,C,L,$)=>{let Q=Te(K,b,C);return Q?et(u[L],Q):$()},de=(K,b,C,L)=>{let $=K.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,_e]of K.atomOut)$.push({s:ie,e:ie+1,start:{kind:"before",node:_e},end:{kind:"after",node:_e}});for(let[ie,_e]of K.breakOut)$.push({s:ie,e:ie+1,start:{kind:"end",node:_e},end:{kind:"after",node:_e}});for(let ie of $)if(ie.start.kind==="text"&&ie.s<b&&b<ie.e)return{kind:"text",node:ie.start.node,offset:b-ie.s};if(C!=="empty"){let ie=$.find(_e=>C==="start"?_e.s===b:_e.e===b);if(ie)return C==="start"?ie.start:ie.end}let Q=$.find(ie=>ie.e===b);if(Q)return Q.end;let B=$.find(ie=>ie.s===b);if(B)return B.start;let he=null,ye=null;for(let ie of $)ie.e<=b&&(!he||ie.e>he.e)&&(he=ie),ie.s>=b&&(!ye||ie.s<ye.s)&&(ye=ie);return he?he.end:ye?ye.start:L()},Ee=(K,b)=>{if(!b)return null;if(b.kind==="text"){let $=K.nodes.find(Q=>Q.node===b.node);return $?$.s+Math.min(b.offset,$.e-$.s):null}let C=K.atoms.find($=>$.el===b.node);if(C)return b.kind==="after"?C.i+1:C.i;let L=K.marks.find($=>$.el===b.node);return L?b.kind==="before"&&L.block&&K.text[L.from-1]===Ot&&!K.marks.some($=>$.block&&$.to===L.from)?L.from-1:b.kind==="startOf"||b.kind==="before"?L.from:b.kind==="end"&&L.block?L.to-1:L.to:null},Ge=(K,b,C,L)=>{for(let he of K.nodes)if(C==="start"?he.s<=b&&b<he.e:he.s<b&&b<=he.e)return{kind:"text",node:he.node,offset:b-he.s};let $=C==="start"?b:b-1;if(!K.atomAt.has($)&&K.text[$]!==Ot){for(let he of K.nodes)if(he.s===b||he.e===b)return{kind:"text",node:he.node,offset:b-he.s}}let Q=K.atomAt.get($);if(Q)return{kind:C==="start"?"before":"after",node:Q.el};if(K.text[$]===Ot){let he=K.marks.find(ie=>ie.block&&ie.to===$+1);if(he)return C==="start"?{kind:"end",node:he.el}:{kind:"after",node:he.el};let ye=K.marks.find(ie=>ie.block&&ie.from===$+1);if(ye)return C==="start"?{kind:"before",node:ye.el}:{kind:"startOf",node:ye.el}}let B=K.marks.find(he=>he.block&&he.from===b);return B?{kind:"startOf",node:B.el}:L?{kind:C==="start"?"startOf":"end",node:L}:null},Ve=K=>{if(!K)return null;if(K.kind==="wholeStart"||K.kind==="wholeEnd"){let b=ze(K.node);return K.kind==="wholeStart"?b.start:b.end}return et(u.out,K)},ze=K=>{let b=K.firstChild,C=K.lastChild;return b&&b.nodeType===3&&C.nodeType===3?{start:X(u.out.pathOf(b),0),end:X(u.out.pathOf(C),C.nodeValue.length)}:{start:X(u.out.pathOf(K),0),end:X(u.out.pathOf(K),K.childNodes.length)}},lt=K=>{let b=J(K,"base"),C=b?j(R(b))[0]:null;if(!C)return null;let L=Fn(C),$=r(b);for(let Q=$.indexOf(K)-1;Q>=0;Q--){let B=j(R($[Q])).filter(he=>he.parentNode===L);if(B.length)return{kind:"after",node:B[B.length-1]}}return{kind:"startOf",node:C}},pt=(K,b,C,L,$,Q)=>({text:K,start:b,end:C,fragment:L,span:$,scope:Q}),Rt=(K,b,C,L,$)=>pt(K,b,C,K.slice(b,C),L,$),dt=(K,b,C,L,$)=>(w.spans.set(K,{start:b,end:C,scopeStart:L,scopeEnd:$}),K),vt=new Map,gt=new Map,yn=(K,b,C)=>{let L=`text:${K.key}:${b}:${C}`,$=gt.get(L)||0;return gt.set(L,$+1),`${L}:${$}`},Bt=(K,b)=>{let C,L,$,Q="plain",B,he,ye,ie,_e,U=(ke,me,ee,te,W)=>{if(!ke){let ne=re(W,te);return Rt("",0,0,{start:ne,end:ne},{start:ne,end:ne})}return Rt(ke.value,me,ee,{start:Pe(ke,me,me===ee?"end":"start",te),end:Pe(ke,ee,"end",te)},{start:Pe(ke,0,"start",te),end:Pe(ke,ke.value.length,"end",te)})};if(b.site==="run"){let{bRun:ke,lRun:me,rRun:ee,node:te,c:W}=b;C=R(ke),L=W.bs,$=W.be,B=U(ke,W.bs,W.be,"base",ke),he=U(me,W.ls,W.le,"local",ke),ye=U(ee,W.rs,W.re,"remote",ke);let ne=te?te.nodeValue:"",we=Ie=>te?{kind:"text",node:te,offset:Ie}:lt(ke);ie=dt(Rt(ne,W.ms,W.me,{start:Ve(we(W.ms)),end:Ve(we(W.me))},{start:Ve(we(0)),end:Ve(we(ne.length))}),we(W.ms),we(W.me),we(0),we(ne.length)),_e=te||(lt(ke)||{}).node||null}else if(b.site==="whole"){let ke=b.el,me=o.get(ke);C=R(me.base),L=0,$=K.base.length;let ee=(W,ne,we)=>{let Ie=Fe(ne,we);return Rt(W,0,W.length,Ie,Ie)};B=ee(K.base,me.base,"base"),he=ee(K.local,me.local,"local"),ye=ee(K.remote,me.remote,"remote");let te=ze(ke);ie=dt(Rt(K.resolved,0,K.resolved.length,te,te),{kind:"wholeStart",node:ke},{kind:"wholeEnd",node:ke},{kind:"wholeStart",node:ke},{kind:"wholeEnd",node:ke}),_e=ke}else if(b.site==="comment"){let{bRun:ke,lRun:me,rRun:ee,node:te}=b;C=R(ke),L=0,$=K.base.length;let W=(je,Se)=>{if(!je){let st=re(ke,Se);return Rt("",0,0,{start:st,end:st},{start:st,end:st})}let Je=je.nodes[0],nt={start:X(u[Se].pathOf(Je),0),end:X(u[Se].pathOf(Je),je.value.length)};return Rt(je.value,0,je.value.length,nt,nt)};B=W(ke,"base"),he=W(me,"local"),ye=W(ee,"remote");let ne=K.resolved,we=je=>te?{kind:"text",node:te,offset:je}:lt(ke),Ie={start:Ve(we(0)),end:Ve(we(ne.length))};ie=dt(Rt(ne,0,ne.length,Ie,Ie),we(0),we(ne.length),we(0),we(ne.length)),_e=te||(lt(ke)||{}).node||null}else{let{fb:ke,fl:me,fr:ee,scope:te}=b,W=b.merged;Q="html",C=te.base?R(te.base):D(te.local,"local"),L=K.bs,$=K.be;let ne=oe=>{let Re=te[oe];for(let De=te.at-1;De>=0;De--){let We=te.units[De],Ye=oe==="base"?We:p(f(oe),We);if(Ye&&J(Ye,oe)===Re)return Ye}return null},we=oe=>()=>le(te[oe],ne(oe),oe),Ie=(oe,Re,De,We,Ye)=>{let wt=En=>En?et(u[Ye],En):we(Ye)(),at=Re===De?ot(oe,Re):Te(oe,Re,"start"),Wt=Re===De?ot(oe,Re):Te(oe,De,"end"),zt=wt(at),bn={start:zt,end:Re===De?zt:wt(Wt)},Tt=b.full?b.full(Ye):null;if(!Tt)return pt(oe.text,Re,De,We,bn,{start:wt(Te(oe,0,"start")),end:wt(Te(oe,oe.text.length,"end"))});let ht=at?Ee(Tt,at):null,Qe=Wt?Ee(Tt,Wt):null,Mt=ht===null?0:ht,bt=Math.max(Mt,Qe===null?Tt.text.length:Qe),Ut=wt(Te(Tt,0,"start"));return pt(Tt.text,Mt,bt,Dr(Tt,Mt,bt),bn,{start:Ut,end:Tt.text.length?wt(Te(Tt,Tt.text.length,"end")):Ut})};B=b.synthetic?null:Ie(ke,K.bs,K.be,K.base,"base"),he=Ie(me,K.lss,K.lse,K.local,"local"),ye=Ie(ee,K.rss,K.rse,K.remote,"remote");let[je,Se]=K.range||[0,0],Je=W.out,nt=()=>{let oe=Fn(W.node);for(let Re=te.at-1;Re>=0;Re--){let De=j(R(te.units[Re])).filter(We=>We.parentNode===oe);if(De.length)return{kind:"after",node:De[De.length-1]}}for(let Re=te.at;Re<te.units.length;Re++){let De=j(R(te.units[Re])).filter(We=>We.parentNode===oe);if(De.length)return{kind:"before",node:De[0]}}return{kind:"startOf",node:W.node}};if(Je.via)for(let[oe,Re]of Je.via)A.set(oe,Re);let st=de(W,je,je===Se?"empty":"start",nt),$t=je===Se?st:de(W,Se,"end",nt),Ft=Je.text.length?Ge(Je,0,"start",W.node):nt(),I=Je.text.length?Ge(Je,Je.text.length,"end",W.node):Ft,G=Ee(Je,st),se=Ee(Je,$t),be=G===null?0:G,xe=Math.max(be,se===null?Je.text.length:se);ie=dt(pt(Je.text,be,xe,Dr(Je,be,xe),{start:Ve(st),end:Ve($t)},{start:Ve(Ft),end:Ve(I)}),st,$t,Ft,I);let fe=w.spans.get(ie);if(fe.flat=Je,!Je.text.length){let oe=Ve(Ft),Re=wr(h,oe),De=Re[0],We=Re[1];fe.empty={parent:De.nodeType===11?g.get(De):De,previous:De.childNodes[We-1]||null,next:De.childNodes[We]||null}}_e=st?st.node:W.node}let Y=Me(C),pe=(b.site==="whole"||b.site==="comment"||(b.policy||s)!=="both")&&K.resolved!==K.local;return{key:b.site==="comment"&&vt.get(C.b||C.l||C.r)||yn(Y,L,$),subject:Y,localLost:pe,anchor:_e,text:{encoding:Q,base:B,local:he,remote:ye,merged:ie,liveSpan:null,liveScope:null}}},Qt=(K,b)=>{let C=T(b.el),L=Me(C),$=b.sample;return{key:`attr:${L.key}:${$.namespaceURI||""}:${$.localName}`,subject:L,localLost:K.resolved!==K.local,anchor:b.el,attribute:{namespaceURI:$.namespaceURI||null,localName:$.localName,qualifiedName:$.name}}},Yt=(K,b)=>{let C=K.detail,L=b.unit||R(b.subject),$=Me(L),Q=w.refs.get($),B=L.l?Ae(L.l,"local"):null,he=L.r?Ae(L.r,"remote"):null,ye=Q.length?Ue(Q[0]):null,ie,_e,U,Y=null,pe=null,ke=b.deleted;switch(C){case"both-reordered":{ie=_e="reordered";let me=new Set(b.rKept),ee=b.lKept.filter(Ie=>me.has(Ie)&&j(R(Ie)).length),te=Ie=>y.get(j(R(Ie))[0]);Y=ee.map(Ie=>Me(R(Ie))),pe=ee.slice().sort((Ie,je)=>te(Ie)-te(je)).map(Ie=>Me(R(Ie)));let W=Ie=>!kn(Ie)&&Ie.kind!=="comment"&&Ie.nodes.every(je=>!/[^\t\n\f\r ]/.test(je.data)),ne=ee.filter(Ie=>!W(Ie)),we=ne.slice().sort((Ie,je)=>te(Ie)-te(je));U=ne.some((Ie,je)=>Ie!==we[je]);break}case"both-moved":ie=_e="moved",U=!B||!Q.some(me=>{let ee=me===Q[0]?ye:Ue(me);return ee&&ee.parent===B.parent});break;case"edit-beats-delete":ie=ke==="local"?"deleted":"edited",_e=ke==="remote"?"deleted":"edited",U=ke==="local";break;case"move-beats-delete":ie=ke==="local"?"deleted":"moved",_e=ke==="remote"?"deleted":"moved",U=ke==="local";break;case"remote-wins":ie="edited",_e="edited",U=!0;break;default:ie=_e="inserted",U=b.localLost}return{key:`structure:${$.key}:${C}`,subject:$,localLost:U,anchor:Q[0]||null,structure:{localAction:ie,remoteAction:_e,localPlacement:B,remotePlacement:he,mergedPlacement:ye,localOrder:Y,mergedOrder:pe,localFragment:C==="both-reordered"||!L.l?null:Ne(L.l),fragmentKind:O(L.b||L.l||L.r)}}};for(let[K,b]of i){if(K.kind!=="structure")continue;let C=b.unit||R(b.subject),L=C.b||C.l||C.r;!kn(L)&&L.kind==="comment"&&vt.set(L,`structure:${Me(C).key}:${K.detail}`)}let gn=new Map;for(let[K,b]of i){if(K.kind==="structure"){let Q=Me(b.unit||R(b.subject)),B=`structure:${Q.key}:${K.detail}`,he=gn.get(B);if(he&&he.structure){K.recovery=he;let ye=w.refs.get(Q);K.el==null&&ye.length&&(K.el=kn(ye[0])?ye[0]:u.out.logicalParent(ye[0]));continue}}let C=K.kind==="text"?Bt(K,b):K.kind==="attr"?Qt(K,b):Yt(K,b),L=gn.get(C.key);L||(L={version:Ed,key:C.key,localLost:C.localLost,subject:C.subject,applied:!1,unavailable:null},gn.set(C.key,L),w.anchors.set(L,C.anchor)),C.text&&(L.text=C.text),C.attribute&&(L.attribute=C.attribute),C.structure&&(L.structure=C.structure),C.text&&(L.localLost=C.localLost),K.recovery=L;let $=w.refs.get(C.subject);K.kind==="structure"&&K.el==null&&$.length&&(K.el=kn($[0])?$[0]:u.out.logicalParent($[0])),K.kind==="text"&&K.node==null&&$.length&&C.subject.nodeType===8&&(K.node=$[0])}return w}}function Ca(e,t,n){if(!t)return;let{lookup:r,vetoed:o,vetoedAttrs:s,liveAttr:i}=n,l=n.ignored||(()=>!1),a=Sr(n.liveRoot),c=S=>!!S&&a.containerPath(S)!==null,h=S=>{let T=S.parentNode;return T&&T.nodeType===11?t.outOwners.get(T)||null:T},u=S=>{for(let T=S;T;T=h(T))if(t.via.has(T)&&(T=t.via.get(T)),o.has(T)||n.vetoedLive?.has(d(T)))return!0;return!1},f=S=>Array.from(Fn(S).children).filter(T=>!l(T)),p=(S,T)=>f(S)[f(T.parentNode).indexOf(T)],m=(S,T)=>{let J=null,q=null,V=0;for(let ce=T.previousSibling;ce;ce=ce.previousSibling){if(ce.nodeType===1&&!l(ce)){J=ce;break}ce.nodeType===3&&(V+=ce.nodeValue.length)}for(let ce=T.nextSibling;ce&&!q;ce=ce.nextSibling)ce.nodeType===1&&!l(ce)&&(q=ce);let Ce=J?p(S,J):null,Me=q?p(S,q):null;if(J&&!Ce||q&&!Me)return null;let Be=[];for(let ce=Ce?Ce.nextSibling:Fn(S).firstChild;ce&&ce!==Me;ce=ce.nextSibling)ce.nodeType===3&&Be.push(ce);return Be.length?{nodes:Be,lead:V}:null},y=S=>{let T=[],J=S;for(;J&&!t.via.has(J);J=J.parentNode)T.push(J);if(!J||!T.length)return null;let q=d(t.via.get(J));for(let Me=T.length-1;Me>0&&q;Me--)q=p(q,T[Me]);if(!q)return null;let V=T[0];if(V.nodeType===3)return m(q,V);let Ce=V.nodeType===1?p(q,V):null;return Ce?{nodes:[Ce],lead:0}:null},g=S=>{let T=r(S),J=T?{nodes:Array.isArray(T)?T:[T],lead:0}:t.via.size?y(S):null;if(!J)return null;let q=J.nodes.filter(c);return q.length?{nodes:q,lead:J.lead}:null},d=S=>{let T=g(S);return T?T.nodes[0]:null},k=S=>{if(!S)return null;if(S.kind==="text"){let V=g(S.node);if(!V)return null;let Ce=V.nodes,Me=S.offset+V.lead,Be=0;for(let ce=0;ce<Ce.length;ce++){let Ae=Ce[ce].nodeValue.length;if(Me<=Be+Ae||ce===Ce.length-1)return Me>=Be&&Me<=Be+Ae?[Ce[ce],Me-Be]:null;Be+=Ae}return null}let T=d(S.node);if(!T)return null;if(S.kind==="end")return[Fn(T),Fn(T).childNodes.length];if(S.kind==="startOf")return[Fn(T),0];if(S.kind==="wholeStart")return T.firstChild?[T.firstChild,0]:[T,0];if(S.kind==="wholeEnd")return T.lastChild?[T.lastChild,T.lastChild.nodeValue.length]:[T,T.childNodes.length];let J=T.parentNode;if(!J)return null;let q=Array.prototype.indexOf.call(J.childNodes,T);return[J,S.kind==="after"?q+1:q]},A=S=>({blocks:new Set((S.flat?.marks||[]).filter(T=>T.block).map(T=>d(T.el)).filter(Boolean)),atoms:new Set((S.flat?.atoms||[]).map(T=>d(T.el)).filter(Boolean)),ignored:l}),w=(S,T,J,q)=>{if(!S||!T||!Ar(S)||!Ar(T))return!1;for(let Me of[S,T])if(!c(Me.startContainer)||!c(Me.endContainer))return!1;let V=J.merged;if(V.start===V.end&&(S.startContainer!==S.endContainer||S.startOffset!==S.endOffset))return!1;let Ce=A(q);return fr(T,J.encoding,Ce)===V.text&&fr(S,J.encoding,Ce)===V.text.slice(V.start,V.end)},v=new Map,E=S=>{let T=S.parentNode;return T?(v.has(T)||v.set(T,new Map(Array.from(T.childNodes,(J,q)=>[J,q]))),v.get(T).get(S)):-1},N=(S,T)=>{if(!T)return!1;let J=a.logicalParent(S);if(!T.parent.live.includes(J))return!1;let q=E(S);for(let[V,Ce]of[["before",1],["after",-1]]){let Me=q;for(let Be of T[V]){if(Be.live.includes(S))continue;let ce=Be.live.filter(Ue=>Ue!==S&&Ue.parentNode===S.parentNode);if(!ce.length)continue;let Ae=Ce===1?Math.min(...ce.map(E)):Math.max(...ce.map(E));if(Ce*(Ae-Me)<=0)return!1;Me=Ae}}return!0},_=S=>{let T=S.structure;if(T.mergedOrder){let J=new Set(S.subject.live.map(Fn)),q=null,V=-1;for(let Ce of T.mergedOrder){let Me=Ce.live.find(Be=>J.has(Be.parentNode));if(!Me||q&&Me.parentNode!==q||E(Me)<=V)return!1;q=Me.parentNode,V=E(Me)}return S.subject.live.length>0}return S.subject.live.some(J=>N(J,T.mergedPlacement))},M=(S,T)=>{let J=k(S),q=k(T);return J&&q?{startContainer:J[0],startOffset:J[1],endContainer:q[0],endOffset:q[1]}:null},j=new Set,R=S=>{if(!S||j.has(S))return;j.add(S);let T=[];for(let J of t.refs.get(S)||[]){let q=g(J);if(q)for(let V of q.nodes)T.includes(V)||T.push(V)}S.live=T},D=S=>{S&&(R(S.parent),S.before.forEach(R),S.after.forEach(R))},F=new Set;for(let S of e){let T=S.recovery;if(!T||F.has(T))continue;F.add(T),R(T.subject),T.structure&&(D(T.structure.localPlacement),D(T.structure.remotePlacement),D(T.structure.mergedPlacement),(T.structure.localOrder||[]).forEach(R),(T.structure.mergedOrder||[]).forEach(R));let J=t.anchors.get(T),q=J?d(J):null,V=!!q;if(T.text){let O=t.spans.get(T.text.merged),X=O?M(O.start,O.end):null,le=O?M(O.scopeStart,O.scopeEnd):null;if(O?.empty){let re=O.empty,Pe=re.previous?{kind:"after",node:re.previous}:{kind:"startOf",node:re.parent},Fe=re.next?{kind:"before",node:re.next}:{kind:"end",node:re.parent},Te=M(Pe,Fe);!Te||Te.startContainer!==Te.endContainer||Te.startOffset!==Te.endOffset?X=null:X=le=Te}w(X,le,T.text,O)||(X=le=null),T.text.liveSpan=X,T.text.liveScope=X?le:null,X||(V=!1)}T.structure&&V&&(V=_(T)),T.attribute&&V&&(V=i(q,T.attribute,S.resolved));let Ce=(!!T.attribute||!!T.text&&q?.tagName==="TEXTAREA")&&!!s&&[J,q].some(O=>s.get(O)?.has(T.attribute?T.attribute.qualifiedName:"value")),Me=t.localState?.states.get(T),Be=!!T.text&&[...n.removedVetoes||[]].some(O=>Me?.touched.has(O)),ce=T.structure?.localAction==="inserted"&&[...o].some(O=>O===J||J?.contains(O)),Ae=J&&u(J)||Ce||Be||ce,Ue=Ae&&_a(T,S,t,c);Ue&&(Be||ce&&T.localLost)&&(V=!1);let Ne=!V&&Ue&&Ae;T.applied=V,T.unavailable=V?null:Ne?"hook-veto":"missing-output",Ne&&(T.localLost=!1),!V&&T.text&&(T.text.liveSpan=T.text.liveScope=null)}}function fs(e,t,n){let r=Sr(t),o=Sr(n),s=u=>!!u&&o.containerPath(u)!==null,i=u=>{if(u===t)return n;let f=r.pathOf(u);if(f&&t!==n){let p=wr(n,{path:f,offset:0});if(p&&p[0].nodeType===u.nodeType)return p[0]}return u},l=new Set,a=u=>{!u||l.has(u)||(l.add(u),u.live=u.live.map(i).filter(s))},c=u=>{u&&(u.startContainer=i(u.startContainer),u.endContainer=i(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 m=f.text.liveSpan,y=f.text.liveScope,g=f.text.merged,d=k=>!!k&&Ar(k)&&s(k.startContainer)&&s(k.endContainer);(!d(m)||!d(y)||fr(y,f.text.encoding)!==g.text||fr(m,f.text.encoding)!==g.text.slice(g.start,g.end))&&(f.text.liveSpan=null,f.text.liveScope=null,f.applied=!1,f.unavailable="missing-output")}let p=f.structure;if(p){for(let m of[p.localPlacement,p.remotePlacement,p.mergedPlacement])m&&(a(m.parent),m.before.forEach(a),m.after.forEach(a));(p.localOrder||[]).forEach(a),(p.mergedOrder||[]).forEach(a),f.subject.live.length||(f.applied=!1,f.unavailable="missing-output")}}}var $r=e=>e?.nodeType===1,Ao=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function Od({provenance:e,parentOf:t,twins:n,baseOf:r,build:o,ignored:s,remoteWins:i,discarded:l}){let a=new Map,c=new WeakMap;function h(p,m,y,g=!1){if(!$r(p)||!$r(y))return null;let d=a.get(p);if(d)(g||!d.selected&&m==="remote")&&(d.parent=t(y),d.port=y,d.sourceSide=m,d.selected=g);else{let k=c.get(p)||null;d={owner:p,parent:t(y),port:y,sourceSide:m,originalParent:t(p),originalPort:p,selected:g,state:k?"built":"planned",output:k,disposition:null},a.set(p,d)}return d}function u(p,m){if(!$r(p)||!$r(m))return;c.has(p)||c.set(p,m);let y=a.get(p);y&&y.state!=="attached"&&!y.output&&(y.output=m,y.state="built")}function f(p){if(!a.size)return;let m=new Map,y=new WeakMap,g=new WeakMap,d=new WeakSet,k=new Set,A=(D,F)=>{if(!D)return;if(Array.isArray(D)){for(let T of D)A(T,F);return}let S=m.get(D);S||m.set(D,S=[]),S.push(F)},w=(D,F)=>{if(!D)return;let S=[D];for(;S.length;){let T=S.pop();A(T,F);for(let J of Ao(T).childNodes)S.push(J)}};function v(D,F=null,S=!1){if(d.has(D))return;d.add(D),y.set(D,F);let T=e.get(D),J=S||!!(T&&i(T.remote||T.base));g.set(D,J);let q={node:D,kind:"node",authority:J};if(T?.pinned)w(T.local,{...q,kind:"ignored"});else if(T?.unchanged)for(let V of[T.base,T.local,T.remote])w(V,{...q,kind:"unchanged"});else if(T){for(let V of[T.base,T.local,T.remote])A(V,q);if($r(T.local))for(let V of Ao(T.local).children)s(V)&&w(V,{...q,kind:"ignored"})}for(let V of Ao(D).childNodes)v(V,D,J)}let E=D=>{if(D.output&&d.has(D.output))return D.state="attached",D.disposition="node",!0;let{local:F,remote:S}=n(D.owner);for(let T of[D.owner,F,S]){let J=m.get(T);if(J?.length){let q=J.find(V=>V.kind==="node")||J[0];return D.output=q.node,D.state="attached",D.disposition=q.kind,!0}}return!1},N=(D,F)=>(m.get(D)||[]).find(T=>T.kind==="node"&&$r(T.node)&&(!T.authority||F.sourceSide==="remote"))?.node,_=(D,F,S)=>{let T=m.get(D)||[],J=S?[...T].reverse():T;for(let q of J){if(q.kind!=="node")continue;let V=q.node;for(;V&&y.get(V)!==F;)V=y.get(V);if(V)return V}return null},M=(D,F,S)=>{let T=Ao(F);for(let J=S?.previousSibling;J;J=J.previousSibling){let q=_(J,F,!0);if(q){T.insertBefore(D,q.nextSibling);return}}for(let J=S?.nextSibling;J;J=J.nextSibling){let q=_(J,F,!1);if(q){T.insertBefore(D,q);return}}T.appendChild(D)};function j(D,F,S){let T=F==="base"?D:r(D,F),J=a.get(T);J&&J!==S&&R(J)}function R(D){if(D.state==="attached"||D.disposition==="remote-wins"||k.has(D)||E(D))return;k.add(D);let{local:F,remote:S}=n(D.owner);if(i(S||D.owner)){if(!S){D.disposition="remote-wins",l(D.owner,F),k.delete(D);return}D.parent=t(S),D.port=S,D.sourceSide="remote"}if(j(D.parent,D.sourceSide,D),E(D)){k.delete(D);return}let T=N(D.parent,D),J=D.port;if(!T){if(j(D.originalParent,"base",D),E(D)){k.delete(D);return}let V=D.originalParent;for(J=D.originalPort;V&&!T;)T=N(V,D),T||(J=V,V=t(V))}if(!T)throw new Error("A planned move has no allowed surviving parent");let q=D.output||o(D.owner);D.output=q,D.state="built",M(q,T,J),v(q,T,g.get(T)||!1),E(D),k.delete(D)}v(p);for(let D of a.values())R(D)}return{planned:a,has:p=>a.has(p),plan:h,produced:u,drain:f}}function Hr(e,t,n,r,o,s,i,l,a,c,h,u,f){let p=null;return Od({provenance:e,parentOf:g=>{if(!g)return null;let d=t(g);if(d||g.parentNode?.nodeType!==11)return d;if(!p){p=new WeakMap;let k=[u,f];for(;k.length;){let A=k.pop(),w=Ao(A);w!==A&&p.set(w,A);for(let v of w.children)k.push(v)}}return p.get(g.parentNode)||null},twins:g=>({local:o(n,g),remote:o(r,g)}),baseOf:(g,d)=>g&&(d==="local"?n:r).reverse.get(g)||null,build:g=>s(g,o(n,g),o(r,g),!1),ignored:i,remoteWins:l,discarded:(g,d)=>{d&&h(g,d,n)&&!a.some(k=>k.detail==="remote-wins"&&k.base===g)&&c({kind:"structure",el:null,detail:"remote-wins",base:g,local:d,remote:null},{subject:g})}})}function _d({parent:e,base:t,views:n,eligible:r,ignored:o,remoteWins:s,budget:i=Zt(2e4*32),maxUnits:l=256,maxCharacters:a=2e4}){let c=(d,k=null)=>({status:d,reason:k,parent:e,records:[]});if(n.some(({V:d})=>d.asBase)||o(e)||s(e)||n.some(({V:d})=>!d.el||o(d.el)||s(d.el)))return c("none");let h=t.length+n[0].V.units.length+n[1].V.units.length;if(h>l)return c("fallback","unit-limit");let u=Symbol(),f=d=>{if(d>i.remaining)throw u;i.remaining-=d,i.crossParentSteps=(i.crossParentSteps||0)+d},p=new Map,m=0,y=d=>{if(f(1),p.has(d))return p.get(d);let k=d.nodeType===1?d.childNodes:d.nodes;f(k.length*4+1);let A=d.nodeType===1?Array.from(k):k,w=0;for(let N=0;N<A.length;N++){let _=A[N];if(_.nodeType!==3||N&&A[N-1].nextSibling!==_)return p.set(d,null),null;w+=_.data.length}if(w>a-m)throw u;f(w*8+1),m+=w;let v=an(A);if(v.text.includes(Ot))return p.set(d,null),null;let E={unit:d,nodes:A,flat:v};return p.set(d,E),E},g=[];try{f(h*8+1);for(let d=0;d<2;d++){let k=n[d].V,A=n[1-d].V,w=[],v=new Map;for(let E=0;E<t.length;E++){f(1);let N=t[E];if(N.kind!=="text"||k.twin(N))continue;let _=A.twin(N);if(!_||_.kind!=="text"||!A.here(_))continue;let M=y(N),j=y(_);if(!M||!j||!/\S/.test(M.flat.text))continue;f(M.flat.text.length*2+1);let R=M.flat.text;v.set(R,(v.get(R)||0)+1),w.push({source:N,opposite:_,sourceModel:M,oppositeModel:j,index:E})}for(let E of w){let{source:N,opposite:_,sourceModel:M,oppositeModel:j,index:R}=E,D=[];for(let X of[-1,1]){f(1);let le=t[R+X];if(!le||le.nodeType!==1||!r(le)||o(le)||s(le))continue;let re=M.nodes[0],Pe=M.nodes.at(-1);if(X===-1?re?.previousSibling!==le:Pe?.nextSibling!==le)continue;let Fe=k.twin(le),Te=A.twin(le);if(!Fe||!Te||!k.here(Fe)||A.here(Te)||k.baseOf(Fe)!==le||A.baseOf(Te)!==le||!r(Fe)||!r(Te)||o(Fe)||o(Te)||s(Fe)||s(Te)||Fe.tagName!==le.tagName||Te.tagName!==le.tagName||Fe.namespaceURI!==le.namespaceURI||Te.namespaceURI!==le.namespaceURI)continue;let ot=y(le),et=y(Fe),ae=y(Te);if(!ot||!et||!ae||!/\S/.test(ot.flat.text))continue;let de=ot.flat.text,Ee=M.flat.text,Ge=et.flat.text;if(f((de.length+Ee.length+Ge.length)*3+1),Ge.length!==de.length+Ee.length)continue;let Ve=X===-1;(Ve?!Ge.startsWith(de)||!Ge.endsWith(Ee):!Ge.startsWith(Ee)||!Ge.endsWith(de))||D.push({owner:le,target:Fe,moved:Te,ownerBase:ot,joined:et,ownerOther:ae,targetFrom:Ve?de.length:0,retainedFrom:Ve?0:Ee.length})}if(!D.length)continue;if(D.length!==1||v.get(M.flat.text)!==1)return c("fallback","ambiguous-origin");let F=D[0],{owner:S,target:T,moved:J,ownerBase:q,joined:V,ownerOther:Ce,targetFrom:Me,retainedFrom:Be}=F;if(f(g.length+1),g.some(X=>X.owner===S))return c("fallback","ambiguous-owner");let ce={source:N,target:T,from:0,to:M.flat.text.length,targetFrom:Me},Ae=Gn({base:M.flat,side:V.flat,retained:[],transfers:[{from:ce.from,to:ce.to,target:Me,destination:S}],budget:i});if(Ae.status!=="ready"||Ae.covers(ce.from,ce.to)!==!0)return c("fallback",Ae.reason||"work-limit");let Ue=[{unit:N,model:M,from:0,to:M.flat.text.length},null,null];Ue[d+1]={unit:T,model:V,from:Me,to:Me+M.flat.text.length},Ue[2-d]={unit:_,model:j,from:0,to:j.flat.text.length};let Ne=[q,null,null];Ne[d+1]=V,Ne[2-d]=Ce;let O=[S,null,null];O[d+1]=T,O[2-d]=J,g.push({side:d,parent:e,source:N,target:T,owner:S,owners:O,ownerModels:Ne,native:Ue,models:p,runs:[ce],proof:Ae,retained:[{source:S,target:T,from:0,to:q.flat.text.length,targetFrom:Be}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:c("none")}catch(d){if(d!==u)throw d;return c("fallback","work-limit")}}function Ma({describe:e,parentOf:t,...n}){let r=new WeakMap,o=new WeakMap,s=n.budget||Zt(2e4*32),i=l=>{if(!l)return null;if(r.has(l))return r.get(l);r.set(l,{status:"planning",parent:l,records:[]});let a=e(l),c=a?_d({...n,...a,parent:l,budget:s}):{status:"none",reason:null,parent:l,records:[]};if(r.set(l,c),c.status==="ready")for(let h of c.records)o.set(h.owner,[h]);return c};return{get:i,forOwner(l){return i(t(l))?.status==="ready"&&o.get(l)||null}}}function Nd(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=(A,w)=>o?[...A.nodes,...w.nodes]:[...w.nodes,...A.nodes],i=e.ownerModels.reduce((A,w)=>A+w.flat.text.length,0)+n.flat.text.length+e.native[2].model.flat.text.length;if(i*8>t.remaining)return null;t.remaining-=i*8;let l={base:s(r,n),local:e.ownerModels[1].nodes,remote:s(e.ownerModels[2],e.native[2].model)},a=an(l.base),c=e.ownerModels[1].flat,h=an(l.remote),u=o?r.flat.text.length:0,f=o?0:n.flat.text.length,p=Gn({base:a,side:c,retained:e.retained.map(A=>({from:f+A.from,to:f+A.to,target:A.targetFrom})),transfers:e.runs.map(A=>({from:u+A.from,to:u+A.to,target:A.targetFrom,destination:e.owner})),budget:t});if(p.status!=="ready"||p.covers(0,a.text.length)!==!0)return null;let m=e.ownerModels[2].flat,y=e.native[2].model.flat,g=[];for(let[A,w,v,E]of[[r.flat,m,f,o?0:y.text.length],[n.flat,y,u,o?m.text.length:0]]){let N=Ai(A,A,w).remoteMap.bTo,_=-1;for(let M=0;M<A.text.length;M++){if(N[M]<0){_=-1;continue}let j=g.at(-1);_>=0&&j.to===v+M&&j.target+j.to-j.from===E+N[M]?j.to++:(g.push({from:v+M,to:v+M+1,target:E+N[M]}),_=M)}}let d=Gn({base:a,side:h,retained:g,transfers:[],budget:t});if(d.status!=="ready")return null;let k=Ai(a,c,h,{},{local:p,remote:d});return k.localEdits.hunks.length?null:(k.localMap=p,k.remoteMap=d,{nodes:l,prepared:k})}function Ra({L:e,R:t,twinIn:n,unitsOf:r,view:o,parentOf:s,ignored:i,remoteWins:l,eligible:a,build:c,out:h,policy:u,provenance:f,textMappers:p,segments:m,conflicts:y,conflict:g,decisions:d}){let k=Zt(2e4*32),A=D=>{let F=0;for(let S=D;S;S=s(S))if(++F>64||S.nodeType===1&&(i(S)||l(S)))return!1;return!0},w=Ma({parentOf:s,eligible:a,ignored:i,remoteWins:l,budget:k,describe(D){let F=n(e,D),S=n(t,D);return!F||!S||!A(D)||!A(F)||!A(S)?null:{base:r(D),views:[{A:e,V:o(e,F,D,!1)},{A:t,V:o(t,S,D,!1)}]}}}),v=new WeakSet,E=new WeakMap,N=new WeakSet,_=[];function M(D){if(!D||v.has(D))return;v.add(D);let F=w.get(D);if(F?.status==="ready")for(let S of F.records){if((D.tagName==="TEMPLATE"&&D.content?D.content:D).childNodes.length!==S.native[0].model.nodes.length+1||!S.owners.every(A))continue;let J=Nd(S,k);if(!J)continue;let q={record:S,payload:J,state:"planned",output:null,result:null};E.set(S.owner,q),N.add(S.source),N.add(S.native[2].unit),_.push(q)}}function j(D,F){let S=E.get(D);if(!S)return!1;if(!S.result){if(S.result=os({...S.payload.nodes,prepared:S.payload.prepared,out:h,policy:u,provenance:f,textMappers:p,conflicts:y,conflict:g,decisions:d,node:F}),S.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");m.push(...S.result.segments),S.decision={kind:"text",node:F,source:"local"},d.push(S.decision)}return S.decision.node=F,F.replaceChildren(...S.result.nodes),S.output=F,S.state="built",!0}function R(D){if(!_.length)return;let F=new WeakSet,S=new WeakMap,T=new WeakMap,J=new WeakMap,q=Ae=>Ae.tagName==="TEMPLATE"&&Ae.content?Ae.content:Ae,V=(Ae,Ue)=>{if(!Ae)return;if(Array.isArray(Ae)){for(let O of Ae)V(O,Ue);return}let Ne=J.get(Ae);Ne||J.set(Ae,Ne=[]),Ne.push(Ue)},Ce=(Ae,Ue=null,Ne=!1)=>{F.add(Ae),S.set(Ae,Ue);let O=f.get(Ae),X=Ne||!!(O&&l(O.remote||O.base));if(T.set(Ae,X),O)for(let le of[O.base,O.local,O.remote])V(le,Ae);if(!(O?.pinned||O?.unchanged))for(let le of q(Ae).childNodes)Ce(le,Ae,X)},Me=Ae=>(J.get(Ae)||[]).find(Ue=>Ue.nodeType===1&&!T.get(Ue)&&!f.get(Ue)?.pinned&&!f.get(Ue)?.unchanged),Be=(Ae,Ue)=>{for(let Ne of J.get(Ae)||[]){let O=Ne;for(;O&&S.get(O)!==Ue;)O=S.get(O);if(O)return O}return null},ce=(Ae,Ue,Ne)=>{let O=q(Ue);for(let X=Ne.nextSibling;X;X=X.nextSibling){let le=Be(X,Ue);if(le){O.insertBefore(Ae,le);return}}for(let X=Ne.previousSibling;X;X=X.previousSibling){let le=Be(X,Ue);if(le){O.insertBefore(Ae,le.nextSibling);return}}O.appendChild(Ae)};Ce(D);for(let Ae of _){let{record:Ue}=Ae,Ne=Me(Ue.owner)||Me(Ue.owners[1])||Me(Ue.owners[2]);if(Ne)(!Ae.result||Ae.output!==Ne||Ae.result.nodes.some(O=>!F.has(O)||S.get(O)!==Ne)||Ne.textContent!==Ae.result.text)&&(j(Ue.owner,Ne),Ce(Ne,S.get(Ne),T.get(Ne)));else{let O=Ue.parent,X=Ue.owner,le=null;for(;O&&!le;)le=Me(O),le||(X=O,O=s(O));if(!le)throw new Error("A cross-parent payload has no allowed surviving parent");Ne=Ae.output||c(Ue.owner,Ue.owners[1],Ue.owners[2],!1),Ae.result||j(Ue.owner,Ne),ce(Ne,le,X),Ce(Ne,le,T.get(le))}Ae.state="attached"}}return{ensureParent:M,ensureOwner(D){M(s(D))},consumes(D){return N.has(D)},render:j,drain:R}}var jn=/\S/,Ia=/[\p{L}\p{N}]/u;function Tr(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 Ri(e,t,n){for(let r=e.parentNode;r;r=r.parentNode)if(n(t,1),r.nodeType===11)return!1;return!0}function La(e,t,n,r,o){let s=n(e,r),i=n(t,r),l=null,a=null,c=null,h=null;o(r,s.length+i.length);for(let u of s)Ia.test(u.raw)&&(l||=u,a=u);for(let u of i)Ia.test(u.raw)&&(c||=u,h=u);return!!(l&&c&&(l.raw===c.raw||a.raw===h.raw))}function Cd({base:e,V:t,A:n,source:r,original:o,current:s,edited:i,destination:l,at:a,ownLength:c,eligible:h,model:u,tokensOf:f,budget:p,charge:m}){let y=o.flat.text,g=s.flat.text,d=i.flat.text,k=l.flat.text;if(m(p,y.length+g.length+k.length),y.startsWith(g)||y.endsWith(g))return!1;let A=jn.test(k.slice(0,a)),w=jn.test(k.slice(a+c));if(A===w)return!1;let v=A?0:a+c,E=A?a:k.length;for(;v<E&&!jn.test(k[v]);)v++;for(;E>v&&!jn.test(k[E-1]);)E--;let N=k.slice(v,E);if(Bn(N,k,f(l,p),p,m,!0)!==v)return!1;let _=Bn(N,y,f(o,p),p,m,!0);if(_<0)return!1;let M=_+N.length,j=!jn.test(y.slice(0,_)),R=!jn.test(y.slice(M));if(j===R||Bn(N,g,f(s,p),p,m,!1)>=0)return!1;let D=j?y.slice(M):y.slice(0,_),F=j?d.length-D.length:0;if(m(p,y.length+d.length),F<0||!jn.test(D)||Bn(D,d,f(i,p),p,m,!0)!==F||!jn.test(j?d.slice(0,F):d.slice(D.length)))return!1;for(let S of e){if(m(p,1),S===r||!Tr(S,h,p,m))continue;let T=u(S,null,p);if(Bn(N,T.flat.text,f(T,p),p,m,!1)>=0)return!1}for(let S of t.units){if(m(p,1),S===s.unit||S===l.unit||!Tr(S,h,p,m))continue;let T=u(S,n,p);if(Bn(N,T.flat.text,f(T,p),p,m,!1)>=0)return!1}return!0}function Pa({base:e,views:t,side:n,attempt:r,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,charge:c,exhausted:h,limit:u}){if(u<=0)return null;let f=Zt(u),{V:p,A:m,idOf:y}=t[n],g=t[1-n],[d,k,A,w]=r,v=null;try{for(let E=d;E<=k;E++){c(f,1);let N=e[E];if(N.parentNode?.nodeType!==1||s.has(N)||m.identical.has(N)||g.A.identical.has(N)||!Tr(N,o,f,c)||i(N))continue;let _=p.twin(N),M=g.V.twin(N);if(!_||!M||!p.here(_)||!g.V.here(M)||m.map.get(N)!==_||m.reverse.get(_)!==N||g.A.map.get(N)!==M||g.A.reverse.get(M)!==N||y(_)||g.idOf(M)||_.tagName!==N.tagName||M.tagName!==N.tagName||!Tr(_,o,f,c)||!Tr(M,o,f,c)||!Ri(N,f,c)||!Ri(_,f,c)||!Ri(M,f,c))continue;let j=l(N,null,f),R=l(_,m,f),D=l(M,g.A,f),F=j.flat.text,S=R.flat.text,T=D.flat.text;if(c(f,F.length+S.length+T.length),!jn.test(F)||!jn.test(S)||!jn.test(T)||F===S||F===T||S===T||!La(j,R,a,f,c)||!La(j,D,a,f,c))continue;let J=null,q=!1;for(let Me=A;Me<=w;Me++){c(f,1);let Be=p.units[Me],ce=p.baseOf(Be);if(!ce||ce===N||s.has(ce)||ce.parentNode!==N.parentNode||Be.parentNode!==_.parentNode||ce.tagName!==N.tagName||Be.tagName!==N.tagName||m.map.get(ce)!==Be||m.reverse.get(Be)!==ce||i(ce)!==y(Be)||!Tr(ce,o,f,c)||!Tr(Be,o,f,c))continue;let Ae=l(ce,null,f),Ue=l(Be,m,f),Ne=Ae.flat.text,O=Ue.flat.text;if(c(f,Ne.length),!jn.test(Ne)||O.length<=Ne.length)continue;let X=a(Ue,f),le=Bn(Ne,O,X,f,c,!0);if(!(le<0||Bn(F,O,X,f,c,!0,le,le+Ne.length)<0&&!Cd({base:e,V:p,A:m,source:N,original:j,current:R,edited:D,destination:Ue,at:le,ownLength:Ne.length,eligible:o,model:l,tokensOf:a,budget:f,charge:c}))){if(J){q=!0;break}J=Be}}if(!J||q)continue;let V=n===0?_:M,Ce=n===0?M:_;(v||=[]).push({source:N,local:V,remote:Ce,models:[j,n===0?R:D,n===0?D:R]})}}catch(E){if(E!==h)throw E}return v}var Jn=/\S/,Sn=/\s/,Md=/[\s\u001e]/g,Ii=/[^\s\p{P}\u001e\ufffc]/u;function Rd(e,t,n,r,o,s,i){let l=0;for(let a of e)i(s,1),a.nodeType===1&&!r.baseOf(a)&&l++;if(l<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;i(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]&&Jn.test(c.text[u]))return!0}return!1}function Id(e,t,n){let{source:r,models:o,retained:s,runs:i}=e,l=o.get(r).flat.text;n(t,l.length*2+s.length+i.length);let a=new Uint8Array(l.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 i)n(t,c.to-c.from),a.fill(1,c.from,c.to);for(let c=0;c<l.length;c++)if(!a[c]&&Jn.test(l[c]))return!1;return!0}function Ld(e,t,n,r,o,s,i,l,a,c){let h=s.get(e),u=s.get(t),f=h.flat.text,p=i.get(e);a(c,f.length*2+n.length);let m=f.length,y=0;for(let k=0;k<f.length;k++)!Sn.test(f[k])&&!p[k]&&(m=Math.min(m,k),y=k+1);if(m>=y)return null;for(let k=m;k<y;k++)if(!Sn.test(f[k])&&p[k])return null;let g=-1;for(let k of n)if(k.target===t&&k.from<=m&&k.to>m){g=k.targetFrom+m-k.from;break}if(g<0)return null;let d=f.slice(m,y);if(a(c,d.length*(n.length+2)),u.flat.text.slice(g,g+d.length)!==d)return null;for(let k=m;k<y;k++){if(Sn.test(f[k]))continue;let A=!1;for(let w of n)if(w.target===t&&w.from<=k&&w.to>k&&w.targetFrom+k-w.from===g+k-m){A=!0;break}if(!A)return null}if(h.flat.atoms.length||u.flat.atoms.length){a(c,h.flat.atoms.length+u.flat.atoms.length);let k=0,A=u.flat.atoms;for(;k<A.length&&A[k].i<g;)k++;for(let w of h.flat.atoms){if(w.i<m||w.i>=y)continue;let v=A[k++];if(!v||v.i!==g+w.i-m||u.alignment?.reverse.get(v.el)!==w.el)return null}if(k<A.length&&A[k].i<g+y-m)return null}for(let[k,A,w]of[[r,e,m],[o,t,g]]){let v=!1;for(let E of k){let N=s.get(E),_=i.get(E),M=l(N,c);for(let j=0;j<M.length;j++){let R=M[j].from,D=R+d.length;if(a(c,d.length*2+1),N.flat.text.slice(R,D)!==d)continue;let F=j;for(;F<M.length&&M[F].to<D;)a(c,1),F++;if(F===M.length||M[F].to!==D)continue;let S=!0;for(let T=R;T<D;T++)if(!Sn.test(N.flat.text[T])&&_[T]){S=!1;break}if(S){if(v||E!==A||R!==w)return null;v=!0}}}if(!v)return null}return d}function Pd(e,t,n,r,o,s,i,l){if(i(l,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 ja({base:e,views:t,eligible:n,baseId:r,ignored:o,remoteWins:s,atomKey:i,limit:l=2e4*8}){if(l<=0)return null;let a=Symbol(),c=(w,v)=>{if(v>w.remaining)throw a;w.remaining-=v},h=[new Map,new Map];for(let w=0;w<2;w++)for(let v=0;v<t[w].V.units.length;v++)h[w].set(t[w].V.units[v],v);let u=new Int32Array(e.length),f=new Int32Array(e.length),p=w=>t.every(({V:v},E)=>{let N=v.twin(w);return N&&h[E].has(N)}),m=-1;for(let w=0;w<e.length;w++)u[w]=m,p(e[w])&&(m=w);m=e.length;for(let w=e.length-1;w>=0;w--)f[w]=m,p(e[w])&&(m=w);let y=new Map,g=(w,v)=>{if(c(v,1),y.has(w))return y.get(w);let E=w.firstChild,N=1;for(;E;){if(c(v,N*8+8),E.nodeType===3&&c(v,E.data.length*8),E.nodeType===1&&Cn.has(E.tagName)&&!o(E)&&!s(E)&&E.firstChild){E=E.firstChild,N++;continue}for(;E&&E!==w&&!E.nextSibling;)E=E.parentNode,N--;E=!E||E===w?null:E.nextSibling}let _=an(Array.from(w.childNodes),{ignored:o,remoteWins:s});return y.set(w,_),_},d=(w,v,E,N,_,M)=>{for(let j of w.atoms){c(M,1);let R=v.atomAt.get(j.i+E);if(!R)return!1;let D=N?.reverse.get(j.el)||i(j.el),F=_?.reverse.get(R.el)||i(R.el);if(D!==F)return!1}return!0},k=(w,v,E,N,_)=>{let M=w.text.length<=v.text.length?w:v,j=M===w?v:w;if(c(_,M.text.length+j.text.length),!M.text||!Jn.test(M.text.replaceAll(Yn,"")))return!1;let R;if(M.text===j.text)R=0;else{let D=j.text.length-M.text.length;if(c(_,(D+1)*M.text.length*2),j.text.startsWith(M.text))R=0;else if(j.text.endsWith(M.text))R=D;else return!1;if(j.text.indexOf(M.text)!==R||j.text.lastIndexOf(M.text)!==R)return!1;c(_,j.text.length*2);let F=0,S=R===0,T=!1;for(let J of pn(j.text,Nn(j.text)))F+=J.len,F===R&&(S=!0),F===R+M.text.length&&(T=!0);if(!S||!T)return!1}return M===w?d(M,j,R,E,N,_):d(M,j,R,N,E,_)},A=null;for(let w=0;w<2;w++){let{V:v,A:E,idOf:N}=t[w],_=t[1-w];if(!v.asBase)for(let M=0;M<e.length;M++){let j=e[M];if(v.twin(j)||!n(j))continue;let R=_.V.twin(j);if(!R||!h[1-w].has(R)||!n(R))continue;let D={remaining:l};try{let F=u[M],S=f[M],T=0;for(let Ce=F+1;Ce<S;Ce++)c(D,1),!v.twin(e[Ce])&&_.V.twin(e[Ce])&&n(e[Ce])&&T++;if(T!==1||g(j,D).text===g(R,D).text)continue;let J=F<0?-1:h[w].get(v.twin(e[F])),q=S===e.length?v.units.length:h[w].get(v.twin(e[S]));if(J===void 0||q===void 0||J>=q)continue;let V=null;for(let Ce=J+1;Ce<q;Ce++){c(D,1);let Me=v.units[Ce];if(v.baseOf(Me)||!n(Me)||Me.tagName!==j.tagName||Me.namespaceURI!==j.namespaceURI)continue;let Be=r(j),ce=_.idOf(R),Ae=N(Me);if(!(Be&&ce&&Be!==ce||Be&&Ae&&Be!==Ae||ce&&Ae&&ce!==Ae)&&k(g(R,D),g(Me,D),_.A,E,D)){if(V){V=null;break}V=Me}}if(!V)continue;A||(A=[new Map,new Map]),A[w].set(j,V)}catch(F){if(F!==a)throw F}}}return A?t.map(({V:w},v)=>{let E=A[v];if(!E.size)return w;let N=new Map;for(let[_,M]of E)N.set(M,_);return{...w,twin:_=>E.get(_)||w.twin(_),baseOf:_=>N.get(_)||w.baseOf(_)}}):null}function Da({onUncertainSource:e,onUncertainOwner:t,base:n,views:r,eligible:o,ignored:s,remoteWins:i,baseId:l,atomKey:a,limit:c=2e4*32}){if(c<=0)return null;let h=new Set(n),u=new Map(n.map((F,S)=>[F,S])),f=new Map,p=[],m=null,y=null,g=null,d=new Set;for(let F of n)for(let{V:S}of r){let T=S.twin(F);T&&!S.asBase&&!S.here(T)&&d.add(F)}let k=new Set,A=Symbol(),w=(F,S)=>{if(S>F.remaining)throw A;F.remaining-=S},v=(F,S,T)=>{w(T,1);let J=f.get(F);if(J)return J;if(F.nodeType===1){let Ce=F.firstChild,Me=1;for(;Ce;){if(w(T,Me*8+8),Ce.nodeType===3&&w(T,Ce.data.length*8),Ce.nodeType===1&&Cn.has(Ce.tagName)&&!s(Ce)&&!i(Ce)&&Ce.firstChild){Ce=Ce.firstChild,Me++;continue}for(;Ce&&Ce!==F&&!Ce.nextSibling;)Ce=Ce.parentNode,Me--;Ce=!Ce||Ce===F?null:Ce.nextSibling}}else w(T,F.value.length*8+F.nodes.length);let q=F.nodeType===1?Array.from(F.childNodes):F.nodes,V=q.length===1&&q[0].nodeType===3?{text:q[0].data,nodes:[{node:q[0],s:0,e:q[0].data.length}],atoms:[]}:an(q,{ignored:s,remoteWins:i});return J={unit:F,flat:V,alignment:S,tokens:null},f.set(F,J),J},E=(F,S)=>{if(F.tokens)return F.tokens;w(S,F.flat.text.length*8);let{unit:T,flat:J,alignment:q}=F,V=[],Ce=Nn(J.text),Me=0,Be=ce=>{for(let Ae of pn(J.text.slice(Me,ce),Ce))Ae.from=Me,Ae.to=Me+Ae.len,Ae.unit=T,V.push(Ae),Me+=Ae.len};for(let ce of J.atoms){Be(ce.i);let Ae=i(ce.el)&&ce.el.nodeType===1?"w"+ce.el.tagName+"#"+(ce.el.id||""):a(q?.reverse.get(ce.el)||ce.el);V.push({k:Ae,raw:Yn,len:1,from:Me,to:Me+1,unit:T,atom:!0}),Me++}return Be(J.text.length),F.tokens=V,V},N=(F,S,T,J,q)=>{if(!F.flat.atoms.length&&!S.flat.atoms.length)return!0;let V=E(F,q),Ce=E(S,q);w(q,V.length+Ce.length);let Me=0;for(let Be of Ce){if(!Be.atom||Be.from<T||Be.from>=T+J)continue;for(;Me<V.length&&!V[Me].atom;)Me++;let ce=V[Me++];if(!ce||ce.from!==Be.from-T||ce.k!==Be.k)return!1}for(;Me<V.length;)if(V[Me++].atom)return!1;return!0},_=(F,S,T)=>{let J=F.length+S.length+4;if(J*8>T.remaining)return null;T.remaining-=J*8;let q=Math.floor(T.remaining/8),V=Math.min(F.length+S.length,4e3,Math.floor((Math.sqrt(J*J+q)-J)/2)),Ce=4*(V+1)*(J+V+1);if(V<1||Ce>T.remaining)return null;T.remaining-=Ce;let Me=Zn(F,S,V),Be=[],ce=0,Ae=0;for(let Ue of Me.hunks){for(;ce<Ue.bs;)F[ce].raw===S[Ae].raw&&Be.push([F[ce],S[Ae]]),ce++,Ae++;ce=Ue.be,Ae+=Ue.toks.length}for(;ce<F.length&&Ae<S.length;)F[ce].raw===S[Ae].raw&&Be.push([F[ce],S[Ae]]),ce++,Ae++;return Be},M=(F,S,T,J,q,V,Ce)=>{if(q<=J)return;let Me=F[F.length-1];if(Me&&Me.source===S&&Me.target===T&&Me.to<=J&&Me.targetFrom-Me.from===V-J){w(Ce,(J-Me.to)*3);let Be=f.get(S).flat.text,ce=f.get(T).flat.text,Ae=!0;for(let Ue=Me.to;Ue<J;Ue++)if(!Sn.test(Be[Ue])||Be[Ue]!==ce[V+Ue-J]){Ae=!1;break}if(Ae){Me.to=q;return}}F.push({source:S,target:T,from:J,to:q,targetFrom:V})},j=F=>F.replace(Md,"");for(let F=0;F<r.length;F++){let{V:S,A:T,idOf:J}=r[F];if(S.asBase)continue;let q=new Map(S.units.map((O,X)=>[O,X])),V=O=>{let X=S.twin(O);return X&&q.has(X)?X:null},Ce=(O,X)=>{let le=new Int32Array(O.length),re=new Int32Array(O.length),Pe=-1;for(let Fe=0;Fe<O.length;Fe++)le[Fe]=Pe,X(O[Fe])&&(Pe=Fe);Pe=O.length;for(let Fe=O.length-1;Fe>=0;Fe--)re[Fe]=Pe,X(O[Fe])&&(Pe=Fe);return{prev:le,next:re}},Me=Ce(n,O=>(O.nodeType===1||O.kind==="text"&&Jn.test(O.value))&&V(O)),Be=Ce(S.units,O=>(O.nodeType===1||O.kind==="text"&&Jn.test(O.value))&&h.has(S.baseOf(O))),ce=new Map,Ae=(O,X,le,re)=>{if(O>X||le>re)return;let Pe=`${O}:${X}:${le}:${re}`;ce.set(Pe,[O,X,le,re])};for(let O=0;O<S.units.length;O++){let X=S.units[O];if(S.baseOf(X)||!o(X))continue;let le=Be.prev[O],re=Be.next[O],Pe=le<0?0:u.get(S.baseOf(S.units[le])),Fe=re===S.units.length?n.length-1:u.get(S.baseOf(S.units[re]));Ae(Pe,Fe,Math.max(0,le),Math.min(S.units.length-1,re))}for(let O=0;O<n.length;O++){let X=n[O];if(d.has(X)||!o(X))continue;if(!S.twin(X)){let ot=Me.prev[O],et=Me.next[O],ae=ot<0?0:q.get(V(n[ot])),de=et===n.length?S.units.length-1:q.get(V(n[et]));Ae(Math.max(0,ot),Math.min(n.length-1,et),ae,de)}let le=V(X);if(!le||T.identical.has(X)||!o(le))continue;let re=O+1;for(;re<n.length&&n[re].kind==="text"&&!n[re].value.trim();)re++;if(re>=n.length||!o(n[re]))continue;let Pe=V(n[re]);if(!Pe||T.identical.has(n[re])||!o(Pe))continue;let Fe=q.get(le),Te=q.get(Pe);Fe<Te&&Ae(O,re,Fe,Te)}let Ue=Array.from(ce.values()),Ne=new Set;if(Ue.length>1){let O=Zt(c);try{w(O,Ue.length*4);let X=Ue.slice().sort((Pe,Fe)=>(w(O,1),Pe[0]-Fe[0]||Pe[2]-Fe[2])),le=[],re=null;for(let Pe of X)w(O,1),re&&Pe[0]<=re[1]&&Pe[2]<=re[3]&&Pe[3]>=re[2]?(re[1]=Math.max(re[1],Pe[1]),re[2]=Math.min(re[2],Pe[2]),re[3]=Math.max(re[3],Pe[3]),re[4].push(Pe)):(re?.[4].length>1&&le.push(re),re=[Pe[0],Pe[1],Pe[2],Pe[3],[Pe]]);re?.[4].length>1&&le.push(re),Ue=le.concat(Ue)}catch(X){if(X!==A)throw X}}for(let O of Ue){if(Ne.has(O))continue;let[X,le,re,Pe,Fe]=O,Te=Zt(c),ot=[],et=new Set,ae=!1;try{w(Te,(le-X+Pe-re+2)*4);let de=n.slice(X,le+1).filter(B=>!T.identical.has(B)&&o(B)&&!d.has(B)),Ee=S.units.slice(re,Pe+1).filter(B=>o(B)&&(!S.baseOf(B)||h.has(S.baseOf(B)))&&!T.identical.has(S.baseOf(B))&&!d.has(S.baseOf(B))),Ge=new Set(Ee),Ve=!1,ze="",lt="",pt=0;for(let B of de){let he=v(B,null,Te);ze+=he.flat.text,pt+=he.flat.text.length}for(let B of Ee){let he=v(B,T,Te);lt+=he.flat.text,pt+=he.flat.text.length}w(Te,pt);let Rt=j(ze),dt=j(lt),vt=Rt===dt;if(ae=vt,Fe&&!vt)continue;let gt=vt?null:new Map;if(gt)for(let B of de.concat(Ee)){let he=f.get(B).flat.text.length;w(Te,he*16),gt.set(B,new Uint8Array(he))}let yn=B=>{let he=[];for(let ye of B){let ie=f.get(ye);ie.flat.atoms.length?he.push(...E(ie,Te)):he.push({unit:ye,raw:ie.flat.text,from:0})}return he},Bt=[];for(let B of vt?[]:de){let he=V(B);if(!Ge.has(he))continue;let ye=v(B,null,Te),ie=v(he,T,Te);w(Te,ye.flat.text.length+ie.flat.text.length);let _e=ye.flat.text&&ie.flat.text.startsWith(ye.flat.text)?0:ye.flat.text&&ie.flat.text.endsWith(ye.flat.text)?ie.flat.text.length-ye.flat.text.length:-1;if(_e>=0&&N(ye,ie,_e,ye.flat.text.length,Te)){gt.get(B).fill(1),gt.get(he).fill(1,_e,_e+ye.flat.text.length),M(Bt,B,he,0,ye.flat.text.length,_e,Te);continue}let U=_(E(ye,Te),E(ie,Te),Te);if(!U){Ve=!0;break}for(let[Y,pe]of U)gt.get(B).fill(1,Y.from,Y.to),gt.get(he).fill(1,pe.from,pe.to),M(Bt,B,he,Y.from,Y.to,pe.from,Te)}if(Ve)continue;let Qt=null,Yt=null;if(!vt)for(let B of de){let he=V(B),ye=f.get(B);if(!he||ye.flat.atoms.length||!Ge.has(he))continue;let ie=ye.flat.text,_e=gt.get(B);w(Te,ie.length*3+Ee.length);let U=-1,Y=-1,pe=!1;for(let je=0;je<ie.length;je++)Sn.test(ie[je])||(_e[je]?pe=!0:(U<0&&(U=je),Y=je+1));if(!pe||U<0)continue;let ke=!0;for(let je=U;je<Y;je++)if(_e[je]&&!Sn.test(ie[je])){ke=!1;break}if(!ke)continue;let me=j(ie.slice(U,Y)),ee=null,te=!1;for(let je of Ee){if(S.baseOf(je))continue;let Se=f.get(je);if(!Se.flat.atoms.length&&(w(Te,Se.flat.text.length),j(Se.flat.text)===me)){if(ee){te=!0;break}ee=je}}if(te){(Yt||=new Set).add(B);continue}if(!ee||Yt?.has(B))continue;let W=!1;for(let je of de){if(je===B||!Ge.has(V(je)))continue;let Se=f.get(je);if(Se.flat.atoms.length)continue;let Je=gt.get(je);w(Te,Se.flat.text.length*3);let nt="",st=!1;for(let $t=0;$t<Se.flat.text.length;$t++)Sn.test(Se.flat.text[$t])||(Je[$t]?st=!0:nt+=Se.flat.text[$t]);st&&nt===me&&(Yt||=new Set,Yt.add(B),Yt.add(je),W=!0)}if(W)continue;let ne=f.get(ee).flat.text;w(Te,Y-U+ne.length);let we=U,Ie=0;for(;we<Y&&Ie<ne.length;){for(;we<Y&&Sn.test(ie[we]);)we++;for(;Ie<ne.length&&Sn.test(ne[Ie]);)Ie++;if(we>=Y||Ie>=ne.length)break;M(Qt||=[],B,ee,we,we+1,Ie,Te),we++,Ie++}_e.fill(1,U,Y),gt.get(ee).fill(1)}let gn=B=>{let he=[];for(let ye of B){let ie=v(ye,h.has(ye)?null:T,Te),_e=gt.get(ye);for(let U of E(ie,Te)){let Y=U.from;for(;Y<U.to;){for(;Y<U.to&&_e[Y];)Y++;let pe=Y;for(;Y<U.to&&!_e[Y];)Y++;if(Y>pe){let ke=ie.flat.text.slice(pe,Y);Jn.test(ke)&&he.push({...U,raw:ke,len:Y-pe,k:U.atom?U.k:ke,from:pe,to:Y})}}}}return he},K=vt?yn(de):gn(de),b=vt?yn(Ee):gn(Ee),C=vt?Rt:K.map(B=>j(B.raw)).join(""),L=vt?dt:b.map(B=>j(B.raw)).join("");if((!C||!L)&&!Qt)continue;let $=Qt||[];if(C&&L&&C===L){let B=0,he=0,ye=0,ie=0;for(;B<K.length&&he<b.length;){let _e=K[B],U=b[he];for(;ye<_e.raw.length&&Sn.test(_e.raw[ye]);)ye++;for(;ie<U.raw.length&&Sn.test(U.raw[ie]);)ie++;if(ye===_e.raw.length){B++,ye=0;continue}if(ie===U.raw.length){he++,ie=0;continue}if((_e.atom||U.atom)&&_e.k!==U.k){Ve=!0;break}M($,_e.unit,U.unit,_e.from+ye,_e.from+ye+1,U.from+ie,Te),ye++,ie++}}else if(C&&L){let B=_(K,b,Te);if(!B)continue;for(let[he,ye]of B)M($,he.unit,ye.unit,he.from,he.to,ye.from,Te)}if(Ve)continue;let Q=new Map;for(let B of $)if(!Yt?.has(B.source)){if(V(B.source)===B.target){vt&&Bt.push(B);continue}Q.has(B.source)||Q.set(B.source,[]),Q.get(B.source).push(B)}for(let[B,he]of Q){let ye=v(B,null,Te),ie=V(B),_e=ye.flat.text,U=[],Y=new Set,pe=r[1-F],ke=pe.V.twin(B),me=ke&&pe.V.here(ke)?v(ke,pe.A,Te):null,ee=(Se,Je)=>{let nt=E(Se,Te),st=E(Je,Te);return w(Te,Se.flat.text.length+Je.flat.text.length+nt.length+st.length),Se.flat.text===Je.flat.text&&nt.length===st.length&&nt.every(($t,Ft)=>$t.k===st[Ft].k)},te=ie&&me&&me.flat.text!==_e&&ee(v(ie,T,Te),me);for(let Se of new Set(he.map(Je=>Je.target))){if(B.nodeType!==1&&Se.nodeType!==1)continue;let Je=v(Se,T,Te),nt=S.baseOf(Se);if(B.nodeType!==1&&nt||(w(Te,_e.length*2+Je.flat.text.length*3+Bt.length*2),ie&&j(_e)===j(Je.flat.text)&&v(ie,T,Te).flat.text.trim()))continue;if(!ie&&!nt&&B.nodeType===1&&Se.nodeType===1){let G=l(B),se=J(Se);if(G&&se&&G!==se)continue}let st=Je.flat.text,$t=_e&&(st.startsWith(_e)||st.endsWith(_e)),Ft=!1;if(!ie&&me&&nt&&me.flat.text!==_e){let G=v(nt,null,Te).flat.text,se=u.get(B)<u.get(nt)?me.flat.text:G,be=u.get(B)<u.get(nt)?G:me.flat.text;w(Te,se.length+be.length+st.length),Ft=!!se&&!!be&&se.length+be.length<=st.length&&st.startsWith(se)&&st.endsWith(be)&&!st.slice(se.length,st.length-be.length).trim()}let I=!ye.flat.atoms.length&&!me?.flat.atoms.length&&!Je.flat.atoms.length&&(te&&$t||Ft);if(ie&&nt){let G=v(ie,T,Te).flat.text,se=_e.startsWith(G)||_e.endsWith(G),be=v(nt,null,Te).flat.text,xe=Je.flat.text,fe=xe.startsWith(be)||xe.endsWith(be),oe=!r[1-F].V.twin(nt)&&!Bt.some(Re=>Re.source===nt&&Jn.test(be.slice(Re.from,Re.to)));if(!vt&&(!se&&!I||!fe&&!oe)){let Re=Ld(B,Se,he,de,Ee,f,gt,E,w,Te);if(!Re)continue;let De=T.weak?.has(B)&&!T.identityPaired?.has(B)&&_e.trim()===Re;if(!se&&!I&&!De)continue;let We=T.weak?.has(nt)&&!T.identityPaired?.has(nt)&&st.trim()===Re&&!f.get(nt).flat.atoms.length&&!Bt.some(Ye=>Ye.source===nt&&Jn.test(be.slice(Ye.from,Ye.to)));if(!fe&&!oe&&!We&&!Pd(nt,Se,be,st,Bt,E(Je,Te),w,Te))continue;De&&Y.add(Se)}}I&&Y.add(Se),w(Te,he.length),U.push(...he.filter(G=>G.target===Se))}if(!U.length)continue;let W=new Uint8Array(_e.length);w(Te,_e.length*4+Bt.length);for(let Se of U)W.fill(1,Se.from,Se.to);let ne=[];for(let Se=0;Se<_e.length;Se++)Sn.test(_e[Se])||ne.push(Se);if(!ne.length)continue;let we=new Set(U.map(Se=>Se.target));if(!vt&&ie&&we.size>1&&Rd(we,$,Bt,S,f,Te,w)){if(g||=new Map,g.set(B,(g.get(B)||0)|1<<F),e){let Se=vi({source:B,side:F,views:r,eligible:o,blocked:d,baseId:l,model:v,tokensOf:E,budget:Te,charge:w});if(Se){w(Te,Se.to-Se.from);let Je=!0;for(let nt=Se.from;nt<Se.to;nt++)if(Jn.test(_e[nt])&&!W[nt]){Je=!1;break}Je&&(m||=[]).push(Se)}}continue}let Ie=ne.filter(Se=>Ii.test(_e[Se]));if(!U.some(Se=>Ii.test(_e.slice(Se.from,Se.to)))&&!ne.every(Se=>W[Se]))continue;if(!ie&&!Array.from(we).some(Se=>Y.has(Se))&&!ne.every(Se=>W[Se])&&!(Ie.length&&W[Ie[0]]&&W[Ie[Ie.length-1]]&&we.size===1)){let Se=null,Je=0,nt=0,st=null,$t=null;if(!ie&&me&&B.nodeType===1&&!ye.flat.atoms.length){let Ft=E(ye,Te).filter(I=>Ii.test(I.raw));w(Te,Ee.length+_e.length);for(let I of Ee){let G=S.baseOf(I);if(!G||G===B||G.nodeType!==1||I.nodeType!==1||G.tagName!==B.tagName||I.tagName!==G.tagName)continue;let se=u.get(B),be=u.get(G),xe=!0;for(let at=Math.min(se,be)+1;at<Math.max(se,be);at++){let Wt=n[at];if(w(Te,Wt.nodeType===1?1:Wt.value.length+1),Wt.nodeType===1||Wt.value.trim()){xe=!1;break}}if(!xe)continue;let fe=v(G,null,Te),oe=v(I,T,Te);if(fe.flat.atoms.length||oe.flat.atoms.length)continue;let Re=fe.flat.text,De=oe.flat.text;if(w(Te,Re.length+De.length+_e.length),!Re||!Ft.length)continue;let We=0,Ye=De.length;if(se<be&&De.endsWith(Re))Ye-=Re.length;else if(se>be&&De.startsWith(Re))We=Re.length;else continue;for(;We<Ye&&Sn.test(De[We]);)We++;for(;Ye>We&&Sn.test(De[Ye-1]);)Ye--;let wt=De.slice(We,Ye);if(!(!wt||!(wt.startsWith(Ft[0].raw)||wt.endsWith(Ft[Ft.length-1].raw)))){if(Se){Se=null;break}Se=I,Je=We,nt=Ye,st=Ft[0],$t=Ft[Ft.length-1]}}}if(w(Te,U.length),!Se||!we.has(Se)||!U.some(Ft=>Ft.target===Se&&(Ft.from<=st.from&&Ft.to>=st.to&&Ft.targetFrom+st.from-Ft.from===Je||Ft.from<=$t.from&&Ft.to>=$t.to&&Ft.targetFrom+$t.to-Ft.from===nt)))continue}if(ie&&!(ne.every(Se=>W[Se])&&(vt||Array.from(we).some(Se=>Y.has(Se))))&&!Bt.some(Se=>Se.source===B&&Jn.test(_e.slice(Se.from,Se.to))))continue;let je=!1;if(vt){w(Te,Bt.length+ne.length);for(let Se of Bt)Se.source===B&&(w(Te,Se.to-Se.from),W.fill(1,Se.from,Se.to));je=!0;for(let Se of ne)if(!W[Se]){je=!1;break}}for(let Se of we){w(Te,U.length);let Je=U.filter(st=>st.target===Se);ot.push({side:F,source:B,target:Se,runs:Je,models:f,retained:Bt,conservedSource:je}),B.nodeType===1&&et.add(B),Se.nodeType===1&&et.add(Se);let nt=S.baseOf(Se);nt?.nodeType===1&&et.add(nt)}}if(p.push(...ot),Fe&&ot.length)for(let B of Fe)Ne.add(B);for(let B of et)k.add(B)}catch(de){if(de!==A)throw de}finally{if(t&&!Fe&&!ae){let de=Pa({base:n,views:r,side:F,attempt:O,eligible:o,blocked:d,baseId:l,model:v,tokensOf:E,charge:w,exhausted:A,limit:c});de&&(y||=[]).push(...de)}if(e&&!Fe&&!ae){let de=Xl({base:n,views:r,side:F,attempt:O,eligible:o,blocked:d,baseId:l,model:v,tokensOf:E,certificates:p,charge:w,exhausted:A,limit:c});de&&(m||=[]).push(...de)}}}}let R=p.length?new Map:null;for(let F of p){let S=R.get(F.source);S||R.set(F.source,S=[]),S.push(F)}let D=null;if(R){let F=null;for(let[S,T]of R){let J=g?.get(S)||0;if(T.length<2&&!J)continue;let q=0;for(let V of T)V.conservedSource&&(q|=1<<V.side);for(let V of T){if(V.conservedSource)continue;let Ce=1<<V.side,Me=!0;if(q&Ce)Me=!1;else if(J&Ce){Me=!1;try{Me=Id(V,F||=Zt(c),w)}catch(Be){if(Be!==A)throw Be}}Me||(D||=new Set).add(V)}}}if(D){let F=0;for(let S of p)D.has(S)||(p[F++]=S);p.length=F;for(let[S,T]of R){F=0;for(let J of T)D.has(J)||(T[F++]=J);T.length=F,F||R.delete(S)}k.clear();for(let S of p){let{source:T,target:J,side:q}=S;T.nodeType===1&&k.add(T),J.nodeType===1&&k.add(J);let V=r[q].V.baseOf(J);V?.nodeType===1&&k.add(V)}}if(m){let F=Zt(c),S=!1;for(let T of m){let J=!1,q=R?.get(T.source);if(q&&!S)try{J=xi(T,q,F,w)}catch(V){if(V!==A)throw V;S=!0}J||e(T)}}if(y){let F=new Set,S=Zt(c);try{for(let T of y){if(w(S,1),F.has(T.source))continue;F.add(T.source);let J=!1;for(let q of p)if(w(S,1),q.source===T.source||q.target===T.local||q.target===T.remote){J=!0;break}J||t(T)}}catch(T){if(T!==A)throw T}}for(let F of n)if(k.has(F))for(let{V:S}of r){let T=S.twin(F);T&&S.here(T)&&k.add(T)}return p.length?{blocks:k,certificates:p,certificatesBySource:R,models:f}:null}function Ba({certificates:e,scopes:t,flats:n,keys:r,limit:o=2e4*32}){let s=Symbol(),i=Zt(o),l=g=>{if(g>i.remaining)throw s;i.remaining-=g},a=t.map(g=>new Set(g)),c=new Map,h=new Map,u=(g,d)=>{let k=c.get(g);if(k||c.set(g,k=new Map),k.has(d))return k.get(d);l(g.text.length);let A=h.get(d);if(!A){l(d.nodes.length+d.atoms.length),A={nodes:new Map,atoms:new Map};for(let N of d.nodes)A.nodes.set(N.node,N);for(let N of d.atoms)A.atoms.set(N.el,N.i);h.set(d,A)}let{nodes:w,atoms:v}=A,E=new Int32Array(g.text.length).fill(-1);for(let N of g.nodes){let _=w.get(N.node);if(!(!_||N.e-N.s!==_.e-_.s)){l(N.e-N.s);for(let M=N.s;M<N.e;M++)E[M]=_.s+M-N.s}}for(let N of g.atoms){let _=v.get(N.el);_!==void 0&&(E[N.i]=_)}return k.set(d,E),E},f=(g,d,k,A,w)=>{let v=g[g.length-1];v&&v.to===d&&v.target+v.to-v.from===A&&v.kind===w?v.to=k:g.push({from:d,to:k,target:A,kind:w})},p=(g,d,k,A)=>{l((A-k)*4);let w=[],v=k,E=M=>{let j=g.text.slice(v,M);for(let R of pn(j,Nn(j)))R.from=v,R.to=v+R.len,w.push(R),v+=R.len},N=0,_=g.atoms.length;for(;N<_;){l(1);let M=N+_>>>1;g.atoms[M].i<k?N=M+1:_=M}for(let M=N;M<g.atoms.length&&g.atoms[M].i<A;M++){l(1);let j=g.atoms[M];E(j.i),w.push({k:d(j),raw:Yn,len:1,from:v,to:v+1}),v++}return E(A),w},m=(g,d,k,A,w,v)=>{if(k===A||w===v)return;if(A-k===v-w){l((A-k)*4);let S=!0;for(let T=k,J=w;T<A;T++,J++){if(n[0].text[T]!==n[d].text[J]){S=!1;break}let q=n[0].atomAt.get(T),V=n[d].atomAt.get(J);if(!!q!=!!V||q&&r[0](q)!==r[d](V)){S=!1;break}}if(S){f(g,k,A,w,"retained");return}}let E=p(n[0],r[0],k,A),N=p(n[d],r[d],w,v),_=E.length+N.length+4,M=Math.min(E.length+N.length,4e3,Math.floor((Math.sqrt(_*_+i.remaining/2)-_)/2));if(M<1)throw s;l(4*(M+1)*(_+M+1));let j=Zn(E,N,M),R=0,D=0,F=()=>{let S=E[R++],T=N[D++];l(S.len),S.raw===T.raw&&f(g,S.from,S.to,T.from,"retained")};for(let S of j.hunks){for(;R<S.bs;)F();R=S.be,D+=S.toks.length}for(;R<E.length&&D<N.length;)F()},y=g=>{let d=e.filter(j=>j.side===g-1&&a[0].has(j.source)&&a[g].has(j.target));if(!d.length)return null;let k=[],A=(j,R,D)=>{if(!a[0].has(j.source)||!a[g].has(j.target))return;let F=u(R.get(j.source).flat,n[0]),S=u(R.get(j.target).flat,n[g]);l(j.to-j.from);for(let T=0;T<j.to-j.from;T++){let J=F[j.from+T],q=S[j.targetFrom+T];if(J<0||q<0)throw s;f(k,J,J+1,q,D)}},w=new Set;for(let j of d){if(!w.has(j.retained)){w.add(j.retained);for(let R of j.retained)A(R,j.models,"retained")}for(let R of j.runs)A(R,j.models,"transfer")}k.sort((j,R)=>(l(1),j.from-R.from||j.target-R.target));let v=[];for(let j of k){l(1);let R=v[v.length-1];if(R&&j.from<R.to){if(j.target-j.from!==R.target-R.from)throw s;R.to=Math.max(R.to,j.to),j.kind==="transfer"&&(R.kind="transfer")}else v.push(j)}let E=[],N=0,_=0;for(let j of v){if(j.target<_)throw s;m(E,g,N,j.from,_,j.target),E.push(j),N=j.to,_=j.target+j.to-j.from}m(E,g,N,n[0].text.length,_,n[g].text.length);let M=Gn({base:n[0],side:n[g],retained:E.filter(j=>j.kind==="retained"),transfers:E.filter(j=>j.kind==="transfer"),baseAtomKey:r[0],sideAtomKey:r[g],budget:i});if(M.status!=="ready"||!M.monotone)throw s;return M};try{let g=y(1),d=y(2);return g||d?{local:g,remote:d}:{fallback:!0}}catch(g){if(g!==s)throw g;return{fallback:!0}}}function Li(e,t,n=!1){let r=-1,o=-1;for(let i=0;i<e.list.length;i++){let l=e.list[i];l.bLo<t.lo||l.bLo>t.hi||(r<0&&(r=i),o=i)}let s=[];for(let i=r;i>=0&&i<=o;i++){let l=e.list[i],a=!n&&i===r?l.inlineStart<0?l.to:l.inlineStart:l.from,c=!n&&i===o?l.inlineEnd<0?l.from:l.inlineEnd:l.to;for(let h=a;h<c;h++)s.push(e.units[h]);i<o&&s.push(e.units[l.next])}return s}var ut=e=>!!e&&e.nodeType===1,qn=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function Pi(e){for(let t of e)if(qn.has(t.tagName))return!0;return!1}function jd(e,t,n){let r=null;for(let o of t.childNodes)if(!(!ut(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 So="[id],[data-id],script,head>*";function ji(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let r=qr(n,e);if(r)return"merge:"+r.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?va(n,t):null}}function us(e,t,n,r){let o=r.ignored,s=r.stats||ar(),i=Vl({ignored:o,ignoreAttribute:r.ignoreAttribute,stats:s}),{unitsOf:l,meta:a}=i,c=r.baseURI,h=r.mergeTags!==null,u=ji(r.mergeTags,c),f=I=>G=>{let se=u(G);return se!==null?se:I(G)},p=f(r.identity.base),m=f(r.identity.local),y=f(r.identity.remote),g=r.authored||r.identity,d=I=>I&&I.nodeType===9?I.documentElement:I,k=d(e),A=d(t),w=d(n),v=globalThis.__hyperMorphProfile,E=v?performance.now():0,N=I=>I===_n?So:null,_=r.scope||null,M=_?_.baseDropped:new Set,j=new Set,R=_?_.remoteDropped:new Set,D=_?_.baseIndex:Qo(k,p,o,N(r.identity.base),M),F=r.localIsBase||k===A?null:Qo(A,m,o,N(r.identity.local),j),S=_?_.remoteIndex:Qo(w,y,o,N(r.identity.remote),R),T=I=>{let G=ut(I)&&m(I);return G&&F?.get(G)===I&&!D.has(G)?G:null},J=I=>{let G=ut(I)&&y(I);return G&&S.get(G)===I&&!D.has(G)?G:null},q=F?ui(k,A,{analyzer:i,baseIndex:D,sideIndex:F,baseId:g.base,sideId:g.local,baseKey:p,sideKey:m,baseDropped:M,sideDropped:j,stats:s}):qa(),V=ui(k,w,{analyzer:i,baseIndex:D,sideIndex:S,baseId:g.base,sideId:g.remote,baseKey:p,sideKey:y,baseDropped:M,sideDropped:R,stats:s,scope:_,comparisons:r.comparisons});if(_){if(!_.held(V))return null;for(let I of _.dropped)ci(I)}let Ce=null;function Me(I){if(!Ce){Ce=new WeakMap;let G=[k];for(;G.length;){let se=G.pop();se.tagName==="TEMPLATE"&&se.content&&Ce.set(se.content,se);for(let be of i.childrenOf(se))be.nodeType===1&&G.push(be)}}return Ce.get(I)||null}let Be=I=>{let G=ut(I)||I.nodeType?I.parentNode:I.parent;return G&&G.nodeType===11?Me(G):G};if(V.moved.size){let I=!1;for(let G of Array.from(V.moved))!ut(G)||V.identityPaired.has(G)||!g.base(G)||b(V,Be(G))||(V.unpair(G),I=!0);I&&V.rematch()}gn(),K(q,V),K(V,q);for(let I of[q,V])if(I.refused)for(let G of I.refused)I.moved.has(G)||s.ambiguousMoves++;v&&(v.alignTotal=(v.alignTotal||0)+(performance.now()-E),E=performance.now());let ce=k.ownerDocument.implementation.createHTMLDocument(""),Ae=new WeakMap,Ue=new WeakMap,Ne=[],O=[],X=new Set,le=[],re=new Set,Pe=new Set,Fe=new Set,Te=new WeakMap,ot=null,et=r.lineage?.locals.length?ca():null,ae=I=>{let G=os(I);return G&&et&&et.consume(I.local),G},de=r.conflicts||"remote",Ee=I=>Ne.push(I),Ge=I=>Ne.push(I),Ve=Na({roots:{base:k,local:A,remote:w},L:q,R:V,unitsOf:l,provenance:Ae,policy:de}),ze=(I,G)=>{O.push(I),G&&Ve.note(I,G)},lt=null,pt=null,Rt=Qt(),dt=null,vt=B(k,q.map.get(k),V.map.get(k),!!r.localIsBase,!!r.childrenOnly);vt.tagName==="HTML"?ce.replaceChild(vt,ce.documentElement):ce.body.appendChild(vt),lt?.drain(vt),pt?.drain(vt),v&&(v.build=(v.build||0)+(performance.now()-E));let gt=r.childrenOnly?!je(we(vt),we(w)):!te(vt,w),yn=Ve.finish(vt),Bt=et?fa({locals:r.lineage.locals,rec:et,root:vt,provenance:Ae,segments:le,ignored:o}):null;return{doc:ce,root:vt,provenance:Ae,textMappers:Ue,decisions:Ne,conflicts:O,recoveryLinks:yn,localDiverged:gt,mergedScripts:X,segments:le,remoteIdOf:r.identity.remote,customIdentity:r.identity.remote!==_n,L:q,R:V,stats:s,lineage:Bt};function Qt(){let I=new Map,G=new Set;if(r.localIsBase||!q.insertedByHash)return{partner:I,drop:G};let se=q.insertedByHash(),be=V.insertedByHash();if(!se.size||!be.size)return{partner:I,drop:G};let xe={ignored:o,remoteWins:r.remoteWins,inlineCache:Te},fe=ht=>{let Qe=0;for(let Mt=ht.parentNode;Mt;Mt=Mt.parentNode)Qe++;return Qe},oe=[],Re=ht=>{let Qe=ht.textContent.trim();return Qe.split(/\s+/).length>=3||Qe.replace(/\s/g,"").length>=12},De=ht=>{let Qe=b(q,ht),Mt=b(V,ht);return Qe&&q.reverse.get(Qe.parentNode)!==ht.parentNode||Mt&&V.reverse.get(Mt.parentNode)!==ht.parentNode},We=(ht,Qe,Mt)=>{for(let Ut of Mt.parentNode.children){let En=Ut!==Mt&&ht.reverse.get(Ut);if(En&&De(En))return!0}let bt=ht.reverse.get(Mt.parentNode);if(bt){for(let Ut of bt.children)if(!b(Qe,Ut)&&!o(Ut))return!0}return!1},Ye=new Map([[q,new Map],[V,new Map]]),wt=(ht,Qe)=>{let Mt=Ye.get(ht),bt=Mt.get(Qe);if(bt===void 0){bt=!1;for(let Ut of Qe.children)if(ht.reverse.has(Ut)||wt(ht,Ut)){bt=!0;break}Mt.set(Qe,bt)}return bt},at=new Map;for(let ht of be.values())for(let Qe of ht){let Mt=J(Qe);Mt&&at.set(Mt,Qe)}for(let ht of se.values())for(let Qe of ht){let Mt=T(Qe),bt=Mt?at.get(Mt):null;bt&&bt.tagName===Qe.tagName&&!Xn(Qe,xe)&&!Xn(bt,xe)&&!r.remoteWins(Qe)&&!r.remoteWins(bt)&&oe.push([Qe,[bt],fe(Qe),!0,!0])}for(let[ht,Qe]of se){let Mt=be.get(ht);if(!Mt)continue;let bt=Qe.length===1&&Mt.length===1;for(let Ut of Qe)!Xn(Ut,xe)&&!T(Ut)&&oe.push([Ut,Mt,fe(Ut),bt&&(Re(Ut)||We(q,V,Ut)||We(V,q,Mt[0]))])}if(!oe.length)return{partner:I,drop:G};oe.sort((ht,Qe)=>ht[2]-Qe[2]);let Wt=new Set,zt=new Set,bn=ht=>{for(let Qe of ht.querySelectorAll("*"))Wt.add(Qe)},Tt=(ht,Qe)=>ht.reverse.get(Qe.parentNode)||null;for(let[ht,Qe,,Mt,bt]of oe){if(Wt.has(ht)||zt.has(ht)||bt&&(wt(q,ht)||wt(V,Qe[0])))continue;let Ut=Tt(q,ht),En=en=>!zt.has(en)&&!Wt.has(en)&&(bt||en.tagName===ht.tagName&&!J(en)&&i.equalUnits(ht,en)),cn=Qe.find(en=>Ut&&Tt(V,en)===Ut&&En(en))||(Mt?Qe.find(En):null);if(!cn)continue;zt.add(ht),zt.add(cn);let xn=Ut&&Tt(V,cn)===Ut;(!bt||!xn||i.equalUnits(ht,cn))&&(bn(ht),bn(cn)),!xn&&(I.set(ht,cn),I.set(cn,ht),G.add(de==="local"?cn:ht))}return{partner:I,drop:G}}function Yt(I,G,se){if(re.add(I),Rt.drop.has(I))return null;re.add(se);let be=G==="local"?I:se,xe=G==="local"?se:I,fe;return i.equalUnits(be,xe)?(fe=me(be,"local",!0),Ae.get(fe).remote=xe):fe=ke(be,xe),ze({kind:"structure",el:fe,detail:"both-moved",base:null,local:be,remote:xe},{unit:{b:null,l:be,r:xe}}),Ee({kind:"insert",el:fe,source:"both"}),fe}function gn(){if(!q.weak||!V.weak||!q.weak.size||!V.weak.size||!q.unpair)return;let I=new Map;for(let se of q.weak){let be=b(q,se);ut(se)&&ut(be)&&I.set(i.unitHash(be),se)}let G=!1;for(let se of Array.from(V.weak)){let be=b(V,se);if(!ut(se)||!ut(be))continue;let xe=I.get(i.unitHash(be));if(!xe||xe===se||!q.weak.has(xe)||b(q,se)&&b(V,xe))continue;let fe=b(q,xe);fe.tagName===be.tagName&&i.equalUnits(fe,be)&&(q.unpair(xe),V.unpair(se),G=!0)}G&&(q.rematch(),V.rematch())}function K(I,G){if(!I.weak||!I.weak.size||!G.insertedByHash)return;let se=G.insertedByHash();if(!se.size)return;let be=!1;for(let xe of Array.from(I.weak)){let fe=b(I,xe);if(!fe)continue;let oe=I===q?T(fe):J(fe);if(oe){let De=(I===q?S:F)?.get(oe);De&&De.tagName===fe.tagName&&!G.reverse.has(De)&&(I.unpair(xe),be=!0);continue}let Re=se.get(i.unitHash(fe));Re&&Re.some(De=>De.tagName===fe.tagName&&i.equalUnits(De,fe))&&(I.unpair(xe),be=!0)}be&&I.rematch()}function b(I,G){if(!G)return null;if(I.map.has(G))return I.map.get(G);let se=[],be=Be(G);for(;be&&!I.map.has(be);be=Be(be))se.push(be);let xe=be;if(!xe||!I.identical.has(xe))return null;I.pairIdenticalChildren(xe);for(let oe=se.length-1;oe>=0;oe--)I.pairIdenticalChildren(se[oe]);let fe=I.map.get(G)||null;return fe&&s.lazyTwins++,fe}function C(I,G,se,be){if(ut(I)&&qn.has(I.tagName)&&!q.identical.has(I)&&(I.previousSibling?.nodeType===3||I.nextSibling?.nodeType===3)){let Re=Be(I),De=b(q,I),We=b(V,I);De&&We&&$t(De,b(q,Re),q)&&!$t(We,b(V,Re),V)&&(pt||=Ra({L:q,R:V,twinIn:b,unitsOf:l,view:L,parentOf:Be,ignored:o,remoteWins:r.remoteWins,eligible:Ye=>ut(Ye)&&qn.has(Ye.tagName),build:B,out:ce,policy:de,provenance:Ae,textMappers:Ue,segments:le,conflicts:O,conflict:ze,decisions:Ne}),pt.ensureOwner(I))}if(G===null)return null;if(be!==void 0)return lt||=Hr(Ae,Be,q,V,b,B,o,r.remoteWins,O,ze,$,A,w),lt.plan(I,G,se,!!be),be&&(lt.produced(I,be),Pe.add(I)),be;if(Pe.has(I)||Fe.has(I))return ze({kind:"structure",el:null,detail:"both-moved",base:I},{subject:I}),Pe.has(I)?null:me(se,G);lt||=Hr(Ae,Be,q,V,b,B,o,r.remoteWins,O,ze,$,A,w),lt.plan(I,G,se,!0);let xe=b(q,I),fe=b(V,I);(!xe||!fe)&&ze({kind:"structure",el:null,detail:"move-beats-delete",base:I},{subject:I,deleted:xe?"remote":"local"});let oe=B(I,xe,fe,!1);return(G==="local"?Ee:Ge)({kind:"move",el:oe,source:G}),oe}function L(I,G,se,be){return be||!G||G===se?{el:se,asBase:!0,twin:xe=>xe,baseOf:xe=>xe,units:l(se),here:()=>!0,parentOfTwin:()=>se}:{el:G,asBase:!1,twin:xe=>b(I,xe),baseOf:xe=>I.reverse.get(xe),units:l(G),here:xe=>ut(xe)?xe.parentNode===G||G.tagName==="TEMPLATE"&&xe.parentNode===G.content:xe.parent===G||G.tagName==="TEMPLATE"&&xe.parent===G.content}}function $(I,G,se){return!G||se&&se.identical.has(I)?!1:ut(I)?!i.equalUnits(I,G)||!Q(I,G,se):I.value!==G.value}function Q(I,G,se){if(!se||I===G)return!0;let be=[[I,G]];for(;be.length;){let[xe,fe]=be.pop(),oe=l(xe),Re=l(fe);for(let De=0;De<oe.length&&De<Re.length;De++){let We=oe[De],Ye=Re[De];if(!ut(We)||!ut(Ye))continue;let wt=se.map.get(We);if(wt!==void 0&&wt!==Ye)return!1;let at=se.reverse.get(Ye);if(at!==void 0&&at!==We)return!1;be.push([We,Ye])}}return!0}function B(I,G,se,be,xe=!1){let fe=be||(se?r.remoteWins(se):r.remoteWins(I)),oe=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?ce.createElementNS(I.namespaceURI,I.tagName):ce.createElement(I.tagName),Re={base:I,local:G||null,remote:se||null};if(Ae.set(oe,Re),fe&&!be&&G&&$(I,G,q)&&(!se||!i.equalUnits(G,se))&&ze({kind:"structure",el:oe,detail:"remote-wins",base:I,local:G,remote:se||null},{subject:I}),re.add(I),Pe.add(I),G&&re.add(G),se&&re.add(se),r.skipUnchanged&&!xe&&(r.localIsBase||q.identical.has(I))&&se&&V.identical.has(I)&&!r.remoteWins(I)){Re.unchanged=!0;for(let We of I.attributes)We.namespaceURI?oe.setAttributeNS(We.namespaceURI,We.name,We.value):oe.setAttribute(We.name,We.value);return lt?.produced(I,oe),oe}Fe.add(I),xe||ie(I,fe?I:G,se,oe);let De=I.tagName;if(vn(I))ye(I,fe?I:G,se,oe);else if(De==="TEXTAREA")oe.textContent=he(I.textContent,(fe?I:G)?(fe?I:G).textContent:I.textContent,se?se.textContent:I.textContent,oe,"text");else if(!pt?.render(I,oe)){let We=ee(I,G,se,fe,oe),Ye=De==="TEMPLATE"&&oe.content?oe.content:oe;for(let wt of We)Ye.appendChild(wt)}return Fe.delete(I),lt?.produced(I,oe),oe}function he(I,G,se,be,xe){if(G===se)return G;if(G===I)return se!==I&&Ge({kind:xe,node:be,source:"remote"}),se;if(se===I)return Ee({kind:xe,node:be,source:"local"}),G;let fe=de==="local"?G:se;return ze({kind:xe,node:be,base:I,local:G,remote:se,resolved:fe},{site:"whole",el:be}),Ne.push({kind:xe,node:be,source:"both"}),fe}function ye(I,G,se,be){let xe=I.textContent,fe=G?G.textContent:xe,oe=se?se.textContent:xe,Re=h?qr(I,r.mergeTags,!0):null;if(Re&&fe!==oe){let De=se&&se.getAttribute("merge-key")||I.getAttribute("merge-key"),{text:We,warnings:Ye,conflicts:wt}=Mi(r.localIsBase?void 0:xe,fe,oe,{parse:Re.recognizer.parse,keyCandidates:De?De.split(/[\s,]+/).filter(Boolean):void 0});for(let at of Ye)console.warn(`[hyper-morph] merge "${Re.raw}": ${at}`);for(let at of r.localIsBase?[]:wt)ze({kind:"json",node:be,name:Re.raw,path:at.path,base:at.base,local:at.local,remote:at.remote,resolved:at.resolved});be.textContent=We,X.add(be),We!==oe?Ee({kind:"text",node:be,source:We===fe?"local":"both"}):We!==xe&&Ge({kind:"text",node:be,source:"remote"});return}be.textContent=he(xe,fe,oe,be,"text")}function ie(I,G,se,be){let xe=new Map;for(let fe of[I,G,se])if(fe)for(let oe of fe.attributes)r.ignoreAttribute(fe,oe.name)||xe.set(oe.name,oe);for(let[fe,oe]of xe){let Re=I?I.getAttribute(fe):null,De=G?G.getAttribute(fe):Re,We=se?se.getAttribute(fe):Re,Ye;De===We?Ye=De:De===Re?(Ye=We,Ge({kind:"attr",el:be,name:fe,source:"remote"})):We===Re?(Ye=De,Ee({kind:"attr",el:be,name:fe,source:"local"})):(Ye=_e(fe,Re,De,We),Ye===void 0&&(Ye=de==="local"?De:We,ze({kind:"attr",el:be,name:fe,base:Re,local:De,remote:We,resolved:Ye},{el:be,sample:oe})),Ne.push({kind:"attr",el:be,name:fe,source:"both"})),Ye!=null&&(oe.namespaceURI?be.setAttributeNS(oe.namespaceURI,oe.name,Ye):be.setAttribute(fe,Ye))}}function _e(I,G,se,be){if(I==="class"){let xe=We=>new Set((We||"").split(/\s+/).filter(Boolean)),fe=xe(G),oe=xe(se),Re=xe(be),De=new Set;for(let We of new Set([...fe,...oe,...Re])){let Ye=fe.has(We),wt=oe.has(We),at=Re.has(We);(wt===at?wt:wt===Ye?at:wt)&&De.add(We)}return[...De].join(" ")}if(I==="style"){let xe=Ye=>{let wt=new Map;if(!Ye)return wt;let at=0,Wt=null,zt="",bn=()=>{let Tt=zt.indexOf(":");Tt>0&&wt.set(zt.slice(0,Tt).trim(),zt.slice(Tt+1).trim()),zt=""};for(let Tt of Ye){if(Wt){zt+=Tt,Tt===Wt&&(Wt=null);continue}if(Tt==='"'||Tt==="'"){Wt=Tt,zt+=Tt;continue}if(Tt==="("?at++:Tt===")"&&at--,Tt===";"&&at===0){bn();continue}zt+=Tt}return zt.trim()&&bn(),wt},fe=xe(G),oe=xe(se),Re=xe(be),De=new Map,We=!1;for(let Ye of new Set([...fe.keys(),...oe.keys(),...Re.keys()])){let wt=fe.get(Ye)??null,at=oe.get(Ye)??null,Wt=Re.get(Ye)??null,zt;at===Wt?zt=at:at===wt?zt=Wt:Wt===wt?zt=at:(zt=de==="local"?at:Wt,We=!0),zt!=null&&De.set(Ye,zt)}return We?void 0:[...De].map(([Ye,wt])=>`${Ye}: ${wt}`).join("; ")}}function U(I,G,se,be){let xe=I.value,fe=be?xe:G?G.value:"",oe=se?se.value:"";re.add(I),G&&re.add(G),se&&re.add(se);let Re=ko(xe,fe,oe,de),De=Re.text===""?null:ce.createTextNode(Re.text);De&&(Ae.set(De,{base:I.nodes,local:G?G.nodes:null,remote:se?se.nodes:null}),Ue.set(De,Re.mapLocalOffset)),fe!==xe&&oe!==xe?Ne.push({kind:"text",node:De,source:"both"}):fe!==xe?Ee({kind:"text",node:De,source:"local"}):oe!==xe&&Ge({kind:"text",node:De,source:"remote"});for(let We of Re.conflicts)ze({kind:"text",node:De,base:xe.slice(We.bs,We.be),local:We.local,remote:We.remote,resolved:We.resolved},{site:"run",bRun:I,lRun:G,rRun:se,node:De,c:We});return De}function Y(I,G){return vr(I,G).every(se=>se.bs===se.be)}function pe(I,G){let se=I?I.value:"",be=G?G.value:"",xe;if(se===be||!be?xe=se:se?Y(se,be)?xe=be:Y(be,se)?xe=se:(xe=de==="local"?se:de==="both"?se+be:be,ze({kind:"structure",el:null,detail:"insert-collision",local:se,remote:be,resolved:xe},{unit:{b:null,l:I,r:G},localLost:de==="remote"})):xe=be,I&&re.add(I),G&&re.add(G),xe==="")return null;let fe=ce.createTextNode(xe);return Ae.set(fe,{base:null,local:I?I.nodes:null,remote:G?G.nodes:null}),se?Ee({kind:"insert",el:fe,source:be&&se===be?"both":"local"}):Ge({kind:"insert",el:fe,source:"remote"}),fe}function ke(I,G){let se={ignored:o,remoteWins:r.remoteWins,inlineCache:Te},be=Re=>l(Re).every(De=>ut(De)?Xn(De,se):De.kind==="text"),xe=null;if(be(I)&&be(G)){let Re=I.textContent,De=G.textContent;Re===De||Y(De,Re)?xe=G:Y(Re,De)&&(xe=I)}if(!xe){let Re=de==="local",De=me(Re?I:G,Re?"local":"remote",!0),We=Ae.get(De);return Re?We.remote=G:We.local=I,ze({kind:"structure",el:De,detail:"insert-collision",local:I,remote:G,resolved:Re?I:G},{unit:{b:null,l:I,r:G},localLost:!Re}),De}let fe=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?ce.createElementNS(I.namespaceURI,I.tagName):ce.createElement(I.tagName);ie(null,I,G,fe),Ae.set(fe,{base:null,local:I,remote:G}),re.add(I),re.add(G);let oe=ae({base:Array.from(xe.childNodes),local:Array.from(I.childNodes),remote:Array.from(G.childNodes),out:ce,policy:de,idOf:{local:m,remote:y},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,provenance:Ae,textMappers:Ue,conflicts:O,conflict:ze,scope:{base:null,local:I,remote:G,units:[],at:0},synthetic:!0,decisions:Ne,node:fe});le.push(...oe.segments);for(let Re of oe.nodes)fe.appendChild(Re);return fe}function me(I,G,se=!1){if(!se&&ut(I)){let oe=Rt.partner.get(I);if(oe)return Yt(I,G,oe)}if(!ut(I)){if(I.value==="")return null;let oe=I.kind==="comment"?ce.createComment(I.value):ce.createTextNode(I.value);return Ae.set(oe,{base:null,local:G==="local"?I.nodes:null,remote:G==="remote"?I.nodes:null}),re.add(I),oe}let be=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?ce.createElementNS(I.namespaceURI,I.tagName):ce.createElement(I.tagName);for(let oe of I.attributes)oe.namespaceURI?be.setAttributeNS(oe.namespaceURI,oe.name,oe.value):be.setAttribute(oe.name,oe.value);Ae.set(be,{base:null,local:G==="local"?I:null,remote:G==="remote"?I:null}),re.add(I);let xe=I.tagName==="TEMPLATE"&&be.content?be.content:be,fe=G==="local"?q:V;for(let oe of l(I)){let Re=ut(oe)?fe.reverse.get(oe):null;if(Re&&C(Re,null,null),Re&&Pe.has(Re)){ze({kind:"structure",el:null,detail:"both-moved",base:Re},{subject:Re});continue}if(Re&&!Fe.has(Re)){let We=b(q,Re)||null,Ye=b(V,Re)||null;if(We||Ye){lt||=Hr(Ae,Be,q,V,b,B,o,r.remoteWins,O,ze,$,A,w),lt.plan(Re,G,oe,!0);let wt=B(Re,We,Ye,!1);G==="local"?Ee({kind:"move",el:wt,source:"local"}):Ge({kind:"move",el:wt,source:"remote"}),xe.appendChild(wt);continue}}let De=me(oe,G);De&&xe.appendChild(De)}if(!se&&Rt.drop.size&&I.tagName==="DIV"&&!xe.firstChild&&!I.attributes.length&&!(G==="local"?m(I):y(I))&&!fe.reverse.has(I)&&!o(I)&&!r.remoteWins(I)){let oe=I.firstChild;if(oe&&oe===I.lastChild&&ut(oe)&&(Rt.drop.has(oe)||dt?.has(oe)))return(dt||=new WeakSet).add(I),null}return be}function ee(I,G,se,be,xe){G&&q.identical.has(I)&&q.pairIdenticalChildren(I),se&&V.identical.has(I)&&V.pairIdenticalChildren(I);let fe=L(q,G,I,be),oe=L(V,se,I,!1),Re=l(I),De=new Set(Re),We=new Map;for(let ue=0;ue<Re.length;ue++)We.set(Re[ue],ue);let Ye=[],wt=new Set,at=new Map,Wt=new Set,zt=et&&[],bn=et&&[],Tt=new Set,ht=[],Qe=null,Mt=new Map;if(!fe.asBase&&!oe.asBase&&!q.identical.has(I)&&!V.identical.has(I))for(let ue of Re){if(!ut(ue)||!qn.has(ue.tagName))continue;let Ke=fe.twin(ue),He=oe.twin(ue);Ke&&He&&(!fe.here(Ke)||!oe.here(He))&&C(ue,null,null)}go();let bt=ue=>{let Ke=[];for(let He of ue.units){if(Tt.has(He))continue;let it=ue.baseOf(He);it&&De.has(it)&&Ke.push(it)}return Ke},Ut=ue=>bt(ue).map(Ke=>We.get(Ke)),En=ue=>ue.every((Ke,He)=>He===0||Ke>=ue[He-1]),cn=!fe.asBase&&!En(Ut(fe)),xn=!oe.asBase&&!En(Ut(oe));cn&&xn&&ze({kind:"structure",el:xe,detail:"both-reordered",base:I},{subject:I,lKept:bt(fe),rKept:bt(oe)});let en=xn||!cn?{V:oe,A:V,side:"remote",other:fe,otherA:q,otherSide:"local"}:{V:fe,A:q,side:"local",other:oe,otherA:V,otherSide:"remote"};cn?Ee({kind:"move",el:null,source:xn?"both":"local",base:I}):xn&&Ge({kind:"move",el:null,source:"remote",base:I});let Hn=fe.asBase?[]:fe.units.filter(ue=>!fe.baseOf(ue)&&!Tt.has(ue)&&!Rt.partner.has(ue)),Rr=oe.asBase?[]:oe.units.filter(ue=>!oe.baseOf(ue)&&!Tt.has(ue)&&!Rt.partner.has(ue)),zn=new Map;if(Hn.length&&Rr.length){let ue=new Map,Ke=new Map;for(let Xe of Rr){if(ut(Xe)){let _t=y(Xe);_t&&ue.set(_t,Xe)}let Ze=i.unitHash(Xe);Ke.has(Ze)||Ke.set(Ze,[]),Ke.get(Ze).push(Xe)}let He=(Xe,Ze)=>{let _t=Xe.units.indexOf(Ze);for(let tt=_t-1;tt>=0;tt--){let ft=Xe.baseOf(Xe.units[tt]);if(ft)return ft}return"start"},it=new Map,Et=new Map;for(let Xe of Rr){let Ze=He(oe,Xe);ut(Xe)?(Et.has(Ze)||Et.set(Ze,[]),Et.get(Ze).push(Xe)):Xe.kind==="text"&&!it.has(Ze)&&it.set(Ze,Xe)}for(let Xe of Hn){let Ze=null;if(ut(Xe)){let tt=m(Xe);tt&&ue.has(tt)&&!zn.has(ue.get(tt))&&(Ze=ue.get(tt))}else if(Xe.kind==="text"){let tt=it.get(He(fe,Xe));tt&&!zn.has(tt)&&(Ze=tt)}let _t=!!T(Xe);if(!Ze&&!_t){let tt=Ke.get(i.unitHash(Xe));tt&&(Ze=tt.find(ft=>!zn.has(ft)&&ut(ft)===ut(Xe)&&(ut(ft)?ft.tagName===Xe.tagName&&!J(ft):ft.kind===Xe.kind)&&i.equalUnits(Xe,ft))||null)}if(!Ze&&ut(Xe)&&!_t){let tt=g.local(Xe),ft=(Et.get(He(fe,Xe))||[]).filter(kt=>{let Vt=g.remote(kt);return!zn.has(kt)&&kt.tagName===Xe.tagName&&!J(kt)&&!(tt&&Vt&&tt!==Vt)&&i.similar(Xe,kt)});ft.length===1&&(Ze=ft[0])}Ze&&(zn.set(Ze,Xe),zn.set(Xe,Ze))}}let mo=ue=>{if(pt?.consumes(ue))return null;if(re.has(ue)||lt?.has(ue))return at.get(ue)||null;let Ke=fe.twin(ue),He=oe.twin(ue),it=Ke&&!fe.asBase&&!fe.here(Ke),Et=He&&!oe.asBase&&!oe.here(He);if(it||Et){if((!Ke||!He)&&ze({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:Ke?"remote":"local"}),!st(ue))return ut(ue)?(lt||=Hr(Ae,Be,q,V,b,B,o,r.remoteWins,O,ze,$,A,w),it&<.plan(ue,"local",Ke),Et&<.plan(ue,"remote",He)):re.add(ue),null;ze({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue})}if(Ke&&!He&&!fe.asBase&&!oe.asBase&&ut(ue)&&qn.has(ue.tagName)&&!r.remoteWins(ue)&&!r.remoteWins(Ke)&&$(ue,Ke,q)&&jd(ue,we(oe.el),o)){let ft={ignored:o,remoteWins:r.remoteWins,inlineCache:Te},kt=Vt=>ut(Vt)?Xn(Vt,ft):Vt.kind==="text";if(l(ue).every(kt)&&l(Ke).every(kt)){let Vt=ae({base:[ue],local:[Ke],remote:[],blocks:new Set([ue,Ke]),out:ce,policy:de,L:q,R:V,idOf:{base:p,local:m,remote:y},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(nn,Rn,ir)=>B(nn,Rn,ir,!1),cloneUnit:me,mergeAttrs:ie,atomKey:i.exactUnitKey,moveIn:C,moveBuilt:C,movePlanned:C,provenance:Ae,textMappers:Ue,conflicts:O,conflict:ze,scope:{base:I,local:fe.el,remote:oe.el,units:Re,at:We.get(ue)},decisions:Ne,node:xe});le.push(...Vt.segments),re.add(ue),re.add(Ke);let Pt=ce.createDocumentFragment();for(let nn of Vt.nodes)Pt.appendChild(nn);return at.set(ue,Pt),at.set(Ke,Pt),Pt}}if(!Ke&&!He)return re.add(ue),Ge({kind:"remove",source:"both",base:ue}),null;if(!Ke&&!$(ue,He,V))return re.add(ue),Ee({kind:"remove",source:"local",base:ue}),null;if(!He&&!$(ue,Ke,q))return re.add(ue),Ge({kind:"remove",source:"remote",base:ue}),et&&(et.remove(Ke),zt.push({bk:ue,lk:Ke})),null;let Xe=!Ke||!He,Ze=fe.asBase?b(q,ue)||null:Ke,_t=oe.asBase&&ut(ue)&&(V.identityPaired.has(ue)||!g.base(ue))&&b(V,ue)||He,tt;return ut(ue)?tt=B(ue,Ze,_t,fe.asBase):ue.kind==="comment"?tt=Je(ue,Ze,He,fe.asBase):tt=U(ue,Ze,He,fe.asBase),re.add(ue),tt&&(at.set(ue,tt),Ke&&at.set(Ke,tt),He&&at.set(He,tt),Xe&&(ze({kind:"structure",el:tt,detail:"edit-beats-delete",base:ue},{subject:ue,deleted:Ke?"remote":"local"}),Ke?Ee({kind:"insert",el:tt,source:"local"}):Ge({kind:"insert",el:tt,source:"remote"}))),tt},or=(ue,Ke,He,it)=>{if(pt?.consumes(ue))return null;if(re.has(ue))return at.get(ue)||null;let Et=Ke.baseOf(ue);if(Et&&De.has(Et))return Tt.has(Et)&&!Tt.has(ue)?Yo(Et,ue,it):mo(Et);if(Et)return ti(Et,ue,it);let Xe=zn.get(ue);if(Xe){let _t=it==="local"?ue:Xe,tt=it==="local"?Xe:ue,ft;return ut(_t)?i.equalUnits(_t,tt)?(ft=me(_t,"local"),ft&&(Ae.get(ft).remote=tt)):ft=ke(_t,tt):ft=pe(_t,tt),re.add(_t),re.add(tt),ft&&(at.set(_t,ft),at.set(tt,ft),ut(_t)&&Ee({kind:"insert",el:ft,source:"both"})),ft}let Ze=me(ue,it);return Ze&&(at.set(ue,Ze),it==="local"?Ee({kind:"insert",el:Ze,source:"local"}):(Ge({kind:"insert",el:Ze,source:"remote"}),et&&ut(ue)&&!Rt.partner.has(ue)&&bn.push({su:ue,node:Ze}))),Ze},Yo=(ue,Ke,He)=>{let it;return ut(ue)?(it=C(ue,He,Ke),it&&re.add(Ke)):(it=me(Ke,He),re.add(Ke),it&&(He==="local"?Ee:Ge)({kind:"insert",el:it,source:He})),it&&at.set(Ke,it),it},ti=(ue,Ke,He)=>{C(ue,null,null);let Et=b(He==="local"?V:q,ue),Xe=Ke,Ze=Et?$t(Et,He==="local"?se:G,He==="local"?V:q):!1,_t=Et&&!Ze&&!Ft(ue,Et);if(_t&&He===en.otherSide)return ze({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),null;if(_t&&ze({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),Et||ze({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:He==="local"?"remote":"local"}),Fe.has(ue)){ze({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue});let ft=me(Xe,He);return ft&&at.set(Ke,ft),ft}ut(ue)&&(lt||=Hr(Ae,Be,q,V,b,B,o,r.remoteWins,O,ze,$,A,w),lt.plan(ue,He,Xe,!0));let tt=ut(ue)?B(ue,He==="local"?Xe:b(q,ue)||null,He==="remote"?Xe:b(V,ue)||null,!1):null;return tt&&(at.set(ue,tt),at.set(Ke,tt),Et&&at.set(Et,tt),He==="local"?Ee({kind:"move",el:tt,source:"local"}):Ge({kind:"move",el:tt,source:"remote"})),tt};for(let ue of en.V.units){if(Tt.has(ue)){if(Qe?.has(ue)){for(let it of Qe.get(ue))wt.has(it)||(Ye.push(it),wt.add(it));continue}let He=at.get(ue);wt.has(He)||(Ye.push(He),wt.add(He));continue}if(re.has(ue)&&!(at.get(ue)&&wt.has(at.get(ue)))){let He=en.V.baseOf(ue);He&&!De.has(He)&&ze({kind:"structure",el:null,detail:"both-moved",base:He},{subject:He});continue}let Ke=or(ue,en.V,en.A,en.side);Ke&&!wt.has(Ke)&&(Ye.push(Ke),wt.add(Ke),!en.V.baseOf(ue)&&!zn.has(ue)&&!Tt.has(ue)&&Wt.add(Ke))}for(let ue of ht)wt.has(ue.frag)||(Ye.splice(ue.previous&&wt.has(ue.previous)?Ye.indexOf(ue.previous)+1:Ir(ue.at),0,ue.frag),wt.add(ue.frag));if(!en.other.asBase){let ue=en.other,Ke=en.otherSide,He=en.otherA,it=null,Et=0,Xe=null;for(let Ze of ue.units){let _t=Mt.get(Ze)||at.get(Ze);if(_t&&wt.has(_t)){it=_t,Xe=null;continue}if(re.has(Ze)){let kt=ue.baseOf(Ze);kt&&!De.has(kt)&&ze({kind:"structure",el:null,detail:"both-moved",base:kt},{subject:kt});continue}let tt=or(Ze,ue,He,Ke);if(!tt)continue;let ft;if(Xe)ft=Ye.indexOf(Xe)+1;else if(it){if(ft=Ye.indexOf(it)+1,Ke==="remote")for(;ft<Ye.length&&Wt.has(Ye[ft]);)ft++}else ft=Et++;Ye.splice(ft,0,tt),wt.add(tt),Xe=tt}}for(let ue=0;ue<Re.length;ue++){let Ke=Re[ue];if(re.has(Ke))continue;let He=mo(Ke);He&&Ye.splice(Ir(ue),0,He)}return et&&zt.length&&bn.length&&Xo(),Ye;function Xo(){if(cn||xn)return;let ue=new Set(Ye),Ke=kt=>kt&&De.has(kt)&&ue.has(at.get(kt))?kt:null,He=(kt,Vt)=>{let Pt=[{prev:null,units:[]}];for(let nn of kt){let Rn=Ke(Vt(nn));Rn?Pt.push({prev:Rn,units:[]}):Pt[Pt.length-1].units.push(nn)}return Pt},it=He(Re,kt=>kt),Et=He(oe.units,oe.baseOf),Xe=fe.asBase?null:He(fe.units,fe.baseOf),Ze=kt=>kt.length===it.length&&kt.every((Vt,Pt)=>Vt.prev===it[Pt].prev);if(!Ze(Et)||Xe&&!Ze(Xe))return;let _t=new Map(zt.map(kt=>[kt.bk,kt])),tt=new Map(bn.map(kt=>[kt.su,kt])),ft=kt=>kt?Ye.indexOf(at.get(kt)):-1;for(let kt=0;kt<it.length;kt++){if(it[kt].units.length!==1||Et[kt].units.length!==1)continue;let Vt=_t.get(it[kt].units[0]),Pt=tt.get(Et[kt].units[0]);if(!Vt||!Pt||Xe&&(Xe[kt].units.length!==1||Xe[kt].units[0]!==Vt.lk))continue;let nn=ft(it[kt].prev);(kt+1<it.length?ft(it[kt+1].prev):Ye.length)-nn!==2||Ye[nn+1]!==Pt.node||po(Vt.bk,Vt.lk,Pt.su)&&et.link(Vt.lk,Pt.node)}}function sr(ue,Ke,He,it){let Et=Pt=>{let nn=Pt.filter(ut);return nn.length===1?nn[0]:null},Xe=Et(ue),Ze=Et(Ke),_t=Et(He);if(!Xe||!Ze||!_t)return;let tt=ue.indexOf(Xe);if(Ke.indexOf(Ze)!==tt||He.indexOf(_t)!==tt||ue.length!==Ke.length||ue.length!==He.length)return;for(let Pt=0;Pt<ue.length;Pt++)if(Pt!==tt&&(ue[Pt].value!==Ke[Pt].value||ue[Pt].value!==He[Pt].value))return;if((fe.asBase?Xe:fe.twin(Xe))!==Ze||oe.twin(Xe)||V.reverse.get(_t)||Ze!==Xe&&$(Xe,Ze,q))return;let ft=it.filter(Pt=>Pt.nodeType===1);if(ft.length!==1||Ae.get(ft[0])?.remote!==_t)return;let kt=Pt=>Pt.map(nn=>ut(nn)?"":nn.value??nn.nodeValue).join(""),Vt=it.indexOf(ft[0]);kt(it.slice(0,Vt))!==kt(ue.slice(0,tt))||kt(it.slice(Vt+1))!==kt(ue.slice(tt+1))||po(Xe,Ze,_t)&&et.link(Ze,ft[0])}function po(ue,Ke,He){if(!ut(Ke)||!ut(He)||!ut(ue)||Ke.namespaceURI!==He.namespaceURI||Ke.localName===He.localName)return!1;for(let Ze of[Ke,He])if(Ze.tagName==="TEMPLATE"||vn(Ze)||Ze.querySelector("template"))return!1;if(r.remoteWins(ue)||r.remoteWins(He)||o(He)||Ke.attributes.length!==He.attributes.length)return!1;for(let Ze of Ke.attributes)if(He.getAttributeNS(Ze.namespaceURI,Ze.localName)!==Ze.value)return!1;let it=Ke.childNodes,Et=He.childNodes;if(it.length!==Et.length)return!1;for(let Ze=0;Ze<it.length;Ze++)if(!it[Ze].isEqualNode(Et[Ze]))return!1;let Xe=[[ue,He]];for(;Xe.length;){let[Ze,_t]=Xe.pop();if(Ze.children.length!==_t.children.length)return!1;for(let tt=0;tt<_t.children.length;tt++){let ft=V.reverse.get(_t.children[tt]);if(ft!==void 0&&ft!==Ze.children[tt])return!1;Xe.push([Ze.children[tt],_t.children[tt]])}}return!0}function Ir(ue){for(let Ke=ue-1;Ke>=0;Ke--){let He=at.get(Re[Ke]);if(He){let it=Ye.indexOf(He);if(it>=0)return it+1}}return 0}function go(){if((fe.asBase||q.identical.has(I))&&(oe.asBase||V.identical.has(I)))return;let ue={ignored:o,remoteWins:r.remoteWins,inlineCache:Te},Ke=yt=>ut(yt)?Xn(yt,ue):yt.kind==="text";if(!fe.asBase&&!oe.asBase)for(let yt of Re){if(!ut(yt)||!qn.has(yt.tagName))continue;let rt=fe.twin(yt),jt=oe.twin(yt);if(!rt&&jt||rt&&!jt){let ct=ja({base:Re,views:[{V:fe,A:q,idOf:g.local},{V:oe,A:V,idOf:g.remote}],eligible:Lt=>ut(Lt)&&qn.has(Lt.tagName)&&!o(Lt)&&!r.remoteWins(Lt),baseId:g.base,ignored:o,remoteWins:r.remoteWins,atomKey:i.exactUnitKey});ct&&(fe=ct[0],oe=ct[1]);break}}let He=!fe.asBase&&!oe.asBase&&Re.length>=2&&qn.has(Re[0].tagName)&&fe.units.length===Re.length&&oe.units.length===Re.length?ba({base:Re,local:fe.units,remote:oe.units,localTwin:fe.twin,remoteTwin:oe.twin,eligible:yt=>ut(yt)&&qn.has(yt.tagName)&&!o(yt)&&!r.remoteWins(yt),nodes:{base:Array.from(we(I).childNodes),local:Array.from(we(fe.el).childNodes),remote:Array.from(we(oe.el).childNodes)}}):null,it=null,Et=null;if(!He&&!fe.asBase&&!oe.asBase&&(Pi(Re)||Pi(fe.units)||Pi(oe.units))){let yt={ignored:o,remoteWins:()=>!1},rt=ct=>Ke(ct)||ut(ct)&&r.remoteWins(ct)&&Cn.has(ct.tagName)&&Xn(ct,yt),jt=ct=>ut(ct)?qn.has(ct.tagName)&&!o(ct)&&!r.remoteWins(ct)&&l(ct).every(rt):ct.kind==="text";it=Da({onUncertainOwner:ct=>{let Lt=r.identity.local(ct.local);Lt&&Lt===r.identity.remote(ct.remote)||(Et||=[]).push(ct)},onUncertainSource:ct=>{ot||(ot=new Map);let Lt=ot.get(ct.source);Lt||ot.set(ct.source,Lt=[]);for(let tn of Lt)if(tn.side===ct.side&&tn.from===ct.from&&tn.to===ct.to)return;Lt.push(ct)},base:Re,views:[{V:fe,A:q,idOf:g.local},{V:oe,A:V,idOf:g.remote}],eligible:jt,ignored:o,remoteWins:r.remoteWins,baseId:g.base,atomKey:i.exactUnitKey})}if(Et){Qe||=new Map;for(let yt of Et){let{source:rt,local:jt,remote:ct}=yt,Lt={map:new Map,reverse:new Map,identical:new Set},tn=ae({base:[rt],local:[jt],remote:[ct],out:ce,policy:"both",L:Lt,R:Lt,ignored:o,remoteWins:r.remoteWins,atomKey:i.exactUnitKey,cloneUnit:me,provenance:Ae,textMappers:Ue,conflicts:O,decisions:Ne,conflict:(Dt,Kt)=>ze(Dt,{...Kt,policy:"both"}),scope:{base:I,local:fe.el,remote:oe.el,units:Re,at:We.get(rt)},node:xe});le.push(...tn.segments);for(let Dt of[rt,jt,ct])re.add(Dt),Tt.add(Dt),Qe.set(Dt,tn.nodes),at.set(Dt,tn.nodes[tn.nodes.length-1]);for(let Dt=0;Dt<tn.nodes.length;Dt++)ht.push({frag:tn.nodes[Dt],at:We.get(rt),previous:Dt?tn.nodes[Dt-1]:null})}}let Xe=He?He.blocks:null;if(it){Xe=new Set;for(let yt of it.blocks)Xe.add(yt)}let Ze=yt=>!pt?.consumes(yt)&&(Xe&&Xe.has(yt)||Ke(yt)),_t=Re.map(Ze);if(!_t.includes(!0))return;let tt=yt=>{let rt=yt.units,jt=new Map;for(let ln=0;ln<rt.length;ln++)jt.set(rt[ln],ln);let ct=[],Lt=-1;for(let ln=0;ln<Re.length;ln++){if(_t[ln])continue;let Nt=yt.twin(Re[ln]),At=Nt?jt.get(Nt):void 0;At===void 0||At<=Lt||Ze(Nt)||(ct.push([ln,At]),Lt=At)}let tn=[],Dt=-1,Kt=-1;for(let ln=0;ln<=ct.length;ln++){let[Nt,At]=ln<ct.length?ct[ln]:[Re.length,rt.length],It={bLo:-1,bHi:-1,from:Kt+1,to:At,inlineStart:-1,inlineEnd:-1,next:At};for(let rn=Dt+1;rn<Nt;rn++)_t[rn]&&(It.bLo<0&&(It.bLo=rn),It.bHi=rn);for(let rn=Kt+1;rn<At;rn++){let lr=rt[rn];Ze(lr)&&(It.inlineStart<0&&(It.inlineStart=rn),It.inlineEnd=rn+1)}tn.push(It),Dt=Nt,Kt=At}return{units:rt,list:tn}},ft=tt(fe),kt=tt(oe),Vt=[];for(let yt of[ft,kt])for(let rt of yt.list)rt.bLo>=0&&Vt.push([rt.bLo,rt.bHi]);Vt.sort((yt,rt)=>yt[0]-rt[0]);let Pt=[];for(let[yt,rt]of Vt){let jt=Pt[Pt.length-1];jt&&yt<=jt.hi?jt.hi=Math.max(jt.hi,rt):Pt.push({lo:yt,hi:rt})}let nn=(yt,rt)=>yt.length===rt.length&&yt.every((jt,ct)=>i.equalUnits(jt,rt[ct])),Rn=yt=>!ut(yt)&&yt.kind==="comment",ir=yt=>{if(!yt.length)return[];let rt=(Dt,Kt)=>ut(Dt)?Dt:Dt.nodes[Kt?Dt.nodes.length-1:0],jt=rt(yt[0]),ct=rt(yt[yt.length-1],!0),Lt=Dt=>Dt&&ut(Dt)&&o(Dt);for(;Lt(jt.previousSibling);)jt=jt.previousSibling;for(;Lt(ct.nextSibling);)ct=ct.nextSibling;let tn=[];for(let Dt=jt;Dt&&(tn.push(Dt),Dt!==ct);Dt=Dt.nextSibling);return tn},Vn=yt=>yt.some(rt=>ut(rt)&&o(rt));for(let yt of Pt){let rt=Re.slice(yt.lo,yt.hi+1),jt=null;if(it)for(let Nt of rt){let At=it.certificatesBySource.get(Nt);At&&(jt||=[]).push(...At)}let ct=fe.asBase?null:Li(ft,yt),Lt=oe.asBase?null:Li(kt,yt);if(jt){let Nt=[new Set(ct||rt),new Set(Lt||rt)],At=jt.some(It=>!Nt[It.side].has(It.target));for(let It of rt)if(Xe.has(It))for(let[rn,lr]of[[0,fe],[1,oe]]){let In=lr.twin(It);In&&lr.here(In)&&!Nt[rn].has(In)&&(At=!0)}if(At)continue}if(rt.some(Rn)||ct&&ct.some(Rn)||Lt&&Lt.some(Rn))continue;let tn=ir(ct||rt),Dt=ir(Lt||rt);if((!ct||nn(rt,ct))&&(!Lt||nn(rt,Lt))&&!(ct&&Vn(tn)))continue;let Kt=ae({base:ir(rt),sourceRetentions:ot?.get(I),local:tn,remote:Dt,out:ce,policy:de,blocks:Xe,scopeUnits:jt?[rt,ct||rt,Lt||rt]:null,certifiedOrigins:jt?(Nt,At,It,rn,lr,In)=>Ba({certificates:jt,scopes:[rt,ct||rt,Lt||rt],flats:[Nt,At,It],keys:[rn,lr,In]}):null,prepared:He?He.prepared:null,nativeTransfers:He,L:ct?q:Fa(q,I),R:Lt?V:Fa(V,I),idOf:{base:p,local:m,remote:y},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(Nt,At,It)=>B(Nt,At,It,!1),cloneUnit:me,mergeAttrs:ie,atomKey:i.exactUnitKey,moveIn:C,moveBuilt:C,movePlanned:C,provenance:Ae,textMappers:Ue,conflicts:O,conflict:ze,scope:{base:I,local:fe.asBase?null:fe.el,remote:oe.asBase?null:oe.el,units:Re,at:yt.lo},decisions:Ne,node:xe});if(!Kt){if(jt){let Nt=ka({certificates:jt,scopes:[rt,ct||rt,Lt||rt],views:[{V:fe,A:q,idOf:g.local},{V:oe,A:V,idOf:g.remote}],eligible:At=>ut(At)&&qn.has(At.tagName)&&!o(At)&&!r.remoteWins(At),baseId:g.base});for(let At of Nt.records){ot||=new Map;let It=ot.get(At.source);It||ot.set(At.source,It=[]),It.push(At)}}continue}if(le.push(...Kt.segments),He){let Nt=new Map;for(let At of Kt.nodes){let It=Ae.get(At)?.base;if(!It||Nt.has(It))throw new Error("Invalid native transfer owner output");Nt.set(It,At)}if(Nt.size!==He.owners.length)throw new Error("Incomplete native transfer owner output");for(let At of He.owners){let It=Nt.get(At.base);if(!It)throw new Error("Missing native transfer owner output");for(let rn of[At.base,At.local,At.remote])re.add(rn),Tt.add(rn),at.set(rn,It);ht.push({frag:It,at:We.get(At.base)})}continue}if(et&&sr(rt,ct||rt,Lt||rt,Kt.nodes),Kt.unitOutputs){Qe||=new Map;for(let At of[...rt,...ct||[],...Lt||[]]){let It=Kt.unitOutputs.get(At)||[];re.add(At),Tt.add(At),Qe.set(At,It),It.length&&at.set(At,It[It.length-1])}let Nt=Kt.nodes[Kt.nodes.length-1];if(Nt)for(let At of[ct||rt,Lt||rt]){let It=At[At.length-1];It&&Mt.set(It,Nt)}for(let At=0;At<Kt.nodes.length;At++)ht.push({frag:Kt.nodes[At],at:yt.lo,previous:At>0?Kt.nodes[At-1]:null});continue}et&&sr(rt,ct||rt,Lt||rt,Kt.nodes);let ln=ce.createDocumentFragment();for(let Nt of Kt.nodes)ln.appendChild(Nt);for(let Nt of[...rt,...ct||[],...Lt||[]])re.add(Nt),Tt.add(Nt),at.set(Nt,ln);ht.push({frag:ln,at:yt.lo})}}}function te(I,G){let se=Ae.get(I);return se&&se.unchanged?!se.remote||se.remote===G?!0:W(se.remote,G):I.tagName!==G.tagName||!Ie(I,G)?!1:je(we(I),we(G))}function W(I,G){return I===G?!0:I.tagName!==G.tagName||I.namespaceURI!==G.namespaceURI||!Ie(I,G)?!1:ne(we(I),we(G))}function ne(I,G){let se=Se(I,o),be=Se(G,o);if(se.length!==be.length)return!1;for(let xe=0;xe<se.length;xe++){let fe=se[xe],oe=be[xe];if(typeof fe=="string"||typeof oe=="string"){if(fe!==oe)return!1}else{if(fe.nodeType!==oe.nodeType)return!1;if(fe.nodeType===1){if(!W(fe,oe))return!1}else if(fe.nodeValue!==oe.nodeValue)return!1}}return!0}function we(I){return I.tagName==="TEMPLATE"&&I.content?I.content:I}function Ie(I,G){let se=0;for(let be of I.attributes)if(!r.ignoreAttribute(I,be.name)&&(se++,G.getAttribute(be.name)!==be.value))return!1;for(let be of G.attributes)r.ignoreAttribute(G,be.name)||se--;return se===0}function je(I,G){let se=Se(I,xe=>{let fe=Ae.get(xe);return!!(fe&&fe.pinned)}),be=Se(G,o);if(se.length!==be.length)return!1;for(let xe=0;xe<se.length;xe++){let fe=se[xe],oe=be[xe];if(typeof fe=="string"||typeof oe=="string"){if(fe!==oe)return!1}else{if(fe.nodeType!==oe.nodeType)return!1;if(fe.nodeType===1){if(!te(fe,oe))return!1}else if(fe.nodeValue!==oe.nodeValue)return!1}}return!0}function Se(I,G){let se=[],be=null;for(let xe=I.firstChild;xe;xe=xe.nextSibling){if(xe.nodeType===3){be=be===null?xe.nodeValue:be+xe.nodeValue;continue}xe.nodeType===1&&G(xe)||(be!==null&&(be!==""&&se.push(be),be=null),se.push(xe))}return be!==null&&be!==""&&se.push(be),se}function Je(I,G,se,be){let xe=I.value,fe=be?xe:G?G.value:"",oe=se?se.value:"";re.add(I),G&&re.add(G),se&&re.add(se);let Re=fe===oe?fe:fe===xe?oe:oe===xe||de==="local"?fe:oe,De={site:"comment",bRun:I,lRun:G,rRun:se,node:null};if(fe!==xe&&oe!==xe&&fe!==oe&&ze({kind:"text",node:null,base:xe,local:fe,remote:oe,resolved:Re},De),!G&&!se)return null;let We=ce.createComment(Re);return De.node=We,Ae.set(We,{base:I.nodes,local:G?G.nodes:null,remote:se?se.nodes:null}),We}function nt(I,G){let se=b(G,I);if(!se)return null;let be=ut(se)?se.parentNode:se.parent,xe=ut(I)?I.parentNode:I.parent;return b(G,xe)===be?null:G.reverse.get(be)||null}function st(I){let G=new Set([I]),se=I;for(let be=0;be<64;be++){let xe=nt(se,q)||nt(se,V);if(!xe)return!1;if(xe===I||ut(I)&&ut(xe)&&I.contains(xe)||G.has(xe))return!0;G.add(xe),se=xe}return!0}function $t(I,G,se){if(!G)return!1;let be=ut(I)?I.parentNode:I.parent;return be===G||G.tagName==="TEMPLATE"&&be===G.content}function Ft(I,G){let se=Be(I),be=b(q,se);if(be&&$t(G,be,q))return!0;let xe=b(V,se);return!!(xe&&$t(G,xe,V))}}function Fa(e,t){return e.map.get(t)?qa():{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 qa(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Ua=new Set(["INPUT","OPTION","TEXTAREA"]),Di=/[\t\n\f\r ]+/;function $a(e,t,n,r){let o=e.ownerDocument,{provenance:s,textMappers:i}=n,l=r.hooks,a=[],c=[],h=[],u=new Set,f=[],p=[],m=new Map,y=new Set,g=new Map,d=n.conflicts.length>0||r.trackInserted===!0,k=new Map,A=new Set,w=new Map,v=(b,C)=>{let L=w.get(b);L||w.set(b,L=new Set),L.add(C)},E=d?new Set:null,N=(b,C,L)=>{let $=l.beforeAttributeUpdated(b,C,L);return d&&$===!1&&v(C,b),$},_=b=>!!b&&(b===e||e.contains(b)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(b)),M=new Map,j=new Map,R=new Map,D=new Set,F=new Map;(function b(C){let L=s.get(C);if(L){if(C.nodeType===1){let Q=L.local?r.toLive(L.local):null;Q&&_(Q)&&Q.nodeType===1&&(M.set(C,Q),j.set(Q,C))}else if(Array.isArray(L.local)){let Q=V(L.local,L.local.map(B=>r.toLive(B)).filter(B=>B&&_(B)&&B.nodeType===C.nodeType));if(Q.length&&(M.set(C,Q[0]),j.set(Q[0],C),R.set(C,Q)),Array.isArray(L.caret))for(let B of L.caret){let he=r.toLive(B.node);if(!he||!_(he)||he.nodeType!==3)continue;let ye=F.get(he);Array.isArray(ye)||F.set(he,ye=[]),ye.push({merged:C,from:B.from,to:B.to,flatStart:B.flatStart})}else{let B=0;for(let he of Q)F.set(he,{merged:C,shift:B}),B+=he.nodeValue.length}}}let $=C.nodeType===1&&C.tagName==="TEMPLATE"&&C.content?C.content.childNodes:C.childNodes;for(let Q of $)b(Q)})(t);let S=new Set;for(let b of M.values())S.add(b);for(let b of R.values())for(let C of b)S.add(C);let T=r.localRoot&&r.localRoot!==e?new Set:null;if(T){for(let b=r.localRoot.firstElementChild;b;b=b.nextElementSibling)if(b.tagName==="HEAD")for(let C=b.firstElementChild;C;C=C.nextElementSibling){let L=r.toLive(C);L&&T.add(L)}}for(let b of n.segments||[])Ce(b);let J=r.restoreFocus===!1?null:Dd(o,F);r.childrenOnly?Ae(Me(e),Me(t)):Be(e,t);for(let{node:b,parent:C}of f)u.has(b)||!b.parentNode||b.nodeType===1&&(r.ignored(b)||Ue(b))||ot(b,C);return Bd(o,J,F,i,R,g,D),{applied:a,moved:c,replaced:h,identities:p,mergedScriptsLive:y,liveOf:M,heldBy:g,runOf:R,keptRuns:D,insertedLive:k,vetoed:A,vetoedAttrs:w,removedVetoes:E};function q(b,C){let L=b.slice(C.bs,C.be),$=0;for(;$<L.length&&$<C.text.length&&L[$]===C.text[$];)$++;let Q=0;for(;Q<L.length-$&&Q<C.text.length-$&&L[L.length-1-Q]===C.text[C.text.length-1-Q];)Q++;return{bs:C.bs+$,be:C.be-Q,text:C.text.slice($,C.text.length-Q)}}function V(b,C){if(!C.length)return C;let L=[];for(let B of b){let he=B.parentNode;if(!he)continue;let ye=m.get(he);if(!ye){ye=new Set;for(let ie=he.firstChild;ie;ie=ie.nextSibling)ie.nodeType===3&&ye.add(r.toLive(ie));m.set(he,ye)}L.includes(ye)||L.push(ye)}let $={has:B=>L.some(he=>he.has(B))},Q=[];for(let B of C){Q.push(B);for(let he=B.nextSibling;he&&he.nodeType===3&&!$.has(he)&&!Q.includes(he);he=he.nextSibling)Q.push(he)}return Q}function Ce(b){let C=[];for(let ee of b.localNodes){let te=r.toLive(ee.node);if(!te||!_(te)||te.nodeType!==3)return;C.push(te)}let L=V(b.localNodes.map(ee=>ee.node),C);if(!L.length)return;let $=L.map(ee=>ee.nodeValue).join(""),{flatLocal:Q,lToM:B,mapLocal:he}=b;if($===Q)return;let ye=b.textNodes.map(ee=>({node:ee.node,ms:ee.ms,me:ee.me})),ie=[],_e=0;for(let ee of L)ie.push(_e),_e+=ee.nodeValue.length;let U=(ee,te)=>L.find((W,ne)=>ie[ne]<=ee&&ee+te<=ie[ne]+W.nodeValue.length)||null,Y=[],pe=0;for(let ee of vr(Q,$).map(te=>q(Q,te))){let te=ee.bs+pe;pe+=ee.text.length-(ee.be-ee.bs);let W,ne;if(ee.be>ee.bs){W=B[ee.bs];let we=W>=0;for(let Ie=ee.bs;we&&Ie<ee.be;Ie++)B[Ie]!==W+(Ie-ee.bs)&&(we=!1);if(!we)continue;ne=W+(ee.be-ee.bs)}else{let we=ee.bs>0?B[ee.bs-1]:0,Ie=ee.bs<Q.length?B[ee.bs]:0;if(we<0||Ie<0)continue;W=ne=he(ee.bs)}Y.push({ms:W,me:ne,text:ee.text,live:ne===W?U(te,ee.text.length):null})}Y.sort((ee,te)=>te.ms-ee.ms);let ke=(ee,te)=>(R.get(ee.node)||[M.get(ee.node)]).includes(te),me=ee=>!!ee&&ee.nodeType===1&&Cn.has(ee.tagName);for(let ee of Y){let te=ye.find(ne=>ne.ms<=ee.ms&&ee.me<=ne.me&&ee.ms<ne.me);if(te&&ee.live&&te.ms===ee.ms&&!ke(te,ee.live)){let ne=ye.find(we=>we.me===ee.ms&&ke(we,ee.live));ne&&(te=ne)}if(!te&&ee.me===ee.ms){let ne=ye.find(Se=>Se.me===ee.ms),we=ye.find(Se=>Se.ms===ee.ms),Ie=ne||we;if(!Ie)continue;let je=Ie.node;for(;me(je.parentNode)&&(ne?je.parentNode.lastChild:je.parentNode.firstChild)===je;)je=je.parentNode;if(je===Ie.node)te=Ie;else{let Se=je.ownerDocument.createTextNode(ee.text);je.parentNode.insertBefore(Se,ne?je.nextSibling:je);continue}}if(!te)continue;let W=te.node.nodeValue;te.node.nodeValue=W.slice(0,ee.ms-te.ms)+ee.text+W.slice(ee.me-te.ms),te.me+=ee.text.length-(ee.me-ee.ms)}}function Me(b){return b.nodeType===1&&b.tagName==="TEMPLATE"&&b.content?b.content:b}function Be(b,C){u.add(b);let L=s.get(C);if(L&&L.remote&&n.remoteIdOf){let Q=n.remoteIdOf(L.remote);Q&&p.push([b,Q])}if(L&&L.unchanged){r.opaque&&r.opaque(b)||(n.customIdentity&&L.remote&&le(b,L.remote),L.remote&&X(b,L.remote));return}if(l.beforeNodeMorphed(b,C)===!1){A.add(C);return}Ve(b,C,r.keepLiveOnly&&L&&L.local&&L.local.nodeType===1&&L.local!==b?L.local:null);let $=b.tagName;if(vn(b))b.textContent!==C.textContent&&(a.push({kind:"text",node:b,before:b.textContent,after:C.textContent}),b.textContent=C.textContent),n.mergedScripts.has(C)&&y.add(b);else if($==="TEXTAREA")K(b,C,L);else{Yt(b,C,L);let Q=$==="TEMPLATE"&&b.content?b.content:b,B=$==="TEMPLATE"&&C.content?C.content:C;r.opaque&&r.opaque(b)||r.protectFocusedValue==="subtree"&<(b)&&b!==o.body?ce(Q):Ae(Q,B)}l.afterNodeMorphed(b,C)}function ce(b){for(let C=b.firstChild;C;C=C.nextSibling){let L=j.get(C);L&&M.get(L.parentNode)!==b||(u.add(C),C.nodeType===1&&ce(C))}}function Ae(b,C){let L=Fe(b.firstChild),$=new Set;for(let Q of Array.from(C.childNodes)){let B=M.get(Q);B&&u.has(B)&&!$.has(B)&&(B=null);let he=s.get(Q);if(he&&he.pinned){B&&B.nodeType===1&&((B.parentNode!==b||Fe(B.nextSibling)!==L)&&Te(b,B,L),u.add(B),$.add(B));continue}if(B&&B.nodeType===1){if(B!==L){let _e=B.parentNode;if(_e===b&&L&&pt(B)){let U=B.nextSibling;for(let Y=L;Y&&Y!==B;){let pe=Y.nextSibling;Te(b,Y,U),Y=pe}}else Te(b,B,L),_e!==b&&(c.push(B),a.push({kind:"move",el:B,from:_e,to:b}))}$.add(B),Be(B,Q),L=Fe(B.nextSibling);continue}if(B&&B.nodeType!==1){let _e=R.get(Q)||[B],U=_e.map(pe=>pe.nodeValue).join(""),Y=Q.nodeValue;if(Q.nodeType===3){let pe=Ne(Q);pe!=null&&U!==pe&&(Y=ko(pe,U,Q.nodeValue).text)}if(_e.length>1&&U===Y&&!_e.includes(L,1)&&_e.every((pe,ke)=>pe.parentNode===b&&(ke===0||_e[ke-1].nextSibling===pe))){if(B!==L)for(let pe of _e)Te(b,pe,L);l.beforeNodeMorphed(B,Q)!==!1?l.afterNodeMorphed(B,Q):d&&A.add(Q);for(let pe of _e)u.add(pe),$.add(pe);g.set(Q,B),D.add(Q),L=Fe(_e[_e.length-1].nextSibling);continue}B!==L&&Te(b,B,L),l.beforeNodeMorphed(B,Q)!==!1?(B.nodeValue!==Y&&(a.push({kind:"text",node:B,before:B.nodeValue,after:Y}),B.nodeValue=Y),l.afterNodeMorphed(B,Q)):A.add(Q),u.add(B),$.add(B),g.set(Q,B),L=Fe(B.nextSibling);continue}if(Q.nodeType===3&&L&&L.nodeType===3&&!u.has(L)&&!F.has(L)){L.nodeValue!==Q.nodeValue&&(a.push({kind:"text",node:L,before:L.nodeValue,after:Q.nodeValue}),L.nodeValue=Q.nodeValue),u.add(L),g.set(Q,L),L=Fe(L.nextSibling);continue}let ye=s.get(Q),ie=et(ye&&ye.unchanged&&ye.remote?ye.remote:Q);if(l.beforeNodeAdded(ie)===!1){A.add(Q);continue}b.insertBefore(ie,L),u.add(ie),d&&k.set(Q,ie),ie.nodeType===3&&g.set(Q,ie),ie.nodeType===1&&(h.push(ie),Pe(ie,Q),n.customIdentity&&ye&&ye.unchanged&&ye.remote&&le(ie,ye.remote),vn(ie)||ae(ie,Q),r.formState==="property"&&Qt(ye)&&X(ie,ye.remote)),L=Fe(ie.nextSibling),a.push({kind:"insert",node:ie,parent:b}),l.afterNodeAdded(ie)}for(let Q of Array.from(b.childNodes))u.has(Q)||$.has(Q)||Q.nodeType===1&&(r.ignored(Q)||Ue(Q))||(S.has(Q)?f.push({node:Q,parent:b}):ot(Q,b))}function Ue(b){return b.parentNode&&b.parentNode.nodeType===1&&b.parentNode.tagName==="HEAD"&&(T&&!T.has(b)||r.preserve&&r.preserve(b)===!0)}function Ne(b){let C=s.get(b);return!C||!Array.isArray(C.local)?null:C.local.map(L=>L.nodeValue).join("")}function O(b){return s.get(b)}function X(b,C){if(!Ua.has(b.tagName)&&!b.querySelector("input,option,textarea"))return;let L=($,Q)=>{if($.tagName!==Q.tagName||($.tagName==="TEXTAREA"?K($,Q,{remote:Q}):Ua.has($.tagName)&&Yt($,Q,{remote:Q}),r.opaque&&r.opaque($)))return;let B=re($),he=re(Q);if(B.length===he.length)for(let ye=0;ye<B.length;ye++)L(B[ye],he[ye])};L(b,C)}function le(b,C){if(r.opaque&&r.opaque(b))return;let L=re(b),$=re(C);if(L.length===$.length)for(let Q=0;Q<L.length;Q++){let B=n.remoteIdOf($[Q]);B&&p.push([L[Q],B]),le(L[Q],$[Q])}}function re(b){let C=b.tagName==="TEMPLATE"&&b.content?b.content:b;return Array.from(C.children).filter(L=>!r.ignored(L))}function Pe(b,C){if(!n.remoteIdOf)return;let L=($,Q)=>{let B=s.get(Q);if(B&&B.remote&&Q.nodeType===1){let ie=n.remoteIdOf(B.remote);ie&&p.push([$,ie])}let he=$.childNodes,ye=Q.childNodes;for(let ie=0;ie<he.length&&ie<ye.length;ie++)L(he[ie],ye[ie])};L(b,C)}function Fe(b){for(;b&&b.nodeType===1&&r.ignored(b);)b=b.nextSibling;return b}function Te(b,C,L){if(typeof b.moveBefore=="function"&&C.ownerDocument===b.ownerDocument)try{b.moveBefore(C,L);return}catch{}b.insertBefore(C,L)}function ot(b,C){if(l.beforeNodeRemoved(b)===!1){d&&E.add(b);return}b.parentNode.removeChild(b),a.push({kind:"remove",node:b,parent:C}),l.afterNodeRemoved(b)}function et(b){if(vn(b))return vo(b,o);let C=o.importNode(b,!0);if(C.nodeType===1)for(let L of Array.from(C.querySelectorAll("script")))vn(L)&&L.replaceWith(vo(L,o));return C}function ae(b,C){let L=b.tagName==="TEMPLATE"&&b.content?b.content:b,$=C.tagName==="TEMPLATE"&&C.content?C.content:C,Q=Array.from(L.childNodes),B=Array.from($.childNodes);for(let he=0;he<B.length&&he<Q.length;he++){let ye=B[he],ie=Q[he],_e=M.get(ye);_e&&u.has(_e)&&(_e=null);let U=s.get(ye);if(U&&U.pinned){if(_e&&_e.nodeType===1){let Y=_e.parentNode;Te(L,_e,ie),Y!==L&&(c.push(_e),a.push({kind:"move",el:_e,from:Y,to:L})),u.add(_e)}ie.remove();continue}if(_e){let Y=_e.parentNode;Te(L,_e,ie),ie.remove(),_e.nodeType===1?(Y!==L&&(c.push(_e),a.push({kind:"move",el:_e,from:Y,to:L})),Be(_e,ye)):(u.add(_e),g.set(ye,_e),_e.nodeValue!==ye.nodeValue&&(a.push({kind:"text",node:_e,before:_e.nodeValue,after:ye.nodeValue}),_e.nodeValue=ye.nodeValue));continue}u.add(ie),d&&k.set(ye,ie),ie.nodeType===3&&g.set(ye,ie),U&&U.unchanged&&U.remote?(de(ie,U.remote),n.customIdentity&&le(ie,U.remote)):ye.nodeType===1&&!vn(ye)&&ae(ie,ye)}}function de(b,C){let L=b.tagName==="TEMPLATE"&&b.content?b.content:b,$=C.tagName==="TEMPLATE"&&C.content?C.content:C;for(let Q of Array.from($.childNodes))L.appendChild(et(Q))}function Ee(b,C){return C.namespaceURI?b.getAttributeNS(C.namespaceURI,C.localName):b.getAttribute(C.name)}function Ge(b,C){let L=new Set((C||"").split(Di).filter(Boolean));return(b||"").split(Di).filter($=>$&&!L.has($))}function Ve(b,C,L){for(let $ of Array.from(C.attributes)){if(ze(b,$.name)||r.ignoreAttribute(b,$.name,C))continue;let Q=Ee(b,$);if(Q===$.value||L&&Ee(L,$)===$.value)continue;let B=$.value;if(L&&$.name==="class"&&!$.namespaceURI){let he=$.value.split(Di).filter(Boolean),ye=Ge(Q,L.getAttribute("class")).filter(ie=>!he.includes(ie));ye.length&&(B=[...he,...ye].join(" "))}if(Q!==B){if(l.beforeAttributeUpdated($.name,b,"update")===!1){d&&v(C,$.name);continue}$.namespaceURI?b.setAttributeNS($.namespaceURI,$.name,B):b.setAttribute($.name,B),a.push({kind:"attr",el:b,name:$.name,before:Q,after:B})}}for(let $ of Array.from(b.attributes)){if(ze(b,$.name)||r.ignoreAttribute(b,$.name,C)||($.namespaceURI?C.hasAttributeNS($.namespaceURI,$.localName):C.hasAttribute($.name)))continue;if(L&&$.name==="class"&&!$.namespaceURI){let he=Ge($.value,L.getAttribute("class"));if(he.length){let ye=he.join(" ");if(ye===$.value)continue;if(l.beforeAttributeUpdated("class",b,"update")===!1){d&&v(C,"class");continue}b.setAttribute("class",ye),a.push({kind:"attr",el:b,name:"class",before:$.value,after:ye});continue}}if(L&&Ee(L,$)===null)continue;if(l.beforeAttributeUpdated($.name,b,"remove")===!1){d&&v(C,$.name);continue}let B=$.value;$.namespaceURI?b.removeAttributeNS($.namespaceURI,$.localName):b.removeAttribute($.name),a.push({kind:"attr",el:b,name:$.name,before:B,after:null})}}function ze(b,C){let L=b.tagName;return L==="INPUT"?C==="value"||C==="checked"||C==="disabled":L==="OPTION"?C==="selected":!1}function lt(b){return b===o.activeElement}function pt(b){let C=o.activeElement;return!!C&&C!==o.body&&b.contains(C)}function Rt(b,C){let L=C&&C.local&&C.local.nodeType===1&&C.local!==b?C.local:null;if(!L)return!0;let $=b.tagName==="TEXTAREA"?L.textContent:L.getAttribute("value")??"";return b.value!==$}function dt(b,C){return!!r.protectFocusedValue&<(b)&&Rt(b,C)}function vt(b,C,L){let $=Math.min(b.length,C.length),Q=0;for(;Q<$&&b[Q]===C[Q];)Q++;if(L<=Q)return L;let B=0;for(;B<$-Q&&b[b.length-1-B]===C[C.length-1-B];)B++;return L>=b.length-B?L+C.length-b.length:C.length-B}function gt(b){try{return b.selectionStart==null?null:[b.selectionStart,b.selectionEnd,b.selectionDirection]}catch{return null}}function yn(b,C,L,$){try{b.setSelectionRange(vt(C,L,$[0]),vt(C,L,$[1]),$[2]||"none")}catch{}}function Bt(b,C){let L=b.value,$=gt(b);b.value=C,$&&yn(b,L,C,$)}function Qt(b){let C=b&&b.remote;return C&&C.nodeType===1?C:null}function Yt(b,C,L){let $=b.tagName,Q=Qt(L),B=r.formState==="property"&&Q?Q:C;if($==="INPUT"){let he=dt(b,L),ye=(b.getAttribute("type")||"").toLowerCase(),ie=ye!=="file"&&ye!=="checkbox"&&ye!=="radio",_e=Q&&Q.hasAttribute("value")&&Q.value!==Q.getAttribute("value")?Q.value:null;if(ie&&!he)if(r.formState==="property"){let U=C.getAttribute("value"),Y=b.getAttribute("value");(Y!==U||b.value!==B.value)&&N("value",b,U==null?"remove":"update")!==!1&&(Y!==U&&(U==null?b.removeAttribute("value"):b.setAttribute("value",U),a.push({kind:"attr",el:b,name:"value",before:Y,after:U})),b.value!==B.value&&(lt(b)?Bt(b,B.value):b.value=B.value))}else if(C.hasAttribute("value")||_e!=null){let U=_e??C.getAttribute("value");b.getAttribute("value")!==U&&N("value",b,"update")!==!1?(b.setAttribute("value",U),b.value!==U&&(lt(b)?Bt(b,U):b.value=U),a.push({kind:"attr",el:b,name:"value",before:null,after:U})):b.value!==U&&b.getAttribute("value")===U&&(lt(b)?Bt(b,U):b.value=U)}else(b.hasAttribute("value")||b.value!=="")&&N("value",b,"remove")!==!1&&(b.removeAttribute("value"),b.value="",a.push({kind:"attr",el:b,name:"value",before:"",after:null}));if(!ie&&ye!=="file"){let U=C.getAttribute("value");U==null?b.hasAttribute("value")&&N("value",b,"remove")!==!1&&b.removeAttribute("value"):b.getAttribute("value")!==U&&N("value",b,"update")!==!1&&b.setAttribute("value",U)}r.protectFocusedValue&<(b)||(gn(b,B,"checked"),r.formState==="property"&&b.indeterminate!==B.indeterminate&&(b.indeterminate=B.indeterminate)),gn(b,B,"disabled")}else if($==="OPTION"){let he=b.parentNode&&b.closest("select");r.protectFocusedValue&&he&<(he)||gn(b,B,"selected")}}function gn(b,C,L){if(r.ignoreAttribute(b,L,C))return;let $=r.formState==="property"?!!C[L]:C.hasAttribute(L);if(r.formState!=="property"){let Q=b.hasAttribute(L);if(Q!==$){if(N(L,b,$?"update":"remove")===!1)return;$?b.setAttribute(L,""):b.removeAttribute(L),a.push({kind:"attr",el:b,name:L,before:Q?"":null,after:$?"":null})}}b[L]!==$&&(b[L]=$)}function K(b,C,L){if(dt(b,L)||N("value",b,"update")===!1)return;let $=Qt(L),Q=C.textContent,B=$&&$.value!==$.defaultValue?$.value:Q,he=lt(b)?gt(b):null,ye=b.value;r.formState!=="property"&&b.textContent!==Q&&(a.push({kind:"text",node:b,before:b.textContent,after:Q}),b.textContent=Q),b.value!==B&&(b.value=B),he&&b.value!==ye&&yn(b,ye,b.value,he)}}function Dd(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 Bd(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=(u,f)=>{let p=n.get(u);if(Array.isArray(p)){let m=p.find(k=>f>=k.from&&f<k.to)||p.find(k=>f===k.to)||p[p.length-1],y=s.get(m.merged);if(!y||!y.isConnected)return null;let g=r.get(m.merged),d=g&&g.flat?g.flat(m.flatStart+f):f;return[y,Math.max(0,Math.min(d,y.nodeValue.length))]}if(p&&!i.has(p.merged)){let m=(o.get(p.merged)||[u])[0];if(!m.isConnected)return null;let y=r.get(p.merged),g=p.shift+f,d=y?y(g):g;return[m,Math.max(0,Math.min(d,m.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 Fd={compared:0},qd=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Ud(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 Bi(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 Ha(e,t,n,r,o,s,i,l){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 i||t.querySelectorAll("*"))h(u);for(let u of c)a.delete(u),l.add(u);return a}function za(e,t,n,r,o,s){let i=!1;for(let h of o)h.startsWith("merge:")&&(i=!0);if(!i)return[...r];let l=new Map,a=[],c=s===_n?So:"*";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=(l.get(u)||0)+1;l.set(u,f),f===2&&a.push(u)}return a}function Va({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(!Ud(e,t,o.ignoreAttribute))return{bail:"root-attrs"};let{ignored:l,remoteWins:a}=o,c=ji(o.scripts.merge===!1?null:o.scripts.mergeTags,i),h=Ne=>{let O=c(Ne);return O!==null?O:s.base(Ne)||null},u=Ne=>{let O=c(Ne);return O!==null?O:s.remote(Ne)||null},f=[],p=[],m=new Map,y=new Map,g={same:m,differ:y},d=Ne=>({bail:Ne,comparisons:g}),k=(Ne,O,X=!0)=>{if(m.get(Ne)===O)return!0;if(y.get(Ne)===O)return!1;if(Fd.compared++,X&&Ne.isEqualNode(O))return m.set(Ne,O),!0;let le=Ne.nodeType===O.nodeType;if(le&&Ne.nodeType===1){if(le=Bi(Ne,O),le){let re=Ne.firstChild,Pe=O.firstChild;for(;re&&Pe;re=re.nextSibling,Pe=Pe.nextSibling)if(!k(re,Pe,!1)){le=!1;break}(re||Pe)&&(le=!1)}}else le&&(le=Ne.isEqualNode(O));return(le?m:y).set(Ne,O),le},A=e,w=t,v=!1,E=()=>{m.set(A,w);for(let Ne=0;Ne<f.length;Ne++)m.set(f[Ne],p[Ne]);return d("equal")};for(;;){let Ne=A.childNodes,O=w.childNodes;if(Ne.length!==O.length)break;let X=et=>k(Ne[et],O[et])?(m.set(Ne[et],O[et]),!1):!0,le=-1,re=-1;for(let et=0;et<Ne.length;et++){if(Ne[et].nodeType!==1)continue;let ae=0;for(let de=Ne[et].firstElementChild;de;de=de.nextElementSibling)ae++;ae>=re&&(re=ae,le=et)}let Pe=[],Fe=!1;for(let et=0;et<Ne.length&&Pe.length<2;et++)et!==le&&X(et)&&Pe.push(et);if(le>=0&&Pe.length<2&&(Pe.length===0&&Bi(A,w)?(Pe.push(le),Fe=!0):X(le)&&Pe.push(le)),Pe.length!==1){if(!v&&Pe.length===0&&Bi(A,w))return E();break}let Te=Ne[Pe[0]],ot=O[Pe[0]];if(v=v||!Fe,v&&y.set(Te,ot),Te.nodeType!==1||ot.nodeType!==1||Te.tagName!==ot.tagName)break;if(h(Te)!==u(ot)){if(!v&&k(Te,ot))return E();break}f.push(A),p.push(w),A=Te,w=ot}y.set(A,w);for(let Ne=0;Ne<f.length;Ne++)y.set(f[Ne],p[Ne]);if(A===e||A.tagName==="HEAD"||A.tagName==="BODY")return d("root-level");if(f.length<2||f[1].tagName!=="BODY")return d("not-in-body");if(l(A)||l(w))return d("ignored-ancestor");if(a(A)||a(w))return d("remote-wins-ancestor");for(let Ne of f)if(qd.has(Ne.tagName))return d("form-ancestor");if(A.tagName==="SCRIPT"||A.getElementsByTagName("script").length||w.getElementsByTagName("script").length)return d("script-or-template");let N=r(A);if(!N||N.nodeType!==1||N.tagName!==A.tagName)return d("no-live-twin");if(!n.contains(N))return d("live-detached");for(let Ne of f){let O=r(Ne);if(!O||O.nodeType!==1)return d("ancestor-live")}let _=s.base===_n&&s.remote===_n&&l===ii,M=new Set,j=new Set,R=[],D=null,F=Ne=>{Ne&&(M.has(Ne)?j.add(Ne):M.add(Ne))},S=(Ne,O)=>{let X=c(Ne),le=X!==null?X:s.base(Ne)||null;return le!==(X!==null?X:s.remote(O)||null)?!1:(F(le),!0)},T=(Ne,O)=>{for(let X=Ne.firstElementChild,le=O.firstElementChild;X;X=X.nextElementSibling,le=le.nextElementSibling){let re=l(X);if(re!==l(le))return!1;if(!re&&(!S(X,le)||!T(X,le)))return!1}return!0},J=Ne=>{let O=Ne+1<f.length?f[Ne+1]:A;for(let X=f[Ne].firstElementChild,le=p[Ne].firstElementChild;X;X=X.nextElementSibling,le=le.nextElementSibling){if(X===O){let Fe=Ne+1<f.length?J(Ne+1):null;if(Fe)return Fe;continue}let re=l(X);if(re!==l(le))return"outside-id-changed";if(re)continue;let Pe=r(X);if(!Pe||Pe.nodeType!==1)return"sibling-live";if(R.push([X,le]),!_&&(!S(X,le)||!T(X,le)))return"outside-id-changed";Ne===0&&X.tagName==="HEAD"&&h(X)&&(D=[X,le])}return null},q=J(0);if(q)return d(q);let V=new Set(f),Ce=null;if(s.base===_n){Ce=[];for(let Ne of e.querySelectorAll(So))Ne===A||V.has(Ne)||(A.contains(Ne)?Ce.push(Ne):_&&F(h(Ne)))}let Me=new Set,Be=new Set,ce=new Set,Ae=Ha(f,A,h,l,M,Me,Ce,Be),Ue=Ha(p,w,u,l,M,Me,s.remote===_n&&w.querySelectorAll(So),ce);return D&&(j.has(h(D[0]))||Me.has(h(D[0])))&&(D=null),{scope:{chain:f,root:A,onChain:V,baseIndex:Ae,remoteIndex:Ue,baseDropped:Be,remoteDropped:ce,head:D,same:m,differ:y,dropped:[...za(e,h,l,j,Be,s.base),...za(t,u,l,j,ce,s.remote)],held:Ne=>{for(let O=1;O<f.length;O++)if(Ne.map.get(f[O])!==p[O])return!1;for(let[O,X]of R)if(Ne.map.get(O)!==X)return!1;return!0}}}}var ik=Symbol("hyper-morph-duplicate-key");var $d='[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"]',Hd='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',zd='[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=Kd(e,t,r)),!!o)return n?Array.from(o.childNodes):o}function Kd(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=qr(a,n);c&&!o.has(c.key)&&o.set(c.key,a.textContent)}if(!o.size)return null;let i=e.cloneNode(!0),l=!1;for(let a of[i,...i.querySelectorAll("script")]){let c=qr(a,n);c&&o.has(c.key)&&(a.textContent=o.get(c.key),l=!0)}return l?i:null}function Wa(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 ur(e,t,n={}){let r=n||{};if(!r.head?.block)return Ka(e,t,r);try{return Ka(e,t,r)}catch(o){return Promise.reject(o)}}function Ka(e,t,n){let r=n.policy||"sync",o=r==="raw"?void 0:(a,c)=>Vd(a)||(r==="history"?!(c&&a.matches(zd))&&a.matches(Hd):a.matches($d)),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 To(Object.assign({},i,{live:e,base:n.scripts?.mergeBase||null,remote:Wa(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:Wa(t,e.ownerDocument)});return To(a)}n.morphStyle==="innerHTML"&&(i.children=!0);let l=Wd(e,n.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return l!==void 0&&(i.base=l),Fi(e,t,i)}var Gd=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),Dn=()=>{};function Eo(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!Gd.has(l))throw new TypeError(`unknown option "${l}"`);let n=Object.assign({beforeNodeAdded:Dn,afterNodeAdded:Dn,beforeNodeRemoved:Dn,afterNodeRemoved:Dn,beforeNodeMorphed:Dn,afterNodeMorphed:Dn,beforeAttributeUpdated:Dn},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");let i=e.lineage;if(i!==void 0&&(!i||typeof i!="object"||typeof i.onResult!="function"||!i.elements||typeof i.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:li(e.ignore,t),remoteWins:li(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,opaque:typeof e.opaque=="function"?e.opaque:()=>!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,lineage:i||null}}function zr(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 _n}function Vr(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=ai(t,e.map),r=typeof e.then=="function"?e.then:_n;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 _n}function Yd(e,t,n,r={}){let o=p=>p&&p.nodeType===9?p.documentElement:p,s=o(t),i=o(n),l=o(e)||s;if(r.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let a=Object.assign({},r);delete a.live,delete a.base,delete a.remote;let c=Eo(a,[l,s,i].filter(Boolean)),h=r.identity||{},u=ar(),f=us(l,s,i,{identity:{base:Vr(h.base,l),local:Vr(h.local,s),remote:Vr(h.remote,i)},authored:{base:zr(h.base),local:zr(h.local),remote:zr(h.remote)},skipUnchanged:c.hooks.beforeNodeMorphed===Dn&&c.hooks.afterNodeMorphed===Dn,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,delete f.lineage,f}function qi({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:r,toLive:o,options:s,identity:i,childrenOnly:l,isDocument:a}){let c=Eo(s,[e,t,n,r].filter(Boolean));if(c.ignored(e)){let S=Ui(),T=c.lineage?xo(c.lineage,e,S):null;return{report:S,loads:[],lineage:T}}let h=e.ownerDocument,u=c.lineage?Ei(c.lineage,{liveRoot:e,localRoot:n,toLive:o}):null,f=c.scripts.execute?ya(e,c.ignored,h.baseURI):null,p=ar(),m=c.hooks.beforeNodeMorphed===Dn&&c.hooks.afterNodeMorphed===Dn,y={identity:{base:Vr(i.base,t||n),local:Vr(i.local,n),remote:Vr(i.remote,r)},authored:{base:zr(i.base),local:zr(i.local),remote:zr(i.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:l,skipUnchanged:m,lineage:u?{locals:u.locals}:null},g=c.fastPath&&a&&!l&&m&&t===n,d=null,k=null;if(g){let S=Va({baseRoot:t,remoteRoot:r,liveRoot:e,toLive:o,o:c,identity:y.identity,baseURI:h.baseURI});y.comparisons=S.comparisons||S.scope,S.bail?k=S.bail:(d=us(t,n,r,Object.assign({},y,{stats:p,scope:S.scope})),d||(k="chain-unpaired",p=ar()))}d||(d=us(t||n,n,r,Object.assign({},y,{stats:p}))),g&&(p.fastPathAttempted=1,p.fastPathTaken=k?0:1,p.fastPathFallback=k),d.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(S=>c.hooks[S]!==Dn)&&Oa(d.conflicts,d.recoveryLinks,o),c.beforeApply&&c.beforeApply(d.doc);let A=globalThis.__hyperMorphProfile,w=A?performance.now():0,v=$a(e,d.root,d,{toLive:o,localRoot:n,ignored:c.ignored,ignoreAttribute:c.ignoreAttribute,opaque:c.opaque,formState:c.formState,protectFocusedValue:c.protectFocusedValue,restoreFocus:c.restoreFocus,preserve:c.head.preserve,hooks:c.hooks,childrenOnly:l,keepLiveOnly:c.keepLiveOnly,trackInserted:!!u});A&&(A.apply=(A.apply||0)+(performance.now()-w));let E=[];if(c.head.awaitLoads)for(let S of v.applied){if(S.kind!=="insert"||S.node.nodeType!==1)continue;let T=S.node;T.tagName==="LINK"&&/\bstylesheet\b/i.test(T.getAttribute("rel")||"")&&T.getAttribute("href")&&T.closest("head")&&E.push(new Promise(q=>{T.addEventListener("load",()=>q()),T.addEventListener("error",()=>q())}))}let N=null,_=null;if(f){let S=xa(e,f,{ignored:c.ignored,skip:v.mergedScriptsLive,baseURI:h.baseURI,beforeNodeAdded:c.hooks.beforeNodeAdded,afterNodeAdded:c.hooks.afterNodeAdded,trackRecovery:!!d.recoveryLinks});E.push(...S.loads),N=S.swapped,_=S.vetoed}let M=S=>N&&N.get(S)||S,j=S=>{if(v.keptRuns.has(S))return v.runOf.get(S);let T=v.liveOf.get(S)||v.heldBy.get(S)||v.insertedLive.get(S);return T?M(T):null},R=S=>{let T=S&&v.liveOf.get(S);return T?M(T):null},D=S=>{let T=S&&j(S);return Array.isArray(T)?T[0]:T};if(d.recoveryLinks){let S=(T,J,q)=>(J.namespaceURI?T.getAttributeNS(J.namespaceURI,J.localName):T.getAttribute(J.qualifiedName))===q;Ca(d.conflicts,d.recoveryLinks,{lookup:j,vetoed:v.vetoed,vetoedAttrs:v.vetoedAttrs,removedVetoes:v.removedVetoes,vetoedLive:_,liveAttr:S,ignored:c.ignored,liveRoot:e})}let F={applied:v.applied,decisions:d.decisions.map(S=>Object.assign({},S,{node:S.node?R(S.node):null,el:S.el?R(S.el):null,applied:!!(S.node?R(S.node):S.el&&R(S.el))})),conflicts:d.conflicts.map(S=>Object.assign({},S,{node:S.node?S.kind==="text"&&S.recovery.subject.nodeType===8?D(S.node):R(S.node):S.node,el:S.el?S.kind==="structure"?D(S.el):R(S.el):S.el})),localDiverged:d.localDiverged,identities:v.identities,moved:v.moved,replaced:v.replaced,stats:p};return u&&(F.lineage=u.finish(d.lineage,j)),{report:F,loads:E,lineage:u}}var Ga=new WeakMap;function Ui(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:ar()}}function To(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");return t.lineage===void 0?Ya(t):Ti(t,t.live.documentElement,r=>Ya(r))}function Ya(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let r=Ga.get(n);r||(r=si(n),Ga.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:f=>f;Ul(n,o);let{report:c,loads:h,lineage:u}=qi({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 u?.deliver(c),Promise.all(h).then(()=>c)}function Xd(e,t,n={}){return To(Object.assign({},n,{live:e,base:null,remote:t}))}function Xa(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=Zo(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 Fi(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return n.lineage===void 0?Ja(e,t,n):Ti(n,e,r=>Ja(e,t,r))}function Ja(e,t,n={}){let r=e.ownerDocument,{base:o,...s}=n,i=!!s.children,l=Eo(s,[e]);if(l.ignored(e)){let y=Ui();return l.lineage&&xo(l.lineage,e,y).deliver(y),Promise.resolve(y)}let a=Xa(t,r),c=o!=null?Xa(o,r):null,h,u=null;if(i)h=a.root,u=c?c.root:null;else{if(h=a.first,u=c?c.first:null,!h){let y=Eo(s),g=y.lineage?xo(y.lineage,e,{}):null;y.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),y.hooks.afterNodeRemoved(e));let d={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:ar()};return g&&(d.lineage=g.result,g.deliver(d)),Promise.resolve(d)}if(h.tagName!==e.tagName){let y=Eo(s,[e,h]);if(y.hooks.beforeNodeMorphed(e,h)===!1){let k=Ui();return y.lineage&&xo(y.lineage,e,k).deliver(k),Promise.resolve(k)}let g=qi({liveRoot:e,baseRoot:u&&u.tagName===e.tagName?u:null,localRoot:e,remoteRoot:h,toLive:k=>k,options:s,identity:s.identity||{},childrenOnly:!0,isDocument:!1}),d=vn(h)?vo(h,r):r.importNode(h,!1);if(!vn(d))for(;e.firstChild;)d.appendChild(e.firstChild);return y.hooks.beforeNodeAdded(d)===!1?(fs(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):y.hooks.beforeNodeRemoved(e)===!1?(fs(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(d),fs(g.report.conflicts,e,d),y.hooks.afterNodeRemoved(e),y.hooks.afterNodeAdded(d),y.hooks.afterNodeMorphed(e,h),g.report.replaced.push(d),g.report.applied.push({kind:"insert",node:d,parent:d.parentNode},{kind:"remove",node:e,parent:d.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,d),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:f,loads:p,lineage:m}=qi({liveRoot:e,baseRoot:u,localRoot:e,remoteRoot:h,toLive:y=>y,options:s,identity:s.identity||{},childrenOnly:i,isDocument:!1});return m?.deliver(f),Promise.all(p).then(()=>f)}var $i={mergeDocument:To,morphDocument:Xd,morphElement:Fi,merge3:Yd,morph:ur};var ds=["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"],Hi=new Set(ds),Za=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Wr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var ms={};oi(ms,{EmptyListInsert:()=>_o,MAX_RULE_DEPTH:()=>Yr,MaxRuleDepthExceeded:()=>Er,NoRulesTag:()=>zi,RuleTargetReadOnly:()=>No,RulesParseError:()=>Kr,ShapeMismatch:()=>Oo,UnknownRulesVersion:()=>Gr,WriteRefused:()=>hs,WriteRejected:()=>Vi});var Kr=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},Gr=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},Yr=20,Er=class extends Error{constructor(t){super(`rule depth exceeded ${Yr} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},Oo=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},_o=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}},No=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},hs=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}},zi=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Vi=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 dr(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 Wi(e,t,n,{depth:0,path:[]},r)}function Wi(e,t,n,r,o){if(r.depth>Yr)throw new Er(r.path);if(typeof n=="string")return th(e,t,n,r,o);if(Array.isArray(n)){let[s,i]=n,l=e.find(t,s,o);return ec(o,r,l),l.map((a,c)=>Wi(e,a,i,{depth:r.depth+1,path:[...r.path,c]},o))}if(typeof n=="object"&&n!==null){let s={};for(let[i,l]of Object.entries(n))s[i]=Wi(e,t,l,{depth:r.depth+1,path:[...r.path,i]},o);return s}return null}function th(e,t,n,r,o){if(n.endsWith("[]")){let l=n.slice(0,-2),a=e.find(t,l,o);return ec(o,r,a),a.map(c=>e.text(c))}if(n.startsWith("@"))return Qa(e,t,n.slice(1));let s=sn(n);if(s!==-1){let l=n.slice(0,s),a=n.slice(s+1),c=l?e.find(t,l,o):[t];return c.length===0?null:Qa(e,c[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 ec(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 Qa(e,t,n){if(Hi.has(n)){let o=e.prop(t,n);return o==null?null:String(o)}let r=e.attr(t,n);return r||null}var ps=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"]})}),nh=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),tc=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function Co(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 Ki(e,t){if(Co(e,t))return!0;for(let[n,r]of Object.entries(nh))if(r.includes(t)&&Co(e,n))return!0;return!1}function Mo(e){let t=ps[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function rh(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=ps[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>Ki(n,o))||r.bundles.some(o=>Co(n,o)))return n;n=n.parentElement}return null}function nc(e,t){return!!rh(e,t)}var oh=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function sh(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"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),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function rc(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 oc(e,t,n,r,o,s){return(s?nc(e,t):rc(e,n,o,!1))||!!(r&&(s&&e!==o?e.matches(r):rc(e,r,o,s)))}function ih(e,t){let n=ps[t];return n.tokens.some(r=>Ki(e,r))||n.bundles.some(r=>Co(e,r))}var lh=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function sc(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let o=e,s=t;if(e.nodeType===1){if(lh.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);o=e.content,s=t.content,n.cloneToLive.set(s,o),n.liveToClone.set(o,s)}}else if(e.nodeType!==11)return;let i=s.firstChild;for(let l=o.firstChild;l&&i;l=l.nextSibling)sc(l,i,n,r),i=i.nextSibling}function Ro(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:o=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=s.implementation.createHTMLDocument(""),l=o||new WeakMap,a=new WeakMap,c=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let h=Mo(t),u=r?m=>ih(m,t)||!!(n&&m.matches(n)):m=>oc(m,t,h,n,c,!1),f=null;if(c.nodeType!==1||!oc(c,t,h,n,c,r)){f=i.importNode(c,!0);let m={cloneToLive:l,liveToClone:a,dropped:[],controls:[]};sc(c,f,m,u);for(let y of m.dropped)y.remove();for(let y=0;y<m.controls.length;y+=2)sh(m.controls[y],m.controls[y+1])}e.nodeType===9&&f&&(i.replaceChild(f,i.documentElement),a.set(e,i),l.set(i,e));let p=m=>{if(oh.test(m))throw new Error(`Filtered content queries do not support stateful selector: ${m}`)};return{root:f,document:i,capability:t,selector:Mo(t),cloneToLive:l,liveToClone:a,original(m){return l.get(m)||null},cloneOf(m){return a.get(m)||null},query(m,y=f){return p(m),Array.from(y.querySelectorAll(m),g=>l.get(g)||g)},text(m=f){return(m===f?f:a.get(m))?.textContent||""},html(m=f){return(m===f?f:a.get(m))?.innerHTML??""},clone(m=f){let y=m===f?f:a.get(m);return y?i.importNode(y,!0):null}}}function ic(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function ah(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var un={semanticExclude:!0,find(e,t,n={}){let r=ah(e);if(!r||!r.querySelectorAll)return[];let o=Array.from(r.querySelectorAll(t));n.includeRulesTag||(o=o.filter(l=>!ic(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)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},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 er(e,t={}){if(t.exclude===null)return un;let n=[Mo("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 un;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,i=e.nodeType===9?e:e.ownerDocument,l=null,a=()=>l||(l=Ro(s,{capability:"data",exclude:t.exclude||null})),c=m=>{let y=a();return m===e?y.cloneOf(e):y.cloneOf(m)||m},h=m=>l?.original(m)||m,u=(m,y)=>{a().liveToClone.set(m,y),a().cloneToLive.set(y,m);let g=m.childNodes||[],d=y.childNodes||[];for(let k=0;k<Math.min(g.length,d.length);k++)u(g[k],d[k])},f=(m,y,g,d)=>{let k=Array.from(m.childNodes).filter(N=>l.cloneOf(N)),w=k[0];for(;w&&k.includes(w);)w=w.nextSibling;for(let N of k)N.remove();if(g==="innerHTML"){let N=i.createElement("template");N.innerHTML=d;for(let _ of Array.from(N.content.childNodes))m.insertBefore(_,w||null)}else m.insertBefore(i.createTextNode(d),w||null);let v=Ro(m,{capability:"data",exclude:t.exclude||null});y.replaceChildren(...Array.from(v.root?.childNodes||[]));let E=N=>{let _=v.original(N);_&&(l.liveToClone.set(_,N),l.cloneToLive.set(N,_));for(let M of Array.from(N.childNodes||[]))E(M)};for(let N of Array.from(y.childNodes))E(N)},p={...un,find(m,y,g={}){let d=c(m);if(!d?.querySelectorAll)return[];let k=a().query(y,d);g.includeRulesTag||(k=k.filter(v=>!ic(v)));let A=[];g.skip&&A.push(g.skip);let w=g.templateAttr===null?null:g.templateAttr||"cms-template";if(w&&A.push(`[${w}]`),A.length){let v=A.join(", ");k=k.filter(E=>!E.closest?.(v))}return k},parent(m){let y=c(m)?.parentElement;return y?h(y):null},children(m){return Array.from(c(m)?.children||[],h)},text(m,y){if(y===void 0){let k=h(m);return!k?.matches?.(n)&&!k?.querySelector?.(n)?un.text(k):(c(m)?.textContent||"").trim()}let g=h(m);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){un.text(g,y);return}let d=a().cloneOf(g);d?f(g,d,"textContent",y):un.text(g,y)},attr(m,y,g){let d=h(m);if(g===void 0)return un.attr(d,y);un.attr(d,y,g);let k=l?.cloneOf(d);k&&(un.attr(k,y,g),Ro(d,{capability:"data",exclude:t.exclude||null}).root===null&&(k.remove(),l.liveToClone.delete(d),l.cloneToLive.delete(k)))},removeAttr(m,y){let g=h(m);un.removeAttr(g,y);let d=l?.cloneOf(g);d&&un.removeAttr(d,y)},prop(m,y,g){let d=h(m);if(g===void 0)return y==="innerHTML"||y==="outerHTML"||y==="textContent"||y==="innerText"?un.prop(c(d),y):un.prop(d,y);let k=y==="innerHTML"||y==="textContent"||y==="innerText",A=k?a().cloneOf(d):l?.cloneOf(d);A&&k?f(d,A,y,g):(un.prop(d,y,g),A&&un.prop(A,y,g))},clone(m){let y=c(m);return y===m?un.clone(m):i.importNode(y,!0)},insertAt(m,y,g){let d=h(m),A=p.children(d)[g]||(()=>{for(let E=d.children.length-1;E>=0;E--){let N=d.children[E];if(a().cloneOf(N))return N.nextElementSibling}return d.firstElementChild})(),w=h(y);d.insertBefore(w,A||null);let v=a().cloneOf(d);if(v){let E=a().cloneOf(w);E||(E=i.importNode(w,!0),u(w,E));let N=Array.from(v.children);v.insertBefore(E,N[g]||null)}},insertBefore(m,y){let g=h(m),d=h(y);g.parentNode.insertBefore(d,g);let k=a().cloneOf(g.parentNode);if(k){let A=a().cloneOf(d);A||(A=i.importNode(d,!0),u(d,A));let w=a().cloneOf(g);w?w.before(A):k.appendChild(A)}},insertAfter(m,y){let g=h(m),d=h(y);g.parentNode.insertBefore(d,g.nextSibling);let k=a().cloneOf(g.parentNode);if(k){let A=a().cloneOf(d);A||(A=i.importNode(d,!0),u(d,A));let w=a().cloneOf(g);w?w.after(A):k.appendChild(A)}},identity(m){return h(m)||null},remove(m){let y=h(m),g=a().cloneOf(y);un.remove(y),g&&un.remove(g)},replaceWith(m,y){let g=h(m),d=a().cloneOf(g),k=un.replaceWith(g,y);if(d){let A=Ro(k,{capability:"data",exclude:t.exclude||null});if(!A.root)d.remove();else{d.replaceWith(A.root);let w=v=>{let E=A.original(v);E&&(l.liveToClone.set(E,v),l.cloneToLive.set(v,E));for(let N of Array.from(v.childNodes||[]))w(N)};w(A.root)}}return k}};return p}var Xr=un;function Gi(e){try{return JSON.parse(e)}catch(t){throw new Kr(`Invalid strict JSON: ${t.message}`,t)}}function Jr(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 u=!1,f=i+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: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 u=l,f=i+1;for(;f<o.length&&o[f]!==u;)o[f]==="\\"&&f++,f++;s.push({type:t.STRING,value:o.substring(i+1,f),quoted:!0,sourceQuote:u}),i=f+1;continue}let a=i,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 p of u){let m=p.substring(1);if(o.substring(a+1,a+1+m.length)===m){f=!0,a+=m.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(i,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}),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,(c,h)=>h.length%2===0?h+'\\"':c)),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 Kr("Invalid extraction rules syntax: "+o.message,o)}}var ac="1",lc=/^[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"||!lc.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${lc})`);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!==ac)throw new Gr(i);return{rules:Jr(e.text(s)),tagNode:s}}var gy=new Function("url","return import(url)");function mc(e,t,n,r){let o=e.length,s=t.length,i=new Array(o).fill(-1);if(r){let d=new Set;for(let k=0;k<o;k++){let A=r[k];!(A>=0&&A<s)||d.has(A)||(i[k]=A,d.add(A))}}if(o===0||s===0)return i;let l=e.map(d=>dc(d,n)),a=t.map(d=>dc(d,n)),c=new Array(s).fill(!1);for(let d of i)d>=0&&(c[d]=!0);let h=new Map;a.forEach((d,k)=>{c[k]||h.set(d,h.has(d)?-1:k)});let u=new Map;l.forEach((d,k)=>{i[k]>=0||u.set(d,(u.get(d)||0)+1)}),l.forEach((d,k)=>{if(i[k]>=0||u.get(d)!==1)return;let A=h.get(d);A===void 0||A===-1||c[A]||(i[k]=A,c[A]=!0)});let f=[];for(let d=0;d<o;d++)i[d]<0&&f.push(d);let p=[];for(let d=0;d<s;d++)c[d]||p.push(d);if(f.length===0||p.length===0)return i;let m=o*s+1,y=fh(e,t,n),g=(d,k)=>y(d,k)*m+Math.abs(d-k);for(let[d,k]of uh(f,p,g))i[d]=k;return i}var pc=e=>typeof e=="object"&&e!==null;function dc(e,t){if(!pc(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 fh(e,t,n){if(!pc(n))return(l,a)=>e[l]===t[a]?0:1;let r=Object.keys(n),o=l=>r.map(a=>JSON.stringify(l?.[a])),s=e.map(o),i=t.map(o);return(l,a)=>{let c=s[l],h=i[a],u=0;for(let f=0;f<r.length;f++)c[f]!==h[f]&&u++;return u}}function uh(e,t,n){return e.length<=t.length?hc(e,t,n,!1):hc(t,e,(r,o)=>n(o,r),!0)}function hc(e,t,n,r){let o=e.length,s=t.length,i=[];for(let u=0;u<=o;u++)i.push(new Float64Array(s+1).fill(1/0));let l=[];for(let u=0;u<=o;u++)l.push(new Uint8Array(s+1));for(let u=0;u<=s;u++)i[o][u]=0;for(let u=o-1;u>=0;u--)for(let f=s-1;f>=0;f--){let p=n(e[u],t[f])+i[u+1][f+1],m=i[u][f+1];p<=m?(i[u][f]=p,l[u][f]=1):i[u][f]=m}let a=[],c=0,h=0;for(;c<o&&h<s;)l[c][h]&&(a.push(r?[t[h],e[c]]:[e[c],t[h]]),c++),h++;return a}function Xi(e,t,n,r,o,s,i,l={}){let a=e.find(t,n,l);if(o.length===0){a.forEach(v=>e.remove(v)),Yi(l,"onRowsApplied",s.path,[]);return}let c=o.length>a.length,h=a[0]||null;if(c&&!h&&(h=ph(e,t,n,l),!h))throw new _o(s.path);let u=a.map(v=>mh(e,v,r,l)),f=null;if(c&&h){f=e.clone(h),l.templateAttr&&e.removeAttr(f,l.templateAttr);let v=e.stripIds(f);v>0&&console.warn(`[hyper-html-api] stripped ${v} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let p=mc(o,u,r,dh(e,a,o,s,l)),m=a[0]||h,y=e.parent(m),g=a.length>0?gc(e,y,m):0,d=bh(e,a),k=new Set,A=[],w=o.map((v,E)=>{let N=p[E];if(N>=0)return k.add(N),A.push(!1),a[N];A.push(!0);let _=e.clone(f);return e.stripIds(_),_});a.forEach((v,E)=>{k.has(E)||e.remove(v)}),d?gh(e,y,g,w,A):kh(e,w,A,y,g),hh(e,w,r,o,s,i,l),Yi(l,"onRowsApplied",s.path,w)}function Yi(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 dh(e,t,n,r,o){let s=Yi(o,"identifyRows",r.path,n);if(!Array.isArray(s))return null;let i=new Array(n.length).fill(-1),l=new Set,a=new Map(t.map((c,h)=>[e.identity(c),h]));for(let c=0;c<n.length;c++){if(!s[c])continue;let h=a.get(e.identity(s[c]));h===void 0||l.has(h)||(i[c]=h,l.add(h))}return i}function hh(e,t,n,r,o,s,i){t.forEach((l,a)=>{if(n===null){let c=r[a],h=c==null?"":String(c);e.text(l)!==h&&e.text(l,h)}else{let c=s(e,l,n,r[a],{depth:o.depth+1,path:[...o.path,a]},i);c&&c!==l&&(t[a]=c)}})}function mh(e,t,n,r){return n===null?e.text(t):dr(e,t,n,r.onRowsRead?{...r,onRowsRead:void 0}:r)}function gc(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 ph(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 gh(e,t,n,r,o){let s=e.children(t),i=s.map(a=>e.identity(a)),l=!1;r.forEach((a,c)=>{let h=e.identity(a),u=n+c;if(i[u]===h)return;if(!o[c]){let p=i.indexOf(h);p!==-1&&(i.splice(p,1),s.splice(p,1))}let f=Math.min(u,s.length);f<s.length?e.insertBefore(s[f],a):s.length?l?e.insertAfter(s[s.length-1],a):(e.insertAt(t,a,u),l=!0):e.insertAt(t,a,0),i.splice(f,0,h),s.splice(f,0,a)})}function bh(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let r=new Map(e.children(n).map((s,i)=>[e.identity(s),i])),o=[];for(let s of t){let i=r.get(e.identity(s));if(i===void 0)return!1;o.push(i)}return o.sort((s,i)=>s-i),o[o.length-1]-o[0]===o.length-1}function kh(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 c=s?gc(e,a,s)+1:i++;e.insertAt(a,t[l],c),s=t[l]}}var bc=new Set(["checked","selected","disabled","readOnly","paused"]);function Zr(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(Ji(n,r,[],s),s.length)throw new Oo(s);gs(e,t,n,r,{depth:0,path:[]},o)}function gs(e,t,n,r,o,s={}){if(o.depth>Yr)throw new Er(o.path);if(r===void 0)return t;if(typeof n=="string")return yh(e,t,n,r,o,s);if(Array.isArray(n)){let[i,l]=n;return Xi(e,t,i,l,r,o,gs,s),t}if(typeof n=="object"&&n!==null){for(let[i,l]of Object.entries(n)){let a=gs(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 yh(e,t,n,r,o,s){if(n.endsWith("[]")){let a=n.slice(0,-2);return Xi(e,t,a,null,r,o,gs,s),t}if(n.startsWith("@"))return yc(e,t,n.slice(1),r);let i=sn(n);if(i!==-1){let a=n.slice(0,i),c=n.slice(i+1),h=a?e.find(t,a,s):[t];return h.length===0||yc(e,h[0],c,r),t}if(n===".")return kc(e,t,r),t;let l=e.find(t,n,s);return l.length===0||kc(e,l[0],r),t}function kc(e,t,n){let r=n==null?"":String(n);e.text(t)!==r&&e.text(t,r)}function yc(e,t,n,r){if(Wr.has(n)){let s=e.prop(t,n);if(s===r||s!=null&&r!=null&&String(s)===String(r))return t;throw new No(n)}if(n==="outerHTML"){let s=r==null?"":String(r);return e.replaceWith(t,s)}if(Za.has(n)){let s=xh(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 xh(e,t){return t==null?bc.has(e)?!1:"":bc.has(e)?t==="false"?!1:!!t:t}function Ji(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:Po([...n,s]),expected:"scalar",got:Lo(o)})}):r.push({path:Po(n),expected:"array",got:Lo(t)});return}t!==null&&typeof t=="object"&&r.push({path:Po(n),expected:"scalar",got:Lo(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){r.push({path:Po(n),expected:"array",got:Lo(t)});return}let o=e[1];t.forEach((s,i)=>Ji(o,s,[...n,i],r));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){r.push({path:Po(n),expected:"object",got:Lo(t)});return}for(let[o,s]of Object.entries(e))Ji(s,t[o],[...n,o],r)}}}function Lo(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Po(e){return e.join(".")}var Rh=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",...tc],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 Zi(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 wn={extract:(e,t,n={})=>dr(er(e,n),e,t,n),apply:(e,t,n,r={})=>Zr(er(e,{...r,_write:!0}),e,t,n,r),findRulesIn:(e,t)=>Io(Xr,e,t),findRules:(e,t)=>Zi(Xr,e,t),bind:(e,t,n={})=>{let r=Zi(Xr,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:()=>dr(er(e,n),e,r.rules,n),set:o=>Zr(er(e,{...n,_write:!0}),e,r.rules,o,n)}},parseStrict:Gi,parseRelaxed:Jr,ruleAttrIndex:sn,splitRule:Jo,errors:ms,DOM_PROPERTIES:ds};var el={};oi(el,{fromString:()=>tr,getRuleAtPath:()=>Or,getValueAtPath:()=>Dh,setAtPath:()=>Qi,toString:()=>jh});function jh(e){return e.map(String).join(".")}function tr(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function Or(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 Dh(e,t){let n=e;for(let r of t){if(n==null)return;n=n[r]}return n}function Qi(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]=Qi(s[r],o,n),s}return{...e&&typeof e=="object"?e:{},[r]:Qi((e||{})[r],o,n)}}function jo(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]=jo(r);return t}return""}function bs(e,t,{ignoreActiveValue:n=!0}={}){$i.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:n,restoreFocus:!0,formStateSync:"property",policy:"raw"})}var vc=new WeakMap,tl=e=>e.map(String).join(".");function Bh(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function wc(e,t){if(!e||!e.querySelector)return null;let n=e.querySelector(`[data-hcms-path="${Bh(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 Ac(e,t,n){let r=wc(e,t);!r||r.length!==n.length||r.forEach((o,s)=>{n[s]&&vc.set(o,n[s])})}function ks(){let e=new Map;return{hooks:{onRowsRead(t,n){e.set(tl(t),n)}},seed(t){for(let[n,r]of e)Ac(t,n,r);e.clear()}}}function Sc(e){return{identifyRows(t,n){let r=wc(e,tl(t));return!r||r.length!==n.length?null:r.map(o=>vc.get(o)||null)},onRowsApplied(t,n){Ac(e,tl(t),n)}}}var Tc={skip:"[data-hcms-shell]",templateAttr:"cms-template"},nl="data-hcms-rollback-ui",Fh=0;function Ec(e,t,n,r={}){return qh(e,t,n,r)}function qh(e,t,n,r){let{shellRoot:o,structural:s,structuralPath:i,formRoot:l}=r,a=l?{...Tc,...Sc(l)}:Tc;if(!s)try{return wn.apply(e,t,n,a),{ok:!0}}catch(f){return{ok:!1,error:f}}let c=Uh(e,t,i),h=c?Hh(c):null,u=c?null:Vh(e,o);try{return wn.apply(e,t,n,a),{ok:!0}}catch(f){return h?zh(c,h):u&&Wh(e,o,u),{ok:!1,error:f}}}function Uh(e,t,n){if(!n||!e)return null;let r=tr(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:$h(e,t,o)}function $h(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 Hh(e){let t=[],n=[];for(let r of Array.from(e.childNodes))t.push(rl(r,n));return{nodes:t,retained:n}}function zh(e,t){let n=e.cloneNode(!1);for(let r of t.nodes)n.appendChild(r);ur(e,Array.from(n.childNodes),_c()),Oc(e,t.retained)}function Vh(e,t){let n=[],r=[];for(let o of Array.from(e.childNodes))o===t||t&&o.contains?.(t)||n.push(rl(o,r));return{nodes:n,retained:r}}function Wh(e,t,n){let r=e.cloneNode(!1);for(let o of n.nodes)r.appendChild(o);ur(e,Array.from(r.childNodes),_c()),Oc(e,n.retained)}function rl(e,t){let n=e.cloneNode(!1);if(e.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]')){let s=String(++Fh);n.setAttribute(nl,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(rl(s,t));return n}function Oc(e,t){for(let{id:n,node:r}of t){let o=e.querySelector(`[${nl}="${n}"]`);o===r?r.removeAttribute(nl):r.isConnected?o?.remove():o?.replaceWith(r)}}function _c(){return{morphStyle:"innerHTML",policy:"raw",restoreFocus:!1,scripts:{handle:!1,merge:!1}}}function xs(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 Kh='<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>',ol='<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>',Mc={"@scalar":`
|
|
6
|
+
`+s)}return n+l.replace(/</g,"\\u003c")+r}function ji(e,t,n,r={}){let o=r.parse||Li,s=[],i=[],l=(f,p)=>{if(typeof f!="string")return Xt;try{return o(f)}catch(m){return s.push(`${p} side is not valid JSON (${m.message})`),Xt}},a=l(t,"local"),c=l(n,"remote");if(a===Xt)return{text:n,warnings:s,conflicts:i};if(c===Xt)return{text:t,warnings:s,conflicts:i};let d=l(e,"base"),u=Na(d===Xt?void 0:d,a,c,{...r,onConflict:f=>{i.push(f),r.onConflict?.(f)}});return Qn(u,c)?{text:n,warnings:s,conflicts:i}:Qn(u,a)?{text:t,warnings:s,conflicts:i}:{text:jd(u,n),warnings:s,conflicts:i}}var _a=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Sr(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>_a(t)||o>_a(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 fr(e,t,n={}){if(!Sr(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 g=r;g;g=g.parentNode)l.add(g);let a=s;for(;!l.has(a);)a=a.parentNode;let c=(g,h)=>{let y=a.ownerDocument.createRange(),A=a.ownerDocument.createRange();return y.setStart(g[0],g[1]),y.collapse(!0),A.setStart(h[0],h[1]),A.collapse(!0),y.compareBoundaryPoints(0,A)},d=(g,h=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(h)],u=[],f;if(t==="plain"){f="";let g=h=>{if(h.nodeType===3||h.nodeType===8){let y=f.length;f+=h.nodeValue,u.push({s:y,e:f.length,a:[h,0],b:[h,h.nodeValue.length],node:h})}else for(let y of h.childNodes)g(y)};g(a)}else{let g=n.blocks;if(!g){g=new Set;let y=A=>{A!==a&&A.nodeType===1&&Oi.has(A.tagName)&&g.add(A);for(let w of A.childNodes)y(w)};y(a)}let h=an(Array.from(a.childNodes),{blocks:g,atomize:y=>!!n.atoms?.has(y),ignored:n.ignored});f=h.text;for(let y of h.nodes)u.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 h.atoms)u.push({s:y.i,e:y.i+1,a:d(y.el),b:d(y.el,!0)});for(let y=0;y<h.text.length;y++){if(h.text[y]!==Ot)continue;let A=h.marks.find(v=>v.block&&v.to===y+1),w=h.marks.find(v=>v.block&&v.from===y+1);if(A)u.push({s:y,e:y+1,a:[A.el,A.el.childNodes.length],b:d(A.el,!0)});else if(w)u.push({s:y,e:y+1,a:d(w.el),b:[w.el,0]});else return null}}u.sort((g,h)=>g.s-h.s);let p=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let y=u.find(A=>A.node===g[0]);return y?y.s+g[1]:null}let h=0;for(let y of u){if(c(g,y.a)<=0)return y.s;if(c(g,y.b)<0)return null;h=y.e}return h},m=p([r,o]),k=p([s,i]);return m!==null&&k!==null&&m<=k?f.slice(m,k):null}function Ar(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 Ca(e,t){if(!e||!t)return null;let n=Ar(e,t.start),r=Ar(e,t.end);return n&&r?{startContainer:n[0],startOffset:n[1],endContainer:r[0],endOffset:r[1]}:null}var Ma=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ra(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 c=l.local.map(d=>Ar(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:Ma(d)}));return o.set(l,c),c},i=l=>{let a=Ca(t.localRoot,l);if(!a)return null;let c=n(a.startContainer),d=n(a.endContainer);if(!c||!d)return null;let u={...a,startContainer:c,endContainer:d};return Sr(u)?u:null};for(let l of e){let a=l.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=i(a.text.local.span),c.scope=i(a.text.local.scope);let d=c.span;if(d){let u=d.startContainer.ownerDocument.createRange();u.setStart(d.startContainer,d.startOffset),u.setEnd(d.endContainer,d.endOffset);let f=p=>{if(u.intersectsNode(p)){c.touched.add(p);for(let m of p.childNodes)f(m)}};f(u.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,c)}t.localState={states:r,refs:o}}function Ia(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 c=d=>Array.prototype.indexOf.call(a.parentNode.childNodes,d);return!(l.previous&&r(l.previous)&&l.previous.parentNode===a.parentNode&&c(l.previous)>=c(a)||l.next&&r(l.next)&&l.next.parentNode===a.parentNode&&c(l.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 l=e.text.local,a=c=>c&&r(c.startContainer)&&r(c.endContainer);return a(o.span)&&a(o.scope)&&fr(o.scope,e.text.encoding)===l.text&&fr(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 c of i.localOrder){let d=n.localState.refs.get(c)?.[0]?.node;if(!d||!r(d)||a&&d.parentNode!==a)return!1;let u=Array.prototype.indexOf.call(d.parentNode.childNodes,d);if(u<=l)return!1;a=d.parentNode,l=u}return!0}return i.localAction==="moved"||o.subject.every(l=>Ma(l.node)===l.fragment)}var Dd=1,yn=e=>!!e&&e.nodeType===1,us=e=>yn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function Tr(e,t=null,n=null){let r=new Map,o=new Map,s=d=>{if(!t){t=new WeakMap;let u=[e];for(;u.length;){let f=u.pop();us(f)&&(t.set(f.content,f),u.push(f.content));for(let p=f.firstChild;p;p=p.nextSibling)p.nodeType===1&&u.push(p)}}return t.get(d)||null},i=(d,u)=>{let f=o.get(d);if(!f){f=new Map;let p=0;for(let m=d.firstChild;m;m=m.nextSibling)f.set(m,p++);o.set(d,f)}return f.get(u)},l=d=>{if(!d)return null;if(n&&n.has(d))return l(n.get(d));if(d===e)return[];let u=r.get(d);if(u!==void 0)return u;let f=d.parentNode,p=null;if(f&&f.nodeType===11){let m=s(f),k=m?l(m):null;k&&(p=k.concat(["content",i(f,d)]))}else if(f){let m=l(f);m&&(p=m.concat([i(f,d)]))}return r.set(d,p),p};return{root:e,pathOf:l,logicalParent:d=>{let u=d.parentNode;return u&&u.nodeType===11?s(u):u},indexIn:i,containerPath:d=>{if(d.nodeType===11){let f=s(d),p=l(f);return p?p.concat(["content"]):null}let u=l(d);return u&&us(d)?u.concat(["content"]):u},ownerOf:s}}var Bn=e=>us(e)?e.content:e;function La(e){let{L:t,R:n,unitsOf:r,provenance:o,policy:s}=e,i=[];return{note:(d,u)=>{i.push([d,u])},finish:d=>i.length?c(d):null};function c(d){let u={base:Tr(e.roots.base),local:Tr(e.roots.local),remote:Tr(e.roots.remote)},f=K=>K==="local"?t:n,p=(K,b)=>{if(!b)return null;if(K.map.has(b))return K.map.get(b);let C=[],L=yn(b)?u.base.logicalParent(b):b.parent;for(;L&&!K.map.has(L);L=u.base.logicalParent(L))C.push(L);if(!L||!K.identical.has(L))return null;let $=K.map.get(L);for(let Q=C.length-1;Q>=0&&$;Q--)$=Bn($).childNodes[u.base.indexIn(C[Q].parentNode,C[Q])];return $?yn(b)?Bn($).childNodes[u.base.indexIn(b.parentNode,b)]||null:r($)[r(b.parent).indexOf(b)]||null:null},m=new Map,k=new Map,g=new WeakMap,h=0,y=(K,b)=>{let C=m.get(K);C||m.set(K,C=[]),C.push(b)};(function K(b){k.set(b,h++);let C=o.get(b);if(C&&!C.pinned){for(let L of[C.base,C.local,C.remote])if(L)if(Array.isArray(L))for(let $ of L)y($,b);else y(L,b)}if(us(b)){g.set(b.content,b);for(let L=b.content.firstChild;L;L=L.nextSibling)K(L)}for(let L=b.firstChild;L;L=L.nextSibling)K(L)})(d);let A=new Map;u.out=Tr(d,g,A);let w={refs:new Map,spans:new Map,anchors:new Map,via:A,outOwners:g,outRoot:d,localRoot:e.roots.local},v=K=>yn(K)?[K]:K.nodes,E=(K,b)=>{let C=u[b].logicalParent(K);if(!C)return null;for(let L of r(C))if(!yn(L)&&L.nodes.includes(K))return L;return null},N=(K,b)=>K==null?null:Array.isArray(K)?K.length?E(K[0],b):null:K,_=K=>{let b=new Set,C=[];for(let L of K)for(let $ of m.get(L)||[])b.has($)||(b.add($),C.push($));return C.sort((L,$)=>k.get(L)-k.get($))},M=new Map,j=K=>{let b=K.b||K.l||K.r,C=M.get(b);if(C)return C;let L=[];for(let $ of[K.b,K.l,K.r])$&&L.push(...v($));return C=_(L),M.set(b,C),C},R=K=>({b:K,l:p(t,K),r:p(n,K)}),D=(K,b)=>{let C=f(b).reverse.get(K);if(C)return R(C);for(let L of _(v(K))){let $=o.get(L);if($&&!$.base&&$.local&&$.remote)return{b:null,l:N($.local,"local"),r:N($.remote,"remote")}}return b==="local"?{b:null,l:K,r:null}:{b:null,l:null,r:K}},B=new Map,S=K=>{let b=o.get(K);if(!b||b.pinned)return null;let C=N(b.base,"base");if(C)return R(C);let L=N(b.local,"local"),$=N(b.remote,"remote");if(L){let Q=t.reverse.get(L);if(Q)return R(Q)}if($){let Q=n.reverse.get($);if(Q)return R(Q)}return L||$?{b:null,l:L,r:$}:null},T=K=>(B.has(K)||B.set(K,S(K)),B.get(K)),J=(K,b)=>yn(K)?u[b].logicalParent(K):K.parent,q=new Map,V=new Map,Ce=(K,b)=>(yn(K)?[u[b].pathOf(K)]:K.nodes.map(C=>u[b].pathOf(C))).filter(Boolean),Me=K=>{let b=K.b||K.l||K.r,C=K.b?"base":K.l?"local":"remote",L=V.get(b);if(L)return L;let $=!yn(b),Q=Ce(b,C)[0],F=`${C[0]}:${JSON.stringify(Q===void 0?null:Q)}${$?":run":""}`,he=q.get(F);if(he)return V.set(b,he),he;let ke=j(K);return he={key:F,nodeType:yn(b)?1:b.kind==="comment"?8:3,base:K.b?Ce(K.b,"base"):[],local:K.l?Ce(K.l,"local"):[],remote:K.r?Ce(K.r,"remote"):[],merged:ke.map(ie=>u.out.pathOf(ie)).filter(Boolean),live:[]},q.set(F,he),V.set(b,he),w.refs.set(he,ke),he},Fe={base:new Map,local:new Map,remote:new Map},ce=new Map,Ae=(K,b)=>{let C=J(K,b);if(!C||C.nodeType!==1)return null;let L=Fe[b].get(C);if(!L){let Q=r(C),F=he=>Me(b==="base"?R(he):D(he,b));L={parent:F(C),refs:Q.map(F),index:new Map(Q.map((he,ke)=>[he,ke]))},Fe[b].set(C,L)}let $=L.index.get(K)??-1;return{parent:L.parent,before:L.refs.slice($+1),after:L.refs.slice(0,Math.max(0,$)).reverse()}},Ue=K=>{let b=K.parentNode;if(!b)return null;let C=ce.get(b);if(!C){let $=b.nodeType===11?g.get(b):b,Q=$&&$.nodeType===1?T($):null;if(!Q)return null;let F=[],he=[],ke=new Map;for(let Ne of b.childNodes){let U=T(Ne),Y=U&&Me(U),pe=F.length,ye=F.length-1;Y&&Y!==F[ye]&&(F.push(Y),ye++);let me={ref:Y,group:ye,after:pe};he.push(me),ke.set(Ne,me)}let ie=F.length;for(let Ne=he.length-1;Ne>=0;Ne--){let U=he[Ne];U.before=ie,U.ref&&(ie=U.group)}C={parent:Me(Q),refs:F,index:ke},ce.set(b,C)}let L=C.index.get(K);return{parent:C.parent,before:C.refs.slice(L.before),after:C.refs.slice(0,L.after).reverse()}},_e=K=>yn(K)?K.outerHTML:K.value,O=K=>yn(K)?"element":K.kind==="comment"?"comment":"text",X=(K,b)=>({path:K,offset:b}),le=(K,b,C)=>{if(!K)return null;let L=u[C],$=0;if(b){let Q=yn(b)?b:b.nodes[b.nodes.length-1];Q.parentNode&&($=L.indexIn(Q.parentNode,Q)+1)}return X(L.containerPath(K),$)},re=(K,b)=>{let C=J(K,"base"),L=C?p(f(b),C):null;if(!yn(L))return null;let $=r(C),Q=null;for(let F=$.indexOf(K)-1;F>=0&&!Q;F--){let he=p(f(b),$[F]);he&&J(he,b)===L&&(Q=he)}return le(L,Q,b)},Pe=(K,b,C,L)=>{let $=u[L],Q=0;for(let F=0;F<K.nodes.length;F++){let he=K.nodes[F],ke=he.nodeValue.length,ie=F===K.nodes.length-1;if((C==="start"?b<Q+ke:b<=Q+ke)||ie)return X($.pathOf(he),Math.max(0,Math.min(b-Q,ke)));Q+=ke}return null},Be=(K,b)=>{let C=u[b],L=K.firstChild,$=K.lastChild;return L&&L.nodeType===3&&$.nodeType===3?{start:X(C.pathOf(L),0),end:X(C.pathOf($),$.nodeValue.length)}:{start:X(C.pathOf(K),0),end:X(C.pathOf(K),K.childNodes.length)}},Te=(K,b,C)=>{for(let F of K.nodes)if(C==="start"?F.s<=b&&b<F.e:F.s<b&&b<=F.e)return{kind:"text",node:F.node,offset:b-F.s};let L=C==="start"?b:b-1,$=()=>{for(let F of K.nodes)if(F.s===b||F.e===b)return{kind:"text",node:F.node,offset:b-F.s};return null},Q=K.atomAt.get(L);if(Q)return{kind:C==="start"?"before":"after",node:Q.el};if(K.text[L]===Ot){let F=K.marks.find(ke=>ke.block&&ke.to===L+1);if(F)return C==="start"?{kind:"end",node:F.el}:{kind:"after",node:F.el};let he=K.marks.find(ke=>ke.block&&ke.from===L+1);if(he)return C==="start"?{kind:"before",node:he.el}:{kind:"startOf",node:he.el}}return $()},ot=(K,b)=>Te(K,b,"end")||Te(K,b,"start"),et=(K,b)=>{switch(b.kind){case"text":return X(K.pathOf(b.node),b.offset);case"end":return X(K.containerPath(b.node),Bn(b.node).childNodes.length);case"startOf":return X(K.containerPath(b.node),0);default:{let C=b.node.parentNode;return X(K.containerPath(C),K.indexIn(C,b.node)+(b.kind==="after"?1:0))}}},ae=(K,b,C,L,$)=>{let Q=Te(K,b,C);return Q?et(u[L],Q):$()},de=(K,b,C,L)=>{let $=K.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,Ne]of K.atomOut)$.push({s:ie,e:ie+1,start:{kind:"before",node:Ne},end:{kind:"after",node:Ne}});for(let[ie,Ne]of K.breakOut)$.push({s:ie,e:ie+1,start:{kind:"end",node:Ne},end:{kind:"after",node:Ne}});for(let ie of $)if(ie.start.kind==="text"&&ie.s<b&&b<ie.e)return{kind:"text",node:ie.start.node,offset:b-ie.s};if(C!=="empty"){let ie=$.find(Ne=>C==="start"?Ne.s===b:Ne.e===b);if(ie)return C==="start"?ie.start:ie.end}let Q=$.find(ie=>ie.e===b);if(Q)return Q.end;let F=$.find(ie=>ie.s===b);if(F)return F.start;let he=null,ke=null;for(let ie of $)ie.e<=b&&(!he||ie.e>he.e)&&(he=ie),ie.s>=b&&(!ke||ie.s<ke.s)&&(ke=ie);return he?he.end:ke?ke.start:L()},Ee=(K,b)=>{if(!b)return null;if(b.kind==="text"){let $=K.nodes.find(Q=>Q.node===b.node);return $?$.s+Math.min(b.offset,$.e-$.s):null}let C=K.atoms.find($=>$.el===b.node);if(C)return b.kind==="after"?C.i+1:C.i;let L=K.marks.find($=>$.el===b.node);return L?b.kind==="before"&&L.block&&K.text[L.from-1]===Ot&&!K.marks.some($=>$.block&&$.to===L.from)?L.from-1:b.kind==="startOf"||b.kind==="before"?L.from:b.kind==="end"&&L.block?L.to-1:L.to:null},Ge=(K,b,C,L)=>{for(let he of K.nodes)if(C==="start"?he.s<=b&&b<he.e:he.s<b&&b<=he.e)return{kind:"text",node:he.node,offset:b-he.s};let $=C==="start"?b:b-1;if(!K.atomAt.has($)&&K.text[$]!==Ot){for(let he of K.nodes)if(he.s===b||he.e===b)return{kind:"text",node:he.node,offset:b-he.s}}let Q=K.atomAt.get($);if(Q)return{kind:C==="start"?"before":"after",node:Q.el};if(K.text[$]===Ot){let he=K.marks.find(ie=>ie.block&&ie.to===$+1);if(he)return C==="start"?{kind:"end",node:he.el}:{kind:"after",node:he.el};let ke=K.marks.find(ie=>ie.block&&ie.from===$+1);if(ke)return C==="start"?{kind:"before",node:ke.el}:{kind:"startOf",node:ke.el}}let F=K.marks.find(he=>he.block&&he.from===b);return F?{kind:"startOf",node:F.el}:L?{kind:C==="start"?"startOf":"end",node:L}:null},Ve=K=>{if(!K)return null;if(K.kind==="wholeStart"||K.kind==="wholeEnd"){let b=ze(K.node);return K.kind==="wholeStart"?b.start:b.end}return et(u.out,K)},ze=K=>{let b=K.firstChild,C=K.lastChild;return b&&b.nodeType===3&&C.nodeType===3?{start:X(u.out.pathOf(b),0),end:X(u.out.pathOf(C),C.nodeValue.length)}:{start:X(u.out.pathOf(K),0),end:X(u.out.pathOf(K),K.childNodes.length)}},lt=K=>{let b=J(K,"base"),C=b?j(R(b))[0]:null;if(!C)return null;let L=Bn(C),$=r(b);for(let Q=$.indexOf(K)-1;Q>=0;Q--){let F=j(R($[Q])).filter(he=>he.parentNode===L);if(F.length)return{kind:"after",node:F[F.length-1]}}return{kind:"startOf",node:C}},pt=(K,b,C,L,$,Q)=>({text:K,start:b,end:C,fragment:L,span:$,scope:Q}),Rt=(K,b,C,L,$)=>pt(K,b,C,K.slice(b,C),L,$),dt=(K,b,C,L,$)=>(w.spans.set(K,{start:b,end:C,scopeStart:L,scopeEnd:$}),K),vt=new Map,gt=new Map,kn=(K,b,C)=>{let L=`text:${K.key}:${b}:${C}`,$=gt.get(L)||0;return gt.set(L,$+1),`${L}:${$}`},Ft=(K,b)=>{let C,L,$,Q="plain",F,he,ke,ie,Ne,U=(ye,me,ee,te,W)=>{if(!ye){let ne=re(W,te);return Rt("",0,0,{start:ne,end:ne},{start:ne,end:ne})}return Rt(ye.value,me,ee,{start:Pe(ye,me,me===ee?"end":"start",te),end:Pe(ye,ee,"end",te)},{start:Pe(ye,0,"start",te),end:Pe(ye,ye.value.length,"end",te)})};if(b.site==="run"){let{bRun:ye,lRun:me,rRun:ee,node:te,c:W}=b;C=R(ye),L=W.bs,$=W.be,F=U(ye,W.bs,W.be,"base",ye),he=U(me,W.ls,W.le,"local",ye),ke=U(ee,W.rs,W.re,"remote",ye);let ne=te?te.nodeValue:"",we=Ie=>te?{kind:"text",node:te,offset:Ie}:lt(ye);ie=dt(Rt(ne,W.ms,W.me,{start:Ve(we(W.ms)),end:Ve(we(W.me))},{start:Ve(we(0)),end:Ve(we(ne.length))}),we(W.ms),we(W.me),we(0),we(ne.length)),Ne=te||(lt(ye)||{}).node||null}else if(b.site==="whole"){let ye=b.el,me=o.get(ye);C=R(me.base),L=0,$=K.base.length;let ee=(W,ne,we)=>{let Ie=Be(ne,we);return Rt(W,0,W.length,Ie,Ie)};F=ee(K.base,me.base,"base"),he=ee(K.local,me.local,"local"),ke=ee(K.remote,me.remote,"remote");let te=ze(ye);ie=dt(Rt(K.resolved,0,K.resolved.length,te,te),{kind:"wholeStart",node:ye},{kind:"wholeEnd",node:ye},{kind:"wholeStart",node:ye},{kind:"wholeEnd",node:ye}),Ne=ye}else if(b.site==="comment"){let{bRun:ye,lRun:me,rRun:ee,node:te}=b;C=R(ye),L=0,$=K.base.length;let W=(je,Se)=>{if(!je){let st=re(ye,Se);return Rt("",0,0,{start:st,end:st},{start:st,end:st})}let Je=je.nodes[0],nt={start:X(u[Se].pathOf(Je),0),end:X(u[Se].pathOf(Je),je.value.length)};return Rt(je.value,0,je.value.length,nt,nt)};F=W(ye,"base"),he=W(me,"local"),ke=W(ee,"remote");let ne=K.resolved,we=je=>te?{kind:"text",node:te,offset:je}:lt(ye),Ie={start:Ve(we(0)),end:Ve(we(ne.length))};ie=dt(Rt(ne,0,ne.length,Ie,Ie),we(0),we(ne.length),we(0),we(ne.length)),Ne=te||(lt(ye)||{}).node||null}else{let{fb:ye,fl:me,fr:ee,scope:te}=b,W=b.merged;Q="html",C=te.base?R(te.base):D(te.local,"local"),L=K.bs,$=K.be;let ne=oe=>{let Re=te[oe];for(let De=te.at-1;De>=0;De--){let We=te.units[De],Ye=oe==="base"?We:p(f(oe),We);if(Ye&&J(Ye,oe)===Re)return Ye}return null},we=oe=>()=>le(te[oe],ne(oe),oe),Ie=(oe,Re,De,We,Ye)=>{let wt=En=>En?et(u[Ye],En):we(Ye)(),at=Re===De?ot(oe,Re):Te(oe,Re,"start"),Wt=Re===De?ot(oe,Re):Te(oe,De,"end"),zt=wt(at),bn={start:zt,end:Re===De?zt:wt(Wt)},Tt=b.full?b.full(Ye):null;if(!Tt)return pt(oe.text,Re,De,We,bn,{start:wt(Te(oe,0,"start")),end:wt(Te(oe,oe.text.length,"end"))});let ht=at?Ee(Tt,at):null,Qe=Wt?Ee(Tt,Wt):null,Mt=ht===null?0:ht,bt=Math.max(Mt,Qe===null?Tt.text.length:Qe),Ut=wt(Te(Tt,0,"start"));return pt(Tt.text,Mt,bt,Br(Tt,Mt,bt),bn,{start:Ut,end:Tt.text.length?wt(Te(Tt,Tt.text.length,"end")):Ut})};F=b.synthetic?null:Ie(ye,K.bs,K.be,K.base,"base"),he=Ie(me,K.lss,K.lse,K.local,"local"),ke=Ie(ee,K.rss,K.rse,K.remote,"remote");let[je,Se]=K.range||[0,0],Je=W.out,nt=()=>{let oe=Bn(W.node);for(let Re=te.at-1;Re>=0;Re--){let De=j(R(te.units[Re])).filter(We=>We.parentNode===oe);if(De.length)return{kind:"after",node:De[De.length-1]}}for(let Re=te.at;Re<te.units.length;Re++){let De=j(R(te.units[Re])).filter(We=>We.parentNode===oe);if(De.length)return{kind:"before",node:De[0]}}return{kind:"startOf",node:W.node}};if(Je.via)for(let[oe,Re]of Je.via)A.set(oe,Re);let st=de(W,je,je===Se?"empty":"start",nt),$t=je===Se?st:de(W,Se,"end",nt),Bt=Je.text.length?Ge(Je,0,"start",W.node):nt(),I=Je.text.length?Ge(Je,Je.text.length,"end",W.node):Bt,G=Ee(Je,st),se=Ee(Je,$t),be=G===null?0:G,xe=Math.max(be,se===null?Je.text.length:se);ie=dt(pt(Je.text,be,xe,Br(Je,be,xe),{start:Ve(st),end:Ve($t)},{start:Ve(Bt),end:Ve(I)}),st,$t,Bt,I);let fe=w.spans.get(ie);if(fe.flat=Je,!Je.text.length){let oe=Ve(Bt),Re=Ar(d,oe),De=Re[0],We=Re[1];fe.empty={parent:De.nodeType===11?g.get(De):De,previous:De.childNodes[We-1]||null,next:De.childNodes[We]||null}}Ne=st?st.node:W.node}let Y=Me(C),pe=(b.site==="whole"||b.site==="comment"||(b.policy||s)!=="both")&&K.resolved!==K.local;return{key:b.site==="comment"&&vt.get(C.b||C.l||C.r)||kn(Y,L,$),subject:Y,localLost:pe,anchor:Ne,text:{encoding:Q,base:F,local:he,remote:ke,merged:ie,liveSpan:null,liveScope:null}}},Qt=(K,b)=>{let C=T(b.el),L=Me(C),$=b.sample;return{key:`attr:${L.key}:${$.namespaceURI||""}:${$.localName}`,subject:L,localLost:K.resolved!==K.local,anchor:b.el,attribute:{namespaceURI:$.namespaceURI||null,localName:$.localName,qualifiedName:$.name}}},Yt=(K,b)=>{let C=K.detail,L=b.unit||R(b.subject),$=Me(L),Q=w.refs.get($),F=L.l?Ae(L.l,"local"):null,he=L.r?Ae(L.r,"remote"):null,ke=Q.length?Ue(Q[0]):null,ie,Ne,U,Y=null,pe=null,ye=b.deleted;switch(C){case"both-reordered":{ie=Ne="reordered";let me=new Set(b.rKept),ee=b.lKept.filter(Ie=>me.has(Ie)&&j(R(Ie)).length),te=Ie=>k.get(j(R(Ie))[0]);Y=ee.map(Ie=>Me(R(Ie))),pe=ee.slice().sort((Ie,je)=>te(Ie)-te(je)).map(Ie=>Me(R(Ie)));let W=Ie=>!yn(Ie)&&Ie.kind!=="comment"&&Ie.nodes.every(je=>!/[^\t\n\f\r ]/.test(je.data)),ne=ee.filter(Ie=>!W(Ie)),we=ne.slice().sort((Ie,je)=>te(Ie)-te(je));U=ne.some((Ie,je)=>Ie!==we[je]);break}case"both-moved":ie=Ne="moved",U=!F||!Q.some(me=>{let ee=me===Q[0]?ke:Ue(me);return ee&&ee.parent===F.parent});break;case"edit-beats-delete":ie=ye==="local"?"deleted":"edited",Ne=ye==="remote"?"deleted":"edited",U=ye==="local";break;case"move-beats-delete":ie=ye==="local"?"deleted":"moved",Ne=ye==="remote"?"deleted":"moved",U=ye==="local";break;case"remote-wins":ie="edited",Ne="edited",U=!0;break;default:ie=Ne="inserted",U=b.localLost}return{key:`structure:${$.key}:${C}`,subject:$,localLost:U,anchor:Q[0]||null,structure:{localAction:ie,remoteAction:Ne,localPlacement:F,remotePlacement:he,mergedPlacement:ke,localOrder:Y,mergedOrder:pe,localFragment:C==="both-reordered"||!L.l?null:_e(L.l),fragmentKind:O(L.b||L.l||L.r)}}};for(let[K,b]of i){if(K.kind!=="structure")continue;let C=b.unit||R(b.subject),L=C.b||C.l||C.r;!yn(L)&&L.kind==="comment"&&vt.set(L,`structure:${Me(C).key}:${K.detail}`)}let gn=new Map;for(let[K,b]of i){if(K.kind==="structure"){let Q=Me(b.unit||R(b.subject)),F=`structure:${Q.key}:${K.detail}`,he=gn.get(F);if(he&&he.structure){K.recovery=he;let ke=w.refs.get(Q);K.el==null&&ke.length&&(K.el=yn(ke[0])?ke[0]:u.out.logicalParent(ke[0]));continue}}let C=K.kind==="text"?Ft(K,b):K.kind==="attr"?Qt(K,b):Yt(K,b),L=gn.get(C.key);L||(L={version:Dd,key:C.key,localLost:C.localLost,subject:C.subject,applied:!1,unavailable:null},gn.set(C.key,L),w.anchors.set(L,C.anchor)),C.text&&(L.text=C.text),C.attribute&&(L.attribute=C.attribute),C.structure&&(L.structure=C.structure),C.text&&(L.localLost=C.localLost),K.recovery=L;let $=w.refs.get(C.subject);K.kind==="structure"&&K.el==null&&$.length&&(K.el=yn($[0])?$[0]:u.out.logicalParent($[0])),K.kind==="text"&&K.node==null&&$.length&&C.subject.nodeType===8&&(K.node=$[0])}return w}}function Pa(e,t,n){if(!t)return;let{lookup:r,vetoed:o,vetoedAttrs:s,liveAttr:i}=n,l=n.ignored||(()=>!1),a=Tr(n.liveRoot),c=S=>!!S&&a.containerPath(S)!==null,d=S=>{let T=S.parentNode;return T&&T.nodeType===11?t.outOwners.get(T)||null:T},u=S=>{for(let T=S;T;T=d(T))if(t.via.has(T)&&(T=t.via.get(T)),o.has(T)||n.vetoedLive?.has(h(T)))return!0;return!1},f=S=>Array.from(Bn(S).children).filter(T=>!l(T)),p=(S,T)=>f(S)[f(T.parentNode).indexOf(T)],m=(S,T)=>{let J=null,q=null,V=0;for(let ce=T.previousSibling;ce;ce=ce.previousSibling){if(ce.nodeType===1&&!l(ce)){J=ce;break}ce.nodeType===3&&(V+=ce.nodeValue.length)}for(let ce=T.nextSibling;ce&&!q;ce=ce.nextSibling)ce.nodeType===1&&!l(ce)&&(q=ce);let Ce=J?p(S,J):null,Me=q?p(S,q):null;if(J&&!Ce||q&&!Me)return null;let Fe=[];for(let ce=Ce?Ce.nextSibling:Bn(S).firstChild;ce&&ce!==Me;ce=ce.nextSibling)ce.nodeType===3&&Fe.push(ce);return Fe.length?{nodes:Fe,lead:V}:null},k=S=>{let T=[],J=S;for(;J&&!t.via.has(J);J=J.parentNode)T.push(J);if(!J||!T.length)return null;let q=h(t.via.get(J));for(let Me=T.length-1;Me>0&&q;Me--)q=p(q,T[Me]);if(!q)return null;let V=T[0];if(V.nodeType===3)return m(q,V);let Ce=V.nodeType===1?p(q,V):null;return Ce?{nodes:[Ce],lead:0}:null},g=S=>{let T=r(S),J=T?{nodes:Array.isArray(T)?T:[T],lead:0}:t.via.size?k(S):null;if(!J)return null;let q=J.nodes.filter(c);return q.length?{nodes:q,lead:J.lead}:null},h=S=>{let T=g(S);return T?T.nodes[0]:null},y=S=>{if(!S)return null;if(S.kind==="text"){let V=g(S.node);if(!V)return null;let Ce=V.nodes,Me=S.offset+V.lead,Fe=0;for(let ce=0;ce<Ce.length;ce++){let Ae=Ce[ce].nodeValue.length;if(Me<=Fe+Ae||ce===Ce.length-1)return Me>=Fe&&Me<=Fe+Ae?[Ce[ce],Me-Fe]:null;Fe+=Ae}return null}let T=h(S.node);if(!T)return null;if(S.kind==="end")return[Bn(T),Bn(T).childNodes.length];if(S.kind==="startOf")return[Bn(T),0];if(S.kind==="wholeStart")return T.firstChild?[T.firstChild,0]:[T,0];if(S.kind==="wholeEnd")return T.lastChild?[T.lastChild,T.lastChild.nodeValue.length]:[T,T.childNodes.length];let J=T.parentNode;if(!J)return null;let q=Array.prototype.indexOf.call(J.childNodes,T);return[J,S.kind==="after"?q+1:q]},A=S=>({blocks:new Set((S.flat?.marks||[]).filter(T=>T.block).map(T=>h(T.el)).filter(Boolean)),atoms:new Set((S.flat?.atoms||[]).map(T=>h(T.el)).filter(Boolean)),ignored:l}),w=(S,T,J,q)=>{if(!S||!T||!Sr(S)||!Sr(T))return!1;for(let Me of[S,T])if(!c(Me.startContainer)||!c(Me.endContainer))return!1;let V=J.merged;if(V.start===V.end&&(S.startContainer!==S.endContainer||S.startOffset!==S.endOffset))return!1;let Ce=A(q);return fr(T,J.encoding,Ce)===V.text&&fr(S,J.encoding,Ce)===V.text.slice(V.start,V.end)},v=new Map,E=S=>{let T=S.parentNode;return T?(v.has(T)||v.set(T,new Map(Array.from(T.childNodes,(J,q)=>[J,q]))),v.get(T).get(S)):-1},N=(S,T)=>{if(!T)return!1;let J=a.logicalParent(S);if(!T.parent.live.includes(J))return!1;let q=E(S);for(let[V,Ce]of[["before",1],["after",-1]]){let Me=q;for(let Fe of T[V]){if(Fe.live.includes(S))continue;let ce=Fe.live.filter(Ue=>Ue!==S&&Ue.parentNode===S.parentNode);if(!ce.length)continue;let Ae=Ce===1?Math.min(...ce.map(E)):Math.max(...ce.map(E));if(Ce*(Ae-Me)<=0)return!1;Me=Ae}}return!0},_=S=>{let T=S.structure;if(T.mergedOrder){let J=new Set(S.subject.live.map(Bn)),q=null,V=-1;for(let Ce of T.mergedOrder){let Me=Ce.live.find(Fe=>J.has(Fe.parentNode));if(!Me||q&&Me.parentNode!==q||E(Me)<=V)return!1;q=Me.parentNode,V=E(Me)}return S.subject.live.length>0}return S.subject.live.some(J=>N(J,T.mergedPlacement))},M=(S,T)=>{let J=y(S),q=y(T);return J&&q?{startContainer:J[0],startOffset:J[1],endContainer:q[0],endOffset:q[1]}:null},j=new Set,R=S=>{if(!S||j.has(S))return;j.add(S);let T=[];for(let J of t.refs.get(S)||[]){let q=g(J);if(q)for(let V of q.nodes)T.includes(V)||T.push(V)}S.live=T},D=S=>{S&&(R(S.parent),S.before.forEach(R),S.after.forEach(R))},B=new Set;for(let S of e){let T=S.recovery;if(!T||B.has(T))continue;B.add(T),R(T.subject),T.structure&&(D(T.structure.localPlacement),D(T.structure.remotePlacement),D(T.structure.mergedPlacement),(T.structure.localOrder||[]).forEach(R),(T.structure.mergedOrder||[]).forEach(R));let J=t.anchors.get(T),q=J?h(J):null,V=!!q;if(T.text){let O=t.spans.get(T.text.merged),X=O?M(O.start,O.end):null,le=O?M(O.scopeStart,O.scopeEnd):null;if(O?.empty){let re=O.empty,Pe=re.previous?{kind:"after",node:re.previous}:{kind:"startOf",node:re.parent},Be=re.next?{kind:"before",node:re.next}:{kind:"end",node:re.parent},Te=M(Pe,Be);!Te||Te.startContainer!==Te.endContainer||Te.startOffset!==Te.endOffset?X=null:X=le=Te}w(X,le,T.text,O)||(X=le=null),T.text.liveSpan=X,T.text.liveScope=X?le:null,X||(V=!1)}T.structure&&V&&(V=_(T)),T.attribute&&V&&(V=i(q,T.attribute,S.resolved));let Ce=(!!T.attribute||!!T.text&&q?.tagName==="TEXTAREA")&&!!s&&[J,q].some(O=>s.get(O)?.has(T.attribute?T.attribute.qualifiedName:"value")),Me=t.localState?.states.get(T),Fe=!!T.text&&[...n.removedVetoes||[]].some(O=>Me?.touched.has(O)),ce=T.structure?.localAction==="inserted"&&[...o].some(O=>O===J||J?.contains(O)),Ae=J&&u(J)||Ce||Fe||ce,Ue=Ae&&Ia(T,S,t,c);Ue&&(Fe||ce&&T.localLost)&&(V=!1);let _e=!V&&Ue&&Ae;T.applied=V,T.unavailable=V?null:_e?"hook-veto":"missing-output",_e&&(T.localLost=!1),!V&&T.text&&(T.text.liveSpan=T.text.liveScope=null)}}function ds(e,t,n){let r=Tr(t),o=Tr(n),s=u=>!!u&&o.containerPath(u)!==null,i=u=>{if(u===t)return n;let f=r.pathOf(u);if(f&&t!==n){let p=Ar(n,{path:f,offset:0});if(p&&p[0].nodeType===u.nodeType)return p[0]}return u},l=new Set,a=u=>{!u||l.has(u)||(l.add(u),u.live=u.live.map(i).filter(s))},c=u=>{u&&(u.startContainer=i(u.startContainer),u.endContainer=i(u.endContainer))},d=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||d.has(f))continue;if(d.add(f),a(f.subject),f.text){c(f.text.liveSpan),c(f.text.liveScope);let m=f.text.liveSpan,k=f.text.liveScope,g=f.text.merged,h=y=>!!y&&Sr(y)&&s(y.startContainer)&&s(y.endContainer);(!h(m)||!h(k)||fr(k,f.text.encoding)!==g.text||fr(m,f.text.encoding)!==g.text.slice(g.start,g.end))&&(f.text.liveSpan=null,f.text.liveScope=null,f.applied=!1,f.unavailable="missing-output")}let p=f.structure;if(p){for(let m of[p.localPlacement,p.remotePlacement,p.mergedPlacement])m&&(a(m.parent),m.before.forEach(a),m.after.forEach(a));(p.localOrder||[]).forEach(a),(p.mergedOrder||[]).forEach(a),f.subject.live.length||(f.applied=!1,f.unavailable="missing-output")}}}var zr=e=>e?.nodeType===1,Eo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function Fd({provenance:e,parentOf:t,twins:n,baseOf:r,build:o,ignored:s,remoteWins:i,discarded:l}){let a=new Map,c=new WeakMap;function d(p,m,k,g=!1){if(!zr(p)||!zr(k))return null;let h=a.get(p);if(h)(g||!h.selected&&m==="remote")&&(h.parent=t(k),h.port=k,h.sourceSide=m,h.selected=g);else{let y=c.get(p)||null;h={owner:p,parent:t(k),port:k,sourceSide:m,originalParent:t(p),originalPort:p,selected:g,state:y?"built":"planned",output:y,disposition:null},a.set(p,h)}return h}function u(p,m){if(!zr(p)||!zr(m))return;c.has(p)||c.set(p,m);let k=a.get(p);k&&k.state!=="attached"&&!k.output&&(k.output=m,k.state="built")}function f(p){if(!a.size)return;let m=new Map,k=new WeakMap,g=new WeakMap,h=new WeakSet,y=new Set,A=(D,B)=>{if(!D)return;if(Array.isArray(D)){for(let T of D)A(T,B);return}let S=m.get(D);S||m.set(D,S=[]),S.push(B)},w=(D,B)=>{if(!D)return;let S=[D];for(;S.length;){let T=S.pop();A(T,B);for(let J of Eo(T).childNodes)S.push(J)}};function v(D,B=null,S=!1){if(h.has(D))return;h.add(D),k.set(D,B);let T=e.get(D),J=S||!!(T&&i(T.remote||T.base));g.set(D,J);let q={node:D,kind:"node",authority:J};if(T?.pinned)w(T.local,{...q,kind:"ignored"});else if(T?.unchanged)for(let V of[T.base,T.local,T.remote])w(V,{...q,kind:"unchanged"});else if(T){for(let V of[T.base,T.local,T.remote])A(V,q);if(zr(T.local))for(let V of Eo(T.local).children)s(V)&&w(V,{...q,kind:"ignored"})}for(let V of Eo(D).childNodes)v(V,D,J)}let E=D=>{if(D.output&&h.has(D.output))return D.state="attached",D.disposition="node",!0;let{local:B,remote:S}=n(D.owner);for(let T of[D.owner,B,S]){let J=m.get(T);if(J?.length){let q=J.find(V=>V.kind==="node")||J[0];return D.output=q.node,D.state="attached",D.disposition=q.kind,!0}}return!1},N=(D,B)=>(m.get(D)||[]).find(T=>T.kind==="node"&&zr(T.node)&&(!T.authority||B.sourceSide==="remote"))?.node,_=(D,B,S)=>{let T=m.get(D)||[],J=S?[...T].reverse():T;for(let q of J){if(q.kind!=="node")continue;let V=q.node;for(;V&&k.get(V)!==B;)V=k.get(V);if(V)return V}return null},M=(D,B,S)=>{let T=Eo(B);for(let J=S?.previousSibling;J;J=J.previousSibling){let q=_(J,B,!0);if(q){T.insertBefore(D,q.nextSibling);return}}for(let J=S?.nextSibling;J;J=J.nextSibling){let q=_(J,B,!1);if(q){T.insertBefore(D,q);return}}T.appendChild(D)};function j(D,B,S){let T=B==="base"?D:r(D,B),J=a.get(T);J&&J!==S&&R(J)}function R(D){if(D.state==="attached"||D.disposition==="remote-wins"||y.has(D)||E(D))return;y.add(D);let{local:B,remote:S}=n(D.owner);if(i(S||D.owner)){if(!S){D.disposition="remote-wins",l(D.owner,B),y.delete(D);return}D.parent=t(S),D.port=S,D.sourceSide="remote"}if(j(D.parent,D.sourceSide,D),E(D)){y.delete(D);return}let T=N(D.parent,D),J=D.port;if(!T){if(j(D.originalParent,"base",D),E(D)){y.delete(D);return}let V=D.originalParent;for(J=D.originalPort;V&&!T;)T=N(V,D),T||(J=V,V=t(V))}if(!T)throw new Error("A planned move has no allowed surviving parent");let q=D.output||o(D.owner);D.output=q,D.state="built",M(q,T,J),v(q,T,g.get(T)||!1),E(D),y.delete(D)}v(p);for(let D of a.values())R(D)}return{planned:a,has:p=>a.has(p),plan:d,produced:u,drain:f}}function Vr(e,t,n,r,o,s,i,l,a,c,d,u,f){let p=null;return Fd({provenance:e,parentOf:g=>{if(!g)return null;let h=t(g);if(h||g.parentNode?.nodeType!==11)return h;if(!p){p=new WeakMap;let y=[u,f];for(;y.length;){let A=y.pop(),w=Eo(A);w!==A&&p.set(w,A);for(let v of w.children)y.push(v)}}return p.get(g.parentNode)||null},twins:g=>({local:o(n,g),remote:o(r,g)}),baseOf:(g,h)=>g&&(h==="local"?n:r).reverse.get(g)||null,build:g=>s(g,o(n,g),o(r,g),!1),ignored:i,remoteWins:l,discarded:(g,h)=>{h&&d(g,h,n)&&!a.some(y=>y.detail==="remote-wins"&&y.base===g)&&c({kind:"structure",el:null,detail:"remote-wins",base:g,local:h,remote:null},{subject:g})}})}function Bd({parent:e,base:t,views:n,eligible:r,ignored:o,remoteWins:s,budget:i=Zt(2e4*32),maxUnits:l=256,maxCharacters:a=2e4}){let c=(h,y=null)=>({status:h,reason:y,parent:e,records:[]});if(n.some(({V:h})=>h.asBase)||o(e)||s(e)||n.some(({V:h})=>!h.el||o(h.el)||s(h.el)))return c("none");let d=t.length+n[0].V.units.length+n[1].V.units.length;if(d>l)return c("fallback","unit-limit");let u=Symbol(),f=h=>{if(h>i.remaining)throw u;i.remaining-=h,i.crossParentSteps=(i.crossParentSteps||0)+h},p=new Map,m=0,k=h=>{if(f(1),p.has(h))return p.get(h);let y=h.nodeType===1?h.childNodes:h.nodes;f(y.length*4+1);let A=h.nodeType===1?Array.from(y):y,w=0;for(let N=0;N<A.length;N++){let _=A[N];if(_.nodeType!==3||N&&A[N-1].nextSibling!==_)return p.set(h,null),null;w+=_.data.length}if(w>a-m)throw u;f(w*8+1),m+=w;let v=an(A);if(v.text.includes(Ot))return p.set(h,null),null;let E={unit:h,nodes:A,flat:v};return p.set(h,E),E},g=[];try{f(d*8+1);for(let h=0;h<2;h++){let y=n[h].V,A=n[1-h].V,w=[],v=new Map;for(let E=0;E<t.length;E++){f(1);let N=t[E];if(N.kind!=="text"||y.twin(N))continue;let _=A.twin(N);if(!_||_.kind!=="text"||!A.here(_))continue;let M=k(N),j=k(_);if(!M||!j||!/\S/.test(M.flat.text))continue;f(M.flat.text.length*2+1);let R=M.flat.text;v.set(R,(v.get(R)||0)+1),w.push({source:N,opposite:_,sourceModel:M,oppositeModel:j,index:E})}for(let E of w){let{source:N,opposite:_,sourceModel:M,oppositeModel:j,index:R}=E,D=[];for(let X of[-1,1]){f(1);let le=t[R+X];if(!le||le.nodeType!==1||!r(le)||o(le)||s(le))continue;let re=M.nodes[0],Pe=M.nodes.at(-1);if(X===-1?re?.previousSibling!==le:Pe?.nextSibling!==le)continue;let Be=y.twin(le),Te=A.twin(le);if(!Be||!Te||!y.here(Be)||A.here(Te)||y.baseOf(Be)!==le||A.baseOf(Te)!==le||!r(Be)||!r(Te)||o(Be)||o(Te)||s(Be)||s(Te)||Be.tagName!==le.tagName||Te.tagName!==le.tagName||Be.namespaceURI!==le.namespaceURI||Te.namespaceURI!==le.namespaceURI)continue;let ot=k(le),et=k(Be),ae=k(Te);if(!ot||!et||!ae||!/\S/.test(ot.flat.text))continue;let de=ot.flat.text,Ee=M.flat.text,Ge=et.flat.text;if(f((de.length+Ee.length+Ge.length)*3+1),Ge.length!==de.length+Ee.length)continue;let Ve=X===-1;(Ve?!Ge.startsWith(de)||!Ge.endsWith(Ee):!Ge.startsWith(Ee)||!Ge.endsWith(de))||D.push({owner:le,target:Be,moved:Te,ownerBase:ot,joined:et,ownerOther:ae,targetFrom:Ve?de.length:0,retainedFrom:Ve?0:Ee.length})}if(!D.length)continue;if(D.length!==1||v.get(M.flat.text)!==1)return c("fallback","ambiguous-origin");let B=D[0],{owner:S,target:T,moved:J,ownerBase:q,joined:V,ownerOther:Ce,targetFrom:Me,retainedFrom:Fe}=B;if(f(g.length+1),g.some(X=>X.owner===S))return c("fallback","ambiguous-owner");let ce={source:N,target:T,from:0,to:M.flat.text.length,targetFrom:Me},Ae=Gn({base:M.flat,side:V.flat,retained:[],transfers:[{from:ce.from,to:ce.to,target:Me,destination:S}],budget:i});if(Ae.status!=="ready"||Ae.covers(ce.from,ce.to)!==!0)return c("fallback",Ae.reason||"work-limit");let Ue=[{unit:N,model:M,from:0,to:M.flat.text.length},null,null];Ue[h+1]={unit:T,model:V,from:Me,to:Me+M.flat.text.length},Ue[2-h]={unit:_,model:j,from:0,to:j.flat.text.length};let _e=[q,null,null];_e[h+1]=V,_e[2-h]=Ce;let O=[S,null,null];O[h+1]=T,O[2-h]=J,g.push({side:h,parent:e,source:N,target:T,owner:S,owners:O,ownerModels:_e,native:Ue,models:p,runs:[ce],proof:Ae,retained:[{source:S,target:T,from:0,to:q.flat.text.length,targetFrom:Fe}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:c("none")}catch(h){if(h!==u)throw h;return c("fallback","work-limit")}}function ja({describe:e,parentOf:t,...n}){let r=new WeakMap,o=new WeakMap,s=n.budget||Zt(2e4*32),i=l=>{if(!l)return null;if(r.has(l))return r.get(l);r.set(l,{status:"planning",parent:l,records:[]});let a=e(l),c=a?Bd({...n,...a,parent:l,budget:s}):{status:"none",reason:null,parent:l,records:[]};if(r.set(l,c),c.status==="ready")for(let d of c.records)o.set(d.owner,[d]);return c};return{get:i,forOwner(l){return i(t(l))?.status==="ready"&&o.get(l)||null}}}function qd(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=(A,w)=>o?[...A.nodes,...w.nodes]:[...w.nodes,...A.nodes],i=e.ownerModels.reduce((A,w)=>A+w.flat.text.length,0)+n.flat.text.length+e.native[2].model.flat.text.length;if(i*8>t.remaining)return null;t.remaining-=i*8;let l={base:s(r,n),local:e.ownerModels[1].nodes,remote:s(e.ownerModels[2],e.native[2].model)},a=an(l.base),c=e.ownerModels[1].flat,d=an(l.remote),u=o?r.flat.text.length:0,f=o?0:n.flat.text.length,p=Gn({base:a,side:c,retained:e.retained.map(A=>({from:f+A.from,to:f+A.to,target:A.targetFrom})),transfers:e.runs.map(A=>({from:u+A.from,to:u+A.to,target:A.targetFrom,destination:e.owner})),budget:t});if(p.status!=="ready"||p.covers(0,a.text.length)!==!0)return null;let m=e.ownerModels[2].flat,k=e.native[2].model.flat,g=[];for(let[A,w,v,E]of[[r.flat,m,f,o?0:k.text.length],[n.flat,k,u,o?m.text.length:0]]){let N=Ni(A,A,w).remoteMap.bTo,_=-1;for(let M=0;M<A.text.length;M++){if(N[M]<0){_=-1;continue}let j=g.at(-1);_>=0&&j.to===v+M&&j.target+j.to-j.from===E+N[M]?j.to++:(g.push({from:v+M,to:v+M+1,target:E+N[M]}),_=M)}}let h=Gn({base:a,side:d,retained:g,transfers:[],budget:t});if(h.status!=="ready")return null;let y=Ni(a,c,d,{},{local:p,remote:h});return y.localEdits.hunks.length?null:(y.localMap=p,y.remoteMap=h,{nodes:l,prepared:y})}function Da({L:e,R:t,twinIn:n,unitsOf:r,view:o,parentOf:s,ignored:i,remoteWins:l,eligible:a,build:c,out:d,policy:u,provenance:f,textMappers:p,segments:m,conflicts:k,conflict:g,decisions:h}){let y=Zt(2e4*32),A=D=>{let B=0;for(let S=D;S;S=s(S))if(++B>64||S.nodeType===1&&(i(S)||l(S)))return!1;return!0},w=ja({parentOf:s,eligible:a,ignored:i,remoteWins:l,budget:y,describe(D){let B=n(e,D),S=n(t,D);return!B||!S||!A(D)||!A(B)||!A(S)?null:{base:r(D),views:[{A:e,V:o(e,B,D,!1)},{A:t,V:o(t,S,D,!1)}]}}}),v=new WeakSet,E=new WeakMap,N=new WeakSet,_=[];function M(D){if(!D||v.has(D))return;v.add(D);let B=w.get(D);if(B?.status==="ready")for(let S of B.records){if((D.tagName==="TEMPLATE"&&D.content?D.content:D).childNodes.length!==S.native[0].model.nodes.length+1||!S.owners.every(A))continue;let J=qd(S,y);if(!J)continue;let q={record:S,payload:J,state:"planned",output:null,result:null};E.set(S.owner,q),N.add(S.source),N.add(S.native[2].unit),_.push(q)}}function j(D,B){let S=E.get(D);if(!S)return!1;if(!S.result){if(S.result=is({...S.payload.nodes,prepared:S.payload.prepared,out:d,policy:u,provenance:f,textMappers:p,conflicts:k,conflict:g,decisions:h,node:B}),S.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");m.push(...S.result.segments),S.decision={kind:"text",node:B,source:"local"},h.push(S.decision)}return S.decision.node=B,B.replaceChildren(...S.result.nodes),S.output=B,S.state="built",!0}function R(D){if(!_.length)return;let B=new WeakSet,S=new WeakMap,T=new WeakMap,J=new WeakMap,q=Ae=>Ae.tagName==="TEMPLATE"&&Ae.content?Ae.content:Ae,V=(Ae,Ue)=>{if(!Ae)return;if(Array.isArray(Ae)){for(let O of Ae)V(O,Ue);return}let _e=J.get(Ae);_e||J.set(Ae,_e=[]),_e.push(Ue)},Ce=(Ae,Ue=null,_e=!1)=>{B.add(Ae),S.set(Ae,Ue);let O=f.get(Ae),X=_e||!!(O&&l(O.remote||O.base));if(T.set(Ae,X),O)for(let le of[O.base,O.local,O.remote])V(le,Ae);if(!(O?.pinned||O?.unchanged))for(let le of q(Ae).childNodes)Ce(le,Ae,X)},Me=Ae=>(J.get(Ae)||[]).find(Ue=>Ue.nodeType===1&&!T.get(Ue)&&!f.get(Ue)?.pinned&&!f.get(Ue)?.unchanged),Fe=(Ae,Ue)=>{for(let _e of J.get(Ae)||[]){let O=_e;for(;O&&S.get(O)!==Ue;)O=S.get(O);if(O)return O}return null},ce=(Ae,Ue,_e)=>{let O=q(Ue);for(let X=_e.nextSibling;X;X=X.nextSibling){let le=Fe(X,Ue);if(le){O.insertBefore(Ae,le);return}}for(let X=_e.previousSibling;X;X=X.previousSibling){let le=Fe(X,Ue);if(le){O.insertBefore(Ae,le.nextSibling);return}}O.appendChild(Ae)};Ce(D);for(let Ae of _){let{record:Ue}=Ae,_e=Me(Ue.owner)||Me(Ue.owners[1])||Me(Ue.owners[2]);if(_e)(!Ae.result||Ae.output!==_e||Ae.result.nodes.some(O=>!B.has(O)||S.get(O)!==_e)||_e.textContent!==Ae.result.text)&&(j(Ue.owner,_e),Ce(_e,S.get(_e),T.get(_e)));else{let O=Ue.parent,X=Ue.owner,le=null;for(;O&&!le;)le=Me(O),le||(X=O,O=s(O));if(!le)throw new Error("A cross-parent payload has no allowed surviving parent");_e=Ae.output||c(Ue.owner,Ue.owners[1],Ue.owners[2],!1),Ae.result||j(Ue.owner,_e),ce(_e,le,X),Ce(_e,le,T.get(le))}Ae.state="attached"}}return{ensureParent:M,ensureOwner(D){M(s(D))},consumes(D){return N.has(D)},render:j,drain:R}}var jn=/\S/,Fa=/[\p{L}\p{N}]/u;function Er(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 Di(e,t,n){for(let r=e.parentNode;r;r=r.parentNode)if(n(t,1),r.nodeType===11)return!1;return!0}function Ba(e,t,n,r,o){let s=n(e,r),i=n(t,r),l=null,a=null,c=null,d=null;o(r,s.length+i.length);for(let u of s)Fa.test(u.raw)&&(l||=u,a=u);for(let u of i)Fa.test(u.raw)&&(c||=u,d=u);return!!(l&&c&&(l.raw===c.raw||a.raw===d.raw))}function Ud({base:e,V:t,A:n,source:r,original:o,current:s,edited:i,destination:l,at:a,ownLength:c,eligible:d,model:u,tokensOf:f,budget:p,charge:m}){let k=o.flat.text,g=s.flat.text,h=i.flat.text,y=l.flat.text;if(m(p,k.length+g.length+y.length),k.startsWith(g)||k.endsWith(g))return!1;let A=jn.test(y.slice(0,a)),w=jn.test(y.slice(a+c));if(A===w)return!1;let v=A?0:a+c,E=A?a:y.length;for(;v<E&&!jn.test(y[v]);)v++;for(;E>v&&!jn.test(y[E-1]);)E--;let N=y.slice(v,E);if(Fn(N,y,f(l,p),p,m,!0)!==v)return!1;let _=Fn(N,k,f(o,p),p,m,!0);if(_<0)return!1;let M=_+N.length,j=!jn.test(k.slice(0,_)),R=!jn.test(k.slice(M));if(j===R||Fn(N,g,f(s,p),p,m,!1)>=0)return!1;let D=j?k.slice(M):k.slice(0,_),B=j?h.length-D.length:0;if(m(p,k.length+h.length),B<0||!jn.test(D)||Fn(D,h,f(i,p),p,m,!0)!==B||!jn.test(j?h.slice(0,B):h.slice(D.length)))return!1;for(let S of e){if(m(p,1),S===r||!Er(S,d,p,m))continue;let T=u(S,null,p);if(Fn(N,T.flat.text,f(T,p),p,m,!1)>=0)return!1}for(let S of t.units){if(m(p,1),S===s.unit||S===l.unit||!Er(S,d,p,m))continue;let T=u(S,n,p);if(Fn(N,T.flat.text,f(T,p),p,m,!1)>=0)return!1}return!0}function qa({base:e,views:t,side:n,attempt:r,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,charge:c,exhausted:d,limit:u}){if(u<=0)return null;let f=Zt(u),{V:p,A:m,idOf:k}=t[n],g=t[1-n],[h,y,A,w]=r,v=null;try{for(let E=h;E<=y;E++){c(f,1);let N=e[E];if(N.parentNode?.nodeType!==1||s.has(N)||m.identical.has(N)||g.A.identical.has(N)||!Er(N,o,f,c)||i(N))continue;let _=p.twin(N),M=g.V.twin(N);if(!_||!M||!p.here(_)||!g.V.here(M)||m.map.get(N)!==_||m.reverse.get(_)!==N||g.A.map.get(N)!==M||g.A.reverse.get(M)!==N||k(_)||g.idOf(M)||_.tagName!==N.tagName||M.tagName!==N.tagName||!Er(_,o,f,c)||!Er(M,o,f,c)||!Di(N,f,c)||!Di(_,f,c)||!Di(M,f,c))continue;let j=l(N,null,f),R=l(_,m,f),D=l(M,g.A,f),B=j.flat.text,S=R.flat.text,T=D.flat.text;if(c(f,B.length+S.length+T.length),!jn.test(B)||!jn.test(S)||!jn.test(T)||B===S||B===T||S===T||!Ba(j,R,a,f,c)||!Ba(j,D,a,f,c))continue;let J=null,q=!1;for(let Me=A;Me<=w;Me++){c(f,1);let Fe=p.units[Me],ce=p.baseOf(Fe);if(!ce||ce===N||s.has(ce)||ce.parentNode!==N.parentNode||Fe.parentNode!==_.parentNode||ce.tagName!==N.tagName||Fe.tagName!==N.tagName||m.map.get(ce)!==Fe||m.reverse.get(Fe)!==ce||i(ce)!==k(Fe)||!Er(ce,o,f,c)||!Er(Fe,o,f,c))continue;let Ae=l(ce,null,f),Ue=l(Fe,m,f),_e=Ae.flat.text,O=Ue.flat.text;if(c(f,_e.length),!jn.test(_e)||O.length<=_e.length)continue;let X=a(Ue,f),le=Fn(_e,O,X,f,c,!0);if(!(le<0||Fn(B,O,X,f,c,!0,le,le+_e.length)<0&&!Ud({base:e,V:p,A:m,source:N,original:j,current:R,edited:D,destination:Ue,at:le,ownLength:_e.length,eligible:o,model:l,tokensOf:a,budget:f,charge:c}))){if(J){q=!0;break}J=Fe}}if(!J||q)continue;let V=n===0?_:M,Ce=n===0?M:_;(v||=[]).push({source:N,local:V,remote:Ce,models:[j,n===0?R:D,n===0?D:R]})}}catch(E){if(E!==d)throw E}return v}var Jn=/\S/,Sn=/\s/,$d=/[\s\u001e]/g,Fi=/[^\s\p{P}\u001e\ufffc]/u;function Hd(e,t,n,r,o,s,i){let l=0;for(let a of e)i(s,1),a.nodeType===1&&!r.baseOf(a)&&l++;if(l<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;i(s,c.text.length*2+t.length+n.length);let d=new Uint8Array(c.text.length);for(let u of n)u.target===a&&d.fill(1,u.targetFrom,u.targetFrom+u.to-u.from);for(let u of t)u.target===a&&d.fill(1,u.targetFrom,u.targetFrom+u.to-u.from);for(let u=0;u<c.text.length;u++)if(!d[u]&&Jn.test(c.text[u]))return!0}return!1}function zd(e,t,n){let{source:r,models:o,retained:s,runs:i}=e,l=o.get(r).flat.text;n(t,l.length*2+s.length+i.length);let a=new Uint8Array(l.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 i)n(t,c.to-c.from),a.fill(1,c.from,c.to);for(let c=0;c<l.length;c++)if(!a[c]&&Jn.test(l[c]))return!1;return!0}function Vd(e,t,n,r,o,s,i,l,a,c){let d=s.get(e),u=s.get(t),f=d.flat.text,p=i.get(e);a(c,f.length*2+n.length);let m=f.length,k=0;for(let y=0;y<f.length;y++)!Sn.test(f[y])&&!p[y]&&(m=Math.min(m,y),k=y+1);if(m>=k)return null;for(let y=m;y<k;y++)if(!Sn.test(f[y])&&p[y])return null;let g=-1;for(let y of n)if(y.target===t&&y.from<=m&&y.to>m){g=y.targetFrom+m-y.from;break}if(g<0)return null;let h=f.slice(m,k);if(a(c,h.length*(n.length+2)),u.flat.text.slice(g,g+h.length)!==h)return null;for(let y=m;y<k;y++){if(Sn.test(f[y]))continue;let A=!1;for(let w of n)if(w.target===t&&w.from<=y&&w.to>y&&w.targetFrom+y-w.from===g+y-m){A=!0;break}if(!A)return null}if(d.flat.atoms.length||u.flat.atoms.length){a(c,d.flat.atoms.length+u.flat.atoms.length);let y=0,A=u.flat.atoms;for(;y<A.length&&A[y].i<g;)y++;for(let w of d.flat.atoms){if(w.i<m||w.i>=k)continue;let v=A[y++];if(!v||v.i!==g+w.i-m||u.alignment?.reverse.get(v.el)!==w.el)return null}if(y<A.length&&A[y].i<g+k-m)return null}for(let[y,A,w]of[[r,e,m],[o,t,g]]){let v=!1;for(let E of y){let N=s.get(E),_=i.get(E),M=l(N,c);for(let j=0;j<M.length;j++){let R=M[j].from,D=R+h.length;if(a(c,h.length*2+1),N.flat.text.slice(R,D)!==h)continue;let B=j;for(;B<M.length&&M[B].to<D;)a(c,1),B++;if(B===M.length||M[B].to!==D)continue;let S=!0;for(let T=R;T<D;T++)if(!Sn.test(N.flat.text[T])&&_[T]){S=!1;break}if(S){if(v||E!==A||R!==w)return null;v=!0}}}if(!v)return null}return h}function Wd(e,t,n,r,o,s,i,l){if(i(l,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 Ua({base:e,views:t,eligible:n,baseId:r,ignored:o,remoteWins:s,atomKey:i,limit:l=2e4*8}){if(l<=0)return null;let a=Symbol(),c=(w,v)=>{if(v>w.remaining)throw a;w.remaining-=v},d=[new Map,new Map];for(let w=0;w<2;w++)for(let v=0;v<t[w].V.units.length;v++)d[w].set(t[w].V.units[v],v);let u=new Int32Array(e.length),f=new Int32Array(e.length),p=w=>t.every(({V:v},E)=>{let N=v.twin(w);return N&&d[E].has(N)}),m=-1;for(let w=0;w<e.length;w++)u[w]=m,p(e[w])&&(m=w);m=e.length;for(let w=e.length-1;w>=0;w--)f[w]=m,p(e[w])&&(m=w);let k=new Map,g=(w,v)=>{if(c(v,1),k.has(w))return k.get(w);let E=w.firstChild,N=1;for(;E;){if(c(v,N*8+8),E.nodeType===3&&c(v,E.data.length*8),E.nodeType===1&&Cn.has(E.tagName)&&!o(E)&&!s(E)&&E.firstChild){E=E.firstChild,N++;continue}for(;E&&E!==w&&!E.nextSibling;)E=E.parentNode,N--;E=!E||E===w?null:E.nextSibling}let _=an(Array.from(w.childNodes),{ignored:o,remoteWins:s});return k.set(w,_),_},h=(w,v,E,N,_,M)=>{for(let j of w.atoms){c(M,1);let R=v.atomAt.get(j.i+E);if(!R)return!1;let D=N?.reverse.get(j.el)||i(j.el),B=_?.reverse.get(R.el)||i(R.el);if(D!==B)return!1}return!0},y=(w,v,E,N,_)=>{let M=w.text.length<=v.text.length?w:v,j=M===w?v:w;if(c(_,M.text.length+j.text.length),!M.text||!Jn.test(M.text.replaceAll(Yn,"")))return!1;let R;if(M.text===j.text)R=0;else{let D=j.text.length-M.text.length;if(c(_,(D+1)*M.text.length*2),j.text.startsWith(M.text))R=0;else if(j.text.endsWith(M.text))R=D;else return!1;if(j.text.indexOf(M.text)!==R||j.text.lastIndexOf(M.text)!==R)return!1;c(_,j.text.length*2);let B=0,S=R===0,T=!1;for(let J of pn(j.text,_n(j.text)))B+=J.len,B===R&&(S=!0),B===R+M.text.length&&(T=!0);if(!S||!T)return!1}return M===w?h(M,j,R,E,N,_):h(M,j,R,N,E,_)},A=null;for(let w=0;w<2;w++){let{V:v,A:E,idOf:N}=t[w],_=t[1-w];if(!v.asBase)for(let M=0;M<e.length;M++){let j=e[M];if(v.twin(j)||!n(j))continue;let R=_.V.twin(j);if(!R||!d[1-w].has(R)||!n(R))continue;let D={remaining:l};try{let B=u[M],S=f[M],T=0;for(let Ce=B+1;Ce<S;Ce++)c(D,1),!v.twin(e[Ce])&&_.V.twin(e[Ce])&&n(e[Ce])&&T++;if(T!==1||g(j,D).text===g(R,D).text)continue;let J=B<0?-1:d[w].get(v.twin(e[B])),q=S===e.length?v.units.length:d[w].get(v.twin(e[S]));if(J===void 0||q===void 0||J>=q)continue;let V=null;for(let Ce=J+1;Ce<q;Ce++){c(D,1);let Me=v.units[Ce];if(v.baseOf(Me)||!n(Me)||Me.tagName!==j.tagName||Me.namespaceURI!==j.namespaceURI)continue;let Fe=r(j),ce=_.idOf(R),Ae=N(Me);if(!(Fe&&ce&&Fe!==ce||Fe&&Ae&&Fe!==Ae||ce&&Ae&&ce!==Ae)&&y(g(R,D),g(Me,D),_.A,E,D)){if(V){V=null;break}V=Me}}if(!V)continue;A||(A=[new Map,new Map]),A[w].set(j,V)}catch(B){if(B!==a)throw B}}}return A?t.map(({V:w},v)=>{let E=A[v];if(!E.size)return w;let N=new Map;for(let[_,M]of E)N.set(M,_);return{...w,twin:_=>E.get(_)||w.twin(_),baseOf:_=>N.get(_)||w.baseOf(_)}}):null}function $a({onUncertainSource:e,onUncertainOwner:t,base:n,views:r,eligible:o,ignored:s,remoteWins:i,baseId:l,atomKey:a,limit:c=2e4*32}){if(c<=0)return null;let d=new Set(n),u=new Map(n.map((B,S)=>[B,S])),f=new Map,p=[],m=null,k=null,g=null,h=new Set;for(let B of n)for(let{V:S}of r){let T=S.twin(B);T&&!S.asBase&&!S.here(T)&&h.add(B)}let y=new Set,A=Symbol(),w=(B,S)=>{if(S>B.remaining)throw A;B.remaining-=S},v=(B,S,T)=>{w(T,1);let J=f.get(B);if(J)return J;if(B.nodeType===1){let Ce=B.firstChild,Me=1;for(;Ce;){if(w(T,Me*8+8),Ce.nodeType===3&&w(T,Ce.data.length*8),Ce.nodeType===1&&Cn.has(Ce.tagName)&&!s(Ce)&&!i(Ce)&&Ce.firstChild){Ce=Ce.firstChild,Me++;continue}for(;Ce&&Ce!==B&&!Ce.nextSibling;)Ce=Ce.parentNode,Me--;Ce=!Ce||Ce===B?null:Ce.nextSibling}}else w(T,B.value.length*8+B.nodes.length);let q=B.nodeType===1?Array.from(B.childNodes):B.nodes,V=q.length===1&&q[0].nodeType===3?{text:q[0].data,nodes:[{node:q[0],s:0,e:q[0].data.length}],atoms:[]}:an(q,{ignored:s,remoteWins:i});return J={unit:B,flat:V,alignment:S,tokens:null},f.set(B,J),J},E=(B,S)=>{if(B.tokens)return B.tokens;w(S,B.flat.text.length*8);let{unit:T,flat:J,alignment:q}=B,V=[],Ce=_n(J.text),Me=0,Fe=ce=>{for(let Ae of pn(J.text.slice(Me,ce),Ce))Ae.from=Me,Ae.to=Me+Ae.len,Ae.unit=T,V.push(Ae),Me+=Ae.len};for(let ce of J.atoms){Fe(ce.i);let Ae=i(ce.el)&&ce.el.nodeType===1?"w"+ce.el.tagName+"#"+(ce.el.id||""):a(q?.reverse.get(ce.el)||ce.el);V.push({k:Ae,raw:Yn,len:1,from:Me,to:Me+1,unit:T,atom:!0}),Me++}return Fe(J.text.length),B.tokens=V,V},N=(B,S,T,J,q)=>{if(!B.flat.atoms.length&&!S.flat.atoms.length)return!0;let V=E(B,q),Ce=E(S,q);w(q,V.length+Ce.length);let Me=0;for(let Fe of Ce){if(!Fe.atom||Fe.from<T||Fe.from>=T+J)continue;for(;Me<V.length&&!V[Me].atom;)Me++;let ce=V[Me++];if(!ce||ce.from!==Fe.from-T||ce.k!==Fe.k)return!1}for(;Me<V.length;)if(V[Me++].atom)return!1;return!0},_=(B,S,T)=>{let J=B.length+S.length+4;if(J*8>T.remaining)return null;T.remaining-=J*8;let q=Math.floor(T.remaining/8),V=Math.min(B.length+S.length,4e3,Math.floor((Math.sqrt(J*J+q)-J)/2)),Ce=4*(V+1)*(J+V+1);if(V<1||Ce>T.remaining)return null;T.remaining-=Ce;let Me=Zn(B,S,V),Fe=[],ce=0,Ae=0;for(let Ue of Me.hunks){for(;ce<Ue.bs;)B[ce].raw===S[Ae].raw&&Fe.push([B[ce],S[Ae]]),ce++,Ae++;ce=Ue.be,Ae+=Ue.toks.length}for(;ce<B.length&&Ae<S.length;)B[ce].raw===S[Ae].raw&&Fe.push([B[ce],S[Ae]]),ce++,Ae++;return Fe},M=(B,S,T,J,q,V,Ce)=>{if(q<=J)return;let Me=B[B.length-1];if(Me&&Me.source===S&&Me.target===T&&Me.to<=J&&Me.targetFrom-Me.from===V-J){w(Ce,(J-Me.to)*3);let Fe=f.get(S).flat.text,ce=f.get(T).flat.text,Ae=!0;for(let Ue=Me.to;Ue<J;Ue++)if(!Sn.test(Fe[Ue])||Fe[Ue]!==ce[V+Ue-J]){Ae=!1;break}if(Ae){Me.to=q;return}}B.push({source:S,target:T,from:J,to:q,targetFrom:V})},j=B=>B.replace($d,"");for(let B=0;B<r.length;B++){let{V:S,A:T,idOf:J}=r[B];if(S.asBase)continue;let q=new Map(S.units.map((O,X)=>[O,X])),V=O=>{let X=S.twin(O);return X&&q.has(X)?X:null},Ce=(O,X)=>{let le=new Int32Array(O.length),re=new Int32Array(O.length),Pe=-1;for(let Be=0;Be<O.length;Be++)le[Be]=Pe,X(O[Be])&&(Pe=Be);Pe=O.length;for(let Be=O.length-1;Be>=0;Be--)re[Be]=Pe,X(O[Be])&&(Pe=Be);return{prev:le,next:re}},Me=Ce(n,O=>(O.nodeType===1||O.kind==="text"&&Jn.test(O.value))&&V(O)),Fe=Ce(S.units,O=>(O.nodeType===1||O.kind==="text"&&Jn.test(O.value))&&d.has(S.baseOf(O))),ce=new Map,Ae=(O,X,le,re)=>{if(O>X||le>re)return;let Pe=`${O}:${X}:${le}:${re}`;ce.set(Pe,[O,X,le,re])};for(let O=0;O<S.units.length;O++){let X=S.units[O];if(S.baseOf(X)||!o(X))continue;let le=Fe.prev[O],re=Fe.next[O],Pe=le<0?0:u.get(S.baseOf(S.units[le])),Be=re===S.units.length?n.length-1:u.get(S.baseOf(S.units[re]));Ae(Pe,Be,Math.max(0,le),Math.min(S.units.length-1,re))}for(let O=0;O<n.length;O++){let X=n[O];if(h.has(X)||!o(X))continue;if(!S.twin(X)){let ot=Me.prev[O],et=Me.next[O],ae=ot<0?0:q.get(V(n[ot])),de=et===n.length?S.units.length-1:q.get(V(n[et]));Ae(Math.max(0,ot),Math.min(n.length-1,et),ae,de)}let le=V(X);if(!le||T.identical.has(X)||!o(le))continue;let re=O+1;for(;re<n.length&&n[re].kind==="text"&&!n[re].value.trim();)re++;if(re>=n.length||!o(n[re]))continue;let Pe=V(n[re]);if(!Pe||T.identical.has(n[re])||!o(Pe))continue;let Be=q.get(le),Te=q.get(Pe);Be<Te&&Ae(O,re,Be,Te)}let Ue=Array.from(ce.values()),_e=new Set;if(Ue.length>1){let O=Zt(c);try{w(O,Ue.length*4);let X=Ue.slice().sort((Pe,Be)=>(w(O,1),Pe[0]-Be[0]||Pe[2]-Be[2])),le=[],re=null;for(let Pe of X)w(O,1),re&&Pe[0]<=re[1]&&Pe[2]<=re[3]&&Pe[3]>=re[2]?(re[1]=Math.max(re[1],Pe[1]),re[2]=Math.min(re[2],Pe[2]),re[3]=Math.max(re[3],Pe[3]),re[4].push(Pe)):(re?.[4].length>1&&le.push(re),re=[Pe[0],Pe[1],Pe[2],Pe[3],[Pe]]);re?.[4].length>1&&le.push(re),Ue=le.concat(Ue)}catch(X){if(X!==A)throw X}}for(let O of Ue){if(_e.has(O))continue;let[X,le,re,Pe,Be]=O,Te=Zt(c),ot=[],et=new Set,ae=!1;try{w(Te,(le-X+Pe-re+2)*4);let de=n.slice(X,le+1).filter(F=>!T.identical.has(F)&&o(F)&&!h.has(F)),Ee=S.units.slice(re,Pe+1).filter(F=>o(F)&&(!S.baseOf(F)||d.has(S.baseOf(F)))&&!T.identical.has(S.baseOf(F))&&!h.has(S.baseOf(F))),Ge=new Set(Ee),Ve=!1,ze="",lt="",pt=0;for(let F of de){let he=v(F,null,Te);ze+=he.flat.text,pt+=he.flat.text.length}for(let F of Ee){let he=v(F,T,Te);lt+=he.flat.text,pt+=he.flat.text.length}w(Te,pt);let Rt=j(ze),dt=j(lt),vt=Rt===dt;if(ae=vt,Be&&!vt)continue;let gt=vt?null:new Map;if(gt)for(let F of de.concat(Ee)){let he=f.get(F).flat.text.length;w(Te,he*16),gt.set(F,new Uint8Array(he))}let kn=F=>{let he=[];for(let ke of F){let ie=f.get(ke);ie.flat.atoms.length?he.push(...E(ie,Te)):he.push({unit:ke,raw:ie.flat.text,from:0})}return he},Ft=[];for(let F of vt?[]:de){let he=V(F);if(!Ge.has(he))continue;let ke=v(F,null,Te),ie=v(he,T,Te);w(Te,ke.flat.text.length+ie.flat.text.length);let Ne=ke.flat.text&&ie.flat.text.startsWith(ke.flat.text)?0:ke.flat.text&&ie.flat.text.endsWith(ke.flat.text)?ie.flat.text.length-ke.flat.text.length:-1;if(Ne>=0&&N(ke,ie,Ne,ke.flat.text.length,Te)){gt.get(F).fill(1),gt.get(he).fill(1,Ne,Ne+ke.flat.text.length),M(Ft,F,he,0,ke.flat.text.length,Ne,Te);continue}let U=_(E(ke,Te),E(ie,Te),Te);if(!U){Ve=!0;break}for(let[Y,pe]of U)gt.get(F).fill(1,Y.from,Y.to),gt.get(he).fill(1,pe.from,pe.to),M(Ft,F,he,Y.from,Y.to,pe.from,Te)}if(Ve)continue;let Qt=null,Yt=null;if(!vt)for(let F of de){let he=V(F),ke=f.get(F);if(!he||ke.flat.atoms.length||!Ge.has(he))continue;let ie=ke.flat.text,Ne=gt.get(F);w(Te,ie.length*3+Ee.length);let U=-1,Y=-1,pe=!1;for(let je=0;je<ie.length;je++)Sn.test(ie[je])||(Ne[je]?pe=!0:(U<0&&(U=je),Y=je+1));if(!pe||U<0)continue;let ye=!0;for(let je=U;je<Y;je++)if(Ne[je]&&!Sn.test(ie[je])){ye=!1;break}if(!ye)continue;let me=j(ie.slice(U,Y)),ee=null,te=!1;for(let je of Ee){if(S.baseOf(je))continue;let Se=f.get(je);if(!Se.flat.atoms.length&&(w(Te,Se.flat.text.length),j(Se.flat.text)===me)){if(ee){te=!0;break}ee=je}}if(te){(Yt||=new Set).add(F);continue}if(!ee||Yt?.has(F))continue;let W=!1;for(let je of de){if(je===F||!Ge.has(V(je)))continue;let Se=f.get(je);if(Se.flat.atoms.length)continue;let Je=gt.get(je);w(Te,Se.flat.text.length*3);let nt="",st=!1;for(let $t=0;$t<Se.flat.text.length;$t++)Sn.test(Se.flat.text[$t])||(Je[$t]?st=!0:nt+=Se.flat.text[$t]);st&&nt===me&&(Yt||=new Set,Yt.add(F),Yt.add(je),W=!0)}if(W)continue;let ne=f.get(ee).flat.text;w(Te,Y-U+ne.length);let we=U,Ie=0;for(;we<Y&&Ie<ne.length;){for(;we<Y&&Sn.test(ie[we]);)we++;for(;Ie<ne.length&&Sn.test(ne[Ie]);)Ie++;if(we>=Y||Ie>=ne.length)break;M(Qt||=[],F,ee,we,we+1,Ie,Te),we++,Ie++}Ne.fill(1,U,Y),gt.get(ee).fill(1)}let gn=F=>{let he=[];for(let ke of F){let ie=v(ke,d.has(ke)?null:T,Te),Ne=gt.get(ke);for(let U of E(ie,Te)){let Y=U.from;for(;Y<U.to;){for(;Y<U.to&&Ne[Y];)Y++;let pe=Y;for(;Y<U.to&&!Ne[Y];)Y++;if(Y>pe){let ye=ie.flat.text.slice(pe,Y);Jn.test(ye)&&he.push({...U,raw:ye,len:Y-pe,k:U.atom?U.k:ye,from:pe,to:Y})}}}}return he},K=vt?kn(de):gn(de),b=vt?kn(Ee):gn(Ee),C=vt?Rt:K.map(F=>j(F.raw)).join(""),L=vt?dt:b.map(F=>j(F.raw)).join("");if((!C||!L)&&!Qt)continue;let $=Qt||[];if(C&&L&&C===L){let F=0,he=0,ke=0,ie=0;for(;F<K.length&&he<b.length;){let Ne=K[F],U=b[he];for(;ke<Ne.raw.length&&Sn.test(Ne.raw[ke]);)ke++;for(;ie<U.raw.length&&Sn.test(U.raw[ie]);)ie++;if(ke===Ne.raw.length){F++,ke=0;continue}if(ie===U.raw.length){he++,ie=0;continue}if((Ne.atom||U.atom)&&Ne.k!==U.k){Ve=!0;break}M($,Ne.unit,U.unit,Ne.from+ke,Ne.from+ke+1,U.from+ie,Te),ke++,ie++}}else if(C&&L){let F=_(K,b,Te);if(!F)continue;for(let[he,ke]of F)M($,he.unit,ke.unit,he.from,he.to,ke.from,Te)}if(Ve)continue;let Q=new Map;for(let F of $)if(!Yt?.has(F.source)){if(V(F.source)===F.target){vt&&Ft.push(F);continue}Q.has(F.source)||Q.set(F.source,[]),Q.get(F.source).push(F)}for(let[F,he]of Q){let ke=v(F,null,Te),ie=V(F),Ne=ke.flat.text,U=[],Y=new Set,pe=r[1-B],ye=pe.V.twin(F),me=ye&&pe.V.here(ye)?v(ye,pe.A,Te):null,ee=(Se,Je)=>{let nt=E(Se,Te),st=E(Je,Te);return w(Te,Se.flat.text.length+Je.flat.text.length+nt.length+st.length),Se.flat.text===Je.flat.text&&nt.length===st.length&&nt.every(($t,Bt)=>$t.k===st[Bt].k)},te=ie&&me&&me.flat.text!==Ne&&ee(v(ie,T,Te),me);for(let Se of new Set(he.map(Je=>Je.target))){if(F.nodeType!==1&&Se.nodeType!==1)continue;let Je=v(Se,T,Te),nt=S.baseOf(Se);if(F.nodeType!==1&&nt||(w(Te,Ne.length*2+Je.flat.text.length*3+Ft.length*2),ie&&j(Ne)===j(Je.flat.text)&&v(ie,T,Te).flat.text.trim()))continue;if(!ie&&!nt&&F.nodeType===1&&Se.nodeType===1){let G=l(F),se=J(Se);if(G&&se&&G!==se)continue}let st=Je.flat.text,$t=Ne&&(st.startsWith(Ne)||st.endsWith(Ne)),Bt=!1;if(!ie&&me&&nt&&me.flat.text!==Ne){let G=v(nt,null,Te).flat.text,se=u.get(F)<u.get(nt)?me.flat.text:G,be=u.get(F)<u.get(nt)?G:me.flat.text;w(Te,se.length+be.length+st.length),Bt=!!se&&!!be&&se.length+be.length<=st.length&&st.startsWith(se)&&st.endsWith(be)&&!st.slice(se.length,st.length-be.length).trim()}let I=!ke.flat.atoms.length&&!me?.flat.atoms.length&&!Je.flat.atoms.length&&(te&&$t||Bt);if(ie&&nt){let G=v(ie,T,Te).flat.text,se=Ne.startsWith(G)||Ne.endsWith(G),be=v(nt,null,Te).flat.text,xe=Je.flat.text,fe=xe.startsWith(be)||xe.endsWith(be),oe=!r[1-B].V.twin(nt)&&!Ft.some(Re=>Re.source===nt&&Jn.test(be.slice(Re.from,Re.to)));if(!vt&&(!se&&!I||!fe&&!oe)){let Re=Vd(F,Se,he,de,Ee,f,gt,E,w,Te);if(!Re)continue;let De=T.weak?.has(F)&&!T.identityPaired?.has(F)&&Ne.trim()===Re;if(!se&&!I&&!De)continue;let We=T.weak?.has(nt)&&!T.identityPaired?.has(nt)&&st.trim()===Re&&!f.get(nt).flat.atoms.length&&!Ft.some(Ye=>Ye.source===nt&&Jn.test(be.slice(Ye.from,Ye.to)));if(!fe&&!oe&&!We&&!Wd(nt,Se,be,st,Ft,E(Je,Te),w,Te))continue;De&&Y.add(Se)}}I&&Y.add(Se),w(Te,he.length),U.push(...he.filter(G=>G.target===Se))}if(!U.length)continue;let W=new Uint8Array(Ne.length);w(Te,Ne.length*4+Ft.length);for(let Se of U)W.fill(1,Se.from,Se.to);let ne=[];for(let Se=0;Se<Ne.length;Se++)Sn.test(Ne[Se])||ne.push(Se);if(!ne.length)continue;let we=new Set(U.map(Se=>Se.target));if(!vt&&ie&&we.size>1&&Hd(we,$,Ft,S,f,Te,w)){if(g||=new Map,g.set(F,(g.get(F)||0)|1<<B),e){let Se=Ei({source:F,side:B,views:r,eligible:o,blocked:h,baseId:l,model:v,tokensOf:E,budget:Te,charge:w});if(Se){w(Te,Se.to-Se.from);let Je=!0;for(let nt=Se.from;nt<Se.to;nt++)if(Jn.test(Ne[nt])&&!W[nt]){Je=!1;break}Je&&(m||=[]).push(Se)}}continue}let Ie=ne.filter(Se=>Fi.test(Ne[Se]));if(!U.some(Se=>Fi.test(Ne.slice(Se.from,Se.to)))&&!ne.every(Se=>W[Se]))continue;if(!ie&&!Array.from(we).some(Se=>Y.has(Se))&&!ne.every(Se=>W[Se])&&!(Ie.length&&W[Ie[0]]&&W[Ie[Ie.length-1]]&&we.size===1)){let Se=null,Je=0,nt=0,st=null,$t=null;if(!ie&&me&&F.nodeType===1&&!ke.flat.atoms.length){let Bt=E(ke,Te).filter(I=>Fi.test(I.raw));w(Te,Ee.length+Ne.length);for(let I of Ee){let G=S.baseOf(I);if(!G||G===F||G.nodeType!==1||I.nodeType!==1||G.tagName!==F.tagName||I.tagName!==G.tagName)continue;let se=u.get(F),be=u.get(G),xe=!0;for(let at=Math.min(se,be)+1;at<Math.max(se,be);at++){let Wt=n[at];if(w(Te,Wt.nodeType===1?1:Wt.value.length+1),Wt.nodeType===1||Wt.value.trim()){xe=!1;break}}if(!xe)continue;let fe=v(G,null,Te),oe=v(I,T,Te);if(fe.flat.atoms.length||oe.flat.atoms.length)continue;let Re=fe.flat.text,De=oe.flat.text;if(w(Te,Re.length+De.length+Ne.length),!Re||!Bt.length)continue;let We=0,Ye=De.length;if(se<be&&De.endsWith(Re))Ye-=Re.length;else if(se>be&&De.startsWith(Re))We=Re.length;else continue;for(;We<Ye&&Sn.test(De[We]);)We++;for(;Ye>We&&Sn.test(De[Ye-1]);)Ye--;let wt=De.slice(We,Ye);if(!(!wt||!(wt.startsWith(Bt[0].raw)||wt.endsWith(Bt[Bt.length-1].raw)))){if(Se){Se=null;break}Se=I,Je=We,nt=Ye,st=Bt[0],$t=Bt[Bt.length-1]}}}if(w(Te,U.length),!Se||!we.has(Se)||!U.some(Bt=>Bt.target===Se&&(Bt.from<=st.from&&Bt.to>=st.to&&Bt.targetFrom+st.from-Bt.from===Je||Bt.from<=$t.from&&Bt.to>=$t.to&&Bt.targetFrom+$t.to-Bt.from===nt)))continue}if(ie&&!(ne.every(Se=>W[Se])&&(vt||Array.from(we).some(Se=>Y.has(Se))))&&!Ft.some(Se=>Se.source===F&&Jn.test(Ne.slice(Se.from,Se.to))))continue;let je=!1;if(vt){w(Te,Ft.length+ne.length);for(let Se of Ft)Se.source===F&&(w(Te,Se.to-Se.from),W.fill(1,Se.from,Se.to));je=!0;for(let Se of ne)if(!W[Se]){je=!1;break}}for(let Se of we){w(Te,U.length);let Je=U.filter(st=>st.target===Se);ot.push({side:B,source:F,target:Se,runs:Je,models:f,retained:Ft,conservedSource:je}),F.nodeType===1&&et.add(F),Se.nodeType===1&&et.add(Se);let nt=S.baseOf(Se);nt?.nodeType===1&&et.add(nt)}}if(p.push(...ot),Be&&ot.length)for(let F of Be)_e.add(F);for(let F of et)y.add(F)}catch(de){if(de!==A)throw de}finally{if(t&&!Be&&!ae){let de=qa({base:n,views:r,side:B,attempt:O,eligible:o,blocked:h,baseId:l,model:v,tokensOf:E,charge:w,exhausted:A,limit:c});de&&(k||=[]).push(...de)}if(e&&!Be&&!ae){let de=ta({base:n,views:r,side:B,attempt:O,eligible:o,blocked:h,baseId:l,model:v,tokensOf:E,certificates:p,charge:w,exhausted:A,limit:c});de&&(m||=[]).push(...de)}}}}let R=p.length?new Map:null;for(let B of p){let S=R.get(B.source);S||R.set(B.source,S=[]),S.push(B)}let D=null;if(R){let B=null;for(let[S,T]of R){let J=g?.get(S)||0;if(T.length<2&&!J)continue;let q=0;for(let V of T)V.conservedSource&&(q|=1<<V.side);for(let V of T){if(V.conservedSource)continue;let Ce=1<<V.side,Me=!0;if(q&Ce)Me=!1;else if(J&Ce){Me=!1;try{Me=zd(V,B||=Zt(c),w)}catch(Fe){if(Fe!==A)throw Fe}}Me||(D||=new Set).add(V)}}}if(D){let B=0;for(let S of p)D.has(S)||(p[B++]=S);p.length=B;for(let[S,T]of R){B=0;for(let J of T)D.has(J)||(T[B++]=J);T.length=B,B||R.delete(S)}y.clear();for(let S of p){let{source:T,target:J,side:q}=S;T.nodeType===1&&y.add(T),J.nodeType===1&&y.add(J);let V=r[q].V.baseOf(J);V?.nodeType===1&&y.add(V)}}if(m){let B=Zt(c),S=!1;for(let T of m){let J=!1,q=R?.get(T.source);if(q&&!S)try{J=Ti(T,q,B,w)}catch(V){if(V!==A)throw V;S=!0}J||e(T)}}if(k){let B=new Set,S=Zt(c);try{for(let T of k){if(w(S,1),B.has(T.source))continue;B.add(T.source);let J=!1;for(let q of p)if(w(S,1),q.source===T.source||q.target===T.local||q.target===T.remote){J=!0;break}J||t(T)}}catch(T){if(T!==A)throw T}}for(let B of n)if(y.has(B))for(let{V:S}of r){let T=S.twin(B);T&&S.here(T)&&y.add(T)}return p.length?{blocks:y,certificates:p,certificatesBySource:R,models:f}:null}function Ha({certificates:e,scopes:t,flats:n,keys:r,limit:o=2e4*32}){let s=Symbol(),i=Zt(o),l=g=>{if(g>i.remaining)throw s;i.remaining-=g},a=t.map(g=>new Set(g)),c=new Map,d=new Map,u=(g,h)=>{let y=c.get(g);if(y||c.set(g,y=new Map),y.has(h))return y.get(h);l(g.text.length);let A=d.get(h);if(!A){l(h.nodes.length+h.atoms.length),A={nodes:new Map,atoms:new Map};for(let N of h.nodes)A.nodes.set(N.node,N);for(let N of h.atoms)A.atoms.set(N.el,N.i);d.set(h,A)}let{nodes:w,atoms:v}=A,E=new Int32Array(g.text.length).fill(-1);for(let N of g.nodes){let _=w.get(N.node);if(!(!_||N.e-N.s!==_.e-_.s)){l(N.e-N.s);for(let M=N.s;M<N.e;M++)E[M]=_.s+M-N.s}}for(let N of g.atoms){let _=v.get(N.el);_!==void 0&&(E[N.i]=_)}return y.set(h,E),E},f=(g,h,y,A,w)=>{let v=g[g.length-1];v&&v.to===h&&v.target+v.to-v.from===A&&v.kind===w?v.to=y:g.push({from:h,to:y,target:A,kind:w})},p=(g,h,y,A)=>{l((A-y)*4);let w=[],v=y,E=M=>{let j=g.text.slice(v,M);for(let R of pn(j,_n(j)))R.from=v,R.to=v+R.len,w.push(R),v+=R.len},N=0,_=g.atoms.length;for(;N<_;){l(1);let M=N+_>>>1;g.atoms[M].i<y?N=M+1:_=M}for(let M=N;M<g.atoms.length&&g.atoms[M].i<A;M++){l(1);let j=g.atoms[M];E(j.i),w.push({k:h(j),raw:Yn,len:1,from:v,to:v+1}),v++}return E(A),w},m=(g,h,y,A,w,v)=>{if(y===A||w===v)return;if(A-y===v-w){l((A-y)*4);let S=!0;for(let T=y,J=w;T<A;T++,J++){if(n[0].text[T]!==n[h].text[J]){S=!1;break}let q=n[0].atomAt.get(T),V=n[h].atomAt.get(J);if(!!q!=!!V||q&&r[0](q)!==r[h](V)){S=!1;break}}if(S){f(g,y,A,w,"retained");return}}let E=p(n[0],r[0],y,A),N=p(n[h],r[h],w,v),_=E.length+N.length+4,M=Math.min(E.length+N.length,4e3,Math.floor((Math.sqrt(_*_+i.remaining/2)-_)/2));if(M<1)throw s;l(4*(M+1)*(_+M+1));let j=Zn(E,N,M),R=0,D=0,B=()=>{let S=E[R++],T=N[D++];l(S.len),S.raw===T.raw&&f(g,S.from,S.to,T.from,"retained")};for(let S of j.hunks){for(;R<S.bs;)B();R=S.be,D+=S.toks.length}for(;R<E.length&&D<N.length;)B()},k=g=>{let h=e.filter(j=>j.side===g-1&&a[0].has(j.source)&&a[g].has(j.target));if(!h.length)return null;let y=[],A=(j,R,D)=>{if(!a[0].has(j.source)||!a[g].has(j.target))return;let B=u(R.get(j.source).flat,n[0]),S=u(R.get(j.target).flat,n[g]);l(j.to-j.from);for(let T=0;T<j.to-j.from;T++){let J=B[j.from+T],q=S[j.targetFrom+T];if(J<0||q<0)throw s;f(y,J,J+1,q,D)}},w=new Set;for(let j of h){if(!w.has(j.retained)){w.add(j.retained);for(let R of j.retained)A(R,j.models,"retained")}for(let R of j.runs)A(R,j.models,"transfer")}y.sort((j,R)=>(l(1),j.from-R.from||j.target-R.target));let v=[];for(let j of y){l(1);let R=v[v.length-1];if(R&&j.from<R.to){if(j.target-j.from!==R.target-R.from)throw s;R.to=Math.max(R.to,j.to),j.kind==="transfer"&&(R.kind="transfer")}else v.push(j)}let E=[],N=0,_=0;for(let j of v){if(j.target<_)throw s;m(E,g,N,j.from,_,j.target),E.push(j),N=j.to,_=j.target+j.to-j.from}m(E,g,N,n[0].text.length,_,n[g].text.length);let M=Gn({base:n[0],side:n[g],retained:E.filter(j=>j.kind==="retained"),transfers:E.filter(j=>j.kind==="transfer"),baseAtomKey:r[0],sideAtomKey:r[g],budget:i});if(M.status!=="ready"||!M.monotone)throw s;return M};try{let g=k(1),h=k(2);return g||h?{local:g,remote:h}:{fallback:!0}}catch(g){if(g!==s)throw g;return{fallback:!0}}}function Bi(e,t,n=!1){let r=-1,o=-1;for(let i=0;i<e.list.length;i++){let l=e.list[i];l.bLo<t.lo||l.bLo>t.hi||(r<0&&(r=i),o=i)}let s=[];for(let i=r;i>=0&&i<=o;i++){let l=e.list[i],a=!n&&i===r?l.inlineStart<0?l.to:l.inlineStart:l.from,c=!n&&i===o?l.inlineEnd<0?l.from:l.inlineEnd:l.to;for(let d=a;d<c;d++)s.push(e.units[d]);i<o&&s.push(e.units[l.next])}return s}var ut=e=>!!e&&e.nodeType===1,qn=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function qi(e){for(let t of e)if(qn.has(t.tagName))return!0;return!1}function Kd(e,t,n){let r=null;for(let o of t.childNodes)if(!(!ut(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 Oo="[id],[data-id],script,head>*";function Ui(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let r=$r(n,e);if(r)return"merge:"+r.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?Ea(n,t):null}}function hs(e,t,n,r){let o=r.ignored,s=r.stats||ar(),i=Xl({ignored:o,ignoreAttribute:r.ignoreAttribute,stats:s}),{unitsOf:l,meta:a}=i,c=r.baseURI,d=r.mergeTags!==null,u=Ui(r.mergeTags,c),f=I=>G=>{let se=u(G);return se!==null?se:I(G)},p=f(r.identity.base),m=f(r.identity.local),k=f(r.identity.remote),g=r.authored||r.identity,h=I=>I&&I.nodeType===9?I.documentElement:I,y=h(e),A=h(t),w=h(n),v=globalThis.__hyperMorphProfile,E=v?performance.now():0,N=I=>I===Nn?Oo:null,_=r.scope||null,M=_?_.baseDropped:new Set,j=new Set,R=_?_.remoteDropped:new Set,D=_?_.baseIndex:ts(y,p,o,N(r.identity.base),M),B=r.localIsBase||y===A?null:ts(A,m,o,N(r.identity.local),j),S=_?_.remoteIndex:ts(w,k,o,N(r.identity.remote),R),T=I=>{let G=ut(I)&&m(I);return G&&B?.get(G)===I&&!D.has(G)?G:null},J=I=>{let G=ut(I)&&k(I);return G&&S.get(G)===I&&!D.has(G)?G:null},q=B?gi(y,A,{analyzer:i,baseIndex:D,sideIndex:B,baseId:g.base,sideId:g.local,baseKey:p,sideKey:m,baseDropped:M,sideDropped:j,stats:s}):Va(),V=gi(y,w,{analyzer:i,baseIndex:D,sideIndex:S,baseId:g.base,sideId:g.remote,baseKey:p,sideKey:k,baseDropped:M,sideDropped:R,stats:s,scope:_,comparisons:r.comparisons});if(_){if(!_.held(V))return null;for(let I of _.dropped)mi(I)}let Ce=null;function Me(I){if(!Ce){Ce=new WeakMap;let G=[y];for(;G.length;){let se=G.pop();se.tagName==="TEMPLATE"&&se.content&&Ce.set(se.content,se);for(let be of i.childrenOf(se))be.nodeType===1&&G.push(be)}}return Ce.get(I)||null}let Fe=I=>{let G=ut(I)||I.nodeType?I.parentNode:I.parent;return G&&G.nodeType===11?Me(G):G};if(V.moved.size){let I=!1;for(let G of Array.from(V.moved))!ut(G)||V.identityPaired.has(G)||!g.base(G)||b(V,Fe(G))||(V.unpair(G),I=!0);I&&V.rematch()}gn(),K(q,V),K(V,q);for(let I of[q,V])if(I.refused)for(let G of I.refused)I.moved.has(G)||s.ambiguousMoves++;v&&(v.alignTotal=(v.alignTotal||0)+(performance.now()-E),E=performance.now());let ce=y.ownerDocument.implementation.createHTMLDocument(""),Ae=new WeakMap,Ue=new WeakMap,_e=[],O=[],X=new Set,le=[],re=new Set,Pe=new Set,Be=new Set,Te=new WeakMap,ot=null,et=r.lineage?.locals.length?ma():null,ae=I=>{let G=is(I);return G&&et&&et.consume(I.local),G},de=r.conflicts||"remote",Ee=I=>_e.push(I),Ge=I=>_e.push(I),Ve=La({roots:{base:y,local:A,remote:w},L:q,R:V,unitsOf:l,provenance:Ae,policy:de}),ze=(I,G)=>{O.push(I),G&&Ve.note(I,G)},lt=null,pt=null,Rt=Qt(),dt=null,vt=F(y,q.map.get(y),V.map.get(y),!!r.localIsBase,!!r.childrenOnly);vt.tagName==="HTML"?ce.replaceChild(vt,ce.documentElement):ce.body.appendChild(vt),lt?.drain(vt),pt?.drain(vt),v&&(v.build=(v.build||0)+(performance.now()-E));let gt=r.childrenOnly?!je(we(vt),we(w)):!te(vt,w),kn=Ve.finish(vt),Ft=et?pa({locals:r.lineage.locals,rec:et,root:vt,provenance:Ae,segments:le,ignored:o}):null;return{doc:ce,root:vt,provenance:Ae,textMappers:Ue,decisions:_e,conflicts:O,recoveryLinks:kn,localDiverged:gt,mergedScripts:X,segments:le,remoteIdOf:r.identity.remote,customIdentity:r.identity.remote!==Nn,L:q,R:V,stats:s,lineage:Ft};function Qt(){let I=new Map,G=new Set;if(r.localIsBase||!q.insertedByHash)return{partner:I,drop:G};let se=q.insertedByHash(),be=V.insertedByHash();if(!se.size||!be.size)return{partner:I,drop:G};let xe={ignored:o,remoteWins:r.remoteWins,inlineCache:Te},fe=ht=>{let Qe=0;for(let Mt=ht.parentNode;Mt;Mt=Mt.parentNode)Qe++;return Qe},oe=[],Re=ht=>{let Qe=ht.textContent.trim();return Qe.split(/\s+/).length>=3||Qe.replace(/\s/g,"").length>=12},De=ht=>{let Qe=b(q,ht),Mt=b(V,ht);return Qe&&q.reverse.get(Qe.parentNode)!==ht.parentNode||Mt&&V.reverse.get(Mt.parentNode)!==ht.parentNode},We=(ht,Qe,Mt)=>{for(let Ut of Mt.parentNode.children){let En=Ut!==Mt&&ht.reverse.get(Ut);if(En&&De(En))return!0}let bt=ht.reverse.get(Mt.parentNode);if(bt){for(let Ut of bt.children)if(!b(Qe,Ut)&&!o(Ut))return!0}return!1},Ye=new Map([[q,new Map],[V,new Map]]),wt=(ht,Qe)=>{let Mt=Ye.get(ht),bt=Mt.get(Qe);if(bt===void 0){bt=!1;for(let Ut of Qe.children)if(ht.reverse.has(Ut)||wt(ht,Ut)){bt=!0;break}Mt.set(Qe,bt)}return bt},at=new Map;for(let ht of be.values())for(let Qe of ht){let Mt=J(Qe);Mt&&at.set(Mt,Qe)}for(let ht of se.values())for(let Qe of ht){let Mt=T(Qe),bt=Mt?at.get(Mt):null;bt&&bt.tagName===Qe.tagName&&!Xn(Qe,xe)&&!Xn(bt,xe)&&!r.remoteWins(Qe)&&!r.remoteWins(bt)&&oe.push([Qe,[bt],fe(Qe),!0,!0])}for(let[ht,Qe]of se){let Mt=be.get(ht);if(!Mt)continue;let bt=Qe.length===1&&Mt.length===1;for(let Ut of Qe)!Xn(Ut,xe)&&!T(Ut)&&oe.push([Ut,Mt,fe(Ut),bt&&(Re(Ut)||We(q,V,Ut)||We(V,q,Mt[0]))])}if(!oe.length)return{partner:I,drop:G};oe.sort((ht,Qe)=>ht[2]-Qe[2]);let Wt=new Set,zt=new Set,bn=ht=>{for(let Qe of ht.querySelectorAll("*"))Wt.add(Qe)},Tt=(ht,Qe)=>ht.reverse.get(Qe.parentNode)||null;for(let[ht,Qe,,Mt,bt]of oe){if(Wt.has(ht)||zt.has(ht)||bt&&(wt(q,ht)||wt(V,Qe[0])))continue;let Ut=Tt(q,ht),En=en=>!zt.has(en)&&!Wt.has(en)&&(bt||en.tagName===ht.tagName&&!J(en)&&i.equalUnits(ht,en)),cn=Qe.find(en=>Ut&&Tt(V,en)===Ut&&En(en))||(Mt?Qe.find(En):null);if(!cn)continue;zt.add(ht),zt.add(cn);let xn=Ut&&Tt(V,cn)===Ut;(!bt||!xn||i.equalUnits(ht,cn))&&(bn(ht),bn(cn)),!xn&&(I.set(ht,cn),I.set(cn,ht),G.add(de==="local"?cn:ht))}return{partner:I,drop:G}}function Yt(I,G,se){if(re.add(I),Rt.drop.has(I))return null;re.add(se);let be=G==="local"?I:se,xe=G==="local"?se:I,fe;return i.equalUnits(be,xe)?(fe=me(be,"local",!0),Ae.get(fe).remote=xe):fe=ye(be,xe),ze({kind:"structure",el:fe,detail:"both-moved",base:null,local:be,remote:xe},{unit:{b:null,l:be,r:xe}}),Ee({kind:"insert",el:fe,source:"both"}),fe}function gn(){if(!q.weak||!V.weak||!q.weak.size||!V.weak.size||!q.unpair)return;let I=new Map;for(let se of q.weak){let be=b(q,se);ut(se)&&ut(be)&&I.set(i.unitHash(be),se)}let G=!1;for(let se of Array.from(V.weak)){let be=b(V,se);if(!ut(se)||!ut(be))continue;let xe=I.get(i.unitHash(be));if(!xe||xe===se||!q.weak.has(xe)||b(q,se)&&b(V,xe))continue;let fe=b(q,xe);fe.tagName===be.tagName&&i.equalUnits(fe,be)&&(q.unpair(xe),V.unpair(se),G=!0)}G&&(q.rematch(),V.rematch())}function K(I,G){if(!I.weak||!I.weak.size||!G.insertedByHash)return;let se=G.insertedByHash();if(!se.size)return;let be=!1;for(let xe of Array.from(I.weak)){let fe=b(I,xe);if(!fe)continue;let oe=I===q?T(fe):J(fe);if(oe){let De=(I===q?S:B)?.get(oe);De&&De.tagName===fe.tagName&&!G.reverse.has(De)&&(I.unpair(xe),be=!0);continue}let Re=se.get(i.unitHash(fe));Re&&Re.some(De=>De.tagName===fe.tagName&&i.equalUnits(De,fe))&&(I.unpair(xe),be=!0)}be&&I.rematch()}function b(I,G){if(!G)return null;if(I.map.has(G))return I.map.get(G);let se=[],be=Fe(G);for(;be&&!I.map.has(be);be=Fe(be))se.push(be);let xe=be;if(!xe||!I.identical.has(xe))return null;I.pairIdenticalChildren(xe);for(let oe=se.length-1;oe>=0;oe--)I.pairIdenticalChildren(se[oe]);let fe=I.map.get(G)||null;return fe&&s.lazyTwins++,fe}function C(I,G,se,be){if(ut(I)&&qn.has(I.tagName)&&!q.identical.has(I)&&(I.previousSibling?.nodeType===3||I.nextSibling?.nodeType===3)){let Re=Fe(I),De=b(q,I),We=b(V,I);De&&We&&$t(De,b(q,Re),q)&&!$t(We,b(V,Re),V)&&(pt||=Da({L:q,R:V,twinIn:b,unitsOf:l,view:L,parentOf:Fe,ignored:o,remoteWins:r.remoteWins,eligible:Ye=>ut(Ye)&&qn.has(Ye.tagName),build:F,out:ce,policy:de,provenance:Ae,textMappers:Ue,segments:le,conflicts:O,conflict:ze,decisions:_e}),pt.ensureOwner(I))}if(G===null)return null;if(be!==void 0)return lt||=Vr(Ae,Fe,q,V,b,F,o,r.remoteWins,O,ze,$,A,w),lt.plan(I,G,se,!!be),be&&(lt.produced(I,be),Pe.add(I)),be;if(Pe.has(I)||Be.has(I))return ze({kind:"structure",el:null,detail:"both-moved",base:I},{subject:I}),Pe.has(I)?null:me(se,G);lt||=Vr(Ae,Fe,q,V,b,F,o,r.remoteWins,O,ze,$,A,w),lt.plan(I,G,se,!0);let xe=b(q,I),fe=b(V,I);(!xe||!fe)&&ze({kind:"structure",el:null,detail:"move-beats-delete",base:I},{subject:I,deleted:xe?"remote":"local"});let oe=F(I,xe,fe,!1);return(G==="local"?Ee:Ge)({kind:"move",el:oe,source:G}),oe}function L(I,G,se,be){return be||!G||G===se?{el:se,asBase:!0,twin:xe=>xe,baseOf:xe=>xe,units:l(se),here:()=>!0,parentOfTwin:()=>se}:{el:G,asBase:!1,twin:xe=>b(I,xe),baseOf:xe=>I.reverse.get(xe),units:l(G),here:xe=>ut(xe)?xe.parentNode===G||G.tagName==="TEMPLATE"&&xe.parentNode===G.content:xe.parent===G||G.tagName==="TEMPLATE"&&xe.parent===G.content}}function $(I,G,se){return!G||se&&se.identical.has(I)?!1:ut(I)?!i.equalUnits(I,G)||!Q(I,G,se):I.value!==G.value}function Q(I,G,se){if(!se||I===G)return!0;let be=[[I,G]];for(;be.length;){let[xe,fe]=be.pop(),oe=l(xe),Re=l(fe);for(let De=0;De<oe.length&&De<Re.length;De++){let We=oe[De],Ye=Re[De];if(!ut(We)||!ut(Ye))continue;let wt=se.map.get(We);if(wt!==void 0&&wt!==Ye)return!1;let at=se.reverse.get(Ye);if(at!==void 0&&at!==We)return!1;be.push([We,Ye])}}return!0}function F(I,G,se,be,xe=!1){let fe=be||(se?r.remoteWins(se):r.remoteWins(I)),oe=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?ce.createElementNS(I.namespaceURI,I.tagName):ce.createElement(I.tagName),Re={base:I,local:G||null,remote:se||null};if(Ae.set(oe,Re),fe&&!be&&G&&$(I,G,q)&&(!se||!i.equalUnits(G,se))&&ze({kind:"structure",el:oe,detail:"remote-wins",base:I,local:G,remote:se||null},{subject:I}),re.add(I),Pe.add(I),G&&re.add(G),se&&re.add(se),r.skipUnchanged&&!xe&&(r.localIsBase||q.identical.has(I))&&se&&V.identical.has(I)&&!r.remoteWins(I)){Re.unchanged=!0;for(let We of I.attributes)We.namespaceURI?oe.setAttributeNS(We.namespaceURI,We.name,We.value):oe.setAttribute(We.name,We.value);return lt?.produced(I,oe),oe}Be.add(I),xe||ie(I,fe?I:G,se,oe);let De=I.tagName;if(vn(I))ke(I,fe?I:G,se,oe);else if(De==="TEXTAREA")oe.textContent=he(I.textContent,(fe?I:G)?(fe?I:G).textContent:I.textContent,se?se.textContent:I.textContent,oe,"text");else if(!pt?.render(I,oe)){let We=ee(I,G,se,fe,oe),Ye=De==="TEMPLATE"&&oe.content?oe.content:oe;for(let wt of We)Ye.appendChild(wt)}return Be.delete(I),lt?.produced(I,oe),oe}function he(I,G,se,be,xe){if(G===se)return G;if(G===I)return se!==I&&Ge({kind:xe,node:be,source:"remote"}),se;if(se===I)return Ee({kind:xe,node:be,source:"local"}),G;let fe=de==="local"?G:se;return ze({kind:xe,node:be,base:I,local:G,remote:se,resolved:fe},{site:"whole",el:be}),_e.push({kind:xe,node:be,source:"both"}),fe}function ke(I,G,se,be){let xe=I.textContent,fe=G?G.textContent:xe,oe=se?se.textContent:xe,Re=d?$r(I,r.mergeTags,!0):null;if(Re&&fe!==oe){let De=se&&se.getAttribute("merge-key")||I.getAttribute("merge-key"),{text:We,warnings:Ye,conflicts:wt}=ji(r.localIsBase?void 0:xe,fe,oe,{parse:Re.recognizer.parse,keyCandidates:De?De.split(/[\s,]+/).filter(Boolean):void 0});for(let at of Ye)console.warn(`[hyper-morph] merge "${Re.raw}": ${at}`);for(let at of r.localIsBase?[]:wt)ze({kind:"json",node:be,name:Re.raw,path:at.path,base:at.base,local:at.local,remote:at.remote,resolved:at.resolved});be.textContent=We,X.add(be),We!==oe?Ee({kind:"text",node:be,source:We===fe?"local":"both"}):We!==xe&&Ge({kind:"text",node:be,source:"remote"});return}be.textContent=he(xe,fe,oe,be,"text")}function ie(I,G,se,be){let xe=new Map;for(let fe of[I,G,se])if(fe)for(let oe of fe.attributes)r.ignoreAttribute(fe,oe.name)||xe.set(oe.name,oe);for(let[fe,oe]of xe){let Re=I?I.getAttribute(fe):null,De=G?G.getAttribute(fe):Re,We=se?se.getAttribute(fe):Re,Ye;De===We?Ye=De:De===Re?(Ye=We,Ge({kind:"attr",el:be,name:fe,source:"remote"})):We===Re?(Ye=De,Ee({kind:"attr",el:be,name:fe,source:"local"})):(Ye=Ne(fe,Re,De,We),Ye===void 0&&(Ye=de==="local"?De:We,ze({kind:"attr",el:be,name:fe,base:Re,local:De,remote:We,resolved:Ye},{el:be,sample:oe})),_e.push({kind:"attr",el:be,name:fe,source:"both"})),Ye!=null&&(oe.namespaceURI?be.setAttributeNS(oe.namespaceURI,oe.name,Ye):be.setAttribute(fe,Ye))}}function Ne(I,G,se,be){if(I==="class"){let xe=We=>new Set((We||"").split(/\s+/).filter(Boolean)),fe=xe(G),oe=xe(se),Re=xe(be),De=new Set;for(let We of new Set([...fe,...oe,...Re])){let Ye=fe.has(We),wt=oe.has(We),at=Re.has(We);(wt===at?wt:wt===Ye?at:wt)&&De.add(We)}return[...De].join(" ")}if(I==="style"){let xe=Ye=>{let wt=new Map;if(!Ye)return wt;let at=0,Wt=null,zt="",bn=()=>{let Tt=zt.indexOf(":");Tt>0&&wt.set(zt.slice(0,Tt).trim(),zt.slice(Tt+1).trim()),zt=""};for(let Tt of Ye){if(Wt){zt+=Tt,Tt===Wt&&(Wt=null);continue}if(Tt==='"'||Tt==="'"){Wt=Tt,zt+=Tt;continue}if(Tt==="("?at++:Tt===")"&&at--,Tt===";"&&at===0){bn();continue}zt+=Tt}return zt.trim()&&bn(),wt},fe=xe(G),oe=xe(se),Re=xe(be),De=new Map,We=!1;for(let Ye of new Set([...fe.keys(),...oe.keys(),...Re.keys()])){let wt=fe.get(Ye)??null,at=oe.get(Ye)??null,Wt=Re.get(Ye)??null,zt;at===Wt?zt=at:at===wt?zt=Wt:Wt===wt?zt=at:(zt=de==="local"?at:Wt,We=!0),zt!=null&&De.set(Ye,zt)}return We?void 0:[...De].map(([Ye,wt])=>`${Ye}: ${wt}`).join("; ")}}function U(I,G,se,be){let xe=I.value,fe=be?xe:G?G.value:"",oe=se?se.value:"";re.add(I),G&&re.add(G),se&&re.add(se);let Re=vo(xe,fe,oe,de),De=Re.text===""?null:ce.createTextNode(Re.text);De&&(Ae.set(De,{base:I.nodes,local:G?G.nodes:null,remote:se?se.nodes:null}),Ue.set(De,Re.mapLocalOffset)),fe!==xe&&oe!==xe?_e.push({kind:"text",node:De,source:"both"}):fe!==xe?Ee({kind:"text",node:De,source:"local"}):oe!==xe&&Ge({kind:"text",node:De,source:"remote"});for(let We of Re.conflicts)ze({kind:"text",node:De,base:xe.slice(We.bs,We.be),local:We.local,remote:We.remote,resolved:We.resolved},{site:"run",bRun:I,lRun:G,rRun:se,node:De,c:We});return De}function Y(I,G){return wr(I,G).every(se=>se.bs===se.be)}function pe(I,G){let se=I?I.value:"",be=G?G.value:"",xe;if(se===be||!be?xe=se:se?Y(se,be)?xe=be:Y(be,se)?xe=se:(xe=de==="local"?se:de==="both"?se+be:be,ze({kind:"structure",el:null,detail:"insert-collision",local:se,remote:be,resolved:xe},{unit:{b:null,l:I,r:G},localLost:de==="remote"})):xe=be,I&&re.add(I),G&&re.add(G),xe==="")return null;let fe=ce.createTextNode(xe);return Ae.set(fe,{base:null,local:I?I.nodes:null,remote:G?G.nodes:null}),se?Ee({kind:"insert",el:fe,source:be&&se===be?"both":"local"}):Ge({kind:"insert",el:fe,source:"remote"}),fe}function ye(I,G){let se={ignored:o,remoteWins:r.remoteWins,inlineCache:Te},be=Re=>l(Re).every(De=>ut(De)?Xn(De,se):De.kind==="text"),xe=null;if(be(I)&&be(G)){let Re=I.textContent,De=G.textContent;Re===De||Y(De,Re)?xe=G:Y(Re,De)&&(xe=I)}if(!xe){let Re=de==="local",De=me(Re?I:G,Re?"local":"remote",!0),We=Ae.get(De);return Re?We.remote=G:We.local=I,ze({kind:"structure",el:De,detail:"insert-collision",local:I,remote:G,resolved:Re?I:G},{unit:{b:null,l:I,r:G},localLost:!Re}),De}let fe=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?ce.createElementNS(I.namespaceURI,I.tagName):ce.createElement(I.tagName);ie(null,I,G,fe),Ae.set(fe,{base:null,local:I,remote:G}),re.add(I),re.add(G);let oe=ae({base:Array.from(xe.childNodes),local:Array.from(I.childNodes),remote:Array.from(G.childNodes),out:ce,policy:de,idOf:{local:m,remote:k},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,provenance:Ae,textMappers:Ue,conflicts:O,conflict:ze,scope:{base:null,local:I,remote:G,units:[],at:0},synthetic:!0,decisions:_e,node:fe});le.push(...oe.segments);for(let Re of oe.nodes)fe.appendChild(Re);return fe}function me(I,G,se=!1){if(!se&&ut(I)){let oe=Rt.partner.get(I);if(oe)return Yt(I,G,oe)}if(!ut(I)){if(I.value==="")return null;let oe=I.kind==="comment"?ce.createComment(I.value):ce.createTextNode(I.value);return Ae.set(oe,{base:null,local:G==="local"?I.nodes:null,remote:G==="remote"?I.nodes:null}),re.add(I),oe}let be=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?ce.createElementNS(I.namespaceURI,I.tagName):ce.createElement(I.tagName);for(let oe of I.attributes)oe.namespaceURI?be.setAttributeNS(oe.namespaceURI,oe.name,oe.value):be.setAttribute(oe.name,oe.value);Ae.set(be,{base:null,local:G==="local"?I:null,remote:G==="remote"?I:null}),re.add(I);let xe=I.tagName==="TEMPLATE"&&be.content?be.content:be,fe=G==="local"?q:V;for(let oe of l(I)){let Re=ut(oe)?fe.reverse.get(oe):null;if(Re&&C(Re,null,null),Re&&Pe.has(Re)){ze({kind:"structure",el:null,detail:"both-moved",base:Re},{subject:Re});continue}if(Re&&!Be.has(Re)){let We=b(q,Re)||null,Ye=b(V,Re)||null;if(We||Ye){lt||=Vr(Ae,Fe,q,V,b,F,o,r.remoteWins,O,ze,$,A,w),lt.plan(Re,G,oe,!0);let wt=F(Re,We,Ye,!1);G==="local"?Ee({kind:"move",el:wt,source:"local"}):Ge({kind:"move",el:wt,source:"remote"}),xe.appendChild(wt);continue}}let De=me(oe,G);De&&xe.appendChild(De)}if(!se&&Rt.drop.size&&I.tagName==="DIV"&&!xe.firstChild&&!I.attributes.length&&!(G==="local"?m(I):k(I))&&!fe.reverse.has(I)&&!o(I)&&!r.remoteWins(I)){let oe=I.firstChild;if(oe&&oe===I.lastChild&&ut(oe)&&(Rt.drop.has(oe)||dt?.has(oe)))return(dt||=new WeakSet).add(I),null}return be}function ee(I,G,se,be,xe){G&&q.identical.has(I)&&q.pairIdenticalChildren(I),se&&V.identical.has(I)&&V.pairIdenticalChildren(I);let fe=L(q,G,I,be),oe=L(V,se,I,!1),Re=l(I),De=new Set(Re),We=new Map;for(let ue=0;ue<Re.length;ue++)We.set(Re[ue],ue);let Ye=[],wt=new Set,at=new Map,Wt=new Set,zt=et&&[],bn=et&&[],Tt=new Set,ht=[],Qe=null,Mt=new Map;if(!fe.asBase&&!oe.asBase&&!q.identical.has(I)&&!V.identical.has(I))for(let ue of Re){if(!ut(ue)||!qn.has(ue.tagName))continue;let Ke=fe.twin(ue),He=oe.twin(ue);Ke&&He&&(!fe.here(Ke)||!oe.here(He))&&C(ue,null,null)}bo();let bt=ue=>{let Ke=[];for(let He of ue.units){if(Tt.has(He))continue;let it=ue.baseOf(He);it&&De.has(it)&&Ke.push(it)}return Ke},Ut=ue=>bt(ue).map(Ke=>We.get(Ke)),En=ue=>ue.every((Ke,He)=>He===0||Ke>=ue[He-1]),cn=!fe.asBase&&!En(Ut(fe)),xn=!oe.asBase&&!En(Ut(oe));cn&&xn&&ze({kind:"structure",el:xe,detail:"both-reordered",base:I},{subject:I,lKept:bt(fe),rKept:bt(oe)});let en=xn||!cn?{V:oe,A:V,side:"remote",other:fe,otherA:q,otherSide:"local"}:{V:fe,A:q,side:"local",other:oe,otherA:V,otherSide:"remote"};cn?Ee({kind:"move",el:null,source:xn?"both":"local",base:I}):xn&&Ge({kind:"move",el:null,source:"remote",base:I});let Hn=fe.asBase?[]:fe.units.filter(ue=>!fe.baseOf(ue)&&!Tt.has(ue)&&!Rt.partner.has(ue)),Ir=oe.asBase?[]:oe.units.filter(ue=>!oe.baseOf(ue)&&!Tt.has(ue)&&!Rt.partner.has(ue)),zn=new Map;if(Hn.length&&Ir.length){let ue=new Map,Ke=new Map;for(let Xe of Ir){if(ut(Xe)){let Nt=k(Xe);Nt&&ue.set(Nt,Xe)}let Ze=i.unitHash(Xe);Ke.has(Ze)||Ke.set(Ze,[]),Ke.get(Ze).push(Xe)}let He=(Xe,Ze)=>{let Nt=Xe.units.indexOf(Ze);for(let tt=Nt-1;tt>=0;tt--){let ft=Xe.baseOf(Xe.units[tt]);if(ft)return ft}return"start"},it=new Map,Et=new Map;for(let Xe of Ir){let Ze=He(oe,Xe);ut(Xe)?(Et.has(Ze)||Et.set(Ze,[]),Et.get(Ze).push(Xe)):Xe.kind==="text"&&!it.has(Ze)&&it.set(Ze,Xe)}for(let Xe of Hn){let Ze=null;if(ut(Xe)){let tt=m(Xe);tt&&ue.has(tt)&&!zn.has(ue.get(tt))&&(Ze=ue.get(tt))}else if(Xe.kind==="text"){let tt=it.get(He(fe,Xe));tt&&!zn.has(tt)&&(Ze=tt)}let Nt=!!T(Xe);if(!Ze&&!Nt){let tt=Ke.get(i.unitHash(Xe));tt&&(Ze=tt.find(ft=>!zn.has(ft)&&ut(ft)===ut(Xe)&&(ut(ft)?ft.tagName===Xe.tagName&&!J(ft):ft.kind===Xe.kind)&&i.equalUnits(Xe,ft))||null)}if(!Ze&&ut(Xe)&&!Nt){let tt=g.local(Xe),ft=(Et.get(He(fe,Xe))||[]).filter(yt=>{let Vt=g.remote(yt);return!zn.has(yt)&&yt.tagName===Xe.tagName&&!J(yt)&&!(tt&&Vt&&tt!==Vt)&&i.similar(Xe,yt)});ft.length===1&&(Ze=ft[0])}Ze&&(zn.set(Ze,Xe),zn.set(Xe,Ze))}}let po=ue=>{if(pt?.consumes(ue))return null;if(re.has(ue)||lt?.has(ue))return at.get(ue)||null;let Ke=fe.twin(ue),He=oe.twin(ue),it=Ke&&!fe.asBase&&!fe.here(Ke),Et=He&&!oe.asBase&&!oe.here(He);if(it||Et){if((!Ke||!He)&&ze({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:Ke?"remote":"local"}),!st(ue))return ut(ue)?(lt||=Vr(Ae,Fe,q,V,b,F,o,r.remoteWins,O,ze,$,A,w),it&<.plan(ue,"local",Ke),Et&<.plan(ue,"remote",He)):re.add(ue),null;ze({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue})}if(Ke&&!He&&!fe.asBase&&!oe.asBase&&ut(ue)&&qn.has(ue.tagName)&&!r.remoteWins(ue)&&!r.remoteWins(Ke)&&$(ue,Ke,q)&&Kd(ue,we(oe.el),o)){let ft={ignored:o,remoteWins:r.remoteWins,inlineCache:Te},yt=Vt=>ut(Vt)?Xn(Vt,ft):Vt.kind==="text";if(l(ue).every(yt)&&l(Ke).every(yt)){let Vt=ae({base:[ue],local:[Ke],remote:[],blocks:new Set([ue,Ke]),out:ce,policy:de,L:q,R:V,idOf:{base:p,local:m,remote:k},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(rn,Rn,ir)=>F(rn,Rn,ir,!1),cloneUnit:me,mergeAttrs:ie,atomKey:i.exactUnitKey,moveIn:C,moveBuilt:C,movePlanned:C,provenance:Ae,textMappers:Ue,conflicts:O,conflict:ze,scope:{base:I,local:fe.el,remote:oe.el,units:Re,at:We.get(ue)},decisions:_e,node:xe});le.push(...Vt.segments),re.add(ue),re.add(Ke);let Pt=ce.createDocumentFragment();for(let rn of Vt.nodes)Pt.appendChild(rn);return at.set(ue,Pt),at.set(Ke,Pt),Pt}}if(!Ke&&!He)return re.add(ue),Ge({kind:"remove",source:"both",base:ue}),null;if(!Ke&&!$(ue,He,V))return re.add(ue),Ee({kind:"remove",source:"local",base:ue}),null;if(!He&&!$(ue,Ke,q))return re.add(ue),Ge({kind:"remove",source:"remote",base:ue}),et&&(et.remove(Ke),zt.push({bk:ue,lk:Ke})),null;let Xe=!Ke||!He,Ze=fe.asBase?b(q,ue)||null:Ke,Nt=oe.asBase&&ut(ue)&&(V.identityPaired.has(ue)||!g.base(ue))&&b(V,ue)||He,tt;return ut(ue)?tt=F(ue,Ze,Nt,fe.asBase):ue.kind==="comment"?tt=Je(ue,Ze,He,fe.asBase):tt=U(ue,Ze,He,fe.asBase),re.add(ue),tt&&(at.set(ue,tt),Ke&&at.set(Ke,tt),He&&at.set(He,tt),Xe&&(ze({kind:"structure",el:tt,detail:"edit-beats-delete",base:ue},{subject:ue,deleted:Ke?"remote":"local"}),Ke?Ee({kind:"insert",el:tt,source:"local"}):Ge({kind:"insert",el:tt,source:"remote"}))),tt},or=(ue,Ke,He,it)=>{if(pt?.consumes(ue))return null;if(re.has(ue))return at.get(ue)||null;let Et=Ke.baseOf(ue);if(Et&&De.has(Et))return Tt.has(Et)&&!Tt.has(ue)?Jo(Et,ue,it):po(Et);if(Et)return ri(Et,ue,it);let Xe=zn.get(ue);if(Xe){let Nt=it==="local"?ue:Xe,tt=it==="local"?Xe:ue,ft;return ut(Nt)?i.equalUnits(Nt,tt)?(ft=me(Nt,"local"),ft&&(Ae.get(ft).remote=tt)):ft=ye(Nt,tt):ft=pe(Nt,tt),re.add(Nt),re.add(tt),ft&&(at.set(Nt,ft),at.set(tt,ft),ut(Nt)&&Ee({kind:"insert",el:ft,source:"both"})),ft}let Ze=me(ue,it);return Ze&&(at.set(ue,Ze),it==="local"?Ee({kind:"insert",el:Ze,source:"local"}):(Ge({kind:"insert",el:Ze,source:"remote"}),et&&ut(ue)&&!Rt.partner.has(ue)&&bn.push({su:ue,node:Ze}))),Ze},Jo=(ue,Ke,He)=>{let it;return ut(ue)?(it=C(ue,He,Ke),it&&re.add(Ke)):(it=me(Ke,He),re.add(Ke),it&&(He==="local"?Ee:Ge)({kind:"insert",el:it,source:He})),it&&at.set(Ke,it),it},ri=(ue,Ke,He)=>{C(ue,null,null);let Et=b(He==="local"?V:q,ue),Xe=Ke,Ze=Et?$t(Et,He==="local"?se:G,He==="local"?V:q):!1,Nt=Et&&!Ze&&!Bt(ue,Et);if(Nt&&He===en.otherSide)return ze({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),null;if(Nt&&ze({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),Et||ze({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:He==="local"?"remote":"local"}),Be.has(ue)){ze({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue});let ft=me(Xe,He);return ft&&at.set(Ke,ft),ft}ut(ue)&&(lt||=Vr(Ae,Fe,q,V,b,F,o,r.remoteWins,O,ze,$,A,w),lt.plan(ue,He,Xe,!0));let tt=ut(ue)?F(ue,He==="local"?Xe:b(q,ue)||null,He==="remote"?Xe:b(V,ue)||null,!1):null;return tt&&(at.set(ue,tt),at.set(Ke,tt),Et&&at.set(Et,tt),He==="local"?Ee({kind:"move",el:tt,source:"local"}):Ge({kind:"move",el:tt,source:"remote"})),tt};for(let ue of en.V.units){if(Tt.has(ue)){if(Qe?.has(ue)){for(let it of Qe.get(ue))wt.has(it)||(Ye.push(it),wt.add(it));continue}let He=at.get(ue);wt.has(He)||(Ye.push(He),wt.add(He));continue}if(re.has(ue)&&!(at.get(ue)&&wt.has(at.get(ue)))){let He=en.V.baseOf(ue);He&&!De.has(He)&&ze({kind:"structure",el:null,detail:"both-moved",base:He},{subject:He});continue}let Ke=or(ue,en.V,en.A,en.side);Ke&&!wt.has(Ke)&&(Ye.push(Ke),wt.add(Ke),!en.V.baseOf(ue)&&!zn.has(ue)&&!Tt.has(ue)&&Wt.add(Ke))}for(let ue of ht)wt.has(ue.frag)||(Ye.splice(ue.previous&&wt.has(ue.previous)?Ye.indexOf(ue.previous)+1:Lr(ue.at),0,ue.frag),wt.add(ue.frag));if(!en.other.asBase){let ue=en.other,Ke=en.otherSide,He=en.otherA,it=null,Et=0,Xe=null;for(let Ze of ue.units){let Nt=Mt.get(Ze)||at.get(Ze);if(Nt&&wt.has(Nt)){it=Nt,Xe=null;continue}if(re.has(Ze)){let yt=ue.baseOf(Ze);yt&&!De.has(yt)&&ze({kind:"structure",el:null,detail:"both-moved",base:yt},{subject:yt});continue}let tt=or(Ze,ue,He,Ke);if(!tt)continue;let ft;if(Xe)ft=Ye.indexOf(Xe)+1;else if(it){if(ft=Ye.indexOf(it)+1,Ke==="remote")for(;ft<Ye.length&&Wt.has(Ye[ft]);)ft++}else ft=Et++;Ye.splice(ft,0,tt),wt.add(tt),Xe=tt}}for(let ue=0;ue<Re.length;ue++){let Ke=Re[ue];if(re.has(Ke))continue;let He=po(Ke);He&&Ye.splice(Lr(ue),0,He)}return et&&zt.length&&bn.length&&Zo(),Ye;function Zo(){if(cn||xn)return;let ue=new Set(Ye),Ke=yt=>yt&&De.has(yt)&&ue.has(at.get(yt))?yt:null,He=(yt,Vt)=>{let Pt=[{prev:null,units:[]}];for(let rn of yt){let Rn=Ke(Vt(rn));Rn?Pt.push({prev:Rn,units:[]}):Pt[Pt.length-1].units.push(rn)}return Pt},it=He(Re,yt=>yt),Et=He(oe.units,oe.baseOf),Xe=fe.asBase?null:He(fe.units,fe.baseOf),Ze=yt=>yt.length===it.length&&yt.every((Vt,Pt)=>Vt.prev===it[Pt].prev);if(!Ze(Et)||Xe&&!Ze(Xe))return;let Nt=new Map(zt.map(yt=>[yt.bk,yt])),tt=new Map(bn.map(yt=>[yt.su,yt])),ft=yt=>yt?Ye.indexOf(at.get(yt)):-1;for(let yt=0;yt<it.length;yt++){if(it[yt].units.length!==1||Et[yt].units.length!==1)continue;let Vt=Nt.get(it[yt].units[0]),Pt=tt.get(Et[yt].units[0]);if(!Vt||!Pt||Xe&&(Xe[yt].units.length!==1||Xe[yt].units[0]!==Vt.lk))continue;let rn=ft(it[yt].prev);(yt+1<it.length?ft(it[yt+1].prev):Ye.length)-rn!==2||Ye[rn+1]!==Pt.node||go(Vt.bk,Vt.lk,Pt.su)&&et.link(Vt.lk,Pt.node)}}function sr(ue,Ke,He,it){let Et=Pt=>{let rn=Pt.filter(ut);return rn.length===1?rn[0]:null},Xe=Et(ue),Ze=Et(Ke),Nt=Et(He);if(!Xe||!Ze||!Nt)return;let tt=ue.indexOf(Xe);if(Ke.indexOf(Ze)!==tt||He.indexOf(Nt)!==tt||ue.length!==Ke.length||ue.length!==He.length)return;for(let Pt=0;Pt<ue.length;Pt++)if(Pt!==tt&&(ue[Pt].value!==Ke[Pt].value||ue[Pt].value!==He[Pt].value))return;if((fe.asBase?Xe:fe.twin(Xe))!==Ze||oe.twin(Xe)||V.reverse.get(Nt)||Ze!==Xe&&$(Xe,Ze,q))return;let ft=it.filter(Pt=>Pt.nodeType===1);if(ft.length!==1||Ae.get(ft[0])?.remote!==Nt)return;let yt=Pt=>Pt.map(rn=>ut(rn)?"":rn.value??rn.nodeValue).join(""),Vt=it.indexOf(ft[0]);yt(it.slice(0,Vt))!==yt(ue.slice(0,tt))||yt(it.slice(Vt+1))!==yt(ue.slice(tt+1))||go(Xe,Ze,Nt)&&et.link(Ze,ft[0])}function go(ue,Ke,He){if(!ut(Ke)||!ut(He)||!ut(ue)||Ke.namespaceURI!==He.namespaceURI||Ke.localName===He.localName)return!1;for(let Ze of[Ke,He])if(Ze.tagName==="TEMPLATE"||vn(Ze)||Ze.querySelector("template"))return!1;if(r.remoteWins(ue)||r.remoteWins(He)||o(He)||Ke.attributes.length!==He.attributes.length)return!1;for(let Ze of Ke.attributes)if(He.getAttributeNS(Ze.namespaceURI,Ze.localName)!==Ze.value)return!1;let it=Ke.childNodes,Et=He.childNodes;if(it.length!==Et.length)return!1;for(let Ze=0;Ze<it.length;Ze++)if(!it[Ze].isEqualNode(Et[Ze]))return!1;let Xe=[[ue,He]];for(;Xe.length;){let[Ze,Nt]=Xe.pop();if(Ze.children.length!==Nt.children.length)return!1;for(let tt=0;tt<Nt.children.length;tt++){let ft=V.reverse.get(Nt.children[tt]);if(ft!==void 0&&ft!==Ze.children[tt])return!1;Xe.push([Ze.children[tt],Nt.children[tt]])}}return!0}function Lr(ue){for(let Ke=ue-1;Ke>=0;Ke--){let He=at.get(Re[Ke]);if(He){let it=Ye.indexOf(He);if(it>=0)return it+1}}return 0}function bo(){if((fe.asBase||q.identical.has(I))&&(oe.asBase||V.identical.has(I)))return;let ue={ignored:o,remoteWins:r.remoteWins,inlineCache:Te},Ke=kt=>ut(kt)?Xn(kt,ue):kt.kind==="text";if(!fe.asBase&&!oe.asBase)for(let kt of Re){if(!ut(kt)||!qn.has(kt.tagName))continue;let rt=fe.twin(kt),jt=oe.twin(kt);if(!rt&&jt||rt&&!jt){let ct=Ua({base:Re,views:[{V:fe,A:q,idOf:g.local},{V:oe,A:V,idOf:g.remote}],eligible:Lt=>ut(Lt)&&qn.has(Lt.tagName)&&!o(Lt)&&!r.remoteWins(Lt),baseId:g.base,ignored:o,remoteWins:r.remoteWins,atomKey:i.exactUnitKey});ct&&(fe=ct[0],oe=ct[1]);break}}let He=!fe.asBase&&!oe.asBase&&Re.length>=2&&qn.has(Re[0].tagName)&&fe.units.length===Re.length&&oe.units.length===Re.length?wa({base:Re,local:fe.units,remote:oe.units,localTwin:fe.twin,remoteTwin:oe.twin,eligible:kt=>ut(kt)&&qn.has(kt.tagName)&&!o(kt)&&!r.remoteWins(kt),nodes:{base:Array.from(we(I).childNodes),local:Array.from(we(fe.el).childNodes),remote:Array.from(we(oe.el).childNodes)}}):null,it=null,Et=null;if(!He&&!fe.asBase&&!oe.asBase&&(qi(Re)||qi(fe.units)||qi(oe.units))){let kt={ignored:o,remoteWins:()=>!1},rt=ct=>Ke(ct)||ut(ct)&&r.remoteWins(ct)&&Cn.has(ct.tagName)&&Xn(ct,kt),jt=ct=>ut(ct)?qn.has(ct.tagName)&&!o(ct)&&!r.remoteWins(ct)&&l(ct).every(rt):ct.kind==="text";it=$a({onUncertainOwner:ct=>{let Lt=r.identity.local(ct.local);Lt&&Lt===r.identity.remote(ct.remote)||(Et||=[]).push(ct)},onUncertainSource:ct=>{ot||(ot=new Map);let Lt=ot.get(ct.source);Lt||ot.set(ct.source,Lt=[]);for(let tn of Lt)if(tn.side===ct.side&&tn.from===ct.from&&tn.to===ct.to)return;Lt.push(ct)},base:Re,views:[{V:fe,A:q,idOf:g.local},{V:oe,A:V,idOf:g.remote}],eligible:jt,ignored:o,remoteWins:r.remoteWins,baseId:g.base,atomKey:i.exactUnitKey})}if(Et){Qe||=new Map;for(let kt of Et){let{source:rt,local:jt,remote:ct}=kt,Lt={map:new Map,reverse:new Map,identical:new Set},tn=ae({base:[rt],local:[jt],remote:[ct],out:ce,policy:"both",L:Lt,R:Lt,ignored:o,remoteWins:r.remoteWins,atomKey:i.exactUnitKey,cloneUnit:me,provenance:Ae,textMappers:Ue,conflicts:O,decisions:_e,conflict:(Dt,Kt)=>ze(Dt,{...Kt,policy:"both"}),scope:{base:I,local:fe.el,remote:oe.el,units:Re,at:We.get(rt)},node:xe});le.push(...tn.segments);for(let Dt of[rt,jt,ct])re.add(Dt),Tt.add(Dt),Qe.set(Dt,tn.nodes),at.set(Dt,tn.nodes[tn.nodes.length-1]);for(let Dt=0;Dt<tn.nodes.length;Dt++)ht.push({frag:tn.nodes[Dt],at:We.get(rt),previous:Dt?tn.nodes[Dt-1]:null})}}let Xe=He?He.blocks:null;if(it){Xe=new Set;for(let kt of it.blocks)Xe.add(kt)}let Ze=kt=>!pt?.consumes(kt)&&(Xe&&Xe.has(kt)||Ke(kt)),Nt=Re.map(Ze);if(!Nt.includes(!0))return;let tt=kt=>{let rt=kt.units,jt=new Map;for(let ln=0;ln<rt.length;ln++)jt.set(rt[ln],ln);let ct=[],Lt=-1;for(let ln=0;ln<Re.length;ln++){if(Nt[ln])continue;let _t=kt.twin(Re[ln]),At=_t?jt.get(_t):void 0;At===void 0||At<=Lt||Ze(_t)||(ct.push([ln,At]),Lt=At)}let tn=[],Dt=-1,Kt=-1;for(let ln=0;ln<=ct.length;ln++){let[_t,At]=ln<ct.length?ct[ln]:[Re.length,rt.length],It={bLo:-1,bHi:-1,from:Kt+1,to:At,inlineStart:-1,inlineEnd:-1,next:At};for(let on=Dt+1;on<_t;on++)Nt[on]&&(It.bLo<0&&(It.bLo=on),It.bHi=on);for(let on=Kt+1;on<At;on++){let lr=rt[on];Ze(lr)&&(It.inlineStart<0&&(It.inlineStart=on),It.inlineEnd=on+1)}tn.push(It),Dt=_t,Kt=At}return{units:rt,list:tn}},ft=tt(fe),yt=tt(oe),Vt=[];for(let kt of[ft,yt])for(let rt of kt.list)rt.bLo>=0&&Vt.push([rt.bLo,rt.bHi]);Vt.sort((kt,rt)=>kt[0]-rt[0]);let Pt=[];for(let[kt,rt]of Vt){let jt=Pt[Pt.length-1];jt&&kt<=jt.hi?jt.hi=Math.max(jt.hi,rt):Pt.push({lo:kt,hi:rt})}let rn=(kt,rt)=>kt.length===rt.length&&kt.every((jt,ct)=>i.equalUnits(jt,rt[ct])),Rn=kt=>!ut(kt)&&kt.kind==="comment",ir=kt=>{if(!kt.length)return[];let rt=(Dt,Kt)=>ut(Dt)?Dt:Dt.nodes[Kt?Dt.nodes.length-1:0],jt=rt(kt[0]),ct=rt(kt[kt.length-1],!0),Lt=Dt=>Dt&&ut(Dt)&&o(Dt);for(;Lt(jt.previousSibling);)jt=jt.previousSibling;for(;Lt(ct.nextSibling);)ct=ct.nextSibling;let tn=[];for(let Dt=jt;Dt&&(tn.push(Dt),Dt!==ct);Dt=Dt.nextSibling);return tn},Vn=kt=>kt.some(rt=>ut(rt)&&o(rt));for(let kt of Pt){let rt=Re.slice(kt.lo,kt.hi+1),jt=null;if(it)for(let _t of rt){let At=it.certificatesBySource.get(_t);At&&(jt||=[]).push(...At)}let ct=fe.asBase?null:Bi(ft,kt),Lt=oe.asBase?null:Bi(yt,kt);if(jt){let _t=[new Set(ct||rt),new Set(Lt||rt)],At=jt.some(It=>!_t[It.side].has(It.target));for(let It of rt)if(Xe.has(It))for(let[on,lr]of[[0,fe],[1,oe]]){let In=lr.twin(It);In&&lr.here(In)&&!_t[on].has(In)&&(At=!0)}if(At)continue}if(rt.some(Rn)||ct&&ct.some(Rn)||Lt&&Lt.some(Rn))continue;let tn=ir(ct||rt),Dt=ir(Lt||rt);if((!ct||rn(rt,ct))&&(!Lt||rn(rt,Lt))&&!(ct&&Vn(tn)))continue;let Kt=ae({base:ir(rt),sourceRetentions:ot?.get(I),local:tn,remote:Dt,out:ce,policy:de,blocks:Xe,scopeUnits:jt?[rt,ct||rt,Lt||rt]:null,certifiedOrigins:jt?(_t,At,It,on,lr,In)=>Ha({certificates:jt,scopes:[rt,ct||rt,Lt||rt],flats:[_t,At,It],keys:[on,lr,In]}):null,prepared:He?He.prepared:null,nativeTransfers:He,L:ct?q:za(q,I),R:Lt?V:za(V,I),idOf:{base:p,local:m,remote:k},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(_t,At,It)=>F(_t,At,It,!1),cloneUnit:me,mergeAttrs:ie,atomKey:i.exactUnitKey,moveIn:C,moveBuilt:C,movePlanned:C,provenance:Ae,textMappers:Ue,conflicts:O,conflict:ze,scope:{base:I,local:fe.asBase?null:fe.el,remote:oe.asBase?null:oe.el,units:Re,at:kt.lo},decisions:_e,node:xe});if(!Kt){if(jt){let _t=Aa({certificates:jt,scopes:[rt,ct||rt,Lt||rt],views:[{V:fe,A:q,idOf:g.local},{V:oe,A:V,idOf:g.remote}],eligible:At=>ut(At)&&qn.has(At.tagName)&&!o(At)&&!r.remoteWins(At),baseId:g.base});for(let At of _t.records){ot||=new Map;let It=ot.get(At.source);It||ot.set(At.source,It=[]),It.push(At)}}continue}if(le.push(...Kt.segments),He){let _t=new Map;for(let At of Kt.nodes){let It=Ae.get(At)?.base;if(!It||_t.has(It))throw new Error("Invalid native transfer owner output");_t.set(It,At)}if(_t.size!==He.owners.length)throw new Error("Incomplete native transfer owner output");for(let At of He.owners){let It=_t.get(At.base);if(!It)throw new Error("Missing native transfer owner output");for(let on of[At.base,At.local,At.remote])re.add(on),Tt.add(on),at.set(on,It);ht.push({frag:It,at:We.get(At.base)})}continue}if(et&&sr(rt,ct||rt,Lt||rt,Kt.nodes),Kt.unitOutputs){Qe||=new Map;for(let At of[...rt,...ct||[],...Lt||[]]){let It=Kt.unitOutputs.get(At)||[];re.add(At),Tt.add(At),Qe.set(At,It),It.length&&at.set(At,It[It.length-1])}let _t=Kt.nodes[Kt.nodes.length-1];if(_t)for(let At of[ct||rt,Lt||rt]){let It=At[At.length-1];It&&Mt.set(It,_t)}for(let At=0;At<Kt.nodes.length;At++)ht.push({frag:Kt.nodes[At],at:kt.lo,previous:At>0?Kt.nodes[At-1]:null});continue}et&&sr(rt,ct||rt,Lt||rt,Kt.nodes);let ln=ce.createDocumentFragment();for(let _t of Kt.nodes)ln.appendChild(_t);for(let _t of[...rt,...ct||[],...Lt||[]])re.add(_t),Tt.add(_t),at.set(_t,ln);ht.push({frag:ln,at:kt.lo})}}}function te(I,G){let se=Ae.get(I);return se&&se.unchanged?!se.remote||se.remote===G?!0:W(se.remote,G):I.tagName!==G.tagName||!Ie(I,G)?!1:je(we(I),we(G))}function W(I,G){return I===G?!0:I.tagName!==G.tagName||I.namespaceURI!==G.namespaceURI||!Ie(I,G)?!1:ne(we(I),we(G))}function ne(I,G){let se=Se(I,o),be=Se(G,o);if(se.length!==be.length)return!1;for(let xe=0;xe<se.length;xe++){let fe=se[xe],oe=be[xe];if(typeof fe=="string"||typeof oe=="string"){if(fe!==oe)return!1}else{if(fe.nodeType!==oe.nodeType)return!1;if(fe.nodeType===1){if(!W(fe,oe))return!1}else if(fe.nodeValue!==oe.nodeValue)return!1}}return!0}function we(I){return I.tagName==="TEMPLATE"&&I.content?I.content:I}function Ie(I,G){let se=0;for(let be of I.attributes)if(!r.ignoreAttribute(I,be.name)&&(se++,G.getAttribute(be.name)!==be.value))return!1;for(let be of G.attributes)r.ignoreAttribute(G,be.name)||se--;return se===0}function je(I,G){let se=Se(I,xe=>{let fe=Ae.get(xe);return!!(fe&&fe.pinned)}),be=Se(G,o);if(se.length!==be.length)return!1;for(let xe=0;xe<se.length;xe++){let fe=se[xe],oe=be[xe];if(typeof fe=="string"||typeof oe=="string"){if(fe!==oe)return!1}else{if(fe.nodeType!==oe.nodeType)return!1;if(fe.nodeType===1){if(!te(fe,oe))return!1}else if(fe.nodeValue!==oe.nodeValue)return!1}}return!0}function Se(I,G){let se=[],be=null;for(let xe=I.firstChild;xe;xe=xe.nextSibling){if(xe.nodeType===3){be=be===null?xe.nodeValue:be+xe.nodeValue;continue}xe.nodeType===1&&G(xe)||(be!==null&&(be!==""&&se.push(be),be=null),se.push(xe))}return be!==null&&be!==""&&se.push(be),se}function Je(I,G,se,be){let xe=I.value,fe=be?xe:G?G.value:"",oe=se?se.value:"";re.add(I),G&&re.add(G),se&&re.add(se);let Re=fe===oe?fe:fe===xe?oe:oe===xe||de==="local"?fe:oe,De={site:"comment",bRun:I,lRun:G,rRun:se,node:null};if(fe!==xe&&oe!==xe&&fe!==oe&&ze({kind:"text",node:null,base:xe,local:fe,remote:oe,resolved:Re},De),!G&&!se)return null;let We=ce.createComment(Re);return De.node=We,Ae.set(We,{base:I.nodes,local:G?G.nodes:null,remote:se?se.nodes:null}),We}function nt(I,G){let se=b(G,I);if(!se)return null;let be=ut(se)?se.parentNode:se.parent,xe=ut(I)?I.parentNode:I.parent;return b(G,xe)===be?null:G.reverse.get(be)||null}function st(I){let G=new Set([I]),se=I;for(let be=0;be<64;be++){let xe=nt(se,q)||nt(se,V);if(!xe)return!1;if(xe===I||ut(I)&&ut(xe)&&I.contains(xe)||G.has(xe))return!0;G.add(xe),se=xe}return!0}function $t(I,G,se){if(!G)return!1;let be=ut(I)?I.parentNode:I.parent;return be===G||G.tagName==="TEMPLATE"&&be===G.content}function Bt(I,G){let se=Fe(I),be=b(q,se);if(be&&$t(G,be,q))return!0;let xe=b(V,se);return!!(xe&&$t(G,xe,V))}}function za(e,t){return e.map.get(t)?Va():{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 Va(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Wa=new Set(["INPUT","OPTION","TEXTAREA"]),$i=/[\t\n\f\r ]+/;function Ka(e,t,n,r){let o=e.ownerDocument,{provenance:s,textMappers:i}=n,l=r.hooks,a=[],c=[],d=[],u=new Set,f=[],p=[],m=new Map,k=new Set,g=new Map,h=n.conflicts.length>0||r.trackInserted===!0,y=new Map,A=new Set,w=new Map,v=(b,C)=>{let L=w.get(b);L||w.set(b,L=new Set),L.add(C)},E=h?new Set:null,N=(b,C,L)=>{let $=l.beforeAttributeUpdated(b,C,L);return h&&$===!1&&v(C,b),$},_=b=>!!b&&(b===e||e.contains(b)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(b)),M=new Map,j=new Map,R=new Map,D=new Set,B=new Map;(function b(C){let L=s.get(C);if(L){if(C.nodeType===1){let Q=L.local?r.toLive(L.local):null;Q&&_(Q)&&Q.nodeType===1&&(M.set(C,Q),j.set(Q,C))}else if(Array.isArray(L.local)){let Q=V(L.local,L.local.map(F=>r.toLive(F)).filter(F=>F&&_(F)&&F.nodeType===C.nodeType));if(Q.length&&(M.set(C,Q[0]),j.set(Q[0],C),R.set(C,Q)),Array.isArray(L.caret))for(let F of L.caret){let he=r.toLive(F.node);if(!he||!_(he)||he.nodeType!==3)continue;let ke=B.get(he);Array.isArray(ke)||B.set(he,ke=[]),ke.push({merged:C,from:F.from,to:F.to,flatStart:F.flatStart})}else{let F=0;for(let he of Q)B.set(he,{merged:C,shift:F}),F+=he.nodeValue.length}}}let $=C.nodeType===1&&C.tagName==="TEMPLATE"&&C.content?C.content.childNodes:C.childNodes;for(let Q of $)b(Q)})(t);let S=new Set;for(let b of M.values())S.add(b);for(let b of R.values())for(let C of b)S.add(C);let T=r.localRoot&&r.localRoot!==e?new Set:null;if(T){for(let b=r.localRoot.firstElementChild;b;b=b.nextElementSibling)if(b.tagName==="HEAD")for(let C=b.firstElementChild;C;C=C.nextElementSibling){let L=r.toLive(C);L&&T.add(L)}}for(let b of n.segments||[])Ce(b);let J=r.restoreFocus===!1?null:Gd(o,B);r.childrenOnly?Ae(Me(e),Me(t)):Fe(e,t);for(let{node:b,parent:C}of f)u.has(b)||!b.parentNode||b.nodeType===1&&(r.ignored(b)||Ue(b))||ot(b,C);return Yd(o,J,B,i,R,g,D),{applied:a,moved:c,replaced:d,identities:p,mergedScriptsLive:k,liveOf:M,heldBy:g,runOf:R,keptRuns:D,insertedLive:y,vetoed:A,vetoedAttrs:w,removedVetoes:E};function q(b,C){let L=b.slice(C.bs,C.be),$=0;for(;$<L.length&&$<C.text.length&&L[$]===C.text[$];)$++;let Q=0;for(;Q<L.length-$&&Q<C.text.length-$&&L[L.length-1-Q]===C.text[C.text.length-1-Q];)Q++;return{bs:C.bs+$,be:C.be-Q,text:C.text.slice($,C.text.length-Q)}}function V(b,C){if(!C.length)return C;let L=[];for(let F of b){let he=F.parentNode;if(!he)continue;let ke=m.get(he);if(!ke){ke=new Set;for(let ie=he.firstChild;ie;ie=ie.nextSibling)ie.nodeType===3&&ke.add(r.toLive(ie));m.set(he,ke)}L.includes(ke)||L.push(ke)}let $={has:F=>L.some(he=>he.has(F))},Q=[];for(let F of C){Q.push(F);for(let he=F.nextSibling;he&&he.nodeType===3&&!$.has(he)&&!Q.includes(he);he=he.nextSibling)Q.push(he)}return Q}function Ce(b){let C=[];for(let ee of b.localNodes){let te=r.toLive(ee.node);if(!te||!_(te)||te.nodeType!==3)return;C.push(te)}let L=V(b.localNodes.map(ee=>ee.node),C);if(!L.length)return;let $=L.map(ee=>ee.nodeValue).join(""),{flatLocal:Q,lToM:F,mapLocal:he}=b;if($===Q)return;let ke=b.textNodes.map(ee=>({node:ee.node,ms:ee.ms,me:ee.me})),ie=[],Ne=0;for(let ee of L)ie.push(Ne),Ne+=ee.nodeValue.length;let U=(ee,te)=>L.find((W,ne)=>ie[ne]<=ee&&ee+te<=ie[ne]+W.nodeValue.length)||null,Y=[],pe=0;for(let ee of wr(Q,$).map(te=>q(Q,te))){let te=ee.bs+pe;pe+=ee.text.length-(ee.be-ee.bs);let W,ne;if(ee.be>ee.bs){W=F[ee.bs];let we=W>=0;for(let Ie=ee.bs;we&&Ie<ee.be;Ie++)F[Ie]!==W+(Ie-ee.bs)&&(we=!1);if(!we)continue;ne=W+(ee.be-ee.bs)}else{let we=ee.bs>0?F[ee.bs-1]:0,Ie=ee.bs<Q.length?F[ee.bs]:0;if(we<0||Ie<0)continue;W=ne=he(ee.bs)}Y.push({ms:W,me:ne,text:ee.text,live:ne===W?U(te,ee.text.length):null})}Y.sort((ee,te)=>te.ms-ee.ms);let ye=(ee,te)=>(R.get(ee.node)||[M.get(ee.node)]).includes(te),me=ee=>!!ee&&ee.nodeType===1&&Cn.has(ee.tagName);for(let ee of Y){let te=ke.find(ne=>ne.ms<=ee.ms&&ee.me<=ne.me&&ee.ms<ne.me);if(te&&ee.live&&te.ms===ee.ms&&!ye(te,ee.live)){let ne=ke.find(we=>we.me===ee.ms&&ye(we,ee.live));ne&&(te=ne)}if(!te&&ee.me===ee.ms){let ne=ke.find(Se=>Se.me===ee.ms),we=ke.find(Se=>Se.ms===ee.ms),Ie=ne||we;if(!Ie)continue;let je=Ie.node;for(;me(je.parentNode)&&(ne?je.parentNode.lastChild:je.parentNode.firstChild)===je;)je=je.parentNode;if(je===Ie.node)te=Ie;else{let Se=je.ownerDocument.createTextNode(ee.text);je.parentNode.insertBefore(Se,ne?je.nextSibling:je);continue}}if(!te)continue;let W=te.node.nodeValue;te.node.nodeValue=W.slice(0,ee.ms-te.ms)+ee.text+W.slice(ee.me-te.ms),te.me+=ee.text.length-(ee.me-ee.ms)}}function Me(b){return b.nodeType===1&&b.tagName==="TEMPLATE"&&b.content?b.content:b}function Fe(b,C){u.add(b);let L=s.get(C);if(L&&L.remote&&n.remoteIdOf){let Q=n.remoteIdOf(L.remote);Q&&p.push([b,Q])}if(L&&L.unchanged){r.opaque&&r.opaque(b)||(n.customIdentity&&L.remote&&le(b,L.remote),L.remote&&X(b,L.remote));return}if(l.beforeNodeMorphed(b,C)===!1){A.add(C);return}Ve(b,C,r.keepLiveOnly&&L&&L.local&&L.local.nodeType===1&&L.local!==b?L.local:null);let $=b.tagName;if(vn(b))b.textContent!==C.textContent&&(a.push({kind:"text",node:b,before:b.textContent,after:C.textContent}),b.textContent=C.textContent),n.mergedScripts.has(C)&&k.add(b);else if($==="TEXTAREA")K(b,C,L);else{Yt(b,C,L);let Q=$==="TEMPLATE"&&b.content?b.content:b,F=$==="TEMPLATE"&&C.content?C.content:C;r.opaque&&r.opaque(b)||r.protectFocusedValue==="subtree"&<(b)&&b!==o.body?ce(Q):Ae(Q,F)}l.afterNodeMorphed(b,C)}function ce(b){for(let C=b.firstChild;C;C=C.nextSibling){let L=j.get(C);L&&M.get(L.parentNode)!==b||(u.add(C),C.nodeType===1&&ce(C))}}function Ae(b,C){let L=Be(b.firstChild),$=new Set;for(let Q of Array.from(C.childNodes)){let F=M.get(Q);F&&u.has(F)&&!$.has(F)&&(F=null);let he=s.get(Q);if(he&&he.pinned){F&&F.nodeType===1&&((F.parentNode!==b||Be(F.nextSibling)!==L)&&Te(b,F,L),u.add(F),$.add(F));continue}if(F&&F.nodeType===1){if(F!==L){let Ne=F.parentNode;if(Ne===b&&L&&pt(F)){let U=F.nextSibling;for(let Y=L;Y&&Y!==F;){let pe=Y.nextSibling;Te(b,Y,U),Y=pe}}else Te(b,F,L),Ne!==b&&(c.push(F),a.push({kind:"move",el:F,from:Ne,to:b}))}$.add(F),Fe(F,Q),L=Be(F.nextSibling);continue}if(F&&F.nodeType!==1){let Ne=R.get(Q)||[F],U=Ne.map(pe=>pe.nodeValue).join(""),Y=Q.nodeValue;if(Q.nodeType===3){let pe=_e(Q);pe!=null&&U!==pe&&(Y=vo(pe,U,Q.nodeValue).text)}if(Ne.length>1&&U===Y&&!Ne.includes(L,1)&&Ne.every((pe,ye)=>pe.parentNode===b&&(ye===0||Ne[ye-1].nextSibling===pe))){if(F!==L)for(let pe of Ne)Te(b,pe,L);l.beforeNodeMorphed(F,Q)!==!1?l.afterNodeMorphed(F,Q):h&&A.add(Q);for(let pe of Ne)u.add(pe),$.add(pe);g.set(Q,F),D.add(Q),L=Be(Ne[Ne.length-1].nextSibling);continue}F!==L&&Te(b,F,L),l.beforeNodeMorphed(F,Q)!==!1?(F.nodeValue!==Y&&(a.push({kind:"text",node:F,before:F.nodeValue,after:Y}),F.nodeValue=Y),l.afterNodeMorphed(F,Q)):A.add(Q),u.add(F),$.add(F),g.set(Q,F),L=Be(F.nextSibling);continue}if(Q.nodeType===3&&L&&L.nodeType===3&&!u.has(L)&&!B.has(L)){L.nodeValue!==Q.nodeValue&&(a.push({kind:"text",node:L,before:L.nodeValue,after:Q.nodeValue}),L.nodeValue=Q.nodeValue),u.add(L),g.set(Q,L),L=Be(L.nextSibling);continue}let ke=s.get(Q),ie=et(ke&&ke.unchanged&&ke.remote?ke.remote:Q);if(l.beforeNodeAdded(ie)===!1){A.add(Q);continue}b.insertBefore(ie,L),u.add(ie),h&&y.set(Q,ie),ie.nodeType===3&&g.set(Q,ie),ie.nodeType===1&&(d.push(ie),Pe(ie,Q),n.customIdentity&&ke&&ke.unchanged&&ke.remote&&le(ie,ke.remote),vn(ie)||ae(ie,Q),r.formState==="property"&&Qt(ke)&&X(ie,ke.remote)),L=Be(ie.nextSibling),a.push({kind:"insert",node:ie,parent:b}),l.afterNodeAdded(ie)}for(let Q of Array.from(b.childNodes))u.has(Q)||$.has(Q)||Q.nodeType===1&&(r.ignored(Q)||Ue(Q))||(S.has(Q)?f.push({node:Q,parent:b}):ot(Q,b))}function Ue(b){return b.parentNode&&b.parentNode.nodeType===1&&b.parentNode.tagName==="HEAD"&&(T&&!T.has(b)||r.preserve&&r.preserve(b)===!0)}function _e(b){let C=s.get(b);return!C||!Array.isArray(C.local)?null:C.local.map(L=>L.nodeValue).join("")}function O(b){return s.get(b)}function X(b,C){if(!Wa.has(b.tagName)&&!b.querySelector("input,option,textarea"))return;let L=($,Q)=>{if($.tagName!==Q.tagName||($.tagName==="TEXTAREA"?K($,Q,{remote:Q}):Wa.has($.tagName)&&Yt($,Q,{remote:Q}),r.opaque&&r.opaque($)))return;let F=re($),he=re(Q);if(F.length===he.length)for(let ke=0;ke<F.length;ke++)L(F[ke],he[ke])};L(b,C)}function le(b,C){if(r.opaque&&r.opaque(b))return;let L=re(b),$=re(C);if(L.length===$.length)for(let Q=0;Q<L.length;Q++){let F=n.remoteIdOf($[Q]);F&&p.push([L[Q],F]),le(L[Q],$[Q])}}function re(b){let C=b.tagName==="TEMPLATE"&&b.content?b.content:b;return Array.from(C.children).filter(L=>!r.ignored(L))}function Pe(b,C){if(!n.remoteIdOf)return;let L=($,Q)=>{let F=s.get(Q);if(F&&F.remote&&Q.nodeType===1){let ie=n.remoteIdOf(F.remote);ie&&p.push([$,ie])}let he=$.childNodes,ke=Q.childNodes;for(let ie=0;ie<he.length&&ie<ke.length;ie++)L(he[ie],ke[ie])};L(b,C)}function Be(b){for(;b&&b.nodeType===1&&r.ignored(b);)b=b.nextSibling;return b}function Te(b,C,L){if(typeof b.moveBefore=="function"&&C.ownerDocument===b.ownerDocument)try{b.moveBefore(C,L);return}catch{}b.insertBefore(C,L)}function ot(b,C){if(l.beforeNodeRemoved(b)===!1){h&&E.add(b);return}b.parentNode.removeChild(b),a.push({kind:"remove",node:b,parent:C}),l.afterNodeRemoved(b)}function et(b){if(vn(b))return So(b,o);let C=o.importNode(b,!0);if(C.nodeType===1)for(let L of Array.from(C.querySelectorAll("script")))vn(L)&&L.replaceWith(So(L,o));return C}function ae(b,C){let L=b.tagName==="TEMPLATE"&&b.content?b.content:b,$=C.tagName==="TEMPLATE"&&C.content?C.content:C,Q=Array.from(L.childNodes),F=Array.from($.childNodes);for(let he=0;he<F.length&&he<Q.length;he++){let ke=F[he],ie=Q[he],Ne=M.get(ke);Ne&&u.has(Ne)&&(Ne=null);let U=s.get(ke);if(U&&U.pinned){if(Ne&&Ne.nodeType===1){let Y=Ne.parentNode;Te(L,Ne,ie),Y!==L&&(c.push(Ne),a.push({kind:"move",el:Ne,from:Y,to:L})),u.add(Ne)}ie.remove();continue}if(Ne){let Y=Ne.parentNode;Te(L,Ne,ie),ie.remove(),Ne.nodeType===1?(Y!==L&&(c.push(Ne),a.push({kind:"move",el:Ne,from:Y,to:L})),Fe(Ne,ke)):(u.add(Ne),g.set(ke,Ne),Ne.nodeValue!==ke.nodeValue&&(a.push({kind:"text",node:Ne,before:Ne.nodeValue,after:ke.nodeValue}),Ne.nodeValue=ke.nodeValue));continue}u.add(ie),h&&y.set(ke,ie),ie.nodeType===3&&g.set(ke,ie),U&&U.unchanged&&U.remote?(de(ie,U.remote),n.customIdentity&&le(ie,U.remote)):ke.nodeType===1&&!vn(ke)&&ae(ie,ke)}}function de(b,C){let L=b.tagName==="TEMPLATE"&&b.content?b.content:b,$=C.tagName==="TEMPLATE"&&C.content?C.content:C;for(let Q of Array.from($.childNodes))L.appendChild(et(Q))}function Ee(b,C){return C.namespaceURI?b.getAttributeNS(C.namespaceURI,C.localName):b.getAttribute(C.name)}function Ge(b,C){let L=new Set((C||"").split($i).filter(Boolean));return(b||"").split($i).filter($=>$&&!L.has($))}function Ve(b,C,L){for(let $ of Array.from(C.attributes)){if(ze(b,$.name)||r.ignoreAttribute(b,$.name,C))continue;let Q=Ee(b,$);if(Q===$.value||L&&Ee(L,$)===$.value)continue;let F=$.value;if(L&&$.name==="class"&&!$.namespaceURI){let he=$.value.split($i).filter(Boolean),ke=Ge(Q,L.getAttribute("class")).filter(ie=>!he.includes(ie));ke.length&&(F=[...he,...ke].join(" "))}if(Q!==F){if(l.beforeAttributeUpdated($.name,b,"update")===!1){h&&v(C,$.name);continue}$.namespaceURI?b.setAttributeNS($.namespaceURI,$.name,F):b.setAttribute($.name,F),a.push({kind:"attr",el:b,name:$.name,before:Q,after:F})}}for(let $ of Array.from(b.attributes)){if(ze(b,$.name)||r.ignoreAttribute(b,$.name,C)||($.namespaceURI?C.hasAttributeNS($.namespaceURI,$.localName):C.hasAttribute($.name)))continue;if(L&&$.name==="class"&&!$.namespaceURI){let he=Ge($.value,L.getAttribute("class"));if(he.length){let ke=he.join(" ");if(ke===$.value)continue;if(l.beforeAttributeUpdated("class",b,"update")===!1){h&&v(C,"class");continue}b.setAttribute("class",ke),a.push({kind:"attr",el:b,name:"class",before:$.value,after:ke});continue}}if(L&&Ee(L,$)===null&&!r.ignoreAttribute(L,$.name))continue;if(l.beforeAttributeUpdated($.name,b,"remove")===!1){h&&v(C,$.name);continue}let F=$.value;$.namespaceURI?b.removeAttributeNS($.namespaceURI,$.localName):b.removeAttribute($.name),a.push({kind:"attr",el:b,name:$.name,before:F,after:null})}}function ze(b,C){let L=b.tagName;return L==="INPUT"?C==="value"||C==="checked"||C==="disabled":L==="OPTION"?C==="selected":!1}function lt(b){return b===o.activeElement}function pt(b){let C=o.activeElement;return!!C&&C!==o.body&&b.contains(C)}function Rt(b,C){let L=C&&C.local&&C.local.nodeType===1&&C.local!==b?C.local:null;if(!L)return!0;let $=b.tagName==="TEXTAREA"?L.textContent:L.getAttribute("value")??"";return b.value!==$}function dt(b,C){return!!r.protectFocusedValue&<(b)&&Rt(b,C)}function vt(b,C,L){let $=Math.min(b.length,C.length),Q=0;for(;Q<$&&b[Q]===C[Q];)Q++;if(L<=Q)return L;let F=0;for(;F<$-Q&&b[b.length-1-F]===C[C.length-1-F];)F++;return L>=b.length-F?L+C.length-b.length:C.length-F}function gt(b){try{return b.selectionStart==null?null:[b.selectionStart,b.selectionEnd,b.selectionDirection]}catch{return null}}function kn(b,C,L,$){try{b.setSelectionRange(vt(C,L,$[0]),vt(C,L,$[1]),$[2]||"none")}catch{}}function Ft(b,C){let L=b.value,$=gt(b);b.value=C,$&&kn(b,L,C,$)}function Qt(b){let C=b&&b.remote;return C&&C.nodeType===1?C:null}function Yt(b,C,L){let $=b.tagName,Q=Qt(L),F=r.formState==="property"&&Q?Q:C;if($==="INPUT"){let he=dt(b,L),ke=(b.getAttribute("type")||"").toLowerCase(),ie=ke!=="file"&&ke!=="checkbox"&&ke!=="radio",Ne=Q&&Q.hasAttribute("value")&&Q.value!==Q.getAttribute("value")?Q.value:null;if(ie&&!he)if(r.formState==="property"){let U=C.getAttribute("value"),Y=b.getAttribute("value");(Y!==U||b.value!==F.value)&&N("value",b,U==null?"remove":"update")!==!1&&(Y!==U&&(U==null?b.removeAttribute("value"):b.setAttribute("value",U),a.push({kind:"attr",el:b,name:"value",before:Y,after:U})),b.value!==F.value&&(lt(b)?Ft(b,F.value):b.value=F.value))}else if(C.hasAttribute("value")||Ne!=null){let U=Ne??C.getAttribute("value");b.getAttribute("value")!==U&&N("value",b,"update")!==!1?(b.setAttribute("value",U),b.value!==U&&(lt(b)?Ft(b,U):b.value=U),a.push({kind:"attr",el:b,name:"value",before:null,after:U})):b.value!==U&&b.getAttribute("value")===U&&(lt(b)?Ft(b,U):b.value=U)}else(b.hasAttribute("value")||b.value!=="")&&N("value",b,"remove")!==!1&&(b.removeAttribute("value"),b.value="",a.push({kind:"attr",el:b,name:"value",before:"",after:null}));if(!ie&&ke!=="file"){let U=C.getAttribute("value");U==null?b.hasAttribute("value")&&N("value",b,"remove")!==!1&&b.removeAttribute("value"):b.getAttribute("value")!==U&&N("value",b,"update")!==!1&&b.setAttribute("value",U)}r.protectFocusedValue&<(b)||(gn(b,F,"checked"),r.formState==="property"&&b.indeterminate!==F.indeterminate&&(b.indeterminate=F.indeterminate)),gn(b,F,"disabled")}else if($==="OPTION"){let he=b.parentNode&&b.closest("select");r.protectFocusedValue&&he&<(he)||gn(b,F,"selected")}}function gn(b,C,L){if(r.ignoreAttribute(b,L,C))return;let $=r.formState==="property"?!!C[L]:C.hasAttribute(L);if(r.formState!=="property"){let Q=b.hasAttribute(L);if(Q!==$){if(N(L,b,$?"update":"remove")===!1)return;$?b.setAttribute(L,""):b.removeAttribute(L),a.push({kind:"attr",el:b,name:L,before:Q?"":null,after:$?"":null})}}b[L]!==$&&(b[L]=$)}function K(b,C,L){if(dt(b,L)||N("value",b,"update")===!1)return;let $=Qt(L),Q=C.textContent,F=$&&$.value!==$.defaultValue?$.value:Q,he=lt(b)?gt(b):null,ke=b.value;r.formState!=="property"&&b.textContent!==Q&&(a.push({kind:"text",node:b,before:b.textContent,after:Q}),b.textContent=Q),b.value!==F&&(b.value=F),he&&b.value!==ke&&kn(b,ke,b.value,he)}}function Gd(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 Yd(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=(u,f)=>{let p=n.get(u);if(Array.isArray(p)){let m=p.find(y=>f>=y.from&&f<y.to)||p.find(y=>f===y.to)||p[p.length-1],k=s.get(m.merged);if(!k||!k.isConnected)return null;let g=r.get(m.merged),h=g&&g.flat?g.flat(m.flatStart+f):f;return[k,Math.max(0,Math.min(h,k.nodeValue.length))]}if(p&&!i.has(p.merged)){let m=(o.get(p.merged)||[u])[0];if(!m.isConnected)return null;let k=r.get(p.merged),g=p.shift+f,h=k?k(g):g;return[m,Math.max(0,Math.min(h,m.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),d=a(t.range.ec,t.range.eo);if(!(!c||!d))try{let u=e.createRange();u.setStart(c[0],c[1]),u.setEnd(d[0],d[1]);let f=e.getSelection();f.removeAllRanges(),f.addRange(u)}catch{}}var Xd={compared:0},Jd=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Zd(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 Hi(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 Ga(e,t,n,r,o,s,i,l){let a=new Map,c=new Set,d=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)d(u);d(t);for(let u of i||t.querySelectorAll("*"))d(u);for(let u of c)a.delete(u),l.add(u);return a}function Ya(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=[],c=s===Nn?Oo:"*";for(let d of[e,...e.querySelectorAll(c)]){if(n(d))continue;let u=t(d);if(!u||!(r.has(u)||o.has(u)))continue;let f=(l.get(u)||0)+1;l.set(u,f),f===2&&a.push(u)}return a}function Xa({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(!Zd(e,t,o.ignoreAttribute))return{bail:"root-attrs"};let{ignored:l,remoteWins:a}=o,c=Ui(o.scripts.merge===!1?null:o.scripts.mergeTags,i),d=_e=>{let O=c(_e);return O!==null?O:s.base(_e)||null},u=_e=>{let O=c(_e);return O!==null?O:s.remote(_e)||null},f=[],p=[],m=new Map,k=new Map,g={same:m,differ:k},h=_e=>({bail:_e,comparisons:g}),y=(_e,O,X=!0)=>{if(m.get(_e)===O)return!0;if(k.get(_e)===O)return!1;if(Xd.compared++,X&&_e.isEqualNode(O))return m.set(_e,O),!0;let le=_e.nodeType===O.nodeType;if(le&&_e.nodeType===1){if(le=Hi(_e,O),le){let re=_e.firstChild,Pe=O.firstChild;for(;re&&Pe;re=re.nextSibling,Pe=Pe.nextSibling)if(!y(re,Pe,!1)){le=!1;break}(re||Pe)&&(le=!1)}}else le&&(le=_e.isEqualNode(O));return(le?m:k).set(_e,O),le},A=e,w=t,v=!1,E=()=>{m.set(A,w);for(let _e=0;_e<f.length;_e++)m.set(f[_e],p[_e]);return h("equal")};for(;;){let _e=A.childNodes,O=w.childNodes;if(_e.length!==O.length)break;let X=et=>y(_e[et],O[et])?(m.set(_e[et],O[et]),!1):!0,le=-1,re=-1;for(let et=0;et<_e.length;et++){if(_e[et].nodeType!==1)continue;let ae=0;for(let de=_e[et].firstElementChild;de;de=de.nextElementSibling)ae++;ae>=re&&(re=ae,le=et)}let Pe=[],Be=!1;for(let et=0;et<_e.length&&Pe.length<2;et++)et!==le&&X(et)&&Pe.push(et);if(le>=0&&Pe.length<2&&(Pe.length===0&&Hi(A,w)?(Pe.push(le),Be=!0):X(le)&&Pe.push(le)),Pe.length!==1){if(!v&&Pe.length===0&&Hi(A,w))return E();break}let Te=_e[Pe[0]],ot=O[Pe[0]];if(v=v||!Be,v&&k.set(Te,ot),Te.nodeType!==1||ot.nodeType!==1||Te.tagName!==ot.tagName)break;if(d(Te)!==u(ot)){if(!v&&y(Te,ot))return E();break}f.push(A),p.push(w),A=Te,w=ot}k.set(A,w);for(let _e=0;_e<f.length;_e++)k.set(f[_e],p[_e]);if(A===e||A.tagName==="HEAD"||A.tagName==="BODY")return h("root-level");if(f.length<2||f[1].tagName!=="BODY")return h("not-in-body");if(l(A)||l(w))return h("ignored-ancestor");if(a(A)||a(w))return h("remote-wins-ancestor");for(let _e of f)if(Jd.has(_e.tagName))return h("form-ancestor");if(A.tagName==="SCRIPT"||A.getElementsByTagName("script").length||w.getElementsByTagName("script").length)return h("script-or-template");let N=r(A);if(!N||N.nodeType!==1||N.tagName!==A.tagName)return h("no-live-twin");if(!n.contains(N))return h("live-detached");for(let _e of f){let O=r(_e);if(!O||O.nodeType!==1)return h("ancestor-live")}let _=s.base===Nn&&s.remote===Nn&&l===ui,M=new Set,j=new Set,R=[],D=null,B=_e=>{_e&&(M.has(_e)?j.add(_e):M.add(_e))},S=(_e,O)=>{let X=c(_e),le=X!==null?X:s.base(_e)||null;return le!==(X!==null?X:s.remote(O)||null)?!1:(B(le),!0)},T=(_e,O)=>{for(let X=_e.firstElementChild,le=O.firstElementChild;X;X=X.nextElementSibling,le=le.nextElementSibling){let re=l(X);if(re!==l(le))return!1;if(!re&&(!S(X,le)||!T(X,le)))return!1}return!0},J=_e=>{let O=_e+1<f.length?f[_e+1]:A;for(let X=f[_e].firstElementChild,le=p[_e].firstElementChild;X;X=X.nextElementSibling,le=le.nextElementSibling){if(X===O){let Be=_e+1<f.length?J(_e+1):null;if(Be)return Be;continue}let re=l(X);if(re!==l(le))return"outside-id-changed";if(re)continue;let Pe=r(X);if(!Pe||Pe.nodeType!==1)return"sibling-live";if(R.push([X,le]),!_&&(!S(X,le)||!T(X,le)))return"outside-id-changed";_e===0&&X.tagName==="HEAD"&&d(X)&&(D=[X,le])}return null},q=J(0);if(q)return h(q);let V=new Set(f),Ce=null;if(s.base===Nn){Ce=[];for(let _e of e.querySelectorAll(Oo))_e===A||V.has(_e)||(A.contains(_e)?Ce.push(_e):_&&B(d(_e)))}let Me=new Set,Fe=new Set,ce=new Set,Ae=Ga(f,A,d,l,M,Me,Ce,Fe),Ue=Ga(p,w,u,l,M,Me,s.remote===Nn&&w.querySelectorAll(Oo),ce);return D&&(j.has(d(D[0]))||Me.has(d(D[0])))&&(D=null),{scope:{chain:f,root:A,onChain:V,baseIndex:Ae,remoteIndex:Ue,baseDropped:Fe,remoteDropped:ce,head:D,same:m,differ:k,dropped:[...Ya(e,d,l,j,Fe,s.base),...Ya(t,u,l,j,ce,s.remote)],held:_e=>{for(let O=1;O<f.length;O++)if(_e.map.get(f[O])!==p[O])return!1;for(let[O,X]of R)if(_e.map.get(O)!==X)return!1;return!0}}}}var Ty=Symbol("hyper-morph-duplicate-key");var Qd='[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"]',eh='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',th='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function nh(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 rh(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=oh(e,t,r)),!!o)return n?Array.from(o.childNodes):o}function oh(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=$r(a,n);c&&!o.has(c.key)&&o.set(c.key,a.textContent)}if(!o.size)return null;let i=e.cloneNode(!0),l=!1;for(let a of[i,...i.querySelectorAll("script")]){let c=$r(a,n);c&&o.has(c.key)&&(a.textContent=o.get(c.key),l=!0)}return l?i:null}function Ja(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 ur(e,t,n={}){let r=n||{};if(!r.head?.block)return Za(e,t,r);try{return Za(e,t,r)}catch(o){return Promise.reject(o)}}function Za(e,t,n){let r=n.policy||"sync",o=r==="raw"?void 0:(a,c)=>nh(a)||(r==="history"?!(c&&a.matches(th))&&a.matches(eh):a.matches(Qd)),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 No(Object.assign({},i,{live:e,base:n.scripts?.mergeBase||null,remote:Ja(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:Ja(t,e.ownerDocument)});return No(a)}n.morphStyle==="innerHTML"&&(i.children=!0);let l=rh(e,n.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return l!==void 0&&(i.base=l),zi(e,t,i)}var sh=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),Dn=()=>{};function _o(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!sh.has(l))throw new TypeError(`unknown option "${l}"`);let n=Object.assign({beforeNodeAdded:Dn,afterNodeAdded:Dn,beforeNodeRemoved:Dn,afterNodeRemoved:Dn,beforeNodeMorphed:Dn,afterNodeMorphed:Dn,beforeAttributeUpdated:Dn},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");let i=e.lineage;if(i!==void 0&&(!i||typeof i!="object"||typeof i.onResult!="function"||!i.elements||typeof i.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:di(e.ignore,t),remoteWins:di(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,opaque:typeof e.opaque=="function"?e.opaque:()=>!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,lineage:i||null}}function Wr(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 Nn}function Kr(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=hi(t,e.map),r=typeof e.then=="function"?e.then:Nn;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 Nn}function ih(e,t,n,r={}){let o=p=>p&&p.nodeType===9?p.documentElement:p,s=o(t),i=o(n),l=o(e)||s;if(r.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let a=Object.assign({},r);delete a.live,delete a.base,delete a.remote;let c=_o(a,[l,s,i].filter(Boolean)),d=r.identity||{},u=ar(),f=hs(l,s,i,{identity:{base:Kr(d.base,l),local:Kr(d.local,s),remote:Kr(d.remote,i)},authored:{base:Wr(d.base),local:Wr(d.local),remote:Wr(d.remote)},skipUnchanged:c.hooks.beforeNodeMorphed===Dn&&c.hooks.afterNodeMorphed===Dn,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,delete f.lineage,f}function Vi({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:r,toLive:o,options:s,identity:i,childrenOnly:l,isDocument:a}){let c=_o(s,[e,t,n,r].filter(Boolean));if(c.ignored(e)){let S=Wi(),T=c.lineage?Ao(c.lineage,e,S):null;return{report:S,loads:[],lineage:T}}let d=e.ownerDocument,u=c.lineage?Mi(c.lineage,{liveRoot:e,localRoot:n,toLive:o}):null,f=c.scripts.execute?Sa(e,c.ignored,d.baseURI):null,p=ar(),m=c.hooks.beforeNodeMorphed===Dn&&c.hooks.afterNodeMorphed===Dn,k={identity:{base:Kr(i.base,t||n),local:Kr(i.local,n),remote:Kr(i.remote,r)},authored:{base:Wr(i.base),local:Wr(i.local),remote:Wr(i.remote)},ignored:c.ignored,remoteWins:c.remoteWins,ignoreAttribute:c.ignoreAttribute,conflicts:c.conflicts,mergeTags:c.scripts.merge===!1?null:c.scripts.mergeTags,baseURI:d.baseURI,localIsBase:!t,childrenOnly:l,skipUnchanged:m,lineage:u?{locals:u.locals}:null},g=c.fastPath&&a&&!l&&m&&t===n,h=null,y=null;if(g){let S=Xa({baseRoot:t,remoteRoot:r,liveRoot:e,toLive:o,o:c,identity:k.identity,baseURI:d.baseURI});k.comparisons=S.comparisons||S.scope,S.bail?y=S.bail:(h=hs(t,n,r,Object.assign({},k,{stats:p,scope:S.scope})),h||(y="chain-unpaired",p=ar()))}h||(h=hs(t||n,n,r,Object.assign({},k,{stats:p}))),g&&(p.fastPathAttempted=1,p.fastPathTaken=y?0:1,p.fastPathFallback=y),h.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(S=>c.hooks[S]!==Dn)&&Ra(h.conflicts,h.recoveryLinks,o),c.beforeApply&&c.beforeApply(h.doc);let A=globalThis.__hyperMorphProfile,w=A?performance.now():0,v=Ka(e,h.root,h,{toLive:o,localRoot:n,ignored:c.ignored,ignoreAttribute:c.ignoreAttribute,opaque:c.opaque,formState:c.formState,protectFocusedValue:c.protectFocusedValue,restoreFocus:c.restoreFocus,preserve:c.head.preserve,hooks:c.hooks,childrenOnly:l,keepLiveOnly:c.keepLiveOnly,trackInserted:!!u});A&&(A.apply=(A.apply||0)+(performance.now()-w));let E=[];if(c.head.awaitLoads)for(let S of v.applied){if(S.kind!=="insert"||S.node.nodeType!==1)continue;let T=S.node;T.tagName==="LINK"&&/\bstylesheet\b/i.test(T.getAttribute("rel")||"")&&T.getAttribute("href")&&T.closest("head")&&E.push(new Promise(q=>{T.addEventListener("load",()=>q()),T.addEventListener("error",()=>q())}))}let N=null,_=null;if(f){let S=Ta(e,f,{ignored:c.ignored,skip:v.mergedScriptsLive,baseURI:d.baseURI,beforeNodeAdded:c.hooks.beforeNodeAdded,afterNodeAdded:c.hooks.afterNodeAdded,trackRecovery:!!h.recoveryLinks});E.push(...S.loads),N=S.swapped,_=S.vetoed}let M=S=>N&&N.get(S)||S,j=S=>{if(v.keptRuns.has(S))return v.runOf.get(S);let T=v.liveOf.get(S)||v.heldBy.get(S)||v.insertedLive.get(S);return T?M(T):null},R=S=>{let T=S&&v.liveOf.get(S);return T?M(T):null},D=S=>{let T=S&&j(S);return Array.isArray(T)?T[0]:T};if(h.recoveryLinks){let S=(T,J,q)=>(J.namespaceURI?T.getAttributeNS(J.namespaceURI,J.localName):T.getAttribute(J.qualifiedName))===q;Pa(h.conflicts,h.recoveryLinks,{lookup:j,vetoed:v.vetoed,vetoedAttrs:v.vetoedAttrs,removedVetoes:v.removedVetoes,vetoedLive:_,liveAttr:S,ignored:c.ignored,liveRoot:e})}let B={applied:v.applied,decisions:h.decisions.map(S=>Object.assign({},S,{node:S.node?R(S.node):null,el:S.el?R(S.el):null,applied:!!(S.node?R(S.node):S.el&&R(S.el))})),conflicts:h.conflicts.map(S=>Object.assign({},S,{node:S.node?S.kind==="text"&&S.recovery.subject.nodeType===8?D(S.node):R(S.node):S.node,el:S.el?S.kind==="structure"?D(S.el):R(S.el):S.el})),localDiverged:h.localDiverged,identities:v.identities,moved:v.moved,replaced:v.replaced,stats:p};return u&&(B.lineage=u.finish(h.lineage,j)),{report:B,loads:E,lineage:u}}var Qa=new WeakMap;function Wi(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:ar()}}function No(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");return t.lineage===void 0?ec(t):Ci(t,t.live.documentElement,r=>ec(r))}function ec(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let r=Qa.get(n);r||(r=fi(n),Qa.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:f=>f;Wl(n,o);let{report:c,loads:d,lineage:u}=Vi({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 u?.deliver(c),Promise.all(d).then(()=>c)}function lh(e,t,n={}){return No(Object.assign({},n,{live:e,base:null,remote:t}))}function tc(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=es(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 zi(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return n.lineage===void 0?nc(e,t,n):Ci(n,e,r=>nc(e,t,r))}function nc(e,t,n={}){let r=e.ownerDocument,{base:o,...s}=n,i=!!s.children,l=_o(s,[e]);if(l.ignored(e)){let k=Wi();return l.lineage&&Ao(l.lineage,e,k).deliver(k),Promise.resolve(k)}let a=tc(t,r),c=o!=null?tc(o,r):null,d,u=null;if(i)d=a.root,u=c?c.root:null;else{if(d=a.first,u=c?c.first:null,!d){let k=_o(s),g=k.lineage?Ao(k.lineage,e,{}):null;k.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),k.hooks.afterNodeRemoved(e));let h={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:ar()};return g&&(h.lineage=g.result,g.deliver(h)),Promise.resolve(h)}if(d.tagName!==e.tagName){let k=_o(s,[e,d]);if(k.hooks.beforeNodeMorphed(e,d)===!1){let y=Wi();return k.lineage&&Ao(k.lineage,e,y).deliver(y),Promise.resolve(y)}let g=Vi({liveRoot:e,baseRoot:u&&u.tagName===e.tagName?u:null,localRoot:e,remoteRoot:d,toLive:y=>y,options:s,identity:s.identity||{},childrenOnly:!0,isDocument:!1}),h=vn(d)?So(d,r):r.importNode(d,!1);if(!vn(h))for(;e.firstChild;)h.appendChild(e.firstChild);return k.hooks.beforeNodeAdded(h)===!1?(ds(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):k.hooks.beforeNodeRemoved(e)===!1?(ds(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(h),ds(g.report.conflicts,e,h),k.hooks.afterNodeRemoved(e),k.hooks.afterNodeAdded(h),k.hooks.afterNodeMorphed(e,d),g.report.replaced.push(h),g.report.applied.push({kind:"insert",node:h,parent:h.parentNode},{kind:"remove",node:e,parent:h.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,h),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:f,loads:p,lineage:m}=Vi({liveRoot:e,baseRoot:u,localRoot:e,remoteRoot:d,toLive:k=>k,options:s,identity:s.identity||{},childrenOnly:i,isDocument:!1});return m?.deliver(f),Promise.all(p).then(()=>f)}var Ki={mergeDocument:No,morphDocument:lh,morphElement:zi,merge3:ih,morph:ur};var gs={};ii(gs,{EmptyListInsert:()=>dr,MAX_RULE_DEPTH:()=>Xr,MaxRuleDepthExceeded:()=>Or,NoRulesTag:()=>Gi,RuleTargetReadOnly:()=>Mo,RulesParseError:()=>Gr,ShapeMismatch:()=>Co,UnknownRulesVersion:()=>Yr,WriteNotRoundTripped:()=>ps,WriteRefused:()=>ms,WriteRejected:()=>Yi});var Gr=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},Yr=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},Xr=20,Or=class extends Error{constructor(t){super(`rule depth exceeded ${Xr} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},Co=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},dr=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`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}},Mo=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},ms=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function dh(e){return e.reduce((n,r)=>typeof r=="number"?`${n}[${r}]`:n?`${n}.${r}`:String(r),"")||"(root)"}var ps=class extends Error{constructor(t){super(`write did not round-trip at "${dh(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},Gi=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Yi=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 hr(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 Xi(e,t,n,{depth:0,path:[]},r)}function Xi(e,t,n,r,o){if(r.depth>Xr)throw new Or(r.path);if(typeof n=="string")return hh(e,t,n,r,o);if(Array.isArray(n)){let[s,i]=n,l=e.find(t,s,o);return oc(o,r,l),l.map((a,c)=>Xi(e,a,i,{depth:r.depth+1,path:[...r.path,c]},o))}if(typeof n=="object"&&n!==null){let s={};for(let[i,l]of Object.entries(n))s[i]=Xi(e,t,l,{depth:r.depth+1,path:[...r.path,i]},o);return s}return null}function hh(e,t,n,r,o){if(n.endsWith("[]")){let l=n.slice(0,-2),a=e.find(t,l,o);return oc(o,r,a),a.map(c=>e.text(c))}if(n.startsWith("@"))return rc(e,t,n.slice(1));let s=nn(n);if(s!==-1){let l=n.slice(0,s),a=n.slice(s+1),c=l?e.find(t,l,o):[t];return c.length===0?null:rc(e,c[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 oc(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 rc(e,t,n){if(ko.has(n)){let o=e.prop(t,n);return o==null?null:String(o)}let r=e.attr(t,n);return r??null}var bs=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"]})}),mh=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),sc=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function Ro(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 Ji(e,t){if(Ro(e,t))return!0;for(let[n,r]of Object.entries(mh))if(r.includes(t)&&Ro(e,n))return!0;return!1}function Io(e){let t=bs[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function ph(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=bs[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>Ji(n,o))||r.bundles.some(o=>Ro(n,o)))return n;n=n.parentElement}return null}function ic(e,t){return!!ph(e,t)}var gh=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function bh(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"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),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function lc(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 ac(e,t,n,r,o,s){return(s?ic(e,t):lc(e,n,o,!1))||!!(r&&(s&&e!==o?e.matches(r):lc(e,r,o,s)))}function yh(e,t){let n=bs[t];return n.tokens.some(r=>Ji(e,r))||n.bundles.some(r=>Ro(e,r))}var kh=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function cc(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let o=e,s=t;if(e.nodeType===1){if(kh.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);o=e.content,s=t.content,n.cloneToLive.set(s,o),n.liveToClone.set(o,s)}}else if(e.nodeType!==11)return;let i=s.firstChild;for(let l=o.firstChild;l&&i;l=l.nextSibling)cc(l,i,n,r),i=i.nextSibling}function Lo(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:o=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=s.implementation.createHTMLDocument(""),l=o||new WeakMap,a=new WeakMap,c=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let d=Io(t),u=r?m=>yh(m,t)||!!(n&&m.matches(n)):m=>ac(m,t,d,n,c,!1),f=null;if(c.nodeType!==1||!ac(c,t,d,n,c,r)){f=i.importNode(c,!0);let m={cloneToLive:l,liveToClone:a,dropped:[],controls:[]};cc(c,f,m,u);for(let k of m.dropped)k.remove();for(let k=0;k<m.controls.length;k+=2)bh(m.controls[k],m.controls[k+1])}e.nodeType===9&&f&&(i.replaceChild(f,i.documentElement),a.set(e,i),l.set(i,e));let p=m=>{if(gh.test(m))throw new Error(`Filtered content queries do not support stateful selector: ${m}`)};return{root:f,document:i,capability:t,selector:Io(t),cloneToLive:l,liveToClone:a,original(m){return l.get(m)||null},cloneOf(m){return a.get(m)||null},query(m,k=f){return p(m),Array.from(k.querySelectorAll(m),g=>l.get(g)||g)},text(m=f){return(m===f?f:a.get(m))?.textContent||""},html(m=f){return(m===f?f:a.get(m))?.innerHTML??""},clone(m=f){let k=m===f?f:a.get(m);return k?i.importNode(k,!0):null}}}function uc(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function xh(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function fc(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function dc(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function hc(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let r=n.type;r!=="file"&&r!=="checkbox"&&r!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var un={semanticExclude:!0,find(e,t,n={}){let r=xh(e);if(!r||!r.querySelectorAll)return[];let o=Array.from(r.querySelectorAll(t));n.includeRulesTag||(o=o.filter(l=>!uc(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):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,dc(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),fc(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),fc(e,t,null)},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){let t=e.cloneNode(!0);return hc(t),t},insertAt(e,t,n){let r=e.children[n]||null;e.insertBefore(t,r)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},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 er(e,t={}){if(t.exclude===null)return un;let n=[Io("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 un;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,i=e.nodeType===9?e:e.ownerDocument,l=null,a=()=>l||(l=Lo(s,{capability:"data",exclude:t.exclude||null})),c=m=>{let k=a();return m===e?k.cloneOf(e):k.cloneOf(m)||m},d=m=>l?.original(m)||m,u=(m,k)=>{a().liveToClone.set(m,k),a().cloneToLive.set(k,m);let g=m.childNodes||[],h=k.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)u(g[y],h[y])},f=(m,k,g,h)=>{let y=Array.from(m.childNodes).filter(N=>l.cloneOf(N)),w=y[0];for(;w&&y.includes(w);)w=w.nextSibling;for(let N of y)N.remove();if(g==="innerHTML"){let N=i.createElement("template");N.innerHTML=h;for(let _ of Array.from(N.content.childNodes))m.insertBefore(_,w||null)}else m.insertBefore(i.createTextNode(h),w||null),dc(m,h);let v=Lo(m,{capability:"data",exclude:t.exclude||null});k.replaceChildren(...Array.from(v.root?.childNodes||[]));let E=N=>{let _=v.original(N);_&&(l.liveToClone.set(_,N),l.cloneToLive.set(N,_));for(let M of Array.from(N.childNodes||[]))E(M)};for(let N of Array.from(k.childNodes))E(N)},p={...un,find(m,k,g={}){let h=c(m);if(!h?.querySelectorAll)return[];let y=a().query(k,h);g.includeRulesTag||(y=y.filter(v=>!uc(v)));let A=[];g.skip&&A.push(g.skip);let w=g.templateAttr===null?null:g.templateAttr||"cms-template";if(w&&A.push(`[${w}]`),A.length){let v=A.join(", ");y=y.filter(E=>!E.closest?.(v))}return y},parent(m){let k=c(m)?.parentElement;return k?d(k):null},children(m){return Array.from(c(m)?.children||[],d)},text(m,k){if(k===void 0){let y=d(m);return!y?.matches?.(n)&&!y?.querySelector?.(n)?un.text(y):(c(m)?.textContent||"").trim()}let g=d(m);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){un.text(g,k);return}let h=a().cloneOf(g);h?f(g,h,"textContent",k):un.text(g,k)},attr(m,k,g){let h=d(m);if(g===void 0)return un.attr(h,k);un.attr(h,k,g);let y=l?.cloneOf(h);y&&(un.attr(y,k,g),Lo(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(h),l.cloneToLive.delete(y)))},removeAttr(m,k){let g=d(m);un.removeAttr(g,k);let h=l?.cloneOf(g);h&&un.removeAttr(h,k)},prop(m,k,g){let h=d(m);if(g===void 0)return k==="innerHTML"||k==="outerHTML"||k==="textContent"||k==="innerText"?un.prop(c(h),k):un.prop(h,k);let y=k==="innerHTML"||k==="textContent"||k==="innerText",A=y?a().cloneOf(h):l?.cloneOf(h);A&&y?f(h,A,k,g):(un.prop(h,k,g),A&&un.prop(A,k,g))},clone(m){let k=c(m);if(k===m)return un.clone(m);let g=i.importNode(k,!0);return hc(g),g},insertAt(m,k,g){let h=d(m),A=p.children(h)[g]||(()=>{for(let E=h.children.length-1;E>=0;E--){let N=h.children[E];if(a().cloneOf(N))return N.nextElementSibling}return h.firstElementChild})(),w=d(k);h.insertBefore(w,A||null);let v=a().cloneOf(h);if(v){let E=a().cloneOf(w);E||(E=i.importNode(w,!0),u(w,E));let N=Array.from(v.children);v.insertBefore(E,N[g]||null)}},insertBefore(m,k){let g=d(m),h=d(k);g.parentNode.insertBefore(h,g);let y=a().cloneOf(g.parentNode);if(y){let A=a().cloneOf(h);A||(A=i.importNode(h,!0),u(h,A));let w=a().cloneOf(g);w?w.before(A):y.appendChild(A)}},insertAfter(m,k){let g=d(m),h=d(k);g.parentNode.insertBefore(h,g.nextSibling);let y=a().cloneOf(g.parentNode);if(y){let A=a().cloneOf(h);A||(A=i.importNode(h,!0),u(h,A));let w=a().cloneOf(g);w?w.after(A):y.appendChild(A)}},identity(m){return d(m)||null},remove(m){let k=d(m),g=a().cloneOf(k);un.remove(k),g&&un.remove(g)},replaceWith(m,k){let g=d(m),h=a().cloneOf(g),y=un.replaceWith(g,k);if(h){let A=Lo(y,{capability:"data",exclude:t.exclude||null});if(!A.root)h.remove();else{h.replaceWith(A.root);let w=v=>{let E=A.original(v);E&&(l.liveToClone.set(E,v),l.cloneToLive.set(v,E));for(let N of Array.from(v.childNodes||[]))w(N)};w(A.root)}}return y}};return p}var Jr=un;function Zi(e){try{return JSON.parse(e)}catch(t){throw new Gr(`Invalid strict JSON: ${t.message}`,t)}}function Zr(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 u=!1,f=i+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: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 u=l,f=i+1;for(;f<o.length&&o[f]!==u;)o[f]==="\\"&&f++,f++;s.push({type:t.STRING,value:o.substring(i+1,f),quoted:!0,sourceQuote:u}),i=f+1;continue}let a=i,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 p of u){let m=p.substring(1);if(o.substring(a+1,a+1+m.length)===m){f=!0,a+=m.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(i,a);let d=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?d=t.NUMBER:c==="true"||c==="false"||c==="null"?d=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(d=t.SELECTOR),s.push({type:d,value:c,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,(c,d)=>d.length%2===0?d+'\\"':c)),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 Gr("Invalid extraction rules syntax: "+o.message,o)}}var pc="1",mc=/^[a-zA-Z0-9_-]+$/;function Po(e,t,n){let r;if(n===void 0)r="script[data-rules-name]";else{if(typeof n!="string"||!mc.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${mc})`);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!==pc)throw new Yr(i);return{rules:Zr(e.text(s)),tagNode:s}}var Lk=new Function("url","return import(url)");function vc(e,t,n,r){let o=e.length,s=t.length,i=new Array(o).fill(-1);if(r){let h=new Set;for(let y=0;y<o;y++){let A=r[y];!(A>=0&&A<s)||h.has(A)||(i[y]=A,h.add(A))}}if(o===0||s===0)return i;let l=e.map(h=>kc(h,n)),a=t.map(h=>kc(h,n)),c=new Array(s).fill(!1);for(let h of i)h>=0&&(c[h]=!0);let d=new Map;a.forEach((h,y)=>{c[y]||d.set(h,d.has(h)?-1:y)});let u=new Map;l.forEach((h,y)=>{i[y]>=0||u.set(h,(u.get(h)||0)+1)}),l.forEach((h,y)=>{if(i[y]>=0||u.get(h)!==1)return;let A=d.get(h);A===void 0||A===-1||c[A]||(i[y]=A,c[A]=!0)});let f=[];for(let h=0;h<o;h++)i[h]<0&&f.push(h);let p=[];for(let h=0;h<s;h++)c[h]||p.push(h);if(f.length===0||p.length===0)return i;let m=o*s+1,k=wh(e,t,n),g=(h,y)=>k(h,y)*m+Math.abs(h-y);for(let[h,y]of Ah(f,p,g))i[h]=y;return i}var wc=e=>typeof e=="object"&&e!==null;function kc(e,t){if(!wc(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 wh(e,t,n){if(!wc(n))return(l,a)=>e[l]===t[a]?0:1;let r=Object.keys(n),o=l=>r.map(a=>JSON.stringify(l?.[a])),s=e.map(o),i=t.map(o);return(l,a)=>{let c=s[l],d=i[a],u=0;for(let f=0;f<r.length;f++)c[f]!==d[f]&&u++;return u}}function Ah(e,t,n){return e.length<=t.length?xc(e,t,n,!1):xc(t,e,(r,o)=>n(o,r),!0)}function xc(e,t,n,r){let o=e.length,s=t.length,i=[];for(let u=0;u<=o;u++)i.push(new Float64Array(s+1).fill(1/0));let l=[];for(let u=0;u<=o;u++)l.push(new Uint8Array(s+1));for(let u=0;u<=s;u++)i[o][u]=0;for(let u=o-1;u>=0;u--)for(let f=s-1;f>=0;f--){let p=n(e[u],t[f])+i[u+1][f+1],m=i[u][f+1];p<=m?(i[u][f]=p,l[u][f]=1):i[u][f]=m}let a=[],c=0,d=0;for(;c<o&&d<s;)l[c][d]&&(a.push(r?[t[d],e[c]]:[e[c],t[d]]),c++),d++;return a}function el(e,t,n,r,o,s,i,l={}){let a=e.find(t,n,l);if(o.length===0){a.forEach(w=>e.remove(w)),Qi(l,"onRowsApplied",s.path,[]);return}let c=o.length>a.length,d=a[0]||null;if(c&&!d&&(d=Oh(e,t,n,l),!d))throw new dr(s.path);let u=a.map(w=>Eh(e,w,r,l)),f=null;if(c&&d){f=e.clone(d),l.templateAttr&&e.removeAttr(f,l.templateAttr);let w=e.stripIds(f);w>0&&console.warn(`[hyper-html-api] stripped ${w} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let p=vc(o,u,r,Sh(e,a,o,s,l)),m=a.length>0?e.parent(a[0]):Mh(e,t,n,d,s,l),k=a.length>0?Oc(e,m,a[0]):0,g=Lh(e,a),h=new Set,y=[],A=o.map((w,v)=>{let E=p[v];if(E>=0)return h.add(E),y.push(!1),a[E];y.push(!0);let N=e.clone(f);return e.stripIds(N),N});a.forEach((w,v)=>{h.has(v)||e.remove(w)}),g?Ih(e,m,k,A,y):Ph(e,A,y,m,k),Th(e,A,r,o,s,i,l),Qi(l,"onRowsApplied",s.path,A)}function Qi(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 Sh(e,t,n,r,o){let s=Qi(o,"identifyRows",r.path,n);if(!Array.isArray(s))return null;let i=new Array(n.length).fill(-1),l=new Set,a=new Map(t.map((c,d)=>[e.identity(c),d]));for(let c=0;c<n.length;c++){if(!s[c])continue;let d=a.get(e.identity(s[c]));d===void 0||l.has(d)||(i[c]=d,l.add(d))}return i}function Th(e,t,n,r,o,s,i){t.forEach((l,a)=>{if(n===null){let c=r[a],d=c==null?"":String(c);e.text(l)!==d&&e.text(l,d)}else{let c=s(e,l,n,r[a],{depth:o.depth+1,path:[...o.path,a]},i);c&&c!==l&&(t[a]=c)}})}function Eh(e,t,n,r){return n===null?e.text(t):hr(e,t,n,r.onRowsRead?{...r,onRowsRead:void 0}:r)}function Oc(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 Oh(e,t,n,r){if(!r.templateAttr)return null;let o=/^\s*:scope\s*>\s*/.test(n),s=new RegExp(":not\\(\\["+r.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),i=n.replace(/^\s*:scope\s*>\s*/,"").replace(s,""),l=o?Nh(i):0,a=ci(i),c=t;for(;c;){let d=e.find(c,i,{includeRulesTag:!1,templateAttr:null});for(let u of d)if(e.attr(u,r.templateAttr)!=null&&!(o&&!Ch(e,t,u,l))&&!(a&&!e.matches(e.parent(u),a)))return u;c=e.parent(c)}return null}function Nh(e){let t=0,n=null,r=1;for(let o=0;o<e.length;o++){let s=e[o];if(s==="\\")o++;else if(n)s===n&&(n=null);else if(s==='"'||s==="'")n=s;else if(s==="["||s==="(")t++;else if(s==="]"||s===")")t>0&&t--;else if(t===0&&s===">")r++;else{if(t===0&&(s==="+"||s==="~"))return null;if(t===0&&/\s/.test(s)){if(!_h(e,o))return null;for(;o+1<e.length&&/\s/.test(e[o+1]);)o++}}}return r}function _h(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let r=t>0?e[t-1]:"",o=n<e.length?e[n]:"";return Ac(r)||Ac(o)}function Ac(e){return e===">"||e==="+"||e==="~"}function Ch(e,t,n,r){if(r===null)return!0;let o=n;for(let a=0;a<r;a++)if(o=e.parent(o),!o)return!1;let s=e.prop(t,"tagName");if(!s)return!0;let i=e.prop(o,"tagName");if(!i||String(i).toLowerCase()!==String(s).toLowerCase())return!1;let l=new Set(Sc(e,o));return Sc(e,t).every(a=>l.has(a))}function Sc(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Mh(e,t,n,r,o,s){let i=e.parent(r);if(i&&Rh(e,t,i)&&!Ec(e,i,s))return i;let l=ci(n);if(!l)throw new dr(o.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let c=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,s)).filter(d=>!Ec(e,d,s));if(c.length===0)throw new dr(o.path,`no container matching "${l}" inside this context to hold the new rows`);if(c.length>1)throw new dr(o.path,`"${l}" matches ${c.length} containers inside this context, so the new rows have no single destination`);return c[0]}function Rh(e,t,n){let r=n;for(;r;){if(e.sameNode(r,t))return!0;r=e.parent(r)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(o=>e.sameNode(o,n))}var Tc=["no-data","editor-ui"];function Ec(e,t,n){let r=t;for(;r;){if(n.templateAttr&&e.attr(r,n.templateAttr)!=null||Tc.some(s=>e.attr(r,s)!=null))return!0;let o=e.attr(r,"clay");if(o&&o.split(/\s+/).some(s=>Tc.includes(s)))return!0;r=e.parent(r)}return!1}function Ih(e,t,n,r,o){let s=e.children(t),i=s.map(a=>e.identity(a)),l=!1;r.forEach((a,c)=>{let d=e.identity(a),u=n+c;if(i[u]===d)return;if(!o[c]){let p=i.indexOf(d);p!==-1&&(i.splice(p,1),s.splice(p,1))}let f=Math.min(u,s.length);f<s.length?e.insertBefore(s[f],a):s.length?l?e.insertAfter(s[s.length-1],a):(e.insertAt(t,a,u),l=!0):e.insertAt(t,a,0),i.splice(f,0,d),s.splice(f,0,a)})}function Lh(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let r=new Map(e.children(n).map((s,i)=>[e.identity(s),i])),o=[];for(let s of t){let i=r.get(e.identity(s));if(i===void 0)return!1;o.push(i)}return o.sort((s,i)=>s-i),o[o.length-1]-o[0]===o.length-1}function Ph(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 c=s?Oc(e,a,s)+1:i++;e.insertAt(a,t[l],c),s=t[l]}}function Qr(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(tl(n,r,[],s),s.length)throw new Co(s);ys(e,t,n,r,{depth:0,path:[]},o)}function ys(e,t,n,r,o,s={}){if(o.depth>Xr)throw new Or(o.path);if(r===void 0)return t;if(typeof n=="string")return jh(e,t,n,r,o,s);if(Array.isArray(n)){let[i,l]=n;return el(e,t,i,l,r,o,ys,s),t}if(typeof n=="object"&&n!==null){for(let[i,l]of Object.entries(n)){let a=ys(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 jh(e,t,n,r,o,s){if(n.endsWith("[]")){let a=n.slice(0,-2);return el(e,t,a,null,r,o,ys,s),t}if(n.startsWith("@"))return _c(e,t,n.slice(1),r);let i=nn(n);if(i!==-1){let a=n.slice(0,i),c=n.slice(i+1),d=a?e.find(t,a,s):[t];return d.length===0||_c(e,d[0],c,r),t}if(n===".")return Nc(e,t,r),t;let l=e.find(t,n,s);return l.length===0||Nc(e,l[0],r),t}function Nc(e,t,n){let r=n==null?"":String(n);e.text(t)!==r&&e.text(t,r)}function _c(e,t,n,r){if(Pr.has(n)){let o=e.prop(t,n);if(o===r||o!=null&&r!=null&&String(o)===String(r))return t;throw new Mo(n)}if(n==="outerHTML"){let o=r==null?"":String(r);return e.replaceWith(t,o)}if(li.has(n)){let o=ai(n,r);return e.prop(t,n)!==o&&e.prop(t,n,o),t}if(r==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let o=String(r);e.attr(t,n)!==o&&e.attr(t,n,o)}return t}function tl(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:Do([...n,s]),expected:"scalar",got:jo(o)})}):r.push({path:Do(n),expected:"array",got:jo(t)});return}t!==null&&typeof t=="object"&&r.push({path:Do(n),expected:"scalar",got:jo(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){r.push({path:Do(n),expected:"array",got:jo(t)});return}let o=e[1];t.forEach((s,i)=>tl(o,s,[...n,i],r));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){r.push({path:Do(n),expected:"object",got:jo(t)});return}for(let[o,s]of Object.entries(e))tl(s,t[o],[...n,o],r)}}}function jo(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Do(e){return e.join(".")}var Gh=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",...sc],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 nl(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 Po(e,r,n)}return null}var wn={extract:(e,t,n={})=>hr(er(e,n),e,t,n),apply:(e,t,n,r={})=>Qr(er(e,{...r,_write:!0}),e,t,n,r),findRulesIn:(e,t)=>Po(Jr,e,t),findRules:(e,t)=>nl(Jr,e,t),bind:(e,t,n={})=>{let r=nl(Jr,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:()=>hr(er(e,n),e,r.rules,n),set:o=>Qr(er(e,{...n,_write:!0}),e,r.rules,o,n)}},parseStrict:Zi,parseRelaxed:Zr,ruleAttrIndex:nn,splitRule:xo,errors:gs,DOM_PROPERTIES:Qo};var ol={};ii(ol,{fromString:()=>tr,getRuleAtPath:()=>Nr,getValueAtPath:()=>Qh,setAtPath:()=>rl,toString:()=>Zh});function Zh(e){return e.map(String).join(".")}function tr(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function Nr(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 Qh(e,t){let n=e;for(let r of t){if(n==null)return;n=n[r]}return n}function rl(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]=rl(s[r],o,n),s}return{...e&&typeof e=="object"?e:{},[r]:rl((e||{})[r],o,n)}}function Fo(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]=Fo(r);return t}return""}function ks(e,t,{ignoreActiveValue:n=!0}={}){Ki.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:n,restoreFocus:!0,formStateSync:"property",policy:"raw"})}var Mc=new WeakMap,sl=e=>e.map(String).join(".");function em(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function Rc(e,t){if(!e||!e.querySelector)return null;let n=e.querySelector(`[data-hcms-path="${em(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 Ic(e,t,n){let r=Rc(e,t);!r||r.length!==n.length||r.forEach((o,s)=>{n[s]&&Mc.set(o,n[s])})}function xs(){let e=new Map;return{hooks:{onRowsRead(t,n){e.set(sl(t),n)}},seed(t){for(let[n,r]of e)Ic(t,n,r);e.clear()}}}function Lc(e){return{identifyRows(t,n){let r=Rc(e,sl(t));return!r||r.length!==n.length?null:r.map(o=>Mc.get(o)||null)},onRowsApplied(t,n){Ic(e,sl(t),n)}}}var Pc={skip:"[data-hcms-shell]",templateAttr:"cms-template"},il="data-hcms-rollback-ui",tm=0;function jc(e,t,n,r={}){return nm(e,t,n,r)}function nm(e,t,n,r){let{shellRoot:o,structural:s,structuralPath:i,formRoot:l}=r,a=l?{...Pc,...Lc(l)}:Pc;if(!s)try{return wn.apply(e,t,n,a),{ok:!0}}catch(f){return{ok:!1,error:f}}let c=rm(e,t,i),d=c?sm(c):null,u=c?null:lm(e,o);try{return wn.apply(e,t,n,a),{ok:!0}}catch(f){return d?im(c,d):u&&am(e,o,u),{ok:!1,error:f}}}function rm(e,t,n){if(!n||!e)return null;let r=tr(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:om(e,t,o)}function om(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 sm(e){let t=[],n=[];for(let r of Array.from(e.childNodes))t.push(ll(r,n));return{nodes:t,retained:n}}function im(e,t){let n=e.cloneNode(!1);for(let r of t.nodes)n.appendChild(r);ur(e,Array.from(n.childNodes),Fc()),Dc(e,t.retained)}function lm(e,t){let n=[],r=[];for(let o of Array.from(e.childNodes))o===t||t&&o.contains?.(t)||n.push(ll(o,r));return{nodes:n,retained:r}}function am(e,t,n){let r=e.cloneNode(!1);for(let o of n.nodes)r.appendChild(o);ur(e,Array.from(r.childNodes),Fc()),Dc(e,n.retained)}function ll(e,t){let n=e.cloneNode(!1);if(e.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]')){let s=String(++tm);n.setAttribute(il,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(ll(s,t));return n}function Dc(e,t){for(let{id:n,node:r}of t){let o=e.querySelector(`[${il}="${n}"]`);o===r?r.removeAttribute(il):r.isConnected?o?.remove():o?.replaceWith(r)}}function Fc(){return{morphStyle:"innerHTML",policy:"raw",restoreFocus:!1,scripts:{handle:!1,merge:!1}}}function ws(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 cm='<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>',al='<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>',Uc={"@scalar":`
|
|
7
7
|
<label class="hcms-field" data-hcms-shape="scalar">
|
|
8
8
|
<span class="hcms-label" data-hcms-label></span>
|
|
9
9
|
<textarea class="mirk-textarea" rows="1" data-hcms-field></textarea>
|
|
@@ -43,13 +43,13 @@ var hypercms=(()=>{var ri=Object.defineProperty;var vu=Object.getOwnPropertyDesc
|
|
|
43
43
|
</section>
|
|
44
44
|
`,"@object-array-item":`
|
|
45
45
|
<article class="hcms-card mirk-sortable__item" draggable="true">
|
|
46
|
-
${
|
|
46
|
+
${cm}
|
|
47
47
|
<div class="hcms-card-body mirk-sortable__body">
|
|
48
48
|
<div class="hcms-card-fields"></div>
|
|
49
49
|
<div class="hcms-card-controls">
|
|
50
50
|
<button type="button" class="hcms-move hcms-move-up hcms-sr-only" data-hcms-action="move-up" aria-label="Move up">\u2191</button>
|
|
51
51
|
<button type="button" class="hcms-move hcms-move-down hcms-sr-only" data-hcms-action="move-down" aria-label="Move down">\u2193</button>
|
|
52
|
-
<button type="button" class="hcms-remove hcms-remove--card" data-hcms-action="remove" aria-label="Remove">${
|
|
52
|
+
<button type="button" class="hcms-remove hcms-remove--card" data-hcms-action="remove" aria-label="Remove">${al}</button>
|
|
53
53
|
</div>
|
|
54
54
|
</div>
|
|
55
55
|
<div class="hcms-error" hidden></div>
|
|
@@ -63,7 +63,7 @@ var hypercms=(()=>{var ri=Object.defineProperty;var vu=Object.getOwnPropertyDesc
|
|
|
63
63
|
<span class="mirk-button__label">Choose</span>
|
|
64
64
|
</label>
|
|
65
65
|
<a class="mirk-file__name" data-hcms-field></a>
|
|
66
|
-
<button type="button" class="hcms-upload-clear" data-hcms-action="clear-upload" aria-label="Remove file">${
|
|
66
|
+
<button type="button" class="hcms-upload-clear" data-hcms-action="clear-upload" aria-label="Remove file">${al}</button>
|
|
67
67
|
</div>
|
|
68
68
|
<div class="hcms-error" hidden></div>
|
|
69
69
|
</div>
|
|
@@ -77,7 +77,7 @@ var hypercms=(()=>{var ri=Object.defineProperty;var vu=Object.getOwnPropertyDesc
|
|
|
77
77
|
</label>
|
|
78
78
|
<figure class="mirk-image__thumb">
|
|
79
79
|
<span class="mirk-image__frame"><img class="mirk-image__preview" data-hcms-field alt="" /></span>
|
|
80
|
-
<button type="button" class="hcms-upload-clear hcms-upload-clear--badge" data-hcms-action="clear-upload" aria-label="Remove image">${
|
|
80
|
+
<button type="button" class="hcms-upload-clear hcms-upload-clear--badge" data-hcms-action="clear-upload" aria-label="Remove image">${al}</button>
|
|
81
81
|
</figure>
|
|
82
82
|
</div>
|
|
83
83
|
<div class="hcms-error" hidden></div>
|
|
@@ -151,9 +151,9 @@ var hypercms=(()=>{var ri=Object.defineProperty;var vu=Object.getOwnPropertyDesc
|
|
|
151
151
|
<input class="hcms-chip-field" data-hcms-field aria-label="Item" placeholder="\u2026" />
|
|
152
152
|
<button type="button" class="hcms-remove" data-hcms-action="remove" aria-label="Remove">\xD7</button>
|
|
153
153
|
</span>
|
|
154
|
-
`},Gh=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function vs(e){let t=e.head||e.documentElement;if(t)for(let n of Gh)Pc(e,t,n)}function sl(e,t){if(!Mc[t])return null;let n=e&&(e.head||e.documentElement);return n?Pc(e,n,t):null}var Nc={src:"@image",checked:"@checkbox",innerHTML:"@richtext"},ys={image:"@image",file:"@file",checkbox:"@checkbox",toggle:"@toggle",select:"@select",radio:"@radio",textarea:"@textarea",number:"@number",richtext:"@richtext"},Yh=new Set([...Object.values(ys),"@chips","@chips-item"]);function Do(e,t,n,r){if(typeof e!="string")return"@scalar";let o=sn(e),s=Ss(e,o,n,r),i=Ts(s,t,"data-hcms-component");if(i&&ys[i]){let l=ys[i],a=Array.isArray(n)&&n.some(c=>c==="*"||typeof c=="number");return l==="@number"&&!Cc(e,o,t,a,s).every(Jh)||(l==="@checkbox"||l==="@toggle")&&(o<0||e.slice(o+1)!=="checked")&&!Cc(e,o,t,a,s).every(Zh)?"@scalar":l}if(o>=0){let l=e.slice(o+1);if(Nc[l])return Nc[l]}return"@scalar"}function Rc(e,t,n,r){if(typeof e!="string")return null;let o=sn(e),s=Ts(Ss(e,o,n,r),t,"data-hcms-component");return s&&ys[s]||null}var Xh=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function Jh(e){return e==null||e===""?!0:Xh.test(String(e))}function Zh(e){return e==null||e===""||e==="true"||e==="false"}function Cc(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 ws(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 Qr(e,t,n){let r=e.join("."),o=e.map(s=>typeof s=="number"?"*":s).join(".");return r&&Un(n,r)||o&&o!==r&&Un(n,o)||Un(n,t)}function As(e,t,n){let r=ws(e,n);if(!r)return null;let o=Qr(t,r.array,n);return o&&o.getAttribute("data-hcms-tpl")===r.array?r:null}function Ic(e,t,n,r){if(typeof e!="string")return null;let o=sn(e),s=Ts(Ss(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 Lc(e,t,n,r){if(typeof e!="string")return null;let o=sn(e);return Ts(Ss(e,o,n,r),t,"data-hcms-crop")}function Qh(e,t){return t>=0?e.slice(0,t):e}function Ss(e,t,n,r){let o=Qh(e,t);return o&&o!=="."?o:em(r,n)}function em(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 Ts(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 Es(e,t){if(!e||t==null)return;n(t,[]);function n(r,o){let s=_r(r);if(s==="scalar"){let i=Do(r,e,o,t);Yh.has(i)&&sl(e,i);return}if(s==="scalar-array"){let i=ws(r,e);i&&(sl(e,i.array),sl(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,c]of Object.entries(i))n(c,[...l,a]);else n(i,l)}}}function Pc(e,t,n){let r=Un(e,n);if(r)return r;let o=e.createElement("template");return o.setAttribute("data-hcms-tpl",n),o.setAttribute("save-remove",""),o.innerHTML=Mc[n].trim(),t.appendChild(o),o}function Un(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${tm(t)}"]`)}function tm(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function _r(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function Bo(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var jc={IMG:"src",A:"href"};function Os(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":jc[t]?jc[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function Dc(e,t){let n=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),o=Os(e),i=`${Fc(n,r)}[data-hcms-field="${eo(t)}"]`;return n==="INPUT"&&r==="radio"?`${i}:checked@value`:o?`${i}@${o}`:i}function nm(e){let t=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),r=Os(e),s=`${Fc(t,n)}[data-hcms-field]`;return t==="INPUT"&&n==="radio"?`${s}:checked@value`:r?`${s}@${r}`:s}function Fc(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 eo(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Bc=new Set(["__proto__","constructor","prototype"]);function _s(e,t){return n(e,[]);function n(c,h){let u=_r(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[p,m]of Object.entries(c)){if(Bc.has(p))throw new Error(`hypercms: rule key "${p}" is forbidden at "${h.join(".")||"<root>"}"`);f[p]=n(m,[...h,p])}return f}return null}function r(c,h){let u=h.length?h[h.length-1]:null,f=typeof u=="string"?u:"__value",p=a(h,f);if(p)return Dc(p,f);let m=l(Do(c,t,h,e),f);return m?Dc(m,f):`input[data-hcms-field="${eo(f)}"]@value`}function o(c,h){let u=As(c,h,t),f=u&&l(u.item,null)||l("@scalar-array-item",null),p=f?nm(f):"input[data-hcms-field]@value";return[i(h,"[data-hcms-array-item]"),p]}function s(c,h){let[,u]=c,f=[...h,"*"],p=i(h,"[data-hcms-card]");if(u&&typeof u=="object"&&!Array.isArray(u)){let m=Object.create(null);for(let[y,g]of Object.entries(u)){if(Bc.has(y))throw new Error(`hypercms: rule key "${y}" is forbidden at "${f.join(".")}"`);m[y]=n(g,[...f,y])}return[p,m]}return[p,n(u,[...f,0])]}function i(c,h){let u=c.length?c[c.length-1]:"",f=c.some(y=>y==="*"),p=c.join(".");return`${f?`[data-hcms-field="${eo(u)}"]`:`[data-hcms-path="${eo(p)}"]`} > .hcms-array-items > ${h}`}function l(c,h){if(!t)return null;let u=Un(t,c);if(!u)return null;let f=u.content||u;if(h){let p=f.querySelector(`[data-hcms-field="${eo(h)}"]`);if(p)return p}return f.querySelector("[data-hcms-field]")}function a(c,h){if(!t)return null;let u=c.map(m=>typeof m=="number"?"*":m).join("."),p=[c.join("."),u];for(let m=c.length-1;m>=0;m--){let y=c.slice(0,m).map(g=>typeof g=="number"?"*":g);y.push("*"),p.push(y.join("."))}for(let m of p){if(!m)continue;let y=Un(t,m);if(!y||!Bo(y))continue;let g=y.content||y,d=g.querySelector(`[data-hcms-field="${eo(h)}"]`)||g.querySelector("[data-hcms-field]");if(d)return d}return null}}function il(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],n=t.split("/").pop()||t;try{return decodeURIComponent(n)}catch{return n}}function to({pageRules:e,formRules:t,data:n,doc:r}){let o=r.createDocumentFragment(),s=ll(e,[],n,r,e);return s&&o.appendChild(s),o}function Uc({shape:e,itemShape:t,pathArr:n,data:r,doc:o,itemKey:s,pageRules:i}){if(e==="object-array-item")return Hc(t,n,r,o,i);if(e==="scalar-array-item")return zc(n,r,o,s||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function ll(e,t,n,r,o){let s=_r(e);return s==="scalar"?rm(e,t,n,r,o):s==="object"?lm(e,t,n,r,o):s==="object-array"?am(e,t,n,r,o):s==="scalar-array"?cm(e,t,n,r):null}function rm(e,t,n,r,o){let s=Do(e,r,t,o),i=Qr(t,s,r);if(!i)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let l=Rc(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`),$c(i,l===s?l:null,t);let a=no(i,r);ro(a,t);let c=i.getAttribute?.("data-hcms-tpl");if((s==="@select"||s==="@radio")&&c===s&&om(a,e,t,n,r,s,o),s==="@image"&&c==="@image"){let h=Lc(e,r,t,o);h!=null&&!a.hasAttribute("data-hcms-crop")&&a.setAttribute("data-hcms-crop",h)}return fm(a,nr(t)),Ns(a,nr(t)),Cs(a,nr(t)),Yc(a,n),s==="@file"&&im(a),a}function $c(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 om(e,t,n,r,o,s,i){let l=Ic(t,o,n,i),a=l?[...l]:[],c=r==null?"":String(r);if(c!==""&&!a.includes(c)&&a.unshift(c),!l&&(sm(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 m=o.createElement("option");m.value=p,m.textContent=xs(p),f.appendChild(m)}return}let h=e.querySelector(".mirk-radio");if(!h||!h.parentNode)return;let u=al(n.join("."));for(let f of a){let p=h.cloneNode(!0),m=p.querySelector('input[type="radio"]');m&&(m.value=f,m.name=u);let y=p.querySelector(".mirk-radio__label");y&&(y.textContent=xs(f)),h.parentNode.insertBefore(p,h)}h.remove()}function al(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function sm(e,t){let n=e.querySelector?e.querySelector(".hcms-error"):null;n&&(n.textContent=t,n.hidden=!1)}function im(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=il(t.getAttribute("href")))}function lm(e,t,n,r,o){let s=Qr(t,"@object",r);if(!s)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let i=no(s,r);if(ro(i,t),Ns(i,nr(t)),Cs(i,nr(t)),Bo(s))return Jc(i,e,t),Xc(i,e,n),i;let l=Ms(i,".hcms-object-fields",s,t);for(let[a,c]of Object.entries(e)){let h=n==null?null:n[a],u=ll(c,[...t,a],h,r,o);u&&l.appendChild(u)}return i}function am(e,t,n,r,o){let s=Qr(t,"@object-array",r);if(!s)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let i=no(s,r);ro(i,t),Ns(i,nr(t)),Cs(i,nr(t)),Wc(i,s),Gc(i,s,t);let l=Ms(i,".hcms-array-items",s,t),[,a]=e;return(Array.isArray(n)?n:[]).forEach((h,u)=>{let f=Hc(a,[...t,u],h,r,o);f&&l.appendChild(f)}),Kc(i),i}function Hc(e,t,n,r,o){let s=Vc(t,"object-array-item",r);if(!s)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let i=no(s,r);if(i.setAttribute("data-hcms-card",""),i.classList.contains("hcms-card")||i.classList.add("hcms-card"),ro(i,t),Bo(s))return e&&typeof e=="object"&&!Array.isArray(e)&&(Jc(i,e,t),Xc(i,e,n)),i;let l=Ms(i,".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=ll(c,[...t,a],h,r,o);u&&l.appendChild(u)}return i}function cm(e,t,n,r){let o=ws(e,r),s=As(e,t,r),i=o?o.array:"@scalar-array",l=Qr(t,i,r);if(!l)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);$c(l,o?o.array:null,t);let a=no(l,r);ro(a,t),Ns(a,nr(t)),Cs(a,nr(t)),Wc(a,l),Gc(a,l,t),s&&a.setAttribute("data-hcms-item-tpl",s.item);let c=Ms(a,".hcms-array-items",l,t);return(Array.isArray(n)?n:[]).forEach((u,f)=>{let p=zc([...t,f],u,r,s?s.item:null);p&&c.appendChild(p)}),Kc(a),a}function zc(e,t,n,r){let o=Vc(e,"scalar-array-item",n,r);if(!o)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let s=no(o,n);return s.setAttribute("data-hcms-array-item",""),s.classList.contains("hcms-array-item")||s.classList.add("hcms-array-item"),ro(s,e),Yc(s,t),s}function Vc(e,t,n,r){let o=e.map(s=>typeof s=="number"?"*":s).join(".");return Un(n,o)||r&&Un(n,r)||Un(n,"@"+t)}function no(e,t){let n=e.content||e,r=t.createElement("div");return r.appendChild(n.cloneNode(!0)),r.firstElementChild||r}function ro(e,t){e.setAttribute("data-hcms-path",t.join("."))}function fm(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 Ns(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function Cs(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(r=>{(r.textContent||"").trim()===""&&(r.textContent=xs(String(t)))})}function Wc(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 Kc(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=qc(e,"data-hcms-max-items"),s=qc(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"),c=e.querySelector('[data-hcms-action="add"]');c&&(c.hidden=i||o!=null&&r>=o),n.forEach((h,u)=>{let f=h.querySelector('[data-hcms-action="remove"]');f&&(f.hidden=l||s!=null&&r<=s);let p=h.querySelector('[data-hcms-action="move-up"]');p&&(p.hidden=a||u===0);let m=h.querySelector('[data-hcms-action="move-down"]');m&&(m.hidden=a||u===r-1)})}function qc(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function Gc(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 nr(e){return e.length?e[e.length-1]:null}function Yc(e,t){let n=um(e);if(n.length!==0)for(let r of n)Zc(r,t)}function um(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&dm(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 dm(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function Xc(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];Zc(o,i)})}function Jc(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 Ms(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 Zc(e,t){let n=Os(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 hm={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?pm(t.uploadFileBasic):null)},mm={402:"payment-required",413:"too-large",415:"unsupported-type",401:"unauthorized",403:"forbidden",404:"not-found"},cl=()=>({ok:!1,msg:"Upload cancelled",msgType:"skipped",code:"aborted",uploads:[]});function pm(e){return async function(n,{onProgress:r,signal:o}={}){if(o?.aborted)return cl();try{let s=await e(n,{onProgress:l=>{r?.({loaded:null,total:null,percent:l})}});if(o?.aborted)return cl();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 cl();let i={};try{i=JSON.parse(s?.response||"{}")}catch{i={}}let l=i.code||mm[s?.status]||"error";return{ok:!1,msg:s&&s.message||"Upload failed",msgType:"error",code:l,uploads:[]}}}}function dn(e,t){let n=hm[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 Qc=["clay:mutation-ready","hyperclay:mutation-ready"],ef=["clay:sync-applied","hyperclay:livesync-applied"],tf=["clay:ready","hyperclay:ready"];function oo(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 $n="data-hcms-bound",hr="data-hcms-bound-id",fl=new Map;function nf(e,t){fl.set(e,t)}function rf(e){fl.delete(e)}function of(e){let t=e.getAttribute(hr);if(!t)return null;let n=fl.get(t);return!n||!n.restorable()?null:n.originalHTML}var Nr="data-hcms-owns-richclay";function so(e){return e&&e.richclay&&e.richclay.RichClay||dn("RichClay",e)||(e&&typeof e.RichClay=="function"?e.RichClay:null)}function sf(e,t,n){!e||typeof e.setAttribute!="function"||(e.setAttribute($n,t?"rich":"plain"),n&&e.setAttribute(Nr,"true"))}function lf(e,t){if(!e||typeof e.querySelectorAll!="function")return;let n=e.querySelectorAll(`[${$n}]`);if(!n.length)return;let r=so(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(Nr)==="true"&&o.removeAttribute("data-richclay"),o.removeAttribute(Nr),o.removeAttribute($n)}function af(e,t){if(!e||typeof e.removeAttribute!="function")return;let n=so(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(Nr)==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute(Nr),e.removeAttribute($n),e.removeAttribute(hr)}function cf(e,t){if(!t||e==null)return e;return n(e);function n(r){if(typeof r=="string"){if(r.endsWith("[]")||sn(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 ff(e,t){if(!t||e==null)return e;return n(e,[t]);function n(r,o){if(typeof r=="string")return r.endsWith("[]")||sn(r)!==-1?r:o.some(s=>gm(s,r))?r+"@innerHTML":r;if(Array.isArray(r)){let[s,i]=r;if(typeof s!="string"||!s)return r;let l=bm(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 gm(e,t){let n=null;try{n=e.querySelector(t)}catch{return!1}return n?n.hasAttribute($n)?n.getAttribute($n)==="rich":n.children.length>0:!1}function bm(e,t){try{return[...e.querySelectorAll(t)]}catch{return[]}}function io(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 mr(e,t,n=!0){if(!e||!e.querySelectorAll||(e.querySelectorAll("textarea[data-hcms-field]").forEach(io),n===!1))return;let r=t&&t.defaultView||(typeof window<"u"?window:null),o=so(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 ul=new WeakSet;function Cr(e,t){let n=dn("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 rr(e){let t=dn("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function Ls(e){let{formRoot:t}=e;if(!t||ul.has(t))return;ul.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"&&io(l),!l.matches('input[type="file"]')&&(!l.closest("[data-hcms-field]")&&!l.hasAttribute?.("data-hcms-field")||uf(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]')){Tm(l,e);return}l.matches('input[type="checkbox"], input[type="radio"], select')&&uf(l,e)}},o=i=>{let l=i.target;if(!l||!l.closest)return;let a=l.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");Fo(u,e)}else if(c==="remove"){let h=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!h)return;ml(h,e)}else if(c==="move-up"||c==="move-down"){let h=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!h)return;hl(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),ul.delete(t)}}var km=new Set(["value","checked"]);function ym(e,t){if(!t)return null;let n=tr(t);if(n.some(a=>typeof a=="number"||a==="*"))return null;let r=Or(e.pageRules,n);if(typeof r!="string")return null;let o=wn.ruleAttrIndex(r);if(o===-1)return null;let s=r.slice(o+1);if(!km.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 uf(e,t){let r=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",o=ym(t,r);if(Mn(Tn(t),{path:r,structural:!1},t),o){let s=dn("undo");s&&typeof s.recordValue=="function"&&s.recordValue(o.el,{prop:o.prop,oldValue:o.oldValue,newValue:o.el[o.prop]})}}var xm={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function vm(e,t){let n=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(n==null)return{file:e};let r=dn("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:wm(n),modal:o,...xm});return s===null?null:{file:Am(s.blob,e.name),dataURL:s.dataURL}}catch(o){return ao(t,o&&o.message||"Crop failed"),null}}function wm(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 Am(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 Sm=new Set(["unsupported","payment-required"]);async function Tm(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")||"";ao(r,null);let s=await vm(n,r);if(!s||t.closed){pr(e);return}let i=s.file,l=s.dataURL||null,a=dn("upload");if(typeof a!="function")return dl(e,r,t,o,await df(i,l,r),i);gf(r,l),hf(r,0);let c=Om(t),h;try{h=await a(i,{signal:c?.signal,onProgress:({percent:f})=>hf(r,f)})}finally{_m(t,c),Mm(r)}if(t.closed){pr(e);return}if(h.code==="aborted"){pr(e);return}if(h.ok)return dl(e,r,t,o,h.uploads[0].url,i);if(!Sm.has(h.code)){ao(r,h.msg||"Upload failed"),t.dispatch?.("hcms:error",{error:new Error(h.msg||"Upload failed"),code:h.code,path:o}),pr(e);return}let u=h.code==="payment-required"?"This file is stored in the page. Add a paid plan to upload files.":null;return dl(e,r,t,o,await df(i,l,r),i,u)}function dl(e,t,n,r,o,s,i=null){if(n.closed){pr(e);return}if(gf(t,null),ao(t,null),!o){pr(e);return}pf(t,o,s.name),Mn(Tn(n),{path:r,structural:!1},n),i&&ao(t,i,"info"),pr(e)}async function df(e,t,n){return t||await Em(e,n)}function Em(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 Om(e){if(typeof AbortController!="function")return null;let t=new AbortController;return(e.uploads||(e.uploads=new Set)).add(t),t}function _m(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")||"";pf(n,"","");let o=n.querySelector('input[type="file"][data-hcms-upload]');o&&pr(o),ao(n,null),Mn(Tn(t),{path:r,structural:!1},t)}function Cm(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function pf(e,t,n){let r=Cm(e);if(!r)return;let o=(r.tagName||"").toUpperCase();o==="IMG"?r.src=t||"":o==="A"&&(r.href=t||"",r.textContent=t?n||il(t):"")}function pr(e){try{e.value=""}catch{}}function gf(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 hf(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 Mm(e){e.removeAttribute("data-hcms-uploading"),e.style?.removeProperty?.("--hcms-upload-progress")}function ao(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 Fo(e,t){let{formRoot:n,pageRules:r}=t,o=n.querySelector(`[data-hcms-path="${co(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=tr(e),l=jm(r,i),a=Array.isArray(l),c=typeof l=="string"&&l.endsWith("[]");if(!a&&!c)throw new Error(`hypercms: path "${e}" is not an array`);let h=Is(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,p=a?l[1]:l.replace(/\[\]$/,""),m=jo(a?p:"string"),y=Uc({shape:a?"object-array-item":"scalar-array-item",itemShape:p,pathArr:[...i,f],data:m,doc:t.doc,itemKey:o.getAttribute("data-hcms-item-tpl")||null,pageRules:r});return s.appendChild(y),mr(y,t.doc,t.view?.enhanceFormRichText!==!1),gl(o),Cr(`Add ${e}`,()=>Mn(Tn(t),{path:e,structural:!0},t))}function hl(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),bl(o),gl(r),a&&typeof a.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),Cr(`Reorder ${r.getAttribute("data-hcms-path")||""}`,()=>Mn(Tn(n),{path:r.getAttribute("data-hcms-path")||"",structural:!0},n))}var Rs="Delete this item?";function Rm(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||Rs;let r=t&&t.confirmRemove;return r===!1?null:typeof r=="string"?r||Rs:r===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?Rs:null}function ml(e,t){let n=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),r=Rm(n,t);if(r==null)return lo(e,t);let o=dn("consent")||typeof window<"u"&&window.consent;typeof o=="function"?Promise.resolve(o(r)).then(()=>{t.closed||lo(e,t)},()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(r)&&lo(e,t):lo(e,t)}function lo(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=Is(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&&bl(r),o&&gl(o),Cr(`Remove ${n}`,()=>Mn(Tn(t),{path:n,structural:!0},t))}}function Mn(e,t,n){if(n.closed)return{ok:!1,skipped:!0,closed:!0};let r=qo(e);if(!t.structural&&r===n.lastFingerprint)return{ok:!0,skipped:!0};let o=Object.hasOwn(n,"writeRules")?n.writeRules:n.pageRules,s=Ec(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,mf(n,null),n.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),n.onChange?.(e,t)):(mf(n,Pm(s.error,t.path)),n.dispatch?.("hcms:error",{error:s.error,attemptedData:e}),n.onError?.(s.error)),s}function Ps(e,t){let n=co(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 js(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=co(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 Tn(e){let t=wn.extract(e.formRoot,e.formRules,{exclude:null});return gr(t,e.formRules)}function gr(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=>gr(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]=gr(e[r],o);return n}return e}function mf(e,t){e.lastErrors=t&&t.length?t:null,pl(e)}function pl(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}
|
|
154
|
+
`},fm=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function As(e){let t=e.head||e.documentElement;if(t)for(let n of fm)Vc(e,t,n)}function cl(e,t){if(!Uc[t])return null;let n=e&&(e.head||e.documentElement);return n?Vc(e,n,t):null}var Bc={src:"@image",checked:"@checkbox",innerHTML:"@richtext"},vs={image:"@image",file:"@file",checkbox:"@checkbox",toggle:"@toggle",select:"@select",radio:"@radio",textarea:"@textarea",number:"@number",richtext:"@richtext"},um=new Set([...Object.values(vs),"@chips","@chips-item"]);function Bo(e,t,n,r){if(typeof e!="string")return"@scalar";let o=nn(e),s=Es(e,o,n,r),i=Os(s,t,"data-hcms-component");if(i&&vs[i]){let l=vs[i],a=Array.isArray(n)&&n.some(c=>c==="*"||typeof c=="number");return l==="@number"&&!qc(e,o,t,a,s).every(hm)||(l==="@checkbox"||l==="@toggle")&&(o<0||e.slice(o+1)!=="checked")&&!qc(e,o,t,a,s).every(mm)?"@scalar":l}if(o>=0){let l=e.slice(o+1);if(Bc[l])return Bc[l]}return"@scalar"}function $c(e,t,n,r){if(typeof e!="string")return null;let o=nn(e),s=Os(Es(e,o,n,r),t,"data-hcms-component");return s&&vs[s]||null}var dm=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function hm(e){return e==null||e===""?!0:dm.test(String(e))}function mm(e){return e==null||e===""||e==="true"||e==="false"}function qc(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 Ss(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 eo(e,t,n){let r=e.join("."),o=e.map(s=>typeof s=="number"?"*":s).join(".");return r&&Un(n,r)||o&&o!==r&&Un(n,o)||Un(n,t)}function Ts(e,t,n){let r=Ss(e,n);if(!r)return null;let o=eo(t,r.array,n);return o&&o.getAttribute("data-hcms-tpl")===r.array?r:null}function Hc(e,t,n,r){if(typeof e!="string")return null;let o=nn(e),s=Os(Es(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 zc(e,t,n,r){if(typeof e!="string")return null;let o=nn(e);return Os(Es(e,o,n,r),t,"data-hcms-crop")}function pm(e,t){return t>=0?e.slice(0,t):e}function Es(e,t,n,r){let o=pm(e,t);return o&&o!=="."?o:gm(r,n)}function gm(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 Os(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 Ns(e,t){if(!e||t==null)return;n(t,[]);function n(r,o){let s=_r(r);if(s==="scalar"){let i=Bo(r,e,o,t);um.has(i)&&cl(e,i);return}if(s==="scalar-array"){let i=Ss(r,e);i&&(cl(e,i.array),cl(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,c]of Object.entries(i))n(c,[...l,a]);else n(i,l)}}}function Vc(e,t,n){let r=Un(e,n);if(r)return r;let o=e.createElement("template");return o.setAttribute("data-hcms-tpl",n),o.setAttribute("save-remove",""),o.innerHTML=Uc[n].trim(),t.appendChild(o),o}function Un(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${bm(t)}"]`)}function bm(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function _r(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function qo(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var Wc={IMG:"src",A:"href"};function _s(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":Wc[t]?Wc[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function Kc(e,t){let n=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),o=_s(e),i=`${Yc(n,r)}[data-hcms-field="${to(t)}"]`;return n==="INPUT"&&r==="radio"?`${i}:checked@value`:o?`${i}@${o}`:i}function ym(e){let t=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),r=_s(e),s=`${Yc(t,n)}[data-hcms-field]`;return t==="INPUT"&&n==="radio"?`${s}:checked@value`:r?`${s}@${r}`:s}function Yc(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 to(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 Cs(e,t){return n(e,[]);function n(c,d){let u=_r(c);if(u==="scalar")return r(c,d);if(u==="scalar-array")return o(c,d);if(u==="object-array")return s(c,d);if(u==="object"){let f=Object.create(null);for(let[p,m]of Object.entries(c)){if(Gc.has(p))throw new Error(`hypercms: rule key "${p}" is forbidden at "${d.join(".")||"<root>"}"`);f[p]=n(m,[...d,p])}return f}return null}function r(c,d){let u=d.length?d[d.length-1]:null,f=typeof u=="string"?u:"__value",p=a(d,f);if(p)return Kc(p,f);let m=l(Bo(c,t,d,e),f);return m?Kc(m,f):`input[data-hcms-field="${to(f)}"]@value`}function o(c,d){let u=Ts(c,d,t),f=u&&l(u.item,null)||l("@scalar-array-item",null),p=f?ym(f):"input[data-hcms-field]@value";return[i(d,"[data-hcms-array-item]"),p]}function s(c,d){let[,u]=c,f=[...d,"*"],p=i(d,"[data-hcms-card]");if(u&&typeof u=="object"&&!Array.isArray(u)){let m=Object.create(null);for(let[k,g]of Object.entries(u)){if(Gc.has(k))throw new Error(`hypercms: rule key "${k}" is forbidden at "${f.join(".")}"`);m[k]=n(g,[...f,k])}return[p,m]}return[p,n(u,[...f,0])]}function i(c,d){let u=c.length?c[c.length-1]:"",f=c.some(k=>k==="*"),p=c.join(".");return`${f?`[data-hcms-field="${to(u)}"]`:`[data-hcms-path="${to(p)}"]`} > .hcms-array-items > ${d}`}function l(c,d){if(!t)return null;let u=Un(t,c);if(!u)return null;let f=u.content||u;if(d){let p=f.querySelector(`[data-hcms-field="${to(d)}"]`);if(p)return p}return f.querySelector("[data-hcms-field]")}function a(c,d){if(!t)return null;let u=c.map(m=>typeof m=="number"?"*":m).join("."),p=[c.join("."),u];for(let m=c.length-1;m>=0;m--){let k=c.slice(0,m).map(g=>typeof g=="number"?"*":g);k.push("*"),p.push(k.join("."))}for(let m of p){if(!m)continue;let k=Un(t,m);if(!k||!qo(k))continue;let g=k.content||k,h=g.querySelector(`[data-hcms-field="${to(d)}"]`)||g.querySelector("[data-hcms-field]");if(h)return h}return null}}function fl(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],n=t.split("/").pop()||t;try{return decodeURIComponent(n)}catch{return n}}function no({pageRules:e,formRules:t,data:n,doc:r}){let o=r.createDocumentFragment(),s=ul(e,[],n,r,e);return s&&o.appendChild(s),o}function Jc({shape:e,itemShape:t,pathArr:n,data:r,doc:o,itemKey:s,pageRules:i}){if(e==="object-array-item")return Qc(t,n,r,o,i);if(e==="scalar-array-item")return ef(n,r,o,s||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function ul(e,t,n,r,o){let s=_r(e);return s==="scalar"?km(e,t,n,r,o):s==="object"?Am(e,t,n,r,o):s==="object-array"?Sm(e,t,n,r,o):s==="scalar-array"?Tm(e,t,n,r):null}function km(e,t,n,r,o){let s=Bo(e,r,t,o),i=eo(t,s,r);if(!i)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let l=$c(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`),Zc(i,l===s?l:null,t);let a=ro(i,r);oo(a,t);let c=i.getAttribute?.("data-hcms-tpl");if((s==="@select"||s==="@radio")&&c===s&&xm(a,e,t,n,r,s,o),s==="@image"&&c==="@image"){let d=zc(e,r,t,o);d!=null&&!a.hasAttribute("data-hcms-crop")&&a.setAttribute("data-hcms-crop",d)}return Em(a,nr(t)),Ms(a,nr(t)),Rs(a,nr(t)),sf(a,n),s==="@file"&&wm(a),a}function Zc(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 xm(e,t,n,r,o,s,i){let l=Hc(t,o,n,i),a=l?[...l]:[],c=r==null?"":String(r);if(c!==""&&!a.includes(c)&&a.unshift(c),!l&&(vm(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 m=o.createElement("option");m.value=p,m.textContent=ws(p),f.appendChild(m)}return}let d=e.querySelector(".mirk-radio");if(!d||!d.parentNode)return;let u=dl(n.join("."));for(let f of a){let p=d.cloneNode(!0),m=p.querySelector('input[type="radio"]');m&&(m.value=f,m.name=u);let k=p.querySelector(".mirk-radio__label");k&&(k.textContent=ws(f)),d.parentNode.insertBefore(p,d)}d.remove()}function dl(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function vm(e,t){let n=e.querySelector?e.querySelector(".hcms-error"):null;n&&(n.textContent=t,n.hidden=!1)}function wm(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=fl(t.getAttribute("href")))}function Am(e,t,n,r,o){let s=eo(t,"@object",r);if(!s)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let i=ro(s,r);if(oo(i,t),Ms(i,nr(t)),Rs(i,nr(t)),qo(s))return af(i,e,t),lf(i,e,n),i;let l=Is(i,".hcms-object-fields",s,t);for(let[a,c]of Object.entries(e)){let d=n==null?null:n[a],u=ul(c,[...t,a],d,r,o);u&&l.appendChild(u)}return i}function Sm(e,t,n,r,o){let s=eo(t,"@object-array",r);if(!s)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let i=ro(s,r);oo(i,t),Ms(i,nr(t)),Rs(i,nr(t)),nf(i,s),of(i,s,t);let l=Is(i,".hcms-array-items",s,t),[,a]=e;return(Array.isArray(n)?n:[]).forEach((d,u)=>{let f=Qc(a,[...t,u],d,r,o);f&&l.appendChild(f)}),rf(i),i}function Qc(e,t,n,r,o){let s=tf(t,"object-array-item",r);if(!s)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let i=ro(s,r);if(i.setAttribute("data-hcms-card",""),i.classList.contains("hcms-card")||i.classList.add("hcms-card"),oo(i,t),qo(s))return e&&typeof e=="object"&&!Array.isArray(e)&&(af(i,e,t),lf(i,e,n)),i;let l=Is(i,".hcms-card-fields",s,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[a,c]of Object.entries(e)){let d=n==null?null:n[a],u=ul(c,[...t,a],d,r,o);u&&l.appendChild(u)}return i}function Tm(e,t,n,r){let o=Ss(e,r),s=Ts(e,t,r),i=o?o.array:"@scalar-array",l=eo(t,i,r);if(!l)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);Zc(l,o?o.array:null,t);let a=ro(l,r);oo(a,t),Ms(a,nr(t)),Rs(a,nr(t)),nf(a,l),of(a,l,t),s&&a.setAttribute("data-hcms-item-tpl",s.item);let c=Is(a,".hcms-array-items",l,t);return(Array.isArray(n)?n:[]).forEach((u,f)=>{let p=ef([...t,f],u,r,s?s.item:null);p&&c.appendChild(p)}),rf(a),a}function ef(e,t,n,r){let o=tf(e,"scalar-array-item",n,r);if(!o)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let s=ro(o,n);return s.setAttribute("data-hcms-array-item",""),s.classList.contains("hcms-array-item")||s.classList.add("hcms-array-item"),oo(s,e),sf(s,t),s}function tf(e,t,n,r){let o=e.map(s=>typeof s=="number"?"*":s).join(".");return Un(n,o)||r&&Un(n,r)||Un(n,"@"+t)}function ro(e,t){let n=e.content||e,r=t.createElement("div");return r.appendChild(n.cloneNode(!0)),r.firstElementChild||r}function oo(e,t){e.setAttribute("data-hcms-path",t.join("."))}function Em(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 Ms(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function Rs(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(r=>{(r.textContent||"").trim()===""&&(r.textContent=ws(String(t)))})}function nf(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 rf(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=Xc(e,"data-hcms-max-items"),s=Xc(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"),c=e.querySelector('[data-hcms-action="add"]');c&&(c.hidden=i||o!=null&&r>=o),n.forEach((d,u)=>{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||u===0);let m=d.querySelector('[data-hcms-action="move-down"]');m&&(m.hidden=a||u===r-1)})}function Xc(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function of(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 nr(e){return e.length?e[e.length-1]:null}function sf(e,t){let n=Om(e);if(n.length!==0)for(let r of n)cf(r,t)}function Om(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&Nm(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 Nm(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function lf(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];cf(o,i)})}function af(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 Is(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 cf(e,t){let n=_s(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 _m={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?Mm(t.uploadFileBasic):null)},Cm={402:"payment-required",413:"too-large",415:"unsupported-type",401:"unauthorized",403:"forbidden",404:"not-found"},hl=()=>({ok:!1,msg:"Upload cancelled",msgType:"skipped",code:"aborted",uploads:[]});function Mm(e){return async function(n,{onProgress:r,signal:o}={}){if(o?.aborted)return hl();try{let s=await e(n,{onProgress:l=>{r?.({loaded:null,total:null,percent:l})}});if(o?.aborted)return hl();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 hl();let i={};try{i=JSON.parse(s?.response||"{}")}catch{i={}}let l=i.code||Cm[s?.status]||"error";return{ok:!1,msg:s&&s.message||"Upload failed",msgType:"error",code:l,uploads:[]}}}}function dn(e,t){let n=_m[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 ff=["clay:mutation-ready","hyperclay:mutation-ready"],uf=["clay:sync-applied","hyperclay:livesync-applied"],df=["clay:ready","hyperclay:ready"];function so(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 $n="data-hcms-bound",mr="data-hcms-bound-id",ml=new Map;function hf(e,t){ml.set(e,t)}function mf(e){ml.delete(e)}function pf(e){let t=e.getAttribute(mr);if(!t)return null;let n=ml.get(t);return!n||!n.restorable()?null:n.originalHTML}var Cr="data-hcms-owns-richclay";function io(e){return e&&e.richclay&&e.richclay.RichClay||dn("RichClay",e)||(e&&typeof e.RichClay=="function"?e.RichClay:null)}function gf(e,t,n){!e||typeof e.setAttribute!="function"||(e.setAttribute($n,t?"rich":"plain"),n&&e.setAttribute(Cr,"true"))}function bf(e,t){if(!e||typeof e.querySelectorAll!="function")return;let n=e.querySelectorAll(`[${$n}]`);if(!n.length)return;let r=io(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(Cr)==="true"&&o.removeAttribute("data-richclay"),o.removeAttribute(Cr),o.removeAttribute($n)}function yf(e,t){if(!e||typeof e.removeAttribute!="function")return;let n=io(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(Cr)==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute(Cr),e.removeAttribute($n),e.removeAttribute(mr)}function kf(e,t){if(!t||e==null)return e;return n(e);function n(r){if(typeof r=="string"){if(r.endsWith("[]")||nn(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 xf(e,t){if(!t||e==null)return e;return n(e,[t]);function n(r,o){if(typeof r=="string")return r.endsWith("[]")||nn(r)!==-1?r:o.some(s=>Rm(s,r))?r+"@innerHTML":r;if(Array.isArray(r)){let[s,i]=r;if(typeof s!="string"||!s)return r;let l=Im(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 Rm(e,t){let n=null;try{n=e.querySelector(t)}catch{return!1}return n?n.hasAttribute($n)?n.getAttribute($n)==="rich":n.children.length>0:!1}function Im(e,t){try{return[...e.querySelectorAll(t)]}catch{return[]}}function lo(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 pr(e,t,n=!0){if(!e||!e.querySelectorAll||(e.querySelectorAll("textarea[data-hcms-field]").forEach(lo),n===!1))return;let r=t&&t.defaultView||(typeof window<"u"?window:null),o=io(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 pl=new WeakSet;function Mr(e,t){let n=dn("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 rr(e){let t=dn("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function js(e){let{formRoot:t}=e;if(!t||pl.has(t))return;pl.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"&&lo(l),!l.matches('input[type="file"]')&&(!l.closest("[data-hcms-field]")&&!l.hasAttribute?.("data-hcms-field")||vf(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]')){Um(l,e);return}l.matches('input[type="checkbox"], input[type="radio"], select')&&vf(l,e)}},o=i=>{let l=i.target;if(!l||!l.closest)return;let a=l.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 d=a.closest("[data-hcms-path]");if(!d)return;let u=d.getAttribute("data-hcms-path");Uo(u,e)}else if(c==="remove"){let d=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!d)return;yl(d,e)}else if(c==="move-up"||c==="move-down"){let d=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!d)return;bl(d,c==="move-up"?-1:1,e)}else c==="clear-upload"?Vm(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),pl.delete(t)}}var Lm=new Set(["value","checked"]);function Pm(e,t){if(!t)return null;let n=tr(t);if(n.some(a=>typeof a=="number"||a==="*"))return null;let r=Nr(e.pageRules,n);if(typeof r!="string")return null;let o=wn.ruleAttrIndex(r);if(o===-1)return null;let s=r.slice(o+1);if(!Lm.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 vf(e,t){let r=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",o=Pm(t,r);if(Mn(Tn(t),{path:r,structural:!1},t),o){let s=dn("undo");s&&typeof s.recordValue=="function"&&s.recordValue(o.el,{prop:o.prop,oldValue:o.oldValue,newValue:o.el[o.prop]})}}var jm={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function Dm(e,t){let n=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(n==null)return{file:e};let r=dn("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:Fm(n),modal:o,...jm});return s===null?null:{file:Bm(s.blob,e.name),dataURL:s.dataURL}}catch(o){return co(t,o&&o.message||"Crop failed"),null}}function Fm(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 Bm(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 qm=new Set(["unsupported","payment-required"]);async function Um(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")||"";co(r,null);let s=await Dm(n,r);if(!s||t.closed){gr(e);return}let i=s.file,l=s.dataURL||null,a=dn("upload");if(typeof a!="function")return gl(e,r,t,o,await wf(i,l,r),i);Ef(r,l),Af(r,0);let c=Hm(t),d;try{d=await a(i,{signal:c?.signal,onProgress:({percent:f})=>Af(r,f)})}finally{zm(t,c),Km(r)}if(t.closed){gr(e);return}if(d.code==="aborted"){gr(e);return}if(d.ok)return gl(e,r,t,o,d.uploads[0].url,i);if(!qm.has(d.code)){co(r,d.msg||"Upload failed"),t.dispatch?.("hcms:error",{error:new Error(d.msg||"Upload failed"),code:d.code,path:o}),gr(e);return}let u=d.code==="payment-required"?"This file is stored in the page. Add a paid plan to upload files.":null;return gl(e,r,t,o,await wf(i,l,r),i,u)}function gl(e,t,n,r,o,s,i=null){if(n.closed){gr(e);return}if(Ef(t,null),co(t,null),!o){gr(e);return}Tf(t,o,s.name),Mn(Tn(n),{path:r,structural:!1},n),i&&co(t,i,"info"),gr(e)}async function wf(e,t,n){return t||await $m(e,n)}function $m(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 Hm(e){if(typeof AbortController!="function")return null;let t=new AbortController;return(e.uploads||(e.uploads=new Set)).add(t),t}function zm(e,t){t&&e.uploads?.delete(t)}function Vm(e,t){let n=e.closest("[data-hcms-path]");if(!n)return;let r=n.getAttribute("data-hcms-path")||"";Tf(n,"","");let o=n.querySelector('input[type="file"][data-hcms-upload]');o&&gr(o),co(n,null),Mn(Tn(t),{path:r,structural:!1},t)}function Wm(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function Tf(e,t,n){let r=Wm(e);if(!r)return;let o=(r.tagName||"").toUpperCase();o==="IMG"?r.src=t||"":o==="A"&&(r.href=t||"",r.textContent=t?n||fl(t):"")}function gr(e){try{e.value=""}catch{}}function Ef(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 Af(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 Km(e){e.removeAttribute("data-hcms-uploading"),e.style?.removeProperty?.("--hcms-upload-progress")}function co(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 Uo(e,t){let{formRoot:n,pageRules:r}=t,o=n.querySelector(`[data-hcms-path="${fo(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=tr(e),l=Zm(r,i),a=Array.isArray(l),c=typeof l=="string"&&l.endsWith("[]");if(!a&&!c)throw new Error(`hypercms: path "${e}" is not an array`);let d=Ps(o,"data-hcms-max-items"),u=s.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(o.hasAttribute("data-hcms-no-add")||d!=null&&u.length>=d)return;let f=u.length,p=a?l[1]:l.replace(/\[\]$/,""),m=Fo(a?p:"string"),k=Jc({shape:a?"object-array-item":"scalar-array-item",itemShape:p,pathArr:[...i,f],data:m,doc:t.doc,itemKey:o.getAttribute("data-hcms-item-tpl")||null,pageRules:r});return s.appendChild(k),pr(k,t.doc,t.view?.enhanceFormRichText!==!1),xl(o),Mr(`Add ${e}`,()=>Mn(Tn(t),{path:e,structural:!0},t))}function bl(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),vl(o),xl(r),a&&typeof a.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),Mr(`Reorder ${r.getAttribute("data-hcms-path")||""}`,()=>Mn(Tn(n),{path:r.getAttribute("data-hcms-path")||"",structural:!0},n))}var Ls="Delete this item?";function Gm(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||Ls;let r=t&&t.confirmRemove;return r===!1?null:typeof r=="string"?r||Ls:r===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?Ls:null}function yl(e,t){let n=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),r=Gm(n,t);if(r==null)return ao(e,t);let o=dn("consent")||typeof window<"u"&&window.consent;typeof o=="function"?Promise.resolve(o(r)).then(()=>{t.closed||ao(e,t)},()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(r)&&ao(e,t):ao(e,t)}function ao(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=Ps(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&&vl(r),o&&xl(o),Mr(`Remove ${n}`,()=>Mn(Tn(t),{path:n,structural:!0},t))}}function Mn(e,t,n){if(n.closed)return{ok:!1,skipped:!0,closed:!0};let r=$o(e);if(!t.structural&&r===n.lastFingerprint)return{ok:!0,skipped:!0};let o=Object.hasOwn(n,"writeRules")?n.writeRules:n.pageRules,s=jc(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,Sf(n,null),n.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),n.onChange?.(e,t)):(Sf(n,Jm(s.error,t.path)),n.dispatch?.("hcms:error",{error:s.error,attemptedData:e}),n.onError?.(s.error)),s}function Ds(e,t){let n=fo(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 Fs(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=fo(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 Tn(e){let t=wn.extract(e.formRoot,e.formRules,{exclude:null});return br(t,e.formRules)}function br(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=>br(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]=br(e[r],o);return n}return e}function Sf(e,t){e.lastErrors=t&&t.length?t:null,kl(e)}function kl(e){if(Ym(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=Xm(e.formRoot,r);if(o){o.textContent=o.textContent?`${o.textContent}
|
|
155
155
|
${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textContent=t.join(`
|
|
156
|
-
`),e.errorEl.hidden=!1)}function
|
|
156
|
+
`),e.errorEl.hidden=!1)}function Ym(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function Xm(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 Jm(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 Zm(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 Ps(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function xl(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=Ps(e,"data-hcms-max-items"),s=Ps(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"),c=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');c&&(c.hidden=i||o!=null&&r>=o),n.forEach((d,u)=>{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||u===0);let m=d.querySelector('[data-hcms-action="move-down"]');m&&(m.hidden=a||u===r-1)})}function Bs(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>vl(t))}function vl(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&&Qm(r,o,i),n++}for(let[r,o]of t)r.checked!==o&&(r.checked=o)}function Qm(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))}ep(e)}function ep(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=dl(n.getAttribute("data-hcms-path")))}}function $o(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 fo(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var ip={},qs="hcms-shell-styles",tp="hcms-bundled-styles-installed",Us="hcms-session-open",np='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',uo=new WeakSet,wl="";function Nf(e){wl=e}function Ho(e){e?.body?.classList.add(Us)}function Al(e){e?.body?.classList.remove(Us)}var rp=0;function Of(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&","<":"<",">":">",'"':"""})[t])}function _f({mountTo:e,side:t="right",overlay:n=!1,showSaveButton:r=!1,title:o="Page content",eyebrow:s="Edit",theme:i=null,doc:l}){Cf(l);let a=`hcms-shell-title-${++rp}`,c=l.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 d=i==="dark"?" dark":i==="light"?" light":"";c.className="hcms-shell pixel-quiet hcms-panel hcms-side-"+t+(n?" hcms-overlay":"")+d;let u=Of(o),f=Of(s);c.innerHTML=`
|
|
157
157
|
<div class="hcms-shell-minibar" aria-hidden="true">
|
|
158
158
|
<span class="hcms-shell-minibar-title">${u}</span>
|
|
159
159
|
<button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
|
|
@@ -179,8 +179,8 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
|
|
|
179
179
|
</button>
|
|
180
180
|
</footer>
|
|
181
181
|
</div>
|
|
182
|
-
`,(e||l.body).appendChild(c);let m=l.body;m.classList.add("hcms-open"),
|
|
183
|
-
`),t.hidden=!1}function Ym(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(`${Vm} "${r}" matches ${o} elements; edits go to the first one.`)}}function Af(e){return[...new Set(e)]}function Xm(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 uo(e){return e.length?e.join("."):"(whole page)"}var Jm={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function kr(e,{ignoreActiveValue:t}={}){return Zm(e,{ignoreActiveValue:t})}function Zm(e,{ignoreActiveValue:t}){let n=wn.findRules(e.doc,e.rulesSource||"cms");n&&(e.pageRules=e.view.prepareRules(n.rules),e.rulesTagNode=n.tagNode),vs(e.doc),Es(e.doc,e.pageRules),e.formRules=_s(e.pageRules,e.doc),e.writeRules=$s(e.pageRules),e.unresolved=Us(e.pageRoot,e.pageRules);let r=ks(),o=gr(wn.extract(e.pageRoot,e.pageRules,{...Jm,...r.hooks}),e.pageRules),s=to({pageRules:e.pageRules,formRules:e.formRules,data:o,doc:e.doc});bs(e.formRoot,s,{ignoreActiveValue:t}),r.seed(e.formRoot),mr(e.formRoot,e.doc,e.view?.enhanceFormRichText!==!1),pl(e),ho(e),e.updateFingerprint&&e.updateFingerprint()}function Tf({debounce:e=100,onRefresh:t}){let n=dn("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 Qm='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])';function Ef({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?cf(s,t):s},mount(s){let i=this.ctx;o=rr(()=>yf({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=to({pageRules:i.pageRules,formRules:i.formRules,data:s,doc:e});o.formRoot.appendChild(l),i.seeder.seed(o.formRoot),mr(o.formRoot,e),ho(i),Ls(i)},refresh(s){if(s==="livesync"){o?.restoreChrome?.(),kr(this.ctx,{ignoreActiveValue:!0});return}if(s==="undo"){kr(this.ctx,{ignoreActiveValue:!1});return}kr(this.ctx)},focusOnOpen(){let s=this.root&&this.root.querySelector(Qm);s&&typeof s.focus=="function"&&s.focus()},destroy(){o?.destroy(),o=null}}}var ep="[cms-template], [data-hcms-shell]";function $o(e){if(!e||typeof e.getBoundingClientRect!="function"||typeof e.closest=="function"&&e.closest(ep))return!1;let t=e.getBoundingClientRect();return t.width>=8&&t.height>=8}var tp={skip:"[data-hcms-shell]",templateAttr:"cms-template"},np={skip:"[data-hcms-shell]",templateAttr:null},rp="text",op="native",Of="handle",sp=new Set(["INPUT","TEXTAREA","SELECT"]),Cf=new Set(["IMG","INPUT","TEXTAREA","SELECT","OPTION","BR","HR","VIDEO","AUDIO","IFRAME","EMBED","OBJECT","CANVAS","SOURCE","TRACK","AREA","COL","PARAM","BUTTON"]);function Sl(e,t){return ip(e,t)}function ip(e,t){let n=[],r=[],o=er(e);return Al(o,e,t,[],n,r),{targets:n,lists:r}}function Al(e,t,n,r,o,s){if(typeof n=="string"){if(n.endsWith("[]")){let h=n.slice(0,-2);if(!h)return;let u=Hs(e,t,h);u.forEach((f,p)=>{o.push(Nf([...r,p],f,n,null))}),s.push(_f(e,t,r,h,u,!0));return}let i=sn(n),l=i===-1?null:n.slice(i+1),a=i===-1?n:n.slice(0,i),c=!a||a==="."?t:Hs(e,t,a)[0];c&&o.push(Nf(r,c,n,l));return}if(Array.isArray(n)){let[i,l]=n;if(typeof i!="string"||!i)return;let a=Hs(e,t,i);a.forEach((c,h)=>Al(e,c,l,[...r,h],o,s)),s.push(_f(e,t,r,i,a,typeof l=="string"));return}if(n&&typeof n=="object")for(let[i,l]of Object.entries(n))Al(e,t,l,[...r,i],o,s)}function _f(e,t,n,r,o,s){let i=o[0]?o[0].parentElement:null;if(!i){let l=Hs(e,t,r,np)[0];i=l?l.parentElement:null}return{path:n,items:o,container:i,scalar:s}}function Nf(e,t,n,r){return{path:e,el:t,rule:n,attr:r,kind:lp(t,r),icon:cp(t,r)}}function lp(e,t){let n=(e.tagName||"").toUpperCase();return!t||t==="innerHTML"?Cf.has(n)?Of:rp:t==="value"&&sp.has(n)&&!e.readOnly&&!ap(e)?op:Of}function ap(e){return e.disabled?!0:typeof e.matches=="function"&&e.matches(":disabled")}function cp(e,t){let n=(e.tagName||"").toUpperCase();return(!t||t==="innerHTML")&&!Cf.has(n)?null:n==="IMG"||t==="srcset"?"camera":n==="A"&&t==="href"?"paperclip":"pencil"}function Hs(e,t,n,r=tp){try{return e.find(t,n,r)}catch{return[]}}var zs=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"]})}),fp=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Cv=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function Ho(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 Tl(e,t){if(Ho(e,t))return!0;for(let[n,r]of Object.entries(fp))if(r.includes(t)&&Ho(e,n))return!0;return!1}function zo(e){let t=zs[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function up(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=zs[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>Tl(n,o))||r.bundles.some(o=>Ho(n,o)))return n;n=n.parentElement}return null}function Mf(e,t){return!!up(e,t)}var dp=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function hp(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"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),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Rf(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 If(e,t,n,r,o,s){return(s?Mf(e,t):Rf(e,n,o,!1))||!!(r&&(s&&e!==o?e.matches(r):Rf(e,r,o,s)))}function mp(e,t){let n=zs[t];return n.tokens.some(r=>Tl(e,r))||n.bundles.some(r=>Ho(e,r))}var pp=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Lf(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let o=e,s=t;if(e.nodeType===1){if(pp.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);o=e.content,s=t.content,n.cloneToLive.set(s,o),n.liveToClone.set(o,s)}}else if(e.nodeType!==11)return;let i=s.firstChild;for(let l=o.firstChild;l&&i;l=l.nextSibling)Lf(l,i,n,r),i=i.nextSibling}function El(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:o=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=s.implementation.createHTMLDocument(""),l=o||new WeakMap,a=new WeakMap,c=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let h=zo(t),u=r?m=>mp(m,t)||!!(n&&m.matches(n)):m=>If(m,t,h,n,c,!1),f=null;if(c.nodeType!==1||!If(c,t,h,n,c,r)){f=i.importNode(c,!0);let m={cloneToLive:l,liveToClone:a,dropped:[],controls:[]};Lf(c,f,m,u);for(let y of m.dropped)y.remove();for(let y=0;y<m.controls.length;y+=2)hp(m.controls[y],m.controls[y+1])}e.nodeType===9&&f&&(i.replaceChild(f,i.documentElement),a.set(e,i),l.set(i,e));let p=m=>{if(dp.test(m))throw new Error(`Filtered content queries do not support stateful selector: ${m}`)};return{root:f,document:i,capability:t,selector:zo(t),cloneToLive:l,liveToClone:a,original(m){return l.get(m)||null},cloneOf(m){return a.get(m)||null},query(m,y=f){return p(m),Array.from(y.querySelectorAll(m),g=>l.get(g)||g)},text(m=f){return(m===f?f:a.get(m))?.textContent||""},html(m=f){return(m===f?f:a.get(m))?.innerHTML??""},clone(m=f){let y=m===f?f:a.get(m);return y?i.importNode(y,!0):null}}}var gp=[16,8,0],hn=8,bp=4;function Pf({anchor:e,bar:t,rail:n=t,viewport:r,current:o=null}){let s=f=>o===f?bp: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(hn,Math.min(e.left,r.width-f-hn)),l=e.top-16-t.height;if(l>=hn-s("above"))return{mode:"above",x:i(t.width),y:l};let a=e.bottom+16;if(a+t.height<=r.height-hn+s("below"))return{mode:"below",x:i(t.width),y:a};let c=r.width-e.right-hn,h=e.left-hn,u=c>=h?[["rail-right",c],["rail-left",h]]:[["rail-left",h],["rail-right",c]];for(let[f,p]of u)for(let m of gp){if(n.width+m>p+s(f))continue;let y=f==="rail-right"?Math.min(e.right+m,r.width-n.width-hn):Math.max(e.left-m-n.width,hn),g=Math.min(e.bottom,r.height-hn)-n.height,d=Math.max(hn,Math.min(Math.max(e.top,hn),g));return{mode:f,x:y,y:d,gap:m}}return{mode:"pinned",x:i(t.width),y:hn}}function Ol({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(hn,Math.min(e.right-t.width+r,n.width-t.width-hn)),p=Math.max(hn,Math.min(e.top-r,n.height-t.height-hn));return{x:f,y:p,mode:"over"}}let i=4,l=e.right+i+t.width<=n.width-hn,a=l?e.right+i:e.left-i-t.width,c=Math.max(hn,a),h=e.top+e.height/2-t.height/2,u=Math.max(hn,Math.min(h,n.height-t.height-hn));return{x:c,y:u,mode:l?"beside-right":"beside-left"}}var Ws=!1;function jf(){if(Ws)return;let e=dn("onPrepareForSave");typeof e=="function"&&(e(t=>{Bf(t),Df(t)}),Ws=!0)}function Df(e){let t=e&&e.querySelector&&e.querySelector("body");t&&t.classList.remove("hcms-open","hcms-overlay","hcms-side-left",Fs)}function Bf(e){if(!(!e||typeof e.querySelectorAll!="function"))for(let t of e.querySelectorAll(`[${hr}]`)){let n=of(t);n!==null&&(t.innerHTML=n),t.removeAttribute(hr)}}var Ks=!1;function Gs(){if(Ks)return;let e=dn("onSnapshot");typeof e=="function"&&(e(t=>{Bf(t),lf(t,typeof window<"u"?window:null),Df(t)}),Ks=!0)}function Ff(){jf(),Gs(),(!Ws||!Ks)&&kp()}var Vs=null;function kp(){if(Vs||typeof document>"u")return;Vs=oo(document,tf,()=>{jf(),Gs(),Ws&&Ks&&(Vs?.(),Vs=null)})}var yp={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 Mr(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="${yp[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 qf="data-hcms-ghost",xp=zo("history");function vp(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 Uf({doc:e,themeRoot:t,onAdd:n,onResize:r}){let o=e.defaultView,s=[],i=!1,l=null,a=new Map;function c(p,m,y){p.style[m]!==y&&(p.style[m]=y)}function h(){let p=new Set(s.map(m=>m.node.parentElement));for(let[m,y]of a)p.has(m)&&o?.Sortable?.get(m)===y.instance||(y.instance.option("draggable")===y.selector&&y.instance.option("draggable",y.original),a.delete(m));for(let m of p){let y=o?.Sortable?.get(m);if(!y)continue;let g=y.option("draggable");if(a.get(m)?.selector===g)continue;let d=g,A=`${d.trim().startsWith(">")?"> ":""}:is(${d.trim().replace(/^>\s*/,"")}):not(${xp})`;y.option("draggable",A),a.set(m,{instance:y,original:d,selector:A})}}function u(){for(let p of s){let{node:m,slot:y,list:g}=p,d=g.items.filter(k=>k.isConnected).map(k=>k.getBoundingClientRect()).filter(k=>k.width>0&&k.height>0);d.length&&(p.width=d.reduce((k,A)=>k+A.width,0)/d.length,p.height=d.reduce((k,A)=>k+A.height,0)/d.length),c(m,"width",p.width?`${Math.round(p.width)}px`:"100%"),c(y,"height",`${Math.max(48,Math.round(p.height||64))}px`),y!==m&&(y.colSpan=Math.max(1,...g.items.map(k=>[...k.children].reduce((A,w)=>A+(w.colSpan||1),0)))),m.hidden!==i&&(m.hidden=i)}h()}function f(p,m){let y=m.tagName,g=["TBODY","THEAD","TFOOT","TABLE"].includes(y),d=e.createElement(g?"tr":["UL","OL","MENU"].includes(y)?"li":"div");for(let v of[qf,"data-hcms-shell","editor-ui","no-watch","no-save","save-remove","snapshot-remove"])d.setAttribute(v,"");d.setAttribute("draggable","false"),d.setAttribute("contenteditable","false"),d.className="hcms-shell pixel-quiet hcms-inline-ghost";for(let v of["light","dark"])d.classList.toggle(v,!!t?.classList.contains(v));let k=g?e.createElement("td"):d;k!==d&&(k.className="hcms-inline-ghost-cell",d.appendChild(k));let A=e.createElement("button");A.type="button",A.className="hcms-inline-list-button hcms-inline-list-add mirk-button mirk-button--small",A.setAttribute("data-hcms-list-action","add"),A.innerHTML=`<span class="mirk-button__label">${Mr("add")}<span>Add</span></span>`,k.appendChild(A);let w={node:d,slot:k,button:A,list:p,width:0,height:0};A.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),n(w.list)});for(let v of["pointerdown","mousedown","touchstart","click"])d.addEventListener(v,E=>E.stopPropagation());return d.addEventListener("dragstart",v=>{v.preventDefault(),v.stopPropagation()}),w}return{setLists(p){let m=new Set(s),y=[],g=new Set(s.map(k=>k.node)),d=new Set;for(let k of p||[]){if(!k.container||!k.container.isConnected)continue;let{parent:A,anchor:w}=vp(k);if(!A)continue;if(!d.has(A)){for(let N of A.querySelectorAll(`:scope > [${qf}]`))g.has(N)||N.remove();d.add(A)}let v=s.find(N=>m.has(N)&&N.list.container===k.container&&N.list.path.join(".")===k.path.join("."))||f(k,A);m.delete(v),v.list=k,v.button.setAttribute("data-hcms-list",k.path.join(".")),v.button.setAttribute("aria-label",`Add to ${k.path.join(".")||"the list"}`);let E=w||k.items.filter(N=>N.parentElement===A).at(-1);E?E.nextSibling!==v.node&&E.after(v.node):v.node.parentElement!==A&&A.appendChild(v.node),y.push(v)}for(let k of m)k.node.remove();s=y,l?.disconnect(),!l&&typeof o?.ResizeObserver=="function"&&(l=new o.ResizeObserver(()=>{u(),r?.()}));for(let k of s)for(let A of k.list.items)l?.observe(A);u()},update:u,setHidden(p){i=!!p,u()},destroy(){l?.disconnect();for(let p of s)p.node.remove();s=[],h()}}}var $f=[["move-up","Move up"],["move-down","Move down"]],wp={prefer:"corner",inset:0};function Ap(e,t){return t.width<=e.width&&t.height<=e.height}function Hf({doc:e,layerEl:t,onActivate:n,onListAction:r}){let o=e.defaultView,s=[],i=new Map,l=0,a=new Map,c=null,h=new Set,u=0,f=!1,p=null,m=null,y=null,g=null,d=new Map,k=!1,A=null,w=Uf({doc:e,themeRoot:t.closest("[data-hcms-shell]"),onResize:E,onAdd:ae=>r?.({action:"add",list:ae,index:ae.items.length})}),v=e.createElement("div");v.className="hcms-inline-highlight",v.hidden=!0,v.setAttribute("aria-hidden","true"),t.appendChild(v);function E(){if(!(u||!o)){if(typeof o.requestAnimationFrame!="function")return _();u=o.requestAnimationFrame(()=>{u=0,_()})}}let N=()=>y||g;function _(){if(!o)return;w.update();let ae={width:o.innerWidth,height:o.innerHeight},de=N();for(let Ee of s){if(!Ee.visible){Ee.node.hidden=!0;continue}for(let gt of Ee.members)gt.node.hidden=k&>.kind!=="handle";Ee.node.hidden=!1;let Ge=Ee.el.getBoundingClientRect(),Ve=Ee.node.getBoundingClientRect(),ze=Ve.width,lt=Ee.kind==="row"&&!Ap(Ge,Ve);if(lt&&Ee.el!==de){for(let gt of Ee.members)gt.kind==="row"&&(gt.node.hidden=!0);Ve=Ee.node.getBoundingClientRect()}if(Ee.members.every(gt=>gt.node.hidden)){Ee.node.hidden=!0;continue}let pt=Ee.kind==="handle"?null:wp,{x:Rt,y:dt}=Ol({anchor:Ge,handle:Ve,viewport:ae,...pt}),vt=Ee.members.find(gt=>gt.kind==="handle");if(lt&&vt){let gt=vt.node.getBoundingClientRect(),yn=Ol({anchor:Ge,handle:gt,viewport:ae}),Bt=Ee.members.slice(Ee.members.indexOf(vt)+1).filter(Qt=>!Qt.node.hidden).reduce((Qt,Yt)=>Qt+Yt.node.getBoundingClientRect().width+2,0);Rt=Math.max(8+ze,Math.min(ae.width-8,yn.x+gt.width+Bt))-Ve.width,dt=yn.y}Ee.node.style.transform=`translate(${Math.round(Rt)}px, ${Math.round(dt)}px)`}if(A)if(!A.node.isConnected||A.node.closest("[hidden]"))Ue();else{let Ee=A.button.getBoundingClientRect(),Ge=A.menu.getBoundingClientRect();A.menu.style.left=`${Math.max(8,Ee.right-Ge.width)-Ee.left}px`,A.menu.style.right="auto",A.menu.style.top=Ee.bottom+6+Ge.height>ae.height-8?"auto":"calc(100% + 6px)",A.menu.style.bottom=Ee.bottom+6+Ge.height>ae.height-8?"calc(100% + 6px)":"auto"}D(),p?.()}function M(ae){if(ae?.closest?.("[data-hcms-ghost]"))return null;for(let de=ae;de&&de.nodeType===1;de=de.parentElement){let Ee=d.get(de);if(Ee)return Ee}return null}function j(ae){A&&!A.node.contains(ae.target)&&Ue();let de=N();g=M(ae.target),g&&t.contains(ae.target)&&(y=null),N()!==de&&E()}function R(ae){if(ae.relatedTarget||!g)return;let de=N();g=null,N()!==de&&E()}function D(){if(!m||v.hidden)return;let ae=m.getBoundingClientRect();v.style.width=`${Math.round(ae.width)}px`,v.style.height=`${Math.round(ae.height)}px`,v.style.transform=`translate(${Math.round(ae.left)}px, ${Math.round(ae.top)}px)`}function F(){if(!o||typeof o.IntersectionObserver!="function"){for(let de of s)de.visible=!0;return}c||(c=new o.IntersectionObserver(de=>{let Ee=!1;for(let Ge of de)for(let Ve of i.get(Ge.target)||[])Ve.visible!==Ge.isIntersecting&&(Ve.visible=Ge.isIntersecting,Ee=!0);Ee&&E()},{threshold:0}));let ae=new Set(i.keys());for(let de of h)ae.has(de)||c.unobserve(de);for(let de of ae)h.has(de)||c.observe(de);h=ae}function S(){f||!o||(o.addEventListener("scroll",E,{passive:!0,capture:!0}),o.addEventListener("resize",E,{passive:!0}),e.addEventListener("focusin",j),e.addEventListener("focusout",R),e.addEventListener("pointerdown",Ne,!0),e.addEventListener("keydown",O,!0),f=!0)}function T(){!f||!o||(o.removeEventListener("scroll",E,{capture:!0}),o.removeEventListener("resize",E),e.removeEventListener("focusin",j),e.removeEventListener("focusout",R),e.removeEventListener("pointerdown",Ne,!0),e.removeEventListener("keydown",O,!0),f=!1)}function J(ae){return`${ae.kind}\0${ae.attr||""}`}function q(ae,de){return ae.container===de.container&&ae.scalar===de.scalar}function V(ae,de){return ae.kind!==de.kind?!1:ae.kind==="handle"?J(ae.target)===J(de.target):ae.kind==="row"?ae.row===de.row&&q(ae.list,de.list):q(ae.list,de.list)}function Ce(ae,de){ae.target=de;let Ee=de.path.join(".");ae.node.setAttribute("data-hcms-target",Ee),de.icon?ae.node.setAttribute("data-hcms-icon",de.icon):ae.node.removeAttribute("data-hcms-icon"),ae.node.setAttribute("aria-label",`Edit ${Ee}`)}function Me(ae){let de=e.createElement("button");de.type="button",de.className="hcms-inline-handle mirk-button mirk-button--small",de.innerHTML=`<span class="mirk-button__label">${Mr("edit")}</span>`;let Ee={node:de,kind:"handle",target:ae};return Ce(Ee,ae),de.addEventListener("click",Ge=>{Ge.preventDefault(),Ge.stopPropagation(),n?.(Ee.target,de)}),Ee}function Be(ae,de){let Ee=e.createElement("button");return Ee.type="button",Ee.className="hcms-inline-list-button mirk-button mirk-button--small",Ee.setAttribute("data-hcms-list-action",ae),Ee.setAttribute("aria-label",de),Ee.innerHTML=`<span class="mirk-button__label">${Mr(ae)}${ae==="add"?"<span>Add</span>":""}</span>`,Ee}function ce(ae,{list:de,row:Ee,rowIndex:Ge,count:Ve}){let ze=de.path.join(".");ae.list=de,ae.row=Ee,ae.index=Ge,ae.count=Ve,ae.node.setAttribute("data-hcms-list",ze),ae.node.setAttribute("data-hcms-row",String(Ge));for(let lt of ae.node.querySelectorAll("[data-hcms-list-action]")){let pt=lt.getAttribute("data-hcms-list-action"),Rt=$f.find(([dt])=>dt===pt)?.[1]||pt;lt.setAttribute("aria-label",`${Rt} ${ze}.${Ge}`),lt.disabled=pt==="move-up"&&Ge===0||pt==="move-down"&&Ge===Ve-1}}function Ae(ae,de,Ee,Ge){let Ve=e.createElement("div");Ve.className="hcms-inline-row-controls";let ze={node:Ve,kind:"row",list:ae,row:de,index:Ee,count:Ge};for(let[lt,pt]of $f){let Rt=Be(lt,pt);Rt.addEventListener("click",dt=>{dt.preventDefault(),dt.stopPropagation(),!Rt.disabled&&r?.({action:lt,list:ze.list,index:ze.index,row:ze.row})}),Ve.appendChild(Rt)}return ce(ze,{list:ae,row:de,rowIndex:Ee,count:Ge}),ze}function Ue(ae=!1){if(!A)return;let de=A;A=null,de.menu.hidden=!0,de.button.setAttribute("aria-expanded","false"),de.node.parentElement?.classList.remove("has-open-settings"),ae&&de.button.isConnected&&de.button.focus({preventScroll:!0})}function Ne(ae){A&&!A.node.contains(ae.target)&&Ue()}function O(ae){A&&(ae.key==="Escape"?(ae.preventDefault(),ae.stopPropagation(),Ue(!0)):ae.key==="Tab"?Ue(!0):["ArrowDown","ArrowUp","Home","End"].includes(ae.key)&&A.menu.contains(ae.target)&&(ae.preventDefault(),A.menu.querySelector('[role="menuitem"]').focus({preventScroll:!0})))}function X(ae,{list:de,row:Ee,rowIndex:Ge}){Object.assign(ae,{list:de,row:Ee,index:Ge}),ae.node.setAttribute("data-hcms-list",de.path.join(".")),ae.node.setAttribute("data-hcms-row",String(Ge)),ae.button.setAttribute("aria-label",`Settings ${de.path.join(".")}.${Ge}`)}function le(ae){let de=e.createElement("div");de.className="hcms-inline-settings";let Ee=Be("settings","Settings");Ee.setAttribute("aria-haspopup","menu"),Ee.setAttribute("aria-expanded","false");let Ge=e.createElement("div");Ge.className="hcms-inline-settings-menu",Ge.setAttribute("role","menu"),Ge.setAttribute("aria-label","Item settings"),Ge.hidden=!0;let Ve=e.createElement("button");Ve.type="button",Ve.setAttribute("role","menuitem"),Ve.setAttribute("data-hcms-list-action","remove"),Ve.textContent="Delete",Ge.appendChild(Ve),de.append(Ee,Ge);let ze={node:de,button:Ee,menu:Ge,kind:"settings"};X(ze,ae);let lt=()=>{Ue(),A=ze,Ge.hidden=!1,Ee.setAttribute("aria-expanded","true"),de.parentElement.classList.add("has-open-settings"),Ve.focus({preventScroll:!0}),E()};return Ee.addEventListener("click",pt=>{pt.preventDefault(),pt.stopPropagation(),A===ze?Ue(!0):lt()}),Ee.addEventListener("keydown",pt=>{(pt.key==="ArrowDown"||pt.key==="ArrowUp")&&(pt.preventDefault(),lt())}),Ve.addEventListener("click",pt=>{pt.preventDefault(),pt.stopPropagation(),Ue(!0),r?.({action:"remove",list:ze.list,index:ze.index,row:ze.row})}),ze}function re(ae,de){ae.kind==="handle"?Ce(ae,de.target):ae.kind==="row"?ce(ae,de):ae.kind==="settings"&&X(ae,de)}function Pe(ae,de,Ee,Ge,Ve){let ze=de.get(Ee)?.find(lt=>lt.category===Ve);if(!ze){ze={el:Ee,category:Ve,members:[]},ae.push(ze);let lt=de.get(Ee);lt?lt.push(ze):de.set(Ee,[ze])}ze.members.push(Ge)}function Fe(ae,de,Ee){let Ge=Ee.items||[];Ge.forEach((Ve,ze)=>{$o(Ve)&&(Pe(ae,de,Ve,{kind:"row",list:Ee,row:Ve,rowIndex:ze,count:Ge.length},"item"),Pe(ae,de,Ve,{kind:"settings",list:Ee,row:Ve,rowIndex:ze},"item"))})}function Te(ae,de){let Ee=new Set(ae.members),Ge=[];for(let Ve of de){let ze=ae.members.find(lt=>Ee.has(lt)&&V(lt,Ve))||(Ve.kind==="handle"?Me(Ve.target):Ve.kind==="row"?Ae(Ve.list,Ve.row,Ve.rowIndex,Ve.count):le(Ve));Ee.delete(ze),re(ze,Ve),k&&ze.kind!=="handle"&&(ze.node.hidden=!0),Ge.push(ze)}for(let Ve of Ee)Ve===A&&Ue(),Ve.node.remove();Ge.sort((Ve,ze)=>["row","handle","settings"].indexOf(Ve.kind)-["row","handle","settings"].indexOf(ze.kind)),Ge.forEach((Ve,ze)=>{ae.node.children[ze]!==Ve.node&&ae.node.insertBefore(Ve.node,ae.node.children[ze]||null)}),ae.members=Ge}function ot(ae,de){let Ee=[],Ge=new Map,Ve=new Map,ze=0;for(let dt of ae||[])Ve.has(dt.el)||Ve.set(dt.el,dt),!(dt.kind!=="handle"||!$o(dt.el))&&(Pe(Ee,Ge,dt.el,{kind:"handle",target:dt},"item"),ze++);for(let dt of de||[])Fe(Ee,Ge,dt);let lt=new Set(s),pt=new Map;for(let dt of s)pt.has(dt.el)||pt.set(dt.el,dt.visible);let Rt=[];for(let dt of Ee){let vt=s.find(gt=>lt.has(gt)&>.el===dt.el&>.category===dt.category);if(!vt){let gt=e.createElement("div");gt.className="hcms-inline-item-controls",gt.setAttribute("role","group"),vt={el:dt.el,node:gt,category:dt.category,kind:dt.category==="add"?"add":"handle",members:[],visible:pt.get(dt.el)??!1},t.appendChild(gt)}lt.delete(vt),vt.el=dt.el,vt.category=dt.category,Te(vt,dt.members),vt.kind=vt.members.some(gt=>gt.kind==="row")?"row":vt.members.some(gt=>gt.kind==="handle")?"handle":"add",vt.node.setAttribute("aria-label",vt.category==="add"?"List controls":"Item controls"),Rt.push(vt)}for(let dt of lt)dt.node.remove();s=Rt,i=new Map,d=new Map;for(let dt of s){let vt=i.get(dt.el);vt?vt.push(dt):i.set(dt.el,[dt]);for(let gt of dt.members)gt.kind!=="row"&>.kind!=="settings"||(d.set(gt.row,gt.row),d.set(gt.node,gt.row),d.set(dt.node,gt.row))}y&&!d.has(y)&&(y=null),g&&!d.has(g)&&(g=null),a=Ve,l=ze}function et(){Ue(),c?.disconnect(),c=null,h=new Set;for(let ae of s)ae.node.remove();s=[],i=new Map,a=new Map,d=new Map,l=0}return{setTargets(ae,de){ot(ae,de),w.setLists(de),F(),S(),E()},refresh:E,get count(){return l},get controlsHidden(){return k},setControlsHidden(ae){if(k=!!ae,w.setHidden(k),k){Ue();for(let de of s){for(let Ee of de.members)Ee.kind!=="handle"&&(Ee.node.hidden=!0);de.members.every(Ee=>Ee.node.hidden)&&(de.node.hidden=!0)}}E()},elementToTarget(ae){if(ae?.closest?.("[data-hcms-ghost]"))return null;for(let de=ae;de&&de.nodeType===1;de=de.parentElement){let Ee=a.get(de);if(Ee)return Ee}return null},setHoveredRow(ae){let de=N();y=ae?M(ae):null,N()!==de&&E()},showHighlight(ae){ae&&(m=ae,v.hidden=!1,D())},hideHighlight(){m=null,v.hidden=!0},setFollower(ae){p=typeof ae=="function"?ae:null},destroy(){w.destroy(),u&&o&&o.cancelAnimationFrame(u),u=0,p=null,m=null,y=null,g=null,v.remove(),T(),et()}}}var Sp="hypercms-inline",Ko="is-hcms-inline-active",_l="is-hcms-inline-onpath",zf='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])',Tp=["bold","italic","link","undo","redo"],Ep=/^H[1-6]$/,Op=0;function Kf({doc:e,pageRoot:t,opts:n={}}){let r=n.richText!==!1,o=null,s=null,i=null,l=new Map,a=null,c=null,h=null;function u(f,p,m,y,g){let d=so(e.defaultView);if(typeof d!="function")return null;let k=g||{},A=k.originalHTML??El(p,{capability:"history"}).html(),w=k.richClayIsOurs??!p.hasAttribute("data-richclay"),v=k.adopted??p.getAttribute("data-richclay-active")==="true",E=Vo(p,y,"history"),N=_p(f,d,p,y,w);if(!N)return null;sf(p,y==="innerHTML",w);let _=String(++Op);p.setAttribute(hr,_),Gs();let M={el:p,editor:N,path:m,prop:y,boundId:_,originalHTML:A,oldValue:E,richClayIsOurs:w,adopted:v,dirty:!1,written:!1,restorable(){return!this.adopted&&!this.dirty&&!this.written},lastEdited:void 0};l.set(p,M),nf(_,M);let j=N.squire;if(j&&typeof j.addEventListener=="function"){let D=()=>{M.dirty=!0,M.lastEdited=Vo(p,M.prop,"history"),Np(f,M)};j.addEventListener("input",D),M.detachInput=()=>j.removeEventListener?.("input",D)}let R=()=>Gf(M);return p.addEventListener("blur",R),M.detachBlur=()=>p.removeEventListener("blur",R),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?ff(f,t):f},bindText(f,p,m,y){return u(this.ctx,f,p,m,y)},mount(f){let p=this.ctx;o=Lp(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,rr(()=>Uo(e));let m=to({pageRules:p.pageRules,formRules:p.formRules,data:f,doc:e});o.formRoot.appendChild(m),p.seeder.seed(o.formRoot),mr(o.formRoot,e,this.enhanceFormRichText),ho(p),Ls(p),s=Hf({doc:e,layerEl:o.layerEl,onActivate:(y,g)=>this.activate(y,g),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(),p.onViewRequested?.("sidebar")}),this.bindPage(),this.syncTargets()},listAction({action:f,list:p,index:m,row:y}){let g=this.ctx,d=p.path.join("."),k=g.formRoot.querySelector(`[data-hcms-path="${co(d)}"]`);if(!k)return;if(f==="add"){Fo(d,g);return}let A=y?jp(g,d,y):m;if(A===-1)return;let w=Pp(k,A);if(w){if(f==="remove"){ml(w,g),this.syncTargets();return}hl(w,f==="move-up"?-1:1,g),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,m=w=>{let v=s&&s.elementToTarget(w.target);v?s.showHighlight(v.el):s?.hideHighlight(),s?.setHoveredRow(w.target)},y=()=>{s?.hideHighlight(),s?.setHoveredRow(null)},g=w=>{if(p.contains(w.target))return;let v=s&&s.elementToTarget(w.target);!v||v.kind!=="text"||l.has(v.el)||u(this.ctx,v.el,v.path.join("."),Xs(v))},d=w=>{if(p.contains(w.target))return;let v=s&&s.elementToTarget(w.target);if(!v){this.deactivate();return}(typeof w.target.closest=="function"&&w.target.closest("a[href]")||v.kind!=="text")&&w.preventDefault(),this.activate(v)},k=w=>{w.key==="Escape"&&this.deactivate()},A=w=>{let v=w.detail;if(!(!v||v.pageRoot!==this.ctx.pageRoot||!v.path))for(let E of l.values())E.path===v.path&&(E.written=!0)};f.addEventListener("pointerover",m),f.addEventListener("pointerleave",y),f.addEventListener("pointerdown",g),f.addEventListener("click",d),p.addEventListener("keydown",k),e.addEventListener("hcms:change",A),i=()=>{f.removeEventListener("pointerover",m),f.removeEventListener("pointerleave",y),f.removeEventListener("pointerdown",g),f.removeEventListener("click",d),p.removeEventListener("keydown",k),e.removeEventListener("hcms:change",A)}},activate(f,p){if(!f||!o||f.kind==="text"&&this.activateText(f))return;let m=Vf(this,o,f.path.join("."));if(!m){this.deactivate();return}a=f,c=p||null,h=null,o.popEl.hidden=!1,o.formRoot.querySelectorAll(`.${Ko}`).forEach(Wf),this.placePopover(),Ip(m)},activateText(f){let p=f.el,m=l.get(p);if(m)return Ys(m),!0;let y=u(this.ctx,p,f.path.join("."),Xs(f));return y?(Ys(y),!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},m=a.el.getBoundingClientRect(),y=o.popEl.getBoundingClientRect(),{mode:g,x:d,y:k}=Pf({anchor:m,bar:y,viewport:p,current:h});h=g,o.popEl.style.transform=`translate(${Math.round(d)}px, ${Math.round(k)}px)`},deactivate(){if(!o||!a&&o.popEl.hidden)return;o.popEl.hidden=!0,Xf(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:p,lists:m}=Sl(f.pageRoot,f.pageRules);s.setTargets(p,m);let y=Cp(this,l,p,e);if(a){let d=y.get(a.el)||[],k=d.find(A=>Mp(A,a))||d.find(A=>A.path.join(".")===a.path.join("."))||(d.length===1?d[0]:null);k?a=k:this.deactivate()}Rp(this.ctx,l,e);let g=p.reduce((d,k)=>d+($o(k.el)?0:1),0);this.handoffEl&&(this.handoffCountEl.textContent=g===0?"":`${g} ${g===1?"field isn't":"fields aren't"} visible right now.`,this.handoffEl.hidden=g===0)},refresh(f,p){f==="livesync"?(br(e),Uo(e),kr(this.ctx,{ignoreActiveValue:!0})):f==="undo"?kr(this.ctx,{ignoreActiveValue:!1}):kr(this.ctx),this.syncTargets(),(f==="livesync"||f==="undo")&&this.rebindText(f),this.restoreActive()},rebindText(f){let p=f!=="undo";for(let[m,y]of[...l]){if(!e.contains(m)){Wo(this.ctx,y,{restore:!1,record:p}),l.delete(m);continue}if(m.hasAttribute($n)){let k=Vo(m,y.prop);k!==y.lastEdited&&(y.oldValue=k,y.lastEdited=void 0);continue}let g=e.activeElement===m;Wo(this.ctx,y,{restore:!1,record:p}),l.delete(m);let d=u(this.ctx,m,y.path,y.prop,{richClayIsOurs:y.richClayIsOurs,adopted:y.adopted});d&&g&&Ys(d)}},restoreActive(){if(!o||!a||o.popEl.hidden)return;if(!e.contains(a.el)){this.deactivate();return}if(!Vf(this,o,a.path.join("."))){this.deactivate();return}o.formRoot.querySelectorAll(`.${Ko}`).forEach(Wf),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 l.values())Wo(this.ctx,f);l.clear(),i?.(),i=null,s?.destroy(),s=null,o?.destroy(),o=null,yl(e),this.popEl=null,this.handoffEl=null,this.handoffCountEl=null}}}function _p(e,t,n,r,o){return rr(()=>{let s=null;try{s=new t(n,{inline:!0,hyperclay:!1,toolbar:r==="innerHTML"?Tp:!1,...Ep.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 Np(e,{path:t,el:n,prop:r}){let o=Ps(e.formRoot,t);o&&(js(o,Vo(n,r),e.formRoot,t),Mn(Tn(e),{path:t,structural:!1},e))}function Vo(e,t,n="data"){let r=El(e,{capability:n});return t==="innerHTML"?r.html():r.text().trim()}function Gf(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=dn("undo");if(!i||typeof i.recordValue!="function")return;let l={prop:n,oldValue:r,newValue:s,read:a=>Vo(a,n,"history"),write:(a,c)=>Yf(a,n,c)};i.isPaused?queueMicrotask(()=>{t.isConnected&&i.recordValue(t,l)}):i.recordValue(t,l)}function Yf(e,t,n){let r=e.cloneNode(!1);t==="innerHTML"?r.innerHTML=n:r.textContent=n,ur(e,Array.from(r.childNodes),{morphStyle:"innerHTML",policy:"history",restoreFocus:!1,scripts:{handle:!1,merge:!1}})}function Wo(e,t,{restore:n=!0,record:r=!0}={}){r&&Gf(t),t.detachInput?.(),t.detachBlur?.(),rr(()=>{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($n),t.el.removeAttribute(Nr),t.el.removeAttribute(hr),rf(t.boundId),n&&t.restorable()&&Yf(t.el,"innerHTML",t.originalHTML)})}function Ys(e){let{editor:t,el:n}=e;if(n.ownerDocument.activeElement!==n)try{typeof t.focus=="function"?t.focus():n.focus()}catch{}}function Cp(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=>Xs(f)===i.prop)||l[0];if(!a){Wo(e.ctx,i,{restore:!0}),t.delete(s);continue}i.path=a.path.join(".");let c=Xs(a);if(c===i.prop)continue;let h=r.activeElement===s;Wo(e.ctx,i,{restore:!1}),t.delete(s);let u=e.bindText(s,i.path,c,{richClayIsOurs:i.richClayIsOurs,adopted:i.adopted,originalHTML:i.originalHTML});u&&h&&Ys(u)}return o}function Mp(e,t){return e.el===t.el&&e.kind===t.kind&&e.attr===t.attr}function Xs(e){return e.attr==="innerHTML"?"innerHTML":"textContent"}function Rp(e,t,n){for(let r of e.pageRoot.querySelectorAll(`[${$n}]`))t.has(r)||rr(()=>af(r,n.defaultView))}function Vf(e,t,n){let r=e.formRoot&&e.formRoot.querySelector(`[data-hcms-path="${co(n)}"]`);if(Xf(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(Ko),i.removeAttribute("draggable");for(let l=i.parentElement;l&&(l.classList.add(_l),l.removeAttribute("draggable"),l!==e.formRoot);l=l.parentElement);}return r}function Xf(e){if(e)for(let t of e.querySelectorAll(`.${Ko}, .${_l}`))t.classList.remove(Ko,_l)}function Wf(e){e.tagName==="TEXTAREA"&&io(e),e.querySelectorAll?.("textarea").forEach(io)}function Ip(e){let t=e.matches?.(zf)?e:e.querySelector?.(zf);if(!(!t||typeof t.focus!="function"))try{t.focus({preventScroll:!0})}catch{t.focus()}}function Lp(e,t){br(e);let n=e.createElement(Sp),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
|
+
`,(e||l.body).appendChild(c);let m=l.body;m.classList.add("hcms-open"),Ho(l),n&&m.classList.add("hcms-overlay"),t==="left"&&m.classList.add("hcms-side-left");let k=sp(c,l),g=op(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(){k.detach(),g.detach(),c.remove(),m.classList.remove("hcms-open","hcms-overlay","hcms-side-left"),Al(l)},restoreChrome(){yr(l),m.classList.add("hcms-open"),Ho(l),n&&m.classList.add("hcms-overlay"),t==="left"&&m.classList.add("hcms-side-left")}}}function yr(e){e&&(e.getElementById(qs)||e.querySelector("style[data-hcms-bundled-styles]")||(uo.delete(e),Cf(e)))}function Cf(e){if(e&&!uo.has(e)){if(e[tp]){uo.add(e);return}if(e.getElementById(qs)||e.querySelector("style[data-hcms-bundled-styles]")){uo.add(e);return}if(wl){let t=e.createElement("style");t.id=qs,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=wl,(e.head||e.documentElement).appendChild(t),uo.add(e);return}try{let t=new URL("./theme.generated.css",ip.url).href,n=e.createElement("link");n.rel="stylesheet",n.id=qs,n.setAttribute("save-remove",""),n.setAttribute("save-ignore",""),n.href=t,(e.head||e.documentElement).appendChild(n),uo.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 op(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 sp(e,t){function n(r){if(r.key!=="Tab"||!e.contains(t.activeElement))return;let o=Array.from(e.querySelectorAll(np));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 lp="[hypercms]",Mf={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Rf={skip:"[data-hcms-shell]",templateAttr:null},Sl=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 Hs(e,t){let n=[],r=[],o=[];return El(er(e),e,t,[],n,r,o),{missing:If(n),twins:dp(r),readOnly:If(o)}}function zs(e){return Tl(e)}function Tl(e){if(typeof e=="string")return Lf(e)?void 0:e;if(Array.isArray(e)){let[t,n]=e;return[t,Tl(n)]}if(e&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e)){let o=Tl(r);o!==void 0&&(t[n]=o)}return t}return e}function El(e,t,n,r,o,s,i){if(typeof n=="string"){let l=ap(n),a=l?$s(e,t,l,Mf,r):[];if(Lf(n)){i.push(ho(r));return}if(!l)return;if(n.endsWith("[]")){a.length===0&&$s(e,t,l,Rf,r).length===0&&o.push(ho(r));return}a.length===0?o.push(ho(r)):a.length>1&&s.push({path:ho(r),count:a.length});return}if(Array.isArray(n)){let[l,a]=n;if(typeof l!="string"||!l)return;let c=$s(e,t,l,Mf,r);if(c.length===0){$s(e,t,l,Rf,r).length===0&&o.push(ho(r));return}for(let d of c)El(e,d,a,[...r,"*"],o,s,i);return}if(n&&typeof n=="object")for(let[l,a]of Object.entries(n))El(e,t,a,[...r,l],o,s,i)}function $s(e,t,n,r,o){try{return e.find(t,n,r)}catch(s){throw new Sl(ho(o),n,s)}}function ap(e){if(e==="."||e.startsWith("@"))return null;if(e.endsWith("[]"))return e.slice(0,-2)||null;let t=nn(e);return(t===-1?e:e.slice(0,t))||null}function cp(e){if(e.endsWith("[]"))return null;let t=nn(e);return t===-1?null:e.slice(t+1)||null}function Lf(e){let t=cp(e);return t!=null&&Pr.has(t)}function mo(e){fp(e),up(e)}function fp(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(`
|
|
183
|
+
`),t.hidden=!1}function up(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(`${lp} "${r}" matches ${o} elements; edits go to the first one.`)}}function If(e){return[...new Set(e)]}function dp(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 ho(e){return e.length?e.join("."):"(whole page)"}var hp={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function kr(e,{ignoreActiveValue:t}={}){return mp(e,{ignoreActiveValue:t})}function mp(e,{ignoreActiveValue:t}){let n=wn.findRules(e.doc,e.rulesSource||"cms");n&&(e.pageRules=e.view.prepareRules(n.rules),e.rulesTagNode=n.tagNode),As(e.doc),Ns(e.doc,e.pageRules),e.formRules=Cs(e.pageRules,e.doc),e.writeRules=zs(e.pageRules),e.unresolved=Hs(e.pageRoot,e.pageRules);let r=xs(),o=br(wn.extract(e.pageRoot,e.pageRules,{...hp,...r.hooks}),e.pageRules),s=no({pageRules:e.pageRules,formRules:e.formRules,data:o,doc:e.doc});ks(e.formRoot,s,{ignoreActiveValue:t}),r.seed(e.formRoot),pr(e.formRoot,e.doc,e.view?.enhanceFormRichText!==!1),kl(e),mo(e),e.updateFingerprint&&e.updateFingerprint()}function Pf({debounce:e=100,onRefresh:t}){let n=dn("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 pp='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])';function jf({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?kf(s,t):s},mount(s){let i=this.ctx;o=rr(()=>_f({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=no({pageRules:i.pageRules,formRules:i.formRules,data:s,doc:e});o.formRoot.appendChild(l),i.seeder.seed(o.formRoot),pr(o.formRoot,e),mo(i),js(i)},refresh(s){if(s==="livesync"){o?.restoreChrome?.(),kr(this.ctx,{ignoreActiveValue:!0});return}if(s==="undo"){kr(this.ctx,{ignoreActiveValue:!1});return}kr(this.ctx)},focusOnOpen(){let s=this.root&&this.root.querySelector(pp);s&&typeof s.focus=="function"&&s.focus()},destroy(){o?.destroy(),o=null}}}var gp="[cms-template], [data-hcms-shell]";function zo(e){if(!e||typeof e.getBoundingClientRect!="function"||typeof e.closest=="function"&&e.closest(gp))return!1;let t=e.getBoundingClientRect();return t.width>=8&&t.height>=8}var bp={skip:"[data-hcms-shell]",templateAttr:"cms-template"},yp={skip:"[data-hcms-shell]",templateAttr:null},kp="text",xp="native",Df="handle",vp=new Set(["INPUT","TEXTAREA","SELECT"]),qf=new Set(["IMG","INPUT","TEXTAREA","SELECT","OPTION","BR","HR","VIDEO","AUDIO","IFRAME","EMBED","OBJECT","CANVAS","SOURCE","TRACK","AREA","COL","PARAM","BUTTON"]);function Nl(e,t){return wp(e,t)}function wp(e,t){let n=[],r=[],o=er(e);return Ol(o,e,t,[],n,r),{targets:n,lists:r}}function Ol(e,t,n,r,o,s){if(typeof n=="string"){if(n.endsWith("[]")){let d=n.slice(0,-2);if(!d)return;let u=Vs(e,t,d);u.forEach((f,p)=>{o.push(Bf([...r,p],f,n,null))}),s.push(Ff(e,t,r,d,u,!0));return}let i=nn(n),l=i===-1?null:n.slice(i+1),a=i===-1?n:n.slice(0,i),c=!a||a==="."?t:Vs(e,t,a)[0];c&&o.push(Bf(r,c,n,l));return}if(Array.isArray(n)){let[i,l]=n;if(typeof i!="string"||!i)return;let a=Vs(e,t,i);a.forEach((c,d)=>Ol(e,c,l,[...r,d],o,s)),s.push(Ff(e,t,r,i,a,typeof l=="string"));return}if(n&&typeof n=="object")for(let[i,l]of Object.entries(n))Ol(e,t,l,[...r,i],o,s)}function Ff(e,t,n,r,o,s){let i=o[0]?o[0].parentElement:null;if(!i){let l=Vs(e,t,r,yp)[0];i=l?l.parentElement:null}return{path:n,items:o,container:i,scalar:s}}function Bf(e,t,n,r){return{path:e,el:t,rule:n,attr:r,kind:Ap(t,r),icon:Tp(t,r)}}function Ap(e,t){let n=(e.tagName||"").toUpperCase();return!t||t==="innerHTML"?qf.has(n)?Df:kp:t==="value"&&vp.has(n)&&!e.readOnly&&!Sp(e)?xp:Df}function Sp(e){return e.disabled?!0:typeof e.matches=="function"&&e.matches(":disabled")}function Tp(e,t){let n=(e.tagName||"").toUpperCase();return(!t||t==="innerHTML")&&!qf.has(n)?null:n==="IMG"||t==="srcset"?"camera":n==="A"&&t==="href"?"paperclip":"pencil"}function Vs(e,t,n,r=bp){try{return e.find(t,n,r)}catch{return[]}}var Ws=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"]})}),Ep=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),tw=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function Vo(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 _l(e,t){if(Vo(e,t))return!0;for(let[n,r]of Object.entries(Ep))if(r.includes(t)&&Vo(e,n))return!0;return!1}function Wo(e){let t=Ws[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Op(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=Ws[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>_l(n,o))||r.bundles.some(o=>Vo(n,o)))return n;n=n.parentElement}return null}function Uf(e,t){return!!Op(e,t)}var Np=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function _p(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"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),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function $f(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){return(s?Uf(e,t):$f(e,n,o,!1))||!!(r&&(s&&e!==o?e.matches(r):$f(e,r,o,s)))}function Cp(e,t){let n=Ws[t];return n.tokens.some(r=>_l(e,r))||n.bundles.some(r=>Vo(e,r))}var Mp=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function zf(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let o=e,s=t;if(e.nodeType===1){if(Mp.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);o=e.content,s=t.content,n.cloneToLive.set(s,o),n.liveToClone.set(o,s)}}else if(e.nodeType!==11)return;let i=s.firstChild;for(let l=o.firstChild;l&&i;l=l.nextSibling)zf(l,i,n,r),i=i.nextSibling}function Cl(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:o=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=s.implementation.createHTMLDocument(""),l=o||new WeakMap,a=new WeakMap,c=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let d=Wo(t),u=r?m=>Cp(m,t)||!!(n&&m.matches(n)):m=>Hf(m,t,d,n,c,!1),f=null;if(c.nodeType!==1||!Hf(c,t,d,n,c,r)){f=i.importNode(c,!0);let m={cloneToLive:l,liveToClone:a,dropped:[],controls:[]};zf(c,f,m,u);for(let k of m.dropped)k.remove();for(let k=0;k<m.controls.length;k+=2)_p(m.controls[k],m.controls[k+1])}e.nodeType===9&&f&&(i.replaceChild(f,i.documentElement),a.set(e,i),l.set(i,e));let p=m=>{if(Np.test(m))throw new Error(`Filtered content queries do not support stateful selector: ${m}`)};return{root:f,document:i,capability:t,selector:Wo(t),cloneToLive:l,liveToClone:a,original(m){return l.get(m)||null},cloneOf(m){return a.get(m)||null},query(m,k=f){return p(m),Array.from(k.querySelectorAll(m),g=>l.get(g)||g)},text(m=f){return(m===f?f:a.get(m))?.textContent||""},html(m=f){return(m===f?f:a.get(m))?.innerHTML??""},clone(m=f){let k=m===f?f:a.get(m);return k?i.importNode(k,!0):null}}}var Rp=[16,8,0],hn=8,Ip=4;function Vf({anchor:e,bar:t,rail:n=t,viewport:r,current:o=null}){let s=f=>o===f?Ip: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(hn,Math.min(e.left,r.width-f-hn)),l=e.top-16-t.height;if(l>=hn-s("above"))return{mode:"above",x:i(t.width),y:l};let a=e.bottom+16;if(a+t.height<=r.height-hn+s("below"))return{mode:"below",x:i(t.width),y:a};let c=r.width-e.right-hn,d=e.left-hn,u=c>=d?[["rail-right",c],["rail-left",d]]:[["rail-left",d],["rail-right",c]];for(let[f,p]of u)for(let m of Rp){if(n.width+m>p+s(f))continue;let k=f==="rail-right"?Math.min(e.right+m,r.width-n.width-hn):Math.max(e.left-m-n.width,hn),g=Math.min(e.bottom,r.height-hn)-n.height,h=Math.max(hn,Math.min(Math.max(e.top,hn),g));return{mode:f,x:k,y:h,gap:m}}return{mode:"pinned",x:i(t.width),y:hn}}function Ml({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(hn,Math.min(e.right-t.width+r,n.width-t.width-hn)),p=Math.max(hn,Math.min(e.top-r,n.height-t.height-hn));return{x:f,y:p,mode:"over"}}let i=4,l=e.right+i+t.width<=n.width-hn,a=l?e.right+i:e.left-i-t.width,c=Math.max(hn,a),d=e.top+e.height/2-t.height/2,u=Math.max(hn,Math.min(d,n.height-t.height-hn));return{x:c,y:u,mode:l?"beside-right":"beside-left"}}var Gs=!1;function Wf(){if(Gs)return;let e=dn("onPrepareForSave");typeof e=="function"&&(e(t=>{Gf(t),Kf(t)}),Gs=!0)}function Kf(e){let t=e&&e.querySelector&&e.querySelector("body");t&&t.classList.remove("hcms-open","hcms-overlay","hcms-side-left",Us)}function Gf(e){if(!(!e||typeof e.querySelectorAll!="function"))for(let t of e.querySelectorAll(`[${mr}]`)){let n=pf(t);n!==null&&(t.innerHTML=n),t.removeAttribute(mr)}}var Ys=!1;function Xs(){if(Ys)return;let e=dn("onSnapshot");typeof e=="function"&&(e(t=>{Gf(t),bf(t,typeof window<"u"?window:null),Kf(t)}),Ys=!0)}function Yf(){Wf(),Xs(),(!Gs||!Ys)&&Lp()}var Ks=null;function Lp(){if(Ks||typeof document>"u")return;Ks=so(document,df,()=>{Wf(),Xs(),Gs&&Ys&&(Ks?.(),Ks=null)})}var Pp={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 Rr(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="${Pp[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 Xf="data-hcms-ghost",jp=Wo("history");function Dp(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 Jf({doc:e,themeRoot:t,onAdd:n,onResize:r}){let o=e.defaultView,s=[],i=!1,l=null,a=new Map;function c(p,m,k){p.style[m]!==k&&(p.style[m]=k)}function d(){let p=new Set(s.map(m=>m.node.parentElement));for(let[m,k]of a)p.has(m)&&o?.Sortable?.get(m)===k.instance||(k.instance.option("draggable")===k.selector&&k.instance.option("draggable",k.original),a.delete(m));for(let m of p){let k=o?.Sortable?.get(m);if(!k)continue;let g=k.option("draggable");if(a.get(m)?.selector===g)continue;let h=g,A=`${h.trim().startsWith(">")?"> ":""}:is(${h.trim().replace(/^>\s*/,"")}):not(${jp})`;k.option("draggable",A),a.set(m,{instance:k,original:h,selector:A})}}function u(){for(let p of s){let{node:m,slot:k,list:g}=p,h=g.items.filter(y=>y.isConnected).map(y=>y.getBoundingClientRect()).filter(y=>y.width>0&&y.height>0);h.length&&(p.width=h.reduce((y,A)=>y+A.width,0)/h.length,p.height=h.reduce((y,A)=>y+A.height,0)/h.length),c(m,"width",p.width?`${Math.round(p.width)}px`:"100%"),c(k,"height",`${Math.max(48,Math.round(p.height||64))}px`),k!==m&&(k.colSpan=Math.max(1,...g.items.map(y=>[...y.children].reduce((A,w)=>A+(w.colSpan||1),0)))),m.hidden!==i&&(m.hidden=i)}d()}function f(p,m){let k=m.tagName,g=["TBODY","THEAD","TFOOT","TABLE"].includes(k),h=e.createElement(g?"tr":["UL","OL","MENU"].includes(k)?"li":"div");for(let v of[Xf,"data-hcms-shell","editor-ui","no-watch","no-save","save-remove","snapshot-remove"])h.setAttribute(v,"");h.setAttribute("draggable","false"),h.setAttribute("contenteditable","false"),h.className="hcms-shell pixel-quiet hcms-inline-ghost";for(let v of["light","dark"])h.classList.toggle(v,!!t?.classList.contains(v));let y=g?e.createElement("td"):h;y!==h&&(y.className="hcms-inline-ghost-cell",h.appendChild(y));let A=e.createElement("button");A.type="button",A.className="hcms-inline-list-button hcms-inline-list-add mirk-button mirk-button--small",A.setAttribute("data-hcms-list-action","add"),A.innerHTML=`<span class="mirk-button__label">${Rr("add")}<span>Add</span></span>`,y.appendChild(A);let w={node:h,slot:y,button:A,list:p,width:0,height:0};A.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),n(w.list)});for(let v of["pointerdown","mousedown","touchstart","click"])h.addEventListener(v,E=>E.stopPropagation());return h.addEventListener("dragstart",v=>{v.preventDefault(),v.stopPropagation()}),w}return{setLists(p){let m=new Set(s),k=[],g=new Set(s.map(y=>y.node)),h=new Set;for(let y of p||[]){if(!y.container||!y.container.isConnected)continue;let{parent:A,anchor:w}=Dp(y);if(!A)continue;if(!h.has(A)){for(let N of A.querySelectorAll(`:scope > [${Xf}]`))g.has(N)||N.remove();h.add(A)}let v=s.find(N=>m.has(N)&&N.list.container===y.container&&N.list.path.join(".")===y.path.join("."))||f(y,A);m.delete(v),v.list=y,v.button.setAttribute("data-hcms-list",y.path.join(".")),v.button.setAttribute("aria-label",`Add to ${y.path.join(".")||"the list"}`);let E=w||y.items.filter(N=>N.parentElement===A).at(-1);E?E.nextSibling!==v.node&&E.after(v.node):v.node.parentElement!==A&&A.appendChild(v.node),k.push(v)}for(let y of m)y.node.remove();s=k,l?.disconnect(),!l&&typeof o?.ResizeObserver=="function"&&(l=new o.ResizeObserver(()=>{u(),r?.()}));for(let y of s)for(let A of y.list.items)l?.observe(A);u()},update:u,setHidden(p){i=!!p,u()},destroy(){l?.disconnect();for(let p of s)p.node.remove();s=[],d()}}}var Zf=[["move-up","Move up"],["move-down","Move down"]],Fp={prefer:"corner",inset:0};function Bp(e,t){return t.width<=e.width&&t.height<=e.height}function Qf({doc:e,layerEl:t,onActivate:n,onListAction:r}){let o=e.defaultView,s=[],i=new Map,l=0,a=new Map,c=null,d=new Set,u=0,f=!1,p=null,m=null,k=null,g=null,h=new Map,y=!1,A=null,w=Jf({doc:e,themeRoot:t.closest("[data-hcms-shell]"),onResize:E,onAdd:ae=>r?.({action:"add",list:ae,index:ae.items.length})}),v=e.createElement("div");v.className="hcms-inline-highlight",v.hidden=!0,v.setAttribute("aria-hidden","true"),t.appendChild(v);function E(){if(!(u||!o)){if(typeof o.requestAnimationFrame!="function")return _();u=o.requestAnimationFrame(()=>{u=0,_()})}}let N=()=>k||g;function _(){if(!o)return;w.update();let ae={width:o.innerWidth,height:o.innerHeight},de=N();for(let Ee of s){if(!Ee.visible){Ee.node.hidden=!0;continue}for(let gt of Ee.members)gt.node.hidden=y&>.kind!=="handle";Ee.node.hidden=!1;let Ge=Ee.el.getBoundingClientRect(),Ve=Ee.node.getBoundingClientRect(),ze=Ve.width,lt=Ee.kind==="row"&&!Bp(Ge,Ve);if(lt&&Ee.el!==de){for(let gt of Ee.members)gt.kind==="row"&&(gt.node.hidden=!0);Ve=Ee.node.getBoundingClientRect()}if(Ee.members.every(gt=>gt.node.hidden)){Ee.node.hidden=!0;continue}let pt=Ee.kind==="handle"?null:Fp,{x:Rt,y:dt}=Ml({anchor:Ge,handle:Ve,viewport:ae,...pt}),vt=Ee.members.find(gt=>gt.kind==="handle");if(lt&&vt){let gt=vt.node.getBoundingClientRect(),kn=Ml({anchor:Ge,handle:gt,viewport:ae}),Ft=Ee.members.slice(Ee.members.indexOf(vt)+1).filter(Qt=>!Qt.node.hidden).reduce((Qt,Yt)=>Qt+Yt.node.getBoundingClientRect().width+2,0);Rt=Math.max(8+ze,Math.min(ae.width-8,kn.x+gt.width+Ft))-Ve.width,dt=kn.y}Ee.node.style.transform=`translate(${Math.round(Rt)}px, ${Math.round(dt)}px)`}if(A)if(!A.node.isConnected||A.node.closest("[hidden]"))Ue();else{let Ee=A.button.getBoundingClientRect(),Ge=A.menu.getBoundingClientRect();A.menu.style.left=`${Math.max(8,Ee.right-Ge.width)-Ee.left}px`,A.menu.style.right="auto",A.menu.style.top=Ee.bottom+6+Ge.height>ae.height-8?"auto":"calc(100% + 6px)",A.menu.style.bottom=Ee.bottom+6+Ge.height>ae.height-8?"calc(100% + 6px)":"auto"}D(),p?.()}function M(ae){if(ae?.closest?.("[data-hcms-ghost]"))return null;for(let de=ae;de&&de.nodeType===1;de=de.parentElement){let Ee=h.get(de);if(Ee)return Ee}return null}function j(ae){A&&!A.node.contains(ae.target)&&Ue();let de=N();g=M(ae.target),g&&t.contains(ae.target)&&(k=null),N()!==de&&E()}function R(ae){if(ae.relatedTarget||!g)return;let de=N();g=null,N()!==de&&E()}function D(){if(!m||v.hidden)return;let ae=m.getBoundingClientRect();v.style.width=`${Math.round(ae.width)}px`,v.style.height=`${Math.round(ae.height)}px`,v.style.transform=`translate(${Math.round(ae.left)}px, ${Math.round(ae.top)}px)`}function B(){if(!o||typeof o.IntersectionObserver!="function"){for(let de of s)de.visible=!0;return}c||(c=new o.IntersectionObserver(de=>{let Ee=!1;for(let Ge of de)for(let Ve of i.get(Ge.target)||[])Ve.visible!==Ge.isIntersecting&&(Ve.visible=Ge.isIntersecting,Ee=!0);Ee&&E()},{threshold:0}));let ae=new Set(i.keys());for(let de of d)ae.has(de)||c.unobserve(de);for(let de of ae)d.has(de)||c.observe(de);d=ae}function S(){f||!o||(o.addEventListener("scroll",E,{passive:!0,capture:!0}),o.addEventListener("resize",E,{passive:!0}),e.addEventListener("focusin",j),e.addEventListener("focusout",R),e.addEventListener("pointerdown",_e,!0),e.addEventListener("keydown",O,!0),f=!0)}function T(){!f||!o||(o.removeEventListener("scroll",E,{capture:!0}),o.removeEventListener("resize",E),e.removeEventListener("focusin",j),e.removeEventListener("focusout",R),e.removeEventListener("pointerdown",_e,!0),e.removeEventListener("keydown",O,!0),f=!1)}function J(ae){return`${ae.kind}\0${ae.attr||""}`}function q(ae,de){return ae.container===de.container&&ae.scalar===de.scalar}function V(ae,de){return ae.kind!==de.kind?!1:ae.kind==="handle"?J(ae.target)===J(de.target):ae.kind==="row"?ae.row===de.row&&q(ae.list,de.list):q(ae.list,de.list)}function Ce(ae,de){ae.target=de;let Ee=de.path.join(".");ae.node.setAttribute("data-hcms-target",Ee),de.icon?ae.node.setAttribute("data-hcms-icon",de.icon):ae.node.removeAttribute("data-hcms-icon"),ae.node.setAttribute("aria-label",`Edit ${Ee}`)}function Me(ae){let de=e.createElement("button");de.type="button",de.className="hcms-inline-handle mirk-button mirk-button--small",de.innerHTML=`<span class="mirk-button__label">${Rr("edit")}</span>`;let Ee={node:de,kind:"handle",target:ae};return Ce(Ee,ae),de.addEventListener("click",Ge=>{Ge.preventDefault(),Ge.stopPropagation(),n?.(Ee.target,de)}),Ee}function Fe(ae,de){let Ee=e.createElement("button");return Ee.type="button",Ee.className="hcms-inline-list-button mirk-button mirk-button--small",Ee.setAttribute("data-hcms-list-action",ae),Ee.setAttribute("aria-label",de),Ee.innerHTML=`<span class="mirk-button__label">${Rr(ae)}${ae==="add"?"<span>Add</span>":""}</span>`,Ee}function ce(ae,{list:de,row:Ee,rowIndex:Ge,count:Ve}){let ze=de.path.join(".");ae.list=de,ae.row=Ee,ae.index=Ge,ae.count=Ve,ae.node.setAttribute("data-hcms-list",ze),ae.node.setAttribute("data-hcms-row",String(Ge));for(let lt of ae.node.querySelectorAll("[data-hcms-list-action]")){let pt=lt.getAttribute("data-hcms-list-action"),Rt=Zf.find(([dt])=>dt===pt)?.[1]||pt;lt.setAttribute("aria-label",`${Rt} ${ze}.${Ge}`),lt.disabled=pt==="move-up"&&Ge===0||pt==="move-down"&&Ge===Ve-1}}function Ae(ae,de,Ee,Ge){let Ve=e.createElement("div");Ve.className="hcms-inline-row-controls";let ze={node:Ve,kind:"row",list:ae,row:de,index:Ee,count:Ge};for(let[lt,pt]of Zf){let Rt=Fe(lt,pt);Rt.addEventListener("click",dt=>{dt.preventDefault(),dt.stopPropagation(),!Rt.disabled&&r?.({action:lt,list:ze.list,index:ze.index,row:ze.row})}),Ve.appendChild(Rt)}return ce(ze,{list:ae,row:de,rowIndex:Ee,count:Ge}),ze}function Ue(ae=!1){if(!A)return;let de=A;A=null,de.menu.hidden=!0,de.button.setAttribute("aria-expanded","false"),de.node.parentElement?.classList.remove("has-open-settings"),ae&&de.button.isConnected&&de.button.focus({preventScroll:!0})}function _e(ae){A&&!A.node.contains(ae.target)&&Ue()}function O(ae){A&&(ae.key==="Escape"?(ae.preventDefault(),ae.stopPropagation(),Ue(!0)):ae.key==="Tab"?Ue(!0):["ArrowDown","ArrowUp","Home","End"].includes(ae.key)&&A.menu.contains(ae.target)&&(ae.preventDefault(),A.menu.querySelector('[role="menuitem"]').focus({preventScroll:!0})))}function X(ae,{list:de,row:Ee,rowIndex:Ge}){Object.assign(ae,{list:de,row:Ee,index:Ge}),ae.node.setAttribute("data-hcms-list",de.path.join(".")),ae.node.setAttribute("data-hcms-row",String(Ge)),ae.button.setAttribute("aria-label",`Settings ${de.path.join(".")}.${Ge}`)}function le(ae){let de=e.createElement("div");de.className="hcms-inline-settings";let Ee=Fe("settings","Settings");Ee.setAttribute("aria-haspopup","menu"),Ee.setAttribute("aria-expanded","false");let Ge=e.createElement("div");Ge.className="hcms-inline-settings-menu",Ge.setAttribute("role","menu"),Ge.setAttribute("aria-label","Item settings"),Ge.hidden=!0;let Ve=e.createElement("button");Ve.type="button",Ve.setAttribute("role","menuitem"),Ve.setAttribute("data-hcms-list-action","remove"),Ve.textContent="Delete",Ge.appendChild(Ve),de.append(Ee,Ge);let ze={node:de,button:Ee,menu:Ge,kind:"settings"};X(ze,ae);let lt=()=>{Ue(),A=ze,Ge.hidden=!1,Ee.setAttribute("aria-expanded","true"),de.parentElement.classList.add("has-open-settings"),Ve.focus({preventScroll:!0}),E()};return Ee.addEventListener("click",pt=>{pt.preventDefault(),pt.stopPropagation(),A===ze?Ue(!0):lt()}),Ee.addEventListener("keydown",pt=>{(pt.key==="ArrowDown"||pt.key==="ArrowUp")&&(pt.preventDefault(),lt())}),Ve.addEventListener("click",pt=>{pt.preventDefault(),pt.stopPropagation(),Ue(!0),r?.({action:"remove",list:ze.list,index:ze.index,row:ze.row})}),ze}function re(ae,de){ae.kind==="handle"?Ce(ae,de.target):ae.kind==="row"?ce(ae,de):ae.kind==="settings"&&X(ae,de)}function Pe(ae,de,Ee,Ge,Ve){let ze=de.get(Ee)?.find(lt=>lt.category===Ve);if(!ze){ze={el:Ee,category:Ve,members:[]},ae.push(ze);let lt=de.get(Ee);lt?lt.push(ze):de.set(Ee,[ze])}ze.members.push(Ge)}function Be(ae,de,Ee){let Ge=Ee.items||[];Ge.forEach((Ve,ze)=>{zo(Ve)&&(Pe(ae,de,Ve,{kind:"row",list:Ee,row:Ve,rowIndex:ze,count:Ge.length},"item"),Pe(ae,de,Ve,{kind:"settings",list:Ee,row:Ve,rowIndex:ze},"item"))})}function Te(ae,de){let Ee=new Set(ae.members),Ge=[];for(let Ve of de){let ze=ae.members.find(lt=>Ee.has(lt)&&V(lt,Ve))||(Ve.kind==="handle"?Me(Ve.target):Ve.kind==="row"?Ae(Ve.list,Ve.row,Ve.rowIndex,Ve.count):le(Ve));Ee.delete(ze),re(ze,Ve),y&&ze.kind!=="handle"&&(ze.node.hidden=!0),Ge.push(ze)}for(let Ve of Ee)Ve===A&&Ue(),Ve.node.remove();Ge.sort((Ve,ze)=>["row","handle","settings"].indexOf(Ve.kind)-["row","handle","settings"].indexOf(ze.kind)),Ge.forEach((Ve,ze)=>{ae.node.children[ze]!==Ve.node&&ae.node.insertBefore(Ve.node,ae.node.children[ze]||null)}),ae.members=Ge}function ot(ae,de){let Ee=[],Ge=new Map,Ve=new Map,ze=0;for(let dt of ae||[])Ve.has(dt.el)||Ve.set(dt.el,dt),!(dt.kind!=="handle"||!zo(dt.el))&&(Pe(Ee,Ge,dt.el,{kind:"handle",target:dt},"item"),ze++);for(let dt of de||[])Be(Ee,Ge,dt);let lt=new Set(s),pt=new Map;for(let dt of s)pt.has(dt.el)||pt.set(dt.el,dt.visible);let Rt=[];for(let dt of Ee){let vt=s.find(gt=>lt.has(gt)&>.el===dt.el&>.category===dt.category);if(!vt){let gt=e.createElement("div");gt.className="hcms-inline-item-controls",gt.setAttribute("role","group"),vt={el:dt.el,node:gt,category:dt.category,kind:dt.category==="add"?"add":"handle",members:[],visible:pt.get(dt.el)??!1},t.appendChild(gt)}lt.delete(vt),vt.el=dt.el,vt.category=dt.category,Te(vt,dt.members),vt.kind=vt.members.some(gt=>gt.kind==="row")?"row":vt.members.some(gt=>gt.kind==="handle")?"handle":"add",vt.node.setAttribute("aria-label",vt.category==="add"?"List controls":"Item controls"),Rt.push(vt)}for(let dt of lt)dt.node.remove();s=Rt,i=new Map,h=new Map;for(let dt of s){let vt=i.get(dt.el);vt?vt.push(dt):i.set(dt.el,[dt]);for(let gt of dt.members)gt.kind!=="row"&>.kind!=="settings"||(h.set(gt.row,gt.row),h.set(gt.node,gt.row),h.set(dt.node,gt.row))}k&&!h.has(k)&&(k=null),g&&!h.has(g)&&(g=null),a=Ve,l=ze}function et(){Ue(),c?.disconnect(),c=null,d=new Set;for(let ae of s)ae.node.remove();s=[],i=new Map,a=new Map,h=new Map,l=0}return{setTargets(ae,de){ot(ae,de),w.setLists(de),B(),S(),E()},refresh:E,get count(){return l},get controlsHidden(){return y},setControlsHidden(ae){if(y=!!ae,w.setHidden(y),y){Ue();for(let de of s){for(let Ee of de.members)Ee.kind!=="handle"&&(Ee.node.hidden=!0);de.members.every(Ee=>Ee.node.hidden)&&(de.node.hidden=!0)}}E()},elementToTarget(ae){if(ae?.closest?.("[data-hcms-ghost]"))return null;for(let de=ae;de&&de.nodeType===1;de=de.parentElement){let Ee=a.get(de);if(Ee)return Ee}return null},setHoveredRow(ae){let de=N();k=ae?M(ae):null,N()!==de&&E()},showHighlight(ae){ae&&(m=ae,v.hidden=!1,D())},hideHighlight(){m=null,v.hidden=!0},setFollower(ae){p=typeof ae=="function"?ae:null},destroy(){w.destroy(),u&&o&&o.cancelAnimationFrame(u),u=0,p=null,m=null,k=null,g=null,v.remove(),T(),et()}}}var qp="hypercms-inline",Yo="is-hcms-inline-active",Rl="is-hcms-inline-onpath",eu='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])',Up=["bold","italic","link","undo","redo"],$p=/^H[1-6]$/,Hp=0;function ru({doc:e,pageRoot:t,opts:n={}}){let r=n.richText!==!1,o=null,s=null,i=null,l=new Map,a=null,c=null,d=null;function u(f,p,m,k,g){let h=io(e.defaultView);if(typeof h!="function")return null;let y=g||{},A=y.originalHTML??Cl(p,{capability:"history"}).html(),w=y.richClayIsOurs??!p.hasAttribute("data-richclay"),v=y.adopted??p.getAttribute("data-richclay-active")==="true",E=Ko(p,k,"history"),N=zp(f,h,p,k,w);if(!N)return null;gf(p,k==="innerHTML",w);let _=String(++Hp);p.setAttribute(mr,_),Xs();let M={el:p,editor:N,path:m,prop:k,boundId:_,originalHTML:A,oldValue:E,richClayIsOurs:w,adopted:v,dirty:!1,written:!1,restorable(){return!this.adopted&&!this.dirty&&!this.written},lastEdited:void 0};l.set(p,M),hf(_,M);let j=N.squire;if(j&&typeof j.addEventListener=="function"){let D=()=>{M.dirty=!0,M.lastEdited=Ko(p,M.prop,"history"),Vp(f,M)};j.addEventListener("input",D),M.detachInput=()=>j.removeEventListener?.("input",D)}let R=()=>ou(M);return p.addEventListener("blur",R),M.detachBlur=()=>p.removeEventListener("blur",R),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?xf(f,t):f},bindText(f,p,m,k){return u(this.ctx,f,p,m,k)},mount(f){let p=this.ctx;o=Xp(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,rr(()=>Ho(e));let m=no({pageRules:p.pageRules,formRules:p.formRules,data:f,doc:e});o.formRoot.appendChild(m),p.seeder.seed(o.formRoot),pr(o.formRoot,e,this.enhanceFormRichText),mo(p),js(p),s=Qf({doc:e,layerEl:o.layerEl,onActivate:(k,g)=>this.activate(k,g),onListAction:k=>this.listAction(k)}),s.setFollower(()=>this.placePopover()),o.closeEl.addEventListener("click",()=>this.deactivate()),o.toggleEl.addEventListener("click",k=>{k.preventDefault(),k.stopPropagation(),this.toggleControls()}),o.handoffEl.querySelector("[data-hcms-open-view]").addEventListener("click",k=>{k.preventDefault(),k.stopPropagation(),p.onViewRequested?.("sidebar")}),this.bindPage(),this.syncTargets()},listAction({action:f,list:p,index:m,row:k}){let g=this.ctx,h=p.path.join("."),y=g.formRoot.querySelector(`[data-hcms-path="${fo(h)}"]`);if(!y)return;if(f==="add"){Uo(h,g);return}let A=k?Zp(g,h,k):m;if(A===-1)return;let w=Jp(y,A);if(w){if(f==="remove"){yl(w,g),this.syncTargets();return}bl(w,f==="move-up"?-1:1,g),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,m=w=>{let v=s&&s.elementToTarget(w.target);v?s.showHighlight(v.el):s?.hideHighlight(),s?.setHoveredRow(w.target)},k=()=>{s?.hideHighlight(),s?.setHoveredRow(null)},g=w=>{if(p.contains(w.target))return;let v=s&&s.elementToTarget(w.target);!v||v.kind!=="text"||l.has(v.el)||u(this.ctx,v.el,v.path.join("."),Zs(v))},h=w=>{if(p.contains(w.target))return;let v=s&&s.elementToTarget(w.target);if(!v){this.deactivate();return}(typeof w.target.closest=="function"&&w.target.closest("a[href]")||v.kind!=="text")&&w.preventDefault(),this.activate(v)},y=w=>{w.key==="Escape"&&this.deactivate()},A=w=>{let v=w.detail;if(!(!v||v.pageRoot!==this.ctx.pageRoot||!v.path))for(let E of l.values())E.path===v.path&&(E.written=!0)};f.addEventListener("pointerover",m),f.addEventListener("pointerleave",k),f.addEventListener("pointerdown",g),f.addEventListener("click",h),p.addEventListener("keydown",y),e.addEventListener("hcms:change",A),i=()=>{f.removeEventListener("pointerover",m),f.removeEventListener("pointerleave",k),f.removeEventListener("pointerdown",g),f.removeEventListener("click",h),p.removeEventListener("keydown",y),e.removeEventListener("hcms:change",A)}},activate(f,p){if(!f||!o||f.kind==="text"&&this.activateText(f))return;let m=tu(this,o,f.path.join("."));if(!m){this.deactivate();return}a=f,c=p||null,d=null,o.popEl.hidden=!1,o.formRoot.querySelectorAll(`.${Yo}`).forEach(nu),this.placePopover(),Yp(m)},activateText(f){let p=f.el,m=l.get(p);if(m)return Js(m),!0;let k=u(this.ctx,p,f.path.join("."),Zs(f));return k?(Js(k),!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},m=a.el.getBoundingClientRect(),k=o.popEl.getBoundingClientRect(),{mode:g,x:h,y}=Vf({anchor:m,bar:k,viewport:p,current:d});d=g,o.popEl.style.transform=`translate(${Math.round(h)}px, ${Math.round(y)}px)`},deactivate(){if(!o||!a&&o.popEl.hidden)return;o.popEl.hidden=!0,iu(o.root);let f=c;if(a=null,c=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:m}=Nl(f.pageRoot,f.pageRules);s.setTargets(p,m);let k=Wp(this,l,p,e);if(a){let h=k.get(a.el)||[],y=h.find(A=>Kp(A,a))||h.find(A=>A.path.join(".")===a.path.join("."))||(h.length===1?h[0]:null);y?a=y:this.deactivate()}Gp(this.ctx,l,e);let g=p.reduce((h,y)=>h+(zo(y.el)?0:1),0);this.handoffEl&&(this.handoffCountEl.textContent=g===0?"":`${g} ${g===1?"field isn't":"fields aren't"} visible right now.`,this.handoffEl.hidden=g===0)},refresh(f,p){f==="livesync"?(yr(e),Ho(e),kr(this.ctx,{ignoreActiveValue:!0})):f==="undo"?kr(this.ctx,{ignoreActiveValue:!1}):kr(this.ctx),this.syncTargets(),(f==="livesync"||f==="undo")&&this.rebindText(f),this.restoreActive()},rebindText(f){let p=f!=="undo";for(let[m,k]of[...l]){if(!e.contains(m)){Go(this.ctx,k,{restore:!1,record:p}),l.delete(m);continue}if(m.hasAttribute($n)){let y=Ko(m,k.prop);y!==k.lastEdited&&(k.oldValue=y,k.lastEdited=void 0);continue}let g=e.activeElement===m;Go(this.ctx,k,{restore:!1,record:p}),l.delete(m);let h=u(this.ctx,m,k.path,k.prop,{richClayIsOurs:k.richClayIsOurs,adopted:k.adopted});h&&g&&Js(h)}},restoreActive(){if(!o||!a||o.popEl.hidden)return;if(!e.contains(a.el)){this.deactivate();return}if(!tu(this,o,a.path.join("."))){this.deactivate();return}o.formRoot.querySelectorAll(`.${Yo}`).forEach(nu),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 l.values())Go(this.ctx,f);l.clear(),i?.(),i=null,s?.destroy(),s=null,o?.destroy(),o=null,Al(e),this.popEl=null,this.handoffEl=null,this.handoffCountEl=null}}}function zp(e,t,n,r,o){return rr(()=>{let s=null;try{s=new t(n,{inline:!0,hyperclay:!1,toolbar:r==="innerHTML"?Up:!1,...$p.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 Vp(e,{path:t,el:n,prop:r}){let o=Ds(e.formRoot,t);o&&(Fs(o,Ko(n,r),e.formRoot,t),Mn(Tn(e),{path:t,structural:!1},e))}function Ko(e,t,n="data"){let r=Cl(e,{capability:n});return t==="innerHTML"?r.html():r.text().trim()}function ou(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=dn("undo");if(!i||typeof i.recordValue!="function")return;let l={prop:n,oldValue:r,newValue:s,read:a=>Ko(a,n,"history"),write:(a,c)=>su(a,n,c)};i.isPaused?queueMicrotask(()=>{t.isConnected&&i.recordValue(t,l)}):i.recordValue(t,l)}function su(e,t,n){let r=e.cloneNode(!1);t==="innerHTML"?r.innerHTML=n:r.textContent=n,ur(e,Array.from(r.childNodes),{morphStyle:"innerHTML",policy:"history",restoreFocus:!1,scripts:{handle:!1,merge:!1}})}function Go(e,t,{restore:n=!0,record:r=!0}={}){r&&ou(t),t.detachInput?.(),t.detachBlur?.(),rr(()=>{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($n),t.el.removeAttribute(Cr),t.el.removeAttribute(mr),mf(t.boundId),n&&t.restorable()&&su(t.el,"innerHTML",t.originalHTML)})}function Js(e){let{editor:t,el:n}=e;if(n.ownerDocument.activeElement!==n)try{typeof t.focus=="function"?t.focus():n.focus()}catch{}}function Wp(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=>Zs(f)===i.prop)||l[0];if(!a){Go(e.ctx,i,{restore:!0}),t.delete(s);continue}i.path=a.path.join(".");let c=Zs(a);if(c===i.prop)continue;let d=r.activeElement===s;Go(e.ctx,i,{restore:!1}),t.delete(s);let u=e.bindText(s,i.path,c,{richClayIsOurs:i.richClayIsOurs,adopted:i.adopted,originalHTML:i.originalHTML});u&&d&&Js(u)}return o}function Kp(e,t){return e.el===t.el&&e.kind===t.kind&&e.attr===t.attr}function Zs(e){return e.attr==="innerHTML"?"innerHTML":"textContent"}function Gp(e,t,n){for(let r of e.pageRoot.querySelectorAll(`[${$n}]`))t.has(r)||rr(()=>yf(r,n.defaultView))}function tu(e,t,n){let r=e.formRoot&&e.formRoot.querySelector(`[data-hcms-path="${fo(n)}"]`);if(iu(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(Yo),i.removeAttribute("draggable");for(let l=i.parentElement;l&&(l.classList.add(Rl),l.removeAttribute("draggable"),l!==e.formRoot);l=l.parentElement);}return r}function iu(e){if(e)for(let t of e.querySelectorAll(`.${Yo}, .${Rl}`))t.classList.remove(Yo,Rl)}function nu(e){e.tagName==="TEXTAREA"&&lo(e),e.querySelectorAll?.("textarea").forEach(lo)}function Yp(e){let t=e.matches?.(eu)?e:e.querySelector?.(eu);if(!(!t||typeof t.focus!="function"))try{t.focus({preventScroll:!0})}catch{t.focus()}}function Xp(e,t){yr(e);let n=e.createElement(qp),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=`
|
|
184
184
|
<div class="hcms-inline-bar">
|
|
185
185
|
<div class="hcms-inline-handoff" hidden>
|
|
186
186
|
<span class="hcms-inline-handoff-count"></span>
|
|
@@ -199,21 +199,21 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
|
|
|
199
199
|
<div class="hcms-inline-pop-header">
|
|
200
200
|
<span>Edit content</span>
|
|
201
201
|
<button type="button" class="hcms-inline-pop-close mirk-button mirk-button--small" aria-label="Close field editor">
|
|
202
|
-
<span class="mirk-button__label">${
|
|
202
|
+
<span class="mirk-button__label">${Rr("remove")}</span>
|
|
203
203
|
</button>
|
|
204
204
|
</div>
|
|
205
205
|
<div data-hcms-form-root class="hcms-form"></div>
|
|
206
206
|
</div>
|
|
207
|
-
`,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
|
|
207
|
+
`,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 Jp(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 Zp(e,t,n){let{lists:r}=Nl(e.pageRoot,e.pageRules),o=r.find(s=>s.path.join(".")===t);return o?o.items.indexOf(n):-1}var Qp="[hypercms]";function lu(e,t){if(!e||!e.querySelectorAll||!t)return;let n=eg(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(o=>{let s=o.getAttribute("data-hcms-tpl");s&&(s.startsWith("@")||n.has(s)||console.warn(`${Qp} template "${s}" doesn't match any rule path; ignored`))})}function eg(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=_r(o);if(l==="object")for(let[a,c]of Object.entries(o))n([...r,a],c);else if(l==="object-array"||l==="scalar-array"){let a=[...r,"*"],c=a.map(d=>typeof d=="number"?"*":d).join(".");if(t.add(c),l==="object-array"){let d=o[1];if(d&&typeof d=="object"&&!Array.isArray(d))for(let[u,f]of Object.entries(d))n([...a,u],f)}}}}var cu={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Ct={isOpen:!1,ctx:null,opts:null};function fu({view:e,doc:t,pageRoot:n,opts:r={},onCloseRequested:o,onViewRequested:s}){let i=r.rules!==void 0?r.rules:"cms",l=wn.findRules(t,i);if(!l){let g=typeof i=="string"?`data-rules-name~="${i}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${g}`)}let a=e.prepareRules(l.rules),c=l.tagNode;As(t),Ns(t,a),lu(t,a);let d=Cs(a,t),u=zs(a),f=Hs(n,a),p=xs(),m=br(wn.extract(n,a,{...cu,...p.hooks}),a),k={doc:t,pageRoot:n,pageRules:a,writeRules:u,formRules:d,rulesTagNode:c,rulesSource:i,richText:e.richText,view:e,seeder:p,initialData:m,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(g,h){let y=t.defaultView&&t.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!y)return;let A={...h||{},pageRoot:n,view:e.name},w=new y(g,{bubbles:!0,cancelable:g==="hcms:change",detail:A});(e.root&&e.root.isConnected!==!1?e.root:n).dispatchEvent(w)},onCloseRequested:o,onViewRequested:s};return k.updateFingerprint=()=>{k.lastFingerprint=$o(Tn(k))},e.ctx=k,k}function uu(e){e.updateFingerprint(),e.observerHandle=Pf({onRefresh:r=>e.view.refresh("observer",r)});let t=dn("undo");if(t&&typeof t.on=="function"){let r=()=>{if(Ct.ctx!==e)return;au(e,"undo");let o=br(wn.extract(e.pageRoot,e.pageRules,cu),e.pageRules);$o(o)!==$o(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=()=>au(e,"livesync");e.livesyncUnsub=so(e.doc,uf,n),Ll.ctx=e,ng(e.doc)}function au(e,t){Ct.ctx===e&&e.view.refresh(t)}function Qs(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&&rg(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),rr(()=>e.view.destroy()),tg(),n&&typeof s?.focus=="function")try{s.focus()}catch{}}function tg(){Ct.isOpen=!1,Ct.ctx=null,Ct.opts=null,Ll.ctx=null}var Ll={ctx:null};function ng(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let n=function(){let o=Ll.ctx;if(o)return Bs(o.formRoot),Mr("Reorder",()=>Mn(Tn(o),{path:"",structural:!0},o))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=n),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=n)}var Il="cms";function du(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(Il)!=="true"?t:(o.set(Il,"false"),"?"+o.toString())}function hu(e){let t=typeof e=="string"?e:"",n=t.indexOf("?"),r=n===-1?t:t.slice(n+1);return r?new URLSearchParams(r).get(Il)==="true":!1}function rg(){if(typeof window>"u"||!window.location||!window.history||typeof window.history.replaceState!="function")return;let e=window.location.search,t=du(e);t!==e&&window.history.replaceState(window.history.state,"",t+window.location.hash)}var mu="hcms-toggle",Jt="data-hcms-toggle-host",pu="hcms-toggle-style",gu="data-hcms-toggle-style",ei="data-hcms-session",Au="data-hcms-split",Su="hcms.view",ti=["sidebar","inline"],og={sidebar:"In the sidebar",inline:"On the page"},Dl="var(--hcms-toggle-bg, var(--hcms-toggle-_surface))";function bu(e){try{let t=e&&e.localStorage?e.localStorage.getItem(Su):null;return ti.includes(t)?t:null}catch{return null}}function sg(e,t){if(ti.includes(t))try{e?.localStorage?.setItem(Su,t)}catch{}}var ig="#fafafa",lg="#0a0a0a",ag=`
|
|
208
208
|
[${Jt}] {
|
|
209
209
|
all: unset;
|
|
210
210
|
box-sizing: border-box;
|
|
211
211
|
display: var(--hcms-toggle-display, inline-flex);
|
|
212
212
|
font-family: 'Departure Mono', ui-monospace, Menlo, monospace;
|
|
213
|
-
--hcms-toggle-_surface: ${
|
|
213
|
+
--hcms-toggle-_surface: ${ig};
|
|
214
214
|
}
|
|
215
215
|
[${Jt}][data-hcms-surface="dark"] {
|
|
216
|
-
--hcms-toggle-_surface: ${
|
|
216
|
+
--hcms-toggle-_surface: ${lg};
|
|
217
217
|
}
|
|
218
218
|
[${Jt}] .hcms-toggle__main,
|
|
219
219
|
[${Jt}] .hcms-toggle__arrow {
|
|
@@ -250,9 +250,9 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
|
|
|
250
250
|
outline-offset: -5px;
|
|
251
251
|
}
|
|
252
252
|
[${Jt}] .hcms-toggle__close { display: none; }
|
|
253
|
-
[${Jt}][${
|
|
254
|
-
[${Jt}][${
|
|
255
|
-
[${Jt}][${
|
|
253
|
+
[${Jt}][${ei}="open"] .hcms-toggle__open { display: none; }
|
|
254
|
+
[${Jt}][${ei}="open"] .hcms-toggle__close { display: inline; }
|
|
255
|
+
[${Jt}][${Au}] .hcms-toggle__main {
|
|
256
256
|
border-radius: 0;
|
|
257
257
|
padding-right: 12px;
|
|
258
258
|
}
|
|
@@ -271,7 +271,7 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
|
|
|
271
271
|
font-size: 14px;
|
|
272
272
|
line-height: 1.5;
|
|
273
273
|
color: var(--hcms-toggle-color, currentColor);
|
|
274
|
-
background: ${
|
|
274
|
+
background: ${Dl};
|
|
275
275
|
border: 1px solid var(--mirk-input-border, #D8C8AF);
|
|
276
276
|
border-radius: var(--mirk-radius, 5px);
|
|
277
277
|
box-shadow: 0 14px 34px -14px rgba(0, 0, 0, .45);
|
|
@@ -305,7 +305,7 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
|
|
|
305
305
|
[${Jt}] .hcms-toggle__main,
|
|
306
306
|
[${Jt}] .hcms-toggle__arrow { min-height: 44px; }
|
|
307
307
|
}
|
|
308
|
-
`;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),i=new URLSearchParams(s).get("editmode");return i?i==="true":n!=null?!!n:/(?:^|;\s*)isAdminOfCurrentResource=[^;]/.test(t)}var Ml=new WeakMap;function pu(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 Gp(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=pu(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 Yp(e,t){let n=String(e??"").trim();if(!n)return null;let r=Xp(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=Gp(t);return s?pu(s,n):null}function Xp(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 au({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 cu(e,t){let n=au(e),r=au(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var fu={r:10,g:10,b:10},uu={r:250,g:250,b:250};function du(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 Jp(e){if(!e)return"light";let t=cu(du(e,fu),fu),n=cu(du(e,uu),uu);return t>n?"dark":"light"}function Go(e,t){for(let[n,r]of Object.entries(t))e.style.setProperty(n,r,"important")}function Rl(e){let t=e.ownerDocument&&e.ownerDocument.defaultView,n=e.querySelector(".hcms-toggle__main");if(!t||!n||typeof t.getComputedStyle!="function")return;let r=Yp(t.getComputedStyle(n).color,e.ownerDocument);e.setAttribute("data-hcms-surface",Jp(r))}function Zp(e){Rl(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?Rl(e):l();r=n.requestAnimationFrame(()=>{if(r=0,!e.isConnected)return l();Rl(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 Qp({open:e,close:t,isOpen:n,getTheme:r=()=>null,views:o=Qs},s=document){let i=s.querySelector(`[${Jt}]`);if(i)return i;if(!s.querySelector(`[${iu}]`)){let R=s.createElement("style");R.setAttribute(iu,""),R.setAttribute("editor-ui",""),s.getElementById(su)||(R.id=su),R.setAttribute("no-save",""),R.setAttribute("snapshot-remove",""),R.setAttribute("save-ignore",""),R.textContent=Wp,s.head.insertBefore(R,s.head.firstChild)}let l=s.createElement("hypercms-toggle");l.className="hcms-shell pixel-quiet",s.getElementById(ou)||(l.id=ou),l.setAttribute(Jt,""),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,c=l.querySelector(".hcms-toggle__main"),h=Qs.filter(R=>o.includes(R)),u=h.length>1,f=u?eg(s):null,p=u?tg(s,h):null;u&&(l.setAttribute(hu,""),l.appendChild(f),l.appendChild(p)),Go(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)"}),Go(c,{background:Il}),f&&Go(f,{background:Il}),p&&Go(p,{position:"absolute",right:"0",bottom:"calc(100% + 8px)","z-index":"var(--hcms-toggle-z, 2147482900)",display:"none"});let m=()=>p?[...p.querySelectorAll('[role="menuitemradio"]')]:[];function y(R){if(!(!R||typeof R.focus!="function"))try{R.focus({preventScroll:!0})}catch{R.focus()}}function g(R){let D=m();D.length&&y(D[(R+D.length)%D.length])}function d(){let R=lu(a);for(let D of m())D.setAttribute("aria-checked",String(D.getAttribute("data-hcms-view")===R))}function k(R){l.contains(R.target)||v()}function A(R){p&&(p.hidden=!R,Go(p,{display:R?"block":"none"}),f.setAttribute("aria-expanded",String(R)),R?(d(),s.addEventListener("pointerdown",k,!0)):s.removeEventListener("pointerdown",k,!0))}function w(R=0){A(!0),g(R)}function v({focusArrow:R=!1}={}){!p||p.hidden||(A(!1),R&&y(f))}function E(){let R=lu(a);return R&&h.includes(R)?R:null}async function N(R){await e({view:R}),Hp(a,R)}async function _(){if(n()){t();return}let R=E();return R?e({view:R}):u?w():e(h[0]?{view:h[0]}:{})}async function M(R){try{await R()}catch(D){console.warn("hypercms: toggle failed to open the CMS",D)}}l.addEventListener("click",async R=>{f&&f.contains(R.target)||p&&p.contains(R.target)||await M(_)}),f&&(f.addEventListener("click",R=>{R.preventDefault(),p.hidden?w():v({focusArrow:!0})}),f.addEventListener("keydown",R=>{if(R.key==="ArrowUp"){R.preventDefault(),w(-1);return}(R.key==="ArrowDown"||R.key==="Enter"||R.key===" ")&&(R.preventDefault(),w(0))}),p.addEventListener("click",R=>{let D=R.target.closest?.('[role="menuitemradio"]');D&&(R.preventDefault(),v(),M(()=>N(D.getAttribute("data-hcms-view"))))}),p.addEventListener("keydown",R=>{let D=m(),F=D.indexOf(s.activeElement);switch(R.key){case"ArrowDown":R.preventDefault(),g(F+1);break;case"ArrowUp":R.preventDefault(),g(F-1);break;case"Home":R.preventDefault(),g(0);break;case"End":R.preventDefault(),g(D.length-1);break;case"Enter":case" ":if(R.preventDefault(),F===-1)break;v(),M(()=>N(D[F].getAttribute("data-hcms-view")));break;case"Escape":R.preventDefault(),v({focusArrow:!0});break;case"Tab":v();break}}));let j=R=>{let D=r();l.classList.toggle("light",D==="light"),l.classList.toggle("dark",D==="dark"),R?l.setAttribute(Zs,"open"):l.removeAttribute(Zs)};return j(n()),s.addEventListener("hcms:open",()=>j(!0)),s.addEventListener("hcms:close",()=>j(!1)),s.body.appendChild(l),br(s),Zp(l),l}function eg(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 tg(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=$p[r],n.appendChild(o)}return n}function gu(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)&&Qp(e)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n,{once:!0}):n()}function bu(e){if(kf(e),typeof document<"u"){let t=document.getElementById("hcms-shell-styles");t?.tagName==="LINK"&&t.remove(),br(document)}}var Pl={sidebar:Ef,inline:Kf};function ei(e={}){let t=e.view||(Ct.isOpen?Ct.ctx.view.name:"sidebar"),n=Pl[t];if(!n)throw new Error(`hypercms: unknown view "${t}" (expected ${Object.keys(Pl).join(" or ")})`);let r=Ct.isOpen?{...Ct.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(Ct.isOpen){if(Ct.ctx.view.name===t)return;i=Ct.ctx.previouslyFocused,l=Ct.ctx.view.name,Js(Ct.ctx,{restoreFocus:!1,updateUrl:!1,reason:"switch"})}Ff();let a=n({doc:s,pageRoot:o,opts:r}),c=eu({view:a,doc:s,pageRoot:o,opts:r,onCloseRequested:()=>jl(),onViewRequested:h=>ei({view:h})});i&&(c.previouslyFocused=i);try{a.mount(c.initialData),tu(c),a.focusOnOpen(),Ct.isOpen=!0,Ct.ctx=c,Ct.opts=r,c.dispatch("hcms:open",{pageRoot:o,previous:l})}catch(h){throw Js(c,{dispatch:!1,restoreFocus:!!i,updateUrl:!1}),h}}function jl(){Ct.isOpen&&Js(Ct.ctx)}function ku(){Ct.isOpen&&Ct.ctx.view.refresh("api")}function ng(){return Ct.isOpen}function rg(){return Ct.isOpen&&Ct.ctx?Ct.ctx.view.name:null}var og={getData(){return Ct.isOpen?Tn(Ct.ctx):null},setValue(e,t){if(!Ct.isOpen)throw new Error("hypercms: cms is not open");let n=Ct.ctx,r=tr(e),o=Or(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=Ps(n.formRoot,e);if(!s)throw new Error(`hypercms: no field element at path "${e}"`);js(s,t,n.formRoot,e),Mn(Tn(n),{path:e,structural:!1},n)},addItem(e){if(!Ct.isOpen)throw new Error("hypercms: cms is not open");Fo(e,Ct.ctx)},removeItem(e){if(!Ct.isOpen)throw new Error("hypercms: cms is not open");let t=Ct.ctx,n=tr(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=Or(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="${cg(e)}"]`);if(!i)throw new Error(`hypercms: no element at path "${e}"`);lo(i,t)},refresh:ku,_commit(){if(!Ct.isOpen)return;let e=Ct.ctx;return Ds(e.formRoot),Cr("Update",()=>Mn(Tn(e),{path:"",structural:!0},e))}},sg=250,ig=1e4;function lg(){typeof window>"u"||typeof document>"u"||ru(window.location?window.location.search:"")&&(Ct.isOpen||ag(()=>{if(!Ct.isOpen)try{ei()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function Ll(){return!!document.body&&!!dn("Mutation")}function ag(e){if(Ll()){queueMicrotask(e);return}let t=Date.now()+ig,n=!1,r=null,o=null,s=()=>{n||(n=!0,r!==null&&clearInterval(r),o&&o())};function i(){if(Ct.isOpen){s();return}Ll()&&(s(),e())}o=oo(document,Qc,i),r=setInterval(()=>{if(Ct.isOpen){s();return}if(Ll()){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."))},sg)}lg();gu({open:ei,close:jl,isOpen:ng,getTheme:()=>Ct.opts?.theme,views:Object.keys(Pl),hasRules:e=>!!wn.findRules(e,"cms")});var Dl={open:ei,close:jl,refresh:ku,api:og,get isOpen(){return Ct.isOpen},currentView:rg,path:el,scaffold:jo,morphForm:bs};function cg(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var yu=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
|
|
308
|
+
`;function cg({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 Pl=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 fg(e){if(Pl.has(e))return Pl.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 Pl.set(e,t),t}function ug(e,t){let n=String(e??"").trim();if(!n)return null;let r=dg(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=fg(t);return s?Tu(s,n):null}function dg(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 yu({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 ku(e,t){let n=yu(e),r=yu(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var xu={r:10,g:10,b:10},vu={r:250,g:250,b:250};function wu(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 hg(e){if(!e)return"light";let t=ku(wu(e,xu),xu),n=ku(wu(e,vu),vu);return t>n?"dark":"light"}function Xo(e,t){for(let[n,r]of Object.entries(t))e.style.setProperty(n,r,"important")}function jl(e){let t=e.ownerDocument&&e.ownerDocument.defaultView,n=e.querySelector(".hcms-toggle__main");if(!t||!n||typeof t.getComputedStyle!="function")return;let r=ug(t.getComputedStyle(n).color,e.ownerDocument);e.setAttribute("data-hcms-surface",hg(r))}function mg(e){jl(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?jl(e):l();r=n.requestAnimationFrame(()=>{if(r=0,!e.isConnected)return l();jl(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 pg({open:e,close:t,isOpen:n,getTheme:r=()=>null,views:o=ti},s=document){let i=s.querySelector(`[${Jt}]`);if(i)return i;if(!s.querySelector(`[${gu}]`)){let R=s.createElement("style");R.setAttribute(gu,""),R.setAttribute("editor-ui",""),s.getElementById(pu)||(R.id=pu),R.setAttribute("no-save",""),R.setAttribute("snapshot-remove",""),R.setAttribute("save-ignore",""),R.textContent=ag,s.head.insertBefore(R,s.head.firstChild)}let l=s.createElement("hypercms-toggle");l.className="hcms-shell pixel-quiet",s.getElementById(mu)||(l.id=mu),l.setAttribute(Jt,""),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,c=l.querySelector(".hcms-toggle__main"),d=ti.filter(R=>o.includes(R)),u=d.length>1,f=u?gg(s):null,p=u?bg(s,d):null;u&&(l.setAttribute(Au,""),l.appendChild(f),l.appendChild(p)),Xo(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)"}),Xo(c,{background:Dl}),f&&Xo(f,{background:Dl}),p&&Xo(p,{position:"absolute",right:"0",bottom:"calc(100% + 8px)","z-index":"var(--hcms-toggle-z, 2147482900)",display:"none"});let m=()=>p?[...p.querySelectorAll('[role="menuitemradio"]')]:[];function k(R){if(!(!R||typeof R.focus!="function"))try{R.focus({preventScroll:!0})}catch{R.focus()}}function g(R){let D=m();D.length&&k(D[(R+D.length)%D.length])}function h(){let R=bu(a);for(let D of m())D.setAttribute("aria-checked",String(D.getAttribute("data-hcms-view")===R))}function y(R){l.contains(R.target)||v()}function A(R){p&&(p.hidden=!R,Xo(p,{display:R?"block":"none"}),f.setAttribute("aria-expanded",String(R)),R?(h(),s.addEventListener("pointerdown",y,!0)):s.removeEventListener("pointerdown",y,!0))}function w(R=0){A(!0),g(R)}function v({focusArrow:R=!1}={}){!p||p.hidden||(A(!1),R&&k(f))}function E(){let R=bu(a);return R&&d.includes(R)?R:null}async function N(R){await e({view:R}),sg(a,R)}async function _(){if(n()){t();return}let R=E();return R?e({view:R}):u?w():e(d[0]?{view:d[0]}:{})}async function M(R){try{await R()}catch(D){console.warn("hypercms: toggle failed to open the CMS",D)}}l.addEventListener("click",async R=>{f&&f.contains(R.target)||p&&p.contains(R.target)||await M(_)}),f&&(f.addEventListener("click",R=>{R.preventDefault(),p.hidden?w():v({focusArrow:!0})}),f.addEventListener("keydown",R=>{if(R.key==="ArrowUp"){R.preventDefault(),w(-1);return}(R.key==="ArrowDown"||R.key==="Enter"||R.key===" ")&&(R.preventDefault(),w(0))}),p.addEventListener("click",R=>{let D=R.target.closest?.('[role="menuitemradio"]');D&&(R.preventDefault(),v(),M(()=>N(D.getAttribute("data-hcms-view"))))}),p.addEventListener("keydown",R=>{let D=m(),B=D.indexOf(s.activeElement);switch(R.key){case"ArrowDown":R.preventDefault(),g(B+1);break;case"ArrowUp":R.preventDefault(),g(B-1);break;case"Home":R.preventDefault(),g(0);break;case"End":R.preventDefault(),g(D.length-1);break;case"Enter":case" ":if(R.preventDefault(),B===-1)break;v(),M(()=>N(D[B].getAttribute("data-hcms-view")));break;case"Escape":R.preventDefault(),v({focusArrow:!0});break;case"Tab":v();break}}));let j=R=>{let D=r();l.classList.toggle("light",D==="light"),l.classList.toggle("dark",D==="dark"),R?l.setAttribute(ei,"open"):l.removeAttribute(ei)};return j(n()),s.addEventListener("hcms:open",()=>j(!0)),s.addEventListener("hcms:close",()=>j(!1)),s.body.appendChild(l),yr(s),mg(l),l}function gg(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 bg(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=og[r],n.appendChild(o)}return n}function Eu(e){if(typeof window>"u"||typeof document>"u")return;let t=window.__hyperclayEditMode!=null?window.__hyperclayEditMode:null;if(!cg({search:window.location.search,cookie:document.cookie,forced:t}))return;let n=()=>{document.body&&e.hasRules(document)&&pg(e)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n,{once:!0}):n()}function Ou(e){if(Nf(e),typeof document<"u"){let t=document.getElementById("hcms-shell-styles");t?.tagName==="LINK"&&t.remove(),yr(document)}}var Bl={sidebar:jf,inline:ru};function ni(e={}){let t=e.view||(Ct.isOpen?Ct.ctx.view.name:"sidebar"),n=Bl[t];if(!n)throw new Error(`hypercms: unknown view "${t}" (expected ${Object.keys(Bl).join(" or ")})`);let r=Ct.isOpen?{...Ct.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(Ct.isOpen){if(Ct.ctx.view.name===t)return;i=Ct.ctx.previouslyFocused,l=Ct.ctx.view.name,Qs(Ct.ctx,{restoreFocus:!1,updateUrl:!1,reason:"switch"})}Yf();let a=n({doc:s,pageRoot:o,opts:r}),c=fu({view:a,doc:s,pageRoot:o,opts:r,onCloseRequested:()=>ql(),onViewRequested:d=>ni({view:d})});i&&(c.previouslyFocused=i);try{a.mount(c.initialData),uu(c),a.focusOnOpen(),Ct.isOpen=!0,Ct.ctx=c,Ct.opts=r,c.dispatch("hcms:open",{pageRoot:o,previous:l})}catch(d){throw Qs(c,{dispatch:!1,restoreFocus:!!i,updateUrl:!1}),d}}function ql(){Ct.isOpen&&Qs(Ct.ctx)}function Nu(){Ct.isOpen&&Ct.ctx.view.refresh("api")}function yg(){return Ct.isOpen}function kg(){return Ct.isOpen&&Ct.ctx?Ct.ctx.view.name:null}var xg={getData(){return Ct.isOpen?Tn(Ct.ctx):null},setValue(e,t){if(!Ct.isOpen)throw new Error("hypercms: cms is not open");let n=Ct.ctx,r=tr(e),o=Nr(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=Ds(n.formRoot,e);if(!s)throw new Error(`hypercms: no field element at path "${e}"`);Fs(s,t,n.formRoot,e),Mn(Tn(n),{path:e,structural:!1},n)},addItem(e){if(!Ct.isOpen)throw new Error("hypercms: cms is not open");Uo(e,Ct.ctx)},removeItem(e){if(!Ct.isOpen)throw new Error("hypercms: cms is not open");let t=Ct.ctx,n=tr(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=Nr(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="${Tg(e)}"]`);if(!i)throw new Error(`hypercms: no element at path "${e}"`);ao(i,t)},refresh:Nu,_commit(){if(!Ct.isOpen)return;let e=Ct.ctx;return Bs(e.formRoot),Mr("Update",()=>Mn(Tn(e),{path:"",structural:!0},e))}},vg=250,wg=1e4;function Ag(){typeof window>"u"||typeof document>"u"||hu(window.location?window.location.search:"")&&(Ct.isOpen||Sg(()=>{if(!Ct.isOpen)try{ni()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function Fl(){return!!document.body&&!!dn("Mutation")}function Sg(e){if(Fl()){queueMicrotask(e);return}let t=Date.now()+wg,n=!1,r=null,o=null,s=()=>{n||(n=!0,r!==null&&clearInterval(r),o&&o())};function i(){if(Ct.isOpen){s();return}Fl()&&(s(),e())}o=so(document,ff,i),r=setInterval(()=>{if(Ct.isOpen){s();return}if(Fl()){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."))},vg)}Ag();Eu({open:ni,close:ql,isOpen:yg,getTheme:()=>Ct.opts?.theme,views:Object.keys(Bl),hasRules:e=>!!wn.findRules(e,"cms")});var Ul={open:ni,close:ql,refresh:Nu,api:xg,get isOpen(){return Ct.isOpen},currentView:kg,path:ol,scaffold:Fo,morphForm:ks};function Tg(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var _u=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
|
|
309
309
|
Source of truth: mirk-interface/mirk.css + src/theme/pixel-quiet.overrides.css.
|
|
310
310
|
Regenerate with: npm run build:theme */
|
|
311
311
|
|
|
@@ -2201,4 +2201,4 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
2201
2201
|
will-change: transform;
|
|
2202
2202
|
}
|
|
2203
2203
|
.hcms-inline-highlight[hidden] { display: none; }
|
|
2204
|
-
`;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)})})})();
|
|
2204
|
+
`;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)})})})();Ou(_u);var Ng=Ul,_g={cms:Ul};return Pu(Cg);})();
|