hyper-html-api 0.10.0 → 0.10.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.
@@ -1,6 +1,8 @@
1
- var HyperHtmlApi=(()=>{var Rr=Object.defineProperty;var Ul=Object.getOwnPropertyDescriptor;var Hl=Object.getOwnPropertyNames;var Wl=Object.prototype.hasOwnProperty;var Lr=(e,n)=>{for(var t in n)Rr(e,t,{get:n[t],enumerable:!0})},Vl=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Hl(n))!Wl.call(e,r)&&r!==t&&Rr(e,r,{get:()=>n[r],enumerable:!(o=Ul(n,r))||o.enumerable});return e};var _l=e=>Vl(Rr({},"__esModule",{value:!0}),e);var lf={};Lr(lf,{applyData:()=>Ks,cms:()=>Cl,default:()=>sf,engine:()=>lr,extractData:()=>$s,upgrade:()=>Rl});var ur={};Lr(ur,{fromString:()=>fr,getRuleAtPath:()=>Pr,getValueAtPath:()=>Uo,parseConfigKey:()=>$l,setAtPath:()=>Yn,toConfigKey:()=>Fl,toString:()=>An});function An(e){return e.map(String).join(".")}function Fl(e){return e.map(n=>typeof n=="number"?"*":String(n)).join(".")}function $l(e){return e===""?[]:e.split(".")}function fr(e){return e===""?[]:e.split(".").map(n=>/^\d+$/.test(n)?Number(n):n)}function Pr(e,n){let t=e;for(let o of n){if(t==null||typeof t=="string")return;if(Array.isArray(t)){if(typeof o!="number"&&o!=="*")return;t=t[1];continue}if(typeof t=="object"){if(typeof o=="number"||!(o in t))return;t=t[o];continue}return}return t}function Uo(e,n){let t=e;for(let o of n){if(t==null)return;t=t[o]}return t}function Yn(e,n,t){if(n.length===0)return t;let[o,...r]=n;if(typeof o=="number"){let c=Array.isArray(e)?[...e]:[];return c[o]=Yn(c[o],r,t),c}return{...e&&typeof e=="object"?e:{},[o]:Yn((e||{})[o],r,t)}}function go(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let n={};for(let[t,o]of Object.entries(e))n[t]=go(o);return n}return""}var dr=new WeakMap;function On(e){let n=0,t=null,o=-1;for(let r=0;r<e.length;r++){let c=e[r];c==="\\"?r++:t?c===t&&(t=null):c==='"'||c==="'"?t=c:c==="["||c==="("?n++:c==="]"||c===")"?n>0&&n--:c==="@"&&n===0&&(o=r)}return o}function bo(e){let n=On(e);return n===-1?{selector:e,prop:null}:{selector:e.slice(0,n),prop:e.slice(n+1)||null}}var Kl=new Set(["checked","selected","disabled","readOnly","paused"]);function jr({rules:e,data:n,appRoot:t,cmsRoot:o}){let r=document.createDocumentFragment(),c={rules:e,appRoot:t,cmsRoot:o};return r.appendChild(Br({rule:e,value:n,path:[],ctx:c})),r}function Dr(e,{rules:n,getData:t,onChange:o}){e.setAttribute("data-hha-form-root",""),Js.set(e,{rules:n,getData:t,onChange:o}),ql()}var Js=new WeakMap,Ys=!1;function ql(){Ys||(document.addEventListener("input",Xs,!0),document.addEventListener("change",Xs,!0),document.addEventListener("click",zl,!0),Ys=!0)}function Qs(e){if(!(e instanceof Element))return null;let n=e.closest("[data-hha-form-root]");return n&&Js.get(n)||null}function zl(e){if(!(e.target instanceof Element))return;let n=e.target.closest("[data-hha-action]");if(!n||e.defaultPrevented)return;let t=Qs(n);if(!t)return;let{rules:o,getData:r,onChange:c}=t,l=n.getAttribute("data-hha-action"),i=fr(n.getAttribute("data-hha-path")||"");if(l==="scalar-array-add"){let s=Uo(r(),i)||[];c(Yn(r(),i,[...s,""]),{structural:!0});return}if(l==="object-array-add"){let s=Pr(o,i);if(!Array.isArray(s))return;let a=Uo(r(),i)||[];c(Yn(r(),i,[...a,go(s[1])]),{structural:!0});return}if(l==="array-remove"){if(i.length===0)return;let s=i.slice(0,-1),a=i[i.length-1],h=Uo(r(),s)||[];if(typeof a!="number")return;let f=h.filter((u,g)=>g!==a);c(Yn(r(),s,f),{structural:!0})}}function Xs(e){let n=e.target;if(!n?.matches?.("input, textarea, select"))return;let t=Qs(n);if(!t)return;let{getData:o,onChange:r}=t,c=n.closest("[data-hha-path]");if(!c)return;let l=fr(c.getAttribute("data-hha-path")||""),i=n.type==="checkbox"?n.checked:n.value;r(Yn(o(),l,i),{structural:!1})}function Br({rule:e,value:n,path:t,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?Xl({rule:e,value:n,path:t,ctx:o}):Yl({rule:e,value:n,path:t,ctx:o});if(Array.isArray(e))return Jl({rule:e,value:n,path:t,ctx:o});if(typeof e=="object"&&e!==null)return Gl({rule:e,value:n,path:t,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function Gl({rule:e,value:n,path:t,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",An(t)),t.length>0){let c=document.createElement("div");c.className="form-section-label",c.textContent=hr(t[t.length-1]),r.appendChild(c)}for(let[c,l]of Object.entries(e)){let i=[...t,c],s=n?.[c];r.appendChild(Br({rule:l,value:s,path:i,ctx:o}))}return r}function Yl({rule:e,value:n,path:t,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",An(t));let c=document.createElement("div");c.className="field-body";let l=document.createElement("label");l.className="field-label",l.textContent=hr(t[t.length-1]||".")+nc(e);let i=Zl(e,o.appRoot),s=Ql(i,{value:n,rule:e,path:t,appRoot:o.appRoot}),a=s.el;return a.classList.add(i.type==="textarea"?"field-textarea":"field-input"),c.appendChild(l),c.appendChild(a),r.appendChild(c),dr.set(r,s),r}function Xl({rule:e,value:n,path:t,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",An(t));let c=document.createElement("div");c.className="form-section-label",c.textContent=hr(t[t.length-1]),r.appendChild(c);let l=Array.isArray(n)?n:[],i=document.createElement("div");r.appendChild(i),l.forEach((a,h)=>{let f=[...t,h],u=document.createElement("div");u.className="scalar-array-row",u.setAttribute("data-hha-path",An(f));let g=document.createElement("input");g.type="text",g.className="field-input",g.value=a==null?"":String(a);let b=document.createElement("button");b.type="button",b.className="array-remove",b.textContent="\xD7",b.title="remove",b.setAttribute("data-hha-action","array-remove"),b.setAttribute("data-hha-path",An(f)),u.appendChild(g),u.appendChild(b),i.appendChild(u)});let s=document.createElement("button");return s.type="button",s.className="array-add",s.textContent="+ add",s.setAttribute("data-hha-action","scalar-array-add"),s.setAttribute("data-hha-path",An(t)),r.appendChild(s),r}function Jl({rule:e,value:n,path:t,ctx:o}){let[,r]=e,c=Array.isArray(n)?n:[],l=document.createElement("div");l.className="form-section",l.setAttribute("data-hha-path",An(t));let i=document.createElement("div");i.className="form-section-label",i.textContent=hr(t[t.length-1]),l.appendChild(i),c.forEach((a,h)=>{let f=[...t,h],u=document.createElement("div");u.className="array-card",u.setAttribute("data-hha-path",An(f));let g=document.createElement("button");g.type="button",g.className="array-remove",g.textContent="\xD7",g.title="remove item",g.setAttribute("data-hha-action","array-remove"),g.setAttribute("data-hha-path",An(f)),u.appendChild(g);let b=Br({rule:r,value:a,path:f,ctx:o});b.querySelector(".form-section-label")?.remove(),u.appendChild(b),l.appendChild(u)});let s=document.createElement("button");return s.type="button",s.className="array-add",s.textContent="+ add",s.setAttribute("data-hha-action","object-array-add"),s.setAttribute("data-hha-path",An(t)),l.appendChild(s),l}function Ql(e,n){let t=tc(e);if(e.type==="select"&&e.options)for(let o of e.options){let r=document.createElement("option");r.value=o.value,r.textContent=o.text,String(n.value)===o.value&&(r.selected=!0),t.appendChild(r)}else e.type==="checkbox"?t.checked=n.value===!0||n.value==="true"||n.value==="checked":(e.type,t.value=n.value==null?"":String(n.value));return{el:t,destroy(){},focus(){t.focus()},validate(){}}}function Zl(e,n){let t=null;if(e.startsWith("@")?t=e.slice(1):t=bo(e).prop,t&&Kl.has(t))return{type:"checkbox"};if(t==="innerHTML")return{type:"textarea"};let o=ec(e,n);if(!o)return{type:"text"};let r=(o.tagName||"").toLowerCase();if(r==="textarea")return{type:"textarea"};if(r==="select")return{type:"select",options:Array.from(o.querySelectorAll("option")).map(i=>({value:i.getAttribute("value")||i.textContent,text:i.textContent.trim()||i.getAttribute("value")||""}))};if(r==="input"){let l=(o.getAttribute("type")||"text").toLowerCase();if(l==="checkbox"||l==="radio")return{type:"checkbox"};if(l==="number")return{type:"number"}}let c=(o.textContent||"").trim();return c.length>60||c.includes(`
2
- `)?{type:"textarea"}:{type:"text"}}function ec(e,n){if(!n||e==="."||e===""||e.startsWith("@"))return null;let t=bo(e).selector;if(!t)return null;try{return n.querySelector(t)}catch{return null}}function tc(e){if(e.type==="textarea")return document.createElement("textarea");if(e.type==="select")return document.createElement("select");let n=document.createElement("input");return n.type=e.type==="checkbox"?"checkbox":e.type==="number"?"number":"text",n}function hr(e){return typeof e=="number"?`#${e+1}`:String(e).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^\w/,n=>n.toUpperCase())}function nc(e){return` \xB7 ${e}`}function pr(e,n){if(typeof e=="string"){let t=n&&n.defaultView,o=t&&t.DOMParser||globalThis.DOMParser;return new o().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Ur(e){let n=new Map;return(t,o)=>{if(typeof o!="string")return pr(o,e);let r=n.get(t);if(r&&r.text===o)return r.doc;let c=pr(o,e);return n.set(t,{text:o,doc:c}),c}}function Zs(e,n){let t=n.doctype;if(!t)return!1;let o=e.doctype;if(o&&o.name===t.name&&o.publicId===t.publicId&&o.systemId===t.systemId)return!1;let r=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return o?e.replaceChild(r,o):e.insertBefore(r,e.documentElement),!0}var Hr=()=>!1;function Wr(e,n=[]){if(typeof e!="function")return Hr;let t=new WeakMap,o=new Set(n);return r=>{if(!r||r.nodeType!==1)return!1;let c=t.get(r);if(c!==void 0)return c;let l=[],i=r,s=!1;for(;i&&i.nodeType===1;){let a=t.get(i);if(a!==void 0){s=a;break}if(l.push(i),e(i,o.has(i))){s=!0;break}if(o.has(i))break;i=i.parentElement}for(let a of l)t.set(a,s);return s}}var wf=Object.freeze(["root-tag","equal","root-attrs","root-level","not-in-body","ignored-ancestor","remote-wins-ancestor","form-ancestor","script-or-template","no-live-twin","live-detached","ancestor-live","sibling-live","outside-id-changed","chain-unpaired"]);function Xn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var oc="~",ei="^";function Vr(e,n){let t=new WeakMap;if(!e||!n||typeof n!="object"||Array.isArray(n))return t;let o=n[oc],r=typeof o=="string"?o.split(",").map(Number):null,c=r&&typeof n[ei]=="string"?n[ei].split(","):null,l=f=>Number.isInteger(f)&&f>=0,i=0,s=!1,a=f=>{let u=f;for(;u>0;){let g=r[i++];if(i>r.length||!l(g))return!1;u+=g-1}return!0},h=(f,u)=>{if(s)return;if(r){let A=i++,p=r[A];if(A>=r.length||!l(p)){s=!0;return}let m=!c||c[A]===f.tagName.toLowerCase();if(!m||p!==f.children.length){let y=m&&n[u];typeof y=="string"&&y&&t.set(f,y),a(p)||(s=!0);return}}let g=n[u];typeof g=="string"&&g&&t.set(f,g);let b=f.children;for(let A=0;A<b.length;A++)h(b[A],u===""?String(A):`${u}.${A}`)};return h(e,""),t}function ti(e){return n=>{for(let t of e){let o=t(n);if(typeof o=="string"&&o!=="")return o}return null}}var bn=ti([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function mr(e,n,t,o=null,r=null){let c=new Map,l=new Set,i=s=>{if(t(s))return;let a=n(s);a&&(c.has(a)?l.add(a):c.set(a,s))};if(o){let s=a=>{for(let h of a.querySelectorAll(o))i(h);for(let h of a.querySelectorAll("template"))h.content&&s(h.content)};i(e),s(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let s=a=>{i(a);let h=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let f=0;f<h.length;f++)s(h[f])};s(e)}for(let s of l)c.delete(s),r&&r.add(s),_r(s);return c}function _r(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var rc=new Set(["href","src","name","type","role"]),oi=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function yo(e,n=5381){let t=n;for(let o=0;o<e.length;o++)t=(t<<5)+t^e.charCodeAt(o);return t>>>0}function ni(e){return e.replace(/\s+/g," ")}var sc=0;function ri({ignored:e=()=>!1,ignoreAttribute:n=()=>!1,stats:t=null}={}){let o=new WeakMap,r=new WeakMap;function c(M){let E=M.attributes,N=E.length;if(N===0)return{all:"",sig:M.tagName+"|"};let L=[],j="",F=[];for(let W=0;W<N;W++){let C=E[W],T=C.name;n(M,T)||L.push(T+"="+C.value),T==="class"?j=C.value.indexOf(" ")<0?C.value:C.value.split(/\s+/).filter(Boolean).sort().join(" "):rc.has(T)&&F.push(T+"="+C.value)}return L.length>1&&L.sort(),F.length>1&&F.sort(),{all:L.join(""),sig:M.tagName+"|"+j+(F.length?"|"+F.join("|"):"")}}function l(M){return M.nodeType===1&&M.tagName==="TEMPLATE"&&M.content?M.content.childNodes:M.childNodes}function i(M){let E=o.get(M);if(E)return E;if(M.nodeType===3)E={hash:"T"+yo(M.nodeValue),hint:ni(M.nodeValue).slice(0,64),sig:null,tok:null};else if(M.nodeType===8)E={hash:"C"+yo(M.nodeValue),hint:"",sig:null,tok:null};else if(M.nodeType===1){let N=c(M),L=yo(M.tagName+""+N.all),j="";for(let F of a(M))if(F.nodeType===1){let W=i(F);L=yo(W.hash,L),j.length<64&&(j+=" "+W.hint)}else L=yo(h(F),L),F.kind==="text"&&j.length<64&&(j+=F.value.slice(0,64));E={hash:"E"+L,hint:ni(j).trim().slice(0,64),sig:N.sig,tok:null}}else E={hash:"N"+M.nodeType,hint:"",sig:null,tok:null};return o.set(M,E),E}function s(M){if(!M.tok){M.tok=new Set;for(let E of M.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))E&&M.tok.add(E)}return M.tok}function a(M){let E=r.get(M);if(E)return E;E=[];let N=null,L=()=>{N&&(N.value=N.nodes.map(j=>j.nodeValue).join(""),E.push(N),N=null)};for(let j of l(M)){if(j.nodeType===3){N||(N={kind:"text",nodes:[],value:"",parent:M,hash:void 0}),N.nodes.push(j);continue}L(),j.nodeType===8?E.push({kind:"comment",nodes:[j],value:j.nodeValue,parent:M,hash:void 0}):j.nodeType===1&&!e(j)&&E.push(j)}return L(),r.set(M,E),E}function h(M){return M.nodeType===1?i(M).hash:(M.hash===void 0&&(M.hash=(M.kind==="text"?"T":"C")+yo(M.value)),M.hash)}function f(M,E){let N=s(i(M)),L=s(i(E));if(N.size===0&&L.size===0)return{coef:1,share:1};if(N.size===0||L.size===0)return null;let j=0;for(let F of N)L.has(F)&&j++;return{coef:j/Math.min(N.size,L.size),share:j/Math.max(N.size,L.size)}}function u(M,E){let N=f(M,E);return!!N&&N.coef>=.5}let g=new WeakMap;function b(M){let E=g.get(M);if(E)return E;E=[];for(let N of M.attributes)n(M,N.name)||E.push([N.namespaceURI||"",N.localName,N.value]);return E.sort((N,L)=>N[0]<L[0]?-1:N[0]>L[0]?1:N[1]<L[1]?-1:N[1]>L[1]?1:0),g.set(M,E),E}let A=new WeakMap;function p(M,E){if(M===E)return!0;if(h(M)!==h(E))return!1;let N=A.get(M);if(N&&N.has(E))return N.get(E);let L=A.get(E);if(L&&L.has(M))return L.get(M);let j=m(M,E),F=j===!0;return j===!1&&t&&t.hashRejected++,N||A.set(M,N=new WeakMap),N.set(E,F),F}function m(M,E){if(M.nodeType===1){if(E.nodeType!==1||M.tagName!==E.tagName||M.namespaceURI!==E.namespaceURI)return!1;let N=b(M),L=b(E);if(N.length!==L.length)return!1;for(let W=0;W<N.length;W++)if(N[W][0]!==L[W][0]||N[W][1]!==L[W][1]||N[W][2]!==L[W][2])return!1;let j=a(M),F=a(E);if(j.length!==F.length)return!1;for(let W=0;W<j.length;W++){if(h(j[W])!==h(F[W]))return!1;if(!p(j[W],F[W]))return sc}return!0}return E.nodeType===1?!1:M.kind===E.kind&&M.value===E.value}let y=new WeakMap,R=new Map,S=0;function O(M){let E=y.get(M);if(E)return E;let N=h(M),L=R.get(N);L||R.set(N,L=[]);let j=L.find(F=>p(F.unit,M));return E=j?j.key:"K"+S++,j||L.push({unit:M,key:E}),y.set(M,E),E}return{meta:i,unitsOf:a,unitHash:h,similar:u,score:f,childrenOf:l,equalUnits:p,exactUnitKey:O,ignored:e}}var si=16,ic=2e3,lc=3,Fr={align:0,certifyVisited:0,certifyScheduled:0};function $r(e,n,t){let{meta:o,unitsOf:r,unitHash:c,similar:l,score:i,childrenOf:s,equalUnits:a,ignored:h}=t.analyzer,f=t.baseId||(()=>null),u=t.sideId||(()=>null),g=t.baseKey||(()=>null),b=t.sideKey||(()=>null),A=t.baseDropped||new Set,p=t.sideDropped||new Set,m=t.stats||null,y=m?new Set:null,R=m?new Set:null,S=new Map,O=new Map,M=new Set,E=new Map,N=new Set,L=new Set,j=new Set,F=[],W=[],C=[],T=[],x=ic,z=new Map,D=new Map,V=(B,G)=>{S.set(B,G),O.set(G,B)},Ee=new Set,Me=new Set,De=null,re=B=>{let G=B.nodeType?B.parentNode:B.parent;if(!G||G.nodeType!==11)return G;if(!De){De=new WeakMap;let ue=he=>{for(let ce of he.querySelectorAll("template"))ce.content&&(De.set(ce.content,ce),ue(ce.content))};for(let he of[e,n])ue(he.tagName==="TEMPLATE"&&he.content?he.content:he)}return De.get(G)||null},Se=(B,G)=>{for(let ue=re(B);ue&&!Ee.has(ue);ue=re(ue))Ee.add(ue);for(let ue=re(G);ue&&!Me.has(ue);ue=re(ue))Me.add(ue)},qe=B=>{for(let G=re(B);G;G=re(G))if(S.has(G))return L.has(G);return!1},ve=B=>{for(let G=re(B);G;G=re(G)){let ue=O.get(G);if(ue!==void 0)return L.has(ue)}return!1},w=B=>!!B&&B.nodeType===1,K=(B,G)=>{let ue=E.get(B);return!!ue&&ue.has(G)},ne=B=>oi.has(B.tagName),ee=t.comparisons||t.scope,Pe=(B,G)=>{if(ee){if(ee.same.get(B)===G)return!0;if(ee.differ.get(B)===G)return!1}if(!B.isEqualNode(G))return!1;if(B.tagName==="TEMPLATE")return a(B,G);let ue=B.getElementsByTagName("template");if(ue.length===0)return!0;let he=G.getElementsByTagName("template");if(ue.length!==he.length)return!1;for(let ce=0;ce<ue.length;ce++)if(!a(ue[ce],he[ce]))return!1;return!0},_e=(B,G)=>{let ue=f(B);if(!ue)return!0;let he=u(G);return!he||ue===he},Ae=B=>{let G=g(B);return G&&t.baseIndex.get(G)===B&&!p.has(G)?G:null},ot=B=>{let G=b(B);return G&&t.sideIndex.get(G)===B&&!A.has(G)?G:null},Qe=(B,G)=>{let ue=Ae(B);if(!ue)return!0;let he=ot(G);return!he||ue===he},Ze=globalThis.__hyperMorphProfile,Xe=Ze?performance.now():0;Ze&&!t.scope&&(o(e),o(n),Ze.meta=(Ze.meta||0)+(performance.now()-Xe),Xe=performance.now()),V(e,n);let yt=new Set;for(let[B,G]of t.baseIndex){let ue=t.sideIndex.get(B);ue&&ue.tagName===G.tagName&&!S.has(G)&&!O.has(ue)&&(V(G,ue),Se(G,ue),yt.add(G))}if(yt.size){let B=[];if(t.scope)for(let ce of t.scope.chain)yt.has(ce)&&B.push(ce);let G=[t.scope?t.scope.root:e];for(;G.length;){let ce=G.pop();yt.has(ce)&&B.push(ce);let xe=s(ce);for(let te=xe.length-1;te>=0;te--)xe[te].nodeType===1&&G.push(xe[te])}let ue=new Set;for(let ce=B.length-1;ce>=0;ce--){let xe=B[ce];t.scope&&t.scope.onChain.has(xe)?ue.add(xe):ie(xe,S.get(xe),ue)?(L.add(xe),j.add(xe),m&&m.certificationPairs++):ue.add(xe)}let he=new Set;for(let ce of B)L.has(ce)&&!he.has(ce)&&dt(ce,he)}t.scope&&t.scope.head&&pe(t.scope.head[0],t.scope.head[1]);function dt(B,G){let ue=[B];for(;ue.length;){let he=ue.pop();if(!G.has(he)){G.add(he),Y(he);for(let ce of r(he))w(ce)&&S.has(ce)&&ue.push(ce)}}}T.push([e,n]);for(let[B,G]of S)w(B)&&B!==e&&T.push([B,G]);return Ht(),gt(),Ze&&(Ze.align=(Ze.align||0)+(performance.now()-Xe)),{map:S,reverse:O,moved:N,identical:L,pairIdenticalChildren:Y,weak:M,unpair:qt,rematch:gt,insertedByHash:$t,refused:R,identityPaired:yt};function gt(){ge(),Ht();for(let B=0;B<C.length;){let G=C.length;_t(B,G),B=G,Ht(),ge(),Ht()}}function qt(B){let G=S.get(B);if(!G)return;E.has(B)||E.set(B,new Set),E.get(B).add(G);let ue=(ce,xe)=>{S.delete(ce),O.delete(xe),N.delete(ce),L.delete(ce),M.delete(ce),j.delete(ce)},he=(ce,xe)=>{for(let te of r(ce)){let q=S.get(te);!q||yt.has(te)||!(w(q)?xe.contains(q):xe.contains(q.nodes[0]))||(ue(te,q),w(te)&&he(te,q))}};ue(B,G),w(B)&&he(B,G),F.push(B),W.push(G)}function $t(){let B=new Map;for(let G of new Set(W)){if(O.has(G))continue;let ue=o(G).hash;B.has(ue)||B.set(ue,[]),B.get(ue).push(G)}return B}function Ht(){for(;T.length;){let[B,G]=T.shift();S.get(B)!==G||j.has(B)||L.has(B)||an(B,G)}}function jt(B,G){if(!ne(B))for(let ue of r(B))w(ue)&&(G.push(ue),jt(ue,G))}function an(B,G){j.add(B);let ue=r(B),he=r(G);Fr.align+=ue.length+he.length,z=new Map,D=new Map;for(let ae=0;ae<ue.length;ae++)z.set(ue[ae],ae);for(let ae=0;ae<he.length;ae++)D.set(he[ae],ae);if(B.tagName==="HTML")for(let ae of["HEAD","BODY"]){let Ce=ue.find(We=>w(We)&&We.tagName===ae),Le=he.find(We=>w(We)&&We.tagName===ae);Ce&&Le&&!S.has(Ce)&&!O.has(Le)&&V(Ce,Le)}for(let ae=0;ae<ue.length&&ae<he.length;ae++){let Ce=ue[ae],Le=he[ae];S.has(Ce)||O.has(Le)||(w(Ce)?w(Le)&&Ce.tagName===Le.tagName&&Pe(Ce,Le)&&pe(Ce,Le):!w(Le)&&Ce.kind===Le.kind&&Ce.value===Le.value&&pe(Ce,Le))}Ie(ue,he);let ce=ue.filter(ae=>!S.has(ae)),xe=he.filter(ae=>!O.has(ae));ce.length&&xe.length&&(_(ce,xe),J(ce,xe),oe(ce,xe,ue,he),Oe(ue,he));let te=!1,q=!1;for(let ae of ue){if(!S.has(ae)){w(ae)&&(F.push(ae),jt(ae,F),te=!0);continue}w(ae)&&!L.has(ae)&&T.push([ae,S.get(ae)])}for(let ae of he)!O.has(ae)&&w(ae)&&(W.push(ae),jt(ae,W),q=!0);te&&q&&C.push([B,G])}function _t(B,G){for(let ue=B;ue<G;ue++){let[he,ce]=C[ue];if(S.get(he)!==ce)continue;let xe=r(he),te=r(ce),q=new Map,ae=new Map,Ce=null;for(let Le of xe)w(Le)&&(S.has(Le)?Ce=Le:(q.has(Ce)||q.set(Ce,[]),q.get(Ce).push(Le)));Ce=null;for(let Le of te)w(Le)&&(O.has(Le)?Ce=O.get(Le):(ae.has(Ce)||ae.set(Ce,[]),ae.get(Ce).push(Le)));for(let[Le,We]of q){let Ne=ae.get(Le);if(!(!Ne||We.length!==Ne.length)&&We.every((ze,tt)=>Ne[tt].tagName===ze.tagName&&_e(ze,Ne[tt])&&!K(ze,Ne[tt])))for(let ze=0;ze<We.length;ze++)zt(We[ze],Ne[ze])}}}function zt(B,G){V(B,G),M.add(B),T.push([B,G]),Ht()}function _(B,G){let ue=wo(B,c),he=wo(G,c),ce=new Map;for(let xe of G){let te=c(xe);he.get(te)===1&&ce.set(te,xe)}for(let xe of B){if(S.has(xe))continue;let te=c(xe);if(ue.get(te)!==1)continue;let q=ce.get(te);q&&!O.has(q)&&a(xe,q)&&pe(xe,q)}}function ie(B,G,ue){let he=[[B,G]];for(;he.length;){let[ce,xe]=he.pop();if(Fr.certifyVisited++,m&&m.certificationVisited++,ce.nodeType!==xe.nodeType)return!1;if(ce.nodeType===3||ce.nodeType===8){if(ce.nodeValue!==xe.nodeValue)return!1;continue}if(ce.nodeType!==1){if(!ce.isEqualNode(xe))return!1;continue}if(ce.tagName!==xe.tagName||ce.namespaceURI!==xe.namespaceURI||h(ce)!==h(xe))return!1;let te=ce.attributes,q=xe.attributes;if(te.length!==q.length)return!1;for(let Ne=0;Ne<te.length;Ne++){let ze=te[Ne];if(xe.getAttributeNS(ze.namespaceURI,ze.localName)!==ze.value)return!1}let ae=S.get(ce);if(ae!==void 0&&ae!==xe)return!1;let Ce=O.get(xe);if(Ce!==void 0&&Ce!==ce)return!1;if(ce!==B){if(L.has(ce))continue;if(ue.has(ce))return!1}let Le=s(ce),We=s(xe);if(Le.length!==We.length)return!1;Fr.certifyScheduled+=Le.length;for(let Ne=Le.length-1;Ne>=0;Ne--)he.push([Le[Ne],We[Ne]])}return!0}function me(B,G){return!w(B)||!(Ee.has(B)||Me.has(G))?!0:!!v(B,G)||!(Ae(B)||ot(G))}function pe(B,G){if(w(B)&&(Ee.has(B)||Me.has(G))){let ue=v(B,G);if(!ue){if(Ae(B)||ot(G))return;V(B,G),T.push([B,G]);return}for(let he=0;he<ue.length;he+=2){let ce=ue[he],xe=ue[he+1],te=S.get(ce);te!==void 0&&te!==xe&&ke(ce,te);let q=O.get(xe);q!==void 0&&q!==ce&&ke(q,xe),S.get(ce)===xe&&(N.delete(ce),M.delete(ce),L.add(ce),j.add(ce))}}P(B,G)}function ke(B,G){S.delete(B),O.delete(G),N.delete(B),L.delete(B),M.delete(B),j.delete(B)}function v(B,G){let ue=[B,G,!1],he=[];for(;ue.length;){let ce=ue.pop(),xe=ue.pop(),te=ue.pop(),q=S.get(te),ae=O.get(xe);if(te!==B&&(q!==void 0&&q!==xe&&yt.has(te)||ae!==void 0&&ae!==te&&yt.has(ae)))return null;if(!(q===xe&&L.has(te))&&((q!==void 0||ae!==void 0)&&he.push(te,xe),!!w(te))){if(ce||q!==void 0&&q!==xe||ae!==void 0&&ae!==te){let Ce=r(te),Le=r(xe);for(let We=0;We<Ce.length&&We<Le.length;We++)ue.push(Ce[We],Le[We],!0)}else if(Ee.has(te)||Me.has(xe)){let Ce=te.tagName==="TEMPLATE"?te.content:te,Le=xe.tagName==="TEMPLATE"?xe.content:xe;for(let We=Ce.firstElementChild,Ne=Le.firstElementChild;We&&Ne;){if(h(We)){We=We.nextElementSibling;continue}if(h(Ne)){Ne=Ne.nextElementSibling;continue}(S.has(We)||O.has(Ne)||Ee.has(We)||Me.has(Ne))&&ue.push(We,Ne,!1),We=We.nextElementSibling,Ne=Ne.nextElementSibling}}}}return he}function P(B,G){V(B,G),L.add(B),w(B)&&j.add(B)}function Y(B){let G=S.get(B);if(!G||!w(B))return;let ue=r(B),he=r(G);for(let ce=0;ce<ue.length&&ce<he.length;ce++)S.has(ue[ce])||P(ue[ce],he[ce])}function J(B,G){let ue=te=>w(te)&&!ne(te)?o(te).sig+""+o(te).hint:null,he=wo(B,ue),ce=wo(G,ue),xe=new Map;for(let te of G){let q=ue(te);q!=null&&ce.get(q)===1&&xe.set(q,te)}for(let te of B){if(S.has(te))continue;let q=ue(te);if(q==null||he.get(q)!==1)continue;let ae=xe.get(q);ae&&!O.has(ae)&&_e(te,ae)&&V(te,ae)}}function oe(B,G,ue,he){let ce=new Map;for(let te of G){if(!w(te)||O.has(te)||ne(te))continue;let q=o(te).sig;ce.has(q)||ce.set(q,[]),ce.get(q).push({el:te,index:D.get(te)})}let xe=[];for(let te of B){if(S.has(te)||!w(te)||ne(te))continue;let q=ce.get(o(te).sig);if(!q||!q.length)continue;let ae=z.get(te),Ce=q.filter(Le=>!O.has(Le.el)).map(Le=>({c:Le,d:Math.abs(Le.index-ae)}));Ce.sort((Le,We)=>Le.d-We.d),Ce.length>si&&(Ce=Ce.slice(0,si));for(let{c:Le,d:We}of Ce){if(!_e(te,Le.el))continue;let Ne=i(te,Le.el);Ne&&Ne.coef>=.5&&xe.push({b:te,s:Le.el,coef:Ne.coef,share:Ne.share,d:We,bi:ae})}}if(xe.sort((te,q)=>q.coef-te.coef||q.share-te.share||te.d-q.d||te.bi-q.bi),m&&xe.length>1){let te=new Map;for(let q of xe){let ae=te.get(q.b);ae?ae.coef===q.coef&&(ae.share===q.share?ae.strict++:ae.loose++):te.set(q.b,{coef:q.coef,share:q.share,strict:0,loose:0})}for(let[q,ae]of te)y.has(q)||!(ae.strict||ae.loose)||(y.add(q),ae.strict?m.similarTiesStrict++:m.similarTiesLoose++)}for(let te of xe)!S.has(te.b)&&!O.has(te.s)&&V(te.b,te.s)}function je(B,G){return w(B)!==w(G)?!1:w(B)?B.tagName!==G.tagName||!_e(B,G)?!1:ne(B)||o(B).hint===""||o(G).hint===""?!0:l(B,G):B.kind===G.kind}function Z(B,G){let ue=(ce,xe)=>{let te=xe===null?-1:ce===G?D.get(xe):z.get(xe),q=ce[te+1];return q&&!w(q)?q:null},he=null;for(let ce of B){if(w(ce)){he=ce;continue}if(S.has(ce))continue;let xe=he===null?null:S.get(he);if(he!==null&&!xe)continue;let te=ue(G,xe);te&&!O.has(te)&&te.kind===ce.kind&&V(ce,te)}}function Oe(B,G){Z(B,G);let ue=He(B,G),he=(xe,te)=>w(xe)&&o(xe).hint!==""&&o(te).hint===""&&!!te.querySelector("br")&&!ue(xe,te),ce=0;for(let xe of B){if(S.has(xe)){let q=D.get(S.get(xe));q!==void 0&&q>=ce&&(ce=q+1);continue}let te=0;for(let q=ce;q<G.length&&te<lc;q++){let ae=G[q];if(!O.has(ae)&&(te++,je(xe,ae)&&!K(xe,ae)&&!he(xe,ae))){V(xe,ae),w(xe)&&(o(xe).hint===""||o(ae).hint==="")&&M.add(xe),ce=q+1;break}}}Ie(B,G)}function He(B,G){let ue=(he,ce,xe)=>{for(let te=ce-1;te>=0;te--)if(w(he[te])&&xe(he[te]))return he[te];return null};return(he,ce)=>{let xe=z.get(he),te=D.get(ce);if(xe===te)return!0;let q=ue(B,xe,Ce=>S.has(Ce)),ae=ue(G,te,Ce=>O.has(Ce));return q?S.get(q)===ae:!ae}}function Ie(B,G){let ue=B.filter(q=>w(q)&&!S.has(q)),he=G.filter(q=>w(q)&&!O.has(q));if(!ue.length||!he.length)return;let ce=wo(ue,q=>q.tagName),xe=wo(he,q=>q.tagName),te=He(B,G);for(let q of ue){let ae=q.tagName;if(ce.get(ae)!==1||xe.get(ae)!==1)continue;let Ce=he.find(Le=>Le.tagName===ae);Ce&&!O.has(Ce)&&te(q,Ce)&&_e(q,Ce)&&!K(q,Ce)&&(a(q,Ce)?pe(q,Ce):(V(q,Ce),M.add(q)))}}function ge(){let B=new Map;for(let q of M)if(w(q)&&w(S.get(q))){let ae=o(q).hash;B.has(ae)||B.set(ae,[]),B.get(ae).push(q)}if(B.size)for(let q of W){if(O.has(q)||!w(q)||ve(q))continue;let ae=B.get(o(q).hash),Ce=ae&&ae.find(Le=>M.has(Le)&&!K(Le,q)&&_e(Le,q)&&Qe(Le,q)&&a(Le,q)&&me(Le,q));Ce&&(qt(Ce),pe(Ce,q),Se(Ce,q),N.add(Ce))}let G=new Map,ue=new Map,he=new Map;for(let q of M){let ae=S.get(q);w(q)&&w(ae)&&he.set(ae,q)}let ce=(q,ae)=>{if(!O.has(q))return!ve(q);let Ce=he.get(q);return Ce===O.get(q)&&Ce!==ae&&!Ce.contains(ae)},xe=q=>{if(O.has(q)){let ae=he.get(q);he.delete(q),qt(ae)}};for(let q of[...W,...he.keys()]){if(O.has(q)&&!he.has(q))continue;let ae=o(q).hash;if(G.has(ae)||G.set(ae,[]),G.get(ae).push(q),ne(q))continue;let Ce=o(q).sig;ue.has(Ce)||ue.set(Ce,[]),ue.get(Ce).push(q)}let te=new Set;for(let q of M){let ae=S.get(q);!w(q)||!w(ae)||ne(q)||o(q).hint===""||o(ae).hint===""||l(q,ae)||te.add(q)}for(let q of[...F,...te]){let ae=S.get(q);if(ae?!(M.has(q)&&te.has(q)):qe(q))continue;let Ce=tt=>{ae&&qt(q),xe(tt)},Le=G.get(o(q).hash);if(Le){let tt=Le.find(k=>k!==ae&&ce(k,q)&&!K(q,k)&&Qe(q,k)&&a(q,k)&&me(q,k));if(tt){Ce(tt),pe(q,tt),Se(q,tt),N.add(q);continue}}if(ne(q)||x<=0)continue;let We=ue.get(o(q).sig);if(!We)continue;let Ne=null,ze=0;for(let tt of We)if(!(tt===ae||!ce(tt,q)||!_e(q,tt)||!Qe(q,tt)||K(q,tt))&&(x--<=0||l(q,tt)&&(ze++,Ne=tt,ze>1)))break;ze>1&&R&&R.add(q),ze===1&&(Ce(Ne),V(q,Ne),Se(q,Ne),N.add(q),T.push([q,Ne]))}}}function wo(e,n){let t=new Map;for(let o of e){let r=n(o);r!=null&&t.set(r,(t.get(r)||0)+1)}return t}var cc={diff:0},ii=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,ac=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,fc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,uc=/\P{M}\p{M}*/gu;function dc(e){if(e==="")return[];if(ii){let t=[];for(let o of ii.segment(e))t.push(o.segment);return t}let n=[];for(let t of e.match(fc))if(ac.test(t))for(let o of t.match(uc))n.push(o);else n.push(t);return n}var hc=/^[  ]+$/,pc=e=>hc.test(e)?" ".repeat(e.length):e,Jn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),wt="",Kr=e=>e.every(n=>Jn(n)||n.k===wt),mc=/^[\x00-\x7f\u00A0]*$/,gc=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function bc(e){return e===""?[]:e.match(gc)}function ln(e,n=!1){return(n?bc(e):dc(e)).map(t=>({k:pc(t),raw:t,len:t.length}))}var yn=(...e)=>e.every(n=>mc.test(n));function qr(e,n,t){let o=e.length,r=n.length,c=Math.min(o+r,t),l=c+1,i=new Int32Array(2*c+3),s=[],a=o===0&&r===0;for(let g=0;g<=c&&!a;g++){s.push(i.slice(l-g,l+g+1));for(let b=-g;b<=g;b+=2){let A;b===-g||b!==g&&i[l+b-1]<i[l+b+1]?A=i[l+b+1]:A=i[l+b-1]+1;let p=A-b,m=A;for(;A<o&&p<r&&e[A].k===n[p].k;)A++,p++;if(cc.diff+=1+A-m,i[l+b]=A,A>=o&&p>=r){a=!0;break}}}if(!a)return null;let h=[],f=o,u=r;for(let g=s.length-1;g>0;g--){let b=s[g],A=f-u,p=A+g,m=A===-g||A!==g&&b[p-1]<b[p+1]?A+1:A-1,y=b[m+g],R=y-m;for(;f>y&&u>R;)h.push([0,f-1,u-1]),f--,u--;f===y?(h.push([1,f,u-1]),u--):(h.push([-1,f-1,u]),f--)}for(;f>0&&u>0;)h.push([0,f-1,u-1]),f--,u--;return h.reverse(),h}function yc(e,n,t){let o=f=>f.k===wt;if(!e.some(o)&&!n.some(o))return qr(e,n,t);let r=[],c=[];for(let f=0;f<e.length;f++)o(e[f])||r.push(f);for(let f=0;f<n.length;f++)o(n[f])||c.push(f);let l=qr(r.map(f=>e[f]),c.map(f=>n[f]),t);if(!l)return null;let i=[],s=0,a=0,h=(f,u)=>{for(;s<f&&a<u&&e[s].k===n[a].k;)i.push([0,s++,a++]);let g=qr(e.slice(s,f),n.slice(a,u),t);if(!g)return!1;for(let[b,A,p]of g)i.push([b,A+s,p+a]);return s=f,a=u,!0};for(let[f,u,g]of l)if(f===0){if(!h(r[u],c[g]))return null;i.push([0,s,a]),s++,a++}return h(e.length,n.length)?i:null}function Kn(e,n,t=4e3){let o=[],r=0;for(;r<e.length&&r<n.length&&e[r].k===n[r].k;)e[r].raw!==n[r].raw&&o.push({bi:r,tok:n[r]}),r++;let c=0;for(;c<e.length-r&&c<n.length-r&&e[e.length-1-c].k===n[n.length-1-c].k;)e[e.length-1-c].raw!==n[n.length-1-c].raw&&o.push({bi:e.length-1-c,tok:n[n.length-1-c]}),c++;let l=e.slice(r,e.length-c),i=n.slice(r,n.length-c),s=Sc(l,i)?null:yc(l,i,t);if(!s){let m=l.length||i.length?[{bs:r,be:r+l.length,toks:i}]:[];return{hunks:m,cosmetic:o,coarse:!0,parts:m.map(y=>({...y,gap:[],group:0})),cosmeticEq:o}}let a=[],h=(m,y)=>{l[m].raw!==i[y].raw&&o.push({bi:r+m,tok:i[y]})},f=null,u=[],g=0,b=0,A=()=>{f&&a.push(f),f=null;for(let[m,y]of u)h(m,y);u=[],g++};for(let[m,y,R]of s){if(m===0){f&&Jn(l[y])&&!l[y].k.includes(`
3
- `)?u.push([y,R]):(A(),h(y,R)),b=y+1;continue}(!f||u.length)&&(f&&a.push(f),f={bs:r+b,be:r+b,toks:[],gap:u.map(([S,O])=>({bi:r+S,tok:i[O]})),group:g},u=[]),m===-1?(f.be=r+b+1,b=y+1):f.toks.push(i[R])}A(),wc(a,e);let p=Gr(a);return{hunks:p.hunks,cosmetic:o.concat(p.cosmetic),parts:a,cosmeticEq:o}}function wc(e,n){for(let t=0;t<e.length;t++){let o=e[t];if(o.gap.length)continue;let r=t+1<e.length?e[t+1].bs:1/0;if(o.toks.length){if(o.bs===o.be)for(;o.bs+1<r&&o.bs<n.length&&o.toks[0].k===wt&&n[o.bs].k===wt;)o.toks=[...o.toks.slice(1),o.toks[0]],o.bs++,o.be++}else for(;o.be+1<r&&o.be<n.length&&n[o.bs].k===wt&&n[o.be].k===wt;)o.bs++,o.be++}}function Gr(e,n=()=>!1){let t=[],o=[],r=null,c=-1;for(let l of e){let i=n(l);if(r&&!r.alone&&!i&&l.group===c){r.be=l.be;for(let s of l.gap)r.toks.push(s.tok);for(let s of l.toks)r.toks.push(s);continue}r&&t.push({bs:r.bs,be:r.be,toks:r.toks});for(let s of l.gap)o.push(s);r={bs:l.bs,be:l.be,toks:l.toks.slice(),alone:i},c=l.group}return r&&t.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:t,cosmetic:o}}var xc=(e,n)=>e.bs===n.bs&&e.be===n.be&&Jr(e.toks,n.toks);function Xr(e,n,t){let o=h=>f=>h.some(u=>xc(f,u)),r=Gr(e.parts,o(n.parts)),c=Gr(n.parts,o(e.parts)),l=e.cosmeticEq.concat(r.cosmetic),i=n.cosmeticEq.concat(c.cosmetic),[s,a]=t?kc(r.hunks,c.hunks,t,l,i):[r.hunks,c.hunks];return{lh:s,rh:a,cosL:l,cosR:i}}function kc(e,n,t,o,r){let c=(b,A)=>b.k===A.k&&b.raw===A.raw,l=[{list:e.map(b=>({...b})),resp:new Set(o.map(b=>b.bi)),raw:new Map(o.map(b=>[b.bi,b.tok]))},{list:n.map(b=>({...b})),resp:new Set(r.map(b=>b.bi)),raw:new Map(r.map(b=>[b.bi,b.tok]))}],i=b=>b.bs===b.be,s=(b,A,p,m)=>{let y=b.list[A];if(!i(y))return m(y)===p?y.toks:null;let R=A?b.list[A-1].be:0,S=A+1<b.list.length?b.list[A+1].bs:t.length;if(p<R||p>S)return null;let O=y.toks,M=y.bs;for(;M>p;){let E=O[O.length-1];if(!c(E,t[M-1])||b.resp.has(M-1))return null;O=[E,...O.slice(0,-1)],M--}for(;M<p;){if(!c(O[0],t[M])||b.resp.has(M))return null;O=[...O.slice(1),O[0]],M++}return O},a=(b,A,p,m,y,R)=>{let S=b.list[A],O=y?p.slice(p.length-m):p.slice(0,m),M=y?p.slice(0,p.length-m):p.slice(m),E={bs:R,be:R,toks:O};if(i(S)){if(!M.length){b.list[A]=E;return}let L={bs:R,be:R,toks:M};y&&(L.lead=!0),b.list.splice(A,1,...y?[L,E]:[E,L]);return}let N={bs:S.bs,be:S.be,toks:M};b.list.splice(A,1,...y?[N,E]:[E,N])},h=(b,A,p,m,y)=>{let R=b.list[A],S=y?p.slice(p.length-m):p.slice(0,m),O=y?p.slice(0,p.length-m):p.slice(m),M={bs:R.bs,be:R.be,toks:S};if(!O.length){b.list[A]=M;return}let E=y?{bs:R.bs,be:R.bs,toks:O,lead:!0}:{bs:R.be,be:R.be,toks:O};b.list.splice(A,1,...y?[E,M]:[M,E])},f=(b,A,p,m)=>{let y=b.list[A],R=p.list[m],S=y.be,O=R.bs;if(S>=O||A+1<b.list.length&&b.list[A+1].bs<=R.be||m>0&&p.list[m-1].be>=y.bs)return!1;for(let D=S;D<O;D++)if(!Jn(t[D])||t[D].k.includes(`
4
- `))return!1;let M=D=>t.slice(S,O).map((V,Ee)=>D.raw.get(S+Ee)||V),E=[...y.toks,...M(b)],N=[...M(p),...R.toks],L=(D,V,Ee)=>V>=0&&V+Ee.length<=D.length&&Ee.every((Me,De)=>D[V+De].k===Me.k),j=(D,V,Ee)=>Kr(D)&&t.slice(V,Ee).some(Me=>!Jn(Me)),F=D=>D.some(V=>!Jn(V)),W,C,T,x;if(i(y)&&F(y.toks)&&L(N,0,y.toks)){let D=N.slice(y.toks.length);j(D,S,R.be)||(W=S,C=y.toks,T=N.slice(0,y.toks.length),x=[null,{bs:S,be:R.be,toks:D}])}if(W===void 0&&i(R)&&F(R.toks)){let D=E.length-R.toks.length,V=E.slice(0,D);L(E,D,R.toks)&&!j(V,y.bs,O)&&(W=O,C=E.slice(D),T=R.toks,x=[{bs:y.bs,be:O,toks:V},null])}if(W===void 0)return!1;let z=D=>D&&(D.bs<D.be||D.toks.length);return b.list.splice(A,1,...[x[0],{bs:W,be:W,toks:C}].filter(z)),p.list.splice(m,1,...[{bs:W,be:W,toks:T},x[1]].filter(z)),!0},u=l[0],g=l[1];for(let b=0;b<64;b++){let A=!1;e:for(let p=0;p<u.list.length;p++)for(let m=0;m<g.list.length;m++){let y=u.list[p],R=g.list[m];if(!(y.bs===R.bs&&y.be===R.be&&Jr(y.toks,R.toks))){for(let S of[!0,!1]){let O=E=>S?E.be:E.bs,M=i(y)?[O(R),y.bs]:[O(y)];for(let E of M){let N=s(u,p,E,O),L=N&&s(g,m,E,O);if(!L)continue;let j=(x,z)=>S?x[x.length-1-z]:x[z],F=0;for(;F<N.length&&F<L.length&&j(N,F).k===j(L,F).k;)F++;if(!F)continue;let W=S?N.slice(0,N.length-F):N.slice(F),C=S?L.slice(0,L.length-F):L.slice(F);if(!(F<N.length&&F<L.length&&!Kr(W)&&!Kr(C)&&(i(y)&&i(R)||y.bs===R.bs&&y.be===R.be)||!(S?N.slice(N.length-F):N.slice(0,F)).some(x=>!Jn(x)))){if(F===N.length&&F===L.length&&i(y)&&i(R)){if(y.bs===E&&R.bs===E)continue;u.list[p]={bs:E,be:E,toks:N},g.list[m]={bs:E,be:E,toks:L}}else!i(y)&&y.bs===R.bs&&y.be===R.be?(h(u,p,N,F,S),h(g,m,L,F,S)):(a(u,p,N,F,S,E),a(g,m,L,F,S,E));A=!0;break e}}}if(f(u,p,g,m)||f(g,m,u,p)){A=!0;break e}}}if(!A)break}return[u.list,g.list]}var Tc=48,Ac=.3;function Sc(e,n){let t=e.filter(l=>!Jn(l)),o=n.filter(l=>!Jn(l));if(Math.min(t.length,o.length)<Tc)return!1;let r=new Map;for(let l of t)r.set(l.k,(r.get(l.k)||0)+1);let c=0;for(let l of o){let i=r.get(l.k);i>0&&(c++,r.set(l.k,i-1))}return c/Math.min(t.length,o.length)<Ac}var Nc=(e,n)=>{let t=new Set;for(let o of e.toks)typeof o.k!="string"&&t.add(o.k.el);for(let o=e.bs;o<e.be;o++)typeof n[o].k!="string"&&t.add(n[o].k.el);return t},Jr=(e,n)=>e.length===n.length&&e.every((t,o)=>t.k===n[o].k);function li(e,n,t,o="remote"){let r=Kn(e,n),c=Kn(e,t),{lh:l,rh:i,cosL:s,cosR:a}=Xr(r,c,e),h=w=>w.bs===w.be,f=w=>w.toks.some(K=>typeof K.k=="string"),u=w=>h(w)&&!f(w),g=(w,K)=>K.bs<w.be&&w.bs<K.be,b=(w,K)=>!g(w,K)&&K.bs<=w.be&&w.bs<=K.be&&(h(w)&&f(w)||h(K)&&f(K))&&!(h(w)&&h(K)),A=(w,K)=>w.bs===K.bs&&w.be===K.be&&Jr(w.toks,K.toks),p=[],m=new Set;for(let w of l){let K=i.find(ne=>!m.has(ne)&&A(w,ne));K?(m.add(K),p.push({bs:w.bs,be:w.be,side:"both",l:w,r:K,toks:w.toks})):p.push({bs:w.bs,be:w.be,side:"L",l:w,toks:w.toks,lead:!!w.lead})}for(let w of i)m.has(w)||p.push({bs:w.bs,be:w.be,side:"R",r:w,toks:w.toks,lead:!!w.lead});p.sort((w,K)=>w.bs-K.bs||w.be-K.be||K.lead-w.lead);let y=0,R=0;for(let w of p)w.side==="both"&&(y+=w.toks.length-(w.be-w.bs));let S=p.map((w,K)=>K),O=w=>S[w]===w?w:S[w]=O(S[w]),M=(w,K)=>(w=O(w),K=O(K),w===K?!1:(S[w]=K,!0)),E=p.map(w=>Nc({bs:w.bs,be:w.be,toks:w.toks},e)),N={L:new Map,R:new Map};p.forEach((w,K)=>{let ne=w.side==="both"?["L","R"]:[w.side];for(let ee of ne)for(let Pe of E[K])N[ee].has(Pe)||N[ee].set(Pe,[]),N[ee].get(Pe).push(K)});for(let w of[N.L,N.R])for(let K of w.values())for(let ne=1;ne<K.length;ne++)M(K[0],K[ne]);for(let w=0;w<p.length;w++)for(let K=w+1;K<p.length;K++){let ne=p[w],ee=p[K];ne.side===ee.side&&ne.side!=="both"||ne.bs>ee.be||(g(ne,ee)||b(ne,ee)?M(w,K):ne.bs===ee.bs&&h(ne)&&h(ee)&&R++)}let L=(w,K)=>{let ne=w==="L"?l:i;for(let ee of ne)if(ee.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===K.el))return ee.bs;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="close"&&e[ee].k.el===K.el)return ee;return-1};p.forEach((w,K)=>{if(!(!u(w)||w.side==="both"))for(let ne of w.toks){if(ne.kind!=="open")continue;let ee=L(w.side,ne.k);if(ee<=w.bs)continue;let Pe=new Uint8Array(ee-w.bs),_e=[];if(p.forEach((Ae,ot)=>{if(!(Ae.side===w.side||h(Ae))&&Ae.bs<ee&&Ae.be>w.bs){_e.push(ot);for(let Qe=Math.max(Ae.bs,w.bs);Qe<Math.min(Ae.be,ee);Qe++)Pe[Qe-w.bs]=1}}),_e.length&&Pe.every(Ae=>Ae===1))for(let Ae of _e)M(K,Ae)}});let j=!0;for(;j;){j=!1;let w=new Map;p.forEach((K,ne)=>{let ee=O(ne),Pe=w.get(ee)||{bs:K.bs,be:K.be,L:!1,R:!1};Pe.bs=Math.min(Pe.bs,K.bs),Pe.be=Math.max(Pe.be,K.be),K.side!=="R"&&(Pe.L=!0),K.side!=="L"&&(Pe.R=!0),w.set(ee,Pe)}),p.forEach((K,ne)=>{for(let[ee,Pe]of w){if(O(ne)===O(ee)||!(Pe.L&&Pe.R))continue;let _e=K.bs<Pe.be&&K.be>Pe.bs,Ae=h(K)&&f(K)&&(K.bs===Pe.be||K.bs===Pe.bs);(_e||Ae)&&M(ne,ee)&&(j=!0)}})}let F=new Map;p.forEach((w,K)=>{let ne=O(K);F.has(ne)||F.set(ne,[]),F.get(ne).push(w)});let W=[];for(let w of F.values()){let K=w.some(ee=>ee.side==="L"),ne=w.some(ee=>ee.side==="R");if(K&&ne){let ee=Math.min(...w.map(ot=>ot.bs)),Pe=Math.max(...w.map(ot=>ot.be)),_e=w.filter(ot=>ot.side!=="R").map(ot=>ot.l).sort((ot,Qe)=>ot.bs-Qe.bs),Ae=w.filter(ot=>ot.side!=="L").map(ot=>ot.r).sort((ot,Qe)=>ot.bs-Qe.bs);W.push({bs:ee,be:Pe,kind:"conflict",localHunks:_e,remoteHunks:Ae})}else for(let ee of w)W.push({bs:ee.bs,be:ee.be,kind:ee.side,u:ee})}let C=(w,K)=>{let ne=w==="L"?l:i;for(let ee of ne)if(ee.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===K.el))return ee.bs+.5;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="close"&&e[ee].k.el===K.el)return ee;return 1/0},T=(w,K)=>{let ne=w==="L"?l:i;for(let ee of ne)if(ee.toks.some(Pe=>Pe.kind==="open"&&Pe.k.el===K.el))return ee.bs-.5;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="open"&&e[ee].k.el===K.el)return ee;return-1/0},x=w=>w.kind==="R"?"R":"L",z=w=>w.kind==="R"?1:0;W.sort((w,K)=>{if(w.bs!==K.bs)return w.bs-K.bs;let ne=w.bs===w.be,ee=K.bs===K.be;if(ne!==ee)return ne?-1:1;if(ne&&ee&&w.kind!=="conflict"&&K.kind!=="conflict"){let _e=w.u.toks,Ae=K.u.toks,ot=Ze=>Ze.length&&Ze.every(Xe=>Xe.kind==="open"),Qe=Ze=>Ze.length&&Ze.every(Xe=>Xe.kind==="close");if(ot(_e)&&ot(Ae)){let Ze=Math.max(..._e.map(yt=>C(x(w),yt.k))),Xe=Math.max(...Ae.map(yt=>C(x(K),yt.k)));if(Ze!==Xe)return Xe-Ze}if(Qe(_e)&&Qe(Ae)){let Ze=Math.min(..._e.map(yt=>T(x(w),yt.k))),Xe=Math.min(...Ae.map(yt=>T(x(K),yt.k)));return Ze!==Xe?Xe-Ze:z(K)-z(w)}}let Pe=_e=>_e.u&&_e.u.lead?1:0;return Pe(K)-Pe(w)||z(w)-z(K)||w.be-K.be});let D=[],V=[],Ee=0,Me=w=>{w>Ee&&(D.push({bs:Ee,be:w,toks:e.slice(Ee,w),source:"base"}),Ee=w)};for(let w of W){if(Me(w.bs),w.kind==="conflict"){let K=Yr(e,w.localHunks,w.bs,w.be),ne=Yr(e,w.remoteHunks,w.bs,w.be),ee=o==="local"?K:o==="both"?K.concat(ne):ne,Pe=(ot,Qe)=>{let Ze=0;for(let Xe of ot)Xe.be<=w.bs&&!Qe.includes(Xe)&&(Ze+=Xe.toks.length-(Xe.be-Xe.bs));return Ze},_e=w.bs+Pe(l,w.localHunks),Ae=w.bs+Pe(i,w.remoteHunks);V.push({bs:w.bs,be:w.be,ls:_e,le:_e+K.length,rs:Ae,re:Ae+ne.length,ms:0,me:0,base:e.slice(w.bs,w.be),local:K,remote:ne,resolved:ee}),D.push({bs:w.bs,be:w.be,toks:ee,source:"conflict",localHunks:w.localHunks,localToks:K,keepsLocal:o!=="remote"})}else D.push({bs:w.bs,be:w.be,toks:w.u.toks,source:w.kind==="R"?"remote":"local",localHunks:w.kind==="R"?[]:[w.u.l]});Ee=Math.max(Ee,w.be)}Me(e.length);let De=0,re=0;for(let w of D)w.source==="conflict"&&(V[re].ms=De,V[re].me=De+w.toks.length,re++),De+=w.toks.length;let Se=new Map(s.map(w=>[w.bi,w.tok])),qe=new Map(a.map(w=>[w.bi,w.tok])),ve=[];for(let w of D){w.source==="base"&&(w.toks=w.toks.map((K,ne)=>{let ee=w.bs+ne,Pe=Se.get(ee),_e=qe.get(ee),Ae=Pe&&_e?o==="remote"?_e:Pe:Pe||_e||K;return Ae===K?K:{...Ae,cosmetic:!0}}));for(let K of w.toks)ve.push({...K,src:w.source})}return{tokens:ve,segments:D,conflicts:V,localHunks:l,remoteHunks:i,collapsedDelta:y,samePoint:R,mapLocalOffset:vc(e,l,D)}}function Yr(e,n,t,o){let r=[],c=t;for(let l of n)r=r.concat(e.slice(c,l.bs),l.toks),c=l.be;return r.concat(e.slice(c,o))}var zr=e=>e.reduce((n,t)=>n+t.len,0);function vc(e,n,t){let o=new Int32Array(e.length+1);for(let l=0;l<e.length;l++)o[l+1]=o[l]+e[l].len;let r=n.map(l=>({bs:o[l.bs],be:o[l.be],text:l.toks.map(i=>i.raw).join(""),ref:l})),c=t.map(l=>({bs:o[l.bs],be:o[l.be],len:zr(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?zr(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let i=null,s=null,a=0,h=0,f=0;for(let g of r){let b=g.bs-f;if(l<=h+b){i=f+(l-h);break}if(h+=b,f=g.bs,l<=h+g.text.length){s=g,a=l-h,i=g.bs;break}h+=g.text.length,f=g.be}i===null&&(i=f+(l-h));let u=0;for(let g of c){if(!s&&i<=g.bs)return u;if(!(s?g.localHunks.includes(s.ref):i<g.be)){u+=g.len;continue}if(g.source==="base")return u+(i-g.bs);if(g.source==="remote")return u+g.len;if(g.source==="local")return u+Math.min(a,g.len);if(!g.keepsLocal||!s)return u+g.len;let A=g.localHunks.indexOf(s.ref),p=zr(Yr(e,g.localHunks.slice(0,A),g.ref.bs,s.ref.bs));return u+Math.min(p+a,g.localLen)}return u}}function Ho(e,n,t,o="remote"){if(n===t||t===e)return{text:n,conflicts:[],mapLocalOffset:m=>Math.min(m,n.length),granularity:"word"};let r=yn(e,n,t),c=ln(e,r),l=ln(n,r),i=ln(t,r),s=c.length<=2e4&&l.length<=2e4&&i.length<=2e4?li(c,l,i,o):null,a="word",h=c;if(!s){let m=y=>y.split(/(?<=\n)/).map(R=>({k:R,raw:R,len:R.length}));h=m(e),s=li(h,m(n),m(t),o),a="line"}let f=m=>m.map(y=>y.raw).join(""),u=m=>{let y=[0];for(let R of m)y.push(y[y.length-1]+R.len);return y},g=u(h),b=null,A=null,p=null;if(s.conflicts.length){let m=y=>y.split(/(?<=\n)/).map(R=>({k:R,raw:R,len:R.length}));b=u(a==="line"?m(n):l),A=u(a==="line"?m(t):i),p=u(s.tokens)}return{text:f(s.tokens),conflicts:s.conflicts.map(m=>({bs:g[m.bs],be:g[m.be],ls:b[m.ls],le:b[m.le],rs:A[m.rs],re:A[m.re],ms:p[m.ms],me:p[m.me],base:f(m.base),local:f(m.local),remote:f(m.remote),resolved:f(m.resolved)})),mapLocalOffset:s.mapLocalOffset,granularity:a}}function ro(e,n,t=4e3){if(e===n)return[];let o=yn(e,n),r=ln(e,o),c=ln(n,o),l=Kn(r,c,t),i=[0];for(let s of r)i.push(i[i.length-1]+s.len);return l.hunks.map(s=>({bs:i[s.bs],be:i[s.be],text:s.toks.map(a=>a.raw).join("")}))}function Kt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Dn({base:e,side:n,retained:t,transfers:o,baseAtomKey:r=i=>i.el,sideAtomKey:c=i=>i.el,budget:l=Kt()}){let i=[],s=O=>({status:"fallback",reason:O}),a=O=>O>l.remaining?!1:(l.remaining-=O,!0);if(!a((t.length+o.length)*3))return s("work-limit");for(let[O,M]of[["retained",t],["transfer",o]])for(let E of M){let{from:N,to:L,target:j}=E;if(!Number.isInteger(N)||!Number.isInteger(L)||!Number.isInteger(j)||N<0||L<=N||L>e.text.length||j<0||j+L-N>n.text.length)return s("invalid-range");i.push({...E,kind:O})}let h=Symbol(),f=O=>(M,E)=>{if(!a(1))throw h;return l.sortComparisons++,O(M,E)},u,g;try{u=i.slice().sort(f((O,M)=>O.from-M.from||O.to-M.to)),g=i.slice().sort(f((O,M)=>O.target-M.target||O.to-O.from-(M.to-M.from)))}catch(O){if(O===h)return s("work-limit");throw O}if(!a(i.length*2))return s("work-limit");for(let O=1;O<u.length;O++)if(u[O].from<u[O-1].to)return s("source-overlap");for(let O=1;O<g.length;O++)if(g[O].target<g[O-1].target+g[O-1].to-g[O-1].from)return s("target-overlap");for(let O of u){let M=O.to-O.from;if(!a(M))return s("work-limit");for(let E=0;E<M;E++){let N=O.from+E,L=O.target+E;if(l.comparisons++,e.text[N]!==n.text[L])return s("unequal-occurrence");let j=e.atomAt.get(N),F=n.atomAt.get(L);if(!!j!=!!F||j&&r(j)!==c(F))return s("different-atom")}}let b=e.text.length+n.text.length+2,A=i.reduce((O,M)=>O+(M.to-M.from)*2,2);if(!a(b+A+i.length))return s("work-limit");let p=new Int32Array(e.text.length+1).fill(-1),m=new Int32Array(n.text.length+1).fill(-1);l.mapCells+=b,l.mapWrites+=A;let y=-1,R=!0;for(let O of u){O.target<y&&(R=!1),y=O.target+O.to-O.from;for(let M=0;M<O.to-O.from;M++)p[O.from+M]=O.target+M,m[O.target+M]=O.from+M}return p[e.text.length]=n.text.length,m[n.text.length]=e.text.length,{status:"ready",runs:u,bTo:p,toB:m,monotone:R,covers:(O,M)=>{if(!a(M-O))return null;l.coverageChecks+=M-O;for(let E=O;E<M;E++)if(e.text[E]!==wt&&!/\s/.test(e.text[E])&&p[E]<0)return!1;return!0}}}function Qr({base:e,side:n,baseOf:t=()=>null,budget:o=Kt()}){if(e.text===n.text||!e.text.includes(wt)&&!n.text.includes(wt))return{status:"none"};let r=(e.text.length+n.text.length)*8;if(r>o.remaining)return{status:"fallback",reason:"work-limit"};o.remaining-=r,o.boundarySteps=(o.boundarySteps||0)+r;let c=(b,A)=>A<b.length&&(b[A]===wt||/\s/.test(b[A])),l=new Map,i=Symbol(),s=(b,A)=>{let p=b.stackAt[A]||[];if(!l.has(p)){if(p.length>o.remaining)throw i;o.remaining-=p.length,o.boundarySteps+=p.length,l.set(p,p.find(m=>m.block)?.el||null)}return l.get(p)},a=[],h=(b,A)=>{let p=s(e,b),m=s(n,A),y=p&&m&&t(m)!==p?"transfer":"retained",R=a[a.length-1];R&&R.to===b&&R.target+R.to-R.from===A&&R.kind===y&&R.destination===m?R.to++:a.push({from:b,to:b+1,target:A,destination:m,kind:y})},f=0,u=0,g=!1;try{for(;f<e.text.length||u<n.text.length;){if(f<e.text.length&&u<n.text.length&&e.text[f]===n.text[u]){let R=e.atomAt.get(f),S=n.atomAt.get(u);if(!!R!=!!S||R&&t(S.el)!==R.el)return{status:"none"};h(f++,u++);continue}if(!c(e.text,f)&&!c(n.text,u))return{status:"none"};let b=f,A=u;for(;c(e.text,f);)f++;for(;c(n.text,u);)u++;let p=e.text.slice(b,f),m=n.text.slice(A,u);(p.includes(wt)||m.includes(wt))&&(g=!0);let y=0;for(;y<f-b&&y<u-A&&e.text[f-y-1]===n.text[u-y-1];)y++;for(let R=y;R>0;R--)h(f-R,u-R)}}catch(b){if(b===i)return{status:"fallback",reason:"work-limit"};throw b}return g?Dn({base:e,side:n,retained:a.filter(b=>b.kind==="retained"),transfers:a.filter(b=>b.kind==="transfer"),sideAtomKey:b=>t(b.el)||b.el,budget:o}):{status:"none"}}var ci=/\s/,gr=/\S/;function Mn(e,n,t,o,r,c,l=-1,i=-1){if(!e.length)return-1;r(o,e.length);let s=new Int32Array(e.length),a=0;for(let g=1;g<e.length;g++){for(r(o,1);a&&(r(o,1),e[a]!==e[g]);)a=s[a-1];r(o,1),e[a]===e[g]&&a++,s[g]=a}let h=-1,f=0,u=0;a=0;for(let g=0;g<n.length;g++){for(r(o,1);a&&(r(o,1),e[a]!==n[g]);)a=s[a-1];if(r(o,1),e[a]===n[g]&&a++,a!==e.length)continue;let b=g+1-e.length,A=g+1;for(a=s[a-1];f<t.length&&t[f].from<b;)r(o,1),f++;for(;u<t.length&&t[u].to<A;)r(o,1),u++;if(r(o,6),!(f===t.length||u===t.length||t[f].from!==b||t[u].to!==A||l>=0&&b<i&&A>l)){if(!c)return b;if(h>=0)return-1;h=b}}return h}function Wo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function Zr(e,n,t,o){let r=null;for(let l of n)if(o(t,1),!(l.source!==e.source||l.side!==e.side))for(let i of l.runs){if(o(t,1),i.source!==e.source)continue;let s=Math.max(e.from,i.from),a=Math.min(e.to,i.to);s>=a||(r||(o(t,e.to-e.from),r=new Uint8Array(e.to-e.from)),o(t,a-s),r.fill(1,s-e.from,a-e.from))}if(!r)return!1;o(t,e.to-e.from);let c=!1;for(let l=e.from;l<e.to;l++)if(gr.test(e.flat.text[l])){if(!r[l-e.from])return!1;c=!0}return c}function es({source:e,side:n,views:t,eligible:o,blocked:r,baseId:c,model:l,tokensOf:i,budget:s,charge:a}){let{V:h,A:f,idOf:u}=t[n],g=t[1-n];if(e.nodeType!==1||f.identical.has(e)||g.A.identical.has(e)||r.has(e)||!o(e))return null;let b=h.twin(e),A=g.V.twin(e);if(!b||!A||f.map.get(e)!==b||f.reverse.get(b)!==e||g.A.map.get(e)!==A||g.A.reverse.get(A)!==e||!h.here(b)||!g.V.here(A)||!o(b)||!o(A))return null;let p=c(e);if(p!==u(b)||p!==g.idOf(A))return null;let m=l(e,null,s),y=l(b,f,s),R=l(A,g.A,s);if(!Wo(m)||!Wo(y)||!Wo(R))return null;let S=m.flat.text,O=y.flat.text;if(a(s,S.length+O.length*3),!gr.test(O)||O.length>=S.length)return null;let M=S.startsWith(O),E=S.endsWith(O);if(M===E)return null;let N=M?O.length:0,L=M?S.length:S.length-O.length,j=N,F=L;for(;j<F&&(a(s,1),!!ci.test(S[j]));)j++;for(;F>j&&(a(s,1),!!ci.test(S[F-1]));)F--;if(j===F)return null;let W=i(m,s),C=!1,T=!1;for(let x of W)a(s,1),x.from===j&&(C=!0),x.to===F&&(T=!0);return!C||!T?null:{source:e,side:n,flat:m.flat,from:N,to:L}}function ai({base:e,views:n,side:t,attempt:o,eligible:r,blocked:c,baseId:l,model:i,tokensOf:s,certificates:a,charge:h,exhausted:f,limit:u}){if(u<=0)return null;let g=Kt(u),{V:b,A,idOf:p}=n[t],m=n[1-t],[y,R,S,O]=o,M=null;try{for(let E=y;E<=R;E++){h(g,1);let N=e[E];if(N.nodeType!==1||A.identical.has(N)||m.A.identical.has(N)||c.has(N)||!r(N))continue;let L=es({source:N,side:t,views:n,eligible:r,blocked:c,baseId:l,model:i,tokensOf:s,budget:g,charge:h});if(!L||Zr(L,a,g,h))continue;let{flat:j,from:F,to:W}=L;h(g,(W-F)*2);let C=j.text.slice(F,W).trim();for(let T=S;T<=O;T++){h(g,1);let x=b.units[T],z=b.baseOf(x);if(!z||z===N||z.nodeType!==1||x.nodeType!==1||z.parentNode!==N.parentNode||x.parentNode!==A.map.get(N).parentNode||A.map.get(z)!==x||A.reverse.get(x)!==z||c.has(z)||!r(z)||!r(x)||l(z)!==p(x))continue;let D=i(z,null,g),V=i(x,A,g);if(!Wo(D)||!Wo(V))continue;let Ee=D.flat.text,Me=V.flat.text;if(h(g,Ee.length),!gr.test(Ee)||Me.length<=Ee.length)continue;let De=s(V,g),re=Mn(Ee,Me,De,g,h,!0);if(!(re<0)&&!(Mn(C,Me,De,g,h,!1,re,re+Ee.length)<0)){(M||=[]).push(L);break}}}}catch(E){if(E!==f)throw E}return M}function fi(e,n,t,o,r,c,l){if(c==="both"||t.atoms.length||o.atoms.length||r.atoms.length)return c;let i=c==="remote";if(i?l.rss!==l.rse||l.lss===l.lse||l.local===l.base:l.lss!==l.lse||l.rss===l.rse||l.remote===l.base)return c;for(let s of e){if(s.source!==n||s.side!==(i?1:0)||s.flat.text!==t.text||s.flat.nodes.length!==t.nodes.length||l.be<=s.from||l.bs>=s.to)continue;let a=!0;for(let f=0;f<t.nodes.length;f++){let u=s.flat.nodes[f],g=t.nodes[f];if(u.node!==g.node||u.s!==g.s||u.e!==g.e){a=!1;break}}if(!a)continue;let h=!1;for(let f=l.bs;f<l.be;f++)if(gr.test(t.text[f])){if(f<s.from||f>=s.to){a=!1;break}h=!0}if(a&&h)return i?"local":"remote"}return c}var Bn="\uFFFC";var Oc={caret:0},wn=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),yi=new Set(["BR","WBR","IMG"]),ts=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function Un(e,n={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(n.ignored&&n.ignored(e)||yi.has(e.tagName))return!0;if(!wn.has(e.tagName))return!ts.has(e.tagName);if(n.remoteWins&&n.remoteWins(e))return!1;let t=n.inlineCache&&n.inlineCache.get(e);if(t!==void 0)return t;let o=!0;for(let r of e.childNodes)if(!Un(r,n)){o=!1;break}return n.inlineCache&&n.inlineCache.set(e,o),o}function Mc(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function en(e,n={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,c)=>{for(let l of r){if(l.nodeType===3){let f=l.nodeValue;if(!f)continue;t.nodes.push({node:l,s:t.text.length,e:t.text.length+f.length}),t.text+=f;for(let u=0;u<f.length;u++)t.stackAt.push(c);continue}if(l.nodeType!==1)continue;if(n.ignored&&n.ignored(l)){t.pins.push({el:l,i:t.text.length});continue}if(n.skip&&n.skip.has(l))continue;let i=n.via&&n.via(l)||l;i!==l&&(t.via||(t.via=new Map)).set(i,l);let s=l.tagName;if(n.blocks&&n.blocks.has(l)){t.text.length&&t.text[t.text.length-1]!==wt&&(t.stackAt.push(c),t.text+=wt);let f={el:l,tag:s,from:t.text.length,to:-1,depth:c.length,block:!0};t.marks.push(f);let u=c.concat([f]);o(i.childNodes,u),t.stackAt.push(u),t.text+=wt,f.to=t.text.length;continue}let a=wn.has(s)&&Mc(i);if(yi.has(s)||!wn.has(s)||n.remoteWins&&n.remoteWins(l)||n.atomize&&n.atomize(l)||a){t.atoms.push({i:t.text.length,el:l,key:a?s+":empty":s,stack:c}),t.stackAt.push(c),t.text+=Bn;continue}let h={el:l,tag:s,from:t.text.length,to:-1,depth:c.length};t.marks.push(h),o(i.childNodes,c.concat([h])),h.to=t.text.length}};if(o(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&wr(t).trim()===""){let r=t.atoms[0];t.placeholder=r.el,t.text=t.text.slice(0,r.i)+t.text.slice(r.i+1),t.stackAt.splice(r.i,1);for(let c of t.nodes)c.s>r.i&&(c.s--,c.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(r=>[r.i,r])),t}function Ec(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Ic(e){let n="<"+e.tagName.toLowerCase();for(let t of e.attributes)n+=` ${t.name}="${t.value.replace(/"/g,"&quot;")}"`;return n+">"}function ko(e,n,t){let o="",r=[];for(let c=n;c<t;c++){let l=e.stackAt[c],i=0;for(;i<r.length&&i<l.length&&r[i]===l[i];)i++;for(;r.length>i;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<l.length;){let a=l[r.length];o+=Ic(a.el),r.push(a)}let s=e.atomAt.get(c);o+=s?s.el.outerHTML:e.text[c]===wt?"":Ec(e.text[c])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function Cc(e,n){let t=[...e.el.attributes].filter(o=>!n(e.el,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tag+"|"+t}function wi(e,n){let t=[...e.attributes].filter(o=>!n(e,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function ui(e,n=()=>!1){let t=new Map,o=c=>{let l=t.get(c);return l===void 0&&(l="{"+c.map(i=>Cc(i,n)).sort().join(",")+"}",t.set(c,l)),l},r="";for(let c=0;c<e.text.length;c++){let l=e.atomAt.get(c);r+=(l?"["+wi(l.el,n)+"]":e.text[c])+o(e.stackAt[c])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function xo(e,n,t,o=r=>r.key){let r=[],c=e.text,l=0,i=s=>{if(s<=l)return;let a=c.slice(l,s);if(t)for(let h of a.split(/(?<=\n)/))r.push({k:h,raw:h,len:h.length});else for(let h of ln(a,n))r.push(h)};for(let s of e.atoms)i(s.i),r.push({k:"\0"+o(s),raw:Bn,len:1,atom:!0}),l=s.i+1;return i(c.length),r}function wr(e){if(!e.atoms.length)return e.text;let n="",t=0;for(let o of e.atoms)n+=e.text.slice(t,o.i),t=o.i+1;return n+e.text.slice(t)}var To=e=>{let n=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)n[t+1]=n[t]+e[t].len;return n};function br(e,n,t,o){let r=To(n),c=To(t),l=[],i=0,s=0;for(let h of o.hunks){s+=h.bs-i;let f=s+h.toks.length;l.push({bs:r[h.bs],be:r[h.be],ss:c[s],se:c[f],text:e.text.slice(c[s],c[f]),toks:h.toks,lead:!!h.lead}),s=f,i=h.be}let a=new Map;for(let h of o.cosmetic)a.set(h.bi,h.tok.raw);return{hunks:l,respell:a}}function di(e,n,t){let o=l=>l===wt||/\s/.test(l),r=l=>l.replace(/[\u001E\s]/g,""),c=[];for(let l of e){let i=n.slice(l.bs,l.be),s=t.slice(l.ss,l.se);if(!i.includes(wt)&&!s.includes(wt)||i.includes(Bn)||s.includes(Bn)||r(i)!==r(s)){c.push(l);continue}let a=0,h=0;for(;;){let f=a,u=h;for(;f<i.length&&o(i[f]);)f++;for(;u<s.length&&o(s[u]);)u++;let g=a,b=h;for(;g<f&&b<u&&i[g]===s[b];)g++,b++;let A=f,p=u;for(;A>g&&p>b&&i[A-1]===s[p-1];)A--,p--;if(A>g||p>b){let m=s.slice(b,p);c.push({bs:l.bs+g,be:l.bs+A,ss:l.ss+b,se:l.ss+p,text:m,toks:[...m].map(y=>({k:y,raw:y,len:1})),lead:l.lead})}if(f>=i.length)break;a=f+1,h=u+1}}return c}function hi(e,n,t){let o=new Int32Array(n+1).fill(-1),r=new Int32Array(t+1).fill(-1),c=0,l=0,i=s=>{for(;c<s;)o[c]=l,r[l]=c,c++,l++};for(let s of e)i(s.bs),c=s.be,l=s.se;return i(n),o[n]=l,r[l]=n,{bTo:o,toB:r}}function pi(e,n,t){let o=[],r=0,c=0,l=(i,s)=>{if(r===i&&c===s)return;let a=n.text.slice(c,s);o.push({bs:r,be:i,ss:c,se:s,text:a,toks:ln(a,yn(a)),lead:!1})};for(let i of t.runs)l(i.from,i.target),r=i.to,c=i.target+i.to-i.from;return l(e.text.length,n.text.length),{hunks:o,respell:new Map}}function mi(e,n,t,o){let r=To(n),c=To(t),l=(s,a)=>{let h=0,f=s.length;for(;h<f;){let u=h+f>>>1;s[u]<a?h=u+1:f=u}return s[h]===a?h:-1};for(let s of e.hunks)if(l(r,s.bs)<0||l(r,s.be)<0)return null;if(e.hunks.some(s=>l(c,s.ss)<0||l(c,s.se)<0)){if(!o)return null;let s=[];for(let u of e.hunks)s.push(u.ss,u.se);let a=[],h=0,f=0;for(let u of t){let g=f+u.len;for(;h<s.length&&s[h]<=f;)h++;let b=f;for(;h<s.length&&s[h]<g;){let A=s[h++];if(A>b){let p=u.raw.slice(b-f,A-f);a.push(...ln(p,yn(p))),b=A}}if(b===f)a.push(u);else{let A=u.raw.slice(b-f);a.push(...ln(A,yn(A)))}f=g}t=a,c=To(t)}let i=[];for(let s of e.hunks){let a=l(r,s.bs),h=l(r,s.be),f=l(c,s.ss),u=l(c,s.se);if(a<0||h<0||f<0||u<0)return null;i.push({bs:a,be:h,toks:t.slice(f,u),gap:[],group:i.length})}return{parts:i,cosmeticEq:[],tokens:t}}function ns(e,n,t,o={},r=null){return xi(e,n,t,o.base,o.local,o.remote,r,{})}function xi(e,n,t,o,r,c,l,i){let s=yn(wr(e),wr(n),wr(t)),a=xo(e,s,!1,o),h=xo(n,s,!1,r),f=xo(t,s,!1,c),u=a.length>2e4||h.length>2e4||f.length>2e4;u&&(a=xo(e,s,!0,o),h=xo(n,s,!0,r),f=xo(t,s,!0,c));let g=l?.local?pi(e,n,l.local):null,b=l?.remote?pi(e,t,l.remote):null,A=g?mi(g,a,h,!u):Kn(a,h),p=b?mi(b,a,f,!u):Kn(a,f);g&&A&&(h=A.tokens),b&&p&&(f=p.tokens);let m,y;if(A&&p){let R=Xr(A,p,a);m=br(n,a,h,{hunks:R.lh,cosmetic:R.cosL}),y=br(t,a,f,{hunks:R.rh,cosmetic:R.cosR})}else m=g||br(n,a,h,A),y=b||br(t,a,f,p);return m.hunks=di(m.hunks,e.text,n.text),y.hunks=di(y.hunks,e.text,t.text),i.base=e,i.local=n,i.remote=t,i.lines=u,i.baseTokens=a,i.localEdits=m,i.remoteEdits=y,i.localMap=hi(m.hunks,e.text.length,n.text.length),i.remoteMap=hi(y.hunks,e.text.length,t.text.length),i.full=null,i}function gi(e,n){if(e.size!==n.size)return!1;for(let t of e)if(!n.has(t))return!1;return!0}var Ao=/\s/;function yr(e,n,t){for(let o=n;o<t;o++)if(!Ao.test(e[o]))return!1;return!0}function Rc(e,n,t){let o=e.cache[t]||(e.cache[t]=new Map);if(o.has(n))return o.get(n);let r=t===0?"local":"remote",c=t===0?"remote":"local",l=n.baseMark,i=n[c+"Mark"],s=!n.block&&!n[r]&&!!i&&l.to>l.from;if(s){let a=t===0?e.ML:e.MR,h=t===0?e.MR:e.ML,f=t===0?e.fr:e.fl,u=!1;for(let g=l.from;g<l.to;g++){if(a.bTo[g]>=0){s=!1;break}h.bTo[g]<0&&!Ao.test(e.fb.text[g])&&(u=!0)}if(s&&!u){for(let g=i.from;g<i.to;g++)if(h.toB[g]<0&&!Ao.test(f.text[g])){u=!0;break}}s&&=u}return o.set(n,s),s}function bi(e,n,t,o,r,c,l,i,s){let a=i===0?e.fl:e.fr,h=null;for(let f=t;f<o;f++){let u=n[f];if(!yr(a.text,u.ss,u.se))return null;if(yr(e.fb.text,u.bs,u.be)){if(u.bs<u.be&&u.ss<u.se||Ao.test(e.fb.text[u.bs-1]||"")||Ao.test(e.fb.text[u.be]||""))continue;return null}let g=!1;for(let b=u.bs;b<u.be;b++){if(Ao.test(e.fb.text[b]))continue;let A=null;for(let p of e.fb.stackAt[b]){let m=e.byEl.get(p.el);if(m&&Rc(e,m,i)){A=m;break}}if(!A)return null;(h||(h=new Set)).add(A),g=!0}if(!g)return null}if(!h){if((i===0?"local":"remote")!==s)return null;let f=i===0?e.fr:e.fl,u=!1;for(let g=c;g<l;g++){let b=r[g];if(!yr(e.fb.text,b.bs,b.be))return null;yr(f.text,b.ss,b.se)||(u=!0)}if(!u)return null}return h||0}function so(e){let{out:n,policy:t="remote",L:o,R:r}=e,c=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,i=e.conflicts||[],s=e.decisions||[],a=i.length,h=e.conflict||(d=>i.push(d)),f={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},u=[],g=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),b={base:null,local:null,remote:null};if(!e.prepared&&g&&e.moveIn){let d=Te=>Ve=>Te.some(Re=>Re===Ve||Re.nodeType===1&&Re.contains(Ve)),I=d(e.local),U=d(e.remote),H=d(e.base),X=new Set,de=Te=>{if(!wn.has(Te.tagName))return;let Ve=o.map.get(Te),Re=r.map.get(Te);(Ve&&!I(Ve)||Re&&!U(Re))&&X.add(Te);for(let Fe of Te.children)de(Fe)};for(let Te of e.base)Te.nodeType===1&&de(Te);let we=Te=>Ve=>{if(!wn.has(Ve.tagName))return!1;let Re=Te.reverse.get(Ve);return!!Re&&(X.has(Re)||!H(Re))};X.size&&(b.base=Te=>X.has(Te)),b.local=we(o),b.remote=we(r)}let A={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&g&&e.moveIn){let d=H=>X=>H.some(de=>de===X||de.nodeType===1&&de.contains(X)),I=d(e.local),U=d(e.remote);for(let H of en(e.base,{...e,atomize:b.base}).atoms){let X=o.map.get(H.el),de=r.map.get(H.el),we=!!X&&!I(X),Te=!!de&&!U(de);!we&&!Te||(we&&e.movePlanned?.(H.el,"local",X,null),Te&&e.movePlanned?.(H.el,"remote",de,null),A.base.add(H.el),X&&!we&&A.local.add(X),de&&!Te&&A.remote.add(de),I(H.el)&&A.local.add(H.el),U(H.el)&&A.remote.add(H.el))}}let p=e.prepared?.base||en(e.base,{...e,atomize:b.base,skip:A.base}),m=e.prepared?.local||en(e.local,{...e,atomize:b.local,skip:A.local}),y=e.prepared?.remote||en(e.remote,{...e,atomize:b.remote,skip:A.remote}),R=new Map(p.atoms.map(d=>[d.el,d])),S={},O=d=>e.prepared?e.prepared.full?.(d)||null:A[d].size?(S[d]||(S[d]=en(e[d],{...e,atomize:b[d]})),S[d]):null,M=(d,I,U)=>{I.namespaceURI?d.setAttributeNS(I.namespaceURI,I.name,U):d.setAttribute(I.name,U)},E=(d,I,U,H)=>{if(!I&&(!U||!H)){for(let de of(U||H).attributes)M(d,de,de.value);return}let X=new Map;for(let de of[I,U,H])if(de)for(let we of de.attributes)X.set(we.name,we);for(let[de,we]of X){let Te=I?I.getAttribute(de):null,Ve=U?U.getAttribute(de):Te,Re=H?H.getAttribute(de):Te,Fe;Ve===Re?Fe=Ve:Ve===Te?(Fe=Re,s.push({kind:"attr",el:d,name:de,source:"remote"})):Re===Te?(Fe=Ve,s.push({kind:"attr",el:d,name:de,source:"local"})):(Fe=t==="local"?Ve:Re,h({kind:"attr",el:d,name:de,base:Te,local:Ve,remote:Re,resolved:Fe},{el:d,sample:we}),s.push({kind:"attr",el:d,name:de,source:"both"})),Fe!=null&&M(d,we,Fe)}},N=(d,I,U,H)=>d&&e.mergeAttrs?e.mergeAttrs(d,I,U,H):E(H,d,I,U),L=e.mergeElement||((d,I,U)=>{let H=n.createElement(d.tagName);N(d,I,U,H);let X=I||d,de=U||d,we=t==="local"?X.isEqualNode(d)?de:X:de.isEqualNode(d)?X:de;for(let Te of we.childNodes)H.appendChild(n.importNode(Te,!0));return c.set(H,{base:d,local:I,remote:U}),H}),j=e.cloneUnit||((d,I)=>{let U=n.importNode(d,!0);return c.set(U,{base:null,local:I==="local"?d:null,remote:I==="remote"?d:null}),U}),F=e.atomKey||(d=>wi(d,()=>!1)),W=(d,I)=>{let U=new Map;for(let H of d.atoms)if(e.remoteWins&&e.remoteWins(H.el)&&wn.has(H.el.tagName))U.set(H,"w"+H.el.tagName+"#"+(H.el.id||""));else if(!g)U.set(H,H.key);else if(d===p)U.set(H,"="+F(H.el));else{let X=I.reverse.get(H.el),de=X?R.get(X):null;de?U.set(H,"="+F(de.el)):X?U.set(H,"m"+F(H.el)):U.set(H,"="+F(H.el))}return H=>U.get(H)},C=W(p,null),T=W(m,o),x=W(y,r),z=e.certifiedOrigins?e.certifiedOrigins(p,m,y,C,T,x):null;if(z?.fallback)return null;if(!z&&!e.prepared&&e.blocks){let d=Kt(),I=Qr({base:p,side:m,baseOf:H=>o?.reverse?.get(H)||null,budget:d}),U=Qr({base:p,side:y,baseOf:H=>r?.reverse?.get(H)||null,budget:d});(I.status==="ready"||U.status==="ready")&&(z={local:I.status==="ready"?I:null,remote:U.status==="ready"?U:null})}let D=e.prepared||xi(p,m,y,C,T,x,z,f),V=D.lines,Ee=D.baseTokens,Me=D.localEdits,De=D.remoteEdits,re=D.localMap,Se=D.remoteMap,qe=p.text.length,ve=d=>new Map(d.atoms.map(I=>[I.el,I])),w=ve(m),K=ve(y),ne=(d,I,U)=>{let H=new Set;if(!g)return H;for(let X of d.atoms){let de=R.get(I.reverse.get(X.el));de&&U.bTo[de.i]<0&&H.add(de)}return H},ee=ne(m,o,re),Pe=ne(y,r,Se),_e=d=>!Un(d,{...e,remoteWins:null}),Ae=new Set;if(g)for(let d of p.atoms){if(!_e(d.el))continue;let I=o.map.get(d.el)||null,U=r.map.get(d.el)||null,H=I&&!U?I:U&&!I?U:null;H&&(w.has(H)||K.has(H))&&!H.isEqualNode(d.el)&&Ae.add(d)}let ot=1,Qe=(d,I)=>({id:ot++,tag:d,base:null,local:null,remote:null,rank:I}),Ze=new Map,Xe=[];for(let d of p.marks){let I=Qe(d.tag,d.depth);I.block=!!d.block,I.base=d.el,I.baseMark=d,Ze.set(d.el,I),Xe.push(I)}let yt=(d,I)=>{let U=-1,H=-1;for(let X=d.from;X<d.to;X++){let de=I[X];de>=0&&(U<0&&(U=de),H=de+1)}return U<0?null:[U,H]},dt=(d,I,U,H)=>{for(let X of d.marks){let de=U?U.reverse.get(X.el):null;de&&U.identical.has(de)&&U.pairIdenticalChildren&&U.pairIdenticalChildren(de);let we=de?Ze.get(de):null;if(we&&we[I]&&(we=null),!we){let Te=yt(X,H),Ve=0;if(Te)for(let Re of Xe){if(Re.tag!==X.tag||Re[I]||!!Re.block!=!!X.block)continue;let Fe=Math.min(Te[1],Re.baseMark.to)-Math.max(Te[0],Re.baseMark.from);(Fe>Ve||Fe===Ve&&Fe>0&&Math.abs(Re.rank-X.depth)<Math.abs(we.rank-X.depth))&&(we=Re,Ve=Fe)}}we||(we=Qe(X.tag,X.depth),we.block=!!X.block,we.new=I),we[I]=X.el,we[I+"Mark"]=X,Ze.set(X.el,we)}};dt(m,"local",o,re.toB),dt(y,"remote",r,Se.toB);let gt=d=>d.merged||d,qt=d=>{let I=new Set;for(let U of d)U.block||I.add(Ze.get(U.el));return I},$t=new Map,Ht=d=>{let I=$t.get(d);return I||(I=qt(d),$t.set(d,I)),I},jt=(d,I)=>{let U=[],H=null;for(let X=0;X<qe;X++){let de=I[X];if(de<0){H&&U.push(H),H=null;continue}let we=Ht(p.stackAt[X]),Te=Ht(d.stackAt[de]),Ve=new Set,Re=new Set;for(let Fe of Te)we.has(Fe)||Ve.add(Fe);for(let Fe of we)Te.has(Fe)||Re.add(Fe);if(!Ve.size&&!Re.size){H&&U.push(H),H=null;continue}if(H&&gi(H.added,Ve)&&gi(H.removed,Re)){H.be=X+1;continue}H&&U.push(H),H={bs:X,be:X+1,added:Ve,removed:Re}}return H&&U.push(H),U},an=jt(m,re.bTo),_t=jt(y,Se.bTo),zt=d=>d.be>d.bs?[d.bs,d.be-1]:[d.bs-1,d.bs],_=(d,I)=>{if(qe===0)return null;let[U,H]=zt(d);for(let X of I){if(X.be<=U)continue;if(X.bs>H)break;let de=X.bs<=U&&H<X.be;return de&&d.text===""&&X.bs===d.bs&&X.be===d.be?"straddle":de?X:d.be>d.bs?"straddle":null}return null},ie=d=>d.bs===d.be,me=(d,I,U=null)=>{let H=!1;for(let X=d.bs;X<d.be;X++){let de=p.text[X];if(de===wt)H=!0;else if(!/\s/.test(de))return!1}for(let X=d.ss;X<d.se;X++){let de=I.text[X];if(de===wt)H=!0;else if(!/\s/.test(de)){let we=U&&e.scopeUnits&&ie(d)&&I.atomAt.get(X);if(!we||!_e(we.el)||U.ss!==U.se||U.bs>=U.be)return!1;for(let Ve=U.bs;Ve<U.be;Ve++)if(!/\s/.test(p.text[Ve]))return!1;let Te=I===m?1:2;if(!e.scopeUnits[Te].includes(we.el)||(Te===1?o:r)?.reverse.has(we.el))return!1;H=!0}}return H},pe=(d,I)=>d.bs<I.be&&I.bs<d.be,ke=(d,I)=>d.bs<=I.be&&I.bs<=d.be&&ie(d)!==ie(I),v=(d,I)=>p.text.slice(d.bs,d.be).includes(wt)||I.text.slice(d.ss,d.se).includes(wt),P=d=>{if(ie(d))return!1;let I=d.bs,U=d.be;for(;I>0&&/\s/.test(p.text[I-1]);)I--;for(;U<p.text.length&&/\s/.test(p.text[U]);)U++;return(I===0||p.text[I-1]===wt)&&(U===p.text.length||p.text[U]===wt)},Y=(d,I)=>!v(d,I)&&!P(d),J=(d,I)=>pe(d,I)||ke(d,I)&&!(d.transferIn||d.transferOut||I.transferIn||I.transferOut)&&!(me(d,m,I)&&Y(I,y))&&!(me(I,y,d)&&Y(d,m)),oe=(d,I)=>{if(d.bs!==I.bs||d.be!==I.be||d.toks.length!==I.toks.length)return!1;let U=d.ss,H=I.ss;for(let X=0;X<d.toks.length;X++){let de=d.toks[X],we=I.toks[X];if(de.k!==we.k||de.atom&&!m.atomAt.get(U).el.isEqualNode(y.atomAt.get(H).el))return!1;U+=de.len,H+=we.len}return!0},je=(d,I,U,H)=>{for(let X of p.atoms){if(X.i<d.bs||X.i>=d.be||H.has(X)||Ae.has(X))continue;let de=I.bTo[X.i],we=de>=0?U.atomAt.get(de):null;if(we&&!we.el.isEqualNode(X.el))return!0}return!1},Z=[],Oe=null,He=null,Ie=Me.hunks,ge=De.hunks,B=0,G=0,ue=0,he=0,ce=0,xe=d=>{d>ue&&(Z.push({src:"base",from:ue,to:d,dL:he,dR:ce}),ue=d)};for(;B<Ie.length||G<ge.length;){let d=Ie[B],I=ge[G],U=!!d&&(!I||d.bs<I.bs||d.bs===I.bs&&d.be<=I.be&&!I.lead);if(d&&I&&d.bs===I.bs&&ie(d)&&ie(I)){let Ft=me(d,m),Bo=me(I,y);Ft!==Bo&&(U=Bo)}let H=U?d:I,X=U?I:d,de=!!X&&oe(d,I),we=!!X&&(U?!!Ie[B+1]&&oe(Ie[B+1],I):!!ge[G+1]&&oe(d,ge[G+1])),Te=!!X&&!de&&!we&&(qe===0||J(d,I)),Ve=Te,Re=_(H,U?_t:an);if(Re==="straddle"&&(Ve=!0),!Ve&&H.be>H.bs&&(Ve=je(H,U?Se:re,U?y:m,U?ee:Pe)),!Ve&&de){xe(H.bs),Z.push({src:"both",lfrom:d.ss,rfrom:I.ss,len:H.text.length,owner:d.owner||I.owner||null,transfer:d.transferIn||I.transferIn||null}),ue=H.be,he+=H.text.length-(H.be-H.bs),ce+=H.text.length-(H.be-H.bs),B++,G++;continue}if(!Ve){xe(H.bs),Z.push({src:U?"local":"remote",from:H.ss,to:H.se,inherit:Re&&Re!=="straddle"?Re:null,owner:H.owner||null,transfer:H.transferIn||null}),ue=H.be,U?(he+=H.text.length-(H.be-H.bs),B++):(ce+=H.text.length-(H.be-H.bs),G++);continue}let Fe=H.bs,ht=H.be,lt=B,ft=G,Ut=Ft=>Ft.bs<ht&&Ft.be>Fe||ie(Ft)&&(Ft.bs===Fe||Ft.bs===ht);U?lt++:ft++,Te&&(Fe=Math.min(Fe,X.bs),ht=Math.max(ht,X.be),U?ft++:lt++);let Pt=!0;for(;Pt;){for(Pt=!1;lt<Ie.length&&Ut(Ie[lt]);)Fe=Math.min(Fe,Ie[lt].bs),ht=Math.max(ht,Ie[lt].be),lt++,Pt=!0;for(;ft<ge.length&&Ut(ge[ft]);)Fe=Math.min(Fe,ge[ft].bs),ht=Math.max(ht,ge[ft].be),ft++,Pt=!0}let dn=Fe+he,rn=Fe+ce,gn=ht-Fe,Tn=ht-Fe;for(let Ft=B;Ft<lt;Ft++)gn+=Ie[Ft].text.length-(Ie[Ft].be-Ie[Ft].bs);for(let Ft=G;Ft<ft;Ft++)Tn+=ge[Ft].text.length-(ge[Ft].be-ge[Ft].bs);let Pn=dn+gn,jn=rn+Tn;if(xe(Fe),B<lt&&G<ft&&!z&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!p.atoms.length&&!m.atoms.length&&!y.atoms.length&&!p.pins.length&&!m.pins.length&&!y.pins.length){Oe||={fb:p,fl:m,fr:y,ML:re,MR:Se,byEl:Ze,cache:[null,null]};let Ft=bi(Oe,Ie,B,lt,ge,G,ft,0,t),Bo=bi(Oe,ge,G,ft,Ie,B,lt,1,t);if(Ft===null!=(Bo===null)){let Cr=Ft!==null,Gs=Cr?Ft:Bo;if(Gs){He||=new Map;for(let Bl of Gs)He.set(Bl,Cr?"local":"remote")}Z.push(Cr?{src:"remote",from:rn,to:jn}:{src:"local",from:dn,to:Pn}),ue=ht,he+=gn-(ht-Fe),ce+=Tn-(ht-Fe),B=lt,G=ft;continue}}let Zt={kind:"text",node:e.node||null,base:ko(p,Fe,ht),local:ko(m,dn,Pn),remote:ko(y,rn,jn),resolved:null,range:null,bs:Fe,be:ht,lss:dn,lse:Pn,rss:rn,rse:jn},no=e.sourceRetentions?fi(e.sourceRetentions,e.scope?.base,p,m,y,t,Zt):t;Zt.resolved=no==="local"?Zt.local:no==="remote"?Zt.remote:Zt.local+Zt.remote,no!=="remote"&&Z.push({src:"local",from:dn,to:Pn,conflict:Zt}),no!=="local"&&Z.push({src:"remote",from:rn,to:jn,conflict:Zt});let oo={site:"inline",policy:no,fb:p,fl:m,fr:y,scope:e.scope||null,synthetic:!!e.synthetic,full:O,merged:f};u.push(oo),h(Zt,oo),ue=ht,he+=gn-(ht-Fe),ce+=Tn-(ht-Fe),B=lt,G=ft}xe(qe);let te=p.text,q=[];if(Me.respell.size||De.respell.size){let d=To(Ee),I=[];for(let U=0;U<Ee.length;U++){let H=Ee[U].raw,X=Me.respell.get(U)??H,de=De.respell.get(U)??H;(X!==H||de!==H)&&q.push([d[U],X!==H&&de!==H?"both":X!==H?"local":"remote"]),I.push(X===de?X:X===H?de:de===H||t==="local"?X:de)}te=I.join("")}let ae="",Ce=[],Le=[],We=[],Ne=[];for(let d of Z){let I=ae.length;if(d.src==="base"){for(let U=d.from;U<d.to;U++)Ce.push(U),Le.push(e.nativeTransfers?re.bTo[U]:U+d.dL),We.push(e.nativeTransfers?Se.bTo[U]:U+d.dR),Ne.push(d);ae+=te.slice(d.from,d.to)}else if(d.src==="both"){for(let U=0;U<d.len;U++){let H=d.transfer&&(d.transfer.side==="remote"?d.rfrom+U:d.lfrom+U);Ce.push(d.transfer&&H>=d.transfer.ss&&H<d.transfer.se?d.transfer.bs+H-d.transfer.ss:-1),Le.push(d.lfrom+U),We.push(d.rfrom+U),Ne.push(d)}ae+=m.text.slice(d.lfrom,d.lfrom+d.len)}else{let U=d.src==="local"?m:y,H=d.transfer&&e.nativeTransfers.byOrigin[d.src==="local"?"remote":"local"].get(d.transfer.key);for(let X=d.from;X<d.to;X++){let de=d.transfer&&X>=d.transfer.ss&&X<d.transfer.se?d.transfer.bs+X-d.transfer.ss:-1,we=de>=0&&(!H||H.destination===d.owner)?(d.src==="local"?Se:re).bTo[de]:-1;Ce.push(de),Le.push(d.src==="local"?X:we),We.push(d.src==="remote"?X:we),Ne.push(d)}ae+=U.text.slice(d.from,d.to)}d.ms=I,d.me=ae.length,d.conflict&&(d.conflict.range||(d.conflict.range=[I,I]),d.conflict.range[1]=ae.length)}let ze=ae.length,tt=new Int32Array(qe+1).fill(-1),k=new Int32Array(m.text.length+1).fill(-1),$=new Int32Array(y.text.length+1).fill(-1);for(let d=0;d<ze;d++)Ce[d]>=0&&(tt[Ce[d]]=d),Le[d]>=0&&(k[Le[d]]=d),We[d]>=0&&($[We[d]]=d);let Q=(d,I)=>{let U=-1,H=-1;for(let X=d.from;X<d.to;X++){let de=I[X];de>=0&&(U<0&&(U=de),H=de+1)}return U<0?null:[U,H]},be=[],fe=[];for(let d of new Set(Ze.values()))d.new==="local"?be.push(d):d.new==="remote"&&fe.push(d);let se=(d,I)=>{d.remote=I.remote,d.remoteMark=I.remoteMark,d.new="both",I.merged=d,Ze.set(I.remote,d)};if(be.length&&fe.length){let d=e.idOf;for(let I of be){let U=d?d.local(I.local):null;if(!U)continue;let H=fe.find(X=>!X.merged&&X.tag===I.tag&&!!X.block==!!I.block&&d.remote(X.remote)===U);H&&se(I,H)}for(let I of be){if(I.remote)continue;let U=Q(I.localMark,k);if(U)for(let H of fe){if(H.merged||H.tag!==I.tag||!!H.block!=!!I.block)continue;let X=Q(H.remoteMark,$);if(X&&Math.min(U[1],X[1])-Math.max(U[0],X[0])>0){se(I,H);break}}}}$t.clear();let le=d=>{for(let I of d)if(I.block)return gt(Ze.get(I.el));return null},Be=p.marks.some(d=>d.block)||m.marks.some(d=>d.block)||y.marks.some(d=>d.block),Ke=new Array(ze).fill(null),Ue=new Set;if(e.nativeTransfers)for(let d=0;d<ze;d++){let I=Ne[d].owner;Ke[d]=I?gt(Ze.get(I)):Ce[d]>=0?le(p.stackAt[Ce[d]]):null}else if(Be){let d=(Re,Fe,ht)=>{let lt=new Set([Re,Fe,ht]);lt.delete(null);let ft=[];for(let Pt of lt){let dn=Pt===Re,rn=Pt===Fe,gn=Pt===ht;(rn===gn?rn:rn===dn?gn:rn)&&ft.push(Pt)}if(ft.length<=1)return ft[0]||null;let Ut=t==="local"?Fe:ht;return ft.includes(Ut)?Ut:ft[0]},I=(Re,Fe)=>Fe>=0?le(Re.stackAt[Fe]):null,U=new Map;for(let Re=0;Re<ze;Re++){if(ae[Re]!==wt)continue;let Fe=Ce[Re]>=0?I(p,Ce[Re]):null,ht=I(m,Le[Re]),lt=I(y,We[Re]);U.set(Re,[Fe,Ce[Re]>=0?d(Fe,ht,lt):ht||lt])}let H=new Set([...U.values()].map(Re=>Re[1])),X=Re=>Re!==wt&&Re!==Bn&&!/\s/.test(Re),de=(Re,Fe)=>{let ht=Re;for(;ht<Fe&&!X(ae[ht]);)ht++;return ht<Fe&&Ce[ht]>=0?I(p,Ce[ht]):null},we=new Map,Te=0;for(let Re=0;Re<ze;Re++){if(ae[Re]!==wt)continue;let[Fe,ht]=U.get(Re),lt=de(Te,Re),ft=ht,Ut=we.get(ft)===ft&&lt===ft;ft&&we.has(ft)&&!Ut&&Fe&&!we.has(Fe)&&!H.has(Fe)&&(ft=Fe),ft&&!we.has(ft)&&we.set(ft,lt);for(let Pt=Te;Pt<=Re;Pt++)Ke[Pt]=ft;Te=Re+1}let Ve=Re=>{for(let Fe=0;Fe<Re.text.length;Fe++)if(X(Re.text[Fe])&&!I(Re,Fe))return!0;return!1};if(!Ve(p)&&!Ve(m)&&!Ve(y)){let Re=[],Fe=0;for(let lt=0;lt<ze;lt++)(ae[lt]===wt||lt===ze-1)&&(Re.push([Fe,lt]),Fe=lt+1);let ht=new Set(Ke);for(let lt=0;lt<Re.length;lt++){let[ft,Ut]=Re[lt];if(Ke[Ut])continue;let Pt=ft;for(;Pt<=Ut&&!X(ae[Pt]);)Pt++;if(Pt>Ut)continue;let dn=I(p,Ce[Pt]),rn=I(m,Le[Pt]),gn=I(y,We[Pt]),Tn=d(dn,rn,gn)||rn||gn||dn;if(Tn&&!ht.has(Tn)){ht.add(Tn);for(let Zt=ft;Zt<=Ut;Zt++)Ke[Zt]=Tn;continue}let Pn=lt>0&&Ke[Re[lt-1][1]],jn=lt+1<Re.length&&Ke[Re[lt+1][1]];if(Pn)Ue.add(Re[lt-1][1]);else if(jn&&ae[Ut]===wt)Ue.add(Ut);else continue;for(let Zt=ft;Zt<=Ut;Zt++)Ke[Zt]=Pn||jn}}}let $e=new Map,Ge=d=>{let I=$e.get(d);if(I)return I;I=[1/0,-1/0];for(let[U,H]of[[d.baseMark,tt],[d.localMark,k],[d.remoteMark,$]]){let X=U&&Q(U,H);X&&(I[0]=Math.min(I[0],X[0]),I[1]=Math.max(I[1],X[1]))}return $e.set(d,I),I},et=(d,I,U)=>{let H=-1,X=-1;for(let de=0;de<d.length;de++){let we=Ze.get(d[de].el);we===I&&(H=de),we===U&&(X=de)}return H>=0&&X>=0?H-X:0},Ot=(d,I)=>[...d].sort((U,H)=>{for(let we of I){let Te=et(we,U,H);if(Te)return Te}let X=Ge(U),de=Ge(H);return X[0]-de[0]||de[1]-X[1]||U.rank-H.rank||U.id-H.id}),xt=new Map,Jt=new Map,Mt=e.nativeTransfers?[]:null,pt=d=>{if(Mt)return Mt;let I=Ce[d],U=Le[d],H=We[d],X=Ne[d];if(I>=0){let lt=p.stackAt[I],ft=m.stackAt[U],Ut=y.stackAt[H],Pt=xt.get(lt);Pt||xt.set(lt,Pt=new Map);let dn=Pt.get(ft);dn||Pt.set(ft,dn=new Map);let rn=dn.get(Ut);if(rn)return rn;let gn=Ht(lt),Tn=Ht(ft),Pn=Ht(Ut),jn=new Set;for(let Zt of new Set([...gn,...Tn,...Pn])){let no=gn.has(Zt),oo=Tn.has(Zt),Ft=Pn.has(Zt);(oo===Ft?oo:oo===no?Ft:oo)&&jn.add(Zt)}return rn=Ot(jn,[ft,Ut,lt]),dn.set(Ut,rn),rn}if(X.src==="both"){let lt=m.stackAt[U],ft=y.stackAt[H];return Ot(new Set([...Ht(lt),...Ht(ft)]),[lt,ft])}let we=(X.src==="local"?m:y).stackAt[X.src==="local"?U:H];if(!X.inherit)return Ot(Ht(we),[we]);let Te=Jt.get(X);Te||Jt.set(X,Te=new Map);let Ve=Te.get(we);if(Ve)return Ve;let Re=new Set(Ht(we));for(let lt of X.inherit.added)Re.add(gt(lt));for(let lt of X.inherit.removed)Re.delete(gt(lt));let Fe=X.src==="local"?y:m,ht=(X.src==="local"?Se.bTo:re.bTo)[X.inherit.bs];return Ve=Ot(Re,[we,Fe.stackAt[ht]]),Te.set(we,Ve),Ve},bt=new Int32Array(m.text.length+1);bt[m.text.length]=ze;for(let d=m.text.length-1;d>=0;d--)bt[d]=k[d]>=0?k[d]:bt[d+1];Oc.caret+=m.text.length;let mt=d=>d<=0?0:(d>m.text.length&&(d=m.text.length),k[d-1]>=0?k[d-1]+1:bt[d]),It=[],ct=[],Wt=null,St=[],fn="",Gt=-1,Fn=d=>{Wt?Wt.appendChild(d):It.push(d)},Rn=d=>{if(!fn)return;let I=n.createTextNode(fn);Fn(I),ct.push({node:I,ms:Gt,me:d,local:[],u:St.length?St[St.length-1].u:null}),fn=""},cr=new Set,$n=new Map,jo=new Set,Ir=d=>{let I=n.createElement(d.tag);if(d.block&&Ct.add(I),!$n.has(d)){$n.set(d,I),N(d.base,d.local,d.remote,I),c.set(I,{base:d.base,local:d.local,remote:d.remote});let H=(we,Te)=>g&&d[Te]&&we.reverse.get(d[Te])?Te:null,X=!d.base&&(H(o,"local")||H(r,"remote"));if(X){let we=X==="local"?o.reverse.get(d.local):r.reverse.get(d.remote),Te=c.get(I);Te.local=Te.local||o.map.get(we)||null,Te.remote=Te.remote||r.map.get(we)||null,s.push({kind:"move",el:I,source:X}),e.moveBuilt?.(we,X,d[X],I)}else d.base||s.push({kind:"insert",el:I,source:d.local&&d.remote?"both":d.local?"local":"remote"});let de=c.get(I);de.local&&(jo.has(de.local)?de.local=null:jo.add(de.local))}else{let H=$n.get(d);for(let X of H.attributes)X.name!=="id"&&X.name!=="data-id"&&M(I,X,X.value);c.set(I,{base:null,local:null,remote:null})}Fn(I),St.push({u:d,el:I}),Wt=I},ye=new Set,Je=new Map;for(let d of m.pins){let I=mt(d.i);Je.has(I)||Je.set(I,[]),Je.get(I).push(d)}let Ye=d=>{let I=Je.get(d);if(I){Rn(d);for(let U of I){let H=U.el.namespaceURI&&U.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?n.createElementNS(U.el.namespaceURI,U.el.tagName):n.createElement(U.el.tagName);c.set(H,{base:null,local:U.el,remote:null,pinned:!0}),ye.add(H),Fn(H)}}},kt=p.atoms.length||m.atoms.length||y.atoms.length,Dt=d=>{if(!kt)return null;let I=Ce[d]>=0?p.atomAt.get(Ce[d]):null,U=Le[d]>=0?m.atomAt.get(Le[d]):null,H=We[d]>=0?y.atomAt.get(We[d]):null;return I||U||H?{ab:I,al:U,ar:H}:null},rt=(d,I,U)=>{let H=e.idOf;if(!H||!H.base)return!1;let X=H.base(d.el);return X!=null&&X===H[U](I.el)},At=(d,I,U,H,X)=>{if(!d||!g)return null;let de=R.get(I.reverse.get(d.el))||null;return!de||de===H||(H?de.el.isEqualNode(H.el)&&!rt(de,d,X):U.bTo[de.i]>=0)?null:de},Lt=(d,I)=>{if(!d||!g||!e.moveIn)return null;let U=I.reverse.get(d.el);return U&&!R.has(U)?U:null},at=(d,I)=>{let U=new Map;for(let H of d.atoms)U.set(I(H),(U.get(I(H))||0)+1);return U},Nt=at(p,C),sn=at(m,T),un=at(y,x),xn=d=>{let I=C(d);return Nt.get(I)===1&&(sn.get(I)||0)<=1&&(un.get(I)||0)<=1},mn=new Map,kn=new Set,Ln=new Set,ar=new Set,it=null;for(let d=0;d<ze;d++){let I=Dt(d);if(!I)continue;let{ab:U,al:H,ar:X}=I,de=At(X,r,Se,U,"remote"),we=At(H,o,re,U,"local"),Te=U,Ve=null;if(de?(Te=de,Ve="remote"):we&&(Te=we,Ve="local"),Te){U&&Te!==U&&(it||=new Map).set(U,Ve),kn.has(Te)?mn.set(d,{dup:Te.el}):(kn.add(Te),mn.set(d,{bk:Te,from:Ve,al:H,ar:X}));continue}let Re=Lt(X,r),Fe=Lt(H,o),ht=Re||Fe;if(ht){Ln.has(ht)?mn.set(d,{dup:ht}):(Ln.add(ht),mn.set(d,{moveIn:ht,side:Re?"remote":"local",sideEl:Re?X.el:H.el}));continue}let lt=(Ut,Pt)=>Ut&&g&&R.get(Pt.reverse.get(Ut.el))||null,ft=lt(X,r)||lt(H,o);if(ft&&(ar.add(ft),Ne[d].conflict&&(xn(ft)||X&&(X.el===ft.el||r.identityPaired?.has(ft.el))&&rt(ft,X,"remote")||H&&(H.el===ft.el||o.identityPaired?.has(ft.el))&&rt(ft,H,"local")))){if(kn.has(ft)){mn.set(d,{dup:ft.el});continue}kn.add(ft)}mn.set(d,{al:H,ar:X})}let nt=new Map,Rt,st,Et=(d,I)=>{if(d[I]>=0)return d[I];for(let U=I-1;U>=0;U--)if(d[U]>=0)return d[U]+1;return 0};if(g)for(let d of p.atoms){if(kn.has(d)||ar.has(d))continue;let I=o.map.get(d.el)||null,U=r.map.get(d.el)||null,H=I&&w.get(I),X=U&&K.get(U);if(I&&!H||U&&!X)continue;let de=!(H&&X)&&Ae.has(d);if(!de&&!(H&&X&&(xn(d)||it?.has(d)||(H.el===d.el||o.identityPaired?.has(d.el))&&(X.el===d.el||r.identityPaired?.has(d.el))&&rt(d,H,"local")&&rt(d,X,"remote"))))continue;let we=it?.get(d),Te=t;if(we){let lt=we==="local"?y:m,ft=we==="local"?r:o,Ut=we==="local"?st:Rt;if(Ut===void 0){Ut=lt.atoms.length===p.atoms.length;for(let Pt=0;Ut&&Pt<p.atoms.length;Pt++)Ut=ft.reverse.get(lt.atoms[Pt].el)===p.atoms[Pt].el;we==="local"?st=Ut:Rt=Ut}Ut&&(Te=we)}let Ve=Te==="local"?[[H,k],[X,$]]:[[X,$],[H,k]],[Re,Fe]=Ve.find(([lt])=>lt),ht=Et(Fe,Re.i);nt.has(ht)||nt.set(ht,[]),nt.get(ht).push({a:d,lt:I,rt:U,edited:de}),kn.add(d)}if(g&&e.moveIn){let d=[[m,o,k,"local"],[y,r,$,"remote"]];t!=="local"&&d.reverse();for(let[I,U,H,X]of d)for(let de of I.atoms){let we=Lt(de,U);if(!we||Ln.has(we))continue;Ln.add(we);let Te=Et(H,de.i);nt.has(Te)||nt.set(Te,[]),nt.get(Te).push({move:we,side:X,sideEl:de.el})}}let Yt=d=>{let I=nt.get(d);if(I){if(Rn(d),I.some(U=>_e(U.move?U.sideEl:U.a.el)))for(;St.length;)St.pop(),Wt=St.length?St[St.length-1].el:null;for(let{a:U,lt:H,rt:X,edited:de,move:we,side:Te,sideEl:Ve}of I){if(we){let Fe=e.moveIn(we,Te,Ve);Fe&&Fn(Fe);continue}cr.add(U);let Re=L(U.el,H,X);de&&(h({kind:"structure",el:Re,detail:"edit-beats-delete",base:U.el},{subject:U.el,deleted:H?"remote":"local"}),s.push({kind:"insert",el:Re,source:H?"local":"remote"})),Fn(Re)}}},Ct=new Set,tn=i.length>a;for(let d=0;d<ze;d++){let I=Dt(d),U=e.scopeUnits&&I&&(I.ab?.stack.some(we=>we.block)||I.al?.stack.some(we=>we.block)||I.ar?.stack.some(we=>we.block)),X=!!I&&_e((I.ab||I.al||I.ar).el)&&!U?[]:Ke[d]?[Ke[d],...pt(d)]:pt(d),de=0;for(;de<St.length&&de<X.length&&St[de].u===X[de];)de++;if(de<St.length)for(Rn(d);St.length>de;)St.pop(),Wt=St.length?St[St.length-1].el:null;if(Ye(d),Yt(d),X.length>St.length)for(Rn(d);St.length<X.length;)Ir(X[St.length]);if(ae[d]===wt){if(Ue.has(d))continue;Rn(d);let we=St.length;for(;we>0&&!St[we-1].u.block;)we--;if(we>0)for(tn&&f.breakOut.set(d,St[we-1].el);St.length>=we;)St.pop(),Wt=St.length?St[St.length-1].el:null;continue}if(I){Rn(d);let we=mn.get(d),Te;if(we.dup){h({kind:"structure",el:null,detail:"both-moved",base:we.dup},{subject:we.dup});continue}if(we.moveIn){if(Te=e.moveIn(we.moveIn,we.side,we.sideEl),!Te)continue}else if(we.bk){let Ve=we.bk;if(cr.add(Ve),Ve===I.ab)Te=L(Ve.el,we.al.el,we.ar.el);else{let Re=o.map.get(Ve.el)||null,Fe=r.map.get(Ve.el)||null;Te=L(Ve.el,Re,Fe),(!Re||!Fe)&&h({kind:"structure",el:null,detail:"move-beats-delete",base:Ve.el},{subject:Ve.el,deleted:Re?"remote":"local"}),s.push({kind:"move",el:Te,source:we.from})}}else we.al?(Te=j(we.al.el,"local"),we.ar&&(c.get(Te).remote=we.ar.el),s.push({kind:"insert",el:Te,source:we.ar?"both":"local"})):(Te=j(we.ar.el,"remote"),s.push({kind:"insert",el:Te,source:"remote"}));tn&&f.atomOut.set(d,Te),Fn(Te);continue}fn||(Gt=d),fn+=ae[d]}if(Rn(ze),(Je.has(ze)||nt.has(ze))&&(St.length=0,Wt=null,Ye(ze),Yt(ze)),ze===0&&(m.placeholder||y.placeholder||p.placeholder)){let d=n.createElement("br");c.set(d,{base:p.placeholder,local:m.placeholder,remote:y.placeholder}),It.push(d)}let Vt=0,vt=d=>{for(;Vt>0&&ct[Vt-1].me>=d;)Vt--;for(;Vt<ct.length&&ct[Vt].me<d;)Vt++;let I=ct[Vt];if(!I)return ct[ct.length-1]||null;let U=ct[Vt+1];return I.me===d&&U&&U.ms===d?U:I},Tt=new Map,Bt={},Qt=(d,I,U)=>{let H=vt(d)||(U?Bt:null);if(!H)return;let X=Tt.get(H)||{l:!1,r:!1};I!=="remote"&&(X.l=!0),I!=="local"&&(X.r=!0),Tt.set(H,X)},zn=d=>{if(d.conflict)return!0;let I=d.src==="local"?m.text:d.src==="remote"?y.text:"";for(let U=d.from;U<d.to;U++)if(I[U]!==Bn&&I[U]!==wt)return!0;return!1};for(let d of Z)d.src!=="base"&&Qt(d.ms,d.conflict?"both":d.src,zn(d));for(let[d,I]of q)tt[d]>=0&&Qt(tt[d],I);for(let d of ct.length?ct:[Bt]){let I=Tt.get(d);I&&s.push({kind:"text",node:d.node||null,source:I.l&&I.r?"both":I.l?"local":"remote"})}for(let d of Xe){if($n.has(d))continue;let I=!d.local&&!(g&&o.map.get(d.base)),U=!d.remote&&!(g&&r.map.get(d.base));!I&&!U||s.push({kind:"remove",source:I&&U?"both":I?"local":"remote",base:d.base})}if(He)for(let[d,I]of He)$n.has(d)&&h({kind:"structure",el:$n.get(d),detail:"edit-beats-delete",base:d.base},{subject:d.base,deleted:I});let Gn=(d,I,U)=>{if(I<=d)return!1;for(let H=d;H<I;H++)if(U[H]>=0)return!1;return!0};for(let d of Xe)for(let I of["local","remote"]){let U=d[I+"Mark"],H=d.baseMark;if(!U)continue;let X=I==="local"?re:Se;if(!Gn(H.from,H.to,X.bTo)||!Gn(U.from,U.to,X.toB))continue;let de=(I==="local"?Ie:ge).find(we=>we.ss<=U.from&&U.from<we.se);de&&(de.be<=H.from||de.bs>=H.to)&&s.push({kind:"move",el:$n.get(d)||null,source:I})}let Ll=d=>{let I=Ze.get(d.node.parentNode);return I?gt(I):null};for(let d of m.nodes){let I=-1;for(let H=d.s;H<d.e;H++)if(k[H]>=0){I=k[H];break}let U;if(I>=0)U=vt(I);else{let H=mt(d.s),X=Ll(d);U=ct.find(de=>de.u===X&&de.me>=H)||ct.filter(de=>de.u===X).pop()}U&&U.local.push(d)}let Do=new Map,Pl=ct[ct.length-1]||null,vn=0;for(let d of m.nodes){let I=null;for(let U=d.s;U<=d.e;U++){let H=mt(U);for(;vn>0&&ct[vn-1].me>=H;)vn--;for(;vn<ct.length&&ct[vn].me<H;)vn++;let X=we=>we&&H>=we.ms&&H<=we.me&&(H<we.me||U===d.e||we===I),de=X(ct[vn])?ct[vn]:X(ct[vn+1])?ct[vn+1]:ct[vn]||Pl;if(!de)break;if(I===de){let we=Do.get(de);we[we.length-1].to=U-d.s;continue}I=de,Do.has(de)||Do.set(de,[]),Do.get(de).push({node:d.node,from:U-d.s,to:U-d.s,flatStart:d.s})}}for(let d of ct){let I=d.local,U=!1;for(let we of I)for(let Te=we.s;Te<we.e&&!U;Te++)(k[Te]<d.ms||k[Te]>=d.me)&&(U=!0);c.set(d.node,{base:null,local:I.map(we=>we.node),remote:null,caret:Do.get(d)||[],partial:U});let H=d.ms,X=d.me-d.ms,de=we=>{let Te=0,Ve=-1;for(let Re of I){let Fe=Re.e-Re.s;if(we<=Te+Fe){Ve=Re.s+(we-Te);break}Te+=Fe}return Ve<0&&(Ve=I.length?I[I.length-1].e:0),Math.max(0,Math.min(mt(Ve)-H,X))};de.flat=we=>Math.max(0,Math.min(mt(we)-H,X)),l.set(d.node,de)}function jl(){if(!m.text.includes(wt))return[{flatLocal:m.text,localNodes:m.nodes,textNodes:ct,lToM:k,mapLocal:mt}];let d=[],I=0,U=0;for(let H=0;H<=m.text.length;H++){if(H<m.text.length&&m.text[H]!==wt)continue;let X=I,de=H;if(de>X){let we=[];for(;U<m.nodes.length&&m.nodes[U].e<=X;)U++;for(let Te=U;Te<m.nodes.length&&m.nodes[Te].s<de;Te++){let Ve=m.nodes[Te],Re=Math.max(Ve.s,X),Fe=Math.min(Ve.e,de);Re<Fe&&we.push({node:Ve.node,s:Re-X,e:Fe-X})}d.push({flatLocal:m.text.slice(X,de),localNodes:we,textNodes:ct,lToM:k.subarray?k.subarray(X,de+1):k.slice(X,de+1),mapLocal:Te=>mt(X+Math.max(0,Math.min(Te,de-X)))})}I=H+1}return d}let qs={...e,blocks:Ct,ignored:d=>ye.has(d)||(e.ignored?e.ignored(d):!1)},zs=e.ignoreAttribute||(()=>!1),Dl=ui(en(It,qs),zs)!==ui(y,zs);if(u.length){let d=I=>{let U=c.get(I);return U&&U.unchanged?U.remote:null};f.text=ae,f.textNodes=ct,f.out=en(It,{...qs,via:d})}let mo=null;if(e.scopeUnits){mo=new Map;let d=new Set(It),I=Te=>{for(;Te&&!d.has(Te);)Te=Te.parentNode;return Te},U=e.scopeUnits.map(Te=>{let Ve=new Map;for(let Re of Te)if(Re.nodeType===1)Ve.set(Re,Re);else for(let Fe of Re.nodes)Ve.set(Fe,Re);return Ve}),H=(Te,Ve)=>{for(;Te&&!Ve.has(Te);)Te=Te.parentNode;return Te?Ve.get(Te):null},X=[p,m,y].map((Te,Ve)=>{let Re=new Array(Te.text.length);for(let Fe of Te.nodes){let ht=H(Fe.node,U[Ve]);ht&&Re.fill(ht,Fe.s,Fe.e)}for(let Fe of Te.atoms)Re[Fe.i]=H(Fe.el,U[Ve]);return Re}),de=(Te,Ve)=>{if(!Te||!Ve)return;let Re=mo.get(Te);Re||mo.set(Te,Re=new Set),Re.add(Ve)};for(let Te of It){let Ve=c.get(Te);Ve&&(de(H(Ve.base,U[0]),Te),de(H(Ve.local,U[1]),Te),de(H(Ve.remote,U[2]),Te))}for(let Te of ct){let Ve=I(Te.node);for(let Re=Te.ms;Re<Te.me;Re++)de(X[0][Ce[Re]],Ve),de(X[1][Le[Re]],Ve),de(X[2][We[Re]],Ve)}let we=new Map(It.map((Te,Ve)=>[Te,Ve]));for(let[Te,Ve]of mo)mo.set(Te,Array.from(Ve).sort((Re,Fe)=>we.get(Re)-we.get(Fe)))}return{unitOutputs:mo,nodes:It,text:ae,textNodes:ct,localDiverged:Dl,mapLocal:mt,conflicts:i.slice(a),granularity:V?"line":"word",segments:jl(),localHunks:Ie,remoteHunks:ge,lToM:k}}function ki(e,n,t,o,r){if(!r(e.length*8+1))return null;let c=0,l=n===0,i=!1;for(let s of ln(e,o)){if(!r(1))return null;if(c+=s.len,c===n&&(l=!0),c===t&&(i=!0),c>=t)break}return l&&i}function Lc(e,n,t,o,r,c,l){if(!l(n.length*2))return!1;let i=new Map,s=new Map,a=new Set;for(let h of n){let f=h.bs<h.be,u=f?t[h.ownerIndex].text.base:t[h.ownerIndex].text[e],g=f?h.bs:h.ss,b=f?h.be:h.se;if(!l((b-g)*4+1))return!1;for(;g<b&&/\s/.test(u[g]);)g++;for(;b>g&&/\s/.test(u[b-1]);)b--;if(g===b)continue;let A=u.slice(g,b),p=f?i:s;f&&h.text&&a.add(A),p.has(A)?p.set(A,null):p.set(A,{h,from:g,to:b})}for(let h of o){if(!l(1))return!1;if(h.side!==e)continue;let f=h.deletion,u=t[f.ownerIndex].text.base;if(!l((f.be-f.bs)*3)||a.has(u.slice(f.bs,f.be).trim()))return!1}for(let[h,f]of i){if(!l(h.length+1))return!1;let u=s.get(h);if(!f||!u)continue;let g=f.h,b=u.h;if(!g.text||g.transferOut||b.transferIn||g.owner===b.owner)continue;let A=t[g.ownerIndex],p=t[b.ownerIndex];if(!l(A.text.base.length))return!1;if(!/\S/.test(A.text.base.slice(0,g.bs)+A.text.base.slice(g.be)))continue;let m=ki(A.text.base,f.from,f.to,c,l),y=ki(p.text[e],u.from,u.to,c,l);if(m===null||y===null)return!1;if(!m||!y)continue;let R=`${A.index}:${f.from}:${f.to}`,S={key:R,side:e,source:g.owner,destination:b.owner,deletion:g,insertion:b,sourceOffset:f.from-g.bs,targetOffset:u.from-b.ss,length:f.to-f.from};g.transferOut=S,b.transferIn=S,r[e].set(R,S),o.push(S)}return!0}function Ti({base:e,local:n,remote:t,localTwin:o,remoteTwin:r,eligible:c,nodes:l,budget:i=Kt(2e4*32)}){let s=N=>N>i.remaining?!1:(i.remaining-=N,i.nativeSteps=(i.nativeSteps||0)+N,!0);if(e.length<2||n.length!==e.length||t.length!==e.length||!s(e.length*12))return null;for(let[N,L]of[["base",e],["local",n],["remote",t]]){let j=l[N];if(j.length!==L.length||j.some((F,W)=>F!==L[W]))return null}let a=[],h=0;for(let N=0;N<e.length;N++){let L=e[N],j=n[N],F=t[N];if(o(L)!==j||r(L)!==F)return null;let W={};for(let[C,T]of[["base",L],["local",j],["remote",F]]){if(!c(T)||T.tagName!==L.tagName||T.namespaceURI!==L.namespaceURI||!s(T.childNodes.length+1))return null;let x="";for(let z of T.childNodes){if(z.nodeType!==3||!s(z.data.length*4+1))return null;x+=z.data}if(x.includes(wt)||(h+=x.length+1,h>2e4))return null;W[C]=x}a.push({base:L,local:j,remote:F,index:N,text:W})}let f=a.every(N=>yn(N.text.base,N.text.local,N.text.remote)),u={local:[],remote:[]};for(let N of a){N.hunks={local:[],remote:[]};for(let L of["local","remote"]){let j=N.text.base,F=N.text[L];if(j===F)continue;let W=j.length+F.length+4,C=W*8;if(!s(C))return null;let T=Math.floor(i.remaining/8),x=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(W*W+T)-W)/2)));if(x<1||!s(4*(x+1)*(W+x+1)))return null;let z=0;for(let D of ro(j,F,x)){if(!s(D.text.length+1))return null;let V=D.bs+z,Ee={...D,ss:V,se:V+D.text.length,toks:ln(D.text,f),owner:N.base,ownerIndex:N.index};N.hunks[L].push(Ee),u[L].push(Ee),z+=D.text.length-(D.be-D.bs)}}}let g=[],b={local:new Map,remote:new Map};for(let N of["local","remote"]){let L=new Map,j=new Map,F=!1,W=(C,T,x)=>{C.has(T)?C.set(T,null):C.set(T,x)};for(let C of u[N]){if(!s(1))return null;let T=a[C.ownerIndex].text.base;if(C.bs<C.be&&C.text===""){let x=T.slice(C.bs,C.be);if(!s(x.length*2))return null;/\S/.test(x)&&W(L,x,C)}else if(C.bs===C.be&&/\S/.test(C.text)){if(!s(C.text.length*2))return null;W(j,C.text,C)}else C.bs<C.be&&(F=!0)}for(let[C,T]of L){if(!s(C.length+1))return null;let x=j.get(C);if(!T||!x||T.owner===x.owner)continue;let z=a[T.ownerIndex];if(!s(z.text.base.length))return null;if(!/\S/.test(z.text.base.slice(0,T.bs)+z.text.base.slice(T.be)))continue;let D=`${z.index}:${T.bs}:${T.be}`,V={key:D,side:N,source:T.owner,destination:x.owner,deletion:T,insertion:x};T.transferOut=V,x.transferIn=V,b[N].set(D,V),g.push(V)}if(F&&j.size&&!Lc(N,u[N],a,g,b,f,s))return null}if(!g.length)return null;let A=(N,L)=>N.bs<L.be&&L.bs<N.be,p=N=>N.bs===N.be,m=(N,L)=>N.bs<=L.be&&L.bs<=N.be&&p(N)!==p(L),y=(N,L)=>N.bs===L.bs&&N.be===L.be&&N.text===L.text,R=(N,L)=>!!(N.transferIn||N.transferOut&&(!N.text||L.bs===N.be&&/\s/.test(L.text[0])||L.bs===N.bs&&/\s/.test(L.text[L.text.length-1])));for(let N of g){let L=N.side==="local"?"remote":"local",j=a[N.deletion.ownerIndex];for(let F of j.hunks[L])if(!s(1)||A(N.deletion,F)&&F.transferOut?.key!==N.key)return null}for(let N of a)for(let L of N.hunks.local)for(let j of N.hunks.remote){if(!s(1))return null;if(y(L,j)){if(L.transferIn?.key!==j.transferIn?.key)return null;continue}if(A(L,j)||m(L,j)&&!R(L,j)&&!R(j,L))return null}if(!s(h*8))return null;let S=new Set([...e,...n,...t]),O={base:en(e,{blocks:S}),local:en(n,{blocks:S}),remote:en(t,{blocks:S})},M={};for(let N of["base","local","remote"]){let L=O[N];if(L.atoms.length||L.pins.length)return null;M[N]=new Map(L.marks.filter(j=>j.block).map(j=>[j.el,j.from]))}for(let N of a){let L=M.base.get(N.base);if(L===void 0)return null;for(let j of["local","remote"]){let F=M[j].get(N[j]);if(F===void 0)return null;for(let W of N.hunks[j])W.bs+=L,W.be+=L,W.ss+=F,W.se+=F}}for(let N of g)N.bs=N.deletion.bs+(N.sourceOffset||0),N.be=N.length===void 0?N.deletion.be:N.bs+N.length,N.ss=N.insertion.ss+(N.targetOffset||0),N.se=N.length===void 0?N.insertion.se:N.ss+N.length;let E={};for(let N of["local","remote"]){let L=0,j=0,F=[];for(let C of u[N]){if(!s(1))return null;C.bs>L&&F.push({from:L,to:C.bs,target:j}),L=C.be,j=C.se}L<O.base.text.length&&F.push({from:L,to:O.base.text.length,target:j});let W=g.filter(C=>C.side===N).map(C=>({from:C.bs,to:C.be,target:C.ss,destination:C.destination}));if(E[N]=Dn({base:O.base,side:O[N],retained:F,transfers:W,budget:i}),E[N].status!=="ready")return null}return s(O.base.text.length)?{owners:a,blocks:S,transfers:g,byOrigin:b,budget:i,prepared:{base:O.base,local:O.local,remote:O.remote,lines:!1,baseTokens:ln(O.base.text,f),localEdits:{hunks:u.local,respell:new Map},remoteEdits:{hunks:u.remote,respell:new Map},localMap:E.local,remoteMap:E.remote,full:null}}:null}var os=/\S/;function Ai({certificates:e,scopes:n,views:t,eligible:o,baseId:r,limit:c=2e4*32}){let l=Kt(c),i=Symbol(),s=[],a=f=>{if(f>l.remaining)throw i;l.remaining-=f},h=(f,u=null)=>{if(a(1),!f||f.nodeType!==1||f.parentNode?.nodeType!==1||!o(f))return null;for(let A=f.parentNode;A;A=A.parentNode)if(a(1),A.nodeType===11)return null;let g="",b=0;for(let A of f.childNodes){if(a(1),A.nodeType!==3)return null;if(a(A.data.length*4+1),u){let p=u.flat.nodes[b++];if(!p||p.node!==A||p.s!==g.length||p.e!==g.length+A.data.length)return null}g+=A.data}return a(g.length*3+1),u&&(u.flat.atoms.length||u.flat.pins?.length||b!==u.flat.nodes.length||u.flat.text!==g)?null:os.test(g)?g:null};try{a(n[0].length+n[1].length+n[2].length+e.length);let f=n.map(g=>new Set(g)),u=new Map;for(let g of e){a(1);let b=u.get(g.source);b||u.set(g.source,b=[]),b.push(g)}for(let g of u.values()){let b=[null,null],A=[];for(let p of g){a(1);let{source:m,target:y,side:R,models:S,runs:O}=p;if(R!==0&&R!==1||!f[0].has(m)||!f[R+1].has(y))continue;let{V:M,A:E,idOf:N}=t[R],L=t[1-R],j=M.twin(m),F=L.V.twin(m),W=M.baseOf(y);if(!j||!F||!W||W===m||!f[0].has(W)||!f[R+1].has(j)||!f[2-R].has(F)||E.map.get(m)!==j||E.reverse.get(j)!==m||L.A.map.get(m)!==F||L.A.reverse.get(F)!==m||E.map.get(W)!==y||E.reverse.get(y)!==W||y.parentNode!==j.parentNode||W.parentNode!==m.parentNode||m.tagName!==j.tagName||m.tagName!==F.tagName||r(m)!==N(j)||r(m)!==L.idOf(F)||r(W)!==N(y))continue;let C=S.get(m),T=S.get(y);if(!C||!T)continue;let x=h(m,C),z=h(y,T),D=h(j),V=h(F);if(a((x?.length||0)+(V?.length||0)),x===null||z===null||D===null||V===null||V===x)continue;let Ee=O.length>0,Me=!1;for(let re of O){if(a(1),re.source!==m||re.target!==y||!Number.isInteger(re.from)||!Number.isInteger(re.to)||!Number.isInteger(re.targetFrom)||re.from<0||re.to<=re.from||re.to>x.length||re.targetFrom<0||re.targetFrom+re.to-re.from>z.length){Ee=!1;break}a((re.to-re.from)*3);for(let Se=re.from;Se<re.to;Se++){if(x[Se]!==z[re.targetFrom+Se-re.from]){Ee=!1;break}os.test(x[Se])&&(Me=!0)}if(!Ee)break}if(!Ee||!Me)continue;let De=b[R];De||(a(x.length),De=b[R]={source:m,side:R,flat:C.flat,before:x,covered:new Uint8Array(x.length)});for(let re of O)a(re.to-re.from),De.covered.fill(1,re.from,re.to)}for(let p of b){if(!p)continue;let{source:m,side:y,flat:R,before:S,covered:O}=p;a(S.length*3+1);let M=-1,E=-1;for(let N=0;N<=S.length;N++)N<S.length&&O[N]?(M<0&&(M=N),E=N+1):(N===S.length||os.test(S[N]))&&M>=0&&(A.push({source:m,side:y,flat:R,from:M,to:E}),M=E=-1)}a(A.length),s.push(...A)}}catch(f){if(f!==i)throw f}return{records:s,budget:l}}var Pc="http://www.w3.org/1999/xhtml";function jc(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n^e.charCodeAt(t);return(n>>>0).toString(36)}function hn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Pc}function Dc(e){let n=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return n==="application/json"||n.endsWith("+json")}function kr(e,n){let t=e.getAttribute("src"),o=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let r=t;try{let c=new URL(t,n);r=c.origin+c.pathname+c.search}catch{}return"script|src|"+o+"|"+r}return"script|inline|"+o+"|"+jc(e.textContent.trim())}var Bc={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function So(e,n=[],t=!1){if(!hn(e)||e.hasAttribute("src"))return null;let o=[Bc,...n];for(let r=0;r<o.length;r++){let c=o[r];if(!c.match(e))continue;if(!Dc(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=c.identity(e);return l==null||l===""?null:{key:r+":"+l,raw:l,recognizer:c}}return null}function Si(e,n,t){let o=new Set,r=c=>{hn(c)&&!n(c)&&o.add(kr(c,t))};r(e);for(let c of e.querySelectorAll("script"))r(c);return o}function Vo(e,n){let t=n.createElement("div");t.innerHTML="<script><\/script>";let o=t.firstChild;for(let r of e.attributes)o.setAttribute(r.name,r.value);return o.textContent=e.textContent,o}function Ni(e,n,t){let o=[],r=[],c=new Map,l=t.trackRecovery?new Set:null,i=Array.from(e.querySelectorAll("script"));hn(e)&&i.unshift(e);for(let s of i){if(!hn(s)||t.ignored(s)||t.skip.has(s)||n.has(kr(s,t.baseURI)))continue;let a=s.ownerDocument.createElement("script");for(let h of s.attributes)a.setAttribute(h.name,h.value);if(a.textContent=s.textContent,t.beforeNodeAdded(a)===!1){l?.add(s);continue}a.hasAttribute("src")&&r.push(new Promise(h=>{a.addEventListener("load",()=>h()),a.addEventListener("error",()=>h())})),s.replaceWith(a),c.set(s,a),t.afterNodeAdded(a),o.push(a)}return{executed:o,loads:r,swapped:c,vetoed:l}}function Uc(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n^e.charCodeAt(t);return(n>>>0).toString(36)}function Hc(e,n){try{let t=new URL(e,n);return t.origin+t.pathname+t.search}catch{return e}}function vi(e,n){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return kr(e,n);if(t==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+Hc(o,n):e.outerHTML}if(t==="META"){for(let o of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(o))return"meta|"+o+"="+e.getAttribute(o);return e.outerHTML}return t==="STYLE"?"style|"+Uc(e.textContent):e.outerHTML}function rs(e,n){for(;;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]==="/"&&e[n+1]==="/"){for(;n<e.length&&e[n]!==`
5
- `;)n++;continue}if(e[n]==="/"&&e[n+1]==="*"){let t=e.indexOf("*/",n+2);if(t===-1)return e.length;n=t+2;continue}return n}}function Wc(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(n,t)=>t.length%2===0?t+'\\"':n)}var Vc=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,_c=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ss(e){try{return JSON.parse(e)}catch{return JSON.parse(Fc(e))}}function Fc(e){let n="",t=0,o=(r,c)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${c}`)};for(;t<e.length&&(t=rs(e,t),!(t>=e.length));){let r=e[t];if("{}[]:".includes(r)){n+=r,t++;continue}if(r===","){let i=rs(e,t+1);if(e[i]==="}"||e[i]==="]"){t++;continue}n+=r,t++;continue}if(r==='"'||r==="'"){let i=t+1;for(;i<e.length&&e[i]!==r;)e[i]==="\\"&&i++,i++;i>=e.length&&o("unterminated string",t);let s=e.slice(t+1,i);r==="'"&&(s=Wc(s)),n+='"'+s+'"',t=i+1;continue}let c=t;for(;c<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[c]);)c++;c===t&&o("unexpected character "+JSON.stringify(r),t);let l=e.slice(t,c);if(l==="true"||l==="false"||l==="null"||Vc.test(l)){n+=l,t=c;continue}if(_c.test(l)){if(e[rs(e,c)]===":"){n+='"'+l+'"',t=c;continue}o("unquoted value "+JSON.stringify(l),t)}o("invalid token "+JSON.stringify(l),t)}return n}var Xt=Symbol("hyper-morph-json-merge:missing"),Oi=["id","_id","uuid","key","slug","code","name"];function No(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _o(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function $c(e,n,t){Object.defineProperty(e,n,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Qn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!Qn(e[t],n[t]))return!1;return!0}if(No(e)&&No(n)){let t=Object.keys(e);if(t.length!==Object.keys(n).length)return!1;for(let o of t)if(!_o(n,o)||!Qn(e[o],n[o]))return!1;return!0}return!1}function Mi(e,n,t,o){return Qn(n,t)?n:Qn(n,e)?t:Qn(t,e)?n:No(n)&&No(t)?Kc(No(e)?e:{},n,t,o):Array.isArray(n)&&Array.isArray(t)?Yc(Array.isArray(e)?e:[],n,t,o):t}function Ei(e,n,t,o){return n===Xt&&t===Xt?Xt:n===Xt?e===Xt?t:Qn(t,e)?Xt:t:t===Xt?e===Xt?n:Xt:Mi(e,n,t,o)}function Kc(e,n,t,o){let r={},c=new Set([...Object.keys(e),...Object.keys(n),...Object.keys(t)]);for(let l of c){let i=Ei(_o(e,l)?e[l]:Xt,_o(n,l)?n[l]:Xt,_o(t,l)?t[l]:Xt,o);i!==Xt&&$c(r,l,i)}return r}function qc(e){return e===null||typeof e!="object"}function Tr(e){return typeof e+":"+String(e)}function zc(e,n){for(let t of n){let o=new Set;for(let r of t){if(!_o(r,e))return!1;let c=r[e];if(typeof c!="string"&&typeof c!="number")return!1;let l=Tr(c);if(o.has(l))return!1;o.add(l)}}return!0}function Gc(e,n,t,o){let r=[e,n,t],c=!0;for(let l of r)for(let i of l)No(i)||(c=!1);if(c){for(let l of o.keyCandidates)if(zc(l,r))return{kind:"keyed",field:l};return null}for(let l of r){let i=new Set;for(let s of l){if(!qc(s))return null;let a=Tr(s);if(i.has(a))return null;i.add(a)}}return{kind:"self"}}function Yc(e,n,t,o){let r=Gc(e,n,t,o);if(!r)return t;let c=r.kind==="self"?Tr:g=>Tr(g[r.field]),l=g=>{let b=new Map;for(let A of g)b.set(c(A),A);return b},i=l(e),s=l(n),a=l(t),h=new Map,f=new Set([...i.keys(),...s.keys(),...a.keys()]);for(let g of f){let b=Ei(i.has(g)?i.get(g):Xt,s.has(g)?s.get(g):Xt,a.has(g)?a.get(g):Xt,o);b!==Xt&&h.set(g,b)}let u=[];for(let g of t){let b=c(g);h.has(b)&&u.push(b)}for(let g=0;g<n.length;g++){let b=c(n[g]);if(!h.has(b)||u.includes(b))continue;let A=0;for(let p=g-1;p>=0;p--){let m=u.indexOf(c(n[p]));if(m!==-1){A=m+1;break}}u.splice(A,0,b)}return u.map(g=>h.get(g))}function Ii(e,n,t,o={}){let r=o.keyCandidates?[...o.keyCandidates,...Oi]:Oi;return Mi(e===void 0?Xt:e,n,t,{keyCandidates:r})}function is(e,n,t,o={}){let r=o.parse||ss,c=[],l=(f,u)=>{if(typeof f!="string")return Xt;try{return r(f)}catch(g){return c.push(`${u} side is not valid JSON (${g.message})`),Xt}},i=l(n,"local"),s=l(t,"remote");if(i===Xt)return{text:t,warnings:c};if(s===Xt)return{text:n,warnings:c};let a=l(e,"base"),h=Ii(a===Xt?void 0:a,i,s,o);return Qn(h,s)?{text:t,warnings:c}:Qn(h,i)?{text:n,warnings:c}:{text:JSON.stringify(h,null,2),warnings:c}}var Ci=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function lo(e){if(!e)return!1;let{startContainer:n,startOffset:t,endContainer:o,endOffset:r}=e;if(!n||!o||!Number.isInteger(t)||!Number.isInteger(r)||t<0||r<0||t>Ci(n)||r>Ci(o)||n.getRootNode()!==o.getRootNode())return!1;let c=n.ownerDocument.createRange();return c.setStart(n,t),c.setEnd(o,r),c.startContainer===n&&c.startOffset===t}function Zn(e,n,t={}){if(!lo(e))return null;let{startContainer:o,startOffset:r,endContainer:c,endOffset:l}=e;if(o===c&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,l);if(o===c&&r===l)return"";let i=new Set;for(let p=o;p;p=p.parentNode)i.add(p);let s=c;for(;!i.has(s);)s=s.parentNode;let a=(p,m)=>{let y=s.ownerDocument.createRange(),R=s.ownerDocument.createRange();return y.setStart(p[0],p[1]),y.collapse(!0),R.setStart(m[0],m[1]),R.collapse(!0),y.compareBoundaryPoints(0,R)},h=(p,m=!1)=>[p.parentNode,Array.prototype.indexOf.call(p.parentNode.childNodes,p)+Number(m)],f=[],u;if(n==="plain"){u="";let p=m=>{if(m.nodeType===3||m.nodeType===8){let y=u.length;u+=m.nodeValue,f.push({s:y,e:u.length,a:[m,0],b:[m,m.nodeValue.length],node:m})}else for(let y of m.childNodes)p(y)};p(s)}else{let p=t.blocks;if(!p){p=new Set;let y=R=>{R!==s&&R.nodeType===1&&ts.has(R.tagName)&&p.add(R);for(let S of R.childNodes)y(S)};y(s)}let m=en(Array.from(s.childNodes),{blocks:p,atomize:y=>!!t.atoms?.has(y),ignored:t.ignored});u=m.text;for(let y of m.nodes)f.push({s:y.s,e:y.e,a:[y.node,0],b:[y.node,y.e-y.s],node:y.node});for(let y of m.atoms)f.push({s:y.i,e:y.i+1,a:h(y.el),b:h(y.el,!0)});for(let y=0;y<m.text.length;y++){if(m.text[y]!==wt)continue;let R=m.marks.find(O=>O.block&&O.to===y+1),S=m.marks.find(O=>O.block&&O.from===y+1);if(R)f.push({s:y,e:y+1,a:[R.el,R.el.childNodes.length],b:h(R.el,!0)});else if(S)f.push({s:y,e:y+1,a:h(S.el),b:[S.el,0]});else return null}}f.sort((p,m)=>p.s-m.s);let g=p=>{if(p[0].nodeType===3||p[0].nodeType===8){let y=f.find(R=>R.node===p[0]);return y?y.s+p[1]:null}let m=0;for(let y of f){if(a(p,y.a)<=0)return y.s;if(a(p,y.b)<0)return null;m=y.e}return m},b=g([o,r]),A=g([c,l]);return b!==null&&A!==null&&b<=A?u.slice(b,A):null}function io(e,n){let t=e;for(let o of n.path)if(t=o==="content"?t?.content:t?.childNodes[o],!t)return null;return[t,n.offset]}function Ri(e,n){if(!e||!n)return null;let t=io(e,n.start),o=io(e,n.end);return t&&o?{startContainer:t[0],startOffset:t[1],endContainer:o[0],endOffset:o[1]}:null}var Li=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Pi(e,n,t){if(!n)return;let o=new Map,r=new Map,c=i=>{if(!i)return null;if(r.has(i))return r.get(i);let a=i.local.map(h=>io(n.localRoot,{path:h,offset:0})?.[0]).map(h=>h&&t(h)).filter(Boolean).map(h=>({node:h,parent:h.parentNode,previous:h.previousSibling,next:h.nextSibling,fragment:Li(h)}));return r.set(i,a),a},l=i=>{let s=Ri(n.localRoot,i);if(!s)return null;let a=t(s.startContainer),h=t(s.endContainer);if(!a||!h)return null;let f={...s,startContainer:a,endContainer:h};return lo(f)?f:null};for(let i of e){let s=i.recovery;if(!s||o.has(s))continue;let a={subject:c(s.subject),span:null,scope:null,touched:new Set};if(s.text){a.span=l(s.text.local.span),a.scope=l(s.text.local.scope);let h=a.span;if(h){let f=h.startContainer.ownerDocument.createRange();f.setStart(h.startContainer,h.startOffset),f.setEnd(h.endContainer,h.endOffset);let u=g=>{if(f.intersectsNode(g)){a.touched.add(g);for(let b of g.childNodes)u(b)}};u(f.commonAncestorContainer)}}if(s.structure){for(let h of[s.structure.localPlacement])h&&(c(h.parent),h.before.forEach(c),h.after.forEach(c));for(let h of s.structure.localOrder||[])c(h)}o.set(s,a)}n.localState={states:o,refs:r}}function ji(e,n,t,o){let r=t.localState?.states.get(e);if(!r)return!1;let c=i=>{let s=i.node;if(!o(s)||s.parentNode!==i.parent)return!1;let a=h=>Array.prototype.indexOf.call(s.parentNode.childNodes,h);return!(i.previous&&o(i.previous)&&i.previous.parentNode===s.parentNode&&a(i.previous)>=a(s)||i.next&&o(i.next)&&i.next.parentNode===s.parentNode&&a(i.next)<=a(s))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!r.subject.length||!r.subject.every(c))return!1;if(e.text){let i=e.text.local,s=a=>a&&o(a.startContainer)&&o(a.endContainer);return s(r.span)&&s(r.scope)&&Zn(r.scope,e.text.encoding)===i.text&&Zn(r.span,e.text.encoding)===i.text.slice(i.start,i.end)}if(e.attribute){let i=e.attribute,s=r.subject[0].node;return(i.namespaceURI?s.getAttributeNS(i.namespaceURI,i.localName):s.getAttribute(i.qualifiedName))===n.local}let l=e.structure;if(l.localOrder){let i=-1,s=null;for(let a of l.localOrder){let h=t.localState.refs.get(a)?.[0]?.node;if(!h||!o(h)||s&&h.parentNode!==s)return!1;let f=Array.prototype.indexOf.call(h.parentNode.childNodes,h);if(f<=i)return!1;s=h.parentNode,i=f}return!0}return l.localAction==="moved"||r.subject.every(i=>Li(i.node)===i.fragment)}var Xc=1,cn=e=>!!e&&e.nodeType===1,Ar=e=>cn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function co(e,n=null,t=null){let o=new Map,r=new Map,c=h=>{if(!n){n=new WeakMap;let f=[e];for(;f.length;){let u=f.pop();Ar(u)&&(n.set(u.content,u),f.push(u.content));for(let g=u.firstChild;g;g=g.nextSibling)g.nodeType===1&&f.push(g)}}return n.get(h)||null},l=(h,f)=>{let u=r.get(h);if(!u){u=new Map;let g=0;for(let b=h.firstChild;b;b=b.nextSibling)u.set(b,g++);r.set(h,u)}return u.get(f)},i=h=>{if(!h)return null;if(t&&t.has(h))return i(t.get(h));if(h===e)return[];let f=o.get(h);if(f!==void 0)return f;let u=h.parentNode,g=null;if(u&&u.nodeType===11){let b=c(u),A=b?i(b):null;A&&(g=A.concat(["content",l(u,h)]))}else if(u){let b=i(u);b&&(g=b.concat([l(u,h)]))}return o.set(h,g),g};return{root:e,pathOf:i,logicalParent:h=>{let f=h.parentNode;return f&&f.nodeType===11?c(f):f},indexIn:l,containerPath:h=>{if(h.nodeType===11){let u=c(h),g=i(u);return g?g.concat(["content"]):null}let f=i(h);return f&&Ar(h)?f.concat(["content"]):f},ownerOf:c}}var En=e=>Ar(e)?e.content:e;function Di(e){let{L:n,R:t,unitsOf:o,provenance:r,policy:c}=e,l=[];return{note:(h,f)=>{l.push([h,f])},finish:h=>l.length?a(h):null};function a(h){let f={base:co(e.roots.base),local:co(e.roots.local),remote:co(e.roots.remote)},u=v=>v==="local"?n:t,g=(v,P)=>{if(!P)return null;if(v.map.has(P))return v.map.get(P);let Y=[],J=cn(P)?f.base.logicalParent(P):P.parent;for(;J&&!v.map.has(J);J=f.base.logicalParent(J))Y.push(J);if(!J||!v.identical.has(J))return null;let oe=v.map.get(J);for(let je=Y.length-1;je>=0&&oe;je--)oe=En(oe).childNodes[f.base.indexIn(Y[je].parentNode,Y[je])];return oe?cn(P)?En(oe).childNodes[f.base.indexIn(P.parentNode,P)]||null:o(oe)[o(P.parent).indexOf(P)]||null:null},b=new Map,A=new Map,p=new WeakMap,m=0,y=(v,P)=>{let Y=b.get(v);Y||b.set(v,Y=[]),Y.push(P)};(function v(P){A.set(P,m++);let Y=r.get(P);if(Y&&!Y.pinned){for(let J of[Y.base,Y.local,Y.remote])if(J)if(Array.isArray(J))for(let oe of J)y(oe,P);else y(J,P)}if(Ar(P)){p.set(P.content,P);for(let J=P.content.firstChild;J;J=J.nextSibling)v(J)}for(let J=P.firstChild;J;J=J.nextSibling)v(J)})(h);let R=new Map;f.out=co(h,p,R);let S={refs:new Map,spans:new Map,anchors:new Map,via:R,outOwners:p,outRoot:h,localRoot:e.roots.local},O=v=>cn(v)?[v]:v.nodes,M=(v,P)=>{let Y=f[P].logicalParent(v);if(!Y)return null;for(let J of o(Y))if(!cn(J)&&J.nodes.includes(v))return J;return null},E=(v,P)=>v==null?null:Array.isArray(v)?v.length?M(v[0],P):null:v,N=v=>{let P=new Set,Y=[];for(let J of v)for(let oe of b.get(J)||[])P.has(oe)||(P.add(oe),Y.push(oe));return Y.sort((J,oe)=>A.get(J)-A.get(oe))},L=new Map,j=v=>{let P=v.b||v.l||v.r,Y=L.get(P);if(Y)return Y;let J=[];for(let oe of[v.b,v.l,v.r])oe&&J.push(...O(oe));return Y=N(J),L.set(P,Y),Y},F=v=>({b:v,l:g(n,v),r:g(t,v)}),W=(v,P)=>{let Y=u(P).reverse.get(v);if(Y)return F(Y);for(let J of N(O(v))){let oe=r.get(J);if(oe&&!oe.base&&oe.local&&oe.remote)return{b:null,l:E(oe.local,"local"),r:E(oe.remote,"remote")}}return P==="local"?{b:null,l:v,r:null}:{b:null,l:null,r:v}},C=new Map,T=v=>{let P=r.get(v);if(!P||P.pinned)return null;let Y=E(P.base,"base");if(Y)return F(Y);let J=E(P.local,"local"),oe=E(P.remote,"remote");if(J){let je=n.reverse.get(J);if(je)return F(je)}if(oe){let je=t.reverse.get(oe);if(je)return F(je)}return J||oe?{b:null,l:J,r:oe}:null},x=v=>(C.has(v)||C.set(v,T(v)),C.get(v)),z=(v,P)=>cn(v)?f[P].logicalParent(v):v.parent,D=new Map,V=new Map,Ee=(v,P)=>(cn(v)?[f[P].pathOf(v)]:v.nodes.map(Y=>f[P].pathOf(Y))).filter(Boolean),Me=v=>{let P=v.b||v.l||v.r,Y=v.b?"base":v.l?"local":"remote",J=V.get(P);if(J)return J;let oe=!cn(P),je=Ee(P,Y)[0],Z=`${Y[0]}:${JSON.stringify(je===void 0?null:je)}${oe?":run":""}`,Oe=D.get(Z);if(Oe)return V.set(P,Oe),Oe;let He=j(v);return Oe={key:Z,nodeType:cn(P)?1:P.kind==="comment"?8:3,base:v.b?Ee(v.b,"base"):[],local:v.l?Ee(v.l,"local"):[],remote:v.r?Ee(v.r,"remote"):[],merged:He.map(Ie=>f.out.pathOf(Ie)).filter(Boolean),live:[]},D.set(Z,Oe),V.set(P,Oe),S.refs.set(Oe,He),Oe},De={base:new Map,local:new Map,remote:new Map},re=new Map,Se=(v,P)=>{let Y=z(v,P);if(!Y||Y.nodeType!==1)return null;let J=De[P].get(Y);if(!J){let je=o(Y),Z=Oe=>Me(P==="base"?F(Oe):W(Oe,P));J={parent:Z(Y),refs:je.map(Z),index:new Map(je.map((Oe,He)=>[Oe,He]))},De[P].set(Y,J)}let oe=J.index.get(v)??-1;return{parent:J.parent,before:J.refs.slice(oe+1),after:J.refs.slice(0,Math.max(0,oe)).reverse()}},qe=v=>{let P=v.parentNode;if(!P)return null;let Y=re.get(P);if(!Y){let oe=P.nodeType===11?p.get(P):P,je=oe&&oe.nodeType===1?x(oe):null;if(!je)return null;let Z=[],Oe=[],He=new Map;for(let ge of P.childNodes){let B=x(ge),G=B&&Me(B),ue=Z.length,he=Z.length-1;G&&G!==Z[he]&&(Z.push(G),he++);let ce={ref:G,group:he,after:ue};Oe.push(ce),He.set(ge,ce)}let Ie=Z.length;for(let ge=Oe.length-1;ge>=0;ge--){let B=Oe[ge];B.before=Ie,B.ref&&(Ie=B.group)}Y={parent:Me(je),refs:Z,index:He},re.set(P,Y)}let J=Y.index.get(v);return{parent:Y.parent,before:Y.refs.slice(J.before),after:Y.refs.slice(0,J.after).reverse()}},ve=v=>cn(v)?v.outerHTML:v.value,w=v=>cn(v)?"element":v.kind==="comment"?"comment":"text",K=(v,P)=>({path:v,offset:P}),ne=(v,P,Y)=>{if(!v)return null;let J=f[Y],oe=0;if(P){let je=cn(P)?P:P.nodes[P.nodes.length-1];je.parentNode&&(oe=J.indexIn(je.parentNode,je)+1)}return K(J.containerPath(v),oe)},ee=(v,P)=>{let Y=z(v,"base"),J=Y?g(u(P),Y):null;if(!cn(J))return null;let oe=o(Y),je=null;for(let Z=oe.indexOf(v)-1;Z>=0&&!je;Z--){let Oe=g(u(P),oe[Z]);Oe&&z(Oe,P)===J&&(je=Oe)}return ne(J,je,P)},Pe=(v,P,Y,J)=>{let oe=f[J],je=0;for(let Z=0;Z<v.nodes.length;Z++){let Oe=v.nodes[Z],He=Oe.nodeValue.length,Ie=Z===v.nodes.length-1;if((Y==="start"?P<je+He:P<=je+He)||Ie)return K(oe.pathOf(Oe),Math.max(0,Math.min(P-je,He)));je+=He}return null},_e=(v,P)=>{let Y=f[P],J=v.firstChild,oe=v.lastChild;return J&&J.nodeType===3&&oe.nodeType===3?{start:K(Y.pathOf(J),0),end:K(Y.pathOf(oe),oe.nodeValue.length)}:{start:K(Y.pathOf(v),0),end:K(Y.pathOf(v),v.childNodes.length)}},Ae=(v,P,Y)=>{for(let Z of v.nodes)if(Y==="start"?Z.s<=P&&P<Z.e:Z.s<P&&P<=Z.e)return{kind:"text",node:Z.node,offset:P-Z.s};let J=Y==="start"?P:P-1,oe=()=>{for(let Z of v.nodes)if(Z.s===P||Z.e===P)return{kind:"text",node:Z.node,offset:P-Z.s};return null},je=v.atomAt.get(J);if(je)return{kind:Y==="start"?"before":"after",node:je.el};if(v.text[J]===wt){let Z=v.marks.find(He=>He.block&&He.to===J+1);if(Z)return Y==="start"?{kind:"end",node:Z.el}:{kind:"after",node:Z.el};let Oe=v.marks.find(He=>He.block&&He.from===J+1);if(Oe)return Y==="start"?{kind:"before",node:Oe.el}:{kind:"startOf",node:Oe.el}}return oe()},ot=(v,P)=>Ae(v,P,"end")||Ae(v,P,"start"),Qe=(v,P)=>{switch(P.kind){case"text":return K(v.pathOf(P.node),P.offset);case"end":return K(v.containerPath(P.node),En(P.node).childNodes.length);case"startOf":return K(v.containerPath(P.node),0);default:{let Y=P.node.parentNode;return K(v.containerPath(Y),v.indexIn(Y,P.node)+(P.kind==="after"?1:0))}}},Ze=(v,P,Y,J,oe)=>{let je=Ae(v,P,Y);return je?Qe(f[J],je):oe()},Xe=(v,P,Y,J)=>{let oe=v.textNodes.map(Ie=>({s:Ie.ms,e:Ie.me,start:{kind:"text",node:Ie.node,offset:0},end:{kind:"text",node:Ie.node,offset:Ie.me-Ie.ms}}));for(let[Ie,ge]of v.atomOut)oe.push({s:Ie,e:Ie+1,start:{kind:"before",node:ge},end:{kind:"after",node:ge}});for(let[Ie,ge]of v.breakOut)oe.push({s:Ie,e:Ie+1,start:{kind:"end",node:ge},end:{kind:"after",node:ge}});for(let Ie of oe)if(Ie.start.kind==="text"&&Ie.s<P&&P<Ie.e)return{kind:"text",node:Ie.start.node,offset:P-Ie.s};if(Y!=="empty"){let Ie=oe.find(ge=>Y==="start"?ge.s===P:ge.e===P);if(Ie)return Y==="start"?Ie.start:Ie.end}let je=oe.find(Ie=>Ie.e===P);if(je)return je.end;let Z=oe.find(Ie=>Ie.s===P);if(Z)return Z.start;let Oe=null,He=null;for(let Ie of oe)Ie.e<=P&&(!Oe||Ie.e>Oe.e)&&(Oe=Ie),Ie.s>=P&&(!He||Ie.s<He.s)&&(He=Ie);return Oe?Oe.end:He?He.start:J()},yt=(v,P)=>{if(!P)return null;if(P.kind==="text"){let oe=v.nodes.find(je=>je.node===P.node);return oe?oe.s+Math.min(P.offset,oe.e-oe.s):null}let Y=v.atoms.find(oe=>oe.el===P.node);if(Y)return P.kind==="after"?Y.i+1:Y.i;let J=v.marks.find(oe=>oe.el===P.node);return J?P.kind==="before"&&J.block&&v.text[J.from-1]===wt&&!v.marks.some(oe=>oe.block&&oe.to===J.from)?J.from-1:P.kind==="startOf"||P.kind==="before"?J.from:P.kind==="end"&&J.block?J.to-1:J.to:null},dt=(v,P,Y,J)=>{for(let Oe of v.nodes)if(Y==="start"?Oe.s<=P&&P<Oe.e:Oe.s<P&&P<=Oe.e)return{kind:"text",node:Oe.node,offset:P-Oe.s};let oe=Y==="start"?P:P-1;if(!v.atomAt.has(oe)&&v.text[oe]!==wt){for(let Oe of v.nodes)if(Oe.s===P||Oe.e===P)return{kind:"text",node:Oe.node,offset:P-Oe.s}}let je=v.atomAt.get(oe);if(je)return{kind:Y==="start"?"before":"after",node:je.el};if(v.text[oe]===wt){let Oe=v.marks.find(Ie=>Ie.block&&Ie.to===oe+1);if(Oe)return Y==="start"?{kind:"end",node:Oe.el}:{kind:"after",node:Oe.el};let He=v.marks.find(Ie=>Ie.block&&Ie.from===oe+1);if(He)return Y==="start"?{kind:"before",node:He.el}:{kind:"startOf",node:He.el}}let Z=v.marks.find(Oe=>Oe.block&&Oe.from===P);return Z?{kind:"startOf",node:Z.el}:J?{kind:Y==="start"?"startOf":"end",node:J}:null},gt=v=>{if(!v)return null;if(v.kind==="wholeStart"||v.kind==="wholeEnd"){let P=qt(v.node);return v.kind==="wholeStart"?P.start:P.end}return Qe(f.out,v)},qt=v=>{let P=v.firstChild,Y=v.lastChild;return P&&P.nodeType===3&&Y.nodeType===3?{start:K(f.out.pathOf(P),0),end:K(f.out.pathOf(Y),Y.nodeValue.length)}:{start:K(f.out.pathOf(v),0),end:K(f.out.pathOf(v),v.childNodes.length)}},$t=v=>{let P=z(v,"base"),Y=P?j(F(P))[0]:null;if(!Y)return null;let J=En(Y),oe=o(P);for(let je=oe.indexOf(v)-1;je>=0;je--){let Z=j(F(oe[je])).filter(Oe=>Oe.parentNode===J);if(Z.length)return{kind:"after",node:Z[Z.length-1]}}return{kind:"startOf",node:Y}},Ht=(v,P,Y,J,oe,je)=>({text:v,start:P,end:Y,fragment:J,span:oe,scope:je}),jt=(v,P,Y,J,oe)=>Ht(v,P,Y,v.slice(P,Y),J,oe),an=(v,P,Y,J,oe)=>(S.spans.set(v,{start:P,end:Y,scopeStart:J,scopeEnd:oe}),v),_t=new Map,zt=new Map,_=(v,P,Y)=>{let J=`text:${v.key}:${P}:${Y}`,oe=zt.get(J)||0;return zt.set(J,oe+1),`${J}:${oe}`},ie=(v,P)=>{let Y,J,oe,je="plain",Z,Oe,He,Ie,ge,B=(he,ce,xe,te,q)=>{if(!he){let ae=ee(q,te);return jt("",0,0,{start:ae,end:ae},{start:ae,end:ae})}return jt(he.value,ce,xe,{start:Pe(he,ce,ce===xe?"end":"start",te),end:Pe(he,xe,"end",te)},{start:Pe(he,0,"start",te),end:Pe(he,he.value.length,"end",te)})};if(P.site==="run"){let{bRun:he,lRun:ce,rRun:xe,node:te,c:q}=P;Y=F(he),J=q.bs,oe=q.be,Z=B(he,q.bs,q.be,"base",he),Oe=B(ce,q.ls,q.le,"local",he),He=B(xe,q.rs,q.re,"remote",he);let ae=te?te.nodeValue:"",Ce=Le=>te?{kind:"text",node:te,offset:Le}:$t(he);Ie=an(jt(ae,q.ms,q.me,{start:gt(Ce(q.ms)),end:gt(Ce(q.me))},{start:gt(Ce(0)),end:gt(Ce(ae.length))}),Ce(q.ms),Ce(q.me),Ce(0),Ce(ae.length)),ge=te||($t(he)||{}).node||null}else if(P.site==="whole"){let he=P.el,ce=r.get(he);Y=F(ce.base),J=0,oe=v.base.length;let xe=(q,ae,Ce)=>{let Le=_e(ae,Ce);return jt(q,0,q.length,Le,Le)};Z=xe(v.base,ce.base,"base"),Oe=xe(v.local,ce.local,"local"),He=xe(v.remote,ce.remote,"remote");let te=qt(he);Ie=an(jt(v.resolved,0,v.resolved.length,te,te),{kind:"wholeStart",node:he},{kind:"wholeEnd",node:he},{kind:"wholeStart",node:he},{kind:"wholeEnd",node:he}),ge=he}else if(P.site==="comment"){let{bRun:he,lRun:ce,rRun:xe,node:te}=P;Y=F(he),J=0,oe=v.base.length;let q=(We,Ne)=>{if(!We){let k=ee(he,Ne);return jt("",0,0,{start:k,end:k},{start:k,end:k})}let ze=We.nodes[0],tt={start:K(f[Ne].pathOf(ze),0),end:K(f[Ne].pathOf(ze),We.value.length)};return jt(We.value,0,We.value.length,tt,tt)};Z=q(he,"base"),Oe=q(ce,"local"),He=q(xe,"remote");let ae=v.resolved,Ce=We=>te?{kind:"text",node:te,offset:We}:$t(he),Le={start:gt(Ce(0)),end:gt(Ce(ae.length))};Ie=an(jt(ae,0,ae.length,Le,Le),Ce(0),Ce(ae.length),Ce(0),Ce(ae.length)),ge=te||($t(he)||{}).node||null}else{let{fb:he,fl:ce,fr:xe,scope:te}=P,q=P.merged;je="html",Y=te.base?F(te.base):W(te.local,"local"),J=v.bs,oe=v.be;let ae=Ue=>{let $e=te[Ue];for(let Ge=te.at-1;Ge>=0;Ge--){let et=te.units[Ge],Ot=Ue==="base"?et:g(u(Ue),et);if(Ot&&z(Ot,Ue)===$e)return Ot}return null},Ce=Ue=>()=>ne(te[Ue],ae(Ue),Ue),Le=(Ue,$e,Ge,et,Ot)=>{let xt=Gt=>Gt?Qe(f[Ot],Gt):Ce(Ot)(),Jt=$e===Ge?ot(Ue,$e):Ae(Ue,$e,"start"),Mt=$e===Ge?ot(Ue,$e):Ae(Ue,Ge,"end"),pt=xt(Jt),bt={start:pt,end:$e===Ge?pt:xt(Mt)},mt=P.full?P.full(Ot):null;if(!mt)return Ht(Ue.text,$e,Ge,et,bt,{start:xt(Ae(Ue,0,"start")),end:xt(Ae(Ue,Ue.text.length,"end"))});let It=Jt?yt(mt,Jt):null,ct=Mt?yt(mt,Mt):null,Wt=It===null?0:It,St=Math.max(Wt,ct===null?mt.text.length:ct),fn=xt(Ae(mt,0,"start"));return Ht(mt.text,Wt,St,ko(mt,Wt,St),bt,{start:fn,end:mt.text.length?xt(Ae(mt,mt.text.length,"end")):fn})};Z=P.synthetic?null:Le(he,v.bs,v.be,v.base,"base"),Oe=Le(ce,v.lss,v.lse,v.local,"local"),He=Le(xe,v.rss,v.rse,v.remote,"remote");let[We,Ne]=v.range||[0,0],ze=q.out,tt=()=>{let Ue=En(q.node);for(let $e=te.at-1;$e>=0;$e--){let Ge=j(F(te.units[$e])).filter(et=>et.parentNode===Ue);if(Ge.length)return{kind:"after",node:Ge[Ge.length-1]}}for(let $e=te.at;$e<te.units.length;$e++){let Ge=j(F(te.units[$e])).filter(et=>et.parentNode===Ue);if(Ge.length)return{kind:"before",node:Ge[0]}}return{kind:"startOf",node:q.node}};if(ze.via)for(let[Ue,$e]of ze.via)R.set(Ue,$e);let k=Xe(q,We,We===Ne?"empty":"start",tt),$=We===Ne?k:Xe(q,Ne,"end",tt),Q=ze.text.length?dt(ze,0,"start",q.node):tt(),be=ze.text.length?dt(ze,ze.text.length,"end",q.node):Q,fe=yt(ze,k),se=yt(ze,$),le=fe===null?0:fe,Be=Math.max(le,se===null?ze.text.length:se);Ie=an(Ht(ze.text,le,Be,ko(ze,le,Be),{start:gt(k),end:gt($)},{start:gt(Q),end:gt(be)}),k,$,Q,be);let Ke=S.spans.get(Ie);if(Ke.flat=ze,!ze.text.length){let Ue=gt(Q),$e=io(h,Ue),Ge=$e[0],et=$e[1];Ke.empty={parent:Ge.nodeType===11?p.get(Ge):Ge,previous:Ge.childNodes[et-1]||null,next:Ge.childNodes[et]||null}}ge=k?k.node:q.node}let G=Me(Y),ue=(P.site==="whole"||P.site==="comment"||(P.policy||c)!=="both")&&v.resolved!==v.local;return{key:P.site==="comment"&&_t.get(Y.b||Y.l||Y.r)||_(G,J,oe),subject:G,localLost:ue,anchor:ge,text:{encoding:je,base:Z,local:Oe,remote:He,merged:Ie,liveSpan:null,liveScope:null}}},me=(v,P)=>{let Y=x(P.el),J=Me(Y),oe=P.sample;return{key:`attr:${J.key}:${oe.namespaceURI||""}:${oe.localName}`,subject:J,localLost:v.resolved!==v.local,anchor:P.el,attribute:{namespaceURI:oe.namespaceURI||null,localName:oe.localName,qualifiedName:oe.name}}},pe=(v,P)=>{let Y=v.detail,J=P.unit||F(P.subject),oe=Me(J),je=S.refs.get(oe),Z=J.l?Se(J.l,"local"):null,Oe=J.r?Se(J.r,"remote"):null,He=je.length?qe(je[0]):null,Ie,ge,B,G=null,ue=null,he=P.deleted;switch(Y){case"both-reordered":{Ie=ge="reordered";let ce=new Set(P.rKept),xe=P.lKept.filter(Le=>ce.has(Le)&&j(F(Le)).length),te=Le=>A.get(j(F(Le))[0]);G=xe.map(Le=>Me(F(Le))),ue=xe.slice().sort((Le,We)=>te(Le)-te(We)).map(Le=>Me(F(Le)));let q=Le=>!cn(Le)&&Le.kind!=="comment"&&Le.nodes.every(We=>!/[^\t\n\f\r ]/.test(We.data)),ae=xe.filter(Le=>!q(Le)),Ce=ae.slice().sort((Le,We)=>te(Le)-te(We));B=ae.some((Le,We)=>Le!==Ce[We]);break}case"both-moved":Ie=ge="moved",B=!Z||!je.some(ce=>{let xe=ce===je[0]?He:qe(ce);return xe&&xe.parent===Z.parent});break;case"edit-beats-delete":Ie=he==="local"?"deleted":"edited",ge=he==="remote"?"deleted":"edited",B=he==="local";break;case"move-beats-delete":Ie=he==="local"?"deleted":"moved",ge=he==="remote"?"deleted":"moved",B=he==="local";break;case"remote-wins":Ie="edited",ge="edited",B=!0;break;default:Ie=ge="inserted",B=P.localLost}return{key:`structure:${oe.key}:${Y}`,subject:oe,localLost:B,anchor:je[0]||null,structure:{localAction:Ie,remoteAction:ge,localPlacement:Z,remotePlacement:Oe,mergedPlacement:He,localOrder:G,mergedOrder:ue,localFragment:Y==="both-reordered"||!J.l?null:ve(J.l),fragmentKind:w(J.b||J.l||J.r)}}};for(let[v,P]of l){if(v.kind!=="structure")continue;let Y=P.unit||F(P.subject),J=Y.b||Y.l||Y.r;!cn(J)&&J.kind==="comment"&&_t.set(J,`structure:${Me(Y).key}:${v.detail}`)}let ke=new Map;for(let[v,P]of l){if(v.kind==="structure"){let je=Me(P.unit||F(P.subject)),Z=`structure:${je.key}:${v.detail}`,Oe=ke.get(Z);if(Oe&&Oe.structure){v.recovery=Oe;let He=S.refs.get(je);v.el==null&&He.length&&(v.el=cn(He[0])?He[0]:f.out.logicalParent(He[0]));continue}}let Y=v.kind==="text"?ie(v,P):v.kind==="attr"?me(v,P):pe(v,P),J=ke.get(Y.key);J||(J={version:Xc,key:Y.key,localLost:Y.localLost,subject:Y.subject,applied:!1,unavailable:null},ke.set(Y.key,J),S.anchors.set(J,Y.anchor)),Y.text&&(J.text=Y.text),Y.attribute&&(J.attribute=Y.attribute),Y.structure&&(J.structure=Y.structure),Y.text&&(J.localLost=Y.localLost),v.recovery=J;let oe=S.refs.get(Y.subject);v.kind==="structure"&&v.el==null&&oe.length&&(v.el=cn(oe[0])?oe[0]:f.out.logicalParent(oe[0])),v.kind==="text"&&v.node==null&&oe.length&&Y.subject.nodeType===8&&(v.node=oe[0])}return S}}function Bi(e,n,t){if(!n)return;let{lookup:o,vetoed:r,vetoedAttrs:c,liveAttr:l}=t,i=t.ignored||(()=>!1),s=co(t.liveRoot),a=T=>!!T&&s.containerPath(T)!==null,h=T=>{let x=T.parentNode;return x&&x.nodeType===11?n.outOwners.get(x)||null:x},f=T=>{for(let x=T;x;x=h(x))if(n.via.has(x)&&(x=n.via.get(x)),r.has(x)||t.vetoedLive?.has(m(x)))return!0;return!1},u=T=>Array.from(En(T).children).filter(x=>!i(x)),g=(T,x)=>u(T)[u(x.parentNode).indexOf(x)],b=(T,x)=>{let z=null,D=null,V=0;for(let re=x.previousSibling;re;re=re.previousSibling){if(re.nodeType===1&&!i(re)){z=re;break}re.nodeType===3&&(V+=re.nodeValue.length)}for(let re=x.nextSibling;re&&!D;re=re.nextSibling)re.nodeType===1&&!i(re)&&(D=re);let Ee=z?g(T,z):null,Me=D?g(T,D):null;if(z&&!Ee||D&&!Me)return null;let De=[];for(let re=Ee?Ee.nextSibling:En(T).firstChild;re&&re!==Me;re=re.nextSibling)re.nodeType===3&&De.push(re);return De.length?{nodes:De,lead:V}:null},A=T=>{let x=[],z=T;for(;z&&!n.via.has(z);z=z.parentNode)x.push(z);if(!z||!x.length)return null;let D=m(n.via.get(z));for(let Me=x.length-1;Me>0&&D;Me--)D=g(D,x[Me]);if(!D)return null;let V=x[0];if(V.nodeType===3)return b(D,V);let Ee=V.nodeType===1?g(D,V):null;return Ee?{nodes:[Ee],lead:0}:null},p=T=>{let x=o(T),z=x?{nodes:Array.isArray(x)?x:[x],lead:0}:n.via.size?A(T):null;if(!z)return null;let D=z.nodes.filter(a);return D.length?{nodes:D,lead:z.lead}:null},m=T=>{let x=p(T);return x?x.nodes[0]:null},y=T=>{if(!T)return null;if(T.kind==="text"){let V=p(T.node);if(!V)return null;let Ee=V.nodes,Me=T.offset+V.lead,De=0;for(let re=0;re<Ee.length;re++){let Se=Ee[re].nodeValue.length;if(Me<=De+Se||re===Ee.length-1)return Me>=De&&Me<=De+Se?[Ee[re],Me-De]:null;De+=Se}return null}let x=m(T.node);if(!x)return null;if(T.kind==="end")return[En(x),En(x).childNodes.length];if(T.kind==="startOf")return[En(x),0];if(T.kind==="wholeStart")return x.firstChild?[x.firstChild,0]:[x,0];if(T.kind==="wholeEnd")return x.lastChild?[x.lastChild,x.lastChild.nodeValue.length]:[x,x.childNodes.length];let z=x.parentNode;if(!z)return null;let D=Array.prototype.indexOf.call(z.childNodes,x);return[z,T.kind==="after"?D+1:D]},R=T=>({blocks:new Set((T.flat?.marks||[]).filter(x=>x.block).map(x=>m(x.el)).filter(Boolean)),atoms:new Set((T.flat?.atoms||[]).map(x=>m(x.el)).filter(Boolean)),ignored:i}),S=(T,x,z,D)=>{if(!T||!x||!lo(T)||!lo(x))return!1;for(let Me of[T,x])if(!a(Me.startContainer)||!a(Me.endContainer))return!1;let V=z.merged;if(V.start===V.end&&(T.startContainer!==T.endContainer||T.startOffset!==T.endOffset))return!1;let Ee=R(D);return Zn(x,z.encoding,Ee)===V.text&&Zn(T,z.encoding,Ee)===V.text.slice(V.start,V.end)},O=new Map,M=T=>{let x=T.parentNode;return x?(O.has(x)||O.set(x,new Map(Array.from(x.childNodes,(z,D)=>[z,D]))),O.get(x).get(T)):-1},E=(T,x)=>{if(!x)return!1;let z=s.logicalParent(T);if(!x.parent.live.includes(z))return!1;let D=M(T);for(let[V,Ee]of[["before",1],["after",-1]]){let Me=D;for(let De of x[V]){if(De.live.includes(T))continue;let re=De.live.filter(qe=>qe!==T&&qe.parentNode===T.parentNode);if(!re.length)continue;let Se=Ee===1?Math.min(...re.map(M)):Math.max(...re.map(M));if(Ee*(Se-Me)<=0)return!1;Me=Se}}return!0},N=T=>{let x=T.structure;if(x.mergedOrder){let z=new Set(T.subject.live.map(En)),D=null,V=-1;for(let Ee of x.mergedOrder){let Me=Ee.live.find(De=>z.has(De.parentNode));if(!Me||D&&Me.parentNode!==D||M(Me)<=V)return!1;D=Me.parentNode,V=M(Me)}return T.subject.live.length>0}return T.subject.live.some(z=>E(z,x.mergedPlacement))},L=(T,x)=>{let z=y(T),D=y(x);return z&&D?{startContainer:z[0],startOffset:z[1],endContainer:D[0],endOffset:D[1]}:null},j=new Set,F=T=>{if(!T||j.has(T))return;j.add(T);let x=[];for(let z of n.refs.get(T)||[]){let D=p(z);if(D)for(let V of D.nodes)x.includes(V)||x.push(V)}T.live=x},W=T=>{T&&(F(T.parent),T.before.forEach(F),T.after.forEach(F))},C=new Set;for(let T of e){let x=T.recovery;if(!x||C.has(x))continue;C.add(x),F(x.subject),x.structure&&(W(x.structure.localPlacement),W(x.structure.remotePlacement),W(x.structure.mergedPlacement),(x.structure.localOrder||[]).forEach(F),(x.structure.mergedOrder||[]).forEach(F));let z=n.anchors.get(x),D=z?m(z):null,V=!!D;if(x.text){let w=n.spans.get(x.text.merged),K=w?L(w.start,w.end):null,ne=w?L(w.scopeStart,w.scopeEnd):null;if(w?.empty){let ee=w.empty,Pe=ee.previous?{kind:"after",node:ee.previous}:{kind:"startOf",node:ee.parent},_e=ee.next?{kind:"before",node:ee.next}:{kind:"end",node:ee.parent},Ae=L(Pe,_e);!Ae||Ae.startContainer!==Ae.endContainer||Ae.startOffset!==Ae.endOffset?K=null:K=ne=Ae}S(K,ne,x.text,w)||(K=ne=null),x.text.liveSpan=K,x.text.liveScope=K?ne:null,K||(V=!1)}x.structure&&V&&(V=N(x)),x.attribute&&V&&(V=l(D,x.attribute,T.resolved));let Ee=(!!x.attribute||!!x.text&&D?.tagName==="TEXTAREA")&&!!c&&[z,D].some(w=>c.get(w)?.has(x.attribute?x.attribute.qualifiedName:"value")),Me=n.localState?.states.get(x),De=!!x.text&&[...t.removedVetoes||[]].some(w=>Me?.touched.has(w)),re=x.structure?.localAction==="inserted"&&[...r].some(w=>w===z||z?.contains(w)),Se=z&&f(z)||Ee||De||re,qe=Se&&ji(x,T,n,a);qe&&(De||re&&x.localLost)&&(V=!1);let ve=!V&&qe&&Se;x.applied=V,x.unavailable=V?null:ve?"hook-veto":"missing-output",ve&&(x.localLost=!1),!V&&x.text&&(x.text.liveSpan=x.text.liveScope=null)}}function Sr(e,n,t){let o=co(n),r=co(t),c=f=>!!f&&r.containerPath(f)!==null,l=f=>{if(f===n)return t;let u=o.pathOf(f);if(u&&n!==t){let g=io(t,{path:u,offset:0});if(g&&g[0].nodeType===f.nodeType)return g[0]}return f},i=new Set,s=f=>{!f||i.has(f)||(i.add(f),f.live=f.live.map(l).filter(c))},a=f=>{f&&(f.startContainer=l(f.startContainer),f.endContainer=l(f.endContainer))},h=new Set;for(let f of e){f.node===n&&t.tagName==="SCRIPT"&&(f.node=t),f.el===n&&f.kind==="structure"&&(f.el=t);let u=f.recovery;if(!u||h.has(u))continue;if(h.add(u),s(u.subject),u.text){a(u.text.liveSpan),a(u.text.liveScope);let b=u.text.liveSpan,A=u.text.liveScope,p=u.text.merged,m=y=>!!y&&lo(y)&&c(y.startContainer)&&c(y.endContainer);(!m(b)||!m(A)||Zn(A,u.text.encoding)!==p.text||Zn(b,u.text.encoding)!==p.text.slice(p.start,p.end))&&(u.text.liveSpan=null,u.text.liveScope=null,u.applied=!1,u.unavailable="missing-output")}let g=u.structure;if(g){for(let b of[g.localPlacement,g.remotePlacement,g.mergedPlacement])b&&(s(b.parent),b.before.forEach(s),b.after.forEach(s));(g.localOrder||[]).forEach(s),(g.mergedOrder||[]).forEach(s),u.subject.live.length||(u.applied=!1,u.unavailable="missing-output")}}}var vo=e=>e?.nodeType===1,Fo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function Jc({provenance:e,parentOf:n,twins:t,baseOf:o,build:r,ignored:c,remoteWins:l,discarded:i}){let s=new Map,a=new WeakMap;function h(g,b,A,p=!1){if(!vo(g)||!vo(A))return null;let m=s.get(g);if(m)(p||!m.selected&&b==="remote")&&(m.parent=n(A),m.port=A,m.sourceSide=b,m.selected=p);else{let y=a.get(g)||null;m={owner:g,parent:n(A),port:A,sourceSide:b,originalParent:n(g),originalPort:g,selected:p,state:y?"built":"planned",output:y,disposition:null},s.set(g,m)}return m}function f(g,b){if(!vo(g)||!vo(b))return;a.has(g)||a.set(g,b);let A=s.get(g);A&&A.state!=="attached"&&!A.output&&(A.output=b,A.state="built")}function u(g){if(!s.size)return;let b=new Map,A=new WeakMap,p=new WeakMap,m=new WeakSet,y=new Set,R=(W,C)=>{if(!W)return;if(Array.isArray(W)){for(let x of W)R(x,C);return}let T=b.get(W);T||b.set(W,T=[]),T.push(C)},S=(W,C)=>{if(!W)return;let T=[W];for(;T.length;){let x=T.pop();R(x,C);for(let z of Fo(x).childNodes)T.push(z)}};function O(W,C=null,T=!1){if(m.has(W))return;m.add(W),A.set(W,C);let x=e.get(W),z=T||!!(x&&l(x.remote||x.base));p.set(W,z);let D={node:W,kind:"node",authority:z};if(x?.pinned)S(x.local,{...D,kind:"ignored"});else if(x?.unchanged)for(let V of[x.base,x.local,x.remote])S(V,{...D,kind:"unchanged"});else if(x){for(let V of[x.base,x.local,x.remote])R(V,D);if(vo(x.local))for(let V of Fo(x.local).children)c(V)&&S(V,{...D,kind:"ignored"})}for(let V of Fo(W).childNodes)O(V,W,z)}let M=W=>{if(W.output&&m.has(W.output))return W.state="attached",W.disposition="node",!0;let{local:C,remote:T}=t(W.owner);for(let x of[W.owner,C,T]){let z=b.get(x);if(z?.length){let D=z.find(V=>V.kind==="node")||z[0];return W.output=D.node,W.state="attached",W.disposition=D.kind,!0}}return!1},E=(W,C)=>(b.get(W)||[]).find(x=>x.kind==="node"&&vo(x.node)&&(!x.authority||C.sourceSide==="remote"))?.node,N=(W,C,T)=>{let x=b.get(W)||[],z=T?[...x].reverse():x;for(let D of z){if(D.kind!=="node")continue;let V=D.node;for(;V&&A.get(V)!==C;)V=A.get(V);if(V)return V}return null},L=(W,C,T)=>{let x=Fo(C);for(let z=T?.previousSibling;z;z=z.previousSibling){let D=N(z,C,!0);if(D){x.insertBefore(W,D.nextSibling);return}}for(let z=T?.nextSibling;z;z=z.nextSibling){let D=N(z,C,!1);if(D){x.insertBefore(W,D);return}}x.appendChild(W)};function j(W,C,T){let x=C==="base"?W:o(W,C),z=s.get(x);z&&z!==T&&F(z)}function F(W){if(W.state==="attached"||W.disposition==="remote-wins"||y.has(W)||M(W))return;y.add(W);let{local:C,remote:T}=t(W.owner);if(l(T||W.owner)){if(!T){W.disposition="remote-wins",i(W.owner,C),y.delete(W);return}W.parent=n(T),W.port=T,W.sourceSide="remote"}if(j(W.parent,W.sourceSide,W),M(W)){y.delete(W);return}let x=E(W.parent,W),z=W.port;if(!x){if(j(W.originalParent,"base",W),M(W)){y.delete(W);return}let V=W.originalParent;for(z=W.originalPort;V&&!x;)x=E(V,W),x||(z=V,V=n(V))}if(!x)throw new Error("A planned move has no allowed surviving parent");let D=W.output||r(W.owner);W.output=D,W.state="built",L(D,x,z),O(D,x,p.get(x)||!1),M(W),y.delete(W)}O(g);for(let W of s.values())F(W)}return{planned:s,has:g=>s.has(g),plan:h,produced:f,drain:u}}function Oo(e,n,t,o,r,c,l,i,s,a,h,f,u){let g=null;return Jc({provenance:e,parentOf:p=>{if(!p)return null;let m=n(p);if(m||p.parentNode?.nodeType!==11)return m;if(!g){g=new WeakMap;let y=[f,u];for(;y.length;){let R=y.pop(),S=Fo(R);S!==R&&g.set(S,R);for(let O of S.children)y.push(O)}}return g.get(p.parentNode)||null},twins:p=>({local:r(t,p),remote:r(o,p)}),baseOf:(p,m)=>p&&(m==="local"?t:o).reverse.get(p)||null,build:p=>c(p,r(t,p),r(o,p),!1),ignored:l,remoteWins:i,discarded:(p,m)=>{m&&h(p,m,t)&&!s.some(y=>y.detail==="remote-wins"&&y.base===p)&&a({kind:"structure",el:null,detail:"remote-wins",base:p,local:m,remote:null},{subject:p})}})}function Qc({parent:e,base:n,views:t,eligible:o,ignored:r,remoteWins:c,budget:l=Kt(2e4*32),maxUnits:i=256,maxCharacters:s=2e4}){let a=(m,y=null)=>({status:m,reason:y,parent:e,records:[]});if(t.some(({V:m})=>m.asBase)||r(e)||c(e)||t.some(({V:m})=>!m.el||r(m.el)||c(m.el)))return a("none");let h=n.length+t[0].V.units.length+t[1].V.units.length;if(h>i)return a("fallback","unit-limit");let f=Symbol(),u=m=>{if(m>l.remaining)throw f;l.remaining-=m,l.crossParentSteps=(l.crossParentSteps||0)+m},g=new Map,b=0,A=m=>{if(u(1),g.has(m))return g.get(m);let y=m.nodeType===1?m.childNodes:m.nodes;u(y.length*4+1);let R=m.nodeType===1?Array.from(y):y,S=0;for(let E=0;E<R.length;E++){let N=R[E];if(N.nodeType!==3||E&&R[E-1].nextSibling!==N)return g.set(m,null),null;S+=N.data.length}if(S>s-b)throw f;u(S*8+1),b+=S;let O=en(R);if(O.text.includes(wt))return g.set(m,null),null;let M={unit:m,nodes:R,flat:O};return g.set(m,M),M},p=[];try{u(h*8+1);for(let m=0;m<2;m++){let y=t[m].V,R=t[1-m].V,S=[],O=new Map;for(let M=0;M<n.length;M++){u(1);let E=n[M];if(E.kind!=="text"||y.twin(E))continue;let N=R.twin(E);if(!N||N.kind!=="text"||!R.here(N))continue;let L=A(E),j=A(N);if(!L||!j||!/\S/.test(L.flat.text))continue;u(L.flat.text.length*2+1);let F=L.flat.text;O.set(F,(O.get(F)||0)+1),S.push({source:E,opposite:N,sourceModel:L,oppositeModel:j,index:M})}for(let M of S){let{source:E,opposite:N,sourceModel:L,oppositeModel:j,index:F}=M,W=[];for(let K of[-1,1]){u(1);let ne=n[F+K];if(!ne||ne.nodeType!==1||!o(ne)||r(ne)||c(ne))continue;let ee=L.nodes[0],Pe=L.nodes.at(-1);if(K===-1?ee?.previousSibling!==ne:Pe?.nextSibling!==ne)continue;let _e=y.twin(ne),Ae=R.twin(ne);if(!_e||!Ae||!y.here(_e)||R.here(Ae)||y.baseOf(_e)!==ne||R.baseOf(Ae)!==ne||!o(_e)||!o(Ae)||r(_e)||r(Ae)||c(_e)||c(Ae)||_e.tagName!==ne.tagName||Ae.tagName!==ne.tagName||_e.namespaceURI!==ne.namespaceURI||Ae.namespaceURI!==ne.namespaceURI)continue;let ot=A(ne),Qe=A(_e),Ze=A(Ae);if(!ot||!Qe||!Ze||!/\S/.test(ot.flat.text))continue;let Xe=ot.flat.text,yt=L.flat.text,dt=Qe.flat.text;if(u((Xe.length+yt.length+dt.length)*3+1),dt.length!==Xe.length+yt.length)continue;let gt=K===-1;(gt?!dt.startsWith(Xe)||!dt.endsWith(yt):!dt.startsWith(yt)||!dt.endsWith(Xe))||W.push({owner:ne,target:_e,moved:Ae,ownerBase:ot,joined:Qe,ownerOther:Ze,targetFrom:gt?Xe.length:0,retainedFrom:gt?0:yt.length})}if(!W.length)continue;if(W.length!==1||O.get(L.flat.text)!==1)return a("fallback","ambiguous-origin");let C=W[0],{owner:T,target:x,moved:z,ownerBase:D,joined:V,ownerOther:Ee,targetFrom:Me,retainedFrom:De}=C;if(u(p.length+1),p.some(K=>K.owner===T))return a("fallback","ambiguous-owner");let re={source:E,target:x,from:0,to:L.flat.text.length,targetFrom:Me},Se=Dn({base:L.flat,side:V.flat,retained:[],transfers:[{from:re.from,to:re.to,target:Me,destination:T}],budget:l});if(Se.status!=="ready"||Se.covers(re.from,re.to)!==!0)return a("fallback",Se.reason||"work-limit");let qe=[{unit:E,model:L,from:0,to:L.flat.text.length},null,null];qe[m+1]={unit:x,model:V,from:Me,to:Me+L.flat.text.length},qe[2-m]={unit:N,model:j,from:0,to:j.flat.text.length};let ve=[D,null,null];ve[m+1]=V,ve[2-m]=Ee;let w=[T,null,null];w[m+1]=x,w[2-m]=z,p.push({side:m,parent:e,source:E,target:x,owner:T,owners:w,ownerModels:ve,native:qe,models:g,runs:[re],proof:Se,retained:[{source:T,target:x,from:0,to:D.flat.text.length,targetFrom:De}]})}}return p.length?{status:"ready",reason:null,parent:e,records:p}:a("none")}catch(m){if(m!==f)throw m;return a("fallback","work-limit")}}function Ui({describe:e,parentOf:n,...t}){let o=new WeakMap,r=new WeakMap,c=t.budget||Kt(2e4*32),l=i=>{if(!i)return null;if(o.has(i))return o.get(i);o.set(i,{status:"planning",parent:i,records:[]});let s=e(i),a=s?Qc({...t,...s,parent:i,budget:c}):{status:"none",reason:null,parent:i,records:[]};if(o.set(i,a),a.status==="ready")for(let h of a.records)r.set(h.owner,[h]);return a};return{get:l,forOwner(i){return l(n(i))?.status==="ready"&&r.get(i)||null}}}function Zc(e,n){if(e.side!==0)return null;let t=e.native[0].model,o=e.ownerModels[0],r=e.native[1].from!==0,c=(R,S)=>r?[...R.nodes,...S.nodes]:[...S.nodes,...R.nodes],l=e.ownerModels.reduce((R,S)=>R+S.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(l*8>n.remaining)return null;n.remaining-=l*8;let i={base:c(o,t),local:e.ownerModels[1].nodes,remote:c(e.ownerModels[2],e.native[2].model)},s=en(i.base),a=e.ownerModels[1].flat,h=en(i.remote),f=r?o.flat.text.length:0,u=r?0:t.flat.text.length,g=Dn({base:s,side:a,retained:e.retained.map(R=>({from:u+R.from,to:u+R.to,target:R.targetFrom})),transfers:e.runs.map(R=>({from:f+R.from,to:f+R.to,target:R.targetFrom,destination:e.owner})),budget:n});if(g.status!=="ready"||g.covers(0,s.text.length)!==!0)return null;let b=e.ownerModels[2].flat,A=e.native[2].model.flat,p=[];for(let[R,S,O,M]of[[o.flat,b,u,r?0:A.text.length],[t.flat,A,f,r?b.text.length:0]]){let E=ns(R,R,S).remoteMap.bTo,N=-1;for(let L=0;L<R.text.length;L++){if(E[L]<0){N=-1;continue}let j=p.at(-1);N>=0&&j.to===O+L&&j.target+j.to-j.from===M+E[L]?j.to++:(p.push({from:O+L,to:O+L+1,target:M+E[L]}),N=L)}}let m=Dn({base:s,side:h,retained:p,transfers:[],budget:n});if(m.status!=="ready")return null;let y=ns(s,a,h,{},{local:g,remote:m});return y.localEdits.hunks.length?null:(y.localMap=g,y.remoteMap=m,{nodes:i,prepared:y})}function Hi({L:e,R:n,twinIn:t,unitsOf:o,view:r,parentOf:c,ignored:l,remoteWins:i,eligible:s,build:a,out:h,policy:f,provenance:u,textMappers:g,segments:b,conflicts:A,conflict:p,decisions:m}){let y=Kt(2e4*32),R=W=>{let C=0;for(let T=W;T;T=c(T))if(++C>64||T.nodeType===1&&(l(T)||i(T)))return!1;return!0},S=Ui({parentOf:c,eligible:s,ignored:l,remoteWins:i,budget:y,describe(W){let C=t(e,W),T=t(n,W);return!C||!T||!R(W)||!R(C)||!R(T)?null:{base:o(W),views:[{A:e,V:r(e,C,W,!1)},{A:n,V:r(n,T,W,!1)}]}}}),O=new WeakSet,M=new WeakMap,E=new WeakSet,N=[];function L(W){if(!W||O.has(W))return;O.add(W);let C=S.get(W);if(C?.status==="ready")for(let T of C.records){if((W.tagName==="TEMPLATE"&&W.content?W.content:W).childNodes.length!==T.native[0].model.nodes.length+1||!T.owners.every(R))continue;let z=Zc(T,y);if(!z)continue;let D={record:T,payload:z,state:"planned",output:null,result:null};M.set(T.owner,D),E.add(T.source),E.add(T.native[2].unit),N.push(D)}}function j(W,C){let T=M.get(W);if(!T)return!1;if(!T.result){if(T.result=so({...T.payload.nodes,prepared:T.payload.prepared,out:h,policy:f,provenance:u,textMappers:g,conflicts:A,conflict:p,decisions:m,node:C}),T.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");b.push(...T.result.segments),T.decision={kind:"text",node:C,source:"local"},m.push(T.decision)}return T.decision.node=C,C.replaceChildren(...T.result.nodes),T.output=C,T.state="built",!0}function F(W){if(!N.length)return;let C=new WeakSet,T=new WeakMap,x=new WeakMap,z=new WeakMap,D=Se=>Se.tagName==="TEMPLATE"&&Se.content?Se.content:Se,V=(Se,qe)=>{if(!Se)return;if(Array.isArray(Se)){for(let w of Se)V(w,qe);return}let ve=z.get(Se);ve||z.set(Se,ve=[]),ve.push(qe)},Ee=(Se,qe=null,ve=!1)=>{C.add(Se),T.set(Se,qe);let w=u.get(Se),K=ve||!!(w&&i(w.remote||w.base));if(x.set(Se,K),w)for(let ne of[w.base,w.local,w.remote])V(ne,Se);if(!(w?.pinned||w?.unchanged))for(let ne of D(Se).childNodes)Ee(ne,Se,K)},Me=Se=>(z.get(Se)||[]).find(qe=>qe.nodeType===1&&!x.get(qe)&&!u.get(qe)?.pinned&&!u.get(qe)?.unchanged),De=(Se,qe)=>{for(let ve of z.get(Se)||[]){let w=ve;for(;w&&T.get(w)!==qe;)w=T.get(w);if(w)return w}return null},re=(Se,qe,ve)=>{let w=D(qe);for(let K=ve.nextSibling;K;K=K.nextSibling){let ne=De(K,qe);if(ne){w.insertBefore(Se,ne);return}}for(let K=ve.previousSibling;K;K=K.previousSibling){let ne=De(K,qe);if(ne){w.insertBefore(Se,ne.nextSibling);return}}w.appendChild(Se)};Ee(W);for(let Se of N){let{record:qe}=Se,ve=Me(qe.owner)||Me(qe.owners[1])||Me(qe.owners[2]);if(ve)(!Se.result||Se.output!==ve||Se.result.nodes.some(w=>!C.has(w)||T.get(w)!==ve)||ve.textContent!==Se.result.text)&&(j(qe.owner,ve),Ee(ve,T.get(ve),x.get(ve)));else{let w=qe.parent,K=qe.owner,ne=null;for(;w&&!ne;)ne=Me(w),ne||(K=w,w=c(w));if(!ne)throw new Error("A cross-parent payload has no allowed surviving parent");ve=Se.output||a(qe.owner,qe.owners[1],qe.owners[2],!1),Se.result||j(qe.owner,ve),re(ve,ne,K),Ee(ve,ne,x.get(ne))}Se.state="attached"}}return{ensureParent:L,ensureOwner(W){L(c(W))},consumes(W){return E.has(W)},render:j,drain:F}}var Sn=/\S/,Wi=/[\p{L}\p{N}]/u;function ao(e,n,t,o){if(e?.nodeType!==1||!n(e))return!1;for(let r=e.firstChild;r;r=r.nextSibling)if(o(t,1),r.nodeType!==3)return!1;return!!e.firstChild}function ls(e,n,t){for(let o=e.parentNode;o;o=o.parentNode)if(t(n,1),o.nodeType===11)return!1;return!0}function Vi(e,n,t,o,r){let c=t(e,o),l=t(n,o),i=null,s=null,a=null,h=null;r(o,c.length+l.length);for(let f of c)Wi.test(f.raw)&&(i||=f,s=f);for(let f of l)Wi.test(f.raw)&&(a||=f,h=f);return!!(i&&a&&(i.raw===a.raw||s.raw===h.raw))}function ea({base:e,V:n,A:t,source:o,original:r,current:c,edited:l,destination:i,at:s,ownLength:a,eligible:h,model:f,tokensOf:u,budget:g,charge:b}){let A=r.flat.text,p=c.flat.text,m=l.flat.text,y=i.flat.text;if(b(g,A.length+p.length+y.length),A.startsWith(p)||A.endsWith(p))return!1;let R=Sn.test(y.slice(0,s)),S=Sn.test(y.slice(s+a));if(R===S)return!1;let O=R?0:s+a,M=R?s:y.length;for(;O<M&&!Sn.test(y[O]);)O++;for(;M>O&&!Sn.test(y[M-1]);)M--;let E=y.slice(O,M);if(Mn(E,y,u(i,g),g,b,!0)!==O)return!1;let N=Mn(E,A,u(r,g),g,b,!0);if(N<0)return!1;let L=N+E.length,j=!Sn.test(A.slice(0,N)),F=!Sn.test(A.slice(L));if(j===F||Mn(E,p,u(c,g),g,b,!1)>=0)return!1;let W=j?A.slice(L):A.slice(0,N),C=j?m.length-W.length:0;if(b(g,A.length+m.length),C<0||!Sn.test(W)||Mn(W,m,u(l,g),g,b,!0)!==C||!Sn.test(j?m.slice(0,C):m.slice(W.length)))return!1;for(let T of e){if(b(g,1),T===o||!ao(T,h,g,b))continue;let x=f(T,null,g);if(Mn(E,x.flat.text,u(x,g),g,b,!1)>=0)return!1}for(let T of n.units){if(b(g,1),T===c.unit||T===i.unit||!ao(T,h,g,b))continue;let x=f(T,t,g);if(Mn(E,x.flat.text,u(x,g),g,b,!1)>=0)return!1}return!0}function _i({base:e,views:n,side:t,attempt:o,eligible:r,blocked:c,baseId:l,model:i,tokensOf:s,charge:a,exhausted:h,limit:f}){if(f<=0)return null;let u=Kt(f),{V:g,A:b,idOf:A}=n[t],p=n[1-t],[m,y,R,S]=o,O=null;try{for(let M=m;M<=y;M++){a(u,1);let E=e[M];if(E.parentNode?.nodeType!==1||c.has(E)||b.identical.has(E)||p.A.identical.has(E)||!ao(E,r,u,a)||l(E))continue;let N=g.twin(E),L=p.V.twin(E);if(!N||!L||!g.here(N)||!p.V.here(L)||b.map.get(E)!==N||b.reverse.get(N)!==E||p.A.map.get(E)!==L||p.A.reverse.get(L)!==E||A(N)||p.idOf(L)||N.tagName!==E.tagName||L.tagName!==E.tagName||!ao(N,r,u,a)||!ao(L,r,u,a)||!ls(E,u,a)||!ls(N,u,a)||!ls(L,u,a))continue;let j=i(E,null,u),F=i(N,b,u),W=i(L,p.A,u),C=j.flat.text,T=F.flat.text,x=W.flat.text;if(a(u,C.length+T.length+x.length),!Sn.test(C)||!Sn.test(T)||!Sn.test(x)||C===T||C===x||T===x||!Vi(j,F,s,u,a)||!Vi(j,W,s,u,a))continue;let z=null,D=!1;for(let Me=R;Me<=S;Me++){a(u,1);let De=g.units[Me],re=g.baseOf(De);if(!re||re===E||c.has(re)||re.parentNode!==E.parentNode||De.parentNode!==N.parentNode||re.tagName!==E.tagName||De.tagName!==E.tagName||b.map.get(re)!==De||b.reverse.get(De)!==re||l(re)!==A(De)||!ao(re,r,u,a)||!ao(De,r,u,a))continue;let Se=i(re,null,u),qe=i(De,b,u),ve=Se.flat.text,w=qe.flat.text;if(a(u,ve.length),!Sn.test(ve)||w.length<=ve.length)continue;let K=s(qe,u),ne=Mn(ve,w,K,u,a,!0);if(!(ne<0||Mn(C,w,K,u,a,!0,ne,ne+ve.length)<0&&!ea({base:e,V:g,A:b,source:E,original:j,current:F,edited:W,destination:qe,at:ne,ownLength:ve.length,eligible:r,model:i,tokensOf:s,budget:u,charge:a}))){if(z){D=!0;break}z=De}}if(!z||D)continue;let V=t===0?N:L,Ee=t===0?L:N;(O||=[]).push({source:E,local:V,remote:Ee,models:[j,t===0?F:W,t===0?W:F]})}}catch(M){if(M!==h)throw M}return O}var Hn=/\S/,pn=/\s/,ta=/[\s\u001e]/g,cs=/[^\s\p{P}\u001e\ufffc]/u;function na(e,n,t,o,r,c,l){let i=0;for(let s of e)l(c,1),s.nodeType===1&&!o.baseOf(s)&&i++;if(i<2)return!1;for(let s of e){if(s.nodeType!==1||o.baseOf(s))continue;let a=r.get(s).flat;if(a.atoms.length||a.pins?.length)continue;l(c,a.text.length*2+n.length+t.length);let h=new Uint8Array(a.text.length);for(let f of t)f.target===s&&h.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f of n)f.target===s&&h.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f=0;f<a.text.length;f++)if(!h[f]&&Hn.test(a.text[f]))return!0}return!1}function oa(e,n,t){let{source:o,models:r,retained:c,runs:l}=e,i=r.get(o).flat.text;t(n,i.length*2+c.length+l.length);let s=new Uint8Array(i.length);for(let a of c)a.source===o&&(t(n,a.to-a.from),s.fill(1,a.from,a.to));for(let a of l)t(n,a.to-a.from),s.fill(1,a.from,a.to);for(let a=0;a<i.length;a++)if(!s[a]&&Hn.test(i[a]))return!1;return!0}function ra(e,n,t,o,r,c,l,i,s,a){let h=c.get(e),f=c.get(n),u=h.flat.text,g=l.get(e);s(a,u.length*2+t.length);let b=u.length,A=0;for(let y=0;y<u.length;y++)!pn.test(u[y])&&!g[y]&&(b=Math.min(b,y),A=y+1);if(b>=A)return null;for(let y=b;y<A;y++)if(!pn.test(u[y])&&g[y])return null;let p=-1;for(let y of t)if(y.target===n&&y.from<=b&&y.to>b){p=y.targetFrom+b-y.from;break}if(p<0)return null;let m=u.slice(b,A);if(s(a,m.length*(t.length+2)),f.flat.text.slice(p,p+m.length)!==m)return null;for(let y=b;y<A;y++){if(pn.test(u[y]))continue;let R=!1;for(let S of t)if(S.target===n&&S.from<=y&&S.to>y&&S.targetFrom+y-S.from===p+y-b){R=!0;break}if(!R)return null}if(h.flat.atoms.length||f.flat.atoms.length){s(a,h.flat.atoms.length+f.flat.atoms.length);let y=0,R=f.flat.atoms;for(;y<R.length&&R[y].i<p;)y++;for(let S of h.flat.atoms){if(S.i<b||S.i>=A)continue;let O=R[y++];if(!O||O.i!==p+S.i-b||f.alignment?.reverse.get(O.el)!==S.el)return null}if(y<R.length&&R[y].i<p+A-b)return null}for(let[y,R,S]of[[o,e,b],[r,n,p]]){let O=!1;for(let M of y){let E=c.get(M),N=l.get(M),L=i(E,a);for(let j=0;j<L.length;j++){let F=L[j].from,W=F+m.length;if(s(a,m.length*2+1),E.flat.text.slice(F,W)!==m)continue;let C=j;for(;C<L.length&&L[C].to<W;)s(a,1),C++;if(C===L.length||L[C].to!==W)continue;let T=!0;for(let x=F;x<W;x++)if(!pn.test(E.flat.text[x])&&N[x]){T=!1;break}if(T){if(O||M!==R||F!==S)return null;O=!0}}}if(!O)return null}return m}function sa(e,n,t,o,r,c,l,i){if(l(i,r.length+c.length+(o.length+1)*t.length*2),!t)return!1;let s=o.indexOf(t);return s<0||o.lastIndexOf(t)!==s||!c.some(a=>a.from===s)||!c.some(a=>a.to===s+t.length)?!1:r.some(a=>a.source===e&&a.target===n&&a.from===0&&a.to===t.length&&a.targetFrom===s)}function Fi({base:e,views:n,eligible:t,baseId:o,ignored:r,remoteWins:c,atomKey:l,limit:i=2e4*8}){if(i<=0)return null;let s=Symbol(),a=(S,O)=>{if(O>S.remaining)throw s;S.remaining-=O},h=[new Map,new Map];for(let S=0;S<2;S++)for(let O=0;O<n[S].V.units.length;O++)h[S].set(n[S].V.units[O],O);let f=new Int32Array(e.length),u=new Int32Array(e.length),g=S=>n.every(({V:O},M)=>{let E=O.twin(S);return E&&h[M].has(E)}),b=-1;for(let S=0;S<e.length;S++)f[S]=b,g(e[S])&&(b=S);b=e.length;for(let S=e.length-1;S>=0;S--)u[S]=b,g(e[S])&&(b=S);let A=new Map,p=(S,O)=>{if(a(O,1),A.has(S))return A.get(S);let M=S.firstChild,E=1;for(;M;){if(a(O,E*8+8),M.nodeType===3&&a(O,M.data.length*8),M.nodeType===1&&wn.has(M.tagName)&&!r(M)&&!c(M)&&M.firstChild){M=M.firstChild,E++;continue}for(;M&&M!==S&&!M.nextSibling;)M=M.parentNode,E--;M=!M||M===S?null:M.nextSibling}let N=en(Array.from(S.childNodes),{ignored:r,remoteWins:c});return A.set(S,N),N},m=(S,O,M,E,N,L)=>{for(let j of S.atoms){a(L,1);let F=O.atomAt.get(j.i+M);if(!F)return!1;let W=E?.reverse.get(j.el)||l(j.el),C=N?.reverse.get(F.el)||l(F.el);if(W!==C)return!1}return!0},y=(S,O,M,E,N)=>{let L=S.text.length<=O.text.length?S:O,j=L===S?O:S;if(a(N,L.text.length+j.text.length),!L.text||!Hn.test(L.text.replaceAll(Bn,"")))return!1;let F;if(L.text===j.text)F=0;else{let W=j.text.length-L.text.length;if(a(N,(W+1)*L.text.length*2),j.text.startsWith(L.text))F=0;else if(j.text.endsWith(L.text))F=W;else return!1;if(j.text.indexOf(L.text)!==F||j.text.lastIndexOf(L.text)!==F)return!1;a(N,j.text.length*2);let C=0,T=F===0,x=!1;for(let z of ln(j.text,yn(j.text)))C+=z.len,C===F&&(T=!0),C===F+L.text.length&&(x=!0);if(!T||!x)return!1}return L===S?m(L,j,F,M,E,N):m(L,j,F,E,M,N)},R=null;for(let S=0;S<2;S++){let{V:O,A:M,idOf:E}=n[S],N=n[1-S];if(!O.asBase)for(let L=0;L<e.length;L++){let j=e[L];if(O.twin(j)||!t(j))continue;let F=N.V.twin(j);if(!F||!h[1-S].has(F)||!t(F))continue;let W={remaining:i};try{let C=f[L],T=u[L],x=0;for(let Ee=C+1;Ee<T;Ee++)a(W,1),!O.twin(e[Ee])&&N.V.twin(e[Ee])&&t(e[Ee])&&x++;if(x!==1||p(j,W).text===p(F,W).text)continue;let z=C<0?-1:h[S].get(O.twin(e[C])),D=T===e.length?O.units.length:h[S].get(O.twin(e[T]));if(z===void 0||D===void 0||z>=D)continue;let V=null;for(let Ee=z+1;Ee<D;Ee++){a(W,1);let Me=O.units[Ee];if(O.baseOf(Me)||!t(Me)||Me.tagName!==j.tagName||Me.namespaceURI!==j.namespaceURI)continue;let De=o(j),re=N.idOf(F),Se=E(Me);if(!(De&&re&&De!==re||De&&Se&&De!==Se||re&&Se&&re!==Se)&&y(p(F,W),p(Me,W),N.A,M,W)){if(V){V=null;break}V=Me}}if(!V)continue;R||(R=[new Map,new Map]),R[S].set(j,V)}catch(C){if(C!==s)throw C}}}return R?n.map(({V:S},O)=>{let M=R[O];if(!M.size)return S;let E=new Map;for(let[N,L]of M)E.set(L,N);return{...S,twin:N=>M.get(N)||S.twin(N),baseOf:N=>E.get(N)||S.baseOf(N)}}):null}function $i({onUncertainSource:e,onUncertainOwner:n,base:t,views:o,eligible:r,ignored:c,remoteWins:l,baseId:i,atomKey:s,limit:a=2e4*32}){if(a<=0)return null;let h=new Set(t),f=new Map(t.map((C,T)=>[C,T])),u=new Map,g=[],b=null,A=null,p=null,m=new Set;for(let C of t)for(let{V:T}of o){let x=T.twin(C);x&&!T.asBase&&!T.here(x)&&m.add(C)}let y=new Set,R=Symbol(),S=(C,T)=>{if(T>C.remaining)throw R;C.remaining-=T},O=(C,T,x)=>{S(x,1);let z=u.get(C);if(z)return z;if(C.nodeType===1){let Ee=C.firstChild,Me=1;for(;Ee;){if(S(x,Me*8+8),Ee.nodeType===3&&S(x,Ee.data.length*8),Ee.nodeType===1&&wn.has(Ee.tagName)&&!c(Ee)&&!l(Ee)&&Ee.firstChild){Ee=Ee.firstChild,Me++;continue}for(;Ee&&Ee!==C&&!Ee.nextSibling;)Ee=Ee.parentNode,Me--;Ee=!Ee||Ee===C?null:Ee.nextSibling}}else S(x,C.value.length*8+C.nodes.length);let D=C.nodeType===1?Array.from(C.childNodes):C.nodes,V=D.length===1&&D[0].nodeType===3?{text:D[0].data,nodes:[{node:D[0],s:0,e:D[0].data.length}],atoms:[]}:en(D,{ignored:c,remoteWins:l});return z={unit:C,flat:V,alignment:T,tokens:null},u.set(C,z),z},M=(C,T)=>{if(C.tokens)return C.tokens;S(T,C.flat.text.length*8);let{unit:x,flat:z,alignment:D}=C,V=[],Ee=yn(z.text),Me=0,De=re=>{for(let Se of ln(z.text.slice(Me,re),Ee))Se.from=Me,Se.to=Me+Se.len,Se.unit=x,V.push(Se),Me+=Se.len};for(let re of z.atoms){De(re.i);let Se=l(re.el)&&re.el.nodeType===1?"w"+re.el.tagName+"#"+(re.el.id||""):s(D?.reverse.get(re.el)||re.el);V.push({k:Se,raw:Bn,len:1,from:Me,to:Me+1,unit:x,atom:!0}),Me++}return De(z.text.length),C.tokens=V,V},E=(C,T,x,z,D)=>{if(!C.flat.atoms.length&&!T.flat.atoms.length)return!0;let V=M(C,D),Ee=M(T,D);S(D,V.length+Ee.length);let Me=0;for(let De of Ee){if(!De.atom||De.from<x||De.from>=x+z)continue;for(;Me<V.length&&!V[Me].atom;)Me++;let re=V[Me++];if(!re||re.from!==De.from-x||re.k!==De.k)return!1}for(;Me<V.length;)if(V[Me++].atom)return!1;return!0},N=(C,T,x)=>{let z=C.length+T.length+4;if(z*8>x.remaining)return null;x.remaining-=z*8;let D=Math.floor(x.remaining/8),V=Math.min(C.length+T.length,4e3,Math.floor((Math.sqrt(z*z+D)-z)/2)),Ee=4*(V+1)*(z+V+1);if(V<1||Ee>x.remaining)return null;x.remaining-=Ee;let Me=Kn(C,T,V),De=[],re=0,Se=0;for(let qe of Me.hunks){for(;re<qe.bs;)C[re].raw===T[Se].raw&&De.push([C[re],T[Se]]),re++,Se++;re=qe.be,Se+=qe.toks.length}for(;re<C.length&&Se<T.length;)C[re].raw===T[Se].raw&&De.push([C[re],T[Se]]),re++,Se++;return De},L=(C,T,x,z,D,V,Ee)=>{if(D<=z)return;let Me=C[C.length-1];if(Me&&Me.source===T&&Me.target===x&&Me.to<=z&&Me.targetFrom-Me.from===V-z){S(Ee,(z-Me.to)*3);let De=u.get(T).flat.text,re=u.get(x).flat.text,Se=!0;for(let qe=Me.to;qe<z;qe++)if(!pn.test(De[qe])||De[qe]!==re[V+qe-z]){Se=!1;break}if(Se){Me.to=D;return}}C.push({source:T,target:x,from:z,to:D,targetFrom:V})},j=C=>C.replace(ta,"");for(let C=0;C<o.length;C++){let{V:T,A:x,idOf:z}=o[C];if(T.asBase)continue;let D=new Map(T.units.map((w,K)=>[w,K])),V=w=>{let K=T.twin(w);return K&&D.has(K)?K:null},Ee=(w,K)=>{let ne=new Int32Array(w.length),ee=new Int32Array(w.length),Pe=-1;for(let _e=0;_e<w.length;_e++)ne[_e]=Pe,K(w[_e])&&(Pe=_e);Pe=w.length;for(let _e=w.length-1;_e>=0;_e--)ee[_e]=Pe,K(w[_e])&&(Pe=_e);return{prev:ne,next:ee}},Me=Ee(t,w=>(w.nodeType===1||w.kind==="text"&&Hn.test(w.value))&&V(w)),De=Ee(T.units,w=>(w.nodeType===1||w.kind==="text"&&Hn.test(w.value))&&h.has(T.baseOf(w))),re=new Map,Se=(w,K,ne,ee)=>{if(w>K||ne>ee)return;let Pe=`${w}:${K}:${ne}:${ee}`;re.set(Pe,[w,K,ne,ee])};for(let w=0;w<T.units.length;w++){let K=T.units[w];if(T.baseOf(K)||!r(K))continue;let ne=De.prev[w],ee=De.next[w],Pe=ne<0?0:f.get(T.baseOf(T.units[ne])),_e=ee===T.units.length?t.length-1:f.get(T.baseOf(T.units[ee]));Se(Pe,_e,Math.max(0,ne),Math.min(T.units.length-1,ee))}for(let w=0;w<t.length;w++){let K=t[w];if(m.has(K)||!r(K))continue;if(!T.twin(K)){let ot=Me.prev[w],Qe=Me.next[w],Ze=ot<0?0:D.get(V(t[ot])),Xe=Qe===t.length?T.units.length-1:D.get(V(t[Qe]));Se(Math.max(0,ot),Math.min(t.length-1,Qe),Ze,Xe)}let ne=V(K);if(!ne||x.identical.has(K)||!r(ne))continue;let ee=w+1;for(;ee<t.length&&t[ee].kind==="text"&&!t[ee].value.trim();)ee++;if(ee>=t.length||!r(t[ee]))continue;let Pe=V(t[ee]);if(!Pe||x.identical.has(t[ee])||!r(Pe))continue;let _e=D.get(ne),Ae=D.get(Pe);_e<Ae&&Se(w,ee,_e,Ae)}let qe=Array.from(re.values()),ve=new Set;if(qe.length>1){let w=Kt(a);try{S(w,qe.length*4);let K=qe.slice().sort((Pe,_e)=>(S(w,1),Pe[0]-_e[0]||Pe[2]-_e[2])),ne=[],ee=null;for(let Pe of K)S(w,1),ee&&Pe[0]<=ee[1]&&Pe[2]<=ee[3]&&Pe[3]>=ee[2]?(ee[1]=Math.max(ee[1],Pe[1]),ee[2]=Math.min(ee[2],Pe[2]),ee[3]=Math.max(ee[3],Pe[3]),ee[4].push(Pe)):(ee?.[4].length>1&&ne.push(ee),ee=[Pe[0],Pe[1],Pe[2],Pe[3],[Pe]]);ee?.[4].length>1&&ne.push(ee),qe=ne.concat(qe)}catch(K){if(K!==R)throw K}}for(let w of qe){if(ve.has(w))continue;let[K,ne,ee,Pe,_e]=w,Ae=Kt(a),ot=[],Qe=new Set,Ze=!1;try{S(Ae,(ne-K+Pe-ee+2)*4);let Xe=t.slice(K,ne+1).filter(Z=>!x.identical.has(Z)&&r(Z)&&!m.has(Z)),yt=T.units.slice(ee,Pe+1).filter(Z=>r(Z)&&(!T.baseOf(Z)||h.has(T.baseOf(Z)))&&!x.identical.has(T.baseOf(Z))&&!m.has(T.baseOf(Z))),dt=new Set(yt),gt=!1,qt="",$t="",Ht=0;for(let Z of Xe){let Oe=O(Z,null,Ae);qt+=Oe.flat.text,Ht+=Oe.flat.text.length}for(let Z of yt){let Oe=O(Z,x,Ae);$t+=Oe.flat.text,Ht+=Oe.flat.text.length}S(Ae,Ht);let jt=j(qt),an=j($t),_t=jt===an;if(Ze=_t,_e&&!_t)continue;let zt=_t?null:new Map;if(zt)for(let Z of Xe.concat(yt)){let Oe=u.get(Z).flat.text.length;S(Ae,Oe*16),zt.set(Z,new Uint8Array(Oe))}let _=Z=>{let Oe=[];for(let He of Z){let Ie=u.get(He);Ie.flat.atoms.length?Oe.push(...M(Ie,Ae)):Oe.push({unit:He,raw:Ie.flat.text,from:0})}return Oe},ie=[];for(let Z of _t?[]:Xe){let Oe=V(Z);if(!dt.has(Oe))continue;let He=O(Z,null,Ae),Ie=O(Oe,x,Ae);S(Ae,He.flat.text.length+Ie.flat.text.length);let ge=He.flat.text&&Ie.flat.text.startsWith(He.flat.text)?0:He.flat.text&&Ie.flat.text.endsWith(He.flat.text)?Ie.flat.text.length-He.flat.text.length:-1;if(ge>=0&&E(He,Ie,ge,He.flat.text.length,Ae)){zt.get(Z).fill(1),zt.get(Oe).fill(1,ge,ge+He.flat.text.length),L(ie,Z,Oe,0,He.flat.text.length,ge,Ae);continue}let B=N(M(He,Ae),M(Ie,Ae),Ae);if(!B){gt=!0;break}for(let[G,ue]of B)zt.get(Z).fill(1,G.from,G.to),zt.get(Oe).fill(1,ue.from,ue.to),L(ie,Z,Oe,G.from,G.to,ue.from,Ae)}if(gt)continue;let me=null,pe=null;if(!_t)for(let Z of Xe){let Oe=V(Z),He=u.get(Z);if(!Oe||He.flat.atoms.length||!dt.has(Oe))continue;let Ie=He.flat.text,ge=zt.get(Z);S(Ae,Ie.length*3+yt.length);let B=-1,G=-1,ue=!1;for(let We=0;We<Ie.length;We++)pn.test(Ie[We])||(ge[We]?ue=!0:(B<0&&(B=We),G=We+1));if(!ue||B<0)continue;let he=!0;for(let We=B;We<G;We++)if(ge[We]&&!pn.test(Ie[We])){he=!1;break}if(!he)continue;let ce=j(Ie.slice(B,G)),xe=null,te=!1;for(let We of yt){if(T.baseOf(We))continue;let Ne=u.get(We);if(!Ne.flat.atoms.length&&(S(Ae,Ne.flat.text.length),j(Ne.flat.text)===ce)){if(xe){te=!0;break}xe=We}}if(te){(pe||=new Set).add(Z);continue}if(!xe||pe?.has(Z))continue;let q=!1;for(let We of Xe){if(We===Z||!dt.has(V(We)))continue;let Ne=u.get(We);if(Ne.flat.atoms.length)continue;let ze=zt.get(We);S(Ae,Ne.flat.text.length*3);let tt="",k=!1;for(let $=0;$<Ne.flat.text.length;$++)pn.test(Ne.flat.text[$])||(ze[$]?k=!0:tt+=Ne.flat.text[$]);k&&tt===ce&&(pe||=new Set,pe.add(Z),pe.add(We),q=!0)}if(q)continue;let ae=u.get(xe).flat.text;S(Ae,G-B+ae.length);let Ce=B,Le=0;for(;Ce<G&&Le<ae.length;){for(;Ce<G&&pn.test(Ie[Ce]);)Ce++;for(;Le<ae.length&&pn.test(ae[Le]);)Le++;if(Ce>=G||Le>=ae.length)break;L(me||=[],Z,xe,Ce,Ce+1,Le,Ae),Ce++,Le++}ge.fill(1,B,G),zt.get(xe).fill(1)}let ke=Z=>{let Oe=[];for(let He of Z){let Ie=O(He,h.has(He)?null:x,Ae),ge=zt.get(He);for(let B of M(Ie,Ae)){let G=B.from;for(;G<B.to;){for(;G<B.to&&ge[G];)G++;let ue=G;for(;G<B.to&&!ge[G];)G++;if(G>ue){let he=Ie.flat.text.slice(ue,G);Hn.test(he)&&Oe.push({...B,raw:he,len:G-ue,k:B.atom?B.k:he,from:ue,to:G})}}}}return Oe},v=_t?_(Xe):ke(Xe),P=_t?_(yt):ke(yt),Y=_t?jt:v.map(Z=>j(Z.raw)).join(""),J=_t?an:P.map(Z=>j(Z.raw)).join("");if((!Y||!J)&&!me)continue;let oe=me||[];if(Y&&J&&Y===J){let Z=0,Oe=0,He=0,Ie=0;for(;Z<v.length&&Oe<P.length;){let ge=v[Z],B=P[Oe];for(;He<ge.raw.length&&pn.test(ge.raw[He]);)He++;for(;Ie<B.raw.length&&pn.test(B.raw[Ie]);)Ie++;if(He===ge.raw.length){Z++,He=0;continue}if(Ie===B.raw.length){Oe++,Ie=0;continue}if((ge.atom||B.atom)&&ge.k!==B.k){gt=!0;break}L(oe,ge.unit,B.unit,ge.from+He,ge.from+He+1,B.from+Ie,Ae),He++,Ie++}}else if(Y&&J){let Z=N(v,P,Ae);if(!Z)continue;for(let[Oe,He]of Z)L(oe,Oe.unit,He.unit,Oe.from,Oe.to,He.from,Ae)}if(gt)continue;let je=new Map;for(let Z of oe)if(!pe?.has(Z.source)){if(V(Z.source)===Z.target){_t&&ie.push(Z);continue}je.has(Z.source)||je.set(Z.source,[]),je.get(Z.source).push(Z)}for(let[Z,Oe]of je){let He=O(Z,null,Ae),Ie=V(Z),ge=He.flat.text,B=[],G=new Set,ue=o[1-C],he=ue.V.twin(Z),ce=he&&ue.V.here(he)?O(he,ue.A,Ae):null,xe=(Ne,ze)=>{let tt=M(Ne,Ae),k=M(ze,Ae);return S(Ae,Ne.flat.text.length+ze.flat.text.length+tt.length+k.length),Ne.flat.text===ze.flat.text&&tt.length===k.length&&tt.every(($,Q)=>$.k===k[Q].k)},te=Ie&&ce&&ce.flat.text!==ge&&xe(O(Ie,x,Ae),ce);for(let Ne of new Set(Oe.map(ze=>ze.target))){if(Z.nodeType!==1&&Ne.nodeType!==1)continue;let ze=O(Ne,x,Ae),tt=T.baseOf(Ne);if(Z.nodeType!==1&&tt||(S(Ae,ge.length*2+ze.flat.text.length*3+ie.length*2),Ie&&j(ge)===j(ze.flat.text)&&O(Ie,x,Ae).flat.text.trim()))continue;if(!Ie&&!tt&&Z.nodeType===1&&Ne.nodeType===1){let fe=i(Z),se=z(Ne);if(fe&&se&&fe!==se)continue}let k=ze.flat.text,$=ge&&(k.startsWith(ge)||k.endsWith(ge)),Q=!1;if(!Ie&&ce&&tt&&ce.flat.text!==ge){let fe=O(tt,null,Ae).flat.text,se=f.get(Z)<f.get(tt)?ce.flat.text:fe,le=f.get(Z)<f.get(tt)?fe:ce.flat.text;S(Ae,se.length+le.length+k.length),Q=!!se&&!!le&&se.length+le.length<=k.length&&k.startsWith(se)&&k.endsWith(le)&&!k.slice(se.length,k.length-le.length).trim()}let be=!He.flat.atoms.length&&!ce?.flat.atoms.length&&!ze.flat.atoms.length&&(te&&$||Q);if(Ie&&tt){let fe=O(Ie,x,Ae).flat.text,se=ge.startsWith(fe)||ge.endsWith(fe),le=O(tt,null,Ae).flat.text,Be=ze.flat.text,Ke=Be.startsWith(le)||Be.endsWith(le),Ue=!o[1-C].V.twin(tt)&&!ie.some($e=>$e.source===tt&&Hn.test(le.slice($e.from,$e.to)));if(!_t&&(!se&&!be||!Ke&&!Ue)){let $e=ra(Z,Ne,Oe,Xe,yt,u,zt,M,S,Ae);if(!$e)continue;let Ge=x.weak?.has(Z)&&!x.identityPaired?.has(Z)&&ge.trim()===$e;if(!se&&!be&&!Ge)continue;let et=x.weak?.has(tt)&&!x.identityPaired?.has(tt)&&k.trim()===$e&&!u.get(tt).flat.atoms.length&&!ie.some(Ot=>Ot.source===tt&&Hn.test(le.slice(Ot.from,Ot.to)));if(!Ke&&!Ue&&!et&&!sa(tt,Ne,le,k,ie,M(ze,Ae),S,Ae))continue;Ge&&G.add(Ne)}}be&&G.add(Ne),S(Ae,Oe.length),B.push(...Oe.filter(fe=>fe.target===Ne))}if(!B.length)continue;let q=new Uint8Array(ge.length);S(Ae,ge.length*4+ie.length);for(let Ne of B)q.fill(1,Ne.from,Ne.to);let ae=[];for(let Ne=0;Ne<ge.length;Ne++)pn.test(ge[Ne])||ae.push(Ne);if(!ae.length)continue;let Ce=new Set(B.map(Ne=>Ne.target));if(!_t&&Ie&&Ce.size>1&&na(Ce,oe,ie,T,u,Ae,S)){if(p||=new Map,p.set(Z,(p.get(Z)||0)|1<<C),e){let Ne=es({source:Z,side:C,views:o,eligible:r,blocked:m,baseId:i,model:O,tokensOf:M,budget:Ae,charge:S});if(Ne){S(Ae,Ne.to-Ne.from);let ze=!0;for(let tt=Ne.from;tt<Ne.to;tt++)if(Hn.test(ge[tt])&&!q[tt]){ze=!1;break}ze&&(b||=[]).push(Ne)}}continue}let Le=ae.filter(Ne=>cs.test(ge[Ne]));if(!B.some(Ne=>cs.test(ge.slice(Ne.from,Ne.to)))&&!ae.every(Ne=>q[Ne]))continue;if(!Ie&&!Array.from(Ce).some(Ne=>G.has(Ne))&&!ae.every(Ne=>q[Ne])&&!(Le.length&&q[Le[0]]&&q[Le[Le.length-1]]&&Ce.size===1)){let Ne=null,ze=0,tt=0,k=null,$=null;if(!Ie&&ce&&Z.nodeType===1&&!He.flat.atoms.length){let Q=M(He,Ae).filter(be=>cs.test(be.raw));S(Ae,yt.length+ge.length);for(let be of yt){let fe=T.baseOf(be);if(!fe||fe===Z||fe.nodeType!==1||be.nodeType!==1||fe.tagName!==Z.tagName||be.tagName!==fe.tagName)continue;let se=f.get(Z),le=f.get(fe),Be=!0;for(let Jt=Math.min(se,le)+1;Jt<Math.max(se,le);Jt++){let Mt=t[Jt];if(S(Ae,Mt.nodeType===1?1:Mt.value.length+1),Mt.nodeType===1||Mt.value.trim()){Be=!1;break}}if(!Be)continue;let Ke=O(fe,null,Ae),Ue=O(be,x,Ae);if(Ke.flat.atoms.length||Ue.flat.atoms.length)continue;let $e=Ke.flat.text,Ge=Ue.flat.text;if(S(Ae,$e.length+Ge.length+ge.length),!$e||!Q.length)continue;let et=0,Ot=Ge.length;if(se<le&&Ge.endsWith($e))Ot-=$e.length;else if(se>le&&Ge.startsWith($e))et=$e.length;else continue;for(;et<Ot&&pn.test(Ge[et]);)et++;for(;Ot>et&&pn.test(Ge[Ot-1]);)Ot--;let xt=Ge.slice(et,Ot);if(!(!xt||!(xt.startsWith(Q[0].raw)||xt.endsWith(Q[Q.length-1].raw)))){if(Ne){Ne=null;break}Ne=be,ze=et,tt=Ot,k=Q[0],$=Q[Q.length-1]}}}if(S(Ae,B.length),!Ne||!Ce.has(Ne)||!B.some(Q=>Q.target===Ne&&(Q.from<=k.from&&Q.to>=k.to&&Q.targetFrom+k.from-Q.from===ze||Q.from<=$.from&&Q.to>=$.to&&Q.targetFrom+$.to-Q.from===tt)))continue}if(Ie&&!(ae.every(Ne=>q[Ne])&&(_t||Array.from(Ce).some(Ne=>G.has(Ne))))&&!ie.some(Ne=>Ne.source===Z&&Hn.test(ge.slice(Ne.from,Ne.to))))continue;let We=!1;if(_t){S(Ae,ie.length+ae.length);for(let Ne of ie)Ne.source===Z&&(S(Ae,Ne.to-Ne.from),q.fill(1,Ne.from,Ne.to));We=!0;for(let Ne of ae)if(!q[Ne]){We=!1;break}}for(let Ne of Ce){S(Ae,B.length);let ze=B.filter(k=>k.target===Ne);ot.push({side:C,source:Z,target:Ne,runs:ze,models:u,retained:ie,conservedSource:We}),Z.nodeType===1&&Qe.add(Z),Ne.nodeType===1&&Qe.add(Ne);let tt=T.baseOf(Ne);tt?.nodeType===1&&Qe.add(tt)}}if(g.push(...ot),_e&&ot.length)for(let Z of _e)ve.add(Z);for(let Z of Qe)y.add(Z)}catch(Xe){if(Xe!==R)throw Xe}finally{if(n&&!_e&&!Ze){let Xe=_i({base:t,views:o,side:C,attempt:w,eligible:r,blocked:m,baseId:i,model:O,tokensOf:M,charge:S,exhausted:R,limit:a});Xe&&(A||=[]).push(...Xe)}if(e&&!_e&&!Ze){let Xe=ai({base:t,views:o,side:C,attempt:w,eligible:r,blocked:m,baseId:i,model:O,tokensOf:M,certificates:g,charge:S,exhausted:R,limit:a});Xe&&(b||=[]).push(...Xe)}}}}let F=g.length?new Map:null;for(let C of g){let T=F.get(C.source);T||F.set(C.source,T=[]),T.push(C)}let W=null;if(F){let C=null;for(let[T,x]of F){let z=p?.get(T)||0;if(x.length<2&&!z)continue;let D=0;for(let V of x)V.conservedSource&&(D|=1<<V.side);for(let V of x){if(V.conservedSource)continue;let Ee=1<<V.side,Me=!0;if(D&Ee)Me=!1;else if(z&Ee){Me=!1;try{Me=oa(V,C||=Kt(a),S)}catch(De){if(De!==R)throw De}}Me||(W||=new Set).add(V)}}}if(W){let C=0;for(let T of g)W.has(T)||(g[C++]=T);g.length=C;for(let[T,x]of F){C=0;for(let z of x)W.has(z)||(x[C++]=z);x.length=C,C||F.delete(T)}y.clear();for(let T of g){let{source:x,target:z,side:D}=T;x.nodeType===1&&y.add(x),z.nodeType===1&&y.add(z);let V=o[D].V.baseOf(z);V?.nodeType===1&&y.add(V)}}if(b){let C=Kt(a),T=!1;for(let x of b){let z=!1,D=F?.get(x.source);if(D&&!T)try{z=Zr(x,D,C,S)}catch(V){if(V!==R)throw V;T=!0}z||e(x)}}if(A){let C=new Set,T=Kt(a);try{for(let x of A){if(S(T,1),C.has(x.source))continue;C.add(x.source);let z=!1;for(let D of g)if(S(T,1),D.source===x.source||D.target===x.local||D.target===x.remote){z=!0;break}z||n(x)}}catch(x){if(x!==R)throw x}}for(let C of t)if(y.has(C))for(let{V:T}of o){let x=T.twin(C);x&&T.here(x)&&y.add(x)}return g.length?{blocks:y,certificates:g,certificatesBySource:F,models:u}:null}function Ki({certificates:e,scopes:n,flats:t,keys:o,limit:r=2e4*32}){let c=Symbol(),l=Kt(r),i=p=>{if(p>l.remaining)throw c;l.remaining-=p},s=n.map(p=>new Set(p)),a=new Map,h=new Map,f=(p,m)=>{let y=a.get(p);if(y||a.set(p,y=new Map),y.has(m))return y.get(m);i(p.text.length);let R=h.get(m);if(!R){i(m.nodes.length+m.atoms.length),R={nodes:new Map,atoms:new Map};for(let E of m.nodes)R.nodes.set(E.node,E);for(let E of m.atoms)R.atoms.set(E.el,E.i);h.set(m,R)}let{nodes:S,atoms:O}=R,M=new Int32Array(p.text.length).fill(-1);for(let E of p.nodes){let N=S.get(E.node);if(!(!N||E.e-E.s!==N.e-N.s)){i(E.e-E.s);for(let L=E.s;L<E.e;L++)M[L]=N.s+L-E.s}}for(let E of p.atoms){let N=O.get(E.el);N!==void 0&&(M[E.i]=N)}return y.set(m,M),M},u=(p,m,y,R,S)=>{let O=p[p.length-1];O&&O.to===m&&O.target+O.to-O.from===R&&O.kind===S?O.to=y:p.push({from:m,to:y,target:R,kind:S})},g=(p,m,y,R)=>{i((R-y)*4);let S=[],O=y,M=L=>{let j=p.text.slice(O,L);for(let F of ln(j,yn(j)))F.from=O,F.to=O+F.len,S.push(F),O+=F.len},E=0,N=p.atoms.length;for(;E<N;){i(1);let L=E+N>>>1;p.atoms[L].i<y?E=L+1:N=L}for(let L=E;L<p.atoms.length&&p.atoms[L].i<R;L++){i(1);let j=p.atoms[L];M(j.i),S.push({k:m(j),raw:Bn,len:1,from:O,to:O+1}),O++}return M(R),S},b=(p,m,y,R,S,O)=>{if(y===R||S===O)return;if(R-y===O-S){i((R-y)*4);let T=!0;for(let x=y,z=S;x<R;x++,z++){if(t[0].text[x]!==t[m].text[z]){T=!1;break}let D=t[0].atomAt.get(x),V=t[m].atomAt.get(z);if(!!D!=!!V||D&&o[0](D)!==o[m](V)){T=!1;break}}if(T){u(p,y,R,S,"retained");return}}let M=g(t[0],o[0],y,R),E=g(t[m],o[m],S,O),N=M.length+E.length+4,L=Math.min(M.length+E.length,4e3,Math.floor((Math.sqrt(N*N+l.remaining/2)-N)/2));if(L<1)throw c;i(4*(L+1)*(N+L+1));let j=Kn(M,E,L),F=0,W=0,C=()=>{let T=M[F++],x=E[W++];i(T.len),T.raw===x.raw&&u(p,T.from,T.to,x.from,"retained")};for(let T of j.hunks){for(;F<T.bs;)C();F=T.be,W+=T.toks.length}for(;F<M.length&&W<E.length;)C()},A=p=>{let m=e.filter(j=>j.side===p-1&&s[0].has(j.source)&&s[p].has(j.target));if(!m.length)return null;let y=[],R=(j,F,W)=>{if(!s[0].has(j.source)||!s[p].has(j.target))return;let C=f(F.get(j.source).flat,t[0]),T=f(F.get(j.target).flat,t[p]);i(j.to-j.from);for(let x=0;x<j.to-j.from;x++){let z=C[j.from+x],D=T[j.targetFrom+x];if(z<0||D<0)throw c;u(y,z,z+1,D,W)}},S=new Set;for(let j of m){if(!S.has(j.retained)){S.add(j.retained);for(let F of j.retained)R(F,j.models,"retained")}for(let F of j.runs)R(F,j.models,"transfer")}y.sort((j,F)=>(i(1),j.from-F.from||j.target-F.target));let O=[];for(let j of y){i(1);let F=O[O.length-1];if(F&&j.from<F.to){if(j.target-j.from!==F.target-F.from)throw c;F.to=Math.max(F.to,j.to),j.kind==="transfer"&&(F.kind="transfer")}else O.push(j)}let M=[],E=0,N=0;for(let j of O){if(j.target<N)throw c;b(M,p,E,j.from,N,j.target),M.push(j),E=j.to,N=j.target+j.to-j.from}b(M,p,E,t[0].text.length,N,t[p].text.length);let L=Dn({base:t[0],side:t[p],retained:M.filter(j=>j.kind==="retained"),transfers:M.filter(j=>j.kind==="transfer"),baseAtomKey:o[0],sideAtomKey:o[p],budget:l});if(L.status!=="ready"||!L.monotone)throw c;return L};try{let p=A(1),m=A(2);return p||m?{local:p,remote:m}:{fallback:!0}}catch(p){if(p!==c)throw p;return{fallback:!0}}}function as(e,n,t=!1){let o=-1,r=-1;for(let l=0;l<e.list.length;l++){let i=e.list[l];i.bLo<n.lo||i.bLo>n.hi||(o<0&&(o=l),r=l)}let c=[];for(let l=o;l>=0&&l<=r;l++){let i=e.list[l],s=!t&&l===o?i.inlineStart<0?i.to:i.inlineStart:i.from,a=!t&&l===r?i.inlineEnd<0?i.from:i.inlineEnd:i.to;for(let h=s;h<a;h++)c.push(e.units[h]);l<r&&c.push(e.units[i.next])}return c}var ut=e=>!!e&&e.nodeType===1,In=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function fs(e){for(let n of e)if(In.has(n.tagName))return!0;return!1}function ia(e,n,t){let o=null;for(let r of n.childNodes)if(!(!ut(r)||!t(r)||!r.isEqualNode(e))){if(o)return null;o=r}if(!o)return null;for(let r of e.parentNode.childNodes)if(r!==e&&r.isEqualNode(e))return null;return o}var $o="[id],[data-id],script,head>*";function us(e,n){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let o=So(t,e);if(o)return"merge:"+o.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?vi(t,n):null}}function Nr(e,n,t,o){let r=o.ignored,c=o.stats||Xn(),l=ri({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:c}),{unitsOf:i,meta:s}=l,a=o.baseURI,h=o.mergeTags!==null,f=us(o.mergeTags,a),u=k=>$=>{let Q=f($);return Q!==null?Q:k($)},g=u(o.identity.base),b=u(o.identity.local),A=u(o.identity.remote),p=o.authored||o.identity,m=k=>k&&k.nodeType===9?k.documentElement:k,y=m(e),R=m(n),S=m(t),O=globalThis.__hyperMorphProfile,M=O?performance.now():0,E=k=>k===bn?$o:null,N=o.scope||null,L=N?N.baseDropped:new Set,j=new Set,F=N?N.remoteDropped:new Set,W=N?N.baseIndex:mr(y,g,r,E(o.identity.base),L),C=o.localIsBase||y===R?null:mr(R,b,r,E(o.identity.local),j),T=N?N.remoteIndex:mr(S,A,r,E(o.identity.remote),F),x=k=>{let $=ut(k)&&b(k);return $&&C?.get($)===k&&!W.has($)?$:null},z=k=>{let $=ut(k)&&A(k);return $&&T.get($)===k&&!W.has($)?$:null},D=C?$r(y,R,{analyzer:l,baseIndex:W,sideIndex:C,baseId:p.base,sideId:p.local,baseKey:g,sideKey:b,baseDropped:L,sideDropped:j,stats:c}):zi(),V=$r(y,S,{analyzer:l,baseIndex:W,sideIndex:T,baseId:p.base,sideId:p.remote,baseKey:g,sideKey:A,baseDropped:L,sideDropped:F,stats:c,scope:N,comparisons:o.comparisons});if(N){if(!N.held(V))return null;for(let k of N.dropped)_r(k)}let Ee=null;function Me(k){if(!Ee){Ee=new WeakMap;let $=[y];for(;$.length;){let Q=$.pop();Q.tagName==="TEMPLATE"&&Q.content&&Ee.set(Q.content,Q);for(let be of l.childrenOf(Q))be.nodeType===1&&$.push(be)}}return Ee.get(k)||null}let De=k=>{let $=ut(k)||k.nodeType?k.parentNode:k.parent;return $&&$.nodeType===11?Me($):$};if(V.moved.size){let k=!1;for(let $ of Array.from(V.moved))!ut($)||V.identityPaired.has($)||!p.base($)||pe(V,De($))||(V.unpair($),k=!0);k&&V.rematch()}ie(),me(D,V),me(V,D);for(let k of[D,V])if(k.refused)for(let $ of k.refused)k.moved.has($)||c.ambiguousMoves++;O&&(O.alignTotal=(O.alignTotal||0)+(performance.now()-M),M=performance.now());let re=y.ownerDocument.implementation.createHTMLDocument(""),Se=new WeakMap,qe=new WeakMap,ve=[],w=[],K=new Set,ne=[],ee=new Set,Pe=new Set,_e=new Set,Ae=new WeakMap,ot=null,Qe=o.conflicts||"remote",Ze=k=>ve.push(k),Xe=k=>ve.push(k),yt=Di({roots:{base:y,local:R,remote:S},L:D,R:V,unitsOf:i,provenance:Se,policy:Qe}),dt=(k,$)=>{w.push(k),$&&yt.note(k,$)},gt=null,qt=null,$t=zt(),Ht=null,jt=J(y,D.map.get(y),V.map.get(y),!!o.localIsBase,!!o.childrenOnly);jt.tagName==="HTML"?re.replaceChild(jt,re.documentElement):re.body.appendChild(jt),gt?.drain(jt),qt?.drain(jt),O&&(O.build=(O.build||0)+(performance.now()-M));let an=o.childrenOnly?!ae(te(jt),te(S)):!he(jt,S),_t=yt.finish(jt);return{doc:re,root:jt,provenance:Se,textMappers:qe,decisions:ve,conflicts:w,recoveryLinks:_t,localDiverged:an,mergedScripts:K,segments:ne,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==bn,L:D,R:V,stats:c};function zt(){let k=new Map,$=new Set;if(o.localIsBase||!D.insertedByHash)return{partner:k,drop:$};let Q=D.insertedByHash(),be=V.insertedByHash();if(!Q.size||!be.size)return{partner:k,drop:$};let fe={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},se=pt=>{let bt=0;for(let mt=pt.parentNode;mt;mt=mt.parentNode)bt++;return bt},le=[],Be=pt=>{let bt=pt.textContent.trim();return bt.split(/\s+/).length>=3||bt.replace(/\s/g,"").length>=12},Ke=pt=>{let bt=pe(D,pt),mt=pe(V,pt);return bt&&D.reverse.get(bt.parentNode)!==pt.parentNode||mt&&V.reverse.get(mt.parentNode)!==pt.parentNode},Ue=(pt,bt,mt)=>{for(let ct of mt.parentNode.children){let Wt=ct!==mt&&pt.reverse.get(ct);if(Wt&&Ke(Wt))return!0}let It=pt.reverse.get(mt.parentNode);if(It){for(let ct of It.children)if(!pe(bt,ct)&&!r(ct))return!0}return!1},$e=new Map([[D,new Map],[V,new Map]]),Ge=(pt,bt)=>{let mt=$e.get(pt),It=mt.get(bt);if(It===void 0){It=!1;for(let ct of bt.children)if(pt.reverse.has(ct)||Ge(pt,ct)){It=!0;break}mt.set(bt,It)}return It},et=new Map;for(let pt of be.values())for(let bt of pt){let mt=z(bt);mt&&et.set(mt,bt)}for(let pt of Q.values())for(let bt of pt){let mt=x(bt),It=mt?et.get(mt):null;It&&It.tagName===bt.tagName&&!Un(bt,fe)&&!Un(It,fe)&&!o.remoteWins(bt)&&!o.remoteWins(It)&&le.push([bt,[It],se(bt),!0,!0])}for(let[pt,bt]of Q){let mt=be.get(pt);if(!mt)continue;let It=bt.length===1&&mt.length===1;for(let ct of bt)!Un(ct,fe)&&!x(ct)&&le.push([ct,mt,se(ct),It&&(Be(ct)||Ue(D,V,ct)||Ue(V,D,mt[0]))])}if(!le.length)return{partner:k,drop:$};le.sort((pt,bt)=>pt[2]-bt[2]);let Ot=new Set,xt=new Set,Jt=pt=>{for(let bt of pt.querySelectorAll("*"))Ot.add(bt)},Mt=(pt,bt)=>pt.reverse.get(bt.parentNode)||null;for(let[pt,bt,,mt,It]of le){if(Ot.has(pt)||xt.has(pt)||It&&(Ge(D,pt)||Ge(V,bt[0])))continue;let ct=Mt(D,pt),Wt=Gt=>!xt.has(Gt)&&!Ot.has(Gt)&&(It||Gt.tagName===pt.tagName&&!z(Gt)&&l.equalUnits(pt,Gt)),St=bt.find(Gt=>ct&&Mt(V,Gt)===ct&&Wt(Gt))||(mt?bt.find(Wt):null);if(!St)continue;xt.add(pt),xt.add(St);let fn=ct&&Mt(V,St)===ct;(!It||!fn||l.equalUnits(pt,St))&&(Jt(pt),Jt(St)),!fn&&(k.set(pt,St),k.set(St,pt),$.add(Qe==="local"?St:pt))}return{partner:k,drop:$}}function _(k,$,Q){if(ee.add(k),$t.drop.has(k))return null;ee.add(Q);let be=$==="local"?k:Q,fe=$==="local"?Q:k,se;return l.equalUnits(be,fe)?(se=G(be,"local",!0),Se.get(se).remote=fe):se=B(be,fe),dt({kind:"structure",el:se,detail:"both-moved",base:null,local:be,remote:fe},{unit:{b:null,l:be,r:fe}}),Ze({kind:"insert",el:se,source:"both"}),se}function ie(){if(!D.weak||!V.weak||!D.weak.size||!V.weak.size||!D.unpair)return;let k=new Map;for(let Q of D.weak){let be=pe(D,Q);ut(Q)&&ut(be)&&k.set(l.unitHash(be),Q)}let $=!1;for(let Q of Array.from(V.weak)){let be=pe(V,Q);if(!ut(Q)||!ut(be))continue;let fe=k.get(l.unitHash(be));if(!fe||fe===Q||!D.weak.has(fe)||pe(D,Q)&&pe(V,fe))continue;let se=pe(D,fe);se.tagName===be.tagName&&l.equalUnits(se,be)&&(D.unpair(fe),V.unpair(Q),$=!0)}$&&(D.rematch(),V.rematch())}function me(k,$){if(!k.weak||!k.weak.size||!$.insertedByHash)return;let Q=$.insertedByHash();if(!Q.size)return;let be=!1;for(let fe of Array.from(k.weak)){let se=pe(k,fe);if(!se)continue;let le=k===D?x(se):z(se);if(le){let Ke=(k===D?T:C)?.get(le);Ke&&Ke.tagName===se.tagName&&!$.reverse.has(Ke)&&(k.unpair(fe),be=!0);continue}let Be=Q.get(l.unitHash(se));Be&&Be.some(Ke=>Ke.tagName===se.tagName&&l.equalUnits(Ke,se))&&(k.unpair(fe),be=!0)}be&&k.rematch()}function pe(k,$){if(!$)return null;if(k.map.has($))return k.map.get($);let Q=[],be=De($);for(;be&&!k.map.has(be);be=De(be))Q.push(be);let fe=be;if(!fe||!k.identical.has(fe))return null;k.pairIdenticalChildren(fe);for(let le=Q.length-1;le>=0;le--)k.pairIdenticalChildren(Q[le]);let se=k.map.get($)||null;return se&&c.lazyTwins++,se}function ke(k,$,Q,be){if(ut(k)&&In.has(k.tagName)&&!D.identical.has(k)&&(k.previousSibling?.nodeType===3||k.nextSibling?.nodeType===3)){let Be=De(k),Ke=pe(D,k),Ue=pe(V,k);Ke&&Ue&&ze(Ke,pe(D,Be),D)&&!ze(Ue,pe(V,Be),V)&&(qt||=Hi({L:D,R:V,twinIn:pe,unitsOf:i,view:v,parentOf:De,ignored:r,remoteWins:o.remoteWins,eligible:$e=>ut($e)&&In.has($e.tagName),build:J,out:re,policy:Qe,provenance:Se,textMappers:qe,segments:ne,conflicts:w,conflict:dt,decisions:ve}),qt.ensureOwner(k))}if($===null)return null;if(be!==void 0)return gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(k,$,Q,!!be),be&&(gt.produced(k,be),Pe.add(k)),be;if(Pe.has(k)||_e.has(k))return dt({kind:"structure",el:null,detail:"both-moved",base:k},{subject:k}),Pe.has(k)?null:G(Q,$);gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(k,$,Q,!0);let fe=pe(D,k),se=pe(V,k);(!fe||!se)&&dt({kind:"structure",el:null,detail:"move-beats-delete",base:k},{subject:k,deleted:fe?"remote":"local"});let le=J(k,fe,se,!1);return($==="local"?Ze:Xe)({kind:"move",el:le,source:$}),le}function v(k,$,Q,be){return be||!$||$===Q?{el:Q,asBase:!0,twin:fe=>fe,baseOf:fe=>fe,units:i(Q),here:()=>!0,parentOfTwin:()=>Q}:{el:$,asBase:!1,twin:fe=>pe(k,fe),baseOf:fe=>k.reverse.get(fe),units:i($),here:fe=>ut(fe)?fe.parentNode===$||$.tagName==="TEMPLATE"&&fe.parentNode===$.content:fe.parent===$||$.tagName==="TEMPLATE"&&fe.parent===$.content}}function P(k,$,Q){return!$||Q&&Q.identical.has(k)?!1:ut(k)?!l.equalUnits(k,$)||!Y(k,$,Q):k.value!==$.value}function Y(k,$,Q){if(!Q||k===$)return!0;let be=[[k,$]];for(;be.length;){let[fe,se]=be.pop(),le=i(fe),Be=i(se);for(let Ke=0;Ke<le.length&&Ke<Be.length;Ke++){let Ue=le[Ke],$e=Be[Ke];if(!ut(Ue)||!ut($e))continue;let Ge=Q.map.get(Ue);if(Ge!==void 0&&Ge!==$e)return!1;let et=Q.reverse.get($e);if(et!==void 0&&et!==Ue)return!1;be.push([Ue,$e])}}return!0}function J(k,$,Q,be,fe=!1){let se=be||(Q?o.remoteWins(Q):o.remoteWins(k)),le=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(k.namespaceURI,k.tagName):re.createElement(k.tagName),Be={base:k,local:$||null,remote:Q||null};if(Se.set(le,Be),se&&!be&&$&&P(k,$,D)&&(!Q||!l.equalUnits($,Q))&&dt({kind:"structure",el:le,detail:"remote-wins",base:k,local:$,remote:Q||null},{subject:k}),ee.add(k),Pe.add(k),$&&ee.add($),Q&&ee.add(Q),o.skipUnchanged&&!fe&&(o.localIsBase||D.identical.has(k))&&Q&&V.identical.has(k)&&!o.remoteWins(k)){Be.unchanged=!0;for(let Ue of k.attributes)Ue.namespaceURI?le.setAttributeNS(Ue.namespaceURI,Ue.name,Ue.value):le.setAttribute(Ue.name,Ue.value);return gt?.produced(k,le),le}_e.add(k),fe||Z(k,se?k:$,Q,le);let Ke=k.tagName;if(hn(k))je(k,se?k:$,Q,le);else if(Ke==="TEXTAREA")le.textContent=oe(k.textContent,(se?k:$)?(se?k:$).textContent:k.textContent,Q?Q.textContent:k.textContent,le,"text");else if(!qt?.render(k,le)){let Ue=ue(k,$,Q,se,le),$e=Ke==="TEMPLATE"&&le.content?le.content:le;for(let Ge of Ue)$e.appendChild(Ge)}return _e.delete(k),gt?.produced(k,le),le}function oe(k,$,Q,be,fe){if($===Q)return $;if($===k)return Q!==k&&Xe({kind:fe,node:be,source:"remote"}),Q;if(Q===k)return Ze({kind:fe,node:be,source:"local"}),$;let se=Qe==="local"?$:Q;return dt({kind:fe,node:be,base:k,local:$,remote:Q,resolved:se},{site:"whole",el:be}),ve.push({kind:fe,node:be,source:"both"}),se}function je(k,$,Q,be){let fe=k.textContent,se=$?$.textContent:fe,le=Q?Q.textContent:fe,Be=h?So(k,o.mergeTags,!0):null;if(Be&&se!==le){let Ke=Q&&Q.getAttribute("merge-key")||k.getAttribute("merge-key"),{text:Ue,warnings:$e}=is(o.localIsBase?void 0:fe,se,le,{parse:Be.recognizer.parse,keyCandidates:Ke?Ke.split(/[\s,]+/).filter(Boolean):void 0});for(let Ge of $e)console.warn(`[hyper-morph] merge "${Be.raw}": ${Ge}`);be.textContent=Ue,K.add(be),Ue!==le?Ze({kind:"text",node:be,source:Ue===se?"local":"both"}):Ue!==fe&&Xe({kind:"text",node:be,source:"remote"});return}be.textContent=oe(fe,se,le,be,"text")}function Z(k,$,Q,be){let fe=new Map;for(let se of[k,$,Q])if(se)for(let le of se.attributes)o.ignoreAttribute(se,le.name)||fe.set(le.name,le);for(let[se,le]of fe){let Be=k?k.getAttribute(se):null,Ke=$?$.getAttribute(se):Be,Ue=Q?Q.getAttribute(se):Be,$e;Ke===Ue?$e=Ke:Ke===Be?($e=Ue,Xe({kind:"attr",el:be,name:se,source:"remote"})):Ue===Be?($e=Ke,Ze({kind:"attr",el:be,name:se,source:"local"})):($e=Oe(se,Be,Ke,Ue),$e===void 0&&($e=Qe==="local"?Ke:Ue,dt({kind:"attr",el:be,name:se,base:Be,local:Ke,remote:Ue,resolved:$e},{el:be,sample:le})),ve.push({kind:"attr",el:be,name:se,source:"both"})),$e!=null&&(le.namespaceURI?be.setAttributeNS(le.namespaceURI,le.name,$e):be.setAttribute(se,$e))}}function Oe(k,$,Q,be){if(k==="class"){let fe=Ue=>new Set((Ue||"").split(/\s+/).filter(Boolean)),se=fe($),le=fe(Q),Be=fe(be),Ke=new Set;for(let Ue of new Set([...se,...le,...Be])){let $e=se.has(Ue),Ge=le.has(Ue),et=Be.has(Ue);(Ge===et?Ge:Ge===$e?et:Ge)&&Ke.add(Ue)}return[...Ke].join(" ")}if(k==="style"){let fe=$e=>{let Ge=new Map;if(!$e)return Ge;let et=0,Ot=null,xt="",Jt=()=>{let Mt=xt.indexOf(":");Mt>0&&Ge.set(xt.slice(0,Mt).trim(),xt.slice(Mt+1).trim()),xt=""};for(let Mt of $e){if(Ot){xt+=Mt,Mt===Ot&&(Ot=null);continue}if(Mt==='"'||Mt==="'"){Ot=Mt,xt+=Mt;continue}if(Mt==="("?et++:Mt===")"&&et--,Mt===";"&&et===0){Jt();continue}xt+=Mt}return xt.trim()&&Jt(),Ge},se=fe($),le=fe(Q),Be=fe(be),Ke=new Map,Ue=!1;for(let $e of new Set([...se.keys(),...le.keys(),...Be.keys()])){let Ge=se.get($e)??null,et=le.get($e)??null,Ot=Be.get($e)??null,xt;et===Ot?xt=et:et===Ge?xt=Ot:Ot===Ge?xt=et:(xt=Qe==="local"?et:Ot,Ue=!0),xt!=null&&Ke.set($e,xt)}return Ue?void 0:[...Ke].map(([$e,Ge])=>`${$e}: ${Ge}`).join("; ")}}function He(k,$,Q,be){let fe=k.value,se=be?fe:$?$.value:"",le=Q?Q.value:"";ee.add(k),$&&ee.add($),Q&&ee.add(Q);let Be=Ho(fe,se,le,Qe),Ke=Be.text===""?null:re.createTextNode(Be.text);Ke&&(Se.set(Ke,{base:k.nodes,local:$?$.nodes:null,remote:Q?Q.nodes:null}),qe.set(Ke,Be.mapLocalOffset)),se!==fe&&le!==fe?ve.push({kind:"text",node:Ke,source:"both"}):se!==fe?Ze({kind:"text",node:Ke,source:"local"}):le!==fe&&Xe({kind:"text",node:Ke,source:"remote"});for(let Ue of Be.conflicts)dt({kind:"text",node:Ke,base:fe.slice(Ue.bs,Ue.be),local:Ue.local,remote:Ue.remote,resolved:Ue.resolved},{site:"run",bRun:k,lRun:$,rRun:Q,node:Ke,c:Ue});return Ke}function Ie(k,$){return ro(k,$).every(Q=>Q.bs===Q.be)}function ge(k,$){let Q=k?k.value:"",be=$?$.value:"",fe;if(Q===be||!be?fe=Q:Q?Ie(Q,be)?fe=be:Ie(be,Q)?fe=Q:(fe=Qe==="local"?Q:Qe==="both"?Q+be:be,dt({kind:"structure",el:null,detail:"insert-collision",local:Q,remote:be,resolved:fe},{unit:{b:null,l:k,r:$},localLost:Qe==="remote"})):fe=be,k&&ee.add(k),$&&ee.add($),fe==="")return null;let se=re.createTextNode(fe);return Se.set(se,{base:null,local:k?k.nodes:null,remote:$?$.nodes:null}),Q?Ze({kind:"insert",el:se,source:be&&Q===be?"both":"local"}):Xe({kind:"insert",el:se,source:"remote"}),se}function B(k,$){let Q={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},be=Be=>i(Be).every(Ke=>ut(Ke)?Un(Ke,Q):Ke.kind==="text"),fe=null;if(be(k)&&be($)){let Be=k.textContent,Ke=$.textContent;Be===Ke||Ie(Ke,Be)?fe=$:Ie(Be,Ke)&&(fe=k)}if(!fe){let Be=Qe==="local",Ke=G(Be?k:$,Be?"local":"remote",!0),Ue=Se.get(Ke);return Be?Ue.remote=$:Ue.local=k,dt({kind:"structure",el:Ke,detail:"insert-collision",local:k,remote:$,resolved:Be?k:$},{unit:{b:null,l:k,r:$},localLost:!Be}),Ke}let se=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(k.namespaceURI,k.tagName):re.createElement(k.tagName);Z(null,k,$,se),Se.set(se,{base:null,local:k,remote:$}),ee.add(k),ee.add($);let le=so({base:Array.from(fe.childNodes),local:Array.from(k.childNodes),remote:Array.from($.childNodes),out:re,policy:Qe,idOf:{local:b,remote:A},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:Se,textMappers:qe,conflicts:w,conflict:dt,scope:{base:null,local:k,remote:$,units:[],at:0},synthetic:!0,decisions:ve,node:se});ne.push(...le.segments);for(let Be of le.nodes)se.appendChild(Be);return se}function G(k,$,Q=!1){if(!Q&&ut(k)){let le=$t.partner.get(k);if(le)return _(k,$,le)}if(!ut(k)){if(k.value==="")return null;let le=k.kind==="comment"?re.createComment(k.value):re.createTextNode(k.value);return Se.set(le,{base:null,local:$==="local"?k.nodes:null,remote:$==="remote"?k.nodes:null}),ee.add(k),le}let be=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(k.namespaceURI,k.tagName):re.createElement(k.tagName);for(let le of k.attributes)le.namespaceURI?be.setAttributeNS(le.namespaceURI,le.name,le.value):be.setAttribute(le.name,le.value);Se.set(be,{base:null,local:$==="local"?k:null,remote:$==="remote"?k:null}),ee.add(k);let fe=k.tagName==="TEMPLATE"&&be.content?be.content:be,se=$==="local"?D:V;for(let le of i(k)){let Be=ut(le)?se.reverse.get(le):null;if(Be&&ke(Be,null,null),Be&&Pe.has(Be)){dt({kind:"structure",el:null,detail:"both-moved",base:Be},{subject:Be});continue}if(Be&&!_e.has(Be)){let Ue=pe(D,Be)||null,$e=pe(V,Be)||null;if(Ue||$e){gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(Be,$,le,!0);let Ge=J(Be,Ue,$e,!1);$==="local"?Ze({kind:"move",el:Ge,source:"local"}):Xe({kind:"move",el:Ge,source:"remote"}),fe.appendChild(Ge);continue}}let Ke=G(le,$);Ke&&fe.appendChild(Ke)}if(!Q&&$t.drop.size&&k.tagName==="DIV"&&!fe.firstChild&&!k.attributes.length&&!($==="local"?b(k):A(k))&&!se.reverse.has(k)&&!r(k)&&!o.remoteWins(k)){let le=k.firstChild;if(le&&le===k.lastChild&&ut(le)&&($t.drop.has(le)||Ht?.has(le)))return(Ht||=new WeakSet).add(k),null}return be}function ue(k,$,Q,be,fe){$&&D.identical.has(k)&&D.pairIdenticalChildren(k),Q&&V.identical.has(k)&&V.pairIdenticalChildren(k);let se=v(D,$,k,be),le=v(V,Q,k,!1),Be=i(k),Ke=new Set(Be),Ue=new Map;for(let ye=0;ye<Be.length;ye++)Ue.set(Be[ye],ye);let $e=[],Ge=new Set,et=new Map,Ot=new Set,xt=new Set,Jt=[],Mt=null;if(!se.asBase&&!le.asBase&&!D.identical.has(k)&&!V.identical.has(k))for(let ye of Be){if(!ut(ye)||!In.has(ye.tagName))continue;let Je=se.twin(ye),Ye=le.twin(ye);Je&&Ye&&(!se.here(Je)||!le.here(Ye))&&ke(ye,null,null)}Ir();let pt=ye=>{let Je=[];for(let Ye of ye.units){if(xt.has(Ye))continue;let kt=ye.baseOf(Ye);kt&&Ke.has(kt)&&Je.push(kt)}return Je},bt=ye=>pt(ye).map(Je=>Ue.get(Je)),mt=ye=>ye.every((Je,Ye)=>Ye===0||Je>=ye[Ye-1]),It=!se.asBase&&!mt(bt(se)),ct=!le.asBase&&!mt(bt(le));It&&ct&&dt({kind:"structure",el:fe,detail:"both-reordered",base:k},{subject:k,lKept:pt(se),rKept:pt(le)});let Wt=ct||!It?{V:le,A:V,side:"remote",other:se,otherA:D,otherSide:"local"}:{V:se,A:D,side:"local",other:le,otherA:V,otherSide:"remote"};It?Ze({kind:"move",el:null,source:ct?"both":"local",base:k}):ct&&Xe({kind:"move",el:null,source:"remote",base:k});let St=se.asBase?[]:se.units.filter(ye=>!se.baseOf(ye)&&!xt.has(ye)&&!$t.partner.has(ye)),fn=le.asBase?[]:le.units.filter(ye=>!le.baseOf(ye)&&!xt.has(ye)&&!$t.partner.has(ye)),Gt=new Map;if(St.length&&fn.length){let ye=new Map,Je=new Map;for(let rt of fn){if(ut(rt)){let Lt=A(rt);Lt&&ye.set(Lt,rt)}let At=l.unitHash(rt);Je.has(At)||Je.set(At,[]),Je.get(At).push(rt)}let Ye=(rt,At)=>{let Lt=rt.units.indexOf(At);for(let at=Lt-1;at>=0;at--){let Nt=rt.baseOf(rt.units[at]);if(Nt)return Nt}return"start"},kt=new Map,Dt=new Map;for(let rt of fn){let At=Ye(le,rt);ut(rt)?(Dt.has(At)||Dt.set(At,[]),Dt.get(At).push(rt)):rt.kind==="text"&&!kt.has(At)&&kt.set(At,rt)}for(let rt of St){let At=null;if(ut(rt)){let at=b(rt);at&&ye.has(at)&&!Gt.has(ye.get(at))&&(At=ye.get(at))}else if(rt.kind==="text"){let at=kt.get(Ye(se,rt));at&&!Gt.has(at)&&(At=at)}let Lt=!!x(rt);if(!At&&!Lt){let at=Je.get(l.unitHash(rt));at&&(At=at.find(Nt=>!Gt.has(Nt)&&ut(Nt)===ut(rt)&&(ut(Nt)?Nt.tagName===rt.tagName&&!z(Nt):Nt.kind===rt.kind)&&l.equalUnits(rt,Nt))||null)}if(!At&&ut(rt)&&!Lt){let at=p.local(rt),Nt=(Dt.get(Ye(se,rt))||[]).filter(sn=>{let un=p.remote(sn);return!Gt.has(sn)&&sn.tagName===rt.tagName&&!z(sn)&&!(at&&un&&at!==un)&&l.similar(rt,sn)});Nt.length===1&&(At=Nt[0])}At&&(Gt.set(At,rt),Gt.set(rt,At))}}let Fn=ye=>{if(qt?.consumes(ye))return null;if(ee.has(ye)||gt?.has(ye))return et.get(ye)||null;let Je=se.twin(ye),Ye=le.twin(ye),kt=Je&&!se.asBase&&!se.here(Je),Dt=Ye&&!le.asBase&&!le.here(Ye);if(kt||Dt){if((!Je||!Ye)&&dt({kind:"structure",el:null,detail:"move-beats-delete",base:ye},{subject:ye,deleted:Je?"remote":"local"}),!Ne(ye))return ut(ye)?(gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),kt&&gt.plan(ye,"local",Je),Dt&&gt.plan(ye,"remote",Ye)):ee.add(ye),null;dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye})}if(Je&&!Ye&&!se.asBase&&!le.asBase&&ut(ye)&&In.has(ye.tagName)&&!o.remoteWins(ye)&&!o.remoteWins(Je)&&P(ye,Je,D)&&ia(ye,te(le.el),r)){let Nt={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},sn=un=>ut(un)?Un(un,Nt):un.kind==="text";if(i(ye).every(sn)&&i(Je).every(sn)){let un=so({base:[ye],local:[Je],remote:[],blocks:new Set([ye,Je]),out:re,policy:Qe,L:D,R:V,idOf:{base:g,local:b,remote:A},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(mn,kn,Ln)=>J(mn,kn,Ln,!1),cloneUnit:G,mergeAttrs:Z,atomKey:l.exactUnitKey,moveIn:ke,moveBuilt:ke,movePlanned:ke,provenance:Se,textMappers:qe,conflicts:w,conflict:dt,scope:{base:k,local:se.el,remote:le.el,units:Be,at:Ue.get(ye)},decisions:ve,node:fe});ne.push(...un.segments),ee.add(ye),ee.add(Je);let xn=re.createDocumentFragment();for(let mn of un.nodes)xn.appendChild(mn);return et.set(ye,xn),et.set(Je,xn),xn}}if(!Je&&!Ye)return ee.add(ye),Xe({kind:"remove",source:"both",base:ye}),null;if(!Je&&!P(ye,Ye,V))return ee.add(ye),Ze({kind:"remove",source:"local",base:ye}),null;if(!Ye&&!P(ye,Je,D))return ee.add(ye),Xe({kind:"remove",source:"remote",base:ye}),null;let rt=!Je||!Ye,At=se.asBase?pe(D,ye)||null:Je,Lt=le.asBase&&ut(ye)&&(V.identityPaired.has(ye)||!p.base(ye))&&pe(V,ye)||Ye,at;return ut(ye)?at=J(ye,At,Lt,se.asBase):ye.kind==="comment"?at=Le(ye,At,Ye,se.asBase):at=He(ye,At,Ye,se.asBase),ee.add(ye),at&&(et.set(ye,at),Je&&et.set(Je,at),Ye&&et.set(Ye,at),rt&&(dt({kind:"structure",el:at,detail:"edit-beats-delete",base:ye},{subject:ye,deleted:Je?"remote":"local"}),Je?Ze({kind:"insert",el:at,source:"local"}):Xe({kind:"insert",el:at,source:"remote"}))),at},Rn=(ye,Je,Ye,kt)=>{if(qt?.consumes(ye))return null;if(ee.has(ye))return et.get(ye)||null;let Dt=Je.baseOf(ye);if(Dt&&Ke.has(Dt))return xt.has(Dt)&&!xt.has(ye)?cr(Dt,ye,kt):Fn(Dt);if(Dt)return $n(Dt,ye,kt);let rt=Gt.get(ye);if(rt){let Lt=kt==="local"?ye:rt,at=kt==="local"?rt:ye,Nt;return ut(Lt)?l.equalUnits(Lt,at)?(Nt=G(Lt,"local"),Nt&&(Se.get(Nt).remote=at)):Nt=B(Lt,at):Nt=ge(Lt,at),ee.add(Lt),ee.add(at),Nt&&(et.set(Lt,Nt),et.set(at,Nt),ut(Lt)&&Ze({kind:"insert",el:Nt,source:"both"})),Nt}let At=G(ye,kt);return At&&(et.set(ye,At),kt==="local"?Ze({kind:"insert",el:At,source:"local"}):Xe({kind:"insert",el:At,source:"remote"})),At},cr=(ye,Je,Ye)=>{let kt;return ut(ye)?(kt=ke(ye,Ye,Je),kt&&ee.add(Je)):(kt=G(Je,Ye),ee.add(Je),kt&&(Ye==="local"?Ze:Xe)({kind:"insert",el:kt,source:Ye})),kt&&et.set(Je,kt),kt},$n=(ye,Je,Ye)=>{ke(ye,null,null);let Dt=pe(Ye==="local"?V:D,ye),rt=Je,At=Dt?ze(Dt,Ye==="local"?Q:$,Ye==="local"?V:D):!1,Lt=Dt&&!At&&!tt(ye,Dt);if(Lt&&Ye===Wt.otherSide)return dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye}),null;if(Lt&&dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye}),Dt||dt({kind:"structure",el:null,detail:"move-beats-delete",base:ye},{subject:ye,deleted:Ye==="local"?"remote":"local"}),_e.has(ye)){dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye});let Nt=G(rt,Ye);return Nt&&et.set(Je,Nt),Nt}ut(ye)&&(gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(ye,Ye,rt,!0));let at=ut(ye)?J(ye,Ye==="local"?rt:pe(D,ye)||null,Ye==="remote"?rt:pe(V,ye)||null,!1):null;return at&&(et.set(ye,at),et.set(Je,at),Dt&&et.set(Dt,at),Ye==="local"?Ze({kind:"move",el:at,source:"local"}):Xe({kind:"move",el:at,source:"remote"})),at};for(let ye of Wt.V.units){if(xt.has(ye)){if(Mt?.has(ye)){for(let kt of Mt.get(ye))Ge.has(kt)||($e.push(kt),Ge.add(kt));continue}let Ye=et.get(ye);Ge.has(Ye)||($e.push(Ye),Ge.add(Ye));continue}if(ee.has(ye)&&!(et.get(ye)&&Ge.has(et.get(ye)))){let Ye=Wt.V.baseOf(ye);Ye&&!Ke.has(Ye)&&dt({kind:"structure",el:null,detail:"both-moved",base:Ye},{subject:Ye});continue}let Je=Rn(ye,Wt.V,Wt.A,Wt.side);Je&&!Ge.has(Je)&&($e.push(Je),Ge.add(Je),!Wt.V.baseOf(ye)&&!Gt.has(ye)&&!xt.has(ye)&&Ot.add(Je))}for(let ye of Jt)Ge.has(ye.frag)||($e.splice(ye.previous&&Ge.has(ye.previous)?$e.indexOf(ye.previous)+1:jo(ye.at),0,ye.frag),Ge.add(ye.frag));if(!Wt.other.asBase){let ye=Wt.other,Je=Wt.otherSide,Ye=Wt.otherA,kt=null,Dt=0,rt=null;for(let At of ye.units){let Lt=et.get(At);if(Lt&&Ge.has(Lt)){kt=Lt,rt=null;continue}if(ee.has(At)){let sn=ye.baseOf(At);sn&&!Ke.has(sn)&&dt({kind:"structure",el:null,detail:"both-moved",base:sn},{subject:sn});continue}let at=Rn(At,ye,Ye,Je);if(!at)continue;let Nt;if(rt)Nt=$e.indexOf(rt)+1;else if(kt){if(Nt=$e.indexOf(kt)+1,Je==="remote")for(;Nt<$e.length&&Ot.has($e[Nt]);)Nt++}else Nt=Dt++;$e.splice(Nt,0,at),Ge.add(at),rt=at}}for(let ye=0;ye<Be.length;ye++){let Je=Be[ye];if(ee.has(Je))continue;let Ye=Fn(Je);Ye&&$e.splice(jo(ye),0,Ye)}return $e;function jo(ye){for(let Je=ye-1;Je>=0;Je--){let Ye=et.get(Be[Je]);if(Ye){let kt=$e.indexOf(Ye);if(kt>=0)return kt+1}}return 0}function Ir(){if((se.asBase||D.identical.has(k))&&(le.asBase||V.identical.has(k)))return;let ye={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},Je=it=>ut(it)?Un(it,ye):it.kind==="text";if(!se.asBase&&!le.asBase)for(let it of Be){if(!ut(it)||!In.has(it.tagName))continue;let nt=se.twin(it),Rt=le.twin(it);if(!nt&&Rt||nt&&!Rt){let st=Fi({base:Be,views:[{V:se,A:D,idOf:p.local},{V:le,A:V,idOf:p.remote}],eligible:Et=>ut(Et)&&In.has(Et.tagName)&&!r(Et)&&!o.remoteWins(Et),baseId:p.base,ignored:r,remoteWins:o.remoteWins,atomKey:l.exactUnitKey});st&&(se=st[0],le=st[1]);break}}let Ye=!se.asBase&&!le.asBase&&Be.length>=2&&In.has(Be[0].tagName)&&se.units.length===Be.length&&le.units.length===Be.length?Ti({base:Be,local:se.units,remote:le.units,localTwin:se.twin,remoteTwin:le.twin,eligible:it=>ut(it)&&In.has(it.tagName)&&!r(it)&&!o.remoteWins(it),nodes:{base:Array.from(te(k).childNodes),local:Array.from(te(se.el).childNodes),remote:Array.from(te(le.el).childNodes)}}):null,kt=null,Dt=null;if(!Ye&&!se.asBase&&!le.asBase&&(fs(Be)||fs(se.units)||fs(le.units))){let it={ignored:r,remoteWins:()=>!1},nt=st=>Je(st)||ut(st)&&o.remoteWins(st)&&wn.has(st.tagName)&&Un(st,it),Rt=st=>ut(st)?In.has(st.tagName)&&!r(st)&&!o.remoteWins(st)&&i(st).every(nt):st.kind==="text";kt=$i({onUncertainOwner:st=>{let Et=o.identity.local(st.local);Et&&Et===o.identity.remote(st.remote)||(Dt||=[]).push(st)},onUncertainSource:st=>{ot||(ot=new Map);let Et=ot.get(st.source);Et||ot.set(st.source,Et=[]);for(let Yt of Et)if(Yt.side===st.side&&Yt.from===st.from&&Yt.to===st.to)return;Et.push(st)},base:Be,views:[{V:se,A:D,idOf:p.local},{V:le,A:V,idOf:p.remote}],eligible:Rt,ignored:r,remoteWins:o.remoteWins,baseId:p.base,atomKey:l.exactUnitKey})}if(Dt){Mt||=new Map;for(let it of Dt){let{source:nt,local:Rt,remote:st}=it,Et={map:new Map,reverse:new Map,identical:new Set},Yt=so({base:[nt],local:[Rt],remote:[st],out:re,policy:"both",L:Et,R:Et,ignored:r,remoteWins:o.remoteWins,atomKey:l.exactUnitKey,cloneUnit:G,provenance:Se,textMappers:qe,conflicts:w,decisions:ve,conflict:(Ct,tn)=>dt(Ct,{...tn,policy:"both"}),scope:{base:k,local:se.el,remote:le.el,units:Be,at:Ue.get(nt)},node:fe});ne.push(...Yt.segments);for(let Ct of[nt,Rt,st])ee.add(Ct),xt.add(Ct),Mt.set(Ct,Yt.nodes),et.set(Ct,Yt.nodes[Yt.nodes.length-1]);for(let Ct=0;Ct<Yt.nodes.length;Ct++)Jt.push({frag:Yt.nodes[Ct],at:Ue.get(nt),previous:Ct?Yt.nodes[Ct-1]:null})}}let rt=Ye?Ye.blocks:null;if(kt){rt=new Set;for(let it of kt.blocks)rt.add(it)}let At=it=>!qt?.consumes(it)&&(rt&&rt.has(it)||Je(it)),Lt=Be.map(At);if(!Lt.includes(!0))return;let at=it=>{let nt=it.units,Rt=new Map;for(let Vt=0;Vt<nt.length;Vt++)Rt.set(nt[Vt],Vt);let st=[],Et=-1;for(let Vt=0;Vt<Be.length;Vt++){if(Lt[Vt])continue;let vt=it.twin(Be[Vt]),Tt=vt?Rt.get(vt):void 0;Tt===void 0||Tt<=Et||At(vt)||(st.push([Vt,Tt]),Et=Tt)}let Yt=[],Ct=-1,tn=-1;for(let Vt=0;Vt<=st.length;Vt++){let[vt,Tt]=Vt<st.length?st[Vt]:[Be.length,nt.length],Bt={bLo:-1,bHi:-1,from:tn+1,to:Tt,inlineStart:-1,inlineEnd:-1,next:Tt};for(let Qt=Ct+1;Qt<vt;Qt++)Lt[Qt]&&(Bt.bLo<0&&(Bt.bLo=Qt),Bt.bHi=Qt);for(let Qt=tn+1;Qt<Tt;Qt++){let zn=nt[Qt];At(zn)&&(Bt.inlineStart<0&&(Bt.inlineStart=Qt),Bt.inlineEnd=Qt+1)}Yt.push(Bt),Ct=vt,tn=Tt}return{units:nt,list:Yt}},Nt=at(se),sn=at(le),un=[];for(let it of[Nt,sn])for(let nt of it.list)nt.bLo>=0&&un.push([nt.bLo,nt.bHi]);un.sort((it,nt)=>it[0]-nt[0]);let xn=[];for(let[it,nt]of un){let Rt=xn[xn.length-1];Rt&&it<=Rt.hi?Rt.hi=Math.max(Rt.hi,nt):xn.push({lo:it,hi:nt})}let mn=(it,nt)=>it.length===nt.length&&it.every((Rt,st)=>l.equalUnits(Rt,nt[st])),kn=it=>!ut(it)&&it.kind==="comment",Ln=it=>{if(!it.length)return[];let nt=(Ct,tn)=>ut(Ct)?Ct:Ct.nodes[tn?Ct.nodes.length-1:0],Rt=nt(it[0]),st=nt(it[it.length-1],!0),Et=Ct=>Ct&&ut(Ct)&&r(Ct);for(;Et(Rt.previousSibling);)Rt=Rt.previousSibling;for(;Et(st.nextSibling);)st=st.nextSibling;let Yt=[];for(let Ct=Rt;Ct&&(Yt.push(Ct),Ct!==st);Ct=Ct.nextSibling);return Yt},ar=it=>it.some(nt=>ut(nt)&&r(nt));for(let it of xn){let nt=Be.slice(it.lo,it.hi+1),Rt=null;if(kt)for(let vt of nt){let Tt=kt.certificatesBySource.get(vt);Tt&&(Rt||=[]).push(...Tt)}let st=se.asBase?null:as(Nt,it),Et=le.asBase?null:as(sn,it);if(Rt){let vt=[new Set(st||nt),new Set(Et||nt)],Tt=Rt.some(Bt=>!vt[Bt.side].has(Bt.target));for(let Bt of nt)if(rt.has(Bt))for(let[Qt,zn]of[[0,se],[1,le]]){let Gn=zn.twin(Bt);Gn&&zn.here(Gn)&&!vt[Qt].has(Gn)&&(Tt=!0)}if(Tt)continue}if(nt.some(kn)||st&&st.some(kn)||Et&&Et.some(kn))continue;let Yt=Ln(st||nt),Ct=Ln(Et||nt);if((!st||mn(nt,st))&&(!Et||mn(nt,Et))&&!(st&&ar(Yt)))continue;let tn=so({base:Ln(nt),sourceRetentions:ot?.get(k),local:Yt,remote:Ct,out:re,policy:Qe,blocks:rt,scopeUnits:Rt?[nt,st||nt,Et||nt]:null,certifiedOrigins:Rt?(vt,Tt,Bt,Qt,zn,Gn)=>Ki({certificates:Rt,scopes:[nt,st||nt,Et||nt],flats:[vt,Tt,Bt],keys:[Qt,zn,Gn]}):null,prepared:Ye?Ye.prepared:null,nativeTransfers:Ye,L:st?D:qi(D,k),R:Et?V:qi(V,k),idOf:{base:g,local:b,remote:A},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(vt,Tt,Bt)=>J(vt,Tt,Bt,!1),cloneUnit:G,mergeAttrs:Z,atomKey:l.exactUnitKey,moveIn:ke,moveBuilt:ke,movePlanned:ke,provenance:Se,textMappers:qe,conflicts:w,conflict:dt,scope:{base:k,local:se.asBase?null:se.el,remote:le.asBase?null:le.el,units:Be,at:it.lo},decisions:ve,node:fe});if(!tn){if(Rt){let vt=Ai({certificates:Rt,scopes:[nt,st||nt,Et||nt],views:[{V:se,A:D,idOf:p.local},{V:le,A:V,idOf:p.remote}],eligible:Tt=>ut(Tt)&&In.has(Tt.tagName)&&!r(Tt)&&!o.remoteWins(Tt),baseId:p.base});for(let Tt of vt.records){ot||=new Map;let Bt=ot.get(Tt.source);Bt||ot.set(Tt.source,Bt=[]),Bt.push(Tt)}}continue}if(ne.push(...tn.segments),Ye){let vt=new Map;for(let Tt of tn.nodes){let Bt=Se.get(Tt)?.base;if(!Bt||vt.has(Bt))throw new Error("Invalid native transfer owner output");vt.set(Bt,Tt)}if(vt.size!==Ye.owners.length)throw new Error("Incomplete native transfer owner output");for(let Tt of Ye.owners){let Bt=vt.get(Tt.base);if(!Bt)throw new Error("Missing native transfer owner output");for(let Qt of[Tt.base,Tt.local,Tt.remote])ee.add(Qt),xt.add(Qt),et.set(Qt,Bt);Jt.push({frag:Bt,at:Ue.get(Tt.base)})}continue}if(tn.unitOutputs){Mt||=new Map;for(let vt of[...nt,...st||[],...Et||[]]){let Tt=tn.unitOutputs.get(vt)||[];ee.add(vt),xt.add(vt),Mt.set(vt,Tt),Tt.length&&et.set(vt,Tt[Tt.length-1])}for(let vt=0;vt<tn.nodes.length;vt++)Jt.push({frag:tn.nodes[vt],at:it.lo,previous:vt>0?tn.nodes[vt-1]:null});continue}let Vt=re.createDocumentFragment();for(let vt of tn.nodes)Vt.appendChild(vt);for(let vt of[...nt,...st||[],...Et||[]])ee.add(vt),xt.add(vt),et.set(vt,Vt);Jt.push({frag:Vt,at:it.lo})}}}function he(k,$){let Q=Se.get(k);return Q&&Q.unchanged?!Q.remote||Q.remote===$?!0:ce(Q.remote,$):k.tagName!==$.tagName||!q(k,$)?!1:ae(te(k),te($))}function ce(k,$){return k===$?!0:k.tagName!==$.tagName||k.namespaceURI!==$.namespaceURI||!q(k,$)?!1:xe(te(k),te($))}function xe(k,$){let Q=Ce(k,r),be=Ce($,r);if(Q.length!==be.length)return!1;for(let fe=0;fe<Q.length;fe++){let se=Q[fe],le=be[fe];if(typeof se=="string"||typeof le=="string"){if(se!==le)return!1}else{if(se.nodeType!==le.nodeType)return!1;if(se.nodeType===1){if(!ce(se,le))return!1}else if(se.nodeValue!==le.nodeValue)return!1}}return!0}function te(k){return k.tagName==="TEMPLATE"&&k.content?k.content:k}function q(k,$){let Q=0;for(let be of k.attributes)if(!o.ignoreAttribute(k,be.name)&&(Q++,$.getAttribute(be.name)!==be.value))return!1;for(let be of $.attributes)o.ignoreAttribute($,be.name)||Q--;return Q===0}function ae(k,$){let Q=Ce(k,fe=>{let se=Se.get(fe);return!!(se&&se.pinned)}),be=Ce($,r);if(Q.length!==be.length)return!1;for(let fe=0;fe<Q.length;fe++){let se=Q[fe],le=be[fe];if(typeof se=="string"||typeof le=="string"){if(se!==le)return!1}else{if(se.nodeType!==le.nodeType)return!1;if(se.nodeType===1){if(!he(se,le))return!1}else if(se.nodeValue!==le.nodeValue)return!1}}return!0}function Ce(k,$){let Q=[],be=null;for(let fe=k.firstChild;fe;fe=fe.nextSibling){if(fe.nodeType===3){be=be===null?fe.nodeValue:be+fe.nodeValue;continue}fe.nodeType===1&&$(fe)||(be!==null&&(be!==""&&Q.push(be),be=null),Q.push(fe))}return be!==null&&be!==""&&Q.push(be),Q}function Le(k,$,Q,be){let fe=k.value,se=be?fe:$?$.value:"",le=Q?Q.value:"";ee.add(k),$&&ee.add($),Q&&ee.add(Q);let Be=se===le?se:se===fe?le:le===fe||Qe==="local"?se:le,Ke={site:"comment",bRun:k,lRun:$,rRun:Q,node:null};if(se!==fe&&le!==fe&&se!==le&&dt({kind:"text",node:null,base:fe,local:se,remote:le,resolved:Be},Ke),!$&&!Q)return null;let Ue=re.createComment(Be);return Ke.node=Ue,Se.set(Ue,{base:k.nodes,local:$?$.nodes:null,remote:Q?Q.nodes:null}),Ue}function We(k,$){let Q=pe($,k);if(!Q)return null;let be=ut(Q)?Q.parentNode:Q.parent,fe=ut(k)?k.parentNode:k.parent;return pe($,fe)===be?null:$.reverse.get(be)||null}function Ne(k){let $=new Set([k]),Q=k;for(let be=0;be<64;be++){let fe=We(Q,D)||We(Q,V);if(!fe)return!1;if(fe===k||ut(k)&&ut(fe)&&k.contains(fe)||$.has(fe))return!0;$.add(fe),Q=fe}return!0}function ze(k,$,Q){if(!$)return!1;let be=ut(k)?k.parentNode:k.parent;return be===$||$.tagName==="TEMPLATE"&&be===$.content}function tt(k,$){let Q=De(k),be=pe(D,Q);if(be&&ze($,be,D))return!0;let fe=pe(V,Q);return!!(fe&&ze($,fe,V))}}function qi(e,n){return e.map.get(n)?zi():{map:{get:o=>o&&o.nodeType===1&&e.map.get(o)||o,has:()=>!0},reverse:{get:o=>e.reverse.get(o)||o,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function zi(){let e={get:n=>n,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Gi=new Set(["INPUT","OPTION","TEXTAREA"]),ds=/[\t\n\f\r ]+/;function Yi(e,n,t,o){let r=e.ownerDocument,{provenance:c,textMappers:l}=t,i=o.hooks,s=[],a=[],h=[],f=new Set,u=[],g=[],b=new Map,A=new Set,p=new Map,m=t.conflicts.length>0,y=new Map,R=new Set,S=new Map,O=(_,ie)=>{let me=S.get(_);me||S.set(_,me=new Set),me.add(ie)},M=m?new Set:null,E=(_,ie,me)=>{let pe=i.beforeAttributeUpdated(_,ie,me);return m&&pe===!1&&O(ie,_),pe},N=_=>!!_&&(_===e||e.contains(_)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(_)),L=new Map,j=new Map,F=new Map,W=new Set,C=new Map;(function _(ie){let me=c.get(ie);if(me){if(ie.nodeType===1){let ke=me.local?o.toLive(me.local):null;ke&&N(ke)&&ke.nodeType===1&&(L.set(ie,ke),j.set(ke,ie))}else if(Array.isArray(me.local)){let ke=V(me.local,me.local.map(v=>o.toLive(v)).filter(v=>v&&N(v)&&v.nodeType===ie.nodeType));if(ke.length&&(L.set(ie,ke[0]),j.set(ke[0],ie),F.set(ie,ke)),Array.isArray(me.caret))for(let v of me.caret){let P=o.toLive(v.node);if(!P||!N(P)||P.nodeType!==3)continue;let Y=C.get(P);Array.isArray(Y)||C.set(P,Y=[]),Y.push({merged:ie,from:v.from,to:v.to,flatStart:v.flatStart})}else{let v=0;for(let P of ke)C.set(P,{merged:ie,shift:v}),v+=P.nodeValue.length}}}let pe=ie.nodeType===1&&ie.tagName==="TEMPLATE"&&ie.content?ie.content.childNodes:ie.childNodes;for(let ke of pe)_(ke)})(n);let T=new Set;for(let _ of L.values())T.add(_);for(let _ of F.values())for(let ie of _)T.add(ie);let x=o.localRoot&&o.localRoot!==e?new Set:null;if(x){for(let _=o.localRoot.firstElementChild;_;_=_.nextElementSibling)if(_.tagName==="HEAD")for(let ie=_.firstElementChild;ie;ie=ie.nextElementSibling){let me=o.toLive(ie);me&&x.add(me)}}for(let _ of t.segments||[])Ee(_);let z=o.restoreFocus===!1?null:la(r,C);o.childrenOnly?Se(Me(e),Me(n)):De(e,n);for(let{node:_,parent:ie}of u)f.has(_)||!_.parentNode||_.nodeType===1&&(o.ignored(_)||qe(_))||ot(_,ie);return ca(r,z,C,l,F,p,W),{applied:s,moved:a,replaced:h,identities:g,mergedScriptsLive:A,liveOf:L,heldBy:p,runOf:F,keptRuns:W,insertedLive:y,vetoed:R,vetoedAttrs:S,removedVetoes:M};function D(_,ie){let me=_.slice(ie.bs,ie.be),pe=0;for(;pe<me.length&&pe<ie.text.length&&me[pe]===ie.text[pe];)pe++;let ke=0;for(;ke<me.length-pe&&ke<ie.text.length-pe&&me[me.length-1-ke]===ie.text[ie.text.length-1-ke];)ke++;return{bs:ie.bs+pe,be:ie.be-ke,text:ie.text.slice(pe,ie.text.length-ke)}}function V(_,ie){if(!ie.length)return ie;let me=[];for(let v of _){let P=v.parentNode;if(!P)continue;let Y=b.get(P);if(!Y){Y=new Set;for(let J=P.firstChild;J;J=J.nextSibling)J.nodeType===3&&Y.add(o.toLive(J));b.set(P,Y)}me.includes(Y)||me.push(Y)}let pe={has:v=>me.some(P=>P.has(v))},ke=[];for(let v of ie){ke.push(v);for(let P=v.nextSibling;P&&P.nodeType===3&&!pe.has(P)&&!ke.includes(P);P=P.nextSibling)ke.push(P)}return ke}function Ee(_){let ie=[];for(let ge of _.localNodes){let B=o.toLive(ge.node);if(!B||!N(B)||B.nodeType!==3)return;ie.push(B)}let me=V(_.localNodes.map(ge=>ge.node),ie);if(!me.length)return;let pe=me.map(ge=>ge.nodeValue).join(""),{flatLocal:ke,lToM:v,mapLocal:P}=_;if(pe===ke)return;let Y=_.textNodes.map(ge=>({node:ge.node,ms:ge.ms,me:ge.me})),J=[],oe=0;for(let ge of me)J.push(oe),oe+=ge.nodeValue.length;let je=(ge,B)=>me.find((G,ue)=>J[ue]<=ge&&ge+B<=J[ue]+G.nodeValue.length)||null,Z=[],Oe=0;for(let ge of ro(ke,pe).map(B=>D(ke,B))){let B=ge.bs+Oe;Oe+=ge.text.length-(ge.be-ge.bs);let G,ue;if(ge.be>ge.bs){G=v[ge.bs];let he=G>=0;for(let ce=ge.bs;he&&ce<ge.be;ce++)v[ce]!==G+(ce-ge.bs)&&(he=!1);if(!he)continue;ue=G+(ge.be-ge.bs)}else{let he=ge.bs>0?v[ge.bs-1]:0,ce=ge.bs<ke.length?v[ge.bs]:0;if(he<0||ce<0)continue;G=ue=P(ge.bs)}Z.push({ms:G,me:ue,text:ge.text,live:ue===G?je(B,ge.text.length):null})}Z.sort((ge,B)=>B.ms-ge.ms);let He=(ge,B)=>(F.get(ge.node)||[L.get(ge.node)]).includes(B),Ie=ge=>!!ge&&ge.nodeType===1&&wn.has(ge.tagName);for(let ge of Z){let B=Y.find(ue=>ue.ms<=ge.ms&&ge.me<=ue.me&&ge.ms<ue.me);if(B&&ge.live&&B.ms===ge.ms&&!He(B,ge.live)){let ue=Y.find(he=>he.me===ge.ms&&He(he,ge.live));ue&&(B=ue)}if(!B&&ge.me===ge.ms){let ue=Y.find(te=>te.me===ge.ms),he=Y.find(te=>te.ms===ge.ms),ce=ue||he;if(!ce)continue;let xe=ce.node;for(;Ie(xe.parentNode)&&(ue?xe.parentNode.lastChild:xe.parentNode.firstChild)===xe;)xe=xe.parentNode;if(xe===ce.node)B=ce;else{let te=xe.ownerDocument.createTextNode(ge.text);xe.parentNode.insertBefore(te,ue?xe.nextSibling:xe);continue}}if(!B)continue;let G=B.node.nodeValue;B.node.nodeValue=G.slice(0,ge.ms-B.ms)+ge.text+G.slice(ge.me-B.ms),B.me+=ge.text.length-(ge.me-ge.ms)}}function Me(_){return _.nodeType===1&&_.tagName==="TEMPLATE"&&_.content?_.content:_}function De(_,ie){f.add(_);let me=c.get(ie);if(me&&me.remote&&t.remoteIdOf){let ke=t.remoteIdOf(me.remote);ke&&g.push([_,ke])}if(me&&me.unchanged){t.customIdentity&&me.remote&&ne(_,me.remote),me.remote&&K(_,me.remote);return}if(i.beforeNodeMorphed(_,ie)===!1){R.add(ie);return}gt(_,ie,o.keepLiveOnly&&me&&me.local&&me.local.nodeType===1&&me.local!==_?me.local:null);let pe=_.tagName;if(hn(_))_.textContent!==ie.textContent&&(s.push({kind:"text",node:_,before:_.textContent,after:ie.textContent}),_.textContent=ie.textContent),t.mergedScripts.has(ie)&&A.add(_);else if(pe==="TEXTAREA")zt(_,ie,me);else{an(_,ie,me);let ke=pe==="TEMPLATE"&&_.content?_.content:_,v=pe==="TEMPLATE"&&ie.content?ie.content:ie;o.protectFocusedValue==="subtree"&&$t(_)&&_!==r.body?re(ke):Se(ke,v)}i.afterNodeMorphed(_,ie)}function re(_){for(let ie=_.firstChild;ie;ie=ie.nextSibling){let me=j.get(ie);me&&L.get(me.parentNode)!==_||(f.add(ie),ie.nodeType===1&&re(ie))}}function Se(_,ie){let me=_e(_.firstChild),pe=new Set;for(let ke of Array.from(ie.childNodes)){let v=L.get(ke);v&&f.has(v)&&!pe.has(v)&&(v=null);let P=c.get(ke);if(P&&P.pinned){v&&v.nodeType===1&&((v.parentNode!==_||_e(v.nextSibling)!==me)&&Ae(_,v,me),f.add(v),pe.add(v));continue}if(v&&v.nodeType===1){if(v!==me){let oe=v.parentNode;if(oe===_&&me&&Ht(v)){let je=v.nextSibling;for(let Z=me;Z&&Z!==v;){let Oe=Z.nextSibling;Ae(_,Z,je),Z=Oe}}else Ae(_,v,me),oe!==_&&(a.push(v),s.push({kind:"move",el:v,from:oe,to:_}))}pe.add(v),De(v,ke),me=_e(v.nextSibling);continue}if(v&&v.nodeType!==1){let oe=F.get(ke)||[v],je=oe.map(Oe=>Oe.nodeValue).join(""),Z=ke.nodeValue;if(ke.nodeType===3){let Oe=ve(ke);Oe!=null&&je!==Oe&&(Z=Ho(Oe,je,ke.nodeValue).text)}if(oe.length>1&&je===Z&&!oe.includes(me,1)&&oe.every((Oe,He)=>Oe.parentNode===_&&(He===0||oe[He-1].nextSibling===Oe))){if(v!==me)for(let Oe of oe)Ae(_,Oe,me);i.beforeNodeMorphed(v,ke)!==!1?i.afterNodeMorphed(v,ke):m&&R.add(ke);for(let Oe of oe)f.add(Oe),pe.add(Oe);p.set(ke,v),W.add(ke),me=_e(oe[oe.length-1].nextSibling);continue}v!==me&&Ae(_,v,me),i.beforeNodeMorphed(v,ke)!==!1?(v.nodeValue!==Z&&(s.push({kind:"text",node:v,before:v.nodeValue,after:Z}),v.nodeValue=Z),i.afterNodeMorphed(v,ke)):R.add(ke),f.add(v),pe.add(v),p.set(ke,v),me=_e(v.nextSibling);continue}if(ke.nodeType===3&&me&&me.nodeType===3&&!f.has(me)&&!C.has(me)){me.nodeValue!==ke.nodeValue&&(s.push({kind:"text",node:me,before:me.nodeValue,after:ke.nodeValue}),me.nodeValue=ke.nodeValue),f.add(me),p.set(ke,me),me=_e(me.nextSibling);continue}let Y=c.get(ke),J=Qe(Y&&Y.unchanged&&Y.remote?Y.remote:ke);if(i.beforeNodeAdded(J)===!1){R.add(ke);continue}_.insertBefore(J,me),f.add(J),m&&y.set(ke,J),J.nodeType===3&&p.set(ke,J),J.nodeType===1&&(h.push(J),Pe(J,ke),t.customIdentity&&Y&&Y.unchanged&&Y.remote&&ne(J,Y.remote),hn(J)||Ze(J,ke),o.formState==="property"&&jt(Y)&&K(J,Y.remote)),me=_e(J.nextSibling),s.push({kind:"insert",node:J,parent:_}),i.afterNodeAdded(J)}for(let ke of Array.from(_.childNodes))f.has(ke)||pe.has(ke)||ke.nodeType===1&&(o.ignored(ke)||qe(ke))||(T.has(ke)?u.push({node:ke,parent:_}):ot(ke,_))}function qe(_){return _.parentNode&&_.parentNode.nodeType===1&&_.parentNode.tagName==="HEAD"&&(x&&!x.has(_)||o.preserve&&o.preserve(_)===!0)}function ve(_){let ie=c.get(_);return!ie||!Array.isArray(ie.local)?null:ie.local.map(me=>me.nodeValue).join("")}function w(_){return c.get(_)}function K(_,ie){if(!Gi.has(_.tagName)&&!_.querySelector("input,option,textarea"))return;let me=(pe,ke)=>{if(pe.tagName!==ke.tagName)return;pe.tagName==="TEXTAREA"?zt(pe,ke,{remote:ke}):Gi.has(pe.tagName)&&an(pe,ke,{remote:ke});let v=ee(pe),P=ee(ke);if(v.length===P.length)for(let Y=0;Y<v.length;Y++)me(v[Y],P[Y])};me(_,ie)}function ne(_,ie){let me=ee(_),pe=ee(ie);if(me.length===pe.length)for(let ke=0;ke<me.length;ke++){let v=t.remoteIdOf(pe[ke]);v&&g.push([me[ke],v]),ne(me[ke],pe[ke])}}function ee(_){let ie=_.tagName==="TEMPLATE"&&_.content?_.content:_;return Array.from(ie.children).filter(me=>!o.ignored(me))}function Pe(_,ie){if(!t.remoteIdOf)return;let me=(pe,ke)=>{let v=c.get(ke);if(v&&v.remote&&ke.nodeType===1){let J=t.remoteIdOf(v.remote);J&&g.push([pe,J])}let P=pe.childNodes,Y=ke.childNodes;for(let J=0;J<P.length&&J<Y.length;J++)me(P[J],Y[J])};me(_,ie)}function _e(_){for(;_&&_.nodeType===1&&o.ignored(_);)_=_.nextSibling;return _}function Ae(_,ie,me){if(typeof _.moveBefore=="function"&&ie.ownerDocument===_.ownerDocument)try{_.moveBefore(ie,me);return}catch{}_.insertBefore(ie,me)}function ot(_,ie){if(i.beforeNodeRemoved(_)===!1){m&&M.add(_);return}_.parentNode.removeChild(_),s.push({kind:"remove",node:_,parent:ie}),i.afterNodeRemoved(_)}function Qe(_){if(hn(_))return Vo(_,r);let ie=r.importNode(_,!0);if(ie.nodeType===1)for(let me of Array.from(ie.querySelectorAll("script")))hn(me)&&me.replaceWith(Vo(me,r));return ie}function Ze(_,ie){let me=_.tagName==="TEMPLATE"&&_.content?_.content:_,pe=ie.tagName==="TEMPLATE"&&ie.content?ie.content:ie,ke=Array.from(me.childNodes),v=Array.from(pe.childNodes);for(let P=0;P<v.length&&P<ke.length;P++){let Y=v[P],J=ke[P],oe=L.get(Y);oe&&f.has(oe)&&(oe=null);let je=c.get(Y);if(je&&je.pinned){if(oe&&oe.nodeType===1){let Z=oe.parentNode;Ae(me,oe,J),Z!==me&&(a.push(oe),s.push({kind:"move",el:oe,from:Z,to:me})),f.add(oe)}J.remove();continue}if(oe){let Z=oe.parentNode;Ae(me,oe,J),J.remove(),oe.nodeType===1?(Z!==me&&(a.push(oe),s.push({kind:"move",el:oe,from:Z,to:me})),De(oe,Y)):(f.add(oe),p.set(Y,oe),oe.nodeValue!==Y.nodeValue&&(s.push({kind:"text",node:oe,before:oe.nodeValue,after:Y.nodeValue}),oe.nodeValue=Y.nodeValue));continue}f.add(J),m&&y.set(Y,J),J.nodeType===3&&p.set(Y,J),je&&je.unchanged&&je.remote?(Xe(J,je.remote),t.customIdentity&&ne(J,je.remote)):Y.nodeType===1&&!hn(Y)&&Ze(J,Y)}}function Xe(_,ie){let me=_.tagName==="TEMPLATE"&&_.content?_.content:_,pe=ie.tagName==="TEMPLATE"&&ie.content?ie.content:ie;for(let ke of Array.from(pe.childNodes))me.appendChild(Qe(ke))}function yt(_,ie){return ie.namespaceURI?_.getAttributeNS(ie.namespaceURI,ie.localName):_.getAttribute(ie.name)}function dt(_,ie){let me=new Set((ie||"").split(ds).filter(Boolean));return(_||"").split(ds).filter(pe=>pe&&!me.has(pe))}function gt(_,ie,me){for(let pe of Array.from(ie.attributes)){if(qt(_,pe.name)||o.ignoreAttribute(_,pe.name))continue;let ke=yt(_,pe);if(ke===pe.value||me&&yt(me,pe)===pe.value)continue;let v=pe.value;if(me&&pe.name==="class"&&!pe.namespaceURI){let P=pe.value.split(ds).filter(Boolean),Y=dt(ke,me.getAttribute("class")).filter(J=>!P.includes(J));Y.length&&(v=[...P,...Y].join(" "))}if(ke!==v){if(i.beforeAttributeUpdated(pe.name,_,"update")===!1){m&&O(ie,pe.name);continue}pe.namespaceURI?_.setAttributeNS(pe.namespaceURI,pe.name,v):_.setAttribute(pe.name,v),s.push({kind:"attr",el:_,name:pe.name,before:ke,after:v})}}for(let pe of Array.from(_.attributes)){if(qt(_,pe.name)||o.ignoreAttribute(_,pe.name)||(pe.namespaceURI?ie.hasAttributeNS(pe.namespaceURI,pe.localName):ie.hasAttribute(pe.name)))continue;if(me&&pe.name==="class"&&!pe.namespaceURI){let P=dt(pe.value,me.getAttribute("class"));if(P.length){let Y=P.join(" ");if(Y===pe.value)continue;if(i.beforeAttributeUpdated("class",_,"update")===!1){m&&O(ie,"class");continue}_.setAttribute("class",Y),s.push({kind:"attr",el:_,name:"class",before:pe.value,after:Y});continue}}if(me&&yt(me,pe)===null)continue;if(i.beforeAttributeUpdated(pe.name,_,"remove")===!1){m&&O(ie,pe.name);continue}let v=pe.value;pe.namespaceURI?_.removeAttributeNS(pe.namespaceURI,pe.localName):_.removeAttribute(pe.name),s.push({kind:"attr",el:_,name:pe.name,before:v,after:null})}}function qt(_,ie){let me=_.tagName;return me==="INPUT"?ie==="value"||ie==="checked"||ie==="disabled":me==="OPTION"?ie==="selected":!1}function $t(_){return _===r.activeElement}function Ht(_){let ie=r.activeElement;return!!ie&&ie!==r.body&&_.contains(ie)}function jt(_){let ie=_&&_.remote;return ie&&ie.nodeType===1?ie:null}function an(_,ie,me){let pe=_.tagName,ke=jt(me),v=o.formState==="property"&&ke?ke:ie;if(pe==="INPUT"){let P=o.protectFocusedValue&&$t(_),Y=(_.getAttribute("type")||"").toLowerCase(),J=Y!=="file"&&Y!=="checkbox"&&Y!=="radio",oe=ke&&ke.hasAttribute("value")&&ke.value!==ke.getAttribute("value")?ke.value:null;if(J&&!P)if(o.formState==="property"){let je=ie.getAttribute("value"),Z=_.getAttribute("value");(Z!==je||_.value!==v.value)&&E("value",_,je==null?"remove":"update")!==!1&&(Z!==je&&(je==null?_.removeAttribute("value"):_.setAttribute("value",je),s.push({kind:"attr",el:_,name:"value",before:Z,after:je})),_.value!==v.value&&(_.value=v.value))}else if(ie.hasAttribute("value")||oe!=null){let je=oe??ie.getAttribute("value");_.getAttribute("value")!==je&&E("value",_,"update")!==!1?(_.setAttribute("value",je),_.value!==je&&(_.value=je),s.push({kind:"attr",el:_,name:"value",before:null,after:je})):_.value!==je&&_.getAttribute("value")===je&&(_.value=je)}else(_.hasAttribute("value")||_.value!=="")&&E("value",_,"remove")!==!1&&(_.removeAttribute("value"),_.value="",s.push({kind:"attr",el:_,name:"value",before:"",after:null}));if(!J&&Y!=="file"){let je=ie.getAttribute("value");je==null?_.hasAttribute("value")&&E("value",_,"remove")!==!1&&_.removeAttribute("value"):_.getAttribute("value")!==je&&E("value",_,"update")!==!1&&_.setAttribute("value",je)}P||(_t(_,v,"checked"),o.formState==="property"&&_.indeterminate!==v.indeterminate&&(_.indeterminate=v.indeterminate)),_t(_,v,"disabled")}else if(pe==="OPTION"){let P=_.parentNode&&_.closest("select");o.protectFocusedValue&&P&&$t(P)||_t(_,v,"selected")}}function _t(_,ie,me){let pe=o.formState==="property"?!!ie[me]:ie.hasAttribute(me);if(o.formState!=="property"){let ke=_.hasAttribute(me);if(ke!==pe){if(E(me,_,pe?"update":"remove")===!1)return;pe?_.setAttribute(me,""):_.removeAttribute(me),s.push({kind:"attr",el:_,name:me,before:ke?"":null,after:pe?"":null})}}_[me]!==pe&&(_[me]=pe)}function zt(_,ie,me){if(o.protectFocusedValue&&$t(_)||E("value",_,"update")===!1)return;let pe=jt(me),ke=ie.textContent,v=pe&&pe.value!==pe.defaultValue?pe.value:ke;o.formState!=="property"&&_.textContent!==ke&&(s.push({kind:"text",node:_,before:_.textContent,after:ke}),_.textContent=ke),_.value!==v&&(_.value=v)}}function la(e,n){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let o={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{o.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return o}let r=e.getSelection&&e.getSelection();if(r&&r.rangeCount){let c=r.getRangeAt(0);o.range={sc:c.startContainer,so:c.startOffset,ec:c.endContainer,eo:c.endOffset}}return o}function ca(e,n,t,o,r,c,l){if(!n)return;let i=n.el;if(!i.isConnected&&n.id&&(i=e.getElementById(n.id)),!i||!i.isConnected)return;if(e.activeElement!==i)try{i.focus({preventScroll:!0})}catch{}try{i.scrollTop=n.scrollTop,i.scrollLeft=n.scrollLeft}catch{}if(n.selection){try{i.setSelectionRange&&!i.selectionEnd&&n.selection[1]!=null&&i.setSelectionRange(n.selection[0],n.selection[1],n.selection[2]||"none")}catch{}return}if(!n.range)return;let s=(f,u)=>{let g=t.get(f);if(Array.isArray(g)){let b=g.find(y=>u>=y.from&&u<y.to)||g.find(y=>u===y.to)||g[g.length-1],A=c.get(b.merged);if(!A||!A.isConnected)return null;let p=o.get(b.merged),m=p&&p.flat?p.flat(b.flatStart+u):u;return[A,Math.max(0,Math.min(m,A.nodeValue.length))]}if(g&&!l.has(g.merged)){let b=(r.get(g.merged)||[f])[0];if(!b.isConnected)return null;let A=o.get(g.merged),p=g.shift+u,m=A?A(p):p;return[b,Math.max(0,Math.min(m,b.nodeValue.length))]}return f.isConnected?[f,Math.min(u,f.nodeType===3?f.nodeValue.length:f.childNodes.length)]:null},a=s(n.range.sc,n.range.so),h=s(n.range.ec,n.range.eo);if(!(!a||!h))try{let f=e.createRange();f.setStart(a[0],a[1]),f.setEnd(h[0],h[1]);let u=e.getSelection();u.removeAllRanges(),u.addRange(f)}catch{}}var aa={compared:0},fa=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function ua(e,n,t){let o=0;for(let r of e.attributes)if(!t(e,r.name)&&(o++,n.getAttribute(r.name)!==r.value))return!1;for(let r of n.attributes)t(n,r.name)||o--;return o===0}function hs(e,n){if(e.namespaceURI!==n.namespaceURI||e.prefix!==n.prefix||e.localName!==n.localName)return!1;let t=e.attributes;if(t.length!==n.attributes.length)return!1;for(let o of t)if(n.getAttributeNS(o.namespaceURI,o.localName)!==o.value)return!1;return!0}function Xi(e,n,t,o,r,c,l,i){let s=new Map,a=new Set,h=f=>{if(o(f))return;let u=t(f);u&&(c.add(u),r.has(u)||s.has(u)?a.add(u):s.set(u,f))};for(let f of e)h(f);h(n);for(let f of l||n.querySelectorAll("*"))h(f);for(let f of a)s.delete(f),i.add(f);return s}function Ji(e,n,t,o,r,c){let l=!1;for(let h of r)h.startsWith("merge:")&&(l=!0);if(!l)return[...o];let i=new Map,s=[],a=c===bn?$o:"*";for(let h of[e,...e.querySelectorAll(a)]){if(t(h))continue;let f=n(h);if(!f||!(o.has(f)||r.has(f)))continue;let u=(i.get(f)||0)+1;i.set(f,u),u===2&&s.push(f)}return s}function Qi({baseRoot:e,remoteRoot:n,liveRoot:t,toLive:o,o:r,identity:c,baseURI:l}){if(e.tagName!==n.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||n.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!ua(e,n,r.ignoreAttribute))return{bail:"root-attrs"};let{ignored:i,remoteWins:s}=r,a=us(r.scripts.merge===!1?null:r.scripts.mergeTags,l),h=ve=>{let w=a(ve);return w!==null?w:c.base(ve)||null},f=ve=>{let w=a(ve);return w!==null?w:c.remote(ve)||null},u=[],g=[],b=new Map,A=new Map,p={same:b,differ:A},m=ve=>({bail:ve,comparisons:p}),y=(ve,w,K=!0)=>{if(b.get(ve)===w)return!0;if(A.get(ve)===w)return!1;if(aa.compared++,K&&ve.isEqualNode(w))return b.set(ve,w),!0;let ne=ve.nodeType===w.nodeType;if(ne&&ve.nodeType===1){if(ne=hs(ve,w),ne){let ee=ve.firstChild,Pe=w.firstChild;for(;ee&&Pe;ee=ee.nextSibling,Pe=Pe.nextSibling)if(!y(ee,Pe,!1)){ne=!1;break}(ee||Pe)&&(ne=!1)}}else ne&&(ne=ve.isEqualNode(w));return(ne?b:A).set(ve,w),ne},R=e,S=n,O=!1,M=()=>{b.set(R,S);for(let ve=0;ve<u.length;ve++)b.set(u[ve],g[ve]);return m("equal")};for(;;){let ve=R.childNodes,w=S.childNodes;if(ve.length!==w.length)break;let K=Qe=>y(ve[Qe],w[Qe])?(b.set(ve[Qe],w[Qe]),!1):!0,ne=-1,ee=-1;for(let Qe=0;Qe<ve.length;Qe++){if(ve[Qe].nodeType!==1)continue;let Ze=0;for(let Xe=ve[Qe].firstElementChild;Xe;Xe=Xe.nextElementSibling)Ze++;Ze>=ee&&(ee=Ze,ne=Qe)}let Pe=[],_e=!1;for(let Qe=0;Qe<ve.length&&Pe.length<2;Qe++)Qe!==ne&&K(Qe)&&Pe.push(Qe);if(ne>=0&&Pe.length<2&&(Pe.length===0&&hs(R,S)?(Pe.push(ne),_e=!0):K(ne)&&Pe.push(ne)),Pe.length!==1){if(!O&&Pe.length===0&&hs(R,S))return M();break}let Ae=ve[Pe[0]],ot=w[Pe[0]];if(O=O||!_e,O&&A.set(Ae,ot),Ae.nodeType!==1||ot.nodeType!==1||Ae.tagName!==ot.tagName)break;if(h(Ae)!==f(ot)){if(!O&&y(Ae,ot))return M();break}u.push(R),g.push(S),R=Ae,S=ot}A.set(R,S);for(let ve=0;ve<u.length;ve++)A.set(u[ve],g[ve]);if(R===e||R.tagName==="HEAD"||R.tagName==="BODY")return m("root-level");if(u.length<2||u[1].tagName!=="BODY")return m("not-in-body");if(i(R)||i(S))return m("ignored-ancestor");if(s(R)||s(S))return m("remote-wins-ancestor");for(let ve of u)if(fa.has(ve.tagName))return m("form-ancestor");if(R.tagName==="SCRIPT"||R.getElementsByTagName("script").length||S.getElementsByTagName("script").length)return m("script-or-template");let E=o(R);if(!E||E.nodeType!==1||E.tagName!==R.tagName)return m("no-live-twin");if(!t.contains(E))return m("live-detached");for(let ve of u){let w=o(ve);if(!w||w.nodeType!==1)return m("ancestor-live")}let N=c.base===bn&&c.remote===bn&&i===Hr,L=new Set,j=new Set,F=[],W=null,C=ve=>{ve&&(L.has(ve)?j.add(ve):L.add(ve))},T=(ve,w)=>{let K=a(ve),ne=K!==null?K:c.base(ve)||null;return ne!==(K!==null?K:c.remote(w)||null)?!1:(C(ne),!0)},x=(ve,w)=>{for(let K=ve.firstElementChild,ne=w.firstElementChild;K;K=K.nextElementSibling,ne=ne.nextElementSibling){let ee=i(K);if(ee!==i(ne))return!1;if(!ee&&(!T(K,ne)||!x(K,ne)))return!1}return!0},z=ve=>{let w=ve+1<u.length?u[ve+1]:R;for(let K=u[ve].firstElementChild,ne=g[ve].firstElementChild;K;K=K.nextElementSibling,ne=ne.nextElementSibling){if(K===w){let _e=ve+1<u.length?z(ve+1):null;if(_e)return _e;continue}let ee=i(K);if(ee!==i(ne))return"outside-id-changed";if(ee)continue;let Pe=o(K);if(!Pe||Pe.nodeType!==1)return"sibling-live";if(F.push([K,ne]),!N&&(!T(K,ne)||!x(K,ne)))return"outside-id-changed";ve===0&&K.tagName==="HEAD"&&h(K)&&(W=[K,ne])}return null},D=z(0);if(D)return m(D);let V=new Set(u),Ee=null;if(c.base===bn){Ee=[];for(let ve of e.querySelectorAll($o))ve===R||V.has(ve)||(R.contains(ve)?Ee.push(ve):N&&C(h(ve)))}let Me=new Set,De=new Set,re=new Set,Se=Xi(u,R,h,i,L,Me,Ee,De),qe=Xi(g,S,f,i,L,Me,c.remote===bn&&S.querySelectorAll($o),re);return W&&(j.has(h(W[0]))||Me.has(h(W[0])))&&(W=null),{scope:{chain:u,root:R,onChain:V,baseIndex:Se,remoteIndex:qe,baseDropped:De,remoteDropped:re,head:W,same:b,differ:A,dropped:[...Ji(e,h,i,j,De,c.base),...Ji(n,f,i,j,re,c.remote)],held:ve=>{for(let w=1;w<u.length;w++)if(ve.map.get(u[w])!==g[w])return!1;for(let[w,K]of F)if(ve.map.get(w)!==K)return!1;return!0}}}}var qu=Symbol("hyper-morph-duplicate-key");var da='[editor-ui],[clay~="editor-ui"],[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]',ha='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',pa='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function ma(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let n=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(n)}function ga(e,n,t,o){if(n==null)return;if(typeof n=="string")return n;let r=n;if(r.nodeType===9){let c=e.getAttribute("id");r=c&&r.getElementById(c)||(e.tagName==="BODY"?r.body:e.tagName==="HTML"?r.documentElement:r.body&&r.body.firstElementChild)}if((!r||r.nodeType!==1||r.tagName!==e.tagName)&&(r=ba(e,n,o)),!!r)return t?Array.from(r.childNodes):r}function ba(e,n,t){let o=n.nodeType===9?n.documentElement:n;if(!o||o.nodeType!==1)return null;let r=new Map,c=[o,...o.querySelectorAll("script")];for(let s of c){let a=So(s,t);a&&!r.has(a.key)&&r.set(a.key,s.textContent)}if(!r.size)return null;let l=e.cloneNode(!0),i=!1;for(let s of[l,...l.querySelectorAll("script")]){let a=So(s,t);a&&r.has(a.key)&&(s.textContent=r.get(a.key),i=!0)}return i?l:null}function Zi(e,n){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=n.implementation.createHTMLDocument(""),o=e.nodeType===1&&e.tagName==="HTML"?e:null;if(o)return t.replaceChild(t.adoptNode(o),t.documentElement),t;let r=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let c of r)t.body.appendChild(t.adoptNode(c));return t}function ps(e,n,t={}){let o=t||{};if(!o.head?.block)return el(e,n,o);try{return el(e,n,o)}catch(r){return Promise.reject(r)}}function el(e,n,t){let o=t.policy||"sync",r=o==="raw"?void 0:(s,a)=>ma(s)||(o==="history"?!(a&&s.matches(pa))&&s.matches(ha):s.matches(da)),c=t.callbacks||{},l={ignore:r,hooks:c,protectFocusedValue:t.ignoreActiveValue===!0?"subtree":!1,restoreFocus:t.restoreFocus!==!1,formState:t.formStateSync||"attribute",scripts:{execute:t.scripts?.handle!==!1,merge:t.scripts?.merge!==!1,mergeTags:t.scripts?.mergeTags||[]},head:{awaitLoads:!!t.head?.block,preserve:t.head?.shouldPreserve||(()=>!1)}};if(typeof t.key=="function"&&(l.identity={base:t.key,local:t.key,remote:t.key}),e&&e.nodeType===9)return Ko(Object.assign({},l,{live:e,base:t.scripts?.mergeBase||null,remote:Zi(n,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let s=Object.assign({},l,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Zi(n,e.ownerDocument)});return Ko(s)}t.morphStyle==="innerHTML"&&(l.children=!0);let i=ga(e,t.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return i!==void 0&&(l.base=i),ms(e,n,l)}var ya=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),Nn=()=>{};function qo(e,n=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!ya.has(l))throw new TypeError(`unknown option "${l}"`);let t=Object.assign({beforeNodeAdded:Nn,afterNodeAdded:Nn,beforeNodeRemoved:Nn,afterNodeRemoved:Nn,beforeNodeMorphed:Nn,afterNodeMorphed:Nn,beforeAttributeUpdated:Nn},e.hooks||{}),o=e.conflicts||"remote";if(!["remote","local","both"].includes(o))throw new TypeError("conflicts must be remote, local or both");let r=e.formState||"attribute";if(!["attribute","property"].includes(r))throw new TypeError("formState must be attribute or property");let c=e.protectFocusedValue;if(c!==void 0&&typeof c!="boolean"&&c!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");return{ignored:Wr(e.ignore,n),remoteWins:Wr(e.remoteWins,n),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:o,protectFocusedValue:c===void 0?!0:c,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:r,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0}}function Mo(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return bn}function Eo(e,n){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=Vr(n,e.map),o=typeof e.then=="function"?e.then:bn;if(typeof e.first=="function"){let r=e.first;return c=>r(c)||t.get(c)||o(c)}return r=>t.get(r)||o(r)}return bn}function wa(e,n,t,o={}){let r=g=>g&&g.nodeType===9?g.documentElement:g,c=r(n),l=r(t),i=r(e)||c,s=Object.assign({},o);delete s.live,delete s.base,delete s.remote;let a=qo(s,[i,c,l].filter(Boolean)),h=o.identity||{},f=Xn(),u=Nr(i,c,l,{identity:{base:Eo(h.base,i),local:Eo(h.local,c),remote:Eo(h.remote,l)},authored:{base:Mo(h.base),local:Mo(h.local),remote:Mo(h.remote)},skipUnchanged:a.hooks.beforeNodeMorphed===Nn&&a.hooks.afterNodeMorphed===Nn,ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:c.ownerDocument&&c.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===n,childrenOnly:a.children,stats:f});return delete u.recoveryLinks,u}function gs({liveRoot:e,baseRoot:n,localRoot:t,remoteRoot:o,toLive:r,options:c,identity:l,childrenOnly:i,isDocument:s}){let a=qo(c,[e,n,t,o].filter(Boolean));if(a.ignored(e))return{report:bs(),loads:[]};let h=e.ownerDocument,f=a.scripts.execute?Si(e,a.ignored,h.baseURI):null,u=Xn(),g=a.hooks.beforeNodeMorphed===Nn&&a.hooks.afterNodeMorphed===Nn,b={identity:{base:Eo(l.base,n||t),local:Eo(l.local,t),remote:Eo(l.remote,o)},authored:{base:Mo(l.base),local:Mo(l.local),remote:Mo(l.remote)},ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:h.baseURI,localIsBase:!n,childrenOnly:i,skipUnchanged:g},A=a.fastPath&&s&&!i&&g&&n===t,p=null,m=null;if(A){let C=Qi({baseRoot:n,remoteRoot:o,liveRoot:e,toLive:r,o:a,identity:b.identity,baseURI:h.baseURI});b.comparisons=C.comparisons||C.scope,C.bail?m=C.bail:(p=Nr(n,t,o,Object.assign({},b,{stats:u,scope:C.scope})),p||(m="chain-unpaired",u=Xn()))}p||(p=Nr(n||t,t,o,Object.assign({},b,{stats:u}))),A&&(u.fastPathAttempted=1,u.fastPathTaken=m?0:1,u.fastPathFallback=m),p.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(C=>a.hooks[C]!==Nn)&&Pi(p.conflicts,p.recoveryLinks,r),a.beforeApply&&a.beforeApply(p.doc);let y=globalThis.__hyperMorphProfile,R=y?performance.now():0,S=Yi(e,p.root,p,{toLive:r,localRoot:t,ignored:a.ignored,ignoreAttribute:a.ignoreAttribute,formState:a.formState,protectFocusedValue:a.protectFocusedValue,restoreFocus:a.restoreFocus,preserve:a.head.preserve,hooks:a.hooks,childrenOnly:i,keepLiveOnly:a.keepLiveOnly});y&&(y.apply=(y.apply||0)+(performance.now()-R));let O=[];if(a.head.awaitLoads)for(let C of S.applied){if(C.kind!=="insert"||C.node.nodeType!==1)continue;let T=C.node;T.tagName==="LINK"&&/\bstylesheet\b/i.test(T.getAttribute("rel")||"")&&T.getAttribute("href")&&T.closest("head")&&O.push(new Promise(z=>{T.addEventListener("load",()=>z()),T.addEventListener("error",()=>z())}))}let M=null,E=null;if(f){let C=Ni(e,f,{ignored:a.ignored,skip:S.mergedScriptsLive,baseURI:h.baseURI,beforeNodeAdded:a.hooks.beforeNodeAdded,afterNodeAdded:a.hooks.afterNodeAdded,trackRecovery:!!p.recoveryLinks});O.push(...C.loads),M=C.swapped,E=C.vetoed}let N=C=>M&&M.get(C)||C,L=C=>{if(S.keptRuns.has(C))return S.runOf.get(C);let T=S.liveOf.get(C)||S.heldBy.get(C)||S.insertedLive.get(C);return T?N(T):null},j=C=>{let T=C&&S.liveOf.get(C);return T?N(T):null},F=C=>{let T=C&&L(C);return Array.isArray(T)?T[0]:T};if(p.recoveryLinks){let C=(T,x,z)=>(x.namespaceURI?T.getAttributeNS(x.namespaceURI,x.localName):T.getAttribute(x.qualifiedName))===z;Bi(p.conflicts,p.recoveryLinks,{lookup:L,vetoed:S.vetoed,vetoedAttrs:S.vetoedAttrs,removedVetoes:S.removedVetoes,vetoedLive:E,liveAttr:C,ignored:a.ignored,liveRoot:e})}return{report:{applied:S.applied,decisions:p.decisions.map(C=>Object.assign({},C,{node:C.node?j(C.node):null,el:C.el?j(C.el):null,applied:!!(C.node?j(C.node):C.el&&j(C.el))})),conflicts:p.conflicts.map(C=>Object.assign({},C,{node:C.node?C.kind==="text"&&C.recovery.subject.nodeType===8?F(C.node):j(C.node):C.node,el:C.el?C.kind==="structure"?F(C.el):j(C.el):C.el})),localDiverged:p.localDiverged,identities:S.identities,moved:S.moved,replaced:S.replaced,stats:u},loads:O}}var tl=new WeakMap;function bs(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Xn()}}function Ko(e){let n=e||{},t=n.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let o=tl.get(t);o||(o=Ur(t),tl.set(t,o));let r=o("remote",n.remote),c=typeof n.base=="string"&&n.base===""?null:n.base,l=c?o("base",c):null,i=n.local?n.local.root:t.documentElement,s=n.local?n.local.toLive:f=>f;Zs(t,r);let{report:a,loads:h}=gs({liveRoot:t.documentElement,baseRoot:l?l.documentElement:null,localRoot:i,remoteRoot:r.documentElement,toLive:s,options:n,identity:n.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(h).then(()=>a)}function xa(e,n,t={}){return Ko(Object.assign({},t,{live:e,base:null,remote:n}))}function nl(e,n){if(e==null)return{root:n.createElement("template"),first:null};if(typeof e=="string"){let o=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(o){let c=pr(e,n),l=o[1].toLowerCase()==="html"?c.documentElement:c.body;return{root:l,first:l}}let r=n.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let o=n.createElement("template"),r=e.isConnected;return o.content.appendChild(r?n.importNode(e,!0):e),{root:o,first:e}}if(e.nodeType===11){let o=n.createElement("template");return o.content.appendChild(e),{root:o,first:o.content.firstElementChild}}let t=n.createElement("template");for(let o of Array.from(e))t.content.appendChild(o.parentNode?n.importNode(o,!0):o);return{root:t,first:t.content.firstElementChild}}function ms(e,n,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let o=e.ownerDocument,{base:r,...c}=t,l=!!c.children;if(qo(c,[e]).ignored(e))return Promise.resolve(bs());let i=nl(n,o),s=r!=null?nl(r,o):null,a,h=null;if(l)a=i.root,h=s?s.root:null;else{if(a=i.first,h=s?s.first:null,!a){let g=qo(c);return g.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),g.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Xn()})}if(a.tagName!==e.tagName){let g=qo(c,[e,a]);if(g.hooks.beforeNodeMorphed(e,a)===!1)return Promise.resolve(bs());let b=gs({liveRoot:e,baseRoot:h&&h.tagName===e.tagName?h:null,localRoot:e,remoteRoot:a,toLive:p=>p,options:c,identity:c.identity||{},childrenOnly:!0,isDocument:!1}),A=hn(a)?Vo(a,o):o.importNode(a,!1);if(!hn(A))for(;e.firstChild;)A.appendChild(e.firstChild);return g.hooks.beforeNodeAdded(A)===!1?(Sr(b.report.conflicts,e,e),Promise.resolve(b.report)):g.hooks.beforeNodeRemoved(e)===!1?(Sr(b.report.conflicts,e,e),Promise.resolve(b.report)):(e.replaceWith(A),Sr(b.report.conflicts,e,A),g.hooks.afterNodeRemoved(e),g.hooks.afterNodeAdded(A),g.hooks.afterNodeMorphed(e,a),b.report.replaced.push(A),b.report.applied.push({kind:"insert",node:A,parent:A.parentNode},{kind:"remove",node:e,parent:A.parentNode}),Promise.all(b.loads).then(()=>b.report))}}let{report:f,loads:u}=gs({liveRoot:e,baseRoot:h,localRoot:e,remoteRoot:a,toLive:g=>g,options:c,identity:c.identity||{},childrenOnly:l,isDocument:!1});return Promise.all(u).then(()=>f)}var ol={mergeDocument:Ko,morphDocument:xa,morphElement:ms,merge3:wa,morph:ps};function ys(e,n,{onWidgetRemoved:t}={}){ol.morph(e,n,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=dr.get(o);r?.destroy&&r.destroy(),t?.(o)}}})}var Ta="hha:upgrade-check:";function Wn(e,n){let t=e.querySelector(`meta[name="${n}"]`),o=t?t.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function ws(e){if(typeof e!="string")return null;let n=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(n)?n.split(".").map(Number):null}function rl(e,n){let t=ws(e),o=ws(n);if(!t||!o)return!1;let r=Math.max(t.length,o.length);for(let c=0;c<r;c++){let l=t[c]||0,i=o[c]||0;if(l!==i)return l>i}return!1}function Aa(e){try{let n=globalThis.localStorage.getItem(e);return n?JSON.parse(n):null}catch{return null}}function Sa(e,n){try{globalThis.localStorage.setItem(e,JSON.stringify(n))}catch{}}async function xs({force:e=!1,doc:n,loc:t,fetchFn:o,now:r,ttlMs:c=864e5}={}){if(n=n||(typeof document<"u"?document:null),t=t||(typeof location<"u"?location:null),o=o||(u=>fetch(u)),r=r??Date.now(),!n)return null;let l=Wn(n,"hyper-source");if(!l)return null;let i=Wn(n,"hyper-version"),s;try{s=new URL(l,t?t.href:void 0)}catch{return null}if(t&&s.origin===t.origin&&s.pathname===t.pathname)return null;let a=`${Ta}${s.href}:${i||"none"}`,h,f=e?null:Aa(a);if(f&&typeof f.checkedAt=="number"&&r-f.checkedAt<c)h=f.sourceVersion;else{try{let u=await o(s.href);if(!u.ok)throw new Error(`HTTP ${u.status}`);let g=await u.text(),b=new DOMParser().parseFromString(g,"text/html");h=Wn(b,"hyper-version")}catch{h=null}Sa(a,{checkedAt:r,sourceVersion:h})}return h?{available:rl(h,i||"0.0.0"),currentVersion:i,sourceVersion:h,sourceUrl:s.href}:null}var vr=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],ks=new Set(vr),sl=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),zo=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Vn={};Lr(Vn,{EmptyListInsert:()=>Yo,MAX_RULE_DEPTH:()=>Co,MaxRuleDepthExceeded:()=>uo,NoRulesTag:()=>Ts,RuleTargetReadOnly:()=>Xo,RulesParseError:()=>Io,ShapeMismatch:()=>Go,UnknownRulesVersion:()=>fo,WriteRefused:()=>Jo,WriteRejected:()=>As});var Io=class extends Error{constructor(n,t){super(n),this.name="RulesParseError",this.cause=t}},fo=class extends Error{constructor(n){super(`unknown rules version: ${n}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=n}},Co=20,uo=class extends Error{constructor(n){super(`rule depth exceeded ${Co} at path: ${n.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=n}},Go=class extends Error{constructor(n){super(`shape mismatch: ${n.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=n}},Yo=class extends Error{constructor(n){super(`cannot add items to empty list at "${n.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=n}},Xo=class extends Error{constructor(n){super(`cannot write to read-only DOM property "${n}"`),this.name="RuleTargetReadOnly",this.target=n}},Jo=class extends Error{constructor(n){super(`write refused: ${n.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=n}},Ts=class extends Error{constructor(n){super(`no <script data-rules-name~="${n}"> rules tag in this document`),this.name="NoRulesTag",this.token=n}},As=class extends Error{constructor(n,t){super(`write rejected: ${n.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=n,this.unmatched=t}};function _n(e,n,t,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Ss(e,n,t,{depth:0,path:[]},o)}function Ss(e,n,t,o,r){if(o.depth>Co)throw new uo(o.path);if(typeof t=="string")return Na(e,n,t,o,r);if(Array.isArray(t)){let[c,l]=t,i=e.find(n,c,r);return ll(r,o,i),i.map((s,a)=>Ss(e,s,l,{depth:o.depth+1,path:[...o.path,a]},r))}if(typeof t=="object"&&t!==null){let c={};for(let[l,i]of Object.entries(t))c[l]=Ss(e,n,i,{depth:o.depth+1,path:[...o.path,l]},r);return c}return null}function Na(e,n,t,o,r){if(t.endsWith("[]")){let i=t.slice(0,-2),s=e.find(n,i,r);return ll(r,o,s),s.map(a=>e.text(a))}if(t.startsWith("@"))return il(e,n,t.slice(1));let c=On(t);if(c!==-1){let i=t.slice(0,c),s=t.slice(c+1),a=i?e.find(n,i,r):[n];return a.length===0?null:il(e,a[0],s)}if(t===".")return e.text(n);let l=e.find(n,t,r);return l.length===0?null:e.text(l[0])}function ll(e,n,t){if(typeof e.onRowsRead=="function")try{e.onRowsRead(n.path.slice(),t)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${n.path.join(".")||"(root)"}"`,o)}}function il(e,n,t){if(ks.has(t)){let r=e.prop(n,t);return r==null?null:String(r)}let o=e.attr(n,t);return o||null}var cl=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),va=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),al=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function Ns(e,n){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(n)||e.hasAttribute?.(n))}function Oa(e,n){if(Ns(e,n))return!0;for(let[t,o]of Object.entries(va))if(o.includes(n)&&Ns(e,t))return!0;return!1}function Qo(e){let n=cl[e];if(!n)throw new Error(`Unknown region capability: ${e}`);return[...n.tokens,...n.bundles].flatMap(t=>[`[clay~="${t}"]`,`[${t}]`]).join(", ")}function Ma(e,n){let t=e&&e.nodeType===1?e:e?.parentElement;for(;t&&t.nodeType===1;){let o=cl[n];if(!o)throw new Error(`Unknown region capability: ${n}`);if(o.tokens.some(r=>Oa(t,r))||o.bundles.some(r=>Ns(t,r)))return t;t=t.parentElement}return null}function fl(e,n){return!!Ma(e,n)}var Ea=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function ul(e,n){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let t=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in n&&e.tagName!=="OPTION"&&t!=="checkbox"&&t!=="radio"&&t!=="file"&&(n.value=e.value),e.tagName==="INPUT"&&(t==="checkbox"||t==="radio")&&(n.checked=e.checked),e.tagName==="OPTION"&&(n.selected=e.selected),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)n.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in n&&(n.indeterminate=e.indeterminate)}function dl(e,n,t,o){if(o)return!!e.closest?.(n);let r=e;for(;r?.nodeType===1;){if(r.matches(n))return!0;if(r===t)break;r=r.parentElement}return!1}function hl(e,n,t,o,r,c,l,i){if(e.nodeType===1&&((l?fl(e,t):dl(e,o,c,!1))||r&&(l&&e!==c?e.matches(r):dl(e,r,c,l))))return null;let s=n.importNode(e,!1);i.cloneToLive.set(s,e),i.liveToClone.set(e,s);let a=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,h=s.nodeType===1&&s.tagName==="TEMPLATE"?s.content:s;a!==e&&(i.cloneToLive.set(h,a),i.liveToClone.set(a,h));for(let f of a.childNodes||[]){let u=hl(f,n,t,o,r,c,l,i);u&&(h.appendChild(u),f.nodeType===1&&ul(f,u))}return e.nodeType===1&&ul(e,s),s}function Zo(e,{capability:n="data",exclude:t=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let c=r.implementation.createHTMLDocument(""),l=new WeakMap,i=new WeakMap,s=e.nodeType===9?e.documentElement:e;t&&c.documentElement.matches(t);let a=Qo(n),h=hl(s,c,n,a,t,s,o,{cloneToLive:l,liveToClone:i});e.nodeType===9&&h&&(c.replaceChild(h,c.documentElement),i.set(e,c),l.set(c,e));let f=u=>{if(Ea.test(u))throw new Error(`Filtered content queries do not support stateful selector: ${u}`)};return{root:h,document:c,capability:n,selector:Qo(n),cloneToLive:l,liveToClone:i,original(u){return l.get(u)||null},cloneOf(u){return i.get(u)||null},query(u,g=h){return f(u),Array.from(g.querySelectorAll(u),b=>l.get(b)||b)},text(u=h){return(u===h?h:i.get(u))?.textContent||""},html(u=h){return(u===h?h:i.get(u))?.innerHTML??""},clone(u=h){let g=u===h?h:i.get(u);return g?c.importNode(g,!0):null}}}function pl(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Ia(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var on={semanticExclude:!0,find(e,n,t={}){let o=Ia(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(n));t.includeRulesTag||(r=r.filter(i=>!pl(i)));let c=[];t.skip&&c.push(t.skip);let l=t.templateAttr===null?null:t.templateAttr||"cms-template";if(l&&c.push("["+l+"]"),c.length){let i=c.join(", ");r=r.filter(s=>!s.closest||!s.closest(i))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,n){if(n===void 0)return(e.textContent||"").trim();e.textContent=n},attr(e,n,t){if(t===void 0)return e.hasAttribute&&e.hasAttribute(n)?e.getAttribute(n):null;e.setAttribute(n,t)},removeAttr(e,n){e&&e.removeAttribute&&e.removeAttribute(n)},prop(e,n,t){if(t===void 0){let o=e?e[n]:void 0;return o!==void 0?o:null}e[n]=t},clone(e){return e.cloneNode(!0)},insertAt(e,n,t){let o=e.children[t]||null;e.insertBefore(n,o)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,n){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=n;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let n=0;return e.id&&(e.removeAttribute("id"),n++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),n++}),n},sameNode(e,n){return e===n}};function eo(e,n={}){if(n.exclude===null)return on;let t=[Qo("data"),n.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!n._write&&!r?.matches?.(t)&&!r?.querySelector?.(t)&&!o?.querySelector?.(t))return on;let c=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,i=null,s=()=>i||(i=Zo(c,{capability:"data",exclude:n.exclude||null})),a=b=>{let A=s();return b===e?A.cloneOf(e):A.cloneOf(b)||b},h=b=>i?.original(b)||b,f=(b,A)=>{s().liveToClone.set(b,A),s().cloneToLive.set(A,b);let p=b.childNodes||[],m=A.childNodes||[];for(let y=0;y<Math.min(p.length,m.length);y++)f(p[y],m[y])},u=(b,A,p,m)=>{let y=Array.from(b.childNodes).filter(E=>i.cloneOf(E)),S=y[0];for(;S&&y.includes(S);)S=S.nextSibling;for(let E of y)E.remove();if(p==="innerHTML"){let E=l.createElement("template");E.innerHTML=m;for(let N of Array.from(E.content.childNodes))b.insertBefore(N,S||null)}else b.insertBefore(l.createTextNode(m),S||null);let O=Zo(b,{capability:"data",exclude:n.exclude||null});A.replaceChildren(...Array.from(O.root?.childNodes||[]));let M=E=>{let N=O.original(E);N&&(i.liveToClone.set(N,E),i.cloneToLive.set(E,N));for(let L of Array.from(E.childNodes||[]))M(L)};for(let E of Array.from(A.childNodes))M(E)},g={...on,find(b,A,p={}){let m=a(b);if(!m?.querySelectorAll)return[];let y=s().query(A,m);p.includeRulesTag||(y=y.filter(O=>!pl(O)));let R=[];p.skip&&R.push(p.skip);let S=p.templateAttr===null?null:p.templateAttr||"cms-template";if(S&&R.push(`[${S}]`),R.length){let O=R.join(", ");y=y.filter(M=>!M.closest?.(O))}return y},parent(b){let A=a(b)?.parentElement;return A?h(A):null},children(b){return Array.from(a(b)?.children||[],h)},text(b,A){if(A===void 0){let y=h(b);return!y?.matches?.(t)&&!y?.querySelector?.(t)?on.text(y):(a(b)?.textContent||"").trim()}let p=h(b);if(!p?.matches?.(t)&&!p?.querySelector?.(t)&&!i){on.text(p,A);return}let m=s().cloneOf(p);m?u(p,m,"textContent",A):on.text(p,A)},attr(b,A,p){let m=h(b);if(p===void 0)return on.attr(m,A);on.attr(m,A,p);let y=i?.cloneOf(m);y&&(on.attr(y,A,p),Zo(m,{capability:"data",exclude:n.exclude||null}).root===null&&(y.remove(),i.liveToClone.delete(m),i.cloneToLive.delete(y)))},removeAttr(b,A){let p=h(b);on.removeAttr(p,A);let m=i?.cloneOf(p);m&&on.removeAttr(m,A)},prop(b,A,p){let m=h(b);if(p===void 0)return A==="innerHTML"||A==="outerHTML"||A==="textContent"||A==="innerText"?on.prop(a(m),A):on.prop(m,A);let y=A==="innerHTML"||A==="textContent"||A==="innerText",R=y?s().cloneOf(m):i?.cloneOf(m);R&&y?u(m,R,A,p):(on.prop(m,A,p),R&&on.prop(R,A,p))},clone(b){let A=a(b);return A===b?on.clone(b):l.importNode(A,!0)},insertAt(b,A,p){let m=h(b),R=g.children(m)[p]||(()=>{for(let M=m.children.length-1;M>=0;M--){let E=m.children[M];if(s().cloneOf(E))return E.nextElementSibling}return m.firstElementChild})(),S=h(A);m.insertBefore(S,R||null);let O=s().cloneOf(m);if(O){let M=s().cloneOf(S);M||(M=l.importNode(S,!0),f(S,M));let E=Array.from(O.children);O.insertBefore(M,E[p]||null)}},remove(b){let A=h(b),p=s().cloneOf(A);on.remove(A),p&&on.remove(p)},replaceWith(b,A){let p=h(b),m=s().cloneOf(p),y=on.replaceWith(p,A);if(m){let R=Zo(y,{capability:"data",exclude:n.exclude||null});if(!R.root)m.remove();else{m.replaceWith(R.root);let S=O=>{let M=R.original(O);M&&(i.liveToClone.set(M,O),i.cloneToLive.set(O,M));for(let E of Array.from(O.childNodes||[]))S(E)};S(R.root)}}return y}};return g}var Cn=on;function vs(e){try{return JSON.parse(e)}catch(n){throw new Io(`Invalid strict JSON: ${n.message}`,n)}}function ho(e){try{return JSON.parse(e)}catch{}let n={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(r){let c=[],l=0;for(;l<r.length;){let i=r[l];if(/\s/.test(i)){l++;continue}if("{}".includes(i)){c.push({type:i,value:i}),l++;continue}if(i==="["){let f=!1,u=l+1;for(;u<r.length&&/\s/.test(r[u]);)u++;if(u<r.length&&/[a-zA-Z_]/.test(r[u])&&(f=!0),!f){c.push({type:i,value:i}),l++;continue}}if(i==="]"){c.push({type:i,value:i}),l++;continue}if(i===":"){c.push({type:n.COLON,value:i}),l++;continue}if(i===","){c.push({type:n.COMMA,value:i}),l++;continue}if(i==='"'||i==="'"){let f=i,u=l+1;for(;u<r.length&&r[u]!==f;)r[u]==="\\"&&u++,u++;c.push({type:n.STRING,value:r.substring(l+1,u),quoted:!0,sourceQuote:f}),l=u+1;continue}let s=l,a;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let f=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],u=!1;for(let g of f){let b=g.substring(1);if(r.substring(s+1,s+1+b.length)===b){u=!0,s+=b.length;break}}if(!u)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let f=r[s];for(s++;s<r.length&&r[s]!==f;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;a=r.substring(l,s);let h=n.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(a)?h=n.NUMBER:a==="true"||a==="false"||a==="null"?h=n.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(a)&&(h=n.SELECTOR),c.push({type:h,value:a,quoted:!1}),l=s}return c}function o(r){let c="";for(let l=0;l<r.length;l++){let i=r[l];if("{}".includes(i.type)||"[]".includes(i.type)){c+=i.value;continue}if(i.type===n.COLON){c+=i.value;continue}if(i.type===n.COMMA){let s=r[l+1];if(s&&(s.type==="}"||s.type==="]"))continue;c+=i.value;continue}if(i.type===n.STRING&&i.quoted){let s=i.value;i.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(a,h)=>h.length%2===0?h+'\\"':a)),c+=`"${s}"`;continue}if(i.type===n.NUMBER||i.type===n.BOOLEAN){c+=i.value;continue}if(i.type===n.SELECTOR||i.type===n.IDENTIFIER){c+=`"${i.value}"`;continue}c+=`"${i.value}"`}return c}try{let r=t(e),c=o(r);return JSON.parse(c)}catch(r){throw new Io("Invalid extraction rules syntax: "+r.message,r)}}var Os="1",ml=/^[a-zA-Z0-9_-]+$/;function Ro(e,n,t){let o;if(t===void 0)o="script[data-rules-name]";else{if(typeof t!="string"||!ml.test(t))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(t)} (must match ${ml})`);o=`script[data-rules-name~="${t}"]`}let r=e.find(n,o,{includeRulesTag:!0});if(r.length===0)return null;t!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${t}"; using the first.`);let c=r[0],l=e.attr(c,"data-rules-version");if(l!==Os)throw new fo(l);return{rules:ho(e.text(c)),tagNode:c}}var Ca="script[data-rules-name]";function gl(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function er(e,n){let t=e.find(n,Ca,{includeRulesTag:!0}),o=new Set,r=[];for(let c of t){let l=gl(e.attr(c,"data-rules-name"));if(!l)continue;if(o.has(l)){console.warn(`hyper-html-api: duplicate rules tag name "${l}"; using the first.`);continue}let i=e.attr(c,"data-rules-version");if(i!==Os)throw new fo(i);o.add(l),r.push({name:l,rules:ho(e.text(c))})}return r}function Or(e,n){let t={};for(let{name:o,rules:r}of er(e,n))t[o]=_n(e,n,r);return t}function Ms(e){let n=e||document,t=n.nodeType===9?n:n.ownerDocument||n;return{dataByName:Or(Cn,n),version:Wn(t,"hyper-version")}}var Lo=class extends Error{constructor(n,t){super(`could not fetch upgrade source: ${n}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=n,this.cause=t}},tr=class extends Error{constructor(n){super(`upgrade source has no rules tags; refusing to drop all existing data: ${n}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=n}},to=class extends Error{constructor(n,t){super(n),this.name="UpgradeTransformInvalid",this.cause=t}},nr=class extends Error{constructor(n){super(`found ${n} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=n}};var bl="text/hyper-upgrade";function Es(e,n){let t=e.find(n,`script[type="${bl}"]`);if(t.length===0)return null;if(t.length>1)throw new nr(t.length);return e.text(t[0])||null}var Ra=new Function("url","return import(url)");async function Is(e){let n=new Blob([e],{type:"text/javascript"}),t=URL.createObjectURL(n),o;try{o=await Ra(t)}catch(r){throw new to(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(t)}if(typeof o.default!="function")throw new to("transform must `export default` a function");return o.default}function xl(e,n,t,o){let r=e.length,c=n.length,l=new Array(r).fill(-1);if(o){let p=new Set;for(let m=0;m<r;m++){let y=o[m];!(y>=0&&y<c)||p.has(y)||(l[m]=y,p.add(y))}}if(r===0||c===0)return l;let i=e.map(p=>yl(p,t)),s=n.map(p=>yl(p,t)),a=new Array(c).fill(!1);for(let p of l)p>=0&&(a[p]=!0);let h=new Map;s.forEach((p,m)=>{a[m]||h.set(p,h.has(p)?-1:m)});let f=new Map;i.forEach((p,m)=>{l[m]>=0||f.set(p,(f.get(p)||0)+1)}),i.forEach((p,m)=>{if(l[m]>=0||f.get(p)!==1)return;let y=h.get(p);y===void 0||y===-1||a[y]||(l[m]=y,a[y]=!0)});let u=[];for(let p=0;p<r;p++)l[p]<0&&u.push(p);let g=[];for(let p=0;p<c;p++)a[p]||g.push(p);if(u.length===0||g.length===0)return l;let b=r*c+1,A=(p,m)=>La(e[p],n[m],t)*b+Math.abs(p-m);for(let[p,m]of Pa(u,g,A))l[p]=m;return l}var kl=e=>typeof e=="object"&&e!==null;function yl(e,n){if(!kl(n))return e==null?" null":String(e);let t=Object.keys(n);return JSON.stringify(t.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function La(e,n,t){if(!kl(t))return e===n?0:1;let o=Object.keys(t);if(o.length===0)return 0;let r=0;for(let c of o){let l=JSON.stringify(e?.[c]),i=JSON.stringify(n?.[c]);l!==i&&r++}return r}function Pa(e,n,t){return e.length<=n.length?wl(e,n,t,!1):wl(n,e,(o,r)=>t(r,o),!0)}function wl(e,n,t,o){let r=e.length,c=n.length,l=[];for(let f=0;f<=r;f++)l.push(new Float64Array(c+1).fill(1/0));let i=[];for(let f=0;f<=r;f++)i.push(new Uint8Array(c+1));for(let f=0;f<=c;f++)l[r][f]=0;for(let f=r-1;f>=0;f--)for(let u=c-1;u>=0;u--){let g=t(e[f],n[u])+l[f+1][u+1],b=l[f][u+1];g<=b?(l[f][u]=g,i[f][u]=1):l[f][u]=b}let s=[],a=0,h=0;for(;a<r&&h<c;)i[a][h]&&(s.push(o?[n[h],e[a]]:[e[a],n[h]]),a++),h++;return s}function Rs(e,n,t,o,r,c,l,i={}){let s=e.find(n,t,i);if(r.length===0){s.forEach(O=>e.remove(O)),Cs(i,"onRowsApplied",c.path,[]);return}let a=r.length>s.length,h=s[0]||null;if(a&&!h&&(h=Ua(e,n,t,i),!h))throw new Yo(c.path);let f=s.map(O=>Ba(e,O,o,i)),u=null;if(a&&h){u=e.clone(h),i.templateAttr&&e.removeAttr(u,i.templateAttr);let O=e.stripIds(u);O>0&&console.warn(`[hyper-html-api] stripped ${O} id attribute(s) from cloned template at "${c.path.join(".")||"(root)"}"`)}let g=xl(r,f,o,ja(e,s,r,c,i)),b=s[0]||h,A=e.parent(b),p=s.length>0?Tl(e,A,b):0,m=Ha(e,s),y=new Set,R=[],S=r.map((O,M)=>{let E=g[M];if(E>=0)return y.add(E),R.push(!1),s[E];R.push(!0);let N=e.clone(u);return e.stripIds(N),N});s.forEach((O,M)=>{y.has(M)||e.remove(O)}),m?S.forEach((O,M)=>{let E=p+M;e.children(A).findIndex(j=>e.sameNode(j,O))!==E&&e.insertAt(A,O,E)}):Wa(e,S,R,A,p),Da(e,S,o,r,c,l,i),Cs(i,"onRowsApplied",c.path,S)}function Cs(e,n,t,o){if(typeof e[n]=="function")try{return e[n](t.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${n} threw at "${t.join(".")||"(root)"}"`,r);return}}function ja(e,n,t,o,r){let c=Cs(r,"identifyRows",o.path,t);if(!Array.isArray(c))return null;let l=new Array(t.length).fill(-1),i=new Set;for(let s=0;s<t.length;s++)if(c[s]){for(let a=0;a<n.length;a++)if(!(i.has(a)||!e.sameNode(n[a],c[s]))){l[s]=a,i.add(a);break}}return l}function Da(e,n,t,o,r,c,l){n.forEach((i,s)=>{if(t===null){let a=o[s],h=a==null?"":String(a);e.text(i)!==h&&e.text(i,h)}else{let a=c(e,i,t,o[s],{depth:r.depth+1,path:[...r.path,s]},l);a&&a!==i&&(n[s]=a)}})}function Ba(e,n,t,o){return t===null?e.text(n):_n(e,n,t,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Tl(e,n,t){let o=e.children(n);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],t))return r;return-1}function Ua(e,n,t,o){if(!o.templateAttr)return null;let r=n;for(;r;){let c=e.find(r,t,{includeRulesTag:!1,templateAttr:null});for(let l of c)if(e.attr(l,o.templateAttr)!=null)return l;r=e.parent(r)}return null}function Ha(e,n){if(n.length<=1)return!0;let t=e.parent(n[0]);if(!t)return!1;let o=e.children(t),r=[];for(let c of n){let l=o.findIndex(i=>e.sameNode(i,c));if(l===-1)return!1;r.push(l)}return r.sort((c,l)=>c-l),r[r.length-1]-r[0]===r.length-1}function Wa(e,n,t,o,r){let c=null,l=r;for(let i=0;i<n.length;i++){if(!t[i]){c=n[i];continue}let s=c?e.parent(c):o;if(!s)continue;let a=c?Tl(e,s,c)+1:l++;e.insertAt(s,n[i],a),c=n[i]}}var Al=new Set(["checked","selected","disabled","readOnly","paused"]);function qn(e,n,t,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let c=[];if(Ls(t,o,[],c),c.length)throw new Go(c);Mr(e,n,t,o,{depth:0,path:[]},r)}function Mr(e,n,t,o,r,c={}){if(r.depth>Co)throw new uo(r.path);if(o===void 0)return n;if(typeof t=="string")return Va(e,n,t,o,r,c);if(Array.isArray(t)){let[l,i]=t;return Rs(e,n,l,i,o,r,Mr,c),n}if(typeof t=="object"&&t!==null){for(let[l,i]of Object.entries(t)){let s=Mr(e,n,i,o==null?o:o[l],{depth:r.depth+1,path:[...r.path,l]},c);s&&s!==n&&(n=s)}return n}return n}function Va(e,n,t,o,r,c){if(t.endsWith("[]")){let s=t.slice(0,-2);return Rs(e,n,s,null,o,r,Mr,c),n}if(t.startsWith("@"))return Nl(e,n,t.slice(1),o);let l=On(t);if(l!==-1){let s=t.slice(0,l),a=t.slice(l+1),h=s?e.find(n,s,c):[n];return h.length===0||Nl(e,h[0],a,o),n}if(t===".")return Sl(e,n,o),n;let i=e.find(n,t,c);return i.length===0||Sl(e,i[0],o),n}function Sl(e,n,t){let o=t==null?"":String(t);e.text(n)!==o&&e.text(n,o)}function Nl(e,n,t,o){if(zo.has(t)){let c=e.prop(n,t);if(c===o||c!=null&&o!=null&&String(c)===String(o))return n;throw new Xo(t)}if(t==="outerHTML"){let c=o==null?"":String(o);return e.replaceWith(n,c)}if(sl.has(t)){let c=_a(t,o);return e.prop(n,t)!==c&&e.prop(n,t,c),n}let r=o==null?"":String(o);return e.attr(n,t)!==r&&e.attr(n,t,r),n}function _a(e,n){return n==null?Al.has(e)?!1:"":Al.has(e)?n==="false"?!1:!!n:n}function Ls(e,n,t,o){if(n!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(n)?n.forEach((r,c)=>{typeof r=="object"&&r!==null&&o.push({path:rr([...t,c]),expected:"scalar",got:or(r)})}):o.push({path:rr(t),expected:"array",got:or(n)});return}n!==null&&typeof n=="object"&&o.push({path:rr(t),expected:"scalar",got:or(n)});return}if(Array.isArray(e)){if(!Array.isArray(n)){o.push({path:rr(t),expected:"array",got:or(n)});return}let r=e[1];n.forEach((c,l)=>Ls(r,c,[...t,l],o));return}if(typeof e=="object"&&e!==null){if(n===null||Array.isArray(n)||typeof n!="object"){o.push({path:rr(t),expected:"object",got:or(n)});return}for(let[r,c]of Object.entries(e))Ls(c,n[r],[...t,r],o)}}}function or(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function rr(e){return e.join(".")}function sr(e,n){let t={carriedOver:0,discarded:0,listItems:0},o=Ps(n,e,t);return js(n,e,t),{data:o,summary:t}}function Ps(e,n,t){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(n)?(t.listItems+=n.length,t.carriedOver+=n.length,n):void 0:n==null||typeof n=="object"?void 0:(t.carriedOver++,n);if(Array.isArray(e)){let[,o]=e;return Array.isArray(n)?(t.listItems+=n.length,n.map(r=>Ps(o,r,t))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,c]of Object.entries(e)){let l=Ps(c,n?.[r],t);l!==void 0&&(o[r]=l)}return o}}function js(e,n,t){if(n!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof n!="object"||Array.isArray(n))return;let o=new Set(Object.keys(e));for(let r of Object.keys(n))o.has(r)?js(e[r],n[r],t):t.discarded+=po(n[r]);return}if(Array.isArray(e)&&Array.isArray(n)){let o=e[1];n.forEach(r=>js(o,r,t));return}typeof e=="string"&&!e.endsWith("[]")&&typeof n=="object"&&n!==null&&(t.discarded+=po(n))}}function po(e){return e==null?0:Array.isArray(e)?e.reduce((n,t)=>n+po(t),0):typeof e=="object"?Object.values(e).reduce((n,t)=>n+po(t),0):1}function Ds(e,n,t){let o=er(e,n),r={carriedOver:0,discarded:0,listItems:0},c={},l=new Set;for(let{name:i,rules:s}of o){if(l.add(i),!Object.prototype.hasOwnProperty.call(t,i)){c[i]={carriedOver:0,discarded:0,listItems:0};continue}let{data:a,summary:h}=sr(t[i],s);qn(e,n,s,a),c[i]=h,r.carriedOver+=h.carriedOver,r.discarded+=h.discarded,r.listItems+=h.listItems}for(let i of Object.keys(t))l.has(i)||(r.discarded+=po(t[i]));return{totals:r,byName:c,rulesTagCount:o.length}}async function Bs({sourceUrl:e,dataByName:n,fromVersion:t,doc:o,loc:r,fetchFn:c}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),c=c||(m=>fetch(m)),!o)throw new Error("upgrade.run requires a document context");if(e=e||Wn(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let l=new URL(e,r?r.href:void 0);t=t!==void 0?t:Wn(o,"hyper-version"),n=n||Or(Cn,o);let i;try{i=await c(l.href)}catch(m){throw new Lo(l.href,m)}if(!i.ok)throw new Lo(l.href,new Error(`HTTP ${i.status}`));let s=await i.text(),a=new DOMParser().parseFromString(s,"text/html"),h=Wn(a,"hyper-version"),f=n,u=!1,g=Es(Cn,a);if(g){let y=await(await Is(g))(f,{fromVersion:t,toVersion:h});if(!y||typeof y!="object"||Array.isArray(y))throw new to("transform must return a plain object map of { rulesName: data }");f=y,u=!0}let{totals:b,byName:A,rulesTagCount:p}=Ds(Cn,a,f);if(p===0&&Object.keys(f).length>0)throw new tr(l.href);return{html:Fa(a),fromVersion:t,toVersion:h,summary:{transformApplied:u,totals:b,byName:A}}}function Fa(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
6
- `+e.documentElement.outerHTML}var Us=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...al],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]}),Ka=new Set(["textContent","innerText"]);function vl(e){let t=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return t?t[1].toLowerCase():null}var qa=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function Ol(e,n,t=Us){if(!qa.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(t.refusedAttributePrefixes.some(r=>o.startsWith(r)))return`attribute "${o}" can run script`;if(t.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(t.urlAttributes.includes(o)&&n!=null){let r=o==="srcset"?String(n).split(",").map(c=>c.trim().split(/\s+/)[0]).filter(Boolean):[String(n)];for(let c of r){let l=vl(c);if(l&&t.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${o}"`}}return null}function Hs(e,n){let t=e.prop(n,"tagName");return t?String(t).toLowerCase():""}function za(e,n){let t=Hs(e,n)||"node",o=e.attr(n,"id");return o?`<${t}#${o}>`:`<${t}>`}function Ga(e,n,t){let o=n;for(;o;){let r=Hs(e,o);if(r&&t.refusedTargets.includes(r))return r;o=e.parent(o)}return null}function Ml(e,n){return e.find(n,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Ya(e,n){return Hs(e,n)==="script"&&e.attr(n,"data-rules-name")!=null?!0:Ml(e,n)}function Er(e,n=Us){let t=[],o=(s,a)=>(t.push({target:za(e,s),reason:a}),!1),r=s=>{let a=Ga(e,s,n);return a?o(s,`inside <${a}>, which is not content`):!0},c=s=>r(s)?Ml(e,s)?o(s,"a text write here would delete the data rules tag"):!0:!1,l=(s,a,h)=>{if(!r(s))return!1;let f=Ol(a,h,n);return f?o(s,f):!0};return{...e,text(s,a){if(a===void 0)return e.text(s);c(s)&&e.text(s,a)},attr(s,a,h){if(h===void 0)return e.attr(s,a);l(s,a,h)&&e.attr(s,a,h)},prop(s,a,h){if(h===void 0)return e.prop(s,a);if(n.refusedRuleForms.includes(a))return o(s,`"@${a}" writes HTML, only text is allowed`);if(Ka.has(a)){c(s)&&e.prop(s,a,h);return}l(s,a==="className"?"class":a,h)&&e.prop(s,a,h)},remove(s){if(Ya(e,s)){o(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,a){return a===e.prop(s,"outerHTML")||o(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:t,assertClean(){if(t.length)throw new Jo(t.slice())}}}function ir(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function El(e){return e.reduce((n,t)=>typeof t=="number"?`${n}[${t}]`:n?`${n}.${t}`:t,"")}function Ws(e,n,t,o,r={}){let c=[],l=[];function i(a,h,f){if(Array.isArray(a)){let[,u]=a;if(!Array.isArray(h)||!ir(u))return;h.forEach((g,b)=>i(u,g,[...f,b]));return}if(!(!ir(a)||!ir(h)))for(let u of Object.keys(h))Object.prototype.hasOwnProperty.call(a,u)?i(a[u],h[u],[...f,u]):c.push(El([...f,u]))}function s(a,h,f,u){if(f!==void 0){if(typeof h=="string"){if(h.endsWith("[]")||h==="."||h.startsWith("@"))return;let g=On(h),b=g===-1?h:h.slice(0,g);if(!b)return;e.find(a,b,r).length===0&&l.push({path:El(u),selector:b});return}if(!Array.isArray(h)&&ir(h)&&ir(f))for(let[g,b]of Object.entries(h))s(a,b,f[g],[...u,g])}}return i(t,o,[]),s(n,t,o,[]),{unknownKeys:c,unmatched:l}}function Vs(e,n,t){if(t&&typeof t=="object")return{rules:t,tagNode:null};if(typeof t=="string"){let o=n&&n.ownerDocument?n.ownerDocument:n;return Ro(e,o,t)}return null}var lr={extract:(e,n,t={})=>_n(eo(e,t),e,n,t),apply:(e,n,t,o={})=>qn(eo(e,{...o,_write:!0}),e,n,t,o),findRulesIn:(e,n)=>Ro(Cn,e,n),findRules:(e,n)=>Vs(Cn,e,n),bind:(e,n,t={})=>{let o=Vs(Cn,e,n);if(!o){let r=typeof n=="string"?`data-rules-name~="${n}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>_n(eo(e,t),e,o.rules,t),set:r=>qn(eo(e,{...t,_write:!0}),e,o.rules,r,t)}},parseStrict:vs,parseRelaxed:ho,ruleAttrIndex:On,splitRule:bo,errors:Vn,DOM_PROPERTIES:vr},_s=e=>!!e&&typeof e.nodeType=="number";function Il(e){let n=e&&e.ownerDocument?e.ownerDocument:e,t=Ro(Cn,n,"api");if(!t)throw new Vn.NoRulesTag("api");return t.rules}function Ja(e){if(e.nodeType===9)return e;let n=e.ownerDocument?.documentElement;if(n?.contains(e))return n;let t=e;for(;t.parentNode;)t=t.parentNode;return t}function Qa(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let n=e.ownerDocument.createDocumentFragment();for(let t of e.childNodes)n.appendChild(t.cloneNode(!0));return n}function Za(e,n){let t=[];for(;n!==e;){let o=n.parentNode;t.push(Array.prototype.indexOf.call(o.childNodes,n)),n=o}return t.reverse()}function ef(e,n){return n.reduce((t,o)=>t.childNodes[o],e)}function Po(e,n){let t=e.querySelectorAll?Array.from(e.querySelectorAll(n)):[];return e.matches?.(n)&&t.unshift(e),t}function tf(e,n){let t=Po(e,"option"),o=Po(n,"option");t.forEach((s,a)=>o[a].selected=s.selected);let r=Po(e,"input"),c=Po(n,"input");r.forEach((s,a)=>{let h=s.type.toLowerCase();h!=="file"&&(c[a].value=s.value),(h==="checkbox"||h==="radio")&&(c[a].checked=s.checked)});let l=Po(e,"textarea"),i=Po(n,"textarea");l.forEach((s,a)=>i[a].value=s.value)}function Fs(e,n){if(n!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let t=e.startsWith("@")?0:On(e);if(t===-1)return;let o=e.slice(t+1);if(zo.has(o))throw new Vn.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(n))return;n.forEach(t=>Fs(e[1],t));return}if(e&&typeof e=="object"&&n&&typeof n=="object"&&!Array.isArray(n))for(let[t,o]of Object.entries(e))Fs(o,n[t])}}function nf(e,n,t){let o={templateAttr:"cms-template"},r=Ja(e),c=Za(r,e),l=Qa(r);tf(r,l);let i=ef(l,c),s=eo(l,{...o,_write:!0}),a=Ws(s,i,n,t,o);if(a.unknownKeys.length||a.unmatched.length)throw new Vn.WriteRejected(a.unknownKeys,a.unmatched);let h=Er(s);qn(h,i,n,t,o),h.assertClean(),Fs(n,t);let f=Er(eo(r,{...o,_write:!0}));qn(f,e,n,t,o),f.assertClean()}function of(e){if(!(e instanceof Error))return e;let n=e.name||"Error";try{e.code=n}catch{Object.defineProperty(e,"code",{value:n,configurable:!0,enumerable:!0})}return e instanceof Vn.WriteRefused?e.details=e.refusals:e instanceof Vn.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof Vn.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function $s(e,n){let t=_s(e)?e:document,o=_s(e)?n:e;return o===void 0?_n(eo(t),t,Il(t)):lr.bind(t,o).get()}function Ks(e,n,t){try{if(!_s(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=t===void 0?Il(e):lr.bind(e,t).rules;nf(e,o,n)}catch(o){throw of(o)}return e}var Cl={buildForm:jr,bindFormEvents:Dr,scaffold:go,morphForm:ys,path:ur},Rl={checkForUpdate:xs,run:Bs,extractAll:Ms,shapeMatch:sr};var rf={engine:lr,cms:Cl,upgrade:Rl,extractData:$s,applyData:Ks},sf=rf;return _l(lf);})();
1
+ var HyperHtmlApi=(()=>{var Fr=Object.defineProperty;var ec=Object.getOwnPropertyDescriptor;var tc=Object.getOwnPropertyNames;var nc=Object.prototype.hasOwnProperty;var qr=(e,t)=>{for(var n in t)Fr(e,n,{get:t[n],enumerable:!0})},oc=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of tc(t))!nc.call(e,r)&&r!==n&&Fr(e,r,{get:()=>t[r],enumerable:!(o=ec(t,r))||o.enumerable});return e};var rc=e=>oc(Fr({},"__esModule",{value:!0}),e);var Lf={};qr(Lf,{applyData:()=>ii,cms:()=>Xl,default:()=>Rf,engine:()=>mr,extractData:()=>si,upgrade:()=>Zl});var wr={};qr(wr,{fromString:()=>yr,getRuleAtPath:()=>$r,getValueAtPath:()=>qo,parseConfigKey:()=>ic,setAtPath:()=>to,toConfigKey:()=>sc,toString:()=>On});function On(e){return e.map(String).join(".")}function sc(e){return e.map(t=>typeof t=="number"?"*":String(t)).join(".")}function ic(e){return e===""?[]:e.split(".")}function yr(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function $r(e,t){let n=e;for(let o of t){if(n==null||typeof n=="string")return;if(Array.isArray(n)){if(typeof o!="number"&&o!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof o=="number"||!(o in n))return;n=n[o];continue}return}return n}function qo(e,t){let n=e;for(let o of t){if(n==null)return;n=n[o]}return n}function to(e,t,n){if(t.length===0)return n;let[o,...r]=t;if(typeof o=="number"){let c=Array.isArray(e)?[...e]:[];return c[o]=to(c[o],r,n),c}return{...e&&typeof e=="object"?e:{},[o]:to((e||{})[o],r,n)}}function ko(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[n,o]of Object.entries(e))t[n]=ko(o);return t}return""}var xr=new WeakMap;function Cn(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let c=e[r];c==="\\"?r++:n?c===n&&(n=null):c==='"'||c==="'"?n=c:c==="["||c==="("?t++:c==="]"||c===")"?t>0&&t--:c==="@"&&t===0&&(o=r)}return o}function To(e){let t=Cn(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}var lc=new Set(["checked","selected","disabled","readOnly","paused"]);function Kr({rules:e,data:t,appRoot:n,cmsRoot:o}){let r=document.createDocumentFragment(),c={rules:e,appRoot:n,cmsRoot:o};return r.appendChild(Gr({rule:e,value:t,path:[],ctx:c})),r}function zr(e,{rules:t,getData:n,onChange:o}){e.setAttribute("data-hha-form-root",""),fi.set(e,{rules:t,getData:n,onChange:o}),cc()}var fi=new WeakMap,ci=!1;function cc(){ci||(document.addEventListener("input",ai,!0),document.addEventListener("change",ai,!0),document.addEventListener("click",ac,!0),ci=!0)}function ui(e){if(!(e instanceof Element))return null;let t=e.closest("[data-hha-form-root]");return t&&fi.get(t)||null}function ac(e){if(!(e.target instanceof Element))return;let t=e.target.closest("[data-hha-action]");if(!t||e.defaultPrevented)return;let n=ui(t);if(!n)return;let{rules:o,getData:r,onChange:c}=n,l=t.getAttribute("data-hha-action"),s=yr(t.getAttribute("data-hha-path")||"");if(l==="scalar-array-add"){let i=qo(r(),s)||[];c(to(r(),s,[...i,""]),{structural:!0});return}if(l==="object-array-add"){let i=$r(o,s);if(!Array.isArray(i))return;let a=qo(r(),s)||[];c(to(r(),s,[...a,ko(i[1])]),{structural:!0});return}if(l==="array-remove"){if(s.length===0)return;let i=s.slice(0,-1),a=s[s.length-1],p=qo(r(),i)||[];if(typeof a!="number")return;let f=p.filter((u,y)=>y!==a);c(to(r(),i,f),{structural:!0})}}function ai(e){let t=e.target;if(!t?.matches?.("input, textarea, select"))return;let n=ui(t);if(!n)return;let{getData:o,onChange:r}=n,c=t.closest("[data-hha-path]");if(!c)return;let l=yr(c.getAttribute("data-hha-path")||""),s=t.type==="checkbox"?t.checked:t.value;r(to(o(),l,s),{structural:!1})}function Gr({rule:e,value:t,path:n,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?dc({rule:e,value:t,path:n,ctx:o}):uc({rule:e,value:t,path:n,ctx:o});if(Array.isArray(e))return hc({rule:e,value:t,path:n,ctx:o});if(typeof e=="object"&&e!==null)return fc({rule:e,value:t,path:n,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function fc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",On(n)),n.length>0){let c=document.createElement("div");c.className="form-section-label",c.textContent=kr(n[n.length-1]),r.appendChild(c)}for(let[c,l]of Object.entries(e)){let s=[...n,c],i=t?.[c];r.appendChild(Gr({rule:l,value:i,path:s,ctx:o}))}return r}function uc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",On(n));let c=document.createElement("div");c.className="field-body";let l=document.createElement("label");l.className="field-label",l.textContent=kr(n[n.length-1]||".")+yc(e);let s=mc(e,o.appRoot),i=pc(s,{value:t,rule:e,path:n,appRoot:o.appRoot}),a=i.el;return a.classList.add(s.type==="textarea"?"field-textarea":"field-input"),c.appendChild(l),c.appendChild(a),r.appendChild(c),xr.set(r,i),r}function dc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",On(n));let c=document.createElement("div");c.className="form-section-label",c.textContent=kr(n[n.length-1]),r.appendChild(c);let l=Array.isArray(t)?t:[],s=document.createElement("div");r.appendChild(s),l.forEach((a,p)=>{let f=[...n,p],u=document.createElement("div");u.className="scalar-array-row",u.setAttribute("data-hha-path",On(f));let y=document.createElement("input");y.type="text",y.className="field-input",y.value=a==null?"":String(a);let b=document.createElement("button");b.type="button",b.className="array-remove",b.textContent="\xD7",b.title="remove",b.setAttribute("data-hha-action","array-remove"),b.setAttribute("data-hha-path",On(f)),u.appendChild(y),u.appendChild(b),s.appendChild(u)});let i=document.createElement("button");return i.type="button",i.className="array-add",i.textContent="+ add",i.setAttribute("data-hha-action","scalar-array-add"),i.setAttribute("data-hha-path",On(n)),r.appendChild(i),r}function hc({rule:e,value:t,path:n,ctx:o}){let[,r]=e,c=Array.isArray(t)?t:[],l=document.createElement("div");l.className="form-section",l.setAttribute("data-hha-path",On(n));let s=document.createElement("div");s.className="form-section-label",s.textContent=kr(n[n.length-1]),l.appendChild(s),c.forEach((a,p)=>{let f=[...n,p],u=document.createElement("div");u.className="array-card",u.setAttribute("data-hha-path",On(f));let y=document.createElement("button");y.type="button",y.className="array-remove",y.textContent="\xD7",y.title="remove item",y.setAttribute("data-hha-action","array-remove"),y.setAttribute("data-hha-path",On(f)),u.appendChild(y);let b=Gr({rule:r,value:a,path:f,ctx:o});b.querySelector(".form-section-label")?.remove(),u.appendChild(b),l.appendChild(u)});let i=document.createElement("button");return i.type="button",i.className="array-add",i.textContent="+ add",i.setAttribute("data-hha-action","object-array-add"),i.setAttribute("data-hha-path",On(n)),l.appendChild(i),l}function pc(e,t){let n=bc(e);if(e.type==="select"&&e.options)for(let o of e.options){let r=document.createElement("option");r.value=o.value,r.textContent=o.text,String(t.value)===o.value&&(r.selected=!0),n.appendChild(r)}else e.type==="checkbox"?n.checked=t.value===!0||t.value==="true"||t.value==="checked":(e.type,n.value=t.value==null?"":String(t.value));return{el:n,destroy(){},focus(){n.focus()},validate(){}}}function mc(e,t){let n=null;if(e.startsWith("@")?n=e.slice(1):n=To(e).prop,n&&lc.has(n))return{type:"checkbox"};if(n==="innerHTML")return{type:"textarea"};let o=gc(e,t);if(!o)return{type:"text"};let r=(o.tagName||"").toLowerCase();if(r==="textarea")return{type:"textarea"};if(r==="select")return{type:"select",options:Array.from(o.querySelectorAll("option")).map(s=>({value:s.getAttribute("value")||s.textContent,text:s.textContent.trim()||s.getAttribute("value")||""}))};if(r==="input"){let l=(o.getAttribute("type")||"text").toLowerCase();if(l==="checkbox"||l==="radio")return{type:"checkbox"};if(l==="number")return{type:"number"}}let c=(o.textContent||"").trim();return c.length>60||c.includes(`
2
+ `)?{type:"textarea"}:{type:"text"}}function gc(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=To(e).selector;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function bc(e){if(e.type==="textarea")return document.createElement("textarea");if(e.type==="select")return document.createElement("select");let t=document.createElement("input");return t.type=e.type==="checkbox"?"checkbox":e.type==="number"?"number":"text",t}function kr(e){return typeof e=="number"?`#${e+1}`:String(e).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^\w/,t=>t.toUpperCase())}function yc(e){return` \xB7 ${e}`}function Tr(e,t){if(typeof e=="string"){let n=t&&t.defaultView,o=n&&n.DOMParser||globalThis.DOMParser;return new o().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Yr(e){let t=new Map;return(n,o)=>{if(typeof o!="string")return Tr(o,e);let r=t.get(n);if(r&&r.text===o)return r.doc;let c=Tr(o,e);return t.set(n,{text:o,doc:c}),c}}function di(e,t){let n=t.doctype;if(!n)return!1;let o=e.doctype;if(o&&o.name===n.name&&o.publicId===n.publicId&&o.systemId===n.systemId)return!1;let r=e.implementation.createDocumentType(n.name,n.publicId,n.systemId);return o?e.replaceChild(r,o):e.insertBefore(r,e.documentElement),!0}var Jr=()=>!1;function Xr(e,t=[]){if(typeof e!="function")return Jr;let n=new WeakMap,o=new Set(t);return r=>{if(!r||r.nodeType!==1)return!1;let c=n.get(r);if(c!==void 0)return c;let l=[],s=r,i=!1;for(;s&&s.nodeType===1;){let a=n.get(s);if(a!==void 0){i=a;break}if(l.push(s),e(s,o.has(s))){i=!0;break}if(o.has(s))break;s=s.parentElement}for(let a of l)n.set(a,i);return i}}var $f=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 no(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var wc="~",hi="^";function Zr(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let o=t[wc],r=typeof o=="string"?o.split(",").map(Number):null,c=r&&typeof t[hi]=="string"?t[hi].split(","):null,l=f=>Number.isInteger(f)&&f>=0,s=0,i=!1,a=f=>{let u=f;for(;u>0;){let y=r[s++];if(s>r.length||!l(y))return!1;u+=y-1}return!0},p=(f,u)=>{if(i)return;if(r){let S=s++,g=r[S];if(S>=r.length||!l(g)){i=!0;return}let d=!c||c[S]===f.tagName.toLowerCase();if(!d||g!==f.children.length){let w=d&&t[u];typeof w=="string"&&w&&n.set(f,w),a(g)||(i=!0);return}}let y=t[u];typeof y=="string"&&y&&n.set(f,y);let b=f.children;for(let S=0;S<b.length;S++)p(b[S],u===""?String(S):`${u}.${S}`)};return p(e,""),n}function pi(e){return t=>{for(let n of e){let o=n(t);if(typeof o=="string"&&o!=="")return o}return null}}var kn=pi([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Ar(e,t,n,o=null,r=null){let c=new Map,l=new Set,s=i=>{if(n(i))return;let a=t(i);a&&(c.has(a)?l.add(a):c.set(a,i))};if(o){let i=a=>{for(let p of a.querySelectorAll(o))s(p);for(let p of a.querySelectorAll("template"))p.content&&i(p.content)};s(e),i(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let i=a=>{s(a);let p=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let f=0;f<p.length;f++)i(p[f])};i(e)}for(let i of l)c.delete(i),r&&r.add(i),Qr(i);return c}function Qr(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var xc=new Set(["href","src","name","type","role"]),gi=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function Ao(e,t=5381){let n=t;for(let o=0;o<e.length;o++)n=(n<<5)+n^e.charCodeAt(o);return n>>>0}function mi(e){return e.replace(/\s+/g," ")}var kc=0;function bi({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let o=new WeakMap,r=new WeakMap;function c(v){let I=v.attributes,M=I.length;if(M===0)return{all:"",sig:v.tagName+"|"};let P=[],D="",$=[];for(let W=0;W<M;W++){let B=I[W],x=B.name;t(v,x)||P.push(x+"="+B.value),x==="class"?D=B.value.indexOf(" ")<0?B.value:B.value.split(/\s+/).filter(Boolean).sort().join(" "):xc.has(x)&&$.push(x+"="+B.value)}return P.length>1&&P.sort(),$.length>1&&$.sort(),{all:P.join(""),sig:v.tagName+"|"+D+($.length?"|"+$.join("|"):"")}}function l(v){return v.nodeType===1&&v.tagName==="TEMPLATE"&&v.content?v.content.childNodes:v.childNodes}function s(v){let I=o.get(v);if(I)return I;if(v.nodeType===3)I={hash:"T"+Ao(v.nodeValue),hint:mi(v.nodeValue).slice(0,64),sig:null,tok:null};else if(v.nodeType===8)I={hash:"C"+Ao(v.nodeValue),hint:"",sig:null,tok:null};else if(v.nodeType===1){let M=c(v),P=Ao(v.tagName+""+M.all),D="";for(let $ of a(v))if($.nodeType===1){let W=s($);P=Ao(W.hash,P),D.length<64&&(D+=" "+W.hint)}else P=Ao(p($),P),$.kind==="text"&&D.length<64&&(D+=$.value.slice(0,64));I={hash:"E"+P,hint:mi(D).trim().slice(0,64),sig:M.sig,tok:null}}else I={hash:"N"+v.nodeType,hint:"",sig:null,tok:null};return o.set(v,I),I}function i(v){if(!v.tok){v.tok=new Set;for(let I of v.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))I&&v.tok.add(I)}return v.tok}function a(v){let I=r.get(v);if(I)return I;I=[];let M=null,P=()=>{M&&(M.value=M.nodes.map(D=>D.nodeValue).join(""),I.push(M),M=null)};for(let D of l(v)){if(D.nodeType===3){M||(M={kind:"text",nodes:[],value:"",parent:v,hash:void 0}),M.nodes.push(D);continue}P(),D.nodeType===8?I.push({kind:"comment",nodes:[D],value:D.nodeValue,parent:v,hash:void 0}):D.nodeType===1&&!e(D)&&I.push(D)}return P(),r.set(v,I),I}function p(v){return v.nodeType===1?s(v).hash:(v.hash===void 0&&(v.hash=(v.kind==="text"?"T":"C")+Ao(v.value)),v.hash)}function f(v,I){let M=i(s(v)),P=i(s(I));if(M.size===0&&P.size===0)return{coef:1,share:1};if(M.size===0||P.size===0)return null;let D=0;for(let $ of M)P.has($)&&D++;return{coef:D/Math.min(M.size,P.size),share:D/Math.max(M.size,P.size)}}function u(v,I){let M=f(v,I);return!!M&&M.coef>=.5}let y=new WeakMap;function b(v){let I=y.get(v);if(I)return I;I=[];for(let M of v.attributes)t(v,M.name)||I.push([M.namespaceURI||"",M.localName,M.value]);return I.sort((M,P)=>M[0]<P[0]?-1:M[0]>P[0]?1:M[1]<P[1]?-1:M[1]>P[1]?1:0),y.set(v,I),I}let S=new WeakMap;function g(v,I){if(v===I)return!0;if(p(v)!==p(I))return!1;let M=S.get(v);if(M&&M.has(I))return M.get(I);let P=S.get(I);if(P&&P.has(v))return P.get(v);let D=d(v,I),$=D===!0;return D===!1&&n&&n.hashRejected++,M||S.set(v,M=new WeakMap),M.set(I,$),$}function d(v,I){if(v.nodeType===1){if(I.nodeType!==1||v.tagName!==I.tagName||v.namespaceURI!==I.namespaceURI)return!1;let M=b(v),P=b(I);if(M.length!==P.length)return!1;for(let W=0;W<M.length;W++)if(M[W][0]!==P[W][0]||M[W][1]!==P[W][1]||M[W][2]!==P[W][2])return!1;let D=a(v),$=a(I);if(D.length!==$.length)return!1;for(let W=0;W<D.length;W++){if(p(D[W])!==p($[W]))return!1;if(!g(D[W],$[W]))return kc}return!0}return I.nodeType===1?!1:v.kind===I.kind&&v.value===I.value}let w=new WeakMap,O=new Map,T=0;function k(v){let I=w.get(v);if(I)return I;let M=p(v),P=O.get(M);P||O.set(M,P=[]);let D=P.find($=>g($.unit,v));return I=D?D.key:"K"+T++,D||P.push({unit:v,key:I}),w.set(v,I),I}return{meta:s,unitsOf:a,unitHash:p,similar:u,score:f,childrenOf:l,equalUnits:g,exactUnitKey:k,ignored:e}}var yi=16,Tc=2e3,Ac=3,es={align:0,certifyVisited:0,certifyScheduled:0};function ts(e,t,n){let{meta:o,unitsOf:r,unitHash:c,similar:l,score:s,childrenOf:i,equalUnits:a,ignored:p}=n.analyzer,f=n.baseId||(()=>null),u=n.sideId||(()=>null),y=n.baseKey||(()=>null),b=n.sideKey||(()=>null),S=n.baseDropped||new Set,g=n.sideDropped||new Set,d=n.stats||null,w=d?new Set:null,O=d?new Set:null,T=new Map,k=new Map,v=new Set,I=new Map,M=new Set,P=new Set,D=new Set,$=[],W=[],B=[],x=[],A=Tc,X=new Map,H=new Map,q=(U,Y)=>{T.set(U,Y),k.set(Y,U)},Ee=new Set,Me=new Set,je=null,ae=U=>{let Y=U.nodeType?U.parentNode:U.parent;if(!Y||Y.nodeType!==11)return Y;if(!je){je=new WeakMap;let he=ge=>{for(let de of ge.querySelectorAll("template"))de.content&&(je.set(de.content,de),he(de.content))};for(let ge of[e,t])he(ge.tagName==="TEMPLATE"&&ge.content?ge.content:ge)}return je.get(Y)||null},Ae=(U,Y)=>{for(let he=ae(U);he&&!Ee.has(he);he=ae(he))Ee.add(he);for(let he=ae(Y);he&&!Me.has(he);he=ae(he))Me.add(he)},_e=U=>{for(let Y=ae(U);Y;Y=ae(Y))if(T.has(Y))return P.has(Y);return!1},ve=U=>{for(let Y=ae(U);Y;Y=ae(Y)){let he=k.get(Y);if(he!==void 0)return P.has(he)}return!1},N=U=>!!U&&U.nodeType===1,J=(U,Y)=>{let he=I.get(U);return!!he&&he.has(Y)},le=U=>gi.has(U.tagName),oe=n.comparisons||n.scope,Re=(U,Y)=>{if(oe){if(oe.same.get(U)===Y)return!0;if(oe.differ.get(U)===Y)return!1}if(!U.isEqualNode(Y))return!1;if(U.tagName==="TEMPLATE")return a(U,Y);let he=U.getElementsByTagName("template");if(he.length===0)return!0;let ge=Y.getElementsByTagName("template");if(he.length!==ge.length)return!1;for(let de=0;de<he.length;de++)if(!a(he[de],ge[de]))return!1;return!0},Be=(U,Y)=>{let he=f(U);if(!he)return!0;let ge=u(Y);return!ge||he===ge},Se=U=>{let Y=y(U);return Y&&n.baseIndex.get(Y)===U&&!g.has(Y)?Y:null},nt=U=>{let Y=b(U);return Y&&n.sideIndex.get(Y)===U&&!S.has(Y)?Y:null},Je=(U,Y)=>{let he=Se(U);if(!he)return!0;let ge=nt(Y);return!ge||he===ge},ht=globalThis.__hyperMorphProfile,Ge=ht?performance.now():0;ht&&!n.scope&&(o(e),o(t),ht.meta=(ht.meta||0)+(performance.now()-Ge),Ge=performance.now()),q(e,t);let st=new Set;for(let[U,Y]of n.baseIndex){let he=n.sideIndex.get(U);he&&he.tagName===Y.tagName&&!T.has(Y)&&!k.has(he)&&(q(Y,he),Ae(Y,he),st.add(Y))}if(st.size){let U=[];if(n.scope)for(let de of n.scope.chain)st.has(de)&&U.push(de);let Y=[n.scope?n.scope.root:e];for(;Y.length;){let de=Y.pop();st.has(de)&&U.push(de);let ee=i(de);for(let te=ee.length-1;te>=0;te--)ee[te].nodeType===1&&Y.push(ee[te])}let he=new Set;for(let de=U.length-1;de>=0;de--){let ee=U[de];n.scope&&n.scope.onChain.has(ee)?he.add(ee):Bt(ee,T.get(ee),he)?(P.add(ee),D.add(ee),d&&d.certificationPairs++):he.add(ee)}let ge=new Set;for(let de of U)P.has(de)&&!ge.has(de)&&Mt(de,ge)}n.scope&&n.scope.head&&Yt(n.scope.head[0],n.scope.head[1]);function Mt(U,Y){let he=[U];for(;he.length;){let ge=he.pop();if(!Y.has(ge)){Y.add(ge),E(ge);for(let de of r(ge))N(de)&&T.has(de)&&he.push(de)}}}x.push([e,t]);for(let[U,Y]of T)N(U)&&U!==e&&x.push([U,Y]);return Ct(),It(),ht&&(ht.align=(ht.align||0)+(performance.now()-Ge)),{map:T,reverse:k,moved:M,identical:P,pairIdenticalChildren:E,weak:v,unpair:yt,rematch:It,insertedByHash:Nt,refused:O,identityPaired:st};function It(){Ne(),Ct();for(let U=0;U<B.length;){let Y=B.length;Et(U,Y),U=Y,Ct(),Ne(),Ct()}}function yt(U){let Y=T.get(U);if(!Y)return;I.has(U)||I.set(U,new Set),I.get(U).add(Y);let he=(de,ee)=>{T.delete(de),k.delete(ee),M.delete(de),P.delete(de),v.delete(de),D.delete(de)},ge=(de,ee)=>{for(let te of r(de)){let K=T.get(te);!K||st.has(te)||!(N(K)?ee.contains(K):ee.contains(K.nodes[0]))||(he(te,K),N(te)&&ge(te,K))}};he(U,Y),N(U)&&ge(U,Y),$.push(U),W.push(Y)}function Nt(){let U=new Map;for(let Y of new Set(W)){if(k.has(Y))continue;let he=o(Y).hash;U.has(he)||U.set(he,[]),U.get(he).push(Y)}return U}function Ct(){for(;x.length;){let[U,Y]=x.shift();T.get(U)!==Y||D.has(U)||P.has(U)||fn(U,Y)}}function _t(U,Y){if(!le(U))for(let he of r(U))N(he)&&(Y.push(he),_t(he,Y))}function fn(U,Y){D.add(U);let he=r(U),ge=r(Y);es.align+=he.length+ge.length,X=new Map,H=new Map;for(let ne=0;ne<he.length;ne++)X.set(he[ne],ne);for(let ne=0;ne<ge.length;ne++)H.set(ge[ne],ne);if(U.tagName==="HTML")for(let ne of["HEAD","BODY"]){let xe=he.find(Le=>N(Le)&&Le.tagName===ne),Ie=ge.find(Le=>N(Le)&&Le.tagName===ne);xe&&Ie&&!T.has(xe)&&!k.has(Ie)&&q(xe,Ie)}for(let ne=0;ne<he.length&&ne<ge.length;ne++){let xe=he[ne],Ie=ge[ne];T.has(xe)||k.has(Ie)||(N(xe)?N(Ie)&&xe.tagName===Ie.tagName&&Re(xe,Ie)&&Yt(xe,Ie):!N(Ie)&&xe.kind===Ie.kind&&xe.value===Ie.value&&Yt(xe,Ie))}ie(he,ge);let de=he.filter(ne=>!T.has(ne)),ee=ge.filter(ne=>!k.has(ne));de.length&&ee.length&&(wn(de,ee),R(de,ee),V(de,ee,he,ge),ue(he,ge));let te=!1,K=!1;for(let ne of he){if(!T.has(ne)){N(ne)&&($.push(ne),_t(ne,$),te=!0);continue}N(ne)&&!P.has(ne)&&x.push([ne,T.get(ne)])}for(let ne of ge)!k.has(ne)&&N(ne)&&(W.push(ne),_t(ne,W),K=!0);te&&K&&B.push([U,Y])}function Et(U,Y){for(let he=U;he<Y;he++){let[ge,de]=B[he];if(T.get(ge)!==de)continue;let ee=r(ge),te=r(de),K=new Map,ne=new Map,xe=null;for(let Ie of ee)N(Ie)&&(T.has(Ie)?xe=Ie:(K.has(xe)||K.set(xe,[]),K.get(xe).push(Ie)));xe=null;for(let Ie of te)N(Ie)&&(k.has(Ie)?xe=k.get(Ie):(ne.has(xe)||ne.set(xe,[]),ne.get(xe).push(Ie)));for(let[Ie,Le]of K){let ke=ne.get(Ie);if(!(!ke||Le.length!==ke.length)&&Le.every(($e,Xe)=>ke[Xe].tagName===$e.tagName&&Be($e,ke[Xe])&&!J($e,ke[Xe])))for(let $e=0;$e<Le.length;$e++)Gt(Le[$e],ke[$e])}}}function Gt(U,Y){q(U,Y),v.add(U),x.push([U,Y]),Ct()}function wn(U,Y){let he=So(U,c),ge=So(Y,c),de=new Map;for(let ee of Y){let te=c(ee);ge.get(te)===1&&de.set(te,ee)}for(let ee of U){if(T.has(ee))continue;let te=c(ee);if(he.get(te)!==1)continue;let K=de.get(te);K&&!k.has(K)&&a(ee,K)&&Yt(ee,K)}}function Bt(U,Y,he){let ge=[[U,Y]];for(;ge.length;){let[de,ee]=ge.pop();if(es.certifyVisited++,d&&d.certificationVisited++,de.nodeType!==ee.nodeType)return!1;if(de.nodeType===3||de.nodeType===8){if(de.nodeValue!==ee.nodeValue)return!1;continue}if(de.nodeType!==1){if(!de.isEqualNode(ee))return!1;continue}if(de.tagName!==ee.tagName||de.namespaceURI!==ee.namespaceURI||p(de)!==p(ee))return!1;let te=de.attributes,K=ee.attributes;if(te.length!==K.length)return!1;for(let ke=0;ke<te.length;ke++){let $e=te[ke];if(ee.getAttributeNS($e.namespaceURI,$e.localName)!==$e.value)return!1}let ne=T.get(de);if(ne!==void 0&&ne!==ee)return!1;let xe=k.get(ee);if(xe!==void 0&&xe!==de)return!1;if(de!==U){if(P.has(de))continue;if(he.has(de))return!1}let Ie=i(de),Le=i(ee);if(Ie.length!==Le.length)return!1;es.certifyScheduled+=Ie.length;for(let ke=Ie.length-1;ke>=0;ke--)ge.push([Ie[ke],Le[ke]])}return!0}function ln(U,Y){return!N(U)||!(Ee.has(U)||Me.has(Y))?!0:!!z(U,Y)||!(Se(U)||nt(Y))}function Yt(U,Y){if(N(U)&&(Ee.has(U)||Me.has(Y))){let he=z(U,Y);if(!he){if(Se(U)||nt(Y))return;q(U,Y),x.push([U,Y]);return}for(let ge=0;ge<he.length;ge+=2){let de=he[ge],ee=he[ge+1],te=T.get(de);te!==void 0&&te!==ee&&un(de,te);let K=k.get(ee);K!==void 0&&K!==de&&un(K,ee),T.get(de)===ee&&(M.delete(de),v.delete(de),P.add(de),D.add(de))}}h(U,Y)}function un(U,Y){T.delete(U),k.delete(Y),M.delete(U),P.delete(U),v.delete(U),D.delete(U)}function z(U,Y){let he=[U,Y,!1],ge=[];for(;he.length;){let de=he.pop(),ee=he.pop(),te=he.pop(),K=T.get(te),ne=k.get(ee);if(te!==U&&(K!==void 0&&K!==ee&&st.has(te)||ne!==void 0&&ne!==te&&st.has(ne)))return null;if(!(K===ee&&P.has(te))&&((K!==void 0||ne!==void 0)&&ge.push(te,ee),!!N(te))){if(de||K!==void 0&&K!==ee||ne!==void 0&&ne!==te){let xe=r(te),Ie=r(ee);for(let Le=0;Le<xe.length&&Le<Ie.length;Le++)he.push(xe[Le],Ie[Le],!0)}else if(Ee.has(te)||Me.has(ee)){let xe=te.tagName==="TEMPLATE"?te.content:te,Ie=ee.tagName==="TEMPLATE"?ee.content:ee;for(let Le=xe.firstElementChild,ke=Ie.firstElementChild;Le&&ke;){if(p(Le)){Le=Le.nextElementSibling;continue}if(p(ke)){ke=ke.nextElementSibling;continue}(T.has(Le)||k.has(ke)||Ee.has(Le)||Me.has(ke))&&he.push(Le,ke,!1),Le=Le.nextElementSibling,ke=ke.nextElementSibling}}}}return ge}function h(U,Y){q(U,Y),P.add(U),N(U)&&D.add(U)}function E(U){let Y=T.get(U);if(!Y||!N(U))return;let he=r(U),ge=r(Y);for(let de=0;de<he.length&&de<ge.length;de++)T.has(he[de])||h(he[de],ge[de])}function R(U,Y){let he=te=>N(te)&&!le(te)?o(te).sig+""+o(te).hint:null,ge=So(U,he),de=So(Y,he),ee=new Map;for(let te of Y){let K=he(te);K!=null&&de.get(K)===1&&ee.set(K,te)}for(let te of U){if(T.has(te))continue;let K=he(te);if(K==null||ge.get(K)!==1)continue;let ne=ee.get(K);ne&&!k.has(ne)&&Be(te,ne)&&q(te,ne)}}function V(U,Y,he,ge){let de=new Map;for(let te of Y){if(!N(te)||k.has(te)||le(te))continue;let K=o(te).sig;de.has(K)||de.set(K,[]),de.get(K).push({el:te,index:H.get(te)})}let ee=[];for(let te of U){if(T.has(te)||!N(te)||le(te))continue;let K=de.get(o(te).sig);if(!K||!K.length)continue;let ne=X.get(te),xe=K.filter(Ie=>!k.has(Ie.el)).map(Ie=>({c:Ie,d:Math.abs(Ie.index-ne)}));xe.sort((Ie,Le)=>Ie.d-Le.d),xe.length>yi&&(xe=xe.slice(0,yi));for(let{c:Ie,d:Le}of xe){if(!Be(te,Ie.el))continue;let ke=s(te,Ie.el);ke&&ke.coef>=.5&&ee.push({b:te,s:Ie.el,coef:ke.coef,share:ke.share,d:Le,bi:ne})}}if(ee.sort((te,K)=>K.coef-te.coef||K.share-te.share||te.d-K.d||te.bi-K.bi),d&&ee.length>1){let te=new Map;for(let K of ee){let ne=te.get(K.b);ne?ne.coef===K.coef&&(ne.share===K.share?ne.strict++:ne.loose++):te.set(K.b,{coef:K.coef,share:K.share,strict:0,loose:0})}for(let[K,ne]of te)w.has(K)||!(ne.strict||ne.loose)||(w.add(K),ne.strict?d.similarTiesStrict++:d.similarTiesLoose++)}for(let te of ee)!T.has(te.b)&&!k.has(te.s)&&q(te.b,te.s)}function Q(U,Y){return N(U)!==N(Y)?!1:N(U)?U.tagName!==Y.tagName||!Be(U,Y)?!1:le(U)||o(U).hint===""||o(Y).hint===""?!0:l(U,Y):U.kind===Y.kind}function j(U,Y){let he=(de,ee)=>{let te=ee===null?-1:de===Y?H.get(ee):X.get(ee),K=de[te+1];return K&&!N(K)?K:null},ge=null;for(let de of U){if(N(de)){ge=de;continue}if(T.has(de))continue;let ee=ge===null?null:T.get(ge);if(ge!==null&&!ee)continue;let te=he(Y,ee);te&&!k.has(te)&&te.kind===de.kind&&q(de,te)}}function ue(U,Y){j(U,Y);let he=be(U,Y),ge=(ee,te)=>N(ee)&&o(ee).hint!==""&&o(te).hint===""&&!!te.querySelector("br")&&!he(ee,te),de=0;for(let ee of U){if(T.has(ee)){let K=H.get(T.get(ee));K!==void 0&&K>=de&&(de=K+1);continue}let te=0;for(let K=de;K<Y.length&&te<Ac;K++){let ne=Y[K];if(!k.has(ne)&&(te++,Q(ee,ne)&&!J(ee,ne)&&!ge(ee,ne))){q(ee,ne),N(ee)&&(o(ee).hint===""||o(ne).hint==="")&&v.add(ee),de=K+1;break}}}ie(U,Y)}function be(U,Y){let he=(ge,de,ee)=>{for(let te=de-1;te>=0;te--)if(N(ge[te])&&ee(ge[te]))return ge[te];return null};return(ge,de)=>{let ee=X.get(ge),te=H.get(de);if(ee===te)return!0;let K=he(U,ee,xe=>T.has(xe)),ne=he(Y,te,xe=>k.has(xe));return K?T.get(K)===ne:!ne}}function ie(U,Y){let he=U.filter(K=>N(K)&&!T.has(K)),ge=Y.filter(K=>N(K)&&!k.has(K));if(!he.length||!ge.length)return;let de=So(he,K=>K.tagName),ee=So(ge,K=>K.tagName),te=be(U,Y);for(let K of he){let ne=K.tagName;if(de.get(ne)!==1||ee.get(ne)!==1)continue;let xe=ge.find(Ie=>Ie.tagName===ne);xe&&!k.has(xe)&&te(K,xe)&&Be(K,xe)&&!J(K,xe)&&(a(K,xe)?Yt(K,xe):(q(K,xe),v.add(K)))}}function Ne(){let U=new Map;for(let K of v)if(N(K)&&N(T.get(K))){let ne=o(K).hash;U.has(ne)||U.set(ne,[]),U.get(ne).push(K)}if(U.size)for(let K of W){if(k.has(K)||!N(K)||ve(K))continue;let ne=U.get(o(K).hash),xe=ne&&ne.find(Ie=>v.has(Ie)&&!J(Ie,K)&&Be(Ie,K)&&Je(Ie,K)&&a(Ie,K)&&ln(Ie,K));xe&&(yt(xe),Yt(xe,K),Ae(xe,K),M.add(xe))}let Y=new Map,he=new Map,ge=new Map;for(let K of v){let ne=T.get(K);N(K)&&N(ne)&&ge.set(ne,K)}let de=(K,ne)=>{if(!k.has(K))return!ve(K);let xe=ge.get(K);return xe===k.get(K)&&xe!==ne&&!xe.contains(ne)},ee=K=>{if(k.has(K)){let ne=ge.get(K);ge.delete(K),yt(ne)}};for(let K of[...W,...ge.keys()]){if(k.has(K)&&!ge.has(K))continue;let ne=o(K).hash;if(Y.has(ne)||Y.set(ne,[]),Y.get(ne).push(K),le(K))continue;let xe=o(K).sig;he.has(xe)||he.set(xe,[]),he.get(xe).push(K)}let te=new Set;for(let K of v){let ne=T.get(K);!N(K)||!N(ne)||le(K)||o(K).hint===""||o(ne).hint===""||l(K,ne)||te.add(K)}for(let K of[...$,...te]){let ne=T.get(K);if(ne?!(v.has(K)&&te.has(K)):_e(K))continue;let xe=Xe=>{ne&&yt(K),ee(Xe)},Ie=Y.get(o(K).hash);if(Ie){let Xe=Ie.find(Qe=>Qe!==ne&&de(Qe,K)&&!J(K,Qe)&&Je(K,Qe)&&a(K,Qe)&&ln(K,Qe));if(Xe){xe(Xe),Yt(K,Xe),Ae(K,Xe),M.add(K);continue}}if(le(K)||A<=0)continue;let Le=he.get(o(K).sig);if(!Le)continue;let ke=null,$e=0;for(let Xe of Le)if(!(Xe===ne||!de(Xe,K)||!Be(K,Xe)||!Je(K,Xe)||J(K,Xe))&&(A--<=0||l(K,Xe)&&($e++,ke=Xe,$e>1)))break;$e>1&&O&&O.add(K),$e===1&&(xe(ke),q(K,ke),Ae(K,ke),M.add(K),x.push([K,ke]))}}}function So(e,t){let n=new Map;for(let o of e){let r=t(o);r!=null&&n.set(r,(n.get(r)||0)+1)}return n}var Sc={diff:0},wi=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,Nc=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,vc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,Oc=/\P{M}\p{M}*/gu;function Mc(e){if(e==="")return[];if(wi){let n=[];for(let o of wi.segment(e))n.push(o.segment);return n}let t=[];for(let n of e.match(vc))if(Nc.test(n))for(let o of n.match(Oc))t.push(o);else t.push(n);return t}var Ec=/^[  ]+$/,Ic=e=>Ec.test(e)?" ".repeat(e.length):e,oo=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),xt="",ns=e=>e.every(t=>oo(t)||t.k===xt),Cc=/^[\x00-\x7f\u00A0]*$/,Rc=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Lc(e){return e===""?[]:e.match(Rc)}function an(e,t=!1){return(t?Lc(e):Mc(e)).map(n=>({k:Ic(n),raw:n,len:n.length}))}var Tn=(...e)=>e.every(t=>Cc.test(t));function os(e,t,n){let o=e.length,r=t.length,c=Math.min(o+r,n),l=c+1,s=new Int32Array(2*c+3),i=[],a=o===0&&r===0;for(let y=0;y<=c&&!a;y++){i.push(s.slice(l-y,l+y+1));for(let b=-y;b<=y;b+=2){let S;b===-y||b!==y&&s[l+b-1]<s[l+b+1]?S=s[l+b+1]:S=s[l+b-1]+1;let g=S-b,d=S;for(;S<o&&g<r&&e[S].k===t[g].k;)S++,g++;if(Sc.diff+=1+S-d,s[l+b]=S,S>=o&&g>=r){a=!0;break}}}if(!a)return null;let p=[],f=o,u=r;for(let y=i.length-1;y>0;y--){let b=i[y],S=f-u,g=S+y,d=S===-y||S!==y&&b[g-1]<b[g+1]?S+1:S-1,w=b[d+y],O=w-d;for(;f>w&&u>O;)p.push([0,f-1,u-1]),f--,u--;f===w?(p.push([1,f,u-1]),u--):(p.push([-1,f-1,u]),f--)}for(;f>0&&u>0;)p.push([0,f-1,u-1]),f--,u--;return p.reverse(),p}function Pc(e,t,n){let o=f=>f.k===xt;if(!e.some(o)&&!t.some(o))return os(e,t,n);let r=[],c=[];for(let f=0;f<e.length;f++)o(e[f])||r.push(f);for(let f=0;f<t.length;f++)o(t[f])||c.push(f);let l=os(r.map(f=>e[f]),c.map(f=>t[f]),n);if(!l)return null;let s=[],i=0,a=0,p=(f,u)=>{for(;i<f&&a<u&&e[i].k===t[a].k;)s.push([0,i++,a++]);let y=os(e.slice(i,f),t.slice(a,u),n);if(!y)return!1;for(let[b,S,g]of y)s.push([b,S+i,g+a]);return i=f,a=u,!0};for(let[f,u,y]of l)if(f===0){if(!p(r[u],c[y]))return null;s.push([0,i,a]),i++,a++}return p(e.length,t.length)?s:null}function Gn(e,t,n=4e3){let o=[],r=0;for(;r<e.length&&r<t.length&&e[r].k===t[r].k;)e[r].raw!==t[r].raw&&o.push({bi:r,tok:t[r]}),r++;let c=0;for(;c<e.length-r&&c<t.length-r&&e[e.length-1-c].k===t[t.length-1-c].k;)e[e.length-1-c].raw!==t[t.length-1-c].raw&&o.push({bi:e.length-1-c,tok:t[t.length-1-c]}),c++;let l=e.slice(r,e.length-c),s=t.slice(r,t.length-c),i=Wc(l,s)?null:Pc(l,s,n);if(!i){let d=l.length||s.length?[{bs:r,be:r+l.length,toks:s}]:[];return{hunks:d,cosmetic:o,coarse:!0,parts:d.map(w=>({...w,gap:[],group:0})),cosmeticEq:o}}let a=[],p=(d,w)=>{l[d].raw!==s[w].raw&&o.push({bi:r+d,tok:s[w]})},f=null,u=[],y=0,b=0,S=()=>{f&&a.push(f),f=null;for(let[d,w]of u)p(d,w);u=[],y++};for(let[d,w,O]of i){if(d===0){f&&oo(l[w])&&!l[w].k.includes(`
3
+ `)?u.push([w,O]):(S(),p(w,O)),b=w+1;continue}(!f||u.length)&&(f&&a.push(f),f={bs:r+b,be:r+b,toks:[],gap:u.map(([T,k])=>({bi:r+T,tok:s[k]})),group:y},u=[]),d===-1?(f.be=r+b+1,b=w+1):f.toks.push(s[O])}S(),jc(a,e);let g=ss(a);return{hunks:g.hunks,cosmetic:o.concat(g.cosmetic),parts:a,cosmeticEq:o}}function jc(e,t){for(let n=0;n<e.length;n++){let o=e[n];if(o.gap.length)continue;let r=n+1<e.length?e[n+1].bs:1/0;if(o.toks.length){if(o.bs===o.be)for(;o.bs+1<r&&o.bs<t.length&&o.toks[0].k===xt&&t[o.bs].k===xt;)o.toks=[...o.toks.slice(1),o.toks[0]],o.bs++,o.be++}else for(;o.be+1<r&&o.be<t.length&&t[o.bs].k===xt&&t[o.be].k===xt;)o.bs++,o.be++}}function ss(e,t=()=>!1){let n=[],o=[],r=null,c=-1;for(let l of e){let s=t(l);if(r&&!r.alone&&!s&&l.group===c){r.be=l.be;for(let i of l.gap)r.toks.push(i.tok);for(let i of l.toks)r.toks.push(i);continue}r&&n.push({bs:r.bs,be:r.be,toks:r.toks});for(let i of l.gap)o.push(i);r={bs:l.bs,be:l.be,toks:l.toks.slice(),alone:s},c=l.group}return r&&n.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:n,cosmetic:o}}var Dc=(e,t)=>e.bs===t.bs&&e.be===t.be&&cs(e.toks,t.toks);function ls(e,t,n){let o=p=>f=>p.some(u=>Dc(f,u)),r=ss(e.parts,o(t.parts)),c=ss(t.parts,o(e.parts)),l=e.cosmeticEq.concat(r.cosmetic),s=t.cosmeticEq.concat(c.cosmetic),[i,a]=n?Bc(r.hunks,c.hunks,n,l,s):[r.hunks,c.hunks];return{lh:i,rh:a,cosL:l,cosR:s}}function Bc(e,t,n,o,r){let c=(b,S)=>b.k===S.k&&b.raw===S.raw,l=[{list:e.map(b=>({...b})),resp:new Set(o.map(b=>b.bi)),raw:new Map(o.map(b=>[b.bi,b.tok]))},{list:t.map(b=>({...b})),resp:new Set(r.map(b=>b.bi)),raw:new Map(r.map(b=>[b.bi,b.tok]))}],s=b=>b.bs===b.be,i=(b,S,g,d)=>{let w=b.list[S];if(!s(w))return d(w)===g?w.toks:null;let O=S?b.list[S-1].be:0,T=S+1<b.list.length?b.list[S+1].bs:n.length;if(g<O||g>T)return null;let k=w.toks,v=w.bs;for(;v>g;){let I=k[k.length-1];if(!c(I,n[v-1])||b.resp.has(v-1))return null;k=[I,...k.slice(0,-1)],v--}for(;v<g;){if(!c(k[0],n[v])||b.resp.has(v))return null;k=[...k.slice(1),k[0]],v++}return k},a=(b,S,g,d,w,O)=>{let T=b.list[S],k=w?g.slice(g.length-d):g.slice(0,d),v=w?g.slice(0,g.length-d):g.slice(d),I={bs:O,be:O,toks:k};if(s(T)){if(!v.length){b.list[S]=I;return}let P={bs:O,be:O,toks:v};w&&(P.lead=!0),b.list.splice(S,1,...w?[P,I]:[I,P]);return}let M={bs:T.bs,be:T.be,toks:v};b.list.splice(S,1,...w?[M,I]:[I,M])},p=(b,S,g,d,w)=>{let O=b.list[S],T=w?g.slice(g.length-d):g.slice(0,d),k=w?g.slice(0,g.length-d):g.slice(d),v={bs:O.bs,be:O.be,toks:T};if(!k.length){b.list[S]=v;return}let I=w?{bs:O.bs,be:O.bs,toks:k,lead:!0}:{bs:O.be,be:O.be,toks:k};b.list.splice(S,1,...w?[I,v]:[v,I])},f=(b,S,g,d)=>{let w=b.list[S],O=g.list[d],T=w.be,k=O.bs;if(T>=k||S+1<b.list.length&&b.list[S+1].bs<=O.be||d>0&&g.list[d-1].be>=w.bs)return!1;for(let H=T;H<k;H++)if(!oo(n[H])||n[H].k.includes(`
4
+ `))return!1;let v=H=>n.slice(T,k).map((q,Ee)=>H.raw.get(T+Ee)||q),I=[...w.toks,...v(b)],M=[...v(g),...O.toks],P=(H,q,Ee)=>q>=0&&q+Ee.length<=H.length&&Ee.every((Me,je)=>H[q+je].k===Me.k),D=(H,q,Ee)=>ns(H)&&n.slice(q,Ee).some(Me=>!oo(Me)),$=H=>H.some(q=>!oo(q)),W,B,x,A;if(s(w)&&$(w.toks)&&P(M,0,w.toks)){let H=M.slice(w.toks.length);D(H,T,O.be)||(W=T,B=w.toks,x=M.slice(0,w.toks.length),A=[null,{bs:T,be:O.be,toks:H}])}if(W===void 0&&s(O)&&$(O.toks)){let H=I.length-O.toks.length,q=I.slice(0,H);P(I,H,O.toks)&&!D(q,w.bs,k)&&(W=k,B=I.slice(H),x=O.toks,A=[{bs:w.bs,be:k,toks:q},null])}if(W===void 0)return!1;let X=H=>H&&(H.bs<H.be||H.toks.length);return b.list.splice(S,1,...[A[0],{bs:W,be:W,toks:B}].filter(X)),g.list.splice(d,1,...[{bs:W,be:W,toks:x},A[1]].filter(X)),!0},u=l[0],y=l[1];for(let b=0;b<64;b++){let S=!1;e:for(let g=0;g<u.list.length;g++)for(let d=0;d<y.list.length;d++){let w=u.list[g],O=y.list[d];if(!(w.bs===O.bs&&w.be===O.be&&cs(w.toks,O.toks))){for(let T of[!0,!1]){let k=I=>T?I.be:I.bs,v=s(w)?[k(O),w.bs]:[k(w)];for(let I of v){let M=i(u,g,I,k),P=M&&i(y,d,I,k);if(!P)continue;let D=(A,X)=>T?A[A.length-1-X]:A[X],$=0;for(;$<M.length&&$<P.length&&D(M,$).k===D(P,$).k;)$++;if(!$)continue;let W=T?M.slice(0,M.length-$):M.slice($),B=T?P.slice(0,P.length-$):P.slice($);if(!($<M.length&&$<P.length&&!ns(W)&&!ns(B)&&(s(w)&&s(O)||w.bs===O.bs&&w.be===O.be)||!(T?M.slice(M.length-$):M.slice(0,$)).some(A=>!oo(A)))){if($===M.length&&$===P.length&&s(w)&&s(O)){if(w.bs===I&&O.bs===I)continue;u.list[g]={bs:I,be:I,toks:M},y.list[d]={bs:I,be:I,toks:P}}else!s(w)&&w.bs===O.bs&&w.be===O.be?(p(u,g,M,$,T),p(y,d,P,$,T)):(a(u,g,M,$,T,I),a(y,d,P,$,T,I));S=!0;break e}}}if(f(u,g,y,d)||f(y,d,u,g)){S=!0;break e}}}if(!S)break}return[u.list,y.list]}var Uc=48,Hc=.3;function Wc(e,t){let n=e.filter(l=>!oo(l)),o=t.filter(l=>!oo(l));if(Math.min(n.length,o.length)<Uc)return!1;let r=new Map;for(let l of n)r.set(l.k,(r.get(l.k)||0)+1);let c=0;for(let l of o){let s=r.get(l.k);s>0&&(c++,r.set(l.k,s-1))}return c/Math.min(n.length,o.length)<Hc}var Vc=(e,t)=>{let n=new Set;for(let o of e.toks)typeof o.k!="string"&&n.add(o.k.el);for(let o=e.bs;o<e.be;o++)typeof t[o].k!="string"&&n.add(t[o].k.el);return n},cs=(e,t)=>e.length===t.length&&e.every((n,o)=>n.k===t[o].k);function xi(e,t,n,o="remote"){let r=Gn(e,t),c=Gn(e,n),{lh:l,rh:s,cosL:i,cosR:a}=ls(r,c,e),p=N=>N.bs===N.be,f=N=>N.toks.some(J=>typeof J.k=="string"),u=N=>p(N)&&!f(N),y=(N,J)=>J.bs<N.be&&N.bs<J.be,b=(N,J)=>!y(N,J)&&J.bs<=N.be&&N.bs<=J.be&&(p(N)&&f(N)||p(J)&&f(J))&&!(p(N)&&p(J)),S=(N,J)=>N.bs===J.bs&&N.be===J.be&&cs(N.toks,J.toks),g=[],d=new Set;for(let N of l){let J=s.find(le=>!d.has(le)&&S(N,le));J?(d.add(J),g.push({bs:N.bs,be:N.be,side:"both",l:N,r:J,toks:N.toks})):g.push({bs:N.bs,be:N.be,side:"L",l:N,toks:N.toks,lead:!!N.lead})}for(let N of s)d.has(N)||g.push({bs:N.bs,be:N.be,side:"R",r:N,toks:N.toks,lead:!!N.lead});g.sort((N,J)=>N.bs-J.bs||N.be-J.be||J.lead-N.lead);let w=0,O=0;for(let N of g)N.side==="both"&&(w+=N.toks.length-(N.be-N.bs));let T=g.map((N,J)=>J),k=N=>T[N]===N?N:T[N]=k(T[N]),v=(N,J)=>(N=k(N),J=k(J),N===J?!1:(T[N]=J,!0)),I=g.map(N=>Vc({bs:N.bs,be:N.be,toks:N.toks},e)),M={L:new Map,R:new Map};g.forEach((N,J)=>{let le=N.side==="both"?["L","R"]:[N.side];for(let oe of le)for(let Re of I[J])M[oe].has(Re)||M[oe].set(Re,[]),M[oe].get(Re).push(J)});for(let N of[M.L,M.R])for(let J of N.values())for(let le=1;le<J.length;le++)v(J[0],J[le]);for(let N=0;N<g.length;N++)for(let J=N+1;J<g.length;J++){let le=g[N],oe=g[J];le.side===oe.side&&le.side!=="both"||le.bs>oe.be||(y(le,oe)||b(le,oe)?v(N,J):le.bs===oe.bs&&p(le)&&p(oe)&&O++)}let P=(N,J)=>{let le=N==="L"?l:s;for(let oe of le)if(oe.toks.some(Re=>Re.kind==="close"&&Re.k.el===J.el))return oe.bs;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===J.el)return oe;return-1};g.forEach((N,J)=>{if(!(!u(N)||N.side==="both"))for(let le of N.toks){if(le.kind!=="open")continue;let oe=P(N.side,le.k);if(oe<=N.bs)continue;let Re=new Uint8Array(oe-N.bs),Be=[];if(g.forEach((Se,nt)=>{if(!(Se.side===N.side||p(Se))&&Se.bs<oe&&Se.be>N.bs){Be.push(nt);for(let Je=Math.max(Se.bs,N.bs);Je<Math.min(Se.be,oe);Je++)Re[Je-N.bs]=1}}),Be.length&&Re.every(Se=>Se===1))for(let Se of Be)v(J,Se)}});let D=!0;for(;D;){D=!1;let N=new Map;g.forEach((J,le)=>{let oe=k(le),Re=N.get(oe)||{bs:J.bs,be:J.be,L:!1,R:!1};Re.bs=Math.min(Re.bs,J.bs),Re.be=Math.max(Re.be,J.be),J.side!=="R"&&(Re.L=!0),J.side!=="L"&&(Re.R=!0),N.set(oe,Re)}),g.forEach((J,le)=>{for(let[oe,Re]of N){if(k(le)===k(oe)||!(Re.L&&Re.R))continue;let Be=J.bs<Re.be&&J.be>Re.bs,Se=p(J)&&f(J)&&(J.bs===Re.be||J.bs===Re.bs);(Be||Se)&&v(le,oe)&&(D=!0)}})}let $=new Map;g.forEach((N,J)=>{let le=k(J);$.has(le)||$.set(le,[]),$.get(le).push(N)});let W=[];for(let N of $.values()){let J=N.some(oe=>oe.side==="L"),le=N.some(oe=>oe.side==="R");if(J&&le){let oe=Math.min(...N.map(nt=>nt.bs)),Re=Math.max(...N.map(nt=>nt.be)),Be=N.filter(nt=>nt.side!=="R").map(nt=>nt.l).sort((nt,Je)=>nt.bs-Je.bs),Se=N.filter(nt=>nt.side!=="L").map(nt=>nt.r).sort((nt,Je)=>nt.bs-Je.bs);W.push({bs:oe,be:Re,kind:"conflict",localHunks:Be,remoteHunks:Se})}else for(let oe of N)W.push({bs:oe.bs,be:oe.be,kind:oe.side,u:oe})}let B=(N,J)=>{let le=N==="L"?l:s;for(let oe of le)if(oe.toks.some(Re=>Re.kind==="close"&&Re.k.el===J.el))return oe.bs+.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===J.el)return oe;return 1/0},x=(N,J)=>{let le=N==="L"?l:s;for(let oe of le)if(oe.toks.some(Re=>Re.kind==="open"&&Re.k.el===J.el))return oe.bs-.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="open"&&e[oe].k.el===J.el)return oe;return-1/0},A=N=>N.kind==="R"?"R":"L",X=N=>N.kind==="R"?1:0;W.sort((N,J)=>{if(N.bs!==J.bs)return N.bs-J.bs;let le=N.bs===N.be,oe=J.bs===J.be;if(le!==oe)return le?-1:1;if(le&&oe&&N.kind!=="conflict"&&J.kind!=="conflict"){let Be=N.u.toks,Se=J.u.toks,nt=ht=>ht.length&&ht.every(Ge=>Ge.kind==="open"),Je=ht=>ht.length&&ht.every(Ge=>Ge.kind==="close");if(nt(Be)&&nt(Se)){let ht=Math.max(...Be.map(st=>B(A(N),st.k))),Ge=Math.max(...Se.map(st=>B(A(J),st.k)));if(ht!==Ge)return Ge-ht}if(Je(Be)&&Je(Se)){let ht=Math.min(...Be.map(st=>x(A(N),st.k))),Ge=Math.min(...Se.map(st=>x(A(J),st.k)));return ht!==Ge?Ge-ht:X(J)-X(N)}}let Re=Be=>Be.u&&Be.u.lead?1:0;return Re(J)-Re(N)||X(N)-X(J)||N.be-J.be});let H=[],q=[],Ee=0,Me=N=>{N>Ee&&(H.push({bs:Ee,be:N,toks:e.slice(Ee,N),source:"base"}),Ee=N)};for(let N of W){if(Me(N.bs),N.kind==="conflict"){let J=is(e,N.localHunks,N.bs,N.be),le=is(e,N.remoteHunks,N.bs,N.be),oe=o==="local"?J:o==="both"?J.concat(le):le,Re=(nt,Je)=>{let ht=0;for(let Ge of nt)Ge.be<=N.bs&&!Je.includes(Ge)&&(ht+=Ge.toks.length-(Ge.be-Ge.bs));return ht},Be=N.bs+Re(l,N.localHunks),Se=N.bs+Re(s,N.remoteHunks);q.push({bs:N.bs,be:N.be,ls:Be,le:Be+J.length,rs:Se,re:Se+le.length,ms:0,me:0,base:e.slice(N.bs,N.be),local:J,remote:le,resolved:oe}),H.push({bs:N.bs,be:N.be,toks:oe,source:"conflict",localHunks:N.localHunks,localToks:J,keepsLocal:o!=="remote"})}else H.push({bs:N.bs,be:N.be,toks:N.u.toks,source:N.kind==="R"?"remote":"local",localHunks:N.kind==="R"?[]:[N.u.l]});Ee=Math.max(Ee,N.be)}Me(e.length);let je=0,ae=0;for(let N of H)N.source==="conflict"&&(q[ae].ms=je,q[ae].me=je+N.toks.length,ae++),je+=N.toks.length;let Ae=new Map(i.map(N=>[N.bi,N.tok])),_e=new Map(a.map(N=>[N.bi,N.tok])),ve=[];for(let N of H){N.source==="base"&&(N.toks=N.toks.map((J,le)=>{let oe=N.bs+le,Re=Ae.get(oe),Be=_e.get(oe),Se=Re&&Be?o==="remote"?Be:Re:Re||Be||J;return Se===J?J:{...Se,cosmetic:!0}}));for(let J of N.toks)ve.push({...J,src:N.source})}return{tokens:ve,segments:H,conflicts:q,localHunks:l,remoteHunks:s,collapsedDelta:w,samePoint:O,mapLocalOffset:_c(e,l,H)}}function is(e,t,n,o){let r=[],c=n;for(let l of t)r=r.concat(e.slice(c,l.bs),l.toks),c=l.be;return r.concat(e.slice(c,o))}var rs=e=>e.reduce((t,n)=>t+n.len,0);function _c(e,t,n){let o=new Int32Array(e.length+1);for(let l=0;l<e.length;l++)o[l+1]=o[l]+e[l].len;let r=t.map(l=>({bs:o[l.bs],be:o[l.be],text:l.toks.map(s=>s.raw).join(""),ref:l})),c=n.map(l=>({bs:o[l.bs],be:o[l.be],len:rs(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?rs(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let s=null,i=null,a=0,p=0,f=0;for(let y of r){let b=y.bs-f;if(l<=p+b){s=f+(l-p);break}if(p+=b,f=y.bs,l<=p+y.text.length){i=y,a=l-p,s=y.bs;break}p+=y.text.length,f=y.be}s===null&&(s=f+(l-p));let u=0;for(let y of c){if(!i&&s<=y.bs)return u;if(!(i?y.localHunks.includes(i.ref):s<y.be)){u+=y.len;continue}if(y.source==="base")return u+(s-y.bs);if(y.source==="remote")return u+y.len;if(y.source==="local")return u+Math.min(a,y.len);if(!y.keepsLocal||!i)return u+y.len;let S=y.localHunks.indexOf(i.ref),g=rs(is(e,y.localHunks.slice(0,S),y.ref.bs,i.ref.bs));return u+Math.min(g+a,y.localLen)}return u}}function $o(e,t,n,o="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:d=>Math.min(d,t.length),granularity:"word"};let r=Tn(e,t,n),c=an(e,r),l=an(t,r),s=an(n,r),i=c.length<=2e4&&l.length<=2e4&&s.length<=2e4?xi(c,l,s,o):null,a="word",p=c;if(!i){let d=w=>w.split(/(?<=\n)/).map(O=>({k:O,raw:O,len:O.length}));p=d(e),i=xi(p,d(t),d(n),o),a="line"}let f=d=>d.map(w=>w.raw).join(""),u=d=>{let w=[0];for(let O of d)w.push(w[w.length-1]+O.len);return w},y=u(p),b=null,S=null,g=null;if(i.conflicts.length){let d=w=>w.split(/(?<=\n)/).map(O=>({k:O,raw:O,len:O.length}));b=u(a==="line"?d(t):l),S=u(a==="line"?d(n):s),g=u(i.tokens)}return{text:f(i.tokens),conflicts:i.conflicts.map(d=>({bs:y[d.bs],be:y[d.be],ls:b[d.ls],le:b[d.le],rs:S[d.rs],re:S[d.re],ms:g[d.ms],me:g[d.me],base:f(d.base),local:f(d.local),remote:f(d.remote),resolved:f(d.resolved)})),mapLocalOffset:i.mapLocalOffset,granularity:a}}function ao(e,t,n=4e3){if(e===t)return[];let o=Tn(e,t),r=an(e,o),c=an(t,o),l=Gn(r,c,n),s=[0];for(let i of r)s.push(s[s.length-1]+i.len);return l.hunks.map(i=>({bs:s[i.bs],be:s[i.be],text:i.toks.map(a=>a.raw).join("")}))}function zt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Vn({base:e,side:t,retained:n,transfers:o,baseAtomKey:r=s=>s.el,sideAtomKey:c=s=>s.el,budget:l=zt()}){let s=[],i=k=>({status:"fallback",reason:k}),a=k=>k>l.remaining?!1:(l.remaining-=k,!0);if(!a((n.length+o.length)*3))return i("work-limit");for(let[k,v]of[["retained",n],["transfer",o]])for(let I of v){let{from:M,to:P,target:D}=I;if(!Number.isInteger(M)||!Number.isInteger(P)||!Number.isInteger(D)||M<0||P<=M||P>e.text.length||D<0||D+P-M>t.text.length)return i("invalid-range");s.push({...I,kind:k})}let p=Symbol(),f=k=>(v,I)=>{if(!a(1))throw p;return l.sortComparisons++,k(v,I)},u,y;try{u=s.slice().sort(f((k,v)=>k.from-v.from||k.to-v.to)),y=s.slice().sort(f((k,v)=>k.target-v.target||k.to-k.from-(v.to-v.from)))}catch(k){if(k===p)return i("work-limit");throw k}if(!a(s.length*2))return i("work-limit");for(let k=1;k<u.length;k++)if(u[k].from<u[k-1].to)return i("source-overlap");for(let k=1;k<y.length;k++)if(y[k].target<y[k-1].target+y[k-1].to-y[k-1].from)return i("target-overlap");for(let k of u){let v=k.to-k.from;if(!a(v))return i("work-limit");for(let I=0;I<v;I++){let M=k.from+I,P=k.target+I;if(l.comparisons++,e.text[M]!==t.text[P])return i("unequal-occurrence");let D=e.atomAt.get(M),$=t.atomAt.get(P);if(!!D!=!!$||D&&r(D)!==c($))return i("different-atom")}}let b=e.text.length+t.text.length+2,S=s.reduce((k,v)=>k+(v.to-v.from)*2,2);if(!a(b+S+s.length))return i("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),d=new Int32Array(t.text.length+1).fill(-1);l.mapCells+=b,l.mapWrites+=S;let w=-1,O=!0;for(let k of u){k.target<w&&(O=!1),w=k.target+k.to-k.from;for(let v=0;v<k.to-k.from;v++)g[k.from+v]=k.target+v,d[k.target+v]=k.from+v}return g[e.text.length]=t.text.length,d[t.text.length]=e.text.length,{status:"ready",runs:u,bTo:g,toB:d,monotone:O,covers:(k,v)=>{if(!a(v-k))return null;l.coverageChecks+=v-k;for(let I=k;I<v;I++)if(e.text[I]!==xt&&!/\s/.test(e.text[I])&&g[I]<0)return!1;return!0}}}function as({base:e,side:t,baseOf:n=()=>null,budget:o=zt()}){if(e.text===t.text||!e.text.includes(xt)&&!t.text.includes(xt))return{status:"none"};let r=(e.text.length+t.text.length)*8;if(r>o.remaining)return{status:"fallback",reason:"work-limit"};o.remaining-=r,o.boundarySteps=(o.boundarySteps||0)+r;let c=(b,S)=>S<b.length&&(b[S]===xt||/\s/.test(b[S])),l=new Map,s=Symbol(),i=(b,S)=>{let g=b.stackAt[S]||[];if(!l.has(g)){if(g.length>o.remaining)throw s;o.remaining-=g.length,o.boundarySteps+=g.length,l.set(g,g.find(d=>d.block)?.el||null)}return l.get(g)},a=[],p=(b,S)=>{let g=i(e,b),d=i(t,S),w=g&&d&&n(d)!==g?"transfer":"retained",O=a[a.length-1];O&&O.to===b&&O.target+O.to-O.from===S&&O.kind===w&&O.destination===d?O.to++:a.push({from:b,to:b+1,target:S,destination:d,kind:w})},f=0,u=0,y=!1;try{for(;f<e.text.length||u<t.text.length;){if(f<e.text.length&&u<t.text.length&&e.text[f]===t.text[u]){let O=e.atomAt.get(f),T=t.atomAt.get(u);if(!!O!=!!T||O&&n(T.el)!==O.el)return{status:"none"};p(f++,u++);continue}if(!c(e.text,f)&&!c(t.text,u))return{status:"none"};let b=f,S=u;for(;c(e.text,f);)f++;for(;c(t.text,u);)u++;let g=e.text.slice(b,f),d=t.text.slice(S,u);(g.includes(xt)||d.includes(xt))&&(y=!0);let w=0;for(;w<f-b&&w<u-S&&e.text[f-w-1]===t.text[u-w-1];)w++;for(let O=w;O>0;O--)p(f-O,u-O)}}catch(b){if(b===s)return{status:"fallback",reason:"work-limit"};throw b}return y?Vn({base:e,side:t,retained:a.filter(b=>b.kind==="retained"),transfers:a.filter(b=>b.kind==="transfer"),sideAtomKey:b=>n(b.el)||b.el,budget:o}):{status:"none"}}var ki=/\s/,Sr=/\S/;function Rn(e,t,n,o,r,c,l=-1,s=-1){if(!e.length)return-1;r(o,e.length);let i=new Int32Array(e.length),a=0;for(let y=1;y<e.length;y++){for(r(o,1);a&&(r(o,1),e[a]!==e[y]);)a=i[a-1];r(o,1),e[a]===e[y]&&a++,i[y]=a}let p=-1,f=0,u=0;a=0;for(let y=0;y<t.length;y++){for(r(o,1);a&&(r(o,1),e[a]!==t[y]);)a=i[a-1];if(r(o,1),e[a]===t[y]&&a++,a!==e.length)continue;let b=y+1-e.length,S=y+1;for(a=i[a-1];f<n.length&&n[f].from<b;)r(o,1),f++;for(;u<n.length&&n[u].to<S;)r(o,1),u++;if(r(o,6),!(f===n.length||u===n.length||n[f].from!==b||n[u].to!==S||l>=0&&b<s&&S>l)){if(!c)return b;if(p>=0)return-1;p=b}}return p}function Ko(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function fs(e,t,n,o){let r=null;for(let l of t)if(o(n,1),!(l.source!==e.source||l.side!==e.side))for(let s of l.runs){if(o(n,1),s.source!==e.source)continue;let i=Math.max(e.from,s.from),a=Math.min(e.to,s.to);i>=a||(r||(o(n,e.to-e.from),r=new Uint8Array(e.to-e.from)),o(n,a-i),r.fill(1,i-e.from,a-e.from))}if(!r)return!1;o(n,e.to-e.from);let c=!1;for(let l=e.from;l<e.to;l++)if(Sr.test(e.flat.text[l])){if(!r[l-e.from])return!1;c=!0}return c}function us({source:e,side:t,views:n,eligible:o,blocked:r,baseId:c,model:l,tokensOf:s,budget:i,charge:a}){let{V:p,A:f,idOf:u}=n[t],y=n[1-t];if(e.nodeType!==1||f.identical.has(e)||y.A.identical.has(e)||r.has(e)||!o(e))return null;let b=p.twin(e),S=y.V.twin(e);if(!b||!S||f.map.get(e)!==b||f.reverse.get(b)!==e||y.A.map.get(e)!==S||y.A.reverse.get(S)!==e||!p.here(b)||!y.V.here(S)||!o(b)||!o(S))return null;let g=c(e);if(g!==u(b)||g!==y.idOf(S))return null;let d=l(e,null,i),w=l(b,f,i),O=l(S,y.A,i);if(!Ko(d)||!Ko(w)||!Ko(O))return null;let T=d.flat.text,k=w.flat.text;if(a(i,T.length+k.length*3),!Sr.test(k)||k.length>=T.length)return null;let v=T.startsWith(k),I=T.endsWith(k);if(v===I)return null;let M=v?k.length:0,P=v?T.length:T.length-k.length,D=M,$=P;for(;D<$&&(a(i,1),!!ki.test(T[D]));)D++;for(;$>D&&(a(i,1),!!ki.test(T[$-1]));)$--;if(D===$)return null;let W=s(d,i),B=!1,x=!1;for(let A of W)a(i,1),A.from===D&&(B=!0),A.to===$&&(x=!0);return!B||!x?null:{source:e,side:t,flat:d.flat,from:M,to:P}}function Ti({base:e,views:t,side:n,attempt:o,eligible:r,blocked:c,baseId:l,model:s,tokensOf:i,certificates:a,charge:p,exhausted:f,limit:u}){if(u<=0)return null;let y=zt(u),{V:b,A:S,idOf:g}=t[n],d=t[1-n],[w,O,T,k]=o,v=null;try{for(let I=w;I<=O;I++){p(y,1);let M=e[I];if(M.nodeType!==1||S.identical.has(M)||d.A.identical.has(M)||c.has(M)||!r(M))continue;let P=us({source:M,side:n,views:t,eligible:r,blocked:c,baseId:l,model:s,tokensOf:i,budget:y,charge:p});if(!P||fs(P,a,y,p))continue;let{flat:D,from:$,to:W}=P;p(y,(W-$)*2);let B=D.text.slice($,W).trim();for(let x=T;x<=k;x++){p(y,1);let A=b.units[x],X=b.baseOf(A);if(!X||X===M||X.nodeType!==1||A.nodeType!==1||X.parentNode!==M.parentNode||A.parentNode!==S.map.get(M).parentNode||S.map.get(X)!==A||S.reverse.get(A)!==X||c.has(X)||!r(X)||!r(A)||l(X)!==g(A))continue;let H=s(X,null,y),q=s(A,S,y);if(!Ko(H)||!Ko(q))continue;let Ee=H.flat.text,Me=q.flat.text;if(p(y,Ee.length),!Sr.test(Ee)||Me.length<=Ee.length)continue;let je=i(q,y),ae=Rn(Ee,Me,je,y,p,!0);if(!(ae<0)&&!(Rn(B,Me,je,y,p,!1,ae,ae+Ee.length)<0)){(v||=[]).push(P);break}}}}catch(I){if(I!==f)throw I}return v}function Ai(e,t,n,o,r,c,l){if(c==="both"||n.atoms.length||o.atoms.length||r.atoms.length)return c;let s=c==="remote";if(s?l.rss!==l.rse||l.lss===l.lse||l.local===l.base:l.lss!==l.lse||l.rss===l.rse||l.remote===l.base)return c;for(let i of e){if(i.source!==t||i.side!==(s?1:0)||i.flat.text!==n.text||i.flat.nodes.length!==n.nodes.length||l.be<=i.from||l.bs>=i.to)continue;let a=!0;for(let f=0;f<n.nodes.length;f++){let u=i.flat.nodes[f],y=n.nodes[f];if(u.node!==y.node||u.s!==y.s||u.e!==y.e){a=!1;break}}if(!a)continue;let p=!1;for(let f=l.bs;f<l.be;f++)if(Sr.test(n.text[f])){if(f<i.from||f>=i.to){a=!1;break}p=!0}if(a&&p)return s?"local":"remote"}return c}var _n="\uFFFC";var Fc={caret:0},An=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(" ")),Ci=new Set(["BR","WBR","IMG"]),ds=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 Fn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||Ci.has(e.tagName))return!0;if(!An.has(e.tagName))return!ds.has(e.tagName);if(t.remoteWins&&t.remoteWins(e))return!1;let n=t.inlineCache&&t.inlineCache.get(e);if(n!==void 0)return n;let o=!0;for(let r of e.childNodes)if(!Fn(r,t)){o=!1;break}return t.inlineCache&&t.inlineCache.set(e,o),o}function qc(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function nn(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,c)=>{for(let l of r){if(l.nodeType===3){let f=l.nodeValue;if(!f)continue;n.nodes.push({node:l,s:n.text.length,e:n.text.length+f.length}),n.text+=f;for(let u=0;u<f.length;u++)n.stackAt.push(c);continue}if(l.nodeType!==1)continue;if(t.ignored&&t.ignored(l)){n.pins.push({el:l,i:n.text.length});continue}if(t.skip&&t.skip.has(l))continue;let s=t.via&&t.via(l)||l;s!==l&&(n.via||(n.via=new Map)).set(s,l);let i=l.tagName;if(t.blocks&&t.blocks.has(l)){n.text.length&&n.text[n.text.length-1]!==xt&&(n.stackAt.push(c),n.text+=xt);let f={el:l,tag:i,from:n.text.length,to:-1,depth:c.length,block:!0};n.marks.push(f);let u=c.concat([f]);o(s.childNodes,u),n.stackAt.push(u),n.text+=xt,f.to=n.text.length;continue}let a=An.has(i)&&qc(s);if(Ci.has(i)||!An.has(i)||t.remoteWins&&t.remoteWins(l)||t.atomize&&t.atomize(l)||a){n.atoms.push({i:n.text.length,el:l,key:a?i+":empty":i,stack:c}),n.stackAt.push(c),n.text+=_n;continue}let p={el:l,tag:i,from:n.text.length,to:-1,depth:c.length};n.marks.push(p),o(s.childNodes,c.concat([p])),p.to=n.text.length}};if(o(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&Or(n).trim()===""){let r=n.atoms[0];n.placeholder=r.el,n.text=n.text.slice(0,r.i)+n.text.slice(r.i+1),n.stackAt.splice(r.i,1);for(let c of n.nodes)c.s>r.i&&(c.s--,c.e--);n.atoms=[]}return n.atomAt=new Map(n.atoms.map(r=>[r.i,r])),n}function $c(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Kc(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,"&quot;")}"`;return t+">"}function vo(e,t,n){let o="",r=[];for(let c=t;c<n;c++){let l=e.stackAt[c],s=0;for(;s<r.length&&s<l.length&&r[s]===l[s];)s++;for(;r.length>s;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<l.length;){let a=l[r.length];o+=Kc(a.el),r.push(a)}let i=e.atomAt.get(c);o+=i?i.el.outerHTML:e.text[c]===xt?"":$c(e.text[c])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function zc(e,t){let n=[...e.el.attributes].filter(o=>!t(e.el,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tag+"|"+n}function Ri(e,t){let n=[...e.attributes].filter(o=>!t(e,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tagName+"|"+n+"|"+e.innerHTML}function Si(e,t=()=>!1){let n=new Map,o=c=>{let l=n.get(c);return l===void 0&&(l="{"+c.map(s=>zc(s,t)).sort().join(",")+"}",n.set(c,l)),l},r="";for(let c=0;c<e.text.length;c++){let l=e.atomAt.get(c);r+=(l?"["+Ri(l.el,t)+"]":e.text[c])+o(e.stackAt[c])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function No(e,t,n,o=r=>r.key){let r=[],c=e.text,l=0,s=i=>{if(i<=l)return;let a=c.slice(l,i);if(n)for(let p of a.split(/(?<=\n)/))r.push({k:p,raw:p,len:p.length});else for(let p of an(a,t))r.push(p)};for(let i of e.atoms)s(i.i),r.push({k:"\0"+o(i),raw:_n,len:1,atom:!0}),l=i.i+1;return s(c.length),r}function Or(e){if(!e.atoms.length)return e.text;let t="",n=0;for(let o of e.atoms)t+=e.text.slice(n,o.i),n=o.i+1;return t+e.text.slice(n)}var Oo=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n].len;return t};function Nr(e,t,n,o){let r=Oo(t),c=Oo(n),l=[],s=0,i=0;for(let p of o.hunks){i+=p.bs-s;let f=i+p.toks.length;l.push({bs:r[p.bs],be:r[p.be],ss:c[i],se:c[f],text:e.text.slice(c[i],c[f]),toks:p.toks,lead:!!p.lead}),i=f,s=p.be}let a=new Map;for(let p of o.cosmetic)a.set(p.bi,p.tok.raw);return{hunks:l,respell:a}}function Ni(e,t,n){let o=l=>l===xt||/\s/.test(l),r=l=>l.replace(/[\u001E\s]/g,""),c=[];for(let l of e){let s=t.slice(l.bs,l.be),i=n.slice(l.ss,l.se);if(!s.includes(xt)&&!i.includes(xt)||s.includes(_n)||i.includes(_n)||r(s)!==r(i)){c.push(l);continue}let a=0,p=0;for(;;){let f=a,u=p;for(;f<s.length&&o(s[f]);)f++;for(;u<i.length&&o(i[u]);)u++;let y=a,b=p;for(;y<f&&b<u&&s[y]===i[b];)y++,b++;let S=f,g=u;for(;S>y&&g>b&&s[S-1]===i[g-1];)S--,g--;if(S>y||g>b){let d=i.slice(b,g);c.push({bs:l.bs+y,be:l.bs+S,ss:l.ss+b,se:l.ss+g,text:d,toks:[...d].map(w=>({k:w,raw:w,len:1})),lead:l.lead})}if(f>=s.length)break;a=f+1,p=u+1}}return c}function vi(e,t,n){let o=new Int32Array(t+1).fill(-1),r=new Int32Array(n+1).fill(-1),c=0,l=0,s=i=>{for(;c<i;)o[c]=l,r[l]=c,c++,l++};for(let i of e)s(i.bs),c=i.be,l=i.se;return s(t),o[t]=l,r[l]=t,{bTo:o,toB:r}}function Oi(e,t,n){let o=[],r=0,c=0,l=(s,i)=>{if(r===s&&c===i)return;let a=t.text.slice(c,i);o.push({bs:r,be:s,ss:c,se:i,text:a,toks:an(a,Tn(a)),lead:!1})};for(let s of n.runs)l(s.from,s.target),r=s.to,c=s.target+s.to-s.from;return l(e.text.length,t.text.length),{hunks:o,respell:new Map}}function Mi(e,t,n,o){let r=Oo(t),c=Oo(n),l=(i,a)=>{let p=0,f=i.length;for(;p<f;){let u=p+f>>>1;i[u]<a?p=u+1:f=u}return i[p]===a?p:-1};for(let i of e.hunks)if(l(r,i.bs)<0||l(r,i.be)<0)return null;if(e.hunks.some(i=>l(c,i.ss)<0||l(c,i.se)<0)){if(!o)return null;let i=[];for(let u of e.hunks)i.push(u.ss,u.se);let a=[],p=0,f=0;for(let u of n){let y=f+u.len;for(;p<i.length&&i[p]<=f;)p++;let b=f;for(;p<i.length&&i[p]<y;){let S=i[p++];if(S>b){let g=u.raw.slice(b-f,S-f);a.push(...an(g,Tn(g))),b=S}}if(b===f)a.push(u);else{let S=u.raw.slice(b-f);a.push(...an(S,Tn(S)))}f=y}n=a,c=Oo(n)}let s=[];for(let i of e.hunks){let a=l(r,i.bs),p=l(r,i.be),f=l(c,i.ss),u=l(c,i.se);if(a<0||p<0||f<0||u<0)return null;s.push({bs:a,be:p,toks:n.slice(f,u),gap:[],group:s.length})}return{parts:s,cosmeticEq:[],tokens:n}}function hs(e,t,n,o={},r=null){return Li(e,t,n,o.base,o.local,o.remote,r,{})}function Li(e,t,n,o,r,c,l,s){let i=Tn(Or(e),Or(t),Or(n)),a=No(e,i,!1,o),p=No(t,i,!1,r),f=No(n,i,!1,c),u=a.length>2e4||p.length>2e4||f.length>2e4;u&&(a=No(e,i,!0,o),p=No(t,i,!0,r),f=No(n,i,!0,c));let y=l?.local?Oi(e,t,l.local):null,b=l?.remote?Oi(e,n,l.remote):null,S=y?Mi(y,a,p,!u):Gn(a,p),g=b?Mi(b,a,f,!u):Gn(a,f);y&&S&&(p=S.tokens),b&&g&&(f=g.tokens);let d,w;if(S&&g){let O=ls(S,g,a);d=Nr(t,a,p,{hunks:O.lh,cosmetic:O.cosL}),w=Nr(n,a,f,{hunks:O.rh,cosmetic:O.cosR})}else d=y||Nr(t,a,p,S),w=b||Nr(n,a,f,g);return d.hunks=Ni(d.hunks,e.text,t.text),w.hunks=Ni(w.hunks,e.text,n.text),s.base=e,s.local=t,s.remote=n,s.lines=u,s.baseTokens=a,s.localEdits=d,s.remoteEdits=w,s.localMap=vi(d.hunks,e.text.length,t.text.length),s.remoteMap=vi(w.hunks,e.text.length,n.text.length),s.full=null,s}function Ei(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Mo=/\s/;function vr(e,t,n){for(let o=t;o<n;o++)if(!Mo.test(e[o]))return!1;return!0}function Gc(e,t,n){let o=e.cache[n]||(e.cache[n]=new Map);if(o.has(t))return o.get(t);let r=n===0?"local":"remote",c=n===0?"remote":"local",l=t.baseMark,s=t[c+"Mark"],i=!t.block&&!t[r]&&!!s&&l.to>l.from;if(i){let a=n===0?e.ML:e.MR,p=n===0?e.MR:e.ML,f=n===0?e.fr:e.fl,u=!1;for(let y=l.from;y<l.to;y++){if(a.bTo[y]>=0){i=!1;break}p.bTo[y]<0&&!Mo.test(e.fb.text[y])&&(u=!0)}if(i&&!u){for(let y=s.from;y<s.to;y++)if(p.toB[y]<0&&!Mo.test(f.text[y])){u=!0;break}}i&&=u}return o.set(t,i),i}function Ii(e,t,n,o,r,c,l,s,i){let a=s===0?e.fl:e.fr,p=null;for(let f=n;f<o;f++){let u=t[f];if(!vr(a.text,u.ss,u.se))return null;if(vr(e.fb.text,u.bs,u.be)){if(u.bs<u.be&&u.ss<u.se||Mo.test(e.fb.text[u.bs-1]||"")||Mo.test(e.fb.text[u.be]||""))continue;return null}let y=!1;for(let b=u.bs;b<u.be;b++){if(Mo.test(e.fb.text[b]))continue;let S=null;for(let g of e.fb.stackAt[b]){let d=e.byEl.get(g.el);if(d&&Gc(e,d,s)){S=d;break}}if(!S)return null;(p||(p=new Set)).add(S),y=!0}if(!y)return null}if(!p){if((s===0?"local":"remote")!==i)return null;let f=s===0?e.fr:e.fl,u=!1;for(let y=c;y<l;y++){let b=r[y];if(!vr(e.fb.text,b.bs,b.be))return null;vr(f.text,b.ss,b.se)||(u=!0)}if(!u)return null}return p||0}function Mr(e){let{out:t,policy:n="remote",L:o,R:r}=e,c=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,s=e.conflicts||[],i=e.decisions||[],a=s.length,p=e.conflict||(m=>s.push(m)),f={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},u=[],y=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),b={base:null,local:null,remote:null};if(!e.prepared&&y&&e.moveIn){let m=Te=>De=>Te.some(Ce=>Ce===De||Ce.nodeType===1&&Ce.contains(De)),L=m(e.local),_=m(e.remote),F=m(e.base),Z=new Set,pe=Te=>{if(!An.has(Te.tagName))return;let De=o.map.get(Te),Ce=r.map.get(Te);(De&&!L(De)||Ce&&!_(Ce))&&Z.add(Te);for(let Ue of Te.children)pe(Ue)};for(let Te of e.base)Te.nodeType===1&&pe(Te);let we=Te=>De=>{if(!An.has(De.tagName))return!1;let Ce=Te.reverse.get(De);return!!Ce&&(Z.has(Ce)||!F(Ce))};Z.size&&(b.base=Te=>Z.has(Te)),b.local=we(o),b.remote=we(r)}let S={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&y&&e.moveIn){let m=F=>Z=>F.some(pe=>pe===Z||pe.nodeType===1&&pe.contains(Z)),L=m(e.local),_=m(e.remote);for(let F of nn(e.base,{...e,atomize:b.base}).atoms){let Z=o.map.get(F.el),pe=r.map.get(F.el),we=!!Z&&!L(Z),Te=!!pe&&!_(pe);!we&&!Te||(we&&e.movePlanned?.(F.el,"local",Z,null),Te&&e.movePlanned?.(F.el,"remote",pe,null),S.base.add(F.el),Z&&!we&&S.local.add(Z),pe&&!Te&&S.remote.add(pe),L(F.el)&&S.local.add(F.el),_(F.el)&&S.remote.add(F.el))}}let g=e.prepared?.base||nn(e.base,{...e,atomize:b.base,skip:S.base}),d=e.prepared?.local||nn(e.local,{...e,atomize:b.local,skip:S.local}),w=e.prepared?.remote||nn(e.remote,{...e,atomize:b.remote,skip:S.remote}),O=new Map(g.atoms.map(m=>[m.el,m])),T={},k=m=>e.prepared?e.prepared.full?.(m)||null:S[m].size?(T[m]||(T[m]=nn(e[m],{...e,atomize:b[m]})),T[m]):null,v=(m,L,_)=>{L.namespaceURI?m.setAttributeNS(L.namespaceURI,L.name,_):m.setAttribute(L.name,_)},I=(m,L,_,F)=>{if(!L&&(!_||!F)){for(let pe of(_||F).attributes)v(m,pe,pe.value);return}let Z=new Map;for(let pe of[L,_,F])if(pe)for(let we of pe.attributes)Z.set(we.name,we);for(let[pe,we]of Z){let Te=L?L.getAttribute(pe):null,De=_?_.getAttribute(pe):Te,Ce=F?F.getAttribute(pe):Te,Ue;De===Ce?Ue=De:De===Te?(Ue=Ce,i.push({kind:"attr",el:m,name:pe,source:"remote"})):Ce===Te?(Ue=De,i.push({kind:"attr",el:m,name:pe,source:"local"})):(Ue=n==="local"?De:Ce,p({kind:"attr",el:m,name:pe,base:Te,local:De,remote:Ce,resolved:Ue},{el:m,sample:we}),i.push({kind:"attr",el:m,name:pe,source:"both"})),Ue!=null&&v(m,we,Ue)}},M=(m,L,_,F)=>m&&e.mergeAttrs?e.mergeAttrs(m,L,_,F):I(F,m,L,_),P=e.mergeElement||((m,L,_)=>{let F=t.createElement(m.tagName);M(m,L,_,F);let Z=L||m,pe=_||m,we=n==="local"?Z.isEqualNode(m)?pe:Z:pe.isEqualNode(m)?Z:pe;for(let Te of we.childNodes)F.appendChild(t.importNode(Te,!0));return c.set(F,{base:m,local:L,remote:_}),F}),D=e.cloneUnit||((m,L)=>{let _=t.importNode(m,!0);return c.set(_,{base:null,local:L==="local"?m:null,remote:L==="remote"?m:null}),_}),$=e.atomKey||(m=>Ri(m,()=>!1)),W=(m,L)=>{let _=new Map;for(let F of m.atoms)if(e.remoteWins&&e.remoteWins(F.el)&&An.has(F.el.tagName))_.set(F,"w"+F.el.tagName+"#"+(F.el.id||""));else if(!y)_.set(F,F.key);else if(m===g)_.set(F,"="+$(F.el));else{let Z=L.reverse.get(F.el),pe=Z?O.get(Z):null;pe?_.set(F,"="+$(pe.el)):Z?_.set(F,"m"+$(F.el)):_.set(F,"="+$(F.el))}return F=>_.get(F)},B=W(g,null),x=W(d,o),A=W(w,r),X=e.certifiedOrigins?e.certifiedOrigins(g,d,w,B,x,A):null;if(X?.fallback)return null;if(!X&&!e.prepared&&e.blocks){let m=zt(),L=as({base:g,side:d,baseOf:F=>o?.reverse?.get(F)||null,budget:m}),_=as({base:g,side:w,baseOf:F=>r?.reverse?.get(F)||null,budget:m});(L.status==="ready"||_.status==="ready")&&(X={local:L.status==="ready"?L:null,remote:_.status==="ready"?_:null})}let H=e.prepared||Li(g,d,w,B,x,A,X,f),q=H.lines,Ee=H.baseTokens,Me=H.localEdits,je=H.remoteEdits,ae=H.localMap,Ae=H.remoteMap,_e=g.text.length,ve=m=>new Map(m.atoms.map(L=>[L.el,L])),N=ve(d),J=ve(w),le=(m,L,_)=>{let F=new Set;if(!y)return F;for(let Z of m.atoms){let pe=O.get(L.reverse.get(Z.el));pe&&_.bTo[pe.i]<0&&F.add(pe)}return F},oe=le(d,o,ae),Re=le(w,r,Ae),Be=m=>!Fn(m,{...e,remoteWins:null}),Se=new Set;if(y)for(let m of g.atoms){if(!Be(m.el))continue;let L=o.map.get(m.el)||null,_=r.map.get(m.el)||null,F=L&&!_?L:_&&!L?_:null;F&&(N.has(F)||J.has(F))&&!F.isEqualNode(m.el)&&Se.add(m)}let nt=1,Je=(m,L)=>({id:nt++,tag:m,base:null,local:null,remote:null,rank:L}),ht=new Map,Ge=[];for(let m of g.marks){let L=Je(m.tag,m.depth);L.block=!!m.block,L.base=m.el,L.baseMark=m,ht.set(m.el,L),Ge.push(L)}let st=(m,L)=>{let _=-1,F=-1;for(let Z=m.from;Z<m.to;Z++){let pe=L[Z];pe>=0&&(_<0&&(_=pe),F=pe+1)}return _<0?null:[_,F]},Mt=(m,L,_,F)=>{for(let Z of m.marks){let pe=_?_.reverse.get(Z.el):null;pe&&_.identical.has(pe)&&_.pairIdenticalChildren&&_.pairIdenticalChildren(pe);let we=pe?ht.get(pe):null;if(we&&we[L]&&(we=null),!we){let Te=st(Z,F),De=0;if(Te)for(let Ce of Ge){if(Ce.tag!==Z.tag||Ce[L]||!!Ce.block!=!!Z.block)continue;let Ue=Math.min(Te[1],Ce.baseMark.to)-Math.max(Te[0],Ce.baseMark.from);(Ue>De||Ue===De&&Ue>0&&Math.abs(Ce.rank-Z.depth)<Math.abs(we.rank-Z.depth))&&(we=Ce,De=Ue)}}we||(we=Je(Z.tag,Z.depth),we.block=!!Z.block,we.new=L),we[L]=Z.el,we[L+"Mark"]=Z,ht.set(Z.el,we)}};Mt(d,"local",o,ae.toB),Mt(w,"remote",r,Ae.toB);let It=m=>m.merged||m,yt=m=>{let L=new Set;for(let _ of m)_.block||L.add(ht.get(_.el));return L},Nt=new Map,Ct=m=>{let L=Nt.get(m);return L||(L=yt(m),Nt.set(m,L)),L},_t=(m,L)=>{let _=[],F=null;for(let Z=0;Z<_e;Z++){let pe=L[Z];if(pe<0){F&&_.push(F),F=null;continue}let we=Ct(g.stackAt[Z]),Te=Ct(m.stackAt[pe]),De=new Set,Ce=new Set;for(let Ue of Te)we.has(Ue)||De.add(Ue);for(let Ue of we)Te.has(Ue)||Ce.add(Ue);if(!De.size&&!Ce.size){F&&_.push(F),F=null;continue}if(F&&Ei(F.added,De)&&Ei(F.removed,Ce)){F.be=Z+1;continue}F&&_.push(F),F={bs:Z,be:Z+1,added:De,removed:Ce}}return F&&_.push(F),_},fn=_t(d,ae.bTo),Et=_t(w,Ae.bTo),Gt=m=>m.be>m.bs?[m.bs,m.be-1]:[m.bs-1,m.bs],wn=(m,L)=>{if(_e===0)return null;let[_,F]=Gt(m);for(let Z of L){if(Z.be<=_)continue;if(Z.bs>F)break;let pe=Z.bs<=_&&F<Z.be;return pe&&m.text===""&&Z.bs===m.bs&&Z.be===m.be?"straddle":pe?Z:m.be>m.bs?"straddle":null}return null},Bt=m=>m.bs===m.be,ln=(m,L,_=null)=>{let F=!1;for(let Z=m.bs;Z<m.be;Z++){let pe=g.text[Z];if(pe===xt)F=!0;else if(!/\s/.test(pe))return!1}for(let Z=m.ss;Z<m.se;Z++){let pe=L.text[Z];if(pe===xt)F=!0;else if(!/\s/.test(pe)){let we=_&&e.scopeUnits&&Bt(m)&&L.atomAt.get(Z);if(!we||!Be(we.el)||_.ss!==_.se||_.bs>=_.be)return!1;for(let De=_.bs;De<_.be;De++)if(!/\s/.test(g.text[De]))return!1;let Te=L===d?1:2;if(!e.scopeUnits[Te].includes(we.el)||(Te===1?o:r)?.reverse.has(we.el))return!1;F=!0}}return F},Yt=(m,L)=>m.bs<L.be&&L.bs<m.be,un=(m,L)=>m.bs<=L.be&&L.bs<=m.be&&Bt(m)!==Bt(L),z=(m,L)=>g.text.slice(m.bs,m.be).includes(xt)||L.text.slice(m.ss,m.se).includes(xt),h=m=>{if(Bt(m))return!1;let L=m.bs,_=m.be;for(;L>0&&/\s/.test(g.text[L-1]);)L--;for(;_<g.text.length&&/\s/.test(g.text[_]);)_++;return(L===0||g.text[L-1]===xt)&&(_===g.text.length||g.text[_]===xt)},E=(m,L)=>!z(m,L)&&!h(m),R=(m,L)=>Yt(m,L)||un(m,L)&&!(m.transferIn||m.transferOut||L.transferIn||L.transferOut)&&!(ln(m,d,L)&&E(L,w))&&!(ln(L,w,m)&&E(m,d)),V=(m,L)=>{if(m.bs!==L.bs||m.be!==L.be||m.toks.length!==L.toks.length)return!1;let _=m.ss,F=L.ss;for(let Z=0;Z<m.toks.length;Z++){let pe=m.toks[Z],we=L.toks[Z];if(pe.k!==we.k||pe.atom&&!d.atomAt.get(_).el.isEqualNode(w.atomAt.get(F).el))return!1;_+=pe.len,F+=we.len}return!0},Q=(m,L,_,F)=>{for(let Z of g.atoms){if(Z.i<m.bs||Z.i>=m.be||F.has(Z)||Se.has(Z))continue;let pe=L.bTo[Z.i],we=pe>=0?_.atomAt.get(pe):null;if(we&&!we.el.isEqualNode(Z.el))return!0}return!1},j=[],ue=null,be=null,ie=Me.hunks,Ne=je.hunks,U=0,Y=0,he=0,ge=0,de=0,ee=m=>{m>he&&(j.push({src:"base",from:he,to:m,dL:ge,dR:de}),he=m)};for(;U<ie.length||Y<Ne.length;){let m=ie[U],L=Ne[Y],_=!!m&&(!L||m.bs<L.bs||m.bs===L.bs&&m.be<=L.be&&!L.lead);if(m&&L&&m.bs===L.bs&&Bt(m)&&Bt(L)){let $t=ln(m,d),Fo=ln(L,w);$t!==Fo&&(_=Fo)}let F=_?m:L,Z=_?L:m,pe=!!Z&&V(m,L),we=!!Z&&(_?!!ie[U+1]&&V(ie[U+1],L):!!Ne[Y+1]&&V(m,Ne[Y+1])),Te=!!Z&&!pe&&!we&&(_e===0||R(m,L)),De=Te,Ce=wn(F,_?Et:fn);if(Ce==="straddle"&&(De=!0),!De&&F.be>F.bs&&(De=Q(F,_?Ae:ae,_?w:d,_?oe:Re)),!De&&pe){ee(F.bs),j.push({src:"both",lfrom:m.ss,rfrom:L.ss,len:F.text.length,owner:m.owner||L.owner||null,transfer:m.transferIn||L.transferIn||null}),he=F.be,ge+=F.text.length-(F.be-F.bs),de+=F.text.length-(F.be-F.bs),U++,Y++;continue}if(!De){ee(F.bs),j.push({src:_?"local":"remote",from:F.ss,to:F.se,inherit:Ce&&Ce!=="straddle"?Ce:null,owner:F.owner||null,transfer:F.transferIn||null}),he=F.be,_?(ge+=F.text.length-(F.be-F.bs),U++):(de+=F.text.length-(F.be-F.bs),Y++);continue}let Ue=F.bs,gt=F.be,ct=U,dt=Y,Ht=$t=>$t.bs<gt&&$t.be>Ue||Bt($t)&&($t.bs===Ue||$t.bs===gt);_?ct++:dt++,Te&&(Ue=Math.min(Ue,Z.bs),gt=Math.max(gt,Z.be),_?dt++:ct++);let jt=!0;for(;jt;){for(jt=!1;ct<ie.length&&Ht(ie[ct]);)Ue=Math.min(Ue,ie[ct].bs),gt=Math.max(gt,ie[ct].be),ct++,jt=!0;for(;dt<Ne.length&&Ht(Ne[dt]);)Ue=Math.min(Ue,Ne[dt].bs),gt=Math.max(gt,Ne[dt].be),dt++,jt=!0}let gn=Ue+ge,cn=Ue+de,xn=gt-Ue,vn=gt-Ue;for(let $t=U;$t<ct;$t++)xn+=ie[$t].text.length-(ie[$t].be-ie[$t].bs);for(let $t=Y;$t<dt;$t++)vn+=Ne[$t].text.length-(Ne[$t].be-Ne[$t].bs);let Hn=gn+xn,Wn=cn+vn;if(ee(Ue),U<ct&&Y<dt&&!X&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!d.atoms.length&&!w.atoms.length&&!g.pins.length&&!d.pins.length&&!w.pins.length){ue||={fb:g,fl:d,fr:w,ML:ae,MR:Ae,byEl:ht,cache:[null,null]};let $t=Ii(ue,ie,U,ct,Ne,Y,dt,0,n),Fo=Ii(ue,Ne,Y,dt,ie,U,ct,1,n);if($t===null!=(Fo===null)){let _r=$t!==null,li=_r?$t:Fo;if(li){be||=new Map;for(let Ql of li)be.set(Ql,_r?"local":"remote")}j.push(_r?{src:"remote",from:cn,to:Wn}:{src:"local",from:gn,to:Hn}),he=gt,ge+=xn-(gt-Ue),de+=vn-(gt-Ue),U=ct,Y=dt;continue}}let en={kind:"text",node:e.node||null,base:vo(g,Ue,gt),local:vo(d,gn,Hn),remote:vo(w,cn,Wn),resolved:null,range:null,bs:Ue,be:gt,lss:gn,lse:Hn,rss:cn,rse:Wn},lo=e.sourceRetentions?Ai(e.sourceRetentions,e.scope?.base,g,d,w,n,en):n;en.resolved=lo==="local"?en.local:lo==="remote"?en.remote:en.local+en.remote,lo!=="remote"&&j.push({src:"local",from:gn,to:Hn,conflict:en}),lo!=="local"&&j.push({src:"remote",from:cn,to:Wn,conflict:en});let co={site:"inline",policy:lo,fb:g,fl:d,fr:w,scope:e.scope||null,synthetic:!!e.synthetic,full:k,merged:f};u.push(co),p(en,co),he=gt,ge+=xn-(gt-Ue),de+=vn-(gt-Ue),U=ct,Y=dt}ee(_e);let te=g.text,K=[];if(Me.respell.size||je.respell.size){let m=Oo(Ee),L=[];for(let _=0;_<Ee.length;_++){let F=Ee[_].raw,Z=Me.respell.get(_)??F,pe=je.respell.get(_)??F;(Z!==F||pe!==F)&&K.push([m[_],Z!==F&&pe!==F?"both":Z!==F?"local":"remote"]),L.push(Z===pe?Z:Z===F?pe:pe===F||n==="local"?Z:pe)}te=L.join("")}let ne="",xe=[],Ie=[],Le=[],ke=[];for(let m of j){let L=ne.length;if(m.src==="base"){for(let _=m.from;_<m.to;_++)xe.push(_),Ie.push(e.nativeTransfers?ae.bTo[_]:_+m.dL),Le.push(e.nativeTransfers?Ae.bTo[_]:_+m.dR),ke.push(m);ne+=te.slice(m.from,m.to)}else if(m.src==="both"){for(let _=0;_<m.len;_++){let F=m.transfer&&(m.transfer.side==="remote"?m.rfrom+_:m.lfrom+_);xe.push(m.transfer&&F>=m.transfer.ss&&F<m.transfer.se?m.transfer.bs+F-m.transfer.ss:-1),Ie.push(m.lfrom+_),Le.push(m.rfrom+_),ke.push(m)}ne+=d.text.slice(m.lfrom,m.lfrom+m.len)}else{let _=m.src==="local"?d:w,F=m.transfer&&e.nativeTransfers.byOrigin[m.src==="local"?"remote":"local"].get(m.transfer.key);for(let Z=m.from;Z<m.to;Z++){let pe=m.transfer&&Z>=m.transfer.ss&&Z<m.transfer.se?m.transfer.bs+Z-m.transfer.ss:-1,we=pe>=0&&(!F||F.destination===m.owner)?(m.src==="local"?Ae:ae).bTo[pe]:-1;xe.push(pe),Ie.push(m.src==="local"?Z:we),Le.push(m.src==="remote"?Z:we),ke.push(m)}ne+=_.text.slice(m.from,m.to)}m.ms=L,m.me=ne.length,m.conflict&&(m.conflict.range||(m.conflict.range=[L,L]),m.conflict.range[1]=ne.length)}let $e=ne.length,Xe=new Int32Array(_e+1).fill(-1),Qe=new Int32Array(d.text.length+1).fill(-1),Ut=new Int32Array(w.text.length+1).fill(-1);for(let m=0;m<$e;m++)xe[m]>=0&&(Xe[xe[m]]=m),Ie[m]>=0&&(Qe[Ie[m]]=m),Le[m]>=0&&(Ut[Le[m]]=m);let Pt=(m,L)=>{let _=-1,F=-1;for(let Z=m.from;Z<m.to;Z++){let pe=L[Z];pe>=0&&(_<0&&(_=pe),F=pe+1)}return _<0?null:[_,F]},C=[],G=[];for(let m of new Set(ht.values()))m.new==="local"?C.push(m):m.new==="remote"&&G.push(m);let se=(m,L)=>{m.remote=L.remote,m.remoteMark=L.remoteMark,m.new="both",L.merged=m,ht.set(L.remote,m)};if(C.length&&G.length){let m=e.idOf;for(let L of C){let _=m?m.local(L.local):null;if(!_)continue;let F=G.find(Z=>!Z.merged&&Z.tag===L.tag&&!!Z.block==!!L.block&&m.remote(Z.remote)===_);F&&se(L,F)}for(let L of C){if(L.remote)continue;let _=Pt(L.localMark,Qe);if(_)for(let F of G){if(F.merged||F.tag!==L.tag||!!F.block!=!!L.block)continue;let Z=Pt(F.remoteMark,Ut);if(Z&&Math.min(_[1],Z[1])-Math.max(_[0],Z[0])>0){se(L,F);break}}}}Nt.clear();let me=m=>{for(let L of m)if(L.block)return It(ht.get(L.el));return null},ye=g.marks.some(m=>m.block)||d.marks.some(m=>m.block)||w.marks.some(m=>m.block),ce=new Array($e).fill(null),re=new Set;if(e.nativeTransfers)for(let m=0;m<$e;m++){let L=ke[m].owner;ce[m]=L?It(ht.get(L)):xe[m]>=0?me(g.stackAt[xe[m]]):null}else if(ye){let m=(Ce,Ue,gt)=>{let ct=new Set([Ce,Ue,gt]);ct.delete(null);let dt=[];for(let jt of ct){let gn=jt===Ce,cn=jt===Ue,xn=jt===gt;(cn===xn?cn:cn===gn?xn:cn)&&dt.push(jt)}if(dt.length<=1)return dt[0]||null;let Ht=n==="local"?Ue:gt;return dt.includes(Ht)?Ht:dt[0]},L=(Ce,Ue)=>Ue>=0?me(Ce.stackAt[Ue]):null,_=new Map;for(let Ce=0;Ce<$e;Ce++){if(ne[Ce]!==xt)continue;let Ue=xe[Ce]>=0?L(g,xe[Ce]):null,gt=L(d,Ie[Ce]),ct=L(w,Le[Ce]);_.set(Ce,[Ue,xe[Ce]>=0?m(Ue,gt,ct):gt||ct])}let F=new Set([..._.values()].map(Ce=>Ce[1])),Z=Ce=>Ce!==xt&&Ce!==_n&&!/\s/.test(Ce),pe=(Ce,Ue)=>{let gt=Ce;for(;gt<Ue&&!Z(ne[gt]);)gt++;return gt<Ue&&xe[gt]>=0?L(g,xe[gt]):null},we=new Map,Te=0;for(let Ce=0;Ce<$e;Ce++){if(ne[Ce]!==xt)continue;let[Ue,gt]=_.get(Ce),ct=pe(Te,Ce),dt=gt,Ht=we.get(dt)===dt&&ct===dt;dt&&we.has(dt)&&!Ht&&Ue&&!we.has(Ue)&&!F.has(Ue)&&(dt=Ue),dt&&!we.has(dt)&&we.set(dt,ct);for(let jt=Te;jt<=Ce;jt++)ce[jt]=dt;Te=Ce+1}let De=Ce=>{for(let Ue=0;Ue<Ce.text.length;Ue++)if(Z(Ce.text[Ue])&&!L(Ce,Ue))return!0;return!1};if(!De(g)&&!De(d)&&!De(w)){let Ce=[],Ue=0;for(let ct=0;ct<$e;ct++)(ne[ct]===xt||ct===$e-1)&&(Ce.push([Ue,ct]),Ue=ct+1);let gt=new Set(ce);for(let ct=0;ct<Ce.length;ct++){let[dt,Ht]=Ce[ct];if(ce[Ht])continue;let jt=dt;for(;jt<=Ht&&!Z(ne[jt]);)jt++;if(jt>Ht)continue;let gn=L(g,xe[jt]),cn=L(d,Ie[jt]),xn=L(w,Le[jt]),vn=m(gn,cn,xn)||cn||xn||gn;if(vn&&!gt.has(vn)){gt.add(vn);for(let en=dt;en<=Ht;en++)ce[en]=vn;continue}let Hn=ct>0&&ce[Ce[ct-1][1]],Wn=ct+1<Ce.length&&ce[Ce[ct+1][1]];if(Hn)re.add(Ce[ct-1][1]);else if(Wn&&ne[Ht]===xt)re.add(Ht);else continue;for(let en=dt;en<=Ht;en++)ce[en]=Hn||Wn}}}let Oe=new Map,Pe=m=>{let L=Oe.get(m);if(L)return L;L=[1/0,-1/0];for(let[_,F]of[[m.baseMark,Xe],[m.localMark,Qe],[m.remoteMark,Ut]]){let Z=_&&Pt(_,F);Z&&(L[0]=Math.min(L[0],Z[0]),L[1]=Math.max(L[1],Z[1]))}return Oe.set(m,L),L},We=(m,L,_)=>{let F=-1,Z=-1;for(let pe=0;pe<m.length;pe++){let we=ht.get(m[pe].el);we===L&&(F=pe),we===_&&(Z=pe)}return F>=0&&Z>=0?F-Z:0},Fe=(m,L)=>[...m].sort((_,F)=>{for(let we of L){let Te=We(we,_,F);if(Te)return Te}let Z=Pe(_),pe=Pe(F);return Z[0]-pe[0]||pe[1]-Z[1]||_.rank-F.rank||_.id-F.id}),pt=new Map,tt=new Map,Ft=e.nativeTransfers?[]:null,Wt=m=>{if(Ft)return Ft;let L=xe[m],_=Ie[m],F=Le[m],Z=ke[m];if(L>=0){let ct=g.stackAt[L],dt=d.stackAt[_],Ht=w.stackAt[F],jt=pt.get(ct);jt||pt.set(ct,jt=new Map);let gn=jt.get(dt);gn||jt.set(dt,gn=new Map);let cn=gn.get(Ht);if(cn)return cn;let xn=Ct(ct),vn=Ct(dt),Hn=Ct(Ht),Wn=new Set;for(let en of new Set([...xn,...vn,...Hn])){let lo=xn.has(en),co=vn.has(en),$t=Hn.has(en);(co===$t?co:co===lo?$t:co)&&Wn.add(en)}return cn=Fe(Wn,[dt,Ht,ct]),gn.set(Ht,cn),cn}if(Z.src==="both"){let ct=d.stackAt[_],dt=w.stackAt[F];return Fe(new Set([...Ct(ct),...Ct(dt)]),[ct,dt])}let we=(Z.src==="local"?d:w).stackAt[Z.src==="local"?_:F];if(!Z.inherit)return Fe(Ct(we),[we]);let Te=tt.get(Z);Te||tt.set(Z,Te=new Map);let De=Te.get(we);if(De)return De;let Ce=new Set(Ct(we));for(let ct of Z.inherit.added)Ce.add(It(ct));for(let ct of Z.inherit.removed)Ce.delete(It(ct));let Ue=Z.src==="local"?w:d,gt=(Z.src==="local"?Ae.bTo:ae.bTo)[Z.inherit.bs];return De=Fe(Ce,[we,Ue.stackAt[gt]]),Te.set(we,De),De},dn=new Int32Array(d.text.length+1);dn[d.text.length]=$e;for(let m=d.text.length-1;m>=0;m--)dn[m]=Qe[m]>=0?Qe[m]:dn[m+1];Fc.caret+=d.text.length;let bt=m=>m<=0?0:(m>d.text.length&&(m=d.text.length),Qe[m-1]>=0?Qe[m-1]+1:dn[m]),lt=[],ze=[],At=null,at=[],Dt="",yn=-1,on=m=>{At?At.appendChild(m):lt.push(m)},pn=m=>{if(!Dt)return;let L=t.createTextNode(Dt);on(L),ze.push({node:L,ms:yn,me:m,local:[],u:at.length?at[at.length-1].u:null}),Dt=""},Jt=new Set,Dn=new Map,wo=new Set,Bn=m=>{let L=t.createElement(m.tag);if(m.block&&Sn.add(L),!Dn.has(m)){Dn.set(m,L),M(m.base,m.local,m.remote,L),c.set(L,{base:m.base,local:m.local,remote:m.remote});let F=(we,Te)=>y&&m[Te]&&we.reverse.get(m[Te])?Te:null,Z=!m.base&&(F(o,"local")||F(r,"remote"));if(Z){let we=Z==="local"?o.reverse.get(m.local):r.reverse.get(m.remote),Te=c.get(L);Te.local=Te.local||o.map.get(we)||null,Te.remote=Te.remote||r.map.get(we)||null,i.push({kind:"move",el:L,source:Z}),e.moveBuilt?.(we,Z,m[Z],L)}else m.base||i.push({kind:"insert",el:L,source:m.local&&m.remote?"both":m.local?"local":"remote"});let pe=c.get(L);pe.local&&(wo.has(pe.local)?pe.local=null:wo.add(pe.local))}else{let F=Dn.get(m);for(let Z of F.attributes)Z.name!=="id"&&Z.name!=="data-id"&&v(L,Z,Z.value);c.set(L,{base:null,local:null,remote:null})}on(L),at.push({u:m,el:L}),At=L},Wo=new Set,Xn=new Map;for(let m of d.pins){let L=bt(m.i);Xn.has(L)||Xn.set(L,[]),Xn.get(L).push(m)}let gr=m=>{let L=Xn.get(m);if(L){pn(m);for(let _ of L){let F=_.el.namespaceURI&&_.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(_.el.namespaceURI,_.el.tagName):t.createElement(_.el.tagName);c.set(F,{base:null,local:_.el,remote:null,pinned:!0}),Wo.add(F),on(F)}}},Vr=g.atoms.length||d.atoms.length||w.atoms.length,br=m=>{if(!Vr)return null;let L=xe[m]>=0?g.atomAt.get(xe[m]):null,_=Ie[m]>=0?d.atomAt.get(Ie[m]):null,F=Le[m]>=0?w.atomAt.get(Le[m]):null;return L||_||F?{ab:L,al:_,ar:F}:null},Zn=(m,L,_)=>{let F=e.idOf;if(!F||!F.base)return!1;let Z=F.base(m.el);return Z!=null&&Z===F[_](L.el)},Vo=(m,L,_,F,Z)=>{if(!m||!y)return null;let pe=O.get(L.reverse.get(m.el))||null;return!pe||pe===F||(F?pe.el.isEqualNode(F.el)&&!Zn(pe,m,Z):_.bTo[pe.i]>=0)?null:pe},xo=(m,L)=>{if(!m||!y||!e.moveIn)return null;let _=L.reverse.get(m.el);return _&&!O.has(_)?_:null},_o=(m,L)=>{let _=new Map;for(let F of m.atoms)_.set(L(F),(_.get(L(F))||0)+1);return _},fe=_o(g,B),Ve=_o(d,x),He=_o(w,A),et=m=>{let L=B(m);return fe.get(L)===1&&(Ve.get(L)||0)<=1&&(He.get(L)||0)<=1},wt=new Map,qe=new Set,Ke=new Set,kt=new Set,Ye=null;for(let m=0;m<$e;m++){let L=br(m);if(!L)continue;let{ab:_,al:F,ar:Z}=L,pe=Vo(Z,r,Ae,_,"remote"),we=Vo(F,o,ae,_,"local"),Te=_,De=null;if(pe?(Te=pe,De="remote"):we&&(Te=we,De="local"),Te){_&&Te!==_&&(Ye||=new Map).set(_,De),qe.has(Te)?wt.set(m,{dup:Te.el}):(qe.add(Te),wt.set(m,{bk:Te,from:De,al:F,ar:Z}));continue}let Ce=xo(Z,r),Ue=xo(F,o),gt=Ce||Ue;if(gt){Ke.has(gt)?wt.set(m,{dup:gt}):(Ke.add(gt),wt.set(m,{moveIn:gt,side:Ce?"remote":"local",sideEl:Ce?Z.el:F.el}));continue}let ct=(Ht,jt)=>Ht&&y&&O.get(jt.reverse.get(Ht.el))||null,dt=ct(Z,r)||ct(F,o);if(dt&&(kt.add(dt),ke[m].conflict&&(et(dt)||Z&&(Z.el===dt.el||r.identityPaired?.has(dt.el))&&Zn(dt,Z,"remote")||F&&(F.el===dt.el||o.identityPaired?.has(dt.el))&&Zn(dt,F,"local")))){if(qe.has(dt)){wt.set(m,{dup:dt.el});continue}qe.add(dt)}wt.set(m,{al:F,ar:Z})}let rt=new Map,ft,Vt,Ot=(m,L)=>{if(m[L]>=0)return m[L];for(let _=L-1;_>=0;_--)if(m[_]>=0)return m[_]+1;return 0};if(y)for(let m of g.atoms){if(qe.has(m)||kt.has(m))continue;let L=o.map.get(m.el)||null,_=r.map.get(m.el)||null,F=L&&N.get(L),Z=_&&J.get(_);if(L&&!F||_&&!Z)continue;let pe=!(F&&Z)&&Se.has(m);if(!pe&&!(F&&Z&&(et(m)||Ye?.has(m)||(F.el===m.el||o.identityPaired?.has(m.el))&&(Z.el===m.el||r.identityPaired?.has(m.el))&&Zn(m,F,"local")&&Zn(m,Z,"remote"))))continue;let we=Ye?.get(m),Te=n;if(we){let ct=we==="local"?w:d,dt=we==="local"?r:o,Ht=we==="local"?Vt:ft;if(Ht===void 0){Ht=ct.atoms.length===g.atoms.length;for(let jt=0;Ht&&jt<g.atoms.length;jt++)Ht=dt.reverse.get(ct.atoms[jt].el)===g.atoms[jt].el;we==="local"?Vt=Ht:ft=Ht}Ht&&(Te=we)}let De=Te==="local"?[[F,Qe],[Z,Ut]]:[[Z,Ut],[F,Qe]],[Ce,Ue]=De.find(([ct])=>ct),gt=Ot(Ue,Ce.i);rt.has(gt)||rt.set(gt,[]),rt.get(gt).push({a:m,lt:L,rt:_,edited:pe}),qe.add(m)}if(y&&e.moveIn){let m=[[d,o,Qe,"local"],[w,r,Ut,"remote"]];n!=="local"&&m.reverse();for(let[L,_,F,Z]of m)for(let pe of L.atoms){let we=xo(pe,_);if(!we||Ke.has(we))continue;Ke.add(we);let Te=Ot(F,pe.i);rt.has(Te)||rt.set(Te,[]),rt.get(Te).push({move:we,side:Z,sideEl:pe.el})}}let Zt=m=>{let L=rt.get(m);if(L){if(pn(m),L.some(_=>Be(_.move?_.sideEl:_.a.el)))for(;at.length;)at.pop(),At=at.length?at[at.length-1].el:null;for(let{a:_,lt:F,rt:Z,edited:pe,move:we,side:Te,sideEl:De}of L){if(we){let Ue=e.moveIn(we,Te,De);Ue&&on(Ue);continue}Jt.add(_);let Ce=P(_.el,F,Z);pe&&(p({kind:"structure",el:Ce,detail:"edit-beats-delete",base:_.el},{subject:_.el,deleted:F?"remote":"local"}),i.push({kind:"insert",el:Ce,source:F?"local":"remote"})),on(Ce)}}},Sn=new Set,Qn=s.length>a;for(let m=0;m<$e;m++){let L=br(m),_=e.scopeUnits&&L&&(L.ab?.stack.some(we=>we.block)||L.al?.stack.some(we=>we.block)||L.ar?.stack.some(we=>we.block)),Z=!!L&&Be((L.ab||L.al||L.ar).el)&&!_?[]:ce[m]?[ce[m],...Wt(m)]:Wt(m),pe=0;for(;pe<at.length&&pe<Z.length&&at[pe].u===Z[pe];)pe++;if(pe<at.length)for(pn(m);at.length>pe;)at.pop(),At=at.length?at[at.length-1].el:null;if(gr(m),Zt(m),Z.length>at.length)for(pn(m);at.length<Z.length;)Bn(Z[at.length]);if(ne[m]===xt){if(re.has(m))continue;pn(m);let we=at.length;for(;we>0&&!at[we-1].u.block;)we--;if(we>0)for(Qn&&f.breakOut.set(m,at[we-1].el);at.length>=we;)at.pop(),At=at.length?at[at.length-1].el:null;continue}if(L){pn(m);let we=wt.get(m),Te;if(we.dup){p({kind:"structure",el:null,detail:"both-moved",base:we.dup},{subject:we.dup});continue}if(we.moveIn){if(Te=e.moveIn(we.moveIn,we.side,we.sideEl),!Te)continue}else if(we.bk){let De=we.bk;if(Jt.add(De),De===L.ab)Te=P(De.el,we.al.el,we.ar.el);else{let Ce=o.map.get(De.el)||null,Ue=r.map.get(De.el)||null;Te=P(De.el,Ce,Ue),(!Ce||!Ue)&&p({kind:"structure",el:null,detail:"move-beats-delete",base:De.el},{subject:De.el,deleted:Ce?"remote":"local"}),i.push({kind:"move",el:Te,source:we.from})}}else we.al?(Te=D(we.al.el,"local"),we.ar&&(c.get(Te).remote=we.ar.el),i.push({kind:"insert",el:Te,source:we.ar?"both":"local"})):(Te=D(we.ar.el,"remote"),i.push({kind:"insert",el:Te,source:"remote"}));Qn&&f.atomOut.set(m,Te),on(Te);continue}Dt||(yn=m),Dt+=ne[m]}if(pn($e),(Xn.has($e)||rt.has($e))&&(at.length=0,At=null,gr($e),Zt($e)),$e===0&&(d.placeholder||w.placeholder||g.placeholder)){let m=t.createElement("br");c.set(m,{base:g.placeholder,local:d.placeholder,remote:w.placeholder}),lt.push(m)}let Un=0,ut=m=>{for(;Un>0&&ze[Un-1].me>=m;)Un--;for(;Un<ze.length&&ze[Un].me<m;)Un++;let L=ze[Un];if(!L)return ze[ze.length-1]||null;let _=ze[Un+1];return L.me===m&&_&&_.ms===m?_:L},Ze=new Map,Rt={},ot=(m,L,_)=>{let F=ut(m)||(_?Rt:null);if(!F)return;let Z=Ze.get(F)||{l:!1,r:!1};L!=="remote"&&(Z.l=!0),L!=="local"&&(Z.r=!0),Ze.set(F,Z)},vt=m=>{if(m.conflict)return!0;let L=m.src==="local"?d.text:m.src==="remote"?w.text:"";for(let _=m.from;_<m.to;_++)if(L[_]!==_n&&L[_]!==xt)return!0;return!1};for(let m of j)m.src!=="base"&&ot(m.ms,m.conflict?"both":m.src,vt(m));for(let[m,L]of K)Xe[m]>=0&&ot(Xe[m],L);for(let m of ze.length?ze:[Rt]){let L=Ze.get(m);L&&i.push({kind:"text",node:m.node||null,source:L.l&&L.r?"both":L.l?"local":"remote"})}for(let m of Ge){if(Dn.has(m))continue;let L=!m.local&&!(y&&o.map.get(m.base)),_=!m.remote&&!(y&&r.map.get(m.base));!L&&!_||i.push({kind:"remove",source:L&&_?"both":L?"local":"remote",base:m.base})}if(be)for(let[m,L]of be)Dn.has(m)&&p({kind:"structure",el:Dn.get(m),detail:"edit-beats-delete",base:m.base},{subject:m.base,deleted:L});let Xt=(m,L,_)=>{if(L<=m)return!1;for(let F=m;F<L;F++)if(_[F]>=0)return!1;return!0};for(let m of Ge)for(let L of["local","remote"]){let _=m[L+"Mark"],F=m.baseMark;if(!_)continue;let Z=L==="local"?ae:Ae;if(!Xt(F.from,F.to,Z.bTo)||!Xt(_.from,_.to,Z.toB))continue;let pe=(L==="local"?ie:Ne).find(we=>we.ss<=_.from&&_.from<we.se);pe&&(pe.be<=F.from||pe.bs>=F.to)&&i.push({kind:"move",el:Dn.get(m)||null,source:L})}let Lt=m=>{let L=ht.get(m.node.parentNode);return L?It(L):null};for(let m of d.nodes){let L=-1;for(let F=m.s;F<m.e;F++)if(Qe[F]>=0){L=Qe[F];break}let _;if(L>=0)_=ut(L);else{let F=bt(m.s),Z=Lt(m);_=ze.find(pe=>pe.u===Z&&pe.me>=F)||ze.filter(pe=>pe.u===Z).pop()}_&&_.local.push(m)}let qt=new Map,tn=ze[ze.length-1]||null,Tt=0;for(let m of d.nodes){let L=null;for(let _=m.s;_<=m.e;_++){let F=bt(_);for(;Tt>0&&ze[Tt-1].me>=F;)Tt--;for(;Tt<ze.length&&ze[Tt].me<F;)Tt++;let Z=we=>we&&F>=we.ms&&F<=we.me&&(F<we.me||_===m.e||we===L),pe=Z(ze[Tt])?ze[Tt]:Z(ze[Tt+1])?ze[Tt+1]:ze[Tt]||tn;if(!pe)break;if(L===pe){let we=qt.get(pe);we[we.length-1].to=_-m.s;continue}L=pe,qt.has(pe)||qt.set(pe,[]),qt.get(pe).push({node:m.node,from:_-m.s,to:_-m.s,flatStart:m.s})}}for(let m of ze){let L=m.local,_=!1;for(let we of L)for(let Te=we.s;Te<we.e&&!_;Te++)(Qe[Te]<m.ms||Qe[Te]>=m.me)&&(_=!0);c.set(m.node,{base:null,local:L.map(we=>we.node),remote:null,caret:qt.get(m)||[],partial:_});let F=m.ms,Z=m.me-m.ms,pe=we=>{let Te=0,De=-1;for(let Ce of L){let Ue=Ce.e-Ce.s;if(we<=Te+Ue){De=Ce.s+(we-Te);break}Te+=Ue}return De<0&&(De=L.length?L[L.length-1].e:0),Math.max(0,Math.min(bt(De)-F,Z))};pe.flat=we=>Math.max(0,Math.min(bt(we)-F,Z)),l.set(m.node,pe)}function mt(){if(!d.text.includes(xt))return[{flatLocal:d.text,localNodes:d.nodes,textNodes:ze,lToM:Qe,mapLocal:bt}];let m=[],L=0,_=0;for(let F=0;F<=d.text.length;F++){if(F<d.text.length&&d.text[F]!==xt)continue;let Z=L,pe=F;if(pe>Z){let we=[];for(;_<d.nodes.length&&d.nodes[_].e<=Z;)_++;for(let Te=_;Te<d.nodes.length&&d.nodes[Te].s<pe;Te++){let De=d.nodes[Te],Ce=Math.max(De.s,Z),Ue=Math.min(De.e,pe);Ce<Ue&&we.push({node:De.node,s:Ce-Z,e:Ue-Z})}m.push({flatLocal:d.text.slice(Z,pe),localNodes:we,textNodes:ze,lToM:Qe.subarray?Qe.subarray(Z,pe+1):Qe.slice(Z,pe+1),mapLocal:Te=>bt(Z+Math.max(0,Math.min(Te,pe-Z)))})}L=F+1}return m}let St={...e,blocks:Sn,ignored:m=>Wo.has(m)||(e.ignored?e.ignored(m):!1)},Qt=e.ignoreAttribute||(()=>!1),eo=Si(nn(lt,St),Qt)!==Si(w,Qt);if(u.length){let m=L=>{let _=c.get(L);return _&&_.unchanged?_.remote:null};f.text=ne,f.textNodes=ze,f.out=nn(lt,{...St,via:m})}let Nn=null;if(e.scopeUnits){Nn=new Map;let m=new Set(lt),L=Te=>{for(;Te&&!m.has(Te);)Te=Te.parentNode;return Te},_=e.scopeUnits.map(Te=>{let De=new Map;for(let Ce of Te)if(Ce.nodeType===1)De.set(Ce,Ce);else for(let Ue of Ce.nodes)De.set(Ue,Ce);return De}),F=(Te,De)=>{for(;Te&&!De.has(Te);)Te=Te.parentNode;return Te?De.get(Te):null},Z=[g,d,w].map((Te,De)=>{let Ce=new Array(Te.text.length);for(let Ue of Te.nodes){let gt=F(Ue.node,_[De]);gt&&Ce.fill(gt,Ue.s,Ue.e)}for(let Ue of Te.atoms)Ce[Ue.i]=F(Ue.el,_[De]);return Ce}),pe=(Te,De)=>{if(!Te||!De)return;let Ce=Nn.get(Te);Ce||Nn.set(Te,Ce=new Set),Ce.add(De)};for(let Te of lt){let De=c.get(Te);De&&(pe(F(De.base,_[0]),Te),pe(F(De.local,_[1]),Te),pe(F(De.remote,_[2]),Te))}for(let Te of ze){let De=L(Te.node);for(let Ce=Te.ms;Ce<Te.me;Ce++)pe(Z[0][xe[Ce]],De),pe(Z[1][Ie[Ce]],De),pe(Z[2][Le[Ce]],De)}let we=new Map(lt.map((Te,De)=>[Te,De]));for(let[Te,De]of Nn)Nn.set(Te,Array.from(De).sort((Ce,Ue)=>we.get(Ce)-we.get(Ue)))}return{unitOutputs:Nn,nodes:lt,text:ne,textNodes:ze,localDiverged:eo,mapLocal:bt,conflicts:s.slice(a),granularity:q?"line":"word",segments:mt(),localHunks:ie,remoteHunks:Ne,lToM:Qe}}var ps=Symbol("lost");function ji(){return{links:new Map,removed:new Set,consumed:new Set,link(e,t){this.links.set(e,t)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let t of e.nodes)this.removed.add(t)},consume(e){for(let t of e)this.consumed.add(t)}}}var Pi=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function Di({locals:e,rec:t,root:n,provenance:o,segments:r,ignored:c}){let l=new Map,s=(T,k)=>{let v=l.get(T);v||l.set(T,v=new Set),v.add(k)},i=new Set,a=new Set;for(let T of r){let k=T.textNodes;for(let v of k)i.add(v.node);for(let v of T.localNodes){a.add(v.node);let I=0,M=null;for(let P=v.s;P<v.e;P++){let D=T.lToM[P];if(D<0)continue;for((!k[I]||D<k[I].ms)&&(I=0);I<k.length&&k[I].me<=D;)I++;let $=k[I]&&k[I].ms<=D?k[I].node:ps;$!==M&&s(v.node,$),M=$}}}let p=new Set,f=new Map,u=new Set;(function T(k){p.add(k);let v=o.get(k);if(k.nodeType===1)v&&v.local&&v.local.nodeType===1&&(s(v.local,k),v.unchanged&&u.add(v.local)),k.tagName==="TEMPLATE"&&k.content&&f.set(k.content,k);else if(v&&Array.isArray(v.local)&&!i.has(k))for(let I of v.local)s(I,k);for(let I=Pi(k).firstChild;I;I=I.nextSibling)T(I)})(n);let y=new Set;for(let[T,k]of t.links)s(T,k),y.add(T);let b=T=>{let k=T.parentNode;return k&&k.nodeType===11?f.get(k)||null:k},S=(T,k)=>{for(let v=T;v;v=b(v))if(v===k)return!0;return!1},g=T=>t.removed.has(T)||t.consumed.has(T),d=T=>{for(let k=T.parentNode;k&&k.nodeType===1;k=k.parentNode){if(u.has(k))return"kept";if(g(k))return"decided";if(l.has(k))return null}return null},w=new Map;for(let T of e)w.set(T,O(T));return w;function O(T){let k=l.get(T);if(k&&(k.size!==1||k.has(ps)))return{kind:"unknown",reason:"several-outputs"};let v=k?k.values().next().value:null;if(v&&(v.nodeType!==1||!p.has(v)))return{kind:"unknown",reason:"output-not-placed"};if(!v){let D=g(T)?"decided":d(T);if(D==="kept")return{kind:"untouched"};if(D!=="decided")return{kind:"unknown",reason:"unmapped"}}let I=[],M=P(T,!!v&&(u.has(T)||y.has(T)),!v||g(T));if(M)return{kind:"unknown",reason:M};return v?{kind:"single",output:v,owned:I,carried:y.has(T)}:{kind:"removed"};function P(D,$,W){for(let B=Pi(D).firstChild;B;B=B.nextSibling){if(B.nodeType===1?c(B):B.nodeType!==3&&B.nodeType!==8)continue;let x=l.get(B);if(x)for(let A of x){if(A===ps||!p.has(A))return"output-not-placed";if(!v)return"survives-elsewhere";if(!S(A,v))return"escaped";I.push(A)}else if(!$&&!W&&!g(B)&&!a.has(B))return"unmapped";if(B.nodeType===1){let A=P(B,$||u.has(B)||y.has(B),W||g(B));if(A)return A}}return null}}}function Bi(e,t){if(!t)return!1;let n=t.nodeType===1&&t.tagName==="TEMPLATE"?[t,...t.querySelectorAll("template")]:[...t.querySelectorAll("template")];for(let o of n)if(o.content.contains(e)||Bi(e,o.content))return!0;return!1}function Ui(e,t){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let n=[],o=new Set;for(let r of Array.from(e.elements)){if(!r||r.nodeType!==1||r.ownerDocument!==t&&!Bi(r,t.documentElement))throw new TypeError("lineage.elements must be elements of the live document");o.has(r)||(o.add(r),n.push(r))}return n}var Hi=new WeakMap;function Wi(e){let t=new Map;for(let n of e){let o=[],r=!1;(function c(l){l.nodeType===1&&l.namespaceURI==="http://www.w3.org/1999/xhtml"&&l.localName==="template"&&(r=!0);for(let s=l.firstChild;s;s=s.nextSibling)o.push(s),s.nodeType===1&&c(s)})(n),t.set(n,{nodes:o,opaque:r})}return t}function ms(e,t,n){if(e.lineage===void 0)return n(e);if(!t||t.nodeType!==1)throw new TypeError("lineage requires an element root");let o=e.lineage,r=Ui(o,t.ownerDocument),c=!1,l={...e,lineage:{elements:r,onResult(s,i){if(!c)return c=!0,o.onResult(s,i)}}};try{return Hi.set(l.lineage,Wi(r)),n(l)}catch(s){if(!c){c=!0;try{o.onResult({version:1,root:t,status:"incomplete",entries:r.map(Mn)},null)}catch{}}throw s}}function gs(e,{liveRoot:t,localRoot:n,toLive:o}){let r=Ui(e,t.ownerDocument),c=a=>a===t||t.contains(a),l=new Map,s=new Set(r.filter(c));if(s.size&&n===t)for(let a of s)l.set(a,a);else s.size&&function a(p){let f=o(p);s.delete(f)&&l.set(f,p);for(let u=p.firstElementChild;u&&s.size;u=u.nextElementSibling)a(u)}(n);return{spec:e,watched:r,root:t,locals:Array.from(new Set(l.values())),before:Hi.get(e)||Wi(r),delivered:!1,result:null,finish(a,p){return this.resolve=p,this.plans=a,this.result={version:1,root:this.root,status:"complete",entries:r.map(f=>Yc(f,l.get(f),a,p,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(a,p){this.root=p;let f=this.resolve,u=b=>{let S=f(b);return S===a?p:S};return this.finish(this.plans,u)},deliver(a){this.delivered||(this.delivered=!0,e.onResult(this.result,a))}}}var Mn=e=>({from:e,to:[],kind:"unknown",complete:!1});function Yc(e,t,n,o,r){let c=r.root,l=u=>!!u&&(u===c||c.contains(u)),s=t&&n?n.get(t):null;if(!s||s.kind==="unknown")return Mn(e);let i=r.before.get(e);if(!i||i.opaque)return Mn(e);let a=i.nodes,p=u=>l(u)||!!(u&&u.ownerDocument===c.ownerDocument&&c.ownerDocument.documentElement?.contains(u));if(s.kind==="untouched"){if(!l(e))return Mn(e);for(let u of a)if(p(u)&&!e.contains(u))return Mn(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(s.kind==="removed")return p(e)||a.some(p)?Mn(e):{from:e,to:[],kind:"removed",complete:!0};let f=o(s.output);if(!f||f.nodeType!==1||!l(f)||f!==e&&p(e))return Mn(e);for(let u of a)if(p(u)&&!f.contains(u))return Mn(e);for(let u of s.owned){let y=o(u),b=Array.isArray(y)?y:[y];for(let S of b)if(!S||!l(S)||!f.contains(S))return Mn(e)}return s.carried&&!Vi(f,s.output,o)?Mn(e):{from:e,to:[f],kind:f===e?"retained":"replaced",complete:!0}}function Vi(e,t,n){for(let o=t.firstChild;o;o=o.nextSibling){let r=n(o),c=Array.isArray(r)?r:[r];for(let l of c)if(!l||!e.contains(l))return!1;if(o.nodeType===1&&!Vi(e,o,n))return!1}return!0}function zo(e,t,n){let o=gs(e,{liveRoot:t,localRoot:t,toLive:r=>r});return o.result={version:1,root:t,status:"complete",entries:o.watched.map(r=>Mn(r))},n.lineage=o.result,o}function _i(e,t,n,o,r){if(!r(e.length*8+1))return null;let c=0,l=t===0,s=!1;for(let i of an(e,o)){if(!r(1))return null;if(c+=i.len,c===t&&(l=!0),c===n&&(s=!0),c>=n)break}return l&&s}function Jc(e,t,n,o,r,c,l){if(!l(t.length*2))return!1;let s=new Map,i=new Map,a=new Set;for(let p of t){let f=p.bs<p.be,u=f?n[p.ownerIndex].text.base:n[p.ownerIndex].text[e],y=f?p.bs:p.ss,b=f?p.be:p.se;if(!l((b-y)*4+1))return!1;for(;y<b&&/\s/.test(u[y]);)y++;for(;b>y&&/\s/.test(u[b-1]);)b--;if(y===b)continue;let S=u.slice(y,b),g=f?s:i;f&&p.text&&a.add(S),g.has(S)?g.set(S,null):g.set(S,{h:p,from:y,to:b})}for(let p of o){if(!l(1))return!1;if(p.side!==e)continue;let f=p.deletion,u=n[f.ownerIndex].text.base;if(!l((f.be-f.bs)*3)||a.has(u.slice(f.bs,f.be).trim()))return!1}for(let[p,f]of s){if(!l(p.length+1))return!1;let u=i.get(p);if(!f||!u)continue;let y=f.h,b=u.h;if(!y.text||y.transferOut||b.transferIn||y.owner===b.owner)continue;let S=n[y.ownerIndex],g=n[b.ownerIndex];if(!l(S.text.base.length))return!1;if(!/\S/.test(S.text.base.slice(0,y.bs)+S.text.base.slice(y.be)))continue;let d=_i(S.text.base,f.from,f.to,c,l),w=_i(g.text[e],u.from,u.to,c,l);if(d===null||w===null)return!1;if(!d||!w)continue;let O=`${S.index}:${f.from}:${f.to}`,T={key:O,side:e,source:y.owner,destination:b.owner,deletion:y,insertion:b,sourceOffset:f.from-y.bs,targetOffset:u.from-b.ss,length:f.to-f.from};y.transferOut=T,b.transferIn=T,r[e].set(O,T),o.push(T)}return!0}function Fi({base:e,local:t,remote:n,localTwin:o,remoteTwin:r,eligible:c,nodes:l,budget:s=zt(2e4*32)}){let i=M=>M>s.remaining?!1:(s.remaining-=M,s.nativeSteps=(s.nativeSteps||0)+M,!0);if(e.length<2||t.length!==e.length||n.length!==e.length||!i(e.length*12))return null;for(let[M,P]of[["base",e],["local",t],["remote",n]]){let D=l[M];if(D.length!==P.length||D.some(($,W)=>$!==P[W]))return null}let a=[],p=0;for(let M=0;M<e.length;M++){let P=e[M],D=t[M],$=n[M];if(o(P)!==D||r(P)!==$)return null;let W={};for(let[B,x]of[["base",P],["local",D],["remote",$]]){if(!c(x)||x.tagName!==P.tagName||x.namespaceURI!==P.namespaceURI||!i(x.childNodes.length+1))return null;let A="";for(let X of x.childNodes){if(X.nodeType!==3||!i(X.data.length*4+1))return null;A+=X.data}if(A.includes(xt)||(p+=A.length+1,p>2e4))return null;W[B]=A}a.push({base:P,local:D,remote:$,index:M,text:W})}let f=a.every(M=>Tn(M.text.base,M.text.local,M.text.remote)),u={local:[],remote:[]};for(let M of a){M.hunks={local:[],remote:[]};for(let P of["local","remote"]){let D=M.text.base,$=M.text[P];if(D===$)continue;let W=D.length+$.length+4,B=W*8;if(!i(B))return null;let x=Math.floor(s.remaining/8),A=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(W*W+x)-W)/2)));if(A<1||!i(4*(A+1)*(W+A+1)))return null;let X=0;for(let H of ao(D,$,A)){if(!i(H.text.length+1))return null;let q=H.bs+X,Ee={...H,ss:q,se:q+H.text.length,toks:an(H.text,f),owner:M.base,ownerIndex:M.index};M.hunks[P].push(Ee),u[P].push(Ee),X+=H.text.length-(H.be-H.bs)}}}let y=[],b={local:new Map,remote:new Map};for(let M of["local","remote"]){let P=new Map,D=new Map,$=!1,W=(B,x,A)=>{B.has(x)?B.set(x,null):B.set(x,A)};for(let B of u[M]){if(!i(1))return null;let x=a[B.ownerIndex].text.base;if(B.bs<B.be&&B.text===""){let A=x.slice(B.bs,B.be);if(!i(A.length*2))return null;/\S/.test(A)&&W(P,A,B)}else if(B.bs===B.be&&/\S/.test(B.text)){if(!i(B.text.length*2))return null;W(D,B.text,B)}else B.bs<B.be&&($=!0)}for(let[B,x]of P){if(!i(B.length+1))return null;let A=D.get(B);if(!x||!A||x.owner===A.owner)continue;let X=a[x.ownerIndex];if(!i(X.text.base.length))return null;if(!/\S/.test(X.text.base.slice(0,x.bs)+X.text.base.slice(x.be)))continue;let H=`${X.index}:${x.bs}:${x.be}`,q={key:H,side:M,source:x.owner,destination:A.owner,deletion:x,insertion:A};x.transferOut=q,A.transferIn=q,b[M].set(H,q),y.push(q)}if($&&D.size&&!Jc(M,u[M],a,y,b,f,i))return null}if(!y.length)return null;let S=(M,P)=>M.bs<P.be&&P.bs<M.be,g=M=>M.bs===M.be,d=(M,P)=>M.bs<=P.be&&P.bs<=M.be&&g(M)!==g(P),w=(M,P)=>M.bs===P.bs&&M.be===P.be&&M.text===P.text,O=(M,P)=>!!(M.transferIn||M.transferOut&&(!M.text||P.bs===M.be&&/\s/.test(P.text[0])||P.bs===M.bs&&/\s/.test(P.text[P.text.length-1])));for(let M of y){let P=M.side==="local"?"remote":"local",D=a[M.deletion.ownerIndex];for(let $ of D.hunks[P])if(!i(1)||S(M.deletion,$)&&$.transferOut?.key!==M.key)return null}for(let M of a)for(let P of M.hunks.local)for(let D of M.hunks.remote){if(!i(1))return null;if(w(P,D)){if(P.transferIn?.key!==D.transferIn?.key)return null;continue}if(S(P,D)||d(P,D)&&!O(P,D)&&!O(D,P))return null}if(!i(p*8))return null;let T=new Set([...e,...t,...n]),k={base:nn(e,{blocks:T}),local:nn(t,{blocks:T}),remote:nn(n,{blocks:T})},v={};for(let M of["base","local","remote"]){let P=k[M];if(P.atoms.length||P.pins.length)return null;v[M]=new Map(P.marks.filter(D=>D.block).map(D=>[D.el,D.from]))}for(let M of a){let P=v.base.get(M.base);if(P===void 0)return null;for(let D of["local","remote"]){let $=v[D].get(M[D]);if($===void 0)return null;for(let W of M.hunks[D])W.bs+=P,W.be+=P,W.ss+=$,W.se+=$}}for(let M of y)M.bs=M.deletion.bs+(M.sourceOffset||0),M.be=M.length===void 0?M.deletion.be:M.bs+M.length,M.ss=M.insertion.ss+(M.targetOffset||0),M.se=M.length===void 0?M.insertion.se:M.ss+M.length;let I={};for(let M of["local","remote"]){let P=0,D=0,$=[];for(let B of u[M]){if(!i(1))return null;B.bs>P&&$.push({from:P,to:B.bs,target:D}),P=B.be,D=B.se}P<k.base.text.length&&$.push({from:P,to:k.base.text.length,target:D});let W=y.filter(B=>B.side===M).map(B=>({from:B.bs,to:B.be,target:B.ss,destination:B.destination}));if(I[M]=Vn({base:k.base,side:k[M],retained:$,transfers:W,budget:s}),I[M].status!=="ready")return null}return i(k.base.text.length)?{owners:a,blocks:T,transfers:y,byOrigin:b,budget:s,prepared:{base:k.base,local:k.local,remote:k.remote,lines:!1,baseTokens:an(k.base.text,f),localEdits:{hunks:u.local,respell:new Map},remoteEdits:{hunks:u.remote,respell:new Map},localMap:I.local,remoteMap:I.remote,full:null}}:null}var bs=/\S/;function qi({certificates:e,scopes:t,views:n,eligible:o,baseId:r,limit:c=2e4*32}){let l=zt(c),s=Symbol(),i=[],a=f=>{if(f>l.remaining)throw s;l.remaining-=f},p=(f,u=null)=>{if(a(1),!f||f.nodeType!==1||f.parentNode?.nodeType!==1||!o(f))return null;for(let S=f.parentNode;S;S=S.parentNode)if(a(1),S.nodeType===11)return null;let y="",b=0;for(let S of f.childNodes){if(a(1),S.nodeType!==3)return null;if(a(S.data.length*4+1),u){let g=u.flat.nodes[b++];if(!g||g.node!==S||g.s!==y.length||g.e!==y.length+S.data.length)return null}y+=S.data}return a(y.length*3+1),u&&(u.flat.atoms.length||u.flat.pins?.length||b!==u.flat.nodes.length||u.flat.text!==y)?null:bs.test(y)?y:null};try{a(t[0].length+t[1].length+t[2].length+e.length);let f=t.map(y=>new Set(y)),u=new Map;for(let y of e){a(1);let b=u.get(y.source);b||u.set(y.source,b=[]),b.push(y)}for(let y of u.values()){let b=[null,null],S=[];for(let g of y){a(1);let{source:d,target:w,side:O,models:T,runs:k}=g;if(O!==0&&O!==1||!f[0].has(d)||!f[O+1].has(w))continue;let{V:v,A:I,idOf:M}=n[O],P=n[1-O],D=v.twin(d),$=P.V.twin(d),W=v.baseOf(w);if(!D||!$||!W||W===d||!f[0].has(W)||!f[O+1].has(D)||!f[2-O].has($)||I.map.get(d)!==D||I.reverse.get(D)!==d||P.A.map.get(d)!==$||P.A.reverse.get($)!==d||I.map.get(W)!==w||I.reverse.get(w)!==W||w.parentNode!==D.parentNode||W.parentNode!==d.parentNode||d.tagName!==D.tagName||d.tagName!==$.tagName||r(d)!==M(D)||r(d)!==P.idOf($)||r(W)!==M(w))continue;let B=T.get(d),x=T.get(w);if(!B||!x)continue;let A=p(d,B),X=p(w,x),H=p(D),q=p($);if(a((A?.length||0)+(q?.length||0)),A===null||X===null||H===null||q===null||q===A)continue;let Ee=k.length>0,Me=!1;for(let ae of k){if(a(1),ae.source!==d||ae.target!==w||!Number.isInteger(ae.from)||!Number.isInteger(ae.to)||!Number.isInteger(ae.targetFrom)||ae.from<0||ae.to<=ae.from||ae.to>A.length||ae.targetFrom<0||ae.targetFrom+ae.to-ae.from>X.length){Ee=!1;break}a((ae.to-ae.from)*3);for(let Ae=ae.from;Ae<ae.to;Ae++){if(A[Ae]!==X[ae.targetFrom+Ae-ae.from]){Ee=!1;break}bs.test(A[Ae])&&(Me=!0)}if(!Ee)break}if(!Ee||!Me)continue;let je=b[O];je||(a(A.length),je=b[O]={source:d,side:O,flat:B.flat,before:A,covered:new Uint8Array(A.length)});for(let ae of k)a(ae.to-ae.from),je.covered.fill(1,ae.from,ae.to)}for(let g of b){if(!g)continue;let{source:d,side:w,flat:O,before:T,covered:k}=g;a(T.length*3+1);let v=-1,I=-1;for(let M=0;M<=T.length;M++)M<T.length&&k[M]?(v<0&&(v=M),I=M+1):(M===T.length||bs.test(T[M]))&&v>=0&&(S.push({source:d,side:w,flat:O,from:v,to:I}),v=I=-1)}a(S.length),i.push(...S)}}catch(f){if(f!==s)throw f}return{records:i,budget:l}}var Xc="http://www.w3.org/1999/xhtml";function Zc(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function mn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Xc}function Qc(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Ir(e,t){let n=e.getAttribute("src"),o=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(n){let r=n;try{let c=new URL(n,t);r=c.origin+c.pathname+c.search}catch{}return"script|src|"+o+"|"+r}return"script|inline|"+o+"|"+Zc(e.textContent.trim())}var ea={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function Eo(e,t=[],n=!1){if(!mn(e)||e.hasAttribute("src"))return null;let o=[ea,...t];for(let r=0;r<o.length;r++){let c=o[r];if(!c.match(e))continue;if(!Qc(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=c.identity(e);return l==null||l===""?null:{key:r+":"+l,raw:l,recognizer:c}}return null}function $i(e,t,n){let o=new Set,r=c=>{mn(c)&&!t(c)&&o.add(Ir(c,n))};r(e);for(let c of e.querySelectorAll("script"))r(c);return o}function Go(e,t){let n=t.createElement("div");n.innerHTML="<script><\/script>";let o=n.firstChild;for(let r of e.attributes)o.setAttribute(r.name,r.value);return o.textContent=e.textContent,o}function Ki(e,t,n){let o=[],r=[],c=new Map,l=n.trackRecovery?new Set:null,s=Array.from(e.querySelectorAll("script"));mn(e)&&s.unshift(e);for(let i of s){if(!mn(i)||n.ignored(i)||n.skip.has(i)||t.has(Ir(i,n.baseURI)))continue;let a=i.ownerDocument.createElement("script");for(let p of i.attributes)a.setAttribute(p.name,p.value);if(a.textContent=i.textContent,n.beforeNodeAdded(a)===!1){l?.add(i);continue}a.hasAttribute("src")&&r.push(new Promise(p=>{a.addEventListener("load",()=>p()),a.addEventListener("error",()=>p())})),i.replaceWith(a),c.set(i,a),n.afterNodeAdded(a),o.push(a)}return{executed:o,loads:r,swapped:c,vetoed:l}}function ta(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function na(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function zi(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Ir(e,t);if(n==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+na(o,t):e.outerHTML}if(n==="META"){for(let o of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(o))return"meta|"+o+"="+e.getAttribute(o);return e.outerHTML}return n==="STYLE"?"style|"+ta(e.textContent):e.outerHTML}function ys(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
5
+ `;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);if(n===-1)return e.length;t=n+2;continue}return t}}function oa(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var ra=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,sa=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ws(e){try{return JSON.parse(e)}catch{return JSON.parse(ia(e))}}function ia(e){let t="",n=0,o=(r,c)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${c}`)};for(;n<e.length&&(n=ys(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let s=ys(e,n+1);if(e[s]==="}"||e[s]==="]"){n++;continue}t+=r,n++;continue}if(r==='"'||r==="'"){let s=n+1;for(;s<e.length&&e[s]!==r;)e[s]==="\\"&&s++,s++;s>=e.length&&o("unterminated string",n);let i=e.slice(n+1,s);r==="'"&&(i=oa(i)),t+='"'+i+'"',n=s+1;continue}let c=n;for(;c<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[c]);)c++;c===n&&o("unexpected character "+JSON.stringify(r),n);let l=e.slice(n,c);if(l==="true"||l==="false"||l==="null"||ra.test(l)){t+=l,n=c;continue}if(sa.test(l)){if(e[ys(e,c)]===":"){t+='"'+l+'"',n=c;continue}o("unquoted value "+JSON.stringify(l),n)}o("invalid token "+JSON.stringify(l),n)}return t}var Kt=Symbol("hyper-morph-json-merge:missing"),la=["id","_id","uuid","key","slug","code","name"];function Io(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Yo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ca(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}var aa=/^[A-Za-z_$][\w$]*$/;function fa(e,t){return aa.test(t)?e===""?t:e+"."+t:e+"["+JSON.stringify(t)+"]"}function ua(e,t){return e===""?t:e+"."+t}function Cr(e,t,n,o,r,c){if(e.onConflict){let l=s=>s===Kt?void 0:s;e.onConflict({path:t,base:l(n),local:l(o),remote:l(r),resolved:l(c)})}return c}function Yn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Yn(e[n],t[n]))return!1;return!0}if(Io(e)&&Io(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Yo(t,o)||!Yn(e[o],t[o]))return!1;return!0}return!1}function xs(e,t,n,o,r,c){return Yn(t,n)?t:Yn(t,e)?n:Yn(n,e)?t:Io(t)&&Io(n)?da(Io(e)?e:{},t,n,o,r,c):Array.isArray(t)&&Array.isArray(n)?ga(e,t,n,o,r,c):Cr(o,r,e,t,n,n)}function Gi(e,t,n,o,r,c){return t===Kt&&n===Kt?Kt:t===Kt?e===Kt?n:Yn(n,e)?Kt:Cr(o,r,e,t,n,n):n===Kt?e===Kt?t:Yn(t,e)?Kt:Cr(o,r,e,t,n,Kt):xs(e,t,n,o,r,c)}function da(e,t,n,o,r,c){let l={},s=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let i of s){let a=Gi(Yo(e,i)?e[i]:Kt,Yo(t,i)?t[i]:Kt,Yo(n,i)?n[i]:Kt,o,fa(r,i),ua(c,i));a!==Kt&&ca(l,i,a)}return l}function ha(e){return e===null||typeof e!="object"}function Rr(e){return typeof e+":"+String(e)}function pa(e,t){for(let n of t){let o=new Set;for(let r of n){if(!Yo(r,e))return!1;let c=r[e];if(typeof c!="string"&&typeof c!="number")return!1;let l=Rr(c);if(o.has(l))return!1;o.add(l)}}return!0}function ma(e,t,n,o,r){let c=[e,t,n],l=!0;for(let s of c)for(let i of s)Io(i)||(l=!1);if(l){let s=o.keyPaths.get(r),i=s!==void 0?[s]:o.keyCandidates;for(let a of i)if(pa(a,c))return{kind:"keyed",field:a};return null}for(let s of c){let i=new Set;for(let a of s){if(!ha(a))return null;let p=Rr(a);if(i.has(p))return null;i.add(p)}}return{kind:"self"}}function ga(e,t,n,o,r,c){let l=Array.isArray(e)?e:[],s=ma(l,t,n,o,c),i=Array.isArray(e)&&e.length===t.length&&e.length===n.length;if(!s||s.kind==="self"&&i)return i?t.map((O,T)=>xs(e[T],O,n[T],o,r+"["+T+"]",c)):Cr(o,r,e,t,n,n);let a=s.kind==="self"?Rr:O=>Rr(O[s.field]),p=O=>s.kind==="self"?r+"["+JSON.stringify(O)+"]":r+"["+s.field+"="+JSON.stringify(O[s.field])+"]",f=new Map,u=O=>{let T=new Map;for(let k of O){let v=a(k);T.set(v,k),f.has(v)||f.set(v,p(k))}return T},y=u(l),b=u(t),S=u(n),g=new Map,d=new Set([...y.keys(),...b.keys(),...S.keys()]);for(let O of d){let T=Gi(y.has(O)?y.get(O):Kt,b.has(O)?b.get(O):Kt,S.has(O)?S.get(O):Kt,o,f.get(O),c);T!==Kt&&g.set(O,T)}let w=[];for(let O of n){let T=a(O);g.has(T)&&w.push(T)}for(let O=0;O<t.length;O++){let T=a(t[O]);if(!g.has(T)||w.includes(T))continue;let k=0;for(let v=O-1;v>=0;v--){let I=w.indexOf(a(t[v]));if(I!==-1){k=I+1;break}}w.splice(k,0,T)}return w.map(O=>g.get(O))}function ba(e){let t=new Map,n=[];for(let o of e.keyCandidates||[]){let r=o.lastIndexOf(":");r>=0?t.set(o.slice(0,r),o.slice(r+1)):n.push(o)}return{keyCandidates:[...n,...la],keyPaths:t,onConflict:e.onConflict||null}}function Yi(e,t,n,o={}){return xs(e===void 0?Kt:e,t,n,ba(o),"","")}function ya(e,t){let n=/^\s*/.exec(t)[0],o=/\s*$/.exec(t.slice(n.length))[0],r=t.slice(n.length,t.length-o.length),c=n.slice(n.lastIndexOf(`
6
+ `)+1),l=/\n([ \t]+)\S/.exec(r),s;if(!l)s=JSON.stringify(e);else{let i=l[1],a=i.length>c.length&&i.startsWith(c)?i.slice(c.length):" ";s=JSON.stringify(e,null,a).replace(/\n/g,`
7
+ `+c)}return n+s.replace(/</g,"\\u003c")+o}function ks(e,t,n,o={}){let r=o.parse||ws,c=[],l=[],s=(u,y)=>{if(typeof u!="string")return Kt;try{return r(u)}catch(b){return c.push(`${y} side is not valid JSON (${b.message})`),Kt}},i=s(t,"local"),a=s(n,"remote");if(i===Kt)return{text:n,warnings:c,conflicts:l};if(a===Kt)return{text:t,warnings:c,conflicts:l};let p=s(e,"base"),f=Yi(p===Kt?void 0:p,i,a,{...o,onConflict:u=>{l.push(u),o.onConflict?.(u)}});return Yn(f,a)?{text:n,warnings:c,conflicts:l}:Yn(f,i)?{text:t,warnings:c,conflicts:l}:{text:ya(f,n),warnings:c,conflicts:l}}var Ji=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function uo(e){if(!e)return!1;let{startContainer:t,startOffset:n,endContainer:o,endOffset:r}=e;if(!t||!o||!Number.isInteger(n)||!Number.isInteger(r)||n<0||r<0||n>Ji(t)||r>Ji(o)||t.getRootNode()!==o.getRootNode())return!1;let c=t.ownerDocument.createRange();return c.setStart(t,n),c.setEnd(o,r),c.startContainer===t&&c.startOffset===n}function ro(e,t,n={}){if(!uo(e))return null;let{startContainer:o,startOffset:r,endContainer:c,endOffset:l}=e;if(o===c&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,l);if(o===c&&r===l)return"";let s=new Set;for(let g=o;g;g=g.parentNode)s.add(g);let i=c;for(;!s.has(i);)i=i.parentNode;let a=(g,d)=>{let w=i.ownerDocument.createRange(),O=i.ownerDocument.createRange();return w.setStart(g[0],g[1]),w.collapse(!0),O.setStart(d[0],d[1]),O.collapse(!0),w.compareBoundaryPoints(0,O)},p=(g,d=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(d)],f=[],u;if(t==="plain"){u="";let g=d=>{if(d.nodeType===3||d.nodeType===8){let w=u.length;u+=d.nodeValue,f.push({s:w,e:u.length,a:[d,0],b:[d,d.nodeValue.length],node:d})}else for(let w of d.childNodes)g(w)};g(i)}else{let g=n.blocks;if(!g){g=new Set;let w=O=>{O!==i&&O.nodeType===1&&ds.has(O.tagName)&&g.add(O);for(let T of O.childNodes)w(T)};w(i)}let d=nn(Array.from(i.childNodes),{blocks:g,atomize:w=>!!n.atoms?.has(w),ignored:n.ignored});u=d.text;for(let w of d.nodes)f.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)f.push({s:w.i,e:w.i+1,a:p(w.el),b:p(w.el,!0)});for(let w=0;w<d.text.length;w++){if(d.text[w]!==xt)continue;let O=d.marks.find(k=>k.block&&k.to===w+1),T=d.marks.find(k=>k.block&&k.from===w+1);if(O)f.push({s:w,e:w+1,a:[O.el,O.el.childNodes.length],b:p(O.el,!0)});else if(T)f.push({s:w,e:w+1,a:p(T.el),b:[T.el,0]});else return null}}f.sort((g,d)=>g.s-d.s);let y=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let w=f.find(O=>O.node===g[0]);return w?w.s+g[1]:null}let d=0;for(let w of f){if(a(g,w.a)<=0)return w.s;if(a(g,w.b)<0)return null;d=w.e}return d},b=y([o,r]),S=y([c,l]);return b!==null&&S!==null&&b<=S?u.slice(b,S):null}function fo(e,t){let n=e;for(let o of t.path)if(n=o==="content"?n?.content:n?.childNodes[o],!n)return null;return[n,t.offset]}function Xi(e,t){if(!e||!t)return null;let n=fo(e,t.start),o=fo(e,t.end);return n&&o?{startContainer:n[0],startOffset:n[1],endContainer:o[0],endOffset:o[1]}:null}var Zi=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Qi(e,t,n){if(!t)return;let o=new Map,r=new Map,c=s=>{if(!s)return null;if(r.has(s))return r.get(s);let a=s.local.map(p=>fo(t.localRoot,{path:p,offset:0})?.[0]).map(p=>p&&n(p)).filter(Boolean).map(p=>({node:p,parent:p.parentNode,previous:p.previousSibling,next:p.nextSibling,fragment:Zi(p)}));return r.set(s,a),a},l=s=>{let i=Xi(t.localRoot,s);if(!i)return null;let a=n(i.startContainer),p=n(i.endContainer);if(!a||!p)return null;let f={...i,startContainer:a,endContainer:p};return uo(f)?f:null};for(let s of e){let i=s.recovery;if(!i||o.has(i))continue;let a={subject:c(i.subject),span:null,scope:null,touched:new Set};if(i.text){a.span=l(i.text.local.span),a.scope=l(i.text.local.scope);let p=a.span;if(p){let f=p.startContainer.ownerDocument.createRange();f.setStart(p.startContainer,p.startOffset),f.setEnd(p.endContainer,p.endOffset);let u=y=>{if(f.intersectsNode(y)){a.touched.add(y);for(let b of y.childNodes)u(b)}};u(f.commonAncestorContainer)}}if(i.structure){for(let p of[i.structure.localPlacement])p&&(c(p.parent),p.before.forEach(c),p.after.forEach(c));for(let p of i.structure.localOrder||[])c(p)}o.set(i,a)}t.localState={states:o,refs:r}}function el(e,t,n,o){let r=n.localState?.states.get(e);if(!r)return!1;let c=s=>{let i=s.node;if(!o(i)||i.parentNode!==s.parent)return!1;let a=p=>Array.prototype.indexOf.call(i.parentNode.childNodes,p);return!(s.previous&&o(s.previous)&&s.previous.parentNode===i.parentNode&&a(s.previous)>=a(i)||s.next&&o(s.next)&&s.next.parentNode===i.parentNode&&a(s.next)<=a(i))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!r.subject.length||!r.subject.every(c))return!1;if(e.text){let s=e.text.local,i=a=>a&&o(a.startContainer)&&o(a.endContainer);return i(r.span)&&i(r.scope)&&ro(r.scope,e.text.encoding)===s.text&&ro(r.span,e.text.encoding)===s.text.slice(s.start,s.end)}if(e.attribute){let s=e.attribute,i=r.subject[0].node;return(s.namespaceURI?i.getAttributeNS(s.namespaceURI,s.localName):i.getAttribute(s.qualifiedName))===t.local}let l=e.structure;if(l.localOrder){let s=-1,i=null;for(let a of l.localOrder){let p=n.localState.refs.get(a)?.[0]?.node;if(!p||!o(p)||i&&p.parentNode!==i)return!1;let f=Array.prototype.indexOf.call(p.parentNode.childNodes,p);if(f<=s)return!1;i=p.parentNode,s=f}return!0}return l.localAction==="moved"||r.subject.every(s=>Zi(s.node)===s.fragment)}var wa=1,hn=e=>!!e&&e.nodeType===1,Lr=e=>hn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function ho(e,t=null,n=null){let o=new Map,r=new Map,c=p=>{if(!t){t=new WeakMap;let f=[e];for(;f.length;){let u=f.pop();Lr(u)&&(t.set(u.content,u),f.push(u.content));for(let y=u.firstChild;y;y=y.nextSibling)y.nodeType===1&&f.push(y)}}return t.get(p)||null},l=(p,f)=>{let u=r.get(p);if(!u){u=new Map;let y=0;for(let b=p.firstChild;b;b=b.nextSibling)u.set(b,y++);r.set(p,u)}return u.get(f)},s=p=>{if(!p)return null;if(n&&n.has(p))return s(n.get(p));if(p===e)return[];let f=o.get(p);if(f!==void 0)return f;let u=p.parentNode,y=null;if(u&&u.nodeType===11){let b=c(u),S=b?s(b):null;S&&(y=S.concat(["content",l(u,p)]))}else if(u){let b=s(u);b&&(y=b.concat([l(u,p)]))}return o.set(p,y),y};return{root:e,pathOf:s,logicalParent:p=>{let f=p.parentNode;return f&&f.nodeType===11?c(f):f},indexIn:l,containerPath:p=>{if(p.nodeType===11){let u=c(p),y=s(u);return y?y.concat(["content"]):null}let f=s(p);return f&&Lr(p)?f.concat(["content"]):f},ownerOf:c}}var Ln=e=>Lr(e)?e.content:e;function tl(e){let{L:t,R:n,unitsOf:o,provenance:r,policy:c}=e,l=[];return{note:(p,f)=>{l.push([p,f])},finish:p=>l.length?a(p):null};function a(p){let f={base:ho(e.roots.base),local:ho(e.roots.local),remote:ho(e.roots.remote)},u=z=>z==="local"?t:n,y=(z,h)=>{if(!h)return null;if(z.map.has(h))return z.map.get(h);let E=[],R=hn(h)?f.base.logicalParent(h):h.parent;for(;R&&!z.map.has(R);R=f.base.logicalParent(R))E.push(R);if(!R||!z.identical.has(R))return null;let V=z.map.get(R);for(let Q=E.length-1;Q>=0&&V;Q--)V=Ln(V).childNodes[f.base.indexIn(E[Q].parentNode,E[Q])];return V?hn(h)?Ln(V).childNodes[f.base.indexIn(h.parentNode,h)]||null:o(V)[o(h.parent).indexOf(h)]||null:null},b=new Map,S=new Map,g=new WeakMap,d=0,w=(z,h)=>{let E=b.get(z);E||b.set(z,E=[]),E.push(h)};(function z(h){S.set(h,d++);let E=r.get(h);if(E&&!E.pinned){for(let R of[E.base,E.local,E.remote])if(R)if(Array.isArray(R))for(let V of R)w(V,h);else w(R,h)}if(Lr(h)){g.set(h.content,h);for(let R=h.content.firstChild;R;R=R.nextSibling)z(R)}for(let R=h.firstChild;R;R=R.nextSibling)z(R)})(p);let O=new Map;f.out=ho(p,g,O);let T={refs:new Map,spans:new Map,anchors:new Map,via:O,outOwners:g,outRoot:p,localRoot:e.roots.local},k=z=>hn(z)?[z]:z.nodes,v=(z,h)=>{let E=f[h].logicalParent(z);if(!E)return null;for(let R of o(E))if(!hn(R)&&R.nodes.includes(z))return R;return null},I=(z,h)=>z==null?null:Array.isArray(z)?z.length?v(z[0],h):null:z,M=z=>{let h=new Set,E=[];for(let R of z)for(let V of b.get(R)||[])h.has(V)||(h.add(V),E.push(V));return E.sort((R,V)=>S.get(R)-S.get(V))},P=new Map,D=z=>{let h=z.b||z.l||z.r,E=P.get(h);if(E)return E;let R=[];for(let V of[z.b,z.l,z.r])V&&R.push(...k(V));return E=M(R),P.set(h,E),E},$=z=>({b:z,l:y(t,z),r:y(n,z)}),W=(z,h)=>{let E=u(h).reverse.get(z);if(E)return $(E);for(let R of M(k(z))){let V=r.get(R);if(V&&!V.base&&V.local&&V.remote)return{b:null,l:I(V.local,"local"),r:I(V.remote,"remote")}}return h==="local"?{b:null,l:z,r:null}:{b:null,l:null,r:z}},B=new Map,x=z=>{let h=r.get(z);if(!h||h.pinned)return null;let E=I(h.base,"base");if(E)return $(E);let R=I(h.local,"local"),V=I(h.remote,"remote");if(R){let Q=t.reverse.get(R);if(Q)return $(Q)}if(V){let Q=n.reverse.get(V);if(Q)return $(Q)}return R||V?{b:null,l:R,r:V}:null},A=z=>(B.has(z)||B.set(z,x(z)),B.get(z)),X=(z,h)=>hn(z)?f[h].logicalParent(z):z.parent,H=new Map,q=new Map,Ee=(z,h)=>(hn(z)?[f[h].pathOf(z)]:z.nodes.map(E=>f[h].pathOf(E))).filter(Boolean),Me=z=>{let h=z.b||z.l||z.r,E=z.b?"base":z.l?"local":"remote",R=q.get(h);if(R)return R;let V=!hn(h),Q=Ee(h,E)[0],j=`${E[0]}:${JSON.stringify(Q===void 0?null:Q)}${V?":run":""}`,ue=H.get(j);if(ue)return q.set(h,ue),ue;let be=D(z);return ue={key:j,nodeType:hn(h)?1:h.kind==="comment"?8:3,base:z.b?Ee(z.b,"base"):[],local:z.l?Ee(z.l,"local"):[],remote:z.r?Ee(z.r,"remote"):[],merged:be.map(ie=>f.out.pathOf(ie)).filter(Boolean),live:[]},H.set(j,ue),q.set(h,ue),T.refs.set(ue,be),ue},je={base:new Map,local:new Map,remote:new Map},ae=new Map,Ae=(z,h)=>{let E=X(z,h);if(!E||E.nodeType!==1)return null;let R=je[h].get(E);if(!R){let Q=o(E),j=ue=>Me(h==="base"?$(ue):W(ue,h));R={parent:j(E),refs:Q.map(j),index:new Map(Q.map((ue,be)=>[ue,be]))},je[h].set(E,R)}let V=R.index.get(z)??-1;return{parent:R.parent,before:R.refs.slice(V+1),after:R.refs.slice(0,Math.max(0,V)).reverse()}},_e=z=>{let h=z.parentNode;if(!h)return null;let E=ae.get(h);if(!E){let V=h.nodeType===11?g.get(h):h,Q=V&&V.nodeType===1?A(V):null;if(!Q)return null;let j=[],ue=[],be=new Map;for(let Ne of h.childNodes){let U=A(Ne),Y=U&&Me(U),he=j.length,ge=j.length-1;Y&&Y!==j[ge]&&(j.push(Y),ge++);let de={ref:Y,group:ge,after:he};ue.push(de),be.set(Ne,de)}let ie=j.length;for(let Ne=ue.length-1;Ne>=0;Ne--){let U=ue[Ne];U.before=ie,U.ref&&(ie=U.group)}E={parent:Me(Q),refs:j,index:be},ae.set(h,E)}let R=E.index.get(z);return{parent:E.parent,before:E.refs.slice(R.before),after:E.refs.slice(0,R.after).reverse()}},ve=z=>hn(z)?z.outerHTML:z.value,N=z=>hn(z)?"element":z.kind==="comment"?"comment":"text",J=(z,h)=>({path:z,offset:h}),le=(z,h,E)=>{if(!z)return null;let R=f[E],V=0;if(h){let Q=hn(h)?h:h.nodes[h.nodes.length-1];Q.parentNode&&(V=R.indexIn(Q.parentNode,Q)+1)}return J(R.containerPath(z),V)},oe=(z,h)=>{let E=X(z,"base"),R=E?y(u(h),E):null;if(!hn(R))return null;let V=o(E),Q=null;for(let j=V.indexOf(z)-1;j>=0&&!Q;j--){let ue=y(u(h),V[j]);ue&&X(ue,h)===R&&(Q=ue)}return le(R,Q,h)},Re=(z,h,E,R)=>{let V=f[R],Q=0;for(let j=0;j<z.nodes.length;j++){let ue=z.nodes[j],be=ue.nodeValue.length,ie=j===z.nodes.length-1;if((E==="start"?h<Q+be:h<=Q+be)||ie)return J(V.pathOf(ue),Math.max(0,Math.min(h-Q,be)));Q+=be}return null},Be=(z,h)=>{let E=f[h],R=z.firstChild,V=z.lastChild;return R&&R.nodeType===3&&V.nodeType===3?{start:J(E.pathOf(R),0),end:J(E.pathOf(V),V.nodeValue.length)}:{start:J(E.pathOf(z),0),end:J(E.pathOf(z),z.childNodes.length)}},Se=(z,h,E)=>{for(let j of z.nodes)if(E==="start"?j.s<=h&&h<j.e:j.s<h&&h<=j.e)return{kind:"text",node:j.node,offset:h-j.s};let R=E==="start"?h:h-1,V=()=>{for(let j of z.nodes)if(j.s===h||j.e===h)return{kind:"text",node:j.node,offset:h-j.s};return null},Q=z.atomAt.get(R);if(Q)return{kind:E==="start"?"before":"after",node:Q.el};if(z.text[R]===xt){let j=z.marks.find(be=>be.block&&be.to===R+1);if(j)return E==="start"?{kind:"end",node:j.el}:{kind:"after",node:j.el};let ue=z.marks.find(be=>be.block&&be.from===R+1);if(ue)return E==="start"?{kind:"before",node:ue.el}:{kind:"startOf",node:ue.el}}return V()},nt=(z,h)=>Se(z,h,"end")||Se(z,h,"start"),Je=(z,h)=>{switch(h.kind){case"text":return J(z.pathOf(h.node),h.offset);case"end":return J(z.containerPath(h.node),Ln(h.node).childNodes.length);case"startOf":return J(z.containerPath(h.node),0);default:{let E=h.node.parentNode;return J(z.containerPath(E),z.indexIn(E,h.node)+(h.kind==="after"?1:0))}}},ht=(z,h,E,R,V)=>{let Q=Se(z,h,E);return Q?Je(f[R],Q):V()},Ge=(z,h,E,R)=>{let V=z.textNodes.map(ie=>({s:ie.ms,e:ie.me,start:{kind:"text",node:ie.node,offset:0},end:{kind:"text",node:ie.node,offset:ie.me-ie.ms}}));for(let[ie,Ne]of z.atomOut)V.push({s:ie,e:ie+1,start:{kind:"before",node:Ne},end:{kind:"after",node:Ne}});for(let[ie,Ne]of z.breakOut)V.push({s:ie,e:ie+1,start:{kind:"end",node:Ne},end:{kind:"after",node:Ne}});for(let ie of V)if(ie.start.kind==="text"&&ie.s<h&&h<ie.e)return{kind:"text",node:ie.start.node,offset:h-ie.s};if(E!=="empty"){let ie=V.find(Ne=>E==="start"?Ne.s===h:Ne.e===h);if(ie)return E==="start"?ie.start:ie.end}let Q=V.find(ie=>ie.e===h);if(Q)return Q.end;let j=V.find(ie=>ie.s===h);if(j)return j.start;let ue=null,be=null;for(let ie of V)ie.e<=h&&(!ue||ie.e>ue.e)&&(ue=ie),ie.s>=h&&(!be||ie.s<be.s)&&(be=ie);return ue?ue.end:be?be.start:R()},st=(z,h)=>{if(!h)return null;if(h.kind==="text"){let V=z.nodes.find(Q=>Q.node===h.node);return V?V.s+Math.min(h.offset,V.e-V.s):null}let E=z.atoms.find(V=>V.el===h.node);if(E)return h.kind==="after"?E.i+1:E.i;let R=z.marks.find(V=>V.el===h.node);return R?h.kind==="before"&&R.block&&z.text[R.from-1]===xt&&!z.marks.some(V=>V.block&&V.to===R.from)?R.from-1:h.kind==="startOf"||h.kind==="before"?R.from:h.kind==="end"&&R.block?R.to-1:R.to:null},Mt=(z,h,E,R)=>{for(let ue of z.nodes)if(E==="start"?ue.s<=h&&h<ue.e:ue.s<h&&h<=ue.e)return{kind:"text",node:ue.node,offset:h-ue.s};let V=E==="start"?h:h-1;if(!z.atomAt.has(V)&&z.text[V]!==xt){for(let ue of z.nodes)if(ue.s===h||ue.e===h)return{kind:"text",node:ue.node,offset:h-ue.s}}let Q=z.atomAt.get(V);if(Q)return{kind:E==="start"?"before":"after",node:Q.el};if(z.text[V]===xt){let ue=z.marks.find(ie=>ie.block&&ie.to===V+1);if(ue)return E==="start"?{kind:"end",node:ue.el}:{kind:"after",node:ue.el};let be=z.marks.find(ie=>ie.block&&ie.from===V+1);if(be)return E==="start"?{kind:"before",node:be.el}:{kind:"startOf",node:be.el}}let j=z.marks.find(ue=>ue.block&&ue.from===h);return j?{kind:"startOf",node:j.el}:R?{kind:E==="start"?"startOf":"end",node:R}:null},It=z=>{if(!z)return null;if(z.kind==="wholeStart"||z.kind==="wholeEnd"){let h=yt(z.node);return z.kind==="wholeStart"?h.start:h.end}return Je(f.out,z)},yt=z=>{let h=z.firstChild,E=z.lastChild;return h&&h.nodeType===3&&E.nodeType===3?{start:J(f.out.pathOf(h),0),end:J(f.out.pathOf(E),E.nodeValue.length)}:{start:J(f.out.pathOf(z),0),end:J(f.out.pathOf(z),z.childNodes.length)}},Nt=z=>{let h=X(z,"base"),E=h?D($(h))[0]:null;if(!E)return null;let R=Ln(E),V=o(h);for(let Q=V.indexOf(z)-1;Q>=0;Q--){let j=D($(V[Q])).filter(ue=>ue.parentNode===R);if(j.length)return{kind:"after",node:j[j.length-1]}}return{kind:"startOf",node:E}},Ct=(z,h,E,R,V,Q)=>({text:z,start:h,end:E,fragment:R,span:V,scope:Q}),_t=(z,h,E,R,V)=>Ct(z,h,E,z.slice(h,E),R,V),fn=(z,h,E,R,V)=>(T.spans.set(z,{start:h,end:E,scopeStart:R,scopeEnd:V}),z),Et=new Map,Gt=new Map,wn=(z,h,E)=>{let R=`text:${z.key}:${h}:${E}`,V=Gt.get(R)||0;return Gt.set(R,V+1),`${R}:${V}`},Bt=(z,h)=>{let E,R,V,Q="plain",j,ue,be,ie,Ne,U=(ge,de,ee,te,K)=>{if(!ge){let ne=oe(K,te);return _t("",0,0,{start:ne,end:ne},{start:ne,end:ne})}return _t(ge.value,de,ee,{start:Re(ge,de,de===ee?"end":"start",te),end:Re(ge,ee,"end",te)},{start:Re(ge,0,"start",te),end:Re(ge,ge.value.length,"end",te)})};if(h.site==="run"){let{bRun:ge,lRun:de,rRun:ee,node:te,c:K}=h;E=$(ge),R=K.bs,V=K.be,j=U(ge,K.bs,K.be,"base",ge),ue=U(de,K.ls,K.le,"local",ge),be=U(ee,K.rs,K.re,"remote",ge);let ne=te?te.nodeValue:"",xe=Ie=>te?{kind:"text",node:te,offset:Ie}:Nt(ge);ie=fn(_t(ne,K.ms,K.me,{start:It(xe(K.ms)),end:It(xe(K.me))},{start:It(xe(0)),end:It(xe(ne.length))}),xe(K.ms),xe(K.me),xe(0),xe(ne.length)),Ne=te||(Nt(ge)||{}).node||null}else if(h.site==="whole"){let ge=h.el,de=r.get(ge);E=$(de.base),R=0,V=z.base.length;let ee=(K,ne,xe)=>{let Ie=Be(ne,xe);return _t(K,0,K.length,Ie,Ie)};j=ee(z.base,de.base,"base"),ue=ee(z.local,de.local,"local"),be=ee(z.remote,de.remote,"remote");let te=yt(ge);ie=fn(_t(z.resolved,0,z.resolved.length,te,te),{kind:"wholeStart",node:ge},{kind:"wholeEnd",node:ge},{kind:"wholeStart",node:ge},{kind:"wholeEnd",node:ge}),Ne=ge}else if(h.site==="comment"){let{bRun:ge,lRun:de,rRun:ee,node:te}=h;E=$(ge),R=0,V=z.base.length;let K=(Le,ke)=>{if(!Le){let Qe=oe(ge,ke);return _t("",0,0,{start:Qe,end:Qe},{start:Qe,end:Qe})}let $e=Le.nodes[0],Xe={start:J(f[ke].pathOf($e),0),end:J(f[ke].pathOf($e),Le.value.length)};return _t(Le.value,0,Le.value.length,Xe,Xe)};j=K(ge,"base"),ue=K(de,"local"),be=K(ee,"remote");let ne=z.resolved,xe=Le=>te?{kind:"text",node:te,offset:Le}:Nt(ge),Ie={start:It(xe(0)),end:It(xe(ne.length))};ie=fn(_t(ne,0,ne.length,Ie,Ie),xe(0),xe(ne.length),xe(0),xe(ne.length)),Ne=te||(Nt(ge)||{}).node||null}else{let{fb:ge,fl:de,fr:ee,scope:te}=h,K=h.merged;Q="html",E=te.base?$(te.base):W(te.local,"local"),R=z.bs,V=z.be;let ne=re=>{let Oe=te[re];for(let Pe=te.at-1;Pe>=0;Pe--){let We=te.units[Pe],Fe=re==="base"?We:y(u(re),We);if(Fe&&X(Fe,re)===Oe)return Fe}return null},xe=re=>()=>le(te[re],ne(re),re),Ie=(re,Oe,Pe,We,Fe)=>{let pt=yn=>yn?Je(f[Fe],yn):xe(Fe)(),tt=Oe===Pe?nt(re,Oe):Se(re,Oe,"start"),Ft=Oe===Pe?nt(re,Oe):Se(re,Pe,"end"),Wt=pt(tt),dn={start:Wt,end:Oe===Pe?Wt:pt(Ft)},bt=h.full?h.full(Fe):null;if(!bt)return Ct(re.text,Oe,Pe,We,dn,{start:pt(Se(re,0,"start")),end:pt(Se(re,re.text.length,"end"))});let lt=tt?st(bt,tt):null,ze=Ft?st(bt,Ft):null,At=lt===null?0:lt,at=Math.max(At,ze===null?bt.text.length:ze),Dt=pt(Se(bt,0,"start"));return Ct(bt.text,At,at,vo(bt,At,at),dn,{start:Dt,end:bt.text.length?pt(Se(bt,bt.text.length,"end")):Dt})};j=h.synthetic?null:Ie(ge,z.bs,z.be,z.base,"base"),ue=Ie(de,z.lss,z.lse,z.local,"local"),be=Ie(ee,z.rss,z.rse,z.remote,"remote");let[Le,ke]=z.range||[0,0],$e=K.out,Xe=()=>{let re=Ln(K.node);for(let Oe=te.at-1;Oe>=0;Oe--){let Pe=D($(te.units[Oe])).filter(We=>We.parentNode===re);if(Pe.length)return{kind:"after",node:Pe[Pe.length-1]}}for(let Oe=te.at;Oe<te.units.length;Oe++){let Pe=D($(te.units[Oe])).filter(We=>We.parentNode===re);if(Pe.length)return{kind:"before",node:Pe[0]}}return{kind:"startOf",node:K.node}};if($e.via)for(let[re,Oe]of $e.via)O.set(re,Oe);let Qe=Ge(K,Le,Le===ke?"empty":"start",Xe),Ut=Le===ke?Qe:Ge(K,ke,"end",Xe),Pt=$e.text.length?Mt($e,0,"start",K.node):Xe(),C=$e.text.length?Mt($e,$e.text.length,"end",K.node):Pt,G=st($e,Qe),se=st($e,Ut),me=G===null?0:G,ye=Math.max(me,se===null?$e.text.length:se);ie=fn(Ct($e.text,me,ye,vo($e,me,ye),{start:It(Qe),end:It(Ut)},{start:It(Pt),end:It(C)}),Qe,Ut,Pt,C);let ce=T.spans.get(ie);if(ce.flat=$e,!$e.text.length){let re=It(Pt),Oe=fo(p,re),Pe=Oe[0],We=Oe[1];ce.empty={parent:Pe.nodeType===11?g.get(Pe):Pe,previous:Pe.childNodes[We-1]||null,next:Pe.childNodes[We]||null}}Ne=Qe?Qe.node:K.node}let Y=Me(E),he=(h.site==="whole"||h.site==="comment"||(h.policy||c)!=="both")&&z.resolved!==z.local;return{key:h.site==="comment"&&Et.get(E.b||E.l||E.r)||wn(Y,R,V),subject:Y,localLost:he,anchor:Ne,text:{encoding:Q,base:j,local:ue,remote:be,merged:ie,liveSpan:null,liveScope:null}}},ln=(z,h)=>{let E=A(h.el),R=Me(E),V=h.sample;return{key:`attr:${R.key}:${V.namespaceURI||""}:${V.localName}`,subject:R,localLost:z.resolved!==z.local,anchor:h.el,attribute:{namespaceURI:V.namespaceURI||null,localName:V.localName,qualifiedName:V.name}}},Yt=(z,h)=>{let E=z.detail,R=h.unit||$(h.subject),V=Me(R),Q=T.refs.get(V),j=R.l?Ae(R.l,"local"):null,ue=R.r?Ae(R.r,"remote"):null,be=Q.length?_e(Q[0]):null,ie,Ne,U,Y=null,he=null,ge=h.deleted;switch(E){case"both-reordered":{ie=Ne="reordered";let de=new Set(h.rKept),ee=h.lKept.filter(Ie=>de.has(Ie)&&D($(Ie)).length),te=Ie=>S.get(D($(Ie))[0]);Y=ee.map(Ie=>Me($(Ie))),he=ee.slice().sort((Ie,Le)=>te(Ie)-te(Le)).map(Ie=>Me($(Ie)));let K=Ie=>!hn(Ie)&&Ie.kind!=="comment"&&Ie.nodes.every(Le=>!/[^\t\n\f\r ]/.test(Le.data)),ne=ee.filter(Ie=>!K(Ie)),xe=ne.slice().sort((Ie,Le)=>te(Ie)-te(Le));U=ne.some((Ie,Le)=>Ie!==xe[Le]);break}case"both-moved":ie=Ne="moved",U=!j||!Q.some(de=>{let ee=de===Q[0]?be:_e(de);return ee&&ee.parent===j.parent});break;case"edit-beats-delete":ie=ge==="local"?"deleted":"edited",Ne=ge==="remote"?"deleted":"edited",U=ge==="local";break;case"move-beats-delete":ie=ge==="local"?"deleted":"moved",Ne=ge==="remote"?"deleted":"moved",U=ge==="local";break;case"remote-wins":ie="edited",Ne="edited",U=!0;break;default:ie=Ne="inserted",U=h.localLost}return{key:`structure:${V.key}:${E}`,subject:V,localLost:U,anchor:Q[0]||null,structure:{localAction:ie,remoteAction:Ne,localPlacement:j,remotePlacement:ue,mergedPlacement:be,localOrder:Y,mergedOrder:he,localFragment:E==="both-reordered"||!R.l?null:ve(R.l),fragmentKind:N(R.b||R.l||R.r)}}};for(let[z,h]of l){if(z.kind!=="structure")continue;let E=h.unit||$(h.subject),R=E.b||E.l||E.r;!hn(R)&&R.kind==="comment"&&Et.set(R,`structure:${Me(E).key}:${z.detail}`)}let un=new Map;for(let[z,h]of l){if(z.kind==="structure"){let Q=Me(h.unit||$(h.subject)),j=`structure:${Q.key}:${z.detail}`,ue=un.get(j);if(ue&&ue.structure){z.recovery=ue;let be=T.refs.get(Q);z.el==null&&be.length&&(z.el=hn(be[0])?be[0]:f.out.logicalParent(be[0]));continue}}let E=z.kind==="text"?Bt(z,h):z.kind==="attr"?ln(z,h):Yt(z,h),R=un.get(E.key);R||(R={version:wa,key:E.key,localLost:E.localLost,subject:E.subject,applied:!1,unavailable:null},un.set(E.key,R),T.anchors.set(R,E.anchor)),E.text&&(R.text=E.text),E.attribute&&(R.attribute=E.attribute),E.structure&&(R.structure=E.structure),E.text&&(R.localLost=E.localLost),z.recovery=R;let V=T.refs.get(E.subject);z.kind==="structure"&&z.el==null&&V.length&&(z.el=hn(V[0])?V[0]:f.out.logicalParent(V[0])),z.kind==="text"&&z.node==null&&V.length&&E.subject.nodeType===8&&(z.node=V[0])}return T}}function nl(e,t,n){if(!t)return;let{lookup:o,vetoed:r,vetoedAttrs:c,liveAttr:l}=n,s=n.ignored||(()=>!1),i=ho(n.liveRoot),a=x=>!!x&&i.containerPath(x)!==null,p=x=>{let A=x.parentNode;return A&&A.nodeType===11?t.outOwners.get(A)||null:A},f=x=>{for(let A=x;A;A=p(A))if(t.via.has(A)&&(A=t.via.get(A)),r.has(A)||n.vetoedLive?.has(d(A)))return!0;return!1},u=x=>Array.from(Ln(x).children).filter(A=>!s(A)),y=(x,A)=>u(x)[u(A.parentNode).indexOf(A)],b=(x,A)=>{let X=null,H=null,q=0;for(let ae=A.previousSibling;ae;ae=ae.previousSibling){if(ae.nodeType===1&&!s(ae)){X=ae;break}ae.nodeType===3&&(q+=ae.nodeValue.length)}for(let ae=A.nextSibling;ae&&!H;ae=ae.nextSibling)ae.nodeType===1&&!s(ae)&&(H=ae);let Ee=X?y(x,X):null,Me=H?y(x,H):null;if(X&&!Ee||H&&!Me)return null;let je=[];for(let ae=Ee?Ee.nextSibling:Ln(x).firstChild;ae&&ae!==Me;ae=ae.nextSibling)ae.nodeType===3&&je.push(ae);return je.length?{nodes:je,lead:q}:null},S=x=>{let A=[],X=x;for(;X&&!t.via.has(X);X=X.parentNode)A.push(X);if(!X||!A.length)return null;let H=d(t.via.get(X));for(let Me=A.length-1;Me>0&&H;Me--)H=y(H,A[Me]);if(!H)return null;let q=A[0];if(q.nodeType===3)return b(H,q);let Ee=q.nodeType===1?y(H,q):null;return Ee?{nodes:[Ee],lead:0}:null},g=x=>{let A=o(x),X=A?{nodes:Array.isArray(A)?A:[A],lead:0}:t.via.size?S(x):null;if(!X)return null;let H=X.nodes.filter(a);return H.length?{nodes:H,lead:X.lead}:null},d=x=>{let A=g(x);return A?A.nodes[0]:null},w=x=>{if(!x)return null;if(x.kind==="text"){let q=g(x.node);if(!q)return null;let Ee=q.nodes,Me=x.offset+q.lead,je=0;for(let ae=0;ae<Ee.length;ae++){let Ae=Ee[ae].nodeValue.length;if(Me<=je+Ae||ae===Ee.length-1)return Me>=je&&Me<=je+Ae?[Ee[ae],Me-je]:null;je+=Ae}return null}let A=d(x.node);if(!A)return null;if(x.kind==="end")return[Ln(A),Ln(A).childNodes.length];if(x.kind==="startOf")return[Ln(A),0];if(x.kind==="wholeStart")return A.firstChild?[A.firstChild,0]:[A,0];if(x.kind==="wholeEnd")return A.lastChild?[A.lastChild,A.lastChild.nodeValue.length]:[A,A.childNodes.length];let X=A.parentNode;if(!X)return null;let H=Array.prototype.indexOf.call(X.childNodes,A);return[X,x.kind==="after"?H+1:H]},O=x=>({blocks:new Set((x.flat?.marks||[]).filter(A=>A.block).map(A=>d(A.el)).filter(Boolean)),atoms:new Set((x.flat?.atoms||[]).map(A=>d(A.el)).filter(Boolean)),ignored:s}),T=(x,A,X,H)=>{if(!x||!A||!uo(x)||!uo(A))return!1;for(let Me of[x,A])if(!a(Me.startContainer)||!a(Me.endContainer))return!1;let q=X.merged;if(q.start===q.end&&(x.startContainer!==x.endContainer||x.startOffset!==x.endOffset))return!1;let Ee=O(H);return ro(A,X.encoding,Ee)===q.text&&ro(x,X.encoding,Ee)===q.text.slice(q.start,q.end)},k=new Map,v=x=>{let A=x.parentNode;return A?(k.has(A)||k.set(A,new Map(Array.from(A.childNodes,(X,H)=>[X,H]))),k.get(A).get(x)):-1},I=(x,A)=>{if(!A)return!1;let X=i.logicalParent(x);if(!A.parent.live.includes(X))return!1;let H=v(x);for(let[q,Ee]of[["before",1],["after",-1]]){let Me=H;for(let je of A[q]){if(je.live.includes(x))continue;let ae=je.live.filter(_e=>_e!==x&&_e.parentNode===x.parentNode);if(!ae.length)continue;let Ae=Ee===1?Math.min(...ae.map(v)):Math.max(...ae.map(v));if(Ee*(Ae-Me)<=0)return!1;Me=Ae}}return!0},M=x=>{let A=x.structure;if(A.mergedOrder){let X=new Set(x.subject.live.map(Ln)),H=null,q=-1;for(let Ee of A.mergedOrder){let Me=Ee.live.find(je=>X.has(je.parentNode));if(!Me||H&&Me.parentNode!==H||v(Me)<=q)return!1;H=Me.parentNode,q=v(Me)}return x.subject.live.length>0}return x.subject.live.some(X=>I(X,A.mergedPlacement))},P=(x,A)=>{let X=w(x),H=w(A);return X&&H?{startContainer:X[0],startOffset:X[1],endContainer:H[0],endOffset:H[1]}:null},D=new Set,$=x=>{if(!x||D.has(x))return;D.add(x);let A=[];for(let X of t.refs.get(x)||[]){let H=g(X);if(H)for(let q of H.nodes)A.includes(q)||A.push(q)}x.live=A},W=x=>{x&&($(x.parent),x.before.forEach($),x.after.forEach($))},B=new Set;for(let x of e){let A=x.recovery;if(!A||B.has(A))continue;B.add(A),$(A.subject),A.structure&&(W(A.structure.localPlacement),W(A.structure.remotePlacement),W(A.structure.mergedPlacement),(A.structure.localOrder||[]).forEach($),(A.structure.mergedOrder||[]).forEach($));let X=t.anchors.get(A),H=X?d(X):null,q=!!H;if(A.text){let N=t.spans.get(A.text.merged),J=N?P(N.start,N.end):null,le=N?P(N.scopeStart,N.scopeEnd):null;if(N?.empty){let oe=N.empty,Re=oe.previous?{kind:"after",node:oe.previous}:{kind:"startOf",node:oe.parent},Be=oe.next?{kind:"before",node:oe.next}:{kind:"end",node:oe.parent},Se=P(Re,Be);!Se||Se.startContainer!==Se.endContainer||Se.startOffset!==Se.endOffset?J=null:J=le=Se}T(J,le,A.text,N)||(J=le=null),A.text.liveSpan=J,A.text.liveScope=J?le:null,J||(q=!1)}A.structure&&q&&(q=M(A)),A.attribute&&q&&(q=l(H,A.attribute,x.resolved));let Ee=(!!A.attribute||!!A.text&&H?.tagName==="TEXTAREA")&&!!c&&[X,H].some(N=>c.get(N)?.has(A.attribute?A.attribute.qualifiedName:"value")),Me=t.localState?.states.get(A),je=!!A.text&&[...n.removedVetoes||[]].some(N=>Me?.touched.has(N)),ae=A.structure?.localAction==="inserted"&&[...r].some(N=>N===X||X?.contains(N)),Ae=X&&f(X)||Ee||je||ae,_e=Ae&&el(A,x,t,a);_e&&(je||ae&&A.localLost)&&(q=!1);let ve=!q&&_e&&Ae;A.applied=q,A.unavailable=q?null:ve?"hook-veto":"missing-output",ve&&(A.localLost=!1),!q&&A.text&&(A.text.liveSpan=A.text.liveScope=null)}}function Pr(e,t,n){let o=ho(t),r=ho(n),c=f=>!!f&&r.containerPath(f)!==null,l=f=>{if(f===t)return n;let u=o.pathOf(f);if(u&&t!==n){let y=fo(n,{path:u,offset:0});if(y&&y[0].nodeType===f.nodeType)return y[0]}return f},s=new Set,i=f=>{!f||s.has(f)||(s.add(f),f.live=f.live.map(l).filter(c))},a=f=>{f&&(f.startContainer=l(f.startContainer),f.endContainer=l(f.endContainer))},p=new Set;for(let f of e){f.node===t&&n.tagName==="SCRIPT"&&(f.node=n),f.el===t&&f.kind==="structure"&&(f.el=n);let u=f.recovery;if(!u||p.has(u))continue;if(p.add(u),i(u.subject),u.text){a(u.text.liveSpan),a(u.text.liveScope);let b=u.text.liveSpan,S=u.text.liveScope,g=u.text.merged,d=w=>!!w&&uo(w)&&c(w.startContainer)&&c(w.endContainer);(!d(b)||!d(S)||ro(S,u.text.encoding)!==g.text||ro(b,u.text.encoding)!==g.text.slice(g.start,g.end))&&(u.text.liveSpan=null,u.text.liveScope=null,u.applied=!1,u.unavailable="missing-output")}let y=u.structure;if(y){for(let b of[y.localPlacement,y.remotePlacement,y.mergedPlacement])b&&(i(b.parent),b.before.forEach(i),b.after.forEach(i));(y.localOrder||[]).forEach(i),(y.mergedOrder||[]).forEach(i),u.subject.live.length||(u.applied=!1,u.unavailable="missing-output")}}}var Co=e=>e?.nodeType===1,Jo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function xa({provenance:e,parentOf:t,twins:n,baseOf:o,build:r,ignored:c,remoteWins:l,discarded:s}){let i=new Map,a=new WeakMap;function p(y,b,S,g=!1){if(!Co(y)||!Co(S))return null;let d=i.get(y);if(d)(g||!d.selected&&b==="remote")&&(d.parent=t(S),d.port=S,d.sourceSide=b,d.selected=g);else{let w=a.get(y)||null;d={owner:y,parent:t(S),port:S,sourceSide:b,originalParent:t(y),originalPort:y,selected:g,state:w?"built":"planned",output:w,disposition:null},i.set(y,d)}return d}function f(y,b){if(!Co(y)||!Co(b))return;a.has(y)||a.set(y,b);let S=i.get(y);S&&S.state!=="attached"&&!S.output&&(S.output=b,S.state="built")}function u(y){if(!i.size)return;let b=new Map,S=new WeakMap,g=new WeakMap,d=new WeakSet,w=new Set,O=(W,B)=>{if(!W)return;if(Array.isArray(W)){for(let A of W)O(A,B);return}let x=b.get(W);x||b.set(W,x=[]),x.push(B)},T=(W,B)=>{if(!W)return;let x=[W];for(;x.length;){let A=x.pop();O(A,B);for(let X of Jo(A).childNodes)x.push(X)}};function k(W,B=null,x=!1){if(d.has(W))return;d.add(W),S.set(W,B);let A=e.get(W),X=x||!!(A&&l(A.remote||A.base));g.set(W,X);let H={node:W,kind:"node",authority:X};if(A?.pinned)T(A.local,{...H,kind:"ignored"});else if(A?.unchanged)for(let q of[A.base,A.local,A.remote])T(q,{...H,kind:"unchanged"});else if(A){for(let q of[A.base,A.local,A.remote])O(q,H);if(Co(A.local))for(let q of Jo(A.local).children)c(q)&&T(q,{...H,kind:"ignored"})}for(let q of Jo(W).childNodes)k(q,W,X)}let v=W=>{if(W.output&&d.has(W.output))return W.state="attached",W.disposition="node",!0;let{local:B,remote:x}=n(W.owner);for(let A of[W.owner,B,x]){let X=b.get(A);if(X?.length){let H=X.find(q=>q.kind==="node")||X[0];return W.output=H.node,W.state="attached",W.disposition=H.kind,!0}}return!1},I=(W,B)=>(b.get(W)||[]).find(A=>A.kind==="node"&&Co(A.node)&&(!A.authority||B.sourceSide==="remote"))?.node,M=(W,B,x)=>{let A=b.get(W)||[],X=x?[...A].reverse():A;for(let H of X){if(H.kind!=="node")continue;let q=H.node;for(;q&&S.get(q)!==B;)q=S.get(q);if(q)return q}return null},P=(W,B,x)=>{let A=Jo(B);for(let X=x?.previousSibling;X;X=X.previousSibling){let H=M(X,B,!0);if(H){A.insertBefore(W,H.nextSibling);return}}for(let X=x?.nextSibling;X;X=X.nextSibling){let H=M(X,B,!1);if(H){A.insertBefore(W,H);return}}A.appendChild(W)};function D(W,B,x){let A=B==="base"?W:o(W,B),X=i.get(A);X&&X!==x&&$(X)}function $(W){if(W.state==="attached"||W.disposition==="remote-wins"||w.has(W)||v(W))return;w.add(W);let{local:B,remote:x}=n(W.owner);if(l(x||W.owner)){if(!x){W.disposition="remote-wins",s(W.owner,B),w.delete(W);return}W.parent=t(x),W.port=x,W.sourceSide="remote"}if(D(W.parent,W.sourceSide,W),v(W)){w.delete(W);return}let A=I(W.parent,W),X=W.port;if(!A){if(D(W.originalParent,"base",W),v(W)){w.delete(W);return}let q=W.originalParent;for(X=W.originalPort;q&&!A;)A=I(q,W),A||(X=q,q=t(q))}if(!A)throw new Error("A planned move has no allowed surviving parent");let H=W.output||r(W.owner);W.output=H,W.state="built",P(H,A,X),k(H,A,g.get(A)||!1),v(W),w.delete(W)}k(y);for(let W of i.values())$(W)}return{planned:i,has:y=>i.has(y),plan:p,produced:f,drain:u}}function Ro(e,t,n,o,r,c,l,s,i,a,p,f,u){let y=null;return xa({provenance:e,parentOf:g=>{if(!g)return null;let d=t(g);if(d||g.parentNode?.nodeType!==11)return d;if(!y){y=new WeakMap;let w=[f,u];for(;w.length;){let O=w.pop(),T=Jo(O);T!==O&&y.set(T,O);for(let k of T.children)w.push(k)}}return y.get(g.parentNode)||null},twins:g=>({local:r(n,g),remote:r(o,g)}),baseOf:(g,d)=>g&&(d==="local"?n:o).reverse.get(g)||null,build:g=>c(g,r(n,g),r(o,g),!1),ignored:l,remoteWins:s,discarded:(g,d)=>{d&&p(g,d,n)&&!i.some(w=>w.detail==="remote-wins"&&w.base===g)&&a({kind:"structure",el:null,detail:"remote-wins",base:g,local:d,remote:null},{subject:g})}})}function ka({parent:e,base:t,views:n,eligible:o,ignored:r,remoteWins:c,budget:l=zt(2e4*32),maxUnits:s=256,maxCharacters:i=2e4}){let a=(d,w=null)=>({status:d,reason:w,parent:e,records:[]});if(n.some(({V:d})=>d.asBase)||r(e)||c(e)||n.some(({V:d})=>!d.el||r(d.el)||c(d.el)))return a("none");let p=t.length+n[0].V.units.length+n[1].V.units.length;if(p>s)return a("fallback","unit-limit");let f=Symbol(),u=d=>{if(d>l.remaining)throw f;l.remaining-=d,l.crossParentSteps=(l.crossParentSteps||0)+d},y=new Map,b=0,S=d=>{if(u(1),y.has(d))return y.get(d);let w=d.nodeType===1?d.childNodes:d.nodes;u(w.length*4+1);let O=d.nodeType===1?Array.from(w):w,T=0;for(let I=0;I<O.length;I++){let M=O[I];if(M.nodeType!==3||I&&O[I-1].nextSibling!==M)return y.set(d,null),null;T+=M.data.length}if(T>i-b)throw f;u(T*8+1),b+=T;let k=nn(O);if(k.text.includes(xt))return y.set(d,null),null;let v={unit:d,nodes:O,flat:k};return y.set(d,v),v},g=[];try{u(p*8+1);for(let d=0;d<2;d++){let w=n[d].V,O=n[1-d].V,T=[],k=new Map;for(let v=0;v<t.length;v++){u(1);let I=t[v];if(I.kind!=="text"||w.twin(I))continue;let M=O.twin(I);if(!M||M.kind!=="text"||!O.here(M))continue;let P=S(I),D=S(M);if(!P||!D||!/\S/.test(P.flat.text))continue;u(P.flat.text.length*2+1);let $=P.flat.text;k.set($,(k.get($)||0)+1),T.push({source:I,opposite:M,sourceModel:P,oppositeModel:D,index:v})}for(let v of T){let{source:I,opposite:M,sourceModel:P,oppositeModel:D,index:$}=v,W=[];for(let J of[-1,1]){u(1);let le=t[$+J];if(!le||le.nodeType!==1||!o(le)||r(le)||c(le))continue;let oe=P.nodes[0],Re=P.nodes.at(-1);if(J===-1?oe?.previousSibling!==le:Re?.nextSibling!==le)continue;let Be=w.twin(le),Se=O.twin(le);if(!Be||!Se||!w.here(Be)||O.here(Se)||w.baseOf(Be)!==le||O.baseOf(Se)!==le||!o(Be)||!o(Se)||r(Be)||r(Se)||c(Be)||c(Se)||Be.tagName!==le.tagName||Se.tagName!==le.tagName||Be.namespaceURI!==le.namespaceURI||Se.namespaceURI!==le.namespaceURI)continue;let nt=S(le),Je=S(Be),ht=S(Se);if(!nt||!Je||!ht||!/\S/.test(nt.flat.text))continue;let Ge=nt.flat.text,st=P.flat.text,Mt=Je.flat.text;if(u((Ge.length+st.length+Mt.length)*3+1),Mt.length!==Ge.length+st.length)continue;let It=J===-1;(It?!Mt.startsWith(Ge)||!Mt.endsWith(st):!Mt.startsWith(st)||!Mt.endsWith(Ge))||W.push({owner:le,target:Be,moved:Se,ownerBase:nt,joined:Je,ownerOther:ht,targetFrom:It?Ge.length:0,retainedFrom:It?0:st.length})}if(!W.length)continue;if(W.length!==1||k.get(P.flat.text)!==1)return a("fallback","ambiguous-origin");let B=W[0],{owner:x,target:A,moved:X,ownerBase:H,joined:q,ownerOther:Ee,targetFrom:Me,retainedFrom:je}=B;if(u(g.length+1),g.some(J=>J.owner===x))return a("fallback","ambiguous-owner");let ae={source:I,target:A,from:0,to:P.flat.text.length,targetFrom:Me},Ae=Vn({base:P.flat,side:q.flat,retained:[],transfers:[{from:ae.from,to:ae.to,target:Me,destination:x}],budget:l});if(Ae.status!=="ready"||Ae.covers(ae.from,ae.to)!==!0)return a("fallback",Ae.reason||"work-limit");let _e=[{unit:I,model:P,from:0,to:P.flat.text.length},null,null];_e[d+1]={unit:A,model:q,from:Me,to:Me+P.flat.text.length},_e[2-d]={unit:M,model:D,from:0,to:D.flat.text.length};let ve=[H,null,null];ve[d+1]=q,ve[2-d]=Ee;let N=[x,null,null];N[d+1]=A,N[2-d]=X,g.push({side:d,parent:e,source:I,target:A,owner:x,owners:N,ownerModels:ve,native:_e,models:y,runs:[ae],proof:Ae,retained:[{source:x,target:A,from:0,to:H.flat.text.length,targetFrom:je}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:a("none")}catch(d){if(d!==f)throw d;return a("fallback","work-limit")}}function ol({describe:e,parentOf:t,...n}){let o=new WeakMap,r=new WeakMap,c=n.budget||zt(2e4*32),l=s=>{if(!s)return null;if(o.has(s))return o.get(s);o.set(s,{status:"planning",parent:s,records:[]});let i=e(s),a=i?ka({...n,...i,parent:s,budget:c}):{status:"none",reason:null,parent:s,records:[]};if(o.set(s,a),a.status==="ready")for(let p of a.records)r.set(p.owner,[p]);return a};return{get:l,forOwner(s){return l(t(s))?.status==="ready"&&r.get(s)||null}}}function Ta(e,t){if(e.side!==0)return null;let n=e.native[0].model,o=e.ownerModels[0],r=e.native[1].from!==0,c=(O,T)=>r?[...O.nodes,...T.nodes]:[...T.nodes,...O.nodes],l=e.ownerModels.reduce((O,T)=>O+T.flat.text.length,0)+n.flat.text.length+e.native[2].model.flat.text.length;if(l*8>t.remaining)return null;t.remaining-=l*8;let s={base:c(o,n),local:e.ownerModels[1].nodes,remote:c(e.ownerModels[2],e.native[2].model)},i=nn(s.base),a=e.ownerModels[1].flat,p=nn(s.remote),f=r?o.flat.text.length:0,u=r?0:n.flat.text.length,y=Vn({base:i,side:a,retained:e.retained.map(O=>({from:u+O.from,to:u+O.to,target:O.targetFrom})),transfers:e.runs.map(O=>({from:f+O.from,to:f+O.to,target:O.targetFrom,destination:e.owner})),budget:t});if(y.status!=="ready"||y.covers(0,i.text.length)!==!0)return null;let b=e.ownerModels[2].flat,S=e.native[2].model.flat,g=[];for(let[O,T,k,v]of[[o.flat,b,u,r?0:S.text.length],[n.flat,S,f,r?b.text.length:0]]){let I=hs(O,O,T).remoteMap.bTo,M=-1;for(let P=0;P<O.text.length;P++){if(I[P]<0){M=-1;continue}let D=g.at(-1);M>=0&&D.to===k+P&&D.target+D.to-D.from===v+I[P]?D.to++:(g.push({from:k+P,to:k+P+1,target:v+I[P]}),M=P)}}let d=Vn({base:i,side:p,retained:g,transfers:[],budget:t});if(d.status!=="ready")return null;let w=hs(i,a,p,{},{local:y,remote:d});return w.localEdits.hunks.length?null:(w.localMap=y,w.remoteMap=d,{nodes:s,prepared:w})}function rl({L:e,R:t,twinIn:n,unitsOf:o,view:r,parentOf:c,ignored:l,remoteWins:s,eligible:i,build:a,out:p,policy:f,provenance:u,textMappers:y,segments:b,conflicts:S,conflict:g,decisions:d}){let w=zt(2e4*32),O=W=>{let B=0;for(let x=W;x;x=c(x))if(++B>64||x.nodeType===1&&(l(x)||s(x)))return!1;return!0},T=ol({parentOf:c,eligible:i,ignored:l,remoteWins:s,budget:w,describe(W){let B=n(e,W),x=n(t,W);return!B||!x||!O(W)||!O(B)||!O(x)?null:{base:o(W),views:[{A:e,V:r(e,B,W,!1)},{A:t,V:r(t,x,W,!1)}]}}}),k=new WeakSet,v=new WeakMap,I=new WeakSet,M=[];function P(W){if(!W||k.has(W))return;k.add(W);let B=T.get(W);if(B?.status==="ready")for(let x of B.records){if((W.tagName==="TEMPLATE"&&W.content?W.content:W).childNodes.length!==x.native[0].model.nodes.length+1||!x.owners.every(O))continue;let X=Ta(x,w);if(!X)continue;let H={record:x,payload:X,state:"planned",output:null,result:null};v.set(x.owner,H),I.add(x.source),I.add(x.native[2].unit),M.push(H)}}function D(W,B){let x=v.get(W);if(!x)return!1;if(!x.result){if(x.result=Mr({...x.payload.nodes,prepared:x.payload.prepared,out:p,policy:f,provenance:u,textMappers:y,conflicts:S,conflict:g,decisions:d,node:B}),x.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");b.push(...x.result.segments),x.decision={kind:"text",node:B,source:"local"},d.push(x.decision)}return x.decision.node=B,B.replaceChildren(...x.result.nodes),x.output=B,x.state="built",!0}function $(W){if(!M.length)return;let B=new WeakSet,x=new WeakMap,A=new WeakMap,X=new WeakMap,H=Ae=>Ae.tagName==="TEMPLATE"&&Ae.content?Ae.content:Ae,q=(Ae,_e)=>{if(!Ae)return;if(Array.isArray(Ae)){for(let N of Ae)q(N,_e);return}let ve=X.get(Ae);ve||X.set(Ae,ve=[]),ve.push(_e)},Ee=(Ae,_e=null,ve=!1)=>{B.add(Ae),x.set(Ae,_e);let N=u.get(Ae),J=ve||!!(N&&s(N.remote||N.base));if(A.set(Ae,J),N)for(let le of[N.base,N.local,N.remote])q(le,Ae);if(!(N?.pinned||N?.unchanged))for(let le of H(Ae).childNodes)Ee(le,Ae,J)},Me=Ae=>(X.get(Ae)||[]).find(_e=>_e.nodeType===1&&!A.get(_e)&&!u.get(_e)?.pinned&&!u.get(_e)?.unchanged),je=(Ae,_e)=>{for(let ve of X.get(Ae)||[]){let N=ve;for(;N&&x.get(N)!==_e;)N=x.get(N);if(N)return N}return null},ae=(Ae,_e,ve)=>{let N=H(_e);for(let J=ve.nextSibling;J;J=J.nextSibling){let le=je(J,_e);if(le){N.insertBefore(Ae,le);return}}for(let J=ve.previousSibling;J;J=J.previousSibling){let le=je(J,_e);if(le){N.insertBefore(Ae,le.nextSibling);return}}N.appendChild(Ae)};Ee(W);for(let Ae of M){let{record:_e}=Ae,ve=Me(_e.owner)||Me(_e.owners[1])||Me(_e.owners[2]);if(ve)(!Ae.result||Ae.output!==ve||Ae.result.nodes.some(N=>!B.has(N)||x.get(N)!==ve)||ve.textContent!==Ae.result.text)&&(D(_e.owner,ve),Ee(ve,x.get(ve),A.get(ve)));else{let N=_e.parent,J=_e.owner,le=null;for(;N&&!le;)le=Me(N),le||(J=N,N=c(N));if(!le)throw new Error("A cross-parent payload has no allowed surviving parent");ve=Ae.output||a(_e.owner,_e.owners[1],_e.owners[2],!1),Ae.result||D(_e.owner,ve),ae(ve,le,J),Ee(ve,le,A.get(le))}Ae.state="attached"}}return{ensureParent:P,ensureOwner(W){P(c(W))},consumes(W){return I.has(W)},render:D,drain:$}}var En=/\S/,sl=/[\p{L}\p{N}]/u;function po(e,t,n,o){if(e?.nodeType!==1||!t(e))return!1;for(let r=e.firstChild;r;r=r.nextSibling)if(o(n,1),r.nodeType!==3)return!1;return!!e.firstChild}function Ts(e,t,n){for(let o=e.parentNode;o;o=o.parentNode)if(n(t,1),o.nodeType===11)return!1;return!0}function il(e,t,n,o,r){let c=n(e,o),l=n(t,o),s=null,i=null,a=null,p=null;r(o,c.length+l.length);for(let f of c)sl.test(f.raw)&&(s||=f,i=f);for(let f of l)sl.test(f.raw)&&(a||=f,p=f);return!!(s&&a&&(s.raw===a.raw||i.raw===p.raw))}function Aa({base:e,V:t,A:n,source:o,original:r,current:c,edited:l,destination:s,at:i,ownLength:a,eligible:p,model:f,tokensOf:u,budget:y,charge:b}){let S=r.flat.text,g=c.flat.text,d=l.flat.text,w=s.flat.text;if(b(y,S.length+g.length+w.length),S.startsWith(g)||S.endsWith(g))return!1;let O=En.test(w.slice(0,i)),T=En.test(w.slice(i+a));if(O===T)return!1;let k=O?0:i+a,v=O?i:w.length;for(;k<v&&!En.test(w[k]);)k++;for(;v>k&&!En.test(w[v-1]);)v--;let I=w.slice(k,v);if(Rn(I,w,u(s,y),y,b,!0)!==k)return!1;let M=Rn(I,S,u(r,y),y,b,!0);if(M<0)return!1;let P=M+I.length,D=!En.test(S.slice(0,M)),$=!En.test(S.slice(P));if(D===$||Rn(I,g,u(c,y),y,b,!1)>=0)return!1;let W=D?S.slice(P):S.slice(0,M),B=D?d.length-W.length:0;if(b(y,S.length+d.length),B<0||!En.test(W)||Rn(W,d,u(l,y),y,b,!0)!==B||!En.test(D?d.slice(0,B):d.slice(W.length)))return!1;for(let x of e){if(b(y,1),x===o||!po(x,p,y,b))continue;let A=f(x,null,y);if(Rn(I,A.flat.text,u(A,y),y,b,!1)>=0)return!1}for(let x of t.units){if(b(y,1),x===c.unit||x===s.unit||!po(x,p,y,b))continue;let A=f(x,n,y);if(Rn(I,A.flat.text,u(A,y),y,b,!1)>=0)return!1}return!0}function ll({base:e,views:t,side:n,attempt:o,eligible:r,blocked:c,baseId:l,model:s,tokensOf:i,charge:a,exhausted:p,limit:f}){if(f<=0)return null;let u=zt(f),{V:y,A:b,idOf:S}=t[n],g=t[1-n],[d,w,O,T]=o,k=null;try{for(let v=d;v<=w;v++){a(u,1);let I=e[v];if(I.parentNode?.nodeType!==1||c.has(I)||b.identical.has(I)||g.A.identical.has(I)||!po(I,r,u,a)||l(I))continue;let M=y.twin(I),P=g.V.twin(I);if(!M||!P||!y.here(M)||!g.V.here(P)||b.map.get(I)!==M||b.reverse.get(M)!==I||g.A.map.get(I)!==P||g.A.reverse.get(P)!==I||S(M)||g.idOf(P)||M.tagName!==I.tagName||P.tagName!==I.tagName||!po(M,r,u,a)||!po(P,r,u,a)||!Ts(I,u,a)||!Ts(M,u,a)||!Ts(P,u,a))continue;let D=s(I,null,u),$=s(M,b,u),W=s(P,g.A,u),B=D.flat.text,x=$.flat.text,A=W.flat.text;if(a(u,B.length+x.length+A.length),!En.test(B)||!En.test(x)||!En.test(A)||B===x||B===A||x===A||!il(D,$,i,u,a)||!il(D,W,i,u,a))continue;let X=null,H=!1;for(let Me=O;Me<=T;Me++){a(u,1);let je=y.units[Me],ae=y.baseOf(je);if(!ae||ae===I||c.has(ae)||ae.parentNode!==I.parentNode||je.parentNode!==M.parentNode||ae.tagName!==I.tagName||je.tagName!==I.tagName||b.map.get(ae)!==je||b.reverse.get(je)!==ae||l(ae)!==S(je)||!po(ae,r,u,a)||!po(je,r,u,a))continue;let Ae=s(ae,null,u),_e=s(je,b,u),ve=Ae.flat.text,N=_e.flat.text;if(a(u,ve.length),!En.test(ve)||N.length<=ve.length)continue;let J=i(_e,u),le=Rn(ve,N,J,u,a,!0);if(!(le<0||Rn(B,N,J,u,a,!0,le,le+ve.length)<0&&!Aa({base:e,V:y,A:b,source:I,original:D,current:$,edited:W,destination:_e,at:le,ownLength:ve.length,eligible:r,model:s,tokensOf:i,budget:u,charge:a}))){if(X){H=!0;break}X=je}}if(!X||H)continue;let q=n===0?M:P,Ee=n===0?P:M;(k||=[]).push({source:I,local:q,remote:Ee,models:[D,n===0?$:W,n===0?W:$]})}}catch(v){if(v!==p)throw v}return k}var qn=/\S/,bn=/\s/,Sa=/[\s\u001e]/g,As=/[^\s\p{P}\u001e\ufffc]/u;function Na(e,t,n,o,r,c,l){let s=0;for(let i of e)l(c,1),i.nodeType===1&&!o.baseOf(i)&&s++;if(s<2)return!1;for(let i of e){if(i.nodeType!==1||o.baseOf(i))continue;let a=r.get(i).flat;if(a.atoms.length||a.pins?.length)continue;l(c,a.text.length*2+t.length+n.length);let p=new Uint8Array(a.text.length);for(let f of n)f.target===i&&p.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f of t)f.target===i&&p.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f=0;f<a.text.length;f++)if(!p[f]&&qn.test(a.text[f]))return!0}return!1}function va(e,t,n){let{source:o,models:r,retained:c,runs:l}=e,s=r.get(o).flat.text;n(t,s.length*2+c.length+l.length);let i=new Uint8Array(s.length);for(let a of c)a.source===o&&(n(t,a.to-a.from),i.fill(1,a.from,a.to));for(let a of l)n(t,a.to-a.from),i.fill(1,a.from,a.to);for(let a=0;a<s.length;a++)if(!i[a]&&qn.test(s[a]))return!1;return!0}function Oa(e,t,n,o,r,c,l,s,i,a){let p=c.get(e),f=c.get(t),u=p.flat.text,y=l.get(e);i(a,u.length*2+n.length);let b=u.length,S=0;for(let w=0;w<u.length;w++)!bn.test(u[w])&&!y[w]&&(b=Math.min(b,w),S=w+1);if(b>=S)return null;for(let w=b;w<S;w++)if(!bn.test(u[w])&&y[w])return null;let g=-1;for(let w of n)if(w.target===t&&w.from<=b&&w.to>b){g=w.targetFrom+b-w.from;break}if(g<0)return null;let d=u.slice(b,S);if(i(a,d.length*(n.length+2)),f.flat.text.slice(g,g+d.length)!==d)return null;for(let w=b;w<S;w++){if(bn.test(u[w]))continue;let O=!1;for(let T of n)if(T.target===t&&T.from<=w&&T.to>w&&T.targetFrom+w-T.from===g+w-b){O=!0;break}if(!O)return null}if(p.flat.atoms.length||f.flat.atoms.length){i(a,p.flat.atoms.length+f.flat.atoms.length);let w=0,O=f.flat.atoms;for(;w<O.length&&O[w].i<g;)w++;for(let T of p.flat.atoms){if(T.i<b||T.i>=S)continue;let k=O[w++];if(!k||k.i!==g+T.i-b||f.alignment?.reverse.get(k.el)!==T.el)return null}if(w<O.length&&O[w].i<g+S-b)return null}for(let[w,O,T]of[[o,e,b],[r,t,g]]){let k=!1;for(let v of w){let I=c.get(v),M=l.get(v),P=s(I,a);for(let D=0;D<P.length;D++){let $=P[D].from,W=$+d.length;if(i(a,d.length*2+1),I.flat.text.slice($,W)!==d)continue;let B=D;for(;B<P.length&&P[B].to<W;)i(a,1),B++;if(B===P.length||P[B].to!==W)continue;let x=!0;for(let A=$;A<W;A++)if(!bn.test(I.flat.text[A])&&M[A]){x=!1;break}if(x){if(k||v!==O||$!==T)return null;k=!0}}}if(!k)return null}return d}function Ma(e,t,n,o,r,c,l,s){if(l(s,r.length+c.length+(o.length+1)*n.length*2),!n)return!1;let i=o.indexOf(n);return i<0||o.lastIndexOf(n)!==i||!c.some(a=>a.from===i)||!c.some(a=>a.to===i+n.length)?!1:r.some(a=>a.source===e&&a.target===t&&a.from===0&&a.to===n.length&&a.targetFrom===i)}function cl({base:e,views:t,eligible:n,baseId:o,ignored:r,remoteWins:c,atomKey:l,limit:s=2e4*8}){if(s<=0)return null;let i=Symbol(),a=(T,k)=>{if(k>T.remaining)throw i;T.remaining-=k},p=[new Map,new Map];for(let T=0;T<2;T++)for(let k=0;k<t[T].V.units.length;k++)p[T].set(t[T].V.units[k],k);let f=new Int32Array(e.length),u=new Int32Array(e.length),y=T=>t.every(({V:k},v)=>{let I=k.twin(T);return I&&p[v].has(I)}),b=-1;for(let T=0;T<e.length;T++)f[T]=b,y(e[T])&&(b=T);b=e.length;for(let T=e.length-1;T>=0;T--)u[T]=b,y(e[T])&&(b=T);let S=new Map,g=(T,k)=>{if(a(k,1),S.has(T))return S.get(T);let v=T.firstChild,I=1;for(;v;){if(a(k,I*8+8),v.nodeType===3&&a(k,v.data.length*8),v.nodeType===1&&An.has(v.tagName)&&!r(v)&&!c(v)&&v.firstChild){v=v.firstChild,I++;continue}for(;v&&v!==T&&!v.nextSibling;)v=v.parentNode,I--;v=!v||v===T?null:v.nextSibling}let M=nn(Array.from(T.childNodes),{ignored:r,remoteWins:c});return S.set(T,M),M},d=(T,k,v,I,M,P)=>{for(let D of T.atoms){a(P,1);let $=k.atomAt.get(D.i+v);if(!$)return!1;let W=I?.reverse.get(D.el)||l(D.el),B=M?.reverse.get($.el)||l($.el);if(W!==B)return!1}return!0},w=(T,k,v,I,M)=>{let P=T.text.length<=k.text.length?T:k,D=P===T?k:T;if(a(M,P.text.length+D.text.length),!P.text||!qn.test(P.text.replaceAll(_n,"")))return!1;let $;if(P.text===D.text)$=0;else{let W=D.text.length-P.text.length;if(a(M,(W+1)*P.text.length*2),D.text.startsWith(P.text))$=0;else if(D.text.endsWith(P.text))$=W;else return!1;if(D.text.indexOf(P.text)!==$||D.text.lastIndexOf(P.text)!==$)return!1;a(M,D.text.length*2);let B=0,x=$===0,A=!1;for(let X of an(D.text,Tn(D.text)))B+=X.len,B===$&&(x=!0),B===$+P.text.length&&(A=!0);if(!x||!A)return!1}return P===T?d(P,D,$,v,I,M):d(P,D,$,I,v,M)},O=null;for(let T=0;T<2;T++){let{V:k,A:v,idOf:I}=t[T],M=t[1-T];if(!k.asBase)for(let P=0;P<e.length;P++){let D=e[P];if(k.twin(D)||!n(D))continue;let $=M.V.twin(D);if(!$||!p[1-T].has($)||!n($))continue;let W={remaining:s};try{let B=f[P],x=u[P],A=0;for(let Ee=B+1;Ee<x;Ee++)a(W,1),!k.twin(e[Ee])&&M.V.twin(e[Ee])&&n(e[Ee])&&A++;if(A!==1||g(D,W).text===g($,W).text)continue;let X=B<0?-1:p[T].get(k.twin(e[B])),H=x===e.length?k.units.length:p[T].get(k.twin(e[x]));if(X===void 0||H===void 0||X>=H)continue;let q=null;for(let Ee=X+1;Ee<H;Ee++){a(W,1);let Me=k.units[Ee];if(k.baseOf(Me)||!n(Me)||Me.tagName!==D.tagName||Me.namespaceURI!==D.namespaceURI)continue;let je=o(D),ae=M.idOf($),Ae=I(Me);if(!(je&&ae&&je!==ae||je&&Ae&&je!==Ae||ae&&Ae&&ae!==Ae)&&w(g($,W),g(Me,W),M.A,v,W)){if(q){q=null;break}q=Me}}if(!q)continue;O||(O=[new Map,new Map]),O[T].set(D,q)}catch(B){if(B!==i)throw B}}}return O?t.map(({V:T},k)=>{let v=O[k];if(!v.size)return T;let I=new Map;for(let[M,P]of v)I.set(P,M);return{...T,twin:M=>v.get(M)||T.twin(M),baseOf:M=>I.get(M)||T.baseOf(M)}}):null}function al({onUncertainSource:e,onUncertainOwner:t,base:n,views:o,eligible:r,ignored:c,remoteWins:l,baseId:s,atomKey:i,limit:a=2e4*32}){if(a<=0)return null;let p=new Set(n),f=new Map(n.map((B,x)=>[B,x])),u=new Map,y=[],b=null,S=null,g=null,d=new Set;for(let B of n)for(let{V:x}of o){let A=x.twin(B);A&&!x.asBase&&!x.here(A)&&d.add(B)}let w=new Set,O=Symbol(),T=(B,x)=>{if(x>B.remaining)throw O;B.remaining-=x},k=(B,x,A)=>{T(A,1);let X=u.get(B);if(X)return X;if(B.nodeType===1){let Ee=B.firstChild,Me=1;for(;Ee;){if(T(A,Me*8+8),Ee.nodeType===3&&T(A,Ee.data.length*8),Ee.nodeType===1&&An.has(Ee.tagName)&&!c(Ee)&&!l(Ee)&&Ee.firstChild){Ee=Ee.firstChild,Me++;continue}for(;Ee&&Ee!==B&&!Ee.nextSibling;)Ee=Ee.parentNode,Me--;Ee=!Ee||Ee===B?null:Ee.nextSibling}}else T(A,B.value.length*8+B.nodes.length);let H=B.nodeType===1?Array.from(B.childNodes):B.nodes,q=H.length===1&&H[0].nodeType===3?{text:H[0].data,nodes:[{node:H[0],s:0,e:H[0].data.length}],atoms:[]}:nn(H,{ignored:c,remoteWins:l});return X={unit:B,flat:q,alignment:x,tokens:null},u.set(B,X),X},v=(B,x)=>{if(B.tokens)return B.tokens;T(x,B.flat.text.length*8);let{unit:A,flat:X,alignment:H}=B,q=[],Ee=Tn(X.text),Me=0,je=ae=>{for(let Ae of an(X.text.slice(Me,ae),Ee))Ae.from=Me,Ae.to=Me+Ae.len,Ae.unit=A,q.push(Ae),Me+=Ae.len};for(let ae of X.atoms){je(ae.i);let Ae=l(ae.el)&&ae.el.nodeType===1?"w"+ae.el.tagName+"#"+(ae.el.id||""):i(H?.reverse.get(ae.el)||ae.el);q.push({k:Ae,raw:_n,len:1,from:Me,to:Me+1,unit:A,atom:!0}),Me++}return je(X.text.length),B.tokens=q,q},I=(B,x,A,X,H)=>{if(!B.flat.atoms.length&&!x.flat.atoms.length)return!0;let q=v(B,H),Ee=v(x,H);T(H,q.length+Ee.length);let Me=0;for(let je of Ee){if(!je.atom||je.from<A||je.from>=A+X)continue;for(;Me<q.length&&!q[Me].atom;)Me++;let ae=q[Me++];if(!ae||ae.from!==je.from-A||ae.k!==je.k)return!1}for(;Me<q.length;)if(q[Me++].atom)return!1;return!0},M=(B,x,A)=>{let X=B.length+x.length+4;if(X*8>A.remaining)return null;A.remaining-=X*8;let H=Math.floor(A.remaining/8),q=Math.min(B.length+x.length,4e3,Math.floor((Math.sqrt(X*X+H)-X)/2)),Ee=4*(q+1)*(X+q+1);if(q<1||Ee>A.remaining)return null;A.remaining-=Ee;let Me=Gn(B,x,q),je=[],ae=0,Ae=0;for(let _e of Me.hunks){for(;ae<_e.bs;)B[ae].raw===x[Ae].raw&&je.push([B[ae],x[Ae]]),ae++,Ae++;ae=_e.be,Ae+=_e.toks.length}for(;ae<B.length&&Ae<x.length;)B[ae].raw===x[Ae].raw&&je.push([B[ae],x[Ae]]),ae++,Ae++;return je},P=(B,x,A,X,H,q,Ee)=>{if(H<=X)return;let Me=B[B.length-1];if(Me&&Me.source===x&&Me.target===A&&Me.to<=X&&Me.targetFrom-Me.from===q-X){T(Ee,(X-Me.to)*3);let je=u.get(x).flat.text,ae=u.get(A).flat.text,Ae=!0;for(let _e=Me.to;_e<X;_e++)if(!bn.test(je[_e])||je[_e]!==ae[q+_e-X]){Ae=!1;break}if(Ae){Me.to=H;return}}B.push({source:x,target:A,from:X,to:H,targetFrom:q})},D=B=>B.replace(Sa,"");for(let B=0;B<o.length;B++){let{V:x,A,idOf:X}=o[B];if(x.asBase)continue;let H=new Map(x.units.map((N,J)=>[N,J])),q=N=>{let J=x.twin(N);return J&&H.has(J)?J:null},Ee=(N,J)=>{let le=new Int32Array(N.length),oe=new Int32Array(N.length),Re=-1;for(let Be=0;Be<N.length;Be++)le[Be]=Re,J(N[Be])&&(Re=Be);Re=N.length;for(let Be=N.length-1;Be>=0;Be--)oe[Be]=Re,J(N[Be])&&(Re=Be);return{prev:le,next:oe}},Me=Ee(n,N=>(N.nodeType===1||N.kind==="text"&&qn.test(N.value))&&q(N)),je=Ee(x.units,N=>(N.nodeType===1||N.kind==="text"&&qn.test(N.value))&&p.has(x.baseOf(N))),ae=new Map,Ae=(N,J,le,oe)=>{if(N>J||le>oe)return;let Re=`${N}:${J}:${le}:${oe}`;ae.set(Re,[N,J,le,oe])};for(let N=0;N<x.units.length;N++){let J=x.units[N];if(x.baseOf(J)||!r(J))continue;let le=je.prev[N],oe=je.next[N],Re=le<0?0:f.get(x.baseOf(x.units[le])),Be=oe===x.units.length?n.length-1:f.get(x.baseOf(x.units[oe]));Ae(Re,Be,Math.max(0,le),Math.min(x.units.length-1,oe))}for(let N=0;N<n.length;N++){let J=n[N];if(d.has(J)||!r(J))continue;if(!x.twin(J)){let nt=Me.prev[N],Je=Me.next[N],ht=nt<0?0:H.get(q(n[nt])),Ge=Je===n.length?x.units.length-1:H.get(q(n[Je]));Ae(Math.max(0,nt),Math.min(n.length-1,Je),ht,Ge)}let le=q(J);if(!le||A.identical.has(J)||!r(le))continue;let oe=N+1;for(;oe<n.length&&n[oe].kind==="text"&&!n[oe].value.trim();)oe++;if(oe>=n.length||!r(n[oe]))continue;let Re=q(n[oe]);if(!Re||A.identical.has(n[oe])||!r(Re))continue;let Be=H.get(le),Se=H.get(Re);Be<Se&&Ae(N,oe,Be,Se)}let _e=Array.from(ae.values()),ve=new Set;if(_e.length>1){let N=zt(a);try{T(N,_e.length*4);let J=_e.slice().sort((Re,Be)=>(T(N,1),Re[0]-Be[0]||Re[2]-Be[2])),le=[],oe=null;for(let Re of J)T(N,1),oe&&Re[0]<=oe[1]&&Re[2]<=oe[3]&&Re[3]>=oe[2]?(oe[1]=Math.max(oe[1],Re[1]),oe[2]=Math.min(oe[2],Re[2]),oe[3]=Math.max(oe[3],Re[3]),oe[4].push(Re)):(oe?.[4].length>1&&le.push(oe),oe=[Re[0],Re[1],Re[2],Re[3],[Re]]);oe?.[4].length>1&&le.push(oe),_e=le.concat(_e)}catch(J){if(J!==O)throw J}}for(let N of _e){if(ve.has(N))continue;let[J,le,oe,Re,Be]=N,Se=zt(a),nt=[],Je=new Set,ht=!1;try{T(Se,(le-J+Re-oe+2)*4);let Ge=n.slice(J,le+1).filter(j=>!A.identical.has(j)&&r(j)&&!d.has(j)),st=x.units.slice(oe,Re+1).filter(j=>r(j)&&(!x.baseOf(j)||p.has(x.baseOf(j)))&&!A.identical.has(x.baseOf(j))&&!d.has(x.baseOf(j))),Mt=new Set(st),It=!1,yt="",Nt="",Ct=0;for(let j of Ge){let ue=k(j,null,Se);yt+=ue.flat.text,Ct+=ue.flat.text.length}for(let j of st){let ue=k(j,A,Se);Nt+=ue.flat.text,Ct+=ue.flat.text.length}T(Se,Ct);let _t=D(yt),fn=D(Nt),Et=_t===fn;if(ht=Et,Be&&!Et)continue;let Gt=Et?null:new Map;if(Gt)for(let j of Ge.concat(st)){let ue=u.get(j).flat.text.length;T(Se,ue*16),Gt.set(j,new Uint8Array(ue))}let wn=j=>{let ue=[];for(let be of j){let ie=u.get(be);ie.flat.atoms.length?ue.push(...v(ie,Se)):ue.push({unit:be,raw:ie.flat.text,from:0})}return ue},Bt=[];for(let j of Et?[]:Ge){let ue=q(j);if(!Mt.has(ue))continue;let be=k(j,null,Se),ie=k(ue,A,Se);T(Se,be.flat.text.length+ie.flat.text.length);let Ne=be.flat.text&&ie.flat.text.startsWith(be.flat.text)?0:be.flat.text&&ie.flat.text.endsWith(be.flat.text)?ie.flat.text.length-be.flat.text.length:-1;if(Ne>=0&&I(be,ie,Ne,be.flat.text.length,Se)){Gt.get(j).fill(1),Gt.get(ue).fill(1,Ne,Ne+be.flat.text.length),P(Bt,j,ue,0,be.flat.text.length,Ne,Se);continue}let U=M(v(be,Se),v(ie,Se),Se);if(!U){It=!0;break}for(let[Y,he]of U)Gt.get(j).fill(1,Y.from,Y.to),Gt.get(ue).fill(1,he.from,he.to),P(Bt,j,ue,Y.from,Y.to,he.from,Se)}if(It)continue;let ln=null,Yt=null;if(!Et)for(let j of Ge){let ue=q(j),be=u.get(j);if(!ue||be.flat.atoms.length||!Mt.has(ue))continue;let ie=be.flat.text,Ne=Gt.get(j);T(Se,ie.length*3+st.length);let U=-1,Y=-1,he=!1;for(let Le=0;Le<ie.length;Le++)bn.test(ie[Le])||(Ne[Le]?he=!0:(U<0&&(U=Le),Y=Le+1));if(!he||U<0)continue;let ge=!0;for(let Le=U;Le<Y;Le++)if(Ne[Le]&&!bn.test(ie[Le])){ge=!1;break}if(!ge)continue;let de=D(ie.slice(U,Y)),ee=null,te=!1;for(let Le of st){if(x.baseOf(Le))continue;let ke=u.get(Le);if(!ke.flat.atoms.length&&(T(Se,ke.flat.text.length),D(ke.flat.text)===de)){if(ee){te=!0;break}ee=Le}}if(te){(Yt||=new Set).add(j);continue}if(!ee||Yt?.has(j))continue;let K=!1;for(let Le of Ge){if(Le===j||!Mt.has(q(Le)))continue;let ke=u.get(Le);if(ke.flat.atoms.length)continue;let $e=Gt.get(Le);T(Se,ke.flat.text.length*3);let Xe="",Qe=!1;for(let Ut=0;Ut<ke.flat.text.length;Ut++)bn.test(ke.flat.text[Ut])||($e[Ut]?Qe=!0:Xe+=ke.flat.text[Ut]);Qe&&Xe===de&&(Yt||=new Set,Yt.add(j),Yt.add(Le),K=!0)}if(K)continue;let ne=u.get(ee).flat.text;T(Se,Y-U+ne.length);let xe=U,Ie=0;for(;xe<Y&&Ie<ne.length;){for(;xe<Y&&bn.test(ie[xe]);)xe++;for(;Ie<ne.length&&bn.test(ne[Ie]);)Ie++;if(xe>=Y||Ie>=ne.length)break;P(ln||=[],j,ee,xe,xe+1,Ie,Se),xe++,Ie++}Ne.fill(1,U,Y),Gt.get(ee).fill(1)}let un=j=>{let ue=[];for(let be of j){let ie=k(be,p.has(be)?null:A,Se),Ne=Gt.get(be);for(let U of v(ie,Se)){let Y=U.from;for(;Y<U.to;){for(;Y<U.to&&Ne[Y];)Y++;let he=Y;for(;Y<U.to&&!Ne[Y];)Y++;if(Y>he){let ge=ie.flat.text.slice(he,Y);qn.test(ge)&&ue.push({...U,raw:ge,len:Y-he,k:U.atom?U.k:ge,from:he,to:Y})}}}}return ue},z=Et?wn(Ge):un(Ge),h=Et?wn(st):un(st),E=Et?_t:z.map(j=>D(j.raw)).join(""),R=Et?fn:h.map(j=>D(j.raw)).join("");if((!E||!R)&&!ln)continue;let V=ln||[];if(E&&R&&E===R){let j=0,ue=0,be=0,ie=0;for(;j<z.length&&ue<h.length;){let Ne=z[j],U=h[ue];for(;be<Ne.raw.length&&bn.test(Ne.raw[be]);)be++;for(;ie<U.raw.length&&bn.test(U.raw[ie]);)ie++;if(be===Ne.raw.length){j++,be=0;continue}if(ie===U.raw.length){ue++,ie=0;continue}if((Ne.atom||U.atom)&&Ne.k!==U.k){It=!0;break}P(V,Ne.unit,U.unit,Ne.from+be,Ne.from+be+1,U.from+ie,Se),be++,ie++}}else if(E&&R){let j=M(z,h,Se);if(!j)continue;for(let[ue,be]of j)P(V,ue.unit,be.unit,ue.from,ue.to,be.from,Se)}if(It)continue;let Q=new Map;for(let j of V)if(!Yt?.has(j.source)){if(q(j.source)===j.target){Et&&Bt.push(j);continue}Q.has(j.source)||Q.set(j.source,[]),Q.get(j.source).push(j)}for(let[j,ue]of Q){let be=k(j,null,Se),ie=q(j),Ne=be.flat.text,U=[],Y=new Set,he=o[1-B],ge=he.V.twin(j),de=ge&&he.V.here(ge)?k(ge,he.A,Se):null,ee=(ke,$e)=>{let Xe=v(ke,Se),Qe=v($e,Se);return T(Se,ke.flat.text.length+$e.flat.text.length+Xe.length+Qe.length),ke.flat.text===$e.flat.text&&Xe.length===Qe.length&&Xe.every((Ut,Pt)=>Ut.k===Qe[Pt].k)},te=ie&&de&&de.flat.text!==Ne&&ee(k(ie,A,Se),de);for(let ke of new Set(ue.map($e=>$e.target))){if(j.nodeType!==1&&ke.nodeType!==1)continue;let $e=k(ke,A,Se),Xe=x.baseOf(ke);if(j.nodeType!==1&&Xe||(T(Se,Ne.length*2+$e.flat.text.length*3+Bt.length*2),ie&&D(Ne)===D($e.flat.text)&&k(ie,A,Se).flat.text.trim()))continue;if(!ie&&!Xe&&j.nodeType===1&&ke.nodeType===1){let G=s(j),se=X(ke);if(G&&se&&G!==se)continue}let Qe=$e.flat.text,Ut=Ne&&(Qe.startsWith(Ne)||Qe.endsWith(Ne)),Pt=!1;if(!ie&&de&&Xe&&de.flat.text!==Ne){let G=k(Xe,null,Se).flat.text,se=f.get(j)<f.get(Xe)?de.flat.text:G,me=f.get(j)<f.get(Xe)?G:de.flat.text;T(Se,se.length+me.length+Qe.length),Pt=!!se&&!!me&&se.length+me.length<=Qe.length&&Qe.startsWith(se)&&Qe.endsWith(me)&&!Qe.slice(se.length,Qe.length-me.length).trim()}let C=!be.flat.atoms.length&&!de?.flat.atoms.length&&!$e.flat.atoms.length&&(te&&Ut||Pt);if(ie&&Xe){let G=k(ie,A,Se).flat.text,se=Ne.startsWith(G)||Ne.endsWith(G),me=k(Xe,null,Se).flat.text,ye=$e.flat.text,ce=ye.startsWith(me)||ye.endsWith(me),re=!o[1-B].V.twin(Xe)&&!Bt.some(Oe=>Oe.source===Xe&&qn.test(me.slice(Oe.from,Oe.to)));if(!Et&&(!se&&!C||!ce&&!re)){let Oe=Oa(j,ke,ue,Ge,st,u,Gt,v,T,Se);if(!Oe)continue;let Pe=A.weak?.has(j)&&!A.identityPaired?.has(j)&&Ne.trim()===Oe;if(!se&&!C&&!Pe)continue;let We=A.weak?.has(Xe)&&!A.identityPaired?.has(Xe)&&Qe.trim()===Oe&&!u.get(Xe).flat.atoms.length&&!Bt.some(Fe=>Fe.source===Xe&&qn.test(me.slice(Fe.from,Fe.to)));if(!ce&&!re&&!We&&!Ma(Xe,ke,me,Qe,Bt,v($e,Se),T,Se))continue;Pe&&Y.add(ke)}}C&&Y.add(ke),T(Se,ue.length),U.push(...ue.filter(G=>G.target===ke))}if(!U.length)continue;let K=new Uint8Array(Ne.length);T(Se,Ne.length*4+Bt.length);for(let ke of U)K.fill(1,ke.from,ke.to);let ne=[];for(let ke=0;ke<Ne.length;ke++)bn.test(Ne[ke])||ne.push(ke);if(!ne.length)continue;let xe=new Set(U.map(ke=>ke.target));if(!Et&&ie&&xe.size>1&&Na(xe,V,Bt,x,u,Se,T)){if(g||=new Map,g.set(j,(g.get(j)||0)|1<<B),e){let ke=us({source:j,side:B,views:o,eligible:r,blocked:d,baseId:s,model:k,tokensOf:v,budget:Se,charge:T});if(ke){T(Se,ke.to-ke.from);let $e=!0;for(let Xe=ke.from;Xe<ke.to;Xe++)if(qn.test(Ne[Xe])&&!K[Xe]){$e=!1;break}$e&&(b||=[]).push(ke)}}continue}let Ie=ne.filter(ke=>As.test(Ne[ke]));if(!U.some(ke=>As.test(Ne.slice(ke.from,ke.to)))&&!ne.every(ke=>K[ke]))continue;if(!ie&&!Array.from(xe).some(ke=>Y.has(ke))&&!ne.every(ke=>K[ke])&&!(Ie.length&&K[Ie[0]]&&K[Ie[Ie.length-1]]&&xe.size===1)){let ke=null,$e=0,Xe=0,Qe=null,Ut=null;if(!ie&&de&&j.nodeType===1&&!be.flat.atoms.length){let Pt=v(be,Se).filter(C=>As.test(C.raw));T(Se,st.length+Ne.length);for(let C of st){let G=x.baseOf(C);if(!G||G===j||G.nodeType!==1||C.nodeType!==1||G.tagName!==j.tagName||C.tagName!==G.tagName)continue;let se=f.get(j),me=f.get(G),ye=!0;for(let tt=Math.min(se,me)+1;tt<Math.max(se,me);tt++){let Ft=n[tt];if(T(Se,Ft.nodeType===1?1:Ft.value.length+1),Ft.nodeType===1||Ft.value.trim()){ye=!1;break}}if(!ye)continue;let ce=k(G,null,Se),re=k(C,A,Se);if(ce.flat.atoms.length||re.flat.atoms.length)continue;let Oe=ce.flat.text,Pe=re.flat.text;if(T(Se,Oe.length+Pe.length+Ne.length),!Oe||!Pt.length)continue;let We=0,Fe=Pe.length;if(se<me&&Pe.endsWith(Oe))Fe-=Oe.length;else if(se>me&&Pe.startsWith(Oe))We=Oe.length;else continue;for(;We<Fe&&bn.test(Pe[We]);)We++;for(;Fe>We&&bn.test(Pe[Fe-1]);)Fe--;let pt=Pe.slice(We,Fe);if(!(!pt||!(pt.startsWith(Pt[0].raw)||pt.endsWith(Pt[Pt.length-1].raw)))){if(ke){ke=null;break}ke=C,$e=We,Xe=Fe,Qe=Pt[0],Ut=Pt[Pt.length-1]}}}if(T(Se,U.length),!ke||!xe.has(ke)||!U.some(Pt=>Pt.target===ke&&(Pt.from<=Qe.from&&Pt.to>=Qe.to&&Pt.targetFrom+Qe.from-Pt.from===$e||Pt.from<=Ut.from&&Pt.to>=Ut.to&&Pt.targetFrom+Ut.to-Pt.from===Xe)))continue}if(ie&&!(ne.every(ke=>K[ke])&&(Et||Array.from(xe).some(ke=>Y.has(ke))))&&!Bt.some(ke=>ke.source===j&&qn.test(Ne.slice(ke.from,ke.to))))continue;let Le=!1;if(Et){T(Se,Bt.length+ne.length);for(let ke of Bt)ke.source===j&&(T(Se,ke.to-ke.from),K.fill(1,ke.from,ke.to));Le=!0;for(let ke of ne)if(!K[ke]){Le=!1;break}}for(let ke of xe){T(Se,U.length);let $e=U.filter(Qe=>Qe.target===ke);nt.push({side:B,source:j,target:ke,runs:$e,models:u,retained:Bt,conservedSource:Le}),j.nodeType===1&&Je.add(j),ke.nodeType===1&&Je.add(ke);let Xe=x.baseOf(ke);Xe?.nodeType===1&&Je.add(Xe)}}if(y.push(...nt),Be&&nt.length)for(let j of Be)ve.add(j);for(let j of Je)w.add(j)}catch(Ge){if(Ge!==O)throw Ge}finally{if(t&&!Be&&!ht){let Ge=ll({base:n,views:o,side:B,attempt:N,eligible:r,blocked:d,baseId:s,model:k,tokensOf:v,charge:T,exhausted:O,limit:a});Ge&&(S||=[]).push(...Ge)}if(e&&!Be&&!ht){let Ge=Ti({base:n,views:o,side:B,attempt:N,eligible:r,blocked:d,baseId:s,model:k,tokensOf:v,certificates:y,charge:T,exhausted:O,limit:a});Ge&&(b||=[]).push(...Ge)}}}}let $=y.length?new Map:null;for(let B of y){let x=$.get(B.source);x||$.set(B.source,x=[]),x.push(B)}let W=null;if($){let B=null;for(let[x,A]of $){let X=g?.get(x)||0;if(A.length<2&&!X)continue;let H=0;for(let q of A)q.conservedSource&&(H|=1<<q.side);for(let q of A){if(q.conservedSource)continue;let Ee=1<<q.side,Me=!0;if(H&Ee)Me=!1;else if(X&Ee){Me=!1;try{Me=va(q,B||=zt(a),T)}catch(je){if(je!==O)throw je}}Me||(W||=new Set).add(q)}}}if(W){let B=0;for(let x of y)W.has(x)||(y[B++]=x);y.length=B;for(let[x,A]of $){B=0;for(let X of A)W.has(X)||(A[B++]=X);A.length=B,B||$.delete(x)}w.clear();for(let x of y){let{source:A,target:X,side:H}=x;A.nodeType===1&&w.add(A),X.nodeType===1&&w.add(X);let q=o[H].V.baseOf(X);q?.nodeType===1&&w.add(q)}}if(b){let B=zt(a),x=!1;for(let A of b){let X=!1,H=$?.get(A.source);if(H&&!x)try{X=fs(A,H,B,T)}catch(q){if(q!==O)throw q;x=!0}X||e(A)}}if(S){let B=new Set,x=zt(a);try{for(let A of S){if(T(x,1),B.has(A.source))continue;B.add(A.source);let X=!1;for(let H of y)if(T(x,1),H.source===A.source||H.target===A.local||H.target===A.remote){X=!0;break}X||t(A)}}catch(A){if(A!==O)throw A}}for(let B of n)if(w.has(B))for(let{V:x}of o){let A=x.twin(B);A&&x.here(A)&&w.add(A)}return y.length?{blocks:w,certificates:y,certificatesBySource:$,models:u}:null}function fl({certificates:e,scopes:t,flats:n,keys:o,limit:r=2e4*32}){let c=Symbol(),l=zt(r),s=g=>{if(g>l.remaining)throw c;l.remaining-=g},i=t.map(g=>new Set(g)),a=new Map,p=new Map,f=(g,d)=>{let w=a.get(g);if(w||a.set(g,w=new Map),w.has(d))return w.get(d);s(g.text.length);let O=p.get(d);if(!O){s(d.nodes.length+d.atoms.length),O={nodes:new Map,atoms:new Map};for(let I of d.nodes)O.nodes.set(I.node,I);for(let I of d.atoms)O.atoms.set(I.el,I.i);p.set(d,O)}let{nodes:T,atoms:k}=O,v=new Int32Array(g.text.length).fill(-1);for(let I of g.nodes){let M=T.get(I.node);if(!(!M||I.e-I.s!==M.e-M.s)){s(I.e-I.s);for(let P=I.s;P<I.e;P++)v[P]=M.s+P-I.s}}for(let I of g.atoms){let M=k.get(I.el);M!==void 0&&(v[I.i]=M)}return w.set(d,v),v},u=(g,d,w,O,T)=>{let k=g[g.length-1];k&&k.to===d&&k.target+k.to-k.from===O&&k.kind===T?k.to=w:g.push({from:d,to:w,target:O,kind:T})},y=(g,d,w,O)=>{s((O-w)*4);let T=[],k=w,v=P=>{let D=g.text.slice(k,P);for(let $ of an(D,Tn(D)))$.from=k,$.to=k+$.len,T.push($),k+=$.len},I=0,M=g.atoms.length;for(;I<M;){s(1);let P=I+M>>>1;g.atoms[P].i<w?I=P+1:M=P}for(let P=I;P<g.atoms.length&&g.atoms[P].i<O;P++){s(1);let D=g.atoms[P];v(D.i),T.push({k:d(D),raw:_n,len:1,from:k,to:k+1}),k++}return v(O),T},b=(g,d,w,O,T,k)=>{if(w===O||T===k)return;if(O-w===k-T){s((O-w)*4);let x=!0;for(let A=w,X=T;A<O;A++,X++){if(n[0].text[A]!==n[d].text[X]){x=!1;break}let H=n[0].atomAt.get(A),q=n[d].atomAt.get(X);if(!!H!=!!q||H&&o[0](H)!==o[d](q)){x=!1;break}}if(x){u(g,w,O,T,"retained");return}}let v=y(n[0],o[0],w,O),I=y(n[d],o[d],T,k),M=v.length+I.length+4,P=Math.min(v.length+I.length,4e3,Math.floor((Math.sqrt(M*M+l.remaining/2)-M)/2));if(P<1)throw c;s(4*(P+1)*(M+P+1));let D=Gn(v,I,P),$=0,W=0,B=()=>{let x=v[$++],A=I[W++];s(x.len),x.raw===A.raw&&u(g,x.from,x.to,A.from,"retained")};for(let x of D.hunks){for(;$<x.bs;)B();$=x.be,W+=x.toks.length}for(;$<v.length&&W<I.length;)B()},S=g=>{let d=e.filter(D=>D.side===g-1&&i[0].has(D.source)&&i[g].has(D.target));if(!d.length)return null;let w=[],O=(D,$,W)=>{if(!i[0].has(D.source)||!i[g].has(D.target))return;let B=f($.get(D.source).flat,n[0]),x=f($.get(D.target).flat,n[g]);s(D.to-D.from);for(let A=0;A<D.to-D.from;A++){let X=B[D.from+A],H=x[D.targetFrom+A];if(X<0||H<0)throw c;u(w,X,X+1,H,W)}},T=new Set;for(let D of d){if(!T.has(D.retained)){T.add(D.retained);for(let $ of D.retained)O($,D.models,"retained")}for(let $ of D.runs)O($,D.models,"transfer")}w.sort((D,$)=>(s(1),D.from-$.from||D.target-$.target));let k=[];for(let D of w){s(1);let $=k[k.length-1];if($&&D.from<$.to){if(D.target-D.from!==$.target-$.from)throw c;$.to=Math.max($.to,D.to),D.kind==="transfer"&&($.kind="transfer")}else k.push(D)}let v=[],I=0,M=0;for(let D of k){if(D.target<M)throw c;b(v,g,I,D.from,M,D.target),v.push(D),I=D.to,M=D.target+D.to-D.from}b(v,g,I,n[0].text.length,M,n[g].text.length);let P=Vn({base:n[0],side:n[g],retained:v.filter(D=>D.kind==="retained"),transfers:v.filter(D=>D.kind==="transfer"),baseAtomKey:o[0],sideAtomKey:o[g],budget:l});if(P.status!=="ready"||!P.monotone)throw c;return P};try{let g=S(1),d=S(2);return g||d?{local:g,remote:d}:{fallback:!0}}catch(g){if(g!==c)throw g;return{fallback:!0}}}function Ss(e,t,n=!1){let o=-1,r=-1;for(let l=0;l<e.list.length;l++){let s=e.list[l];s.bLo<t.lo||s.bLo>t.hi||(o<0&&(o=l),r=l)}let c=[];for(let l=o;l>=0&&l<=r;l++){let s=e.list[l],i=!n&&l===o?s.inlineStart<0?s.to:s.inlineStart:s.from,a=!n&&l===r?s.inlineEnd<0?s.from:s.inlineEnd:s.to;for(let p=i;p<a;p++)c.push(e.units[p]);l<r&&c.push(e.units[s.next])}return c}var it=e=>!!e&&e.nodeType===1,Pn=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function Ns(e){for(let t of e)if(Pn.has(t.tagName))return!0;return!1}function Ea(e,t,n){let o=null;for(let r of t.childNodes)if(!(!it(r)||!n(r)||!r.isEqualNode(e))){if(o)return null;o=r}if(!o)return null;for(let r of e.parentNode.childNodes)if(r!==e&&r.isEqualNode(e))return null;return o}var Xo="[id],[data-id],script,head>*";function vs(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let o=Eo(n,e);if(o)return"merge:"+o.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?zi(n,t):null}}function jr(e,t,n,o){let r=o.ignored,c=o.stats||no(),l=bi({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:c}),{unitsOf:s,meta:i}=l,a=o.baseURI,p=o.mergeTags!==null,f=vs(o.mergeTags,a),u=C=>G=>{let se=f(G);return se!==null?se:C(G)},y=u(o.identity.base),b=u(o.identity.local),S=u(o.identity.remote),g=o.authored||o.identity,d=C=>C&&C.nodeType===9?C.documentElement:C,w=d(e),O=d(t),T=d(n),k=globalThis.__hyperMorphProfile,v=k?performance.now():0,I=C=>C===kn?Xo:null,M=o.scope||null,P=M?M.baseDropped:new Set,D=new Set,$=M?M.remoteDropped:new Set,W=M?M.baseIndex:Ar(w,y,r,I(o.identity.base),P),B=o.localIsBase||w===O?null:Ar(O,b,r,I(o.identity.local),D),x=M?M.remoteIndex:Ar(T,S,r,I(o.identity.remote),$),A=C=>{let G=it(C)&&b(C);return G&&B?.get(G)===C&&!W.has(G)?G:null},X=C=>{let G=it(C)&&S(C);return G&&x.get(G)===C&&!W.has(G)?G:null},H=B?ts(w,O,{analyzer:l,baseIndex:W,sideIndex:B,baseId:g.base,sideId:g.local,baseKey:y,sideKey:b,baseDropped:P,sideDropped:D,stats:c}):dl(),q=ts(w,T,{analyzer:l,baseIndex:W,sideIndex:x,baseId:g.base,sideId:g.remote,baseKey:y,sideKey:S,baseDropped:P,sideDropped:$,stats:c,scope:M,comparisons:o.comparisons});if(M){if(!M.held(q))return null;for(let C of M.dropped)Qr(C)}let Ee=null;function Me(C){if(!Ee){Ee=new WeakMap;let G=[w];for(;G.length;){let se=G.pop();se.tagName==="TEMPLATE"&&se.content&&Ee.set(se.content,se);for(let me of l.childrenOf(se))me.nodeType===1&&G.push(me)}}return Ee.get(C)||null}let je=C=>{let G=it(C)||C.nodeType?C.parentNode:C.parent;return G&&G.nodeType===11?Me(G):G};if(q.moved.size){let C=!1;for(let G of Array.from(q.moved))!it(G)||q.identityPaired.has(G)||!g.base(G)||h(q,je(G))||(q.unpair(G),C=!0);C&&q.rematch()}un(),z(H,q),z(q,H);for(let C of[H,q])if(C.refused)for(let G of C.refused)C.moved.has(G)||c.ambiguousMoves++;k&&(k.alignTotal=(k.alignTotal||0)+(performance.now()-v),v=performance.now());let ae=w.ownerDocument.implementation.createHTMLDocument(""),Ae=new WeakMap,_e=new WeakMap,ve=[],N=[],J=new Set,le=[],oe=new Set,Re=new Set,Be=new Set,Se=new WeakMap,nt=null,Je=o.lineage?.locals.length?ji():null,ht=C=>{let G=Mr(C);return G&&Je&&Je.consume(C.local),G},Ge=o.conflicts||"remote",st=C=>ve.push(C),Mt=C=>ve.push(C),It=tl({roots:{base:w,local:O,remote:T},L:H,R:q,unitsOf:s,provenance:Ae,policy:Ge}),yt=(C,G)=>{N.push(C),G&&It.note(C,G)},Nt=null,Ct=null,_t=ln(),fn=null,Et=j(w,H.map.get(w),q.map.get(w),!!o.localIsBase,!!o.childrenOnly);Et.tagName==="HTML"?ae.replaceChild(Et,ae.documentElement):ae.body.appendChild(Et),Nt?.drain(Et),Ct?.drain(Et),k&&(k.build=(k.build||0)+(performance.now()-v));let Gt=o.childrenOnly?!Le(xe(Et),xe(T)):!te(Et,T),wn=It.finish(Et),Bt=Je?Di({locals:o.lineage.locals,rec:Je,root:Et,provenance:Ae,segments:le,ignored:r}):null;return{doc:ae,root:Et,provenance:Ae,textMappers:_e,decisions:ve,conflicts:N,recoveryLinks:wn,localDiverged:Gt,mergedScripts:J,segments:le,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==kn,L:H,R:q,stats:c,lineage:Bt};function ln(){let C=new Map,G=new Set;if(o.localIsBase||!H.insertedByHash)return{partner:C,drop:G};let se=H.insertedByHash(),me=q.insertedByHash();if(!se.size||!me.size)return{partner:C,drop:G};let ye={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},ce=lt=>{let ze=0;for(let At=lt.parentNode;At;At=At.parentNode)ze++;return ze},re=[],Oe=lt=>{let ze=lt.textContent.trim();return ze.split(/\s+/).length>=3||ze.replace(/\s/g,"").length>=12},Pe=lt=>{let ze=h(H,lt),At=h(q,lt);return ze&&H.reverse.get(ze.parentNode)!==lt.parentNode||At&&q.reverse.get(At.parentNode)!==lt.parentNode},We=(lt,ze,At)=>{for(let Dt of At.parentNode.children){let yn=Dt!==At&&lt.reverse.get(Dt);if(yn&&Pe(yn))return!0}let at=lt.reverse.get(At.parentNode);if(at){for(let Dt of at.children)if(!h(ze,Dt)&&!r(Dt))return!0}return!1},Fe=new Map([[H,new Map],[q,new Map]]),pt=(lt,ze)=>{let At=Fe.get(lt),at=At.get(ze);if(at===void 0){at=!1;for(let Dt of ze.children)if(lt.reverse.has(Dt)||pt(lt,Dt)){at=!0;break}At.set(ze,at)}return at},tt=new Map;for(let lt of me.values())for(let ze of lt){let At=X(ze);At&&tt.set(At,ze)}for(let lt of se.values())for(let ze of lt){let At=A(ze),at=At?tt.get(At):null;at&&at.tagName===ze.tagName&&!Fn(ze,ye)&&!Fn(at,ye)&&!o.remoteWins(ze)&&!o.remoteWins(at)&&re.push([ze,[at],ce(ze),!0,!0])}for(let[lt,ze]of se){let At=me.get(lt);if(!At)continue;let at=ze.length===1&&At.length===1;for(let Dt of ze)!Fn(Dt,ye)&&!A(Dt)&&re.push([Dt,At,ce(Dt),at&&(Oe(Dt)||We(H,q,Dt)||We(q,H,At[0]))])}if(!re.length)return{partner:C,drop:G};re.sort((lt,ze)=>lt[2]-ze[2]);let Ft=new Set,Wt=new Set,dn=lt=>{for(let ze of lt.querySelectorAll("*"))Ft.add(ze)},bt=(lt,ze)=>lt.reverse.get(ze.parentNode)||null;for(let[lt,ze,,At,at]of re){if(Ft.has(lt)||Wt.has(lt)||at&&(pt(H,lt)||pt(q,ze[0])))continue;let Dt=bt(H,lt),yn=Jt=>!Wt.has(Jt)&&!Ft.has(Jt)&&(at||Jt.tagName===lt.tagName&&!X(Jt)&&l.equalUnits(lt,Jt)),on=ze.find(Jt=>Dt&&bt(q,Jt)===Dt&&yn(Jt))||(At?ze.find(yn):null);if(!on)continue;Wt.add(lt),Wt.add(on);let pn=Dt&&bt(q,on)===Dt;(!at||!pn||l.equalUnits(lt,on))&&(dn(lt),dn(on)),!pn&&(C.set(lt,on),C.set(on,lt),G.add(Ge==="local"?on:lt))}return{partner:C,drop:G}}function Yt(C,G,se){if(oe.add(C),_t.drop.has(C))return null;oe.add(se);let me=G==="local"?C:se,ye=G==="local"?se:C,ce;return l.equalUnits(me,ye)?(ce=de(me,"local",!0),Ae.get(ce).remote=ye):ce=ge(me,ye),yt({kind:"structure",el:ce,detail:"both-moved",base:null,local:me,remote:ye},{unit:{b:null,l:me,r:ye}}),st({kind:"insert",el:ce,source:"both"}),ce}function un(){if(!H.weak||!q.weak||!H.weak.size||!q.weak.size||!H.unpair)return;let C=new Map;for(let se of H.weak){let me=h(H,se);it(se)&&it(me)&&C.set(l.unitHash(me),se)}let G=!1;for(let se of Array.from(q.weak)){let me=h(q,se);if(!it(se)||!it(me))continue;let ye=C.get(l.unitHash(me));if(!ye||ye===se||!H.weak.has(ye)||h(H,se)&&h(q,ye))continue;let ce=h(H,ye);ce.tagName===me.tagName&&l.equalUnits(ce,me)&&(H.unpair(ye),q.unpair(se),G=!0)}G&&(H.rematch(),q.rematch())}function z(C,G){if(!C.weak||!C.weak.size||!G.insertedByHash)return;let se=G.insertedByHash();if(!se.size)return;let me=!1;for(let ye of Array.from(C.weak)){let ce=h(C,ye);if(!ce)continue;let re=C===H?A(ce):X(ce);if(re){let Pe=(C===H?x:B)?.get(re);Pe&&Pe.tagName===ce.tagName&&!G.reverse.has(Pe)&&(C.unpair(ye),me=!0);continue}let Oe=se.get(l.unitHash(ce));Oe&&Oe.some(Pe=>Pe.tagName===ce.tagName&&l.equalUnits(Pe,ce))&&(C.unpair(ye),me=!0)}me&&C.rematch()}function h(C,G){if(!G)return null;if(C.map.has(G))return C.map.get(G);let se=[],me=je(G);for(;me&&!C.map.has(me);me=je(me))se.push(me);let ye=me;if(!ye||!C.identical.has(ye))return null;C.pairIdenticalChildren(ye);for(let re=se.length-1;re>=0;re--)C.pairIdenticalChildren(se[re]);let ce=C.map.get(G)||null;return ce&&c.lazyTwins++,ce}function E(C,G,se,me){if(it(C)&&Pn.has(C.tagName)&&!H.identical.has(C)&&(C.previousSibling?.nodeType===3||C.nextSibling?.nodeType===3)){let Oe=je(C),Pe=h(H,C),We=h(q,C);Pe&&We&&Ut(Pe,h(H,Oe),H)&&!Ut(We,h(q,Oe),q)&&(Ct||=rl({L:H,R:q,twinIn:h,unitsOf:s,view:R,parentOf:je,ignored:r,remoteWins:o.remoteWins,eligible:Fe=>it(Fe)&&Pn.has(Fe.tagName),build:j,out:ae,policy:Ge,provenance:Ae,textMappers:_e,segments:le,conflicts:N,conflict:yt,decisions:ve}),Ct.ensureOwner(C))}if(G===null)return null;if(me!==void 0)return Nt||=Ro(Ae,je,H,q,h,j,r,o.remoteWins,N,yt,V,O,T),Nt.plan(C,G,se,!!me),me&&(Nt.produced(C,me),Re.add(C)),me;if(Re.has(C)||Be.has(C))return yt({kind:"structure",el:null,detail:"both-moved",base:C},{subject:C}),Re.has(C)?null:de(se,G);Nt||=Ro(Ae,je,H,q,h,j,r,o.remoteWins,N,yt,V,O,T),Nt.plan(C,G,se,!0);let ye=h(H,C),ce=h(q,C);(!ye||!ce)&&yt({kind:"structure",el:null,detail:"move-beats-delete",base:C},{subject:C,deleted:ye?"remote":"local"});let re=j(C,ye,ce,!1);return(G==="local"?st:Mt)({kind:"move",el:re,source:G}),re}function R(C,G,se,me){return me||!G||G===se?{el:se,asBase:!0,twin:ye=>ye,baseOf:ye=>ye,units:s(se),here:()=>!0,parentOfTwin:()=>se}:{el:G,asBase:!1,twin:ye=>h(C,ye),baseOf:ye=>C.reverse.get(ye),units:s(G),here:ye=>it(ye)?ye.parentNode===G||G.tagName==="TEMPLATE"&&ye.parentNode===G.content:ye.parent===G||G.tagName==="TEMPLATE"&&ye.parent===G.content}}function V(C,G,se){return!G||se&&se.identical.has(C)?!1:it(C)?!l.equalUnits(C,G)||!Q(C,G,se):C.value!==G.value}function Q(C,G,se){if(!se||C===G)return!0;let me=[[C,G]];for(;me.length;){let[ye,ce]=me.pop(),re=s(ye),Oe=s(ce);for(let Pe=0;Pe<re.length&&Pe<Oe.length;Pe++){let We=re[Pe],Fe=Oe[Pe];if(!it(We)||!it(Fe))continue;let pt=se.map.get(We);if(pt!==void 0&&pt!==Fe)return!1;let tt=se.reverse.get(Fe);if(tt!==void 0&&tt!==We)return!1;me.push([We,Fe])}}return!0}function j(C,G,se,me,ye=!1){let ce=me||(se?o.remoteWins(se):o.remoteWins(C)),re=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ae.createElementNS(C.namespaceURI,C.tagName):ae.createElement(C.tagName),Oe={base:C,local:G||null,remote:se||null};if(Ae.set(re,Oe),ce&&!me&&G&&V(C,G,H)&&(!se||!l.equalUnits(G,se))&&yt({kind:"structure",el:re,detail:"remote-wins",base:C,local:G,remote:se||null},{subject:C}),oe.add(C),Re.add(C),G&&oe.add(G),se&&oe.add(se),o.skipUnchanged&&!ye&&(o.localIsBase||H.identical.has(C))&&se&&q.identical.has(C)&&!o.remoteWins(C)){Oe.unchanged=!0;for(let We of C.attributes)We.namespaceURI?re.setAttributeNS(We.namespaceURI,We.name,We.value):re.setAttribute(We.name,We.value);return Nt?.produced(C,re),re}Be.add(C),ye||ie(C,ce?C:G,se,re);let Pe=C.tagName;if(mn(C))be(C,ce?C:G,se,re);else if(Pe==="TEXTAREA")re.textContent=ue(C.textContent,(ce?C:G)?(ce?C:G).textContent:C.textContent,se?se.textContent:C.textContent,re,"text");else if(!Ct?.render(C,re)){let We=ee(C,G,se,ce,re),Fe=Pe==="TEMPLATE"&&re.content?re.content:re;for(let pt of We)Fe.appendChild(pt)}return Be.delete(C),Nt?.produced(C,re),re}function ue(C,G,se,me,ye){if(G===se)return G;if(G===C)return se!==C&&Mt({kind:ye,node:me,source:"remote"}),se;if(se===C)return st({kind:ye,node:me,source:"local"}),G;let ce=Ge==="local"?G:se;return yt({kind:ye,node:me,base:C,local:G,remote:se,resolved:ce},{site:"whole",el:me}),ve.push({kind:ye,node:me,source:"both"}),ce}function be(C,G,se,me){let ye=C.textContent,ce=G?G.textContent:ye,re=se?se.textContent:ye,Oe=p?Eo(C,o.mergeTags,!0):null;if(Oe&&ce!==re){let Pe=se&&se.getAttribute("merge-key")||C.getAttribute("merge-key"),{text:We,warnings:Fe,conflicts:pt}=ks(o.localIsBase?void 0:ye,ce,re,{parse:Oe.recognizer.parse,keyCandidates:Pe?Pe.split(/[\s,]+/).filter(Boolean):void 0});for(let tt of Fe)console.warn(`[hyper-morph] merge "${Oe.raw}": ${tt}`);for(let tt of o.localIsBase?[]:pt)yt({kind:"json",node:me,name:Oe.raw,path:tt.path,base:tt.base,local:tt.local,remote:tt.remote,resolved:tt.resolved});me.textContent=We,J.add(me),We!==re?st({kind:"text",node:me,source:We===ce?"local":"both"}):We!==ye&&Mt({kind:"text",node:me,source:"remote"});return}me.textContent=ue(ye,ce,re,me,"text")}function ie(C,G,se,me){let ye=new Map;for(let ce of[C,G,se])if(ce)for(let re of ce.attributes)o.ignoreAttribute(ce,re.name)||ye.set(re.name,re);for(let[ce,re]of ye){let Oe=C?C.getAttribute(ce):null,Pe=G?G.getAttribute(ce):Oe,We=se?se.getAttribute(ce):Oe,Fe;Pe===We?Fe=Pe:Pe===Oe?(Fe=We,Mt({kind:"attr",el:me,name:ce,source:"remote"})):We===Oe?(Fe=Pe,st({kind:"attr",el:me,name:ce,source:"local"})):(Fe=Ne(ce,Oe,Pe,We),Fe===void 0&&(Fe=Ge==="local"?Pe:We,yt({kind:"attr",el:me,name:ce,base:Oe,local:Pe,remote:We,resolved:Fe},{el:me,sample:re})),ve.push({kind:"attr",el:me,name:ce,source:"both"})),Fe!=null&&(re.namespaceURI?me.setAttributeNS(re.namespaceURI,re.name,Fe):me.setAttribute(ce,Fe))}}function Ne(C,G,se,me){if(C==="class"){let ye=We=>new Set((We||"").split(/\s+/).filter(Boolean)),ce=ye(G),re=ye(se),Oe=ye(me),Pe=new Set;for(let We of new Set([...ce,...re,...Oe])){let Fe=ce.has(We),pt=re.has(We),tt=Oe.has(We);(pt===tt?pt:pt===Fe?tt:pt)&&Pe.add(We)}return[...Pe].join(" ")}if(C==="style"){let ye=Fe=>{let pt=new Map;if(!Fe)return pt;let tt=0,Ft=null,Wt="",dn=()=>{let bt=Wt.indexOf(":");bt>0&&pt.set(Wt.slice(0,bt).trim(),Wt.slice(bt+1).trim()),Wt=""};for(let bt of Fe){if(Ft){Wt+=bt,bt===Ft&&(Ft=null);continue}if(bt==='"'||bt==="'"){Ft=bt,Wt+=bt;continue}if(bt==="("?tt++:bt===")"&&tt--,bt===";"&&tt===0){dn();continue}Wt+=bt}return Wt.trim()&&dn(),pt},ce=ye(G),re=ye(se),Oe=ye(me),Pe=new Map,We=!1;for(let Fe of new Set([...ce.keys(),...re.keys(),...Oe.keys()])){let pt=ce.get(Fe)??null,tt=re.get(Fe)??null,Ft=Oe.get(Fe)??null,Wt;tt===Ft?Wt=tt:tt===pt?Wt=Ft:Ft===pt?Wt=tt:(Wt=Ge==="local"?tt:Ft,We=!0),Wt!=null&&Pe.set(Fe,Wt)}return We?void 0:[...Pe].map(([Fe,pt])=>`${Fe}: ${pt}`).join("; ")}}function U(C,G,se,me){let ye=C.value,ce=me?ye:G?G.value:"",re=se?se.value:"";oe.add(C),G&&oe.add(G),se&&oe.add(se);let Oe=$o(ye,ce,re,Ge),Pe=Oe.text===""?null:ae.createTextNode(Oe.text);Pe&&(Ae.set(Pe,{base:C.nodes,local:G?G.nodes:null,remote:se?se.nodes:null}),_e.set(Pe,Oe.mapLocalOffset)),ce!==ye&&re!==ye?ve.push({kind:"text",node:Pe,source:"both"}):ce!==ye?st({kind:"text",node:Pe,source:"local"}):re!==ye&&Mt({kind:"text",node:Pe,source:"remote"});for(let We of Oe.conflicts)yt({kind:"text",node:Pe,base:ye.slice(We.bs,We.be),local:We.local,remote:We.remote,resolved:We.resolved},{site:"run",bRun:C,lRun:G,rRun:se,node:Pe,c:We});return Pe}function Y(C,G){return ao(C,G).every(se=>se.bs===se.be)}function he(C,G){let se=C?C.value:"",me=G?G.value:"",ye;if(se===me||!me?ye=se:se?Y(se,me)?ye=me:Y(me,se)?ye=se:(ye=Ge==="local"?se:Ge==="both"?se+me:me,yt({kind:"structure",el:null,detail:"insert-collision",local:se,remote:me,resolved:ye},{unit:{b:null,l:C,r:G},localLost:Ge==="remote"})):ye=me,C&&oe.add(C),G&&oe.add(G),ye==="")return null;let ce=ae.createTextNode(ye);return Ae.set(ce,{base:null,local:C?C.nodes:null,remote:G?G.nodes:null}),se?st({kind:"insert",el:ce,source:me&&se===me?"both":"local"}):Mt({kind:"insert",el:ce,source:"remote"}),ce}function ge(C,G){let se={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},me=Oe=>s(Oe).every(Pe=>it(Pe)?Fn(Pe,se):Pe.kind==="text"),ye=null;if(me(C)&&me(G)){let Oe=C.textContent,Pe=G.textContent;Oe===Pe||Y(Pe,Oe)?ye=G:Y(Oe,Pe)&&(ye=C)}if(!ye){let Oe=Ge==="local",Pe=de(Oe?C:G,Oe?"local":"remote",!0),We=Ae.get(Pe);return Oe?We.remote=G:We.local=C,yt({kind:"structure",el:Pe,detail:"insert-collision",local:C,remote:G,resolved:Oe?C:G},{unit:{b:null,l:C,r:G},localLost:!Oe}),Pe}let ce=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ae.createElementNS(C.namespaceURI,C.tagName):ae.createElement(C.tagName);ie(null,C,G,ce),Ae.set(ce,{base:null,local:C,remote:G}),oe.add(C),oe.add(G);let re=ht({base:Array.from(ye.childNodes),local:Array.from(C.childNodes),remote:Array.from(G.childNodes),out:ae,policy:Ge,idOf:{local:b,remote:S},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:Ae,textMappers:_e,conflicts:N,conflict:yt,scope:{base:null,local:C,remote:G,units:[],at:0},synthetic:!0,decisions:ve,node:ce});le.push(...re.segments);for(let Oe of re.nodes)ce.appendChild(Oe);return ce}function de(C,G,se=!1){if(!se&&it(C)){let re=_t.partner.get(C);if(re)return Yt(C,G,re)}if(!it(C)){if(C.value==="")return null;let re=C.kind==="comment"?ae.createComment(C.value):ae.createTextNode(C.value);return Ae.set(re,{base:null,local:G==="local"?C.nodes:null,remote:G==="remote"?C.nodes:null}),oe.add(C),re}let me=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ae.createElementNS(C.namespaceURI,C.tagName):ae.createElement(C.tagName);for(let re of C.attributes)re.namespaceURI?me.setAttributeNS(re.namespaceURI,re.name,re.value):me.setAttribute(re.name,re.value);Ae.set(me,{base:null,local:G==="local"?C:null,remote:G==="remote"?C:null}),oe.add(C);let ye=C.tagName==="TEMPLATE"&&me.content?me.content:me,ce=G==="local"?H:q;for(let re of s(C)){let Oe=it(re)?ce.reverse.get(re):null;if(Oe&&E(Oe,null,null),Oe&&Re.has(Oe)){yt({kind:"structure",el:null,detail:"both-moved",base:Oe},{subject:Oe});continue}if(Oe&&!Be.has(Oe)){let We=h(H,Oe)||null,Fe=h(q,Oe)||null;if(We||Fe){Nt||=Ro(Ae,je,H,q,h,j,r,o.remoteWins,N,yt,V,O,T),Nt.plan(Oe,G,re,!0);let pt=j(Oe,We,Fe,!1);G==="local"?st({kind:"move",el:pt,source:"local"}):Mt({kind:"move",el:pt,source:"remote"}),ye.appendChild(pt);continue}}let Pe=de(re,G);Pe&&ye.appendChild(Pe)}if(!se&&_t.drop.size&&C.tagName==="DIV"&&!ye.firstChild&&!C.attributes.length&&!(G==="local"?b(C):S(C))&&!ce.reverse.has(C)&&!r(C)&&!o.remoteWins(C)){let re=C.firstChild;if(re&&re===C.lastChild&&it(re)&&(_t.drop.has(re)||fn?.has(re)))return(fn||=new WeakSet).add(C),null}return me}function ee(C,G,se,me,ye){G&&H.identical.has(C)&&H.pairIdenticalChildren(C),se&&q.identical.has(C)&&q.pairIdenticalChildren(C);let ce=R(H,G,C,me),re=R(q,se,C,!1),Oe=s(C),Pe=new Set(Oe),We=new Map;for(let fe=0;fe<Oe.length;fe++)We.set(Oe[fe],fe);let Fe=[],pt=new Set,tt=new Map,Ft=new Set,Wt=Je&&[],dn=Je&&[],bt=new Set,lt=[],ze=null,At=new Map;if(!ce.asBase&&!re.asBase&&!H.identical.has(C)&&!q.identical.has(C))for(let fe of Oe){if(!it(fe)||!Pn.has(fe.tagName))continue;let Ve=ce.twin(fe),He=re.twin(fe);Ve&&He&&(!ce.here(Ve)||!re.here(He))&&E(fe,null,null)}_o();let at=fe=>{let Ve=[];for(let He of fe.units){if(bt.has(He))continue;let et=fe.baseOf(He);et&&Pe.has(et)&&Ve.push(et)}return Ve},Dt=fe=>at(fe).map(Ve=>We.get(Ve)),yn=fe=>fe.every((Ve,He)=>He===0||Ve>=fe[He-1]),on=!ce.asBase&&!yn(Dt(ce)),pn=!re.asBase&&!yn(Dt(re));on&&pn&&yt({kind:"structure",el:ye,detail:"both-reordered",base:C},{subject:C,lKept:at(ce),rKept:at(re)});let Jt=pn||!on?{V:re,A:q,side:"remote",other:ce,otherA:H,otherSide:"local"}:{V:ce,A:H,side:"local",other:re,otherA:q,otherSide:"remote"};on?st({kind:"move",el:null,source:pn?"both":"local",base:C}):pn&&Mt({kind:"move",el:null,source:"remote",base:C});let Dn=ce.asBase?[]:ce.units.filter(fe=>!ce.baseOf(fe)&&!bt.has(fe)&&!_t.partner.has(fe)),wo=re.asBase?[]:re.units.filter(fe=>!re.baseOf(fe)&&!bt.has(fe)&&!_t.partner.has(fe)),Bn=new Map;if(Dn.length&&wo.length){let fe=new Map,Ve=new Map;for(let qe of wo){if(it(qe)){let kt=S(qe);kt&&fe.set(kt,qe)}let Ke=l.unitHash(qe);Ve.has(Ke)||Ve.set(Ke,[]),Ve.get(Ke).push(qe)}let He=(qe,Ke)=>{let kt=qe.units.indexOf(Ke);for(let Ye=kt-1;Ye>=0;Ye--){let rt=qe.baseOf(qe.units[Ye]);if(rt)return rt}return"start"},et=new Map,wt=new Map;for(let qe of wo){let Ke=He(re,qe);it(qe)?(wt.has(Ke)||wt.set(Ke,[]),wt.get(Ke).push(qe)):qe.kind==="text"&&!et.has(Ke)&&et.set(Ke,qe)}for(let qe of Dn){let Ke=null;if(it(qe)){let Ye=b(qe);Ye&&fe.has(Ye)&&!Bn.has(fe.get(Ye))&&(Ke=fe.get(Ye))}else if(qe.kind==="text"){let Ye=et.get(He(ce,qe));Ye&&!Bn.has(Ye)&&(Ke=Ye)}let kt=!!A(qe);if(!Ke&&!kt){let Ye=Ve.get(l.unitHash(qe));Ye&&(Ke=Ye.find(rt=>!Bn.has(rt)&&it(rt)===it(qe)&&(it(rt)?rt.tagName===qe.tagName&&!X(rt):rt.kind===qe.kind)&&l.equalUnits(qe,rt))||null)}if(!Ke&&it(qe)&&!kt){let Ye=g.local(qe),rt=(wt.get(He(ce,qe))||[]).filter(ft=>{let Vt=g.remote(ft);return!Bn.has(ft)&&ft.tagName===qe.tagName&&!X(ft)&&!(Ye&&Vt&&Ye!==Vt)&&l.similar(qe,ft)});rt.length===1&&(Ke=rt[0])}Ke&&(Bn.set(Ke,qe),Bn.set(qe,Ke))}}let Wo=fe=>{if(Ct?.consumes(fe))return null;if(oe.has(fe)||Nt?.has(fe))return tt.get(fe)||null;let Ve=ce.twin(fe),He=re.twin(fe),et=Ve&&!ce.asBase&&!ce.here(Ve),wt=He&&!re.asBase&&!re.here(He);if(et||wt){if((!Ve||!He)&&yt({kind:"structure",el:null,detail:"move-beats-delete",base:fe},{subject:fe,deleted:Ve?"remote":"local"}),!Qe(fe))return it(fe)?(Nt||=Ro(Ae,je,H,q,h,j,r,o.remoteWins,N,yt,V,O,T),et&&Nt.plan(fe,"local",Ve),wt&&Nt.plan(fe,"remote",He)):oe.add(fe),null;yt({kind:"structure",el:null,detail:"both-moved",base:fe},{subject:fe})}if(Ve&&!He&&!ce.asBase&&!re.asBase&&it(fe)&&Pn.has(fe.tagName)&&!o.remoteWins(fe)&&!o.remoteWins(Ve)&&V(fe,Ve,H)&&Ea(fe,xe(re.el),r)){let rt={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},ft=Vt=>it(Vt)?Fn(Vt,rt):Vt.kind==="text";if(s(fe).every(ft)&&s(Ve).every(ft)){let Vt=ht({base:[fe],local:[Ve],remote:[],blocks:new Set([fe,Ve]),out:ae,policy:Ge,L:H,R:q,idOf:{base:y,local:b,remote:S},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Zt,Sn,Qn)=>j(Zt,Sn,Qn,!1),cloneUnit:de,mergeAttrs:ie,atomKey:l.exactUnitKey,moveIn:E,moveBuilt:E,movePlanned:E,provenance:Ae,textMappers:_e,conflicts:N,conflict:yt,scope:{base:C,local:ce.el,remote:re.el,units:Oe,at:We.get(fe)},decisions:ve,node:ye});le.push(...Vt.segments),oe.add(fe),oe.add(Ve);let Ot=ae.createDocumentFragment();for(let Zt of Vt.nodes)Ot.appendChild(Zt);return tt.set(fe,Ot),tt.set(Ve,Ot),Ot}}if(!Ve&&!He)return oe.add(fe),Mt({kind:"remove",source:"both",base:fe}),null;if(!Ve&&!V(fe,He,q))return oe.add(fe),st({kind:"remove",source:"local",base:fe}),null;if(!He&&!V(fe,Ve,H))return oe.add(fe),Mt({kind:"remove",source:"remote",base:fe}),Je&&(Je.remove(Ve),Wt.push({bk:fe,lk:Ve})),null;let qe=!Ve||!He,Ke=ce.asBase?h(H,fe)||null:Ve,kt=re.asBase&&it(fe)&&(q.identityPaired.has(fe)||!g.base(fe))&&h(q,fe)||He,Ye;return it(fe)?Ye=j(fe,Ke,kt,ce.asBase):fe.kind==="comment"?Ye=$e(fe,Ke,He,ce.asBase):Ye=U(fe,Ke,He,ce.asBase),oe.add(fe),Ye&&(tt.set(fe,Ye),Ve&&tt.set(Ve,Ye),He&&tt.set(He,Ye),qe&&(yt({kind:"structure",el:Ye,detail:"edit-beats-delete",base:fe},{subject:fe,deleted:Ve?"remote":"local"}),Ve?st({kind:"insert",el:Ye,source:"local"}):Mt({kind:"insert",el:Ye,source:"remote"}))),Ye},Xn=(fe,Ve,He,et)=>{if(Ct?.consumes(fe))return null;if(oe.has(fe))return tt.get(fe)||null;let wt=Ve.baseOf(fe);if(wt&&Pe.has(wt))return bt.has(wt)&&!bt.has(fe)?gr(wt,fe,et):Wo(wt);if(wt)return Vr(wt,fe,et);let qe=Bn.get(fe);if(qe){let kt=et==="local"?fe:qe,Ye=et==="local"?qe:fe,rt;return it(kt)?l.equalUnits(kt,Ye)?(rt=de(kt,"local"),rt&&(Ae.get(rt).remote=Ye)):rt=ge(kt,Ye):rt=he(kt,Ye),oe.add(kt),oe.add(Ye),rt&&(tt.set(kt,rt),tt.set(Ye,rt),it(kt)&&st({kind:"insert",el:rt,source:"both"})),rt}let Ke=de(fe,et);return Ke&&(tt.set(fe,Ke),et==="local"?st({kind:"insert",el:Ke,source:"local"}):(Mt({kind:"insert",el:Ke,source:"remote"}),Je&&it(fe)&&!_t.partner.has(fe)&&dn.push({su:fe,node:Ke}))),Ke},gr=(fe,Ve,He)=>{let et;return it(fe)?(et=E(fe,He,Ve),et&&oe.add(Ve)):(et=de(Ve,He),oe.add(Ve),et&&(He==="local"?st:Mt)({kind:"insert",el:et,source:He})),et&&tt.set(Ve,et),et},Vr=(fe,Ve,He)=>{E(fe,null,null);let wt=h(He==="local"?q:H,fe),qe=Ve,Ke=wt?Ut(wt,He==="local"?se:G,He==="local"?q:H):!1,kt=wt&&!Ke&&!Pt(fe,wt);if(kt&&He===Jt.otherSide)return yt({kind:"structure",el:null,detail:"both-moved",base:fe},{subject:fe}),null;if(kt&&yt({kind:"structure",el:null,detail:"both-moved",base:fe},{subject:fe}),wt||yt({kind:"structure",el:null,detail:"move-beats-delete",base:fe},{subject:fe,deleted:He==="local"?"remote":"local"}),Be.has(fe)){yt({kind:"structure",el:null,detail:"both-moved",base:fe},{subject:fe});let rt=de(qe,He);return rt&&tt.set(Ve,rt),rt}it(fe)&&(Nt||=Ro(Ae,je,H,q,h,j,r,o.remoteWins,N,yt,V,O,T),Nt.plan(fe,He,qe,!0));let Ye=it(fe)?j(fe,He==="local"?qe:h(H,fe)||null,He==="remote"?qe:h(q,fe)||null,!1):null;return Ye&&(tt.set(fe,Ye),tt.set(Ve,Ye),wt&&tt.set(wt,Ye),He==="local"?st({kind:"move",el:Ye,source:"local"}):Mt({kind:"move",el:Ye,source:"remote"})),Ye};for(let fe of Jt.V.units){if(bt.has(fe)){if(ze?.has(fe)){for(let et of ze.get(fe))pt.has(et)||(Fe.push(et),pt.add(et));continue}let He=tt.get(fe);pt.has(He)||(Fe.push(He),pt.add(He));continue}if(oe.has(fe)&&!(tt.get(fe)&&pt.has(tt.get(fe)))){let He=Jt.V.baseOf(fe);He&&!Pe.has(He)&&yt({kind:"structure",el:null,detail:"both-moved",base:He},{subject:He});continue}let Ve=Xn(fe,Jt.V,Jt.A,Jt.side);Ve&&!pt.has(Ve)&&(Fe.push(Ve),pt.add(Ve),!Jt.V.baseOf(fe)&&!Bn.has(fe)&&!bt.has(fe)&&Ft.add(Ve))}for(let fe of lt)pt.has(fe.frag)||(Fe.splice(fe.previous&&pt.has(fe.previous)?Fe.indexOf(fe.previous)+1:xo(fe.at),0,fe.frag),pt.add(fe.frag));if(!Jt.other.asBase){let fe=Jt.other,Ve=Jt.otherSide,He=Jt.otherA,et=null,wt=0,qe=null;for(let Ke of fe.units){let kt=At.get(Ke)||tt.get(Ke);if(kt&&pt.has(kt)){et=kt,qe=null;continue}if(oe.has(Ke)){let ft=fe.baseOf(Ke);ft&&!Pe.has(ft)&&yt({kind:"structure",el:null,detail:"both-moved",base:ft},{subject:ft});continue}let Ye=Xn(Ke,fe,He,Ve);if(!Ye)continue;let rt;if(qe)rt=Fe.indexOf(qe)+1;else if(et){if(rt=Fe.indexOf(et)+1,Ve==="remote")for(;rt<Fe.length&&Ft.has(Fe[rt]);)rt++}else rt=wt++;Fe.splice(rt,0,Ye),pt.add(Ye),qe=Ye}}for(let fe=0;fe<Oe.length;fe++){let Ve=Oe[fe];if(oe.has(Ve))continue;let He=Wo(Ve);He&&Fe.splice(xo(fe),0,He)}return Je&&Wt.length&&dn.length&&br(),Fe;function br(){if(on||pn)return;let fe=new Set(Fe),Ve=ft=>ft&&Pe.has(ft)&&fe.has(tt.get(ft))?ft:null,He=(ft,Vt)=>{let Ot=[{prev:null,units:[]}];for(let Zt of ft){let Sn=Ve(Vt(Zt));Sn?Ot.push({prev:Sn,units:[]}):Ot[Ot.length-1].units.push(Zt)}return Ot},et=He(Oe,ft=>ft),wt=He(re.units,re.baseOf),qe=ce.asBase?null:He(ce.units,ce.baseOf),Ke=ft=>ft.length===et.length&&ft.every((Vt,Ot)=>Vt.prev===et[Ot].prev);if(!Ke(wt)||qe&&!Ke(qe))return;let kt=new Map(Wt.map(ft=>[ft.bk,ft])),Ye=new Map(dn.map(ft=>[ft.su,ft])),rt=ft=>ft?Fe.indexOf(tt.get(ft)):-1;for(let ft=0;ft<et.length;ft++){if(et[ft].units.length!==1||wt[ft].units.length!==1)continue;let Vt=kt.get(et[ft].units[0]),Ot=Ye.get(wt[ft].units[0]);if(!Vt||!Ot||qe&&(qe[ft].units.length!==1||qe[ft].units[0]!==Vt.lk))continue;let Zt=rt(et[ft].prev);(ft+1<et.length?rt(et[ft+1].prev):Fe.length)-Zt!==2||Fe[Zt+1]!==Ot.node||Vo(Vt.bk,Vt.lk,Ot.su)&&Je.link(Vt.lk,Ot.node)}}function Zn(fe,Ve,He,et){let wt=Ot=>{let Zt=Ot.filter(it);return Zt.length===1?Zt[0]:null},qe=wt(fe),Ke=wt(Ve),kt=wt(He);if(!qe||!Ke||!kt)return;let Ye=fe.indexOf(qe);if(Ve.indexOf(Ke)!==Ye||He.indexOf(kt)!==Ye||fe.length!==Ve.length||fe.length!==He.length)return;for(let Ot=0;Ot<fe.length;Ot++)if(Ot!==Ye&&(fe[Ot].value!==Ve[Ot].value||fe[Ot].value!==He[Ot].value))return;if((ce.asBase?qe:ce.twin(qe))!==Ke||re.twin(qe)||q.reverse.get(kt)||Ke!==qe&&V(qe,Ke,H))return;let rt=et.filter(Ot=>Ot.nodeType===1);if(rt.length!==1||Ae.get(rt[0])?.remote!==kt)return;let ft=Ot=>Ot.map(Zt=>it(Zt)?"":Zt.value??Zt.nodeValue).join(""),Vt=et.indexOf(rt[0]);ft(et.slice(0,Vt))!==ft(fe.slice(0,Ye))||ft(et.slice(Vt+1))!==ft(fe.slice(Ye+1))||Vo(qe,Ke,kt)&&Je.link(Ke,rt[0])}function Vo(fe,Ve,He){if(!it(Ve)||!it(He)||!it(fe)||Ve.namespaceURI!==He.namespaceURI||Ve.localName===He.localName)return!1;for(let Ke of[Ve,He])if(Ke.tagName==="TEMPLATE"||mn(Ke)||Ke.querySelector("template"))return!1;if(o.remoteWins(fe)||o.remoteWins(He)||r(He)||Ve.attributes.length!==He.attributes.length)return!1;for(let Ke of Ve.attributes)if(He.getAttributeNS(Ke.namespaceURI,Ke.localName)!==Ke.value)return!1;let et=Ve.childNodes,wt=He.childNodes;if(et.length!==wt.length)return!1;for(let Ke=0;Ke<et.length;Ke++)if(!et[Ke].isEqualNode(wt[Ke]))return!1;let qe=[[fe,He]];for(;qe.length;){let[Ke,kt]=qe.pop();if(Ke.children.length!==kt.children.length)return!1;for(let Ye=0;Ye<kt.children.length;Ye++){let rt=q.reverse.get(kt.children[Ye]);if(rt!==void 0&&rt!==Ke.children[Ye])return!1;qe.push([Ke.children[Ye],kt.children[Ye]])}}return!0}function xo(fe){for(let Ve=fe-1;Ve>=0;Ve--){let He=tt.get(Oe[Ve]);if(He){let et=Fe.indexOf(He);if(et>=0)return et+1}}return 0}function _o(){if((ce.asBase||H.identical.has(C))&&(re.asBase||q.identical.has(C)))return;let fe={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},Ve=ut=>it(ut)?Fn(ut,fe):ut.kind==="text";if(!ce.asBase&&!re.asBase)for(let ut of Oe){if(!it(ut)||!Pn.has(ut.tagName))continue;let Ze=ce.twin(ut),Rt=re.twin(ut);if(!Ze&&Rt||Ze&&!Rt){let ot=cl({base:Oe,views:[{V:ce,A:H,idOf:g.local},{V:re,A:q,idOf:g.remote}],eligible:vt=>it(vt)&&Pn.has(vt.tagName)&&!r(vt)&&!o.remoteWins(vt),baseId:g.base,ignored:r,remoteWins:o.remoteWins,atomKey:l.exactUnitKey});ot&&(ce=ot[0],re=ot[1]);break}}let He=!ce.asBase&&!re.asBase&&Oe.length>=2&&Pn.has(Oe[0].tagName)&&ce.units.length===Oe.length&&re.units.length===Oe.length?Fi({base:Oe,local:ce.units,remote:re.units,localTwin:ce.twin,remoteTwin:re.twin,eligible:ut=>it(ut)&&Pn.has(ut.tagName)&&!r(ut)&&!o.remoteWins(ut),nodes:{base:Array.from(xe(C).childNodes),local:Array.from(xe(ce.el).childNodes),remote:Array.from(xe(re.el).childNodes)}}):null,et=null,wt=null;if(!He&&!ce.asBase&&!re.asBase&&(Ns(Oe)||Ns(ce.units)||Ns(re.units))){let ut={ignored:r,remoteWins:()=>!1},Ze=ot=>Ve(ot)||it(ot)&&o.remoteWins(ot)&&An.has(ot.tagName)&&Fn(ot,ut),Rt=ot=>it(ot)?Pn.has(ot.tagName)&&!r(ot)&&!o.remoteWins(ot)&&s(ot).every(Ze):ot.kind==="text";et=al({onUncertainOwner:ot=>{let vt=o.identity.local(ot.local);vt&&vt===o.identity.remote(ot.remote)||(wt||=[]).push(ot)},onUncertainSource:ot=>{nt||(nt=new Map);let vt=nt.get(ot.source);vt||nt.set(ot.source,vt=[]);for(let Xt of vt)if(Xt.side===ot.side&&Xt.from===ot.from&&Xt.to===ot.to)return;vt.push(ot)},base:Oe,views:[{V:ce,A:H,idOf:g.local},{V:re,A:q,idOf:g.remote}],eligible:Rt,ignored:r,remoteWins:o.remoteWins,baseId:g.base,atomKey:l.exactUnitKey})}if(wt){ze||=new Map;for(let ut of wt){let{source:Ze,local:Rt,remote:ot}=ut,vt={map:new Map,reverse:new Map,identical:new Set},Xt=ht({base:[Ze],local:[Rt],remote:[ot],out:ae,policy:"both",L:vt,R:vt,ignored:r,remoteWins:o.remoteWins,atomKey:l.exactUnitKey,cloneUnit:de,provenance:Ae,textMappers:_e,conflicts:N,decisions:ve,conflict:(Lt,qt)=>yt(Lt,{...qt,policy:"both"}),scope:{base:C,local:ce.el,remote:re.el,units:Oe,at:We.get(Ze)},node:ye});le.push(...Xt.segments);for(let Lt of[Ze,Rt,ot])oe.add(Lt),bt.add(Lt),ze.set(Lt,Xt.nodes),tt.set(Lt,Xt.nodes[Xt.nodes.length-1]);for(let Lt=0;Lt<Xt.nodes.length;Lt++)lt.push({frag:Xt.nodes[Lt],at:We.get(Ze),previous:Lt?Xt.nodes[Lt-1]:null})}}let qe=He?He.blocks:null;if(et){qe=new Set;for(let ut of et.blocks)qe.add(ut)}let Ke=ut=>!Ct?.consumes(ut)&&(qe&&qe.has(ut)||Ve(ut)),kt=Oe.map(Ke);if(!kt.includes(!0))return;let Ye=ut=>{let Ze=ut.units,Rt=new Map;for(let tn=0;tn<Ze.length;tn++)Rt.set(Ze[tn],tn);let ot=[],vt=-1;for(let tn=0;tn<Oe.length;tn++){if(kt[tn])continue;let Tt=ut.twin(Oe[tn]),mt=Tt?Rt.get(Tt):void 0;mt===void 0||mt<=vt||Ke(Tt)||(ot.push([tn,mt]),vt=mt)}let Xt=[],Lt=-1,qt=-1;for(let tn=0;tn<=ot.length;tn++){let[Tt,mt]=tn<ot.length?ot[tn]:[Oe.length,Ze.length],St={bLo:-1,bHi:-1,from:qt+1,to:mt,inlineStart:-1,inlineEnd:-1,next:mt};for(let Qt=Lt+1;Qt<Tt;Qt++)kt[Qt]&&(St.bLo<0&&(St.bLo=Qt),St.bHi=Qt);for(let Qt=qt+1;Qt<mt;Qt++){let eo=Ze[Qt];Ke(eo)&&(St.inlineStart<0&&(St.inlineStart=Qt),St.inlineEnd=Qt+1)}Xt.push(St),Lt=Tt,qt=mt}return{units:Ze,list:Xt}},rt=Ye(ce),ft=Ye(re),Vt=[];for(let ut of[rt,ft])for(let Ze of ut.list)Ze.bLo>=0&&Vt.push([Ze.bLo,Ze.bHi]);Vt.sort((ut,Ze)=>ut[0]-Ze[0]);let Ot=[];for(let[ut,Ze]of Vt){let Rt=Ot[Ot.length-1];Rt&&ut<=Rt.hi?Rt.hi=Math.max(Rt.hi,Ze):Ot.push({lo:ut,hi:Ze})}let Zt=(ut,Ze)=>ut.length===Ze.length&&ut.every((Rt,ot)=>l.equalUnits(Rt,Ze[ot])),Sn=ut=>!it(ut)&&ut.kind==="comment",Qn=ut=>{if(!ut.length)return[];let Ze=(Lt,qt)=>it(Lt)?Lt:Lt.nodes[qt?Lt.nodes.length-1:0],Rt=Ze(ut[0]),ot=Ze(ut[ut.length-1],!0),vt=Lt=>Lt&&it(Lt)&&r(Lt);for(;vt(Rt.previousSibling);)Rt=Rt.previousSibling;for(;vt(ot.nextSibling);)ot=ot.nextSibling;let Xt=[];for(let Lt=Rt;Lt&&(Xt.push(Lt),Lt!==ot);Lt=Lt.nextSibling);return Xt},Un=ut=>ut.some(Ze=>it(Ze)&&r(Ze));for(let ut of Ot){let Ze=Oe.slice(ut.lo,ut.hi+1),Rt=null;if(et)for(let Tt of Ze){let mt=et.certificatesBySource.get(Tt);mt&&(Rt||=[]).push(...mt)}let ot=ce.asBase?null:Ss(rt,ut),vt=re.asBase?null:Ss(ft,ut);if(Rt){let Tt=[new Set(ot||Ze),new Set(vt||Ze)],mt=Rt.some(St=>!Tt[St.side].has(St.target));for(let St of Ze)if(qe.has(St))for(let[Qt,eo]of[[0,ce],[1,re]]){let Nn=eo.twin(St);Nn&&eo.here(Nn)&&!Tt[Qt].has(Nn)&&(mt=!0)}if(mt)continue}if(Ze.some(Sn)||ot&&ot.some(Sn)||vt&&vt.some(Sn))continue;let Xt=Qn(ot||Ze),Lt=Qn(vt||Ze);if((!ot||Zt(Ze,ot))&&(!vt||Zt(Ze,vt))&&!(ot&&Un(Xt)))continue;let qt=ht({base:Qn(Ze),sourceRetentions:nt?.get(C),local:Xt,remote:Lt,out:ae,policy:Ge,blocks:qe,scopeUnits:Rt?[Ze,ot||Ze,vt||Ze]:null,certifiedOrigins:Rt?(Tt,mt,St,Qt,eo,Nn)=>fl({certificates:Rt,scopes:[Ze,ot||Ze,vt||Ze],flats:[Tt,mt,St],keys:[Qt,eo,Nn]}):null,prepared:He?He.prepared:null,nativeTransfers:He,L:ot?H:ul(H,C),R:vt?q:ul(q,C),idOf:{base:y,local:b,remote:S},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Tt,mt,St)=>j(Tt,mt,St,!1),cloneUnit:de,mergeAttrs:ie,atomKey:l.exactUnitKey,moveIn:E,moveBuilt:E,movePlanned:E,provenance:Ae,textMappers:_e,conflicts:N,conflict:yt,scope:{base:C,local:ce.asBase?null:ce.el,remote:re.asBase?null:re.el,units:Oe,at:ut.lo},decisions:ve,node:ye});if(!qt){if(Rt){let Tt=qi({certificates:Rt,scopes:[Ze,ot||Ze,vt||Ze],views:[{V:ce,A:H,idOf:g.local},{V:re,A:q,idOf:g.remote}],eligible:mt=>it(mt)&&Pn.has(mt.tagName)&&!r(mt)&&!o.remoteWins(mt),baseId:g.base});for(let mt of Tt.records){nt||=new Map;let St=nt.get(mt.source);St||nt.set(mt.source,St=[]),St.push(mt)}}continue}if(le.push(...qt.segments),He){let Tt=new Map;for(let mt of qt.nodes){let St=Ae.get(mt)?.base;if(!St||Tt.has(St))throw new Error("Invalid native transfer owner output");Tt.set(St,mt)}if(Tt.size!==He.owners.length)throw new Error("Incomplete native transfer owner output");for(let mt of He.owners){let St=Tt.get(mt.base);if(!St)throw new Error("Missing native transfer owner output");for(let Qt of[mt.base,mt.local,mt.remote])oe.add(Qt),bt.add(Qt),tt.set(Qt,St);lt.push({frag:St,at:We.get(mt.base)})}continue}if(Je&&Zn(Ze,ot||Ze,vt||Ze,qt.nodes),qt.unitOutputs){ze||=new Map;for(let mt of[...Ze,...ot||[],...vt||[]]){let St=qt.unitOutputs.get(mt)||[];oe.add(mt),bt.add(mt),ze.set(mt,St),St.length&&tt.set(mt,St[St.length-1])}let Tt=qt.nodes[qt.nodes.length-1];if(Tt)for(let mt of[ot||Ze,vt||Ze]){let St=mt[mt.length-1];St&&At.set(St,Tt)}for(let mt=0;mt<qt.nodes.length;mt++)lt.push({frag:qt.nodes[mt],at:ut.lo,previous:mt>0?qt.nodes[mt-1]:null});continue}Je&&Zn(Ze,ot||Ze,vt||Ze,qt.nodes);let tn=ae.createDocumentFragment();for(let Tt of qt.nodes)tn.appendChild(Tt);for(let Tt of[...Ze,...ot||[],...vt||[]])oe.add(Tt),bt.add(Tt),tt.set(Tt,tn);lt.push({frag:tn,at:ut.lo})}}}function te(C,G){let se=Ae.get(C);return se&&se.unchanged?!se.remote||se.remote===G?!0:K(se.remote,G):C.tagName!==G.tagName||!Ie(C,G)?!1:Le(xe(C),xe(G))}function K(C,G){return C===G?!0:C.tagName!==G.tagName||C.namespaceURI!==G.namespaceURI||!Ie(C,G)?!1:ne(xe(C),xe(G))}function ne(C,G){let se=ke(C,r),me=ke(G,r);if(se.length!==me.length)return!1;for(let ye=0;ye<se.length;ye++){let ce=se[ye],re=me[ye];if(typeof ce=="string"||typeof re=="string"){if(ce!==re)return!1}else{if(ce.nodeType!==re.nodeType)return!1;if(ce.nodeType===1){if(!K(ce,re))return!1}else if(ce.nodeValue!==re.nodeValue)return!1}}return!0}function xe(C){return C.tagName==="TEMPLATE"&&C.content?C.content:C}function Ie(C,G){let se=0;for(let me of C.attributes)if(!o.ignoreAttribute(C,me.name)&&(se++,G.getAttribute(me.name)!==me.value))return!1;for(let me of G.attributes)o.ignoreAttribute(G,me.name)||se--;return se===0}function Le(C,G){let se=ke(C,ye=>{let ce=Ae.get(ye);return!!(ce&&ce.pinned)}),me=ke(G,r);if(se.length!==me.length)return!1;for(let ye=0;ye<se.length;ye++){let ce=se[ye],re=me[ye];if(typeof ce=="string"||typeof re=="string"){if(ce!==re)return!1}else{if(ce.nodeType!==re.nodeType)return!1;if(ce.nodeType===1){if(!te(ce,re))return!1}else if(ce.nodeValue!==re.nodeValue)return!1}}return!0}function ke(C,G){let se=[],me=null;for(let ye=C.firstChild;ye;ye=ye.nextSibling){if(ye.nodeType===3){me=me===null?ye.nodeValue:me+ye.nodeValue;continue}ye.nodeType===1&&G(ye)||(me!==null&&(me!==""&&se.push(me),me=null),se.push(ye))}return me!==null&&me!==""&&se.push(me),se}function $e(C,G,se,me){let ye=C.value,ce=me?ye:G?G.value:"",re=se?se.value:"";oe.add(C),G&&oe.add(G),se&&oe.add(se);let Oe=ce===re?ce:ce===ye?re:re===ye||Ge==="local"?ce:re,Pe={site:"comment",bRun:C,lRun:G,rRun:se,node:null};if(ce!==ye&&re!==ye&&ce!==re&&yt({kind:"text",node:null,base:ye,local:ce,remote:re,resolved:Oe},Pe),!G&&!se)return null;let We=ae.createComment(Oe);return Pe.node=We,Ae.set(We,{base:C.nodes,local:G?G.nodes:null,remote:se?se.nodes:null}),We}function Xe(C,G){let se=h(G,C);if(!se)return null;let me=it(se)?se.parentNode:se.parent,ye=it(C)?C.parentNode:C.parent;return h(G,ye)===me?null:G.reverse.get(me)||null}function Qe(C){let G=new Set([C]),se=C;for(let me=0;me<64;me++){let ye=Xe(se,H)||Xe(se,q);if(!ye)return!1;if(ye===C||it(C)&&it(ye)&&C.contains(ye)||G.has(ye))return!0;G.add(ye),se=ye}return!0}function Ut(C,G,se){if(!G)return!1;let me=it(C)?C.parentNode:C.parent;return me===G||G.tagName==="TEMPLATE"&&me===G.content}function Pt(C,G){let se=je(C),me=h(H,se);if(me&&Ut(G,me,H))return!0;let ye=h(q,se);return!!(ye&&Ut(G,ye,q))}}function ul(e,t){return e.map.get(t)?dl():{map:{get:o=>o&&o.nodeType===1&&e.map.get(o)||o,has:()=>!0},reverse:{get:o=>e.reverse.get(o)||o,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function dl(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var hl=new Set(["INPUT","OPTION","TEXTAREA"]),Os=/[\t\n\f\r ]+/;function pl(e,t,n,o){let r=e.ownerDocument,{provenance:c,textMappers:l}=n,s=o.hooks,i=[],a=[],p=[],f=new Set,u=[],y=[],b=new Map,S=new Set,g=new Map,d=n.conflicts.length>0||o.trackInserted===!0,w=new Map,O=new Set,T=new Map,k=(h,E)=>{let R=T.get(h);R||T.set(h,R=new Set),R.add(E)},v=d?new Set:null,I=(h,E,R)=>{let V=s.beforeAttributeUpdated(h,E,R);return d&&V===!1&&k(E,h),V},M=h=>!!h&&(h===e||e.contains(h)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(h)),P=new Map,D=new Map,$=new Map,W=new Set,B=new Map;(function h(E){let R=c.get(E);if(R){if(E.nodeType===1){let Q=R.local?o.toLive(R.local):null;Q&&M(Q)&&Q.nodeType===1&&(P.set(E,Q),D.set(Q,E))}else if(Array.isArray(R.local)){let Q=q(R.local,R.local.map(j=>o.toLive(j)).filter(j=>j&&M(j)&&j.nodeType===E.nodeType));if(Q.length&&(P.set(E,Q[0]),D.set(Q[0],E),$.set(E,Q)),Array.isArray(R.caret))for(let j of R.caret){let ue=o.toLive(j.node);if(!ue||!M(ue)||ue.nodeType!==3)continue;let be=B.get(ue);Array.isArray(be)||B.set(ue,be=[]),be.push({merged:E,from:j.from,to:j.to,flatStart:j.flatStart})}else{let j=0;for(let ue of Q)B.set(ue,{merged:E,shift:j}),j+=ue.nodeValue.length}}}let V=E.nodeType===1&&E.tagName==="TEMPLATE"&&E.content?E.content.childNodes:E.childNodes;for(let Q of V)h(Q)})(t);let x=new Set;for(let h of P.values())x.add(h);for(let h of $.values())for(let E of h)x.add(E);let A=o.localRoot&&o.localRoot!==e?new Set:null;if(A){for(let h=o.localRoot.firstElementChild;h;h=h.nextElementSibling)if(h.tagName==="HEAD")for(let E=h.firstElementChild;E;E=E.nextElementSibling){let R=o.toLive(E);R&&A.add(R)}}for(let h of n.segments||[])Ee(h);let X=o.restoreFocus===!1?null:Ia(r,B);o.childrenOnly?Ae(Me(e),Me(t)):je(e,t);for(let{node:h,parent:E}of u)f.has(h)||!h.parentNode||h.nodeType===1&&(o.ignored(h)||_e(h))||nt(h,E);return Ca(r,X,B,l,$,g,W),{applied:i,moved:a,replaced:p,identities:y,mergedScriptsLive:S,liveOf:P,heldBy:g,runOf:$,keptRuns:W,insertedLive:w,vetoed:O,vetoedAttrs:T,removedVetoes:v};function H(h,E){let R=h.slice(E.bs,E.be),V=0;for(;V<R.length&&V<E.text.length&&R[V]===E.text[V];)V++;let Q=0;for(;Q<R.length-V&&Q<E.text.length-V&&R[R.length-1-Q]===E.text[E.text.length-1-Q];)Q++;return{bs:E.bs+V,be:E.be-Q,text:E.text.slice(V,E.text.length-Q)}}function q(h,E){if(!E.length)return E;let R=[];for(let j of h){let ue=j.parentNode;if(!ue)continue;let be=b.get(ue);if(!be){be=new Set;for(let ie=ue.firstChild;ie;ie=ie.nextSibling)ie.nodeType===3&&be.add(o.toLive(ie));b.set(ue,be)}R.includes(be)||R.push(be)}let V={has:j=>R.some(ue=>ue.has(j))},Q=[];for(let j of E){Q.push(j);for(let ue=j.nextSibling;ue&&ue.nodeType===3&&!V.has(ue)&&!Q.includes(ue);ue=ue.nextSibling)Q.push(ue)}return Q}function Ee(h){let E=[];for(let ee of h.localNodes){let te=o.toLive(ee.node);if(!te||!M(te)||te.nodeType!==3)return;E.push(te)}let R=q(h.localNodes.map(ee=>ee.node),E);if(!R.length)return;let V=R.map(ee=>ee.nodeValue).join(""),{flatLocal:Q,lToM:j,mapLocal:ue}=h;if(V===Q)return;let be=h.textNodes.map(ee=>({node:ee.node,ms:ee.ms,me:ee.me})),ie=[],Ne=0;for(let ee of R)ie.push(Ne),Ne+=ee.nodeValue.length;let U=(ee,te)=>R.find((K,ne)=>ie[ne]<=ee&&ee+te<=ie[ne]+K.nodeValue.length)||null,Y=[],he=0;for(let ee of ao(Q,V).map(te=>H(Q,te))){let te=ee.bs+he;he+=ee.text.length-(ee.be-ee.bs);let K,ne;if(ee.be>ee.bs){K=j[ee.bs];let xe=K>=0;for(let Ie=ee.bs;xe&&Ie<ee.be;Ie++)j[Ie]!==K+(Ie-ee.bs)&&(xe=!1);if(!xe)continue;ne=K+(ee.be-ee.bs)}else{let xe=ee.bs>0?j[ee.bs-1]:0,Ie=ee.bs<Q.length?j[ee.bs]:0;if(xe<0||Ie<0)continue;K=ne=ue(ee.bs)}Y.push({ms:K,me:ne,text:ee.text,live:ne===K?U(te,ee.text.length):null})}Y.sort((ee,te)=>te.ms-ee.ms);let ge=(ee,te)=>($.get(ee.node)||[P.get(ee.node)]).includes(te),de=ee=>!!ee&&ee.nodeType===1&&An.has(ee.tagName);for(let ee of Y){let te=be.find(ne=>ne.ms<=ee.ms&&ee.me<=ne.me&&ee.ms<ne.me);if(te&&ee.live&&te.ms===ee.ms&&!ge(te,ee.live)){let ne=be.find(xe=>xe.me===ee.ms&&ge(xe,ee.live));ne&&(te=ne)}if(!te&&ee.me===ee.ms){let ne=be.find(ke=>ke.me===ee.ms),xe=be.find(ke=>ke.ms===ee.ms),Ie=ne||xe;if(!Ie)continue;let Le=Ie.node;for(;de(Le.parentNode)&&(ne?Le.parentNode.lastChild:Le.parentNode.firstChild)===Le;)Le=Le.parentNode;if(Le===Ie.node)te=Ie;else{let ke=Le.ownerDocument.createTextNode(ee.text);Le.parentNode.insertBefore(ke,ne?Le.nextSibling:Le);continue}}if(!te)continue;let K=te.node.nodeValue;te.node.nodeValue=K.slice(0,ee.ms-te.ms)+ee.text+K.slice(ee.me-te.ms),te.me+=ee.text.length-(ee.me-ee.ms)}}function Me(h){return h.nodeType===1&&h.tagName==="TEMPLATE"&&h.content?h.content:h}function je(h,E){f.add(h);let R=c.get(E);if(R&&R.remote&&n.remoteIdOf){let Q=n.remoteIdOf(R.remote);Q&&y.push([h,Q])}if(R&&R.unchanged){o.opaque&&o.opaque(h)||(n.customIdentity&&R.remote&&le(h,R.remote),R.remote&&J(h,R.remote));return}if(s.beforeNodeMorphed(h,E)===!1){O.add(E);return}It(h,E,o.keepLiveOnly&&R&&R.local&&R.local.nodeType===1&&R.local!==h?R.local:null);let V=h.tagName;if(mn(h))h.textContent!==E.textContent&&(i.push({kind:"text",node:h,before:h.textContent,after:E.textContent}),h.textContent=E.textContent),n.mergedScripts.has(E)&&S.add(h);else if(V==="TEXTAREA")z(h,E,R);else{Yt(h,E,R);let Q=V==="TEMPLATE"&&h.content?h.content:h,j=V==="TEMPLATE"&&E.content?E.content:E;o.opaque&&o.opaque(h)||o.protectFocusedValue==="subtree"&&Nt(h)&&h!==r.body?ae(Q):Ae(Q,j)}s.afterNodeMorphed(h,E)}function ae(h){for(let E=h.firstChild;E;E=E.nextSibling){let R=D.get(E);R&&P.get(R.parentNode)!==h||(f.add(E),E.nodeType===1&&ae(E))}}function Ae(h,E){let R=Be(h.firstChild),V=new Set;for(let Q of Array.from(E.childNodes)){let j=P.get(Q);j&&f.has(j)&&!V.has(j)&&(j=null);let ue=c.get(Q);if(ue&&ue.pinned){j&&j.nodeType===1&&((j.parentNode!==h||Be(j.nextSibling)!==R)&&Se(h,j,R),f.add(j),V.add(j));continue}if(j&&j.nodeType===1){if(j!==R){let Ne=j.parentNode;if(Ne===h&&R&&Ct(j)){let U=j.nextSibling;for(let Y=R;Y&&Y!==j;){let he=Y.nextSibling;Se(h,Y,U),Y=he}}else Se(h,j,R),Ne!==h&&(a.push(j),i.push({kind:"move",el:j,from:Ne,to:h}))}V.add(j),je(j,Q),R=Be(j.nextSibling);continue}if(j&&j.nodeType!==1){let Ne=$.get(Q)||[j],U=Ne.map(he=>he.nodeValue).join(""),Y=Q.nodeValue;if(Q.nodeType===3){let he=ve(Q);he!=null&&U!==he&&(Y=$o(he,U,Q.nodeValue).text)}if(Ne.length>1&&U===Y&&!Ne.includes(R,1)&&Ne.every((he,ge)=>he.parentNode===h&&(ge===0||Ne[ge-1].nextSibling===he))){if(j!==R)for(let he of Ne)Se(h,he,R);s.beforeNodeMorphed(j,Q)!==!1?s.afterNodeMorphed(j,Q):d&&O.add(Q);for(let he of Ne)f.add(he),V.add(he);g.set(Q,j),W.add(Q),R=Be(Ne[Ne.length-1].nextSibling);continue}j!==R&&Se(h,j,R),s.beforeNodeMorphed(j,Q)!==!1?(j.nodeValue!==Y&&(i.push({kind:"text",node:j,before:j.nodeValue,after:Y}),j.nodeValue=Y),s.afterNodeMorphed(j,Q)):O.add(Q),f.add(j),V.add(j),g.set(Q,j),R=Be(j.nextSibling);continue}if(Q.nodeType===3&&R&&R.nodeType===3&&!f.has(R)&&!B.has(R)){R.nodeValue!==Q.nodeValue&&(i.push({kind:"text",node:R,before:R.nodeValue,after:Q.nodeValue}),R.nodeValue=Q.nodeValue),f.add(R),g.set(Q,R),R=Be(R.nextSibling);continue}let be=c.get(Q),ie=Je(be&&be.unchanged&&be.remote?be.remote:Q);if(s.beforeNodeAdded(ie)===!1){O.add(Q);continue}h.insertBefore(ie,R),f.add(ie),d&&w.set(Q,ie),ie.nodeType===3&&g.set(Q,ie),ie.nodeType===1&&(p.push(ie),Re(ie,Q),n.customIdentity&&be&&be.unchanged&&be.remote&&le(ie,be.remote),mn(ie)||ht(ie,Q),o.formState==="property"&&ln(be)&&J(ie,be.remote)),R=Be(ie.nextSibling),i.push({kind:"insert",node:ie,parent:h}),s.afterNodeAdded(ie)}for(let Q of Array.from(h.childNodes))f.has(Q)||V.has(Q)||Q.nodeType===1&&(o.ignored(Q)||_e(Q))||(x.has(Q)?u.push({node:Q,parent:h}):nt(Q,h))}function _e(h){return h.parentNode&&h.parentNode.nodeType===1&&h.parentNode.tagName==="HEAD"&&(A&&!A.has(h)||o.preserve&&o.preserve(h)===!0)}function ve(h){let E=c.get(h);return!E||!Array.isArray(E.local)?null:E.local.map(R=>R.nodeValue).join("")}function N(h){return c.get(h)}function J(h,E){if(!hl.has(h.tagName)&&!h.querySelector("input,option,textarea"))return;let R=(V,Q)=>{if(V.tagName!==Q.tagName||(V.tagName==="TEXTAREA"?z(V,Q,{remote:Q}):hl.has(V.tagName)&&Yt(V,Q,{remote:Q}),o.opaque&&o.opaque(V)))return;let j=oe(V),ue=oe(Q);if(j.length===ue.length)for(let be=0;be<j.length;be++)R(j[be],ue[be])};R(h,E)}function le(h,E){if(o.opaque&&o.opaque(h))return;let R=oe(h),V=oe(E);if(R.length===V.length)for(let Q=0;Q<R.length;Q++){let j=n.remoteIdOf(V[Q]);j&&y.push([R[Q],j]),le(R[Q],V[Q])}}function oe(h){let E=h.tagName==="TEMPLATE"&&h.content?h.content:h;return Array.from(E.children).filter(R=>!o.ignored(R))}function Re(h,E){if(!n.remoteIdOf)return;let R=(V,Q)=>{let j=c.get(Q);if(j&&j.remote&&Q.nodeType===1){let ie=n.remoteIdOf(j.remote);ie&&y.push([V,ie])}let ue=V.childNodes,be=Q.childNodes;for(let ie=0;ie<ue.length&&ie<be.length;ie++)R(ue[ie],be[ie])};R(h,E)}function Be(h){for(;h&&h.nodeType===1&&o.ignored(h);)h=h.nextSibling;return h}function Se(h,E,R){if(typeof h.moveBefore=="function"&&E.ownerDocument===h.ownerDocument)try{h.moveBefore(E,R);return}catch{}h.insertBefore(E,R)}function nt(h,E){if(s.beforeNodeRemoved(h)===!1){d&&v.add(h);return}h.parentNode.removeChild(h),i.push({kind:"remove",node:h,parent:E}),s.afterNodeRemoved(h)}function Je(h){if(mn(h))return Go(h,r);let E=r.importNode(h,!0);if(E.nodeType===1)for(let R of Array.from(E.querySelectorAll("script")))mn(R)&&R.replaceWith(Go(R,r));return E}function ht(h,E){let R=h.tagName==="TEMPLATE"&&h.content?h.content:h,V=E.tagName==="TEMPLATE"&&E.content?E.content:E,Q=Array.from(R.childNodes),j=Array.from(V.childNodes);for(let ue=0;ue<j.length&&ue<Q.length;ue++){let be=j[ue],ie=Q[ue],Ne=P.get(be);Ne&&f.has(Ne)&&(Ne=null);let U=c.get(be);if(U&&U.pinned){if(Ne&&Ne.nodeType===1){let Y=Ne.parentNode;Se(R,Ne,ie),Y!==R&&(a.push(Ne),i.push({kind:"move",el:Ne,from:Y,to:R})),f.add(Ne)}ie.remove();continue}if(Ne){let Y=Ne.parentNode;Se(R,Ne,ie),ie.remove(),Ne.nodeType===1?(Y!==R&&(a.push(Ne),i.push({kind:"move",el:Ne,from:Y,to:R})),je(Ne,be)):(f.add(Ne),g.set(be,Ne),Ne.nodeValue!==be.nodeValue&&(i.push({kind:"text",node:Ne,before:Ne.nodeValue,after:be.nodeValue}),Ne.nodeValue=be.nodeValue));continue}f.add(ie),d&&w.set(be,ie),ie.nodeType===3&&g.set(be,ie),U&&U.unchanged&&U.remote?(Ge(ie,U.remote),n.customIdentity&&le(ie,U.remote)):be.nodeType===1&&!mn(be)&&ht(ie,be)}}function Ge(h,E){let R=h.tagName==="TEMPLATE"&&h.content?h.content:h,V=E.tagName==="TEMPLATE"&&E.content?E.content:E;for(let Q of Array.from(V.childNodes))R.appendChild(Je(Q))}function st(h,E){return E.namespaceURI?h.getAttributeNS(E.namespaceURI,E.localName):h.getAttribute(E.name)}function Mt(h,E){let R=new Set((E||"").split(Os).filter(Boolean));return(h||"").split(Os).filter(V=>V&&!R.has(V))}function It(h,E,R){for(let V of Array.from(E.attributes)){if(yt(h,V.name)||o.ignoreAttribute(h,V.name,E))continue;let Q=st(h,V);if(Q===V.value||R&&st(R,V)===V.value)continue;let j=V.value;if(R&&V.name==="class"&&!V.namespaceURI){let ue=V.value.split(Os).filter(Boolean),be=Mt(Q,R.getAttribute("class")).filter(ie=>!ue.includes(ie));be.length&&(j=[...ue,...be].join(" "))}if(Q!==j){if(s.beforeAttributeUpdated(V.name,h,"update")===!1){d&&k(E,V.name);continue}V.namespaceURI?h.setAttributeNS(V.namespaceURI,V.name,j):h.setAttribute(V.name,j),i.push({kind:"attr",el:h,name:V.name,before:Q,after:j})}}for(let V of Array.from(h.attributes)){if(yt(h,V.name)||o.ignoreAttribute(h,V.name,E)||(V.namespaceURI?E.hasAttributeNS(V.namespaceURI,V.localName):E.hasAttribute(V.name)))continue;if(R&&V.name==="class"&&!V.namespaceURI){let ue=Mt(V.value,R.getAttribute("class"));if(ue.length){let be=ue.join(" ");if(be===V.value)continue;if(s.beforeAttributeUpdated("class",h,"update")===!1){d&&k(E,"class");continue}h.setAttribute("class",be),i.push({kind:"attr",el:h,name:"class",before:V.value,after:be});continue}}if(R&&st(R,V)===null)continue;if(s.beforeAttributeUpdated(V.name,h,"remove")===!1){d&&k(E,V.name);continue}let j=V.value;V.namespaceURI?h.removeAttributeNS(V.namespaceURI,V.localName):h.removeAttribute(V.name),i.push({kind:"attr",el:h,name:V.name,before:j,after:null})}}function yt(h,E){let R=h.tagName;return R==="INPUT"?E==="value"||E==="checked"||E==="disabled":R==="OPTION"?E==="selected":!1}function Nt(h){return h===r.activeElement}function Ct(h){let E=r.activeElement;return!!E&&E!==r.body&&h.contains(E)}function _t(h,E){let R=E&&E.local&&E.local.nodeType===1&&E.local!==h?E.local:null;if(!R)return!0;let V=h.tagName==="TEXTAREA"?R.textContent:R.getAttribute("value")??"";return h.value!==V}function fn(h,E){return!!o.protectFocusedValue&&Nt(h)&&_t(h,E)}function Et(h,E,R){let V=Math.min(h.length,E.length),Q=0;for(;Q<V&&h[Q]===E[Q];)Q++;if(R<=Q)return R;let j=0;for(;j<V-Q&&h[h.length-1-j]===E[E.length-1-j];)j++;return R>=h.length-j?R+E.length-h.length:E.length-j}function Gt(h){try{return h.selectionStart==null?null:[h.selectionStart,h.selectionEnd,h.selectionDirection]}catch{return null}}function wn(h,E,R,V){try{h.setSelectionRange(Et(E,R,V[0]),Et(E,R,V[1]),V[2]||"none")}catch{}}function Bt(h,E){let R=h.value,V=Gt(h);h.value=E,V&&wn(h,R,E,V)}function ln(h){let E=h&&h.remote;return E&&E.nodeType===1?E:null}function Yt(h,E,R){let V=h.tagName,Q=ln(R),j=o.formState==="property"&&Q?Q:E;if(V==="INPUT"){let ue=fn(h,R),be=(h.getAttribute("type")||"").toLowerCase(),ie=be!=="file"&&be!=="checkbox"&&be!=="radio",Ne=Q&&Q.hasAttribute("value")&&Q.value!==Q.getAttribute("value")?Q.value:null;if(ie&&!ue)if(o.formState==="property"){let U=E.getAttribute("value"),Y=h.getAttribute("value");(Y!==U||h.value!==j.value)&&I("value",h,U==null?"remove":"update")!==!1&&(Y!==U&&(U==null?h.removeAttribute("value"):h.setAttribute("value",U),i.push({kind:"attr",el:h,name:"value",before:Y,after:U})),h.value!==j.value&&(Nt(h)?Bt(h,j.value):h.value=j.value))}else if(E.hasAttribute("value")||Ne!=null){let U=Ne??E.getAttribute("value");h.getAttribute("value")!==U&&I("value",h,"update")!==!1?(h.setAttribute("value",U),h.value!==U&&(Nt(h)?Bt(h,U):h.value=U),i.push({kind:"attr",el:h,name:"value",before:null,after:U})):h.value!==U&&h.getAttribute("value")===U&&(Nt(h)?Bt(h,U):h.value=U)}else(h.hasAttribute("value")||h.value!=="")&&I("value",h,"remove")!==!1&&(h.removeAttribute("value"),h.value="",i.push({kind:"attr",el:h,name:"value",before:"",after:null}));if(!ie&&be!=="file"){let U=E.getAttribute("value");U==null?h.hasAttribute("value")&&I("value",h,"remove")!==!1&&h.removeAttribute("value"):h.getAttribute("value")!==U&&I("value",h,"update")!==!1&&h.setAttribute("value",U)}o.protectFocusedValue&&Nt(h)||(un(h,j,"checked"),o.formState==="property"&&h.indeterminate!==j.indeterminate&&(h.indeterminate=j.indeterminate)),un(h,j,"disabled")}else if(V==="OPTION"){let ue=h.parentNode&&h.closest("select");o.protectFocusedValue&&ue&&Nt(ue)||un(h,j,"selected")}}function un(h,E,R){if(o.ignoreAttribute(h,R,E))return;let V=o.formState==="property"?!!E[R]:E.hasAttribute(R);if(o.formState!=="property"){let Q=h.hasAttribute(R);if(Q!==V){if(I(R,h,V?"update":"remove")===!1)return;V?h.setAttribute(R,""):h.removeAttribute(R),i.push({kind:"attr",el:h,name:R,before:Q?"":null,after:V?"":null})}}h[R]!==V&&(h[R]=V)}function z(h,E,R){if(fn(h,R)||I("value",h,"update")===!1)return;let V=ln(R),Q=E.textContent,j=V&&V.value!==V.defaultValue?V.value:Q,ue=Nt(h)?Gt(h):null,be=h.value;o.formState!=="property"&&h.textContent!==Q&&(i.push({kind:"text",node:h,before:h.textContent,after:Q}),h.textContent=Q),h.value!==j&&(h.value=j),ue&&h.value!==be&&wn(h,be,h.value,ue)}}function Ia(e,t){let n=e.activeElement;if(!n||n===e.body||n===e.documentElement)return null;let o={el:n,id:n.getAttribute&&n.getAttribute("id"),scrollTop:n.scrollTop,scrollLeft:n.scrollLeft};if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"){try{o.selection=[n.selectionStart,n.selectionEnd,n.selectionDirection]}catch{}return o}let r=e.getSelection&&e.getSelection();if(r&&r.rangeCount){let c=r.getRangeAt(0);o.range={sc:c.startContainer,so:c.startOffset,ec:c.endContainer,eo:c.endOffset}}return o}function Ca(e,t,n,o,r,c,l){if(!t)return;let s=t.el;if(!s.isConnected&&t.id&&(s=e.getElementById(t.id)),!s||!s.isConnected)return;if(e.activeElement!==s)try{s.focus({preventScroll:!0})}catch{}try{s.scrollTop=t.scrollTop,s.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{s.setSelectionRange&&!s.selectionEnd&&t.selection[1]!=null&&s.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let i=(f,u)=>{let y=n.get(f);if(Array.isArray(y)){let b=y.find(w=>u>=w.from&&u<w.to)||y.find(w=>u===w.to)||y[y.length-1],S=c.get(b.merged);if(!S||!S.isConnected)return null;let g=o.get(b.merged),d=g&&g.flat?g.flat(b.flatStart+u):u;return[S,Math.max(0,Math.min(d,S.nodeValue.length))]}if(y&&!l.has(y.merged)){let b=(r.get(y.merged)||[f])[0];if(!b.isConnected)return null;let S=o.get(y.merged),g=y.shift+u,d=S?S(g):g;return[b,Math.max(0,Math.min(d,b.nodeValue.length))]}return f.isConnected?[f,Math.min(u,f.nodeType===3?f.nodeValue.length:f.childNodes.length)]:null},a=i(t.range.sc,t.range.so),p=i(t.range.ec,t.range.eo);if(!(!a||!p))try{let f=e.createRange();f.setStart(a[0],a[1]),f.setEnd(p[0],p[1]);let u=e.getSelection();u.removeAllRanges(),u.addRange(f)}catch{}}var Ra={compared:0},La=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Pa(e,t,n){let o=0;for(let r of e.attributes)if(!n(e,r.name)&&(o++,t.getAttribute(r.name)!==r.value))return!1;for(let r of t.attributes)n(t,r.name)||o--;return o===0}function Ms(e,t){if(e.namespaceURI!==t.namespaceURI||e.prefix!==t.prefix||e.localName!==t.localName)return!1;let n=e.attributes;if(n.length!==t.attributes.length)return!1;for(let o of n)if(t.getAttributeNS(o.namespaceURI,o.localName)!==o.value)return!1;return!0}function ml(e,t,n,o,r,c,l,s){let i=new Map,a=new Set,p=f=>{if(o(f))return;let u=n(f);u&&(c.add(u),r.has(u)||i.has(u)?a.add(u):i.set(u,f))};for(let f of e)p(f);p(t);for(let f of l||t.querySelectorAll("*"))p(f);for(let f of a)i.delete(f),s.add(f);return i}function gl(e,t,n,o,r,c){let l=!1;for(let p of r)p.startsWith("merge:")&&(l=!0);if(!l)return[...o];let s=new Map,i=[],a=c===kn?Xo:"*";for(let p of[e,...e.querySelectorAll(a)]){if(n(p))continue;let f=t(p);if(!f||!(o.has(f)||r.has(f)))continue;let u=(s.get(f)||0)+1;s.set(f,u),u===2&&i.push(f)}return i}function bl({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:o,o:r,identity:c,baseURI:l}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!Pa(e,t,r.ignoreAttribute))return{bail:"root-attrs"};let{ignored:s,remoteWins:i}=r,a=vs(r.scripts.merge===!1?null:r.scripts.mergeTags,l),p=ve=>{let N=a(ve);return N!==null?N:c.base(ve)||null},f=ve=>{let N=a(ve);return N!==null?N:c.remote(ve)||null},u=[],y=[],b=new Map,S=new Map,g={same:b,differ:S},d=ve=>({bail:ve,comparisons:g}),w=(ve,N,J=!0)=>{if(b.get(ve)===N)return!0;if(S.get(ve)===N)return!1;if(Ra.compared++,J&&ve.isEqualNode(N))return b.set(ve,N),!0;let le=ve.nodeType===N.nodeType;if(le&&ve.nodeType===1){if(le=Ms(ve,N),le){let oe=ve.firstChild,Re=N.firstChild;for(;oe&&Re;oe=oe.nextSibling,Re=Re.nextSibling)if(!w(oe,Re,!1)){le=!1;break}(oe||Re)&&(le=!1)}}else le&&(le=ve.isEqualNode(N));return(le?b:S).set(ve,N),le},O=e,T=t,k=!1,v=()=>{b.set(O,T);for(let ve=0;ve<u.length;ve++)b.set(u[ve],y[ve]);return d("equal")};for(;;){let ve=O.childNodes,N=T.childNodes;if(ve.length!==N.length)break;let J=Je=>w(ve[Je],N[Je])?(b.set(ve[Je],N[Je]),!1):!0,le=-1,oe=-1;for(let Je=0;Je<ve.length;Je++){if(ve[Je].nodeType!==1)continue;let ht=0;for(let Ge=ve[Je].firstElementChild;Ge;Ge=Ge.nextElementSibling)ht++;ht>=oe&&(oe=ht,le=Je)}let Re=[],Be=!1;for(let Je=0;Je<ve.length&&Re.length<2;Je++)Je!==le&&J(Je)&&Re.push(Je);if(le>=0&&Re.length<2&&(Re.length===0&&Ms(O,T)?(Re.push(le),Be=!0):J(le)&&Re.push(le)),Re.length!==1){if(!k&&Re.length===0&&Ms(O,T))return v();break}let Se=ve[Re[0]],nt=N[Re[0]];if(k=k||!Be,k&&S.set(Se,nt),Se.nodeType!==1||nt.nodeType!==1||Se.tagName!==nt.tagName)break;if(p(Se)!==f(nt)){if(!k&&w(Se,nt))return v();break}u.push(O),y.push(T),O=Se,T=nt}S.set(O,T);for(let ve=0;ve<u.length;ve++)S.set(u[ve],y[ve]);if(O===e||O.tagName==="HEAD"||O.tagName==="BODY")return d("root-level");if(u.length<2||u[1].tagName!=="BODY")return d("not-in-body");if(s(O)||s(T))return d("ignored-ancestor");if(i(O)||i(T))return d("remote-wins-ancestor");for(let ve of u)if(La.has(ve.tagName))return d("form-ancestor");if(O.tagName==="SCRIPT"||O.getElementsByTagName("script").length||T.getElementsByTagName("script").length)return d("script-or-template");let I=o(O);if(!I||I.nodeType!==1||I.tagName!==O.tagName)return d("no-live-twin");if(!n.contains(I))return d("live-detached");for(let ve of u){let N=o(ve);if(!N||N.nodeType!==1)return d("ancestor-live")}let M=c.base===kn&&c.remote===kn&&s===Jr,P=new Set,D=new Set,$=[],W=null,B=ve=>{ve&&(P.has(ve)?D.add(ve):P.add(ve))},x=(ve,N)=>{let J=a(ve),le=J!==null?J:c.base(ve)||null;return le!==(J!==null?J:c.remote(N)||null)?!1:(B(le),!0)},A=(ve,N)=>{for(let J=ve.firstElementChild,le=N.firstElementChild;J;J=J.nextElementSibling,le=le.nextElementSibling){let oe=s(J);if(oe!==s(le))return!1;if(!oe&&(!x(J,le)||!A(J,le)))return!1}return!0},X=ve=>{let N=ve+1<u.length?u[ve+1]:O;for(let J=u[ve].firstElementChild,le=y[ve].firstElementChild;J;J=J.nextElementSibling,le=le.nextElementSibling){if(J===N){let Be=ve+1<u.length?X(ve+1):null;if(Be)return Be;continue}let oe=s(J);if(oe!==s(le))return"outside-id-changed";if(oe)continue;let Re=o(J);if(!Re||Re.nodeType!==1)return"sibling-live";if($.push([J,le]),!M&&(!x(J,le)||!A(J,le)))return"outside-id-changed";ve===0&&J.tagName==="HEAD"&&p(J)&&(W=[J,le])}return null},H=X(0);if(H)return d(H);let q=new Set(u),Ee=null;if(c.base===kn){Ee=[];for(let ve of e.querySelectorAll(Xo))ve===O||q.has(ve)||(O.contains(ve)?Ee.push(ve):M&&B(p(ve)))}let Me=new Set,je=new Set,ae=new Set,Ae=ml(u,O,p,s,P,Me,Ee,je),_e=ml(y,T,f,s,P,Me,c.remote===kn&&T.querySelectorAll(Xo),ae);return W&&(D.has(p(W[0]))||Me.has(p(W[0])))&&(W=null),{scope:{chain:u,root:O,onChain:q,baseIndex:Ae,remoteIndex:_e,baseDropped:je,remoteDropped:ae,head:W,same:b,differ:S,dropped:[...gl(e,p,s,D,je,c.base),...gl(t,f,s,D,ae,c.remote)],held:ve=>{for(let N=1;N<u.length;N++)if(ve.map.get(u[N])!==y[N])return!1;for(let[N,J]of $)if(ve.map.get(N)!==J)return!1;return!0}}}}var xd=Symbol("hyper-morph-duplicate-key");var ja='[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"]',Da='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Ba='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Ua(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let t=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(t)}function Ha(e,t,n,o){if(t==null)return;if(typeof t=="string")return t;let r=t;if(r.nodeType===9){let c=e.getAttribute("id");r=c&&r.getElementById(c)||(e.tagName==="BODY"?r.body:e.tagName==="HTML"?r.documentElement:r.body&&r.body.firstElementChild)}if((!r||r.nodeType!==1||r.tagName!==e.tagName)&&(r=Wa(e,t,o)),!!r)return n?Array.from(r.childNodes):r}function Wa(e,t,n){let o=t.nodeType===9?t.documentElement:t;if(!o||o.nodeType!==1)return null;let r=new Map,c=[o,...o.querySelectorAll("script")];for(let i of c){let a=Eo(i,n);a&&!r.has(a.key)&&r.set(a.key,i.textContent)}if(!r.size)return null;let l=e.cloneNode(!0),s=!1;for(let i of[l,...l.querySelectorAll("script")]){let a=Eo(i,n);a&&r.has(a.key)&&(i.textContent=r.get(a.key),s=!0)}return s?l:null}function yl(e,t){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let n=t.implementation.createHTMLDocument(""),o=e.nodeType===1&&e.tagName==="HTML"?e:null;if(o)return n.replaceChild(n.adoptNode(o),n.documentElement),n;let r=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let c of r)n.body.appendChild(n.adoptNode(c));return n}function Es(e,t,n={}){let o=n||{};if(!o.head?.block)return wl(e,t,o);try{return wl(e,t,o)}catch(r){return Promise.reject(r)}}function wl(e,t,n){let o=n.policy||"sync",r=o==="raw"?void 0:(i,a)=>Ua(i)||(o==="history"?!(a&&i.matches(Ba))&&i.matches(Da):i.matches(ja)),c=n.callbacks||{},l={ignore:r,hooks:c,protectFocusedValue:n.ignoreActiveValue===!0?"subtree":!1,restoreFocus:n.restoreFocus!==!1,formState:n.formStateSync||"attribute",scripts:{execute:n.scripts?.handle!==!1,merge:n.scripts?.merge!==!1,mergeTags:n.scripts?.mergeTags||[]},head:{awaitLoads:!!n.head?.block,preserve:n.head?.shouldPreserve||(()=>!1)}};if(typeof n.key=="function"&&(l.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return Zo(Object.assign({},l,{live:e,base:n.scripts?.mergeBase||null,remote:yl(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let i=Object.assign({},l,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:yl(t,e.ownerDocument)});return Zo(i)}n.morphStyle==="innerHTML"&&(l.children=!0);let s=Ha(e,n.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return s!==void 0&&(l.base=s),Is(e,t,l)}var Va=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),In=()=>{};function Qo(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let s of Object.keys(e))if(!Va.has(s))throw new TypeError(`unknown option "${s}"`);let n=Object.assign({beforeNodeAdded:In,afterNodeAdded:In,beforeNodeRemoved:In,afterNodeRemoved:In,beforeNodeMorphed:In,afterNodeMorphed:In,beforeAttributeUpdated:In},e.hooks||{}),o=e.conflicts||"remote";if(!["remote","local","both"].includes(o))throw new TypeError("conflicts must be remote, local or both");let r=e.formState||"attribute";if(!["attribute","property"].includes(r))throw new TypeError("formState must be attribute or property");let c=e.protectFocusedValue;if(c!==void 0&&typeof c!="boolean"&&c!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");let l=e.lineage;if(l!==void 0&&(!l||typeof l!="object"||typeof l.onResult!="function"||!l.elements||typeof l.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:Xr(e.ignore,t),remoteWins:Xr(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,opaque:typeof e.opaque=="function"?e.opaque:()=>!1,conflicts:o,protectFocusedValue:c===void 0?!0:c,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:r,hooks:n,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:l||null}}function Lo(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return kn}function Po(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=Zr(t,e.map),o=typeof e.then=="function"?e.then:kn;if(typeof e.first=="function"){let r=e.first;return c=>r(c)||n.get(c)||o(c)}return r=>n.get(r)||o(r)}return kn}function _a(e,t,n,o={}){let r=y=>y&&y.nodeType===9?y.documentElement:y,c=r(t),l=r(n),s=r(e)||c;if(o.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let i=Object.assign({},o);delete i.live,delete i.base,delete i.remote;let a=Qo(i,[s,c,l].filter(Boolean)),p=o.identity||{},f=no(),u=jr(s,c,l,{identity:{base:Po(p.base,s),local:Po(p.local,c),remote:Po(p.remote,l)},authored:{base:Lo(p.base),local:Lo(p.local),remote:Lo(p.remote)},skipUnchanged:a.hooks.beforeNodeMorphed===In&&a.hooks.afterNodeMorphed===In,ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:c.ownerDocument&&c.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:a.children,stats:f});return delete u.recoveryLinks,delete u.lineage,u}function Cs({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:o,toLive:r,options:c,identity:l,childrenOnly:s,isDocument:i}){let a=Qo(c,[e,t,n,o].filter(Boolean));if(a.ignored(e)){let x=Rs(),A=a.lineage?zo(a.lineage,e,x):null;return{report:x,loads:[],lineage:A}}let p=e.ownerDocument,f=a.lineage?gs(a.lineage,{liveRoot:e,localRoot:n,toLive:r}):null,u=a.scripts.execute?$i(e,a.ignored,p.baseURI):null,y=no(),b=a.hooks.beforeNodeMorphed===In&&a.hooks.afterNodeMorphed===In,S={identity:{base:Po(l.base,t||n),local:Po(l.local,n),remote:Po(l.remote,o)},authored:{base:Lo(l.base),local:Lo(l.local),remote:Lo(l.remote)},ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:p.baseURI,localIsBase:!t,childrenOnly:s,skipUnchanged:b,lineage:f?{locals:f.locals}:null},g=a.fastPath&&i&&!s&&b&&t===n,d=null,w=null;if(g){let x=bl({baseRoot:t,remoteRoot:o,liveRoot:e,toLive:r,o:a,identity:S.identity,baseURI:p.baseURI});S.comparisons=x.comparisons||x.scope,x.bail?w=x.bail:(d=jr(t,n,o,Object.assign({},S,{stats:y,scope:x.scope})),d||(w="chain-unpaired",y=no()))}d||(d=jr(t||n,n,o,Object.assign({},S,{stats:y}))),g&&(y.fastPathAttempted=1,y.fastPathTaken=w?0:1,y.fastPathFallback=w),d.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(x=>a.hooks[x]!==In)&&Qi(d.conflicts,d.recoveryLinks,r),a.beforeApply&&a.beforeApply(d.doc);let O=globalThis.__hyperMorphProfile,T=O?performance.now():0,k=pl(e,d.root,d,{toLive:r,localRoot:n,ignored:a.ignored,ignoreAttribute:a.ignoreAttribute,opaque:a.opaque,formState:a.formState,protectFocusedValue:a.protectFocusedValue,restoreFocus:a.restoreFocus,preserve:a.head.preserve,hooks:a.hooks,childrenOnly:s,keepLiveOnly:a.keepLiveOnly,trackInserted:!!f});O&&(O.apply=(O.apply||0)+(performance.now()-T));let v=[];if(a.head.awaitLoads)for(let x of k.applied){if(x.kind!=="insert"||x.node.nodeType!==1)continue;let A=x.node;A.tagName==="LINK"&&/\bstylesheet\b/i.test(A.getAttribute("rel")||"")&&A.getAttribute("href")&&A.closest("head")&&v.push(new Promise(H=>{A.addEventListener("load",()=>H()),A.addEventListener("error",()=>H())}))}let I=null,M=null;if(u){let x=Ki(e,u,{ignored:a.ignored,skip:k.mergedScriptsLive,baseURI:p.baseURI,beforeNodeAdded:a.hooks.beforeNodeAdded,afterNodeAdded:a.hooks.afterNodeAdded,trackRecovery:!!d.recoveryLinks});v.push(...x.loads),I=x.swapped,M=x.vetoed}let P=x=>I&&I.get(x)||x,D=x=>{if(k.keptRuns.has(x))return k.runOf.get(x);let A=k.liveOf.get(x)||k.heldBy.get(x)||k.insertedLive.get(x);return A?P(A):null},$=x=>{let A=x&&k.liveOf.get(x);return A?P(A):null},W=x=>{let A=x&&D(x);return Array.isArray(A)?A[0]:A};if(d.recoveryLinks){let x=(A,X,H)=>(X.namespaceURI?A.getAttributeNS(X.namespaceURI,X.localName):A.getAttribute(X.qualifiedName))===H;nl(d.conflicts,d.recoveryLinks,{lookup:D,vetoed:k.vetoed,vetoedAttrs:k.vetoedAttrs,removedVetoes:k.removedVetoes,vetoedLive:M,liveAttr:x,ignored:a.ignored,liveRoot:e})}let B={applied:k.applied,decisions:d.decisions.map(x=>Object.assign({},x,{node:x.node?$(x.node):null,el:x.el?$(x.el):null,applied:!!(x.node?$(x.node):x.el&&$(x.el))})),conflicts:d.conflicts.map(x=>Object.assign({},x,{node:x.node?x.kind==="text"&&x.recovery.subject.nodeType===8?W(x.node):$(x.node):x.node,el:x.el?x.kind==="structure"?W(x.el):$(x.el):x.el})),localDiverged:d.localDiverged,identities:k.identities,moved:k.moved,replaced:k.replaced,stats:y};return f&&(B.lineage=f.finish(d.lineage,D)),{report:B,loads:v,lineage:f}}var xl=new WeakMap;function Rs(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:no()}}function Zo(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");return t.lineage===void 0?kl(t):ms(t,t.live.documentElement,o=>kl(o))}function kl(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let o=xl.get(n);o||(o=Yr(n),xl.set(n,o));let r=o("remote",t.remote),c=typeof t.base=="string"&&t.base===""?null:t.base,l=c?o("base",c):null,s=t.local?t.local.root:n.documentElement,i=t.local?t.local.toLive:u=>u;di(n,r);let{report:a,loads:p,lineage:f}=Cs({liveRoot:n.documentElement,baseRoot:l?l.documentElement:null,localRoot:s,remoteRoot:r.documentElement,toLive:i,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return f?.deliver(a),Promise.all(p).then(()=>a)}function Fa(e,t,n={}){return Zo(Object.assign({},n,{live:e,base:null,remote:t}))}function Tl(e,t){if(e==null)return{root:t.createElement("template"),first:null};if(typeof e=="string"){let o=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(o){let c=Tr(e,t),l=o[1].toLowerCase()==="html"?c.documentElement:c.body;return{root:l,first:l}}let r=t.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let o=t.createElement("template"),r=e.isConnected;return o.content.appendChild(r?t.importNode(e,!0):e),{root:o,first:e}}if(e.nodeType===11){let o=t.createElement("template");return o.content.appendChild(e),{root:o,first:o.content.firstElementChild}}let n=t.createElement("template");for(let o of Array.from(e))n.content.appendChild(o.parentNode?t.importNode(o,!0):o);return{root:n,first:n.content.firstElementChild}}function Is(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return n.lineage===void 0?Al(e,t,n):ms(n,e,o=>Al(e,t,o))}function Al(e,t,n={}){let o=e.ownerDocument,{base:r,...c}=n,l=!!c.children,s=Qo(c,[e]);if(s.ignored(e)){let S=Rs();return s.lineage&&zo(s.lineage,e,S).deliver(S),Promise.resolve(S)}let i=Tl(t,o),a=r!=null?Tl(r,o):null,p,f=null;if(l)p=i.root,f=a?a.root:null;else{if(p=i.first,f=a?a.first:null,!p){let S=Qo(c),g=S.lineage?zo(S.lineage,e,{}):null;S.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),S.hooks.afterNodeRemoved(e));let d={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:no()};return g&&(d.lineage=g.result,g.deliver(d)),Promise.resolve(d)}if(p.tagName!==e.tagName){let S=Qo(c,[e,p]);if(S.hooks.beforeNodeMorphed(e,p)===!1){let w=Rs();return S.lineage&&zo(S.lineage,e,w).deliver(w),Promise.resolve(w)}let g=Cs({liveRoot:e,baseRoot:f&&f.tagName===e.tagName?f:null,localRoot:e,remoteRoot:p,toLive:w=>w,options:c,identity:c.identity||{},childrenOnly:!0,isDocument:!1}),d=mn(p)?Go(p,o):o.importNode(p,!1);if(!mn(d))for(;e.firstChild;)d.appendChild(e.firstChild);return S.hooks.beforeNodeAdded(d)===!1?(Pr(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):S.hooks.beforeNodeRemoved(e)===!1?(Pr(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(d),Pr(g.report.conflicts,e,d),S.hooks.afterNodeRemoved(e),S.hooks.afterNodeAdded(d),S.hooks.afterNodeMorphed(e,p),g.report.replaced.push(d),g.report.applied.push({kind:"insert",node:d,parent:d.parentNode},{kind:"remove",node:e,parent:d.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,d),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:u,loads:y,lineage:b}=Cs({liveRoot:e,baseRoot:f,localRoot:e,remoteRoot:p,toLive:S=>S,options:c,identity:c.identity||{},childrenOnly:l,isDocument:!1});return b?.deliver(u),Promise.all(y).then(()=>u)}var Sl={mergeDocument:Zo,morphDocument:Fa,morphElement:Is,merge3:_a,morph:Es};function Ls(e,t,{onWidgetRemoved:n}={}){Sl.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=xr.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var $a="hha:upgrade-check:";function $n(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function Ps(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Nl(e,t){let n=Ps(e),o=Ps(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let c=0;c<r;c++){let l=n[c]||0,s=o[c]||0;if(l!==s)return l>s}return!1}function Ka(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function za(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function js({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:c=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(u=>fetch(u)),r=r??Date.now(),!t)return null;let l=$n(t,"hyper-source");if(!l)return null;let s=$n(t,"hyper-version"),i;try{i=new URL(l,n?n.href:void 0)}catch{return null}if(n&&i.origin===n.origin&&i.pathname===n.pathname)return null;let a=`${$a}${i.href}:${s||"none"}`,p,f=e?null:Ka(a);if(f&&typeof f.checkedAt=="number"&&r-f.checkedAt<c)p=f.sourceVersion;else{try{let u=await o(i.href);if(!u.ok)throw new Error(`HTTP ${u.status}`);let y=await u.text(),b=new DOMParser().parseFromString(y,"text/html");p=$n(b,"hyper-version")}catch{p=null}za(a,{checkedAt:r,sourceVersion:p})}return p?{available:Nl(p,s||"0.0.0"),currentVersion:s,sourceVersion:p,sourceUrl:i.href}:null}var Dr=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Ds=new Set(Dr),vl=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),er=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Kn={};qr(Kn,{EmptyListInsert:()=>nr,MAX_RULE_DEPTH:()=>Do,MaxRuleDepthExceeded:()=>go,NoRulesTag:()=>Bs,RuleTargetReadOnly:()=>or,RulesParseError:()=>jo,ShapeMismatch:()=>tr,UnknownRulesVersion:()=>mo,WriteRefused:()=>rr,WriteRejected:()=>Us});var jo=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},mo=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},Do=20,go=class extends Error{constructor(t){super(`rule depth exceeded ${Do} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},tr=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},nr=class extends Error{constructor(t){super(`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},or=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},rr=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}},Bs=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Us=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};function zn(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Hs(e,t,n,{depth:0,path:[]},o)}function Hs(e,t,n,o,r){if(o.depth>Do)throw new go(o.path);if(typeof n=="string")return Ga(e,t,n,o,r);if(Array.isArray(n)){let[c,l]=n,s=e.find(t,c,r);return Ml(r,o,s),s.map((i,a)=>Hs(e,i,l,{depth:o.depth+1,path:[...o.path,a]},r))}if(typeof n=="object"&&n!==null){let c={};for(let[l,s]of Object.entries(n))c[l]=Hs(e,t,s,{depth:o.depth+1,path:[...o.path,l]},r);return c}return null}function Ga(e,t,n,o,r){if(n.endsWith("[]")){let s=n.slice(0,-2),i=e.find(t,s,r);return Ml(r,o,i),i.map(a=>e.text(a))}if(n.startsWith("@"))return Ol(e,t,n.slice(1));let c=Cn(n);if(c!==-1){let s=n.slice(0,c),i=n.slice(c+1),a=s?e.find(t,s,r):[t];return a.length===0?null:Ol(e,a[0],i)}if(n===".")return e.text(t);let l=e.find(t,n,r);return l.length===0?null:e.text(l[0])}function Ml(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function Ol(e,t,n){if(Ds.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}var Br=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Ya=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),El=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function sr(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Ws(e,t){if(sr(e,t))return!0;for(let[n,o]of Object.entries(Ya))if(o.includes(t)&&sr(e,n))return!0;return!1}function ir(e){let t=Br[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Ja(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=Br[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Ws(n,r))||o.bundles.some(r=>sr(n,r)))return n;n=n.parentElement}return null}function Il(e,t){return!!Ja(e,t)}var Xa=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Za(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Cl(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Rl(e,t,n,o,r,c){return(c?Il(e,t):Cl(e,n,r,!1))||!!(o&&(c&&e!==r?e.matches(o):Cl(e,o,r,c)))}function Qa(e,t){let n=Br[t];return n.tokens.some(o=>Ws(e,o))||n.bundles.some(o=>sr(e,o))}var ef=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Ll(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,c=t;if(e.nodeType===1){if(ef.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,c=t.content,n.cloneToLive.set(c,r),n.liveToClone.set(r,c)}}else if(e.nodeType!==11)return;let l=c.firstChild;for(let s=r.firstChild;s&&l;s=s.nextSibling)Ll(s,l,n,o),l=l.nextSibling}function lr(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let c=e.nodeType===9?e:e.ownerDocument;if(!c?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let l=c.implementation.createHTMLDocument(""),s=r||new WeakMap,i=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&l.documentElement.matches(n);let p=ir(t),f=o?b=>Qa(b,t)||!!(n&&b.matches(n)):b=>Rl(b,t,p,n,a,!1),u=null;if(a.nodeType!==1||!Rl(a,t,p,n,a,o)){u=l.importNode(a,!0);let b={cloneToLive:s,liveToClone:i,dropped:[],controls:[]};Ll(a,u,b,f);for(let S of b.dropped)S.remove();for(let S=0;S<b.controls.length;S+=2)Za(b.controls[S],b.controls[S+1])}e.nodeType===9&&u&&(l.replaceChild(u,l.documentElement),i.set(e,l),s.set(l,e));let y=b=>{if(Xa.test(b))throw new Error(`Filtered content queries do not support stateful selector: ${b}`)};return{root:u,document:l,capability:t,selector:ir(t),cloneToLive:s,liveToClone:i,original(b){return s.get(b)||null},cloneOf(b){return i.get(b)||null},query(b,S=u){return y(b),Array.from(S.querySelectorAll(b),g=>s.get(g)||g)},text(b=u){return(b===u?u:i.get(b))?.textContent||""},html(b=u){return(b===u?u:i.get(b))?.innerHTML??""},clone(b=u){let S=b===u?u:i.get(b);return S?l.importNode(S,!0):null}}}function Pl(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function tf(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var sn={semanticExclude:!0,find(e,t,n={}){let o=tf(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(s=>!Pl(s)));let c=[];n.skip&&c.push(n.skip);let l=n.templateAttr===null?null:n.templateAttr||"cms-template";if(l&&c.push("["+l+"]"),c.length){let s=c.join(", ");r=r.filter(i=>!i.closest||!i.closest(s))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function so(e,t={}){if(t.exclude===null)return sn;let n=[ir("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return sn;let c=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,s=null,i=()=>s||(s=lr(c,{capability:"data",exclude:t.exclude||null})),a=b=>{let S=i();return b===e?S.cloneOf(e):S.cloneOf(b)||b},p=b=>s?.original(b)||b,f=(b,S)=>{i().liveToClone.set(b,S),i().cloneToLive.set(S,b);let g=b.childNodes||[],d=S.childNodes||[];for(let w=0;w<Math.min(g.length,d.length);w++)f(g[w],d[w])},u=(b,S,g,d)=>{let w=Array.from(b.childNodes).filter(I=>s.cloneOf(I)),T=w[0];for(;T&&w.includes(T);)T=T.nextSibling;for(let I of w)I.remove();if(g==="innerHTML"){let I=l.createElement("template");I.innerHTML=d;for(let M of Array.from(I.content.childNodes))b.insertBefore(M,T||null)}else b.insertBefore(l.createTextNode(d),T||null);let k=lr(b,{capability:"data",exclude:t.exclude||null});S.replaceChildren(...Array.from(k.root?.childNodes||[]));let v=I=>{let M=k.original(I);M&&(s.liveToClone.set(M,I),s.cloneToLive.set(I,M));for(let P of Array.from(I.childNodes||[]))v(P)};for(let I of Array.from(S.childNodes))v(I)},y={...sn,find(b,S,g={}){let d=a(b);if(!d?.querySelectorAll)return[];let w=i().query(S,d);g.includeRulesTag||(w=w.filter(k=>!Pl(k)));let O=[];g.skip&&O.push(g.skip);let T=g.templateAttr===null?null:g.templateAttr||"cms-template";if(T&&O.push(`[${T}]`),O.length){let k=O.join(", ");w=w.filter(v=>!v.closest?.(k))}return w},parent(b){let S=a(b)?.parentElement;return S?p(S):null},children(b){return Array.from(a(b)?.children||[],p)},text(b,S){if(S===void 0){let w=p(b);return!w?.matches?.(n)&&!w?.querySelector?.(n)?sn.text(w):(a(b)?.textContent||"").trim()}let g=p(b);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!s){sn.text(g,S);return}let d=i().cloneOf(g);d?u(g,d,"textContent",S):sn.text(g,S)},attr(b,S,g){let d=p(b);if(g===void 0)return sn.attr(d,S);sn.attr(d,S,g);let w=s?.cloneOf(d);w&&(sn.attr(w,S,g),lr(d,{capability:"data",exclude:t.exclude||null}).root===null&&(w.remove(),s.liveToClone.delete(d),s.cloneToLive.delete(w)))},removeAttr(b,S){let g=p(b);sn.removeAttr(g,S);let d=s?.cloneOf(g);d&&sn.removeAttr(d,S)},prop(b,S,g){let d=p(b);if(g===void 0)return S==="innerHTML"||S==="outerHTML"||S==="textContent"||S==="innerText"?sn.prop(a(d),S):sn.prop(d,S);let w=S==="innerHTML"||S==="textContent"||S==="innerText",O=w?i().cloneOf(d):s?.cloneOf(d);O&&w?u(d,O,S,g):(sn.prop(d,S,g),O&&sn.prop(O,S,g))},clone(b){let S=a(b);return S===b?sn.clone(b):l.importNode(S,!0)},insertAt(b,S,g){let d=p(b),O=y.children(d)[g]||(()=>{for(let v=d.children.length-1;v>=0;v--){let I=d.children[v];if(i().cloneOf(I))return I.nextElementSibling}return d.firstElementChild})(),T=p(S);d.insertBefore(T,O||null);let k=i().cloneOf(d);if(k){let v=i().cloneOf(T);v||(v=l.importNode(T,!0),f(T,v));let I=Array.from(k.children);k.insertBefore(v,I[g]||null)}},insertBefore(b,S){let g=p(b),d=p(S);g.parentNode.insertBefore(d,g);let w=i().cloneOf(g.parentNode);if(w){let O=i().cloneOf(d);O||(O=l.importNode(d,!0),f(d,O));let T=i().cloneOf(g);T?T.before(O):w.appendChild(O)}},insertAfter(b,S){let g=p(b),d=p(S);g.parentNode.insertBefore(d,g.nextSibling);let w=i().cloneOf(g.parentNode);if(w){let O=i().cloneOf(d);O||(O=l.importNode(d,!0),f(d,O));let T=i().cloneOf(g);T?T.after(O):w.appendChild(O)}},identity(b){return p(b)||null},remove(b){let S=p(b),g=i().cloneOf(S);sn.remove(S),g&&sn.remove(g)},replaceWith(b,S){let g=p(b),d=i().cloneOf(g),w=sn.replaceWith(g,S);if(d){let O=lr(w,{capability:"data",exclude:t.exclude||null});if(!O.root)d.remove();else{d.replaceWith(O.root);let T=k=>{let v=O.original(k);v&&(s.liveToClone.set(v,k),s.cloneToLive.set(k,v));for(let I of Array.from(k.childNodes||[]))T(I)};T(O.root)}}return w}};return y}var jn=sn;function Vs(e){try{return JSON.parse(e)}catch(t){throw new jo(`Invalid strict JSON: ${t.message}`,t)}}function bo(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let c=[],l=0;for(;l<r.length;){let s=r[l];if(/\s/.test(s)){l++;continue}if("{}".includes(s)){c.push({type:s,value:s}),l++;continue}if(s==="["){let f=!1,u=l+1;for(;u<r.length&&/\s/.test(r[u]);)u++;if(u<r.length&&/[a-zA-Z_]/.test(r[u])&&(f=!0),!f){c.push({type:s,value:s}),l++;continue}}if(s==="]"){c.push({type:s,value:s}),l++;continue}if(s===":"){c.push({type:t.COLON,value:s}),l++;continue}if(s===","){c.push({type:t.COMMA,value:s}),l++;continue}if(s==='"'||s==="'"){let f=s,u=l+1;for(;u<r.length&&r[u]!==f;)r[u]==="\\"&&u++,u++;c.push({type:t.STRING,value:r.substring(l+1,u),quoted:!0,sourceQuote:f}),l=u+1;continue}let i=l,a;for(;i<r.length&&!/[{},]/.test(r[i]);)if(r[i]===":"){let f=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],u=!1;for(let y of f){let b=y.substring(1);if(r.substring(i+1,i+1+b.length)===b){u=!0,i+=b.length;break}}if(!u)break}else if(r[i]==="["){for(i++;i<r.length&&r[i]!=="]";){if(r[i]==='"'||r[i]==="'"){let f=r[i];for(i++;i<r.length&&r[i]!==f;)r[i]==="\\"&&i++,i++}i++}i<r.length&&r[i]==="]"&&i++}else i++;a=r.substring(l,i);let p=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(a)?p=t.NUMBER:a==="true"||a==="false"||a==="null"?p=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(a)&&(p=t.SELECTOR),c.push({type:p,value:a,quoted:!1}),l=i}return c}function o(r){let c="";for(let l=0;l<r.length;l++){let s=r[l];if("{}".includes(s.type)||"[]".includes(s.type)){c+=s.value;continue}if(s.type===t.COLON){c+=s.value;continue}if(s.type===t.COMMA){let i=r[l+1];if(i&&(i.type==="}"||i.type==="]"))continue;c+=s.value;continue}if(s.type===t.STRING&&s.quoted){let i=s.value;s.sourceQuote==="'"&&(i=i.replace(/\\'/g,"'"),i=i.replace(/(\\*)"/g,(a,p)=>p.length%2===0?p+'\\"':a)),c+=`"${i}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){c+=s.value;continue}if(s.type===t.SELECTOR||s.type===t.IDENTIFIER){c+=`"${s.value}"`;continue}c+=`"${s.value}"`}return c}try{let r=n(e),c=o(r);return JSON.parse(c)}catch(r){throw new jo("Invalid extraction rules syntax: "+r.message,r)}}var _s="1",jl=/^[a-zA-Z0-9_-]+$/;function Bo(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!jl.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${jl})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let c=r[0],l=e.attr(c,"data-rules-version");if(l!==_s)throw new mo(l);return{rules:bo(e.text(c)),tagNode:c}}var nf="script[data-rules-name]";function Dl(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function cr(e,t){let n=e.find(t,nf,{includeRulesTag:!0}),o=new Set,r=[];for(let c of n){let l=Dl(e.attr(c,"data-rules-name"));if(!l)continue;if(o.has(l)){console.warn(`hyper-html-api: duplicate rules tag name "${l}"; using the first.`);continue}let s=e.attr(c,"data-rules-version");if(s!==_s)throw new mo(s);o.add(l),r.push({name:l,rules:bo(e.text(c))})}return r}function Ur(e,t){let n={};for(let{name:o,rules:r}of cr(e,t))n[o]=zn(e,t,r);return n}function Fs(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Ur(jn,t),version:$n(n,"hyper-version")}}var Uo=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},ar=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},io=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},fr=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var Bl="text/hyper-upgrade";function qs(e,t){let n=e.find(t,`script[type="${Bl}"]`);if(n.length===0)return null;if(n.length>1)throw new fr(n.length);return e.text(n[0])||null}var of=new Function("url","return import(url)");async function $s(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await of(n)}catch(r){throw new io(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new io("transform must `export default` a function");return o.default}function Wl(e,t,n,o){let r=e.length,c=t.length,l=new Array(r).fill(-1);if(o){let d=new Set;for(let w=0;w<r;w++){let O=o[w];!(O>=0&&O<c)||d.has(O)||(l[w]=O,d.add(O))}}if(r===0||c===0)return l;let s=e.map(d=>Ul(d,n)),i=t.map(d=>Ul(d,n)),a=new Array(c).fill(!1);for(let d of l)d>=0&&(a[d]=!0);let p=new Map;i.forEach((d,w)=>{a[w]||p.set(d,p.has(d)?-1:w)});let f=new Map;s.forEach((d,w)=>{l[w]>=0||f.set(d,(f.get(d)||0)+1)}),s.forEach((d,w)=>{if(l[w]>=0||f.get(d)!==1)return;let O=p.get(d);O===void 0||O===-1||a[O]||(l[w]=O,a[O]=!0)});let u=[];for(let d=0;d<r;d++)l[d]<0&&u.push(d);let y=[];for(let d=0;d<c;d++)a[d]||y.push(d);if(u.length===0||y.length===0)return l;let b=r*c+1,S=rf(e,t,n),g=(d,w)=>S(d,w)*b+Math.abs(d-w);for(let[d,w]of sf(u,y,g))l[d]=w;return l}var Vl=e=>typeof e=="object"&&e!==null;function Ul(e,t){if(!Vl(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function rf(e,t,n){if(!Vl(n))return(s,i)=>e[s]===t[i]?0:1;let o=Object.keys(n),r=s=>o.map(i=>JSON.stringify(s?.[i])),c=e.map(r),l=t.map(r);return(s,i)=>{let a=c[s],p=l[i],f=0;for(let u=0;u<o.length;u++)a[u]!==p[u]&&f++;return f}}function sf(e,t,n){return e.length<=t.length?Hl(e,t,n,!1):Hl(t,e,(o,r)=>n(r,o),!0)}function Hl(e,t,n,o){let r=e.length,c=t.length,l=[];for(let f=0;f<=r;f++)l.push(new Float64Array(c+1).fill(1/0));let s=[];for(let f=0;f<=r;f++)s.push(new Uint8Array(c+1));for(let f=0;f<=c;f++)l[r][f]=0;for(let f=r-1;f>=0;f--)for(let u=c-1;u>=0;u--){let y=n(e[f],t[u])+l[f+1][u+1],b=l[f][u+1];y<=b?(l[f][u]=y,s[f][u]=1):l[f][u]=b}let i=[],a=0,p=0;for(;a<r&&p<c;)s[a][p]&&(i.push(o?[t[p],e[a]]:[e[a],t[p]]),a++),p++;return i}function zs(e,t,n,o,r,c,l,s={}){let i=e.find(t,n,s);if(r.length===0){i.forEach(k=>e.remove(k)),Ks(s,"onRowsApplied",c.path,[]);return}let a=r.length>i.length,p=i[0]||null;if(a&&!p&&(p=ff(e,t,n,s),!p))throw new nr(c.path);let f=i.map(k=>af(e,k,o,s)),u=null;if(a&&p){u=e.clone(p),s.templateAttr&&e.removeAttr(u,s.templateAttr);let k=e.stripIds(u);k>0&&console.warn(`[hyper-html-api] stripped ${k} id attribute(s) from cloned template at "${c.path.join(".")||"(root)"}"`)}let y=Wl(r,f,o,lf(e,i,r,c,s)),b=i[0]||p,S=e.parent(b),g=i.length>0?_l(e,S,b):0,d=df(e,i),w=new Set,O=[],T=r.map((k,v)=>{let I=y[v];if(I>=0)return w.add(I),O.push(!1),i[I];O.push(!0);let M=e.clone(u);return e.stripIds(M),M});i.forEach((k,v)=>{w.has(v)||e.remove(k)}),d?uf(e,S,g,T,O):hf(e,T,O,S,g),cf(e,T,o,r,c,l,s),Ks(s,"onRowsApplied",c.path,T)}function Ks(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function lf(e,t,n,o,r){let c=Ks(r,"identifyRows",o.path,n);if(!Array.isArray(c))return null;let l=new Array(n.length).fill(-1),s=new Set,i=new Map(t.map((a,p)=>[e.identity(a),p]));for(let a=0;a<n.length;a++){if(!c[a])continue;let p=i.get(e.identity(c[a]));p===void 0||s.has(p)||(l[a]=p,s.add(p))}return l}function cf(e,t,n,o,r,c,l){t.forEach((s,i)=>{if(n===null){let a=o[i],p=a==null?"":String(a);e.text(s)!==p&&e.text(s,p)}else{let a=c(e,s,n,o[i],{depth:r.depth+1,path:[...r.path,i]},l);a&&a!==s&&(t[i]=a)}})}function af(e,t,n,o){return n===null?e.text(t):zn(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function _l(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function ff(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let c=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let l of c)if(e.attr(l,o.templateAttr)!=null)return l;r=e.parent(r)}return null}function uf(e,t,n,o,r){let c=e.children(t),l=c.map(i=>e.identity(i)),s=!1;o.forEach((i,a)=>{let p=e.identity(i),f=n+a;if(l[f]===p)return;if(!r[a]){let y=l.indexOf(p);y!==-1&&(l.splice(y,1),c.splice(y,1))}let u=Math.min(f,c.length);u<c.length?e.insertBefore(c[u],i):c.length?s?e.insertAfter(c[c.length-1],i):(e.insertAt(t,i,f),s=!0):e.insertAt(t,i,0),l.splice(u,0,p),c.splice(u,0,i)})}function df(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((c,l)=>[e.identity(c),l])),r=[];for(let c of t){let l=o.get(e.identity(c));if(l===void 0)return!1;r.push(l)}return r.sort((c,l)=>c-l),r[r.length-1]-r[0]===r.length-1}function hf(e,t,n,o,r){let c=null,l=r;for(let s=0;s<t.length;s++){if(!n[s]){c=t[s];continue}let i=c?e.parent(c):o;if(!i)continue;let a=c?_l(e,i,c)+1:l++;e.insertAt(i,t[s],a),c=t[s]}}var Fl=new Set(["checked","selected","disabled","readOnly","paused"]);function Jn(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let c=[];if(Gs(n,o,[],c),c.length)throw new tr(c);Hr(e,t,n,o,{depth:0,path:[]},r)}function Hr(e,t,n,o,r,c={}){if(r.depth>Do)throw new go(r.path);if(o===void 0)return t;if(typeof n=="string")return pf(e,t,n,o,r,c);if(Array.isArray(n)){let[l,s]=n;return zs(e,t,l,s,o,r,Hr,c),t}if(typeof n=="object"&&n!==null){for(let[l,s]of Object.entries(n)){let i=Hr(e,t,s,o==null?o:o[l],{depth:r.depth+1,path:[...r.path,l]},c);i&&i!==t&&(t=i)}return t}return t}function pf(e,t,n,o,r,c){if(n.endsWith("[]")){let i=n.slice(0,-2);return zs(e,t,i,null,o,r,Hr,c),t}if(n.startsWith("@"))return $l(e,t,n.slice(1),o);let l=Cn(n);if(l!==-1){let i=n.slice(0,l),a=n.slice(l+1),p=i?e.find(t,i,c):[t];return p.length===0||$l(e,p[0],a,o),t}if(n===".")return ql(e,t,o),t;let s=e.find(t,n,c);return s.length===0||ql(e,s[0],o),t}function ql(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function $l(e,t,n,o){if(er.has(n)){let c=e.prop(t,n);if(c===o||c!=null&&o!=null&&String(c)===String(o))return t;throw new or(n)}if(n==="outerHTML"){let c=o==null?"":String(o);return e.replaceWith(t,c)}if(vl.has(n)){let c=mf(n,o);return e.prop(t,n)!==c&&e.prop(t,n,c),t}let r=o==null?"":String(o);return e.attr(t,n)!==r&&e.attr(t,n,r),t}function mf(e,t){return t==null?Fl.has(e)?!1:"":Fl.has(e)?t==="false"?!1:!!t:t}function Gs(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,c)=>{typeof r=="object"&&r!==null&&o.push({path:dr([...n,c]),expected:"scalar",got:ur(r)})}):o.push({path:dr(n),expected:"array",got:ur(t)});return}t!==null&&typeof t=="object"&&o.push({path:dr(n),expected:"scalar",got:ur(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:dr(n),expected:"array",got:ur(t)});return}let r=e[1];t.forEach((c,l)=>Gs(r,c,[...n,l],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:dr(n),expected:"object",got:ur(t)});return}for(let[r,c]of Object.entries(e))Gs(c,t[r],[...n,r],o)}}}function ur(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function dr(e){return e.join(".")}function hr(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=Ys(t,e,n);return Js(t,e,n),{data:o,summary:n}}function Ys(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>Ys(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,c]of Object.entries(e)){let l=Ys(c,t?.[r],n);l!==void 0&&(o[r]=l)}return o}}function Js(e,t,n){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let r of Object.keys(t))o.has(r)?Js(e[r],t[r],n):n.discarded+=yo(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>Js(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=yo(t))}}function yo(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+yo(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+yo(n),0):1}function Xs(e,t,n){let o=cr(e,t),r={carriedOver:0,discarded:0,listItems:0},c={},l=new Set;for(let{name:s,rules:i}of o){if(l.add(s),!Object.prototype.hasOwnProperty.call(n,s)){c[s]={carriedOver:0,discarded:0,listItems:0};continue}let{data:a,summary:p}=hr(n[s],i);Jn(e,t,i,a),c[s]=p,r.carriedOver+=p.carriedOver,r.discarded+=p.discarded,r.listItems+=p.listItems}for(let s of Object.keys(n))l.has(s)||(r.discarded+=yo(n[s]));return{totals:r,byName:c,rulesTagCount:o.length}}async function Zs({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:c}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),c=c||(d=>fetch(d)),!o)throw new Error("upgrade.run requires a document context");if(e=e||$n(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let l=new URL(e,r?r.href:void 0);n=n!==void 0?n:$n(o,"hyper-version"),t=t||Ur(jn,o);let s;try{s=await c(l.href)}catch(d){throw new Uo(l.href,d)}if(!s.ok)throw new Uo(l.href,new Error(`HTTP ${s.status}`));let i=await s.text(),a=new DOMParser().parseFromString(i,"text/html"),p=$n(a,"hyper-version"),f=t,u=!1,y=qs(jn,a);if(y){let w=await(await $s(y))(f,{fromVersion:n,toVersion:p});if(!w||typeof w!="object"||Array.isArray(w))throw new io("transform must return a plain object map of { rulesName: data }");f=w,u=!0}let{totals:b,byName:S,rulesTagCount:g}=Xs(jn,a,f);if(g===0&&Object.keys(f).length>0)throw new ar(l.href);return{html:gf(a),fromVersion:n,toVersion:p,summary:{transformApplied:u,totals:b,byName:S}}}function gf(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
8
+ `+e.documentElement.outerHTML}var Qs=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...El],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]}),yf=new Set(["textContent","innerText"]);function Kl(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var wf=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function zl(e,t,n=Qs){if(!wf.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>o.startsWith(r)))return`attribute "${o}" can run script`;if(n.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(n.urlAttributes.includes(o)&&t!=null){let r=o==="srcset"?String(t).split(",").map(c=>c.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let c of r){let l=Kl(c);if(l&&n.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${o}"`}}return null}function ei(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function xf(e,t){let n=ei(e,t)||"node",o=e.attr(t,"id");return o?`<${n}#${o}>`:`<${n}>`}function kf(e,t,n){let o=t;for(;o;){let r=ei(e,o);if(r&&n.refusedTargets.includes(r))return r;o=e.parent(o)}return null}function Gl(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Tf(e,t){return ei(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:Gl(e,t)}function Wr(e,t=Qs){let n=[],o=(i,a)=>(n.push({target:xf(e,i),reason:a}),!1),r=i=>{let a=kf(e,i,t);return a?o(i,`inside <${a}>, which is not content`):!0},c=i=>r(i)?Gl(e,i)?o(i,"a text write here would delete the data rules tag"):!0:!1,l=(i,a,p)=>{if(!r(i))return!1;let f=zl(a,p,t);return f?o(i,f):!0};return{...e,text(i,a){if(a===void 0)return e.text(i);c(i)&&e.text(i,a)},attr(i,a,p){if(p===void 0)return e.attr(i,a);l(i,a,p)&&e.attr(i,a,p)},prop(i,a,p){if(p===void 0)return e.prop(i,a);if(t.refusedRuleForms.includes(a))return o(i,`"@${a}" writes HTML, only text is allowed`);if(yf.has(a)){c(i)&&e.prop(i,a,p);return}l(i,a==="className"?"class":a,p)&&e.prop(i,a,p)},remove(i){if(Tf(e,i)){o(i,"removing this would delete the data rules tag");return}e.remove(i)},replaceWith(i,a){return a===e.prop(i,"outerHTML")||o(i,'"@outerHTML" writes HTML, only text is allowed'),i},refusals:n,assertClean(){if(n.length)throw new rr(n.slice())}}}function pr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Yl(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function ti(e,t,n,o,r={}){let c=[],l=[];function s(a,p,f){if(Array.isArray(a)){let[,u]=a;if(!Array.isArray(p)||!pr(u))return;p.forEach((y,b)=>s(u,y,[...f,b]));return}if(!(!pr(a)||!pr(p)))for(let u of Object.keys(p))Object.prototype.hasOwnProperty.call(a,u)?s(a[u],p[u],[...f,u]):c.push(Yl([...f,u]))}function i(a,p,f,u){if(f!==void 0){if(typeof p=="string"){if(p.endsWith("[]")||p==="."||p.startsWith("@"))return;let y=Cn(p),b=y===-1?p:p.slice(0,y);if(!b)return;e.find(a,b,r).length===0&&l.push({path:Yl(u),selector:b});return}if(!Array.isArray(p)&&pr(p)&&pr(f))for(let[y,b]of Object.entries(p))i(a,b,f[y],[...u,y])}}return s(n,o,[]),i(t,n,o,[]),{unknownKeys:c,unmatched:l}}function ni(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return Bo(e,o,n)}return null}var mr={extract:(e,t,n={})=>zn(so(e,n),e,t,n),apply:(e,t,n,o={})=>Jn(so(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>Bo(jn,e,t),findRules:(e,t)=>ni(jn,e,t),bind:(e,t,n={})=>{let o=ni(jn,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>zn(so(e,n),e,o.rules,n),set:r=>Jn(so(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:Vs,parseRelaxed:bo,ruleAttrIndex:Cn,splitRule:To,errors:Kn,DOM_PROPERTIES:Dr},oi=e=>!!e&&typeof e.nodeType=="number";function Jl(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=Bo(jn,t,"api");if(!n)throw new Kn.NoRulesTag("api");return n.rules}function Sf(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function Nf(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function vf(e,t){let n=[];for(;t!==e;){let o=t.parentNode;n.push(Array.prototype.indexOf.call(o.childNodes,t)),t=o}return n.reverse()}function Of(e,t){return t.reduce((n,o)=>n.childNodes[o],e)}function Ho(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function Mf(e,t){let n=Ho(e,"option"),o=Ho(t,"option");n.forEach((i,a)=>o[a].selected=i.selected);let r=Ho(e,"input"),c=Ho(t,"input");r.forEach((i,a)=>{let p=i.type.toLowerCase();p!=="file"&&(c[a].value=i.value),(p==="checkbox"||p==="radio")&&(c[a].checked=i.checked)});let l=Ho(e,"textarea"),s=Ho(t,"textarea");l.forEach((i,a)=>s[a].value=i.value)}function ri(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:Cn(e);if(n===-1)return;let o=e.slice(n+1);if(er.has(o))throw new Kn.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>ri(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,o]of Object.entries(e))ri(o,t[n])}}function Ef(e,t,n){let o={templateAttr:"cms-template"},r=Sf(e),c=vf(r,e),l=Nf(r);Mf(r,l);let s=Of(l,c),i=so(l,{...o,_write:!0}),a=ti(i,s,t,n,o);if(a.unknownKeys.length||a.unmatched.length)throw new Kn.WriteRejected(a.unknownKeys,a.unmatched);let p=Wr(i);Jn(p,s,t,n,o),p.assertClean(),ri(t,n);let f=Wr(so(r,{...o,_write:!0}));Jn(f,e,t,n,o),f.assertClean()}function If(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof Kn.WriteRefused?e.details=e.refusals:e instanceof Kn.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof Kn.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function si(e,t){let n=oi(e)?e:document,o=oi(e)?t:e;return o===void 0?zn(so(n),n,Jl(n)):mr.bind(n,o).get()}function ii(e,t,n){try{if(!oi(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=n===void 0?Jl(e):mr.bind(e,n).rules;Ef(e,o,t)}catch(o){throw If(o)}return e}var Xl={buildForm:Kr,bindFormEvents:zr,scaffold:ko,morphForm:Ls,path:wr},Zl={checkForUpdate:js,run:Zs,extractAll:Fs,shapeMatch:hr};var Cf={engine:mr,cms:Xl,upgrade:Zl,extractData:si,applyData:ii},Rf=Cf;return rc(Lf);})();