hyper-html-api 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -5
- package/conformance/MANIFEST.json +2 -2
- package/conformance/cases/write-query-attribute.after.html +1 -0
- package/conformance/cases/write-query-attribute.after.json +3 -0
- package/conformance/cases/write-query-attribute.data.json +1 -0
- package/conformance/cases/write-query-attribute.html +1 -0
- package/conformance/cases/write-query-attribute.meta +4 -0
- package/conformance/cases/write-query-attribute.parsed.json +3 -0
- package/conformance/cases/write-query-attribute.rules +1 -0
- package/conformance/cases/write-query-attribute.write.json +4 -0
- package/conformance/cases/write-query-list.after.html +1 -0
- package/conformance/cases/write-query-list.after.json +10 -0
- package/conformance/cases/write-query-list.data.json +1 -0
- package/conformance/cases/write-query-list.html +1 -0
- package/conformance/cases/write-query-list.meta +6 -0
- package/conformance/cases/write-query-list.parsed.json +8 -0
- package/conformance/cases/write-query-list.rules +1 -0
- package/conformance/cases/write-query-list.write.json +4 -0
- package/conformance/cases/write-query-noop.after.html +1 -0
- package/conformance/cases/write-query-noop.after.json +3 -0
- package/conformance/cases/write-query-noop.data.json +1 -0
- package/conformance/cases/write-query-noop.html +1 -0
- package/conformance/cases/write-query-noop.meta +4 -0
- package/conformance/cases/write-query-noop.parsed.json +3 -0
- package/conformance/cases/write-query-noop.rules +1 -0
- package/conformance/cases/write-query-noop.write.json +4 -0
- package/conformance/cases/write-query-override.after.html +1 -0
- package/conformance/cases/write-query-override.after.json +3 -0
- package/conformance/cases/write-query-override.data.json +1 -0
- package/conformance/cases/write-query-override.html +1 -0
- package/conformance/cases/write-query-override.meta +4 -0
- package/conformance/cases/write-query-override.parsed.json +3 -0
- package/conformance/cases/write-query-override.rules +1 -0
- package/conformance/cases/write-query-override.write.json +4 -0
- package/conformance/cases/write-query-refused.data.json +1 -0
- package/conformance/cases/write-query-refused.error.json +11 -0
- package/conformance/cases/write-query-refused.html +1 -0
- package/conformance/cases/write-query-refused.meta +4 -0
- package/conformance/cases/write-query-refused.parsed.json +4 -0
- package/conformance/cases/write-query-refused.rules +1 -0
- package/conformance/cases/write-query-text.after.html +1 -0
- package/conformance/cases/write-query-text.after.json +3 -0
- package/conformance/cases/write-query-text.data.json +1 -0
- package/conformance/cases/write-query-text.html +1 -0
- package/conformance/cases/write-query-text.meta +4 -0
- package/conformance/cases/write-query-text.parsed.json +3 -0
- package/conformance/cases/write-query-text.rules +1 -0
- package/conformance/cases/write-query-text.write.json +4 -0
- package/dist/hyper-html-api.engine.min.js +1 -1
- package/dist/hyper-html-api.min.js +6 -5
- package/dist/hyper-html-api.upgrade.min.js +2 -2
- package/package.json +2 -2
- package/src/dom-api.js +149 -23
- package/src/lib/content-dom.js +7 -5
- package/src/write.js +20 -10
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
var HyperHtmlApi=(()=>{var
|
|
2
|
-
`)?{type:"textarea"}:{type:"text"}}function hi(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=Cn(e).selector;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function pi(e){if(e.type==="textarea")return document.createElement("textarea");if(e.type==="select")return document.createElement("select");let t=document.createElement("input");return t.type=e.type==="checkbox"?"checkbox":e.type==="number"?"number":"text",t}function No(e){return typeof e=="number"?`#${e+1}`:String(e).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^\w/,t=>t.toUpperCase())}function mi(e){return` \xB7 ${e}`}function Oo(e,t){if(typeof e=="string"){let n=t&&t.defaultView,o=n&&n.DOMParser||globalThis.DOMParser;return new o().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Fo(e){let t=new Map;return(n,o)=>{if(typeof o!="string")return Oo(o,e);let r=t.get(n);if(r&&r.text===o)return r.doc;let s=Oo(o,e);return t.set(n,{text:o,doc:s}),s}}function Fr(e,t){let n=t.doctype;if(!n)return!1;let o=e.doctype;if(o&&o.name===n.name&&o.publicId===n.publicId&&o.systemId===n.systemId)return!1;let r=e.implementation.createDocumentType(n.name,n.publicId,n.systemId);return o?e.replaceChild(r,o):e.insertBefore(r,e.documentElement),!0}function Vo(e,t=[]){if(typeof e!="function")return()=>!1;let n=new WeakMap,o=new Set(t);return r=>{if(!r||r.nodeType!==1)return!1;let s=n.get(r);if(s!==void 0)return s;let c=[],l=r,a=!1;for(;l&&l.nodeType===1;){let b=n.get(l);if(b!==void 0){a=b;break}if(c.push(l),e(l,o.has(l))){a=!0;break}if(o.has(l))break;l=l.parentElement}for(let b of c)n.set(b,a);return a}}var gi="~",Vr="^";function zo(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let o=t[gi],r=typeof o=="string"?o.split(",").map(Number):null,s=r&&typeof t[Vr]=="string"?t[Vr].split(","):null,c=g=>Number.isInteger(g)&&g>=0,l=0,a=!1,b=g=>{let m=g;for(;m>0;){let u=r[l++];if(l>r.length||!c(u))return!1;m+=u-1}return!0},p=(g,m)=>{if(a)return;if(r){let y=l++,S=r[y];if(y>=r.length||!c(S)){a=!0;return}let v=!s||s[y]===g.tagName.toLowerCase();if(!v||S!==g.children.length){let D=v&&t[m];typeof D=="string"&&D&&n.set(g,D),b(S)||(a=!0);return}}let u=t[m];typeof u=="string"&&u&&n.set(g,u);let h=g.children;for(let y=0;y<h.length;y++)p(h[y],m===""?String(y):`${m}.${y}`)};return p(e,""),n}function zr(e){return t=>{for(let n of e){let o=n(t);if(typeof o=="string"&&o!=="")return o}return null}}var wn=zr([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Mo(e,t,n,o=null){let r=new Map,s=new Set,c=l=>{if(n(l))return;let a=t(l);a&&(r.has(a)?s.add(a):r.set(a,l))};if(o){let l=a=>{for(let b of a.querySelectorAll(o))c(b);for(let b of a.querySelectorAll("template"))b.content&&l(b.content)};c(e),l(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let l=a=>{c(a);let b=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let p=0;p<b.length;p++)l(b[p])};l(e)}for(let l of s)r.delete(l),l.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${l.slice(l.indexOf(":",6)+1)}"`);return r}var bi=new Set(["href","src","name","type","role"]),Kr=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function Ln(e,t=5381){let n=t;for(let o=0;o<e.length;o++)n=(n<<5)+n^e.charCodeAt(o);return n>>>0}function qr(e){return e.replace(/\s+/g," ")}function Gr({ignored:e=()=>!1,ignoreAttribute:t=()=>!1}={}){let n=new WeakMap,o=new WeakMap;function r(m){let u=m.attributes,h=u.length;if(h===0)return{all:"",sig:m.tagName+"|"};let y=[],S="",v=[];for(let D=0;D<h;D++){let q=u[D],Z=q.name;t(m,Z)||y.push(Z+"="+q.value),Z==="class"?S=q.value.indexOf(" ")<0?q.value:q.value.split(/\s+/).filter(Boolean).sort().join(" "):bi.has(Z)&&v.push(Z+"="+q.value)}return y.length>1&&y.sort(),v.length>1&&v.sort(),{all:y.join(""),sig:m.tagName+"|"+S+(v.length?"|"+v.join("|"):"")}}function s(m){return m.nodeType===1&&m.tagName==="TEMPLATE"&&m.content?m.content.childNodes:m.childNodes}function c(m){let u=n.get(m);if(u)return u;if(m.nodeType===3)u={hash:"T"+Ln(m.nodeValue),hint:qr(m.nodeValue).slice(0,64),sig:null,tok:null};else if(m.nodeType===8)u={hash:"C"+Ln(m.nodeValue),hint:"",sig:null,tok:null};else if(m.nodeType===1){let h=r(m),y=Ln(m.tagName+""+h.all),S="";for(let v of a(m))if(v.nodeType===1){let D=c(v);y=Ln(D.hash,y),S.length<64&&(S+=" "+D.hint)}else y=Ln(b(v),y),v.kind==="text"&&S.length<64&&(S+=v.value.slice(0,64));u={hash:"E"+y,hint:qr(S).trim().slice(0,64),sig:h.sig,tok:null}}else u={hash:"N"+m.nodeType,hint:"",sig:null,tok:null};return n.set(m,u),u}function l(m){if(!m.tok){m.tok=new Set;for(let u of m.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))u&&m.tok.add(u)}return m.tok}function a(m){let u=o.get(m);if(u)return u;u=[];let h=null,y=()=>{h&&(h.value=h.nodes.map(S=>S.nodeValue).join(""),u.push(h),h=null)};for(let S of s(m)){if(S.nodeType===3){h||(h={kind:"text",nodes:[],value:"",parent:m,hash:void 0}),h.nodes.push(S);continue}y(),S.nodeType===8?u.push({kind:"comment",nodes:[S],value:S.nodeValue,parent:m,hash:void 0}):S.nodeType===1&&!e(S)&&u.push(S)}return y(),o.set(m,u),u}function b(m){return m.nodeType===1?c(m).hash:(m.hash===void 0&&(m.hash=(m.kind==="text"?"T":"C")+Ln(m.value)),m.hash)}function p(m,u){let h=l(c(m)),y=l(c(u));if(h.size===0&&y.size===0)return{coef:1,share:1};if(h.size===0||y.size===0)return null;let S=0;for(let v of h)y.has(v)&&S++;return{coef:S/Math.min(h.size,y.size),share:S/Math.max(h.size,y.size)}}function g(m,u){let h=p(m,u);return!!h&&h.coef>=.5}return{meta:c,unitsOf:a,unitHash:b,similar:g,score:p,childrenOf:s}}var Jr=16,yi=2e3,ki=3,wi={align:0};function qo(e,t,n){let{meta:o,unitsOf:r,unitHash:s,similar:c,score:l}=n.analyzer,a=n.baseId||(()=>null),b=n.sideId||(()=>null),p=new Map,g=new Map,m=new Set,u=new Map,h=new Set,y=new Set,S=new Set,v=[],D=[],q=[],Z=[],ae=yi,ie=new Map,he=new Map,K=(f,T)=>{p.set(f,T),g.set(T,f)},J=f=>!!f&&f.nodeType===1,ye=(f,T)=>{let x=u.get(f);return!!x&&x.has(T)},je=f=>Kr.has(f.tagName),Fe=(f,T)=>{let x=a(f);if(!x)return!0;let B=b(T);return!B||x===B},ot=globalThis.__hyperMorphProfile,ct=ot?performance.now():0;ot&&(o(e),o(t),ot.meta=(ot.meta||0)+(performance.now()-ct),ct=performance.now()),K(e,t);for(let[f,T]of n.baseIndex){let x=n.sideIndex.get(f);x&&x.tagName===T.tagName&&!p.has(T)&&!g.has(x)&&K(T,x)}Z.push([e,t]);for(let[f,T]of p)J(f)&&f!==e&&Z.push([f,T]);return dt(),Ct(),ot&&(ot.align=(ot.align||0)+(performance.now()-ct)),{map:p,reverse:g,moved:h,identical:y,pairIdenticalChildren:F,weak:m,unpair:vt,rematch:Ct,insertedByHash:Oe};function Ct(){at(),dt();for(let f=0;f<q.length;){let T=q.length;rt(f,T),f=T,dt(),at(),dt()}}function vt(f){let T=p.get(f);if(!T)return;u.has(f)||u.set(f,new Set),u.get(f).add(T);let x=(I,E)=>{p.delete(I),g.delete(E),h.delete(I),y.delete(I),m.delete(I),S.delete(I)},B=(I,E)=>{for(let j of r(I)){let M=p.get(j);!M||!(J(M)?E.contains(M):E.contains(M.nodes[0]))||(x(j,M),J(j)&&B(j,M))}};x(f,T),J(f)&&B(f,T),v.push(f),D.push(T)}function Oe(){let f=new Map;for(let T of new Set(D)){if(g.has(T))continue;let x=o(T).hash;f.has(x)||f.set(x,[]),f.get(x).push(T)}return f}function dt(){for(;Z.length;){let[f,T]=Z.shift();S.has(f)||y.has(f)||Lt(f,T)}}function Qe(f,T){if(!je(f))for(let x of r(f))J(x)&&(T.push(x),Qe(x,T))}function Lt(f,T){S.add(f);let x=r(f),B=r(T);wi.align+=x.length+B.length,ie=new Map,he=new Map;for(let P=0;P<x.length;P++)ie.set(x[P],P);for(let P=0;P<B.length;P++)he.set(B[P],P);if(f.tagName==="HTML")for(let P of["HEAD","BODY"]){let Y=x.find(we=>J(we)&&we.tagName===P),Q=B.find(we=>J(we)&&we.tagName===P);Y&&Q&&!p.has(Y)&&!g.has(Q)&&K(Y,Q)}for(let P=0;P<x.length&&P<B.length;P++){let Y=x[P],Q=B[P];p.has(Y)||g.has(Q)||(J(Y)?J(Q)&&Y.tagName===Q.tagName&&Y.isEqualNode(Q)&&O(Y,Q):!J(Q)&&Y.kind===Q.kind&&Y.value===Q.value&&O(Y,Q))}Ze(x,B);let I=x.filter(P=>!p.has(P)),E=B.filter(P=>!g.has(P));I.length&&E.length&&(lt(I,E),ke(I,E),re(I,E,x,B),qe(x,B));let j=!1,M=!1;for(let P of x){if(!p.has(P)){J(P)&&(v.push(P),Qe(P,v),j=!0);continue}J(P)&&!y.has(P)&&Z.push([P,p.get(P)])}for(let P of B)!g.has(P)&&J(P)&&(D.push(P),Qe(P,D),M=!0);j&&M&&q.push([f,T])}function rt(f,T){for(let x=f;x<T;x++){let[B,I]=q[x],E=r(B),j=r(I),M=new Map,P=new Map,Y=null;for(let Q of E)J(Q)&&(p.has(Q)?Y=Q:(M.has(Y)||M.set(Y,[]),M.get(Y).push(Q)));Y=null;for(let Q of j)J(Q)&&(g.has(Q)?Y=g.get(Q):(P.has(Y)||P.set(Y,[]),P.get(Y).push(Q)));for(let[Q,we]of M){let Ye=P.get(Q);if(!(!Ye||we.length!==Ye.length)&&we.every((bt,ft)=>Ye[ft].tagName===bt.tagName&&Fe(bt,Ye[ft])&&!ye(bt,Ye[ft])))for(let bt=0;bt<we.length;bt++)et(we[bt],Ye[bt])}}}function et(f,T){K(f,T),m.add(f),Z.push([f,T]),dt()}function lt(f,T){let x=Rn(f,s),B=Rn(T,s),I=new Map;for(let E of T){let j=s(E);B.get(j)===1&&I.set(j,E)}for(let E of f){if(p.has(E))continue;let j=s(E);if(x.get(j)!==1)continue;let M=I.get(j);M&&!g.has(M)&&O(E,M)}}function O(f,T){K(f,T),y.add(f),J(f)&&S.add(f)}function F(f){let T=p.get(f);if(!T||!J(f))return;let x=r(f),B=r(T);for(let I=0;I<x.length&&I<B.length;I++)p.has(x[I])||O(x[I],B[I])}function ke(f,T){let x=j=>J(j)&&!je(j)?o(j).sig+""+o(j).hint:null,B=Rn(f,x),I=Rn(T,x),E=new Map;for(let j of T){let M=x(j);M!=null&&I.get(M)===1&&E.set(M,j)}for(let j of f){if(p.has(j))continue;let M=x(j);if(M==null||B.get(M)!==1)continue;let P=E.get(M);P&&!g.has(P)&&Fe(j,P)&&K(j,P)}}function re(f,T,x,B){let I=new Map;for(let j of T){if(!J(j)||g.has(j)||je(j))continue;let M=o(j).sig;I.has(M)||I.set(M,[]),I.get(M).push({el:j,index:he.get(j)})}let E=[];for(let j of f){if(p.has(j)||!J(j)||je(j))continue;let M=I.get(o(j).sig);if(!M||!M.length)continue;let P=ie.get(j),Y=M.filter(Q=>!g.has(Q.el)).map(Q=>({c:Q,d:Math.abs(Q.index-P)}));Y.sort((Q,we)=>Q.d-we.d),Y.length>Jr&&(Y=Y.slice(0,Jr));for(let{c:Q,d:we}of Y){if(!Fe(j,Q.el))continue;let Ye=l(j,Q.el);Ye&&Ye.coef>=.5&&E.push({b:j,s:Q.el,coef:Ye.coef,share:Ye.share,d:we,bi:P})}}E.sort((j,M)=>M.coef-j.coef||M.share-j.share||j.d-M.d||j.bi-M.bi);for(let j of E)!p.has(j.b)&&!g.has(j.s)&&K(j.b,j.s)}function Ne(f,T){return J(f)!==J(T)?!1:J(f)?f.tagName!==T.tagName||!Fe(f,T)?!1:je(f)||o(f).hint===""||o(T).hint===""?!0:c(f,T):f.kind===T.kind}function tt(f,T){let x=(I,E)=>{let j=E===null?-1:I===T?he.get(E):ie.get(E),M=I[j+1];return M&&!J(M)?M:null},B=null;for(let I of f){if(J(I)){B=I;continue}if(p.has(I))continue;let E=B===null?null:p.get(B);if(B!==null&&!E)continue;let j=x(T,E);j&&!g.has(j)&&j.kind===I.kind&&K(I,j)}}function qe(f,T){tt(f,T);let x=Ke(f,T),B=(E,j)=>J(E)&&o(E).hint!==""&&o(j).hint===""&&!!j.querySelector("br")&&!x(E,j),I=0;for(let E of f){if(p.has(E)){let M=he.get(p.get(E));M!==void 0&&M>=I&&(I=M+1);continue}let j=0;for(let M=I;M<T.length&&j<ki;M++){let P=T[M];if(!g.has(P)&&(j++,Ne(E,P)&&!ye(E,P)&&!B(E,P))){K(E,P),J(E)&&(o(E).hint===""||o(P).hint==="")&&m.add(E),I=M+1;break}}}Ze(f,T)}function Ke(f,T){let x=(B,I,E)=>{for(let j=I-1;j>=0;j--)if(J(B[j])&&E(B[j]))return B[j];return null};return(B,I)=>{let E=ie.get(B),j=he.get(I);if(E===j)return!0;let M=x(f,E,Y=>p.has(Y)),P=x(T,j,Y=>g.has(Y));return M?p.get(M)===P:!P}}function Ze(f,T){let x=f.filter(M=>J(M)&&!p.has(M)),B=T.filter(M=>J(M)&&!g.has(M));if(!x.length||!B.length)return;let I=Rn(x,M=>M.tagName),E=Rn(B,M=>M.tagName),j=Ke(f,T);for(let M of x){let P=M.tagName;if(I.get(P)!==1||E.get(P)!==1)continue;let Y=B.find(Q=>Q.tagName===P);Y&&!g.has(Y)&&j(M,Y)&&Fe(M,Y)&&!ye(M,Y)&&(K(M,Y),m.add(M))}}function at(){let f=new Map;for(let M of m)if(J(M)&&J(p.get(M))){let P=o(M).hash;f.has(P)||f.set(P,[]),f.get(P).push(M)}if(f.size)for(let M of D){if(g.has(M)||!J(M))continue;let P=f.get(o(M).hash),Y=P&&P.find(Q=>m.has(Q)&&!ye(Q,M)&&Fe(Q,M));Y&&(vt(Y),O(Y,M),h.add(Y))}let T=new Map,x=new Map,B=new Map;for(let M of m){let P=p.get(M);J(M)&&J(P)&&B.set(P,M)}let I=(M,P)=>{if(!g.has(M))return!0;let Y=B.get(M);return Y===g.get(M)&&Y!==P&&!Y.contains(P)},E=M=>{if(g.has(M)){let P=B.get(M);B.delete(M),vt(P)}};for(let M of[...D,...B.keys()]){if(g.has(M)&&!B.has(M))continue;let P=o(M).hash;if(T.has(P)||T.set(P,[]),T.get(P).push(M),je(M))continue;let Y=o(M).sig;x.has(Y)||x.set(Y,[]),x.get(Y).push(M)}let j=new Set;for(let M of m){let P=p.get(M);!J(M)||!J(P)||je(M)||o(M).hint===""||o(P).hint===""||c(M,P)||j.add(M)}for(let M of[...v,...j]){let P=p.get(M);if(P&&!(m.has(M)&&j.has(M)))continue;let Y=ft=>{P&&vt(M),E(ft)},Q=T.get(o(M).hash);if(Q){let ft=Q.find(le=>le!==P&&I(le,M)&&!ye(M,le));if(ft){Y(ft),O(M,ft),h.add(M);continue}}if(je(M)||ae<=0)continue;let we=x.get(o(M).sig);if(!we)continue;let Ye=null,bt=0;for(let ft of we)if(!(ft===P||!I(ft,M)||!Fe(M,ft)||ye(M,ft))&&(ae--<=0||c(M,ft)&&(bt++,Ye=ft,bt>1)))break;bt===1&&(Y(Ye),K(M,Ye),h.add(M),Z.push([M,Ye]))}}}function Rn(e,t){let n=new Map;for(let o of e){let r=t(o);r!=null&&n.set(r,(n.get(r)||0)+1)}return n}var Ai={diff:0},Yr=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,xi=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,Ti=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,Si=/\P{M}\p{M}*/gu;function Xo(e){if(e==="")return[];if(Yr){let n=[];for(let o of Yr.segment(e))n.push(o.segment);return n}let t=[];for(let n of e.match(Ti))if(xi.test(n))for(let o of n.match(Si))t.push(o);else t.push(n);return t}var Ni=/^[ ]+$/,Oi=e=>Ni.test(e)?" ".repeat(e.length):e,Yn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),nt="",Xr=e=>e.every(t=>Yn(t)||t.k===nt),Mi=/^[\x00-\x7f\u00A0]*$/,vi=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Ii(e){return e===""?[]:e.match(vi)}function An(e,t=!1){return(t?Ii(e):Xo(e)).map(n=>({k:Oi(n),raw:n,len:n.length}))}var vo=(...e)=>e.every(t=>Mi.test(t));function Ko(e,t,n){let o=e.length,r=t.length,s=Math.min(o+r,n),c=s+1,l=new Int32Array(2*s+3),a=[],b=o===0&&r===0;for(let u=0;u<=s&&!b;u++){a.push(l.slice(c-u,c+u+1));for(let h=-u;h<=u;h+=2){let y;h===-u||h!==u&&l[c+h-1]<l[c+h+1]?y=l[c+h+1]:y=l[c+h-1]+1;let S=y-h,v=y;for(;y<o&&S<r&&e[y].k===t[S].k;)y++,S++;if(Ai.diff+=1+y-v,l[c+h]=y,y>=o&&S>=r){b=!0;break}}}if(!b)return null;let p=[],g=o,m=r;for(let u=a.length-1;u>0;u--){let h=a[u],y=g-m,S=y+u,v=y===-u||y!==u&&h[S-1]<h[S+1]?y+1:y-1,D=h[v+u],q=D-v;for(;g>D&&m>q;)p.push([0,g-1,m-1]),g--,m--;g===D?(p.push([1,g,m-1]),m--):(p.push([-1,g-1,m]),g--)}for(;g>0&&m>0;)p.push([0,g-1,m-1]),g--,m--;return p.reverse(),p}function Ei(e,t,n){let o=g=>g.k===nt;if(!e.some(o)&&!t.some(o))return Ko(e,t,n);let r=[],s=[];for(let g=0;g<e.length;g++)o(e[g])||r.push(g);for(let g=0;g<t.length;g++)o(t[g])||s.push(g);let c=Ko(r.map(g=>e[g]),s.map(g=>t[g]),n);if(!c)return null;let l=[],a=0,b=0,p=(g,m)=>{for(;a<g&&b<m&&e[a].k===t[b].k;)l.push([0,a++,b++]);let u=Ko(e.slice(a,g),t.slice(b,m),n);if(!u)return!1;for(let[h,y,S]of u)l.push([h,y+a,S+b]);return a=g,b=m,!0};for(let[g,m,u]of c)if(g===0){if(!p(r[m],s[u]))return null;l.push([0,a,b]),a++,b++}return p(e.length,t.length)?l:null}function Pn(e,t,n=4e3){let o=[],r=0;for(;r<e.length&&r<t.length&&e[r].k===t[r].k;)e[r].raw!==t[r].raw&&o.push({bi:r,tok:t[r]}),r++;let s=0;for(;s<e.length-r&&s<t.length-r&&e[e.length-1-s].k===t[t.length-1-s].k;)e[e.length-1-s].raw!==t[t.length-1-s].raw&&o.push({bi:e.length-1-s,tok:t[t.length-1-s]}),s++;let c=e.slice(r,e.length-s),l=t.slice(r,t.length-s),a=Di(c,l)?null:Ei(c,l,n);if(!a){let v=c.length||l.length?[{bs:r,be:r+c.length,toks:l}]:[];return{hunks:v,cosmetic:o,coarse:!0,parts:v.map(D=>({...D,gap:[],group:0})),cosmeticEq:o}}let b=[],p=(v,D)=>{c[v].raw!==l[D].raw&&o.push({bi:r+v,tok:l[D]})},g=null,m=[],u=0,h=0,y=()=>{g&&b.push(g),g=null;for(let[v,D]of m)p(v,D);m=[],u++};for(let[v,D,q]of a){if(v===0){g&&Yn(c[D])&&!c[D].k.includes(`
|
|
3
|
-
`)?m.push([D,q]):(y(),p(D,q)),h=D+1;continue}(!g||m.length)&&(g&&b.push(g),g={bs:r+h,be:r+h,toks:[],gap:m.map(([Z,ae])=>({bi:r+Z,tok:l[ae]})),group:u},m=[]),v===-1?(g.be=r+h+1,h=D+1):g.toks.push(l[q])}y(),Ci(b,e);let S=Jo(b);return{hunks:S.hunks,cosmetic:o.concat(S.cosmetic),parts:b,cosmeticEq:o}}function Ci(e,t){for(let n=0;n<e.length;n++){let o=e[n];if(o.gap.length)continue;let r=n+1<e.length?e[n+1].bs:1/0;if(o.toks.length){if(o.bs===o.be)for(;o.bs+1<r&&o.bs<t.length&&o.toks[0].k===nt&&t[o.bs].k===nt;)o.toks=[...o.toks.slice(1),o.toks[0]],o.bs++,o.be++}else for(;o.be+1<r&&o.be<t.length&&t[o.bs].k===nt&&t[o.be].k===nt;)o.bs++,o.be++}}function Jo(e,t=()=>!1){let n=[],o=[],r=null,s=-1;for(let c of e){let l=t(c);if(r&&!r.alone&&!l&&c.group===s){r.be=c.be;for(let a of c.gap)r.toks.push(a.tok);for(let a of c.toks)r.toks.push(a);continue}r&&n.push({bs:r.bs,be:r.be,toks:r.toks});for(let a of c.gap)o.push(a);r={bs:c.bs,be:c.be,toks:c.toks.slice(),alone:l},s=c.group}return r&&n.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:n,cosmetic:o}}var Li=(e,t)=>e.bs===t.bs&&e.be===t.be&&Qo(e.toks,t.toks);function Zo(e,t,n){let o=p=>g=>p.some(m=>Li(g,m)),r=Jo(e.parts,o(t.parts)),s=Jo(t.parts,o(e.parts)),c=e.cosmeticEq.concat(r.cosmetic),l=t.cosmeticEq.concat(s.cosmetic),[a,b]=n?Ri(r.hunks,s.hunks,n,c,l):[r.hunks,s.hunks];return{lh:a,rh:b,cosL:c,cosR:l}}function Ri(e,t,n,o,r){let s=(u,h)=>u.k===h.k&&u.raw===h.raw,c=[{list:e.map(u=>({...u})),resp:new Set(o.map(u=>u.bi))},{list:t.map(u=>({...u})),resp:new Set(r.map(u=>u.bi))}],l=u=>u.bs===u.be,a=(u,h,y,S)=>{let v=u.list[h];if(!l(v))return S(v)===y?v.toks:null;let D=h?u.list[h-1].be:0,q=h+1<u.list.length?u.list[h+1].bs:n.length;if(y<D||y>q)return null;let Z=v.toks,ae=v.bs;for(;ae>y;){let ie=Z[Z.length-1];if(!s(ie,n[ae-1])||u.resp.has(ae-1))return null;Z=[ie,...Z.slice(0,-1)],ae--}for(;ae<y;){if(!s(Z[0],n[ae])||u.resp.has(ae))return null;Z=[...Z.slice(1),Z[0]],ae++}return Z},b=(u,h,y,S,v,D)=>{let q=u.list[h],Z=v?y.slice(y.length-S):y.slice(0,S),ae=v?y.slice(0,y.length-S):y.slice(S),ie={bs:D,be:D,toks:Z};if(l(q)){if(!ae.length){u.list[h]=ie;return}let K={bs:D,be:D,toks:ae};v&&(K.lead=!0),u.list.splice(h,1,...v?[K,ie]:[ie,K]);return}let he={bs:q.bs,be:q.be,toks:ae};u.list.splice(h,1,...v?[he,ie]:[ie,he])},p=(u,h,y,S,v)=>{let D=u.list[h],q=v?y.slice(y.length-S):y.slice(0,S),Z=v?y.slice(0,y.length-S):y.slice(S),ae={bs:D.bs,be:D.be,toks:q};if(!Z.length){u.list[h]=ae;return}let ie=v?{bs:D.bs,be:D.bs,toks:Z,lead:!0}:{bs:D.be,be:D.be,toks:Z};u.list.splice(h,1,...v?[ie,ae]:[ae,ie])},g=c[0],m=c[1];for(let u=0;u<64;u++){let h=!1;e:for(let y=0;y<g.list.length;y++)for(let S=0;S<m.list.length;S++){let v=g.list[y],D=m.list[S];if(!(v.bs===D.bs&&v.be===D.be&&Qo(v.toks,D.toks)))for(let q of[!0,!1]){let Z=ie=>q?ie.be:ie.bs,ae=l(v)?[Z(D),v.bs]:[Z(v)];for(let ie of ae){let he=a(g,y,ie,Z),K=he&&a(m,S,ie,Z);if(!K)continue;let J=(ct,Ct)=>q?ct[ct.length-1-Ct]:ct[Ct],ye=0;for(;ye<he.length&&ye<K.length&&J(he,ye).k===J(K,ye).k;)ye++;if(!ye)continue;let je=q?he.slice(0,he.length-ye):he.slice(ye),Fe=q?K.slice(0,K.length-ye):K.slice(ye);if(!(ye<he.length&&ye<K.length&&!Xr(je)&&!Xr(Fe)&&(l(v)&&l(D)||v.bs===D.bs&&v.be===D.be)||!(q?he.slice(he.length-ye):he.slice(0,ye)).some(ct=>!Yn(ct)))){if(ye===he.length&&ye===K.length&&l(v)&&l(D)){if(v.bs===ie&&D.bs===ie)continue;g.list[y]={bs:ie,be:ie,toks:he},m.list[S]={bs:ie,be:ie,toks:K}}else!l(v)&&v.bs===D.bs&&v.be===D.be?(p(g,y,he,ye,q),p(m,S,K,ye,q)):(b(g,y,he,ye,q,ie),b(m,S,K,ye,q,ie));h=!0;break e}}}}if(!h)break}return[g.list,m.list]}var Pi=48,Hi=.3;function Di(e,t){let n=e.filter(c=>!Yn(c)),o=t.filter(c=>!Yn(c));if(Math.min(n.length,o.length)<Pi)return!1;let r=new Map;for(let c of n)r.set(c.k,(r.get(c.k)||0)+1);let s=0;for(let c of o){let l=r.get(c.k);l>0&&(s++,r.set(c.k,l-1))}return s/Math.min(n.length,o.length)<Hi}var ji=(e,t)=>{let n=new Set;for(let o of e.toks)typeof o.k!="string"&&n.add(o.k.el);for(let o=e.bs;o<e.be;o++)typeof t[o].k!="string"&&n.add(t[o].k.el);return n},Qo=(e,t)=>e.length===t.length&&e.every((n,o)=>n.k===t[o].k);function Zr(e,t,n,o="remote"){let r=Pn(e,t),s=Pn(e,n),{lh:c,rh:l,cosL:a,cosR:b}=Zo(r,s,e),p=O=>O.bs===O.be,g=O=>O.toks.some(F=>typeof F.k=="string"),m=O=>p(O)&&!g(O),u=(O,F)=>F.bs<O.be&&O.bs<F.be,h=(O,F)=>!u(O,F)&&F.bs<=O.be&&O.bs<=F.be&&(p(O)&&g(O)||p(F)&&g(F))&&!(p(O)&&p(F)),y=(O,F)=>O.bs===F.bs&&O.be===F.be&&Qo(O.toks,F.toks),S=[],v=new Set;for(let O of c){let F=l.find(ke=>!v.has(ke)&&y(O,ke));F?(v.add(F),S.push({bs:O.bs,be:O.be,side:"both",l:O,r:F,toks:O.toks})):S.push({bs:O.bs,be:O.be,side:"L",l:O,toks:O.toks,lead:!!O.lead})}for(let O of l)v.has(O)||S.push({bs:O.bs,be:O.be,side:"R",r:O,toks:O.toks,lead:!!O.lead});S.sort((O,F)=>O.bs-F.bs||O.be-F.be||F.lead-O.lead);let D=0,q=0;for(let O of S)O.side==="both"&&(D+=O.toks.length-(O.be-O.bs));let Z=S.map((O,F)=>F),ae=O=>Z[O]===O?O:Z[O]=ae(Z[O]),ie=(O,F)=>(O=ae(O),F=ae(F),O===F?!1:(Z[O]=F,!0)),he=S.map(O=>ji({bs:O.bs,be:O.be,toks:O.toks},e)),K={L:new Map,R:new Map};S.forEach((O,F)=>{let ke=O.side==="both"?["L","R"]:[O.side];for(let re of ke)for(let Ne of he[F])K[re].has(Ne)||K[re].set(Ne,[]),K[re].get(Ne).push(F)});for(let O of[K.L,K.R])for(let F of O.values())for(let ke=1;ke<F.length;ke++)ie(F[0],F[ke]);for(let O=0;O<S.length;O++)for(let F=O+1;F<S.length;F++){let ke=S[O],re=S[F];ke.side===re.side&&ke.side!=="both"||ke.bs>re.be||(u(ke,re)||h(ke,re)?ie(O,F):ke.bs===re.bs&&p(ke)&&p(re)&&q++)}let J=(O,F)=>{let ke=O==="L"?c:l;for(let re of ke)if(re.toks.some(Ne=>Ne.kind==="close"&&Ne.k.el===F.el))return re.bs;for(let re=0;re<e.length;re++)if(e[re].kind==="close"&&e[re].k.el===F.el)return re;return-1};S.forEach((O,F)=>{if(!(!m(O)||O.side==="both"))for(let ke of O.toks){if(ke.kind!=="open")continue;let re=J(O.side,ke.k);if(re<=O.bs)continue;let Ne=new Uint8Array(re-O.bs),tt=[];if(S.forEach((qe,Ke)=>{if(!(qe.side===O.side||p(qe))&&qe.bs<re&&qe.be>O.bs){tt.push(Ke);for(let Ze=Math.max(qe.bs,O.bs);Ze<Math.min(qe.be,re);Ze++)Ne[Ze-O.bs]=1}}),tt.length&&Ne.every(qe=>qe===1))for(let qe of tt)ie(F,qe)}});let ye=!0;for(;ye;){ye=!1;let O=new Map;S.forEach((F,ke)=>{let re=ae(ke),Ne=O.get(re)||{bs:F.bs,be:F.be,L:!1,R:!1};Ne.bs=Math.min(Ne.bs,F.bs),Ne.be=Math.max(Ne.be,F.be),F.side!=="R"&&(Ne.L=!0),F.side!=="L"&&(Ne.R=!0),O.set(re,Ne)}),S.forEach((F,ke)=>{for(let[re,Ne]of O){if(ae(ke)===ae(re)||!(Ne.L&&Ne.R))continue;let tt=F.bs<Ne.be&&F.be>Ne.bs,qe=p(F)&&g(F)&&(F.bs===Ne.be||F.bs===Ne.bs);(tt||qe)&&ie(ke,re)&&(ye=!0)}})}let je=new Map;S.forEach((O,F)=>{let ke=ae(F);je.has(ke)||je.set(ke,[]),je.get(ke).push(O)});let Fe=[];for(let O of je.values()){let F=O.some(re=>re.side==="L"),ke=O.some(re=>re.side==="R");if(F&&ke){let re=Math.min(...O.map(Ke=>Ke.bs)),Ne=Math.max(...O.map(Ke=>Ke.be)),tt=O.filter(Ke=>Ke.side!=="R").map(Ke=>Ke.l).sort((Ke,Ze)=>Ke.bs-Ze.bs),qe=O.filter(Ke=>Ke.side!=="L").map(Ke=>Ke.r).sort((Ke,Ze)=>Ke.bs-Ze.bs);Fe.push({bs:re,be:Ne,kind:"conflict",localHunks:tt,remoteHunks:qe})}else for(let re of O)Fe.push({bs:re.bs,be:re.be,kind:re.side,u:re})}let ot=(O,F)=>{let ke=O==="L"?c:l;for(let re of ke)if(re.toks.some(Ne=>Ne.kind==="close"&&Ne.k.el===F.el))return re.bs+.5;for(let re=0;re<e.length;re++)if(e[re].kind==="close"&&e[re].k.el===F.el)return re;return 1/0},ct=(O,F)=>{let ke=O==="L"?c:l;for(let re of ke)if(re.toks.some(Ne=>Ne.kind==="open"&&Ne.k.el===F.el))return re.bs-.5;for(let re=0;re<e.length;re++)if(e[re].kind==="open"&&e[re].k.el===F.el)return re;return-1/0},Ct=O=>O.kind==="R"?"R":"L",vt=O=>O.kind==="R"?1:0;Fe.sort((O,F)=>{if(O.bs!==F.bs)return O.bs-F.bs;let ke=O.bs===O.be,re=F.bs===F.be;if(ke!==re)return ke?-1:1;if(ke&&re&&O.kind!=="conflict"&&F.kind!=="conflict"){let tt=O.u.toks,qe=F.u.toks,Ke=at=>at.length&&at.every(f=>f.kind==="open"),Ze=at=>at.length&&at.every(f=>f.kind==="close");if(Ke(tt)&&Ke(qe)){let at=Math.max(...tt.map(T=>ot(Ct(O),T.k))),f=Math.max(...qe.map(T=>ot(Ct(F),T.k)));if(at!==f)return f-at}if(Ze(tt)&&Ze(qe)){let at=Math.min(...tt.map(T=>ct(Ct(O),T.k))),f=Math.min(...qe.map(T=>ct(Ct(F),T.k)));return at!==f?f-at:vt(F)-vt(O)}}let Ne=tt=>tt.u&&tt.u.lead?1:0;return Ne(F)-Ne(O)||vt(O)-vt(F)||O.be-F.be});let Oe=[],dt=[],Qe=0,Lt=O=>{O>Qe&&(Oe.push({bs:Qe,be:O,toks:e.slice(Qe,O),source:"base"}),Qe=O)};for(let O of Fe){if(Lt(O.bs),O.kind==="conflict"){let F=Yo(e,O.localHunks,O.bs,O.be),ke=Yo(e,O.remoteHunks,O.bs,O.be),re=o==="local"?F:o==="both"?F.concat(ke):ke;dt.push({bs:O.bs,be:O.be,base:e.slice(O.bs,O.be),local:F,remote:ke,resolved:re}),Oe.push({bs:O.bs,be:O.be,toks:re,source:"conflict",localHunks:O.localHunks,localToks:F,keepsLocal:o!=="remote"})}else Oe.push({bs:O.bs,be:O.be,toks:O.u.toks,source:O.kind==="R"?"remote":"local",localHunks:O.kind==="R"?[]:[O.u.l]});Qe=Math.max(Qe,O.be)}Lt(e.length);let rt=new Map(a.map(O=>[O.bi,O.tok])),et=new Map(b.map(O=>[O.bi,O.tok])),lt=[];for(let O of Oe){O.source==="base"&&(O.toks=O.toks.map((F,ke)=>{let re=O.bs+ke,Ne=rt.get(re),tt=et.get(re),qe=Ne&&tt?o==="remote"?tt:Ne:Ne||tt||F;return qe===F?F:{...qe,cosmetic:!0}}));for(let F of O.toks)lt.push({...F,src:O.source})}return{tokens:lt,segments:Oe,conflicts:dt,localHunks:c,remoteHunks:l,collapsedDelta:D,samePoint:q,mapLocalOffset:Bi(e,c,Oe)}}function Yo(e,t,n,o){let r=[],s=n;for(let c of t)r=r.concat(e.slice(s,c.bs),c.toks),s=c.be;return r.concat(e.slice(s,o))}var Go=e=>e.reduce((t,n)=>t+n.len,0);function Bi(e,t,n){let o=new Int32Array(e.length+1);for(let c=0;c<e.length;c++)o[c+1]=o[c]+e[c].len;let r=t.map(c=>({bs:o[c.bs],be:o[c.be],text:c.toks.map(l=>l.raw).join(""),ref:c})),s=n.map(c=>({bs:o[c.bs],be:o[c.be],len:Go(c.toks),source:c.source,localHunks:c.localHunks||[],localLen:c.localToks?Go(c.localToks):0,keepsLocal:c.keepsLocal,ref:c}));return c=>{let l=null,a=null,b=0,p=0,g=0;for(let u of r){let h=u.bs-g;if(c<=p+h){l=g+(c-p);break}if(p+=h,g=u.bs,c<=p+u.text.length){a=u,b=c-p,l=u.bs;break}p+=u.text.length,g=u.be}l===null&&(l=g+(c-p));let m=0;for(let u of s){if(!a&&l<=u.bs)return m;if(!(a?u.localHunks.includes(a.ref):l<u.be)){m+=u.len;continue}if(u.source==="base")return m+(l-u.bs);if(u.source==="remote")return m+u.len;if(u.source==="local")return m+Math.min(b,u.len);if(!u.keepsLocal||!a)return m+u.len;let y=u.localHunks.indexOf(a.ref),S=Go(Yo(e,u.localHunks.slice(0,y),u.ref.bs,a.ref.bs));return m+Math.min(S+b,u.localLen)}return m}}function Xn(e,t,n,o="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:u=>Math.min(u,t.length),granularity:"word"};let r=vo(e,t,n),s=An(e,r),c=An(t,r),l=An(n,r),a=s.length<=2e4&&c.length<=2e4&&l.length<=2e4?Zr(s,c,l,o):null,b="word",p=s;if(!a){let u=h=>h.split(/(?<=\n)/).map(y=>({k:y,raw:y,len:y.length}));p=u(e),a=Zr(p,u(t),u(n),o),b="line"}let g=u=>u.map(h=>h.raw).join(""),m=[0];for(let u of p)m.push(m[m.length-1]+u.len);return{text:g(a.tokens),conflicts:a.conflicts.map(u=>({bs:m[u.bs],be:m[u.be],base:g(u.base),local:g(u.local),remote:g(u.remote),resolved:g(u.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:b}}function Zn(e,t,n=4e3){if(e===t)return[];let o=vo(e,t),r=An(e,o),s=An(t,o),c=Pn(r,s,n),l=[0];for(let a of r)l.push(l[l.length-1]+a.len);return c.hunks.map(a=>({bs:l[a.bs],be:l[a.be],text:a.toks.map(b=>b.raw).join("")}))}var Dn="\uFFFC";var _i={caret:0},sn=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(" ")),rs=new Set(["BR","WBR","IMG"]),Ui=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)||rs.has(e.tagName))return!0;if(!sn.has(e.tagName))return!Ui.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 o=!0;for(let r of e.childNodes)if(!xn(r,t)){o=!1;break}return t.inlineCache&&t.inlineCache.set(e,o),o}function Wi(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function Qn(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null},o=(r,s)=>{for(let c of r){if(c.nodeType===3){let p=c.nodeValue;if(!p)continue;n.nodes.push({node:c,s:n.text.length,e:n.text.length+p.length}),n.text+=p;for(let g=0;g<p.length;g++)n.stackAt.push(s);continue}if(c.nodeType!==1)continue;if(t.ignored&&t.ignored(c)){n.pins.push({el:c,i:n.text.length});continue}if(t.skip&&t.skip.has(c))continue;let l=c.tagName;if(t.blocks&&t.blocks.has(c)){n.text.length&&n.text[n.text.length-1]!==nt&&(n.stackAt.push(s),n.text+=nt);let p={el:c,tag:l,from:n.text.length,to:-1,depth:s.length,block:!0};n.marks.push(p);let g=s.concat([p]);o(c.childNodes,g),n.stackAt.push(g),n.text+=nt,p.to=n.text.length;continue}let a=sn.has(l)&&Wi(c);if(rs.has(l)||!sn.has(l)||t.remoteWins&&t.remoteWins(c)||t.atomize&&t.atomize(c)||a){n.atoms.push({i:n.text.length,el:c,key:a?l+":empty":l,stack:s}),n.stackAt.push(s),n.text+=Dn;continue}let b={el:c,tag:l,from:n.text.length,to:-1,depth:s.length};n.marks.push(b),o(c.childNodes,s.concat([b])),b.to=n.text.length}};if(o(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&Io(n).trim()===""){let r=n.atoms[0];n.placeholder=r.el,n.text=n.text.slice(0,r.i)+n.text.slice(r.i+1),n.stackAt.splice(r.i,1);for(let s of n.nodes)s.s>r.i&&(s.s--,s.e--);n.atoms=[]}return n.atomAt=new Map(n.atoms.map(r=>[r.i,r])),n}function $i(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function Fi(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,""")}"`;return t+">"}function tr(e,t,n){let o="",r=[];for(let s=t;s<n;s++){let c=e.stackAt[s],l=0;for(;l<r.length&&l<c.length&&r[l]===c[l];)l++;for(;r.length>l;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<c.length;){let b=c[r.length];o+=Fi(b.el),r.push(b)}let a=e.atomAt.get(s);o+=a?a.el.outerHTML:e.text[s]===nt?"":$i(e.text[s])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function Vi(e,t){let n=[...e.el.attributes].filter(o=>!t(e.el,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tag+"|"+n}function ss(e,t){let n=[...e.attributes].filter(o=>!t(e,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tagName+"|"+n+"|"+e.innerHTML}function Qr(e,t=()=>!1){let n=new Map,o=s=>{let c=n.get(s);return c===void 0&&(c="{"+s.map(l=>Vi(l,t)).sort().join(",")+"}",n.set(s,c)),c},r="";for(let s=0;s<e.text.length;s++){let c=e.atomAt.get(s);r+=(c?"["+ss(c.el,t)+"]":e.text[s])+o(e.stackAt[s])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function Hn(e,t,n,o=r=>r.key){let r=[],s=e.text,c=0,l=a=>{if(a<=c)return;let b=s.slice(c,a);if(n)for(let p of b.split(/(?<=\n)/))r.push({k:p,raw:p,len:p.length});else for(let p of An(b,t))r.push(p)};for(let a of e.atoms)l(a.i),r.push({k:"\0"+o(a),raw:Dn,len:1,atom:!0}),c=a.i+1;return l(s.length),r}function Io(e){if(!e.atoms.length)return e.text;let t="",n=0;for(let o of e.atoms)t+=e.text.slice(n,o.i),n=o.i+1;return t+e.text.slice(n)}var nr=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 es(e,t,n,o){let r=nr(t),s=nr(n),c=[],l=0,a=0;for(let p of o.hunks){a+=p.bs-l;let g=a+p.toks.length;c.push({bs:r[p.bs],be:r[p.be],ss:s[a],se:s[g],text:e.text.slice(s[a],s[g]),toks:p.toks,lead:!!p.lead}),a=g,l=p.be}let b=new Map;for(let p of o.cosmetic)b.set(p.bi,p.tok.raw);return{hunks:c,respell:b}}function ts(e,t,n){let o=c=>c===nt||/\s/.test(c),r=c=>c.replace(/[\u001E\s]/g,""),s=[];for(let c of e){let l=t.slice(c.bs,c.be),a=n.slice(c.ss,c.se);if(!l.includes(nt)&&!a.includes(nt)||l.includes(Dn)||a.includes(Dn)||r(l)!==r(a)){s.push(c);continue}let b=0,p=0;for(;;){let g=b,m=p;for(;g<l.length&&o(l[g]);)g++;for(;m<a.length&&o(a[m]);)m++;let u=b,h=p;for(;u<g&&h<m&&l[u]===a[h];)u++,h++;let y=g,S=m;for(;y>u&&S>h&&l[y-1]===a[S-1];)y--,S--;if(y>u||S>h){let v=a.slice(h,S);s.push({bs:c.bs+u,be:c.bs+y,ss:c.ss+h,se:c.ss+S,text:v,toks:[...v].map(D=>({k:D,raw:D,len:1})),lead:c.lead})}if(g>=l.length)break;b=g+1,p=m+1}}return s}function ns(e,t,n){let o=new Int32Array(t+1).fill(-1),r=new Int32Array(n+1).fill(-1),s=0,c=0,l=a=>{for(;s<a;)o[s]=c,r[c]=s,s++,c++};for(let a of e)l(a.bs),s=a.be,c=a.se;return l(t),o[t]=c,r[c]=t,{bTo:o,toB:r}}function os(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function or(e){let{out:t,policy:n="remote",L:o,R:r}=e,s=e.provenance||new WeakMap,c=e.textMappers||new WeakMap,l=e.conflicts||[],a=e.decisions||[],b=l.length,p=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),g={base:null,local:null,remote:null};if(p&&e.moveIn){let i=X=>be=>X.some(G=>G===be||G.nodeType===1&&G.contains(be)),d=i(e.local),w=i(e.remote),k=i(e.base),N=new Set,L=X=>{if(!sn.has(X.tagName))return;let be=o.map.get(X),G=r.map.get(X);(be&&!d(be)||G&&!w(G))&&N.add(X);for(let oe of X.children)L(oe)};for(let X of e.base)X.nodeType===1&&L(X);let $=X=>be=>{if(!sn.has(be.tagName))return!1;let G=X.reverse.get(be);return!!G&&(N.has(G)||!k(G))};N.size&&(g.base=X=>N.has(X)),g.local=$(o),g.remote=$(r)}let m={base:new Set,local:new Set,remote:new Set};if(p&&e.moveIn){let i=k=>N=>k.some(L=>L===N||L.nodeType===1&&L.contains(N)),d=i(e.local),w=i(e.remote);for(let k of Qn(e.base,{...e,atomize:g.base}).atoms){let N=o.map.get(k.el),L=r.map.get(k.el),$=!!N&&!d(N),X=!!L&&!w(L);!$&&!X||(m.base.add(k.el),N&&!$&&m.local.add(N),L&&!X&&m.remote.add(L),d(k.el)&&m.local.add(k.el),w(k.el)&&m.remote.add(k.el))}}let u=Qn(e.base,{...e,atomize:g.base,skip:m.base}),h=Qn(e.local,{...e,atomize:g.local,skip:m.local}),y=Qn(e.remote,{...e,atomize:g.remote,skip:m.remote}),S=new Map(u.atoms.map(i=>[i.el,i])),v=(i,d,w)=>{d.namespaceURI?i.setAttributeNS(d.namespaceURI,d.name,w):i.setAttribute(d.name,w)},D=(i,d,w,k)=>{if(!d&&(!w||!k)){for(let L of(w||k).attributes)v(i,L,L.value);return}let N=new Map;for(let L of[d,w,k])if(L)for(let $ of L.attributes)N.set($.name,$);for(let[L,$]of N){let X=d?d.getAttribute(L):null,be=w?w.getAttribute(L):X,G=k?k.getAttribute(L):X,oe;be===G?oe=be:be===X?(oe=G,a.push({kind:"attr",el:i,name:L,source:"remote"})):G===X?(oe=be,a.push({kind:"attr",el:i,name:L,source:"local"})):(oe=n==="local"?be:G,l.push({kind:"attr",el:i,name:L,base:X,local:be,remote:G,resolved:oe}),a.push({kind:"attr",el:i,name:L,source:"both"})),oe!=null&&v(i,$,oe)}},q=(i,d,w,k)=>i&&e.mergeAttrs?e.mergeAttrs(i,d,w,k):D(k,i,d,w),Z=e.mergeElement||((i,d,w)=>{let k=t.createElement(i.tagName);q(i,d,w,k);let N=d||i,L=w||i,$=n==="local"?N.isEqualNode(i)?L:N:L.isEqualNode(i)?N:L;for(let X of $.childNodes)k.appendChild(t.importNode(X,!0));return s.set(k,{base:i,local:d,remote:w}),k}),ae=e.cloneUnit||((i,d)=>{let w=t.importNode(i,!0);return s.set(w,{base:null,local:d==="local"?i:null,remote:d==="remote"?i:null}),w}),ie=e.atomKey||(i=>ss(i,()=>!1)),he=(i,d)=>{let w=new Map;for(let k of i.atoms)if(e.remoteWins&&e.remoteWins(k.el)&&sn.has(k.el.tagName))w.set(k,"w"+k.el.tagName+"#"+(k.el.id||""));else if(!p)w.set(k,k.key);else if(i===u)w.set(k,"="+ie(k.el));else{let N=d.reverse.get(k.el),L=N?S.get(N):null;L?w.set(k,"="+ie(L.el)):N?w.set(k,"m"+ie(k.el)):w.set(k,"="+ie(k.el))}return k=>w.get(k)},K=he(u,null),J=he(h,o),ye=he(y,r),je=vo(Io(u),Io(h),Io(y)),Fe=Hn(u,je,!1,K),ot=Hn(h,je,!1,J),ct=Hn(y,je,!1,ye),Ct=Fe.length>2e4||ot.length>2e4||ct.length>2e4;Ct&&(Fe=Hn(u,je,!0,K),ot=Hn(h,je,!0,J),ct=Hn(y,je,!0,ye));let vt=Zo(Pn(Fe,ot),Pn(Fe,ct),Fe),Oe=es(h,Fe,ot,{hunks:vt.lh,cosmetic:vt.cosL}),dt=es(y,Fe,ct,{hunks:vt.rh,cosmetic:vt.cosR});Oe.hunks=ts(Oe.hunks,u.text,h.text),dt.hunks=ts(dt.hunks,u.text,y.text);let Qe=ns(Oe.hunks,u.text.length,h.text.length),Lt=ns(dt.hunks,u.text.length,y.text.length),rt=u.text.length,et=i=>new Map(i.atoms.map(d=>[d.el,d])),lt=et(h),O=et(y),F=(i,d,w)=>{let k=new Set;if(!p)return k;for(let N of i.atoms){let L=S.get(d.reverse.get(N.el));L&&w.bTo[L.i]<0&&k.add(L)}return k},ke=F(h,o,Qe),re=F(y,r,Lt),Ne=i=>!xn(i,{...e,remoteWins:null}),tt=new Set;if(p)for(let i of u.atoms){if(!Ne(i.el))continue;let d=o.map.get(i.el)||null,w=r.map.get(i.el)||null,k=d&&!w?d:w&&!d?w:null;k&&(lt.has(k)||O.has(k))&&!k.isEqualNode(i.el)&&tt.add(i)}let qe=1,Ke=(i,d)=>({id:qe++,tag:i,base:null,local:null,remote:null,rank:d}),Ze=new Map,at=[];for(let i of u.marks){let d=Ke(i.tag,i.depth);d.block=!!i.block,d.base=i.el,d.baseMark=i,Ze.set(i.el,d),at.push(d)}let f=(i,d)=>{let w=-1,k=-1;for(let N=i.from;N<i.to;N++){let L=d[N];L>=0&&(w<0&&(w=L),k=L+1)}return w<0?null:[w,k]},T=(i,d,w,k)=>{for(let N of i.marks){let L=w?w.reverse.get(N.el):null;L&&w.identical.has(L)&&w.pairIdenticalChildren&&w.pairIdenticalChildren(L);let $=L?Ze.get(L):null;if($&&$[d]&&($=null),!$){let X=f(N,k),be=0;if(X)for(let G of at){if(G.tag!==N.tag||G[d]||!!G.block!=!!N.block)continue;let oe=Math.min(X[1],G.baseMark.to)-Math.max(X[0],G.baseMark.from);(oe>be||oe===be&&oe>0&&Math.abs(G.rank-N.depth)<Math.abs($.rank-N.depth))&&($=G,be=oe)}}$||($=Ke(N.tag,N.depth),$.block=!!N.block,$.new=d),$[d]=N.el,$[d+"Mark"]=N,Ze.set(N.el,$)}};T(h,"local",o,Qe.toB),T(y,"remote",r,Lt.toB);let x=i=>i.merged||i,B=i=>{let d=new Set;for(let w of i)w.block||d.add(Ze.get(w.el));return d},I=new Map,E=i=>{let d=I.get(i);return d||(d=B(i),I.set(i,d)),d},j=(i,d)=>{let w=[],k=null;for(let N=0;N<rt;N++){let L=d[N];if(L<0){k&&w.push(k),k=null;continue}let $=E(u.stackAt[N]),X=E(i.stackAt[L]),be=new Set,G=new Set;for(let oe of X)$.has(oe)||be.add(oe);for(let oe of $)X.has(oe)||G.add(oe);if(!be.size&&!G.size){k&&w.push(k),k=null;continue}if(k&&os(k.added,be)&&os(k.removed,G)){k.be=N+1;continue}k&&w.push(k),k={bs:N,be:N+1,added:be,removed:G}}return k&&w.push(k),w},M=j(h,Qe.bTo),P=j(y,Lt.bTo),Y=i=>i.be>i.bs?[i.bs,i.be-1]:[i.bs-1,i.bs],Q=(i,d)=>{if(rt===0)return null;let[w,k]=Y(i);for(let N of d){if(N.be<=w)continue;if(N.bs>k)break;let L=N.bs<=w&&k<N.be;return L&&i.text===""&&N.bs===i.bs&&N.be===i.be?"straddle":L?N:i.be>i.bs?"straddle":null}return null},we=i=>i.bs===i.be,Ye=(i,d)=>{let w=!1;for(let k=i.bs;k<i.be;k++){let N=u.text[k];if(N===nt)w=!0;else if(!/\s/.test(N))return!1}for(let k=i.ss;k<i.se;k++){let N=d.text[k];if(N===nt)w=!0;else if(!/\s/.test(N))return!1}return w},bt=(i,d)=>i.bs<d.be&&d.bs<i.be,ft=(i,d)=>i.bs<=d.be&&d.bs<=i.be&&we(i)!==we(d),le=(i,d)=>u.text.slice(i.bs,i.be).includes(nt)||d.text.slice(i.ss,i.se).includes(nt),Ge=i=>{if(we(i))return!1;let d=i.bs,w=i.be;for(;d>0&&/\s/.test(u.text[d-1]);)d--;for(;w<u.text.length&&/\s/.test(u.text[w]);)w++;return(d===0||u.text[d-1]===nt)&&(w===u.text.length||u.text[w]===nt)},Rt=(i,d)=>!le(i,d)&&!Ge(i),yt=(i,d)=>bt(i,d)||ft(i,d)&&!(Ye(i,h)&&Rt(d,y))&&!(Ye(d,y)&&Rt(i,h)),Dt=(i,d)=>{if(i.bs!==d.bs||i.be!==d.be||i.toks.length!==d.toks.length)return!1;let w=i.ss,k=d.ss;for(let N=0;N<i.toks.length;N++){let L=i.toks[N],$=d.toks[N];if(L.k!==$.k||L.atom&&!h.atomAt.get(w).el.isEqualNode(y.atomAt.get(k).el))return!1;w+=L.len,k+=$.len}return!0},Ut=(i,d,w,k)=>{for(let N of u.atoms){if(N.i<i.bs||N.i>=i.be||k.has(N)||tt.has(N))continue;let L=d.bTo[N.i],$=L>=0?w.atomAt.get(L):null;if($&&!$.el.isEqualNode(N.el))return!0}return!1},At=[],xt=Oe.hunks,A=dt.hunks,C=0,R=0,U=0,H=0,_=0,z=i=>{i>U&&(At.push({src:"base",from:U,to:i,dL:H,dR:_}),U=i)};for(;C<xt.length||R<A.length;){let i=xt[C],d=A[R],w=!!i&&(!d||i.bs<d.bs||i.bs===d.bs&&i.be<=d.be&&!d.lead);if(i&&d&&i.bs===d.bs&&we(i)&&we(d)){let Nt=Ye(i,h),kn=Ye(d,y);Nt!==kn&&(w=kn)}let k=w?i:d,N=w?d:i,L=!!N&&Dt(i,d),$=!!N&&(w?!!xt[C+1]&&Dt(xt[C+1],d):!!A[R+1]&&Dt(i,A[R+1])),X=!!N&&!L&&!$&&(rt===0||yt(i,d)),be=X,G=Q(k,w?P:M);if(G==="straddle"&&(be=!0),!be&&k.be>k.bs&&(be=Ut(k,w?Lt:Qe,w?y:h,w?ke:re)),!be&&L){z(k.bs),At.push({src:"both",lfrom:i.ss,rfrom:d.ss,len:k.text.length}),U=k.be,H+=k.text.length-(k.be-k.bs),_+=k.text.length-(k.be-k.bs),C++,R++;continue}if(!be){z(k.bs),At.push({src:w?"local":"remote",from:k.ss,to:k.se,inherit:G&&G!=="straddle"?G:null}),U=k.be,w?(H+=k.text.length-(k.be-k.bs),C++):(_+=k.text.length-(k.be-k.bs),R++);continue}let oe=k.bs,Be=k.be,Ie=C,De=R,mt=Nt=>Nt.bs<Be&&Nt.be>oe||we(Nt)&&(Nt.bs===oe||Nt.bs===Be);w?Ie++:De++,X&&(oe=Math.min(oe,N.bs),Be=Math.max(Be,N.be),w?De++:Ie++);let it=!0;for(;it;){for(it=!1;Ie<xt.length&&mt(xt[Ie]);)oe=Math.min(oe,xt[Ie].bs),Be=Math.max(Be,xt[Ie].be),Ie++,it=!0;for(;De<A.length&&mt(A[De]);)oe=Math.min(oe,A[De].bs),Be=Math.max(Be,A[De].be),De++,it=!0}let Ft=oe+H,Ht=oe+_,Xt=Be-oe,nn=Be-oe;for(let Nt=C;Nt<Ie;Nt++)Xt+=xt[Nt].text.length-(xt[Nt].be-xt[Nt].bs);for(let Nt=R;Nt<De;Nt++)nn+=A[Nt].text.length-(A[Nt].be-A[Nt].bs);let fn=Ft+Xt,un=Ht+nn;z(oe);let St={kind:"text",node:e.node||null,base:tr(u,oe,Be),local:tr(h,Ft,fn),remote:tr(y,Ht,un),resolved:null,range:null,bs:oe,be:Be,lss:Ft,lse:fn,rss:Ht,rse:un};St.resolved=n==="local"?St.local:n==="remote"?St.remote:St.local+St.remote,n!=="remote"&&At.push({src:"local",from:Ft,to:fn,conflict:St}),n!=="local"&&At.push({src:"remote",from:Ht,to:un,conflict:St}),l.push(St),U=Be,H+=Xt-(Be-oe),_+=nn-(Be-oe),C=Ie,R=De}z(rt);let ne=u.text,pe=[];if(Oe.respell.size||dt.respell.size){let i=nr(Fe),d=[];for(let w=0;w<Fe.length;w++){let k=Fe[w].raw,N=Oe.respell.get(w)??k,L=dt.respell.get(w)??k;(N!==k||L!==k)&&pe.push([i[w],N!==k&&L!==k?"both":N!==k?"local":"remote"]),d.push(N===L?N:N===k?L:L===k||n==="local"?N:L)}ne=d.join("")}let fe="",me=[],Pe=[],Le=[],kt=[];for(let i of At){let d=fe.length;if(i.src==="base"){for(let w=i.from;w<i.to;w++)me.push(w),Pe.push(w+i.dL),Le.push(w+i.dR),kt.push(i);fe+=ne.slice(i.from,i.to)}else if(i.src==="both"){for(let w=0;w<i.len;w++)me.push(-1),Pe.push(i.lfrom+w),Le.push(i.rfrom+w),kt.push(i);fe+=h.text.slice(i.lfrom,i.lfrom+i.len)}else{let w=i.src==="local"?h:y;for(let k=i.from;k<i.to;k++)me.push(-1),Pe.push(i.src==="local"?k:-1),Le.push(i.src==="remote"?k:-1),kt.push(i);fe+=w.text.slice(i.from,i.to)}i.ms=d,i.me=fe.length,i.conflict&&(i.conflict.range||(i.conflict.range=[d,d]),i.conflict.range[1]=fe.length)}let ue=fe.length,Ve=new Int32Array(rt+1).fill(-1),Te=new Int32Array(h.text.length+1).fill(-1),It=new Int32Array(y.text.length+1).fill(-1);for(let i=0;i<ue;i++)me[i]>=0&&(Ve[me[i]]=i),Pe[i]>=0&&(Te[Pe[i]]=i),Le[i]>=0&&(It[Le[i]]=i);let wt=(i,d)=>{let w=-1,k=-1;for(let N=i.from;N<i.to;N++){let L=d[N];L>=0&&(w<0&&(w=L),k=L+1)}return w<0?null:[w,k]},Ot=[],ht=[];for(let i of new Set(Ze.values()))i.new==="local"?Ot.push(i):i.new==="remote"&&ht.push(i);let zn=(i,d)=>{i.remote=d.remote,i.remoteMark=d.remoteMark,i.new="both",d.merged=i,Ze.set(d.remote,i)};if(Ot.length&&ht.length){let i=e.idOf;for(let d of Ot){let w=i?i.local(d.local):null;if(!w)continue;let k=ht.find(N=>!N.merged&&N.tag===d.tag&&!!N.block==!!d.block&&i.remote(N.remote)===w);k&&zn(d,k)}for(let d of Ot){if(d.remote)continue;let w=wt(d.localMark,Te);if(w)for(let k of ht){if(k.merged||k.tag!==d.tag||!!k.block!=!!d.block)continue;let N=wt(k.remoteMark,It);if(N&&Math.min(w[1],N[1])-Math.max(w[0],N[0])>0){zn(d,k);break}}}}I.clear();let qn=i=>{for(let d of i)if(d.block)return x(Ze.get(d.el));return null},rn=u.marks.some(i=>i.block)||h.marks.some(i=>i.block)||y.marks.some(i=>i.block),Gt=new Array(ue).fill(null),vn=new Set;if(rn){let i=(G,oe,Be)=>{let Ie=new Set([G,oe,Be]);Ie.delete(null);let De=[];for(let it of Ie){let Ft=it===G,Ht=it===oe,Xt=it===Be;(Ht===Xt?Ht:Ht===Ft?Xt:Ht)&&De.push(it)}if(De.length<=1)return De[0]||null;let mt=n==="local"?oe:Be;return De.includes(mt)?mt:De[0]},d=(G,oe)=>oe>=0?qn(G.stackAt[oe]):null,w=new Map;for(let G=0;G<ue;G++){if(fe[G]!==nt)continue;let oe=me[G]>=0?d(u,me[G]):null,Be=d(h,Pe[G]),Ie=d(y,Le[G]);w.set(G,[oe,me[G]>=0?i(oe,Be,Ie):Be||Ie])}let k=new Set([...w.values()].map(G=>G[1])),N=G=>G!==nt&&G!==Dn&&!/\s/.test(G),L=(G,oe)=>{let Be=G;for(;Be<oe&&!N(fe[Be]);)Be++;return Be<oe&&me[Be]>=0?d(u,me[Be]):null},$=new Map,X=0;for(let G=0;G<ue;G++){if(fe[G]!==nt)continue;let[oe,Be]=w.get(G),Ie=L(X,G),De=Be,mt=$.get(De)===De&&Ie===De;De&&$.has(De)&&!mt&&oe&&!$.has(oe)&&!k.has(oe)&&(De=oe),De&&!$.has(De)&&$.set(De,Ie);for(let it=X;it<=G;it++)Gt[it]=De;X=G+1}let be=G=>{for(let oe=0;oe<G.text.length;oe++)if(N(G.text[oe])&&!d(G,oe))return!0;return!1};if(!be(u)&&!be(h)&&!be(y)){let G=[],oe=0;for(let Ie=0;Ie<ue;Ie++)(fe[Ie]===nt||Ie===ue-1)&&(G.push([oe,Ie]),oe=Ie+1);let Be=new Set(Gt);for(let Ie=0;Ie<G.length;Ie++){let[De,mt]=G[Ie];if(Gt[mt])continue;let it=De;for(;it<=mt&&!N(fe[it]);)it++;if(it>mt)continue;let Ft=d(u,me[it]),Ht=d(h,Pe[it]),Xt=d(y,Le[it]),nn=i(Ft,Ht,Xt)||Ht||Xt||Ft;if(nn&&!Be.has(nn)){Be.add(nn);for(let St=De;St<=mt;St++)Gt[St]=nn;continue}let fn=Ie>0&&Gt[G[Ie-1][1]],un=Ie+1<G.length&&Gt[G[Ie+1][1]];if(fn)vn.add(G[Ie-1][1]);else if(un&&fe[mt]===nt)vn.add(mt);else continue;for(let St=De;St<=mt;St++)Gt[St]=fn||un}}}let bo=new Map,yo=i=>{let d=bo.get(i);if(d)return d;d=[1/0,-1/0];for(let[w,k]of[[i.baseMark,Ve],[i.localMark,Te],[i.remoteMark,It]]){let N=w&&wt(w,k);N&&(d[0]=Math.min(d[0],N[0]),d[1]=Math.max(d[1],N[1]))}return bo.set(i,d),d},ko=(i,d,w)=>{let k=-1,N=-1;for(let L=0;L<i.length;L++){let $=Ze.get(i[L].el);$===d&&(k=L),$===w&&(N=L)}return k>=0&&N>=0?k-N:0},In=(i,d)=>[...i].sort((w,k)=>{for(let $ of d){let X=ko($,w,k);if(X)return X}let N=yo(w),L=yo(k);return N[0]-L[0]||L[1]-N[1]||w.rank-k.rank||w.id-k.id}),wo=new Map,W=new Map,xe=i=>{let d=me[i],w=Pe[i],k=Le[i],N=kt[i];if(d>=0){let Ie=u.stackAt[d],De=h.stackAt[w],mt=y.stackAt[k],it=wo.get(Ie);it||wo.set(Ie,it=new Map);let Ft=it.get(De);Ft||it.set(De,Ft=new Map);let Ht=Ft.get(mt);if(Ht)return Ht;let Xt=E(Ie),nn=E(De),fn=E(mt),un=new Set;for(let St of new Set([...Xt,...nn,...fn])){let Nt=Xt.has(St),kn=nn.has(St),Br=fn.has(St);(kn===Br?kn:kn===Nt?Br:kn)&&un.add(St)}return Ht=In(un,[De,mt,Ie]),Ft.set(mt,Ht),Ht}if(N.src==="both"){let Ie=h.stackAt[w],De=y.stackAt[k];return In(new Set([...E(Ie),...E(De)]),[Ie,De])}let $=(N.src==="local"?h:y).stackAt[N.src==="local"?w:k];if(!N.inherit)return In(E($),[$]);let X=W.get(N);X||W.set(N,X=new Map);let be=X.get($);if(be)return be;let G=new Set(E($));for(let Ie of N.inherit.added)G.add(x(Ie));for(let Ie of N.inherit.removed)G.delete(x(Ie));let oe=N.src==="local"?y:h,Be=(N.src==="local"?Lt.bTo:Qe.bTo)[N.inherit.bs];return be=In(G,[$,oe.stackAt[Be]]),X.set($,be),be},de=new Int32Array(h.text.length+1);de[h.text.length]=ue;for(let i=h.text.length-1;i>=0;i--)de[i]=Te[i]>=0?Te[i]:de[i+1];_i.caret+=h.text.length;let Me=i=>i<=0?0:(i>h.text.length&&(i=h.text.length),Te[i-1]>=0?Te[i-1]+1:de[i]),_e=[],te=[],Ae=null,ee=[],ve="",He=-1,Et=i=>{Ae?Ae.appendChild(i):_e.push(i)},Jt=i=>{if(!ve)return;let d=t.createTextNode(ve);Et(d),te.push({node:d,ms:He,me:i,local:[],u:ee.length?ee[ee.length-1].u:null}),ve=""},an=new Set,Bt=new Map,hn=new Set,Re=i=>{let d=t.createElement(i.tag);if(i.block&&Gn.add(d),!Bt.has(i)){Bt.set(i,d),q(i.base,i.local,i.remote,d),s.set(d,{base:i.base,local:i.local,remote:i.remote});let k=($,X)=>p&&i[X]&&$.reverse.get(i[X])?X:null,N=!i.base&&(k(o,"local")||k(r,"remote"));if(N){let $=N==="local"?o.reverse.get(i.local):r.reverse.get(i.remote),X=s.get(d);X.local=X.local||o.map.get($)||null,X.remote=X.remote||r.map.get($)||null,a.push({kind:"move",el:d,source:N})}else i.base||a.push({kind:"insert",el:d,source:i.local&&i.remote?"both":i.local?"local":"remote"});let L=s.get(d);L.local&&(hn.has(L.local)?L.local=null:hn.add(L.local))}else{let k=Bt.get(i);for(let N of k.attributes)N.name!=="id"&&N.name!=="data-id"&&v(d,N,N.value);s.set(d,{base:null,local:null,remote:null})}Et(d),ee.push({u:i,el:d}),Ae=d},Ue=new Set,V=new Map;for(let i of h.pins){let d=Me(i.i);V.has(d)||V.set(d,[]),V.get(d).push(i)}let ce=i=>{let d=V.get(i);if(d){Jt(i);for(let w of d){let k=w.el.namespaceURI&&w.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(w.el.namespaceURI,w.el.tagName):t.createElement(w.el.tagName);s.set(k,{base:null,local:w.el,remote:null,pinned:!0}),Ue.add(k),Et(k)}}},ge=u.atoms.length||h.atoms.length||y.atoms.length,Ce=i=>{if(!ge)return null;let d=me[i]>=0?u.atomAt.get(me[i]):null,w=Pe[i]>=0?h.atomAt.get(Pe[i]):null,k=Le[i]>=0?y.atomAt.get(Le[i]):null;return d||w||k?{ab:d,al:w,ar:k}:null},Se=(i,d,w,k)=>{if(!i||!p)return null;let N=S.get(d.reverse.get(i.el))||null;return!N||N===k||(k?N.el.isEqualNode(k.el):w.bTo[N.i]>=0)?null:N},$e=(i,d)=>{if(!i||!p||!e.moveIn)return null;let w=d.reverse.get(i.el);return w&&!S.has(w)?w:null},Xe=(i,d)=>{let w=new Map;for(let k of i.atoms)w.set(d(k),(w.get(d(k))||0)+1);return w},Pt=Xe(u,K),_t=Xe(h,J),Vt=Xe(y,ye),Tt=i=>{let d=K(i);return Pt.get(d)===1&&(_t.get(d)||0)<=1&&(Vt.get(d)||0)<=1},zt=new Map,ut=new Set,pt=new Set,qt=new Set;for(let i=0;i<ue;i++){let d=Ce(i);if(!d)continue;let{ab:w,al:k,ar:N}=d,L=Se(N,r,Lt,w),$=Se(k,o,Qe,w),X=w,be=null;if(L?(X=L,be="remote"):$&&(X=$,be="local"),X){ut.has(X)?zt.set(i,{dup:X.el}):(ut.add(X),zt.set(i,{bk:X,from:be,al:k,ar:N}));continue}let G=$e(N,r),oe=$e(k,o),Be=G||oe;if(Be){pt.has(Be)?zt.set(i,{dup:Be}):(pt.add(Be),zt.set(i,{moveIn:Be,side:G?"remote":"local",sideEl:G?N.el:k.el}));continue}let Ie=(mt,it)=>mt&&p&&S.get(it.reverse.get(mt.el))||null,De=Ie(N,r)||Ie(k,o);if(De&&(qt.add(De),kt[i].conflict&&Tt(De))){if(ut.has(De)){zt.set(i,{dup:De.el});continue}ut.add(De)}zt.set(i,{al:k,ar:N})}let en=new Map,Ao=(i,d)=>{if(i[d]>=0)return i[d];for(let w=d-1;w>=0;w--)if(i[w]>=0)return i[w]+1;return 0};if(p)for(let i of u.atoms){if(ut.has(i)||qt.has(i))continue;let d=o.map.get(i.el)||null,w=r.map.get(i.el)||null,k=d&<.get(d),N=w&&O.get(w);if(d&&!k||w&&!N)continue;let L=!(k&&N)&&tt.has(i);if(!L&&!(k&&N&&Tt(i)))continue;let $=n==="local"?[[k,Te],[N,It]]:[[N,It],[k,Te]],[X,be]=$.find(([oe])=>oe),G=Ao(be,X.i);en.has(G)||en.set(G,[]),en.get(G).push({a:i,lt:d,rt:w,edited:L}),ut.add(i)}if(p&&e.moveIn){let i=[[h,o,Te,"local"],[y,r,It,"remote"]];n!=="local"&&i.reverse();for(let[d,w,k,N]of i)for(let L of d.atoms){let $=$e(L,w);if(!$||pt.has($))continue;pt.add($);let X=Ao(k,L.i);en.has(X)||en.set(X,[]),en.get(X).push({move:$,side:N,sideEl:L.el})}}let Kn=i=>{let d=en.get(i);if(d){if(Jt(i),d.some(w=>Ne(w.move?w.sideEl:w.a.el)))for(;ee.length;)ee.pop(),Ae=ee.length?ee[ee.length-1].el:null;for(let{a:w,lt:k,rt:N,edited:L,move:$,side:X,sideEl:be}of d){if($){let oe=e.moveIn($,X,be);oe&&Et(oe);continue}an.add(w);let G=Z(w.el,k,N);L&&(l.push({kind:"structure",el:G,detail:"edit-beats-delete",base:w.el}),a.push({kind:"insert",el:G,source:k?"local":"remote"})),Et(G)}}},Gn=new Set;for(let i=0;i<ue;i++){let d=Ce(i),k=!!d&&Ne((d.ab||d.al||d.ar).el)?[]:Gt[i]?[Gt[i],...xe(i)]:xe(i),N=0;for(;N<ee.length&&N<k.length&&ee[N].u===k[N];)N++;if(N<ee.length)for(Jt(i);ee.length>N;)ee.pop(),Ae=ee.length?ee[ee.length-1].el:null;if(ce(i),Kn(i),k.length>ee.length)for(Jt(i);ee.length<k.length;)Re(k[ee.length]);if(fe[i]===nt){if(vn.has(i))continue;Jt(i);let L=ee.length;for(;L>0&&!ee[L-1].u.block;)L--;if(L>0)for(;ee.length>=L;)ee.pop(),Ae=ee.length?ee[ee.length-1].el:null;continue}if(d){Jt(i);let L=zt.get(i),$;if(L.dup){l.push({kind:"structure",el:null,detail:"both-moved",base:L.dup});continue}if(L.moveIn){if($=e.moveIn(L.moveIn,L.side,L.sideEl),!$)continue}else if(L.bk){let X=L.bk;if(an.add(X),X===d.ab)$=Z(X.el,L.al.el,L.ar.el);else{let be=o.map.get(X.el)||null,G=r.map.get(X.el)||null;$=Z(X.el,be,G),(!be||!G)&&l.push({kind:"structure",el:null,detail:"move-beats-delete",base:X.el}),a.push({kind:"move",el:$,source:L.from})}}else L.al?($=ae(L.al.el,"local"),L.ar&&(s.get($).remote=L.ar.el),a.push({kind:"insert",el:$,source:L.ar?"both":"local"})):($=ae(L.ar.el,"remote"),a.push({kind:"insert",el:$,source:"remote"}));Et($);continue}ve||(He=i),ve+=fe[i]}if(Jt(ue),(V.has(ue)||en.has(ue))&&(ee.length=0,Ae=null,ce(ue),Kn(ue)),ue===0&&(h.placeholder||y.placeholder||u.placeholder)){let i=t.createElement("br");s.set(i,{base:u.placeholder,local:h.placeholder,remote:y.placeholder}),_e.push(i)}let se=0,We=i=>{for(;se>0&&te[se-1].me>=i;)se--;for(;se<te.length&&te[se].me<i;)se++;let d=te[se];if(!d)return te[te.length-1]||null;let w=te[se+1];return d.me===i&&w&&w.ms===i?w:d},st=new Map,Je={},ze=(i,d,w)=>{let k=We(i)||(w?Je:null);if(!k)return;let N=st.get(k)||{l:!1,r:!1};d!=="remote"&&(N.l=!0),d!=="local"&&(N.r=!0),st.set(k,N)},tn=i=>{if(i.conflict)return!0;let d=i.src==="local"?h.text:i.src==="remote"?y.text:"";for(let w=i.from;w<i.to;w++)if(d[w]!==Dn&&d[w]!==nt)return!0;return!1};for(let i of At)i.src!=="base"&&ze(i.ms,i.conflict?"both":i.src,tn(i));for(let[i,d]of pe)Ve[i]>=0&&ze(Ve[i],d);for(let i of te.length?te:[Je]){let d=st.get(i);d&&a.push({kind:"text",node:i.node||null,source:d.l&&d.r?"both":d.l?"local":"remote"})}for(let i of at){if(Bt.has(i))continue;let d=!i.local&&!(p&&o.map.get(i.base)),w=!i.remote&&!(p&&r.map.get(i.base));!d&&!w||a.push({kind:"remove",source:d&&w?"both":d?"local":"remote",base:i.base})}let Yt=(i,d,w)=>{if(d<=i)return!1;for(let k=i;k<d;k++)if(w[k]>=0)return!1;return!0};for(let i of at)for(let d of["local","remote"]){let w=i[d+"Mark"],k=i.baseMark;if(!w)continue;let N=d==="local"?Qe:Lt;if(!Yt(k.from,k.to,N.bTo)||!Yt(w.from,w.to,N.toB))continue;let L=(d==="local"?xt:A).find($=>$.ss<=w.from&&w.from<$.se);L&&(L.be<=k.from||L.bs>=k.to)&&a.push({kind:"move",el:Bt.get(i)||null,source:d})}let pn=i=>{let d=Ze.get(i.node.parentNode);return d?x(d):null};for(let i of h.nodes){let d=-1;for(let k=i.s;k<i.e;k++)if(Te[k]>=0){d=Te[k];break}let w;if(d>=0)w=We(d);else{let k=Me(i.s),N=pn(i);w=te.find(L=>L.u===N&&L.me>=k)||te.filter(L=>L.u===N).pop()}w&&w.local.push(i)}let Kt=new Map,jt=te[te.length-1]||null,$t=0;for(let i of h.nodes){let d=null;for(let w=i.s;w<=i.e;w++){let k=Me(w);for(;$t>0&&te[$t-1].me>=k;)$t--;for(;$t<te.length&&te[$t].me<k;)$t++;let N=$=>$&&k>=$.ms&&k<=$.me&&(k<$.me||w===i.e||$===d),L=N(te[$t])?te[$t]:N(te[$t+1])?te[$t+1]:te[$t]||jt;if(!L)break;if(d===L){let $=Kt.get(L);$[$.length-1].to=w-i.s;continue}d=L,Kt.has(L)||Kt.set(L,[]),Kt.get(L).push({node:i.node,from:w-i.s,to:w-i.s,flatStart:i.s})}}for(let i of te){let d=i.local,w=!1;for(let $ of d)for(let X=$.s;X<$.e&&!w;X++)(Te[X]<i.ms||Te[X]>=i.me)&&(w=!0);s.set(i.node,{base:null,local:d.map($=>$.node),remote:null,caret:Kt.get(i)||[],partial:w});let k=i.ms,N=i.me-i.ms,L=$=>{let X=0,be=-1;for(let G of d){let oe=G.e-G.s;if($<=X+oe){be=G.s+($-X);break}X+=oe}return be<0&&(be=d.length?d[d.length-1].e:0),Math.max(0,Math.min(Me(be)-k,N))};L.flat=$=>Math.max(0,Math.min(Me($)-k,N)),c.set(i.node,L)}function Gs(){if(!h.text.includes(nt))return[{flatLocal:h.text,localNodes:h.nodes,textNodes:te,lToM:Te,mapLocal:Me}];let i=[],d=0,w=0;for(let k=0;k<=h.text.length;k++){if(k<h.text.length&&h.text[k]!==nt)continue;let N=d,L=k;if(L>N){let $=[];for(;w<h.nodes.length&&h.nodes[w].e<=N;)w++;for(let X=w;X<h.nodes.length&&h.nodes[X].s<L;X++){let be=h.nodes[X],G=Math.max(be.s,N),oe=Math.min(be.e,L);G<oe&&$.push({node:be.node,s:G-N,e:oe-N})}i.push({flatLocal:h.text.slice(N,L),localNodes:$,textNodes:te,lToM:Te.subarray?Te.subarray(N,L+1):Te.slice(N,L+1),mapLocal:X=>Me(N+Math.max(0,Math.min(X,L-N)))})}d=k+1}return i}let Js={...e,blocks:Gn,ignored:i=>Ue.has(i)||(e.ignored?e.ignored(i):!1)},jr=e.ignoreAttribute||(()=>!1),Ys=Qr(Qn(_e,Js),jr)!==Qr(y,jr);return{nodes:_e,text:fe,textNodes:te,localDiverged:Ys,mapLocal:Me,conflicts:l.slice(b),granularity:Ct?"line":"word",segments:Gs(),localHunks:xt,remoteHunks:A,lToM:Te}}var zi="http://www.w3.org/1999/xhtml";function qi(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 Wt(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===zi}function Ki(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Eo(e,t){let n=e.getAttribute("src"),o=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(n){let r=n;try{let s=new URL(n,t);r=s.origin+s.pathname+s.search}catch{}return"script|src|"+o+"|"+r}return"script|inline|"+o+"|"+qi(e.textContent.trim())}var Gi={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function jn(e,t=[],n=!1){if(!Wt(e)||e.hasAttribute("src"))return null;let o=[Gi,...t];for(let r=0;r<o.length;r++){let s=o[r];if(!s.match(e))continue;if(!Ki(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let c=s.identity(e);return c==null||c===""?null:{key:r+":"+c,raw:c,recognizer:s}}return null}function is(e,t,n){let o=new Set,r=s=>{Wt(s)&&!t(s)&&o.add(Eo(s,n))};r(e);for(let s of e.querySelectorAll("script"))r(s);return o}function eo(e,t){let n=t.createElement("div");n.innerHTML="<script><\/script>";let o=n.firstChild;for(let r of e.attributes)o.setAttribute(r.name,r.value);return o.textContent=e.textContent,o}function cs(e,t,n){let o=[],r=[],s=Array.from(e.querySelectorAll("script"));Wt(e)&&s.unshift(e);for(let c of s){if(!Wt(c)||n.ignored(c)||n.skip.has(c)||t.has(Eo(c,n.baseURI)))continue;let l=c.ownerDocument.createElement("script");for(let a of c.attributes)l.setAttribute(a.name,a.value);l.textContent=c.textContent,n.beforeNodeAdded(l)!==!1&&(l.hasAttribute("src")&&r.push(new Promise(a=>{l.addEventListener("load",()=>a()),l.addEventListener("error",()=>a())})),c.replaceWith(l),n.afterNodeAdded(l),o.push(l))}return{executed:o,loads:r}}function Ji(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 Yi(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function ls(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Eo(e,t);if(n==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+Yi(o,t):e.outerHTML}if(n==="META"){for(let o of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(o))return"meta|"+o+"="+e.getAttribute(o);return e.outerHTML}return n==="STYLE"?"style|"+Ji(e.textContent):e.outerHTML}function rr(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 Xi(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var Zi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Qi=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function sr(e){try{return JSON.parse(e)}catch{return JSON.parse(ec(e))}}function ec(e){let t="",n=0,o=(r,s)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${s}`)};for(;n<e.length&&(n=rr(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let l=rr(e,n+1);if(e[l]==="}"||e[l]==="]"){n++;continue}t+=r,n++;continue}if(r==='"'||r==="'"){let l=n+1;for(;l<e.length&&e[l]!==r;)e[l]==="\\"&&l++,l++;l>=e.length&&o("unterminated string",n);let a=e.slice(n+1,l);r==="'"&&(a=Xi(a)),t+='"'+a+'"',n=l+1;continue}let s=n;for(;s<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[s]);)s++;s===n&&o("unexpected character "+JSON.stringify(r),n);let c=e.slice(n,s);if(c==="true"||c==="false"||c==="null"||Zi.test(c)){t+=c,n=s;continue}if(Qi.test(c)){if(e[rr(e,s)]===":"){t+='"'+c+'"',n=s;continue}o("unquoted value "+JSON.stringify(c),n)}o("invalid token "+JSON.stringify(c),n)}return t}var gt=Symbol("hyper-morph-json-merge:missing"),as=["id","_id","uuid","key","slug","code","name"];function Bn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function to(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function tc(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function gn(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(!gn(e[n],t[n]))return!1;return!0}if(Bn(e)&&Bn(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!to(t,o)||!gn(e[o],t[o]))return!1;return!0}return!1}function fs(e,t,n,o){return gn(t,n)?t:gn(t,e)?n:gn(n,e)?t:Bn(t)&&Bn(n)?nc(Bn(e)?e:{},t,n,o):Array.isArray(t)&&Array.isArray(n)?ic(Array.isArray(e)?e:[],t,n,o):n}function us(e,t,n,o){return t===gt&&n===gt?gt:t===gt?e===gt?n:gn(n,e)?gt:n:n===gt?e===gt?t:gt:fs(e,t,n,o)}function nc(e,t,n,o){let r={},s=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let c of s){let l=us(to(e,c)?e[c]:gt,to(t,c)?t[c]:gt,to(n,c)?n[c]:gt,o);l!==gt&&tc(r,c,l)}return r}function oc(e){return e===null||typeof e!="object"}function Co(e){return typeof e+":"+String(e)}function rc(e,t){for(let n of t){let o=new Set;for(let r of n){if(!to(r,e))return!1;let s=r[e];if(typeof s!="string"&&typeof s!="number")return!1;let c=Co(s);if(o.has(c))return!1;o.add(c)}}return!0}function sc(e,t,n,o){let r=[e,t,n],s=!0;for(let c of r)for(let l of c)Bn(l)||(s=!1);if(s){for(let c of o.keyCandidates)if(rc(c,r))return{kind:"keyed",field:c};return null}for(let c of r){let l=new Set;for(let a of c){if(!oc(a))return null;let b=Co(a);if(l.has(b))return null;l.add(b)}}return{kind:"self"}}function ic(e,t,n,o){let r=sc(e,t,n,o);if(!r)return n;let s=r.kind==="self"?Co:u=>Co(u[r.field]),c=u=>{let h=new Map;for(let y of u)h.set(s(y),y);return h},l=c(e),a=c(t),b=c(n),p=new Map,g=new Set([...l.keys(),...a.keys(),...b.keys()]);for(let u of g){let h=us(l.has(u)?l.get(u):gt,a.has(u)?a.get(u):gt,b.has(u)?b.get(u):gt,o);h!==gt&&p.set(u,h)}let m=[];for(let u of n){let h=s(u);p.has(h)&&m.push(h)}for(let u=0;u<t.length;u++){let h=s(t[u]);if(!p.has(h)||m.includes(h))continue;let y=0;for(let S=u-1;S>=0;S--){let v=m.indexOf(s(t[S]));if(v!==-1){y=v+1;break}}m.splice(y,0,h)}return m.map(u=>p.get(u))}function ds(e,t,n,o={}){let r=o.keyCandidates?[...o.keyCandidates,...as]:as;return fs(e===void 0?gt:e,t,n,{keyCandidates:r})}function ir(e,t,n,o={}){let r=o.parse||sr,s=[],c=(g,m)=>{if(typeof g!="string")return gt;try{return r(g)}catch(u){return s.push(`${m} side is not valid JSON (${u.message})`),gt}},l=c(t,"local"),a=c(n,"remote");if(l===gt)return{text:n,warnings:s};if(a===gt)return{text:t,warnings:s};let b=c(e,"base"),p=ds(b===gt?void 0:b,l,a,o);return gn(p,a)?{text:n,warnings:s}:gn(p,l)?{text:t,warnings:s}:{text:JSON.stringify(p,null,2),warnings:s}}var Ee=e=>!!e&&e.nodeType===1,cc=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),hs=5e4;function cr(e,t,n,o){let r=o.ignored,s=Gr({ignored:r,ignoreAttribute:o.ignoreAttribute}),{unitsOf:c,meta:l}=s,a=o.baseURI,b=o.mergeTags!==null,p=A=>C=>{if(b&&C.tagName==="SCRIPT"){let R=jn(C,o.mergeTags);if(R)return"merge:"+R.key}return C.parentElement&&C.parentElement.tagName==="HEAD"?ls(C,a):A(C)},g=p(o.identity.base),m=p(o.identity.local),u=p(o.identity.remote),h=o.authored||o.identity,y=A=>A&&A.nodeType===9?A.documentElement:A,S=y(e),v=y(t),D=y(n),q=globalThis.__hyperMorphProfile,Z=q?performance.now():0,ae="[id],[data-id],script,head>*",ie=A=>A===wn?ae:null,he=Mo(S,g,r,ie(o.identity.base)),K=o.localIsBase?ms():qo(S,v,{analyzer:s,baseIndex:he,sideIndex:Mo(v,m,r,ie(o.identity.local)),baseId:h.base,sideId:h.local}),J=qo(S,D,{analyzer:s,baseIndex:he,sideIndex:Mo(D,u,r,ie(o.identity.remote)),baseId:h.base,sideId:h.remote});qe(),Ke(K,J),Ke(J,K),q&&(q.alignTotal=(q.alignTotal||0)+(performance.now()-Z),Z=performance.now());let ye=S.ownerDocument.implementation.createHTMLDocument(""),je=new WeakMap,Fe=new WeakMap,ot=[],ct=[],Ct=new Set,vt=[],Oe=new Set,dt=new Set,Qe=new Set,Lt=new WeakMap,rt=o.conflicts||"remote",et=A=>ot.push(A),lt=A=>ot.push(A),O=A=>ct.push(A),F=Ne(),ke=x(S,K.map.get(S),J.map.get(S),!!o.localIsBase,!!o.childrenOnly);ke.tagName==="HTML"?ye.replaceChild(ke,ye.documentElement):ye.body.appendChild(ke),q&&(q.build=(q.build||0)+(performance.now()-Z));let re=o.childrenOnly?!Ge(ft(ke),ft(D)):!bt(ke,D);return{doc:ye,root:ke,provenance:je,textMappers:Fe,decisions:ot,conflicts:ct,localDiverged:re,mergedScripts:Ct,segments:vt,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==wn,L:K,R:J};function Ne(){let A=new Map,C=new Set;if(o.localIsBase||!K.insertedByHash)return{partner:A,drop:C};let R=K.insertedByHash(),U=J.insertedByHash();if(!R.size||!U.size)return{partner:A,drop:C};let H={ignored:r,remoteWins:o.remoteWins,inlineCache:Lt},_=ue=>{let Ve=0;for(let Te=ue.parentNode;Te;Te=Te.parentNode)Ve++;return Ve},z=[],ne=ue=>{let Ve=ue.textContent.trim();return Ve.split(/\s+/).length>=3||Ve.replace(/\s/g,"").length>=12},pe=ue=>{let Ve=K.map.get(ue),Te=J.map.get(ue);return Ve&&K.reverse.get(Ve.parentNode)!==ue.parentNode||Te&&J.reverse.get(Te.parentNode)!==ue.parentNode},fe=(ue,Ve,Te)=>{for(let wt of Te.parentNode.children){let Ot=wt!==Te&&ue.reverse.get(wt);if(Ot&&pe(Ot))return!0}let It=ue.reverse.get(Te.parentNode);if(It){for(let wt of It.children)if(!Ve.map.has(wt)&&!r(wt))return!0}return!1};for(let[ue,Ve]of R){let Te=U.get(ue);if(!Te)continue;let It=Ve.length===1&&Te.length===1;for(let wt of Ve)xn(wt,H)||z.push([wt,Te,_(wt),It&&(ne(wt)||fe(K,J,wt)||fe(J,K,Te[0]))])}if(!z.length)return{partner:A,drop:C};z.sort((ue,Ve)=>ue[2]-Ve[2]);let me=new Set,Pe=new Set,Le=ue=>{for(let Ve of ue.querySelectorAll("*"))me.add(Ve)},kt=(ue,Ve)=>ue.reverse.get(Ve.parentNode)||null;for(let[ue,Ve,,Te]of z){if(me.has(ue))continue;let It=kt(K,ue),wt=ht=>!Pe.has(ht)&&!me.has(ht)&&ht.tagName===ue.tagName,Ot=Ve.find(ht=>wt(ht)&&It&&kt(J,ht)===It)||(Te?Ve.find(wt):null);Ot&&(Pe.add(Ot),Le(ue),Le(Ot),!(It&&kt(J,Ot)===It)&&(A.set(ue,Ot),A.set(Ot,ue),C.add(rt==="local"?Ot:ue)))}return{partner:A,drop:C}}function tt(A,C,R){if(Oe.add(A),F.drop.has(A))return null;Oe.add(R);let U=C==="local"?A:R,H=C==="local"?R:A,_;return s.unitHash(U)===s.unitHash(H)?(_=we(U,"local",!0),je.get(_).remote=H):_=Q(U,H),O({kind:"structure",el:_,detail:"both-moved",base:null,local:U,remote:H}),et({kind:"insert",el:_,source:"both"}),_}function qe(){if(!K.weak||!J.weak||!K.weak.size||!J.weak.size||!K.unpair)return;let A=new Map;for(let R of K.weak){let U=K.map.get(R);Ee(R)&&Ee(U)&&A.set(s.unitHash(U),R)}let C=!1;for(let R of Array.from(J.weak)){let U=J.map.get(R);if(!Ee(R)||!Ee(U))continue;let H=A.get(s.unitHash(U));!H||H===R||!K.weak.has(H)||K.map.has(R)&&J.map.has(H)||K.map.get(H).tagName===U.tagName&&(K.unpair(H),J.unpair(R),C=!0)}C&&(K.rematch(),J.rematch())}function Ke(A,C){if(!A.weak||!A.weak.size||!C.insertedByHash)return;let R=C.insertedByHash();if(!R.size)return;let U=!1;for(let H of Array.from(A.weak)){let _=A.map.get(H);if(!_)continue;let z=R.get(s.unitHash(_));z&&z.some(ne=>ne.tagName===_.tagName)&&(A.unpair(H),U=!0)}U&&A.rematch()}function Ze(A,C){if(A.map.has(C))return A.map.get(C);let R=[];for(let H=C.parentNode;H&&!A.map.has(H);H=H.parentNode)R.push(H);let U=R.length?R[R.length-1].parentNode:C.parentNode;if(!U||!A.identical.has(U))return null;A.pairIdenticalChildren(U);for(let H=R.length-1;H>=0;H--)A.pairIdenticalChildren(R[H]);return A.map.get(C)||null}function at(A,C,R){if(dt.has(A)||Qe.has(A))return O({kind:"structure",el:null,detail:"both-moved",base:A}),dt.has(A)?null:we(R,C);let U=Ze(K,A),H=Ze(J,A);(!U||!H)&&O({kind:"structure",el:null,detail:"move-beats-delete",base:A});let _=x(A,U,H,!1);return(C==="local"?et:lt)({kind:"move",el:_,source:C}),_}function f(A,C,R,U){return U||!C||C===R?{el:R,asBase:!0,twin:H=>H,baseOf:H=>H,units:c(R),here:()=>!0,parentOfTwin:()=>R}:{el:C,asBase:!1,twin:H=>A.map.get(H),baseOf:H=>A.reverse.get(H),units:c(C),here:H=>Ee(H)?H.parentNode===C||C.tagName==="TEMPLATE"&&H.parentNode===C.content:H.parent===C||C.tagName==="TEMPLATE"&&H.parent===C.content}}function T(A,C,R){return!C||R&&R.identical.has(A)?!1:Ee(A)?l(A).hash!==l(C).hash:A.value!==C.value}function x(A,C,R,U,H=!1){let _=U||o.remoteWins(A),z=A.namespaceURI&&A.namespaceURI!=="http://www.w3.org/1999/xhtml"?ye.createElementNS(A.namespaceURI,A.tagName):ye.createElement(A.tagName),ne={base:A,local:C||null,remote:R||null};if(je.set(z,ne),Oe.add(A),dt.add(A),C&&Oe.add(C),R&&Oe.add(R),o.skipUnchanged&&!H&&(o.localIsBase||K.identical.has(A))&&R&&J.identical.has(A)&&!o.remoteWins(A)){ne.unchanged=!0;for(let fe of A.attributes)fe.namespaceURI?z.setAttributeNS(fe.namespaceURI,fe.name,fe.value):z.setAttribute(fe.name,fe.value);return z}Qe.add(A),H||E(A,_?A:C,R,z);let pe=A.tagName;if(Wt(A))I(A,_?A:C,R,z);else if(pe==="TEXTAREA")z.textContent=B(A.textContent,(_?A:C)?(_?A:C).textContent:A.textContent,R?R.textContent:A.textContent,z,"text");else{let fe=Ye(A,C,R,_,z),me=pe==="TEMPLATE"&&z.content?z.content:z;for(let Pe of fe)me.appendChild(Pe)}return Qe.delete(A),z}function B(A,C,R,U,H){if(C===R)return C;if(C===A)return R!==A&<({kind:H,node:U,source:"remote"}),R;if(R===A)return et({kind:H,node:U,source:"local"}),C;let _=rt==="local"?C:R;return O({kind:H,node:U,base:A,local:C,remote:R,resolved:_}),ot.push({kind:H,node:U,source:"both"}),_}function I(A,C,R,U){let H=A.textContent,_=C?C.textContent:H,z=R?R.textContent:H,ne=b?jn(A,o.mergeTags,!0):null;if(ne&&_!==z){let pe=R&&R.getAttribute("merge-key")||A.getAttribute("merge-key"),{text:fe,warnings:me}=ir(o.localIsBase?void 0:H,_,z,{parse:ne.recognizer.parse,keyCandidates:pe?pe.split(/[\s,]+/).filter(Boolean):void 0});for(let Pe of me)console.warn(`[hyper-morph] merge "${ne.raw}": ${Pe}`);U.textContent=fe,Ct.add(U),fe!==z?et({kind:"text",node:U,source:fe===_?"local":"both"}):fe!==H&<({kind:"text",node:U,source:"remote"});return}U.textContent=B(H,_,z,U,"text")}function E(A,C,R,U){let H=new Map;for(let _ of[A,C,R])if(_)for(let z of _.attributes)o.ignoreAttribute(_,z.name)||H.set(z.name,z);for(let[_,z]of H){let ne=A?A.getAttribute(_):null,pe=C?C.getAttribute(_):ne,fe=R?R.getAttribute(_):ne,me;pe===fe?me=pe:pe===ne?(me=fe,lt({kind:"attr",el:U,name:_,source:"remote"})):fe===ne?(me=pe,et({kind:"attr",el:U,name:_,source:"local"})):(me=j(_,ne,pe,fe),me===void 0&&(me=rt==="local"?pe:fe,O({kind:"attr",el:U,name:_,base:ne,local:pe,remote:fe,resolved:me})),ot.push({kind:"attr",el:U,name:_,source:"both"})),me!=null&&(z.namespaceURI?U.setAttributeNS(z.namespaceURI,z.name,me):U.setAttribute(_,me))}}function j(A,C,R,U){if(A==="class"){let H=fe=>new Set((fe||"").split(/\s+/).filter(Boolean)),_=H(C),z=H(R),ne=H(U),pe=new Set;for(let fe of new Set([..._,...z,...ne])){let me=_.has(fe),Pe=z.has(fe),Le=ne.has(fe);(Pe===Le?Pe:Pe===me?Le:Pe)&&pe.add(fe)}return[...pe].join(" ")}if(A==="style"){let H=me=>{let Pe=new Map;if(!me)return Pe;let Le=0,kt=null,ue="",Ve=()=>{let Te=ue.indexOf(":");Te>0&&Pe.set(ue.slice(0,Te).trim(),ue.slice(Te+1).trim()),ue=""};for(let Te of me){if(kt){ue+=Te,Te===kt&&(kt=null);continue}if(Te==='"'||Te==="'"){kt=Te,ue+=Te;continue}if(Te==="("?Le++:Te===")"&&Le--,Te===";"&&Le===0){Ve();continue}ue+=Te}return ue.trim()&&Ve(),Pe},_=H(C),z=H(R),ne=H(U),pe=new Map,fe=!1;for(let me of new Set([..._.keys(),...z.keys(),...ne.keys()])){let Pe=_.get(me)??null,Le=z.get(me)??null,kt=ne.get(me)??null,ue;Le===kt?ue=Le:Le===Pe?ue=kt:kt===Pe?ue=Le:(ue=rt==="local"?Le:kt,fe=!0),ue!=null&&pe.set(me,ue)}return fe?void 0:[...pe].map(([me,Pe])=>`${me}: ${Pe}`).join("; ")}}function M(A,C,R,U){let H=A.value,_=U?H:C?C.value:"",z=R?R.value:"";Oe.add(A),C&&Oe.add(C),R&&Oe.add(R);let ne=Xn(H,_,z,rt),pe=ne.text===""?null:ye.createTextNode(ne.text);pe&&(je.set(pe,{base:A.nodes,local:C?C.nodes:null,remote:R?R.nodes:null}),Fe.set(pe,ne.mapLocalOffset)),_!==H&&z!==H?ot.push({kind:"text",node:pe,source:"both"}):_!==H?et({kind:"text",node:pe,source:"local"}):z!==H&<({kind:"text",node:pe,source:"remote"});for(let fe of ne.conflicts)O({kind:"text",node:pe,base:H.slice(fe.bs,fe.be),local:fe.local,remote:fe.remote,resolved:fe.resolved});return pe}function P(A,C){return Zn(A,C).every(R=>R.bs===R.be)}function Y(A,C){let R=A?A.value:"",U=C?C.value:"",H;if(R===U||!U?H=R:R?P(R,U)?H=U:P(U,R)?H=R:(H=rt==="local"?R:rt==="both"?R+U:U,O({kind:"structure",el:null,detail:"insert-collision",local:R,remote:U,resolved:H})):H=U,A&&Oe.add(A),C&&Oe.add(C),H==="")return null;let _=ye.createTextNode(H);return je.set(_,{base:null,local:A?A.nodes:null,remote:C?C.nodes:null}),R?et({kind:"insert",el:_,source:U&&R===U?"both":"local"}):lt({kind:"insert",el:_,source:"remote"}),_}function Q(A,C){let R={ignored:r,remoteWins:o.remoteWins,inlineCache:Lt},U=ne=>c(ne).every(pe=>Ee(pe)?xn(pe,R):pe.kind==="text"),H=null;if(U(A)&&U(C)){let ne=A.textContent,pe=C.textContent;ne===pe||P(pe,ne)?H=C:P(ne,pe)&&(H=A)}if(!H){let ne=rt==="local",pe=we(ne?A:C,ne?"local":"remote",!0),fe=je.get(pe);return ne?fe.remote=C:fe.local=A,O({kind:"structure",el:pe,detail:"insert-collision",local:A,remote:C,resolved:ne?A:C}),pe}let _=A.namespaceURI&&A.namespaceURI!=="http://www.w3.org/1999/xhtml"?ye.createElementNS(A.namespaceURI,A.tagName):ye.createElement(A.tagName);E(null,A,C,_),je.set(_,{base:null,local:A,remote:C}),Oe.add(A),Oe.add(C);let z=or({base:Array.from(H.childNodes),local:Array.from(A.childNodes),remote:Array.from(C.childNodes),out:ye,policy:rt,idOf:{local:m,remote:u},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:je,textMappers:Fe,conflicts:ct,decisions:ot,node:_});vt.push(...z.segments);for(let ne of z.nodes)_.appendChild(ne);return _}function we(A,C,R=!1){if(!R&&Ee(A)){let z=F.partner.get(A);if(z)return tt(A,C,z)}if(!Ee(A)){if(A.value==="")return null;let z=A.kind==="comment"?ye.createComment(A.value):ye.createTextNode(A.value);return je.set(z,{base:null,local:C==="local"?A.nodes:null,remote:C==="remote"?A.nodes:null}),Oe.add(A),z}let U=A.namespaceURI&&A.namespaceURI!=="http://www.w3.org/1999/xhtml"?ye.createElementNS(A.namespaceURI,A.tagName):ye.createElement(A.tagName);for(let z of A.attributes)z.namespaceURI?U.setAttributeNS(z.namespaceURI,z.name,z.value):U.setAttribute(z.name,z.value);je.set(U,{base:null,local:C==="local"?A:null,remote:C==="remote"?A:null}),Oe.add(A);let H=A.tagName==="TEMPLATE"&&U.content?U.content:U,_=C==="local"?K:J;for(let z of c(A)){let ne=Ee(z)?_.reverse.get(z):null;if(ne&&dt.has(ne)){O({kind:"structure",el:null,detail:"both-moved",base:ne});continue}if(ne&&!Qe.has(ne)){let fe=K.map.get(ne)||null,me=J.map.get(ne)||null;if(fe||me){let Pe=x(ne,fe,me,!1);C==="local"?et({kind:"move",el:Pe,source:"local"}):lt({kind:"move",el:Pe,source:"remote"}),H.appendChild(Pe);continue}}let pe=we(z,C);pe&&H.appendChild(pe)}return U}function Ye(A,C,R,U,H){C&&K.identical.has(A)&&K.pairIdenticalChildren(A),R&&J.identical.has(A)&&J.pairIdenticalChildren(A);let _=f(K,C,A,U),z=f(J,R,A,!1),ne=c(A),pe=new Set(ne),fe=new Map;for(let W=0;W<ne.length;W++)fe.set(ne[W],W);let me=[],Pe=new Set,Le=new Map,kt=new Set,ue=new Set,Ve=[];wo();let Te=W=>{let xe=[];for(let de of W.units){if(ue.has(de))continue;let Me=W.baseOf(de);Me&&pe.has(Me)&&xe.push(fe.get(Me))}return xe},It=W=>W.every((xe,de)=>de===0||xe>=W[de-1]),wt=!_.asBase&&!It(Te(_)),Ot=!z.asBase&&!It(Te(z));wt&&Ot&&O({kind:"structure",el:null,detail:"both-reordered",base:A});let ht=Ot||!wt?{V:z,A:J,side:"remote",other:_,otherA:K,otherSide:"local"}:{V:_,A:K,side:"local",other:z,otherA:J,otherSide:"remote"};wt?et({kind:"move",el:null,source:Ot?"both":"local",base:A}):Ot&<({kind:"move",el:null,source:"remote",base:A});let zn=_.asBase?[]:_.units.filter(W=>!_.baseOf(W)&&!ue.has(W)&&!F.partner.has(W)),qn=z.asBase?[]:z.units.filter(W=>!z.baseOf(W)&&!ue.has(W)&&!F.partner.has(W)),rn=new Map;if(zn.length&&qn.length){let W=new Map,xe=new Map;for(let te of qn){if(Ee(te)){let ee=u(te);ee&&W.set(ee,te)}let Ae=s.unitHash(te);xe.has(Ae)||xe.set(Ae,[]),xe.get(Ae).push(te)}let de=(te,Ae)=>{let ee=te.units.indexOf(Ae);for(let ve=ee-1;ve>=0;ve--){let He=te.baseOf(te.units[ve]);if(He)return He}return"start"},Me=new Map,_e=new Map;for(let te of qn){let Ae=de(z,te);Ee(te)?(_e.has(Ae)||_e.set(Ae,[]),_e.get(Ae).push(te)):te.kind==="text"&&!Me.has(Ae)&&Me.set(Ae,te)}for(let te of zn){let Ae=null;if(Ee(te)){let ee=m(te);ee&&W.has(ee)&&!rn.has(W.get(ee))&&(Ae=W.get(ee))}else if(te.kind==="text"){let ee=Me.get(de(_,te));ee&&!rn.has(ee)&&(Ae=ee)}if(!Ae){let ee=xe.get(s.unitHash(te));ee&&(Ae=ee.find(ve=>!rn.has(ve)&&Ee(ve)===Ee(te)&&(Ee(ve)?ve.tagName===te.tagName:ve.kind===te.kind))||null)}if(!Ae&&Ee(te)){let ee=h.local(te),ve=(_e.get(de(_,te))||[]).filter(He=>{let Et=h.remote(He);return!rn.has(He)&&He.tagName===te.tagName&&!(ee&&Et&&ee!==Et)&&s.similar(te,He)});ve.length===1&&(Ae=ve[0])}Ae&&(rn.set(Ae,te),rn.set(te,Ae))}}let Gt=W=>{if(Oe.has(W))return Le.get(W)||null;let xe=_.twin(W),de=z.twin(W),Me=xe&&!_.asBase&&!_.here(xe),_e=de&&!z.asBase&&!z.here(de);if(Me||_e){if((!xe||!de)&&O({kind:"structure",el:null,detail:"move-beats-delete",base:W}),!Ut(W))return Oe.add(W),null;O({kind:"structure",el:null,detail:"both-moved",base:W})}if(!xe&&!de)return Oe.add(W),lt({kind:"remove",source:"both",base:W}),null;if(!xe&&!T(W,de,J))return Oe.add(W),et({kind:"remove",source:"local",base:W}),null;if(!de&&!T(W,xe,K))return Oe.add(W),lt({kind:"remove",source:"remote",base:W}),null;let te=!xe||!de,Ae=_.asBase?K.map.get(W)||null:xe,ee;return Ee(W)?ee=x(W,Ae,de,_.asBase):W.kind==="comment"?ee=yt(W,Ae,de,_.asBase):ee=M(W,Ae,de,_.asBase),Oe.add(W),ee&&(Le.set(W,ee),xe&&Le.set(xe,ee),de&&Le.set(de,ee),te&&(O({kind:"structure",el:ee,detail:"edit-beats-delete",base:W}),xe?et({kind:"insert",el:ee,source:"local"}):lt({kind:"insert",el:ee,source:"remote"}))),ee},vn=(W,xe,de,Me)=>{if(Oe.has(W))return Le.get(W)||null;let _e=xe.baseOf(W);if(_e&&pe.has(_e))return ue.has(_e)&&!ue.has(W)?bo(_e,W,Me):Gt(_e);if(_e)return yo(_e,W,Me);let te=rn.get(W);if(te){let ee=Me==="local"?W:te,ve=Me==="local"?te:W,He;return Ee(ee)?s.unitHash(ee)===s.unitHash(ve)?(He=we(ee,"local"),je.get(He).remote=ve):He=Q(ee,ve):He=Y(ee,ve),Oe.add(ee),Oe.add(ve),He&&(Le.set(ee,He),Le.set(ve,He),Ee(ee)&&et({kind:"insert",el:He,source:"both"})),He}let Ae=we(W,Me);return Ae&&(Le.set(W,Ae),Me==="local"?et({kind:"insert",el:Ae,source:"local"}):lt({kind:"insert",el:Ae,source:"remote"})),Ae},bo=(W,xe,de)=>{let Me;return Ee(W)?(Me=at(W,de,xe),Me&&Oe.add(xe)):(Me=we(xe,de),Oe.add(xe),Me&&(de==="local"?et:lt)({kind:"insert",el:Me,source:de})),Me&&Le.set(xe,Me),Me},yo=(W,xe,de)=>{let _e=(de==="local"?J:K).map.get(W),te=xe,Ae=_e?At(_e,de==="local"?R:C,de==="local"?J:K):!1,ee=_e&&!Ae&&!xt(W,_e);if(ee&&de===ht.otherSide)return O({kind:"structure",el:null,detail:"both-moved",base:W}),null;if(ee&&O({kind:"structure",el:null,detail:"both-moved",base:W}),_e||O({kind:"structure",el:null,detail:"move-beats-delete",base:W}),Qe.has(W)){O({kind:"structure",el:null,detail:"both-moved",base:W});let He=we(te,de);return He&&Le.set(xe,He),He}let ve=Ee(W)?x(W,de==="local"?te:K.map.get(W)||null,de==="remote"?te:J.map.get(W)||null,!1):null;return ve&&(Le.set(W,ve),Le.set(xe,ve),_e&&Le.set(_e,ve),de==="local"?et({kind:"move",el:ve,source:"local"}):lt({kind:"move",el:ve,source:"remote"})),ve};for(let W of ht.V.units){if(ue.has(W)){let de=Le.get(W);Pe.has(de)||(me.push(de),Pe.add(de));continue}if(Oe.has(W)&&!(Le.get(W)&&Pe.has(Le.get(W)))){let de=ht.V.baseOf(W);de&&!pe.has(de)&&O({kind:"structure",el:null,detail:"both-moved",base:de});continue}let xe=vn(W,ht.V,ht.A,ht.side);xe&&!Pe.has(xe)&&(me.push(xe),Pe.add(xe),!ht.V.baseOf(W)&&!rn.has(W)&&!ue.has(W)&&kt.add(xe))}for(let W of Ve)Pe.has(W.frag)||(me.splice(ko(W.at),0,W.frag),Pe.add(W.frag));if(!ht.other.asBase){let W=ht.other,xe=ht.otherSide,de=ht.otherA,Me=null,_e=0,te=null;for(let Ae of W.units){let ee=Le.get(Ae);if(ee&&Pe.has(ee)){Me=ee,te=null;continue}if(Oe.has(Ae)){let Et=W.baseOf(Ae);Et&&!pe.has(Et)&&O({kind:"structure",el:null,detail:"both-moved",base:Et});continue}let ve=vn(Ae,W,de,xe);if(!ve)continue;let He;if(te)He=me.indexOf(te)+1;else if(Me){if(He=me.indexOf(Me)+1,xe==="remote")for(;He<me.length&&kt.has(me[He]);)He++}else He=_e++;me.splice(He,0,ve),Pe.add(ve),te=ve}}for(let W=0;W<ne.length;W++){let xe=ne[W];if(Oe.has(xe))continue;let de=Gt(xe);de&&me.splice(ko(W),0,de)}return me;function ko(W){for(let xe=W-1;xe>=0;xe--){let de=Le.get(ne[xe]);if(de){let Me=me.indexOf(de);if(Me>=0)return Me+1}}return 0}function In(W){let xe={ignored:r,remoteWins:()=>!1},de=V=>W(V)||Ee(V)&&o.remoteWins(V)&&sn.has(V.tagName)&&xn(V,xe),Me=new Map,_e=V=>{if(!Ee(V)||!cc.has(V.tagName))return!1;let ce=Me.get(V);return ce===void 0&&(ce=!r(V)&&!o.remoteWins(V)&&c(V).every(de),Me.set(V,ce)),ce},te=V=>!Ee(V)&&V.kind==="text",Ae=null,ee=new Map,ve=V=>{let ce=ee.get(V);if(ce)return ce;let ge=Ee(V)?V.textContent:V.value;ce=new Set;let Ce=ge.toLowerCase();if(!(ge.length>hs))if(/^[\x00-\x7f]*$/.test(Ce))for(let Se of Ce.split(/[^\p{L}\p{N}]+/u))Se&&ce.add(Se);else for(let Se of Xo(Ce))/^[\s\p{P}]+$/u.test(Se)||ce.add(Se);return ee.set(V,ce),ce},He=V=>(Ee(V)?V.textContent:V.value).toLowerCase().replace(/\s+/g," ").trim(),Et=new Map,Jt=V=>{let ce=Et.get(V);if(ce)return ce;ce=new Set(ve(V));let ge=Se=>{if(Se)for(let $e of ve(Se))ce.add($e)},Ce=pe.has(V)?V:!_.asBase&&_.baseOf(V)||!z.asBase&&z.baseOf(V);return Ce&&(ge(Ce),ge(K.map.get(Ce)),ge(J.map.get(Ce))),Et.set(V,ce),ce},an=(V,ce)=>{let ge=He(ce),Ce=pe.has(V)?V:!_.asBase&&_.baseOf(V)||!z.asBase&&z.baseOf(V),Se=ut=>ge?ut.split(ge).length-1:0;if(Ce&&Ee(ce)&&!pe.has(ce)){let ut=Se(He(Ce));for(let pt of[K.map.get(Ce),J.map.get(Ce)]){if(!pt||pt===ce||pt.ownerDocument!==ce.ownerDocument)continue;let qt=He(pt);if(qt.length>ge.length&&Se(qt)>=ut&&(qt.startsWith(ge)||qt.endsWith(ge)))return!1}}let $e=ve(ce),Xe=Jt(V),Pt=0;for(let ut of $e)Xe.has(ut)&&Pt++;if($e.size&&Pt*2>=$e.size)return!0;if(!ge||ge.length>hs)return!1;let _t=Ce?[V,Ce,K.map.get(Ce),J.map.get(Ce)]:[V],Vt=(ut,pt)=>ut!==pt&&(ut.startsWith(pt)||ut.endsWith(pt));if(_t.some(ut=>ut&&Vt(He(ut),ge)))return!0;if(!pe.has(ce)||!Ce)return!1;let Tt=He(V),zt=He(Ce);return[K.map.get(ce),J.map.get(ce)].some(ut=>{let pt=ut&&He(ut);return!!pt&&Tt!==pt&&(Tt.startsWith(pt)&&!zt.startsWith(pt)||Tt.endsWith(pt)&&!zt.endsWith(pt))})},Bt=V=>{Ae||(Ae=new Set),Ae.add(V)},hn=V=>{Bt(V);for(let[ce,ge]of[[K,_],[J,z]]){if(ge.asBase)continue;let Ce=ce.map.get(V);Ce&&ge.here(Ce)&&Bt(Ce)}},Re=(V,ce)=>V.asBase||ne.every(ge=>!Ee(ge)||ce.identical.has(ge)&&V.here(ce.map.get(ge)))&&V.units.every(ge=>!Ee(ge)||V.baseOf(ge));if(Re(_,K)&&Re(z,J))return null;let Ue=V=>{if(V.asBase)return!1;let ce=-1;for(let ge of V.units){let Ce=Ee(ge)?V.baseOf(ge):null;if(!Ce||!pe.has(Ce))continue;let Se=fe.get(Ce);if(Se<ce)return!0;ce=Se}return!1};if(Ue(_)||Ue(z))return null;for(let[V,ce]of[[_,K],[z,J]]){if(V.asBase||Re(V,ce))continue;let ge=V.units,Ce=ce===K?h.local:h.remote,Se=(se,We)=>{let st=Ee(se)&&h.base(se),Je=Ee(We)&&Ce(We);return!st||!Je||st===Je},$e=new Map;for(let se=0;se<ge.length;se++)$e.set(ge[se],se);let Xe=se=>!!se&&(Ee(se)?V.here(se):$e.has(se)),Pt=se=>{let We=V.twin(se);return Xe(We)?We:null},_t=ne.filter(se=>!V.twin(se)&&_e(se)),Vt=ge.filter(se=>!V.baseOf(se)&&_e(se)),Tt=(se,We)=>We===ne?!!Pt(se):pe.has(V.baseOf(se)),zt=se=>{let We=new Int32Array(se.length),st=new Int32Array(se.length),Je=-1;for(let ze=0;ze<se.length;ze++)We[ze]=Je,Tt(se[ze],se)&&(Je=ze);Je=se.length;for(let ze=se.length-1;ze>=0;ze--)st[ze]=Je,Tt(se[ze],se)&&(Je=ze);return{prev:We,next:st}},ut=zt(ge),pt=zt(ne),qt=(se,We)=>{hn(se),Bt(We)};for(let se of Vt){let We=$e.get(se),st=ut.prev[We],Je=ut.next[We],ze=st>=0?V.baseOf(ge[st]):null,tn=Je<ge.length?V.baseOf(ge[Je]):null,Yt=ze?fe.get(ze):-1,pn=tn?fe.get(tn):ne.length;for(let Kt=Math.max(0,Yt);Kt<=Math.min(pn,ne.length-1);Kt++){let jt=ne[Kt];(_e(jt)||te(jt))&&(!Se(jt,se)||!an(jt,se)||(te(jt)?Bt(se):qt(jt,se)))}}let en=(se,We,st)=>{for(let Je=We+st;Je>=0&&Je<se.length;Je+=st){let ze=se[Je];if(_e(ze))return ze;if(Ee(ze)||ze.value.trim())return null}return null},Ao=se=>{let We=new Set;for(let st of c(se))if(!Ee(st)&&st.kind==="text")for(let Je of ve(st))We.add(Je);return We},Kn=(se,We)=>{let st=ve(We),Je=new Set;for(let ze of Ao(se))st.has(ze)||Je.add(ze);return Je},Gn=(se,We)=>{if(!se.size)return!1;let st=ve(We),Je=0;for(let ze of se)st.has(ze)&&Je++;return Je*2>=se.size};for(let se of ne){if(ce.identical.has(se)||!_e(se))continue;let We=Pt(se);if(!We||!_e(We))continue;let st=Kn(We,se),Je=Kn(se,We);for(let ze of[-1,1]){let tn=en(ne,fe.get(se),ze);tn&&Gn(st,tn)&&(qt(se,We),hn(tn));let Yt=en(ge,$e.get(We)??-1,ze);if(Yt&&Gn(Je,Yt)){qt(se,We);let pn=V.baseOf(Yt);pn?qt(pn,Yt):Bt(Yt)}}}for(let se of _t){let We=fe.get(se),st=pt.prev[We],Je=pt.next[We],ze=st>=0?Pt(ne[st]):null,tn=Je<ne.length?Pt(ne[Je]):null,Yt=ze?$e.get(ze)??-1:-1,pn=tn?$e.get(tn)??-1:ge.length;for(let Kt=Math.max(0,Yt);Kt<=Math.min(pn,ge.length-1);Kt++){let jt=ge[Kt];if((_e(jt)||te(jt))&&!(!Se(se,jt)||!an(jt,se))&&(hn(se),!te(jt))){let $t=V.baseOf(jt);$t?qt($t,jt):Bt(jt)}}}}if(!Ae)return null;for(let V of Array.from(Ae))if(pe.has(V))for(let ce of[K,J]){let ge=ce.map.get(V);ge&&ge.parentNode!==(ce===K?C:R)&&!(ce===K?_:z).asBase&&Ae.delete(V)}return Ae.size?Ae:null}function wo(){if((_.asBase||K.identical.has(A))&&(z.asBase||J.identical.has(A)))return;let W={ignored:r,remoteWins:o.remoteWins,inlineCache:Lt},xe=Re=>Ee(Re)?xn(Re,W):Re.kind==="text",de=In(xe),Me=Re=>de&&de.has(Re)||xe(Re),_e=ne.map(Me);if(!_e.includes(!0))return;let te=Re=>{let Ue=Re.units,V=new Map;for(let Xe=0;Xe<Ue.length;Xe++)V.set(Ue[Xe],Xe);let ce=[],ge=-1;for(let Xe=0;Xe<ne.length;Xe++){if(_e[Xe])continue;let Pt=Re.twin(ne[Xe]),_t=Pt?V.get(Pt):void 0;_t===void 0||_t<=ge||Me(Pt)||(ce.push([Xe,_t]),ge=_t)}let Ce=[],Se=-1,$e=-1;for(let Xe=0;Xe<=ce.length;Xe++){let[Pt,_t]=Xe<ce.length?ce[Xe]:[ne.length,Ue.length],Vt={bLo:-1,bHi:-1,sLo:-1,sHi:-1,next:_t};for(let Tt=Se+1;Tt<Pt;Tt++)_e[Tt]&&(Vt.bLo<0&&(Vt.bLo=Tt),Vt.bHi=Tt);for(let Tt=$e+1;Tt<_t;Tt++)Me(Ue[Tt])&&(Vt.sLo<0&&(Vt.sLo=Tt),Vt.sHi=Tt);Ce.push(Vt),Se=Pt,$e=_t}return{units:Ue,list:Ce}},Ae=te(_),ee=te(z),ve=[];for(let Re of[Ae,ee])for(let Ue of Re.list)Ue.bLo>=0&&ve.push([Ue.bLo,Ue.bHi]);ve.sort((Re,Ue)=>Re[0]-Ue[0]);let He=[];for(let[Re,Ue]of ve){let V=He[He.length-1];V&&Re<=V.hi?V.hi=Math.max(V.hi,Ue):He.push({lo:Re,hi:Ue})}let Et=(Re,Ue)=>{let V=-1,ce=-1;for(let Se=0;Se<Re.list.length;Se++){let $e=Re.list[Se];$e.bLo<Ue.lo||$e.bLo>Ue.hi||(V<0&&(V=Se),ce=Se)}let ge=1/0,Ce=-1;for(let Se=V;Se>=0&&Se<=ce;Se++){let $e=Re.list[Se];$e.sLo>=0&&(ge=Math.min(ge,$e.sLo),Ce=Math.max(Ce,$e.sHi)),Se<ce&&(ge=Math.min(ge,$e.next),Ce=Math.max(Ce,$e.next))}return Ce<0?[]:Re.units.slice(ge,Ce+1)},Jt=(Re,Ue)=>Re.length===Ue.length&&Re.every((V,ce)=>s.unitHash(V)===s.unitHash(Ue[ce])),an=Re=>!Ee(Re)&&Re.kind==="comment",Bt=Re=>{if(!Re.length)return[];let Ue=(Se,$e)=>Ee(Se)?Se:Se.nodes[$e?Se.nodes.length-1:0],V=Ue(Re[0]),ce=Ue(Re[Re.length-1],!0),ge=Se=>Se&&Ee(Se)&&r(Se);for(;ge(V.previousSibling);)V=V.previousSibling;for(;ge(ce.nextSibling);)ce=ce.nextSibling;let Ce=[];for(let Se=V;Se&&(Ce.push(Se),Se!==ce);Se=Se.nextSibling);return Ce},hn=Re=>Re.some(Ue=>Ee(Ue)&&r(Ue));for(let Re of He){let Ue=ne.slice(Re.lo,Re.hi+1),V=_.asBase?null:Et(Ae,Re),ce=z.asBase?null:Et(ee,Re);if(Ue.some(an)||V&&V.some(an)||ce&&ce.some(an))continue;let ge=Bt(V||Ue),Ce=Bt(ce||Ue);if((!V||Jt(Ue,V))&&(!ce||Jt(Ue,ce))&&!(V&&hn(ge)))continue;let Se=or({base:Bt(Ue),local:ge,remote:Ce,out:ye,policy:rt,blocks:de,L:V?K:ps(K,A),R:ce?J:ps(J,A),idOf:{local:m,remote:u},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Xe,Pt,_t)=>x(Xe,Pt,_t,!1),cloneUnit:we,mergeAttrs:E,atomKey:s.unitHash,moveIn:at,provenance:je,textMappers:Fe,conflicts:ct,decisions:ot,node:H});vt.push(...Se.segments);let $e=ye.createDocumentFragment();for(let Xe of Se.nodes)$e.appendChild(Xe);for(let Xe of[...Ue,...V||[],...ce||[]])Oe.add(Xe),ue.add(Xe),Le.set(Xe,$e);Ve.push({frag:$e,at:Re.lo})}}}function bt(A,C){let R=je.get(A);return R&&R.unchanged?!0:A.tagName!==C.tagName||!le(A,C)?!1:Ge(ft(A),ft(C))}function ft(A){return A.tagName==="TEMPLATE"&&A.content?A.content:A}function le(A,C){let R=0;for(let U of A.attributes)if(!o.ignoreAttribute(A,U.name)&&(R++,C.getAttribute(U.name)!==U.value))return!1;for(let U of C.attributes)o.ignoreAttribute(C,U.name)||R--;return R===0}function Ge(A,C){let R=Rt(A,H=>{let _=je.get(H);return!!(_&&_.pinned)}),U=Rt(C,r);if(R.length!==U.length)return!1;for(let H=0;H<R.length;H++){let _=R[H],z=U[H];if(typeof _=="string"||typeof z=="string"){if(_!==z)return!1}else{if(_.nodeType!==z.nodeType)return!1;if(_.nodeType===1){if(!bt(_,z))return!1}else if(_.nodeValue!==z.nodeValue)return!1}}return!0}function Rt(A,C){let R=[],U=null;for(let H=A.firstChild;H;H=H.nextSibling){if(H.nodeType===3){U=U===null?H.nodeValue:U+H.nodeValue;continue}H.nodeType===1&&C(H)||(U!==null&&(U!==""&&R.push(U),U=null),R.push(H))}return U!==null&&U!==""&&R.push(U),R}function yt(A,C,R,U){let H=A.value,_=U?H:C?C.value:"",z=R?R.value:"";Oe.add(A),C&&Oe.add(C),R&&Oe.add(R);let ne=_===z?_:_===H?z:z===H||rt==="local"?_:z;if(_!==H&&z!==H&&_!==z&&O({kind:"text",node:null,base:H,local:_,remote:z,resolved:ne}),!C&&!R)return null;let pe=ye.createComment(ne);return je.set(pe,{base:A.nodes,local:C?C.nodes:null,remote:R?R.nodes:null}),pe}function Dt(A,C){let R=C.map.get(A);if(!R)return null;let U=Ee(R)?R.parentNode:R.parent,H=Ee(A)?A.parentNode:A.parent;return C.map.get(H)===U?null:C.reverse.get(U)||null}function Ut(A){let C=new Set([A]),R=A;for(let U=0;U<64;U++){let H=Dt(R,K)||Dt(R,J);if(!H)return!1;if(H===A||Ee(A)&&Ee(H)&&A.contains(H)||C.has(H))return!0;C.add(H),R=H}return!0}function At(A,C,R){if(!C)return!1;let U=Ee(A)?A.parentNode:A.parent;return U===C||C.tagName==="TEMPLATE"&&U===C.content}function xt(A,C){let R=Ee(A)?A.parentNode:A.parent,U=Ee(C)?C.parentNode:C.parent;return!!(K.map.get(R)===U?K:J.map.get(R)===U?J:null)}}function ps(e,t){return e.map.get(t)?ms():{map:{get:o=>o&&o.nodeType===1&&e.map.get(o)||o,has:()=>!0},reverse:{get:o=>e.reverse.get(o)||o,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function ms(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var gs=new Set(["INPUT","OPTION","TEXTAREA"]);function bs(e,t,n,o){let r=e.ownerDocument,{provenance:s,textMappers:c}=n,l=o.hooks,a=[],b=[],p=[],g=new Set,m=[],u=[],h=new Set,y=new Map,S=f=>!!f&&(f===e||e.contains(f)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(f)),v=new Map,D=new Map,q=new Map,Z=new Map;(function f(T){let x=s.get(T);if(x){if(T.nodeType===1){let I=x.local?o.toLive(x.local):null;I&&S(I)&&I.nodeType===1&&(v.set(T,I),D.set(I,T))}else if(Array.isArray(x.local)){let I=K(x.local,x.local.map(E=>o.toLive(E)).filter(E=>E&&S(E)&&E.nodeType===T.nodeType));if(I.length&&(v.set(T,I[0]),D.set(I[0],T),q.set(T,I)),Array.isArray(x.caret))for(let E of x.caret){let j=o.toLive(E.node);if(!j||!S(j)||j.nodeType!==3)continue;let M=Z.get(j);Array.isArray(M)||Z.set(j,M=[]),M.push({merged:T,from:E.from,to:E.to,flatStart:E.flatStart})}else{let E=0;for(let j of I)Z.set(j,{merged:T,shift:E}),E+=j.nodeValue.length}}}let B=T.nodeType===1&&T.tagName==="TEMPLATE"&&T.content?T.content.childNodes:T.childNodes;for(let I of B)f(I)})(t);let ae=new Set;for(let f of v.values())ae.add(f);for(let f of q.values())for(let T of f)ae.add(T);for(let f of n.segments||[])J(f);let ie=o.restoreFocus===!1?null:lc(r,Z);o.childrenOnly?ot(ye(e),ye(t)):je(e,t);for(let{node:f,parent:T}of m)g.has(f)||!f.parentNode||f.nodeType===1&&(o.ignored(f)||ct(f))||lt(f,T);return ac(r,ie,Z,c,q,y),{applied:a,moved:b,replaced:p,identities:u,mergedScriptsLive:h,liveOf:v};function he(f,T){let x=f.slice(T.bs,T.be),B=0;for(;B<x.length&&B<T.text.length&&x[B]===T.text[B];)B++;let I=0;for(;I<x.length-B&&I<T.text.length-B&&x[x.length-1-I]===T.text[T.text.length-1-I];)I++;return{bs:T.bs+B,be:T.be-I,text:T.text.slice(B,T.text.length-I)}}function K(f,T){if(!T.length)return T;let x=new Set;for(let I of f){let E=I.parentNode;if(E)for(let j=E.firstChild;j;j=j.nextSibling)j.nodeType===3&&x.add(o.toLive(j))}let B=[];for(let I of T){B.push(I);for(let E=I.nextSibling;E&&E.nodeType===3&&!x.has(E)&&!B.includes(E);E=E.nextSibling)B.push(E)}return B}function J(f){let T=[];for(let le of f.localNodes){let Ge=o.toLive(le.node);if(!Ge||!S(Ge)||Ge.nodeType!==3)return;T.push(Ge)}let x=K(f.localNodes.map(le=>le.node),T);if(!x.length)return;let B=x.map(le=>le.nodeValue).join(""),{flatLocal:I,lToM:E,mapLocal:j}=f;if(B===I)return;let M=f.textNodes.map(le=>({node:le.node,ms:le.ms,me:le.me})),P=[],Y=0;for(let le of x)P.push(Y),Y+=le.nodeValue.length;let Q=(le,Ge)=>x.find((Rt,yt)=>P[yt]<=le&&le+Ge<=P[yt]+Rt.nodeValue.length)||null,we=[],Ye=0;for(let le of Zn(I,B).map(Ge=>he(I,Ge))){let Ge=le.bs+Ye;Ye+=le.text.length-(le.be-le.bs);let Rt,yt;if(le.be>le.bs){Rt=E[le.bs];let Dt=Rt>=0;for(let Ut=le.bs;Dt&&Ut<le.be;Ut++)E[Ut]!==Rt+(Ut-le.bs)&&(Dt=!1);if(!Dt)continue;yt=Rt+(le.be-le.bs)}else{let Dt=le.bs>0?E[le.bs-1]:0,Ut=le.bs<I.length?E[le.bs]:0;if(Dt<0||Ut<0)continue;Rt=yt=j(le.bs)}we.push({ms:Rt,me:yt,text:le.text,live:yt===Rt?Q(Ge,le.text.length):null})}we.sort((le,Ge)=>Ge.ms-le.ms);let bt=(le,Ge)=>(q.get(le.node)||[v.get(le.node)]).includes(Ge),ft=le=>!!le&&le.nodeType===1&&sn.has(le.tagName);for(let le of we){let Ge=M.find(yt=>yt.ms<=le.ms&&le.me<=yt.me&&le.ms<yt.me);if(Ge&&le.live&&Ge.ms===le.ms&&!bt(Ge,le.live)){let yt=M.find(Dt=>Dt.me===le.ms&&bt(Dt,le.live));yt&&(Ge=yt)}if(!Ge&&le.me===le.ms){let yt=M.find(xt=>xt.me===le.ms),Dt=M.find(xt=>xt.ms===le.ms),Ut=yt||Dt;if(!Ut)continue;let At=Ut.node;for(;ft(At.parentNode)&&(yt?At.parentNode.lastChild:At.parentNode.firstChild)===At;)At=At.parentNode;if(At===Ut.node)Ge=Ut;else{let xt=At.ownerDocument.createTextNode(le.text);At.parentNode.insertBefore(xt,yt?At.nextSibling:At);continue}}if(!Ge)continue;let Rt=Ge.node.nodeValue;Ge.node.nodeValue=Rt.slice(0,le.ms-Ge.ms)+le.text+Rt.slice(le.me-Ge.ms),Ge.me+=le.text.length-(le.me-le.ms)}}function ye(f){return f.nodeType===1&&f.tagName==="TEMPLATE"&&f.content?f.content:f}function je(f,T){g.add(f);let x=s.get(T);if(x&&x.remote&&n.remoteIdOf){let I=n.remoteIdOf(x.remote);I&&u.push([f,I])}if(x&&x.unchanged){n.customIdentity&&x.remote&&dt(f,x.remote),x.remote&&Oe(f,x.remote);return}if(l.beforeNodeMorphed(f,T)===!1)return;ke(f,T);let B=f.tagName;if(Wt(f))f.textContent!==T.textContent&&(a.push({kind:"text",node:f,before:f.textContent,after:T.textContent}),f.textContent=T.textContent),n.mergedScripts.has(T)&&h.add(f);else if(B==="TEXTAREA")at(f,T,x);else{Ke(f,T,x);let I=B==="TEMPLATE"&&f.content?f.content:f,E=B==="TEMPLATE"&&T.content?T.content:T;o.protectFocusedValue==="subtree"&&Ne(f)&&f!==r.body?Fe(I):ot(I,E)}l.afterNodeMorphed(f,T)}function Fe(f){for(let T=f.firstChild;T;T=T.nextSibling){let x=D.get(T);x&&v.get(x.parentNode)!==f||(g.add(T),T.nodeType===1&&Fe(T))}}function ot(f,T){let x=rt(f.firstChild),B=new Set;for(let I of Array.from(T.childNodes)){let E=v.get(I);E&&g.has(E)&&!B.has(E)&&(E=null);let j=s.get(I);if(j&&j.pinned){E&&E.nodeType===1&&((E.parentNode!==f||rt(E.nextSibling)!==x)&&et(f,E,x),g.add(E),B.add(E));continue}if(E&&E.nodeType===1){if(E!==x){let Y=E.parentNode;if(Y===f&&x&&tt(E)){let Q=E.nextSibling;for(let we=x;we&&we!==E;){let Ye=we.nextSibling;et(f,we,Q),we=Ye}}else et(f,E,x),Y!==f&&(b.push(E),a.push({kind:"move",el:E,from:Y,to:f}))}B.add(E),je(E,I),x=rt(E.nextSibling);continue}if(E&&E.nodeType!==1){let Y=q.get(I)||[E];E!==x&&et(f,E,x);let Q=I.nodeValue;if(I.nodeType===3){let we=Ct(I),Ye=Y.map(bt=>bt.nodeValue).join("");we!=null&&Ye!==we&&(Q=Xn(we,Ye,I.nodeValue).text)}l.beforeNodeMorphed(E,I)!==!1&&(E.nodeValue!==Q&&(a.push({kind:"text",node:E,before:E.nodeValue,after:Q}),E.nodeValue=Q),l.afterNodeMorphed(E,I)),g.add(E),B.add(E),y.set(I,E),x=rt(E.nextSibling);continue}if(I.nodeType===3&&x&&x.nodeType===3&&!g.has(x)&&!Z.has(x)){x.nodeValue!==I.nodeValue&&(a.push({kind:"text",node:x,before:x.nodeValue,after:I.nodeValue}),x.nodeValue=I.nodeValue),g.add(x),y.set(I,x),x=rt(x.nextSibling);continue}let M=s.get(I),P=O(M&&M.unchanged&&M.remote?M.remote:I);l.beforeNodeAdded(P)!==!1&&(f.insertBefore(P,x),g.add(P),P.nodeType===3&&y.set(I,P),P.nodeType===1&&(p.push(P),Lt(P,I),Wt(P)||F(P,I),o.formState==="property"&&qe(M)&&Oe(P,M.remote)),x=rt(P.nextSibling),a.push({kind:"insert",node:P,parent:f}),l.afterNodeAdded(P))}for(let I of Array.from(f.childNodes))g.has(I)||B.has(I)||I.nodeType===1&&(o.ignored(I)||ct(I))||(ae.has(I)?m.push({node:I,parent:f}):lt(I,f))}function ct(f){return o.preserve&&f.parentNode&&f.parentNode.nodeType===1&&f.parentNode.tagName==="HEAD"&&o.preserve(f)===!0}function Ct(f){let T=s.get(f);return!T||!Array.isArray(T.local)?null:T.local.map(x=>x.nodeValue).join("")}function vt(f){return s.get(f)}function Oe(f,T){if(!gs.has(f.tagName)&&!f.querySelector("input,option,textarea"))return;let x=(B,I)=>{if(B.tagName!==I.tagName)return;B.tagName==="TEXTAREA"?at(B,I,{remote:I}):gs.has(B.tagName)&&Ke(B,I,{remote:I});let E=Qe(B),j=Qe(I);if(E.length===j.length)for(let M=0;M<E.length;M++)x(E[M],j[M])};x(f,T)}function dt(f,T){let x=Qe(f),B=Qe(T);if(x.length===B.length)for(let I=0;I<x.length;I++){let E=n.remoteIdOf(B[I]);E&&u.push([x[I],E]),dt(x[I],B[I])}}function Qe(f){let T=f.tagName==="TEMPLATE"&&f.content?f.content:f;return Array.from(T.children).filter(x=>!o.ignored(x))}function Lt(f,T){if(!n.remoteIdOf)return;let x=(B,I)=>{let E=s.get(I);if(E&&E.remote&&I.nodeType===1){let P=n.remoteIdOf(E.remote);P&&u.push([B,P])}let j=B.childNodes,M=I.childNodes;for(let P=0;P<j.length&&P<M.length;P++)x(j[P],M[P])};x(f,T)}function rt(f){for(;f&&f.nodeType===1&&o.ignored(f);)f=f.nextSibling;return f}function et(f,T,x){if(typeof f.moveBefore=="function"&&T.ownerDocument===f.ownerDocument)try{f.moveBefore(T,x);return}catch{}f.insertBefore(T,x)}function lt(f,T){l.beforeNodeRemoved(f)!==!1&&(f.parentNode.removeChild(f),a.push({kind:"remove",node:f,parent:T}),l.afterNodeRemoved(f))}function O(f){if(Wt(f))return eo(f,r);let T=r.importNode(f,!0);if(T.nodeType===1)for(let x of Array.from(T.querySelectorAll("script")))Wt(x)&&x.replaceWith(eo(x,r));return T}function F(f,T){let x=f.tagName==="TEMPLATE"&&f.content?f.content:f,B=T.tagName==="TEMPLATE"&&T.content?T.content:T,I=Array.from(x.childNodes),E=Array.from(B.childNodes);for(let j=0;j<E.length&&j<I.length;j++){let M=E[j],P=I[j],Y=v.get(M);Y&&g.has(Y)&&(Y=null);let Q=s.get(M);if(Q&&Q.pinned){if(Y&&Y.nodeType===1){let we=Y.parentNode;et(x,Y,P),we!==x&&(b.push(Y),a.push({kind:"move",el:Y,from:we,to:x})),g.add(Y)}P.remove();continue}if(Y){let we=Y.parentNode;et(x,Y,P),P.remove(),Y.nodeType===1?(we!==x&&(b.push(Y),a.push({kind:"move",el:Y,from:we,to:x})),je(Y,M)):(g.add(Y),y.set(M,Y),Y.nodeValue!==M.nodeValue&&(a.push({kind:"text",node:Y,before:Y.nodeValue,after:M.nodeValue}),Y.nodeValue=M.nodeValue));continue}g.add(P),P.nodeType===3&&y.set(M,P),M.nodeType===1&&!Wt(M)&&F(P,M)}}function ke(f,T){for(let x of Array.from(T.attributes)){if(re(f,x.name)||o.ignoreAttribute(f,x.name))continue;let B=x.namespaceURI?f.getAttributeNS(x.namespaceURI,x.localName):f.getAttribute(x.name);B!==x.value&&l.beforeAttributeUpdated(x.name,f,"update")!==!1&&(x.namespaceURI?f.setAttributeNS(x.namespaceURI,x.name,x.value):f.setAttribute(x.name,x.value),a.push({kind:"attr",el:f,name:x.name,before:B,after:x.value}))}for(let x of Array.from(f.attributes)){if(re(f,x.name)||o.ignoreAttribute(f,x.name)||(x.namespaceURI?T.hasAttributeNS(x.namespaceURI,x.localName):T.hasAttribute(x.name))||l.beforeAttributeUpdated(x.name,f,"remove")===!1)continue;let I=x.value;x.namespaceURI?f.removeAttributeNS(x.namespaceURI,x.localName):f.removeAttribute(x.name),a.push({kind:"attr",el:f,name:x.name,before:I,after:null})}}function re(f,T){let x=f.tagName;return x==="INPUT"?T==="value"||T==="checked"||T==="disabled":x==="OPTION"?T==="selected":!1}function Ne(f){return f===r.activeElement}function tt(f){let T=r.activeElement;return!!T&&T!==r.body&&f.contains(T)}function qe(f){let T=f&&f.remote;return T&&T.nodeType===1?T:null}function Ke(f,T,x){let B=f.tagName,I=qe(x),E=o.formState==="property"&&I?I:T;if(B==="INPUT"){let j=o.protectFocusedValue&&Ne(f),M=(f.getAttribute("type")||"").toLowerCase(),P=M!=="file"&&M!=="checkbox"&&M!=="radio",Y=I&&I.hasAttribute("value")&&I.value!==I.getAttribute("value")?I.value:null;if(P&&!j)if(o.formState==="property"){let Q=T.getAttribute("value"),we=f.getAttribute("value");(we!==Q||f.value!==E.value)&&l.beforeAttributeUpdated("value",f,Q==null?"remove":"update")!==!1&&(we!==Q&&(Q==null?f.removeAttribute("value"):f.setAttribute("value",Q),a.push({kind:"attr",el:f,name:"value",before:we,after:Q})),f.value!==E.value&&(f.value=E.value))}else if(T.hasAttribute("value")||Y!=null){let Q=Y??T.getAttribute("value");f.getAttribute("value")!==Q&&l.beforeAttributeUpdated("value",f,"update")!==!1?(f.setAttribute("value",Q),f.value!==Q&&(f.value=Q),a.push({kind:"attr",el:f,name:"value",before:null,after:Q})):f.value!==Q&&f.getAttribute("value")===Q&&(f.value=Q)}else(f.hasAttribute("value")||f.value!=="")&&l.beforeAttributeUpdated("value",f,"remove")!==!1&&(f.removeAttribute("value"),f.value="",a.push({kind:"attr",el:f,name:"value",before:"",after:null}));if(!P&&M!=="file"){let Q=T.getAttribute("value");Q==null?f.hasAttribute("value")&&l.beforeAttributeUpdated("value",f,"remove")!==!1&&f.removeAttribute("value"):f.getAttribute("value")!==Q&&l.beforeAttributeUpdated("value",f,"update")!==!1&&f.setAttribute("value",Q)}j||(Ze(f,E,"checked"),o.formState==="property"&&f.indeterminate!==E.indeterminate&&(f.indeterminate=E.indeterminate)),Ze(f,E,"disabled")}else if(B==="OPTION"){let j=f.parentNode&&f.closest("select");o.protectFocusedValue&&j&&Ne(j)||Ze(f,E,"selected")}}function Ze(f,T,x){let B=o.formState==="property"?!!T[x]:T.hasAttribute(x);if(o.formState!=="property"){let I=f.hasAttribute(x);if(I!==B){if(l.beforeAttributeUpdated(x,f,B?"update":"remove")===!1)return;B?f.setAttribute(x,""):f.removeAttribute(x),a.push({kind:"attr",el:f,name:x,before:I?"":null,after:B?"":null})}}f[x]!==B&&(f[x]=B)}function at(f,T,x){if(o.protectFocusedValue&&Ne(f)||l.beforeAttributeUpdated("value",f,"update")===!1)return;let B=qe(x),I=T.textContent,E=B&&B.value!==B.defaultValue?B.value:I;o.formState!=="property"&&f.textContent!==I&&(a.push({kind:"text",node:f,before:f.textContent,after:I}),f.textContent=I),f.value!==E&&(f.value=E)}}function lc(e,t){let n=e.activeElement;if(!n||n===e.body||n===e.documentElement)return null;let o={el:n,id:n.getAttribute&&n.getAttribute("id"),scrollTop:n.scrollTop,scrollLeft:n.scrollLeft};if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"){try{o.selection=[n.selectionStart,n.selectionEnd,n.selectionDirection]}catch{}return o}let r=e.getSelection&&e.getSelection();if(r&&r.rangeCount){let s=r.getRangeAt(0);o.range={sc:s.startContainer,so:s.startOffset,ec:s.endContainer,eo:s.endOffset}}return o}function ac(e,t,n,o,r,s){if(!t)return;let c=t.el;if(!c.isConnected&&t.id&&(c=e.getElementById(t.id)),!c||!c.isConnected)return;if(e.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}try{c.scrollTop=t.scrollTop,c.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{c.setSelectionRange&&!c.selectionEnd&&t.selection[1]!=null&&c.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let l=(p,g)=>{let m=n.get(p);if(Array.isArray(m)){let u=m.find(v=>g>=v.from&&g<v.to)||m.find(v=>g===v.to)||m[m.length-1],h=s.get(u.merged);if(!h||!h.isConnected)return null;let y=o.get(u.merged),S=y&&y.flat?y.flat(u.flatStart+g):g;return[h,Math.max(0,Math.min(S,h.nodeValue.length))]}if(m){let u=(r.get(m.merged)||[p])[0];if(!u.isConnected)return null;let h=o.get(m.merged),y=m.shift+g,S=h?h(y):y;return[u,Math.max(0,Math.min(S,u.nodeValue.length))]}return p.isConnected?[p,Math.min(g,p.nodeType===3?p.nodeValue.length:p.childNodes.length)]:null},a=l(t.range.sc,t.range.so),b=l(t.range.ec,t.range.eo);if(!(!a||!b))try{let p=e.createRange();p.setStart(a[0],a[1]),p.setEnd(b[0],b[1]);let g=e.getSelection();g.removeAllRanges(),g.addRange(p)}catch{}}var Cl=Symbol("hyper-morph-duplicate-key");var fc='[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"]',uc='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',dc='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function hc(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 pc(e,t,n,o){if(t==null)return;if(typeof t=="string")return t;let r=t;if(r.nodeType===9){let s=e.getAttribute("id");r=s&&r.getElementById(s)||(e.tagName==="BODY"?r.body:e.tagName==="HTML"?r.documentElement:r.body&&r.body.firstElementChild)}if((!r||r.nodeType!==1||r.tagName!==e.tagName)&&(r=mc(e,t,o)),!!r)return n?Array.from(r.childNodes):r}function mc(e,t,n){let o=t.nodeType===9?t.documentElement:t;if(!o||o.nodeType!==1)return null;let r=new Map,s=[o,...o.querySelectorAll("script")];for(let a of s){let b=jn(a,n);b&&!r.has(b.key)&&r.set(b.key,a.textContent)}if(!r.size)return null;let c=e.cloneNode(!0),l=!1;for(let a of[c,...c.querySelectorAll("script")]){let b=jn(a,n);b&&r.has(b.key)&&(a.textContent=r.get(b.key),l=!0)}return l?c:null}function ys(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(""),o=e.nodeType===1&&e.tagName==="HTML"?e:null;if(o)return n.replaceChild(n.adoptNode(o),n.documentElement),n;let r=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let s of r)n.body.appendChild(n.adoptNode(s));return n}function lr(e,t,n={}){let o=n||{};if(!o.head?.block)return ks(e,t,o);try{return ks(e,t,o)}catch(r){return Promise.reject(r)}}function ks(e,t,n){let o=n.policy||"sync",r=o==="raw"?void 0:(a,b)=>hc(a)||(o==="history"?!(b&&a.matches(dc))&&a.matches(uc):a.matches(fc)),s=n.callbacks||{},c={ignore:r,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"&&(c.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return no(Object.assign({},c,{live:e,base:n.scripts?.mergeBase||null,remote:ys(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let a=Object.assign({},c,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:ys(t,e.ownerDocument)});return no(a)}n.morphStyle==="innerHTML"&&(c.children=!0);let l=pc(e,n.scripts?.mergeBase,!!c.children,c.scripts.mergeTags);return l!==void 0&&(c.base=l),ar(e,t,c)}var gc=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply"]),on=()=>{};function oo(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let c of Object.keys(e))if(!gc.has(c))throw new TypeError(`unknown option "${c}"`);let n=Object.assign({beforeNodeAdded:on,afterNodeAdded:on,beforeNodeRemoved:on,afterNodeRemoved:on,beforeNodeMorphed:on,afterNodeMorphed:on,beforeAttributeUpdated:on},e.hooks||{}),o=e.conflicts||"remote";if(!["remote","local","both"].includes(o))throw new TypeError("conflicts must be remote, local or both");let r=e.formState||"attribute";if(!["attribute","property"].includes(r))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"');return{ignored:Vo(e.ignore,t),remoteWins:Vo(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:o,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:r,hooks:n,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null}}function _n(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 wn}function Un(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=zo(t,e.map),o=typeof e.then=="function"?e.then:wn;if(typeof e.first=="function"){let r=e.first;return s=>r(s)||n.get(s)||o(s)}return r=>n.get(r)||o(r)}return wn}function bc(e,t,n,o={}){let r=g=>g&&g.nodeType===9?g.documentElement:g,s=r(t),c=r(n),l=r(e)||s,a=Object.assign({},o);delete a.live,delete a.base,delete a.remote;let b=oo(a,[l,s,c].filter(Boolean)),p=o.identity||{};return cr(l,s,c,{identity:{base:Un(p.base,l),local:Un(p.local,s),remote:Un(p.remote,c)},authored:{base:_n(p.base),local:_n(p.local),remote:_n(p.remote)},skipUnchanged:b.hooks.beforeNodeMorphed===on&&b.hooks.afterNodeMorphed===on,ignored:b.ignored,remoteWins:b.remoteWins,ignoreAttribute:b.ignoreAttribute,conflicts:b.conflicts,mergeTags:b.scripts.merge===!1?null:b.scripts.mergeTags,baseURI:s.ownerDocument&&s.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:b.children})}function fr({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:o,toLive:r,options:s,identity:c,childrenOnly:l,isDocument:a}){let b=oo(s,[e,t,n,o].filter(Boolean));if(b.ignored(e))return{report:ur(),loads:[]};let p=e.ownerDocument,g=b.scripts.execute?is(e,b.ignored,p.baseURI):null,m=cr(t||n,n,o,{identity:{base:Un(c.base,t||n),local:Un(c.local,n),remote:Un(c.remote,o)},authored:{base:_n(c.base),local:_n(c.local),remote:_n(c.remote)},ignored:b.ignored,remoteWins:b.remoteWins,ignoreAttribute:b.ignoreAttribute,conflicts:b.conflicts,mergeTags:b.scripts.merge===!1?null:b.scripts.mergeTags,baseURI:p.baseURI,localIsBase:!t,childrenOnly:l,skipUnchanged:b.hooks.beforeNodeMorphed===on&&b.hooks.afterNodeMorphed===on});b.beforeApply&&b.beforeApply(m.doc);let u=globalThis.__hyperMorphProfile,h=u?performance.now():0,y=bs(e,m.root,m,{toLive:r,ignored:b.ignored,ignoreAttribute:b.ignoreAttribute,formState:b.formState,protectFocusedValue:b.protectFocusedValue,restoreFocus:b.restoreFocus,preserve:b.head.preserve,hooks:b.hooks,childrenOnly:l});u&&(u.apply=(u.apply||0)+(performance.now()-h));let S=[];if(b.head.awaitLoads)for(let q of y.applied){if(q.kind!=="insert"||q.node.nodeType!==1)continue;let Z=q.node;Z.tagName==="LINK"&&/\bstylesheet\b/i.test(Z.getAttribute("rel")||"")&&Z.getAttribute("href")&&Z.closest("head")&&S.push(new Promise(ie=>{Z.addEventListener("load",()=>ie()),Z.addEventListener("error",()=>ie())}))}if(g){let q=cs(e,g,{ignored:b.ignored,skip:y.mergedScriptsLive,baseURI:p.baseURI,beforeNodeAdded:b.hooks.beforeNodeAdded,afterNodeAdded:b.hooks.afterNodeAdded});S.push(...q.loads)}let v=q=>q&&y.liveOf&&y.liveOf.get(q)||null;return{report:{applied:y.applied,decisions:m.decisions.map(q=>Object.assign({},q,{node:q.node?v(q.node):null,el:q.el?v(q.el):null,applied:!!(q.node?v(q.node):q.el&&v(q.el))})),conflicts:m.conflicts.map(q=>Object.assign({},q,{node:q.node?v(q.node):q.node,el:q.el?v(q.el):q.el})),localDiverged:m.localDiverged,identities:y.identities,moved:y.moved,replaced:y.replaced},loads:S}}var ws=new WeakMap;function ur(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[]}}function no(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let o=ws.get(n);o||(o=Fo(n),ws.set(n,o));let r=o("remote",t.remote),s=typeof t.base=="string"&&t.base===""?null:t.base,c=s?o("base",s):null,l=t.local?t.local.root:n.documentElement,a=t.local?t.local.toLive:g=>g;Fr(n,r);let{report:b,loads:p}=fr({liveRoot:n.documentElement,baseRoot:c?c.documentElement:null,localRoot:l,remoteRoot:r.documentElement,toLive:a,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(p).then(()=>b)}function yc(e,t,n={}){return no(Object.assign({},n,{live:e,base:null,remote:t}))}function As(e,t){if(e==null)return{root:t.createElement("template"),first:null};if(typeof e=="string"){let o=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(o){let s=Oo(e,t),c=o[1].toLowerCase()==="html"?s.documentElement:s.body;return{root:c,first:c}}let r=t.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let o=t.createElement("template"),r=e.isConnected;return o.content.appendChild(r?t.importNode(e,!0):e),{root:o,first:e}}if(e.nodeType===11){let o=t.createElement("template");return o.content.appendChild(e),{root:o,first:o.content.firstElementChild}}let n=t.createElement("template");for(let o of Array.from(e))n.content.appendChild(o.parentNode?t.importNode(o,!0):o);return{root:n,first:n.content.firstElementChild}}function ar(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let o=e.ownerDocument,{base:r,...s}=n,c=!!s.children;if(oo(s,[e]).ignored(e))return Promise.resolve(ur());let l=As(t,o),a=r!=null?As(r,o):null,b,p=null;if(c)b=l.root,p=a?a.root:null;else{if(b=l.first,p=a?a.first:null,!b){let u=oo(s);return u.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),u.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e]})}if(b.tagName!==e.tagName){let u=oo(s,[e,b]);if(u.hooks.beforeNodeMorphed(e,b)===!1)return Promise.resolve(ur());let h=fr({liveRoot:e,baseRoot:p&&p.tagName===e.tagName?p:null,localRoot:e,remoteRoot:b,toLive:S=>S,options:s,identity:s.identity||{},childrenOnly:!0,isDocument:!1}),y=Wt(b)?eo(b,o):o.importNode(b,!1);if(!Wt(y))for(;e.firstChild;)y.appendChild(e.firstChild);return u.hooks.beforeNodeAdded(y)===!1||u.hooks.beforeNodeRemoved(e)===!1?Promise.resolve(h.report):(e.replaceWith(y),u.hooks.afterNodeRemoved(e),u.hooks.afterNodeAdded(y),u.hooks.afterNodeMorphed(e,b),h.report.replaced.push(y),h.report.applied.push({kind:"insert",node:y,parent:y.parentNode},{kind:"remove",node:e,parent:y.parentNode}),Promise.all(h.loads).then(()=>h.report))}}let{report:g,loads:m}=fr({liveRoot:e,baseRoot:p,localRoot:e,remoteRoot:b,toLive:u=>u,options:s,identity:s.identity||{},childrenOnly:c,isDocument:!1});return Promise.all(m).then(()=>g)}var xs={mergeDocument:no,morphDocument:yc,morphElement:ar,merge3:bc,morph:lr};function dr(e,t,{onWidgetRemoved:n}={}){xs.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=So.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var wc="hha:upgrade-check:";function cn(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function hr(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Ts(e,t){let n=hr(e),o=hr(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let s=0;s<r;s++){let c=n[s]||0,l=o[s]||0;if(c!==l)return c>l}return!1}function Ac(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function xc(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function pr({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:s=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(m=>fetch(m)),r=r??Date.now(),!t)return null;let c=cn(t,"hyper-source");if(!c)return null;let l=cn(t,"hyper-version"),a;try{a=new URL(c,n?n.href:void 0)}catch{return null}if(n&&a.origin===n.origin&&a.pathname===n.pathname)return null;let b=`${wc}${a.href}:${l||"none"}`,p,g=e?null:Ac(b);if(g&&typeof g.checkedAt=="number"&&r-g.checkedAt<s)p=g.sourceVersion;else{try{let m=await o(a.href);if(!m.ok)throw new Error(`HTTP ${m.status}`);let u=await m.text(),h=new DOMParser().parseFromString(u,"text/html");p=cn(h,"hyper-version")}catch{p=null}xc(b,{checkedAt:r,sourceVersion:p})}return p?{available:Ts(p,l||"0.0.0"),currentVersion:l,sourceVersion:p,sourceUrl:a.href}:null}var Lo=["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"],mr=new Set(Lo),Ss=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),gr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Po={};Bo(Po,{EmptyListInsert:()=>so,MAX_RULE_DEPTH:()=>$n,MaxRuleDepthExceeded:()=>Sn,NoRulesTag:()=>br,RuleTargetReadOnly:()=>io,RulesParseError:()=>Wn,ShapeMismatch:()=>ro,UnknownRulesVersion:()=>Tn,WriteRefused:()=>Ro,WriteRejected:()=>yr});var Wn=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},Tn=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},$n=20,Sn=class extends Error{constructor(t){super(`rule depth exceeded ${$n} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},ro=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},so=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}},io=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},Ro=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}},br=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},yr=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 ln(e,t,n,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.");return kr(e,t,n,{depth:0,path:[]},o)}function kr(e,t,n,o,r){if(o.depth>$n)throw new Sn(o.path);if(typeof n=="string")return Tc(e,t,n,o,r);if(Array.isArray(n)){let[s,c]=n,l=e.find(t,s,r);return Os(r,o,l),l.map((a,b)=>kr(e,a,c,{depth:o.depth+1,path:[...o.path,b]},r))}if(typeof n=="object"&&n!==null){let s={};for(let[c,l]of Object.entries(n))s[c]=kr(e,t,l,{depth:o.depth+1,path:[...o.path,c]},r);return s}return null}function Tc(e,t,n,o,r){if(n.endsWith("[]")){let l=n.slice(0,-2),a=e.find(t,l,r);return Os(r,o,a),a.map(b=>e.text(b))}if(n.startsWith("@"))return Ns(e,t,n.slice(1));let s=dn(n);if(s!==-1){let l=n.slice(0,s),a=n.slice(s+1),b=l?e.find(t,l,r):[t];return b.length===0?null:Ns(e,b[0],a)}if(n===".")return e.text(t);let c=e.find(t,n,r);return c.length===0?null:e.text(c[0])}function Os(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function Ns(e,t,n){if(mr.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}var Ms=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"]})}),Sc=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),vs=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function wr(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 Nc(e,t){if(wr(e,t))return!0;for(let[n,o]of Object.entries(Sc))if(o.includes(t)&&wr(e,n))return!0;return!1}function co(e){let t=Ms[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Oc(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=Ms[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Nc(n,r))||o.bundles.some(r=>wr(n,r)))return n;n=n.parentElement}return null}function Is(e,t){return!!Oc(e,t)}var Mc=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Es(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)t.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Cs(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Ls(e,t,n,o,r,s,c,l){if(e.nodeType===1&&((c?Is(e,n):Cs(e,o,s,!1))||r&&Cs(e,r,s,c)))return null;let a=t.importNode(e,!1);l.cloneToLive.set(a,e),l.liveToClone.set(e,a);let b=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,p=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;b!==e&&(l.cloneToLive.set(p,b),l.liveToClone.set(b,p));for(let g of b.childNodes||[]){let m=Ls(g,t,n,o,r,s,c,l);m&&(p.appendChild(m),g.nodeType===1&&Es(g,m))}return e.nodeType===1&&Es(e,a),a}function lo(e,{capability:t="data",exclude:n=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=r.implementation.createHTMLDocument(""),c=new WeakMap,l=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let b=co(t),p=Ls(a,s,t,b,n,a,o,{cloneToLive:c,liveToClone:l});e.nodeType===9&&p&&(s.replaceChild(p,s.documentElement),l.set(e,s),c.set(s,e));let g=m=>{if(Mc.test(m))throw new Error(`Filtered content queries do not support stateful selector: ${m}`)};return{root:p,document:s,capability:t,selector:co(t),cloneToLive:c,liveToClone:l,original(m){return c.get(m)||null},cloneOf(m){return l.get(m)||null},query(m,u=p){return g(m),Array.from(u.querySelectorAll(m),h=>c.get(h)||h)},text(m=p){return(m===p?p:l.get(m))?.textContent||""},html(m=p){return(m===p?p:l.get(m))?.innerHTML??""},clone(m=p){let u=m===p?p:l.get(m);return u?s.importNode(u,!0):null}}}function Rs(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function vc(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var Mt={semanticExclude:!0,find(e,t,n={}){let o=vc(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!Rs(l)));let s=[];n.skip&&s.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&s.push("["+c+"]"),s.length){let l=s.join(", ");r=r.filter(a=>!a.closest||!a.closest(l))}return r},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 o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},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 o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Nn(e,t={}){if(t.exclude===null)return Mt;let n=[co("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return Mt;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,l=null,a=()=>l||(l=lo(s,{capability:"data",exclude:t.exclude||null})),b=h=>{let y=a();return h===e?y.cloneOf(e):y.cloneOf(h)||h},p=h=>l?.original(h)||h,g=(h,y)=>{a().liveToClone.set(h,y),a().cloneToLive.set(y,h);let S=h.childNodes||[],v=y.childNodes||[];for(let D=0;D<Math.min(S.length,v.length);D++)g(S[D],v[D])},m=(h,y,S,v)=>{let D=Array.from(h.childNodes).filter(he=>l.cloneOf(he)),Z=D[0];for(;Z&&D.includes(Z);)Z=Z.nextSibling;for(let he of D)he.remove();if(S==="innerHTML"){let he=c.createElement("template");he.innerHTML=v;for(let K of Array.from(he.content.childNodes))h.insertBefore(K,Z||null)}else h.insertBefore(c.createTextNode(v),Z||null);let ae=lo(h,{capability:"data",exclude:t.exclude||null});y.replaceChildren(...Array.from(ae.root?.childNodes||[]));let ie=he=>{let K=ae.original(he);K&&(l.liveToClone.set(K,he),l.cloneToLive.set(he,K));for(let J of Array.from(he.childNodes||[]))ie(J)};for(let he of Array.from(y.childNodes))ie(he)},u={...Mt,find(h,y,S={}){let v=b(h);if(!v?.querySelectorAll)return[];let D=a().query(y,v);S.includeRulesTag||(D=D.filter(ae=>!Rs(ae)));let q=[];S.skip&&q.push(S.skip);let Z=S.templateAttr===null?null:S.templateAttr||"cms-template";if(Z&&q.push(`[${Z}]`),q.length){let ae=q.join(", ");D=D.filter(ie=>!ie.closest?.(ae))}return D},parent(h){let y=b(h)?.parentElement;return y?p(y):null},children(h){return Array.from(b(h)?.children||[],p)},text(h,y){if(y===void 0){let D=p(h);return!D?.matches?.(n)&&!D?.querySelector?.(n)?Mt.text(D):(b(h)?.textContent||"").trim()}let S=p(h);if(!S?.matches?.(n)&&!S?.querySelector?.(n)&&!l){Mt.text(S,y);return}let v=a().cloneOf(S);v?m(S,v,"textContent",y):Mt.text(S,y)},attr(h,y,S){let v=p(h);if(S===void 0)return Mt.attr(v,y);Mt.attr(v,y,S);let D=l?.cloneOf(v);D&&(Mt.attr(D,y,S),lo(v,{capability:"data",exclude:t.exclude||null}).root===null&&(D.remove(),l.liveToClone.delete(v),l.cloneToLive.delete(D)))},removeAttr(h,y){let S=p(h);Mt.removeAttr(S,y);let v=l?.cloneOf(S);v&&Mt.removeAttr(v,y)},prop(h,y,S){let v=p(h);if(S===void 0)return y==="innerHTML"||y==="outerHTML"||y==="textContent"||y==="innerText"?Mt.prop(b(v),y):Mt.prop(v,y);let D=y==="innerHTML"||y==="textContent"||y==="innerText",q=D?a().cloneOf(v):l?.cloneOf(v);q&&D?m(v,q,y,S):(Mt.prop(v,y,S),q&&Mt.prop(q,y,S))},clone(h){let y=b(h);return y===h?Mt.clone(h):c.importNode(y,!0)},insertAt(h,y,S){let v=p(h),q=u.children(v)[S]||(()=>{for(let ie=v.children.length-1;ie>=0;ie--){let he=v.children[ie];if(a().cloneOf(he))return he.nextElementSibling}return v.firstElementChild})(),Z=p(y);v.insertBefore(Z,q||null);let ae=a().cloneOf(v);if(ae){let ie=a().cloneOf(Z);ie||(ie=c.importNode(Z,!0),g(Z,ie));let he=Array.from(ae.children);ae.insertBefore(ie,he[S]||null)}},remove(h){let y=p(h),S=a().cloneOf(y);Mt.remove(y),S&&Mt.remove(S)},replaceWith(h,y){let S=p(h),v=a().cloneOf(S),D=Mt.replaceWith(S,y);if(v){let q=lo(D,{capability:"data",exclude:t.exclude||null});if(!q.root)v.remove();else{v.replaceWith(q.root);let Z=ae=>{let ie=q.original(ae);ie&&(l.liveToClone.set(ie,ae),l.cloneToLive.set(ae,ie));for(let he of Array.from(ae.childNodes||[]))Z(he)};Z(q.root)}}return D}};return u}var Qt=Mt;function Ar(e){try{return JSON.parse(e)}catch(t){throw new Wn(`Invalid strict JSON: ${t.message}`,t)}}function On(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(r){let s=[],c=0;for(;c<r.length;){let l=r[c];if(/\s/.test(l)){c++;continue}if("{}".includes(l)){s.push({type:l,value:l}),c++;continue}if(l==="["){let g=!1,m=c+1;for(;m<r.length&&/\s/.test(r[m]);)m++;if(m<r.length&&/[a-zA-Z_]/.test(r[m])&&(g=!0),!g){s.push({type:l,value:l}),c++;continue}}if(l==="]"){s.push({type:l,value:l}),c++;continue}if(l===":"){s.push({type:t.COLON,value:l}),c++;continue}if(l===","){s.push({type:t.COMMA,value:l}),c++;continue}if(l==='"'||l==="'"){let g=l,m=c+1;for(;m<r.length&&r[m]!==g;)r[m]==="\\"&&m++,m++;s.push({type:t.STRING,value:r.substring(c+1,m),quoted:!0,sourceQuote:g}),c=m+1;continue}let a=c,b;for(;a<r.length&&!/[{},]/.test(r[a]);)if(r[a]===":"){let g=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],m=!1;for(let u of g){let h=u.substring(1);if(r.substring(a+1,a+1+h.length)===h){m=!0,a+=h.length;break}}if(!m)break}else if(r[a]==="["){for(a++;a<r.length&&r[a]!=="]";){if(r[a]==='"'||r[a]==="'"){let g=r[a];for(a++;a<r.length&&r[a]!==g;)r[a]==="\\"&&a++,a++}a++}a<r.length&&r[a]==="]"&&a++}else a++;b=r.substring(c,a);let p=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(b)?p=t.NUMBER:b==="true"||b==="false"||b==="null"?p=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(b)&&(p=t.SELECTOR),s.push({type:p,value:b,quoted:!1}),c=a}return s}function o(r){let s="";for(let c=0;c<r.length;c++){let l=r[c];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=r[c+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,(b,p)=>p.length%2===0?p+'\\"':b)),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 r=n(e),s=o(r);return JSON.parse(s)}catch(r){throw new Wn("Invalid extraction rules syntax: "+r.message,r)}}var xr="1",Ps=/^[a-zA-Z0-9_-]+$/;function Fn(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!Ps.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Ps})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=r[0],c=e.attr(s,"data-rules-version");if(c!==xr)throw new Tn(c);return{rules:On(e.text(s)),tagNode:s}}var Ic="script[data-rules-name]";function Hs(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ao(e,t){let n=e.find(t,Ic,{includeRulesTag:!0}),o=new Set,r=[];for(let s of n){let c=Hs(e.attr(s,"data-rules-name"));if(!c)continue;if(o.has(c)){console.warn(`hyper-html-api: duplicate rules tag name "${c}"; using the first.`);continue}let l=e.attr(s,"data-rules-version");if(l!==xr)throw new Tn(l);o.add(c),r.push({name:c,rules:On(e.text(s))})}return r}function Ho(e,t){let n={};for(let{name:o,rules:r}of ao(e,t))n[o]=ln(e,t,r);return n}function Tr(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Ho(Qt,t),version:cn(n,"hyper-version")}}var Vn=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},fo=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},bn=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},uo=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var Ds="text/hyper-upgrade";function Sr(e,t){let n=e.find(t,`script[type="${Ds}"]`);if(n.length===0)return null;if(n.length>1)throw new uo(n.length);return e.text(n[0])||null}var Ec=new Function("url","return import(url)");async function Nr(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await Ec(n)}catch(r){throw new bn(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new bn("transform must `export default` a function");return o.default}function _s(e,t,n,o){let r=e.length,s=t.length,c=new Array(r).fill(-1);if(o){let S=new Set;for(let v=0;v<r;v++){let D=o[v];!(D>=0&&D<s)||S.has(D)||(c[v]=D,S.add(D))}}if(r===0||s===0)return c;let l=e.map(S=>js(S,n)),a=t.map(S=>js(S,n)),b=new Array(s).fill(!1);for(let S of c)S>=0&&(b[S]=!0);let p=new Map;a.forEach((S,v)=>{b[v]||p.set(S,p.has(S)?-1:v)});let g=new Map;l.forEach((S,v)=>{c[v]>=0||g.set(S,(g.get(S)||0)+1)}),l.forEach((S,v)=>{if(c[v]>=0||g.get(S)!==1)return;let D=p.get(S);D===void 0||D===-1||b[D]||(c[v]=D,b[D]=!0)});let m=[];for(let S=0;S<r;S++)c[S]<0&&m.push(S);let u=[];for(let S=0;S<s;S++)b[S]||u.push(S);if(m.length===0||u.length===0)return c;let h=r*s+1,y=(S,v)=>Cc(e[S],t[v],n)*h+Math.abs(S-v);for(let[S,v]of Lc(m,u,y))c[S]=v;return c}var Us=e=>typeof e=="object"&&e!==null;function js(e,t){if(!Us(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function Cc(e,t,n){if(!Us(n))return e===t?0:1;let o=Object.keys(n);if(o.length===0)return 0;let r=0;for(let s of o){let c=JSON.stringify(e?.[s]),l=JSON.stringify(t?.[s]);c!==l&&r++}return r}function Lc(e,t,n){return e.length<=t.length?Bs(e,t,n,!1):Bs(t,e,(o,r)=>n(r,o),!0)}function Bs(e,t,n,o){let r=e.length,s=t.length,c=[];for(let g=0;g<=r;g++)c.push(new Float64Array(s+1).fill(1/0));let l=[];for(let g=0;g<=r;g++)l.push(new Uint8Array(s+1));for(let g=0;g<=s;g++)c[r][g]=0;for(let g=r-1;g>=0;g--)for(let m=s-1;m>=0;m--){let u=n(e[g],t[m])+c[g+1][m+1],h=c[g][m+1];u<=h?(c[g][m]=u,l[g][m]=1):c[g][m]=h}let a=[],b=0,p=0;for(;b<r&&p<s;)l[b][p]&&(a.push(o?[t[p],e[b]]:[e[b],t[p]]),b++),p++;return a}function Mr(e,t,n,o,r,s,c,l={}){let a=e.find(t,n,l);if(r.length===0){a.forEach(ae=>e.remove(ae)),Or(l,"onRowsApplied",s.path,[]);return}let b=r.length>a.length,p=a[0]||null;if(b&&!p&&(p=Dc(e,t,n,l),!p))throw new so(s.path);let g=a.map(ae=>Hc(e,ae,o,l)),m=null;if(b&&p){m=e.clone(p),l.templateAttr&&e.removeAttr(m,l.templateAttr);let ae=e.stripIds(m);ae>0&&console.warn(`[hyper-html-api] stripped ${ae} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let u=_s(r,g,o,Rc(e,a,r,s,l)),h=a[0]||p,y=e.parent(h),S=a.length>0?Ws(e,y,h):0,v=jc(e,a),D=new Set,q=[],Z=r.map((ae,ie)=>{let he=u[ie];if(he>=0)return D.add(he),q.push(!1),a[he];q.push(!0);let K=e.clone(m);return e.stripIds(K),K});a.forEach((ae,ie)=>{D.has(ie)||e.remove(ae)}),v?Z.forEach((ae,ie)=>{let he=S+ie;e.children(y).findIndex(ye=>e.sameNode(ye,ae))!==he&&e.insertAt(y,ae,he)}):Bc(e,Z,q,y,S),Pc(e,Z,o,r,s,c,l),Or(l,"onRowsApplied",s.path,Z)}function Or(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function Rc(e,t,n,o,r){let s=Or(r,"identifyRows",o.path,n);if(!Array.isArray(s))return null;let c=new Array(n.length).fill(-1),l=new Set;for(let a=0;a<n.length;a++)if(s[a]){for(let b=0;b<t.length;b++)if(!(l.has(b)||!e.sameNode(t[b],s[a]))){c[a]=b,l.add(b);break}}return c}function Pc(e,t,n,o,r,s,c){t.forEach((l,a)=>{if(n===null){let b=o[a],p=b==null?"":String(b);e.text(l)!==p&&e.text(l,p)}else{let b=s(e,l,n,o[a],{depth:r.depth+1,path:[...r.path,a]},c);b&&b!==l&&(t[a]=b)}})}function Hc(e,t,n,o){return n===null?e.text(t):ln(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Ws(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Dc(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let s=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let c of s)if(e.attr(c,o.templateAttr)!=null)return c;r=e.parent(r)}return null}function jc(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=e.children(n),r=[];for(let s of t){let c=o.findIndex(l=>e.sameNode(l,s));if(c===-1)return!1;r.push(c)}return r.sort((s,c)=>s-c),r[r.length-1]-r[0]===r.length-1}function Bc(e,t,n,o,r){let s=null,c=r;for(let l=0;l<t.length;l++){if(!n[l]){s=t[l];continue}let a=s?e.parent(s):o;if(!a)continue;let b=s?Ws(e,a,s)+1:c++;e.insertAt(a,t[l],b),s=t[l]}}var $s=new Set(["checked","selected","disabled","readOnly","paused"]);function yn(e,t,n,o,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.");let s=[];if(vr(n,o,[],s),s.length)throw new ro(s);Do(e,t,n,o,{depth:0,path:[]},r)}function Do(e,t,n,o,r,s={}){if(r.depth>$n)throw new Sn(r.path);if(o===void 0)return t;if(typeof n=="string")return _c(e,t,n,o,r,s);if(Array.isArray(n)){let[c,l]=n;return Mr(e,t,c,l,o,r,Do,s),t}if(typeof n=="object"&&n!==null){for(let[c,l]of Object.entries(n)){let a=Do(e,t,l,o==null?o:o[c],{depth:r.depth+1,path:[...r.path,c]},s);a&&a!==t&&(t=a)}return t}return t}function _c(e,t,n,o,r,s){if(n.endsWith("[]")){let a=n.slice(0,-2);return Mr(e,t,a,null,o,r,Do,s),t}if(n.startsWith("@"))return Vs(e,t,n.slice(1),o);let c=dn(n);if(c!==-1){let a=n.slice(0,c),b=n.slice(c+1),p=a?e.find(t,a,s):[t];return p.length===0||Vs(e,p[0],b,o),t}if(n===".")return Fs(e,t,o),t;let l=e.find(t,n,s);return l.length===0||Fs(e,l[0],o),t}function Fs(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Vs(e,t,n,o){if(gr.has(n)){let s=e.prop(t,n);if(s===o||s!=null&&o!=null&&String(s)===String(o))return t;throw new io(n)}if(n==="outerHTML"){let s=o==null?"":String(o);return e.replaceWith(t,s)}if(Ss.has(n)){let s=Uc(n,o);return e.prop(t,n)!==s&&e.prop(t,n,s),t}let r=o==null?"":String(o);return e.attr(t,n)!==r&&e.attr(t,n,r),t}function Uc(e,t){return t==null?$s.has(e)?!1:"":$s.has(e)?t==="false"?!1:!!t:t}function vr(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,s)=>{typeof r=="object"&&r!==null&&o.push({path:po([...n,s]),expected:"scalar",got:ho(r)})}):o.push({path:po(n),expected:"array",got:ho(t)});return}t!==null&&typeof t=="object"&&o.push({path:po(n),expected:"scalar",got:ho(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:po(n),expected:"array",got:ho(t)});return}let r=e[1];t.forEach((s,c)=>vr(r,s,[...n,c],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:po(n),expected:"object",got:ho(t)});return}for(let[r,s]of Object.entries(e))vr(s,t[r],[...n,r],o)}}}function ho(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function po(e){return e.join(".")}function mo(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=Ir(t,e,n);return Er(t,e,n),{data:o,summary:n}}function Ir(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>Ir(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,s]of Object.entries(e)){let c=Ir(s,t?.[r],n);c!==void 0&&(o[r]=c)}return o}}function Er(e,t,n){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let r of Object.keys(t))o.has(r)?Er(e[r],t[r],n):n.discarded+=Mn(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>Er(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=Mn(t))}}function Mn(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+Mn(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+Mn(n),0):1}function Cr(e,t,n){let o=ao(e,t),r={carriedOver:0,discarded:0,listItems:0},s={},c=new Set;for(let{name:l,rules:a}of o){if(c.add(l),!Object.prototype.hasOwnProperty.call(n,l)){s[l]={carriedOver:0,discarded:0,listItems:0};continue}let{data:b,summary:p}=mo(n[l],a);yn(e,t,a,b),s[l]=p,r.carriedOver+=p.carriedOver,r.discarded+=p.discarded,r.listItems+=p.listItems}for(let l of Object.keys(n))c.has(l)||(r.discarded+=Mn(n[l]));return{totals:r,byName:s,rulesTagCount:o.length}}async function Lr({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:s}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),s=s||(v=>fetch(v)),!o)throw new Error("upgrade.run requires a document context");if(e=e||cn(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let c=new URL(e,r?r.href:void 0);n=n!==void 0?n:cn(o,"hyper-version"),t=t||Ho(Qt,o);let l;try{l=await s(c.href)}catch(v){throw new Vn(c.href,v)}if(!l.ok)throw new Vn(c.href,new Error(`HTTP ${l.status}`));let a=await l.text(),b=new DOMParser().parseFromString(a,"text/html"),p=cn(b,"hyper-version"),g=t,m=!1,u=Sr(Qt,b);if(u){let D=await(await Nr(u))(g,{fromVersion:n,toVersion:p});if(!D||typeof D!="object"||Array.isArray(D))throw new bn("transform must return a plain object map of { rulesName: data }");g=D,m=!0}let{totals:h,byName:y,rulesTagCount:S}=Cr(Qt,b,g);if(S===0&&Object.keys(g).length>0)throw new fo(c.href);return{html:Wc(b),fromVersion:n,toVersion:p,summary:{transformApplied:m,totals:h,byName:y}}}function Wc(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
5
|
-
`+e.documentElement.outerHTML}var Fc=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",...vs],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 Rr(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return Fn(e,o,n)}return null}var go={extract:(e,t,n={})=>ln(Nn(e,n),e,t,n),apply:(e,t,n,o={})=>yn(Nn(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>Fn(Qt,e,t),findRules:(e,t)=>Rr(Qt,e,t),bind:(e,t,n={})=>{let o=Rr(Qt,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>ln(Nn(e,n),e,o.rules,n),set:r=>yn(Nn(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:Ar,parseRelaxed:On,ruleAttrIndex:dn,splitRule:Cn,errors:Po,DOM_PROPERTIES:Lo},Pr=e=>!!e&&typeof e.nodeType=="number";function zs(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=Qt.find(t,"script[data-rules-name]",{includeRulesTag:!0});if(n.length===0)throw new Error('hyper-html-api: no rules tag found. Add <script type="application/json" data-rules-name="\u2026" data-rules-version="1"> or pass rules.');if(n.length>1)throw new Error('hyper-html-api: multiple rules tags found; pass a name, e.g. extractData("api").');return Fn(Qt,t).rules}function Hr(e,t){let n=Pr(e)?e:document,o=Pr(e)?t:e;return o===void 0?ln(Nn(n),n,zs(n)):go.bind(n,o).get()}function Dr(e,t,n){if(!Pr(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");return n===void 0?yn(Nn(e),e,zs(e),t):go.bind(e,n).set(t),e}var qs={buildForm:Uo,bindFormEvents:Wo,scaffold:En,morphForm:dr,path:To},Ks={checkForUpdate:pr,run:Lr,extractAll:Tr,shapeMatch:mo};var zc={engine:go,cms:qs,upgrade:Ks,extractData:Hr,applyData:Dr},qc=zc;return ti(Kc);})();
|
|
1
|
+
var HyperHtmlApi=(()=>{var Rr=Object.defineProperty;var Ul=Object.getOwnPropertyDescriptor;var Hl=Object.getOwnPropertyNames;var Wl=Object.prototype.hasOwnProperty;var Lr=(e,n)=>{for(var t in n)Rr(e,t,{get:n[t],enumerable:!0})},Vl=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Hl(n))!Wl.call(e,r)&&r!==t&&Rr(e,r,{get:()=>n[r],enumerable:!(o=Ul(n,r))||o.enumerable});return e};var _l=e=>Vl(Rr({},"__esModule",{value:!0}),e);var lf={};Lr(lf,{applyData:()=>Ks,cms:()=>Cl,default:()=>sf,engine:()=>lr,extractData:()=>$s,upgrade:()=>Rl});var ur={};Lr(ur,{fromString:()=>fr,getRuleAtPath:()=>Pr,getValueAtPath:()=>Uo,parseConfigKey:()=>$l,setAtPath:()=>Yn,toConfigKey:()=>Fl,toString:()=>An});function An(e){return e.map(String).join(".")}function Fl(e){return e.map(n=>typeof n=="number"?"*":String(n)).join(".")}function $l(e){return e===""?[]:e.split(".")}function fr(e){return e===""?[]:e.split(".").map(n=>/^\d+$/.test(n)?Number(n):n)}function Pr(e,n){let t=e;for(let o of n){if(t==null||typeof t=="string")return;if(Array.isArray(t)){if(typeof o!="number"&&o!=="*")return;t=t[1];continue}if(typeof t=="object"){if(typeof o=="number"||!(o in t))return;t=t[o];continue}return}return t}function Uo(e,n){let t=e;for(let o of n){if(t==null)return;t=t[o]}return t}function Yn(e,n,t){if(n.length===0)return t;let[o,...r]=n;if(typeof o=="number"){let c=Array.isArray(e)?[...e]:[];return c[o]=Yn(c[o],r,t),c}return{...e&&typeof e=="object"?e:{},[o]:Yn((e||{})[o],r,t)}}function go(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let n={};for(let[t,o]of Object.entries(e))n[t]=go(o);return n}return""}var dr=new WeakMap;function On(e){let n=0,t=null,o=-1;for(let r=0;r<e.length;r++){let c=e[r];c==="\\"?r++:t?c===t&&(t=null):c==='"'||c==="'"?t=c:c==="["||c==="("?n++:c==="]"||c===")"?n>0&&n--:c==="@"&&n===0&&(o=r)}return o}function bo(e){let n=On(e);return n===-1?{selector:e,prop:null}:{selector:e.slice(0,n),prop:e.slice(n+1)||null}}var Kl=new Set(["checked","selected","disabled","readOnly","paused"]);function jr({rules:e,data:n,appRoot:t,cmsRoot:o}){let r=document.createDocumentFragment(),c={rules:e,appRoot:t,cmsRoot:o};return r.appendChild(Br({rule:e,value:n,path:[],ctx:c})),r}function Dr(e,{rules:n,getData:t,onChange:o}){e.setAttribute("data-hha-form-root",""),Js.set(e,{rules:n,getData:t,onChange:o}),ql()}var Js=new WeakMap,Ys=!1;function ql(){Ys||(document.addEventListener("input",Xs,!0),document.addEventListener("change",Xs,!0),document.addEventListener("click",zl,!0),Ys=!0)}function Qs(e){if(!(e instanceof Element))return null;let n=e.closest("[data-hha-form-root]");return n&&Js.get(n)||null}function zl(e){if(!(e.target instanceof Element))return;let n=e.target.closest("[data-hha-action]");if(!n||e.defaultPrevented)return;let t=Qs(n);if(!t)return;let{rules:o,getData:r,onChange:c}=t,l=n.getAttribute("data-hha-action"),i=fr(n.getAttribute("data-hha-path")||"");if(l==="scalar-array-add"){let s=Uo(r(),i)||[];c(Yn(r(),i,[...s,""]),{structural:!0});return}if(l==="object-array-add"){let s=Pr(o,i);if(!Array.isArray(s))return;let a=Uo(r(),i)||[];c(Yn(r(),i,[...a,go(s[1])]),{structural:!0});return}if(l==="array-remove"){if(i.length===0)return;let s=i.slice(0,-1),a=i[i.length-1],h=Uo(r(),s)||[];if(typeof a!="number")return;let f=h.filter((u,g)=>g!==a);c(Yn(r(),s,f),{structural:!0})}}function Xs(e){let n=e.target;if(!n?.matches?.("input, textarea, select"))return;let t=Qs(n);if(!t)return;let{getData:o,onChange:r}=t,c=n.closest("[data-hha-path]");if(!c)return;let l=fr(c.getAttribute("data-hha-path")||""),i=n.type==="checkbox"?n.checked:n.value;r(Yn(o(),l,i),{structural:!1})}function Br({rule:e,value:n,path:t,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?Xl({rule:e,value:n,path:t,ctx:o}):Yl({rule:e,value:n,path:t,ctx:o});if(Array.isArray(e))return Jl({rule:e,value:n,path:t,ctx:o});if(typeof e=="object"&&e!==null)return Gl({rule:e,value:n,path:t,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function Gl({rule:e,value:n,path:t,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",An(t)),t.length>0){let c=document.createElement("div");c.className="form-section-label",c.textContent=hr(t[t.length-1]),r.appendChild(c)}for(let[c,l]of Object.entries(e)){let i=[...t,c],s=n?.[c];r.appendChild(Br({rule:l,value:s,path:i,ctx:o}))}return r}function Yl({rule:e,value:n,path:t,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",An(t));let c=document.createElement("div");c.className="field-body";let l=document.createElement("label");l.className="field-label",l.textContent=hr(t[t.length-1]||".")+nc(e);let i=Zl(e,o.appRoot),s=Ql(i,{value:n,rule:e,path:t,appRoot:o.appRoot}),a=s.el;return a.classList.add(i.type==="textarea"?"field-textarea":"field-input"),c.appendChild(l),c.appendChild(a),r.appendChild(c),dr.set(r,s),r}function Xl({rule:e,value:n,path:t,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",An(t));let c=document.createElement("div");c.className="form-section-label",c.textContent=hr(t[t.length-1]),r.appendChild(c);let l=Array.isArray(n)?n:[],i=document.createElement("div");r.appendChild(i),l.forEach((a,h)=>{let f=[...t,h],u=document.createElement("div");u.className="scalar-array-row",u.setAttribute("data-hha-path",An(f));let g=document.createElement("input");g.type="text",g.className="field-input",g.value=a==null?"":String(a);let b=document.createElement("button");b.type="button",b.className="array-remove",b.textContent="\xD7",b.title="remove",b.setAttribute("data-hha-action","array-remove"),b.setAttribute("data-hha-path",An(f)),u.appendChild(g),u.appendChild(b),i.appendChild(u)});let s=document.createElement("button");return s.type="button",s.className="array-add",s.textContent="+ add",s.setAttribute("data-hha-action","scalar-array-add"),s.setAttribute("data-hha-path",An(t)),r.appendChild(s),r}function Jl({rule:e,value:n,path:t,ctx:o}){let[,r]=e,c=Array.isArray(n)?n:[],l=document.createElement("div");l.className="form-section",l.setAttribute("data-hha-path",An(t));let i=document.createElement("div");i.className="form-section-label",i.textContent=hr(t[t.length-1]),l.appendChild(i),c.forEach((a,h)=>{let f=[...t,h],u=document.createElement("div");u.className="array-card",u.setAttribute("data-hha-path",An(f));let g=document.createElement("button");g.type="button",g.className="array-remove",g.textContent="\xD7",g.title="remove item",g.setAttribute("data-hha-action","array-remove"),g.setAttribute("data-hha-path",An(f)),u.appendChild(g);let b=Br({rule:r,value:a,path:f,ctx:o});b.querySelector(".form-section-label")?.remove(),u.appendChild(b),l.appendChild(u)});let s=document.createElement("button");return s.type="button",s.className="array-add",s.textContent="+ add",s.setAttribute("data-hha-action","object-array-add"),s.setAttribute("data-hha-path",An(t)),l.appendChild(s),l}function Ql(e,n){let t=tc(e);if(e.type==="select"&&e.options)for(let o of e.options){let r=document.createElement("option");r.value=o.value,r.textContent=o.text,String(n.value)===o.value&&(r.selected=!0),t.appendChild(r)}else e.type==="checkbox"?t.checked=n.value===!0||n.value==="true"||n.value==="checked":(e.type,t.value=n.value==null?"":String(n.value));return{el:t,destroy(){},focus(){t.focus()},validate(){}}}function Zl(e,n){let t=null;if(e.startsWith("@")?t=e.slice(1):t=bo(e).prop,t&&Kl.has(t))return{type:"checkbox"};if(t==="innerHTML")return{type:"textarea"};let o=ec(e,n);if(!o)return{type:"text"};let r=(o.tagName||"").toLowerCase();if(r==="textarea")return{type:"textarea"};if(r==="select")return{type:"select",options:Array.from(o.querySelectorAll("option")).map(i=>({value:i.getAttribute("value")||i.textContent,text:i.textContent.trim()||i.getAttribute("value")||""}))};if(r==="input"){let l=(o.getAttribute("type")||"text").toLowerCase();if(l==="checkbox"||l==="radio")return{type:"checkbox"};if(l==="number")return{type:"number"}}let c=(o.textContent||"").trim();return c.length>60||c.includes(`
|
|
2
|
+
`)?{type:"textarea"}:{type:"text"}}function ec(e,n){if(!n||e==="."||e===""||e.startsWith("@"))return null;let t=bo(e).selector;if(!t)return null;try{return n.querySelector(t)}catch{return null}}function tc(e){if(e.type==="textarea")return document.createElement("textarea");if(e.type==="select")return document.createElement("select");let n=document.createElement("input");return n.type=e.type==="checkbox"?"checkbox":e.type==="number"?"number":"text",n}function hr(e){return typeof e=="number"?`#${e+1}`:String(e).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^\w/,n=>n.toUpperCase())}function nc(e){return` \xB7 ${e}`}function pr(e,n){if(typeof e=="string"){let t=n&&n.defaultView,o=t&&t.DOMParser||globalThis.DOMParser;return new o().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Ur(e){let n=new Map;return(t,o)=>{if(typeof o!="string")return pr(o,e);let r=n.get(t);if(r&&r.text===o)return r.doc;let c=pr(o,e);return n.set(t,{text:o,doc:c}),c}}function Zs(e,n){let t=n.doctype;if(!t)return!1;let o=e.doctype;if(o&&o.name===t.name&&o.publicId===t.publicId&&o.systemId===t.systemId)return!1;let r=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return o?e.replaceChild(r,o):e.insertBefore(r,e.documentElement),!0}var Hr=()=>!1;function Wr(e,n=[]){if(typeof e!="function")return Hr;let t=new WeakMap,o=new Set(n);return r=>{if(!r||r.nodeType!==1)return!1;let c=t.get(r);if(c!==void 0)return c;let l=[],i=r,s=!1;for(;i&&i.nodeType===1;){let a=t.get(i);if(a!==void 0){s=a;break}if(l.push(i),e(i,o.has(i))){s=!0;break}if(o.has(i))break;i=i.parentElement}for(let a of l)t.set(a,s);return s}}var wf=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 Xn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var oc="~",ei="^";function Vr(e,n){let t=new WeakMap;if(!e||!n||typeof n!="object"||Array.isArray(n))return t;let o=n[oc],r=typeof o=="string"?o.split(",").map(Number):null,c=r&&typeof n[ei]=="string"?n[ei].split(","):null,l=f=>Number.isInteger(f)&&f>=0,i=0,s=!1,a=f=>{let u=f;for(;u>0;){let g=r[i++];if(i>r.length||!l(g))return!1;u+=g-1}return!0},h=(f,u)=>{if(s)return;if(r){let A=i++,p=r[A];if(A>=r.length||!l(p)){s=!0;return}let m=!c||c[A]===f.tagName.toLowerCase();if(!m||p!==f.children.length){let y=m&&n[u];typeof y=="string"&&y&&t.set(f,y),a(p)||(s=!0);return}}let g=n[u];typeof g=="string"&&g&&t.set(f,g);let b=f.children;for(let A=0;A<b.length;A++)h(b[A],u===""?String(A):`${u}.${A}`)};return h(e,""),t}function ti(e){return n=>{for(let t of e){let o=t(n);if(typeof o=="string"&&o!=="")return o}return null}}var bn=ti([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function mr(e,n,t,o=null,r=null){let c=new Map,l=new Set,i=s=>{if(t(s))return;let a=n(s);a&&(c.has(a)?l.add(a):c.set(a,s))};if(o){let s=a=>{for(let h of a.querySelectorAll(o))i(h);for(let h of a.querySelectorAll("template"))h.content&&s(h.content)};i(e),s(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let s=a=>{i(a);let h=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let f=0;f<h.length;f++)s(h[f])};s(e)}for(let s of l)c.delete(s),r&&r.add(s),_r(s);return c}function _r(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var rc=new Set(["href","src","name","type","role"]),oi=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function yo(e,n=5381){let t=n;for(let o=0;o<e.length;o++)t=(t<<5)+t^e.charCodeAt(o);return t>>>0}function ni(e){return e.replace(/\s+/g," ")}var sc=0;function ri({ignored:e=()=>!1,ignoreAttribute:n=()=>!1,stats:t=null}={}){let o=new WeakMap,r=new WeakMap;function c(M){let E=M.attributes,N=E.length;if(N===0)return{all:"",sig:M.tagName+"|"};let L=[],j="",F=[];for(let W=0;W<N;W++){let C=E[W],T=C.name;n(M,T)||L.push(T+"="+C.value),T==="class"?j=C.value.indexOf(" ")<0?C.value:C.value.split(/\s+/).filter(Boolean).sort().join(" "):rc.has(T)&&F.push(T+"="+C.value)}return L.length>1&&L.sort(),F.length>1&&F.sort(),{all:L.join(""),sig:M.tagName+"|"+j+(F.length?"|"+F.join("|"):"")}}function l(M){return M.nodeType===1&&M.tagName==="TEMPLATE"&&M.content?M.content.childNodes:M.childNodes}function i(M){let E=o.get(M);if(E)return E;if(M.nodeType===3)E={hash:"T"+yo(M.nodeValue),hint:ni(M.nodeValue).slice(0,64),sig:null,tok:null};else if(M.nodeType===8)E={hash:"C"+yo(M.nodeValue),hint:"",sig:null,tok:null};else if(M.nodeType===1){let N=c(M),L=yo(M.tagName+""+N.all),j="";for(let F of a(M))if(F.nodeType===1){let W=i(F);L=yo(W.hash,L),j.length<64&&(j+=" "+W.hint)}else L=yo(h(F),L),F.kind==="text"&&j.length<64&&(j+=F.value.slice(0,64));E={hash:"E"+L,hint:ni(j).trim().slice(0,64),sig:N.sig,tok:null}}else E={hash:"N"+M.nodeType,hint:"",sig:null,tok:null};return o.set(M,E),E}function s(M){if(!M.tok){M.tok=new Set;for(let E of M.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))E&&M.tok.add(E)}return M.tok}function a(M){let E=r.get(M);if(E)return E;E=[];let N=null,L=()=>{N&&(N.value=N.nodes.map(j=>j.nodeValue).join(""),E.push(N),N=null)};for(let j of l(M)){if(j.nodeType===3){N||(N={kind:"text",nodes:[],value:"",parent:M,hash:void 0}),N.nodes.push(j);continue}L(),j.nodeType===8?E.push({kind:"comment",nodes:[j],value:j.nodeValue,parent:M,hash:void 0}):j.nodeType===1&&!e(j)&&E.push(j)}return L(),r.set(M,E),E}function h(M){return M.nodeType===1?i(M).hash:(M.hash===void 0&&(M.hash=(M.kind==="text"?"T":"C")+yo(M.value)),M.hash)}function f(M,E){let N=s(i(M)),L=s(i(E));if(N.size===0&&L.size===0)return{coef:1,share:1};if(N.size===0||L.size===0)return null;let j=0;for(let F of N)L.has(F)&&j++;return{coef:j/Math.min(N.size,L.size),share:j/Math.max(N.size,L.size)}}function u(M,E){let N=f(M,E);return!!N&&N.coef>=.5}let g=new WeakMap;function b(M){let E=g.get(M);if(E)return E;E=[];for(let N of M.attributes)n(M,N.name)||E.push([N.namespaceURI||"",N.localName,N.value]);return E.sort((N,L)=>N[0]<L[0]?-1:N[0]>L[0]?1:N[1]<L[1]?-1:N[1]>L[1]?1:0),g.set(M,E),E}let A=new WeakMap;function p(M,E){if(M===E)return!0;if(h(M)!==h(E))return!1;let N=A.get(M);if(N&&N.has(E))return N.get(E);let L=A.get(E);if(L&&L.has(M))return L.get(M);let j=m(M,E),F=j===!0;return j===!1&&t&&t.hashRejected++,N||A.set(M,N=new WeakMap),N.set(E,F),F}function m(M,E){if(M.nodeType===1){if(E.nodeType!==1||M.tagName!==E.tagName||M.namespaceURI!==E.namespaceURI)return!1;let N=b(M),L=b(E);if(N.length!==L.length)return!1;for(let W=0;W<N.length;W++)if(N[W][0]!==L[W][0]||N[W][1]!==L[W][1]||N[W][2]!==L[W][2])return!1;let j=a(M),F=a(E);if(j.length!==F.length)return!1;for(let W=0;W<j.length;W++){if(h(j[W])!==h(F[W]))return!1;if(!p(j[W],F[W]))return sc}return!0}return E.nodeType===1?!1:M.kind===E.kind&&M.value===E.value}let y=new WeakMap,R=new Map,S=0;function O(M){let E=y.get(M);if(E)return E;let N=h(M),L=R.get(N);L||R.set(N,L=[]);let j=L.find(F=>p(F.unit,M));return E=j?j.key:"K"+S++,j||L.push({unit:M,key:E}),y.set(M,E),E}return{meta:i,unitsOf:a,unitHash:h,similar:u,score:f,childrenOf:l,equalUnits:p,exactUnitKey:O,ignored:e}}var si=16,ic=2e3,lc=3,Fr={align:0,certifyVisited:0,certifyScheduled:0};function $r(e,n,t){let{meta:o,unitsOf:r,unitHash:c,similar:l,score:i,childrenOf:s,equalUnits:a,ignored:h}=t.analyzer,f=t.baseId||(()=>null),u=t.sideId||(()=>null),g=t.baseKey||(()=>null),b=t.sideKey||(()=>null),A=t.baseDropped||new Set,p=t.sideDropped||new Set,m=t.stats||null,y=m?new Set:null,R=m?new Set:null,S=new Map,O=new Map,M=new Set,E=new Map,N=new Set,L=new Set,j=new Set,F=[],W=[],C=[],T=[],x=ic,z=new Map,D=new Map,V=(B,G)=>{S.set(B,G),O.set(G,B)},Ee=new Set,Me=new Set,De=null,re=B=>{let G=B.nodeType?B.parentNode:B.parent;if(!G||G.nodeType!==11)return G;if(!De){De=new WeakMap;let ue=he=>{for(let ce of he.querySelectorAll("template"))ce.content&&(De.set(ce.content,ce),ue(ce.content))};for(let he of[e,n])ue(he.tagName==="TEMPLATE"&&he.content?he.content:he)}return De.get(G)||null},Se=(B,G)=>{for(let ue=re(B);ue&&!Ee.has(ue);ue=re(ue))Ee.add(ue);for(let ue=re(G);ue&&!Me.has(ue);ue=re(ue))Me.add(ue)},qe=B=>{for(let G=re(B);G;G=re(G))if(S.has(G))return L.has(G);return!1},ve=B=>{for(let G=re(B);G;G=re(G)){let ue=O.get(G);if(ue!==void 0)return L.has(ue)}return!1},w=B=>!!B&&B.nodeType===1,K=(B,G)=>{let ue=E.get(B);return!!ue&&ue.has(G)},ne=B=>oi.has(B.tagName),ee=t.comparisons||t.scope,Pe=(B,G)=>{if(ee){if(ee.same.get(B)===G)return!0;if(ee.differ.get(B)===G)return!1}if(!B.isEqualNode(G))return!1;if(B.tagName==="TEMPLATE")return a(B,G);let ue=B.getElementsByTagName("template");if(ue.length===0)return!0;let he=G.getElementsByTagName("template");if(ue.length!==he.length)return!1;for(let ce=0;ce<ue.length;ce++)if(!a(ue[ce],he[ce]))return!1;return!0},_e=(B,G)=>{let ue=f(B);if(!ue)return!0;let he=u(G);return!he||ue===he},Ae=B=>{let G=g(B);return G&&t.baseIndex.get(G)===B&&!p.has(G)?G:null},ot=B=>{let G=b(B);return G&&t.sideIndex.get(G)===B&&!A.has(G)?G:null},Qe=(B,G)=>{let ue=Ae(B);if(!ue)return!0;let he=ot(G);return!he||ue===he},Ze=globalThis.__hyperMorphProfile,Xe=Ze?performance.now():0;Ze&&!t.scope&&(o(e),o(n),Ze.meta=(Ze.meta||0)+(performance.now()-Xe),Xe=performance.now()),V(e,n);let yt=new Set;for(let[B,G]of t.baseIndex){let ue=t.sideIndex.get(B);ue&&ue.tagName===G.tagName&&!S.has(G)&&!O.has(ue)&&(V(G,ue),Se(G,ue),yt.add(G))}if(yt.size){let B=[];if(t.scope)for(let ce of t.scope.chain)yt.has(ce)&&B.push(ce);let G=[t.scope?t.scope.root:e];for(;G.length;){let ce=G.pop();yt.has(ce)&&B.push(ce);let xe=s(ce);for(let te=xe.length-1;te>=0;te--)xe[te].nodeType===1&&G.push(xe[te])}let ue=new Set;for(let ce=B.length-1;ce>=0;ce--){let xe=B[ce];t.scope&&t.scope.onChain.has(xe)?ue.add(xe):ie(xe,S.get(xe),ue)?(L.add(xe),j.add(xe),m&&m.certificationPairs++):ue.add(xe)}let he=new Set;for(let ce of B)L.has(ce)&&!he.has(ce)&&dt(ce,he)}t.scope&&t.scope.head&&pe(t.scope.head[0],t.scope.head[1]);function dt(B,G){let ue=[B];for(;ue.length;){let he=ue.pop();if(!G.has(he)){G.add(he),Y(he);for(let ce of r(he))w(ce)&&S.has(ce)&&ue.push(ce)}}}T.push([e,n]);for(let[B,G]of S)w(B)&&B!==e&&T.push([B,G]);return Ht(),gt(),Ze&&(Ze.align=(Ze.align||0)+(performance.now()-Xe)),{map:S,reverse:O,moved:N,identical:L,pairIdenticalChildren:Y,weak:M,unpair:qt,rematch:gt,insertedByHash:$t,refused:R,identityPaired:yt};function gt(){ge(),Ht();for(let B=0;B<C.length;){let G=C.length;_t(B,G),B=G,Ht(),ge(),Ht()}}function qt(B){let G=S.get(B);if(!G)return;E.has(B)||E.set(B,new Set),E.get(B).add(G);let ue=(ce,xe)=>{S.delete(ce),O.delete(xe),N.delete(ce),L.delete(ce),M.delete(ce),j.delete(ce)},he=(ce,xe)=>{for(let te of r(ce)){let q=S.get(te);!q||yt.has(te)||!(w(q)?xe.contains(q):xe.contains(q.nodes[0]))||(ue(te,q),w(te)&&he(te,q))}};ue(B,G),w(B)&&he(B,G),F.push(B),W.push(G)}function $t(){let B=new Map;for(let G of new Set(W)){if(O.has(G))continue;let ue=o(G).hash;B.has(ue)||B.set(ue,[]),B.get(ue).push(G)}return B}function Ht(){for(;T.length;){let[B,G]=T.shift();S.get(B)!==G||j.has(B)||L.has(B)||an(B,G)}}function jt(B,G){if(!ne(B))for(let ue of r(B))w(ue)&&(G.push(ue),jt(ue,G))}function an(B,G){j.add(B);let ue=r(B),he=r(G);Fr.align+=ue.length+he.length,z=new Map,D=new Map;for(let ae=0;ae<ue.length;ae++)z.set(ue[ae],ae);for(let ae=0;ae<he.length;ae++)D.set(he[ae],ae);if(B.tagName==="HTML")for(let ae of["HEAD","BODY"]){let Ce=ue.find(We=>w(We)&&We.tagName===ae),Le=he.find(We=>w(We)&&We.tagName===ae);Ce&&Le&&!S.has(Ce)&&!O.has(Le)&&V(Ce,Le)}for(let ae=0;ae<ue.length&&ae<he.length;ae++){let Ce=ue[ae],Le=he[ae];S.has(Ce)||O.has(Le)||(w(Ce)?w(Le)&&Ce.tagName===Le.tagName&&Pe(Ce,Le)&&pe(Ce,Le):!w(Le)&&Ce.kind===Le.kind&&Ce.value===Le.value&&pe(Ce,Le))}Ie(ue,he);let ce=ue.filter(ae=>!S.has(ae)),xe=he.filter(ae=>!O.has(ae));ce.length&&xe.length&&(_(ce,xe),J(ce,xe),oe(ce,xe,ue,he),Oe(ue,he));let te=!1,q=!1;for(let ae of ue){if(!S.has(ae)){w(ae)&&(F.push(ae),jt(ae,F),te=!0);continue}w(ae)&&!L.has(ae)&&T.push([ae,S.get(ae)])}for(let ae of he)!O.has(ae)&&w(ae)&&(W.push(ae),jt(ae,W),q=!0);te&&q&&C.push([B,G])}function _t(B,G){for(let ue=B;ue<G;ue++){let[he,ce]=C[ue];if(S.get(he)!==ce)continue;let xe=r(he),te=r(ce),q=new Map,ae=new Map,Ce=null;for(let Le of xe)w(Le)&&(S.has(Le)?Ce=Le:(q.has(Ce)||q.set(Ce,[]),q.get(Ce).push(Le)));Ce=null;for(let Le of te)w(Le)&&(O.has(Le)?Ce=O.get(Le):(ae.has(Ce)||ae.set(Ce,[]),ae.get(Ce).push(Le)));for(let[Le,We]of q){let Ne=ae.get(Le);if(!(!Ne||We.length!==Ne.length)&&We.every((ze,tt)=>Ne[tt].tagName===ze.tagName&&_e(ze,Ne[tt])&&!K(ze,Ne[tt])))for(let ze=0;ze<We.length;ze++)zt(We[ze],Ne[ze])}}}function zt(B,G){V(B,G),M.add(B),T.push([B,G]),Ht()}function _(B,G){let ue=wo(B,c),he=wo(G,c),ce=new Map;for(let xe of G){let te=c(xe);he.get(te)===1&&ce.set(te,xe)}for(let xe of B){if(S.has(xe))continue;let te=c(xe);if(ue.get(te)!==1)continue;let q=ce.get(te);q&&!O.has(q)&&a(xe,q)&&pe(xe,q)}}function ie(B,G,ue){let he=[[B,G]];for(;he.length;){let[ce,xe]=he.pop();if(Fr.certifyVisited++,m&&m.certificationVisited++,ce.nodeType!==xe.nodeType)return!1;if(ce.nodeType===3||ce.nodeType===8){if(ce.nodeValue!==xe.nodeValue)return!1;continue}if(ce.nodeType!==1){if(!ce.isEqualNode(xe))return!1;continue}if(ce.tagName!==xe.tagName||ce.namespaceURI!==xe.namespaceURI||h(ce)!==h(xe))return!1;let te=ce.attributes,q=xe.attributes;if(te.length!==q.length)return!1;for(let Ne=0;Ne<te.length;Ne++){let ze=te[Ne];if(xe.getAttributeNS(ze.namespaceURI,ze.localName)!==ze.value)return!1}let ae=S.get(ce);if(ae!==void 0&&ae!==xe)return!1;let Ce=O.get(xe);if(Ce!==void 0&&Ce!==ce)return!1;if(ce!==B){if(L.has(ce))continue;if(ue.has(ce))return!1}let Le=s(ce),We=s(xe);if(Le.length!==We.length)return!1;Fr.certifyScheduled+=Le.length;for(let Ne=Le.length-1;Ne>=0;Ne--)he.push([Le[Ne],We[Ne]])}return!0}function me(B,G){return!w(B)||!(Ee.has(B)||Me.has(G))?!0:!!v(B,G)||!(Ae(B)||ot(G))}function pe(B,G){if(w(B)&&(Ee.has(B)||Me.has(G))){let ue=v(B,G);if(!ue){if(Ae(B)||ot(G))return;V(B,G),T.push([B,G]);return}for(let he=0;he<ue.length;he+=2){let ce=ue[he],xe=ue[he+1],te=S.get(ce);te!==void 0&&te!==xe&&ke(ce,te);let q=O.get(xe);q!==void 0&&q!==ce&&ke(q,xe),S.get(ce)===xe&&(N.delete(ce),M.delete(ce),L.add(ce),j.add(ce))}}P(B,G)}function ke(B,G){S.delete(B),O.delete(G),N.delete(B),L.delete(B),M.delete(B),j.delete(B)}function v(B,G){let ue=[B,G,!1],he=[];for(;ue.length;){let ce=ue.pop(),xe=ue.pop(),te=ue.pop(),q=S.get(te),ae=O.get(xe);if(te!==B&&(q!==void 0&&q!==xe&&yt.has(te)||ae!==void 0&&ae!==te&&yt.has(ae)))return null;if(!(q===xe&&L.has(te))&&((q!==void 0||ae!==void 0)&&he.push(te,xe),!!w(te))){if(ce||q!==void 0&&q!==xe||ae!==void 0&&ae!==te){let Ce=r(te),Le=r(xe);for(let We=0;We<Ce.length&&We<Le.length;We++)ue.push(Ce[We],Le[We],!0)}else if(Ee.has(te)||Me.has(xe)){let Ce=te.tagName==="TEMPLATE"?te.content:te,Le=xe.tagName==="TEMPLATE"?xe.content:xe;for(let We=Ce.firstElementChild,Ne=Le.firstElementChild;We&&Ne;){if(h(We)){We=We.nextElementSibling;continue}if(h(Ne)){Ne=Ne.nextElementSibling;continue}(S.has(We)||O.has(Ne)||Ee.has(We)||Me.has(Ne))&&ue.push(We,Ne,!1),We=We.nextElementSibling,Ne=Ne.nextElementSibling}}}}return he}function P(B,G){V(B,G),L.add(B),w(B)&&j.add(B)}function Y(B){let G=S.get(B);if(!G||!w(B))return;let ue=r(B),he=r(G);for(let ce=0;ce<ue.length&&ce<he.length;ce++)S.has(ue[ce])||P(ue[ce],he[ce])}function J(B,G){let ue=te=>w(te)&&!ne(te)?o(te).sig+""+o(te).hint:null,he=wo(B,ue),ce=wo(G,ue),xe=new Map;for(let te of G){let q=ue(te);q!=null&&ce.get(q)===1&&xe.set(q,te)}for(let te of B){if(S.has(te))continue;let q=ue(te);if(q==null||he.get(q)!==1)continue;let ae=xe.get(q);ae&&!O.has(ae)&&_e(te,ae)&&V(te,ae)}}function oe(B,G,ue,he){let ce=new Map;for(let te of G){if(!w(te)||O.has(te)||ne(te))continue;let q=o(te).sig;ce.has(q)||ce.set(q,[]),ce.get(q).push({el:te,index:D.get(te)})}let xe=[];for(let te of B){if(S.has(te)||!w(te)||ne(te))continue;let q=ce.get(o(te).sig);if(!q||!q.length)continue;let ae=z.get(te),Ce=q.filter(Le=>!O.has(Le.el)).map(Le=>({c:Le,d:Math.abs(Le.index-ae)}));Ce.sort((Le,We)=>Le.d-We.d),Ce.length>si&&(Ce=Ce.slice(0,si));for(let{c:Le,d:We}of Ce){if(!_e(te,Le.el))continue;let Ne=i(te,Le.el);Ne&&Ne.coef>=.5&&xe.push({b:te,s:Le.el,coef:Ne.coef,share:Ne.share,d:We,bi:ae})}}if(xe.sort((te,q)=>q.coef-te.coef||q.share-te.share||te.d-q.d||te.bi-q.bi),m&&xe.length>1){let te=new Map;for(let q of xe){let ae=te.get(q.b);ae?ae.coef===q.coef&&(ae.share===q.share?ae.strict++:ae.loose++):te.set(q.b,{coef:q.coef,share:q.share,strict:0,loose:0})}for(let[q,ae]of te)y.has(q)||!(ae.strict||ae.loose)||(y.add(q),ae.strict?m.similarTiesStrict++:m.similarTiesLoose++)}for(let te of xe)!S.has(te.b)&&!O.has(te.s)&&V(te.b,te.s)}function je(B,G){return w(B)!==w(G)?!1:w(B)?B.tagName!==G.tagName||!_e(B,G)?!1:ne(B)||o(B).hint===""||o(G).hint===""?!0:l(B,G):B.kind===G.kind}function Z(B,G){let ue=(ce,xe)=>{let te=xe===null?-1:ce===G?D.get(xe):z.get(xe),q=ce[te+1];return q&&!w(q)?q:null},he=null;for(let ce of B){if(w(ce)){he=ce;continue}if(S.has(ce))continue;let xe=he===null?null:S.get(he);if(he!==null&&!xe)continue;let te=ue(G,xe);te&&!O.has(te)&&te.kind===ce.kind&&V(ce,te)}}function Oe(B,G){Z(B,G);let ue=He(B,G),he=(xe,te)=>w(xe)&&o(xe).hint!==""&&o(te).hint===""&&!!te.querySelector("br")&&!ue(xe,te),ce=0;for(let xe of B){if(S.has(xe)){let q=D.get(S.get(xe));q!==void 0&&q>=ce&&(ce=q+1);continue}let te=0;for(let q=ce;q<G.length&&te<lc;q++){let ae=G[q];if(!O.has(ae)&&(te++,je(xe,ae)&&!K(xe,ae)&&!he(xe,ae))){V(xe,ae),w(xe)&&(o(xe).hint===""||o(ae).hint==="")&&M.add(xe),ce=q+1;break}}}Ie(B,G)}function He(B,G){let ue=(he,ce,xe)=>{for(let te=ce-1;te>=0;te--)if(w(he[te])&&xe(he[te]))return he[te];return null};return(he,ce)=>{let xe=z.get(he),te=D.get(ce);if(xe===te)return!0;let q=ue(B,xe,Ce=>S.has(Ce)),ae=ue(G,te,Ce=>O.has(Ce));return q?S.get(q)===ae:!ae}}function Ie(B,G){let ue=B.filter(q=>w(q)&&!S.has(q)),he=G.filter(q=>w(q)&&!O.has(q));if(!ue.length||!he.length)return;let ce=wo(ue,q=>q.tagName),xe=wo(he,q=>q.tagName),te=He(B,G);for(let q of ue){let ae=q.tagName;if(ce.get(ae)!==1||xe.get(ae)!==1)continue;let Ce=he.find(Le=>Le.tagName===ae);Ce&&!O.has(Ce)&&te(q,Ce)&&_e(q,Ce)&&!K(q,Ce)&&(a(q,Ce)?pe(q,Ce):(V(q,Ce),M.add(q)))}}function ge(){let B=new Map;for(let q of M)if(w(q)&&w(S.get(q))){let ae=o(q).hash;B.has(ae)||B.set(ae,[]),B.get(ae).push(q)}if(B.size)for(let q of W){if(O.has(q)||!w(q)||ve(q))continue;let ae=B.get(o(q).hash),Ce=ae&&ae.find(Le=>M.has(Le)&&!K(Le,q)&&_e(Le,q)&&Qe(Le,q)&&a(Le,q)&&me(Le,q));Ce&&(qt(Ce),pe(Ce,q),Se(Ce,q),N.add(Ce))}let G=new Map,ue=new Map,he=new Map;for(let q of M){let ae=S.get(q);w(q)&&w(ae)&&he.set(ae,q)}let ce=(q,ae)=>{if(!O.has(q))return!ve(q);let Ce=he.get(q);return Ce===O.get(q)&&Ce!==ae&&!Ce.contains(ae)},xe=q=>{if(O.has(q)){let ae=he.get(q);he.delete(q),qt(ae)}};for(let q of[...W,...he.keys()]){if(O.has(q)&&!he.has(q))continue;let ae=o(q).hash;if(G.has(ae)||G.set(ae,[]),G.get(ae).push(q),ne(q))continue;let Ce=o(q).sig;ue.has(Ce)||ue.set(Ce,[]),ue.get(Ce).push(q)}let te=new Set;for(let q of M){let ae=S.get(q);!w(q)||!w(ae)||ne(q)||o(q).hint===""||o(ae).hint===""||l(q,ae)||te.add(q)}for(let q of[...F,...te]){let ae=S.get(q);if(ae?!(M.has(q)&&te.has(q)):qe(q))continue;let Ce=tt=>{ae&&qt(q),xe(tt)},Le=G.get(o(q).hash);if(Le){let tt=Le.find(k=>k!==ae&&ce(k,q)&&!K(q,k)&&Qe(q,k)&&a(q,k)&&me(q,k));if(tt){Ce(tt),pe(q,tt),Se(q,tt),N.add(q);continue}}if(ne(q)||x<=0)continue;let We=ue.get(o(q).sig);if(!We)continue;let Ne=null,ze=0;for(let tt of We)if(!(tt===ae||!ce(tt,q)||!_e(q,tt)||!Qe(q,tt)||K(q,tt))&&(x--<=0||l(q,tt)&&(ze++,Ne=tt,ze>1)))break;ze>1&&R&&R.add(q),ze===1&&(Ce(Ne),V(q,Ne),Se(q,Ne),N.add(q),T.push([q,Ne]))}}}function wo(e,n){let t=new Map;for(let o of e){let r=n(o);r!=null&&t.set(r,(t.get(r)||0)+1)}return t}var cc={diff:0},ii=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,ac=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,fc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,uc=/\P{M}\p{M}*/gu;function dc(e){if(e==="")return[];if(ii){let t=[];for(let o of ii.segment(e))t.push(o.segment);return t}let n=[];for(let t of e.match(fc))if(ac.test(t))for(let o of t.match(uc))n.push(o);else n.push(t);return n}var hc=/^[ ]+$/,pc=e=>hc.test(e)?" ".repeat(e.length):e,Jn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),wt="",Kr=e=>e.every(n=>Jn(n)||n.k===wt),mc=/^[\x00-\x7f\u00A0]*$/,gc=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function bc(e){return e===""?[]:e.match(gc)}function ln(e,n=!1){return(n?bc(e):dc(e)).map(t=>({k:pc(t),raw:t,len:t.length}))}var yn=(...e)=>e.every(n=>mc.test(n));function qr(e,n,t){let o=e.length,r=n.length,c=Math.min(o+r,t),l=c+1,i=new Int32Array(2*c+3),s=[],a=o===0&&r===0;for(let g=0;g<=c&&!a;g++){s.push(i.slice(l-g,l+g+1));for(let b=-g;b<=g;b+=2){let A;b===-g||b!==g&&i[l+b-1]<i[l+b+1]?A=i[l+b+1]:A=i[l+b-1]+1;let p=A-b,m=A;for(;A<o&&p<r&&e[A].k===n[p].k;)A++,p++;if(cc.diff+=1+A-m,i[l+b]=A,A>=o&&p>=r){a=!0;break}}}if(!a)return null;let h=[],f=o,u=r;for(let g=s.length-1;g>0;g--){let b=s[g],A=f-u,p=A+g,m=A===-g||A!==g&&b[p-1]<b[p+1]?A+1:A-1,y=b[m+g],R=y-m;for(;f>y&&u>R;)h.push([0,f-1,u-1]),f--,u--;f===y?(h.push([1,f,u-1]),u--):(h.push([-1,f-1,u]),f--)}for(;f>0&&u>0;)h.push([0,f-1,u-1]),f--,u--;return h.reverse(),h}function yc(e,n,t){let o=f=>f.k===wt;if(!e.some(o)&&!n.some(o))return qr(e,n,t);let r=[],c=[];for(let f=0;f<e.length;f++)o(e[f])||r.push(f);for(let f=0;f<n.length;f++)o(n[f])||c.push(f);let l=qr(r.map(f=>e[f]),c.map(f=>n[f]),t);if(!l)return null;let i=[],s=0,a=0,h=(f,u)=>{for(;s<f&&a<u&&e[s].k===n[a].k;)i.push([0,s++,a++]);let g=qr(e.slice(s,f),n.slice(a,u),t);if(!g)return!1;for(let[b,A,p]of g)i.push([b,A+s,p+a]);return s=f,a=u,!0};for(let[f,u,g]of l)if(f===0){if(!h(r[u],c[g]))return null;i.push([0,s,a]),s++,a++}return h(e.length,n.length)?i:null}function Kn(e,n,t=4e3){let o=[],r=0;for(;r<e.length&&r<n.length&&e[r].k===n[r].k;)e[r].raw!==n[r].raw&&o.push({bi:r,tok:n[r]}),r++;let c=0;for(;c<e.length-r&&c<n.length-r&&e[e.length-1-c].k===n[n.length-1-c].k;)e[e.length-1-c].raw!==n[n.length-1-c].raw&&o.push({bi:e.length-1-c,tok:n[n.length-1-c]}),c++;let l=e.slice(r,e.length-c),i=n.slice(r,n.length-c),s=Sc(l,i)?null:yc(l,i,t);if(!s){let m=l.length||i.length?[{bs:r,be:r+l.length,toks:i}]:[];return{hunks:m,cosmetic:o,coarse:!0,parts:m.map(y=>({...y,gap:[],group:0})),cosmeticEq:o}}let a=[],h=(m,y)=>{l[m].raw!==i[y].raw&&o.push({bi:r+m,tok:i[y]})},f=null,u=[],g=0,b=0,A=()=>{f&&a.push(f),f=null;for(let[m,y]of u)h(m,y);u=[],g++};for(let[m,y,R]of s){if(m===0){f&&Jn(l[y])&&!l[y].k.includes(`
|
|
3
|
+
`)?u.push([y,R]):(A(),h(y,R)),b=y+1;continue}(!f||u.length)&&(f&&a.push(f),f={bs:r+b,be:r+b,toks:[],gap:u.map(([S,O])=>({bi:r+S,tok:i[O]})),group:g},u=[]),m===-1?(f.be=r+b+1,b=y+1):f.toks.push(i[R])}A(),wc(a,e);let p=Gr(a);return{hunks:p.hunks,cosmetic:o.concat(p.cosmetic),parts:a,cosmeticEq:o}}function wc(e,n){for(let t=0;t<e.length;t++){let o=e[t];if(o.gap.length)continue;let r=t+1<e.length?e[t+1].bs:1/0;if(o.toks.length){if(o.bs===o.be)for(;o.bs+1<r&&o.bs<n.length&&o.toks[0].k===wt&&n[o.bs].k===wt;)o.toks=[...o.toks.slice(1),o.toks[0]],o.bs++,o.be++}else for(;o.be+1<r&&o.be<n.length&&n[o.bs].k===wt&&n[o.be].k===wt;)o.bs++,o.be++}}function Gr(e,n=()=>!1){let t=[],o=[],r=null,c=-1;for(let l of e){let i=n(l);if(r&&!r.alone&&!i&&l.group===c){r.be=l.be;for(let s of l.gap)r.toks.push(s.tok);for(let s of l.toks)r.toks.push(s);continue}r&&t.push({bs:r.bs,be:r.be,toks:r.toks});for(let s of l.gap)o.push(s);r={bs:l.bs,be:l.be,toks:l.toks.slice(),alone:i},c=l.group}return r&&t.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:t,cosmetic:o}}var xc=(e,n)=>e.bs===n.bs&&e.be===n.be&&Jr(e.toks,n.toks);function Xr(e,n,t){let o=h=>f=>h.some(u=>xc(f,u)),r=Gr(e.parts,o(n.parts)),c=Gr(n.parts,o(e.parts)),l=e.cosmeticEq.concat(r.cosmetic),i=n.cosmeticEq.concat(c.cosmetic),[s,a]=t?kc(r.hunks,c.hunks,t,l,i):[r.hunks,c.hunks];return{lh:s,rh:a,cosL:l,cosR:i}}function kc(e,n,t,o,r){let c=(b,A)=>b.k===A.k&&b.raw===A.raw,l=[{list:e.map(b=>({...b})),resp:new Set(o.map(b=>b.bi)),raw:new Map(o.map(b=>[b.bi,b.tok]))},{list:n.map(b=>({...b})),resp:new Set(r.map(b=>b.bi)),raw:new Map(r.map(b=>[b.bi,b.tok]))}],i=b=>b.bs===b.be,s=(b,A,p,m)=>{let y=b.list[A];if(!i(y))return m(y)===p?y.toks:null;let R=A?b.list[A-1].be:0,S=A+1<b.list.length?b.list[A+1].bs:t.length;if(p<R||p>S)return null;let O=y.toks,M=y.bs;for(;M>p;){let E=O[O.length-1];if(!c(E,t[M-1])||b.resp.has(M-1))return null;O=[E,...O.slice(0,-1)],M--}for(;M<p;){if(!c(O[0],t[M])||b.resp.has(M))return null;O=[...O.slice(1),O[0]],M++}return O},a=(b,A,p,m,y,R)=>{let S=b.list[A],O=y?p.slice(p.length-m):p.slice(0,m),M=y?p.slice(0,p.length-m):p.slice(m),E={bs:R,be:R,toks:O};if(i(S)){if(!M.length){b.list[A]=E;return}let L={bs:R,be:R,toks:M};y&&(L.lead=!0),b.list.splice(A,1,...y?[L,E]:[E,L]);return}let N={bs:S.bs,be:S.be,toks:M};b.list.splice(A,1,...y?[N,E]:[E,N])},h=(b,A,p,m,y)=>{let R=b.list[A],S=y?p.slice(p.length-m):p.slice(0,m),O=y?p.slice(0,p.length-m):p.slice(m),M={bs:R.bs,be:R.be,toks:S};if(!O.length){b.list[A]=M;return}let E=y?{bs:R.bs,be:R.bs,toks:O,lead:!0}:{bs:R.be,be:R.be,toks:O};b.list.splice(A,1,...y?[E,M]:[M,E])},f=(b,A,p,m)=>{let y=b.list[A],R=p.list[m],S=y.be,O=R.bs;if(S>=O||A+1<b.list.length&&b.list[A+1].bs<=R.be||m>0&&p.list[m-1].be>=y.bs)return!1;for(let D=S;D<O;D++)if(!Jn(t[D])||t[D].k.includes(`
|
|
4
|
+
`))return!1;let M=D=>t.slice(S,O).map((V,Ee)=>D.raw.get(S+Ee)||V),E=[...y.toks,...M(b)],N=[...M(p),...R.toks],L=(D,V,Ee)=>V>=0&&V+Ee.length<=D.length&&Ee.every((Me,De)=>D[V+De].k===Me.k),j=(D,V,Ee)=>Kr(D)&&t.slice(V,Ee).some(Me=>!Jn(Me)),F=D=>D.some(V=>!Jn(V)),W,C,T,x;if(i(y)&&F(y.toks)&&L(N,0,y.toks)){let D=N.slice(y.toks.length);j(D,S,R.be)||(W=S,C=y.toks,T=N.slice(0,y.toks.length),x=[null,{bs:S,be:R.be,toks:D}])}if(W===void 0&&i(R)&&F(R.toks)){let D=E.length-R.toks.length,V=E.slice(0,D);L(E,D,R.toks)&&!j(V,y.bs,O)&&(W=O,C=E.slice(D),T=R.toks,x=[{bs:y.bs,be:O,toks:V},null])}if(W===void 0)return!1;let z=D=>D&&(D.bs<D.be||D.toks.length);return b.list.splice(A,1,...[x[0],{bs:W,be:W,toks:C}].filter(z)),p.list.splice(m,1,...[{bs:W,be:W,toks:T},x[1]].filter(z)),!0},u=l[0],g=l[1];for(let b=0;b<64;b++){let A=!1;e:for(let p=0;p<u.list.length;p++)for(let m=0;m<g.list.length;m++){let y=u.list[p],R=g.list[m];if(!(y.bs===R.bs&&y.be===R.be&&Jr(y.toks,R.toks))){for(let S of[!0,!1]){let O=E=>S?E.be:E.bs,M=i(y)?[O(R),y.bs]:[O(y)];for(let E of M){let N=s(u,p,E,O),L=N&&s(g,m,E,O);if(!L)continue;let j=(x,z)=>S?x[x.length-1-z]:x[z],F=0;for(;F<N.length&&F<L.length&&j(N,F).k===j(L,F).k;)F++;if(!F)continue;let W=S?N.slice(0,N.length-F):N.slice(F),C=S?L.slice(0,L.length-F):L.slice(F);if(!(F<N.length&&F<L.length&&!Kr(W)&&!Kr(C)&&(i(y)&&i(R)||y.bs===R.bs&&y.be===R.be)||!(S?N.slice(N.length-F):N.slice(0,F)).some(x=>!Jn(x)))){if(F===N.length&&F===L.length&&i(y)&&i(R)){if(y.bs===E&&R.bs===E)continue;u.list[p]={bs:E,be:E,toks:N},g.list[m]={bs:E,be:E,toks:L}}else!i(y)&&y.bs===R.bs&&y.be===R.be?(h(u,p,N,F,S),h(g,m,L,F,S)):(a(u,p,N,F,S,E),a(g,m,L,F,S,E));A=!0;break e}}}if(f(u,p,g,m)||f(g,m,u,p)){A=!0;break e}}}if(!A)break}return[u.list,g.list]}var Tc=48,Ac=.3;function Sc(e,n){let t=e.filter(l=>!Jn(l)),o=n.filter(l=>!Jn(l));if(Math.min(t.length,o.length)<Tc)return!1;let r=new Map;for(let l of t)r.set(l.k,(r.get(l.k)||0)+1);let c=0;for(let l of o){let i=r.get(l.k);i>0&&(c++,r.set(l.k,i-1))}return c/Math.min(t.length,o.length)<Ac}var Nc=(e,n)=>{let t=new Set;for(let o of e.toks)typeof o.k!="string"&&t.add(o.k.el);for(let o=e.bs;o<e.be;o++)typeof n[o].k!="string"&&t.add(n[o].k.el);return t},Jr=(e,n)=>e.length===n.length&&e.every((t,o)=>t.k===n[o].k);function li(e,n,t,o="remote"){let r=Kn(e,n),c=Kn(e,t),{lh:l,rh:i,cosL:s,cosR:a}=Xr(r,c,e),h=w=>w.bs===w.be,f=w=>w.toks.some(K=>typeof K.k=="string"),u=w=>h(w)&&!f(w),g=(w,K)=>K.bs<w.be&&w.bs<K.be,b=(w,K)=>!g(w,K)&&K.bs<=w.be&&w.bs<=K.be&&(h(w)&&f(w)||h(K)&&f(K))&&!(h(w)&&h(K)),A=(w,K)=>w.bs===K.bs&&w.be===K.be&&Jr(w.toks,K.toks),p=[],m=new Set;for(let w of l){let K=i.find(ne=>!m.has(ne)&&A(w,ne));K?(m.add(K),p.push({bs:w.bs,be:w.be,side:"both",l:w,r:K,toks:w.toks})):p.push({bs:w.bs,be:w.be,side:"L",l:w,toks:w.toks,lead:!!w.lead})}for(let w of i)m.has(w)||p.push({bs:w.bs,be:w.be,side:"R",r:w,toks:w.toks,lead:!!w.lead});p.sort((w,K)=>w.bs-K.bs||w.be-K.be||K.lead-w.lead);let y=0,R=0;for(let w of p)w.side==="both"&&(y+=w.toks.length-(w.be-w.bs));let S=p.map((w,K)=>K),O=w=>S[w]===w?w:S[w]=O(S[w]),M=(w,K)=>(w=O(w),K=O(K),w===K?!1:(S[w]=K,!0)),E=p.map(w=>Nc({bs:w.bs,be:w.be,toks:w.toks},e)),N={L:new Map,R:new Map};p.forEach((w,K)=>{let ne=w.side==="both"?["L","R"]:[w.side];for(let ee of ne)for(let Pe of E[K])N[ee].has(Pe)||N[ee].set(Pe,[]),N[ee].get(Pe).push(K)});for(let w of[N.L,N.R])for(let K of w.values())for(let ne=1;ne<K.length;ne++)M(K[0],K[ne]);for(let w=0;w<p.length;w++)for(let K=w+1;K<p.length;K++){let ne=p[w],ee=p[K];ne.side===ee.side&&ne.side!=="both"||ne.bs>ee.be||(g(ne,ee)||b(ne,ee)?M(w,K):ne.bs===ee.bs&&h(ne)&&h(ee)&&R++)}let L=(w,K)=>{let ne=w==="L"?l:i;for(let ee of ne)if(ee.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===K.el))return ee.bs;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="close"&&e[ee].k.el===K.el)return ee;return-1};p.forEach((w,K)=>{if(!(!u(w)||w.side==="both"))for(let ne of w.toks){if(ne.kind!=="open")continue;let ee=L(w.side,ne.k);if(ee<=w.bs)continue;let Pe=new Uint8Array(ee-w.bs),_e=[];if(p.forEach((Ae,ot)=>{if(!(Ae.side===w.side||h(Ae))&&Ae.bs<ee&&Ae.be>w.bs){_e.push(ot);for(let Qe=Math.max(Ae.bs,w.bs);Qe<Math.min(Ae.be,ee);Qe++)Pe[Qe-w.bs]=1}}),_e.length&&Pe.every(Ae=>Ae===1))for(let Ae of _e)M(K,Ae)}});let j=!0;for(;j;){j=!1;let w=new Map;p.forEach((K,ne)=>{let ee=O(ne),Pe=w.get(ee)||{bs:K.bs,be:K.be,L:!1,R:!1};Pe.bs=Math.min(Pe.bs,K.bs),Pe.be=Math.max(Pe.be,K.be),K.side!=="R"&&(Pe.L=!0),K.side!=="L"&&(Pe.R=!0),w.set(ee,Pe)}),p.forEach((K,ne)=>{for(let[ee,Pe]of w){if(O(ne)===O(ee)||!(Pe.L&&Pe.R))continue;let _e=K.bs<Pe.be&&K.be>Pe.bs,Ae=h(K)&&f(K)&&(K.bs===Pe.be||K.bs===Pe.bs);(_e||Ae)&&M(ne,ee)&&(j=!0)}})}let F=new Map;p.forEach((w,K)=>{let ne=O(K);F.has(ne)||F.set(ne,[]),F.get(ne).push(w)});let W=[];for(let w of F.values()){let K=w.some(ee=>ee.side==="L"),ne=w.some(ee=>ee.side==="R");if(K&&ne){let ee=Math.min(...w.map(ot=>ot.bs)),Pe=Math.max(...w.map(ot=>ot.be)),_e=w.filter(ot=>ot.side!=="R").map(ot=>ot.l).sort((ot,Qe)=>ot.bs-Qe.bs),Ae=w.filter(ot=>ot.side!=="L").map(ot=>ot.r).sort((ot,Qe)=>ot.bs-Qe.bs);W.push({bs:ee,be:Pe,kind:"conflict",localHunks:_e,remoteHunks:Ae})}else for(let ee of w)W.push({bs:ee.bs,be:ee.be,kind:ee.side,u:ee})}let C=(w,K)=>{let ne=w==="L"?l:i;for(let ee of ne)if(ee.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===K.el))return ee.bs+.5;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="close"&&e[ee].k.el===K.el)return ee;return 1/0},T=(w,K)=>{let ne=w==="L"?l:i;for(let ee of ne)if(ee.toks.some(Pe=>Pe.kind==="open"&&Pe.k.el===K.el))return ee.bs-.5;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="open"&&e[ee].k.el===K.el)return ee;return-1/0},x=w=>w.kind==="R"?"R":"L",z=w=>w.kind==="R"?1:0;W.sort((w,K)=>{if(w.bs!==K.bs)return w.bs-K.bs;let ne=w.bs===w.be,ee=K.bs===K.be;if(ne!==ee)return ne?-1:1;if(ne&&ee&&w.kind!=="conflict"&&K.kind!=="conflict"){let _e=w.u.toks,Ae=K.u.toks,ot=Ze=>Ze.length&&Ze.every(Xe=>Xe.kind==="open"),Qe=Ze=>Ze.length&&Ze.every(Xe=>Xe.kind==="close");if(ot(_e)&&ot(Ae)){let Ze=Math.max(..._e.map(yt=>C(x(w),yt.k))),Xe=Math.max(...Ae.map(yt=>C(x(K),yt.k)));if(Ze!==Xe)return Xe-Ze}if(Qe(_e)&&Qe(Ae)){let Ze=Math.min(..._e.map(yt=>T(x(w),yt.k))),Xe=Math.min(...Ae.map(yt=>T(x(K),yt.k)));return Ze!==Xe?Xe-Ze:z(K)-z(w)}}let Pe=_e=>_e.u&&_e.u.lead?1:0;return Pe(K)-Pe(w)||z(w)-z(K)||w.be-K.be});let D=[],V=[],Ee=0,Me=w=>{w>Ee&&(D.push({bs:Ee,be:w,toks:e.slice(Ee,w),source:"base"}),Ee=w)};for(let w of W){if(Me(w.bs),w.kind==="conflict"){let K=Yr(e,w.localHunks,w.bs,w.be),ne=Yr(e,w.remoteHunks,w.bs,w.be),ee=o==="local"?K:o==="both"?K.concat(ne):ne,Pe=(ot,Qe)=>{let Ze=0;for(let Xe of ot)Xe.be<=w.bs&&!Qe.includes(Xe)&&(Ze+=Xe.toks.length-(Xe.be-Xe.bs));return Ze},_e=w.bs+Pe(l,w.localHunks),Ae=w.bs+Pe(i,w.remoteHunks);V.push({bs:w.bs,be:w.be,ls:_e,le:_e+K.length,rs:Ae,re:Ae+ne.length,ms:0,me:0,base:e.slice(w.bs,w.be),local:K,remote:ne,resolved:ee}),D.push({bs:w.bs,be:w.be,toks:ee,source:"conflict",localHunks:w.localHunks,localToks:K,keepsLocal:o!=="remote"})}else D.push({bs:w.bs,be:w.be,toks:w.u.toks,source:w.kind==="R"?"remote":"local",localHunks:w.kind==="R"?[]:[w.u.l]});Ee=Math.max(Ee,w.be)}Me(e.length);let De=0,re=0;for(let w of D)w.source==="conflict"&&(V[re].ms=De,V[re].me=De+w.toks.length,re++),De+=w.toks.length;let Se=new Map(s.map(w=>[w.bi,w.tok])),qe=new Map(a.map(w=>[w.bi,w.tok])),ve=[];for(let w of D){w.source==="base"&&(w.toks=w.toks.map((K,ne)=>{let ee=w.bs+ne,Pe=Se.get(ee),_e=qe.get(ee),Ae=Pe&&_e?o==="remote"?_e:Pe:Pe||_e||K;return Ae===K?K:{...Ae,cosmetic:!0}}));for(let K of w.toks)ve.push({...K,src:w.source})}return{tokens:ve,segments:D,conflicts:V,localHunks:l,remoteHunks:i,collapsedDelta:y,samePoint:R,mapLocalOffset:vc(e,l,D)}}function Yr(e,n,t,o){let r=[],c=t;for(let l of n)r=r.concat(e.slice(c,l.bs),l.toks),c=l.be;return r.concat(e.slice(c,o))}var zr=e=>e.reduce((n,t)=>n+t.len,0);function vc(e,n,t){let o=new Int32Array(e.length+1);for(let l=0;l<e.length;l++)o[l+1]=o[l]+e[l].len;let r=n.map(l=>({bs:o[l.bs],be:o[l.be],text:l.toks.map(i=>i.raw).join(""),ref:l})),c=t.map(l=>({bs:o[l.bs],be:o[l.be],len:zr(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?zr(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let i=null,s=null,a=0,h=0,f=0;for(let g of r){let b=g.bs-f;if(l<=h+b){i=f+(l-h);break}if(h+=b,f=g.bs,l<=h+g.text.length){s=g,a=l-h,i=g.bs;break}h+=g.text.length,f=g.be}i===null&&(i=f+(l-h));let u=0;for(let g of c){if(!s&&i<=g.bs)return u;if(!(s?g.localHunks.includes(s.ref):i<g.be)){u+=g.len;continue}if(g.source==="base")return u+(i-g.bs);if(g.source==="remote")return u+g.len;if(g.source==="local")return u+Math.min(a,g.len);if(!g.keepsLocal||!s)return u+g.len;let A=g.localHunks.indexOf(s.ref),p=zr(Yr(e,g.localHunks.slice(0,A),g.ref.bs,s.ref.bs));return u+Math.min(p+a,g.localLen)}return u}}function Ho(e,n,t,o="remote"){if(n===t||t===e)return{text:n,conflicts:[],mapLocalOffset:m=>Math.min(m,n.length),granularity:"word"};let r=yn(e,n,t),c=ln(e,r),l=ln(n,r),i=ln(t,r),s=c.length<=2e4&&l.length<=2e4&&i.length<=2e4?li(c,l,i,o):null,a="word",h=c;if(!s){let m=y=>y.split(/(?<=\n)/).map(R=>({k:R,raw:R,len:R.length}));h=m(e),s=li(h,m(n),m(t),o),a="line"}let f=m=>m.map(y=>y.raw).join(""),u=m=>{let y=[0];for(let R of m)y.push(y[y.length-1]+R.len);return y},g=u(h),b=null,A=null,p=null;if(s.conflicts.length){let m=y=>y.split(/(?<=\n)/).map(R=>({k:R,raw:R,len:R.length}));b=u(a==="line"?m(n):l),A=u(a==="line"?m(t):i),p=u(s.tokens)}return{text:f(s.tokens),conflicts:s.conflicts.map(m=>({bs:g[m.bs],be:g[m.be],ls:b[m.ls],le:b[m.le],rs:A[m.rs],re:A[m.re],ms:p[m.ms],me:p[m.me],base:f(m.base),local:f(m.local),remote:f(m.remote),resolved:f(m.resolved)})),mapLocalOffset:s.mapLocalOffset,granularity:a}}function ro(e,n,t=4e3){if(e===n)return[];let o=yn(e,n),r=ln(e,o),c=ln(n,o),l=Kn(r,c,t),i=[0];for(let s of r)i.push(i[i.length-1]+s.len);return l.hunks.map(s=>({bs:i[s.bs],be:i[s.be],text:s.toks.map(a=>a.raw).join("")}))}function Kt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Dn({base:e,side:n,retained:t,transfers:o,baseAtomKey:r=i=>i.el,sideAtomKey:c=i=>i.el,budget:l=Kt()}){let i=[],s=O=>({status:"fallback",reason:O}),a=O=>O>l.remaining?!1:(l.remaining-=O,!0);if(!a((t.length+o.length)*3))return s("work-limit");for(let[O,M]of[["retained",t],["transfer",o]])for(let E of M){let{from:N,to:L,target:j}=E;if(!Number.isInteger(N)||!Number.isInteger(L)||!Number.isInteger(j)||N<0||L<=N||L>e.text.length||j<0||j+L-N>n.text.length)return s("invalid-range");i.push({...E,kind:O})}let h=Symbol(),f=O=>(M,E)=>{if(!a(1))throw h;return l.sortComparisons++,O(M,E)},u,g;try{u=i.slice().sort(f((O,M)=>O.from-M.from||O.to-M.to)),g=i.slice().sort(f((O,M)=>O.target-M.target||O.to-O.from-(M.to-M.from)))}catch(O){if(O===h)return s("work-limit");throw O}if(!a(i.length*2))return s("work-limit");for(let O=1;O<u.length;O++)if(u[O].from<u[O-1].to)return s("source-overlap");for(let O=1;O<g.length;O++)if(g[O].target<g[O-1].target+g[O-1].to-g[O-1].from)return s("target-overlap");for(let O of u){let M=O.to-O.from;if(!a(M))return s("work-limit");for(let E=0;E<M;E++){let N=O.from+E,L=O.target+E;if(l.comparisons++,e.text[N]!==n.text[L])return s("unequal-occurrence");let j=e.atomAt.get(N),F=n.atomAt.get(L);if(!!j!=!!F||j&&r(j)!==c(F))return s("different-atom")}}let b=e.text.length+n.text.length+2,A=i.reduce((O,M)=>O+(M.to-M.from)*2,2);if(!a(b+A+i.length))return s("work-limit");let p=new Int32Array(e.text.length+1).fill(-1),m=new Int32Array(n.text.length+1).fill(-1);l.mapCells+=b,l.mapWrites+=A;let y=-1,R=!0;for(let O of u){O.target<y&&(R=!1),y=O.target+O.to-O.from;for(let M=0;M<O.to-O.from;M++)p[O.from+M]=O.target+M,m[O.target+M]=O.from+M}return p[e.text.length]=n.text.length,m[n.text.length]=e.text.length,{status:"ready",runs:u,bTo:p,toB:m,monotone:R,covers:(O,M)=>{if(!a(M-O))return null;l.coverageChecks+=M-O;for(let E=O;E<M;E++)if(e.text[E]!==wt&&!/\s/.test(e.text[E])&&p[E]<0)return!1;return!0}}}function Qr({base:e,side:n,baseOf:t=()=>null,budget:o=Kt()}){if(e.text===n.text||!e.text.includes(wt)&&!n.text.includes(wt))return{status:"none"};let r=(e.text.length+n.text.length)*8;if(r>o.remaining)return{status:"fallback",reason:"work-limit"};o.remaining-=r,o.boundarySteps=(o.boundarySteps||0)+r;let c=(b,A)=>A<b.length&&(b[A]===wt||/\s/.test(b[A])),l=new Map,i=Symbol(),s=(b,A)=>{let p=b.stackAt[A]||[];if(!l.has(p)){if(p.length>o.remaining)throw i;o.remaining-=p.length,o.boundarySteps+=p.length,l.set(p,p.find(m=>m.block)?.el||null)}return l.get(p)},a=[],h=(b,A)=>{let p=s(e,b),m=s(n,A),y=p&&m&&t(m)!==p?"transfer":"retained",R=a[a.length-1];R&&R.to===b&&R.target+R.to-R.from===A&&R.kind===y&&R.destination===m?R.to++:a.push({from:b,to:b+1,target:A,destination:m,kind:y})},f=0,u=0,g=!1;try{for(;f<e.text.length||u<n.text.length;){if(f<e.text.length&&u<n.text.length&&e.text[f]===n.text[u]){let R=e.atomAt.get(f),S=n.atomAt.get(u);if(!!R!=!!S||R&&t(S.el)!==R.el)return{status:"none"};h(f++,u++);continue}if(!c(e.text,f)&&!c(n.text,u))return{status:"none"};let b=f,A=u;for(;c(e.text,f);)f++;for(;c(n.text,u);)u++;let p=e.text.slice(b,f),m=n.text.slice(A,u);(p.includes(wt)||m.includes(wt))&&(g=!0);let y=0;for(;y<f-b&&y<u-A&&e.text[f-y-1]===n.text[u-y-1];)y++;for(let R=y;R>0;R--)h(f-R,u-R)}}catch(b){if(b===i)return{status:"fallback",reason:"work-limit"};throw b}return g?Dn({base:e,side:n,retained:a.filter(b=>b.kind==="retained"),transfers:a.filter(b=>b.kind==="transfer"),sideAtomKey:b=>t(b.el)||b.el,budget:o}):{status:"none"}}var ci=/\s/,gr=/\S/;function Mn(e,n,t,o,r,c,l=-1,i=-1){if(!e.length)return-1;r(o,e.length);let s=new Int32Array(e.length),a=0;for(let g=1;g<e.length;g++){for(r(o,1);a&&(r(o,1),e[a]!==e[g]);)a=s[a-1];r(o,1),e[a]===e[g]&&a++,s[g]=a}let h=-1,f=0,u=0;a=0;for(let g=0;g<n.length;g++){for(r(o,1);a&&(r(o,1),e[a]!==n[g]);)a=s[a-1];if(r(o,1),e[a]===n[g]&&a++,a!==e.length)continue;let b=g+1-e.length,A=g+1;for(a=s[a-1];f<t.length&&t[f].from<b;)r(o,1),f++;for(;u<t.length&&t[u].to<A;)r(o,1),u++;if(r(o,6),!(f===t.length||u===t.length||t[f].from!==b||t[u].to!==A||l>=0&&b<i&&A>l)){if(!c)return b;if(h>=0)return-1;h=b}}return h}function Wo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function Zr(e,n,t,o){let r=null;for(let l of n)if(o(t,1),!(l.source!==e.source||l.side!==e.side))for(let i of l.runs){if(o(t,1),i.source!==e.source)continue;let s=Math.max(e.from,i.from),a=Math.min(e.to,i.to);s>=a||(r||(o(t,e.to-e.from),r=new Uint8Array(e.to-e.from)),o(t,a-s),r.fill(1,s-e.from,a-e.from))}if(!r)return!1;o(t,e.to-e.from);let c=!1;for(let l=e.from;l<e.to;l++)if(gr.test(e.flat.text[l])){if(!r[l-e.from])return!1;c=!0}return c}function es({source:e,side:n,views:t,eligible:o,blocked:r,baseId:c,model:l,tokensOf:i,budget:s,charge:a}){let{V:h,A:f,idOf:u}=t[n],g=t[1-n];if(e.nodeType!==1||f.identical.has(e)||g.A.identical.has(e)||r.has(e)||!o(e))return null;let b=h.twin(e),A=g.V.twin(e);if(!b||!A||f.map.get(e)!==b||f.reverse.get(b)!==e||g.A.map.get(e)!==A||g.A.reverse.get(A)!==e||!h.here(b)||!g.V.here(A)||!o(b)||!o(A))return null;let p=c(e);if(p!==u(b)||p!==g.idOf(A))return null;let m=l(e,null,s),y=l(b,f,s),R=l(A,g.A,s);if(!Wo(m)||!Wo(y)||!Wo(R))return null;let S=m.flat.text,O=y.flat.text;if(a(s,S.length+O.length*3),!gr.test(O)||O.length>=S.length)return null;let M=S.startsWith(O),E=S.endsWith(O);if(M===E)return null;let N=M?O.length:0,L=M?S.length:S.length-O.length,j=N,F=L;for(;j<F&&(a(s,1),!!ci.test(S[j]));)j++;for(;F>j&&(a(s,1),!!ci.test(S[F-1]));)F--;if(j===F)return null;let W=i(m,s),C=!1,T=!1;for(let x of W)a(s,1),x.from===j&&(C=!0),x.to===F&&(T=!0);return!C||!T?null:{source:e,side:n,flat:m.flat,from:N,to:L}}function ai({base:e,views:n,side:t,attempt:o,eligible:r,blocked:c,baseId:l,model:i,tokensOf:s,certificates:a,charge:h,exhausted:f,limit:u}){if(u<=0)return null;let g=Kt(u),{V:b,A,idOf:p}=n[t],m=n[1-t],[y,R,S,O]=o,M=null;try{for(let E=y;E<=R;E++){h(g,1);let N=e[E];if(N.nodeType!==1||A.identical.has(N)||m.A.identical.has(N)||c.has(N)||!r(N))continue;let L=es({source:N,side:t,views:n,eligible:r,blocked:c,baseId:l,model:i,tokensOf:s,budget:g,charge:h});if(!L||Zr(L,a,g,h))continue;let{flat:j,from:F,to:W}=L;h(g,(W-F)*2);let C=j.text.slice(F,W).trim();for(let T=S;T<=O;T++){h(g,1);let x=b.units[T],z=b.baseOf(x);if(!z||z===N||z.nodeType!==1||x.nodeType!==1||z.parentNode!==N.parentNode||x.parentNode!==A.map.get(N).parentNode||A.map.get(z)!==x||A.reverse.get(x)!==z||c.has(z)||!r(z)||!r(x)||l(z)!==p(x))continue;let D=i(z,null,g),V=i(x,A,g);if(!Wo(D)||!Wo(V))continue;let Ee=D.flat.text,Me=V.flat.text;if(h(g,Ee.length),!gr.test(Ee)||Me.length<=Ee.length)continue;let De=s(V,g),re=Mn(Ee,Me,De,g,h,!0);if(!(re<0)&&!(Mn(C,Me,De,g,h,!1,re,re+Ee.length)<0)){(M||=[]).push(L);break}}}}catch(E){if(E!==f)throw E}return M}function fi(e,n,t,o,r,c,l){if(c==="both"||t.atoms.length||o.atoms.length||r.atoms.length)return c;let i=c==="remote";if(i?l.rss!==l.rse||l.lss===l.lse||l.local===l.base:l.lss!==l.lse||l.rss===l.rse||l.remote===l.base)return c;for(let s of e){if(s.source!==n||s.side!==(i?1:0)||s.flat.text!==t.text||s.flat.nodes.length!==t.nodes.length||l.be<=s.from||l.bs>=s.to)continue;let a=!0;for(let f=0;f<t.nodes.length;f++){let u=s.flat.nodes[f],g=t.nodes[f];if(u.node!==g.node||u.s!==g.s||u.e!==g.e){a=!1;break}}if(!a)continue;let h=!1;for(let f=l.bs;f<l.be;f++)if(gr.test(t.text[f])){if(f<s.from||f>=s.to){a=!1;break}h=!0}if(a&&h)return i?"local":"remote"}return c}var Bn="\uFFFC";var Oc={caret:0},wn=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(" ")),yi=new Set(["BR","WBR","IMG"]),ts=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 Un(e,n={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(n.ignored&&n.ignored(e)||yi.has(e.tagName))return!0;if(!wn.has(e.tagName))return!ts.has(e.tagName);if(n.remoteWins&&n.remoteWins(e))return!1;let t=n.inlineCache&&n.inlineCache.get(e);if(t!==void 0)return t;let o=!0;for(let r of e.childNodes)if(!Un(r,n)){o=!1;break}return n.inlineCache&&n.inlineCache.set(e,o),o}function Mc(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function en(e,n={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,c)=>{for(let l of r){if(l.nodeType===3){let f=l.nodeValue;if(!f)continue;t.nodes.push({node:l,s:t.text.length,e:t.text.length+f.length}),t.text+=f;for(let u=0;u<f.length;u++)t.stackAt.push(c);continue}if(l.nodeType!==1)continue;if(n.ignored&&n.ignored(l)){t.pins.push({el:l,i:t.text.length});continue}if(n.skip&&n.skip.has(l))continue;let i=n.via&&n.via(l)||l;i!==l&&(t.via||(t.via=new Map)).set(i,l);let s=l.tagName;if(n.blocks&&n.blocks.has(l)){t.text.length&&t.text[t.text.length-1]!==wt&&(t.stackAt.push(c),t.text+=wt);let f={el:l,tag:s,from:t.text.length,to:-1,depth:c.length,block:!0};t.marks.push(f);let u=c.concat([f]);o(i.childNodes,u),t.stackAt.push(u),t.text+=wt,f.to=t.text.length;continue}let a=wn.has(s)&&Mc(i);if(yi.has(s)||!wn.has(s)||n.remoteWins&&n.remoteWins(l)||n.atomize&&n.atomize(l)||a){t.atoms.push({i:t.text.length,el:l,key:a?s+":empty":s,stack:c}),t.stackAt.push(c),t.text+=Bn;continue}let h={el:l,tag:s,from:t.text.length,to:-1,depth:c.length};t.marks.push(h),o(i.childNodes,c.concat([h])),h.to=t.text.length}};if(o(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&wr(t).trim()===""){let r=t.atoms[0];t.placeholder=r.el,t.text=t.text.slice(0,r.i)+t.text.slice(r.i+1),t.stackAt.splice(r.i,1);for(let c of t.nodes)c.s>r.i&&(c.s--,c.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(r=>[r.i,r])),t}function Ec(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function Ic(e){let n="<"+e.tagName.toLowerCase();for(let t of e.attributes)n+=` ${t.name}="${t.value.replace(/"/g,""")}"`;return n+">"}function ko(e,n,t){let o="",r=[];for(let c=n;c<t;c++){let l=e.stackAt[c],i=0;for(;i<r.length&&i<l.length&&r[i]===l[i];)i++;for(;r.length>i;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<l.length;){let a=l[r.length];o+=Ic(a.el),r.push(a)}let s=e.atomAt.get(c);o+=s?s.el.outerHTML:e.text[c]===wt?"":Ec(e.text[c])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function Cc(e,n){let t=[...e.el.attributes].filter(o=>!n(e.el,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tag+"|"+t}function wi(e,n){let t=[...e.attributes].filter(o=>!n(e,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function ui(e,n=()=>!1){let t=new Map,o=c=>{let l=t.get(c);return l===void 0&&(l="{"+c.map(i=>Cc(i,n)).sort().join(",")+"}",t.set(c,l)),l},r="";for(let c=0;c<e.text.length;c++){let l=e.atomAt.get(c);r+=(l?"["+wi(l.el,n)+"]":e.text[c])+o(e.stackAt[c])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function xo(e,n,t,o=r=>r.key){let r=[],c=e.text,l=0,i=s=>{if(s<=l)return;let a=c.slice(l,s);if(t)for(let h of a.split(/(?<=\n)/))r.push({k:h,raw:h,len:h.length});else for(let h of ln(a,n))r.push(h)};for(let s of e.atoms)i(s.i),r.push({k:"\0"+o(s),raw:Bn,len:1,atom:!0}),l=s.i+1;return i(c.length),r}function wr(e){if(!e.atoms.length)return e.text;let n="",t=0;for(let o of e.atoms)n+=e.text.slice(t,o.i),t=o.i+1;return n+e.text.slice(t)}var To=e=>{let n=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)n[t+1]=n[t]+e[t].len;return n};function br(e,n,t,o){let r=To(n),c=To(t),l=[],i=0,s=0;for(let h of o.hunks){s+=h.bs-i;let f=s+h.toks.length;l.push({bs:r[h.bs],be:r[h.be],ss:c[s],se:c[f],text:e.text.slice(c[s],c[f]),toks:h.toks,lead:!!h.lead}),s=f,i=h.be}let a=new Map;for(let h of o.cosmetic)a.set(h.bi,h.tok.raw);return{hunks:l,respell:a}}function di(e,n,t){let o=l=>l===wt||/\s/.test(l),r=l=>l.replace(/[\u001E\s]/g,""),c=[];for(let l of e){let i=n.slice(l.bs,l.be),s=t.slice(l.ss,l.se);if(!i.includes(wt)&&!s.includes(wt)||i.includes(Bn)||s.includes(Bn)||r(i)!==r(s)){c.push(l);continue}let a=0,h=0;for(;;){let f=a,u=h;for(;f<i.length&&o(i[f]);)f++;for(;u<s.length&&o(s[u]);)u++;let g=a,b=h;for(;g<f&&b<u&&i[g]===s[b];)g++,b++;let A=f,p=u;for(;A>g&&p>b&&i[A-1]===s[p-1];)A--,p--;if(A>g||p>b){let m=s.slice(b,p);c.push({bs:l.bs+g,be:l.bs+A,ss:l.ss+b,se:l.ss+p,text:m,toks:[...m].map(y=>({k:y,raw:y,len:1})),lead:l.lead})}if(f>=i.length)break;a=f+1,h=u+1}}return c}function hi(e,n,t){let o=new Int32Array(n+1).fill(-1),r=new Int32Array(t+1).fill(-1),c=0,l=0,i=s=>{for(;c<s;)o[c]=l,r[l]=c,c++,l++};for(let s of e)i(s.bs),c=s.be,l=s.se;return i(n),o[n]=l,r[l]=n,{bTo:o,toB:r}}function pi(e,n,t){let o=[],r=0,c=0,l=(i,s)=>{if(r===i&&c===s)return;let a=n.text.slice(c,s);o.push({bs:r,be:i,ss:c,se:s,text:a,toks:ln(a,yn(a)),lead:!1})};for(let i of t.runs)l(i.from,i.target),r=i.to,c=i.target+i.to-i.from;return l(e.text.length,n.text.length),{hunks:o,respell:new Map}}function mi(e,n,t,o){let r=To(n),c=To(t),l=(s,a)=>{let h=0,f=s.length;for(;h<f;){let u=h+f>>>1;s[u]<a?h=u+1:f=u}return s[h]===a?h:-1};for(let s of e.hunks)if(l(r,s.bs)<0||l(r,s.be)<0)return null;if(e.hunks.some(s=>l(c,s.ss)<0||l(c,s.se)<0)){if(!o)return null;let s=[];for(let u of e.hunks)s.push(u.ss,u.se);let a=[],h=0,f=0;for(let u of t){let g=f+u.len;for(;h<s.length&&s[h]<=f;)h++;let b=f;for(;h<s.length&&s[h]<g;){let A=s[h++];if(A>b){let p=u.raw.slice(b-f,A-f);a.push(...ln(p,yn(p))),b=A}}if(b===f)a.push(u);else{let A=u.raw.slice(b-f);a.push(...ln(A,yn(A)))}f=g}t=a,c=To(t)}let i=[];for(let s of e.hunks){let a=l(r,s.bs),h=l(r,s.be),f=l(c,s.ss),u=l(c,s.se);if(a<0||h<0||f<0||u<0)return null;i.push({bs:a,be:h,toks:t.slice(f,u),gap:[],group:i.length})}return{parts:i,cosmeticEq:[],tokens:t}}function ns(e,n,t,o={},r=null){return xi(e,n,t,o.base,o.local,o.remote,r,{})}function xi(e,n,t,o,r,c,l,i){let s=yn(wr(e),wr(n),wr(t)),a=xo(e,s,!1,o),h=xo(n,s,!1,r),f=xo(t,s,!1,c),u=a.length>2e4||h.length>2e4||f.length>2e4;u&&(a=xo(e,s,!0,o),h=xo(n,s,!0,r),f=xo(t,s,!0,c));let g=l?.local?pi(e,n,l.local):null,b=l?.remote?pi(e,t,l.remote):null,A=g?mi(g,a,h,!u):Kn(a,h),p=b?mi(b,a,f,!u):Kn(a,f);g&&A&&(h=A.tokens),b&&p&&(f=p.tokens);let m,y;if(A&&p){let R=Xr(A,p,a);m=br(n,a,h,{hunks:R.lh,cosmetic:R.cosL}),y=br(t,a,f,{hunks:R.rh,cosmetic:R.cosR})}else m=g||br(n,a,h,A),y=b||br(t,a,f,p);return m.hunks=di(m.hunks,e.text,n.text),y.hunks=di(y.hunks,e.text,t.text),i.base=e,i.local=n,i.remote=t,i.lines=u,i.baseTokens=a,i.localEdits=m,i.remoteEdits=y,i.localMap=hi(m.hunks,e.text.length,n.text.length),i.remoteMap=hi(y.hunks,e.text.length,t.text.length),i.full=null,i}function gi(e,n){if(e.size!==n.size)return!1;for(let t of e)if(!n.has(t))return!1;return!0}var Ao=/\s/;function yr(e,n,t){for(let o=n;o<t;o++)if(!Ao.test(e[o]))return!1;return!0}function Rc(e,n,t){let o=e.cache[t]||(e.cache[t]=new Map);if(o.has(n))return o.get(n);let r=t===0?"local":"remote",c=t===0?"remote":"local",l=n.baseMark,i=n[c+"Mark"],s=!n.block&&!n[r]&&!!i&&l.to>l.from;if(s){let a=t===0?e.ML:e.MR,h=t===0?e.MR:e.ML,f=t===0?e.fr:e.fl,u=!1;for(let g=l.from;g<l.to;g++){if(a.bTo[g]>=0){s=!1;break}h.bTo[g]<0&&!Ao.test(e.fb.text[g])&&(u=!0)}if(s&&!u){for(let g=i.from;g<i.to;g++)if(h.toB[g]<0&&!Ao.test(f.text[g])){u=!0;break}}s&&=u}return o.set(n,s),s}function bi(e,n,t,o,r,c,l,i,s){let a=i===0?e.fl:e.fr,h=null;for(let f=t;f<o;f++){let u=n[f];if(!yr(a.text,u.ss,u.se))return null;if(yr(e.fb.text,u.bs,u.be)){if(u.bs<u.be&&u.ss<u.se||Ao.test(e.fb.text[u.bs-1]||"")||Ao.test(e.fb.text[u.be]||""))continue;return null}let g=!1;for(let b=u.bs;b<u.be;b++){if(Ao.test(e.fb.text[b]))continue;let A=null;for(let p of e.fb.stackAt[b]){let m=e.byEl.get(p.el);if(m&&Rc(e,m,i)){A=m;break}}if(!A)return null;(h||(h=new Set)).add(A),g=!0}if(!g)return null}if(!h){if((i===0?"local":"remote")!==s)return null;let f=i===0?e.fr:e.fl,u=!1;for(let g=c;g<l;g++){let b=r[g];if(!yr(e.fb.text,b.bs,b.be))return null;yr(f.text,b.ss,b.se)||(u=!0)}if(!u)return null}return h||0}function so(e){let{out:n,policy:t="remote",L:o,R:r}=e,c=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,i=e.conflicts||[],s=e.decisions||[],a=i.length,h=e.conflict||(d=>i.push(d)),f={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},u=[],g=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),b={base:null,local:null,remote:null};if(!e.prepared&&g&&e.moveIn){let d=Te=>Ve=>Te.some(Re=>Re===Ve||Re.nodeType===1&&Re.contains(Ve)),I=d(e.local),U=d(e.remote),H=d(e.base),X=new Set,de=Te=>{if(!wn.has(Te.tagName))return;let Ve=o.map.get(Te),Re=r.map.get(Te);(Ve&&!I(Ve)||Re&&!U(Re))&&X.add(Te);for(let Fe of Te.children)de(Fe)};for(let Te of e.base)Te.nodeType===1&&de(Te);let we=Te=>Ve=>{if(!wn.has(Ve.tagName))return!1;let Re=Te.reverse.get(Ve);return!!Re&&(X.has(Re)||!H(Re))};X.size&&(b.base=Te=>X.has(Te)),b.local=we(o),b.remote=we(r)}let A={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&g&&e.moveIn){let d=H=>X=>H.some(de=>de===X||de.nodeType===1&&de.contains(X)),I=d(e.local),U=d(e.remote);for(let H of en(e.base,{...e,atomize:b.base}).atoms){let X=o.map.get(H.el),de=r.map.get(H.el),we=!!X&&!I(X),Te=!!de&&!U(de);!we&&!Te||(we&&e.movePlanned?.(H.el,"local",X,null),Te&&e.movePlanned?.(H.el,"remote",de,null),A.base.add(H.el),X&&!we&&A.local.add(X),de&&!Te&&A.remote.add(de),I(H.el)&&A.local.add(H.el),U(H.el)&&A.remote.add(H.el))}}let p=e.prepared?.base||en(e.base,{...e,atomize:b.base,skip:A.base}),m=e.prepared?.local||en(e.local,{...e,atomize:b.local,skip:A.local}),y=e.prepared?.remote||en(e.remote,{...e,atomize:b.remote,skip:A.remote}),R=new Map(p.atoms.map(d=>[d.el,d])),S={},O=d=>e.prepared?e.prepared.full?.(d)||null:A[d].size?(S[d]||(S[d]=en(e[d],{...e,atomize:b[d]})),S[d]):null,M=(d,I,U)=>{I.namespaceURI?d.setAttributeNS(I.namespaceURI,I.name,U):d.setAttribute(I.name,U)},E=(d,I,U,H)=>{if(!I&&(!U||!H)){for(let de of(U||H).attributes)M(d,de,de.value);return}let X=new Map;for(let de of[I,U,H])if(de)for(let we of de.attributes)X.set(we.name,we);for(let[de,we]of X){let Te=I?I.getAttribute(de):null,Ve=U?U.getAttribute(de):Te,Re=H?H.getAttribute(de):Te,Fe;Ve===Re?Fe=Ve:Ve===Te?(Fe=Re,s.push({kind:"attr",el:d,name:de,source:"remote"})):Re===Te?(Fe=Ve,s.push({kind:"attr",el:d,name:de,source:"local"})):(Fe=t==="local"?Ve:Re,h({kind:"attr",el:d,name:de,base:Te,local:Ve,remote:Re,resolved:Fe},{el:d,sample:we}),s.push({kind:"attr",el:d,name:de,source:"both"})),Fe!=null&&M(d,we,Fe)}},N=(d,I,U,H)=>d&&e.mergeAttrs?e.mergeAttrs(d,I,U,H):E(H,d,I,U),L=e.mergeElement||((d,I,U)=>{let H=n.createElement(d.tagName);N(d,I,U,H);let X=I||d,de=U||d,we=t==="local"?X.isEqualNode(d)?de:X:de.isEqualNode(d)?X:de;for(let Te of we.childNodes)H.appendChild(n.importNode(Te,!0));return c.set(H,{base:d,local:I,remote:U}),H}),j=e.cloneUnit||((d,I)=>{let U=n.importNode(d,!0);return c.set(U,{base:null,local:I==="local"?d:null,remote:I==="remote"?d:null}),U}),F=e.atomKey||(d=>wi(d,()=>!1)),W=(d,I)=>{let U=new Map;for(let H of d.atoms)if(e.remoteWins&&e.remoteWins(H.el)&&wn.has(H.el.tagName))U.set(H,"w"+H.el.tagName+"#"+(H.el.id||""));else if(!g)U.set(H,H.key);else if(d===p)U.set(H,"="+F(H.el));else{let X=I.reverse.get(H.el),de=X?R.get(X):null;de?U.set(H,"="+F(de.el)):X?U.set(H,"m"+F(H.el)):U.set(H,"="+F(H.el))}return H=>U.get(H)},C=W(p,null),T=W(m,o),x=W(y,r),z=e.certifiedOrigins?e.certifiedOrigins(p,m,y,C,T,x):null;if(z?.fallback)return null;if(!z&&!e.prepared&&e.blocks){let d=Kt(),I=Qr({base:p,side:m,baseOf:H=>o?.reverse?.get(H)||null,budget:d}),U=Qr({base:p,side:y,baseOf:H=>r?.reverse?.get(H)||null,budget:d});(I.status==="ready"||U.status==="ready")&&(z={local:I.status==="ready"?I:null,remote:U.status==="ready"?U:null})}let D=e.prepared||xi(p,m,y,C,T,x,z,f),V=D.lines,Ee=D.baseTokens,Me=D.localEdits,De=D.remoteEdits,re=D.localMap,Se=D.remoteMap,qe=p.text.length,ve=d=>new Map(d.atoms.map(I=>[I.el,I])),w=ve(m),K=ve(y),ne=(d,I,U)=>{let H=new Set;if(!g)return H;for(let X of d.atoms){let de=R.get(I.reverse.get(X.el));de&&U.bTo[de.i]<0&&H.add(de)}return H},ee=ne(m,o,re),Pe=ne(y,r,Se),_e=d=>!Un(d,{...e,remoteWins:null}),Ae=new Set;if(g)for(let d of p.atoms){if(!_e(d.el))continue;let I=o.map.get(d.el)||null,U=r.map.get(d.el)||null,H=I&&!U?I:U&&!I?U:null;H&&(w.has(H)||K.has(H))&&!H.isEqualNode(d.el)&&Ae.add(d)}let ot=1,Qe=(d,I)=>({id:ot++,tag:d,base:null,local:null,remote:null,rank:I}),Ze=new Map,Xe=[];for(let d of p.marks){let I=Qe(d.tag,d.depth);I.block=!!d.block,I.base=d.el,I.baseMark=d,Ze.set(d.el,I),Xe.push(I)}let yt=(d,I)=>{let U=-1,H=-1;for(let X=d.from;X<d.to;X++){let de=I[X];de>=0&&(U<0&&(U=de),H=de+1)}return U<0?null:[U,H]},dt=(d,I,U,H)=>{for(let X of d.marks){let de=U?U.reverse.get(X.el):null;de&&U.identical.has(de)&&U.pairIdenticalChildren&&U.pairIdenticalChildren(de);let we=de?Ze.get(de):null;if(we&&we[I]&&(we=null),!we){let Te=yt(X,H),Ve=0;if(Te)for(let Re of Xe){if(Re.tag!==X.tag||Re[I]||!!Re.block!=!!X.block)continue;let Fe=Math.min(Te[1],Re.baseMark.to)-Math.max(Te[0],Re.baseMark.from);(Fe>Ve||Fe===Ve&&Fe>0&&Math.abs(Re.rank-X.depth)<Math.abs(we.rank-X.depth))&&(we=Re,Ve=Fe)}}we||(we=Qe(X.tag,X.depth),we.block=!!X.block,we.new=I),we[I]=X.el,we[I+"Mark"]=X,Ze.set(X.el,we)}};dt(m,"local",o,re.toB),dt(y,"remote",r,Se.toB);let gt=d=>d.merged||d,qt=d=>{let I=new Set;for(let U of d)U.block||I.add(Ze.get(U.el));return I},$t=new Map,Ht=d=>{let I=$t.get(d);return I||(I=qt(d),$t.set(d,I)),I},jt=(d,I)=>{let U=[],H=null;for(let X=0;X<qe;X++){let de=I[X];if(de<0){H&&U.push(H),H=null;continue}let we=Ht(p.stackAt[X]),Te=Ht(d.stackAt[de]),Ve=new Set,Re=new Set;for(let Fe of Te)we.has(Fe)||Ve.add(Fe);for(let Fe of we)Te.has(Fe)||Re.add(Fe);if(!Ve.size&&!Re.size){H&&U.push(H),H=null;continue}if(H&&gi(H.added,Ve)&&gi(H.removed,Re)){H.be=X+1;continue}H&&U.push(H),H={bs:X,be:X+1,added:Ve,removed:Re}}return H&&U.push(H),U},an=jt(m,re.bTo),_t=jt(y,Se.bTo),zt=d=>d.be>d.bs?[d.bs,d.be-1]:[d.bs-1,d.bs],_=(d,I)=>{if(qe===0)return null;let[U,H]=zt(d);for(let X of I){if(X.be<=U)continue;if(X.bs>H)break;let de=X.bs<=U&&H<X.be;return de&&d.text===""&&X.bs===d.bs&&X.be===d.be?"straddle":de?X:d.be>d.bs?"straddle":null}return null},ie=d=>d.bs===d.be,me=(d,I,U=null)=>{let H=!1;for(let X=d.bs;X<d.be;X++){let de=p.text[X];if(de===wt)H=!0;else if(!/\s/.test(de))return!1}for(let X=d.ss;X<d.se;X++){let de=I.text[X];if(de===wt)H=!0;else if(!/\s/.test(de)){let we=U&&e.scopeUnits&&ie(d)&&I.atomAt.get(X);if(!we||!_e(we.el)||U.ss!==U.se||U.bs>=U.be)return!1;for(let Ve=U.bs;Ve<U.be;Ve++)if(!/\s/.test(p.text[Ve]))return!1;let Te=I===m?1:2;if(!e.scopeUnits[Te].includes(we.el)||(Te===1?o:r)?.reverse.has(we.el))return!1;H=!0}}return H},pe=(d,I)=>d.bs<I.be&&I.bs<d.be,ke=(d,I)=>d.bs<=I.be&&I.bs<=d.be&&ie(d)!==ie(I),v=(d,I)=>p.text.slice(d.bs,d.be).includes(wt)||I.text.slice(d.ss,d.se).includes(wt),P=d=>{if(ie(d))return!1;let I=d.bs,U=d.be;for(;I>0&&/\s/.test(p.text[I-1]);)I--;for(;U<p.text.length&&/\s/.test(p.text[U]);)U++;return(I===0||p.text[I-1]===wt)&&(U===p.text.length||p.text[U]===wt)},Y=(d,I)=>!v(d,I)&&!P(d),J=(d,I)=>pe(d,I)||ke(d,I)&&!(d.transferIn||d.transferOut||I.transferIn||I.transferOut)&&!(me(d,m,I)&&Y(I,y))&&!(me(I,y,d)&&Y(d,m)),oe=(d,I)=>{if(d.bs!==I.bs||d.be!==I.be||d.toks.length!==I.toks.length)return!1;let U=d.ss,H=I.ss;for(let X=0;X<d.toks.length;X++){let de=d.toks[X],we=I.toks[X];if(de.k!==we.k||de.atom&&!m.atomAt.get(U).el.isEqualNode(y.atomAt.get(H).el))return!1;U+=de.len,H+=we.len}return!0},je=(d,I,U,H)=>{for(let X of p.atoms){if(X.i<d.bs||X.i>=d.be||H.has(X)||Ae.has(X))continue;let de=I.bTo[X.i],we=de>=0?U.atomAt.get(de):null;if(we&&!we.el.isEqualNode(X.el))return!0}return!1},Z=[],Oe=null,He=null,Ie=Me.hunks,ge=De.hunks,B=0,G=0,ue=0,he=0,ce=0,xe=d=>{d>ue&&(Z.push({src:"base",from:ue,to:d,dL:he,dR:ce}),ue=d)};for(;B<Ie.length||G<ge.length;){let d=Ie[B],I=ge[G],U=!!d&&(!I||d.bs<I.bs||d.bs===I.bs&&d.be<=I.be&&!I.lead);if(d&&I&&d.bs===I.bs&&ie(d)&&ie(I)){let Ft=me(d,m),Bo=me(I,y);Ft!==Bo&&(U=Bo)}let H=U?d:I,X=U?I:d,de=!!X&&oe(d,I),we=!!X&&(U?!!Ie[B+1]&&oe(Ie[B+1],I):!!ge[G+1]&&oe(d,ge[G+1])),Te=!!X&&!de&&!we&&(qe===0||J(d,I)),Ve=Te,Re=_(H,U?_t:an);if(Re==="straddle"&&(Ve=!0),!Ve&&H.be>H.bs&&(Ve=je(H,U?Se:re,U?y:m,U?ee:Pe)),!Ve&&de){xe(H.bs),Z.push({src:"both",lfrom:d.ss,rfrom:I.ss,len:H.text.length,owner:d.owner||I.owner||null,transfer:d.transferIn||I.transferIn||null}),ue=H.be,he+=H.text.length-(H.be-H.bs),ce+=H.text.length-(H.be-H.bs),B++,G++;continue}if(!Ve){xe(H.bs),Z.push({src:U?"local":"remote",from:H.ss,to:H.se,inherit:Re&&Re!=="straddle"?Re:null,owner:H.owner||null,transfer:H.transferIn||null}),ue=H.be,U?(he+=H.text.length-(H.be-H.bs),B++):(ce+=H.text.length-(H.be-H.bs),G++);continue}let Fe=H.bs,ht=H.be,lt=B,ft=G,Ut=Ft=>Ft.bs<ht&&Ft.be>Fe||ie(Ft)&&(Ft.bs===Fe||Ft.bs===ht);U?lt++:ft++,Te&&(Fe=Math.min(Fe,X.bs),ht=Math.max(ht,X.be),U?ft++:lt++);let Pt=!0;for(;Pt;){for(Pt=!1;lt<Ie.length&&Ut(Ie[lt]);)Fe=Math.min(Fe,Ie[lt].bs),ht=Math.max(ht,Ie[lt].be),lt++,Pt=!0;for(;ft<ge.length&&Ut(ge[ft]);)Fe=Math.min(Fe,ge[ft].bs),ht=Math.max(ht,ge[ft].be),ft++,Pt=!0}let dn=Fe+he,rn=Fe+ce,gn=ht-Fe,Tn=ht-Fe;for(let Ft=B;Ft<lt;Ft++)gn+=Ie[Ft].text.length-(Ie[Ft].be-Ie[Ft].bs);for(let Ft=G;Ft<ft;Ft++)Tn+=ge[Ft].text.length-(ge[Ft].be-ge[Ft].bs);let Pn=dn+gn,jn=rn+Tn;if(xe(Fe),B<lt&&G<ft&&!z&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!p.atoms.length&&!m.atoms.length&&!y.atoms.length&&!p.pins.length&&!m.pins.length&&!y.pins.length){Oe||={fb:p,fl:m,fr:y,ML:re,MR:Se,byEl:Ze,cache:[null,null]};let Ft=bi(Oe,Ie,B,lt,ge,G,ft,0,t),Bo=bi(Oe,ge,G,ft,Ie,B,lt,1,t);if(Ft===null!=(Bo===null)){let Cr=Ft!==null,Gs=Cr?Ft:Bo;if(Gs){He||=new Map;for(let Bl of Gs)He.set(Bl,Cr?"local":"remote")}Z.push(Cr?{src:"remote",from:rn,to:jn}:{src:"local",from:dn,to:Pn}),ue=ht,he+=gn-(ht-Fe),ce+=Tn-(ht-Fe),B=lt,G=ft;continue}}let Zt={kind:"text",node:e.node||null,base:ko(p,Fe,ht),local:ko(m,dn,Pn),remote:ko(y,rn,jn),resolved:null,range:null,bs:Fe,be:ht,lss:dn,lse:Pn,rss:rn,rse:jn},no=e.sourceRetentions?fi(e.sourceRetentions,e.scope?.base,p,m,y,t,Zt):t;Zt.resolved=no==="local"?Zt.local:no==="remote"?Zt.remote:Zt.local+Zt.remote,no!=="remote"&&Z.push({src:"local",from:dn,to:Pn,conflict:Zt}),no!=="local"&&Z.push({src:"remote",from:rn,to:jn,conflict:Zt});let oo={site:"inline",policy:no,fb:p,fl:m,fr:y,scope:e.scope||null,synthetic:!!e.synthetic,full:O,merged:f};u.push(oo),h(Zt,oo),ue=ht,he+=gn-(ht-Fe),ce+=Tn-(ht-Fe),B=lt,G=ft}xe(qe);let te=p.text,q=[];if(Me.respell.size||De.respell.size){let d=To(Ee),I=[];for(let U=0;U<Ee.length;U++){let H=Ee[U].raw,X=Me.respell.get(U)??H,de=De.respell.get(U)??H;(X!==H||de!==H)&&q.push([d[U],X!==H&&de!==H?"both":X!==H?"local":"remote"]),I.push(X===de?X:X===H?de:de===H||t==="local"?X:de)}te=I.join("")}let ae="",Ce=[],Le=[],We=[],Ne=[];for(let d of Z){let I=ae.length;if(d.src==="base"){for(let U=d.from;U<d.to;U++)Ce.push(U),Le.push(e.nativeTransfers?re.bTo[U]:U+d.dL),We.push(e.nativeTransfers?Se.bTo[U]:U+d.dR),Ne.push(d);ae+=te.slice(d.from,d.to)}else if(d.src==="both"){for(let U=0;U<d.len;U++){let H=d.transfer&&(d.transfer.side==="remote"?d.rfrom+U:d.lfrom+U);Ce.push(d.transfer&&H>=d.transfer.ss&&H<d.transfer.se?d.transfer.bs+H-d.transfer.ss:-1),Le.push(d.lfrom+U),We.push(d.rfrom+U),Ne.push(d)}ae+=m.text.slice(d.lfrom,d.lfrom+d.len)}else{let U=d.src==="local"?m:y,H=d.transfer&&e.nativeTransfers.byOrigin[d.src==="local"?"remote":"local"].get(d.transfer.key);for(let X=d.from;X<d.to;X++){let de=d.transfer&&X>=d.transfer.ss&&X<d.transfer.se?d.transfer.bs+X-d.transfer.ss:-1,we=de>=0&&(!H||H.destination===d.owner)?(d.src==="local"?Se:re).bTo[de]:-1;Ce.push(de),Le.push(d.src==="local"?X:we),We.push(d.src==="remote"?X:we),Ne.push(d)}ae+=U.text.slice(d.from,d.to)}d.ms=I,d.me=ae.length,d.conflict&&(d.conflict.range||(d.conflict.range=[I,I]),d.conflict.range[1]=ae.length)}let ze=ae.length,tt=new Int32Array(qe+1).fill(-1),k=new Int32Array(m.text.length+1).fill(-1),$=new Int32Array(y.text.length+1).fill(-1);for(let d=0;d<ze;d++)Ce[d]>=0&&(tt[Ce[d]]=d),Le[d]>=0&&(k[Le[d]]=d),We[d]>=0&&($[We[d]]=d);let Q=(d,I)=>{let U=-1,H=-1;for(let X=d.from;X<d.to;X++){let de=I[X];de>=0&&(U<0&&(U=de),H=de+1)}return U<0?null:[U,H]},be=[],fe=[];for(let d of new Set(Ze.values()))d.new==="local"?be.push(d):d.new==="remote"&&fe.push(d);let se=(d,I)=>{d.remote=I.remote,d.remoteMark=I.remoteMark,d.new="both",I.merged=d,Ze.set(I.remote,d)};if(be.length&&fe.length){let d=e.idOf;for(let I of be){let U=d?d.local(I.local):null;if(!U)continue;let H=fe.find(X=>!X.merged&&X.tag===I.tag&&!!X.block==!!I.block&&d.remote(X.remote)===U);H&&se(I,H)}for(let I of be){if(I.remote)continue;let U=Q(I.localMark,k);if(U)for(let H of fe){if(H.merged||H.tag!==I.tag||!!H.block!=!!I.block)continue;let X=Q(H.remoteMark,$);if(X&&Math.min(U[1],X[1])-Math.max(U[0],X[0])>0){se(I,H);break}}}}$t.clear();let le=d=>{for(let I of d)if(I.block)return gt(Ze.get(I.el));return null},Be=p.marks.some(d=>d.block)||m.marks.some(d=>d.block)||y.marks.some(d=>d.block),Ke=new Array(ze).fill(null),Ue=new Set;if(e.nativeTransfers)for(let d=0;d<ze;d++){let I=Ne[d].owner;Ke[d]=I?gt(Ze.get(I)):Ce[d]>=0?le(p.stackAt[Ce[d]]):null}else if(Be){let d=(Re,Fe,ht)=>{let lt=new Set([Re,Fe,ht]);lt.delete(null);let ft=[];for(let Pt of lt){let dn=Pt===Re,rn=Pt===Fe,gn=Pt===ht;(rn===gn?rn:rn===dn?gn:rn)&&ft.push(Pt)}if(ft.length<=1)return ft[0]||null;let Ut=t==="local"?Fe:ht;return ft.includes(Ut)?Ut:ft[0]},I=(Re,Fe)=>Fe>=0?le(Re.stackAt[Fe]):null,U=new Map;for(let Re=0;Re<ze;Re++){if(ae[Re]!==wt)continue;let Fe=Ce[Re]>=0?I(p,Ce[Re]):null,ht=I(m,Le[Re]),lt=I(y,We[Re]);U.set(Re,[Fe,Ce[Re]>=0?d(Fe,ht,lt):ht||lt])}let H=new Set([...U.values()].map(Re=>Re[1])),X=Re=>Re!==wt&&Re!==Bn&&!/\s/.test(Re),de=(Re,Fe)=>{let ht=Re;for(;ht<Fe&&!X(ae[ht]);)ht++;return ht<Fe&&Ce[ht]>=0?I(p,Ce[ht]):null},we=new Map,Te=0;for(let Re=0;Re<ze;Re++){if(ae[Re]!==wt)continue;let[Fe,ht]=U.get(Re),lt=de(Te,Re),ft=ht,Ut=we.get(ft)===ft&<===ft;ft&&we.has(ft)&&!Ut&&Fe&&!we.has(Fe)&&!H.has(Fe)&&(ft=Fe),ft&&!we.has(ft)&&we.set(ft,lt);for(let Pt=Te;Pt<=Re;Pt++)Ke[Pt]=ft;Te=Re+1}let Ve=Re=>{for(let Fe=0;Fe<Re.text.length;Fe++)if(X(Re.text[Fe])&&!I(Re,Fe))return!0;return!1};if(!Ve(p)&&!Ve(m)&&!Ve(y)){let Re=[],Fe=0;for(let lt=0;lt<ze;lt++)(ae[lt]===wt||lt===ze-1)&&(Re.push([Fe,lt]),Fe=lt+1);let ht=new Set(Ke);for(let lt=0;lt<Re.length;lt++){let[ft,Ut]=Re[lt];if(Ke[Ut])continue;let Pt=ft;for(;Pt<=Ut&&!X(ae[Pt]);)Pt++;if(Pt>Ut)continue;let dn=I(p,Ce[Pt]),rn=I(m,Le[Pt]),gn=I(y,We[Pt]),Tn=d(dn,rn,gn)||rn||gn||dn;if(Tn&&!ht.has(Tn)){ht.add(Tn);for(let Zt=ft;Zt<=Ut;Zt++)Ke[Zt]=Tn;continue}let Pn=lt>0&&Ke[Re[lt-1][1]],jn=lt+1<Re.length&&Ke[Re[lt+1][1]];if(Pn)Ue.add(Re[lt-1][1]);else if(jn&&ae[Ut]===wt)Ue.add(Ut);else continue;for(let Zt=ft;Zt<=Ut;Zt++)Ke[Zt]=Pn||jn}}}let $e=new Map,Ge=d=>{let I=$e.get(d);if(I)return I;I=[1/0,-1/0];for(let[U,H]of[[d.baseMark,tt],[d.localMark,k],[d.remoteMark,$]]){let X=U&&Q(U,H);X&&(I[0]=Math.min(I[0],X[0]),I[1]=Math.max(I[1],X[1]))}return $e.set(d,I),I},et=(d,I,U)=>{let H=-1,X=-1;for(let de=0;de<d.length;de++){let we=Ze.get(d[de].el);we===I&&(H=de),we===U&&(X=de)}return H>=0&&X>=0?H-X:0},Ot=(d,I)=>[...d].sort((U,H)=>{for(let we of I){let Te=et(we,U,H);if(Te)return Te}let X=Ge(U),de=Ge(H);return X[0]-de[0]||de[1]-X[1]||U.rank-H.rank||U.id-H.id}),xt=new Map,Jt=new Map,Mt=e.nativeTransfers?[]:null,pt=d=>{if(Mt)return Mt;let I=Ce[d],U=Le[d],H=We[d],X=Ne[d];if(I>=0){let lt=p.stackAt[I],ft=m.stackAt[U],Ut=y.stackAt[H],Pt=xt.get(lt);Pt||xt.set(lt,Pt=new Map);let dn=Pt.get(ft);dn||Pt.set(ft,dn=new Map);let rn=dn.get(Ut);if(rn)return rn;let gn=Ht(lt),Tn=Ht(ft),Pn=Ht(Ut),jn=new Set;for(let Zt of new Set([...gn,...Tn,...Pn])){let no=gn.has(Zt),oo=Tn.has(Zt),Ft=Pn.has(Zt);(oo===Ft?oo:oo===no?Ft:oo)&&jn.add(Zt)}return rn=Ot(jn,[ft,Ut,lt]),dn.set(Ut,rn),rn}if(X.src==="both"){let lt=m.stackAt[U],ft=y.stackAt[H];return Ot(new Set([...Ht(lt),...Ht(ft)]),[lt,ft])}let we=(X.src==="local"?m:y).stackAt[X.src==="local"?U:H];if(!X.inherit)return Ot(Ht(we),[we]);let Te=Jt.get(X);Te||Jt.set(X,Te=new Map);let Ve=Te.get(we);if(Ve)return Ve;let Re=new Set(Ht(we));for(let lt of X.inherit.added)Re.add(gt(lt));for(let lt of X.inherit.removed)Re.delete(gt(lt));let Fe=X.src==="local"?y:m,ht=(X.src==="local"?Se.bTo:re.bTo)[X.inherit.bs];return Ve=Ot(Re,[we,Fe.stackAt[ht]]),Te.set(we,Ve),Ve},bt=new Int32Array(m.text.length+1);bt[m.text.length]=ze;for(let d=m.text.length-1;d>=0;d--)bt[d]=k[d]>=0?k[d]:bt[d+1];Oc.caret+=m.text.length;let mt=d=>d<=0?0:(d>m.text.length&&(d=m.text.length),k[d-1]>=0?k[d-1]+1:bt[d]),It=[],ct=[],Wt=null,St=[],fn="",Gt=-1,Fn=d=>{Wt?Wt.appendChild(d):It.push(d)},Rn=d=>{if(!fn)return;let I=n.createTextNode(fn);Fn(I),ct.push({node:I,ms:Gt,me:d,local:[],u:St.length?St[St.length-1].u:null}),fn=""},cr=new Set,$n=new Map,jo=new Set,Ir=d=>{let I=n.createElement(d.tag);if(d.block&&Ct.add(I),!$n.has(d)){$n.set(d,I),N(d.base,d.local,d.remote,I),c.set(I,{base:d.base,local:d.local,remote:d.remote});let H=(we,Te)=>g&&d[Te]&&we.reverse.get(d[Te])?Te:null,X=!d.base&&(H(o,"local")||H(r,"remote"));if(X){let we=X==="local"?o.reverse.get(d.local):r.reverse.get(d.remote),Te=c.get(I);Te.local=Te.local||o.map.get(we)||null,Te.remote=Te.remote||r.map.get(we)||null,s.push({kind:"move",el:I,source:X}),e.moveBuilt?.(we,X,d[X],I)}else d.base||s.push({kind:"insert",el:I,source:d.local&&d.remote?"both":d.local?"local":"remote"});let de=c.get(I);de.local&&(jo.has(de.local)?de.local=null:jo.add(de.local))}else{let H=$n.get(d);for(let X of H.attributes)X.name!=="id"&&X.name!=="data-id"&&M(I,X,X.value);c.set(I,{base:null,local:null,remote:null})}Fn(I),St.push({u:d,el:I}),Wt=I},ye=new Set,Je=new Map;for(let d of m.pins){let I=mt(d.i);Je.has(I)||Je.set(I,[]),Je.get(I).push(d)}let Ye=d=>{let I=Je.get(d);if(I){Rn(d);for(let U of I){let H=U.el.namespaceURI&&U.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?n.createElementNS(U.el.namespaceURI,U.el.tagName):n.createElement(U.el.tagName);c.set(H,{base:null,local:U.el,remote:null,pinned:!0}),ye.add(H),Fn(H)}}},kt=p.atoms.length||m.atoms.length||y.atoms.length,Dt=d=>{if(!kt)return null;let I=Ce[d]>=0?p.atomAt.get(Ce[d]):null,U=Le[d]>=0?m.atomAt.get(Le[d]):null,H=We[d]>=0?y.atomAt.get(We[d]):null;return I||U||H?{ab:I,al:U,ar:H}:null},rt=(d,I,U)=>{let H=e.idOf;if(!H||!H.base)return!1;let X=H.base(d.el);return X!=null&&X===H[U](I.el)},At=(d,I,U,H,X)=>{if(!d||!g)return null;let de=R.get(I.reverse.get(d.el))||null;return!de||de===H||(H?de.el.isEqualNode(H.el)&&!rt(de,d,X):U.bTo[de.i]>=0)?null:de},Lt=(d,I)=>{if(!d||!g||!e.moveIn)return null;let U=I.reverse.get(d.el);return U&&!R.has(U)?U:null},at=(d,I)=>{let U=new Map;for(let H of d.atoms)U.set(I(H),(U.get(I(H))||0)+1);return U},Nt=at(p,C),sn=at(m,T),un=at(y,x),xn=d=>{let I=C(d);return Nt.get(I)===1&&(sn.get(I)||0)<=1&&(un.get(I)||0)<=1},mn=new Map,kn=new Set,Ln=new Set,ar=new Set,it=null;for(let d=0;d<ze;d++){let I=Dt(d);if(!I)continue;let{ab:U,al:H,ar:X}=I,de=At(X,r,Se,U,"remote"),we=At(H,o,re,U,"local"),Te=U,Ve=null;if(de?(Te=de,Ve="remote"):we&&(Te=we,Ve="local"),Te){U&&Te!==U&&(it||=new Map).set(U,Ve),kn.has(Te)?mn.set(d,{dup:Te.el}):(kn.add(Te),mn.set(d,{bk:Te,from:Ve,al:H,ar:X}));continue}let Re=Lt(X,r),Fe=Lt(H,o),ht=Re||Fe;if(ht){Ln.has(ht)?mn.set(d,{dup:ht}):(Ln.add(ht),mn.set(d,{moveIn:ht,side:Re?"remote":"local",sideEl:Re?X.el:H.el}));continue}let lt=(Ut,Pt)=>Ut&&g&&R.get(Pt.reverse.get(Ut.el))||null,ft=lt(X,r)||lt(H,o);if(ft&&(ar.add(ft),Ne[d].conflict&&(xn(ft)||X&&(X.el===ft.el||r.identityPaired?.has(ft.el))&&rt(ft,X,"remote")||H&&(H.el===ft.el||o.identityPaired?.has(ft.el))&&rt(ft,H,"local")))){if(kn.has(ft)){mn.set(d,{dup:ft.el});continue}kn.add(ft)}mn.set(d,{al:H,ar:X})}let nt=new Map,Rt,st,Et=(d,I)=>{if(d[I]>=0)return d[I];for(let U=I-1;U>=0;U--)if(d[U]>=0)return d[U]+1;return 0};if(g)for(let d of p.atoms){if(kn.has(d)||ar.has(d))continue;let I=o.map.get(d.el)||null,U=r.map.get(d.el)||null,H=I&&w.get(I),X=U&&K.get(U);if(I&&!H||U&&!X)continue;let de=!(H&&X)&&Ae.has(d);if(!de&&!(H&&X&&(xn(d)||it?.has(d)||(H.el===d.el||o.identityPaired?.has(d.el))&&(X.el===d.el||r.identityPaired?.has(d.el))&&rt(d,H,"local")&&rt(d,X,"remote"))))continue;let we=it?.get(d),Te=t;if(we){let lt=we==="local"?y:m,ft=we==="local"?r:o,Ut=we==="local"?st:Rt;if(Ut===void 0){Ut=lt.atoms.length===p.atoms.length;for(let Pt=0;Ut&&Pt<p.atoms.length;Pt++)Ut=ft.reverse.get(lt.atoms[Pt].el)===p.atoms[Pt].el;we==="local"?st=Ut:Rt=Ut}Ut&&(Te=we)}let Ve=Te==="local"?[[H,k],[X,$]]:[[X,$],[H,k]],[Re,Fe]=Ve.find(([lt])=>lt),ht=Et(Fe,Re.i);nt.has(ht)||nt.set(ht,[]),nt.get(ht).push({a:d,lt:I,rt:U,edited:de}),kn.add(d)}if(g&&e.moveIn){let d=[[m,o,k,"local"],[y,r,$,"remote"]];t!=="local"&&d.reverse();for(let[I,U,H,X]of d)for(let de of I.atoms){let we=Lt(de,U);if(!we||Ln.has(we))continue;Ln.add(we);let Te=Et(H,de.i);nt.has(Te)||nt.set(Te,[]),nt.get(Te).push({move:we,side:X,sideEl:de.el})}}let Yt=d=>{let I=nt.get(d);if(I){if(Rn(d),I.some(U=>_e(U.move?U.sideEl:U.a.el)))for(;St.length;)St.pop(),Wt=St.length?St[St.length-1].el:null;for(let{a:U,lt:H,rt:X,edited:de,move:we,side:Te,sideEl:Ve}of I){if(we){let Fe=e.moveIn(we,Te,Ve);Fe&&Fn(Fe);continue}cr.add(U);let Re=L(U.el,H,X);de&&(h({kind:"structure",el:Re,detail:"edit-beats-delete",base:U.el},{subject:U.el,deleted:H?"remote":"local"}),s.push({kind:"insert",el:Re,source:H?"local":"remote"})),Fn(Re)}}},Ct=new Set,tn=i.length>a;for(let d=0;d<ze;d++){let I=Dt(d),U=e.scopeUnits&&I&&(I.ab?.stack.some(we=>we.block)||I.al?.stack.some(we=>we.block)||I.ar?.stack.some(we=>we.block)),X=!!I&&_e((I.ab||I.al||I.ar).el)&&!U?[]:Ke[d]?[Ke[d],...pt(d)]:pt(d),de=0;for(;de<St.length&&de<X.length&&St[de].u===X[de];)de++;if(de<St.length)for(Rn(d);St.length>de;)St.pop(),Wt=St.length?St[St.length-1].el:null;if(Ye(d),Yt(d),X.length>St.length)for(Rn(d);St.length<X.length;)Ir(X[St.length]);if(ae[d]===wt){if(Ue.has(d))continue;Rn(d);let we=St.length;for(;we>0&&!St[we-1].u.block;)we--;if(we>0)for(tn&&f.breakOut.set(d,St[we-1].el);St.length>=we;)St.pop(),Wt=St.length?St[St.length-1].el:null;continue}if(I){Rn(d);let we=mn.get(d),Te;if(we.dup){h({kind:"structure",el:null,detail:"both-moved",base:we.dup},{subject:we.dup});continue}if(we.moveIn){if(Te=e.moveIn(we.moveIn,we.side,we.sideEl),!Te)continue}else if(we.bk){let Ve=we.bk;if(cr.add(Ve),Ve===I.ab)Te=L(Ve.el,we.al.el,we.ar.el);else{let Re=o.map.get(Ve.el)||null,Fe=r.map.get(Ve.el)||null;Te=L(Ve.el,Re,Fe),(!Re||!Fe)&&h({kind:"structure",el:null,detail:"move-beats-delete",base:Ve.el},{subject:Ve.el,deleted:Re?"remote":"local"}),s.push({kind:"move",el:Te,source:we.from})}}else we.al?(Te=j(we.al.el,"local"),we.ar&&(c.get(Te).remote=we.ar.el),s.push({kind:"insert",el:Te,source:we.ar?"both":"local"})):(Te=j(we.ar.el,"remote"),s.push({kind:"insert",el:Te,source:"remote"}));tn&&f.atomOut.set(d,Te),Fn(Te);continue}fn||(Gt=d),fn+=ae[d]}if(Rn(ze),(Je.has(ze)||nt.has(ze))&&(St.length=0,Wt=null,Ye(ze),Yt(ze)),ze===0&&(m.placeholder||y.placeholder||p.placeholder)){let d=n.createElement("br");c.set(d,{base:p.placeholder,local:m.placeholder,remote:y.placeholder}),It.push(d)}let Vt=0,vt=d=>{for(;Vt>0&&ct[Vt-1].me>=d;)Vt--;for(;Vt<ct.length&&ct[Vt].me<d;)Vt++;let I=ct[Vt];if(!I)return ct[ct.length-1]||null;let U=ct[Vt+1];return I.me===d&&U&&U.ms===d?U:I},Tt=new Map,Bt={},Qt=(d,I,U)=>{let H=vt(d)||(U?Bt:null);if(!H)return;let X=Tt.get(H)||{l:!1,r:!1};I!=="remote"&&(X.l=!0),I!=="local"&&(X.r=!0),Tt.set(H,X)},zn=d=>{if(d.conflict)return!0;let I=d.src==="local"?m.text:d.src==="remote"?y.text:"";for(let U=d.from;U<d.to;U++)if(I[U]!==Bn&&I[U]!==wt)return!0;return!1};for(let d of Z)d.src!=="base"&&Qt(d.ms,d.conflict?"both":d.src,zn(d));for(let[d,I]of q)tt[d]>=0&&Qt(tt[d],I);for(let d of ct.length?ct:[Bt]){let I=Tt.get(d);I&&s.push({kind:"text",node:d.node||null,source:I.l&&I.r?"both":I.l?"local":"remote"})}for(let d of Xe){if($n.has(d))continue;let I=!d.local&&!(g&&o.map.get(d.base)),U=!d.remote&&!(g&&r.map.get(d.base));!I&&!U||s.push({kind:"remove",source:I&&U?"both":I?"local":"remote",base:d.base})}if(He)for(let[d,I]of He)$n.has(d)&&h({kind:"structure",el:$n.get(d),detail:"edit-beats-delete",base:d.base},{subject:d.base,deleted:I});let Gn=(d,I,U)=>{if(I<=d)return!1;for(let H=d;H<I;H++)if(U[H]>=0)return!1;return!0};for(let d of Xe)for(let I of["local","remote"]){let U=d[I+"Mark"],H=d.baseMark;if(!U)continue;let X=I==="local"?re:Se;if(!Gn(H.from,H.to,X.bTo)||!Gn(U.from,U.to,X.toB))continue;let de=(I==="local"?Ie:ge).find(we=>we.ss<=U.from&&U.from<we.se);de&&(de.be<=H.from||de.bs>=H.to)&&s.push({kind:"move",el:$n.get(d)||null,source:I})}let Ll=d=>{let I=Ze.get(d.node.parentNode);return I?gt(I):null};for(let d of m.nodes){let I=-1;for(let H=d.s;H<d.e;H++)if(k[H]>=0){I=k[H];break}let U;if(I>=0)U=vt(I);else{let H=mt(d.s),X=Ll(d);U=ct.find(de=>de.u===X&&de.me>=H)||ct.filter(de=>de.u===X).pop()}U&&U.local.push(d)}let Do=new Map,Pl=ct[ct.length-1]||null,vn=0;for(let d of m.nodes){let I=null;for(let U=d.s;U<=d.e;U++){let H=mt(U);for(;vn>0&&ct[vn-1].me>=H;)vn--;for(;vn<ct.length&&ct[vn].me<H;)vn++;let X=we=>we&&H>=we.ms&&H<=we.me&&(H<we.me||U===d.e||we===I),de=X(ct[vn])?ct[vn]:X(ct[vn+1])?ct[vn+1]:ct[vn]||Pl;if(!de)break;if(I===de){let we=Do.get(de);we[we.length-1].to=U-d.s;continue}I=de,Do.has(de)||Do.set(de,[]),Do.get(de).push({node:d.node,from:U-d.s,to:U-d.s,flatStart:d.s})}}for(let d of ct){let I=d.local,U=!1;for(let we of I)for(let Te=we.s;Te<we.e&&!U;Te++)(k[Te]<d.ms||k[Te]>=d.me)&&(U=!0);c.set(d.node,{base:null,local:I.map(we=>we.node),remote:null,caret:Do.get(d)||[],partial:U});let H=d.ms,X=d.me-d.ms,de=we=>{let Te=0,Ve=-1;for(let Re of I){let Fe=Re.e-Re.s;if(we<=Te+Fe){Ve=Re.s+(we-Te);break}Te+=Fe}return Ve<0&&(Ve=I.length?I[I.length-1].e:0),Math.max(0,Math.min(mt(Ve)-H,X))};de.flat=we=>Math.max(0,Math.min(mt(we)-H,X)),l.set(d.node,de)}function jl(){if(!m.text.includes(wt))return[{flatLocal:m.text,localNodes:m.nodes,textNodes:ct,lToM:k,mapLocal:mt}];let d=[],I=0,U=0;for(let H=0;H<=m.text.length;H++){if(H<m.text.length&&m.text[H]!==wt)continue;let X=I,de=H;if(de>X){let we=[];for(;U<m.nodes.length&&m.nodes[U].e<=X;)U++;for(let Te=U;Te<m.nodes.length&&m.nodes[Te].s<de;Te++){let Ve=m.nodes[Te],Re=Math.max(Ve.s,X),Fe=Math.min(Ve.e,de);Re<Fe&&we.push({node:Ve.node,s:Re-X,e:Fe-X})}d.push({flatLocal:m.text.slice(X,de),localNodes:we,textNodes:ct,lToM:k.subarray?k.subarray(X,de+1):k.slice(X,de+1),mapLocal:Te=>mt(X+Math.max(0,Math.min(Te,de-X)))})}I=H+1}return d}let qs={...e,blocks:Ct,ignored:d=>ye.has(d)||(e.ignored?e.ignored(d):!1)},zs=e.ignoreAttribute||(()=>!1),Dl=ui(en(It,qs),zs)!==ui(y,zs);if(u.length){let d=I=>{let U=c.get(I);return U&&U.unchanged?U.remote:null};f.text=ae,f.textNodes=ct,f.out=en(It,{...qs,via:d})}let mo=null;if(e.scopeUnits){mo=new Map;let d=new Set(It),I=Te=>{for(;Te&&!d.has(Te);)Te=Te.parentNode;return Te},U=e.scopeUnits.map(Te=>{let Ve=new Map;for(let Re of Te)if(Re.nodeType===1)Ve.set(Re,Re);else for(let Fe of Re.nodes)Ve.set(Fe,Re);return Ve}),H=(Te,Ve)=>{for(;Te&&!Ve.has(Te);)Te=Te.parentNode;return Te?Ve.get(Te):null},X=[p,m,y].map((Te,Ve)=>{let Re=new Array(Te.text.length);for(let Fe of Te.nodes){let ht=H(Fe.node,U[Ve]);ht&&Re.fill(ht,Fe.s,Fe.e)}for(let Fe of Te.atoms)Re[Fe.i]=H(Fe.el,U[Ve]);return Re}),de=(Te,Ve)=>{if(!Te||!Ve)return;let Re=mo.get(Te);Re||mo.set(Te,Re=new Set),Re.add(Ve)};for(let Te of It){let Ve=c.get(Te);Ve&&(de(H(Ve.base,U[0]),Te),de(H(Ve.local,U[1]),Te),de(H(Ve.remote,U[2]),Te))}for(let Te of ct){let Ve=I(Te.node);for(let Re=Te.ms;Re<Te.me;Re++)de(X[0][Ce[Re]],Ve),de(X[1][Le[Re]],Ve),de(X[2][We[Re]],Ve)}let we=new Map(It.map((Te,Ve)=>[Te,Ve]));for(let[Te,Ve]of mo)mo.set(Te,Array.from(Ve).sort((Re,Fe)=>we.get(Re)-we.get(Fe)))}return{unitOutputs:mo,nodes:It,text:ae,textNodes:ct,localDiverged:Dl,mapLocal:mt,conflicts:i.slice(a),granularity:V?"line":"word",segments:jl(),localHunks:Ie,remoteHunks:ge,lToM:k}}function ki(e,n,t,o,r){if(!r(e.length*8+1))return null;let c=0,l=n===0,i=!1;for(let s of ln(e,o)){if(!r(1))return null;if(c+=s.len,c===n&&(l=!0),c===t&&(i=!0),c>=t)break}return l&&i}function Lc(e,n,t,o,r,c,l){if(!l(n.length*2))return!1;let i=new Map,s=new Map,a=new Set;for(let h of n){let f=h.bs<h.be,u=f?t[h.ownerIndex].text.base:t[h.ownerIndex].text[e],g=f?h.bs:h.ss,b=f?h.be:h.se;if(!l((b-g)*4+1))return!1;for(;g<b&&/\s/.test(u[g]);)g++;for(;b>g&&/\s/.test(u[b-1]);)b--;if(g===b)continue;let A=u.slice(g,b),p=f?i:s;f&&h.text&&a.add(A),p.has(A)?p.set(A,null):p.set(A,{h,from:g,to:b})}for(let h of o){if(!l(1))return!1;if(h.side!==e)continue;let f=h.deletion,u=t[f.ownerIndex].text.base;if(!l((f.be-f.bs)*3)||a.has(u.slice(f.bs,f.be).trim()))return!1}for(let[h,f]of i){if(!l(h.length+1))return!1;let u=s.get(h);if(!f||!u)continue;let g=f.h,b=u.h;if(!g.text||g.transferOut||b.transferIn||g.owner===b.owner)continue;let A=t[g.ownerIndex],p=t[b.ownerIndex];if(!l(A.text.base.length))return!1;if(!/\S/.test(A.text.base.slice(0,g.bs)+A.text.base.slice(g.be)))continue;let m=ki(A.text.base,f.from,f.to,c,l),y=ki(p.text[e],u.from,u.to,c,l);if(m===null||y===null)return!1;if(!m||!y)continue;let R=`${A.index}:${f.from}:${f.to}`,S={key:R,side:e,source:g.owner,destination:b.owner,deletion:g,insertion:b,sourceOffset:f.from-g.bs,targetOffset:u.from-b.ss,length:f.to-f.from};g.transferOut=S,b.transferIn=S,r[e].set(R,S),o.push(S)}return!0}function Ti({base:e,local:n,remote:t,localTwin:o,remoteTwin:r,eligible:c,nodes:l,budget:i=Kt(2e4*32)}){let s=N=>N>i.remaining?!1:(i.remaining-=N,i.nativeSteps=(i.nativeSteps||0)+N,!0);if(e.length<2||n.length!==e.length||t.length!==e.length||!s(e.length*12))return null;for(let[N,L]of[["base",e],["local",n],["remote",t]]){let j=l[N];if(j.length!==L.length||j.some((F,W)=>F!==L[W]))return null}let a=[],h=0;for(let N=0;N<e.length;N++){let L=e[N],j=n[N],F=t[N];if(o(L)!==j||r(L)!==F)return null;let W={};for(let[C,T]of[["base",L],["local",j],["remote",F]]){if(!c(T)||T.tagName!==L.tagName||T.namespaceURI!==L.namespaceURI||!s(T.childNodes.length+1))return null;let x="";for(let z of T.childNodes){if(z.nodeType!==3||!s(z.data.length*4+1))return null;x+=z.data}if(x.includes(wt)||(h+=x.length+1,h>2e4))return null;W[C]=x}a.push({base:L,local:j,remote:F,index:N,text:W})}let f=a.every(N=>yn(N.text.base,N.text.local,N.text.remote)),u={local:[],remote:[]};for(let N of a){N.hunks={local:[],remote:[]};for(let L of["local","remote"]){let j=N.text.base,F=N.text[L];if(j===F)continue;let W=j.length+F.length+4,C=W*8;if(!s(C))return null;let T=Math.floor(i.remaining/8),x=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(W*W+T)-W)/2)));if(x<1||!s(4*(x+1)*(W+x+1)))return null;let z=0;for(let D of ro(j,F,x)){if(!s(D.text.length+1))return null;let V=D.bs+z,Ee={...D,ss:V,se:V+D.text.length,toks:ln(D.text,f),owner:N.base,ownerIndex:N.index};N.hunks[L].push(Ee),u[L].push(Ee),z+=D.text.length-(D.be-D.bs)}}}let g=[],b={local:new Map,remote:new Map};for(let N of["local","remote"]){let L=new Map,j=new Map,F=!1,W=(C,T,x)=>{C.has(T)?C.set(T,null):C.set(T,x)};for(let C of u[N]){if(!s(1))return null;let T=a[C.ownerIndex].text.base;if(C.bs<C.be&&C.text===""){let x=T.slice(C.bs,C.be);if(!s(x.length*2))return null;/\S/.test(x)&&W(L,x,C)}else if(C.bs===C.be&&/\S/.test(C.text)){if(!s(C.text.length*2))return null;W(j,C.text,C)}else C.bs<C.be&&(F=!0)}for(let[C,T]of L){if(!s(C.length+1))return null;let x=j.get(C);if(!T||!x||T.owner===x.owner)continue;let z=a[T.ownerIndex];if(!s(z.text.base.length))return null;if(!/\S/.test(z.text.base.slice(0,T.bs)+z.text.base.slice(T.be)))continue;let D=`${z.index}:${T.bs}:${T.be}`,V={key:D,side:N,source:T.owner,destination:x.owner,deletion:T,insertion:x};T.transferOut=V,x.transferIn=V,b[N].set(D,V),g.push(V)}if(F&&j.size&&!Lc(N,u[N],a,g,b,f,s))return null}if(!g.length)return null;let A=(N,L)=>N.bs<L.be&&L.bs<N.be,p=N=>N.bs===N.be,m=(N,L)=>N.bs<=L.be&&L.bs<=N.be&&p(N)!==p(L),y=(N,L)=>N.bs===L.bs&&N.be===L.be&&N.text===L.text,R=(N,L)=>!!(N.transferIn||N.transferOut&&(!N.text||L.bs===N.be&&/\s/.test(L.text[0])||L.bs===N.bs&&/\s/.test(L.text[L.text.length-1])));for(let N of g){let L=N.side==="local"?"remote":"local",j=a[N.deletion.ownerIndex];for(let F of j.hunks[L])if(!s(1)||A(N.deletion,F)&&F.transferOut?.key!==N.key)return null}for(let N of a)for(let L of N.hunks.local)for(let j of N.hunks.remote){if(!s(1))return null;if(y(L,j)){if(L.transferIn?.key!==j.transferIn?.key)return null;continue}if(A(L,j)||m(L,j)&&!R(L,j)&&!R(j,L))return null}if(!s(h*8))return null;let S=new Set([...e,...n,...t]),O={base:en(e,{blocks:S}),local:en(n,{blocks:S}),remote:en(t,{blocks:S})},M={};for(let N of["base","local","remote"]){let L=O[N];if(L.atoms.length||L.pins.length)return null;M[N]=new Map(L.marks.filter(j=>j.block).map(j=>[j.el,j.from]))}for(let N of a){let L=M.base.get(N.base);if(L===void 0)return null;for(let j of["local","remote"]){let F=M[j].get(N[j]);if(F===void 0)return null;for(let W of N.hunks[j])W.bs+=L,W.be+=L,W.ss+=F,W.se+=F}}for(let N of g)N.bs=N.deletion.bs+(N.sourceOffset||0),N.be=N.length===void 0?N.deletion.be:N.bs+N.length,N.ss=N.insertion.ss+(N.targetOffset||0),N.se=N.length===void 0?N.insertion.se:N.ss+N.length;let E={};for(let N of["local","remote"]){let L=0,j=0,F=[];for(let C of u[N]){if(!s(1))return null;C.bs>L&&F.push({from:L,to:C.bs,target:j}),L=C.be,j=C.se}L<O.base.text.length&&F.push({from:L,to:O.base.text.length,target:j});let W=g.filter(C=>C.side===N).map(C=>({from:C.bs,to:C.be,target:C.ss,destination:C.destination}));if(E[N]=Dn({base:O.base,side:O[N],retained:F,transfers:W,budget:i}),E[N].status!=="ready")return null}return s(O.base.text.length)?{owners:a,blocks:S,transfers:g,byOrigin:b,budget:i,prepared:{base:O.base,local:O.local,remote:O.remote,lines:!1,baseTokens:ln(O.base.text,f),localEdits:{hunks:u.local,respell:new Map},remoteEdits:{hunks:u.remote,respell:new Map},localMap:E.local,remoteMap:E.remote,full:null}}:null}var os=/\S/;function Ai({certificates:e,scopes:n,views:t,eligible:o,baseId:r,limit:c=2e4*32}){let l=Kt(c),i=Symbol(),s=[],a=f=>{if(f>l.remaining)throw i;l.remaining-=f},h=(f,u=null)=>{if(a(1),!f||f.nodeType!==1||f.parentNode?.nodeType!==1||!o(f))return null;for(let A=f.parentNode;A;A=A.parentNode)if(a(1),A.nodeType===11)return null;let g="",b=0;for(let A of f.childNodes){if(a(1),A.nodeType!==3)return null;if(a(A.data.length*4+1),u){let p=u.flat.nodes[b++];if(!p||p.node!==A||p.s!==g.length||p.e!==g.length+A.data.length)return null}g+=A.data}return a(g.length*3+1),u&&(u.flat.atoms.length||u.flat.pins?.length||b!==u.flat.nodes.length||u.flat.text!==g)?null:os.test(g)?g:null};try{a(n[0].length+n[1].length+n[2].length+e.length);let f=n.map(g=>new Set(g)),u=new Map;for(let g of e){a(1);let b=u.get(g.source);b||u.set(g.source,b=[]),b.push(g)}for(let g of u.values()){let b=[null,null],A=[];for(let p of g){a(1);let{source:m,target:y,side:R,models:S,runs:O}=p;if(R!==0&&R!==1||!f[0].has(m)||!f[R+1].has(y))continue;let{V:M,A:E,idOf:N}=t[R],L=t[1-R],j=M.twin(m),F=L.V.twin(m),W=M.baseOf(y);if(!j||!F||!W||W===m||!f[0].has(W)||!f[R+1].has(j)||!f[2-R].has(F)||E.map.get(m)!==j||E.reverse.get(j)!==m||L.A.map.get(m)!==F||L.A.reverse.get(F)!==m||E.map.get(W)!==y||E.reverse.get(y)!==W||y.parentNode!==j.parentNode||W.parentNode!==m.parentNode||m.tagName!==j.tagName||m.tagName!==F.tagName||r(m)!==N(j)||r(m)!==L.idOf(F)||r(W)!==N(y))continue;let C=S.get(m),T=S.get(y);if(!C||!T)continue;let x=h(m,C),z=h(y,T),D=h(j),V=h(F);if(a((x?.length||0)+(V?.length||0)),x===null||z===null||D===null||V===null||V===x)continue;let Ee=O.length>0,Me=!1;for(let re of O){if(a(1),re.source!==m||re.target!==y||!Number.isInteger(re.from)||!Number.isInteger(re.to)||!Number.isInteger(re.targetFrom)||re.from<0||re.to<=re.from||re.to>x.length||re.targetFrom<0||re.targetFrom+re.to-re.from>z.length){Ee=!1;break}a((re.to-re.from)*3);for(let Se=re.from;Se<re.to;Se++){if(x[Se]!==z[re.targetFrom+Se-re.from]){Ee=!1;break}os.test(x[Se])&&(Me=!0)}if(!Ee)break}if(!Ee||!Me)continue;let De=b[R];De||(a(x.length),De=b[R]={source:m,side:R,flat:C.flat,before:x,covered:new Uint8Array(x.length)});for(let re of O)a(re.to-re.from),De.covered.fill(1,re.from,re.to)}for(let p of b){if(!p)continue;let{source:m,side:y,flat:R,before:S,covered:O}=p;a(S.length*3+1);let M=-1,E=-1;for(let N=0;N<=S.length;N++)N<S.length&&O[N]?(M<0&&(M=N),E=N+1):(N===S.length||os.test(S[N]))&&M>=0&&(A.push({source:m,side:y,flat:R,from:M,to:E}),M=E=-1)}a(A.length),s.push(...A)}}catch(f){if(f!==i)throw f}return{records:s,budget:l}}var Pc="http://www.w3.org/1999/xhtml";function jc(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n^e.charCodeAt(t);return(n>>>0).toString(36)}function hn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Pc}function Dc(e){let n=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return n==="application/json"||n.endsWith("+json")}function kr(e,n){let t=e.getAttribute("src"),o=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let r=t;try{let c=new URL(t,n);r=c.origin+c.pathname+c.search}catch{}return"script|src|"+o+"|"+r}return"script|inline|"+o+"|"+jc(e.textContent.trim())}var Bc={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function So(e,n=[],t=!1){if(!hn(e)||e.hasAttribute("src"))return null;let o=[Bc,...n];for(let r=0;r<o.length;r++){let c=o[r];if(!c.match(e))continue;if(!Dc(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=c.identity(e);return l==null||l===""?null:{key:r+":"+l,raw:l,recognizer:c}}return null}function Si(e,n,t){let o=new Set,r=c=>{hn(c)&&!n(c)&&o.add(kr(c,t))};r(e);for(let c of e.querySelectorAll("script"))r(c);return o}function Vo(e,n){let t=n.createElement("div");t.innerHTML="<script><\/script>";let o=t.firstChild;for(let r of e.attributes)o.setAttribute(r.name,r.value);return o.textContent=e.textContent,o}function Ni(e,n,t){let o=[],r=[],c=new Map,l=t.trackRecovery?new Set:null,i=Array.from(e.querySelectorAll("script"));hn(e)&&i.unshift(e);for(let s of i){if(!hn(s)||t.ignored(s)||t.skip.has(s)||n.has(kr(s,t.baseURI)))continue;let a=s.ownerDocument.createElement("script");for(let h of s.attributes)a.setAttribute(h.name,h.value);if(a.textContent=s.textContent,t.beforeNodeAdded(a)===!1){l?.add(s);continue}a.hasAttribute("src")&&r.push(new Promise(h=>{a.addEventListener("load",()=>h()),a.addEventListener("error",()=>h())})),s.replaceWith(a),c.set(s,a),t.afterNodeAdded(a),o.push(a)}return{executed:o,loads:r,swapped:c,vetoed:l}}function Uc(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n^e.charCodeAt(t);return(n>>>0).toString(36)}function Hc(e,n){try{let t=new URL(e,n);return t.origin+t.pathname+t.search}catch{return e}}function vi(e,n){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return kr(e,n);if(t==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+Hc(o,n):e.outerHTML}if(t==="META"){for(let o of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(o))return"meta|"+o+"="+e.getAttribute(o);return e.outerHTML}return t==="STYLE"?"style|"+Uc(e.textContent):e.outerHTML}function rs(e,n){for(;;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]==="/"&&e[n+1]==="/"){for(;n<e.length&&e[n]!==`
|
|
5
|
+
`;)n++;continue}if(e[n]==="/"&&e[n+1]==="*"){let t=e.indexOf("*/",n+2);if(t===-1)return e.length;n=t+2;continue}return n}}function Wc(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(n,t)=>t.length%2===0?t+'\\"':n)}var Vc=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,_c=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ss(e){try{return JSON.parse(e)}catch{return JSON.parse(Fc(e))}}function Fc(e){let n="",t=0,o=(r,c)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${c}`)};for(;t<e.length&&(t=rs(e,t),!(t>=e.length));){let r=e[t];if("{}[]:".includes(r)){n+=r,t++;continue}if(r===","){let i=rs(e,t+1);if(e[i]==="}"||e[i]==="]"){t++;continue}n+=r,t++;continue}if(r==='"'||r==="'"){let i=t+1;for(;i<e.length&&e[i]!==r;)e[i]==="\\"&&i++,i++;i>=e.length&&o("unterminated string",t);let s=e.slice(t+1,i);r==="'"&&(s=Wc(s)),n+='"'+s+'"',t=i+1;continue}let c=t;for(;c<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[c]);)c++;c===t&&o("unexpected character "+JSON.stringify(r),t);let l=e.slice(t,c);if(l==="true"||l==="false"||l==="null"||Vc.test(l)){n+=l,t=c;continue}if(_c.test(l)){if(e[rs(e,c)]===":"){n+='"'+l+'"',t=c;continue}o("unquoted value "+JSON.stringify(l),t)}o("invalid token "+JSON.stringify(l),t)}return n}var Xt=Symbol("hyper-morph-json-merge:missing"),Oi=["id","_id","uuid","key","slug","code","name"];function No(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _o(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function $c(e,n,t){Object.defineProperty(e,n,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Qn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!Qn(e[t],n[t]))return!1;return!0}if(No(e)&&No(n)){let t=Object.keys(e);if(t.length!==Object.keys(n).length)return!1;for(let o of t)if(!_o(n,o)||!Qn(e[o],n[o]))return!1;return!0}return!1}function Mi(e,n,t,o){return Qn(n,t)?n:Qn(n,e)?t:Qn(t,e)?n:No(n)&&No(t)?Kc(No(e)?e:{},n,t,o):Array.isArray(n)&&Array.isArray(t)?Yc(Array.isArray(e)?e:[],n,t,o):t}function Ei(e,n,t,o){return n===Xt&&t===Xt?Xt:n===Xt?e===Xt?t:Qn(t,e)?Xt:t:t===Xt?e===Xt?n:Xt:Mi(e,n,t,o)}function Kc(e,n,t,o){let r={},c=new Set([...Object.keys(e),...Object.keys(n),...Object.keys(t)]);for(let l of c){let i=Ei(_o(e,l)?e[l]:Xt,_o(n,l)?n[l]:Xt,_o(t,l)?t[l]:Xt,o);i!==Xt&&$c(r,l,i)}return r}function qc(e){return e===null||typeof e!="object"}function Tr(e){return typeof e+":"+String(e)}function zc(e,n){for(let t of n){let o=new Set;for(let r of t){if(!_o(r,e))return!1;let c=r[e];if(typeof c!="string"&&typeof c!="number")return!1;let l=Tr(c);if(o.has(l))return!1;o.add(l)}}return!0}function Gc(e,n,t,o){let r=[e,n,t],c=!0;for(let l of r)for(let i of l)No(i)||(c=!1);if(c){for(let l of o.keyCandidates)if(zc(l,r))return{kind:"keyed",field:l};return null}for(let l of r){let i=new Set;for(let s of l){if(!qc(s))return null;let a=Tr(s);if(i.has(a))return null;i.add(a)}}return{kind:"self"}}function Yc(e,n,t,o){let r=Gc(e,n,t,o);if(!r)return t;let c=r.kind==="self"?Tr:g=>Tr(g[r.field]),l=g=>{let b=new Map;for(let A of g)b.set(c(A),A);return b},i=l(e),s=l(n),a=l(t),h=new Map,f=new Set([...i.keys(),...s.keys(),...a.keys()]);for(let g of f){let b=Ei(i.has(g)?i.get(g):Xt,s.has(g)?s.get(g):Xt,a.has(g)?a.get(g):Xt,o);b!==Xt&&h.set(g,b)}let u=[];for(let g of t){let b=c(g);h.has(b)&&u.push(b)}for(let g=0;g<n.length;g++){let b=c(n[g]);if(!h.has(b)||u.includes(b))continue;let A=0;for(let p=g-1;p>=0;p--){let m=u.indexOf(c(n[p]));if(m!==-1){A=m+1;break}}u.splice(A,0,b)}return u.map(g=>h.get(g))}function Ii(e,n,t,o={}){let r=o.keyCandidates?[...o.keyCandidates,...Oi]:Oi;return Mi(e===void 0?Xt:e,n,t,{keyCandidates:r})}function is(e,n,t,o={}){let r=o.parse||ss,c=[],l=(f,u)=>{if(typeof f!="string")return Xt;try{return r(f)}catch(g){return c.push(`${u} side is not valid JSON (${g.message})`),Xt}},i=l(n,"local"),s=l(t,"remote");if(i===Xt)return{text:t,warnings:c};if(s===Xt)return{text:n,warnings:c};let a=l(e,"base"),h=Ii(a===Xt?void 0:a,i,s,o);return Qn(h,s)?{text:t,warnings:c}:Qn(h,i)?{text:n,warnings:c}:{text:JSON.stringify(h,null,2),warnings:c}}var Ci=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function lo(e){if(!e)return!1;let{startContainer:n,startOffset:t,endContainer:o,endOffset:r}=e;if(!n||!o||!Number.isInteger(t)||!Number.isInteger(r)||t<0||r<0||t>Ci(n)||r>Ci(o)||n.getRootNode()!==o.getRootNode())return!1;let c=n.ownerDocument.createRange();return c.setStart(n,t),c.setEnd(o,r),c.startContainer===n&&c.startOffset===t}function Zn(e,n,t={}){if(!lo(e))return null;let{startContainer:o,startOffset:r,endContainer:c,endOffset:l}=e;if(o===c&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,l);if(o===c&&r===l)return"";let i=new Set;for(let p=o;p;p=p.parentNode)i.add(p);let s=c;for(;!i.has(s);)s=s.parentNode;let a=(p,m)=>{let y=s.ownerDocument.createRange(),R=s.ownerDocument.createRange();return y.setStart(p[0],p[1]),y.collapse(!0),R.setStart(m[0],m[1]),R.collapse(!0),y.compareBoundaryPoints(0,R)},h=(p,m=!1)=>[p.parentNode,Array.prototype.indexOf.call(p.parentNode.childNodes,p)+Number(m)],f=[],u;if(n==="plain"){u="";let p=m=>{if(m.nodeType===3||m.nodeType===8){let y=u.length;u+=m.nodeValue,f.push({s:y,e:u.length,a:[m,0],b:[m,m.nodeValue.length],node:m})}else for(let y of m.childNodes)p(y)};p(s)}else{let p=t.blocks;if(!p){p=new Set;let y=R=>{R!==s&&R.nodeType===1&&ts.has(R.tagName)&&p.add(R);for(let S of R.childNodes)y(S)};y(s)}let m=en(Array.from(s.childNodes),{blocks:p,atomize:y=>!!t.atoms?.has(y),ignored:t.ignored});u=m.text;for(let y of m.nodes)f.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 m.atoms)f.push({s:y.i,e:y.i+1,a:h(y.el),b:h(y.el,!0)});for(let y=0;y<m.text.length;y++){if(m.text[y]!==wt)continue;let R=m.marks.find(O=>O.block&&O.to===y+1),S=m.marks.find(O=>O.block&&O.from===y+1);if(R)f.push({s:y,e:y+1,a:[R.el,R.el.childNodes.length],b:h(R.el,!0)});else if(S)f.push({s:y,e:y+1,a:h(S.el),b:[S.el,0]});else return null}}f.sort((p,m)=>p.s-m.s);let g=p=>{if(p[0].nodeType===3||p[0].nodeType===8){let y=f.find(R=>R.node===p[0]);return y?y.s+p[1]:null}let m=0;for(let y of f){if(a(p,y.a)<=0)return y.s;if(a(p,y.b)<0)return null;m=y.e}return m},b=g([o,r]),A=g([c,l]);return b!==null&&A!==null&&b<=A?u.slice(b,A):null}function io(e,n){let t=e;for(let o of n.path)if(t=o==="content"?t?.content:t?.childNodes[o],!t)return null;return[t,n.offset]}function Ri(e,n){if(!e||!n)return null;let t=io(e,n.start),o=io(e,n.end);return t&&o?{startContainer:t[0],startOffset:t[1],endContainer:o[0],endOffset:o[1]}:null}var Li=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Pi(e,n,t){if(!n)return;let o=new Map,r=new Map,c=i=>{if(!i)return null;if(r.has(i))return r.get(i);let a=i.local.map(h=>io(n.localRoot,{path:h,offset:0})?.[0]).map(h=>h&&t(h)).filter(Boolean).map(h=>({node:h,parent:h.parentNode,previous:h.previousSibling,next:h.nextSibling,fragment:Li(h)}));return r.set(i,a),a},l=i=>{let s=Ri(n.localRoot,i);if(!s)return null;let a=t(s.startContainer),h=t(s.endContainer);if(!a||!h)return null;let f={...s,startContainer:a,endContainer:h};return lo(f)?f:null};for(let i of e){let s=i.recovery;if(!s||o.has(s))continue;let a={subject:c(s.subject),span:null,scope:null,touched:new Set};if(s.text){a.span=l(s.text.local.span),a.scope=l(s.text.local.scope);let h=a.span;if(h){let f=h.startContainer.ownerDocument.createRange();f.setStart(h.startContainer,h.startOffset),f.setEnd(h.endContainer,h.endOffset);let u=g=>{if(f.intersectsNode(g)){a.touched.add(g);for(let b of g.childNodes)u(b)}};u(f.commonAncestorContainer)}}if(s.structure){for(let h of[s.structure.localPlacement])h&&(c(h.parent),h.before.forEach(c),h.after.forEach(c));for(let h of s.structure.localOrder||[])c(h)}o.set(s,a)}n.localState={states:o,refs:r}}function ji(e,n,t,o){let r=t.localState?.states.get(e);if(!r)return!1;let c=i=>{let s=i.node;if(!o(s)||s.parentNode!==i.parent)return!1;let a=h=>Array.prototype.indexOf.call(s.parentNode.childNodes,h);return!(i.previous&&o(i.previous)&&i.previous.parentNode===s.parentNode&&a(i.previous)>=a(s)||i.next&&o(i.next)&&i.next.parentNode===s.parentNode&&a(i.next)<=a(s))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!r.subject.length||!r.subject.every(c))return!1;if(e.text){let i=e.text.local,s=a=>a&&o(a.startContainer)&&o(a.endContainer);return s(r.span)&&s(r.scope)&&Zn(r.scope,e.text.encoding)===i.text&&Zn(r.span,e.text.encoding)===i.text.slice(i.start,i.end)}if(e.attribute){let i=e.attribute,s=r.subject[0].node;return(i.namespaceURI?s.getAttributeNS(i.namespaceURI,i.localName):s.getAttribute(i.qualifiedName))===n.local}let l=e.structure;if(l.localOrder){let i=-1,s=null;for(let a of l.localOrder){let h=t.localState.refs.get(a)?.[0]?.node;if(!h||!o(h)||s&&h.parentNode!==s)return!1;let f=Array.prototype.indexOf.call(h.parentNode.childNodes,h);if(f<=i)return!1;s=h.parentNode,i=f}return!0}return l.localAction==="moved"||r.subject.every(i=>Li(i.node)===i.fragment)}var Xc=1,cn=e=>!!e&&e.nodeType===1,Ar=e=>cn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function co(e,n=null,t=null){let o=new Map,r=new Map,c=h=>{if(!n){n=new WeakMap;let f=[e];for(;f.length;){let u=f.pop();Ar(u)&&(n.set(u.content,u),f.push(u.content));for(let g=u.firstChild;g;g=g.nextSibling)g.nodeType===1&&f.push(g)}}return n.get(h)||null},l=(h,f)=>{let u=r.get(h);if(!u){u=new Map;let g=0;for(let b=h.firstChild;b;b=b.nextSibling)u.set(b,g++);r.set(h,u)}return u.get(f)},i=h=>{if(!h)return null;if(t&&t.has(h))return i(t.get(h));if(h===e)return[];let f=o.get(h);if(f!==void 0)return f;let u=h.parentNode,g=null;if(u&&u.nodeType===11){let b=c(u),A=b?i(b):null;A&&(g=A.concat(["content",l(u,h)]))}else if(u){let b=i(u);b&&(g=b.concat([l(u,h)]))}return o.set(h,g),g};return{root:e,pathOf:i,logicalParent:h=>{let f=h.parentNode;return f&&f.nodeType===11?c(f):f},indexIn:l,containerPath:h=>{if(h.nodeType===11){let u=c(h),g=i(u);return g?g.concat(["content"]):null}let f=i(h);return f&&Ar(h)?f.concat(["content"]):f},ownerOf:c}}var En=e=>Ar(e)?e.content:e;function Di(e){let{L:n,R:t,unitsOf:o,provenance:r,policy:c}=e,l=[];return{note:(h,f)=>{l.push([h,f])},finish:h=>l.length?a(h):null};function a(h){let f={base:co(e.roots.base),local:co(e.roots.local),remote:co(e.roots.remote)},u=v=>v==="local"?n:t,g=(v,P)=>{if(!P)return null;if(v.map.has(P))return v.map.get(P);let Y=[],J=cn(P)?f.base.logicalParent(P):P.parent;for(;J&&!v.map.has(J);J=f.base.logicalParent(J))Y.push(J);if(!J||!v.identical.has(J))return null;let oe=v.map.get(J);for(let je=Y.length-1;je>=0&&oe;je--)oe=En(oe).childNodes[f.base.indexIn(Y[je].parentNode,Y[je])];return oe?cn(P)?En(oe).childNodes[f.base.indexIn(P.parentNode,P)]||null:o(oe)[o(P.parent).indexOf(P)]||null:null},b=new Map,A=new Map,p=new WeakMap,m=0,y=(v,P)=>{let Y=b.get(v);Y||b.set(v,Y=[]),Y.push(P)};(function v(P){A.set(P,m++);let Y=r.get(P);if(Y&&!Y.pinned){for(let J of[Y.base,Y.local,Y.remote])if(J)if(Array.isArray(J))for(let oe of J)y(oe,P);else y(J,P)}if(Ar(P)){p.set(P.content,P);for(let J=P.content.firstChild;J;J=J.nextSibling)v(J)}for(let J=P.firstChild;J;J=J.nextSibling)v(J)})(h);let R=new Map;f.out=co(h,p,R);let S={refs:new Map,spans:new Map,anchors:new Map,via:R,outOwners:p,outRoot:h,localRoot:e.roots.local},O=v=>cn(v)?[v]:v.nodes,M=(v,P)=>{let Y=f[P].logicalParent(v);if(!Y)return null;for(let J of o(Y))if(!cn(J)&&J.nodes.includes(v))return J;return null},E=(v,P)=>v==null?null:Array.isArray(v)?v.length?M(v[0],P):null:v,N=v=>{let P=new Set,Y=[];for(let J of v)for(let oe of b.get(J)||[])P.has(oe)||(P.add(oe),Y.push(oe));return Y.sort((J,oe)=>A.get(J)-A.get(oe))},L=new Map,j=v=>{let P=v.b||v.l||v.r,Y=L.get(P);if(Y)return Y;let J=[];for(let oe of[v.b,v.l,v.r])oe&&J.push(...O(oe));return Y=N(J),L.set(P,Y),Y},F=v=>({b:v,l:g(n,v),r:g(t,v)}),W=(v,P)=>{let Y=u(P).reverse.get(v);if(Y)return F(Y);for(let J of N(O(v))){let oe=r.get(J);if(oe&&!oe.base&&oe.local&&oe.remote)return{b:null,l:E(oe.local,"local"),r:E(oe.remote,"remote")}}return P==="local"?{b:null,l:v,r:null}:{b:null,l:null,r:v}},C=new Map,T=v=>{let P=r.get(v);if(!P||P.pinned)return null;let Y=E(P.base,"base");if(Y)return F(Y);let J=E(P.local,"local"),oe=E(P.remote,"remote");if(J){let je=n.reverse.get(J);if(je)return F(je)}if(oe){let je=t.reverse.get(oe);if(je)return F(je)}return J||oe?{b:null,l:J,r:oe}:null},x=v=>(C.has(v)||C.set(v,T(v)),C.get(v)),z=(v,P)=>cn(v)?f[P].logicalParent(v):v.parent,D=new Map,V=new Map,Ee=(v,P)=>(cn(v)?[f[P].pathOf(v)]:v.nodes.map(Y=>f[P].pathOf(Y))).filter(Boolean),Me=v=>{let P=v.b||v.l||v.r,Y=v.b?"base":v.l?"local":"remote",J=V.get(P);if(J)return J;let oe=!cn(P),je=Ee(P,Y)[0],Z=`${Y[0]}:${JSON.stringify(je===void 0?null:je)}${oe?":run":""}`,Oe=D.get(Z);if(Oe)return V.set(P,Oe),Oe;let He=j(v);return Oe={key:Z,nodeType:cn(P)?1:P.kind==="comment"?8:3,base:v.b?Ee(v.b,"base"):[],local:v.l?Ee(v.l,"local"):[],remote:v.r?Ee(v.r,"remote"):[],merged:He.map(Ie=>f.out.pathOf(Ie)).filter(Boolean),live:[]},D.set(Z,Oe),V.set(P,Oe),S.refs.set(Oe,He),Oe},De={base:new Map,local:new Map,remote:new Map},re=new Map,Se=(v,P)=>{let Y=z(v,P);if(!Y||Y.nodeType!==1)return null;let J=De[P].get(Y);if(!J){let je=o(Y),Z=Oe=>Me(P==="base"?F(Oe):W(Oe,P));J={parent:Z(Y),refs:je.map(Z),index:new Map(je.map((Oe,He)=>[Oe,He]))},De[P].set(Y,J)}let oe=J.index.get(v)??-1;return{parent:J.parent,before:J.refs.slice(oe+1),after:J.refs.slice(0,Math.max(0,oe)).reverse()}},qe=v=>{let P=v.parentNode;if(!P)return null;let Y=re.get(P);if(!Y){let oe=P.nodeType===11?p.get(P):P,je=oe&&oe.nodeType===1?x(oe):null;if(!je)return null;let Z=[],Oe=[],He=new Map;for(let ge of P.childNodes){let B=x(ge),G=B&&Me(B),ue=Z.length,he=Z.length-1;G&&G!==Z[he]&&(Z.push(G),he++);let ce={ref:G,group:he,after:ue};Oe.push(ce),He.set(ge,ce)}let Ie=Z.length;for(let ge=Oe.length-1;ge>=0;ge--){let B=Oe[ge];B.before=Ie,B.ref&&(Ie=B.group)}Y={parent:Me(je),refs:Z,index:He},re.set(P,Y)}let J=Y.index.get(v);return{parent:Y.parent,before:Y.refs.slice(J.before),after:Y.refs.slice(0,J.after).reverse()}},ve=v=>cn(v)?v.outerHTML:v.value,w=v=>cn(v)?"element":v.kind==="comment"?"comment":"text",K=(v,P)=>({path:v,offset:P}),ne=(v,P,Y)=>{if(!v)return null;let J=f[Y],oe=0;if(P){let je=cn(P)?P:P.nodes[P.nodes.length-1];je.parentNode&&(oe=J.indexIn(je.parentNode,je)+1)}return K(J.containerPath(v),oe)},ee=(v,P)=>{let Y=z(v,"base"),J=Y?g(u(P),Y):null;if(!cn(J))return null;let oe=o(Y),je=null;for(let Z=oe.indexOf(v)-1;Z>=0&&!je;Z--){let Oe=g(u(P),oe[Z]);Oe&&z(Oe,P)===J&&(je=Oe)}return ne(J,je,P)},Pe=(v,P,Y,J)=>{let oe=f[J],je=0;for(let Z=0;Z<v.nodes.length;Z++){let Oe=v.nodes[Z],He=Oe.nodeValue.length,Ie=Z===v.nodes.length-1;if((Y==="start"?P<je+He:P<=je+He)||Ie)return K(oe.pathOf(Oe),Math.max(0,Math.min(P-je,He)));je+=He}return null},_e=(v,P)=>{let Y=f[P],J=v.firstChild,oe=v.lastChild;return J&&J.nodeType===3&&oe.nodeType===3?{start:K(Y.pathOf(J),0),end:K(Y.pathOf(oe),oe.nodeValue.length)}:{start:K(Y.pathOf(v),0),end:K(Y.pathOf(v),v.childNodes.length)}},Ae=(v,P,Y)=>{for(let Z of v.nodes)if(Y==="start"?Z.s<=P&&P<Z.e:Z.s<P&&P<=Z.e)return{kind:"text",node:Z.node,offset:P-Z.s};let J=Y==="start"?P:P-1,oe=()=>{for(let Z of v.nodes)if(Z.s===P||Z.e===P)return{kind:"text",node:Z.node,offset:P-Z.s};return null},je=v.atomAt.get(J);if(je)return{kind:Y==="start"?"before":"after",node:je.el};if(v.text[J]===wt){let Z=v.marks.find(He=>He.block&&He.to===J+1);if(Z)return Y==="start"?{kind:"end",node:Z.el}:{kind:"after",node:Z.el};let Oe=v.marks.find(He=>He.block&&He.from===J+1);if(Oe)return Y==="start"?{kind:"before",node:Oe.el}:{kind:"startOf",node:Oe.el}}return oe()},ot=(v,P)=>Ae(v,P,"end")||Ae(v,P,"start"),Qe=(v,P)=>{switch(P.kind){case"text":return K(v.pathOf(P.node),P.offset);case"end":return K(v.containerPath(P.node),En(P.node).childNodes.length);case"startOf":return K(v.containerPath(P.node),0);default:{let Y=P.node.parentNode;return K(v.containerPath(Y),v.indexIn(Y,P.node)+(P.kind==="after"?1:0))}}},Ze=(v,P,Y,J,oe)=>{let je=Ae(v,P,Y);return je?Qe(f[J],je):oe()},Xe=(v,P,Y,J)=>{let oe=v.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,ge]of v.atomOut)oe.push({s:Ie,e:Ie+1,start:{kind:"before",node:ge},end:{kind:"after",node:ge}});for(let[Ie,ge]of v.breakOut)oe.push({s:Ie,e:Ie+1,start:{kind:"end",node:ge},end:{kind:"after",node:ge}});for(let Ie of oe)if(Ie.start.kind==="text"&&Ie.s<P&&P<Ie.e)return{kind:"text",node:Ie.start.node,offset:P-Ie.s};if(Y!=="empty"){let Ie=oe.find(ge=>Y==="start"?ge.s===P:ge.e===P);if(Ie)return Y==="start"?Ie.start:Ie.end}let je=oe.find(Ie=>Ie.e===P);if(je)return je.end;let Z=oe.find(Ie=>Ie.s===P);if(Z)return Z.start;let Oe=null,He=null;for(let Ie of oe)Ie.e<=P&&(!Oe||Ie.e>Oe.e)&&(Oe=Ie),Ie.s>=P&&(!He||Ie.s<He.s)&&(He=Ie);return Oe?Oe.end:He?He.start:J()},yt=(v,P)=>{if(!P)return null;if(P.kind==="text"){let oe=v.nodes.find(je=>je.node===P.node);return oe?oe.s+Math.min(P.offset,oe.e-oe.s):null}let Y=v.atoms.find(oe=>oe.el===P.node);if(Y)return P.kind==="after"?Y.i+1:Y.i;let J=v.marks.find(oe=>oe.el===P.node);return J?P.kind==="before"&&J.block&&v.text[J.from-1]===wt&&!v.marks.some(oe=>oe.block&&oe.to===J.from)?J.from-1:P.kind==="startOf"||P.kind==="before"?J.from:P.kind==="end"&&J.block?J.to-1:J.to:null},dt=(v,P,Y,J)=>{for(let Oe of v.nodes)if(Y==="start"?Oe.s<=P&&P<Oe.e:Oe.s<P&&P<=Oe.e)return{kind:"text",node:Oe.node,offset:P-Oe.s};let oe=Y==="start"?P:P-1;if(!v.atomAt.has(oe)&&v.text[oe]!==wt){for(let Oe of v.nodes)if(Oe.s===P||Oe.e===P)return{kind:"text",node:Oe.node,offset:P-Oe.s}}let je=v.atomAt.get(oe);if(je)return{kind:Y==="start"?"before":"after",node:je.el};if(v.text[oe]===wt){let Oe=v.marks.find(Ie=>Ie.block&&Ie.to===oe+1);if(Oe)return Y==="start"?{kind:"end",node:Oe.el}:{kind:"after",node:Oe.el};let He=v.marks.find(Ie=>Ie.block&&Ie.from===oe+1);if(He)return Y==="start"?{kind:"before",node:He.el}:{kind:"startOf",node:He.el}}let Z=v.marks.find(Oe=>Oe.block&&Oe.from===P);return Z?{kind:"startOf",node:Z.el}:J?{kind:Y==="start"?"startOf":"end",node:J}:null},gt=v=>{if(!v)return null;if(v.kind==="wholeStart"||v.kind==="wholeEnd"){let P=qt(v.node);return v.kind==="wholeStart"?P.start:P.end}return Qe(f.out,v)},qt=v=>{let P=v.firstChild,Y=v.lastChild;return P&&P.nodeType===3&&Y.nodeType===3?{start:K(f.out.pathOf(P),0),end:K(f.out.pathOf(Y),Y.nodeValue.length)}:{start:K(f.out.pathOf(v),0),end:K(f.out.pathOf(v),v.childNodes.length)}},$t=v=>{let P=z(v,"base"),Y=P?j(F(P))[0]:null;if(!Y)return null;let J=En(Y),oe=o(P);for(let je=oe.indexOf(v)-1;je>=0;je--){let Z=j(F(oe[je])).filter(Oe=>Oe.parentNode===J);if(Z.length)return{kind:"after",node:Z[Z.length-1]}}return{kind:"startOf",node:Y}},Ht=(v,P,Y,J,oe,je)=>({text:v,start:P,end:Y,fragment:J,span:oe,scope:je}),jt=(v,P,Y,J,oe)=>Ht(v,P,Y,v.slice(P,Y),J,oe),an=(v,P,Y,J,oe)=>(S.spans.set(v,{start:P,end:Y,scopeStart:J,scopeEnd:oe}),v),_t=new Map,zt=new Map,_=(v,P,Y)=>{let J=`text:${v.key}:${P}:${Y}`,oe=zt.get(J)||0;return zt.set(J,oe+1),`${J}:${oe}`},ie=(v,P)=>{let Y,J,oe,je="plain",Z,Oe,He,Ie,ge,B=(he,ce,xe,te,q)=>{if(!he){let ae=ee(q,te);return jt("",0,0,{start:ae,end:ae},{start:ae,end:ae})}return jt(he.value,ce,xe,{start:Pe(he,ce,ce===xe?"end":"start",te),end:Pe(he,xe,"end",te)},{start:Pe(he,0,"start",te),end:Pe(he,he.value.length,"end",te)})};if(P.site==="run"){let{bRun:he,lRun:ce,rRun:xe,node:te,c:q}=P;Y=F(he),J=q.bs,oe=q.be,Z=B(he,q.bs,q.be,"base",he),Oe=B(ce,q.ls,q.le,"local",he),He=B(xe,q.rs,q.re,"remote",he);let ae=te?te.nodeValue:"",Ce=Le=>te?{kind:"text",node:te,offset:Le}:$t(he);Ie=an(jt(ae,q.ms,q.me,{start:gt(Ce(q.ms)),end:gt(Ce(q.me))},{start:gt(Ce(0)),end:gt(Ce(ae.length))}),Ce(q.ms),Ce(q.me),Ce(0),Ce(ae.length)),ge=te||($t(he)||{}).node||null}else if(P.site==="whole"){let he=P.el,ce=r.get(he);Y=F(ce.base),J=0,oe=v.base.length;let xe=(q,ae,Ce)=>{let Le=_e(ae,Ce);return jt(q,0,q.length,Le,Le)};Z=xe(v.base,ce.base,"base"),Oe=xe(v.local,ce.local,"local"),He=xe(v.remote,ce.remote,"remote");let te=qt(he);Ie=an(jt(v.resolved,0,v.resolved.length,te,te),{kind:"wholeStart",node:he},{kind:"wholeEnd",node:he},{kind:"wholeStart",node:he},{kind:"wholeEnd",node:he}),ge=he}else if(P.site==="comment"){let{bRun:he,lRun:ce,rRun:xe,node:te}=P;Y=F(he),J=0,oe=v.base.length;let q=(We,Ne)=>{if(!We){let k=ee(he,Ne);return jt("",0,0,{start:k,end:k},{start:k,end:k})}let ze=We.nodes[0],tt={start:K(f[Ne].pathOf(ze),0),end:K(f[Ne].pathOf(ze),We.value.length)};return jt(We.value,0,We.value.length,tt,tt)};Z=q(he,"base"),Oe=q(ce,"local"),He=q(xe,"remote");let ae=v.resolved,Ce=We=>te?{kind:"text",node:te,offset:We}:$t(he),Le={start:gt(Ce(0)),end:gt(Ce(ae.length))};Ie=an(jt(ae,0,ae.length,Le,Le),Ce(0),Ce(ae.length),Ce(0),Ce(ae.length)),ge=te||($t(he)||{}).node||null}else{let{fb:he,fl:ce,fr:xe,scope:te}=P,q=P.merged;je="html",Y=te.base?F(te.base):W(te.local,"local"),J=v.bs,oe=v.be;let ae=Ue=>{let $e=te[Ue];for(let Ge=te.at-1;Ge>=0;Ge--){let et=te.units[Ge],Ot=Ue==="base"?et:g(u(Ue),et);if(Ot&&z(Ot,Ue)===$e)return Ot}return null},Ce=Ue=>()=>ne(te[Ue],ae(Ue),Ue),Le=(Ue,$e,Ge,et,Ot)=>{let xt=Gt=>Gt?Qe(f[Ot],Gt):Ce(Ot)(),Jt=$e===Ge?ot(Ue,$e):Ae(Ue,$e,"start"),Mt=$e===Ge?ot(Ue,$e):Ae(Ue,Ge,"end"),pt=xt(Jt),bt={start:pt,end:$e===Ge?pt:xt(Mt)},mt=P.full?P.full(Ot):null;if(!mt)return Ht(Ue.text,$e,Ge,et,bt,{start:xt(Ae(Ue,0,"start")),end:xt(Ae(Ue,Ue.text.length,"end"))});let It=Jt?yt(mt,Jt):null,ct=Mt?yt(mt,Mt):null,Wt=It===null?0:It,St=Math.max(Wt,ct===null?mt.text.length:ct),fn=xt(Ae(mt,0,"start"));return Ht(mt.text,Wt,St,ko(mt,Wt,St),bt,{start:fn,end:mt.text.length?xt(Ae(mt,mt.text.length,"end")):fn})};Z=P.synthetic?null:Le(he,v.bs,v.be,v.base,"base"),Oe=Le(ce,v.lss,v.lse,v.local,"local"),He=Le(xe,v.rss,v.rse,v.remote,"remote");let[We,Ne]=v.range||[0,0],ze=q.out,tt=()=>{let Ue=En(q.node);for(let $e=te.at-1;$e>=0;$e--){let Ge=j(F(te.units[$e])).filter(et=>et.parentNode===Ue);if(Ge.length)return{kind:"after",node:Ge[Ge.length-1]}}for(let $e=te.at;$e<te.units.length;$e++){let Ge=j(F(te.units[$e])).filter(et=>et.parentNode===Ue);if(Ge.length)return{kind:"before",node:Ge[0]}}return{kind:"startOf",node:q.node}};if(ze.via)for(let[Ue,$e]of ze.via)R.set(Ue,$e);let k=Xe(q,We,We===Ne?"empty":"start",tt),$=We===Ne?k:Xe(q,Ne,"end",tt),Q=ze.text.length?dt(ze,0,"start",q.node):tt(),be=ze.text.length?dt(ze,ze.text.length,"end",q.node):Q,fe=yt(ze,k),se=yt(ze,$),le=fe===null?0:fe,Be=Math.max(le,se===null?ze.text.length:se);Ie=an(Ht(ze.text,le,Be,ko(ze,le,Be),{start:gt(k),end:gt($)},{start:gt(Q),end:gt(be)}),k,$,Q,be);let Ke=S.spans.get(Ie);if(Ke.flat=ze,!ze.text.length){let Ue=gt(Q),$e=io(h,Ue),Ge=$e[0],et=$e[1];Ke.empty={parent:Ge.nodeType===11?p.get(Ge):Ge,previous:Ge.childNodes[et-1]||null,next:Ge.childNodes[et]||null}}ge=k?k.node:q.node}let G=Me(Y),ue=(P.site==="whole"||P.site==="comment"||(P.policy||c)!=="both")&&v.resolved!==v.local;return{key:P.site==="comment"&&_t.get(Y.b||Y.l||Y.r)||_(G,J,oe),subject:G,localLost:ue,anchor:ge,text:{encoding:je,base:Z,local:Oe,remote:He,merged:Ie,liveSpan:null,liveScope:null}}},me=(v,P)=>{let Y=x(P.el),J=Me(Y),oe=P.sample;return{key:`attr:${J.key}:${oe.namespaceURI||""}:${oe.localName}`,subject:J,localLost:v.resolved!==v.local,anchor:P.el,attribute:{namespaceURI:oe.namespaceURI||null,localName:oe.localName,qualifiedName:oe.name}}},pe=(v,P)=>{let Y=v.detail,J=P.unit||F(P.subject),oe=Me(J),je=S.refs.get(oe),Z=J.l?Se(J.l,"local"):null,Oe=J.r?Se(J.r,"remote"):null,He=je.length?qe(je[0]):null,Ie,ge,B,G=null,ue=null,he=P.deleted;switch(Y){case"both-reordered":{Ie=ge="reordered";let ce=new Set(P.rKept),xe=P.lKept.filter(Le=>ce.has(Le)&&j(F(Le)).length),te=Le=>A.get(j(F(Le))[0]);G=xe.map(Le=>Me(F(Le))),ue=xe.slice().sort((Le,We)=>te(Le)-te(We)).map(Le=>Me(F(Le)));let q=Le=>!cn(Le)&&Le.kind!=="comment"&&Le.nodes.every(We=>!/[^\t\n\f\r ]/.test(We.data)),ae=xe.filter(Le=>!q(Le)),Ce=ae.slice().sort((Le,We)=>te(Le)-te(We));B=ae.some((Le,We)=>Le!==Ce[We]);break}case"both-moved":Ie=ge="moved",B=!Z||!je.some(ce=>{let xe=ce===je[0]?He:qe(ce);return xe&&xe.parent===Z.parent});break;case"edit-beats-delete":Ie=he==="local"?"deleted":"edited",ge=he==="remote"?"deleted":"edited",B=he==="local";break;case"move-beats-delete":Ie=he==="local"?"deleted":"moved",ge=he==="remote"?"deleted":"moved",B=he==="local";break;case"remote-wins":Ie="edited",ge="edited",B=!0;break;default:Ie=ge="inserted",B=P.localLost}return{key:`structure:${oe.key}:${Y}`,subject:oe,localLost:B,anchor:je[0]||null,structure:{localAction:Ie,remoteAction:ge,localPlacement:Z,remotePlacement:Oe,mergedPlacement:He,localOrder:G,mergedOrder:ue,localFragment:Y==="both-reordered"||!J.l?null:ve(J.l),fragmentKind:w(J.b||J.l||J.r)}}};for(let[v,P]of l){if(v.kind!=="structure")continue;let Y=P.unit||F(P.subject),J=Y.b||Y.l||Y.r;!cn(J)&&J.kind==="comment"&&_t.set(J,`structure:${Me(Y).key}:${v.detail}`)}let ke=new Map;for(let[v,P]of l){if(v.kind==="structure"){let je=Me(P.unit||F(P.subject)),Z=`structure:${je.key}:${v.detail}`,Oe=ke.get(Z);if(Oe&&Oe.structure){v.recovery=Oe;let He=S.refs.get(je);v.el==null&&He.length&&(v.el=cn(He[0])?He[0]:f.out.logicalParent(He[0]));continue}}let Y=v.kind==="text"?ie(v,P):v.kind==="attr"?me(v,P):pe(v,P),J=ke.get(Y.key);J||(J={version:Xc,key:Y.key,localLost:Y.localLost,subject:Y.subject,applied:!1,unavailable:null},ke.set(Y.key,J),S.anchors.set(J,Y.anchor)),Y.text&&(J.text=Y.text),Y.attribute&&(J.attribute=Y.attribute),Y.structure&&(J.structure=Y.structure),Y.text&&(J.localLost=Y.localLost),v.recovery=J;let oe=S.refs.get(Y.subject);v.kind==="structure"&&v.el==null&&oe.length&&(v.el=cn(oe[0])?oe[0]:f.out.logicalParent(oe[0])),v.kind==="text"&&v.node==null&&oe.length&&Y.subject.nodeType===8&&(v.node=oe[0])}return S}}function Bi(e,n,t){if(!n)return;let{lookup:o,vetoed:r,vetoedAttrs:c,liveAttr:l}=t,i=t.ignored||(()=>!1),s=co(t.liveRoot),a=T=>!!T&&s.containerPath(T)!==null,h=T=>{let x=T.parentNode;return x&&x.nodeType===11?n.outOwners.get(x)||null:x},f=T=>{for(let x=T;x;x=h(x))if(n.via.has(x)&&(x=n.via.get(x)),r.has(x)||t.vetoedLive?.has(m(x)))return!0;return!1},u=T=>Array.from(En(T).children).filter(x=>!i(x)),g=(T,x)=>u(T)[u(x.parentNode).indexOf(x)],b=(T,x)=>{let z=null,D=null,V=0;for(let re=x.previousSibling;re;re=re.previousSibling){if(re.nodeType===1&&!i(re)){z=re;break}re.nodeType===3&&(V+=re.nodeValue.length)}for(let re=x.nextSibling;re&&!D;re=re.nextSibling)re.nodeType===1&&!i(re)&&(D=re);let Ee=z?g(T,z):null,Me=D?g(T,D):null;if(z&&!Ee||D&&!Me)return null;let De=[];for(let re=Ee?Ee.nextSibling:En(T).firstChild;re&&re!==Me;re=re.nextSibling)re.nodeType===3&&De.push(re);return De.length?{nodes:De,lead:V}:null},A=T=>{let x=[],z=T;for(;z&&!n.via.has(z);z=z.parentNode)x.push(z);if(!z||!x.length)return null;let D=m(n.via.get(z));for(let Me=x.length-1;Me>0&&D;Me--)D=g(D,x[Me]);if(!D)return null;let V=x[0];if(V.nodeType===3)return b(D,V);let Ee=V.nodeType===1?g(D,V):null;return Ee?{nodes:[Ee],lead:0}:null},p=T=>{let x=o(T),z=x?{nodes:Array.isArray(x)?x:[x],lead:0}:n.via.size?A(T):null;if(!z)return null;let D=z.nodes.filter(a);return D.length?{nodes:D,lead:z.lead}:null},m=T=>{let x=p(T);return x?x.nodes[0]:null},y=T=>{if(!T)return null;if(T.kind==="text"){let V=p(T.node);if(!V)return null;let Ee=V.nodes,Me=T.offset+V.lead,De=0;for(let re=0;re<Ee.length;re++){let Se=Ee[re].nodeValue.length;if(Me<=De+Se||re===Ee.length-1)return Me>=De&&Me<=De+Se?[Ee[re],Me-De]:null;De+=Se}return null}let x=m(T.node);if(!x)return null;if(T.kind==="end")return[En(x),En(x).childNodes.length];if(T.kind==="startOf")return[En(x),0];if(T.kind==="wholeStart")return x.firstChild?[x.firstChild,0]:[x,0];if(T.kind==="wholeEnd")return x.lastChild?[x.lastChild,x.lastChild.nodeValue.length]:[x,x.childNodes.length];let z=x.parentNode;if(!z)return null;let D=Array.prototype.indexOf.call(z.childNodes,x);return[z,T.kind==="after"?D+1:D]},R=T=>({blocks:new Set((T.flat?.marks||[]).filter(x=>x.block).map(x=>m(x.el)).filter(Boolean)),atoms:new Set((T.flat?.atoms||[]).map(x=>m(x.el)).filter(Boolean)),ignored:i}),S=(T,x,z,D)=>{if(!T||!x||!lo(T)||!lo(x))return!1;for(let Me of[T,x])if(!a(Me.startContainer)||!a(Me.endContainer))return!1;let V=z.merged;if(V.start===V.end&&(T.startContainer!==T.endContainer||T.startOffset!==T.endOffset))return!1;let Ee=R(D);return Zn(x,z.encoding,Ee)===V.text&&Zn(T,z.encoding,Ee)===V.text.slice(V.start,V.end)},O=new Map,M=T=>{let x=T.parentNode;return x?(O.has(x)||O.set(x,new Map(Array.from(x.childNodes,(z,D)=>[z,D]))),O.get(x).get(T)):-1},E=(T,x)=>{if(!x)return!1;let z=s.logicalParent(T);if(!x.parent.live.includes(z))return!1;let D=M(T);for(let[V,Ee]of[["before",1],["after",-1]]){let Me=D;for(let De of x[V]){if(De.live.includes(T))continue;let re=De.live.filter(qe=>qe!==T&&qe.parentNode===T.parentNode);if(!re.length)continue;let Se=Ee===1?Math.min(...re.map(M)):Math.max(...re.map(M));if(Ee*(Se-Me)<=0)return!1;Me=Se}}return!0},N=T=>{let x=T.structure;if(x.mergedOrder){let z=new Set(T.subject.live.map(En)),D=null,V=-1;for(let Ee of x.mergedOrder){let Me=Ee.live.find(De=>z.has(De.parentNode));if(!Me||D&&Me.parentNode!==D||M(Me)<=V)return!1;D=Me.parentNode,V=M(Me)}return T.subject.live.length>0}return T.subject.live.some(z=>E(z,x.mergedPlacement))},L=(T,x)=>{let z=y(T),D=y(x);return z&&D?{startContainer:z[0],startOffset:z[1],endContainer:D[0],endOffset:D[1]}:null},j=new Set,F=T=>{if(!T||j.has(T))return;j.add(T);let x=[];for(let z of n.refs.get(T)||[]){let D=p(z);if(D)for(let V of D.nodes)x.includes(V)||x.push(V)}T.live=x},W=T=>{T&&(F(T.parent),T.before.forEach(F),T.after.forEach(F))},C=new Set;for(let T of e){let x=T.recovery;if(!x||C.has(x))continue;C.add(x),F(x.subject),x.structure&&(W(x.structure.localPlacement),W(x.structure.remotePlacement),W(x.structure.mergedPlacement),(x.structure.localOrder||[]).forEach(F),(x.structure.mergedOrder||[]).forEach(F));let z=n.anchors.get(x),D=z?m(z):null,V=!!D;if(x.text){let w=n.spans.get(x.text.merged),K=w?L(w.start,w.end):null,ne=w?L(w.scopeStart,w.scopeEnd):null;if(w?.empty){let ee=w.empty,Pe=ee.previous?{kind:"after",node:ee.previous}:{kind:"startOf",node:ee.parent},_e=ee.next?{kind:"before",node:ee.next}:{kind:"end",node:ee.parent},Ae=L(Pe,_e);!Ae||Ae.startContainer!==Ae.endContainer||Ae.startOffset!==Ae.endOffset?K=null:K=ne=Ae}S(K,ne,x.text,w)||(K=ne=null),x.text.liveSpan=K,x.text.liveScope=K?ne:null,K||(V=!1)}x.structure&&V&&(V=N(x)),x.attribute&&V&&(V=l(D,x.attribute,T.resolved));let Ee=(!!x.attribute||!!x.text&&D?.tagName==="TEXTAREA")&&!!c&&[z,D].some(w=>c.get(w)?.has(x.attribute?x.attribute.qualifiedName:"value")),Me=n.localState?.states.get(x),De=!!x.text&&[...t.removedVetoes||[]].some(w=>Me?.touched.has(w)),re=x.structure?.localAction==="inserted"&&[...r].some(w=>w===z||z?.contains(w)),Se=z&&f(z)||Ee||De||re,qe=Se&&ji(x,T,n,a);qe&&(De||re&&x.localLost)&&(V=!1);let ve=!V&&qe&&Se;x.applied=V,x.unavailable=V?null:ve?"hook-veto":"missing-output",ve&&(x.localLost=!1),!V&&x.text&&(x.text.liveSpan=x.text.liveScope=null)}}function Sr(e,n,t){let o=co(n),r=co(t),c=f=>!!f&&r.containerPath(f)!==null,l=f=>{if(f===n)return t;let u=o.pathOf(f);if(u&&n!==t){let g=io(t,{path:u,offset:0});if(g&&g[0].nodeType===f.nodeType)return g[0]}return f},i=new Set,s=f=>{!f||i.has(f)||(i.add(f),f.live=f.live.map(l).filter(c))},a=f=>{f&&(f.startContainer=l(f.startContainer),f.endContainer=l(f.endContainer))},h=new Set;for(let f of e){f.node===n&&t.tagName==="SCRIPT"&&(f.node=t),f.el===n&&f.kind==="structure"&&(f.el=t);let u=f.recovery;if(!u||h.has(u))continue;if(h.add(u),s(u.subject),u.text){a(u.text.liveSpan),a(u.text.liveScope);let b=u.text.liveSpan,A=u.text.liveScope,p=u.text.merged,m=y=>!!y&&lo(y)&&c(y.startContainer)&&c(y.endContainer);(!m(b)||!m(A)||Zn(A,u.text.encoding)!==p.text||Zn(b,u.text.encoding)!==p.text.slice(p.start,p.end))&&(u.text.liveSpan=null,u.text.liveScope=null,u.applied=!1,u.unavailable="missing-output")}let g=u.structure;if(g){for(let b of[g.localPlacement,g.remotePlacement,g.mergedPlacement])b&&(s(b.parent),b.before.forEach(s),b.after.forEach(s));(g.localOrder||[]).forEach(s),(g.mergedOrder||[]).forEach(s),u.subject.live.length||(u.applied=!1,u.unavailable="missing-output")}}}var vo=e=>e?.nodeType===1,Fo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function Jc({provenance:e,parentOf:n,twins:t,baseOf:o,build:r,ignored:c,remoteWins:l,discarded:i}){let s=new Map,a=new WeakMap;function h(g,b,A,p=!1){if(!vo(g)||!vo(A))return null;let m=s.get(g);if(m)(p||!m.selected&&b==="remote")&&(m.parent=n(A),m.port=A,m.sourceSide=b,m.selected=p);else{let y=a.get(g)||null;m={owner:g,parent:n(A),port:A,sourceSide:b,originalParent:n(g),originalPort:g,selected:p,state:y?"built":"planned",output:y,disposition:null},s.set(g,m)}return m}function f(g,b){if(!vo(g)||!vo(b))return;a.has(g)||a.set(g,b);let A=s.get(g);A&&A.state!=="attached"&&!A.output&&(A.output=b,A.state="built")}function u(g){if(!s.size)return;let b=new Map,A=new WeakMap,p=new WeakMap,m=new WeakSet,y=new Set,R=(W,C)=>{if(!W)return;if(Array.isArray(W)){for(let x of W)R(x,C);return}let T=b.get(W);T||b.set(W,T=[]),T.push(C)},S=(W,C)=>{if(!W)return;let T=[W];for(;T.length;){let x=T.pop();R(x,C);for(let z of Fo(x).childNodes)T.push(z)}};function O(W,C=null,T=!1){if(m.has(W))return;m.add(W),A.set(W,C);let x=e.get(W),z=T||!!(x&&l(x.remote||x.base));p.set(W,z);let D={node:W,kind:"node",authority:z};if(x?.pinned)S(x.local,{...D,kind:"ignored"});else if(x?.unchanged)for(let V of[x.base,x.local,x.remote])S(V,{...D,kind:"unchanged"});else if(x){for(let V of[x.base,x.local,x.remote])R(V,D);if(vo(x.local))for(let V of Fo(x.local).children)c(V)&&S(V,{...D,kind:"ignored"})}for(let V of Fo(W).childNodes)O(V,W,z)}let M=W=>{if(W.output&&m.has(W.output))return W.state="attached",W.disposition="node",!0;let{local:C,remote:T}=t(W.owner);for(let x of[W.owner,C,T]){let z=b.get(x);if(z?.length){let D=z.find(V=>V.kind==="node")||z[0];return W.output=D.node,W.state="attached",W.disposition=D.kind,!0}}return!1},E=(W,C)=>(b.get(W)||[]).find(x=>x.kind==="node"&&vo(x.node)&&(!x.authority||C.sourceSide==="remote"))?.node,N=(W,C,T)=>{let x=b.get(W)||[],z=T?[...x].reverse():x;for(let D of z){if(D.kind!=="node")continue;let V=D.node;for(;V&&A.get(V)!==C;)V=A.get(V);if(V)return V}return null},L=(W,C,T)=>{let x=Fo(C);for(let z=T?.previousSibling;z;z=z.previousSibling){let D=N(z,C,!0);if(D){x.insertBefore(W,D.nextSibling);return}}for(let z=T?.nextSibling;z;z=z.nextSibling){let D=N(z,C,!1);if(D){x.insertBefore(W,D);return}}x.appendChild(W)};function j(W,C,T){let x=C==="base"?W:o(W,C),z=s.get(x);z&&z!==T&&F(z)}function F(W){if(W.state==="attached"||W.disposition==="remote-wins"||y.has(W)||M(W))return;y.add(W);let{local:C,remote:T}=t(W.owner);if(l(T||W.owner)){if(!T){W.disposition="remote-wins",i(W.owner,C),y.delete(W);return}W.parent=n(T),W.port=T,W.sourceSide="remote"}if(j(W.parent,W.sourceSide,W),M(W)){y.delete(W);return}let x=E(W.parent,W),z=W.port;if(!x){if(j(W.originalParent,"base",W),M(W)){y.delete(W);return}let V=W.originalParent;for(z=W.originalPort;V&&!x;)x=E(V,W),x||(z=V,V=n(V))}if(!x)throw new Error("A planned move has no allowed surviving parent");let D=W.output||r(W.owner);W.output=D,W.state="built",L(D,x,z),O(D,x,p.get(x)||!1),M(W),y.delete(W)}O(g);for(let W of s.values())F(W)}return{planned:s,has:g=>s.has(g),plan:h,produced:f,drain:u}}function Oo(e,n,t,o,r,c,l,i,s,a,h,f,u){let g=null;return Jc({provenance:e,parentOf:p=>{if(!p)return null;let m=n(p);if(m||p.parentNode?.nodeType!==11)return m;if(!g){g=new WeakMap;let y=[f,u];for(;y.length;){let R=y.pop(),S=Fo(R);S!==R&&g.set(S,R);for(let O of S.children)y.push(O)}}return g.get(p.parentNode)||null},twins:p=>({local:r(t,p),remote:r(o,p)}),baseOf:(p,m)=>p&&(m==="local"?t:o).reverse.get(p)||null,build:p=>c(p,r(t,p),r(o,p),!1),ignored:l,remoteWins:i,discarded:(p,m)=>{m&&h(p,m,t)&&!s.some(y=>y.detail==="remote-wins"&&y.base===p)&&a({kind:"structure",el:null,detail:"remote-wins",base:p,local:m,remote:null},{subject:p})}})}function Qc({parent:e,base:n,views:t,eligible:o,ignored:r,remoteWins:c,budget:l=Kt(2e4*32),maxUnits:i=256,maxCharacters:s=2e4}){let a=(m,y=null)=>({status:m,reason:y,parent:e,records:[]});if(t.some(({V:m})=>m.asBase)||r(e)||c(e)||t.some(({V:m})=>!m.el||r(m.el)||c(m.el)))return a("none");let h=n.length+t[0].V.units.length+t[1].V.units.length;if(h>i)return a("fallback","unit-limit");let f=Symbol(),u=m=>{if(m>l.remaining)throw f;l.remaining-=m,l.crossParentSteps=(l.crossParentSteps||0)+m},g=new Map,b=0,A=m=>{if(u(1),g.has(m))return g.get(m);let y=m.nodeType===1?m.childNodes:m.nodes;u(y.length*4+1);let R=m.nodeType===1?Array.from(y):y,S=0;for(let E=0;E<R.length;E++){let N=R[E];if(N.nodeType!==3||E&&R[E-1].nextSibling!==N)return g.set(m,null),null;S+=N.data.length}if(S>s-b)throw f;u(S*8+1),b+=S;let O=en(R);if(O.text.includes(wt))return g.set(m,null),null;let M={unit:m,nodes:R,flat:O};return g.set(m,M),M},p=[];try{u(h*8+1);for(let m=0;m<2;m++){let y=t[m].V,R=t[1-m].V,S=[],O=new Map;for(let M=0;M<n.length;M++){u(1);let E=n[M];if(E.kind!=="text"||y.twin(E))continue;let N=R.twin(E);if(!N||N.kind!=="text"||!R.here(N))continue;let L=A(E),j=A(N);if(!L||!j||!/\S/.test(L.flat.text))continue;u(L.flat.text.length*2+1);let F=L.flat.text;O.set(F,(O.get(F)||0)+1),S.push({source:E,opposite:N,sourceModel:L,oppositeModel:j,index:M})}for(let M of S){let{source:E,opposite:N,sourceModel:L,oppositeModel:j,index:F}=M,W=[];for(let K of[-1,1]){u(1);let ne=n[F+K];if(!ne||ne.nodeType!==1||!o(ne)||r(ne)||c(ne))continue;let ee=L.nodes[0],Pe=L.nodes.at(-1);if(K===-1?ee?.previousSibling!==ne:Pe?.nextSibling!==ne)continue;let _e=y.twin(ne),Ae=R.twin(ne);if(!_e||!Ae||!y.here(_e)||R.here(Ae)||y.baseOf(_e)!==ne||R.baseOf(Ae)!==ne||!o(_e)||!o(Ae)||r(_e)||r(Ae)||c(_e)||c(Ae)||_e.tagName!==ne.tagName||Ae.tagName!==ne.tagName||_e.namespaceURI!==ne.namespaceURI||Ae.namespaceURI!==ne.namespaceURI)continue;let ot=A(ne),Qe=A(_e),Ze=A(Ae);if(!ot||!Qe||!Ze||!/\S/.test(ot.flat.text))continue;let Xe=ot.flat.text,yt=L.flat.text,dt=Qe.flat.text;if(u((Xe.length+yt.length+dt.length)*3+1),dt.length!==Xe.length+yt.length)continue;let gt=K===-1;(gt?!dt.startsWith(Xe)||!dt.endsWith(yt):!dt.startsWith(yt)||!dt.endsWith(Xe))||W.push({owner:ne,target:_e,moved:Ae,ownerBase:ot,joined:Qe,ownerOther:Ze,targetFrom:gt?Xe.length:0,retainedFrom:gt?0:yt.length})}if(!W.length)continue;if(W.length!==1||O.get(L.flat.text)!==1)return a("fallback","ambiguous-origin");let C=W[0],{owner:T,target:x,moved:z,ownerBase:D,joined:V,ownerOther:Ee,targetFrom:Me,retainedFrom:De}=C;if(u(p.length+1),p.some(K=>K.owner===T))return a("fallback","ambiguous-owner");let re={source:E,target:x,from:0,to:L.flat.text.length,targetFrom:Me},Se=Dn({base:L.flat,side:V.flat,retained:[],transfers:[{from:re.from,to:re.to,target:Me,destination:T}],budget:l});if(Se.status!=="ready"||Se.covers(re.from,re.to)!==!0)return a("fallback",Se.reason||"work-limit");let qe=[{unit:E,model:L,from:0,to:L.flat.text.length},null,null];qe[m+1]={unit:x,model:V,from:Me,to:Me+L.flat.text.length},qe[2-m]={unit:N,model:j,from:0,to:j.flat.text.length};let ve=[D,null,null];ve[m+1]=V,ve[2-m]=Ee;let w=[T,null,null];w[m+1]=x,w[2-m]=z,p.push({side:m,parent:e,source:E,target:x,owner:T,owners:w,ownerModels:ve,native:qe,models:g,runs:[re],proof:Se,retained:[{source:T,target:x,from:0,to:D.flat.text.length,targetFrom:De}]})}}return p.length?{status:"ready",reason:null,parent:e,records:p}:a("none")}catch(m){if(m!==f)throw m;return a("fallback","work-limit")}}function Ui({describe:e,parentOf:n,...t}){let o=new WeakMap,r=new WeakMap,c=t.budget||Kt(2e4*32),l=i=>{if(!i)return null;if(o.has(i))return o.get(i);o.set(i,{status:"planning",parent:i,records:[]});let s=e(i),a=s?Qc({...t,...s,parent:i,budget:c}):{status:"none",reason:null,parent:i,records:[]};if(o.set(i,a),a.status==="ready")for(let h of a.records)r.set(h.owner,[h]);return a};return{get:l,forOwner(i){return l(n(i))?.status==="ready"&&r.get(i)||null}}}function Zc(e,n){if(e.side!==0)return null;let t=e.native[0].model,o=e.ownerModels[0],r=e.native[1].from!==0,c=(R,S)=>r?[...R.nodes,...S.nodes]:[...S.nodes,...R.nodes],l=e.ownerModels.reduce((R,S)=>R+S.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(l*8>n.remaining)return null;n.remaining-=l*8;let i={base:c(o,t),local:e.ownerModels[1].nodes,remote:c(e.ownerModels[2],e.native[2].model)},s=en(i.base),a=e.ownerModels[1].flat,h=en(i.remote),f=r?o.flat.text.length:0,u=r?0:t.flat.text.length,g=Dn({base:s,side:a,retained:e.retained.map(R=>({from:u+R.from,to:u+R.to,target:R.targetFrom})),transfers:e.runs.map(R=>({from:f+R.from,to:f+R.to,target:R.targetFrom,destination:e.owner})),budget:n});if(g.status!=="ready"||g.covers(0,s.text.length)!==!0)return null;let b=e.ownerModels[2].flat,A=e.native[2].model.flat,p=[];for(let[R,S,O,M]of[[o.flat,b,u,r?0:A.text.length],[t.flat,A,f,r?b.text.length:0]]){let E=ns(R,R,S).remoteMap.bTo,N=-1;for(let L=0;L<R.text.length;L++){if(E[L]<0){N=-1;continue}let j=p.at(-1);N>=0&&j.to===O+L&&j.target+j.to-j.from===M+E[L]?j.to++:(p.push({from:O+L,to:O+L+1,target:M+E[L]}),N=L)}}let m=Dn({base:s,side:h,retained:p,transfers:[],budget:n});if(m.status!=="ready")return null;let y=ns(s,a,h,{},{local:g,remote:m});return y.localEdits.hunks.length?null:(y.localMap=g,y.remoteMap=m,{nodes:i,prepared:y})}function Hi({L:e,R:n,twinIn:t,unitsOf:o,view:r,parentOf:c,ignored:l,remoteWins:i,eligible:s,build:a,out:h,policy:f,provenance:u,textMappers:g,segments:b,conflicts:A,conflict:p,decisions:m}){let y=Kt(2e4*32),R=W=>{let C=0;for(let T=W;T;T=c(T))if(++C>64||T.nodeType===1&&(l(T)||i(T)))return!1;return!0},S=Ui({parentOf:c,eligible:s,ignored:l,remoteWins:i,budget:y,describe(W){let C=t(e,W),T=t(n,W);return!C||!T||!R(W)||!R(C)||!R(T)?null:{base:o(W),views:[{A:e,V:r(e,C,W,!1)},{A:n,V:r(n,T,W,!1)}]}}}),O=new WeakSet,M=new WeakMap,E=new WeakSet,N=[];function L(W){if(!W||O.has(W))return;O.add(W);let C=S.get(W);if(C?.status==="ready")for(let T of C.records){if((W.tagName==="TEMPLATE"&&W.content?W.content:W).childNodes.length!==T.native[0].model.nodes.length+1||!T.owners.every(R))continue;let z=Zc(T,y);if(!z)continue;let D={record:T,payload:z,state:"planned",output:null,result:null};M.set(T.owner,D),E.add(T.source),E.add(T.native[2].unit),N.push(D)}}function j(W,C){let T=M.get(W);if(!T)return!1;if(!T.result){if(T.result=so({...T.payload.nodes,prepared:T.payload.prepared,out:h,policy:f,provenance:u,textMappers:g,conflicts:A,conflict:p,decisions:m,node:C}),T.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");b.push(...T.result.segments),T.decision={kind:"text",node:C,source:"local"},m.push(T.decision)}return T.decision.node=C,C.replaceChildren(...T.result.nodes),T.output=C,T.state="built",!0}function F(W){if(!N.length)return;let C=new WeakSet,T=new WeakMap,x=new WeakMap,z=new WeakMap,D=Se=>Se.tagName==="TEMPLATE"&&Se.content?Se.content:Se,V=(Se,qe)=>{if(!Se)return;if(Array.isArray(Se)){for(let w of Se)V(w,qe);return}let ve=z.get(Se);ve||z.set(Se,ve=[]),ve.push(qe)},Ee=(Se,qe=null,ve=!1)=>{C.add(Se),T.set(Se,qe);let w=u.get(Se),K=ve||!!(w&&i(w.remote||w.base));if(x.set(Se,K),w)for(let ne of[w.base,w.local,w.remote])V(ne,Se);if(!(w?.pinned||w?.unchanged))for(let ne of D(Se).childNodes)Ee(ne,Se,K)},Me=Se=>(z.get(Se)||[]).find(qe=>qe.nodeType===1&&!x.get(qe)&&!u.get(qe)?.pinned&&!u.get(qe)?.unchanged),De=(Se,qe)=>{for(let ve of z.get(Se)||[]){let w=ve;for(;w&&T.get(w)!==qe;)w=T.get(w);if(w)return w}return null},re=(Se,qe,ve)=>{let w=D(qe);for(let K=ve.nextSibling;K;K=K.nextSibling){let ne=De(K,qe);if(ne){w.insertBefore(Se,ne);return}}for(let K=ve.previousSibling;K;K=K.previousSibling){let ne=De(K,qe);if(ne){w.insertBefore(Se,ne.nextSibling);return}}w.appendChild(Se)};Ee(W);for(let Se of N){let{record:qe}=Se,ve=Me(qe.owner)||Me(qe.owners[1])||Me(qe.owners[2]);if(ve)(!Se.result||Se.output!==ve||Se.result.nodes.some(w=>!C.has(w)||T.get(w)!==ve)||ve.textContent!==Se.result.text)&&(j(qe.owner,ve),Ee(ve,T.get(ve),x.get(ve)));else{let w=qe.parent,K=qe.owner,ne=null;for(;w&&!ne;)ne=Me(w),ne||(K=w,w=c(w));if(!ne)throw new Error("A cross-parent payload has no allowed surviving parent");ve=Se.output||a(qe.owner,qe.owners[1],qe.owners[2],!1),Se.result||j(qe.owner,ve),re(ve,ne,K),Ee(ve,ne,x.get(ne))}Se.state="attached"}}return{ensureParent:L,ensureOwner(W){L(c(W))},consumes(W){return E.has(W)},render:j,drain:F}}var Sn=/\S/,Wi=/[\p{L}\p{N}]/u;function ao(e,n,t,o){if(e?.nodeType!==1||!n(e))return!1;for(let r=e.firstChild;r;r=r.nextSibling)if(o(t,1),r.nodeType!==3)return!1;return!!e.firstChild}function ls(e,n,t){for(let o=e.parentNode;o;o=o.parentNode)if(t(n,1),o.nodeType===11)return!1;return!0}function Vi(e,n,t,o,r){let c=t(e,o),l=t(n,o),i=null,s=null,a=null,h=null;r(o,c.length+l.length);for(let f of c)Wi.test(f.raw)&&(i||=f,s=f);for(let f of l)Wi.test(f.raw)&&(a||=f,h=f);return!!(i&&a&&(i.raw===a.raw||s.raw===h.raw))}function ea({base:e,V:n,A:t,source:o,original:r,current:c,edited:l,destination:i,at:s,ownLength:a,eligible:h,model:f,tokensOf:u,budget:g,charge:b}){let A=r.flat.text,p=c.flat.text,m=l.flat.text,y=i.flat.text;if(b(g,A.length+p.length+y.length),A.startsWith(p)||A.endsWith(p))return!1;let R=Sn.test(y.slice(0,s)),S=Sn.test(y.slice(s+a));if(R===S)return!1;let O=R?0:s+a,M=R?s:y.length;for(;O<M&&!Sn.test(y[O]);)O++;for(;M>O&&!Sn.test(y[M-1]);)M--;let E=y.slice(O,M);if(Mn(E,y,u(i,g),g,b,!0)!==O)return!1;let N=Mn(E,A,u(r,g),g,b,!0);if(N<0)return!1;let L=N+E.length,j=!Sn.test(A.slice(0,N)),F=!Sn.test(A.slice(L));if(j===F||Mn(E,p,u(c,g),g,b,!1)>=0)return!1;let W=j?A.slice(L):A.slice(0,N),C=j?m.length-W.length:0;if(b(g,A.length+m.length),C<0||!Sn.test(W)||Mn(W,m,u(l,g),g,b,!0)!==C||!Sn.test(j?m.slice(0,C):m.slice(W.length)))return!1;for(let T of e){if(b(g,1),T===o||!ao(T,h,g,b))continue;let x=f(T,null,g);if(Mn(E,x.flat.text,u(x,g),g,b,!1)>=0)return!1}for(let T of n.units){if(b(g,1),T===c.unit||T===i.unit||!ao(T,h,g,b))continue;let x=f(T,t,g);if(Mn(E,x.flat.text,u(x,g),g,b,!1)>=0)return!1}return!0}function _i({base:e,views:n,side:t,attempt:o,eligible:r,blocked:c,baseId:l,model:i,tokensOf:s,charge:a,exhausted:h,limit:f}){if(f<=0)return null;let u=Kt(f),{V:g,A:b,idOf:A}=n[t],p=n[1-t],[m,y,R,S]=o,O=null;try{for(let M=m;M<=y;M++){a(u,1);let E=e[M];if(E.parentNode?.nodeType!==1||c.has(E)||b.identical.has(E)||p.A.identical.has(E)||!ao(E,r,u,a)||l(E))continue;let N=g.twin(E),L=p.V.twin(E);if(!N||!L||!g.here(N)||!p.V.here(L)||b.map.get(E)!==N||b.reverse.get(N)!==E||p.A.map.get(E)!==L||p.A.reverse.get(L)!==E||A(N)||p.idOf(L)||N.tagName!==E.tagName||L.tagName!==E.tagName||!ao(N,r,u,a)||!ao(L,r,u,a)||!ls(E,u,a)||!ls(N,u,a)||!ls(L,u,a))continue;let j=i(E,null,u),F=i(N,b,u),W=i(L,p.A,u),C=j.flat.text,T=F.flat.text,x=W.flat.text;if(a(u,C.length+T.length+x.length),!Sn.test(C)||!Sn.test(T)||!Sn.test(x)||C===T||C===x||T===x||!Vi(j,F,s,u,a)||!Vi(j,W,s,u,a))continue;let z=null,D=!1;for(let Me=R;Me<=S;Me++){a(u,1);let De=g.units[Me],re=g.baseOf(De);if(!re||re===E||c.has(re)||re.parentNode!==E.parentNode||De.parentNode!==N.parentNode||re.tagName!==E.tagName||De.tagName!==E.tagName||b.map.get(re)!==De||b.reverse.get(De)!==re||l(re)!==A(De)||!ao(re,r,u,a)||!ao(De,r,u,a))continue;let Se=i(re,null,u),qe=i(De,b,u),ve=Se.flat.text,w=qe.flat.text;if(a(u,ve.length),!Sn.test(ve)||w.length<=ve.length)continue;let K=s(qe,u),ne=Mn(ve,w,K,u,a,!0);if(!(ne<0||Mn(C,w,K,u,a,!0,ne,ne+ve.length)<0&&!ea({base:e,V:g,A:b,source:E,original:j,current:F,edited:W,destination:qe,at:ne,ownLength:ve.length,eligible:r,model:i,tokensOf:s,budget:u,charge:a}))){if(z){D=!0;break}z=De}}if(!z||D)continue;let V=t===0?N:L,Ee=t===0?L:N;(O||=[]).push({source:E,local:V,remote:Ee,models:[j,t===0?F:W,t===0?W:F]})}}catch(M){if(M!==h)throw M}return O}var Hn=/\S/,pn=/\s/,ta=/[\s\u001e]/g,cs=/[^\s\p{P}\u001e\ufffc]/u;function na(e,n,t,o,r,c,l){let i=0;for(let s of e)l(c,1),s.nodeType===1&&!o.baseOf(s)&&i++;if(i<2)return!1;for(let s of e){if(s.nodeType!==1||o.baseOf(s))continue;let a=r.get(s).flat;if(a.atoms.length||a.pins?.length)continue;l(c,a.text.length*2+n.length+t.length);let h=new Uint8Array(a.text.length);for(let f of t)f.target===s&&h.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f of n)f.target===s&&h.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f=0;f<a.text.length;f++)if(!h[f]&&Hn.test(a.text[f]))return!0}return!1}function oa(e,n,t){let{source:o,models:r,retained:c,runs:l}=e,i=r.get(o).flat.text;t(n,i.length*2+c.length+l.length);let s=new Uint8Array(i.length);for(let a of c)a.source===o&&(t(n,a.to-a.from),s.fill(1,a.from,a.to));for(let a of l)t(n,a.to-a.from),s.fill(1,a.from,a.to);for(let a=0;a<i.length;a++)if(!s[a]&&Hn.test(i[a]))return!1;return!0}function ra(e,n,t,o,r,c,l,i,s,a){let h=c.get(e),f=c.get(n),u=h.flat.text,g=l.get(e);s(a,u.length*2+t.length);let b=u.length,A=0;for(let y=0;y<u.length;y++)!pn.test(u[y])&&!g[y]&&(b=Math.min(b,y),A=y+1);if(b>=A)return null;for(let y=b;y<A;y++)if(!pn.test(u[y])&&g[y])return null;let p=-1;for(let y of t)if(y.target===n&&y.from<=b&&y.to>b){p=y.targetFrom+b-y.from;break}if(p<0)return null;let m=u.slice(b,A);if(s(a,m.length*(t.length+2)),f.flat.text.slice(p,p+m.length)!==m)return null;for(let y=b;y<A;y++){if(pn.test(u[y]))continue;let R=!1;for(let S of t)if(S.target===n&&S.from<=y&&S.to>y&&S.targetFrom+y-S.from===p+y-b){R=!0;break}if(!R)return null}if(h.flat.atoms.length||f.flat.atoms.length){s(a,h.flat.atoms.length+f.flat.atoms.length);let y=0,R=f.flat.atoms;for(;y<R.length&&R[y].i<p;)y++;for(let S of h.flat.atoms){if(S.i<b||S.i>=A)continue;let O=R[y++];if(!O||O.i!==p+S.i-b||f.alignment?.reverse.get(O.el)!==S.el)return null}if(y<R.length&&R[y].i<p+A-b)return null}for(let[y,R,S]of[[o,e,b],[r,n,p]]){let O=!1;for(let M of y){let E=c.get(M),N=l.get(M),L=i(E,a);for(let j=0;j<L.length;j++){let F=L[j].from,W=F+m.length;if(s(a,m.length*2+1),E.flat.text.slice(F,W)!==m)continue;let C=j;for(;C<L.length&&L[C].to<W;)s(a,1),C++;if(C===L.length||L[C].to!==W)continue;let T=!0;for(let x=F;x<W;x++)if(!pn.test(E.flat.text[x])&&N[x]){T=!1;break}if(T){if(O||M!==R||F!==S)return null;O=!0}}}if(!O)return null}return m}function sa(e,n,t,o,r,c,l,i){if(l(i,r.length+c.length+(o.length+1)*t.length*2),!t)return!1;let s=o.indexOf(t);return s<0||o.lastIndexOf(t)!==s||!c.some(a=>a.from===s)||!c.some(a=>a.to===s+t.length)?!1:r.some(a=>a.source===e&&a.target===n&&a.from===0&&a.to===t.length&&a.targetFrom===s)}function Fi({base:e,views:n,eligible:t,baseId:o,ignored:r,remoteWins:c,atomKey:l,limit:i=2e4*8}){if(i<=0)return null;let s=Symbol(),a=(S,O)=>{if(O>S.remaining)throw s;S.remaining-=O},h=[new Map,new Map];for(let S=0;S<2;S++)for(let O=0;O<n[S].V.units.length;O++)h[S].set(n[S].V.units[O],O);let f=new Int32Array(e.length),u=new Int32Array(e.length),g=S=>n.every(({V:O},M)=>{let E=O.twin(S);return E&&h[M].has(E)}),b=-1;for(let S=0;S<e.length;S++)f[S]=b,g(e[S])&&(b=S);b=e.length;for(let S=e.length-1;S>=0;S--)u[S]=b,g(e[S])&&(b=S);let A=new Map,p=(S,O)=>{if(a(O,1),A.has(S))return A.get(S);let M=S.firstChild,E=1;for(;M;){if(a(O,E*8+8),M.nodeType===3&&a(O,M.data.length*8),M.nodeType===1&&wn.has(M.tagName)&&!r(M)&&!c(M)&&M.firstChild){M=M.firstChild,E++;continue}for(;M&&M!==S&&!M.nextSibling;)M=M.parentNode,E--;M=!M||M===S?null:M.nextSibling}let N=en(Array.from(S.childNodes),{ignored:r,remoteWins:c});return A.set(S,N),N},m=(S,O,M,E,N,L)=>{for(let j of S.atoms){a(L,1);let F=O.atomAt.get(j.i+M);if(!F)return!1;let W=E?.reverse.get(j.el)||l(j.el),C=N?.reverse.get(F.el)||l(F.el);if(W!==C)return!1}return!0},y=(S,O,M,E,N)=>{let L=S.text.length<=O.text.length?S:O,j=L===S?O:S;if(a(N,L.text.length+j.text.length),!L.text||!Hn.test(L.text.replaceAll(Bn,"")))return!1;let F;if(L.text===j.text)F=0;else{let W=j.text.length-L.text.length;if(a(N,(W+1)*L.text.length*2),j.text.startsWith(L.text))F=0;else if(j.text.endsWith(L.text))F=W;else return!1;if(j.text.indexOf(L.text)!==F||j.text.lastIndexOf(L.text)!==F)return!1;a(N,j.text.length*2);let C=0,T=F===0,x=!1;for(let z of ln(j.text,yn(j.text)))C+=z.len,C===F&&(T=!0),C===F+L.text.length&&(x=!0);if(!T||!x)return!1}return L===S?m(L,j,F,M,E,N):m(L,j,F,E,M,N)},R=null;for(let S=0;S<2;S++){let{V:O,A:M,idOf:E}=n[S],N=n[1-S];if(!O.asBase)for(let L=0;L<e.length;L++){let j=e[L];if(O.twin(j)||!t(j))continue;let F=N.V.twin(j);if(!F||!h[1-S].has(F)||!t(F))continue;let W={remaining:i};try{let C=f[L],T=u[L],x=0;for(let Ee=C+1;Ee<T;Ee++)a(W,1),!O.twin(e[Ee])&&N.V.twin(e[Ee])&&t(e[Ee])&&x++;if(x!==1||p(j,W).text===p(F,W).text)continue;let z=C<0?-1:h[S].get(O.twin(e[C])),D=T===e.length?O.units.length:h[S].get(O.twin(e[T]));if(z===void 0||D===void 0||z>=D)continue;let V=null;for(let Ee=z+1;Ee<D;Ee++){a(W,1);let Me=O.units[Ee];if(O.baseOf(Me)||!t(Me)||Me.tagName!==j.tagName||Me.namespaceURI!==j.namespaceURI)continue;let De=o(j),re=N.idOf(F),Se=E(Me);if(!(De&&re&&De!==re||De&&Se&&De!==Se||re&&Se&&re!==Se)&&y(p(F,W),p(Me,W),N.A,M,W)){if(V){V=null;break}V=Me}}if(!V)continue;R||(R=[new Map,new Map]),R[S].set(j,V)}catch(C){if(C!==s)throw C}}}return R?n.map(({V:S},O)=>{let M=R[O];if(!M.size)return S;let E=new Map;for(let[N,L]of M)E.set(L,N);return{...S,twin:N=>M.get(N)||S.twin(N),baseOf:N=>E.get(N)||S.baseOf(N)}}):null}function $i({onUncertainSource:e,onUncertainOwner:n,base:t,views:o,eligible:r,ignored:c,remoteWins:l,baseId:i,atomKey:s,limit:a=2e4*32}){if(a<=0)return null;let h=new Set(t),f=new Map(t.map((C,T)=>[C,T])),u=new Map,g=[],b=null,A=null,p=null,m=new Set;for(let C of t)for(let{V:T}of o){let x=T.twin(C);x&&!T.asBase&&!T.here(x)&&m.add(C)}let y=new Set,R=Symbol(),S=(C,T)=>{if(T>C.remaining)throw R;C.remaining-=T},O=(C,T,x)=>{S(x,1);let z=u.get(C);if(z)return z;if(C.nodeType===1){let Ee=C.firstChild,Me=1;for(;Ee;){if(S(x,Me*8+8),Ee.nodeType===3&&S(x,Ee.data.length*8),Ee.nodeType===1&&wn.has(Ee.tagName)&&!c(Ee)&&!l(Ee)&&Ee.firstChild){Ee=Ee.firstChild,Me++;continue}for(;Ee&&Ee!==C&&!Ee.nextSibling;)Ee=Ee.parentNode,Me--;Ee=!Ee||Ee===C?null:Ee.nextSibling}}else S(x,C.value.length*8+C.nodes.length);let D=C.nodeType===1?Array.from(C.childNodes):C.nodes,V=D.length===1&&D[0].nodeType===3?{text:D[0].data,nodes:[{node:D[0],s:0,e:D[0].data.length}],atoms:[]}:en(D,{ignored:c,remoteWins:l});return z={unit:C,flat:V,alignment:T,tokens:null},u.set(C,z),z},M=(C,T)=>{if(C.tokens)return C.tokens;S(T,C.flat.text.length*8);let{unit:x,flat:z,alignment:D}=C,V=[],Ee=yn(z.text),Me=0,De=re=>{for(let Se of ln(z.text.slice(Me,re),Ee))Se.from=Me,Se.to=Me+Se.len,Se.unit=x,V.push(Se),Me+=Se.len};for(let re of z.atoms){De(re.i);let Se=l(re.el)&&re.el.nodeType===1?"w"+re.el.tagName+"#"+(re.el.id||""):s(D?.reverse.get(re.el)||re.el);V.push({k:Se,raw:Bn,len:1,from:Me,to:Me+1,unit:x,atom:!0}),Me++}return De(z.text.length),C.tokens=V,V},E=(C,T,x,z,D)=>{if(!C.flat.atoms.length&&!T.flat.atoms.length)return!0;let V=M(C,D),Ee=M(T,D);S(D,V.length+Ee.length);let Me=0;for(let De of Ee){if(!De.atom||De.from<x||De.from>=x+z)continue;for(;Me<V.length&&!V[Me].atom;)Me++;let re=V[Me++];if(!re||re.from!==De.from-x||re.k!==De.k)return!1}for(;Me<V.length;)if(V[Me++].atom)return!1;return!0},N=(C,T,x)=>{let z=C.length+T.length+4;if(z*8>x.remaining)return null;x.remaining-=z*8;let D=Math.floor(x.remaining/8),V=Math.min(C.length+T.length,4e3,Math.floor((Math.sqrt(z*z+D)-z)/2)),Ee=4*(V+1)*(z+V+1);if(V<1||Ee>x.remaining)return null;x.remaining-=Ee;let Me=Kn(C,T,V),De=[],re=0,Se=0;for(let qe of Me.hunks){for(;re<qe.bs;)C[re].raw===T[Se].raw&&De.push([C[re],T[Se]]),re++,Se++;re=qe.be,Se+=qe.toks.length}for(;re<C.length&&Se<T.length;)C[re].raw===T[Se].raw&&De.push([C[re],T[Se]]),re++,Se++;return De},L=(C,T,x,z,D,V,Ee)=>{if(D<=z)return;let Me=C[C.length-1];if(Me&&Me.source===T&&Me.target===x&&Me.to<=z&&Me.targetFrom-Me.from===V-z){S(Ee,(z-Me.to)*3);let De=u.get(T).flat.text,re=u.get(x).flat.text,Se=!0;for(let qe=Me.to;qe<z;qe++)if(!pn.test(De[qe])||De[qe]!==re[V+qe-z]){Se=!1;break}if(Se){Me.to=D;return}}C.push({source:T,target:x,from:z,to:D,targetFrom:V})},j=C=>C.replace(ta,"");for(let C=0;C<o.length;C++){let{V:T,A:x,idOf:z}=o[C];if(T.asBase)continue;let D=new Map(T.units.map((w,K)=>[w,K])),V=w=>{let K=T.twin(w);return K&&D.has(K)?K:null},Ee=(w,K)=>{let ne=new Int32Array(w.length),ee=new Int32Array(w.length),Pe=-1;for(let _e=0;_e<w.length;_e++)ne[_e]=Pe,K(w[_e])&&(Pe=_e);Pe=w.length;for(let _e=w.length-1;_e>=0;_e--)ee[_e]=Pe,K(w[_e])&&(Pe=_e);return{prev:ne,next:ee}},Me=Ee(t,w=>(w.nodeType===1||w.kind==="text"&&Hn.test(w.value))&&V(w)),De=Ee(T.units,w=>(w.nodeType===1||w.kind==="text"&&Hn.test(w.value))&&h.has(T.baseOf(w))),re=new Map,Se=(w,K,ne,ee)=>{if(w>K||ne>ee)return;let Pe=`${w}:${K}:${ne}:${ee}`;re.set(Pe,[w,K,ne,ee])};for(let w=0;w<T.units.length;w++){let K=T.units[w];if(T.baseOf(K)||!r(K))continue;let ne=De.prev[w],ee=De.next[w],Pe=ne<0?0:f.get(T.baseOf(T.units[ne])),_e=ee===T.units.length?t.length-1:f.get(T.baseOf(T.units[ee]));Se(Pe,_e,Math.max(0,ne),Math.min(T.units.length-1,ee))}for(let w=0;w<t.length;w++){let K=t[w];if(m.has(K)||!r(K))continue;if(!T.twin(K)){let ot=Me.prev[w],Qe=Me.next[w],Ze=ot<0?0:D.get(V(t[ot])),Xe=Qe===t.length?T.units.length-1:D.get(V(t[Qe]));Se(Math.max(0,ot),Math.min(t.length-1,Qe),Ze,Xe)}let ne=V(K);if(!ne||x.identical.has(K)||!r(ne))continue;let ee=w+1;for(;ee<t.length&&t[ee].kind==="text"&&!t[ee].value.trim();)ee++;if(ee>=t.length||!r(t[ee]))continue;let Pe=V(t[ee]);if(!Pe||x.identical.has(t[ee])||!r(Pe))continue;let _e=D.get(ne),Ae=D.get(Pe);_e<Ae&&Se(w,ee,_e,Ae)}let qe=Array.from(re.values()),ve=new Set;if(qe.length>1){let w=Kt(a);try{S(w,qe.length*4);let K=qe.slice().sort((Pe,_e)=>(S(w,1),Pe[0]-_e[0]||Pe[2]-_e[2])),ne=[],ee=null;for(let Pe of K)S(w,1),ee&&Pe[0]<=ee[1]&&Pe[2]<=ee[3]&&Pe[3]>=ee[2]?(ee[1]=Math.max(ee[1],Pe[1]),ee[2]=Math.min(ee[2],Pe[2]),ee[3]=Math.max(ee[3],Pe[3]),ee[4].push(Pe)):(ee?.[4].length>1&&ne.push(ee),ee=[Pe[0],Pe[1],Pe[2],Pe[3],[Pe]]);ee?.[4].length>1&&ne.push(ee),qe=ne.concat(qe)}catch(K){if(K!==R)throw K}}for(let w of qe){if(ve.has(w))continue;let[K,ne,ee,Pe,_e]=w,Ae=Kt(a),ot=[],Qe=new Set,Ze=!1;try{S(Ae,(ne-K+Pe-ee+2)*4);let Xe=t.slice(K,ne+1).filter(Z=>!x.identical.has(Z)&&r(Z)&&!m.has(Z)),yt=T.units.slice(ee,Pe+1).filter(Z=>r(Z)&&(!T.baseOf(Z)||h.has(T.baseOf(Z)))&&!x.identical.has(T.baseOf(Z))&&!m.has(T.baseOf(Z))),dt=new Set(yt),gt=!1,qt="",$t="",Ht=0;for(let Z of Xe){let Oe=O(Z,null,Ae);qt+=Oe.flat.text,Ht+=Oe.flat.text.length}for(let Z of yt){let Oe=O(Z,x,Ae);$t+=Oe.flat.text,Ht+=Oe.flat.text.length}S(Ae,Ht);let jt=j(qt),an=j($t),_t=jt===an;if(Ze=_t,_e&&!_t)continue;let zt=_t?null:new Map;if(zt)for(let Z of Xe.concat(yt)){let Oe=u.get(Z).flat.text.length;S(Ae,Oe*16),zt.set(Z,new Uint8Array(Oe))}let _=Z=>{let Oe=[];for(let He of Z){let Ie=u.get(He);Ie.flat.atoms.length?Oe.push(...M(Ie,Ae)):Oe.push({unit:He,raw:Ie.flat.text,from:0})}return Oe},ie=[];for(let Z of _t?[]:Xe){let Oe=V(Z);if(!dt.has(Oe))continue;let He=O(Z,null,Ae),Ie=O(Oe,x,Ae);S(Ae,He.flat.text.length+Ie.flat.text.length);let ge=He.flat.text&&Ie.flat.text.startsWith(He.flat.text)?0:He.flat.text&&Ie.flat.text.endsWith(He.flat.text)?Ie.flat.text.length-He.flat.text.length:-1;if(ge>=0&&E(He,Ie,ge,He.flat.text.length,Ae)){zt.get(Z).fill(1),zt.get(Oe).fill(1,ge,ge+He.flat.text.length),L(ie,Z,Oe,0,He.flat.text.length,ge,Ae);continue}let B=N(M(He,Ae),M(Ie,Ae),Ae);if(!B){gt=!0;break}for(let[G,ue]of B)zt.get(Z).fill(1,G.from,G.to),zt.get(Oe).fill(1,ue.from,ue.to),L(ie,Z,Oe,G.from,G.to,ue.from,Ae)}if(gt)continue;let me=null,pe=null;if(!_t)for(let Z of Xe){let Oe=V(Z),He=u.get(Z);if(!Oe||He.flat.atoms.length||!dt.has(Oe))continue;let Ie=He.flat.text,ge=zt.get(Z);S(Ae,Ie.length*3+yt.length);let B=-1,G=-1,ue=!1;for(let We=0;We<Ie.length;We++)pn.test(Ie[We])||(ge[We]?ue=!0:(B<0&&(B=We),G=We+1));if(!ue||B<0)continue;let he=!0;for(let We=B;We<G;We++)if(ge[We]&&!pn.test(Ie[We])){he=!1;break}if(!he)continue;let ce=j(Ie.slice(B,G)),xe=null,te=!1;for(let We of yt){if(T.baseOf(We))continue;let Ne=u.get(We);if(!Ne.flat.atoms.length&&(S(Ae,Ne.flat.text.length),j(Ne.flat.text)===ce)){if(xe){te=!0;break}xe=We}}if(te){(pe||=new Set).add(Z);continue}if(!xe||pe?.has(Z))continue;let q=!1;for(let We of Xe){if(We===Z||!dt.has(V(We)))continue;let Ne=u.get(We);if(Ne.flat.atoms.length)continue;let ze=zt.get(We);S(Ae,Ne.flat.text.length*3);let tt="",k=!1;for(let $=0;$<Ne.flat.text.length;$++)pn.test(Ne.flat.text[$])||(ze[$]?k=!0:tt+=Ne.flat.text[$]);k&&tt===ce&&(pe||=new Set,pe.add(Z),pe.add(We),q=!0)}if(q)continue;let ae=u.get(xe).flat.text;S(Ae,G-B+ae.length);let Ce=B,Le=0;for(;Ce<G&&Le<ae.length;){for(;Ce<G&&pn.test(Ie[Ce]);)Ce++;for(;Le<ae.length&&pn.test(ae[Le]);)Le++;if(Ce>=G||Le>=ae.length)break;L(me||=[],Z,xe,Ce,Ce+1,Le,Ae),Ce++,Le++}ge.fill(1,B,G),zt.get(xe).fill(1)}let ke=Z=>{let Oe=[];for(let He of Z){let Ie=O(He,h.has(He)?null:x,Ae),ge=zt.get(He);for(let B of M(Ie,Ae)){let G=B.from;for(;G<B.to;){for(;G<B.to&&ge[G];)G++;let ue=G;for(;G<B.to&&!ge[G];)G++;if(G>ue){let he=Ie.flat.text.slice(ue,G);Hn.test(he)&&Oe.push({...B,raw:he,len:G-ue,k:B.atom?B.k:he,from:ue,to:G})}}}}return Oe},v=_t?_(Xe):ke(Xe),P=_t?_(yt):ke(yt),Y=_t?jt:v.map(Z=>j(Z.raw)).join(""),J=_t?an:P.map(Z=>j(Z.raw)).join("");if((!Y||!J)&&!me)continue;let oe=me||[];if(Y&&J&&Y===J){let Z=0,Oe=0,He=0,Ie=0;for(;Z<v.length&&Oe<P.length;){let ge=v[Z],B=P[Oe];for(;He<ge.raw.length&&pn.test(ge.raw[He]);)He++;for(;Ie<B.raw.length&&pn.test(B.raw[Ie]);)Ie++;if(He===ge.raw.length){Z++,He=0;continue}if(Ie===B.raw.length){Oe++,Ie=0;continue}if((ge.atom||B.atom)&&ge.k!==B.k){gt=!0;break}L(oe,ge.unit,B.unit,ge.from+He,ge.from+He+1,B.from+Ie,Ae),He++,Ie++}}else if(Y&&J){let Z=N(v,P,Ae);if(!Z)continue;for(let[Oe,He]of Z)L(oe,Oe.unit,He.unit,Oe.from,Oe.to,He.from,Ae)}if(gt)continue;let je=new Map;for(let Z of oe)if(!pe?.has(Z.source)){if(V(Z.source)===Z.target){_t&&ie.push(Z);continue}je.has(Z.source)||je.set(Z.source,[]),je.get(Z.source).push(Z)}for(let[Z,Oe]of je){let He=O(Z,null,Ae),Ie=V(Z),ge=He.flat.text,B=[],G=new Set,ue=o[1-C],he=ue.V.twin(Z),ce=he&&ue.V.here(he)?O(he,ue.A,Ae):null,xe=(Ne,ze)=>{let tt=M(Ne,Ae),k=M(ze,Ae);return S(Ae,Ne.flat.text.length+ze.flat.text.length+tt.length+k.length),Ne.flat.text===ze.flat.text&&tt.length===k.length&&tt.every(($,Q)=>$.k===k[Q].k)},te=Ie&&ce&&ce.flat.text!==ge&&xe(O(Ie,x,Ae),ce);for(let Ne of new Set(Oe.map(ze=>ze.target))){if(Z.nodeType!==1&&Ne.nodeType!==1)continue;let ze=O(Ne,x,Ae),tt=T.baseOf(Ne);if(Z.nodeType!==1&&tt||(S(Ae,ge.length*2+ze.flat.text.length*3+ie.length*2),Ie&&j(ge)===j(ze.flat.text)&&O(Ie,x,Ae).flat.text.trim()))continue;if(!Ie&&!tt&&Z.nodeType===1&&Ne.nodeType===1){let fe=i(Z),se=z(Ne);if(fe&&se&&fe!==se)continue}let k=ze.flat.text,$=ge&&(k.startsWith(ge)||k.endsWith(ge)),Q=!1;if(!Ie&&ce&&tt&&ce.flat.text!==ge){let fe=O(tt,null,Ae).flat.text,se=f.get(Z)<f.get(tt)?ce.flat.text:fe,le=f.get(Z)<f.get(tt)?fe:ce.flat.text;S(Ae,se.length+le.length+k.length),Q=!!se&&!!le&&se.length+le.length<=k.length&&k.startsWith(se)&&k.endsWith(le)&&!k.slice(se.length,k.length-le.length).trim()}let be=!He.flat.atoms.length&&!ce?.flat.atoms.length&&!ze.flat.atoms.length&&(te&&$||Q);if(Ie&&tt){let fe=O(Ie,x,Ae).flat.text,se=ge.startsWith(fe)||ge.endsWith(fe),le=O(tt,null,Ae).flat.text,Be=ze.flat.text,Ke=Be.startsWith(le)||Be.endsWith(le),Ue=!o[1-C].V.twin(tt)&&!ie.some($e=>$e.source===tt&&Hn.test(le.slice($e.from,$e.to)));if(!_t&&(!se&&!be||!Ke&&!Ue)){let $e=ra(Z,Ne,Oe,Xe,yt,u,zt,M,S,Ae);if(!$e)continue;let Ge=x.weak?.has(Z)&&!x.identityPaired?.has(Z)&&ge.trim()===$e;if(!se&&!be&&!Ge)continue;let et=x.weak?.has(tt)&&!x.identityPaired?.has(tt)&&k.trim()===$e&&!u.get(tt).flat.atoms.length&&!ie.some(Ot=>Ot.source===tt&&Hn.test(le.slice(Ot.from,Ot.to)));if(!Ke&&!Ue&&!et&&!sa(tt,Ne,le,k,ie,M(ze,Ae),S,Ae))continue;Ge&&G.add(Ne)}}be&&G.add(Ne),S(Ae,Oe.length),B.push(...Oe.filter(fe=>fe.target===Ne))}if(!B.length)continue;let q=new Uint8Array(ge.length);S(Ae,ge.length*4+ie.length);for(let Ne of B)q.fill(1,Ne.from,Ne.to);let ae=[];for(let Ne=0;Ne<ge.length;Ne++)pn.test(ge[Ne])||ae.push(Ne);if(!ae.length)continue;let Ce=new Set(B.map(Ne=>Ne.target));if(!_t&&Ie&&Ce.size>1&&na(Ce,oe,ie,T,u,Ae,S)){if(p||=new Map,p.set(Z,(p.get(Z)||0)|1<<C),e){let Ne=es({source:Z,side:C,views:o,eligible:r,blocked:m,baseId:i,model:O,tokensOf:M,budget:Ae,charge:S});if(Ne){S(Ae,Ne.to-Ne.from);let ze=!0;for(let tt=Ne.from;tt<Ne.to;tt++)if(Hn.test(ge[tt])&&!q[tt]){ze=!1;break}ze&&(b||=[]).push(Ne)}}continue}let Le=ae.filter(Ne=>cs.test(ge[Ne]));if(!B.some(Ne=>cs.test(ge.slice(Ne.from,Ne.to)))&&!ae.every(Ne=>q[Ne]))continue;if(!Ie&&!Array.from(Ce).some(Ne=>G.has(Ne))&&!ae.every(Ne=>q[Ne])&&!(Le.length&&q[Le[0]]&&q[Le[Le.length-1]]&&Ce.size===1)){let Ne=null,ze=0,tt=0,k=null,$=null;if(!Ie&&ce&&Z.nodeType===1&&!He.flat.atoms.length){let Q=M(He,Ae).filter(be=>cs.test(be.raw));S(Ae,yt.length+ge.length);for(let be of yt){let fe=T.baseOf(be);if(!fe||fe===Z||fe.nodeType!==1||be.nodeType!==1||fe.tagName!==Z.tagName||be.tagName!==fe.tagName)continue;let se=f.get(Z),le=f.get(fe),Be=!0;for(let Jt=Math.min(se,le)+1;Jt<Math.max(se,le);Jt++){let Mt=t[Jt];if(S(Ae,Mt.nodeType===1?1:Mt.value.length+1),Mt.nodeType===1||Mt.value.trim()){Be=!1;break}}if(!Be)continue;let Ke=O(fe,null,Ae),Ue=O(be,x,Ae);if(Ke.flat.atoms.length||Ue.flat.atoms.length)continue;let $e=Ke.flat.text,Ge=Ue.flat.text;if(S(Ae,$e.length+Ge.length+ge.length),!$e||!Q.length)continue;let et=0,Ot=Ge.length;if(se<le&&Ge.endsWith($e))Ot-=$e.length;else if(se>le&&Ge.startsWith($e))et=$e.length;else continue;for(;et<Ot&&pn.test(Ge[et]);)et++;for(;Ot>et&&pn.test(Ge[Ot-1]);)Ot--;let xt=Ge.slice(et,Ot);if(!(!xt||!(xt.startsWith(Q[0].raw)||xt.endsWith(Q[Q.length-1].raw)))){if(Ne){Ne=null;break}Ne=be,ze=et,tt=Ot,k=Q[0],$=Q[Q.length-1]}}}if(S(Ae,B.length),!Ne||!Ce.has(Ne)||!B.some(Q=>Q.target===Ne&&(Q.from<=k.from&&Q.to>=k.to&&Q.targetFrom+k.from-Q.from===ze||Q.from<=$.from&&Q.to>=$.to&&Q.targetFrom+$.to-Q.from===tt)))continue}if(Ie&&!(ae.every(Ne=>q[Ne])&&(_t||Array.from(Ce).some(Ne=>G.has(Ne))))&&!ie.some(Ne=>Ne.source===Z&&Hn.test(ge.slice(Ne.from,Ne.to))))continue;let We=!1;if(_t){S(Ae,ie.length+ae.length);for(let Ne of ie)Ne.source===Z&&(S(Ae,Ne.to-Ne.from),q.fill(1,Ne.from,Ne.to));We=!0;for(let Ne of ae)if(!q[Ne]){We=!1;break}}for(let Ne of Ce){S(Ae,B.length);let ze=B.filter(k=>k.target===Ne);ot.push({side:C,source:Z,target:Ne,runs:ze,models:u,retained:ie,conservedSource:We}),Z.nodeType===1&&Qe.add(Z),Ne.nodeType===1&&Qe.add(Ne);let tt=T.baseOf(Ne);tt?.nodeType===1&&Qe.add(tt)}}if(g.push(...ot),_e&&ot.length)for(let Z of _e)ve.add(Z);for(let Z of Qe)y.add(Z)}catch(Xe){if(Xe!==R)throw Xe}finally{if(n&&!_e&&!Ze){let Xe=_i({base:t,views:o,side:C,attempt:w,eligible:r,blocked:m,baseId:i,model:O,tokensOf:M,charge:S,exhausted:R,limit:a});Xe&&(A||=[]).push(...Xe)}if(e&&!_e&&!Ze){let Xe=ai({base:t,views:o,side:C,attempt:w,eligible:r,blocked:m,baseId:i,model:O,tokensOf:M,certificates:g,charge:S,exhausted:R,limit:a});Xe&&(b||=[]).push(...Xe)}}}}let F=g.length?new Map:null;for(let C of g){let T=F.get(C.source);T||F.set(C.source,T=[]),T.push(C)}let W=null;if(F){let C=null;for(let[T,x]of F){let z=p?.get(T)||0;if(x.length<2&&!z)continue;let D=0;for(let V of x)V.conservedSource&&(D|=1<<V.side);for(let V of x){if(V.conservedSource)continue;let Ee=1<<V.side,Me=!0;if(D&Ee)Me=!1;else if(z&Ee){Me=!1;try{Me=oa(V,C||=Kt(a),S)}catch(De){if(De!==R)throw De}}Me||(W||=new Set).add(V)}}}if(W){let C=0;for(let T of g)W.has(T)||(g[C++]=T);g.length=C;for(let[T,x]of F){C=0;for(let z of x)W.has(z)||(x[C++]=z);x.length=C,C||F.delete(T)}y.clear();for(let T of g){let{source:x,target:z,side:D}=T;x.nodeType===1&&y.add(x),z.nodeType===1&&y.add(z);let V=o[D].V.baseOf(z);V?.nodeType===1&&y.add(V)}}if(b){let C=Kt(a),T=!1;for(let x of b){let z=!1,D=F?.get(x.source);if(D&&!T)try{z=Zr(x,D,C,S)}catch(V){if(V!==R)throw V;T=!0}z||e(x)}}if(A){let C=new Set,T=Kt(a);try{for(let x of A){if(S(T,1),C.has(x.source))continue;C.add(x.source);let z=!1;for(let D of g)if(S(T,1),D.source===x.source||D.target===x.local||D.target===x.remote){z=!0;break}z||n(x)}}catch(x){if(x!==R)throw x}}for(let C of t)if(y.has(C))for(let{V:T}of o){let x=T.twin(C);x&&T.here(x)&&y.add(x)}return g.length?{blocks:y,certificates:g,certificatesBySource:F,models:u}:null}function Ki({certificates:e,scopes:n,flats:t,keys:o,limit:r=2e4*32}){let c=Symbol(),l=Kt(r),i=p=>{if(p>l.remaining)throw c;l.remaining-=p},s=n.map(p=>new Set(p)),a=new Map,h=new Map,f=(p,m)=>{let y=a.get(p);if(y||a.set(p,y=new Map),y.has(m))return y.get(m);i(p.text.length);let R=h.get(m);if(!R){i(m.nodes.length+m.atoms.length),R={nodes:new Map,atoms:new Map};for(let E of m.nodes)R.nodes.set(E.node,E);for(let E of m.atoms)R.atoms.set(E.el,E.i);h.set(m,R)}let{nodes:S,atoms:O}=R,M=new Int32Array(p.text.length).fill(-1);for(let E of p.nodes){let N=S.get(E.node);if(!(!N||E.e-E.s!==N.e-N.s)){i(E.e-E.s);for(let L=E.s;L<E.e;L++)M[L]=N.s+L-E.s}}for(let E of p.atoms){let N=O.get(E.el);N!==void 0&&(M[E.i]=N)}return y.set(m,M),M},u=(p,m,y,R,S)=>{let O=p[p.length-1];O&&O.to===m&&O.target+O.to-O.from===R&&O.kind===S?O.to=y:p.push({from:m,to:y,target:R,kind:S})},g=(p,m,y,R)=>{i((R-y)*4);let S=[],O=y,M=L=>{let j=p.text.slice(O,L);for(let F of ln(j,yn(j)))F.from=O,F.to=O+F.len,S.push(F),O+=F.len},E=0,N=p.atoms.length;for(;E<N;){i(1);let L=E+N>>>1;p.atoms[L].i<y?E=L+1:N=L}for(let L=E;L<p.atoms.length&&p.atoms[L].i<R;L++){i(1);let j=p.atoms[L];M(j.i),S.push({k:m(j),raw:Bn,len:1,from:O,to:O+1}),O++}return M(R),S},b=(p,m,y,R,S,O)=>{if(y===R||S===O)return;if(R-y===O-S){i((R-y)*4);let T=!0;for(let x=y,z=S;x<R;x++,z++){if(t[0].text[x]!==t[m].text[z]){T=!1;break}let D=t[0].atomAt.get(x),V=t[m].atomAt.get(z);if(!!D!=!!V||D&&o[0](D)!==o[m](V)){T=!1;break}}if(T){u(p,y,R,S,"retained");return}}let M=g(t[0],o[0],y,R),E=g(t[m],o[m],S,O),N=M.length+E.length+4,L=Math.min(M.length+E.length,4e3,Math.floor((Math.sqrt(N*N+l.remaining/2)-N)/2));if(L<1)throw c;i(4*(L+1)*(N+L+1));let j=Kn(M,E,L),F=0,W=0,C=()=>{let T=M[F++],x=E[W++];i(T.len),T.raw===x.raw&&u(p,T.from,T.to,x.from,"retained")};for(let T of j.hunks){for(;F<T.bs;)C();F=T.be,W+=T.toks.length}for(;F<M.length&&W<E.length;)C()},A=p=>{let m=e.filter(j=>j.side===p-1&&s[0].has(j.source)&&s[p].has(j.target));if(!m.length)return null;let y=[],R=(j,F,W)=>{if(!s[0].has(j.source)||!s[p].has(j.target))return;let C=f(F.get(j.source).flat,t[0]),T=f(F.get(j.target).flat,t[p]);i(j.to-j.from);for(let x=0;x<j.to-j.from;x++){let z=C[j.from+x],D=T[j.targetFrom+x];if(z<0||D<0)throw c;u(y,z,z+1,D,W)}},S=new Set;for(let j of m){if(!S.has(j.retained)){S.add(j.retained);for(let F of j.retained)R(F,j.models,"retained")}for(let F of j.runs)R(F,j.models,"transfer")}y.sort((j,F)=>(i(1),j.from-F.from||j.target-F.target));let O=[];for(let j of y){i(1);let F=O[O.length-1];if(F&&j.from<F.to){if(j.target-j.from!==F.target-F.from)throw c;F.to=Math.max(F.to,j.to),j.kind==="transfer"&&(F.kind="transfer")}else O.push(j)}let M=[],E=0,N=0;for(let j of O){if(j.target<N)throw c;b(M,p,E,j.from,N,j.target),M.push(j),E=j.to,N=j.target+j.to-j.from}b(M,p,E,t[0].text.length,N,t[p].text.length);let L=Dn({base:t[0],side:t[p],retained:M.filter(j=>j.kind==="retained"),transfers:M.filter(j=>j.kind==="transfer"),baseAtomKey:o[0],sideAtomKey:o[p],budget:l});if(L.status!=="ready"||!L.monotone)throw c;return L};try{let p=A(1),m=A(2);return p||m?{local:p,remote:m}:{fallback:!0}}catch(p){if(p!==c)throw p;return{fallback:!0}}}function as(e,n,t=!1){let o=-1,r=-1;for(let l=0;l<e.list.length;l++){let i=e.list[l];i.bLo<n.lo||i.bLo>n.hi||(o<0&&(o=l),r=l)}let c=[];for(let l=o;l>=0&&l<=r;l++){let i=e.list[l],s=!t&&l===o?i.inlineStart<0?i.to:i.inlineStart:i.from,a=!t&&l===r?i.inlineEnd<0?i.from:i.inlineEnd:i.to;for(let h=s;h<a;h++)c.push(e.units[h]);l<r&&c.push(e.units[i.next])}return c}var ut=e=>!!e&&e.nodeType===1,In=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function fs(e){for(let n of e)if(In.has(n.tagName))return!0;return!1}function ia(e,n,t){let o=null;for(let r of n.childNodes)if(!(!ut(r)||!t(r)||!r.isEqualNode(e))){if(o)return null;o=r}if(!o)return null;for(let r of e.parentNode.childNodes)if(r!==e&&r.isEqualNode(e))return null;return o}var $o="[id],[data-id],script,head>*";function us(e,n){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let o=So(t,e);if(o)return"merge:"+o.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?vi(t,n):null}}function Nr(e,n,t,o){let r=o.ignored,c=o.stats||Xn(),l=ri({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:c}),{unitsOf:i,meta:s}=l,a=o.baseURI,h=o.mergeTags!==null,f=us(o.mergeTags,a),u=k=>$=>{let Q=f($);return Q!==null?Q:k($)},g=u(o.identity.base),b=u(o.identity.local),A=u(o.identity.remote),p=o.authored||o.identity,m=k=>k&&k.nodeType===9?k.documentElement:k,y=m(e),R=m(n),S=m(t),O=globalThis.__hyperMorphProfile,M=O?performance.now():0,E=k=>k===bn?$o:null,N=o.scope||null,L=N?N.baseDropped:new Set,j=new Set,F=N?N.remoteDropped:new Set,W=N?N.baseIndex:mr(y,g,r,E(o.identity.base),L),C=o.localIsBase||y===R?null:mr(R,b,r,E(o.identity.local),j),T=N?N.remoteIndex:mr(S,A,r,E(o.identity.remote),F),x=k=>{let $=ut(k)&&b(k);return $&&C?.get($)===k&&!W.has($)?$:null},z=k=>{let $=ut(k)&&A(k);return $&&T.get($)===k&&!W.has($)?$:null},D=C?$r(y,R,{analyzer:l,baseIndex:W,sideIndex:C,baseId:p.base,sideId:p.local,baseKey:g,sideKey:b,baseDropped:L,sideDropped:j,stats:c}):zi(),V=$r(y,S,{analyzer:l,baseIndex:W,sideIndex:T,baseId:p.base,sideId:p.remote,baseKey:g,sideKey:A,baseDropped:L,sideDropped:F,stats:c,scope:N,comparisons:o.comparisons});if(N){if(!N.held(V))return null;for(let k of N.dropped)_r(k)}let Ee=null;function Me(k){if(!Ee){Ee=new WeakMap;let $=[y];for(;$.length;){let Q=$.pop();Q.tagName==="TEMPLATE"&&Q.content&&Ee.set(Q.content,Q);for(let be of l.childrenOf(Q))be.nodeType===1&&$.push(be)}}return Ee.get(k)||null}let De=k=>{let $=ut(k)||k.nodeType?k.parentNode:k.parent;return $&&$.nodeType===11?Me($):$};if(V.moved.size){let k=!1;for(let $ of Array.from(V.moved))!ut($)||V.identityPaired.has($)||!p.base($)||pe(V,De($))||(V.unpair($),k=!0);k&&V.rematch()}ie(),me(D,V),me(V,D);for(let k of[D,V])if(k.refused)for(let $ of k.refused)k.moved.has($)||c.ambiguousMoves++;O&&(O.alignTotal=(O.alignTotal||0)+(performance.now()-M),M=performance.now());let re=y.ownerDocument.implementation.createHTMLDocument(""),Se=new WeakMap,qe=new WeakMap,ve=[],w=[],K=new Set,ne=[],ee=new Set,Pe=new Set,_e=new Set,Ae=new WeakMap,ot=null,Qe=o.conflicts||"remote",Ze=k=>ve.push(k),Xe=k=>ve.push(k),yt=Di({roots:{base:y,local:R,remote:S},L:D,R:V,unitsOf:i,provenance:Se,policy:Qe}),dt=(k,$)=>{w.push(k),$&&yt.note(k,$)},gt=null,qt=null,$t=zt(),Ht=null,jt=J(y,D.map.get(y),V.map.get(y),!!o.localIsBase,!!o.childrenOnly);jt.tagName==="HTML"?re.replaceChild(jt,re.documentElement):re.body.appendChild(jt),gt?.drain(jt),qt?.drain(jt),O&&(O.build=(O.build||0)+(performance.now()-M));let an=o.childrenOnly?!ae(te(jt),te(S)):!he(jt,S),_t=yt.finish(jt);return{doc:re,root:jt,provenance:Se,textMappers:qe,decisions:ve,conflicts:w,recoveryLinks:_t,localDiverged:an,mergedScripts:K,segments:ne,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==bn,L:D,R:V,stats:c};function zt(){let k=new Map,$=new Set;if(o.localIsBase||!D.insertedByHash)return{partner:k,drop:$};let Q=D.insertedByHash(),be=V.insertedByHash();if(!Q.size||!be.size)return{partner:k,drop:$};let fe={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},se=pt=>{let bt=0;for(let mt=pt.parentNode;mt;mt=mt.parentNode)bt++;return bt},le=[],Be=pt=>{let bt=pt.textContent.trim();return bt.split(/\s+/).length>=3||bt.replace(/\s/g,"").length>=12},Ke=pt=>{let bt=pe(D,pt),mt=pe(V,pt);return bt&&D.reverse.get(bt.parentNode)!==pt.parentNode||mt&&V.reverse.get(mt.parentNode)!==pt.parentNode},Ue=(pt,bt,mt)=>{for(let ct of mt.parentNode.children){let Wt=ct!==mt&&pt.reverse.get(ct);if(Wt&&Ke(Wt))return!0}let It=pt.reverse.get(mt.parentNode);if(It){for(let ct of It.children)if(!pe(bt,ct)&&!r(ct))return!0}return!1},$e=new Map([[D,new Map],[V,new Map]]),Ge=(pt,bt)=>{let mt=$e.get(pt),It=mt.get(bt);if(It===void 0){It=!1;for(let ct of bt.children)if(pt.reverse.has(ct)||Ge(pt,ct)){It=!0;break}mt.set(bt,It)}return It},et=new Map;for(let pt of be.values())for(let bt of pt){let mt=z(bt);mt&&et.set(mt,bt)}for(let pt of Q.values())for(let bt of pt){let mt=x(bt),It=mt?et.get(mt):null;It&&It.tagName===bt.tagName&&!Un(bt,fe)&&!Un(It,fe)&&!o.remoteWins(bt)&&!o.remoteWins(It)&&le.push([bt,[It],se(bt),!0,!0])}for(let[pt,bt]of Q){let mt=be.get(pt);if(!mt)continue;let It=bt.length===1&&mt.length===1;for(let ct of bt)!Un(ct,fe)&&!x(ct)&&le.push([ct,mt,se(ct),It&&(Be(ct)||Ue(D,V,ct)||Ue(V,D,mt[0]))])}if(!le.length)return{partner:k,drop:$};le.sort((pt,bt)=>pt[2]-bt[2]);let Ot=new Set,xt=new Set,Jt=pt=>{for(let bt of pt.querySelectorAll("*"))Ot.add(bt)},Mt=(pt,bt)=>pt.reverse.get(bt.parentNode)||null;for(let[pt,bt,,mt,It]of le){if(Ot.has(pt)||xt.has(pt)||It&&(Ge(D,pt)||Ge(V,bt[0])))continue;let ct=Mt(D,pt),Wt=Gt=>!xt.has(Gt)&&!Ot.has(Gt)&&(It||Gt.tagName===pt.tagName&&!z(Gt)&&l.equalUnits(pt,Gt)),St=bt.find(Gt=>ct&&Mt(V,Gt)===ct&&Wt(Gt))||(mt?bt.find(Wt):null);if(!St)continue;xt.add(pt),xt.add(St);let fn=ct&&Mt(V,St)===ct;(!It||!fn||l.equalUnits(pt,St))&&(Jt(pt),Jt(St)),!fn&&(k.set(pt,St),k.set(St,pt),$.add(Qe==="local"?St:pt))}return{partner:k,drop:$}}function _(k,$,Q){if(ee.add(k),$t.drop.has(k))return null;ee.add(Q);let be=$==="local"?k:Q,fe=$==="local"?Q:k,se;return l.equalUnits(be,fe)?(se=G(be,"local",!0),Se.get(se).remote=fe):se=B(be,fe),dt({kind:"structure",el:se,detail:"both-moved",base:null,local:be,remote:fe},{unit:{b:null,l:be,r:fe}}),Ze({kind:"insert",el:se,source:"both"}),se}function ie(){if(!D.weak||!V.weak||!D.weak.size||!V.weak.size||!D.unpair)return;let k=new Map;for(let Q of D.weak){let be=pe(D,Q);ut(Q)&&ut(be)&&k.set(l.unitHash(be),Q)}let $=!1;for(let Q of Array.from(V.weak)){let be=pe(V,Q);if(!ut(Q)||!ut(be))continue;let fe=k.get(l.unitHash(be));if(!fe||fe===Q||!D.weak.has(fe)||pe(D,Q)&&pe(V,fe))continue;let se=pe(D,fe);se.tagName===be.tagName&&l.equalUnits(se,be)&&(D.unpair(fe),V.unpair(Q),$=!0)}$&&(D.rematch(),V.rematch())}function me(k,$){if(!k.weak||!k.weak.size||!$.insertedByHash)return;let Q=$.insertedByHash();if(!Q.size)return;let be=!1;for(let fe of Array.from(k.weak)){let se=pe(k,fe);if(!se)continue;let le=k===D?x(se):z(se);if(le){let Ke=(k===D?T:C)?.get(le);Ke&&Ke.tagName===se.tagName&&!$.reverse.has(Ke)&&(k.unpair(fe),be=!0);continue}let Be=Q.get(l.unitHash(se));Be&&Be.some(Ke=>Ke.tagName===se.tagName&&l.equalUnits(Ke,se))&&(k.unpair(fe),be=!0)}be&&k.rematch()}function pe(k,$){if(!$)return null;if(k.map.has($))return k.map.get($);let Q=[],be=De($);for(;be&&!k.map.has(be);be=De(be))Q.push(be);let fe=be;if(!fe||!k.identical.has(fe))return null;k.pairIdenticalChildren(fe);for(let le=Q.length-1;le>=0;le--)k.pairIdenticalChildren(Q[le]);let se=k.map.get($)||null;return se&&c.lazyTwins++,se}function ke(k,$,Q,be){if(ut(k)&&In.has(k.tagName)&&!D.identical.has(k)&&(k.previousSibling?.nodeType===3||k.nextSibling?.nodeType===3)){let Be=De(k),Ke=pe(D,k),Ue=pe(V,k);Ke&&Ue&&ze(Ke,pe(D,Be),D)&&!ze(Ue,pe(V,Be),V)&&(qt||=Hi({L:D,R:V,twinIn:pe,unitsOf:i,view:v,parentOf:De,ignored:r,remoteWins:o.remoteWins,eligible:$e=>ut($e)&&In.has($e.tagName),build:J,out:re,policy:Qe,provenance:Se,textMappers:qe,segments:ne,conflicts:w,conflict:dt,decisions:ve}),qt.ensureOwner(k))}if($===null)return null;if(be!==void 0)return gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(k,$,Q,!!be),be&&(gt.produced(k,be),Pe.add(k)),be;if(Pe.has(k)||_e.has(k))return dt({kind:"structure",el:null,detail:"both-moved",base:k},{subject:k}),Pe.has(k)?null:G(Q,$);gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(k,$,Q,!0);let fe=pe(D,k),se=pe(V,k);(!fe||!se)&&dt({kind:"structure",el:null,detail:"move-beats-delete",base:k},{subject:k,deleted:fe?"remote":"local"});let le=J(k,fe,se,!1);return($==="local"?Ze:Xe)({kind:"move",el:le,source:$}),le}function v(k,$,Q,be){return be||!$||$===Q?{el:Q,asBase:!0,twin:fe=>fe,baseOf:fe=>fe,units:i(Q),here:()=>!0,parentOfTwin:()=>Q}:{el:$,asBase:!1,twin:fe=>pe(k,fe),baseOf:fe=>k.reverse.get(fe),units:i($),here:fe=>ut(fe)?fe.parentNode===$||$.tagName==="TEMPLATE"&&fe.parentNode===$.content:fe.parent===$||$.tagName==="TEMPLATE"&&fe.parent===$.content}}function P(k,$,Q){return!$||Q&&Q.identical.has(k)?!1:ut(k)?!l.equalUnits(k,$)||!Y(k,$,Q):k.value!==$.value}function Y(k,$,Q){if(!Q||k===$)return!0;let be=[[k,$]];for(;be.length;){let[fe,se]=be.pop(),le=i(fe),Be=i(se);for(let Ke=0;Ke<le.length&&Ke<Be.length;Ke++){let Ue=le[Ke],$e=Be[Ke];if(!ut(Ue)||!ut($e))continue;let Ge=Q.map.get(Ue);if(Ge!==void 0&&Ge!==$e)return!1;let et=Q.reverse.get($e);if(et!==void 0&&et!==Ue)return!1;be.push([Ue,$e])}}return!0}function J(k,$,Q,be,fe=!1){let se=be||(Q?o.remoteWins(Q):o.remoteWins(k)),le=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(k.namespaceURI,k.tagName):re.createElement(k.tagName),Be={base:k,local:$||null,remote:Q||null};if(Se.set(le,Be),se&&!be&&$&&P(k,$,D)&&(!Q||!l.equalUnits($,Q))&&dt({kind:"structure",el:le,detail:"remote-wins",base:k,local:$,remote:Q||null},{subject:k}),ee.add(k),Pe.add(k),$&&ee.add($),Q&&ee.add(Q),o.skipUnchanged&&!fe&&(o.localIsBase||D.identical.has(k))&&Q&&V.identical.has(k)&&!o.remoteWins(k)){Be.unchanged=!0;for(let Ue of k.attributes)Ue.namespaceURI?le.setAttributeNS(Ue.namespaceURI,Ue.name,Ue.value):le.setAttribute(Ue.name,Ue.value);return gt?.produced(k,le),le}_e.add(k),fe||Z(k,se?k:$,Q,le);let Ke=k.tagName;if(hn(k))je(k,se?k:$,Q,le);else if(Ke==="TEXTAREA")le.textContent=oe(k.textContent,(se?k:$)?(se?k:$).textContent:k.textContent,Q?Q.textContent:k.textContent,le,"text");else if(!qt?.render(k,le)){let Ue=ue(k,$,Q,se,le),$e=Ke==="TEMPLATE"&&le.content?le.content:le;for(let Ge of Ue)$e.appendChild(Ge)}return _e.delete(k),gt?.produced(k,le),le}function oe(k,$,Q,be,fe){if($===Q)return $;if($===k)return Q!==k&&Xe({kind:fe,node:be,source:"remote"}),Q;if(Q===k)return Ze({kind:fe,node:be,source:"local"}),$;let se=Qe==="local"?$:Q;return dt({kind:fe,node:be,base:k,local:$,remote:Q,resolved:se},{site:"whole",el:be}),ve.push({kind:fe,node:be,source:"both"}),se}function je(k,$,Q,be){let fe=k.textContent,se=$?$.textContent:fe,le=Q?Q.textContent:fe,Be=h?So(k,o.mergeTags,!0):null;if(Be&&se!==le){let Ke=Q&&Q.getAttribute("merge-key")||k.getAttribute("merge-key"),{text:Ue,warnings:$e}=is(o.localIsBase?void 0:fe,se,le,{parse:Be.recognizer.parse,keyCandidates:Ke?Ke.split(/[\s,]+/).filter(Boolean):void 0});for(let Ge of $e)console.warn(`[hyper-morph] merge "${Be.raw}": ${Ge}`);be.textContent=Ue,K.add(be),Ue!==le?Ze({kind:"text",node:be,source:Ue===se?"local":"both"}):Ue!==fe&&Xe({kind:"text",node:be,source:"remote"});return}be.textContent=oe(fe,se,le,be,"text")}function Z(k,$,Q,be){let fe=new Map;for(let se of[k,$,Q])if(se)for(let le of se.attributes)o.ignoreAttribute(se,le.name)||fe.set(le.name,le);for(let[se,le]of fe){let Be=k?k.getAttribute(se):null,Ke=$?$.getAttribute(se):Be,Ue=Q?Q.getAttribute(se):Be,$e;Ke===Ue?$e=Ke:Ke===Be?($e=Ue,Xe({kind:"attr",el:be,name:se,source:"remote"})):Ue===Be?($e=Ke,Ze({kind:"attr",el:be,name:se,source:"local"})):($e=Oe(se,Be,Ke,Ue),$e===void 0&&($e=Qe==="local"?Ke:Ue,dt({kind:"attr",el:be,name:se,base:Be,local:Ke,remote:Ue,resolved:$e},{el:be,sample:le})),ve.push({kind:"attr",el:be,name:se,source:"both"})),$e!=null&&(le.namespaceURI?be.setAttributeNS(le.namespaceURI,le.name,$e):be.setAttribute(se,$e))}}function Oe(k,$,Q,be){if(k==="class"){let fe=Ue=>new Set((Ue||"").split(/\s+/).filter(Boolean)),se=fe($),le=fe(Q),Be=fe(be),Ke=new Set;for(let Ue of new Set([...se,...le,...Be])){let $e=se.has(Ue),Ge=le.has(Ue),et=Be.has(Ue);(Ge===et?Ge:Ge===$e?et:Ge)&&Ke.add(Ue)}return[...Ke].join(" ")}if(k==="style"){let fe=$e=>{let Ge=new Map;if(!$e)return Ge;let et=0,Ot=null,xt="",Jt=()=>{let Mt=xt.indexOf(":");Mt>0&&Ge.set(xt.slice(0,Mt).trim(),xt.slice(Mt+1).trim()),xt=""};for(let Mt of $e){if(Ot){xt+=Mt,Mt===Ot&&(Ot=null);continue}if(Mt==='"'||Mt==="'"){Ot=Mt,xt+=Mt;continue}if(Mt==="("?et++:Mt===")"&&et--,Mt===";"&&et===0){Jt();continue}xt+=Mt}return xt.trim()&&Jt(),Ge},se=fe($),le=fe(Q),Be=fe(be),Ke=new Map,Ue=!1;for(let $e of new Set([...se.keys(),...le.keys(),...Be.keys()])){let Ge=se.get($e)??null,et=le.get($e)??null,Ot=Be.get($e)??null,xt;et===Ot?xt=et:et===Ge?xt=Ot:Ot===Ge?xt=et:(xt=Qe==="local"?et:Ot,Ue=!0),xt!=null&&Ke.set($e,xt)}return Ue?void 0:[...Ke].map(([$e,Ge])=>`${$e}: ${Ge}`).join("; ")}}function He(k,$,Q,be){let fe=k.value,se=be?fe:$?$.value:"",le=Q?Q.value:"";ee.add(k),$&&ee.add($),Q&&ee.add(Q);let Be=Ho(fe,se,le,Qe),Ke=Be.text===""?null:re.createTextNode(Be.text);Ke&&(Se.set(Ke,{base:k.nodes,local:$?$.nodes:null,remote:Q?Q.nodes:null}),qe.set(Ke,Be.mapLocalOffset)),se!==fe&&le!==fe?ve.push({kind:"text",node:Ke,source:"both"}):se!==fe?Ze({kind:"text",node:Ke,source:"local"}):le!==fe&&Xe({kind:"text",node:Ke,source:"remote"});for(let Ue of Be.conflicts)dt({kind:"text",node:Ke,base:fe.slice(Ue.bs,Ue.be),local:Ue.local,remote:Ue.remote,resolved:Ue.resolved},{site:"run",bRun:k,lRun:$,rRun:Q,node:Ke,c:Ue});return Ke}function Ie(k,$){return ro(k,$).every(Q=>Q.bs===Q.be)}function ge(k,$){let Q=k?k.value:"",be=$?$.value:"",fe;if(Q===be||!be?fe=Q:Q?Ie(Q,be)?fe=be:Ie(be,Q)?fe=Q:(fe=Qe==="local"?Q:Qe==="both"?Q+be:be,dt({kind:"structure",el:null,detail:"insert-collision",local:Q,remote:be,resolved:fe},{unit:{b:null,l:k,r:$},localLost:Qe==="remote"})):fe=be,k&&ee.add(k),$&&ee.add($),fe==="")return null;let se=re.createTextNode(fe);return Se.set(se,{base:null,local:k?k.nodes:null,remote:$?$.nodes:null}),Q?Ze({kind:"insert",el:se,source:be&&Q===be?"both":"local"}):Xe({kind:"insert",el:se,source:"remote"}),se}function B(k,$){let Q={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},be=Be=>i(Be).every(Ke=>ut(Ke)?Un(Ke,Q):Ke.kind==="text"),fe=null;if(be(k)&&be($)){let Be=k.textContent,Ke=$.textContent;Be===Ke||Ie(Ke,Be)?fe=$:Ie(Be,Ke)&&(fe=k)}if(!fe){let Be=Qe==="local",Ke=G(Be?k:$,Be?"local":"remote",!0),Ue=Se.get(Ke);return Be?Ue.remote=$:Ue.local=k,dt({kind:"structure",el:Ke,detail:"insert-collision",local:k,remote:$,resolved:Be?k:$},{unit:{b:null,l:k,r:$},localLost:!Be}),Ke}let se=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(k.namespaceURI,k.tagName):re.createElement(k.tagName);Z(null,k,$,se),Se.set(se,{base:null,local:k,remote:$}),ee.add(k),ee.add($);let le=so({base:Array.from(fe.childNodes),local:Array.from(k.childNodes),remote:Array.from($.childNodes),out:re,policy:Qe,idOf:{local:b,remote:A},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:Se,textMappers:qe,conflicts:w,conflict:dt,scope:{base:null,local:k,remote:$,units:[],at:0},synthetic:!0,decisions:ve,node:se});ne.push(...le.segments);for(let Be of le.nodes)se.appendChild(Be);return se}function G(k,$,Q=!1){if(!Q&&ut(k)){let le=$t.partner.get(k);if(le)return _(k,$,le)}if(!ut(k)){if(k.value==="")return null;let le=k.kind==="comment"?re.createComment(k.value):re.createTextNode(k.value);return Se.set(le,{base:null,local:$==="local"?k.nodes:null,remote:$==="remote"?k.nodes:null}),ee.add(k),le}let be=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(k.namespaceURI,k.tagName):re.createElement(k.tagName);for(let le of k.attributes)le.namespaceURI?be.setAttributeNS(le.namespaceURI,le.name,le.value):be.setAttribute(le.name,le.value);Se.set(be,{base:null,local:$==="local"?k:null,remote:$==="remote"?k:null}),ee.add(k);let fe=k.tagName==="TEMPLATE"&&be.content?be.content:be,se=$==="local"?D:V;for(let le of i(k)){let Be=ut(le)?se.reverse.get(le):null;if(Be&&ke(Be,null,null),Be&&Pe.has(Be)){dt({kind:"structure",el:null,detail:"both-moved",base:Be},{subject:Be});continue}if(Be&&!_e.has(Be)){let Ue=pe(D,Be)||null,$e=pe(V,Be)||null;if(Ue||$e){gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(Be,$,le,!0);let Ge=J(Be,Ue,$e,!1);$==="local"?Ze({kind:"move",el:Ge,source:"local"}):Xe({kind:"move",el:Ge,source:"remote"}),fe.appendChild(Ge);continue}}let Ke=G(le,$);Ke&&fe.appendChild(Ke)}if(!Q&&$t.drop.size&&k.tagName==="DIV"&&!fe.firstChild&&!k.attributes.length&&!($==="local"?b(k):A(k))&&!se.reverse.has(k)&&!r(k)&&!o.remoteWins(k)){let le=k.firstChild;if(le&&le===k.lastChild&&ut(le)&&($t.drop.has(le)||Ht?.has(le)))return(Ht||=new WeakSet).add(k),null}return be}function ue(k,$,Q,be,fe){$&&D.identical.has(k)&&D.pairIdenticalChildren(k),Q&&V.identical.has(k)&&V.pairIdenticalChildren(k);let se=v(D,$,k,be),le=v(V,Q,k,!1),Be=i(k),Ke=new Set(Be),Ue=new Map;for(let ye=0;ye<Be.length;ye++)Ue.set(Be[ye],ye);let $e=[],Ge=new Set,et=new Map,Ot=new Set,xt=new Set,Jt=[],Mt=null;if(!se.asBase&&!le.asBase&&!D.identical.has(k)&&!V.identical.has(k))for(let ye of Be){if(!ut(ye)||!In.has(ye.tagName))continue;let Je=se.twin(ye),Ye=le.twin(ye);Je&&Ye&&(!se.here(Je)||!le.here(Ye))&&ke(ye,null,null)}Ir();let pt=ye=>{let Je=[];for(let Ye of ye.units){if(xt.has(Ye))continue;let kt=ye.baseOf(Ye);kt&&Ke.has(kt)&&Je.push(kt)}return Je},bt=ye=>pt(ye).map(Je=>Ue.get(Je)),mt=ye=>ye.every((Je,Ye)=>Ye===0||Je>=ye[Ye-1]),It=!se.asBase&&!mt(bt(se)),ct=!le.asBase&&!mt(bt(le));It&&ct&&dt({kind:"structure",el:fe,detail:"both-reordered",base:k},{subject:k,lKept:pt(se),rKept:pt(le)});let Wt=ct||!It?{V:le,A:V,side:"remote",other:se,otherA:D,otherSide:"local"}:{V:se,A:D,side:"local",other:le,otherA:V,otherSide:"remote"};It?Ze({kind:"move",el:null,source:ct?"both":"local",base:k}):ct&&Xe({kind:"move",el:null,source:"remote",base:k});let St=se.asBase?[]:se.units.filter(ye=>!se.baseOf(ye)&&!xt.has(ye)&&!$t.partner.has(ye)),fn=le.asBase?[]:le.units.filter(ye=>!le.baseOf(ye)&&!xt.has(ye)&&!$t.partner.has(ye)),Gt=new Map;if(St.length&&fn.length){let ye=new Map,Je=new Map;for(let rt of fn){if(ut(rt)){let Lt=A(rt);Lt&&ye.set(Lt,rt)}let At=l.unitHash(rt);Je.has(At)||Je.set(At,[]),Je.get(At).push(rt)}let Ye=(rt,At)=>{let Lt=rt.units.indexOf(At);for(let at=Lt-1;at>=0;at--){let Nt=rt.baseOf(rt.units[at]);if(Nt)return Nt}return"start"},kt=new Map,Dt=new Map;for(let rt of fn){let At=Ye(le,rt);ut(rt)?(Dt.has(At)||Dt.set(At,[]),Dt.get(At).push(rt)):rt.kind==="text"&&!kt.has(At)&&kt.set(At,rt)}for(let rt of St){let At=null;if(ut(rt)){let at=b(rt);at&&ye.has(at)&&!Gt.has(ye.get(at))&&(At=ye.get(at))}else if(rt.kind==="text"){let at=kt.get(Ye(se,rt));at&&!Gt.has(at)&&(At=at)}let Lt=!!x(rt);if(!At&&!Lt){let at=Je.get(l.unitHash(rt));at&&(At=at.find(Nt=>!Gt.has(Nt)&&ut(Nt)===ut(rt)&&(ut(Nt)?Nt.tagName===rt.tagName&&!z(Nt):Nt.kind===rt.kind)&&l.equalUnits(rt,Nt))||null)}if(!At&&ut(rt)&&!Lt){let at=p.local(rt),Nt=(Dt.get(Ye(se,rt))||[]).filter(sn=>{let un=p.remote(sn);return!Gt.has(sn)&&sn.tagName===rt.tagName&&!z(sn)&&!(at&&un&&at!==un)&&l.similar(rt,sn)});Nt.length===1&&(At=Nt[0])}At&&(Gt.set(At,rt),Gt.set(rt,At))}}let Fn=ye=>{if(qt?.consumes(ye))return null;if(ee.has(ye)||gt?.has(ye))return et.get(ye)||null;let Je=se.twin(ye),Ye=le.twin(ye),kt=Je&&!se.asBase&&!se.here(Je),Dt=Ye&&!le.asBase&&!le.here(Ye);if(kt||Dt){if((!Je||!Ye)&&dt({kind:"structure",el:null,detail:"move-beats-delete",base:ye},{subject:ye,deleted:Je?"remote":"local"}),!Ne(ye))return ut(ye)?(gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),kt&>.plan(ye,"local",Je),Dt&>.plan(ye,"remote",Ye)):ee.add(ye),null;dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye})}if(Je&&!Ye&&!se.asBase&&!le.asBase&&ut(ye)&&In.has(ye.tagName)&&!o.remoteWins(ye)&&!o.remoteWins(Je)&&P(ye,Je,D)&&ia(ye,te(le.el),r)){let Nt={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},sn=un=>ut(un)?Un(un,Nt):un.kind==="text";if(i(ye).every(sn)&&i(Je).every(sn)){let un=so({base:[ye],local:[Je],remote:[],blocks:new Set([ye,Je]),out:re,policy:Qe,L:D,R:V,idOf:{base:g,local:b,remote:A},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(mn,kn,Ln)=>J(mn,kn,Ln,!1),cloneUnit:G,mergeAttrs:Z,atomKey:l.exactUnitKey,moveIn:ke,moveBuilt:ke,movePlanned:ke,provenance:Se,textMappers:qe,conflicts:w,conflict:dt,scope:{base:k,local:se.el,remote:le.el,units:Be,at:Ue.get(ye)},decisions:ve,node:fe});ne.push(...un.segments),ee.add(ye),ee.add(Je);let xn=re.createDocumentFragment();for(let mn of un.nodes)xn.appendChild(mn);return et.set(ye,xn),et.set(Je,xn),xn}}if(!Je&&!Ye)return ee.add(ye),Xe({kind:"remove",source:"both",base:ye}),null;if(!Je&&!P(ye,Ye,V))return ee.add(ye),Ze({kind:"remove",source:"local",base:ye}),null;if(!Ye&&!P(ye,Je,D))return ee.add(ye),Xe({kind:"remove",source:"remote",base:ye}),null;let rt=!Je||!Ye,At=se.asBase?pe(D,ye)||null:Je,Lt=le.asBase&&ut(ye)&&(V.identityPaired.has(ye)||!p.base(ye))&&pe(V,ye)||Ye,at;return ut(ye)?at=J(ye,At,Lt,se.asBase):ye.kind==="comment"?at=Le(ye,At,Ye,se.asBase):at=He(ye,At,Ye,se.asBase),ee.add(ye),at&&(et.set(ye,at),Je&&et.set(Je,at),Ye&&et.set(Ye,at),rt&&(dt({kind:"structure",el:at,detail:"edit-beats-delete",base:ye},{subject:ye,deleted:Je?"remote":"local"}),Je?Ze({kind:"insert",el:at,source:"local"}):Xe({kind:"insert",el:at,source:"remote"}))),at},Rn=(ye,Je,Ye,kt)=>{if(qt?.consumes(ye))return null;if(ee.has(ye))return et.get(ye)||null;let Dt=Je.baseOf(ye);if(Dt&&Ke.has(Dt))return xt.has(Dt)&&!xt.has(ye)?cr(Dt,ye,kt):Fn(Dt);if(Dt)return $n(Dt,ye,kt);let rt=Gt.get(ye);if(rt){let Lt=kt==="local"?ye:rt,at=kt==="local"?rt:ye,Nt;return ut(Lt)?l.equalUnits(Lt,at)?(Nt=G(Lt,"local"),Nt&&(Se.get(Nt).remote=at)):Nt=B(Lt,at):Nt=ge(Lt,at),ee.add(Lt),ee.add(at),Nt&&(et.set(Lt,Nt),et.set(at,Nt),ut(Lt)&&Ze({kind:"insert",el:Nt,source:"both"})),Nt}let At=G(ye,kt);return At&&(et.set(ye,At),kt==="local"?Ze({kind:"insert",el:At,source:"local"}):Xe({kind:"insert",el:At,source:"remote"})),At},cr=(ye,Je,Ye)=>{let kt;return ut(ye)?(kt=ke(ye,Ye,Je),kt&&ee.add(Je)):(kt=G(Je,Ye),ee.add(Je),kt&&(Ye==="local"?Ze:Xe)({kind:"insert",el:kt,source:Ye})),kt&&et.set(Je,kt),kt},$n=(ye,Je,Ye)=>{ke(ye,null,null);let Dt=pe(Ye==="local"?V:D,ye),rt=Je,At=Dt?ze(Dt,Ye==="local"?Q:$,Ye==="local"?V:D):!1,Lt=Dt&&!At&&!tt(ye,Dt);if(Lt&&Ye===Wt.otherSide)return dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye}),null;if(Lt&&dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye}),Dt||dt({kind:"structure",el:null,detail:"move-beats-delete",base:ye},{subject:ye,deleted:Ye==="local"?"remote":"local"}),_e.has(ye)){dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye});let Nt=G(rt,Ye);return Nt&&et.set(Je,Nt),Nt}ut(ye)&&(gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(ye,Ye,rt,!0));let at=ut(ye)?J(ye,Ye==="local"?rt:pe(D,ye)||null,Ye==="remote"?rt:pe(V,ye)||null,!1):null;return at&&(et.set(ye,at),et.set(Je,at),Dt&&et.set(Dt,at),Ye==="local"?Ze({kind:"move",el:at,source:"local"}):Xe({kind:"move",el:at,source:"remote"})),at};for(let ye of Wt.V.units){if(xt.has(ye)){if(Mt?.has(ye)){for(let kt of Mt.get(ye))Ge.has(kt)||($e.push(kt),Ge.add(kt));continue}let Ye=et.get(ye);Ge.has(Ye)||($e.push(Ye),Ge.add(Ye));continue}if(ee.has(ye)&&!(et.get(ye)&&Ge.has(et.get(ye)))){let Ye=Wt.V.baseOf(ye);Ye&&!Ke.has(Ye)&&dt({kind:"structure",el:null,detail:"both-moved",base:Ye},{subject:Ye});continue}let Je=Rn(ye,Wt.V,Wt.A,Wt.side);Je&&!Ge.has(Je)&&($e.push(Je),Ge.add(Je),!Wt.V.baseOf(ye)&&!Gt.has(ye)&&!xt.has(ye)&&Ot.add(Je))}for(let ye of Jt)Ge.has(ye.frag)||($e.splice(ye.previous&&Ge.has(ye.previous)?$e.indexOf(ye.previous)+1:jo(ye.at),0,ye.frag),Ge.add(ye.frag));if(!Wt.other.asBase){let ye=Wt.other,Je=Wt.otherSide,Ye=Wt.otherA,kt=null,Dt=0,rt=null;for(let At of ye.units){let Lt=et.get(At);if(Lt&&Ge.has(Lt)){kt=Lt,rt=null;continue}if(ee.has(At)){let sn=ye.baseOf(At);sn&&!Ke.has(sn)&&dt({kind:"structure",el:null,detail:"both-moved",base:sn},{subject:sn});continue}let at=Rn(At,ye,Ye,Je);if(!at)continue;let Nt;if(rt)Nt=$e.indexOf(rt)+1;else if(kt){if(Nt=$e.indexOf(kt)+1,Je==="remote")for(;Nt<$e.length&&Ot.has($e[Nt]);)Nt++}else Nt=Dt++;$e.splice(Nt,0,at),Ge.add(at),rt=at}}for(let ye=0;ye<Be.length;ye++){let Je=Be[ye];if(ee.has(Je))continue;let Ye=Fn(Je);Ye&&$e.splice(jo(ye),0,Ye)}return $e;function jo(ye){for(let Je=ye-1;Je>=0;Je--){let Ye=et.get(Be[Je]);if(Ye){let kt=$e.indexOf(Ye);if(kt>=0)return kt+1}}return 0}function Ir(){if((se.asBase||D.identical.has(k))&&(le.asBase||V.identical.has(k)))return;let ye={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},Je=it=>ut(it)?Un(it,ye):it.kind==="text";if(!se.asBase&&!le.asBase)for(let it of Be){if(!ut(it)||!In.has(it.tagName))continue;let nt=se.twin(it),Rt=le.twin(it);if(!nt&&Rt||nt&&!Rt){let st=Fi({base:Be,views:[{V:se,A:D,idOf:p.local},{V:le,A:V,idOf:p.remote}],eligible:Et=>ut(Et)&&In.has(Et.tagName)&&!r(Et)&&!o.remoteWins(Et),baseId:p.base,ignored:r,remoteWins:o.remoteWins,atomKey:l.exactUnitKey});st&&(se=st[0],le=st[1]);break}}let Ye=!se.asBase&&!le.asBase&&Be.length>=2&&In.has(Be[0].tagName)&&se.units.length===Be.length&&le.units.length===Be.length?Ti({base:Be,local:se.units,remote:le.units,localTwin:se.twin,remoteTwin:le.twin,eligible:it=>ut(it)&&In.has(it.tagName)&&!r(it)&&!o.remoteWins(it),nodes:{base:Array.from(te(k).childNodes),local:Array.from(te(se.el).childNodes),remote:Array.from(te(le.el).childNodes)}}):null,kt=null,Dt=null;if(!Ye&&!se.asBase&&!le.asBase&&(fs(Be)||fs(se.units)||fs(le.units))){let it={ignored:r,remoteWins:()=>!1},nt=st=>Je(st)||ut(st)&&o.remoteWins(st)&&wn.has(st.tagName)&&Un(st,it),Rt=st=>ut(st)?In.has(st.tagName)&&!r(st)&&!o.remoteWins(st)&&i(st).every(nt):st.kind==="text";kt=$i({onUncertainOwner:st=>{let Et=o.identity.local(st.local);Et&&Et===o.identity.remote(st.remote)||(Dt||=[]).push(st)},onUncertainSource:st=>{ot||(ot=new Map);let Et=ot.get(st.source);Et||ot.set(st.source,Et=[]);for(let Yt of Et)if(Yt.side===st.side&&Yt.from===st.from&&Yt.to===st.to)return;Et.push(st)},base:Be,views:[{V:se,A:D,idOf:p.local},{V:le,A:V,idOf:p.remote}],eligible:Rt,ignored:r,remoteWins:o.remoteWins,baseId:p.base,atomKey:l.exactUnitKey})}if(Dt){Mt||=new Map;for(let it of Dt){let{source:nt,local:Rt,remote:st}=it,Et={map:new Map,reverse:new Map,identical:new Set},Yt=so({base:[nt],local:[Rt],remote:[st],out:re,policy:"both",L:Et,R:Et,ignored:r,remoteWins:o.remoteWins,atomKey:l.exactUnitKey,cloneUnit:G,provenance:Se,textMappers:qe,conflicts:w,decisions:ve,conflict:(Ct,tn)=>dt(Ct,{...tn,policy:"both"}),scope:{base:k,local:se.el,remote:le.el,units:Be,at:Ue.get(nt)},node:fe});ne.push(...Yt.segments);for(let Ct of[nt,Rt,st])ee.add(Ct),xt.add(Ct),Mt.set(Ct,Yt.nodes),et.set(Ct,Yt.nodes[Yt.nodes.length-1]);for(let Ct=0;Ct<Yt.nodes.length;Ct++)Jt.push({frag:Yt.nodes[Ct],at:Ue.get(nt),previous:Ct?Yt.nodes[Ct-1]:null})}}let rt=Ye?Ye.blocks:null;if(kt){rt=new Set;for(let it of kt.blocks)rt.add(it)}let At=it=>!qt?.consumes(it)&&(rt&&rt.has(it)||Je(it)),Lt=Be.map(At);if(!Lt.includes(!0))return;let at=it=>{let nt=it.units,Rt=new Map;for(let Vt=0;Vt<nt.length;Vt++)Rt.set(nt[Vt],Vt);let st=[],Et=-1;for(let Vt=0;Vt<Be.length;Vt++){if(Lt[Vt])continue;let vt=it.twin(Be[Vt]),Tt=vt?Rt.get(vt):void 0;Tt===void 0||Tt<=Et||At(vt)||(st.push([Vt,Tt]),Et=Tt)}let Yt=[],Ct=-1,tn=-1;for(let Vt=0;Vt<=st.length;Vt++){let[vt,Tt]=Vt<st.length?st[Vt]:[Be.length,nt.length],Bt={bLo:-1,bHi:-1,from:tn+1,to:Tt,inlineStart:-1,inlineEnd:-1,next:Tt};for(let Qt=Ct+1;Qt<vt;Qt++)Lt[Qt]&&(Bt.bLo<0&&(Bt.bLo=Qt),Bt.bHi=Qt);for(let Qt=tn+1;Qt<Tt;Qt++){let zn=nt[Qt];At(zn)&&(Bt.inlineStart<0&&(Bt.inlineStart=Qt),Bt.inlineEnd=Qt+1)}Yt.push(Bt),Ct=vt,tn=Tt}return{units:nt,list:Yt}},Nt=at(se),sn=at(le),un=[];for(let it of[Nt,sn])for(let nt of it.list)nt.bLo>=0&&un.push([nt.bLo,nt.bHi]);un.sort((it,nt)=>it[0]-nt[0]);let xn=[];for(let[it,nt]of un){let Rt=xn[xn.length-1];Rt&&it<=Rt.hi?Rt.hi=Math.max(Rt.hi,nt):xn.push({lo:it,hi:nt})}let mn=(it,nt)=>it.length===nt.length&&it.every((Rt,st)=>l.equalUnits(Rt,nt[st])),kn=it=>!ut(it)&&it.kind==="comment",Ln=it=>{if(!it.length)return[];let nt=(Ct,tn)=>ut(Ct)?Ct:Ct.nodes[tn?Ct.nodes.length-1:0],Rt=nt(it[0]),st=nt(it[it.length-1],!0),Et=Ct=>Ct&&ut(Ct)&&r(Ct);for(;Et(Rt.previousSibling);)Rt=Rt.previousSibling;for(;Et(st.nextSibling);)st=st.nextSibling;let Yt=[];for(let Ct=Rt;Ct&&(Yt.push(Ct),Ct!==st);Ct=Ct.nextSibling);return Yt},ar=it=>it.some(nt=>ut(nt)&&r(nt));for(let it of xn){let nt=Be.slice(it.lo,it.hi+1),Rt=null;if(kt)for(let vt of nt){let Tt=kt.certificatesBySource.get(vt);Tt&&(Rt||=[]).push(...Tt)}let st=se.asBase?null:as(Nt,it),Et=le.asBase?null:as(sn,it);if(Rt){let vt=[new Set(st||nt),new Set(Et||nt)],Tt=Rt.some(Bt=>!vt[Bt.side].has(Bt.target));for(let Bt of nt)if(rt.has(Bt))for(let[Qt,zn]of[[0,se],[1,le]]){let Gn=zn.twin(Bt);Gn&&zn.here(Gn)&&!vt[Qt].has(Gn)&&(Tt=!0)}if(Tt)continue}if(nt.some(kn)||st&&st.some(kn)||Et&&Et.some(kn))continue;let Yt=Ln(st||nt),Ct=Ln(Et||nt);if((!st||mn(nt,st))&&(!Et||mn(nt,Et))&&!(st&&ar(Yt)))continue;let tn=so({base:Ln(nt),sourceRetentions:ot?.get(k),local:Yt,remote:Ct,out:re,policy:Qe,blocks:rt,scopeUnits:Rt?[nt,st||nt,Et||nt]:null,certifiedOrigins:Rt?(vt,Tt,Bt,Qt,zn,Gn)=>Ki({certificates:Rt,scopes:[nt,st||nt,Et||nt],flats:[vt,Tt,Bt],keys:[Qt,zn,Gn]}):null,prepared:Ye?Ye.prepared:null,nativeTransfers:Ye,L:st?D:qi(D,k),R:Et?V:qi(V,k),idOf:{base:g,local:b,remote:A},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(vt,Tt,Bt)=>J(vt,Tt,Bt,!1),cloneUnit:G,mergeAttrs:Z,atomKey:l.exactUnitKey,moveIn:ke,moveBuilt:ke,movePlanned:ke,provenance:Se,textMappers:qe,conflicts:w,conflict:dt,scope:{base:k,local:se.asBase?null:se.el,remote:le.asBase?null:le.el,units:Be,at:it.lo},decisions:ve,node:fe});if(!tn){if(Rt){let vt=Ai({certificates:Rt,scopes:[nt,st||nt,Et||nt],views:[{V:se,A:D,idOf:p.local},{V:le,A:V,idOf:p.remote}],eligible:Tt=>ut(Tt)&&In.has(Tt.tagName)&&!r(Tt)&&!o.remoteWins(Tt),baseId:p.base});for(let Tt of vt.records){ot||=new Map;let Bt=ot.get(Tt.source);Bt||ot.set(Tt.source,Bt=[]),Bt.push(Tt)}}continue}if(ne.push(...tn.segments),Ye){let vt=new Map;for(let Tt of tn.nodes){let Bt=Se.get(Tt)?.base;if(!Bt||vt.has(Bt))throw new Error("Invalid native transfer owner output");vt.set(Bt,Tt)}if(vt.size!==Ye.owners.length)throw new Error("Incomplete native transfer owner output");for(let Tt of Ye.owners){let Bt=vt.get(Tt.base);if(!Bt)throw new Error("Missing native transfer owner output");for(let Qt of[Tt.base,Tt.local,Tt.remote])ee.add(Qt),xt.add(Qt),et.set(Qt,Bt);Jt.push({frag:Bt,at:Ue.get(Tt.base)})}continue}if(tn.unitOutputs){Mt||=new Map;for(let vt of[...nt,...st||[],...Et||[]]){let Tt=tn.unitOutputs.get(vt)||[];ee.add(vt),xt.add(vt),Mt.set(vt,Tt),Tt.length&&et.set(vt,Tt[Tt.length-1])}for(let vt=0;vt<tn.nodes.length;vt++)Jt.push({frag:tn.nodes[vt],at:it.lo,previous:vt>0?tn.nodes[vt-1]:null});continue}let Vt=re.createDocumentFragment();for(let vt of tn.nodes)Vt.appendChild(vt);for(let vt of[...nt,...st||[],...Et||[]])ee.add(vt),xt.add(vt),et.set(vt,Vt);Jt.push({frag:Vt,at:it.lo})}}}function he(k,$){let Q=Se.get(k);return Q&&Q.unchanged?!Q.remote||Q.remote===$?!0:ce(Q.remote,$):k.tagName!==$.tagName||!q(k,$)?!1:ae(te(k),te($))}function ce(k,$){return k===$?!0:k.tagName!==$.tagName||k.namespaceURI!==$.namespaceURI||!q(k,$)?!1:xe(te(k),te($))}function xe(k,$){let Q=Ce(k,r),be=Ce($,r);if(Q.length!==be.length)return!1;for(let fe=0;fe<Q.length;fe++){let se=Q[fe],le=be[fe];if(typeof se=="string"||typeof le=="string"){if(se!==le)return!1}else{if(se.nodeType!==le.nodeType)return!1;if(se.nodeType===1){if(!ce(se,le))return!1}else if(se.nodeValue!==le.nodeValue)return!1}}return!0}function te(k){return k.tagName==="TEMPLATE"&&k.content?k.content:k}function q(k,$){let Q=0;for(let be of k.attributes)if(!o.ignoreAttribute(k,be.name)&&(Q++,$.getAttribute(be.name)!==be.value))return!1;for(let be of $.attributes)o.ignoreAttribute($,be.name)||Q--;return Q===0}function ae(k,$){let Q=Ce(k,fe=>{let se=Se.get(fe);return!!(se&&se.pinned)}),be=Ce($,r);if(Q.length!==be.length)return!1;for(let fe=0;fe<Q.length;fe++){let se=Q[fe],le=be[fe];if(typeof se=="string"||typeof le=="string"){if(se!==le)return!1}else{if(se.nodeType!==le.nodeType)return!1;if(se.nodeType===1){if(!he(se,le))return!1}else if(se.nodeValue!==le.nodeValue)return!1}}return!0}function Ce(k,$){let Q=[],be=null;for(let fe=k.firstChild;fe;fe=fe.nextSibling){if(fe.nodeType===3){be=be===null?fe.nodeValue:be+fe.nodeValue;continue}fe.nodeType===1&&$(fe)||(be!==null&&(be!==""&&Q.push(be),be=null),Q.push(fe))}return be!==null&&be!==""&&Q.push(be),Q}function Le(k,$,Q,be){let fe=k.value,se=be?fe:$?$.value:"",le=Q?Q.value:"";ee.add(k),$&&ee.add($),Q&&ee.add(Q);let Be=se===le?se:se===fe?le:le===fe||Qe==="local"?se:le,Ke={site:"comment",bRun:k,lRun:$,rRun:Q,node:null};if(se!==fe&&le!==fe&&se!==le&&dt({kind:"text",node:null,base:fe,local:se,remote:le,resolved:Be},Ke),!$&&!Q)return null;let Ue=re.createComment(Be);return Ke.node=Ue,Se.set(Ue,{base:k.nodes,local:$?$.nodes:null,remote:Q?Q.nodes:null}),Ue}function We(k,$){let Q=pe($,k);if(!Q)return null;let be=ut(Q)?Q.parentNode:Q.parent,fe=ut(k)?k.parentNode:k.parent;return pe($,fe)===be?null:$.reverse.get(be)||null}function Ne(k){let $=new Set([k]),Q=k;for(let be=0;be<64;be++){let fe=We(Q,D)||We(Q,V);if(!fe)return!1;if(fe===k||ut(k)&&ut(fe)&&k.contains(fe)||$.has(fe))return!0;$.add(fe),Q=fe}return!0}function ze(k,$,Q){if(!$)return!1;let be=ut(k)?k.parentNode:k.parent;return be===$||$.tagName==="TEMPLATE"&&be===$.content}function tt(k,$){let Q=De(k),be=pe(D,Q);if(be&&ze($,be,D))return!0;let fe=pe(V,Q);return!!(fe&&ze($,fe,V))}}function qi(e,n){return e.map.get(n)?zi():{map:{get:o=>o&&o.nodeType===1&&e.map.get(o)||o,has:()=>!0},reverse:{get:o=>e.reverse.get(o)||o,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function zi(){let e={get:n=>n,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Gi=new Set(["INPUT","OPTION","TEXTAREA"]),ds=/[\t\n\f\r ]+/;function Yi(e,n,t,o){let r=e.ownerDocument,{provenance:c,textMappers:l}=t,i=o.hooks,s=[],a=[],h=[],f=new Set,u=[],g=[],b=new Map,A=new Set,p=new Map,m=t.conflicts.length>0,y=new Map,R=new Set,S=new Map,O=(_,ie)=>{let me=S.get(_);me||S.set(_,me=new Set),me.add(ie)},M=m?new Set:null,E=(_,ie,me)=>{let pe=i.beforeAttributeUpdated(_,ie,me);return m&&pe===!1&&O(ie,_),pe},N=_=>!!_&&(_===e||e.contains(_)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(_)),L=new Map,j=new Map,F=new Map,W=new Set,C=new Map;(function _(ie){let me=c.get(ie);if(me){if(ie.nodeType===1){let ke=me.local?o.toLive(me.local):null;ke&&N(ke)&&ke.nodeType===1&&(L.set(ie,ke),j.set(ke,ie))}else if(Array.isArray(me.local)){let ke=V(me.local,me.local.map(v=>o.toLive(v)).filter(v=>v&&N(v)&&v.nodeType===ie.nodeType));if(ke.length&&(L.set(ie,ke[0]),j.set(ke[0],ie),F.set(ie,ke)),Array.isArray(me.caret))for(let v of me.caret){let P=o.toLive(v.node);if(!P||!N(P)||P.nodeType!==3)continue;let Y=C.get(P);Array.isArray(Y)||C.set(P,Y=[]),Y.push({merged:ie,from:v.from,to:v.to,flatStart:v.flatStart})}else{let v=0;for(let P of ke)C.set(P,{merged:ie,shift:v}),v+=P.nodeValue.length}}}let pe=ie.nodeType===1&&ie.tagName==="TEMPLATE"&&ie.content?ie.content.childNodes:ie.childNodes;for(let ke of pe)_(ke)})(n);let T=new Set;for(let _ of L.values())T.add(_);for(let _ of F.values())for(let ie of _)T.add(ie);let x=o.localRoot&&o.localRoot!==e?new Set:null;if(x){for(let _=o.localRoot.firstElementChild;_;_=_.nextElementSibling)if(_.tagName==="HEAD")for(let ie=_.firstElementChild;ie;ie=ie.nextElementSibling){let me=o.toLive(ie);me&&x.add(me)}}for(let _ of t.segments||[])Ee(_);let z=o.restoreFocus===!1?null:la(r,C);o.childrenOnly?Se(Me(e),Me(n)):De(e,n);for(let{node:_,parent:ie}of u)f.has(_)||!_.parentNode||_.nodeType===1&&(o.ignored(_)||qe(_))||ot(_,ie);return ca(r,z,C,l,F,p,W),{applied:s,moved:a,replaced:h,identities:g,mergedScriptsLive:A,liveOf:L,heldBy:p,runOf:F,keptRuns:W,insertedLive:y,vetoed:R,vetoedAttrs:S,removedVetoes:M};function D(_,ie){let me=_.slice(ie.bs,ie.be),pe=0;for(;pe<me.length&&pe<ie.text.length&&me[pe]===ie.text[pe];)pe++;let ke=0;for(;ke<me.length-pe&&ke<ie.text.length-pe&&me[me.length-1-ke]===ie.text[ie.text.length-1-ke];)ke++;return{bs:ie.bs+pe,be:ie.be-ke,text:ie.text.slice(pe,ie.text.length-ke)}}function V(_,ie){if(!ie.length)return ie;let me=[];for(let v of _){let P=v.parentNode;if(!P)continue;let Y=b.get(P);if(!Y){Y=new Set;for(let J=P.firstChild;J;J=J.nextSibling)J.nodeType===3&&Y.add(o.toLive(J));b.set(P,Y)}me.includes(Y)||me.push(Y)}let pe={has:v=>me.some(P=>P.has(v))},ke=[];for(let v of ie){ke.push(v);for(let P=v.nextSibling;P&&P.nodeType===3&&!pe.has(P)&&!ke.includes(P);P=P.nextSibling)ke.push(P)}return ke}function Ee(_){let ie=[];for(let ge of _.localNodes){let B=o.toLive(ge.node);if(!B||!N(B)||B.nodeType!==3)return;ie.push(B)}let me=V(_.localNodes.map(ge=>ge.node),ie);if(!me.length)return;let pe=me.map(ge=>ge.nodeValue).join(""),{flatLocal:ke,lToM:v,mapLocal:P}=_;if(pe===ke)return;let Y=_.textNodes.map(ge=>({node:ge.node,ms:ge.ms,me:ge.me})),J=[],oe=0;for(let ge of me)J.push(oe),oe+=ge.nodeValue.length;let je=(ge,B)=>me.find((G,ue)=>J[ue]<=ge&&ge+B<=J[ue]+G.nodeValue.length)||null,Z=[],Oe=0;for(let ge of ro(ke,pe).map(B=>D(ke,B))){let B=ge.bs+Oe;Oe+=ge.text.length-(ge.be-ge.bs);let G,ue;if(ge.be>ge.bs){G=v[ge.bs];let he=G>=0;for(let ce=ge.bs;he&&ce<ge.be;ce++)v[ce]!==G+(ce-ge.bs)&&(he=!1);if(!he)continue;ue=G+(ge.be-ge.bs)}else{let he=ge.bs>0?v[ge.bs-1]:0,ce=ge.bs<ke.length?v[ge.bs]:0;if(he<0||ce<0)continue;G=ue=P(ge.bs)}Z.push({ms:G,me:ue,text:ge.text,live:ue===G?je(B,ge.text.length):null})}Z.sort((ge,B)=>B.ms-ge.ms);let He=(ge,B)=>(F.get(ge.node)||[L.get(ge.node)]).includes(B),Ie=ge=>!!ge&&ge.nodeType===1&&wn.has(ge.tagName);for(let ge of Z){let B=Y.find(ue=>ue.ms<=ge.ms&&ge.me<=ue.me&&ge.ms<ue.me);if(B&&ge.live&&B.ms===ge.ms&&!He(B,ge.live)){let ue=Y.find(he=>he.me===ge.ms&&He(he,ge.live));ue&&(B=ue)}if(!B&&ge.me===ge.ms){let ue=Y.find(te=>te.me===ge.ms),he=Y.find(te=>te.ms===ge.ms),ce=ue||he;if(!ce)continue;let xe=ce.node;for(;Ie(xe.parentNode)&&(ue?xe.parentNode.lastChild:xe.parentNode.firstChild)===xe;)xe=xe.parentNode;if(xe===ce.node)B=ce;else{let te=xe.ownerDocument.createTextNode(ge.text);xe.parentNode.insertBefore(te,ue?xe.nextSibling:xe);continue}}if(!B)continue;let G=B.node.nodeValue;B.node.nodeValue=G.slice(0,ge.ms-B.ms)+ge.text+G.slice(ge.me-B.ms),B.me+=ge.text.length-(ge.me-ge.ms)}}function Me(_){return _.nodeType===1&&_.tagName==="TEMPLATE"&&_.content?_.content:_}function De(_,ie){f.add(_);let me=c.get(ie);if(me&&me.remote&&t.remoteIdOf){let ke=t.remoteIdOf(me.remote);ke&&g.push([_,ke])}if(me&&me.unchanged){t.customIdentity&&me.remote&&ne(_,me.remote),me.remote&&K(_,me.remote);return}if(i.beforeNodeMorphed(_,ie)===!1){R.add(ie);return}gt(_,ie,o.keepLiveOnly&&me&&me.local&&me.local.nodeType===1&&me.local!==_?me.local:null);let pe=_.tagName;if(hn(_))_.textContent!==ie.textContent&&(s.push({kind:"text",node:_,before:_.textContent,after:ie.textContent}),_.textContent=ie.textContent),t.mergedScripts.has(ie)&&A.add(_);else if(pe==="TEXTAREA")zt(_,ie,me);else{an(_,ie,me);let ke=pe==="TEMPLATE"&&_.content?_.content:_,v=pe==="TEMPLATE"&&ie.content?ie.content:ie;o.protectFocusedValue==="subtree"&&$t(_)&&_!==r.body?re(ke):Se(ke,v)}i.afterNodeMorphed(_,ie)}function re(_){for(let ie=_.firstChild;ie;ie=ie.nextSibling){let me=j.get(ie);me&&L.get(me.parentNode)!==_||(f.add(ie),ie.nodeType===1&&re(ie))}}function Se(_,ie){let me=_e(_.firstChild),pe=new Set;for(let ke of Array.from(ie.childNodes)){let v=L.get(ke);v&&f.has(v)&&!pe.has(v)&&(v=null);let P=c.get(ke);if(P&&P.pinned){v&&v.nodeType===1&&((v.parentNode!==_||_e(v.nextSibling)!==me)&&Ae(_,v,me),f.add(v),pe.add(v));continue}if(v&&v.nodeType===1){if(v!==me){let oe=v.parentNode;if(oe===_&&me&&Ht(v)){let je=v.nextSibling;for(let Z=me;Z&&Z!==v;){let Oe=Z.nextSibling;Ae(_,Z,je),Z=Oe}}else Ae(_,v,me),oe!==_&&(a.push(v),s.push({kind:"move",el:v,from:oe,to:_}))}pe.add(v),De(v,ke),me=_e(v.nextSibling);continue}if(v&&v.nodeType!==1){let oe=F.get(ke)||[v],je=oe.map(Oe=>Oe.nodeValue).join(""),Z=ke.nodeValue;if(ke.nodeType===3){let Oe=ve(ke);Oe!=null&&je!==Oe&&(Z=Ho(Oe,je,ke.nodeValue).text)}if(oe.length>1&&je===Z&&!oe.includes(me,1)&&oe.every((Oe,He)=>Oe.parentNode===_&&(He===0||oe[He-1].nextSibling===Oe))){if(v!==me)for(let Oe of oe)Ae(_,Oe,me);i.beforeNodeMorphed(v,ke)!==!1?i.afterNodeMorphed(v,ke):m&&R.add(ke);for(let Oe of oe)f.add(Oe),pe.add(Oe);p.set(ke,v),W.add(ke),me=_e(oe[oe.length-1].nextSibling);continue}v!==me&&Ae(_,v,me),i.beforeNodeMorphed(v,ke)!==!1?(v.nodeValue!==Z&&(s.push({kind:"text",node:v,before:v.nodeValue,after:Z}),v.nodeValue=Z),i.afterNodeMorphed(v,ke)):R.add(ke),f.add(v),pe.add(v),p.set(ke,v),me=_e(v.nextSibling);continue}if(ke.nodeType===3&&me&&me.nodeType===3&&!f.has(me)&&!C.has(me)){me.nodeValue!==ke.nodeValue&&(s.push({kind:"text",node:me,before:me.nodeValue,after:ke.nodeValue}),me.nodeValue=ke.nodeValue),f.add(me),p.set(ke,me),me=_e(me.nextSibling);continue}let Y=c.get(ke),J=Qe(Y&&Y.unchanged&&Y.remote?Y.remote:ke);if(i.beforeNodeAdded(J)===!1){R.add(ke);continue}_.insertBefore(J,me),f.add(J),m&&y.set(ke,J),J.nodeType===3&&p.set(ke,J),J.nodeType===1&&(h.push(J),Pe(J,ke),t.customIdentity&&Y&&Y.unchanged&&Y.remote&&ne(J,Y.remote),hn(J)||Ze(J,ke),o.formState==="property"&&jt(Y)&&K(J,Y.remote)),me=_e(J.nextSibling),s.push({kind:"insert",node:J,parent:_}),i.afterNodeAdded(J)}for(let ke of Array.from(_.childNodes))f.has(ke)||pe.has(ke)||ke.nodeType===1&&(o.ignored(ke)||qe(ke))||(T.has(ke)?u.push({node:ke,parent:_}):ot(ke,_))}function qe(_){return _.parentNode&&_.parentNode.nodeType===1&&_.parentNode.tagName==="HEAD"&&(x&&!x.has(_)||o.preserve&&o.preserve(_)===!0)}function ve(_){let ie=c.get(_);return!ie||!Array.isArray(ie.local)?null:ie.local.map(me=>me.nodeValue).join("")}function w(_){return c.get(_)}function K(_,ie){if(!Gi.has(_.tagName)&&!_.querySelector("input,option,textarea"))return;let me=(pe,ke)=>{if(pe.tagName!==ke.tagName)return;pe.tagName==="TEXTAREA"?zt(pe,ke,{remote:ke}):Gi.has(pe.tagName)&&an(pe,ke,{remote:ke});let v=ee(pe),P=ee(ke);if(v.length===P.length)for(let Y=0;Y<v.length;Y++)me(v[Y],P[Y])};me(_,ie)}function ne(_,ie){let me=ee(_),pe=ee(ie);if(me.length===pe.length)for(let ke=0;ke<me.length;ke++){let v=t.remoteIdOf(pe[ke]);v&&g.push([me[ke],v]),ne(me[ke],pe[ke])}}function ee(_){let ie=_.tagName==="TEMPLATE"&&_.content?_.content:_;return Array.from(ie.children).filter(me=>!o.ignored(me))}function Pe(_,ie){if(!t.remoteIdOf)return;let me=(pe,ke)=>{let v=c.get(ke);if(v&&v.remote&&ke.nodeType===1){let J=t.remoteIdOf(v.remote);J&&g.push([pe,J])}let P=pe.childNodes,Y=ke.childNodes;for(let J=0;J<P.length&&J<Y.length;J++)me(P[J],Y[J])};me(_,ie)}function _e(_){for(;_&&_.nodeType===1&&o.ignored(_);)_=_.nextSibling;return _}function Ae(_,ie,me){if(typeof _.moveBefore=="function"&&ie.ownerDocument===_.ownerDocument)try{_.moveBefore(ie,me);return}catch{}_.insertBefore(ie,me)}function ot(_,ie){if(i.beforeNodeRemoved(_)===!1){m&&M.add(_);return}_.parentNode.removeChild(_),s.push({kind:"remove",node:_,parent:ie}),i.afterNodeRemoved(_)}function Qe(_){if(hn(_))return Vo(_,r);let ie=r.importNode(_,!0);if(ie.nodeType===1)for(let me of Array.from(ie.querySelectorAll("script")))hn(me)&&me.replaceWith(Vo(me,r));return ie}function Ze(_,ie){let me=_.tagName==="TEMPLATE"&&_.content?_.content:_,pe=ie.tagName==="TEMPLATE"&&ie.content?ie.content:ie,ke=Array.from(me.childNodes),v=Array.from(pe.childNodes);for(let P=0;P<v.length&&P<ke.length;P++){let Y=v[P],J=ke[P],oe=L.get(Y);oe&&f.has(oe)&&(oe=null);let je=c.get(Y);if(je&&je.pinned){if(oe&&oe.nodeType===1){let Z=oe.parentNode;Ae(me,oe,J),Z!==me&&(a.push(oe),s.push({kind:"move",el:oe,from:Z,to:me})),f.add(oe)}J.remove();continue}if(oe){let Z=oe.parentNode;Ae(me,oe,J),J.remove(),oe.nodeType===1?(Z!==me&&(a.push(oe),s.push({kind:"move",el:oe,from:Z,to:me})),De(oe,Y)):(f.add(oe),p.set(Y,oe),oe.nodeValue!==Y.nodeValue&&(s.push({kind:"text",node:oe,before:oe.nodeValue,after:Y.nodeValue}),oe.nodeValue=Y.nodeValue));continue}f.add(J),m&&y.set(Y,J),J.nodeType===3&&p.set(Y,J),je&&je.unchanged&&je.remote?(Xe(J,je.remote),t.customIdentity&&ne(J,je.remote)):Y.nodeType===1&&!hn(Y)&&Ze(J,Y)}}function Xe(_,ie){let me=_.tagName==="TEMPLATE"&&_.content?_.content:_,pe=ie.tagName==="TEMPLATE"&&ie.content?ie.content:ie;for(let ke of Array.from(pe.childNodes))me.appendChild(Qe(ke))}function yt(_,ie){return ie.namespaceURI?_.getAttributeNS(ie.namespaceURI,ie.localName):_.getAttribute(ie.name)}function dt(_,ie){let me=new Set((ie||"").split(ds).filter(Boolean));return(_||"").split(ds).filter(pe=>pe&&!me.has(pe))}function gt(_,ie,me){for(let pe of Array.from(ie.attributes)){if(qt(_,pe.name)||o.ignoreAttribute(_,pe.name))continue;let ke=yt(_,pe);if(ke===pe.value||me&&yt(me,pe)===pe.value)continue;let v=pe.value;if(me&&pe.name==="class"&&!pe.namespaceURI){let P=pe.value.split(ds).filter(Boolean),Y=dt(ke,me.getAttribute("class")).filter(J=>!P.includes(J));Y.length&&(v=[...P,...Y].join(" "))}if(ke!==v){if(i.beforeAttributeUpdated(pe.name,_,"update")===!1){m&&O(ie,pe.name);continue}pe.namespaceURI?_.setAttributeNS(pe.namespaceURI,pe.name,v):_.setAttribute(pe.name,v),s.push({kind:"attr",el:_,name:pe.name,before:ke,after:v})}}for(let pe of Array.from(_.attributes)){if(qt(_,pe.name)||o.ignoreAttribute(_,pe.name)||(pe.namespaceURI?ie.hasAttributeNS(pe.namespaceURI,pe.localName):ie.hasAttribute(pe.name)))continue;if(me&&pe.name==="class"&&!pe.namespaceURI){let P=dt(pe.value,me.getAttribute("class"));if(P.length){let Y=P.join(" ");if(Y===pe.value)continue;if(i.beforeAttributeUpdated("class",_,"update")===!1){m&&O(ie,"class");continue}_.setAttribute("class",Y),s.push({kind:"attr",el:_,name:"class",before:pe.value,after:Y});continue}}if(me&&yt(me,pe)===null)continue;if(i.beforeAttributeUpdated(pe.name,_,"remove")===!1){m&&O(ie,pe.name);continue}let v=pe.value;pe.namespaceURI?_.removeAttributeNS(pe.namespaceURI,pe.localName):_.removeAttribute(pe.name),s.push({kind:"attr",el:_,name:pe.name,before:v,after:null})}}function qt(_,ie){let me=_.tagName;return me==="INPUT"?ie==="value"||ie==="checked"||ie==="disabled":me==="OPTION"?ie==="selected":!1}function $t(_){return _===r.activeElement}function Ht(_){let ie=r.activeElement;return!!ie&&ie!==r.body&&_.contains(ie)}function jt(_){let ie=_&&_.remote;return ie&&ie.nodeType===1?ie:null}function an(_,ie,me){let pe=_.tagName,ke=jt(me),v=o.formState==="property"&&ke?ke:ie;if(pe==="INPUT"){let P=o.protectFocusedValue&&$t(_),Y=(_.getAttribute("type")||"").toLowerCase(),J=Y!=="file"&&Y!=="checkbox"&&Y!=="radio",oe=ke&&ke.hasAttribute("value")&&ke.value!==ke.getAttribute("value")?ke.value:null;if(J&&!P)if(o.formState==="property"){let je=ie.getAttribute("value"),Z=_.getAttribute("value");(Z!==je||_.value!==v.value)&&E("value",_,je==null?"remove":"update")!==!1&&(Z!==je&&(je==null?_.removeAttribute("value"):_.setAttribute("value",je),s.push({kind:"attr",el:_,name:"value",before:Z,after:je})),_.value!==v.value&&(_.value=v.value))}else if(ie.hasAttribute("value")||oe!=null){let je=oe??ie.getAttribute("value");_.getAttribute("value")!==je&&E("value",_,"update")!==!1?(_.setAttribute("value",je),_.value!==je&&(_.value=je),s.push({kind:"attr",el:_,name:"value",before:null,after:je})):_.value!==je&&_.getAttribute("value")===je&&(_.value=je)}else(_.hasAttribute("value")||_.value!=="")&&E("value",_,"remove")!==!1&&(_.removeAttribute("value"),_.value="",s.push({kind:"attr",el:_,name:"value",before:"",after:null}));if(!J&&Y!=="file"){let je=ie.getAttribute("value");je==null?_.hasAttribute("value")&&E("value",_,"remove")!==!1&&_.removeAttribute("value"):_.getAttribute("value")!==je&&E("value",_,"update")!==!1&&_.setAttribute("value",je)}P||(_t(_,v,"checked"),o.formState==="property"&&_.indeterminate!==v.indeterminate&&(_.indeterminate=v.indeterminate)),_t(_,v,"disabled")}else if(pe==="OPTION"){let P=_.parentNode&&_.closest("select");o.protectFocusedValue&&P&&$t(P)||_t(_,v,"selected")}}function _t(_,ie,me){let pe=o.formState==="property"?!!ie[me]:ie.hasAttribute(me);if(o.formState!=="property"){let ke=_.hasAttribute(me);if(ke!==pe){if(E(me,_,pe?"update":"remove")===!1)return;pe?_.setAttribute(me,""):_.removeAttribute(me),s.push({kind:"attr",el:_,name:me,before:ke?"":null,after:pe?"":null})}}_[me]!==pe&&(_[me]=pe)}function zt(_,ie,me){if(o.protectFocusedValue&&$t(_)||E("value",_,"update")===!1)return;let pe=jt(me),ke=ie.textContent,v=pe&&pe.value!==pe.defaultValue?pe.value:ke;o.formState!=="property"&&_.textContent!==ke&&(s.push({kind:"text",node:_,before:_.textContent,after:ke}),_.textContent=ke),_.value!==v&&(_.value=v)}}function la(e,n){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let o={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{o.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return o}let r=e.getSelection&&e.getSelection();if(r&&r.rangeCount){let c=r.getRangeAt(0);o.range={sc:c.startContainer,so:c.startOffset,ec:c.endContainer,eo:c.endOffset}}return o}function ca(e,n,t,o,r,c,l){if(!n)return;let i=n.el;if(!i.isConnected&&n.id&&(i=e.getElementById(n.id)),!i||!i.isConnected)return;if(e.activeElement!==i)try{i.focus({preventScroll:!0})}catch{}try{i.scrollTop=n.scrollTop,i.scrollLeft=n.scrollLeft}catch{}if(n.selection){try{i.setSelectionRange&&!i.selectionEnd&&n.selection[1]!=null&&i.setSelectionRange(n.selection[0],n.selection[1],n.selection[2]||"none")}catch{}return}if(!n.range)return;let s=(f,u)=>{let g=t.get(f);if(Array.isArray(g)){let b=g.find(y=>u>=y.from&&u<y.to)||g.find(y=>u===y.to)||g[g.length-1],A=c.get(b.merged);if(!A||!A.isConnected)return null;let p=o.get(b.merged),m=p&&p.flat?p.flat(b.flatStart+u):u;return[A,Math.max(0,Math.min(m,A.nodeValue.length))]}if(g&&!l.has(g.merged)){let b=(r.get(g.merged)||[f])[0];if(!b.isConnected)return null;let A=o.get(g.merged),p=g.shift+u,m=A?A(p):p;return[b,Math.max(0,Math.min(m,b.nodeValue.length))]}return f.isConnected?[f,Math.min(u,f.nodeType===3?f.nodeValue.length:f.childNodes.length)]:null},a=s(n.range.sc,n.range.so),h=s(n.range.ec,n.range.eo);if(!(!a||!h))try{let f=e.createRange();f.setStart(a[0],a[1]),f.setEnd(h[0],h[1]);let u=e.getSelection();u.removeAllRanges(),u.addRange(f)}catch{}}var aa={compared:0},fa=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function ua(e,n,t){let o=0;for(let r of e.attributes)if(!t(e,r.name)&&(o++,n.getAttribute(r.name)!==r.value))return!1;for(let r of n.attributes)t(n,r.name)||o--;return o===0}function hs(e,n){if(e.namespaceURI!==n.namespaceURI||e.prefix!==n.prefix||e.localName!==n.localName)return!1;let t=e.attributes;if(t.length!==n.attributes.length)return!1;for(let o of t)if(n.getAttributeNS(o.namespaceURI,o.localName)!==o.value)return!1;return!0}function Xi(e,n,t,o,r,c,l,i){let s=new Map,a=new Set,h=f=>{if(o(f))return;let u=t(f);u&&(c.add(u),r.has(u)||s.has(u)?a.add(u):s.set(u,f))};for(let f of e)h(f);h(n);for(let f of l||n.querySelectorAll("*"))h(f);for(let f of a)s.delete(f),i.add(f);return s}function Ji(e,n,t,o,r,c){let l=!1;for(let h of r)h.startsWith("merge:")&&(l=!0);if(!l)return[...o];let i=new Map,s=[],a=c===bn?$o:"*";for(let h of[e,...e.querySelectorAll(a)]){if(t(h))continue;let f=n(h);if(!f||!(o.has(f)||r.has(f)))continue;let u=(i.get(f)||0)+1;i.set(f,u),u===2&&s.push(f)}return s}function Qi({baseRoot:e,remoteRoot:n,liveRoot:t,toLive:o,o:r,identity:c,baseURI:l}){if(e.tagName!==n.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||n.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!ua(e,n,r.ignoreAttribute))return{bail:"root-attrs"};let{ignored:i,remoteWins:s}=r,a=us(r.scripts.merge===!1?null:r.scripts.mergeTags,l),h=ve=>{let w=a(ve);return w!==null?w:c.base(ve)||null},f=ve=>{let w=a(ve);return w!==null?w:c.remote(ve)||null},u=[],g=[],b=new Map,A=new Map,p={same:b,differ:A},m=ve=>({bail:ve,comparisons:p}),y=(ve,w,K=!0)=>{if(b.get(ve)===w)return!0;if(A.get(ve)===w)return!1;if(aa.compared++,K&&ve.isEqualNode(w))return b.set(ve,w),!0;let ne=ve.nodeType===w.nodeType;if(ne&&ve.nodeType===1){if(ne=hs(ve,w),ne){let ee=ve.firstChild,Pe=w.firstChild;for(;ee&&Pe;ee=ee.nextSibling,Pe=Pe.nextSibling)if(!y(ee,Pe,!1)){ne=!1;break}(ee||Pe)&&(ne=!1)}}else ne&&(ne=ve.isEqualNode(w));return(ne?b:A).set(ve,w),ne},R=e,S=n,O=!1,M=()=>{b.set(R,S);for(let ve=0;ve<u.length;ve++)b.set(u[ve],g[ve]);return m("equal")};for(;;){let ve=R.childNodes,w=S.childNodes;if(ve.length!==w.length)break;let K=Qe=>y(ve[Qe],w[Qe])?(b.set(ve[Qe],w[Qe]),!1):!0,ne=-1,ee=-1;for(let Qe=0;Qe<ve.length;Qe++){if(ve[Qe].nodeType!==1)continue;let Ze=0;for(let Xe=ve[Qe].firstElementChild;Xe;Xe=Xe.nextElementSibling)Ze++;Ze>=ee&&(ee=Ze,ne=Qe)}let Pe=[],_e=!1;for(let Qe=0;Qe<ve.length&&Pe.length<2;Qe++)Qe!==ne&&K(Qe)&&Pe.push(Qe);if(ne>=0&&Pe.length<2&&(Pe.length===0&&hs(R,S)?(Pe.push(ne),_e=!0):K(ne)&&Pe.push(ne)),Pe.length!==1){if(!O&&Pe.length===0&&hs(R,S))return M();break}let Ae=ve[Pe[0]],ot=w[Pe[0]];if(O=O||!_e,O&&A.set(Ae,ot),Ae.nodeType!==1||ot.nodeType!==1||Ae.tagName!==ot.tagName)break;if(h(Ae)!==f(ot)){if(!O&&y(Ae,ot))return M();break}u.push(R),g.push(S),R=Ae,S=ot}A.set(R,S);for(let ve=0;ve<u.length;ve++)A.set(u[ve],g[ve]);if(R===e||R.tagName==="HEAD"||R.tagName==="BODY")return m("root-level");if(u.length<2||u[1].tagName!=="BODY")return m("not-in-body");if(i(R)||i(S))return m("ignored-ancestor");if(s(R)||s(S))return m("remote-wins-ancestor");for(let ve of u)if(fa.has(ve.tagName))return m("form-ancestor");if(R.tagName==="SCRIPT"||R.getElementsByTagName("script").length||S.getElementsByTagName("script").length)return m("script-or-template");let E=o(R);if(!E||E.nodeType!==1||E.tagName!==R.tagName)return m("no-live-twin");if(!t.contains(E))return m("live-detached");for(let ve of u){let w=o(ve);if(!w||w.nodeType!==1)return m("ancestor-live")}let N=c.base===bn&&c.remote===bn&&i===Hr,L=new Set,j=new Set,F=[],W=null,C=ve=>{ve&&(L.has(ve)?j.add(ve):L.add(ve))},T=(ve,w)=>{let K=a(ve),ne=K!==null?K:c.base(ve)||null;return ne!==(K!==null?K:c.remote(w)||null)?!1:(C(ne),!0)},x=(ve,w)=>{for(let K=ve.firstElementChild,ne=w.firstElementChild;K;K=K.nextElementSibling,ne=ne.nextElementSibling){let ee=i(K);if(ee!==i(ne))return!1;if(!ee&&(!T(K,ne)||!x(K,ne)))return!1}return!0},z=ve=>{let w=ve+1<u.length?u[ve+1]:R;for(let K=u[ve].firstElementChild,ne=g[ve].firstElementChild;K;K=K.nextElementSibling,ne=ne.nextElementSibling){if(K===w){let _e=ve+1<u.length?z(ve+1):null;if(_e)return _e;continue}let ee=i(K);if(ee!==i(ne))return"outside-id-changed";if(ee)continue;let Pe=o(K);if(!Pe||Pe.nodeType!==1)return"sibling-live";if(F.push([K,ne]),!N&&(!T(K,ne)||!x(K,ne)))return"outside-id-changed";ve===0&&K.tagName==="HEAD"&&h(K)&&(W=[K,ne])}return null},D=z(0);if(D)return m(D);let V=new Set(u),Ee=null;if(c.base===bn){Ee=[];for(let ve of e.querySelectorAll($o))ve===R||V.has(ve)||(R.contains(ve)?Ee.push(ve):N&&C(h(ve)))}let Me=new Set,De=new Set,re=new Set,Se=Xi(u,R,h,i,L,Me,Ee,De),qe=Xi(g,S,f,i,L,Me,c.remote===bn&&S.querySelectorAll($o),re);return W&&(j.has(h(W[0]))||Me.has(h(W[0])))&&(W=null),{scope:{chain:u,root:R,onChain:V,baseIndex:Se,remoteIndex:qe,baseDropped:De,remoteDropped:re,head:W,same:b,differ:A,dropped:[...Ji(e,h,i,j,De,c.base),...Ji(n,f,i,j,re,c.remote)],held:ve=>{for(let w=1;w<u.length;w++)if(ve.map.get(u[w])!==g[w])return!1;for(let[w,K]of F)if(ve.map.get(w)!==K)return!1;return!0}}}}var qu=Symbol("hyper-morph-duplicate-key");var da='[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"]',ha='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',pa='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function ma(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let n=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(n)}function ga(e,n,t,o){if(n==null)return;if(typeof n=="string")return n;let r=n;if(r.nodeType===9){let c=e.getAttribute("id");r=c&&r.getElementById(c)||(e.tagName==="BODY"?r.body:e.tagName==="HTML"?r.documentElement:r.body&&r.body.firstElementChild)}if((!r||r.nodeType!==1||r.tagName!==e.tagName)&&(r=ba(e,n,o)),!!r)return t?Array.from(r.childNodes):r}function ba(e,n,t){let o=n.nodeType===9?n.documentElement:n;if(!o||o.nodeType!==1)return null;let r=new Map,c=[o,...o.querySelectorAll("script")];for(let s of c){let a=So(s,t);a&&!r.has(a.key)&&r.set(a.key,s.textContent)}if(!r.size)return null;let l=e.cloneNode(!0),i=!1;for(let s of[l,...l.querySelectorAll("script")]){let a=So(s,t);a&&r.has(a.key)&&(s.textContent=r.get(a.key),i=!0)}return i?l:null}function Zi(e,n){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=n.implementation.createHTMLDocument(""),o=e.nodeType===1&&e.tagName==="HTML"?e:null;if(o)return t.replaceChild(t.adoptNode(o),t.documentElement),t;let r=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let c of r)t.body.appendChild(t.adoptNode(c));return t}function ps(e,n,t={}){let o=t||{};if(!o.head?.block)return el(e,n,o);try{return el(e,n,o)}catch(r){return Promise.reject(r)}}function el(e,n,t){let o=t.policy||"sync",r=o==="raw"?void 0:(s,a)=>ma(s)||(o==="history"?!(a&&s.matches(pa))&&s.matches(ha):s.matches(da)),c=t.callbacks||{},l={ignore:r,hooks:c,protectFocusedValue:t.ignoreActiveValue===!0?"subtree":!1,restoreFocus:t.restoreFocus!==!1,formState:t.formStateSync||"attribute",scripts:{execute:t.scripts?.handle!==!1,merge:t.scripts?.merge!==!1,mergeTags:t.scripts?.mergeTags||[]},head:{awaitLoads:!!t.head?.block,preserve:t.head?.shouldPreserve||(()=>!1)}};if(typeof t.key=="function"&&(l.identity={base:t.key,local:t.key,remote:t.key}),e&&e.nodeType===9)return Ko(Object.assign({},l,{live:e,base:t.scripts?.mergeBase||null,remote:Zi(n,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let s=Object.assign({},l,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Zi(n,e.ownerDocument)});return Ko(s)}t.morphStyle==="innerHTML"&&(l.children=!0);let i=ga(e,t.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return i!==void 0&&(l.base=i),ms(e,n,l)}var ya=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),Nn=()=>{};function qo(e,n=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!ya.has(l))throw new TypeError(`unknown option "${l}"`);let t=Object.assign({beforeNodeAdded:Nn,afterNodeAdded:Nn,beforeNodeRemoved:Nn,afterNodeRemoved:Nn,beforeNodeMorphed:Nn,afterNodeMorphed:Nn,beforeAttributeUpdated:Nn},e.hooks||{}),o=e.conflicts||"remote";if(!["remote","local","both"].includes(o))throw new TypeError("conflicts must be remote, local or both");let r=e.formState||"attribute";if(!["attribute","property"].includes(r))throw new TypeError("formState must be attribute or property");let c=e.protectFocusedValue;if(c!==void 0&&typeof c!="boolean"&&c!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");return{ignored:Wr(e.ignore,n),remoteWins:Wr(e.remoteWins,n),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:o,protectFocusedValue:c===void 0?!0:c,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:r,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0}}function Mo(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return bn}function Eo(e,n){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=Vr(n,e.map),o=typeof e.then=="function"?e.then:bn;if(typeof e.first=="function"){let r=e.first;return c=>r(c)||t.get(c)||o(c)}return r=>t.get(r)||o(r)}return bn}function wa(e,n,t,o={}){let r=g=>g&&g.nodeType===9?g.documentElement:g,c=r(n),l=r(t),i=r(e)||c,s=Object.assign({},o);delete s.live,delete s.base,delete s.remote;let a=qo(s,[i,c,l].filter(Boolean)),h=o.identity||{},f=Xn(),u=Nr(i,c,l,{identity:{base:Eo(h.base,i),local:Eo(h.local,c),remote:Eo(h.remote,l)},authored:{base:Mo(h.base),local:Mo(h.local),remote:Mo(h.remote)},skipUnchanged:a.hooks.beforeNodeMorphed===Nn&&a.hooks.afterNodeMorphed===Nn,ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:c.ownerDocument&&c.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===n,childrenOnly:a.children,stats:f});return delete u.recoveryLinks,u}function gs({liveRoot:e,baseRoot:n,localRoot:t,remoteRoot:o,toLive:r,options:c,identity:l,childrenOnly:i,isDocument:s}){let a=qo(c,[e,n,t,o].filter(Boolean));if(a.ignored(e))return{report:bs(),loads:[]};let h=e.ownerDocument,f=a.scripts.execute?Si(e,a.ignored,h.baseURI):null,u=Xn(),g=a.hooks.beforeNodeMorphed===Nn&&a.hooks.afterNodeMorphed===Nn,b={identity:{base:Eo(l.base,n||t),local:Eo(l.local,t),remote:Eo(l.remote,o)},authored:{base:Mo(l.base),local:Mo(l.local),remote:Mo(l.remote)},ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:h.baseURI,localIsBase:!n,childrenOnly:i,skipUnchanged:g},A=a.fastPath&&s&&!i&&g&&n===t,p=null,m=null;if(A){let C=Qi({baseRoot:n,remoteRoot:o,liveRoot:e,toLive:r,o:a,identity:b.identity,baseURI:h.baseURI});b.comparisons=C.comparisons||C.scope,C.bail?m=C.bail:(p=Nr(n,t,o,Object.assign({},b,{stats:u,scope:C.scope})),p||(m="chain-unpaired",u=Xn()))}p||(p=Nr(n||t,t,o,Object.assign({},b,{stats:u}))),A&&(u.fastPathAttempted=1,u.fastPathTaken=m?0:1,u.fastPathFallback=m),p.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(C=>a.hooks[C]!==Nn)&&Pi(p.conflicts,p.recoveryLinks,r),a.beforeApply&&a.beforeApply(p.doc);let y=globalThis.__hyperMorphProfile,R=y?performance.now():0,S=Yi(e,p.root,p,{toLive:r,localRoot:t,ignored:a.ignored,ignoreAttribute:a.ignoreAttribute,formState:a.formState,protectFocusedValue:a.protectFocusedValue,restoreFocus:a.restoreFocus,preserve:a.head.preserve,hooks:a.hooks,childrenOnly:i,keepLiveOnly:a.keepLiveOnly});y&&(y.apply=(y.apply||0)+(performance.now()-R));let O=[];if(a.head.awaitLoads)for(let C of S.applied){if(C.kind!=="insert"||C.node.nodeType!==1)continue;let T=C.node;T.tagName==="LINK"&&/\bstylesheet\b/i.test(T.getAttribute("rel")||"")&&T.getAttribute("href")&&T.closest("head")&&O.push(new Promise(z=>{T.addEventListener("load",()=>z()),T.addEventListener("error",()=>z())}))}let M=null,E=null;if(f){let C=Ni(e,f,{ignored:a.ignored,skip:S.mergedScriptsLive,baseURI:h.baseURI,beforeNodeAdded:a.hooks.beforeNodeAdded,afterNodeAdded:a.hooks.afterNodeAdded,trackRecovery:!!p.recoveryLinks});O.push(...C.loads),M=C.swapped,E=C.vetoed}let N=C=>M&&M.get(C)||C,L=C=>{if(S.keptRuns.has(C))return S.runOf.get(C);let T=S.liveOf.get(C)||S.heldBy.get(C)||S.insertedLive.get(C);return T?N(T):null},j=C=>{let T=C&&S.liveOf.get(C);return T?N(T):null},F=C=>{let T=C&&L(C);return Array.isArray(T)?T[0]:T};if(p.recoveryLinks){let C=(T,x,z)=>(x.namespaceURI?T.getAttributeNS(x.namespaceURI,x.localName):T.getAttribute(x.qualifiedName))===z;Bi(p.conflicts,p.recoveryLinks,{lookup:L,vetoed:S.vetoed,vetoedAttrs:S.vetoedAttrs,removedVetoes:S.removedVetoes,vetoedLive:E,liveAttr:C,ignored:a.ignored,liveRoot:e})}return{report:{applied:S.applied,decisions:p.decisions.map(C=>Object.assign({},C,{node:C.node?j(C.node):null,el:C.el?j(C.el):null,applied:!!(C.node?j(C.node):C.el&&j(C.el))})),conflicts:p.conflicts.map(C=>Object.assign({},C,{node:C.node?C.kind==="text"&&C.recovery.subject.nodeType===8?F(C.node):j(C.node):C.node,el:C.el?C.kind==="structure"?F(C.el):j(C.el):C.el})),localDiverged:p.localDiverged,identities:S.identities,moved:S.moved,replaced:S.replaced,stats:u},loads:O}}var tl=new WeakMap;function bs(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Xn()}}function Ko(e){let n=e||{},t=n.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let o=tl.get(t);o||(o=Ur(t),tl.set(t,o));let r=o("remote",n.remote),c=typeof n.base=="string"&&n.base===""?null:n.base,l=c?o("base",c):null,i=n.local?n.local.root:t.documentElement,s=n.local?n.local.toLive:f=>f;Zs(t,r);let{report:a,loads:h}=gs({liveRoot:t.documentElement,baseRoot:l?l.documentElement:null,localRoot:i,remoteRoot:r.documentElement,toLive:s,options:n,identity:n.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(h).then(()=>a)}function xa(e,n,t={}){return Ko(Object.assign({},t,{live:e,base:null,remote:n}))}function nl(e,n){if(e==null)return{root:n.createElement("template"),first:null};if(typeof e=="string"){let o=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(o){let c=pr(e,n),l=o[1].toLowerCase()==="html"?c.documentElement:c.body;return{root:l,first:l}}let r=n.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let o=n.createElement("template"),r=e.isConnected;return o.content.appendChild(r?n.importNode(e,!0):e),{root:o,first:e}}if(e.nodeType===11){let o=n.createElement("template");return o.content.appendChild(e),{root:o,first:o.content.firstElementChild}}let t=n.createElement("template");for(let o of Array.from(e))t.content.appendChild(o.parentNode?n.importNode(o,!0):o);return{root:t,first:t.content.firstElementChild}}function ms(e,n,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let o=e.ownerDocument,{base:r,...c}=t,l=!!c.children;if(qo(c,[e]).ignored(e))return Promise.resolve(bs());let i=nl(n,o),s=r!=null?nl(r,o):null,a,h=null;if(l)a=i.root,h=s?s.root:null;else{if(a=i.first,h=s?s.first:null,!a){let g=qo(c);return g.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),g.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Xn()})}if(a.tagName!==e.tagName){let g=qo(c,[e,a]);if(g.hooks.beforeNodeMorphed(e,a)===!1)return Promise.resolve(bs());let b=gs({liveRoot:e,baseRoot:h&&h.tagName===e.tagName?h:null,localRoot:e,remoteRoot:a,toLive:p=>p,options:c,identity:c.identity||{},childrenOnly:!0,isDocument:!1}),A=hn(a)?Vo(a,o):o.importNode(a,!1);if(!hn(A))for(;e.firstChild;)A.appendChild(e.firstChild);return g.hooks.beforeNodeAdded(A)===!1?(Sr(b.report.conflicts,e,e),Promise.resolve(b.report)):g.hooks.beforeNodeRemoved(e)===!1?(Sr(b.report.conflicts,e,e),Promise.resolve(b.report)):(e.replaceWith(A),Sr(b.report.conflicts,e,A),g.hooks.afterNodeRemoved(e),g.hooks.afterNodeAdded(A),g.hooks.afterNodeMorphed(e,a),b.report.replaced.push(A),b.report.applied.push({kind:"insert",node:A,parent:A.parentNode},{kind:"remove",node:e,parent:A.parentNode}),Promise.all(b.loads).then(()=>b.report))}}let{report:f,loads:u}=gs({liveRoot:e,baseRoot:h,localRoot:e,remoteRoot:a,toLive:g=>g,options:c,identity:c.identity||{},childrenOnly:l,isDocument:!1});return Promise.all(u).then(()=>f)}var ol={mergeDocument:Ko,morphDocument:xa,morphElement:ms,merge3:wa,morph:ps};function ys(e,n,{onWidgetRemoved:t}={}){ol.morph(e,n,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=dr.get(o);r?.destroy&&r.destroy(),t?.(o)}}})}var Ta="hha:upgrade-check:";function Wn(e,n){let t=e.querySelector(`meta[name="${n}"]`),o=t?t.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function ws(e){if(typeof e!="string")return null;let n=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(n)?n.split(".").map(Number):null}function rl(e,n){let t=ws(e),o=ws(n);if(!t||!o)return!1;let r=Math.max(t.length,o.length);for(let c=0;c<r;c++){let l=t[c]||0,i=o[c]||0;if(l!==i)return l>i}return!1}function Aa(e){try{let n=globalThis.localStorage.getItem(e);return n?JSON.parse(n):null}catch{return null}}function Sa(e,n){try{globalThis.localStorage.setItem(e,JSON.stringify(n))}catch{}}async function xs({force:e=!1,doc:n,loc:t,fetchFn:o,now:r,ttlMs:c=864e5}={}){if(n=n||(typeof document<"u"?document:null),t=t||(typeof location<"u"?location:null),o=o||(u=>fetch(u)),r=r??Date.now(),!n)return null;let l=Wn(n,"hyper-source");if(!l)return null;let i=Wn(n,"hyper-version"),s;try{s=new URL(l,t?t.href:void 0)}catch{return null}if(t&&s.origin===t.origin&&s.pathname===t.pathname)return null;let a=`${Ta}${s.href}:${i||"none"}`,h,f=e?null:Aa(a);if(f&&typeof f.checkedAt=="number"&&r-f.checkedAt<c)h=f.sourceVersion;else{try{let u=await o(s.href);if(!u.ok)throw new Error(`HTTP ${u.status}`);let g=await u.text(),b=new DOMParser().parseFromString(g,"text/html");h=Wn(b,"hyper-version")}catch{h=null}Sa(a,{checkedAt:r,sourceVersion:h})}return h?{available:rl(h,i||"0.0.0"),currentVersion:i,sourceVersion:h,sourceUrl:s.href}:null}var vr=["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"],ks=new Set(vr),sl=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),zo=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Vn={};Lr(Vn,{EmptyListInsert:()=>Yo,MAX_RULE_DEPTH:()=>Co,MaxRuleDepthExceeded:()=>uo,NoRulesTag:()=>Ts,RuleTargetReadOnly:()=>Xo,RulesParseError:()=>Io,ShapeMismatch:()=>Go,UnknownRulesVersion:()=>fo,WriteRefused:()=>Jo,WriteRejected:()=>As});var Io=class extends Error{constructor(n,t){super(n),this.name="RulesParseError",this.cause=t}},fo=class extends Error{constructor(n){super(`unknown rules version: ${n}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=n}},Co=20,uo=class extends Error{constructor(n){super(`rule depth exceeded ${Co} at path: ${n.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=n}},Go=class extends Error{constructor(n){super(`shape mismatch: ${n.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=n}},Yo=class extends Error{constructor(n){super(`cannot add items to empty list at "${n.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=n}},Xo=class extends Error{constructor(n){super(`cannot write to read-only DOM property "${n}"`),this.name="RuleTargetReadOnly",this.target=n}},Jo=class extends Error{constructor(n){super(`write refused: ${n.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=n}},Ts=class extends Error{constructor(n){super(`no <script data-rules-name~="${n}"> rules tag in this document`),this.name="NoRulesTag",this.token=n}},As=class extends Error{constructor(n,t){super(`write rejected: ${n.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=n,this.unmatched=t}};function _n(e,n,t,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.");return Ss(e,n,t,{depth:0,path:[]},o)}function Ss(e,n,t,o,r){if(o.depth>Co)throw new uo(o.path);if(typeof t=="string")return Na(e,n,t,o,r);if(Array.isArray(t)){let[c,l]=t,i=e.find(n,c,r);return ll(r,o,i),i.map((s,a)=>Ss(e,s,l,{depth:o.depth+1,path:[...o.path,a]},r))}if(typeof t=="object"&&t!==null){let c={};for(let[l,i]of Object.entries(t))c[l]=Ss(e,n,i,{depth:o.depth+1,path:[...o.path,l]},r);return c}return null}function Na(e,n,t,o,r){if(t.endsWith("[]")){let i=t.slice(0,-2),s=e.find(n,i,r);return ll(r,o,s),s.map(a=>e.text(a))}if(t.startsWith("@"))return il(e,n,t.slice(1));let c=On(t);if(c!==-1){let i=t.slice(0,c),s=t.slice(c+1),a=i?e.find(n,i,r):[n];return a.length===0?null:il(e,a[0],s)}if(t===".")return e.text(n);let l=e.find(n,t,r);return l.length===0?null:e.text(l[0])}function ll(e,n,t){if(typeof e.onRowsRead=="function")try{e.onRowsRead(n.path.slice(),t)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${n.path.join(".")||"(root)"}"`,o)}}function il(e,n,t){if(ks.has(t)){let r=e.prop(n,t);return r==null?null:String(r)}let o=e.attr(n,t);return o||null}var cl=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"]})}),va=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),al=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function Ns(e,n){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(n)||e.hasAttribute?.(n))}function Oa(e,n){if(Ns(e,n))return!0;for(let[t,o]of Object.entries(va))if(o.includes(n)&&Ns(e,t))return!0;return!1}function Qo(e){let n=cl[e];if(!n)throw new Error(`Unknown region capability: ${e}`);return[...n.tokens,...n.bundles].flatMap(t=>[`[clay~="${t}"]`,`[${t}]`]).join(", ")}function Ma(e,n){let t=e&&e.nodeType===1?e:e?.parentElement;for(;t&&t.nodeType===1;){let o=cl[n];if(!o)throw new Error(`Unknown region capability: ${n}`);if(o.tokens.some(r=>Oa(t,r))||o.bundles.some(r=>Ns(t,r)))return t;t=t.parentElement}return null}function fl(e,n){return!!Ma(e,n)}var Ea=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function ul(e,n){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let t=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in n&&e.tagName!=="OPTION"&&t!=="checkbox"&&t!=="radio"&&t!=="file"&&(n.value=e.value),e.tagName==="INPUT"&&(t==="checkbox"||t==="radio")&&(n.checked=e.checked),e.tagName==="OPTION"&&(n.selected=e.selected),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)n.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in n&&(n.indeterminate=e.indeterminate)}function dl(e,n,t,o){if(o)return!!e.closest?.(n);let r=e;for(;r?.nodeType===1;){if(r.matches(n))return!0;if(r===t)break;r=r.parentElement}return!1}function hl(e,n,t,o,r,c,l,i){if(e.nodeType===1&&((l?fl(e,t):dl(e,o,c,!1))||r&&(l&&e!==c?e.matches(r):dl(e,r,c,l))))return null;let s=n.importNode(e,!1);i.cloneToLive.set(s,e),i.liveToClone.set(e,s);let a=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,h=s.nodeType===1&&s.tagName==="TEMPLATE"?s.content:s;a!==e&&(i.cloneToLive.set(h,a),i.liveToClone.set(a,h));for(let f of a.childNodes||[]){let u=hl(f,n,t,o,r,c,l,i);u&&(h.appendChild(u),f.nodeType===1&&ul(f,u))}return e.nodeType===1&&ul(e,s),s}function Zo(e,{capability:n="data",exclude:t=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let c=r.implementation.createHTMLDocument(""),l=new WeakMap,i=new WeakMap,s=e.nodeType===9?e.documentElement:e;t&&c.documentElement.matches(t);let a=Qo(n),h=hl(s,c,n,a,t,s,o,{cloneToLive:l,liveToClone:i});e.nodeType===9&&h&&(c.replaceChild(h,c.documentElement),i.set(e,c),l.set(c,e));let f=u=>{if(Ea.test(u))throw new Error(`Filtered content queries do not support stateful selector: ${u}`)};return{root:h,document:c,capability:n,selector:Qo(n),cloneToLive:l,liveToClone:i,original(u){return l.get(u)||null},cloneOf(u){return i.get(u)||null},query(u,g=h){return f(u),Array.from(g.querySelectorAll(u),b=>l.get(b)||b)},text(u=h){return(u===h?h:i.get(u))?.textContent||""},html(u=h){return(u===h?h:i.get(u))?.innerHTML??""},clone(u=h){let g=u===h?h:i.get(u);return g?c.importNode(g,!0):null}}}function pl(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Ia(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var on={semanticExclude:!0,find(e,n,t={}){let o=Ia(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(n));t.includeRulesTag||(r=r.filter(i=>!pl(i)));let c=[];t.skip&&c.push(t.skip);let l=t.templateAttr===null?null:t.templateAttr||"cms-template";if(l&&c.push("["+l+"]"),c.length){let i=c.join(", ");r=r.filter(s=>!s.closest||!s.closest(i))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,n){if(n===void 0)return(e.textContent||"").trim();e.textContent=n},attr(e,n,t){if(t===void 0)return e.hasAttribute&&e.hasAttribute(n)?e.getAttribute(n):null;e.setAttribute(n,t)},removeAttr(e,n){e&&e.removeAttribute&&e.removeAttribute(n)},prop(e,n,t){if(t===void 0){let o=e?e[n]:void 0;return o!==void 0?o:null}e[n]=t},clone(e){return e.cloneNode(!0)},insertAt(e,n,t){let o=e.children[t]||null;e.insertBefore(n,o)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,n){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=n;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let n=0;return e.id&&(e.removeAttribute("id"),n++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),n++}),n},sameNode(e,n){return e===n}};function eo(e,n={}){if(n.exclude===null)return on;let t=[Qo("data"),n.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!n._write&&!r?.matches?.(t)&&!r?.querySelector?.(t)&&!o?.querySelector?.(t))return on;let c=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,i=null,s=()=>i||(i=Zo(c,{capability:"data",exclude:n.exclude||null})),a=b=>{let A=s();return b===e?A.cloneOf(e):A.cloneOf(b)||b},h=b=>i?.original(b)||b,f=(b,A)=>{s().liveToClone.set(b,A),s().cloneToLive.set(A,b);let p=b.childNodes||[],m=A.childNodes||[];for(let y=0;y<Math.min(p.length,m.length);y++)f(p[y],m[y])},u=(b,A,p,m)=>{let y=Array.from(b.childNodes).filter(E=>i.cloneOf(E)),S=y[0];for(;S&&y.includes(S);)S=S.nextSibling;for(let E of y)E.remove();if(p==="innerHTML"){let E=l.createElement("template");E.innerHTML=m;for(let N of Array.from(E.content.childNodes))b.insertBefore(N,S||null)}else b.insertBefore(l.createTextNode(m),S||null);let O=Zo(b,{capability:"data",exclude:n.exclude||null});A.replaceChildren(...Array.from(O.root?.childNodes||[]));let M=E=>{let N=O.original(E);N&&(i.liveToClone.set(N,E),i.cloneToLive.set(E,N));for(let L of Array.from(E.childNodes||[]))M(L)};for(let E of Array.from(A.childNodes))M(E)},g={...on,find(b,A,p={}){let m=a(b);if(!m?.querySelectorAll)return[];let y=s().query(A,m);p.includeRulesTag||(y=y.filter(O=>!pl(O)));let R=[];p.skip&&R.push(p.skip);let S=p.templateAttr===null?null:p.templateAttr||"cms-template";if(S&&R.push(`[${S}]`),R.length){let O=R.join(", ");y=y.filter(M=>!M.closest?.(O))}return y},parent(b){let A=a(b)?.parentElement;return A?h(A):null},children(b){return Array.from(a(b)?.children||[],h)},text(b,A){if(A===void 0){let y=h(b);return!y?.matches?.(t)&&!y?.querySelector?.(t)?on.text(y):(a(b)?.textContent||"").trim()}let p=h(b);if(!p?.matches?.(t)&&!p?.querySelector?.(t)&&!i){on.text(p,A);return}let m=s().cloneOf(p);m?u(p,m,"textContent",A):on.text(p,A)},attr(b,A,p){let m=h(b);if(p===void 0)return on.attr(m,A);on.attr(m,A,p);let y=i?.cloneOf(m);y&&(on.attr(y,A,p),Zo(m,{capability:"data",exclude:n.exclude||null}).root===null&&(y.remove(),i.liveToClone.delete(m),i.cloneToLive.delete(y)))},removeAttr(b,A){let p=h(b);on.removeAttr(p,A);let m=i?.cloneOf(p);m&&on.removeAttr(m,A)},prop(b,A,p){let m=h(b);if(p===void 0)return A==="innerHTML"||A==="outerHTML"||A==="textContent"||A==="innerText"?on.prop(a(m),A):on.prop(m,A);let y=A==="innerHTML"||A==="textContent"||A==="innerText",R=y?s().cloneOf(m):i?.cloneOf(m);R&&y?u(m,R,A,p):(on.prop(m,A,p),R&&on.prop(R,A,p))},clone(b){let A=a(b);return A===b?on.clone(b):l.importNode(A,!0)},insertAt(b,A,p){let m=h(b),R=g.children(m)[p]||(()=>{for(let M=m.children.length-1;M>=0;M--){let E=m.children[M];if(s().cloneOf(E))return E.nextElementSibling}return m.firstElementChild})(),S=h(A);m.insertBefore(S,R||null);let O=s().cloneOf(m);if(O){let M=s().cloneOf(S);M||(M=l.importNode(S,!0),f(S,M));let E=Array.from(O.children);O.insertBefore(M,E[p]||null)}},remove(b){let A=h(b),p=s().cloneOf(A);on.remove(A),p&&on.remove(p)},replaceWith(b,A){let p=h(b),m=s().cloneOf(p),y=on.replaceWith(p,A);if(m){let R=Zo(y,{capability:"data",exclude:n.exclude||null});if(!R.root)m.remove();else{m.replaceWith(R.root);let S=O=>{let M=R.original(O);M&&(i.liveToClone.set(M,O),i.cloneToLive.set(O,M));for(let E of Array.from(O.childNodes||[]))S(E)};S(R.root)}}return y}};return g}var Cn=on;function vs(e){try{return JSON.parse(e)}catch(n){throw new Io(`Invalid strict JSON: ${n.message}`,n)}}function ho(e){try{return JSON.parse(e)}catch{}let n={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(r){let c=[],l=0;for(;l<r.length;){let i=r[l];if(/\s/.test(i)){l++;continue}if("{}".includes(i)){c.push({type:i,value:i}),l++;continue}if(i==="["){let f=!1,u=l+1;for(;u<r.length&&/\s/.test(r[u]);)u++;if(u<r.length&&/[a-zA-Z_]/.test(r[u])&&(f=!0),!f){c.push({type:i,value:i}),l++;continue}}if(i==="]"){c.push({type:i,value:i}),l++;continue}if(i===":"){c.push({type:n.COLON,value:i}),l++;continue}if(i===","){c.push({type:n.COMMA,value:i}),l++;continue}if(i==='"'||i==="'"){let f=i,u=l+1;for(;u<r.length&&r[u]!==f;)r[u]==="\\"&&u++,u++;c.push({type:n.STRING,value:r.substring(l+1,u),quoted:!0,sourceQuote:f}),l=u+1;continue}let s=l,a;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let f=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],u=!1;for(let g of f){let b=g.substring(1);if(r.substring(s+1,s+1+b.length)===b){u=!0,s+=b.length;break}}if(!u)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let f=r[s];for(s++;s<r.length&&r[s]!==f;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;a=r.substring(l,s);let h=n.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(a)?h=n.NUMBER:a==="true"||a==="false"||a==="null"?h=n.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(a)&&(h=n.SELECTOR),c.push({type:h,value:a,quoted:!1}),l=s}return c}function o(r){let c="";for(let l=0;l<r.length;l++){let i=r[l];if("{}".includes(i.type)||"[]".includes(i.type)){c+=i.value;continue}if(i.type===n.COLON){c+=i.value;continue}if(i.type===n.COMMA){let s=r[l+1];if(s&&(s.type==="}"||s.type==="]"))continue;c+=i.value;continue}if(i.type===n.STRING&&i.quoted){let s=i.value;i.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(a,h)=>h.length%2===0?h+'\\"':a)),c+=`"${s}"`;continue}if(i.type===n.NUMBER||i.type===n.BOOLEAN){c+=i.value;continue}if(i.type===n.SELECTOR||i.type===n.IDENTIFIER){c+=`"${i.value}"`;continue}c+=`"${i.value}"`}return c}try{let r=t(e),c=o(r);return JSON.parse(c)}catch(r){throw new Io("Invalid extraction rules syntax: "+r.message,r)}}var Os="1",ml=/^[a-zA-Z0-9_-]+$/;function Ro(e,n,t){let o;if(t===void 0)o="script[data-rules-name]";else{if(typeof t!="string"||!ml.test(t))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(t)} (must match ${ml})`);o=`script[data-rules-name~="${t}"]`}let r=e.find(n,o,{includeRulesTag:!0});if(r.length===0)return null;t!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${t}"; using the first.`);let c=r[0],l=e.attr(c,"data-rules-version");if(l!==Os)throw new fo(l);return{rules:ho(e.text(c)),tagNode:c}}var Ca="script[data-rules-name]";function gl(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function er(e,n){let t=e.find(n,Ca,{includeRulesTag:!0}),o=new Set,r=[];for(let c of t){let l=gl(e.attr(c,"data-rules-name"));if(!l)continue;if(o.has(l)){console.warn(`hyper-html-api: duplicate rules tag name "${l}"; using the first.`);continue}let i=e.attr(c,"data-rules-version");if(i!==Os)throw new fo(i);o.add(l),r.push({name:l,rules:ho(e.text(c))})}return r}function Or(e,n){let t={};for(let{name:o,rules:r}of er(e,n))t[o]=_n(e,n,r);return t}function Ms(e){let n=e||document,t=n.nodeType===9?n:n.ownerDocument||n;return{dataByName:Or(Cn,n),version:Wn(t,"hyper-version")}}var Lo=class extends Error{constructor(n,t){super(`could not fetch upgrade source: ${n}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=n,this.cause=t}},tr=class extends Error{constructor(n){super(`upgrade source has no rules tags; refusing to drop all existing data: ${n}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=n}},to=class extends Error{constructor(n,t){super(n),this.name="UpgradeTransformInvalid",this.cause=t}},nr=class extends Error{constructor(n){super(`found ${n} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=n}};var bl="text/hyper-upgrade";function Es(e,n){let t=e.find(n,`script[type="${bl}"]`);if(t.length===0)return null;if(t.length>1)throw new nr(t.length);return e.text(t[0])||null}var Ra=new Function("url","return import(url)");async function Is(e){let n=new Blob([e],{type:"text/javascript"}),t=URL.createObjectURL(n),o;try{o=await Ra(t)}catch(r){throw new to(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(t)}if(typeof o.default!="function")throw new to("transform must `export default` a function");return o.default}function xl(e,n,t,o){let r=e.length,c=n.length,l=new Array(r).fill(-1);if(o){let p=new Set;for(let m=0;m<r;m++){let y=o[m];!(y>=0&&y<c)||p.has(y)||(l[m]=y,p.add(y))}}if(r===0||c===0)return l;let i=e.map(p=>yl(p,t)),s=n.map(p=>yl(p,t)),a=new Array(c).fill(!1);for(let p of l)p>=0&&(a[p]=!0);let h=new Map;s.forEach((p,m)=>{a[m]||h.set(p,h.has(p)?-1:m)});let f=new Map;i.forEach((p,m)=>{l[m]>=0||f.set(p,(f.get(p)||0)+1)}),i.forEach((p,m)=>{if(l[m]>=0||f.get(p)!==1)return;let y=h.get(p);y===void 0||y===-1||a[y]||(l[m]=y,a[y]=!0)});let u=[];for(let p=0;p<r;p++)l[p]<0&&u.push(p);let g=[];for(let p=0;p<c;p++)a[p]||g.push(p);if(u.length===0||g.length===0)return l;let b=r*c+1,A=(p,m)=>La(e[p],n[m],t)*b+Math.abs(p-m);for(let[p,m]of Pa(u,g,A))l[p]=m;return l}var kl=e=>typeof e=="object"&&e!==null;function yl(e,n){if(!kl(n))return e==null?" null":String(e);let t=Object.keys(n);return JSON.stringify(t.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function La(e,n,t){if(!kl(t))return e===n?0:1;let o=Object.keys(t);if(o.length===0)return 0;let r=0;for(let c of o){let l=JSON.stringify(e?.[c]),i=JSON.stringify(n?.[c]);l!==i&&r++}return r}function Pa(e,n,t){return e.length<=n.length?wl(e,n,t,!1):wl(n,e,(o,r)=>t(r,o),!0)}function wl(e,n,t,o){let r=e.length,c=n.length,l=[];for(let f=0;f<=r;f++)l.push(new Float64Array(c+1).fill(1/0));let i=[];for(let f=0;f<=r;f++)i.push(new Uint8Array(c+1));for(let f=0;f<=c;f++)l[r][f]=0;for(let f=r-1;f>=0;f--)for(let u=c-1;u>=0;u--){let g=t(e[f],n[u])+l[f+1][u+1],b=l[f][u+1];g<=b?(l[f][u]=g,i[f][u]=1):l[f][u]=b}let s=[],a=0,h=0;for(;a<r&&h<c;)i[a][h]&&(s.push(o?[n[h],e[a]]:[e[a],n[h]]),a++),h++;return s}function Rs(e,n,t,o,r,c,l,i={}){let s=e.find(n,t,i);if(r.length===0){s.forEach(O=>e.remove(O)),Cs(i,"onRowsApplied",c.path,[]);return}let a=r.length>s.length,h=s[0]||null;if(a&&!h&&(h=Ua(e,n,t,i),!h))throw new Yo(c.path);let f=s.map(O=>Ba(e,O,o,i)),u=null;if(a&&h){u=e.clone(h),i.templateAttr&&e.removeAttr(u,i.templateAttr);let O=e.stripIds(u);O>0&&console.warn(`[hyper-html-api] stripped ${O} id attribute(s) from cloned template at "${c.path.join(".")||"(root)"}"`)}let g=xl(r,f,o,ja(e,s,r,c,i)),b=s[0]||h,A=e.parent(b),p=s.length>0?Tl(e,A,b):0,m=Ha(e,s),y=new Set,R=[],S=r.map((O,M)=>{let E=g[M];if(E>=0)return y.add(E),R.push(!1),s[E];R.push(!0);let N=e.clone(u);return e.stripIds(N),N});s.forEach((O,M)=>{y.has(M)||e.remove(O)}),m?S.forEach((O,M)=>{let E=p+M;e.children(A).findIndex(j=>e.sameNode(j,O))!==E&&e.insertAt(A,O,E)}):Wa(e,S,R,A,p),Da(e,S,o,r,c,l,i),Cs(i,"onRowsApplied",c.path,S)}function Cs(e,n,t,o){if(typeof e[n]=="function")try{return e[n](t.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${n} threw at "${t.join(".")||"(root)"}"`,r);return}}function ja(e,n,t,o,r){let c=Cs(r,"identifyRows",o.path,t);if(!Array.isArray(c))return null;let l=new Array(t.length).fill(-1),i=new Set;for(let s=0;s<t.length;s++)if(c[s]){for(let a=0;a<n.length;a++)if(!(i.has(a)||!e.sameNode(n[a],c[s]))){l[s]=a,i.add(a);break}}return l}function Da(e,n,t,o,r,c,l){n.forEach((i,s)=>{if(t===null){let a=o[s],h=a==null?"":String(a);e.text(i)!==h&&e.text(i,h)}else{let a=c(e,i,t,o[s],{depth:r.depth+1,path:[...r.path,s]},l);a&&a!==i&&(n[s]=a)}})}function Ba(e,n,t,o){return t===null?e.text(n):_n(e,n,t,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Tl(e,n,t){let o=e.children(n);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],t))return r;return-1}function Ua(e,n,t,o){if(!o.templateAttr)return null;let r=n;for(;r;){let c=e.find(r,t,{includeRulesTag:!1,templateAttr:null});for(let l of c)if(e.attr(l,o.templateAttr)!=null)return l;r=e.parent(r)}return null}function Ha(e,n){if(n.length<=1)return!0;let t=e.parent(n[0]);if(!t)return!1;let o=e.children(t),r=[];for(let c of n){let l=o.findIndex(i=>e.sameNode(i,c));if(l===-1)return!1;r.push(l)}return r.sort((c,l)=>c-l),r[r.length-1]-r[0]===r.length-1}function Wa(e,n,t,o,r){let c=null,l=r;for(let i=0;i<n.length;i++){if(!t[i]){c=n[i];continue}let s=c?e.parent(c):o;if(!s)continue;let a=c?Tl(e,s,c)+1:l++;e.insertAt(s,n[i],a),c=n[i]}}var Al=new Set(["checked","selected","disabled","readOnly","paused"]);function qn(e,n,t,o,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.");let c=[];if(Ls(t,o,[],c),c.length)throw new Go(c);Mr(e,n,t,o,{depth:0,path:[]},r)}function Mr(e,n,t,o,r,c={}){if(r.depth>Co)throw new uo(r.path);if(o===void 0)return n;if(typeof t=="string")return Va(e,n,t,o,r,c);if(Array.isArray(t)){let[l,i]=t;return Rs(e,n,l,i,o,r,Mr,c),n}if(typeof t=="object"&&t!==null){for(let[l,i]of Object.entries(t)){let s=Mr(e,n,i,o==null?o:o[l],{depth:r.depth+1,path:[...r.path,l]},c);s&&s!==n&&(n=s)}return n}return n}function Va(e,n,t,o,r,c){if(t.endsWith("[]")){let s=t.slice(0,-2);return Rs(e,n,s,null,o,r,Mr,c),n}if(t.startsWith("@"))return Nl(e,n,t.slice(1),o);let l=On(t);if(l!==-1){let s=t.slice(0,l),a=t.slice(l+1),h=s?e.find(n,s,c):[n];return h.length===0||Nl(e,h[0],a,o),n}if(t===".")return Sl(e,n,o),n;let i=e.find(n,t,c);return i.length===0||Sl(e,i[0],o),n}function Sl(e,n,t){let o=t==null?"":String(t);e.text(n)!==o&&e.text(n,o)}function Nl(e,n,t,o){if(zo.has(t)){let c=e.prop(n,t);if(c===o||c!=null&&o!=null&&String(c)===String(o))return n;throw new Xo(t)}if(t==="outerHTML"){let c=o==null?"":String(o);return e.replaceWith(n,c)}if(sl.has(t)){let c=_a(t,o);return e.prop(n,t)!==c&&e.prop(n,t,c),n}let r=o==null?"":String(o);return e.attr(n,t)!==r&&e.attr(n,t,r),n}function _a(e,n){return n==null?Al.has(e)?!1:"":Al.has(e)?n==="false"?!1:!!n:n}function Ls(e,n,t,o){if(n!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(n)?n.forEach((r,c)=>{typeof r=="object"&&r!==null&&o.push({path:rr([...t,c]),expected:"scalar",got:or(r)})}):o.push({path:rr(t),expected:"array",got:or(n)});return}n!==null&&typeof n=="object"&&o.push({path:rr(t),expected:"scalar",got:or(n)});return}if(Array.isArray(e)){if(!Array.isArray(n)){o.push({path:rr(t),expected:"array",got:or(n)});return}let r=e[1];n.forEach((c,l)=>Ls(r,c,[...t,l],o));return}if(typeof e=="object"&&e!==null){if(n===null||Array.isArray(n)||typeof n!="object"){o.push({path:rr(t),expected:"object",got:or(n)});return}for(let[r,c]of Object.entries(e))Ls(c,n[r],[...t,r],o)}}}function or(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function rr(e){return e.join(".")}function sr(e,n){let t={carriedOver:0,discarded:0,listItems:0},o=Ps(n,e,t);return js(n,e,t),{data:o,summary:t}}function Ps(e,n,t){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(n)?(t.listItems+=n.length,t.carriedOver+=n.length,n):void 0:n==null||typeof n=="object"?void 0:(t.carriedOver++,n);if(Array.isArray(e)){let[,o]=e;return Array.isArray(n)?(t.listItems+=n.length,n.map(r=>Ps(o,r,t))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,c]of Object.entries(e)){let l=Ps(c,n?.[r],t);l!==void 0&&(o[r]=l)}return o}}function js(e,n,t){if(n!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof n!="object"||Array.isArray(n))return;let o=new Set(Object.keys(e));for(let r of Object.keys(n))o.has(r)?js(e[r],n[r],t):t.discarded+=po(n[r]);return}if(Array.isArray(e)&&Array.isArray(n)){let o=e[1];n.forEach(r=>js(o,r,t));return}typeof e=="string"&&!e.endsWith("[]")&&typeof n=="object"&&n!==null&&(t.discarded+=po(n))}}function po(e){return e==null?0:Array.isArray(e)?e.reduce((n,t)=>n+po(t),0):typeof e=="object"?Object.values(e).reduce((n,t)=>n+po(t),0):1}function Ds(e,n,t){let o=er(e,n),r={carriedOver:0,discarded:0,listItems:0},c={},l=new Set;for(let{name:i,rules:s}of o){if(l.add(i),!Object.prototype.hasOwnProperty.call(t,i)){c[i]={carriedOver:0,discarded:0,listItems:0};continue}let{data:a,summary:h}=sr(t[i],s);qn(e,n,s,a),c[i]=h,r.carriedOver+=h.carriedOver,r.discarded+=h.discarded,r.listItems+=h.listItems}for(let i of Object.keys(t))l.has(i)||(r.discarded+=po(t[i]));return{totals:r,byName:c,rulesTagCount:o.length}}async function Bs({sourceUrl:e,dataByName:n,fromVersion:t,doc:o,loc:r,fetchFn:c}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),c=c||(m=>fetch(m)),!o)throw new Error("upgrade.run requires a document context");if(e=e||Wn(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let l=new URL(e,r?r.href:void 0);t=t!==void 0?t:Wn(o,"hyper-version"),n=n||Or(Cn,o);let i;try{i=await c(l.href)}catch(m){throw new Lo(l.href,m)}if(!i.ok)throw new Lo(l.href,new Error(`HTTP ${i.status}`));let s=await i.text(),a=new DOMParser().parseFromString(s,"text/html"),h=Wn(a,"hyper-version"),f=n,u=!1,g=Es(Cn,a);if(g){let y=await(await Is(g))(f,{fromVersion:t,toVersion:h});if(!y||typeof y!="object"||Array.isArray(y))throw new to("transform must return a plain object map of { rulesName: data }");f=y,u=!0}let{totals:b,byName:A,rulesTagCount:p}=Ds(Cn,a,f);if(p===0&&Object.keys(f).length>0)throw new tr(l.href);return{html:Fa(a),fromVersion:t,toVersion:h,summary:{transformApplied:u,totals:b,byName:A}}}function Fa(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
6
|
+
`+e.documentElement.outerHTML}var Us=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",...al],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]}),Ka=new Set(["textContent","innerText"]);function vl(e){let t=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return t?t[1].toLowerCase():null}var qa=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function Ol(e,n,t=Us){if(!qa.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(t.refusedAttributePrefixes.some(r=>o.startsWith(r)))return`attribute "${o}" can run script`;if(t.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(t.urlAttributes.includes(o)&&n!=null){let r=o==="srcset"?String(n).split(",").map(c=>c.trim().split(/\s+/)[0]).filter(Boolean):[String(n)];for(let c of r){let l=vl(c);if(l&&t.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${o}"`}}return null}function Hs(e,n){let t=e.prop(n,"tagName");return t?String(t).toLowerCase():""}function za(e,n){let t=Hs(e,n)||"node",o=e.attr(n,"id");return o?`<${t}#${o}>`:`<${t}>`}function Ga(e,n,t){let o=n;for(;o;){let r=Hs(e,o);if(r&&t.refusedTargets.includes(r))return r;o=e.parent(o)}return null}function Ml(e,n){return e.find(n,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Ya(e,n){return Hs(e,n)==="script"&&e.attr(n,"data-rules-name")!=null?!0:Ml(e,n)}function Er(e,n=Us){let t=[],o=(s,a)=>(t.push({target:za(e,s),reason:a}),!1),r=s=>{let a=Ga(e,s,n);return a?o(s,`inside <${a}>, which is not content`):!0},c=s=>r(s)?Ml(e,s)?o(s,"a text write here would delete the data rules tag"):!0:!1,l=(s,a,h)=>{if(!r(s))return!1;let f=Ol(a,h,n);return f?o(s,f):!0};return{...e,text(s,a){if(a===void 0)return e.text(s);c(s)&&e.text(s,a)},attr(s,a,h){if(h===void 0)return e.attr(s,a);l(s,a,h)&&e.attr(s,a,h)},prop(s,a,h){if(h===void 0)return e.prop(s,a);if(n.refusedRuleForms.includes(a))return o(s,`"@${a}" writes HTML, only text is allowed`);if(Ka.has(a)){c(s)&&e.prop(s,a,h);return}l(s,a==="className"?"class":a,h)&&e.prop(s,a,h)},remove(s){if(Ya(e,s)){o(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,a){return a===e.prop(s,"outerHTML")||o(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:t,assertClean(){if(t.length)throw new Jo(t.slice())}}}function ir(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function El(e){return e.reduce((n,t)=>typeof t=="number"?`${n}[${t}]`:n?`${n}.${t}`:t,"")}function Ws(e,n,t,o,r={}){let c=[],l=[];function i(a,h,f){if(Array.isArray(a)){let[,u]=a;if(!Array.isArray(h)||!ir(u))return;h.forEach((g,b)=>i(u,g,[...f,b]));return}if(!(!ir(a)||!ir(h)))for(let u of Object.keys(h))Object.prototype.hasOwnProperty.call(a,u)?i(a[u],h[u],[...f,u]):c.push(El([...f,u]))}function s(a,h,f,u){if(f!==void 0){if(typeof h=="string"){if(h.endsWith("[]")||h==="."||h.startsWith("@"))return;let g=On(h),b=g===-1?h:h.slice(0,g);if(!b)return;e.find(a,b,r).length===0&&l.push({path:El(u),selector:b});return}if(!Array.isArray(h)&&ir(h)&&ir(f))for(let[g,b]of Object.entries(h))s(a,b,f[g],[...u,g])}}return i(t,o,[]),s(n,t,o,[]),{unknownKeys:c,unmatched:l}}function Vs(e,n,t){if(t&&typeof t=="object")return{rules:t,tagNode:null};if(typeof t=="string"){let o=n&&n.ownerDocument?n.ownerDocument:n;return Ro(e,o,t)}return null}var lr={extract:(e,n,t={})=>_n(eo(e,t),e,n,t),apply:(e,n,t,o={})=>qn(eo(e,{...o,_write:!0}),e,n,t,o),findRulesIn:(e,n)=>Ro(Cn,e,n),findRules:(e,n)=>Vs(Cn,e,n),bind:(e,n,t={})=>{let o=Vs(Cn,e,n);if(!o){let r=typeof n=="string"?`data-rules-name~="${n}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>_n(eo(e,t),e,o.rules,t),set:r=>qn(eo(e,{...t,_write:!0}),e,o.rules,r,t)}},parseStrict:vs,parseRelaxed:ho,ruleAttrIndex:On,splitRule:bo,errors:Vn,DOM_PROPERTIES:vr},_s=e=>!!e&&typeof e.nodeType=="number";function Il(e){let n=e&&e.ownerDocument?e.ownerDocument:e,t=Ro(Cn,n,"api");if(!t)throw new Vn.NoRulesTag("api");return t.rules}function Ja(e){if(e.nodeType===9)return e;let n=e.ownerDocument?.documentElement;if(n?.contains(e))return n;let t=e;for(;t.parentNode;)t=t.parentNode;return t}function Qa(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let n=e.ownerDocument.createDocumentFragment();for(let t of e.childNodes)n.appendChild(t.cloneNode(!0));return n}function Za(e,n){let t=[];for(;n!==e;){let o=n.parentNode;t.push(Array.prototype.indexOf.call(o.childNodes,n)),n=o}return t.reverse()}function ef(e,n){return n.reduce((t,o)=>t.childNodes[o],e)}function Po(e,n){let t=e.querySelectorAll?Array.from(e.querySelectorAll(n)):[];return e.matches?.(n)&&t.unshift(e),t}function tf(e,n){let t=Po(e,"option"),o=Po(n,"option");t.forEach((s,a)=>o[a].selected=s.selected);let r=Po(e,"input"),c=Po(n,"input");r.forEach((s,a)=>{let h=s.type.toLowerCase();h!=="file"&&(c[a].value=s.value),(h==="checkbox"||h==="radio")&&(c[a].checked=s.checked)});let l=Po(e,"textarea"),i=Po(n,"textarea");l.forEach((s,a)=>i[a].value=s.value)}function Fs(e,n){if(n!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let t=e.startsWith("@")?0:On(e);if(t===-1)return;let o=e.slice(t+1);if(zo.has(o))throw new Vn.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(n))return;n.forEach(t=>Fs(e[1],t));return}if(e&&typeof e=="object"&&n&&typeof n=="object"&&!Array.isArray(n))for(let[t,o]of Object.entries(e))Fs(o,n[t])}}function nf(e,n,t){let o={templateAttr:"cms-template"},r=Ja(e),c=Za(r,e),l=Qa(r);tf(r,l);let i=ef(l,c),s=eo(l,{...o,_write:!0}),a=Ws(s,i,n,t,o);if(a.unknownKeys.length||a.unmatched.length)throw new Vn.WriteRejected(a.unknownKeys,a.unmatched);let h=Er(s);qn(h,i,n,t,o),h.assertClean(),Fs(n,t);let f=Er(eo(r,{...o,_write:!0}));qn(f,e,n,t,o),f.assertClean()}function of(e){if(!(e instanceof Error))return e;let n=e.name||"Error";try{e.code=n}catch{Object.defineProperty(e,"code",{value:n,configurable:!0,enumerable:!0})}return e instanceof Vn.WriteRefused?e.details=e.refusals:e instanceof Vn.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof Vn.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function $s(e,n){let t=_s(e)?e:document,o=_s(e)?n:e;return o===void 0?_n(eo(t),t,Il(t)):lr.bind(t,o).get()}function Ks(e,n,t){try{if(!_s(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=t===void 0?Il(e):lr.bind(e,t).rules;nf(e,o,n)}catch(o){throw of(o)}return e}var Cl={buildForm:jr,bindFormEvents:Dr,scaffold:go,morphForm:ys,path:ur},Rl={checkForUpdate:xs,run:Bs,extractAll:Ms,shapeMatch:sr};var rf={engine:lr,cms:Cl,upgrade:Rl,extractData:$s,applyData:Ks},sf=rf;return _l(lf);})();
|