@panphora/clayjs 1.5.3 → 1.6.1

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.
Files changed (46) hide show
  1. package/README.md +5 -3
  2. package/THIRD-PARTY-NOTICES.md +6 -0
  3. package/dist/clay.standalone.js +15041 -10657
  4. package/package.json +9 -4
  5. package/src/core/conflict-download.js +91 -0
  6. package/src/core/conflict-notice.js +720 -0
  7. package/src/core/conflict-presentation.js +301 -0
  8. package/src/core/save-conflict-notice.js +2 -192
  9. package/src/core/save-core.js +35 -2
  10. package/src/core/save-feedback.js +6 -0
  11. package/src/core/save.js +157 -3
  12. package/src/core/snapshot.js +21 -0
  13. package/src/core/stale-host-notice.js +21 -24
  14. package/src/core/unsaved-warning.js +64 -16
  15. package/src/lib/content-dom.js +4 -2
  16. package/src/lib/dirty-gate.js +37 -1
  17. package/src/lib/unsaved-state.js +55 -0
  18. package/src/loader-logic.js +26 -15
  19. package/src/loader.js +10 -3
  20. package/src/plugins/ai-edit.js +489 -179
  21. package/src/plugins/cms.js +12 -0
  22. package/src/plugins/indicator.js +35 -16
  23. package/src/plugins/quickcrop.js +103 -0
  24. package/src/plugins/richclay.js +21 -0
  25. package/src/plugins/source.js +13 -6
  26. package/src/plugins/wire.js +4 -0
  27. package/src/sync/conflict-revert.js +1138 -0
  28. package/src/sync/conflicts.js +159 -0
  29. package/src/sync/live-sync.js +130 -109
  30. package/src/sync/presence.js +42 -36
  31. package/src/sync/section-notice.js +53 -28
  32. package/src/ui/bevel-controls.js +277 -0
  33. package/src/ui/bevel-dialog.js +112 -0
  34. package/src/ui/bevel.js +247 -0
  35. package/src/ui/dialogs.js +63 -86
  36. package/src/ui/index.js +22 -11
  37. package/src/ui/modal.js +80 -387
  38. package/src/ui/skins/cms-toggle.js +15 -0
  39. package/src/ui/skins/cms.js +4 -0
  40. package/src/ui/skins/quickcrop.js +4 -0
  41. package/src/ui/skins/richclay.js +4 -0
  42. package/src/ui/toast.js +116 -401
  43. package/src/ui/vendor-skin.js +65 -0
  44. package/src/vendor/hyper-morph.vendor.js +4 -4
  45. package/src/vendor/quickcrop.vendor.js +14 -8
  46. package/src/vendor/richclay.vendor.js +22 -41
@@ -1,7 +1,7 @@
1
- var HyperMorph=(()=>{var no=Object.defineProperty;var ps=Object.getOwnPropertyDescriptor;var ms=Object.getOwnPropertyNames;var gs=Object.prototype.hasOwnProperty;var bs=(e,s)=>{for(var o in s)no(e,o,{get:s[o],enumerable:!0})},ks=(e,s,o,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of ms(s))!gs.call(e,r)&&r!==o&&no(e,r,{get:()=>s[r],enumerable:!(n=ps(s,r))||n.enumerable});return e};var ys=e=>ks(no({},"__esModule",{value:!0}),e);var wr={};bs(wr,{createIdentityStore:()=>Mo,createParseCache:()=>zn,default:()=>yr,diff:()=>An,findChangedRoots:()=>os,importMap:()=>qn,merge3:()=>as,merge3Text:()=>wn,mergeDocument:()=>Mn,mergeJson:()=>wo,mergeScriptText:()=>Zn,morph:()=>eo,morphDocument:()=>fs,morphElement:()=>to,parseJsonRelaxed:()=>Xn,parseRulesRelaxed:()=>zo,spliceProtected:()=>ss,tieredIdentity:()=>so});function Kn(e,s){if(typeof e=="string"){let o=s&&s.defaultView,n=o&&o.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 zn(e){let s=new Map;return(o,n)=>{if(typeof n!="string")return Kn(n,e);let r=s.get(o);if(r&&r.text===n)return r.doc;let l=Kn(n,e);return s.set(o,{text:n,doc:l}),l}}function vo(e,s){let o=s.doctype;if(!o)return!1;let n=e.doctype;if(n&&n.name===o.name&&n.publicId===o.publicId&&n.systemId===o.systemId)return!1;let r=e.implementation.createDocumentType(o.name,o.publicId,o.systemId);return n?e.replaceChild(r,n):e.insertBefore(r,e.documentElement),!0}function oo(e,s=[]){if(typeof e!="function")return()=>!1;let o=new WeakMap,n=new Set(s);return r=>{if(!r||r.nodeType!==1)return!1;let l=o.get(r);if(l!==void 0)return l;let c=[],f=r,u=!1;for(;f&&f.nodeType===1;){let v=o.get(f);if(v!==void 0){u=v;break}if(c.push(f),e(f,n.has(f))){u=!0;break}if(n.has(f))break;f=f.parentElement}for(let v of c)o.set(v,u);return u}}function Mo(e){let s=new WeakMap,o=0,n=f=>s.get(f)||null,r=f=>{let u=s.get(f);return u||(u=`${e}:${++o}`,s.set(f,u)),u};return{idOf:n,ensure:r,adopt:(f,u)=>{f&&typeof u=="string"&&u&&s.set(f,u)},exportMap:(f,u)=>{let v={},N=[],A=[],T=(p,h)=>{let x=u(p);x&&(v[h]=r(x));let R=p.children;N.push(R.length),A.push(p.tagName.toLowerCase());for(let M=0;M<R.length;M++)T(R[M],h===""?String(M):`${h}.${M}`)};return T(f,""),v["~"]=N.join(","),v["^"]=A.join(","),v}}}function qn(e,s){let o=new WeakMap;if(!e||!s||typeof s!="object"||Array.isArray(s))return o;let n=s["~"],r=typeof n=="string"?n.split(",").map(Number):null,l=r&&typeof s["^"]=="string"?s["^"].split(","):null,c=A=>Number.isInteger(A)&&A>=0,f=0,u=!1,v=A=>{let T=A;for(;T>0;){let p=r[f++];if(f>r.length||!c(p))return!1;T+=p-1}return!0},N=(A,T)=>{if(u)return;if(r){let x=f++,R=r[x];if(x>=r.length||!c(R)){u=!0;return}let M=!l||l[x]===A.tagName.toLowerCase();if(!M||R!==A.children.length){let D=M&&s[T];typeof D=="string"&&D&&o.set(A,D),v(R)||(u=!0);return}}let p=s[T];typeof p=="string"&&p&&o.set(A,p);let h=A.children;for(let x=0;x<h.length;x++)N(h[x],T===""?String(x):`${T}.${x}`)};return N(e,""),o}function so(e){return s=>{for(let o of e){let n=o(s);if(typeof n=="string"&&n!=="")return n}return null}}var dn=so([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Gn(e,s,o,n=null){let r=new Map,l=new Set,c=f=>{if(o(f))return;let u=s(f);u&&(r.has(u)?l.add(u):r.set(u,f))};if(n){let f=u=>{for(let v of u.querySelectorAll(n))c(v);for(let v of u.querySelectorAll("template"))v.content&&f(v.content)};c(e),f(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let f=u=>{c(u);let v=u.tagName==="TEMPLATE"&&u.content?u.content.children:u.children;for(let N=0;N<v.length;N++)f(v[N])};f(e)}for(let f of l)r.delete(f),f.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${f.slice(f.indexOf(":",6)+1)}"`);return r}var ws=new Set(["href","src","name","type","role"]),Oo=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function bn(e,s=5381){let o=s;for(let n=0;n<e.length;n++)o=(o<<5)+o^e.charCodeAt(n);return o>>>0}function Io(e){return e.replace(/\s+/g," ")}function Lo({ignored:e=()=>!1,ignoreAttribute:s=()=>!1}={}){let o=new WeakMap,n=new WeakMap;function r(T){let p=T.attributes,h=p.length;if(h===0)return{all:"",sig:T.tagName+"|"};let x=[],R="",M=[];for(let D=0;D<h;D++){let K=p[D],ie=K.name;s(T,ie)||x.push(ie+"="+K.value),ie==="class"?R=K.value.indexOf(" ")<0?K.value:K.value.split(/\s+/).filter(Boolean).sort().join(" "):ws.has(ie)&&M.push(ie+"="+K.value)}return x.length>1&&x.sort(),M.length>1&&M.sort(),{all:x.join(""),sig:T.tagName+"|"+R+(M.length?"|"+M.join("|"):"")}}function l(T){return T.nodeType===1&&T.tagName==="TEMPLATE"&&T.content?T.content.childNodes:T.childNodes}function c(T){let p=o.get(T);if(p)return p;if(T.nodeType===3)p={hash:"T"+bn(T.nodeValue),hint:Io(T.nodeValue).slice(0,64),sig:null,tok:null};else if(T.nodeType===8)p={hash:"C"+bn(T.nodeValue),hint:"",sig:null,tok:null};else if(T.nodeType===1){let h=r(T),x=bn(T.tagName+""+h.all),R="";for(let M of u(T))if(M.nodeType===1){let D=c(M);x=bn(D.hash,x),R.length<64&&(R+=" "+D.hint)}else x=bn(v(M),x),M.kind==="text"&&R.length<64&&(R+=M.value.slice(0,64));p={hash:"E"+x,hint:Io(R).trim().slice(0,64),sig:h.sig,tok:null}}else p={hash:"N"+T.nodeType,hint:"",sig:null,tok:null};return o.set(T,p),p}function f(T){if(!T.tok){T.tok=new Set;for(let p of T.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))p&&T.tok.add(p)}return T.tok}function u(T){let p=n.get(T);if(p)return p;p=[];let h=null,x=()=>{h&&(h.value=h.nodes.map(R=>R.nodeValue).join(""),p.push(h),h=null)};for(let R of l(T)){if(R.nodeType===3){h||(h={kind:"text",nodes:[],value:"",parent:T,hash:void 0}),h.nodes.push(R);continue}x(),R.nodeType===8?p.push({kind:"comment",nodes:[R],value:R.nodeValue,parent:T,hash:void 0}):R.nodeType===1&&!e(R)&&p.push(R)}return x(),n.set(T,p),p}function v(T){return T.nodeType===1?c(T).hash:(T.hash===void 0&&(T.hash=(T.kind==="text"?"T":"C")+bn(T.value)),T.hash)}function N(T,p){let h=f(c(T)),x=f(c(p));if(h.size===0&&x.size===0)return{coef:1,share:1};if(h.size===0||x.size===0)return null;let R=0;for(let M of h)x.has(M)&&R++;return{coef:R/Math.min(h.size,x.size),share:R/Math.max(h.size,x.size)}}function A(T,p){let h=N(T,p);return!!h&&h.coef>=.5}return{meta:c,unitsOf:u,unitHash:v,similar:A,score:N,childrenOf:l}}var Co=16,As=2e3,Ts=3,xs={align:0};function ro(e,s,o){let{meta:n,unitsOf:r,unitHash:l,similar:c,score:f}=o.analyzer,u=o.baseId||(()=>null),v=o.sideId||(()=>null),N=new Map,A=new Map,T=new Set,p=new Map,h=new Set,x=new Set,R=new Set,M=[],D=[],K=[],ie=[],ge=As,Me=new Map,Ae=new Map,_=(i,k)=>{N.set(i,k),A.set(k,i)},C=i=>!!i&&i.nodeType===1,fe=(i,k)=>{let b=p.get(i);return!!b&&b.has(k)},J=i=>Oo.has(i.tagName),he=(i,k)=>{let b=u(i);if(!b)return!0;let V=v(k);return!V||b===V},Se=globalThis.__hyperMorphProfile,ct=Se?performance.now():0;Se&&(n(e),n(s),Se.meta=(Se.meta||0)+(performance.now()-ct),ct=performance.now()),_(e,s);for(let[i,k]of o.baseIndex){let b=o.sideIndex.get(i);b&&b.tagName===k.tagName&&!N.has(k)&&!A.has(b)&&_(k,b)}ie.push([e,s]);for(let[i,k]of N)C(i)&&i!==e&&ie.push([i,k]);return We(),ot(),Se&&(Se.align=(Se.align||0)+(performance.now()-ct)),{map:N,reverse:A,moved:h,identical:x,pairIdenticalChildren:H,weak:T,unpair:lt,rematch:ot,insertedByHash:oe};function ot(){ht(),We();for(let i=0;i<K.length;){let k=K.length;ze(i,k),i=k,We(),ht(),We()}}function lt(i){let k=N.get(i);if(!k)return;p.has(i)||p.set(i,new Set),p.get(i).add(k);let b=(I,O)=>{N.delete(I),A.delete(O),h.delete(I),x.delete(I),T.delete(I),R.delete(I)},V=(I,O)=>{for(let j of r(I)){let S=N.get(j);!S||!(C(S)?O.contains(S):O.contains(S.nodes[0]))||(b(j,S),C(j)&&V(j,S))}};b(i,k),C(i)&&V(i,k),M.push(i),D.push(k)}function oe(){let i=new Map;for(let k of new Set(D)){if(A.has(k))continue;let b=n(k).hash;i.has(b)||i.set(b,[]),i.get(b).push(k)}return i}function We(){for(;ie.length;){let[i,k]=ie.shift();R.has(i)||x.has(i)||dt(i,k)}}function Fe(i,k){if(!J(i))for(let b of r(i))C(b)&&(k.push(b),Fe(b,k))}function dt(i,k){R.add(i);let b=r(i),V=r(k);xs.align+=b.length+V.length,Me=new Map,Ae=new Map;for(let P=0;P<b.length;P++)Me.set(b[P],P);for(let P=0;P<V.length;P++)Ae.set(V[P],P);if(i.tagName==="HTML")for(let P of["HEAD","BODY"]){let X=b.find(Te=>C(Te)&&Te.tagName===P),ee=V.find(Te=>C(Te)&&Te.tagName===P);X&&ee&&!N.has(X)&&!A.has(ee)&&_(X,ee)}for(let P=0;P<b.length&&P<V.length;P++){let X=b[P],ee=V[P];N.has(X)||A.has(ee)||(C(X)?C(ee)&&X.tagName===ee.tagName&&X.isEqualNode(ee)&&y(X,ee):!C(ee)&&X.kind===ee.kind&&X.value===ee.value&&y(X,ee))}st(b,V);let I=b.filter(P=>!N.has(P)),O=V.filter(P=>!A.has(P));I.length&&O.length&&(at(I,O),se(I,O),Z(I,O,b,V),Xe(b,V));let j=!1,S=!1;for(let P of b){if(!N.has(P)){C(P)&&(M.push(P),Fe(P,M),j=!0);continue}C(P)&&!x.has(P)&&ie.push([P,N.get(P)])}for(let P of V)!A.has(P)&&C(P)&&(D.push(P),Fe(P,D),S=!0);j&&S&&K.push([i,k])}function ze(i,k){for(let b=i;b<k;b++){let[V,I]=K[b],O=r(V),j=r(I),S=new Map,P=new Map,X=null;for(let ee of O)C(ee)&&(N.has(ee)?X=ee:(S.has(X)||S.set(X,[]),S.get(X).push(ee)));X=null;for(let ee of j)C(ee)&&(A.has(ee)?X=A.get(ee):(P.has(X)||P.set(X,[]),P.get(X).push(ee)));for(let[ee,Te]of S){let tt=P.get(ee);if(!(!tt||Te.length!==tt.length)&&Te.every((wt,pt)=>tt[pt].tagName===wt.tagName&&he(wt,tt[pt])&&!fe(wt,tt[pt])))for(let wt=0;wt<Te.length;wt++)Ge(Te[wt],tt[wt])}}}function Ge(i,k){_(i,k),T.add(i),ie.push([i,k]),We()}function at(i,k){let b=kn(i,l),V=kn(k,l),I=new Map;for(let O of k){let j=l(O);V.get(j)===1&&I.set(j,O)}for(let O of i){if(N.has(O))continue;let j=l(O);if(b.get(j)!==1)continue;let S=I.get(j);S&&!A.has(S)&&y(O,S)}}function y(i,k){_(i,k),x.add(i),C(i)&&R.add(i)}function H(i){let k=N.get(i);if(!k||!C(i))return;let b=r(i),V=r(k);for(let I=0;I<b.length&&I<V.length;I++)N.has(b[I])||y(b[I],V[I])}function se(i,k){let b=j=>C(j)&&!J(j)?n(j).sig+""+n(j).hint:null,V=kn(i,b),I=kn(k,b),O=new Map;for(let j of k){let S=b(j);S!=null&&I.get(S)===1&&O.set(S,j)}for(let j of i){if(N.has(j))continue;let S=b(j);if(S==null||V.get(S)!==1)continue;let P=O.get(S);P&&!A.has(P)&&he(j,P)&&_(j,P)}}function Z(i,k,b,V){let I=new Map;for(let j of k){if(!C(j)||A.has(j)||J(j))continue;let S=n(j).sig;I.has(S)||I.set(S,[]),I.get(S).push({el:j,index:Ae.get(j)})}let O=[];for(let j of i){if(N.has(j)||!C(j)||J(j))continue;let S=I.get(n(j).sig);if(!S||!S.length)continue;let P=Me.get(j),X=S.filter(ee=>!A.has(ee.el)).map(ee=>({c:ee,d:Math.abs(ee.index-P)}));X.sort((ee,Te)=>ee.d-Te.d),X.length>Co&&(X=X.slice(0,Co));for(let{c:ee,d:Te}of X){if(!he(j,ee.el))continue;let tt=f(j,ee.el);tt&&tt.coef>=.5&&O.push({b:j,s:ee.el,coef:tt.coef,share:tt.share,d:Te,bi:P})}}O.sort((j,S)=>S.coef-j.coef||S.share-j.share||j.d-S.d||j.bi-S.bi);for(let j of O)!N.has(j.b)&&!A.has(j.s)&&_(j.b,j.s)}function Oe(i,k){return C(i)!==C(k)?!1:C(i)?i.tagName!==k.tagName||!he(i,k)?!1:J(i)||n(i).hint===""||n(k).hint===""?!0:c(i,k):i.kind===k.kind}function rt(i,k){let b=(I,O)=>{let j=O===null?-1:I===k?Ae.get(O):Me.get(O),S=I[j+1];return S&&!C(S)?S:null},V=null;for(let I of i){if(C(I)){V=I;continue}if(N.has(I))continue;let O=V===null?null:N.get(V);if(V!==null&&!O)continue;let j=b(k,O);j&&!A.has(j)&&j.kind===I.kind&&_(I,j)}}function Xe(i,k){rt(i,k);let b=Qe(i,k),V=(O,j)=>C(O)&&n(O).hint!==""&&n(j).hint===""&&!!j.querySelector("br")&&!b(O,j),I=0;for(let O of i){if(N.has(O)){let S=Ae.get(N.get(O));S!==void 0&&S>=I&&(I=S+1);continue}let j=0;for(let S=I;S<k.length&&j<Ts;S++){let P=k[S];if(!A.has(P)&&(j++,Oe(O,P)&&!fe(O,P)&&!V(O,P))){_(O,P),C(O)&&(n(O).hint===""||n(P).hint==="")&&T.add(O),I=S+1;break}}}st(i,k)}function Qe(i,k){let b=(V,I,O)=>{for(let j=I-1;j>=0;j--)if(C(V[j])&&O(V[j]))return V[j];return null};return(V,I)=>{let O=Me.get(V),j=Ae.get(I);if(O===j)return!0;let S=b(i,O,X=>N.has(X)),P=b(k,j,X=>A.has(X));return S?N.get(S)===P:!P}}function st(i,k){let b=i.filter(S=>C(S)&&!N.has(S)),V=k.filter(S=>C(S)&&!A.has(S));if(!b.length||!V.length)return;let I=kn(b,S=>S.tagName),O=kn(V,S=>S.tagName),j=Qe(i,k);for(let S of b){let P=S.tagName;if(I.get(P)!==1||O.get(P)!==1)continue;let X=V.find(ee=>ee.tagName===P);X&&!A.has(X)&&j(S,X)&&he(S,X)&&!fe(S,X)&&(_(S,X),T.add(S))}}function ht(){let i=new Map;for(let S of T)if(C(S)&&C(N.get(S))){let P=n(S).hash;i.has(P)||i.set(P,[]),i.get(P).push(S)}if(i.size)for(let S of D){if(A.has(S)||!C(S))continue;let P=i.get(n(S).hash),X=P&&P.find(ee=>T.has(ee)&&!fe(ee,S)&&he(ee,S));X&&(lt(X),y(X,S),h.add(X))}let k=new Map,b=new Map,V=new Map;for(let S of T){let P=N.get(S);C(S)&&C(P)&&V.set(P,S)}let I=(S,P)=>{if(!A.has(S))return!0;let X=V.get(S);return X===A.get(S)&&X!==P&&!X.contains(P)},O=S=>{if(A.has(S)){let P=V.get(S);V.delete(S),lt(P)}};for(let S of[...D,...V.keys()]){if(A.has(S)&&!V.has(S))continue;let P=n(S).hash;if(k.has(P)||k.set(P,[]),k.get(P).push(S),J(S))continue;let X=n(S).sig;b.has(X)||b.set(X,[]),b.get(X).push(S)}let j=new Set;for(let S of T){let P=N.get(S);!C(S)||!C(P)||J(S)||n(S).hint===""||n(P).hint===""||c(S,P)||j.add(S)}for(let S of[...M,...j]){let P=N.get(S);if(P&&!(T.has(S)&&j.has(S)))continue;let X=pt=>{P&&lt(S),O(pt)},ee=k.get(n(S).hash);if(ee){let pt=ee.find(ue=>ue!==P&&I(ue,S)&&!fe(S,ue));if(pt){X(pt),y(S,pt),h.add(S);continue}}if(J(S)||ge<=0)continue;let Te=b.get(n(S).sig);if(!Te)continue;let tt=null,wt=0;for(let pt of Te)if(!(pt===P||!I(pt,S)||!he(S,pt)||fe(S,pt))&&(ge--<=0||c(S,pt)&&(wt++,tt=pt,wt>1)))break;wt===1&&(X(tt),_(S,tt),h.add(S),ie.push([S,tt]))}}}function kn(e,s){let o=new Map;for(let n of e){let r=s(n);r!=null&&o.set(r,(o.get(r)||0)+1)}return o}var Ns={diff:0},Eo=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,Ss=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,vs=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,Ms=/\P{M}\p{M}*/gu;function uo(e){if(e==="")return[];if(Eo){let o=[];for(let n of Eo.segment(e))o.push(n.segment);return o}let s=[];for(let o of e.match(vs))if(Ss.test(o))for(let n of o.match(Ms))s.push(n);else s.push(o);return s}var Is=/^[  ]+$/,Os=e=>Is.test(e)?" ".repeat(e.length):e,an=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),it="",io=e=>e.every(s=>an(s)||s.k===it),Ls=/^[\x00-\x7f\u00A0]*$/,Cs=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Es(e){return e===""?[]:e.match(Cs)}function hn(e,s=!1){return(s?Es(e):uo(e)).map(o=>({k:Os(o),raw:o,len:o.length}))}var $n=(...e)=>e.every(s=>Ls.test(s));function co(e,s,o){let n=e.length,r=s.length,l=Math.min(n+r,o),c=l+1,f=new Int32Array(2*l+3),u=[],v=n===0&&r===0;for(let p=0;p<=l&&!v;p++){u.push(f.slice(c-p,c+p+1));for(let h=-p;h<=p;h+=2){let x;h===-p||h!==p&&f[c+h-1]<f[c+h+1]?x=f[c+h+1]:x=f[c+h-1]+1;let R=x-h,M=x;for(;x<n&&R<r&&e[x].k===s[R].k;)x++,R++;if(Ns.diff+=1+x-M,f[c+h]=x,x>=n&&R>=r){v=!0;break}}}if(!v)return null;let N=[],A=n,T=r;for(let p=u.length-1;p>0;p--){let h=u[p],x=A-T,R=x+p,M=x===-p||x!==p&&h[R-1]<h[R+1]?x+1:x-1,D=h[M+p],K=D-M;for(;A>D&&T>K;)N.push([0,A-1,T-1]),A--,T--;A===D?(N.push([1,A,T-1]),T--):(N.push([-1,A-1,T]),A--)}for(;A>0&&T>0;)N.push([0,A-1,T-1]),A--,T--;return N.reverse(),N}function Rs(e,s,o){let n=A=>A.k===it;if(!e.some(n)&&!s.some(n))return co(e,s,o);let r=[],l=[];for(let A=0;A<e.length;A++)n(e[A])||r.push(A);for(let A=0;A<s.length;A++)n(s[A])||l.push(A);let c=co(r.map(A=>e[A]),l.map(A=>s[A]),o);if(!c)return null;let f=[],u=0,v=0,N=(A,T)=>{for(;u<A&&v<T&&e[u].k===s[v].k;)f.push([0,u++,v++]);let p=co(e.slice(u,A),s.slice(v,T),o);if(!p)return!1;for(let[h,x,R]of p)f.push([h,x+u,R+v]);return u=A,v=T,!0};for(let[A,T,p]of c)if(A===0){if(!N(r[T],l[p]))return null;f.push([0,u,v]),u++,v++}return N(e.length,s.length)?f:null}function yn(e,s,o=4e3){let n=[],r=0;for(;r<e.length&&r<s.length&&e[r].k===s[r].k;)e[r].raw!==s[r].raw&&n.push({bi:r,tok:s[r]}),r++;let l=0;for(;l<e.length-r&&l<s.length-r&&e[e.length-1-l].k===s[s.length-1-l].k;)e[e.length-1-l].raw!==s[s.length-1-l].raw&&n.push({bi:e.length-1-l,tok:s[s.length-1-l]}),l++;let c=e.slice(r,e.length-l),f=s.slice(r,s.length-l),u=js(c,f)?null:Rs(c,f,o);if(!u){let M=c.length||f.length?[{bs:r,be:r+c.length,toks:f}]:[];return{hunks:M,cosmetic:n,coarse:!0,parts:M.map(D=>({...D,gap:[],group:0})),cosmeticEq:n}}let v=[],N=(M,D)=>{c[M].raw!==f[D].raw&&n.push({bi:r+M,tok:f[D]})},A=null,T=[],p=0,h=0,x=()=>{A&&v.push(A),A=null;for(let[M,D]of T)N(M,D);T=[],p++};for(let[M,D,K]of u){if(M===0){A&&an(c[D])&&!c[D].k.includes(`
2
- `)?T.push([D,K]):(x(),N(D,K)),h=D+1;continue}(!A||T.length)&&(A&&v.push(A),A={bs:r+h,be:r+h,toks:[],gap:T.map(([ie,ge])=>({bi:r+ie,tok:f[ge]})),group:p},T=[]),M===-1?(A.be=r+h+1,h=D+1):A.toks.push(f[K])}x(),Hs(v,e);let R=ao(v);return{hunks:R.hunks,cosmetic:n.concat(R.cosmetic),parts:v,cosmeticEq:n}}function Hs(e,s){for(let o=0;o<e.length;o++){let n=e[o];if(n.gap.length)continue;let r=o+1<e.length?e[o+1].bs:1/0;if(n.toks.length){if(n.bs===n.be)for(;n.bs+1<r&&n.bs<s.length&&n.toks[0].k===it&&s[n.bs].k===it;)n.toks=[...n.toks.slice(1),n.toks[0]],n.bs++,n.be++}else for(;n.be+1<r&&n.be<s.length&&s[n.bs].k===it&&s[n.be].k===it;)n.bs++,n.be++}}function ao(e,s=()=>!1){let o=[],n=[],r=null,l=-1;for(let c of e){let f=s(c);if(r&&!r.alone&&!f&&c.group===l){r.be=c.be;for(let u of c.gap)r.toks.push(u.tok);for(let u of c.toks)r.toks.push(u);continue}r&&o.push({bs:r.bs,be:r.be,toks:r.toks});for(let u of c.gap)n.push(u);r={bs:c.bs,be:c.be,toks:c.toks.slice(),alone:f},l=c.group}return r&&o.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:o,cosmetic:n}}var Bs=(e,s)=>e.bs===s.bs&&e.be===s.be&&po(e.toks,s.toks);function ho(e,s,o){let n=N=>A=>N.some(T=>Bs(A,T)),r=ao(e.parts,n(s.parts)),l=ao(s.parts,n(e.parts)),c=e.cosmeticEq.concat(r.cosmetic),f=s.cosmeticEq.concat(l.cosmetic),[u,v]=o?Ds(r.hunks,l.hunks,o,c,f):[r.hunks,l.hunks];return{lh:u,rh:v,cosL:c,cosR:f}}function Ds(e,s,o,n,r){let l=(h,x)=>h.k===x.k&&h.raw===x.raw,c=[{list:e.map(h=>({...h})),resp:new Set(n.map(h=>h.bi)),raw:new Map(n.map(h=>[h.bi,h.tok]))},{list:s.map(h=>({...h})),resp:new Set(r.map(h=>h.bi)),raw:new Map(r.map(h=>[h.bi,h.tok]))}],f=h=>h.bs===h.be,u=(h,x,R,M)=>{let D=h.list[x];if(!f(D))return M(D)===R?D.toks:null;let K=x?h.list[x-1].be:0,ie=x+1<h.list.length?h.list[x+1].bs:o.length;if(R<K||R>ie)return null;let ge=D.toks,Me=D.bs;for(;Me>R;){let Ae=ge[ge.length-1];if(!l(Ae,o[Me-1])||h.resp.has(Me-1))return null;ge=[Ae,...ge.slice(0,-1)],Me--}for(;Me<R;){if(!l(ge[0],o[Me])||h.resp.has(Me))return null;ge=[...ge.slice(1),ge[0]],Me++}return ge},v=(h,x,R,M,D,K)=>{let ie=h.list[x],ge=D?R.slice(R.length-M):R.slice(0,M),Me=D?R.slice(0,R.length-M):R.slice(M),Ae={bs:K,be:K,toks:ge};if(f(ie)){if(!Me.length){h.list[x]=Ae;return}let C={bs:K,be:K,toks:Me};D&&(C.lead=!0),h.list.splice(x,1,...D?[C,Ae]:[Ae,C]);return}let _={bs:ie.bs,be:ie.be,toks:Me};h.list.splice(x,1,...D?[_,Ae]:[Ae,_])},N=(h,x,R,M,D)=>{let K=h.list[x],ie=D?R.slice(R.length-M):R.slice(0,M),ge=D?R.slice(0,R.length-M):R.slice(M),Me={bs:K.bs,be:K.be,toks:ie};if(!ge.length){h.list[x]=Me;return}let Ae=D?{bs:K.bs,be:K.bs,toks:ge,lead:!0}:{bs:K.be,be:K.be,toks:ge};h.list.splice(x,1,...D?[Ae,Me]:[Me,Ae])},A=(h,x,R,M)=>{let D=h.list[x],K=R.list[M],ie=D.be,ge=K.bs;if(ie>=ge||x+1<h.list.length&&h.list[x+1].bs<=K.be||M>0&&R.list[M-1].be>=D.bs)return!1;for(let oe=ie;oe<ge;oe++)if(!an(o[oe])||o[oe].k.includes(`
3
- `))return!1;let Me=oe=>o.slice(ie,ge).map((We,Fe)=>oe.raw.get(ie+Fe)||We),Ae=[...D.toks,...Me(h)],_=[...Me(R),...K.toks],C=(oe,We,Fe)=>We>=0&&We+Fe.length<=oe.length&&Fe.every((dt,ze)=>oe[We+ze].k===dt.k),fe=(oe,We,Fe)=>io(oe)&&o.slice(We,Fe).some(dt=>!an(dt)),J=oe=>oe.some(We=>!an(We)),he,Se,ct,ot;if(f(D)&&J(D.toks)&&C(_,0,D.toks)){let oe=_.slice(D.toks.length);fe(oe,ie,K.be)||(he=ie,Se=D.toks,ct=_.slice(0,D.toks.length),ot=[null,{bs:ie,be:K.be,toks:oe}])}if(he===void 0&&f(K)&&J(K.toks)){let oe=Ae.length-K.toks.length,We=Ae.slice(0,oe);C(Ae,oe,K.toks)&&!fe(We,D.bs,ge)&&(he=ge,Se=Ae.slice(oe),ct=K.toks,ot=[{bs:D.bs,be:ge,toks:We},null])}if(he===void 0)return!1;let lt=oe=>oe&&(oe.bs<oe.be||oe.toks.length);return h.list.splice(x,1,...[ot[0],{bs:he,be:he,toks:Se}].filter(lt)),R.list.splice(M,1,...[{bs:he,be:he,toks:ct},ot[1]].filter(lt)),!0},T=c[0],p=c[1];for(let h=0;h<64;h++){let x=!1;e:for(let R=0;R<T.list.length;R++)for(let M=0;M<p.list.length;M++){let D=T.list[R],K=p.list[M];if(!(D.bs===K.bs&&D.be===K.be&&po(D.toks,K.toks))){for(let ie of[!0,!1]){let ge=Ae=>ie?Ae.be:Ae.bs,Me=f(D)?[ge(K),D.bs]:[ge(D)];for(let Ae of Me){let _=u(T,R,Ae,ge),C=_&&u(p,M,Ae,ge);if(!C)continue;let fe=(ot,lt)=>ie?ot[ot.length-1-lt]:ot[lt],J=0;for(;J<_.length&&J<C.length&&fe(_,J).k===fe(C,J).k;)J++;if(!J)continue;let he=ie?_.slice(0,_.length-J):_.slice(J),Se=ie?C.slice(0,C.length-J):C.slice(J);if(!(J<_.length&&J<C.length&&!io(he)&&!io(Se)&&(f(D)&&f(K)||D.bs===K.bs&&D.be===K.be)||!(ie?_.slice(_.length-J):_.slice(0,J)).some(ot=>!an(ot)))){if(J===_.length&&J===C.length&&f(D)&&f(K)){if(D.bs===Ae&&K.bs===Ae)continue;T.list[R]={bs:Ae,be:Ae,toks:_},p.list[M]={bs:Ae,be:Ae,toks:C}}else!f(D)&&D.bs===K.bs&&D.be===K.be?(N(T,R,_,J,ie),N(p,M,C,J,ie)):(v(T,R,_,J,ie,Ae),v(p,M,C,J,ie,Ae));x=!0;break e}}}if(A(T,R,p,M)||A(p,M,T,R)){x=!0;break e}}}if(!x)break}return[T.list,p.list]}var Ps=48,Us=.3;function js(e,s){let o=e.filter(c=>!an(c)),n=s.filter(c=>!an(c));if(Math.min(o.length,n.length)<Ps)return!1;let r=new Map;for(let c of o)r.set(c.k,(r.get(c.k)||0)+1);let l=0;for(let c of n){let f=r.get(c.k);f>0&&(l++,r.set(c.k,f-1))}return l/Math.min(o.length,n.length)<Us}var _s=(e,s)=>{let o=new Set;for(let n of e.toks)typeof n.k!="string"&&o.add(n.k.el);for(let n=e.bs;n<e.be;n++)typeof s[n].k!="string"&&o.add(s[n].k.el);return o},po=(e,s)=>e.length===s.length&&e.every((o,n)=>o.k===s[n].k);function Ro(e,s,o,n="remote"){let r=yn(e,s),l=yn(e,o),{lh:c,rh:f,cosL:u,cosR:v}=ho(r,l,e),N=y=>y.bs===y.be,A=y=>y.toks.some(H=>typeof H.k=="string"),T=y=>N(y)&&!A(y),p=(y,H)=>H.bs<y.be&&y.bs<H.be,h=(y,H)=>!p(y,H)&&H.bs<=y.be&&y.bs<=H.be&&(N(y)&&A(y)||N(H)&&A(H))&&!(N(y)&&N(H)),x=(y,H)=>y.bs===H.bs&&y.be===H.be&&po(y.toks,H.toks),R=[],M=new Set;for(let y of c){let H=f.find(se=>!M.has(se)&&x(y,se));H?(M.add(H),R.push({bs:y.bs,be:y.be,side:"both",l:y,r:H,toks:y.toks})):R.push({bs:y.bs,be:y.be,side:"L",l:y,toks:y.toks,lead:!!y.lead})}for(let y of f)M.has(y)||R.push({bs:y.bs,be:y.be,side:"R",r:y,toks:y.toks,lead:!!y.lead});R.sort((y,H)=>y.bs-H.bs||y.be-H.be||H.lead-y.lead);let D=0,K=0;for(let y of R)y.side==="both"&&(D+=y.toks.length-(y.be-y.bs));let ie=R.map((y,H)=>H),ge=y=>ie[y]===y?y:ie[y]=ge(ie[y]),Me=(y,H)=>(y=ge(y),H=ge(H),y===H?!1:(ie[y]=H,!0)),Ae=R.map(y=>_s({bs:y.bs,be:y.be,toks:y.toks},e)),_={L:new Map,R:new Map};R.forEach((y,H)=>{let se=y.side==="both"?["L","R"]:[y.side];for(let Z of se)for(let Oe of Ae[H])_[Z].has(Oe)||_[Z].set(Oe,[]),_[Z].get(Oe).push(H)});for(let y of[_.L,_.R])for(let H of y.values())for(let se=1;se<H.length;se++)Me(H[0],H[se]);for(let y=0;y<R.length;y++)for(let H=y+1;H<R.length;H++){let se=R[y],Z=R[H];se.side===Z.side&&se.side!=="both"||se.bs>Z.be||(p(se,Z)||h(se,Z)?Me(y,H):se.bs===Z.bs&&N(se)&&N(Z)&&K++)}let C=(y,H)=>{let se=y==="L"?c:f;for(let Z of se)if(Z.toks.some(Oe=>Oe.kind==="close"&&Oe.k.el===H.el))return Z.bs;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="close"&&e[Z].k.el===H.el)return Z;return-1};R.forEach((y,H)=>{if(!(!T(y)||y.side==="both"))for(let se of y.toks){if(se.kind!=="open")continue;let Z=C(y.side,se.k);if(Z<=y.bs)continue;let Oe=new Uint8Array(Z-y.bs),rt=[];if(R.forEach((Xe,Qe)=>{if(!(Xe.side===y.side||N(Xe))&&Xe.bs<Z&&Xe.be>y.bs){rt.push(Qe);for(let st=Math.max(Xe.bs,y.bs);st<Math.min(Xe.be,Z);st++)Oe[st-y.bs]=1}}),rt.length&&Oe.every(Xe=>Xe===1))for(let Xe of rt)Me(H,Xe)}});let fe=!0;for(;fe;){fe=!1;let y=new Map;R.forEach((H,se)=>{let Z=ge(se),Oe=y.get(Z)||{bs:H.bs,be:H.be,L:!1,R:!1};Oe.bs=Math.min(Oe.bs,H.bs),Oe.be=Math.max(Oe.be,H.be),H.side!=="R"&&(Oe.L=!0),H.side!=="L"&&(Oe.R=!0),y.set(Z,Oe)}),R.forEach((H,se)=>{for(let[Z,Oe]of y){if(ge(se)===ge(Z)||!(Oe.L&&Oe.R))continue;let rt=H.bs<Oe.be&&H.be>Oe.bs,Xe=N(H)&&A(H)&&(H.bs===Oe.be||H.bs===Oe.bs);(rt||Xe)&&Me(se,Z)&&(fe=!0)}})}let J=new Map;R.forEach((y,H)=>{let se=ge(H);J.has(se)||J.set(se,[]),J.get(se).push(y)});let he=[];for(let y of J.values()){let H=y.some(Z=>Z.side==="L"),se=y.some(Z=>Z.side==="R");if(H&&se){let Z=Math.min(...y.map(Qe=>Qe.bs)),Oe=Math.max(...y.map(Qe=>Qe.be)),rt=y.filter(Qe=>Qe.side!=="R").map(Qe=>Qe.l).sort((Qe,st)=>Qe.bs-st.bs),Xe=y.filter(Qe=>Qe.side!=="L").map(Qe=>Qe.r).sort((Qe,st)=>Qe.bs-st.bs);he.push({bs:Z,be:Oe,kind:"conflict",localHunks:rt,remoteHunks:Xe})}else for(let Z of y)he.push({bs:Z.bs,be:Z.be,kind:Z.side,u:Z})}let Se=(y,H)=>{let se=y==="L"?c:f;for(let Z of se)if(Z.toks.some(Oe=>Oe.kind==="close"&&Oe.k.el===H.el))return Z.bs+.5;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="close"&&e[Z].k.el===H.el)return Z;return 1/0},ct=(y,H)=>{let se=y==="L"?c:f;for(let Z of se)if(Z.toks.some(Oe=>Oe.kind==="open"&&Oe.k.el===H.el))return Z.bs-.5;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="open"&&e[Z].k.el===H.el)return Z;return-1/0},ot=y=>y.kind==="R"?"R":"L",lt=y=>y.kind==="R"?1:0;he.sort((y,H)=>{if(y.bs!==H.bs)return y.bs-H.bs;let se=y.bs===y.be,Z=H.bs===H.be;if(se!==Z)return se?-1:1;if(se&&Z&&y.kind!=="conflict"&&H.kind!=="conflict"){let rt=y.u.toks,Xe=H.u.toks,Qe=ht=>ht.length&&ht.every(i=>i.kind==="open"),st=ht=>ht.length&&ht.every(i=>i.kind==="close");if(Qe(rt)&&Qe(Xe)){let ht=Math.max(...rt.map(k=>Se(ot(y),k.k))),i=Math.max(...Xe.map(k=>Se(ot(H),k.k)));if(ht!==i)return i-ht}if(st(rt)&&st(Xe)){let ht=Math.min(...rt.map(k=>ct(ot(y),k.k))),i=Math.min(...Xe.map(k=>ct(ot(H),k.k)));return ht!==i?i-ht:lt(H)-lt(y)}}let Oe=rt=>rt.u&&rt.u.lead?1:0;return Oe(H)-Oe(y)||lt(y)-lt(H)||y.be-H.be});let oe=[],We=[],Fe=0,dt=y=>{y>Fe&&(oe.push({bs:Fe,be:y,toks:e.slice(Fe,y),source:"base"}),Fe=y)};for(let y of he){if(dt(y.bs),y.kind==="conflict"){let H=fo(e,y.localHunks,y.bs,y.be),se=fo(e,y.remoteHunks,y.bs,y.be),Z=n==="local"?H:n==="both"?H.concat(se):se;We.push({bs:y.bs,be:y.be,base:e.slice(y.bs,y.be),local:H,remote:se,resolved:Z}),oe.push({bs:y.bs,be:y.be,toks:Z,source:"conflict",localHunks:y.localHunks,localToks:H,keepsLocal:n!=="remote"})}else oe.push({bs:y.bs,be:y.be,toks:y.u.toks,source:y.kind==="R"?"remote":"local",localHunks:y.kind==="R"?[]:[y.u.l]});Fe=Math.max(Fe,y.be)}dt(e.length);let ze=new Map(u.map(y=>[y.bi,y.tok])),Ge=new Map(v.map(y=>[y.bi,y.tok])),at=[];for(let y of oe){y.source==="base"&&(y.toks=y.toks.map((H,se)=>{let Z=y.bs+se,Oe=ze.get(Z),rt=Ge.get(Z),Xe=Oe&&rt?n==="remote"?rt:Oe:Oe||rt||H;return Xe===H?H:{...Xe,cosmetic:!0}}));for(let H of y.toks)at.push({...H,src:y.source})}return{tokens:at,segments:oe,conflicts:We,localHunks:c,remoteHunks:f,collapsedDelta:D,samePoint:K,mapLocalOffset:Vs(e,c,oe)}}function fo(e,s,o,n){let r=[],l=o;for(let c of s)r=r.concat(e.slice(l,c.bs),c.toks),l=c.be;return r.concat(e.slice(l,n))}var lo=e=>e.reduce((s,o)=>s+o.len,0);function Vs(e,s,o){let n=new Int32Array(e.length+1);for(let c=0;c<e.length;c++)n[c+1]=n[c]+e[c].len;let r=s.map(c=>({bs:n[c.bs],be:n[c.be],text:c.toks.map(f=>f.raw).join(""),ref:c})),l=o.map(c=>({bs:n[c.bs],be:n[c.be],len:lo(c.toks),source:c.source,localHunks:c.localHunks||[],localLen:c.localToks?lo(c.localToks):0,keepsLocal:c.keepsLocal,ref:c}));return c=>{let f=null,u=null,v=0,N=0,A=0;for(let p of r){let h=p.bs-A;if(c<=N+h){f=A+(c-N);break}if(N+=h,A=p.bs,c<=N+p.text.length){u=p,v=c-N,f=p.bs;break}N+=p.text.length,A=p.be}f===null&&(f=A+(c-N));let T=0;for(let p of l){if(!u&&f<=p.bs)return T;if(!(u?p.localHunks.includes(u.ref):f<p.be)){T+=p.len;continue}if(p.source==="base")return T+(f-p.bs);if(p.source==="remote")return T+p.len;if(p.source==="local")return T+Math.min(v,p.len);if(!p.keepsLocal||!u)return T+p.len;let x=p.localHunks.indexOf(u.ref),R=lo(fo(e,p.localHunks.slice(0,x),p.ref.bs,u.ref.bs));return T+Math.min(R+v,p.localLen)}return T}}function wn(e,s,o,n="remote"){if(s===o||o===e)return{text:s,conflicts:[],mapLocalOffset:p=>Math.min(p,s.length),granularity:"word"};let r=$n(e,s,o),l=hn(e,r),c=hn(s,r),f=hn(o,r),u=l.length<=2e4&&c.length<=2e4&&f.length<=2e4?Ro(l,c,f,n):null,v="word",N=l;if(!u){let p=h=>h.split(/(?<=\n)/).map(x=>({k:x,raw:x,len:x.length}));N=p(e),u=Ro(N,p(s),p(o),n),v="line"}let A=p=>p.map(h=>h.raw).join(""),T=[0];for(let p of N)T.push(T[T.length-1]+p.len);return{text:A(u.tokens),conflicts:u.conflicts.map(p=>({bs:T[p.bs],be:T[p.be],base:A(p.base),local:A(p.local),remote:A(p.remote),resolved:A(p.resolved)})),mapLocalOffset:u.mapLocalOffset,granularity:v}}function An(e,s,o=4e3){if(e===s)return[];let n=$n(e,s),r=hn(e,n),l=hn(s,n),c=yn(r,l,o),f=[0];for(let u of r)f.push(f[f.length-1]+u.len);return c.hunks.map(u=>({bs:f[u.bs],be:f[u.be],text:u.toks.map(v=>v.raw).join("")}))}var xn="\uFFFC";var Ws={caret:0},nn=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(" ")),jo=new Set(["BR","WBR","IMG"]),Fs=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 pn(e,s={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(s.ignored&&s.ignored(e)||jo.has(e.tagName))return!0;if(!nn.has(e.tagName))return!Fs.has(e.tagName);if(s.remoteWins&&s.remoteWins(e))return!1;let o=s.inlineCache&&s.inlineCache.get(e);if(o!==void 0)return o;let n=!0;for(let r of e.childNodes)if(!pn(r,s)){n=!1;break}return s.inlineCache&&s.inlineCache.set(e,n),n}function Ks(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function Hn(e,s={}){let o={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null},n=(r,l)=>{for(let c of r){if(c.nodeType===3){let N=c.nodeValue;if(!N)continue;o.nodes.push({node:c,s:o.text.length,e:o.text.length+N.length}),o.text+=N;for(let A=0;A<N.length;A++)o.stackAt.push(l);continue}if(c.nodeType!==1)continue;if(s.ignored&&s.ignored(c)){o.pins.push({el:c,i:o.text.length});continue}if(s.skip&&s.skip.has(c))continue;let f=c.tagName;if(s.blocks&&s.blocks.has(c)){o.text.length&&o.text[o.text.length-1]!==it&&(o.stackAt.push(l),o.text+=it);let N={el:c,tag:f,from:o.text.length,to:-1,depth:l.length,block:!0};o.marks.push(N);let A=l.concat([N]);n(c.childNodes,A),o.stackAt.push(A),o.text+=it,N.to=o.text.length;continue}let u=nn.has(f)&&Ks(c);if(jo.has(f)||!nn.has(f)||s.remoteWins&&s.remoteWins(c)||s.atomize&&s.atomize(c)||u){o.atoms.push({i:o.text.length,el:c,key:u?f+":empty":f,stack:l}),o.stackAt.push(l),o.text+=xn;continue}let v={el:c,tag:f,from:o.text.length,to:-1,depth:l.length};o.marks.push(v),n(c.childNodes,l.concat([v])),v.to=o.text.length}};if(n(e,[]),o.atoms.length===1&&o.atoms[0].el.tagName==="BR"&&o.marks.length===0&&Yn(o).trim()===""){let r=o.atoms[0];o.placeholder=r.el,o.text=o.text.slice(0,r.i)+o.text.slice(r.i+1),o.stackAt.splice(r.i,1);for(let l of o.nodes)l.s>r.i&&(l.s--,l.e--);o.atoms=[]}return o.atomAt=new Map(o.atoms.map(r=>[r.i,r])),o}function zs(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function qs(e){let s="<"+e.tagName.toLowerCase();for(let o of e.attributes)s+=` ${o.name}="${o.value.replace(/"/g,"&quot;")}"`;return s+">"}function go(e,s,o){let n="",r=[];for(let l=s;l<o;l++){let c=e.stackAt[l],f=0;for(;f<r.length&&f<c.length&&r[f]===c[f];)f++;for(;r.length>f;)n+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<c.length;){let v=c[r.length];n+=qs(v.el),r.push(v)}let u=e.atomAt.get(l);n+=u?u.el.outerHTML:e.text[l]===it?"":zs(e.text[l])}for(;r.length;)n+=`</${r.pop().tag.toLowerCase()}>`;return n}function Gs(e,s){let o=[...e.el.attributes].filter(n=>!s(e.el,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tag+"|"+o}function _o(e,s){let o=[...e.attributes].filter(n=>!s(e,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tagName+"|"+o+"|"+e.innerHTML}function Ho(e,s=()=>!1){let o=new Map,n=l=>{let c=o.get(l);return c===void 0&&(c="{"+l.map(f=>Gs(f,s)).sort().join(",")+"}",o.set(l,c)),c},r="";for(let l=0;l<e.text.length;l++){let c=e.atomAt.get(l);r+=(c?"["+_o(c.el,s)+"]":e.text[l])+n(e.stackAt[l])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function Tn(e,s,o,n=r=>r.key){let r=[],l=e.text,c=0,f=u=>{if(u<=c)return;let v=l.slice(c,u);if(o)for(let N of v.split(/(?<=\n)/))r.push({k:N,raw:N,len:N.length});else for(let N of hn(v,s))r.push(N)};for(let u of e.atoms)f(u.i),r.push({k:"\0"+n(u),raw:xn,len:1,atom:!0}),c=u.i+1;return f(l.length),r}function Yn(e){if(!e.atoms.length)return e.text;let s="",o=0;for(let n of e.atoms)s+=e.text.slice(o,n.i),o=n.i+1;return s+e.text.slice(o)}var bo=e=>{let s=new Int32Array(e.length+1);for(let o=0;o<e.length;o++)s[o+1]=s[o]+e[o].len;return s};function Bo(e,s,o,n){let r=bo(s),l=bo(o),c=[],f=0,u=0;for(let N of n.hunks){u+=N.bs-f;let A=u+N.toks.length;c.push({bs:r[N.bs],be:r[N.be],ss:l[u],se:l[A],text:e.text.slice(l[u],l[A]),toks:N.toks,lead:!!N.lead}),u=A,f=N.be}let v=new Map;for(let N of n.cosmetic)v.set(N.bi,N.tok.raw);return{hunks:c,respell:v}}function Do(e,s,o){let n=c=>c===it||/\s/.test(c),r=c=>c.replace(/[\u001E\s]/g,""),l=[];for(let c of e){let f=s.slice(c.bs,c.be),u=o.slice(c.ss,c.se);if(!f.includes(it)&&!u.includes(it)||f.includes(xn)||u.includes(xn)||r(f)!==r(u)){l.push(c);continue}let v=0,N=0;for(;;){let A=v,T=N;for(;A<f.length&&n(f[A]);)A++;for(;T<u.length&&n(u[T]);)T++;let p=v,h=N;for(;p<A&&h<T&&f[p]===u[h];)p++,h++;let x=A,R=T;for(;x>p&&R>h&&f[x-1]===u[R-1];)x--,R--;if(x>p||R>h){let M=u.slice(h,R);l.push({bs:c.bs+p,be:c.bs+x,ss:c.ss+h,se:c.ss+R,text:M,toks:[...M].map(D=>({k:D,raw:D,len:1})),lead:c.lead})}if(A>=f.length)break;v=A+1,N=T+1}}return l}function Po(e,s,o){let n=new Int32Array(s+1).fill(-1),r=new Int32Array(o+1).fill(-1),l=0,c=0,f=u=>{for(;l<u;)n[l]=c,r[c]=l,l++,c++};for(let u of e)f(u.bs),l=u.be,c=u.se;return f(s),n[s]=c,r[c]=s,{bTo:n,toB:r}}function Uo(e,s){if(e.size!==s.size)return!1;for(let o of e)if(!s.has(o))return!1;return!0}function ko(e){let{out:s,policy:o="remote",L:n,R:r}=e,l=e.provenance||new WeakMap,c=e.textMappers||new WeakMap,f=e.conflicts||[],u=e.decisions||[],v=f.length,N=!!(n&&n.reverse&&n.map&&r&&r.reverse&&r.map),A={base:null,local:null,remote:null};if(N&&e.moveIn){let t=Q=>we=>Q.some(Y=>Y===we||Y.nodeType===1&&Y.contains(we)),a=t(e.local),m=t(e.remote),d=t(e.base),w=new Set,E=Q=>{if(!nn.has(Q.tagName))return;let we=n.map.get(Q),Y=r.map.get(Q);(we&&!a(we)||Y&&!m(Y))&&w.add(Q);for(let ce of Q.children)E(ce)};for(let Q of e.base)Q.nodeType===1&&E(Q);let q=Q=>we=>{if(!nn.has(we.tagName))return!1;let Y=Q.reverse.get(we);return!!Y&&(w.has(Y)||!d(Y))};w.size&&(A.base=Q=>w.has(Q)),A.local=q(n),A.remote=q(r)}let T={base:new Set,local:new Set,remote:new Set};if(N&&e.moveIn){let t=d=>w=>d.some(E=>E===w||E.nodeType===1&&E.contains(w)),a=t(e.local),m=t(e.remote);for(let d of Hn(e.base,{...e,atomize:A.base}).atoms){let w=n.map.get(d.el),E=r.map.get(d.el),q=!!w&&!a(w),Q=!!E&&!m(E);!q&&!Q||(T.base.add(d.el),w&&!q&&T.local.add(w),E&&!Q&&T.remote.add(E),a(d.el)&&T.local.add(d.el),m(d.el)&&T.remote.add(d.el))}}let p=Hn(e.base,{...e,atomize:A.base,skip:T.base}),h=Hn(e.local,{...e,atomize:A.local,skip:T.local}),x=Hn(e.remote,{...e,atomize:A.remote,skip:T.remote}),R=new Map(p.atoms.map(t=>[t.el,t])),M=(t,a,m)=>{a.namespaceURI?t.setAttributeNS(a.namespaceURI,a.name,m):t.setAttribute(a.name,m)},D=(t,a,m,d)=>{if(!a&&(!m||!d)){for(let E of(m||d).attributes)M(t,E,E.value);return}let w=new Map;for(let E of[a,m,d])if(E)for(let q of E.attributes)w.set(q.name,q);for(let[E,q]of w){let Q=a?a.getAttribute(E):null,we=m?m.getAttribute(E):Q,Y=d?d.getAttribute(E):Q,ce;we===Y?ce=we:we===Q?(ce=Y,u.push({kind:"attr",el:t,name:E,source:"remote"})):Y===Q?(ce=we,u.push({kind:"attr",el:t,name:E,source:"local"})):(ce=o==="local"?we:Y,f.push({kind:"attr",el:t,name:E,base:Q,local:we,remote:Y,resolved:ce}),u.push({kind:"attr",el:t,name:E,source:"both"})),ce!=null&&M(t,q,ce)}},K=(t,a,m,d)=>t&&e.mergeAttrs?e.mergeAttrs(t,a,m,d):D(d,t,a,m),ie=e.mergeElement||((t,a,m)=>{let d=s.createElement(t.tagName);K(t,a,m,d);let w=a||t,E=m||t,q=o==="local"?w.isEqualNode(t)?E:w:E.isEqualNode(t)?w:E;for(let Q of q.childNodes)d.appendChild(s.importNode(Q,!0));return l.set(d,{base:t,local:a,remote:m}),d}),ge=e.cloneUnit||((t,a)=>{let m=s.importNode(t,!0);return l.set(m,{base:null,local:a==="local"?t:null,remote:a==="remote"?t:null}),m}),Me=e.atomKey||(t=>_o(t,()=>!1)),Ae=(t,a)=>{let m=new Map;for(let d of t.atoms)if(e.remoteWins&&e.remoteWins(d.el)&&nn.has(d.el.tagName))m.set(d,"w"+d.el.tagName+"#"+(d.el.id||""));else if(!N)m.set(d,d.key);else if(t===p)m.set(d,"="+Me(d.el));else{let w=a.reverse.get(d.el),E=w?R.get(w):null;E?m.set(d,"="+Me(E.el)):w?m.set(d,"m"+Me(d.el)):m.set(d,"="+Me(d.el))}return d=>m.get(d)},_=Ae(p,null),C=Ae(h,n),fe=Ae(x,r),J=$n(Yn(p),Yn(h),Yn(x)),he=Tn(p,J,!1,_),Se=Tn(h,J,!1,C),ct=Tn(x,J,!1,fe),ot=he.length>2e4||Se.length>2e4||ct.length>2e4;ot&&(he=Tn(p,J,!0,_),Se=Tn(h,J,!0,C),ct=Tn(x,J,!0,fe));let lt=ho(yn(he,Se),yn(he,ct),he),oe=Bo(h,he,Se,{hunks:lt.lh,cosmetic:lt.cosL}),We=Bo(x,he,ct,{hunks:lt.rh,cosmetic:lt.cosR});oe.hunks=Do(oe.hunks,p.text,h.text),We.hunks=Do(We.hunks,p.text,x.text);let Fe=Po(oe.hunks,p.text.length,h.text.length),dt=Po(We.hunks,p.text.length,x.text.length),ze=p.text.length,Ge=t=>new Map(t.atoms.map(a=>[a.el,a])),at=Ge(h),y=Ge(x),H=(t,a,m)=>{let d=new Set;if(!N)return d;for(let w of t.atoms){let E=R.get(a.reverse.get(w.el));E&&m.bTo[E.i]<0&&d.add(E)}return d},se=H(h,n,Fe),Z=H(x,r,dt),Oe=t=>!pn(t,{...e,remoteWins:null}),rt=new Set;if(N)for(let t of p.atoms){if(!Oe(t.el))continue;let a=n.map.get(t.el)||null,m=r.map.get(t.el)||null,d=a&&!m?a:m&&!a?m:null;d&&(at.has(d)||y.has(d))&&!d.isEqualNode(t.el)&&rt.add(t)}let Xe=1,Qe=(t,a)=>({id:Xe++,tag:t,base:null,local:null,remote:null,rank:a}),st=new Map,ht=[];for(let t of p.marks){let a=Qe(t.tag,t.depth);a.block=!!t.block,a.base=t.el,a.baseMark=t,st.set(t.el,a),ht.push(a)}let i=(t,a)=>{let m=-1,d=-1;for(let w=t.from;w<t.to;w++){let E=a[w];E>=0&&(m<0&&(m=E),d=E+1)}return m<0?null:[m,d]},k=(t,a,m,d)=>{for(let w of t.marks){let E=m?m.reverse.get(w.el):null;E&&m.identical.has(E)&&m.pairIdenticalChildren&&m.pairIdenticalChildren(E);let q=E?st.get(E):null;if(q&&q[a]&&(q=null),!q){let Q=i(w,d),we=0;if(Q)for(let Y of ht){if(Y.tag!==w.tag||Y[a]||!!Y.block!=!!w.block)continue;let ce=Math.min(Q[1],Y.baseMark.to)-Math.max(Q[0],Y.baseMark.from);(ce>we||ce===we&&ce>0&&Math.abs(Y.rank-w.depth)<Math.abs(q.rank-w.depth))&&(q=Y,we=ce)}}q||(q=Qe(w.tag,w.depth),q.block=!!w.block,q.new=a),q[a]=w.el,q[a+"Mark"]=w,st.set(w.el,q)}};k(h,"local",n,Fe.toB),k(x,"remote",r,dt.toB);let b=t=>t.merged||t,V=t=>{let a=new Set;for(let m of t)m.block||a.add(st.get(m.el));return a},I=new Map,O=t=>{let a=I.get(t);return a||(a=V(t),I.set(t,a)),a},j=(t,a)=>{let m=[],d=null;for(let w=0;w<ze;w++){let E=a[w];if(E<0){d&&m.push(d),d=null;continue}let q=O(p.stackAt[w]),Q=O(t.stackAt[E]),we=new Set,Y=new Set;for(let ce of Q)q.has(ce)||we.add(ce);for(let ce of q)Q.has(ce)||Y.add(ce);if(!we.size&&!Y.size){d&&m.push(d),d=null;continue}if(d&&Uo(d.added,we)&&Uo(d.removed,Y)){d.be=w+1;continue}d&&m.push(d),d={bs:w,be:w+1,added:we,removed:Y}}return d&&m.push(d),m},S=j(h,Fe.bTo),P=j(x,dt.bTo),X=t=>t.be>t.bs?[t.bs,t.be-1]:[t.bs-1,t.bs],ee=(t,a)=>{if(ze===0)return null;let[m,d]=X(t);for(let w of a){if(w.be<=m)continue;if(w.bs>d)break;let E=w.bs<=m&&d<w.be;return E&&t.text===""&&w.bs===t.bs&&w.be===t.be?"straddle":E?w:t.be>t.bs?"straddle":null}return null},Te=t=>t.bs===t.be,tt=(t,a)=>{let m=!1;for(let d=t.bs;d<t.be;d++){let w=p.text[d];if(w===it)m=!0;else if(!/\s/.test(w))return!1}for(let d=t.ss;d<t.se;d++){let w=a.text[d];if(w===it)m=!0;else if(!/\s/.test(w))return!1}return m},wt=(t,a)=>t.bs<a.be&&a.bs<t.be,pt=(t,a)=>t.bs<=a.be&&a.bs<=t.be&&Te(t)!==Te(a),ue=(t,a)=>p.text.slice(t.bs,t.be).includes(it)||a.text.slice(t.ss,t.se).includes(it),Ze=t=>{if(Te(t))return!1;let a=t.bs,m=t.be;for(;a>0&&/\s/.test(p.text[a-1]);)a--;for(;m<p.text.length&&/\s/.test(p.text[m]);)m++;return(a===0||p.text[a-1]===it)&&(m===p.text.length||p.text[m]===it)},Et=(t,a)=>!ue(t,a)&&!Ze(t),At=(t,a)=>wt(t,a)||pt(t,a)&&!(tt(t,h)&&Et(a,x))&&!(tt(a,x)&&Et(t,h)),Bt=(t,a)=>{if(t.bs!==a.bs||t.be!==a.be||t.toks.length!==a.toks.length)return!1;let m=t.ss,d=a.ss;for(let w=0;w<t.toks.length;w++){let E=t.toks[w],q=a.toks[w];if(E.k!==q.k||E.atom&&!h.atomAt.get(m).el.isEqualNode(x.atomAt.get(d).el))return!1;m+=E.len,d+=q.len}return!0},jt=(t,a,m,d)=>{for(let w of p.atoms){if(w.i<t.bs||w.i>=t.be||d.has(w)||rt.has(w))continue;let E=a.bTo[w.i],q=E>=0?m.atomAt.get(E):null;if(q&&!q.el.isEqualNode(w.el))return!0}return!1},Nt=[],St=oe.hunks,g=We.hunks,L=0,B=0,F=0,U=0,W=0,$=t=>{t>F&&(Nt.push({src:"base",from:F,to:t,dL:U,dR:W}),F=t)};for(;L<St.length||B<g.length;){let t=St[L],a=g[B],m=!!t&&(!a||t.bs<a.bs||t.bs===a.bs&&t.be<=a.be&&!a.lead);if(t&&a&&t.bs===a.bs&&Te(t)&&Te(a)){let It=tt(t,h),un=tt(a,x);It!==un&&(m=un)}let d=m?t:a,w=m?a:t,E=!!w&&Bt(t,a),q=!!w&&(m?!!St[L+1]&&Bt(St[L+1],a):!!g[B+1]&&Bt(t,g[B+1])),Q=!!w&&!E&&!q&&(ze===0||At(t,a)),we=Q,Y=ee(d,m?P:S);if(Y==="straddle"&&(we=!0),!we&&d.be>d.bs&&(we=jt(d,m?dt:Fe,m?x:h,m?se:Z)),!we&&E){$(d.bs),Nt.push({src:"both",lfrom:t.ss,rfrom:a.ss,len:d.text.length}),F=d.be,U+=d.text.length-(d.be-d.bs),W+=d.text.length-(d.be-d.bs),L++,B++;continue}if(!we){$(d.bs),Nt.push({src:m?"local":"remote",from:d.ss,to:d.se,inherit:Y&&Y!=="straddle"?Y:null}),F=d.be,m?(U+=d.text.length-(d.be-d.bs),L++):(W+=d.text.length-(d.be-d.bs),B++);continue}let ce=d.bs,_e=d.be,Ee=L,je=B,kt=It=>It.bs<_e&&It.be>ce||Te(It)&&(It.bs===ce||It.bs===_e);m?Ee++:je++,Q&&(ce=Math.min(ce,w.bs),_e=Math.max(_e,w.be),m?je++:Ee++);let ut=!0;for(;ut;){for(ut=!1;Ee<St.length&&kt(St[Ee]);)ce=Math.min(ce,St[Ee].bs),_e=Math.max(_e,St[Ee].be),Ee++,ut=!0;for(;je<g.length&&kt(g[je]);)ce=Math.min(ce,g[je].bs),_e=Math.max(_e,g[je].be),je++,ut=!0}let Wt=ce+U,Ht=ce+W,Jt=_e-ce,Zt=_e-ce;for(let It=L;It<Ee;It++)Jt+=St[It].text.length-(St[It].be-St[It].bs);for(let It=B;It<je;It++)Zt+=g[It].text.length-(g[It].be-g[It].bs);let sn=Wt+Jt,rn=Ht+Zt;$(ce);let Mt={kind:"text",node:e.node||null,base:go(p,ce,_e),local:go(h,Wt,sn),remote:go(x,Ht,rn),resolved:null,range:null,bs:ce,be:_e,lss:Wt,lse:sn,rss:Ht,rse:rn};Mt.resolved=o==="local"?Mt.local:o==="remote"?Mt.remote:Mt.local+Mt.remote,o!=="remote"&&Nt.push({src:"local",from:Wt,to:sn,conflict:Mt}),o!=="local"&&Nt.push({src:"remote",from:Ht,to:rn,conflict:Mt}),f.push(Mt),F=_e,U+=Jt-(_e-ce),W+=Zt-(_e-ce),L=Ee,B=je}$(ze);let re=p.text,be=[];if(oe.respell.size||We.respell.size){let t=bo(he),a=[];for(let m=0;m<he.length;m++){let d=he[m].raw,w=oe.respell.get(m)??d,E=We.respell.get(m)??d;(w!==d||E!==d)&&be.push([t[m],w!==d&&E!==d?"both":w!==d?"local":"remote"]),a.push(w===E?w:w===d?E:E===d||o==="local"?w:E)}re=a.join("")}let de="",ke=[],Pe=[],Be=[],Tt=[];for(let t of Nt){let a=de.length;if(t.src==="base"){for(let m=t.from;m<t.to;m++)ke.push(m),Pe.push(m+t.dL),Be.push(m+t.dR),Tt.push(t);de+=re.slice(t.from,t.to)}else if(t.src==="both"){for(let m=0;m<t.len;m++)ke.push(-1),Pe.push(t.lfrom+m),Be.push(t.rfrom+m),Tt.push(t);de+=h.text.slice(t.lfrom,t.lfrom+t.len)}else{let m=t.src==="local"?h:x;for(let d=t.from;d<t.to;d++)ke.push(-1),Pe.push(t.src==="local"?d:-1),Be.push(t.src==="remote"?d:-1),Tt.push(t);de+=m.text.slice(t.from,t.to)}t.ms=a,t.me=de.length,t.conflict&&(t.conflict.range||(t.conflict.range=[a,a]),t.conflict.range[1]=de.length)}let pe=de.length,Ye=new Int32Array(ze+1).fill(-1),ve=new Int32Array(h.text.length+1).fill(-1),Lt=new Int32Array(x.text.length+1).fill(-1);for(let t=0;t<pe;t++)ke[t]>=0&&(Ye[ke[t]]=t),Pe[t]>=0&&(ve[Pe[t]]=t),Be[t]>=0&&(Lt[Be[t]]=t);let xt=(t,a)=>{let m=-1,d=-1;for(let w=t.from;w<t.to;w++){let E=a[w];E>=0&&(m<0&&(m=E),d=E+1)}return m<0?null:[m,d]},Ot=[],gt=[];for(let t of new Set(st.values()))t.new==="local"?Ot.push(t):t.new==="remote"&&gt.push(t);let Ln=(t,a)=>{t.remote=a.remote,t.remoteMark=a.remoteMark,t.new="both",a.merged=t,st.set(a.remote,t)};if(Ot.length&&gt.length){let t=e.idOf;for(let a of Ot){let m=t?t.local(a.local):null;if(!m)continue;let d=gt.find(w=>!w.merged&&w.tag===a.tag&&!!w.block==!!a.block&&t.remote(w.remote)===m);d&&Ln(a,d)}for(let a of Ot){if(a.remote)continue;let m=xt(a.localMark,ve);if(m)for(let d of gt){if(d.merged||d.tag!==a.tag||!!d.block!=!!a.block)continue;let w=xt(d.remoteMark,Lt);if(w&&Math.min(m[1],w[1])-Math.max(m[0],w[0])>0){Ln(a,d);break}}}}I.clear();let Cn=t=>{for(let a of t)if(a.block)return b(st.get(a.el));return null},tn=p.marks.some(t=>t.block)||h.marks.some(t=>t.block)||x.marks.some(t=>t.block),Gt=new Array(pe).fill(null),mn=new Set;if(tn){let t=(Y,ce,_e)=>{let Ee=new Set([Y,ce,_e]);Ee.delete(null);let je=[];for(let ut of Ee){let Wt=ut===Y,Ht=ut===ce,Jt=ut===_e;(Ht===Jt?Ht:Ht===Wt?Jt:Ht)&&je.push(ut)}if(je.length<=1)return je[0]||null;let kt=o==="local"?ce:_e;return je.includes(kt)?kt:je[0]},a=(Y,ce)=>ce>=0?Cn(Y.stackAt[ce]):null,m=new Map;for(let Y=0;Y<pe;Y++){if(de[Y]!==it)continue;let ce=ke[Y]>=0?a(p,ke[Y]):null,_e=a(h,Pe[Y]),Ee=a(x,Be[Y]);m.set(Y,[ce,ke[Y]>=0?t(ce,_e,Ee):_e||Ee])}let d=new Set([...m.values()].map(Y=>Y[1])),w=Y=>Y!==it&&Y!==xn&&!/\s/.test(Y),E=(Y,ce)=>{let _e=Y;for(;_e<ce&&!w(de[_e]);)_e++;return _e<ce&&ke[_e]>=0?a(p,ke[_e]):null},q=new Map,Q=0;for(let Y=0;Y<pe;Y++){if(de[Y]!==it)continue;let[ce,_e]=m.get(Y),Ee=E(Q,Y),je=_e,kt=q.get(je)===je&&Ee===je;je&&q.has(je)&&!kt&&ce&&!q.has(ce)&&!d.has(ce)&&(je=ce),je&&!q.has(je)&&q.set(je,Ee);for(let ut=Q;ut<=Y;ut++)Gt[ut]=je;Q=Y+1}let we=Y=>{for(let ce=0;ce<Y.text.length;ce++)if(w(Y.text[ce])&&!a(Y,ce))return!0;return!1};if(!we(p)&&!we(h)&&!we(x)){let Y=[],ce=0;for(let Ee=0;Ee<pe;Ee++)(de[Ee]===it||Ee===pe-1)&&(Y.push([ce,Ee]),ce=Ee+1);let _e=new Set(Gt);for(let Ee=0;Ee<Y.length;Ee++){let[je,kt]=Y[Ee];if(Gt[kt])continue;let ut=je;for(;ut<=kt&&!w(de[ut]);)ut++;if(ut>kt)continue;let Wt=a(p,ke[ut]),Ht=a(h,Pe[ut]),Jt=a(x,Be[ut]),Zt=t(Wt,Ht,Jt)||Ht||Jt||Wt;if(Zt&&!_e.has(Zt)){_e.add(Zt);for(let Mt=je;Mt<=kt;Mt++)Gt[Mt]=Zt;continue}let sn=Ee>0&&Gt[Y[Ee-1][1]],rn=Ee+1<Y.length&&Gt[Y[Ee+1][1]];if(sn)mn.add(Y[Ee-1][1]);else if(rn&&de[kt]===it)mn.add(kt);else continue;for(let Mt=je;Mt<=kt;Mt++)Gt[Mt]=sn||rn}}}let jn=new Map,_n=t=>{let a=jn.get(t);if(a)return a;a=[1/0,-1/0];for(let[m,d]of[[t.baseMark,Ye],[t.localMark,ve],[t.remoteMark,Lt]]){let w=m&&xt(m,d);w&&(a[0]=Math.min(a[0],w[0]),a[1]=Math.max(a[1],w[1]))}return jn.set(t,a),a},Vn=(t,a,m)=>{let d=-1,w=-1;for(let E=0;E<t.length;E++){let q=st.get(t[E].el);q===a&&(d=E),q===m&&(w=E)}return d>=0&&w>=0?d-w:0},gn=(t,a)=>[...t].sort((m,d)=>{for(let q of a){let Q=Vn(q,m,d);if(Q)return Q}let w=_n(m),E=_n(d);return w[0]-E[0]||E[1]-w[1]||m.rank-d.rank||m.id-d.id}),Wn=new Map,z=new Map,Ne=t=>{let a=ke[t],m=Pe[t],d=Be[t],w=Tt[t];if(a>=0){let Ee=p.stackAt[a],je=h.stackAt[m],kt=x.stackAt[d],ut=Wn.get(Ee);ut||Wn.set(Ee,ut=new Map);let Wt=ut.get(je);Wt||ut.set(je,Wt=new Map);let Ht=Wt.get(kt);if(Ht)return Ht;let Jt=O(Ee),Zt=O(je),sn=O(kt),rn=new Set;for(let Mt of new Set([...Jt,...Zt,...sn])){let It=Jt.has(Mt),un=Zt.has(Mt),So=sn.has(Mt);(un===So?un:un===It?So:un)&&rn.add(Mt)}return Ht=gn(rn,[je,kt,Ee]),Wt.set(kt,Ht),Ht}if(w.src==="both"){let Ee=h.stackAt[m],je=x.stackAt[d];return gn(new Set([...O(Ee),...O(je)]),[Ee,je])}let q=(w.src==="local"?h:x).stackAt[w.src==="local"?m:d];if(!w.inherit)return gn(O(q),[q]);let Q=z.get(w);Q||z.set(w,Q=new Map);let we=Q.get(q);if(we)return we;let Y=new Set(O(q));for(let Ee of w.inherit.added)Y.add(b(Ee));for(let Ee of w.inherit.removed)Y.delete(b(Ee));let ce=w.src==="local"?x:h,_e=(w.src==="local"?dt.bTo:Fe.bTo)[w.inherit.bs];return we=gn(Y,[q,ce.stackAt[_e]]),Q.set(q,we),we},me=new Int32Array(h.text.length+1);me[h.text.length]=pe;for(let t=h.text.length-1;t>=0;t--)me[t]=ve[t]>=0?ve[t]:me[t+1];Ws.caret+=h.text.length;let Le=t=>t<=0?0:(t>h.text.length&&(t=h.text.length),ve[t-1]>=0?ve[t-1]+1:me[t]),Ve=[],ne=[],xe=null,te=[],Ce="",Ue=-1,Ct=t=>{xe?xe.appendChild(t):Ve.push(t)},$t=t=>{if(!Ce)return;let a=s.createTextNode(Ce);Ct(a),ne.push({node:a,ms:Ue,me:t,local:[],u:te.length?te[te.length-1].u:null}),Ce=""},on=new Set,Pt=new Map,cn=new Set,De=t=>{let a=s.createElement(t.tag);if(t.block&&Rn.add(a),!Pt.has(t)){Pt.set(t,a),K(t.base,t.local,t.remote,a),l.set(a,{base:t.base,local:t.local,remote:t.remote});let d=(q,Q)=>N&&t[Q]&&q.reverse.get(t[Q])?Q:null,w=!t.base&&(d(n,"local")||d(r,"remote"));if(w){let q=w==="local"?n.reverse.get(t.local):r.reverse.get(t.remote),Q=l.get(a);Q.local=Q.local||n.map.get(q)||null,Q.remote=Q.remote||r.map.get(q)||null,u.push({kind:"move",el:a,source:w})}else t.base||u.push({kind:"insert",el:a,source:t.local&&t.remote?"both":t.local?"local":"remote"});let E=l.get(a);E.local&&(cn.has(E.local)?E.local=null:cn.add(E.local))}else{let d=Pt.get(t);for(let w of d.attributes)w.name!=="id"&&w.name!=="data-id"&&M(a,w,w.value);l.set(a,{base:null,local:null,remote:null})}Ct(a),te.push({u:t,el:a}),xe=a},Ke=new Set,G=new Map;for(let t of h.pins){let a=Le(t.i);G.has(a)||G.set(a,[]),G.get(a).push(t)}let ae=t=>{let a=G.get(t);if(a){$t(t);for(let m of a){let d=m.el.namespaceURI&&m.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?s.createElementNS(m.el.namespaceURI,m.el.tagName):s.createElement(m.el.tagName);l.set(d,{base:null,local:m.el,remote:null,pinned:!0}),Ke.add(d),Ct(d)}}},ye=p.atoms.length||h.atoms.length||x.atoms.length,He=t=>{if(!ye)return null;let a=ke[t]>=0?p.atomAt.get(ke[t]):null,m=Pe[t]>=0?h.atomAt.get(Pe[t]):null,d=Be[t]>=0?x.atomAt.get(Be[t]):null;return a||m||d?{ab:a,al:m,ar:d}:null},Ie=(t,a,m,d)=>{if(!t||!N)return null;let w=R.get(a.reverse.get(t.el))||null;return!w||w===d||(d?w.el.isEqualNode(d.el):m.bTo[w.i]>=0)?null:w},$e=(t,a)=>{if(!t||!N||!e.moveIn)return null;let m=a.reverse.get(t.el);return m&&!R.has(m)?m:null},nt=(t,a)=>{let m=new Map;for(let d of t.atoms)m.set(a(d),(m.get(a(d))||0)+1);return m},Rt=nt(p,_),Ut=nt(h,C),Ft=nt(x,fe),vt=t=>{let a=_(t);return Rt.get(a)===1&&(Ut.get(a)||0)<=1&&(Ft.get(a)||0)<=1},Kt=new Map,mt=new Set,bt=new Set,zt=new Set;for(let t=0;t<pe;t++){let a=He(t);if(!a)continue;let{ab:m,al:d,ar:w}=a,E=Ie(w,r,dt,m),q=Ie(d,n,Fe,m),Q=m,we=null;if(E?(Q=E,we="remote"):q&&(Q=q,we="local"),Q){mt.has(Q)?Kt.set(t,{dup:Q.el}):(mt.add(Q),Kt.set(t,{bk:Q,from:we,al:d,ar:w}));continue}let Y=$e(w,r),ce=$e(d,n),_e=Y||ce;if(_e){bt.has(_e)?Kt.set(t,{dup:_e}):(bt.add(_e),Kt.set(t,{moveIn:_e,side:Y?"remote":"local",sideEl:Y?w.el:d.el}));continue}let Ee=(kt,ut)=>kt&&N&&R.get(ut.reverse.get(kt.el))||null,je=Ee(w,r)||Ee(d,n);if(je&&(zt.add(je),Tt[t].conflict&&vt(je))){if(mt.has(je)){Kt.set(t,{dup:je.el});continue}mt.add(je)}Kt.set(t,{al:d,ar:w})}let Xt=new Map,Fn=(t,a)=>{if(t[a]>=0)return t[a];for(let m=a-1;m>=0;m--)if(t[m]>=0)return t[m]+1;return 0};if(N)for(let t of p.atoms){if(mt.has(t)||zt.has(t))continue;let a=n.map.get(t.el)||null,m=r.map.get(t.el)||null,d=a&&at.get(a),w=m&&y.get(m);if(a&&!d||m&&!w)continue;let E=!(d&&w)&&rt.has(t);if(!E&&!(d&&w&&vt(t)))continue;let q=o==="local"?[[d,ve],[w,Lt]]:[[w,Lt],[d,ve]],[Q,we]=q.find(([ce])=>ce),Y=Fn(we,Q.i);Xt.has(Y)||Xt.set(Y,[]),Xt.get(Y).push({a:t,lt:a,rt:m,edited:E}),mt.add(t)}if(N&&e.moveIn){let t=[[h,n,ve,"local"],[x,r,Lt,"remote"]];o!=="local"&&t.reverse();for(let[a,m,d,w]of t)for(let E of a.atoms){let q=$e(E,m);if(!q||bt.has(q))continue;bt.add(q);let Q=Fn(d,E.i);Xt.has(Q)||Xt.set(Q,[]),Xt.get(Q).push({move:q,side:w,sideEl:E.el})}}let En=t=>{let a=Xt.get(t);if(a){if($t(t),a.some(m=>Oe(m.move?m.sideEl:m.a.el)))for(;te.length;)te.pop(),xe=te.length?te[te.length-1].el:null;for(let{a:m,lt:d,rt:w,edited:E,move:q,side:Q,sideEl:we}of a){if(q){let ce=e.moveIn(q,Q,we);ce&&Ct(ce);continue}on.add(m);let Y=ie(m.el,d,w);E&&(f.push({kind:"structure",el:Y,detail:"edit-beats-delete",base:m.el}),u.push({kind:"insert",el:Y,source:d?"local":"remote"})),Ct(Y)}}},Rn=new Set;for(let t=0;t<pe;t++){let a=He(t),d=!!a&&Oe((a.ab||a.al||a.ar).el)?[]:Gt[t]?[Gt[t],...Ne(t)]:Ne(t),w=0;for(;w<te.length&&w<d.length&&te[w].u===d[w];)w++;if(w<te.length)for($t(t);te.length>w;)te.pop(),xe=te.length?te[te.length-1].el:null;if(ae(t),En(t),d.length>te.length)for($t(t);te.length<d.length;)De(d[te.length]);if(de[t]===it){if(mn.has(t))continue;$t(t);let E=te.length;for(;E>0&&!te[E-1].u.block;)E--;if(E>0)for(;te.length>=E;)te.pop(),xe=te.length?te[te.length-1].el:null;continue}if(a){$t(t);let E=Kt.get(t),q;if(E.dup){f.push({kind:"structure",el:null,detail:"both-moved",base:E.dup});continue}if(E.moveIn){if(q=e.moveIn(E.moveIn,E.side,E.sideEl),!q)continue}else if(E.bk){let Q=E.bk;if(on.add(Q),Q===a.ab)q=ie(Q.el,E.al.el,E.ar.el);else{let we=n.map.get(Q.el)||null,Y=r.map.get(Q.el)||null;q=ie(Q.el,we,Y),(!we||!Y)&&f.push({kind:"structure",el:null,detail:"move-beats-delete",base:Q.el}),u.push({kind:"move",el:q,source:E.from})}}else E.al?(q=ge(E.al.el,"local"),E.ar&&(l.get(q).remote=E.ar.el),u.push({kind:"insert",el:q,source:E.ar?"both":"local"})):(q=ge(E.ar.el,"remote"),u.push({kind:"insert",el:q,source:"remote"}));Ct(q);continue}Ce||(Ue=t),Ce+=de[t]}if($t(pe),(G.has(pe)||Xt.has(pe))&&(te.length=0,xe=null,ae(pe),En(pe)),pe===0&&(h.placeholder||x.placeholder||p.placeholder)){let t=s.createElement("br");l.set(t,{base:p.placeholder,local:h.placeholder,remote:x.placeholder}),Ve.push(t)}let le=0,qe=t=>{for(;le>0&&ne[le-1].me>=t;)le--;for(;le<ne.length&&ne[le].me<t;)le++;let a=ne[le];if(!a)return ne[ne.length-1]||null;let m=ne[le+1];return a.me===t&&m&&m.ms===t?m:a},ft=new Map,et={},Je=(t,a,m)=>{let d=qe(t)||(m?et:null);if(!d)return;let w=ft.get(d)||{l:!1,r:!1};a!=="remote"&&(w.l=!0),a!=="local"&&(w.r=!0),ft.set(d,w)},Qt=t=>{if(t.conflict)return!0;let a=t.src==="local"?h.text:t.src==="remote"?x.text:"";for(let m=t.from;m<t.to;m++)if(a[m]!==xn&&a[m]!==it)return!0;return!1};for(let t of Nt)t.src!=="base"&&Je(t.ms,t.conflict?"both":t.src,Qt(t));for(let[t,a]of be)Ye[t]>=0&&Je(Ye[t],a);for(let t of ne.length?ne:[et]){let a=ft.get(t);a&&u.push({kind:"text",node:t.node||null,source:a.l&&a.r?"both":a.l?"local":"remote"})}for(let t of ht){if(Pt.has(t))continue;let a=!t.local&&!(N&&n.map.get(t.base)),m=!t.remote&&!(N&&r.map.get(t.base));!a&&!m||u.push({kind:"remove",source:a&&m?"both":a?"local":"remote",base:t.base})}let Yt=(t,a,m)=>{if(a<=t)return!1;for(let d=t;d<a;d++)if(m[d]>=0)return!1;return!0};for(let t of ht)for(let a of["local","remote"]){let m=t[a+"Mark"],d=t.baseMark;if(!m)continue;let w=a==="local"?Fe:dt;if(!Yt(d.from,d.to,w.bTo)||!Yt(m.from,m.to,w.toB))continue;let E=(a==="local"?St:g).find(q=>q.ss<=m.from&&m.from<q.se);E&&(E.be<=d.from||E.bs>=d.to)&&u.push({kind:"move",el:Pt.get(t)||null,source:a})}let ln=t=>{let a=st.get(t.node.parentNode);return a?b(a):null};for(let t of h.nodes){let a=-1;for(let d=t.s;d<t.e;d++)if(ve[d]>=0){a=ve[d];break}let m;if(a>=0)m=qe(a);else{let d=Le(t.s),w=ln(t);m=ne.find(E=>E.u===w&&E.me>=d)||ne.filter(E=>E.u===w).pop()}m&&m.local.push(t)}let qt=new Map,Dt=ne[ne.length-1]||null,Vt=0;for(let t of h.nodes){let a=null;for(let m=t.s;m<=t.e;m++){let d=Le(m);for(;Vt>0&&ne[Vt-1].me>=d;)Vt--;for(;Vt<ne.length&&ne[Vt].me<d;)Vt++;let w=q=>q&&d>=q.ms&&d<=q.me&&(d<q.me||m===t.e||q===a),E=w(ne[Vt])?ne[Vt]:w(ne[Vt+1])?ne[Vt+1]:ne[Vt]||Dt;if(!E)break;if(a===E){let q=qt.get(E);q[q.length-1].to=m-t.s;continue}a=E,qt.has(E)||qt.set(E,[]),qt.get(E).push({node:t.node,from:m-t.s,to:m-t.s,flatStart:t.s})}}for(let t of ne){let a=t.local,m=!1;for(let q of a)for(let Q=q.s;Q<q.e&&!m;Q++)(ve[Q]<t.ms||ve[Q]>=t.me)&&(m=!0);l.set(t.node,{base:null,local:a.map(q=>q.node),remote:null,caret:qt.get(t)||[],partial:m});let d=t.ms,w=t.me-t.ms,E=q=>{let Q=0,we=-1;for(let Y of a){let ce=Y.e-Y.s;if(q<=Q+ce){we=Y.s+(q-Q);break}Q+=ce}return we<0&&(we=a.length?a[a.length-1].e:0),Math.max(0,Math.min(Le(we)-d,w))};E.flat=q=>Math.max(0,Math.min(Le(q)-d,w)),c.set(t.node,E)}function us(){if(!h.text.includes(it))return[{flatLocal:h.text,localNodes:h.nodes,textNodes:ne,lToM:ve,mapLocal:Le}];let t=[],a=0,m=0;for(let d=0;d<=h.text.length;d++){if(d<h.text.length&&h.text[d]!==it)continue;let w=a,E=d;if(E>w){let q=[];for(;m<h.nodes.length&&h.nodes[m].e<=w;)m++;for(let Q=m;Q<h.nodes.length&&h.nodes[Q].s<E;Q++){let we=h.nodes[Q],Y=Math.max(we.s,w),ce=Math.min(we.e,E);Y<ce&&q.push({node:we.node,s:Y-w,e:ce-w})}t.push({flatLocal:h.text.slice(w,E),localNodes:q,textNodes:ne,lToM:ve.subarray?ve.subarray(w,E+1):ve.slice(w,E+1),mapLocal:Q=>Le(w+Math.max(0,Math.min(Q,E-w)))})}a=d+1}return t}let ds={...e,blocks:Rn,ignored:t=>Ke.has(t)||(e.ignored?e.ignored(t):!1)},No=e.ignoreAttribute||(()=>!1),hs=Ho(Hn(Ve,ds),No)!==Ho(x,No);return{nodes:Ve,text:de,textNodes:ne,localDiverged:hs,mapLocal:Le,conflicts:f.slice(v),granularity:ot?"line":"word",segments:us(),localHunks:St,remoteHunks:g,lToM:ve}}var $s="http://www.w3.org/1999/xhtml";function Ys(e){let s=5381;for(let o=0;o<e.length;o++)s=(s<<5)+s^e.charCodeAt(o);return(s>>>0).toString(36)}function _t(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===$s}function Js(e){let s=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return s==="application/json"||s.endsWith("+json")}function Jn(e,s){let o=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(o){let r=o;try{let l=new URL(o,s);r=l.origin+l.pathname+l.search}catch{}return"script|src|"+n+"|"+r}return"script|inline|"+n+"|"+Ys(e.textContent.trim())}var Xs={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function Nn(e,s=[],o=!1){if(!_t(e)||e.hasAttribute("src"))return null;let n=[Xs,...s];for(let r=0;r<n.length;r++){let l=n[r];if(!l.match(e))continue;if(!Js(e))return o&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let c=l.identity(e);return c==null||c===""?null:{key:r+":"+c,raw:c,recognizer:l}}return null}function Vo(e,s,o){let n=new Set,r=l=>{_t(l)&&!s(l)&&n.add(Jn(l,o))};r(e);for(let l of e.querySelectorAll("script"))r(l);return n}function Bn(e,s){let o=s.createElement("div");o.innerHTML="<script><\/script>";let n=o.firstChild;for(let r of e.attributes)n.setAttribute(r.name,r.value);return n.textContent=e.textContent,n}function Wo(e,s,o){let n=[],r=[],l=Array.from(e.querySelectorAll("script"));_t(e)&&l.unshift(e);for(let c of l){if(!_t(c)||o.ignored(c)||o.skip.has(c)||s.has(Jn(c,o.baseURI)))continue;let f=c.ownerDocument.createElement("script");for(let u of c.attributes)f.setAttribute(u.name,u.value);f.textContent=c.textContent,o.beforeNodeAdded(f)!==!1&&(f.hasAttribute("src")&&r.push(new Promise(u=>{f.addEventListener("load",()=>u()),f.addEventListener("error",()=>u())})),c.replaceWith(f),o.afterNodeAdded(f),n.push(f))}return{executed:n,loads:r}}function Qs(e){let s=5381;for(let o=0;o<e.length;o++)s=(s<<5)+s^e.charCodeAt(o);return(s>>>0).toString(36)}function Zs(e,s){try{let o=new URL(e,s);return o.origin+o.pathname+o.search}catch{return e}}function Fo(e,s){let o=e.tagName;if(o==="TITLE"||o==="BASE")return o;if(o==="SCRIPT")return Jn(e,s);if(o==="LINK"){let n=e.getAttribute("href");return n?"link|"+(e.getAttribute("rel")||"")+"|"+Zs(n,s):e.outerHTML}if(o==="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 o==="STYLE"?"style|"+Qs(e.textContent):e.outerHTML}function yo(e,s){for(;;){for(;s<e.length&&/\s/.test(e[s]);)s++;if(e[s]==="/"&&e[s+1]==="/"){for(;s<e.length&&e[s]!==`
4
- `;)s++;continue}if(e[s]==="/"&&e[s+1]==="*"){let o=e.indexOf("*/",s+2);if(o===-1)return e.length;s=o+2;continue}return s}}function Ko(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(s,o)=>o.length%2===0?o+'\\"':s)}var er=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,tr=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Xn(e){try{return JSON.parse(e)}catch{return JSON.parse(nr(e))}}function nr(e){let s="",o=0,n=(r,l)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${l}`)};for(;o<e.length&&(o=yo(e,o),!(o>=e.length));){let r=e[o];if("{}[]:".includes(r)){s+=r,o++;continue}if(r===","){let f=yo(e,o+1);if(e[f]==="}"||e[f]==="]"){o++;continue}s+=r,o++;continue}if(r==='"'||r==="'"){let f=o+1;for(;f<e.length&&e[f]!==r;)e[f]==="\\"&&f++,f++;f>=e.length&&n("unterminated string",o);let u=e.slice(o+1,f);r==="'"&&(u=Ko(u)),s+='"'+u+'"',o=f+1;continue}let l=o;for(;l<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[l]);)l++;l===o&&n("unexpected character "+JSON.stringify(r),o);let c=e.slice(o,l);if(c==="true"||c==="false"||c==="null"||er.test(c)){s+=c,o=l;continue}if(tr.test(c)){if(e[yo(e,l)]===":"){s+='"'+c+'"',o=l;continue}n("unquoted value "+JSON.stringify(c),o)}n("invalid token "+JSON.stringify(c),o)}return s}function zo(e){try{return JSON.parse(e)}catch{}let s={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function o(r){let l=[],c=0;for(;c<r.length;){let f=r[c];if(/\s/.test(f)){c++;continue}if("{}".includes(f)){l.push({type:f,value:f}),c++;continue}if(f==="["){let A=!1,T=c+1;for(;T<r.length&&/\s/.test(r[T]);)T++;if(T<r.length&&/[a-zA-Z_]/.test(r[T])&&(A=!0),!A){l.push({type:f,value:f}),c++;continue}}if(f==="]"){l.push({type:f,value:f}),c++;continue}if(f===":"){l.push({type:s.COLON,value:f}),c++;continue}if(f===","){l.push({type:s.COMMA,value:f}),c++;continue}if(f==='"'||f==="'"){let A=f,T=c+1;for(;T<r.length&&r[T]!==A;)r[T]==="\\"&&T++,T++;l.push({type:s.STRING,value:r.substring(c+1,T),quoted:!0,sourceQuote:A}),c=T+1;continue}let u=c,v;for(;u<r.length&&!/[{},]/.test(r[u]);)if(r[u]===":"){let A=[":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"],T=!1;for(let p of A){let h=p.substring(1);if(r.substring(u+1,u+1+h.length)===h){T=!0,u+=h.length;break}}if(!T)break}else if(r[u]==="["){for(u++;u<r.length&&r[u]!=="]";){if(r[u]==='"'||r[u]==="'"){let A=r[u];for(u++;u<r.length&&r[u]!==A;)r[u]==="\\"&&u++,u++}u++}u<r.length&&r[u]==="]"&&u++}else u++;v=r.substring(c,u);let N=s.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(v)?N=s.NUMBER:v==="true"||v==="false"||v==="null"?N=s.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(v)&&(N=s.SELECTOR),l.push({type:N,value:v,quoted:!1}),c=u}return l}function n(r){let l="";for(let c=0;c<r.length;c++){let f=r[c];if("{}".includes(f.type)||"[]".includes(f.type)){l+=f.value;continue}if(f.type===s.COLON){l+=f.value;continue}if(f.type===s.COMMA){let u=r[c+1];if(u&&(u.type==="}"||u.type==="]"))continue;l+=f.value;continue}if(f.type===s.STRING){let u=f.value;f.sourceQuote==="'"&&(u=Ko(u)),l+=`"${u}"`;continue}if(f.type===s.NUMBER||f.type===s.BOOLEAN){l+=f.value;continue}l+=`"${f.value}"`}return l}try{let r=o(e),l=n(r);return JSON.parse(l)}catch(r){throw new Error("Invalid extraction rules syntax: "+r.message)}}var yt=Symbol("hyper-morph-json-merge:missing"),qo=["id","_id","uuid","key","slug","code","name"];function Sn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Dn(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function or(e,s,o){Object.defineProperty(e,s,{value:o,enumerable:!0,writable:!0,configurable:!0})}function fn(e,s){if(e===s)return!0;if(Array.isArray(e)&&Array.isArray(s)){if(e.length!==s.length)return!1;for(let o=0;o<e.length;o++)if(!fn(e[o],s[o]))return!1;return!0}if(Sn(e)&&Sn(s)){let o=Object.keys(e);if(o.length!==Object.keys(s).length)return!1;for(let n of o)if(!Dn(s,n)||!fn(e[n],s[n]))return!1;return!0}return!1}function Go(e,s,o,n){return fn(s,o)?s:fn(s,e)?o:fn(o,e)?s:Sn(s)&&Sn(o)?sr(Sn(e)?e:{},s,o,n):Array.isArray(s)&&Array.isArray(o)?lr(Array.isArray(e)?e:[],s,o,n):o}function $o(e,s,o,n){return s===yt&&o===yt?yt:s===yt?e===yt?o:fn(o,e)?yt:o:o===yt?e===yt?s:yt:Go(e,s,o,n)}function sr(e,s,o,n){let r={},l=new Set([...Object.keys(e),...Object.keys(s),...Object.keys(o)]);for(let c of l){let f=$o(Dn(e,c)?e[c]:yt,Dn(s,c)?s[c]:yt,Dn(o,c)?o[c]:yt,n);f!==yt&&or(r,c,f)}return r}function rr(e){return e===null||typeof e!="object"}function Qn(e){return typeof e+":"+String(e)}function ir(e,s){for(let o of s){let n=new Set;for(let r of o){if(!Dn(r,e))return!1;let l=r[e];if(typeof l!="string"&&typeof l!="number")return!1;let c=Qn(l);if(n.has(c))return!1;n.add(c)}}return!0}function cr(e,s,o,n){let r=[e,s,o],l=!0;for(let c of r)for(let f of c)Sn(f)||(l=!1);if(l){for(let c of n.keyCandidates)if(ir(c,r))return{kind:"keyed",field:c};return null}for(let c of r){let f=new Set;for(let u of c){if(!rr(u))return null;let v=Qn(u);if(f.has(v))return null;f.add(v)}}return{kind:"self"}}function lr(e,s,o,n){let r=cr(e,s,o,n);if(!r)return o;let l=r.kind==="self"?Qn:p=>Qn(p[r.field]),c=p=>{let h=new Map;for(let x of p)h.set(l(x),x);return h},f=c(e),u=c(s),v=c(o),N=new Map,A=new Set([...f.keys(),...u.keys(),...v.keys()]);for(let p of A){let h=$o(f.has(p)?f.get(p):yt,u.has(p)?u.get(p):yt,v.has(p)?v.get(p):yt,n);h!==yt&&N.set(p,h)}let T=[];for(let p of o){let h=l(p);N.has(h)&&T.push(h)}for(let p=0;p<s.length;p++){let h=l(s[p]);if(!N.has(h)||T.includes(h))continue;let x=0;for(let R=p-1;R>=0;R--){let M=T.indexOf(l(s[R]));if(M!==-1){x=M+1;break}}T.splice(x,0,h)}return T.map(p=>N.get(p))}function wo(e,s,o,n={}){let r=n.keyCandidates?[...n.keyCandidates,...qo]:qo;return Go(e===void 0?yt:e,s,o,{keyCandidates:r})}function Zn(e,s,o,n={}){let r=n.parse||Xn,l=[],c=(A,T)=>{if(typeof A!="string")return yt;try{return r(A)}catch(p){return l.push(`${T} side is not valid JSON (${p.message})`),yt}},f=c(s,"local"),u=c(o,"remote");if(f===yt)return{text:o,warnings:l};if(u===yt)return{text:s,warnings:l};let v=c(e,"base"),N=wo(v===yt?void 0:v,f,u,n);return fn(N,u)?{text:o,warnings:l}:fn(N,f)?{text:s,warnings:l}:{text:JSON.stringify(N,null,2),warnings:l}}var Re=e=>!!e&&e.nodeType===1,ar=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),Yo=5e4;function Ao(e,s,o,n){let r=n.ignored,l=Lo({ignored:r,ignoreAttribute:n.ignoreAttribute}),{unitsOf:c,meta:f}=l,u=n.baseURI,v=n.mergeTags!==null,N=g=>L=>{if(v&&L.tagName==="SCRIPT"){let B=Nn(L,n.mergeTags);if(B)return"merge:"+B.key}return L.parentElement&&L.parentElement.tagName==="HEAD"?Fo(L,u):g(L)},A=N(n.identity.base),T=N(n.identity.local),p=N(n.identity.remote),h=n.authored||n.identity,x=g=>g&&g.nodeType===9?g.documentElement:g,R=x(e),M=x(s),D=x(o),K=globalThis.__hyperMorphProfile,ie=K?performance.now():0,ge="[id],[data-id],script,head>*",Me=g=>g===dn?ge:null,Ae=Gn(R,A,r,Me(n.identity.base)),_=n.localIsBase?Xo():ro(R,M,{analyzer:l,baseIndex:Ae,sideIndex:Gn(M,T,r,Me(n.identity.local)),baseId:h.base,sideId:h.local}),C=ro(R,D,{analyzer:l,baseIndex:Ae,sideIndex:Gn(D,p,r,Me(n.identity.remote)),baseId:h.base,sideId:h.remote});Xe(),Qe(_,C),Qe(C,_),K&&(K.alignTotal=(K.alignTotal||0)+(performance.now()-ie),ie=performance.now());let fe=R.ownerDocument.implementation.createHTMLDocument(""),J=new WeakMap,he=new WeakMap,Se=[],ct=[],ot=new Set,lt=[],oe=new Set,We=new Set,Fe=new Set,dt=new WeakMap,ze=n.conflicts||"remote",Ge=g=>Se.push(g),at=g=>Se.push(g),y=g=>ct.push(g),H=Oe(),se=b(R,_.map.get(R),C.map.get(R),!!n.localIsBase,!!n.childrenOnly);se.tagName==="HTML"?fe.replaceChild(se,fe.documentElement):fe.body.appendChild(se),K&&(K.build=(K.build||0)+(performance.now()-ie));let Z=n.childrenOnly?!Ze(pt(se),pt(D)):!wt(se,D);return{doc:fe,root:se,provenance:J,textMappers:he,decisions:Se,conflicts:ct,localDiverged:Z,mergedScripts:ot,segments:lt,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==dn,L:_,R:C};function Oe(){let g=new Map,L=new Set;if(n.localIsBase||!_.insertedByHash)return{partner:g,drop:L};let B=_.insertedByHash(),F=C.insertedByHash();if(!B.size||!F.size)return{partner:g,drop:L};let U={ignored:r,remoteWins:n.remoteWins,inlineCache:dt},W=pe=>{let Ye=0;for(let ve=pe.parentNode;ve;ve=ve.parentNode)Ye++;return Ye},$=[],re=pe=>{let Ye=pe.textContent.trim();return Ye.split(/\s+/).length>=3||Ye.replace(/\s/g,"").length>=12},be=pe=>{let Ye=_.map.get(pe),ve=C.map.get(pe);return Ye&&_.reverse.get(Ye.parentNode)!==pe.parentNode||ve&&C.reverse.get(ve.parentNode)!==pe.parentNode},de=(pe,Ye,ve)=>{for(let xt of ve.parentNode.children){let Ot=xt!==ve&&pe.reverse.get(xt);if(Ot&&be(Ot))return!0}let Lt=pe.reverse.get(ve.parentNode);if(Lt){for(let xt of Lt.children)if(!Ye.map.has(xt)&&!r(xt))return!0}return!1};for(let[pe,Ye]of B){let ve=F.get(pe);if(!ve)continue;let Lt=Ye.length===1&&ve.length===1;for(let xt of Ye)pn(xt,U)||$.push([xt,ve,W(xt),Lt&&(re(xt)||de(_,C,xt)||de(C,_,ve[0]))])}if(!$.length)return{partner:g,drop:L};$.sort((pe,Ye)=>pe[2]-Ye[2]);let ke=new Set,Pe=new Set,Be=pe=>{for(let Ye of pe.querySelectorAll("*"))ke.add(Ye)},Tt=(pe,Ye)=>pe.reverse.get(Ye.parentNode)||null;for(let[pe,Ye,,ve]of $){if(ke.has(pe))continue;let Lt=Tt(_,pe),xt=gt=>!Pe.has(gt)&&!ke.has(gt)&&gt.tagName===pe.tagName,Ot=Ye.find(gt=>xt(gt)&&Lt&&Tt(C,gt)===Lt)||(ve?Ye.find(xt):null);Ot&&(Pe.add(Ot),Be(pe),Be(Ot),!(Lt&&Tt(C,Ot)===Lt)&&(g.set(pe,Ot),g.set(Ot,pe),L.add(ze==="local"?Ot:pe)))}return{partner:g,drop:L}}function rt(g,L,B){if(oe.add(g),H.drop.has(g))return null;oe.add(B);let F=L==="local"?g:B,U=L==="local"?B:g,W;return l.unitHash(F)===l.unitHash(U)?(W=Te(F,"local",!0),J.get(W).remote=U):W=ee(F,U),y({kind:"structure",el:W,detail:"both-moved",base:null,local:F,remote:U}),Ge({kind:"insert",el:W,source:"both"}),W}function Xe(){if(!_.weak||!C.weak||!_.weak.size||!C.weak.size||!_.unpair)return;let g=new Map;for(let B of _.weak){let F=_.map.get(B);Re(B)&&Re(F)&&g.set(l.unitHash(F),B)}let L=!1;for(let B of Array.from(C.weak)){let F=C.map.get(B);if(!Re(B)||!Re(F))continue;let U=g.get(l.unitHash(F));!U||U===B||!_.weak.has(U)||_.map.has(B)&&C.map.has(U)||_.map.get(U).tagName===F.tagName&&(_.unpair(U),C.unpair(B),L=!0)}L&&(_.rematch(),C.rematch())}function Qe(g,L){if(!g.weak||!g.weak.size||!L.insertedByHash)return;let B=L.insertedByHash();if(!B.size)return;let F=!1;for(let U of Array.from(g.weak)){let W=g.map.get(U);if(!W)continue;let $=B.get(l.unitHash(W));$&&$.some(re=>re.tagName===W.tagName)&&(g.unpair(U),F=!0)}F&&g.rematch()}function st(g,L){if(g.map.has(L))return g.map.get(L);let B=[];for(let U=L.parentNode;U&&!g.map.has(U);U=U.parentNode)B.push(U);let F=B.length?B[B.length-1].parentNode:L.parentNode;if(!F||!g.identical.has(F))return null;g.pairIdenticalChildren(F);for(let U=B.length-1;U>=0;U--)g.pairIdenticalChildren(B[U]);return g.map.get(L)||null}function ht(g,L,B){if(We.has(g)||Fe.has(g))return y({kind:"structure",el:null,detail:"both-moved",base:g}),We.has(g)?null:Te(B,L);let F=st(_,g),U=st(C,g);(!F||!U)&&y({kind:"structure",el:null,detail:"move-beats-delete",base:g});let W=b(g,F,U,!1);return(L==="local"?Ge:at)({kind:"move",el:W,source:L}),W}function i(g,L,B,F){return F||!L||L===B?{el:B,asBase:!0,twin:U=>U,baseOf:U=>U,units:c(B),here:()=>!0,parentOfTwin:()=>B}:{el:L,asBase:!1,twin:U=>g.map.get(U),baseOf:U=>g.reverse.get(U),units:c(L),here:U=>Re(U)?U.parentNode===L||L.tagName==="TEMPLATE"&&U.parentNode===L.content:U.parent===L||L.tagName==="TEMPLATE"&&U.parent===L.content}}function k(g,L,B){return!L||B&&B.identical.has(g)?!1:Re(g)?f(g).hash!==f(L).hash:g.value!==L.value}function b(g,L,B,F,U=!1){let W=F||n.remoteWins(g),$=g.namespaceURI&&g.namespaceURI!=="http://www.w3.org/1999/xhtml"?fe.createElementNS(g.namespaceURI,g.tagName):fe.createElement(g.tagName),re={base:g,local:L||null,remote:B||null};if(J.set($,re),oe.add(g),We.add(g),L&&oe.add(L),B&&oe.add(B),n.skipUnchanged&&!U&&(n.localIsBase||_.identical.has(g))&&B&&C.identical.has(g)&&!n.remoteWins(g)){re.unchanged=!0;for(let de of g.attributes)de.namespaceURI?$.setAttributeNS(de.namespaceURI,de.name,de.value):$.setAttribute(de.name,de.value);return $}Fe.add(g),U||O(g,W?g:L,B,$);let be=g.tagName;if(_t(g))I(g,W?g:L,B,$);else if(be==="TEXTAREA")$.textContent=V(g.textContent,(W?g:L)?(W?g:L).textContent:g.textContent,B?B.textContent:g.textContent,$,"text");else{let de=tt(g,L,B,W,$),ke=be==="TEMPLATE"&&$.content?$.content:$;for(let Pe of de)ke.appendChild(Pe)}return Fe.delete(g),$}function V(g,L,B,F,U){if(L===B)return L;if(L===g)return B!==g&&at({kind:U,node:F,source:"remote"}),B;if(B===g)return Ge({kind:U,node:F,source:"local"}),L;let W=ze==="local"?L:B;return y({kind:U,node:F,base:g,local:L,remote:B,resolved:W}),Se.push({kind:U,node:F,source:"both"}),W}function I(g,L,B,F){let U=g.textContent,W=L?L.textContent:U,$=B?B.textContent:U,re=v?Nn(g,n.mergeTags,!0):null;if(re&&W!==$){let be=B&&B.getAttribute("merge-key")||g.getAttribute("merge-key"),{text:de,warnings:ke}=Zn(n.localIsBase?void 0:U,W,$,{parse:re.recognizer.parse,keyCandidates:be?be.split(/[\s,]+/).filter(Boolean):void 0});for(let Pe of ke)console.warn(`[hyper-morph] merge "${re.raw}": ${Pe}`);F.textContent=de,ot.add(F),de!==$?Ge({kind:"text",node:F,source:de===W?"local":"both"}):de!==U&&at({kind:"text",node:F,source:"remote"});return}F.textContent=V(U,W,$,F,"text")}function O(g,L,B,F){let U=new Map;for(let W of[g,L,B])if(W)for(let $ of W.attributes)n.ignoreAttribute(W,$.name)||U.set($.name,$);for(let[W,$]of U){let re=g?g.getAttribute(W):null,be=L?L.getAttribute(W):re,de=B?B.getAttribute(W):re,ke;be===de?ke=be:be===re?(ke=de,at({kind:"attr",el:F,name:W,source:"remote"})):de===re?(ke=be,Ge({kind:"attr",el:F,name:W,source:"local"})):(ke=j(W,re,be,de),ke===void 0&&(ke=ze==="local"?be:de,y({kind:"attr",el:F,name:W,base:re,local:be,remote:de,resolved:ke})),Se.push({kind:"attr",el:F,name:W,source:"both"})),ke!=null&&($.namespaceURI?F.setAttributeNS($.namespaceURI,$.name,ke):F.setAttribute(W,ke))}}function j(g,L,B,F){if(g==="class"){let U=de=>new Set((de||"").split(/\s+/).filter(Boolean)),W=U(L),$=U(B),re=U(F),be=new Set;for(let de of new Set([...W,...$,...re])){let ke=W.has(de),Pe=$.has(de),Be=re.has(de);(Pe===Be?Pe:Pe===ke?Be:Pe)&&be.add(de)}return[...be].join(" ")}if(g==="style"){let U=ke=>{let Pe=new Map;if(!ke)return Pe;let Be=0,Tt=null,pe="",Ye=()=>{let ve=pe.indexOf(":");ve>0&&Pe.set(pe.slice(0,ve).trim(),pe.slice(ve+1).trim()),pe=""};for(let ve of ke){if(Tt){pe+=ve,ve===Tt&&(Tt=null);continue}if(ve==='"'||ve==="'"){Tt=ve,pe+=ve;continue}if(ve==="("?Be++:ve===")"&&Be--,ve===";"&&Be===0){Ye();continue}pe+=ve}return pe.trim()&&Ye(),Pe},W=U(L),$=U(B),re=U(F),be=new Map,de=!1;for(let ke of new Set([...W.keys(),...$.keys(),...re.keys()])){let Pe=W.get(ke)??null,Be=$.get(ke)??null,Tt=re.get(ke)??null,pe;Be===Tt?pe=Be:Be===Pe?pe=Tt:Tt===Pe?pe=Be:(pe=ze==="local"?Be:Tt,de=!0),pe!=null&&be.set(ke,pe)}return de?void 0:[...be].map(([ke,Pe])=>`${ke}: ${Pe}`).join("; ")}}function S(g,L,B,F){let U=g.value,W=F?U:L?L.value:"",$=B?B.value:"";oe.add(g),L&&oe.add(L),B&&oe.add(B);let re=wn(U,W,$,ze),be=re.text===""?null:fe.createTextNode(re.text);be&&(J.set(be,{base:g.nodes,local:L?L.nodes:null,remote:B?B.nodes:null}),he.set(be,re.mapLocalOffset)),W!==U&&$!==U?Se.push({kind:"text",node:be,source:"both"}):W!==U?Ge({kind:"text",node:be,source:"local"}):$!==U&&at({kind:"text",node:be,source:"remote"});for(let de of re.conflicts)y({kind:"text",node:be,base:U.slice(de.bs,de.be),local:de.local,remote:de.remote,resolved:de.resolved});return be}function P(g,L){return An(g,L).every(B=>B.bs===B.be)}function X(g,L){let B=g?g.value:"",F=L?L.value:"",U;if(B===F||!F?U=B:B?P(B,F)?U=F:P(F,B)?U=B:(U=ze==="local"?B:ze==="both"?B+F:F,y({kind:"structure",el:null,detail:"insert-collision",local:B,remote:F,resolved:U})):U=F,g&&oe.add(g),L&&oe.add(L),U==="")return null;let W=fe.createTextNode(U);return J.set(W,{base:null,local:g?g.nodes:null,remote:L?L.nodes:null}),B?Ge({kind:"insert",el:W,source:F&&B===F?"both":"local"}):at({kind:"insert",el:W,source:"remote"}),W}function ee(g,L){let B={ignored:r,remoteWins:n.remoteWins,inlineCache:dt},F=re=>c(re).every(be=>Re(be)?pn(be,B):be.kind==="text"),U=null;if(F(g)&&F(L)){let re=g.textContent,be=L.textContent;re===be||P(be,re)?U=L:P(re,be)&&(U=g)}if(!U){let re=ze==="local",be=Te(re?g:L,re?"local":"remote",!0),de=J.get(be);return re?de.remote=L:de.local=g,y({kind:"structure",el:be,detail:"insert-collision",local:g,remote:L,resolved:re?g:L}),be}let W=g.namespaceURI&&g.namespaceURI!=="http://www.w3.org/1999/xhtml"?fe.createElementNS(g.namespaceURI,g.tagName):fe.createElement(g.tagName);O(null,g,L,W),J.set(W,{base:null,local:g,remote:L}),oe.add(g),oe.add(L);let $=ko({base:Array.from(U.childNodes),local:Array.from(g.childNodes),remote:Array.from(L.childNodes),out:fe,policy:ze,idOf:{local:T,remote:p},ignored:r,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:J,textMappers:he,conflicts:ct,decisions:Se,node:W});lt.push(...$.segments);for(let re of $.nodes)W.appendChild(re);return W}function Te(g,L,B=!1){if(!B&&Re(g)){let $=H.partner.get(g);if($)return rt(g,L,$)}if(!Re(g)){if(g.value==="")return null;let $=g.kind==="comment"?fe.createComment(g.value):fe.createTextNode(g.value);return J.set($,{base:null,local:L==="local"?g.nodes:null,remote:L==="remote"?g.nodes:null}),oe.add(g),$}let F=g.namespaceURI&&g.namespaceURI!=="http://www.w3.org/1999/xhtml"?fe.createElementNS(g.namespaceURI,g.tagName):fe.createElement(g.tagName);for(let $ of g.attributes)$.namespaceURI?F.setAttributeNS($.namespaceURI,$.name,$.value):F.setAttribute($.name,$.value);J.set(F,{base:null,local:L==="local"?g:null,remote:L==="remote"?g:null}),oe.add(g);let U=g.tagName==="TEMPLATE"&&F.content?F.content:F,W=L==="local"?_:C;for(let $ of c(g)){let re=Re($)?W.reverse.get($):null;if(re&&We.has(re)){y({kind:"structure",el:null,detail:"both-moved",base:re});continue}if(re&&!Fe.has(re)){let de=_.map.get(re)||null,ke=C.map.get(re)||null;if(de||ke){let Pe=b(re,de,ke,!1);L==="local"?Ge({kind:"move",el:Pe,source:"local"}):at({kind:"move",el:Pe,source:"remote"}),U.appendChild(Pe);continue}}let be=Te($,L);be&&U.appendChild(be)}return F}function tt(g,L,B,F,U){L&&_.identical.has(g)&&_.pairIdenticalChildren(g),B&&C.identical.has(g)&&C.pairIdenticalChildren(g);let W=i(_,L,g,F),$=i(C,B,g,!1),re=c(g),be=new Set(re),de=new Map;for(let z=0;z<re.length;z++)de.set(re[z],z);let ke=[],Pe=new Set,Be=new Map,Tt=new Set,pe=new Set,Ye=[];Wn();let ve=z=>{let Ne=[];for(let me of z.units){if(pe.has(me))continue;let Le=z.baseOf(me);Le&&be.has(Le)&&Ne.push(de.get(Le))}return Ne},Lt=z=>z.every((Ne,me)=>me===0||Ne>=z[me-1]),xt=!W.asBase&&!Lt(ve(W)),Ot=!$.asBase&&!Lt(ve($));xt&&Ot&&y({kind:"structure",el:null,detail:"both-reordered",base:g});let gt=Ot||!xt?{V:$,A:C,side:"remote",other:W,otherA:_,otherSide:"local"}:{V:W,A:_,side:"local",other:$,otherA:C,otherSide:"remote"};xt?Ge({kind:"move",el:null,source:Ot?"both":"local",base:g}):Ot&&at({kind:"move",el:null,source:"remote",base:g});let Ln=W.asBase?[]:W.units.filter(z=>!W.baseOf(z)&&!pe.has(z)&&!H.partner.has(z)),Cn=$.asBase?[]:$.units.filter(z=>!$.baseOf(z)&&!pe.has(z)&&!H.partner.has(z)),tn=new Map;if(Ln.length&&Cn.length){let z=new Map,Ne=new Map;for(let ne of Cn){if(Re(ne)){let te=p(ne);te&&z.set(te,ne)}let xe=l.unitHash(ne);Ne.has(xe)||Ne.set(xe,[]),Ne.get(xe).push(ne)}let me=(ne,xe)=>{let te=ne.units.indexOf(xe);for(let Ce=te-1;Ce>=0;Ce--){let Ue=ne.baseOf(ne.units[Ce]);if(Ue)return Ue}return"start"},Le=new Map,Ve=new Map;for(let ne of Cn){let xe=me($,ne);Re(ne)?(Ve.has(xe)||Ve.set(xe,[]),Ve.get(xe).push(ne)):ne.kind==="text"&&!Le.has(xe)&&Le.set(xe,ne)}for(let ne of Ln){let xe=null;if(Re(ne)){let te=T(ne);te&&z.has(te)&&!tn.has(z.get(te))&&(xe=z.get(te))}else if(ne.kind==="text"){let te=Le.get(me(W,ne));te&&!tn.has(te)&&(xe=te)}if(!xe){let te=Ne.get(l.unitHash(ne));te&&(xe=te.find(Ce=>!tn.has(Ce)&&Re(Ce)===Re(ne)&&(Re(Ce)?Ce.tagName===ne.tagName:Ce.kind===ne.kind))||null)}if(!xe&&Re(ne)){let te=h.local(ne),Ce=(Ve.get(me(W,ne))||[]).filter(Ue=>{let Ct=h.remote(Ue);return!tn.has(Ue)&&Ue.tagName===ne.tagName&&!(te&&Ct&&te!==Ct)&&l.similar(ne,Ue)});Ce.length===1&&(xe=Ce[0])}xe&&(tn.set(xe,ne),tn.set(ne,xe))}}let Gt=z=>{if(oe.has(z))return Be.get(z)||null;let Ne=W.twin(z),me=$.twin(z),Le=Ne&&!W.asBase&&!W.here(Ne),Ve=me&&!$.asBase&&!$.here(me);if(Le||Ve){if((!Ne||!me)&&y({kind:"structure",el:null,detail:"move-beats-delete",base:z}),!jt(z))return oe.add(z),null;y({kind:"structure",el:null,detail:"both-moved",base:z})}if(!Ne&&!me)return oe.add(z),at({kind:"remove",source:"both",base:z}),null;if(!Ne&&!k(z,me,C))return oe.add(z),Ge({kind:"remove",source:"local",base:z}),null;if(!me&&!k(z,Ne,_))return oe.add(z),at({kind:"remove",source:"remote",base:z}),null;let ne=!Ne||!me,xe=W.asBase?_.map.get(z)||null:Ne,te;return Re(z)?te=b(z,xe,me,W.asBase):z.kind==="comment"?te=At(z,xe,me,W.asBase):te=S(z,xe,me,W.asBase),oe.add(z),te&&(Be.set(z,te),Ne&&Be.set(Ne,te),me&&Be.set(me,te),ne&&(y({kind:"structure",el:te,detail:"edit-beats-delete",base:z}),Ne?Ge({kind:"insert",el:te,source:"local"}):at({kind:"insert",el:te,source:"remote"}))),te},mn=(z,Ne,me,Le)=>{if(oe.has(z))return Be.get(z)||null;let Ve=Ne.baseOf(z);if(Ve&&be.has(Ve))return pe.has(Ve)&&!pe.has(z)?jn(Ve,z,Le):Gt(Ve);if(Ve)return _n(Ve,z,Le);let ne=tn.get(z);if(ne){let te=Le==="local"?z:ne,Ce=Le==="local"?ne:z,Ue;return Re(te)?l.unitHash(te)===l.unitHash(Ce)?(Ue=Te(te,"local"),J.get(Ue).remote=Ce):Ue=ee(te,Ce):Ue=X(te,Ce),oe.add(te),oe.add(Ce),Ue&&(Be.set(te,Ue),Be.set(Ce,Ue),Re(te)&&Ge({kind:"insert",el:Ue,source:"both"})),Ue}let xe=Te(z,Le);return xe&&(Be.set(z,xe),Le==="local"?Ge({kind:"insert",el:xe,source:"local"}):at({kind:"insert",el:xe,source:"remote"})),xe},jn=(z,Ne,me)=>{let Le;return Re(z)?(Le=ht(z,me,Ne),Le&&oe.add(Ne)):(Le=Te(Ne,me),oe.add(Ne),Le&&(me==="local"?Ge:at)({kind:"insert",el:Le,source:me})),Le&&Be.set(Ne,Le),Le},_n=(z,Ne,me)=>{let Ve=(me==="local"?C:_).map.get(z),ne=Ne,xe=Ve?Nt(Ve,me==="local"?B:L,me==="local"?C:_):!1,te=Ve&&!xe&&!St(z,Ve);if(te&&me===gt.otherSide)return y({kind:"structure",el:null,detail:"both-moved",base:z}),null;if(te&&y({kind:"structure",el:null,detail:"both-moved",base:z}),Ve||y({kind:"structure",el:null,detail:"move-beats-delete",base:z}),Fe.has(z)){y({kind:"structure",el:null,detail:"both-moved",base:z});let Ue=Te(ne,me);return Ue&&Be.set(Ne,Ue),Ue}let Ce=Re(z)?b(z,me==="local"?ne:_.map.get(z)||null,me==="remote"?ne:C.map.get(z)||null,!1):null;return Ce&&(Be.set(z,Ce),Be.set(Ne,Ce),Ve&&Be.set(Ve,Ce),me==="local"?Ge({kind:"move",el:Ce,source:"local"}):at({kind:"move",el:Ce,source:"remote"})),Ce};for(let z of gt.V.units){if(pe.has(z)){let me=Be.get(z);Pe.has(me)||(ke.push(me),Pe.add(me));continue}if(oe.has(z)&&!(Be.get(z)&&Pe.has(Be.get(z)))){let me=gt.V.baseOf(z);me&&!be.has(me)&&y({kind:"structure",el:null,detail:"both-moved",base:me});continue}let Ne=mn(z,gt.V,gt.A,gt.side);Ne&&!Pe.has(Ne)&&(ke.push(Ne),Pe.add(Ne),!gt.V.baseOf(z)&&!tn.has(z)&&!pe.has(z)&&Tt.add(Ne))}for(let z of Ye)Pe.has(z.frag)||(ke.splice(Vn(z.at),0,z.frag),Pe.add(z.frag));if(!gt.other.asBase){let z=gt.other,Ne=gt.otherSide,me=gt.otherA,Le=null,Ve=0,ne=null;for(let xe of z.units){let te=Be.get(xe);if(te&&Pe.has(te)){Le=te,ne=null;continue}if(oe.has(xe)){let Ct=z.baseOf(xe);Ct&&!be.has(Ct)&&y({kind:"structure",el:null,detail:"both-moved",base:Ct});continue}let Ce=mn(xe,z,me,Ne);if(!Ce)continue;let Ue;if(ne)Ue=ke.indexOf(ne)+1;else if(Le){if(Ue=ke.indexOf(Le)+1,Ne==="remote")for(;Ue<ke.length&&Tt.has(ke[Ue]);)Ue++}else Ue=Ve++;ke.splice(Ue,0,Ce),Pe.add(Ce),ne=Ce}}for(let z=0;z<re.length;z++){let Ne=re[z];if(oe.has(Ne))continue;let me=Gt(Ne);me&&ke.splice(Vn(z),0,me)}return ke;function Vn(z){for(let Ne=z-1;Ne>=0;Ne--){let me=Be.get(re[Ne]);if(me){let Le=ke.indexOf(me);if(Le>=0)return Le+1}}return 0}function gn(z){let Ne={ignored:r,remoteWins:()=>!1},me=G=>z(G)||Re(G)&&n.remoteWins(G)&&nn.has(G.tagName)&&pn(G,Ne),Le=new Map,Ve=G=>{if(!Re(G)||!ar.has(G.tagName))return!1;let ae=Le.get(G);return ae===void 0&&(ae=!r(G)&&!n.remoteWins(G)&&c(G).every(me),Le.set(G,ae)),ae},ne=G=>!Re(G)&&G.kind==="text",xe=null,te=new Map,Ce=G=>{let ae=te.get(G);if(ae)return ae;let ye=Re(G)?G.textContent:G.value;ae=new Set;let He=ye.toLowerCase();if(!(ye.length>Yo))if(/^[\x00-\x7f]*$/.test(He))for(let Ie of He.split(/[^\p{L}\p{N}]+/u))Ie&&ae.add(Ie);else for(let Ie of uo(He))/^[\s\p{P}]+$/u.test(Ie)||ae.add(Ie);return te.set(G,ae),ae},Ue=G=>(Re(G)?G.textContent:G.value).toLowerCase().replace(/\s+/g," ").trim(),Ct=new Map,$t=G=>{let ae=Ct.get(G);if(ae)return ae;ae=new Set(Ce(G));let ye=Ie=>{if(Ie)for(let $e of Ce(Ie))ae.add($e)},He=be.has(G)?G:!W.asBase&&W.baseOf(G)||!$.asBase&&$.baseOf(G);return He&&(ye(He),ye(_.map.get(He)),ye(C.map.get(He))),Ct.set(G,ae),ae},on=(G,ae)=>{let ye=Ue(ae),He=be.has(G)?G:!W.asBase&&W.baseOf(G)||!$.asBase&&$.baseOf(G),Ie=mt=>ye?mt.split(ye).length-1:0;if(He&&Re(ae)&&!be.has(ae)){let mt=Ie(Ue(He));for(let bt of[_.map.get(He),C.map.get(He)]){if(!bt||bt===ae||bt.ownerDocument!==ae.ownerDocument)continue;let zt=Ue(bt);if(zt.length>ye.length&&Ie(zt)>=mt&&(zt.startsWith(ye)||zt.endsWith(ye)))return!1}}let $e=Ce(ae),nt=$t(G),Rt=0;for(let mt of $e)nt.has(mt)&&Rt++;if($e.size&&Rt*2>=$e.size)return!0;if(!ye||ye.length>Yo)return!1;let Ut=He?[G,He,_.map.get(He),C.map.get(He)]:[G],Ft=(mt,bt)=>mt!==bt&&(mt.startsWith(bt)||mt.endsWith(bt));if(Ut.some(mt=>mt&&Ft(Ue(mt),ye)))return!0;if(!be.has(ae)||!He)return!1;let vt=Ue(G),Kt=Ue(He);return[_.map.get(ae),C.map.get(ae)].some(mt=>{let bt=mt&&Ue(mt);return!!bt&&vt!==bt&&(vt.startsWith(bt)&&!Kt.startsWith(bt)||vt.endsWith(bt)&&!Kt.endsWith(bt))})},Pt=G=>{xe||(xe=new Set),xe.add(G)},cn=G=>{Pt(G);for(let[ae,ye]of[[_,W],[C,$]]){if(ye.asBase)continue;let He=ae.map.get(G);He&&ye.here(He)&&Pt(He)}},De=(G,ae)=>G.asBase||re.every(ye=>!Re(ye)||ae.identical.has(ye)&&G.here(ae.map.get(ye)))&&G.units.every(ye=>!Re(ye)||G.baseOf(ye));if(De(W,_)&&De($,C))return null;let Ke=G=>{if(G.asBase)return!1;let ae=-1;for(let ye of G.units){let He=Re(ye)?G.baseOf(ye):null;if(!He||!be.has(He))continue;let Ie=de.get(He);if(Ie<ae)return!0;ae=Ie}return!1};if(Ke(W)||Ke($))return null;for(let[G,ae]of[[W,_],[$,C]]){if(G.asBase||De(G,ae))continue;let ye=G.units,He=ae===_?h.local:h.remote,Ie=(le,qe)=>{let ft=Re(le)&&h.base(le),et=Re(qe)&&He(qe);return!ft||!et||ft===et},$e=new Map;for(let le=0;le<ye.length;le++)$e.set(ye[le],le);let nt=le=>!!le&&(Re(le)?G.here(le):$e.has(le)),Rt=le=>{let qe=G.twin(le);return nt(qe)?qe:null},Ut=re.filter(le=>!G.twin(le)&&Ve(le)),Ft=ye.filter(le=>!G.baseOf(le)&&Ve(le)),vt=(le,qe)=>qe===re?!!Rt(le):be.has(G.baseOf(le)),Kt=le=>{let qe=new Int32Array(le.length),ft=new Int32Array(le.length),et=-1;for(let Je=0;Je<le.length;Je++)qe[Je]=et,vt(le[Je],le)&&(et=Je);et=le.length;for(let Je=le.length-1;Je>=0;Je--)ft[Je]=et,vt(le[Je],le)&&(et=Je);return{prev:qe,next:ft}},mt=Kt(ye),bt=Kt(re),zt=(le,qe)=>{cn(le),Pt(qe)};for(let le of Ft){let qe=$e.get(le),ft=mt.prev[qe],et=mt.next[qe],Je=ft>=0?G.baseOf(ye[ft]):null,Qt=et<ye.length?G.baseOf(ye[et]):null,Yt=Je?de.get(Je):-1,ln=Qt?de.get(Qt):re.length;for(let qt=Math.max(0,Yt);qt<=Math.min(ln,re.length-1);qt++){let Dt=re[qt];(Ve(Dt)||ne(Dt))&&(!Ie(Dt,le)||!on(Dt,le)||(ne(Dt)?Pt(le):zt(Dt,le)))}}let Xt=(le,qe,ft)=>{for(let et=qe+ft;et>=0&&et<le.length;et+=ft){let Je=le[et];if(Ve(Je))return Je;if(Re(Je)||Je.value.trim())return null}return null},Fn=le=>{let qe=new Set;for(let ft of c(le))if(!Re(ft)&&ft.kind==="text")for(let et of Ce(ft))qe.add(et);return qe},En=(le,qe)=>{let ft=Ce(qe),et=new Set;for(let Je of Fn(le))ft.has(Je)||et.add(Je);return et},Rn=(le,qe)=>{if(!le.size)return!1;let ft=Ce(qe),et=0;for(let Je of le)ft.has(Je)&&et++;return et*2>=le.size};for(let le of re){if(ae.identical.has(le)||!Ve(le))continue;let qe=Rt(le);if(!qe||!Ve(qe))continue;let ft=En(qe,le),et=En(le,qe);for(let Je of[-1,1]){let Qt=Xt(re,de.get(le),Je);Qt&&Rn(ft,Qt)&&(zt(le,qe),cn(Qt));let Yt=Xt(ye,$e.get(qe)??-1,Je);if(Yt&&Rn(et,Yt)){zt(le,qe);let ln=G.baseOf(Yt);ln?zt(ln,Yt):Pt(Yt)}}}for(let le of Ut){let qe=de.get(le),ft=bt.prev[qe],et=bt.next[qe],Je=ft>=0?Rt(re[ft]):null,Qt=et<re.length?Rt(re[et]):null,Yt=Je?$e.get(Je)??-1:-1,ln=Qt?$e.get(Qt)??-1:ye.length;for(let qt=Math.max(0,Yt);qt<=Math.min(ln,ye.length-1);qt++){let Dt=ye[qt];if((Ve(Dt)||ne(Dt))&&!(!Ie(le,Dt)||!on(Dt,le))&&(cn(le),!ne(Dt))){let Vt=G.baseOf(Dt);Vt?zt(Vt,Dt):Pt(Dt)}}}}if(!xe)return null;for(let G of Array.from(xe))if(be.has(G))for(let ae of[_,C]){let ye=ae.map.get(G);ye&&ye.parentNode!==(ae===_?L:B)&&!(ae===_?W:$).asBase&&xe.delete(G)}return xe.size?xe:null}function Wn(){if((W.asBase||_.identical.has(g))&&($.asBase||C.identical.has(g)))return;let z={ignored:r,remoteWins:n.remoteWins,inlineCache:dt},Ne=De=>Re(De)?pn(De,z):De.kind==="text",me=gn(Ne),Le=De=>me&&me.has(De)||Ne(De),Ve=re.map(Le);if(!Ve.includes(!0))return;let ne=De=>{let Ke=De.units,G=new Map;for(let nt=0;nt<Ke.length;nt++)G.set(Ke[nt],nt);let ae=[],ye=-1;for(let nt=0;nt<re.length;nt++){if(Ve[nt])continue;let Rt=De.twin(re[nt]),Ut=Rt?G.get(Rt):void 0;Ut===void 0||Ut<=ye||Le(Rt)||(ae.push([nt,Ut]),ye=Ut)}let He=[],Ie=-1,$e=-1;for(let nt=0;nt<=ae.length;nt++){let[Rt,Ut]=nt<ae.length?ae[nt]:[re.length,Ke.length],Ft={bLo:-1,bHi:-1,sLo:-1,sHi:-1,next:Ut};for(let vt=Ie+1;vt<Rt;vt++)Ve[vt]&&(Ft.bLo<0&&(Ft.bLo=vt),Ft.bHi=vt);for(let vt=$e+1;vt<Ut;vt++)Le(Ke[vt])&&(Ft.sLo<0&&(Ft.sLo=vt),Ft.sHi=vt);He.push(Ft),Ie=Rt,$e=Ut}return{units:Ke,list:He}},xe=ne(W),te=ne($),Ce=[];for(let De of[xe,te])for(let Ke of De.list)Ke.bLo>=0&&Ce.push([Ke.bLo,Ke.bHi]);Ce.sort((De,Ke)=>De[0]-Ke[0]);let Ue=[];for(let[De,Ke]of Ce){let G=Ue[Ue.length-1];G&&De<=G.hi?G.hi=Math.max(G.hi,Ke):Ue.push({lo:De,hi:Ke})}let Ct=(De,Ke)=>{let G=-1,ae=-1;for(let Ie=0;Ie<De.list.length;Ie++){let $e=De.list[Ie];$e.bLo<Ke.lo||$e.bLo>Ke.hi||(G<0&&(G=Ie),ae=Ie)}let ye=1/0,He=-1;for(let Ie=G;Ie>=0&&Ie<=ae;Ie++){let $e=De.list[Ie];$e.sLo>=0&&(ye=Math.min(ye,$e.sLo),He=Math.max(He,$e.sHi)),Ie<ae&&(ye=Math.min(ye,$e.next),He=Math.max(He,$e.next))}return He<0?[]:De.units.slice(ye,He+1)},$t=(De,Ke)=>De.length===Ke.length&&De.every((G,ae)=>l.unitHash(G)===l.unitHash(Ke[ae])),on=De=>!Re(De)&&De.kind==="comment",Pt=De=>{if(!De.length)return[];let Ke=(Ie,$e)=>Re(Ie)?Ie:Ie.nodes[$e?Ie.nodes.length-1:0],G=Ke(De[0]),ae=Ke(De[De.length-1],!0),ye=Ie=>Ie&&Re(Ie)&&r(Ie);for(;ye(G.previousSibling);)G=G.previousSibling;for(;ye(ae.nextSibling);)ae=ae.nextSibling;let He=[];for(let Ie=G;Ie&&(He.push(Ie),Ie!==ae);Ie=Ie.nextSibling);return He},cn=De=>De.some(Ke=>Re(Ke)&&r(Ke));for(let De of Ue){let Ke=re.slice(De.lo,De.hi+1),G=W.asBase?null:Ct(xe,De),ae=$.asBase?null:Ct(te,De);if(Ke.some(on)||G&&G.some(on)||ae&&ae.some(on))continue;let ye=Pt(G||Ke),He=Pt(ae||Ke);if((!G||$t(Ke,G))&&(!ae||$t(Ke,ae))&&!(G&&cn(ye)))continue;let Ie=ko({base:Pt(Ke),local:ye,remote:He,out:fe,policy:ze,blocks:me,L:G?_:Jo(_,g),R:ae?C:Jo(C,g),idOf:{local:T,remote:p},ignored:r,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(nt,Rt,Ut)=>b(nt,Rt,Ut,!1),cloneUnit:Te,mergeAttrs:O,atomKey:l.unitHash,moveIn:ht,provenance:J,textMappers:he,conflicts:ct,decisions:Se,node:U});lt.push(...Ie.segments);let $e=fe.createDocumentFragment();for(let nt of Ie.nodes)$e.appendChild(nt);for(let nt of[...Ke,...G||[],...ae||[]])oe.add(nt),pe.add(nt),Be.set(nt,$e);Ye.push({frag:$e,at:De.lo})}}}function wt(g,L){let B=J.get(g);return B&&B.unchanged?!0:g.tagName!==L.tagName||!ue(g,L)?!1:Ze(pt(g),pt(L))}function pt(g){return g.tagName==="TEMPLATE"&&g.content?g.content:g}function ue(g,L){let B=0;for(let F of g.attributes)if(!n.ignoreAttribute(g,F.name)&&(B++,L.getAttribute(F.name)!==F.value))return!1;for(let F of L.attributes)n.ignoreAttribute(L,F.name)||B--;return B===0}function Ze(g,L){let B=Et(g,U=>{let W=J.get(U);return!!(W&&W.pinned)}),F=Et(L,r);if(B.length!==F.length)return!1;for(let U=0;U<B.length;U++){let W=B[U],$=F[U];if(typeof W=="string"||typeof $=="string"){if(W!==$)return!1}else{if(W.nodeType!==$.nodeType)return!1;if(W.nodeType===1){if(!wt(W,$))return!1}else if(W.nodeValue!==$.nodeValue)return!1}}return!0}function Et(g,L){let B=[],F=null;for(let U=g.firstChild;U;U=U.nextSibling){if(U.nodeType===3){F=F===null?U.nodeValue:F+U.nodeValue;continue}U.nodeType===1&&L(U)||(F!==null&&(F!==""&&B.push(F),F=null),B.push(U))}return F!==null&&F!==""&&B.push(F),B}function At(g,L,B,F){let U=g.value,W=F?U:L?L.value:"",$=B?B.value:"";oe.add(g),L&&oe.add(L),B&&oe.add(B);let re=W===$?W:W===U?$:$===U||ze==="local"?W:$;if(W!==U&&$!==U&&W!==$&&y({kind:"text",node:null,base:U,local:W,remote:$,resolved:re}),!L&&!B)return null;let be=fe.createComment(re);return J.set(be,{base:g.nodes,local:L?L.nodes:null,remote:B?B.nodes:null}),be}function Bt(g,L){let B=L.map.get(g);if(!B)return null;let F=Re(B)?B.parentNode:B.parent,U=Re(g)?g.parentNode:g.parent;return L.map.get(U)===F?null:L.reverse.get(F)||null}function jt(g){let L=new Set([g]),B=g;for(let F=0;F<64;F++){let U=Bt(B,_)||Bt(B,C);if(!U)return!1;if(U===g||Re(g)&&Re(U)&&g.contains(U)||L.has(U))return!0;L.add(U),B=U}return!0}function Nt(g,L,B){if(!L)return!1;let F=Re(g)?g.parentNode:g.parent;return F===L||L.tagName==="TEMPLATE"&&F===L.content}function St(g,L){let B=Re(g)?g.parentNode:g.parent,F=Re(L)?L.parentNode:L.parent;return!!(_.map.get(B)===F?_:C.map.get(B)===F?C:null)}}function Jo(e,s){return e.map.get(s)?Xo():{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 Xo(){let e={get:s=>s,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Qo=new Set(["INPUT","OPTION","TEXTAREA"]);function Zo(e,s,o,n){let r=e.ownerDocument,{provenance:l,textMappers:c}=o,f=n.hooks,u=[],v=[],N=[],A=new Set,T=[],p=[],h=new Set,x=new Map,R=i=>!!i&&(i===e||e.contains(i)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(i)),M=new Map,D=new Map,K=new Map,ie=new Map;(function i(k){let b=l.get(k);if(b){if(k.nodeType===1){let I=b.local?n.toLive(b.local):null;I&&R(I)&&I.nodeType===1&&(M.set(k,I),D.set(I,k))}else if(Array.isArray(b.local)){let I=_(b.local,b.local.map(O=>n.toLive(O)).filter(O=>O&&R(O)&&O.nodeType===k.nodeType));if(I.length&&(M.set(k,I[0]),D.set(I[0],k),K.set(k,I)),Array.isArray(b.caret))for(let O of b.caret){let j=n.toLive(O.node);if(!j||!R(j)||j.nodeType!==3)continue;let S=ie.get(j);Array.isArray(S)||ie.set(j,S=[]),S.push({merged:k,from:O.from,to:O.to,flatStart:O.flatStart})}else{let O=0;for(let j of I)ie.set(j,{merged:k,shift:O}),O+=j.nodeValue.length}}}let V=k.nodeType===1&&k.tagName==="TEMPLATE"&&k.content?k.content.childNodes:k.childNodes;for(let I of V)i(I)})(s);let ge=new Set;for(let i of M.values())ge.add(i);for(let i of K.values())for(let k of i)ge.add(k);for(let i of o.segments||[])C(i);let Me=n.restoreFocus===!1?null:fr(r,ie);n.childrenOnly?Se(fe(e),fe(s)):J(e,s);for(let{node:i,parent:k}of T)A.has(i)||!i.parentNode||i.nodeType===1&&(n.ignored(i)||ct(i))||at(i,k);return ur(r,Me,ie,c,K,x),{applied:u,moved:v,replaced:N,identities:p,mergedScriptsLive:h,liveOf:M};function Ae(i,k){let b=i.slice(k.bs,k.be),V=0;for(;V<b.length&&V<k.text.length&&b[V]===k.text[V];)V++;let I=0;for(;I<b.length-V&&I<k.text.length-V&&b[b.length-1-I]===k.text[k.text.length-1-I];)I++;return{bs:k.bs+V,be:k.be-I,text:k.text.slice(V,k.text.length-I)}}function _(i,k){if(!k.length)return k;let b=new Set;for(let I of i){let O=I.parentNode;if(O)for(let j=O.firstChild;j;j=j.nextSibling)j.nodeType===3&&b.add(n.toLive(j))}let V=[];for(let I of k){V.push(I);for(let O=I.nextSibling;O&&O.nodeType===3&&!b.has(O)&&!V.includes(O);O=O.nextSibling)V.push(O)}return V}function C(i){let k=[];for(let ue of i.localNodes){let Ze=n.toLive(ue.node);if(!Ze||!R(Ze)||Ze.nodeType!==3)return;k.push(Ze)}let b=_(i.localNodes.map(ue=>ue.node),k);if(!b.length)return;let V=b.map(ue=>ue.nodeValue).join(""),{flatLocal:I,lToM:O,mapLocal:j}=i;if(V===I)return;let S=i.textNodes.map(ue=>({node:ue.node,ms:ue.ms,me:ue.me})),P=[],X=0;for(let ue of b)P.push(X),X+=ue.nodeValue.length;let ee=(ue,Ze)=>b.find((Et,At)=>P[At]<=ue&&ue+Ze<=P[At]+Et.nodeValue.length)||null,Te=[],tt=0;for(let ue of An(I,V).map(Ze=>Ae(I,Ze))){let Ze=ue.bs+tt;tt+=ue.text.length-(ue.be-ue.bs);let Et,At;if(ue.be>ue.bs){Et=O[ue.bs];let Bt=Et>=0;for(let jt=ue.bs;Bt&&jt<ue.be;jt++)O[jt]!==Et+(jt-ue.bs)&&(Bt=!1);if(!Bt)continue;At=Et+(ue.be-ue.bs)}else{let Bt=ue.bs>0?O[ue.bs-1]:0,jt=ue.bs<I.length?O[ue.bs]:0;if(Bt<0||jt<0)continue;Et=At=j(ue.bs)}Te.push({ms:Et,me:At,text:ue.text,live:At===Et?ee(Ze,ue.text.length):null})}Te.sort((ue,Ze)=>Ze.ms-ue.ms);let wt=(ue,Ze)=>(K.get(ue.node)||[M.get(ue.node)]).includes(Ze),pt=ue=>!!ue&&ue.nodeType===1&&nn.has(ue.tagName);for(let ue of Te){let Ze=S.find(At=>At.ms<=ue.ms&&ue.me<=At.me&&ue.ms<At.me);if(Ze&&ue.live&&Ze.ms===ue.ms&&!wt(Ze,ue.live)){let At=S.find(Bt=>Bt.me===ue.ms&&wt(Bt,ue.live));At&&(Ze=At)}if(!Ze&&ue.me===ue.ms){let At=S.find(St=>St.me===ue.ms),Bt=S.find(St=>St.ms===ue.ms),jt=At||Bt;if(!jt)continue;let Nt=jt.node;for(;pt(Nt.parentNode)&&(At?Nt.parentNode.lastChild:Nt.parentNode.firstChild)===Nt;)Nt=Nt.parentNode;if(Nt===jt.node)Ze=jt;else{let St=Nt.ownerDocument.createTextNode(ue.text);Nt.parentNode.insertBefore(St,At?Nt.nextSibling:Nt);continue}}if(!Ze)continue;let Et=Ze.node.nodeValue;Ze.node.nodeValue=Et.slice(0,ue.ms-Ze.ms)+ue.text+Et.slice(ue.me-Ze.ms),Ze.me+=ue.text.length-(ue.me-ue.ms)}}function fe(i){return i.nodeType===1&&i.tagName==="TEMPLATE"&&i.content?i.content:i}function J(i,k){A.add(i);let b=l.get(k);if(b&&b.remote&&o.remoteIdOf){let I=o.remoteIdOf(b.remote);I&&p.push([i,I])}if(b&&b.unchanged){o.customIdentity&&b.remote&&We(i,b.remote),b.remote&&oe(i,b.remote);return}if(f.beforeNodeMorphed(i,k)===!1)return;se(i,k);let V=i.tagName;if(_t(i))i.textContent!==k.textContent&&(u.push({kind:"text",node:i,before:i.textContent,after:k.textContent}),i.textContent=k.textContent),o.mergedScripts.has(k)&&h.add(i);else if(V==="TEXTAREA")ht(i,k,b);else{Qe(i,k,b);let I=V==="TEMPLATE"&&i.content?i.content:i,O=V==="TEMPLATE"&&k.content?k.content:k;n.protectFocusedValue==="subtree"&&Oe(i)&&i!==r.body?he(I):Se(I,O)}f.afterNodeMorphed(i,k)}function he(i){for(let k=i.firstChild;k;k=k.nextSibling){let b=D.get(k);b&&M.get(b.parentNode)!==i||(A.add(k),k.nodeType===1&&he(k))}}function Se(i,k){let b=ze(i.firstChild),V=new Set;for(let I of Array.from(k.childNodes)){let O=M.get(I);O&&A.has(O)&&!V.has(O)&&(O=null);let j=l.get(I);if(j&&j.pinned){O&&O.nodeType===1&&((O.parentNode!==i||ze(O.nextSibling)!==b)&&Ge(i,O,b),A.add(O),V.add(O));continue}if(O&&O.nodeType===1){if(O!==b){let X=O.parentNode;if(X===i&&b&&rt(O)){let ee=O.nextSibling;for(let Te=b;Te&&Te!==O;){let tt=Te.nextSibling;Ge(i,Te,ee),Te=tt}}else Ge(i,O,b),X!==i&&(v.push(O),u.push({kind:"move",el:O,from:X,to:i}))}V.add(O),J(O,I),b=ze(O.nextSibling);continue}if(O&&O.nodeType!==1){let X=K.get(I)||[O];O!==b&&Ge(i,O,b);let ee=I.nodeValue;if(I.nodeType===3){let Te=ot(I),tt=X.map(wt=>wt.nodeValue).join("");Te!=null&&tt!==Te&&(ee=wn(Te,tt,I.nodeValue).text)}f.beforeNodeMorphed(O,I)!==!1&&(O.nodeValue!==ee&&(u.push({kind:"text",node:O,before:O.nodeValue,after:ee}),O.nodeValue=ee),f.afterNodeMorphed(O,I)),A.add(O),V.add(O),x.set(I,O),b=ze(O.nextSibling);continue}if(I.nodeType===3&&b&&b.nodeType===3&&!A.has(b)&&!ie.has(b)){b.nodeValue!==I.nodeValue&&(u.push({kind:"text",node:b,before:b.nodeValue,after:I.nodeValue}),b.nodeValue=I.nodeValue),A.add(b),x.set(I,b),b=ze(b.nextSibling);continue}let S=l.get(I),P=y(S&&S.unchanged&&S.remote?S.remote:I);f.beforeNodeAdded(P)!==!1&&(i.insertBefore(P,b),A.add(P),P.nodeType===3&&x.set(I,P),P.nodeType===1&&(N.push(P),dt(P,I),_t(P)||H(P,I),n.formState==="property"&&Xe(S)&&oe(P,S.remote)),b=ze(P.nextSibling),u.push({kind:"insert",node:P,parent:i}),f.afterNodeAdded(P))}for(let I of Array.from(i.childNodes))A.has(I)||V.has(I)||I.nodeType===1&&(n.ignored(I)||ct(I))||(ge.has(I)?T.push({node:I,parent:i}):at(I,i))}function ct(i){return n.preserve&&i.parentNode&&i.parentNode.nodeType===1&&i.parentNode.tagName==="HEAD"&&n.preserve(i)===!0}function ot(i){let k=l.get(i);return!k||!Array.isArray(k.local)?null:k.local.map(b=>b.nodeValue).join("")}function lt(i){return l.get(i)}function oe(i,k){if(!Qo.has(i.tagName)&&!i.querySelector("input,option,textarea"))return;let b=(V,I)=>{if(V.tagName!==I.tagName)return;V.tagName==="TEXTAREA"?ht(V,I,{remote:I}):Qo.has(V.tagName)&&Qe(V,I,{remote:I});let O=Fe(V),j=Fe(I);if(O.length===j.length)for(let S=0;S<O.length;S++)b(O[S],j[S])};b(i,k)}function We(i,k){let b=Fe(i),V=Fe(k);if(b.length===V.length)for(let I=0;I<b.length;I++){let O=o.remoteIdOf(V[I]);O&&p.push([b[I],O]),We(b[I],V[I])}}function Fe(i){let k=i.tagName==="TEMPLATE"&&i.content?i.content:i;return Array.from(k.children).filter(b=>!n.ignored(b))}function dt(i,k){if(!o.remoteIdOf)return;let b=(V,I)=>{let O=l.get(I);if(O&&O.remote&&I.nodeType===1){let P=o.remoteIdOf(O.remote);P&&p.push([V,P])}let j=V.childNodes,S=I.childNodes;for(let P=0;P<j.length&&P<S.length;P++)b(j[P],S[P])};b(i,k)}function ze(i){for(;i&&i.nodeType===1&&n.ignored(i);)i=i.nextSibling;return i}function Ge(i,k,b){if(typeof i.moveBefore=="function"&&k.ownerDocument===i.ownerDocument)try{i.moveBefore(k,b);return}catch{}i.insertBefore(k,b)}function at(i,k){f.beforeNodeRemoved(i)!==!1&&(i.parentNode.removeChild(i),u.push({kind:"remove",node:i,parent:k}),f.afterNodeRemoved(i))}function y(i){if(_t(i))return Bn(i,r);let k=r.importNode(i,!0);if(k.nodeType===1)for(let b of Array.from(k.querySelectorAll("script")))_t(b)&&b.replaceWith(Bn(b,r));return k}function H(i,k){let b=i.tagName==="TEMPLATE"&&i.content?i.content:i,V=k.tagName==="TEMPLATE"&&k.content?k.content:k,I=Array.from(b.childNodes),O=Array.from(V.childNodes);for(let j=0;j<O.length&&j<I.length;j++){let S=O[j],P=I[j],X=M.get(S);X&&A.has(X)&&(X=null);let ee=l.get(S);if(ee&&ee.pinned){if(X&&X.nodeType===1){let Te=X.parentNode;Ge(b,X,P),Te!==b&&(v.push(X),u.push({kind:"move",el:X,from:Te,to:b})),A.add(X)}P.remove();continue}if(X){let Te=X.parentNode;Ge(b,X,P),P.remove(),X.nodeType===1?(Te!==b&&(v.push(X),u.push({kind:"move",el:X,from:Te,to:b})),J(X,S)):(A.add(X),x.set(S,X),X.nodeValue!==S.nodeValue&&(u.push({kind:"text",node:X,before:X.nodeValue,after:S.nodeValue}),X.nodeValue=S.nodeValue));continue}A.add(P),P.nodeType===3&&x.set(S,P),S.nodeType===1&&!_t(S)&&H(P,S)}}function se(i,k){for(let b of Array.from(k.attributes)){if(Z(i,b.name)||n.ignoreAttribute(i,b.name))continue;let V=b.namespaceURI?i.getAttributeNS(b.namespaceURI,b.localName):i.getAttribute(b.name);V!==b.value&&f.beforeAttributeUpdated(b.name,i,"update")!==!1&&(b.namespaceURI?i.setAttributeNS(b.namespaceURI,b.name,b.value):i.setAttribute(b.name,b.value),u.push({kind:"attr",el:i,name:b.name,before:V,after:b.value}))}for(let b of Array.from(i.attributes)){if(Z(i,b.name)||n.ignoreAttribute(i,b.name)||(b.namespaceURI?k.hasAttributeNS(b.namespaceURI,b.localName):k.hasAttribute(b.name))||f.beforeAttributeUpdated(b.name,i,"remove")===!1)continue;let I=b.value;b.namespaceURI?i.removeAttributeNS(b.namespaceURI,b.localName):i.removeAttribute(b.name),u.push({kind:"attr",el:i,name:b.name,before:I,after:null})}}function Z(i,k){let b=i.tagName;return b==="INPUT"?k==="value"||k==="checked"||k==="disabled":b==="OPTION"?k==="selected":!1}function Oe(i){return i===r.activeElement}function rt(i){let k=r.activeElement;return!!k&&k!==r.body&&i.contains(k)}function Xe(i){let k=i&&i.remote;return k&&k.nodeType===1?k:null}function Qe(i,k,b){let V=i.tagName,I=Xe(b),O=n.formState==="property"&&I?I:k;if(V==="INPUT"){let j=n.protectFocusedValue&&Oe(i),S=(i.getAttribute("type")||"").toLowerCase(),P=S!=="file"&&S!=="checkbox"&&S!=="radio",X=I&&I.hasAttribute("value")&&I.value!==I.getAttribute("value")?I.value:null;if(P&&!j)if(n.formState==="property"){let ee=k.getAttribute("value"),Te=i.getAttribute("value");(Te!==ee||i.value!==O.value)&&f.beforeAttributeUpdated("value",i,ee==null?"remove":"update")!==!1&&(Te!==ee&&(ee==null?i.removeAttribute("value"):i.setAttribute("value",ee),u.push({kind:"attr",el:i,name:"value",before:Te,after:ee})),i.value!==O.value&&(i.value=O.value))}else if(k.hasAttribute("value")||X!=null){let ee=X??k.getAttribute("value");i.getAttribute("value")!==ee&&f.beforeAttributeUpdated("value",i,"update")!==!1?(i.setAttribute("value",ee),i.value!==ee&&(i.value=ee),u.push({kind:"attr",el:i,name:"value",before:null,after:ee})):i.value!==ee&&i.getAttribute("value")===ee&&(i.value=ee)}else(i.hasAttribute("value")||i.value!=="")&&f.beforeAttributeUpdated("value",i,"remove")!==!1&&(i.removeAttribute("value"),i.value="",u.push({kind:"attr",el:i,name:"value",before:"",after:null}));if(!P&&S!=="file"){let ee=k.getAttribute("value");ee==null?i.hasAttribute("value")&&f.beforeAttributeUpdated("value",i,"remove")!==!1&&i.removeAttribute("value"):i.getAttribute("value")!==ee&&f.beforeAttributeUpdated("value",i,"update")!==!1&&i.setAttribute("value",ee)}j||(st(i,O,"checked"),n.formState==="property"&&i.indeterminate!==O.indeterminate&&(i.indeterminate=O.indeterminate)),st(i,O,"disabled")}else if(V==="OPTION"){let j=i.parentNode&&i.closest("select");n.protectFocusedValue&&j&&Oe(j)||st(i,O,"selected")}}function st(i,k,b){let V=n.formState==="property"?!!k[b]:k.hasAttribute(b);if(n.formState!=="property"){let I=i.hasAttribute(b);if(I!==V){if(f.beforeAttributeUpdated(b,i,V?"update":"remove")===!1)return;V?i.setAttribute(b,""):i.removeAttribute(b),u.push({kind:"attr",el:i,name:b,before:I?"":null,after:V?"":null})}}i[b]!==V&&(i[b]=V)}function ht(i,k,b){if(n.protectFocusedValue&&Oe(i)||f.beforeAttributeUpdated("value",i,"update")===!1)return;let V=Xe(b),I=k.textContent,O=V&&V.value!==V.defaultValue?V.value:I;n.formState!=="property"&&i.textContent!==I&&(u.push({kind:"text",node:i,before:i.textContent,after:I}),i.textContent=I),i.value!==O&&(i.value=O)}}function fr(e,s){let o=e.activeElement;if(!o||o===e.body||o===e.documentElement)return null;let n={el:o,id:o.getAttribute&&o.getAttribute("id"),scrollTop:o.scrollTop,scrollLeft:o.scrollLeft};if(o.tagName==="INPUT"||o.tagName==="TEXTAREA"){try{n.selection=[o.selectionStart,o.selectionEnd,o.selectionDirection]}catch{}return n}let r=e.getSelection&&e.getSelection();if(r&&r.rangeCount){let l=r.getRangeAt(0);n.range={sc:l.startContainer,so:l.startOffset,ec:l.endContainer,eo:l.endOffset}}return n}function ur(e,s,o,n,r,l){if(!s)return;let c=s.el;if(!c.isConnected&&s.id&&(c=e.getElementById(s.id)),!c||!c.isConnected)return;if(e.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}try{c.scrollTop=s.scrollTop,c.scrollLeft=s.scrollLeft}catch{}if(s.selection){try{c.setSelectionRange&&!c.selectionEnd&&s.selection[1]!=null&&c.setSelectionRange(s.selection[0],s.selection[1],s.selection[2]||"none")}catch{}return}if(!s.range)return;let f=(N,A)=>{let T=o.get(N);if(Array.isArray(T)){let p=T.find(M=>A>=M.from&&A<M.to)||T.find(M=>A===M.to)||T[T.length-1],h=l.get(p.merged);if(!h||!h.isConnected)return null;let x=n.get(p.merged),R=x&&x.flat?x.flat(p.flatStart+A):A;return[h,Math.max(0,Math.min(R,h.nodeValue.length))]}if(T){let p=(r.get(T.merged)||[N])[0];if(!p.isConnected)return null;let h=n.get(T.merged),x=T.shift+A,R=h?h(x):x;return[p,Math.max(0,Math.min(R,p.nodeValue.length))]}return N.isConnected?[N,Math.min(A,N.nodeType===3?N.nodeValue.length:N.childNodes.length)]:null},u=f(s.range.sc,s.range.so),v=f(s.range.ec,s.range.eo);if(!(!u||!v))try{let N=e.createRange();N.setStart(u[0],u[1]),N.setEnd(v[0],v[1]);let A=e.getSelection();A.removeAllRanges(),A.addRange(N)}catch{}}var es=Symbol("hyper-morph-duplicate-key"),ts=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function Pn(e,s){return s.map(o=>{let n=new Map;for(let r of e){if(r.nodeType!==1)continue;let l=o(r);l==null||l===""||n.set(l,n.has(l)?es:r)}return n})}function ns(e,s,o,n){for(let r=0;r<n.length;r++){let l=n[r](e);if(l==null||l===""||s[r].get(l)!==e)continue;let c=o[r].get(l);if(!(!c||c===es)&&c.tagName===e.tagName)return c}return null}function vn(e,s,o){for(let n=0;n<o.length;n++){let r=o[n](e);if(!(r==null||r==="")&&s[n].get(r)===e)return!0}return!1}function os(e,s,o={}){let n=o.skip||(()=>!1),r=o.ignoreAttr||(()=>!1),l=o.tiers&&o.tiers.length?o.tiers:ts,c=null;function f(){return c||(c=Pn([e,...e.querySelectorAll("*")],l)),c}let u=null;function v(){return u||(u=Pn([s,...s.querySelectorAll("*")],l)),u}function N(C){return!C.parentElement||!C.parentElement.parentElement}function A(C,fe,J){return N(C)||vn(C,f(),l)?(J.push({type:"subtree",el:C,base:fe}),!1):!0}function T(C,fe){let J=[];for(let he of C.attributes)r(C,he.name)||fe.getAttribute(he.name)!==he.value&&J.push(he.name);for(let he of fe.attributes)r(C,he.name)||C.hasAttribute(he.name)||J.push(he.name);return J}function p(C){let fe=[],J=null,he=()=>{J!==null&&(fe.push({nodeType:3,nodeValue:J}),J=null)};for(let Se of C.childNodes){if(Se.nodeType===3){J=(J===null?"":J)+Se.nodeValue;continue}Se.nodeType===1&&n(Se)||(he(),(Se.nodeType===1||Se.nodeType===8)&&fe.push(Se))}return he(),fe}function h(C,fe){if(C.nodeType!==fe.nodeType)return!1;if(C.nodeType!==1)return!0;if(C.tagName!==fe.tagName)return!1;for(let J of l){let he=J(C),Se=J(fe);if(he!=null&&he!==""&&Se!=null&&Se!==""&&he!==Se)return!1}return!0}function x(C){let fe="";for(let J of C)J.nodeType===3&&J.nodeValue.trim()!==""?fe+="\0"+J.nodeValue:J.nodeType===8&&(fe+=""+J.nodeValue);return fe}function R(C,fe,J){let he=p(C),Se=p(fe);if(he.length===Se.length){let H=!0;for(let se=0;se<he.length;se++)if(!h(he[se],Se[se])){H=!1;break}if(H){for(let se=0;se<he.length;se++){let Z=he[se];if(Z.nodeType===1){if(M(Z,Se[se],J))return!0}else if(Z.nodeValue!==Se[se].nodeValue)return!0}return!1}}let ct=he.filter(H=>H.nodeType===1),ot=Se.filter(H=>H.nodeType===1);if(x(he)!==x(Se))return!0;let lt=Pn(ct,l),oe=Pn(ot,l),We=[],Fe=new Set,dt=[];for(let H of ct){let se=ns(H,lt,oe,l);se&&!Fe.has(se)?(We.push([H,se]),Fe.add(se)):dt.push(H)}let ze=[];for(let H of dt)vn(H,lt,l)?J.push({type:"subtree",el:H,base:null}):ze.push(H);let Ge=[];for(let H of ot)Fe.has(H)||(vn(H,oe,l)?J.push({type:"deletion",el:H}):Ge.push(H));if(ze.length!==Ge.length)return!0;for(let H=0;H<ze.length;H++)if(!h(ze[H],Ge[H]))return!0;let at=new Map(We);for(let H=0;H<ze.length;H++)at.set(ze[H],Ge[H]);let y=-1;for(let H of ct){let se=at.get(H);if(!se)continue;let Z=ot.indexOf(se);if(Z<y)return!0;y=Z}for(let H=0;H<ze.length;H++)if(M(ze[H],Ge[H],J))return!0;for(let[H,se]of We)if(M(H,se,J))return!0;return!1}function M(C,fe,J){if(C.tagName!==fe.tagName)return A(C,fe,J);let he=T(C,fe),Se=[];if(R(C,fe,Se))return A(C,fe,J);if(he.length){if(!N(C)&&!vn(fe,v(),l))return!0;J.push({type:"attrs",el:C,names:he,base:fe})}return J.push(...Se),!1}let D=[],K=T(e,s);K.length&&D.push({type:"attrs",el:e,names:K});let ie=(C,fe)=>Array.from(C.children).find(J=>J.tagName===fe)||null,ge=ie(e,"HEAD"),Me=ie(s,"HEAD");if(ge&&Me){let C=[];M(ge,Me,C),C.length&&D.push({type:"head",el:ge})}else(ge||Me)&&ge&&D.push({type:"head",el:ge});let Ae=ie(e,"BODY"),_=ie(s,"BODY");return Ae&&_?M(Ae,_,D):Ae&&D.push({type:"subtree",el:Ae,base:null}),{entries:D}}function ss(e,s,o={}){let n=o.tiers&&o.tiers.length?o.tiers:ts,r=e.documentElement,l=[],c=0,f=M=>({ok:!1,placed:l,held:M,skippedAttrs:c});if(!r)return f(null);function u(M){let D=[M,...M.querySelectorAll("*")];return Pn(D,n)}let v=u(r),N=new Map,A=M=>{let D=M.getRootNode(),K=N.get(D);if(!K){let ie=D.nodeType===9?D.documentElement:D;K=u(ie),N.set(D,K)}return K};function T(M){if(!M.parentElement&&M.tagName==="HTML")return r;if(M.parentElement&&!M.parentElement.parentElement&&M.parentElement.tagName==="HTML"){if(M.tagName==="BODY")return e.body||null;if(M.tagName==="HEAD")return e.head||null}return null}function p(M){let D=T(M);return D||ns(M,A(M),v,n)}function h(M){if(!M)return null;let D=p(M);return D&&D.isConnected?D:null}function x(M){for(let D=0;D<n.length;D++){let K=n[D](M);K!=null&&K!==""&&v[D].set(K,M)}}for(let M of s){if(M.type!=="deletion")continue;let D=p(M.el);D&&D!==r&&D.remove()}let R=s.filter(M=>M.type!=="deletion").sort((M,D)=>M.el===D.el?0:M.el.compareDocumentPosition(D.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let M of R){if(M.type==="head"){let _=e.importNode(M.el,!0);e.head?e.head.replaceWith(_):r.insertBefore(_,r.firstChild),l.push({entry:M,imported:_});continue}if(M.type==="attrs"){let _=h(M.el)||h(M.base);if(!_){c++;continue}for(let C of M.names)M.el.hasAttribute(C)?_.setAttribute(C,M.el.getAttribute(C)):_.removeAttribute(C);continue}let D=M.el;if(T(D))return f(M);let K=h(D)||h(M.base);if(K){let _=e.importNode(D,!0);K.replaceWith(_),x(_),l.push({entry:M,imported:_});continue}if(M.base!=null&&!vn(M.base,A(M.base),n)||!vn(D,A(D),n))return f(M);let ie=D.parentElement;if(!ie)return f(M);let ge=h(ie);if(!ge)return f(M);let Me=null;for(let _=D.previousElementSibling;_;_=_.previousElementSibling){let C=h(_);if(C&&C.parentNode===ge){Me=C;break}}let Ae=e.importNode(D,!0);if(Me)ge.insertBefore(Ae,Me.nextSibling);else{let _=Array.prototype.indexOf.call(ie.children,D);ge.insertBefore(Ae,ge.children[_]||null)}x(Ae),l.push({entry:M,imported:Ae})}return{ok:!0,placed:l,held:null,skippedAttrs:c}}var dr='[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"]',hr='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',pr='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function mr(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let s=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(s)}function gr(e,s,o,n){if(s==null)return;if(typeof s=="string")return s;let r=s;if(r.nodeType===9){let l=e.getAttribute("id");r=l&&r.getElementById(l)||(e.tagName==="BODY"?r.body:e.tagName==="HTML"?r.documentElement:r.body&&r.body.firstElementChild)}if((!r||r.nodeType!==1||r.tagName!==e.tagName)&&(r=br(e,s,n)),!!r)return o?Array.from(r.childNodes):r}function br(e,s,o){let n=s.nodeType===9?s.documentElement:s;if(!n||n.nodeType!==1)return null;let r=new Map,l=[n,...n.querySelectorAll("script")];for(let u of l){let v=Nn(u,o);v&&!r.has(v.key)&&r.set(v.key,u.textContent)}if(!r.size)return null;let c=e.cloneNode(!0),f=!1;for(let u of[c,...c.querySelectorAll("script")]){let v=Nn(u,o);v&&r.has(v.key)&&(u.textContent=r.get(v.key),f=!0)}return f?c:null}function rs(e,s){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let o=s.implementation.createHTMLDocument(""),n=e.nodeType===1&&e.tagName==="HTML"?e:null;if(n)return o.replaceChild(o.adoptNode(n),o.documentElement),o;let r=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let l of r)o.body.appendChild(o.adoptNode(l));return o}function eo(e,s,o={}){let n=o||{};if(!n.head?.block)return is(e,s,n);try{return is(e,s,n)}catch(r){return Promise.reject(r)}}function is(e,s,o){let n=o.policy||"sync",r=n==="raw"?void 0:(u,v)=>mr(u)||(n==="history"?!(v&&u.matches(pr))&&u.matches(hr):u.matches(dr)),l=o.callbacks||{},c={ignore:r,hooks:l,protectFocusedValue:o.ignoreActiveValue===!0?"subtree":!1,restoreFocus:o.restoreFocus!==!1,formState:o.formStateSync||"attribute",scripts:{execute:o.scripts?.handle!==!1,merge:o.scripts?.merge!==!1,mergeTags:o.scripts?.mergeTags||[]},head:{awaitLoads:!!o.head?.block,preserve:o.head?.shouldPreserve||(()=>!1)}};if(typeof o.key=="function"&&(c.identity={base:o.key,local:o.key,remote:o.key}),e&&e.nodeType===9)return Mn(Object.assign({},c,{live:e,base:o.scripts?.mergeBase||null,remote:rs(s,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let u=Object.assign({},c,{live:e.ownerDocument,base:o.scripts?.mergeBase||null,remote:rs(s,e.ownerDocument)});return Mn(u)}o.morphStyle==="innerHTML"&&(c.children=!0);let f=gr(e,o.scripts?.mergeBase,!!c.children,c.scripts.mergeTags);return f!==void 0&&(c.base=f),to(e,s,c)}var kr=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply"]),en=()=>{};function Un(e,s=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let c of Object.keys(e))if(!kr.has(c))throw new TypeError(`unknown option "${c}"`);let o=Object.assign({beforeNodeAdded:en,afterNodeAdded:en,beforeNodeRemoved:en,afterNodeRemoved:en,beforeNodeMorphed:en,afterNodeMorphed:en,beforeAttributeUpdated:en},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let r=e.formState||"attribute";if(!["attribute","property"].includes(r))throw new TypeError("formState must be attribute or property");let l=e.protectFocusedValue;if(l!==void 0&&typeof l!="boolean"&&l!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');return{ignored:oo(e.ignore,s),remoteWins:oo(e.remoteWins,s),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:n,protectFocusedValue:l===void 0?!0:l,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:r,hooks:o,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null}}function In(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 dn}function On(e,s){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let o=qn(s,e.map),n=typeof e.then=="function"?e.then:dn;if(typeof e.first=="function"){let r=e.first;return l=>r(l)||o.get(l)||n(l)}return r=>o.get(r)||n(r)}return dn}function as(e,s,o,n={}){let r=A=>A&&A.nodeType===9?A.documentElement:A,l=r(s),c=r(o),f=r(e)||l,u=Object.assign({},n);delete u.live,delete u.base,delete u.remote;let v=Un(u,[f,l,c].filter(Boolean)),N=n.identity||{};return Ao(f,l,c,{identity:{base:On(N.base,f),local:On(N.local,l),remote:On(N.remote,c)},authored:{base:In(N.base),local:In(N.local),remote:In(N.remote)},skipUnchanged:v.hooks.beforeNodeMorphed===en&&v.hooks.afterNodeMorphed===en,ignored:v.ignored,remoteWins:v.remoteWins,ignoreAttribute:v.ignoreAttribute,conflicts:v.conflicts,mergeTags:v.scripts.merge===!1?null:v.scripts.mergeTags,baseURI:l.ownerDocument&&l.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===s,childrenOnly:v.children})}function To({liveRoot:e,baseRoot:s,localRoot:o,remoteRoot:n,toLive:r,options:l,identity:c,childrenOnly:f,isDocument:u}){let v=Un(l,[e,s,o,n].filter(Boolean));if(v.ignored(e))return{report:xo(),loads:[]};let N=e.ownerDocument,A=v.scripts.execute?Vo(e,v.ignored,N.baseURI):null,T=Ao(s||o,o,n,{identity:{base:On(c.base,s||o),local:On(c.local,o),remote:On(c.remote,n)},authored:{base:In(c.base),local:In(c.local),remote:In(c.remote)},ignored:v.ignored,remoteWins:v.remoteWins,ignoreAttribute:v.ignoreAttribute,conflicts:v.conflicts,mergeTags:v.scripts.merge===!1?null:v.scripts.mergeTags,baseURI:N.baseURI,localIsBase:!s,childrenOnly:f,skipUnchanged:v.hooks.beforeNodeMorphed===en&&v.hooks.afterNodeMorphed===en});v.beforeApply&&v.beforeApply(T.doc);let p=globalThis.__hyperMorphProfile,h=p?performance.now():0,x=Zo(e,T.root,T,{toLive:r,ignored:v.ignored,ignoreAttribute:v.ignoreAttribute,formState:v.formState,protectFocusedValue:v.protectFocusedValue,restoreFocus:v.restoreFocus,preserve:v.head.preserve,hooks:v.hooks,childrenOnly:f});p&&(p.apply=(p.apply||0)+(performance.now()-h));let R=[];if(v.head.awaitLoads)for(let K of x.applied){if(K.kind!=="insert"||K.node.nodeType!==1)continue;let ie=K.node;ie.tagName==="LINK"&&/\bstylesheet\b/i.test(ie.getAttribute("rel")||"")&&ie.getAttribute("href")&&ie.closest("head")&&R.push(new Promise(Me=>{ie.addEventListener("load",()=>Me()),ie.addEventListener("error",()=>Me())}))}if(A){let K=Wo(e,A,{ignored:v.ignored,skip:x.mergedScriptsLive,baseURI:N.baseURI,beforeNodeAdded:v.hooks.beforeNodeAdded,afterNodeAdded:v.hooks.afterNodeAdded});R.push(...K.loads)}let M=K=>K&&x.liveOf&&x.liveOf.get(K)||null;return{report:{applied:x.applied,decisions:T.decisions.map(K=>Object.assign({},K,{node:K.node?M(K.node):null,el:K.el?M(K.el):null,applied:!!(K.node?M(K.node):K.el&&M(K.el))})),conflicts:T.conflicts.map(K=>Object.assign({},K,{node:K.node?M(K.node):K.node,el:K.el?M(K.el):K.el})),localDiverged:T.localDiverged,identities:x.identities,moved:x.moved,replaced:x.replaced},loads:R}}var cs=new WeakMap;function xo(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[]}}function Mn(e){let s=e||{},o=s.live;if(!o||o.nodeType!==9)throw new TypeError("live must be a Document");let n=cs.get(o);n||(n=zn(o),cs.set(o,n));let r=n("remote",s.remote),l=typeof s.base=="string"&&s.base===""?null:s.base,c=l?n("base",l):null,f=s.local?s.local.root:o.documentElement,u=s.local?s.local.toLive:A=>A;vo(o,r);let{report:v,loads:N}=To({liveRoot:o.documentElement,baseRoot:c?c.documentElement:null,localRoot:f,remoteRoot:r.documentElement,toLive:u,options:s,identity:s.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(N).then(()=>v)}function fs(e,s,o={}){return Mn(Object.assign({},o,{live:e,base:null,remote:s}))}function ls(e,s){if(e==null)return{root:s.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 l=Kn(e,s),c=n[1].toLowerCase()==="html"?l.documentElement:l.body;return{root:c,first:c}}let r=s.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let n=s.createElement("template"),r=e.isConnected;return n.content.appendChild(r?s.importNode(e,!0):e),{root:n,first:e}}if(e.nodeType===11){let n=s.createElement("template");return n.content.appendChild(e),{root:n,first:n.content.firstElementChild}}let o=s.createElement("template");for(let n of Array.from(e))o.content.appendChild(n.parentNode?s.importNode(n,!0):n);return{root:o,first:o.content.firstElementChild}}function to(e,s,o={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let n=e.ownerDocument,{base:r,...l}=o,c=!!l.children;if(Un(l,[e]).ignored(e))return Promise.resolve(xo());let f=ls(s,n),u=r!=null?ls(r,n):null,v,N=null;if(c)v=f.root,N=u?u.root:null;else{if(v=f.first,N=u?u.first:null,!v){let p=Un(l);return p.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),p.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e]})}if(v.tagName!==e.tagName){let p=Un(l,[e,v]);if(p.hooks.beforeNodeMorphed(e,v)===!1)return Promise.resolve(xo());let h=To({liveRoot:e,baseRoot:N&&N.tagName===e.tagName?N:null,localRoot:e,remoteRoot:v,toLive:R=>R,options:l,identity:l.identity||{},childrenOnly:!0,isDocument:!1}),x=_t(v)?Bn(v,n):n.importNode(v,!1);if(!_t(x))for(;e.firstChild;)x.appendChild(e.firstChild);return p.hooks.beforeNodeAdded(x)===!1||p.hooks.beforeNodeRemoved(e)===!1?Promise.resolve(h.report):(e.replaceWith(x),p.hooks.afterNodeRemoved(e),p.hooks.afterNodeAdded(x),p.hooks.afterNodeMorphed(e,v),h.report.replaced.push(x),h.report.applied.push({kind:"insert",node:x,parent:x.parentNode},{kind:"remove",node:e,parent:x.parentNode}),Promise.all(h.loads).then(()=>h.report))}}let{report:A,loads:T}=To({liveRoot:e,baseRoot:N,localRoot:e,remoteRoot:v,toLive:p=>p,options:l,identity:l.identity||{},childrenOnly:c,isDocument:!1});return Promise.all(T).then(()=>A)}var yr={mergeDocument:Mn,morphDocument:fs,morphElement:to,merge3:as,morph:eo};return ys(wr);})();
1
+ var HyperMorph=(()=>{var So=Object.defineProperty;var $s=Object.getOwnPropertyDescriptor;var Gs=Object.getOwnPropertyNames;var Ys=Object.prototype.hasOwnProperty;var Js=(e,o)=>{for(var t in o)So(e,t,{get:o[t],enumerable:!0})},Xs=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of Gs(o))!Ys.call(e,r)&&r!==t&&So(e,r,{get:()=>o[r],enumerable:!(n=$s(o,r))||n.enumerable});return e};var Qs=e=>Xs(So({},"__esModule",{value:!0}),e);var ni={};Js(ni,{createIdentityStore:()=>Zo,createParseCache:()=>uo,default:()=>ti,diff:()=>Wn,findChangedRoots:()=>Us,importMap:()=>ho,merge3:()=>Fs,merge3Text:()=>Kn,mergeDocument:()=>Xn,mergeJson:()=>zo,mergeScriptText:()=>wo,morph:()=>Ao,morphDocument:()=>zs,morphElement:()=>vo,parseJsonRelaxed:()=>ko,parseRulesRelaxed:()=>bs,spliceProtected:()=>Vs,tieredIdentity:()=>Io});function fo(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 uo(e){let o=new Map;return(t,n)=>{if(typeof n!="string")return fo(n,e);let r=o.get(t);if(r&&r.text===n)return r.doc;let a=fo(n,e);return o.set(t,{text:n,doc:a}),a}}function Qo(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 r=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return n?e.replaceChild(r,n):e.insertBefore(r,e.documentElement),!0}var Oo=()=>!1;function Mo(e,o=[]){if(typeof e!="function")return Oo;let t=new WeakMap,n=new Set(o);return r=>{if(!r||r.nodeType!==1)return!1;let a=t.get(r);if(a!==void 0)return a;let l=[],i=r,u=!1;for(;i&&i.nodeType===1;){let A=t.get(i);if(A!==void 0){u=A;break}if(l.push(i),e(i,n.has(i))){u=!0;break}if(n.has(i))break;i=i.parentElement}for(let A of l)t.set(A,u);return u}}var ii=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 Mn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Zo(e){let o=new WeakMap,t=0,n=i=>o.get(i)||null,r=i=>{let u=o.get(i);return u||(u=`${e}:${++t}`,o.set(i,u)),u};return{idOf:n,ensure:r,adopt:(i,u)=>{i&&typeof u=="string"&&u&&o.set(i,u)},exportMap:(i,u)=>{let A={},N=[],h=[],M=(L,R)=>{let F=u(L);F&&(A[R]=r(F));let k=L.children;N.push(k.length),h.push(L.tagName.toLowerCase());for(let d=0;d<k.length;d++)M(k[d],R===""?String(d):`${R}.${d}`)};return M(i,""),A["~"]=N.join(","),A["^"]=h.join(","),A}}}function ho(e,o){let t=new WeakMap;if(!e||!o||typeof o!="object"||Array.isArray(o))return t;let n=o["~"],r=typeof n=="string"?n.split(",").map(Number):null,a=r&&typeof o["^"]=="string"?o["^"].split(","):null,l=h=>Number.isInteger(h)&&h>=0,i=0,u=!1,A=h=>{let M=h;for(;M>0;){let L=r[i++];if(i>r.length||!l(L))return!1;M+=L-1}return!0},N=(h,M)=>{if(u)return;if(r){let F=i++,k=r[F];if(F>=r.length||!l(k)){u=!0;return}let d=!a||a[F]===h.tagName.toLowerCase();if(!d||k!==h.children.length){let w=d&&o[M];typeof w=="string"&&w&&t.set(h,w),A(k)||(u=!0);return}}let L=o[M];typeof L=="string"&&L&&t.set(h,L);let R=h.children;for(let F=0;F<R.length;F++)N(R[F],M===""?String(F):`${M}.${F}`)};return N(e,""),t}function Io(e){return o=>{for(let t of e){let n=t(o);if(typeof n=="string"&&n!=="")return n}return null}}var an=Io([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function po(e,o,t,n=null){let r=new Map,a=new Set,l=i=>{if(t(i))return;let u=o(i);u&&(r.has(u)?a.add(u):r.set(u,i))};if(n){let i=u=>{for(let A of u.querySelectorAll(n))l(A);for(let A of u.querySelectorAll("template"))A.content&&i(A.content)};l(e),i(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let i=u=>{l(u);let A=u.tagName==="TEMPLATE"&&u.content?u.content.children:u.children;for(let N=0;N<A.length;N++)i(A[N])};i(e)}for(let i of a)r.delete(i),Lo(i);return r}function Lo(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var Zs=new Set(["href","src","name","type","role"]),ts=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function Vn(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 es(e){return e.replace(/\s+/g," ")}var er=0;function ns({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,r=new WeakMap;function a(ee){let oe=ee.attributes,re=oe.length;if(re===0)return{all:"",sig:ee.tagName+"|"};let ne=[],K="",D=[];for(let Ne=0;Ne<re;Ne++){let ae=oe[Ne],te=ae.name;o(ee,te)||ne.push(te+"="+ae.value),te==="class"?K=ae.value.indexOf(" ")<0?ae.value:ae.value.split(/\s+/).filter(Boolean).sort().join(" "):Zs.has(te)&&D.push(te+"="+ae.value)}return ne.length>1&&ne.sort(),D.length>1&&D.sort(),{all:ne.join(""),sig:ee.tagName+"|"+K+(D.length?"|"+D.join("|"):"")}}function l(ee){return ee.nodeType===1&&ee.tagName==="TEMPLATE"&&ee.content?ee.content.childNodes:ee.childNodes}function i(ee){let oe=n.get(ee);if(oe)return oe;if(ee.nodeType===3)oe={hash:"T"+Vn(ee.nodeValue),hint:es(ee.nodeValue).slice(0,64),sig:null,tok:null};else if(ee.nodeType===8)oe={hash:"C"+Vn(ee.nodeValue),hint:"",sig:null,tok:null};else if(ee.nodeType===1){let re=a(ee),ne=Vn(ee.tagName+""+re.all),K="";for(let D of A(ee))if(D.nodeType===1){let Ne=i(D);ne=Vn(Ne.hash,ne),K.length<64&&(K+=" "+Ne.hint)}else ne=Vn(N(D),ne),D.kind==="text"&&K.length<64&&(K+=D.value.slice(0,64));oe={hash:"E"+ne,hint:es(K).trim().slice(0,64),sig:re.sig,tok:null}}else oe={hash:"N"+ee.nodeType,hint:"",sig:null,tok:null};return n.set(ee,oe),oe}function u(ee){if(!ee.tok){ee.tok=new Set;for(let oe of ee.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))oe&&ee.tok.add(oe)}return ee.tok}function A(ee){let oe=r.get(ee);if(oe)return oe;oe=[];let re=null,ne=()=>{re&&(re.value=re.nodes.map(K=>K.nodeValue).join(""),oe.push(re),re=null)};for(let K of l(ee)){if(K.nodeType===3){re||(re={kind:"text",nodes:[],value:"",parent:ee,hash:void 0}),re.nodes.push(K);continue}ne(),K.nodeType===8?oe.push({kind:"comment",nodes:[K],value:K.nodeValue,parent:ee,hash:void 0}):K.nodeType===1&&!e(K)&&oe.push(K)}return ne(),r.set(ee,oe),oe}function N(ee){return ee.nodeType===1?i(ee).hash:(ee.hash===void 0&&(ee.hash=(ee.kind==="text"?"T":"C")+Vn(ee.value)),ee.hash)}function h(ee,oe){let re=u(i(ee)),ne=u(i(oe));if(re.size===0&&ne.size===0)return{coef:1,share:1};if(re.size===0||ne.size===0)return null;let K=0;for(let D of re)ne.has(D)&&K++;return{coef:K/Math.min(re.size,ne.size),share:K/Math.max(re.size,ne.size)}}function M(ee,oe){let re=h(ee,oe);return!!re&&re.coef>=.5}let L=new WeakMap;function R(ee){let oe=L.get(ee);if(oe)return oe;oe=[];for(let re of ee.attributes)o(ee,re.name)||oe.push([re.namespaceURI||"",re.localName,re.value]);return oe.sort((re,ne)=>re[0]<ne[0]?-1:re[0]>ne[0]?1:re[1]<ne[1]?-1:re[1]>ne[1]?1:0),L.set(ee,oe),oe}let F=new WeakMap;function k(ee,oe){if(ee===oe)return!0;if(N(ee)!==N(oe))return!1;let re=F.get(ee);if(re&&re.has(oe))return re.get(oe);let ne=F.get(oe);if(ne&&ne.has(ee))return ne.get(ee);let K=d(ee,oe),D=K===!0;return K===!1&&t&&t.hashRejected++,re||F.set(ee,re=new WeakMap),re.set(oe,D),D}function d(ee,oe){if(ee.nodeType===1){if(oe.nodeType!==1||ee.tagName!==oe.tagName||ee.namespaceURI!==oe.namespaceURI)return!1;let re=R(ee),ne=R(oe);if(re.length!==ne.length)return!1;for(let Ne=0;Ne<re.length;Ne++)if(re[Ne][0]!==ne[Ne][0]||re[Ne][1]!==ne[Ne][1]||re[Ne][2]!==ne[Ne][2])return!1;let K=A(ee),D=A(oe);if(K.length!==D.length)return!1;for(let Ne=0;Ne<K.length;Ne++){if(N(K[Ne])!==N(D[Ne]))return!1;if(!k(K[Ne],D[Ne]))return er}return!0}return oe.nodeType===1?!1:ee.kind===oe.kind&&ee.value===oe.value}let w=new WeakMap,Z=new Map,he=0;function xe(ee){let oe=w.get(ee);if(oe)return oe;let re=N(ee),ne=Z.get(re);ne||Z.set(re,ne=[]);let K=ne.find(D=>k(D.unit,ee));return oe=K?K.key:"K"+he++,K||ne.push({unit:ee,key:oe}),w.set(ee,oe),oe}return{meta:i,unitsOf:A,unitHash:N,similar:M,score:h,childrenOf:l,equalUnits:k,exactUnitKey:xe,ignored:e}}var os=16,tr=2e3,nr=3,Co={align:0,certifyVisited:0,certifyScheduled:0};function Eo(e,o,t){let{meta:n,unitsOf:r,unitHash:a,similar:l,score:i,childrenOf:u,equalUnits:A,ignored:N}=t.analyzer,h=t.baseId||(()=>null),M=t.sideId||(()=>null),L=t.stats||null,R=L?new Set:null,F=L?new Set:null,k=new Map,d=new Map,w=new Set,Z=new Map,he=new Set,xe=new Set,ee=new Set,oe=[],re=[],ne=[],K=[],D=tr,Ne=new Map,ae=new Map,te=(f,m)=>{k.set(f,m),d.set(m,f)},V=new Set,ye=new Set,be=null,Oe=f=>{let m=f.nodeType?f.parentNode:f.parent;if(!m||m.nodeType!==11)return m;if(!be){be=new WeakMap;let C=W=>{for(let j of W.querySelectorAll("template"))j.content&&(be.set(j.content,j),C(j.content))};for(let W of[e,o])C(W.tagName==="TEMPLATE"&&W.content?W.content:W)}return be.get(m)||null},He=(f,m)=>{for(let C=Oe(f);C&&!V.has(C);C=Oe(C))V.add(C);for(let C=Oe(m);C&&!ye.has(C);C=Oe(C))ye.add(C)},Ue=f=>{for(let m=Oe(f);m;m=Oe(m))if(k.has(m))return xe.has(m);return!1},ze=f=>{for(let m=Oe(f);m;m=Oe(m)){let C=d.get(m);if(C!==void 0)return xe.has(C)}return!1},se=f=>!!f&&f.nodeType===1,at=(f,m)=>{let C=Z.get(f);return!!C&&C.has(m)},ft=f=>ts.has(f.tagName),le=t.comparisons||t.scope,b=(f,m)=>{if(le){if(le.same.get(f)===m)return!0;if(le.differ.get(f)===m)return!1}if(!f.isEqualNode(m))return!1;if(f.tagName==="TEMPLATE")return A(f,m);let C=f.getElementsByTagName("template");if(C.length===0)return!0;let W=m.getElementsByTagName("template");if(C.length!==W.length)return!1;for(let j=0;j<C.length;j++)if(!A(C[j],W[j]))return!1;return!0},H=(f,m)=>{let C=h(f);if(!C)return!0;let W=M(m);return!W||C===W},fe=globalThis.__hyperMorphProfile,we=fe?performance.now():0;fe&&!t.scope&&(n(e),n(o),fe.meta=(fe.meta||0)+(performance.now()-we),we=performance.now()),te(e,o);let pe=new Set;for(let[f,m]of t.baseIndex){let C=t.sideIndex.get(f);C&&C.tagName===m.tagName&&!k.has(m)&&!d.has(C)&&(te(m,C),He(m,C),pe.add(m))}if(pe.size){let f=[];if(t.scope)for(let j of t.scope.chain)pe.has(j)&&f.push(j);let m=[t.scope?t.scope.root:e];for(;m.length;){let j=m.pop();pe.has(j)&&f.push(j);let z=u(j);for(let x=z.length-1;x>=0;x--)z[x].nodeType===1&&m.push(z[x])}let C=new Set;for(let j=f.length-1;j>=0;j--){let z=f[j];t.scope&&t.scope.onChain.has(z)?C.add(z):Jt(z,k.get(z),C)?(xe.add(z),ee.add(z),L&&L.certificationPairs++):C.add(z)}let W=new Set;for(let j of f)xe.has(j)&&!W.has(j)&&Ge(j,W)}t.scope&&t.scope.head&&Dt(t.scope.head[0],t.scope.head[1]);function Ge(f,m){let C=[f];for(;C.length;){let W=C.pop();if(!m.has(W)){m.add(W),v(W);for(let j of r(W))se(j)&&k.has(j)&&C.push(j)}}}K.push([e,o]);for(let[f,m]of k)se(f)&&f!==e&&K.push([f,m]);return wt(),je(),fe&&(fe.align=(fe.align||0)+(performance.now()-we)),{map:k,reverse:d,moved:he,identical:xe,pairIdenticalChildren:v,weak:w,unpair:Ze,rematch:je,insertedByHash:rt,refused:F,identityPaired:pe};function je(){E(),wt();for(let f=0;f<ne.length;){let m=ne.length;tn(f,m),f=m,wt(),E(),wt()}}function Ze(f){let m=k.get(f);if(!m)return;Z.has(f)||Z.set(f,new Set),Z.get(f).add(m);let C=(j,z)=>{k.delete(j),d.delete(z),he.delete(j),xe.delete(j),w.delete(j),ee.delete(j)},W=(j,z)=>{for(let x of r(j)){let S=k.get(x);!S||pe.has(x)||!(se(S)?z.contains(S):z.contains(S.nodes[0]))||(C(x,S),se(x)&&W(x,S))}};C(f,m),se(f)&&W(f,m),oe.push(f),re.push(m)}function rt(){let f=new Map;for(let m of new Set(re)){if(d.has(m))continue;let C=n(m).hash;f.has(C)||f.set(C,[]),f.get(C).push(m)}return f}function wt(){for(;K.length;){let[f,m]=K.shift();k.get(f)!==m||ee.has(f)||xe.has(f)||Tt(f,m)}}function bt(f,m){if(!ft(f))for(let C of r(f))se(C)&&(m.push(C),bt(C,m))}function Tt(f,m){ee.add(f);let C=r(f),W=r(m);Co.align+=C.length+W.length,Ne=new Map,ae=new Map;for(let G=0;G<C.length;G++)Ne.set(C[G],G);for(let G=0;G<W.length;G++)ae.set(W[G],G);if(f.tagName==="HTML")for(let G of["HEAD","BODY"]){let ge=C.find(c=>se(c)&&c.tagName===G),Me=W.find(c=>se(c)&&c.tagName===G);ge&&Me&&!k.has(ge)&&!d.has(Me)&&te(ge,Me)}for(let G=0;G<C.length&&G<W.length;G++){let ge=C[G],Me=W[G];k.has(ge)||d.has(Me)||(se(ge)?se(Me)&&ge.tagName===Me.tagName&&b(ge,Me)&&Dt(ge,Me):!se(Me)&&ge.kind===Me.kind&&ge.value===Me.value&&Dt(ge,Me))}y(C,W);let j=C.filter(G=>!k.has(G)),z=W.filter(G=>!d.has(G));j.length&&z.length&&(Xt(j,z),X(j,z),Q(j,z,C,W),ue(C,W));let x=!1,S=!1;for(let G of C){if(!k.has(G)){se(G)&&(oe.push(G),bt(G,oe),x=!0);continue}se(G)&&!xe.has(G)&&K.push([G,k.get(G)])}for(let G of W)!d.has(G)&&se(G)&&(re.push(G),bt(G,re),S=!0);x&&S&&ne.push([f,m])}function tn(f,m){for(let C=f;C<m;C++){let[W,j]=ne[C];if(k.get(W)!==j)continue;let z=r(W),x=r(j),S=new Map,G=new Map,ge=null;for(let Me of z)se(Me)&&(k.has(Me)?ge=Me:(S.has(ge)||S.set(ge,[]),S.get(ge).push(Me)));ge=null;for(let Me of x)se(Me)&&(d.has(Me)?ge=d.get(Me):(G.has(ge)||G.set(ge,[]),G.get(ge).push(Me)));for(let[Me,c]of S){let T=G.get(Me);if(!(!T||c.length!==T.length)&&c.every((P,U)=>T[U].tagName===P.tagName&&H(P,T[U])&&!at(P,T[U])))for(let P=0;P<c.length;P++)Fe(c[P],T[P])}}}function Fe(f,m){te(f,m),w.add(f),K.push([f,m]),wt()}function Xt(f,m){let C=_n(f,a),W=_n(m,a),j=new Map;for(let z of m){let x=a(z);W.get(x)===1&&j.set(x,z)}for(let z of f){if(k.has(z))continue;let x=a(z);if(C.get(x)!==1)continue;let S=j.get(x);S&&!d.has(S)&&A(z,S)&&Dt(z,S)}}function Jt(f,m,C){let W=[[f,m]];for(;W.length;){let[j,z]=W.pop();if(Co.certifyVisited++,L&&L.certificationVisited++,j.nodeType!==z.nodeType)return!1;if(j.nodeType===3||j.nodeType===8){if(j.nodeValue!==z.nodeValue)return!1;continue}if(j.nodeType!==1){if(!j.isEqualNode(z))return!1;continue}if(j.tagName!==z.tagName||j.namespaceURI!==z.namespaceURI||N(j)!==N(z))return!1;let x=j.attributes,S=z.attributes;if(x.length!==S.length)return!1;for(let T=0;T<x.length;T++){let P=x[T];if(z.getAttributeNS(P.namespaceURI,P.localName)!==P.value)return!1}let G=k.get(j);if(G!==void 0&&G!==z)return!1;let ge=d.get(z);if(ge!==void 0&&ge!==j)return!1;if(j!==f){if(xe.has(j))continue;if(C.has(j))return!1}let Me=u(j),c=u(z);if(Me.length!==c.length)return!1;Co.certifyScheduled+=Me.length;for(let T=Me.length-1;T>=0;T--)W.push([Me[T],c[T]])}return!0}function Dt(f,m){if(se(f)&&(V.has(f)||ye.has(m))){let C=Et(f,m);if(!C){te(f,m),K.push([f,m]);return}for(let W=0;W<C.length;W+=2){let j=C[W],z=C[W+1],x=k.get(j);x!==void 0&&x!==z&&It(j,x);let S=d.get(z);S!==void 0&&S!==j&&It(S,z),k.get(j)===z&&(he.delete(j),w.delete(j),xe.add(j),ee.add(j))}}sn(f,m)}function It(f,m){k.delete(f),d.delete(m),he.delete(f),xe.delete(f),w.delete(f),ee.delete(f)}function Et(f,m){let C=[f,m,!1],W=[];for(;C.length;){let j=C.pop(),z=C.pop(),x=C.pop(),S=k.get(x),G=d.get(z);if(x!==f&&(S!==void 0&&S!==z&&pe.has(x)||G!==void 0&&G!==x&&pe.has(G)))return null;if(!(S===z&&xe.has(x))&&((S!==void 0||G!==void 0)&&W.push(x,z),!!se(x))){if(j||S!==void 0&&S!==z||G!==void 0&&G!==x){let ge=r(x),Me=r(z);for(let c=0;c<ge.length&&c<Me.length;c++)C.push(ge[c],Me[c],!0)}else if(V.has(x)||ye.has(z)){let ge=x.tagName==="TEMPLATE"?x.content:x,Me=z.tagName==="TEMPLATE"?z.content:z;for(let c=ge.firstElementChild,T=Me.firstElementChild;c&&T;){if(N(c)){c=c.nextElementSibling;continue}if(N(T)){T=T.nextElementSibling;continue}(k.has(c)||d.has(T)||V.has(c)||ye.has(T))&&C.push(c,T,!1),c=c.nextElementSibling,T=T.nextElementSibling}}}}return W}function sn(f,m){te(f,m),xe.add(f),se(f)&&ee.add(f)}function v(f){let m=k.get(f);if(!m||!se(f))return;let C=r(f),W=r(m);for(let j=0;j<C.length&&j<W.length;j++)k.has(C[j])||sn(C[j],W[j])}function X(f,m){let C=x=>se(x)&&!ft(x)?n(x).sig+""+n(x).hint:null,W=_n(f,C),j=_n(m,C),z=new Map;for(let x of m){let S=C(x);S!=null&&j.get(S)===1&&z.set(S,x)}for(let x of f){if(k.has(x))continue;let S=C(x);if(S==null||W.get(S)!==1)continue;let G=z.get(S);G&&!d.has(G)&&H(x,G)&&te(x,G)}}function Q(f,m,C,W){let j=new Map;for(let x of m){if(!se(x)||d.has(x)||ft(x))continue;let S=n(x).sig;j.has(S)||j.set(S,[]),j.get(S).push({el:x,index:ae.get(x)})}let z=[];for(let x of f){if(k.has(x)||!se(x)||ft(x))continue;let S=j.get(n(x).sig);if(!S||!S.length)continue;let G=Ne.get(x),ge=S.filter(Me=>!d.has(Me.el)).map(Me=>({c:Me,d:Math.abs(Me.index-G)}));ge.sort((Me,c)=>Me.d-c.d),ge.length>os&&(ge=ge.slice(0,os));for(let{c:Me,d:c}of ge){if(!H(x,Me.el))continue;let T=i(x,Me.el);T&&T.coef>=.5&&z.push({b:x,s:Me.el,coef:T.coef,share:T.share,d:c,bi:G})}}if(z.sort((x,S)=>S.coef-x.coef||S.share-x.share||x.d-S.d||x.bi-S.bi),L&&z.length>1){let x=new Map;for(let S of z){let G=x.get(S.b);G?G.coef===S.coef&&(G.share===S.share?G.strict++:G.loose++):x.set(S.b,{coef:S.coef,share:S.share,strict:0,loose:0})}for(let[S,G]of x)R.has(S)||!(G.strict||G.loose)||(R.add(S),G.strict?L.similarTiesStrict++:L.similarTiesLoose++)}for(let x of z)!k.has(x.b)&&!d.has(x.s)&&te(x.b,x.s)}function de(f,m){return se(f)!==se(m)?!1:se(f)?f.tagName!==m.tagName||!H(f,m)?!1:ft(f)||n(f).hint===""||n(m).hint===""?!0:l(f,m):f.kind===m.kind}function ie(f,m){let C=(j,z)=>{let x=z===null?-1:j===m?ae.get(z):Ne.get(z),S=j[x+1];return S&&!se(S)?S:null},W=null;for(let j of f){if(se(j)){W=j;continue}if(k.has(j))continue;let z=W===null?null:k.get(W);if(W!==null&&!z)continue;let x=C(m,z);x&&!d.has(x)&&x.kind===j.kind&&te(j,x)}}function ue(f,m){ie(f,m);let C=p(f,m),W=(z,x)=>se(z)&&n(z).hint!==""&&n(x).hint===""&&!!x.querySelector("br")&&!C(z,x),j=0;for(let z of f){if(k.has(z)){let S=ae.get(k.get(z));S!==void 0&&S>=j&&(j=S+1);continue}let x=0;for(let S=j;S<m.length&&x<nr;S++){let G=m[S];if(!d.has(G)&&(x++,de(z,G)&&!at(z,G)&&!W(z,G))){te(z,G),se(z)&&(n(z).hint===""||n(G).hint==="")&&w.add(z),j=S+1;break}}}y(f,m)}function p(f,m){let C=(W,j,z)=>{for(let x=j-1;x>=0;x--)if(se(W[x])&&z(W[x]))return W[x];return null};return(W,j)=>{let z=Ne.get(W),x=ae.get(j);if(z===x)return!0;let S=C(f,z,ge=>k.has(ge)),G=C(m,x,ge=>d.has(ge));return S?k.get(S)===G:!G}}function y(f,m){let C=f.filter(S=>se(S)&&!k.has(S)),W=m.filter(S=>se(S)&&!d.has(S));if(!C.length||!W.length)return;let j=_n(C,S=>S.tagName),z=_n(W,S=>S.tagName),x=p(f,m);for(let S of C){let G=S.tagName;if(j.get(G)!==1||z.get(G)!==1)continue;let ge=W.find(Me=>Me.tagName===G);ge&&!d.has(ge)&&x(S,ge)&&H(S,ge)&&!at(S,ge)&&(A(S,ge)?Dt(S,ge):(te(S,ge),w.add(S)))}}function E(){let f=new Map;for(let S of w)if(se(S)&&se(k.get(S))){let G=n(S).hash;f.has(G)||f.set(G,[]),f.get(G).push(S)}if(f.size)for(let S of re){if(d.has(S)||!se(S)||ze(S))continue;let G=f.get(n(S).hash),ge=G&&G.find(Me=>w.has(Me)&&!at(Me,S)&&H(Me,S)&&A(Me,S));ge&&(Ze(ge),Dt(ge,S),He(ge,S),he.add(ge))}let m=new Map,C=new Map,W=new Map;for(let S of w){let G=k.get(S);se(S)&&se(G)&&W.set(G,S)}let j=(S,G)=>{if(!d.has(S))return!ze(S);let ge=W.get(S);return ge===d.get(S)&&ge!==G&&!ge.contains(G)},z=S=>{if(d.has(S)){let G=W.get(S);W.delete(S),Ze(G)}};for(let S of[...re,...W.keys()]){if(d.has(S)&&!W.has(S))continue;let G=n(S).hash;if(m.has(G)||m.set(G,[]),m.get(G).push(S),ft(S))continue;let ge=n(S).sig;C.has(ge)||C.set(ge,[]),C.get(ge).push(S)}let x=new Set;for(let S of w){let G=k.get(S);!se(S)||!se(G)||ft(S)||n(S).hint===""||n(G).hint===""||l(S,G)||x.add(S)}for(let S of[...oe,...x]){let G=k.get(S);if(G?!(w.has(S)&&x.has(S)):Ue(S))continue;let ge=U=>{G&&Ze(S),z(U)},Me=m.get(n(S).hash);if(Me){let U=Me.find(_=>_!==G&&j(_,S)&&!at(S,_)&&A(S,_));if(U){ge(U),Dt(S,U),He(S,U),he.add(S);continue}}if(ft(S)||D<=0)continue;let c=C.get(n(S).sig);if(!c)continue;let T=null,P=0;for(let U of c)if(!(U===G||!j(U,S)||!H(S,U)||at(S,U))&&(D--<=0||l(S,U)&&(P++,T=U,P>1)))break;P>1&&F&&F.add(S),P===1&&(ge(T),te(S,T),He(S,T),he.add(S),K.push([S,T]))}}}function _n(e,o){let t=new Map;for(let n of e){let r=o(n);r!=null&&t.set(r,(t.get(r)||0)+1)}return t}var or={diff:0},ss=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,sr=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,rr=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,ir=/\P{M}\p{M}*/gu;function Do(e){if(e==="")return[];if(ss){let t=[];for(let n of ss.segment(e))t.push(n.segment);return t}let o=[];for(let t of e.match(rr))if(sr.test(t))for(let n of t.match(ir))o.push(n);else o.push(t);return o}var lr=/^[  ]+$/,cr=e=>lr.test(e)?" ".repeat(e.length):e,In=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),gt="",Ro=e=>e.every(o=>In(o)||o.k===gt),ar=/^[\x00-\x7f\u00A0]*$/,fr=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function ur(e){return e===""?[]:e.match(fr)}function Pn(e,o=!1){return(o?ur(e):Do(e)).map(t=>({k:cr(t),raw:t,len:t.length}))}var mo=(...e)=>e.every(o=>ar.test(o));function Po(e,o,t){let n=e.length,r=o.length,a=Math.min(n+r,t),l=a+1,i=new Int32Array(2*a+3),u=[],A=n===0&&r===0;for(let L=0;L<=a&&!A;L++){u.push(i.slice(l-L,l+L+1));for(let R=-L;R<=L;R+=2){let F;R===-L||R!==L&&i[l+R-1]<i[l+R+1]?F=i[l+R+1]:F=i[l+R-1]+1;let k=F-R,d=F;for(;F<n&&k<r&&e[F].k===o[k].k;)F++,k++;if(or.diff+=1+F-d,i[l+R]=F,F>=n&&k>=r){A=!0;break}}}if(!A)return null;let N=[],h=n,M=r;for(let L=u.length-1;L>0;L--){let R=u[L],F=h-M,k=F+L,d=F===-L||F!==L&&R[k-1]<R[k+1]?F+1:F-1,w=R[d+L],Z=w-d;for(;h>w&&M>Z;)N.push([0,h-1,M-1]),h--,M--;h===w?(N.push([1,h,M-1]),M--):(N.push([-1,h-1,M]),h--)}for(;h>0&&M>0;)N.push([0,h-1,M-1]),h--,M--;return N.reverse(),N}function dr(e,o,t){let n=h=>h.k===gt;if(!e.some(n)&&!o.some(n))return Po(e,o,t);let r=[],a=[];for(let h=0;h<e.length;h++)n(e[h])||r.push(h);for(let h=0;h<o.length;h++)n(o[h])||a.push(h);let l=Po(r.map(h=>e[h]),a.map(h=>o[h]),t);if(!l)return null;let i=[],u=0,A=0,N=(h,M)=>{for(;u<h&&A<M&&e[u].k===o[A].k;)i.push([0,u++,A++]);let L=Po(e.slice(u,h),o.slice(A,M),t);if(!L)return!1;for(let[R,F,k]of L)i.push([R,F+u,k+A]);return u=h,A=M,!0};for(let[h,M,L]of l)if(h===0){if(!N(r[M],a[L]))return null;i.push([0,u,A]),u++,A++}return N(e.length,o.length)?i:null}function qn(e,o,t=4e3){let n=[],r=0;for(;r<e.length&&r<o.length&&e[r].k===o[r].k;)e[r].raw!==o[r].raw&&n.push({bi:r,tok:o[r]}),r++;let a=0;for(;a<e.length-r&&a<o.length-r&&e[e.length-1-a].k===o[o.length-1-a].k;)e[e.length-1-a].raw!==o[o.length-1-a].raw&&n.push({bi:e.length-1-a,tok:o[o.length-1-a]}),a++;let l=e.slice(r,e.length-a),i=o.slice(r,o.length-a),u=kr(l,i)?null:dr(l,i,t);if(!u){let d=l.length||i.length?[{bs:r,be:r+l.length,toks:i}]:[];return{hunks:d,cosmetic:n,coarse:!0,parts:d.map(w=>({...w,gap:[],group:0})),cosmeticEq:n}}let A=[],N=(d,w)=>{l[d].raw!==i[w].raw&&n.push({bi:r+d,tok:i[w]})},h=null,M=[],L=0,R=0,F=()=>{h&&A.push(h),h=null;for(let[d,w]of M)N(d,w);M=[],L++};for(let[d,w,Z]of u){if(d===0){h&&In(l[w])&&!l[w].k.includes(`
2
+ `)?M.push([w,Z]):(F(),N(w,Z)),R=w+1;continue}(!h||M.length)&&(h&&A.push(h),h={bs:r+R,be:r+R,toks:[],gap:M.map(([he,xe])=>({bi:r+he,tok:i[xe]})),group:L},M=[]),d===-1?(h.be=r+R+1,R=w+1):h.toks.push(i[Z])}F(),hr(A,e);let k=Ho(A);return{hunks:k.hunks,cosmetic:n.concat(k.cosmetic),parts:A,cosmeticEq:n}}function hr(e,o){for(let t=0;t<e.length;t++){let n=e[t];if(n.gap.length)continue;let r=t+1<e.length?e[t+1].bs:1/0;if(n.toks.length){if(n.bs===n.be)for(;n.bs+1<r&&n.bs<o.length&&n.toks[0].k===gt&&o[n.bs].k===gt;)n.toks=[...n.toks.slice(1),n.toks[0]],n.bs++,n.be++}else for(;n.be+1<r&&n.be<o.length&&o[n.bs].k===gt&&o[n.be].k===gt;)n.bs++,n.be++}}function Ho(e,o=()=>!1){let t=[],n=[],r=null,a=-1;for(let l of e){let i=o(l);if(r&&!r.alone&&!i&&l.group===a){r.be=l.be;for(let u of l.gap)r.toks.push(u.tok);for(let u of l.toks)r.toks.push(u);continue}r&&t.push({bs:r.bs,be:r.be,toks:r.toks});for(let u of l.gap)n.push(u);r={bs:l.bs,be:l.be,toks:l.toks.slice(),alone:i},a=l.group}return r&&t.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:t,cosmetic:n}}var pr=(e,o)=>e.bs===o.bs&&e.be===o.be&&Vo(e.toks,o.toks);function Uo(e,o,t){let n=N=>h=>N.some(M=>pr(h,M)),r=Ho(e.parts,n(o.parts)),a=Ho(o.parts,n(e.parts)),l=e.cosmeticEq.concat(r.cosmetic),i=o.cosmeticEq.concat(a.cosmetic),[u,A]=t?mr(r.hunks,a.hunks,t,l,i):[r.hunks,a.hunks];return{lh:u,rh:A,cosL:l,cosR:i}}function mr(e,o,t,n,r){let a=(R,F)=>R.k===F.k&&R.raw===F.raw,l=[{list:e.map(R=>({...R})),resp:new Set(n.map(R=>R.bi)),raw:new Map(n.map(R=>[R.bi,R.tok]))},{list:o.map(R=>({...R})),resp:new Set(r.map(R=>R.bi)),raw:new Map(r.map(R=>[R.bi,R.tok]))}],i=R=>R.bs===R.be,u=(R,F,k,d)=>{let w=R.list[F];if(!i(w))return d(w)===k?w.toks:null;let Z=F?R.list[F-1].be:0,he=F+1<R.list.length?R.list[F+1].bs:t.length;if(k<Z||k>he)return null;let xe=w.toks,ee=w.bs;for(;ee>k;){let oe=xe[xe.length-1];if(!a(oe,t[ee-1])||R.resp.has(ee-1))return null;xe=[oe,...xe.slice(0,-1)],ee--}for(;ee<k;){if(!a(xe[0],t[ee])||R.resp.has(ee))return null;xe=[...xe.slice(1),xe[0]],ee++}return xe},A=(R,F,k,d,w,Z)=>{let he=R.list[F],xe=w?k.slice(k.length-d):k.slice(0,d),ee=w?k.slice(0,k.length-d):k.slice(d),oe={bs:Z,be:Z,toks:xe};if(i(he)){if(!ee.length){R.list[F]=oe;return}let ne={bs:Z,be:Z,toks:ee};w&&(ne.lead=!0),R.list.splice(F,1,...w?[ne,oe]:[oe,ne]);return}let re={bs:he.bs,be:he.be,toks:ee};R.list.splice(F,1,...w?[re,oe]:[oe,re])},N=(R,F,k,d,w)=>{let Z=R.list[F],he=w?k.slice(k.length-d):k.slice(0,d),xe=w?k.slice(0,k.length-d):k.slice(d),ee={bs:Z.bs,be:Z.be,toks:he};if(!xe.length){R.list[F]=ee;return}let oe=w?{bs:Z.bs,be:Z.bs,toks:xe,lead:!0}:{bs:Z.be,be:Z.be,toks:xe};R.list.splice(F,1,...w?[oe,ee]:[ee,oe])},h=(R,F,k,d)=>{let w=R.list[F],Z=k.list[d],he=w.be,xe=Z.bs;if(he>=xe||F+1<R.list.length&&R.list[F+1].bs<=Z.be||d>0&&k.list[d-1].be>=w.bs)return!1;for(let be=he;be<xe;be++)if(!In(t[be])||t[be].k.includes(`
3
+ `))return!1;let ee=be=>t.slice(he,xe).map((Oe,He)=>be.raw.get(he+He)||Oe),oe=[...w.toks,...ee(R)],re=[...ee(k),...Z.toks],ne=(be,Oe,He)=>Oe>=0&&Oe+He.length<=be.length&&He.every((Ue,ze)=>be[Oe+ze].k===Ue.k),K=(be,Oe,He)=>Ro(be)&&t.slice(Oe,He).some(Ue=>!In(Ue)),D=be=>be.some(Oe=>!In(Oe)),Ne,ae,te,V;if(i(w)&&D(w.toks)&&ne(re,0,w.toks)){let be=re.slice(w.toks.length);K(be,he,Z.be)||(Ne=he,ae=w.toks,te=re.slice(0,w.toks.length),V=[null,{bs:he,be:Z.be,toks:be}])}if(Ne===void 0&&i(Z)&&D(Z.toks)){let be=oe.length-Z.toks.length,Oe=oe.slice(0,be);ne(oe,be,Z.toks)&&!K(Oe,w.bs,xe)&&(Ne=xe,ae=oe.slice(be),te=Z.toks,V=[{bs:w.bs,be:xe,toks:Oe},null])}if(Ne===void 0)return!1;let ye=be=>be&&(be.bs<be.be||be.toks.length);return R.list.splice(F,1,...[V[0],{bs:Ne,be:Ne,toks:ae}].filter(ye)),k.list.splice(d,1,...[{bs:Ne,be:Ne,toks:te},V[1]].filter(ye)),!0},M=l[0],L=l[1];for(let R=0;R<64;R++){let F=!1;e:for(let k=0;k<M.list.length;k++)for(let d=0;d<L.list.length;d++){let w=M.list[k],Z=L.list[d];if(!(w.bs===Z.bs&&w.be===Z.be&&Vo(w.toks,Z.toks))){for(let he of[!0,!1]){let xe=oe=>he?oe.be:oe.bs,ee=i(w)?[xe(Z),w.bs]:[xe(w)];for(let oe of ee){let re=u(M,k,oe,xe),ne=re&&u(L,d,oe,xe);if(!ne)continue;let K=(V,ye)=>he?V[V.length-1-ye]:V[ye],D=0;for(;D<re.length&&D<ne.length&&K(re,D).k===K(ne,D).k;)D++;if(!D)continue;let Ne=he?re.slice(0,re.length-D):re.slice(D),ae=he?ne.slice(0,ne.length-D):ne.slice(D);if(!(D<re.length&&D<ne.length&&!Ro(Ne)&&!Ro(ae)&&(i(w)&&i(Z)||w.bs===Z.bs&&w.be===Z.be)||!(he?re.slice(re.length-D):re.slice(0,D)).some(V=>!In(V)))){if(D===re.length&&D===ne.length&&i(w)&&i(Z)){if(w.bs===oe&&Z.bs===oe)continue;M.list[k]={bs:oe,be:oe,toks:re},L.list[d]={bs:oe,be:oe,toks:ne}}else!i(w)&&w.bs===Z.bs&&w.be===Z.be?(N(M,k,re,D,he),N(L,d,ne,D,he)):(A(M,k,re,D,he,oe),A(L,d,ne,D,he,oe));F=!0;break e}}}if(h(M,k,L,d)||h(L,d,M,k)){F=!0;break e}}}if(!F)break}return[M.list,L.list]}var gr=48,br=.3;function kr(e,o){let t=e.filter(l=>!In(l)),n=o.filter(l=>!In(l));if(Math.min(t.length,n.length)<gr)return!1;let r=new Map;for(let l of t)r.set(l.k,(r.get(l.k)||0)+1);let a=0;for(let l of n){let i=r.get(l.k);i>0&&(a++,r.set(l.k,i-1))}return a/Math.min(t.length,n.length)<br}var yr=(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},Vo=(e,o)=>e.length===o.length&&e.every((t,n)=>t.k===o[n].k);function rs(e,o,t,n="remote"){let r=qn(e,o),a=qn(e,t),{lh:l,rh:i,cosL:u,cosR:A}=Uo(r,a,e),N=b=>b.bs===b.be,h=b=>b.toks.some(H=>typeof H.k=="string"),M=b=>N(b)&&!h(b),L=(b,H)=>H.bs<b.be&&b.bs<H.be,R=(b,H)=>!L(b,H)&&H.bs<=b.be&&b.bs<=H.be&&(N(b)&&h(b)||N(H)&&h(H))&&!(N(b)&&N(H)),F=(b,H)=>b.bs===H.bs&&b.be===H.be&&Vo(b.toks,H.toks),k=[],d=new Set;for(let b of l){let H=i.find(fe=>!d.has(fe)&&F(b,fe));H?(d.add(H),k.push({bs:b.bs,be:b.be,side:"both",l:b,r:H,toks:b.toks})):k.push({bs:b.bs,be:b.be,side:"L",l:b,toks:b.toks,lead:!!b.lead})}for(let b of i)d.has(b)||k.push({bs:b.bs,be:b.be,side:"R",r:b,toks:b.toks,lead:!!b.lead});k.sort((b,H)=>b.bs-H.bs||b.be-H.be||H.lead-b.lead);let w=0,Z=0;for(let b of k)b.side==="both"&&(w+=b.toks.length-(b.be-b.bs));let he=k.map((b,H)=>H),xe=b=>he[b]===b?b:he[b]=xe(he[b]),ee=(b,H)=>(b=xe(b),H=xe(H),b===H?!1:(he[b]=H,!0)),oe=k.map(b=>yr({bs:b.bs,be:b.be,toks:b.toks},e)),re={L:new Map,R:new Map};k.forEach((b,H)=>{let fe=b.side==="both"?["L","R"]:[b.side];for(let we of fe)for(let pe of oe[H])re[we].has(pe)||re[we].set(pe,[]),re[we].get(pe).push(H)});for(let b of[re.L,re.R])for(let H of b.values())for(let fe=1;fe<H.length;fe++)ee(H[0],H[fe]);for(let b=0;b<k.length;b++)for(let H=b+1;H<k.length;H++){let fe=k[b],we=k[H];fe.side===we.side&&fe.side!=="both"||fe.bs>we.be||(L(fe,we)||R(fe,we)?ee(b,H):fe.bs===we.bs&&N(fe)&&N(we)&&Z++)}let ne=(b,H)=>{let fe=b==="L"?l:i;for(let we of fe)if(we.toks.some(pe=>pe.kind==="close"&&pe.k.el===H.el))return we.bs;for(let we=0;we<e.length;we++)if(e[we].kind==="close"&&e[we].k.el===H.el)return we;return-1};k.forEach((b,H)=>{if(!(!M(b)||b.side==="both"))for(let fe of b.toks){if(fe.kind!=="open")continue;let we=ne(b.side,fe.k);if(we<=b.bs)continue;let pe=new Uint8Array(we-b.bs),Ge=[];if(k.forEach((je,Ze)=>{if(!(je.side===b.side||N(je))&&je.bs<we&&je.be>b.bs){Ge.push(Ze);for(let rt=Math.max(je.bs,b.bs);rt<Math.min(je.be,we);rt++)pe[rt-b.bs]=1}}),Ge.length&&pe.every(je=>je===1))for(let je of Ge)ee(H,je)}});let K=!0;for(;K;){K=!1;let b=new Map;k.forEach((H,fe)=>{let we=xe(fe),pe=b.get(we)||{bs:H.bs,be:H.be,L:!1,R:!1};pe.bs=Math.min(pe.bs,H.bs),pe.be=Math.max(pe.be,H.be),H.side!=="R"&&(pe.L=!0),H.side!=="L"&&(pe.R=!0),b.set(we,pe)}),k.forEach((H,fe)=>{for(let[we,pe]of b){if(xe(fe)===xe(we)||!(pe.L&&pe.R))continue;let Ge=H.bs<pe.be&&H.be>pe.bs,je=N(H)&&h(H)&&(H.bs===pe.be||H.bs===pe.bs);(Ge||je)&&ee(fe,we)&&(K=!0)}})}let D=new Map;k.forEach((b,H)=>{let fe=xe(H);D.has(fe)||D.set(fe,[]),D.get(fe).push(b)});let Ne=[];for(let b of D.values()){let H=b.some(we=>we.side==="L"),fe=b.some(we=>we.side==="R");if(H&&fe){let we=Math.min(...b.map(Ze=>Ze.bs)),pe=Math.max(...b.map(Ze=>Ze.be)),Ge=b.filter(Ze=>Ze.side!=="R").map(Ze=>Ze.l).sort((Ze,rt)=>Ze.bs-rt.bs),je=b.filter(Ze=>Ze.side!=="L").map(Ze=>Ze.r).sort((Ze,rt)=>Ze.bs-rt.bs);Ne.push({bs:we,be:pe,kind:"conflict",localHunks:Ge,remoteHunks:je})}else for(let we of b)Ne.push({bs:we.bs,be:we.be,kind:we.side,u:we})}let ae=(b,H)=>{let fe=b==="L"?l:i;for(let we of fe)if(we.toks.some(pe=>pe.kind==="close"&&pe.k.el===H.el))return we.bs+.5;for(let we=0;we<e.length;we++)if(e[we].kind==="close"&&e[we].k.el===H.el)return we;return 1/0},te=(b,H)=>{let fe=b==="L"?l:i;for(let we of fe)if(we.toks.some(pe=>pe.kind==="open"&&pe.k.el===H.el))return we.bs-.5;for(let we=0;we<e.length;we++)if(e[we].kind==="open"&&e[we].k.el===H.el)return we;return-1/0},V=b=>b.kind==="R"?"R":"L",ye=b=>b.kind==="R"?1:0;Ne.sort((b,H)=>{if(b.bs!==H.bs)return b.bs-H.bs;let fe=b.bs===b.be,we=H.bs===H.be;if(fe!==we)return fe?-1:1;if(fe&&we&&b.kind!=="conflict"&&H.kind!=="conflict"){let Ge=b.u.toks,je=H.u.toks,Ze=wt=>wt.length&&wt.every(bt=>bt.kind==="open"),rt=wt=>wt.length&&wt.every(bt=>bt.kind==="close");if(Ze(Ge)&&Ze(je)){let wt=Math.max(...Ge.map(Tt=>ae(V(b),Tt.k))),bt=Math.max(...je.map(Tt=>ae(V(H),Tt.k)));if(wt!==bt)return bt-wt}if(rt(Ge)&&rt(je)){let wt=Math.min(...Ge.map(Tt=>te(V(b),Tt.k))),bt=Math.min(...je.map(Tt=>te(V(H),Tt.k)));return wt!==bt?bt-wt:ye(H)-ye(b)}}let pe=Ge=>Ge.u&&Ge.u.lead?1:0;return pe(H)-pe(b)||ye(b)-ye(H)||b.be-H.be});let be=[],Oe=[],He=0,Ue=b=>{b>He&&(be.push({bs:He,be:b,toks:e.slice(He,b),source:"base"}),He=b)};for(let b of Ne){if(Ue(b.bs),b.kind==="conflict"){let H=jo(e,b.localHunks,b.bs,b.be),fe=jo(e,b.remoteHunks,b.bs,b.be),we=n==="local"?H:n==="both"?H.concat(fe):fe,pe=(Ze,rt)=>{let wt=0;for(let bt of Ze)bt.be<=b.bs&&!rt.includes(bt)&&(wt+=bt.toks.length-(bt.be-bt.bs));return wt},Ge=b.bs+pe(l,b.localHunks),je=b.bs+pe(i,b.remoteHunks);Oe.push({bs:b.bs,be:b.be,ls:Ge,le:Ge+H.length,rs:je,re:je+fe.length,ms:0,me:0,base:e.slice(b.bs,b.be),local:H,remote:fe,resolved:we}),be.push({bs:b.bs,be:b.be,toks:we,source:"conflict",localHunks:b.localHunks,localToks:H,keepsLocal:n!=="remote"})}else be.push({bs:b.bs,be:b.be,toks:b.u.toks,source:b.kind==="R"?"remote":"local",localHunks:b.kind==="R"?[]:[b.u.l]});He=Math.max(He,b.be)}Ue(e.length);let ze=0,se=0;for(let b of be)b.source==="conflict"&&(Oe[se].ms=ze,Oe[se].me=ze+b.toks.length,se++),ze+=b.toks.length;let at=new Map(u.map(b=>[b.bi,b.tok])),ft=new Map(A.map(b=>[b.bi,b.tok])),le=[];for(let b of be){b.source==="base"&&(b.toks=b.toks.map((H,fe)=>{let we=b.bs+fe,pe=at.get(we),Ge=ft.get(we),je=pe&&Ge?n==="remote"?Ge:pe:pe||Ge||H;return je===H?H:{...je,cosmetic:!0}}));for(let H of b.toks)le.push({...H,src:b.source})}return{tokens:le,segments:be,conflicts:Oe,localHunks:l,remoteHunks:i,collapsedDelta:w,samePoint:Z,mapLocalOffset:wr(e,l,be)}}function jo(e,o,t,n){let r=[],a=t;for(let l of o)r=r.concat(e.slice(a,l.bs),l.toks),a=l.be;return r.concat(e.slice(a,n))}var Bo=e=>e.reduce((o,t)=>o+t.len,0);function wr(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 r=o.map(l=>({bs:n[l.bs],be:n[l.be],text:l.toks.map(i=>i.raw).join(""),ref:l})),a=t.map(l=>({bs:n[l.bs],be:n[l.be],len:Bo(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?Bo(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let i=null,u=null,A=0,N=0,h=0;for(let L of r){let R=L.bs-h;if(l<=N+R){i=h+(l-N);break}if(N+=R,h=L.bs,l<=N+L.text.length){u=L,A=l-N,i=L.bs;break}N+=L.text.length,h=L.be}i===null&&(i=h+(l-N));let M=0;for(let L of a){if(!u&&i<=L.bs)return M;if(!(u?L.localHunks.includes(u.ref):i<L.be)){M+=L.len;continue}if(L.source==="base")return M+(i-L.bs);if(L.source==="remote")return M+L.len;if(L.source==="local")return M+Math.min(A,L.len);if(!L.keepsLocal||!u)return M+L.len;let F=L.localHunks.indexOf(u.ref),k=Bo(jo(e,L.localHunks.slice(0,F),L.ref.bs,u.ref.bs));return M+Math.min(k+A,L.localLen)}return M}}function Kn(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:d=>Math.min(d,o.length),granularity:"word"};let r=mo(e,o,t),a=Pn(e,r),l=Pn(o,r),i=Pn(t,r),u=a.length<=2e4&&l.length<=2e4&&i.length<=2e4?rs(a,l,i,n):null,A="word",N=a;if(!u){let d=w=>w.split(/(?<=\n)/).map(Z=>({k:Z,raw:Z,len:Z.length}));N=d(e),u=rs(N,d(o),d(t),n),A="line"}let h=d=>d.map(w=>w.raw).join(""),M=d=>{let w=[0];for(let Z of d)w.push(w[w.length-1]+Z.len);return w},L=M(N),R=null,F=null,k=null;if(u.conflicts.length){let d=w=>w.split(/(?<=\n)/).map(Z=>({k:Z,raw:Z,len:Z.length}));R=M(A==="line"?d(o):l),F=M(A==="line"?d(t):i),k=M(u.tokens)}return{text:h(u.tokens),conflicts:u.conflicts.map(d=>({bs:L[d.bs],be:L[d.be],ls:R[d.ls],le:R[d.le],rs:F[d.rs],re:F[d.re],ms:k[d.ms],me:k[d.me],base:h(d.base),local:h(d.local),remote:h(d.remote),resolved:h(d.resolved)})),mapLocalOffset:u.mapLocalOffset,granularity:A}}function Wn(e,o,t=4e3){if(e===o)return[];let n=mo(e,o),r=Pn(e,n),a=Pn(o,n),l=qn(r,a,t),i=[0];for(let u of r)i.push(i[i.length-1]+u.len);return l.hunks.map(u=>({bs:i[u.bs],be:i[u.be],text:u.toks.map(A=>A.raw).join("")}))}var $n="\uFFFC";var xr={caret:0},wn=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),us=new Set(["BR","WBR","IMG"]),Ko=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 Bn(e,o={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(o.ignored&&o.ignored(e)||us.has(e.tagName))return!0;if(!wn.has(e.tagName))return!Ko.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 r of e.childNodes)if(!Bn(r,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Tr(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=(r,a)=>{for(let l of r){if(l.nodeType===3){let h=l.nodeValue;if(!h)continue;t.nodes.push({node:l,s:t.text.length,e:t.text.length+h.length}),t.text+=h;for(let M=0;M<h.length;M++)t.stackAt.push(a);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 i=o.via&&o.via(l)||l;i!==l&&(t.via||(t.via=new Map)).set(i,l);let u=l.tagName;if(o.blocks&&o.blocks.has(l)){t.text.length&&t.text[t.text.length-1]!==gt&&(t.stackAt.push(a),t.text+=gt);let h={el:l,tag:u,from:t.text.length,to:-1,depth:a.length,block:!0};t.marks.push(h);let M=a.concat([h]);n(i.childNodes,M),t.stackAt.push(M),t.text+=gt,h.to=t.text.length;continue}let A=wn.has(u)&&Tr(i);if(us.has(u)||!wn.has(u)||o.remoteWins&&o.remoteWins(l)||o.atomize&&o.atomize(l)||A){t.atoms.push({i:t.text.length,el:l,key:A?u+":empty":u,stack:a}),t.stackAt.push(a),t.text+=$n;continue}let N={el:l,tag:u,from:t.text.length,to:-1,depth:a.length};t.marks.push(N),n(i.childNodes,a.concat([N])),N.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&go(t).trim()===""){let r=t.atoms[0];t.placeholder=r.el,t.text=t.text.slice(0,r.i)+t.text.slice(r.i+1),t.stackAt.splice(r.i,1);for(let a of t.nodes)a.s>r.i&&(a.s--,a.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(r=>[r.i,r])),t}function Nr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Ar(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,"&quot;")}"`;return o+">"}function zn(e,o,t){let n="",r=[];for(let a=o;a<t;a++){let l=e.stackAt[a],i=0;for(;i<r.length&&i<l.length&&r[i]===l[i];)i++;for(;r.length>i;)n+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<l.length;){let A=l[r.length];n+=Ar(A.el),r.push(A)}let u=e.atomAt.get(a);n+=u?u.el.outerHTML:e.text[a]===gt?"":Nr(e.text[a])}for(;r.length;)n+=`</${r.pop().tag.toLowerCase()}>`;return n}function vr(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 ds(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 is(e,o=()=>!1){let t=new Map,n=a=>{let l=t.get(a);return l===void 0&&(l="{"+a.map(i=>vr(i,o)).sort().join(",")+"}",t.set(a,l)),l},r="";for(let a=0;a<e.text.length;a++){let l=e.atomAt.get(a);r+=(l?"["+ds(l.el,o)+"]":e.text[a])+n(e.stackAt[a])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function Fn(e,o,t,n=r=>r.key){let r=[],a=e.text,l=0,i=u=>{if(u<=l)return;let A=a.slice(l,u);if(t)for(let N of A.split(/(?<=\n)/))r.push({k:N,raw:N,len:N.length});else for(let N of Pn(A,o))r.push(N)};for(let u of e.atoms)i(u.i),r.push({k:"\0"+n(u),raw:$n,len:1,atom:!0}),l=u.i+1;return i(a.length),r}function go(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 qo=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 ls(e,o,t,n){let r=qo(o),a=qo(t),l=[],i=0,u=0;for(let N of n.hunks){u+=N.bs-i;let h=u+N.toks.length;l.push({bs:r[N.bs],be:r[N.be],ss:a[u],se:a[h],text:e.text.slice(a[u],a[h]),toks:N.toks,lead:!!N.lead}),u=h,i=N.be}let A=new Map;for(let N of n.cosmetic)A.set(N.bi,N.tok.raw);return{hunks:l,respell:A}}function cs(e,o,t){let n=l=>l===gt||/\s/.test(l),r=l=>l.replace(/[\u001E\s]/g,""),a=[];for(let l of e){let i=o.slice(l.bs,l.be),u=t.slice(l.ss,l.se);if(!i.includes(gt)&&!u.includes(gt)||i.includes($n)||u.includes($n)||r(i)!==r(u)){a.push(l);continue}let A=0,N=0;for(;;){let h=A,M=N;for(;h<i.length&&n(i[h]);)h++;for(;M<u.length&&n(u[M]);)M++;let L=A,R=N;for(;L<h&&R<M&&i[L]===u[R];)L++,R++;let F=h,k=M;for(;F>L&&k>R&&i[F-1]===u[k-1];)F--,k--;if(F>L||k>R){let d=u.slice(R,k);a.push({bs:l.bs+L,be:l.bs+F,ss:l.ss+R,se:l.ss+k,text:d,toks:[...d].map(w=>({k:w,raw:w,len:1})),lead:l.lead})}if(h>=i.length)break;A=h+1,N=M+1}}return a}function as(e,o,t){let n=new Int32Array(o+1).fill(-1),r=new Int32Array(t+1).fill(-1),a=0,l=0,i=u=>{for(;a<u;)n[a]=l,r[l]=a,a++,l++};for(let u of e)i(u.bs),a=u.be,l=u.se;return i(o),n[o]=l,r[l]=o,{bTo:n,toB:r}}function fs(e,o){if(e.size!==o.size)return!1;for(let t of e)if(!o.has(t))return!1;return!0}function Wo(e){let{out:o,policy:t="remote",L:n,R:r}=e,a=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,i=e.conflicts||[],u=e.decisions||[],A=i.length,N=e.conflict||(s=>i.push(s)),h={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},M=[],L=!!(n&&n.reverse&&n.map&&r&&r.reverse&&r.map),R={base:null,local:null,remote:null};if(L&&e.moveIn){let s=Ae=>qe=>Ae.some(Te=>Te===qe||Te.nodeType===1&&Te.contains(qe)),g=s(e.local),I=s(e.remote),O=s(e.base),B=new Set,$=Ae=>{if(!wn.has(Ae.tagName))return;let qe=n.map.get(Ae),Te=r.map.get(Ae);(qe&&!g(qe)||Te&&!I(Te))&&B.add(Ae);for(let Le of Ae.children)$(Le)};for(let Ae of e.base)Ae.nodeType===1&&$(Ae);let me=Ae=>qe=>{if(!wn.has(qe.tagName))return!1;let Te=Ae.reverse.get(qe);return!!Te&&(B.has(Te)||!O(Te))};B.size&&(R.base=Ae=>B.has(Ae)),R.local=me(n),R.remote=me(r)}let F={base:new Set,local:new Set,remote:new Set};if(L&&e.moveIn){let s=O=>B=>O.some($=>$===B||$.nodeType===1&&$.contains(B)),g=s(e.local),I=s(e.remote);for(let O of Nn(e.base,{...e,atomize:R.base}).atoms){let B=n.map.get(O.el),$=r.map.get(O.el),me=!!B&&!g(B),Ae=!!$&&!I($);!me&&!Ae||(F.base.add(O.el),B&&!me&&F.local.add(B),$&&!Ae&&F.remote.add($),g(O.el)&&F.local.add(O.el),I(O.el)&&F.remote.add(O.el))}}let k=Nn(e.base,{...e,atomize:R.base,skip:F.base}),d=Nn(e.local,{...e,atomize:R.local,skip:F.local}),w=Nn(e.remote,{...e,atomize:R.remote,skip:F.remote}),Z=new Map(k.atoms.map(s=>[s.el,s])),he={},xe=s=>F[s].size?(he[s]||(he[s]=Nn(e[s],{...e,atomize:R[s]})),he[s]):null,ee=(s,g,I)=>{g.namespaceURI?s.setAttributeNS(g.namespaceURI,g.name,I):s.setAttribute(g.name,I)},oe=(s,g,I,O)=>{if(!g&&(!I||!O)){for(let $ of(I||O).attributes)ee(s,$,$.value);return}let B=new Map;for(let $ of[g,I,O])if($)for(let me of $.attributes)B.set(me.name,me);for(let[$,me]of B){let Ae=g?g.getAttribute($):null,qe=I?I.getAttribute($):Ae,Te=O?O.getAttribute($):Ae,Le;qe===Te?Le=qe:qe===Ae?(Le=Te,u.push({kind:"attr",el:s,name:$,source:"remote"})):Te===Ae?(Le=qe,u.push({kind:"attr",el:s,name:$,source:"local"})):(Le=t==="local"?qe:Te,N({kind:"attr",el:s,name:$,base:Ae,local:qe,remote:Te,resolved:Le},{el:s,sample:me}),u.push({kind:"attr",el:s,name:$,source:"both"})),Le!=null&&ee(s,me,Le)}},re=(s,g,I,O)=>s&&e.mergeAttrs?e.mergeAttrs(s,g,I,O):oe(O,s,g,I),ne=e.mergeElement||((s,g,I)=>{let O=o.createElement(s.tagName);re(s,g,I,O);let B=g||s,$=I||s,me=t==="local"?B.isEqualNode(s)?$:B:$.isEqualNode(s)?B:$;for(let Ae of me.childNodes)O.appendChild(o.importNode(Ae,!0));return a.set(O,{base:s,local:g,remote:I}),O}),K=e.cloneUnit||((s,g)=>{let I=o.importNode(s,!0);return a.set(I,{base:null,local:g==="local"?s:null,remote:g==="remote"?s:null}),I}),D=e.atomKey||(s=>ds(s,()=>!1)),Ne=(s,g)=>{let I=new Map;for(let O of s.atoms)if(e.remoteWins&&e.remoteWins(O.el)&&wn.has(O.el.tagName))I.set(O,"w"+O.el.tagName+"#"+(O.el.id||""));else if(!L)I.set(O,O.key);else if(s===k)I.set(O,"="+D(O.el));else{let B=g.reverse.get(O.el),$=B?Z.get(B):null;$?I.set(O,"="+D($.el)):B?I.set(O,"m"+D(O.el)):I.set(O,"="+D(O.el))}return O=>I.get(O)},ae=Ne(k,null),te=Ne(d,n),V=Ne(w,r),ye=mo(go(k),go(d),go(w)),be=Fn(k,ye,!1,ae),Oe=Fn(d,ye,!1,te),He=Fn(w,ye,!1,V),Ue=be.length>2e4||Oe.length>2e4||He.length>2e4;Ue&&(be=Fn(k,ye,!0,ae),Oe=Fn(d,ye,!0,te),He=Fn(w,ye,!0,V));let ze=Uo(qn(be,Oe),qn(be,He),be),se=ls(d,be,Oe,{hunks:ze.lh,cosmetic:ze.cosL}),at=ls(w,be,He,{hunks:ze.rh,cosmetic:ze.cosR});se.hunks=cs(se.hunks,k.text,d.text),at.hunks=cs(at.hunks,k.text,w.text);let ft=as(se.hunks,k.text.length,d.text.length),le=as(at.hunks,k.text.length,w.text.length),b=k.text.length,H=s=>new Map(s.atoms.map(g=>[g.el,g])),fe=H(d),we=H(w),pe=(s,g,I)=>{let O=new Set;if(!L)return O;for(let B of s.atoms){let $=Z.get(g.reverse.get(B.el));$&&I.bTo[$.i]<0&&O.add($)}return O},Ge=pe(d,n,ft),je=pe(w,r,le),Ze=s=>!Bn(s,{...e,remoteWins:null}),rt=new Set;if(L)for(let s of k.atoms){if(!Ze(s.el))continue;let g=n.map.get(s.el)||null,I=r.map.get(s.el)||null,O=g&&!I?g:I&&!g?I:null;O&&(fe.has(O)||we.has(O))&&!O.isEqualNode(s.el)&&rt.add(s)}let wt=1,bt=(s,g)=>({id:wt++,tag:s,base:null,local:null,remote:null,rank:g}),Tt=new Map,tn=[];for(let s of k.marks){let g=bt(s.tag,s.depth);g.block=!!s.block,g.base=s.el,g.baseMark=s,Tt.set(s.el,g),tn.push(g)}let Fe=(s,g)=>{let I=-1,O=-1;for(let B=s.from;B<s.to;B++){let $=g[B];$>=0&&(I<0&&(I=$),O=$+1)}return I<0?null:[I,O]},Xt=(s,g,I,O)=>{for(let B of s.marks){let $=I?I.reverse.get(B.el):null;$&&I.identical.has($)&&I.pairIdenticalChildren&&I.pairIdenticalChildren($);let me=$?Tt.get($):null;if(me&&me[g]&&(me=null),!me){let Ae=Fe(B,O),qe=0;if(Ae)for(let Te of tn){if(Te.tag!==B.tag||Te[g]||!!Te.block!=!!B.block)continue;let Le=Math.min(Ae[1],Te.baseMark.to)-Math.max(Ae[0],Te.baseMark.from);(Le>qe||Le===qe&&Le>0&&Math.abs(Te.rank-B.depth)<Math.abs(me.rank-B.depth))&&(me=Te,qe=Le)}}me||(me=bt(B.tag,B.depth),me.block=!!B.block,me.new=g),me[g]=B.el,me[g+"Mark"]=B,Tt.set(B.el,me)}};Xt(d,"local",n,ft.toB),Xt(w,"remote",r,le.toB);let Jt=s=>s.merged||s,Dt=s=>{let g=new Set;for(let I of s)I.block||g.add(Tt.get(I.el));return g},It=new Map,Et=s=>{let g=It.get(s);return g||(g=Dt(s),It.set(s,g)),g},sn=(s,g)=>{let I=[],O=null;for(let B=0;B<b;B++){let $=g[B];if($<0){O&&I.push(O),O=null;continue}let me=Et(k.stackAt[B]),Ae=Et(s.stackAt[$]),qe=new Set,Te=new Set;for(let Le of Ae)me.has(Le)||qe.add(Le);for(let Le of me)Ae.has(Le)||Te.add(Le);if(!qe.size&&!Te.size){O&&I.push(O),O=null;continue}if(O&&fs(O.added,qe)&&fs(O.removed,Te)){O.be=B+1;continue}O&&I.push(O),O={bs:B,be:B+1,added:qe,removed:Te}}return O&&I.push(O),I},v=sn(d,ft.bTo),X=sn(w,le.bTo),Q=s=>s.be>s.bs?[s.bs,s.be-1]:[s.bs-1,s.bs],de=(s,g)=>{if(b===0)return null;let[I,O]=Q(s);for(let B of g){if(B.be<=I)continue;if(B.bs>O)break;let $=B.bs<=I&&O<B.be;return $&&s.text===""&&B.bs===s.bs&&B.be===s.be?"straddle":$?B:s.be>s.bs?"straddle":null}return null},ie=s=>s.bs===s.be,ue=(s,g)=>{let I=!1;for(let O=s.bs;O<s.be;O++){let B=k.text[O];if(B===gt)I=!0;else if(!/\s/.test(B))return!1}for(let O=s.ss;O<s.se;O++){let B=g.text[O];if(B===gt)I=!0;else if(!/\s/.test(B))return!1}return I},p=(s,g)=>s.bs<g.be&&g.bs<s.be,y=(s,g)=>s.bs<=g.be&&g.bs<=s.be&&ie(s)!==ie(g),E=(s,g)=>k.text.slice(s.bs,s.be).includes(gt)||g.text.slice(s.ss,s.se).includes(gt),f=s=>{if(ie(s))return!1;let g=s.bs,I=s.be;for(;g>0&&/\s/.test(k.text[g-1]);)g--;for(;I<k.text.length&&/\s/.test(k.text[I]);)I++;return(g===0||k.text[g-1]===gt)&&(I===k.text.length||k.text[I]===gt)},m=(s,g)=>!E(s,g)&&!f(s),C=(s,g)=>p(s,g)||y(s,g)&&!(ue(s,d)&&m(g,w))&&!(ue(g,w)&&m(s,d)),W=(s,g)=>{if(s.bs!==g.bs||s.be!==g.be||s.toks.length!==g.toks.length)return!1;let I=s.ss,O=g.ss;for(let B=0;B<s.toks.length;B++){let $=s.toks[B],me=g.toks[B];if($.k!==me.k||$.atom&&!d.atomAt.get(I).el.isEqualNode(w.atomAt.get(O).el))return!1;I+=$.len,O+=me.len}return!0},j=(s,g,I,O)=>{for(let B of k.atoms){if(B.i<s.bs||B.i>=s.be||O.has(B)||rt.has(B))continue;let $=g.bTo[B.i],me=$>=0?I.atomAt.get($):null;if(me&&!me.el.isEqualNode(B.el))return!0}return!1},z=[],x=se.hunks,S=at.hunks,G=0,ge=0,Me=0,c=0,T=0,P=s=>{s>Me&&(z.push({src:"base",from:Me,to:s,dL:c,dR:T}),Me=s)};for(;G<x.length||ge<S.length;){let s=x[G],g=S[ge],I=!!s&&(!g||s.bs<g.bs||s.bs===g.bs&&s.be<=g.be&&!g.lead);if(s&&g&&s.bs===g.bs&&ie(s)&&ie(g)){let Ct=ue(s,d),to=ue(g,w);Ct!==to&&(I=to)}let O=I?s:g,B=I?g:s,$=!!B&&W(s,g),me=!!B&&(I?!!x[G+1]&&W(x[G+1],g):!!S[ge+1]&&W(s,S[ge+1])),Ae=!!B&&!$&&!me&&(b===0||C(s,g)),qe=Ae,Te=de(O,I?X:v);if(Te==="straddle"&&(qe=!0),!qe&&O.be>O.bs&&(qe=j(O,I?le:ft,I?w:d,I?Ge:je)),!qe&&$){P(O.bs),z.push({src:"both",lfrom:s.ss,rfrom:g.ss,len:O.text.length}),Me=O.be,c+=O.text.length-(O.be-O.bs),T+=O.text.length-(O.be-O.bs),G++,ge++;continue}if(!qe){P(O.bs),z.push({src:I?"local":"remote",from:O.ss,to:O.se,inherit:Te&&Te!=="straddle"?Te:null}),Me=O.be,I?(c+=O.text.length-(O.be-O.bs),G++):(T+=O.text.length-(O.be-O.bs),ge++);continue}let Le=O.bs,ct=O.be,Je=G,st=ge,Bt=Ct=>Ct.bs<ct&&Ct.be>Le||ie(Ct)&&(Ct.bs===Le||Ct.bs===ct);I?Je++:st++,Ae&&(Le=Math.min(Le,B.bs),ct=Math.max(ct,B.be),I?st++:Je++);let vt=!0;for(;vt;){for(vt=!1;Je<x.length&&Bt(x[Je]);)Le=Math.min(Le,x[Je].bs),ct=Math.max(ct,x[Je].be),Je++,vt=!0;for(;st<S.length&&Bt(S[st]);)Le=Math.min(Le,S[st].bs),ct=Math.max(ct,S[st].be),st++,vt=!0}let on=Le+c,Gt=Le+T,dn=ct-Le,gn=ct-Le;for(let Ct=G;Ct<Je;Ct++)dn+=x[Ct].text.length-(x[Ct].be-x[Ct].bs);for(let Ct=ge;Ct<st;Ct++)gn+=S[Ct].text.length-(S[Ct].be-S[Ct].bs);let xn=on+dn,Tn=Gt+gn;P(Le);let qt={kind:"text",node:e.node||null,base:zn(k,Le,ct),local:zn(d,on,xn),remote:zn(w,Gt,Tn),resolved:null,range:null,bs:Le,be:ct,lss:on,lse:xn,rss:Gt,rse:Tn};qt.resolved=t==="local"?qt.local:t==="remote"?qt.remote:qt.local+qt.remote,t!=="remote"&&z.push({src:"local",from:on,to:xn,conflict:qt}),t!=="local"&&z.push({src:"remote",from:Gt,to:Tn,conflict:qt});let ao={site:"inline",fb:k,fl:d,fr:w,scope:e.scope||null,synthetic:!!e.synthetic,full:xe,merged:h};M.push(ao),N(qt,ao),Me=ct,c+=dn-(ct-Le),T+=gn-(ct-Le),G=Je,ge=st}P(b);let U=k.text,_=[];if(se.respell.size||at.respell.size){let s=qo(be),g=[];for(let I=0;I<be.length;I++){let O=be[I].raw,B=se.respell.get(I)??O,$=at.respell.get(I)??O;(B!==O||$!==O)&&_.push([s[I],B!==O&&$!==O?"both":B!==O?"local":"remote"]),g.push(B===$?B:B===O?$:$===O||t==="local"?B:$)}U=g.join("")}let q="",Y=[],ce=[],Se=[],Ee=[];for(let s of z){let g=q.length;if(s.src==="base"){for(let I=s.from;I<s.to;I++)Y.push(I),ce.push(I+s.dL),Se.push(I+s.dR),Ee.push(s);q+=U.slice(s.from,s.to)}else if(s.src==="both"){for(let I=0;I<s.len;I++)Y.push(-1),ce.push(s.lfrom+I),Se.push(s.rfrom+I),Ee.push(s);q+=d.text.slice(s.lfrom,s.lfrom+s.len)}else{let I=s.src==="local"?d:w;for(let O=s.from;O<s.to;O++)Y.push(-1),ce.push(s.src==="local"?O:-1),Se.push(s.src==="remote"?O:-1),Ee.push(s);q+=I.text.slice(s.from,s.to)}s.ms=g,s.me=q.length,s.conflict&&(s.conflict.range||(s.conflict.range=[g,g]),s.conflict.range[1]=q.length)}let Ie=q.length,et=new Int32Array(b+1).fill(-1),Be=new Int32Array(d.text.length+1).fill(-1),St=new Int32Array(w.text.length+1).fill(-1);for(let s=0;s<Ie;s++)Y[s]>=0&&(et[Y[s]]=s),ce[s]>=0&&(Be[ce[s]]=s),Se[s]>=0&&(St[Se[s]]=s);let Ve=(s,g)=>{let I=-1,O=-1;for(let B=s.from;B<s.to;B++){let $=g[B];$>=0&&(I<0&&(I=$),O=$+1)}return I<0?null:[I,O]},pt=[],it=[];for(let s of new Set(Tt.values()))s.new==="local"?pt.push(s):s.new==="remote"&&it.push(s);let Ft=(s,g)=>{s.remote=g.remote,s.remoteMark=g.remoteMark,s.new="both",g.merged=s,Tt.set(g.remote,s)};if(pt.length&&it.length){let s=e.idOf;for(let g of pt){let I=s?s.local(g.local):null;if(!I)continue;let O=it.find(B=>!B.merged&&B.tag===g.tag&&!!B.block==!!g.block&&s.remote(B.remote)===I);O&&Ft(g,O)}for(let g of pt){if(g.remote)continue;let I=Ve(g.localMark,Be);if(I)for(let O of it){if(O.merged||O.tag!==g.tag||!!O.block!=!!g.block)continue;let B=Ve(O.remoteMark,St);if(B&&Math.min(I[1],B[1])-Math.max(I[0],B[0])>0){Ft(g,O);break}}}}It.clear();let Rt=s=>{for(let g of s)if(g.block)return Jt(Tt.get(g.el));return null},Kt=k.marks.some(s=>s.block)||d.marks.some(s=>s.block)||w.marks.some(s=>s.block),Lt=new Array(Ie).fill(null),ut=new Set;if(Kt){let s=(Te,Le,ct)=>{let Je=new Set([Te,Le,ct]);Je.delete(null);let st=[];for(let vt of Je){let on=vt===Te,Gt=vt===Le,dn=vt===ct;(Gt===dn?Gt:Gt===on?dn:Gt)&&st.push(vt)}if(st.length<=1)return st[0]||null;let Bt=t==="local"?Le:ct;return st.includes(Bt)?Bt:st[0]},g=(Te,Le)=>Le>=0?Rt(Te.stackAt[Le]):null,I=new Map;for(let Te=0;Te<Ie;Te++){if(q[Te]!==gt)continue;let Le=Y[Te]>=0?g(k,Y[Te]):null,ct=g(d,ce[Te]),Je=g(w,Se[Te]);I.set(Te,[Le,Y[Te]>=0?s(Le,ct,Je):ct||Je])}let O=new Set([...I.values()].map(Te=>Te[1])),B=Te=>Te!==gt&&Te!==$n&&!/\s/.test(Te),$=(Te,Le)=>{let ct=Te;for(;ct<Le&&!B(q[ct]);)ct++;return ct<Le&&Y[ct]>=0?g(k,Y[ct]):null},me=new Map,Ae=0;for(let Te=0;Te<Ie;Te++){if(q[Te]!==gt)continue;let[Le,ct]=I.get(Te),Je=$(Ae,Te),st=ct,Bt=me.get(st)===st&&Je===st;st&&me.has(st)&&!Bt&&Le&&!me.has(Le)&&!O.has(Le)&&(st=Le),st&&!me.has(st)&&me.set(st,Je);for(let vt=Ae;vt<=Te;vt++)Lt[vt]=st;Ae=Te+1}let qe=Te=>{for(let Le=0;Le<Te.text.length;Le++)if(B(Te.text[Le])&&!g(Te,Le))return!0;return!1};if(!qe(k)&&!qe(d)&&!qe(w)){let Te=[],Le=0;for(let Je=0;Je<Ie;Je++)(q[Je]===gt||Je===Ie-1)&&(Te.push([Le,Je]),Le=Je+1);let ct=new Set(Lt);for(let Je=0;Je<Te.length;Je++){let[st,Bt]=Te[Je];if(Lt[Bt])continue;let vt=st;for(;vt<=Bt&&!B(q[vt]);)vt++;if(vt>Bt)continue;let on=g(k,Y[vt]),Gt=g(d,ce[vt]),dn=g(w,Se[vt]),gn=s(on,Gt,dn)||Gt||dn||on;if(gn&&!ct.has(gn)){ct.add(gn);for(let qt=st;qt<=Bt;qt++)Lt[qt]=gn;continue}let xn=Je>0&&Lt[Te[Je-1][1]],Tn=Je+1<Te.length&&Lt[Te[Je+1][1]];if(xn)ut.add(Te[Je-1][1]);else if(Tn&&q[Bt]===gt)ut.add(Bt);else continue;for(let qt=st;qt<=Bt;qt++)Lt[qt]=xn||Tn}}}let At=new Map,Nt=s=>{let g=At.get(s);if(g)return g;g=[1/0,-1/0];for(let[I,O]of[[s.baseMark,et],[s.localMark,Be],[s.remoteMark,St]]){let B=I&&Ve(I,O);B&&(g[0]=Math.min(g[0],B[0]),g[1]=Math.max(g[1],B[1]))}return At.set(s,g),g},jt=(s,g,I)=>{let O=-1,B=-1;for(let $=0;$<s.length;$++){let me=Tt.get(s[$].el);me===g&&(O=$),me===I&&(B=$)}return O>=0&&B>=0?O-B:0},Qt=(s,g)=>[...s].sort((I,O)=>{for(let me of g){let Ae=jt(me,I,O);if(Ae)return Ae}let B=Nt(I),$=Nt(O);return B[0]-$[0]||$[1]-B[1]||I.rank-O.rank||I.id-O.id}),fn=new Map,An=new Map,vn=s=>{let g=Y[s],I=ce[s],O=Se[s],B=Ee[s];if(g>=0){let Je=k.stackAt[g],st=d.stackAt[I],Bt=w.stackAt[O],vt=fn.get(Je);vt||fn.set(Je,vt=new Map);let on=vt.get(st);on||vt.set(st,on=new Map);let Gt=on.get(Bt);if(Gt)return Gt;let dn=Et(Je),gn=Et(st),xn=Et(Bt),Tn=new Set;for(let qt of new Set([...dn,...gn,...xn])){let ao=dn.has(qt),Ct=gn.has(qt),to=xn.has(qt);(Ct===to?Ct:Ct===ao?to:Ct)&&Tn.add(qt)}return Gt=Qt(Tn,[st,Bt,Je]),on.set(Bt,Gt),Gt}if(B.src==="both"){let Je=d.stackAt[I],st=w.stackAt[O];return Qt(new Set([...Et(Je),...Et(st)]),[Je,st])}let me=(B.src==="local"?d:w).stackAt[B.src==="local"?I:O];if(!B.inherit)return Qt(Et(me),[me]);let Ae=An.get(B);Ae||An.set(B,Ae=new Map);let qe=Ae.get(me);if(qe)return qe;let Te=new Set(Et(me));for(let Je of B.inherit.added)Te.add(Jt(Je));for(let Je of B.inherit.removed)Te.delete(Jt(Je));let Le=B.src==="local"?w:d,ct=(B.src==="local"?le.bTo:ft.bTo)[B.inherit.bs];return qe=Qt(Te,[me,Le.stackAt[ct]]),Ae.set(me,qe),qe},kn=new Int32Array(d.text.length+1);kn[d.text.length]=Ie;for(let s=d.text.length-1;s>=0;s--)kn[s]=Be[s]>=0?Be[s]:kn[s+1];xr.caret+=d.text.length;let rn=s=>s<=0?0:(s>d.text.length&&(s=d.text.length),Be[s-1]>=0?Be[s-1]+1:kn[s]),zt=[],J=[],Re=null,ve=[],Ye="",lt=-1,De=s=>{Re?Re.appendChild(s):zt.push(s)},Ke=s=>{if(!Ye)return;let g=o.createTextNode(Ye);De(g),J.push({node:g,ms:lt,me:s,local:[],u:ve.length?ve[ve.length-1].u:null}),Ye=""},tt=new Set,_e=new Map,ot=new Set,Zt=s=>{let g=o.createElement(s.tag);if(s.block&&Vt.add(g),!_e.has(s)){_e.set(s,g),re(s.base,s.local,s.remote,g),a.set(g,{base:s.base,local:s.local,remote:s.remote});let O=(me,Ae)=>L&&s[Ae]&&me.reverse.get(s[Ae])?Ae:null,B=!s.base&&(O(n,"local")||O(r,"remote"));if(B){let me=B==="local"?n.reverse.get(s.local):r.reverse.get(s.remote),Ae=a.get(g);Ae.local=Ae.local||n.map.get(me)||null,Ae.remote=Ae.remote||r.map.get(me)||null,u.push({kind:"move",el:g,source:B})}else s.base||u.push({kind:"insert",el:g,source:s.local&&s.remote?"both":s.local?"local":"remote"});let $=a.get(g);$.local&&(ot.has($.local)?$.local=null:ot.add($.local))}else{let O=_e.get(s);for(let B of O.attributes)B.name!=="id"&&B.name!=="data-id"&&ee(g,B,B.value);a.set(g,{base:null,local:null,remote:null})}De(g),ve.push({u:s,el:g}),Re=g},En=new Set,un=new Map;for(let s of d.pins){let g=rn(s.i);un.has(g)||un.set(g,[]),un.get(g).push(s)}let ln=s=>{let g=un.get(s);if(g){Ke(s);for(let I of g){let O=I.el.namespaceURI&&I.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(I.el.namespaceURI,I.el.tagName):o.createElement(I.el.tagName);a.set(O,{base:null,local:I.el,remote:null,pinned:!0}),En.add(O),De(O)}}},Rn=k.atoms.length||d.atoms.length||w.atoms.length,Xe=s=>{if(!Rn)return null;let g=Y[s]>=0?k.atomAt.get(Y[s]):null,I=ce[s]>=0?d.atomAt.get(ce[s]):null,O=Se[s]>=0?w.atomAt.get(Se[s]):null;return g||I||O?{ab:g,al:I,ar:O}:null},dt=(s,g,I,O)=>{if(!s||!L)return null;let B=Z.get(g.reverse.get(s.el))||null;return!B||B===O||(O?B.el.isEqualNode(O.el):I.bTo[B.i]>=0)?null:B},ke=(s,g)=>{if(!s||!L||!e.moveIn)return null;let I=g.reverse.get(s.el);return I&&!Z.has(I)?I:null},Ce=(s,g)=>{let I=new Map;for(let O of s.atoms)I.set(g(O),(I.get(g(O))||0)+1);return I},We=Ce(k,ae),nt=Ce(d,te),$e=Ce(w,V),yt=s=>{let g=ae(s);return We.get(g)===1&&(nt.get(g)||0)<=1&&($e.get(g)||0)<=1},kt=new Map,Pt=new Set,Wt=new Set,nn=new Set;for(let s=0;s<Ie;s++){let g=Xe(s);if(!g)continue;let{ab:I,al:O,ar:B}=g,$=dt(B,r,le,I),me=dt(O,n,ft,I),Ae=I,qe=null;if($?(Ae=$,qe="remote"):me&&(Ae=me,qe="local"),Ae){Pt.has(Ae)?kt.set(s,{dup:Ae.el}):(Pt.add(Ae),kt.set(s,{bk:Ae,from:qe,al:O,ar:B}));continue}let Te=ke(B,r),Le=ke(O,n),ct=Te||Le;if(ct){Wt.has(ct)?kt.set(s,{dup:ct}):(Wt.add(ct),kt.set(s,{moveIn:ct,side:Te?"remote":"local",sideEl:Te?B.el:O.el}));continue}let Je=(Bt,vt)=>Bt&&L&&Z.get(vt.reverse.get(Bt.el))||null,st=Je(B,r)||Je(O,n);if(st&&(nn.add(st),Ee[s].conflict&&yt(st))){if(Pt.has(st)){kt.set(s,{dup:st.el});continue}Pt.add(st)}kt.set(s,{al:O,ar:B})}let Ot=new Map,Sn=(s,g)=>{if(s[g]>=0)return s[g];for(let I=g-1;I>=0;I--)if(s[I]>=0)return s[I]+1;return 0};if(L)for(let s of k.atoms){if(Pt.has(s)||nn.has(s))continue;let g=n.map.get(s.el)||null,I=r.map.get(s.el)||null,O=g&&fe.get(g),B=I&&we.get(I);if(g&&!O||I&&!B)continue;let $=!(O&&B)&&rt.has(s);if(!$&&!(O&&B&&yt(s)))continue;let me=t==="local"?[[O,Be],[B,St]]:[[B,St],[O,Be]],[Ae,qe]=me.find(([Le])=>Le),Te=Sn(qe,Ae.i);Ot.has(Te)||Ot.set(Te,[]),Ot.get(Te).push({a:s,lt:g,rt:I,edited:$}),Pt.add(s)}if(L&&e.moveIn){let s=[[d,n,Be,"local"],[w,r,St,"remote"]];t!=="local"&&s.reverse();for(let[g,I,O,B]of s)for(let $ of g.atoms){let me=ke($,I);if(!me||Wt.has(me))continue;Wt.add(me);let Ae=Sn(O,$.i);Ot.has(Ae)||Ot.set(Ae,[]),Ot.get(Ae).push({move:me,side:B,sideEl:$.el})}}let Ut=s=>{let g=Ot.get(s);if(g){if(Ke(s),g.some(I=>Ze(I.move?I.sideEl:I.a.el)))for(;ve.length;)ve.pop(),Re=ve.length?ve[ve.length-1].el:null;for(let{a:I,lt:O,rt:B,edited:$,move:me,side:Ae,sideEl:qe}of g){if(me){let Le=e.moveIn(me,Ae,qe);Le&&De(Le);continue}tt.add(I);let Te=ne(I.el,O,B);$&&(N({kind:"structure",el:Te,detail:"edit-beats-delete",base:I.el},{subject:I.el,deleted:O?"remote":"local"}),u.push({kind:"insert",el:Te,source:O?"local":"remote"})),De(Te)}}},Vt=new Set,cn=i.length>A;for(let s=0;s<Ie;s++){let g=Xe(s),O=!!g&&Ze((g.ab||g.al||g.ar).el)?[]:Lt[s]?[Lt[s],...vn(s)]:vn(s),B=0;for(;B<ve.length&&B<O.length&&ve[B].u===O[B];)B++;if(B<ve.length)for(Ke(s);ve.length>B;)ve.pop(),Re=ve.length?ve[ve.length-1].el:null;if(ln(s),Ut(s),O.length>ve.length)for(Ke(s);ve.length<O.length;)Zt(O[ve.length]);if(q[s]===gt){if(ut.has(s))continue;Ke(s);let $=ve.length;for(;$>0&&!ve[$-1].u.block;)$--;if($>0)for(cn&&h.breakOut.set(s,ve[$-1].el);ve.length>=$;)ve.pop(),Re=ve.length?ve[ve.length-1].el:null;continue}if(g){Ke(s);let $=kt.get(s),me;if($.dup){N({kind:"structure",el:null,detail:"both-moved",base:$.dup},{subject:$.dup});continue}if($.moveIn){if(me=e.moveIn($.moveIn,$.side,$.sideEl),!me)continue}else if($.bk){let Ae=$.bk;if(tt.add(Ae),Ae===g.ab)me=ne(Ae.el,$.al.el,$.ar.el);else{let qe=n.map.get(Ae.el)||null,Te=r.map.get(Ae.el)||null;me=ne(Ae.el,qe,Te),(!qe||!Te)&&N({kind:"structure",el:null,detail:"move-beats-delete",base:Ae.el},{subject:Ae.el,deleted:qe?"remote":"local"}),u.push({kind:"move",el:me,source:$.from})}}else $.al?(me=K($.al.el,"local"),$.ar&&(a.get(me).remote=$.ar.el),u.push({kind:"insert",el:me,source:$.ar?"both":"local"})):(me=K($.ar.el,"remote"),u.push({kind:"insert",el:me,source:"remote"}));cn&&h.atomOut.set(s,me),De(me);continue}Ye||(lt=s),Ye+=q[s]}if(Ke(Ie),(un.has(Ie)||Ot.has(Ie))&&(ve.length=0,Re=null,ln(Ie),Ut(Ie)),Ie===0&&(d.placeholder||w.placeholder||k.placeholder)){let s=o.createElement("br");a.set(s,{base:k.placeholder,local:d.placeholder,remote:w.placeholder}),zt.push(s)}let pn=0,lo=s=>{for(;pn>0&&J[pn-1].me>=s;)pn--;for(;pn<J.length&&J[pn].me<s;)pn++;let g=J[pn];if(!g)return J[J.length-1]||null;let I=J[pn+1];return g.me===s&&I&&I.ms===s?I:g},Un=new Map,eo={},Pe=(s,g,I)=>{let O=lo(s)||(I?eo:null);if(!O)return;let B=Un.get(O)||{l:!1,r:!1};g!=="remote"&&(B.l=!0),g!=="local"&&(B.r=!0),Un.set(O,B)},ht=s=>{if(s.conflict)return!0;let g=s.src==="local"?d.text:s.src==="remote"?w.text:"";for(let I=s.from;I<s.to;I++)if(g[I]!==$n&&g[I]!==gt)return!0;return!1};for(let s of z)s.src!=="base"&&Pe(s.ms,s.conflict?"both":s.src,ht(s));for(let[s,g]of _)et[s]>=0&&Pe(et[s],g);for(let s of J.length?J:[eo]){let g=Un.get(s);g&&u.push({kind:"text",node:s.node||null,source:g.l&&g.r?"both":g.l?"local":"remote"})}for(let s of tn){if(_e.has(s))continue;let g=!s.local&&!(L&&n.map.get(s.base)),I=!s.remote&&!(L&&r.map.get(s.base));!g&&!I||u.push({kind:"remove",source:g&&I?"both":g?"local":"remote",base:s.base})}let Mt=(s,g,I)=>{if(g<=s)return!1;for(let O=s;O<g;O++)if(I[O]>=0)return!1;return!0};for(let s of tn)for(let g of["local","remote"]){let I=s[g+"Mark"],O=s.baseMark;if(!I)continue;let B=g==="local"?ft:le;if(!Mt(O.from,O.to,B.bTo)||!Mt(I.from,I.to,B.toB))continue;let $=(g==="local"?x:S).find(me=>me.ss<=I.from&&I.from<me.se);$&&($.be<=O.from||$.bs>=O.to)&&u.push({kind:"move",el:_e.get(s)||null,source:g})}let xt=s=>{let g=Tt.get(s.node.parentNode);return g?Jt(g):null};for(let s of d.nodes){let g=-1;for(let O=s.s;O<s.e;O++)if(Be[O]>=0){g=Be[O];break}let I;if(g>=0)I=lo(g);else{let O=rn(s.s),B=xt(s);I=J.find($=>$.u===B&&$.me>=O)||J.filter($=>$.u===B).pop()}I&&I.local.push(s)}let mt=new Map,mn=J[J.length-1]||null,_t=0;for(let s of d.nodes){let g=null;for(let I=s.s;I<=s.e;I++){let O=rn(I);for(;_t>0&&J[_t-1].me>=O;)_t--;for(;_t<J.length&&J[_t].me<O;)_t++;let B=me=>me&&O>=me.ms&&O<=me.me&&(O<me.me||I===s.e||me===g),$=B(J[_t])?J[_t]:B(J[_t+1])?J[_t+1]:J[_t]||mn;if(!$)break;if(g===$){let me=mt.get($);me[me.length-1].to=I-s.s;continue}g=$,mt.has($)||mt.set($,[]),mt.get($).push({node:s.node,from:I-s.s,to:I-s.s,flatStart:s.s})}}for(let s of J){let g=s.local,I=!1;for(let me of g)for(let Ae=me.s;Ae<me.e&&!I;Ae++)(Be[Ae]<s.ms||Be[Ae]>=s.me)&&(I=!0);a.set(s.node,{base:null,local:g.map(me=>me.node),remote:null,caret:mt.get(s)||[],partial:I});let O=s.ms,B=s.me-s.ms,$=me=>{let Ae=0,qe=-1;for(let Te of g){let Le=Te.e-Te.s;if(me<=Ae+Le){qe=Te.s+(me-Ae);break}Ae+=Le}return qe<0&&(qe=g.length?g[g.length-1].e:0),Math.max(0,Math.min(rn(qe)-O,B))};$.flat=me=>Math.max(0,Math.min(rn(me)-O,B)),l.set(s.node,$)}function On(){if(!d.text.includes(gt))return[{flatLocal:d.text,localNodes:d.nodes,textNodes:J,lToM:Be,mapLocal:rn}];let s=[],g=0,I=0;for(let O=0;O<=d.text.length;O++){if(O<d.text.length&&d.text[O]!==gt)continue;let B=g,$=O;if($>B){let me=[];for(;I<d.nodes.length&&d.nodes[I].e<=B;)I++;for(let Ae=I;Ae<d.nodes.length&&d.nodes[Ae].s<$;Ae++){let qe=d.nodes[Ae],Te=Math.max(qe.s,B),Le=Math.min(qe.e,$);Te<Le&&me.push({node:qe.node,s:Te-B,e:Le-B})}s.push({flatLocal:d.text.slice(B,$),localNodes:me,textNodes:J,lToM:Be.subarray?Be.subarray(B,$+1):Be.slice(B,$+1),mapLocal:Ae=>rn(B+Math.max(0,Math.min(Ae,$-B)))})}g=O+1}return s}let yn={...e,blocks:Vt,ignored:s=>En.has(s)||(e.ignored?e.ignored(s):!1)},$t=e.ignoreAttribute||(()=>!1),co=is(Nn(zt,yn),$t)!==is(w,$t);if(M.length){let s=g=>{let I=a.get(g);return I&&I.unchanged?I.remote:null};h.text=q,h.textNodes=J,h.out=Nn(zt,{...yn,via:s})}return{nodes:zt,text:q,textNodes:J,localDiverged:co,mapLocal:rn,conflicts:i.slice(A),granularity:Ue?"line":"word",segments:On(),localHunks:x,remoteHunks:S,lToM:Be}}var Sr="http://www.w3.org/1999/xhtml";function Or(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 en(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Sr}function Mr(e){let o=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return o==="application/json"||o.endsWith("+json")}function bo(e,o){let t=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let r=t;try{let a=new URL(t,o);r=a.origin+a.pathname+a.search}catch{}return"script|src|"+n+"|"+r}return"script|inline|"+n+"|"+Or(e.textContent.trim())}var Ir={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function Gn(e,o=[],t=!1){if(!en(e)||e.hasAttribute("src"))return null;let n=[Ir,...o];for(let r=0;r<n.length;r++){let a=n[r];if(!a.match(e))continue;if(!Mr(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=a.identity(e);return l==null||l===""?null:{key:r+":"+l,raw:l,recognizer:a}}return null}function hs(e,o,t){let n=new Set,r=a=>{en(a)&&!o(a)&&n.add(bo(a,t))};r(e);for(let a of e.querySelectorAll("script"))r(a);return n}function no(e,o){let t=o.createElement("div");t.innerHTML="<script><\/script>";let n=t.firstChild;for(let r of e.attributes)n.setAttribute(r.name,r.value);return n.textContent=e.textContent,n}function ps(e,o,t){let n=[],r=[],a=new Map,l=t.trackRecovery?new Set:null,i=Array.from(e.querySelectorAll("script"));en(e)&&i.unshift(e);for(let u of i){if(!en(u)||t.ignored(u)||t.skip.has(u)||o.has(bo(u,t.baseURI)))continue;let A=u.ownerDocument.createElement("script");for(let N of u.attributes)A.setAttribute(N.name,N.value);if(A.textContent=u.textContent,t.beforeNodeAdded(A)===!1){l?.add(u);continue}A.hasAttribute("src")&&r.push(new Promise(N=>{A.addEventListener("load",()=>N()),A.addEventListener("error",()=>N())})),u.replaceWith(A),a.set(u,A),t.afterNodeAdded(A),n.push(A)}return{executed:n,loads:r,swapped:a,vetoed:l}}function Lr(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 Cr(e,o){try{let t=new URL(e,o);return t.origin+t.pathname+t.search}catch{return e}}function ms(e,o){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return bo(e,o);if(t==="LINK"){let n=e.getAttribute("href");return n?"link|"+(e.getAttribute("rel")||"")+"|"+Cr(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|"+Lr(e.textContent):e.outerHTML}function Fo(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
+ `;)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 gs(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(o,t)=>t.length%2===0?t+'\\"':o)}var Er=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Rr=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ko(e){try{return JSON.parse(e)}catch{return JSON.parse(Pr(e))}}function Pr(e){let o="",t=0,n=(r,a)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${a}`)};for(;t<e.length&&(t=Fo(e,t),!(t>=e.length));){let r=e[t];if("{}[]:".includes(r)){o+=r,t++;continue}if(r===","){let i=Fo(e,t+1);if(e[i]==="}"||e[i]==="]"){t++;continue}o+=r,t++;continue}if(r==='"'||r==="'"){let i=t+1;for(;i<e.length&&e[i]!==r;)e[i]==="\\"&&i++,i++;i>=e.length&&n("unterminated string",t);let u=e.slice(t+1,i);r==="'"&&(u=gs(u)),o+='"'+u+'"',t=i+1;continue}let a=t;for(;a<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[a]);)a++;a===t&&n("unexpected character "+JSON.stringify(r),t);let l=e.slice(t,a);if(l==="true"||l==="false"||l==="null"||Er.test(l)){o+=l,t=a;continue}if(Rr.test(l)){if(e[Fo(e,a)]===":"){o+='"'+l+'"',t=a;continue}n("unquoted value "+JSON.stringify(l),t)}n("invalid token "+JSON.stringify(l),t)}return o}function bs(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(r){let a=[],l=0;for(;l<r.length;){let i=r[l];if(/\s/.test(i)){l++;continue}if("{}".includes(i)){a.push({type:i,value:i}),l++;continue}if(i==="["){let h=!1,M=l+1;for(;M<r.length&&/\s/.test(r[M]);)M++;if(M<r.length&&/[a-zA-Z_]/.test(r[M])&&(h=!0),!h){a.push({type:i,value:i}),l++;continue}}if(i==="]"){a.push({type:i,value:i}),l++;continue}if(i===":"){a.push({type:o.COLON,value:i}),l++;continue}if(i===","){a.push({type:o.COMMA,value:i}),l++;continue}if(i==='"'||i==="'"){let h=i,M=l+1;for(;M<r.length&&r[M]!==h;)r[M]==="\\"&&M++,M++;a.push({type:o.STRING,value:r.substring(l+1,M),quoted:!0,sourceQuote:h}),l=M+1;continue}let u=l,A;for(;u<r.length&&!/[{},]/.test(r[u]);)if(r[u]===":"){let h=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],M=!1;for(let L of h){let R=L.substring(1);if(r.substring(u+1,u+1+R.length)===R){M=!0,u+=R.length;break}}if(!M)break}else if(r[u]==="["){for(u++;u<r.length&&r[u]!=="]";){if(r[u]==='"'||r[u]==="'"){let h=r[u];for(u++;u<r.length&&r[u]!==h;)r[u]==="\\"&&u++,u++}u++}u<r.length&&r[u]==="]"&&u++}else u++;A=r.substring(l,u);let N=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(A)?N=o.NUMBER:A==="true"||A==="false"||A==="null"?N=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(A)&&(N=o.SELECTOR),a.push({type:N,value:A,quoted:!1}),l=u}return a}function n(r){let a="";for(let l=0;l<r.length;l++){let i=r[l];if("{}".includes(i.type)||"[]".includes(i.type)){a+=i.value;continue}if(i.type===o.COLON){a+=i.value;continue}if(i.type===o.COMMA){let u=r[l+1];if(u&&(u.type==="}"||u.type==="]"))continue;a+=i.value;continue}if(i.type===o.STRING){let u=i.value;i.sourceQuote==="'"&&(u=gs(u)),a+=`"${u}"`;continue}if(i.type===o.NUMBER||i.type===o.BOOLEAN){a+=i.value;continue}a+=`"${i.value}"`}return a}try{let r=t(e),a=n(r);return JSON.parse(a)}catch(r){throw new Error("Invalid extraction rules syntax: "+r.message)}}var Ht=Symbol("hyper-morph-json-merge:missing"),ks=["id","_id","uuid","key","slug","code","name"];function Yn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function oo(e,o){return Object.prototype.hasOwnProperty.call(e,o)}function Br(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Ln(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(!Ln(e[t],o[t]))return!1;return!0}if(Yn(e)&&Yn(o)){let t=Object.keys(e);if(t.length!==Object.keys(o).length)return!1;for(let n of t)if(!oo(o,n)||!Ln(e[n],o[n]))return!1;return!0}return!1}function ys(e,o,t,n){return Ln(o,t)?o:Ln(o,e)?t:Ln(t,e)?o:Yn(o)&&Yn(t)?Hr(Yn(e)?e:{},o,t,n):Array.isArray(o)&&Array.isArray(t)?Vr(Array.isArray(e)?e:[],o,t,n):t}function ws(e,o,t,n){return o===Ht&&t===Ht?Ht:o===Ht?e===Ht?t:Ln(t,e)?Ht:t:t===Ht?e===Ht?o:Ht:ys(e,o,t,n)}function Hr(e,o,t,n){let r={},a=new Set([...Object.keys(e),...Object.keys(o),...Object.keys(t)]);for(let l of a){let i=ws(oo(e,l)?e[l]:Ht,oo(o,l)?o[l]:Ht,oo(t,l)?t[l]:Ht,n);i!==Ht&&Br(r,l,i)}return r}function jr(e){return e===null||typeof e!="object"}function yo(e){return typeof e+":"+String(e)}function Dr(e,o){for(let t of o){let n=new Set;for(let r of t){if(!oo(r,e))return!1;let a=r[e];if(typeof a!="string"&&typeof a!="number")return!1;let l=yo(a);if(n.has(l))return!1;n.add(l)}}return!0}function Ur(e,o,t,n){let r=[e,o,t],a=!0;for(let l of r)for(let i of l)Yn(i)||(a=!1);if(a){for(let l of n.keyCandidates)if(Dr(l,r))return{kind:"keyed",field:l};return null}for(let l of r){let i=new Set;for(let u of l){if(!jr(u))return null;let A=yo(u);if(i.has(A))return null;i.add(A)}}return{kind:"self"}}function Vr(e,o,t,n){let r=Ur(e,o,t,n);if(!r)return t;let a=r.kind==="self"?yo:L=>yo(L[r.field]),l=L=>{let R=new Map;for(let F of L)R.set(a(F),F);return R},i=l(e),u=l(o),A=l(t),N=new Map,h=new Set([...i.keys(),...u.keys(),...A.keys()]);for(let L of h){let R=ws(i.has(L)?i.get(L):Ht,u.has(L)?u.get(L):Ht,A.has(L)?A.get(L):Ht,n);R!==Ht&&N.set(L,R)}let M=[];for(let L of t){let R=a(L);N.has(R)&&M.push(R)}for(let L=0;L<o.length;L++){let R=a(o[L]);if(!N.has(R)||M.includes(R))continue;let F=0;for(let k=L-1;k>=0;k--){let d=M.indexOf(a(o[k]));if(d!==-1){F=d+1;break}}M.splice(F,0,R)}return M.map(L=>N.get(L))}function zo(e,o,t,n={}){let r=n.keyCandidates?[...n.keyCandidates,...ks]:ks;return ys(e===void 0?Ht:e,o,t,{keyCandidates:r})}function wo(e,o,t,n={}){let r=n.parse||ko,a=[],l=(h,M)=>{if(typeof h!="string")return Ht;try{return r(h)}catch(L){return a.push(`${M} side is not valid JSON (${L.message})`),Ht}},i=l(o,"local"),u=l(t,"remote");if(i===Ht)return{text:t,warnings:a};if(u===Ht)return{text:o,warnings:a};let A=l(e,"base"),N=zo(A===Ht?void 0:A,i,u,n);return Ln(N,u)?{text:t,warnings:a}:Ln(N,i)?{text:o,warnings:a}:{text:JSON.stringify(N,null,2),warnings:a}}var xs=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function jn(e){if(!e)return!1;let{startContainer:o,startOffset:t,endContainer:n,endOffset:r}=e;if(!o||!n||!Number.isInteger(t)||!Number.isInteger(r)||t<0||r<0||t>xs(o)||r>xs(n)||o.getRootNode()!==n.getRootNode())return!1;let a=o.ownerDocument.createRange();return a.setStart(o,t),a.setEnd(n,r),a.startContainer===o&&a.startOffset===t}function Cn(e,o,t={}){if(!jn(e))return null;let{startContainer:n,startOffset:r,endContainer:a,endOffset:l}=e;if(n===a&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(r,l);if(n===a&&r===l)return"";let i=new Set;for(let k=n;k;k=k.parentNode)i.add(k);let u=a;for(;!i.has(u);)u=u.parentNode;let A=(k,d)=>{let w=u.ownerDocument.createRange(),Z=u.ownerDocument.createRange();return w.setStart(k[0],k[1]),w.collapse(!0),Z.setStart(d[0],d[1]),Z.collapse(!0),w.compareBoundaryPoints(0,Z)},N=(k,d=!1)=>[k.parentNode,Array.prototype.indexOf.call(k.parentNode.childNodes,k)+Number(d)],h=[],M;if(o==="plain"){M="";let k=d=>{if(d.nodeType===3||d.nodeType===8){let w=M.length;M+=d.nodeValue,h.push({s:w,e:M.length,a:[d,0],b:[d,d.nodeValue.length],node:d})}else for(let w of d.childNodes)k(w)};k(u)}else{let k=t.blocks;if(!k){k=new Set;let w=Z=>{Z!==u&&Z.nodeType===1&&Ko.has(Z.tagName)&&k.add(Z);for(let he of Z.childNodes)w(he)};w(u)}let d=Nn(Array.from(u.childNodes),{blocks:k,atomize:w=>!!t.atoms?.has(w),ignored:t.ignored});M=d.text;for(let w of d.nodes)h.push({s:w.s,e:w.e,a:[w.node,0],b:[w.node,w.e-w.s],node:w.node});for(let w of d.atoms)h.push({s:w.i,e:w.i+1,a:N(w.el),b:N(w.el,!0)});for(let w=0;w<d.text.length;w++){if(d.text[w]!==gt)continue;let Z=d.marks.find(xe=>xe.block&&xe.to===w+1),he=d.marks.find(xe=>xe.block&&xe.from===w+1);if(Z)h.push({s:w,e:w+1,a:[Z.el,Z.el.childNodes.length],b:N(Z.el,!0)});else if(he)h.push({s:w,e:w+1,a:N(he.el),b:[he.el,0]});else return null}}h.sort((k,d)=>k.s-d.s);let L=k=>{if(k[0].nodeType===3||k[0].nodeType===8){let w=h.find(Z=>Z.node===k[0]);return w?w.s+k[1]:null}let d=0;for(let w of h){if(A(k,w.a)<=0)return w.s;if(A(k,w.b)<0)return null;d=w.e}return d},R=L([n,r]),F=L([a,l]);return R!==null&&F!==null&&R<=F?M.slice(R,F):null}function Hn(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 Ts(e,o){if(!e||!o)return null;let t=Hn(e,o.start),n=Hn(e,o.end);return t&&n?{startContainer:t[0],startOffset:t[1],endContainer:n[0],endOffset:n[1]}:null}var Ns=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function As(e,o,t){if(!o)return;let n=new Map,r=new Map,a=i=>{if(!i)return null;if(r.has(i))return r.get(i);let A=i.local.map(N=>Hn(o.localRoot,{path:N,offset:0})?.[0]).map(N=>N&&t(N)).filter(Boolean).map(N=>({node:N,parent:N.parentNode,previous:N.previousSibling,next:N.nextSibling,fragment:Ns(N)}));return r.set(i,A),A},l=i=>{let u=Ts(o.localRoot,i);if(!u)return null;let A=t(u.startContainer),N=t(u.endContainer);if(!A||!N)return null;let h={...u,startContainer:A,endContainer:N};return jn(h)?h:null};for(let i of e){let u=i.recovery;if(n.has(u))continue;let A={subject:a(u.subject),span:null,scope:null,touched:new Set};if(u.text){A.span=l(u.text.local.span),A.scope=l(u.text.local.scope);let N=A.span;if(N){let h=N.startContainer.ownerDocument.createRange();h.setStart(N.startContainer,N.startOffset),h.setEnd(N.endContainer,N.endOffset);let M=L=>{if(h.intersectsNode(L)){A.touched.add(L);for(let R of L.childNodes)M(R)}};M(h.commonAncestorContainer)}}if(u.structure){for(let N of[u.structure.localPlacement])N&&(a(N.parent),N.before.forEach(a),N.after.forEach(a));for(let N of u.structure.localOrder||[])a(N)}n.set(u,A)}o.localState={states:n,refs:r}}function vs(e,o,t,n){let r=t.localState?.states.get(e);if(!r)return!1;let a=i=>{let u=i.node;if(!n(u)||u.parentNode!==i.parent)return!1;let A=N=>Array.prototype.indexOf.call(u.parentNode.childNodes,N);return!(i.previous&&n(i.previous)&&i.previous.parentNode===u.parentNode&&A(i.previous)>=A(u)||i.next&&n(i.next)&&i.next.parentNode===u.parentNode&&A(i.next)<=A(u))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!r.subject.length||!r.subject.every(a))return!1;if(e.text){let i=e.text.local,u=A=>A&&n(A.startContainer)&&n(A.endContainer);return u(r.span)&&u(r.scope)&&Cn(r.scope,e.text.encoding)===i.text&&Cn(r.span,e.text.encoding)===i.text.slice(i.start,i.end)}if(e.attribute){let i=e.attribute,u=r.subject[0].node;return(i.namespaceURI?u.getAttributeNS(i.namespaceURI,i.localName):u.getAttribute(i.qualifiedName))===o.local}let l=e.structure;if(l.localOrder){let i=-1,u=null;for(let A of l.localOrder){let N=t.localState.refs.get(A)?.[0]?.node;if(!N||!n(N)||u&&N.parentNode!==u)return!1;let h=Array.prototype.indexOf.call(N.parentNode.childNodes,N);if(h<=i)return!1;u=N.parentNode,i=h}return!0}return l.localAction==="moved"||r.subject.every(i=>Ns(i.node)===i.fragment)}var _r=1,Yt=e=>!!e&&e.nodeType===1,xo=e=>Yt(e)&&e.tagName==="TEMPLATE"&&!!e.content;function Dn(e,o=null,t=null){let n=new Map,r=new Map,a=N=>{if(!o){o=new WeakMap;let h=[e];for(;h.length;){let M=h.pop();xo(M)&&(o.set(M.content,M),h.push(M.content));for(let L=M.firstChild;L;L=L.nextSibling)L.nodeType===1&&h.push(L)}}return o.get(N)||null},l=(N,h)=>{let M=r.get(N);if(!M){M=new Map;let L=0;for(let R=N.firstChild;R;R=R.nextSibling)M.set(R,L++);r.set(N,M)}return M.get(h)},i=N=>{if(!N)return null;if(t&&t.has(N))return i(t.get(N));if(N===e)return[];let h=n.get(N);if(h!==void 0)return h;let M=N.parentNode,L=null;if(M&&M.nodeType===11){let R=a(M),F=R?i(R):null;F&&(L=F.concat(["content",l(M,N)]))}else if(M){let R=i(M);R&&(L=R.concat([l(M,N)]))}return n.set(N,L),L};return{root:e,pathOf:i,logicalParent:N=>{let h=N.parentNode;return h&&h.nodeType===11?a(h):h},indexIn:l,containerPath:N=>{if(N.nodeType===11){let M=a(N),L=i(M);return L?L.concat(["content"]):null}let h=i(N);return h&&xo(N)?h.concat(["content"]):h},ownerOf:a}}var bn=e=>xo(e)?e.content:e;function Ss(e){let{L:o,R:t,unitsOf:n,provenance:r,policy:a}=e,l=[];return{note:(N,h)=>{l.push([N,h])},finish:N=>l.length?A(N):null};function A(N){let h={base:Dn(e.roots.base),local:Dn(e.roots.local),remote:Dn(e.roots.remote)},M=p=>p==="local"?o:t,L=(p,y)=>{if(!y)return null;if(p.map.has(y))return p.map.get(y);let E=[],f=Yt(y)?h.base.logicalParent(y):y.parent;for(;f&&!p.map.has(f);f=h.base.logicalParent(f))E.push(f);if(!f||!p.identical.has(f))return null;let m=p.map.get(f);for(let C=E.length-1;C>=0&&m;C--)m=bn(m).childNodes[h.base.indexIn(E[C].parentNode,E[C])];return m?Yt(y)?bn(m).childNodes[h.base.indexIn(y.parentNode,y)]||null:n(m)[n(y.parent).indexOf(y)]||null:null},R=new Map,F=new Map,k=new WeakMap,d=0,w=(p,y)=>{let E=R.get(p);E||R.set(p,E=[]),E.push(y)};(function p(y){F.set(y,d++);let E=r.get(y);if(E&&!E.pinned){for(let f of[E.base,E.local,E.remote])if(f)if(Array.isArray(f))for(let m of f)w(m,y);else w(f,y)}if(xo(y)){k.set(y.content,y);for(let f=y.content.firstChild;f;f=f.nextSibling)p(f)}for(let f=y.firstChild;f;f=f.nextSibling)p(f)})(N);let Z=new Map;h.out=Dn(N,k,Z);let he={refs:new Map,spans:new Map,anchors:new Map,via:Z,outOwners:k,outRoot:N,localRoot:e.roots.local},xe=p=>Yt(p)?[p]:p.nodes,ee=(p,y)=>{let E=h[y].logicalParent(p);if(!E)return null;for(let f of n(E))if(!Yt(f)&&f.nodes.includes(p))return f;return null},oe=(p,y)=>p==null?null:Array.isArray(p)?p.length?ee(p[0],y):null:p,re=p=>{let y=new Set,E=[];for(let f of p)for(let m of R.get(f)||[])y.has(m)||(y.add(m),E.push(m));return E.sort((f,m)=>F.get(f)-F.get(m))},ne=new Map,K=p=>{let y=p.b||p.l||p.r,E=ne.get(y);if(E)return E;let f=[];for(let m of[p.b,p.l,p.r])m&&f.push(...xe(m));return E=re(f),ne.set(y,E),E},D=p=>({b:p,l:L(o,p),r:L(t,p)}),Ne=(p,y)=>{let E=M(y).reverse.get(p);if(E)return D(E);for(let f of re(xe(p))){let m=r.get(f);if(m&&!m.base&&m.local&&m.remote)return{b:null,l:oe(m.local,"local"),r:oe(m.remote,"remote")}}return y==="local"?{b:null,l:p,r:null}:{b:null,l:null,r:p}},ae=new Map,te=p=>{let y=r.get(p);if(!y||y.pinned)return null;let E=oe(y.base,"base");if(E)return D(E);let f=oe(y.local,"local"),m=oe(y.remote,"remote");if(f){let C=o.reverse.get(f);if(C)return D(C)}if(m){let C=t.reverse.get(m);if(C)return D(C)}return f||m?{b:null,l:f,r:m}:null},V=p=>(ae.has(p)||ae.set(p,te(p)),ae.get(p)),ye=(p,y)=>Yt(p)?h[y].logicalParent(p):p.parent,be=new Map,Oe=new Map,He=(p,y)=>(Yt(p)?[h[y].pathOf(p)]:p.nodes.map(E=>h[y].pathOf(E))).filter(Boolean),Ue=p=>{let y=p.b||p.l||p.r,E=p.b?"base":p.l?"local":"remote",f=Oe.get(y);if(f)return f;let m=!Yt(y),C=He(y,E)[0],W=`${E[0]}:${JSON.stringify(C===void 0?null:C)}${m?":run":""}`,j=be.get(W);if(j)return Oe.set(y,j),j;let z=K(p);return j={key:W,nodeType:Yt(y)?1:y.kind==="comment"?8:3,base:p.b?He(p.b,"base"):[],local:p.l?He(p.l,"local"):[],remote:p.r?He(p.r,"remote"):[],merged:z.map(x=>h.out.pathOf(x)).filter(Boolean),live:[]},be.set(W,j),Oe.set(y,j),he.refs.set(j,z),j},ze={base:new Map,local:new Map,remote:new Map},se=new Map,at=(p,y)=>{let E=ye(p,y);if(!E||E.nodeType!==1)return null;let f=ze[y].get(E);if(!f){let C=n(E),W=j=>Ue(y==="base"?D(j):Ne(j,y));f={parent:W(E),refs:C.map(W),index:new Map(C.map((j,z)=>[j,z]))},ze[y].set(E,f)}let m=f.index.get(p)??-1;return{parent:f.parent,before:f.refs.slice(m+1),after:f.refs.slice(0,Math.max(0,m)).reverse()}},ft=p=>{let y=p.parentNode;if(!y)return null;let E=se.get(y);if(!E){let m=y.nodeType===11?k.get(y):y,C=m&&m.nodeType===1?V(m):null;if(!C)return null;let W=[],j=[],z=new Map;for(let S of y.childNodes){let G=V(S),ge=G&&Ue(G),Me=W.length,c=W.length-1;ge&&ge!==W[c]&&(W.push(ge),c++);let T={ref:ge,group:c,after:Me};j.push(T),z.set(S,T)}let x=W.length;for(let S=j.length-1;S>=0;S--){let G=j[S];G.before=x,G.ref&&(x=G.group)}E={parent:Ue(C),refs:W,index:z},se.set(y,E)}let f=E.index.get(p);return{parent:E.parent,before:E.refs.slice(f.before),after:E.refs.slice(0,f.after).reverse()}},le=p=>Yt(p)?p.outerHTML:p.value,b=p=>Yt(p)?"element":p.kind==="comment"?"comment":"text",H=(p,y)=>({path:p,offset:y}),fe=(p,y,E)=>{if(!p)return null;let f=h[E],m=0;if(y){let C=Yt(y)?y:y.nodes[y.nodes.length-1];C.parentNode&&(m=f.indexIn(C.parentNode,C)+1)}return H(f.containerPath(p),m)},we=(p,y)=>{let E=ye(p,"base"),f=E?L(M(y),E):null;if(!Yt(f))return null;let m=n(E),C=null;for(let W=m.indexOf(p)-1;W>=0&&!C;W--){let j=L(M(y),m[W]);j&&ye(j,y)===f&&(C=j)}return fe(f,C,y)},pe=(p,y,E,f)=>{let m=h[f],C=0;for(let W=0;W<p.nodes.length;W++){let j=p.nodes[W],z=j.nodeValue.length,x=W===p.nodes.length-1;if((E==="start"?y<C+z:y<=C+z)||x)return H(m.pathOf(j),Math.max(0,Math.min(y-C,z)));C+=z}return null},Ge=(p,y)=>{let E=h[y],f=p.firstChild,m=p.lastChild;return f&&f.nodeType===3&&m.nodeType===3?{start:H(E.pathOf(f),0),end:H(E.pathOf(m),m.nodeValue.length)}:{start:H(E.pathOf(p),0),end:H(E.pathOf(p),p.childNodes.length)}},je=(p,y,E)=>{for(let W of p.nodes)if(E==="start"?W.s<=y&&y<W.e:W.s<y&&y<=W.e)return{kind:"text",node:W.node,offset:y-W.s};let f=E==="start"?y:y-1,m=()=>{for(let W of p.nodes)if(W.s===y||W.e===y)return{kind:"text",node:W.node,offset:y-W.s};return null},C=p.atomAt.get(f);if(C)return{kind:E==="start"?"before":"after",node:C.el};if(p.text[f]===gt){let W=p.marks.find(z=>z.block&&z.to===f+1);if(W)return E==="start"?{kind:"end",node:W.el}:{kind:"after",node:W.el};let j=p.marks.find(z=>z.block&&z.from===f+1);if(j)return E==="start"?{kind:"before",node:j.el}:{kind:"startOf",node:j.el}}return m()},Ze=(p,y)=>je(p,y,"end")||je(p,y,"start"),rt=(p,y)=>{switch(y.kind){case"text":return H(p.pathOf(y.node),y.offset);case"end":return H(p.containerPath(y.node),bn(y.node).childNodes.length);case"startOf":return H(p.containerPath(y.node),0);default:{let E=y.node.parentNode;return H(p.containerPath(E),p.indexIn(E,y.node)+(y.kind==="after"?1:0))}}},wt=(p,y,E,f,m)=>{let C=je(p,y,E);return C?rt(h[f],C):m()},bt=(p,y,E,f)=>{let m=p.textNodes.map(x=>({s:x.ms,e:x.me,start:{kind:"text",node:x.node,offset:0},end:{kind:"text",node:x.node,offset:x.me-x.ms}}));for(let[x,S]of p.atomOut)m.push({s:x,e:x+1,start:{kind:"before",node:S},end:{kind:"after",node:S}});for(let[x,S]of p.breakOut)m.push({s:x,e:x+1,start:{kind:"end",node:S},end:{kind:"after",node:S}});for(let x of m)if(x.start.kind==="text"&&x.s<y&&y<x.e)return{kind:"text",node:x.start.node,offset:y-x.s};if(E!=="empty"){let x=m.find(S=>E==="start"?S.s===y:S.e===y);if(x)return E==="start"?x.start:x.end}let C=m.find(x=>x.e===y);if(C)return C.end;let W=m.find(x=>x.s===y);if(W)return W.start;let j=null,z=null;for(let x of m)x.e<=y&&(!j||x.e>j.e)&&(j=x),x.s>=y&&(!z||x.s<z.s)&&(z=x);return j?j.end:z?z.start:f()},Tt=(p,y)=>{if(!y)return null;if(y.kind==="text"){let m=p.nodes.find(C=>C.node===y.node);return m?m.s+Math.min(y.offset,m.e-m.s):null}let E=p.atoms.find(m=>m.el===y.node);if(E)return y.kind==="after"?E.i+1:E.i;let f=p.marks.find(m=>m.el===y.node);return f?y.kind==="before"&&f.block&&p.text[f.from-1]===gt&&!p.marks.some(m=>m.block&&m.to===f.from)?f.from-1:y.kind==="startOf"||y.kind==="before"?f.from:y.kind==="end"&&f.block?f.to-1:f.to:null},tn=(p,y,E,f)=>{for(let j of p.nodes)if(E==="start"?j.s<=y&&y<j.e:j.s<y&&y<=j.e)return{kind:"text",node:j.node,offset:y-j.s};let m=E==="start"?y:y-1;if(!p.atomAt.has(m)&&p.text[m]!==gt){for(let j of p.nodes)if(j.s===y||j.e===y)return{kind:"text",node:j.node,offset:y-j.s}}let C=p.atomAt.get(m);if(C)return{kind:E==="start"?"before":"after",node:C.el};if(p.text[m]===gt){let j=p.marks.find(x=>x.block&&x.to===m+1);if(j)return E==="start"?{kind:"end",node:j.el}:{kind:"after",node:j.el};let z=p.marks.find(x=>x.block&&x.from===m+1);if(z)return E==="start"?{kind:"before",node:z.el}:{kind:"startOf",node:z.el}}let W=p.marks.find(j=>j.block&&j.from===y);return W?{kind:"startOf",node:W.el}:f?{kind:E==="start"?"startOf":"end",node:f}:null},Fe=p=>{if(!p)return null;if(p.kind==="wholeStart"||p.kind==="wholeEnd"){let y=Xt(p.node);return p.kind==="wholeStart"?y.start:y.end}return rt(h.out,p)},Xt=p=>{let y=p.firstChild,E=p.lastChild;return y&&y.nodeType===3&&E.nodeType===3?{start:H(h.out.pathOf(y),0),end:H(h.out.pathOf(E),E.nodeValue.length)}:{start:H(h.out.pathOf(p),0),end:H(h.out.pathOf(p),p.childNodes.length)}},Jt=p=>{let y=ye(p,"base"),E=y?K(D(y))[0]:null;if(!E)return null;let f=bn(E),m=n(y);for(let C=m.indexOf(p)-1;C>=0;C--){let W=K(D(m[C])).filter(j=>j.parentNode===f);if(W.length)return{kind:"after",node:W[W.length-1]}}return{kind:"startOf",node:E}},Dt=(p,y,E,f,m,C)=>({text:p,start:y,end:E,fragment:f,span:m,scope:C}),It=(p,y,E,f,m)=>Dt(p,y,E,p.slice(y,E),f,m),Et=(p,y,E,f,m)=>(he.spans.set(p,{start:y,end:E,scopeStart:f,scopeEnd:m}),p),sn=new Map,v=new Map,X=(p,y,E)=>{let f=`text:${p.key}:${y}:${E}`,m=v.get(f)||0;return v.set(f,m+1),`${f}:${m}`},Q=(p,y)=>{let E,f,m,C="plain",W,j,z,x,S,G=(c,T,P,U,_)=>{if(!c){let q=we(_,U);return It("",0,0,{start:q,end:q},{start:q,end:q})}return It(c.value,T,P,{start:pe(c,T,T===P?"end":"start",U),end:pe(c,P,"end",U)},{start:pe(c,0,"start",U),end:pe(c,c.value.length,"end",U)})};if(y.site==="run"){let{bRun:c,lRun:T,rRun:P,node:U,c:_}=y;E=D(c),f=_.bs,m=_.be,W=G(c,_.bs,_.be,"base",c),j=G(T,_.ls,_.le,"local",c),z=G(P,_.rs,_.re,"remote",c);let q=U?U.nodeValue:"",Y=ce=>U?{kind:"text",node:U,offset:ce}:Jt(c);x=Et(It(q,_.ms,_.me,{start:Fe(Y(_.ms)),end:Fe(Y(_.me))},{start:Fe(Y(0)),end:Fe(Y(q.length))}),Y(_.ms),Y(_.me),Y(0),Y(q.length)),S=U||(Jt(c)||{}).node||null}else if(y.site==="whole"){let c=y.el,T=r.get(c);E=D(T.base),f=0,m=p.base.length;let P=(_,q,Y)=>{let ce=Ge(q,Y);return It(_,0,_.length,ce,ce)};W=P(p.base,T.base,"base"),j=P(p.local,T.local,"local"),z=P(p.remote,T.remote,"remote");let U=Xt(c);x=Et(It(p.resolved,0,p.resolved.length,U,U),{kind:"wholeStart",node:c},{kind:"wholeEnd",node:c},{kind:"wholeStart",node:c},{kind:"wholeEnd",node:c}),S=c}else if(y.site==="comment"){let{bRun:c,lRun:T,rRun:P,node:U}=y;E=D(c),f=0,m=p.base.length;let _=(Se,Ee)=>{if(!Se){let Be=we(c,Ee);return It("",0,0,{start:Be,end:Be},{start:Be,end:Be})}let Ie=Se.nodes[0],et={start:H(h[Ee].pathOf(Ie),0),end:H(h[Ee].pathOf(Ie),Se.value.length)};return It(Se.value,0,Se.value.length,et,et)};W=_(c,"base"),j=_(T,"local"),z=_(P,"remote");let q=p.resolved,Y=Se=>U?{kind:"text",node:U,offset:Se}:Jt(c),ce={start:Fe(Y(0)),end:Fe(Y(q.length))};x=Et(It(q,0,q.length,ce,ce),Y(0),Y(q.length),Y(0),Y(q.length)),S=U||(Jt(c)||{}).node||null}else{let{fb:c,fl:T,fr:P,scope:U}=y,_=y.merged;C="html",E=U.base?D(U.base):Ne(U.local,"local"),f=p.bs,m=p.be;let q=ut=>{let At=U[ut];for(let Nt=U.at-1;Nt>=0;Nt--){let jt=U.units[Nt],Qt=ut==="base"?jt:L(M(ut),jt);if(Qt&&ye(Qt,ut)===At)return Qt}return null},Y=ut=>()=>fe(U[ut],q(ut),ut),ce=(ut,At,Nt,jt,Qt)=>{let fn=De=>De?rt(h[Qt],De):Y(Qt)(),An=At===Nt?Ze(ut,At):je(ut,At,"start"),vn=At===Nt?Ze(ut,At):je(ut,Nt,"end"),kn=fn(An),rn={start:kn,end:At===Nt?kn:fn(vn)},zt=y.full?y.full(Qt):null;if(!zt)return Dt(ut.text,At,Nt,jt,rn,{start:fn(je(ut,0,"start")),end:fn(je(ut,ut.text.length,"end"))});let J=An?Tt(zt,An):null,Re=vn?Tt(zt,vn):null,ve=J===null?0:J,Ye=Math.max(ve,Re===null?zt.text.length:Re),lt=fn(je(zt,0,"start"));return Dt(zt.text,ve,Ye,zn(zt,ve,Ye),rn,{start:lt,end:zt.text.length?fn(je(zt,zt.text.length,"end")):lt})};W=y.synthetic?null:ce(c,p.bs,p.be,p.base,"base"),j=ce(T,p.lss,p.lse,p.local,"local"),z=ce(P,p.rss,p.rse,p.remote,"remote");let[Se,Ee]=p.range||[0,0],Ie=_.out,et=()=>{let ut=bn(_.node);for(let At=U.at-1;At>=0;At--){let Nt=K(D(U.units[At])).filter(jt=>jt.parentNode===ut);if(Nt.length)return{kind:"after",node:Nt[Nt.length-1]}}for(let At=U.at;At<U.units.length;At++){let Nt=K(D(U.units[At])).filter(jt=>jt.parentNode===ut);if(Nt.length)return{kind:"before",node:Nt[0]}}return{kind:"startOf",node:_.node}};if(Ie.via)for(let[ut,At]of Ie.via)Z.set(ut,At);let Be=bt(_,Se,Se===Ee?"empty":"start",et),St=Se===Ee?Be:bt(_,Ee,"end",et),Ve=Ie.text.length?tn(Ie,0,"start",_.node):et(),pt=Ie.text.length?tn(Ie,Ie.text.length,"end",_.node):Ve,it=Tt(Ie,Be),Ft=Tt(Ie,St),Rt=it===null?0:it,Kt=Math.max(Rt,Ft===null?Ie.text.length:Ft);x=Et(Dt(Ie.text,Rt,Kt,zn(Ie,Rt,Kt),{start:Fe(Be),end:Fe(St)},{start:Fe(Ve),end:Fe(pt)}),Be,St,Ve,pt);let Lt=he.spans.get(x);if(Lt.flat=Ie,!Ie.text.length){let ut=Fe(Ve),At=Hn(N,ut),Nt=At[0],jt=At[1];Lt.empty={parent:Nt.nodeType===11?k.get(Nt):Nt,previous:Nt.childNodes[jt-1]||null,next:Nt.childNodes[jt]||null}}S=Be?Be.node:_.node}let ge=Ue(E),Me=(y.site==="whole"||y.site==="comment"||a!=="both")&&p.resolved!==p.local;return{key:y.site==="comment"&&sn.get(E.b||E.l||E.r)||X(ge,f,m),subject:ge,localLost:Me,anchor:S,text:{encoding:C,base:W,local:j,remote:z,merged:x,liveSpan:null,liveScope:null}}},de=(p,y)=>{let E=V(y.el),f=Ue(E),m=y.sample;return{key:`attr:${f.key}:${m.namespaceURI||""}:${m.localName}`,subject:f,localLost:p.resolved!==p.local,anchor:y.el,attribute:{namespaceURI:m.namespaceURI||null,localName:m.localName,qualifiedName:m.name}}},ie=(p,y)=>{let E=p.detail,f=y.unit||D(y.subject),m=Ue(f),C=he.refs.get(m),W=f.l?at(f.l,"local"):null,j=f.r?at(f.r,"remote"):null,z=C.length?ft(C[0]):null,x,S,G,ge=null,Me=null,c=y.deleted;switch(E){case"both-reordered":{x=S="reordered";let T=new Set(y.rKept),P=y.lKept.filter(ce=>T.has(ce)&&K(D(ce)).length),U=ce=>F.get(K(D(ce))[0]);ge=P.map(ce=>Ue(D(ce))),Me=P.slice().sort((ce,Se)=>U(ce)-U(Se)).map(ce=>Ue(D(ce)));let _=ce=>!Yt(ce)&&ce.kind!=="comment"&&ce.nodes.every(Se=>!/[^\t\n\f\r ]/.test(Se.data)),q=P.filter(ce=>!_(ce)),Y=q.slice().sort((ce,Se)=>U(ce)-U(Se));G=q.some((ce,Se)=>ce!==Y[Se]);break}case"both-moved":x=S="moved",G=!W||!C.some(T=>{let P=T===C[0]?z:ft(T);return P&&P.parent===W.parent});break;case"edit-beats-delete":x=c==="local"?"deleted":"edited",S=c==="remote"?"deleted":"edited",G=c==="local";break;case"move-beats-delete":x=c==="local"?"deleted":"moved",S=c==="remote"?"deleted":"moved",G=c==="local";break;default:x=S="inserted",G=y.localLost}return{key:`structure:${m.key}:${E}`,subject:m,localLost:G,anchor:C[0]||null,structure:{localAction:x,remoteAction:S,localPlacement:W,remotePlacement:j,mergedPlacement:z,localOrder:ge,mergedOrder:Me,localFragment:E==="both-reordered"||!f.l?null:le(f.l),fragmentKind:b(f.b||f.l||f.r)}}};for(let[p,y]of l){if(p.kind!=="structure")continue;let E=y.unit||D(y.subject),f=E.b||E.l||E.r;!Yt(f)&&f.kind==="comment"&&sn.set(f,`structure:${Ue(E).key}:${p.detail}`)}let ue=new Map;for(let[p,y]of l){if(p.kind==="structure"){let C=Ue(y.unit||D(y.subject)),W=`structure:${C.key}:${p.detail}`,j=ue.get(W);if(j&&j.structure){p.recovery=j;let z=he.refs.get(C);p.el==null&&z.length&&(p.el=Yt(z[0])?z[0]:h.out.logicalParent(z[0]));continue}}let E=p.kind==="text"?Q(p,y):p.kind==="attr"?de(p,y):ie(p,y),f=ue.get(E.key);f||(f={version:_r,key:E.key,localLost:E.localLost,subject:E.subject,applied:!1,unavailable:null},ue.set(E.key,f),he.anchors.set(f,E.anchor)),E.text&&(f.text=E.text),E.attribute&&(f.attribute=E.attribute),E.structure&&(f.structure=E.structure),E.text&&(f.localLost=E.localLost),p.recovery=f;let m=he.refs.get(E.subject);p.kind==="structure"&&p.el==null&&m.length&&(p.el=Yt(m[0])?m[0]:h.out.logicalParent(m[0])),p.kind==="text"&&p.node==null&&m.length&&E.subject.nodeType===8&&(p.node=m[0])}return he}}function Os(e,o,t){if(!o)return;let{lookup:n,vetoed:r,vetoedAttrs:a,liveAttr:l}=t,i=t.ignored||(()=>!1),u=Dn(t.liveRoot),A=te=>!!te&&u.containerPath(te)!==null,N=te=>{let V=te.parentNode;return V&&V.nodeType===11?o.outOwners.get(V)||null:V},h=te=>{for(let V=te;V;V=N(V))if(o.via.has(V)&&(V=o.via.get(V)),r.has(V)||t.vetoedLive?.has(d(V)))return!0;return!1},M=te=>Array.from(bn(te).children).filter(V=>!i(V)),L=(te,V)=>M(te)[M(V.parentNode).indexOf(V)],R=(te,V)=>{let ye=null,be=null,Oe=0;for(let se=V.previousSibling;se;se=se.previousSibling){if(se.nodeType===1&&!i(se)){ye=se;break}se.nodeType===3&&(Oe+=se.nodeValue.length)}for(let se=V.nextSibling;se&&!be;se=se.nextSibling)se.nodeType===1&&!i(se)&&(be=se);let He=ye?L(te,ye):null,Ue=be?L(te,be):null;if(ye&&!He||be&&!Ue)return null;let ze=[];for(let se=He?He.nextSibling:bn(te).firstChild;se&&se!==Ue;se=se.nextSibling)se.nodeType===3&&ze.push(se);return ze.length?{nodes:ze,lead:Oe}:null},F=te=>{let V=[],ye=te;for(;ye&&!o.via.has(ye);ye=ye.parentNode)V.push(ye);if(!ye||!V.length)return null;let be=d(o.via.get(ye));for(let Ue=V.length-1;Ue>0&&be;Ue--)be=L(be,V[Ue]);if(!be)return null;let Oe=V[0];if(Oe.nodeType===3)return R(be,Oe);let He=Oe.nodeType===1?L(be,Oe):null;return He?{nodes:[He],lead:0}:null},k=te=>{let V=n(te),ye=V?{nodes:Array.isArray(V)?V:[V],lead:0}:o.via.size?F(te):null;if(!ye)return null;let be=ye.nodes.filter(A);return be.length?{nodes:be,lead:ye.lead}:null},d=te=>{let V=k(te);return V?V.nodes[0]:null},w=te=>{if(!te)return null;if(te.kind==="text"){let Oe=k(te.node);if(!Oe)return null;let He=Oe.nodes,Ue=te.offset+Oe.lead,ze=0;for(let se=0;se<He.length;se++){let at=He[se].nodeValue.length;if(Ue<=ze+at||se===He.length-1)return Ue>=ze&&Ue<=ze+at?[He[se],Ue-ze]:null;ze+=at}return null}let V=d(te.node);if(!V)return null;if(te.kind==="end")return[bn(V),bn(V).childNodes.length];if(te.kind==="startOf")return[bn(V),0];if(te.kind==="wholeStart")return V.firstChild?[V.firstChild,0]:[V,0];if(te.kind==="wholeEnd")return V.lastChild?[V.lastChild,V.lastChild.nodeValue.length]:[V,V.childNodes.length];let ye=V.parentNode;if(!ye)return null;let be=Array.prototype.indexOf.call(ye.childNodes,V);return[ye,te.kind==="after"?be+1:be]},Z=te=>({blocks:new Set((te.flat?.marks||[]).filter(V=>V.block).map(V=>d(V.el)).filter(Boolean)),atoms:new Set((te.flat?.atoms||[]).map(V=>d(V.el)).filter(Boolean)),ignored:i}),he=(te,V,ye,be)=>{if(!te||!V||!jn(te)||!jn(V))return!1;for(let Ue of[te,V])if(!A(Ue.startContainer)||!A(Ue.endContainer))return!1;let Oe=ye.merged;if(Oe.start===Oe.end&&(te.startContainer!==te.endContainer||te.startOffset!==te.endOffset))return!1;let He=Z(be);return Cn(V,ye.encoding,He)===Oe.text&&Cn(te,ye.encoding,He)===Oe.text.slice(Oe.start,Oe.end)},xe=new Map,ee=te=>{let V=te.parentNode;return V?(xe.has(V)||xe.set(V,new Map(Array.from(V.childNodes,(ye,be)=>[ye,be]))),xe.get(V).get(te)):-1},oe=(te,V)=>{if(!V)return!1;let ye=u.logicalParent(te);if(!V.parent.live.includes(ye))return!1;let be=ee(te);for(let[Oe,He]of[["before",1],["after",-1]]){let Ue=be;for(let ze of V[Oe]){if(ze.live.includes(te))continue;let se=ze.live.filter(ft=>ft!==te&&ft.parentNode===te.parentNode);if(!se.length)continue;let at=He===1?Math.min(...se.map(ee)):Math.max(...se.map(ee));if(He*(at-Ue)<=0)return!1;Ue=at}}return!0},re=te=>{let V=te.structure;if(V.mergedOrder){let ye=new Set(te.subject.live.map(bn)),be=null,Oe=-1;for(let He of V.mergedOrder){let Ue=He.live.find(ze=>ye.has(ze.parentNode));if(!Ue||be&&Ue.parentNode!==be||ee(Ue)<=Oe)return!1;be=Ue.parentNode,Oe=ee(Ue)}return te.subject.live.length>0}return te.subject.live.some(ye=>oe(ye,V.mergedPlacement))},ne=(te,V)=>{let ye=w(te),be=w(V);return ye&&be?{startContainer:ye[0],startOffset:ye[1],endContainer:be[0],endOffset:be[1]}:null},K=new Set,D=te=>{if(!te||K.has(te))return;K.add(te);let V=[];for(let ye of o.refs.get(te)||[]){let be=k(ye);if(be)for(let Oe of be.nodes)V.includes(Oe)||V.push(Oe)}te.live=V},Ne=te=>{te&&(D(te.parent),te.before.forEach(D),te.after.forEach(D))},ae=new Set;for(let te of e){let V=te.recovery;if(!V||ae.has(V))continue;ae.add(V),D(V.subject),V.structure&&(Ne(V.structure.localPlacement),Ne(V.structure.remotePlacement),Ne(V.structure.mergedPlacement),(V.structure.localOrder||[]).forEach(D),(V.structure.mergedOrder||[]).forEach(D));let ye=o.anchors.get(V),be=ye?d(ye):null,Oe=!!be;if(V.text){let b=o.spans.get(V.text.merged),H=b?ne(b.start,b.end):null,fe=b?ne(b.scopeStart,b.scopeEnd):null;if(b?.empty){let we=b.empty,pe=we.previous?{kind:"after",node:we.previous}:{kind:"startOf",node:we.parent},Ge=we.next?{kind:"before",node:we.next}:{kind:"end",node:we.parent},je=ne(pe,Ge);!je||je.startContainer!==je.endContainer||je.startOffset!==je.endOffset?H=null:H=fe=je}he(H,fe,V.text,b)||(H=fe=null),V.text.liveSpan=H,V.text.liveScope=H?fe:null,H||(Oe=!1)}V.structure&&Oe&&(Oe=re(V)),V.attribute&&Oe&&(Oe=l(be,V.attribute,te.resolved));let He=(!!V.attribute||!!V.text&&be?.tagName==="TEXTAREA")&&!!a&&[ye,be].some(b=>a.get(b)?.has(V.attribute?V.attribute.qualifiedName:"value")),Ue=o.localState?.states.get(V),ze=!!V.text&&[...t.removedVetoes||[]].some(b=>Ue?.touched.has(b)),se=V.structure?.localAction==="inserted"&&[...r].some(b=>b===ye||ye?.contains(b)),at=ye&&h(ye)||He||ze||se,ft=at&&vs(V,te,o,A);ft&&(ze||se&&V.localLost)&&(Oe=!1);let le=!Oe&&ft&&at;V.applied=Oe,V.unavailable=Oe?null:le?"hook-veto":"missing-output",le&&(V.localLost=!1),!Oe&&V.text&&(V.text.liveSpan=V.text.liveScope=null)}}function To(e,o,t){let n=Dn(o),r=Dn(t),a=h=>!!h&&r.containerPath(h)!==null,l=h=>{if(h===o)return t;let M=n.pathOf(h);if(M&&o!==t){let L=Hn(t,{path:M,offset:0});if(L&&L[0].nodeType===h.nodeType)return L[0]}return h},i=new Set,u=h=>{!h||i.has(h)||(i.add(h),h.live=h.live.map(l).filter(a))},A=h=>{h&&(h.startContainer=l(h.startContainer),h.endContainer=l(h.endContainer))},N=new Set;for(let h of e){h.node===o&&t.tagName==="SCRIPT"&&(h.node=t),h.el===o&&h.kind==="structure"&&(h.el=t);let M=h.recovery;if(!M||N.has(M))continue;if(N.add(M),u(M.subject),M.text){A(M.text.liveSpan),A(M.text.liveScope);let R=M.text.liveSpan,F=M.text.liveScope,k=M.text.merged,d=w=>!!w&&jn(w)&&a(w.startContainer)&&a(w.endContainer);(!d(R)||!d(F)||Cn(F,M.text.encoding)!==k.text||Cn(R,M.text.encoding)!==k.text.slice(k.start,k.end))&&(M.text.liveSpan=null,M.text.liveScope=null,M.applied=!1,M.unavailable="missing-output")}let L=M.structure;if(L){for(let R of[L.localPlacement,L.remotePlacement,L.mergedPlacement])R&&(u(R.parent),R.before.forEach(u),R.after.forEach(u));(L.localOrder||[]).forEach(u),(L.mergedOrder||[]).forEach(u),M.subject.live.length||(M.applied=!1,M.unavailable="missing-output")}}}var Qe=e=>!!e&&e.nodeType===1,qr=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),Ms=5e4,so="[id],[data-id],script,head>*";function $o(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=Gn(t,e);if(n)return"merge:"+n.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?ms(t,o):null}}function No(e,o,t,n){let r=n.ignored,a=n.stats||Mn(),l=ns({ignored:r,ignoreAttribute:n.ignoreAttribute,stats:a}),{unitsOf:i,meta:u}=l,A=n.baseURI,N=n.mergeTags!==null,h=$o(n.mergeTags,A),M=c=>T=>{let P=h(T);return P!==null?P:c(T)},L=M(n.identity.base),R=M(n.identity.local),F=M(n.identity.remote),k=n.authored||n.identity,d=c=>c&&c.nodeType===9?c.documentElement:c,w=d(e),Z=d(o),he=d(t),xe=globalThis.__hyperMorphProfile,ee=xe?performance.now():0,oe=c=>c===an?so:null,re=n.scope||null,ne=re?re.baseIndex:po(w,L,r,oe(n.identity.base)),K=n.localIsBase||w===Z?Ls():Eo(w,Z,{analyzer:l,baseIndex:ne,sideIndex:po(Z,R,r,oe(n.identity.local)),baseId:k.base,sideId:k.local,stats:a}),D=Eo(w,he,{analyzer:l,baseIndex:ne,sideIndex:re?re.remoteIndex:po(he,F,r,oe(n.identity.remote)),baseId:k.base,sideId:k.remote,stats:a,scope:re,comparisons:n.comparisons});if(re){if(!re.held(D))return null;for(let c of re.dropped)Lo(c)}let Ne=null;function ae(c){if(!Ne){Ne=new WeakMap;let T=[w];for(;T.length;){let P=T.pop();P.tagName==="TEMPLATE"&&P.content&&Ne.set(P.content,P);for(let U of l.childrenOf(P))U.nodeType===1&&T.push(U)}}return Ne.get(c)||null}let te=c=>{let T=Qe(c)||c.nodeType?c.parentNode:c.parent;return T&&T.nodeType===11?ae(T):T};Tt(),tn(K,D),tn(D,K);for(let c of[K,D])if(c.refused)for(let T of c.refused)c.moved.has(T)||a.ambiguousMoves++;xe&&(xe.alignTotal=(xe.alignTotal||0)+(performance.now()-ee),ee=performance.now());let V=w.ownerDocument.implementation.createHTMLDocument(""),ye=new WeakMap,be=new WeakMap,Oe=[],He=[],Ue=new Set,ze=[],se=new Set,at=new Set,ft=new Set,le=new WeakMap,b=n.conflicts||"remote",H=c=>Oe.push(c),fe=c=>Oe.push(c),we=Ss({roots:{base:w,local:Z,remote:he},L:K,R:D,unitsOf:i,provenance:ye,policy:b}),pe=(c,T)=>{He.push(c),T&&we.note(c,T)},Ge=wt(),je=It(w,K.map.get(w),D.map.get(w),!!n.localIsBase,!!n.childrenOnly);je.tagName==="HTML"?V.replaceChild(je,V.documentElement):V.body.appendChild(je),xe&&(xe.build=(xe.build||0)+(performance.now()-ee));let Ze=n.childrenOnly?!j(C(je),C(he)):!E(je,he),rt=we.finish(je);return{doc:V,root:je,provenance:ye,textMappers:be,decisions:Oe,conflicts:He,recoveryLinks:rt,localDiverged:Ze,mergedScripts:Ue,segments:ze,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==an,L:K,R:D,stats:a};function wt(){let c=new Map,T=new Set;if(n.localIsBase||!K.insertedByHash)return{partner:c,drop:T};let P=K.insertedByHash(),U=D.insertedByHash();if(!P.size||!U.size)return{partner:c,drop:T};let _={ignored:r,remoteWins:n.remoteWins,inlineCache:le},q=Ve=>{let pt=0;for(let it=Ve.parentNode;it;it=it.parentNode)pt++;return pt},Y=[],ce=Ve=>{let pt=Ve.textContent.trim();return pt.split(/\s+/).length>=3||pt.replace(/\s/g,"").length>=12},Se=Ve=>{let pt=Fe(K,Ve),it=Fe(D,Ve);return pt&&K.reverse.get(pt.parentNode)!==Ve.parentNode||it&&D.reverse.get(it.parentNode)!==Ve.parentNode},Ee=(Ve,pt,it)=>{for(let Rt of it.parentNode.children){let Kt=Rt!==it&&Ve.reverse.get(Rt);if(Kt&&Se(Kt))return!0}let Ft=Ve.reverse.get(it.parentNode);if(Ft){for(let Rt of Ft.children)if(!Fe(pt,Rt)&&!r(Rt))return!0}return!1};for(let[Ve,pt]of P){let it=U.get(Ve);if(!it)continue;let Ft=pt.length===1&&it.length===1;for(let Rt of pt)Bn(Rt,_)||Y.push([Rt,it,q(Rt),Ft&&(ce(Rt)||Ee(K,D,Rt)||Ee(D,K,it[0]))])}if(!Y.length)return{partner:c,drop:T};Y.sort((Ve,pt)=>Ve[2]-pt[2]);let Ie=new Set,et=new Set,Be=Ve=>{for(let pt of Ve.querySelectorAll("*"))Ie.add(pt)},St=(Ve,pt)=>Ve.reverse.get(pt.parentNode)||null;for(let[Ve,pt,,it]of Y){if(Ie.has(Ve))continue;let Ft=St(K,Ve),Rt=Lt=>!et.has(Lt)&&!Ie.has(Lt)&&Lt.tagName===Ve.tagName&&l.equalUnits(Ve,Lt),Kt=pt.find(Lt=>Ft&&St(D,Lt)===Ft&&Rt(Lt))||(it?pt.find(Rt):null);Kt&&(et.add(Kt),Be(Ve),Be(Kt),!(Ft&&St(D,Kt)===Ft)&&(c.set(Ve,Kt),c.set(Kt,Ve),T.add(b==="local"?Kt:Ve)))}return{partner:c,drop:T}}function bt(c,T,P){if(se.add(c),Ge.drop.has(c))return null;se.add(P);let U=T==="local"?c:P,_=T==="local"?P:c,q;return l.equalUnits(U,_)?(q=p(U,"local",!0),ye.get(q).remote=_):q=ue(U,_),pe({kind:"structure",el:q,detail:"both-moved",base:null,local:U,remote:_},{unit:{b:null,l:U,r:_}}),H({kind:"insert",el:q,source:"both"}),q}function Tt(){if(!K.weak||!D.weak||!K.weak.size||!D.weak.size||!K.unpair)return;let c=new Map;for(let P of K.weak){let U=Fe(K,P);Qe(P)&&Qe(U)&&c.set(l.unitHash(U),P)}let T=!1;for(let P of Array.from(D.weak)){let U=Fe(D,P);if(!Qe(P)||!Qe(U))continue;let _=c.get(l.unitHash(U));if(!_||_===P||!K.weak.has(_)||Fe(K,P)&&Fe(D,_))continue;let q=Fe(K,_);q.tagName===U.tagName&&l.equalUnits(q,U)&&(K.unpair(_),D.unpair(P),T=!0)}T&&(K.rematch(),D.rematch())}function tn(c,T){if(!c.weak||!c.weak.size||!T.insertedByHash)return;let P=T.insertedByHash();if(!P.size)return;let U=!1;for(let _ of Array.from(c.weak)){let q=Fe(c,_);if(!q)continue;let Y=P.get(l.unitHash(q));Y&&Y.some(ce=>ce.tagName===q.tagName&&l.equalUnits(ce,q))&&(c.unpair(_),U=!0)}U&&c.rematch()}function Fe(c,T){if(!T)return null;if(c.map.has(T))return c.map.get(T);let P=[],U=te(T);for(;U&&!c.map.has(U);U=te(U))P.push(U);let _=U;if(!_||!c.identical.has(_))return null;c.pairIdenticalChildren(_);for(let Y=P.length-1;Y>=0;Y--)c.pairIdenticalChildren(P[Y]);let q=c.map.get(T)||null;return q&&a.lazyTwins++,q}function Xt(c,T,P){if(at.has(c)||ft.has(c))return pe({kind:"structure",el:null,detail:"both-moved",base:c},{subject:c}),at.has(c)?null:p(P,T);let U=Fe(K,c),_=Fe(D,c);(!U||!_)&&pe({kind:"structure",el:null,detail:"move-beats-delete",base:c},{subject:c,deleted:U?"remote":"local"});let q=It(c,U,_,!1);return(T==="local"?H:fe)({kind:"move",el:q,source:T}),q}function Jt(c,T,P,U){return U||!T||T===P?{el:P,asBase:!0,twin:_=>_,baseOf:_=>_,units:i(P),here:()=>!0,parentOfTwin:()=>P}:{el:T,asBase:!1,twin:_=>Fe(c,_),baseOf:_=>c.reverse.get(_),units:i(T),here:_=>Qe(_)?_.parentNode===T||T.tagName==="TEMPLATE"&&_.parentNode===T.content:_.parent===T||T.tagName==="TEMPLATE"&&_.parent===T.content}}function Dt(c,T,P){return!T||P&&P.identical.has(c)?!1:Qe(c)?!l.equalUnits(c,T):c.value!==T.value}function It(c,T,P,U,_=!1){let q=U||n.remoteWins(c),Y=c.namespaceURI&&c.namespaceURI!=="http://www.w3.org/1999/xhtml"?V.createElementNS(c.namespaceURI,c.tagName):V.createElement(c.tagName),ce={base:c,local:T||null,remote:P||null};if(ye.set(Y,ce),se.add(c),at.add(c),T&&se.add(T),P&&se.add(P),n.skipUnchanged&&!_&&(n.localIsBase||K.identical.has(c))&&P&&D.identical.has(c)&&!n.remoteWins(c)){ce.unchanged=!0;for(let Ee of c.attributes)Ee.namespaceURI?Y.setAttributeNS(Ee.namespaceURI,Ee.name,Ee.value):Y.setAttribute(Ee.name,Ee.value);return Y}ft.add(c),_||v(c,q?c:T,P,Y);let Se=c.tagName;if(en(c))sn(c,q?c:T,P,Y);else if(Se==="TEXTAREA")Y.textContent=Et(c.textContent,(q?c:T)?(q?c:T).textContent:c.textContent,P?P.textContent:c.textContent,Y,"text");else{let Ee=y(c,T,P,q,Y),Ie=Se==="TEMPLATE"&&Y.content?Y.content:Y;for(let et of Ee)Ie.appendChild(et)}return ft.delete(c),Y}function Et(c,T,P,U,_){if(T===P)return T;if(T===c)return P!==c&&fe({kind:_,node:U,source:"remote"}),P;if(P===c)return H({kind:_,node:U,source:"local"}),T;let q=b==="local"?T:P;return pe({kind:_,node:U,base:c,local:T,remote:P,resolved:q},{site:"whole",el:U}),Oe.push({kind:_,node:U,source:"both"}),q}function sn(c,T,P,U){let _=c.textContent,q=T?T.textContent:_,Y=P?P.textContent:_,ce=N?Gn(c,n.mergeTags,!0):null;if(ce&&q!==Y){let Se=P&&P.getAttribute("merge-key")||c.getAttribute("merge-key"),{text:Ee,warnings:Ie}=wo(n.localIsBase?void 0:_,q,Y,{parse:ce.recognizer.parse,keyCandidates:Se?Se.split(/[\s,]+/).filter(Boolean):void 0});for(let et of Ie)console.warn(`[hyper-morph] merge "${ce.raw}": ${et}`);U.textContent=Ee,Ue.add(U),Ee!==Y?H({kind:"text",node:U,source:Ee===q?"local":"both"}):Ee!==_&&fe({kind:"text",node:U,source:"remote"});return}U.textContent=Et(_,q,Y,U,"text")}function v(c,T,P,U){let _=new Map;for(let q of[c,T,P])if(q)for(let Y of q.attributes)n.ignoreAttribute(q,Y.name)||_.set(Y.name,Y);for(let[q,Y]of _){let ce=c?c.getAttribute(q):null,Se=T?T.getAttribute(q):ce,Ee=P?P.getAttribute(q):ce,Ie;Se===Ee?Ie=Se:Se===ce?(Ie=Ee,fe({kind:"attr",el:U,name:q,source:"remote"})):Ee===ce?(Ie=Se,H({kind:"attr",el:U,name:q,source:"local"})):(Ie=X(q,ce,Se,Ee),Ie===void 0&&(Ie=b==="local"?Se:Ee,pe({kind:"attr",el:U,name:q,base:ce,local:Se,remote:Ee,resolved:Ie},{el:U,sample:Y})),Oe.push({kind:"attr",el:U,name:q,source:"both"})),Ie!=null&&(Y.namespaceURI?U.setAttributeNS(Y.namespaceURI,Y.name,Ie):U.setAttribute(q,Ie))}}function X(c,T,P,U){if(c==="class"){let _=Ee=>new Set((Ee||"").split(/\s+/).filter(Boolean)),q=_(T),Y=_(P),ce=_(U),Se=new Set;for(let Ee of new Set([...q,...Y,...ce])){let Ie=q.has(Ee),et=Y.has(Ee),Be=ce.has(Ee);(et===Be?et:et===Ie?Be:et)&&Se.add(Ee)}return[...Se].join(" ")}if(c==="style"){let _=Ie=>{let et=new Map;if(!Ie)return et;let Be=0,St=null,Ve="",pt=()=>{let it=Ve.indexOf(":");it>0&&et.set(Ve.slice(0,it).trim(),Ve.slice(it+1).trim()),Ve=""};for(let it of Ie){if(St){Ve+=it,it===St&&(St=null);continue}if(it==='"'||it==="'"){St=it,Ve+=it;continue}if(it==="("?Be++:it===")"&&Be--,it===";"&&Be===0){pt();continue}Ve+=it}return Ve.trim()&&pt(),et},q=_(T),Y=_(P),ce=_(U),Se=new Map,Ee=!1;for(let Ie of new Set([...q.keys(),...Y.keys(),...ce.keys()])){let et=q.get(Ie)??null,Be=Y.get(Ie)??null,St=ce.get(Ie)??null,Ve;Be===St?Ve=Be:Be===et?Ve=St:St===et?Ve=Be:(Ve=b==="local"?Be:St,Ee=!0),Ve!=null&&Se.set(Ie,Ve)}return Ee?void 0:[...Se].map(([Ie,et])=>`${Ie}: ${et}`).join("; ")}}function Q(c,T,P,U){let _=c.value,q=U?_:T?T.value:"",Y=P?P.value:"";se.add(c),T&&se.add(T),P&&se.add(P);let ce=Kn(_,q,Y,b),Se=ce.text===""?null:V.createTextNode(ce.text);Se&&(ye.set(Se,{base:c.nodes,local:T?T.nodes:null,remote:P?P.nodes:null}),be.set(Se,ce.mapLocalOffset)),q!==_&&Y!==_?Oe.push({kind:"text",node:Se,source:"both"}):q!==_?H({kind:"text",node:Se,source:"local"}):Y!==_&&fe({kind:"text",node:Se,source:"remote"});for(let Ee of ce.conflicts)pe({kind:"text",node:Se,base:_.slice(Ee.bs,Ee.be),local:Ee.local,remote:Ee.remote,resolved:Ee.resolved},{site:"run",bRun:c,lRun:T,rRun:P,node:Se,c:Ee});return Se}function de(c,T){return Wn(c,T).every(P=>P.bs===P.be)}function ie(c,T){let P=c?c.value:"",U=T?T.value:"",_;if(P===U||!U?_=P:P?de(P,U)?_=U:de(U,P)?_=P:(_=b==="local"?P:b==="both"?P+U:U,pe({kind:"structure",el:null,detail:"insert-collision",local:P,remote:U,resolved:_},{unit:{b:null,l:c,r:T},localLost:b==="remote"})):_=U,c&&se.add(c),T&&se.add(T),_==="")return null;let q=V.createTextNode(_);return ye.set(q,{base:null,local:c?c.nodes:null,remote:T?T.nodes:null}),P?H({kind:"insert",el:q,source:U&&P===U?"both":"local"}):fe({kind:"insert",el:q,source:"remote"}),q}function ue(c,T){let P={ignored:r,remoteWins:n.remoteWins,inlineCache:le},U=ce=>i(ce).every(Se=>Qe(Se)?Bn(Se,P):Se.kind==="text"),_=null;if(U(c)&&U(T)){let ce=c.textContent,Se=T.textContent;ce===Se||de(Se,ce)?_=T:de(ce,Se)&&(_=c)}if(!_){let ce=b==="local",Se=p(ce?c:T,ce?"local":"remote",!0),Ee=ye.get(Se);return ce?Ee.remote=T:Ee.local=c,pe({kind:"structure",el:Se,detail:"insert-collision",local:c,remote:T,resolved:ce?c:T},{unit:{b:null,l:c,r:T},localLost:!ce}),Se}let q=c.namespaceURI&&c.namespaceURI!=="http://www.w3.org/1999/xhtml"?V.createElementNS(c.namespaceURI,c.tagName):V.createElement(c.tagName);v(null,c,T,q),ye.set(q,{base:null,local:c,remote:T}),se.add(c),se.add(T);let Y=Wo({base:Array.from(_.childNodes),local:Array.from(c.childNodes),remote:Array.from(T.childNodes),out:V,policy:b,idOf:{local:R,remote:F},ignored:r,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:ye,textMappers:be,conflicts:He,conflict:pe,scope:{base:null,local:c,remote:T,units:[],at:0},synthetic:!0,decisions:Oe,node:q});ze.push(...Y.segments);for(let ce of Y.nodes)q.appendChild(ce);return q}function p(c,T,P=!1){if(!P&&Qe(c)){let Y=Ge.partner.get(c);if(Y)return bt(c,T,Y)}if(!Qe(c)){if(c.value==="")return null;let Y=c.kind==="comment"?V.createComment(c.value):V.createTextNode(c.value);return ye.set(Y,{base:null,local:T==="local"?c.nodes:null,remote:T==="remote"?c.nodes:null}),se.add(c),Y}let U=c.namespaceURI&&c.namespaceURI!=="http://www.w3.org/1999/xhtml"?V.createElementNS(c.namespaceURI,c.tagName):V.createElement(c.tagName);for(let Y of c.attributes)Y.namespaceURI?U.setAttributeNS(Y.namespaceURI,Y.name,Y.value):U.setAttribute(Y.name,Y.value);ye.set(U,{base:null,local:T==="local"?c:null,remote:T==="remote"?c:null}),se.add(c);let _=c.tagName==="TEMPLATE"&&U.content?U.content:U,q=T==="local"?K:D;for(let Y of i(c)){let ce=Qe(Y)?q.reverse.get(Y):null;if(ce&&at.has(ce)){pe({kind:"structure",el:null,detail:"both-moved",base:ce},{subject:ce});continue}if(ce&&!ft.has(ce)){let Ee=Fe(K,ce)||null,Ie=Fe(D,ce)||null;if(Ee||Ie){let et=It(ce,Ee,Ie,!1);T==="local"?H({kind:"move",el:et,source:"local"}):fe({kind:"move",el:et,source:"remote"}),_.appendChild(et);continue}}let Se=p(Y,T);Se&&_.appendChild(Se)}return U}function y(c,T,P,U,_){T&&K.identical.has(c)&&K.pairIdenticalChildren(c),P&&D.identical.has(c)&&D.pairIdenticalChildren(c);let q=Jt(K,T,c,U),Y=Jt(D,P,c,!1),ce=i(c),Se=new Set(ce),Ee=new Map;for(let J=0;J<ce.length;J++)Ee.set(ce[J],J);let Ie=[],et=new Set,Be=new Map,St=new Set,Ve=new Set,pt=[];zt();let it=J=>{let Re=[];for(let ve of J.units){if(Ve.has(ve))continue;let Ye=J.baseOf(ve);Ye&&Se.has(Ye)&&Re.push(Ye)}return Re},Ft=J=>it(J).map(Re=>Ee.get(Re)),Rt=J=>J.every((Re,ve)=>ve===0||Re>=J[ve-1]),Kt=!q.asBase&&!Rt(Ft(q)),Lt=!Y.asBase&&!Rt(Ft(Y));Kt&&Lt&&pe({kind:"structure",el:_,detail:"both-reordered",base:c},{subject:c,lKept:it(q),rKept:it(Y)});let ut=Lt||!Kt?{V:Y,A:D,side:"remote",other:q,otherA:K,otherSide:"local"}:{V:q,A:K,side:"local",other:Y,otherA:D,otherSide:"remote"};Kt?H({kind:"move",el:null,source:Lt?"both":"local",base:c}):Lt&&fe({kind:"move",el:null,source:"remote",base:c});let At=q.asBase?[]:q.units.filter(J=>!q.baseOf(J)&&!Ve.has(J)&&!Ge.partner.has(J)),Nt=Y.asBase?[]:Y.units.filter(J=>!Y.baseOf(J)&&!Ve.has(J)&&!Ge.partner.has(J)),jt=new Map;if(At.length&&Nt.length){let J=new Map,Re=new Map;for(let De of Nt){if(Qe(De)){let tt=F(De);tt&&J.set(tt,De)}let Ke=l.unitHash(De);Re.has(Ke)||Re.set(Ke,[]),Re.get(Ke).push(De)}let ve=(De,Ke)=>{let tt=De.units.indexOf(Ke);for(let _e=tt-1;_e>=0;_e--){let ot=De.baseOf(De.units[_e]);if(ot)return ot}return"start"},Ye=new Map,lt=new Map;for(let De of Nt){let Ke=ve(Y,De);Qe(De)?(lt.has(Ke)||lt.set(Ke,[]),lt.get(Ke).push(De)):De.kind==="text"&&!Ye.has(Ke)&&Ye.set(Ke,De)}for(let De of At){let Ke=null;if(Qe(De)){let tt=R(De);tt&&J.has(tt)&&!jt.has(J.get(tt))&&(Ke=J.get(tt))}else if(De.kind==="text"){let tt=Ye.get(ve(q,De));tt&&!jt.has(tt)&&(Ke=tt)}if(!Ke){let tt=Re.get(l.unitHash(De));tt&&(Ke=tt.find(_e=>!jt.has(_e)&&Qe(_e)===Qe(De)&&(Qe(_e)?_e.tagName===De.tagName:_e.kind===De.kind)&&l.equalUnits(De,_e))||null)}if(!Ke&&Qe(De)){let tt=k.local(De),_e=(lt.get(ve(q,De))||[]).filter(ot=>{let Zt=k.remote(ot);return!jt.has(ot)&&ot.tagName===De.tagName&&!(tt&&Zt&&tt!==Zt)&&l.similar(De,ot)});_e.length===1&&(Ke=_e[0])}Ke&&(jt.set(Ke,De),jt.set(De,Ke))}}let Qt=J=>{if(se.has(J))return Be.get(J)||null;let Re=q.twin(J),ve=Y.twin(J),Ye=Re&&!q.asBase&&!q.here(Re),lt=ve&&!Y.asBase&&!Y.here(ve);if(Ye||lt){if((!Re||!ve)&&pe({kind:"structure",el:null,detail:"move-beats-delete",base:J},{subject:J,deleted:Re?"remote":"local"}),!G(J))return se.add(J),null;pe({kind:"structure",el:null,detail:"both-moved",base:J},{subject:J})}if(!Re&&!ve)return se.add(J),fe({kind:"remove",source:"both",base:J}),null;if(!Re&&!Dt(J,ve,D))return se.add(J),H({kind:"remove",source:"local",base:J}),null;if(!ve&&!Dt(J,Re,K))return se.add(J),fe({kind:"remove",source:"remote",base:J}),null;let De=!Re||!ve,Ke=q.asBase?Fe(K,J)||null:Re,tt=Y.asBase&&Qe(J)&&(D.identityPaired.has(J)||!k.base(J))&&Fe(D,J)||ve,_e;return Qe(J)?_e=It(J,Ke,tt,q.asBase):J.kind==="comment"?_e=x(J,Ke,ve,q.asBase):_e=Q(J,Ke,ve,q.asBase),se.add(J),_e&&(Be.set(J,_e),Re&&Be.set(Re,_e),ve&&Be.set(ve,_e),De&&(pe({kind:"structure",el:_e,detail:"edit-beats-delete",base:J},{subject:J,deleted:Re?"remote":"local"}),Re?H({kind:"insert",el:_e,source:"local"}):fe({kind:"insert",el:_e,source:"remote"}))),_e},fn=(J,Re,ve,Ye)=>{if(se.has(J))return Be.get(J)||null;let lt=Re.baseOf(J);if(lt&&Se.has(lt))return Ve.has(lt)&&!Ve.has(J)?An(lt,J,Ye):Qt(lt);if(lt)return vn(lt,J,Ye);let De=jt.get(J);if(De){let tt=Ye==="local"?J:De,_e=Ye==="local"?De:J,ot;return Qe(tt)?l.equalUnits(tt,_e)?(ot=p(tt,"local"),ye.get(ot).remote=_e):ot=ue(tt,_e):ot=ie(tt,_e),se.add(tt),se.add(_e),ot&&(Be.set(tt,ot),Be.set(_e,ot),Qe(tt)&&H({kind:"insert",el:ot,source:"both"})),ot}let Ke=p(J,Ye);return Ke&&(Be.set(J,Ke),Ye==="local"?H({kind:"insert",el:Ke,source:"local"}):fe({kind:"insert",el:Ke,source:"remote"})),Ke},An=(J,Re,ve)=>{let Ye;return Qe(J)?(Ye=Xt(J,ve,Re),Ye&&se.add(Re)):(Ye=p(Re,ve),se.add(Re),Ye&&(ve==="local"?H:fe)({kind:"insert",el:Ye,source:ve})),Ye&&Be.set(Re,Ye),Ye},vn=(J,Re,ve)=>{let lt=Fe(ve==="local"?D:K,J),De=Re,Ke=lt?ge(lt,ve==="local"?P:T,ve==="local"?D:K):!1,tt=lt&&!Ke&&!Me(J,lt);if(tt&&ve===ut.otherSide)return pe({kind:"structure",el:null,detail:"both-moved",base:J},{subject:J}),null;if(tt&&pe({kind:"structure",el:null,detail:"both-moved",base:J},{subject:J}),lt||pe({kind:"structure",el:null,detail:"move-beats-delete",base:J},{subject:J,deleted:ve==="local"?"remote":"local"}),ft.has(J)){pe({kind:"structure",el:null,detail:"both-moved",base:J},{subject:J});let ot=p(De,ve);return ot&&Be.set(Re,ot),ot}let _e=Qe(J)?It(J,ve==="local"?De:Fe(K,J)||null,ve==="remote"?De:Fe(D,J)||null,!1):null;return _e&&(Be.set(J,_e),Be.set(Re,_e),lt&&Be.set(lt,_e),ve==="local"?H({kind:"move",el:_e,source:"local"}):fe({kind:"move",el:_e,source:"remote"})),_e};for(let J of ut.V.units){if(Ve.has(J)){let ve=Be.get(J);et.has(ve)||(Ie.push(ve),et.add(ve));continue}if(se.has(J)&&!(Be.get(J)&&et.has(Be.get(J)))){let ve=ut.V.baseOf(J);ve&&!Se.has(ve)&&pe({kind:"structure",el:null,detail:"both-moved",base:ve},{subject:ve});continue}let Re=fn(J,ut.V,ut.A,ut.side);Re&&!et.has(Re)&&(Ie.push(Re),et.add(Re),!ut.V.baseOf(J)&&!jt.has(J)&&!Ve.has(J)&&St.add(Re))}for(let J of pt)et.has(J.frag)||(Ie.splice(kn(J.at),0,J.frag),et.add(J.frag));if(!ut.other.asBase){let J=ut.other,Re=ut.otherSide,ve=ut.otherA,Ye=null,lt=0,De=null;for(let Ke of J.units){let tt=Be.get(Ke);if(tt&&et.has(tt)){Ye=tt,De=null;continue}if(se.has(Ke)){let Zt=J.baseOf(Ke);Zt&&!Se.has(Zt)&&pe({kind:"structure",el:null,detail:"both-moved",base:Zt},{subject:Zt});continue}let _e=fn(Ke,J,ve,Re);if(!_e)continue;let ot;if(De)ot=Ie.indexOf(De)+1;else if(Ye){if(ot=Ie.indexOf(Ye)+1,Re==="remote")for(;ot<Ie.length&&St.has(Ie[ot]);)ot++}else ot=lt++;Ie.splice(ot,0,_e),et.add(_e),De=_e}}for(let J=0;J<ce.length;J++){let Re=ce[J];if(se.has(Re))continue;let ve=Qt(Re);ve&&Ie.splice(kn(J),0,ve)}return Ie;function kn(J){for(let Re=J-1;Re>=0;Re--){let ve=Be.get(ce[Re]);if(ve){let Ye=Ie.indexOf(ve);if(Ye>=0)return Ye+1}}return 0}function rn(J){let Re={ignored:r,remoteWins:()=>!1},ve=ke=>J(ke)||Qe(ke)&&n.remoteWins(ke)&&wn.has(ke.tagName)&&Bn(ke,Re),Ye=new Map,lt=ke=>{if(!Qe(ke)||!qr.has(ke.tagName))return!1;let Ce=Ye.get(ke);return Ce===void 0&&(Ce=!r(ke)&&!n.remoteWins(ke)&&i(ke).every(ve),Ye.set(ke,Ce)),Ce},De=ke=>!Qe(ke)&&ke.kind==="text",Ke=null,tt=new Map,_e=ke=>{let Ce=tt.get(ke);if(Ce)return Ce;let We=Qe(ke)?ke.textContent:ke.value;Ce=new Set;let nt=We.toLowerCase();if(!(We.length>Ms))if(/^[\x00-\x7f]*$/.test(nt))for(let $e of nt.split(/[^\p{L}\p{N}]+/u))$e&&Ce.add($e);else for(let $e of Do(nt))/^[\s\p{P}]+$/u.test($e)||Ce.add($e);return tt.set(ke,Ce),Ce},ot=ke=>(Qe(ke)?ke.textContent:ke.value).toLowerCase().replace(/\s+/g," ").trim(),Zt=new Map,En=ke=>{let Ce=Zt.get(ke);if(Ce)return Ce;Ce=new Set(_e(ke));let We=$e=>{if($e)for(let yt of _e($e))Ce.add(yt)},nt=Se.has(ke)?ke:!q.asBase&&q.baseOf(ke)||!Y.asBase&&Y.baseOf(ke);return nt&&(We(nt),We(Fe(K,nt)),We(Fe(D,nt))),Zt.set(ke,Ce),Ce},un=(ke,Ce)=>{let We=ot(Ce),nt=Se.has(ke)?ke:!q.asBase&&q.baseOf(ke)||!Y.asBase&&Y.baseOf(ke),$e=Ut=>We?Ut.split(We).length-1:0;if(nt&&Qe(Ce)&&!Se.has(Ce)){let Ut=$e(ot(nt));for(let Vt of[Fe(K,nt),Fe(D,nt)]){if(!Vt||Vt===Ce||Vt.ownerDocument!==Ce.ownerDocument)continue;let cn=ot(Vt);if(cn.length>We.length&&$e(cn)>=Ut&&(cn.startsWith(We)||cn.endsWith(We)))return!1}}let yt=_e(Ce),kt=En(ke),Pt=0;for(let Ut of yt)kt.has(Ut)&&Pt++;if(yt.size&&Pt*2>=yt.size)return!0;if(!We||We.length>Ms)return!1;let Wt=nt?[ke,nt,Fe(K,nt),Fe(D,nt)]:[ke],nn=(Ut,Vt)=>Ut!==Vt&&(Ut.startsWith(Vt)||Ut.endsWith(Vt));if(Wt.some(Ut=>Ut&&nn(ot(Ut),We)))return!0;if(!Se.has(Ce)||!nt)return!1;let Ot=ot(ke),Sn=ot(nt);return[Fe(K,Ce),Fe(D,Ce)].some(Ut=>{let Vt=Ut&&ot(Ut);return!!Vt&&Ot!==Vt&&(Ot.startsWith(Vt)&&!Sn.startsWith(Vt)||Ot.endsWith(Vt)&&!Sn.endsWith(Vt))})},ln=ke=>{Ke||(Ke=new Set),Ke.add(ke)},Rn=ke=>{ln(ke);for(let[Ce,We]of[[K,q],[D,Y]]){if(We.asBase)continue;let nt=Fe(Ce,ke);nt&&We.here(nt)&&ln(nt)}},Xe=(ke,Ce)=>ke.asBase||ce.every(We=>!Qe(We)||Ce.identical.has(We)&&ke.here(Fe(Ce,We)))&&ke.units.every(We=>!Qe(We)||ke.baseOf(We));if(Xe(q,K)&&Xe(Y,D))return null;let dt=ke=>{if(ke.asBase)return!1;let Ce=-1;for(let We of ke.units){let nt=Qe(We)?ke.baseOf(We):null;if(!nt||!Se.has(nt))continue;let $e=Ee.get(nt);if($e<Ce)return!0;Ce=$e}return!1};if(dt(q)||dt(Y))return null;for(let[ke,Ce]of[[q,K],[Y,D]]){if(ke.asBase||Xe(ke,Ce))continue;let We=ke.units,nt=Ce===K?k.local:k.remote,$e=(Pe,ht)=>{let Mt=Qe(Pe)&&k.base(Pe),xt=Qe(ht)&&nt(ht);return!Mt||!xt||Mt===xt},yt=new Map;for(let Pe=0;Pe<We.length;Pe++)yt.set(We[Pe],Pe);let kt=Pe=>!!Pe&&(Qe(Pe)?ke.here(Pe):yt.has(Pe)),Pt=Pe=>{let ht=ke.twin(Pe);return kt(ht)?ht:null},Wt=ce.filter(Pe=>!ke.twin(Pe)&&lt(Pe)),nn=We.filter(Pe=>!ke.baseOf(Pe)&&lt(Pe)),Ot=(Pe,ht)=>ht===ce?!!Pt(Pe):Se.has(ke.baseOf(Pe)),Sn=Pe=>{let ht=new Int32Array(Pe.length),Mt=new Int32Array(Pe.length),xt=-1;for(let mt=0;mt<Pe.length;mt++)ht[mt]=xt,Ot(Pe[mt],Pe)&&(xt=mt);xt=Pe.length;for(let mt=Pe.length-1;mt>=0;mt--)Mt[mt]=xt,Ot(Pe[mt],Pe)&&(xt=mt);return{prev:ht,next:Mt}},Ut=Sn(We),Vt=Sn(ce),cn=(Pe,ht)=>{Rn(Pe),ln(ht)};for(let Pe of nn){let ht=yt.get(Pe),Mt=Ut.prev[ht],xt=Ut.next[ht],mt=Mt>=0?ke.baseOf(We[Mt]):null,mn=xt<We.length?ke.baseOf(We[xt]):null,_t=mt?Ee.get(mt):-1,On=mn?Ee.get(mn):ce.length;for(let yn=Math.max(0,_t);yn<=Math.min(On,ce.length-1);yn++){let $t=ce[yn];(lt($t)||De($t))&&(!$e($t,Pe)||!un($t,Pe)||(De($t)?ln(Pe):cn($t,Pe)))}}let pn=(Pe,ht,Mt)=>{for(let xt=ht+Mt;xt>=0&&xt<Pe.length;xt+=Mt){let mt=Pe[xt];if(lt(mt))return mt;if(Qe(mt)||mt.value.trim())return null}return null},lo=Pe=>{let ht=new Set;for(let Mt of i(Pe))if(!Qe(Mt)&&Mt.kind==="text")for(let xt of _e(Mt))ht.add(xt);return ht},Un=(Pe,ht)=>{let Mt=_e(ht),xt=new Set;for(let mt of lo(Pe))Mt.has(mt)||xt.add(mt);return xt},eo=(Pe,ht)=>{if(!Pe.size)return!1;let Mt=_e(ht),xt=0;for(let mt of Pe)Mt.has(mt)&&xt++;return xt*2>=Pe.size};for(let Pe of ce){if(Ce.identical.has(Pe)||!lt(Pe))continue;let ht=Pt(Pe);if(!ht||!lt(ht))continue;let Mt=Un(ht,Pe),xt=Un(Pe,ht);for(let mt of[-1,1]){let mn=pn(ce,Ee.get(Pe),mt);mn&&eo(Mt,mn)&&(cn(Pe,ht),Rn(mn));let _t=pn(We,yt.get(ht)??-1,mt);if(_t&&eo(xt,_t)){cn(Pe,ht);let On=ke.baseOf(_t);On?cn(On,_t):ln(_t)}}}for(let Pe of Wt){let ht=Ee.get(Pe),Mt=Vt.prev[ht],xt=Vt.next[ht],mt=Mt>=0?Pt(ce[Mt]):null,mn=xt<ce.length?Pt(ce[xt]):null,_t=mt?yt.get(mt)??-1:-1,On=mn?yt.get(mn)??-1:We.length;for(let yn=Math.max(0,_t);yn<=Math.min(On,We.length-1);yn++){let $t=We[yn];if((lt($t)||De($t))&&!(!$e(Pe,$t)||!un($t,Pe))&&(Rn(Pe),!De($t))){let co=ke.baseOf($t);co?cn(co,$t):ln($t)}}}}if(!Ke)return null;for(let ke of Array.from(Ke))if(Se.has(ke))for(let Ce of[K,D]){let We=Fe(Ce,ke);We&&!ge(We,Ce===K?T:P,Ce)&&!(Ce===K?q:Y).asBase&&(Ke.delete(ke),Ke.delete(Fe(K,ke)),Ke.delete(Fe(D,ke)))}return Ke.size?Ke:null}function zt(){if((q.asBase||K.identical.has(c))&&(Y.asBase||D.identical.has(c)))return;let J={ignored:r,remoteWins:n.remoteWins,inlineCache:le},Re=Xe=>Qe(Xe)?Bn(Xe,J):Xe.kind==="text",ve=rn(Re),Ye=Xe=>ve&&ve.has(Xe)||Re(Xe),lt=ce.map(Ye);if(!lt.includes(!0))return;let De=Xe=>{let dt=Xe.units,ke=new Map;for(let kt=0;kt<dt.length;kt++)ke.set(dt[kt],kt);let Ce=[],We=-1;for(let kt=0;kt<ce.length;kt++){if(lt[kt])continue;let Pt=Xe.twin(ce[kt]),Wt=Pt?ke.get(Pt):void 0;Wt===void 0||Wt<=We||Ye(Pt)||(Ce.push([kt,Wt]),We=Wt)}let nt=[],$e=-1,yt=-1;for(let kt=0;kt<=Ce.length;kt++){let[Pt,Wt]=kt<Ce.length?Ce[kt]:[ce.length,dt.length],nn={bLo:-1,bHi:-1,sLo:-1,sHi:-1,next:Wt};for(let Ot=$e+1;Ot<Pt;Ot++)lt[Ot]&&(nn.bLo<0&&(nn.bLo=Ot),nn.bHi=Ot);for(let Ot=yt+1;Ot<Wt;Ot++)Ye(dt[Ot])&&(nn.sLo<0&&(nn.sLo=Ot),nn.sHi=Ot);nt.push(nn),$e=Pt,yt=Wt}return{units:dt,list:nt}},Ke=De(q),tt=De(Y),_e=[];for(let Xe of[Ke,tt])for(let dt of Xe.list)dt.bLo>=0&&_e.push([dt.bLo,dt.bHi]);_e.sort((Xe,dt)=>Xe[0]-dt[0]);let ot=[];for(let[Xe,dt]of _e){let ke=ot[ot.length-1];ke&&Xe<=ke.hi?ke.hi=Math.max(ke.hi,dt):ot.push({lo:Xe,hi:dt})}let Zt=(Xe,dt)=>{let ke=-1,Ce=-1;for(let $e=0;$e<Xe.list.length;$e++){let yt=Xe.list[$e];yt.bLo<dt.lo||yt.bLo>dt.hi||(ke<0&&(ke=$e),Ce=$e)}let We=1/0,nt=-1;for(let $e=ke;$e>=0&&$e<=Ce;$e++){let yt=Xe.list[$e];yt.sLo>=0&&(We=Math.min(We,yt.sLo),nt=Math.max(nt,yt.sHi)),$e<Ce&&(We=Math.min(We,yt.next),nt=Math.max(nt,yt.next))}return nt<0?[]:Xe.units.slice(We,nt+1)},En=(Xe,dt)=>Xe.length===dt.length&&Xe.every((ke,Ce)=>l.equalUnits(ke,dt[Ce])),un=Xe=>!Qe(Xe)&&Xe.kind==="comment",ln=Xe=>{if(!Xe.length)return[];let dt=($e,yt)=>Qe($e)?$e:$e.nodes[yt?$e.nodes.length-1:0],ke=dt(Xe[0]),Ce=dt(Xe[Xe.length-1],!0),We=$e=>$e&&Qe($e)&&r($e);for(;We(ke.previousSibling);)ke=ke.previousSibling;for(;We(Ce.nextSibling);)Ce=Ce.nextSibling;let nt=[];for(let $e=ke;$e&&(nt.push($e),$e!==Ce);$e=$e.nextSibling);return nt},Rn=Xe=>Xe.some(dt=>Qe(dt)&&r(dt));for(let Xe of ot){let dt=ce.slice(Xe.lo,Xe.hi+1),ke=q.asBase?null:Zt(Ke,Xe),Ce=Y.asBase?null:Zt(tt,Xe);if(dt.some(un)||ke&&ke.some(un)||Ce&&Ce.some(un))continue;let We=ln(ke||dt),nt=ln(Ce||dt);if((!ke||En(dt,ke))&&(!Ce||En(dt,Ce))&&!(ke&&Rn(We)))continue;let $e=Wo({base:ln(dt),local:We,remote:nt,out:V,policy:b,blocks:ve,L:ke?K:Is(K,c),R:Ce?D:Is(D,c),idOf:{local:R,remote:F},ignored:r,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(kt,Pt,Wt)=>It(kt,Pt,Wt,!1),cloneUnit:p,mergeAttrs:v,atomKey:l.exactUnitKey,moveIn:Xt,provenance:ye,textMappers:be,conflicts:He,conflict:pe,scope:{base:c,local:q.asBase?null:q.el,remote:Y.asBase?null:Y.el,units:ce,at:Xe.lo},decisions:Oe,node:_});ze.push(...$e.segments);let yt=V.createDocumentFragment();for(let kt of $e.nodes)yt.appendChild(kt);for(let kt of[...dt,...ke||[],...Ce||[]])se.add(kt),Ve.add(kt),Be.set(kt,yt);pt.push({frag:yt,at:Xe.lo})}}}function E(c,T){let P=ye.get(c);return P&&P.unchanged?!P.remote||P.remote===T?!0:f(P.remote,T):c.tagName!==T.tagName||!W(c,T)?!1:j(C(c),C(T))}function f(c,T){return c===T?!0:c.tagName!==T.tagName||c.namespaceURI!==T.namespaceURI||!W(c,T)?!1:m(C(c),C(T))}function m(c,T){let P=z(c,r),U=z(T,r);if(P.length!==U.length)return!1;for(let _=0;_<P.length;_++){let q=P[_],Y=U[_];if(typeof q=="string"||typeof Y=="string"){if(q!==Y)return!1}else{if(q.nodeType!==Y.nodeType)return!1;if(q.nodeType===1){if(!f(q,Y))return!1}else if(q.nodeValue!==Y.nodeValue)return!1}}return!0}function C(c){return c.tagName==="TEMPLATE"&&c.content?c.content:c}function W(c,T){let P=0;for(let U of c.attributes)if(!n.ignoreAttribute(c,U.name)&&(P++,T.getAttribute(U.name)!==U.value))return!1;for(let U of T.attributes)n.ignoreAttribute(T,U.name)||P--;return P===0}function j(c,T){let P=z(c,_=>{let q=ye.get(_);return!!(q&&q.pinned)}),U=z(T,r);if(P.length!==U.length)return!1;for(let _=0;_<P.length;_++){let q=P[_],Y=U[_];if(typeof q=="string"||typeof Y=="string"){if(q!==Y)return!1}else{if(q.nodeType!==Y.nodeType)return!1;if(q.nodeType===1){if(!E(q,Y))return!1}else if(q.nodeValue!==Y.nodeValue)return!1}}return!0}function z(c,T){let P=[],U=null;for(let _=c.firstChild;_;_=_.nextSibling){if(_.nodeType===3){U=U===null?_.nodeValue:U+_.nodeValue;continue}_.nodeType===1&&T(_)||(U!==null&&(U!==""&&P.push(U),U=null),P.push(_))}return U!==null&&U!==""&&P.push(U),P}function x(c,T,P,U){let _=c.value,q=U?_:T?T.value:"",Y=P?P.value:"";se.add(c),T&&se.add(T),P&&se.add(P);let ce=q===Y?q:q===_?Y:Y===_||b==="local"?q:Y,Se={site:"comment",bRun:c,lRun:T,rRun:P,node:null};if(q!==_&&Y!==_&&q!==Y&&pe({kind:"text",node:null,base:_,local:q,remote:Y,resolved:ce},Se),!T&&!P)return null;let Ee=V.createComment(ce);return Se.node=Ee,ye.set(Ee,{base:c.nodes,local:T?T.nodes:null,remote:P?P.nodes:null}),Ee}function S(c,T){let P=Fe(T,c);if(!P)return null;let U=Qe(P)?P.parentNode:P.parent,_=Qe(c)?c.parentNode:c.parent;return Fe(T,_)===U?null:T.reverse.get(U)||null}function G(c){let T=new Set([c]),P=c;for(let U=0;U<64;U++){let _=S(P,K)||S(P,D);if(!_)return!1;if(_===c||Qe(c)&&Qe(_)&&c.contains(_)||T.has(_))return!0;T.add(_),P=_}return!0}function ge(c,T,P){if(!T)return!1;let U=Qe(c)?c.parentNode:c.parent;return U===T||T.tagName==="TEMPLATE"&&U===T.content}function Me(c,T){let P=te(c),U=Fe(K,P);if(U&&ge(T,U,K))return!0;let _=Fe(D,P);return!!(_&&ge(T,_,D))}}function Is(e,o){return e.map.get(o)?Ls():{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 Ls(){let e={get:o=>o,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Cs=new Set(["INPUT","OPTION","TEXTAREA"]),Go=/[\t\n\f\r ]+/;function Es(e,o,t,n){let r=e.ownerDocument,{provenance:a,textMappers:l}=t,i=n.hooks,u=[],A=[],N=[],h=new Set,M=[],L=[],R=new Map,F=new Set,k=new Map,d=t.conflicts.length>0,w=new Map,Z=new Set,he=new Map,xe=(v,X)=>{let Q=he.get(v);Q||he.set(v,Q=new Set),Q.add(X)},ee=d?new Set:null,oe=(v,X,Q)=>{let de=i.beforeAttributeUpdated(v,X,Q);return d&&de===!1&&xe(X,v),de},re=v=>!!v&&(v===e||e.contains(v)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(v)),ne=new Map,K=new Map,D=new Map,Ne=new Set,ae=new Map;(function v(X){let Q=a.get(X);if(Q){if(X.nodeType===1){let ie=Q.local?n.toLive(Q.local):null;ie&&re(ie)&&ie.nodeType===1&&(ne.set(X,ie),K.set(ie,X))}else if(Array.isArray(Q.local)){let ie=be(Q.local,Q.local.map(ue=>n.toLive(ue)).filter(ue=>ue&&re(ue)&&ue.nodeType===X.nodeType));if(ie.length&&(ne.set(X,ie[0]),K.set(ie[0],X),D.set(X,ie)),Array.isArray(Q.caret))for(let ue of Q.caret){let p=n.toLive(ue.node);if(!p||!re(p)||p.nodeType!==3)continue;let y=ae.get(p);Array.isArray(y)||ae.set(p,y=[]),y.push({merged:X,from:ue.from,to:ue.to,flatStart:ue.flatStart})}else{let ue=0;for(let p of ie)ae.set(p,{merged:X,shift:ue}),ue+=p.nodeValue.length}}}let de=X.nodeType===1&&X.tagName==="TEMPLATE"&&X.content?X.content.childNodes:X.childNodes;for(let ie of de)v(ie)})(o);let te=new Set;for(let v of ne.values())te.add(v);for(let v of D.values())for(let X of v)te.add(X);for(let v of t.segments||[])Oe(v);let V=n.restoreFocus===!1?null:Kr(r,ae);n.childrenOnly?se(He(e),He(o)):Ue(e,o);for(let{node:v,parent:X}of M)h.has(v)||!v.parentNode||v.nodeType===1&&(n.ignored(v)||at(v))||je(v,X);return Wr(r,V,ae,l,D,k,Ne),{applied:u,moved:A,replaced:N,identities:L,mergedScriptsLive:F,liveOf:ne,heldBy:k,runOf:D,keptRuns:Ne,insertedLive:w,vetoed:Z,vetoedAttrs:he,removedVetoes:ee};function ye(v,X){let Q=v.slice(X.bs,X.be),de=0;for(;de<Q.length&&de<X.text.length&&Q[de]===X.text[de];)de++;let ie=0;for(;ie<Q.length-de&&ie<X.text.length-de&&Q[Q.length-1-ie]===X.text[X.text.length-1-ie];)ie++;return{bs:X.bs+de,be:X.be-ie,text:X.text.slice(de,X.text.length-ie)}}function be(v,X){if(!X.length)return X;let Q=[];for(let ue of v){let p=ue.parentNode;if(!p)continue;let y=R.get(p);if(!y){y=new Set;for(let E=p.firstChild;E;E=E.nextSibling)E.nodeType===3&&y.add(n.toLive(E));R.set(p,y)}Q.includes(y)||Q.push(y)}let de={has:ue=>Q.some(p=>p.has(ue))},ie=[];for(let ue of X){ie.push(ue);for(let p=ue.nextSibling;p&&p.nodeType===3&&!de.has(p)&&!ie.includes(p);p=p.nextSibling)ie.push(p)}return ie}function Oe(v){let X=[];for(let x of v.localNodes){let S=n.toLive(x.node);if(!S||!re(S)||S.nodeType!==3)return;X.push(S)}let Q=be(v.localNodes.map(x=>x.node),X);if(!Q.length)return;let de=Q.map(x=>x.nodeValue).join(""),{flatLocal:ie,lToM:ue,mapLocal:p}=v;if(de===ie)return;let y=v.textNodes.map(x=>({node:x.node,ms:x.ms,me:x.me})),E=[],f=0;for(let x of Q)E.push(f),f+=x.nodeValue.length;let m=(x,S)=>Q.find((G,ge)=>E[ge]<=x&&x+S<=E[ge]+G.nodeValue.length)||null,C=[],W=0;for(let x of Wn(ie,de).map(S=>ye(ie,S))){let S=x.bs+W;W+=x.text.length-(x.be-x.bs);let G,ge;if(x.be>x.bs){G=ue[x.bs];let Me=G>=0;for(let c=x.bs;Me&&c<x.be;c++)ue[c]!==G+(c-x.bs)&&(Me=!1);if(!Me)continue;ge=G+(x.be-x.bs)}else{let Me=x.bs>0?ue[x.bs-1]:0,c=x.bs<ie.length?ue[x.bs]:0;if(Me<0||c<0)continue;G=ge=p(x.bs)}C.push({ms:G,me:ge,text:x.text,live:ge===G?m(S,x.text.length):null})}C.sort((x,S)=>S.ms-x.ms);let j=(x,S)=>(D.get(x.node)||[ne.get(x.node)]).includes(S),z=x=>!!x&&x.nodeType===1&&wn.has(x.tagName);for(let x of C){let S=y.find(ge=>ge.ms<=x.ms&&x.me<=ge.me&&x.ms<ge.me);if(S&&x.live&&S.ms===x.ms&&!j(S,x.live)){let ge=y.find(Me=>Me.me===x.ms&&j(Me,x.live));ge&&(S=ge)}if(!S&&x.me===x.ms){let ge=y.find(P=>P.me===x.ms),Me=y.find(P=>P.ms===x.ms),c=ge||Me;if(!c)continue;let T=c.node;for(;z(T.parentNode)&&(ge?T.parentNode.lastChild:T.parentNode.firstChild)===T;)T=T.parentNode;if(T===c.node)S=c;else{let P=T.ownerDocument.createTextNode(x.text);T.parentNode.insertBefore(P,ge?T.nextSibling:T);continue}}if(!S)continue;let G=S.node.nodeValue;S.node.nodeValue=G.slice(0,x.ms-S.ms)+x.text+G.slice(x.me-S.ms),S.me+=x.text.length-(x.me-x.ms)}}function He(v){return v.nodeType===1&&v.tagName==="TEMPLATE"&&v.content?v.content:v}function Ue(v,X){h.add(v);let Q=a.get(X);if(Q&&Q.remote&&t.remoteIdOf){let ie=t.remoteIdOf(Q.remote);ie&&L.push([v,ie])}if(Q&&Q.unchanged){t.customIdentity&&Q.remote&&H(v,Q.remote),Q.remote&&b(v,Q.remote);return}if(i.beforeNodeMorphed(v,X)===!1){Z.add(X);return}tn(v,X,n.keepLiveOnly&&Q&&Q.local&&Q.local.nodeType===1&&Q.local!==v?Q.local:null);let de=v.tagName;if(en(v))v.textContent!==X.textContent&&(u.push({kind:"text",node:v,before:v.textContent,after:X.textContent}),v.textContent=X.textContent),t.mergedScripts.has(X)&&F.add(v);else if(de==="TEXTAREA")sn(v,X,Q);else{It(v,X,Q);let ie=de==="TEMPLATE"&&v.content?v.content:v,ue=de==="TEMPLATE"&&X.content?X.content:X;n.protectFocusedValue==="subtree"&&Xt(v)&&v!==r.body?ze(ie):se(ie,ue)}i.afterNodeMorphed(v,X)}function ze(v){for(let X=v.firstChild;X;X=X.nextSibling){let Q=K.get(X);Q&&ne.get(Q.parentNode)!==v||(h.add(X),X.nodeType===1&&ze(X))}}function se(v,X){let Q=pe(v.firstChild),de=new Set;for(let ie of Array.from(X.childNodes)){let ue=ne.get(ie);ue&&h.has(ue)&&!de.has(ue)&&(ue=null);let p=a.get(ie);if(p&&p.pinned){ue&&ue.nodeType===1&&((ue.parentNode!==v||pe(ue.nextSibling)!==Q)&&Ge(v,ue,Q),h.add(ue),de.add(ue));continue}if(ue&&ue.nodeType===1){if(ue!==Q){let f=ue.parentNode;if(f===v&&Q&&Jt(ue)){let m=ue.nextSibling;for(let C=Q;C&&C!==ue;){let W=C.nextSibling;Ge(v,C,m),C=W}}else Ge(v,ue,Q),f!==v&&(A.push(ue),u.push({kind:"move",el:ue,from:f,to:v}))}de.add(ue),Ue(ue,ie),Q=pe(ue.nextSibling);continue}if(ue&&ue.nodeType!==1){let f=D.get(ie)||[ue],m=f.map(W=>W.nodeValue).join(""),C=ie.nodeValue;if(ie.nodeType===3){let W=ft(ie);W!=null&&m!==W&&(C=Kn(W,m,ie.nodeValue).text)}if(f.length>1&&m===C&&!f.includes(Q,1)&&f.every((W,j)=>W.parentNode===v&&(j===0||f[j-1].nextSibling===W))){if(ue!==Q)for(let W of f)Ge(v,W,Q);i.beforeNodeMorphed(ue,ie)!==!1?i.afterNodeMorphed(ue,ie):d&&Z.add(ie);for(let W of f)h.add(W),de.add(W);k.set(ie,ue),Ne.add(ie),Q=pe(f[f.length-1].nextSibling);continue}ue!==Q&&Ge(v,ue,Q),i.beforeNodeMorphed(ue,ie)!==!1?(ue.nodeValue!==C&&(u.push({kind:"text",node:ue,before:ue.nodeValue,after:C}),ue.nodeValue=C),i.afterNodeMorphed(ue,ie)):Z.add(ie),h.add(ue),de.add(ue),k.set(ie,ue),Q=pe(ue.nextSibling);continue}if(ie.nodeType===3&&Q&&Q.nodeType===3&&!h.has(Q)&&!ae.has(Q)){Q.nodeValue!==ie.nodeValue&&(u.push({kind:"text",node:Q,before:Q.nodeValue,after:ie.nodeValue}),Q.nodeValue=ie.nodeValue),h.add(Q),k.set(ie,Q),Q=pe(Q.nextSibling);continue}let y=a.get(ie),E=Ze(y&&y.unchanged&&y.remote?y.remote:ie);if(i.beforeNodeAdded(E)===!1){Z.add(ie);continue}v.insertBefore(E,Q),h.add(E),d&&w.set(ie,E),E.nodeType===3&&k.set(ie,E),E.nodeType===1&&(N.push(E),we(E,ie),t.customIdentity&&y&&y.unchanged&&y.remote&&H(E,y.remote),en(E)||rt(E,ie),n.formState==="property"&&Dt(y)&&b(E,y.remote)),Q=pe(E.nextSibling),u.push({kind:"insert",node:E,parent:v}),i.afterNodeAdded(E)}for(let ie of Array.from(v.childNodes))h.has(ie)||de.has(ie)||ie.nodeType===1&&(n.ignored(ie)||at(ie))||(te.has(ie)?M.push({node:ie,parent:v}):je(ie,v))}function at(v){return n.preserve&&v.parentNode&&v.parentNode.nodeType===1&&v.parentNode.tagName==="HEAD"&&n.preserve(v)===!0}function ft(v){let X=a.get(v);return!X||!Array.isArray(X.local)?null:X.local.map(Q=>Q.nodeValue).join("")}function le(v){return a.get(v)}function b(v,X){if(!Cs.has(v.tagName)&&!v.querySelector("input,option,textarea"))return;let Q=(de,ie)=>{if(de.tagName!==ie.tagName)return;de.tagName==="TEXTAREA"?sn(de,ie,{remote:ie}):Cs.has(de.tagName)&&It(de,ie,{remote:ie});let ue=fe(de),p=fe(ie);if(ue.length===p.length)for(let y=0;y<ue.length;y++)Q(ue[y],p[y])};Q(v,X)}function H(v,X){let Q=fe(v),de=fe(X);if(Q.length===de.length)for(let ie=0;ie<Q.length;ie++){let ue=t.remoteIdOf(de[ie]);ue&&L.push([Q[ie],ue]),H(Q[ie],de[ie])}}function fe(v){let X=v.tagName==="TEMPLATE"&&v.content?v.content:v;return Array.from(X.children).filter(Q=>!n.ignored(Q))}function we(v,X){if(!t.remoteIdOf)return;let Q=(de,ie)=>{let ue=a.get(ie);if(ue&&ue.remote&&ie.nodeType===1){let E=t.remoteIdOf(ue.remote);E&&L.push([de,E])}let p=de.childNodes,y=ie.childNodes;for(let E=0;E<p.length&&E<y.length;E++)Q(p[E],y[E])};Q(v,X)}function pe(v){for(;v&&v.nodeType===1&&n.ignored(v);)v=v.nextSibling;return v}function Ge(v,X,Q){if(typeof v.moveBefore=="function"&&X.ownerDocument===v.ownerDocument)try{v.moveBefore(X,Q);return}catch{}v.insertBefore(X,Q)}function je(v,X){if(i.beforeNodeRemoved(v)===!1){d&&ee.add(v);return}v.parentNode.removeChild(v),u.push({kind:"remove",node:v,parent:X}),i.afterNodeRemoved(v)}function Ze(v){if(en(v))return no(v,r);let X=r.importNode(v,!0);if(X.nodeType===1)for(let Q of Array.from(X.querySelectorAll("script")))en(Q)&&Q.replaceWith(no(Q,r));return X}function rt(v,X){let Q=v.tagName==="TEMPLATE"&&v.content?v.content:v,de=X.tagName==="TEMPLATE"&&X.content?X.content:X,ie=Array.from(Q.childNodes),ue=Array.from(de.childNodes);for(let p=0;p<ue.length&&p<ie.length;p++){let y=ue[p],E=ie[p],f=ne.get(y);f&&h.has(f)&&(f=null);let m=a.get(y);if(m&&m.pinned){if(f&&f.nodeType===1){let C=f.parentNode;Ge(Q,f,E),C!==Q&&(A.push(f),u.push({kind:"move",el:f,from:C,to:Q})),h.add(f)}E.remove();continue}if(f){let C=f.parentNode;Ge(Q,f,E),E.remove(),f.nodeType===1?(C!==Q&&(A.push(f),u.push({kind:"move",el:f,from:C,to:Q})),Ue(f,y)):(h.add(f),k.set(y,f),f.nodeValue!==y.nodeValue&&(u.push({kind:"text",node:f,before:f.nodeValue,after:y.nodeValue}),f.nodeValue=y.nodeValue));continue}h.add(E),d&&w.set(y,E),E.nodeType===3&&k.set(y,E),m&&m.unchanged&&m.remote?(wt(E,m.remote),t.customIdentity&&H(E,m.remote)):y.nodeType===1&&!en(y)&&rt(E,y)}}function wt(v,X){let Q=v.tagName==="TEMPLATE"&&v.content?v.content:v,de=X.tagName==="TEMPLATE"&&X.content?X.content:X;for(let ie of Array.from(de.childNodes))Q.appendChild(Ze(ie))}function bt(v,X){return X.namespaceURI?v.getAttributeNS(X.namespaceURI,X.localName):v.getAttribute(X.name)}function Tt(v,X){let Q=new Set((X||"").split(Go).filter(Boolean));return(v||"").split(Go).filter(de=>de&&!Q.has(de))}function tn(v,X,Q){for(let de of Array.from(X.attributes)){if(Fe(v,de.name)||n.ignoreAttribute(v,de.name))continue;let ie=bt(v,de);if(ie===de.value||Q&&bt(Q,de)===de.value)continue;let ue=de.value;if(Q&&de.name==="class"&&!de.namespaceURI){let p=de.value.split(Go).filter(Boolean),y=Tt(ie,Q.getAttribute("class")).filter(E=>!p.includes(E));y.length&&(ue=[...p,...y].join(" "))}if(ie!==ue){if(i.beforeAttributeUpdated(de.name,v,"update")===!1){d&&xe(X,de.name);continue}de.namespaceURI?v.setAttributeNS(de.namespaceURI,de.name,ue):v.setAttribute(de.name,ue),u.push({kind:"attr",el:v,name:de.name,before:ie,after:ue})}}for(let de of Array.from(v.attributes)){if(Fe(v,de.name)||n.ignoreAttribute(v,de.name)||(de.namespaceURI?X.hasAttributeNS(de.namespaceURI,de.localName):X.hasAttribute(de.name)))continue;if(Q&&de.name==="class"&&!de.namespaceURI){let p=Tt(de.value,Q.getAttribute("class"));if(p.length){let y=p.join(" ");if(y===de.value)continue;if(i.beforeAttributeUpdated("class",v,"update")===!1){d&&xe(X,"class");continue}v.setAttribute("class",y),u.push({kind:"attr",el:v,name:"class",before:de.value,after:y});continue}}if(Q&&bt(Q,de)===null)continue;if(i.beforeAttributeUpdated(de.name,v,"remove")===!1){d&&xe(X,de.name);continue}let ue=de.value;de.namespaceURI?v.removeAttributeNS(de.namespaceURI,de.localName):v.removeAttribute(de.name),u.push({kind:"attr",el:v,name:de.name,before:ue,after:null})}}function Fe(v,X){let Q=v.tagName;return Q==="INPUT"?X==="value"||X==="checked"||X==="disabled":Q==="OPTION"?X==="selected":!1}function Xt(v){return v===r.activeElement}function Jt(v){let X=r.activeElement;return!!X&&X!==r.body&&v.contains(X)}function Dt(v){let X=v&&v.remote;return X&&X.nodeType===1?X:null}function It(v,X,Q){let de=v.tagName,ie=Dt(Q),ue=n.formState==="property"&&ie?ie:X;if(de==="INPUT"){let p=n.protectFocusedValue&&Xt(v),y=(v.getAttribute("type")||"").toLowerCase(),E=y!=="file"&&y!=="checkbox"&&y!=="radio",f=ie&&ie.hasAttribute("value")&&ie.value!==ie.getAttribute("value")?ie.value:null;if(E&&!p)if(n.formState==="property"){let m=X.getAttribute("value"),C=v.getAttribute("value");(C!==m||v.value!==ue.value)&&oe("value",v,m==null?"remove":"update")!==!1&&(C!==m&&(m==null?v.removeAttribute("value"):v.setAttribute("value",m),u.push({kind:"attr",el:v,name:"value",before:C,after:m})),v.value!==ue.value&&(v.value=ue.value))}else if(X.hasAttribute("value")||f!=null){let m=f??X.getAttribute("value");v.getAttribute("value")!==m&&oe("value",v,"update")!==!1?(v.setAttribute("value",m),v.value!==m&&(v.value=m),u.push({kind:"attr",el:v,name:"value",before:null,after:m})):v.value!==m&&v.getAttribute("value")===m&&(v.value=m)}else(v.hasAttribute("value")||v.value!=="")&&oe("value",v,"remove")!==!1&&(v.removeAttribute("value"),v.value="",u.push({kind:"attr",el:v,name:"value",before:"",after:null}));if(!E&&y!=="file"){let m=X.getAttribute("value");m==null?v.hasAttribute("value")&&oe("value",v,"remove")!==!1&&v.removeAttribute("value"):v.getAttribute("value")!==m&&oe("value",v,"update")!==!1&&v.setAttribute("value",m)}p||(Et(v,ue,"checked"),n.formState==="property"&&v.indeterminate!==ue.indeterminate&&(v.indeterminate=ue.indeterminate)),Et(v,ue,"disabled")}else if(de==="OPTION"){let p=v.parentNode&&v.closest("select");n.protectFocusedValue&&p&&Xt(p)||Et(v,ue,"selected")}}function Et(v,X,Q){let de=n.formState==="property"?!!X[Q]:X.hasAttribute(Q);if(n.formState!=="property"){let ie=v.hasAttribute(Q);if(ie!==de){if(oe(Q,v,de?"update":"remove")===!1)return;de?v.setAttribute(Q,""):v.removeAttribute(Q),u.push({kind:"attr",el:v,name:Q,before:ie?"":null,after:de?"":null})}}v[Q]!==de&&(v[Q]=de)}function sn(v,X,Q){if(n.protectFocusedValue&&Xt(v)||oe("value",v,"update")===!1)return;let de=Dt(Q),ie=X.textContent,ue=de&&de.value!==de.defaultValue?de.value:ie;n.formState!=="property"&&v.textContent!==ie&&(u.push({kind:"text",node:v,before:v.textContent,after:ie}),v.textContent=ie),v.value!==ue&&(v.value=ue)}}function Kr(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 r=e.getSelection&&e.getSelection();if(r&&r.rangeCount){let a=r.getRangeAt(0);n.range={sc:a.startContainer,so:a.startOffset,ec:a.endContainer,eo:a.endOffset}}return n}function Wr(e,o,t,n,r,a,l){if(!o)return;let i=o.el;if(!i.isConnected&&o.id&&(i=e.getElementById(o.id)),!i||!i.isConnected)return;if(e.activeElement!==i)try{i.focus({preventScroll:!0})}catch{}try{i.scrollTop=o.scrollTop,i.scrollLeft=o.scrollLeft}catch{}if(o.selection){try{i.setSelectionRange&&!i.selectionEnd&&o.selection[1]!=null&&i.setSelectionRange(o.selection[0],o.selection[1],o.selection[2]||"none")}catch{}return}if(!o.range)return;let u=(h,M)=>{let L=t.get(h);if(Array.isArray(L)){let R=L.find(w=>M>=w.from&&M<w.to)||L.find(w=>M===w.to)||L[L.length-1],F=a.get(R.merged);if(!F||!F.isConnected)return null;let k=n.get(R.merged),d=k&&k.flat?k.flat(R.flatStart+M):M;return[F,Math.max(0,Math.min(d,F.nodeValue.length))]}if(L&&!l.has(L.merged)){let R=(r.get(L.merged)||[h])[0];if(!R.isConnected)return null;let F=n.get(L.merged),k=L.shift+M,d=F?F(k):k;return[R,Math.max(0,Math.min(d,R.nodeValue.length))]}return h.isConnected?[h,Math.min(M,h.nodeType===3?h.nodeValue.length:h.childNodes.length)]:null},A=u(o.range.sc,o.range.so),N=u(o.range.ec,o.range.eo);if(!(!A||!N))try{let h=e.createRange();h.setStart(A[0],A[1]),h.setEnd(N[0],N[1]);let M=e.getSelection();M.removeAllRanges(),M.addRange(h)}catch{}}var Fr={compared:0},zr=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function $r(e,o,t){let n=0;for(let r of e.attributes)if(!t(e,r.name)&&(n++,o.getAttribute(r.name)!==r.value))return!1;for(let r of o.attributes)t(o,r.name)||n--;return n===0}function Yo(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 Rs(e,o,t,n,r,a,l,i){let u=new Map,A=new Set,N=h=>{if(n(h))return;let M=t(h);M&&(a.add(M),r.has(M)||u.has(M)?A.add(M):u.set(M,h))};for(let h of e)N(h);N(o);for(let h of l||o.querySelectorAll("*"))N(h);for(let h of A)u.delete(h),i.add(h);return u}function Ps(e,o,t,n,r,a){let l=!1;for(let N of r)N.startsWith("merge:")&&(l=!0);if(!l)return[...n];let i=new Map,u=[],A=a===an?so:"*";for(let N of[e,...e.querySelectorAll(A)]){if(t(N))continue;let h=o(N);if(!h||!(n.has(h)||r.has(h)))continue;let M=(i.get(h)||0)+1;i.set(h,M),M===2&&u.push(h)}return u}function Bs({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:r,identity:a,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(!$r(e,o,r.ignoreAttribute))return{bail:"root-attrs"};let{ignored:i,remoteWins:u}=r,A=$o(r.scripts.merge===!1?null:r.scripts.mergeTags,l),N=le=>{let b=A(le);return b!==null?b:a.base(le)||null},h=le=>{let b=A(le);return b!==null?b:a.remote(le)||null},M=[],L=[],R=new Map,F=new Map,k={same:R,differ:F},d=le=>({bail:le,comparisons:k}),w=(le,b,H=!0)=>{if(R.get(le)===b)return!0;if(F.get(le)===b)return!1;if(Fr.compared++,H&&le.isEqualNode(b))return R.set(le,b),!0;let fe=le.nodeType===b.nodeType;if(fe&&le.nodeType===1){if(fe=Yo(le,b),fe){let we=le.firstChild,pe=b.firstChild;for(;we&&pe;we=we.nextSibling,pe=pe.nextSibling)if(!w(we,pe,!1)){fe=!1;break}(we||pe)&&(fe=!1)}}else fe&&(fe=le.isEqualNode(b));return(fe?R:F).set(le,b),fe},Z=e,he=o,xe=!1,ee=()=>{R.set(Z,he);for(let le=0;le<M.length;le++)R.set(M[le],L[le]);return d("equal")};for(;;){let le=Z.childNodes,b=he.childNodes;if(le.length!==b.length)break;let H=rt=>w(le[rt],b[rt])?(R.set(le[rt],b[rt]),!1):!0,fe=-1,we=-1;for(let rt=0;rt<le.length;rt++){if(le[rt].nodeType!==1)continue;let wt=0;for(let bt=le[rt].firstElementChild;bt;bt=bt.nextElementSibling)wt++;wt>=we&&(we=wt,fe=rt)}let pe=[],Ge=!1;for(let rt=0;rt<le.length&&pe.length<2;rt++)rt!==fe&&H(rt)&&pe.push(rt);if(fe>=0&&pe.length<2&&(pe.length===0&&Yo(Z,he)?(pe.push(fe),Ge=!0):H(fe)&&pe.push(fe)),pe.length!==1){if(!xe&&pe.length===0&&Yo(Z,he))return ee();break}let je=le[pe[0]],Ze=b[pe[0]];if(xe=xe||!Ge,xe&&F.set(je,Ze),je.nodeType!==1||Ze.nodeType!==1||je.tagName!==Ze.tagName)break;if(N(je)!==h(Ze)){if(!xe&&w(je,Ze))return ee();break}M.push(Z),L.push(he),Z=je,he=Ze}F.set(Z,he);for(let le=0;le<M.length;le++)F.set(M[le],L[le]);if(Z===e||Z.tagName==="HEAD"||Z.tagName==="BODY")return d("root-level");if(M.length<2||M[1].tagName!=="BODY")return d("not-in-body");if(i(Z)||i(he))return d("ignored-ancestor");if(u(Z)||u(he))return d("remote-wins-ancestor");for(let le of M)if(zr.has(le.tagName))return d("form-ancestor");if(Z.tagName==="SCRIPT"||Z.getElementsByTagName("script").length||he.getElementsByTagName("script").length)return d("script-or-template");let oe=n(Z);if(!oe||oe.nodeType!==1||oe.tagName!==Z.tagName)return d("no-live-twin");if(!t.contains(oe))return d("live-detached");for(let le of M){let b=n(le);if(!b||b.nodeType!==1)return d("ancestor-live")}let re=a.base===an&&a.remote===an&&i===Oo,ne=new Set,K=new Set,D=[],Ne=null,ae=le=>{le&&(ne.has(le)?K.add(le):ne.add(le))},te=(le,b)=>{let H=A(le),fe=H!==null?H:a.base(le)||null;return fe!==(H!==null?H:a.remote(b)||null)?!1:(ae(fe),!0)},V=(le,b)=>{for(let H=le.firstElementChild,fe=b.firstElementChild;H;H=H.nextElementSibling,fe=fe.nextElementSibling){let we=i(H);if(we!==i(fe))return!1;if(!we&&(!te(H,fe)||!V(H,fe)))return!1}return!0},ye=le=>{let b=le+1<M.length?M[le+1]:Z;for(let H=M[le].firstElementChild,fe=L[le].firstElementChild;H;H=H.nextElementSibling,fe=fe.nextElementSibling){if(H===b){let Ge=le+1<M.length?ye(le+1):null;if(Ge)return Ge;continue}let we=i(H);if(we!==i(fe))return"outside-id-changed";if(we)continue;let pe=n(H);if(!pe||pe.nodeType!==1)return"sibling-live";if(D.push([H,fe]),!re&&(!te(H,fe)||!V(H,fe)))return"outside-id-changed";le===0&&H.tagName==="HEAD"&&N(H)&&(Ne=[H,fe])}return null},be=ye(0);if(be)return d(be);let Oe=new Set(M),He=null;if(a.base===an){He=[];for(let le of e.querySelectorAll(so))le===Z||Oe.has(le)||(Z.contains(le)?He.push(le):re&&ae(N(le)))}let Ue=new Set,ze=new Set,se=new Set,at=Rs(M,Z,N,i,ne,Ue,He,ze),ft=Rs(L,he,h,i,ne,Ue,a.remote===an&&he.querySelectorAll(so),se);return Ne&&(K.has(N(Ne[0]))||Ue.has(N(Ne[0])))&&(Ne=null),{scope:{chain:M,root:Z,onChain:Oe,baseIndex:at,remoteIndex:ft,head:Ne,same:R,differ:F,dropped:[...Ps(e,N,i,K,ze,a.base),...Ps(o,h,i,K,se,a.remote)],held:le=>{for(let b=1;b<M.length;b++)if(le.map.get(M[b])!==L[b])return!1;for(let[b,H]of D)if(le.map.get(b)!==H)return!1;return!0}}}}var Hs=Symbol("hyper-morph-duplicate-key"),js=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function ro(e,o){return o.map(t=>{let n=new Map;for(let r of e){if(r.nodeType!==1)continue;let a=t(r);a==null||a===""||n.set(a,n.has(a)?Hs:r)}return n})}function Ds(e,o,t,n){for(let r=0;r<n.length;r++){let a=n[r](e);if(a==null||a===""||o[r].get(a)!==e)continue;let l=t[r].get(a);if(!(!l||l===Hs)&&l.tagName===e.tagName)return l}return null}function Jn(e,o,t){for(let n=0;n<t.length;n++){let r=t[n](e);if(!(r==null||r==="")&&o[n].get(r)===e)return!0}return!1}function Us(e,o,t={}){let n=t.skip||(()=>!1),r=t.ignoreAttr||(()=>!1),a=t.tiers&&t.tiers.length?t.tiers:js,l=null;function i(){return l||(l=ro([e,...e.querySelectorAll("*")],a)),l}let u=null;function A(){return u||(u=ro([o,...o.querySelectorAll("*")],a)),u}function N(ne){return!ne.parentElement||!ne.parentElement.parentElement}function h(ne,K,D){return N(ne)||Jn(ne,i(),a)?(D.push({type:"subtree",el:ne,base:K}),!1):!0}function M(ne,K){let D=[];for(let Ne of ne.attributes)r(ne,Ne.name)||K.getAttribute(Ne.name)!==Ne.value&&D.push(Ne.name);for(let Ne of K.attributes)r(ne,Ne.name)||ne.hasAttribute(Ne.name)||D.push(Ne.name);return D}function L(ne){let K=[],D=null,Ne=()=>{D!==null&&(K.push({nodeType:3,nodeValue:D}),D=null)};for(let ae of ne.childNodes){if(ae.nodeType===3){D=(D===null?"":D)+ae.nodeValue;continue}ae.nodeType===1&&n(ae)||(Ne(),(ae.nodeType===1||ae.nodeType===8)&&K.push(ae))}return Ne(),K}function R(ne,K){if(ne.nodeType!==K.nodeType)return!1;if(ne.nodeType!==1)return!0;if(ne.tagName!==K.tagName)return!1;for(let D of a){let Ne=D(ne),ae=D(K);if(Ne!=null&&Ne!==""&&ae!=null&&ae!==""&&Ne!==ae)return!1}return!0}function F(ne){let K="";for(let D of ne)D.nodeType===3&&D.nodeValue.trim()!==""?K+="\0"+D.nodeValue:D.nodeType===8&&(K+=""+D.nodeValue);return K}function k(ne,K,D){let Ne=L(ne),ae=L(K);if(Ne.length===ae.length){let le=!0;for(let b=0;b<Ne.length;b++)if(!R(Ne[b],ae[b])){le=!1;break}if(le){for(let b=0;b<Ne.length;b++){let H=Ne[b];if(H.nodeType===1){if(d(H,ae[b],D))return!0}else if(H.nodeValue!==ae[b].nodeValue)return!0}return!1}}let te=Ne.filter(le=>le.nodeType===1),V=ae.filter(le=>le.nodeType===1);if(F(Ne)!==F(ae))return!0;let ye=ro(te,a),be=ro(V,a),Oe=[],He=new Set,Ue=[];for(let le of te){let b=Ds(le,ye,be,a);b&&!He.has(b)?(Oe.push([le,b]),He.add(b)):Ue.push(le)}let ze=[];for(let le of Ue)Jn(le,ye,a)?D.push({type:"subtree",el:le,base:null}):ze.push(le);let se=[];for(let le of V)He.has(le)||(Jn(le,be,a)?D.push({type:"deletion",el:le}):se.push(le));if(ze.length!==se.length)return!0;for(let le=0;le<ze.length;le++)if(!R(ze[le],se[le]))return!0;let at=new Map(Oe);for(let le=0;le<ze.length;le++)at.set(ze[le],se[le]);let ft=-1;for(let le of te){let b=at.get(le);if(!b)continue;let H=V.indexOf(b);if(H<ft)return!0;ft=H}for(let le=0;le<ze.length;le++)if(d(ze[le],se[le],D))return!0;for(let[le,b]of Oe)if(d(le,b,D))return!0;return!1}function d(ne,K,D){if(ne.tagName!==K.tagName)return h(ne,K,D);let Ne=M(ne,K),ae=[];if(k(ne,K,ae))return h(ne,K,D);if(Ne.length){if(!N(ne)&&!Jn(K,A(),a))return!0;D.push({type:"attrs",el:ne,names:Ne,base:K})}return D.push(...ae),!1}let w=[],Z=M(e,o);Z.length&&w.push({type:"attrs",el:e,names:Z});let he=(ne,K)=>Array.from(ne.children).find(D=>D.tagName===K)||null,xe=he(e,"HEAD"),ee=he(o,"HEAD");if(xe&&ee){let ne=[];d(xe,ee,ne),ne.length&&w.push({type:"head",el:xe})}else(xe||ee)&&xe&&w.push({type:"head",el:xe});let oe=he(e,"BODY"),re=he(o,"BODY");return oe&&re?d(oe,re,w):oe&&w.push({type:"subtree",el:oe,base:null}),{entries:w}}function Vs(e,o,t={}){let n=t.tiers&&t.tiers.length?t.tiers:js,r=e.documentElement,a=[],l=0,i=d=>({ok:!1,placed:a,held:d,skippedAttrs:l});if(!r)return i(null);function u(d){let w=[d,...d.querySelectorAll("*")];return ro(w,n)}let A=u(r),N=new Map,h=d=>{let w=d.getRootNode(),Z=N.get(w);if(!Z){let he=w.nodeType===9?w.documentElement:w;Z=u(he),N.set(w,Z)}return Z};function M(d){if(!d.parentElement&&d.tagName==="HTML")return r;if(d.parentElement&&!d.parentElement.parentElement&&d.parentElement.tagName==="HTML"){if(d.tagName==="BODY")return e.body||null;if(d.tagName==="HEAD")return e.head||null}return null}function L(d){let w=M(d);return w||Ds(d,h(d),A,n)}function R(d){if(!d)return null;let w=L(d);return w&&w.isConnected?w:null}function F(d){for(let w=0;w<n.length;w++){let Z=n[w](d);Z!=null&&Z!==""&&A[w].set(Z,d)}}for(let d of o){if(d.type!=="deletion")continue;let w=L(d.el);w&&w!==r&&w.remove()}let k=o.filter(d=>d.type!=="deletion").sort((d,w)=>d.el===w.el?0:d.el.compareDocumentPosition(w.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let d of k){if(d.type==="head"){let re=e.importNode(d.el,!0);e.head?e.head.replaceWith(re):r.insertBefore(re,r.firstChild),a.push({entry:d,imported:re});continue}if(d.type==="attrs"){let re=R(d.el)||R(d.base);if(!re){l++;continue}for(let ne of d.names)d.el.hasAttribute(ne)?re.setAttribute(ne,d.el.getAttribute(ne)):re.removeAttribute(ne);continue}let w=d.el;if(M(w))return i(d);let Z=R(w)||R(d.base);if(Z){let re=e.importNode(w,!0);Z.replaceWith(re),F(re),a.push({entry:d,imported:re});continue}if(d.base!=null&&!Jn(d.base,h(d.base),n)||!Jn(w,h(w),n))return i(d);let he=w.parentElement;if(!he)return i(d);let xe=R(he);if(!xe)return i(d);let ee=null;for(let re=w.previousElementSibling;re;re=re.previousElementSibling){let ne=R(re);if(ne&&ne.parentNode===xe){ee=ne;break}}let oe=e.importNode(w,!0);if(ee)xe.insertBefore(oe,ee.nextSibling);else{let re=Array.prototype.indexOf.call(he.children,w);xe.insertBefore(oe,xe.children[re]||null)}F(oe),a.push({entry:d,imported:oe})}return{ok:!0,placed:a,held:null,skippedAttrs:l}}var Gr='[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"]',Yr='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Jr='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Xr(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 Qr(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let r=o;if(r.nodeType===9){let a=e.getAttribute("id");r=a&&r.getElementById(a)||(e.tagName==="BODY"?r.body:e.tagName==="HTML"?r.documentElement:r.body&&r.body.firstElementChild)}if((!r||r.nodeType!==1||r.tagName!==e.tagName)&&(r=Zr(e,o,n)),!!r)return t?Array.from(r.childNodes):r}function Zr(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let r=new Map,a=[n,...n.querySelectorAll("script")];for(let u of a){let A=Gn(u,t);A&&!r.has(A.key)&&r.set(A.key,u.textContent)}if(!r.size)return null;let l=e.cloneNode(!0),i=!1;for(let u of[l,...l.querySelectorAll("script")]){let A=Gn(u,t);A&&r.has(A.key)&&(u.textContent=r.get(A.key),i=!0)}return i?l:null}function _s(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 r=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let a of r)t.body.appendChild(t.adoptNode(a));return t}function Ao(e,o,t={}){let n=t||{};if(!n.head?.block)return qs(e,o,n);try{return qs(e,o,n)}catch(r){return Promise.reject(r)}}function qs(e,o,t){let n=t.policy||"sync",r=n==="raw"?void 0:(u,A)=>Xr(u)||(n==="history"?!(A&&u.matches(Jr))&&u.matches(Yr):u.matches(Gr)),a=t.callbacks||{},l={ignore:r,hooks:a,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 Xn(Object.assign({},l,{live:e,base:t.scripts?.mergeBase||null,remote:_s(o,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let u=Object.assign({},l,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:_s(o,e.ownerDocument)});return Xn(u)}t.morphStyle==="innerHTML"&&(l.children=!0);let i=Qr(e,t.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return i!==void 0&&(l.base=i),vo(e,o,l)}var ei=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),hn=()=>{};function io(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!ei.has(l))throw new TypeError(`unknown option "${l}"`);let t=Object.assign({beforeNodeAdded:hn,afterNodeAdded:hn,beforeNodeRemoved:hn,afterNodeRemoved:hn,beforeNodeMorphed:hn,afterNodeMorphed:hn,beforeAttributeUpdated:hn},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let r=e.formState||"attribute";if(!["attribute","property"].includes(r))throw new TypeError("formState must be attribute or property");let a=e.protectFocusedValue;if(a!==void 0&&typeof a!="boolean"&&a!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");return{ignored:Mo(e.ignore,o),remoteWins:Mo(e.remoteWins,o),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:n,protectFocusedValue:a===void 0?!0:a,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:r,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0}}function Qn(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 an}function Zn(e,o){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=ho(o,e.map),n=typeof e.then=="function"?e.then:an;if(typeof e.first=="function"){let r=e.first;return a=>r(a)||t.get(a)||n(a)}return r=>t.get(r)||n(r)}return an}function Fs(e,o,t,n={}){let r=L=>L&&L.nodeType===9?L.documentElement:L,a=r(o),l=r(t),i=r(e)||a,u=Object.assign({},n);delete u.live,delete u.base,delete u.remote;let A=io(u,[i,a,l].filter(Boolean)),N=n.identity||{},h=Mn(),M=No(i,a,l,{identity:{base:Zn(N.base,i),local:Zn(N.local,a),remote:Zn(N.remote,l)},authored:{base:Qn(N.base),local:Qn(N.local),remote:Qn(N.remote)},skipUnchanged:A.hooks.beforeNodeMorphed===hn&&A.hooks.afterNodeMorphed===hn,ignored:A.ignored,remoteWins:A.remoteWins,ignoreAttribute:A.ignoreAttribute,conflicts:A.conflicts,mergeTags:A.scripts.merge===!1?null:A.scripts.mergeTags,baseURI:a.ownerDocument&&a.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:A.children,stats:h});return delete M.recoveryLinks,M}function Jo({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:r,options:a,identity:l,childrenOnly:i,isDocument:u}){let A=io(a,[e,o,t,n].filter(Boolean));if(A.ignored(e))return{report:Xo(),loads:[]};let N=e.ownerDocument,h=A.scripts.execute?hs(e,A.ignored,N.baseURI):null,M=Mn(),L=A.hooks.beforeNodeMorphed===hn&&A.hooks.afterNodeMorphed===hn,R={identity:{base:Zn(l.base,o||t),local:Zn(l.local,t),remote:Zn(l.remote,n)},authored:{base:Qn(l.base),local:Qn(l.local),remote:Qn(l.remote)},ignored:A.ignored,remoteWins:A.remoteWins,ignoreAttribute:A.ignoreAttribute,conflicts:A.conflicts,mergeTags:A.scripts.merge===!1?null:A.scripts.mergeTags,baseURI:N.baseURI,localIsBase:!o,childrenOnly:i,skipUnchanged:L},F=A.fastPath&&u&&!i&&L&&o===t,k=null,d=null;if(F){let ae=Bs({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:r,o:A,identity:R.identity,baseURI:N.baseURI});R.comparisons=ae.comparisons||ae.scope,ae.bail?d=ae.bail:(k=No(o,t,n,Object.assign({},R,{stats:M,scope:ae.scope})),k||(d="chain-unpaired",M=Mn()))}k||(k=No(o||t,t,n,Object.assign({},R,{stats:M}))),F&&(M.fastPathAttempted=1,M.fastPathTaken=d?0:1,M.fastPathFallback=d),k.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(ae=>A.hooks[ae]!==hn)&&As(k.conflicts,k.recoveryLinks,r),A.beforeApply&&A.beforeApply(k.doc);let w=globalThis.__hyperMorphProfile,Z=w?performance.now():0,he=Es(e,k.root,k,{toLive:r,ignored:A.ignored,ignoreAttribute:A.ignoreAttribute,formState:A.formState,protectFocusedValue:A.protectFocusedValue,restoreFocus:A.restoreFocus,preserve:A.head.preserve,hooks:A.hooks,childrenOnly:i,keepLiveOnly:A.keepLiveOnly});w&&(w.apply=(w.apply||0)+(performance.now()-Z));let xe=[];if(A.head.awaitLoads)for(let ae of he.applied){if(ae.kind!=="insert"||ae.node.nodeType!==1)continue;let te=ae.node;te.tagName==="LINK"&&/\bstylesheet\b/i.test(te.getAttribute("rel")||"")&&te.getAttribute("href")&&te.closest("head")&&xe.push(new Promise(ye=>{te.addEventListener("load",()=>ye()),te.addEventListener("error",()=>ye())}))}let ee=null,oe=null;if(h){let ae=ps(e,h,{ignored:A.ignored,skip:he.mergedScriptsLive,baseURI:N.baseURI,beforeNodeAdded:A.hooks.beforeNodeAdded,afterNodeAdded:A.hooks.afterNodeAdded,trackRecovery:!!k.recoveryLinks});xe.push(...ae.loads),ee=ae.swapped,oe=ae.vetoed}let re=ae=>ee&&ee.get(ae)||ae,ne=ae=>{if(he.keptRuns.has(ae))return he.runOf.get(ae);let te=he.liveOf.get(ae)||he.heldBy.get(ae)||he.insertedLive.get(ae);return te?re(te):null},K=ae=>{let te=ae&&he.liveOf.get(ae);return te?re(te):null},D=ae=>{let te=ae&&ne(ae);return Array.isArray(te)?te[0]:te};if(k.recoveryLinks){let ae=(te,V,ye)=>(V.namespaceURI?te.getAttributeNS(V.namespaceURI,V.localName):te.getAttribute(V.qualifiedName))===ye;Os(k.conflicts,k.recoveryLinks,{lookup:ne,vetoed:he.vetoed,vetoedAttrs:he.vetoedAttrs,removedVetoes:he.removedVetoes,vetoedLive:oe,liveAttr:ae,ignored:A.ignored,liveRoot:e})}return{report:{applied:he.applied,decisions:k.decisions.map(ae=>Object.assign({},ae,{node:ae.node?K(ae.node):null,el:ae.el?K(ae.el):null,applied:!!(ae.node?K(ae.node):ae.el&&K(ae.el))})),conflicts:k.conflicts.map(ae=>Object.assign({},ae,{node:ae.node?ae.kind==="text"&&ae.recovery.subject.nodeType===8?D(ae.node):K(ae.node):ae.node,el:ae.el?ae.kind==="structure"?D(ae.el):K(ae.el):ae.el})),localDiverged:k.localDiverged,identities:he.identities,moved:he.moved,replaced:he.replaced,stats:M},loads:xe}}var Ks=new WeakMap;function Xo(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Mn()}}function Xn(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let n=Ks.get(t);n||(n=uo(t),Ks.set(t,n));let r=n("remote",o.remote),a=typeof o.base=="string"&&o.base===""?null:o.base,l=a?n("base",a):null,i=o.local?o.local.root:t.documentElement,u=o.local?o.local.toLive:h=>h;Qo(t,r);let{report:A,loads:N}=Jo({liveRoot:t.documentElement,baseRoot:l?l.documentElement:null,localRoot:i,remoteRoot:r.documentElement,toLive:u,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(N).then(()=>A)}function zs(e,o,t={}){return Xn(Object.assign({},t,{live:e,base:null,remote:o}))}function Ws(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 a=fo(e,o),l=n[1].toLowerCase()==="html"?a.documentElement:a.body;return{root:l,first:l}}let r=o.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let n=o.createElement("template"),r=e.isConnected;return n.content.appendChild(r?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 vo(e,o,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let n=e.ownerDocument,{base:r,...a}=t,l=!!a.children;if(io(a,[e]).ignored(e))return Promise.resolve(Xo());let i=Ws(o,n),u=r!=null?Ws(r,n):null,A,N=null;if(l)A=i.root,N=u?u.root:null;else{if(A=i.first,N=u?u.first:null,!A){let L=io(a);return L.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),L.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Mn()})}if(A.tagName!==e.tagName){let L=io(a,[e,A]);if(L.hooks.beforeNodeMorphed(e,A)===!1)return Promise.resolve(Xo());let R=Jo({liveRoot:e,baseRoot:N&&N.tagName===e.tagName?N:null,localRoot:e,remoteRoot:A,toLive:k=>k,options:a,identity:a.identity||{},childrenOnly:!0,isDocument:!1}),F=en(A)?no(A,n):n.importNode(A,!1);if(!en(F))for(;e.firstChild;)F.appendChild(e.firstChild);return L.hooks.beforeNodeAdded(F)===!1?(To(R.report.conflicts,e,e),Promise.resolve(R.report)):L.hooks.beforeNodeRemoved(e)===!1?(To(R.report.conflicts,e,e),Promise.resolve(R.report)):(e.replaceWith(F),To(R.report.conflicts,e,F),L.hooks.afterNodeRemoved(e),L.hooks.afterNodeAdded(F),L.hooks.afterNodeMorphed(e,A),R.report.replaced.push(F),R.report.applied.push({kind:"insert",node:F,parent:F.parentNode},{kind:"remove",node:e,parent:F.parentNode}),Promise.all(R.loads).then(()=>R.report))}}let{report:h,loads:M}=Jo({liveRoot:e,baseRoot:N,localRoot:e,remoteRoot:A,toLive:L=>L,options:a,identity:a.identity||{},childrenOnly:l,isDocument:!1});return Promise.all(M).then(()=>h)}var ti={mergeDocument:Xn,morphDocument:zs,morphElement:vo,merge3:Fs,morph:Ao};return Qs(ni);})();
5
5
 
6
6
  var morph = HyperMorph.morph;
7
7