@panphora/clayjs 1.11.0 → 1.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- var HyperMorph=(()=>{var os=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var ii=Object.getOwnPropertyNames;var li=Object.prototype.hasOwnProperty;var ai=(e,o)=>{for(var t in o)os(e,t,{get:o[t],enumerable:!0})},ci=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of ii(o))!li.call(e,s)&&s!==t&&os(e,s,{get:()=>o[s],enumerable:!(n=ri(o,s))||n.enumerable});return e};var fi=e=>ci(os({},"__esModule",{value:!0}),e);var Rl={};ai(Rl,{createIdentityStore:()=>Hs,createParseCache:()=>jo,default:()=>El,diff:()=>Yn,findChangedRoots:()=>Gr,importMap:()=>Do,merge3:()=>ni,merge3Text:()=>lo,mergeDocument:()=>wo,mergeJson:()=>Os,mergeScriptText:()=>Yo,morph:()=>Zo,morphDocument:()=>oi,morphElement:()=>es,parseJsonRelaxed:()=>zo,parseRulesRelaxed:()=>xr,spliceProtected:()=>Yr,tieredIdentity:()=>is});function Bo(e,o){if(typeof e=="string"){let t=o&&o.defaultView,n=t&&t.DOMParser||globalThis.DOMParser;return new n().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function jo(e){let o=new Map;return(t,n)=>{if(typeof n!="string")return Bo(n,e);let s=o.get(t);if(s&&s.text===n)return s.doc;let h=Bo(n,e);return o.set(t,{text:n,doc:h}),h}}function Vs(e,o){let t=o.doctype;if(!t)return!1;let n=e.doctype;if(n&&n.name===t.name&&n.publicId===t.publicId&&n.systemId===t.systemId)return!1;let s=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return n?e.replaceChild(s,n):e.insertBefore(s,e.documentElement),!0}var ss=()=>!1;function rs(e,o=[]){if(typeof e!="function")return ss;let t=new WeakMap,n=new Set(o);return s=>{if(!s||s.nodeType!==1)return!1;let h=t.get(s);if(h!==void 0)return h;let l=[],r=s,i=!1;for(;r&&r.nodeType===1;){let u=t.get(r);if(u!==void 0){i=u;break}if(l.push(r),e(r,n.has(r))){i=!0;break}if(n.has(r))break;r=r.parentElement}for(let u of l)t.set(u,i);return i}}var Dl=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 $n(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Hs(e){let o=new WeakMap,t=0,n=r=>o.get(r)||null,s=r=>{let i=o.get(r);return i||(i=`${e}:${++t}`,o.set(r,i)),i};return{idOf:n,ensure:s,adopt:(r,i)=>{r&&typeof i=="string"&&i&&o.set(r,i)},exportMap:(r,i)=>{let u={},w=[],c=[],p=(b,S)=>{let C=i(b);C&&(u[S]=s(C));let m=b.children;w.push(m.length),c.push(b.tagName.toLowerCase());for(let f=0;f<m.length;f++)p(m[f],S===""?String(f):`${S}.${f}`)};return p(r,""),u["~"]=w.join(","),u["^"]=c.join(","),u}}}function Do(e,o){let t=new WeakMap;if(!e||!o||typeof o!="object"||Array.isArray(o))return t;let n=o["~"],s=typeof n=="string"?n.split(",").map(Number):null,h=s&&typeof o["^"]=="string"?o["^"].split(","):null,l=c=>Number.isInteger(c)&&c>=0,r=0,i=!1,u=c=>{let p=c;for(;p>0;){let b=s[r++];if(r>s.length||!l(b))return!1;p+=b-1}return!0},w=(c,p)=>{if(i)return;if(s){let C=r++,m=s[C];if(C>=s.length||!l(m)){i=!0;return}let f=!h||h[C]===c.tagName.toLowerCase();if(!f||m!==c.children.length){let g=f&&o[p];typeof g=="string"&&g&&t.set(c,g),u(m)||(i=!0);return}}let b=o[p];typeof b=="string"&&b&&t.set(c,b);let S=c.children;for(let C=0;C<S.length;C++)w(S[C],p===""?String(C):`${p}.${C}`)};return w(e,""),t}function is(e){return o=>{for(let t of e){let n=t(o);if(typeof n=="string"&&n!=="")return n}return null}}var kn=is([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Uo(e,o,t,n=null,s=null){let h=new Map,l=new Set,r=i=>{if(t(i))return;let u=o(i);u&&(h.has(u)?l.add(u):h.set(u,i))};if(n){let i=u=>{for(let w of u.querySelectorAll(n))r(w);for(let w of u.querySelectorAll("template"))w.content&&i(w.content)};r(e),i(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let i=u=>{r(u);let w=u.tagName==="TEMPLATE"&&u.content?u.content.children:u.children;for(let c=0;c<w.length;c++)i(w[c])};i(e)}for(let i of l)h.delete(i),s&&s.add(i),ls(i);return h}function ls(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var ui=new Set(["href","src","name","type","role"]),qs=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function ro(e,o=5381){let t=o;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return t>>>0}function Ws(e){return e.replace(/\s+/g," ")}var di=0;function Ks({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,s=new WeakMap;function h(A){let E=A.attributes,N=E.length;if(N===0)return{all:"",sig:A.tagName+"|"};let M=[],R="",V=[];for(let D=0;D<N;D++){let j=E[D],y=j.name;o(A,y)||M.push(y+"="+j.value),y==="class"?R=j.value.indexOf(" ")<0?j.value:j.value.split(/\s+/).filter(Boolean).sort().join(" "):ui.has(y)&&V.push(y+"="+j.value)}return M.length>1&&M.sort(),V.length>1&&V.sort(),{all:M.join(""),sig:A.tagName+"|"+R+(V.length?"|"+V.join("|"):"")}}function l(A){return A.nodeType===1&&A.tagName==="TEMPLATE"&&A.content?A.content.childNodes:A.childNodes}function r(A){let E=n.get(A);if(E)return E;if(A.nodeType===3)E={hash:"T"+ro(A.nodeValue),hint:Ws(A.nodeValue).slice(0,64),sig:null,tok:null};else if(A.nodeType===8)E={hash:"C"+ro(A.nodeValue),hint:"",sig:null,tok:null};else if(A.nodeType===1){let N=h(A),M=ro(A.tagName+""+N.all),R="";for(let V of u(A))if(V.nodeType===1){let D=r(V);M=ro(D.hash,M),R.length<64&&(R+=" "+D.hint)}else M=ro(w(V),M),V.kind==="text"&&R.length<64&&(R+=V.value.slice(0,64));E={hash:"E"+M,hint:Ws(R).trim().slice(0,64),sig:N.sig,tok:null}}else E={hash:"N"+A.nodeType,hint:"",sig:null,tok:null};return n.set(A,E),E}function i(A){if(!A.tok){A.tok=new Set;for(let E of A.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))E&&A.tok.add(E)}return A.tok}function u(A){let E=s.get(A);if(E)return E;E=[];let N=null,M=()=>{N&&(N.value=N.nodes.map(R=>R.nodeValue).join(""),E.push(N),N=null)};for(let R of l(A)){if(R.nodeType===3){N||(N={kind:"text",nodes:[],value:"",parent:A,hash:void 0}),N.nodes.push(R);continue}M(),R.nodeType===8?E.push({kind:"comment",nodes:[R],value:R.nodeValue,parent:A,hash:void 0}):R.nodeType===1&&!e(R)&&E.push(R)}return M(),s.set(A,E),E}function w(A){return A.nodeType===1?r(A).hash:(A.hash===void 0&&(A.hash=(A.kind==="text"?"T":"C")+ro(A.value)),A.hash)}function c(A,E){let N=i(r(A)),M=i(r(E));if(N.size===0&&M.size===0)return{coef:1,share:1};if(N.size===0||M.size===0)return null;let R=0;for(let V of N)M.has(V)&&R++;return{coef:R/Math.min(N.size,M.size),share:R/Math.max(N.size,M.size)}}function p(A,E){let N=c(A,E);return!!N&&N.coef>=.5}let b=new WeakMap;function S(A){let E=b.get(A);if(E)return E;E=[];for(let N of A.attributes)o(A,N.name)||E.push([N.namespaceURI||"",N.localName,N.value]);return E.sort((N,M)=>N[0]<M[0]?-1:N[0]>M[0]?1:N[1]<M[1]?-1:N[1]>M[1]?1:0),b.set(A,E),E}let C=new WeakMap;function m(A,E){if(A===E)return!0;if(w(A)!==w(E))return!1;let N=C.get(A);if(N&&N.has(E))return N.get(E);let M=C.get(E);if(M&&M.has(A))return M.get(A);let R=f(A,E),V=R===!0;return R===!1&&t&&t.hashRejected++,N||C.set(A,N=new WeakMap),N.set(E,V),V}function f(A,E){if(A.nodeType===1){if(E.nodeType!==1||A.tagName!==E.tagName||A.namespaceURI!==E.namespaceURI)return!1;let N=S(A),M=S(E);if(N.length!==M.length)return!1;for(let D=0;D<N.length;D++)if(N[D][0]!==M[D][0]||N[D][1]!==M[D][1]||N[D][2]!==M[D][2])return!1;let R=u(A),V=u(E);if(R.length!==V.length)return!1;for(let D=0;D<R.length;D++){if(w(R[D])!==w(V[D]))return!1;if(!m(R[D],V[D]))return di}return!0}return E.nodeType===1?!1:A.kind===E.kind&&A.value===E.value}let g=new WeakMap,I=new Map,v=0;function T(A){let E=g.get(A);if(E)return E;let N=w(A),M=I.get(N);M||I.set(N,M=[]);let R=M.find(V=>m(V.unit,A));return E=R?R.key:"K"+v++,R||M.push({unit:A,key:E}),g.set(A,E),E}return{meta:r,unitsOf:u,unitHash:w,similar:p,score:c,childrenOf:l,equalUnits:m,exactUnitKey:T,ignored:e}}var Fs=16,hi=2e3,pi=3,as={align:0,certifyVisited:0,certifyScheduled:0};function cs(e,o,t){let{meta:n,unitsOf:s,unitHash:h,similar:l,score:r,childrenOf:i,equalUnits:u,ignored:w}=t.analyzer,c=t.baseId||(()=>null),p=t.sideId||(()=>null),b=t.baseKey||(()=>null),S=t.sideKey||(()=>null),C=t.baseDropped||new Set,m=t.sideDropped||new Set,f=t.stats||null,g=f?new Set:null,I=f?new Set:null,v=new Map,T=new Map,A=new Set,E=new Map,N=new Set,M=new Set,R=new Set,V=[],D=[],j=[],y=[],k=hi,J=new Map,H=new Map,q=(W,X)=>{v.set(W,X),T.set(X,W)},Me=new Set,Oe=new Set,Re=null,ie=W=>{let X=W.nodeType?W.parentNode:W.parent;if(!X||X.nodeType!==11)return X;if(!Re){Re=new WeakMap;let pe=be=>{for(let he of be.querySelectorAll("template"))he.content&&(Re.set(he.content,he),pe(he.content))};for(let be of[e,o])pe(be.tagName==="TEMPLATE"&&be.content?be.content:be)}return Re.get(X)||null},xe=(W,X)=>{for(let pe=ie(W);pe&&!Me.has(pe);pe=ie(pe))Me.add(pe);for(let pe=ie(X);pe&&!Oe.has(pe);pe=ie(pe))Oe.add(pe)},qe=W=>{for(let X=ie(W);X;X=ie(X))if(v.has(X))return M.has(X);return!1},fe=W=>{for(let X=ie(W);X;X=ie(X)){let pe=T.get(X);if(pe!==void 0)return M.has(pe)}return!1},x=W=>!!W&&W.nodeType===1,Y=(W,X)=>{let pe=E.get(W);return!!pe&&pe.has(X)},ae=W=>qs.has(W.tagName),oe=t.comparisons||t.scope,Ee=(W,X)=>{if(oe){if(oe.same.get(W)===X)return!0;if(oe.differ.get(W)===X)return!1}if(!W.isEqualNode(X))return!1;if(W.tagName==="TEMPLATE")return u(W,X);let pe=W.getElementsByTagName("template");if(pe.length===0)return!0;let be=X.getElementsByTagName("template");if(pe.length!==be.length)return!1;for(let he=0;he<pe.length;he++)if(!u(pe[he],be[he]))return!1;return!0},De=(W,X)=>{let pe=c(W);if(!pe)return!0;let be=p(X);return!be||pe===be},Ne=W=>{let X=b(W);return X&&t.baseIndex.get(X)===W&&!m.has(X)?X:null},nt=W=>{let X=S(W);return X&&t.sideIndex.get(X)===W&&!C.has(X)?X:null},Xe=(W,X)=>{let pe=Ne(W);if(!pe)return!0;let be=nt(X);return!be||pe===be},ht=globalThis.__hyperMorphProfile,Ge=ht?performance.now():0;ht&&!t.scope&&(n(e),n(o),ht.meta=(ht.meta||0)+(performance.now()-Ge),Ge=performance.now()),q(e,o);let rt=new Set;for(let[W,X]of t.baseIndex){let pe=t.sideIndex.get(W);pe&&pe.tagName===X.tagName&&!v.has(X)&&!T.has(pe)&&(q(X,pe),xe(X,pe),rt.add(X))}if(rt.size){let W=[];if(t.scope)for(let he of t.scope.chain)rt.has(he)&&W.push(he);let X=[t.scope?t.scope.root:e];for(;X.length;){let he=X.pop();rt.has(he)&&W.push(he);let ee=i(he);for(let te=ee.length-1;te>=0;te--)ee[te].nodeType===1&&X.push(ee[te])}let pe=new Set;for(let he=W.length-1;he>=0;he--){let ee=W[he];t.scope&&t.scope.onChain.has(ee)?pe.add(ee):Dt(ee,v.get(ee),pe)?(M.add(ee),R.add(ee),f&&f.certificationPairs++):pe.add(ee)}let be=new Set;for(let he of W)M.has(he)&&!be.has(he)&&Ot(he,be)}t.scope&&t.scope.head&&Yt(t.scope.head[0],t.scope.head[1]);function Ot(W,X){let pe=[W];for(;pe.length;){let be=pe.pop();if(!X.has(be)){X.add(be),O(be);for(let he of s(be))x(he)&&v.has(he)&&pe.push(he)}}}y.push([e,o]);for(let[W,X]of v)x(W)&&W!==e&&y.push([W,X]);return Lt(),Ct(),ht&&(ht.align=(ht.align||0)+(performance.now()-Ge)),{map:v,reverse:T,moved:N,identical:M,pairIdenticalChildren:O,weak:A,unpair:wt,rematch:Ct,insertedByHash:Nt,refused:I,identityPaired:rt};function Ct(){Ae(),Lt();for(let W=0;W<j.length;){let X=j.length;It(W,X),W=X,Lt(),Ae(),Lt()}}function wt(W){let X=v.get(W);if(!X)return;E.has(W)||E.set(W,new Set),E.get(W).add(X);let pe=(he,ee)=>{v.delete(he),T.delete(ee),N.delete(he),M.delete(he),A.delete(he),R.delete(he)},be=(he,ee)=>{for(let te of s(he)){let z=v.get(te);!z||rt.has(te)||!(x(z)?ee.contains(z):ee.contains(z.nodes[0]))||(pe(te,z),x(te)&&be(te,z))}};pe(W,X),x(W)&&be(W,X),V.push(W),D.push(X)}function Nt(){let W=new Map;for(let X of new Set(D)){if(T.has(X))continue;let pe=n(X).hash;W.has(pe)||W.set(pe,[]),W.get(pe).push(X)}return W}function Lt(){for(;y.length;){let[W,X]=y.shift();v.get(W)!==X||R.has(W)||M.has(W)||cn(W,X)}}function qt(W,X){if(!ae(W))for(let pe of s(W))x(pe)&&(X.push(pe),qt(pe,X))}function cn(W,X){R.add(W);let pe=s(W),be=s(X);as.align+=pe.length+be.length,J=new Map,H=new Map;for(let ne=0;ne<pe.length;ne++)J.set(pe[ne],ne);for(let ne=0;ne<be.length;ne++)H.set(be[ne],ne);if(W.tagName==="HTML")for(let ne of["HEAD","BODY"]){let Te=pe.find(Pe=>x(Pe)&&Pe.tagName===ne),Ce=be.find(Pe=>x(Pe)&&Pe.tagName===ne);Te&&Ce&&!v.has(Te)&&!T.has(Ce)&&q(Te,Ce)}for(let ne=0;ne<pe.length&&ne<be.length;ne++){let Te=pe[ne],Ce=be[ne];v.has(Te)||T.has(Ce)||(x(Te)?x(Ce)&&Te.tagName===Ce.tagName&&Ee(Te,Ce)&&Yt(Te,Ce):!x(Ce)&&Te.kind===Ce.kind&&Te.value===Ce.value&&Yt(Te,Ce))}le(pe,be);let he=pe.filter(ne=>!v.has(ne)),ee=be.filter(ne=>!T.has(ne));he.length&&ee.length&&(wn(he,ee),P(he,ee),K(he,ee,pe,be),de(pe,be));let te=!1,z=!1;for(let ne of pe){if(!v.has(ne)){x(ne)&&(V.push(ne),qt(ne,V),te=!0);continue}x(ne)&&!M.has(ne)&&y.push([ne,v.get(ne)])}for(let ne of be)!T.has(ne)&&x(ne)&&(D.push(ne),qt(ne,D),z=!0);te&&z&&j.push([W,X])}function It(W,X){for(let pe=W;pe<X;pe++){let[be,he]=j[pe];if(v.get(be)!==he)continue;let ee=s(be),te=s(he),z=new Map,ne=new Map,Te=null;for(let Ce of ee)x(Ce)&&(v.has(Ce)?Te=Ce:(z.has(Te)||z.set(Te,[]),z.get(Te).push(Ce)));Te=null;for(let Ce of te)x(Ce)&&(T.has(Ce)?Te=T.get(Ce):(ne.has(Te)||ne.set(Te,[]),ne.get(Te).push(Ce)));for(let[Ce,Pe]of z){let ve=ne.get(Ce);if(!(!ve||Pe.length!==ve.length)&&Pe.every((_e,Je)=>ve[Je].tagName===_e.tagName&&De(_e,ve[Je])&&!Y(_e,ve[Je])))for(let _e=0;_e<Pe.length;_e++)Gt(Pe[_e],ve[_e])}}}function Gt(W,X){q(W,X),A.add(W),y.push([W,X]),Lt()}function wn(W,X){let pe=io(W,h),be=io(X,h),he=new Map;for(let ee of X){let te=h(ee);be.get(te)===1&&he.set(te,ee)}for(let ee of W){if(v.has(ee))continue;let te=h(ee);if(pe.get(te)!==1)continue;let z=he.get(te);z&&!T.has(z)&&u(ee,z)&&Yt(ee,z)}}function Dt(W,X,pe){let be=[[W,X]];for(;be.length;){let[he,ee]=be.pop();if(as.certifyVisited++,f&&f.certificationVisited++,he.nodeType!==ee.nodeType)return!1;if(he.nodeType===3||he.nodeType===8){if(he.nodeValue!==ee.nodeValue)return!1;continue}if(he.nodeType!==1){if(!he.isEqualNode(ee))return!1;continue}if(he.tagName!==ee.tagName||he.namespaceURI!==ee.namespaceURI||w(he)!==w(ee))return!1;let te=he.attributes,z=ee.attributes;if(te.length!==z.length)return!1;for(let ve=0;ve<te.length;ve++){let _e=te[ve];if(ee.getAttributeNS(_e.namespaceURI,_e.localName)!==_e.value)return!1}let ne=v.get(he);if(ne!==void 0&&ne!==ee)return!1;let Te=T.get(ee);if(Te!==void 0&&Te!==he)return!1;if(he!==W){if(M.has(he))continue;if(pe.has(he))return!1}let Ce=i(he),Pe=i(ee);if(Ce.length!==Pe.length)return!1;as.certifyScheduled+=Ce.length;for(let ve=Ce.length-1;ve>=0;ve--)be.push([Ce[ve],Pe[ve]])}return!0}function rn(W,X){return!x(W)||!(Me.has(W)||Oe.has(X))?!0:!!$(W,X)||!(Ne(W)||nt(X))}function Yt(W,X){if(x(W)&&(Me.has(W)||Oe.has(X))){let pe=$(W,X);if(!pe){if(Ne(W)||nt(X))return;q(W,X),y.push([W,X]);return}for(let be=0;be<pe.length;be+=2){let he=pe[be],ee=pe[be+1],te=v.get(he);te!==void 0&&te!==ee&&fn(he,te);let z=T.get(ee);z!==void 0&&z!==he&&fn(z,ee),v.get(he)===ee&&(N.delete(he),A.delete(he),M.add(he),R.add(he))}}a(W,X)}function fn(W,X){v.delete(W),T.delete(X),N.delete(W),M.delete(W),A.delete(W),R.delete(W)}function $(W,X){let pe=[W,X,!1],be=[];for(;pe.length;){let he=pe.pop(),ee=pe.pop(),te=pe.pop(),z=v.get(te),ne=T.get(ee);if(te!==W&&(z!==void 0&&z!==ee&&rt.has(te)||ne!==void 0&&ne!==te&&rt.has(ne)))return null;if(!(z===ee&&M.has(te))&&((z!==void 0||ne!==void 0)&&be.push(te,ee),!!x(te))){if(he||z!==void 0&&z!==ee||ne!==void 0&&ne!==te){let Te=s(te),Ce=s(ee);for(let Pe=0;Pe<Te.length&&Pe<Ce.length;Pe++)pe.push(Te[Pe],Ce[Pe],!0)}else if(Me.has(te)||Oe.has(ee)){let Te=te.tagName==="TEMPLATE"?te.content:te,Ce=ee.tagName==="TEMPLATE"?ee.content:ee;for(let Pe=Te.firstElementChild,ve=Ce.firstElementChild;Pe&&ve;){if(w(Pe)){Pe=Pe.nextElementSibling;continue}if(w(ve)){ve=ve.nextElementSibling;continue}(v.has(Pe)||T.has(ve)||Me.has(Pe)||Oe.has(ve))&&pe.push(Pe,ve,!1),Pe=Pe.nextElementSibling,ve=ve.nextElementSibling}}}}return be}function a(W,X){q(W,X),M.add(W),x(W)&&R.add(W)}function O(W){let X=v.get(W);if(!X||!x(W))return;let pe=s(W),be=s(X);for(let he=0;he<pe.length&&he<be.length;he++)v.has(pe[he])||a(pe[he],be[he])}function P(W,X){let pe=te=>x(te)&&!ae(te)?n(te).sig+""+n(te).hint:null,be=io(W,pe),he=io(X,pe),ee=new Map;for(let te of X){let z=pe(te);z!=null&&he.get(z)===1&&ee.set(z,te)}for(let te of W){if(v.has(te))continue;let z=pe(te);if(z==null||be.get(z)!==1)continue;let ne=ee.get(z);ne&&!T.has(ne)&&De(te,ne)&&q(te,ne)}}function K(W,X,pe,be){let he=new Map;for(let te of X){if(!x(te)||T.has(te)||ae(te))continue;let z=n(te).sig;he.has(z)||he.set(z,[]),he.get(z).push({el:te,index:H.get(te)})}let ee=[];for(let te of W){if(v.has(te)||!x(te)||ae(te))continue;let z=he.get(n(te).sig);if(!z||!z.length)continue;let ne=J.get(te),Te=z.filter(Ce=>!T.has(Ce.el)).map(Ce=>({c:Ce,d:Math.abs(Ce.index-ne)}));Te.sort((Ce,Pe)=>Ce.d-Pe.d),Te.length>Fs&&(Te=Te.slice(0,Fs));for(let{c:Ce,d:Pe}of Te){if(!De(te,Ce.el))continue;let ve=r(te,Ce.el);ve&&ve.coef>=.5&&ee.push({b:te,s:Ce.el,coef:ve.coef,share:ve.share,d:Pe,bi:ne})}}if(ee.sort((te,z)=>z.coef-te.coef||z.share-te.share||te.d-z.d||te.bi-z.bi),f&&ee.length>1){let te=new Map;for(let z of ee){let ne=te.get(z.b);ne?ne.coef===z.coef&&(ne.share===z.share?ne.strict++:ne.loose++):te.set(z.b,{coef:z.coef,share:z.share,strict:0,loose:0})}for(let[z,ne]of te)g.has(z)||!(ne.strict||ne.loose)||(g.add(z),ne.strict?f.similarTiesStrict++:f.similarTiesLoose++)}for(let te of ee)!v.has(te.b)&&!T.has(te.s)&&q(te.b,te.s)}function Z(W,X){return x(W)!==x(X)?!1:x(W)?W.tagName!==X.tagName||!De(W,X)?!1:ae(W)||n(W).hint===""||n(X).hint===""?!0:l(W,X):W.kind===X.kind}function U(W,X){let pe=(he,ee)=>{let te=ee===null?-1:he===X?H.get(ee):J.get(ee),z=he[te+1];return z&&!x(z)?z:null},be=null;for(let he of W){if(x(he)){be=he;continue}if(v.has(he))continue;let ee=be===null?null:v.get(be);if(be!==null&&!ee)continue;let te=pe(X,ee);te&&!T.has(te)&&te.kind===he.kind&&q(he,te)}}function de(W,X){U(W,X);let pe=we(W,X),be=(ee,te)=>x(ee)&&n(ee).hint!==""&&n(te).hint===""&&!!te.querySelector("br")&&!pe(ee,te),he=0;for(let ee of W){if(v.has(ee)){let z=H.get(v.get(ee));z!==void 0&&z>=he&&(he=z+1);continue}let te=0;for(let z=he;z<X.length&&te<pi;z++){let ne=X[z];if(!T.has(ne)&&(te++,Z(ee,ne)&&!Y(ee,ne)&&!be(ee,ne))){q(ee,ne),x(ee)&&(n(ee).hint===""||n(ne).hint==="")&&A.add(ee),he=z+1;break}}}le(W,X)}function we(W,X){let pe=(be,he,ee)=>{for(let te=he-1;te>=0;te--)if(x(be[te])&&ee(be[te]))return be[te];return null};return(be,he)=>{let ee=J.get(be),te=H.get(he);if(ee===te)return!0;let z=pe(W,ee,Te=>v.has(Te)),ne=pe(X,te,Te=>T.has(Te));return z?v.get(z)===ne:!ne}}function le(W,X){let pe=W.filter(z=>x(z)&&!v.has(z)),be=X.filter(z=>x(z)&&!T.has(z));if(!pe.length||!be.length)return;let he=io(pe,z=>z.tagName),ee=io(be,z=>z.tagName),te=we(W,X);for(let z of pe){let ne=z.tagName;if(he.get(ne)!==1||ee.get(ne)!==1)continue;let Te=be.find(Ce=>Ce.tagName===ne);Te&&!T.has(Te)&&te(z,Te)&&De(z,Te)&&!Y(z,Te)&&(u(z,Te)?Yt(z,Te):(q(z,Te),A.add(z)))}}function Ae(){let W=new Map;for(let z of A)if(x(z)&&x(v.get(z))){let ne=n(z).hash;W.has(ne)||W.set(ne,[]),W.get(ne).push(z)}if(W.size)for(let z of D){if(T.has(z)||!x(z)||fe(z))continue;let ne=W.get(n(z).hash),Te=ne&&ne.find(Ce=>A.has(Ce)&&!Y(Ce,z)&&De(Ce,z)&&Xe(Ce,z)&&u(Ce,z)&&rn(Ce,z));Te&&(wt(Te),Yt(Te,z),xe(Te,z),N.add(Te))}let X=new Map,pe=new Map,be=new Map;for(let z of A){let ne=v.get(z);x(z)&&x(ne)&&be.set(ne,z)}let he=(z,ne)=>{if(!T.has(z))return!fe(z);let Te=be.get(z);return Te===T.get(z)&&Te!==ne&&!Te.contains(ne)},ee=z=>{if(T.has(z)){let ne=be.get(z);be.delete(z),wt(ne)}};for(let z of[...D,...be.keys()]){if(T.has(z)&&!be.has(z))continue;let ne=n(z).hash;if(X.has(ne)||X.set(ne,[]),X.get(ne).push(z),ae(z))continue;let Te=n(z).sig;pe.has(Te)||pe.set(Te,[]),pe.get(Te).push(z)}let te=new Set;for(let z of A){let ne=v.get(z);!x(z)||!x(ne)||ae(z)||n(z).hint===""||n(ne).hint===""||l(z,ne)||te.add(z)}for(let z of[...V,...te]){let ne=v.get(z);if(ne?!(A.has(z)&&te.has(z)):qe(z))continue;let Te=Je=>{ne&&wt(z),ee(Je)},Ce=X.get(n(z).hash);if(Ce){let Je=Ce.find(Ze=>Ze!==ne&&he(Ze,z)&&!Y(z,Ze)&&Xe(z,Ze)&&u(z,Ze)&&rn(z,Ze));if(Je){Te(Je),Yt(z,Je),xe(z,Je),N.add(z);continue}}if(ae(z)||k<=0)continue;let Pe=pe.get(n(z).sig);if(!Pe)continue;let ve=null,_e=0;for(let Je of Pe)if(!(Je===ne||!he(Je,z)||!De(z,Je)||!Xe(z,Je)||Y(z,Je))&&(k--<=0||l(z,Je)&&(_e++,ve=Je,_e>1)))break;_e>1&&I&&I.add(z),_e===1&&(Te(ve),q(z,ve),xe(z,ve),N.add(z),y.push([z,ve]))}}}function io(e,o){let t=new Map;for(let n of e){let s=o(n);s!=null&&t.set(s,(t.get(s)||0)+1)}return t}var mi={diff:0},_s=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,gi=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,bi=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,wi=/\P{M}\p{M}*/gu;function yi(e){if(e==="")return[];if(_s){let t=[];for(let n of _s.segment(e))t.push(n.segment);return t}let o=[];for(let t of e.match(bi))if(gi.test(t))for(let n of t.match(wi))o.push(n);else o.push(t);return o}var ki=/^[  ]+$/,xi=e=>ki.test(e)?" ".repeat(e.length):e,Gn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),kt="",fs=e=>e.every(o=>Gn(o)||o.k===kt),Ti=/^[\x00-\x7f\u00A0]*$/,vi=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Si(e){return e===""?[]:e.match(vi)}function an(e,o=!1){return(o?Si(e):yi(e)).map(t=>({k:xi(t),raw:t,len:t.length}))}var xn=(...e)=>e.every(o=>Ti.test(o));function us(e,o,t){let n=e.length,s=o.length,h=Math.min(n+s,t),l=h+1,r=new Int32Array(2*h+3),i=[],u=n===0&&s===0;for(let b=0;b<=h&&!u;b++){i.push(r.slice(l-b,l+b+1));for(let S=-b;S<=b;S+=2){let C;S===-b||S!==b&&r[l+S-1]<r[l+S+1]?C=r[l+S+1]:C=r[l+S-1]+1;let m=C-S,f=C;for(;C<n&&m<s&&e[C].k===o[m].k;)C++,m++;if(mi.diff+=1+C-f,r[l+S]=C,C>=n&&m>=s){u=!0;break}}}if(!u)return null;let w=[],c=n,p=s;for(let b=i.length-1;b>0;b--){let S=i[b],C=c-p,m=C+b,f=C===-b||C!==b&&S[m-1]<S[m+1]?C+1:C-1,g=S[f+b],I=g-f;for(;c>g&&p>I;)w.push([0,c-1,p-1]),c--,p--;c===g?(w.push([1,c,p-1]),p--):(w.push([-1,c-1,p]),c--)}for(;c>0&&p>0;)w.push([0,c-1,p-1]),c--,p--;return w.reverse(),w}function Ni(e,o,t){let n=c=>c.k===kt;if(!e.some(n)&&!o.some(n))return us(e,o,t);let s=[],h=[];for(let c=0;c<e.length;c++)n(e[c])||s.push(c);for(let c=0;c<o.length;c++)n(o[c])||h.push(c);let l=us(s.map(c=>e[c]),h.map(c=>o[c]),t);if(!l)return null;let r=[],i=0,u=0,w=(c,p)=>{for(;i<c&&u<p&&e[i].k===o[u].k;)r.push([0,i++,u++]);let b=us(e.slice(i,c),o.slice(u,p),t);if(!b)return!1;for(let[S,C,m]of b)r.push([S,C+i,m+u]);return i=c,u=p,!0};for(let[c,p,b]of l)if(c===0){if(!w(s[p],h[b]))return null;r.push([0,i,u]),i++,u++}return w(e.length,o.length)?r:null}function Wn(e,o,t=4e3){let n=[],s=0;for(;s<e.length&&s<o.length&&e[s].k===o[s].k;)e[s].raw!==o[s].raw&&n.push({bi:s,tok:o[s]}),s++;let h=0;for(;h<e.length-s&&h<o.length-s&&e[e.length-1-h].k===o[o.length-1-h].k;)e[e.length-1-h].raw!==o[o.length-1-h].raw&&n.push({bi:e.length-1-h,tok:o[o.length-1-h]}),h++;let l=e.slice(s,e.length-h),r=o.slice(s,o.length-h),i=Li(l,r)?null:Ni(l,r,t);if(!i){let f=l.length||r.length?[{bs:s,be:s+l.length,toks:r}]:[];return{hunks:f,cosmetic:n,coarse:!0,parts:f.map(g=>({...g,gap:[],group:0})),cosmeticEq:n}}let u=[],w=(f,g)=>{l[f].raw!==r[g].raw&&n.push({bi:s+f,tok:r[g]})},c=null,p=[],b=0,S=0,C=()=>{c&&u.push(c),c=null;for(let[f,g]of p)w(f,g);p=[],b++};for(let[f,g,I]of i){if(f===0){c&&Gn(l[g])&&!l[g].k.includes(`
1
+ var HyperMorph=(()=>{var os=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var ii=Object.getOwnPropertyNames;var li=Object.prototype.hasOwnProperty;var ai=(e,o)=>{for(var t in o)os(e,t,{get:o[t],enumerable:!0})},ci=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of ii(o))!li.call(e,s)&&s!==t&&os(e,s,{get:()=>o[s],enumerable:!(n=ri(o,s))||n.enumerable});return e};var fi=e=>ci(os({},"__esModule",{value:!0}),e);var Rl={};ai(Rl,{createIdentityStore:()=>Hs,createParseCache:()=>jo,default:()=>El,diff:()=>Yn,findChangedRoots:()=>Gr,importMap:()=>Do,merge3:()=>ni,merge3Text:()=>lo,mergeDocument:()=>wo,mergeJson:()=>Os,mergeScriptText:()=>Yo,morph:()=>Zo,morphDocument:()=>oi,morphElement:()=>es,parseJsonRelaxed:()=>zo,parseRulesRelaxed:()=>xr,spliceProtected:()=>Yr,tieredIdentity:()=>is});function Bo(e,o){if(typeof e=="string"){let t=o&&o.defaultView,n=t&&t.DOMParser||globalThis.DOMParser;return new n().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function jo(e){let o=new Map;return(t,n)=>{if(typeof n!="string")return Bo(n,e);let s=o.get(t);if(s&&s.text===n)return s.doc;let h=Bo(n,e);return o.set(t,{text:n,doc:h}),h}}function Vs(e,o){let t=o.doctype;if(!t)return!1;let n=e.doctype;if(n&&n.name===t.name&&n.publicId===t.publicId&&n.systemId===t.systemId)return!1;let s=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return n?e.replaceChild(s,n):e.insertBefore(s,e.documentElement),!0}var ss=()=>!1;function rs(e,o=[]){if(typeof e!="function")return ss;let t=new WeakMap,n=new Set(o);return s=>{if(!s||s.nodeType!==1)return!1;let h=t.get(s);if(h!==void 0)return h;let l=[],r=s,i=!1;for(;r&&r.nodeType===1;){let u=t.get(r);if(u!==void 0){i=u;break}if(l.push(r),e(r,n.has(r))){i=!0;break}if(n.has(r))break;r=r.parentElement}for(let u of l)t.set(u,i);return i}}var Dl=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 $n(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Hs(e){let o=new WeakMap,t=0,n=r=>o.get(r)||null,s=r=>{let i=o.get(r);return i||(i=`${e}:${++t}`,o.set(r,i)),i};return{idOf:n,ensure:s,adopt:(r,i)=>{r&&typeof i=="string"&&i&&o.set(r,i)},exportMap:(r,i)=>{let u={},w=[],c=[],p=(b,S)=>{let C=i(b);C&&(u[S]=s(C));let m=b.children;w.push(m.length),c.push(b.tagName.toLowerCase());for(let f=0;f<m.length;f++)p(m[f],S===""?String(f):`${S}.${f}`)};return p(r,""),u["~"]=w.join(","),u["^"]=c.join(","),u}}}function Do(e,o){let t=new WeakMap;if(!e||!o||typeof o!="object"||Array.isArray(o))return t;let n=o["~"],s=typeof n=="string"?n.split(",").map(Number):null,h=s&&typeof o["^"]=="string"?o["^"].split(","):null,l=c=>Number.isInteger(c)&&c>=0,r=0,i=!1,u=c=>{let p=c;for(;p>0;){let b=s[r++];if(r>s.length||!l(b))return!1;p+=b-1}return!0},w=(c,p)=>{if(i)return;if(s){let C=r++,m=s[C];if(C>=s.length||!l(m)){i=!0;return}let f=!h||h[C]===c.tagName.toLowerCase();if(!f||m!==c.children.length){let g=f&&o[p];typeof g=="string"&&g&&t.set(c,g),u(m)||(i=!0);return}}let b=o[p];typeof b=="string"&&b&&t.set(c,b);let S=c.children;for(let C=0;C<S.length;C++)w(S[C],p===""?String(C):`${p}.${C}`)};return w(e,""),t}function is(e){return o=>{for(let t of e){let n=t(o);if(typeof n=="string"&&n!=="")return n}return null}}var kn=is([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Uo(e,o,t,n=null,s=null){let h=new Map,l=new Set,r=i=>{if(t(i))return;let u=o(i);u&&(h.has(u)?l.add(u):h.set(u,i))};if(n){let i=u=>{for(let w of u.querySelectorAll(n))r(w);for(let w of u.querySelectorAll("template"))w.content&&i(w.content)};r(e),i(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let i=u=>{r(u);let w=u.tagName==="TEMPLATE"&&u.content?u.content.children:u.children;for(let c=0;c<w.length;c++)i(w[c])};i(e)}for(let i of l)h.delete(i),s&&s.add(i),ls(i);return h}function ls(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var ui=new Set(["href","src","name","type","role"]),qs=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function ro(e,o=5381){let t=o;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return t>>>0}function Ws(e){return e.replace(/\s+/g," ")}var di=0;function Ks({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,s=new WeakMap;function h(A){let E=A.attributes,N=E.length;if(N===0)return{all:"",sig:A.tagName+"|"};let M=[],P="",V=[];for(let D=0;D<N;D++){let j=E[D],y=j.name;o(A,y)||M.push(y+"="+j.value),y==="class"?P=j.value.indexOf(" ")<0?j.value:j.value.split(/\s+/).filter(Boolean).sort().join(" "):ui.has(y)&&V.push(y+"="+j.value)}return M.length>1&&M.sort(),V.length>1&&V.sort(),{all:M.join(""),sig:A.tagName+"|"+P+(V.length?"|"+V.join("|"):"")}}function l(A){return A.nodeType===1&&A.tagName==="TEMPLATE"&&A.content?A.content.childNodes:A.childNodes}function r(A){let E=n.get(A);if(E)return E;if(A.nodeType===3)E={hash:"T"+ro(A.nodeValue),hint:Ws(A.nodeValue).slice(0,64),sig:null,tok:null};else if(A.nodeType===8)E={hash:"C"+ro(A.nodeValue),hint:"",sig:null,tok:null};else if(A.nodeType===1){let N=h(A),M=ro(A.tagName+""+N.all),P="";for(let V of u(A))if(V.nodeType===1){let D=r(V);M=ro(D.hash,M),P.length<64&&(P+=" "+D.hint)}else M=ro(w(V),M),V.kind==="text"&&P.length<64&&(P+=V.value.slice(0,64));E={hash:"E"+M,hint:Ws(P).trim().slice(0,64),sig:N.sig,tok:null}}else E={hash:"N"+A.nodeType,hint:"",sig:null,tok:null};return n.set(A,E),E}function i(A){if(!A.tok){A.tok=new Set;for(let E of A.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))E&&A.tok.add(E)}return A.tok}function u(A){let E=s.get(A);if(E)return E;E=[];let N=null,M=()=>{N&&(N.value=N.nodes.map(P=>P.nodeValue).join(""),E.push(N),N=null)};for(let P of l(A)){if(P.nodeType===3){N||(N={kind:"text",nodes:[],value:"",parent:A,hash:void 0}),N.nodes.push(P);continue}M(),P.nodeType===8?E.push({kind:"comment",nodes:[P],value:P.nodeValue,parent:A,hash:void 0}):P.nodeType===1&&!e(P)&&E.push(P)}return M(),s.set(A,E),E}function w(A){return A.nodeType===1?r(A).hash:(A.hash===void 0&&(A.hash=(A.kind==="text"?"T":"C")+ro(A.value)),A.hash)}function c(A,E){let N=i(r(A)),M=i(r(E));if(N.size===0&&M.size===0)return{coef:1,share:1};if(N.size===0||M.size===0)return null;let P=0;for(let V of N)M.has(V)&&P++;return{coef:P/Math.min(N.size,M.size),share:P/Math.max(N.size,M.size)}}function p(A,E){let N=c(A,E);return!!N&&N.coef>=.5}let b=new WeakMap;function S(A){let E=b.get(A);if(E)return E;E=[];for(let N of A.attributes)o(A,N.name)||E.push([N.namespaceURI||"",N.localName,N.value]);return E.sort((N,M)=>N[0]<M[0]?-1:N[0]>M[0]?1:N[1]<M[1]?-1:N[1]>M[1]?1:0),b.set(A,E),E}let C=new WeakMap;function m(A,E){if(A===E)return!0;if(w(A)!==w(E))return!1;let N=C.get(A);if(N&&N.has(E))return N.get(E);let M=C.get(E);if(M&&M.has(A))return M.get(A);let P=f(A,E),V=P===!0;return P===!1&&t&&t.hashRejected++,N||C.set(A,N=new WeakMap),N.set(E,V),V}function f(A,E){if(A.nodeType===1){if(E.nodeType!==1||A.tagName!==E.tagName||A.namespaceURI!==E.namespaceURI)return!1;let N=S(A),M=S(E);if(N.length!==M.length)return!1;for(let D=0;D<N.length;D++)if(N[D][0]!==M[D][0]||N[D][1]!==M[D][1]||N[D][2]!==M[D][2])return!1;let P=u(A),V=u(E);if(P.length!==V.length)return!1;for(let D=0;D<P.length;D++){if(w(P[D])!==w(V[D]))return!1;if(!m(P[D],V[D]))return di}return!0}return E.nodeType===1?!1:A.kind===E.kind&&A.value===E.value}let g=new WeakMap,I=new Map,v=0;function T(A){let E=g.get(A);if(E)return E;let N=w(A),M=I.get(N);M||I.set(N,M=[]);let P=M.find(V=>m(V.unit,A));return E=P?P.key:"K"+v++,P||M.push({unit:A,key:E}),g.set(A,E),E}return{meta:r,unitsOf:u,unitHash:w,similar:p,score:c,childrenOf:l,equalUnits:m,exactUnitKey:T,ignored:e}}var Fs=16,hi=2e3,pi=3,as={align:0,certifyVisited:0,certifyScheduled:0};function cs(e,o,t){let{meta:n,unitsOf:s,unitHash:h,similar:l,score:r,childrenOf:i,equalUnits:u,ignored:w}=t.analyzer,c=t.baseId||(()=>null),p=t.sideId||(()=>null),b=t.baseKey||(()=>null),S=t.sideKey||(()=>null),C=t.baseDropped||new Set,m=t.sideDropped||new Set,f=t.stats||null,g=f?new Set:null,I=f?new Set:null,v=new Map,T=new Map,A=new Set,E=new Map,N=new Set,M=new Set,P=new Set,V=[],D=[],j=[],y=[],k=hi,J=new Map,H=new Map,q=(W,X)=>{v.set(W,X),T.set(X,W)},Me=new Set,Oe=new Set,Re=null,ie=W=>{let X=W.nodeType?W.parentNode:W.parent;if(!X||X.nodeType!==11)return X;if(!Re){Re=new WeakMap;let pe=be=>{for(let he of be.querySelectorAll("template"))he.content&&(Re.set(he.content,he),pe(he.content))};for(let be of[e,o])pe(be.tagName==="TEMPLATE"&&be.content?be.content:be)}return Re.get(X)||null},xe=(W,X)=>{for(let pe=ie(W);pe&&!Me.has(pe);pe=ie(pe))Me.add(pe);for(let pe=ie(X);pe&&!Oe.has(pe);pe=ie(pe))Oe.add(pe)},qe=W=>{for(let X=ie(W);X;X=ie(X))if(v.has(X))return M.has(X);return!1},fe=W=>{for(let X=ie(W);X;X=ie(X)){let pe=T.get(X);if(pe!==void 0)return M.has(pe)}return!1},x=W=>!!W&&W.nodeType===1,Y=(W,X)=>{let pe=E.get(W);return!!pe&&pe.has(X)},ae=W=>qs.has(W.tagName),oe=t.comparisons||t.scope,Ee=(W,X)=>{if(oe){if(oe.same.get(W)===X)return!0;if(oe.differ.get(W)===X)return!1}if(!W.isEqualNode(X))return!1;if(W.tagName==="TEMPLATE")return u(W,X);let pe=W.getElementsByTagName("template");if(pe.length===0)return!0;let be=X.getElementsByTagName("template");if(pe.length!==be.length)return!1;for(let he=0;he<pe.length;he++)if(!u(pe[he],be[he]))return!1;return!0},De=(W,X)=>{let pe=c(W);if(!pe)return!0;let be=p(X);return!be||pe===be},Ne=W=>{let X=b(W);return X&&t.baseIndex.get(X)===W&&!m.has(X)?X:null},nt=W=>{let X=S(W);return X&&t.sideIndex.get(X)===W&&!C.has(X)?X:null},Xe=(W,X)=>{let pe=Ne(W);if(!pe)return!0;let be=nt(X);return!be||pe===be},ht=globalThis.__hyperMorphProfile,Ge=ht?performance.now():0;ht&&!t.scope&&(n(e),n(o),ht.meta=(ht.meta||0)+(performance.now()-Ge),Ge=performance.now()),q(e,o);let rt=new Set;for(let[W,X]of t.baseIndex){let pe=t.sideIndex.get(W);pe&&pe.tagName===X.tagName&&!v.has(X)&&!T.has(pe)&&(q(X,pe),xe(X,pe),rt.add(X))}if(rt.size){let W=[];if(t.scope)for(let he of t.scope.chain)rt.has(he)&&W.push(he);let X=[t.scope?t.scope.root:e];for(;X.length;){let he=X.pop();rt.has(he)&&W.push(he);let ee=i(he);for(let te=ee.length-1;te>=0;te--)ee[te].nodeType===1&&X.push(ee[te])}let pe=new Set;for(let he=W.length-1;he>=0;he--){let ee=W[he];t.scope&&t.scope.onChain.has(ee)?pe.add(ee):Dt(ee,v.get(ee),pe)?(M.add(ee),P.add(ee),f&&f.certificationPairs++):pe.add(ee)}let be=new Set;for(let he of W)M.has(he)&&!be.has(he)&&Ot(he,be)}t.scope&&t.scope.head&&Yt(t.scope.head[0],t.scope.head[1]);function Ot(W,X){let pe=[W];for(;pe.length;){let be=pe.pop();if(!X.has(be)){X.add(be),O(be);for(let he of s(be))x(he)&&v.has(he)&&pe.push(he)}}}y.push([e,o]);for(let[W,X]of v)x(W)&&W!==e&&y.push([W,X]);return Lt(),Ct(),ht&&(ht.align=(ht.align||0)+(performance.now()-Ge)),{map:v,reverse:T,moved:N,identical:M,pairIdenticalChildren:O,weak:A,unpair:wt,rematch:Ct,insertedByHash:Nt,refused:I,identityPaired:rt};function Ct(){Ae(),Lt();for(let W=0;W<j.length;){let X=j.length;It(W,X),W=X,Lt(),Ae(),Lt()}}function wt(W){let X=v.get(W);if(!X)return;E.has(W)||E.set(W,new Set),E.get(W).add(X);let pe=(he,ee)=>{v.delete(he),T.delete(ee),N.delete(he),M.delete(he),A.delete(he),P.delete(he)},be=(he,ee)=>{for(let te of s(he)){let z=v.get(te);!z||rt.has(te)||!(x(z)?ee.contains(z):ee.contains(z.nodes[0]))||(pe(te,z),x(te)&&be(te,z))}};pe(W,X),x(W)&&be(W,X),V.push(W),D.push(X)}function Nt(){let W=new Map;for(let X of new Set(D)){if(T.has(X))continue;let pe=n(X).hash;W.has(pe)||W.set(pe,[]),W.get(pe).push(X)}return W}function Lt(){for(;y.length;){let[W,X]=y.shift();v.get(W)!==X||P.has(W)||M.has(W)||cn(W,X)}}function qt(W,X){if(!ae(W))for(let pe of s(W))x(pe)&&(X.push(pe),qt(pe,X))}function cn(W,X){P.add(W);let pe=s(W),be=s(X);as.align+=pe.length+be.length,J=new Map,H=new Map;for(let ne=0;ne<pe.length;ne++)J.set(pe[ne],ne);for(let ne=0;ne<be.length;ne++)H.set(be[ne],ne);if(W.tagName==="HTML")for(let ne of["HEAD","BODY"]){let Te=pe.find(Pe=>x(Pe)&&Pe.tagName===ne),Ce=be.find(Pe=>x(Pe)&&Pe.tagName===ne);Te&&Ce&&!v.has(Te)&&!T.has(Ce)&&q(Te,Ce)}for(let ne=0;ne<pe.length&&ne<be.length;ne++){let Te=pe[ne],Ce=be[ne];v.has(Te)||T.has(Ce)||(x(Te)?x(Ce)&&Te.tagName===Ce.tagName&&Ee(Te,Ce)&&Yt(Te,Ce):!x(Ce)&&Te.kind===Ce.kind&&Te.value===Ce.value&&Yt(Te,Ce))}le(pe,be);let he=pe.filter(ne=>!v.has(ne)),ee=be.filter(ne=>!T.has(ne));he.length&&ee.length&&(wn(he,ee),R(he,ee),K(he,ee,pe,be),de(pe,be));let te=!1,z=!1;for(let ne of pe){if(!v.has(ne)){x(ne)&&(V.push(ne),qt(ne,V),te=!0);continue}x(ne)&&!M.has(ne)&&y.push([ne,v.get(ne)])}for(let ne of be)!T.has(ne)&&x(ne)&&(D.push(ne),qt(ne,D),z=!0);te&&z&&j.push([W,X])}function It(W,X){for(let pe=W;pe<X;pe++){let[be,he]=j[pe];if(v.get(be)!==he)continue;let ee=s(be),te=s(he),z=new Map,ne=new Map,Te=null;for(let Ce of ee)x(Ce)&&(v.has(Ce)?Te=Ce:(z.has(Te)||z.set(Te,[]),z.get(Te).push(Ce)));Te=null;for(let Ce of te)x(Ce)&&(T.has(Ce)?Te=T.get(Ce):(ne.has(Te)||ne.set(Te,[]),ne.get(Te).push(Ce)));for(let[Ce,Pe]of z){let ve=ne.get(Ce);if(!(!ve||Pe.length!==ve.length)&&Pe.every((_e,Je)=>ve[Je].tagName===_e.tagName&&De(_e,ve[Je])&&!Y(_e,ve[Je])))for(let _e=0;_e<Pe.length;_e++)Gt(Pe[_e],ve[_e])}}}function Gt(W,X){q(W,X),A.add(W),y.push([W,X]),Lt()}function wn(W,X){let pe=io(W,h),be=io(X,h),he=new Map;for(let ee of X){let te=h(ee);be.get(te)===1&&he.set(te,ee)}for(let ee of W){if(v.has(ee))continue;let te=h(ee);if(pe.get(te)!==1)continue;let z=he.get(te);z&&!T.has(z)&&u(ee,z)&&Yt(ee,z)}}function Dt(W,X,pe){let be=[[W,X]];for(;be.length;){let[he,ee]=be.pop();if(as.certifyVisited++,f&&f.certificationVisited++,he.nodeType!==ee.nodeType)return!1;if(he.nodeType===3||he.nodeType===8){if(he.nodeValue!==ee.nodeValue)return!1;continue}if(he.nodeType!==1){if(!he.isEqualNode(ee))return!1;continue}if(he.tagName!==ee.tagName||he.namespaceURI!==ee.namespaceURI||w(he)!==w(ee))return!1;let te=he.attributes,z=ee.attributes;if(te.length!==z.length)return!1;for(let ve=0;ve<te.length;ve++){let _e=te[ve];if(ee.getAttributeNS(_e.namespaceURI,_e.localName)!==_e.value)return!1}let ne=v.get(he);if(ne!==void 0&&ne!==ee)return!1;let Te=T.get(ee);if(Te!==void 0&&Te!==he)return!1;if(he!==W){if(M.has(he))continue;if(pe.has(he))return!1}let Ce=i(he),Pe=i(ee);if(Ce.length!==Pe.length)return!1;as.certifyScheduled+=Ce.length;for(let ve=Ce.length-1;ve>=0;ve--)be.push([Ce[ve],Pe[ve]])}return!0}function rn(W,X){return!x(W)||!(Me.has(W)||Oe.has(X))?!0:!!$(W,X)||!(Ne(W)||nt(X))}function Yt(W,X){if(x(W)&&(Me.has(W)||Oe.has(X))){let pe=$(W,X);if(!pe){if(Ne(W)||nt(X))return;q(W,X),y.push([W,X]);return}for(let be=0;be<pe.length;be+=2){let he=pe[be],ee=pe[be+1],te=v.get(he);te!==void 0&&te!==ee&&fn(he,te);let z=T.get(ee);z!==void 0&&z!==he&&fn(z,ee),v.get(he)===ee&&(N.delete(he),A.delete(he),M.add(he),P.add(he))}}a(W,X)}function fn(W,X){v.delete(W),T.delete(X),N.delete(W),M.delete(W),A.delete(W),P.delete(W)}function $(W,X){let pe=[W,X,!1],be=[];for(;pe.length;){let he=pe.pop(),ee=pe.pop(),te=pe.pop(),z=v.get(te),ne=T.get(ee);if(te!==W&&(z!==void 0&&z!==ee&&rt.has(te)||ne!==void 0&&ne!==te&&rt.has(ne)))return null;if(!(z===ee&&M.has(te))&&((z!==void 0||ne!==void 0)&&be.push(te,ee),!!x(te))){if(he||z!==void 0&&z!==ee||ne!==void 0&&ne!==te){let Te=s(te),Ce=s(ee);for(let Pe=0;Pe<Te.length&&Pe<Ce.length;Pe++)pe.push(Te[Pe],Ce[Pe],!0)}else if(Me.has(te)||Oe.has(ee)){let Te=te.tagName==="TEMPLATE"?te.content:te,Ce=ee.tagName==="TEMPLATE"?ee.content:ee;for(let Pe=Te.firstElementChild,ve=Ce.firstElementChild;Pe&&ve;){if(w(Pe)){Pe=Pe.nextElementSibling;continue}if(w(ve)){ve=ve.nextElementSibling;continue}(v.has(Pe)||T.has(ve)||Me.has(Pe)||Oe.has(ve))&&pe.push(Pe,ve,!1),Pe=Pe.nextElementSibling,ve=ve.nextElementSibling}}}}return be}function a(W,X){q(W,X),M.add(W),x(W)&&P.add(W)}function O(W){let X=v.get(W);if(!X||!x(W))return;let pe=s(W),be=s(X);for(let he=0;he<pe.length&&he<be.length;he++)v.has(pe[he])||a(pe[he],be[he])}function R(W,X){let pe=te=>x(te)&&!ae(te)?n(te).sig+""+n(te).hint:null,be=io(W,pe),he=io(X,pe),ee=new Map;for(let te of X){let z=pe(te);z!=null&&he.get(z)===1&&ee.set(z,te)}for(let te of W){if(v.has(te))continue;let z=pe(te);if(z==null||be.get(z)!==1)continue;let ne=ee.get(z);ne&&!T.has(ne)&&De(te,ne)&&q(te,ne)}}function K(W,X,pe,be){let he=new Map;for(let te of X){if(!x(te)||T.has(te)||ae(te))continue;let z=n(te).sig;he.has(z)||he.set(z,[]),he.get(z).push({el:te,index:H.get(te)})}let ee=[];for(let te of W){if(v.has(te)||!x(te)||ae(te))continue;let z=he.get(n(te).sig);if(!z||!z.length)continue;let ne=J.get(te),Te=z.filter(Ce=>!T.has(Ce.el)).map(Ce=>({c:Ce,d:Math.abs(Ce.index-ne)}));Te.sort((Ce,Pe)=>Ce.d-Pe.d),Te.length>Fs&&(Te=Te.slice(0,Fs));for(let{c:Ce,d:Pe}of Te){if(!De(te,Ce.el))continue;let ve=r(te,Ce.el);ve&&ve.coef>=.5&&ee.push({b:te,s:Ce.el,coef:ve.coef,share:ve.share,d:Pe,bi:ne})}}if(ee.sort((te,z)=>z.coef-te.coef||z.share-te.share||te.d-z.d||te.bi-z.bi),f&&ee.length>1){let te=new Map;for(let z of ee){let ne=te.get(z.b);ne?ne.coef===z.coef&&(ne.share===z.share?ne.strict++:ne.loose++):te.set(z.b,{coef:z.coef,share:z.share,strict:0,loose:0})}for(let[z,ne]of te)g.has(z)||!(ne.strict||ne.loose)||(g.add(z),ne.strict?f.similarTiesStrict++:f.similarTiesLoose++)}for(let te of ee)!v.has(te.b)&&!T.has(te.s)&&q(te.b,te.s)}function Z(W,X){return x(W)!==x(X)?!1:x(W)?W.tagName!==X.tagName||!De(W,X)?!1:ae(W)||n(W).hint===""||n(X).hint===""?!0:l(W,X):W.kind===X.kind}function U(W,X){let pe=(he,ee)=>{let te=ee===null?-1:he===X?H.get(ee):J.get(ee),z=he[te+1];return z&&!x(z)?z:null},be=null;for(let he of W){if(x(he)){be=he;continue}if(v.has(he))continue;let ee=be===null?null:v.get(be);if(be!==null&&!ee)continue;let te=pe(X,ee);te&&!T.has(te)&&te.kind===he.kind&&q(he,te)}}function de(W,X){U(W,X);let pe=we(W,X),be=(ee,te)=>x(ee)&&n(ee).hint!==""&&n(te).hint===""&&!!te.querySelector("br")&&!pe(ee,te),he=0;for(let ee of W){if(v.has(ee)){let z=H.get(v.get(ee));z!==void 0&&z>=he&&(he=z+1);continue}let te=0;for(let z=he;z<X.length&&te<pi;z++){let ne=X[z];if(!T.has(ne)&&(te++,Z(ee,ne)&&!Y(ee,ne)&&!be(ee,ne))){q(ee,ne),x(ee)&&(n(ee).hint===""||n(ne).hint==="")&&A.add(ee),he=z+1;break}}}le(W,X)}function we(W,X){let pe=(be,he,ee)=>{for(let te=he-1;te>=0;te--)if(x(be[te])&&ee(be[te]))return be[te];return null};return(be,he)=>{let ee=J.get(be),te=H.get(he);if(ee===te)return!0;let z=pe(W,ee,Te=>v.has(Te)),ne=pe(X,te,Te=>T.has(Te));return z?v.get(z)===ne:!ne}}function le(W,X){let pe=W.filter(z=>x(z)&&!v.has(z)),be=X.filter(z=>x(z)&&!T.has(z));if(!pe.length||!be.length)return;let he=io(pe,z=>z.tagName),ee=io(be,z=>z.tagName),te=we(W,X);for(let z of pe){let ne=z.tagName;if(he.get(ne)!==1||ee.get(ne)!==1)continue;let Te=be.find(Ce=>Ce.tagName===ne);Te&&!T.has(Te)&&te(z,Te)&&De(z,Te)&&!Y(z,Te)&&(u(z,Te)?Yt(z,Te):(q(z,Te),A.add(z)))}}function Ae(){let W=new Map;for(let z of A)if(x(z)&&x(v.get(z))){let ne=n(z).hash;W.has(ne)||W.set(ne,[]),W.get(ne).push(z)}if(W.size)for(let z of D){if(T.has(z)||!x(z)||fe(z))continue;let ne=W.get(n(z).hash),Te=ne&&ne.find(Ce=>A.has(Ce)&&!Y(Ce,z)&&De(Ce,z)&&Xe(Ce,z)&&u(Ce,z)&&rn(Ce,z));Te&&(wt(Te),Yt(Te,z),xe(Te,z),N.add(Te))}let X=new Map,pe=new Map,be=new Map;for(let z of A){let ne=v.get(z);x(z)&&x(ne)&&be.set(ne,z)}let he=(z,ne)=>{if(!T.has(z))return!fe(z);let Te=be.get(z);return Te===T.get(z)&&Te!==ne&&!Te.contains(ne)},ee=z=>{if(T.has(z)){let ne=be.get(z);be.delete(z),wt(ne)}};for(let z of[...D,...be.keys()]){if(T.has(z)&&!be.has(z))continue;let ne=n(z).hash;if(X.has(ne)||X.set(ne,[]),X.get(ne).push(z),ae(z))continue;let Te=n(z).sig;pe.has(Te)||pe.set(Te,[]),pe.get(Te).push(z)}let te=new Set;for(let z of A){let ne=v.get(z);!x(z)||!x(ne)||ae(z)||n(z).hint===""||n(ne).hint===""||l(z,ne)||te.add(z)}for(let z of[...V,...te]){let ne=v.get(z);if(ne?!(A.has(z)&&te.has(z)):qe(z))continue;let Te=Je=>{ne&&wt(z),ee(Je)},Ce=X.get(n(z).hash);if(Ce){let Je=Ce.find(Ze=>Ze!==ne&&he(Ze,z)&&!Y(z,Ze)&&Xe(z,Ze)&&u(z,Ze)&&rn(z,Ze));if(Je){Te(Je),Yt(z,Je),xe(z,Je),N.add(z);continue}}if(ae(z)||k<=0)continue;let Pe=pe.get(n(z).sig);if(!Pe)continue;let ve=null,_e=0;for(let Je of Pe)if(!(Je===ne||!he(Je,z)||!De(z,Je)||!Xe(z,Je)||Y(z,Je))&&(k--<=0||l(z,Je)&&(_e++,ve=Je,_e>1)))break;_e>1&&I&&I.add(z),_e===1&&(Te(ve),q(z,ve),xe(z,ve),N.add(z),y.push([z,ve]))}}}function io(e,o){let t=new Map;for(let n of e){let s=o(n);s!=null&&t.set(s,(t.get(s)||0)+1)}return t}var mi={diff:0},_s=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,gi=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,bi=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,wi=/\P{M}\p{M}*/gu;function yi(e){if(e==="")return[];if(_s){let t=[];for(let n of _s.segment(e))t.push(n.segment);return t}let o=[];for(let t of e.match(bi))if(gi.test(t))for(let n of t.match(wi))o.push(n);else o.push(t);return o}var ki=/^[  ]+$/,xi=e=>ki.test(e)?" ".repeat(e.length):e,Gn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),kt="",fs=e=>e.every(o=>Gn(o)||o.k===kt),Ti=/^[\x00-\x7f\u00A0]*$/,vi=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Si(e){return e===""?[]:e.match(vi)}function an(e,o=!1){return(o?Si(e):yi(e)).map(t=>({k:xi(t),raw:t,len:t.length}))}var xn=(...e)=>e.every(o=>Ti.test(o));function us(e,o,t){let n=e.length,s=o.length,h=Math.min(n+s,t),l=h+1,r=new Int32Array(2*h+3),i=[],u=n===0&&s===0;for(let b=0;b<=h&&!u;b++){i.push(r.slice(l-b,l+b+1));for(let S=-b;S<=b;S+=2){let C;S===-b||S!==b&&r[l+S-1]<r[l+S+1]?C=r[l+S+1]:C=r[l+S-1]+1;let m=C-S,f=C;for(;C<n&&m<s&&e[C].k===o[m].k;)C++,m++;if(mi.diff+=1+C-f,r[l+S]=C,C>=n&&m>=s){u=!0;break}}}if(!u)return null;let w=[],c=n,p=s;for(let b=i.length-1;b>0;b--){let S=i[b],C=c-p,m=C+b,f=C===-b||C!==b&&S[m-1]<S[m+1]?C+1:C-1,g=S[f+b],I=g-f;for(;c>g&&p>I;)w.push([0,c-1,p-1]),c--,p--;c===g?(w.push([1,c,p-1]),p--):(w.push([-1,c-1,p]),c--)}for(;c>0&&p>0;)w.push([0,c-1,p-1]),c--,p--;return w.reverse(),w}function Ni(e,o,t){let n=c=>c.k===kt;if(!e.some(n)&&!o.some(n))return us(e,o,t);let s=[],h=[];for(let c=0;c<e.length;c++)n(e[c])||s.push(c);for(let c=0;c<o.length;c++)n(o[c])||h.push(c);let l=us(s.map(c=>e[c]),h.map(c=>o[c]),t);if(!l)return null;let r=[],i=0,u=0,w=(c,p)=>{for(;i<c&&u<p&&e[i].k===o[u].k;)r.push([0,i++,u++]);let b=us(e.slice(i,c),o.slice(u,p),t);if(!b)return!1;for(let[S,C,m]of b)r.push([S,C+i,m+u]);return i=c,u=p,!0};for(let[c,p,b]of l)if(c===0){if(!w(s[p],h[b]))return null;r.push([0,i,u]),i++,u++}return w(e.length,o.length)?r:null}function Wn(e,o,t=4e3){let n=[],s=0;for(;s<e.length&&s<o.length&&e[s].k===o[s].k;)e[s].raw!==o[s].raw&&n.push({bi:s,tok:o[s]}),s++;let h=0;for(;h<e.length-s&&h<o.length-s&&e[e.length-1-h].k===o[o.length-1-h].k;)e[e.length-1-h].raw!==o[o.length-1-h].raw&&n.push({bi:e.length-1-h,tok:o[o.length-1-h]}),h++;let l=e.slice(s,e.length-h),r=o.slice(s,o.length-h),i=Li(l,r)?null:Ni(l,r,t);if(!i){let f=l.length||r.length?[{bs:s,be:s+l.length,toks:r}]:[];return{hunks:f,cosmetic:n,coarse:!0,parts:f.map(g=>({...g,gap:[],group:0})),cosmeticEq:n}}let u=[],w=(f,g)=>{l[f].raw!==r[g].raw&&n.push({bi:s+f,tok:r[g]})},c=null,p=[],b=0,S=0,C=()=>{c&&u.push(c),c=null;for(let[f,g]of p)w(f,g);p=[],b++};for(let[f,g,I]of i){if(f===0){c&&Gn(l[g])&&!l[g].k.includes(`
2
2
  `)?p.push([g,I]):(C(),w(g,I)),S=g+1;continue}(!c||p.length)&&(c&&u.push(c),c={bs:s+S,be:s+S,toks:[],gap:p.map(([v,T])=>({bi:s+v,tok:r[T]})),group:b},p=[]),f===-1?(c.be=s+S+1,S=g+1):c.toks.push(r[I])}C(),Ai(u,e);let m=hs(u);return{hunks:m.hunks,cosmetic:n.concat(m.cosmetic),parts:u,cosmeticEq:n}}function Ai(e,o){for(let t=0;t<e.length;t++){let n=e[t];if(n.gap.length)continue;let s=t+1<e.length?e[t+1].bs:1/0;if(n.toks.length){if(n.bs===n.be)for(;n.bs+1<s&&n.bs<o.length&&n.toks[0].k===kt&&o[n.bs].k===kt;)n.toks=[...n.toks.slice(1),n.toks[0]],n.bs++,n.be++}else for(;n.be+1<s&&n.be<o.length&&o[n.bs].k===kt&&o[n.be].k===kt;)n.bs++,n.be++}}function hs(e,o=()=>!1){let t=[],n=[],s=null,h=-1;for(let l of e){let r=o(l);if(s&&!s.alone&&!r&&l.group===h){s.be=l.be;for(let i of l.gap)s.toks.push(i.tok);for(let i of l.toks)s.toks.push(i);continue}s&&t.push({bs:s.bs,be:s.be,toks:s.toks});for(let i of l.gap)n.push(i);s={bs:l.bs,be:l.be,toks:l.toks.slice(),alone:r},h=l.group}return s&&t.push({bs:s.bs,be:s.be,toks:s.toks}),{hunks:t,cosmetic:n}}var Mi=(e,o)=>e.bs===o.bs&&e.be===o.be&&gs(e.toks,o.toks);function ms(e,o,t){let n=w=>c=>w.some(p=>Mi(c,p)),s=hs(e.parts,n(o.parts)),h=hs(o.parts,n(e.parts)),l=e.cosmeticEq.concat(s.cosmetic),r=o.cosmeticEq.concat(h.cosmetic),[i,u]=t?Oi(s.hunks,h.hunks,t,l,r):[s.hunks,h.hunks];return{lh:i,rh:u,cosL:l,cosR:r}}function Oi(e,o,t,n,s){let h=(S,C)=>S.k===C.k&&S.raw===C.raw,l=[{list:e.map(S=>({...S})),resp:new Set(n.map(S=>S.bi)),raw:new Map(n.map(S=>[S.bi,S.tok]))},{list:o.map(S=>({...S})),resp:new Set(s.map(S=>S.bi)),raw:new Map(s.map(S=>[S.bi,S.tok]))}],r=S=>S.bs===S.be,i=(S,C,m,f)=>{let g=S.list[C];if(!r(g))return f(g)===m?g.toks:null;let I=C?S.list[C-1].be:0,v=C+1<S.list.length?S.list[C+1].bs:t.length;if(m<I||m>v)return null;let T=g.toks,A=g.bs;for(;A>m;){let E=T[T.length-1];if(!h(E,t[A-1])||S.resp.has(A-1))return null;T=[E,...T.slice(0,-1)],A--}for(;A<m;){if(!h(T[0],t[A])||S.resp.has(A))return null;T=[...T.slice(1),T[0]],A++}return T},u=(S,C,m,f,g,I)=>{let v=S.list[C],T=g?m.slice(m.length-f):m.slice(0,f),A=g?m.slice(0,m.length-f):m.slice(f),E={bs:I,be:I,toks:T};if(r(v)){if(!A.length){S.list[C]=E;return}let M={bs:I,be:I,toks:A};g&&(M.lead=!0),S.list.splice(C,1,...g?[M,E]:[E,M]);return}let N={bs:v.bs,be:v.be,toks:A};S.list.splice(C,1,...g?[N,E]:[E,N])},w=(S,C,m,f,g)=>{let I=S.list[C],v=g?m.slice(m.length-f):m.slice(0,f),T=g?m.slice(0,m.length-f):m.slice(f),A={bs:I.bs,be:I.be,toks:v};if(!T.length){S.list[C]=A;return}let E=g?{bs:I.bs,be:I.bs,toks:T,lead:!0}:{bs:I.be,be:I.be,toks:T};S.list.splice(C,1,...g?[E,A]:[A,E])},c=(S,C,m,f)=>{let g=S.list[C],I=m.list[f],v=g.be,T=I.bs;if(v>=T||C+1<S.list.length&&S.list[C+1].bs<=I.be||f>0&&m.list[f-1].be>=g.bs)return!1;for(let H=v;H<T;H++)if(!Gn(t[H])||t[H].k.includes(`
3
- `))return!1;let A=H=>t.slice(v,T).map((q,Me)=>H.raw.get(v+Me)||q),E=[...g.toks,...A(S)],N=[...A(m),...I.toks],M=(H,q,Me)=>q>=0&&q+Me.length<=H.length&&Me.every((Oe,Re)=>H[q+Re].k===Oe.k),R=(H,q,Me)=>fs(H)&&t.slice(q,Me).some(Oe=>!Gn(Oe)),V=H=>H.some(q=>!Gn(q)),D,j,y,k;if(r(g)&&V(g.toks)&&M(N,0,g.toks)){let H=N.slice(g.toks.length);R(H,v,I.be)||(D=v,j=g.toks,y=N.slice(0,g.toks.length),k=[null,{bs:v,be:I.be,toks:H}])}if(D===void 0&&r(I)&&V(I.toks)){let H=E.length-I.toks.length,q=E.slice(0,H);M(E,H,I.toks)&&!R(q,g.bs,T)&&(D=T,j=E.slice(H),y=I.toks,k=[{bs:g.bs,be:T,toks:q},null])}if(D===void 0)return!1;let J=H=>H&&(H.bs<H.be||H.toks.length);return S.list.splice(C,1,...[k[0],{bs:D,be:D,toks:j}].filter(J)),m.list.splice(f,1,...[{bs:D,be:D,toks:y},k[1]].filter(J)),!0},p=l[0],b=l[1];for(let S=0;S<64;S++){let C=!1;e:for(let m=0;m<p.list.length;m++)for(let f=0;f<b.list.length;f++){let g=p.list[m],I=b.list[f];if(!(g.bs===I.bs&&g.be===I.be&&gs(g.toks,I.toks))){for(let v of[!0,!1]){let T=E=>v?E.be:E.bs,A=r(g)?[T(I),g.bs]:[T(g)];for(let E of A){let N=i(p,m,E,T),M=N&&i(b,f,E,T);if(!M)continue;let R=(k,J)=>v?k[k.length-1-J]:k[J],V=0;for(;V<N.length&&V<M.length&&R(N,V).k===R(M,V).k;)V++;if(!V)continue;let D=v?N.slice(0,N.length-V):N.slice(V),j=v?M.slice(0,M.length-V):M.slice(V);if(!(V<N.length&&V<M.length&&!fs(D)&&!fs(j)&&(r(g)&&r(I)||g.bs===I.bs&&g.be===I.be)||!(v?N.slice(N.length-V):N.slice(0,V)).some(k=>!Gn(k)))){if(V===N.length&&V===M.length&&r(g)&&r(I)){if(g.bs===E&&I.bs===E)continue;p.list[m]={bs:E,be:E,toks:N},b.list[f]={bs:E,be:E,toks:M}}else!r(g)&&g.bs===I.bs&&g.be===I.be?(w(p,m,N,V,v),w(b,f,M,V,v)):(u(p,m,N,V,v,E),u(b,f,M,V,v,E));C=!0;break e}}}if(c(p,m,b,f)||c(b,f,p,m)){C=!0;break e}}}if(!C)break}return[p.list,b.list]}var Ii=48,Ci=.3;function Li(e,o){let t=e.filter(l=>!Gn(l)),n=o.filter(l=>!Gn(l));if(Math.min(t.length,n.length)<Ii)return!1;let s=new Map;for(let l of t)s.set(l.k,(s.get(l.k)||0)+1);let h=0;for(let l of n){let r=s.get(l.k);r>0&&(h++,s.set(l.k,r-1))}return h/Math.min(t.length,n.length)<Ci}var Ei=(e,o)=>{let t=new Set;for(let n of e.toks)typeof n.k!="string"&&t.add(n.k.el);for(let n=e.bs;n<e.be;n++)typeof o[n].k!="string"&&t.add(o[n].k.el);return t},gs=(e,o)=>e.length===o.length&&e.every((t,n)=>t.k===o[n].k);function zs(e,o,t,n="remote"){let s=Wn(e,o),h=Wn(e,t),{lh:l,rh:r,cosL:i,cosR:u}=ms(s,h,e),w=x=>x.bs===x.be,c=x=>x.toks.some(Y=>typeof Y.k=="string"),p=x=>w(x)&&!c(x),b=(x,Y)=>Y.bs<x.be&&x.bs<Y.be,S=(x,Y)=>!b(x,Y)&&Y.bs<=x.be&&x.bs<=Y.be&&(w(x)&&c(x)||w(Y)&&c(Y))&&!(w(x)&&w(Y)),C=(x,Y)=>x.bs===Y.bs&&x.be===Y.be&&gs(x.toks,Y.toks),m=[],f=new Set;for(let x of l){let Y=r.find(ae=>!f.has(ae)&&C(x,ae));Y?(f.add(Y),m.push({bs:x.bs,be:x.be,side:"both",l:x,r:Y,toks:x.toks})):m.push({bs:x.bs,be:x.be,side:"L",l:x,toks:x.toks,lead:!!x.lead})}for(let x of r)f.has(x)||m.push({bs:x.bs,be:x.be,side:"R",r:x,toks:x.toks,lead:!!x.lead});m.sort((x,Y)=>x.bs-Y.bs||x.be-Y.be||Y.lead-x.lead);let g=0,I=0;for(let x of m)x.side==="both"&&(g+=x.toks.length-(x.be-x.bs));let v=m.map((x,Y)=>Y),T=x=>v[x]===x?x:v[x]=T(v[x]),A=(x,Y)=>(x=T(x),Y=T(Y),x===Y?!1:(v[x]=Y,!0)),E=m.map(x=>Ei({bs:x.bs,be:x.be,toks:x.toks},e)),N={L:new Map,R:new Map};m.forEach((x,Y)=>{let ae=x.side==="both"?["L","R"]:[x.side];for(let oe of ae)for(let Ee of E[Y])N[oe].has(Ee)||N[oe].set(Ee,[]),N[oe].get(Ee).push(Y)});for(let x of[N.L,N.R])for(let Y of x.values())for(let ae=1;ae<Y.length;ae++)A(Y[0],Y[ae]);for(let x=0;x<m.length;x++)for(let Y=x+1;Y<m.length;Y++){let ae=m[x],oe=m[Y];ae.side===oe.side&&ae.side!=="both"||ae.bs>oe.be||(b(ae,oe)||S(ae,oe)?A(x,Y):ae.bs===oe.bs&&w(ae)&&w(oe)&&I++)}let M=(x,Y)=>{let ae=x==="L"?l:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="close"&&Ee.k.el===Y.el))return oe.bs;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return-1};m.forEach((x,Y)=>{if(!(!p(x)||x.side==="both"))for(let ae of x.toks){if(ae.kind!=="open")continue;let oe=M(x.side,ae.k);if(oe<=x.bs)continue;let Ee=new Uint8Array(oe-x.bs),De=[];if(m.forEach((Ne,nt)=>{if(!(Ne.side===x.side||w(Ne))&&Ne.bs<oe&&Ne.be>x.bs){De.push(nt);for(let Xe=Math.max(Ne.bs,x.bs);Xe<Math.min(Ne.be,oe);Xe++)Ee[Xe-x.bs]=1}}),De.length&&Ee.every(Ne=>Ne===1))for(let Ne of De)A(Y,Ne)}});let R=!0;for(;R;){R=!1;let x=new Map;m.forEach((Y,ae)=>{let oe=T(ae),Ee=x.get(oe)||{bs:Y.bs,be:Y.be,L:!1,R:!1};Ee.bs=Math.min(Ee.bs,Y.bs),Ee.be=Math.max(Ee.be,Y.be),Y.side!=="R"&&(Ee.L=!0),Y.side!=="L"&&(Ee.R=!0),x.set(oe,Ee)}),m.forEach((Y,ae)=>{for(let[oe,Ee]of x){if(T(ae)===T(oe)||!(Ee.L&&Ee.R))continue;let De=Y.bs<Ee.be&&Y.be>Ee.bs,Ne=w(Y)&&c(Y)&&(Y.bs===Ee.be||Y.bs===Ee.bs);(De||Ne)&&A(ae,oe)&&(R=!0)}})}let V=new Map;m.forEach((x,Y)=>{let ae=T(Y);V.has(ae)||V.set(ae,[]),V.get(ae).push(x)});let D=[];for(let x of V.values()){let Y=x.some(oe=>oe.side==="L"),ae=x.some(oe=>oe.side==="R");if(Y&&ae){let oe=Math.min(...x.map(nt=>nt.bs)),Ee=Math.max(...x.map(nt=>nt.be)),De=x.filter(nt=>nt.side!=="R").map(nt=>nt.l).sort((nt,Xe)=>nt.bs-Xe.bs),Ne=x.filter(nt=>nt.side!=="L").map(nt=>nt.r).sort((nt,Xe)=>nt.bs-Xe.bs);D.push({bs:oe,be:Ee,kind:"conflict",localHunks:De,remoteHunks:Ne})}else for(let oe of x)D.push({bs:oe.bs,be:oe.be,kind:oe.side,u:oe})}let j=(x,Y)=>{let ae=x==="L"?l:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="close"&&Ee.k.el===Y.el))return oe.bs+.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return 1/0},y=(x,Y)=>{let ae=x==="L"?l:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="open"&&Ee.k.el===Y.el))return oe.bs-.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="open"&&e[oe].k.el===Y.el)return oe;return-1/0},k=x=>x.kind==="R"?"R":"L",J=x=>x.kind==="R"?1:0;D.sort((x,Y)=>{if(x.bs!==Y.bs)return x.bs-Y.bs;let ae=x.bs===x.be,oe=Y.bs===Y.be;if(ae!==oe)return ae?-1:1;if(ae&&oe&&x.kind!=="conflict"&&Y.kind!=="conflict"){let De=x.u.toks,Ne=Y.u.toks,nt=ht=>ht.length&&ht.every(Ge=>Ge.kind==="open"),Xe=ht=>ht.length&&ht.every(Ge=>Ge.kind==="close");if(nt(De)&&nt(Ne)){let ht=Math.max(...De.map(rt=>j(k(x),rt.k))),Ge=Math.max(...Ne.map(rt=>j(k(Y),rt.k)));if(ht!==Ge)return Ge-ht}if(Xe(De)&&Xe(Ne)){let ht=Math.min(...De.map(rt=>y(k(x),rt.k))),Ge=Math.min(...Ne.map(rt=>y(k(Y),rt.k)));return ht!==Ge?Ge-ht:J(Y)-J(x)}}let Ee=De=>De.u&&De.u.lead?1:0;return Ee(Y)-Ee(x)||J(x)-J(Y)||x.be-Y.be});let H=[],q=[],Me=0,Oe=x=>{x>Me&&(H.push({bs:Me,be:x,toks:e.slice(Me,x),source:"base"}),Me=x)};for(let x of D){if(Oe(x.bs),x.kind==="conflict"){let Y=ps(e,x.localHunks,x.bs,x.be),ae=ps(e,x.remoteHunks,x.bs,x.be),oe=n==="local"?Y:n==="both"?Y.concat(ae):ae,Ee=(nt,Xe)=>{let ht=0;for(let Ge of nt)Ge.be<=x.bs&&!Xe.includes(Ge)&&(ht+=Ge.toks.length-(Ge.be-Ge.bs));return ht},De=x.bs+Ee(l,x.localHunks),Ne=x.bs+Ee(r,x.remoteHunks);q.push({bs:x.bs,be:x.be,ls:De,le:De+Y.length,rs:Ne,re:Ne+ae.length,ms:0,me:0,base:e.slice(x.bs,x.be),local:Y,remote:ae,resolved:oe}),H.push({bs:x.bs,be:x.be,toks:oe,source:"conflict",localHunks:x.localHunks,localToks:Y,keepsLocal:n!=="remote"})}else H.push({bs:x.bs,be:x.be,toks:x.u.toks,source:x.kind==="R"?"remote":"local",localHunks:x.kind==="R"?[]:[x.u.l]});Me=Math.max(Me,x.be)}Oe(e.length);let Re=0,ie=0;for(let x of H)x.source==="conflict"&&(q[ie].ms=Re,q[ie].me=Re+x.toks.length,ie++),Re+=x.toks.length;let xe=new Map(i.map(x=>[x.bi,x.tok])),qe=new Map(u.map(x=>[x.bi,x.tok])),fe=[];for(let x of H){x.source==="base"&&(x.toks=x.toks.map((Y,ae)=>{let oe=x.bs+ae,Ee=xe.get(oe),De=qe.get(oe),Ne=Ee&&De?n==="remote"?De:Ee:Ee||De||Y;return Ne===Y?Y:{...Ne,cosmetic:!0}}));for(let Y of x.toks)fe.push({...Y,src:x.source})}return{tokens:fe,segments:H,conflicts:q,localHunks:l,remoteHunks:r,collapsedDelta:g,samePoint:I,mapLocalOffset:Ri(e,l,H)}}function ps(e,o,t,n){let s=[],h=t;for(let l of o)s=s.concat(e.slice(h,l.bs),l.toks),h=l.be;return s.concat(e.slice(h,n))}var ds=e=>e.reduce((o,t)=>o+t.len,0);function Ri(e,o,t){let n=new Int32Array(e.length+1);for(let l=0;l<e.length;l++)n[l+1]=n[l]+e[l].len;let s=o.map(l=>({bs:n[l.bs],be:n[l.be],text:l.toks.map(r=>r.raw).join(""),ref:l})),h=t.map(l=>({bs:n[l.bs],be:n[l.be],len:ds(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?ds(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let r=null,i=null,u=0,w=0,c=0;for(let b of s){let S=b.bs-c;if(l<=w+S){r=c+(l-w);break}if(w+=S,c=b.bs,l<=w+b.text.length){i=b,u=l-w,r=b.bs;break}w+=b.text.length,c=b.be}r===null&&(r=c+(l-w));let p=0;for(let b of h){if(!i&&r<=b.bs)return p;if(!(i?b.localHunks.includes(i.ref):r<b.be)){p+=b.len;continue}if(b.source==="base")return p+(r-b.bs);if(b.source==="remote")return p+b.len;if(b.source==="local")return p+Math.min(u,b.len);if(!b.keepsLocal||!i)return p+b.len;let C=b.localHunks.indexOf(i.ref),m=ds(ps(e,b.localHunks.slice(0,C),b.ref.bs,i.ref.bs));return p+Math.min(m+u,b.localLen)}return p}}function lo(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:f=>Math.min(f,o.length),granularity:"word"};let s=xn(e,o,t),h=an(e,s),l=an(o,s),r=an(t,s),i=h.length<=2e4&&l.length<=2e4&&r.length<=2e4?zs(h,l,r,n):null,u="word",w=h;if(!i){let f=g=>g.split(/(?<=\n)/).map(I=>({k:I,raw:I,len:I.length}));w=f(e),i=zs(w,f(o),f(t),n),u="line"}let c=f=>f.map(g=>g.raw).join(""),p=f=>{let g=[0];for(let I of f)g.push(g[g.length-1]+I.len);return g},b=p(w),S=null,C=null,m=null;if(i.conflicts.length){let f=g=>g.split(/(?<=\n)/).map(I=>({k:I,raw:I,len:I.length}));S=p(u==="line"?f(o):l),C=p(u==="line"?f(t):r),m=p(i.tokens)}return{text:c(i.tokens),conflicts:i.conflicts.map(f=>({bs:b[f.bs],be:b[f.be],ls:S[f.ls],le:S[f.le],rs:C[f.rs],re:C[f.re],ms:m[f.ms],me:m[f.me],base:c(f.base),local:c(f.local),remote:c(f.remote),resolved:c(f.resolved)})),mapLocalOffset:i.mapLocalOffset,granularity:u}}function Yn(e,o,t=4e3){if(e===o)return[];let n=xn(e,o),s=an(e,n),h=an(o,n),l=Wn(s,h,t),r=[0];for(let i of s)r.push(r[r.length-1]+i.len);return l.hunks.map(i=>({bs:r[i.bs],be:r[i.be],text:i.toks.map(u=>u.raw).join("")}))}function $t(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Dn({base:e,side:o,retained:t,transfers:n,baseAtomKey:s=r=>r.el,sideAtomKey:h=r=>r.el,budget:l=$t()}){let r=[],i=T=>({status:"fallback",reason:T}),u=T=>T>l.remaining?!1:(l.remaining-=T,!0);if(!u((t.length+n.length)*3))return i("work-limit");for(let[T,A]of[["retained",t],["transfer",n]])for(let E of A){let{from:N,to:M,target:R}=E;if(!Number.isInteger(N)||!Number.isInteger(M)||!Number.isInteger(R)||N<0||M<=N||M>e.text.length||R<0||R+M-N>o.text.length)return i("invalid-range");r.push({...E,kind:T})}let w=Symbol(),c=T=>(A,E)=>{if(!u(1))throw w;return l.sortComparisons++,T(A,E)},p,b;try{p=r.slice().sort(c((T,A)=>T.from-A.from||T.to-A.to)),b=r.slice().sort(c((T,A)=>T.target-A.target||T.to-T.from-(A.to-A.from)))}catch(T){if(T===w)return i("work-limit");throw T}if(!u(r.length*2))return i("work-limit");for(let T=1;T<p.length;T++)if(p[T].from<p[T-1].to)return i("source-overlap");for(let T=1;T<b.length;T++)if(b[T].target<b[T-1].target+b[T-1].to-b[T-1].from)return i("target-overlap");for(let T of p){let A=T.to-T.from;if(!u(A))return i("work-limit");for(let E=0;E<A;E++){let N=T.from+E,M=T.target+E;if(l.comparisons++,e.text[N]!==o.text[M])return i("unequal-occurrence");let R=e.atomAt.get(N),V=o.atomAt.get(M);if(!!R!=!!V||R&&s(R)!==h(V))return i("different-atom")}}let S=e.text.length+o.text.length+2,C=r.reduce((T,A)=>T+(A.to-A.from)*2,2);if(!u(S+C+r.length))return i("work-limit");let m=new Int32Array(e.text.length+1).fill(-1),f=new Int32Array(o.text.length+1).fill(-1);l.mapCells+=S,l.mapWrites+=C;let g=-1,I=!0;for(let T of p){T.target<g&&(I=!1),g=T.target+T.to-T.from;for(let A=0;A<T.to-T.from;A++)m[T.from+A]=T.target+A,f[T.target+A]=T.from+A}return m[e.text.length]=o.text.length,f[o.text.length]=e.text.length,{status:"ready",runs:p,bTo:m,toB:f,monotone:I,covers:(T,A)=>{if(!u(A-T))return null;l.coverageChecks+=A-T;for(let E=T;E<A;E++)if(e.text[E]!==kt&&!/\s/.test(e.text[E])&&m[E]<0)return!1;return!0}}}function bs({base:e,side:o,baseOf:t=()=>null,budget:n=$t()}){if(e.text===o.text||!e.text.includes(kt)&&!o.text.includes(kt))return{status:"none"};let s=(e.text.length+o.text.length)*8;if(s>n.remaining)return{status:"fallback",reason:"work-limit"};n.remaining-=s,n.boundarySteps=(n.boundarySteps||0)+s;let h=(S,C)=>C<S.length&&(S[C]===kt||/\s/.test(S[C])),l=new Map,r=Symbol(),i=(S,C)=>{let m=S.stackAt[C]||[];if(!l.has(m)){if(m.length>n.remaining)throw r;n.remaining-=m.length,n.boundarySteps+=m.length,l.set(m,m.find(f=>f.block)?.el||null)}return l.get(m)},u=[],w=(S,C)=>{let m=i(e,S),f=i(o,C),g=m&&f&&t(f)!==m?"transfer":"retained",I=u[u.length-1];I&&I.to===S&&I.target+I.to-I.from===C&&I.kind===g&&I.destination===f?I.to++:u.push({from:S,to:S+1,target:C,destination:f,kind:g})},c=0,p=0,b=!1;try{for(;c<e.text.length||p<o.text.length;){if(c<e.text.length&&p<o.text.length&&e.text[c]===o.text[p]){let I=e.atomAt.get(c),v=o.atomAt.get(p);if(!!I!=!!v||I&&t(v.el)!==I.el)return{status:"none"};w(c++,p++);continue}if(!h(e.text,c)&&!h(o.text,p))return{status:"none"};let S=c,C=p;for(;h(e.text,c);)c++;for(;h(o.text,p);)p++;let m=e.text.slice(S,c),f=o.text.slice(C,p);(m.includes(kt)||f.includes(kt))&&(b=!0);let g=0;for(;g<c-S&&g<p-C&&e.text[c-g-1]===o.text[p-g-1];)g++;for(let I=g;I>0;I--)w(c-I,p-I)}}catch(S){if(S===r)return{status:"fallback",reason:"work-limit"};throw S}return b?Dn({base:e,side:o,retained:u.filter(S=>S.kind==="retained"),transfers:u.filter(S=>S.kind==="transfer"),sideAtomKey:S=>t(S.el)||S.el,budget:n}):{status:"none"}}var $s=/\s/,Vo=/\S/;function In(e,o,t,n,s,h,l=-1,r=-1){if(!e.length)return-1;s(n,e.length);let i=new Int32Array(e.length),u=0;for(let b=1;b<e.length;b++){for(s(n,1);u&&(s(n,1),e[u]!==e[b]);)u=i[u-1];s(n,1),e[u]===e[b]&&u++,i[b]=u}let w=-1,c=0,p=0;u=0;for(let b=0;b<o.length;b++){for(s(n,1);u&&(s(n,1),e[u]!==o[b]);)u=i[u-1];if(s(n,1),e[u]===o[b]&&u++,u!==e.length)continue;let S=b+1-e.length,C=b+1;for(u=i[u-1];c<t.length&&t[c].from<S;)s(n,1),c++;for(;p<t.length&&t[p].to<C;)s(n,1),p++;if(s(n,6),!(c===t.length||p===t.length||t[c].from!==S||t[p].to!==C||l>=0&&S<r&&C>l)){if(!h)return S;if(w>=0)return-1;w=S}}return w}function No(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function ws(e,o,t,n){let s=null;for(let l of o)if(n(t,1),!(l.source!==e.source||l.side!==e.side))for(let r of l.runs){if(n(t,1),r.source!==e.source)continue;let i=Math.max(e.from,r.from),u=Math.min(e.to,r.to);i>=u||(s||(n(t,e.to-e.from),s=new Uint8Array(e.to-e.from)),n(t,u-i),s.fill(1,i-e.from,u-e.from))}if(!s)return!1;n(t,e.to-e.from);let h=!1;for(let l=e.from;l<e.to;l++)if(Vo.test(e.flat.text[l])){if(!s[l-e.from])return!1;h=!0}return h}function ys({source:e,side:o,views:t,eligible:n,blocked:s,baseId:h,model:l,tokensOf:r,budget:i,charge:u}){let{V:w,A:c,idOf:p}=t[o],b=t[1-o];if(e.nodeType!==1||c.identical.has(e)||b.A.identical.has(e)||s.has(e)||!n(e))return null;let S=w.twin(e),C=b.V.twin(e);if(!S||!C||c.map.get(e)!==S||c.reverse.get(S)!==e||b.A.map.get(e)!==C||b.A.reverse.get(C)!==e||!w.here(S)||!b.V.here(C)||!n(S)||!n(C))return null;let m=h(e);if(m!==p(S)||m!==b.idOf(C))return null;let f=l(e,null,i),g=l(S,c,i),I=l(C,b.A,i);if(!No(f)||!No(g)||!No(I))return null;let v=f.flat.text,T=g.flat.text;if(u(i,v.length+T.length*3),!Vo.test(T)||T.length>=v.length)return null;let A=v.startsWith(T),E=v.endsWith(T);if(A===E)return null;let N=A?T.length:0,M=A?v.length:v.length-T.length,R=N,V=M;for(;R<V&&(u(i,1),!!$s.test(v[R]));)R++;for(;V>R&&(u(i,1),!!$s.test(v[V-1]));)V--;if(R===V)return null;let D=r(f,i),j=!1,y=!1;for(let k of D)u(i,1),k.from===R&&(j=!0),k.to===V&&(y=!0);return!j||!y?null:{source:e,side:o,flat:f.flat,from:N,to:M}}function Gs({base:e,views:o,side:t,attempt:n,eligible:s,blocked:h,baseId:l,model:r,tokensOf:i,certificates:u,charge:w,exhausted:c,limit:p}){if(p<=0)return null;let b=$t(p),{V:S,A:C,idOf:m}=o[t],f=o[1-t],[g,I,v,T]=n,A=null;try{for(let E=g;E<=I;E++){w(b,1);let N=e[E];if(N.nodeType!==1||C.identical.has(N)||f.A.identical.has(N)||h.has(N)||!s(N))continue;let M=ys({source:N,side:t,views:o,eligible:s,blocked:h,baseId:l,model:r,tokensOf:i,budget:b,charge:w});if(!M||ws(M,u,b,w))continue;let{flat:R,from:V,to:D}=M;w(b,(D-V)*2);let j=R.text.slice(V,D).trim();for(let y=v;y<=T;y++){w(b,1);let k=S.units[y],J=S.baseOf(k);if(!J||J===N||J.nodeType!==1||k.nodeType!==1||J.parentNode!==N.parentNode||k.parentNode!==C.map.get(N).parentNode||C.map.get(J)!==k||C.reverse.get(k)!==J||h.has(J)||!s(J)||!s(k)||l(J)!==m(k))continue;let H=r(J,null,b),q=r(k,C,b);if(!No(H)||!No(q))continue;let Me=H.flat.text,Oe=q.flat.text;if(w(b,Me.length),!Vo.test(Me)||Oe.length<=Me.length)continue;let Re=i(q,b),ie=In(Me,Oe,Re,b,w,!0);if(!(ie<0)&&!(In(j,Oe,Re,b,w,!1,ie,ie+Me.length)<0)){(A||=[]).push(M);break}}}}catch(E){if(E!==c)throw E}return A}function Ys(e,o,t,n,s,h,l){if(h==="both"||t.atoms.length||n.atoms.length||s.atoms.length)return h;let r=h==="remote";if(r?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 h;for(let i of e){if(i.source!==o||i.side!==(r?1:0)||i.flat.text!==t.text||i.flat.nodes.length!==t.nodes.length||l.be<=i.from||l.bs>=i.to)continue;let u=!0;for(let c=0;c<t.nodes.length;c++){let p=i.flat.nodes[c],b=t.nodes[c];if(p.node!==b.node||p.s!==b.s||p.e!==b.e){u=!1;break}}if(!u)continue;let w=!1;for(let c=l.bs;c<l.be;c++)if(Vo.test(t.text[c])){if(c<i.from||c>=i.to){u=!1;break}w=!0}if(u&&w)return r?"local":"remote"}return h}var Un="\uFFFC";var Pi={caret:0},Tn=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(" ")),or=new Set(["BR","WBR","IMG"]),ks=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function Vn(e,o={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(o.ignored&&o.ignored(e)||or.has(e.tagName))return!0;if(!Tn.has(e.tagName))return!ks.has(e.tagName);if(o.remoteWins&&o.remoteWins(e))return!1;let t=o.inlineCache&&o.inlineCache.get(e);if(t!==void 0)return t;let n=!0;for(let s of e.childNodes)if(!Vn(s,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Bi(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function nn(e,o={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},n=(s,h)=>{for(let l of s){if(l.nodeType===3){let c=l.nodeValue;if(!c)continue;t.nodes.push({node:l,s:t.text.length,e:t.text.length+c.length}),t.text+=c;for(let p=0;p<c.length;p++)t.stackAt.push(h);continue}if(l.nodeType!==1)continue;if(o.ignored&&o.ignored(l)){t.pins.push({el:l,i:t.text.length});continue}if(o.skip&&o.skip.has(l))continue;let r=o.via&&o.via(l)||l;r!==l&&(t.via||(t.via=new Map)).set(r,l);let i=l.tagName;if(o.blocks&&o.blocks.has(l)){t.text.length&&t.text[t.text.length-1]!==kt&&(t.stackAt.push(h),t.text+=kt);let c={el:l,tag:i,from:t.text.length,to:-1,depth:h.length,block:!0};t.marks.push(c);let p=h.concat([c]);n(r.childNodes,p),t.stackAt.push(p),t.text+=kt,c.to=t.text.length;continue}let u=Tn.has(i)&&Bi(r);if(or.has(i)||!Tn.has(i)||o.remoteWins&&o.remoteWins(l)||o.atomize&&o.atomize(l)||u){t.atoms.push({i:t.text.length,el:l,key:u?i+":empty":i,stack:h}),t.stackAt.push(h),t.text+=Un;continue}let w={el:l,tag:i,from:t.text.length,to:-1,depth:h.length};t.marks.push(w),n(r.childNodes,h.concat([w])),w.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&qo(t).trim()===""){let s=t.atoms[0];t.placeholder=s.el,t.text=t.text.slice(0,s.i)+t.text.slice(s.i+1),t.stackAt.splice(s.i,1);for(let h of t.nodes)h.s>s.i&&(h.s--,h.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(s=>[s.i,s])),t}function ji(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Di(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,"&quot;")}"`;return o+">"}function co(e,o,t){let n="",s=[];for(let h=o;h<t;h++){let l=e.stackAt[h],r=0;for(;r<s.length&&r<l.length&&s[r]===l[r];)r++;for(;s.length>r;)n+=`</${s.pop().tag.toLowerCase()}>`;for(;s.length<l.length;){let u=l[s.length];n+=Di(u.el),s.push(u)}let i=e.atomAt.get(h);n+=i?i.el.outerHTML:e.text[h]===kt?"":ji(e.text[h])}for(;s.length;)n+=`</${s.pop().tag.toLowerCase()}>`;return n}function Ui(e,o){let t=[...e.el.attributes].filter(n=>!o(e.el,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tag+"|"+t}function sr(e,o){let t=[...e.attributes].filter(n=>!o(e,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function Xs(e,o=()=>!1){let t=new Map,n=h=>{let l=t.get(h);return l===void 0&&(l="{"+h.map(r=>Ui(r,o)).sort().join(",")+"}",t.set(h,l)),l},s="";for(let h=0;h<e.text.length;h++){let l=e.atomAt.get(h);s+=(l?"["+sr(l.el,o)+"]":e.text[h])+n(e.stackAt[h])}return e.text.length===0&&e.placeholder&&(s+="[br]"),s}function ao(e,o,t,n=s=>s.key){let s=[],h=e.text,l=0,r=i=>{if(i<=l)return;let u=h.slice(l,i);if(t)for(let w of u.split(/(?<=\n)/))s.push({k:w,raw:w,len:w.length});else for(let w of an(u,o))s.push(w)};for(let i of e.atoms)r(i.i),s.push({k:"\0"+n(i),raw:Un,len:1,atom:!0}),l=i.i+1;return r(h.length),s}function qo(e){if(!e.atoms.length)return e.text;let o="",t=0;for(let n of e.atoms)o+=e.text.slice(t,n.i),t=n.i+1;return o+e.text.slice(t)}var fo=e=>{let o=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)o[t+1]=o[t]+e[t].len;return o};function Ho(e,o,t,n){let s=fo(o),h=fo(t),l=[],r=0,i=0;for(let w of n.hunks){i+=w.bs-r;let c=i+w.toks.length;l.push({bs:s[w.bs],be:s[w.be],ss:h[i],se:h[c],text:e.text.slice(h[i],h[c]),toks:w.toks,lead:!!w.lead}),i=c,r=w.be}let u=new Map;for(let w of n.cosmetic)u.set(w.bi,w.tok.raw);return{hunks:l,respell:u}}function Js(e,o,t){let n=l=>l===kt||/\s/.test(l),s=l=>l.replace(/[\u001E\s]/g,""),h=[];for(let l of e){let r=o.slice(l.bs,l.be),i=t.slice(l.ss,l.se);if(!r.includes(kt)&&!i.includes(kt)||r.includes(Un)||i.includes(Un)||s(r)!==s(i)){h.push(l);continue}let u=0,w=0;for(;;){let c=u,p=w;for(;c<r.length&&n(r[c]);)c++;for(;p<i.length&&n(i[p]);)p++;let b=u,S=w;for(;b<c&&S<p&&r[b]===i[S];)b++,S++;let C=c,m=p;for(;C>b&&m>S&&r[C-1]===i[m-1];)C--,m--;if(C>b||m>S){let f=i.slice(S,m);h.push({bs:l.bs+b,be:l.bs+C,ss:l.ss+S,se:l.ss+m,text:f,toks:[...f].map(g=>({k:g,raw:g,len:1})),lead:l.lead})}if(c>=r.length)break;u=c+1,w=p+1}}return h}function Qs(e,o,t){let n=new Int32Array(o+1).fill(-1),s=new Int32Array(t+1).fill(-1),h=0,l=0,r=i=>{for(;h<i;)n[h]=l,s[l]=h,h++,l++};for(let i of e)r(i.bs),h=i.be,l=i.se;return r(o),n[o]=l,s[l]=o,{bTo:n,toB:s}}function Zs(e,o,t){let n=[],s=0,h=0,l=(r,i)=>{if(s===r&&h===i)return;let u=o.text.slice(h,i);n.push({bs:s,be:r,ss:h,se:i,text:u,toks:an(u,xn(u)),lead:!1})};for(let r of t.runs)l(r.from,r.target),s=r.to,h=r.target+r.to-r.from;return l(e.text.length,o.text.length),{hunks:n,respell:new Map}}function er(e,o,t,n){let s=fo(o),h=fo(t),l=(i,u)=>{let w=0,c=i.length;for(;w<c;){let p=w+c>>>1;i[p]<u?w=p+1:c=p}return i[w]===u?w:-1};for(let i of e.hunks)if(l(s,i.bs)<0||l(s,i.be)<0)return null;if(e.hunks.some(i=>l(h,i.ss)<0||l(h,i.se)<0)){if(!n)return null;let i=[];for(let p of e.hunks)i.push(p.ss,p.se);let u=[],w=0,c=0;for(let p of t){let b=c+p.len;for(;w<i.length&&i[w]<=c;)w++;let S=c;for(;w<i.length&&i[w]<b;){let C=i[w++];if(C>S){let m=p.raw.slice(S-c,C-c);u.push(...an(m,xn(m))),S=C}}if(S===c)u.push(p);else{let C=p.raw.slice(S-c);u.push(...an(C,xn(C)))}c=b}t=u,h=fo(t)}let r=[];for(let i of e.hunks){let u=l(s,i.bs),w=l(s,i.be),c=l(h,i.ss),p=l(h,i.se);if(u<0||w<0||c<0||p<0)return null;r.push({bs:u,be:w,toks:t.slice(c,p),gap:[],group:r.length})}return{parts:r,cosmeticEq:[],tokens:t}}function xs(e,o,t,n={},s=null){return rr(e,o,t,n.base,n.local,n.remote,s,{})}function rr(e,o,t,n,s,h,l,r){let i=xn(qo(e),qo(o),qo(t)),u=ao(e,i,!1,n),w=ao(o,i,!1,s),c=ao(t,i,!1,h),p=u.length>2e4||w.length>2e4||c.length>2e4;p&&(u=ao(e,i,!0,n),w=ao(o,i,!0,s),c=ao(t,i,!0,h));let b=l?.local?Zs(e,o,l.local):null,S=l?.remote?Zs(e,t,l.remote):null,C=b?er(b,u,w,!p):Wn(u,w),m=S?er(S,u,c,!p):Wn(u,c);b&&C&&(w=C.tokens),S&&m&&(c=m.tokens);let f,g;if(C&&m){let I=ms(C,m,u);f=Ho(o,u,w,{hunks:I.lh,cosmetic:I.cosL}),g=Ho(t,u,c,{hunks:I.rh,cosmetic:I.cosR})}else f=b||Ho(o,u,w,C),g=S||Ho(t,u,c,m);return f.hunks=Js(f.hunks,e.text,o.text),g.hunks=Js(g.hunks,e.text,t.text),r.base=e,r.local=o,r.remote=t,r.lines=p,r.baseTokens=u,r.localEdits=f,r.remoteEdits=g,r.localMap=Qs(f.hunks,e.text.length,o.text.length),r.remoteMap=Qs(g.hunks,e.text.length,t.text.length),r.full=null,r}function tr(e,o){if(e.size!==o.size)return!1;for(let t of e)if(!o.has(t))return!1;return!0}var uo=/\s/;function Wo(e,o,t){for(let n=o;n<t;n++)if(!uo.test(e[n]))return!1;return!0}function Vi(e,o,t){let n=e.cache[t]||(e.cache[t]=new Map);if(n.has(o))return n.get(o);let s=t===0?"local":"remote",h=t===0?"remote":"local",l=o.baseMark,r=o[h+"Mark"],i=!o.block&&!o[s]&&!!r&&l.to>l.from;if(i){let u=t===0?e.ML:e.MR,w=t===0?e.MR:e.ML,c=t===0?e.fr:e.fl,p=!1;for(let b=l.from;b<l.to;b++){if(u.bTo[b]>=0){i=!1;break}w.bTo[b]<0&&!uo.test(e.fb.text[b])&&(p=!0)}if(i&&!p){for(let b=r.from;b<r.to;b++)if(w.toB[b]<0&&!uo.test(c.text[b])){p=!0;break}}i&&=p}return n.set(o,i),i}function nr(e,o,t,n,s,h,l,r,i){let u=r===0?e.fl:e.fr,w=null;for(let c=t;c<n;c++){let p=o[c];if(!Wo(u.text,p.ss,p.se))return null;if(Wo(e.fb.text,p.bs,p.be)){if(p.bs<p.be&&p.ss<p.se||uo.test(e.fb.text[p.bs-1]||"")||uo.test(e.fb.text[p.be]||""))continue;return null}let b=!1;for(let S=p.bs;S<p.be;S++){if(uo.test(e.fb.text[S]))continue;let C=null;for(let m of e.fb.stackAt[S]){let f=e.byEl.get(m.el);if(f&&Vi(e,f,r)){C=f;break}}if(!C)return null;(w||(w=new Set)).add(C),b=!0}if(!b)return null}if(!w){if((r===0?"local":"remote")!==i)return null;let c=r===0?e.fr:e.fl,p=!1;for(let b=h;b<l;b++){let S=s[b];if(!Wo(e.fb.text,S.bs,S.be))return null;Wo(c.text,S.ss,S.se)||(p=!0)}if(!p)return null}return w||0}function Ko(e){let{out:o,policy:t="remote",L:n,R:s}=e,h=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,r=e.conflicts||[],i=e.decisions||[],u=r.length,w=e.conflict||(d=>r.push(d)),c={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},p=[],b=!!(n&&n.reverse&&n.map&&s&&s.reverse&&s.map),S={base:null,local:null,remote:null};if(!e.prepared&&b&&e.moveIn){let d=Se=>je=>Se.some(Le=>Le===je||Le.nodeType===1&&Le.contains(je)),B=d(e.local),F=d(e.remote),_=d(e.base),Q=new Set,me=Se=>{if(!Tn.has(Se.tagName))return;let je=n.map.get(Se),Le=s.map.get(Se);(je&&!B(je)||Le&&!F(Le))&&Q.add(Se);for(let Ue of Se.children)me(Ue)};for(let Se of e.base)Se.nodeType===1&&me(Se);let ke=Se=>je=>{if(!Tn.has(je.tagName))return!1;let Le=Se.reverse.get(je);return!!Le&&(Q.has(Le)||!_(Le))};Q.size&&(S.base=Se=>Q.has(Se)),S.local=ke(n),S.remote=ke(s)}let C={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&b&&e.moveIn){let d=_=>Q=>_.some(me=>me===Q||me.nodeType===1&&me.contains(Q)),B=d(e.local),F=d(e.remote);for(let _ of nn(e.base,{...e,atomize:S.base}).atoms){let Q=n.map.get(_.el),me=s.map.get(_.el),ke=!!Q&&!B(Q),Se=!!me&&!F(me);!ke&&!Se||(ke&&e.movePlanned?.(_.el,"local",Q,null),Se&&e.movePlanned?.(_.el,"remote",me,null),C.base.add(_.el),Q&&!ke&&C.local.add(Q),me&&!Se&&C.remote.add(me),B(_.el)&&C.local.add(_.el),F(_.el)&&C.remote.add(_.el))}}let m=e.prepared?.base||nn(e.base,{...e,atomize:S.base,skip:C.base}),f=e.prepared?.local||nn(e.local,{...e,atomize:S.local,skip:C.local}),g=e.prepared?.remote||nn(e.remote,{...e,atomize:S.remote,skip:C.remote}),I=new Map(m.atoms.map(d=>[d.el,d])),v={},T=d=>e.prepared?e.prepared.full?.(d)||null:C[d].size?(v[d]||(v[d]=nn(e[d],{...e,atomize:S[d]})),v[d]):null,A=(d,B,F)=>{B.namespaceURI?d.setAttributeNS(B.namespaceURI,B.name,F):d.setAttribute(B.name,F)},E=(d,B,F,_)=>{if(!B&&(!F||!_)){for(let me of(F||_).attributes)A(d,me,me.value);return}let Q=new Map;for(let me of[B,F,_])if(me)for(let ke of me.attributes)Q.set(ke.name,ke);for(let[me,ke]of Q){let Se=B?B.getAttribute(me):null,je=F?F.getAttribute(me):Se,Le=_?_.getAttribute(me):Se,Ue;je===Le?Ue=je:je===Se?(Ue=Le,i.push({kind:"attr",el:d,name:me,source:"remote"})):Le===Se?(Ue=je,i.push({kind:"attr",el:d,name:me,source:"local"})):(Ue=t==="local"?je:Le,w({kind:"attr",el:d,name:me,base:Se,local:je,remote:Le,resolved:Ue},{el:d,sample:ke}),i.push({kind:"attr",el:d,name:me,source:"both"})),Ue!=null&&A(d,ke,Ue)}},N=(d,B,F,_)=>d&&e.mergeAttrs?e.mergeAttrs(d,B,F,_):E(_,d,B,F),M=e.mergeElement||((d,B,F)=>{let _=o.createElement(d.tagName);N(d,B,F,_);let Q=B||d,me=F||d,ke=t==="local"?Q.isEqualNode(d)?me:Q:me.isEqualNode(d)?Q:me;for(let Se of ke.childNodes)_.appendChild(o.importNode(Se,!0));return h.set(_,{base:d,local:B,remote:F}),_}),R=e.cloneUnit||((d,B)=>{let F=o.importNode(d,!0);return h.set(F,{base:null,local:B==="local"?d:null,remote:B==="remote"?d:null}),F}),V=e.atomKey||(d=>sr(d,()=>!1)),D=(d,B)=>{let F=new Map;for(let _ of d.atoms)if(e.remoteWins&&e.remoteWins(_.el)&&Tn.has(_.el.tagName))F.set(_,"w"+_.el.tagName+"#"+(_.el.id||""));else if(!b)F.set(_,_.key);else if(d===m)F.set(_,"="+V(_.el));else{let Q=B.reverse.get(_.el),me=Q?I.get(Q):null;me?F.set(_,"="+V(me.el)):Q?F.set(_,"m"+V(_.el)):F.set(_,"="+V(_.el))}return _=>F.get(_)},j=D(m,null),y=D(f,n),k=D(g,s),J=e.certifiedOrigins?e.certifiedOrigins(m,f,g,j,y,k):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let d=$t(),B=bs({base:m,side:f,baseOf:_=>n?.reverse?.get(_)||null,budget:d}),F=bs({base:m,side:g,baseOf:_=>s?.reverse?.get(_)||null,budget:d});(B.status==="ready"||F.status==="ready")&&(J={local:B.status==="ready"?B:null,remote:F.status==="ready"?F:null})}let H=e.prepared||rr(m,f,g,j,y,k,J,c),q=H.lines,Me=H.baseTokens,Oe=H.localEdits,Re=H.remoteEdits,ie=H.localMap,xe=H.remoteMap,qe=m.text.length,fe=d=>new Map(d.atoms.map(B=>[B.el,B])),x=fe(f),Y=fe(g),ae=(d,B,F)=>{let _=new Set;if(!b)return _;for(let Q of d.atoms){let me=I.get(B.reverse.get(Q.el));me&&F.bTo[me.i]<0&&_.add(me)}return _},oe=ae(f,n,ie),Ee=ae(g,s,xe),De=d=>!Vn(d,{...e,remoteWins:null}),Ne=new Set;if(b)for(let d of m.atoms){if(!De(d.el))continue;let B=n.map.get(d.el)||null,F=s.map.get(d.el)||null,_=B&&!F?B:F&&!B?F:null;_&&(x.has(_)||Y.has(_))&&!_.isEqualNode(d.el)&&Ne.add(d)}let nt=1,Xe=(d,B)=>({id:nt++,tag:d,base:null,local:null,remote:null,rank:B}),ht=new Map,Ge=[];for(let d of m.marks){let B=Xe(d.tag,d.depth);B.block=!!d.block,B.base=d.el,B.baseMark=d,ht.set(d.el,B),Ge.push(B)}let rt=(d,B)=>{let F=-1,_=-1;for(let Q=d.from;Q<d.to;Q++){let me=B[Q];me>=0&&(F<0&&(F=me),_=me+1)}return F<0?null:[F,_]},Ot=(d,B,F,_)=>{for(let Q of d.marks){let me=F?F.reverse.get(Q.el):null;me&&F.identical.has(me)&&F.pairIdenticalChildren&&F.pairIdenticalChildren(me);let ke=me?ht.get(me):null;if(ke&&ke[B]&&(ke=null),!ke){let Se=rt(Q,_),je=0;if(Se)for(let Le of Ge){if(Le.tag!==Q.tag||Le[B]||!!Le.block!=!!Q.block)continue;let Ue=Math.min(Se[1],Le.baseMark.to)-Math.max(Se[0],Le.baseMark.from);(Ue>je||Ue===je&&Ue>0&&Math.abs(Le.rank-Q.depth)<Math.abs(ke.rank-Q.depth))&&(ke=Le,je=Ue)}}ke||(ke=Xe(Q.tag,Q.depth),ke.block=!!Q.block,ke.new=B),ke[B]=Q.el,ke[B+"Mark"]=Q,ht.set(Q.el,ke)}};Ot(f,"local",n,ie.toB),Ot(g,"remote",s,xe.toB);let Ct=d=>d.merged||d,wt=d=>{let B=new Set;for(let F of d)F.block||B.add(ht.get(F.el));return B},Nt=new Map,Lt=d=>{let B=Nt.get(d);return B||(B=wt(d),Nt.set(d,B)),B},qt=(d,B)=>{let F=[],_=null;for(let Q=0;Q<qe;Q++){let me=B[Q];if(me<0){_&&F.push(_),_=null;continue}let ke=Lt(m.stackAt[Q]),Se=Lt(d.stackAt[me]),je=new Set,Le=new Set;for(let Ue of Se)ke.has(Ue)||je.add(Ue);for(let Ue of ke)Se.has(Ue)||Le.add(Ue);if(!je.size&&!Le.size){_&&F.push(_),_=null;continue}if(_&&tr(_.added,je)&&tr(_.removed,Le)){_.be=Q+1;continue}_&&F.push(_),_={bs:Q,be:Q+1,added:je,removed:Le}}return _&&F.push(_),F},cn=qt(f,ie.bTo),It=qt(g,xe.bTo),Gt=d=>d.be>d.bs?[d.bs,d.be-1]:[d.bs-1,d.bs],wn=(d,B)=>{if(qe===0)return null;let[F,_]=Gt(d);for(let Q of B){if(Q.be<=F)continue;if(Q.bs>_)break;let me=Q.bs<=F&&_<Q.be;return me&&d.text===""&&Q.bs===d.bs&&Q.be===d.be?"straddle":me?Q:d.be>d.bs?"straddle":null}return null},Dt=d=>d.bs===d.be,rn=(d,B,F=null)=>{let _=!1;for(let Q=d.bs;Q<d.be;Q++){let me=m.text[Q];if(me===kt)_=!0;else if(!/\s/.test(me))return!1}for(let Q=d.ss;Q<d.se;Q++){let me=B.text[Q];if(me===kt)_=!0;else if(!/\s/.test(me)){let ke=F&&e.scopeUnits&&Dt(d)&&B.atomAt.get(Q);if(!ke||!De(ke.el)||F.ss!==F.se||F.bs>=F.be)return!1;for(let je=F.bs;je<F.be;je++)if(!/\s/.test(m.text[je]))return!1;let Se=B===f?1:2;if(!e.scopeUnits[Se].includes(ke.el)||(Se===1?n:s)?.reverse.has(ke.el))return!1;_=!0}}return _},Yt=(d,B)=>d.bs<B.be&&B.bs<d.be,fn=(d,B)=>d.bs<=B.be&&B.bs<=d.be&&Dt(d)!==Dt(B),$=(d,B)=>m.text.slice(d.bs,d.be).includes(kt)||B.text.slice(d.ss,d.se).includes(kt),a=d=>{if(Dt(d))return!1;let B=d.bs,F=d.be;for(;B>0&&/\s/.test(m.text[B-1]);)B--;for(;F<m.text.length&&/\s/.test(m.text[F]);)F++;return(B===0||m.text[B-1]===kt)&&(F===m.text.length||m.text[F]===kt)},O=(d,B)=>!$(d,B)&&!a(d),P=(d,B)=>Yt(d,B)||fn(d,B)&&!(d.transferIn||d.transferOut||B.transferIn||B.transferOut)&&!(rn(d,f,B)&&O(B,g))&&!(rn(B,g,d)&&O(d,f)),K=(d,B)=>{if(d.bs!==B.bs||d.be!==B.be||d.toks.length!==B.toks.length)return!1;let F=d.ss,_=B.ss;for(let Q=0;Q<d.toks.length;Q++){let me=d.toks[Q],ke=B.toks[Q];if(me.k!==ke.k||me.atom&&!f.atomAt.get(F).el.isEqualNode(g.atomAt.get(_).el))return!1;F+=me.len,_+=ke.len}return!0},Z=(d,B,F,_)=>{for(let Q of m.atoms){if(Q.i<d.bs||Q.i>=d.be||_.has(Q)||Ne.has(Q))continue;let me=B.bTo[Q.i],ke=me>=0?F.atomAt.get(me):null;if(ke&&!ke.el.isEqualNode(Q.el))return!0}return!1},U=[],de=null,we=null,le=Oe.hunks,Ae=Re.hunks,W=0,X=0,pe=0,be=0,he=0,ee=d=>{d>pe&&(U.push({src:"base",from:pe,to:d,dL:be,dR:he}),pe=d)};for(;W<le.length||X<Ae.length;){let d=le[W],B=Ae[X],F=!!d&&(!B||d.bs<B.bs||d.bs===B.bs&&d.be<=B.be&&!B.lead);if(d&&B&&d.bs===B.bs&&Dt(d)&&Dt(B)){let _t=rn(d,f),So=rn(B,g);_t!==So&&(F=So)}let _=F?d:B,Q=F?B:d,me=!!Q&&K(d,B),ke=!!Q&&(F?!!le[W+1]&&K(le[W+1],B):!!Ae[X+1]&&K(d,Ae[X+1])),Se=!!Q&&!me&&!ke&&(qe===0||P(d,B)),je=Se,Le=wn(_,F?It:cn);if(Le==="straddle"&&(je=!0),!je&&_.be>_.bs&&(je=Z(_,F?xe:ie,F?g:f,F?oe:Ee)),!je&&me){ee(_.bs),U.push({src:"both",lfrom:d.ss,rfrom:B.ss,len:_.text.length,owner:d.owner||B.owner||null,transfer:d.transferIn||B.transferIn||null}),pe=_.be,be+=_.text.length-(_.be-_.bs),he+=_.text.length-(_.be-_.bs),W++,X++;continue}if(!je){ee(_.bs),U.push({src:F?"local":"remote",from:_.ss,to:_.se,inherit:Le&&Le!=="straddle"?Le:null,owner:_.owner||null,transfer:_.transferIn||null}),pe=_.be,F?(be+=_.text.length-(_.be-_.bs),W++):(he+=_.text.length-(_.be-_.bs),X++);continue}let Ue=_.bs,gt=_.be,at=W,dt=X,Vt=_t=>_t.bs<gt&&_t.be>Ue||Dt(_t)&&(_t.bs===Ue||_t.bs===gt);F?at++:dt++,Se&&(Ue=Math.min(Ue,Q.bs),gt=Math.max(gt,Q.be),F?dt++:at++);let Bt=!0;for(;Bt;){for(Bt=!1;at<le.length&&Vt(le[at]);)Ue=Math.min(Ue,le[at].bs),gt=Math.max(gt,le[at].be),at++,Bt=!0;for(;dt<Ae.length&&Vt(Ae[dt]);)Ue=Math.min(Ue,Ae[dt].bs),gt=Math.max(gt,Ae[dt].be),dt++,Bt=!0}let mn=Ue+be,ln=Ue+he,yn=gt-Ue,Nn=gt-Ue;for(let _t=W;_t<at;_t++)yn+=le[_t].text.length-(le[_t].be-le[_t].bs);for(let _t=X;_t<dt;_t++)Nn+=Ae[_t].text.length-(Ae[_t].be-Ae[_t].bs);let Bn=mn+yn,jn=ln+Nn;if(ee(Ue),W<at&&X<dt&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!m.atoms.length&&!f.atoms.length&&!g.atoms.length&&!m.pins.length&&!f.pins.length&&!g.pins.length){de||={fb:m,fl:f,fr:g,ML:ie,MR:xe,byEl:ht,cache:[null,null]};let _t=nr(de,le,W,at,Ae,X,dt,0,t),So=nr(de,Ae,X,dt,le,W,at,1,t);if(_t===null!=(So===null)){let ns=_t!==null,Us=ns?_t:So;if(Us){we||=new Map;for(let si of Us)we.set(si,ns?"local":"remote")}U.push(ns?{src:"remote",from:ln,to:jn}:{src:"local",from:mn,to:Bn}),pe=gt,be+=yn-(gt-Ue),he+=Nn-(gt-Ue),W=at,X=dt;continue}}let en={kind:"text",node:e.node||null,base:co(m,Ue,gt),local:co(f,mn,Bn),remote:co(g,ln,jn),resolved:null,range:null,bs:Ue,be:gt,lss:mn,lse:Bn,rss:ln,rse:jn},Jn=e.sourceRetentions?Ys(e.sourceRetentions,e.scope?.base,m,f,g,t,en):t;en.resolved=Jn==="local"?en.local:Jn==="remote"?en.remote:en.local+en.remote,Jn!=="remote"&&U.push({src:"local",from:mn,to:Bn,conflict:en}),Jn!=="local"&&U.push({src:"remote",from:ln,to:jn,conflict:en});let Qn={site:"inline",policy:Jn,fb:m,fl:f,fr:g,scope:e.scope||null,synthetic:!!e.synthetic,full:T,merged:c};p.push(Qn),w(en,Qn),pe=gt,be+=yn-(gt-Ue),he+=Nn-(gt-Ue),W=at,X=dt}ee(qe);let te=m.text,z=[];if(Oe.respell.size||Re.respell.size){let d=fo(Me),B=[];for(let F=0;F<Me.length;F++){let _=Me[F].raw,Q=Oe.respell.get(F)??_,me=Re.respell.get(F)??_;(Q!==_||me!==_)&&z.push([d[F],Q!==_&&me!==_?"both":Q!==_?"local":"remote"]),B.push(Q===me?Q:Q===_?me:me===_||t==="local"?Q:me)}te=B.join("")}let ne="",Te=[],Ce=[],Pe=[],ve=[];for(let d of U){let B=ne.length;if(d.src==="base"){for(let F=d.from;F<d.to;F++)Te.push(F),Ce.push(e.nativeTransfers?ie.bTo[F]:F+d.dL),Pe.push(e.nativeTransfers?xe.bTo[F]:F+d.dR),ve.push(d);ne+=te.slice(d.from,d.to)}else if(d.src==="both"){for(let F=0;F<d.len;F++){let _=d.transfer&&(d.transfer.side==="remote"?d.rfrom+F:d.lfrom+F);Te.push(d.transfer&&_>=d.transfer.ss&&_<d.transfer.se?d.transfer.bs+_-d.transfer.ss:-1),Ce.push(d.lfrom+F),Pe.push(d.rfrom+F),ve.push(d)}ne+=f.text.slice(d.lfrom,d.lfrom+d.len)}else{let F=d.src==="local"?f:g,_=d.transfer&&e.nativeTransfers.byOrigin[d.src==="local"?"remote":"local"].get(d.transfer.key);for(let Q=d.from;Q<d.to;Q++){let me=d.transfer&&Q>=d.transfer.ss&&Q<d.transfer.se?d.transfer.bs+Q-d.transfer.ss:-1,ke=me>=0&&(!_||_.destination===d.owner)?(d.src==="local"?xe:ie).bTo[me]:-1;Te.push(me),Ce.push(d.src==="local"?Q:ke),Pe.push(d.src==="remote"?Q:ke),ve.push(d)}ne+=F.text.slice(d.from,d.to)}d.ms=B,d.me=ne.length,d.conflict&&(d.conflict.range||(d.conflict.range=[B,B]),d.conflict.range[1]=ne.length)}let _e=ne.length,Je=new Int32Array(qe+1).fill(-1),Ze=new Int32Array(f.text.length+1).fill(-1),Ut=new Int32Array(g.text.length+1).fill(-1);for(let d=0;d<_e;d++)Te[d]>=0&&(Je[Te[d]]=d),Ce[d]>=0&&(Ze[Ce[d]]=d),Pe[d]>=0&&(Ut[Pe[d]]=d);let Pt=(d,B)=>{let F=-1,_=-1;for(let Q=d.from;Q<d.to;Q++){let me=B[Q];me>=0&&(F<0&&(F=me),_=me+1)}return F<0?null:[F,_]},L=[],G=[];for(let d of new Set(ht.values()))d.new==="local"?L.push(d):d.new==="remote"&&G.push(d);let re=(d,B)=>{d.remote=B.remote,d.remoteMark=B.remoteMark,d.new="both",B.merged=d,ht.set(B.remote,d)};if(L.length&&G.length){let d=e.idOf;for(let B of L){let F=d?d.local(B.local):null;if(!F)continue;let _=G.find(Q=>!Q.merged&&Q.tag===B.tag&&!!Q.block==!!B.block&&d.remote(Q.remote)===F);_&&re(B,_)}for(let B of L){if(B.remote)continue;let F=Pt(B.localMark,Ze);if(F)for(let _ of G){if(_.merged||_.tag!==B.tag||!!_.block!=!!B.block)continue;let Q=Pt(_.remoteMark,Ut);if(Q&&Math.min(F[1],Q[1])-Math.max(F[0],Q[0])>0){re(B,_);break}}}}Nt.clear();let ge=d=>{for(let B of d)if(B.block)return Ct(ht.get(B.el));return null},ye=m.marks.some(d=>d.block)||f.marks.some(d=>d.block)||g.marks.some(d=>d.block),ce=new Array(_e).fill(null),se=new Set;if(e.nativeTransfers)for(let d=0;d<_e;d++){let B=ve[d].owner;ce[d]=B?Ct(ht.get(B)):Te[d]>=0?ge(m.stackAt[Te[d]]):null}else if(ye){let d=(Le,Ue,gt)=>{let at=new Set([Le,Ue,gt]);at.delete(null);let dt=[];for(let Bt of at){let mn=Bt===Le,ln=Bt===Ue,yn=Bt===gt;(ln===yn?ln:ln===mn?yn:ln)&&dt.push(Bt)}if(dt.length<=1)return dt[0]||null;let Vt=t==="local"?Ue:gt;return dt.includes(Vt)?Vt:dt[0]},B=(Le,Ue)=>Ue>=0?ge(Le.stackAt[Ue]):null,F=new Map;for(let Le=0;Le<_e;Le++){if(ne[Le]!==kt)continue;let Ue=Te[Le]>=0?B(m,Te[Le]):null,gt=B(f,Ce[Le]),at=B(g,Pe[Le]);F.set(Le,[Ue,Te[Le]>=0?d(Ue,gt,at):gt||at])}let _=new Set([...F.values()].map(Le=>Le[1])),Q=Le=>Le!==kt&&Le!==Un&&!/\s/.test(Le),me=(Le,Ue)=>{let gt=Le;for(;gt<Ue&&!Q(ne[gt]);)gt++;return gt<Ue&&Te[gt]>=0?B(m,Te[gt]):null},ke=new Map,Se=0;for(let Le=0;Le<_e;Le++){if(ne[Le]!==kt)continue;let[Ue,gt]=F.get(Le),at=me(Se,Le),dt=gt,Vt=ke.get(dt)===dt&&at===dt;dt&&ke.has(dt)&&!Vt&&Ue&&!ke.has(Ue)&&!_.has(Ue)&&(dt=Ue),dt&&!ke.has(dt)&&ke.set(dt,at);for(let Bt=Se;Bt<=Le;Bt++)ce[Bt]=dt;Se=Le+1}let je=Le=>{for(let Ue=0;Ue<Le.text.length;Ue++)if(Q(Le.text[Ue])&&!B(Le,Ue))return!0;return!1};if(!je(m)&&!je(f)&&!je(g)){let Le=[],Ue=0;for(let at=0;at<_e;at++)(ne[at]===kt||at===_e-1)&&(Le.push([Ue,at]),Ue=at+1);let gt=new Set(ce);for(let at=0;at<Le.length;at++){let[dt,Vt]=Le[at];if(ce[Vt])continue;let Bt=dt;for(;Bt<=Vt&&!Q(ne[Bt]);)Bt++;if(Bt>Vt)continue;let mn=B(m,Te[Bt]),ln=B(f,Ce[Bt]),yn=B(g,Pe[Bt]),Nn=d(mn,ln,yn)||ln||yn||mn;if(Nn&&!gt.has(Nn)){gt.add(Nn);for(let en=dt;en<=Vt;en++)ce[en]=Nn;continue}let Bn=at>0&&ce[Le[at-1][1]],jn=at+1<Le.length&&ce[Le[at+1][1]];if(Bn)se.add(Le[at-1][1]);else if(jn&&ne[Vt]===kt)se.add(Vt);else continue;for(let en=dt;en<=Vt;en++)ce[en]=Bn||jn}}}let Ie=new Map,Be=d=>{let B=Ie.get(d);if(B)return B;B=[1/0,-1/0];for(let[F,_]of[[d.baseMark,Je],[d.localMark,Ze],[d.remoteMark,Ut]]){let Q=F&&Pt(F,_);Q&&(B[0]=Math.min(B[0],Q[0]),B[1]=Math.max(B[1],Q[1]))}return Ie.set(d,B),B},He=(d,B,F)=>{let _=-1,Q=-1;for(let me=0;me<d.length;me++){let ke=ht.get(d[me].el);ke===B&&(_=me),ke===F&&(Q=me)}return _>=0&&Q>=0?_-Q:0},Ke=(d,B)=>[...d].sort((F,_)=>{for(let ke of B){let Se=He(ke,F,_);if(Se)return Se}let Q=Be(F),me=Be(_);return Q[0]-me[0]||me[1]-Q[1]||F.rank-_.rank||F.id-_.id}),pt=new Map,tt=new Map,Kt=e.nativeTransfers?[]:null,Ht=d=>{if(Kt)return Kt;let B=Te[d],F=Ce[d],_=Pe[d],Q=ve[d];if(B>=0){let at=m.stackAt[B],dt=f.stackAt[F],Vt=g.stackAt[_],Bt=pt.get(at);Bt||pt.set(at,Bt=new Map);let mn=Bt.get(dt);mn||Bt.set(dt,mn=new Map);let ln=mn.get(Vt);if(ln)return ln;let yn=Lt(at),Nn=Lt(dt),Bn=Lt(Vt),jn=new Set;for(let en of new Set([...yn,...Nn,...Bn])){let Jn=yn.has(en),Qn=Nn.has(en),_t=Bn.has(en);(Qn===_t?Qn:Qn===Jn?_t:Qn)&&jn.add(en)}return ln=Ke(jn,[dt,Vt,at]),mn.set(Vt,ln),ln}if(Q.src==="both"){let at=f.stackAt[F],dt=g.stackAt[_];return Ke(new Set([...Lt(at),...Lt(dt)]),[at,dt])}let ke=(Q.src==="local"?f:g).stackAt[Q.src==="local"?F:_];if(!Q.inherit)return Ke(Lt(ke),[ke]);let Se=tt.get(Q);Se||tt.set(Q,Se=new Map);let je=Se.get(ke);if(je)return je;let Le=new Set(Lt(ke));for(let at of Q.inherit.added)Le.add(Ct(at));for(let at of Q.inherit.removed)Le.delete(Ct(at));let Ue=Q.src==="local"?g:f,gt=(Q.src==="local"?xe.bTo:ie.bTo)[Q.inherit.bs];return je=Ke(Le,[ke,Ue.stackAt[gt]]),Se.set(ke,je),je},un=new Int32Array(f.text.length+1);un[f.text.length]=_e;for(let d=f.text.length-1;d>=0;d--)un[d]=Ze[d]>=0?Ze[d]:un[d+1];Pi.caret+=f.text.length;let bt=d=>d<=0?0:(d>f.text.length&&(d=f.text.length),Ze[d-1]>=0?Ze[d-1]+1:un[d]),lt=[],$e=[],vt=null,ct=[],jt="",bn=-1,on=d=>{vt?vt.appendChild(d):lt.push(d)},hn=d=>{if(!jt)return;let B=o.createTextNode(jt);on(B),$e.push({node:B,ms:bn,me:d,local:[],u:ct.length?ct[ct.length-1].u:null}),jt=""},Xt=new Set,En=new Map,oo=new Set,Rn=d=>{let B=o.createElement(d.tag);if(d.block&&vn.add(B),!En.has(d)){En.set(d,B),N(d.base,d.local,d.remote,B),h.set(B,{base:d.base,local:d.local,remote:d.remote});let _=(ke,Se)=>b&&d[Se]&&ke.reverse.get(d[Se])?Se:null,Q=!d.base&&(_(n,"local")||_(s,"remote"));if(Q){let ke=Q==="local"?n.reverse.get(d.local):s.reverse.get(d.remote),Se=h.get(B);Se.local=Se.local||n.map.get(ke)||null,Se.remote=Se.remote||s.map.get(ke)||null,i.push({kind:"move",el:B,source:Q}),e.moveBuilt?.(ke,Q,d[Q],B)}else d.base||i.push({kind:"insert",el:B,source:d.local&&d.remote?"both":d.local?"local":"remote"});let me=h.get(B);me.local&&(oo.has(me.local)?me.local=null:oo.add(me.local))}else{let _=En.get(d);for(let Q of _.attributes)Q.name!=="id"&&Q.name!=="data-id"&&A(B,Q,Q.value);h.set(B,{base:null,local:null,remote:null})}on(B),ct.push({u:d,el:B}),vt=B},xo=new Set,Kn=new Map;for(let d of f.pins){let B=bt(d.i);Kn.has(B)||Kn.set(B,[]),Kn.get(B).push(d)}let Ro=d=>{let B=Kn.get(d);if(B){hn(d);for(let F of B){let _=F.el.namespaceURI&&F.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(F.el.namespaceURI,F.el.tagName):o.createElement(F.el.tagName);h.set(_,{base:null,local:F.el,remote:null,pinned:!0}),xo.add(_),on(_)}}},ts=m.atoms.length||f.atoms.length||g.atoms.length,Po=d=>{if(!ts)return null;let B=Te[d]>=0?m.atomAt.get(Te[d]):null,F=Ce[d]>=0?f.atomAt.get(Ce[d]):null,_=Pe[d]>=0?g.atomAt.get(Pe[d]):null;return B||F||_?{ab:B,al:F,ar:_}:null},Fn=(d,B,F)=>{let _=e.idOf;if(!_||!_.base)return!1;let Q=_.base(d.el);return Q!=null&&Q===_[F](B.el)},To=(d,B,F,_,Q)=>{if(!d||!b)return null;let me=I.get(B.reverse.get(d.el))||null;return!me||me===_||(_?me.el.isEqualNode(_.el)&&!Fn(me,d,Q):F.bTo[me.i]>=0)?null:me},so=(d,B)=>{if(!d||!b||!e.moveIn)return null;let F=B.reverse.get(d.el);return F&&!I.has(F)?F:null},vo=(d,B)=>{let F=new Map;for(let _ of d.atoms)F.set(B(_),(F.get(B(_))||0)+1);return F},ue=vo(m,j),We=vo(f,y),Ve=vo(g,k),et=d=>{let B=j(d);return ue.get(B)===1&&(We.get(B)||0)<=1&&(Ve.get(B)||0)<=1},yt=new Map,Fe=new Set,ze=new Set,xt=new Set,Ye=null;for(let d=0;d<_e;d++){let B=Po(d);if(!B)continue;let{ab:F,al:_,ar:Q}=B,me=To(Q,s,xe,F,"remote"),ke=To(_,n,ie,F,"local"),Se=F,je=null;if(me?(Se=me,je="remote"):ke&&(Se=ke,je="local"),Se){F&&Se!==F&&(Ye||=new Map).set(F,je),Fe.has(Se)?yt.set(d,{dup:Se.el}):(Fe.add(Se),yt.set(d,{bk:Se,from:je,al:_,ar:Q}));continue}let Le=so(Q,s),Ue=so(_,n),gt=Le||Ue;if(gt){ze.has(gt)?yt.set(d,{dup:gt}):(ze.add(gt),yt.set(d,{moveIn:gt,side:Le?"remote":"local",sideEl:Le?Q.el:_.el}));continue}let at=(Vt,Bt)=>Vt&&b&&I.get(Bt.reverse.get(Vt.el))||null,dt=at(Q,s)||at(_,n);if(dt&&(xt.add(dt),ve[d].conflict&&(et(dt)||Q&&(Q.el===dt.el||s.identityPaired?.has(dt.el))&&Fn(dt,Q,"remote")||_&&(_.el===dt.el||n.identityPaired?.has(dt.el))&&Fn(dt,_,"local")))){if(Fe.has(dt)){yt.set(d,{dup:dt.el});continue}Fe.add(dt)}yt.set(d,{al:_,ar:Q})}let st=new Map,ft,Wt,Mt=(d,B)=>{if(d[B]>=0)return d[B];for(let F=B-1;F>=0;F--)if(d[F]>=0)return d[F]+1;return 0};if(b)for(let d of m.atoms){if(Fe.has(d)||xt.has(d))continue;let B=n.map.get(d.el)||null,F=s.map.get(d.el)||null,_=B&&x.get(B),Q=F&&Y.get(F);if(B&&!_||F&&!Q)continue;let me=!(_&&Q)&&Ne.has(d);if(!me&&!(_&&Q&&(et(d)||Ye?.has(d)||(_.el===d.el||n.identityPaired?.has(d.el))&&(Q.el===d.el||s.identityPaired?.has(d.el))&&Fn(d,_,"local")&&Fn(d,Q,"remote"))))continue;let ke=Ye?.get(d),Se=t;if(ke){let at=ke==="local"?g:f,dt=ke==="local"?s:n,Vt=ke==="local"?Wt:ft;if(Vt===void 0){Vt=at.atoms.length===m.atoms.length;for(let Bt=0;Vt&&Bt<m.atoms.length;Bt++)Vt=dt.reverse.get(at.atoms[Bt].el)===m.atoms[Bt].el;ke==="local"?Wt=Vt:ft=Vt}Vt&&(Se=ke)}let je=Se==="local"?[[_,Ze],[Q,Ut]]:[[Q,Ut],[_,Ze]],[Le,Ue]=je.find(([at])=>at),gt=Mt(Ue,Le.i);st.has(gt)||st.set(gt,[]),st.get(gt).push({a:d,lt:B,rt:F,edited:me}),Fe.add(d)}if(b&&e.moveIn){let d=[[f,n,Ze,"local"],[g,s,Ut,"remote"]];t!=="local"&&d.reverse();for(let[B,F,_,Q]of d)for(let me of B.atoms){let ke=so(me,F);if(!ke||ze.has(ke))continue;ze.add(ke);let Se=Mt(_,me.i);st.has(Se)||st.set(Se,[]),st.get(Se).push({move:ke,side:Q,sideEl:me.el})}}let Qt=d=>{let B=st.get(d);if(B){if(hn(d),B.some(F=>De(F.move?F.sideEl:F.a.el)))for(;ct.length;)ct.pop(),vt=ct.length?ct[ct.length-1].el:null;for(let{a:F,lt:_,rt:Q,edited:me,move:ke,side:Se,sideEl:je}of B){if(ke){let Ue=e.moveIn(ke,Se,je);Ue&&on(Ue);continue}Xt.add(F);let Le=M(F.el,_,Q);me&&(w({kind:"structure",el:Le,detail:"edit-beats-delete",base:F.el},{subject:F.el,deleted:_?"remote":"local"}),i.push({kind:"insert",el:Le,source:_?"local":"remote"})),on(Le)}}},vn=new Set,_n=r.length>u;for(let d=0;d<_e;d++){let B=Po(d),F=e.scopeUnits&&B&&(B.ab?.stack.some(ke=>ke.block)||B.al?.stack.some(ke=>ke.block)||B.ar?.stack.some(ke=>ke.block)),Q=!!B&&De((B.ab||B.al||B.ar).el)&&!F?[]:ce[d]?[ce[d],...Ht(d)]:Ht(d),me=0;for(;me<ct.length&&me<Q.length&&ct[me].u===Q[me];)me++;if(me<ct.length)for(hn(d);ct.length>me;)ct.pop(),vt=ct.length?ct[ct.length-1].el:null;if(Ro(d),Qt(d),Q.length>ct.length)for(hn(d);ct.length<Q.length;)Rn(Q[ct.length]);if(ne[d]===kt){if(se.has(d))continue;hn(d);let ke=ct.length;for(;ke>0&&!ct[ke-1].u.block;)ke--;if(ke>0)for(_n&&c.breakOut.set(d,ct[ke-1].el);ct.length>=ke;)ct.pop(),vt=ct.length?ct[ct.length-1].el:null;continue}if(B){hn(d);let ke=yt.get(d),Se;if(ke.dup){w({kind:"structure",el:null,detail:"both-moved",base:ke.dup},{subject:ke.dup});continue}if(ke.moveIn){if(Se=e.moveIn(ke.moveIn,ke.side,ke.sideEl),!Se)continue}else if(ke.bk){let je=ke.bk;if(Xt.add(je),je===B.ab)Se=M(je.el,ke.al.el,ke.ar.el);else{let Le=n.map.get(je.el)||null,Ue=s.map.get(je.el)||null;Se=M(je.el,Le,Ue),(!Le||!Ue)&&w({kind:"structure",el:null,detail:"move-beats-delete",base:je.el},{subject:je.el,deleted:Le?"remote":"local"}),i.push({kind:"move",el:Se,source:ke.from})}}else ke.al?(Se=R(ke.al.el,"local"),ke.ar&&(h.get(Se).remote=ke.ar.el),i.push({kind:"insert",el:Se,source:ke.ar?"both":"local"})):(Se=R(ke.ar.el,"remote"),i.push({kind:"insert",el:Se,source:"remote"}));_n&&c.atomOut.set(d,Se),on(Se);continue}jt||(bn=d),jt+=ne[d]}if(hn(_e),(Kn.has(_e)||st.has(_e))&&(ct.length=0,vt=null,Ro(_e),Qt(_e)),_e===0&&(f.placeholder||g.placeholder||m.placeholder)){let d=o.createElement("br");h.set(d,{base:m.placeholder,local:f.placeholder,remote:g.placeholder}),lt.push(d)}let Pn=0,ut=d=>{for(;Pn>0&&$e[Pn-1].me>=d;)Pn--;for(;Pn<$e.length&&$e[Pn].me<d;)Pn++;let B=$e[Pn];if(!B)return $e[$e.length-1]||null;let F=$e[Pn+1];return B.me===d&&F&&F.ms===d?F:B},Qe=new Map,Et={},ot=(d,B,F)=>{let _=ut(d)||(F?Et:null);if(!_)return;let Q=Qe.get(_)||{l:!1,r:!1};B!=="remote"&&(Q.l=!0),B!=="local"&&(Q.r=!0),Qe.set(_,Q)},At=d=>{if(d.conflict)return!0;let B=d.src==="local"?f.text:d.src==="remote"?g.text:"";for(let F=d.from;F<d.to;F++)if(B[F]!==Un&&B[F]!==kt)return!0;return!1};for(let d of U)d.src!=="base"&&ot(d.ms,d.conflict?"both":d.src,At(d));for(let[d,B]of z)Je[d]>=0&&ot(Je[d],B);for(let d of $e.length?$e:[Et]){let B=Qe.get(d);B&&i.push({kind:"text",node:d.node||null,source:B.l&&B.r?"both":B.l?"local":"remote"})}for(let d of Ge){if(En.has(d))continue;let B=!d.local&&!(b&&n.map.get(d.base)),F=!d.remote&&!(b&&s.map.get(d.base));!B&&!F||i.push({kind:"remove",source:B&&F?"both":B?"local":"remote",base:d.base})}if(we)for(let[d,B]of we)En.has(d)&&w({kind:"structure",el:En.get(d),detail:"edit-beats-delete",base:d.base},{subject:d.base,deleted:B});let Jt=(d,B,F)=>{if(B<=d)return!1;for(let _=d;_<B;_++)if(F[_]>=0)return!1;return!0};for(let d of Ge)for(let B of["local","remote"]){let F=d[B+"Mark"],_=d.baseMark;if(!F)continue;let Q=B==="local"?ie:xe;if(!Jt(_.from,_.to,Q.bTo)||!Jt(F.from,F.to,Q.toB))continue;let me=(B==="local"?le:Ae).find(ke=>ke.ss<=F.from&&F.from<ke.se);me&&(me.be<=_.from||me.bs>=_.to)&&i.push({kind:"move",el:En.get(d)||null,source:B})}let Rt=d=>{let B=ht.get(d.node.parentNode);return B?Ct(B):null};for(let d of f.nodes){let B=-1;for(let _=d.s;_<d.e;_++)if(Ze[_]>=0){B=Ze[_];break}let F;if(B>=0)F=ut(B);else{let _=bt(d.s),Q=Rt(d);F=$e.find(me=>me.u===Q&&me.me>=_)||$e.filter(me=>me.u===Q).pop()}F&&F.local.push(d)}let Ft=new Map,tn=$e[$e.length-1]||null,Tt=0;for(let d of f.nodes){let B=null;for(let F=d.s;F<=d.e;F++){let _=bt(F);for(;Tt>0&&$e[Tt-1].me>=_;)Tt--;for(;Tt<$e.length&&$e[Tt].me<_;)Tt++;let Q=ke=>ke&&_>=ke.ms&&_<=ke.me&&(_<ke.me||F===d.e||ke===B),me=Q($e[Tt])?$e[Tt]:Q($e[Tt+1])?$e[Tt+1]:$e[Tt]||tn;if(!me)break;if(B===me){let ke=Ft.get(me);ke[ke.length-1].to=F-d.s;continue}B=me,Ft.has(me)||Ft.set(me,[]),Ft.get(me).push({node:d.node,from:F-d.s,to:F-d.s,flatStart:d.s})}}for(let d of $e){let B=d.local,F=!1;for(let ke of B)for(let Se=ke.s;Se<ke.e&&!F;Se++)(Ze[Se]<d.ms||Ze[Se]>=d.me)&&(F=!0);h.set(d.node,{base:null,local:B.map(ke=>ke.node),remote:null,caret:Ft.get(d)||[],partial:F});let _=d.ms,Q=d.me-d.ms,me=ke=>{let Se=0,je=-1;for(let Le of B){let Ue=Le.e-Le.s;if(ke<=Se+Ue){je=Le.s+(ke-Se);break}Se+=Ue}return je<0&&(je=B.length?B[B.length-1].e:0),Math.max(0,Math.min(bt(je)-_,Q))};me.flat=ke=>Math.max(0,Math.min(bt(ke)-_,Q)),l.set(d.node,me)}function mt(){if(!f.text.includes(kt))return[{flatLocal:f.text,localNodes:f.nodes,textNodes:$e,lToM:Ze,mapLocal:bt}];let d=[],B=0,F=0;for(let _=0;_<=f.text.length;_++){if(_<f.text.length&&f.text[_]!==kt)continue;let Q=B,me=_;if(me>Q){let ke=[];for(;F<f.nodes.length&&f.nodes[F].e<=Q;)F++;for(let Se=F;Se<f.nodes.length&&f.nodes[Se].s<me;Se++){let je=f.nodes[Se],Le=Math.max(je.s,Q),Ue=Math.min(je.e,me);Le<Ue&&ke.push({node:je.node,s:Le-Q,e:Ue-Q})}d.push({flatLocal:f.text.slice(Q,me),localNodes:ke,textNodes:$e,lToM:Ze.subarray?Ze.subarray(Q,me+1):Ze.slice(Q,me+1),mapLocal:Se=>bt(Q+Math.max(0,Math.min(Se,me-Q)))})}B=_+1}return d}let St={...e,blocks:vn,ignored:d=>xo.has(d)||(e.ignored?e.ignored(d):!1)},Zt=e.ignoreAttribute||(()=>!1),zn=Xs(nn(lt,St),Zt)!==Xs(g,Zt);if(p.length){let d=B=>{let F=h.get(B);return F&&F.unchanged?F.remote:null};c.text=ne,c.textNodes=$e,c.out=nn(lt,{...St,via:d})}let Sn=null;if(e.scopeUnits){Sn=new Map;let d=new Set(lt),B=Se=>{for(;Se&&!d.has(Se);)Se=Se.parentNode;return Se},F=e.scopeUnits.map(Se=>{let je=new Map;for(let Le of Se)if(Le.nodeType===1)je.set(Le,Le);else for(let Ue of Le.nodes)je.set(Ue,Le);return je}),_=(Se,je)=>{for(;Se&&!je.has(Se);)Se=Se.parentNode;return Se?je.get(Se):null},Q=[m,f,g].map((Se,je)=>{let Le=new Array(Se.text.length);for(let Ue of Se.nodes){let gt=_(Ue.node,F[je]);gt&&Le.fill(gt,Ue.s,Ue.e)}for(let Ue of Se.atoms)Le[Ue.i]=_(Ue.el,F[je]);return Le}),me=(Se,je)=>{if(!Se||!je)return;let Le=Sn.get(Se);Le||Sn.set(Se,Le=new Set),Le.add(je)};for(let Se of lt){let je=h.get(Se);je&&(me(_(je.base,F[0]),Se),me(_(je.local,F[1]),Se),me(_(je.remote,F[2]),Se))}for(let Se of $e){let je=B(Se.node);for(let Le=Se.ms;Le<Se.me;Le++)me(Q[0][Te[Le]],je),me(Q[1][Ce[Le]],je),me(Q[2][Pe[Le]],je)}let ke=new Map(lt.map((Se,je)=>[Se,je]));for(let[Se,je]of Sn)Sn.set(Se,Array.from(je).sort((Le,Ue)=>ke.get(Le)-ke.get(Ue)))}return{unitOutputs:Sn,nodes:lt,text:ne,textNodes:$e,localDiverged:zn,mapLocal:bt,conflicts:r.slice(u),granularity:q?"line":"word",segments:mt(),localHunks:le,remoteHunks:Ae,lToM:Ze}}var Ts=Symbol("lost");function lr(){return{links:new Map,removed:new Set,consumed:new Set,link(e,o){this.links.set(e,o)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let o of e.nodes)this.removed.add(o)},consume(e){for(let o of e)this.consumed.add(o)}}}var ir=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function ar({locals:e,rec:o,root:t,provenance:n,segments:s,ignored:h}){let l=new Map,r=(v,T)=>{let A=l.get(v);A||l.set(v,A=new Set),A.add(T)},i=new Set,u=new Set;for(let v of s){let T=v.textNodes;for(let A of T)i.add(A.node);for(let A of v.localNodes){u.add(A.node);let E=0,N=null;for(let M=A.s;M<A.e;M++){let R=v.lToM[M];if(R<0)continue;for((!T[E]||R<T[E].ms)&&(E=0);E<T.length&&T[E].me<=R;)E++;let V=T[E]&&T[E].ms<=R?T[E].node:Ts;V!==N&&r(A.node,V),N=V}}}let w=new Set,c=new Map,p=new Set;(function v(T){w.add(T);let A=n.get(T);if(T.nodeType===1)A&&A.local&&A.local.nodeType===1&&(r(A.local,T),A.unchanged&&p.add(A.local)),T.tagName==="TEMPLATE"&&T.content&&c.set(T.content,T);else if(A&&Array.isArray(A.local)&&!i.has(T))for(let E of A.local)r(E,T);for(let E=ir(T).firstChild;E;E=E.nextSibling)v(E)})(t);let b=new Set;for(let[v,T]of o.links)r(v,T),b.add(v);let S=v=>{let T=v.parentNode;return T&&T.nodeType===11?c.get(T)||null:T},C=(v,T)=>{for(let A=v;A;A=S(A))if(A===T)return!0;return!1},m=v=>o.removed.has(v)||o.consumed.has(v),f=v=>{for(let T=v.parentNode;T&&T.nodeType===1;T=T.parentNode){if(p.has(T))return"kept";if(m(T))return"decided";if(l.has(T))return null}return null},g=new Map;for(let v of e)g.set(v,I(v));return g;function I(v){let T=l.get(v);if(T&&(T.size!==1||T.has(Ts)))return{kind:"unknown",reason:"several-outputs"};let A=T?T.values().next().value:null;if(A&&(A.nodeType!==1||!w.has(A)))return{kind:"unknown",reason:"output-not-placed"};if(!A){let R=m(v)?"decided":f(v);if(R==="kept")return{kind:"untouched"};if(R!=="decided")return{kind:"unknown",reason:"unmapped"}}let E=[],N=M(v,!!A&&(p.has(v)||b.has(v)),!A||m(v));if(N)return{kind:"unknown",reason:N};return A?{kind:"single",output:A,owned:E,carried:b.has(v)}:{kind:"removed"};function M(R,V,D){for(let j=ir(R).firstChild;j;j=j.nextSibling){if(j.nodeType===1?h(j):j.nodeType!==3&&j.nodeType!==8)continue;let y=l.get(j);if(y)for(let k of y){if(k===Ts||!w.has(k))return"output-not-placed";if(!A)return"survives-elsewhere";if(!C(k,A))return"escaped";E.push(k)}else if(!V&&!D&&!m(j)&&!u.has(j))return"unmapped";if(j.nodeType===1){let k=M(j,V||p.has(j)||b.has(j),D||m(j));if(k)return k}}return null}}}function cr(e,o){if(!o)return!1;let t=o.nodeType===1&&o.tagName==="TEMPLATE"?[o,...o.querySelectorAll("template")]:[...o.querySelectorAll("template")];for(let n of t)if(n.content.contains(e)||cr(e,n.content))return!0;return!1}function fr(e,o){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let t=[],n=new Set;for(let s of Array.from(e.elements)){if(!s||s.nodeType!==1||s.ownerDocument!==o&&!cr(s,o.documentElement))throw new TypeError("lineage.elements must be elements of the live document");n.has(s)||(n.add(s),t.push(s))}return t}var ur=new WeakMap;function dr(e){let o=new Map;for(let t of e){let n=[],s=!1;(function h(l){l.nodeType===1&&l.namespaceURI==="http://www.w3.org/1999/xhtml"&&l.localName==="template"&&(s=!0);for(let r=l.firstChild;r;r=r.nextSibling)n.push(r),r.nodeType===1&&h(r)})(t),o.set(t,{nodes:n,opaque:s})}return o}function vs(e,o,t){if(e.lineage===void 0)return t(e);if(!o||o.nodeType!==1)throw new TypeError("lineage requires an element root");let n=e.lineage,s=fr(n,o.ownerDocument),h=!1,l={...e,lineage:{elements:s,onResult(r,i){if(!h)return h=!0,n.onResult(r,i)}}};try{return ur.set(l.lineage,dr(s)),t(l)}catch(r){if(!h){h=!0;try{n.onResult({version:1,root:o,status:"incomplete",entries:s.map(An)},null)}catch{}}throw r}}function Ss(e,{liveRoot:o,localRoot:t,toLive:n}){let s=fr(e,o.ownerDocument),h=u=>u===o||o.contains(u),l=new Map,r=new Set(s.filter(h));if(r.size&&t===o)for(let u of r)l.set(u,u);else r.size&&(function u(w){let c=n(w);r.delete(c)&&l.set(c,w);for(let p=w.firstElementChild;p&&r.size;p=p.nextElementSibling)u(p)})(t);return{spec:e,watched:s,root:o,locals:Array.from(new Set(l.values())),before:ur.get(e)||dr(s),delivered:!1,result:null,finish(u,w){return this.resolve=w,this.plans=u,this.result={version:1,root:this.root,status:"complete",entries:s.map(c=>Hi(c,l.get(c),u,w,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(u,w){this.root=w;let c=this.resolve,p=S=>{let C=c(S);return C===u?w:C};return this.finish(this.plans,p)},deliver(u){this.delivered||(this.delivered=!0,e.onResult(this.result,u))}}}var An=e=>({from:e,to:[],kind:"unknown",complete:!1});function Hi(e,o,t,n,s){let h=s.root,l=p=>!!p&&(p===h||h.contains(p)),r=o&&t?t.get(o):null;if(!r||r.kind==="unknown")return An(e);let i=s.before.get(e);if(!i||i.opaque)return An(e);let u=i.nodes,w=p=>l(p)||!!(p&&p.ownerDocument===h.ownerDocument&&h.ownerDocument.documentElement?.contains(p));if(r.kind==="untouched"){if(!l(e))return An(e);for(let p of u)if(w(p)&&!e.contains(p))return An(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(r.kind==="removed")return w(e)||u.some(w)?An(e):{from:e,to:[],kind:"removed",complete:!0};let c=n(r.output);if(!c||c.nodeType!==1||!l(c)||c!==e&&w(e))return An(e);for(let p of u)if(w(p)&&!c.contains(p))return An(e);for(let p of r.owned){let b=n(p),S=Array.isArray(b)?b:[b];for(let C of S)if(!C||!l(C)||!c.contains(C))return An(e)}return r.carried&&!hr(c,r.output,n)?An(e):{from:e,to:[c],kind:c===e?"retained":"replaced",complete:!0}}function hr(e,o,t){for(let n=o.firstChild;n;n=n.nextSibling){let s=t(n),h=Array.isArray(s)?s:[s];for(let l of h)if(!l||!e.contains(l))return!1;if(n.nodeType===1&&!hr(e,n,t))return!1}return!0}function Ao(e,o,t){let n=Ss(e,{liveRoot:o,localRoot:o,toLive:s=>s});return n.result={version:1,root:o,status:"complete",entries:n.watched.map(s=>An(s))},t.lineage=n.result,n}function pr(e,o,t,n,s){if(!s(e.length*8+1))return null;let h=0,l=o===0,r=!1;for(let i of an(e,n)){if(!s(1))return null;if(h+=i.len,h===o&&(l=!0),h===t&&(r=!0),h>=t)break}return l&&r}function Wi(e,o,t,n,s,h,l){if(!l(o.length*2))return!1;let r=new Map,i=new Map,u=new Set;for(let w of o){let c=w.bs<w.be,p=c?t[w.ownerIndex].text.base:t[w.ownerIndex].text[e],b=c?w.bs:w.ss,S=c?w.be:w.se;if(!l((S-b)*4+1))return!1;for(;b<S&&/\s/.test(p[b]);)b++;for(;S>b&&/\s/.test(p[S-1]);)S--;if(b===S)continue;let C=p.slice(b,S),m=c?r:i;c&&w.text&&u.add(C),m.has(C)?m.set(C,null):m.set(C,{h:w,from:b,to:S})}for(let w of n){if(!l(1))return!1;if(w.side!==e)continue;let c=w.deletion,p=t[c.ownerIndex].text.base;if(!l((c.be-c.bs)*3)||u.has(p.slice(c.bs,c.be).trim()))return!1}for(let[w,c]of r){if(!l(w.length+1))return!1;let p=i.get(w);if(!c||!p)continue;let b=c.h,S=p.h;if(!b.text||b.transferOut||S.transferIn||b.owner===S.owner)continue;let C=t[b.ownerIndex],m=t[S.ownerIndex];if(!l(C.text.base.length))return!1;if(!/\S/.test(C.text.base.slice(0,b.bs)+C.text.base.slice(b.be)))continue;let f=pr(C.text.base,c.from,c.to,h,l),g=pr(m.text[e],p.from,p.to,h,l);if(f===null||g===null)return!1;if(!f||!g)continue;let I=`${C.index}:${c.from}:${c.to}`,v={key:I,side:e,source:b.owner,destination:S.owner,deletion:b,insertion:S,sourceOffset:c.from-b.bs,targetOffset:p.from-S.ss,length:c.to-c.from};b.transferOut=v,S.transferIn=v,s[e].set(I,v),n.push(v)}return!0}function mr({base:e,local:o,remote:t,localTwin:n,remoteTwin:s,eligible:h,nodes:l,budget:r=$t(2e4*32)}){let i=N=>N>r.remaining?!1:(r.remaining-=N,r.nativeSteps=(r.nativeSteps||0)+N,!0);if(e.length<2||o.length!==e.length||t.length!==e.length||!i(e.length*12))return null;for(let[N,M]of[["base",e],["local",o],["remote",t]]){let R=l[N];if(R.length!==M.length||R.some((V,D)=>V!==M[D]))return null}let u=[],w=0;for(let N=0;N<e.length;N++){let M=e[N],R=o[N],V=t[N];if(n(M)!==R||s(M)!==V)return null;let D={};for(let[j,y]of[["base",M],["local",R],["remote",V]]){if(!h(y)||y.tagName!==M.tagName||y.namespaceURI!==M.namespaceURI||!i(y.childNodes.length+1))return null;let k="";for(let J of y.childNodes){if(J.nodeType!==3||!i(J.data.length*4+1))return null;k+=J.data}if(k.includes(kt)||(w+=k.length+1,w>2e4))return null;D[j]=k}u.push({base:M,local:R,remote:V,index:N,text:D})}let c=u.every(N=>xn(N.text.base,N.text.local,N.text.remote)),p={local:[],remote:[]};for(let N of u){N.hunks={local:[],remote:[]};for(let M of["local","remote"]){let R=N.text.base,V=N.text[M];if(R===V)continue;let D=R.length+V.length+4,j=D*8;if(!i(j))return null;let y=Math.floor(r.remaining/8),k=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(D*D+y)-D)/2)));if(k<1||!i(4*(k+1)*(D+k+1)))return null;let J=0;for(let H of Yn(R,V,k)){if(!i(H.text.length+1))return null;let q=H.bs+J,Me={...H,ss:q,se:q+H.text.length,toks:an(H.text,c),owner:N.base,ownerIndex:N.index};N.hunks[M].push(Me),p[M].push(Me),J+=H.text.length-(H.be-H.bs)}}}let b=[],S={local:new Map,remote:new Map};for(let N of["local","remote"]){let M=new Map,R=new Map,V=!1,D=(j,y,k)=>{j.has(y)?j.set(y,null):j.set(y,k)};for(let j of p[N]){if(!i(1))return null;let y=u[j.ownerIndex].text.base;if(j.bs<j.be&&j.text===""){let k=y.slice(j.bs,j.be);if(!i(k.length*2))return null;/\S/.test(k)&&D(M,k,j)}else if(j.bs===j.be&&/\S/.test(j.text)){if(!i(j.text.length*2))return null;D(R,j.text,j)}else j.bs<j.be&&(V=!0)}for(let[j,y]of M){if(!i(j.length+1))return null;let k=R.get(j);if(!y||!k||y.owner===k.owner)continue;let J=u[y.ownerIndex];if(!i(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,y.bs)+J.text.base.slice(y.be)))continue;let H=`${J.index}:${y.bs}:${y.be}`,q={key:H,side:N,source:y.owner,destination:k.owner,deletion:y,insertion:k};y.transferOut=q,k.transferIn=q,S[N].set(H,q),b.push(q)}if(V&&R.size&&!Wi(N,p[N],u,b,S,c,i))return null}if(!b.length)return null;let C=(N,M)=>N.bs<M.be&&M.bs<N.be,m=N=>N.bs===N.be,f=(N,M)=>N.bs<=M.be&&M.bs<=N.be&&m(N)!==m(M),g=(N,M)=>N.bs===M.bs&&N.be===M.be&&N.text===M.text,I=(N,M)=>!!(N.transferIn||N.transferOut&&(!N.text||M.bs===N.be&&/\s/.test(M.text[0])||M.bs===N.bs&&/\s/.test(M.text[M.text.length-1])));for(let N of b){let M=N.side==="local"?"remote":"local",R=u[N.deletion.ownerIndex];for(let V of R.hunks[M])if(!i(1)||C(N.deletion,V)&&V.transferOut?.key!==N.key)return null}for(let N of u)for(let M of N.hunks.local)for(let R of N.hunks.remote){if(!i(1))return null;if(g(M,R)){if(M.transferIn?.key!==R.transferIn?.key)return null;continue}if(C(M,R)||f(M,R)&&!I(M,R)&&!I(R,M))return null}if(!i(w*8))return null;let v=new Set([...e,...o,...t]),T={base:nn(e,{blocks:v}),local:nn(o,{blocks:v}),remote:nn(t,{blocks:v})},A={};for(let N of["base","local","remote"]){let M=T[N];if(M.atoms.length||M.pins.length)return null;A[N]=new Map(M.marks.filter(R=>R.block).map(R=>[R.el,R.from]))}for(let N of u){let M=A.base.get(N.base);if(M===void 0)return null;for(let R of["local","remote"]){let V=A[R].get(N[R]);if(V===void 0)return null;for(let D of N.hunks[R])D.bs+=M,D.be+=M,D.ss+=V,D.se+=V}}for(let N of b)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 M=0,R=0,V=[];for(let j of p[N]){if(!i(1))return null;j.bs>M&&V.push({from:M,to:j.bs,target:R}),M=j.be,R=j.se}M<T.base.text.length&&V.push({from:M,to:T.base.text.length,target:R});let D=b.filter(j=>j.side===N).map(j=>({from:j.bs,to:j.be,target:j.ss,destination:j.destination}));if(E[N]=Dn({base:T.base,side:T[N],retained:V,transfers:D,budget:r}),E[N].status!=="ready")return null}return i(T.base.text.length)?{owners:u,blocks:v,transfers:b,byOrigin:S,budget:r,prepared:{base:T.base,local:T.local,remote:T.remote,lines:!1,baseTokens:an(T.base.text,c),localEdits:{hunks:p.local,respell:new Map},remoteEdits:{hunks:p.remote,respell:new Map},localMap:E.local,remoteMap:E.remote,full:null}}:null}var Ns=/\S/;function gr({certificates:e,scopes:o,views:t,eligible:n,baseId:s,limit:h=2e4*32}){let l=$t(h),r=Symbol(),i=[],u=c=>{if(c>l.remaining)throw r;l.remaining-=c},w=(c,p=null)=>{if(u(1),!c||c.nodeType!==1||c.parentNode?.nodeType!==1||!n(c))return null;for(let C=c.parentNode;C;C=C.parentNode)if(u(1),C.nodeType===11)return null;let b="",S=0;for(let C of c.childNodes){if(u(1),C.nodeType!==3)return null;if(u(C.data.length*4+1),p){let m=p.flat.nodes[S++];if(!m||m.node!==C||m.s!==b.length||m.e!==b.length+C.data.length)return null}b+=C.data}return u(b.length*3+1),p&&(p.flat.atoms.length||p.flat.pins?.length||S!==p.flat.nodes.length||p.flat.text!==b)?null:Ns.test(b)?b:null};try{u(o[0].length+o[1].length+o[2].length+e.length);let c=o.map(b=>new Set(b)),p=new Map;for(let b of e){u(1);let S=p.get(b.source);S||p.set(b.source,S=[]),S.push(b)}for(let b of p.values()){let S=[null,null],C=[];for(let m of b){u(1);let{source:f,target:g,side:I,models:v,runs:T}=m;if(I!==0&&I!==1||!c[0].has(f)||!c[I+1].has(g))continue;let{V:A,A:E,idOf:N}=t[I],M=t[1-I],R=A.twin(f),V=M.V.twin(f),D=A.baseOf(g);if(!R||!V||!D||D===f||!c[0].has(D)||!c[I+1].has(R)||!c[2-I].has(V)||E.map.get(f)!==R||E.reverse.get(R)!==f||M.A.map.get(f)!==V||M.A.reverse.get(V)!==f||E.map.get(D)!==g||E.reverse.get(g)!==D||g.parentNode!==R.parentNode||D.parentNode!==f.parentNode||f.tagName!==R.tagName||f.tagName!==V.tagName||s(f)!==N(R)||s(f)!==M.idOf(V)||s(D)!==N(g))continue;let j=v.get(f),y=v.get(g);if(!j||!y)continue;let k=w(f,j),J=w(g,y),H=w(R),q=w(V);if(u((k?.length||0)+(q?.length||0)),k===null||J===null||H===null||q===null||q===k)continue;let Me=T.length>0,Oe=!1;for(let ie of T){if(u(1),ie.source!==f||ie.target!==g||!Number.isInteger(ie.from)||!Number.isInteger(ie.to)||!Number.isInteger(ie.targetFrom)||ie.from<0||ie.to<=ie.from||ie.to>k.length||ie.targetFrom<0||ie.targetFrom+ie.to-ie.from>J.length){Me=!1;break}u((ie.to-ie.from)*3);for(let xe=ie.from;xe<ie.to;xe++){if(k[xe]!==J[ie.targetFrom+xe-ie.from]){Me=!1;break}Ns.test(k[xe])&&(Oe=!0)}if(!Me)break}if(!Me||!Oe)continue;let Re=S[I];Re||(u(k.length),Re=S[I]={source:f,side:I,flat:j.flat,before:k,covered:new Uint8Array(k.length)});for(let ie of T)u(ie.to-ie.from),Re.covered.fill(1,ie.from,ie.to)}for(let m of S){if(!m)continue;let{source:f,side:g,flat:I,before:v,covered:T}=m;u(v.length*3+1);let A=-1,E=-1;for(let N=0;N<=v.length;N++)N<v.length&&T[N]?(A<0&&(A=N),E=N+1):(N===v.length||Ns.test(v[N]))&&A>=0&&(C.push({source:f,side:g,flat:I,from:A,to:E}),A=E=-1)}u(C.length),i.push(...C)}}catch(c){if(c!==r)throw c}return{records:i,budget:l}}var qi="http://www.w3.org/1999/xhtml";function Ki(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function pn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===qi}function Fi(e){let o=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return o==="application/json"||o.endsWith("+json")}function _o(e,o){let t=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let s=t;try{let h=new URL(t,o);s=h.origin+h.pathname+h.search}catch{}return"script|src|"+n+"|"+s}return"script|inline|"+n+"|"+Ki(e.textContent.trim())}var _i={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function ho(e,o=[],t=!1){if(!pn(e)||e.hasAttribute("src"))return null;let n=[_i,...o];for(let s=0;s<n.length;s++){let h=n[s];if(!h.match(e))continue;if(!Fi(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=h.identity(e);return l==null||l===""?null:{key:s+":"+l,raw:l,recognizer:h}}return null}function br(e,o,t){let n=new Set,s=h=>{pn(h)&&!o(h)&&n.add(_o(h,t))};s(e);for(let h of e.querySelectorAll("script"))s(h);return n}function Mo(e,o){let t=o.createElement("div");t.innerHTML="<script><\/script>";let n=t.firstChild;for(let s of e.attributes)n.setAttribute(s.name,s.value);return n.textContent=e.textContent,n}function wr(e,o,t){let n=[],s=[],h=new Map,l=t.trackRecovery?new Set:null,r=Array.from(e.querySelectorAll("script"));pn(e)&&r.unshift(e);for(let i of r){if(!pn(i)||t.ignored(i)||t.skip.has(i)||o.has(_o(i,t.baseURI)))continue;let u=i.ownerDocument.createElement("script");for(let w of i.attributes)u.setAttribute(w.name,w.value);if(u.textContent=i.textContent,t.beforeNodeAdded(u)===!1){l?.add(i);continue}u.hasAttribute("src")&&s.push(new Promise(w=>{u.addEventListener("load",()=>w()),u.addEventListener("error",()=>w())})),i.replaceWith(u),h.set(i,u),t.afterNodeAdded(u),n.push(u)}return{executed:n,loads:s,swapped:h,vetoed:l}}function zi(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function $i(e,o){try{let t=new URL(e,o);return t.origin+t.pathname+t.search}catch{return e}}function yr(e,o){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return _o(e,o);if(t==="LINK"){let n=e.getAttribute("href");return n?"link|"+(e.getAttribute("rel")||"")+"|"+$i(n,o):e.outerHTML}if(t==="META"){for(let n of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(n))return"meta|"+n+"="+e.getAttribute(n);return e.outerHTML}return t==="STYLE"?"style|"+zi(e.textContent):e.outerHTML}function As(e,o){for(;;){for(;o<e.length&&/\s/.test(e[o]);)o++;if(e[o]==="/"&&e[o+1]==="/"){for(;o<e.length&&e[o]!==`
3
+ `))return!1;let A=H=>t.slice(v,T).map((q,Me)=>H.raw.get(v+Me)||q),E=[...g.toks,...A(S)],N=[...A(m),...I.toks],M=(H,q,Me)=>q>=0&&q+Me.length<=H.length&&Me.every((Oe,Re)=>H[q+Re].k===Oe.k),P=(H,q,Me)=>fs(H)&&t.slice(q,Me).some(Oe=>!Gn(Oe)),V=H=>H.some(q=>!Gn(q)),D,j,y,k;if(r(g)&&V(g.toks)&&M(N,0,g.toks)){let H=N.slice(g.toks.length);P(H,v,I.be)||(D=v,j=g.toks,y=N.slice(0,g.toks.length),k=[null,{bs:v,be:I.be,toks:H}])}if(D===void 0&&r(I)&&V(I.toks)){let H=E.length-I.toks.length,q=E.slice(0,H);M(E,H,I.toks)&&!P(q,g.bs,T)&&(D=T,j=E.slice(H),y=I.toks,k=[{bs:g.bs,be:T,toks:q},null])}if(D===void 0)return!1;let J=H=>H&&(H.bs<H.be||H.toks.length);return S.list.splice(C,1,...[k[0],{bs:D,be:D,toks:j}].filter(J)),m.list.splice(f,1,...[{bs:D,be:D,toks:y},k[1]].filter(J)),!0},p=l[0],b=l[1];for(let S=0;S<64;S++){let C=!1;e:for(let m=0;m<p.list.length;m++)for(let f=0;f<b.list.length;f++){let g=p.list[m],I=b.list[f];if(!(g.bs===I.bs&&g.be===I.be&&gs(g.toks,I.toks))){for(let v of[!0,!1]){let T=E=>v?E.be:E.bs,A=r(g)?[T(I),g.bs]:[T(g)];for(let E of A){let N=i(p,m,E,T),M=N&&i(b,f,E,T);if(!M)continue;let P=(k,J)=>v?k[k.length-1-J]:k[J],V=0;for(;V<N.length&&V<M.length&&P(N,V).k===P(M,V).k;)V++;if(!V)continue;let D=v?N.slice(0,N.length-V):N.slice(V),j=v?M.slice(0,M.length-V):M.slice(V);if(!(V<N.length&&V<M.length&&!fs(D)&&!fs(j)&&(r(g)&&r(I)||g.bs===I.bs&&g.be===I.be)||!(v?N.slice(N.length-V):N.slice(0,V)).some(k=>!Gn(k)))){if(V===N.length&&V===M.length&&r(g)&&r(I)){if(g.bs===E&&I.bs===E)continue;p.list[m]={bs:E,be:E,toks:N},b.list[f]={bs:E,be:E,toks:M}}else!r(g)&&g.bs===I.bs&&g.be===I.be?(w(p,m,N,V,v),w(b,f,M,V,v)):(u(p,m,N,V,v,E),u(b,f,M,V,v,E));C=!0;break e}}}if(c(p,m,b,f)||c(b,f,p,m)){C=!0;break e}}}if(!C)break}return[p.list,b.list]}var Ii=48,Ci=.3;function Li(e,o){let t=e.filter(l=>!Gn(l)),n=o.filter(l=>!Gn(l));if(Math.min(t.length,n.length)<Ii)return!1;let s=new Map;for(let l of t)s.set(l.k,(s.get(l.k)||0)+1);let h=0;for(let l of n){let r=s.get(l.k);r>0&&(h++,s.set(l.k,r-1))}return h/Math.min(t.length,n.length)<Ci}var Ei=(e,o)=>{let t=new Set;for(let n of e.toks)typeof n.k!="string"&&t.add(n.k.el);for(let n=e.bs;n<e.be;n++)typeof o[n].k!="string"&&t.add(o[n].k.el);return t},gs=(e,o)=>e.length===o.length&&e.every((t,n)=>t.k===o[n].k);function zs(e,o,t,n="remote"){let s=Wn(e,o),h=Wn(e,t),{lh:l,rh:r,cosL:i,cosR:u}=ms(s,h,e),w=x=>x.bs===x.be,c=x=>x.toks.some(Y=>typeof Y.k=="string"),p=x=>w(x)&&!c(x),b=(x,Y)=>Y.bs<x.be&&x.bs<Y.be,S=(x,Y)=>!b(x,Y)&&Y.bs<=x.be&&x.bs<=Y.be&&(w(x)&&c(x)||w(Y)&&c(Y))&&!(w(x)&&w(Y)),C=(x,Y)=>x.bs===Y.bs&&x.be===Y.be&&gs(x.toks,Y.toks),m=[],f=new Set;for(let x of l){let Y=r.find(ae=>!f.has(ae)&&C(x,ae));Y?(f.add(Y),m.push({bs:x.bs,be:x.be,side:"both",l:x,r:Y,toks:x.toks})):m.push({bs:x.bs,be:x.be,side:"L",l:x,toks:x.toks,lead:!!x.lead})}for(let x of r)f.has(x)||m.push({bs:x.bs,be:x.be,side:"R",r:x,toks:x.toks,lead:!!x.lead});m.sort((x,Y)=>x.bs-Y.bs||x.be-Y.be||Y.lead-x.lead);let g=0,I=0;for(let x of m)x.side==="both"&&(g+=x.toks.length-(x.be-x.bs));let v=m.map((x,Y)=>Y),T=x=>v[x]===x?x:v[x]=T(v[x]),A=(x,Y)=>(x=T(x),Y=T(Y),x===Y?!1:(v[x]=Y,!0)),E=m.map(x=>Ei({bs:x.bs,be:x.be,toks:x.toks},e)),N={L:new Map,R:new Map};m.forEach((x,Y)=>{let ae=x.side==="both"?["L","R"]:[x.side];for(let oe of ae)for(let Ee of E[Y])N[oe].has(Ee)||N[oe].set(Ee,[]),N[oe].get(Ee).push(Y)});for(let x of[N.L,N.R])for(let Y of x.values())for(let ae=1;ae<Y.length;ae++)A(Y[0],Y[ae]);for(let x=0;x<m.length;x++)for(let Y=x+1;Y<m.length;Y++){let ae=m[x],oe=m[Y];ae.side===oe.side&&ae.side!=="both"||ae.bs>oe.be||(b(ae,oe)||S(ae,oe)?A(x,Y):ae.bs===oe.bs&&w(ae)&&w(oe)&&I++)}let M=(x,Y)=>{let ae=x==="L"?l:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="close"&&Ee.k.el===Y.el))return oe.bs;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return-1};m.forEach((x,Y)=>{if(!(!p(x)||x.side==="both"))for(let ae of x.toks){if(ae.kind!=="open")continue;let oe=M(x.side,ae.k);if(oe<=x.bs)continue;let Ee=new Uint8Array(oe-x.bs),De=[];if(m.forEach((Ne,nt)=>{if(!(Ne.side===x.side||w(Ne))&&Ne.bs<oe&&Ne.be>x.bs){De.push(nt);for(let Xe=Math.max(Ne.bs,x.bs);Xe<Math.min(Ne.be,oe);Xe++)Ee[Xe-x.bs]=1}}),De.length&&Ee.every(Ne=>Ne===1))for(let Ne of De)A(Y,Ne)}});let P=!0;for(;P;){P=!1;let x=new Map;m.forEach((Y,ae)=>{let oe=T(ae),Ee=x.get(oe)||{bs:Y.bs,be:Y.be,L:!1,R:!1};Ee.bs=Math.min(Ee.bs,Y.bs),Ee.be=Math.max(Ee.be,Y.be),Y.side!=="R"&&(Ee.L=!0),Y.side!=="L"&&(Ee.R=!0),x.set(oe,Ee)}),m.forEach((Y,ae)=>{for(let[oe,Ee]of x){if(T(ae)===T(oe)||!(Ee.L&&Ee.R))continue;let De=Y.bs<Ee.be&&Y.be>Ee.bs,Ne=w(Y)&&c(Y)&&(Y.bs===Ee.be||Y.bs===Ee.bs);(De||Ne)&&A(ae,oe)&&(P=!0)}})}let V=new Map;m.forEach((x,Y)=>{let ae=T(Y);V.has(ae)||V.set(ae,[]),V.get(ae).push(x)});let D=[];for(let x of V.values()){let Y=x.some(oe=>oe.side==="L"),ae=x.some(oe=>oe.side==="R");if(Y&&ae){let oe=Math.min(...x.map(nt=>nt.bs)),Ee=Math.max(...x.map(nt=>nt.be)),De=x.filter(nt=>nt.side!=="R").map(nt=>nt.l).sort((nt,Xe)=>nt.bs-Xe.bs),Ne=x.filter(nt=>nt.side!=="L").map(nt=>nt.r).sort((nt,Xe)=>nt.bs-Xe.bs);D.push({bs:oe,be:Ee,kind:"conflict",localHunks:De,remoteHunks:Ne})}else for(let oe of x)D.push({bs:oe.bs,be:oe.be,kind:oe.side,u:oe})}let j=(x,Y)=>{let ae=x==="L"?l:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="close"&&Ee.k.el===Y.el))return oe.bs+.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return 1/0},y=(x,Y)=>{let ae=x==="L"?l:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="open"&&Ee.k.el===Y.el))return oe.bs-.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="open"&&e[oe].k.el===Y.el)return oe;return-1/0},k=x=>x.kind==="R"?"R":"L",J=x=>x.kind==="R"?1:0;D.sort((x,Y)=>{if(x.bs!==Y.bs)return x.bs-Y.bs;let ae=x.bs===x.be,oe=Y.bs===Y.be;if(ae!==oe)return ae?-1:1;if(ae&&oe&&x.kind!=="conflict"&&Y.kind!=="conflict"){let De=x.u.toks,Ne=Y.u.toks,nt=ht=>ht.length&&ht.every(Ge=>Ge.kind==="open"),Xe=ht=>ht.length&&ht.every(Ge=>Ge.kind==="close");if(nt(De)&&nt(Ne)){let ht=Math.max(...De.map(rt=>j(k(x),rt.k))),Ge=Math.max(...Ne.map(rt=>j(k(Y),rt.k)));if(ht!==Ge)return Ge-ht}if(Xe(De)&&Xe(Ne)){let ht=Math.min(...De.map(rt=>y(k(x),rt.k))),Ge=Math.min(...Ne.map(rt=>y(k(Y),rt.k)));return ht!==Ge?Ge-ht:J(Y)-J(x)}}let Ee=De=>De.u&&De.u.lead?1:0;return Ee(Y)-Ee(x)||J(x)-J(Y)||x.be-Y.be});let H=[],q=[],Me=0,Oe=x=>{x>Me&&(H.push({bs:Me,be:x,toks:e.slice(Me,x),source:"base"}),Me=x)};for(let x of D){if(Oe(x.bs),x.kind==="conflict"){let Y=ps(e,x.localHunks,x.bs,x.be),ae=ps(e,x.remoteHunks,x.bs,x.be),oe=n==="local"?Y:n==="both"?Y.concat(ae):ae,Ee=(nt,Xe)=>{let ht=0;for(let Ge of nt)Ge.be<=x.bs&&!Xe.includes(Ge)&&(ht+=Ge.toks.length-(Ge.be-Ge.bs));return ht},De=x.bs+Ee(l,x.localHunks),Ne=x.bs+Ee(r,x.remoteHunks);q.push({bs:x.bs,be:x.be,ls:De,le:De+Y.length,rs:Ne,re:Ne+ae.length,ms:0,me:0,base:e.slice(x.bs,x.be),local:Y,remote:ae,resolved:oe}),H.push({bs:x.bs,be:x.be,toks:oe,source:"conflict",localHunks:x.localHunks,localToks:Y,keepsLocal:n!=="remote"})}else H.push({bs:x.bs,be:x.be,toks:x.u.toks,source:x.kind==="R"?"remote":"local",localHunks:x.kind==="R"?[]:[x.u.l]});Me=Math.max(Me,x.be)}Oe(e.length);let Re=0,ie=0;for(let x of H)x.source==="conflict"&&(q[ie].ms=Re,q[ie].me=Re+x.toks.length,ie++),Re+=x.toks.length;let xe=new Map(i.map(x=>[x.bi,x.tok])),qe=new Map(u.map(x=>[x.bi,x.tok])),fe=[];for(let x of H){x.source==="base"&&(x.toks=x.toks.map((Y,ae)=>{let oe=x.bs+ae,Ee=xe.get(oe),De=qe.get(oe),Ne=Ee&&De?n==="remote"?De:Ee:Ee||De||Y;return Ne===Y?Y:{...Ne,cosmetic:!0}}));for(let Y of x.toks)fe.push({...Y,src:x.source})}return{tokens:fe,segments:H,conflicts:q,localHunks:l,remoteHunks:r,collapsedDelta:g,samePoint:I,mapLocalOffset:Ri(e,l,H)}}function ps(e,o,t,n){let s=[],h=t;for(let l of o)s=s.concat(e.slice(h,l.bs),l.toks),h=l.be;return s.concat(e.slice(h,n))}var ds=e=>e.reduce((o,t)=>o+t.len,0);function Ri(e,o,t){let n=new Int32Array(e.length+1);for(let l=0;l<e.length;l++)n[l+1]=n[l]+e[l].len;let s=o.map(l=>({bs:n[l.bs],be:n[l.be],text:l.toks.map(r=>r.raw).join(""),ref:l})),h=t.map(l=>({bs:n[l.bs],be:n[l.be],len:ds(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?ds(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let r=null,i=null,u=0,w=0,c=0;for(let b of s){let S=b.bs-c;if(l<=w+S){r=c+(l-w);break}if(w+=S,c=b.bs,l<=w+b.text.length){i=b,u=l-w,r=b.bs;break}w+=b.text.length,c=b.be}r===null&&(r=c+(l-w));let p=0;for(let b of h){if(!i&&r<=b.bs)return p;if(!(i?b.localHunks.includes(i.ref):r<b.be)){p+=b.len;continue}if(b.source==="base")return p+(r-b.bs);if(b.source==="remote")return p+b.len;if(b.source==="local")return p+Math.min(u,b.len);if(!b.keepsLocal||!i)return p+b.len;let C=b.localHunks.indexOf(i.ref),m=ds(ps(e,b.localHunks.slice(0,C),b.ref.bs,i.ref.bs));return p+Math.min(m+u,b.localLen)}return p}}function lo(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:f=>Math.min(f,o.length),granularity:"word"};let s=xn(e,o,t),h=an(e,s),l=an(o,s),r=an(t,s),i=h.length<=2e4&&l.length<=2e4&&r.length<=2e4?zs(h,l,r,n):null,u="word",w=h;if(!i){let f=g=>g.split(/(?<=\n)/).map(I=>({k:I,raw:I,len:I.length}));w=f(e),i=zs(w,f(o),f(t),n),u="line"}let c=f=>f.map(g=>g.raw).join(""),p=f=>{let g=[0];for(let I of f)g.push(g[g.length-1]+I.len);return g},b=p(w),S=null,C=null,m=null;if(i.conflicts.length){let f=g=>g.split(/(?<=\n)/).map(I=>({k:I,raw:I,len:I.length}));S=p(u==="line"?f(o):l),C=p(u==="line"?f(t):r),m=p(i.tokens)}return{text:c(i.tokens),conflicts:i.conflicts.map(f=>({bs:b[f.bs],be:b[f.be],ls:S[f.ls],le:S[f.le],rs:C[f.rs],re:C[f.re],ms:m[f.ms],me:m[f.me],base:c(f.base),local:c(f.local),remote:c(f.remote),resolved:c(f.resolved)})),mapLocalOffset:i.mapLocalOffset,granularity:u}}function Yn(e,o,t=4e3){if(e===o)return[];let n=xn(e,o),s=an(e,n),h=an(o,n),l=Wn(s,h,t),r=[0];for(let i of s)r.push(r[r.length-1]+i.len);return l.hunks.map(i=>({bs:r[i.bs],be:r[i.be],text:i.toks.map(u=>u.raw).join("")}))}function $t(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Dn({base:e,side:o,retained:t,transfers:n,baseAtomKey:s=r=>r.el,sideAtomKey:h=r=>r.el,budget:l=$t()}){let r=[],i=T=>({status:"fallback",reason:T}),u=T=>T>l.remaining?!1:(l.remaining-=T,!0);if(!u((t.length+n.length)*3))return i("work-limit");for(let[T,A]of[["retained",t],["transfer",n]])for(let E of A){let{from:N,to:M,target:P}=E;if(!Number.isInteger(N)||!Number.isInteger(M)||!Number.isInteger(P)||N<0||M<=N||M>e.text.length||P<0||P+M-N>o.text.length)return i("invalid-range");r.push({...E,kind:T})}let w=Symbol(),c=T=>(A,E)=>{if(!u(1))throw w;return l.sortComparisons++,T(A,E)},p,b;try{p=r.slice().sort(c((T,A)=>T.from-A.from||T.to-A.to)),b=r.slice().sort(c((T,A)=>T.target-A.target||T.to-T.from-(A.to-A.from)))}catch(T){if(T===w)return i("work-limit");throw T}if(!u(r.length*2))return i("work-limit");for(let T=1;T<p.length;T++)if(p[T].from<p[T-1].to)return i("source-overlap");for(let T=1;T<b.length;T++)if(b[T].target<b[T-1].target+b[T-1].to-b[T-1].from)return i("target-overlap");for(let T of p){let A=T.to-T.from;if(!u(A))return i("work-limit");for(let E=0;E<A;E++){let N=T.from+E,M=T.target+E;if(l.comparisons++,e.text[N]!==o.text[M])return i("unequal-occurrence");let P=e.atomAt.get(N),V=o.atomAt.get(M);if(!!P!=!!V||P&&s(P)!==h(V))return i("different-atom")}}let S=e.text.length+o.text.length+2,C=r.reduce((T,A)=>T+(A.to-A.from)*2,2);if(!u(S+C+r.length))return i("work-limit");let m=new Int32Array(e.text.length+1).fill(-1),f=new Int32Array(o.text.length+1).fill(-1);l.mapCells+=S,l.mapWrites+=C;let g=-1,I=!0;for(let T of p){T.target<g&&(I=!1),g=T.target+T.to-T.from;for(let A=0;A<T.to-T.from;A++)m[T.from+A]=T.target+A,f[T.target+A]=T.from+A}return m[e.text.length]=o.text.length,f[o.text.length]=e.text.length,{status:"ready",runs:p,bTo:m,toB:f,monotone:I,covers:(T,A)=>{if(!u(A-T))return null;l.coverageChecks+=A-T;for(let E=T;E<A;E++)if(e.text[E]!==kt&&!/\s/.test(e.text[E])&&m[E]<0)return!1;return!0}}}function bs({base:e,side:o,baseOf:t=()=>null,budget:n=$t()}){if(e.text===o.text||!e.text.includes(kt)&&!o.text.includes(kt))return{status:"none"};let s=(e.text.length+o.text.length)*8;if(s>n.remaining)return{status:"fallback",reason:"work-limit"};n.remaining-=s,n.boundarySteps=(n.boundarySteps||0)+s;let h=(S,C)=>C<S.length&&(S[C]===kt||/\s/.test(S[C])),l=new Map,r=Symbol(),i=(S,C)=>{let m=S.stackAt[C]||[];if(!l.has(m)){if(m.length>n.remaining)throw r;n.remaining-=m.length,n.boundarySteps+=m.length,l.set(m,m.find(f=>f.block)?.el||null)}return l.get(m)},u=[],w=(S,C)=>{let m=i(e,S),f=i(o,C),g=m&&f&&t(f)!==m?"transfer":"retained",I=u[u.length-1];I&&I.to===S&&I.target+I.to-I.from===C&&I.kind===g&&I.destination===f?I.to++:u.push({from:S,to:S+1,target:C,destination:f,kind:g})},c=0,p=0,b=!1;try{for(;c<e.text.length||p<o.text.length;){if(c<e.text.length&&p<o.text.length&&e.text[c]===o.text[p]){let I=e.atomAt.get(c),v=o.atomAt.get(p);if(!!I!=!!v||I&&t(v.el)!==I.el)return{status:"none"};w(c++,p++);continue}if(!h(e.text,c)&&!h(o.text,p))return{status:"none"};let S=c,C=p;for(;h(e.text,c);)c++;for(;h(o.text,p);)p++;let m=e.text.slice(S,c),f=o.text.slice(C,p);(m.includes(kt)||f.includes(kt))&&(b=!0);let g=0;for(;g<c-S&&g<p-C&&e.text[c-g-1]===o.text[p-g-1];)g++;for(let I=g;I>0;I--)w(c-I,p-I)}}catch(S){if(S===r)return{status:"fallback",reason:"work-limit"};throw S}return b?Dn({base:e,side:o,retained:u.filter(S=>S.kind==="retained"),transfers:u.filter(S=>S.kind==="transfer"),sideAtomKey:S=>t(S.el)||S.el,budget:n}):{status:"none"}}var $s=/\s/,Vo=/\S/;function In(e,o,t,n,s,h,l=-1,r=-1){if(!e.length)return-1;s(n,e.length);let i=new Int32Array(e.length),u=0;for(let b=1;b<e.length;b++){for(s(n,1);u&&(s(n,1),e[u]!==e[b]);)u=i[u-1];s(n,1),e[u]===e[b]&&u++,i[b]=u}let w=-1,c=0,p=0;u=0;for(let b=0;b<o.length;b++){for(s(n,1);u&&(s(n,1),e[u]!==o[b]);)u=i[u-1];if(s(n,1),e[u]===o[b]&&u++,u!==e.length)continue;let S=b+1-e.length,C=b+1;for(u=i[u-1];c<t.length&&t[c].from<S;)s(n,1),c++;for(;p<t.length&&t[p].to<C;)s(n,1),p++;if(s(n,6),!(c===t.length||p===t.length||t[c].from!==S||t[p].to!==C||l>=0&&S<r&&C>l)){if(!h)return S;if(w>=0)return-1;w=S}}return w}function No(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function ws(e,o,t,n){let s=null;for(let l of o)if(n(t,1),!(l.source!==e.source||l.side!==e.side))for(let r of l.runs){if(n(t,1),r.source!==e.source)continue;let i=Math.max(e.from,r.from),u=Math.min(e.to,r.to);i>=u||(s||(n(t,e.to-e.from),s=new Uint8Array(e.to-e.from)),n(t,u-i),s.fill(1,i-e.from,u-e.from))}if(!s)return!1;n(t,e.to-e.from);let h=!1;for(let l=e.from;l<e.to;l++)if(Vo.test(e.flat.text[l])){if(!s[l-e.from])return!1;h=!0}return h}function ys({source:e,side:o,views:t,eligible:n,blocked:s,baseId:h,model:l,tokensOf:r,budget:i,charge:u}){let{V:w,A:c,idOf:p}=t[o],b=t[1-o];if(e.nodeType!==1||c.identical.has(e)||b.A.identical.has(e)||s.has(e)||!n(e))return null;let S=w.twin(e),C=b.V.twin(e);if(!S||!C||c.map.get(e)!==S||c.reverse.get(S)!==e||b.A.map.get(e)!==C||b.A.reverse.get(C)!==e||!w.here(S)||!b.V.here(C)||!n(S)||!n(C))return null;let m=h(e);if(m!==p(S)||m!==b.idOf(C))return null;let f=l(e,null,i),g=l(S,c,i),I=l(C,b.A,i);if(!No(f)||!No(g)||!No(I))return null;let v=f.flat.text,T=g.flat.text;if(u(i,v.length+T.length*3),!Vo.test(T)||T.length>=v.length)return null;let A=v.startsWith(T),E=v.endsWith(T);if(A===E)return null;let N=A?T.length:0,M=A?v.length:v.length-T.length,P=N,V=M;for(;P<V&&(u(i,1),!!$s.test(v[P]));)P++;for(;V>P&&(u(i,1),!!$s.test(v[V-1]));)V--;if(P===V)return null;let D=r(f,i),j=!1,y=!1;for(let k of D)u(i,1),k.from===P&&(j=!0),k.to===V&&(y=!0);return!j||!y?null:{source:e,side:o,flat:f.flat,from:N,to:M}}function Gs({base:e,views:o,side:t,attempt:n,eligible:s,blocked:h,baseId:l,model:r,tokensOf:i,certificates:u,charge:w,exhausted:c,limit:p}){if(p<=0)return null;let b=$t(p),{V:S,A:C,idOf:m}=o[t],f=o[1-t],[g,I,v,T]=n,A=null;try{for(let E=g;E<=I;E++){w(b,1);let N=e[E];if(N.nodeType!==1||C.identical.has(N)||f.A.identical.has(N)||h.has(N)||!s(N))continue;let M=ys({source:N,side:t,views:o,eligible:s,blocked:h,baseId:l,model:r,tokensOf:i,budget:b,charge:w});if(!M||ws(M,u,b,w))continue;let{flat:P,from:V,to:D}=M;w(b,(D-V)*2);let j=P.text.slice(V,D).trim();for(let y=v;y<=T;y++){w(b,1);let k=S.units[y],J=S.baseOf(k);if(!J||J===N||J.nodeType!==1||k.nodeType!==1||J.parentNode!==N.parentNode||k.parentNode!==C.map.get(N).parentNode||C.map.get(J)!==k||C.reverse.get(k)!==J||h.has(J)||!s(J)||!s(k)||l(J)!==m(k))continue;let H=r(J,null,b),q=r(k,C,b);if(!No(H)||!No(q))continue;let Me=H.flat.text,Oe=q.flat.text;if(w(b,Me.length),!Vo.test(Me)||Oe.length<=Me.length)continue;let Re=i(q,b),ie=In(Me,Oe,Re,b,w,!0);if(!(ie<0)&&!(In(j,Oe,Re,b,w,!1,ie,ie+Me.length)<0)){(A||=[]).push(M);break}}}}catch(E){if(E!==c)throw E}return A}function Ys(e,o,t,n,s,h,l){if(h==="both"||t.atoms.length||n.atoms.length||s.atoms.length)return h;let r=h==="remote";if(r?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 h;for(let i of e){if(i.source!==o||i.side!==(r?1:0)||i.flat.text!==t.text||i.flat.nodes.length!==t.nodes.length||l.be<=i.from||l.bs>=i.to)continue;let u=!0;for(let c=0;c<t.nodes.length;c++){let p=i.flat.nodes[c],b=t.nodes[c];if(p.node!==b.node||p.s!==b.s||p.e!==b.e){u=!1;break}}if(!u)continue;let w=!1;for(let c=l.bs;c<l.be;c++)if(Vo.test(t.text[c])){if(c<i.from||c>=i.to){u=!1;break}w=!0}if(u&&w)return r?"local":"remote"}return h}var Un="\uFFFC";var Pi={caret:0},Tn=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(" ")),or=new Set(["BR","WBR","IMG"]),ks=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function Vn(e,o={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(o.ignored&&o.ignored(e)||or.has(e.tagName))return!0;if(!Tn.has(e.tagName))return!ks.has(e.tagName);if(o.remoteWins&&o.remoteWins(e))return!1;let t=o.inlineCache&&o.inlineCache.get(e);if(t!==void 0)return t;let n=!0;for(let s of e.childNodes)if(!Vn(s,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Bi(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function nn(e,o={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},n=(s,h)=>{for(let l of s){if(l.nodeType===3){let c=l.nodeValue;if(!c)continue;t.nodes.push({node:l,s:t.text.length,e:t.text.length+c.length}),t.text+=c;for(let p=0;p<c.length;p++)t.stackAt.push(h);continue}if(l.nodeType!==1)continue;if(o.ignored&&o.ignored(l)){t.pins.push({el:l,i:t.text.length});continue}if(o.skip&&o.skip.has(l))continue;let r=o.via&&o.via(l)||l;r!==l&&(t.via||(t.via=new Map)).set(r,l);let i=l.tagName;if(o.blocks&&o.blocks.has(l)){t.text.length&&t.text[t.text.length-1]!==kt&&(t.stackAt.push(h),t.text+=kt);let c={el:l,tag:i,from:t.text.length,to:-1,depth:h.length,block:!0};t.marks.push(c);let p=h.concat([c]);n(r.childNodes,p),t.stackAt.push(p),t.text+=kt,c.to=t.text.length;continue}let u=Tn.has(i)&&Bi(r);if(or.has(i)||!Tn.has(i)||o.remoteWins&&o.remoteWins(l)||o.atomize&&o.atomize(l)||u){t.atoms.push({i:t.text.length,el:l,key:u?i+":empty":i,stack:h}),t.stackAt.push(h),t.text+=Un;continue}let w={el:l,tag:i,from:t.text.length,to:-1,depth:h.length};t.marks.push(w),n(r.childNodes,h.concat([w])),w.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&qo(t).trim()===""){let s=t.atoms[0];t.placeholder=s.el,t.text=t.text.slice(0,s.i)+t.text.slice(s.i+1),t.stackAt.splice(s.i,1);for(let h of t.nodes)h.s>s.i&&(h.s--,h.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(s=>[s.i,s])),t}function ji(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Di(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,"&quot;")}"`;return o+">"}function co(e,o,t){let n="",s=[];for(let h=o;h<t;h++){let l=e.stackAt[h],r=0;for(;r<s.length&&r<l.length&&s[r]===l[r];)r++;for(;s.length>r;)n+=`</${s.pop().tag.toLowerCase()}>`;for(;s.length<l.length;){let u=l[s.length];n+=Di(u.el),s.push(u)}let i=e.atomAt.get(h);n+=i?i.el.outerHTML:e.text[h]===kt?"":ji(e.text[h])}for(;s.length;)n+=`</${s.pop().tag.toLowerCase()}>`;return n}function Ui(e,o){let t=[...e.el.attributes].filter(n=>!o(e.el,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tag+"|"+t}function sr(e,o){let t=[...e.attributes].filter(n=>!o(e,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function Xs(e,o=()=>!1){let t=new Map,n=h=>{let l=t.get(h);return l===void 0&&(l="{"+h.map(r=>Ui(r,o)).sort().join(",")+"}",t.set(h,l)),l},s="";for(let h=0;h<e.text.length;h++){let l=e.atomAt.get(h);s+=(l?"["+sr(l.el,o)+"]":e.text[h])+n(e.stackAt[h])}return e.text.length===0&&e.placeholder&&(s+="[br]"),s}function ao(e,o,t,n=s=>s.key){let s=[],h=e.text,l=0,r=i=>{if(i<=l)return;let u=h.slice(l,i);if(t)for(let w of u.split(/(?<=\n)/))s.push({k:w,raw:w,len:w.length});else for(let w of an(u,o))s.push(w)};for(let i of e.atoms)r(i.i),s.push({k:"\0"+n(i),raw:Un,len:1,atom:!0}),l=i.i+1;return r(h.length),s}function qo(e){if(!e.atoms.length)return e.text;let o="",t=0;for(let n of e.atoms)o+=e.text.slice(t,n.i),t=n.i+1;return o+e.text.slice(t)}var fo=e=>{let o=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)o[t+1]=o[t]+e[t].len;return o};function Ho(e,o,t,n){let s=fo(o),h=fo(t),l=[],r=0,i=0;for(let w of n.hunks){i+=w.bs-r;let c=i+w.toks.length;l.push({bs:s[w.bs],be:s[w.be],ss:h[i],se:h[c],text:e.text.slice(h[i],h[c]),toks:w.toks,lead:!!w.lead}),i=c,r=w.be}let u=new Map;for(let w of n.cosmetic)u.set(w.bi,w.tok.raw);return{hunks:l,respell:u}}function Js(e,o,t){let n=l=>l===kt||/\s/.test(l),s=l=>l.replace(/[\u001E\s]/g,""),h=[];for(let l of e){let r=o.slice(l.bs,l.be),i=t.slice(l.ss,l.se);if(!r.includes(kt)&&!i.includes(kt)||r.includes(Un)||i.includes(Un)||s(r)!==s(i)){h.push(l);continue}let u=0,w=0;for(;;){let c=u,p=w;for(;c<r.length&&n(r[c]);)c++;for(;p<i.length&&n(i[p]);)p++;let b=u,S=w;for(;b<c&&S<p&&r[b]===i[S];)b++,S++;let C=c,m=p;for(;C>b&&m>S&&r[C-1]===i[m-1];)C--,m--;if(C>b||m>S){let f=i.slice(S,m);h.push({bs:l.bs+b,be:l.bs+C,ss:l.ss+S,se:l.ss+m,text:f,toks:[...f].map(g=>({k:g,raw:g,len:1})),lead:l.lead})}if(c>=r.length)break;u=c+1,w=p+1}}return h}function Qs(e,o,t){let n=new Int32Array(o+1).fill(-1),s=new Int32Array(t+1).fill(-1),h=0,l=0,r=i=>{for(;h<i;)n[h]=l,s[l]=h,h++,l++};for(let i of e)r(i.bs),h=i.be,l=i.se;return r(o),n[o]=l,s[l]=o,{bTo:n,toB:s}}function Zs(e,o,t){let n=[],s=0,h=0,l=(r,i)=>{if(s===r&&h===i)return;let u=o.text.slice(h,i);n.push({bs:s,be:r,ss:h,se:i,text:u,toks:an(u,xn(u)),lead:!1})};for(let r of t.runs)l(r.from,r.target),s=r.to,h=r.target+r.to-r.from;return l(e.text.length,o.text.length),{hunks:n,respell:new Map}}function er(e,o,t,n){let s=fo(o),h=fo(t),l=(i,u)=>{let w=0,c=i.length;for(;w<c;){let p=w+c>>>1;i[p]<u?w=p+1:c=p}return i[w]===u?w:-1};for(let i of e.hunks)if(l(s,i.bs)<0||l(s,i.be)<0)return null;if(e.hunks.some(i=>l(h,i.ss)<0||l(h,i.se)<0)){if(!n)return null;let i=[];for(let p of e.hunks)i.push(p.ss,p.se);let u=[],w=0,c=0;for(let p of t){let b=c+p.len;for(;w<i.length&&i[w]<=c;)w++;let S=c;for(;w<i.length&&i[w]<b;){let C=i[w++];if(C>S){let m=p.raw.slice(S-c,C-c);u.push(...an(m,xn(m))),S=C}}if(S===c)u.push(p);else{let C=p.raw.slice(S-c);u.push(...an(C,xn(C)))}c=b}t=u,h=fo(t)}let r=[];for(let i of e.hunks){let u=l(s,i.bs),w=l(s,i.be),c=l(h,i.ss),p=l(h,i.se);if(u<0||w<0||c<0||p<0)return null;r.push({bs:u,be:w,toks:t.slice(c,p),gap:[],group:r.length})}return{parts:r,cosmeticEq:[],tokens:t}}function xs(e,o,t,n={},s=null){return rr(e,o,t,n.base,n.local,n.remote,s,{})}function rr(e,o,t,n,s,h,l,r){let i=xn(qo(e),qo(o),qo(t)),u=ao(e,i,!1,n),w=ao(o,i,!1,s),c=ao(t,i,!1,h),p=u.length>2e4||w.length>2e4||c.length>2e4;p&&(u=ao(e,i,!0,n),w=ao(o,i,!0,s),c=ao(t,i,!0,h));let b=l?.local?Zs(e,o,l.local):null,S=l?.remote?Zs(e,t,l.remote):null,C=b?er(b,u,w,!p):Wn(u,w),m=S?er(S,u,c,!p):Wn(u,c);b&&C&&(w=C.tokens),S&&m&&(c=m.tokens);let f,g;if(C&&m){let I=ms(C,m,u);f=Ho(o,u,w,{hunks:I.lh,cosmetic:I.cosL}),g=Ho(t,u,c,{hunks:I.rh,cosmetic:I.cosR})}else f=b||Ho(o,u,w,C),g=S||Ho(t,u,c,m);return f.hunks=Js(f.hunks,e.text,o.text),g.hunks=Js(g.hunks,e.text,t.text),r.base=e,r.local=o,r.remote=t,r.lines=p,r.baseTokens=u,r.localEdits=f,r.remoteEdits=g,r.localMap=Qs(f.hunks,e.text.length,o.text.length),r.remoteMap=Qs(g.hunks,e.text.length,t.text.length),r.full=null,r}function tr(e,o){if(e.size!==o.size)return!1;for(let t of e)if(!o.has(t))return!1;return!0}var uo=/\s/;function Wo(e,o,t){for(let n=o;n<t;n++)if(!uo.test(e[n]))return!1;return!0}function Vi(e,o,t){let n=e.cache[t]||(e.cache[t]=new Map);if(n.has(o))return n.get(o);let s=t===0?"local":"remote",h=t===0?"remote":"local",l=o.baseMark,r=o[h+"Mark"],i=!o.block&&!o[s]&&!!r&&l.to>l.from;if(i){let u=t===0?e.ML:e.MR,w=t===0?e.MR:e.ML,c=t===0?e.fr:e.fl,p=!1;for(let b=l.from;b<l.to;b++){if(u.bTo[b]>=0){i=!1;break}w.bTo[b]<0&&!uo.test(e.fb.text[b])&&(p=!0)}if(i&&!p){for(let b=r.from;b<r.to;b++)if(w.toB[b]<0&&!uo.test(c.text[b])){p=!0;break}}i&&=p}return n.set(o,i),i}function nr(e,o,t,n,s,h,l,r,i){let u=r===0?e.fl:e.fr,w=null;for(let c=t;c<n;c++){let p=o[c];if(!Wo(u.text,p.ss,p.se))return null;if(Wo(e.fb.text,p.bs,p.be)){if(p.bs<p.be&&p.ss<p.se||uo.test(e.fb.text[p.bs-1]||"")||uo.test(e.fb.text[p.be]||""))continue;return null}let b=!1;for(let S=p.bs;S<p.be;S++){if(uo.test(e.fb.text[S]))continue;let C=null;for(let m of e.fb.stackAt[S]){let f=e.byEl.get(m.el);if(f&&Vi(e,f,r)){C=f;break}}if(!C)return null;(w||(w=new Set)).add(C),b=!0}if(!b)return null}if(!w){if((r===0?"local":"remote")!==i)return null;let c=r===0?e.fr:e.fl,p=!1;for(let b=h;b<l;b++){let S=s[b];if(!Wo(e.fb.text,S.bs,S.be))return null;Wo(c.text,S.ss,S.se)||(p=!0)}if(!p)return null}return w||0}function Ko(e){let{out:o,policy:t="remote",L:n,R:s}=e,h=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,r=e.conflicts||[],i=e.decisions||[],u=r.length,w=e.conflict||(d=>r.push(d)),c={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},p=[],b=!!(n&&n.reverse&&n.map&&s&&s.reverse&&s.map),S={base:null,local:null,remote:null};if(!e.prepared&&b&&e.moveIn){let d=Se=>je=>Se.some(Le=>Le===je||Le.nodeType===1&&Le.contains(je)),B=d(e.local),F=d(e.remote),_=d(e.base),Q=new Set,me=Se=>{if(!Tn.has(Se.tagName))return;let je=n.map.get(Se),Le=s.map.get(Se);(je&&!B(je)||Le&&!F(Le))&&Q.add(Se);for(let Ue of Se.children)me(Ue)};for(let Se of e.base)Se.nodeType===1&&me(Se);let ke=Se=>je=>{if(!Tn.has(je.tagName))return!1;let Le=Se.reverse.get(je);return!!Le&&(Q.has(Le)||!_(Le))};Q.size&&(S.base=Se=>Q.has(Se)),S.local=ke(n),S.remote=ke(s)}let C={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&b&&e.moveIn){let d=_=>Q=>_.some(me=>me===Q||me.nodeType===1&&me.contains(Q)),B=d(e.local),F=d(e.remote);for(let _ of nn(e.base,{...e,atomize:S.base}).atoms){let Q=n.map.get(_.el),me=s.map.get(_.el),ke=!!Q&&!B(Q),Se=!!me&&!F(me);!ke&&!Se||(ke&&e.movePlanned?.(_.el,"local",Q,null),Se&&e.movePlanned?.(_.el,"remote",me,null),C.base.add(_.el),Q&&!ke&&C.local.add(Q),me&&!Se&&C.remote.add(me),B(_.el)&&C.local.add(_.el),F(_.el)&&C.remote.add(_.el))}}let m=e.prepared?.base||nn(e.base,{...e,atomize:S.base,skip:C.base}),f=e.prepared?.local||nn(e.local,{...e,atomize:S.local,skip:C.local}),g=e.prepared?.remote||nn(e.remote,{...e,atomize:S.remote,skip:C.remote}),I=new Map(m.atoms.map(d=>[d.el,d])),v={},T=d=>e.prepared?e.prepared.full?.(d)||null:C[d].size?(v[d]||(v[d]=nn(e[d],{...e,atomize:S[d]})),v[d]):null,A=(d,B,F)=>{B.namespaceURI?d.setAttributeNS(B.namespaceURI,B.name,F):d.setAttribute(B.name,F)},E=(d,B,F,_)=>{if(!B&&(!F||!_)){for(let me of(F||_).attributes)A(d,me,me.value);return}let Q=new Map;for(let me of[B,F,_])if(me)for(let ke of me.attributes)Q.set(ke.name,ke);for(let[me,ke]of Q){let Se=B?B.getAttribute(me):null,je=F?F.getAttribute(me):Se,Le=_?_.getAttribute(me):Se,Ue;je===Le?Ue=je:je===Se?(Ue=Le,i.push({kind:"attr",el:d,name:me,source:"remote"})):Le===Se?(Ue=je,i.push({kind:"attr",el:d,name:me,source:"local"})):(Ue=t==="local"?je:Le,w({kind:"attr",el:d,name:me,base:Se,local:je,remote:Le,resolved:Ue},{el:d,sample:ke}),i.push({kind:"attr",el:d,name:me,source:"both"})),Ue!=null&&A(d,ke,Ue)}},N=(d,B,F,_)=>d&&e.mergeAttrs?e.mergeAttrs(d,B,F,_):E(_,d,B,F),M=e.mergeElement||((d,B,F)=>{let _=o.createElement(d.tagName);N(d,B,F,_);let Q=B||d,me=F||d,ke=t==="local"?Q.isEqualNode(d)?me:Q:me.isEqualNode(d)?Q:me;for(let Se of ke.childNodes)_.appendChild(o.importNode(Se,!0));return h.set(_,{base:d,local:B,remote:F}),_}),P=e.cloneUnit||((d,B)=>{let F=o.importNode(d,!0);return h.set(F,{base:null,local:B==="local"?d:null,remote:B==="remote"?d:null}),F}),V=e.atomKey||(d=>sr(d,()=>!1)),D=(d,B)=>{let F=new Map;for(let _ of d.atoms)if(e.remoteWins&&e.remoteWins(_.el)&&Tn.has(_.el.tagName))F.set(_,"w"+_.el.tagName+"#"+(_.el.id||""));else if(!b)F.set(_,_.key);else if(d===m)F.set(_,"="+V(_.el));else{let Q=B.reverse.get(_.el),me=Q?I.get(Q):null;me?F.set(_,"="+V(me.el)):Q?F.set(_,"m"+V(_.el)):F.set(_,"="+V(_.el))}return _=>F.get(_)},j=D(m,null),y=D(f,n),k=D(g,s),J=e.certifiedOrigins?e.certifiedOrigins(m,f,g,j,y,k):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let d=$t(),B=bs({base:m,side:f,baseOf:_=>n?.reverse?.get(_)||null,budget:d}),F=bs({base:m,side:g,baseOf:_=>s?.reverse?.get(_)||null,budget:d});(B.status==="ready"||F.status==="ready")&&(J={local:B.status==="ready"?B:null,remote:F.status==="ready"?F:null})}let H=e.prepared||rr(m,f,g,j,y,k,J,c),q=H.lines,Me=H.baseTokens,Oe=H.localEdits,Re=H.remoteEdits,ie=H.localMap,xe=H.remoteMap,qe=m.text.length,fe=d=>new Map(d.atoms.map(B=>[B.el,B])),x=fe(f),Y=fe(g),ae=(d,B,F)=>{let _=new Set;if(!b)return _;for(let Q of d.atoms){let me=I.get(B.reverse.get(Q.el));me&&F.bTo[me.i]<0&&_.add(me)}return _},oe=ae(f,n,ie),Ee=ae(g,s,xe),De=d=>!Vn(d,{...e,remoteWins:null}),Ne=new Set;if(b)for(let d of m.atoms){if(!De(d.el))continue;let B=n.map.get(d.el)||null,F=s.map.get(d.el)||null,_=B&&!F?B:F&&!B?F:null;_&&(x.has(_)||Y.has(_))&&!_.isEqualNode(d.el)&&Ne.add(d)}let nt=1,Xe=(d,B)=>({id:nt++,tag:d,base:null,local:null,remote:null,rank:B}),ht=new Map,Ge=[];for(let d of m.marks){let B=Xe(d.tag,d.depth);B.block=!!d.block,B.base=d.el,B.baseMark=d,ht.set(d.el,B),Ge.push(B)}let rt=(d,B)=>{let F=-1,_=-1;for(let Q=d.from;Q<d.to;Q++){let me=B[Q];me>=0&&(F<0&&(F=me),_=me+1)}return F<0?null:[F,_]},Ot=(d,B,F,_)=>{for(let Q of d.marks){let me=F?F.reverse.get(Q.el):null;me&&F.identical.has(me)&&F.pairIdenticalChildren&&F.pairIdenticalChildren(me);let ke=me?ht.get(me):null;if(ke&&ke[B]&&(ke=null),!ke){let Se=rt(Q,_),je=0;if(Se)for(let Le of Ge){if(Le.tag!==Q.tag||Le[B]||!!Le.block!=!!Q.block)continue;let Ue=Math.min(Se[1],Le.baseMark.to)-Math.max(Se[0],Le.baseMark.from);(Ue>je||Ue===je&&Ue>0&&Math.abs(Le.rank-Q.depth)<Math.abs(ke.rank-Q.depth))&&(ke=Le,je=Ue)}}ke||(ke=Xe(Q.tag,Q.depth),ke.block=!!Q.block,ke.new=B),ke[B]=Q.el,ke[B+"Mark"]=Q,ht.set(Q.el,ke)}};Ot(f,"local",n,ie.toB),Ot(g,"remote",s,xe.toB);let Ct=d=>d.merged||d,wt=d=>{let B=new Set;for(let F of d)F.block||B.add(ht.get(F.el));return B},Nt=new Map,Lt=d=>{let B=Nt.get(d);return B||(B=wt(d),Nt.set(d,B)),B},qt=(d,B)=>{let F=[],_=null;for(let Q=0;Q<qe;Q++){let me=B[Q];if(me<0){_&&F.push(_),_=null;continue}let ke=Lt(m.stackAt[Q]),Se=Lt(d.stackAt[me]),je=new Set,Le=new Set;for(let Ue of Se)ke.has(Ue)||je.add(Ue);for(let Ue of ke)Se.has(Ue)||Le.add(Ue);if(!je.size&&!Le.size){_&&F.push(_),_=null;continue}if(_&&tr(_.added,je)&&tr(_.removed,Le)){_.be=Q+1;continue}_&&F.push(_),_={bs:Q,be:Q+1,added:je,removed:Le}}return _&&F.push(_),F},cn=qt(f,ie.bTo),It=qt(g,xe.bTo),Gt=d=>d.be>d.bs?[d.bs,d.be-1]:[d.bs-1,d.bs],wn=(d,B)=>{if(qe===0)return null;let[F,_]=Gt(d);for(let Q of B){if(Q.be<=F)continue;if(Q.bs>_)break;let me=Q.bs<=F&&_<Q.be;return me&&d.text===""&&Q.bs===d.bs&&Q.be===d.be?"straddle":me?Q:d.be>d.bs?"straddle":null}return null},Dt=d=>d.bs===d.be,rn=(d,B,F=null)=>{let _=!1;for(let Q=d.bs;Q<d.be;Q++){let me=m.text[Q];if(me===kt)_=!0;else if(!/\s/.test(me))return!1}for(let Q=d.ss;Q<d.se;Q++){let me=B.text[Q];if(me===kt)_=!0;else if(!/\s/.test(me)){let ke=F&&e.scopeUnits&&Dt(d)&&B.atomAt.get(Q);if(!ke||!De(ke.el)||F.ss!==F.se||F.bs>=F.be)return!1;for(let je=F.bs;je<F.be;je++)if(!/\s/.test(m.text[je]))return!1;let Se=B===f?1:2;if(!e.scopeUnits[Se].includes(ke.el)||(Se===1?n:s)?.reverse.has(ke.el))return!1;_=!0}}return _},Yt=(d,B)=>d.bs<B.be&&B.bs<d.be,fn=(d,B)=>d.bs<=B.be&&B.bs<=d.be&&Dt(d)!==Dt(B),$=(d,B)=>m.text.slice(d.bs,d.be).includes(kt)||B.text.slice(d.ss,d.se).includes(kt),a=d=>{if(Dt(d))return!1;let B=d.bs,F=d.be;for(;B>0&&/\s/.test(m.text[B-1]);)B--;for(;F<m.text.length&&/\s/.test(m.text[F]);)F++;return(B===0||m.text[B-1]===kt)&&(F===m.text.length||m.text[F]===kt)},O=(d,B)=>!$(d,B)&&!a(d),R=(d,B)=>Yt(d,B)||fn(d,B)&&!(d.transferIn||d.transferOut||B.transferIn||B.transferOut)&&!(rn(d,f,B)&&O(B,g))&&!(rn(B,g,d)&&O(d,f)),K=(d,B)=>{if(d.bs!==B.bs||d.be!==B.be||d.toks.length!==B.toks.length)return!1;let F=d.ss,_=B.ss;for(let Q=0;Q<d.toks.length;Q++){let me=d.toks[Q],ke=B.toks[Q];if(me.k!==ke.k||me.atom&&!f.atomAt.get(F).el.isEqualNode(g.atomAt.get(_).el))return!1;F+=me.len,_+=ke.len}return!0},Z=(d,B,F,_)=>{for(let Q of m.atoms){if(Q.i<d.bs||Q.i>=d.be||_.has(Q)||Ne.has(Q))continue;let me=B.bTo[Q.i],ke=me>=0?F.atomAt.get(me):null;if(ke&&!ke.el.isEqualNode(Q.el))return!0}return!1},U=[],de=null,we=null,le=Oe.hunks,Ae=Re.hunks,W=0,X=0,pe=0,be=0,he=0,ee=d=>{d>pe&&(U.push({src:"base",from:pe,to:d,dL:be,dR:he}),pe=d)};for(;W<le.length||X<Ae.length;){let d=le[W],B=Ae[X],F=!!d&&(!B||d.bs<B.bs||d.bs===B.bs&&d.be<=B.be&&!B.lead);if(d&&B&&d.bs===B.bs&&Dt(d)&&Dt(B)){let _t=rn(d,f),So=rn(B,g);_t!==So&&(F=So)}let _=F?d:B,Q=F?B:d,me=!!Q&&K(d,B),ke=!!Q&&(F?!!le[W+1]&&K(le[W+1],B):!!Ae[X+1]&&K(d,Ae[X+1])),Se=!!Q&&!me&&!ke&&(qe===0||R(d,B)),je=Se,Le=wn(_,F?It:cn);if(Le==="straddle"&&(je=!0),!je&&_.be>_.bs&&(je=Z(_,F?xe:ie,F?g:f,F?oe:Ee)),!je&&me){ee(_.bs),U.push({src:"both",lfrom:d.ss,rfrom:B.ss,len:_.text.length,owner:d.owner||B.owner||null,transfer:d.transferIn||B.transferIn||null}),pe=_.be,be+=_.text.length-(_.be-_.bs),he+=_.text.length-(_.be-_.bs),W++,X++;continue}if(!je){ee(_.bs),U.push({src:F?"local":"remote",from:_.ss,to:_.se,inherit:Le&&Le!=="straddle"?Le:null,owner:_.owner||null,transfer:_.transferIn||null}),pe=_.be,F?(be+=_.text.length-(_.be-_.bs),W++):(he+=_.text.length-(_.be-_.bs),X++);continue}let Ue=_.bs,gt=_.be,at=W,dt=X,Vt=_t=>_t.bs<gt&&_t.be>Ue||Dt(_t)&&(_t.bs===Ue||_t.bs===gt);F?at++:dt++,Se&&(Ue=Math.min(Ue,Q.bs),gt=Math.max(gt,Q.be),F?dt++:at++);let Bt=!0;for(;Bt;){for(Bt=!1;at<le.length&&Vt(le[at]);)Ue=Math.min(Ue,le[at].bs),gt=Math.max(gt,le[at].be),at++,Bt=!0;for(;dt<Ae.length&&Vt(Ae[dt]);)Ue=Math.min(Ue,Ae[dt].bs),gt=Math.max(gt,Ae[dt].be),dt++,Bt=!0}let mn=Ue+be,ln=Ue+he,yn=gt-Ue,Nn=gt-Ue;for(let _t=W;_t<at;_t++)yn+=le[_t].text.length-(le[_t].be-le[_t].bs);for(let _t=X;_t<dt;_t++)Nn+=Ae[_t].text.length-(Ae[_t].be-Ae[_t].bs);let Bn=mn+yn,jn=ln+Nn;if(ee(Ue),W<at&&X<dt&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!m.atoms.length&&!f.atoms.length&&!g.atoms.length&&!m.pins.length&&!f.pins.length&&!g.pins.length){de||={fb:m,fl:f,fr:g,ML:ie,MR:xe,byEl:ht,cache:[null,null]};let _t=nr(de,le,W,at,Ae,X,dt,0,t),So=nr(de,Ae,X,dt,le,W,at,1,t);if(_t===null!=(So===null)){let ns=_t!==null,Us=ns?_t:So;if(Us){we||=new Map;for(let si of Us)we.set(si,ns?"local":"remote")}U.push(ns?{src:"remote",from:ln,to:jn}:{src:"local",from:mn,to:Bn}),pe=gt,be+=yn-(gt-Ue),he+=Nn-(gt-Ue),W=at,X=dt;continue}}let en={kind:"text",node:e.node||null,base:co(m,Ue,gt),local:co(f,mn,Bn),remote:co(g,ln,jn),resolved:null,range:null,bs:Ue,be:gt,lss:mn,lse:Bn,rss:ln,rse:jn},Jn=e.sourceRetentions?Ys(e.sourceRetentions,e.scope?.base,m,f,g,t,en):t;en.resolved=Jn==="local"?en.local:Jn==="remote"?en.remote:en.local+en.remote,Jn!=="remote"&&U.push({src:"local",from:mn,to:Bn,conflict:en}),Jn!=="local"&&U.push({src:"remote",from:ln,to:jn,conflict:en});let Qn={site:"inline",policy:Jn,fb:m,fl:f,fr:g,scope:e.scope||null,synthetic:!!e.synthetic,full:T,merged:c};p.push(Qn),w(en,Qn),pe=gt,be+=yn-(gt-Ue),he+=Nn-(gt-Ue),W=at,X=dt}ee(qe);let te=m.text,z=[];if(Oe.respell.size||Re.respell.size){let d=fo(Me),B=[];for(let F=0;F<Me.length;F++){let _=Me[F].raw,Q=Oe.respell.get(F)??_,me=Re.respell.get(F)??_;(Q!==_||me!==_)&&z.push([d[F],Q!==_&&me!==_?"both":Q!==_?"local":"remote"]),B.push(Q===me?Q:Q===_?me:me===_||t==="local"?Q:me)}te=B.join("")}let ne="",Te=[],Ce=[],Pe=[],ve=[];for(let d of U){let B=ne.length;if(d.src==="base"){for(let F=d.from;F<d.to;F++)Te.push(F),Ce.push(e.nativeTransfers?ie.bTo[F]:F+d.dL),Pe.push(e.nativeTransfers?xe.bTo[F]:F+d.dR),ve.push(d);ne+=te.slice(d.from,d.to)}else if(d.src==="both"){for(let F=0;F<d.len;F++){let _=d.transfer&&(d.transfer.side==="remote"?d.rfrom+F:d.lfrom+F);Te.push(d.transfer&&_>=d.transfer.ss&&_<d.transfer.se?d.transfer.bs+_-d.transfer.ss:-1),Ce.push(d.lfrom+F),Pe.push(d.rfrom+F),ve.push(d)}ne+=f.text.slice(d.lfrom,d.lfrom+d.len)}else{let F=d.src==="local"?f:g,_=d.transfer&&e.nativeTransfers.byOrigin[d.src==="local"?"remote":"local"].get(d.transfer.key);for(let Q=d.from;Q<d.to;Q++){let me=d.transfer&&Q>=d.transfer.ss&&Q<d.transfer.se?d.transfer.bs+Q-d.transfer.ss:-1,ke=me>=0&&(!_||_.destination===d.owner)?(d.src==="local"?xe:ie).bTo[me]:-1;Te.push(me),Ce.push(d.src==="local"?Q:ke),Pe.push(d.src==="remote"?Q:ke),ve.push(d)}ne+=F.text.slice(d.from,d.to)}d.ms=B,d.me=ne.length,d.conflict&&(d.conflict.range||(d.conflict.range=[B,B]),d.conflict.range[1]=ne.length)}let _e=ne.length,Je=new Int32Array(qe+1).fill(-1),Ze=new Int32Array(f.text.length+1).fill(-1),Ut=new Int32Array(g.text.length+1).fill(-1);for(let d=0;d<_e;d++)Te[d]>=0&&(Je[Te[d]]=d),Ce[d]>=0&&(Ze[Ce[d]]=d),Pe[d]>=0&&(Ut[Pe[d]]=d);let Pt=(d,B)=>{let F=-1,_=-1;for(let Q=d.from;Q<d.to;Q++){let me=B[Q];me>=0&&(F<0&&(F=me),_=me+1)}return F<0?null:[F,_]},L=[],G=[];for(let d of new Set(ht.values()))d.new==="local"?L.push(d):d.new==="remote"&&G.push(d);let re=(d,B)=>{d.remote=B.remote,d.remoteMark=B.remoteMark,d.new="both",B.merged=d,ht.set(B.remote,d)};if(L.length&&G.length){let d=e.idOf;for(let B of L){let F=d?d.local(B.local):null;if(!F)continue;let _=G.find(Q=>!Q.merged&&Q.tag===B.tag&&!!Q.block==!!B.block&&d.remote(Q.remote)===F);_&&re(B,_)}for(let B of L){if(B.remote)continue;let F=Pt(B.localMark,Ze);if(F)for(let _ of G){if(_.merged||_.tag!==B.tag||!!_.block!=!!B.block)continue;let Q=Pt(_.remoteMark,Ut);if(Q&&Math.min(F[1],Q[1])-Math.max(F[0],Q[0])>0){re(B,_);break}}}}Nt.clear();let ge=d=>{for(let B of d)if(B.block)return Ct(ht.get(B.el));return null},ye=m.marks.some(d=>d.block)||f.marks.some(d=>d.block)||g.marks.some(d=>d.block),ce=new Array(_e).fill(null),se=new Set;if(e.nativeTransfers)for(let d=0;d<_e;d++){let B=ve[d].owner;ce[d]=B?Ct(ht.get(B)):Te[d]>=0?ge(m.stackAt[Te[d]]):null}else if(ye){let d=(Le,Ue,gt)=>{let at=new Set([Le,Ue,gt]);at.delete(null);let dt=[];for(let Bt of at){let mn=Bt===Le,ln=Bt===Ue,yn=Bt===gt;(ln===yn?ln:ln===mn?yn:ln)&&dt.push(Bt)}if(dt.length<=1)return dt[0]||null;let Vt=t==="local"?Ue:gt;return dt.includes(Vt)?Vt:dt[0]},B=(Le,Ue)=>Ue>=0?ge(Le.stackAt[Ue]):null,F=new Map;for(let Le=0;Le<_e;Le++){if(ne[Le]!==kt)continue;let Ue=Te[Le]>=0?B(m,Te[Le]):null,gt=B(f,Ce[Le]),at=B(g,Pe[Le]);F.set(Le,[Ue,Te[Le]>=0?d(Ue,gt,at):gt||at])}let _=new Set([...F.values()].map(Le=>Le[1])),Q=Le=>Le!==kt&&Le!==Un&&!/\s/.test(Le),me=(Le,Ue)=>{let gt=Le;for(;gt<Ue&&!Q(ne[gt]);)gt++;return gt<Ue&&Te[gt]>=0?B(m,Te[gt]):null},ke=new Map,Se=0;for(let Le=0;Le<_e;Le++){if(ne[Le]!==kt)continue;let[Ue,gt]=F.get(Le),at=me(Se,Le),dt=gt,Vt=ke.get(dt)===dt&&at===dt;dt&&ke.has(dt)&&!Vt&&Ue&&!ke.has(Ue)&&!_.has(Ue)&&(dt=Ue),dt&&!ke.has(dt)&&ke.set(dt,at);for(let Bt=Se;Bt<=Le;Bt++)ce[Bt]=dt;Se=Le+1}let je=Le=>{for(let Ue=0;Ue<Le.text.length;Ue++)if(Q(Le.text[Ue])&&!B(Le,Ue))return!0;return!1};if(!je(m)&&!je(f)&&!je(g)){let Le=[],Ue=0;for(let at=0;at<_e;at++)(ne[at]===kt||at===_e-1)&&(Le.push([Ue,at]),Ue=at+1);let gt=new Set(ce);for(let at=0;at<Le.length;at++){let[dt,Vt]=Le[at];if(ce[Vt])continue;let Bt=dt;for(;Bt<=Vt&&!Q(ne[Bt]);)Bt++;if(Bt>Vt)continue;let mn=B(m,Te[Bt]),ln=B(f,Ce[Bt]),yn=B(g,Pe[Bt]),Nn=d(mn,ln,yn)||ln||yn||mn;if(Nn&&!gt.has(Nn)){gt.add(Nn);for(let en=dt;en<=Vt;en++)ce[en]=Nn;continue}let Bn=at>0&&ce[Le[at-1][1]],jn=at+1<Le.length&&ce[Le[at+1][1]];if(Bn)se.add(Le[at-1][1]);else if(jn&&ne[Vt]===kt)se.add(Vt);else continue;for(let en=dt;en<=Vt;en++)ce[en]=Bn||jn}}}let Ie=new Map,Be=d=>{let B=Ie.get(d);if(B)return B;B=[1/0,-1/0];for(let[F,_]of[[d.baseMark,Je],[d.localMark,Ze],[d.remoteMark,Ut]]){let Q=F&&Pt(F,_);Q&&(B[0]=Math.min(B[0],Q[0]),B[1]=Math.max(B[1],Q[1]))}return Ie.set(d,B),B},He=(d,B,F)=>{let _=-1,Q=-1;for(let me=0;me<d.length;me++){let ke=ht.get(d[me].el);ke===B&&(_=me),ke===F&&(Q=me)}return _>=0&&Q>=0?_-Q:0},Ke=(d,B)=>[...d].sort((F,_)=>{for(let ke of B){let Se=He(ke,F,_);if(Se)return Se}let Q=Be(F),me=Be(_);return Q[0]-me[0]||me[1]-Q[1]||F.rank-_.rank||F.id-_.id}),pt=new Map,tt=new Map,Kt=e.nativeTransfers?[]:null,Ht=d=>{if(Kt)return Kt;let B=Te[d],F=Ce[d],_=Pe[d],Q=ve[d];if(B>=0){let at=m.stackAt[B],dt=f.stackAt[F],Vt=g.stackAt[_],Bt=pt.get(at);Bt||pt.set(at,Bt=new Map);let mn=Bt.get(dt);mn||Bt.set(dt,mn=new Map);let ln=mn.get(Vt);if(ln)return ln;let yn=Lt(at),Nn=Lt(dt),Bn=Lt(Vt),jn=new Set;for(let en of new Set([...yn,...Nn,...Bn])){let Jn=yn.has(en),Qn=Nn.has(en),_t=Bn.has(en);(Qn===_t?Qn:Qn===Jn?_t:Qn)&&jn.add(en)}return ln=Ke(jn,[dt,Vt,at]),mn.set(Vt,ln),ln}if(Q.src==="both"){let at=f.stackAt[F],dt=g.stackAt[_];return Ke(new Set([...Lt(at),...Lt(dt)]),[at,dt])}let ke=(Q.src==="local"?f:g).stackAt[Q.src==="local"?F:_];if(!Q.inherit)return Ke(Lt(ke),[ke]);let Se=tt.get(Q);Se||tt.set(Q,Se=new Map);let je=Se.get(ke);if(je)return je;let Le=new Set(Lt(ke));for(let at of Q.inherit.added)Le.add(Ct(at));for(let at of Q.inherit.removed)Le.delete(Ct(at));let Ue=Q.src==="local"?g:f,gt=(Q.src==="local"?xe.bTo:ie.bTo)[Q.inherit.bs];return je=Ke(Le,[ke,Ue.stackAt[gt]]),Se.set(ke,je),je},un=new Int32Array(f.text.length+1);un[f.text.length]=_e;for(let d=f.text.length-1;d>=0;d--)un[d]=Ze[d]>=0?Ze[d]:un[d+1];Pi.caret+=f.text.length;let bt=d=>d<=0?0:(d>f.text.length&&(d=f.text.length),Ze[d-1]>=0?Ze[d-1]+1:un[d]),lt=[],$e=[],vt=null,ct=[],jt="",bn=-1,on=d=>{vt?vt.appendChild(d):lt.push(d)},hn=d=>{if(!jt)return;let B=o.createTextNode(jt);on(B),$e.push({node:B,ms:bn,me:d,local:[],u:ct.length?ct[ct.length-1].u:null}),jt=""},Xt=new Set,En=new Map,oo=new Set,Rn=d=>{let B=o.createElement(d.tag);if(d.block&&vn.add(B),!En.has(d)){En.set(d,B),N(d.base,d.local,d.remote,B),h.set(B,{base:d.base,local:d.local,remote:d.remote});let _=(ke,Se)=>b&&d[Se]&&ke.reverse.get(d[Se])?Se:null,Q=!d.base&&(_(n,"local")||_(s,"remote"));if(Q){let ke=Q==="local"?n.reverse.get(d.local):s.reverse.get(d.remote),Se=h.get(B);Se.local=Se.local||n.map.get(ke)||null,Se.remote=Se.remote||s.map.get(ke)||null,i.push({kind:"move",el:B,source:Q}),e.moveBuilt?.(ke,Q,d[Q],B)}else d.base||i.push({kind:"insert",el:B,source:d.local&&d.remote?"both":d.local?"local":"remote"});let me=h.get(B);me.local&&(oo.has(me.local)?me.local=null:oo.add(me.local))}else{let _=En.get(d);for(let Q of _.attributes)Q.name!=="id"&&Q.name!=="data-id"&&A(B,Q,Q.value);h.set(B,{base:null,local:null,remote:null})}on(B),ct.push({u:d,el:B}),vt=B},xo=new Set,Kn=new Map;for(let d of f.pins){let B=bt(d.i);Kn.has(B)||Kn.set(B,[]),Kn.get(B).push(d)}let Ro=d=>{let B=Kn.get(d);if(B){hn(d);for(let F of B){let _=F.el.namespaceURI&&F.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(F.el.namespaceURI,F.el.tagName):o.createElement(F.el.tagName);h.set(_,{base:null,local:F.el,remote:null,pinned:!0}),xo.add(_),on(_)}}},ts=m.atoms.length||f.atoms.length||g.atoms.length,Po=d=>{if(!ts)return null;let B=Te[d]>=0?m.atomAt.get(Te[d]):null,F=Ce[d]>=0?f.atomAt.get(Ce[d]):null,_=Pe[d]>=0?g.atomAt.get(Pe[d]):null;return B||F||_?{ab:B,al:F,ar:_}:null},Fn=(d,B,F)=>{let _=e.idOf;if(!_||!_.base)return!1;let Q=_.base(d.el);return Q!=null&&Q===_[F](B.el)},To=(d,B,F,_,Q)=>{if(!d||!b)return null;let me=I.get(B.reverse.get(d.el))||null;return!me||me===_||(_?me.el.isEqualNode(_.el)&&!Fn(me,d,Q):F.bTo[me.i]>=0)?null:me},so=(d,B)=>{if(!d||!b||!e.moveIn)return null;let F=B.reverse.get(d.el);return F&&!I.has(F)?F:null},vo=(d,B)=>{let F=new Map;for(let _ of d.atoms)F.set(B(_),(F.get(B(_))||0)+1);return F},ue=vo(m,j),We=vo(f,y),Ve=vo(g,k),et=d=>{let B=j(d);return ue.get(B)===1&&(We.get(B)||0)<=1&&(Ve.get(B)||0)<=1},yt=new Map,Fe=new Set,ze=new Set,xt=new Set,Ye=null;for(let d=0;d<_e;d++){let B=Po(d);if(!B)continue;let{ab:F,al:_,ar:Q}=B,me=To(Q,s,xe,F,"remote"),ke=To(_,n,ie,F,"local"),Se=F,je=null;if(me?(Se=me,je="remote"):ke&&(Se=ke,je="local"),Se){F&&Se!==F&&(Ye||=new Map).set(F,je),Fe.has(Se)?yt.set(d,{dup:Se.el}):(Fe.add(Se),yt.set(d,{bk:Se,from:je,al:_,ar:Q}));continue}let Le=so(Q,s),Ue=so(_,n),gt=Le||Ue;if(gt){ze.has(gt)?yt.set(d,{dup:gt}):(ze.add(gt),yt.set(d,{moveIn:gt,side:Le?"remote":"local",sideEl:Le?Q.el:_.el}));continue}let at=(Vt,Bt)=>Vt&&b&&I.get(Bt.reverse.get(Vt.el))||null,dt=at(Q,s)||at(_,n);if(dt&&(xt.add(dt),ve[d].conflict&&(et(dt)||Q&&(Q.el===dt.el||s.identityPaired?.has(dt.el))&&Fn(dt,Q,"remote")||_&&(_.el===dt.el||n.identityPaired?.has(dt.el))&&Fn(dt,_,"local")))){if(Fe.has(dt)){yt.set(d,{dup:dt.el});continue}Fe.add(dt)}yt.set(d,{al:_,ar:Q})}let st=new Map,ft,Wt,Mt=(d,B)=>{if(d[B]>=0)return d[B];for(let F=B-1;F>=0;F--)if(d[F]>=0)return d[F]+1;return 0};if(b)for(let d of m.atoms){if(Fe.has(d)||xt.has(d))continue;let B=n.map.get(d.el)||null,F=s.map.get(d.el)||null,_=B&&x.get(B),Q=F&&Y.get(F);if(B&&!_||F&&!Q)continue;let me=!(_&&Q)&&Ne.has(d);if(!me&&!(_&&Q&&(et(d)||Ye?.has(d)||(_.el===d.el||n.identityPaired?.has(d.el))&&(Q.el===d.el||s.identityPaired?.has(d.el))&&Fn(d,_,"local")&&Fn(d,Q,"remote"))))continue;let ke=Ye?.get(d),Se=t;if(ke){let at=ke==="local"?g:f,dt=ke==="local"?s:n,Vt=ke==="local"?Wt:ft;if(Vt===void 0){Vt=at.atoms.length===m.atoms.length;for(let Bt=0;Vt&&Bt<m.atoms.length;Bt++)Vt=dt.reverse.get(at.atoms[Bt].el)===m.atoms[Bt].el;ke==="local"?Wt=Vt:ft=Vt}Vt&&(Se=ke)}let je=Se==="local"?[[_,Ze],[Q,Ut]]:[[Q,Ut],[_,Ze]],[Le,Ue]=je.find(([at])=>at),gt=Mt(Ue,Le.i);st.has(gt)||st.set(gt,[]),st.get(gt).push({a:d,lt:B,rt:F,edited:me}),Fe.add(d)}if(b&&e.moveIn){let d=[[f,n,Ze,"local"],[g,s,Ut,"remote"]];t!=="local"&&d.reverse();for(let[B,F,_,Q]of d)for(let me of B.atoms){let ke=so(me,F);if(!ke||ze.has(ke))continue;ze.add(ke);let Se=Mt(_,me.i);st.has(Se)||st.set(Se,[]),st.get(Se).push({move:ke,side:Q,sideEl:me.el})}}let Qt=d=>{let B=st.get(d);if(B){if(hn(d),B.some(F=>De(F.move?F.sideEl:F.a.el)))for(;ct.length;)ct.pop(),vt=ct.length?ct[ct.length-1].el:null;for(let{a:F,lt:_,rt:Q,edited:me,move:ke,side:Se,sideEl:je}of B){if(ke){let Ue=e.moveIn(ke,Se,je);Ue&&on(Ue);continue}Xt.add(F);let Le=M(F.el,_,Q);me&&(w({kind:"structure",el:Le,detail:"edit-beats-delete",base:F.el},{subject:F.el,deleted:_?"remote":"local"}),i.push({kind:"insert",el:Le,source:_?"local":"remote"})),on(Le)}}},vn=new Set,_n=r.length>u;for(let d=0;d<_e;d++){let B=Po(d),F=e.scopeUnits&&B&&(B.ab?.stack.some(ke=>ke.block)||B.al?.stack.some(ke=>ke.block)||B.ar?.stack.some(ke=>ke.block)),Q=!!B&&De((B.ab||B.al||B.ar).el)&&!F?[]:ce[d]?[ce[d],...Ht(d)]:Ht(d),me=0;for(;me<ct.length&&me<Q.length&&ct[me].u===Q[me];)me++;if(me<ct.length)for(hn(d);ct.length>me;)ct.pop(),vt=ct.length?ct[ct.length-1].el:null;if(Ro(d),Qt(d),Q.length>ct.length)for(hn(d);ct.length<Q.length;)Rn(Q[ct.length]);if(ne[d]===kt){if(se.has(d))continue;hn(d);let ke=ct.length;for(;ke>0&&!ct[ke-1].u.block;)ke--;if(ke>0)for(_n&&c.breakOut.set(d,ct[ke-1].el);ct.length>=ke;)ct.pop(),vt=ct.length?ct[ct.length-1].el:null;continue}if(B){hn(d);let ke=yt.get(d),Se;if(ke.dup){w({kind:"structure",el:null,detail:"both-moved",base:ke.dup},{subject:ke.dup});continue}if(ke.moveIn){if(Se=e.moveIn(ke.moveIn,ke.side,ke.sideEl),!Se)continue}else if(ke.bk){let je=ke.bk;if(Xt.add(je),je===B.ab)Se=M(je.el,ke.al.el,ke.ar.el);else{let Le=n.map.get(je.el)||null,Ue=s.map.get(je.el)||null;Se=M(je.el,Le,Ue),(!Le||!Ue)&&w({kind:"structure",el:null,detail:"move-beats-delete",base:je.el},{subject:je.el,deleted:Le?"remote":"local"}),i.push({kind:"move",el:Se,source:ke.from})}}else ke.al?(Se=P(ke.al.el,"local"),ke.ar&&(h.get(Se).remote=ke.ar.el),i.push({kind:"insert",el:Se,source:ke.ar?"both":"local"})):(Se=P(ke.ar.el,"remote"),i.push({kind:"insert",el:Se,source:"remote"}));_n&&c.atomOut.set(d,Se),on(Se);continue}jt||(bn=d),jt+=ne[d]}if(hn(_e),(Kn.has(_e)||st.has(_e))&&(ct.length=0,vt=null,Ro(_e),Qt(_e)),_e===0&&(f.placeholder||g.placeholder||m.placeholder)){let d=o.createElement("br");h.set(d,{base:m.placeholder,local:f.placeholder,remote:g.placeholder}),lt.push(d)}let Pn=0,ut=d=>{for(;Pn>0&&$e[Pn-1].me>=d;)Pn--;for(;Pn<$e.length&&$e[Pn].me<d;)Pn++;let B=$e[Pn];if(!B)return $e[$e.length-1]||null;let F=$e[Pn+1];return B.me===d&&F&&F.ms===d?F:B},Qe=new Map,Et={},ot=(d,B,F)=>{let _=ut(d)||(F?Et:null);if(!_)return;let Q=Qe.get(_)||{l:!1,r:!1};B!=="remote"&&(Q.l=!0),B!=="local"&&(Q.r=!0),Qe.set(_,Q)},At=d=>{if(d.conflict)return!0;let B=d.src==="local"?f.text:d.src==="remote"?g.text:"";for(let F=d.from;F<d.to;F++)if(B[F]!==Un&&B[F]!==kt)return!0;return!1};for(let d of U)d.src!=="base"&&ot(d.ms,d.conflict?"both":d.src,At(d));for(let[d,B]of z)Je[d]>=0&&ot(Je[d],B);for(let d of $e.length?$e:[Et]){let B=Qe.get(d);B&&i.push({kind:"text",node:d.node||null,source:B.l&&B.r?"both":B.l?"local":"remote"})}for(let d of Ge){if(En.has(d))continue;let B=!d.local&&!(b&&n.map.get(d.base)),F=!d.remote&&!(b&&s.map.get(d.base));!B&&!F||i.push({kind:"remove",source:B&&F?"both":B?"local":"remote",base:d.base})}if(we)for(let[d,B]of we)En.has(d)&&w({kind:"structure",el:En.get(d),detail:"edit-beats-delete",base:d.base},{subject:d.base,deleted:B});let Jt=(d,B,F)=>{if(B<=d)return!1;for(let _=d;_<B;_++)if(F[_]>=0)return!1;return!0};for(let d of Ge)for(let B of["local","remote"]){let F=d[B+"Mark"],_=d.baseMark;if(!F)continue;let Q=B==="local"?ie:xe;if(!Jt(_.from,_.to,Q.bTo)||!Jt(F.from,F.to,Q.toB))continue;let me=(B==="local"?le:Ae).find(ke=>ke.ss<=F.from&&F.from<ke.se);me&&(me.be<=_.from||me.bs>=_.to)&&i.push({kind:"move",el:En.get(d)||null,source:B})}let Rt=d=>{let B=ht.get(d.node.parentNode);return B?Ct(B):null};for(let d of f.nodes){let B=-1;for(let _=d.s;_<d.e;_++)if(Ze[_]>=0){B=Ze[_];break}let F;if(B>=0)F=ut(B);else{let _=bt(d.s),Q=Rt(d);F=$e.find(me=>me.u===Q&&me.me>=_)||$e.filter(me=>me.u===Q).pop()}F&&F.local.push(d)}let Ft=new Map,tn=$e[$e.length-1]||null,Tt=0;for(let d of f.nodes){let B=null;for(let F=d.s;F<=d.e;F++){let _=bt(F);for(;Tt>0&&$e[Tt-1].me>=_;)Tt--;for(;Tt<$e.length&&$e[Tt].me<_;)Tt++;let Q=ke=>ke&&_>=ke.ms&&_<=ke.me&&(_<ke.me||F===d.e||ke===B),me=Q($e[Tt])?$e[Tt]:Q($e[Tt+1])?$e[Tt+1]:$e[Tt]||tn;if(!me)break;if(B===me){let ke=Ft.get(me);ke[ke.length-1].to=F-d.s;continue}B=me,Ft.has(me)||Ft.set(me,[]),Ft.get(me).push({node:d.node,from:F-d.s,to:F-d.s,flatStart:d.s})}}for(let d of $e){let B=d.local,F=!1;for(let ke of B)for(let Se=ke.s;Se<ke.e&&!F;Se++)(Ze[Se]<d.ms||Ze[Se]>=d.me)&&(F=!0);h.set(d.node,{base:null,local:B.map(ke=>ke.node),remote:null,caret:Ft.get(d)||[],partial:F});let _=d.ms,Q=d.me-d.ms,me=ke=>{let Se=0,je=-1;for(let Le of B){let Ue=Le.e-Le.s;if(ke<=Se+Ue){je=Le.s+(ke-Se);break}Se+=Ue}return je<0&&(je=B.length?B[B.length-1].e:0),Math.max(0,Math.min(bt(je)-_,Q))};me.flat=ke=>Math.max(0,Math.min(bt(ke)-_,Q)),l.set(d.node,me)}function mt(){if(!f.text.includes(kt))return[{flatLocal:f.text,localNodes:f.nodes,textNodes:$e,lToM:Ze,mapLocal:bt}];let d=[],B=0,F=0;for(let _=0;_<=f.text.length;_++){if(_<f.text.length&&f.text[_]!==kt)continue;let Q=B,me=_;if(me>Q){let ke=[];for(;F<f.nodes.length&&f.nodes[F].e<=Q;)F++;for(let Se=F;Se<f.nodes.length&&f.nodes[Se].s<me;Se++){let je=f.nodes[Se],Le=Math.max(je.s,Q),Ue=Math.min(je.e,me);Le<Ue&&ke.push({node:je.node,s:Le-Q,e:Ue-Q})}d.push({flatLocal:f.text.slice(Q,me),localNodes:ke,textNodes:$e,lToM:Ze.subarray?Ze.subarray(Q,me+1):Ze.slice(Q,me+1),mapLocal:Se=>bt(Q+Math.max(0,Math.min(Se,me-Q)))})}B=_+1}return d}let St={...e,blocks:vn,ignored:d=>xo.has(d)||(e.ignored?e.ignored(d):!1)},Zt=e.ignoreAttribute||(()=>!1),zn=Xs(nn(lt,St),Zt)!==Xs(g,Zt);if(p.length){let d=B=>{let F=h.get(B);return F&&F.unchanged?F.remote:null};c.text=ne,c.textNodes=$e,c.out=nn(lt,{...St,via:d})}let Sn=null;if(e.scopeUnits){Sn=new Map;let d=new Set(lt),B=Se=>{for(;Se&&!d.has(Se);)Se=Se.parentNode;return Se},F=e.scopeUnits.map(Se=>{let je=new Map;for(let Le of Se)if(Le.nodeType===1)je.set(Le,Le);else for(let Ue of Le.nodes)je.set(Ue,Le);return je}),_=(Se,je)=>{for(;Se&&!je.has(Se);)Se=Se.parentNode;return Se?je.get(Se):null},Q=[m,f,g].map((Se,je)=>{let Le=new Array(Se.text.length);for(let Ue of Se.nodes){let gt=_(Ue.node,F[je]);gt&&Le.fill(gt,Ue.s,Ue.e)}for(let Ue of Se.atoms)Le[Ue.i]=_(Ue.el,F[je]);return Le}),me=(Se,je)=>{if(!Se||!je)return;let Le=Sn.get(Se);Le||Sn.set(Se,Le=new Set),Le.add(je)};for(let Se of lt){let je=h.get(Se);je&&(me(_(je.base,F[0]),Se),me(_(je.local,F[1]),Se),me(_(je.remote,F[2]),Se))}for(let Se of $e){let je=B(Se.node);for(let Le=Se.ms;Le<Se.me;Le++)me(Q[0][Te[Le]],je),me(Q[1][Ce[Le]],je),me(Q[2][Pe[Le]],je)}let ke=new Map(lt.map((Se,je)=>[Se,je]));for(let[Se,je]of Sn)Sn.set(Se,Array.from(je).sort((Le,Ue)=>ke.get(Le)-ke.get(Ue)))}return{unitOutputs:Sn,nodes:lt,text:ne,textNodes:$e,localDiverged:zn,mapLocal:bt,conflicts:r.slice(u),granularity:q?"line":"word",segments:mt(),localHunks:le,remoteHunks:Ae,lToM:Ze}}var Ts=Symbol("lost");function lr(){return{links:new Map,removed:new Set,consumed:new Set,link(e,o){this.links.set(e,o)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let o of e.nodes)this.removed.add(o)},consume(e){for(let o of e)this.consumed.add(o)}}}var ir=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function ar({locals:e,rec:o,root:t,provenance:n,segments:s,ignored:h}){let l=new Map,r=(v,T)=>{let A=l.get(v);A||l.set(v,A=new Set),A.add(T)},i=new Set,u=new Set;for(let v of s){let T=v.textNodes;for(let A of T)i.add(A.node);for(let A of v.localNodes){u.add(A.node);let E=0,N=null;for(let M=A.s;M<A.e;M++){let P=v.lToM[M];if(P<0)continue;for((!T[E]||P<T[E].ms)&&(E=0);E<T.length&&T[E].me<=P;)E++;let V=T[E]&&T[E].ms<=P?T[E].node:Ts;V!==N&&r(A.node,V),N=V}}}let w=new Set,c=new Map,p=new Set;(function v(T){w.add(T);let A=n.get(T);if(T.nodeType===1)A&&A.local&&A.local.nodeType===1&&(r(A.local,T),A.unchanged&&p.add(A.local)),T.tagName==="TEMPLATE"&&T.content&&c.set(T.content,T);else if(A&&Array.isArray(A.local)&&!i.has(T))for(let E of A.local)r(E,T);for(let E=ir(T).firstChild;E;E=E.nextSibling)v(E)})(t);let b=new Set;for(let[v,T]of o.links)r(v,T),b.add(v);let S=v=>{let T=v.parentNode;return T&&T.nodeType===11?c.get(T)||null:T},C=(v,T)=>{for(let A=v;A;A=S(A))if(A===T)return!0;return!1},m=v=>o.removed.has(v)||o.consumed.has(v),f=v=>{for(let T=v.parentNode;T&&T.nodeType===1;T=T.parentNode){if(p.has(T))return"kept";if(m(T))return"decided";if(l.has(T))return null}return null},g=new Map;for(let v of e)g.set(v,I(v));return g;function I(v){let T=l.get(v);if(T&&(T.size!==1||T.has(Ts)))return{kind:"unknown",reason:"several-outputs"};let A=T?T.values().next().value:null;if(A&&(A.nodeType!==1||!w.has(A)))return{kind:"unknown",reason:"output-not-placed"};if(!A){let P=m(v)?"decided":f(v);if(P==="kept")return{kind:"untouched"};if(P!=="decided")return{kind:"unknown",reason:"unmapped"}}let E=[],N=M(v,!!A&&(p.has(v)||b.has(v)),!A||m(v));if(N)return{kind:"unknown",reason:N};return A?{kind:"single",output:A,owned:E,carried:b.has(v)}:{kind:"removed"};function M(P,V,D){for(let j=ir(P).firstChild;j;j=j.nextSibling){if(j.nodeType===1?h(j):j.nodeType!==3&&j.nodeType!==8)continue;let y=l.get(j);if(y)for(let k of y){if(k===Ts||!w.has(k))return"output-not-placed";if(!A)return"survives-elsewhere";if(!C(k,A))return"escaped";E.push(k)}else if(!V&&!D&&!m(j)&&!u.has(j))return"unmapped";if(j.nodeType===1){let k=M(j,V||p.has(j)||b.has(j),D||m(j));if(k)return k}}return null}}}function cr(e,o){if(!o)return!1;let t=o.nodeType===1&&o.tagName==="TEMPLATE"?[o,...o.querySelectorAll("template")]:[...o.querySelectorAll("template")];for(let n of t)if(n.content.contains(e)||cr(e,n.content))return!0;return!1}function fr(e,o){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let t=[],n=new Set;for(let s of Array.from(e.elements)){if(!s||s.nodeType!==1||s.ownerDocument!==o&&!cr(s,o.documentElement))throw new TypeError("lineage.elements must be elements of the live document");n.has(s)||(n.add(s),t.push(s))}return t}var ur=new WeakMap;function dr(e){let o=new Map;for(let t of e){let n=[],s=!1;(function h(l){l.nodeType===1&&l.namespaceURI==="http://www.w3.org/1999/xhtml"&&l.localName==="template"&&(s=!0);for(let r=l.firstChild;r;r=r.nextSibling)n.push(r),r.nodeType===1&&h(r)})(t),o.set(t,{nodes:n,opaque:s})}return o}function vs(e,o,t){if(e.lineage===void 0)return t(e);if(!o||o.nodeType!==1)throw new TypeError("lineage requires an element root");let n=e.lineage,s=fr(n,o.ownerDocument),h=!1,l={...e,lineage:{elements:s,onResult(r,i){if(!h)return h=!0,n.onResult(r,i)}}};try{return ur.set(l.lineage,dr(s)),t(l)}catch(r){if(!h){h=!0;try{n.onResult({version:1,root:o,status:"incomplete",entries:s.map(An)},null)}catch{}}throw r}}function Ss(e,{liveRoot:o,localRoot:t,toLive:n}){let s=fr(e,o.ownerDocument),h=u=>u===o||o.contains(u),l=new Map,r=new Set(s.filter(h));if(r.size&&t===o)for(let u of r)l.set(u,u);else r.size&&(function u(w){let c=n(w);r.delete(c)&&l.set(c,w);for(let p=w.firstElementChild;p&&r.size;p=p.nextElementSibling)u(p)})(t);return{spec:e,watched:s,root:o,locals:Array.from(new Set(l.values())),before:ur.get(e)||dr(s),delivered:!1,result:null,finish(u,w){return this.resolve=w,this.plans=u,this.result={version:1,root:this.root,status:"complete",entries:s.map(c=>Hi(c,l.get(c),u,w,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(u,w){this.root=w;let c=this.resolve,p=S=>{let C=c(S);return C===u?w:C};return this.finish(this.plans,p)},deliver(u){this.delivered||(this.delivered=!0,e.onResult(this.result,u))}}}var An=e=>({from:e,to:[],kind:"unknown",complete:!1});function Hi(e,o,t,n,s){let h=s.root,l=p=>!!p&&(p===h||h.contains(p)),r=o&&t?t.get(o):null;if(!r||r.kind==="unknown")return An(e);let i=s.before.get(e);if(!i||i.opaque)return An(e);let u=i.nodes,w=p=>l(p)||!!(p&&p.ownerDocument===h.ownerDocument&&h.ownerDocument.documentElement?.contains(p));if(r.kind==="untouched"){if(!l(e))return An(e);for(let p of u)if(w(p)&&!e.contains(p))return An(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(r.kind==="removed")return w(e)||u.some(w)?An(e):{from:e,to:[],kind:"removed",complete:!0};let c=n(r.output);if(!c||c.nodeType!==1||!l(c)||c!==e&&w(e))return An(e);for(let p of u)if(w(p)&&!c.contains(p))return An(e);for(let p of r.owned){let b=n(p),S=Array.isArray(b)?b:[b];for(let C of S)if(!C||!l(C)||!c.contains(C))return An(e)}return r.carried&&!hr(c,r.output,n)?An(e):{from:e,to:[c],kind:c===e?"retained":"replaced",complete:!0}}function hr(e,o,t){for(let n=o.firstChild;n;n=n.nextSibling){let s=t(n),h=Array.isArray(s)?s:[s];for(let l of h)if(!l||!e.contains(l))return!1;if(n.nodeType===1&&!hr(e,n,t))return!1}return!0}function Ao(e,o,t){let n=Ss(e,{liveRoot:o,localRoot:o,toLive:s=>s});return n.result={version:1,root:o,status:"complete",entries:n.watched.map(s=>An(s))},t.lineage=n.result,n}function pr(e,o,t,n,s){if(!s(e.length*8+1))return null;let h=0,l=o===0,r=!1;for(let i of an(e,n)){if(!s(1))return null;if(h+=i.len,h===o&&(l=!0),h===t&&(r=!0),h>=t)break}return l&&r}function Wi(e,o,t,n,s,h,l){if(!l(o.length*2))return!1;let r=new Map,i=new Map,u=new Set;for(let w of o){let c=w.bs<w.be,p=c?t[w.ownerIndex].text.base:t[w.ownerIndex].text[e],b=c?w.bs:w.ss,S=c?w.be:w.se;if(!l((S-b)*4+1))return!1;for(;b<S&&/\s/.test(p[b]);)b++;for(;S>b&&/\s/.test(p[S-1]);)S--;if(b===S)continue;let C=p.slice(b,S),m=c?r:i;c&&w.text&&u.add(C),m.has(C)?m.set(C,null):m.set(C,{h:w,from:b,to:S})}for(let w of n){if(!l(1))return!1;if(w.side!==e)continue;let c=w.deletion,p=t[c.ownerIndex].text.base;if(!l((c.be-c.bs)*3)||u.has(p.slice(c.bs,c.be).trim()))return!1}for(let[w,c]of r){if(!l(w.length+1))return!1;let p=i.get(w);if(!c||!p)continue;let b=c.h,S=p.h;if(!b.text||b.transferOut||S.transferIn||b.owner===S.owner)continue;let C=t[b.ownerIndex],m=t[S.ownerIndex];if(!l(C.text.base.length))return!1;if(!/\S/.test(C.text.base.slice(0,b.bs)+C.text.base.slice(b.be)))continue;let f=pr(C.text.base,c.from,c.to,h,l),g=pr(m.text[e],p.from,p.to,h,l);if(f===null||g===null)return!1;if(!f||!g)continue;let I=`${C.index}:${c.from}:${c.to}`,v={key:I,side:e,source:b.owner,destination:S.owner,deletion:b,insertion:S,sourceOffset:c.from-b.bs,targetOffset:p.from-S.ss,length:c.to-c.from};b.transferOut=v,S.transferIn=v,s[e].set(I,v),n.push(v)}return!0}function mr({base:e,local:o,remote:t,localTwin:n,remoteTwin:s,eligible:h,nodes:l,budget:r=$t(2e4*32)}){let i=N=>N>r.remaining?!1:(r.remaining-=N,r.nativeSteps=(r.nativeSteps||0)+N,!0);if(e.length<2||o.length!==e.length||t.length!==e.length||!i(e.length*12))return null;for(let[N,M]of[["base",e],["local",o],["remote",t]]){let P=l[N];if(P.length!==M.length||P.some((V,D)=>V!==M[D]))return null}let u=[],w=0;for(let N=0;N<e.length;N++){let M=e[N],P=o[N],V=t[N];if(n(M)!==P||s(M)!==V)return null;let D={};for(let[j,y]of[["base",M],["local",P],["remote",V]]){if(!h(y)||y.tagName!==M.tagName||y.namespaceURI!==M.namespaceURI||!i(y.childNodes.length+1))return null;let k="";for(let J of y.childNodes){if(J.nodeType!==3||!i(J.data.length*4+1))return null;k+=J.data}if(k.includes(kt)||(w+=k.length+1,w>2e4))return null;D[j]=k}u.push({base:M,local:P,remote:V,index:N,text:D})}let c=u.every(N=>xn(N.text.base,N.text.local,N.text.remote)),p={local:[],remote:[]};for(let N of u){N.hunks={local:[],remote:[]};for(let M of["local","remote"]){let P=N.text.base,V=N.text[M];if(P===V)continue;let D=P.length+V.length+4,j=D*8;if(!i(j))return null;let y=Math.floor(r.remaining/8),k=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(D*D+y)-D)/2)));if(k<1||!i(4*(k+1)*(D+k+1)))return null;let J=0;for(let H of Yn(P,V,k)){if(!i(H.text.length+1))return null;let q=H.bs+J,Me={...H,ss:q,se:q+H.text.length,toks:an(H.text,c),owner:N.base,ownerIndex:N.index};N.hunks[M].push(Me),p[M].push(Me),J+=H.text.length-(H.be-H.bs)}}}let b=[],S={local:new Map,remote:new Map};for(let N of["local","remote"]){let M=new Map,P=new Map,V=!1,D=(j,y,k)=>{j.has(y)?j.set(y,null):j.set(y,k)};for(let j of p[N]){if(!i(1))return null;let y=u[j.ownerIndex].text.base;if(j.bs<j.be&&j.text===""){let k=y.slice(j.bs,j.be);if(!i(k.length*2))return null;/\S/.test(k)&&D(M,k,j)}else if(j.bs===j.be&&/\S/.test(j.text)){if(!i(j.text.length*2))return null;D(P,j.text,j)}else j.bs<j.be&&(V=!0)}for(let[j,y]of M){if(!i(j.length+1))return null;let k=P.get(j);if(!y||!k||y.owner===k.owner)continue;let J=u[y.ownerIndex];if(!i(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,y.bs)+J.text.base.slice(y.be)))continue;let H=`${J.index}:${y.bs}:${y.be}`,q={key:H,side:N,source:y.owner,destination:k.owner,deletion:y,insertion:k};y.transferOut=q,k.transferIn=q,S[N].set(H,q),b.push(q)}if(V&&P.size&&!Wi(N,p[N],u,b,S,c,i))return null}if(!b.length)return null;let C=(N,M)=>N.bs<M.be&&M.bs<N.be,m=N=>N.bs===N.be,f=(N,M)=>N.bs<=M.be&&M.bs<=N.be&&m(N)!==m(M),g=(N,M)=>N.bs===M.bs&&N.be===M.be&&N.text===M.text,I=(N,M)=>!!(N.transferIn||N.transferOut&&(!N.text||M.bs===N.be&&/\s/.test(M.text[0])||M.bs===N.bs&&/\s/.test(M.text[M.text.length-1])));for(let N of b){let M=N.side==="local"?"remote":"local",P=u[N.deletion.ownerIndex];for(let V of P.hunks[M])if(!i(1)||C(N.deletion,V)&&V.transferOut?.key!==N.key)return null}for(let N of u)for(let M of N.hunks.local)for(let P of N.hunks.remote){if(!i(1))return null;if(g(M,P)){if(M.transferIn?.key!==P.transferIn?.key)return null;continue}if(C(M,P)||f(M,P)&&!I(M,P)&&!I(P,M))return null}if(!i(w*8))return null;let v=new Set([...e,...o,...t]),T={base:nn(e,{blocks:v}),local:nn(o,{blocks:v}),remote:nn(t,{blocks:v})},A={};for(let N of["base","local","remote"]){let M=T[N];if(M.atoms.length||M.pins.length)return null;A[N]=new Map(M.marks.filter(P=>P.block).map(P=>[P.el,P.from]))}for(let N of u){let M=A.base.get(N.base);if(M===void 0)return null;for(let P of["local","remote"]){let V=A[P].get(N[P]);if(V===void 0)return null;for(let D of N.hunks[P])D.bs+=M,D.be+=M,D.ss+=V,D.se+=V}}for(let N of b)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 M=0,P=0,V=[];for(let j of p[N]){if(!i(1))return null;j.bs>M&&V.push({from:M,to:j.bs,target:P}),M=j.be,P=j.se}M<T.base.text.length&&V.push({from:M,to:T.base.text.length,target:P});let D=b.filter(j=>j.side===N).map(j=>({from:j.bs,to:j.be,target:j.ss,destination:j.destination}));if(E[N]=Dn({base:T.base,side:T[N],retained:V,transfers:D,budget:r}),E[N].status!=="ready")return null}return i(T.base.text.length)?{owners:u,blocks:v,transfers:b,byOrigin:S,budget:r,prepared:{base:T.base,local:T.local,remote:T.remote,lines:!1,baseTokens:an(T.base.text,c),localEdits:{hunks:p.local,respell:new Map},remoteEdits:{hunks:p.remote,respell:new Map},localMap:E.local,remoteMap:E.remote,full:null}}:null}var Ns=/\S/;function gr({certificates:e,scopes:o,views:t,eligible:n,baseId:s,limit:h=2e4*32}){let l=$t(h),r=Symbol(),i=[],u=c=>{if(c>l.remaining)throw r;l.remaining-=c},w=(c,p=null)=>{if(u(1),!c||c.nodeType!==1||c.parentNode?.nodeType!==1||!n(c))return null;for(let C=c.parentNode;C;C=C.parentNode)if(u(1),C.nodeType===11)return null;let b="",S=0;for(let C of c.childNodes){if(u(1),C.nodeType!==3)return null;if(u(C.data.length*4+1),p){let m=p.flat.nodes[S++];if(!m||m.node!==C||m.s!==b.length||m.e!==b.length+C.data.length)return null}b+=C.data}return u(b.length*3+1),p&&(p.flat.atoms.length||p.flat.pins?.length||S!==p.flat.nodes.length||p.flat.text!==b)?null:Ns.test(b)?b:null};try{u(o[0].length+o[1].length+o[2].length+e.length);let c=o.map(b=>new Set(b)),p=new Map;for(let b of e){u(1);let S=p.get(b.source);S||p.set(b.source,S=[]),S.push(b)}for(let b of p.values()){let S=[null,null],C=[];for(let m of b){u(1);let{source:f,target:g,side:I,models:v,runs:T}=m;if(I!==0&&I!==1||!c[0].has(f)||!c[I+1].has(g))continue;let{V:A,A:E,idOf:N}=t[I],M=t[1-I],P=A.twin(f),V=M.V.twin(f),D=A.baseOf(g);if(!P||!V||!D||D===f||!c[0].has(D)||!c[I+1].has(P)||!c[2-I].has(V)||E.map.get(f)!==P||E.reverse.get(P)!==f||M.A.map.get(f)!==V||M.A.reverse.get(V)!==f||E.map.get(D)!==g||E.reverse.get(g)!==D||g.parentNode!==P.parentNode||D.parentNode!==f.parentNode||f.tagName!==P.tagName||f.tagName!==V.tagName||s(f)!==N(P)||s(f)!==M.idOf(V)||s(D)!==N(g))continue;let j=v.get(f),y=v.get(g);if(!j||!y)continue;let k=w(f,j),J=w(g,y),H=w(P),q=w(V);if(u((k?.length||0)+(q?.length||0)),k===null||J===null||H===null||q===null||q===k)continue;let Me=T.length>0,Oe=!1;for(let ie of T){if(u(1),ie.source!==f||ie.target!==g||!Number.isInteger(ie.from)||!Number.isInteger(ie.to)||!Number.isInteger(ie.targetFrom)||ie.from<0||ie.to<=ie.from||ie.to>k.length||ie.targetFrom<0||ie.targetFrom+ie.to-ie.from>J.length){Me=!1;break}u((ie.to-ie.from)*3);for(let xe=ie.from;xe<ie.to;xe++){if(k[xe]!==J[ie.targetFrom+xe-ie.from]){Me=!1;break}Ns.test(k[xe])&&(Oe=!0)}if(!Me)break}if(!Me||!Oe)continue;let Re=S[I];Re||(u(k.length),Re=S[I]={source:f,side:I,flat:j.flat,before:k,covered:new Uint8Array(k.length)});for(let ie of T)u(ie.to-ie.from),Re.covered.fill(1,ie.from,ie.to)}for(let m of S){if(!m)continue;let{source:f,side:g,flat:I,before:v,covered:T}=m;u(v.length*3+1);let A=-1,E=-1;for(let N=0;N<=v.length;N++)N<v.length&&T[N]?(A<0&&(A=N),E=N+1):(N===v.length||Ns.test(v[N]))&&A>=0&&(C.push({source:f,side:g,flat:I,from:A,to:E}),A=E=-1)}u(C.length),i.push(...C)}}catch(c){if(c!==r)throw c}return{records:i,budget:l}}var qi="http://www.w3.org/1999/xhtml";function Ki(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function pn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===qi}function Fi(e){let o=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return o==="application/json"||o.endsWith("+json")}function _o(e,o){let t=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let s=t;try{let h=new URL(t,o);s=h.origin+h.pathname+h.search}catch{}return"script|src|"+n+"|"+s}return"script|inline|"+n+"|"+Ki(e.textContent.trim())}var _i={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function ho(e,o=[],t=!1){if(!pn(e)||e.hasAttribute("src"))return null;let n=[_i,...o];for(let s=0;s<n.length;s++){let h=n[s];if(!h.match(e))continue;if(!Fi(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=h.identity(e);return l==null||l===""?null:{key:s+":"+l,raw:l,recognizer:h}}return null}function br(e,o,t){let n=new Set,s=h=>{pn(h)&&!o(h)&&n.add(_o(h,t))};s(e);for(let h of e.querySelectorAll("script"))s(h);return n}function Mo(e,o){let t=o.createElement("div");t.innerHTML="<script><\/script>";let n=t.firstChild;for(let s of e.attributes)n.setAttribute(s.name,s.value);return n.textContent=e.textContent,n}function wr(e,o,t){let n=[],s=[],h=new Map,l=t.trackRecovery?new Set:null,r=Array.from(e.querySelectorAll("script"));pn(e)&&r.unshift(e);for(let i of r){if(!pn(i)||t.ignored(i)||t.skip.has(i)||o.has(_o(i,t.baseURI)))continue;let u=i.ownerDocument.createElement("script");for(let w of i.attributes)u.setAttribute(w.name,w.value);if(u.textContent=i.textContent,t.beforeNodeAdded(u)===!1){l?.add(i);continue}u.hasAttribute("src")&&s.push(new Promise(w=>{u.addEventListener("load",()=>w()),u.addEventListener("error",()=>w())})),i.replaceWith(u),h.set(i,u),t.afterNodeAdded(u),n.push(u)}return{executed:n,loads:s,swapped:h,vetoed:l}}function zi(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function $i(e,o){try{let t=new URL(e,o);return t.origin+t.pathname+t.search}catch{return e}}function yr(e,o){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return _o(e,o);if(t==="LINK"){let n=e.getAttribute("href");return n?"link|"+(e.getAttribute("rel")||"")+"|"+$i(n,o):e.outerHTML}if(t==="META"){for(let n of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(n))return"meta|"+n+"="+e.getAttribute(n);return e.outerHTML}return t==="STYLE"?"style|"+zi(e.textContent):e.outerHTML}function As(e,o){for(;;){for(;o<e.length&&/\s/.test(e[o]);)o++;if(e[o]==="/"&&e[o+1]==="/"){for(;o<e.length&&e[o]!==`
4
4
  `;)o++;continue}if(e[o]==="/"&&e[o+1]==="*"){let t=e.indexOf("*/",o+2);if(t===-1)return e.length;o=t+2;continue}return o}}function kr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(o,t)=>t.length%2===0?t+'\\"':o)}var Gi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Yi=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function zo(e){try{return JSON.parse(e)}catch{return JSON.parse(Xi(e))}}function Xi(e){let o="",t=0,n=(s,h)=>{throw new Error(`Invalid relaxed JSON: ${s} at position ${h}`)};for(;t<e.length&&(t=As(e,t),!(t>=e.length));){let s=e[t];if("{}[]:".includes(s)){o+=s,t++;continue}if(s===","){let r=As(e,t+1);if(e[r]==="}"||e[r]==="]"){t++;continue}o+=s,t++;continue}if(s==='"'||s==="'"){let r=t+1;for(;r<e.length&&e[r]!==s;)e[r]==="\\"&&r++,r++;r>=e.length&&n("unterminated string",t);let i=e.slice(t+1,r);s==="'"&&(i=kr(i)),o+='"'+i+'"',t=r+1;continue}let h=t;for(;h<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[h]);)h++;h===t&&n("unexpected character "+JSON.stringify(s),t);let l=e.slice(t,h);if(l==="true"||l==="false"||l==="null"||Gi.test(l)){o+=l,t=h;continue}if(Yi.test(l)){if(e[As(e,h)]===":"){o+='"'+l+'"',t=h;continue}n("unquoted value "+JSON.stringify(l),t)}n("invalid token "+JSON.stringify(l),t)}return o}function xr(e){try{return JSON.parse(e)}catch{}let o={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(s){let h=[],l=0;for(;l<s.length;){let r=s[l];if(/\s/.test(r)){l++;continue}if("{}".includes(r)){h.push({type:r,value:r}),l++;continue}if(r==="["){let c=!1,p=l+1;for(;p<s.length&&/\s/.test(s[p]);)p++;if(p<s.length&&/[a-zA-Z_]/.test(s[p])&&(c=!0),!c){h.push({type:r,value:r}),l++;continue}}if(r==="]"){h.push({type:r,value:r}),l++;continue}if(r===":"){h.push({type:o.COLON,value:r}),l++;continue}if(r===","){h.push({type:o.COMMA,value:r}),l++;continue}if(r==='"'||r==="'"){let c=r,p=l+1;for(;p<s.length&&s[p]!==c;)s[p]==="\\"&&p++,p++;h.push({type:o.STRING,value:s.substring(l+1,p),quoted:!0,sourceQuote:c}),l=p+1;continue}let i=l,u;for(;i<s.length&&!/[{},]/.test(s[i]);)if(s[i]===":"){let c=[":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"],p=!1;for(let b of c){let S=b.substring(1);if(s.substring(i+1,i+1+S.length)===S){p=!0,i+=S.length;break}}if(!p)break}else if(s[i]==="["){for(i++;i<s.length&&s[i]!=="]";){if(s[i]==='"'||s[i]==="'"){let c=s[i];for(i++;i<s.length&&s[i]!==c;)s[i]==="\\"&&i++,i++}i++}i<s.length&&s[i]==="]"&&i++}else i++;u=s.substring(l,i);let w=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?w=o.NUMBER:u==="true"||u==="false"||u==="null"?w=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(w=o.SELECTOR),h.push({type:w,value:u,quoted:!1}),l=i}return h}function n(s){let h="";for(let l=0;l<s.length;l++){let r=s[l];if("{}".includes(r.type)||"[]".includes(r.type)){h+=r.value;continue}if(r.type===o.COLON){h+=r.value;continue}if(r.type===o.COMMA){let i=s[l+1];if(i&&(i.type==="}"||i.type==="]"))continue;h+=r.value;continue}if(r.type===o.STRING){let i=r.value;r.sourceQuote==="'"&&(i=kr(i)),h+=`"${i}"`;continue}if(r.type===o.NUMBER||r.type===o.BOOLEAN){h+=r.value;continue}h+=`"${r.value}"`}return h}try{let s=t(e),h=n(s);return JSON.parse(h)}catch(s){throw new Error("Invalid extraction rules syntax: "+s.message)}}var zt=Symbol("hyper-morph-json-merge:missing"),Ji=["id","_id","uuid","key","slug","code","name"];function po(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Oo(e,o){return Object.prototype.hasOwnProperty.call(e,o)}function Qi(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}var Zi=/^[A-Za-z_$][\w$]*$/;function el(e,o){return Zi.test(o)?e===""?o:e+"."+o:e+"["+JSON.stringify(o)+"]"}function tl(e,o){return e===""?o:e+"."+o}function $o(e,o,t,n,s,h){if(e.onConflict){let l=r=>r===zt?void 0:r;e.onConflict({path:o,base:l(t),local:l(n),remote:l(s),resolved:l(h)})}return h}function qn(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o)){if(e.length!==o.length)return!1;for(let t=0;t<e.length;t++)if(!qn(e[t],o[t]))return!1;return!0}if(po(e)&&po(o)){let t=Object.keys(e);if(t.length!==Object.keys(o).length)return!1;for(let n of t)if(!Oo(o,n)||!qn(e[n],o[n]))return!1;return!0}return!1}function Ms(e,o,t,n,s,h){return qn(o,t)?o:qn(o,e)?t:qn(t,e)?o:po(o)&&po(t)?nl(po(e)?e:{},o,t,n,s,h):Array.isArray(o)&&Array.isArray(t)?il(e,o,t,n,s,h):$o(n,s,e,o,t,t)}function Tr(e,o,t,n,s,h){return o===zt&&t===zt?zt:o===zt?e===zt?t:qn(t,e)?zt:$o(n,s,e,o,t,t):t===zt?e===zt?o:qn(o,e)?zt:$o(n,s,e,o,t,zt):Ms(e,o,t,n,s,h)}function nl(e,o,t,n,s,h){let l={},r=new Set([...Object.keys(e),...Object.keys(o),...Object.keys(t)]);for(let i of r){let u=Tr(Oo(e,i)?e[i]:zt,Oo(o,i)?o[i]:zt,Oo(t,i)?t[i]:zt,n,el(s,i),tl(h,i));u!==zt&&Qi(l,i,u)}return l}function ol(e){return e===null||typeof e!="object"}function Go(e){return typeof e+":"+String(e)}function sl(e,o){for(let t of o){let n=new Set;for(let s of t){if(!Oo(s,e))return!1;let h=s[e];if(typeof h!="string"&&typeof h!="number")return!1;let l=Go(h);if(n.has(l))return!1;n.add(l)}}return!0}function rl(e,o,t,n,s){let h=[e,o,t],l=!0;for(let r of h)for(let i of r)po(i)||(l=!1);if(l){let r=n.keyPaths.get(s),i=r!==void 0?[r]:n.keyCandidates;for(let u of i)if(sl(u,h))return{kind:"keyed",field:u};return null}for(let r of h){let i=new Set;for(let u of r){if(!ol(u))return null;let w=Go(u);if(i.has(w))return null;i.add(w)}}return{kind:"self"}}function il(e,o,t,n,s,h){let l=Array.isArray(e)?e:[],r=rl(l,o,t,n,h),i=Array.isArray(e)&&e.length===o.length&&e.length===t.length;if(!r||r.kind==="self"&&i)return i?o.map((I,v)=>Ms(e[v],I,t[v],n,s+"["+v+"]",h)):$o(n,s,e,o,t,t);let u=r.kind==="self"?Go:I=>Go(I[r.field]),w=I=>r.kind==="self"?s+"["+JSON.stringify(I)+"]":s+"["+r.field+"="+JSON.stringify(I[r.field])+"]",c=new Map,p=I=>{let v=new Map;for(let T of I){let A=u(T);v.set(A,T),c.has(A)||c.set(A,w(T))}return v},b=p(l),S=p(o),C=p(t),m=new Map,f=new Set([...b.keys(),...S.keys(),...C.keys()]);for(let I of f){let v=Tr(b.has(I)?b.get(I):zt,S.has(I)?S.get(I):zt,C.has(I)?C.get(I):zt,n,c.get(I),h);v!==zt&&m.set(I,v)}let g=[];for(let I of t){let v=u(I);m.has(v)&&g.push(v)}for(let I=0;I<o.length;I++){let v=u(o[I]);if(!m.has(v)||g.includes(v))continue;let T=0;for(let A=I-1;A>=0;A--){let E=g.indexOf(u(o[A]));if(E!==-1){T=E+1;break}}g.splice(T,0,v)}return g.map(I=>m.get(I))}function ll(e){let o=new Map,t=[];for(let n of e.keyCandidates||[]){let s=n.lastIndexOf(":");s>=0?o.set(n.slice(0,s),n.slice(s+1)):t.push(n)}return{keyCandidates:[...t,...Ji],keyPaths:o,onConflict:e.onConflict||null}}function Os(e,o,t,n={}){return Ms(e===void 0?zt:e,o,t,ll(n),"","")}function al(e,o){let t=/^\s*/.exec(o)[0],n=/\s*$/.exec(o.slice(t.length))[0],s=o.slice(t.length,o.length-n.length),h=t.slice(t.lastIndexOf(`
5
5
  `)+1),l=/\n([ \t]+)\S/.exec(s),r;if(!l)r=JSON.stringify(e);else{let i=l[1],u=i.length>h.length&&i.startsWith(h)?i.slice(h.length):" ";r=JSON.stringify(e,null,u).replace(/\n/g,`
6
- `+h)}return t+r.replace(/</g,"\\u003c")+n}function Yo(e,o,t,n={}){let s=n.parse||zo,h=[],l=[],r=(p,b)=>{if(typeof p!="string")return zt;try{return s(p)}catch(S){return h.push(`${b} side is not valid JSON (${S.message})`),zt}},i=r(o,"local"),u=r(t,"remote");if(i===zt)return{text:t,warnings:h,conflicts:l};if(u===zt)return{text:o,warnings:h,conflicts:l};let w=r(e,"base"),c=Os(w===zt?void 0:w,i,u,{...n,onConflict:p=>{l.push(p),n.onConflict?.(p)}});return qn(c,u)?{text:t,warnings:h,conflicts:l}:qn(c,i)?{text:o,warnings:h,conflicts:l}:{text:al(c,t),warnings:h,conflicts:l}}var vr=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function eo(e){if(!e)return!1;let{startContainer:o,startOffset:t,endContainer:n,endOffset:s}=e;if(!o||!n||!Number.isInteger(t)||!Number.isInteger(s)||t<0||s<0||t>vr(o)||s>vr(n)||o.getRootNode()!==n.getRootNode())return!1;let h=o.ownerDocument.createRange();return h.setStart(o,t),h.setEnd(n,s),h.startContainer===o&&h.startOffset===t}function Xn(e,o,t={}){if(!eo(e))return null;let{startContainer:n,startOffset:s,endContainer:h,endOffset:l}=e;if(n===h&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(s,l);if(n===h&&s===l)return"";let r=new Set;for(let m=n;m;m=m.parentNode)r.add(m);let i=h;for(;!r.has(i);)i=i.parentNode;let u=(m,f)=>{let g=i.ownerDocument.createRange(),I=i.ownerDocument.createRange();return g.setStart(m[0],m[1]),g.collapse(!0),I.setStart(f[0],f[1]),I.collapse(!0),g.compareBoundaryPoints(0,I)},w=(m,f=!1)=>[m.parentNode,Array.prototype.indexOf.call(m.parentNode.childNodes,m)+Number(f)],c=[],p;if(o==="plain"){p="";let m=f=>{if(f.nodeType===3||f.nodeType===8){let g=p.length;p+=f.nodeValue,c.push({s:g,e:p.length,a:[f,0],b:[f,f.nodeValue.length],node:f})}else for(let g of f.childNodes)m(g)};m(i)}else{let m=t.blocks;if(!m){m=new Set;let g=I=>{I!==i&&I.nodeType===1&&ks.has(I.tagName)&&m.add(I);for(let v of I.childNodes)g(v)};g(i)}let f=nn(Array.from(i.childNodes),{blocks:m,atomize:g=>!!t.atoms?.has(g),ignored:t.ignored});p=f.text;for(let g of f.nodes)c.push({s:g.s,e:g.e,a:[g.node,0],b:[g.node,g.e-g.s],node:g.node});for(let g of f.atoms)c.push({s:g.i,e:g.i+1,a:w(g.el),b:w(g.el,!0)});for(let g=0;g<f.text.length;g++){if(f.text[g]!==kt)continue;let I=f.marks.find(T=>T.block&&T.to===g+1),v=f.marks.find(T=>T.block&&T.from===g+1);if(I)c.push({s:g,e:g+1,a:[I.el,I.el.childNodes.length],b:w(I.el,!0)});else if(v)c.push({s:g,e:g+1,a:w(v.el),b:[v.el,0]});else return null}}c.sort((m,f)=>m.s-f.s);let b=m=>{if(m[0].nodeType===3||m[0].nodeType===8){let g=c.find(I=>I.node===m[0]);return g?g.s+m[1]:null}let f=0;for(let g of c){if(u(m,g.a)<=0)return g.s;if(u(m,g.b)<0)return null;f=g.e}return f},S=b([n,s]),C=b([h,l]);return S!==null&&C!==null&&S<=C?p.slice(S,C):null}function Zn(e,o){let t=e;for(let n of o.path)if(t=n==="content"?t?.content:t?.childNodes[n],!t)return null;return[t,o.offset]}function Sr(e,o){if(!e||!o)return null;let t=Zn(e,o.start),n=Zn(e,o.end);return t&&n?{startContainer:t[0],startOffset:t[1],endContainer:n[0],endOffset:n[1]}:null}var Nr=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ar(e,o,t){if(!o)return;let n=new Map,s=new Map,h=r=>{if(!r)return null;if(s.has(r))return s.get(r);let u=r.local.map(w=>Zn(o.localRoot,{path:w,offset:0})?.[0]).map(w=>w&&t(w)).filter(Boolean).map(w=>({node:w,parent:w.parentNode,previous:w.previousSibling,next:w.nextSibling,fragment:Nr(w)}));return s.set(r,u),u},l=r=>{let i=Sr(o.localRoot,r);if(!i)return null;let u=t(i.startContainer),w=t(i.endContainer);if(!u||!w)return null;let c={...i,startContainer:u,endContainer:w};return eo(c)?c:null};for(let r of e){let i=r.recovery;if(!i||n.has(i))continue;let u={subject:h(i.subject),span:null,scope:null,touched:new Set};if(i.text){u.span=l(i.text.local.span),u.scope=l(i.text.local.scope);let w=u.span;if(w){let c=w.startContainer.ownerDocument.createRange();c.setStart(w.startContainer,w.startOffset),c.setEnd(w.endContainer,w.endOffset);let p=b=>{if(c.intersectsNode(b)){u.touched.add(b);for(let S of b.childNodes)p(S)}};p(c.commonAncestorContainer)}}if(i.structure){for(let w of[i.structure.localPlacement])w&&(h(w.parent),w.before.forEach(h),w.after.forEach(h));for(let w of i.structure.localOrder||[])h(w)}n.set(i,u)}o.localState={states:n,refs:s}}function Mr(e,o,t,n){let s=t.localState?.states.get(e);if(!s)return!1;let h=r=>{let i=r.node;if(!n(i)||i.parentNode!==r.parent)return!1;let u=w=>Array.prototype.indexOf.call(i.parentNode.childNodes,w);return!(r.previous&&n(r.previous)&&r.previous.parentNode===i.parentNode&&u(r.previous)>=u(i)||r.next&&n(r.next)&&r.next.parentNode===i.parentNode&&u(r.next)<=u(i))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!s.subject.length||!s.subject.every(h))return!1;if(e.text){let r=e.text.local,i=u=>u&&n(u.startContainer)&&n(u.endContainer);return i(s.span)&&i(s.scope)&&Xn(s.scope,e.text.encoding)===r.text&&Xn(s.span,e.text.encoding)===r.text.slice(r.start,r.end)}if(e.attribute){let r=e.attribute,i=s.subject[0].node;return(r.namespaceURI?i.getAttributeNS(r.namespaceURI,r.localName):i.getAttribute(r.qualifiedName))===o.local}let l=e.structure;if(l.localOrder){let r=-1,i=null;for(let u of l.localOrder){let w=t.localState.refs.get(u)?.[0]?.node;if(!w||!n(w)||i&&w.parentNode!==i)return!1;let c=Array.prototype.indexOf.call(w.parentNode.childNodes,w);if(c<=r)return!1;i=w.parentNode,r=c}return!0}return l.localAction==="moved"||s.subject.every(r=>Nr(r.node)===r.fragment)}var cl=1,dn=e=>!!e&&e.nodeType===1,Xo=e=>dn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function to(e,o=null,t=null){let n=new Map,s=new Map,h=w=>{if(!o){o=new WeakMap;let c=[e];for(;c.length;){let p=c.pop();Xo(p)&&(o.set(p.content,p),c.push(p.content));for(let b=p.firstChild;b;b=b.nextSibling)b.nodeType===1&&c.push(b)}}return o.get(w)||null},l=(w,c)=>{let p=s.get(w);if(!p){p=new Map;let b=0;for(let S=w.firstChild;S;S=S.nextSibling)p.set(S,b++);s.set(w,p)}return p.get(c)},r=w=>{if(!w)return null;if(t&&t.has(w))return r(t.get(w));if(w===e)return[];let c=n.get(w);if(c!==void 0)return c;let p=w.parentNode,b=null;if(p&&p.nodeType===11){let S=h(p),C=S?r(S):null;C&&(b=C.concat(["content",l(p,w)]))}else if(p){let S=r(p);S&&(b=S.concat([l(p,w)]))}return n.set(w,b),b};return{root:e,pathOf:r,logicalParent:w=>{let c=w.parentNode;return c&&c.nodeType===11?h(c):c},indexIn:l,containerPath:w=>{if(w.nodeType===11){let p=h(w),b=r(p);return b?b.concat(["content"]):null}let c=r(w);return c&&Xo(w)?c.concat(["content"]):c},ownerOf:h}}var Cn=e=>Xo(e)?e.content:e;function Or(e){let{L:o,R:t,unitsOf:n,provenance:s,policy:h}=e,l=[];return{note:(w,c)=>{l.push([w,c])},finish:w=>l.length?u(w):null};function u(w){let c={base:to(e.roots.base),local:to(e.roots.local),remote:to(e.roots.remote)},p=$=>$==="local"?o:t,b=($,a)=>{if(!a)return null;if($.map.has(a))return $.map.get(a);let O=[],P=dn(a)?c.base.logicalParent(a):a.parent;for(;P&&!$.map.has(P);P=c.base.logicalParent(P))O.push(P);if(!P||!$.identical.has(P))return null;let K=$.map.get(P);for(let Z=O.length-1;Z>=0&&K;Z--)K=Cn(K).childNodes[c.base.indexIn(O[Z].parentNode,O[Z])];return K?dn(a)?Cn(K).childNodes[c.base.indexIn(a.parentNode,a)]||null:n(K)[n(a.parent).indexOf(a)]||null:null},S=new Map,C=new Map,m=new WeakMap,f=0,g=($,a)=>{let O=S.get($);O||S.set($,O=[]),O.push(a)};(function $(a){C.set(a,f++);let O=s.get(a);if(O&&!O.pinned){for(let P of[O.base,O.local,O.remote])if(P)if(Array.isArray(P))for(let K of P)g(K,a);else g(P,a)}if(Xo(a)){m.set(a.content,a);for(let P=a.content.firstChild;P;P=P.nextSibling)$(P)}for(let P=a.firstChild;P;P=P.nextSibling)$(P)})(w);let I=new Map;c.out=to(w,m,I);let v={refs:new Map,spans:new Map,anchors:new Map,via:I,outOwners:m,outRoot:w,localRoot:e.roots.local},T=$=>dn($)?[$]:$.nodes,A=($,a)=>{let O=c[a].logicalParent($);if(!O)return null;for(let P of n(O))if(!dn(P)&&P.nodes.includes($))return P;return null},E=($,a)=>$==null?null:Array.isArray($)?$.length?A($[0],a):null:$,N=$=>{let a=new Set,O=[];for(let P of $)for(let K of S.get(P)||[])a.has(K)||(a.add(K),O.push(K));return O.sort((P,K)=>C.get(P)-C.get(K))},M=new Map,R=$=>{let a=$.b||$.l||$.r,O=M.get(a);if(O)return O;let P=[];for(let K of[$.b,$.l,$.r])K&&P.push(...T(K));return O=N(P),M.set(a,O),O},V=$=>({b:$,l:b(o,$),r:b(t,$)}),D=($,a)=>{let O=p(a).reverse.get($);if(O)return V(O);for(let P of N(T($))){let K=s.get(P);if(K&&!K.base&&K.local&&K.remote)return{b:null,l:E(K.local,"local"),r:E(K.remote,"remote")}}return a==="local"?{b:null,l:$,r:null}:{b:null,l:null,r:$}},j=new Map,y=$=>{let a=s.get($);if(!a||a.pinned)return null;let O=E(a.base,"base");if(O)return V(O);let P=E(a.local,"local"),K=E(a.remote,"remote");if(P){let Z=o.reverse.get(P);if(Z)return V(Z)}if(K){let Z=t.reverse.get(K);if(Z)return V(Z)}return P||K?{b:null,l:P,r:K}:null},k=$=>(j.has($)||j.set($,y($)),j.get($)),J=($,a)=>dn($)?c[a].logicalParent($):$.parent,H=new Map,q=new Map,Me=($,a)=>(dn($)?[c[a].pathOf($)]:$.nodes.map(O=>c[a].pathOf(O))).filter(Boolean),Oe=$=>{let a=$.b||$.l||$.r,O=$.b?"base":$.l?"local":"remote",P=q.get(a);if(P)return P;let K=!dn(a),Z=Me(a,O)[0],U=`${O[0]}:${JSON.stringify(Z===void 0?null:Z)}${K?":run":""}`,de=H.get(U);if(de)return q.set(a,de),de;let we=R($);return de={key:U,nodeType:dn(a)?1:a.kind==="comment"?8:3,base:$.b?Me($.b,"base"):[],local:$.l?Me($.l,"local"):[],remote:$.r?Me($.r,"remote"):[],merged:we.map(le=>c.out.pathOf(le)).filter(Boolean),live:[]},H.set(U,de),q.set(a,de),v.refs.set(de,we),de},Re={base:new Map,local:new Map,remote:new Map},ie=new Map,xe=($,a)=>{let O=J($,a);if(!O||O.nodeType!==1)return null;let P=Re[a].get(O);if(!P){let Z=n(O),U=de=>Oe(a==="base"?V(de):D(de,a));P={parent:U(O),refs:Z.map(U),index:new Map(Z.map((de,we)=>[de,we]))},Re[a].set(O,P)}let K=P.index.get($)??-1;return{parent:P.parent,before:P.refs.slice(K+1),after:P.refs.slice(0,Math.max(0,K)).reverse()}},qe=$=>{let a=$.parentNode;if(!a)return null;let O=ie.get(a);if(!O){let K=a.nodeType===11?m.get(a):a,Z=K&&K.nodeType===1?k(K):null;if(!Z)return null;let U=[],de=[],we=new Map;for(let Ae of a.childNodes){let W=k(Ae),X=W&&Oe(W),pe=U.length,be=U.length-1;X&&X!==U[be]&&(U.push(X),be++);let he={ref:X,group:be,after:pe};de.push(he),we.set(Ae,he)}let le=U.length;for(let Ae=de.length-1;Ae>=0;Ae--){let W=de[Ae];W.before=le,W.ref&&(le=W.group)}O={parent:Oe(Z),refs:U,index:we},ie.set(a,O)}let P=O.index.get($);return{parent:O.parent,before:O.refs.slice(P.before),after:O.refs.slice(0,P.after).reverse()}},fe=$=>dn($)?$.outerHTML:$.value,x=$=>dn($)?"element":$.kind==="comment"?"comment":"text",Y=($,a)=>({path:$,offset:a}),ae=($,a,O)=>{if(!$)return null;let P=c[O],K=0;if(a){let Z=dn(a)?a:a.nodes[a.nodes.length-1];Z.parentNode&&(K=P.indexIn(Z.parentNode,Z)+1)}return Y(P.containerPath($),K)},oe=($,a)=>{let O=J($,"base"),P=O?b(p(a),O):null;if(!dn(P))return null;let K=n(O),Z=null;for(let U=K.indexOf($)-1;U>=0&&!Z;U--){let de=b(p(a),K[U]);de&&J(de,a)===P&&(Z=de)}return ae(P,Z,a)},Ee=($,a,O,P)=>{let K=c[P],Z=0;for(let U=0;U<$.nodes.length;U++){let de=$.nodes[U],we=de.nodeValue.length,le=U===$.nodes.length-1;if((O==="start"?a<Z+we:a<=Z+we)||le)return Y(K.pathOf(de),Math.max(0,Math.min(a-Z,we)));Z+=we}return null},De=($,a)=>{let O=c[a],P=$.firstChild,K=$.lastChild;return P&&P.nodeType===3&&K.nodeType===3?{start:Y(O.pathOf(P),0),end:Y(O.pathOf(K),K.nodeValue.length)}:{start:Y(O.pathOf($),0),end:Y(O.pathOf($),$.childNodes.length)}},Ne=($,a,O)=>{for(let U of $.nodes)if(O==="start"?U.s<=a&&a<U.e:U.s<a&&a<=U.e)return{kind:"text",node:U.node,offset:a-U.s};let P=O==="start"?a:a-1,K=()=>{for(let U of $.nodes)if(U.s===a||U.e===a)return{kind:"text",node:U.node,offset:a-U.s};return null},Z=$.atomAt.get(P);if(Z)return{kind:O==="start"?"before":"after",node:Z.el};if($.text[P]===kt){let U=$.marks.find(we=>we.block&&we.to===P+1);if(U)return O==="start"?{kind:"end",node:U.el}:{kind:"after",node:U.el};let de=$.marks.find(we=>we.block&&we.from===P+1);if(de)return O==="start"?{kind:"before",node:de.el}:{kind:"startOf",node:de.el}}return K()},nt=($,a)=>Ne($,a,"end")||Ne($,a,"start"),Xe=($,a)=>{switch(a.kind){case"text":return Y($.pathOf(a.node),a.offset);case"end":return Y($.containerPath(a.node),Cn(a.node).childNodes.length);case"startOf":return Y($.containerPath(a.node),0);default:{let O=a.node.parentNode;return Y($.containerPath(O),$.indexIn(O,a.node)+(a.kind==="after"?1:0))}}},ht=($,a,O,P,K)=>{let Z=Ne($,a,O);return Z?Xe(c[P],Z):K()},Ge=($,a,O,P)=>{let K=$.textNodes.map(le=>({s:le.ms,e:le.me,start:{kind:"text",node:le.node,offset:0},end:{kind:"text",node:le.node,offset:le.me-le.ms}}));for(let[le,Ae]of $.atomOut)K.push({s:le,e:le+1,start:{kind:"before",node:Ae},end:{kind:"after",node:Ae}});for(let[le,Ae]of $.breakOut)K.push({s:le,e:le+1,start:{kind:"end",node:Ae},end:{kind:"after",node:Ae}});for(let le of K)if(le.start.kind==="text"&&le.s<a&&a<le.e)return{kind:"text",node:le.start.node,offset:a-le.s};if(O!=="empty"){let le=K.find(Ae=>O==="start"?Ae.s===a:Ae.e===a);if(le)return O==="start"?le.start:le.end}let Z=K.find(le=>le.e===a);if(Z)return Z.end;let U=K.find(le=>le.s===a);if(U)return U.start;let de=null,we=null;for(let le of K)le.e<=a&&(!de||le.e>de.e)&&(de=le),le.s>=a&&(!we||le.s<we.s)&&(we=le);return de?de.end:we?we.start:P()},rt=($,a)=>{if(!a)return null;if(a.kind==="text"){let K=$.nodes.find(Z=>Z.node===a.node);return K?K.s+Math.min(a.offset,K.e-K.s):null}let O=$.atoms.find(K=>K.el===a.node);if(O)return a.kind==="after"?O.i+1:O.i;let P=$.marks.find(K=>K.el===a.node);return P?a.kind==="before"&&P.block&&$.text[P.from-1]===kt&&!$.marks.some(K=>K.block&&K.to===P.from)?P.from-1:a.kind==="startOf"||a.kind==="before"?P.from:a.kind==="end"&&P.block?P.to-1:P.to:null},Ot=($,a,O,P)=>{for(let de of $.nodes)if(O==="start"?de.s<=a&&a<de.e:de.s<a&&a<=de.e)return{kind:"text",node:de.node,offset:a-de.s};let K=O==="start"?a:a-1;if(!$.atomAt.has(K)&&$.text[K]!==kt){for(let de of $.nodes)if(de.s===a||de.e===a)return{kind:"text",node:de.node,offset:a-de.s}}let Z=$.atomAt.get(K);if(Z)return{kind:O==="start"?"before":"after",node:Z.el};if($.text[K]===kt){let de=$.marks.find(le=>le.block&&le.to===K+1);if(de)return O==="start"?{kind:"end",node:de.el}:{kind:"after",node:de.el};let we=$.marks.find(le=>le.block&&le.from===K+1);if(we)return O==="start"?{kind:"before",node:we.el}:{kind:"startOf",node:we.el}}let U=$.marks.find(de=>de.block&&de.from===a);return U?{kind:"startOf",node:U.el}:P?{kind:O==="start"?"startOf":"end",node:P}:null},Ct=$=>{if(!$)return null;if($.kind==="wholeStart"||$.kind==="wholeEnd"){let a=wt($.node);return $.kind==="wholeStart"?a.start:a.end}return Xe(c.out,$)},wt=$=>{let a=$.firstChild,O=$.lastChild;return a&&a.nodeType===3&&O.nodeType===3?{start:Y(c.out.pathOf(a),0),end:Y(c.out.pathOf(O),O.nodeValue.length)}:{start:Y(c.out.pathOf($),0),end:Y(c.out.pathOf($),$.childNodes.length)}},Nt=$=>{let a=J($,"base"),O=a?R(V(a))[0]:null;if(!O)return null;let P=Cn(O),K=n(a);for(let Z=K.indexOf($)-1;Z>=0;Z--){let U=R(V(K[Z])).filter(de=>de.parentNode===P);if(U.length)return{kind:"after",node:U[U.length-1]}}return{kind:"startOf",node:O}},Lt=($,a,O,P,K,Z)=>({text:$,start:a,end:O,fragment:P,span:K,scope:Z}),qt=($,a,O,P,K)=>Lt($,a,O,$.slice(a,O),P,K),cn=($,a,O,P,K)=>(v.spans.set($,{start:a,end:O,scopeStart:P,scopeEnd:K}),$),It=new Map,Gt=new Map,wn=($,a,O)=>{let P=`text:${$.key}:${a}:${O}`,K=Gt.get(P)||0;return Gt.set(P,K+1),`${P}:${K}`},Dt=($,a)=>{let O,P,K,Z="plain",U,de,we,le,Ae,W=(be,he,ee,te,z)=>{if(!be){let ne=oe(z,te);return qt("",0,0,{start:ne,end:ne},{start:ne,end:ne})}return qt(be.value,he,ee,{start:Ee(be,he,he===ee?"end":"start",te),end:Ee(be,ee,"end",te)},{start:Ee(be,0,"start",te),end:Ee(be,be.value.length,"end",te)})};if(a.site==="run"){let{bRun:be,lRun:he,rRun:ee,node:te,c:z}=a;O=V(be),P=z.bs,K=z.be,U=W(be,z.bs,z.be,"base",be),de=W(he,z.ls,z.le,"local",be),we=W(ee,z.rs,z.re,"remote",be);let ne=te?te.nodeValue:"",Te=Ce=>te?{kind:"text",node:te,offset:Ce}:Nt(be);le=cn(qt(ne,z.ms,z.me,{start:Ct(Te(z.ms)),end:Ct(Te(z.me))},{start:Ct(Te(0)),end:Ct(Te(ne.length))}),Te(z.ms),Te(z.me),Te(0),Te(ne.length)),Ae=te||(Nt(be)||{}).node||null}else if(a.site==="whole"){let be=a.el,he=s.get(be);O=V(he.base),P=0,K=$.base.length;let ee=(z,ne,Te)=>{let Ce=De(ne,Te);return qt(z,0,z.length,Ce,Ce)};U=ee($.base,he.base,"base"),de=ee($.local,he.local,"local"),we=ee($.remote,he.remote,"remote");let te=wt(be);le=cn(qt($.resolved,0,$.resolved.length,te,te),{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be},{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be}),Ae=be}else if(a.site==="comment"){let{bRun:be,lRun:he,rRun:ee,node:te}=a;O=V(be),P=0,K=$.base.length;let z=(Pe,ve)=>{if(!Pe){let Ze=oe(be,ve);return qt("",0,0,{start:Ze,end:Ze},{start:Ze,end:Ze})}let _e=Pe.nodes[0],Je={start:Y(c[ve].pathOf(_e),0),end:Y(c[ve].pathOf(_e),Pe.value.length)};return qt(Pe.value,0,Pe.value.length,Je,Je)};U=z(be,"base"),de=z(he,"local"),we=z(ee,"remote");let ne=$.resolved,Te=Pe=>te?{kind:"text",node:te,offset:Pe}:Nt(be),Ce={start:Ct(Te(0)),end:Ct(Te(ne.length))};le=cn(qt(ne,0,ne.length,Ce,Ce),Te(0),Te(ne.length),Te(0),Te(ne.length)),Ae=te||(Nt(be)||{}).node||null}else{let{fb:be,fl:he,fr:ee,scope:te}=a,z=a.merged;Z="html",O=te.base?V(te.base):D(te.local,"local"),P=$.bs,K=$.be;let ne=se=>{let Ie=te[se];for(let Be=te.at-1;Be>=0;Be--){let He=te.units[Be],Ke=se==="base"?He:b(p(se),He);if(Ke&&J(Ke,se)===Ie)return Ke}return null},Te=se=>()=>ae(te[se],ne(se),se),Ce=(se,Ie,Be,He,Ke)=>{let pt=bn=>bn?Xe(c[Ke],bn):Te(Ke)(),tt=Ie===Be?nt(se,Ie):Ne(se,Ie,"start"),Kt=Ie===Be?nt(se,Ie):Ne(se,Be,"end"),Ht=pt(tt),un={start:Ht,end:Ie===Be?Ht:pt(Kt)},bt=a.full?a.full(Ke):null;if(!bt)return Lt(se.text,Ie,Be,He,un,{start:pt(Ne(se,0,"start")),end:pt(Ne(se,se.text.length,"end"))});let lt=tt?rt(bt,tt):null,$e=Kt?rt(bt,Kt):null,vt=lt===null?0:lt,ct=Math.max(vt,$e===null?bt.text.length:$e),jt=pt(Ne(bt,0,"start"));return Lt(bt.text,vt,ct,co(bt,vt,ct),un,{start:jt,end:bt.text.length?pt(Ne(bt,bt.text.length,"end")):jt})};U=a.synthetic?null:Ce(be,$.bs,$.be,$.base,"base"),de=Ce(he,$.lss,$.lse,$.local,"local"),we=Ce(ee,$.rss,$.rse,$.remote,"remote");let[Pe,ve]=$.range||[0,0],_e=z.out,Je=()=>{let se=Cn(z.node);for(let Ie=te.at-1;Ie>=0;Ie--){let Be=R(V(te.units[Ie])).filter(He=>He.parentNode===se);if(Be.length)return{kind:"after",node:Be[Be.length-1]}}for(let Ie=te.at;Ie<te.units.length;Ie++){let Be=R(V(te.units[Ie])).filter(He=>He.parentNode===se);if(Be.length)return{kind:"before",node:Be[0]}}return{kind:"startOf",node:z.node}};if(_e.via)for(let[se,Ie]of _e.via)I.set(se,Ie);let Ze=Ge(z,Pe,Pe===ve?"empty":"start",Je),Ut=Pe===ve?Ze:Ge(z,ve,"end",Je),Pt=_e.text.length?Ot(_e,0,"start",z.node):Je(),L=_e.text.length?Ot(_e,_e.text.length,"end",z.node):Pt,G=rt(_e,Ze),re=rt(_e,Ut),ge=G===null?0:G,ye=Math.max(ge,re===null?_e.text.length:re);le=cn(Lt(_e.text,ge,ye,co(_e,ge,ye),{start:Ct(Ze),end:Ct(Ut)},{start:Ct(Pt),end:Ct(L)}),Ze,Ut,Pt,L);let ce=v.spans.get(le);if(ce.flat=_e,!_e.text.length){let se=Ct(Pt),Ie=Zn(w,se),Be=Ie[0],He=Ie[1];ce.empty={parent:Be.nodeType===11?m.get(Be):Be,previous:Be.childNodes[He-1]||null,next:Be.childNodes[He]||null}}Ae=Ze?Ze.node:z.node}let X=Oe(O),pe=(a.site==="whole"||a.site==="comment"||(a.policy||h)!=="both")&&$.resolved!==$.local;return{key:a.site==="comment"&&It.get(O.b||O.l||O.r)||wn(X,P,K),subject:X,localLost:pe,anchor:Ae,text:{encoding:Z,base:U,local:de,remote:we,merged:le,liveSpan:null,liveScope:null}}},rn=($,a)=>{let O=k(a.el),P=Oe(O),K=a.sample;return{key:`attr:${P.key}:${K.namespaceURI||""}:${K.localName}`,subject:P,localLost:$.resolved!==$.local,anchor:a.el,attribute:{namespaceURI:K.namespaceURI||null,localName:K.localName,qualifiedName:K.name}}},Yt=($,a)=>{let O=$.detail,P=a.unit||V(a.subject),K=Oe(P),Z=v.refs.get(K),U=P.l?xe(P.l,"local"):null,de=P.r?xe(P.r,"remote"):null,we=Z.length?qe(Z[0]):null,le,Ae,W,X=null,pe=null,be=a.deleted;switch(O){case"both-reordered":{le=Ae="reordered";let he=new Set(a.rKept),ee=a.lKept.filter(Ce=>he.has(Ce)&&R(V(Ce)).length),te=Ce=>C.get(R(V(Ce))[0]);X=ee.map(Ce=>Oe(V(Ce))),pe=ee.slice().sort((Ce,Pe)=>te(Ce)-te(Pe)).map(Ce=>Oe(V(Ce)));let z=Ce=>!dn(Ce)&&Ce.kind!=="comment"&&Ce.nodes.every(Pe=>!/[^\t\n\f\r ]/.test(Pe.data)),ne=ee.filter(Ce=>!z(Ce)),Te=ne.slice().sort((Ce,Pe)=>te(Ce)-te(Pe));W=ne.some((Ce,Pe)=>Ce!==Te[Pe]);break}case"both-moved":le=Ae="moved",W=!U||!Z.some(he=>{let ee=he===Z[0]?we:qe(he);return ee&&ee.parent===U.parent});break;case"edit-beats-delete":le=be==="local"?"deleted":"edited",Ae=be==="remote"?"deleted":"edited",W=be==="local";break;case"move-beats-delete":le=be==="local"?"deleted":"moved",Ae=be==="remote"?"deleted":"moved",W=be==="local";break;case"remote-wins":le="edited",Ae="edited",W=!0;break;default:le=Ae="inserted",W=a.localLost}return{key:`structure:${K.key}:${O}`,subject:K,localLost:W,anchor:Z[0]||null,structure:{localAction:le,remoteAction:Ae,localPlacement:U,remotePlacement:de,mergedPlacement:we,localOrder:X,mergedOrder:pe,localFragment:O==="both-reordered"||!P.l?null:fe(P.l),fragmentKind:x(P.b||P.l||P.r)}}};for(let[$,a]of l){if($.kind!=="structure")continue;let O=a.unit||V(a.subject),P=O.b||O.l||O.r;!dn(P)&&P.kind==="comment"&&It.set(P,`structure:${Oe(O).key}:${$.detail}`)}let fn=new Map;for(let[$,a]of l){if($.kind==="structure"){let Z=Oe(a.unit||V(a.subject)),U=`structure:${Z.key}:${$.detail}`,de=fn.get(U);if(de&&de.structure){$.recovery=de;let we=v.refs.get(Z);$.el==null&&we.length&&($.el=dn(we[0])?we[0]:c.out.logicalParent(we[0]));continue}}let O=$.kind==="text"?Dt($,a):$.kind==="attr"?rn($,a):Yt($,a),P=fn.get(O.key);P||(P={version:cl,key:O.key,localLost:O.localLost,subject:O.subject,applied:!1,unavailable:null},fn.set(O.key,P),v.anchors.set(P,O.anchor)),O.text&&(P.text=O.text),O.attribute&&(P.attribute=O.attribute),O.structure&&(P.structure=O.structure),O.text&&(P.localLost=O.localLost),$.recovery=P;let K=v.refs.get(O.subject);$.kind==="structure"&&$.el==null&&K.length&&($.el=dn(K[0])?K[0]:c.out.logicalParent(K[0])),$.kind==="text"&&$.node==null&&K.length&&O.subject.nodeType===8&&($.node=K[0])}return v}}function Ir(e,o,t){if(!o)return;let{lookup:n,vetoed:s,vetoedAttrs:h,liveAttr:l}=t,r=t.ignored||(()=>!1),i=to(t.liveRoot),u=y=>!!y&&i.containerPath(y)!==null,w=y=>{let k=y.parentNode;return k&&k.nodeType===11?o.outOwners.get(k)||null:k},c=y=>{for(let k=y;k;k=w(k))if(o.via.has(k)&&(k=o.via.get(k)),s.has(k)||t.vetoedLive?.has(f(k)))return!0;return!1},p=y=>Array.from(Cn(y).children).filter(k=>!r(k)),b=(y,k)=>p(y)[p(k.parentNode).indexOf(k)],S=(y,k)=>{let J=null,H=null,q=0;for(let ie=k.previousSibling;ie;ie=ie.previousSibling){if(ie.nodeType===1&&!r(ie)){J=ie;break}ie.nodeType===3&&(q+=ie.nodeValue.length)}for(let ie=k.nextSibling;ie&&!H;ie=ie.nextSibling)ie.nodeType===1&&!r(ie)&&(H=ie);let Me=J?b(y,J):null,Oe=H?b(y,H):null;if(J&&!Me||H&&!Oe)return null;let Re=[];for(let ie=Me?Me.nextSibling:Cn(y).firstChild;ie&&ie!==Oe;ie=ie.nextSibling)ie.nodeType===3&&Re.push(ie);return Re.length?{nodes:Re,lead:q}:null},C=y=>{let k=[],J=y;for(;J&&!o.via.has(J);J=J.parentNode)k.push(J);if(!J||!k.length)return null;let H=f(o.via.get(J));for(let Oe=k.length-1;Oe>0&&H;Oe--)H=b(H,k[Oe]);if(!H)return null;let q=k[0];if(q.nodeType===3)return S(H,q);let Me=q.nodeType===1?b(H,q):null;return Me?{nodes:[Me],lead:0}:null},m=y=>{let k=n(y),J=k?{nodes:Array.isArray(k)?k:[k],lead:0}:o.via.size?C(y):null;if(!J)return null;let H=J.nodes.filter(u);return H.length?{nodes:H,lead:J.lead}:null},f=y=>{let k=m(y);return k?k.nodes[0]:null},g=y=>{if(!y)return null;if(y.kind==="text"){let q=m(y.node);if(!q)return null;let Me=q.nodes,Oe=y.offset+q.lead,Re=0;for(let ie=0;ie<Me.length;ie++){let xe=Me[ie].nodeValue.length;if(Oe<=Re+xe||ie===Me.length-1)return Oe>=Re&&Oe<=Re+xe?[Me[ie],Oe-Re]:null;Re+=xe}return null}let k=f(y.node);if(!k)return null;if(y.kind==="end")return[Cn(k),Cn(k).childNodes.length];if(y.kind==="startOf")return[Cn(k),0];if(y.kind==="wholeStart")return k.firstChild?[k.firstChild,0]:[k,0];if(y.kind==="wholeEnd")return k.lastChild?[k.lastChild,k.lastChild.nodeValue.length]:[k,k.childNodes.length];let J=k.parentNode;if(!J)return null;let H=Array.prototype.indexOf.call(J.childNodes,k);return[J,y.kind==="after"?H+1:H]},I=y=>({blocks:new Set((y.flat?.marks||[]).filter(k=>k.block).map(k=>f(k.el)).filter(Boolean)),atoms:new Set((y.flat?.atoms||[]).map(k=>f(k.el)).filter(Boolean)),ignored:r}),v=(y,k,J,H)=>{if(!y||!k||!eo(y)||!eo(k))return!1;for(let Oe of[y,k])if(!u(Oe.startContainer)||!u(Oe.endContainer))return!1;let q=J.merged;if(q.start===q.end&&(y.startContainer!==y.endContainer||y.startOffset!==y.endOffset))return!1;let Me=I(H);return Xn(k,J.encoding,Me)===q.text&&Xn(y,J.encoding,Me)===q.text.slice(q.start,q.end)},T=new Map,A=y=>{let k=y.parentNode;return k?(T.has(k)||T.set(k,new Map(Array.from(k.childNodes,(J,H)=>[J,H]))),T.get(k).get(y)):-1},E=(y,k)=>{if(!k)return!1;let J=i.logicalParent(y);if(!k.parent.live.includes(J))return!1;let H=A(y);for(let[q,Me]of[["before",1],["after",-1]]){let Oe=H;for(let Re of k[q]){if(Re.live.includes(y))continue;let ie=Re.live.filter(qe=>qe!==y&&qe.parentNode===y.parentNode);if(!ie.length)continue;let xe=Me===1?Math.min(...ie.map(A)):Math.max(...ie.map(A));if(Me*(xe-Oe)<=0)return!1;Oe=xe}}return!0},N=y=>{let k=y.structure;if(k.mergedOrder){let J=new Set(y.subject.live.map(Cn)),H=null,q=-1;for(let Me of k.mergedOrder){let Oe=Me.live.find(Re=>J.has(Re.parentNode));if(!Oe||H&&Oe.parentNode!==H||A(Oe)<=q)return!1;H=Oe.parentNode,q=A(Oe)}return y.subject.live.length>0}return y.subject.live.some(J=>E(J,k.mergedPlacement))},M=(y,k)=>{let J=g(y),H=g(k);return J&&H?{startContainer:J[0],startOffset:J[1],endContainer:H[0],endOffset:H[1]}:null},R=new Set,V=y=>{if(!y||R.has(y))return;R.add(y);let k=[];for(let J of o.refs.get(y)||[]){let H=m(J);if(H)for(let q of H.nodes)k.includes(q)||k.push(q)}y.live=k},D=y=>{y&&(V(y.parent),y.before.forEach(V),y.after.forEach(V))},j=new Set;for(let y of e){let k=y.recovery;if(!k||j.has(k))continue;j.add(k),V(k.subject),k.structure&&(D(k.structure.localPlacement),D(k.structure.remotePlacement),D(k.structure.mergedPlacement),(k.structure.localOrder||[]).forEach(V),(k.structure.mergedOrder||[]).forEach(V));let J=o.anchors.get(k),H=J?f(J):null,q=!!H;if(k.text){let x=o.spans.get(k.text.merged),Y=x?M(x.start,x.end):null,ae=x?M(x.scopeStart,x.scopeEnd):null;if(x?.empty){let oe=x.empty,Ee=oe.previous?{kind:"after",node:oe.previous}:{kind:"startOf",node:oe.parent},De=oe.next?{kind:"before",node:oe.next}:{kind:"end",node:oe.parent},Ne=M(Ee,De);!Ne||Ne.startContainer!==Ne.endContainer||Ne.startOffset!==Ne.endOffset?Y=null:Y=ae=Ne}v(Y,ae,k.text,x)||(Y=ae=null),k.text.liveSpan=Y,k.text.liveScope=Y?ae:null,Y||(q=!1)}k.structure&&q&&(q=N(k)),k.attribute&&q&&(q=l(H,k.attribute,y.resolved));let Me=(!!k.attribute||!!k.text&&H?.tagName==="TEXTAREA")&&!!h&&[J,H].some(x=>h.get(x)?.has(k.attribute?k.attribute.qualifiedName:"value")),Oe=o.localState?.states.get(k),Re=!!k.text&&[...t.removedVetoes||[]].some(x=>Oe?.touched.has(x)),ie=k.structure?.localAction==="inserted"&&[...s].some(x=>x===J||J?.contains(x)),xe=J&&c(J)||Me||Re||ie,qe=xe&&Mr(k,y,o,u);qe&&(Re||ie&&k.localLost)&&(q=!1);let fe=!q&&qe&&xe;k.applied=q,k.unavailable=q?null:fe?"hook-veto":"missing-output",fe&&(k.localLost=!1),!q&&k.text&&(k.text.liveSpan=k.text.liveScope=null)}}function Jo(e,o,t){let n=to(o),s=to(t),h=c=>!!c&&s.containerPath(c)!==null,l=c=>{if(c===o)return t;let p=n.pathOf(c);if(p&&o!==t){let b=Zn(t,{path:p,offset:0});if(b&&b[0].nodeType===c.nodeType)return b[0]}return c},r=new Set,i=c=>{!c||r.has(c)||(r.add(c),c.live=c.live.map(l).filter(h))},u=c=>{c&&(c.startContainer=l(c.startContainer),c.endContainer=l(c.endContainer))},w=new Set;for(let c of e){c.node===o&&t.tagName==="SCRIPT"&&(c.node=t),c.el===o&&c.kind==="structure"&&(c.el=t);let p=c.recovery;if(!p||w.has(p))continue;if(w.add(p),i(p.subject),p.text){u(p.text.liveSpan),u(p.text.liveScope);let S=p.text.liveSpan,C=p.text.liveScope,m=p.text.merged,f=g=>!!g&&eo(g)&&h(g.startContainer)&&h(g.endContainer);(!f(S)||!f(C)||Xn(C,p.text.encoding)!==m.text||Xn(S,p.text.encoding)!==m.text.slice(m.start,m.end))&&(p.text.liveSpan=null,p.text.liveScope=null,p.applied=!1,p.unavailable="missing-output")}let b=p.structure;if(b){for(let S of[b.localPlacement,b.remotePlacement,b.mergedPlacement])S&&(i(S.parent),S.before.forEach(i),S.after.forEach(i));(b.localOrder||[]).forEach(i),(b.mergedOrder||[]).forEach(i),p.subject.live.length||(p.applied=!1,p.unavailable="missing-output")}}}var mo=e=>e?.nodeType===1,Io=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function fl({provenance:e,parentOf:o,twins:t,baseOf:n,build:s,ignored:h,remoteWins:l,discarded:r}){let i=new Map,u=new WeakMap;function w(b,S,C,m=!1){if(!mo(b)||!mo(C))return null;let f=i.get(b);if(f)(m||!f.selected&&S==="remote")&&(f.parent=o(C),f.port=C,f.sourceSide=S,f.selected=m);else{let g=u.get(b)||null;f={owner:b,parent:o(C),port:C,sourceSide:S,originalParent:o(b),originalPort:b,selected:m,state:g?"built":"planned",output:g,disposition:null},i.set(b,f)}return f}function c(b,S){if(!mo(b)||!mo(S))return;u.has(b)||u.set(b,S);let C=i.get(b);C&&C.state!=="attached"&&!C.output&&(C.output=S,C.state="built")}function p(b){if(!i.size)return;let S=new Map,C=new WeakMap,m=new WeakMap,f=new WeakSet,g=new Set,I=(D,j)=>{if(!D)return;if(Array.isArray(D)){for(let k of D)I(k,j);return}let y=S.get(D);y||S.set(D,y=[]),y.push(j)},v=(D,j)=>{if(!D)return;let y=[D];for(;y.length;){let k=y.pop();I(k,j);for(let J of Io(k).childNodes)y.push(J)}};function T(D,j=null,y=!1){if(f.has(D))return;f.add(D),C.set(D,j);let k=e.get(D),J=y||!!(k&&l(k.remote||k.base));m.set(D,J);let H={node:D,kind:"node",authority:J};if(k?.pinned)v(k.local,{...H,kind:"ignored"});else if(k?.unchanged)for(let q of[k.base,k.local,k.remote])v(q,{...H,kind:"unchanged"});else if(k){for(let q of[k.base,k.local,k.remote])I(q,H);if(mo(k.local))for(let q of Io(k.local).children)h(q)&&v(q,{...H,kind:"ignored"})}for(let q of Io(D).childNodes)T(q,D,J)}let A=D=>{if(D.output&&f.has(D.output))return D.state="attached",D.disposition="node",!0;let{local:j,remote:y}=t(D.owner);for(let k of[D.owner,j,y]){let J=S.get(k);if(J?.length){let H=J.find(q=>q.kind==="node")||J[0];return D.output=H.node,D.state="attached",D.disposition=H.kind,!0}}return!1},E=(D,j)=>(S.get(D)||[]).find(k=>k.kind==="node"&&mo(k.node)&&(!k.authority||j.sourceSide==="remote"))?.node,N=(D,j,y)=>{let k=S.get(D)||[],J=y?[...k].reverse():k;for(let H of J){if(H.kind!=="node")continue;let q=H.node;for(;q&&C.get(q)!==j;)q=C.get(q);if(q)return q}return null},M=(D,j,y)=>{let k=Io(j);for(let J=y?.previousSibling;J;J=J.previousSibling){let H=N(J,j,!0);if(H){k.insertBefore(D,H.nextSibling);return}}for(let J=y?.nextSibling;J;J=J.nextSibling){let H=N(J,j,!1);if(H){k.insertBefore(D,H);return}}k.appendChild(D)};function R(D,j,y){let k=j==="base"?D:n(D,j),J=i.get(k);J&&J!==y&&V(J)}function V(D){if(D.state==="attached"||D.disposition==="remote-wins"||g.has(D)||A(D))return;g.add(D);let{local:j,remote:y}=t(D.owner);if(l(y||D.owner)){if(!y){D.disposition="remote-wins",r(D.owner,j),g.delete(D);return}D.parent=o(y),D.port=y,D.sourceSide="remote"}if(R(D.parent,D.sourceSide,D),A(D)){g.delete(D);return}let k=E(D.parent,D),J=D.port;if(!k){if(R(D.originalParent,"base",D),A(D)){g.delete(D);return}let q=D.originalParent;for(J=D.originalPort;q&&!k;)k=E(q,D),k||(J=q,q=o(q))}if(!k)throw new Error("A planned move has no allowed surviving parent");let H=D.output||s(D.owner);D.output=H,D.state="built",M(H,k,J),T(H,k,m.get(k)||!1),A(D),g.delete(D)}T(b);for(let D of i.values())V(D)}return{planned:i,has:b=>i.has(b),plan:w,produced:c,drain:p}}function go(e,o,t,n,s,h,l,r,i,u,w,c,p){let b=null;return fl({provenance:e,parentOf:m=>{if(!m)return null;let f=o(m);if(f||m.parentNode?.nodeType!==11)return f;if(!b){b=new WeakMap;let g=[c,p];for(;g.length;){let I=g.pop(),v=Io(I);v!==I&&b.set(v,I);for(let T of v.children)g.push(T)}}return b.get(m.parentNode)||null},twins:m=>({local:s(t,m),remote:s(n,m)}),baseOf:(m,f)=>m&&(f==="local"?t:n).reverse.get(m)||null,build:m=>h(m,s(t,m),s(n,m),!1),ignored:l,remoteWins:r,discarded:(m,f)=>{f&&w(m,f,t)&&!i.some(g=>g.detail==="remote-wins"&&g.base===m)&&u({kind:"structure",el:null,detail:"remote-wins",base:m,local:f,remote:null},{subject:m})}})}function ul({parent:e,base:o,views:t,eligible:n,ignored:s,remoteWins:h,budget:l=$t(2e4*32),maxUnits:r=256,maxCharacters:i=2e4}){let u=(f,g=null)=>({status:f,reason:g,parent:e,records:[]});if(t.some(({V:f})=>f.asBase)||s(e)||h(e)||t.some(({V:f})=>!f.el||s(f.el)||h(f.el)))return u("none");let w=o.length+t[0].V.units.length+t[1].V.units.length;if(w>r)return u("fallback","unit-limit");let c=Symbol(),p=f=>{if(f>l.remaining)throw c;l.remaining-=f,l.crossParentSteps=(l.crossParentSteps||0)+f},b=new Map,S=0,C=f=>{if(p(1),b.has(f))return b.get(f);let g=f.nodeType===1?f.childNodes:f.nodes;p(g.length*4+1);let I=f.nodeType===1?Array.from(g):g,v=0;for(let E=0;E<I.length;E++){let N=I[E];if(N.nodeType!==3||E&&I[E-1].nextSibling!==N)return b.set(f,null),null;v+=N.data.length}if(v>i-S)throw c;p(v*8+1),S+=v;let T=nn(I);if(T.text.includes(kt))return b.set(f,null),null;let A={unit:f,nodes:I,flat:T};return b.set(f,A),A},m=[];try{p(w*8+1);for(let f=0;f<2;f++){let g=t[f].V,I=t[1-f].V,v=[],T=new Map;for(let A=0;A<o.length;A++){p(1);let E=o[A];if(E.kind!=="text"||g.twin(E))continue;let N=I.twin(E);if(!N||N.kind!=="text"||!I.here(N))continue;let M=C(E),R=C(N);if(!M||!R||!/\S/.test(M.flat.text))continue;p(M.flat.text.length*2+1);let V=M.flat.text;T.set(V,(T.get(V)||0)+1),v.push({source:E,opposite:N,sourceModel:M,oppositeModel:R,index:A})}for(let A of v){let{source:E,opposite:N,sourceModel:M,oppositeModel:R,index:V}=A,D=[];for(let Y of[-1,1]){p(1);let ae=o[V+Y];if(!ae||ae.nodeType!==1||!n(ae)||s(ae)||h(ae))continue;let oe=M.nodes[0],Ee=M.nodes.at(-1);if(Y===-1?oe?.previousSibling!==ae:Ee?.nextSibling!==ae)continue;let De=g.twin(ae),Ne=I.twin(ae);if(!De||!Ne||!g.here(De)||I.here(Ne)||g.baseOf(De)!==ae||I.baseOf(Ne)!==ae||!n(De)||!n(Ne)||s(De)||s(Ne)||h(De)||h(Ne)||De.tagName!==ae.tagName||Ne.tagName!==ae.tagName||De.namespaceURI!==ae.namespaceURI||Ne.namespaceURI!==ae.namespaceURI)continue;let nt=C(ae),Xe=C(De),ht=C(Ne);if(!nt||!Xe||!ht||!/\S/.test(nt.flat.text))continue;let Ge=nt.flat.text,rt=M.flat.text,Ot=Xe.flat.text;if(p((Ge.length+rt.length+Ot.length)*3+1),Ot.length!==Ge.length+rt.length)continue;let Ct=Y===-1;(Ct?!Ot.startsWith(Ge)||!Ot.endsWith(rt):!Ot.startsWith(rt)||!Ot.endsWith(Ge))||D.push({owner:ae,target:De,moved:Ne,ownerBase:nt,joined:Xe,ownerOther:ht,targetFrom:Ct?Ge.length:0,retainedFrom:Ct?0:rt.length})}if(!D.length)continue;if(D.length!==1||T.get(M.flat.text)!==1)return u("fallback","ambiguous-origin");let j=D[0],{owner:y,target:k,moved:J,ownerBase:H,joined:q,ownerOther:Me,targetFrom:Oe,retainedFrom:Re}=j;if(p(m.length+1),m.some(Y=>Y.owner===y))return u("fallback","ambiguous-owner");let ie={source:E,target:k,from:0,to:M.flat.text.length,targetFrom:Oe},xe=Dn({base:M.flat,side:q.flat,retained:[],transfers:[{from:ie.from,to:ie.to,target:Oe,destination:y}],budget:l});if(xe.status!=="ready"||xe.covers(ie.from,ie.to)!==!0)return u("fallback",xe.reason||"work-limit");let qe=[{unit:E,model:M,from:0,to:M.flat.text.length},null,null];qe[f+1]={unit:k,model:q,from:Oe,to:Oe+M.flat.text.length},qe[2-f]={unit:N,model:R,from:0,to:R.flat.text.length};let fe=[H,null,null];fe[f+1]=q,fe[2-f]=Me;let x=[y,null,null];x[f+1]=k,x[2-f]=J,m.push({side:f,parent:e,source:E,target:k,owner:y,owners:x,ownerModels:fe,native:qe,models:b,runs:[ie],proof:xe,retained:[{source:y,target:k,from:0,to:H.flat.text.length,targetFrom:Re}]})}}return m.length?{status:"ready",reason:null,parent:e,records:m}:u("none")}catch(f){if(f!==c)throw f;return u("fallback","work-limit")}}function Cr({describe:e,parentOf:o,...t}){let n=new WeakMap,s=new WeakMap,h=t.budget||$t(2e4*32),l=r=>{if(!r)return null;if(n.has(r))return n.get(r);n.set(r,{status:"planning",parent:r,records:[]});let i=e(r),u=i?ul({...t,...i,parent:r,budget:h}):{status:"none",reason:null,parent:r,records:[]};if(n.set(r,u),u.status==="ready")for(let w of u.records)s.set(w.owner,[w]);return u};return{get:l,forOwner(r){return l(o(r))?.status==="ready"&&s.get(r)||null}}}function dl(e,o){if(e.side!==0)return null;let t=e.native[0].model,n=e.ownerModels[0],s=e.native[1].from!==0,h=(I,v)=>s?[...I.nodes,...v.nodes]:[...v.nodes,...I.nodes],l=e.ownerModels.reduce((I,v)=>I+v.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(l*8>o.remaining)return null;o.remaining-=l*8;let r={base:h(n,t),local:e.ownerModels[1].nodes,remote:h(e.ownerModels[2],e.native[2].model)},i=nn(r.base),u=e.ownerModels[1].flat,w=nn(r.remote),c=s?n.flat.text.length:0,p=s?0:t.flat.text.length,b=Dn({base:i,side:u,retained:e.retained.map(I=>({from:p+I.from,to:p+I.to,target:I.targetFrom})),transfers:e.runs.map(I=>({from:c+I.from,to:c+I.to,target:I.targetFrom,destination:e.owner})),budget:o});if(b.status!=="ready"||b.covers(0,i.text.length)!==!0)return null;let S=e.ownerModels[2].flat,C=e.native[2].model.flat,m=[];for(let[I,v,T,A]of[[n.flat,S,p,s?0:C.text.length],[t.flat,C,c,s?S.text.length:0]]){let E=xs(I,I,v).remoteMap.bTo,N=-1;for(let M=0;M<I.text.length;M++){if(E[M]<0){N=-1;continue}let R=m.at(-1);N>=0&&R.to===T+M&&R.target+R.to-R.from===A+E[M]?R.to++:(m.push({from:T+M,to:T+M+1,target:A+E[M]}),N=M)}}let f=Dn({base:i,side:w,retained:m,transfers:[],budget:o});if(f.status!=="ready")return null;let g=xs(i,u,w,{},{local:b,remote:f});return g.localEdits.hunks.length?null:(g.localMap=b,g.remoteMap=f,{nodes:r,prepared:g})}function Lr({L:e,R:o,twinIn:t,unitsOf:n,view:s,parentOf:h,ignored:l,remoteWins:r,eligible:i,build:u,out:w,policy:c,provenance:p,textMappers:b,segments:S,conflicts:C,conflict:m,decisions:f}){let g=$t(2e4*32),I=D=>{let j=0;for(let y=D;y;y=h(y))if(++j>64||y.nodeType===1&&(l(y)||r(y)))return!1;return!0},v=Cr({parentOf:h,eligible:i,ignored:l,remoteWins:r,budget:g,describe(D){let j=t(e,D),y=t(o,D);return!j||!y||!I(D)||!I(j)||!I(y)?null:{base:n(D),views:[{A:e,V:s(e,j,D,!1)},{A:o,V:s(o,y,D,!1)}]}}}),T=new WeakSet,A=new WeakMap,E=new WeakSet,N=[];function M(D){if(!D||T.has(D))return;T.add(D);let j=v.get(D);if(j?.status==="ready")for(let y of j.records){if((D.tagName==="TEMPLATE"&&D.content?D.content:D).childNodes.length!==y.native[0].model.nodes.length+1||!y.owners.every(I))continue;let J=dl(y,g);if(!J)continue;let H={record:y,payload:J,state:"planned",output:null,result:null};A.set(y.owner,H),E.add(y.source),E.add(y.native[2].unit),N.push(H)}}function R(D,j){let y=A.get(D);if(!y)return!1;if(!y.result){if(y.result=Ko({...y.payload.nodes,prepared:y.payload.prepared,out:w,policy:c,provenance:p,textMappers:b,conflicts:C,conflict:m,decisions:f,node:j}),y.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");S.push(...y.result.segments),y.decision={kind:"text",node:j,source:"local"},f.push(y.decision)}return y.decision.node=j,j.replaceChildren(...y.result.nodes),y.output=j,y.state="built",!0}function V(D){if(!N.length)return;let j=new WeakSet,y=new WeakMap,k=new WeakMap,J=new WeakMap,H=xe=>xe.tagName==="TEMPLATE"&&xe.content?xe.content:xe,q=(xe,qe)=>{if(!xe)return;if(Array.isArray(xe)){for(let x of xe)q(x,qe);return}let fe=J.get(xe);fe||J.set(xe,fe=[]),fe.push(qe)},Me=(xe,qe=null,fe=!1)=>{j.add(xe),y.set(xe,qe);let x=p.get(xe),Y=fe||!!(x&&r(x.remote||x.base));if(k.set(xe,Y),x)for(let ae of[x.base,x.local,x.remote])q(ae,xe);if(!(x?.pinned||x?.unchanged))for(let ae of H(xe).childNodes)Me(ae,xe,Y)},Oe=xe=>(J.get(xe)||[]).find(qe=>qe.nodeType===1&&!k.get(qe)&&!p.get(qe)?.pinned&&!p.get(qe)?.unchanged),Re=(xe,qe)=>{for(let fe of J.get(xe)||[]){let x=fe;for(;x&&y.get(x)!==qe;)x=y.get(x);if(x)return x}return null},ie=(xe,qe,fe)=>{let x=H(qe);for(let Y=fe.nextSibling;Y;Y=Y.nextSibling){let ae=Re(Y,qe);if(ae){x.insertBefore(xe,ae);return}}for(let Y=fe.previousSibling;Y;Y=Y.previousSibling){let ae=Re(Y,qe);if(ae){x.insertBefore(xe,ae.nextSibling);return}}x.appendChild(xe)};Me(D);for(let xe of N){let{record:qe}=xe,fe=Oe(qe.owner)||Oe(qe.owners[1])||Oe(qe.owners[2]);if(fe)(!xe.result||xe.output!==fe||xe.result.nodes.some(x=>!j.has(x)||y.get(x)!==fe)||fe.textContent!==xe.result.text)&&(R(qe.owner,fe),Me(fe,y.get(fe),k.get(fe)));else{let x=qe.parent,Y=qe.owner,ae=null;for(;x&&!ae;)ae=Oe(x),ae||(Y=x,x=h(x));if(!ae)throw new Error("A cross-parent payload has no allowed surviving parent");fe=xe.output||u(qe.owner,qe.owners[1],qe.owners[2],!1),xe.result||R(qe.owner,fe),ie(fe,ae,Y),Me(fe,ae,k.get(ae))}xe.state="attached"}}return{ensureParent:M,ensureOwner(D){M(h(D))},consumes(D){return E.has(D)},render:R,drain:V}}var Mn=/\S/,Er=/[\p{L}\p{N}]/u;function no(e,o,t,n){if(e?.nodeType!==1||!o(e))return!1;for(let s=e.firstChild;s;s=s.nextSibling)if(n(t,1),s.nodeType!==3)return!1;return!!e.firstChild}function Is(e,o,t){for(let n=e.parentNode;n;n=n.parentNode)if(t(o,1),n.nodeType===11)return!1;return!0}function Rr(e,o,t,n,s){let h=t(e,n),l=t(o,n),r=null,i=null,u=null,w=null;s(n,h.length+l.length);for(let c of h)Er.test(c.raw)&&(r||=c,i=c);for(let c of l)Er.test(c.raw)&&(u||=c,w=c);return!!(r&&u&&(r.raw===u.raw||i.raw===w.raw))}function hl({base:e,V:o,A:t,source:n,original:s,current:h,edited:l,destination:r,at:i,ownLength:u,eligible:w,model:c,tokensOf:p,budget:b,charge:S}){let C=s.flat.text,m=h.flat.text,f=l.flat.text,g=r.flat.text;if(S(b,C.length+m.length+g.length),C.startsWith(m)||C.endsWith(m))return!1;let I=Mn.test(g.slice(0,i)),v=Mn.test(g.slice(i+u));if(I===v)return!1;let T=I?0:i+u,A=I?i:g.length;for(;T<A&&!Mn.test(g[T]);)T++;for(;A>T&&!Mn.test(g[A-1]);)A--;let E=g.slice(T,A);if(In(E,g,p(r,b),b,S,!0)!==T)return!1;let N=In(E,C,p(s,b),b,S,!0);if(N<0)return!1;let M=N+E.length,R=!Mn.test(C.slice(0,N)),V=!Mn.test(C.slice(M));if(R===V||In(E,m,p(h,b),b,S,!1)>=0)return!1;let D=R?C.slice(M):C.slice(0,N),j=R?f.length-D.length:0;if(S(b,C.length+f.length),j<0||!Mn.test(D)||In(D,f,p(l,b),b,S,!0)!==j||!Mn.test(R?f.slice(0,j):f.slice(D.length)))return!1;for(let y of e){if(S(b,1),y===n||!no(y,w,b,S))continue;let k=c(y,null,b);if(In(E,k.flat.text,p(k,b),b,S,!1)>=0)return!1}for(let y of o.units){if(S(b,1),y===h.unit||y===r.unit||!no(y,w,b,S))continue;let k=c(y,t,b);if(In(E,k.flat.text,p(k,b),b,S,!1)>=0)return!1}return!0}function Pr({base:e,views:o,side:t,attempt:n,eligible:s,blocked:h,baseId:l,model:r,tokensOf:i,charge:u,exhausted:w,limit:c}){if(c<=0)return null;let p=$t(c),{V:b,A:S,idOf:C}=o[t],m=o[1-t],[f,g,I,v]=n,T=null;try{for(let A=f;A<=g;A++){u(p,1);let E=e[A];if(E.parentNode?.nodeType!==1||h.has(E)||S.identical.has(E)||m.A.identical.has(E)||!no(E,s,p,u)||l(E))continue;let N=b.twin(E),M=m.V.twin(E);if(!N||!M||!b.here(N)||!m.V.here(M)||S.map.get(E)!==N||S.reverse.get(N)!==E||m.A.map.get(E)!==M||m.A.reverse.get(M)!==E||C(N)||m.idOf(M)||N.tagName!==E.tagName||M.tagName!==E.tagName||!no(N,s,p,u)||!no(M,s,p,u)||!Is(E,p,u)||!Is(N,p,u)||!Is(M,p,u))continue;let R=r(E,null,p),V=r(N,S,p),D=r(M,m.A,p),j=R.flat.text,y=V.flat.text,k=D.flat.text;if(u(p,j.length+y.length+k.length),!Mn.test(j)||!Mn.test(y)||!Mn.test(k)||j===y||j===k||y===k||!Rr(R,V,i,p,u)||!Rr(R,D,i,p,u))continue;let J=null,H=!1;for(let Oe=I;Oe<=v;Oe++){u(p,1);let Re=b.units[Oe],ie=b.baseOf(Re);if(!ie||ie===E||h.has(ie)||ie.parentNode!==E.parentNode||Re.parentNode!==N.parentNode||ie.tagName!==E.tagName||Re.tagName!==E.tagName||S.map.get(ie)!==Re||S.reverse.get(Re)!==ie||l(ie)!==C(Re)||!no(ie,s,p,u)||!no(Re,s,p,u))continue;let xe=r(ie,null,p),qe=r(Re,S,p),fe=xe.flat.text,x=qe.flat.text;if(u(p,fe.length),!Mn.test(fe)||x.length<=fe.length)continue;let Y=i(qe,p),ae=In(fe,x,Y,p,u,!0);if(!(ae<0||In(j,x,Y,p,u,!0,ae,ae+fe.length)<0&&!hl({base:e,V:b,A:S,source:E,original:R,current:V,edited:D,destination:qe,at:ae,ownLength:fe.length,eligible:s,model:r,tokensOf:i,budget:p,charge:u}))){if(J){H=!0;break}J=Re}}if(!J||H)continue;let q=t===0?N:M,Me=t===0?M:N;(T||=[]).push({source:E,local:q,remote:Me,models:[R,t===0?V:D,t===0?D:V]})}}catch(A){if(A!==w)throw A}return T}var Hn=/\S/,gn=/\s/,pl=/[\s\u001e]/g,Cs=/[^\s\p{P}\u001e\ufffc]/u;function ml(e,o,t,n,s,h,l){let r=0;for(let i of e)l(h,1),i.nodeType===1&&!n.baseOf(i)&&r++;if(r<2)return!1;for(let i of e){if(i.nodeType!==1||n.baseOf(i))continue;let u=s.get(i).flat;if(u.atoms.length||u.pins?.length)continue;l(h,u.text.length*2+o.length+t.length);let w=new Uint8Array(u.text.length);for(let c of t)c.target===i&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c of o)c.target===i&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c=0;c<u.text.length;c++)if(!w[c]&&Hn.test(u.text[c]))return!0}return!1}function gl(e,o,t){let{source:n,models:s,retained:h,runs:l}=e,r=s.get(n).flat.text;t(o,r.length*2+h.length+l.length);let i=new Uint8Array(r.length);for(let u of h)u.source===n&&(t(o,u.to-u.from),i.fill(1,u.from,u.to));for(let u of l)t(o,u.to-u.from),i.fill(1,u.from,u.to);for(let u=0;u<r.length;u++)if(!i[u]&&Hn.test(r[u]))return!1;return!0}function bl(e,o,t,n,s,h,l,r,i,u){let w=h.get(e),c=h.get(o),p=w.flat.text,b=l.get(e);i(u,p.length*2+t.length);let S=p.length,C=0;for(let g=0;g<p.length;g++)!gn.test(p[g])&&!b[g]&&(S=Math.min(S,g),C=g+1);if(S>=C)return null;for(let g=S;g<C;g++)if(!gn.test(p[g])&&b[g])return null;let m=-1;for(let g of t)if(g.target===o&&g.from<=S&&g.to>S){m=g.targetFrom+S-g.from;break}if(m<0)return null;let f=p.slice(S,C);if(i(u,f.length*(t.length+2)),c.flat.text.slice(m,m+f.length)!==f)return null;for(let g=S;g<C;g++){if(gn.test(p[g]))continue;let I=!1;for(let v of t)if(v.target===o&&v.from<=g&&v.to>g&&v.targetFrom+g-v.from===m+g-S){I=!0;break}if(!I)return null}if(w.flat.atoms.length||c.flat.atoms.length){i(u,w.flat.atoms.length+c.flat.atoms.length);let g=0,I=c.flat.atoms;for(;g<I.length&&I[g].i<m;)g++;for(let v of w.flat.atoms){if(v.i<S||v.i>=C)continue;let T=I[g++];if(!T||T.i!==m+v.i-S||c.alignment?.reverse.get(T.el)!==v.el)return null}if(g<I.length&&I[g].i<m+C-S)return null}for(let[g,I,v]of[[n,e,S],[s,o,m]]){let T=!1;for(let A of g){let E=h.get(A),N=l.get(A),M=r(E,u);for(let R=0;R<M.length;R++){let V=M[R].from,D=V+f.length;if(i(u,f.length*2+1),E.flat.text.slice(V,D)!==f)continue;let j=R;for(;j<M.length&&M[j].to<D;)i(u,1),j++;if(j===M.length||M[j].to!==D)continue;let y=!0;for(let k=V;k<D;k++)if(!gn.test(E.flat.text[k])&&N[k]){y=!1;break}if(y){if(T||A!==I||V!==v)return null;T=!0}}}if(!T)return null}return f}function wl(e,o,t,n,s,h,l,r){if(l(r,s.length+h.length+(n.length+1)*t.length*2),!t)return!1;let i=n.indexOf(t);return i<0||n.lastIndexOf(t)!==i||!h.some(u=>u.from===i)||!h.some(u=>u.to===i+t.length)?!1:s.some(u=>u.source===e&&u.target===o&&u.from===0&&u.to===t.length&&u.targetFrom===i)}function Br({base:e,views:o,eligible:t,baseId:n,ignored:s,remoteWins:h,atomKey:l,limit:r=2e4*8}){if(r<=0)return null;let i=Symbol(),u=(v,T)=>{if(T>v.remaining)throw i;v.remaining-=T},w=[new Map,new Map];for(let v=0;v<2;v++)for(let T=0;T<o[v].V.units.length;T++)w[v].set(o[v].V.units[T],T);let c=new Int32Array(e.length),p=new Int32Array(e.length),b=v=>o.every(({V:T},A)=>{let E=T.twin(v);return E&&w[A].has(E)}),S=-1;for(let v=0;v<e.length;v++)c[v]=S,b(e[v])&&(S=v);S=e.length;for(let v=e.length-1;v>=0;v--)p[v]=S,b(e[v])&&(S=v);let C=new Map,m=(v,T)=>{if(u(T,1),C.has(v))return C.get(v);let A=v.firstChild,E=1;for(;A;){if(u(T,E*8+8),A.nodeType===3&&u(T,A.data.length*8),A.nodeType===1&&Tn.has(A.tagName)&&!s(A)&&!h(A)&&A.firstChild){A=A.firstChild,E++;continue}for(;A&&A!==v&&!A.nextSibling;)A=A.parentNode,E--;A=!A||A===v?null:A.nextSibling}let N=nn(Array.from(v.childNodes),{ignored:s,remoteWins:h});return C.set(v,N),N},f=(v,T,A,E,N,M)=>{for(let R of v.atoms){u(M,1);let V=T.atomAt.get(R.i+A);if(!V)return!1;let D=E?.reverse.get(R.el)||l(R.el),j=N?.reverse.get(V.el)||l(V.el);if(D!==j)return!1}return!0},g=(v,T,A,E,N)=>{let M=v.text.length<=T.text.length?v:T,R=M===v?T:v;if(u(N,M.text.length+R.text.length),!M.text||!Hn.test(M.text.replaceAll(Un,"")))return!1;let V;if(M.text===R.text)V=0;else{let D=R.text.length-M.text.length;if(u(N,(D+1)*M.text.length*2),R.text.startsWith(M.text))V=0;else if(R.text.endsWith(M.text))V=D;else return!1;if(R.text.indexOf(M.text)!==V||R.text.lastIndexOf(M.text)!==V)return!1;u(N,R.text.length*2);let j=0,y=V===0,k=!1;for(let J of an(R.text,xn(R.text)))j+=J.len,j===V&&(y=!0),j===V+M.text.length&&(k=!0);if(!y||!k)return!1}return M===v?f(M,R,V,A,E,N):f(M,R,V,E,A,N)},I=null;for(let v=0;v<2;v++){let{V:T,A,idOf:E}=o[v],N=o[1-v];if(!T.asBase)for(let M=0;M<e.length;M++){let R=e[M];if(T.twin(R)||!t(R))continue;let V=N.V.twin(R);if(!V||!w[1-v].has(V)||!t(V))continue;let D={remaining:r};try{let j=c[M],y=p[M],k=0;for(let Me=j+1;Me<y;Me++)u(D,1),!T.twin(e[Me])&&N.V.twin(e[Me])&&t(e[Me])&&k++;if(k!==1||m(R,D).text===m(V,D).text)continue;let J=j<0?-1:w[v].get(T.twin(e[j])),H=y===e.length?T.units.length:w[v].get(T.twin(e[y]));if(J===void 0||H===void 0||J>=H)continue;let q=null;for(let Me=J+1;Me<H;Me++){u(D,1);let Oe=T.units[Me];if(T.baseOf(Oe)||!t(Oe)||Oe.tagName!==R.tagName||Oe.namespaceURI!==R.namespaceURI)continue;let Re=n(R),ie=N.idOf(V),xe=E(Oe);if(!(Re&&ie&&Re!==ie||Re&&xe&&Re!==xe||ie&&xe&&ie!==xe)&&g(m(V,D),m(Oe,D),N.A,A,D)){if(q){q=null;break}q=Oe}}if(!q)continue;I||(I=[new Map,new Map]),I[v].set(R,q)}catch(j){if(j!==i)throw j}}}return I?o.map(({V:v},T)=>{let A=I[T];if(!A.size)return v;let E=new Map;for(let[N,M]of A)E.set(M,N);return{...v,twin:N=>A.get(N)||v.twin(N),baseOf:N=>E.get(N)||v.baseOf(N)}}):null}function jr({onUncertainSource:e,onUncertainOwner:o,base:t,views:n,eligible:s,ignored:h,remoteWins:l,baseId:r,atomKey:i,limit:u=2e4*32}){if(u<=0)return null;let w=new Set(t),c=new Map(t.map((j,y)=>[j,y])),p=new Map,b=[],S=null,C=null,m=null,f=new Set;for(let j of t)for(let{V:y}of n){let k=y.twin(j);k&&!y.asBase&&!y.here(k)&&f.add(j)}let g=new Set,I=Symbol(),v=(j,y)=>{if(y>j.remaining)throw I;j.remaining-=y},T=(j,y,k)=>{v(k,1);let J=p.get(j);if(J)return J;if(j.nodeType===1){let Me=j.firstChild,Oe=1;for(;Me;){if(v(k,Oe*8+8),Me.nodeType===3&&v(k,Me.data.length*8),Me.nodeType===1&&Tn.has(Me.tagName)&&!h(Me)&&!l(Me)&&Me.firstChild){Me=Me.firstChild,Oe++;continue}for(;Me&&Me!==j&&!Me.nextSibling;)Me=Me.parentNode,Oe--;Me=!Me||Me===j?null:Me.nextSibling}}else v(k,j.value.length*8+j.nodes.length);let H=j.nodeType===1?Array.from(j.childNodes):j.nodes,q=H.length===1&&H[0].nodeType===3?{text:H[0].data,nodes:[{node:H[0],s:0,e:H[0].data.length}],atoms:[]}:nn(H,{ignored:h,remoteWins:l});return J={unit:j,flat:q,alignment:y,tokens:null},p.set(j,J),J},A=(j,y)=>{if(j.tokens)return j.tokens;v(y,j.flat.text.length*8);let{unit:k,flat:J,alignment:H}=j,q=[],Me=xn(J.text),Oe=0,Re=ie=>{for(let xe of an(J.text.slice(Oe,ie),Me))xe.from=Oe,xe.to=Oe+xe.len,xe.unit=k,q.push(xe),Oe+=xe.len};for(let ie of J.atoms){Re(ie.i);let xe=l(ie.el)&&ie.el.nodeType===1?"w"+ie.el.tagName+"#"+(ie.el.id||""):i(H?.reverse.get(ie.el)||ie.el);q.push({k:xe,raw:Un,len:1,from:Oe,to:Oe+1,unit:k,atom:!0}),Oe++}return Re(J.text.length),j.tokens=q,q},E=(j,y,k,J,H)=>{if(!j.flat.atoms.length&&!y.flat.atoms.length)return!0;let q=A(j,H),Me=A(y,H);v(H,q.length+Me.length);let Oe=0;for(let Re of Me){if(!Re.atom||Re.from<k||Re.from>=k+J)continue;for(;Oe<q.length&&!q[Oe].atom;)Oe++;let ie=q[Oe++];if(!ie||ie.from!==Re.from-k||ie.k!==Re.k)return!1}for(;Oe<q.length;)if(q[Oe++].atom)return!1;return!0},N=(j,y,k)=>{let J=j.length+y.length+4;if(J*8>k.remaining)return null;k.remaining-=J*8;let H=Math.floor(k.remaining/8),q=Math.min(j.length+y.length,4e3,Math.floor((Math.sqrt(J*J+H)-J)/2)),Me=4*(q+1)*(J+q+1);if(q<1||Me>k.remaining)return null;k.remaining-=Me;let Oe=Wn(j,y,q),Re=[],ie=0,xe=0;for(let qe of Oe.hunks){for(;ie<qe.bs;)j[ie].raw===y[xe].raw&&Re.push([j[ie],y[xe]]),ie++,xe++;ie=qe.be,xe+=qe.toks.length}for(;ie<j.length&&xe<y.length;)j[ie].raw===y[xe].raw&&Re.push([j[ie],y[xe]]),ie++,xe++;return Re},M=(j,y,k,J,H,q,Me)=>{if(H<=J)return;let Oe=j[j.length-1];if(Oe&&Oe.source===y&&Oe.target===k&&Oe.to<=J&&Oe.targetFrom-Oe.from===q-J){v(Me,(J-Oe.to)*3);let Re=p.get(y).flat.text,ie=p.get(k).flat.text,xe=!0;for(let qe=Oe.to;qe<J;qe++)if(!gn.test(Re[qe])||Re[qe]!==ie[q+qe-J]){xe=!1;break}if(xe){Oe.to=H;return}}j.push({source:y,target:k,from:J,to:H,targetFrom:q})},R=j=>j.replace(pl,"");for(let j=0;j<n.length;j++){let{V:y,A:k,idOf:J}=n[j];if(y.asBase)continue;let H=new Map(y.units.map((x,Y)=>[x,Y])),q=x=>{let Y=y.twin(x);return Y&&H.has(Y)?Y:null},Me=(x,Y)=>{let ae=new Int32Array(x.length),oe=new Int32Array(x.length),Ee=-1;for(let De=0;De<x.length;De++)ae[De]=Ee,Y(x[De])&&(Ee=De);Ee=x.length;for(let De=x.length-1;De>=0;De--)oe[De]=Ee,Y(x[De])&&(Ee=De);return{prev:ae,next:oe}},Oe=Me(t,x=>(x.nodeType===1||x.kind==="text"&&Hn.test(x.value))&&q(x)),Re=Me(y.units,x=>(x.nodeType===1||x.kind==="text"&&Hn.test(x.value))&&w.has(y.baseOf(x))),ie=new Map,xe=(x,Y,ae,oe)=>{if(x>Y||ae>oe)return;let Ee=`${x}:${Y}:${ae}:${oe}`;ie.set(Ee,[x,Y,ae,oe])};for(let x=0;x<y.units.length;x++){let Y=y.units[x];if(y.baseOf(Y)||!s(Y))continue;let ae=Re.prev[x],oe=Re.next[x],Ee=ae<0?0:c.get(y.baseOf(y.units[ae])),De=oe===y.units.length?t.length-1:c.get(y.baseOf(y.units[oe]));xe(Ee,De,Math.max(0,ae),Math.min(y.units.length-1,oe))}for(let x=0;x<t.length;x++){let Y=t[x];if(f.has(Y)||!s(Y))continue;if(!y.twin(Y)){let nt=Oe.prev[x],Xe=Oe.next[x],ht=nt<0?0:H.get(q(t[nt])),Ge=Xe===t.length?y.units.length-1:H.get(q(t[Xe]));xe(Math.max(0,nt),Math.min(t.length-1,Xe),ht,Ge)}let ae=q(Y);if(!ae||k.identical.has(Y)||!s(ae))continue;let oe=x+1;for(;oe<t.length&&t[oe].kind==="text"&&!t[oe].value.trim();)oe++;if(oe>=t.length||!s(t[oe]))continue;let Ee=q(t[oe]);if(!Ee||k.identical.has(t[oe])||!s(Ee))continue;let De=H.get(ae),Ne=H.get(Ee);De<Ne&&xe(x,oe,De,Ne)}let qe=Array.from(ie.values()),fe=new Set;if(qe.length>1){let x=$t(u);try{v(x,qe.length*4);let Y=qe.slice().sort((Ee,De)=>(v(x,1),Ee[0]-De[0]||Ee[2]-De[2])),ae=[],oe=null;for(let Ee of Y)v(x,1),oe&&Ee[0]<=oe[1]&&Ee[2]<=oe[3]&&Ee[3]>=oe[2]?(oe[1]=Math.max(oe[1],Ee[1]),oe[2]=Math.min(oe[2],Ee[2]),oe[3]=Math.max(oe[3],Ee[3]),oe[4].push(Ee)):(oe?.[4].length>1&&ae.push(oe),oe=[Ee[0],Ee[1],Ee[2],Ee[3],[Ee]]);oe?.[4].length>1&&ae.push(oe),qe=ae.concat(qe)}catch(Y){if(Y!==I)throw Y}}for(let x of qe){if(fe.has(x))continue;let[Y,ae,oe,Ee,De]=x,Ne=$t(u),nt=[],Xe=new Set,ht=!1;try{v(Ne,(ae-Y+Ee-oe+2)*4);let Ge=t.slice(Y,ae+1).filter(U=>!k.identical.has(U)&&s(U)&&!f.has(U)),rt=y.units.slice(oe,Ee+1).filter(U=>s(U)&&(!y.baseOf(U)||w.has(y.baseOf(U)))&&!k.identical.has(y.baseOf(U))&&!f.has(y.baseOf(U))),Ot=new Set(rt),Ct=!1,wt="",Nt="",Lt=0;for(let U of Ge){let de=T(U,null,Ne);wt+=de.flat.text,Lt+=de.flat.text.length}for(let U of rt){let de=T(U,k,Ne);Nt+=de.flat.text,Lt+=de.flat.text.length}v(Ne,Lt);let qt=R(wt),cn=R(Nt),It=qt===cn;if(ht=It,De&&!It)continue;let Gt=It?null:new Map;if(Gt)for(let U of Ge.concat(rt)){let de=p.get(U).flat.text.length;v(Ne,de*16),Gt.set(U,new Uint8Array(de))}let wn=U=>{let de=[];for(let we of U){let le=p.get(we);le.flat.atoms.length?de.push(...A(le,Ne)):de.push({unit:we,raw:le.flat.text,from:0})}return de},Dt=[];for(let U of It?[]:Ge){let de=q(U);if(!Ot.has(de))continue;let we=T(U,null,Ne),le=T(de,k,Ne);v(Ne,we.flat.text.length+le.flat.text.length);let Ae=we.flat.text&&le.flat.text.startsWith(we.flat.text)?0:we.flat.text&&le.flat.text.endsWith(we.flat.text)?le.flat.text.length-we.flat.text.length:-1;if(Ae>=0&&E(we,le,Ae,we.flat.text.length,Ne)){Gt.get(U).fill(1),Gt.get(de).fill(1,Ae,Ae+we.flat.text.length),M(Dt,U,de,0,we.flat.text.length,Ae,Ne);continue}let W=N(A(we,Ne),A(le,Ne),Ne);if(!W){Ct=!0;break}for(let[X,pe]of W)Gt.get(U).fill(1,X.from,X.to),Gt.get(de).fill(1,pe.from,pe.to),M(Dt,U,de,X.from,X.to,pe.from,Ne)}if(Ct)continue;let rn=null,Yt=null;if(!It)for(let U of Ge){let de=q(U),we=p.get(U);if(!de||we.flat.atoms.length||!Ot.has(de))continue;let le=we.flat.text,Ae=Gt.get(U);v(Ne,le.length*3+rt.length);let W=-1,X=-1,pe=!1;for(let Pe=0;Pe<le.length;Pe++)gn.test(le[Pe])||(Ae[Pe]?pe=!0:(W<0&&(W=Pe),X=Pe+1));if(!pe||W<0)continue;let be=!0;for(let Pe=W;Pe<X;Pe++)if(Ae[Pe]&&!gn.test(le[Pe])){be=!1;break}if(!be)continue;let he=R(le.slice(W,X)),ee=null,te=!1;for(let Pe of rt){if(y.baseOf(Pe))continue;let ve=p.get(Pe);if(!ve.flat.atoms.length&&(v(Ne,ve.flat.text.length),R(ve.flat.text)===he)){if(ee){te=!0;break}ee=Pe}}if(te){(Yt||=new Set).add(U);continue}if(!ee||Yt?.has(U))continue;let z=!1;for(let Pe of Ge){if(Pe===U||!Ot.has(q(Pe)))continue;let ve=p.get(Pe);if(ve.flat.atoms.length)continue;let _e=Gt.get(Pe);v(Ne,ve.flat.text.length*3);let Je="",Ze=!1;for(let Ut=0;Ut<ve.flat.text.length;Ut++)gn.test(ve.flat.text[Ut])||(_e[Ut]?Ze=!0:Je+=ve.flat.text[Ut]);Ze&&Je===he&&(Yt||=new Set,Yt.add(U),Yt.add(Pe),z=!0)}if(z)continue;let ne=p.get(ee).flat.text;v(Ne,X-W+ne.length);let Te=W,Ce=0;for(;Te<X&&Ce<ne.length;){for(;Te<X&&gn.test(le[Te]);)Te++;for(;Ce<ne.length&&gn.test(ne[Ce]);)Ce++;if(Te>=X||Ce>=ne.length)break;M(rn||=[],U,ee,Te,Te+1,Ce,Ne),Te++,Ce++}Ae.fill(1,W,X),Gt.get(ee).fill(1)}let fn=U=>{let de=[];for(let we of U){let le=T(we,w.has(we)?null:k,Ne),Ae=Gt.get(we);for(let W of A(le,Ne)){let X=W.from;for(;X<W.to;){for(;X<W.to&&Ae[X];)X++;let pe=X;for(;X<W.to&&!Ae[X];)X++;if(X>pe){let be=le.flat.text.slice(pe,X);Hn.test(be)&&de.push({...W,raw:be,len:X-pe,k:W.atom?W.k:be,from:pe,to:X})}}}}return de},$=It?wn(Ge):fn(Ge),a=It?wn(rt):fn(rt),O=It?qt:$.map(U=>R(U.raw)).join(""),P=It?cn:a.map(U=>R(U.raw)).join("");if((!O||!P)&&!rn)continue;let K=rn||[];if(O&&P&&O===P){let U=0,de=0,we=0,le=0;for(;U<$.length&&de<a.length;){let Ae=$[U],W=a[de];for(;we<Ae.raw.length&&gn.test(Ae.raw[we]);)we++;for(;le<W.raw.length&&gn.test(W.raw[le]);)le++;if(we===Ae.raw.length){U++,we=0;continue}if(le===W.raw.length){de++,le=0;continue}if((Ae.atom||W.atom)&&Ae.k!==W.k){Ct=!0;break}M(K,Ae.unit,W.unit,Ae.from+we,Ae.from+we+1,W.from+le,Ne),we++,le++}}else if(O&&P){let U=N($,a,Ne);if(!U)continue;for(let[de,we]of U)M(K,de.unit,we.unit,de.from,de.to,we.from,Ne)}if(Ct)continue;let Z=new Map;for(let U of K)if(!Yt?.has(U.source)){if(q(U.source)===U.target){It&&Dt.push(U);continue}Z.has(U.source)||Z.set(U.source,[]),Z.get(U.source).push(U)}for(let[U,de]of Z){let we=T(U,null,Ne),le=q(U),Ae=we.flat.text,W=[],X=new Set,pe=n[1-j],be=pe.V.twin(U),he=be&&pe.V.here(be)?T(be,pe.A,Ne):null,ee=(ve,_e)=>{let Je=A(ve,Ne),Ze=A(_e,Ne);return v(Ne,ve.flat.text.length+_e.flat.text.length+Je.length+Ze.length),ve.flat.text===_e.flat.text&&Je.length===Ze.length&&Je.every((Ut,Pt)=>Ut.k===Ze[Pt].k)},te=le&&he&&he.flat.text!==Ae&&ee(T(le,k,Ne),he);for(let ve of new Set(de.map(_e=>_e.target))){if(U.nodeType!==1&&ve.nodeType!==1)continue;let _e=T(ve,k,Ne),Je=y.baseOf(ve);if(U.nodeType!==1&&Je||(v(Ne,Ae.length*2+_e.flat.text.length*3+Dt.length*2),le&&R(Ae)===R(_e.flat.text)&&T(le,k,Ne).flat.text.trim()))continue;if(!le&&!Je&&U.nodeType===1&&ve.nodeType===1){let G=r(U),re=J(ve);if(G&&re&&G!==re)continue}let Ze=_e.flat.text,Ut=Ae&&(Ze.startsWith(Ae)||Ze.endsWith(Ae)),Pt=!1;if(!le&&he&&Je&&he.flat.text!==Ae){let G=T(Je,null,Ne).flat.text,re=c.get(U)<c.get(Je)?he.flat.text:G,ge=c.get(U)<c.get(Je)?G:he.flat.text;v(Ne,re.length+ge.length+Ze.length),Pt=!!re&&!!ge&&re.length+ge.length<=Ze.length&&Ze.startsWith(re)&&Ze.endsWith(ge)&&!Ze.slice(re.length,Ze.length-ge.length).trim()}let L=!we.flat.atoms.length&&!he?.flat.atoms.length&&!_e.flat.atoms.length&&(te&&Ut||Pt);if(le&&Je){let G=T(le,k,Ne).flat.text,re=Ae.startsWith(G)||Ae.endsWith(G),ge=T(Je,null,Ne).flat.text,ye=_e.flat.text,ce=ye.startsWith(ge)||ye.endsWith(ge),se=!n[1-j].V.twin(Je)&&!Dt.some(Ie=>Ie.source===Je&&Hn.test(ge.slice(Ie.from,Ie.to)));if(!It&&(!re&&!L||!ce&&!se)){let Ie=bl(U,ve,de,Ge,rt,p,Gt,A,v,Ne);if(!Ie)continue;let Be=k.weak?.has(U)&&!k.identityPaired?.has(U)&&Ae.trim()===Ie;if(!re&&!L&&!Be)continue;let He=k.weak?.has(Je)&&!k.identityPaired?.has(Je)&&Ze.trim()===Ie&&!p.get(Je).flat.atoms.length&&!Dt.some(Ke=>Ke.source===Je&&Hn.test(ge.slice(Ke.from,Ke.to)));if(!ce&&!se&&!He&&!wl(Je,ve,ge,Ze,Dt,A(_e,Ne),v,Ne))continue;Be&&X.add(ve)}}L&&X.add(ve),v(Ne,de.length),W.push(...de.filter(G=>G.target===ve))}if(!W.length)continue;let z=new Uint8Array(Ae.length);v(Ne,Ae.length*4+Dt.length);for(let ve of W)z.fill(1,ve.from,ve.to);let ne=[];for(let ve=0;ve<Ae.length;ve++)gn.test(Ae[ve])||ne.push(ve);if(!ne.length)continue;let Te=new Set(W.map(ve=>ve.target));if(!It&&le&&Te.size>1&&ml(Te,K,Dt,y,p,Ne,v)){if(m||=new Map,m.set(U,(m.get(U)||0)|1<<j),e){let ve=ys({source:U,side:j,views:n,eligible:s,blocked:f,baseId:r,model:T,tokensOf:A,budget:Ne,charge:v});if(ve){v(Ne,ve.to-ve.from);let _e=!0;for(let Je=ve.from;Je<ve.to;Je++)if(Hn.test(Ae[Je])&&!z[Je]){_e=!1;break}_e&&(S||=[]).push(ve)}}continue}let Ce=ne.filter(ve=>Cs.test(Ae[ve]));if(!W.some(ve=>Cs.test(Ae.slice(ve.from,ve.to)))&&!ne.every(ve=>z[ve]))continue;if(!le&&!Array.from(Te).some(ve=>X.has(ve))&&!ne.every(ve=>z[ve])&&!(Ce.length&&z[Ce[0]]&&z[Ce[Ce.length-1]]&&Te.size===1)){let ve=null,_e=0,Je=0,Ze=null,Ut=null;if(!le&&he&&U.nodeType===1&&!we.flat.atoms.length){let Pt=A(we,Ne).filter(L=>Cs.test(L.raw));v(Ne,rt.length+Ae.length);for(let L of rt){let G=y.baseOf(L);if(!G||G===U||G.nodeType!==1||L.nodeType!==1||G.tagName!==U.tagName||L.tagName!==G.tagName)continue;let re=c.get(U),ge=c.get(G),ye=!0;for(let tt=Math.min(re,ge)+1;tt<Math.max(re,ge);tt++){let Kt=t[tt];if(v(Ne,Kt.nodeType===1?1:Kt.value.length+1),Kt.nodeType===1||Kt.value.trim()){ye=!1;break}}if(!ye)continue;let ce=T(G,null,Ne),se=T(L,k,Ne);if(ce.flat.atoms.length||se.flat.atoms.length)continue;let Ie=ce.flat.text,Be=se.flat.text;if(v(Ne,Ie.length+Be.length+Ae.length),!Ie||!Pt.length)continue;let He=0,Ke=Be.length;if(re<ge&&Be.endsWith(Ie))Ke-=Ie.length;else if(re>ge&&Be.startsWith(Ie))He=Ie.length;else continue;for(;He<Ke&&gn.test(Be[He]);)He++;for(;Ke>He&&gn.test(Be[Ke-1]);)Ke--;let pt=Be.slice(He,Ke);if(!(!pt||!(pt.startsWith(Pt[0].raw)||pt.endsWith(Pt[Pt.length-1].raw)))){if(ve){ve=null;break}ve=L,_e=He,Je=Ke,Ze=Pt[0],Ut=Pt[Pt.length-1]}}}if(v(Ne,W.length),!ve||!Te.has(ve)||!W.some(Pt=>Pt.target===ve&&(Pt.from<=Ze.from&&Pt.to>=Ze.to&&Pt.targetFrom+Ze.from-Pt.from===_e||Pt.from<=Ut.from&&Pt.to>=Ut.to&&Pt.targetFrom+Ut.to-Pt.from===Je)))continue}if(le&&!(ne.every(ve=>z[ve])&&(It||Array.from(Te).some(ve=>X.has(ve))))&&!Dt.some(ve=>ve.source===U&&Hn.test(Ae.slice(ve.from,ve.to))))continue;let Pe=!1;if(It){v(Ne,Dt.length+ne.length);for(let ve of Dt)ve.source===U&&(v(Ne,ve.to-ve.from),z.fill(1,ve.from,ve.to));Pe=!0;for(let ve of ne)if(!z[ve]){Pe=!1;break}}for(let ve of Te){v(Ne,W.length);let _e=W.filter(Ze=>Ze.target===ve);nt.push({side:j,source:U,target:ve,runs:_e,models:p,retained:Dt,conservedSource:Pe}),U.nodeType===1&&Xe.add(U),ve.nodeType===1&&Xe.add(ve);let Je=y.baseOf(ve);Je?.nodeType===1&&Xe.add(Je)}}if(b.push(...nt),De&&nt.length)for(let U of De)fe.add(U);for(let U of Xe)g.add(U)}catch(Ge){if(Ge!==I)throw Ge}finally{if(o&&!De&&!ht){let Ge=Pr({base:t,views:n,side:j,attempt:x,eligible:s,blocked:f,baseId:r,model:T,tokensOf:A,charge:v,exhausted:I,limit:u});Ge&&(C||=[]).push(...Ge)}if(e&&!De&&!ht){let Ge=Gs({base:t,views:n,side:j,attempt:x,eligible:s,blocked:f,baseId:r,model:T,tokensOf:A,certificates:b,charge:v,exhausted:I,limit:u});Ge&&(S||=[]).push(...Ge)}}}}let V=b.length?new Map:null;for(let j of b){let y=V.get(j.source);y||V.set(j.source,y=[]),y.push(j)}let D=null;if(V){let j=null;for(let[y,k]of V){let J=m?.get(y)||0;if(k.length<2&&!J)continue;let H=0;for(let q of k)q.conservedSource&&(H|=1<<q.side);for(let q of k){if(q.conservedSource)continue;let Me=1<<q.side,Oe=!0;if(H&Me)Oe=!1;else if(J&Me){Oe=!1;try{Oe=gl(q,j||=$t(u),v)}catch(Re){if(Re!==I)throw Re}}Oe||(D||=new Set).add(q)}}}if(D){let j=0;for(let y of b)D.has(y)||(b[j++]=y);b.length=j;for(let[y,k]of V){j=0;for(let J of k)D.has(J)||(k[j++]=J);k.length=j,j||V.delete(y)}g.clear();for(let y of b){let{source:k,target:J,side:H}=y;k.nodeType===1&&g.add(k),J.nodeType===1&&g.add(J);let q=n[H].V.baseOf(J);q?.nodeType===1&&g.add(q)}}if(S){let j=$t(u),y=!1;for(let k of S){let J=!1,H=V?.get(k.source);if(H&&!y)try{J=ws(k,H,j,v)}catch(q){if(q!==I)throw q;y=!0}J||e(k)}}if(C){let j=new Set,y=$t(u);try{for(let k of C){if(v(y,1),j.has(k.source))continue;j.add(k.source);let J=!1;for(let H of b)if(v(y,1),H.source===k.source||H.target===k.local||H.target===k.remote){J=!0;break}J||o(k)}}catch(k){if(k!==I)throw k}}for(let j of t)if(g.has(j))for(let{V:y}of n){let k=y.twin(j);k&&y.here(k)&&g.add(k)}return b.length?{blocks:g,certificates:b,certificatesBySource:V,models:p}:null}function Dr({certificates:e,scopes:o,flats:t,keys:n,limit:s=2e4*32}){let h=Symbol(),l=$t(s),r=m=>{if(m>l.remaining)throw h;l.remaining-=m},i=o.map(m=>new Set(m)),u=new Map,w=new Map,c=(m,f)=>{let g=u.get(m);if(g||u.set(m,g=new Map),g.has(f))return g.get(f);r(m.text.length);let I=w.get(f);if(!I){r(f.nodes.length+f.atoms.length),I={nodes:new Map,atoms:new Map};for(let E of f.nodes)I.nodes.set(E.node,E);for(let E of f.atoms)I.atoms.set(E.el,E.i);w.set(f,I)}let{nodes:v,atoms:T}=I,A=new Int32Array(m.text.length).fill(-1);for(let E of m.nodes){let N=v.get(E.node);if(!(!N||E.e-E.s!==N.e-N.s)){r(E.e-E.s);for(let M=E.s;M<E.e;M++)A[M]=N.s+M-E.s}}for(let E of m.atoms){let N=T.get(E.el);N!==void 0&&(A[E.i]=N)}return g.set(f,A),A},p=(m,f,g,I,v)=>{let T=m[m.length-1];T&&T.to===f&&T.target+T.to-T.from===I&&T.kind===v?T.to=g:m.push({from:f,to:g,target:I,kind:v})},b=(m,f,g,I)=>{r((I-g)*4);let v=[],T=g,A=M=>{let R=m.text.slice(T,M);for(let V of an(R,xn(R)))V.from=T,V.to=T+V.len,v.push(V),T+=V.len},E=0,N=m.atoms.length;for(;E<N;){r(1);let M=E+N>>>1;m.atoms[M].i<g?E=M+1:N=M}for(let M=E;M<m.atoms.length&&m.atoms[M].i<I;M++){r(1);let R=m.atoms[M];A(R.i),v.push({k:f(R),raw:Un,len:1,from:T,to:T+1}),T++}return A(I),v},S=(m,f,g,I,v,T)=>{if(g===I||v===T)return;if(I-g===T-v){r((I-g)*4);let y=!0;for(let k=g,J=v;k<I;k++,J++){if(t[0].text[k]!==t[f].text[J]){y=!1;break}let H=t[0].atomAt.get(k),q=t[f].atomAt.get(J);if(!!H!=!!q||H&&n[0](H)!==n[f](q)){y=!1;break}}if(y){p(m,g,I,v,"retained");return}}let A=b(t[0],n[0],g,I),E=b(t[f],n[f],v,T),N=A.length+E.length+4,M=Math.min(A.length+E.length,4e3,Math.floor((Math.sqrt(N*N+l.remaining/2)-N)/2));if(M<1)throw h;r(4*(M+1)*(N+M+1));let R=Wn(A,E,M),V=0,D=0,j=()=>{let y=A[V++],k=E[D++];r(y.len),y.raw===k.raw&&p(m,y.from,y.to,k.from,"retained")};for(let y of R.hunks){for(;V<y.bs;)j();V=y.be,D+=y.toks.length}for(;V<A.length&&D<E.length;)j()},C=m=>{let f=e.filter(R=>R.side===m-1&&i[0].has(R.source)&&i[m].has(R.target));if(!f.length)return null;let g=[],I=(R,V,D)=>{if(!i[0].has(R.source)||!i[m].has(R.target))return;let j=c(V.get(R.source).flat,t[0]),y=c(V.get(R.target).flat,t[m]);r(R.to-R.from);for(let k=0;k<R.to-R.from;k++){let J=j[R.from+k],H=y[R.targetFrom+k];if(J<0||H<0)throw h;p(g,J,J+1,H,D)}},v=new Set;for(let R of f){if(!v.has(R.retained)){v.add(R.retained);for(let V of R.retained)I(V,R.models,"retained")}for(let V of R.runs)I(V,R.models,"transfer")}g.sort((R,V)=>(r(1),R.from-V.from||R.target-V.target));let T=[];for(let R of g){r(1);let V=T[T.length-1];if(V&&R.from<V.to){if(R.target-R.from!==V.target-V.from)throw h;V.to=Math.max(V.to,R.to),R.kind==="transfer"&&(V.kind="transfer")}else T.push(R)}let A=[],E=0,N=0;for(let R of T){if(R.target<N)throw h;S(A,m,E,R.from,N,R.target),A.push(R),E=R.to,N=R.target+R.to-R.from}S(A,m,E,t[0].text.length,N,t[m].text.length);let M=Dn({base:t[0],side:t[m],retained:A.filter(R=>R.kind==="retained"),transfers:A.filter(R=>R.kind==="transfer"),baseAtomKey:n[0],sideAtomKey:n[m],budget:l});if(M.status!=="ready"||!M.monotone)throw h;return M};try{let m=C(1),f=C(2);return m||f?{local:m,remote:f}:{fallback:!0}}catch(m){if(m!==h)throw m;return{fallback:!0}}}function Ls(e,o,t=!1){let n=-1,s=-1;for(let l=0;l<e.list.length;l++){let r=e.list[l];r.bLo<o.lo||r.bLo>o.hi||(n<0&&(n=l),s=l)}let h=[];for(let l=n;l>=0&&l<=s;l++){let r=e.list[l],i=!t&&l===n?r.inlineStart<0?r.to:r.inlineStart:r.from,u=!t&&l===s?r.inlineEnd<0?r.from:r.inlineEnd:r.to;for(let w=i;w<u;w++)h.push(e.units[w]);l<s&&h.push(e.units[r.next])}return h}var it=e=>!!e&&e.nodeType===1,Ln=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function Es(e){for(let o of e)if(Ln.has(o.tagName))return!0;return!1}function yl(e,o,t){let n=null;for(let s of o.childNodes)if(!(!it(s)||!t(s)||!s.isEqualNode(e))){if(n)return null;n=s}if(!n)return null;for(let s of e.parentNode.childNodes)if(s!==e&&s.isEqualNode(e))return null;return n}var Co="[id],[data-id],script,head>*";function Rs(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=ho(t,e);if(n)return"merge:"+n.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?yr(t,o):null}}function Qo(e,o,t,n){let s=n.ignored,h=n.stats||$n(),l=Ks({ignored:s,ignoreAttribute:n.ignoreAttribute,stats:h}),{unitsOf:r,meta:i}=l,u=n.baseURI,w=n.mergeTags!==null,c=Rs(n.mergeTags,u),p=L=>G=>{let re=c(G);return re!==null?re:L(G)},b=p(n.identity.base),S=p(n.identity.local),C=p(n.identity.remote),m=n.authored||n.identity,f=L=>L&&L.nodeType===9?L.documentElement:L,g=f(e),I=f(o),v=f(t),T=globalThis.__hyperMorphProfile,A=T?performance.now():0,E=L=>L===kn?Co:null,N=n.scope||null,M=N?N.baseDropped:new Set,R=new Set,V=N?N.remoteDropped:new Set,D=N?N.baseIndex:Uo(g,b,s,E(n.identity.base),M),j=n.localIsBase||g===I?null:Uo(I,S,s,E(n.identity.local),R),y=N?N.remoteIndex:Uo(v,C,s,E(n.identity.remote),V),k=L=>{let G=it(L)&&S(L);return G&&j?.get(G)===L&&!D.has(G)?G:null},J=L=>{let G=it(L)&&C(L);return G&&y.get(G)===L&&!D.has(G)?G:null},H=j?cs(g,I,{analyzer:l,baseIndex:D,sideIndex:j,baseId:m.base,sideId:m.local,baseKey:b,sideKey:S,baseDropped:M,sideDropped:R,stats:h}):Vr(),q=cs(g,v,{analyzer:l,baseIndex:D,sideIndex:y,baseId:m.base,sideId:m.remote,baseKey:b,sideKey:C,baseDropped:M,sideDropped:V,stats:h,scope:N,comparisons:n.comparisons});if(N){if(!N.held(q))return null;for(let L of N.dropped)ls(L)}let Me=null;function Oe(L){if(!Me){Me=new WeakMap;let G=[g];for(;G.length;){let re=G.pop();re.tagName==="TEMPLATE"&&re.content&&Me.set(re.content,re);for(let ge of l.childrenOf(re))ge.nodeType===1&&G.push(ge)}}return Me.get(L)||null}let Re=L=>{let G=it(L)||L.nodeType?L.parentNode:L.parent;return G&&G.nodeType===11?Oe(G):G};if(q.moved.size){let L=!1;for(let G of Array.from(q.moved))!it(G)||q.identityPaired.has(G)||!m.base(G)||a(q,Re(G))||(q.unpair(G),L=!0);L&&q.rematch()}fn(),$(H,q),$(q,H);for(let L of[H,q])if(L.refused)for(let G of L.refused)L.moved.has(G)||h.ambiguousMoves++;T&&(T.alignTotal=(T.alignTotal||0)+(performance.now()-A),A=performance.now());let ie=g.ownerDocument.implementation.createHTMLDocument(""),xe=new WeakMap,qe=new WeakMap,fe=[],x=[],Y=new Set,ae=[],oe=new Set,Ee=new Set,De=new Set,Ne=new WeakMap,nt=null,Xe=n.lineage?.locals.length?lr():null,ht=L=>{let G=Ko(L);return G&&Xe&&Xe.consume(L.local),G},Ge=n.conflicts||"remote",rt=L=>fe.push(L),Ot=L=>fe.push(L),Ct=Or({roots:{base:g,local:I,remote:v},L:H,R:q,unitsOf:r,provenance:xe,policy:Ge}),wt=(L,G)=>{x.push(L),G&&Ct.note(L,G)},Nt=null,Lt=null,qt=rn(),cn=null,It=U(g,H.map.get(g),q.map.get(g),!!n.localIsBase,!!n.childrenOnly);It.tagName==="HTML"?ie.replaceChild(It,ie.documentElement):ie.body.appendChild(It),Nt?.drain(It),Lt?.drain(It),T&&(T.build=(T.build||0)+(performance.now()-A));let Gt=n.childrenOnly?!Pe(Te(It),Te(v)):!te(It,v),wn=Ct.finish(It),Dt=Xe?ar({locals:n.lineage.locals,rec:Xe,root:It,provenance:xe,segments:ae,ignored:s}):null;return{doc:ie,root:It,provenance:xe,textMappers:qe,decisions:fe,conflicts:x,recoveryLinks:wn,localDiverged:Gt,mergedScripts:Y,segments:ae,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==kn,L:H,R:q,stats:h,lineage:Dt};function rn(){let L=new Map,G=new Set;if(n.localIsBase||!H.insertedByHash)return{partner:L,drop:G};let re=H.insertedByHash(),ge=q.insertedByHash();if(!re.size||!ge.size)return{partner:L,drop:G};let ye={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ce=lt=>{let $e=0;for(let vt=lt.parentNode;vt;vt=vt.parentNode)$e++;return $e},se=[],Ie=lt=>{let $e=lt.textContent.trim();return $e.split(/\s+/).length>=3||$e.replace(/\s/g,"").length>=12},Be=lt=>{let $e=a(H,lt),vt=a(q,lt);return $e&&H.reverse.get($e.parentNode)!==lt.parentNode||vt&&q.reverse.get(vt.parentNode)!==lt.parentNode},He=(lt,$e,vt)=>{for(let jt of vt.parentNode.children){let bn=jt!==vt&&lt.reverse.get(jt);if(bn&&Be(bn))return!0}let ct=lt.reverse.get(vt.parentNode);if(ct){for(let jt of ct.children)if(!a($e,jt)&&!s(jt))return!0}return!1},Ke=new Map([[H,new Map],[q,new Map]]),pt=(lt,$e)=>{let vt=Ke.get(lt),ct=vt.get($e);if(ct===void 0){ct=!1;for(let jt of $e.children)if(lt.reverse.has(jt)||pt(lt,jt)){ct=!0;break}vt.set($e,ct)}return ct},tt=new Map;for(let lt of ge.values())for(let $e of lt){let vt=J($e);vt&&tt.set(vt,$e)}for(let lt of re.values())for(let $e of lt){let vt=k($e),ct=vt?tt.get(vt):null;ct&&ct.tagName===$e.tagName&&!Vn($e,ye)&&!Vn(ct,ye)&&!n.remoteWins($e)&&!n.remoteWins(ct)&&se.push([$e,[ct],ce($e),!0,!0])}for(let[lt,$e]of re){let vt=ge.get(lt);if(!vt)continue;let ct=$e.length===1&&vt.length===1;for(let jt of $e)!Vn(jt,ye)&&!k(jt)&&se.push([jt,vt,ce(jt),ct&&(Ie(jt)||He(H,q,jt)||He(q,H,vt[0]))])}if(!se.length)return{partner:L,drop:G};se.sort((lt,$e)=>lt[2]-$e[2]);let Kt=new Set,Ht=new Set,un=lt=>{for(let $e of lt.querySelectorAll("*"))Kt.add($e)},bt=(lt,$e)=>lt.reverse.get($e.parentNode)||null;for(let[lt,$e,,vt,ct]of se){if(Kt.has(lt)||Ht.has(lt)||ct&&(pt(H,lt)||pt(q,$e[0])))continue;let jt=bt(H,lt),bn=Xt=>!Ht.has(Xt)&&!Kt.has(Xt)&&(ct||Xt.tagName===lt.tagName&&!J(Xt)&&l.equalUnits(lt,Xt)),on=$e.find(Xt=>jt&&bt(q,Xt)===jt&&bn(Xt))||(vt?$e.find(bn):null);if(!on)continue;Ht.add(lt),Ht.add(on);let hn=jt&&bt(q,on)===jt;(!ct||!hn||l.equalUnits(lt,on))&&(un(lt),un(on)),!hn&&(L.set(lt,on),L.set(on,lt),G.add(Ge==="local"?on:lt))}return{partner:L,drop:G}}function Yt(L,G,re){if(oe.add(L),qt.drop.has(L))return null;oe.add(re);let ge=G==="local"?L:re,ye=G==="local"?re:L,ce;return l.equalUnits(ge,ye)?(ce=he(ge,"local",!0),xe.get(ce).remote=ye):ce=be(ge,ye),wt({kind:"structure",el:ce,detail:"both-moved",base:null,local:ge,remote:ye},{unit:{b:null,l:ge,r:ye}}),rt({kind:"insert",el:ce,source:"both"}),ce}function fn(){if(!H.weak||!q.weak||!H.weak.size||!q.weak.size||!H.unpair)return;let L=new Map;for(let re of H.weak){let ge=a(H,re);it(re)&&it(ge)&&L.set(l.unitHash(ge),re)}let G=!1;for(let re of Array.from(q.weak)){let ge=a(q,re);if(!it(re)||!it(ge))continue;let ye=L.get(l.unitHash(ge));if(!ye||ye===re||!H.weak.has(ye)||a(H,re)&&a(q,ye))continue;let ce=a(H,ye);ce.tagName===ge.tagName&&l.equalUnits(ce,ge)&&(H.unpair(ye),q.unpair(re),G=!0)}G&&(H.rematch(),q.rematch())}function $(L,G){if(!L.weak||!L.weak.size||!G.insertedByHash)return;let re=G.insertedByHash();if(!re.size)return;let ge=!1;for(let ye of Array.from(L.weak)){let ce=a(L,ye);if(!ce)continue;let se=L===H?k(ce):J(ce);if(se){let Be=(L===H?y:j)?.get(se);Be&&Be.tagName===ce.tagName&&!G.reverse.has(Be)&&(L.unpair(ye),ge=!0);continue}let Ie=re.get(l.unitHash(ce));Ie&&Ie.some(Be=>Be.tagName===ce.tagName&&l.equalUnits(Be,ce))&&(L.unpair(ye),ge=!0)}ge&&L.rematch()}function a(L,G){if(!G)return null;if(L.map.has(G))return L.map.get(G);let re=[],ge=Re(G);for(;ge&&!L.map.has(ge);ge=Re(ge))re.push(ge);let ye=ge;if(!ye||!L.identical.has(ye))return null;L.pairIdenticalChildren(ye);for(let se=re.length-1;se>=0;se--)L.pairIdenticalChildren(re[se]);let ce=L.map.get(G)||null;return ce&&h.lazyTwins++,ce}function O(L,G,re,ge){if(it(L)&&Ln.has(L.tagName)&&!H.identical.has(L)&&(L.previousSibling?.nodeType===3||L.nextSibling?.nodeType===3)){let Ie=Re(L),Be=a(H,L),He=a(q,L);Be&&He&&Ut(Be,a(H,Ie),H)&&!Ut(He,a(q,Ie),q)&&(Lt||=Lr({L:H,R:q,twinIn:a,unitsOf:r,view:P,parentOf:Re,ignored:s,remoteWins:n.remoteWins,eligible:Ke=>it(Ke)&&Ln.has(Ke.tagName),build:U,out:ie,policy:Ge,provenance:xe,textMappers:qe,segments:ae,conflicts:x,conflict:wt,decisions:fe}),Lt.ensureOwner(L))}if(G===null)return null;if(ge!==void 0)return Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(L,G,re,!!ge),ge&&(Nt.produced(L,ge),Ee.add(L)),ge;if(Ee.has(L)||De.has(L))return wt({kind:"structure",el:null,detail:"both-moved",base:L},{subject:L}),Ee.has(L)?null:he(re,G);Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(L,G,re,!0);let ye=a(H,L),ce=a(q,L);(!ye||!ce)&&wt({kind:"structure",el:null,detail:"move-beats-delete",base:L},{subject:L,deleted:ye?"remote":"local"});let se=U(L,ye,ce,!1);return(G==="local"?rt:Ot)({kind:"move",el:se,source:G}),se}function P(L,G,re,ge){return ge||!G||G===re?{el:re,asBase:!0,twin:ye=>ye,baseOf:ye=>ye,units:r(re),here:()=>!0,parentOfTwin:()=>re}:{el:G,asBase:!1,twin:ye=>a(L,ye),baseOf:ye=>L.reverse.get(ye),units:r(G),here:ye=>it(ye)?ye.parentNode===G||G.tagName==="TEMPLATE"&&ye.parentNode===G.content:ye.parent===G||G.tagName==="TEMPLATE"&&ye.parent===G.content}}function K(L,G,re){return!G||re&&re.identical.has(L)?!1:it(L)?!l.equalUnits(L,G)||!Z(L,G,re):L.value!==G.value}function Z(L,G,re){if(!re||L===G)return!0;let ge=[[L,G]];for(;ge.length;){let[ye,ce]=ge.pop(),se=r(ye),Ie=r(ce);for(let Be=0;Be<se.length&&Be<Ie.length;Be++){let He=se[Be],Ke=Ie[Be];if(!it(He)||!it(Ke))continue;let pt=re.map.get(He);if(pt!==void 0&&pt!==Ke)return!1;let tt=re.reverse.get(Ke);if(tt!==void 0&&tt!==He)return!1;ge.push([He,Ke])}}return!0}function U(L,G,re,ge,ye=!1){let ce=ge||(re?n.remoteWins(re):n.remoteWins(L)),se=L.namespaceURI&&L.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(L.namespaceURI,L.tagName):ie.createElement(L.tagName),Ie={base:L,local:G||null,remote:re||null};if(xe.set(se,Ie),ce&&!ge&&G&&K(L,G,H)&&(!re||!l.equalUnits(G,re))&&wt({kind:"structure",el:se,detail:"remote-wins",base:L,local:G,remote:re||null},{subject:L}),oe.add(L),Ee.add(L),G&&oe.add(G),re&&oe.add(re),n.skipUnchanged&&!ye&&(n.localIsBase||H.identical.has(L))&&re&&q.identical.has(L)&&!n.remoteWins(L)){Ie.unchanged=!0;for(let He of L.attributes)He.namespaceURI?se.setAttributeNS(He.namespaceURI,He.name,He.value):se.setAttribute(He.name,He.value);return Nt?.produced(L,se),se}De.add(L),ye||le(L,ce?L:G,re,se);let Be=L.tagName;if(pn(L))we(L,ce?L:G,re,se);else if(Be==="TEXTAREA")se.textContent=de(L.textContent,(ce?L:G)?(ce?L:G).textContent:L.textContent,re?re.textContent:L.textContent,se,"text");else if(!Lt?.render(L,se)){let He=ee(L,G,re,ce,se),Ke=Be==="TEMPLATE"&&se.content?se.content:se;for(let pt of He)Ke.appendChild(pt)}return De.delete(L),Nt?.produced(L,se),se}function de(L,G,re,ge,ye){if(G===re)return G;if(G===L)return re!==L&&Ot({kind:ye,node:ge,source:"remote"}),re;if(re===L)return rt({kind:ye,node:ge,source:"local"}),G;let ce=Ge==="local"?G:re;return wt({kind:ye,node:ge,base:L,local:G,remote:re,resolved:ce},{site:"whole",el:ge}),fe.push({kind:ye,node:ge,source:"both"}),ce}function we(L,G,re,ge){let ye=L.textContent,ce=G?G.textContent:ye,se=re?re.textContent:ye,Ie=w?ho(L,n.mergeTags,!0):null;if(Ie&&ce!==se){let Be=re&&re.getAttribute("merge-key")||L.getAttribute("merge-key"),{text:He,warnings:Ke,conflicts:pt}=Yo(n.localIsBase?void 0:ye,ce,se,{parse:Ie.recognizer.parse,keyCandidates:Be?Be.split(/[\s,]+/).filter(Boolean):void 0});for(let tt of Ke)console.warn(`[hyper-morph] merge "${Ie.raw}": ${tt}`);for(let tt of n.localIsBase?[]:pt)wt({kind:"json",node:ge,name:Ie.raw,path:tt.path,base:tt.base,local:tt.local,remote:tt.remote,resolved:tt.resolved});ge.textContent=He,Y.add(ge),He!==se?rt({kind:"text",node:ge,source:He===ce?"local":"both"}):He!==ye&&Ot({kind:"text",node:ge,source:"remote"});return}ge.textContent=de(ye,ce,se,ge,"text")}function le(L,G,re,ge){let ye=new Map;for(let ce of[L,G,re])if(ce)for(let se of ce.attributes)n.ignoreAttribute(ce,se.name)||ye.set(se.name,se);for(let[ce,se]of ye){let Ie=L?L.getAttribute(ce):null,Be=G?G.getAttribute(ce):Ie,He=re?re.getAttribute(ce):Ie,Ke;Be===He?Ke=Be:Be===Ie?(Ke=He,Ot({kind:"attr",el:ge,name:ce,source:"remote"})):He===Ie?(Ke=Be,rt({kind:"attr",el:ge,name:ce,source:"local"})):(Ke=Ae(ce,Ie,Be,He),Ke===void 0&&(Ke=Ge==="local"?Be:He,wt({kind:"attr",el:ge,name:ce,base:Ie,local:Be,remote:He,resolved:Ke},{el:ge,sample:se})),fe.push({kind:"attr",el:ge,name:ce,source:"both"})),Ke!=null&&(se.namespaceURI?ge.setAttributeNS(se.namespaceURI,se.name,Ke):ge.setAttribute(ce,Ke))}}function Ae(L,G,re,ge){if(L==="class"){let ye=He=>new Set((He||"").split(/\s+/).filter(Boolean)),ce=ye(G),se=ye(re),Ie=ye(ge),Be=new Set;for(let He of new Set([...ce,...se,...Ie])){let Ke=ce.has(He),pt=se.has(He),tt=Ie.has(He);(pt===tt?pt:pt===Ke?tt:pt)&&Be.add(He)}return[...Be].join(" ")}if(L==="style"){let ye=Ke=>{let pt=new Map;if(!Ke)return pt;let tt=0,Kt=null,Ht="",un=()=>{let bt=Ht.indexOf(":");bt>0&&pt.set(Ht.slice(0,bt).trim(),Ht.slice(bt+1).trim()),Ht=""};for(let bt of Ke){if(Kt){Ht+=bt,bt===Kt&&(Kt=null);continue}if(bt==='"'||bt==="'"){Kt=bt,Ht+=bt;continue}if(bt==="("?tt++:bt===")"&&tt--,bt===";"&&tt===0){un();continue}Ht+=bt}return Ht.trim()&&un(),pt},ce=ye(G),se=ye(re),Ie=ye(ge),Be=new Map,He=!1;for(let Ke of new Set([...ce.keys(),...se.keys(),...Ie.keys()])){let pt=ce.get(Ke)??null,tt=se.get(Ke)??null,Kt=Ie.get(Ke)??null,Ht;tt===Kt?Ht=tt:tt===pt?Ht=Kt:Kt===pt?Ht=tt:(Ht=Ge==="local"?tt:Kt,He=!0),Ht!=null&&Be.set(Ke,Ht)}return He?void 0:[...Be].map(([Ke,pt])=>`${Ke}: ${pt}`).join("; ")}}function W(L,G,re,ge){let ye=L.value,ce=ge?ye:G?G.value:"",se=re?re.value:"";oe.add(L),G&&oe.add(G),re&&oe.add(re);let Ie=lo(ye,ce,se,Ge),Be=Ie.text===""?null:ie.createTextNode(Ie.text);Be&&(xe.set(Be,{base:L.nodes,local:G?G.nodes:null,remote:re?re.nodes:null}),qe.set(Be,Ie.mapLocalOffset)),ce!==ye&&se!==ye?fe.push({kind:"text",node:Be,source:"both"}):ce!==ye?rt({kind:"text",node:Be,source:"local"}):se!==ye&&Ot({kind:"text",node:Be,source:"remote"});for(let He of Ie.conflicts)wt({kind:"text",node:Be,base:ye.slice(He.bs,He.be),local:He.local,remote:He.remote,resolved:He.resolved},{site:"run",bRun:L,lRun:G,rRun:re,node:Be,c:He});return Be}function X(L,G){return Yn(L,G).every(re=>re.bs===re.be)}function pe(L,G){let re=L?L.value:"",ge=G?G.value:"",ye;if(re===ge||!ge?ye=re:re?X(re,ge)?ye=ge:X(ge,re)?ye=re:(ye=Ge==="local"?re:Ge==="both"?re+ge:ge,wt({kind:"structure",el:null,detail:"insert-collision",local:re,remote:ge,resolved:ye},{unit:{b:null,l:L,r:G},localLost:Ge==="remote"})):ye=ge,L&&oe.add(L),G&&oe.add(G),ye==="")return null;let ce=ie.createTextNode(ye);return xe.set(ce,{base:null,local:L?L.nodes:null,remote:G?G.nodes:null}),re?rt({kind:"insert",el:ce,source:ge&&re===ge?"both":"local"}):Ot({kind:"insert",el:ce,source:"remote"}),ce}function be(L,G){let re={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ge=Ie=>r(Ie).every(Be=>it(Be)?Vn(Be,re):Be.kind==="text"),ye=null;if(ge(L)&&ge(G)){let Ie=L.textContent,Be=G.textContent;Ie===Be||X(Be,Ie)?ye=G:X(Ie,Be)&&(ye=L)}if(!ye){let Ie=Ge==="local",Be=he(Ie?L:G,Ie?"local":"remote",!0),He=xe.get(Be);return Ie?He.remote=G:He.local=L,wt({kind:"structure",el:Be,detail:"insert-collision",local:L,remote:G,resolved:Ie?L:G},{unit:{b:null,l:L,r:G},localLost:!Ie}),Be}let ce=L.namespaceURI&&L.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(L.namespaceURI,L.tagName):ie.createElement(L.tagName);le(null,L,G,ce),xe.set(ce,{base:null,local:L,remote:G}),oe.add(L),oe.add(G);let se=ht({base:Array.from(ye.childNodes),local:Array.from(L.childNodes),remote:Array.from(G.childNodes),out:ie,policy:Ge,idOf:{local:S,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:xe,textMappers:qe,conflicts:x,conflict:wt,scope:{base:null,local:L,remote:G,units:[],at:0},synthetic:!0,decisions:fe,node:ce});ae.push(...se.segments);for(let Ie of se.nodes)ce.appendChild(Ie);return ce}function he(L,G,re=!1){if(!re&&it(L)){let se=qt.partner.get(L);if(se)return Yt(L,G,se)}if(!it(L)){if(L.value==="")return null;let se=L.kind==="comment"?ie.createComment(L.value):ie.createTextNode(L.value);return xe.set(se,{base:null,local:G==="local"?L.nodes:null,remote:G==="remote"?L.nodes:null}),oe.add(L),se}let ge=L.namespaceURI&&L.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(L.namespaceURI,L.tagName):ie.createElement(L.tagName);for(let se of L.attributes)se.namespaceURI?ge.setAttributeNS(se.namespaceURI,se.name,se.value):ge.setAttribute(se.name,se.value);xe.set(ge,{base:null,local:G==="local"?L:null,remote:G==="remote"?L:null}),oe.add(L);let ye=L.tagName==="TEMPLATE"&&ge.content?ge.content:ge,ce=G==="local"?H:q;for(let se of r(L)){let Ie=it(se)?ce.reverse.get(se):null;if(Ie&&O(Ie,null,null),Ie&&Ee.has(Ie)){wt({kind:"structure",el:null,detail:"both-moved",base:Ie},{subject:Ie});continue}if(Ie&&!De.has(Ie)){let He=a(H,Ie)||null,Ke=a(q,Ie)||null;if(He||Ke){Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(Ie,G,se,!0);let pt=U(Ie,He,Ke,!1);G==="local"?rt({kind:"move",el:pt,source:"local"}):Ot({kind:"move",el:pt,source:"remote"}),ye.appendChild(pt);continue}}let Be=he(se,G);Be&&ye.appendChild(Be)}if(!re&&qt.drop.size&&L.tagName==="DIV"&&!ye.firstChild&&!L.attributes.length&&!(G==="local"?S(L):C(L))&&!ce.reverse.has(L)&&!s(L)&&!n.remoteWins(L)){let se=L.firstChild;if(se&&se===L.lastChild&&it(se)&&(qt.drop.has(se)||cn?.has(se)))return(cn||=new WeakSet).add(L),null}return ge}function ee(L,G,re,ge,ye){G&&H.identical.has(L)&&H.pairIdenticalChildren(L),re&&q.identical.has(L)&&q.pairIdenticalChildren(L);let ce=P(H,G,L,ge),se=P(q,re,L,!1),Ie=r(L),Be=new Set(Ie),He=new Map;for(let ue=0;ue<Ie.length;ue++)He.set(Ie[ue],ue);let Ke=[],pt=new Set,tt=new Map,Kt=new Set,Ht=Xe&&[],un=Xe&&[],bt=new Set,lt=[],$e=null,vt=new Map;if(!ce.asBase&&!se.asBase&&!H.identical.has(L)&&!q.identical.has(L))for(let ue of Ie){if(!it(ue)||!Ln.has(ue.tagName))continue;let We=ce.twin(ue),Ve=se.twin(ue);We&&Ve&&(!ce.here(We)||!se.here(Ve))&&O(ue,null,null)}vo();let ct=ue=>{let We=[];for(let Ve of ue.units){if(bt.has(Ve))continue;let et=ue.baseOf(Ve);et&&Be.has(et)&&We.push(et)}return We},jt=ue=>ct(ue).map(We=>He.get(We)),bn=ue=>ue.every((We,Ve)=>Ve===0||We>=ue[Ve-1]),on=!ce.asBase&&!bn(jt(ce)),hn=!se.asBase&&!bn(jt(se));on&&hn&&wt({kind:"structure",el:ye,detail:"both-reordered",base:L},{subject:L,lKept:ct(ce),rKept:ct(se)});let Xt=hn||!on?{V:se,A:q,side:"remote",other:ce,otherA:H,otherSide:"local"}:{V:ce,A:H,side:"local",other:se,otherA:q,otherSide:"remote"};on?rt({kind:"move",el:null,source:hn?"both":"local",base:L}):hn&&Ot({kind:"move",el:null,source:"remote",base:L});let En=ce.asBase?[]:ce.units.filter(ue=>!ce.baseOf(ue)&&!bt.has(ue)&&!qt.partner.has(ue)),oo=se.asBase?[]:se.units.filter(ue=>!se.baseOf(ue)&&!bt.has(ue)&&!qt.partner.has(ue)),Rn=new Map;if(En.length&&oo.length){let ue=new Map,We=new Map;for(let Fe of oo){if(it(Fe)){let xt=C(Fe);xt&&ue.set(xt,Fe)}let ze=l.unitHash(Fe);We.has(ze)||We.set(ze,[]),We.get(ze).push(Fe)}let Ve=(Fe,ze)=>{let xt=Fe.units.indexOf(ze);for(let Ye=xt-1;Ye>=0;Ye--){let st=Fe.baseOf(Fe.units[Ye]);if(st)return st}return"start"},et=new Map,yt=new Map;for(let Fe of oo){let ze=Ve(se,Fe);it(Fe)?(yt.has(ze)||yt.set(ze,[]),yt.get(ze).push(Fe)):Fe.kind==="text"&&!et.has(ze)&&et.set(ze,Fe)}for(let Fe of En){let ze=null;if(it(Fe)){let Ye=S(Fe);Ye&&ue.has(Ye)&&!Rn.has(ue.get(Ye))&&(ze=ue.get(Ye))}else if(Fe.kind==="text"){let Ye=et.get(Ve(ce,Fe));Ye&&!Rn.has(Ye)&&(ze=Ye)}let xt=!!k(Fe);if(!ze&&!xt){let Ye=We.get(l.unitHash(Fe));Ye&&(ze=Ye.find(st=>!Rn.has(st)&&it(st)===it(Fe)&&(it(st)?st.tagName===Fe.tagName&&!J(st):st.kind===Fe.kind)&&l.equalUnits(Fe,st))||null)}if(!ze&&it(Fe)&&!xt){let Ye=m.local(Fe),st=(yt.get(Ve(ce,Fe))||[]).filter(ft=>{let Wt=m.remote(ft);return!Rn.has(ft)&&ft.tagName===Fe.tagName&&!J(ft)&&!(Ye&&Wt&&Ye!==Wt)&&l.similar(Fe,ft)});st.length===1&&(ze=st[0])}ze&&(Rn.set(ze,Fe),Rn.set(Fe,ze))}}let xo=ue=>{if(Lt?.consumes(ue))return null;if(oe.has(ue)||Nt?.has(ue))return tt.get(ue)||null;let We=ce.twin(ue),Ve=se.twin(ue),et=We&&!ce.asBase&&!ce.here(We),yt=Ve&&!se.asBase&&!se.here(Ve);if(et||yt){if((!We||!Ve)&&wt({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:We?"remote":"local"}),!Ze(ue))return it(ue)?(Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),et&&Nt.plan(ue,"local",We),yt&&Nt.plan(ue,"remote",Ve)):oe.add(ue),null;wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue})}if(We&&!Ve&&!ce.asBase&&!se.asBase&&it(ue)&&Ln.has(ue.tagName)&&!n.remoteWins(ue)&&!n.remoteWins(We)&&K(ue,We,H)&&yl(ue,Te(se.el),s)){let st={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ft=Wt=>it(Wt)?Vn(Wt,st):Wt.kind==="text";if(r(ue).every(ft)&&r(We).every(ft)){let Wt=ht({base:[ue],local:[We],remote:[],blocks:new Set([ue,We]),out:ie,policy:Ge,L:H,R:q,idOf:{base:b,local:S,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Qt,vn,_n)=>U(Qt,vn,_n,!1),cloneUnit:he,mergeAttrs:le,atomKey:l.exactUnitKey,moveIn:O,moveBuilt:O,movePlanned:O,provenance:xe,textMappers:qe,conflicts:x,conflict:wt,scope:{base:L,local:ce.el,remote:se.el,units:Ie,at:He.get(ue)},decisions:fe,node:ye});ae.push(...Wt.segments),oe.add(ue),oe.add(We);let Mt=ie.createDocumentFragment();for(let Qt of Wt.nodes)Mt.appendChild(Qt);return tt.set(ue,Mt),tt.set(We,Mt),Mt}}if(!We&&!Ve)return oe.add(ue),Ot({kind:"remove",source:"both",base:ue}),null;if(!We&&!K(ue,Ve,q))return oe.add(ue),rt({kind:"remove",source:"local",base:ue}),null;if(!Ve&&!K(ue,We,H))return oe.add(ue),Ot({kind:"remove",source:"remote",base:ue}),Xe&&(Xe.remove(We),Ht.push({bk:ue,lk:We})),null;let Fe=!We||!Ve,ze=ce.asBase?a(H,ue)||null:We,xt=se.asBase&&it(ue)&&(q.identityPaired.has(ue)||!m.base(ue))&&a(q,ue)||Ve,Ye;return it(ue)?Ye=U(ue,ze,xt,ce.asBase):ue.kind==="comment"?Ye=_e(ue,ze,Ve,ce.asBase):Ye=W(ue,ze,Ve,ce.asBase),oe.add(ue),Ye&&(tt.set(ue,Ye),We&&tt.set(We,Ye),Ve&&tt.set(Ve,Ye),Fe&&(wt({kind:"structure",el:Ye,detail:"edit-beats-delete",base:ue},{subject:ue,deleted:We?"remote":"local"}),We?rt({kind:"insert",el:Ye,source:"local"}):Ot({kind:"insert",el:Ye,source:"remote"}))),Ye},Kn=(ue,We,Ve,et)=>{if(Lt?.consumes(ue))return null;if(oe.has(ue))return tt.get(ue)||null;let yt=We.baseOf(ue);if(yt&&Be.has(yt))return bt.has(yt)&&!bt.has(ue)?Ro(yt,ue,et):xo(yt);if(yt)return ts(yt,ue,et);let Fe=Rn.get(ue);if(Fe){let xt=et==="local"?ue:Fe,Ye=et==="local"?Fe:ue,st;return it(xt)?l.equalUnits(xt,Ye)?(st=he(xt,"local"),st&&(xe.get(st).remote=Ye)):st=be(xt,Ye):st=pe(xt,Ye),oe.add(xt),oe.add(Ye),st&&(tt.set(xt,st),tt.set(Ye,st),it(xt)&&rt({kind:"insert",el:st,source:"both"})),st}let ze=he(ue,et);return ze&&(tt.set(ue,ze),et==="local"?rt({kind:"insert",el:ze,source:"local"}):(Ot({kind:"insert",el:ze,source:"remote"}),Xe&&it(ue)&&!qt.partner.has(ue)&&un.push({su:ue,node:ze}))),ze},Ro=(ue,We,Ve)=>{let et;return it(ue)?(et=O(ue,Ve,We),et&&oe.add(We)):(et=he(We,Ve),oe.add(We),et&&(Ve==="local"?rt:Ot)({kind:"insert",el:et,source:Ve})),et&&tt.set(We,et),et},ts=(ue,We,Ve)=>{O(ue,null,null);let yt=a(Ve==="local"?q:H,ue),Fe=We,ze=yt?Ut(yt,Ve==="local"?re:G,Ve==="local"?q:H):!1,xt=yt&&!ze&&!Pt(ue,yt);if(xt&&Ve===Xt.otherSide)return wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),null;if(xt&&wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),yt||wt({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:Ve==="local"?"remote":"local"}),De.has(ue)){wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue});let st=he(Fe,Ve);return st&&tt.set(We,st),st}it(ue)&&(Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(ue,Ve,Fe,!0));let Ye=it(ue)?U(ue,Ve==="local"?Fe:a(H,ue)||null,Ve==="remote"?Fe:a(q,ue)||null,!1):null;return Ye&&(tt.set(ue,Ye),tt.set(We,Ye),yt&&tt.set(yt,Ye),Ve==="local"?rt({kind:"move",el:Ye,source:"local"}):Ot({kind:"move",el:Ye,source:"remote"})),Ye};for(let ue of Xt.V.units){if(bt.has(ue)){if($e?.has(ue)){for(let et of $e.get(ue))pt.has(et)||(Ke.push(et),pt.add(et));continue}let Ve=tt.get(ue);pt.has(Ve)||(Ke.push(Ve),pt.add(Ve));continue}if(oe.has(ue)&&!(tt.get(ue)&&pt.has(tt.get(ue)))){let Ve=Xt.V.baseOf(ue);Ve&&!Be.has(Ve)&&wt({kind:"structure",el:null,detail:"both-moved",base:Ve},{subject:Ve});continue}let We=Kn(ue,Xt.V,Xt.A,Xt.side);We&&!pt.has(We)&&(Ke.push(We),pt.add(We),!Xt.V.baseOf(ue)&&!Rn.has(ue)&&!bt.has(ue)&&Kt.add(We))}for(let ue of lt)pt.has(ue.frag)||(Ke.splice(ue.previous&&pt.has(ue.previous)?Ke.indexOf(ue.previous)+1:so(ue.at),0,ue.frag),pt.add(ue.frag));if(!Xt.other.asBase){let ue=Xt.other,We=Xt.otherSide,Ve=Xt.otherA,et=null,yt=0,Fe=null;for(let ze of ue.units){let xt=vt.get(ze)||tt.get(ze);if(xt&&pt.has(xt)){et=xt,Fe=null;continue}if(oe.has(ze)){let ft=ue.baseOf(ze);ft&&!Be.has(ft)&&wt({kind:"structure",el:null,detail:"both-moved",base:ft},{subject:ft});continue}let Ye=Kn(ze,ue,Ve,We);if(!Ye)continue;let st;if(Fe)st=Ke.indexOf(Fe)+1;else if(et){if(st=Ke.indexOf(et)+1,We==="remote")for(;st<Ke.length&&Kt.has(Ke[st]);)st++}else st=yt++;Ke.splice(st,0,Ye),pt.add(Ye),Fe=Ye}}for(let ue=0;ue<Ie.length;ue++){let We=Ie[ue];if(oe.has(We))continue;let Ve=xo(We);Ve&&Ke.splice(so(ue),0,Ve)}return Xe&&Ht.length&&un.length&&Po(),Ke;function Po(){if(on||hn)return;let ue=new Set(Ke),We=ft=>ft&&Be.has(ft)&&ue.has(tt.get(ft))?ft:null,Ve=(ft,Wt)=>{let Mt=[{prev:null,units:[]}];for(let Qt of ft){let vn=We(Wt(Qt));vn?Mt.push({prev:vn,units:[]}):Mt[Mt.length-1].units.push(Qt)}return Mt},et=Ve(Ie,ft=>ft),yt=Ve(se.units,se.baseOf),Fe=ce.asBase?null:Ve(ce.units,ce.baseOf),ze=ft=>ft.length===et.length&&ft.every((Wt,Mt)=>Wt.prev===et[Mt].prev);if(!ze(yt)||Fe&&!ze(Fe))return;let xt=new Map(Ht.map(ft=>[ft.bk,ft])),Ye=new Map(un.map(ft=>[ft.su,ft])),st=ft=>ft?Ke.indexOf(tt.get(ft)):-1;for(let ft=0;ft<et.length;ft++){if(et[ft].units.length!==1||yt[ft].units.length!==1)continue;let Wt=xt.get(et[ft].units[0]),Mt=Ye.get(yt[ft].units[0]);if(!Wt||!Mt||Fe&&(Fe[ft].units.length!==1||Fe[ft].units[0]!==Wt.lk))continue;let Qt=st(et[ft].prev);(ft+1<et.length?st(et[ft+1].prev):Ke.length)-Qt!==2||Ke[Qt+1]!==Mt.node||To(Wt.bk,Wt.lk,Mt.su)&&Xe.link(Wt.lk,Mt.node)}}function Fn(ue,We,Ve,et){let yt=Mt=>{let Qt=Mt.filter(it);return Qt.length===1?Qt[0]:null},Fe=yt(ue),ze=yt(We),xt=yt(Ve);if(!Fe||!ze||!xt)return;let Ye=ue.indexOf(Fe);if(We.indexOf(ze)!==Ye||Ve.indexOf(xt)!==Ye||ue.length!==We.length||ue.length!==Ve.length)return;for(let Mt=0;Mt<ue.length;Mt++)if(Mt!==Ye&&(ue[Mt].value!==We[Mt].value||ue[Mt].value!==Ve[Mt].value))return;if((ce.asBase?Fe:ce.twin(Fe))!==ze||se.twin(Fe)||q.reverse.get(xt)||ze!==Fe&&K(Fe,ze,H))return;let st=et.filter(Mt=>Mt.nodeType===1);if(st.length!==1||xe.get(st[0])?.remote!==xt)return;let ft=Mt=>Mt.map(Qt=>it(Qt)?"":Qt.value??Qt.nodeValue).join(""),Wt=et.indexOf(st[0]);ft(et.slice(0,Wt))!==ft(ue.slice(0,Ye))||ft(et.slice(Wt+1))!==ft(ue.slice(Ye+1))||To(Fe,ze,xt)&&Xe.link(ze,st[0])}function To(ue,We,Ve){if(!it(We)||!it(Ve)||!it(ue)||We.namespaceURI!==Ve.namespaceURI||We.localName===Ve.localName)return!1;for(let ze of[We,Ve])if(ze.tagName==="TEMPLATE"||pn(ze)||ze.querySelector("template"))return!1;if(n.remoteWins(ue)||n.remoteWins(Ve)||s(Ve)||We.attributes.length!==Ve.attributes.length)return!1;for(let ze of We.attributes)if(Ve.getAttributeNS(ze.namespaceURI,ze.localName)!==ze.value)return!1;let et=We.childNodes,yt=Ve.childNodes;if(et.length!==yt.length)return!1;for(let ze=0;ze<et.length;ze++)if(!et[ze].isEqualNode(yt[ze]))return!1;let Fe=[[ue,Ve]];for(;Fe.length;){let[ze,xt]=Fe.pop();if(ze.children.length!==xt.children.length)return!1;for(let Ye=0;Ye<xt.children.length;Ye++){let st=q.reverse.get(xt.children[Ye]);if(st!==void 0&&st!==ze.children[Ye])return!1;Fe.push([ze.children[Ye],xt.children[Ye]])}}return!0}function so(ue){for(let We=ue-1;We>=0;We--){let Ve=tt.get(Ie[We]);if(Ve){let et=Ke.indexOf(Ve);if(et>=0)return et+1}}return 0}function vo(){if((ce.asBase||H.identical.has(L))&&(se.asBase||q.identical.has(L)))return;let ue={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},We=ut=>it(ut)?Vn(ut,ue):ut.kind==="text";if(!ce.asBase&&!se.asBase)for(let ut of Ie){if(!it(ut)||!Ln.has(ut.tagName))continue;let Qe=ce.twin(ut),Et=se.twin(ut);if(!Qe&&Et||Qe&&!Et){let ot=Br({base:Ie,views:[{V:ce,A:H,idOf:m.local},{V:se,A:q,idOf:m.remote}],eligible:At=>it(At)&&Ln.has(At.tagName)&&!s(At)&&!n.remoteWins(At),baseId:m.base,ignored:s,remoteWins:n.remoteWins,atomKey:l.exactUnitKey});ot&&(ce=ot[0],se=ot[1]);break}}let Ve=!ce.asBase&&!se.asBase&&Ie.length>=2&&Ln.has(Ie[0].tagName)&&ce.units.length===Ie.length&&se.units.length===Ie.length?mr({base:Ie,local:ce.units,remote:se.units,localTwin:ce.twin,remoteTwin:se.twin,eligible:ut=>it(ut)&&Ln.has(ut.tagName)&&!s(ut)&&!n.remoteWins(ut),nodes:{base:Array.from(Te(L).childNodes),local:Array.from(Te(ce.el).childNodes),remote:Array.from(Te(se.el).childNodes)}}):null,et=null,yt=null;if(!Ve&&!ce.asBase&&!se.asBase&&(Es(Ie)||Es(ce.units)||Es(se.units))){let ut={ignored:s,remoteWins:()=>!1},Qe=ot=>We(ot)||it(ot)&&n.remoteWins(ot)&&Tn.has(ot.tagName)&&Vn(ot,ut),Et=ot=>it(ot)?Ln.has(ot.tagName)&&!s(ot)&&!n.remoteWins(ot)&&r(ot).every(Qe):ot.kind==="text";et=jr({onUncertainOwner:ot=>{let At=n.identity.local(ot.local);At&&At===n.identity.remote(ot.remote)||(yt||=[]).push(ot)},onUncertainSource:ot=>{nt||(nt=new Map);let At=nt.get(ot.source);At||nt.set(ot.source,At=[]);for(let Jt of At)if(Jt.side===ot.side&&Jt.from===ot.from&&Jt.to===ot.to)return;At.push(ot)},base:Ie,views:[{V:ce,A:H,idOf:m.local},{V:se,A:q,idOf:m.remote}],eligible:Et,ignored:s,remoteWins:n.remoteWins,baseId:m.base,atomKey:l.exactUnitKey})}if(yt){$e||=new Map;for(let ut of yt){let{source:Qe,local:Et,remote:ot}=ut,At={map:new Map,reverse:new Map,identical:new Set},Jt=ht({base:[Qe],local:[Et],remote:[ot],out:ie,policy:"both",L:At,R:At,ignored:s,remoteWins:n.remoteWins,atomKey:l.exactUnitKey,cloneUnit:he,provenance:xe,textMappers:qe,conflicts:x,decisions:fe,conflict:(Rt,Ft)=>wt(Rt,{...Ft,policy:"both"}),scope:{base:L,local:ce.el,remote:se.el,units:Ie,at:He.get(Qe)},node:ye});ae.push(...Jt.segments);for(let Rt of[Qe,Et,ot])oe.add(Rt),bt.add(Rt),$e.set(Rt,Jt.nodes),tt.set(Rt,Jt.nodes[Jt.nodes.length-1]);for(let Rt=0;Rt<Jt.nodes.length;Rt++)lt.push({frag:Jt.nodes[Rt],at:He.get(Qe),previous:Rt?Jt.nodes[Rt-1]:null})}}let Fe=Ve?Ve.blocks:null;if(et){Fe=new Set;for(let ut of et.blocks)Fe.add(ut)}let ze=ut=>!Lt?.consumes(ut)&&(Fe&&Fe.has(ut)||We(ut)),xt=Ie.map(ze);if(!xt.includes(!0))return;let Ye=ut=>{let Qe=ut.units,Et=new Map;for(let tn=0;tn<Qe.length;tn++)Et.set(Qe[tn],tn);let ot=[],At=-1;for(let tn=0;tn<Ie.length;tn++){if(xt[tn])continue;let Tt=ut.twin(Ie[tn]),mt=Tt?Et.get(Tt):void 0;mt===void 0||mt<=At||ze(Tt)||(ot.push([tn,mt]),At=mt)}let Jt=[],Rt=-1,Ft=-1;for(let tn=0;tn<=ot.length;tn++){let[Tt,mt]=tn<ot.length?ot[tn]:[Ie.length,Qe.length],St={bLo:-1,bHi:-1,from:Ft+1,to:mt,inlineStart:-1,inlineEnd:-1,next:mt};for(let Zt=Rt+1;Zt<Tt;Zt++)xt[Zt]&&(St.bLo<0&&(St.bLo=Zt),St.bHi=Zt);for(let Zt=Ft+1;Zt<mt;Zt++){let zn=Qe[Zt];ze(zn)&&(St.inlineStart<0&&(St.inlineStart=Zt),St.inlineEnd=Zt+1)}Jt.push(St),Rt=Tt,Ft=mt}return{units:Qe,list:Jt}},st=Ye(ce),ft=Ye(se),Wt=[];for(let ut of[st,ft])for(let Qe of ut.list)Qe.bLo>=0&&Wt.push([Qe.bLo,Qe.bHi]);Wt.sort((ut,Qe)=>ut[0]-Qe[0]);let Mt=[];for(let[ut,Qe]of Wt){let Et=Mt[Mt.length-1];Et&&ut<=Et.hi?Et.hi=Math.max(Et.hi,Qe):Mt.push({lo:ut,hi:Qe})}let Qt=(ut,Qe)=>ut.length===Qe.length&&ut.every((Et,ot)=>l.equalUnits(Et,Qe[ot])),vn=ut=>!it(ut)&&ut.kind==="comment",_n=ut=>{if(!ut.length)return[];let Qe=(Rt,Ft)=>it(Rt)?Rt:Rt.nodes[Ft?Rt.nodes.length-1:0],Et=Qe(ut[0]),ot=Qe(ut[ut.length-1],!0),At=Rt=>Rt&&it(Rt)&&s(Rt);for(;At(Et.previousSibling);)Et=Et.previousSibling;for(;At(ot.nextSibling);)ot=ot.nextSibling;let Jt=[];for(let Rt=Et;Rt&&(Jt.push(Rt),Rt!==ot);Rt=Rt.nextSibling);return Jt},Pn=ut=>ut.some(Qe=>it(Qe)&&s(Qe));for(let ut of Mt){let Qe=Ie.slice(ut.lo,ut.hi+1),Et=null;if(et)for(let Tt of Qe){let mt=et.certificatesBySource.get(Tt);mt&&(Et||=[]).push(...mt)}let ot=ce.asBase?null:Ls(st,ut),At=se.asBase?null:Ls(ft,ut);if(Et){let Tt=[new Set(ot||Qe),new Set(At||Qe)],mt=Et.some(St=>!Tt[St.side].has(St.target));for(let St of Qe)if(Fe.has(St))for(let[Zt,zn]of[[0,ce],[1,se]]){let Sn=zn.twin(St);Sn&&zn.here(Sn)&&!Tt[Zt].has(Sn)&&(mt=!0)}if(mt)continue}if(Qe.some(vn)||ot&&ot.some(vn)||At&&At.some(vn))continue;let Jt=_n(ot||Qe),Rt=_n(At||Qe);if((!ot||Qt(Qe,ot))&&(!At||Qt(Qe,At))&&!(ot&&Pn(Jt)))continue;let Ft=ht({base:_n(Qe),sourceRetentions:nt?.get(L),local:Jt,remote:Rt,out:ie,policy:Ge,blocks:Fe,scopeUnits:Et?[Qe,ot||Qe,At||Qe]:null,certifiedOrigins:Et?(Tt,mt,St,Zt,zn,Sn)=>Dr({certificates:Et,scopes:[Qe,ot||Qe,At||Qe],flats:[Tt,mt,St],keys:[Zt,zn,Sn]}):null,prepared:Ve?Ve.prepared:null,nativeTransfers:Ve,L:ot?H:Ur(H,L),R:At?q:Ur(q,L),idOf:{base:b,local:S,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Tt,mt,St)=>U(Tt,mt,St,!1),cloneUnit:he,mergeAttrs:le,atomKey:l.exactUnitKey,moveIn:O,moveBuilt:O,movePlanned:O,provenance:xe,textMappers:qe,conflicts:x,conflict:wt,scope:{base:L,local:ce.asBase?null:ce.el,remote:se.asBase?null:se.el,units:Ie,at:ut.lo},decisions:fe,node:ye});if(!Ft){if(Et){let Tt=gr({certificates:Et,scopes:[Qe,ot||Qe,At||Qe],views:[{V:ce,A:H,idOf:m.local},{V:se,A:q,idOf:m.remote}],eligible:mt=>it(mt)&&Ln.has(mt.tagName)&&!s(mt)&&!n.remoteWins(mt),baseId:m.base});for(let mt of Tt.records){nt||=new Map;let St=nt.get(mt.source);St||nt.set(mt.source,St=[]),St.push(mt)}}continue}if(ae.push(...Ft.segments),Ve){let Tt=new Map;for(let mt of Ft.nodes){let St=xe.get(mt)?.base;if(!St||Tt.has(St))throw new Error("Invalid native transfer owner output");Tt.set(St,mt)}if(Tt.size!==Ve.owners.length)throw new Error("Incomplete native transfer owner output");for(let mt of Ve.owners){let St=Tt.get(mt.base);if(!St)throw new Error("Missing native transfer owner output");for(let Zt of[mt.base,mt.local,mt.remote])oe.add(Zt),bt.add(Zt),tt.set(Zt,St);lt.push({frag:St,at:He.get(mt.base)})}continue}if(Xe&&Fn(Qe,ot||Qe,At||Qe,Ft.nodes),Ft.unitOutputs){$e||=new Map;for(let mt of[...Qe,...ot||[],...At||[]]){let St=Ft.unitOutputs.get(mt)||[];oe.add(mt),bt.add(mt),$e.set(mt,St),St.length&&tt.set(mt,St[St.length-1])}let Tt=Ft.nodes[Ft.nodes.length-1];if(Tt)for(let mt of[ot||Qe,At||Qe]){let St=mt[mt.length-1];St&&vt.set(St,Tt)}for(let mt=0;mt<Ft.nodes.length;mt++)lt.push({frag:Ft.nodes[mt],at:ut.lo,previous:mt>0?Ft.nodes[mt-1]:null});continue}Xe&&Fn(Qe,ot||Qe,At||Qe,Ft.nodes);let tn=ie.createDocumentFragment();for(let Tt of Ft.nodes)tn.appendChild(Tt);for(let Tt of[...Qe,...ot||[],...At||[]])oe.add(Tt),bt.add(Tt),tt.set(Tt,tn);lt.push({frag:tn,at:ut.lo})}}}function te(L,G){let re=xe.get(L);return re&&re.unchanged?!re.remote||re.remote===G?!0:z(re.remote,G):L.tagName!==G.tagName||!Ce(L,G)?!1:Pe(Te(L),Te(G))}function z(L,G){return L===G?!0:L.tagName!==G.tagName||L.namespaceURI!==G.namespaceURI||!Ce(L,G)?!1:ne(Te(L),Te(G))}function ne(L,G){let re=ve(L,s),ge=ve(G,s);if(re.length!==ge.length)return!1;for(let ye=0;ye<re.length;ye++){let ce=re[ye],se=ge[ye];if(typeof ce=="string"||typeof se=="string"){if(ce!==se)return!1}else{if(ce.nodeType!==se.nodeType)return!1;if(ce.nodeType===1){if(!z(ce,se))return!1}else if(ce.nodeValue!==se.nodeValue)return!1}}return!0}function Te(L){return L.tagName==="TEMPLATE"&&L.content?L.content:L}function Ce(L,G){let re=0;for(let ge of L.attributes)if(!n.ignoreAttribute(L,ge.name)&&(re++,G.getAttribute(ge.name)!==ge.value))return!1;for(let ge of G.attributes)n.ignoreAttribute(G,ge.name)||re--;return re===0}function Pe(L,G){let re=ve(L,ye=>{let ce=xe.get(ye);return!!(ce&&ce.pinned)}),ge=ve(G,s);if(re.length!==ge.length)return!1;for(let ye=0;ye<re.length;ye++){let ce=re[ye],se=ge[ye];if(typeof ce=="string"||typeof se=="string"){if(ce!==se)return!1}else{if(ce.nodeType!==se.nodeType)return!1;if(ce.nodeType===1){if(!te(ce,se))return!1}else if(ce.nodeValue!==se.nodeValue)return!1}}return!0}function ve(L,G){let re=[],ge=null;for(let ye=L.firstChild;ye;ye=ye.nextSibling){if(ye.nodeType===3){ge=ge===null?ye.nodeValue:ge+ye.nodeValue;continue}ye.nodeType===1&&G(ye)||(ge!==null&&(ge!==""&&re.push(ge),ge=null),re.push(ye))}return ge!==null&&ge!==""&&re.push(ge),re}function _e(L,G,re,ge){let ye=L.value,ce=ge?ye:G?G.value:"",se=re?re.value:"";oe.add(L),G&&oe.add(G),re&&oe.add(re);let Ie=ce===se?ce:ce===ye?se:se===ye||Ge==="local"?ce:se,Be={site:"comment",bRun:L,lRun:G,rRun:re,node:null};if(ce!==ye&&se!==ye&&ce!==se&&wt({kind:"text",node:null,base:ye,local:ce,remote:se,resolved:Ie},Be),!G&&!re)return null;let He=ie.createComment(Ie);return Be.node=He,xe.set(He,{base:L.nodes,local:G?G.nodes:null,remote:re?re.nodes:null}),He}function Je(L,G){let re=a(G,L);if(!re)return null;let ge=it(re)?re.parentNode:re.parent,ye=it(L)?L.parentNode:L.parent;return a(G,ye)===ge?null:G.reverse.get(ge)||null}function Ze(L){let G=new Set([L]),re=L;for(let ge=0;ge<64;ge++){let ye=Je(re,H)||Je(re,q);if(!ye)return!1;if(ye===L||it(L)&&it(ye)&&L.contains(ye)||G.has(ye))return!0;G.add(ye),re=ye}return!0}function Ut(L,G,re){if(!G)return!1;let ge=it(L)?L.parentNode:L.parent;return ge===G||G.tagName==="TEMPLATE"&&ge===G.content}function Pt(L,G){let re=Re(L),ge=a(H,re);if(ge&&Ut(G,ge,H))return!0;let ye=a(q,re);return!!(ye&&Ut(G,ye,q))}}function Ur(e,o){return e.map.get(o)?Vr():{map:{get:n=>n&&n.nodeType===1&&e.map.get(n)||n,has:()=>!0},reverse:{get:n=>e.reverse.get(n)||n,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Vr(){let e={get:o=>o,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Hr=new Set(["INPUT","OPTION","TEXTAREA"]),Ps=/[\t\n\f\r ]+/;function Wr(e,o,t,n){let s=e.ownerDocument,{provenance:h,textMappers:l}=t,r=n.hooks,i=[],u=[],w=[],c=new Set,p=[],b=[],S=new Map,C=new Set,m=new Map,f=t.conflicts.length>0||n.trackInserted===!0,g=new Map,I=new Set,v=new Map,T=(a,O)=>{let P=v.get(a);P||v.set(a,P=new Set),P.add(O)},A=f?new Set:null,E=(a,O,P)=>{let K=r.beforeAttributeUpdated(a,O,P);return f&&K===!1&&T(O,a),K},N=a=>!!a&&(a===e||e.contains(a)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(a)),M=new Map,R=new Map,V=new Map,D=new Set,j=new Map;(function a(O){let P=h.get(O);if(P){if(O.nodeType===1){let Z=P.local?n.toLive(P.local):null;Z&&N(Z)&&Z.nodeType===1&&(M.set(O,Z),R.set(Z,O))}else if(Array.isArray(P.local)){let Z=q(P.local,P.local.map(U=>n.toLive(U)).filter(U=>U&&N(U)&&U.nodeType===O.nodeType));if(Z.length&&(M.set(O,Z[0]),R.set(Z[0],O),V.set(O,Z)),Array.isArray(P.caret))for(let U of P.caret){let de=n.toLive(U.node);if(!de||!N(de)||de.nodeType!==3)continue;let we=j.get(de);Array.isArray(we)||j.set(de,we=[]),we.push({merged:O,from:U.from,to:U.to,flatStart:U.flatStart})}else{let U=0;for(let de of Z)j.set(de,{merged:O,shift:U}),U+=de.nodeValue.length}}}let K=O.nodeType===1&&O.tagName==="TEMPLATE"&&O.content?O.content.childNodes:O.childNodes;for(let Z of K)a(Z)})(o);let y=new Set;for(let a of M.values())y.add(a);for(let a of V.values())for(let O of a)y.add(O);let k=n.localRoot&&n.localRoot!==e?new Set:null;if(k){for(let a=n.localRoot.firstElementChild;a;a=a.nextElementSibling)if(a.tagName==="HEAD")for(let O=a.firstElementChild;O;O=O.nextElementSibling){let P=n.toLive(O);P&&k.add(P)}}for(let a of t.segments||[])Me(a);let J=n.restoreFocus===!1?null:kl(s,j);n.childrenOnly?xe(Oe(e),Oe(o)):Re(e,o);for(let{node:a,parent:O}of p)c.has(a)||!a.parentNode||a.nodeType===1&&(n.ignored(a)||qe(a))||nt(a,O);return xl(s,J,j,l,V,m,D),{applied:i,moved:u,replaced:w,identities:b,mergedScriptsLive:C,liveOf:M,heldBy:m,runOf:V,keptRuns:D,insertedLive:g,vetoed:I,vetoedAttrs:v,removedVetoes:A};function H(a,O){let P=a.slice(O.bs,O.be),K=0;for(;K<P.length&&K<O.text.length&&P[K]===O.text[K];)K++;let Z=0;for(;Z<P.length-K&&Z<O.text.length-K&&P[P.length-1-Z]===O.text[O.text.length-1-Z];)Z++;return{bs:O.bs+K,be:O.be-Z,text:O.text.slice(K,O.text.length-Z)}}function q(a,O){if(!O.length)return O;let P=[];for(let U of a){let de=U.parentNode;if(!de)continue;let we=S.get(de);if(!we){we=new Set;for(let le=de.firstChild;le;le=le.nextSibling)le.nodeType===3&&we.add(n.toLive(le));S.set(de,we)}P.includes(we)||P.push(we)}let K={has:U=>P.some(de=>de.has(U))},Z=[];for(let U of O){Z.push(U);for(let de=U.nextSibling;de&&de.nodeType===3&&!K.has(de)&&!Z.includes(de);de=de.nextSibling)Z.push(de)}return Z}function Me(a){let O=[];for(let ee of a.localNodes){let te=n.toLive(ee.node);if(!te||!N(te)||te.nodeType!==3)return;O.push(te)}let P=q(a.localNodes.map(ee=>ee.node),O);if(!P.length)return;let K=P.map(ee=>ee.nodeValue).join(""),{flatLocal:Z,lToM:U,mapLocal:de}=a;if(K===Z)return;let we=a.textNodes.map(ee=>({node:ee.node,ms:ee.ms,me:ee.me})),le=[],Ae=0;for(let ee of P)le.push(Ae),Ae+=ee.nodeValue.length;let W=(ee,te)=>P.find((z,ne)=>le[ne]<=ee&&ee+te<=le[ne]+z.nodeValue.length)||null,X=[],pe=0;for(let ee of Yn(Z,K).map(te=>H(Z,te))){let te=ee.bs+pe;pe+=ee.text.length-(ee.be-ee.bs);let z,ne;if(ee.be>ee.bs){z=U[ee.bs];let Te=z>=0;for(let Ce=ee.bs;Te&&Ce<ee.be;Ce++)U[Ce]!==z+(Ce-ee.bs)&&(Te=!1);if(!Te)continue;ne=z+(ee.be-ee.bs)}else{let Te=ee.bs>0?U[ee.bs-1]:0,Ce=ee.bs<Z.length?U[ee.bs]:0;if(Te<0||Ce<0)continue;z=ne=de(ee.bs)}X.push({ms:z,me:ne,text:ee.text,live:ne===z?W(te,ee.text.length):null})}X.sort((ee,te)=>te.ms-ee.ms);let be=(ee,te)=>(V.get(ee.node)||[M.get(ee.node)]).includes(te),he=ee=>!!ee&&ee.nodeType===1&&Tn.has(ee.tagName);for(let ee of X){let te=we.find(ne=>ne.ms<=ee.ms&&ee.me<=ne.me&&ee.ms<ne.me);if(te&&ee.live&&te.ms===ee.ms&&!be(te,ee.live)){let ne=we.find(Te=>Te.me===ee.ms&&be(Te,ee.live));ne&&(te=ne)}if(!te&&ee.me===ee.ms){let ne=we.find(ve=>ve.me===ee.ms),Te=we.find(ve=>ve.ms===ee.ms),Ce=ne||Te;if(!Ce)continue;let Pe=Ce.node;for(;he(Pe.parentNode)&&(ne?Pe.parentNode.lastChild:Pe.parentNode.firstChild)===Pe;)Pe=Pe.parentNode;if(Pe===Ce.node)te=Ce;else{let ve=Pe.ownerDocument.createTextNode(ee.text);Pe.parentNode.insertBefore(ve,ne?Pe.nextSibling:Pe);continue}}if(!te)continue;let z=te.node.nodeValue;te.node.nodeValue=z.slice(0,ee.ms-te.ms)+ee.text+z.slice(ee.me-te.ms),te.me+=ee.text.length-(ee.me-ee.ms)}}function Oe(a){return a.nodeType===1&&a.tagName==="TEMPLATE"&&a.content?a.content:a}function Re(a,O){c.add(a);let P=h.get(O);if(P&&P.remote&&t.remoteIdOf){let Z=t.remoteIdOf(P.remote);Z&&b.push([a,Z])}if(P&&P.unchanged){n.opaque&&n.opaque(a)||(t.customIdentity&&P.remote&&ae(a,P.remote),P.remote&&Y(a,P.remote));return}if(r.beforeNodeMorphed(a,O)===!1){I.add(O);return}Ct(a,O,n.keepLiveOnly&&P&&P.local&&P.local.nodeType===1&&P.local!==a?P.local:null);let K=a.tagName;if(pn(a))a.textContent!==O.textContent&&(i.push({kind:"text",node:a,before:a.textContent,after:O.textContent}),a.textContent=O.textContent),t.mergedScripts.has(O)&&C.add(a);else if(K==="TEXTAREA")$(a,O,P);else{Yt(a,O,P);let Z=K==="TEMPLATE"&&a.content?a.content:a,U=K==="TEMPLATE"&&O.content?O.content:O;n.opaque&&n.opaque(a)||n.protectFocusedValue==="subtree"&&Nt(a)&&a!==s.body?ie(Z):xe(Z,U)}r.afterNodeMorphed(a,O)}function ie(a){for(let O=a.firstChild;O;O=O.nextSibling){let P=R.get(O);P&&M.get(P.parentNode)!==a||(c.add(O),O.nodeType===1&&ie(O))}}function xe(a,O){let P=De(a.firstChild),K=new Set;for(let Z of Array.from(O.childNodes)){let U=M.get(Z);U&&c.has(U)&&!K.has(U)&&(U=null);let de=h.get(Z);if(de&&de.pinned){U&&U.nodeType===1&&((U.parentNode!==a||De(U.nextSibling)!==P)&&Ne(a,U,P),c.add(U),K.add(U));continue}if(U&&U.nodeType===1){if(U!==P){let Ae=U.parentNode;if(Ae===a&&P&&Lt(U)){let W=U.nextSibling;for(let X=P;X&&X!==U;){let pe=X.nextSibling;Ne(a,X,W),X=pe}}else Ne(a,U,P),Ae!==a&&(u.push(U),i.push({kind:"move",el:U,from:Ae,to:a}))}K.add(U),Re(U,Z),P=De(U.nextSibling);continue}if(U&&U.nodeType!==1){let Ae=V.get(Z)||[U],W=Ae.map(pe=>pe.nodeValue).join(""),X=Z.nodeValue;if(Z.nodeType===3){let pe=fe(Z);pe!=null&&W!==pe&&(X=lo(pe,W,Z.nodeValue).text)}if(Ae.length>1&&W===X&&!Ae.includes(P,1)&&Ae.every((pe,be)=>pe.parentNode===a&&(be===0||Ae[be-1].nextSibling===pe))){if(U!==P)for(let pe of Ae)Ne(a,pe,P);r.beforeNodeMorphed(U,Z)!==!1?r.afterNodeMorphed(U,Z):f&&I.add(Z);for(let pe of Ae)c.add(pe),K.add(pe);m.set(Z,U),D.add(Z),P=De(Ae[Ae.length-1].nextSibling);continue}U!==P&&Ne(a,U,P),r.beforeNodeMorphed(U,Z)!==!1?(U.nodeValue!==X&&(i.push({kind:"text",node:U,before:U.nodeValue,after:X}),U.nodeValue=X),r.afterNodeMorphed(U,Z)):I.add(Z),c.add(U),K.add(U),m.set(Z,U),P=De(U.nextSibling);continue}if(Z.nodeType===3&&P&&P.nodeType===3&&!c.has(P)&&!j.has(P)){P.nodeValue!==Z.nodeValue&&(i.push({kind:"text",node:P,before:P.nodeValue,after:Z.nodeValue}),P.nodeValue=Z.nodeValue),c.add(P),m.set(Z,P),P=De(P.nextSibling);continue}let we=h.get(Z),le=Xe(we&&we.unchanged&&we.remote?we.remote:Z);if(r.beforeNodeAdded(le)===!1){I.add(Z);continue}a.insertBefore(le,P),c.add(le),f&&g.set(Z,le),le.nodeType===3&&m.set(Z,le),le.nodeType===1&&(w.push(le),Ee(le,Z),t.customIdentity&&we&&we.unchanged&&we.remote&&ae(le,we.remote),pn(le)||ht(le,Z),n.formState==="property"&&rn(we)&&Y(le,we.remote)),P=De(le.nextSibling),i.push({kind:"insert",node:le,parent:a}),r.afterNodeAdded(le)}for(let Z of Array.from(a.childNodes))c.has(Z)||K.has(Z)||Z.nodeType===1&&(n.ignored(Z)||qe(Z))||(y.has(Z)?p.push({node:Z,parent:a}):nt(Z,a))}function qe(a){return a.parentNode&&a.parentNode.nodeType===1&&a.parentNode.tagName==="HEAD"&&(k&&!k.has(a)||n.preserve&&n.preserve(a)===!0)}function fe(a){let O=h.get(a);return!O||!Array.isArray(O.local)?null:O.local.map(P=>P.nodeValue).join("")}function x(a){return h.get(a)}function Y(a,O){if(!Hr.has(a.tagName)&&!a.querySelector("input,option,textarea"))return;let P=(K,Z)=>{if(K.tagName!==Z.tagName||(K.tagName==="TEXTAREA"?$(K,Z,{remote:Z}):Hr.has(K.tagName)&&Yt(K,Z,{remote:Z}),n.opaque&&n.opaque(K)))return;let U=oe(K),de=oe(Z);if(U.length===de.length)for(let we=0;we<U.length;we++)P(U[we],de[we])};P(a,O)}function ae(a,O){if(n.opaque&&n.opaque(a))return;let P=oe(a),K=oe(O);if(P.length===K.length)for(let Z=0;Z<P.length;Z++){let U=t.remoteIdOf(K[Z]);U&&b.push([P[Z],U]),ae(P[Z],K[Z])}}function oe(a){let O=a.tagName==="TEMPLATE"&&a.content?a.content:a;return Array.from(O.children).filter(P=>!n.ignored(P))}function Ee(a,O){if(!t.remoteIdOf)return;let P=(K,Z)=>{let U=h.get(Z);if(U&&U.remote&&Z.nodeType===1){let le=t.remoteIdOf(U.remote);le&&b.push([K,le])}let de=K.childNodes,we=Z.childNodes;for(let le=0;le<de.length&&le<we.length;le++)P(de[le],we[le])};P(a,O)}function De(a){for(;a&&a.nodeType===1&&n.ignored(a);)a=a.nextSibling;return a}function Ne(a,O,P){if(typeof a.moveBefore=="function"&&O.ownerDocument===a.ownerDocument)try{a.moveBefore(O,P);return}catch{}a.insertBefore(O,P)}function nt(a,O){if(r.beforeNodeRemoved(a)===!1){f&&A.add(a);return}a.parentNode.removeChild(a),i.push({kind:"remove",node:a,parent:O}),r.afterNodeRemoved(a)}function Xe(a){if(pn(a))return Mo(a,s);let O=s.importNode(a,!0);if(O.nodeType===1)for(let P of Array.from(O.querySelectorAll("script")))pn(P)&&P.replaceWith(Mo(P,s));return O}function ht(a,O){let P=a.tagName==="TEMPLATE"&&a.content?a.content:a,K=O.tagName==="TEMPLATE"&&O.content?O.content:O,Z=Array.from(P.childNodes),U=Array.from(K.childNodes);for(let de=0;de<U.length&&de<Z.length;de++){let we=U[de],le=Z[de],Ae=M.get(we);Ae&&c.has(Ae)&&(Ae=null);let W=h.get(we);if(W&&W.pinned){if(Ae&&Ae.nodeType===1){let X=Ae.parentNode;Ne(P,Ae,le),X!==P&&(u.push(Ae),i.push({kind:"move",el:Ae,from:X,to:P})),c.add(Ae)}le.remove();continue}if(Ae){let X=Ae.parentNode;Ne(P,Ae,le),le.remove(),Ae.nodeType===1?(X!==P&&(u.push(Ae),i.push({kind:"move",el:Ae,from:X,to:P})),Re(Ae,we)):(c.add(Ae),m.set(we,Ae),Ae.nodeValue!==we.nodeValue&&(i.push({kind:"text",node:Ae,before:Ae.nodeValue,after:we.nodeValue}),Ae.nodeValue=we.nodeValue));continue}c.add(le),f&&g.set(we,le),le.nodeType===3&&m.set(we,le),W&&W.unchanged&&W.remote?(Ge(le,W.remote),t.customIdentity&&ae(le,W.remote)):we.nodeType===1&&!pn(we)&&ht(le,we)}}function Ge(a,O){let P=a.tagName==="TEMPLATE"&&a.content?a.content:a,K=O.tagName==="TEMPLATE"&&O.content?O.content:O;for(let Z of Array.from(K.childNodes))P.appendChild(Xe(Z))}function rt(a,O){return O.namespaceURI?a.getAttributeNS(O.namespaceURI,O.localName):a.getAttribute(O.name)}function Ot(a,O){let P=new Set((O||"").split(Ps).filter(Boolean));return(a||"").split(Ps).filter(K=>K&&!P.has(K))}function Ct(a,O,P){for(let K of Array.from(O.attributes)){if(wt(a,K.name)||n.ignoreAttribute(a,K.name))continue;let Z=rt(a,K);if(Z===K.value||P&&rt(P,K)===K.value)continue;let U=K.value;if(P&&K.name==="class"&&!K.namespaceURI){let de=K.value.split(Ps).filter(Boolean),we=Ot(Z,P.getAttribute("class")).filter(le=>!de.includes(le));we.length&&(U=[...de,...we].join(" "))}if(Z!==U){if(r.beforeAttributeUpdated(K.name,a,"update")===!1){f&&T(O,K.name);continue}K.namespaceURI?a.setAttributeNS(K.namespaceURI,K.name,U):a.setAttribute(K.name,U),i.push({kind:"attr",el:a,name:K.name,before:Z,after:U})}}for(let K of Array.from(a.attributes)){if(wt(a,K.name)||n.ignoreAttribute(a,K.name)||(K.namespaceURI?O.hasAttributeNS(K.namespaceURI,K.localName):O.hasAttribute(K.name)))continue;if(P&&K.name==="class"&&!K.namespaceURI){let de=Ot(K.value,P.getAttribute("class"));if(de.length){let we=de.join(" ");if(we===K.value)continue;if(r.beforeAttributeUpdated("class",a,"update")===!1){f&&T(O,"class");continue}a.setAttribute("class",we),i.push({kind:"attr",el:a,name:"class",before:K.value,after:we});continue}}if(P&&rt(P,K)===null)continue;if(r.beforeAttributeUpdated(K.name,a,"remove")===!1){f&&T(O,K.name);continue}let U=K.value;K.namespaceURI?a.removeAttributeNS(K.namespaceURI,K.localName):a.removeAttribute(K.name),i.push({kind:"attr",el:a,name:K.name,before:U,after:null})}}function wt(a,O){let P=a.tagName;return P==="INPUT"?O==="value"||O==="checked"||O==="disabled":P==="OPTION"?O==="selected":!1}function Nt(a){return a===s.activeElement}function Lt(a){let O=s.activeElement;return!!O&&O!==s.body&&a.contains(O)}function qt(a,O){let P=O&&O.local&&O.local.nodeType===1&&O.local!==a?O.local:null;if(!P)return!0;let K=a.tagName==="TEXTAREA"?P.textContent:P.getAttribute("value")??"";return a.value!==K}function cn(a,O){return!!n.protectFocusedValue&&Nt(a)&&qt(a,O)}function It(a,O,P){let K=Math.min(a.length,O.length),Z=0;for(;Z<K&&a[Z]===O[Z];)Z++;if(P<=Z)return P;let U=0;for(;U<K-Z&&a[a.length-1-U]===O[O.length-1-U];)U++;return P>=a.length-U?P+O.length-a.length:O.length-U}function Gt(a){try{return a.selectionStart==null?null:[a.selectionStart,a.selectionEnd,a.selectionDirection]}catch{return null}}function wn(a,O,P,K){try{a.setSelectionRange(It(O,P,K[0]),It(O,P,K[1]),K[2]||"none")}catch{}}function Dt(a,O){let P=a.value,K=Gt(a);a.value=O,K&&wn(a,P,O,K)}function rn(a){let O=a&&a.remote;return O&&O.nodeType===1?O:null}function Yt(a,O,P){let K=a.tagName,Z=rn(P),U=n.formState==="property"&&Z?Z:O;if(K==="INPUT"){let de=cn(a,P),we=(a.getAttribute("type")||"").toLowerCase(),le=we!=="file"&&we!=="checkbox"&&we!=="radio",Ae=Z&&Z.hasAttribute("value")&&Z.value!==Z.getAttribute("value")?Z.value:null;if(le&&!de)if(n.formState==="property"){let W=O.getAttribute("value"),X=a.getAttribute("value");(X!==W||a.value!==U.value)&&E("value",a,W==null?"remove":"update")!==!1&&(X!==W&&(W==null?a.removeAttribute("value"):a.setAttribute("value",W),i.push({kind:"attr",el:a,name:"value",before:X,after:W})),a.value!==U.value&&(Nt(a)?Dt(a,U.value):a.value=U.value))}else if(O.hasAttribute("value")||Ae!=null){let W=Ae??O.getAttribute("value");a.getAttribute("value")!==W&&E("value",a,"update")!==!1?(a.setAttribute("value",W),a.value!==W&&(Nt(a)?Dt(a,W):a.value=W),i.push({kind:"attr",el:a,name:"value",before:null,after:W})):a.value!==W&&a.getAttribute("value")===W&&(Nt(a)?Dt(a,W):a.value=W)}else(a.hasAttribute("value")||a.value!=="")&&E("value",a,"remove")!==!1&&(a.removeAttribute("value"),a.value="",i.push({kind:"attr",el:a,name:"value",before:"",after:null}));if(!le&&we!=="file"){let W=O.getAttribute("value");W==null?a.hasAttribute("value")&&E("value",a,"remove")!==!1&&a.removeAttribute("value"):a.getAttribute("value")!==W&&E("value",a,"update")!==!1&&a.setAttribute("value",W)}n.protectFocusedValue&&Nt(a)||(fn(a,U,"checked"),n.formState==="property"&&a.indeterminate!==U.indeterminate&&(a.indeterminate=U.indeterminate)),fn(a,U,"disabled")}else if(K==="OPTION"){let de=a.parentNode&&a.closest("select");n.protectFocusedValue&&de&&Nt(de)||fn(a,U,"selected")}}function fn(a,O,P){let K=n.formState==="property"?!!O[P]:O.hasAttribute(P);if(n.formState!=="property"){let Z=a.hasAttribute(P);if(Z!==K){if(E(P,a,K?"update":"remove")===!1)return;K?a.setAttribute(P,""):a.removeAttribute(P),i.push({kind:"attr",el:a,name:P,before:Z?"":null,after:K?"":null})}}a[P]!==K&&(a[P]=K)}function $(a,O,P){if(cn(a,P)||E("value",a,"update")===!1)return;let K=rn(P),Z=O.textContent,U=K&&K.value!==K.defaultValue?K.value:Z,de=Nt(a)?Gt(a):null,we=a.value;n.formState!=="property"&&a.textContent!==Z&&(i.push({kind:"text",node:a,before:a.textContent,after:Z}),a.textContent=Z),a.value!==U&&(a.value=U),de&&a.value!==we&&wn(a,we,a.value,de)}}function kl(e,o){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let n={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{n.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return n}let s=e.getSelection&&e.getSelection();if(s&&s.rangeCount){let h=s.getRangeAt(0);n.range={sc:h.startContainer,so:h.startOffset,ec:h.endContainer,eo:h.endOffset}}return n}function xl(e,o,t,n,s,h,l){if(!o)return;let r=o.el;if(!r.isConnected&&o.id&&(r=e.getElementById(o.id)),!r||!r.isConnected)return;if(e.activeElement!==r)try{r.focus({preventScroll:!0})}catch{}try{r.scrollTop=o.scrollTop,r.scrollLeft=o.scrollLeft}catch{}if(o.selection){try{r.setSelectionRange&&!r.selectionEnd&&o.selection[1]!=null&&r.setSelectionRange(o.selection[0],o.selection[1],o.selection[2]||"none")}catch{}return}if(!o.range)return;let i=(c,p)=>{let b=t.get(c);if(Array.isArray(b)){let S=b.find(g=>p>=g.from&&p<g.to)||b.find(g=>p===g.to)||b[b.length-1],C=h.get(S.merged);if(!C||!C.isConnected)return null;let m=n.get(S.merged),f=m&&m.flat?m.flat(S.flatStart+p):p;return[C,Math.max(0,Math.min(f,C.nodeValue.length))]}if(b&&!l.has(b.merged)){let S=(s.get(b.merged)||[c])[0];if(!S.isConnected)return null;let C=n.get(b.merged),m=b.shift+p,f=C?C(m):m;return[S,Math.max(0,Math.min(f,S.nodeValue.length))]}return c.isConnected?[c,Math.min(p,c.nodeType===3?c.nodeValue.length:c.childNodes.length)]:null},u=i(o.range.sc,o.range.so),w=i(o.range.ec,o.range.eo);if(!(!u||!w))try{let c=e.createRange();c.setStart(u[0],u[1]),c.setEnd(w[0],w[1]);let p=e.getSelection();p.removeAllRanges(),p.addRange(c)}catch{}}var Tl={compared:0},vl=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Sl(e,o,t){let n=0;for(let s of e.attributes)if(!t(e,s.name)&&(n++,o.getAttribute(s.name)!==s.value))return!1;for(let s of o.attributes)t(o,s.name)||n--;return n===0}function Bs(e,o){if(e.namespaceURI!==o.namespaceURI||e.prefix!==o.prefix||e.localName!==o.localName)return!1;let t=e.attributes;if(t.length!==o.attributes.length)return!1;for(let n of t)if(o.getAttributeNS(n.namespaceURI,n.localName)!==n.value)return!1;return!0}function qr(e,o,t,n,s,h,l,r){let i=new Map,u=new Set,w=c=>{if(n(c))return;let p=t(c);p&&(h.add(p),s.has(p)||i.has(p)?u.add(p):i.set(p,c))};for(let c of e)w(c);w(o);for(let c of l||o.querySelectorAll("*"))w(c);for(let c of u)i.delete(c),r.add(c);return i}function Kr(e,o,t,n,s,h){let l=!1;for(let w of s)w.startsWith("merge:")&&(l=!0);if(!l)return[...n];let r=new Map,i=[],u=h===kn?Co:"*";for(let w of[e,...e.querySelectorAll(u)]){if(t(w))continue;let c=o(w);if(!c||!(n.has(c)||s.has(c)))continue;let p=(r.get(c)||0)+1;r.set(c,p),p===2&&i.push(c)}return i}function Fr({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:s,identity:h,baseURI:l}){if(e.tagName!==o.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||o.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!Sl(e,o,s.ignoreAttribute))return{bail:"root-attrs"};let{ignored:r,remoteWins:i}=s,u=Rs(s.scripts.merge===!1?null:s.scripts.mergeTags,l),w=fe=>{let x=u(fe);return x!==null?x:h.base(fe)||null},c=fe=>{let x=u(fe);return x!==null?x:h.remote(fe)||null},p=[],b=[],S=new Map,C=new Map,m={same:S,differ:C},f=fe=>({bail:fe,comparisons:m}),g=(fe,x,Y=!0)=>{if(S.get(fe)===x)return!0;if(C.get(fe)===x)return!1;if(Tl.compared++,Y&&fe.isEqualNode(x))return S.set(fe,x),!0;let ae=fe.nodeType===x.nodeType;if(ae&&fe.nodeType===1){if(ae=Bs(fe,x),ae){let oe=fe.firstChild,Ee=x.firstChild;for(;oe&&Ee;oe=oe.nextSibling,Ee=Ee.nextSibling)if(!g(oe,Ee,!1)){ae=!1;break}(oe||Ee)&&(ae=!1)}}else ae&&(ae=fe.isEqualNode(x));return(ae?S:C).set(fe,x),ae},I=e,v=o,T=!1,A=()=>{S.set(I,v);for(let fe=0;fe<p.length;fe++)S.set(p[fe],b[fe]);return f("equal")};for(;;){let fe=I.childNodes,x=v.childNodes;if(fe.length!==x.length)break;let Y=Xe=>g(fe[Xe],x[Xe])?(S.set(fe[Xe],x[Xe]),!1):!0,ae=-1,oe=-1;for(let Xe=0;Xe<fe.length;Xe++){if(fe[Xe].nodeType!==1)continue;let ht=0;for(let Ge=fe[Xe].firstElementChild;Ge;Ge=Ge.nextElementSibling)ht++;ht>=oe&&(oe=ht,ae=Xe)}let Ee=[],De=!1;for(let Xe=0;Xe<fe.length&&Ee.length<2;Xe++)Xe!==ae&&Y(Xe)&&Ee.push(Xe);if(ae>=0&&Ee.length<2&&(Ee.length===0&&Bs(I,v)?(Ee.push(ae),De=!0):Y(ae)&&Ee.push(ae)),Ee.length!==1){if(!T&&Ee.length===0&&Bs(I,v))return A();break}let Ne=fe[Ee[0]],nt=x[Ee[0]];if(T=T||!De,T&&C.set(Ne,nt),Ne.nodeType!==1||nt.nodeType!==1||Ne.tagName!==nt.tagName)break;if(w(Ne)!==c(nt)){if(!T&&g(Ne,nt))return A();break}p.push(I),b.push(v),I=Ne,v=nt}C.set(I,v);for(let fe=0;fe<p.length;fe++)C.set(p[fe],b[fe]);if(I===e||I.tagName==="HEAD"||I.tagName==="BODY")return f("root-level");if(p.length<2||p[1].tagName!=="BODY")return f("not-in-body");if(r(I)||r(v))return f("ignored-ancestor");if(i(I)||i(v))return f("remote-wins-ancestor");for(let fe of p)if(vl.has(fe.tagName))return f("form-ancestor");if(I.tagName==="SCRIPT"||I.getElementsByTagName("script").length||v.getElementsByTagName("script").length)return f("script-or-template");let E=n(I);if(!E||E.nodeType!==1||E.tagName!==I.tagName)return f("no-live-twin");if(!t.contains(E))return f("live-detached");for(let fe of p){let x=n(fe);if(!x||x.nodeType!==1)return f("ancestor-live")}let N=h.base===kn&&h.remote===kn&&r===ss,M=new Set,R=new Set,V=[],D=null,j=fe=>{fe&&(M.has(fe)?R.add(fe):M.add(fe))},y=(fe,x)=>{let Y=u(fe),ae=Y!==null?Y:h.base(fe)||null;return ae!==(Y!==null?Y:h.remote(x)||null)?!1:(j(ae),!0)},k=(fe,x)=>{for(let Y=fe.firstElementChild,ae=x.firstElementChild;Y;Y=Y.nextElementSibling,ae=ae.nextElementSibling){let oe=r(Y);if(oe!==r(ae))return!1;if(!oe&&(!y(Y,ae)||!k(Y,ae)))return!1}return!0},J=fe=>{let x=fe+1<p.length?p[fe+1]:I;for(let Y=p[fe].firstElementChild,ae=b[fe].firstElementChild;Y;Y=Y.nextElementSibling,ae=ae.nextElementSibling){if(Y===x){let De=fe+1<p.length?J(fe+1):null;if(De)return De;continue}let oe=r(Y);if(oe!==r(ae))return"outside-id-changed";if(oe)continue;let Ee=n(Y);if(!Ee||Ee.nodeType!==1)return"sibling-live";if(V.push([Y,ae]),!N&&(!y(Y,ae)||!k(Y,ae)))return"outside-id-changed";fe===0&&Y.tagName==="HEAD"&&w(Y)&&(D=[Y,ae])}return null},H=J(0);if(H)return f(H);let q=new Set(p),Me=null;if(h.base===kn){Me=[];for(let fe of e.querySelectorAll(Co))fe===I||q.has(fe)||(I.contains(fe)?Me.push(fe):N&&j(w(fe)))}let Oe=new Set,Re=new Set,ie=new Set,xe=qr(p,I,w,r,M,Oe,Me,Re),qe=qr(b,v,c,r,M,Oe,h.remote===kn&&v.querySelectorAll(Co),ie);return D&&(R.has(w(D[0]))||Oe.has(w(D[0])))&&(D=null),{scope:{chain:p,root:I,onChain:q,baseIndex:xe,remoteIndex:qe,baseDropped:Re,remoteDropped:ie,head:D,same:S,differ:C,dropped:[...Kr(e,w,r,R,Re,h.base),...Kr(o,c,r,R,ie,h.remote)],held:fe=>{for(let x=1;x<p.length;x++)if(fe.map.get(p[x])!==b[x])return!1;for(let[x,Y]of V)if(fe.map.get(x)!==Y)return!1;return!0}}}}var _r=Symbol("hyper-morph-duplicate-key"),zr=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function Lo(e,o){return o.map(t=>{let n=new Map;for(let s of e){if(s.nodeType!==1)continue;let h=t(s);h==null||h===""||n.set(h,n.has(h)?_r:s)}return n})}function $r(e,o,t,n){for(let s=0;s<n.length;s++){let h=n[s](e);if(h==null||h===""||o[s].get(h)!==e)continue;let l=t[s].get(h);if(!(!l||l===_r)&&l.tagName===e.tagName)return l}return null}function bo(e,o,t){for(let n=0;n<t.length;n++){let s=t[n](e);if(!(s==null||s==="")&&o[n].get(s)===e)return!0}return!1}function Gr(e,o,t={}){let n=t.skip||(()=>!1),s=t.ignoreAttr||(()=>!1),h=t.tiers&&t.tiers.length?t.tiers:zr,l=null;function r(){return l||(l=Lo([e,...e.querySelectorAll("*")],h)),l}let i=null;function u(){return i||(i=Lo([o,...o.querySelectorAll("*")],h)),i}function w(M){return!M.parentElement||!M.parentElement.parentElement}function c(M,R,V){return w(M)||bo(M,r(),h)?(V.push({type:"subtree",el:M,base:R}),!1):!0}function p(M,R){let V=[];for(let D of M.attributes)s(M,D.name)||R.getAttribute(D.name)!==D.value&&V.push(D.name);for(let D of R.attributes)s(M,D.name)||M.hasAttribute(D.name)||V.push(D.name);return V}function b(M){let R=[],V=null,D=()=>{V!==null&&(R.push({nodeType:3,nodeValue:V}),V=null)};for(let j of M.childNodes){if(j.nodeType===3){V=(V===null?"":V)+j.nodeValue;continue}j.nodeType===1&&n(j)||(D(),(j.nodeType===1||j.nodeType===8)&&R.push(j))}return D(),R}function S(M,R){if(M.nodeType!==R.nodeType)return!1;if(M.nodeType!==1)return!0;if(M.tagName!==R.tagName)return!1;for(let V of h){let D=V(M),j=V(R);if(D!=null&&D!==""&&j!=null&&j!==""&&D!==j)return!1}return!0}function C(M){let R="";for(let V of M)V.nodeType===3&&V.nodeValue.trim()!==""?R+="\0"+V.nodeValue:V.nodeType===8&&(R+=""+V.nodeValue);return R}function m(M,R,V){let D=b(M),j=b(R);if(D.length===j.length){let fe=!0;for(let x=0;x<D.length;x++)if(!S(D[x],j[x])){fe=!1;break}if(fe){for(let x=0;x<D.length;x++){let Y=D[x];if(Y.nodeType===1){if(f(Y,j[x],V))return!0}else if(Y.nodeValue!==j[x].nodeValue)return!0}return!1}}let y=D.filter(fe=>fe.nodeType===1),k=j.filter(fe=>fe.nodeType===1);if(C(D)!==C(j))return!0;let J=Lo(y,h),H=Lo(k,h),q=[],Me=new Set,Oe=[];for(let fe of y){let x=$r(fe,J,H,h);x&&!Me.has(x)?(q.push([fe,x]),Me.add(x)):Oe.push(fe)}let Re=[];for(let fe of Oe)bo(fe,J,h)?V.push({type:"subtree",el:fe,base:null}):Re.push(fe);let ie=[];for(let fe of k)Me.has(fe)||(bo(fe,H,h)?V.push({type:"deletion",el:fe}):ie.push(fe));if(Re.length!==ie.length)return!0;for(let fe=0;fe<Re.length;fe++)if(!S(Re[fe],ie[fe]))return!0;let xe=new Map(q);for(let fe=0;fe<Re.length;fe++)xe.set(Re[fe],ie[fe]);let qe=-1;for(let fe of y){let x=xe.get(fe);if(!x)continue;let Y=k.indexOf(x);if(Y<qe)return!0;qe=Y}for(let fe=0;fe<Re.length;fe++)if(f(Re[fe],ie[fe],V))return!0;for(let[fe,x]of q)if(f(fe,x,V))return!0;return!1}function f(M,R,V){if(M.tagName!==R.tagName)return c(M,R,V);let D=p(M,R),j=[];if(m(M,R,j))return c(M,R,V);if(D.length){if(!w(M)&&!bo(R,u(),h))return!0;V.push({type:"attrs",el:M,names:D,base:R})}return V.push(...j),!1}let g=[],I=p(e,o);I.length&&g.push({type:"attrs",el:e,names:I});let v=(M,R)=>Array.from(M.children).find(V=>V.tagName===R)||null,T=v(e,"HEAD"),A=v(o,"HEAD");if(T&&A){let M=[];f(T,A,M),M.length&&g.push({type:"head",el:T})}else(T||A)&&T&&g.push({type:"head",el:T});let E=v(e,"BODY"),N=v(o,"BODY");return E&&N?f(E,N,g):E&&g.push({type:"subtree",el:E,base:null}),{entries:g}}function Yr(e,o,t={}){let n=t.tiers&&t.tiers.length?t.tiers:zr,s=e.documentElement,h=[],l=0,r=f=>({ok:!1,placed:h,held:f,skippedAttrs:l});if(!s)return r(null);function i(f){let g=[f,...f.querySelectorAll("*")];return Lo(g,n)}let u=i(s),w=new Map,c=f=>{let g=f.getRootNode(),I=w.get(g);if(!I){let v=g.nodeType===9?g.documentElement:g;I=i(v),w.set(g,I)}return I};function p(f){if(!f.parentElement&&f.tagName==="HTML")return s;if(f.parentElement&&!f.parentElement.parentElement&&f.parentElement.tagName==="HTML"){if(f.tagName==="BODY")return e.body||null;if(f.tagName==="HEAD")return e.head||null}return null}function b(f){let g=p(f);return g||$r(f,c(f),u,n)}function S(f){if(!f)return null;let g=b(f);return g&&g.isConnected?g:null}function C(f){for(let g=0;g<n.length;g++){let I=n[g](f);I!=null&&I!==""&&u[g].set(I,f)}}for(let f of o){if(f.type!=="deletion")continue;let g=b(f.el);g&&g!==s&&g.remove()}let m=o.filter(f=>f.type!=="deletion").sort((f,g)=>f.el===g.el?0:f.el.compareDocumentPosition(g.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let f of m){if(f.type==="head"){let N=e.importNode(f.el,!0);e.head?e.head.replaceWith(N):s.insertBefore(N,s.firstChild),h.push({entry:f,imported:N});continue}if(f.type==="attrs"){let N=S(f.el)||S(f.base);if(!N){l++;continue}for(let M of f.names)f.el.hasAttribute(M)?N.setAttribute(M,f.el.getAttribute(M)):N.removeAttribute(M);continue}let g=f.el;if(p(g))return r(f);let I=S(g)||S(f.base);if(I){let N=e.importNode(g,!0);I.replaceWith(N),C(N),h.push({entry:f,imported:N});continue}if(f.base!=null&&!bo(f.base,c(f.base),n)||!bo(g,c(g),n))return r(f);let v=g.parentElement;if(!v)return r(f);let T=S(v);if(!T)return r(f);let A=null;for(let N=g.previousElementSibling;N;N=N.previousElementSibling){let M=S(N);if(M&&M.parentNode===T){A=M;break}}let E=e.importNode(g,!0);if(A)T.insertBefore(E,A.nextSibling);else{let N=Array.prototype.indexOf.call(v.children,g);T.insertBefore(E,T.children[N]||null)}C(E),h.push({entry:f,imported:E})}return{ok:!0,placed:h,held:null,skippedAttrs:l}}var Nl='[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"]',Al='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Ml='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Ol(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let o=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(o)}function Il(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let s=o;if(s.nodeType===9){let h=e.getAttribute("id");s=h&&s.getElementById(h)||(e.tagName==="BODY"?s.body:e.tagName==="HTML"?s.documentElement:s.body&&s.body.firstElementChild)}if((!s||s.nodeType!==1||s.tagName!==e.tagName)&&(s=Cl(e,o,n)),!!s)return t?Array.from(s.childNodes):s}function Cl(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let s=new Map,h=[n,...n.querySelectorAll("script")];for(let i of h){let u=ho(i,t);u&&!s.has(u.key)&&s.set(u.key,i.textContent)}if(!s.size)return null;let l=e.cloneNode(!0),r=!1;for(let i of[l,...l.querySelectorAll("script")]){let u=ho(i,t);u&&s.has(u.key)&&(i.textContent=s.get(u.key),r=!0)}return r?l:null}function Xr(e,o){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=o.implementation.createHTMLDocument(""),n=e.nodeType===1&&e.tagName==="HTML"?e:null;if(n)return t.replaceChild(t.adoptNode(n),t.documentElement),t;let s=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let h of s)t.body.appendChild(t.adoptNode(h));return t}function Zo(e,o,t={}){let n=t||{};if(!n.head?.block)return Jr(e,o,n);try{return Jr(e,o,n)}catch(s){return Promise.reject(s)}}function Jr(e,o,t){let n=t.policy||"sync",s=n==="raw"?void 0:(i,u)=>Ol(i)||(n==="history"?!(u&&i.matches(Ml))&&i.matches(Al):i.matches(Nl)),h=t.callbacks||{},l={ignore:s,hooks:h,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 wo(Object.assign({},l,{live:e,base:t.scripts?.mergeBase||null,remote:Xr(o,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let i=Object.assign({},l,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Xr(o,e.ownerDocument)});return wo(i)}t.morphStyle==="innerHTML"&&(l.children=!0);let r=Il(e,t.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return r!==void 0&&(l.base=r),es(e,o,l)}var Ll=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),On=()=>{};function Eo(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let r of Object.keys(e))if(!Ll.has(r))throw new TypeError(`unknown option "${r}"`);let t=Object.assign({beforeNodeAdded:On,afterNodeAdded:On,beforeNodeRemoved:On,afterNodeRemoved:On,beforeNodeMorphed:On,afterNodeMorphed:On,beforeAttributeUpdated:On},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let s=e.formState||"attribute";if(!["attribute","property"].includes(s))throw new TypeError("formState must be attribute or property");let h=e.protectFocusedValue;if(h!==void 0&&typeof h!="boolean"&&h!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");let l=e.lineage;if(l!==void 0&&(!l||typeof l!="object"||typeof l.onResult!="function"||!l.elements||typeof l.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:rs(e.ignore,o),remoteWins:rs(e.remoteWins,o),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,opaque:typeof e.opaque=="function"?e.opaque:()=>!1,conflicts:n,protectFocusedValue:h===void 0?!0:h,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:s,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:l||null}}function yo(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 kn}function ko(e,o){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=Do(o,e.map),n=typeof e.then=="function"?e.then:kn;if(typeof e.first=="function"){let s=e.first;return h=>s(h)||t.get(h)||n(h)}return s=>t.get(s)||n(s)}return kn}function ni(e,o,t,n={}){let s=b=>b&&b.nodeType===9?b.documentElement:b,h=s(o),l=s(t),r=s(e)||h;if(n.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let i=Object.assign({},n);delete i.live,delete i.base,delete i.remote;let u=Eo(i,[r,h,l].filter(Boolean)),w=n.identity||{},c=$n(),p=Qo(r,h,l,{identity:{base:ko(w.base,r),local:ko(w.local,h),remote:ko(w.remote,l)},authored:{base:yo(w.base),local:yo(w.local),remote:yo(w.remote)},skipUnchanged:u.hooks.beforeNodeMorphed===On&&u.hooks.afterNodeMorphed===On,ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:h.ownerDocument&&h.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:u.children,stats:c});return delete p.recoveryLinks,delete p.lineage,p}function js({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:s,options:h,identity:l,childrenOnly:r,isDocument:i}){let u=Eo(h,[e,o,t,n].filter(Boolean));if(u.ignored(e)){let y=Ds(),k=u.lineage?Ao(u.lineage,e,y):null;return{report:y,loads:[],lineage:k}}let w=e.ownerDocument,c=u.lineage?Ss(u.lineage,{liveRoot:e,localRoot:t,toLive:s}):null,p=u.scripts.execute?br(e,u.ignored,w.baseURI):null,b=$n(),S=u.hooks.beforeNodeMorphed===On&&u.hooks.afterNodeMorphed===On,C={identity:{base:ko(l.base,o||t),local:ko(l.local,t),remote:ko(l.remote,n)},authored:{base:yo(l.base),local:yo(l.local),remote:yo(l.remote)},ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:w.baseURI,localIsBase:!o,childrenOnly:r,skipUnchanged:S,lineage:c?{locals:c.locals}:null},m=u.fastPath&&i&&!r&&S&&o===t,f=null,g=null;if(m){let y=Fr({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:s,o:u,identity:C.identity,baseURI:w.baseURI});C.comparisons=y.comparisons||y.scope,y.bail?g=y.bail:(f=Qo(o,t,n,Object.assign({},C,{stats:b,scope:y.scope})),f||(g="chain-unpaired",b=$n()))}f||(f=Qo(o||t,t,n,Object.assign({},C,{stats:b}))),m&&(b.fastPathAttempted=1,b.fastPathTaken=g?0:1,b.fastPathFallback=g),f.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(y=>u.hooks[y]!==On)&&Ar(f.conflicts,f.recoveryLinks,s),u.beforeApply&&u.beforeApply(f.doc);let I=globalThis.__hyperMorphProfile,v=I?performance.now():0,T=Wr(e,f.root,f,{toLive:s,localRoot:t,ignored:u.ignored,ignoreAttribute:u.ignoreAttribute,opaque:u.opaque,formState:u.formState,protectFocusedValue:u.protectFocusedValue,restoreFocus:u.restoreFocus,preserve:u.head.preserve,hooks:u.hooks,childrenOnly:r,keepLiveOnly:u.keepLiveOnly,trackInserted:!!c});I&&(I.apply=(I.apply||0)+(performance.now()-v));let A=[];if(u.head.awaitLoads)for(let y of T.applied){if(y.kind!=="insert"||y.node.nodeType!==1)continue;let k=y.node;k.tagName==="LINK"&&/\bstylesheet\b/i.test(k.getAttribute("rel")||"")&&k.getAttribute("href")&&k.closest("head")&&A.push(new Promise(H=>{k.addEventListener("load",()=>H()),k.addEventListener("error",()=>H())}))}let E=null,N=null;if(p){let y=wr(e,p,{ignored:u.ignored,skip:T.mergedScriptsLive,baseURI:w.baseURI,beforeNodeAdded:u.hooks.beforeNodeAdded,afterNodeAdded:u.hooks.afterNodeAdded,trackRecovery:!!f.recoveryLinks});A.push(...y.loads),E=y.swapped,N=y.vetoed}let M=y=>E&&E.get(y)||y,R=y=>{if(T.keptRuns.has(y))return T.runOf.get(y);let k=T.liveOf.get(y)||T.heldBy.get(y)||T.insertedLive.get(y);return k?M(k):null},V=y=>{let k=y&&T.liveOf.get(y);return k?M(k):null},D=y=>{let k=y&&R(y);return Array.isArray(k)?k[0]:k};if(f.recoveryLinks){let y=(k,J,H)=>(J.namespaceURI?k.getAttributeNS(J.namespaceURI,J.localName):k.getAttribute(J.qualifiedName))===H;Ir(f.conflicts,f.recoveryLinks,{lookup:R,vetoed:T.vetoed,vetoedAttrs:T.vetoedAttrs,removedVetoes:T.removedVetoes,vetoedLive:N,liveAttr:y,ignored:u.ignored,liveRoot:e})}let j={applied:T.applied,decisions:f.decisions.map(y=>Object.assign({},y,{node:y.node?V(y.node):null,el:y.el?V(y.el):null,applied:!!(y.node?V(y.node):y.el&&V(y.el))})),conflicts:f.conflicts.map(y=>Object.assign({},y,{node:y.node?y.kind==="text"&&y.recovery.subject.nodeType===8?D(y.node):V(y.node):y.node,el:y.el?y.kind==="structure"?D(y.el):V(y.el):y.el})),localDiverged:f.localDiverged,identities:T.identities,moved:T.moved,replaced:T.replaced,stats:b};return c&&(j.lineage=c.finish(f.lineage,R)),{report:j,loads:A,lineage:c}}var Qr=new WeakMap;function Ds(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:$n()}}function wo(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");return o.lineage===void 0?Zr(o):vs(o,o.live.documentElement,n=>Zr(n))}function Zr(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let n=Qr.get(t);n||(n=jo(t),Qr.set(t,n));let s=n("remote",o.remote),h=typeof o.base=="string"&&o.base===""?null:o.base,l=h?n("base",h):null,r=o.local?o.local.root:t.documentElement,i=o.local?o.local.toLive:p=>p;Vs(t,s);let{report:u,loads:w,lineage:c}=js({liveRoot:t.documentElement,baseRoot:l?l.documentElement:null,localRoot:r,remoteRoot:s.documentElement,toLive:i,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return c?.deliver(u),Promise.all(w).then(()=>u)}function oi(e,o,t={}){return wo(Object.assign({},t,{live:e,base:null,remote:o}))}function ei(e,o){if(e==null)return{root:o.createElement("template"),first:null};if(typeof e=="string"){let n=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(n){let h=Bo(e,o),l=n[1].toLowerCase()==="html"?h.documentElement:h.body;return{root:l,first:l}}let s=o.createElement("template");return s.innerHTML=e,{root:s,first:s.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let n=o.createElement("template"),s=e.isConnected;return n.content.appendChild(s?o.importNode(e,!0):e),{root:n,first:e}}if(e.nodeType===11){let n=o.createElement("template");return n.content.appendChild(e),{root:n,first:n.content.firstElementChild}}let t=o.createElement("template");for(let n of Array.from(e))t.content.appendChild(n.parentNode?o.importNode(n,!0):n);return{root:t,first:t.content.firstElementChild}}function es(e,o,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return t.lineage===void 0?ti(e,o,t):vs(t,e,n=>ti(e,o,n))}function ti(e,o,t={}){let n=e.ownerDocument,{base:s,...h}=t,l=!!h.children,r=Eo(h,[e]);if(r.ignored(e)){let C=Ds();return r.lineage&&Ao(r.lineage,e,C).deliver(C),Promise.resolve(C)}let i=ei(o,n),u=s!=null?ei(s,n):null,w,c=null;if(l)w=i.root,c=u?u.root:null;else{if(w=i.first,c=u?u.first:null,!w){let C=Eo(h),m=C.lineage?Ao(C.lineage,e,{}):null;C.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),C.hooks.afterNodeRemoved(e));let f={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:$n()};return m&&(f.lineage=m.result,m.deliver(f)),Promise.resolve(f)}if(w.tagName!==e.tagName){let C=Eo(h,[e,w]);if(C.hooks.beforeNodeMorphed(e,w)===!1){let g=Ds();return C.lineage&&Ao(C.lineage,e,g).deliver(g),Promise.resolve(g)}let m=js({liveRoot:e,baseRoot:c&&c.tagName===e.tagName?c:null,localRoot:e,remoteRoot:w,toLive:g=>g,options:h,identity:h.identity||{},childrenOnly:!0,isDocument:!1}),f=pn(w)?Mo(w,n):n.importNode(w,!1);if(!pn(f))for(;e.firstChild;)f.appendChild(e.firstChild);return C.hooks.beforeNodeAdded(f)===!1?(Jo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):C.hooks.beforeNodeRemoved(e)===!1?(Jo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):(e.replaceWith(f),Jo(m.report.conflicts,e,f),C.hooks.afterNodeRemoved(e),C.hooks.afterNodeAdded(f),C.hooks.afterNodeMorphed(e,w),m.report.replaced.push(f),m.report.applied.push({kind:"insert",node:f,parent:f.parentNode},{kind:"remove",node:e,parent:f.parentNode}),m.lineage&&(m.report.lineage=m.lineage.remapRoot(e,f),m.lineage.deliver(m.report)),Promise.all(m.loads).then(()=>m.report))}}let{report:p,loads:b,lineage:S}=js({liveRoot:e,baseRoot:c,localRoot:e,remoteRoot:w,toLive:C=>C,options:h,identity:h.identity||{},childrenOnly:l,isDocument:!1});return S?.deliver(p),Promise.all(b).then(()=>p)}var El={mergeDocument:wo,morphDocument:oi,morphElement:es,merge3:ni,morph:Zo};return fi(Rl);})();
6
+ `+h)}return t+r.replace(/</g,"\\u003c")+n}function Yo(e,o,t,n={}){let s=n.parse||zo,h=[],l=[],r=(p,b)=>{if(typeof p!="string")return zt;try{return s(p)}catch(S){return h.push(`${b} side is not valid JSON (${S.message})`),zt}},i=r(o,"local"),u=r(t,"remote");if(i===zt)return{text:t,warnings:h,conflicts:l};if(u===zt)return{text:o,warnings:h,conflicts:l};let w=r(e,"base"),c=Os(w===zt?void 0:w,i,u,{...n,onConflict:p=>{l.push(p),n.onConflict?.(p)}});return qn(c,u)?{text:t,warnings:h,conflicts:l}:qn(c,i)?{text:o,warnings:h,conflicts:l}:{text:al(c,t),warnings:h,conflicts:l}}var vr=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function eo(e){if(!e)return!1;let{startContainer:o,startOffset:t,endContainer:n,endOffset:s}=e;if(!o||!n||!Number.isInteger(t)||!Number.isInteger(s)||t<0||s<0||t>vr(o)||s>vr(n)||o.getRootNode()!==n.getRootNode())return!1;let h=o.ownerDocument.createRange();return h.setStart(o,t),h.setEnd(n,s),h.startContainer===o&&h.startOffset===t}function Xn(e,o,t={}){if(!eo(e))return null;let{startContainer:n,startOffset:s,endContainer:h,endOffset:l}=e;if(n===h&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(s,l);if(n===h&&s===l)return"";let r=new Set;for(let m=n;m;m=m.parentNode)r.add(m);let i=h;for(;!r.has(i);)i=i.parentNode;let u=(m,f)=>{let g=i.ownerDocument.createRange(),I=i.ownerDocument.createRange();return g.setStart(m[0],m[1]),g.collapse(!0),I.setStart(f[0],f[1]),I.collapse(!0),g.compareBoundaryPoints(0,I)},w=(m,f=!1)=>[m.parentNode,Array.prototype.indexOf.call(m.parentNode.childNodes,m)+Number(f)],c=[],p;if(o==="plain"){p="";let m=f=>{if(f.nodeType===3||f.nodeType===8){let g=p.length;p+=f.nodeValue,c.push({s:g,e:p.length,a:[f,0],b:[f,f.nodeValue.length],node:f})}else for(let g of f.childNodes)m(g)};m(i)}else{let m=t.blocks;if(!m){m=new Set;let g=I=>{I!==i&&I.nodeType===1&&ks.has(I.tagName)&&m.add(I);for(let v of I.childNodes)g(v)};g(i)}let f=nn(Array.from(i.childNodes),{blocks:m,atomize:g=>!!t.atoms?.has(g),ignored:t.ignored});p=f.text;for(let g of f.nodes)c.push({s:g.s,e:g.e,a:[g.node,0],b:[g.node,g.e-g.s],node:g.node});for(let g of f.atoms)c.push({s:g.i,e:g.i+1,a:w(g.el),b:w(g.el,!0)});for(let g=0;g<f.text.length;g++){if(f.text[g]!==kt)continue;let I=f.marks.find(T=>T.block&&T.to===g+1),v=f.marks.find(T=>T.block&&T.from===g+1);if(I)c.push({s:g,e:g+1,a:[I.el,I.el.childNodes.length],b:w(I.el,!0)});else if(v)c.push({s:g,e:g+1,a:w(v.el),b:[v.el,0]});else return null}}c.sort((m,f)=>m.s-f.s);let b=m=>{if(m[0].nodeType===3||m[0].nodeType===8){let g=c.find(I=>I.node===m[0]);return g?g.s+m[1]:null}let f=0;for(let g of c){if(u(m,g.a)<=0)return g.s;if(u(m,g.b)<0)return null;f=g.e}return f},S=b([n,s]),C=b([h,l]);return S!==null&&C!==null&&S<=C?p.slice(S,C):null}function Zn(e,o){let t=e;for(let n of o.path)if(t=n==="content"?t?.content:t?.childNodes[n],!t)return null;return[t,o.offset]}function Sr(e,o){if(!e||!o)return null;let t=Zn(e,o.start),n=Zn(e,o.end);return t&&n?{startContainer:t[0],startOffset:t[1],endContainer:n[0],endOffset:n[1]}:null}var Nr=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ar(e,o,t){if(!o)return;let n=new Map,s=new Map,h=r=>{if(!r)return null;if(s.has(r))return s.get(r);let u=r.local.map(w=>Zn(o.localRoot,{path:w,offset:0})?.[0]).map(w=>w&&t(w)).filter(Boolean).map(w=>({node:w,parent:w.parentNode,previous:w.previousSibling,next:w.nextSibling,fragment:Nr(w)}));return s.set(r,u),u},l=r=>{let i=Sr(o.localRoot,r);if(!i)return null;let u=t(i.startContainer),w=t(i.endContainer);if(!u||!w)return null;let c={...i,startContainer:u,endContainer:w};return eo(c)?c:null};for(let r of e){let i=r.recovery;if(!i||n.has(i))continue;let u={subject:h(i.subject),span:null,scope:null,touched:new Set};if(i.text){u.span=l(i.text.local.span),u.scope=l(i.text.local.scope);let w=u.span;if(w){let c=w.startContainer.ownerDocument.createRange();c.setStart(w.startContainer,w.startOffset),c.setEnd(w.endContainer,w.endOffset);let p=b=>{if(c.intersectsNode(b)){u.touched.add(b);for(let S of b.childNodes)p(S)}};p(c.commonAncestorContainer)}}if(i.structure){for(let w of[i.structure.localPlacement])w&&(h(w.parent),w.before.forEach(h),w.after.forEach(h));for(let w of i.structure.localOrder||[])h(w)}n.set(i,u)}o.localState={states:n,refs:s}}function Mr(e,o,t,n){let s=t.localState?.states.get(e);if(!s)return!1;let h=r=>{let i=r.node;if(!n(i)||i.parentNode!==r.parent)return!1;let u=w=>Array.prototype.indexOf.call(i.parentNode.childNodes,w);return!(r.previous&&n(r.previous)&&r.previous.parentNode===i.parentNode&&u(r.previous)>=u(i)||r.next&&n(r.next)&&r.next.parentNode===i.parentNode&&u(r.next)<=u(i))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!s.subject.length||!s.subject.every(h))return!1;if(e.text){let r=e.text.local,i=u=>u&&n(u.startContainer)&&n(u.endContainer);return i(s.span)&&i(s.scope)&&Xn(s.scope,e.text.encoding)===r.text&&Xn(s.span,e.text.encoding)===r.text.slice(r.start,r.end)}if(e.attribute){let r=e.attribute,i=s.subject[0].node;return(r.namespaceURI?i.getAttributeNS(r.namespaceURI,r.localName):i.getAttribute(r.qualifiedName))===o.local}let l=e.structure;if(l.localOrder){let r=-1,i=null;for(let u of l.localOrder){let w=t.localState.refs.get(u)?.[0]?.node;if(!w||!n(w)||i&&w.parentNode!==i)return!1;let c=Array.prototype.indexOf.call(w.parentNode.childNodes,w);if(c<=r)return!1;i=w.parentNode,r=c}return!0}return l.localAction==="moved"||s.subject.every(r=>Nr(r.node)===r.fragment)}var cl=1,dn=e=>!!e&&e.nodeType===1,Xo=e=>dn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function to(e,o=null,t=null){let n=new Map,s=new Map,h=w=>{if(!o){o=new WeakMap;let c=[e];for(;c.length;){let p=c.pop();Xo(p)&&(o.set(p.content,p),c.push(p.content));for(let b=p.firstChild;b;b=b.nextSibling)b.nodeType===1&&c.push(b)}}return o.get(w)||null},l=(w,c)=>{let p=s.get(w);if(!p){p=new Map;let b=0;for(let S=w.firstChild;S;S=S.nextSibling)p.set(S,b++);s.set(w,p)}return p.get(c)},r=w=>{if(!w)return null;if(t&&t.has(w))return r(t.get(w));if(w===e)return[];let c=n.get(w);if(c!==void 0)return c;let p=w.parentNode,b=null;if(p&&p.nodeType===11){let S=h(p),C=S?r(S):null;C&&(b=C.concat(["content",l(p,w)]))}else if(p){let S=r(p);S&&(b=S.concat([l(p,w)]))}return n.set(w,b),b};return{root:e,pathOf:r,logicalParent:w=>{let c=w.parentNode;return c&&c.nodeType===11?h(c):c},indexIn:l,containerPath:w=>{if(w.nodeType===11){let p=h(w),b=r(p);return b?b.concat(["content"]):null}let c=r(w);return c&&Xo(w)?c.concat(["content"]):c},ownerOf:h}}var Cn=e=>Xo(e)?e.content:e;function Or(e){let{L:o,R:t,unitsOf:n,provenance:s,policy:h}=e,l=[];return{note:(w,c)=>{l.push([w,c])},finish:w=>l.length?u(w):null};function u(w){let c={base:to(e.roots.base),local:to(e.roots.local),remote:to(e.roots.remote)},p=$=>$==="local"?o:t,b=($,a)=>{if(!a)return null;if($.map.has(a))return $.map.get(a);let O=[],R=dn(a)?c.base.logicalParent(a):a.parent;for(;R&&!$.map.has(R);R=c.base.logicalParent(R))O.push(R);if(!R||!$.identical.has(R))return null;let K=$.map.get(R);for(let Z=O.length-1;Z>=0&&K;Z--)K=Cn(K).childNodes[c.base.indexIn(O[Z].parentNode,O[Z])];return K?dn(a)?Cn(K).childNodes[c.base.indexIn(a.parentNode,a)]||null:n(K)[n(a.parent).indexOf(a)]||null:null},S=new Map,C=new Map,m=new WeakMap,f=0,g=($,a)=>{let O=S.get($);O||S.set($,O=[]),O.push(a)};(function $(a){C.set(a,f++);let O=s.get(a);if(O&&!O.pinned){for(let R of[O.base,O.local,O.remote])if(R)if(Array.isArray(R))for(let K of R)g(K,a);else g(R,a)}if(Xo(a)){m.set(a.content,a);for(let R=a.content.firstChild;R;R=R.nextSibling)$(R)}for(let R=a.firstChild;R;R=R.nextSibling)$(R)})(w);let I=new Map;c.out=to(w,m,I);let v={refs:new Map,spans:new Map,anchors:new Map,via:I,outOwners:m,outRoot:w,localRoot:e.roots.local},T=$=>dn($)?[$]:$.nodes,A=($,a)=>{let O=c[a].logicalParent($);if(!O)return null;for(let R of n(O))if(!dn(R)&&R.nodes.includes($))return R;return null},E=($,a)=>$==null?null:Array.isArray($)?$.length?A($[0],a):null:$,N=$=>{let a=new Set,O=[];for(let R of $)for(let K of S.get(R)||[])a.has(K)||(a.add(K),O.push(K));return O.sort((R,K)=>C.get(R)-C.get(K))},M=new Map,P=$=>{let a=$.b||$.l||$.r,O=M.get(a);if(O)return O;let R=[];for(let K of[$.b,$.l,$.r])K&&R.push(...T(K));return O=N(R),M.set(a,O),O},V=$=>({b:$,l:b(o,$),r:b(t,$)}),D=($,a)=>{let O=p(a).reverse.get($);if(O)return V(O);for(let R of N(T($))){let K=s.get(R);if(K&&!K.base&&K.local&&K.remote)return{b:null,l:E(K.local,"local"),r:E(K.remote,"remote")}}return a==="local"?{b:null,l:$,r:null}:{b:null,l:null,r:$}},j=new Map,y=$=>{let a=s.get($);if(!a||a.pinned)return null;let O=E(a.base,"base");if(O)return V(O);let R=E(a.local,"local"),K=E(a.remote,"remote");if(R){let Z=o.reverse.get(R);if(Z)return V(Z)}if(K){let Z=t.reverse.get(K);if(Z)return V(Z)}return R||K?{b:null,l:R,r:K}:null},k=$=>(j.has($)||j.set($,y($)),j.get($)),J=($,a)=>dn($)?c[a].logicalParent($):$.parent,H=new Map,q=new Map,Me=($,a)=>(dn($)?[c[a].pathOf($)]:$.nodes.map(O=>c[a].pathOf(O))).filter(Boolean),Oe=$=>{let a=$.b||$.l||$.r,O=$.b?"base":$.l?"local":"remote",R=q.get(a);if(R)return R;let K=!dn(a),Z=Me(a,O)[0],U=`${O[0]}:${JSON.stringify(Z===void 0?null:Z)}${K?":run":""}`,de=H.get(U);if(de)return q.set(a,de),de;let we=P($);return de={key:U,nodeType:dn(a)?1:a.kind==="comment"?8:3,base:$.b?Me($.b,"base"):[],local:$.l?Me($.l,"local"):[],remote:$.r?Me($.r,"remote"):[],merged:we.map(le=>c.out.pathOf(le)).filter(Boolean),live:[]},H.set(U,de),q.set(a,de),v.refs.set(de,we),de},Re={base:new Map,local:new Map,remote:new Map},ie=new Map,xe=($,a)=>{let O=J($,a);if(!O||O.nodeType!==1)return null;let R=Re[a].get(O);if(!R){let Z=n(O),U=de=>Oe(a==="base"?V(de):D(de,a));R={parent:U(O),refs:Z.map(U),index:new Map(Z.map((de,we)=>[de,we]))},Re[a].set(O,R)}let K=R.index.get($)??-1;return{parent:R.parent,before:R.refs.slice(K+1),after:R.refs.slice(0,Math.max(0,K)).reverse()}},qe=$=>{let a=$.parentNode;if(!a)return null;let O=ie.get(a);if(!O){let K=a.nodeType===11?m.get(a):a,Z=K&&K.nodeType===1?k(K):null;if(!Z)return null;let U=[],de=[],we=new Map;for(let Ae of a.childNodes){let W=k(Ae),X=W&&Oe(W),pe=U.length,be=U.length-1;X&&X!==U[be]&&(U.push(X),be++);let he={ref:X,group:be,after:pe};de.push(he),we.set(Ae,he)}let le=U.length;for(let Ae=de.length-1;Ae>=0;Ae--){let W=de[Ae];W.before=le,W.ref&&(le=W.group)}O={parent:Oe(Z),refs:U,index:we},ie.set(a,O)}let R=O.index.get($);return{parent:O.parent,before:O.refs.slice(R.before),after:O.refs.slice(0,R.after).reverse()}},fe=$=>dn($)?$.outerHTML:$.value,x=$=>dn($)?"element":$.kind==="comment"?"comment":"text",Y=($,a)=>({path:$,offset:a}),ae=($,a,O)=>{if(!$)return null;let R=c[O],K=0;if(a){let Z=dn(a)?a:a.nodes[a.nodes.length-1];Z.parentNode&&(K=R.indexIn(Z.parentNode,Z)+1)}return Y(R.containerPath($),K)},oe=($,a)=>{let O=J($,"base"),R=O?b(p(a),O):null;if(!dn(R))return null;let K=n(O),Z=null;for(let U=K.indexOf($)-1;U>=0&&!Z;U--){let de=b(p(a),K[U]);de&&J(de,a)===R&&(Z=de)}return ae(R,Z,a)},Ee=($,a,O,R)=>{let K=c[R],Z=0;for(let U=0;U<$.nodes.length;U++){let de=$.nodes[U],we=de.nodeValue.length,le=U===$.nodes.length-1;if((O==="start"?a<Z+we:a<=Z+we)||le)return Y(K.pathOf(de),Math.max(0,Math.min(a-Z,we)));Z+=we}return null},De=($,a)=>{let O=c[a],R=$.firstChild,K=$.lastChild;return R&&R.nodeType===3&&K.nodeType===3?{start:Y(O.pathOf(R),0),end:Y(O.pathOf(K),K.nodeValue.length)}:{start:Y(O.pathOf($),0),end:Y(O.pathOf($),$.childNodes.length)}},Ne=($,a,O)=>{for(let U of $.nodes)if(O==="start"?U.s<=a&&a<U.e:U.s<a&&a<=U.e)return{kind:"text",node:U.node,offset:a-U.s};let R=O==="start"?a:a-1,K=()=>{for(let U of $.nodes)if(U.s===a||U.e===a)return{kind:"text",node:U.node,offset:a-U.s};return null},Z=$.atomAt.get(R);if(Z)return{kind:O==="start"?"before":"after",node:Z.el};if($.text[R]===kt){let U=$.marks.find(we=>we.block&&we.to===R+1);if(U)return O==="start"?{kind:"end",node:U.el}:{kind:"after",node:U.el};let de=$.marks.find(we=>we.block&&we.from===R+1);if(de)return O==="start"?{kind:"before",node:de.el}:{kind:"startOf",node:de.el}}return K()},nt=($,a)=>Ne($,a,"end")||Ne($,a,"start"),Xe=($,a)=>{switch(a.kind){case"text":return Y($.pathOf(a.node),a.offset);case"end":return Y($.containerPath(a.node),Cn(a.node).childNodes.length);case"startOf":return Y($.containerPath(a.node),0);default:{let O=a.node.parentNode;return Y($.containerPath(O),$.indexIn(O,a.node)+(a.kind==="after"?1:0))}}},ht=($,a,O,R,K)=>{let Z=Ne($,a,O);return Z?Xe(c[R],Z):K()},Ge=($,a,O,R)=>{let K=$.textNodes.map(le=>({s:le.ms,e:le.me,start:{kind:"text",node:le.node,offset:0},end:{kind:"text",node:le.node,offset:le.me-le.ms}}));for(let[le,Ae]of $.atomOut)K.push({s:le,e:le+1,start:{kind:"before",node:Ae},end:{kind:"after",node:Ae}});for(let[le,Ae]of $.breakOut)K.push({s:le,e:le+1,start:{kind:"end",node:Ae},end:{kind:"after",node:Ae}});for(let le of K)if(le.start.kind==="text"&&le.s<a&&a<le.e)return{kind:"text",node:le.start.node,offset:a-le.s};if(O!=="empty"){let le=K.find(Ae=>O==="start"?Ae.s===a:Ae.e===a);if(le)return O==="start"?le.start:le.end}let Z=K.find(le=>le.e===a);if(Z)return Z.end;let U=K.find(le=>le.s===a);if(U)return U.start;let de=null,we=null;for(let le of K)le.e<=a&&(!de||le.e>de.e)&&(de=le),le.s>=a&&(!we||le.s<we.s)&&(we=le);return de?de.end:we?we.start:R()},rt=($,a)=>{if(!a)return null;if(a.kind==="text"){let K=$.nodes.find(Z=>Z.node===a.node);return K?K.s+Math.min(a.offset,K.e-K.s):null}let O=$.atoms.find(K=>K.el===a.node);if(O)return a.kind==="after"?O.i+1:O.i;let R=$.marks.find(K=>K.el===a.node);return R?a.kind==="before"&&R.block&&$.text[R.from-1]===kt&&!$.marks.some(K=>K.block&&K.to===R.from)?R.from-1:a.kind==="startOf"||a.kind==="before"?R.from:a.kind==="end"&&R.block?R.to-1:R.to:null},Ot=($,a,O,R)=>{for(let de of $.nodes)if(O==="start"?de.s<=a&&a<de.e:de.s<a&&a<=de.e)return{kind:"text",node:de.node,offset:a-de.s};let K=O==="start"?a:a-1;if(!$.atomAt.has(K)&&$.text[K]!==kt){for(let de of $.nodes)if(de.s===a||de.e===a)return{kind:"text",node:de.node,offset:a-de.s}}let Z=$.atomAt.get(K);if(Z)return{kind:O==="start"?"before":"after",node:Z.el};if($.text[K]===kt){let de=$.marks.find(le=>le.block&&le.to===K+1);if(de)return O==="start"?{kind:"end",node:de.el}:{kind:"after",node:de.el};let we=$.marks.find(le=>le.block&&le.from===K+1);if(we)return O==="start"?{kind:"before",node:we.el}:{kind:"startOf",node:we.el}}let U=$.marks.find(de=>de.block&&de.from===a);return U?{kind:"startOf",node:U.el}:R?{kind:O==="start"?"startOf":"end",node:R}:null},Ct=$=>{if(!$)return null;if($.kind==="wholeStart"||$.kind==="wholeEnd"){let a=wt($.node);return $.kind==="wholeStart"?a.start:a.end}return Xe(c.out,$)},wt=$=>{let a=$.firstChild,O=$.lastChild;return a&&a.nodeType===3&&O.nodeType===3?{start:Y(c.out.pathOf(a),0),end:Y(c.out.pathOf(O),O.nodeValue.length)}:{start:Y(c.out.pathOf($),0),end:Y(c.out.pathOf($),$.childNodes.length)}},Nt=$=>{let a=J($,"base"),O=a?P(V(a))[0]:null;if(!O)return null;let R=Cn(O),K=n(a);for(let Z=K.indexOf($)-1;Z>=0;Z--){let U=P(V(K[Z])).filter(de=>de.parentNode===R);if(U.length)return{kind:"after",node:U[U.length-1]}}return{kind:"startOf",node:O}},Lt=($,a,O,R,K,Z)=>({text:$,start:a,end:O,fragment:R,span:K,scope:Z}),qt=($,a,O,R,K)=>Lt($,a,O,$.slice(a,O),R,K),cn=($,a,O,R,K)=>(v.spans.set($,{start:a,end:O,scopeStart:R,scopeEnd:K}),$),It=new Map,Gt=new Map,wn=($,a,O)=>{let R=`text:${$.key}:${a}:${O}`,K=Gt.get(R)||0;return Gt.set(R,K+1),`${R}:${K}`},Dt=($,a)=>{let O,R,K,Z="plain",U,de,we,le,Ae,W=(be,he,ee,te,z)=>{if(!be){let ne=oe(z,te);return qt("",0,0,{start:ne,end:ne},{start:ne,end:ne})}return qt(be.value,he,ee,{start:Ee(be,he,he===ee?"end":"start",te),end:Ee(be,ee,"end",te)},{start:Ee(be,0,"start",te),end:Ee(be,be.value.length,"end",te)})};if(a.site==="run"){let{bRun:be,lRun:he,rRun:ee,node:te,c:z}=a;O=V(be),R=z.bs,K=z.be,U=W(be,z.bs,z.be,"base",be),de=W(he,z.ls,z.le,"local",be),we=W(ee,z.rs,z.re,"remote",be);let ne=te?te.nodeValue:"",Te=Ce=>te?{kind:"text",node:te,offset:Ce}:Nt(be);le=cn(qt(ne,z.ms,z.me,{start:Ct(Te(z.ms)),end:Ct(Te(z.me))},{start:Ct(Te(0)),end:Ct(Te(ne.length))}),Te(z.ms),Te(z.me),Te(0),Te(ne.length)),Ae=te||(Nt(be)||{}).node||null}else if(a.site==="whole"){let be=a.el,he=s.get(be);O=V(he.base),R=0,K=$.base.length;let ee=(z,ne,Te)=>{let Ce=De(ne,Te);return qt(z,0,z.length,Ce,Ce)};U=ee($.base,he.base,"base"),de=ee($.local,he.local,"local"),we=ee($.remote,he.remote,"remote");let te=wt(be);le=cn(qt($.resolved,0,$.resolved.length,te,te),{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be},{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be}),Ae=be}else if(a.site==="comment"){let{bRun:be,lRun:he,rRun:ee,node:te}=a;O=V(be),R=0,K=$.base.length;let z=(Pe,ve)=>{if(!Pe){let Ze=oe(be,ve);return qt("",0,0,{start:Ze,end:Ze},{start:Ze,end:Ze})}let _e=Pe.nodes[0],Je={start:Y(c[ve].pathOf(_e),0),end:Y(c[ve].pathOf(_e),Pe.value.length)};return qt(Pe.value,0,Pe.value.length,Je,Je)};U=z(be,"base"),de=z(he,"local"),we=z(ee,"remote");let ne=$.resolved,Te=Pe=>te?{kind:"text",node:te,offset:Pe}:Nt(be),Ce={start:Ct(Te(0)),end:Ct(Te(ne.length))};le=cn(qt(ne,0,ne.length,Ce,Ce),Te(0),Te(ne.length),Te(0),Te(ne.length)),Ae=te||(Nt(be)||{}).node||null}else{let{fb:be,fl:he,fr:ee,scope:te}=a,z=a.merged;Z="html",O=te.base?V(te.base):D(te.local,"local"),R=$.bs,K=$.be;let ne=se=>{let Ie=te[se];for(let Be=te.at-1;Be>=0;Be--){let He=te.units[Be],Ke=se==="base"?He:b(p(se),He);if(Ke&&J(Ke,se)===Ie)return Ke}return null},Te=se=>()=>ae(te[se],ne(se),se),Ce=(se,Ie,Be,He,Ke)=>{let pt=bn=>bn?Xe(c[Ke],bn):Te(Ke)(),tt=Ie===Be?nt(se,Ie):Ne(se,Ie,"start"),Kt=Ie===Be?nt(se,Ie):Ne(se,Be,"end"),Ht=pt(tt),un={start:Ht,end:Ie===Be?Ht:pt(Kt)},bt=a.full?a.full(Ke):null;if(!bt)return Lt(se.text,Ie,Be,He,un,{start:pt(Ne(se,0,"start")),end:pt(Ne(se,se.text.length,"end"))});let lt=tt?rt(bt,tt):null,$e=Kt?rt(bt,Kt):null,vt=lt===null?0:lt,ct=Math.max(vt,$e===null?bt.text.length:$e),jt=pt(Ne(bt,0,"start"));return Lt(bt.text,vt,ct,co(bt,vt,ct),un,{start:jt,end:bt.text.length?pt(Ne(bt,bt.text.length,"end")):jt})};U=a.synthetic?null:Ce(be,$.bs,$.be,$.base,"base"),de=Ce(he,$.lss,$.lse,$.local,"local"),we=Ce(ee,$.rss,$.rse,$.remote,"remote");let[Pe,ve]=$.range||[0,0],_e=z.out,Je=()=>{let se=Cn(z.node);for(let Ie=te.at-1;Ie>=0;Ie--){let Be=P(V(te.units[Ie])).filter(He=>He.parentNode===se);if(Be.length)return{kind:"after",node:Be[Be.length-1]}}for(let Ie=te.at;Ie<te.units.length;Ie++){let Be=P(V(te.units[Ie])).filter(He=>He.parentNode===se);if(Be.length)return{kind:"before",node:Be[0]}}return{kind:"startOf",node:z.node}};if(_e.via)for(let[se,Ie]of _e.via)I.set(se,Ie);let Ze=Ge(z,Pe,Pe===ve?"empty":"start",Je),Ut=Pe===ve?Ze:Ge(z,ve,"end",Je),Pt=_e.text.length?Ot(_e,0,"start",z.node):Je(),L=_e.text.length?Ot(_e,_e.text.length,"end",z.node):Pt,G=rt(_e,Ze),re=rt(_e,Ut),ge=G===null?0:G,ye=Math.max(ge,re===null?_e.text.length:re);le=cn(Lt(_e.text,ge,ye,co(_e,ge,ye),{start:Ct(Ze),end:Ct(Ut)},{start:Ct(Pt),end:Ct(L)}),Ze,Ut,Pt,L);let ce=v.spans.get(le);if(ce.flat=_e,!_e.text.length){let se=Ct(Pt),Ie=Zn(w,se),Be=Ie[0],He=Ie[1];ce.empty={parent:Be.nodeType===11?m.get(Be):Be,previous:Be.childNodes[He-1]||null,next:Be.childNodes[He]||null}}Ae=Ze?Ze.node:z.node}let X=Oe(O),pe=(a.site==="whole"||a.site==="comment"||(a.policy||h)!=="both")&&$.resolved!==$.local;return{key:a.site==="comment"&&It.get(O.b||O.l||O.r)||wn(X,R,K),subject:X,localLost:pe,anchor:Ae,text:{encoding:Z,base:U,local:de,remote:we,merged:le,liveSpan:null,liveScope:null}}},rn=($,a)=>{let O=k(a.el),R=Oe(O),K=a.sample;return{key:`attr:${R.key}:${K.namespaceURI||""}:${K.localName}`,subject:R,localLost:$.resolved!==$.local,anchor:a.el,attribute:{namespaceURI:K.namespaceURI||null,localName:K.localName,qualifiedName:K.name}}},Yt=($,a)=>{let O=$.detail,R=a.unit||V(a.subject),K=Oe(R),Z=v.refs.get(K),U=R.l?xe(R.l,"local"):null,de=R.r?xe(R.r,"remote"):null,we=Z.length?qe(Z[0]):null,le,Ae,W,X=null,pe=null,be=a.deleted;switch(O){case"both-reordered":{le=Ae="reordered";let he=new Set(a.rKept),ee=a.lKept.filter(Ce=>he.has(Ce)&&P(V(Ce)).length),te=Ce=>C.get(P(V(Ce))[0]);X=ee.map(Ce=>Oe(V(Ce))),pe=ee.slice().sort((Ce,Pe)=>te(Ce)-te(Pe)).map(Ce=>Oe(V(Ce)));let z=Ce=>!dn(Ce)&&Ce.kind!=="comment"&&Ce.nodes.every(Pe=>!/[^\t\n\f\r ]/.test(Pe.data)),ne=ee.filter(Ce=>!z(Ce)),Te=ne.slice().sort((Ce,Pe)=>te(Ce)-te(Pe));W=ne.some((Ce,Pe)=>Ce!==Te[Pe]);break}case"both-moved":le=Ae="moved",W=!U||!Z.some(he=>{let ee=he===Z[0]?we:qe(he);return ee&&ee.parent===U.parent});break;case"edit-beats-delete":le=be==="local"?"deleted":"edited",Ae=be==="remote"?"deleted":"edited",W=be==="local";break;case"move-beats-delete":le=be==="local"?"deleted":"moved",Ae=be==="remote"?"deleted":"moved",W=be==="local";break;case"remote-wins":le="edited",Ae="edited",W=!0;break;default:le=Ae="inserted",W=a.localLost}return{key:`structure:${K.key}:${O}`,subject:K,localLost:W,anchor:Z[0]||null,structure:{localAction:le,remoteAction:Ae,localPlacement:U,remotePlacement:de,mergedPlacement:we,localOrder:X,mergedOrder:pe,localFragment:O==="both-reordered"||!R.l?null:fe(R.l),fragmentKind:x(R.b||R.l||R.r)}}};for(let[$,a]of l){if($.kind!=="structure")continue;let O=a.unit||V(a.subject),R=O.b||O.l||O.r;!dn(R)&&R.kind==="comment"&&It.set(R,`structure:${Oe(O).key}:${$.detail}`)}let fn=new Map;for(let[$,a]of l){if($.kind==="structure"){let Z=Oe(a.unit||V(a.subject)),U=`structure:${Z.key}:${$.detail}`,de=fn.get(U);if(de&&de.structure){$.recovery=de;let we=v.refs.get(Z);$.el==null&&we.length&&($.el=dn(we[0])?we[0]:c.out.logicalParent(we[0]));continue}}let O=$.kind==="text"?Dt($,a):$.kind==="attr"?rn($,a):Yt($,a),R=fn.get(O.key);R||(R={version:cl,key:O.key,localLost:O.localLost,subject:O.subject,applied:!1,unavailable:null},fn.set(O.key,R),v.anchors.set(R,O.anchor)),O.text&&(R.text=O.text),O.attribute&&(R.attribute=O.attribute),O.structure&&(R.structure=O.structure),O.text&&(R.localLost=O.localLost),$.recovery=R;let K=v.refs.get(O.subject);$.kind==="structure"&&$.el==null&&K.length&&($.el=dn(K[0])?K[0]:c.out.logicalParent(K[0])),$.kind==="text"&&$.node==null&&K.length&&O.subject.nodeType===8&&($.node=K[0])}return v}}function Ir(e,o,t){if(!o)return;let{lookup:n,vetoed:s,vetoedAttrs:h,liveAttr:l}=t,r=t.ignored||(()=>!1),i=to(t.liveRoot),u=y=>!!y&&i.containerPath(y)!==null,w=y=>{let k=y.parentNode;return k&&k.nodeType===11?o.outOwners.get(k)||null:k},c=y=>{for(let k=y;k;k=w(k))if(o.via.has(k)&&(k=o.via.get(k)),s.has(k)||t.vetoedLive?.has(f(k)))return!0;return!1},p=y=>Array.from(Cn(y).children).filter(k=>!r(k)),b=(y,k)=>p(y)[p(k.parentNode).indexOf(k)],S=(y,k)=>{let J=null,H=null,q=0;for(let ie=k.previousSibling;ie;ie=ie.previousSibling){if(ie.nodeType===1&&!r(ie)){J=ie;break}ie.nodeType===3&&(q+=ie.nodeValue.length)}for(let ie=k.nextSibling;ie&&!H;ie=ie.nextSibling)ie.nodeType===1&&!r(ie)&&(H=ie);let Me=J?b(y,J):null,Oe=H?b(y,H):null;if(J&&!Me||H&&!Oe)return null;let Re=[];for(let ie=Me?Me.nextSibling:Cn(y).firstChild;ie&&ie!==Oe;ie=ie.nextSibling)ie.nodeType===3&&Re.push(ie);return Re.length?{nodes:Re,lead:q}:null},C=y=>{let k=[],J=y;for(;J&&!o.via.has(J);J=J.parentNode)k.push(J);if(!J||!k.length)return null;let H=f(o.via.get(J));for(let Oe=k.length-1;Oe>0&&H;Oe--)H=b(H,k[Oe]);if(!H)return null;let q=k[0];if(q.nodeType===3)return S(H,q);let Me=q.nodeType===1?b(H,q):null;return Me?{nodes:[Me],lead:0}:null},m=y=>{let k=n(y),J=k?{nodes:Array.isArray(k)?k:[k],lead:0}:o.via.size?C(y):null;if(!J)return null;let H=J.nodes.filter(u);return H.length?{nodes:H,lead:J.lead}:null},f=y=>{let k=m(y);return k?k.nodes[0]:null},g=y=>{if(!y)return null;if(y.kind==="text"){let q=m(y.node);if(!q)return null;let Me=q.nodes,Oe=y.offset+q.lead,Re=0;for(let ie=0;ie<Me.length;ie++){let xe=Me[ie].nodeValue.length;if(Oe<=Re+xe||ie===Me.length-1)return Oe>=Re&&Oe<=Re+xe?[Me[ie],Oe-Re]:null;Re+=xe}return null}let k=f(y.node);if(!k)return null;if(y.kind==="end")return[Cn(k),Cn(k).childNodes.length];if(y.kind==="startOf")return[Cn(k),0];if(y.kind==="wholeStart")return k.firstChild?[k.firstChild,0]:[k,0];if(y.kind==="wholeEnd")return k.lastChild?[k.lastChild,k.lastChild.nodeValue.length]:[k,k.childNodes.length];let J=k.parentNode;if(!J)return null;let H=Array.prototype.indexOf.call(J.childNodes,k);return[J,y.kind==="after"?H+1:H]},I=y=>({blocks:new Set((y.flat?.marks||[]).filter(k=>k.block).map(k=>f(k.el)).filter(Boolean)),atoms:new Set((y.flat?.atoms||[]).map(k=>f(k.el)).filter(Boolean)),ignored:r}),v=(y,k,J,H)=>{if(!y||!k||!eo(y)||!eo(k))return!1;for(let Oe of[y,k])if(!u(Oe.startContainer)||!u(Oe.endContainer))return!1;let q=J.merged;if(q.start===q.end&&(y.startContainer!==y.endContainer||y.startOffset!==y.endOffset))return!1;let Me=I(H);return Xn(k,J.encoding,Me)===q.text&&Xn(y,J.encoding,Me)===q.text.slice(q.start,q.end)},T=new Map,A=y=>{let k=y.parentNode;return k?(T.has(k)||T.set(k,new Map(Array.from(k.childNodes,(J,H)=>[J,H]))),T.get(k).get(y)):-1},E=(y,k)=>{if(!k)return!1;let J=i.logicalParent(y);if(!k.parent.live.includes(J))return!1;let H=A(y);for(let[q,Me]of[["before",1],["after",-1]]){let Oe=H;for(let Re of k[q]){if(Re.live.includes(y))continue;let ie=Re.live.filter(qe=>qe!==y&&qe.parentNode===y.parentNode);if(!ie.length)continue;let xe=Me===1?Math.min(...ie.map(A)):Math.max(...ie.map(A));if(Me*(xe-Oe)<=0)return!1;Oe=xe}}return!0},N=y=>{let k=y.structure;if(k.mergedOrder){let J=new Set(y.subject.live.map(Cn)),H=null,q=-1;for(let Me of k.mergedOrder){let Oe=Me.live.find(Re=>J.has(Re.parentNode));if(!Oe||H&&Oe.parentNode!==H||A(Oe)<=q)return!1;H=Oe.parentNode,q=A(Oe)}return y.subject.live.length>0}return y.subject.live.some(J=>E(J,k.mergedPlacement))},M=(y,k)=>{let J=g(y),H=g(k);return J&&H?{startContainer:J[0],startOffset:J[1],endContainer:H[0],endOffset:H[1]}:null},P=new Set,V=y=>{if(!y||P.has(y))return;P.add(y);let k=[];for(let J of o.refs.get(y)||[]){let H=m(J);if(H)for(let q of H.nodes)k.includes(q)||k.push(q)}y.live=k},D=y=>{y&&(V(y.parent),y.before.forEach(V),y.after.forEach(V))},j=new Set;for(let y of e){let k=y.recovery;if(!k||j.has(k))continue;j.add(k),V(k.subject),k.structure&&(D(k.structure.localPlacement),D(k.structure.remotePlacement),D(k.structure.mergedPlacement),(k.structure.localOrder||[]).forEach(V),(k.structure.mergedOrder||[]).forEach(V));let J=o.anchors.get(k),H=J?f(J):null,q=!!H;if(k.text){let x=o.spans.get(k.text.merged),Y=x?M(x.start,x.end):null,ae=x?M(x.scopeStart,x.scopeEnd):null;if(x?.empty){let oe=x.empty,Ee=oe.previous?{kind:"after",node:oe.previous}:{kind:"startOf",node:oe.parent},De=oe.next?{kind:"before",node:oe.next}:{kind:"end",node:oe.parent},Ne=M(Ee,De);!Ne||Ne.startContainer!==Ne.endContainer||Ne.startOffset!==Ne.endOffset?Y=null:Y=ae=Ne}v(Y,ae,k.text,x)||(Y=ae=null),k.text.liveSpan=Y,k.text.liveScope=Y?ae:null,Y||(q=!1)}k.structure&&q&&(q=N(k)),k.attribute&&q&&(q=l(H,k.attribute,y.resolved));let Me=(!!k.attribute||!!k.text&&H?.tagName==="TEXTAREA")&&!!h&&[J,H].some(x=>h.get(x)?.has(k.attribute?k.attribute.qualifiedName:"value")),Oe=o.localState?.states.get(k),Re=!!k.text&&[...t.removedVetoes||[]].some(x=>Oe?.touched.has(x)),ie=k.structure?.localAction==="inserted"&&[...s].some(x=>x===J||J?.contains(x)),xe=J&&c(J)||Me||Re||ie,qe=xe&&Mr(k,y,o,u);qe&&(Re||ie&&k.localLost)&&(q=!1);let fe=!q&&qe&&xe;k.applied=q,k.unavailable=q?null:fe?"hook-veto":"missing-output",fe&&(k.localLost=!1),!q&&k.text&&(k.text.liveSpan=k.text.liveScope=null)}}function Jo(e,o,t){let n=to(o),s=to(t),h=c=>!!c&&s.containerPath(c)!==null,l=c=>{if(c===o)return t;let p=n.pathOf(c);if(p&&o!==t){let b=Zn(t,{path:p,offset:0});if(b&&b[0].nodeType===c.nodeType)return b[0]}return c},r=new Set,i=c=>{!c||r.has(c)||(r.add(c),c.live=c.live.map(l).filter(h))},u=c=>{c&&(c.startContainer=l(c.startContainer),c.endContainer=l(c.endContainer))},w=new Set;for(let c of e){c.node===o&&t.tagName==="SCRIPT"&&(c.node=t),c.el===o&&c.kind==="structure"&&(c.el=t);let p=c.recovery;if(!p||w.has(p))continue;if(w.add(p),i(p.subject),p.text){u(p.text.liveSpan),u(p.text.liveScope);let S=p.text.liveSpan,C=p.text.liveScope,m=p.text.merged,f=g=>!!g&&eo(g)&&h(g.startContainer)&&h(g.endContainer);(!f(S)||!f(C)||Xn(C,p.text.encoding)!==m.text||Xn(S,p.text.encoding)!==m.text.slice(m.start,m.end))&&(p.text.liveSpan=null,p.text.liveScope=null,p.applied=!1,p.unavailable="missing-output")}let b=p.structure;if(b){for(let S of[b.localPlacement,b.remotePlacement,b.mergedPlacement])S&&(i(S.parent),S.before.forEach(i),S.after.forEach(i));(b.localOrder||[]).forEach(i),(b.mergedOrder||[]).forEach(i),p.subject.live.length||(p.applied=!1,p.unavailable="missing-output")}}}var mo=e=>e?.nodeType===1,Io=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function fl({provenance:e,parentOf:o,twins:t,baseOf:n,build:s,ignored:h,remoteWins:l,discarded:r}){let i=new Map,u=new WeakMap;function w(b,S,C,m=!1){if(!mo(b)||!mo(C))return null;let f=i.get(b);if(f)(m||!f.selected&&S==="remote")&&(f.parent=o(C),f.port=C,f.sourceSide=S,f.selected=m);else{let g=u.get(b)||null;f={owner:b,parent:o(C),port:C,sourceSide:S,originalParent:o(b),originalPort:b,selected:m,state:g?"built":"planned",output:g,disposition:null},i.set(b,f)}return f}function c(b,S){if(!mo(b)||!mo(S))return;u.has(b)||u.set(b,S);let C=i.get(b);C&&C.state!=="attached"&&!C.output&&(C.output=S,C.state="built")}function p(b){if(!i.size)return;let S=new Map,C=new WeakMap,m=new WeakMap,f=new WeakSet,g=new Set,I=(D,j)=>{if(!D)return;if(Array.isArray(D)){for(let k of D)I(k,j);return}let y=S.get(D);y||S.set(D,y=[]),y.push(j)},v=(D,j)=>{if(!D)return;let y=[D];for(;y.length;){let k=y.pop();I(k,j);for(let J of Io(k).childNodes)y.push(J)}};function T(D,j=null,y=!1){if(f.has(D))return;f.add(D),C.set(D,j);let k=e.get(D),J=y||!!(k&&l(k.remote||k.base));m.set(D,J);let H={node:D,kind:"node",authority:J};if(k?.pinned)v(k.local,{...H,kind:"ignored"});else if(k?.unchanged)for(let q of[k.base,k.local,k.remote])v(q,{...H,kind:"unchanged"});else if(k){for(let q of[k.base,k.local,k.remote])I(q,H);if(mo(k.local))for(let q of Io(k.local).children)h(q)&&v(q,{...H,kind:"ignored"})}for(let q of Io(D).childNodes)T(q,D,J)}let A=D=>{if(D.output&&f.has(D.output))return D.state="attached",D.disposition="node",!0;let{local:j,remote:y}=t(D.owner);for(let k of[D.owner,j,y]){let J=S.get(k);if(J?.length){let H=J.find(q=>q.kind==="node")||J[0];return D.output=H.node,D.state="attached",D.disposition=H.kind,!0}}return!1},E=(D,j)=>(S.get(D)||[]).find(k=>k.kind==="node"&&mo(k.node)&&(!k.authority||j.sourceSide==="remote"))?.node,N=(D,j,y)=>{let k=S.get(D)||[],J=y?[...k].reverse():k;for(let H of J){if(H.kind!=="node")continue;let q=H.node;for(;q&&C.get(q)!==j;)q=C.get(q);if(q)return q}return null},M=(D,j,y)=>{let k=Io(j);for(let J=y?.previousSibling;J;J=J.previousSibling){let H=N(J,j,!0);if(H){k.insertBefore(D,H.nextSibling);return}}for(let J=y?.nextSibling;J;J=J.nextSibling){let H=N(J,j,!1);if(H){k.insertBefore(D,H);return}}k.appendChild(D)};function P(D,j,y){let k=j==="base"?D:n(D,j),J=i.get(k);J&&J!==y&&V(J)}function V(D){if(D.state==="attached"||D.disposition==="remote-wins"||g.has(D)||A(D))return;g.add(D);let{local:j,remote:y}=t(D.owner);if(l(y||D.owner)){if(!y){D.disposition="remote-wins",r(D.owner,j),g.delete(D);return}D.parent=o(y),D.port=y,D.sourceSide="remote"}if(P(D.parent,D.sourceSide,D),A(D)){g.delete(D);return}let k=E(D.parent,D),J=D.port;if(!k){if(P(D.originalParent,"base",D),A(D)){g.delete(D);return}let q=D.originalParent;for(J=D.originalPort;q&&!k;)k=E(q,D),k||(J=q,q=o(q))}if(!k)throw new Error("A planned move has no allowed surviving parent");let H=D.output||s(D.owner);D.output=H,D.state="built",M(H,k,J),T(H,k,m.get(k)||!1),A(D),g.delete(D)}T(b);for(let D of i.values())V(D)}return{planned:i,has:b=>i.has(b),plan:w,produced:c,drain:p}}function go(e,o,t,n,s,h,l,r,i,u,w,c,p){let b=null;return fl({provenance:e,parentOf:m=>{if(!m)return null;let f=o(m);if(f||m.parentNode?.nodeType!==11)return f;if(!b){b=new WeakMap;let g=[c,p];for(;g.length;){let I=g.pop(),v=Io(I);v!==I&&b.set(v,I);for(let T of v.children)g.push(T)}}return b.get(m.parentNode)||null},twins:m=>({local:s(t,m),remote:s(n,m)}),baseOf:(m,f)=>m&&(f==="local"?t:n).reverse.get(m)||null,build:m=>h(m,s(t,m),s(n,m),!1),ignored:l,remoteWins:r,discarded:(m,f)=>{f&&w(m,f,t)&&!i.some(g=>g.detail==="remote-wins"&&g.base===m)&&u({kind:"structure",el:null,detail:"remote-wins",base:m,local:f,remote:null},{subject:m})}})}function ul({parent:e,base:o,views:t,eligible:n,ignored:s,remoteWins:h,budget:l=$t(2e4*32),maxUnits:r=256,maxCharacters:i=2e4}){let u=(f,g=null)=>({status:f,reason:g,parent:e,records:[]});if(t.some(({V:f})=>f.asBase)||s(e)||h(e)||t.some(({V:f})=>!f.el||s(f.el)||h(f.el)))return u("none");let w=o.length+t[0].V.units.length+t[1].V.units.length;if(w>r)return u("fallback","unit-limit");let c=Symbol(),p=f=>{if(f>l.remaining)throw c;l.remaining-=f,l.crossParentSteps=(l.crossParentSteps||0)+f},b=new Map,S=0,C=f=>{if(p(1),b.has(f))return b.get(f);let g=f.nodeType===1?f.childNodes:f.nodes;p(g.length*4+1);let I=f.nodeType===1?Array.from(g):g,v=0;for(let E=0;E<I.length;E++){let N=I[E];if(N.nodeType!==3||E&&I[E-1].nextSibling!==N)return b.set(f,null),null;v+=N.data.length}if(v>i-S)throw c;p(v*8+1),S+=v;let T=nn(I);if(T.text.includes(kt))return b.set(f,null),null;let A={unit:f,nodes:I,flat:T};return b.set(f,A),A},m=[];try{p(w*8+1);for(let f=0;f<2;f++){let g=t[f].V,I=t[1-f].V,v=[],T=new Map;for(let A=0;A<o.length;A++){p(1);let E=o[A];if(E.kind!=="text"||g.twin(E))continue;let N=I.twin(E);if(!N||N.kind!=="text"||!I.here(N))continue;let M=C(E),P=C(N);if(!M||!P||!/\S/.test(M.flat.text))continue;p(M.flat.text.length*2+1);let V=M.flat.text;T.set(V,(T.get(V)||0)+1),v.push({source:E,opposite:N,sourceModel:M,oppositeModel:P,index:A})}for(let A of v){let{source:E,opposite:N,sourceModel:M,oppositeModel:P,index:V}=A,D=[];for(let Y of[-1,1]){p(1);let ae=o[V+Y];if(!ae||ae.nodeType!==1||!n(ae)||s(ae)||h(ae))continue;let oe=M.nodes[0],Ee=M.nodes.at(-1);if(Y===-1?oe?.previousSibling!==ae:Ee?.nextSibling!==ae)continue;let De=g.twin(ae),Ne=I.twin(ae);if(!De||!Ne||!g.here(De)||I.here(Ne)||g.baseOf(De)!==ae||I.baseOf(Ne)!==ae||!n(De)||!n(Ne)||s(De)||s(Ne)||h(De)||h(Ne)||De.tagName!==ae.tagName||Ne.tagName!==ae.tagName||De.namespaceURI!==ae.namespaceURI||Ne.namespaceURI!==ae.namespaceURI)continue;let nt=C(ae),Xe=C(De),ht=C(Ne);if(!nt||!Xe||!ht||!/\S/.test(nt.flat.text))continue;let Ge=nt.flat.text,rt=M.flat.text,Ot=Xe.flat.text;if(p((Ge.length+rt.length+Ot.length)*3+1),Ot.length!==Ge.length+rt.length)continue;let Ct=Y===-1;(Ct?!Ot.startsWith(Ge)||!Ot.endsWith(rt):!Ot.startsWith(rt)||!Ot.endsWith(Ge))||D.push({owner:ae,target:De,moved:Ne,ownerBase:nt,joined:Xe,ownerOther:ht,targetFrom:Ct?Ge.length:0,retainedFrom:Ct?0:rt.length})}if(!D.length)continue;if(D.length!==1||T.get(M.flat.text)!==1)return u("fallback","ambiguous-origin");let j=D[0],{owner:y,target:k,moved:J,ownerBase:H,joined:q,ownerOther:Me,targetFrom:Oe,retainedFrom:Re}=j;if(p(m.length+1),m.some(Y=>Y.owner===y))return u("fallback","ambiguous-owner");let ie={source:E,target:k,from:0,to:M.flat.text.length,targetFrom:Oe},xe=Dn({base:M.flat,side:q.flat,retained:[],transfers:[{from:ie.from,to:ie.to,target:Oe,destination:y}],budget:l});if(xe.status!=="ready"||xe.covers(ie.from,ie.to)!==!0)return u("fallback",xe.reason||"work-limit");let qe=[{unit:E,model:M,from:0,to:M.flat.text.length},null,null];qe[f+1]={unit:k,model:q,from:Oe,to:Oe+M.flat.text.length},qe[2-f]={unit:N,model:P,from:0,to:P.flat.text.length};let fe=[H,null,null];fe[f+1]=q,fe[2-f]=Me;let x=[y,null,null];x[f+1]=k,x[2-f]=J,m.push({side:f,parent:e,source:E,target:k,owner:y,owners:x,ownerModels:fe,native:qe,models:b,runs:[ie],proof:xe,retained:[{source:y,target:k,from:0,to:H.flat.text.length,targetFrom:Re}]})}}return m.length?{status:"ready",reason:null,parent:e,records:m}:u("none")}catch(f){if(f!==c)throw f;return u("fallback","work-limit")}}function Cr({describe:e,parentOf:o,...t}){let n=new WeakMap,s=new WeakMap,h=t.budget||$t(2e4*32),l=r=>{if(!r)return null;if(n.has(r))return n.get(r);n.set(r,{status:"planning",parent:r,records:[]});let i=e(r),u=i?ul({...t,...i,parent:r,budget:h}):{status:"none",reason:null,parent:r,records:[]};if(n.set(r,u),u.status==="ready")for(let w of u.records)s.set(w.owner,[w]);return u};return{get:l,forOwner(r){return l(o(r))?.status==="ready"&&s.get(r)||null}}}function dl(e,o){if(e.side!==0)return null;let t=e.native[0].model,n=e.ownerModels[0],s=e.native[1].from!==0,h=(I,v)=>s?[...I.nodes,...v.nodes]:[...v.nodes,...I.nodes],l=e.ownerModels.reduce((I,v)=>I+v.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(l*8>o.remaining)return null;o.remaining-=l*8;let r={base:h(n,t),local:e.ownerModels[1].nodes,remote:h(e.ownerModels[2],e.native[2].model)},i=nn(r.base),u=e.ownerModels[1].flat,w=nn(r.remote),c=s?n.flat.text.length:0,p=s?0:t.flat.text.length,b=Dn({base:i,side:u,retained:e.retained.map(I=>({from:p+I.from,to:p+I.to,target:I.targetFrom})),transfers:e.runs.map(I=>({from:c+I.from,to:c+I.to,target:I.targetFrom,destination:e.owner})),budget:o});if(b.status!=="ready"||b.covers(0,i.text.length)!==!0)return null;let S=e.ownerModels[2].flat,C=e.native[2].model.flat,m=[];for(let[I,v,T,A]of[[n.flat,S,p,s?0:C.text.length],[t.flat,C,c,s?S.text.length:0]]){let E=xs(I,I,v).remoteMap.bTo,N=-1;for(let M=0;M<I.text.length;M++){if(E[M]<0){N=-1;continue}let P=m.at(-1);N>=0&&P.to===T+M&&P.target+P.to-P.from===A+E[M]?P.to++:(m.push({from:T+M,to:T+M+1,target:A+E[M]}),N=M)}}let f=Dn({base:i,side:w,retained:m,transfers:[],budget:o});if(f.status!=="ready")return null;let g=xs(i,u,w,{},{local:b,remote:f});return g.localEdits.hunks.length?null:(g.localMap=b,g.remoteMap=f,{nodes:r,prepared:g})}function Lr({L:e,R:o,twinIn:t,unitsOf:n,view:s,parentOf:h,ignored:l,remoteWins:r,eligible:i,build:u,out:w,policy:c,provenance:p,textMappers:b,segments:S,conflicts:C,conflict:m,decisions:f}){let g=$t(2e4*32),I=D=>{let j=0;for(let y=D;y;y=h(y))if(++j>64||y.nodeType===1&&(l(y)||r(y)))return!1;return!0},v=Cr({parentOf:h,eligible:i,ignored:l,remoteWins:r,budget:g,describe(D){let j=t(e,D),y=t(o,D);return!j||!y||!I(D)||!I(j)||!I(y)?null:{base:n(D),views:[{A:e,V:s(e,j,D,!1)},{A:o,V:s(o,y,D,!1)}]}}}),T=new WeakSet,A=new WeakMap,E=new WeakSet,N=[];function M(D){if(!D||T.has(D))return;T.add(D);let j=v.get(D);if(j?.status==="ready")for(let y of j.records){if((D.tagName==="TEMPLATE"&&D.content?D.content:D).childNodes.length!==y.native[0].model.nodes.length+1||!y.owners.every(I))continue;let J=dl(y,g);if(!J)continue;let H={record:y,payload:J,state:"planned",output:null,result:null};A.set(y.owner,H),E.add(y.source),E.add(y.native[2].unit),N.push(H)}}function P(D,j){let y=A.get(D);if(!y)return!1;if(!y.result){if(y.result=Ko({...y.payload.nodes,prepared:y.payload.prepared,out:w,policy:c,provenance:p,textMappers:b,conflicts:C,conflict:m,decisions:f,node:j}),y.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");S.push(...y.result.segments),y.decision={kind:"text",node:j,source:"local"},f.push(y.decision)}return y.decision.node=j,j.replaceChildren(...y.result.nodes),y.output=j,y.state="built",!0}function V(D){if(!N.length)return;let j=new WeakSet,y=new WeakMap,k=new WeakMap,J=new WeakMap,H=xe=>xe.tagName==="TEMPLATE"&&xe.content?xe.content:xe,q=(xe,qe)=>{if(!xe)return;if(Array.isArray(xe)){for(let x of xe)q(x,qe);return}let fe=J.get(xe);fe||J.set(xe,fe=[]),fe.push(qe)},Me=(xe,qe=null,fe=!1)=>{j.add(xe),y.set(xe,qe);let x=p.get(xe),Y=fe||!!(x&&r(x.remote||x.base));if(k.set(xe,Y),x)for(let ae of[x.base,x.local,x.remote])q(ae,xe);if(!(x?.pinned||x?.unchanged))for(let ae of H(xe).childNodes)Me(ae,xe,Y)},Oe=xe=>(J.get(xe)||[]).find(qe=>qe.nodeType===1&&!k.get(qe)&&!p.get(qe)?.pinned&&!p.get(qe)?.unchanged),Re=(xe,qe)=>{for(let fe of J.get(xe)||[]){let x=fe;for(;x&&y.get(x)!==qe;)x=y.get(x);if(x)return x}return null},ie=(xe,qe,fe)=>{let x=H(qe);for(let Y=fe.nextSibling;Y;Y=Y.nextSibling){let ae=Re(Y,qe);if(ae){x.insertBefore(xe,ae);return}}for(let Y=fe.previousSibling;Y;Y=Y.previousSibling){let ae=Re(Y,qe);if(ae){x.insertBefore(xe,ae.nextSibling);return}}x.appendChild(xe)};Me(D);for(let xe of N){let{record:qe}=xe,fe=Oe(qe.owner)||Oe(qe.owners[1])||Oe(qe.owners[2]);if(fe)(!xe.result||xe.output!==fe||xe.result.nodes.some(x=>!j.has(x)||y.get(x)!==fe)||fe.textContent!==xe.result.text)&&(P(qe.owner,fe),Me(fe,y.get(fe),k.get(fe)));else{let x=qe.parent,Y=qe.owner,ae=null;for(;x&&!ae;)ae=Oe(x),ae||(Y=x,x=h(x));if(!ae)throw new Error("A cross-parent payload has no allowed surviving parent");fe=xe.output||u(qe.owner,qe.owners[1],qe.owners[2],!1),xe.result||P(qe.owner,fe),ie(fe,ae,Y),Me(fe,ae,k.get(ae))}xe.state="attached"}}return{ensureParent:M,ensureOwner(D){M(h(D))},consumes(D){return E.has(D)},render:P,drain:V}}var Mn=/\S/,Er=/[\p{L}\p{N}]/u;function no(e,o,t,n){if(e?.nodeType!==1||!o(e))return!1;for(let s=e.firstChild;s;s=s.nextSibling)if(n(t,1),s.nodeType!==3)return!1;return!!e.firstChild}function Is(e,o,t){for(let n=e.parentNode;n;n=n.parentNode)if(t(o,1),n.nodeType===11)return!1;return!0}function Rr(e,o,t,n,s){let h=t(e,n),l=t(o,n),r=null,i=null,u=null,w=null;s(n,h.length+l.length);for(let c of h)Er.test(c.raw)&&(r||=c,i=c);for(let c of l)Er.test(c.raw)&&(u||=c,w=c);return!!(r&&u&&(r.raw===u.raw||i.raw===w.raw))}function hl({base:e,V:o,A:t,source:n,original:s,current:h,edited:l,destination:r,at:i,ownLength:u,eligible:w,model:c,tokensOf:p,budget:b,charge:S}){let C=s.flat.text,m=h.flat.text,f=l.flat.text,g=r.flat.text;if(S(b,C.length+m.length+g.length),C.startsWith(m)||C.endsWith(m))return!1;let I=Mn.test(g.slice(0,i)),v=Mn.test(g.slice(i+u));if(I===v)return!1;let T=I?0:i+u,A=I?i:g.length;for(;T<A&&!Mn.test(g[T]);)T++;for(;A>T&&!Mn.test(g[A-1]);)A--;let E=g.slice(T,A);if(In(E,g,p(r,b),b,S,!0)!==T)return!1;let N=In(E,C,p(s,b),b,S,!0);if(N<0)return!1;let M=N+E.length,P=!Mn.test(C.slice(0,N)),V=!Mn.test(C.slice(M));if(P===V||In(E,m,p(h,b),b,S,!1)>=0)return!1;let D=P?C.slice(M):C.slice(0,N),j=P?f.length-D.length:0;if(S(b,C.length+f.length),j<0||!Mn.test(D)||In(D,f,p(l,b),b,S,!0)!==j||!Mn.test(P?f.slice(0,j):f.slice(D.length)))return!1;for(let y of e){if(S(b,1),y===n||!no(y,w,b,S))continue;let k=c(y,null,b);if(In(E,k.flat.text,p(k,b),b,S,!1)>=0)return!1}for(let y of o.units){if(S(b,1),y===h.unit||y===r.unit||!no(y,w,b,S))continue;let k=c(y,t,b);if(In(E,k.flat.text,p(k,b),b,S,!1)>=0)return!1}return!0}function Pr({base:e,views:o,side:t,attempt:n,eligible:s,blocked:h,baseId:l,model:r,tokensOf:i,charge:u,exhausted:w,limit:c}){if(c<=0)return null;let p=$t(c),{V:b,A:S,idOf:C}=o[t],m=o[1-t],[f,g,I,v]=n,T=null;try{for(let A=f;A<=g;A++){u(p,1);let E=e[A];if(E.parentNode?.nodeType!==1||h.has(E)||S.identical.has(E)||m.A.identical.has(E)||!no(E,s,p,u)||l(E))continue;let N=b.twin(E),M=m.V.twin(E);if(!N||!M||!b.here(N)||!m.V.here(M)||S.map.get(E)!==N||S.reverse.get(N)!==E||m.A.map.get(E)!==M||m.A.reverse.get(M)!==E||C(N)||m.idOf(M)||N.tagName!==E.tagName||M.tagName!==E.tagName||!no(N,s,p,u)||!no(M,s,p,u)||!Is(E,p,u)||!Is(N,p,u)||!Is(M,p,u))continue;let P=r(E,null,p),V=r(N,S,p),D=r(M,m.A,p),j=P.flat.text,y=V.flat.text,k=D.flat.text;if(u(p,j.length+y.length+k.length),!Mn.test(j)||!Mn.test(y)||!Mn.test(k)||j===y||j===k||y===k||!Rr(P,V,i,p,u)||!Rr(P,D,i,p,u))continue;let J=null,H=!1;for(let Oe=I;Oe<=v;Oe++){u(p,1);let Re=b.units[Oe],ie=b.baseOf(Re);if(!ie||ie===E||h.has(ie)||ie.parentNode!==E.parentNode||Re.parentNode!==N.parentNode||ie.tagName!==E.tagName||Re.tagName!==E.tagName||S.map.get(ie)!==Re||S.reverse.get(Re)!==ie||l(ie)!==C(Re)||!no(ie,s,p,u)||!no(Re,s,p,u))continue;let xe=r(ie,null,p),qe=r(Re,S,p),fe=xe.flat.text,x=qe.flat.text;if(u(p,fe.length),!Mn.test(fe)||x.length<=fe.length)continue;let Y=i(qe,p),ae=In(fe,x,Y,p,u,!0);if(!(ae<0||In(j,x,Y,p,u,!0,ae,ae+fe.length)<0&&!hl({base:e,V:b,A:S,source:E,original:P,current:V,edited:D,destination:qe,at:ae,ownLength:fe.length,eligible:s,model:r,tokensOf:i,budget:p,charge:u}))){if(J){H=!0;break}J=Re}}if(!J||H)continue;let q=t===0?N:M,Me=t===0?M:N;(T||=[]).push({source:E,local:q,remote:Me,models:[P,t===0?V:D,t===0?D:V]})}}catch(A){if(A!==w)throw A}return T}var Hn=/\S/,gn=/\s/,pl=/[\s\u001e]/g,Cs=/[^\s\p{P}\u001e\ufffc]/u;function ml(e,o,t,n,s,h,l){let r=0;for(let i of e)l(h,1),i.nodeType===1&&!n.baseOf(i)&&r++;if(r<2)return!1;for(let i of e){if(i.nodeType!==1||n.baseOf(i))continue;let u=s.get(i).flat;if(u.atoms.length||u.pins?.length)continue;l(h,u.text.length*2+o.length+t.length);let w=new Uint8Array(u.text.length);for(let c of t)c.target===i&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c of o)c.target===i&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c=0;c<u.text.length;c++)if(!w[c]&&Hn.test(u.text[c]))return!0}return!1}function gl(e,o,t){let{source:n,models:s,retained:h,runs:l}=e,r=s.get(n).flat.text;t(o,r.length*2+h.length+l.length);let i=new Uint8Array(r.length);for(let u of h)u.source===n&&(t(o,u.to-u.from),i.fill(1,u.from,u.to));for(let u of l)t(o,u.to-u.from),i.fill(1,u.from,u.to);for(let u=0;u<r.length;u++)if(!i[u]&&Hn.test(r[u]))return!1;return!0}function bl(e,o,t,n,s,h,l,r,i,u){let w=h.get(e),c=h.get(o),p=w.flat.text,b=l.get(e);i(u,p.length*2+t.length);let S=p.length,C=0;for(let g=0;g<p.length;g++)!gn.test(p[g])&&!b[g]&&(S=Math.min(S,g),C=g+1);if(S>=C)return null;for(let g=S;g<C;g++)if(!gn.test(p[g])&&b[g])return null;let m=-1;for(let g of t)if(g.target===o&&g.from<=S&&g.to>S){m=g.targetFrom+S-g.from;break}if(m<0)return null;let f=p.slice(S,C);if(i(u,f.length*(t.length+2)),c.flat.text.slice(m,m+f.length)!==f)return null;for(let g=S;g<C;g++){if(gn.test(p[g]))continue;let I=!1;for(let v of t)if(v.target===o&&v.from<=g&&v.to>g&&v.targetFrom+g-v.from===m+g-S){I=!0;break}if(!I)return null}if(w.flat.atoms.length||c.flat.atoms.length){i(u,w.flat.atoms.length+c.flat.atoms.length);let g=0,I=c.flat.atoms;for(;g<I.length&&I[g].i<m;)g++;for(let v of w.flat.atoms){if(v.i<S||v.i>=C)continue;let T=I[g++];if(!T||T.i!==m+v.i-S||c.alignment?.reverse.get(T.el)!==v.el)return null}if(g<I.length&&I[g].i<m+C-S)return null}for(let[g,I,v]of[[n,e,S],[s,o,m]]){let T=!1;for(let A of g){let E=h.get(A),N=l.get(A),M=r(E,u);for(let P=0;P<M.length;P++){let V=M[P].from,D=V+f.length;if(i(u,f.length*2+1),E.flat.text.slice(V,D)!==f)continue;let j=P;for(;j<M.length&&M[j].to<D;)i(u,1),j++;if(j===M.length||M[j].to!==D)continue;let y=!0;for(let k=V;k<D;k++)if(!gn.test(E.flat.text[k])&&N[k]){y=!1;break}if(y){if(T||A!==I||V!==v)return null;T=!0}}}if(!T)return null}return f}function wl(e,o,t,n,s,h,l,r){if(l(r,s.length+h.length+(n.length+1)*t.length*2),!t)return!1;let i=n.indexOf(t);return i<0||n.lastIndexOf(t)!==i||!h.some(u=>u.from===i)||!h.some(u=>u.to===i+t.length)?!1:s.some(u=>u.source===e&&u.target===o&&u.from===0&&u.to===t.length&&u.targetFrom===i)}function Br({base:e,views:o,eligible:t,baseId:n,ignored:s,remoteWins:h,atomKey:l,limit:r=2e4*8}){if(r<=0)return null;let i=Symbol(),u=(v,T)=>{if(T>v.remaining)throw i;v.remaining-=T},w=[new Map,new Map];for(let v=0;v<2;v++)for(let T=0;T<o[v].V.units.length;T++)w[v].set(o[v].V.units[T],T);let c=new Int32Array(e.length),p=new Int32Array(e.length),b=v=>o.every(({V:T},A)=>{let E=T.twin(v);return E&&w[A].has(E)}),S=-1;for(let v=0;v<e.length;v++)c[v]=S,b(e[v])&&(S=v);S=e.length;for(let v=e.length-1;v>=0;v--)p[v]=S,b(e[v])&&(S=v);let C=new Map,m=(v,T)=>{if(u(T,1),C.has(v))return C.get(v);let A=v.firstChild,E=1;for(;A;){if(u(T,E*8+8),A.nodeType===3&&u(T,A.data.length*8),A.nodeType===1&&Tn.has(A.tagName)&&!s(A)&&!h(A)&&A.firstChild){A=A.firstChild,E++;continue}for(;A&&A!==v&&!A.nextSibling;)A=A.parentNode,E--;A=!A||A===v?null:A.nextSibling}let N=nn(Array.from(v.childNodes),{ignored:s,remoteWins:h});return C.set(v,N),N},f=(v,T,A,E,N,M)=>{for(let P of v.atoms){u(M,1);let V=T.atomAt.get(P.i+A);if(!V)return!1;let D=E?.reverse.get(P.el)||l(P.el),j=N?.reverse.get(V.el)||l(V.el);if(D!==j)return!1}return!0},g=(v,T,A,E,N)=>{let M=v.text.length<=T.text.length?v:T,P=M===v?T:v;if(u(N,M.text.length+P.text.length),!M.text||!Hn.test(M.text.replaceAll(Un,"")))return!1;let V;if(M.text===P.text)V=0;else{let D=P.text.length-M.text.length;if(u(N,(D+1)*M.text.length*2),P.text.startsWith(M.text))V=0;else if(P.text.endsWith(M.text))V=D;else return!1;if(P.text.indexOf(M.text)!==V||P.text.lastIndexOf(M.text)!==V)return!1;u(N,P.text.length*2);let j=0,y=V===0,k=!1;for(let J of an(P.text,xn(P.text)))j+=J.len,j===V&&(y=!0),j===V+M.text.length&&(k=!0);if(!y||!k)return!1}return M===v?f(M,P,V,A,E,N):f(M,P,V,E,A,N)},I=null;for(let v=0;v<2;v++){let{V:T,A,idOf:E}=o[v],N=o[1-v];if(!T.asBase)for(let M=0;M<e.length;M++){let P=e[M];if(T.twin(P)||!t(P))continue;let V=N.V.twin(P);if(!V||!w[1-v].has(V)||!t(V))continue;let D={remaining:r};try{let j=c[M],y=p[M],k=0;for(let Me=j+1;Me<y;Me++)u(D,1),!T.twin(e[Me])&&N.V.twin(e[Me])&&t(e[Me])&&k++;if(k!==1||m(P,D).text===m(V,D).text)continue;let J=j<0?-1:w[v].get(T.twin(e[j])),H=y===e.length?T.units.length:w[v].get(T.twin(e[y]));if(J===void 0||H===void 0||J>=H)continue;let q=null;for(let Me=J+1;Me<H;Me++){u(D,1);let Oe=T.units[Me];if(T.baseOf(Oe)||!t(Oe)||Oe.tagName!==P.tagName||Oe.namespaceURI!==P.namespaceURI)continue;let Re=n(P),ie=N.idOf(V),xe=E(Oe);if(!(Re&&ie&&Re!==ie||Re&&xe&&Re!==xe||ie&&xe&&ie!==xe)&&g(m(V,D),m(Oe,D),N.A,A,D)){if(q){q=null;break}q=Oe}}if(!q)continue;I||(I=[new Map,new Map]),I[v].set(P,q)}catch(j){if(j!==i)throw j}}}return I?o.map(({V:v},T)=>{let A=I[T];if(!A.size)return v;let E=new Map;for(let[N,M]of A)E.set(M,N);return{...v,twin:N=>A.get(N)||v.twin(N),baseOf:N=>E.get(N)||v.baseOf(N)}}):null}function jr({onUncertainSource:e,onUncertainOwner:o,base:t,views:n,eligible:s,ignored:h,remoteWins:l,baseId:r,atomKey:i,limit:u=2e4*32}){if(u<=0)return null;let w=new Set(t),c=new Map(t.map((j,y)=>[j,y])),p=new Map,b=[],S=null,C=null,m=null,f=new Set;for(let j of t)for(let{V:y}of n){let k=y.twin(j);k&&!y.asBase&&!y.here(k)&&f.add(j)}let g=new Set,I=Symbol(),v=(j,y)=>{if(y>j.remaining)throw I;j.remaining-=y},T=(j,y,k)=>{v(k,1);let J=p.get(j);if(J)return J;if(j.nodeType===1){let Me=j.firstChild,Oe=1;for(;Me;){if(v(k,Oe*8+8),Me.nodeType===3&&v(k,Me.data.length*8),Me.nodeType===1&&Tn.has(Me.tagName)&&!h(Me)&&!l(Me)&&Me.firstChild){Me=Me.firstChild,Oe++;continue}for(;Me&&Me!==j&&!Me.nextSibling;)Me=Me.parentNode,Oe--;Me=!Me||Me===j?null:Me.nextSibling}}else v(k,j.value.length*8+j.nodes.length);let H=j.nodeType===1?Array.from(j.childNodes):j.nodes,q=H.length===1&&H[0].nodeType===3?{text:H[0].data,nodes:[{node:H[0],s:0,e:H[0].data.length}],atoms:[]}:nn(H,{ignored:h,remoteWins:l});return J={unit:j,flat:q,alignment:y,tokens:null},p.set(j,J),J},A=(j,y)=>{if(j.tokens)return j.tokens;v(y,j.flat.text.length*8);let{unit:k,flat:J,alignment:H}=j,q=[],Me=xn(J.text),Oe=0,Re=ie=>{for(let xe of an(J.text.slice(Oe,ie),Me))xe.from=Oe,xe.to=Oe+xe.len,xe.unit=k,q.push(xe),Oe+=xe.len};for(let ie of J.atoms){Re(ie.i);let xe=l(ie.el)&&ie.el.nodeType===1?"w"+ie.el.tagName+"#"+(ie.el.id||""):i(H?.reverse.get(ie.el)||ie.el);q.push({k:xe,raw:Un,len:1,from:Oe,to:Oe+1,unit:k,atom:!0}),Oe++}return Re(J.text.length),j.tokens=q,q},E=(j,y,k,J,H)=>{if(!j.flat.atoms.length&&!y.flat.atoms.length)return!0;let q=A(j,H),Me=A(y,H);v(H,q.length+Me.length);let Oe=0;for(let Re of Me){if(!Re.atom||Re.from<k||Re.from>=k+J)continue;for(;Oe<q.length&&!q[Oe].atom;)Oe++;let ie=q[Oe++];if(!ie||ie.from!==Re.from-k||ie.k!==Re.k)return!1}for(;Oe<q.length;)if(q[Oe++].atom)return!1;return!0},N=(j,y,k)=>{let J=j.length+y.length+4;if(J*8>k.remaining)return null;k.remaining-=J*8;let H=Math.floor(k.remaining/8),q=Math.min(j.length+y.length,4e3,Math.floor((Math.sqrt(J*J+H)-J)/2)),Me=4*(q+1)*(J+q+1);if(q<1||Me>k.remaining)return null;k.remaining-=Me;let Oe=Wn(j,y,q),Re=[],ie=0,xe=0;for(let qe of Oe.hunks){for(;ie<qe.bs;)j[ie].raw===y[xe].raw&&Re.push([j[ie],y[xe]]),ie++,xe++;ie=qe.be,xe+=qe.toks.length}for(;ie<j.length&&xe<y.length;)j[ie].raw===y[xe].raw&&Re.push([j[ie],y[xe]]),ie++,xe++;return Re},M=(j,y,k,J,H,q,Me)=>{if(H<=J)return;let Oe=j[j.length-1];if(Oe&&Oe.source===y&&Oe.target===k&&Oe.to<=J&&Oe.targetFrom-Oe.from===q-J){v(Me,(J-Oe.to)*3);let Re=p.get(y).flat.text,ie=p.get(k).flat.text,xe=!0;for(let qe=Oe.to;qe<J;qe++)if(!gn.test(Re[qe])||Re[qe]!==ie[q+qe-J]){xe=!1;break}if(xe){Oe.to=H;return}}j.push({source:y,target:k,from:J,to:H,targetFrom:q})},P=j=>j.replace(pl,"");for(let j=0;j<n.length;j++){let{V:y,A:k,idOf:J}=n[j];if(y.asBase)continue;let H=new Map(y.units.map((x,Y)=>[x,Y])),q=x=>{let Y=y.twin(x);return Y&&H.has(Y)?Y:null},Me=(x,Y)=>{let ae=new Int32Array(x.length),oe=new Int32Array(x.length),Ee=-1;for(let De=0;De<x.length;De++)ae[De]=Ee,Y(x[De])&&(Ee=De);Ee=x.length;for(let De=x.length-1;De>=0;De--)oe[De]=Ee,Y(x[De])&&(Ee=De);return{prev:ae,next:oe}},Oe=Me(t,x=>(x.nodeType===1||x.kind==="text"&&Hn.test(x.value))&&q(x)),Re=Me(y.units,x=>(x.nodeType===1||x.kind==="text"&&Hn.test(x.value))&&w.has(y.baseOf(x))),ie=new Map,xe=(x,Y,ae,oe)=>{if(x>Y||ae>oe)return;let Ee=`${x}:${Y}:${ae}:${oe}`;ie.set(Ee,[x,Y,ae,oe])};for(let x=0;x<y.units.length;x++){let Y=y.units[x];if(y.baseOf(Y)||!s(Y))continue;let ae=Re.prev[x],oe=Re.next[x],Ee=ae<0?0:c.get(y.baseOf(y.units[ae])),De=oe===y.units.length?t.length-1:c.get(y.baseOf(y.units[oe]));xe(Ee,De,Math.max(0,ae),Math.min(y.units.length-1,oe))}for(let x=0;x<t.length;x++){let Y=t[x];if(f.has(Y)||!s(Y))continue;if(!y.twin(Y)){let nt=Oe.prev[x],Xe=Oe.next[x],ht=nt<0?0:H.get(q(t[nt])),Ge=Xe===t.length?y.units.length-1:H.get(q(t[Xe]));xe(Math.max(0,nt),Math.min(t.length-1,Xe),ht,Ge)}let ae=q(Y);if(!ae||k.identical.has(Y)||!s(ae))continue;let oe=x+1;for(;oe<t.length&&t[oe].kind==="text"&&!t[oe].value.trim();)oe++;if(oe>=t.length||!s(t[oe]))continue;let Ee=q(t[oe]);if(!Ee||k.identical.has(t[oe])||!s(Ee))continue;let De=H.get(ae),Ne=H.get(Ee);De<Ne&&xe(x,oe,De,Ne)}let qe=Array.from(ie.values()),fe=new Set;if(qe.length>1){let x=$t(u);try{v(x,qe.length*4);let Y=qe.slice().sort((Ee,De)=>(v(x,1),Ee[0]-De[0]||Ee[2]-De[2])),ae=[],oe=null;for(let Ee of Y)v(x,1),oe&&Ee[0]<=oe[1]&&Ee[2]<=oe[3]&&Ee[3]>=oe[2]?(oe[1]=Math.max(oe[1],Ee[1]),oe[2]=Math.min(oe[2],Ee[2]),oe[3]=Math.max(oe[3],Ee[3]),oe[4].push(Ee)):(oe?.[4].length>1&&ae.push(oe),oe=[Ee[0],Ee[1],Ee[2],Ee[3],[Ee]]);oe?.[4].length>1&&ae.push(oe),qe=ae.concat(qe)}catch(Y){if(Y!==I)throw Y}}for(let x of qe){if(fe.has(x))continue;let[Y,ae,oe,Ee,De]=x,Ne=$t(u),nt=[],Xe=new Set,ht=!1;try{v(Ne,(ae-Y+Ee-oe+2)*4);let Ge=t.slice(Y,ae+1).filter(U=>!k.identical.has(U)&&s(U)&&!f.has(U)),rt=y.units.slice(oe,Ee+1).filter(U=>s(U)&&(!y.baseOf(U)||w.has(y.baseOf(U)))&&!k.identical.has(y.baseOf(U))&&!f.has(y.baseOf(U))),Ot=new Set(rt),Ct=!1,wt="",Nt="",Lt=0;for(let U of Ge){let de=T(U,null,Ne);wt+=de.flat.text,Lt+=de.flat.text.length}for(let U of rt){let de=T(U,k,Ne);Nt+=de.flat.text,Lt+=de.flat.text.length}v(Ne,Lt);let qt=P(wt),cn=P(Nt),It=qt===cn;if(ht=It,De&&!It)continue;let Gt=It?null:new Map;if(Gt)for(let U of Ge.concat(rt)){let de=p.get(U).flat.text.length;v(Ne,de*16),Gt.set(U,new Uint8Array(de))}let wn=U=>{let de=[];for(let we of U){let le=p.get(we);le.flat.atoms.length?de.push(...A(le,Ne)):de.push({unit:we,raw:le.flat.text,from:0})}return de},Dt=[];for(let U of It?[]:Ge){let de=q(U);if(!Ot.has(de))continue;let we=T(U,null,Ne),le=T(de,k,Ne);v(Ne,we.flat.text.length+le.flat.text.length);let Ae=we.flat.text&&le.flat.text.startsWith(we.flat.text)?0:we.flat.text&&le.flat.text.endsWith(we.flat.text)?le.flat.text.length-we.flat.text.length:-1;if(Ae>=0&&E(we,le,Ae,we.flat.text.length,Ne)){Gt.get(U).fill(1),Gt.get(de).fill(1,Ae,Ae+we.flat.text.length),M(Dt,U,de,0,we.flat.text.length,Ae,Ne);continue}let W=N(A(we,Ne),A(le,Ne),Ne);if(!W){Ct=!0;break}for(let[X,pe]of W)Gt.get(U).fill(1,X.from,X.to),Gt.get(de).fill(1,pe.from,pe.to),M(Dt,U,de,X.from,X.to,pe.from,Ne)}if(Ct)continue;let rn=null,Yt=null;if(!It)for(let U of Ge){let de=q(U),we=p.get(U);if(!de||we.flat.atoms.length||!Ot.has(de))continue;let le=we.flat.text,Ae=Gt.get(U);v(Ne,le.length*3+rt.length);let W=-1,X=-1,pe=!1;for(let Pe=0;Pe<le.length;Pe++)gn.test(le[Pe])||(Ae[Pe]?pe=!0:(W<0&&(W=Pe),X=Pe+1));if(!pe||W<0)continue;let be=!0;for(let Pe=W;Pe<X;Pe++)if(Ae[Pe]&&!gn.test(le[Pe])){be=!1;break}if(!be)continue;let he=P(le.slice(W,X)),ee=null,te=!1;for(let Pe of rt){if(y.baseOf(Pe))continue;let ve=p.get(Pe);if(!ve.flat.atoms.length&&(v(Ne,ve.flat.text.length),P(ve.flat.text)===he)){if(ee){te=!0;break}ee=Pe}}if(te){(Yt||=new Set).add(U);continue}if(!ee||Yt?.has(U))continue;let z=!1;for(let Pe of Ge){if(Pe===U||!Ot.has(q(Pe)))continue;let ve=p.get(Pe);if(ve.flat.atoms.length)continue;let _e=Gt.get(Pe);v(Ne,ve.flat.text.length*3);let Je="",Ze=!1;for(let Ut=0;Ut<ve.flat.text.length;Ut++)gn.test(ve.flat.text[Ut])||(_e[Ut]?Ze=!0:Je+=ve.flat.text[Ut]);Ze&&Je===he&&(Yt||=new Set,Yt.add(U),Yt.add(Pe),z=!0)}if(z)continue;let ne=p.get(ee).flat.text;v(Ne,X-W+ne.length);let Te=W,Ce=0;for(;Te<X&&Ce<ne.length;){for(;Te<X&&gn.test(le[Te]);)Te++;for(;Ce<ne.length&&gn.test(ne[Ce]);)Ce++;if(Te>=X||Ce>=ne.length)break;M(rn||=[],U,ee,Te,Te+1,Ce,Ne),Te++,Ce++}Ae.fill(1,W,X),Gt.get(ee).fill(1)}let fn=U=>{let de=[];for(let we of U){let le=T(we,w.has(we)?null:k,Ne),Ae=Gt.get(we);for(let W of A(le,Ne)){let X=W.from;for(;X<W.to;){for(;X<W.to&&Ae[X];)X++;let pe=X;for(;X<W.to&&!Ae[X];)X++;if(X>pe){let be=le.flat.text.slice(pe,X);Hn.test(be)&&de.push({...W,raw:be,len:X-pe,k:W.atom?W.k:be,from:pe,to:X})}}}}return de},$=It?wn(Ge):fn(Ge),a=It?wn(rt):fn(rt),O=It?qt:$.map(U=>P(U.raw)).join(""),R=It?cn:a.map(U=>P(U.raw)).join("");if((!O||!R)&&!rn)continue;let K=rn||[];if(O&&R&&O===R){let U=0,de=0,we=0,le=0;for(;U<$.length&&de<a.length;){let Ae=$[U],W=a[de];for(;we<Ae.raw.length&&gn.test(Ae.raw[we]);)we++;for(;le<W.raw.length&&gn.test(W.raw[le]);)le++;if(we===Ae.raw.length){U++,we=0;continue}if(le===W.raw.length){de++,le=0;continue}if((Ae.atom||W.atom)&&Ae.k!==W.k){Ct=!0;break}M(K,Ae.unit,W.unit,Ae.from+we,Ae.from+we+1,W.from+le,Ne),we++,le++}}else if(O&&R){let U=N($,a,Ne);if(!U)continue;for(let[de,we]of U)M(K,de.unit,we.unit,de.from,de.to,we.from,Ne)}if(Ct)continue;let Z=new Map;for(let U of K)if(!Yt?.has(U.source)){if(q(U.source)===U.target){It&&Dt.push(U);continue}Z.has(U.source)||Z.set(U.source,[]),Z.get(U.source).push(U)}for(let[U,de]of Z){let we=T(U,null,Ne),le=q(U),Ae=we.flat.text,W=[],X=new Set,pe=n[1-j],be=pe.V.twin(U),he=be&&pe.V.here(be)?T(be,pe.A,Ne):null,ee=(ve,_e)=>{let Je=A(ve,Ne),Ze=A(_e,Ne);return v(Ne,ve.flat.text.length+_e.flat.text.length+Je.length+Ze.length),ve.flat.text===_e.flat.text&&Je.length===Ze.length&&Je.every((Ut,Pt)=>Ut.k===Ze[Pt].k)},te=le&&he&&he.flat.text!==Ae&&ee(T(le,k,Ne),he);for(let ve of new Set(de.map(_e=>_e.target))){if(U.nodeType!==1&&ve.nodeType!==1)continue;let _e=T(ve,k,Ne),Je=y.baseOf(ve);if(U.nodeType!==1&&Je||(v(Ne,Ae.length*2+_e.flat.text.length*3+Dt.length*2),le&&P(Ae)===P(_e.flat.text)&&T(le,k,Ne).flat.text.trim()))continue;if(!le&&!Je&&U.nodeType===1&&ve.nodeType===1){let G=r(U),re=J(ve);if(G&&re&&G!==re)continue}let Ze=_e.flat.text,Ut=Ae&&(Ze.startsWith(Ae)||Ze.endsWith(Ae)),Pt=!1;if(!le&&he&&Je&&he.flat.text!==Ae){let G=T(Je,null,Ne).flat.text,re=c.get(U)<c.get(Je)?he.flat.text:G,ge=c.get(U)<c.get(Je)?G:he.flat.text;v(Ne,re.length+ge.length+Ze.length),Pt=!!re&&!!ge&&re.length+ge.length<=Ze.length&&Ze.startsWith(re)&&Ze.endsWith(ge)&&!Ze.slice(re.length,Ze.length-ge.length).trim()}let L=!we.flat.atoms.length&&!he?.flat.atoms.length&&!_e.flat.atoms.length&&(te&&Ut||Pt);if(le&&Je){let G=T(le,k,Ne).flat.text,re=Ae.startsWith(G)||Ae.endsWith(G),ge=T(Je,null,Ne).flat.text,ye=_e.flat.text,ce=ye.startsWith(ge)||ye.endsWith(ge),se=!n[1-j].V.twin(Je)&&!Dt.some(Ie=>Ie.source===Je&&Hn.test(ge.slice(Ie.from,Ie.to)));if(!It&&(!re&&!L||!ce&&!se)){let Ie=bl(U,ve,de,Ge,rt,p,Gt,A,v,Ne);if(!Ie)continue;let Be=k.weak?.has(U)&&!k.identityPaired?.has(U)&&Ae.trim()===Ie;if(!re&&!L&&!Be)continue;let He=k.weak?.has(Je)&&!k.identityPaired?.has(Je)&&Ze.trim()===Ie&&!p.get(Je).flat.atoms.length&&!Dt.some(Ke=>Ke.source===Je&&Hn.test(ge.slice(Ke.from,Ke.to)));if(!ce&&!se&&!He&&!wl(Je,ve,ge,Ze,Dt,A(_e,Ne),v,Ne))continue;Be&&X.add(ve)}}L&&X.add(ve),v(Ne,de.length),W.push(...de.filter(G=>G.target===ve))}if(!W.length)continue;let z=new Uint8Array(Ae.length);v(Ne,Ae.length*4+Dt.length);for(let ve of W)z.fill(1,ve.from,ve.to);let ne=[];for(let ve=0;ve<Ae.length;ve++)gn.test(Ae[ve])||ne.push(ve);if(!ne.length)continue;let Te=new Set(W.map(ve=>ve.target));if(!It&&le&&Te.size>1&&ml(Te,K,Dt,y,p,Ne,v)){if(m||=new Map,m.set(U,(m.get(U)||0)|1<<j),e){let ve=ys({source:U,side:j,views:n,eligible:s,blocked:f,baseId:r,model:T,tokensOf:A,budget:Ne,charge:v});if(ve){v(Ne,ve.to-ve.from);let _e=!0;for(let Je=ve.from;Je<ve.to;Je++)if(Hn.test(Ae[Je])&&!z[Je]){_e=!1;break}_e&&(S||=[]).push(ve)}}continue}let Ce=ne.filter(ve=>Cs.test(Ae[ve]));if(!W.some(ve=>Cs.test(Ae.slice(ve.from,ve.to)))&&!ne.every(ve=>z[ve]))continue;if(!le&&!Array.from(Te).some(ve=>X.has(ve))&&!ne.every(ve=>z[ve])&&!(Ce.length&&z[Ce[0]]&&z[Ce[Ce.length-1]]&&Te.size===1)){let ve=null,_e=0,Je=0,Ze=null,Ut=null;if(!le&&he&&U.nodeType===1&&!we.flat.atoms.length){let Pt=A(we,Ne).filter(L=>Cs.test(L.raw));v(Ne,rt.length+Ae.length);for(let L of rt){let G=y.baseOf(L);if(!G||G===U||G.nodeType!==1||L.nodeType!==1||G.tagName!==U.tagName||L.tagName!==G.tagName)continue;let re=c.get(U),ge=c.get(G),ye=!0;for(let tt=Math.min(re,ge)+1;tt<Math.max(re,ge);tt++){let Kt=t[tt];if(v(Ne,Kt.nodeType===1?1:Kt.value.length+1),Kt.nodeType===1||Kt.value.trim()){ye=!1;break}}if(!ye)continue;let ce=T(G,null,Ne),se=T(L,k,Ne);if(ce.flat.atoms.length||se.flat.atoms.length)continue;let Ie=ce.flat.text,Be=se.flat.text;if(v(Ne,Ie.length+Be.length+Ae.length),!Ie||!Pt.length)continue;let He=0,Ke=Be.length;if(re<ge&&Be.endsWith(Ie))Ke-=Ie.length;else if(re>ge&&Be.startsWith(Ie))He=Ie.length;else continue;for(;He<Ke&&gn.test(Be[He]);)He++;for(;Ke>He&&gn.test(Be[Ke-1]);)Ke--;let pt=Be.slice(He,Ke);if(!(!pt||!(pt.startsWith(Pt[0].raw)||pt.endsWith(Pt[Pt.length-1].raw)))){if(ve){ve=null;break}ve=L,_e=He,Je=Ke,Ze=Pt[0],Ut=Pt[Pt.length-1]}}}if(v(Ne,W.length),!ve||!Te.has(ve)||!W.some(Pt=>Pt.target===ve&&(Pt.from<=Ze.from&&Pt.to>=Ze.to&&Pt.targetFrom+Ze.from-Pt.from===_e||Pt.from<=Ut.from&&Pt.to>=Ut.to&&Pt.targetFrom+Ut.to-Pt.from===Je)))continue}if(le&&!(ne.every(ve=>z[ve])&&(It||Array.from(Te).some(ve=>X.has(ve))))&&!Dt.some(ve=>ve.source===U&&Hn.test(Ae.slice(ve.from,ve.to))))continue;let Pe=!1;if(It){v(Ne,Dt.length+ne.length);for(let ve of Dt)ve.source===U&&(v(Ne,ve.to-ve.from),z.fill(1,ve.from,ve.to));Pe=!0;for(let ve of ne)if(!z[ve]){Pe=!1;break}}for(let ve of Te){v(Ne,W.length);let _e=W.filter(Ze=>Ze.target===ve);nt.push({side:j,source:U,target:ve,runs:_e,models:p,retained:Dt,conservedSource:Pe}),U.nodeType===1&&Xe.add(U),ve.nodeType===1&&Xe.add(ve);let Je=y.baseOf(ve);Je?.nodeType===1&&Xe.add(Je)}}if(b.push(...nt),De&&nt.length)for(let U of De)fe.add(U);for(let U of Xe)g.add(U)}catch(Ge){if(Ge!==I)throw Ge}finally{if(o&&!De&&!ht){let Ge=Pr({base:t,views:n,side:j,attempt:x,eligible:s,blocked:f,baseId:r,model:T,tokensOf:A,charge:v,exhausted:I,limit:u});Ge&&(C||=[]).push(...Ge)}if(e&&!De&&!ht){let Ge=Gs({base:t,views:n,side:j,attempt:x,eligible:s,blocked:f,baseId:r,model:T,tokensOf:A,certificates:b,charge:v,exhausted:I,limit:u});Ge&&(S||=[]).push(...Ge)}}}}let V=b.length?new Map:null;for(let j of b){let y=V.get(j.source);y||V.set(j.source,y=[]),y.push(j)}let D=null;if(V){let j=null;for(let[y,k]of V){let J=m?.get(y)||0;if(k.length<2&&!J)continue;let H=0;for(let q of k)q.conservedSource&&(H|=1<<q.side);for(let q of k){if(q.conservedSource)continue;let Me=1<<q.side,Oe=!0;if(H&Me)Oe=!1;else if(J&Me){Oe=!1;try{Oe=gl(q,j||=$t(u),v)}catch(Re){if(Re!==I)throw Re}}Oe||(D||=new Set).add(q)}}}if(D){let j=0;for(let y of b)D.has(y)||(b[j++]=y);b.length=j;for(let[y,k]of V){j=0;for(let J of k)D.has(J)||(k[j++]=J);k.length=j,j||V.delete(y)}g.clear();for(let y of b){let{source:k,target:J,side:H}=y;k.nodeType===1&&g.add(k),J.nodeType===1&&g.add(J);let q=n[H].V.baseOf(J);q?.nodeType===1&&g.add(q)}}if(S){let j=$t(u),y=!1;for(let k of S){let J=!1,H=V?.get(k.source);if(H&&!y)try{J=ws(k,H,j,v)}catch(q){if(q!==I)throw q;y=!0}J||e(k)}}if(C){let j=new Set,y=$t(u);try{for(let k of C){if(v(y,1),j.has(k.source))continue;j.add(k.source);let J=!1;for(let H of b)if(v(y,1),H.source===k.source||H.target===k.local||H.target===k.remote){J=!0;break}J||o(k)}}catch(k){if(k!==I)throw k}}for(let j of t)if(g.has(j))for(let{V:y}of n){let k=y.twin(j);k&&y.here(k)&&g.add(k)}return b.length?{blocks:g,certificates:b,certificatesBySource:V,models:p}:null}function Dr({certificates:e,scopes:o,flats:t,keys:n,limit:s=2e4*32}){let h=Symbol(),l=$t(s),r=m=>{if(m>l.remaining)throw h;l.remaining-=m},i=o.map(m=>new Set(m)),u=new Map,w=new Map,c=(m,f)=>{let g=u.get(m);if(g||u.set(m,g=new Map),g.has(f))return g.get(f);r(m.text.length);let I=w.get(f);if(!I){r(f.nodes.length+f.atoms.length),I={nodes:new Map,atoms:new Map};for(let E of f.nodes)I.nodes.set(E.node,E);for(let E of f.atoms)I.atoms.set(E.el,E.i);w.set(f,I)}let{nodes:v,atoms:T}=I,A=new Int32Array(m.text.length).fill(-1);for(let E of m.nodes){let N=v.get(E.node);if(!(!N||E.e-E.s!==N.e-N.s)){r(E.e-E.s);for(let M=E.s;M<E.e;M++)A[M]=N.s+M-E.s}}for(let E of m.atoms){let N=T.get(E.el);N!==void 0&&(A[E.i]=N)}return g.set(f,A),A},p=(m,f,g,I,v)=>{let T=m[m.length-1];T&&T.to===f&&T.target+T.to-T.from===I&&T.kind===v?T.to=g:m.push({from:f,to:g,target:I,kind:v})},b=(m,f,g,I)=>{r((I-g)*4);let v=[],T=g,A=M=>{let P=m.text.slice(T,M);for(let V of an(P,xn(P)))V.from=T,V.to=T+V.len,v.push(V),T+=V.len},E=0,N=m.atoms.length;for(;E<N;){r(1);let M=E+N>>>1;m.atoms[M].i<g?E=M+1:N=M}for(let M=E;M<m.atoms.length&&m.atoms[M].i<I;M++){r(1);let P=m.atoms[M];A(P.i),v.push({k:f(P),raw:Un,len:1,from:T,to:T+1}),T++}return A(I),v},S=(m,f,g,I,v,T)=>{if(g===I||v===T)return;if(I-g===T-v){r((I-g)*4);let y=!0;for(let k=g,J=v;k<I;k++,J++){if(t[0].text[k]!==t[f].text[J]){y=!1;break}let H=t[0].atomAt.get(k),q=t[f].atomAt.get(J);if(!!H!=!!q||H&&n[0](H)!==n[f](q)){y=!1;break}}if(y){p(m,g,I,v,"retained");return}}let A=b(t[0],n[0],g,I),E=b(t[f],n[f],v,T),N=A.length+E.length+4,M=Math.min(A.length+E.length,4e3,Math.floor((Math.sqrt(N*N+l.remaining/2)-N)/2));if(M<1)throw h;r(4*(M+1)*(N+M+1));let P=Wn(A,E,M),V=0,D=0,j=()=>{let y=A[V++],k=E[D++];r(y.len),y.raw===k.raw&&p(m,y.from,y.to,k.from,"retained")};for(let y of P.hunks){for(;V<y.bs;)j();V=y.be,D+=y.toks.length}for(;V<A.length&&D<E.length;)j()},C=m=>{let f=e.filter(P=>P.side===m-1&&i[0].has(P.source)&&i[m].has(P.target));if(!f.length)return null;let g=[],I=(P,V,D)=>{if(!i[0].has(P.source)||!i[m].has(P.target))return;let j=c(V.get(P.source).flat,t[0]),y=c(V.get(P.target).flat,t[m]);r(P.to-P.from);for(let k=0;k<P.to-P.from;k++){let J=j[P.from+k],H=y[P.targetFrom+k];if(J<0||H<0)throw h;p(g,J,J+1,H,D)}},v=new Set;for(let P of f){if(!v.has(P.retained)){v.add(P.retained);for(let V of P.retained)I(V,P.models,"retained")}for(let V of P.runs)I(V,P.models,"transfer")}g.sort((P,V)=>(r(1),P.from-V.from||P.target-V.target));let T=[];for(let P of g){r(1);let V=T[T.length-1];if(V&&P.from<V.to){if(P.target-P.from!==V.target-V.from)throw h;V.to=Math.max(V.to,P.to),P.kind==="transfer"&&(V.kind="transfer")}else T.push(P)}let A=[],E=0,N=0;for(let P of T){if(P.target<N)throw h;S(A,m,E,P.from,N,P.target),A.push(P),E=P.to,N=P.target+P.to-P.from}S(A,m,E,t[0].text.length,N,t[m].text.length);let M=Dn({base:t[0],side:t[m],retained:A.filter(P=>P.kind==="retained"),transfers:A.filter(P=>P.kind==="transfer"),baseAtomKey:n[0],sideAtomKey:n[m],budget:l});if(M.status!=="ready"||!M.monotone)throw h;return M};try{let m=C(1),f=C(2);return m||f?{local:m,remote:f}:{fallback:!0}}catch(m){if(m!==h)throw m;return{fallback:!0}}}function Ls(e,o,t=!1){let n=-1,s=-1;for(let l=0;l<e.list.length;l++){let r=e.list[l];r.bLo<o.lo||r.bLo>o.hi||(n<0&&(n=l),s=l)}let h=[];for(let l=n;l>=0&&l<=s;l++){let r=e.list[l],i=!t&&l===n?r.inlineStart<0?r.to:r.inlineStart:r.from,u=!t&&l===s?r.inlineEnd<0?r.from:r.inlineEnd:r.to;for(let w=i;w<u;w++)h.push(e.units[w]);l<s&&h.push(e.units[r.next])}return h}var it=e=>!!e&&e.nodeType===1,Ln=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function Es(e){for(let o of e)if(Ln.has(o.tagName))return!0;return!1}function yl(e,o,t){let n=null;for(let s of o.childNodes)if(!(!it(s)||!t(s)||!s.isEqualNode(e))){if(n)return null;n=s}if(!n)return null;for(let s of e.parentNode.childNodes)if(s!==e&&s.isEqualNode(e))return null;return n}var Co="[id],[data-id],script,head>*";function Rs(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=ho(t,e);if(n)return"merge:"+n.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?yr(t,o):null}}function Qo(e,o,t,n){let s=n.ignored,h=n.stats||$n(),l=Ks({ignored:s,ignoreAttribute:n.ignoreAttribute,stats:h}),{unitsOf:r,meta:i}=l,u=n.baseURI,w=n.mergeTags!==null,c=Rs(n.mergeTags,u),p=L=>G=>{let re=c(G);return re!==null?re:L(G)},b=p(n.identity.base),S=p(n.identity.local),C=p(n.identity.remote),m=n.authored||n.identity,f=L=>L&&L.nodeType===9?L.documentElement:L,g=f(e),I=f(o),v=f(t),T=globalThis.__hyperMorphProfile,A=T?performance.now():0,E=L=>L===kn?Co:null,N=n.scope||null,M=N?N.baseDropped:new Set,P=new Set,V=N?N.remoteDropped:new Set,D=N?N.baseIndex:Uo(g,b,s,E(n.identity.base),M),j=n.localIsBase||g===I?null:Uo(I,S,s,E(n.identity.local),P),y=N?N.remoteIndex:Uo(v,C,s,E(n.identity.remote),V),k=L=>{let G=it(L)&&S(L);return G&&j?.get(G)===L&&!D.has(G)?G:null},J=L=>{let G=it(L)&&C(L);return G&&y.get(G)===L&&!D.has(G)?G:null},H=j?cs(g,I,{analyzer:l,baseIndex:D,sideIndex:j,baseId:m.base,sideId:m.local,baseKey:b,sideKey:S,baseDropped:M,sideDropped:P,stats:h}):Vr(),q=cs(g,v,{analyzer:l,baseIndex:D,sideIndex:y,baseId:m.base,sideId:m.remote,baseKey:b,sideKey:C,baseDropped:M,sideDropped:V,stats:h,scope:N,comparisons:n.comparisons});if(N){if(!N.held(q))return null;for(let L of N.dropped)ls(L)}let Me=null;function Oe(L){if(!Me){Me=new WeakMap;let G=[g];for(;G.length;){let re=G.pop();re.tagName==="TEMPLATE"&&re.content&&Me.set(re.content,re);for(let ge of l.childrenOf(re))ge.nodeType===1&&G.push(ge)}}return Me.get(L)||null}let Re=L=>{let G=it(L)||L.nodeType?L.parentNode:L.parent;return G&&G.nodeType===11?Oe(G):G};if(q.moved.size){let L=!1;for(let G of Array.from(q.moved))!it(G)||q.identityPaired.has(G)||!m.base(G)||a(q,Re(G))||(q.unpair(G),L=!0);L&&q.rematch()}fn(),$(H,q),$(q,H);for(let L of[H,q])if(L.refused)for(let G of L.refused)L.moved.has(G)||h.ambiguousMoves++;T&&(T.alignTotal=(T.alignTotal||0)+(performance.now()-A),A=performance.now());let ie=g.ownerDocument.implementation.createHTMLDocument(""),xe=new WeakMap,qe=new WeakMap,fe=[],x=[],Y=new Set,ae=[],oe=new Set,Ee=new Set,De=new Set,Ne=new WeakMap,nt=null,Xe=n.lineage?.locals.length?lr():null,ht=L=>{let G=Ko(L);return G&&Xe&&Xe.consume(L.local),G},Ge=n.conflicts||"remote",rt=L=>fe.push(L),Ot=L=>fe.push(L),Ct=Or({roots:{base:g,local:I,remote:v},L:H,R:q,unitsOf:r,provenance:xe,policy:Ge}),wt=(L,G)=>{x.push(L),G&&Ct.note(L,G)},Nt=null,Lt=null,qt=rn(),cn=null,It=U(g,H.map.get(g),q.map.get(g),!!n.localIsBase,!!n.childrenOnly);It.tagName==="HTML"?ie.replaceChild(It,ie.documentElement):ie.body.appendChild(It),Nt?.drain(It),Lt?.drain(It),T&&(T.build=(T.build||0)+(performance.now()-A));let Gt=n.childrenOnly?!Pe(Te(It),Te(v)):!te(It,v),wn=Ct.finish(It),Dt=Xe?ar({locals:n.lineage.locals,rec:Xe,root:It,provenance:xe,segments:ae,ignored:s}):null;return{doc:ie,root:It,provenance:xe,textMappers:qe,decisions:fe,conflicts:x,recoveryLinks:wn,localDiverged:Gt,mergedScripts:Y,segments:ae,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==kn,L:H,R:q,stats:h,lineage:Dt};function rn(){let L=new Map,G=new Set;if(n.localIsBase||!H.insertedByHash)return{partner:L,drop:G};let re=H.insertedByHash(),ge=q.insertedByHash();if(!re.size||!ge.size)return{partner:L,drop:G};let ye={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ce=lt=>{let $e=0;for(let vt=lt.parentNode;vt;vt=vt.parentNode)$e++;return $e},se=[],Ie=lt=>{let $e=lt.textContent.trim();return $e.split(/\s+/).length>=3||$e.replace(/\s/g,"").length>=12},Be=lt=>{let $e=a(H,lt),vt=a(q,lt);return $e&&H.reverse.get($e.parentNode)!==lt.parentNode||vt&&q.reverse.get(vt.parentNode)!==lt.parentNode},He=(lt,$e,vt)=>{for(let jt of vt.parentNode.children){let bn=jt!==vt&&lt.reverse.get(jt);if(bn&&Be(bn))return!0}let ct=lt.reverse.get(vt.parentNode);if(ct){for(let jt of ct.children)if(!a($e,jt)&&!s(jt))return!0}return!1},Ke=new Map([[H,new Map],[q,new Map]]),pt=(lt,$e)=>{let vt=Ke.get(lt),ct=vt.get($e);if(ct===void 0){ct=!1;for(let jt of $e.children)if(lt.reverse.has(jt)||pt(lt,jt)){ct=!0;break}vt.set($e,ct)}return ct},tt=new Map;for(let lt of ge.values())for(let $e of lt){let vt=J($e);vt&&tt.set(vt,$e)}for(let lt of re.values())for(let $e of lt){let vt=k($e),ct=vt?tt.get(vt):null;ct&&ct.tagName===$e.tagName&&!Vn($e,ye)&&!Vn(ct,ye)&&!n.remoteWins($e)&&!n.remoteWins(ct)&&se.push([$e,[ct],ce($e),!0,!0])}for(let[lt,$e]of re){let vt=ge.get(lt);if(!vt)continue;let ct=$e.length===1&&vt.length===1;for(let jt of $e)!Vn(jt,ye)&&!k(jt)&&se.push([jt,vt,ce(jt),ct&&(Ie(jt)||He(H,q,jt)||He(q,H,vt[0]))])}if(!se.length)return{partner:L,drop:G};se.sort((lt,$e)=>lt[2]-$e[2]);let Kt=new Set,Ht=new Set,un=lt=>{for(let $e of lt.querySelectorAll("*"))Kt.add($e)},bt=(lt,$e)=>lt.reverse.get($e.parentNode)||null;for(let[lt,$e,,vt,ct]of se){if(Kt.has(lt)||Ht.has(lt)||ct&&(pt(H,lt)||pt(q,$e[0])))continue;let jt=bt(H,lt),bn=Xt=>!Ht.has(Xt)&&!Kt.has(Xt)&&(ct||Xt.tagName===lt.tagName&&!J(Xt)&&l.equalUnits(lt,Xt)),on=$e.find(Xt=>jt&&bt(q,Xt)===jt&&bn(Xt))||(vt?$e.find(bn):null);if(!on)continue;Ht.add(lt),Ht.add(on);let hn=jt&&bt(q,on)===jt;(!ct||!hn||l.equalUnits(lt,on))&&(un(lt),un(on)),!hn&&(L.set(lt,on),L.set(on,lt),G.add(Ge==="local"?on:lt))}return{partner:L,drop:G}}function Yt(L,G,re){if(oe.add(L),qt.drop.has(L))return null;oe.add(re);let ge=G==="local"?L:re,ye=G==="local"?re:L,ce;return l.equalUnits(ge,ye)?(ce=he(ge,"local",!0),xe.get(ce).remote=ye):ce=be(ge,ye),wt({kind:"structure",el:ce,detail:"both-moved",base:null,local:ge,remote:ye},{unit:{b:null,l:ge,r:ye}}),rt({kind:"insert",el:ce,source:"both"}),ce}function fn(){if(!H.weak||!q.weak||!H.weak.size||!q.weak.size||!H.unpair)return;let L=new Map;for(let re of H.weak){let ge=a(H,re);it(re)&&it(ge)&&L.set(l.unitHash(ge),re)}let G=!1;for(let re of Array.from(q.weak)){let ge=a(q,re);if(!it(re)||!it(ge))continue;let ye=L.get(l.unitHash(ge));if(!ye||ye===re||!H.weak.has(ye)||a(H,re)&&a(q,ye))continue;let ce=a(H,ye);ce.tagName===ge.tagName&&l.equalUnits(ce,ge)&&(H.unpair(ye),q.unpair(re),G=!0)}G&&(H.rematch(),q.rematch())}function $(L,G){if(!L.weak||!L.weak.size||!G.insertedByHash)return;let re=G.insertedByHash();if(!re.size)return;let ge=!1;for(let ye of Array.from(L.weak)){let ce=a(L,ye);if(!ce)continue;let se=L===H?k(ce):J(ce);if(se){let Be=(L===H?y:j)?.get(se);Be&&Be.tagName===ce.tagName&&!G.reverse.has(Be)&&(L.unpair(ye),ge=!0);continue}let Ie=re.get(l.unitHash(ce));Ie&&Ie.some(Be=>Be.tagName===ce.tagName&&l.equalUnits(Be,ce))&&(L.unpair(ye),ge=!0)}ge&&L.rematch()}function a(L,G){if(!G)return null;if(L.map.has(G))return L.map.get(G);let re=[],ge=Re(G);for(;ge&&!L.map.has(ge);ge=Re(ge))re.push(ge);let ye=ge;if(!ye||!L.identical.has(ye))return null;L.pairIdenticalChildren(ye);for(let se=re.length-1;se>=0;se--)L.pairIdenticalChildren(re[se]);let ce=L.map.get(G)||null;return ce&&h.lazyTwins++,ce}function O(L,G,re,ge){if(it(L)&&Ln.has(L.tagName)&&!H.identical.has(L)&&(L.previousSibling?.nodeType===3||L.nextSibling?.nodeType===3)){let Ie=Re(L),Be=a(H,L),He=a(q,L);Be&&He&&Ut(Be,a(H,Ie),H)&&!Ut(He,a(q,Ie),q)&&(Lt||=Lr({L:H,R:q,twinIn:a,unitsOf:r,view:R,parentOf:Re,ignored:s,remoteWins:n.remoteWins,eligible:Ke=>it(Ke)&&Ln.has(Ke.tagName),build:U,out:ie,policy:Ge,provenance:xe,textMappers:qe,segments:ae,conflicts:x,conflict:wt,decisions:fe}),Lt.ensureOwner(L))}if(G===null)return null;if(ge!==void 0)return Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(L,G,re,!!ge),ge&&(Nt.produced(L,ge),Ee.add(L)),ge;if(Ee.has(L)||De.has(L))return wt({kind:"structure",el:null,detail:"both-moved",base:L},{subject:L}),Ee.has(L)?null:he(re,G);Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(L,G,re,!0);let ye=a(H,L),ce=a(q,L);(!ye||!ce)&&wt({kind:"structure",el:null,detail:"move-beats-delete",base:L},{subject:L,deleted:ye?"remote":"local"});let se=U(L,ye,ce,!1);return(G==="local"?rt:Ot)({kind:"move",el:se,source:G}),se}function R(L,G,re,ge){return ge||!G||G===re?{el:re,asBase:!0,twin:ye=>ye,baseOf:ye=>ye,units:r(re),here:()=>!0,parentOfTwin:()=>re}:{el:G,asBase:!1,twin:ye=>a(L,ye),baseOf:ye=>L.reverse.get(ye),units:r(G),here:ye=>it(ye)?ye.parentNode===G||G.tagName==="TEMPLATE"&&ye.parentNode===G.content:ye.parent===G||G.tagName==="TEMPLATE"&&ye.parent===G.content}}function K(L,G,re){return!G||re&&re.identical.has(L)?!1:it(L)?!l.equalUnits(L,G)||!Z(L,G,re):L.value!==G.value}function Z(L,G,re){if(!re||L===G)return!0;let ge=[[L,G]];for(;ge.length;){let[ye,ce]=ge.pop(),se=r(ye),Ie=r(ce);for(let Be=0;Be<se.length&&Be<Ie.length;Be++){let He=se[Be],Ke=Ie[Be];if(!it(He)||!it(Ke))continue;let pt=re.map.get(He);if(pt!==void 0&&pt!==Ke)return!1;let tt=re.reverse.get(Ke);if(tt!==void 0&&tt!==He)return!1;ge.push([He,Ke])}}return!0}function U(L,G,re,ge,ye=!1){let ce=ge||(re?n.remoteWins(re):n.remoteWins(L)),se=L.namespaceURI&&L.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(L.namespaceURI,L.tagName):ie.createElement(L.tagName),Ie={base:L,local:G||null,remote:re||null};if(xe.set(se,Ie),ce&&!ge&&G&&K(L,G,H)&&(!re||!l.equalUnits(G,re))&&wt({kind:"structure",el:se,detail:"remote-wins",base:L,local:G,remote:re||null},{subject:L}),oe.add(L),Ee.add(L),G&&oe.add(G),re&&oe.add(re),n.skipUnchanged&&!ye&&(n.localIsBase||H.identical.has(L))&&re&&q.identical.has(L)&&!n.remoteWins(L)){Ie.unchanged=!0;for(let He of L.attributes)He.namespaceURI?se.setAttributeNS(He.namespaceURI,He.name,He.value):se.setAttribute(He.name,He.value);return Nt?.produced(L,se),se}De.add(L),ye||le(L,ce?L:G,re,se);let Be=L.tagName;if(pn(L))we(L,ce?L:G,re,se);else if(Be==="TEXTAREA")se.textContent=de(L.textContent,(ce?L:G)?(ce?L:G).textContent:L.textContent,re?re.textContent:L.textContent,se,"text");else if(!Lt?.render(L,se)){let He=ee(L,G,re,ce,se),Ke=Be==="TEMPLATE"&&se.content?se.content:se;for(let pt of He)Ke.appendChild(pt)}return De.delete(L),Nt?.produced(L,se),se}function de(L,G,re,ge,ye){if(G===re)return G;if(G===L)return re!==L&&Ot({kind:ye,node:ge,source:"remote"}),re;if(re===L)return rt({kind:ye,node:ge,source:"local"}),G;let ce=Ge==="local"?G:re;return wt({kind:ye,node:ge,base:L,local:G,remote:re,resolved:ce},{site:"whole",el:ge}),fe.push({kind:ye,node:ge,source:"both"}),ce}function we(L,G,re,ge){let ye=L.textContent,ce=G?G.textContent:ye,se=re?re.textContent:ye,Ie=w?ho(L,n.mergeTags,!0):null;if(Ie&&ce!==se){let Be=re&&re.getAttribute("merge-key")||L.getAttribute("merge-key"),{text:He,warnings:Ke,conflicts:pt}=Yo(n.localIsBase?void 0:ye,ce,se,{parse:Ie.recognizer.parse,keyCandidates:Be?Be.split(/[\s,]+/).filter(Boolean):void 0});for(let tt of Ke)console.warn(`[hyper-morph] merge "${Ie.raw}": ${tt}`);for(let tt of n.localIsBase?[]:pt)wt({kind:"json",node:ge,name:Ie.raw,path:tt.path,base:tt.base,local:tt.local,remote:tt.remote,resolved:tt.resolved});ge.textContent=He,Y.add(ge),He!==se?rt({kind:"text",node:ge,source:He===ce?"local":"both"}):He!==ye&&Ot({kind:"text",node:ge,source:"remote"});return}ge.textContent=de(ye,ce,se,ge,"text")}function le(L,G,re,ge){let ye=new Map;for(let ce of[L,G,re])if(ce)for(let se of ce.attributes)n.ignoreAttribute(ce,se.name)||ye.set(se.name,se);for(let[ce,se]of ye){let Ie=L?L.getAttribute(ce):null,Be=G?G.getAttribute(ce):Ie,He=re?re.getAttribute(ce):Ie,Ke;Be===He?Ke=Be:Be===Ie?(Ke=He,Ot({kind:"attr",el:ge,name:ce,source:"remote"})):He===Ie?(Ke=Be,rt({kind:"attr",el:ge,name:ce,source:"local"})):(Ke=Ae(ce,Ie,Be,He),Ke===void 0&&(Ke=Ge==="local"?Be:He,wt({kind:"attr",el:ge,name:ce,base:Ie,local:Be,remote:He,resolved:Ke},{el:ge,sample:se})),fe.push({kind:"attr",el:ge,name:ce,source:"both"})),Ke!=null&&(se.namespaceURI?ge.setAttributeNS(se.namespaceURI,se.name,Ke):ge.setAttribute(ce,Ke))}}function Ae(L,G,re,ge){if(L==="class"){let ye=He=>new Set((He||"").split(/\s+/).filter(Boolean)),ce=ye(G),se=ye(re),Ie=ye(ge),Be=new Set;for(let He of new Set([...ce,...se,...Ie])){let Ke=ce.has(He),pt=se.has(He),tt=Ie.has(He);(pt===tt?pt:pt===Ke?tt:pt)&&Be.add(He)}return[...Be].join(" ")}if(L==="style"){let ye=Ke=>{let pt=new Map;if(!Ke)return pt;let tt=0,Kt=null,Ht="",un=()=>{let bt=Ht.indexOf(":");bt>0&&pt.set(Ht.slice(0,bt).trim(),Ht.slice(bt+1).trim()),Ht=""};for(let bt of Ke){if(Kt){Ht+=bt,bt===Kt&&(Kt=null);continue}if(bt==='"'||bt==="'"){Kt=bt,Ht+=bt;continue}if(bt==="("?tt++:bt===")"&&tt--,bt===";"&&tt===0){un();continue}Ht+=bt}return Ht.trim()&&un(),pt},ce=ye(G),se=ye(re),Ie=ye(ge),Be=new Map,He=!1;for(let Ke of new Set([...ce.keys(),...se.keys(),...Ie.keys()])){let pt=ce.get(Ke)??null,tt=se.get(Ke)??null,Kt=Ie.get(Ke)??null,Ht;tt===Kt?Ht=tt:tt===pt?Ht=Kt:Kt===pt?Ht=tt:(Ht=Ge==="local"?tt:Kt,He=!0),Ht!=null&&Be.set(Ke,Ht)}return He?void 0:[...Be].map(([Ke,pt])=>`${Ke}: ${pt}`).join("; ")}}function W(L,G,re,ge){let ye=L.value,ce=ge?ye:G?G.value:"",se=re?re.value:"";oe.add(L),G&&oe.add(G),re&&oe.add(re);let Ie=lo(ye,ce,se,Ge),Be=Ie.text===""?null:ie.createTextNode(Ie.text);Be&&(xe.set(Be,{base:L.nodes,local:G?G.nodes:null,remote:re?re.nodes:null}),qe.set(Be,Ie.mapLocalOffset)),ce!==ye&&se!==ye?fe.push({kind:"text",node:Be,source:"both"}):ce!==ye?rt({kind:"text",node:Be,source:"local"}):se!==ye&&Ot({kind:"text",node:Be,source:"remote"});for(let He of Ie.conflicts)wt({kind:"text",node:Be,base:ye.slice(He.bs,He.be),local:He.local,remote:He.remote,resolved:He.resolved},{site:"run",bRun:L,lRun:G,rRun:re,node:Be,c:He});return Be}function X(L,G){return Yn(L,G).every(re=>re.bs===re.be)}function pe(L,G){let re=L?L.value:"",ge=G?G.value:"",ye;if(re===ge||!ge?ye=re:re?X(re,ge)?ye=ge:X(ge,re)?ye=re:(ye=Ge==="local"?re:Ge==="both"?re+ge:ge,wt({kind:"structure",el:null,detail:"insert-collision",local:re,remote:ge,resolved:ye},{unit:{b:null,l:L,r:G},localLost:Ge==="remote"})):ye=ge,L&&oe.add(L),G&&oe.add(G),ye==="")return null;let ce=ie.createTextNode(ye);return xe.set(ce,{base:null,local:L?L.nodes:null,remote:G?G.nodes:null}),re?rt({kind:"insert",el:ce,source:ge&&re===ge?"both":"local"}):Ot({kind:"insert",el:ce,source:"remote"}),ce}function be(L,G){let re={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ge=Ie=>r(Ie).every(Be=>it(Be)?Vn(Be,re):Be.kind==="text"),ye=null;if(ge(L)&&ge(G)){let Ie=L.textContent,Be=G.textContent;Ie===Be||X(Be,Ie)?ye=G:X(Ie,Be)&&(ye=L)}if(!ye){let Ie=Ge==="local",Be=he(Ie?L:G,Ie?"local":"remote",!0),He=xe.get(Be);return Ie?He.remote=G:He.local=L,wt({kind:"structure",el:Be,detail:"insert-collision",local:L,remote:G,resolved:Ie?L:G},{unit:{b:null,l:L,r:G},localLost:!Ie}),Be}let ce=L.namespaceURI&&L.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(L.namespaceURI,L.tagName):ie.createElement(L.tagName);le(null,L,G,ce),xe.set(ce,{base:null,local:L,remote:G}),oe.add(L),oe.add(G);let se=ht({base:Array.from(ye.childNodes),local:Array.from(L.childNodes),remote:Array.from(G.childNodes),out:ie,policy:Ge,idOf:{local:S,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:xe,textMappers:qe,conflicts:x,conflict:wt,scope:{base:null,local:L,remote:G,units:[],at:0},synthetic:!0,decisions:fe,node:ce});ae.push(...se.segments);for(let Ie of se.nodes)ce.appendChild(Ie);return ce}function he(L,G,re=!1){if(!re&&it(L)){let se=qt.partner.get(L);if(se)return Yt(L,G,se)}if(!it(L)){if(L.value==="")return null;let se=L.kind==="comment"?ie.createComment(L.value):ie.createTextNode(L.value);return xe.set(se,{base:null,local:G==="local"?L.nodes:null,remote:G==="remote"?L.nodes:null}),oe.add(L),se}let ge=L.namespaceURI&&L.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(L.namespaceURI,L.tagName):ie.createElement(L.tagName);for(let se of L.attributes)se.namespaceURI?ge.setAttributeNS(se.namespaceURI,se.name,se.value):ge.setAttribute(se.name,se.value);xe.set(ge,{base:null,local:G==="local"?L:null,remote:G==="remote"?L:null}),oe.add(L);let ye=L.tagName==="TEMPLATE"&&ge.content?ge.content:ge,ce=G==="local"?H:q;for(let se of r(L)){let Ie=it(se)?ce.reverse.get(se):null;if(Ie&&O(Ie,null,null),Ie&&Ee.has(Ie)){wt({kind:"structure",el:null,detail:"both-moved",base:Ie},{subject:Ie});continue}if(Ie&&!De.has(Ie)){let He=a(H,Ie)||null,Ke=a(q,Ie)||null;if(He||Ke){Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(Ie,G,se,!0);let pt=U(Ie,He,Ke,!1);G==="local"?rt({kind:"move",el:pt,source:"local"}):Ot({kind:"move",el:pt,source:"remote"}),ye.appendChild(pt);continue}}let Be=he(se,G);Be&&ye.appendChild(Be)}if(!re&&qt.drop.size&&L.tagName==="DIV"&&!ye.firstChild&&!L.attributes.length&&!(G==="local"?S(L):C(L))&&!ce.reverse.has(L)&&!s(L)&&!n.remoteWins(L)){let se=L.firstChild;if(se&&se===L.lastChild&&it(se)&&(qt.drop.has(se)||cn?.has(se)))return(cn||=new WeakSet).add(L),null}return ge}function ee(L,G,re,ge,ye){G&&H.identical.has(L)&&H.pairIdenticalChildren(L),re&&q.identical.has(L)&&q.pairIdenticalChildren(L);let ce=R(H,G,L,ge),se=R(q,re,L,!1),Ie=r(L),Be=new Set(Ie),He=new Map;for(let ue=0;ue<Ie.length;ue++)He.set(Ie[ue],ue);let Ke=[],pt=new Set,tt=new Map,Kt=new Set,Ht=Xe&&[],un=Xe&&[],bt=new Set,lt=[],$e=null,vt=new Map;if(!ce.asBase&&!se.asBase&&!H.identical.has(L)&&!q.identical.has(L))for(let ue of Ie){if(!it(ue)||!Ln.has(ue.tagName))continue;let We=ce.twin(ue),Ve=se.twin(ue);We&&Ve&&(!ce.here(We)||!se.here(Ve))&&O(ue,null,null)}vo();let ct=ue=>{let We=[];for(let Ve of ue.units){if(bt.has(Ve))continue;let et=ue.baseOf(Ve);et&&Be.has(et)&&We.push(et)}return We},jt=ue=>ct(ue).map(We=>He.get(We)),bn=ue=>ue.every((We,Ve)=>Ve===0||We>=ue[Ve-1]),on=!ce.asBase&&!bn(jt(ce)),hn=!se.asBase&&!bn(jt(se));on&&hn&&wt({kind:"structure",el:ye,detail:"both-reordered",base:L},{subject:L,lKept:ct(ce),rKept:ct(se)});let Xt=hn||!on?{V:se,A:q,side:"remote",other:ce,otherA:H,otherSide:"local"}:{V:ce,A:H,side:"local",other:se,otherA:q,otherSide:"remote"};on?rt({kind:"move",el:null,source:hn?"both":"local",base:L}):hn&&Ot({kind:"move",el:null,source:"remote",base:L});let En=ce.asBase?[]:ce.units.filter(ue=>!ce.baseOf(ue)&&!bt.has(ue)&&!qt.partner.has(ue)),oo=se.asBase?[]:se.units.filter(ue=>!se.baseOf(ue)&&!bt.has(ue)&&!qt.partner.has(ue)),Rn=new Map;if(En.length&&oo.length){let ue=new Map,We=new Map;for(let Fe of oo){if(it(Fe)){let xt=C(Fe);xt&&ue.set(xt,Fe)}let ze=l.unitHash(Fe);We.has(ze)||We.set(ze,[]),We.get(ze).push(Fe)}let Ve=(Fe,ze)=>{let xt=Fe.units.indexOf(ze);for(let Ye=xt-1;Ye>=0;Ye--){let st=Fe.baseOf(Fe.units[Ye]);if(st)return st}return"start"},et=new Map,yt=new Map;for(let Fe of oo){let ze=Ve(se,Fe);it(Fe)?(yt.has(ze)||yt.set(ze,[]),yt.get(ze).push(Fe)):Fe.kind==="text"&&!et.has(ze)&&et.set(ze,Fe)}for(let Fe of En){let ze=null;if(it(Fe)){let Ye=S(Fe);Ye&&ue.has(Ye)&&!Rn.has(ue.get(Ye))&&(ze=ue.get(Ye))}else if(Fe.kind==="text"){let Ye=et.get(Ve(ce,Fe));Ye&&!Rn.has(Ye)&&(ze=Ye)}let xt=!!k(Fe);if(!ze&&!xt){let Ye=We.get(l.unitHash(Fe));Ye&&(ze=Ye.find(st=>!Rn.has(st)&&it(st)===it(Fe)&&(it(st)?st.tagName===Fe.tagName&&!J(st):st.kind===Fe.kind)&&l.equalUnits(Fe,st))||null)}if(!ze&&it(Fe)&&!xt){let Ye=m.local(Fe),st=(yt.get(Ve(ce,Fe))||[]).filter(ft=>{let Wt=m.remote(ft);return!Rn.has(ft)&&ft.tagName===Fe.tagName&&!J(ft)&&!(Ye&&Wt&&Ye!==Wt)&&l.similar(Fe,ft)});st.length===1&&(ze=st[0])}ze&&(Rn.set(ze,Fe),Rn.set(Fe,ze))}}let xo=ue=>{if(Lt?.consumes(ue))return null;if(oe.has(ue)||Nt?.has(ue))return tt.get(ue)||null;let We=ce.twin(ue),Ve=se.twin(ue),et=We&&!ce.asBase&&!ce.here(We),yt=Ve&&!se.asBase&&!se.here(Ve);if(et||yt){if((!We||!Ve)&&wt({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:We?"remote":"local"}),!Ze(ue))return it(ue)?(Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),et&&Nt.plan(ue,"local",We),yt&&Nt.plan(ue,"remote",Ve)):oe.add(ue),null;wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue})}if(We&&!Ve&&!ce.asBase&&!se.asBase&&it(ue)&&Ln.has(ue.tagName)&&!n.remoteWins(ue)&&!n.remoteWins(We)&&K(ue,We,H)&&yl(ue,Te(se.el),s)){let st={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ft=Wt=>it(Wt)?Vn(Wt,st):Wt.kind==="text";if(r(ue).every(ft)&&r(We).every(ft)){let Wt=ht({base:[ue],local:[We],remote:[],blocks:new Set([ue,We]),out:ie,policy:Ge,L:H,R:q,idOf:{base:b,local:S,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Qt,vn,_n)=>U(Qt,vn,_n,!1),cloneUnit:he,mergeAttrs:le,atomKey:l.exactUnitKey,moveIn:O,moveBuilt:O,movePlanned:O,provenance:xe,textMappers:qe,conflicts:x,conflict:wt,scope:{base:L,local:ce.el,remote:se.el,units:Ie,at:He.get(ue)},decisions:fe,node:ye});ae.push(...Wt.segments),oe.add(ue),oe.add(We);let Mt=ie.createDocumentFragment();for(let Qt of Wt.nodes)Mt.appendChild(Qt);return tt.set(ue,Mt),tt.set(We,Mt),Mt}}if(!We&&!Ve)return oe.add(ue),Ot({kind:"remove",source:"both",base:ue}),null;if(!We&&!K(ue,Ve,q))return oe.add(ue),rt({kind:"remove",source:"local",base:ue}),null;if(!Ve&&!K(ue,We,H))return oe.add(ue),Ot({kind:"remove",source:"remote",base:ue}),Xe&&(Xe.remove(We),Ht.push({bk:ue,lk:We})),null;let Fe=!We||!Ve,ze=ce.asBase?a(H,ue)||null:We,xt=se.asBase&&it(ue)&&(q.identityPaired.has(ue)||!m.base(ue))&&a(q,ue)||Ve,Ye;return it(ue)?Ye=U(ue,ze,xt,ce.asBase):ue.kind==="comment"?Ye=_e(ue,ze,Ve,ce.asBase):Ye=W(ue,ze,Ve,ce.asBase),oe.add(ue),Ye&&(tt.set(ue,Ye),We&&tt.set(We,Ye),Ve&&tt.set(Ve,Ye),Fe&&(wt({kind:"structure",el:Ye,detail:"edit-beats-delete",base:ue},{subject:ue,deleted:We?"remote":"local"}),We?rt({kind:"insert",el:Ye,source:"local"}):Ot({kind:"insert",el:Ye,source:"remote"}))),Ye},Kn=(ue,We,Ve,et)=>{if(Lt?.consumes(ue))return null;if(oe.has(ue))return tt.get(ue)||null;let yt=We.baseOf(ue);if(yt&&Be.has(yt))return bt.has(yt)&&!bt.has(ue)?Ro(yt,ue,et):xo(yt);if(yt)return ts(yt,ue,et);let Fe=Rn.get(ue);if(Fe){let xt=et==="local"?ue:Fe,Ye=et==="local"?Fe:ue,st;return it(xt)?l.equalUnits(xt,Ye)?(st=he(xt,"local"),st&&(xe.get(st).remote=Ye)):st=be(xt,Ye):st=pe(xt,Ye),oe.add(xt),oe.add(Ye),st&&(tt.set(xt,st),tt.set(Ye,st),it(xt)&&rt({kind:"insert",el:st,source:"both"})),st}let ze=he(ue,et);return ze&&(tt.set(ue,ze),et==="local"?rt({kind:"insert",el:ze,source:"local"}):(Ot({kind:"insert",el:ze,source:"remote"}),Xe&&it(ue)&&!qt.partner.has(ue)&&un.push({su:ue,node:ze}))),ze},Ro=(ue,We,Ve)=>{let et;return it(ue)?(et=O(ue,Ve,We),et&&oe.add(We)):(et=he(We,Ve),oe.add(We),et&&(Ve==="local"?rt:Ot)({kind:"insert",el:et,source:Ve})),et&&tt.set(We,et),et},ts=(ue,We,Ve)=>{O(ue,null,null);let yt=a(Ve==="local"?q:H,ue),Fe=We,ze=yt?Ut(yt,Ve==="local"?re:G,Ve==="local"?q:H):!1,xt=yt&&!ze&&!Pt(ue,yt);if(xt&&Ve===Xt.otherSide)return wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),null;if(xt&&wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),yt||wt({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:Ve==="local"?"remote":"local"}),De.has(ue)){wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue});let st=he(Fe,Ve);return st&&tt.set(We,st),st}it(ue)&&(Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(ue,Ve,Fe,!0));let Ye=it(ue)?U(ue,Ve==="local"?Fe:a(H,ue)||null,Ve==="remote"?Fe:a(q,ue)||null,!1):null;return Ye&&(tt.set(ue,Ye),tt.set(We,Ye),yt&&tt.set(yt,Ye),Ve==="local"?rt({kind:"move",el:Ye,source:"local"}):Ot({kind:"move",el:Ye,source:"remote"})),Ye};for(let ue of Xt.V.units){if(bt.has(ue)){if($e?.has(ue)){for(let et of $e.get(ue))pt.has(et)||(Ke.push(et),pt.add(et));continue}let Ve=tt.get(ue);pt.has(Ve)||(Ke.push(Ve),pt.add(Ve));continue}if(oe.has(ue)&&!(tt.get(ue)&&pt.has(tt.get(ue)))){let Ve=Xt.V.baseOf(ue);Ve&&!Be.has(Ve)&&wt({kind:"structure",el:null,detail:"both-moved",base:Ve},{subject:Ve});continue}let We=Kn(ue,Xt.V,Xt.A,Xt.side);We&&!pt.has(We)&&(Ke.push(We),pt.add(We),!Xt.V.baseOf(ue)&&!Rn.has(ue)&&!bt.has(ue)&&Kt.add(We))}for(let ue of lt)pt.has(ue.frag)||(Ke.splice(ue.previous&&pt.has(ue.previous)?Ke.indexOf(ue.previous)+1:so(ue.at),0,ue.frag),pt.add(ue.frag));if(!Xt.other.asBase){let ue=Xt.other,We=Xt.otherSide,Ve=Xt.otherA,et=null,yt=0,Fe=null;for(let ze of ue.units){let xt=vt.get(ze)||tt.get(ze);if(xt&&pt.has(xt)){et=xt,Fe=null;continue}if(oe.has(ze)){let ft=ue.baseOf(ze);ft&&!Be.has(ft)&&wt({kind:"structure",el:null,detail:"both-moved",base:ft},{subject:ft});continue}let Ye=Kn(ze,ue,Ve,We);if(!Ye)continue;let st;if(Fe)st=Ke.indexOf(Fe)+1;else if(et){if(st=Ke.indexOf(et)+1,We==="remote")for(;st<Ke.length&&Kt.has(Ke[st]);)st++}else st=yt++;Ke.splice(st,0,Ye),pt.add(Ye),Fe=Ye}}for(let ue=0;ue<Ie.length;ue++){let We=Ie[ue];if(oe.has(We))continue;let Ve=xo(We);Ve&&Ke.splice(so(ue),0,Ve)}return Xe&&Ht.length&&un.length&&Po(),Ke;function Po(){if(on||hn)return;let ue=new Set(Ke),We=ft=>ft&&Be.has(ft)&&ue.has(tt.get(ft))?ft:null,Ve=(ft,Wt)=>{let Mt=[{prev:null,units:[]}];for(let Qt of ft){let vn=We(Wt(Qt));vn?Mt.push({prev:vn,units:[]}):Mt[Mt.length-1].units.push(Qt)}return Mt},et=Ve(Ie,ft=>ft),yt=Ve(se.units,se.baseOf),Fe=ce.asBase?null:Ve(ce.units,ce.baseOf),ze=ft=>ft.length===et.length&&ft.every((Wt,Mt)=>Wt.prev===et[Mt].prev);if(!ze(yt)||Fe&&!ze(Fe))return;let xt=new Map(Ht.map(ft=>[ft.bk,ft])),Ye=new Map(un.map(ft=>[ft.su,ft])),st=ft=>ft?Ke.indexOf(tt.get(ft)):-1;for(let ft=0;ft<et.length;ft++){if(et[ft].units.length!==1||yt[ft].units.length!==1)continue;let Wt=xt.get(et[ft].units[0]),Mt=Ye.get(yt[ft].units[0]);if(!Wt||!Mt||Fe&&(Fe[ft].units.length!==1||Fe[ft].units[0]!==Wt.lk))continue;let Qt=st(et[ft].prev);(ft+1<et.length?st(et[ft+1].prev):Ke.length)-Qt!==2||Ke[Qt+1]!==Mt.node||To(Wt.bk,Wt.lk,Mt.su)&&Xe.link(Wt.lk,Mt.node)}}function Fn(ue,We,Ve,et){let yt=Mt=>{let Qt=Mt.filter(it);return Qt.length===1?Qt[0]:null},Fe=yt(ue),ze=yt(We),xt=yt(Ve);if(!Fe||!ze||!xt)return;let Ye=ue.indexOf(Fe);if(We.indexOf(ze)!==Ye||Ve.indexOf(xt)!==Ye||ue.length!==We.length||ue.length!==Ve.length)return;for(let Mt=0;Mt<ue.length;Mt++)if(Mt!==Ye&&(ue[Mt].value!==We[Mt].value||ue[Mt].value!==Ve[Mt].value))return;if((ce.asBase?Fe:ce.twin(Fe))!==ze||se.twin(Fe)||q.reverse.get(xt)||ze!==Fe&&K(Fe,ze,H))return;let st=et.filter(Mt=>Mt.nodeType===1);if(st.length!==1||xe.get(st[0])?.remote!==xt)return;let ft=Mt=>Mt.map(Qt=>it(Qt)?"":Qt.value??Qt.nodeValue).join(""),Wt=et.indexOf(st[0]);ft(et.slice(0,Wt))!==ft(ue.slice(0,Ye))||ft(et.slice(Wt+1))!==ft(ue.slice(Ye+1))||To(Fe,ze,xt)&&Xe.link(ze,st[0])}function To(ue,We,Ve){if(!it(We)||!it(Ve)||!it(ue)||We.namespaceURI!==Ve.namespaceURI||We.localName===Ve.localName)return!1;for(let ze of[We,Ve])if(ze.tagName==="TEMPLATE"||pn(ze)||ze.querySelector("template"))return!1;if(n.remoteWins(ue)||n.remoteWins(Ve)||s(Ve)||We.attributes.length!==Ve.attributes.length)return!1;for(let ze of We.attributes)if(Ve.getAttributeNS(ze.namespaceURI,ze.localName)!==ze.value)return!1;let et=We.childNodes,yt=Ve.childNodes;if(et.length!==yt.length)return!1;for(let ze=0;ze<et.length;ze++)if(!et[ze].isEqualNode(yt[ze]))return!1;let Fe=[[ue,Ve]];for(;Fe.length;){let[ze,xt]=Fe.pop();if(ze.children.length!==xt.children.length)return!1;for(let Ye=0;Ye<xt.children.length;Ye++){let st=q.reverse.get(xt.children[Ye]);if(st!==void 0&&st!==ze.children[Ye])return!1;Fe.push([ze.children[Ye],xt.children[Ye]])}}return!0}function so(ue){for(let We=ue-1;We>=0;We--){let Ve=tt.get(Ie[We]);if(Ve){let et=Ke.indexOf(Ve);if(et>=0)return et+1}}return 0}function vo(){if((ce.asBase||H.identical.has(L))&&(se.asBase||q.identical.has(L)))return;let ue={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},We=ut=>it(ut)?Vn(ut,ue):ut.kind==="text";if(!ce.asBase&&!se.asBase)for(let ut of Ie){if(!it(ut)||!Ln.has(ut.tagName))continue;let Qe=ce.twin(ut),Et=se.twin(ut);if(!Qe&&Et||Qe&&!Et){let ot=Br({base:Ie,views:[{V:ce,A:H,idOf:m.local},{V:se,A:q,idOf:m.remote}],eligible:At=>it(At)&&Ln.has(At.tagName)&&!s(At)&&!n.remoteWins(At),baseId:m.base,ignored:s,remoteWins:n.remoteWins,atomKey:l.exactUnitKey});ot&&(ce=ot[0],se=ot[1]);break}}let Ve=!ce.asBase&&!se.asBase&&Ie.length>=2&&Ln.has(Ie[0].tagName)&&ce.units.length===Ie.length&&se.units.length===Ie.length?mr({base:Ie,local:ce.units,remote:se.units,localTwin:ce.twin,remoteTwin:se.twin,eligible:ut=>it(ut)&&Ln.has(ut.tagName)&&!s(ut)&&!n.remoteWins(ut),nodes:{base:Array.from(Te(L).childNodes),local:Array.from(Te(ce.el).childNodes),remote:Array.from(Te(se.el).childNodes)}}):null,et=null,yt=null;if(!Ve&&!ce.asBase&&!se.asBase&&(Es(Ie)||Es(ce.units)||Es(se.units))){let ut={ignored:s,remoteWins:()=>!1},Qe=ot=>We(ot)||it(ot)&&n.remoteWins(ot)&&Tn.has(ot.tagName)&&Vn(ot,ut),Et=ot=>it(ot)?Ln.has(ot.tagName)&&!s(ot)&&!n.remoteWins(ot)&&r(ot).every(Qe):ot.kind==="text";et=jr({onUncertainOwner:ot=>{let At=n.identity.local(ot.local);At&&At===n.identity.remote(ot.remote)||(yt||=[]).push(ot)},onUncertainSource:ot=>{nt||(nt=new Map);let At=nt.get(ot.source);At||nt.set(ot.source,At=[]);for(let Jt of At)if(Jt.side===ot.side&&Jt.from===ot.from&&Jt.to===ot.to)return;At.push(ot)},base:Ie,views:[{V:ce,A:H,idOf:m.local},{V:se,A:q,idOf:m.remote}],eligible:Et,ignored:s,remoteWins:n.remoteWins,baseId:m.base,atomKey:l.exactUnitKey})}if(yt){$e||=new Map;for(let ut of yt){let{source:Qe,local:Et,remote:ot}=ut,At={map:new Map,reverse:new Map,identical:new Set},Jt=ht({base:[Qe],local:[Et],remote:[ot],out:ie,policy:"both",L:At,R:At,ignored:s,remoteWins:n.remoteWins,atomKey:l.exactUnitKey,cloneUnit:he,provenance:xe,textMappers:qe,conflicts:x,decisions:fe,conflict:(Rt,Ft)=>wt(Rt,{...Ft,policy:"both"}),scope:{base:L,local:ce.el,remote:se.el,units:Ie,at:He.get(Qe)},node:ye});ae.push(...Jt.segments);for(let Rt of[Qe,Et,ot])oe.add(Rt),bt.add(Rt),$e.set(Rt,Jt.nodes),tt.set(Rt,Jt.nodes[Jt.nodes.length-1]);for(let Rt=0;Rt<Jt.nodes.length;Rt++)lt.push({frag:Jt.nodes[Rt],at:He.get(Qe),previous:Rt?Jt.nodes[Rt-1]:null})}}let Fe=Ve?Ve.blocks:null;if(et){Fe=new Set;for(let ut of et.blocks)Fe.add(ut)}let ze=ut=>!Lt?.consumes(ut)&&(Fe&&Fe.has(ut)||We(ut)),xt=Ie.map(ze);if(!xt.includes(!0))return;let Ye=ut=>{let Qe=ut.units,Et=new Map;for(let tn=0;tn<Qe.length;tn++)Et.set(Qe[tn],tn);let ot=[],At=-1;for(let tn=0;tn<Ie.length;tn++){if(xt[tn])continue;let Tt=ut.twin(Ie[tn]),mt=Tt?Et.get(Tt):void 0;mt===void 0||mt<=At||ze(Tt)||(ot.push([tn,mt]),At=mt)}let Jt=[],Rt=-1,Ft=-1;for(let tn=0;tn<=ot.length;tn++){let[Tt,mt]=tn<ot.length?ot[tn]:[Ie.length,Qe.length],St={bLo:-1,bHi:-1,from:Ft+1,to:mt,inlineStart:-1,inlineEnd:-1,next:mt};for(let Zt=Rt+1;Zt<Tt;Zt++)xt[Zt]&&(St.bLo<0&&(St.bLo=Zt),St.bHi=Zt);for(let Zt=Ft+1;Zt<mt;Zt++){let zn=Qe[Zt];ze(zn)&&(St.inlineStart<0&&(St.inlineStart=Zt),St.inlineEnd=Zt+1)}Jt.push(St),Rt=Tt,Ft=mt}return{units:Qe,list:Jt}},st=Ye(ce),ft=Ye(se),Wt=[];for(let ut of[st,ft])for(let Qe of ut.list)Qe.bLo>=0&&Wt.push([Qe.bLo,Qe.bHi]);Wt.sort((ut,Qe)=>ut[0]-Qe[0]);let Mt=[];for(let[ut,Qe]of Wt){let Et=Mt[Mt.length-1];Et&&ut<=Et.hi?Et.hi=Math.max(Et.hi,Qe):Mt.push({lo:ut,hi:Qe})}let Qt=(ut,Qe)=>ut.length===Qe.length&&ut.every((Et,ot)=>l.equalUnits(Et,Qe[ot])),vn=ut=>!it(ut)&&ut.kind==="comment",_n=ut=>{if(!ut.length)return[];let Qe=(Rt,Ft)=>it(Rt)?Rt:Rt.nodes[Ft?Rt.nodes.length-1:0],Et=Qe(ut[0]),ot=Qe(ut[ut.length-1],!0),At=Rt=>Rt&&it(Rt)&&s(Rt);for(;At(Et.previousSibling);)Et=Et.previousSibling;for(;At(ot.nextSibling);)ot=ot.nextSibling;let Jt=[];for(let Rt=Et;Rt&&(Jt.push(Rt),Rt!==ot);Rt=Rt.nextSibling);return Jt},Pn=ut=>ut.some(Qe=>it(Qe)&&s(Qe));for(let ut of Mt){let Qe=Ie.slice(ut.lo,ut.hi+1),Et=null;if(et)for(let Tt of Qe){let mt=et.certificatesBySource.get(Tt);mt&&(Et||=[]).push(...mt)}let ot=ce.asBase?null:Ls(st,ut),At=se.asBase?null:Ls(ft,ut);if(Et){let Tt=[new Set(ot||Qe),new Set(At||Qe)],mt=Et.some(St=>!Tt[St.side].has(St.target));for(let St of Qe)if(Fe.has(St))for(let[Zt,zn]of[[0,ce],[1,se]]){let Sn=zn.twin(St);Sn&&zn.here(Sn)&&!Tt[Zt].has(Sn)&&(mt=!0)}if(mt)continue}if(Qe.some(vn)||ot&&ot.some(vn)||At&&At.some(vn))continue;let Jt=_n(ot||Qe),Rt=_n(At||Qe);if((!ot||Qt(Qe,ot))&&(!At||Qt(Qe,At))&&!(ot&&Pn(Jt)))continue;let Ft=ht({base:_n(Qe),sourceRetentions:nt?.get(L),local:Jt,remote:Rt,out:ie,policy:Ge,blocks:Fe,scopeUnits:Et?[Qe,ot||Qe,At||Qe]:null,certifiedOrigins:Et?(Tt,mt,St,Zt,zn,Sn)=>Dr({certificates:Et,scopes:[Qe,ot||Qe,At||Qe],flats:[Tt,mt,St],keys:[Zt,zn,Sn]}):null,prepared:Ve?Ve.prepared:null,nativeTransfers:Ve,L:ot?H:Ur(H,L),R:At?q:Ur(q,L),idOf:{base:b,local:S,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Tt,mt,St)=>U(Tt,mt,St,!1),cloneUnit:he,mergeAttrs:le,atomKey:l.exactUnitKey,moveIn:O,moveBuilt:O,movePlanned:O,provenance:xe,textMappers:qe,conflicts:x,conflict:wt,scope:{base:L,local:ce.asBase?null:ce.el,remote:se.asBase?null:se.el,units:Ie,at:ut.lo},decisions:fe,node:ye});if(!Ft){if(Et){let Tt=gr({certificates:Et,scopes:[Qe,ot||Qe,At||Qe],views:[{V:ce,A:H,idOf:m.local},{V:se,A:q,idOf:m.remote}],eligible:mt=>it(mt)&&Ln.has(mt.tagName)&&!s(mt)&&!n.remoteWins(mt),baseId:m.base});for(let mt of Tt.records){nt||=new Map;let St=nt.get(mt.source);St||nt.set(mt.source,St=[]),St.push(mt)}}continue}if(ae.push(...Ft.segments),Ve){let Tt=new Map;for(let mt of Ft.nodes){let St=xe.get(mt)?.base;if(!St||Tt.has(St))throw new Error("Invalid native transfer owner output");Tt.set(St,mt)}if(Tt.size!==Ve.owners.length)throw new Error("Incomplete native transfer owner output");for(let mt of Ve.owners){let St=Tt.get(mt.base);if(!St)throw new Error("Missing native transfer owner output");for(let Zt of[mt.base,mt.local,mt.remote])oe.add(Zt),bt.add(Zt),tt.set(Zt,St);lt.push({frag:St,at:He.get(mt.base)})}continue}if(Xe&&Fn(Qe,ot||Qe,At||Qe,Ft.nodes),Ft.unitOutputs){$e||=new Map;for(let mt of[...Qe,...ot||[],...At||[]]){let St=Ft.unitOutputs.get(mt)||[];oe.add(mt),bt.add(mt),$e.set(mt,St),St.length&&tt.set(mt,St[St.length-1])}let Tt=Ft.nodes[Ft.nodes.length-1];if(Tt)for(let mt of[ot||Qe,At||Qe]){let St=mt[mt.length-1];St&&vt.set(St,Tt)}for(let mt=0;mt<Ft.nodes.length;mt++)lt.push({frag:Ft.nodes[mt],at:ut.lo,previous:mt>0?Ft.nodes[mt-1]:null});continue}Xe&&Fn(Qe,ot||Qe,At||Qe,Ft.nodes);let tn=ie.createDocumentFragment();for(let Tt of Ft.nodes)tn.appendChild(Tt);for(let Tt of[...Qe,...ot||[],...At||[]])oe.add(Tt),bt.add(Tt),tt.set(Tt,tn);lt.push({frag:tn,at:ut.lo})}}}function te(L,G){let re=xe.get(L);return re&&re.unchanged?!re.remote||re.remote===G?!0:z(re.remote,G):L.tagName!==G.tagName||!Ce(L,G)?!1:Pe(Te(L),Te(G))}function z(L,G){return L===G?!0:L.tagName!==G.tagName||L.namespaceURI!==G.namespaceURI||!Ce(L,G)?!1:ne(Te(L),Te(G))}function ne(L,G){let re=ve(L,s),ge=ve(G,s);if(re.length!==ge.length)return!1;for(let ye=0;ye<re.length;ye++){let ce=re[ye],se=ge[ye];if(typeof ce=="string"||typeof se=="string"){if(ce!==se)return!1}else{if(ce.nodeType!==se.nodeType)return!1;if(ce.nodeType===1){if(!z(ce,se))return!1}else if(ce.nodeValue!==se.nodeValue)return!1}}return!0}function Te(L){return L.tagName==="TEMPLATE"&&L.content?L.content:L}function Ce(L,G){let re=0;for(let ge of L.attributes)if(!n.ignoreAttribute(L,ge.name)&&(re++,G.getAttribute(ge.name)!==ge.value))return!1;for(let ge of G.attributes)n.ignoreAttribute(G,ge.name)||re--;return re===0}function Pe(L,G){let re=ve(L,ye=>{let ce=xe.get(ye);return!!(ce&&ce.pinned)}),ge=ve(G,s);if(re.length!==ge.length)return!1;for(let ye=0;ye<re.length;ye++){let ce=re[ye],se=ge[ye];if(typeof ce=="string"||typeof se=="string"){if(ce!==se)return!1}else{if(ce.nodeType!==se.nodeType)return!1;if(ce.nodeType===1){if(!te(ce,se))return!1}else if(ce.nodeValue!==se.nodeValue)return!1}}return!0}function ve(L,G){let re=[],ge=null;for(let ye=L.firstChild;ye;ye=ye.nextSibling){if(ye.nodeType===3){ge=ge===null?ye.nodeValue:ge+ye.nodeValue;continue}ye.nodeType===1&&G(ye)||(ge!==null&&(ge!==""&&re.push(ge),ge=null),re.push(ye))}return ge!==null&&ge!==""&&re.push(ge),re}function _e(L,G,re,ge){let ye=L.value,ce=ge?ye:G?G.value:"",se=re?re.value:"";oe.add(L),G&&oe.add(G),re&&oe.add(re);let Ie=ce===se?ce:ce===ye?se:se===ye||Ge==="local"?ce:se,Be={site:"comment",bRun:L,lRun:G,rRun:re,node:null};if(ce!==ye&&se!==ye&&ce!==se&&wt({kind:"text",node:null,base:ye,local:ce,remote:se,resolved:Ie},Be),!G&&!re)return null;let He=ie.createComment(Ie);return Be.node=He,xe.set(He,{base:L.nodes,local:G?G.nodes:null,remote:re?re.nodes:null}),He}function Je(L,G){let re=a(G,L);if(!re)return null;let ge=it(re)?re.parentNode:re.parent,ye=it(L)?L.parentNode:L.parent;return a(G,ye)===ge?null:G.reverse.get(ge)||null}function Ze(L){let G=new Set([L]),re=L;for(let ge=0;ge<64;ge++){let ye=Je(re,H)||Je(re,q);if(!ye)return!1;if(ye===L||it(L)&&it(ye)&&L.contains(ye)||G.has(ye))return!0;G.add(ye),re=ye}return!0}function Ut(L,G,re){if(!G)return!1;let ge=it(L)?L.parentNode:L.parent;return ge===G||G.tagName==="TEMPLATE"&&ge===G.content}function Pt(L,G){let re=Re(L),ge=a(H,re);if(ge&&Ut(G,ge,H))return!0;let ye=a(q,re);return!!(ye&&Ut(G,ye,q))}}function Ur(e,o){return e.map.get(o)?Vr():{map:{get:n=>n&&n.nodeType===1&&e.map.get(n)||n,has:()=>!0},reverse:{get:n=>e.reverse.get(n)||n,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Vr(){let e={get:o=>o,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Hr=new Set(["INPUT","OPTION","TEXTAREA"]),Ps=/[\t\n\f\r ]+/;function Wr(e,o,t,n){let s=e.ownerDocument,{provenance:h,textMappers:l}=t,r=n.hooks,i=[],u=[],w=[],c=new Set,p=[],b=[],S=new Map,C=new Set,m=new Map,f=t.conflicts.length>0||n.trackInserted===!0,g=new Map,I=new Set,v=new Map,T=(a,O)=>{let R=v.get(a);R||v.set(a,R=new Set),R.add(O)},A=f?new Set:null,E=(a,O,R)=>{let K=r.beforeAttributeUpdated(a,O,R);return f&&K===!1&&T(O,a),K},N=a=>!!a&&(a===e||e.contains(a)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(a)),M=new Map,P=new Map,V=new Map,D=new Set,j=new Map;(function a(O){let R=h.get(O);if(R){if(O.nodeType===1){let Z=R.local?n.toLive(R.local):null;Z&&N(Z)&&Z.nodeType===1&&(M.set(O,Z),P.set(Z,O))}else if(Array.isArray(R.local)){let Z=q(R.local,R.local.map(U=>n.toLive(U)).filter(U=>U&&N(U)&&U.nodeType===O.nodeType));if(Z.length&&(M.set(O,Z[0]),P.set(Z[0],O),V.set(O,Z)),Array.isArray(R.caret))for(let U of R.caret){let de=n.toLive(U.node);if(!de||!N(de)||de.nodeType!==3)continue;let we=j.get(de);Array.isArray(we)||j.set(de,we=[]),we.push({merged:O,from:U.from,to:U.to,flatStart:U.flatStart})}else{let U=0;for(let de of Z)j.set(de,{merged:O,shift:U}),U+=de.nodeValue.length}}}let K=O.nodeType===1&&O.tagName==="TEMPLATE"&&O.content?O.content.childNodes:O.childNodes;for(let Z of K)a(Z)})(o);let y=new Set;for(let a of M.values())y.add(a);for(let a of V.values())for(let O of a)y.add(O);let k=n.localRoot&&n.localRoot!==e?new Set:null;if(k){for(let a=n.localRoot.firstElementChild;a;a=a.nextElementSibling)if(a.tagName==="HEAD")for(let O=a.firstElementChild;O;O=O.nextElementSibling){let R=n.toLive(O);R&&k.add(R)}}for(let a of t.segments||[])Me(a);let J=n.restoreFocus===!1?null:kl(s,j);n.childrenOnly?xe(Oe(e),Oe(o)):Re(e,o);for(let{node:a,parent:O}of p)c.has(a)||!a.parentNode||a.nodeType===1&&(n.ignored(a)||qe(a))||nt(a,O);return xl(s,J,j,l,V,m,D),{applied:i,moved:u,replaced:w,identities:b,mergedScriptsLive:C,liveOf:M,heldBy:m,runOf:V,keptRuns:D,insertedLive:g,vetoed:I,vetoedAttrs:v,removedVetoes:A};function H(a,O){let R=a.slice(O.bs,O.be),K=0;for(;K<R.length&&K<O.text.length&&R[K]===O.text[K];)K++;let Z=0;for(;Z<R.length-K&&Z<O.text.length-K&&R[R.length-1-Z]===O.text[O.text.length-1-Z];)Z++;return{bs:O.bs+K,be:O.be-Z,text:O.text.slice(K,O.text.length-Z)}}function q(a,O){if(!O.length)return O;let R=[];for(let U of a){let de=U.parentNode;if(!de)continue;let we=S.get(de);if(!we){we=new Set;for(let le=de.firstChild;le;le=le.nextSibling)le.nodeType===3&&we.add(n.toLive(le));S.set(de,we)}R.includes(we)||R.push(we)}let K={has:U=>R.some(de=>de.has(U))},Z=[];for(let U of O){Z.push(U);for(let de=U.nextSibling;de&&de.nodeType===3&&!K.has(de)&&!Z.includes(de);de=de.nextSibling)Z.push(de)}return Z}function Me(a){let O=[];for(let ee of a.localNodes){let te=n.toLive(ee.node);if(!te||!N(te)||te.nodeType!==3)return;O.push(te)}let R=q(a.localNodes.map(ee=>ee.node),O);if(!R.length)return;let K=R.map(ee=>ee.nodeValue).join(""),{flatLocal:Z,lToM:U,mapLocal:de}=a;if(K===Z)return;let we=a.textNodes.map(ee=>({node:ee.node,ms:ee.ms,me:ee.me})),le=[],Ae=0;for(let ee of R)le.push(Ae),Ae+=ee.nodeValue.length;let W=(ee,te)=>R.find((z,ne)=>le[ne]<=ee&&ee+te<=le[ne]+z.nodeValue.length)||null,X=[],pe=0;for(let ee of Yn(Z,K).map(te=>H(Z,te))){let te=ee.bs+pe;pe+=ee.text.length-(ee.be-ee.bs);let z,ne;if(ee.be>ee.bs){z=U[ee.bs];let Te=z>=0;for(let Ce=ee.bs;Te&&Ce<ee.be;Ce++)U[Ce]!==z+(Ce-ee.bs)&&(Te=!1);if(!Te)continue;ne=z+(ee.be-ee.bs)}else{let Te=ee.bs>0?U[ee.bs-1]:0,Ce=ee.bs<Z.length?U[ee.bs]:0;if(Te<0||Ce<0)continue;z=ne=de(ee.bs)}X.push({ms:z,me:ne,text:ee.text,live:ne===z?W(te,ee.text.length):null})}X.sort((ee,te)=>te.ms-ee.ms);let be=(ee,te)=>(V.get(ee.node)||[M.get(ee.node)]).includes(te),he=ee=>!!ee&&ee.nodeType===1&&Tn.has(ee.tagName);for(let ee of X){let te=we.find(ne=>ne.ms<=ee.ms&&ee.me<=ne.me&&ee.ms<ne.me);if(te&&ee.live&&te.ms===ee.ms&&!be(te,ee.live)){let ne=we.find(Te=>Te.me===ee.ms&&be(Te,ee.live));ne&&(te=ne)}if(!te&&ee.me===ee.ms){let ne=we.find(ve=>ve.me===ee.ms),Te=we.find(ve=>ve.ms===ee.ms),Ce=ne||Te;if(!Ce)continue;let Pe=Ce.node;for(;he(Pe.parentNode)&&(ne?Pe.parentNode.lastChild:Pe.parentNode.firstChild)===Pe;)Pe=Pe.parentNode;if(Pe===Ce.node)te=Ce;else{let ve=Pe.ownerDocument.createTextNode(ee.text);Pe.parentNode.insertBefore(ve,ne?Pe.nextSibling:Pe);continue}}if(!te)continue;let z=te.node.nodeValue;te.node.nodeValue=z.slice(0,ee.ms-te.ms)+ee.text+z.slice(ee.me-te.ms),te.me+=ee.text.length-(ee.me-ee.ms)}}function Oe(a){return a.nodeType===1&&a.tagName==="TEMPLATE"&&a.content?a.content:a}function Re(a,O){c.add(a);let R=h.get(O);if(R&&R.remote&&t.remoteIdOf){let Z=t.remoteIdOf(R.remote);Z&&b.push([a,Z])}if(R&&R.unchanged){n.opaque&&n.opaque(a)||(t.customIdentity&&R.remote&&ae(a,R.remote),R.remote&&Y(a,R.remote));return}if(r.beforeNodeMorphed(a,O)===!1){I.add(O);return}Ct(a,O,n.keepLiveOnly&&R&&R.local&&R.local.nodeType===1&&R.local!==a?R.local:null);let K=a.tagName;if(pn(a))a.textContent!==O.textContent&&(i.push({kind:"text",node:a,before:a.textContent,after:O.textContent}),a.textContent=O.textContent),t.mergedScripts.has(O)&&C.add(a);else if(K==="TEXTAREA")$(a,O,R);else{Yt(a,O,R);let Z=K==="TEMPLATE"&&a.content?a.content:a,U=K==="TEMPLATE"&&O.content?O.content:O;n.opaque&&n.opaque(a)||n.protectFocusedValue==="subtree"&&Nt(a)&&a!==s.body?ie(Z):xe(Z,U)}r.afterNodeMorphed(a,O)}function ie(a){for(let O=a.firstChild;O;O=O.nextSibling){let R=P.get(O);R&&M.get(R.parentNode)!==a||(c.add(O),O.nodeType===1&&ie(O))}}function xe(a,O){let R=De(a.firstChild),K=new Set;for(let Z of Array.from(O.childNodes)){let U=M.get(Z);U&&c.has(U)&&!K.has(U)&&(U=null);let de=h.get(Z);if(de&&de.pinned){U&&U.nodeType===1&&((U.parentNode!==a||De(U.nextSibling)!==R)&&Ne(a,U,R),c.add(U),K.add(U));continue}if(U&&U.nodeType===1){if(U!==R){let Ae=U.parentNode;if(Ae===a&&R&&Lt(U)){let W=U.nextSibling;for(let X=R;X&&X!==U;){let pe=X.nextSibling;Ne(a,X,W),X=pe}}else Ne(a,U,R),Ae!==a&&(u.push(U),i.push({kind:"move",el:U,from:Ae,to:a}))}K.add(U),Re(U,Z),R=De(U.nextSibling);continue}if(U&&U.nodeType!==1){let Ae=V.get(Z)||[U],W=Ae.map(pe=>pe.nodeValue).join(""),X=Z.nodeValue;if(Z.nodeType===3){let pe=fe(Z);pe!=null&&W!==pe&&(X=lo(pe,W,Z.nodeValue).text)}if(Ae.length>1&&W===X&&!Ae.includes(R,1)&&Ae.every((pe,be)=>pe.parentNode===a&&(be===0||Ae[be-1].nextSibling===pe))){if(U!==R)for(let pe of Ae)Ne(a,pe,R);r.beforeNodeMorphed(U,Z)!==!1?r.afterNodeMorphed(U,Z):f&&I.add(Z);for(let pe of Ae)c.add(pe),K.add(pe);m.set(Z,U),D.add(Z),R=De(Ae[Ae.length-1].nextSibling);continue}U!==R&&Ne(a,U,R),r.beforeNodeMorphed(U,Z)!==!1?(U.nodeValue!==X&&(i.push({kind:"text",node:U,before:U.nodeValue,after:X}),U.nodeValue=X),r.afterNodeMorphed(U,Z)):I.add(Z),c.add(U),K.add(U),m.set(Z,U),R=De(U.nextSibling);continue}if(Z.nodeType===3&&R&&R.nodeType===3&&!c.has(R)&&!j.has(R)){R.nodeValue!==Z.nodeValue&&(i.push({kind:"text",node:R,before:R.nodeValue,after:Z.nodeValue}),R.nodeValue=Z.nodeValue),c.add(R),m.set(Z,R),R=De(R.nextSibling);continue}let we=h.get(Z),le=Xe(we&&we.unchanged&&we.remote?we.remote:Z);if(r.beforeNodeAdded(le)===!1){I.add(Z);continue}a.insertBefore(le,R),c.add(le),f&&g.set(Z,le),le.nodeType===3&&m.set(Z,le),le.nodeType===1&&(w.push(le),Ee(le,Z),t.customIdentity&&we&&we.unchanged&&we.remote&&ae(le,we.remote),pn(le)||ht(le,Z),n.formState==="property"&&rn(we)&&Y(le,we.remote)),R=De(le.nextSibling),i.push({kind:"insert",node:le,parent:a}),r.afterNodeAdded(le)}for(let Z of Array.from(a.childNodes))c.has(Z)||K.has(Z)||Z.nodeType===1&&(n.ignored(Z)||qe(Z))||(y.has(Z)?p.push({node:Z,parent:a}):nt(Z,a))}function qe(a){return a.parentNode&&a.parentNode.nodeType===1&&a.parentNode.tagName==="HEAD"&&(k&&!k.has(a)||n.preserve&&n.preserve(a)===!0)}function fe(a){let O=h.get(a);return!O||!Array.isArray(O.local)?null:O.local.map(R=>R.nodeValue).join("")}function x(a){return h.get(a)}function Y(a,O){if(!Hr.has(a.tagName)&&!a.querySelector("input,option,textarea"))return;let R=(K,Z)=>{if(K.tagName!==Z.tagName||(K.tagName==="TEXTAREA"?$(K,Z,{remote:Z}):Hr.has(K.tagName)&&Yt(K,Z,{remote:Z}),n.opaque&&n.opaque(K)))return;let U=oe(K),de=oe(Z);if(U.length===de.length)for(let we=0;we<U.length;we++)R(U[we],de[we])};R(a,O)}function ae(a,O){if(n.opaque&&n.opaque(a))return;let R=oe(a),K=oe(O);if(R.length===K.length)for(let Z=0;Z<R.length;Z++){let U=t.remoteIdOf(K[Z]);U&&b.push([R[Z],U]),ae(R[Z],K[Z])}}function oe(a){let O=a.tagName==="TEMPLATE"&&a.content?a.content:a;return Array.from(O.children).filter(R=>!n.ignored(R))}function Ee(a,O){if(!t.remoteIdOf)return;let R=(K,Z)=>{let U=h.get(Z);if(U&&U.remote&&Z.nodeType===1){let le=t.remoteIdOf(U.remote);le&&b.push([K,le])}let de=K.childNodes,we=Z.childNodes;for(let le=0;le<de.length&&le<we.length;le++)R(de[le],we[le])};R(a,O)}function De(a){for(;a&&a.nodeType===1&&n.ignored(a);)a=a.nextSibling;return a}function Ne(a,O,R){if(typeof a.moveBefore=="function"&&O.ownerDocument===a.ownerDocument)try{a.moveBefore(O,R);return}catch{}a.insertBefore(O,R)}function nt(a,O){if(r.beforeNodeRemoved(a)===!1){f&&A.add(a);return}a.parentNode.removeChild(a),i.push({kind:"remove",node:a,parent:O}),r.afterNodeRemoved(a)}function Xe(a){if(pn(a))return Mo(a,s);let O=s.importNode(a,!0);if(O.nodeType===1)for(let R of Array.from(O.querySelectorAll("script")))pn(R)&&R.replaceWith(Mo(R,s));return O}function ht(a,O){let R=a.tagName==="TEMPLATE"&&a.content?a.content:a,K=O.tagName==="TEMPLATE"&&O.content?O.content:O,Z=Array.from(R.childNodes),U=Array.from(K.childNodes);for(let de=0;de<U.length&&de<Z.length;de++){let we=U[de],le=Z[de],Ae=M.get(we);Ae&&c.has(Ae)&&(Ae=null);let W=h.get(we);if(W&&W.pinned){if(Ae&&Ae.nodeType===1){let X=Ae.parentNode;Ne(R,Ae,le),X!==R&&(u.push(Ae),i.push({kind:"move",el:Ae,from:X,to:R})),c.add(Ae)}le.remove();continue}if(Ae){let X=Ae.parentNode;Ne(R,Ae,le),le.remove(),Ae.nodeType===1?(X!==R&&(u.push(Ae),i.push({kind:"move",el:Ae,from:X,to:R})),Re(Ae,we)):(c.add(Ae),m.set(we,Ae),Ae.nodeValue!==we.nodeValue&&(i.push({kind:"text",node:Ae,before:Ae.nodeValue,after:we.nodeValue}),Ae.nodeValue=we.nodeValue));continue}c.add(le),f&&g.set(we,le),le.nodeType===3&&m.set(we,le),W&&W.unchanged&&W.remote?(Ge(le,W.remote),t.customIdentity&&ae(le,W.remote)):we.nodeType===1&&!pn(we)&&ht(le,we)}}function Ge(a,O){let R=a.tagName==="TEMPLATE"&&a.content?a.content:a,K=O.tagName==="TEMPLATE"&&O.content?O.content:O;for(let Z of Array.from(K.childNodes))R.appendChild(Xe(Z))}function rt(a,O){return O.namespaceURI?a.getAttributeNS(O.namespaceURI,O.localName):a.getAttribute(O.name)}function Ot(a,O){let R=new Set((O||"").split(Ps).filter(Boolean));return(a||"").split(Ps).filter(K=>K&&!R.has(K))}function Ct(a,O,R){for(let K of Array.from(O.attributes)){if(wt(a,K.name)||n.ignoreAttribute(a,K.name,O))continue;let Z=rt(a,K);if(Z===K.value||R&&rt(R,K)===K.value)continue;let U=K.value;if(R&&K.name==="class"&&!K.namespaceURI){let de=K.value.split(Ps).filter(Boolean),we=Ot(Z,R.getAttribute("class")).filter(le=>!de.includes(le));we.length&&(U=[...de,...we].join(" "))}if(Z!==U){if(r.beforeAttributeUpdated(K.name,a,"update")===!1){f&&T(O,K.name);continue}K.namespaceURI?a.setAttributeNS(K.namespaceURI,K.name,U):a.setAttribute(K.name,U),i.push({kind:"attr",el:a,name:K.name,before:Z,after:U})}}for(let K of Array.from(a.attributes)){if(wt(a,K.name)||n.ignoreAttribute(a,K.name,O)||(K.namespaceURI?O.hasAttributeNS(K.namespaceURI,K.localName):O.hasAttribute(K.name)))continue;if(R&&K.name==="class"&&!K.namespaceURI){let de=Ot(K.value,R.getAttribute("class"));if(de.length){let we=de.join(" ");if(we===K.value)continue;if(r.beforeAttributeUpdated("class",a,"update")===!1){f&&T(O,"class");continue}a.setAttribute("class",we),i.push({kind:"attr",el:a,name:"class",before:K.value,after:we});continue}}if(R&&rt(R,K)===null&&!n.ignoreAttribute(R,K.name))continue;if(r.beforeAttributeUpdated(K.name,a,"remove")===!1){f&&T(O,K.name);continue}let U=K.value;K.namespaceURI?a.removeAttributeNS(K.namespaceURI,K.localName):a.removeAttribute(K.name),i.push({kind:"attr",el:a,name:K.name,before:U,after:null})}}function wt(a,O){let R=a.tagName;return R==="INPUT"?O==="value"||O==="checked"||O==="disabled":R==="OPTION"?O==="selected":!1}function Nt(a){return a===s.activeElement}function Lt(a){let O=s.activeElement;return!!O&&O!==s.body&&a.contains(O)}function qt(a,O){let R=O&&O.local&&O.local.nodeType===1&&O.local!==a?O.local:null;if(!R)return!0;let K=a.tagName==="TEXTAREA"?R.textContent:R.getAttribute("value")??"";return a.value!==K}function cn(a,O){return!!n.protectFocusedValue&&Nt(a)&&qt(a,O)}function It(a,O,R){let K=Math.min(a.length,O.length),Z=0;for(;Z<K&&a[Z]===O[Z];)Z++;if(R<=Z)return R;let U=0;for(;U<K-Z&&a[a.length-1-U]===O[O.length-1-U];)U++;return R>=a.length-U?R+O.length-a.length:O.length-U}function Gt(a){try{return a.selectionStart==null?null:[a.selectionStart,a.selectionEnd,a.selectionDirection]}catch{return null}}function wn(a,O,R,K){try{a.setSelectionRange(It(O,R,K[0]),It(O,R,K[1]),K[2]||"none")}catch{}}function Dt(a,O){let R=a.value,K=Gt(a);a.value=O,K&&wn(a,R,O,K)}function rn(a){let O=a&&a.remote;return O&&O.nodeType===1?O:null}function Yt(a,O,R){let K=a.tagName,Z=rn(R),U=n.formState==="property"&&Z?Z:O;if(K==="INPUT"){let de=cn(a,R),we=(a.getAttribute("type")||"").toLowerCase(),le=we!=="file"&&we!=="checkbox"&&we!=="radio",Ae=Z&&Z.hasAttribute("value")&&Z.value!==Z.getAttribute("value")?Z.value:null;if(le&&!de)if(n.formState==="property"){let W=O.getAttribute("value"),X=a.getAttribute("value");(X!==W||a.value!==U.value)&&E("value",a,W==null?"remove":"update")!==!1&&(X!==W&&(W==null?a.removeAttribute("value"):a.setAttribute("value",W),i.push({kind:"attr",el:a,name:"value",before:X,after:W})),a.value!==U.value&&(Nt(a)?Dt(a,U.value):a.value=U.value))}else if(O.hasAttribute("value")||Ae!=null){let W=Ae??O.getAttribute("value");a.getAttribute("value")!==W&&E("value",a,"update")!==!1?(a.setAttribute("value",W),a.value!==W&&(Nt(a)?Dt(a,W):a.value=W),i.push({kind:"attr",el:a,name:"value",before:null,after:W})):a.value!==W&&a.getAttribute("value")===W&&(Nt(a)?Dt(a,W):a.value=W)}else(a.hasAttribute("value")||a.value!=="")&&E("value",a,"remove")!==!1&&(a.removeAttribute("value"),a.value="",i.push({kind:"attr",el:a,name:"value",before:"",after:null}));if(!le&&we!=="file"){let W=O.getAttribute("value");W==null?a.hasAttribute("value")&&E("value",a,"remove")!==!1&&a.removeAttribute("value"):a.getAttribute("value")!==W&&E("value",a,"update")!==!1&&a.setAttribute("value",W)}n.protectFocusedValue&&Nt(a)||(fn(a,U,"checked"),n.formState==="property"&&a.indeterminate!==U.indeterminate&&(a.indeterminate=U.indeterminate)),fn(a,U,"disabled")}else if(K==="OPTION"){let de=a.parentNode&&a.closest("select");n.protectFocusedValue&&de&&Nt(de)||fn(a,U,"selected")}}function fn(a,O,R){if(n.ignoreAttribute(a,R,O))return;let K=n.formState==="property"?!!O[R]:O.hasAttribute(R);if(n.formState!=="property"){let Z=a.hasAttribute(R);if(Z!==K){if(E(R,a,K?"update":"remove")===!1)return;K?a.setAttribute(R,""):a.removeAttribute(R),i.push({kind:"attr",el:a,name:R,before:Z?"":null,after:K?"":null})}}a[R]!==K&&(a[R]=K)}function $(a,O,R){if(cn(a,R)||E("value",a,"update")===!1)return;let K=rn(R),Z=O.textContent,U=K&&K.value!==K.defaultValue?K.value:Z,de=Nt(a)?Gt(a):null,we=a.value;n.formState!=="property"&&a.textContent!==Z&&(i.push({kind:"text",node:a,before:a.textContent,after:Z}),a.textContent=Z),a.value!==U&&(a.value=U),de&&a.value!==we&&wn(a,we,a.value,de)}}function kl(e,o){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let n={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{n.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return n}let s=e.getSelection&&e.getSelection();if(s&&s.rangeCount){let h=s.getRangeAt(0);n.range={sc:h.startContainer,so:h.startOffset,ec:h.endContainer,eo:h.endOffset}}return n}function xl(e,o,t,n,s,h,l){if(!o)return;let r=o.el;if(!r.isConnected&&o.id&&(r=e.getElementById(o.id)),!r||!r.isConnected)return;if(e.activeElement!==r)try{r.focus({preventScroll:!0})}catch{}try{r.scrollTop=o.scrollTop,r.scrollLeft=o.scrollLeft}catch{}if(o.selection){try{r.setSelectionRange&&!r.selectionEnd&&o.selection[1]!=null&&r.setSelectionRange(o.selection[0],o.selection[1],o.selection[2]||"none")}catch{}return}if(!o.range)return;let i=(c,p)=>{let b=t.get(c);if(Array.isArray(b)){let S=b.find(g=>p>=g.from&&p<g.to)||b.find(g=>p===g.to)||b[b.length-1],C=h.get(S.merged);if(!C||!C.isConnected)return null;let m=n.get(S.merged),f=m&&m.flat?m.flat(S.flatStart+p):p;return[C,Math.max(0,Math.min(f,C.nodeValue.length))]}if(b&&!l.has(b.merged)){let S=(s.get(b.merged)||[c])[0];if(!S.isConnected)return null;let C=n.get(b.merged),m=b.shift+p,f=C?C(m):m;return[S,Math.max(0,Math.min(f,S.nodeValue.length))]}return c.isConnected?[c,Math.min(p,c.nodeType===3?c.nodeValue.length:c.childNodes.length)]:null},u=i(o.range.sc,o.range.so),w=i(o.range.ec,o.range.eo);if(!(!u||!w))try{let c=e.createRange();c.setStart(u[0],u[1]),c.setEnd(w[0],w[1]);let p=e.getSelection();p.removeAllRanges(),p.addRange(c)}catch{}}var Tl={compared:0},vl=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Sl(e,o,t){let n=0;for(let s of e.attributes)if(!t(e,s.name)&&(n++,o.getAttribute(s.name)!==s.value))return!1;for(let s of o.attributes)t(o,s.name)||n--;return n===0}function Bs(e,o){if(e.namespaceURI!==o.namespaceURI||e.prefix!==o.prefix||e.localName!==o.localName)return!1;let t=e.attributes;if(t.length!==o.attributes.length)return!1;for(let n of t)if(o.getAttributeNS(n.namespaceURI,n.localName)!==n.value)return!1;return!0}function qr(e,o,t,n,s,h,l,r){let i=new Map,u=new Set,w=c=>{if(n(c))return;let p=t(c);p&&(h.add(p),s.has(p)||i.has(p)?u.add(p):i.set(p,c))};for(let c of e)w(c);w(o);for(let c of l||o.querySelectorAll("*"))w(c);for(let c of u)i.delete(c),r.add(c);return i}function Kr(e,o,t,n,s,h){let l=!1;for(let w of s)w.startsWith("merge:")&&(l=!0);if(!l)return[...n];let r=new Map,i=[],u=h===kn?Co:"*";for(let w of[e,...e.querySelectorAll(u)]){if(t(w))continue;let c=o(w);if(!c||!(n.has(c)||s.has(c)))continue;let p=(r.get(c)||0)+1;r.set(c,p),p===2&&i.push(c)}return i}function Fr({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:s,identity:h,baseURI:l}){if(e.tagName!==o.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||o.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!Sl(e,o,s.ignoreAttribute))return{bail:"root-attrs"};let{ignored:r,remoteWins:i}=s,u=Rs(s.scripts.merge===!1?null:s.scripts.mergeTags,l),w=fe=>{let x=u(fe);return x!==null?x:h.base(fe)||null},c=fe=>{let x=u(fe);return x!==null?x:h.remote(fe)||null},p=[],b=[],S=new Map,C=new Map,m={same:S,differ:C},f=fe=>({bail:fe,comparisons:m}),g=(fe,x,Y=!0)=>{if(S.get(fe)===x)return!0;if(C.get(fe)===x)return!1;if(Tl.compared++,Y&&fe.isEqualNode(x))return S.set(fe,x),!0;let ae=fe.nodeType===x.nodeType;if(ae&&fe.nodeType===1){if(ae=Bs(fe,x),ae){let oe=fe.firstChild,Ee=x.firstChild;for(;oe&&Ee;oe=oe.nextSibling,Ee=Ee.nextSibling)if(!g(oe,Ee,!1)){ae=!1;break}(oe||Ee)&&(ae=!1)}}else ae&&(ae=fe.isEqualNode(x));return(ae?S:C).set(fe,x),ae},I=e,v=o,T=!1,A=()=>{S.set(I,v);for(let fe=0;fe<p.length;fe++)S.set(p[fe],b[fe]);return f("equal")};for(;;){let fe=I.childNodes,x=v.childNodes;if(fe.length!==x.length)break;let Y=Xe=>g(fe[Xe],x[Xe])?(S.set(fe[Xe],x[Xe]),!1):!0,ae=-1,oe=-1;for(let Xe=0;Xe<fe.length;Xe++){if(fe[Xe].nodeType!==1)continue;let ht=0;for(let Ge=fe[Xe].firstElementChild;Ge;Ge=Ge.nextElementSibling)ht++;ht>=oe&&(oe=ht,ae=Xe)}let Ee=[],De=!1;for(let Xe=0;Xe<fe.length&&Ee.length<2;Xe++)Xe!==ae&&Y(Xe)&&Ee.push(Xe);if(ae>=0&&Ee.length<2&&(Ee.length===0&&Bs(I,v)?(Ee.push(ae),De=!0):Y(ae)&&Ee.push(ae)),Ee.length!==1){if(!T&&Ee.length===0&&Bs(I,v))return A();break}let Ne=fe[Ee[0]],nt=x[Ee[0]];if(T=T||!De,T&&C.set(Ne,nt),Ne.nodeType!==1||nt.nodeType!==1||Ne.tagName!==nt.tagName)break;if(w(Ne)!==c(nt)){if(!T&&g(Ne,nt))return A();break}p.push(I),b.push(v),I=Ne,v=nt}C.set(I,v);for(let fe=0;fe<p.length;fe++)C.set(p[fe],b[fe]);if(I===e||I.tagName==="HEAD"||I.tagName==="BODY")return f("root-level");if(p.length<2||p[1].tagName!=="BODY")return f("not-in-body");if(r(I)||r(v))return f("ignored-ancestor");if(i(I)||i(v))return f("remote-wins-ancestor");for(let fe of p)if(vl.has(fe.tagName))return f("form-ancestor");if(I.tagName==="SCRIPT"||I.getElementsByTagName("script").length||v.getElementsByTagName("script").length)return f("script-or-template");let E=n(I);if(!E||E.nodeType!==1||E.tagName!==I.tagName)return f("no-live-twin");if(!t.contains(E))return f("live-detached");for(let fe of p){let x=n(fe);if(!x||x.nodeType!==1)return f("ancestor-live")}let N=h.base===kn&&h.remote===kn&&r===ss,M=new Set,P=new Set,V=[],D=null,j=fe=>{fe&&(M.has(fe)?P.add(fe):M.add(fe))},y=(fe,x)=>{let Y=u(fe),ae=Y!==null?Y:h.base(fe)||null;return ae!==(Y!==null?Y:h.remote(x)||null)?!1:(j(ae),!0)},k=(fe,x)=>{for(let Y=fe.firstElementChild,ae=x.firstElementChild;Y;Y=Y.nextElementSibling,ae=ae.nextElementSibling){let oe=r(Y);if(oe!==r(ae))return!1;if(!oe&&(!y(Y,ae)||!k(Y,ae)))return!1}return!0},J=fe=>{let x=fe+1<p.length?p[fe+1]:I;for(let Y=p[fe].firstElementChild,ae=b[fe].firstElementChild;Y;Y=Y.nextElementSibling,ae=ae.nextElementSibling){if(Y===x){let De=fe+1<p.length?J(fe+1):null;if(De)return De;continue}let oe=r(Y);if(oe!==r(ae))return"outside-id-changed";if(oe)continue;let Ee=n(Y);if(!Ee||Ee.nodeType!==1)return"sibling-live";if(V.push([Y,ae]),!N&&(!y(Y,ae)||!k(Y,ae)))return"outside-id-changed";fe===0&&Y.tagName==="HEAD"&&w(Y)&&(D=[Y,ae])}return null},H=J(0);if(H)return f(H);let q=new Set(p),Me=null;if(h.base===kn){Me=[];for(let fe of e.querySelectorAll(Co))fe===I||q.has(fe)||(I.contains(fe)?Me.push(fe):N&&j(w(fe)))}let Oe=new Set,Re=new Set,ie=new Set,xe=qr(p,I,w,r,M,Oe,Me,Re),qe=qr(b,v,c,r,M,Oe,h.remote===kn&&v.querySelectorAll(Co),ie);return D&&(P.has(w(D[0]))||Oe.has(w(D[0])))&&(D=null),{scope:{chain:p,root:I,onChain:q,baseIndex:xe,remoteIndex:qe,baseDropped:Re,remoteDropped:ie,head:D,same:S,differ:C,dropped:[...Kr(e,w,r,P,Re,h.base),...Kr(o,c,r,P,ie,h.remote)],held:fe=>{for(let x=1;x<p.length;x++)if(fe.map.get(p[x])!==b[x])return!1;for(let[x,Y]of V)if(fe.map.get(x)!==Y)return!1;return!0}}}}var _r=Symbol("hyper-morph-duplicate-key"),zr=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function Lo(e,o){return o.map(t=>{let n=new Map;for(let s of e){if(s.nodeType!==1)continue;let h=t(s);h==null||h===""||n.set(h,n.has(h)?_r:s)}return n})}function $r(e,o,t,n){for(let s=0;s<n.length;s++){let h=n[s](e);if(h==null||h===""||o[s].get(h)!==e)continue;let l=t[s].get(h);if(!(!l||l===_r)&&l.tagName===e.tagName)return l}return null}function bo(e,o,t){for(let n=0;n<t.length;n++){let s=t[n](e);if(!(s==null||s==="")&&o[n].get(s)===e)return!0}return!1}function Gr(e,o,t={}){let n=t.skip||(()=>!1),s=t.ignoreAttr||(()=>!1),h=t.tiers&&t.tiers.length?t.tiers:zr,l=null;function r(){return l||(l=Lo([e,...e.querySelectorAll("*")],h)),l}let i=null;function u(){return i||(i=Lo([o,...o.querySelectorAll("*")],h)),i}function w(M){return!M.parentElement||!M.parentElement.parentElement}function c(M,P,V){return w(M)||bo(M,r(),h)?(V.push({type:"subtree",el:M,base:P}),!1):!0}function p(M,P){let V=[];for(let D of M.attributes)s(M,D.name)||P.getAttribute(D.name)!==D.value&&V.push(D.name);for(let D of P.attributes)s(M,D.name)||M.hasAttribute(D.name)||V.push(D.name);return V}function b(M){let P=[],V=null,D=()=>{V!==null&&(P.push({nodeType:3,nodeValue:V}),V=null)};for(let j of M.childNodes){if(j.nodeType===3){V=(V===null?"":V)+j.nodeValue;continue}j.nodeType===1&&n(j)||(D(),(j.nodeType===1||j.nodeType===8)&&P.push(j))}return D(),P}function S(M,P){if(M.nodeType!==P.nodeType)return!1;if(M.nodeType!==1)return!0;if(M.tagName!==P.tagName)return!1;for(let V of h){let D=V(M),j=V(P);if(D!=null&&D!==""&&j!=null&&j!==""&&D!==j)return!1}return!0}function C(M){let P="";for(let V of M)V.nodeType===3&&V.nodeValue.trim()!==""?P+="\0"+V.nodeValue:V.nodeType===8&&(P+=""+V.nodeValue);return P}function m(M,P,V){let D=b(M),j=b(P);if(D.length===j.length){let fe=!0;for(let x=0;x<D.length;x++)if(!S(D[x],j[x])){fe=!1;break}if(fe){for(let x=0;x<D.length;x++){let Y=D[x];if(Y.nodeType===1){if(f(Y,j[x],V))return!0}else if(Y.nodeValue!==j[x].nodeValue)return!0}return!1}}let y=D.filter(fe=>fe.nodeType===1),k=j.filter(fe=>fe.nodeType===1);if(C(D)!==C(j))return!0;let J=Lo(y,h),H=Lo(k,h),q=[],Me=new Set,Oe=[];for(let fe of y){let x=$r(fe,J,H,h);x&&!Me.has(x)?(q.push([fe,x]),Me.add(x)):Oe.push(fe)}let Re=[];for(let fe of Oe)bo(fe,J,h)?V.push({type:"subtree",el:fe,base:null}):Re.push(fe);let ie=[];for(let fe of k)Me.has(fe)||(bo(fe,H,h)?V.push({type:"deletion",el:fe}):ie.push(fe));if(Re.length!==ie.length)return!0;for(let fe=0;fe<Re.length;fe++)if(!S(Re[fe],ie[fe]))return!0;let xe=new Map(q);for(let fe=0;fe<Re.length;fe++)xe.set(Re[fe],ie[fe]);let qe=-1;for(let fe of y){let x=xe.get(fe);if(!x)continue;let Y=k.indexOf(x);if(Y<qe)return!0;qe=Y}for(let fe=0;fe<Re.length;fe++)if(f(Re[fe],ie[fe],V))return!0;for(let[fe,x]of q)if(f(fe,x,V))return!0;return!1}function f(M,P,V){if(M.tagName!==P.tagName)return c(M,P,V);let D=p(M,P),j=[];if(m(M,P,j))return c(M,P,V);if(D.length){if(!w(M)&&!bo(P,u(),h))return!0;V.push({type:"attrs",el:M,names:D,base:P})}return V.push(...j),!1}let g=[],I=p(e,o);I.length&&g.push({type:"attrs",el:e,names:I});let v=(M,P)=>Array.from(M.children).find(V=>V.tagName===P)||null,T=v(e,"HEAD"),A=v(o,"HEAD");if(T&&A){let M=[];f(T,A,M),M.length&&g.push({type:"head",el:T})}else(T||A)&&T&&g.push({type:"head",el:T});let E=v(e,"BODY"),N=v(o,"BODY");return E&&N?f(E,N,g):E&&g.push({type:"subtree",el:E,base:null}),{entries:g}}function Yr(e,o,t={}){let n=t.tiers&&t.tiers.length?t.tiers:zr,s=e.documentElement,h=[],l=0,r=f=>({ok:!1,placed:h,held:f,skippedAttrs:l});if(!s)return r(null);function i(f){let g=[f,...f.querySelectorAll("*")];return Lo(g,n)}let u=i(s),w=new Map,c=f=>{let g=f.getRootNode(),I=w.get(g);if(!I){let v=g.nodeType===9?g.documentElement:g;I=i(v),w.set(g,I)}return I};function p(f){if(!f.parentElement&&f.tagName==="HTML")return s;if(f.parentElement&&!f.parentElement.parentElement&&f.parentElement.tagName==="HTML"){if(f.tagName==="BODY")return e.body||null;if(f.tagName==="HEAD")return e.head||null}return null}function b(f){let g=p(f);return g||$r(f,c(f),u,n)}function S(f){if(!f)return null;let g=b(f);return g&&g.isConnected?g:null}function C(f){for(let g=0;g<n.length;g++){let I=n[g](f);I!=null&&I!==""&&u[g].set(I,f)}}for(let f of o){if(f.type!=="deletion")continue;let g=b(f.el);g&&g!==s&&g.remove()}let m=o.filter(f=>f.type!=="deletion").sort((f,g)=>f.el===g.el?0:f.el.compareDocumentPosition(g.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let f of m){if(f.type==="head"){let N=e.importNode(f.el,!0);e.head?e.head.replaceWith(N):s.insertBefore(N,s.firstChild),h.push({entry:f,imported:N});continue}if(f.type==="attrs"){let N=S(f.el)||S(f.base);if(!N){l++;continue}for(let M of f.names)f.el.hasAttribute(M)?N.setAttribute(M,f.el.getAttribute(M)):N.removeAttribute(M);continue}let g=f.el;if(p(g))return r(f);let I=S(g)||S(f.base);if(I){let N=e.importNode(g,!0);I.replaceWith(N),C(N),h.push({entry:f,imported:N});continue}if(f.base!=null&&!bo(f.base,c(f.base),n)||!bo(g,c(g),n))return r(f);let v=g.parentElement;if(!v)return r(f);let T=S(v);if(!T)return r(f);let A=null;for(let N=g.previousElementSibling;N;N=N.previousElementSibling){let M=S(N);if(M&&M.parentNode===T){A=M;break}}let E=e.importNode(g,!0);if(A)T.insertBefore(E,A.nextSibling);else{let N=Array.prototype.indexOf.call(v.children,g);T.insertBefore(E,T.children[N]||null)}C(E),h.push({entry:f,imported:E})}return{ok:!0,placed:h,held:null,skippedAttrs:l}}var Nl='[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"]',Al='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Ml='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Ol(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let o=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(o)}function Il(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let s=o;if(s.nodeType===9){let h=e.getAttribute("id");s=h&&s.getElementById(h)||(e.tagName==="BODY"?s.body:e.tagName==="HTML"?s.documentElement:s.body&&s.body.firstElementChild)}if((!s||s.nodeType!==1||s.tagName!==e.tagName)&&(s=Cl(e,o,n)),!!s)return t?Array.from(s.childNodes):s}function Cl(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let s=new Map,h=[n,...n.querySelectorAll("script")];for(let i of h){let u=ho(i,t);u&&!s.has(u.key)&&s.set(u.key,i.textContent)}if(!s.size)return null;let l=e.cloneNode(!0),r=!1;for(let i of[l,...l.querySelectorAll("script")]){let u=ho(i,t);u&&s.has(u.key)&&(i.textContent=s.get(u.key),r=!0)}return r?l:null}function Xr(e,o){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=o.implementation.createHTMLDocument(""),n=e.nodeType===1&&e.tagName==="HTML"?e:null;if(n)return t.replaceChild(t.adoptNode(n),t.documentElement),t;let s=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let h of s)t.body.appendChild(t.adoptNode(h));return t}function Zo(e,o,t={}){let n=t||{};if(!n.head?.block)return Jr(e,o,n);try{return Jr(e,o,n)}catch(s){return Promise.reject(s)}}function Jr(e,o,t){let n=t.policy||"sync",s=n==="raw"?void 0:(i,u)=>Ol(i)||(n==="history"?!(u&&i.matches(Ml))&&i.matches(Al):i.matches(Nl)),h=t.callbacks||{},l={ignore:s,hooks:h,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 wo(Object.assign({},l,{live:e,base:t.scripts?.mergeBase||null,remote:Xr(o,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let i=Object.assign({},l,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Xr(o,e.ownerDocument)});return wo(i)}t.morphStyle==="innerHTML"&&(l.children=!0);let r=Il(e,t.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return r!==void 0&&(l.base=r),es(e,o,l)}var Ll=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),On=()=>{};function Eo(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let r of Object.keys(e))if(!Ll.has(r))throw new TypeError(`unknown option "${r}"`);let t=Object.assign({beforeNodeAdded:On,afterNodeAdded:On,beforeNodeRemoved:On,afterNodeRemoved:On,beforeNodeMorphed:On,afterNodeMorphed:On,beforeAttributeUpdated:On},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let s=e.formState||"attribute";if(!["attribute","property"].includes(s))throw new TypeError("formState must be attribute or property");let h=e.protectFocusedValue;if(h!==void 0&&typeof h!="boolean"&&h!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");let l=e.lineage;if(l!==void 0&&(!l||typeof l!="object"||typeof l.onResult!="function"||!l.elements||typeof l.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:rs(e.ignore,o),remoteWins:rs(e.remoteWins,o),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,opaque:typeof e.opaque=="function"?e.opaque:()=>!1,conflicts:n,protectFocusedValue:h===void 0?!0:h,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:s,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:l||null}}function yo(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 kn}function ko(e,o){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=Do(o,e.map),n=typeof e.then=="function"?e.then:kn;if(typeof e.first=="function"){let s=e.first;return h=>s(h)||t.get(h)||n(h)}return s=>t.get(s)||n(s)}return kn}function ni(e,o,t,n={}){let s=b=>b&&b.nodeType===9?b.documentElement:b,h=s(o),l=s(t),r=s(e)||h;if(n.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let i=Object.assign({},n);delete i.live,delete i.base,delete i.remote;let u=Eo(i,[r,h,l].filter(Boolean)),w=n.identity||{},c=$n(),p=Qo(r,h,l,{identity:{base:ko(w.base,r),local:ko(w.local,h),remote:ko(w.remote,l)},authored:{base:yo(w.base),local:yo(w.local),remote:yo(w.remote)},skipUnchanged:u.hooks.beforeNodeMorphed===On&&u.hooks.afterNodeMorphed===On,ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:h.ownerDocument&&h.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:u.children,stats:c});return delete p.recoveryLinks,delete p.lineage,p}function js({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:s,options:h,identity:l,childrenOnly:r,isDocument:i}){let u=Eo(h,[e,o,t,n].filter(Boolean));if(u.ignored(e)){let y=Ds(),k=u.lineage?Ao(u.lineage,e,y):null;return{report:y,loads:[],lineage:k}}let w=e.ownerDocument,c=u.lineage?Ss(u.lineage,{liveRoot:e,localRoot:t,toLive:s}):null,p=u.scripts.execute?br(e,u.ignored,w.baseURI):null,b=$n(),S=u.hooks.beforeNodeMorphed===On&&u.hooks.afterNodeMorphed===On,C={identity:{base:ko(l.base,o||t),local:ko(l.local,t),remote:ko(l.remote,n)},authored:{base:yo(l.base),local:yo(l.local),remote:yo(l.remote)},ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:w.baseURI,localIsBase:!o,childrenOnly:r,skipUnchanged:S,lineage:c?{locals:c.locals}:null},m=u.fastPath&&i&&!r&&S&&o===t,f=null,g=null;if(m){let y=Fr({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:s,o:u,identity:C.identity,baseURI:w.baseURI});C.comparisons=y.comparisons||y.scope,y.bail?g=y.bail:(f=Qo(o,t,n,Object.assign({},C,{stats:b,scope:y.scope})),f||(g="chain-unpaired",b=$n()))}f||(f=Qo(o||t,t,n,Object.assign({},C,{stats:b}))),m&&(b.fastPathAttempted=1,b.fastPathTaken=g?0:1,b.fastPathFallback=g),f.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(y=>u.hooks[y]!==On)&&Ar(f.conflicts,f.recoveryLinks,s),u.beforeApply&&u.beforeApply(f.doc);let I=globalThis.__hyperMorphProfile,v=I?performance.now():0,T=Wr(e,f.root,f,{toLive:s,localRoot:t,ignored:u.ignored,ignoreAttribute:u.ignoreAttribute,opaque:u.opaque,formState:u.formState,protectFocusedValue:u.protectFocusedValue,restoreFocus:u.restoreFocus,preserve:u.head.preserve,hooks:u.hooks,childrenOnly:r,keepLiveOnly:u.keepLiveOnly,trackInserted:!!c});I&&(I.apply=(I.apply||0)+(performance.now()-v));let A=[];if(u.head.awaitLoads)for(let y of T.applied){if(y.kind!=="insert"||y.node.nodeType!==1)continue;let k=y.node;k.tagName==="LINK"&&/\bstylesheet\b/i.test(k.getAttribute("rel")||"")&&k.getAttribute("href")&&k.closest("head")&&A.push(new Promise(H=>{k.addEventListener("load",()=>H()),k.addEventListener("error",()=>H())}))}let E=null,N=null;if(p){let y=wr(e,p,{ignored:u.ignored,skip:T.mergedScriptsLive,baseURI:w.baseURI,beforeNodeAdded:u.hooks.beforeNodeAdded,afterNodeAdded:u.hooks.afterNodeAdded,trackRecovery:!!f.recoveryLinks});A.push(...y.loads),E=y.swapped,N=y.vetoed}let M=y=>E&&E.get(y)||y,P=y=>{if(T.keptRuns.has(y))return T.runOf.get(y);let k=T.liveOf.get(y)||T.heldBy.get(y)||T.insertedLive.get(y);return k?M(k):null},V=y=>{let k=y&&T.liveOf.get(y);return k?M(k):null},D=y=>{let k=y&&P(y);return Array.isArray(k)?k[0]:k};if(f.recoveryLinks){let y=(k,J,H)=>(J.namespaceURI?k.getAttributeNS(J.namespaceURI,J.localName):k.getAttribute(J.qualifiedName))===H;Ir(f.conflicts,f.recoveryLinks,{lookup:P,vetoed:T.vetoed,vetoedAttrs:T.vetoedAttrs,removedVetoes:T.removedVetoes,vetoedLive:N,liveAttr:y,ignored:u.ignored,liveRoot:e})}let j={applied:T.applied,decisions:f.decisions.map(y=>Object.assign({},y,{node:y.node?V(y.node):null,el:y.el?V(y.el):null,applied:!!(y.node?V(y.node):y.el&&V(y.el))})),conflicts:f.conflicts.map(y=>Object.assign({},y,{node:y.node?y.kind==="text"&&y.recovery.subject.nodeType===8?D(y.node):V(y.node):y.node,el:y.el?y.kind==="structure"?D(y.el):V(y.el):y.el})),localDiverged:f.localDiverged,identities:T.identities,moved:T.moved,replaced:T.replaced,stats:b};return c&&(j.lineage=c.finish(f.lineage,P)),{report:j,loads:A,lineage:c}}var Qr=new WeakMap;function Ds(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:$n()}}function wo(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");return o.lineage===void 0?Zr(o):vs(o,o.live.documentElement,n=>Zr(n))}function Zr(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let n=Qr.get(t);n||(n=jo(t),Qr.set(t,n));let s=n("remote",o.remote),h=typeof o.base=="string"&&o.base===""?null:o.base,l=h?n("base",h):null,r=o.local?o.local.root:t.documentElement,i=o.local?o.local.toLive:p=>p;Vs(t,s);let{report:u,loads:w,lineage:c}=js({liveRoot:t.documentElement,baseRoot:l?l.documentElement:null,localRoot:r,remoteRoot:s.documentElement,toLive:i,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return c?.deliver(u),Promise.all(w).then(()=>u)}function oi(e,o,t={}){return wo(Object.assign({},t,{live:e,base:null,remote:o}))}function ei(e,o){if(e==null)return{root:o.createElement("template"),first:null};if(typeof e=="string"){let n=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(n){let h=Bo(e,o),l=n[1].toLowerCase()==="html"?h.documentElement:h.body;return{root:l,first:l}}let s=o.createElement("template");return s.innerHTML=e,{root:s,first:s.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let n=o.createElement("template"),s=e.isConnected;return n.content.appendChild(s?o.importNode(e,!0):e),{root:n,first:e}}if(e.nodeType===11){let n=o.createElement("template");return n.content.appendChild(e),{root:n,first:n.content.firstElementChild}}let t=o.createElement("template");for(let n of Array.from(e))t.content.appendChild(n.parentNode?o.importNode(n,!0):n);return{root:t,first:t.content.firstElementChild}}function es(e,o,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return t.lineage===void 0?ti(e,o,t):vs(t,e,n=>ti(e,o,n))}function ti(e,o,t={}){let n=e.ownerDocument,{base:s,...h}=t,l=!!h.children,r=Eo(h,[e]);if(r.ignored(e)){let C=Ds();return r.lineage&&Ao(r.lineage,e,C).deliver(C),Promise.resolve(C)}let i=ei(o,n),u=s!=null?ei(s,n):null,w,c=null;if(l)w=i.root,c=u?u.root:null;else{if(w=i.first,c=u?u.first:null,!w){let C=Eo(h),m=C.lineage?Ao(C.lineage,e,{}):null;C.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),C.hooks.afterNodeRemoved(e));let f={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:$n()};return m&&(f.lineage=m.result,m.deliver(f)),Promise.resolve(f)}if(w.tagName!==e.tagName){let C=Eo(h,[e,w]);if(C.hooks.beforeNodeMorphed(e,w)===!1){let g=Ds();return C.lineage&&Ao(C.lineage,e,g).deliver(g),Promise.resolve(g)}let m=js({liveRoot:e,baseRoot:c&&c.tagName===e.tagName?c:null,localRoot:e,remoteRoot:w,toLive:g=>g,options:h,identity:h.identity||{},childrenOnly:!0,isDocument:!1}),f=pn(w)?Mo(w,n):n.importNode(w,!1);if(!pn(f))for(;e.firstChild;)f.appendChild(e.firstChild);return C.hooks.beforeNodeAdded(f)===!1?(Jo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):C.hooks.beforeNodeRemoved(e)===!1?(Jo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):(e.replaceWith(f),Jo(m.report.conflicts,e,f),C.hooks.afterNodeRemoved(e),C.hooks.afterNodeAdded(f),C.hooks.afterNodeMorphed(e,w),m.report.replaced.push(f),m.report.applied.push({kind:"insert",node:f,parent:f.parentNode},{kind:"remove",node:e,parent:f.parentNode}),m.lineage&&(m.report.lineage=m.lineage.remapRoot(e,f),m.lineage.deliver(m.report)),Promise.all(m.loads).then(()=>m.report))}}let{report:p,loads:b,lineage:S}=js({liveRoot:e,baseRoot:c,localRoot:e,remoteRoot:w,toLive:C=>C,options:h,identity:h.identity||{},childrenOnly:l,isDocument:!1});return S?.deliver(p),Promise.all(b).then(()=>p)}var El={mergeDocument:wo,morphDocument:oi,morphElement:es,merge3:ni,morph:Zo};return fi(Rl);})();
7
7
 
8
8
  var morph = HyperMorph.morph;
9
9