hyper-html-api 0.9.1 → 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.
- package/README.md +18 -5
- package/conformance/MANIFEST.json +2 -2
- package/conformance/cases/write-query-attribute.after.html +1 -0
- package/conformance/cases/write-query-attribute.after.json +3 -0
- package/conformance/cases/write-query-attribute.data.json +1 -0
- package/conformance/cases/write-query-attribute.html +1 -0
- package/conformance/cases/write-query-attribute.meta +4 -0
- package/conformance/cases/write-query-attribute.parsed.json +3 -0
- package/conformance/cases/write-query-attribute.rules +1 -0
- package/conformance/cases/write-query-attribute.write.json +4 -0
- package/conformance/cases/write-query-list.after.html +1 -0
- package/conformance/cases/write-query-list.after.json +10 -0
- package/conformance/cases/write-query-list.data.json +1 -0
- package/conformance/cases/write-query-list.html +1 -0
- package/conformance/cases/write-query-list.meta +6 -0
- package/conformance/cases/write-query-list.parsed.json +8 -0
- package/conformance/cases/write-query-list.rules +1 -0
- package/conformance/cases/write-query-list.write.json +4 -0
- package/conformance/cases/write-query-noop.after.html +1 -0
- package/conformance/cases/write-query-noop.after.json +3 -0
- package/conformance/cases/write-query-noop.data.json +1 -0
- package/conformance/cases/write-query-noop.html +1 -0
- package/conformance/cases/write-query-noop.meta +4 -0
- package/conformance/cases/write-query-noop.parsed.json +3 -0
- package/conformance/cases/write-query-noop.rules +1 -0
- package/conformance/cases/write-query-noop.write.json +4 -0
- package/conformance/cases/write-query-override.after.html +1 -0
- package/conformance/cases/write-query-override.after.json +3 -0
- package/conformance/cases/write-query-override.data.json +1 -0
- package/conformance/cases/write-query-override.html +1 -0
- package/conformance/cases/write-query-override.meta +4 -0
- package/conformance/cases/write-query-override.parsed.json +3 -0
- package/conformance/cases/write-query-override.rules +1 -0
- package/conformance/cases/write-query-override.write.json +4 -0
- package/conformance/cases/write-query-refused.data.json +1 -0
- package/conformance/cases/write-query-refused.error.json +11 -0
- package/conformance/cases/write-query-refused.html +1 -0
- package/conformance/cases/write-query-refused.meta +4 -0
- package/conformance/cases/write-query-refused.parsed.json +4 -0
- package/conformance/cases/write-query-refused.rules +1 -0
- package/conformance/cases/write-query-text.after.html +1 -0
- package/conformance/cases/write-query-text.after.json +3 -0
- package/conformance/cases/write-query-text.data.json +1 -0
- package/conformance/cases/write-query-text.html +1 -0
- package/conformance/cases/write-query-text.meta +4 -0
- package/conformance/cases/write-query-text.parsed.json +3 -0
- package/conformance/cases/write-query-text.rules +1 -0
- package/conformance/cases/write-query-text.write.json +4 -0
- package/dist/hyper-html-api.engine.min.js +1 -1
- package/dist/hyper-html-api.min.js +8 -6
- package/dist/hyper-html-api.upgrade.min.js +2 -2
- package/package.json +2 -2
- package/src/adapters/cheerio.js +12 -0
- package/src/adapters/dom.js +47 -0
- package/src/dom-api.js +149 -23
- package/src/engine/diff.js +52 -20
- package/src/engine/row-match.js +16 -10
- package/src/engine/splice.js +14 -0
- package/src/lib/content-dom.js +61 -31
- package/src/lib/region-capabilities.js +1 -0
- package/src/write.js +20 -10
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
var HyperHtmlApi=(()=>{var
|
|
2
|
-
`)?{type:"textarea"}:{type:"text"}}function Ki(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 zi(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 Fo(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 Gi(e){return` \xB7 ${e}`}function Ko(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 dr(e){let t=new Map;return(n,o)=>{if(typeof o!="string")return Ko(o,e);let r=t.get(n);if(r&&r.text===o)return r.doc;let i=Ko(o,e);return t.set(n,{text:o,doc:i}),i}}function gs(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 pr=()=>!1;function hr(e,t=[]){if(typeof e!="function")return pr;let n=new WeakMap,o=new Set(t);return r=>{if(!r||r.nodeType!==1)return!1;let i=n.get(r);if(i!==void 0)return i;let c=[],s=r,a=!1;for(;s&&s.nodeType===1;){let m=n.get(s);if(m!==void 0){a=m;break}if(c.push(s),e(s,o.has(s))){a=!0;break}if(o.has(s))break;s=s.parentElement}for(let m of c)n.set(m,a);return a}}var Vl=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 jn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var Yi="~",bs="^";function mr(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let o=t[Yi],r=typeof o=="string"?o.split(",").map(Number):null,i=r&&typeof t[bs]=="string"?t[bs].split(","):null,c=d=>Number.isInteger(d)&&d>=0,s=0,a=!1,m=d=>{let b=d;for(;b>0;){let A=r[s++];if(s>r.length||!c(A))return!1;b+=A-1}return!0},h=(d,b)=>{if(a)return;if(r){let L=s++,f=r[L];if(L>=r.length||!c(f)){a=!0;return}let g=!i||i[L]===d.tagName.toLowerCase();if(!g||f!==d.children.length){let x=g&&t[b];typeof x=="string"&&x&&n.set(d,x),m(f)||(a=!0);return}}let A=t[b];typeof A=="string"&&A&&n.set(d,A);let S=d.children;for(let L=0;L<S.length;L++)h(S[L],b===""?String(L):`${b}.${L}`)};return h(e,""),n}function ys(e){return t=>{for(let n of e){let o=n(t);if(typeof o=="string"&&o!=="")return o}return null}}var fn=ys([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function zo(e,t,n,o=null){let r=new Map,i=new Set,c=s=>{if(n(s))return;let a=t(s);a&&(r.has(a)?i.add(a):r.set(a,s))};if(o){let s=a=>{for(let m of a.querySelectorAll(o))c(m);for(let m of a.querySelectorAll("template"))m.content&&s(m.content)};c(e),s(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let s=a=>{c(a);let m=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let h=0;h<m.length;h++)s(m[h])};s(e)}for(let s of i)r.delete(s),gr(s);return r}function gr(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var Ji=new Set(["href","src","name","type","role"]),ws=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function no(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 ks(e){return e.replace(/\s+/g," ")}var Xi=0;function xs({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let o=new WeakMap,r=new WeakMap;function i(q){let z=q.attributes,ce=z.length;if(ce===0)return{all:"",sig:q.tagName+"|"};let xe=[],te="",J=[];for(let Ce=0;Ce<ce;Ce++){let we=z[Ce],ne=we.name;t(q,ne)||xe.push(ne+"="+we.value),ne==="class"?te=we.value.indexOf(" ")<0?we.value:we.value.split(/\s+/).filter(Boolean).sort().join(" "):Ji.has(ne)&&J.push(ne+"="+we.value)}return xe.length>1&&xe.sort(),J.length>1&&J.sort(),{all:xe.join(""),sig:q.tagName+"|"+te+(J.length?"|"+J.join("|"):"")}}function c(q){return q.nodeType===1&&q.tagName==="TEMPLATE"&&q.content?q.content.childNodes:q.childNodes}function s(q){let z=o.get(q);if(z)return z;if(q.nodeType===3)z={hash:"T"+no(q.nodeValue),hint:ks(q.nodeValue).slice(0,64),sig:null,tok:null};else if(q.nodeType===8)z={hash:"C"+no(q.nodeValue),hint:"",sig:null,tok:null};else if(q.nodeType===1){let ce=i(q),xe=no(q.tagName+""+ce.all),te="";for(let J of m(q))if(J.nodeType===1){let Ce=s(J);xe=no(Ce.hash,xe),te.length<64&&(te+=" "+Ce.hint)}else xe=no(h(J),xe),J.kind==="text"&&te.length<64&&(te+=J.value.slice(0,64));z={hash:"E"+xe,hint:ks(te).trim().slice(0,64),sig:ce.sig,tok:null}}else z={hash:"N"+q.nodeType,hint:"",sig:null,tok:null};return o.set(q,z),z}function a(q){if(!q.tok){q.tok=new Set;for(let z of q.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))z&&q.tok.add(z)}return q.tok}function m(q){let z=r.get(q);if(z)return z;z=[];let ce=null,xe=()=>{ce&&(ce.value=ce.nodes.map(te=>te.nodeValue).join(""),z.push(ce),ce=null)};for(let te of c(q)){if(te.nodeType===3){ce||(ce={kind:"text",nodes:[],value:"",parent:q,hash:void 0}),ce.nodes.push(te);continue}xe(),te.nodeType===8?z.push({kind:"comment",nodes:[te],value:te.nodeValue,parent:q,hash:void 0}):te.nodeType===1&&!e(te)&&z.push(te)}return xe(),r.set(q,z),z}function h(q){return q.nodeType===1?s(q).hash:(q.hash===void 0&&(q.hash=(q.kind==="text"?"T":"C")+no(q.value)),q.hash)}function d(q,z){let ce=a(s(q)),xe=a(s(z));if(ce.size===0&&xe.size===0)return{coef:1,share:1};if(ce.size===0||xe.size===0)return null;let te=0;for(let J of ce)xe.has(J)&&te++;return{coef:te/Math.min(ce.size,xe.size),share:te/Math.max(ce.size,xe.size)}}function b(q,z){let ce=d(q,z);return!!ce&&ce.coef>=.5}let A=new WeakMap;function S(q){let z=A.get(q);if(z)return z;z=[];for(let ce of q.attributes)t(q,ce.name)||z.push([ce.namespaceURI||"",ce.localName,ce.value]);return z.sort((ce,xe)=>ce[0]<xe[0]?-1:ce[0]>xe[0]?1:ce[1]<xe[1]?-1:ce[1]>xe[1]?1:0),A.set(q,z),z}let L=new WeakMap;function f(q,z){if(q===z)return!0;if(h(q)!==h(z))return!1;let ce=L.get(q);if(ce&&ce.has(z))return ce.get(z);let xe=L.get(z);if(xe&&xe.has(q))return xe.get(q);let te=g(q,z),J=te===!0;return te===!1&&n&&n.hashRejected++,ce||L.set(q,ce=new WeakMap),ce.set(z,J),J}function g(q,z){if(q.nodeType===1){if(z.nodeType!==1||q.tagName!==z.tagName||q.namespaceURI!==z.namespaceURI)return!1;let ce=S(q),xe=S(z);if(ce.length!==xe.length)return!1;for(let Ce=0;Ce<ce.length;Ce++)if(ce[Ce][0]!==xe[Ce][0]||ce[Ce][1]!==xe[Ce][1]||ce[Ce][2]!==xe[Ce][2])return!1;let te=m(q),J=m(z);if(te.length!==J.length)return!1;for(let Ce=0;Ce<te.length;Ce++){if(h(te[Ce])!==h(J[Ce]))return!1;if(!f(te[Ce],J[Ce]))return Xi}return!0}return z.nodeType===1?!1:q.kind===z.kind&&q.value===z.value}let x=new WeakMap,Q=new Map,se=0;function le(q){let z=x.get(q);if(z)return z;let ce=h(q),xe=Q.get(ce);xe||Q.set(ce,xe=[]);let te=xe.find(J=>f(J.unit,q));return z=te?te.key:"K"+se++,te||xe.push({unit:q,key:z}),x.set(q,z),z}return{meta:s,unitsOf:m,unitHash:h,similar:b,score:d,childrenOf:c,equalUnits:f,exactUnitKey:le,ignored:e}}var Ts=16,Qi=2e3,Zi=3,br={align:0,certifyVisited:0,certifyScheduled:0};function yr(e,t,n){let{meta:o,unitsOf:r,unitHash:i,similar:c,score:s,childrenOf:a,equalUnits:m,ignored:h}=n.analyzer,d=n.baseId||(()=>null),b=n.sideId||(()=>null),A=n.stats||null,S=A?new Set:null,L=A?new Set:null,f=new Map,g=new Map,x=new Set,Q=new Map,se=new Set,le=new Set,q=new Set,z=[],ce=[],xe=[],te=[],J=Qi,Ce=new Map,we=new Map,ne=(p,k)=>{f.set(p,k),g.set(k,p)},_=new Set,ye=new Set,ge=null,Oe=p=>{let k=p.nodeType?p.parentNode:p.parent;if(!k||k.nodeType!==11)return k;if(!ge){ge=new WeakMap;let R=$=>{for(let H of $.querySelectorAll("template"))H.content&&(ge.set(H.content,H),R(H.content))};for(let $ of[e,t])R($.tagName==="TEMPLATE"&&$.content?$.content:$)}return ge.get(k)||null},Be=(p,k)=>{for(let R=Oe(p);R&&!_.has(R);R=Oe(R))_.add(R);for(let R=Oe(k);R&&!ye.has(R);R=Oe(R))ye.add(R)},We=p=>{for(let k=Oe(p);k;k=Oe(k))if(f.has(k))return le.has(k);return!1},rt=p=>{for(let k=Oe(p);k;k=Oe(k)){let R=g.get(k);if(R!==void 0)return le.has(R)}return!1},re=p=>!!p&&p.nodeType===1,ut=(p,k)=>{let R=Q.get(p);return!!R&&R.has(k)},dt=p=>ws.has(p.tagName),Se=n.comparisons||n.scope,O=(p,k)=>{if(Se){if(Se.same.get(p)===k)return!0;if(Se.differ.get(p)===k)return!1}if(!p.isEqualNode(k))return!1;if(p.tagName==="TEMPLATE")return m(p,k);let R=p.getElementsByTagName("template");if(R.length===0)return!0;let $=k.getElementsByTagName("template");if(R.length!==$.length)return!1;for(let H=0;H<R.length;H++)if(!m(R[H],$[H]))return!1;return!0},B=(p,k)=>{let R=d(p);if(!R)return!0;let $=b(k);return!$||R===$},ae=globalThis.__hyperMorphProfile,be=ae?performance.now():0;ae&&!n.scope&&(o(e),o(t),ae.meta=(ae.meta||0)+(performance.now()-be),be=performance.now()),ne(e,t);let de=new Set;for(let[p,k]of n.baseIndex){let R=n.sideIndex.get(p);R&&R.tagName===k.tagName&&!f.has(k)&&!g.has(R)&&(ne(k,R),Be(k,R),de.add(k))}if(de.size){let p=[];if(n.scope)for(let H of n.scope.chain)de.has(H)&&p.push(H);let k=[n.scope?n.scope.root:e];for(;k.length;){let H=k.pop();de.has(H)&&p.push(H);let F=a(H);for(let N=F.length-1;N>=0;N--)F[N].nodeType===1&&k.push(F[N])}let R=new Set;for(let H=p.length-1;H>=0;H--){let F=p[H];n.scope&&n.scope.onChain.has(F)?R.add(F):Xt(F,f.get(F),R)?(le.add(F),q.add(F),A&&A.certificationPairs++):R.add(F)}let $=new Set;for(let H of p)le.has(H)&&!$.has(H)&&ze(H,$)}n.scope&&n.scope.head&&Bt(n.scope.head[0],n.scope.head[1]);function ze(p,k){let R=[p];for(;R.length;){let $=R.pop();if(!k.has($)){k.add($),M($);for(let H of r($))re(H)&&f.has(H)&&R.push(H)}}}te.push([e,t]);for(let[p,k]of f)re(p)&&p!==e&&te.push([p,k]);return wt(),De(),ae&&(ae.align=(ae.align||0)+(performance.now()-be)),{map:f,reverse:g,moved:se,identical:le,pairIdenticalChildren:M,weak:x,unpair:Qe,rematch:De,insertedByHash:st,refused:L,identityPaired:de};function De(){P(),wt();for(let p=0;p<xe.length;){let k=xe.length;nn(p,k),p=k,wt(),P(),wt()}}function Qe(p){let k=f.get(p);if(!k)return;Q.has(p)||Q.set(p,new Set),Q.get(p).add(k);let R=(H,F)=>{f.delete(H),g.delete(F),se.delete(H),le.delete(H),x.delete(H),q.delete(H)},$=(H,F)=>{for(let N of r(H)){let E=f.get(N);!E||de.has(N)||!(re(E)?F.contains(E):F.contains(E.nodes[0]))||(R(N,E),re(N)&&$(N,E))}};R(p,k),re(p)&&$(p,k),z.push(p),ce.push(k)}function st(){let p=new Map;for(let k of new Set(ce)){if(g.has(k))continue;let R=o(k).hash;p.has(R)||p.set(R,[]),p.get(R).push(k)}return p}function wt(){for(;te.length;){let[p,k]=te.shift();f.get(p)!==k||q.has(p)||le.has(p)||Tt(p,k)}}function bt(p,k){if(!dt(p))for(let R of r(p))re(R)&&(k.push(R),bt(R,k))}function Tt(p,k){q.add(p);let R=r(p),$=r(k);br.align+=R.length+$.length,Ce=new Map,we=new Map;for(let G=0;G<R.length;G++)Ce.set(R[G],G);for(let G=0;G<$.length;G++)we.set($[G],G);if(p.tagName==="HTML")for(let G of["HEAD","BODY"]){let he=R.find(u=>re(u)&&u.tagName===G),ve=$.find(u=>re(u)&&u.tagName===G);he&&ve&&!f.has(he)&&!g.has(ve)&&ne(he,ve)}for(let G=0;G<R.length&&G<$.length;G++){let he=R[G],ve=$[G];f.has(he)||g.has(ve)||(re(he)?re(ve)&&he.tagName===ve.tagName&&O(he,ve)&&Bt(he,ve):!re(ve)&&he.kind===ve.kind&&he.value===ve.value&&Bt(he,ve))}T(R,$);let H=R.filter(G=>!f.has(G)),F=$.filter(G=>!g.has(G));H.length&&F.length&&(Qt(H,F),Z(H,F),ee(H,F,R,$),fe(R,$));let N=!1,E=!1;for(let G of R){if(!f.has(G)){re(G)&&(z.push(G),bt(G,z),N=!0);continue}re(G)&&!le.has(G)&&te.push([G,f.get(G)])}for(let G of $)!g.has(G)&&re(G)&&(ce.push(G),bt(G,ce),E=!0);N&&E&&xe.push([p,k])}function nn(p,k){for(let R=p;R<k;R++){let[$,H]=xe[R];if(f.get($)!==H)continue;let F=r($),N=r(H),E=new Map,G=new Map,he=null;for(let ve of F)re(ve)&&(f.has(ve)?he=ve:(E.has(he)||E.set(he,[]),E.get(he).push(ve)));he=null;for(let ve of N)re(ve)&&(g.has(ve)?he=g.get(ve):(G.has(he)||G.set(he,[]),G.get(he).push(ve)));for(let[ve,u]of E){let v=G.get(ve);if(!(!v||u.length!==v.length)&&u.every((j,U)=>v[U].tagName===j.tagName&&B(j,v[U])&&!ut(j,v[U])))for(let j=0;j<u.length;j++)Fe(u[j],v[j])}}}function Fe(p,k){ne(p,k),x.add(p),te.push([p,k]),wt()}function Qt(p,k){let R=oo(p,i),$=oo(k,i),H=new Map;for(let F of k){let N=i(F);$.get(N)===1&&H.set(N,F)}for(let F of p){if(f.has(F))continue;let N=i(F);if(R.get(N)!==1)continue;let E=H.get(N);E&&!g.has(E)&&m(F,E)&&Bt(F,E)}}function Xt(p,k,R){let $=[[p,k]];for(;$.length;){let[H,F]=$.pop();if(br.certifyVisited++,A&&A.certificationVisited++,H.nodeType!==F.nodeType)return!1;if(H.nodeType===3||H.nodeType===8){if(H.nodeValue!==F.nodeValue)return!1;continue}if(H.nodeType!==1){if(!H.isEqualNode(F))return!1;continue}if(H.tagName!==F.tagName||H.namespaceURI!==F.namespaceURI||h(H)!==h(F))return!1;let N=H.attributes,E=F.attributes;if(N.length!==E.length)return!1;for(let v=0;v<N.length;v++){let j=N[v];if(F.getAttributeNS(j.namespaceURI,j.localName)!==j.value)return!1}let G=f.get(H);if(G!==void 0&&G!==F)return!1;let he=g.get(F);if(he!==void 0&&he!==H)return!1;if(H!==p){if(le.has(H))continue;if(R.has(H))return!1}let ve=a(H),u=a(F);if(ve.length!==u.length)return!1;br.certifyScheduled+=ve.length;for(let v=ve.length-1;v>=0;v--)$.push([ve[v],u[v]])}return!0}function Bt(p,k){if(re(p)&&(_.has(p)||ye.has(k))){let R=Lt(p,k);if(!R){ne(p,k),te.push([p,k]);return}for(let $=0;$<R.length;$+=2){let H=R[$],F=R[$+1],N=f.get(H);N!==void 0&&N!==F&&Et(H,N);let E=g.get(F);E!==void 0&&E!==H&&Et(E,F),f.get(H)===F&&(se.delete(H),x.delete(H),le.add(H),q.add(H))}}sn(p,k)}function Et(p,k){f.delete(p),g.delete(k),se.delete(p),le.delete(p),x.delete(p),q.delete(p)}function Lt(p,k){let R=[p,k,!1],$=[];for(;R.length;){let H=R.pop(),F=R.pop(),N=R.pop(),E=f.get(N),G=g.get(F);if(N!==p&&(E!==void 0&&E!==F&&de.has(N)||G!==void 0&&G!==N&&de.has(G)))return null;if(!(E===F&&le.has(N))&&((E!==void 0||G!==void 0)&&$.push(N,F),!!re(N))){if(H||E!==void 0&&E!==F||G!==void 0&&G!==N){let he=r(N),ve=r(F);for(let u=0;u<he.length&&u<ve.length;u++)R.push(he[u],ve[u],!0)}else if(_.has(N)||ye.has(F)){let he=N.tagName==="TEMPLATE"?N.content:N,ve=F.tagName==="TEMPLATE"?F.content:F;for(let u=he.firstElementChild,v=ve.firstElementChild;u&&v;){if(h(u)){u=u.nextElementSibling;continue}if(h(v)){v=v.nextElementSibling;continue}(f.has(u)||g.has(v)||_.has(u)||ye.has(v))&&R.push(u,v,!1),u=u.nextElementSibling,v=v.nextElementSibling}}}}return $}function sn(p,k){ne(p,k),le.add(p),re(p)&&q.add(p)}function M(p){let k=f.get(p);if(!k||!re(p))return;let R=r(p),$=r(k);for(let H=0;H<R.length&&H<$.length;H++)f.has(R[H])||sn(R[H],$[H])}function Z(p,k){let R=N=>re(N)&&!dt(N)?o(N).sig+""+o(N).hint:null,$=oo(p,R),H=oo(k,R),F=new Map;for(let N of k){let E=R(N);E!=null&&H.get(E)===1&&F.set(E,N)}for(let N of p){if(f.has(N))continue;let E=R(N);if(E==null||$.get(E)!==1)continue;let G=F.get(E);G&&!g.has(G)&&B(N,G)&&ne(N,G)}}function ee(p,k,R,$){let H=new Map;for(let N of k){if(!re(N)||g.has(N)||dt(N))continue;let E=o(N).sig;H.has(E)||H.set(E,[]),H.get(E).push({el:N,index:we.get(N)})}let F=[];for(let N of p){if(f.has(N)||!re(N)||dt(N))continue;let E=H.get(o(N).sig);if(!E||!E.length)continue;let G=Ce.get(N),he=E.filter(ve=>!g.has(ve.el)).map(ve=>({c:ve,d:Math.abs(ve.index-G)}));he.sort((ve,u)=>ve.d-u.d),he.length>Ts&&(he=he.slice(0,Ts));for(let{c:ve,d:u}of he){if(!B(N,ve.el))continue;let v=s(N,ve.el);v&&v.coef>=.5&&F.push({b:N,s:ve.el,coef:v.coef,share:v.share,d:u,bi:G})}}if(F.sort((N,E)=>E.coef-N.coef||E.share-N.share||N.d-E.d||N.bi-E.bi),A&&F.length>1){let N=new Map;for(let E of F){let G=N.get(E.b);G?G.coef===E.coef&&(G.share===E.share?G.strict++:G.loose++):N.set(E.b,{coef:E.coef,share:E.share,strict:0,loose:0})}for(let[E,G]of N)S.has(E)||!(G.strict||G.loose)||(S.add(E),G.strict?A.similarTiesStrict++:A.similarTiesLoose++)}for(let N of F)!f.has(N.b)&&!g.has(N.s)&&ne(N.b,N.s)}function ue(p,k){return re(p)!==re(k)?!1:re(p)?p.tagName!==k.tagName||!B(p,k)?!1:dt(p)||o(p).hint===""||o(k).hint===""?!0:c(p,k):p.kind===k.kind}function oe(p,k){let R=(H,F)=>{let N=F===null?-1:H===k?we.get(F):Ce.get(F),E=H[N+1];return E&&!re(E)?E:null},$=null;for(let H of p){if(re(H)){$=H;continue}if(f.has(H))continue;let F=$===null?null:f.get($);if($!==null&&!F)continue;let N=R(k,F);N&&!g.has(N)&&N.kind===H.kind&&ne(H,N)}}function fe(p,k){oe(p,k);let R=y(p,k),$=(F,N)=>re(F)&&o(F).hint!==""&&o(N).hint===""&&!!N.querySelector("br")&&!R(F,N),H=0;for(let F of p){if(f.has(F)){let E=we.get(f.get(F));E!==void 0&&E>=H&&(H=E+1);continue}let N=0;for(let E=H;E<k.length&&N<Zi;E++){let G=k[E];if(!g.has(G)&&(N++,ue(F,G)&&!ut(F,G)&&!$(F,G))){ne(F,G),re(F)&&(o(F).hint===""||o(G).hint==="")&&x.add(F),H=E+1;break}}}T(p,k)}function y(p,k){let R=($,H,F)=>{for(let N=H-1;N>=0;N--)if(re($[N])&&F($[N]))return $[N];return null};return($,H)=>{let F=Ce.get($),N=we.get(H);if(F===N)return!0;let E=R(p,F,he=>f.has(he)),G=R(k,N,he=>g.has(he));return E?f.get(E)===G:!G}}function T(p,k){let R=p.filter(E=>re(E)&&!f.has(E)),$=k.filter(E=>re(E)&&!g.has(E));if(!R.length||!$.length)return;let H=oo(R,E=>E.tagName),F=oo($,E=>E.tagName),N=y(p,k);for(let E of R){let G=E.tagName;if(H.get(G)!==1||F.get(G)!==1)continue;let he=$.find(ve=>ve.tagName===G);he&&!g.has(he)&&N(E,he)&&B(E,he)&&!ut(E,he)&&(m(E,he)?Bt(E,he):(ne(E,he),x.add(E)))}}function P(){let p=new Map;for(let E of x)if(re(E)&&re(f.get(E))){let G=o(E).hash;p.has(G)||p.set(G,[]),p.get(G).push(E)}if(p.size)for(let E of ce){if(g.has(E)||!re(E)||rt(E))continue;let G=p.get(o(E).hash),he=G&&G.find(ve=>x.has(ve)&&!ut(ve,E)&&B(ve,E)&&m(ve,E));he&&(Qe(he),Bt(he,E),Be(he,E),se.add(he))}let k=new Map,R=new Map,$=new Map;for(let E of x){let G=f.get(E);re(E)&&re(G)&&$.set(G,E)}let H=(E,G)=>{if(!g.has(E))return!rt(E);let he=$.get(E);return he===g.get(E)&&he!==G&&!he.contains(G)},F=E=>{if(g.has(E)){let G=$.get(E);$.delete(E),Qe(G)}};for(let E of[...ce,...$.keys()]){if(g.has(E)&&!$.has(E))continue;let G=o(E).hash;if(k.has(G)||k.set(G,[]),k.get(G).push(E),dt(E))continue;let he=o(E).sig;R.has(he)||R.set(he,[]),R.get(he).push(E)}let N=new Set;for(let E of x){let G=f.get(E);!re(E)||!re(G)||dt(E)||o(E).hint===""||o(G).hint===""||c(E,G)||N.add(E)}for(let E of[...z,...N]){let G=f.get(E);if(G?!(x.has(E)&&N.has(E)):We(E))continue;let he=U=>{G&&Qe(E),F(U)},ve=k.get(o(E).hash);if(ve){let U=ve.find(V=>V!==G&&H(V,E)&&!ut(E,V)&&m(E,V));if(U){he(U),Bt(E,U),Be(E,U),se.add(E);continue}}if(dt(E)||J<=0)continue;let u=R.get(o(E).sig);if(!u)continue;let v=null,j=0;for(let U of u)if(!(U===G||!H(U,E)||!B(E,U)||ut(E,U))&&(J--<=0||c(E,U)&&(j++,v=U,j>1)))break;j>1&&L&&L.add(E),j===1&&(he(v),ne(E,v),Be(E,v),se.add(E),te.push([E,v]))}}}function oo(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 ec={diff:0},As=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,tc=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,nc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,oc=/\P{M}\p{M}*/gu;function Sr(e){if(e==="")return[];if(As){let n=[];for(let o of As.segment(e))n.push(o.segment);return n}let t=[];for(let n of e.match(nc))if(tc.test(n))for(let o of n.match(oc))t.push(o);else t.push(n);return t}var rc=/^[ ]+$/,sc=e=>rc.test(e)?" ".repeat(e.length):e,Dn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),gt="",kr=e=>e.every(t=>Dn(t)||t.k===gt),ic=/^[\x00-\x7f\u00A0]*$/,cc=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function lc(e){return e===""?[]:e.match(cc)}function $n(e,t=!1){return(t?lc(e):Sr(e)).map(n=>({k:sc(n),raw:n,len:n.length}))}var Go=(...e)=>e.every(t=>ic.test(t));function wr(e,t,n){let o=e.length,r=t.length,i=Math.min(o+r,n),c=i+1,s=new Int32Array(2*i+3),a=[],m=o===0&&r===0;for(let A=0;A<=i&&!m;A++){a.push(s.slice(c-A,c+A+1));for(let S=-A;S<=A;S+=2){let L;S===-A||S!==A&&s[c+S-1]<s[c+S+1]?L=s[c+S+1]:L=s[c+S-1]+1;let f=L-S,g=L;for(;L<o&&f<r&&e[L].k===t[f].k;)L++,f++;if(ec.diff+=1+L-g,s[c+S]=L,L>=o&&f>=r){m=!0;break}}}if(!m)return null;let h=[],d=o,b=r;for(let A=a.length-1;A>0;A--){let S=a[A],L=d-b,f=L+A,g=L===-A||L!==A&&S[f-1]<S[f+1]?L+1:L-1,x=S[g+A],Q=x-g;for(;d>x&&b>Q;)h.push([0,d-1,b-1]),d--,b--;d===x?(h.push([1,d,b-1]),b--):(h.push([-1,d-1,b]),d--)}for(;d>0&&b>0;)h.push([0,d-1,b-1]),d--,b--;return h.reverse(),h}function ac(e,t,n){let o=d=>d.k===gt;if(!e.some(o)&&!t.some(o))return wr(e,t,n);let r=[],i=[];for(let d=0;d<e.length;d++)o(e[d])||r.push(d);for(let d=0;d<t.length;d++)o(t[d])||i.push(d);let c=wr(r.map(d=>e[d]),i.map(d=>t[d]),n);if(!c)return null;let s=[],a=0,m=0,h=(d,b)=>{for(;a<d&&m<b&&e[a].k===t[m].k;)s.push([0,a++,m++]);let A=wr(e.slice(a,d),t.slice(m,b),n);if(!A)return!1;for(let[S,L,f]of A)s.push([S,L+a,f+m]);return a=d,m=b,!0};for(let[d,b,A]of c)if(d===0){if(!h(r[b],i[A]))return null;s.push([0,a,m]),a++,m++}return h(e.length,t.length)?s:null}function ro(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 i=0;for(;i<e.length-r&&i<t.length-r&&e[e.length-1-i].k===t[t.length-1-i].k;)e[e.length-1-i].raw!==t[t.length-1-i].raw&&o.push({bi:e.length-1-i,tok:t[t.length-1-i]}),i++;let c=e.slice(r,e.length-i),s=t.slice(r,t.length-i),a=mc(c,s)?null:ac(c,s,n);if(!a){let g=c.length||s.length?[{bs:r,be:r+c.length,toks:s}]:[];return{hunks:g,cosmetic:o,coarse:!0,parts:g.map(x=>({...x,gap:[],group:0})),cosmeticEq:o}}let m=[],h=(g,x)=>{c[g].raw!==s[x].raw&&o.push({bi:r+g,tok:s[x]})},d=null,b=[],A=0,S=0,L=()=>{d&&m.push(d),d=null;for(let[g,x]of b)h(g,x);b=[],A++};for(let[g,x,Q]of a){if(g===0){d&&Dn(c[x])&&!c[x].k.includes(`
|
|
3
|
-
`)?
|
|
4
|
-
`))return!1;let q=ge=>n.slice(se,le).map((Oe,Be)=>ge.raw.get(se+Be)||Oe),z=[...x.toks,...q(S)],ce=[...q(f),...Q.toks],xe=(ge,Oe,Be)=>Oe>=0&&Oe+Be.length<=ge.length&&Be.every((We,rt)=>ge[Oe+rt].k===We.k),te=(ge,Oe,Be)=>kr(ge)&&n.slice(Oe,Be).some(We=>!Dn(We)),J=ge=>ge.some(Oe=>!Dn(Oe)),Ce,we,ne,_;if(s(x)&&J(x.toks)&&xe(ce,0,x.toks)){let ge=ce.slice(x.toks.length);te(ge,se,Q.be)||(Ce=se,we=x.toks,ne=ce.slice(0,x.toks.length),_=[null,{bs:se,be:Q.be,toks:ge}])}if(Ce===void 0&&s(Q)&&J(Q.toks)){let ge=z.length-Q.toks.length,Oe=z.slice(0,ge);xe(z,ge,Q.toks)&&!te(Oe,x.bs,le)&&(Ce=le,we=z.slice(ge),ne=Q.toks,_=[{bs:x.bs,be:le,toks:Oe},null])}if(Ce===void 0)return!1;let ye=ge=>ge&&(ge.bs<ge.be||ge.toks.length);return S.list.splice(L,1,...[_[0],{bs:Ce,be:Ce,toks:we}].filter(ye)),f.list.splice(g,1,...[{bs:Ce,be:Ce,toks:ne},_[1]].filter(ye)),!0},b=c[0],A=c[1];for(let S=0;S<64;S++){let L=!1;e:for(let f=0;f<b.list.length;f++)for(let g=0;g<A.list.length;g++){let x=b.list[f],Q=A.list[g];if(!(x.bs===Q.bs&&x.be===Q.be&&Or(x.toks,Q.toks))){for(let se of[!0,!1]){let le=z=>se?z.be:z.bs,q=s(x)?[le(Q),x.bs]:[le(x)];for(let z of q){let ce=a(b,f,z,le),xe=ce&&a(A,g,z,le);if(!xe)continue;let te=(_,ye)=>se?_[_.length-1-ye]:_[ye],J=0;for(;J<ce.length&&J<xe.length&&te(ce,J).k===te(xe,J).k;)J++;if(!J)continue;let Ce=se?ce.slice(0,ce.length-J):ce.slice(J),we=se?xe.slice(0,xe.length-J):xe.slice(J);if(!(J<ce.length&&J<xe.length&&!kr(Ce)&&!kr(we)&&(s(x)&&s(Q)||x.bs===Q.bs&&x.be===Q.be)||!(se?ce.slice(ce.length-J):ce.slice(0,J)).some(_=>!Dn(_)))){if(J===ce.length&&J===xe.length&&s(x)&&s(Q)){if(x.bs===z&&Q.bs===z)continue;b.list[f]={bs:z,be:z,toks:ce},A.list[g]={bs:z,be:z,toks:xe}}else!s(x)&&x.bs===Q.bs&&x.be===Q.be?(h(b,f,ce,J,se),h(A,g,xe,J,se)):(m(b,f,ce,J,se,z),m(A,g,xe,J,se,z));L=!0;break e}}}if(d(b,f,A,g)||d(A,g,b,f)){L=!0;break e}}}if(!L)break}return[b.list,A.list]}var pc=48,hc=.3;function mc(e,t){let n=e.filter(c=>!Dn(c)),o=t.filter(c=>!Dn(c));if(Math.min(n.length,o.length)<pc)return!1;let r=new Map;for(let c of n)r.set(c.k,(r.get(c.k)||0)+1);let i=0;for(let c of o){let s=r.get(c.k);s>0&&(i++,r.set(c.k,s-1))}return i/Math.min(n.length,o.length)<hc}var gc=(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},Or=(e,t)=>e.length===t.length&&e.every((n,o)=>n.k===t[o].k);function Ss(e,t,n,o="remote"){let r=ro(e,t),i=ro(e,n),{lh:c,rh:s,cosL:a,cosR:m}=Nr(r,i,e),h=O=>O.bs===O.be,d=O=>O.toks.some(B=>typeof B.k=="string"),b=O=>h(O)&&!d(O),A=(O,B)=>B.bs<O.be&&O.bs<B.be,S=(O,B)=>!A(O,B)&&B.bs<=O.be&&O.bs<=B.be&&(h(O)&&d(O)||h(B)&&d(B))&&!(h(O)&&h(B)),L=(O,B)=>O.bs===B.bs&&O.be===B.be&&Or(O.toks,B.toks),f=[],g=new Set;for(let O of c){let B=s.find(ae=>!g.has(ae)&&L(O,ae));B?(g.add(B),f.push({bs:O.bs,be:O.be,side:"both",l:O,r:B,toks:O.toks})):f.push({bs:O.bs,be:O.be,side:"L",l:O,toks:O.toks,lead:!!O.lead})}for(let O of s)g.has(O)||f.push({bs:O.bs,be:O.be,side:"R",r:O,toks:O.toks,lead:!!O.lead});f.sort((O,B)=>O.bs-B.bs||O.be-B.be||B.lead-O.lead);let x=0,Q=0;for(let O of f)O.side==="both"&&(x+=O.toks.length-(O.be-O.bs));let se=f.map((O,B)=>B),le=O=>se[O]===O?O:se[O]=le(se[O]),q=(O,B)=>(O=le(O),B=le(B),O===B?!1:(se[O]=B,!0)),z=f.map(O=>gc({bs:O.bs,be:O.be,toks:O.toks},e)),ce={L:new Map,R:new Map};f.forEach((O,B)=>{let ae=O.side==="both"?["L","R"]:[O.side];for(let be of ae)for(let de of z[B])ce[be].has(de)||ce[be].set(de,[]),ce[be].get(de).push(B)});for(let O of[ce.L,ce.R])for(let B of O.values())for(let ae=1;ae<B.length;ae++)q(B[0],B[ae]);for(let O=0;O<f.length;O++)for(let B=O+1;B<f.length;B++){let ae=f[O],be=f[B];ae.side===be.side&&ae.side!=="both"||ae.bs>be.be||(A(ae,be)||S(ae,be)?q(O,B):ae.bs===be.bs&&h(ae)&&h(be)&&Q++)}let xe=(O,B)=>{let ae=O==="L"?c:s;for(let be of ae)if(be.toks.some(de=>de.kind==="close"&&de.k.el===B.el))return be.bs;for(let be=0;be<e.length;be++)if(e[be].kind==="close"&&e[be].k.el===B.el)return be;return-1};f.forEach((O,B)=>{if(!(!b(O)||O.side==="both"))for(let ae of O.toks){if(ae.kind!=="open")continue;let be=xe(O.side,ae.k);if(be<=O.bs)continue;let de=new Uint8Array(be-O.bs),ze=[];if(f.forEach((De,Qe)=>{if(!(De.side===O.side||h(De))&&De.bs<be&&De.be>O.bs){ze.push(Qe);for(let st=Math.max(De.bs,O.bs);st<Math.min(De.be,be);st++)de[st-O.bs]=1}}),ze.length&&de.every(De=>De===1))for(let De of ze)q(B,De)}});let te=!0;for(;te;){te=!1;let O=new Map;f.forEach((B,ae)=>{let be=le(ae),de=O.get(be)||{bs:B.bs,be:B.be,L:!1,R:!1};de.bs=Math.min(de.bs,B.bs),de.be=Math.max(de.be,B.be),B.side!=="R"&&(de.L=!0),B.side!=="L"&&(de.R=!0),O.set(be,de)}),f.forEach((B,ae)=>{for(let[be,de]of O){if(le(ae)===le(be)||!(de.L&&de.R))continue;let ze=B.bs<de.be&&B.be>de.bs,De=h(B)&&d(B)&&(B.bs===de.be||B.bs===de.bs);(ze||De)&&q(ae,be)&&(te=!0)}})}let J=new Map;f.forEach((O,B)=>{let ae=le(B);J.has(ae)||J.set(ae,[]),J.get(ae).push(O)});let Ce=[];for(let O of J.values()){let B=O.some(be=>be.side==="L"),ae=O.some(be=>be.side==="R");if(B&&ae){let be=Math.min(...O.map(Qe=>Qe.bs)),de=Math.max(...O.map(Qe=>Qe.be)),ze=O.filter(Qe=>Qe.side!=="R").map(Qe=>Qe.l).sort((Qe,st)=>Qe.bs-st.bs),De=O.filter(Qe=>Qe.side!=="L").map(Qe=>Qe.r).sort((Qe,st)=>Qe.bs-st.bs);Ce.push({bs:be,be:de,kind:"conflict",localHunks:ze,remoteHunks:De})}else for(let be of O)Ce.push({bs:be.bs,be:be.be,kind:be.side,u:be})}let we=(O,B)=>{let ae=O==="L"?c:s;for(let be of ae)if(be.toks.some(de=>de.kind==="close"&&de.k.el===B.el))return be.bs+.5;for(let be=0;be<e.length;be++)if(e[be].kind==="close"&&e[be].k.el===B.el)return be;return 1/0},ne=(O,B)=>{let ae=O==="L"?c:s;for(let be of ae)if(be.toks.some(de=>de.kind==="open"&&de.k.el===B.el))return be.bs-.5;for(let be=0;be<e.length;be++)if(e[be].kind==="open"&&e[be].k.el===B.el)return be;return-1/0},_=O=>O.kind==="R"?"R":"L",ye=O=>O.kind==="R"?1:0;Ce.sort((O,B)=>{if(O.bs!==B.bs)return O.bs-B.bs;let ae=O.bs===O.be,be=B.bs===B.be;if(ae!==be)return ae?-1:1;if(ae&&be&&O.kind!=="conflict"&&B.kind!=="conflict"){let ze=O.u.toks,De=B.u.toks,Qe=wt=>wt.length&&wt.every(bt=>bt.kind==="open"),st=wt=>wt.length&&wt.every(bt=>bt.kind==="close");if(Qe(ze)&&Qe(De)){let wt=Math.max(...ze.map(Tt=>we(_(O),Tt.k))),bt=Math.max(...De.map(Tt=>we(_(B),Tt.k)));if(wt!==bt)return bt-wt}if(st(ze)&&st(De)){let wt=Math.min(...ze.map(Tt=>ne(_(O),Tt.k))),bt=Math.min(...De.map(Tt=>ne(_(B),Tt.k)));return wt!==bt?bt-wt:ye(B)-ye(O)}}let de=ze=>ze.u&&ze.u.lead?1:0;return de(B)-de(O)||ye(O)-ye(B)||O.be-B.be});let ge=[],Oe=[],Be=0,We=O=>{O>Be&&(ge.push({bs:Be,be:O,toks:e.slice(Be,O),source:"base"}),Be=O)};for(let O of Ce){if(We(O.bs),O.kind==="conflict"){let B=Ar(e,O.localHunks,O.bs,O.be),ae=Ar(e,O.remoteHunks,O.bs,O.be),be=o==="local"?B:o==="both"?B.concat(ae):ae,de=(Qe,st)=>{let wt=0;for(let bt of Qe)bt.be<=O.bs&&!st.includes(bt)&&(wt+=bt.toks.length-(bt.be-bt.bs));return wt},ze=O.bs+de(c,O.localHunks),De=O.bs+de(s,O.remoteHunks);Oe.push({bs:O.bs,be:O.be,ls:ze,le:ze+B.length,rs:De,re:De+ae.length,ms:0,me:0,base:e.slice(O.bs,O.be),local:B,remote:ae,resolved:be}),ge.push({bs:O.bs,be:O.be,toks:be,source:"conflict",localHunks:O.localHunks,localToks:B,keepsLocal:o!=="remote"})}else ge.push({bs:O.bs,be:O.be,toks:O.u.toks,source:O.kind==="R"?"remote":"local",localHunks:O.kind==="R"?[]:[O.u.l]});Be=Math.max(Be,O.be)}We(e.length);let rt=0,re=0;for(let O of ge)O.source==="conflict"&&(Oe[re].ms=rt,Oe[re].me=rt+O.toks.length,re++),rt+=O.toks.length;let ut=new Map(a.map(O=>[O.bi,O.tok])),dt=new Map(m.map(O=>[O.bi,O.tok])),Se=[];for(let O of ge){O.source==="base"&&(O.toks=O.toks.map((B,ae)=>{let be=O.bs+ae,de=ut.get(be),ze=dt.get(be),De=de&&ze?o==="remote"?ze:de:de||ze||B;return De===B?B:{...De,cosmetic:!0}}));for(let B of O.toks)Se.push({...B,src:O.source})}return{tokens:Se,segments:ge,conflicts:Oe,localHunks:c,remoteHunks:s,collapsedDelta:x,samePoint:Q,mapLocalOffset:bc(e,c,ge)}}function Ar(e,t,n,o){let r=[],i=n;for(let c of t)r=r.concat(e.slice(i,c.bs),c.toks),i=c.be;return r.concat(e.slice(i,o))}var xr=e=>e.reduce((t,n)=>t+n.len,0);function bc(e,t,n){let o=new Int32Array(e.length+1);for(let c=0;c<e.length;c++)o[c+1]=o[c]+e[c].len;let r=t.map(c=>({bs:o[c.bs],be:o[c.be],text:c.toks.map(s=>s.raw).join(""),ref:c})),i=n.map(c=>({bs:o[c.bs],be:o[c.be],len:xr(c.toks),source:c.source,localHunks:c.localHunks||[],localLen:c.localToks?xr(c.localToks):0,keepsLocal:c.keepsLocal,ref:c}));return c=>{let s=null,a=null,m=0,h=0,d=0;for(let A of r){let S=A.bs-d;if(c<=h+S){s=d+(c-h);break}if(h+=S,d=A.bs,c<=h+A.text.length){a=A,m=c-h,s=A.bs;break}h+=A.text.length,d=A.be}s===null&&(s=d+(c-h));let b=0;for(let A of i){if(!a&&s<=A.bs)return b;if(!(a?A.localHunks.includes(a.ref):s<A.be)){b+=A.len;continue}if(A.source==="base")return b+(s-A.bs);if(A.source==="remote")return b+A.len;if(A.source==="local")return b+Math.min(m,A.len);if(!A.keepsLocal||!a)return b+A.len;let L=A.localHunks.indexOf(a.ref),f=xr(Ar(e,A.localHunks.slice(0,L),A.ref.bs,a.ref.bs));return b+Math.min(f+m,A.localLen)}return b}}function wo(e,t,n,o="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:g=>Math.min(g,t.length),granularity:"word"};let r=Go(e,t,n),i=$n(e,r),c=$n(t,r),s=$n(n,r),a=i.length<=2e4&&c.length<=2e4&&s.length<=2e4?Ss(i,c,s,o):null,m="word",h=i;if(!a){let g=x=>x.split(/(?<=\n)/).map(Q=>({k:Q,raw:Q,len:Q.length}));h=g(e),a=Ss(h,g(t),g(n),o),m="line"}let d=g=>g.map(x=>x.raw).join(""),b=g=>{let x=[0];for(let Q of g)x.push(x[x.length-1]+Q.len);return x},A=b(h),S=null,L=null,f=null;if(a.conflicts.length){let g=x=>x.split(/(?<=\n)/).map(Q=>({k:Q,raw:Q,len:Q.length}));S=b(m==="line"?g(t):c),L=b(m==="line"?g(n):s),f=b(a.tokens)}return{text:d(a.tokens),conflicts:a.conflicts.map(g=>({bs:A[g.bs],be:A[g.be],ls:S[g.ls],le:S[g.le],rs:L[g.rs],re:L[g.re],ms:f[g.ms],me:f[g.me],base:d(g.base),local:d(g.local),remote:d(g.remote),resolved:d(g.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:m}}function xo(e,t,n=4e3){if(e===t)return[];let o=Go(e,t),r=$n(e,o),i=$n(t,o),c=ro(r,i,n),s=[0];for(let a of r)s.push(s[s.length-1]+a.len);return c.hunks.map(a=>({bs:s[a.bs],be:s[a.be],text:a.toks.map(m=>m.raw).join("")}))}var co="\uFFFC";var yc={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(" ")),Is=new Set(["BR","WBR","IMG"]),Er=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 qn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||Is.has(e.tagName))return!0;if(!An.has(e.tagName))return!Er.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(!qn(r,t)){o=!1;break}return t.inlineCache&&t.inlineCache.set(e,o),o}function kc(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function En(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,i)=>{for(let c of r){if(c.nodeType===3){let d=c.nodeValue;if(!d)continue;n.nodes.push({node:c,s:n.text.length,e:n.text.length+d.length}),n.text+=d;for(let b=0;b<d.length;b++)n.stackAt.push(i);continue}if(c.nodeType!==1)continue;if(t.ignored&&t.ignored(c)){n.pins.push({el:c,i:n.text.length});continue}if(t.skip&&t.skip.has(c))continue;let s=t.via&&t.via(c)||c;s!==c&&(n.via||(n.via=new Map)).set(s,c);let a=c.tagName;if(t.blocks&&t.blocks.has(c)){n.text.length&&n.text[n.text.length-1]!==gt&&(n.stackAt.push(i),n.text+=gt);let d={el:c,tag:a,from:n.text.length,to:-1,depth:i.length,block:!0};n.marks.push(d);let b=i.concat([d]);o(s.childNodes,b),n.stackAt.push(b),n.text+=gt,d.to=n.text.length;continue}let m=An.has(a)&&kc(s);if(Is.has(a)||!An.has(a)||t.remoteWins&&t.remoteWins(c)||t.atomize&&t.atomize(c)||m){n.atoms.push({i:n.text.length,el:c,key:m?a+":empty":a,stack:i}),n.stackAt.push(i),n.text+=co;continue}let h={el:c,tag:a,from:n.text.length,to:-1,depth:i.length};n.marks.push(h),o(s.childNodes,i.concat([h])),h.to=n.text.length}};if(o(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&Yo(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 i of n.nodes)i.s>r.i&&(i.s--,i.e--);n.atoms=[]}return n.atomAt=new Map(n.atoms.map(r=>[r.i,r])),n}function wc(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function xc(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,""")}"`;return t+">"}function io(e,t,n){let o="",r=[];for(let i=t;i<n;i++){let c=e.stackAt[i],s=0;for(;s<r.length&&s<c.length&&r[s]===c[s];)s++;for(;r.length>s;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<c.length;){let m=c[r.length];o+=xc(m.el),r.push(m)}let a=e.atomAt.get(i);o+=a?a.el.outerHTML:e.text[i]===gt?"":wc(e.text[i])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function Tc(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 Cs(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 Ns(e,t=()=>!1){let n=new Map,o=i=>{let c=n.get(i);return c===void 0&&(c="{"+i.map(s=>Tc(s,t)).sort().join(",")+"}",n.set(i,c)),c},r="";for(let i=0;i<e.text.length;i++){let c=e.atomAt.get(i);r+=(c?"["+Cs(c.el,t)+"]":e.text[i])+o(e.stackAt[i])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function so(e,t,n,o=r=>r.key){let r=[],i=e.text,c=0,s=a=>{if(a<=c)return;let m=i.slice(c,a);if(n)for(let h of m.split(/(?<=\n)/))r.push({k:h,raw:h,len:h.length});else for(let h of $n(m,t))r.push(h)};for(let a of e.atoms)s(a.i),r.push({k:"\0"+o(a),raw:co,len:1,atom:!0}),c=a.i+1;return s(i.length),r}function Yo(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 Mr=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 Os(e,t,n,o){let r=Mr(t),i=Mr(n),c=[],s=0,a=0;for(let h of o.hunks){a+=h.bs-s;let d=a+h.toks.length;c.push({bs:r[h.bs],be:r[h.be],ss:i[a],se:i[d],text:e.text.slice(i[a],i[d]),toks:h.toks,lead:!!h.lead}),a=d,s=h.be}let m=new Map;for(let h of o.cosmetic)m.set(h.bi,h.tok.raw);return{hunks:c,respell:m}}function vs(e,t,n){let o=c=>c===gt||/\s/.test(c),r=c=>c.replace(/[\u001E\s]/g,""),i=[];for(let c of e){let s=t.slice(c.bs,c.be),a=n.slice(c.ss,c.se);if(!s.includes(gt)&&!a.includes(gt)||s.includes(co)||a.includes(co)||r(s)!==r(a)){i.push(c);continue}let m=0,h=0;for(;;){let d=m,b=h;for(;d<s.length&&o(s[d]);)d++;for(;b<a.length&&o(a[b]);)b++;let A=m,S=h;for(;A<d&&S<b&&s[A]===a[S];)A++,S++;let L=d,f=b;for(;L>A&&f>S&&s[L-1]===a[f-1];)L--,f--;if(L>A||f>S){let g=a.slice(S,f);i.push({bs:c.bs+A,be:c.bs+L,ss:c.ss+S,se:c.ss+f,text:g,toks:[...g].map(x=>({k:x,raw:x,len:1})),lead:c.lead})}if(d>=s.length)break;m=d+1,h=b+1}}return i}function Ms(e,t,n){let o=new Int32Array(t+1).fill(-1),r=new Int32Array(n+1).fill(-1),i=0,c=0,s=a=>{for(;i<a;)o[i]=c,r[c]=i,i++,c++};for(let a of e)s(a.bs),i=a.be,c=a.se;return s(t),o[t]=c,r[c]=t,{bTo:o,toB:r}}function Es(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ir(e){let{out:t,policy:n="remote",L:o,R:r}=e,i=e.provenance||new WeakMap,c=e.textMappers||new WeakMap,s=e.conflicts||[],a=e.decisions||[],m=s.length,h=e.conflict||(l=>s.push(l)),d={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},b=[],A=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),S={base:null,local:null,remote:null};if(A&&e.moveIn){let l=Te=>Ve=>Te.some(ke=>ke===Ve||ke.nodeType===1&&ke.contains(Ve)),w=l(e.local),C=l(e.remote),I=l(e.base),D=new Set,K=Te=>{if(!An.has(Te.tagName))return;let Ve=o.map.get(Te),ke=r.map.get(Te);(Ve&&!w(Ve)||ke&&!C(ke))&&D.add(Te);for(let Ee of Te.children)K(Ee)};for(let Te of e.base)Te.nodeType===1&&K(Te);let pe=Te=>Ve=>{if(!An.has(Ve.tagName))return!1;let ke=Te.reverse.get(Ve);return!!ke&&(D.has(ke)||!I(ke))};D.size&&(S.base=Te=>D.has(Te)),S.local=pe(o),S.remote=pe(r)}let L={base:new Set,local:new Set,remote:new Set};if(A&&e.moveIn){let l=I=>D=>I.some(K=>K===D||K.nodeType===1&&K.contains(D)),w=l(e.local),C=l(e.remote);for(let I of En(e.base,{...e,atomize:S.base}).atoms){let D=o.map.get(I.el),K=r.map.get(I.el),pe=!!D&&!w(D),Te=!!K&&!C(K);!pe&&!Te||(L.base.add(I.el),D&&!pe&&L.local.add(D),K&&!Te&&L.remote.add(K),w(I.el)&&L.local.add(I.el),C(I.el)&&L.remote.add(I.el))}}let f=En(e.base,{...e,atomize:S.base,skip:L.base}),g=En(e.local,{...e,atomize:S.local,skip:L.local}),x=En(e.remote,{...e,atomize:S.remote,skip:L.remote}),Q=new Map(f.atoms.map(l=>[l.el,l])),se={},le=l=>L[l].size?(se[l]||(se[l]=En(e[l],{...e,atomize:S[l]})),se[l]):null,q=(l,w,C)=>{w.namespaceURI?l.setAttributeNS(w.namespaceURI,w.name,C):l.setAttribute(w.name,C)},z=(l,w,C,I)=>{if(!w&&(!C||!I)){for(let K of(C||I).attributes)q(l,K,K.value);return}let D=new Map;for(let K of[w,C,I])if(K)for(let pe of K.attributes)D.set(pe.name,pe);for(let[K,pe]of D){let Te=w?w.getAttribute(K):null,Ve=C?C.getAttribute(K):Te,ke=I?I.getAttribute(K):Te,Ee;Ve===ke?Ee=Ve:Ve===Te?(Ee=ke,a.push({kind:"attr",el:l,name:K,source:"remote"})):ke===Te?(Ee=Ve,a.push({kind:"attr",el:l,name:K,source:"local"})):(Ee=n==="local"?Ve:ke,h({kind:"attr",el:l,name:K,base:Te,local:Ve,remote:ke,resolved:Ee},{el:l,sample:pe}),a.push({kind:"attr",el:l,name:K,source:"both"})),Ee!=null&&q(l,pe,Ee)}},ce=(l,w,C,I)=>l&&e.mergeAttrs?e.mergeAttrs(l,w,C,I):z(I,l,w,C),xe=e.mergeElement||((l,w,C)=>{let I=t.createElement(l.tagName);ce(l,w,C,I);let D=w||l,K=C||l,pe=n==="local"?D.isEqualNode(l)?K:D:K.isEqualNode(l)?D:K;for(let Te of pe.childNodes)I.appendChild(t.importNode(Te,!0));return i.set(I,{base:l,local:w,remote:C}),I}),te=e.cloneUnit||((l,w)=>{let C=t.importNode(l,!0);return i.set(C,{base:null,local:w==="local"?l:null,remote:w==="remote"?l:null}),C}),J=e.atomKey||(l=>Cs(l,()=>!1)),Ce=(l,w)=>{let C=new Map;for(let I of l.atoms)if(e.remoteWins&&e.remoteWins(I.el)&&An.has(I.el.tagName))C.set(I,"w"+I.el.tagName+"#"+(I.el.id||""));else if(!A)C.set(I,I.key);else if(l===f)C.set(I,"="+J(I.el));else{let D=w.reverse.get(I.el),K=D?Q.get(D):null;K?C.set(I,"="+J(K.el)):D?C.set(I,"m"+J(I.el)):C.set(I,"="+J(I.el))}return I=>C.get(I)},we=Ce(f,null),ne=Ce(g,o),_=Ce(x,r),ye=Go(Yo(f),Yo(g),Yo(x)),ge=so(f,ye,!1,we),Oe=so(g,ye,!1,ne),Be=so(x,ye,!1,_),We=ge.length>2e4||Oe.length>2e4||Be.length>2e4;We&&(ge=so(f,ye,!0,we),Oe=so(g,ye,!0,ne),Be=so(x,ye,!0,_));let rt=Nr(ro(ge,Oe),ro(ge,Be),ge),re=Os(g,ge,Oe,{hunks:rt.lh,cosmetic:rt.cosL}),ut=Os(x,ge,Be,{hunks:rt.rh,cosmetic:rt.cosR});re.hunks=vs(re.hunks,f.text,g.text),ut.hunks=vs(ut.hunks,f.text,x.text);let dt=Ms(re.hunks,f.text.length,g.text.length),Se=Ms(ut.hunks,f.text.length,x.text.length),O=f.text.length,B=l=>new Map(l.atoms.map(w=>[w.el,w])),ae=B(g),be=B(x),de=(l,w,C)=>{let I=new Set;if(!A)return I;for(let D of l.atoms){let K=Q.get(w.reverse.get(D.el));K&&C.bTo[K.i]<0&&I.add(K)}return I},ze=de(g,o,dt),De=de(x,r,Se),Qe=l=>!qn(l,{...e,remoteWins:null}),st=new Set;if(A)for(let l of f.atoms){if(!Qe(l.el))continue;let w=o.map.get(l.el)||null,C=r.map.get(l.el)||null,I=w&&!C?w:C&&!w?C:null;I&&(ae.has(I)||be.has(I))&&!I.isEqualNode(l.el)&&st.add(l)}let wt=1,bt=(l,w)=>({id:wt++,tag:l,base:null,local:null,remote:null,rank:w}),Tt=new Map,nn=[];for(let l of f.marks){let w=bt(l.tag,l.depth);w.block=!!l.block,w.base=l.el,w.baseMark=l,Tt.set(l.el,w),nn.push(w)}let Fe=(l,w)=>{let C=-1,I=-1;for(let D=l.from;D<l.to;D++){let K=w[D];K>=0&&(C<0&&(C=K),I=K+1)}return C<0?null:[C,I]},Qt=(l,w,C,I)=>{for(let D of l.marks){let K=C?C.reverse.get(D.el):null;K&&C.identical.has(K)&&C.pairIdenticalChildren&&C.pairIdenticalChildren(K);let pe=K?Tt.get(K):null;if(pe&&pe[w]&&(pe=null),!pe){let Te=Fe(D,I),Ve=0;if(Te)for(let ke of nn){if(ke.tag!==D.tag||ke[w]||!!ke.block!=!!D.block)continue;let Ee=Math.min(Te[1],ke.baseMark.to)-Math.max(Te[0],ke.baseMark.from);(Ee>Ve||Ee===Ve&&Ee>0&&Math.abs(ke.rank-D.depth)<Math.abs(pe.rank-D.depth))&&(pe=ke,Ve=Ee)}}pe||(pe=bt(D.tag,D.depth),pe.block=!!D.block,pe.new=w),pe[w]=D.el,pe[w+"Mark"]=D,Tt.set(D.el,pe)}};Qt(g,"local",o,dt.toB),Qt(x,"remote",r,Se.toB);let Xt=l=>l.merged||l,Bt=l=>{let w=new Set;for(let C of l)C.block||w.add(Tt.get(C.el));return w},Et=new Map,Lt=l=>{let w=Et.get(l);return w||(w=Bt(l),Et.set(l,w)),w},sn=(l,w)=>{let C=[],I=null;for(let D=0;D<O;D++){let K=w[D];if(K<0){I&&C.push(I),I=null;continue}let pe=Lt(f.stackAt[D]),Te=Lt(l.stackAt[K]),Ve=new Set,ke=new Set;for(let Ee of Te)pe.has(Ee)||Ve.add(Ee);for(let Ee of pe)Te.has(Ee)||ke.add(Ee);if(!Ve.size&&!ke.size){I&&C.push(I),I=null;continue}if(I&&Es(I.added,Ve)&&Es(I.removed,ke)){I.be=D+1;continue}I&&C.push(I),I={bs:D,be:D+1,added:Ve,removed:ke}}return I&&C.push(I),C},M=sn(g,dt.bTo),Z=sn(x,Se.bTo),ee=l=>l.be>l.bs?[l.bs,l.be-1]:[l.bs-1,l.bs],ue=(l,w)=>{if(O===0)return null;let[C,I]=ee(l);for(let D of w){if(D.be<=C)continue;if(D.bs>I)break;let K=D.bs<=C&&I<D.be;return K&&l.text===""&&D.bs===l.bs&&D.be===l.be?"straddle":K?D:l.be>l.bs?"straddle":null}return null},oe=l=>l.bs===l.be,fe=(l,w)=>{let C=!1;for(let I=l.bs;I<l.be;I++){let D=f.text[I];if(D===gt)C=!0;else if(!/\s/.test(D))return!1}for(let I=l.ss;I<l.se;I++){let D=w.text[I];if(D===gt)C=!0;else if(!/\s/.test(D))return!1}return C},y=(l,w)=>l.bs<w.be&&w.bs<l.be,T=(l,w)=>l.bs<=w.be&&w.bs<=l.be&&oe(l)!==oe(w),P=(l,w)=>f.text.slice(l.bs,l.be).includes(gt)||w.text.slice(l.ss,l.se).includes(gt),p=l=>{if(oe(l))return!1;let w=l.bs,C=l.be;for(;w>0&&/\s/.test(f.text[w-1]);)w--;for(;C<f.text.length&&/\s/.test(f.text[C]);)C++;return(w===0||f.text[w-1]===gt)&&(C===f.text.length||f.text[C]===gt)},k=(l,w)=>!P(l,w)&&!p(l),R=(l,w)=>y(l,w)||T(l,w)&&!(fe(l,g)&&k(w,x))&&!(fe(w,x)&&k(l,g)),$=(l,w)=>{if(l.bs!==w.bs||l.be!==w.be||l.toks.length!==w.toks.length)return!1;let C=l.ss,I=w.ss;for(let D=0;D<l.toks.length;D++){let K=l.toks[D],pe=w.toks[D];if(K.k!==pe.k||K.atom&&!g.atomAt.get(C).el.isEqualNode(x.atomAt.get(I).el))return!1;C+=K.len,I+=pe.len}return!0},H=(l,w,C,I)=>{for(let D of f.atoms){if(D.i<l.bs||D.i>=l.be||I.has(D)||st.has(D))continue;let K=w.bTo[D.i],pe=K>=0?C.atomAt.get(K):null;if(pe&&!pe.el.isEqualNode(D.el))return!0}return!1},F=[],N=re.hunks,E=ut.hunks,G=0,he=0,ve=0,u=0,v=0,j=l=>{l>ve&&(F.push({src:"base",from:ve,to:l,dL:u,dR:v}),ve=l)};for(;G<N.length||he<E.length;){let l=N[G],w=E[he],C=!!l&&(!w||l.bs<w.bs||l.bs===w.bs&&l.be<=w.be&&!w.lead);if(l&&w&&l.bs===w.bs&&oe(l)&&oe(w)){let Ct=fe(l,g),yo=fe(w,x);Ct!==yo&&(C=yo)}let I=C?l:w,D=C?w:l,K=!!D&&$(l,w),pe=!!D&&(C?!!N[G+1]&&$(N[G+1],w):!!E[he+1]&&$(l,E[he+1])),Te=!!D&&!K&&!pe&&(O===0||R(l,w)),Ve=Te,ke=ue(I,C?Z:M);if(ke==="straddle"&&(Ve=!0),!Ve&&I.be>I.bs&&(Ve=H(I,C?Se:dt,C?x:g,C?ze:De)),!Ve&&K){j(I.bs),F.push({src:"both",lfrom:l.ss,rfrom:w.ss,len:I.text.length}),ve=I.be,u+=I.text.length-(I.be-I.bs),v+=I.text.length-(I.be-I.bs),G++,he++;continue}if(!Ve){j(I.bs),F.push({src:C?"local":"remote",from:I.ss,to:I.se,inherit:ke&&ke!=="straddle"?ke:null}),ve=I.be,C?(u+=I.text.length-(I.be-I.bs),G++):(v+=I.text.length-(I.be-I.bs),he++);continue}let Ee=I.bs,lt=I.be,Ye=G,ot=he,jt=Ct=>Ct.bs<lt&&Ct.be>Ee||oe(Ct)&&(Ct.bs===Ee||Ct.bs===lt);C?Ye++:ot++,Te&&(Ee=Math.min(Ee,D.bs),lt=Math.max(lt,D.be),C?ot++:Ye++);let Nt=!0;for(;Nt;){for(Nt=!1;Ye<N.length&&jt(N[Ye]);)Ee=Math.min(Ee,N[Ye].bs),lt=Math.max(lt,N[Ye].be),Ye++,Nt=!0;for(;ot<E.length&&jt(E[ot]);)Ee=Math.min(Ee,E[ot].bs),lt=Math.max(lt,E[ot].be),ot++,Nt=!0}let rn=Ee+u,Yt=Ee+v,pn=lt-Ee,kn=lt-Ee;for(let Ct=G;Ct<Ye;Ct++)pn+=N[Ct].text.length-(N[Ct].be-N[Ct].bs);for(let Ct=he;Ct<ot;Ct++)kn+=E[Ct].text.length-(E[Ct].be-E[Ct].bs);let On=rn+pn,vn=Yt+kn;j(Ee);let Wt={kind:"text",node:e.node||null,base:io(f,Ee,lt),local:io(g,rn,On),remote:io(x,Yt,vn),resolved:null,range:null,bs:Ee,be:lt,lss:rn,lse:On,rss:Yt,rse:vn};Wt.resolved=n==="local"?Wt.local:n==="remote"?Wt.remote:Wt.local+Wt.remote,n!=="remote"&&F.push({src:"local",from:rn,to:On,conflict:Wt}),n!=="local"&&F.push({src:"remote",from:Yt,to:vn,conflict:Wt});let Vo={site:"inline",fb:f,fl:g,fr:x,scope:e.scope||null,synthetic:!!e.synthetic,full:le,merged:d};b.push(Vo),h(Wt,Vo),ve=lt,u+=pn-(lt-Ee),v+=kn-(lt-Ee),G=Ye,he=ot}j(O);let U=f.text,V=[];if(re.respell.size||ut.respell.size){let l=Mr(ge),w=[];for(let C=0;C<ge.length;C++){let I=ge[C].raw,D=re.respell.get(C)??I,K=ut.respell.get(C)??I;(D!==I||K!==I)&&V.push([l[C],D!==I&&K!==I?"both":D!==I?"local":"remote"]),w.push(D===K?D:D===I?K:K===I||n==="local"?D:K)}U=w.join("")}let W="",Y=[],ie=[],Ne=[],Le=[];for(let l of F){let w=W.length;if(l.src==="base"){for(let C=l.from;C<l.to;C++)Y.push(C),ie.push(C+l.dL),Ne.push(C+l.dR),Le.push(l);W+=U.slice(l.from,l.to)}else if(l.src==="both"){for(let C=0;C<l.len;C++)Y.push(-1),ie.push(l.lfrom+C),Ne.push(l.rfrom+C),Le.push(l);W+=g.text.slice(l.lfrom,l.lfrom+l.len)}else{let C=l.src==="local"?g:x;for(let I=l.from;I<l.to;I++)Y.push(-1),ie.push(l.src==="local"?I:-1),Ne.push(l.src==="remote"?I:-1),Le.push(l);W+=C.text.slice(l.from,l.to)}l.ms=w,l.me=W.length,l.conflict&&(l.conflict.range||(l.conflict.range=[w,w]),l.conflict.range[1]=W.length)}let Me=W.length,Ze=new Int32Array(O+1).fill(-1),je=new Int32Array(g.text.length+1).fill(-1),Ot=new Int32Array(x.text.length+1).fill(-1);for(let l=0;l<Me;l++)Y[l]>=0&&(Ze[Y[l]]=l),ie[l]>=0&&(je[ie[l]]=l),Ne[l]>=0&&(Ot[Ne[l]]=l);let Ue=(l,w)=>{let C=-1,I=-1;for(let D=l.from;D<l.to;D++){let K=w[D];K>=0&&(C<0&&(C=K),I=K+1)}return C<0?null:[C,I]},ht=[],it=[];for(let l of new Set(Tt.values()))l.new==="local"?ht.push(l):l.new==="remote"&&it.push(l);let Kt=(l,w)=>{l.remote=w.remote,l.remoteMark=w.remoteMark,l.new="both",w.merged=l,Tt.set(w.remote,l)};if(ht.length&&it.length){let l=e.idOf;for(let w of ht){let C=l?l.local(w.local):null;if(!C)continue;let I=it.find(D=>!D.merged&&D.tag===w.tag&&!!D.block==!!w.block&&l.remote(D.remote)===C);I&&Kt(w,I)}for(let w of ht){if(w.remote)continue;let C=Ue(w.localMark,je);if(C)for(let I of it){if(I.merged||I.tag!==w.tag||!!I.block!=!!w.block)continue;let D=Ue(I.remoteMark,Ot);if(D&&Math.min(C[1],D[1])-Math.max(C[0],D[0])>0){Kt(w,I);break}}}}Et.clear();let Rt=l=>{for(let w of l)if(w.block)return Xt(Tt.get(w.el));return null},qt=f.marks.some(l=>l.block)||g.marks.some(l=>l.block)||x.marks.some(l=>l.block),It=new Array(Me).fill(null),at=new Set;if(qt){let l=(ke,Ee,lt)=>{let Ye=new Set([ke,Ee,lt]);Ye.delete(null);let ot=[];for(let Nt of Ye){let rn=Nt===ke,Yt=Nt===Ee,pn=Nt===lt;(Yt===pn?Yt:Yt===rn?pn:Yt)&&ot.push(Nt)}if(ot.length<=1)return ot[0]||null;let jt=n==="local"?Ee:lt;return ot.includes(jt)?jt:ot[0]},w=(ke,Ee)=>Ee>=0?Rt(ke.stackAt[Ee]):null,C=new Map;for(let ke=0;ke<Me;ke++){if(W[ke]!==gt)continue;let Ee=Y[ke]>=0?w(f,Y[ke]):null,lt=w(g,ie[ke]),Ye=w(x,Ne[ke]);C.set(ke,[Ee,Y[ke]>=0?l(Ee,lt,Ye):lt||Ye])}let I=new Set([...C.values()].map(ke=>ke[1])),D=ke=>ke!==gt&&ke!==co&&!/\s/.test(ke),K=(ke,Ee)=>{let lt=ke;for(;lt<Ee&&!D(W[lt]);)lt++;return lt<Ee&&Y[lt]>=0?w(f,Y[lt]):null},pe=new Map,Te=0;for(let ke=0;ke<Me;ke++){if(W[ke]!==gt)continue;let[Ee,lt]=C.get(ke),Ye=K(Te,ke),ot=lt,jt=pe.get(ot)===ot&&Ye===ot;ot&&pe.has(ot)&&!jt&&Ee&&!pe.has(Ee)&&!I.has(Ee)&&(ot=Ee),ot&&!pe.has(ot)&&pe.set(ot,Ye);for(let Nt=Te;Nt<=ke;Nt++)It[Nt]=ot;Te=ke+1}let Ve=ke=>{for(let Ee=0;Ee<ke.text.length;Ee++)if(D(ke.text[Ee])&&!w(ke,Ee))return!0;return!1};if(!Ve(f)&&!Ve(g)&&!Ve(x)){let ke=[],Ee=0;for(let Ye=0;Ye<Me;Ye++)(W[Ye]===gt||Ye===Me-1)&&(ke.push([Ee,Ye]),Ee=Ye+1);let lt=new Set(It);for(let Ye=0;Ye<ke.length;Ye++){let[ot,jt]=ke[Ye];if(It[jt])continue;let Nt=ot;for(;Nt<=jt&&!D(W[Nt]);)Nt++;if(Nt>jt)continue;let rn=w(f,Y[Nt]),Yt=w(g,ie[Nt]),pn=w(x,Ne[Nt]),kn=l(rn,Yt,pn)||Yt||pn||rn;if(kn&&!lt.has(kn)){lt.add(kn);for(let Wt=ot;Wt<=jt;Wt++)It[Wt]=kn;continue}let On=Ye>0&&It[ke[Ye-1][1]],vn=Ye+1<ke.length&&It[ke[Ye+1][1]];if(On)at.add(ke[Ye-1][1]);else if(vn&&W[jt]===gt)at.add(jt);else continue;for(let Wt=ot;Wt<=jt;Wt++)It[Wt]=On||vn}}}let St=new Map,At=l=>{let w=St.get(l);if(w)return w;w=[1/0,-1/0];for(let[C,I]of[[l.baseMark,Ze],[l.localMark,je],[l.remoteMark,Ot]]){let D=C&&Ue(C,I);D&&(w[0]=Math.min(w[0],D[0]),w[1]=Math.max(w[1],D[1]))}return St.set(l,w),w},Ht=(l,w,C)=>{let I=-1,D=-1;for(let K=0;K<l.length;K++){let pe=Tt.get(l[K].el);pe===w&&(I=K),pe===C&&(D=K)}return I>=0&&D>=0?I-D:0},Zt=(l,w)=>[...l].sort((C,I)=>{for(let pe of w){let Te=Ht(pe,C,I);if(Te)return Te}let D=At(C),K=At(I);return D[0]-K[0]||K[1]-D[1]||C.rank-I.rank||C.id-I.id}),un=new Map,In=new Map,Cn=l=>{let w=Y[l],C=ie[l],I=Ne[l],D=Le[l];if(w>=0){let Ye=f.stackAt[w],ot=g.stackAt[C],jt=x.stackAt[I],Nt=un.get(Ye);Nt||un.set(Ye,Nt=new Map);let rn=Nt.get(ot);rn||Nt.set(ot,rn=new Map);let Yt=rn.get(jt);if(Yt)return Yt;let pn=Lt(Ye),kn=Lt(ot),On=Lt(jt),vn=new Set;for(let Wt of new Set([...pn,...kn,...On])){let Vo=pn.has(Wt),Ct=kn.has(Wt),yo=On.has(Wt);(Ct===yo?Ct:Ct===Vo?yo:Ct)&&vn.add(Wt)}return Yt=Zt(vn,[ot,jt,Ye]),rn.set(jt,Yt),Yt}if(D.src==="both"){let Ye=g.stackAt[C],ot=x.stackAt[I];return Zt(new Set([...Lt(Ye),...Lt(ot)]),[Ye,ot])}let pe=(D.src==="local"?g:x).stackAt[D.src==="local"?C:I];if(!D.inherit)return Zt(Lt(pe),[pe]);let Te=In.get(D);Te||In.set(D,Te=new Map);let Ve=Te.get(pe);if(Ve)return Ve;let ke=new Set(Lt(pe));for(let Ye of D.inherit.added)ke.add(Xt(Ye));for(let Ye of D.inherit.removed)ke.delete(Xt(Ye));let Ee=D.src==="local"?x:g,lt=(D.src==="local"?Se.bTo:dt.bTo)[D.inherit.bs];return Ve=Zt(ke,[pe,Ee.stackAt[lt]]),Te.set(pe,Ve),Ve},xn=new Int32Array(g.text.length+1);xn[g.text.length]=Me;for(let l=g.text.length-1;l>=0;l--)xn[l]=je[l]>=0?je[l]:xn[l+1];yc.caret+=g.text.length;let cn=l=>l<=0?0:(l>g.text.length&&(l=g.text.length),je[l-1]>=0?je[l-1]+1:xn[l]),zt=[],X=[],Re=null,Ae=[],Ge="",ct=-1,He=l=>{Re?Re.appendChild(l):zt.push(l)},$e=l=>{if(!Ge)return;let w=t.createTextNode(Ge);He(w),X.push({node:w,ms:ct,me:l,local:[],u:Ae.length?Ae[Ae.length-1].u:null}),Ge=""},et=new Set,_e=new Map,nt=new Set,en=l=>{let w=t.createElement(l.tag);if(l.block&&_t.add(w),!_e.has(l)){_e.set(l,w),ce(l.base,l.local,l.remote,w),i.set(w,{base:l.base,local:l.local,remote:l.remote});let I=(pe,Te)=>A&&l[Te]&&pe.reverse.get(l[Te])?Te:null,D=!l.base&&(I(o,"local")||I(r,"remote"));if(D){let pe=D==="local"?o.reverse.get(l.local):r.reverse.get(l.remote),Te=i.get(w);Te.local=Te.local||o.map.get(pe)||null,Te.remote=Te.remote||r.map.get(pe)||null,a.push({kind:"move",el:w,source:D})}else l.base||a.push({kind:"insert",el:w,source:l.local&&l.remote?"both":l.local?"local":"remote"});let K=i.get(w);K.local&&(nt.has(K.local)?K.local=null:nt.add(K.local))}else{let I=_e.get(l);for(let D of I.attributes)D.name!=="id"&&D.name!=="data-id"&&q(w,D,D.value);i.set(w,{base:null,local:null,remote:null})}He(w),Ae.push({u:l,el:w}),Re=w},Vn=new Set,dn=new Map;for(let l of g.pins){let w=cn(l.i);dn.has(w)||dn.set(w,[]),dn.get(w).push(l)}let ln=l=>{let w=dn.get(l);if(w){$e(l);for(let C of w){let I=C.el.namespaceURI&&C.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(C.el.namespaceURI,C.el.tagName):t.createElement(C.el.tagName);i.set(I,{base:null,local:C.el,remote:null,pinned:!0}),Vn.add(I),He(I)}}},Wn=f.atoms.length||g.atoms.length||x.atoms.length,Je=l=>{if(!Wn)return null;let w=Y[l]>=0?f.atomAt.get(Y[l]):null,C=ie[l]>=0?g.atomAt.get(ie[l]):null,I=Ne[l]>=0?x.atomAt.get(Ne[l]):null;return w||C||I?{ab:w,al:C,ar:I}:null},ft=(l,w,C,I)=>{if(!l||!A)return null;let D=Q.get(w.reverse.get(l.el))||null;return!D||D===I||(I?D.el.isEqualNode(I.el):C.bTo[D.i]>=0)?null:D},me=(l,w)=>{if(!l||!A||!e.moveIn)return null;let C=w.reverse.get(l.el);return C&&!Q.has(C)?C:null},Ie=(l,w)=>{let C=new Map;for(let I of l.atoms)C.set(w(I),(C.get(w(I))||0)+1);return C},qe=Ie(f,we),tt=Ie(g,ne),Ke=Ie(x,_),kt=l=>{let w=we(l);return qe.get(w)===1&&(tt.get(w)||0)<=1&&(Ke.get(w)||0)<=1},yt=new Map,Pt=new Set,Ft=new Set,on=new Set;for(let l=0;l<Me;l++){let w=Je(l);if(!w)continue;let{ab:C,al:I,ar:D}=w,K=ft(D,r,Se,C),pe=ft(I,o,dt,C),Te=C,Ve=null;if(K?(Te=K,Ve="remote"):pe&&(Te=pe,Ve="local"),Te){Pt.has(Te)?yt.set(l,{dup:Te.el}):(Pt.add(Te),yt.set(l,{bk:Te,from:Ve,al:I,ar:D}));continue}let ke=me(D,r),Ee=me(I,o),lt=ke||Ee;if(lt){Ft.has(lt)?yt.set(l,{dup:lt}):(Ft.add(lt),yt.set(l,{moveIn:lt,side:ke?"remote":"local",sideEl:ke?D.el:I.el}));continue}let Ye=(jt,Nt)=>jt&&A&&Q.get(Nt.reverse.get(jt.el))||null,ot=Ye(D,r)||Ye(I,o);if(ot&&(on.add(ot),Le[l].conflict&&kt(ot))){if(Pt.has(ot)){yt.set(l,{dup:ot.el});continue}Pt.add(ot)}yt.set(l,{al:I,ar:D})}let vt=new Map,Ln=(l,w)=>{if(l[w]>=0)return l[w];for(let C=w-1;C>=0;C--)if(l[C]>=0)return l[C]+1;return 0};if(A)for(let l of f.atoms){if(Pt.has(l)||on.has(l))continue;let w=o.map.get(l.el)||null,C=r.map.get(l.el)||null,I=w&&ae.get(w),D=C&&be.get(C);if(w&&!I||C&&!D)continue;let K=!(I&&D)&&st.has(l);if(!K&&!(I&&D&&kt(l)))continue;let pe=n==="local"?[[I,je],[D,Ot]]:[[D,Ot],[I,je]],[Te,Ve]=pe.find(([Ee])=>Ee),ke=Ln(Ve,Te.i);vt.has(ke)||vt.set(ke,[]),vt.get(ke).push({a:l,lt:w,rt:C,edited:K}),Pt.add(l)}if(A&&e.moveIn){let l=[[g,o,je,"local"],[x,r,Ot,"remote"]];n!=="local"&&l.reverse();for(let[w,C,I,D]of l)for(let K of w.atoms){let pe=me(K,C);if(!pe||Ft.has(pe))continue;Ft.add(pe);let Te=Ln(I,K.i);vt.has(Te)||vt.set(Te,[]),vt.get(Te).push({move:pe,side:D,sideEl:K.el})}}let Ut=l=>{let w=vt.get(l);if(w){if($e(l),w.some(C=>Qe(C.move?C.sideEl:C.a.el)))for(;Ae.length;)Ae.pop(),Re=Ae.length?Ae[Ae.length-1].el:null;for(let{a:C,lt:I,rt:D,edited:K,move:pe,side:Te,sideEl:Ve}of w){if(pe){let Ee=e.moveIn(pe,Te,Ve);Ee&&He(Ee);continue}et.add(C);let ke=xe(C.el,I,D);K&&(h({kind:"structure",el:ke,detail:"edit-beats-delete",base:C.el},{subject:C.el,deleted:I?"remote":"local"}),a.push({kind:"insert",el:ke,source:I?"local":"remote"})),He(ke)}}},_t=new Set,an=s.length>m;for(let l=0;l<Me;l++){let w=Je(l),I=!!w&&Qe((w.ab||w.al||w.ar).el)?[]:It[l]?[It[l],...Cn(l)]:Cn(l),D=0;for(;D<Ae.length&&D<I.length&&Ae[D].u===I[D];)D++;if(D<Ae.length)for($e(l);Ae.length>D;)Ae.pop(),Re=Ae.length?Ae[Ae.length-1].el:null;if(ln(l),Ut(l),I.length>Ae.length)for($e(l);Ae.length<I.length;)en(I[Ae.length]);if(W[l]===gt){if(at.has(l))continue;$e(l);let K=Ae.length;for(;K>0&&!Ae[K-1].u.block;)K--;if(K>0)for(an&&d.breakOut.set(l,Ae[K-1].el);Ae.length>=K;)Ae.pop(),Re=Ae.length?Ae[Ae.length-1].el:null;continue}if(w){$e(l);let K=yt.get(l),pe;if(K.dup){h({kind:"structure",el:null,detail:"both-moved",base:K.dup},{subject:K.dup});continue}if(K.moveIn){if(pe=e.moveIn(K.moveIn,K.side,K.sideEl),!pe)continue}else if(K.bk){let Te=K.bk;if(et.add(Te),Te===w.ab)pe=xe(Te.el,K.al.el,K.ar.el);else{let Ve=o.map.get(Te.el)||null,ke=r.map.get(Te.el)||null;pe=xe(Te.el,Ve,ke),(!Ve||!ke)&&h({kind:"structure",el:null,detail:"move-beats-delete",base:Te.el},{subject:Te.el,deleted:Ve?"remote":"local"}),a.push({kind:"move",el:pe,source:K.from})}}else K.al?(pe=te(K.al.el,"local"),K.ar&&(i.get(pe).remote=K.ar.el),a.push({kind:"insert",el:pe,source:K.ar?"both":"local"})):(pe=te(K.ar.el,"remote"),a.push({kind:"insert",el:pe,source:"remote"}));an&&d.atomOut.set(l,pe),He(pe);continue}Ge||(ct=l),Ge+=W[l]}if($e(Me),(dn.has(Me)||vt.has(Me))&&(Ae.length=0,Re=null,ln(Me),Ut(Me)),Me===0&&(g.placeholder||x.placeholder||f.placeholder)){let l=t.createElement("br");i.set(l,{base:f.placeholder,local:g.placeholder,remote:x.placeholder}),zt.push(l)}let bn=0,Uo=l=>{for(;bn>0&&X[bn-1].me>=l;)bn--;for(;bn<X.length&&X[bn].me<l;)bn++;let w=X[bn];if(!w)return X[X.length-1]||null;let C=X[bn+1];return w.me===l&&C&&C.ms===l?C:w},Zn=new Map,bo={},Pe=(l,w,C)=>{let I=Uo(l)||(C?bo:null);if(!I)return;let D=Zn.get(I)||{l:!1,r:!1};w!=="remote"&&(D.l=!0),w!=="local"&&(D.r=!0),Zn.set(I,D)},pt=l=>{if(l.conflict)return!0;let w=l.src==="local"?g.text:l.src==="remote"?x.text:"";for(let C=l.from;C<l.to;C++)if(w[C]!==co&&w[C]!==gt)return!0;return!1};for(let l of F)l.src!=="base"&&Pe(l.ms,l.conflict?"both":l.src,pt(l));for(let[l,w]of V)Ze[l]>=0&&Pe(Ze[l],w);for(let l of X.length?X:[bo]){let w=Zn.get(l);w&&a.push({kind:"text",node:l.node||null,source:w.l&&w.r?"both":w.l?"local":"remote"})}for(let l of nn){if(_e.has(l))continue;let w=!l.local&&!(A&&o.map.get(l.base)),C=!l.remote&&!(A&&r.map.get(l.base));!w&&!C||a.push({kind:"remove",source:w&&C?"both":w?"local":"remote",base:l.base})}let Mt=(l,w,C)=>{if(w<=l)return!1;for(let I=l;I<w;I++)if(C[I]>=0)return!1;return!0};for(let l of nn)for(let w of["local","remote"]){let C=l[w+"Mark"],I=l.baseMark;if(!C)continue;let D=w==="local"?dt:Se;if(!Mt(I.from,I.to,D.bTo)||!Mt(C.from,C.to,D.toB))continue;let K=(w==="local"?N:E).find(pe=>pe.ss<=C.from&&C.from<pe.se);K&&(K.be<=I.from||K.bs>=I.to)&&a.push({kind:"move",el:_e.get(l)||null,source:w})}let xt=l=>{let w=Tt.get(l.node.parentNode);return w?Xt(w):null};for(let l of g.nodes){let w=-1;for(let I=l.s;I<l.e;I++)if(je[I]>=0){w=je[I];break}let C;if(w>=0)C=Uo(w);else{let I=cn(l.s),D=xt(l);C=X.find(K=>K.u===D&&K.me>=I)||X.filter(K=>K.u===D).pop()}C&&C.local.push(l)}let mt=new Map,yn=X[X.length-1]||null,Vt=0;for(let l of g.nodes){let w=null;for(let C=l.s;C<=l.e;C++){let I=cn(C);for(;Vt>0&&X[Vt-1].me>=I;)Vt--;for(;Vt<X.length&&X[Vt].me<I;)Vt++;let D=pe=>pe&&I>=pe.ms&&I<=pe.me&&(I<pe.me||C===l.e||pe===w),K=D(X[Vt])?X[Vt]:D(X[Vt+1])?X[Vt+1]:X[Vt]||yn;if(!K)break;if(w===K){let pe=mt.get(K);pe[pe.length-1].to=C-l.s;continue}w=K,mt.has(K)||mt.set(K,[]),mt.get(K).push({node:l.node,from:C-l.s,to:C-l.s,flatStart:l.s})}}for(let l of X){let w=l.local,C=!1;for(let pe of w)for(let Te=pe.s;Te<pe.e&&!C;Te++)(je[Te]<l.ms||je[Te]>=l.me)&&(C=!0);i.set(l.node,{base:null,local:w.map(pe=>pe.node),remote:null,caret:mt.get(l)||[],partial:C});let I=l.ms,D=l.me-l.ms,K=pe=>{let Te=0,Ve=-1;for(let ke of w){let Ee=ke.e-ke.s;if(pe<=Te+Ee){Ve=ke.s+(pe-Te);break}Te+=Ee}return Ve<0&&(Ve=w.length?w[w.length-1].e:0),Math.max(0,Math.min(cn(Ve)-I,D))};K.flat=pe=>Math.max(0,Math.min(cn(pe)-I,D)),c.set(l.node,K)}function Rn(){if(!g.text.includes(gt))return[{flatLocal:g.text,localNodes:g.nodes,textNodes:X,lToM:je,mapLocal:cn}];let l=[],w=0,C=0;for(let I=0;I<=g.text.length;I++){if(I<g.text.length&&g.text[I]!==gt)continue;let D=w,K=I;if(K>D){let pe=[];for(;C<g.nodes.length&&g.nodes[C].e<=D;)C++;for(let Te=C;Te<g.nodes.length&&g.nodes[Te].s<K;Te++){let Ve=g.nodes[Te],ke=Math.max(Ve.s,D),Ee=Math.min(Ve.e,K);ke<Ee&&pe.push({node:Ve.node,s:ke-D,e:Ee-D})}l.push({flatLocal:g.text.slice(D,K),localNodes:pe,textNodes:X,lToM:je.subarray?je.subarray(D,K+1):je.slice(D,K+1),mapLocal:Te=>cn(D+Math.max(0,Math.min(Te,K-D)))})}w=I+1}return l}let Tn={...e,blocks:_t,ignored:l=>Vn.has(l)||(e.ignored?e.ignored(l):!1)},Gt=e.ignoreAttribute||(()=>!1),_o=Ns(En(zt,Tn),Gt)!==Ns(x,Gt);if(b.length){let l=w=>{let C=i.get(w);return C&&C.unchanged?C.remote:null};d.text=W,d.textNodes=X,d.out=En(zt,{...Tn,via:l})}return{nodes:zt,text:W,textNodes:X,localDiverged:_o,mapLocal:cn,conflicts:s.slice(m),granularity:We?"line":"word",segments:Rn(),localHunks:N,remoteHunks:E,lToM:je}}var Ac="http://www.w3.org/1999/xhtml";function Sc(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 tn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Ac}function Nc(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Jo(e,t){let n=e.getAttribute("src"),o=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(n){let r=n;try{let i=new URL(n,t);r=i.origin+i.pathname+i.search}catch{}return"script|src|"+o+"|"+r}return"script|inline|"+o+"|"+Sc(e.textContent.trim())}var Oc={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function lo(e,t=[],n=!1){if(!tn(e)||e.hasAttribute("src"))return null;let o=[Oc,...t];for(let r=0;r<o.length;r++){let i=o[r];if(!i.match(e))continue;if(!Nc(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let c=i.identity(e);return c==null||c===""?null:{key:r+":"+c,raw:c,recognizer:i}}return null}function Ls(e,t,n){let o=new Set,r=i=>{tn(i)&&!t(i)&&o.add(Jo(i,n))};r(e);for(let i of e.querySelectorAll("script"))r(i);return o}function To(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 Rs(e,t,n){let o=[],r=[],i=new Map,c=n.trackRecovery?new Set:null,s=Array.from(e.querySelectorAll("script"));tn(e)&&s.unshift(e);for(let a of s){if(!tn(a)||n.ignored(a)||n.skip.has(a)||t.has(Jo(a,n.baseURI)))continue;let m=a.ownerDocument.createElement("script");for(let h of a.attributes)m.setAttribute(h.name,h.value);if(m.textContent=a.textContent,n.beforeNodeAdded(m)===!1){c?.add(a);continue}m.hasAttribute("src")&&r.push(new Promise(h=>{m.addEventListener("load",()=>h()),m.addEventListener("error",()=>h())})),a.replaceWith(m),i.set(a,m),n.afterNodeAdded(m),o.push(m)}return{executed:o,loads:r,swapped:i,vetoed:c}}function vc(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 Mc(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function Ps(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Jo(e,t);if(n==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+Mc(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|"+vc(e.textContent):e.outerHTML}function Cr(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 Ec(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var Ic=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Cc=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Lr(e){try{return JSON.parse(e)}catch{return JSON.parse(Lc(e))}}function Lc(e){let t="",n=0,o=(r,i)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${i}`)};for(;n<e.length&&(n=Cr(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let s=Cr(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 a=e.slice(n+1,s);r==="'"&&(a=Ec(a)),t+='"'+a+'"',n=s+1;continue}let i=n;for(;i<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[i]);)i++;i===n&&o("unexpected character "+JSON.stringify(r),n);let c=e.slice(n,i);if(c==="true"||c==="false"||c==="null"||Ic.test(c)){t+=c,n=i;continue}if(Cc.test(c)){if(e[Cr(e,i)]===":"){t+='"'+c+'"',n=i;continue}o("unquoted value "+JSON.stringify(c),n)}o("invalid token "+JSON.stringify(c),n)}return t}var Dt=Symbol("hyper-morph-json-merge:missing"),js=["id","_id","uuid","key","slug","code","name"];function ao(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ao(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rc(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function Hn(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(!Hn(e[n],t[n]))return!1;return!0}if(ao(e)&&ao(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Ao(t,o)||!Hn(e[o],t[o]))return!1;return!0}return!1}function Ds(e,t,n,o){return Hn(t,n)?t:Hn(t,e)?n:Hn(n,e)?t:ao(t)&&ao(n)?Pc(ao(e)?e:{},t,n,o):Array.isArray(t)&&Array.isArray(n)?Bc(Array.isArray(e)?e:[],t,n,o):n}function Hs(e,t,n,o){return t===Dt&&n===Dt?Dt:t===Dt?e===Dt?n:Hn(n,e)?Dt:n:n===Dt?e===Dt?t:Dt:Ds(e,t,n,o)}function Pc(e,t,n,o){let r={},i=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let c of i){let s=Hs(Ao(e,c)?e[c]:Dt,Ao(t,c)?t[c]:Dt,Ao(n,c)?n[c]:Dt,o);s!==Dt&&Rc(r,c,s)}return r}function jc(e){return e===null||typeof e!="object"}function Xo(e){return typeof e+":"+String(e)}function Dc(e,t){for(let n of t){let o=new Set;for(let r of n){if(!Ao(r,e))return!1;let i=r[e];if(typeof i!="string"&&typeof i!="number")return!1;let c=Xo(i);if(o.has(c))return!1;o.add(c)}}return!0}function Hc(e,t,n,o){let r=[e,t,n],i=!0;for(let c of r)for(let s of c)ao(s)||(i=!1);if(i){for(let c of o.keyCandidates)if(Dc(c,r))return{kind:"keyed",field:c};return null}for(let c of r){let s=new Set;for(let a of c){if(!jc(a))return null;let m=Xo(a);if(s.has(m))return null;s.add(m)}}return{kind:"self"}}function Bc(e,t,n,o){let r=Hc(e,t,n,o);if(!r)return n;let i=r.kind==="self"?Xo:A=>Xo(A[r.field]),c=A=>{let S=new Map;for(let L of A)S.set(i(L),L);return S},s=c(e),a=c(t),m=c(n),h=new Map,d=new Set([...s.keys(),...a.keys(),...m.keys()]);for(let A of d){let S=Hs(s.has(A)?s.get(A):Dt,a.has(A)?a.get(A):Dt,m.has(A)?m.get(A):Dt,o);S!==Dt&&h.set(A,S)}let b=[];for(let A of n){let S=i(A);h.has(S)&&b.push(S)}for(let A=0;A<t.length;A++){let S=i(t[A]);if(!h.has(S)||b.includes(S))continue;let L=0;for(let f=A-1;f>=0;f--){let g=b.indexOf(i(t[f]));if(g!==-1){L=g+1;break}}b.splice(L,0,S)}return b.map(A=>h.get(A))}function Bs(e,t,n,o={}){let r=o.keyCandidates?[...o.keyCandidates,...js]:js;return Ds(e===void 0?Dt:e,t,n,{keyCandidates:r})}function Rr(e,t,n,o={}){let r=o.parse||Lr,i=[],c=(d,b)=>{if(typeof d!="string")return Dt;try{return r(d)}catch(A){return i.push(`${b} side is not valid JSON (${A.message})`),Dt}},s=c(t,"local"),a=c(n,"remote");if(s===Dt)return{text:n,warnings:i};if(a===Dt)return{text:t,warnings:i};let m=c(e,"base"),h=Bs(m===Dt?void 0:m,s,a,o);return Hn(h,a)?{text:n,warnings:i}:Hn(h,s)?{text:t,warnings:i}:{text:JSON.stringify(h,null,2),warnings:i}}var Us=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Kn(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>Us(t)||r>Us(o)||t.getRootNode()!==o.getRootNode())return!1;let i=t.ownerDocument.createRange();return i.setStart(t,n),i.setEnd(o,r),i.startContainer===t&&i.startOffset===n}function Bn(e,t,n={}){if(!Kn(e))return null;let{startContainer:o,startOffset:r,endContainer:i,endOffset:c}=e;if(o===i&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,c);if(o===i&&r===c)return"";let s=new Set;for(let f=o;f;f=f.parentNode)s.add(f);let a=i;for(;!s.has(a);)a=a.parentNode;let m=(f,g)=>{let x=a.ownerDocument.createRange(),Q=a.ownerDocument.createRange();return x.setStart(f[0],f[1]),x.collapse(!0),Q.setStart(g[0],g[1]),Q.collapse(!0),x.compareBoundaryPoints(0,Q)},h=(f,g=!1)=>[f.parentNode,Array.prototype.indexOf.call(f.parentNode.childNodes,f)+Number(g)],d=[],b;if(t==="plain"){b="";let f=g=>{if(g.nodeType===3||g.nodeType===8){let x=b.length;b+=g.nodeValue,d.push({s:x,e:b.length,a:[g,0],b:[g,g.nodeValue.length],node:g})}else for(let x of g.childNodes)f(x)};f(a)}else{let f=n.blocks;if(!f){f=new Set;let x=Q=>{Q!==a&&Q.nodeType===1&&Er.has(Q.tagName)&&f.add(Q);for(let se of Q.childNodes)x(se)};x(a)}let g=En(Array.from(a.childNodes),{blocks:f,atomize:x=>!!n.atoms?.has(x),ignored:n.ignored});b=g.text;for(let x of g.nodes)d.push({s:x.s,e:x.e,a:[x.node,0],b:[x.node,x.e-x.s],node:x.node});for(let x of g.atoms)d.push({s:x.i,e:x.i+1,a:h(x.el),b:h(x.el,!0)});for(let x=0;x<g.text.length;x++){if(g.text[x]!==gt)continue;let Q=g.marks.find(le=>le.block&&le.to===x+1),se=g.marks.find(le=>le.block&&le.from===x+1);if(Q)d.push({s:x,e:x+1,a:[Q.el,Q.el.childNodes.length],b:h(Q.el,!0)});else if(se)d.push({s:x,e:x+1,a:h(se.el),b:[se.el,0]});else return null}}d.sort((f,g)=>f.s-g.s);let A=f=>{if(f[0].nodeType===3||f[0].nodeType===8){let x=d.find(Q=>Q.node===f[0]);return x?x.s+f[1]:null}let g=0;for(let x of d){if(m(f,x.a)<=0)return x.s;if(m(f,x.b)<0)return null;g=x.e}return g},S=A([o,r]),L=A([i,c]);return S!==null&&L!==null&&S<=L?b.slice(S,L):null}function Fn(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 _s(e,t){if(!e||!t)return null;let n=Fn(e,t.start),o=Fn(e,t.end);return n&&o?{startContainer:n[0],startOffset:n[1],endContainer:o[0],endOffset:o[1]}:null}var Vs=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ws(e,t,n){if(!t)return;let o=new Map,r=new Map,i=s=>{if(!s)return null;if(r.has(s))return r.get(s);let m=s.local.map(h=>Fn(t.localRoot,{path:h,offset:0})?.[0]).map(h=>h&&n(h)).filter(Boolean).map(h=>({node:h,parent:h.parentNode,previous:h.previousSibling,next:h.nextSibling,fragment:Vs(h)}));return r.set(s,m),m},c=s=>{let a=_s(t.localRoot,s);if(!a)return null;let m=n(a.startContainer),h=n(a.endContainer);if(!m||!h)return null;let d={...a,startContainer:m,endContainer:h};return Kn(d)?d:null};for(let s of e){let a=s.recovery;if(o.has(a))continue;let m={subject:i(a.subject),span:null,scope:null,touched:new Set};if(a.text){m.span=c(a.text.local.span),m.scope=c(a.text.local.scope);let h=m.span;if(h){let d=h.startContainer.ownerDocument.createRange();d.setStart(h.startContainer,h.startOffset),d.setEnd(h.endContainer,h.endOffset);let b=A=>{if(d.intersectsNode(A)){m.touched.add(A);for(let S of A.childNodes)b(S)}};b(d.commonAncestorContainer)}}if(a.structure){for(let h of[a.structure.localPlacement])h&&(i(h.parent),h.before.forEach(i),h.after.forEach(i));for(let h of a.structure.localOrder||[])i(h)}o.set(a,m)}t.localState={states:o,refs:r}}function $s(e,t,n,o){let r=n.localState?.states.get(e);if(!r)return!1;let i=s=>{let a=s.node;if(!o(a)||a.parentNode!==s.parent)return!1;let m=h=>Array.prototype.indexOf.call(a.parentNode.childNodes,h);return!(s.previous&&o(s.previous)&&s.previous.parentNode===a.parentNode&&m(s.previous)>=m(a)||s.next&&o(s.next)&&s.next.parentNode===a.parentNode&&m(s.next)<=m(a))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!r.subject.length||!r.subject.every(i))return!1;if(e.text){let s=e.text.local,a=m=>m&&o(m.startContainer)&&o(m.endContainer);return a(r.span)&&a(r.scope)&&Bn(r.scope,e.text.encoding)===s.text&&Bn(r.span,e.text.encoding)===s.text.slice(s.start,s.end)}if(e.attribute){let s=e.attribute,a=r.subject[0].node;return(s.namespaceURI?a.getAttributeNS(s.namespaceURI,s.localName):a.getAttribute(s.qualifiedName))===t.local}let c=e.structure;if(c.localOrder){let s=-1,a=null;for(let m of c.localOrder){let h=n.localState.refs.get(m)?.[0]?.node;if(!h||!o(h)||a&&h.parentNode!==a)return!1;let d=Array.prototype.indexOf.call(h.parentNode.childNodes,h);if(d<=s)return!1;a=h.parentNode,s=d}return!0}return c.localAction==="moved"||r.subject.every(s=>Vs(s.node)===s.fragment)}var Uc=1,Jt=e=>!!e&&e.nodeType===1,Qo=e=>Jt(e)&&e.tagName==="TEMPLATE"&&!!e.content;function zn(e,t=null,n=null){let o=new Map,r=new Map,i=h=>{if(!t){t=new WeakMap;let d=[e];for(;d.length;){let b=d.pop();Qo(b)&&(t.set(b.content,b),d.push(b.content));for(let A=b.firstChild;A;A=A.nextSibling)A.nodeType===1&&d.push(A)}}return t.get(h)||null},c=(h,d)=>{let b=r.get(h);if(!b){b=new Map;let A=0;for(let S=h.firstChild;S;S=S.nextSibling)b.set(S,A++);r.set(h,b)}return b.get(d)},s=h=>{if(!h)return null;if(n&&n.has(h))return s(n.get(h));if(h===e)return[];let d=o.get(h);if(d!==void 0)return d;let b=h.parentNode,A=null;if(b&&b.nodeType===11){let S=i(b),L=S?s(S):null;L&&(A=L.concat(["content",c(b,h)]))}else if(b){let S=s(b);S&&(A=S.concat([c(b,h)]))}return o.set(h,A),A};return{root:e,pathOf:s,logicalParent:h=>{let d=h.parentNode;return d&&d.nodeType===11?i(d):d},indexIn:c,containerPath:h=>{if(h.nodeType===11){let b=i(h),A=s(b);return A?A.concat(["content"]):null}let d=s(h);return d&&Qo(h)?d.concat(["content"]):d},ownerOf:i}}var wn=e=>Qo(e)?e.content:e;function qs(e){let{L:t,R:n,unitsOf:o,provenance:r,policy:i}=e,c=[];return{note:(h,d)=>{c.push([h,d])},finish:h=>c.length?m(h):null};function m(h){let d={base:zn(e.roots.base),local:zn(e.roots.local),remote:zn(e.roots.remote)},b=y=>y==="local"?t:n,A=(y,T)=>{if(!T)return null;if(y.map.has(T))return y.map.get(T);let P=[],p=Jt(T)?d.base.logicalParent(T):T.parent;for(;p&&!y.map.has(p);p=d.base.logicalParent(p))P.push(p);if(!p||!y.identical.has(p))return null;let k=y.map.get(p);for(let R=P.length-1;R>=0&&k;R--)k=wn(k).childNodes[d.base.indexIn(P[R].parentNode,P[R])];return k?Jt(T)?wn(k).childNodes[d.base.indexIn(T.parentNode,T)]||null:o(k)[o(T.parent).indexOf(T)]||null:null},S=new Map,L=new Map,f=new WeakMap,g=0,x=(y,T)=>{let P=S.get(y);P||S.set(y,P=[]),P.push(T)};(function y(T){L.set(T,g++);let P=r.get(T);if(P&&!P.pinned){for(let p of[P.base,P.local,P.remote])if(p)if(Array.isArray(p))for(let k of p)x(k,T);else x(p,T)}if(Qo(T)){f.set(T.content,T);for(let p=T.content.firstChild;p;p=p.nextSibling)y(p)}for(let p=T.firstChild;p;p=p.nextSibling)y(p)})(h);let Q=new Map;d.out=zn(h,f,Q);let se={refs:new Map,spans:new Map,anchors:new Map,via:Q,outOwners:f,outRoot:h,localRoot:e.roots.local},le=y=>Jt(y)?[y]:y.nodes,q=(y,T)=>{let P=d[T].logicalParent(y);if(!P)return null;for(let p of o(P))if(!Jt(p)&&p.nodes.includes(y))return p;return null},z=(y,T)=>y==null?null:Array.isArray(y)?y.length?q(y[0],T):null:y,ce=y=>{let T=new Set,P=[];for(let p of y)for(let k of S.get(p)||[])T.has(k)||(T.add(k),P.push(k));return P.sort((p,k)=>L.get(p)-L.get(k))},xe=new Map,te=y=>{let T=y.b||y.l||y.r,P=xe.get(T);if(P)return P;let p=[];for(let k of[y.b,y.l,y.r])k&&p.push(...le(k));return P=ce(p),xe.set(T,P),P},J=y=>({b:y,l:A(t,y),r:A(n,y)}),Ce=(y,T)=>{let P=b(T).reverse.get(y);if(P)return J(P);for(let p of ce(le(y))){let k=r.get(p);if(k&&!k.base&&k.local&&k.remote)return{b:null,l:z(k.local,"local"),r:z(k.remote,"remote")}}return T==="local"?{b:null,l:y,r:null}:{b:null,l:null,r:y}},we=new Map,ne=y=>{let T=r.get(y);if(!T||T.pinned)return null;let P=z(T.base,"base");if(P)return J(P);let p=z(T.local,"local"),k=z(T.remote,"remote");if(p){let R=t.reverse.get(p);if(R)return J(R)}if(k){let R=n.reverse.get(k);if(R)return J(R)}return p||k?{b:null,l:p,r:k}:null},_=y=>(we.has(y)||we.set(y,ne(y)),we.get(y)),ye=(y,T)=>Jt(y)?d[T].logicalParent(y):y.parent,ge=new Map,Oe=new Map,Be=(y,T)=>(Jt(y)?[d[T].pathOf(y)]:y.nodes.map(P=>d[T].pathOf(P))).filter(Boolean),We=y=>{let T=y.b||y.l||y.r,P=y.b?"base":y.l?"local":"remote",p=Oe.get(T);if(p)return p;let k=!Jt(T),R=Be(T,P)[0],$=`${P[0]}:${JSON.stringify(R===void 0?null:R)}${k?":run":""}`,H=ge.get($);if(H)return Oe.set(T,H),H;let F=te(y);return H={key:$,nodeType:Jt(T)?1:T.kind==="comment"?8:3,base:y.b?Be(y.b,"base"):[],local:y.l?Be(y.l,"local"):[],remote:y.r?Be(y.r,"remote"):[],merged:F.map(N=>d.out.pathOf(N)).filter(Boolean),live:[]},ge.set($,H),Oe.set(T,H),se.refs.set(H,F),H},rt={base:new Map,local:new Map,remote:new Map},re=new Map,ut=(y,T)=>{let P=ye(y,T);if(!P||P.nodeType!==1)return null;let p=rt[T].get(P);if(!p){let R=o(P),$=H=>We(T==="base"?J(H):Ce(H,T));p={parent:$(P),refs:R.map($),index:new Map(R.map((H,F)=>[H,F]))},rt[T].set(P,p)}let k=p.index.get(y)??-1;return{parent:p.parent,before:p.refs.slice(k+1),after:p.refs.slice(0,Math.max(0,k)).reverse()}},dt=y=>{let T=y.parentNode;if(!T)return null;let P=re.get(T);if(!P){let k=T.nodeType===11?f.get(T):T,R=k&&k.nodeType===1?_(k):null;if(!R)return null;let $=[],H=[],F=new Map;for(let E of T.childNodes){let G=_(E),he=G&&We(G),ve=$.length,u=$.length-1;he&&he!==$[u]&&($.push(he),u++);let v={ref:he,group:u,after:ve};H.push(v),F.set(E,v)}let N=$.length;for(let E=H.length-1;E>=0;E--){let G=H[E];G.before=N,G.ref&&(N=G.group)}P={parent:We(R),refs:$,index:F},re.set(T,P)}let p=P.index.get(y);return{parent:P.parent,before:P.refs.slice(p.before),after:P.refs.slice(0,p.after).reverse()}},Se=y=>Jt(y)?y.outerHTML:y.value,O=y=>Jt(y)?"element":y.kind==="comment"?"comment":"text",B=(y,T)=>({path:y,offset:T}),ae=(y,T,P)=>{if(!y)return null;let p=d[P],k=0;if(T){let R=Jt(T)?T:T.nodes[T.nodes.length-1];R.parentNode&&(k=p.indexIn(R.parentNode,R)+1)}return B(p.containerPath(y),k)},be=(y,T)=>{let P=ye(y,"base"),p=P?A(b(T),P):null;if(!Jt(p))return null;let k=o(P),R=null;for(let $=k.indexOf(y)-1;$>=0&&!R;$--){let H=A(b(T),k[$]);H&&ye(H,T)===p&&(R=H)}return ae(p,R,T)},de=(y,T,P,p)=>{let k=d[p],R=0;for(let $=0;$<y.nodes.length;$++){let H=y.nodes[$],F=H.nodeValue.length,N=$===y.nodes.length-1;if((P==="start"?T<R+F:T<=R+F)||N)return B(k.pathOf(H),Math.max(0,Math.min(T-R,F)));R+=F}return null},ze=(y,T)=>{let P=d[T],p=y.firstChild,k=y.lastChild;return p&&p.nodeType===3&&k.nodeType===3?{start:B(P.pathOf(p),0),end:B(P.pathOf(k),k.nodeValue.length)}:{start:B(P.pathOf(y),0),end:B(P.pathOf(y),y.childNodes.length)}},De=(y,T,P)=>{for(let $ of y.nodes)if(P==="start"?$.s<=T&&T<$.e:$.s<T&&T<=$.e)return{kind:"text",node:$.node,offset:T-$.s};let p=P==="start"?T:T-1,k=()=>{for(let $ of y.nodes)if($.s===T||$.e===T)return{kind:"text",node:$.node,offset:T-$.s};return null},R=y.atomAt.get(p);if(R)return{kind:P==="start"?"before":"after",node:R.el};if(y.text[p]===gt){let $=y.marks.find(F=>F.block&&F.to===p+1);if($)return P==="start"?{kind:"end",node:$.el}:{kind:"after",node:$.el};let H=y.marks.find(F=>F.block&&F.from===p+1);if(H)return P==="start"?{kind:"before",node:H.el}:{kind:"startOf",node:H.el}}return k()},Qe=(y,T)=>De(y,T,"end")||De(y,T,"start"),st=(y,T)=>{switch(T.kind){case"text":return B(y.pathOf(T.node),T.offset);case"end":return B(y.containerPath(T.node),wn(T.node).childNodes.length);case"startOf":return B(y.containerPath(T.node),0);default:{let P=T.node.parentNode;return B(y.containerPath(P),y.indexIn(P,T.node)+(T.kind==="after"?1:0))}}},wt=(y,T,P,p,k)=>{let R=De(y,T,P);return R?st(d[p],R):k()},bt=(y,T,P,p)=>{let k=y.textNodes.map(N=>({s:N.ms,e:N.me,start:{kind:"text",node:N.node,offset:0},end:{kind:"text",node:N.node,offset:N.me-N.ms}}));for(let[N,E]of y.atomOut)k.push({s:N,e:N+1,start:{kind:"before",node:E},end:{kind:"after",node:E}});for(let[N,E]of y.breakOut)k.push({s:N,e:N+1,start:{kind:"end",node:E},end:{kind:"after",node:E}});for(let N of k)if(N.start.kind==="text"&&N.s<T&&T<N.e)return{kind:"text",node:N.start.node,offset:T-N.s};if(P!=="empty"){let N=k.find(E=>P==="start"?E.s===T:E.e===T);if(N)return P==="start"?N.start:N.end}let R=k.find(N=>N.e===T);if(R)return R.end;let $=k.find(N=>N.s===T);if($)return $.start;let H=null,F=null;for(let N of k)N.e<=T&&(!H||N.e>H.e)&&(H=N),N.s>=T&&(!F||N.s<F.s)&&(F=N);return H?H.end:F?F.start:p()},Tt=(y,T)=>{if(!T)return null;if(T.kind==="text"){let k=y.nodes.find(R=>R.node===T.node);return k?k.s+Math.min(T.offset,k.e-k.s):null}let P=y.atoms.find(k=>k.el===T.node);if(P)return T.kind==="after"?P.i+1:P.i;let p=y.marks.find(k=>k.el===T.node);return p?T.kind==="before"&&p.block&&y.text[p.from-1]===gt&&!y.marks.some(k=>k.block&&k.to===p.from)?p.from-1:T.kind==="startOf"||T.kind==="before"?p.from:T.kind==="end"&&p.block?p.to-1:p.to:null},nn=(y,T,P,p)=>{for(let H of y.nodes)if(P==="start"?H.s<=T&&T<H.e:H.s<T&&T<=H.e)return{kind:"text",node:H.node,offset:T-H.s};let k=P==="start"?T:T-1;if(!y.atomAt.has(k)&&y.text[k]!==gt){for(let H of y.nodes)if(H.s===T||H.e===T)return{kind:"text",node:H.node,offset:T-H.s}}let R=y.atomAt.get(k);if(R)return{kind:P==="start"?"before":"after",node:R.el};if(y.text[k]===gt){let H=y.marks.find(N=>N.block&&N.to===k+1);if(H)return P==="start"?{kind:"end",node:H.el}:{kind:"after",node:H.el};let F=y.marks.find(N=>N.block&&N.from===k+1);if(F)return P==="start"?{kind:"before",node:F.el}:{kind:"startOf",node:F.el}}let $=y.marks.find(H=>H.block&&H.from===T);return $?{kind:"startOf",node:$.el}:p?{kind:P==="start"?"startOf":"end",node:p}:null},Fe=y=>{if(!y)return null;if(y.kind==="wholeStart"||y.kind==="wholeEnd"){let T=Qt(y.node);return y.kind==="wholeStart"?T.start:T.end}return st(d.out,y)},Qt=y=>{let T=y.firstChild,P=y.lastChild;return T&&T.nodeType===3&&P.nodeType===3?{start:B(d.out.pathOf(T),0),end:B(d.out.pathOf(P),P.nodeValue.length)}:{start:B(d.out.pathOf(y),0),end:B(d.out.pathOf(y),y.childNodes.length)}},Xt=y=>{let T=ye(y,"base"),P=T?te(J(T))[0]:null;if(!P)return null;let p=wn(P),k=o(T);for(let R=k.indexOf(y)-1;R>=0;R--){let $=te(J(k[R])).filter(H=>H.parentNode===p);if($.length)return{kind:"after",node:$[$.length-1]}}return{kind:"startOf",node:P}},Bt=(y,T,P,p,k,R)=>({text:y,start:T,end:P,fragment:p,span:k,scope:R}),Et=(y,T,P,p,k)=>Bt(y,T,P,y.slice(T,P),p,k),Lt=(y,T,P,p,k)=>(se.spans.set(y,{start:T,end:P,scopeStart:p,scopeEnd:k}),y),sn=new Map,M=new Map,Z=(y,T,P)=>{let p=`text:${y.key}:${T}:${P}`,k=M.get(p)||0;return M.set(p,k+1),`${p}:${k}`},ee=(y,T)=>{let P,p,k,R="plain",$,H,F,N,E,G=(u,v,j,U,V)=>{if(!u){let W=be(V,U);return Et("",0,0,{start:W,end:W},{start:W,end:W})}return Et(u.value,v,j,{start:de(u,v,v===j?"end":"start",U),end:de(u,j,"end",U)},{start:de(u,0,"start",U),end:de(u,u.value.length,"end",U)})};if(T.site==="run"){let{bRun:u,lRun:v,rRun:j,node:U,c:V}=T;P=J(u),p=V.bs,k=V.be,$=G(u,V.bs,V.be,"base",u),H=G(v,V.ls,V.le,"local",u),F=G(j,V.rs,V.re,"remote",u);let W=U?U.nodeValue:"",Y=ie=>U?{kind:"text",node:U,offset:ie}:Xt(u);N=Lt(Et(W,V.ms,V.me,{start:Fe(Y(V.ms)),end:Fe(Y(V.me))},{start:Fe(Y(0)),end:Fe(Y(W.length))}),Y(V.ms),Y(V.me),Y(0),Y(W.length)),E=U||(Xt(u)||{}).node||null}else if(T.site==="whole"){let u=T.el,v=r.get(u);P=J(v.base),p=0,k=y.base.length;let j=(V,W,Y)=>{let ie=ze(W,Y);return Et(V,0,V.length,ie,ie)};$=j(y.base,v.base,"base"),H=j(y.local,v.local,"local"),F=j(y.remote,v.remote,"remote");let U=Qt(u);N=Lt(Et(y.resolved,0,y.resolved.length,U,U),{kind:"wholeStart",node:u},{kind:"wholeEnd",node:u},{kind:"wholeStart",node:u},{kind:"wholeEnd",node:u}),E=u}else if(T.site==="comment"){let{bRun:u,lRun:v,rRun:j,node:U}=T;P=J(u),p=0,k=y.base.length;let V=(Ne,Le)=>{if(!Ne){let je=be(u,Le);return Et("",0,0,{start:je,end:je},{start:je,end:je})}let Me=Ne.nodes[0],Ze={start:B(d[Le].pathOf(Me),0),end:B(d[Le].pathOf(Me),Ne.value.length)};return Et(Ne.value,0,Ne.value.length,Ze,Ze)};$=V(u,"base"),H=V(v,"local"),F=V(j,"remote");let W=y.resolved,Y=Ne=>U?{kind:"text",node:U,offset:Ne}:Xt(u),ie={start:Fe(Y(0)),end:Fe(Y(W.length))};N=Lt(Et(W,0,W.length,ie,ie),Y(0),Y(W.length),Y(0),Y(W.length)),E=U||(Xt(u)||{}).node||null}else{let{fb:u,fl:v,fr:j,scope:U}=T,V=T.merged;R="html",P=U.base?J(U.base):Ce(U.local,"local"),p=y.bs,k=y.be;let W=at=>{let St=U[at];for(let At=U.at-1;At>=0;At--){let Ht=U.units[At],Zt=at==="base"?Ht:A(b(at),Ht);if(Zt&&ye(Zt,at)===St)return Zt}return null},Y=at=>()=>ae(U[at],W(at),at),ie=(at,St,At,Ht,Zt)=>{let un=He=>He?st(d[Zt],He):Y(Zt)(),In=St===At?Qe(at,St):De(at,St,"start"),Cn=St===At?Qe(at,St):De(at,At,"end"),xn=un(In),cn={start:xn,end:St===At?xn:un(Cn)},zt=T.full?T.full(Zt):null;if(!zt)return Bt(at.text,St,At,Ht,cn,{start:un(De(at,0,"start")),end:un(De(at,at.text.length,"end"))});let X=In?Tt(zt,In):null,Re=Cn?Tt(zt,Cn):null,Ae=X===null?0:X,Ge=Math.max(Ae,Re===null?zt.text.length:Re),ct=un(De(zt,0,"start"));return Bt(zt.text,Ae,Ge,io(zt,Ae,Ge),cn,{start:ct,end:zt.text.length?un(De(zt,zt.text.length,"end")):ct})};$=T.synthetic?null:ie(u,y.bs,y.be,y.base,"base"),H=ie(v,y.lss,y.lse,y.local,"local"),F=ie(j,y.rss,y.rse,y.remote,"remote");let[Ne,Le]=y.range||[0,0],Me=V.out,Ze=()=>{let at=wn(V.node);for(let St=U.at-1;St>=0;St--){let At=te(J(U.units[St])).filter(Ht=>Ht.parentNode===at);if(At.length)return{kind:"after",node:At[At.length-1]}}for(let St=U.at;St<U.units.length;St++){let At=te(J(U.units[St])).filter(Ht=>Ht.parentNode===at);if(At.length)return{kind:"before",node:At[0]}}return{kind:"startOf",node:V.node}};if(Me.via)for(let[at,St]of Me.via)Q.set(at,St);let je=bt(V,Ne,Ne===Le?"empty":"start",Ze),Ot=Ne===Le?je:bt(V,Le,"end",Ze),Ue=Me.text.length?nn(Me,0,"start",V.node):Ze(),ht=Me.text.length?nn(Me,Me.text.length,"end",V.node):Ue,it=Tt(Me,je),Kt=Tt(Me,Ot),Rt=it===null?0:it,qt=Math.max(Rt,Kt===null?Me.text.length:Kt);N=Lt(Bt(Me.text,Rt,qt,io(Me,Rt,qt),{start:Fe(je),end:Fe(Ot)},{start:Fe(Ue),end:Fe(ht)}),je,Ot,Ue,ht);let It=se.spans.get(N);if(It.flat=Me,!Me.text.length){let at=Fe(Ue),St=Fn(h,at),At=St[0],Ht=St[1];It.empty={parent:At.nodeType===11?f.get(At):At,previous:At.childNodes[Ht-1]||null,next:At.childNodes[Ht]||null}}E=je?je.node:V.node}let he=We(P),ve=(T.site==="whole"||T.site==="comment"||i!=="both")&&y.resolved!==y.local;return{key:T.site==="comment"&&sn.get(P.b||P.l||P.r)||Z(he,p,k),subject:he,localLost:ve,anchor:E,text:{encoding:R,base:$,local:H,remote:F,merged:N,liveSpan:null,liveScope:null}}},ue=(y,T)=>{let P=_(T.el),p=We(P),k=T.sample;return{key:`attr:${p.key}:${k.namespaceURI||""}:${k.localName}`,subject:p,localLost:y.resolved!==y.local,anchor:T.el,attribute:{namespaceURI:k.namespaceURI||null,localName:k.localName,qualifiedName:k.name}}},oe=(y,T)=>{let P=y.detail,p=T.unit||J(T.subject),k=We(p),R=se.refs.get(k),$=p.l?ut(p.l,"local"):null,H=p.r?ut(p.r,"remote"):null,F=R.length?dt(R[0]):null,N,E,G,he=null,ve=null,u=T.deleted;switch(P){case"both-reordered":{N=E="reordered";let v=new Set(T.rKept),j=T.lKept.filter(ie=>v.has(ie)&&te(J(ie)).length),U=ie=>L.get(te(J(ie))[0]);he=j.map(ie=>We(J(ie))),ve=j.slice().sort((ie,Ne)=>U(ie)-U(Ne)).map(ie=>We(J(ie)));let V=ie=>!Jt(ie)&&ie.kind!=="comment"&&ie.nodes.every(Ne=>!/[^\t\n\f\r ]/.test(Ne.data)),W=j.filter(ie=>!V(ie)),Y=W.slice().sort((ie,Ne)=>U(ie)-U(Ne));G=W.some((ie,Ne)=>ie!==Y[Ne]);break}case"both-moved":N=E="moved",G=!$||!R.some(v=>{let j=v===R[0]?F:dt(v);return j&&j.parent===$.parent});break;case"edit-beats-delete":N=u==="local"?"deleted":"edited",E=u==="remote"?"deleted":"edited",G=u==="local";break;case"move-beats-delete":N=u==="local"?"deleted":"moved",E=u==="remote"?"deleted":"moved",G=u==="local";break;default:N=E="inserted",G=T.localLost}return{key:`structure:${k.key}:${P}`,subject:k,localLost:G,anchor:R[0]||null,structure:{localAction:N,remoteAction:E,localPlacement:$,remotePlacement:H,mergedPlacement:F,localOrder:he,mergedOrder:ve,localFragment:P==="both-reordered"||!p.l?null:Se(p.l),fragmentKind:O(p.b||p.l||p.r)}}};for(let[y,T]of c){if(y.kind!=="structure")continue;let P=T.unit||J(T.subject),p=P.b||P.l||P.r;!Jt(p)&&p.kind==="comment"&&sn.set(p,`structure:${We(P).key}:${y.detail}`)}let fe=new Map;for(let[y,T]of c){if(y.kind==="structure"){let R=We(T.unit||J(T.subject)),$=`structure:${R.key}:${y.detail}`,H=fe.get($);if(H&&H.structure){y.recovery=H;let F=se.refs.get(R);y.el==null&&F.length&&(y.el=Jt(F[0])?F[0]:d.out.logicalParent(F[0]));continue}}let P=y.kind==="text"?ee(y,T):y.kind==="attr"?ue(y,T):oe(y,T),p=fe.get(P.key);p||(p={version:Uc,key:P.key,localLost:P.localLost,subject:P.subject,applied:!1,unavailable:null},fe.set(P.key,p),se.anchors.set(p,P.anchor)),P.text&&(p.text=P.text),P.attribute&&(p.attribute=P.attribute),P.structure&&(p.structure=P.structure),P.text&&(p.localLost=P.localLost),y.recovery=p;let k=se.refs.get(P.subject);y.kind==="structure"&&y.el==null&&k.length&&(y.el=Jt(k[0])?k[0]:d.out.logicalParent(k[0])),y.kind==="text"&&y.node==null&&k.length&&P.subject.nodeType===8&&(y.node=k[0])}return se}}function Fs(e,t,n){if(!t)return;let{lookup:o,vetoed:r,vetoedAttrs:i,liveAttr:c}=n,s=n.ignored||(()=>!1),a=zn(n.liveRoot),m=ne=>!!ne&&a.containerPath(ne)!==null,h=ne=>{let _=ne.parentNode;return _&&_.nodeType===11?t.outOwners.get(_)||null:_},d=ne=>{for(let _=ne;_;_=h(_))if(t.via.has(_)&&(_=t.via.get(_)),r.has(_)||n.vetoedLive?.has(g(_)))return!0;return!1},b=ne=>Array.from(wn(ne).children).filter(_=>!s(_)),A=(ne,_)=>b(ne)[b(_.parentNode).indexOf(_)],S=(ne,_)=>{let ye=null,ge=null,Oe=0;for(let re=_.previousSibling;re;re=re.previousSibling){if(re.nodeType===1&&!s(re)){ye=re;break}re.nodeType===3&&(Oe+=re.nodeValue.length)}for(let re=_.nextSibling;re&&!ge;re=re.nextSibling)re.nodeType===1&&!s(re)&&(ge=re);let Be=ye?A(ne,ye):null,We=ge?A(ne,ge):null;if(ye&&!Be||ge&&!We)return null;let rt=[];for(let re=Be?Be.nextSibling:wn(ne).firstChild;re&&re!==We;re=re.nextSibling)re.nodeType===3&&rt.push(re);return rt.length?{nodes:rt,lead:Oe}:null},L=ne=>{let _=[],ye=ne;for(;ye&&!t.via.has(ye);ye=ye.parentNode)_.push(ye);if(!ye||!_.length)return null;let ge=g(t.via.get(ye));for(let We=_.length-1;We>0&≥We--)ge=A(ge,_[We]);if(!ge)return null;let Oe=_[0];if(Oe.nodeType===3)return S(ge,Oe);let Be=Oe.nodeType===1?A(ge,Oe):null;return Be?{nodes:[Be],lead:0}:null},f=ne=>{let _=o(ne),ye=_?{nodes:Array.isArray(_)?_:[_],lead:0}:t.via.size?L(ne):null;if(!ye)return null;let ge=ye.nodes.filter(m);return ge.length?{nodes:ge,lead:ye.lead}:null},g=ne=>{let _=f(ne);return _?_.nodes[0]:null},x=ne=>{if(!ne)return null;if(ne.kind==="text"){let Oe=f(ne.node);if(!Oe)return null;let Be=Oe.nodes,We=ne.offset+Oe.lead,rt=0;for(let re=0;re<Be.length;re++){let ut=Be[re].nodeValue.length;if(We<=rt+ut||re===Be.length-1)return We>=rt&&We<=rt+ut?[Be[re],We-rt]:null;rt+=ut}return null}let _=g(ne.node);if(!_)return null;if(ne.kind==="end")return[wn(_),wn(_).childNodes.length];if(ne.kind==="startOf")return[wn(_),0];if(ne.kind==="wholeStart")return _.firstChild?[_.firstChild,0]:[_,0];if(ne.kind==="wholeEnd")return _.lastChild?[_.lastChild,_.lastChild.nodeValue.length]:[_,_.childNodes.length];let ye=_.parentNode;if(!ye)return null;let ge=Array.prototype.indexOf.call(ye.childNodes,_);return[ye,ne.kind==="after"?ge+1:ge]},Q=ne=>({blocks:new Set((ne.flat?.marks||[]).filter(_=>_.block).map(_=>g(_.el)).filter(Boolean)),atoms:new Set((ne.flat?.atoms||[]).map(_=>g(_.el)).filter(Boolean)),ignored:s}),se=(ne,_,ye,ge)=>{if(!ne||!_||!Kn(ne)||!Kn(_))return!1;for(let We of[ne,_])if(!m(We.startContainer)||!m(We.endContainer))return!1;let Oe=ye.merged;if(Oe.start===Oe.end&&(ne.startContainer!==ne.endContainer||ne.startOffset!==ne.endOffset))return!1;let Be=Q(ge);return Bn(_,ye.encoding,Be)===Oe.text&&Bn(ne,ye.encoding,Be)===Oe.text.slice(Oe.start,Oe.end)},le=new Map,q=ne=>{let _=ne.parentNode;return _?(le.has(_)||le.set(_,new Map(Array.from(_.childNodes,(ye,ge)=>[ye,ge]))),le.get(_).get(ne)):-1},z=(ne,_)=>{if(!_)return!1;let ye=a.logicalParent(ne);if(!_.parent.live.includes(ye))return!1;let ge=q(ne);for(let[Oe,Be]of[["before",1],["after",-1]]){let We=ge;for(let rt of _[Oe]){if(rt.live.includes(ne))continue;let re=rt.live.filter(dt=>dt!==ne&&dt.parentNode===ne.parentNode);if(!re.length)continue;let ut=Be===1?Math.min(...re.map(q)):Math.max(...re.map(q));if(Be*(ut-We)<=0)return!1;We=ut}}return!0},ce=ne=>{let _=ne.structure;if(_.mergedOrder){let ye=new Set(ne.subject.live.map(wn)),ge=null,Oe=-1;for(let Be of _.mergedOrder){let We=Be.live.find(rt=>ye.has(rt.parentNode));if(!We||ge&&We.parentNode!==ge||q(We)<=Oe)return!1;ge=We.parentNode,Oe=q(We)}return ne.subject.live.length>0}return ne.subject.live.some(ye=>z(ye,_.mergedPlacement))},xe=(ne,_)=>{let ye=x(ne),ge=x(_);return ye&&ge?{startContainer:ye[0],startOffset:ye[1],endContainer:ge[0],endOffset:ge[1]}:null},te=new Set,J=ne=>{if(!ne||te.has(ne))return;te.add(ne);let _=[];for(let ye of t.refs.get(ne)||[]){let ge=f(ye);if(ge)for(let Oe of ge.nodes)_.includes(Oe)||_.push(Oe)}ne.live=_},Ce=ne=>{ne&&(J(ne.parent),ne.before.forEach(J),ne.after.forEach(J))},we=new Set;for(let ne of e){let _=ne.recovery;if(!_||we.has(_))continue;we.add(_),J(_.subject),_.structure&&(Ce(_.structure.localPlacement),Ce(_.structure.remotePlacement),Ce(_.structure.mergedPlacement),(_.structure.localOrder||[]).forEach(J),(_.structure.mergedOrder||[]).forEach(J));let ye=t.anchors.get(_),ge=ye?g(ye):null,Oe=!!ge;if(_.text){let O=t.spans.get(_.text.merged),B=O?xe(O.start,O.end):null,ae=O?xe(O.scopeStart,O.scopeEnd):null;if(O?.empty){let be=O.empty,de=be.previous?{kind:"after",node:be.previous}:{kind:"startOf",node:be.parent},ze=be.next?{kind:"before",node:be.next}:{kind:"end",node:be.parent},De=xe(de,ze);!De||De.startContainer!==De.endContainer||De.startOffset!==De.endOffset?B=null:B=ae=De}se(B,ae,_.text,O)||(B=ae=null),_.text.liveSpan=B,_.text.liveScope=B?ae:null,B||(Oe=!1)}_.structure&&Oe&&(Oe=ce(_)),_.attribute&&Oe&&(Oe=c(ge,_.attribute,ne.resolved));let Be=(!!_.attribute||!!_.text&&ge?.tagName==="TEXTAREA")&&!!i&&[ye,ge].some(O=>i.get(O)?.has(_.attribute?_.attribute.qualifiedName:"value")),We=t.localState?.states.get(_),rt=!!_.text&&[...n.removedVetoes||[]].some(O=>We?.touched.has(O)),re=_.structure?.localAction==="inserted"&&[...r].some(O=>O===ye||ye?.contains(O)),ut=ye&&d(ye)||Be||rt||re,dt=ut&&$s(_,ne,t,m);dt&&(rt||re&&_.localLost)&&(Oe=!1);let Se=!Oe&&dt&&ut;_.applied=Oe,_.unavailable=Oe?null:Se?"hook-veto":"missing-output",Se&&(_.localLost=!1),!Oe&&_.text&&(_.text.liveSpan=_.text.liveScope=null)}}function Zo(e,t,n){let o=zn(t),r=zn(n),i=d=>!!d&&r.containerPath(d)!==null,c=d=>{if(d===t)return n;let b=o.pathOf(d);if(b&&t!==n){let A=Fn(n,{path:b,offset:0});if(A&&A[0].nodeType===d.nodeType)return A[0]}return d},s=new Set,a=d=>{!d||s.has(d)||(s.add(d),d.live=d.live.map(c).filter(i))},m=d=>{d&&(d.startContainer=c(d.startContainer),d.endContainer=c(d.endContainer))},h=new Set;for(let d of e){d.node===t&&n.tagName==="SCRIPT"&&(d.node=n),d.el===t&&d.kind==="structure"&&(d.el=n);let b=d.recovery;if(!b||h.has(b))continue;if(h.add(b),a(b.subject),b.text){m(b.text.liveSpan),m(b.text.liveScope);let S=b.text.liveSpan,L=b.text.liveScope,f=b.text.merged,g=x=>!!x&&Kn(x)&&i(x.startContainer)&&i(x.endContainer);(!g(S)||!g(L)||Bn(L,b.text.encoding)!==f.text||Bn(S,b.text.encoding)!==f.text.slice(f.start,f.end))&&(b.text.liveSpan=null,b.text.liveScope=null,b.applied=!1,b.unavailable="missing-output")}let A=b.structure;if(A){for(let S of[A.localPlacement,A.remotePlacement,A.mergedPlacement])S&&(a(S.parent),S.before.forEach(a),S.after.forEach(a));(A.localOrder||[]).forEach(a),(A.mergedOrder||[]).forEach(a),b.subject.live.length||(b.applied=!1,b.unavailable="missing-output")}}}var Xe=e=>!!e&&e.nodeType===1,_c=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),Ks=5e4,So="[id],[data-id],script,head>*";function Pr(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let o=lo(n,e);if(o)return"merge:"+o.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?Ps(n,t):null}}function er(e,t,n,o){let r=o.ignored,i=o.stats||jn(),c=xs({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:i}),{unitsOf:s,meta:a}=c,m=o.baseURI,h=o.mergeTags!==null,d=Pr(o.mergeTags,m),b=u=>v=>{let j=d(v);return j!==null?j:u(v)},A=b(o.identity.base),S=b(o.identity.local),L=b(o.identity.remote),f=o.authored||o.identity,g=u=>u&&u.nodeType===9?u.documentElement:u,x=g(e),Q=g(t),se=g(n),le=globalThis.__hyperMorphProfile,q=le?performance.now():0,z=u=>u===fn?So:null,ce=o.scope||null,xe=ce?ce.baseIndex:zo(x,A,r,z(o.identity.base)),te=o.localIsBase||x===Q?Gs():yr(x,Q,{analyzer:c,baseIndex:xe,sideIndex:zo(Q,S,r,z(o.identity.local)),baseId:f.base,sideId:f.local,stats:i}),J=yr(x,se,{analyzer:c,baseIndex:xe,sideIndex:ce?ce.remoteIndex:zo(se,L,r,z(o.identity.remote)),baseId:f.base,sideId:f.remote,stats:i,scope:ce,comparisons:o.comparisons});if(ce){if(!ce.held(J))return null;for(let u of ce.dropped)gr(u)}let Ce=null;function we(u){if(!Ce){Ce=new WeakMap;let v=[x];for(;v.length;){let j=v.pop();j.tagName==="TEMPLATE"&&j.content&&Ce.set(j.content,j);for(let U of c.childrenOf(j))U.nodeType===1&&v.push(U)}}return Ce.get(u)||null}let ne=u=>{let v=Xe(u)||u.nodeType?u.parentNode:u.parent;return v&&v.nodeType===11?we(v):v};Tt(),nn(te,J),nn(J,te);for(let u of[te,J])if(u.refused)for(let v of u.refused)u.moved.has(v)||i.ambiguousMoves++;le&&(le.alignTotal=(le.alignTotal||0)+(performance.now()-q),q=performance.now());let _=x.ownerDocument.implementation.createHTMLDocument(""),ye=new WeakMap,ge=new WeakMap,Oe=[],Be=[],We=new Set,rt=[],re=new Set,ut=new Set,dt=new Set,Se=new WeakMap,O=o.conflicts||"remote",B=u=>Oe.push(u),ae=u=>Oe.push(u),be=qs({roots:{base:x,local:Q,remote:se},L:te,R:J,unitsOf:s,provenance:ye,policy:O}),de=(u,v)=>{Be.push(u),v&&be.note(u,v)},ze=wt(),De=Et(x,te.map.get(x),J.map.get(x),!!o.localIsBase,!!o.childrenOnly);De.tagName==="HTML"?_.replaceChild(De,_.documentElement):_.body.appendChild(De),le&&(le.build=(le.build||0)+(performance.now()-q));let Qe=o.childrenOnly?!H(R(De),R(se)):!P(De,se),st=be.finish(De);return{doc:_,root:De,provenance:ye,textMappers:ge,decisions:Oe,conflicts:Be,recoveryLinks:st,localDiverged:Qe,mergedScripts:We,segments:rt,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==fn,L:te,R:J,stats:i};function wt(){let u=new Map,v=new Set;if(o.localIsBase||!te.insertedByHash)return{partner:u,drop:v};let j=te.insertedByHash(),U=J.insertedByHash();if(!j.size||!U.size)return{partner:u,drop:v};let V={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},W=Ue=>{let ht=0;for(let it=Ue.parentNode;it;it=it.parentNode)ht++;return ht},Y=[],ie=Ue=>{let ht=Ue.textContent.trim();return ht.split(/\s+/).length>=3||ht.replace(/\s/g,"").length>=12},Ne=Ue=>{let ht=Fe(te,Ue),it=Fe(J,Ue);return ht&&te.reverse.get(ht.parentNode)!==Ue.parentNode||it&&J.reverse.get(it.parentNode)!==Ue.parentNode},Le=(Ue,ht,it)=>{for(let Rt of it.parentNode.children){let qt=Rt!==it&&Ue.reverse.get(Rt);if(qt&&Ne(qt))return!0}let Kt=Ue.reverse.get(it.parentNode);if(Kt){for(let Rt of Kt.children)if(!Fe(ht,Rt)&&!r(Rt))return!0}return!1};for(let[Ue,ht]of j){let it=U.get(Ue);if(!it)continue;let Kt=ht.length===1&&it.length===1;for(let Rt of ht)qn(Rt,V)||Y.push([Rt,it,W(Rt),Kt&&(ie(Rt)||Le(te,J,Rt)||Le(J,te,it[0]))])}if(!Y.length)return{partner:u,drop:v};Y.sort((Ue,ht)=>Ue[2]-ht[2]);let Me=new Set,Ze=new Set,je=Ue=>{for(let ht of Ue.querySelectorAll("*"))Me.add(ht)},Ot=(Ue,ht)=>Ue.reverse.get(ht.parentNode)||null;for(let[Ue,ht,,it]of Y){if(Me.has(Ue))continue;let Kt=Ot(te,Ue),Rt=It=>!Ze.has(It)&&!Me.has(It)&&It.tagName===Ue.tagName&&c.equalUnits(Ue,It),qt=ht.find(It=>Kt&&Ot(J,It)===Kt&&Rt(It))||(it?ht.find(Rt):null);qt&&(Ze.add(qt),je(Ue),je(qt),!(Kt&&Ot(J,qt)===Kt)&&(u.set(Ue,qt),u.set(qt,Ue),v.add(O==="local"?qt:Ue)))}return{partner:u,drop:v}}function bt(u,v,j){if(re.add(u),ze.drop.has(u))return null;re.add(j);let U=v==="local"?u:j,V=v==="local"?j:u,W;return c.equalUnits(U,V)?(W=y(U,"local",!0),ye.get(W).remote=V):W=fe(U,V),de({kind:"structure",el:W,detail:"both-moved",base:null,local:U,remote:V},{unit:{b:null,l:U,r:V}}),B({kind:"insert",el:W,source:"both"}),W}function Tt(){if(!te.weak||!J.weak||!te.weak.size||!J.weak.size||!te.unpair)return;let u=new Map;for(let j of te.weak){let U=Fe(te,j);Xe(j)&&Xe(U)&&u.set(c.unitHash(U),j)}let v=!1;for(let j of Array.from(J.weak)){let U=Fe(J,j);if(!Xe(j)||!Xe(U))continue;let V=u.get(c.unitHash(U));if(!V||V===j||!te.weak.has(V)||Fe(te,j)&&Fe(J,V))continue;let W=Fe(te,V);W.tagName===U.tagName&&c.equalUnits(W,U)&&(te.unpair(V),J.unpair(j),v=!0)}v&&(te.rematch(),J.rematch())}function nn(u,v){if(!u.weak||!u.weak.size||!v.insertedByHash)return;let j=v.insertedByHash();if(!j.size)return;let U=!1;for(let V of Array.from(u.weak)){let W=Fe(u,V);if(!W)continue;let Y=j.get(c.unitHash(W));Y&&Y.some(ie=>ie.tagName===W.tagName&&c.equalUnits(ie,W))&&(u.unpair(V),U=!0)}U&&u.rematch()}function Fe(u,v){if(!v)return null;if(u.map.has(v))return u.map.get(v);let j=[],U=ne(v);for(;U&&!u.map.has(U);U=ne(U))j.push(U);let V=U;if(!V||!u.identical.has(V))return null;u.pairIdenticalChildren(V);for(let Y=j.length-1;Y>=0;Y--)u.pairIdenticalChildren(j[Y]);let W=u.map.get(v)||null;return W&&i.lazyTwins++,W}function Qt(u,v,j){if(ut.has(u)||dt.has(u))return de({kind:"structure",el:null,detail:"both-moved",base:u},{subject:u}),ut.has(u)?null:y(j,v);let U=Fe(te,u),V=Fe(J,u);(!U||!V)&&de({kind:"structure",el:null,detail:"move-beats-delete",base:u},{subject:u,deleted:U?"remote":"local"});let W=Et(u,U,V,!1);return(v==="local"?B:ae)({kind:"move",el:W,source:v}),W}function Xt(u,v,j,U){return U||!v||v===j?{el:j,asBase:!0,twin:V=>V,baseOf:V=>V,units:s(j),here:()=>!0,parentOfTwin:()=>j}:{el:v,asBase:!1,twin:V=>Fe(u,V),baseOf:V=>u.reverse.get(V),units:s(v),here:V=>Xe(V)?V.parentNode===v||v.tagName==="TEMPLATE"&&V.parentNode===v.content:V.parent===v||v.tagName==="TEMPLATE"&&V.parent===v.content}}function Bt(u,v,j){return!v||j&&j.identical.has(u)?!1:Xe(u)?!c.equalUnits(u,v):u.value!==v.value}function Et(u,v,j,U,V=!1){let W=U||o.remoteWins(u),Y=u.namespaceURI&&u.namespaceURI!=="http://www.w3.org/1999/xhtml"?_.createElementNS(u.namespaceURI,u.tagName):_.createElement(u.tagName),ie={base:u,local:v||null,remote:j||null};if(ye.set(Y,ie),re.add(u),ut.add(u),v&&re.add(v),j&&re.add(j),o.skipUnchanged&&!V&&(o.localIsBase||te.identical.has(u))&&j&&J.identical.has(u)&&!o.remoteWins(u)){ie.unchanged=!0;for(let Le of u.attributes)Le.namespaceURI?Y.setAttributeNS(Le.namespaceURI,Le.name,Le.value):Y.setAttribute(Le.name,Le.value);return Y}dt.add(u),V||M(u,W?u:v,j,Y);let Ne=u.tagName;if(tn(u))sn(u,W?u:v,j,Y);else if(Ne==="TEXTAREA")Y.textContent=Lt(u.textContent,(W?u:v)?(W?u:v).textContent:u.textContent,j?j.textContent:u.textContent,Y,"text");else{let Le=T(u,v,j,W,Y),Me=Ne==="TEMPLATE"&&Y.content?Y.content:Y;for(let Ze of Le)Me.appendChild(Ze)}return dt.delete(u),Y}function Lt(u,v,j,U,V){if(v===j)return v;if(v===u)return j!==u&&ae({kind:V,node:U,source:"remote"}),j;if(j===u)return B({kind:V,node:U,source:"local"}),v;let W=O==="local"?v:j;return de({kind:V,node:U,base:u,local:v,remote:j,resolved:W},{site:"whole",el:U}),Oe.push({kind:V,node:U,source:"both"}),W}function sn(u,v,j,U){let V=u.textContent,W=v?v.textContent:V,Y=j?j.textContent:V,ie=h?lo(u,o.mergeTags,!0):null;if(ie&&W!==Y){let Ne=j&&j.getAttribute("merge-key")||u.getAttribute("merge-key"),{text:Le,warnings:Me}=Rr(o.localIsBase?void 0:V,W,Y,{parse:ie.recognizer.parse,keyCandidates:Ne?Ne.split(/[\s,]+/).filter(Boolean):void 0});for(let Ze of Me)console.warn(`[hyper-morph] merge "${ie.raw}": ${Ze}`);U.textContent=Le,We.add(U),Le!==Y?B({kind:"text",node:U,source:Le===W?"local":"both"}):Le!==V&&ae({kind:"text",node:U,source:"remote"});return}U.textContent=Lt(V,W,Y,U,"text")}function M(u,v,j,U){let V=new Map;for(let W of[u,v,j])if(W)for(let Y of W.attributes)o.ignoreAttribute(W,Y.name)||V.set(Y.name,Y);for(let[W,Y]of V){let ie=u?u.getAttribute(W):null,Ne=v?v.getAttribute(W):ie,Le=j?j.getAttribute(W):ie,Me;Ne===Le?Me=Ne:Ne===ie?(Me=Le,ae({kind:"attr",el:U,name:W,source:"remote"})):Le===ie?(Me=Ne,B({kind:"attr",el:U,name:W,source:"local"})):(Me=Z(W,ie,Ne,Le),Me===void 0&&(Me=O==="local"?Ne:Le,de({kind:"attr",el:U,name:W,base:ie,local:Ne,remote:Le,resolved:Me},{el:U,sample:Y})),Oe.push({kind:"attr",el:U,name:W,source:"both"})),Me!=null&&(Y.namespaceURI?U.setAttributeNS(Y.namespaceURI,Y.name,Me):U.setAttribute(W,Me))}}function Z(u,v,j,U){if(u==="class"){let V=Le=>new Set((Le||"").split(/\s+/).filter(Boolean)),W=V(v),Y=V(j),ie=V(U),Ne=new Set;for(let Le of new Set([...W,...Y,...ie])){let Me=W.has(Le),Ze=Y.has(Le),je=ie.has(Le);(Ze===je?Ze:Ze===Me?je:Ze)&&Ne.add(Le)}return[...Ne].join(" ")}if(u==="style"){let V=Me=>{let Ze=new Map;if(!Me)return Ze;let je=0,Ot=null,Ue="",ht=()=>{let it=Ue.indexOf(":");it>0&&Ze.set(Ue.slice(0,it).trim(),Ue.slice(it+1).trim()),Ue=""};for(let it of Me){if(Ot){Ue+=it,it===Ot&&(Ot=null);continue}if(it==='"'||it==="'"){Ot=it,Ue+=it;continue}if(it==="("?je++:it===")"&&je--,it===";"&&je===0){ht();continue}Ue+=it}return Ue.trim()&&ht(),Ze},W=V(v),Y=V(j),ie=V(U),Ne=new Map,Le=!1;for(let Me of new Set([...W.keys(),...Y.keys(),...ie.keys()])){let Ze=W.get(Me)??null,je=Y.get(Me)??null,Ot=ie.get(Me)??null,Ue;je===Ot?Ue=je:je===Ze?Ue=Ot:Ot===Ze?Ue=je:(Ue=O==="local"?je:Ot,Le=!0),Ue!=null&&Ne.set(Me,Ue)}return Le?void 0:[...Ne].map(([Me,Ze])=>`${Me}: ${Ze}`).join("; ")}}function ee(u,v,j,U){let V=u.value,W=U?V:v?v.value:"",Y=j?j.value:"";re.add(u),v&&re.add(v),j&&re.add(j);let ie=wo(V,W,Y,O),Ne=ie.text===""?null:_.createTextNode(ie.text);Ne&&(ye.set(Ne,{base:u.nodes,local:v?v.nodes:null,remote:j?j.nodes:null}),ge.set(Ne,ie.mapLocalOffset)),W!==V&&Y!==V?Oe.push({kind:"text",node:Ne,source:"both"}):W!==V?B({kind:"text",node:Ne,source:"local"}):Y!==V&&ae({kind:"text",node:Ne,source:"remote"});for(let Le of ie.conflicts)de({kind:"text",node:Ne,base:V.slice(Le.bs,Le.be),local:Le.local,remote:Le.remote,resolved:Le.resolved},{site:"run",bRun:u,lRun:v,rRun:j,node:Ne,c:Le});return Ne}function ue(u,v){return xo(u,v).every(j=>j.bs===j.be)}function oe(u,v){let j=u?u.value:"",U=v?v.value:"",V;if(j===U||!U?V=j:j?ue(j,U)?V=U:ue(U,j)?V=j:(V=O==="local"?j:O==="both"?j+U:U,de({kind:"structure",el:null,detail:"insert-collision",local:j,remote:U,resolved:V},{unit:{b:null,l:u,r:v},localLost:O==="remote"})):V=U,u&&re.add(u),v&&re.add(v),V==="")return null;let W=_.createTextNode(V);return ye.set(W,{base:null,local:u?u.nodes:null,remote:v?v.nodes:null}),j?B({kind:"insert",el:W,source:U&&j===U?"both":"local"}):ae({kind:"insert",el:W,source:"remote"}),W}function fe(u,v){let j={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},U=ie=>s(ie).every(Ne=>Xe(Ne)?qn(Ne,j):Ne.kind==="text"),V=null;if(U(u)&&U(v)){let ie=u.textContent,Ne=v.textContent;ie===Ne||ue(Ne,ie)?V=v:ue(ie,Ne)&&(V=u)}if(!V){let ie=O==="local",Ne=y(ie?u:v,ie?"local":"remote",!0),Le=ye.get(Ne);return ie?Le.remote=v:Le.local=u,de({kind:"structure",el:Ne,detail:"insert-collision",local:u,remote:v,resolved:ie?u:v},{unit:{b:null,l:u,r:v},localLost:!ie}),Ne}let W=u.namespaceURI&&u.namespaceURI!=="http://www.w3.org/1999/xhtml"?_.createElementNS(u.namespaceURI,u.tagName):_.createElement(u.tagName);M(null,u,v,W),ye.set(W,{base:null,local:u,remote:v}),re.add(u),re.add(v);let Y=Ir({base:Array.from(V.childNodes),local:Array.from(u.childNodes),remote:Array.from(v.childNodes),out:_,policy:O,idOf:{local:S,remote:L},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:ye,textMappers:ge,conflicts:Be,conflict:de,scope:{base:null,local:u,remote:v,units:[],at:0},synthetic:!0,decisions:Oe,node:W});rt.push(...Y.segments);for(let ie of Y.nodes)W.appendChild(ie);return W}function y(u,v,j=!1){if(!j&&Xe(u)){let Y=ze.partner.get(u);if(Y)return bt(u,v,Y)}if(!Xe(u)){if(u.value==="")return null;let Y=u.kind==="comment"?_.createComment(u.value):_.createTextNode(u.value);return ye.set(Y,{base:null,local:v==="local"?u.nodes:null,remote:v==="remote"?u.nodes:null}),re.add(u),Y}let U=u.namespaceURI&&u.namespaceURI!=="http://www.w3.org/1999/xhtml"?_.createElementNS(u.namespaceURI,u.tagName):_.createElement(u.tagName);for(let Y of u.attributes)Y.namespaceURI?U.setAttributeNS(Y.namespaceURI,Y.name,Y.value):U.setAttribute(Y.name,Y.value);ye.set(U,{base:null,local:v==="local"?u:null,remote:v==="remote"?u:null}),re.add(u);let V=u.tagName==="TEMPLATE"&&U.content?U.content:U,W=v==="local"?te:J;for(let Y of s(u)){let ie=Xe(Y)?W.reverse.get(Y):null;if(ie&&ut.has(ie)){de({kind:"structure",el:null,detail:"both-moved",base:ie},{subject:ie});continue}if(ie&&!dt.has(ie)){let Le=Fe(te,ie)||null,Me=Fe(J,ie)||null;if(Le||Me){let Ze=Et(ie,Le,Me,!1);v==="local"?B({kind:"move",el:Ze,source:"local"}):ae({kind:"move",el:Ze,source:"remote"}),V.appendChild(Ze);continue}}let Ne=y(Y,v);Ne&&V.appendChild(Ne)}return U}function T(u,v,j,U,V){v&&te.identical.has(u)&&te.pairIdenticalChildren(u),j&&J.identical.has(u)&&J.pairIdenticalChildren(u);let W=Xt(te,v,u,U),Y=Xt(J,j,u,!1),ie=s(u),Ne=new Set(ie),Le=new Map;for(let X=0;X<ie.length;X++)Le.set(ie[X],X);let Me=[],Ze=new Set,je=new Map,Ot=new Set,Ue=new Set,ht=[];zt();let it=X=>{let Re=[];for(let Ae of X.units){if(Ue.has(Ae))continue;let Ge=X.baseOf(Ae);Ge&&Ne.has(Ge)&&Re.push(Ge)}return Re},Kt=X=>it(X).map(Re=>Le.get(Re)),Rt=X=>X.every((Re,Ae)=>Ae===0||Re>=X[Ae-1]),qt=!W.asBase&&!Rt(Kt(W)),It=!Y.asBase&&!Rt(Kt(Y));qt&&It&&de({kind:"structure",el:V,detail:"both-reordered",base:u},{subject:u,lKept:it(W),rKept:it(Y)});let at=It||!qt?{V:Y,A:J,side:"remote",other:W,otherA:te,otherSide:"local"}:{V:W,A:te,side:"local",other:Y,otherA:J,otherSide:"remote"};qt?B({kind:"move",el:null,source:It?"both":"local",base:u}):It&&ae({kind:"move",el:null,source:"remote",base:u});let St=W.asBase?[]:W.units.filter(X=>!W.baseOf(X)&&!Ue.has(X)&&!ze.partner.has(X)),At=Y.asBase?[]:Y.units.filter(X=>!Y.baseOf(X)&&!Ue.has(X)&&!ze.partner.has(X)),Ht=new Map;if(St.length&&At.length){let X=new Map,Re=new Map;for(let He of At){if(Xe(He)){let et=L(He);et&&X.set(et,He)}let $e=c.unitHash(He);Re.has($e)||Re.set($e,[]),Re.get($e).push(He)}let Ae=(He,$e)=>{let et=He.units.indexOf($e);for(let _e=et-1;_e>=0;_e--){let nt=He.baseOf(He.units[_e]);if(nt)return nt}return"start"},Ge=new Map,ct=new Map;for(let He of At){let $e=Ae(Y,He);Xe(He)?(ct.has($e)||ct.set($e,[]),ct.get($e).push(He)):He.kind==="text"&&!Ge.has($e)&&Ge.set($e,He)}for(let He of St){let $e=null;if(Xe(He)){let et=S(He);et&&X.has(et)&&!Ht.has(X.get(et))&&($e=X.get(et))}else if(He.kind==="text"){let et=Ge.get(Ae(W,He));et&&!Ht.has(et)&&($e=et)}if(!$e){let et=Re.get(c.unitHash(He));et&&($e=et.find(_e=>!Ht.has(_e)&&Xe(_e)===Xe(He)&&(Xe(_e)?_e.tagName===He.tagName:_e.kind===He.kind)&&c.equalUnits(He,_e))||null)}if(!$e&&Xe(He)){let et=f.local(He),_e=(ct.get(Ae(W,He))||[]).filter(nt=>{let en=f.remote(nt);return!Ht.has(nt)&&nt.tagName===He.tagName&&!(et&&en&&et!==en)&&c.similar(He,nt)});_e.length===1&&($e=_e[0])}$e&&(Ht.set($e,He),Ht.set(He,$e))}}let Zt=X=>{if(re.has(X))return je.get(X)||null;let Re=W.twin(X),Ae=Y.twin(X),Ge=Re&&!W.asBase&&!W.here(Re),ct=Ae&&!Y.asBase&&!Y.here(Ae);if(Ge||ct){if((!Re||!Ae)&&de({kind:"structure",el:null,detail:"move-beats-delete",base:X},{subject:X,deleted:Re?"remote":"local"}),!G(X))return re.add(X),null;de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X})}if(!Re&&!Ae)return re.add(X),ae({kind:"remove",source:"both",base:X}),null;if(!Re&&!Bt(X,Ae,J))return re.add(X),B({kind:"remove",source:"local",base:X}),null;if(!Ae&&!Bt(X,Re,te))return re.add(X),ae({kind:"remove",source:"remote",base:X}),null;let He=!Re||!Ae,$e=W.asBase?Fe(te,X)||null:Re,et=Y.asBase&&Xe(X)&&(J.identityPaired.has(X)||!f.base(X))&&Fe(J,X)||Ae,_e;return Xe(X)?_e=Et(X,$e,et,W.asBase):X.kind==="comment"?_e=N(X,$e,Ae,W.asBase):_e=ee(X,$e,Ae,W.asBase),re.add(X),_e&&(je.set(X,_e),Re&&je.set(Re,_e),Ae&&je.set(Ae,_e),He&&(de({kind:"structure",el:_e,detail:"edit-beats-delete",base:X},{subject:X,deleted:Re?"remote":"local"}),Re?B({kind:"insert",el:_e,source:"local"}):ae({kind:"insert",el:_e,source:"remote"}))),_e},un=(X,Re,Ae,Ge)=>{if(re.has(X))return je.get(X)||null;let ct=Re.baseOf(X);if(ct&&Ne.has(ct))return Ue.has(ct)&&!Ue.has(X)?In(ct,X,Ge):Zt(ct);if(ct)return Cn(ct,X,Ge);let He=Ht.get(X);if(He){let et=Ge==="local"?X:He,_e=Ge==="local"?He:X,nt;return Xe(et)?c.equalUnits(et,_e)?(nt=y(et,"local"),ye.get(nt).remote=_e):nt=fe(et,_e):nt=oe(et,_e),re.add(et),re.add(_e),nt&&(je.set(et,nt),je.set(_e,nt),Xe(et)&&B({kind:"insert",el:nt,source:"both"})),nt}let $e=y(X,Ge);return $e&&(je.set(X,$e),Ge==="local"?B({kind:"insert",el:$e,source:"local"}):ae({kind:"insert",el:$e,source:"remote"})),$e},In=(X,Re,Ae)=>{let Ge;return Xe(X)?(Ge=Qt(X,Ae,Re),Ge&&re.add(Re)):(Ge=y(Re,Ae),re.add(Re),Ge&&(Ae==="local"?B:ae)({kind:"insert",el:Ge,source:Ae})),Ge&&je.set(Re,Ge),Ge},Cn=(X,Re,Ae)=>{let ct=Fe(Ae==="local"?J:te,X),He=Re,$e=ct?he(ct,Ae==="local"?j:v,Ae==="local"?J:te):!1,et=ct&&!$e&&!ve(X,ct);if(et&&Ae===at.otherSide)return de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X}),null;if(et&&de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X}),ct||de({kind:"structure",el:null,detail:"move-beats-delete",base:X},{subject:X,deleted:Ae==="local"?"remote":"local"}),dt.has(X)){de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X});let nt=y(He,Ae);return nt&&je.set(Re,nt),nt}let _e=Xe(X)?Et(X,Ae==="local"?He:Fe(te,X)||null,Ae==="remote"?He:Fe(J,X)||null,!1):null;return _e&&(je.set(X,_e),je.set(Re,_e),ct&&je.set(ct,_e),Ae==="local"?B({kind:"move",el:_e,source:"local"}):ae({kind:"move",el:_e,source:"remote"})),_e};for(let X of at.V.units){if(Ue.has(X)){let Ae=je.get(X);Ze.has(Ae)||(Me.push(Ae),Ze.add(Ae));continue}if(re.has(X)&&!(je.get(X)&&Ze.has(je.get(X)))){let Ae=at.V.baseOf(X);Ae&&!Ne.has(Ae)&&de({kind:"structure",el:null,detail:"both-moved",base:Ae},{subject:Ae});continue}let Re=un(X,at.V,at.A,at.side);Re&&!Ze.has(Re)&&(Me.push(Re),Ze.add(Re),!at.V.baseOf(X)&&!Ht.has(X)&&!Ue.has(X)&&Ot.add(Re))}for(let X of ht)Ze.has(X.frag)||(Me.splice(xn(X.at),0,X.frag),Ze.add(X.frag));if(!at.other.asBase){let X=at.other,Re=at.otherSide,Ae=at.otherA,Ge=null,ct=0,He=null;for(let $e of X.units){let et=je.get($e);if(et&&Ze.has(et)){Ge=et,He=null;continue}if(re.has($e)){let en=X.baseOf($e);en&&!Ne.has(en)&&de({kind:"structure",el:null,detail:"both-moved",base:en},{subject:en});continue}let _e=un($e,X,Ae,Re);if(!_e)continue;let nt;if(He)nt=Me.indexOf(He)+1;else if(Ge){if(nt=Me.indexOf(Ge)+1,Re==="remote")for(;nt<Me.length&&Ot.has(Me[nt]);)nt++}else nt=ct++;Me.splice(nt,0,_e),Ze.add(_e),He=_e}}for(let X=0;X<ie.length;X++){let Re=ie[X];if(re.has(Re))continue;let Ae=Zt(Re);Ae&&Me.splice(xn(X),0,Ae)}return Me;function xn(X){for(let Re=X-1;Re>=0;Re--){let Ae=je.get(ie[Re]);if(Ae){let Ge=Me.indexOf(Ae);if(Ge>=0)return Ge+1}}return 0}function cn(X){let Re={ignored:r,remoteWins:()=>!1},Ae=me=>X(me)||Xe(me)&&o.remoteWins(me)&&An.has(me.tagName)&&qn(me,Re),Ge=new Map,ct=me=>{if(!Xe(me)||!_c.has(me.tagName))return!1;let Ie=Ge.get(me);return Ie===void 0&&(Ie=!r(me)&&!o.remoteWins(me)&&s(me).every(Ae),Ge.set(me,Ie)),Ie},He=me=>!Xe(me)&&me.kind==="text",$e=null,et=new Map,_e=me=>{let Ie=et.get(me);if(Ie)return Ie;let qe=Xe(me)?me.textContent:me.value;Ie=new Set;let tt=qe.toLowerCase();if(!(qe.length>Ks))if(/^[\x00-\x7f]*$/.test(tt))for(let Ke of tt.split(/[^\p{L}\p{N}]+/u))Ke&&Ie.add(Ke);else for(let Ke of Sr(tt))/^[\s\p{P}]+$/u.test(Ke)||Ie.add(Ke);return et.set(me,Ie),Ie},nt=me=>(Xe(me)?me.textContent:me.value).toLowerCase().replace(/\s+/g," ").trim(),en=new Map,Vn=me=>{let Ie=en.get(me);if(Ie)return Ie;Ie=new Set(_e(me));let qe=Ke=>{if(Ke)for(let kt of _e(Ke))Ie.add(kt)},tt=Ne.has(me)?me:!W.asBase&&W.baseOf(me)||!Y.asBase&&Y.baseOf(me);return tt&&(qe(tt),qe(Fe(te,tt)),qe(Fe(J,tt))),en.set(me,Ie),Ie},dn=(me,Ie)=>{let qe=nt(Ie),tt=Ne.has(me)?me:!W.asBase&&W.baseOf(me)||!Y.asBase&&Y.baseOf(me),Ke=Ut=>qe?Ut.split(qe).length-1:0;if(tt&&Xe(Ie)&&!Ne.has(Ie)){let Ut=Ke(nt(tt));for(let _t of[Fe(te,tt),Fe(J,tt)]){if(!_t||_t===Ie||_t.ownerDocument!==Ie.ownerDocument)continue;let an=nt(_t);if(an.length>qe.length&&Ke(an)>=Ut&&(an.startsWith(qe)||an.endsWith(qe)))return!1}}let kt=_e(Ie),yt=Vn(me),Pt=0;for(let Ut of kt)yt.has(Ut)&&Pt++;if(kt.size&&Pt*2>=kt.size)return!0;if(!qe||qe.length>Ks)return!1;let Ft=tt?[me,tt,Fe(te,tt),Fe(J,tt)]:[me],on=(Ut,_t)=>Ut!==_t&&(Ut.startsWith(_t)||Ut.endsWith(_t));if(Ft.some(Ut=>Ut&&on(nt(Ut),qe)))return!0;if(!Ne.has(Ie)||!tt)return!1;let vt=nt(me),Ln=nt(tt);return[Fe(te,Ie),Fe(J,Ie)].some(Ut=>{let _t=Ut&&nt(Ut);return!!_t&&vt!==_t&&(vt.startsWith(_t)&&!Ln.startsWith(_t)||vt.endsWith(_t)&&!Ln.endsWith(_t))})},ln=me=>{$e||($e=new Set),$e.add(me)},Wn=me=>{ln(me);for(let[Ie,qe]of[[te,W],[J,Y]]){if(qe.asBase)continue;let tt=Fe(Ie,me);tt&&qe.here(tt)&&ln(tt)}},Je=(me,Ie)=>me.asBase||ie.every(qe=>!Xe(qe)||Ie.identical.has(qe)&&me.here(Fe(Ie,qe)))&&me.units.every(qe=>!Xe(qe)||me.baseOf(qe));if(Je(W,te)&&Je(Y,J))return null;let ft=me=>{if(me.asBase)return!1;let Ie=-1;for(let qe of me.units){let tt=Xe(qe)?me.baseOf(qe):null;if(!tt||!Ne.has(tt))continue;let Ke=Le.get(tt);if(Ke<Ie)return!0;Ie=Ke}return!1};if(ft(W)||ft(Y))return null;for(let[me,Ie]of[[W,te],[Y,J]]){if(me.asBase||Je(me,Ie))continue;let qe=me.units,tt=Ie===te?f.local:f.remote,Ke=(Pe,pt)=>{let Mt=Xe(Pe)&&f.base(Pe),xt=Xe(pt)&&tt(pt);return!Mt||!xt||Mt===xt},kt=new Map;for(let Pe=0;Pe<qe.length;Pe++)kt.set(qe[Pe],Pe);let yt=Pe=>!!Pe&&(Xe(Pe)?me.here(Pe):kt.has(Pe)),Pt=Pe=>{let pt=me.twin(Pe);return yt(pt)?pt:null},Ft=ie.filter(Pe=>!me.twin(Pe)&&ct(Pe)),on=qe.filter(Pe=>!me.baseOf(Pe)&&ct(Pe)),vt=(Pe,pt)=>pt===ie?!!Pt(Pe):Ne.has(me.baseOf(Pe)),Ln=Pe=>{let pt=new Int32Array(Pe.length),Mt=new Int32Array(Pe.length),xt=-1;for(let mt=0;mt<Pe.length;mt++)pt[mt]=xt,vt(Pe[mt],Pe)&&(xt=mt);xt=Pe.length;for(let mt=Pe.length-1;mt>=0;mt--)Mt[mt]=xt,vt(Pe[mt],Pe)&&(xt=mt);return{prev:pt,next:Mt}},Ut=Ln(qe),_t=Ln(ie),an=(Pe,pt)=>{Wn(Pe),ln(pt)};for(let Pe of on){let pt=kt.get(Pe),Mt=Ut.prev[pt],xt=Ut.next[pt],mt=Mt>=0?me.baseOf(qe[Mt]):null,yn=xt<qe.length?me.baseOf(qe[xt]):null,Vt=mt?Le.get(mt):-1,Rn=yn?Le.get(yn):ie.length;for(let Tn=Math.max(0,Vt);Tn<=Math.min(Rn,ie.length-1);Tn++){let Gt=ie[Tn];(ct(Gt)||He(Gt))&&(!Ke(Gt,Pe)||!dn(Gt,Pe)||(He(Gt)?ln(Pe):an(Gt,Pe)))}}let bn=(Pe,pt,Mt)=>{for(let xt=pt+Mt;xt>=0&&xt<Pe.length;xt+=Mt){let mt=Pe[xt];if(ct(mt))return mt;if(Xe(mt)||mt.value.trim())return null}return null},Uo=Pe=>{let pt=new Set;for(let Mt of s(Pe))if(!Xe(Mt)&&Mt.kind==="text")for(let xt of _e(Mt))pt.add(xt);return pt},Zn=(Pe,pt)=>{let Mt=_e(pt),xt=new Set;for(let mt of Uo(Pe))Mt.has(mt)||xt.add(mt);return xt},bo=(Pe,pt)=>{if(!Pe.size)return!1;let Mt=_e(pt),xt=0;for(let mt of Pe)Mt.has(mt)&&xt++;return xt*2>=Pe.size};for(let Pe of ie){if(Ie.identical.has(Pe)||!ct(Pe))continue;let pt=Pt(Pe);if(!pt||!ct(pt))continue;let Mt=Zn(pt,Pe),xt=Zn(Pe,pt);for(let mt of[-1,1]){let yn=bn(ie,Le.get(Pe),mt);yn&&bo(Mt,yn)&&(an(Pe,pt),Wn(yn));let Vt=bn(qe,kt.get(pt)??-1,mt);if(Vt&&bo(xt,Vt)){an(Pe,pt);let Rn=me.baseOf(Vt);Rn?an(Rn,Vt):ln(Vt)}}}for(let Pe of Ft){let pt=Le.get(Pe),Mt=_t.prev[pt],xt=_t.next[pt],mt=Mt>=0?Pt(ie[Mt]):null,yn=xt<ie.length?Pt(ie[xt]):null,Vt=mt?kt.get(mt)??-1:-1,Rn=yn?kt.get(yn)??-1:qe.length;for(let Tn=Math.max(0,Vt);Tn<=Math.min(Rn,qe.length-1);Tn++){let Gt=qe[Tn];if((ct(Gt)||He(Gt))&&!(!Ke(Pe,Gt)||!dn(Gt,Pe))&&(Wn(Pe),!He(Gt))){let _o=me.baseOf(Gt);_o?an(_o,Gt):ln(Gt)}}}}if(!$e)return null;for(let me of Array.from($e))if(Ne.has(me))for(let Ie of[te,J]){let qe=Fe(Ie,me);qe&&!he(qe,Ie===te?v:j,Ie)&&!(Ie===te?W:Y).asBase&&($e.delete(me),$e.delete(Fe(te,me)),$e.delete(Fe(J,me)))}return $e.size?$e:null}function zt(){if((W.asBase||te.identical.has(u))&&(Y.asBase||J.identical.has(u)))return;let X={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},Re=Je=>Xe(Je)?qn(Je,X):Je.kind==="text",Ae=cn(Re),Ge=Je=>Ae&&Ae.has(Je)||Re(Je),ct=ie.map(Ge);if(!ct.includes(!0))return;let He=Je=>{let ft=Je.units,me=new Map;for(let yt=0;yt<ft.length;yt++)me.set(ft[yt],yt);let Ie=[],qe=-1;for(let yt=0;yt<ie.length;yt++){if(ct[yt])continue;let Pt=Je.twin(ie[yt]),Ft=Pt?me.get(Pt):void 0;Ft===void 0||Ft<=qe||Ge(Pt)||(Ie.push([yt,Ft]),qe=Ft)}let tt=[],Ke=-1,kt=-1;for(let yt=0;yt<=Ie.length;yt++){let[Pt,Ft]=yt<Ie.length?Ie[yt]:[ie.length,ft.length],on={bLo:-1,bHi:-1,sLo:-1,sHi:-1,next:Ft};for(let vt=Ke+1;vt<Pt;vt++)ct[vt]&&(on.bLo<0&&(on.bLo=vt),on.bHi=vt);for(let vt=kt+1;vt<Ft;vt++)Ge(ft[vt])&&(on.sLo<0&&(on.sLo=vt),on.sHi=vt);tt.push(on),Ke=Pt,kt=Ft}return{units:ft,list:tt}},$e=He(W),et=He(Y),_e=[];for(let Je of[$e,et])for(let ft of Je.list)ft.bLo>=0&&_e.push([ft.bLo,ft.bHi]);_e.sort((Je,ft)=>Je[0]-ft[0]);let nt=[];for(let[Je,ft]of _e){let me=nt[nt.length-1];me&&Je<=me.hi?me.hi=Math.max(me.hi,ft):nt.push({lo:Je,hi:ft})}let en=(Je,ft)=>{let me=-1,Ie=-1;for(let Ke=0;Ke<Je.list.length;Ke++){let kt=Je.list[Ke];kt.bLo<ft.lo||kt.bLo>ft.hi||(me<0&&(me=Ke),Ie=Ke)}let qe=1/0,tt=-1;for(let Ke=me;Ke>=0&&Ke<=Ie;Ke++){let kt=Je.list[Ke];kt.sLo>=0&&(qe=Math.min(qe,kt.sLo),tt=Math.max(tt,kt.sHi)),Ke<Ie&&(qe=Math.min(qe,kt.next),tt=Math.max(tt,kt.next))}return tt<0?[]:Je.units.slice(qe,tt+1)},Vn=(Je,ft)=>Je.length===ft.length&&Je.every((me,Ie)=>c.equalUnits(me,ft[Ie])),dn=Je=>!Xe(Je)&&Je.kind==="comment",ln=Je=>{if(!Je.length)return[];let ft=(Ke,kt)=>Xe(Ke)?Ke:Ke.nodes[kt?Ke.nodes.length-1:0],me=ft(Je[0]),Ie=ft(Je[Je.length-1],!0),qe=Ke=>Ke&&Xe(Ke)&&r(Ke);for(;qe(me.previousSibling);)me=me.previousSibling;for(;qe(Ie.nextSibling);)Ie=Ie.nextSibling;let tt=[];for(let Ke=me;Ke&&(tt.push(Ke),Ke!==Ie);Ke=Ke.nextSibling);return tt},Wn=Je=>Je.some(ft=>Xe(ft)&&r(ft));for(let Je of nt){let ft=ie.slice(Je.lo,Je.hi+1),me=W.asBase?null:en($e,Je),Ie=Y.asBase?null:en(et,Je);if(ft.some(dn)||me&&me.some(dn)||Ie&&Ie.some(dn))continue;let qe=ln(me||ft),tt=ln(Ie||ft);if((!me||Vn(ft,me))&&(!Ie||Vn(ft,Ie))&&!(me&&Wn(qe)))continue;let Ke=Ir({base:ln(ft),local:qe,remote:tt,out:_,policy:O,blocks:Ae,L:me?te:zs(te,u),R:Ie?J:zs(J,u),idOf:{local:S,remote:L},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(yt,Pt,Ft)=>Et(yt,Pt,Ft,!1),cloneUnit:y,mergeAttrs:M,atomKey:c.exactUnitKey,moveIn:Qt,provenance:ye,textMappers:ge,conflicts:Be,conflict:de,scope:{base:u,local:W.asBase?null:W.el,remote:Y.asBase?null:Y.el,units:ie,at:Je.lo},decisions:Oe,node:V});rt.push(...Ke.segments);let kt=_.createDocumentFragment();for(let yt of Ke.nodes)kt.appendChild(yt);for(let yt of[...ft,...me||[],...Ie||[]])re.add(yt),Ue.add(yt),je.set(yt,kt);ht.push({frag:kt,at:Je.lo})}}}function P(u,v){let j=ye.get(u);return j&&j.unchanged?!j.remote||j.remote===v?!0:p(j.remote,v):u.tagName!==v.tagName||!$(u,v)?!1:H(R(u),R(v))}function p(u,v){return u===v?!0:u.tagName!==v.tagName||u.namespaceURI!==v.namespaceURI||!$(u,v)?!1:k(R(u),R(v))}function k(u,v){let j=F(u,r),U=F(v,r);if(j.length!==U.length)return!1;for(let V=0;V<j.length;V++){let W=j[V],Y=U[V];if(typeof W=="string"||typeof Y=="string"){if(W!==Y)return!1}else{if(W.nodeType!==Y.nodeType)return!1;if(W.nodeType===1){if(!p(W,Y))return!1}else if(W.nodeValue!==Y.nodeValue)return!1}}return!0}function R(u){return u.tagName==="TEMPLATE"&&u.content?u.content:u}function $(u,v){let j=0;for(let U of u.attributes)if(!o.ignoreAttribute(u,U.name)&&(j++,v.getAttribute(U.name)!==U.value))return!1;for(let U of v.attributes)o.ignoreAttribute(v,U.name)||j--;return j===0}function H(u,v){let j=F(u,V=>{let W=ye.get(V);return!!(W&&W.pinned)}),U=F(v,r);if(j.length!==U.length)return!1;for(let V=0;V<j.length;V++){let W=j[V],Y=U[V];if(typeof W=="string"||typeof Y=="string"){if(W!==Y)return!1}else{if(W.nodeType!==Y.nodeType)return!1;if(W.nodeType===1){if(!P(W,Y))return!1}else if(W.nodeValue!==Y.nodeValue)return!1}}return!0}function F(u,v){let j=[],U=null;for(let V=u.firstChild;V;V=V.nextSibling){if(V.nodeType===3){U=U===null?V.nodeValue:U+V.nodeValue;continue}V.nodeType===1&&v(V)||(U!==null&&(U!==""&&j.push(U),U=null),j.push(V))}return U!==null&&U!==""&&j.push(U),j}function N(u,v,j,U){let V=u.value,W=U?V:v?v.value:"",Y=j?j.value:"";re.add(u),v&&re.add(v),j&&re.add(j);let ie=W===Y?W:W===V?Y:Y===V||O==="local"?W:Y,Ne={site:"comment",bRun:u,lRun:v,rRun:j,node:null};if(W!==V&&Y!==V&&W!==Y&&de({kind:"text",node:null,base:V,local:W,remote:Y,resolved:ie},Ne),!v&&!j)return null;let Le=_.createComment(ie);return Ne.node=Le,ye.set(Le,{base:u.nodes,local:v?v.nodes:null,remote:j?j.nodes:null}),Le}function E(u,v){let j=Fe(v,u);if(!j)return null;let U=Xe(j)?j.parentNode:j.parent,V=Xe(u)?u.parentNode:u.parent;return Fe(v,V)===U?null:v.reverse.get(U)||null}function G(u){let v=new Set([u]),j=u;for(let U=0;U<64;U++){let V=E(j,te)||E(j,J);if(!V)return!1;if(V===u||Xe(u)&&Xe(V)&&u.contains(V)||v.has(V))return!0;v.add(V),j=V}return!0}function he(u,v,j){if(!v)return!1;let U=Xe(u)?u.parentNode:u.parent;return U===v||v.tagName==="TEMPLATE"&&U===v.content}function ve(u,v){let j=ne(u),U=Fe(te,j);if(U&&he(v,U,te))return!0;let V=Fe(J,j);return!!(V&&he(v,V,J))}}function zs(e,t){return e.map.get(t)?Gs():{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 Gs(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Ys=new Set(["INPUT","OPTION","TEXTAREA"]),jr=/[\t\n\f\r ]+/;function Js(e,t,n,o){let r=e.ownerDocument,{provenance:i,textMappers:c}=n,s=o.hooks,a=[],m=[],h=[],d=new Set,b=[],A=[],S=new Map,L=new Set,f=new Map,g=n.conflicts.length>0,x=new Map,Q=new Set,se=new Map,le=(M,Z)=>{let ee=se.get(M);ee||se.set(M,ee=new Set),ee.add(Z)},q=g?new Set:null,z=(M,Z,ee)=>{let ue=s.beforeAttributeUpdated(M,Z,ee);return g&&ue===!1&&le(Z,M),ue},ce=M=>!!M&&(M===e||e.contains(M)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(M)),xe=new Map,te=new Map,J=new Map,Ce=new Set,we=new Map;(function M(Z){let ee=i.get(Z);if(ee){if(Z.nodeType===1){let oe=ee.local?o.toLive(ee.local):null;oe&&ce(oe)&&oe.nodeType===1&&(xe.set(Z,oe),te.set(oe,Z))}else if(Array.isArray(ee.local)){let oe=ge(ee.local,ee.local.map(fe=>o.toLive(fe)).filter(fe=>fe&&ce(fe)&&fe.nodeType===Z.nodeType));if(oe.length&&(xe.set(Z,oe[0]),te.set(oe[0],Z),J.set(Z,oe)),Array.isArray(ee.caret))for(let fe of ee.caret){let y=o.toLive(fe.node);if(!y||!ce(y)||y.nodeType!==3)continue;let T=we.get(y);Array.isArray(T)||we.set(y,T=[]),T.push({merged:Z,from:fe.from,to:fe.to,flatStart:fe.flatStart})}else{let fe=0;for(let y of oe)we.set(y,{merged:Z,shift:fe}),fe+=y.nodeValue.length}}}let ue=Z.nodeType===1&&Z.tagName==="TEMPLATE"&&Z.content?Z.content.childNodes:Z.childNodes;for(let oe of ue)M(oe)})(t);let ne=new Set;for(let M of xe.values())ne.add(M);for(let M of J.values())for(let Z of M)ne.add(Z);for(let M of n.segments||[])Oe(M);let _=o.restoreFocus===!1?null:Vc(r,we);o.childrenOnly?re(Be(e),Be(t)):We(e,t);for(let{node:M,parent:Z}of b)d.has(M)||!M.parentNode||M.nodeType===1&&(o.ignored(M)||ut(M))||De(M,Z);return Wc(r,_,we,c,J,f,Ce),{applied:a,moved:m,replaced:h,identities:A,mergedScriptsLive:L,liveOf:xe,heldBy:f,runOf:J,keptRuns:Ce,insertedLive:x,vetoed:Q,vetoedAttrs:se,removedVetoes:q};function ye(M,Z){let ee=M.slice(Z.bs,Z.be),ue=0;for(;ue<ee.length&&ue<Z.text.length&&ee[ue]===Z.text[ue];)ue++;let oe=0;for(;oe<ee.length-ue&&oe<Z.text.length-ue&&ee[ee.length-1-oe]===Z.text[Z.text.length-1-oe];)oe++;return{bs:Z.bs+ue,be:Z.be-oe,text:Z.text.slice(ue,Z.text.length-oe)}}function ge(M,Z){if(!Z.length)return Z;let ee=[];for(let fe of M){let y=fe.parentNode;if(!y)continue;let T=S.get(y);if(!T){T=new Set;for(let P=y.firstChild;P;P=P.nextSibling)P.nodeType===3&&T.add(o.toLive(P));S.set(y,T)}ee.includes(T)||ee.push(T)}let ue={has:fe=>ee.some(y=>y.has(fe))},oe=[];for(let fe of Z){oe.push(fe);for(let y=fe.nextSibling;y&&y.nodeType===3&&!ue.has(y)&&!oe.includes(y);y=y.nextSibling)oe.push(y)}return oe}function Oe(M){let Z=[];for(let N of M.localNodes){let E=o.toLive(N.node);if(!E||!ce(E)||E.nodeType!==3)return;Z.push(E)}let ee=ge(M.localNodes.map(N=>N.node),Z);if(!ee.length)return;let ue=ee.map(N=>N.nodeValue).join(""),{flatLocal:oe,lToM:fe,mapLocal:y}=M;if(ue===oe)return;let T=M.textNodes.map(N=>({node:N.node,ms:N.ms,me:N.me})),P=[],p=0;for(let N of ee)P.push(p),p+=N.nodeValue.length;let k=(N,E)=>ee.find((G,he)=>P[he]<=N&&N+E<=P[he]+G.nodeValue.length)||null,R=[],$=0;for(let N of xo(oe,ue).map(E=>ye(oe,E))){let E=N.bs+$;$+=N.text.length-(N.be-N.bs);let G,he;if(N.be>N.bs){G=fe[N.bs];let ve=G>=0;for(let u=N.bs;ve&&u<N.be;u++)fe[u]!==G+(u-N.bs)&&(ve=!1);if(!ve)continue;he=G+(N.be-N.bs)}else{let ve=N.bs>0?fe[N.bs-1]:0,u=N.bs<oe.length?fe[N.bs]:0;if(ve<0||u<0)continue;G=he=y(N.bs)}R.push({ms:G,me:he,text:N.text,live:he===G?k(E,N.text.length):null})}R.sort((N,E)=>E.ms-N.ms);let H=(N,E)=>(J.get(N.node)||[xe.get(N.node)]).includes(E),F=N=>!!N&&N.nodeType===1&&An.has(N.tagName);for(let N of R){let E=T.find(he=>he.ms<=N.ms&&N.me<=he.me&&N.ms<he.me);if(E&&N.live&&E.ms===N.ms&&!H(E,N.live)){let he=T.find(ve=>ve.me===N.ms&&H(ve,N.live));he&&(E=he)}if(!E&&N.me===N.ms){let he=T.find(j=>j.me===N.ms),ve=T.find(j=>j.ms===N.ms),u=he||ve;if(!u)continue;let v=u.node;for(;F(v.parentNode)&&(he?v.parentNode.lastChild:v.parentNode.firstChild)===v;)v=v.parentNode;if(v===u.node)E=u;else{let j=v.ownerDocument.createTextNode(N.text);v.parentNode.insertBefore(j,he?v.nextSibling:v);continue}}if(!E)continue;let G=E.node.nodeValue;E.node.nodeValue=G.slice(0,N.ms-E.ms)+N.text+G.slice(N.me-E.ms),E.me+=N.text.length-(N.me-N.ms)}}function Be(M){return M.nodeType===1&&M.tagName==="TEMPLATE"&&M.content?M.content:M}function We(M,Z){d.add(M);let ee=i.get(Z);if(ee&&ee.remote&&n.remoteIdOf){let oe=n.remoteIdOf(ee.remote);oe&&A.push([M,oe])}if(ee&&ee.unchanged){n.customIdentity&&ee.remote&&B(M,ee.remote),ee.remote&&O(M,ee.remote);return}if(s.beforeNodeMorphed(M,Z)===!1){Q.add(Z);return}nn(M,Z,o.keepLiveOnly&&ee&&ee.local&&ee.local.nodeType===1&&ee.local!==M?ee.local:null);let ue=M.tagName;if(tn(M))M.textContent!==Z.textContent&&(a.push({kind:"text",node:M,before:M.textContent,after:Z.textContent}),M.textContent=Z.textContent),n.mergedScripts.has(Z)&&L.add(M);else if(ue==="TEXTAREA")sn(M,Z,ee);else{Et(M,Z,ee);let oe=ue==="TEMPLATE"&&M.content?M.content:M,fe=ue==="TEMPLATE"&&Z.content?Z.content:Z;o.protectFocusedValue==="subtree"&&Qt(M)&&M!==r.body?rt(oe):re(oe,fe)}s.afterNodeMorphed(M,Z)}function rt(M){for(let Z=M.firstChild;Z;Z=Z.nextSibling){let ee=te.get(Z);ee&&xe.get(ee.parentNode)!==M||(d.add(Z),Z.nodeType===1&&rt(Z))}}function re(M,Z){let ee=de(M.firstChild),ue=new Set;for(let oe of Array.from(Z.childNodes)){let fe=xe.get(oe);fe&&d.has(fe)&&!ue.has(fe)&&(fe=null);let y=i.get(oe);if(y&&y.pinned){fe&&fe.nodeType===1&&((fe.parentNode!==M||de(fe.nextSibling)!==ee)&&ze(M,fe,ee),d.add(fe),ue.add(fe));continue}if(fe&&fe.nodeType===1){if(fe!==ee){let p=fe.parentNode;if(p===M&&ee&&Xt(fe)){let k=fe.nextSibling;for(let R=ee;R&&R!==fe;){let $=R.nextSibling;ze(M,R,k),R=$}}else ze(M,fe,ee),p!==M&&(m.push(fe),a.push({kind:"move",el:fe,from:p,to:M}))}ue.add(fe),We(fe,oe),ee=de(fe.nextSibling);continue}if(fe&&fe.nodeType!==1){let p=J.get(oe)||[fe],k=p.map($=>$.nodeValue).join(""),R=oe.nodeValue;if(oe.nodeType===3){let $=dt(oe);$!=null&&k!==$&&(R=wo($,k,oe.nodeValue).text)}if(p.length>1&&k===R&&!p.includes(ee,1)&&p.every(($,H)=>$.parentNode===M&&(H===0||p[H-1].nextSibling===$))){if(fe!==ee)for(let $ of p)ze(M,$,ee);s.beforeNodeMorphed(fe,oe)!==!1?s.afterNodeMorphed(fe,oe):g&&Q.add(oe);for(let $ of p)d.add($),ue.add($);f.set(oe,fe),Ce.add(oe),ee=de(p[p.length-1].nextSibling);continue}fe!==ee&&ze(M,fe,ee),s.beforeNodeMorphed(fe,oe)!==!1?(fe.nodeValue!==R&&(a.push({kind:"text",node:fe,before:fe.nodeValue,after:R}),fe.nodeValue=R),s.afterNodeMorphed(fe,oe)):Q.add(oe),d.add(fe),ue.add(fe),f.set(oe,fe),ee=de(fe.nextSibling);continue}if(oe.nodeType===3&&ee&&ee.nodeType===3&&!d.has(ee)&&!we.has(ee)){ee.nodeValue!==oe.nodeValue&&(a.push({kind:"text",node:ee,before:ee.nodeValue,after:oe.nodeValue}),ee.nodeValue=oe.nodeValue),d.add(ee),f.set(oe,ee),ee=de(ee.nextSibling);continue}let T=i.get(oe),P=Qe(T&&T.unchanged&&T.remote?T.remote:oe);if(s.beforeNodeAdded(P)===!1){Q.add(oe);continue}M.insertBefore(P,ee),d.add(P),g&&x.set(oe,P),P.nodeType===3&&f.set(oe,P),P.nodeType===1&&(h.push(P),be(P,oe),n.customIdentity&&T&&T.unchanged&&T.remote&&B(P,T.remote),tn(P)||st(P,oe),o.formState==="property"&&Bt(T)&&O(P,T.remote)),ee=de(P.nextSibling),a.push({kind:"insert",node:P,parent:M}),s.afterNodeAdded(P)}for(let oe of Array.from(M.childNodes))d.has(oe)||ue.has(oe)||oe.nodeType===1&&(o.ignored(oe)||ut(oe))||(ne.has(oe)?b.push({node:oe,parent:M}):De(oe,M))}function ut(M){return o.preserve&&M.parentNode&&M.parentNode.nodeType===1&&M.parentNode.tagName==="HEAD"&&o.preserve(M)===!0}function dt(M){let Z=i.get(M);return!Z||!Array.isArray(Z.local)?null:Z.local.map(ee=>ee.nodeValue).join("")}function Se(M){return i.get(M)}function O(M,Z){if(!Ys.has(M.tagName)&&!M.querySelector("input,option,textarea"))return;let ee=(ue,oe)=>{if(ue.tagName!==oe.tagName)return;ue.tagName==="TEXTAREA"?sn(ue,oe,{remote:oe}):Ys.has(ue.tagName)&&Et(ue,oe,{remote:oe});let fe=ae(ue),y=ae(oe);if(fe.length===y.length)for(let T=0;T<fe.length;T++)ee(fe[T],y[T])};ee(M,Z)}function B(M,Z){let ee=ae(M),ue=ae(Z);if(ee.length===ue.length)for(let oe=0;oe<ee.length;oe++){let fe=n.remoteIdOf(ue[oe]);fe&&A.push([ee[oe],fe]),B(ee[oe],ue[oe])}}function ae(M){let Z=M.tagName==="TEMPLATE"&&M.content?M.content:M;return Array.from(Z.children).filter(ee=>!o.ignored(ee))}function be(M,Z){if(!n.remoteIdOf)return;let ee=(ue,oe)=>{let fe=i.get(oe);if(fe&&fe.remote&&oe.nodeType===1){let P=n.remoteIdOf(fe.remote);P&&A.push([ue,P])}let y=ue.childNodes,T=oe.childNodes;for(let P=0;P<y.length&&P<T.length;P++)ee(y[P],T[P])};ee(M,Z)}function de(M){for(;M&&M.nodeType===1&&o.ignored(M);)M=M.nextSibling;return M}function ze(M,Z,ee){if(typeof M.moveBefore=="function"&&Z.ownerDocument===M.ownerDocument)try{M.moveBefore(Z,ee);return}catch{}M.insertBefore(Z,ee)}function De(M,Z){if(s.beforeNodeRemoved(M)===!1){g&&q.add(M);return}M.parentNode.removeChild(M),a.push({kind:"remove",node:M,parent:Z}),s.afterNodeRemoved(M)}function Qe(M){if(tn(M))return To(M,r);let Z=r.importNode(M,!0);if(Z.nodeType===1)for(let ee of Array.from(Z.querySelectorAll("script")))tn(ee)&&ee.replaceWith(To(ee,r));return Z}function st(M,Z){let ee=M.tagName==="TEMPLATE"&&M.content?M.content:M,ue=Z.tagName==="TEMPLATE"&&Z.content?Z.content:Z,oe=Array.from(ee.childNodes),fe=Array.from(ue.childNodes);for(let y=0;y<fe.length&&y<oe.length;y++){let T=fe[y],P=oe[y],p=xe.get(T);p&&d.has(p)&&(p=null);let k=i.get(T);if(k&&k.pinned){if(p&&p.nodeType===1){let R=p.parentNode;ze(ee,p,P),R!==ee&&(m.push(p),a.push({kind:"move",el:p,from:R,to:ee})),d.add(p)}P.remove();continue}if(p){let R=p.parentNode;ze(ee,p,P),P.remove(),p.nodeType===1?(R!==ee&&(m.push(p),a.push({kind:"move",el:p,from:R,to:ee})),We(p,T)):(d.add(p),f.set(T,p),p.nodeValue!==T.nodeValue&&(a.push({kind:"text",node:p,before:p.nodeValue,after:T.nodeValue}),p.nodeValue=T.nodeValue));continue}d.add(P),g&&x.set(T,P),P.nodeType===3&&f.set(T,P),k&&k.unchanged&&k.remote?(wt(P,k.remote),n.customIdentity&&B(P,k.remote)):T.nodeType===1&&!tn(T)&&st(P,T)}}function wt(M,Z){let ee=M.tagName==="TEMPLATE"&&M.content?M.content:M,ue=Z.tagName==="TEMPLATE"&&Z.content?Z.content:Z;for(let oe of Array.from(ue.childNodes))ee.appendChild(Qe(oe))}function bt(M,Z){return Z.namespaceURI?M.getAttributeNS(Z.namespaceURI,Z.localName):M.getAttribute(Z.name)}function Tt(M,Z){let ee=new Set((Z||"").split(jr).filter(Boolean));return(M||"").split(jr).filter(ue=>ue&&!ee.has(ue))}function nn(M,Z,ee){for(let ue of Array.from(Z.attributes)){if(Fe(M,ue.name)||o.ignoreAttribute(M,ue.name))continue;let oe=bt(M,ue);if(oe===ue.value||ee&&bt(ee,ue)===ue.value)continue;let fe=ue.value;if(ee&&ue.name==="class"&&!ue.namespaceURI){let y=ue.value.split(jr).filter(Boolean),T=Tt(oe,ee.getAttribute("class")).filter(P=>!y.includes(P));T.length&&(fe=[...y,...T].join(" "))}if(oe!==fe){if(s.beforeAttributeUpdated(ue.name,M,"update")===!1){g&&le(Z,ue.name);continue}ue.namespaceURI?M.setAttributeNS(ue.namespaceURI,ue.name,fe):M.setAttribute(ue.name,fe),a.push({kind:"attr",el:M,name:ue.name,before:oe,after:fe})}}for(let ue of Array.from(M.attributes)){if(Fe(M,ue.name)||o.ignoreAttribute(M,ue.name)||(ue.namespaceURI?Z.hasAttributeNS(ue.namespaceURI,ue.localName):Z.hasAttribute(ue.name)))continue;if(ee&&ue.name==="class"&&!ue.namespaceURI){let y=Tt(ue.value,ee.getAttribute("class"));if(y.length){let T=y.join(" ");if(T===ue.value)continue;if(s.beforeAttributeUpdated("class",M,"update")===!1){g&&le(Z,"class");continue}M.setAttribute("class",T),a.push({kind:"attr",el:M,name:"class",before:ue.value,after:T});continue}}if(ee&&bt(ee,ue)===null)continue;if(s.beforeAttributeUpdated(ue.name,M,"remove")===!1){g&&le(Z,ue.name);continue}let fe=ue.value;ue.namespaceURI?M.removeAttributeNS(ue.namespaceURI,ue.localName):M.removeAttribute(ue.name),a.push({kind:"attr",el:M,name:ue.name,before:fe,after:null})}}function Fe(M,Z){let ee=M.tagName;return ee==="INPUT"?Z==="value"||Z==="checked"||Z==="disabled":ee==="OPTION"?Z==="selected":!1}function Qt(M){return M===r.activeElement}function Xt(M){let Z=r.activeElement;return!!Z&&Z!==r.body&&M.contains(Z)}function Bt(M){let Z=M&&M.remote;return Z&&Z.nodeType===1?Z:null}function Et(M,Z,ee){let ue=M.tagName,oe=Bt(ee),fe=o.formState==="property"&&oe?oe:Z;if(ue==="INPUT"){let y=o.protectFocusedValue&&Qt(M),T=(M.getAttribute("type")||"").toLowerCase(),P=T!=="file"&&T!=="checkbox"&&T!=="radio",p=oe&&oe.hasAttribute("value")&&oe.value!==oe.getAttribute("value")?oe.value:null;if(P&&!y)if(o.formState==="property"){let k=Z.getAttribute("value"),R=M.getAttribute("value");(R!==k||M.value!==fe.value)&&z("value",M,k==null?"remove":"update")!==!1&&(R!==k&&(k==null?M.removeAttribute("value"):M.setAttribute("value",k),a.push({kind:"attr",el:M,name:"value",before:R,after:k})),M.value!==fe.value&&(M.value=fe.value))}else if(Z.hasAttribute("value")||p!=null){let k=p??Z.getAttribute("value");M.getAttribute("value")!==k&&z("value",M,"update")!==!1?(M.setAttribute("value",k),M.value!==k&&(M.value=k),a.push({kind:"attr",el:M,name:"value",before:null,after:k})):M.value!==k&&M.getAttribute("value")===k&&(M.value=k)}else(M.hasAttribute("value")||M.value!=="")&&z("value",M,"remove")!==!1&&(M.removeAttribute("value"),M.value="",a.push({kind:"attr",el:M,name:"value",before:"",after:null}));if(!P&&T!=="file"){let k=Z.getAttribute("value");k==null?M.hasAttribute("value")&&z("value",M,"remove")!==!1&&M.removeAttribute("value"):M.getAttribute("value")!==k&&z("value",M,"update")!==!1&&M.setAttribute("value",k)}y||(Lt(M,fe,"checked"),o.formState==="property"&&M.indeterminate!==fe.indeterminate&&(M.indeterminate=fe.indeterminate)),Lt(M,fe,"disabled")}else if(ue==="OPTION"){let y=M.parentNode&&M.closest("select");o.protectFocusedValue&&y&&Qt(y)||Lt(M,fe,"selected")}}function Lt(M,Z,ee){let ue=o.formState==="property"?!!Z[ee]:Z.hasAttribute(ee);if(o.formState!=="property"){let oe=M.hasAttribute(ee);if(oe!==ue){if(z(ee,M,ue?"update":"remove")===!1)return;ue?M.setAttribute(ee,""):M.removeAttribute(ee),a.push({kind:"attr",el:M,name:ee,before:oe?"":null,after:ue?"":null})}}M[ee]!==ue&&(M[ee]=ue)}function sn(M,Z,ee){if(o.protectFocusedValue&&Qt(M)||z("value",M,"update")===!1)return;let ue=Bt(ee),oe=Z.textContent,fe=ue&&ue.value!==ue.defaultValue?ue.value:oe;o.formState!=="property"&&M.textContent!==oe&&(a.push({kind:"text",node:M,before:M.textContent,after:oe}),M.textContent=oe),M.value!==fe&&(M.value=fe)}}function Vc(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 i=r.getRangeAt(0);o.range={sc:i.startContainer,so:i.startOffset,ec:i.endContainer,eo:i.endOffset}}return o}function Wc(e,t,n,o,r,i,c){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 a=(d,b)=>{let A=n.get(d);if(Array.isArray(A)){let S=A.find(x=>b>=x.from&&b<x.to)||A.find(x=>b===x.to)||A[A.length-1],L=i.get(S.merged);if(!L||!L.isConnected)return null;let f=o.get(S.merged),g=f&&f.flat?f.flat(S.flatStart+b):b;return[L,Math.max(0,Math.min(g,L.nodeValue.length))]}if(A&&!c.has(A.merged)){let S=(r.get(A.merged)||[d])[0];if(!S.isConnected)return null;let L=o.get(A.merged),f=A.shift+b,g=L?L(f):f;return[S,Math.max(0,Math.min(g,S.nodeValue.length))]}return d.isConnected?[d,Math.min(b,d.nodeType===3?d.nodeValue.length:d.childNodes.length)]:null},m=a(t.range.sc,t.range.so),h=a(t.range.ec,t.range.eo);if(!(!m||!h))try{let d=e.createRange();d.setStart(m[0],m[1]),d.setEnd(h[0],h[1]);let b=e.getSelection();b.removeAllRanges(),b.addRange(d)}catch{}}var $c={compared:0},qc=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Fc(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 Dr(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 Xs(e,t,n,o,r,i,c,s){let a=new Map,m=new Set,h=d=>{if(o(d))return;let b=n(d);b&&(i.add(b),r.has(b)||a.has(b)?m.add(b):a.set(b,d))};for(let d of e)h(d);h(t);for(let d of c||t.querySelectorAll("*"))h(d);for(let d of m)a.delete(d),s.add(d);return a}function Qs(e,t,n,o,r,i){let c=!1;for(let h of r)h.startsWith("merge:")&&(c=!0);if(!c)return[...o];let s=new Map,a=[],m=i===fn?So:"*";for(let h of[e,...e.querySelectorAll(m)]){if(n(h))continue;let d=t(h);if(!d||!(o.has(d)||r.has(d)))continue;let b=(s.get(d)||0)+1;s.set(d,b),b===2&&a.push(d)}return a}function Zs({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:o,o:r,identity:i,baseURI:c}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!Fc(e,t,r.ignoreAttribute))return{bail:"root-attrs"};let{ignored:s,remoteWins:a}=r,m=Pr(r.scripts.merge===!1?null:r.scripts.mergeTags,c),h=Se=>{let O=m(Se);return O!==null?O:i.base(Se)||null},d=Se=>{let O=m(Se);return O!==null?O:i.remote(Se)||null},b=[],A=[],S=new Map,L=new Map,f={same:S,differ:L},g=Se=>({bail:Se,comparisons:f}),x=(Se,O,B=!0)=>{if(S.get(Se)===O)return!0;if(L.get(Se)===O)return!1;if($c.compared++,B&&Se.isEqualNode(O))return S.set(Se,O),!0;let ae=Se.nodeType===O.nodeType;if(ae&&Se.nodeType===1){if(ae=Dr(Se,O),ae){let be=Se.firstChild,de=O.firstChild;for(;be&&de;be=be.nextSibling,de=de.nextSibling)if(!x(be,de,!1)){ae=!1;break}(be||de)&&(ae=!1)}}else ae&&(ae=Se.isEqualNode(O));return(ae?S:L).set(Se,O),ae},Q=e,se=t,le=!1,q=()=>{S.set(Q,se);for(let Se=0;Se<b.length;Se++)S.set(b[Se],A[Se]);return g("equal")};for(;;){let Se=Q.childNodes,O=se.childNodes;if(Se.length!==O.length)break;let B=st=>x(Se[st],O[st])?(S.set(Se[st],O[st]),!1):!0,ae=-1,be=-1;for(let st=0;st<Se.length;st++){if(Se[st].nodeType!==1)continue;let wt=0;for(let bt=Se[st].firstElementChild;bt;bt=bt.nextElementSibling)wt++;wt>=be&&(be=wt,ae=st)}let de=[],ze=!1;for(let st=0;st<Se.length&&de.length<2;st++)st!==ae&&B(st)&&de.push(st);if(ae>=0&&de.length<2&&(de.length===0&&Dr(Q,se)?(de.push(ae),ze=!0):B(ae)&&de.push(ae)),de.length!==1){if(!le&&de.length===0&&Dr(Q,se))return q();break}let De=Se[de[0]],Qe=O[de[0]];if(le=le||!ze,le&&L.set(De,Qe),De.nodeType!==1||Qe.nodeType!==1||De.tagName!==Qe.tagName)break;if(h(De)!==d(Qe)){if(!le&&x(De,Qe))return q();break}b.push(Q),A.push(se),Q=De,se=Qe}L.set(Q,se);for(let Se=0;Se<b.length;Se++)L.set(b[Se],A[Se]);if(Q===e||Q.tagName==="HEAD"||Q.tagName==="BODY")return g("root-level");if(b.length<2||b[1].tagName!=="BODY")return g("not-in-body");if(s(Q)||s(se))return g("ignored-ancestor");if(a(Q)||a(se))return g("remote-wins-ancestor");for(let Se of b)if(qc.has(Se.tagName))return g("form-ancestor");if(Q.tagName==="SCRIPT"||Q.getElementsByTagName("script").length||se.getElementsByTagName("script").length)return g("script-or-template");let z=o(Q);if(!z||z.nodeType!==1||z.tagName!==Q.tagName)return g("no-live-twin");if(!n.contains(z))return g("live-detached");for(let Se of b){let O=o(Se);if(!O||O.nodeType!==1)return g("ancestor-live")}let ce=i.base===fn&&i.remote===fn&&s===pr,xe=new Set,te=new Set,J=[],Ce=null,we=Se=>{Se&&(xe.has(Se)?te.add(Se):xe.add(Se))},ne=(Se,O)=>{let B=m(Se),ae=B!==null?B:i.base(Se)||null;return ae!==(B!==null?B:i.remote(O)||null)?!1:(we(ae),!0)},_=(Se,O)=>{for(let B=Se.firstElementChild,ae=O.firstElementChild;B;B=B.nextElementSibling,ae=ae.nextElementSibling){let be=s(B);if(be!==s(ae))return!1;if(!be&&(!ne(B,ae)||!_(B,ae)))return!1}return!0},ye=Se=>{let O=Se+1<b.length?b[Se+1]:Q;for(let B=b[Se].firstElementChild,ae=A[Se].firstElementChild;B;B=B.nextElementSibling,ae=ae.nextElementSibling){if(B===O){let ze=Se+1<b.length?ye(Se+1):null;if(ze)return ze;continue}let be=s(B);if(be!==s(ae))return"outside-id-changed";if(be)continue;let de=o(B);if(!de||de.nodeType!==1)return"sibling-live";if(J.push([B,ae]),!ce&&(!ne(B,ae)||!_(B,ae)))return"outside-id-changed";Se===0&&B.tagName==="HEAD"&&h(B)&&(Ce=[B,ae])}return null},ge=ye(0);if(ge)return g(ge);let Oe=new Set(b),Be=null;if(i.base===fn){Be=[];for(let Se of e.querySelectorAll(So))Se===Q||Oe.has(Se)||(Q.contains(Se)?Be.push(Se):ce&&we(h(Se)))}let We=new Set,rt=new Set,re=new Set,ut=Xs(b,Q,h,s,xe,We,Be,rt),dt=Xs(A,se,d,s,xe,We,i.remote===fn&&se.querySelectorAll(So),re);return Ce&&(te.has(h(Ce[0]))||We.has(h(Ce[0])))&&(Ce=null),{scope:{chain:b,root:Q,onChain:Oe,baseIndex:ut,remoteIndex:dt,head:Ce,same:S,differ:L,dropped:[...Qs(e,h,s,te,rt,i.base),...Qs(t,d,s,te,re,i.remote)],held:Se=>{for(let O=1;O<b.length;O++)if(Se.map.get(b[O])!==A[O])return!1;for(let[O,B]of J)if(Se.map.get(O)!==B)return!1;return!0}}}}var Ca=Symbol("hyper-morph-duplicate-key");var Kc='[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"]',zc='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Gc='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Yc(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 Jc(e,t,n,o){if(t==null)return;if(typeof t=="string")return t;let r=t;if(r.nodeType===9){let i=e.getAttribute("id");r=i&&r.getElementById(i)||(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=Xc(e,t,o)),!!r)return n?Array.from(r.childNodes):r}function Xc(e,t,n){let o=t.nodeType===9?t.documentElement:t;if(!o||o.nodeType!==1)return null;let r=new Map,i=[o,...o.querySelectorAll("script")];for(let a of i){let m=lo(a,n);m&&!r.has(m.key)&&r.set(m.key,a.textContent)}if(!r.size)return null;let c=e.cloneNode(!0),s=!1;for(let a of[c,...c.querySelectorAll("script")]){let m=lo(a,n);m&&r.has(m.key)&&(a.textContent=r.get(m.key),s=!0)}return s?c:null}function ei(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 i of r)n.body.appendChild(n.adoptNode(i));return n}function Hr(e,t,n={}){let o=n||{};if(!o.head?.block)return ti(e,t,o);try{return ti(e,t,o)}catch(r){return Promise.reject(r)}}function ti(e,t,n){let o=n.policy||"sync",r=o==="raw"?void 0:(a,m)=>Yc(a)||(o==="history"?!(m&&a.matches(Gc))&&a.matches(zc):a.matches(Kc)),i=n.callbacks||{},c={ignore:r,hooks:i,protectFocusedValue:n.ignoreActiveValue===!0?"subtree":!1,restoreFocus:n.restoreFocus!==!1,formState:n.formStateSync||"attribute",scripts:{execute:n.scripts?.handle!==!1,merge:n.scripts?.merge!==!1,mergeTags:n.scripts?.mergeTags||[]},head:{awaitLoads:!!n.head?.block,preserve:n.head?.shouldPreserve||(()=>!1)}};if(typeof n.key=="function"&&(c.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return No(Object.assign({},c,{live:e,base:n.scripts?.mergeBase||null,remote:ei(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let a=Object.assign({},c,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:ei(t,e.ownerDocument)});return No(a)}n.morphStyle==="innerHTML"&&(c.children=!0);let s=Jc(e,n.scripts?.mergeBase,!!c.children,c.scripts.mergeTags);return s!==void 0&&(c.base=s),Br(e,t,c)}var Qc=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),mn=()=>{};function Oo(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let c of Object.keys(e))if(!Qc.has(c))throw new TypeError(`unknown option "${c}"`);let n=Object.assign({beforeNodeAdded:mn,afterNodeAdded:mn,beforeNodeRemoved:mn,afterNodeRemoved:mn,beforeNodeMorphed:mn,afterNodeMorphed:mn,beforeAttributeUpdated:mn},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 i=e.protectFocusedValue;if(i!==void 0&&typeof i!="boolean"&&i!=="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:hr(e.ignore,t),remoteWins:hr(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:o,protectFocusedValue:i===void 0?!0:i,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}}function fo(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 fn}function uo(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=mr(t,e.map),o=typeof e.then=="function"?e.then:fn;if(typeof e.first=="function"){let r=e.first;return i=>r(i)||n.get(i)||o(i)}return r=>n.get(r)||o(r)}return fn}function Zc(e,t,n,o={}){let r=A=>A&&A.nodeType===9?A.documentElement:A,i=r(t),c=r(n),s=r(e)||i,a=Object.assign({},o);delete a.live,delete a.base,delete a.remote;let m=Oo(a,[s,i,c].filter(Boolean)),h=o.identity||{},d=jn(),b=er(s,i,c,{identity:{base:uo(h.base,s),local:uo(h.local,i),remote:uo(h.remote,c)},authored:{base:fo(h.base),local:fo(h.local),remote:fo(h.remote)},skipUnchanged:m.hooks.beforeNodeMorphed===mn&&m.hooks.afterNodeMorphed===mn,ignored:m.ignored,remoteWins:m.remoteWins,ignoreAttribute:m.ignoreAttribute,conflicts:m.conflicts,mergeTags:m.scripts.merge===!1?null:m.scripts.mergeTags,baseURI:i.ownerDocument&&i.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:m.children,stats:d});return delete b.recoveryLinks,b}function Ur({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:o,toLive:r,options:i,identity:c,childrenOnly:s,isDocument:a}){let m=Oo(i,[e,t,n,o].filter(Boolean));if(m.ignored(e))return{report:_r(),loads:[]};let h=e.ownerDocument,d=m.scripts.execute?Ls(e,m.ignored,h.baseURI):null,b=jn(),A=m.hooks.beforeNodeMorphed===mn&&m.hooks.afterNodeMorphed===mn,S={identity:{base:uo(c.base,t||n),local:uo(c.local,n),remote:uo(c.remote,o)},authored:{base:fo(c.base),local:fo(c.local),remote:fo(c.remote)},ignored:m.ignored,remoteWins:m.remoteWins,ignoreAttribute:m.ignoreAttribute,conflicts:m.conflicts,mergeTags:m.scripts.merge===!1?null:m.scripts.mergeTags,baseURI:h.baseURI,localIsBase:!t,childrenOnly:s,skipUnchanged:A},L=m.fastPath&&a&&!s&&A&&t===n,f=null,g=null;if(L){let we=Zs({baseRoot:t,remoteRoot:o,liveRoot:e,toLive:r,o:m,identity:S.identity,baseURI:h.baseURI});S.comparisons=we.comparisons||we.scope,we.bail?g=we.bail:(f=er(t,n,o,Object.assign({},S,{stats:b,scope:we.scope})),f||(g="chain-unpaired",b=jn()))}f||(f=er(t||n,n,o,Object.assign({},S,{stats:b}))),L&&(b.fastPathAttempted=1,b.fastPathTaken=g?0:1,b.fastPathFallback=g),f.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(we=>m.hooks[we]!==mn)&&Ws(f.conflicts,f.recoveryLinks,r),m.beforeApply&&m.beforeApply(f.doc);let x=globalThis.__hyperMorphProfile,Q=x?performance.now():0,se=Js(e,f.root,f,{toLive:r,ignored:m.ignored,ignoreAttribute:m.ignoreAttribute,formState:m.formState,protectFocusedValue:m.protectFocusedValue,restoreFocus:m.restoreFocus,preserve:m.head.preserve,hooks:m.hooks,childrenOnly:s,keepLiveOnly:m.keepLiveOnly});x&&(x.apply=(x.apply||0)+(performance.now()-Q));let le=[];if(m.head.awaitLoads)for(let we of se.applied){if(we.kind!=="insert"||we.node.nodeType!==1)continue;let ne=we.node;ne.tagName==="LINK"&&/\bstylesheet\b/i.test(ne.getAttribute("rel")||"")&&ne.getAttribute("href")&&ne.closest("head")&&le.push(new Promise(ye=>{ne.addEventListener("load",()=>ye()),ne.addEventListener("error",()=>ye())}))}let q=null,z=null;if(d){let we=Rs(e,d,{ignored:m.ignored,skip:se.mergedScriptsLive,baseURI:h.baseURI,beforeNodeAdded:m.hooks.beforeNodeAdded,afterNodeAdded:m.hooks.afterNodeAdded,trackRecovery:!!f.recoveryLinks});le.push(...we.loads),q=we.swapped,z=we.vetoed}let ce=we=>q&&q.get(we)||we,xe=we=>{if(se.keptRuns.has(we))return se.runOf.get(we);let ne=se.liveOf.get(we)||se.heldBy.get(we)||se.insertedLive.get(we);return ne?ce(ne):null},te=we=>{let ne=we&&se.liveOf.get(we);return ne?ce(ne):null},J=we=>{let ne=we&&xe(we);return Array.isArray(ne)?ne[0]:ne};if(f.recoveryLinks){let we=(ne,_,ye)=>(_.namespaceURI?ne.getAttributeNS(_.namespaceURI,_.localName):ne.getAttribute(_.qualifiedName))===ye;Fs(f.conflicts,f.recoveryLinks,{lookup:xe,vetoed:se.vetoed,vetoedAttrs:se.vetoedAttrs,removedVetoes:se.removedVetoes,vetoedLive:z,liveAttr:we,ignored:m.ignored,liveRoot:e})}return{report:{applied:se.applied,decisions:f.decisions.map(we=>Object.assign({},we,{node:we.node?te(we.node):null,el:we.el?te(we.el):null,applied:!!(we.node?te(we.node):we.el&&te(we.el))})),conflicts:f.conflicts.map(we=>Object.assign({},we,{node:we.node?we.kind==="text"&&we.recovery.subject.nodeType===8?J(we.node):te(we.node):we.node,el:we.el?we.kind==="structure"?J(we.el):te(we.el):we.el})),localDiverged:f.localDiverged,identities:se.identities,moved:se.moved,replaced:se.replaced,stats:b},loads:le}}var ni=new WeakMap;function _r(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:jn()}}function No(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let o=ni.get(n);o||(o=dr(n),ni.set(n,o));let r=o("remote",t.remote),i=typeof t.base=="string"&&t.base===""?null:t.base,c=i?o("base",i):null,s=t.local?t.local.root:n.documentElement,a=t.local?t.local.toLive:d=>d;gs(n,r);let{report:m,loads:h}=Ur({liveRoot:n.documentElement,baseRoot:c?c.documentElement:null,localRoot:s,remoteRoot:r.documentElement,toLive:a,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(h).then(()=>m)}function el(e,t,n={}){return No(Object.assign({},n,{live:e,base:null,remote:t}))}function oi(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 i=Ko(e,t),c=o[1].toLowerCase()==="html"?i.documentElement:i.body;return{root:c,first:c}}let r=t.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let o=t.createElement("template"),r=e.isConnected;return o.content.appendChild(r?t.importNode(e,!0):e),{root:o,first:e}}if(e.nodeType===11){let o=t.createElement("template");return o.content.appendChild(e),{root:o,first:o.content.firstElementChild}}let n=t.createElement("template");for(let o of Array.from(e))n.content.appendChild(o.parentNode?t.importNode(o,!0):o);return{root:n,first:n.content.firstElementChild}}function Br(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let o=e.ownerDocument,{base:r,...i}=n,c=!!i.children;if(Oo(i,[e]).ignored(e))return Promise.resolve(_r());let s=oi(t,o),a=r!=null?oi(r,o):null,m,h=null;if(c)m=s.root,h=a?a.root:null;else{if(m=s.first,h=a?a.first:null,!m){let A=Oo(i);return A.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),A.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:jn()})}if(m.tagName!==e.tagName){let A=Oo(i,[e,m]);if(A.hooks.beforeNodeMorphed(e,m)===!1)return Promise.resolve(_r());let S=Ur({liveRoot:e,baseRoot:h&&h.tagName===e.tagName?h:null,localRoot:e,remoteRoot:m,toLive:f=>f,options:i,identity:i.identity||{},childrenOnly:!0,isDocument:!1}),L=tn(m)?To(m,o):o.importNode(m,!1);if(!tn(L))for(;e.firstChild;)L.appendChild(e.firstChild);return A.hooks.beforeNodeAdded(L)===!1?(Zo(S.report.conflicts,e,e),Promise.resolve(S.report)):A.hooks.beforeNodeRemoved(e)===!1?(Zo(S.report.conflicts,e,e),Promise.resolve(S.report)):(e.replaceWith(L),Zo(S.report.conflicts,e,L),A.hooks.afterNodeRemoved(e),A.hooks.afterNodeAdded(L),A.hooks.afterNodeMorphed(e,m),S.report.replaced.push(L),S.report.applied.push({kind:"insert",node:L,parent:L.parentNode},{kind:"remove",node:e,parent:L.parentNode}),Promise.all(S.loads).then(()=>S.report))}}let{report:d,loads:b}=Ur({liveRoot:e,baseRoot:h,localRoot:e,remoteRoot:m,toLive:A=>A,options:i,identity:i.identity||{},childrenOnly:c,isDocument:!1});return Promise.all(b).then(()=>d)}var ri={mergeDocument:No,morphDocument:el,morphElement:Br,merge3:Zc,morph:Hr};function Vr(e,t,{onWidgetRemoved:n}={}){ri.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=qo.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var nl="hha:upgrade-check:";function Sn(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function Wr(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function si(e,t){let n=Wr(e),o=Wr(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let c=n[i]||0,s=o[i]||0;if(c!==s)return c>s}return!1}function ol(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function rl(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function $r({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(b=>fetch(b)),r=r??Date.now(),!t)return null;let c=Sn(t,"hyper-source");if(!c)return null;let s=Sn(t,"hyper-version"),a;try{a=new URL(c,n?n.href:void 0)}catch{return null}if(n&&a.origin===n.origin&&a.pathname===n.pathname)return null;let m=`${nl}${a.href}:${s||"none"}`,h,d=e?null:ol(m);if(d&&typeof d.checkedAt=="number"&&r-d.checkedAt<i)h=d.sourceVersion;else{try{let b=await o(a.href);if(!b.ok)throw new Error(`HTTP ${b.status}`);let A=await b.text(),S=new DOMParser().parseFromString(A,"text/html");h=Sn(S,"hyper-version")}catch{h=null}rl(m,{checkedAt:r,sourceVersion:h})}return h?{available:si(h,s||"0.0.0"),currentVersion:s,sourceVersion:h,sourceUrl:a.href}:null}var tr=["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"],qr=new Set(tr),ii=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Fr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var or={};cr(or,{EmptyListInsert:()=>Mo,MAX_RULE_DEPTH:()=>ho,MaxRuleDepthExceeded:()=>Yn,NoRulesTag:()=>Kr,RuleTargetReadOnly:()=>Eo,RulesParseError:()=>po,ShapeMismatch:()=>vo,UnknownRulesVersion:()=>Gn,WriteRefused:()=>nr,WriteRejected:()=>zr});var po=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},Gn=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},ho=20,Yn=class extends Error{constructor(t){super(`rule depth exceeded ${ho} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},vo=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},Mo=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}},Eo=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},nr=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}},Kr=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},zr=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 Nn(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 Gr(e,t,n,{depth:0,path:[]},o)}function Gr(e,t,n,o,r){if(o.depth>ho)throw new Yn(o.path);if(typeof n=="string")return sl(e,t,n,o,r);if(Array.isArray(n)){let[i,c]=n,s=e.find(t,i,r);return li(r,o,s),s.map((a,m)=>Gr(e,a,c,{depth:o.depth+1,path:[...o.path,m]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[c,s]of Object.entries(n))i[c]=Gr(e,t,s,{depth:o.depth+1,path:[...o.path,c]},r);return i}return null}function sl(e,t,n,o,r){if(n.endsWith("[]")){let s=n.slice(0,-2),a=e.find(t,s,r);return li(r,o,a),a.map(m=>e.text(m))}if(n.startsWith("@"))return ci(e,t,n.slice(1));let i=Mn(n);if(i!==-1){let s=n.slice(0,i),a=n.slice(i+1),m=s?e.find(t,s,r):[t];return m.length===0?null:ci(e,m[0],a)}if(n===".")return e.text(t);let c=e.find(t,n,r);return c.length===0?null:e.text(c[0])}function li(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 ci(e,t,n){if(qr.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}var ai=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"]})}),il=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),fi=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function Yr(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 cl(e,t){if(Yr(e,t))return!0;for(let[n,o]of Object.entries(il))if(o.includes(t)&&Yr(e,n))return!0;return!1}function Io(e){let t=ai[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function ll(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=ai[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>cl(n,r))||o.bundles.some(r=>Yr(n,r)))return n;n=n.parentElement}return null}function ui(e,t){return!!ll(e,t)}var al=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function di(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)t.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function pi(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 hi(e,t,n,o,r,i,c,s){if(e.nodeType===1&&((c?ui(e,n):pi(e,o,i,!1))||r&&(c&&e!==i?e.matches(r):pi(e,r,i,c))))return null;let a=t.importNode(e,!1);s.cloneToLive.set(a,e),s.liveToClone.set(e,a);let m=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,h=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;m!==e&&(s.cloneToLive.set(h,m),s.liveToClone.set(m,h));for(let d of m.childNodes||[]){let b=hi(d,t,n,o,r,i,c,s);b&&(h.appendChild(b),d.nodeType===1&&di(d,b))}return e.nodeType===1&&di(e,a),a}function Co(e,{capability:t="data",exclude:n=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=r.implementation.createHTMLDocument(""),c=new WeakMap,s=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let m=Io(t),h=hi(a,i,t,m,n,a,o,{cloneToLive:c,liveToClone:s});e.nodeType===9&&h&&(i.replaceChild(h,i.documentElement),s.set(e,i),c.set(i,e));let d=b=>{if(al.test(b))throw new Error(`Filtered content queries do not support stateful selector: ${b}`)};return{root:h,document:i,capability:t,selector:Io(t),cloneToLive:c,liveToClone:s,original(b){return c.get(b)||null},cloneOf(b){return s.get(b)||null},query(b,A=h){return d(b),Array.from(A.querySelectorAll(b),S=>c.get(S)||S)},text(b=h){return(b===h?h:s.get(b))?.textContent||""},html(b=h){return(b===h?h:s.get(b))?.innerHTML??""},clone(b=h){let A=b===h?h:s.get(b);return A?i.importNode(A,!0):null}}}function mi(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function fl(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var $t={semanticExclude:!0,find(e,t,n={}){let o=fl(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(s=>!mi(s)));let i=[];n.skip&&i.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&i.push("["+c+"]"),i.length){let s=i.join(", ");r=r.filter(a=>!a.closest||!a.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)},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 Jn(e,t={}){if(t.exclude===null)return $t;let n=[Io("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 $t;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,s=null,a=()=>s||(s=Co(i,{capability:"data",exclude:t.exclude||null})),m=S=>{let L=a();return S===e?L.cloneOf(e):L.cloneOf(S)||S},h=S=>s?.original(S)||S,d=(S,L)=>{a().liveToClone.set(S,L),a().cloneToLive.set(L,S);let f=S.childNodes||[],g=L.childNodes||[];for(let x=0;x<Math.min(f.length,g.length);x++)d(f[x],g[x])},b=(S,L,f,g)=>{let x=Array.from(S.childNodes).filter(z=>s.cloneOf(z)),se=x[0];for(;se&&x.includes(se);)se=se.nextSibling;for(let z of x)z.remove();if(f==="innerHTML"){let z=c.createElement("template");z.innerHTML=g;for(let ce of Array.from(z.content.childNodes))S.insertBefore(ce,se||null)}else S.insertBefore(c.createTextNode(g),se||null);let le=Co(S,{capability:"data",exclude:t.exclude||null});L.replaceChildren(...Array.from(le.root?.childNodes||[]));let q=z=>{let ce=le.original(z);ce&&(s.liveToClone.set(ce,z),s.cloneToLive.set(z,ce));for(let xe of Array.from(z.childNodes||[]))q(xe)};for(let z of Array.from(L.childNodes))q(z)},A={...$t,find(S,L,f={}){let g=m(S);if(!g?.querySelectorAll)return[];let x=a().query(L,g);f.includeRulesTag||(x=x.filter(le=>!mi(le)));let Q=[];f.skip&&Q.push(f.skip);let se=f.templateAttr===null?null:f.templateAttr||"cms-template";if(se&&Q.push(`[${se}]`),Q.length){let le=Q.join(", ");x=x.filter(q=>!q.closest?.(le))}return x},parent(S){let L=m(S)?.parentElement;return L?h(L):null},children(S){return Array.from(m(S)?.children||[],h)},text(S,L){if(L===void 0){let x=h(S);return!x?.matches?.(n)&&!x?.querySelector?.(n)?$t.text(x):(m(S)?.textContent||"").trim()}let f=h(S);if(!f?.matches?.(n)&&!f?.querySelector?.(n)&&!s){$t.text(f,L);return}let g=a().cloneOf(f);g?b(f,g,"textContent",L):$t.text(f,L)},attr(S,L,f){let g=h(S);if(f===void 0)return $t.attr(g,L);$t.attr(g,L,f);let x=s?.cloneOf(g);x&&($t.attr(x,L,f),Co(g,{capability:"data",exclude:t.exclude||null}).root===null&&(x.remove(),s.liveToClone.delete(g),s.cloneToLive.delete(x)))},removeAttr(S,L){let f=h(S);$t.removeAttr(f,L);let g=s?.cloneOf(f);g&&$t.removeAttr(g,L)},prop(S,L,f){let g=h(S);if(f===void 0)return L==="innerHTML"||L==="outerHTML"||L==="textContent"||L==="innerText"?$t.prop(m(g),L):$t.prop(g,L);let x=L==="innerHTML"||L==="textContent"||L==="innerText",Q=x?a().cloneOf(g):s?.cloneOf(g);Q&&x?b(g,Q,L,f):($t.prop(g,L,f),Q&&$t.prop(Q,L,f))},clone(S){let L=m(S);return L===S?$t.clone(S):c.importNode(L,!0)},insertAt(S,L,f){let g=h(S),Q=A.children(g)[f]||(()=>{for(let q=g.children.length-1;q>=0;q--){let z=g.children[q];if(a().cloneOf(z))return z.nextElementSibling}return g.firstElementChild})(),se=h(L);g.insertBefore(se,Q||null);let le=a().cloneOf(g);if(le){let q=a().cloneOf(se);q||(q=c.importNode(se,!0),d(se,q));let z=Array.from(le.children);le.insertBefore(q,z[f]||null)}},remove(S){let L=h(S),f=a().cloneOf(L);$t.remove(L),f&&$t.remove(f)},replaceWith(S,L){let f=h(S),g=a().cloneOf(f),x=$t.replaceWith(f,L);if(g){let Q=Co(x,{capability:"data",exclude:t.exclude||null});if(!Q.root)g.remove();else{g.replaceWith(Q.root);let se=le=>{let q=Q.original(le);q&&(s.liveToClone.set(q,le),s.cloneToLive.set(le,q));for(let z of Array.from(le.childNodes||[]))se(z)};se(Q.root)}}return x}};return A}var gn=$t;function Jr(e){try{return JSON.parse(e)}catch(t){throw new po(`Invalid strict JSON: ${t.message}`,t)}}function Xn(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 i=[],c=0;for(;c<r.length;){let s=r[c];if(/\s/.test(s)){c++;continue}if("{}".includes(s)){i.push({type:s,value:s}),c++;continue}if(s==="["){let d=!1,b=c+1;for(;b<r.length&&/\s/.test(r[b]);)b++;if(b<r.length&&/[a-zA-Z_]/.test(r[b])&&(d=!0),!d){i.push({type:s,value:s}),c++;continue}}if(s==="]"){i.push({type:s,value:s}),c++;continue}if(s===":"){i.push({type:t.COLON,value:s}),c++;continue}if(s===","){i.push({type:t.COMMA,value:s}),c++;continue}if(s==='"'||s==="'"){let d=s,b=c+1;for(;b<r.length&&r[b]!==d;)r[b]==="\\"&&b++,b++;i.push({type:t.STRING,value:r.substring(c+1,b),quoted:!0,sourceQuote:d}),c=b+1;continue}let a=c,m;for(;a<r.length&&!/[{},]/.test(r[a]);)if(r[a]===":"){let d=[":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"],b=!1;for(let A of d){let S=A.substring(1);if(r.substring(a+1,a+1+S.length)===S){b=!0,a+=S.length;break}}if(!b)break}else if(r[a]==="["){for(a++;a<r.length&&r[a]!=="]";){if(r[a]==='"'||r[a]==="'"){let d=r[a];for(a++;a<r.length&&r[a]!==d;)r[a]==="\\"&&a++,a++}a++}a<r.length&&r[a]==="]"&&a++}else a++;m=r.substring(c,a);let h=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(m)?h=t.NUMBER:m==="true"||m==="false"||m==="null"?h=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(m)&&(h=t.SELECTOR),i.push({type:h,value:m,quoted:!1}),c=a}return i}function o(r){let i="";for(let c=0;c<r.length;c++){let s=r[c];if("{}".includes(s.type)||"[]".includes(s.type)){i+=s.value;continue}if(s.type===t.COLON){i+=s.value;continue}if(s.type===t.COMMA){let a=r[c+1];if(a&&(a.type==="}"||a.type==="]"))continue;i+=s.value;continue}if(s.type===t.STRING&&s.quoted){let a=s.value;s.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(m,h)=>h.length%2===0?h+'\\"':m)),i+=`"${a}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){i+=s.value;continue}if(s.type===t.SELECTOR||s.type===t.IDENTIFIER){i+=`"${s.value}"`;continue}i+=`"${s.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new po("Invalid extraction rules syntax: "+r.message,r)}}var Xr="1",gi=/^[a-zA-Z0-9_-]+$/;function mo(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!gi.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${gi})`);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 i=r[0],c=e.attr(i,"data-rules-version");if(c!==Xr)throw new Gn(c);return{rules:Xn(e.text(i)),tagNode:i}}var ul="script[data-rules-name]";function bi(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function Lo(e,t){let n=e.find(t,ul,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let c=bi(e.attr(i,"data-rules-name"));if(!c)continue;if(o.has(c)){console.warn(`hyper-html-api: duplicate rules tag name "${c}"; using the first.`);continue}let s=e.attr(i,"data-rules-version");if(s!==Xr)throw new Gn(s);o.add(c),r.push({name:c,rules:Xn(e.text(i))})}return r}function rr(e,t){let n={};for(let{name:o,rules:r}of Lo(e,t))n[o]=Nn(e,t,r);return n}function Qr(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:rr(gn,t),version:Sn(n,"hyper-version")}}var go=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},Ro=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}},Un=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},Po=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 yi="text/hyper-upgrade";function Zr(e,t){let n=e.find(t,`script[type="${yi}"]`);if(n.length===0)return null;if(n.length>1)throw new Po(n.length);return e.text(n[0])||null}var dl=new Function("url","return import(url)");async function es(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await dl(n)}catch(r){throw new Un(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new Un("transform must `export default` a function");return o.default}function xi(e,t,n,o){let r=e.length,i=t.length,c=new Array(r).fill(-1);if(o){let f=new Set;for(let g=0;g<r;g++){let x=o[g];!(x>=0&&x<i)||f.has(x)||(c[g]=x,f.add(x))}}if(r===0||i===0)return c;let s=e.map(f=>ki(f,n)),a=t.map(f=>ki(f,n)),m=new Array(i).fill(!1);for(let f of c)f>=0&&(m[f]=!0);let h=new Map;a.forEach((f,g)=>{m[g]||h.set(f,h.has(f)?-1:g)});let d=new Map;s.forEach((f,g)=>{c[g]>=0||d.set(f,(d.get(f)||0)+1)}),s.forEach((f,g)=>{if(c[g]>=0||d.get(f)!==1)return;let x=h.get(f);x===void 0||x===-1||m[x]||(c[g]=x,m[x]=!0)});let b=[];for(let f=0;f<r;f++)c[f]<0&&b.push(f);let A=[];for(let f=0;f<i;f++)m[f]||A.push(f);if(b.length===0||A.length===0)return c;let S=r*i+1,L=(f,g)=>pl(e[f],t[g],n)*S+Math.abs(f-g);for(let[f,g]of hl(b,A,L))c[f]=g;return c}var Ti=e=>typeof e=="object"&&e!==null;function ki(e,t){if(!Ti(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 pl(e,t,n){if(!Ti(n))return e===t?0:1;let o=Object.keys(n);if(o.length===0)return 0;let r=0;for(let i of o){let c=JSON.stringify(e?.[i]),s=JSON.stringify(t?.[i]);c!==s&&r++}return r}function hl(e,t,n){return e.length<=t.length?wi(e,t,n,!1):wi(t,e,(o,r)=>n(r,o),!0)}function wi(e,t,n,o){let r=e.length,i=t.length,c=[];for(let d=0;d<=r;d++)c.push(new Float64Array(i+1).fill(1/0));let s=[];for(let d=0;d<=r;d++)s.push(new Uint8Array(i+1));for(let d=0;d<=i;d++)c[r][d]=0;for(let d=r-1;d>=0;d--)for(let b=i-1;b>=0;b--){let A=n(e[d],t[b])+c[d+1][b+1],S=c[d][b+1];A<=S?(c[d][b]=A,s[d][b]=1):c[d][b]=S}let a=[],m=0,h=0;for(;m<r&&h<i;)s[m][h]&&(a.push(o?[t[h],e[m]]:[e[m],t[h]]),m++),h++;return a}function ns(e,t,n,o,r,i,c,s={}){let a=e.find(t,n,s);if(r.length===0){a.forEach(le=>e.remove(le)),ts(s,"onRowsApplied",i.path,[]);return}let m=r.length>a.length,h=a[0]||null;if(m&&!h&&(h=yl(e,t,n,s),!h))throw new Mo(i.path);let d=a.map(le=>bl(e,le,o,s)),b=null;if(m&&h){b=e.clone(h),s.templateAttr&&e.removeAttr(b,s.templateAttr);let le=e.stripIds(b);le>0&&console.warn(`[hyper-html-api] stripped ${le} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let A=xi(r,d,o,ml(e,a,r,i,s)),S=a[0]||h,L=e.parent(S),f=a.length>0?Ai(e,L,S):0,g=kl(e,a),x=new Set,Q=[],se=r.map((le,q)=>{let z=A[q];if(z>=0)return x.add(z),Q.push(!1),a[z];Q.push(!0);let ce=e.clone(b);return e.stripIds(ce),ce});a.forEach((le,q)=>{x.has(q)||e.remove(le)}),g?se.forEach((le,q)=>{let z=f+q;e.children(L).findIndex(te=>e.sameNode(te,le))!==z&&e.insertAt(L,le,z)}):wl(e,se,Q,L,f),gl(e,se,o,r,i,c,s),ts(s,"onRowsApplied",i.path,se)}function ts(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 ml(e,t,n,o,r){let i=ts(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let c=new Array(n.length).fill(-1),s=new Set;for(let a=0;a<n.length;a++)if(i[a]){for(let m=0;m<t.length;m++)if(!(s.has(m)||!e.sameNode(t[m],i[a]))){c[a]=m,s.add(m);break}}return c}function gl(e,t,n,o,r,i,c){t.forEach((s,a)=>{if(n===null){let m=o[a],h=m==null?"":String(m);e.text(s)!==h&&e.text(s,h)}else{let m=i(e,s,n,o[a],{depth:r.depth+1,path:[...r.path,a]},c);m&&m!==s&&(t[a]=m)}})}function bl(e,t,n,o){return n===null?e.text(t):Nn(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Ai(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 yl(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let i=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let c of i)if(e.attr(c,o.templateAttr)!=null)return c;r=e.parent(r)}return null}function kl(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=e.children(n),r=[];for(let i of t){let c=o.findIndex(s=>e.sameNode(s,i));if(c===-1)return!1;r.push(c)}return r.sort((i,c)=>i-c),r[r.length-1]-r[0]===r.length-1}function wl(e,t,n,o,r){let i=null,c=r;for(let s=0;s<t.length;s++){if(!n[s]){i=t[s];continue}let a=i?e.parent(i):o;if(!a)continue;let m=i?Ai(e,a,i)+1:c++;e.insertAt(a,t[s],m),i=t[s]}}var Si=new Set(["checked","selected","disabled","readOnly","paused"]);function _n(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 i=[];if(os(n,o,[],i),i.length)throw new vo(i);sr(e,t,n,o,{depth:0,path:[]},r)}function sr(e,t,n,o,r,i={}){if(r.depth>ho)throw new Yn(r.path);if(o===void 0)return t;if(typeof n=="string")return xl(e,t,n,o,r,i);if(Array.isArray(n)){let[c,s]=n;return ns(e,t,c,s,o,r,sr,i),t}if(typeof n=="object"&&n!==null){for(let[c,s]of Object.entries(n)){let a=sr(e,t,s,o==null?o:o[c],{depth:r.depth+1,path:[...r.path,c]},i);a&&a!==t&&(t=a)}return t}return t}function xl(e,t,n,o,r,i){if(n.endsWith("[]")){let a=n.slice(0,-2);return ns(e,t,a,null,o,r,sr,i),t}if(n.startsWith("@"))return Oi(e,t,n.slice(1),o);let c=Mn(n);if(c!==-1){let a=n.slice(0,c),m=n.slice(c+1),h=a?e.find(t,a,i):[t];return h.length===0||Oi(e,h[0],m,o),t}if(n===".")return Ni(e,t,o),t;let s=e.find(t,n,i);return s.length===0||Ni(e,s[0],o),t}function Ni(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Oi(e,t,n,o){if(Fr.has(n)){let i=e.prop(t,n);if(i===o||i!=null&&o!=null&&String(i)===String(o))return t;throw new Eo(n)}if(n==="outerHTML"){let i=o==null?"":String(o);return e.replaceWith(t,i)}if(ii.has(n)){let i=Tl(n,o);return e.prop(t,n)!==i&&e.prop(t,n,i),t}let r=o==null?"":String(o);return e.attr(t,n)!==r&&e.attr(t,n,r),t}function Tl(e,t){return t==null?Si.has(e)?!1:"":Si.has(e)?t==="false"?!1:!!t:t}function os(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:Do([...n,i]),expected:"scalar",got:jo(r)})}):o.push({path:Do(n),expected:"array",got:jo(t)});return}t!==null&&typeof t=="object"&&o.push({path:Do(n),expected:"scalar",got:jo(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:Do(n),expected:"array",got:jo(t)});return}let r=e[1];t.forEach((i,c)=>os(r,i,[...n,c],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:Do(n),expected:"object",got:jo(t)});return}for(let[r,i]of Object.entries(e))os(i,t[r],[...n,r],o)}}}function jo(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Do(e){return e.join(".")}function Ho(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=rs(t,e,n);return ss(t,e,n),{data:o,summary:n}}function rs(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=>rs(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,i]of Object.entries(e)){let c=rs(i,t?.[r],n);c!==void 0&&(o[r]=c)}return o}}function ss(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)?ss(e[r],t[r],n):n.discarded+=Qn(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>ss(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=Qn(t))}}function Qn(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+Qn(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+Qn(n),0):1}function is(e,t,n){let o=Lo(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},c=new Set;for(let{name:s,rules:a}of o){if(c.add(s),!Object.prototype.hasOwnProperty.call(n,s)){i[s]={carriedOver:0,discarded:0,listItems:0};continue}let{data:m,summary:h}=Ho(n[s],a);_n(e,t,a,m),i[s]=h,r.carriedOver+=h.carriedOver,r.discarded+=h.discarded,r.listItems+=h.listItems}for(let s of Object.keys(n))c.has(s)||(r.discarded+=Qn(n[s]));return{totals:r,byName:i,rulesTagCount:o.length}}async function cs({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(g=>fetch(g)),!o)throw new Error("upgrade.run requires a document context");if(e=e||Sn(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let c=new URL(e,r?r.href:void 0);n=n!==void 0?n:Sn(o,"hyper-version"),t=t||rr(gn,o);let s;try{s=await i(c.href)}catch(g){throw new go(c.href,g)}if(!s.ok)throw new go(c.href,new Error(`HTTP ${s.status}`));let a=await s.text(),m=new DOMParser().parseFromString(a,"text/html"),h=Sn(m,"hyper-version"),d=t,b=!1,A=Zr(gn,m);if(A){let x=await(await es(A))(d,{fromVersion:n,toVersion:h});if(!x||typeof x!="object"||Array.isArray(x))throw new Un("transform must return a plain object map of { rulesName: data }");d=x,b=!0}let{totals:S,byName:L,rulesTagCount:f}=is(gn,m,d);if(f===0&&Object.keys(d).length>0)throw new Ro(c.href);return{html:Al(m),fromVersion:n,toVersion:h,summary:{transformApplied:b,totals:S,byName:L}}}function Al(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
6
|
-
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function Kc(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,""")}"`;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&<.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&ℜ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);})();
|