@panphora/clayjs 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clay.standalone.js +6278 -5396
- package/package.json +2 -1
- package/src/core/etag.js +67 -3
- package/src/core/host-attrs.js +14 -0
- package/src/core/save.js +13 -5
- package/src/lib/root-attrs.js +14 -0
- package/src/plugins/ai-edit.js +307 -89
- package/src/sync/conflict-footprints.js +272 -35
- package/src/sync/conflict-revert.js +18 -8
- package/src/sync/conflicts.js +2 -0
- package/src/sync/live-sync.js +328 -37
- package/src/sync/stream.js +17 -4
- package/src/vendor/hyper-morph.vendor.js +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var HyperMorph=(()=>{var Go=Object.defineProperty;var _r=Object.getOwnPropertyDescriptor;var qr=Object.getOwnPropertyNames;var zr=Object.prototype.hasOwnProperty;var $r=(e,o)=>{for(var t in o)Go(e,t,{get:o[t],enumerable:!0})},Gr=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of qr(o))!zr.call(e,s)&&s!==t&&Go(e,s,{get:()=>o[s],enumerable:!(n=_r(o,s))||n.enumerable});return e};var Yr=e=>Gr(Go({},"__esModule",{value:!0}),e);var ul={};$r(ul,{createIdentityStore:()=>Is,createParseCache:()=>Io,default:()=>fl,diff:()=>Fn,findChangedRoots:()=>Er,importMap:()=>Co,merge3:()=>Dr,merge3Text:()=>no,mergeDocument:()=>ho,mergeJson:()=>ms,mergeScriptText:()=>Vo,morph:()=>_o,morphDocument:()=>Ur,morphElement:()=>qo,parseJsonRelaxed:()=>Uo,parseRulesRelaxed:()=>nr,spliceProtected:()=>Lr,tieredIdentity:()=>Jo});function Oo(e,o){if(typeof e=="string"){let t=o&&o.defaultView,n=t&&t.DOMParser||globalThis.DOMParser;return new n().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Io(e){let o=new Map;return(t,n)=>{if(typeof n!="string")return Oo(n,e);let s=o.get(t);if(s&&s.text===n)return s.doc;let d=Oo(n,e);return o.set(t,{text:n,doc:d}),d}}function Os(e,o){let t=o.doctype;if(!t)return!1;let n=e.doctype;if(n&&n.name===t.name&&n.publicId===t.publicId&&n.systemId===t.systemId)return!1;let s=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return n?e.replaceChild(s,n):e.insertBefore(s,e.documentElement),!0}var Yo=()=>!1;function Xo(e,o=[]){if(typeof e!="function")return Yo;let t=new WeakMap,n=new Set(o);return s=>{if(!s||s.nodeType!==1)return!1;let d=t.get(s);if(d!==void 0)return d;let l=[],r=s,i=!1;for(;r&&r.nodeType===1;){let u=t.get(r);if(u!==void 0){i=u;break}if(l.push(r),e(r,n.has(r))){i=!0;break}if(n.has(r))break;r=r.parentElement}for(let u of l)t.set(u,i);return i}}var ml=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 Wn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Is(e){let o=new WeakMap,t=0,n=r=>o.get(r)||null,s=r=>{let i=o.get(r);return i||(i=`${e}:${++t}`,o.set(r,i)),i};return{idOf:n,ensure:s,adopt:(r,i)=>{r&&typeof i=="string"&&i&&o.set(r,i)},exportMap:(r,i)=>{let u={},w=[],c=[],h=(p,y)=>{let C=i(p);C&&(u[y]=s(C));let g=p.children;w.push(g.length),c.push(p.tagName.toLowerCase());for(let f=0;f<g.length;f++)h(g[f],y===""?String(f):`${y}.${f}`)};return h(r,""),u["~"]=w.join(","),u["^"]=c.join(","),u}}}function Co(e,o){let t=new WeakMap;if(!e||!o||typeof o!="object"||Array.isArray(o))return t;let n=o["~"],s=typeof n=="string"?n.split(",").map(Number):null,d=s&&typeof o["^"]=="string"?o["^"].split(","):null,l=c=>Number.isInteger(c)&&c>=0,r=0,i=!1,u=c=>{let h=c;for(;h>0;){let p=s[r++];if(r>s.length||!l(p))return!1;h+=p-1}return!0},w=(c,h)=>{if(i)return;if(s){let C=r++,g=s[C];if(C>=s.length||!l(g)){i=!0;return}let f=!d||d[C]===c.tagName.toLowerCase();if(!f||g!==c.children.length){let m=f&&o[h];typeof m=="string"&&m&&t.set(c,m),u(g)||(i=!0);return}}let p=o[h];typeof p=="string"&&p&&t.set(c,p);let y=c.children;for(let C=0;C<y.length;C++)w(y[C],h===""?String(C):`${h}.${C}`)};return w(e,""),t}function Jo(e){return o=>{for(let t of e){let n=t(o);if(typeof n=="string"&&n!=="")return n}return null}}var gn=Jo([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Eo(e,o,t,n=null,s=null){let d=new Map,l=new Set,r=i=>{if(t(i))return;let u=o(i);u&&(d.has(u)?l.add(u):d.set(u,i))};if(n){let i=u=>{for(let w of u.querySelectorAll(n))r(w);for(let w of u.querySelectorAll("template"))w.content&&i(w.content)};r(e),i(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let i=u=>{r(u);let w=u.tagName==="TEMPLATE"&&u.content?u.content.children:u.children;for(let c=0;c<w.length;c++)i(w[c])};i(e)}for(let i of l)d.delete(i),s&&s.add(i),Qo(i);return d}function Qo(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var Xr=new Set(["href","src","name","type","role"]),Es=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function eo(e,o=5381){let t=o;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return t>>>0}function Cs(e){return e.replace(/\s+/g," ")}var Jr=0;function Ls({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,s=new WeakMap;function d(E){let P=E.attributes,v=P.length;if(v===0)return{all:"",sig:E.tagName+"|"};let N=[],L="",D=[];for(let B=0;B<v;B++){let M=P[B],x=M.name;o(E,x)||N.push(x+"="+M.value),x==="class"?L=M.value.indexOf(" ")<0?M.value:M.value.split(/\s+/).filter(Boolean).sort().join(" "):Xr.has(x)&&D.push(x+"="+M.value)}return N.length>1&&N.sort(),D.length>1&&D.sort(),{all:N.join(""),sig:E.tagName+"|"+L+(D.length?"|"+D.join("|"):"")}}function l(E){return E.nodeType===1&&E.tagName==="TEMPLATE"&&E.content?E.content.childNodes:E.childNodes}function r(E){let P=n.get(E);if(P)return P;if(E.nodeType===3)P={hash:"T"+eo(E.nodeValue),hint:Cs(E.nodeValue).slice(0,64),sig:null,tok:null};else if(E.nodeType===8)P={hash:"C"+eo(E.nodeValue),hint:"",sig:null,tok:null};else if(E.nodeType===1){let v=d(E),N=eo(E.tagName+""+v.all),L="";for(let D of u(E))if(D.nodeType===1){let B=r(D);N=eo(B.hash,N),L.length<64&&(L+=" "+B.hint)}else N=eo(w(D),N),D.kind==="text"&&L.length<64&&(L+=D.value.slice(0,64));P={hash:"E"+N,hint:Cs(L).trim().slice(0,64),sig:v.sig,tok:null}}else P={hash:"N"+E.nodeType,hint:"",sig:null,tok:null};return n.set(E,P),P}function i(E){if(!E.tok){E.tok=new Set;for(let P of E.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))P&&E.tok.add(P)}return E.tok}function u(E){let P=s.get(E);if(P)return P;P=[];let v=null,N=()=>{v&&(v.value=v.nodes.map(L=>L.nodeValue).join(""),P.push(v),v=null)};for(let L of l(E)){if(L.nodeType===3){v||(v={kind:"text",nodes:[],value:"",parent:E,hash:void 0}),v.nodes.push(L);continue}N(),L.nodeType===8?P.push({kind:"comment",nodes:[L],value:L.nodeValue,parent:E,hash:void 0}):L.nodeType===1&&!e(L)&&P.push(L)}return N(),s.set(E,P),P}function w(E){return E.nodeType===1?r(E).hash:(E.hash===void 0&&(E.hash=(E.kind==="text"?"T":"C")+eo(E.value)),E.hash)}function c(E,P){let v=i(r(E)),N=i(r(P));if(v.size===0&&N.size===0)return{coef:1,share:1};if(v.size===0||N.size===0)return null;let L=0;for(let D of v)N.has(D)&&L++;return{coef:L/Math.min(v.size,N.size),share:L/Math.max(v.size,N.size)}}function h(E,P){let v=c(E,P);return!!v&&v.coef>=.5}let p=new WeakMap;function y(E){let P=p.get(E);if(P)return P;P=[];for(let v of E.attributes)o(E,v.name)||P.push([v.namespaceURI||"",v.localName,v.value]);return P.sort((v,N)=>v[0]<N[0]?-1:v[0]>N[0]?1:v[1]<N[1]?-1:v[1]>N[1]?1:0),p.set(E,P),P}let C=new WeakMap;function g(E,P){if(E===P)return!0;if(w(E)!==w(P))return!1;let v=C.get(E);if(v&&v.has(P))return v.get(P);let N=C.get(P);if(N&&N.has(E))return N.get(E);let L=f(E,P),D=L===!0;return L===!1&&t&&t.hashRejected++,v||C.set(E,v=new WeakMap),v.set(P,D),D}function f(E,P){if(E.nodeType===1){if(P.nodeType!==1||E.tagName!==P.tagName||E.namespaceURI!==P.namespaceURI)return!1;let v=y(E),N=y(P);if(v.length!==N.length)return!1;for(let B=0;B<v.length;B++)if(v[B][0]!==N[B][0]||v[B][1]!==N[B][1]||v[B][2]!==N[B][2])return!1;let L=u(E),D=u(P);if(L.length!==D.length)return!1;for(let B=0;B<L.length;B++){if(w(L[B])!==w(D[B]))return!1;if(!g(L[B],D[B]))return Jr}return!0}return P.nodeType===1?!1:E.kind===P.kind&&E.value===P.value}let m=new WeakMap,R=new Map,S=0;function O(E){let P=m.get(E);if(P)return P;let v=w(E),N=R.get(v);N||R.set(v,N=[]);let L=N.find(D=>g(D.unit,E));return P=L?L.key:"K"+S++,L||N.push({unit:E,key:P}),m.set(E,P),P}return{meta:r,unitsOf:u,unitHash:w,similar:h,score:c,childrenOf:l,equalUnits:g,exactUnitKey:O,ignored:e}}var Rs=16,Qr=2e3,Zr=3,Zo={align:0,certifyVisited:0,certifyScheduled:0};function es(e,o,t){let{meta:n,unitsOf:s,unitHash:d,similar:l,score:r,childrenOf:i,equalUnits:u,ignored:w}=t.analyzer,c=t.baseId||(()=>null),h=t.sideId||(()=>null),p=t.baseKey||(()=>null),y=t.sideKey||(()=>null),C=t.baseDropped||new Set,g=t.sideDropped||new Set,f=t.stats||null,m=f?new Set:null,R=f?new Set:null,S=new Map,O=new Map,E=new Set,P=new Map,v=new Set,N=new Set,L=new Set,D=[],B=[],M=[],x=[],k=Qr,z=new Map,U=new Map,K=(H,G)=>{S.set(H,G),O.set(G,H)},Ae=new Set,Me=new Set,Be=null,te=H=>{let G=H.nodeType?H.parentNode:H.parent;if(!G||G.nodeType!==11)return G;if(!Be){Be=new WeakMap;let de=pe=>{for(let ce of pe.querySelectorAll("template"))ce.content&&(Be.set(ce.content,ce),de(ce.content))};for(let pe of[e,o])de(pe.tagName==="TEMPLATE"&&pe.content?pe.content:pe)}return Be.get(G)||null},ve=(H,G)=>{for(let de=te(H);de&&!Ae.has(de);de=te(de))Ae.add(de);for(let de=te(G);de&&!Me.has(de);de=te(de))Me.add(de)},ze=H=>{for(let G=te(H);G;G=te(G))if(S.has(G))return N.has(G);return!1},re=H=>{for(let G=te(H);G;G=te(G)){let de=O.get(G);if(de!==void 0)return N.has(de)}return!1},b=H=>!!H&&H.nodeType===1,_=(H,G)=>{let de=P.get(H);return!!de&&de.has(G)},oe=H=>Es.has(H.tagName),ee=t.comparisons||t.scope,Pe=(H,G)=>{if(ee){if(ee.same.get(H)===G)return!0;if(ee.differ.get(H)===G)return!1}if(!H.isEqualNode(G))return!1;if(H.tagName==="TEMPLATE")return u(H,G);let de=H.getElementsByTagName("template");if(de.length===0)return!0;let pe=G.getElementsByTagName("template");if(de.length!==pe.length)return!1;for(let ce=0;ce<de.length;ce++)if(!u(de[ce],pe[ce]))return!1;return!0},Ke=(H,G)=>{let de=c(H);if(!de)return!0;let pe=h(G);return!pe||de===pe},Ne=H=>{let G=p(H);return G&&t.baseIndex.get(G)===H&&!g.has(G)?G:null},ot=H=>{let G=y(H);return G&&t.sideIndex.get(G)===H&&!C.has(G)?G:null},Qe=(H,G)=>{let de=Ne(H);if(!de)return!0;let pe=ot(G);return!pe||de===pe},Ze=globalThis.__hyperMorphProfile,Xe=Ze?performance.now():0;Ze&&!t.scope&&(n(e),n(o),Ze.meta=(Ze.meta||0)+(performance.now()-Xe),Xe=performance.now()),K(e,o);let wt=new Set;for(let[H,G]of t.baseIndex){let de=t.sideIndex.get(H);de&&de.tagName===G.tagName&&!S.has(G)&&!O.has(de)&&(K(G,de),ve(G,de),wt.add(G))}if(wt.size){let H=[];if(t.scope)for(let ce of t.scope.chain)wt.has(ce)&&H.push(ce);let G=[t.scope?t.scope.root:e];for(;G.length;){let ce=G.pop();wt.has(ce)&&H.push(ce);let xe=i(ce);for(let ne=xe.length-1;ne>=0;ne--)xe[ne].nodeType===1&&G.push(xe[ne])}let de=new Set;for(let ce=H.length-1;ce>=0;ce--){let xe=H[ce];t.scope&&t.scope.onChain.has(xe)?de.add(xe):le(xe,S.get(xe),de)?(N.add(xe),L.add(xe),f&&f.certificationPairs++):de.add(xe)}let pe=new Set;for(let ce of H)N.has(ce)&&!pe.has(ce)&&dt(ce,pe)}t.scope&&t.scope.head&&me(t.scope.head[0],t.scope.head[1]);function dt(H,G){let de=[H];for(;de.length;){let pe=de.pop();if(!G.has(pe)){G.add(pe),Y(pe);for(let ce of s(pe))b(ce)&&S.has(ce)&&de.push(ce)}}}x.push([e,o]);for(let[H,G]of S)b(H)&&H!==e&&x.push([H,G]);return Ht(),gt(),Ze&&(Ze.align=(Ze.align||0)+(performance.now()-Xe)),{map:S,reverse:O,moved:v,identical:N,pairIdenticalChildren:Y,weak:E,unpair:zt,rematch:gt,insertedByHash:_t,refused:R,identityPaired:wt};function gt(){be(),Ht();for(let H=0;H<M.length;){let G=M.length;Kt(H,G),H=G,Ht(),be(),Ht()}}function zt(H){let G=S.get(H);if(!G)return;P.has(H)||P.set(H,new Set),P.get(H).add(G);let de=(ce,xe)=>{S.delete(ce),O.delete(xe),v.delete(ce),N.delete(ce),E.delete(ce),L.delete(ce)},pe=(ce,xe)=>{for(let ne of s(ce)){let $=S.get(ne);!$||wt.has(ne)||!(b($)?xe.contains($):xe.contains($.nodes[0]))||(de(ne,$),b(ne)&&pe(ne,$))}};de(H,G),b(H)&&pe(H,G),D.push(H),B.push(G)}function _t(){let H=new Map;for(let G of new Set(B)){if(O.has(G))continue;let de=n(G).hash;H.has(de)||H.set(de,[]),H.get(de).push(G)}return H}function Ht(){for(;x.length;){let[H,G]=x.shift();S.get(H)!==G||L.has(H)||N.has(H)||an(H,G)}}function Bt(H,G){if(!oe(H))for(let de of s(H))b(de)&&(G.push(de),Bt(de,G))}function an(H,G){L.add(H);let de=s(H),pe=s(G);Zo.align+=de.length+pe.length,z=new Map,U=new Map;for(let fe=0;fe<de.length;fe++)z.set(de[fe],fe);for(let fe=0;fe<pe.length;fe++)U.set(pe[fe],fe);if(H.tagName==="HTML")for(let fe of["HEAD","BODY"]){let Ee=de.find(Ve=>b(Ve)&&Ve.tagName===fe),Re=pe.find(Ve=>b(Ve)&&Ve.tagName===fe);Ee&&Re&&!S.has(Ee)&&!O.has(Re)&&K(Ee,Re)}for(let fe=0;fe<de.length&&fe<pe.length;fe++){let Ee=de[fe],Re=pe[fe];S.has(Ee)||O.has(Re)||(b(Ee)?b(Re)&&Ee.tagName===Re.tagName&&Pe(Ee,Re)&&me(Ee,Re):!b(Re)&&Ee.kind===Re.kind&&Ee.value===Re.value&&me(Ee,Re))}Ce(de,pe);let ce=de.filter(fe=>!S.has(fe)),xe=pe.filter(fe=>!O.has(fe));ce.length&&xe.length&&(F(ce,xe),J(ce,xe),se(ce,xe,de,pe),Ie(de,pe));let ne=!1,$=!1;for(let fe of de){if(!S.has(fe)){b(fe)&&(D.push(fe),Bt(fe,D),ne=!0);continue}b(fe)&&!N.has(fe)&&x.push([fe,S.get(fe)])}for(let fe of pe)!O.has(fe)&&b(fe)&&(B.push(fe),Bt(fe,B),$=!0);ne&&$&&M.push([H,G])}function Kt(H,G){for(let de=H;de<G;de++){let[pe,ce]=M[de];if(S.get(pe)!==ce)continue;let xe=s(pe),ne=s(ce),$=new Map,fe=new Map,Ee=null;for(let Re of xe)b(Re)&&(S.has(Re)?Ee=Re:($.has(Ee)||$.set(Ee,[]),$.get(Ee).push(Re)));Ee=null;for(let Re of ne)b(Re)&&(O.has(Re)?Ee=O.get(Re):(fe.has(Ee)||fe.set(Ee,[]),fe.get(Ee).push(Re)));for(let[Re,Ve]of $){let Oe=fe.get(Re);if(!(!Oe||Ve.length!==Oe.length)&&Ve.every(($e,tt)=>Oe[tt].tagName===$e.tagName&&Ke($e,Oe[tt])&&!_($e,Oe[tt])))for(let $e=0;$e<Ve.length;$e++)$t(Ve[$e],Oe[$e])}}}function $t(H,G){K(H,G),E.add(H),x.push([H,G]),Ht()}function F(H,G){let de=to(H,d),pe=to(G,d),ce=new Map;for(let xe of G){let ne=d(xe);pe.get(ne)===1&&ce.set(ne,xe)}for(let xe of H){if(S.has(xe))continue;let ne=d(xe);if(de.get(ne)!==1)continue;let $=ce.get(ne);$&&!O.has($)&&u(xe,$)&&me(xe,$)}}function le(H,G,de){let pe=[[H,G]];for(;pe.length;){let[ce,xe]=pe.pop();if(Zo.certifyVisited++,f&&f.certificationVisited++,ce.nodeType!==xe.nodeType)return!1;if(ce.nodeType===3||ce.nodeType===8){if(ce.nodeValue!==xe.nodeValue)return!1;continue}if(ce.nodeType!==1){if(!ce.isEqualNode(xe))return!1;continue}if(ce.tagName!==xe.tagName||ce.namespaceURI!==xe.namespaceURI||w(ce)!==w(xe))return!1;let ne=ce.attributes,$=xe.attributes;if(ne.length!==$.length)return!1;for(let Oe=0;Oe<ne.length;Oe++){let $e=ne[Oe];if(xe.getAttributeNS($e.namespaceURI,$e.localName)!==$e.value)return!1}let fe=S.get(ce);if(fe!==void 0&&fe!==xe)return!1;let Ee=O.get(xe);if(Ee!==void 0&&Ee!==ce)return!1;if(ce!==H){if(N.has(ce))continue;if(de.has(ce))return!1}let Re=i(ce),Ve=i(xe);if(Re.length!==Ve.length)return!1;Zo.certifyScheduled+=Re.length;for(let Oe=Re.length-1;Oe>=0;Oe--)pe.push([Re[Oe],Ve[Oe]])}return!0}function ge(H,G){return!b(H)||!(Ae.has(H)||Me.has(G))?!0:!!A(H,G)||!(Ne(H)||ot(G))}function me(H,G){if(b(H)&&(Ae.has(H)||Me.has(G))){let de=A(H,G);if(!de){if(Ne(H)||ot(G))return;K(H,G),x.push([H,G]);return}for(let pe=0;pe<de.length;pe+=2){let ce=de[pe],xe=de[pe+1],ne=S.get(ce);ne!==void 0&&ne!==xe&&Te(ce,ne);let $=O.get(xe);$!==void 0&&$!==ce&&Te($,xe),S.get(ce)===xe&&(v.delete(ce),E.delete(ce),N.add(ce),L.add(ce))}}j(H,G)}function Te(H,G){S.delete(H),O.delete(G),v.delete(H),N.delete(H),E.delete(H),L.delete(H)}function A(H,G){let de=[H,G,!1],pe=[];for(;de.length;){let ce=de.pop(),xe=de.pop(),ne=de.pop(),$=S.get(ne),fe=O.get(xe);if(ne!==H&&($!==void 0&&$!==xe&&wt.has(ne)||fe!==void 0&&fe!==ne&&wt.has(fe)))return null;if(!($===xe&&N.has(ne))&&(($!==void 0||fe!==void 0)&&pe.push(ne,xe),!!b(ne))){if(ce||$!==void 0&&$!==xe||fe!==void 0&&fe!==ne){let Ee=s(ne),Re=s(xe);for(let Ve=0;Ve<Ee.length&&Ve<Re.length;Ve++)de.push(Ee[Ve],Re[Ve],!0)}else if(Ae.has(ne)||Me.has(xe)){let Ee=ne.tagName==="TEMPLATE"?ne.content:ne,Re=xe.tagName==="TEMPLATE"?xe.content:xe;for(let Ve=Ee.firstElementChild,Oe=Re.firstElementChild;Ve&&Oe;){if(w(Ve)){Ve=Ve.nextElementSibling;continue}if(w(Oe)){Oe=Oe.nextElementSibling;continue}(S.has(Ve)||O.has(Oe)||Ae.has(Ve)||Me.has(Oe))&&de.push(Ve,Oe,!1),Ve=Ve.nextElementSibling,Oe=Oe.nextElementSibling}}}}return pe}function j(H,G){K(H,G),N.add(H),b(H)&&L.add(H)}function Y(H){let G=S.get(H);if(!G||!b(H))return;let de=s(H),pe=s(G);for(let ce=0;ce<de.length&&ce<pe.length;ce++)S.has(de[ce])||j(de[ce],pe[ce])}function J(H,G){let de=ne=>b(ne)&&!oe(ne)?n(ne).sig+""+n(ne).hint:null,pe=to(H,de),ce=to(G,de),xe=new Map;for(let ne of G){let $=de(ne);$!=null&&ce.get($)===1&&xe.set($,ne)}for(let ne of H){if(S.has(ne))continue;let $=de(ne);if($==null||pe.get($)!==1)continue;let fe=xe.get($);fe&&!O.has(fe)&&Ke(ne,fe)&&K(ne,fe)}}function se(H,G,de,pe){let ce=new Map;for(let ne of G){if(!b(ne)||O.has(ne)||oe(ne))continue;let $=n(ne).sig;ce.has($)||ce.set($,[]),ce.get($).push({el:ne,index:U.get(ne)})}let xe=[];for(let ne of H){if(S.has(ne)||!b(ne)||oe(ne))continue;let $=ce.get(n(ne).sig);if(!$||!$.length)continue;let fe=z.get(ne),Ee=$.filter(Re=>!O.has(Re.el)).map(Re=>({c:Re,d:Math.abs(Re.index-fe)}));Ee.sort((Re,Ve)=>Re.d-Ve.d),Ee.length>Rs&&(Ee=Ee.slice(0,Rs));for(let{c:Re,d:Ve}of Ee){if(!Ke(ne,Re.el))continue;let Oe=r(ne,Re.el);Oe&&Oe.coef>=.5&&xe.push({b:ne,s:Re.el,coef:Oe.coef,share:Oe.share,d:Ve,bi:fe})}}if(xe.sort((ne,$)=>$.coef-ne.coef||$.share-ne.share||ne.d-$.d||ne.bi-$.bi),f&&xe.length>1){let ne=new Map;for(let $ of xe){let fe=ne.get($.b);fe?fe.coef===$.coef&&(fe.share===$.share?fe.strict++:fe.loose++):ne.set($.b,{coef:$.coef,share:$.share,strict:0,loose:0})}for(let[$,fe]of ne)m.has($)||!(fe.strict||fe.loose)||(m.add($),fe.strict?f.similarTiesStrict++:f.similarTiesLoose++)}for(let ne of xe)!S.has(ne.b)&&!O.has(ne.s)&&K(ne.b,ne.s)}function je(H,G){return b(H)!==b(G)?!1:b(H)?H.tagName!==G.tagName||!Ke(H,G)?!1:oe(H)||n(H).hint===""||n(G).hint===""?!0:l(H,G):H.kind===G.kind}function Z(H,G){let de=(ce,xe)=>{let ne=xe===null?-1:ce===G?U.get(xe):z.get(xe),$=ce[ne+1];return $&&!b($)?$:null},pe=null;for(let ce of H){if(b(ce)){pe=ce;continue}if(S.has(ce))continue;let xe=pe===null?null:S.get(pe);if(pe!==null&&!xe)continue;let ne=de(G,xe);ne&&!O.has(ne)&&ne.kind===ce.kind&&K(ce,ne)}}function Ie(H,G){Z(H,G);let de=He(H,G),pe=(xe,ne)=>b(xe)&&n(xe).hint!==""&&n(ne).hint===""&&!!ne.querySelector("br")&&!de(xe,ne),ce=0;for(let xe of H){if(S.has(xe)){let $=U.get(S.get(xe));$!==void 0&&$>=ce&&(ce=$+1);continue}let ne=0;for(let $=ce;$<G.length&&ne<Zr;$++){let fe=G[$];if(!O.has(fe)&&(ne++,je(xe,fe)&&!_(xe,fe)&&!pe(xe,fe))){K(xe,fe),b(xe)&&(n(xe).hint===""||n(fe).hint==="")&&E.add(xe),ce=$+1;break}}}Ce(H,G)}function He(H,G){let de=(pe,ce,xe)=>{for(let ne=ce-1;ne>=0;ne--)if(b(pe[ne])&&xe(pe[ne]))return pe[ne];return null};return(pe,ce)=>{let xe=z.get(pe),ne=U.get(ce);if(xe===ne)return!0;let $=de(H,xe,Ee=>S.has(Ee)),fe=de(G,ne,Ee=>O.has(Ee));return $?S.get($)===fe:!fe}}function Ce(H,G){let de=H.filter($=>b($)&&!S.has($)),pe=G.filter($=>b($)&&!O.has($));if(!de.length||!pe.length)return;let ce=to(de,$=>$.tagName),xe=to(pe,$=>$.tagName),ne=He(H,G);for(let $ of de){let fe=$.tagName;if(ce.get(fe)!==1||xe.get(fe)!==1)continue;let Ee=pe.find(Re=>Re.tagName===fe);Ee&&!O.has(Ee)&&ne($,Ee)&&Ke($,Ee)&&!_($,Ee)&&(u($,Ee)?me($,Ee):(K($,Ee),E.add($)))}}function be(){let H=new Map;for(let $ of E)if(b($)&&b(S.get($))){let fe=n($).hash;H.has(fe)||H.set(fe,[]),H.get(fe).push($)}if(H.size)for(let $ of B){if(O.has($)||!b($)||re($))continue;let fe=H.get(n($).hash),Ee=fe&&fe.find(Re=>E.has(Re)&&!_(Re,$)&&Ke(Re,$)&&Qe(Re,$)&&u(Re,$)&&ge(Re,$));Ee&&(zt(Ee),me(Ee,$),ve(Ee,$),v.add(Ee))}let G=new Map,de=new Map,pe=new Map;for(let $ of E){let fe=S.get($);b($)&&b(fe)&&pe.set(fe,$)}let ce=($,fe)=>{if(!O.has($))return!re($);let Ee=pe.get($);return Ee===O.get($)&&Ee!==fe&&!Ee.contains(fe)},xe=$=>{if(O.has($)){let fe=pe.get($);pe.delete($),zt(fe)}};for(let $ of[...B,...pe.keys()]){if(O.has($)&&!pe.has($))continue;let fe=n($).hash;if(G.has(fe)||G.set(fe,[]),G.get(fe).push($),oe($))continue;let Ee=n($).sig;de.has(Ee)||de.set(Ee,[]),de.get(Ee).push($)}let ne=new Set;for(let $ of E){let fe=S.get($);!b($)||!b(fe)||oe($)||n($).hint===""||n(fe).hint===""||l($,fe)||ne.add($)}for(let $ of[...D,...ne]){let fe=S.get($);if(fe?!(E.has($)&&ne.has($)):ze($))continue;let Ee=tt=>{fe&&zt($),xe(tt)},Re=G.get(n($).hash);if(Re){let tt=Re.find(T=>T!==fe&&ce(T,$)&&!_($,T)&&Qe($,T)&&u($,T)&&ge($,T));if(tt){Ee(tt),me($,tt),ve($,tt),v.add($);continue}}if(oe($)||k<=0)continue;let Ve=de.get(n($).sig);if(!Ve)continue;let Oe=null,$e=0;for(let tt of Ve)if(!(tt===fe||!ce(tt,$)||!Ke($,tt)||!Qe($,tt)||_($,tt))&&(k--<=0||l($,tt)&&($e++,Oe=tt,$e>1)))break;$e>1&&R&&R.add($),$e===1&&(Ee(Oe),K($,Oe),ve($,Oe),v.add($),x.push([$,Oe]))}}}function to(e,o){let t=new Map;for(let n of e){let s=o(n);s!=null&&t.set(s,(t.get(s)||0)+1)}return t}var ei={diff:0},Ps=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,ti=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,ni=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,oi=/\P{M}\p{M}*/gu;function si(e){if(e==="")return[];if(Ps){let t=[];for(let n of Ps.segment(e))t.push(n.segment);return t}let o=[];for(let t of e.match(ni))if(ti.test(t))for(let n of t.match(oi))o.push(n);else o.push(t);return o}var ri=/^[ ]+$/,ii=e=>ri.test(e)?" ".repeat(e.length):e,Kn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),yt="",ts=e=>e.every(o=>Kn(o)||o.k===yt),li=/^[\x00-\x7f\u00A0]*$/,ai=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function ci(e){return e===""?[]:e.match(ai)}function rn(e,o=!1){return(o?ci(e):si(e)).map(t=>({k:ii(t),raw:t,len:t.length}))}var bn=(...e)=>e.every(o=>li.test(o));function ns(e,o,t){let n=e.length,s=o.length,d=Math.min(n+s,t),l=d+1,r=new Int32Array(2*d+3),i=[],u=n===0&&s===0;for(let p=0;p<=d&&!u;p++){i.push(r.slice(l-p,l+p+1));for(let y=-p;y<=p;y+=2){let C;y===-p||y!==p&&r[l+y-1]<r[l+y+1]?C=r[l+y+1]:C=r[l+y-1]+1;let g=C-y,f=C;for(;C<n&&g<s&&e[C].k===o[g].k;)C++,g++;if(ei.diff+=1+C-f,r[l+y]=C,C>=n&&g>=s){u=!0;break}}}if(!u)return null;let w=[],c=n,h=s;for(let p=i.length-1;p>0;p--){let y=i[p],C=c-h,g=C+p,f=C===-p||C!==p&&y[g-1]<y[g+1]?C+1:C-1,m=y[f+p],R=m-f;for(;c>m&&h>R;)w.push([0,c-1,h-1]),c--,h--;c===m?(w.push([1,c,h-1]),h--):(w.push([-1,c-1,h]),c--)}for(;c>0&&h>0;)w.push([0,c-1,h-1]),c--,h--;return w.reverse(),w}function fi(e,o,t){let n=c=>c.k===yt;if(!e.some(n)&&!o.some(n))return ns(e,o,t);let s=[],d=[];for(let c=0;c<e.length;c++)n(e[c])||s.push(c);for(let c=0;c<o.length;c++)n(o[c])||d.push(c);let l=ns(s.map(c=>e[c]),d.map(c=>o[c]),t);if(!l)return null;let r=[],i=0,u=0,w=(c,h)=>{for(;i<c&&u<h&&e[i].k===o[u].k;)r.push([0,i++,u++]);let p=ns(e.slice(i,c),o.slice(u,h),t);if(!p)return!1;for(let[y,C,g]of p)r.push([y,C+i,g+u]);return i=c,u=h,!0};for(let[c,h,p]of l)if(c===0){if(!w(s[h],d[p]))return null;r.push([0,i,u]),i++,u++}return w(e.length,o.length)?r:null}function Un(e,o,t=4e3){let n=[],s=0;for(;s<e.length&&s<o.length&&e[s].k===o[s].k;)e[s].raw!==o[s].raw&&n.push({bi:s,tok:o[s]}),s++;let d=0;for(;d<e.length-s&&d<o.length-s&&e[e.length-1-d].k===o[o.length-1-d].k;)e[e.length-1-d].raw!==o[o.length-1-d].raw&&n.push({bi:e.length-1-d,tok:o[o.length-1-d]}),d++;let l=e.slice(s,e.length-d),r=o.slice(s,o.length-d),i=gi(l,r)?null:fi(l,r,t);if(!i){let f=l.length||r.length?[{bs:s,be:s+l.length,toks:r}]:[];return{hunks:f,cosmetic:n,coarse:!0,parts:f.map(m=>({...m,gap:[],group:0})),cosmeticEq:n}}let u=[],w=(f,m)=>{l[f].raw!==r[m].raw&&n.push({bi:s+f,tok:r[m]})},c=null,h=[],p=0,y=0,C=()=>{c&&u.push(c),c=null;for(let[f,m]of h)w(f,m);h=[],p++};for(let[f,m,R]of i){if(f===0){c&&Kn(l[m])&&!l[m].k.includes(`
|
|
2
|
-
`)?h.push([
|
|
3
|
-
`))return!1;let E=U=>t.slice(S,O).map((K,Ae)=>U.raw.get(S+Ae)||K),P=[...m.toks,...E(y)],v=[...E(g),...R.toks],N=(U,K,Ae)=>K>=0&&K+Ae.length<=U.length&&Ae.every((Me,Be)=>U[K+Be].k===Me.k),L=(U,K,Ae)=>ts(U)&&t.slice(K,Ae).some(Me=>!Kn(Me)),D=U=>U.some(K=>!Kn(K)),B,M,x,k;if(r(m)&&D(m.toks)&&N(v,0,m.toks)){let U=v.slice(m.toks.length);L(U,S,R.be)||(B=S,M=m.toks,x=v.slice(0,m.toks.length),k=[null,{bs:S,be:R.be,toks:U}])}if(B===void 0&&r(R)&&D(R.toks)){let U=P.length-R.toks.length,K=P.slice(0,U);N(P,U,R.toks)&&!L(K,m.bs,O)&&(B=O,M=P.slice(U),x=R.toks,k=[{bs:m.bs,be:O,toks:K},null])}if(B===void 0)return!1;let z=U=>U&&(U.bs<U.be||U.toks.length);return y.list.splice(C,1,...[k[0],{bs:B,be:B,toks:M}].filter(z)),g.list.splice(f,1,...[{bs:B,be:B,toks:x},k[1]].filter(z)),!0},h=l[0],p=l[1];for(let y=0;y<64;y++){let C=!1;e:for(let g=0;g<h.list.length;g++)for(let f=0;f<p.list.length;f++){let m=h.list[g],R=p.list[f];if(!(m.bs===R.bs&&m.be===R.be&&ls(m.toks,R.toks))){for(let S of[!0,!1]){let O=P=>S?P.be:P.bs,E=r(m)?[O(R),m.bs]:[O(m)];for(let P of E){let v=i(h,g,P,O),N=v&&i(p,f,P,O);if(!N)continue;let L=(k,z)=>S?k[k.length-1-z]:k[z],D=0;for(;D<v.length&&D<N.length&&L(v,D).k===L(N,D).k;)D++;if(!D)continue;let B=S?v.slice(0,v.length-D):v.slice(D),M=S?N.slice(0,N.length-D):N.slice(D);if(!(D<v.length&&D<N.length&&!ts(B)&&!ts(M)&&(r(m)&&r(R)||m.bs===R.bs&&m.be===R.be)||!(S?v.slice(v.length-D):v.slice(0,D)).some(k=>!Kn(k)))){if(D===v.length&&D===N.length&&r(m)&&r(R)){if(m.bs===P&&R.bs===P)continue;h.list[g]={bs:P,be:P,toks:v},p.list[f]={bs:P,be:P,toks:N}}else!r(m)&&m.bs===R.bs&&m.be===R.be?(w(h,g,v,D,S),w(p,f,N,D,S)):(u(h,g,v,D,S,P),u(p,f,N,D,S,P));C=!0;break e}}}if(c(h,g,p,f)||c(p,f,h,g)){C=!0;break e}}}if(!C)break}return[h.list,p.list]}var pi=48,mi=.3;function gi(e,o){let t=e.filter(l=>!Kn(l)),n=o.filter(l=>!Kn(l));if(Math.min(t.length,n.length)<pi)return!1;let s=new Map;for(let l of t)s.set(l.k,(s.get(l.k)||0)+1);let d=0;for(let l of n){let r=s.get(l.k);r>0&&(d++,s.set(l.k,r-1))}return d/Math.min(t.length,n.length)<mi}var bi=(e,o)=>{let t=new Set;for(let n of e.toks)typeof n.k!="string"&&t.add(n.k.el);for(let n=e.bs;n<e.be;n++)typeof o[n].k!="string"&&t.add(o[n].k.el);return t},ls=(e,o)=>e.length===o.length&&e.every((t,n)=>t.k===o[n].k);function Bs(e,o,t,n="remote"){let s=Un(e,o),d=Un(e,t),{lh:l,rh:r,cosL:i,cosR:u}=is(s,d,e),w=b=>b.bs===b.be,c=b=>b.toks.some(_=>typeof _.k=="string"),h=b=>w(b)&&!c(b),p=(b,_)=>_.bs<b.be&&b.bs<_.be,y=(b,_)=>!p(b,_)&&_.bs<=b.be&&b.bs<=_.be&&(w(b)&&c(b)||w(_)&&c(_))&&!(w(b)&&w(_)),C=(b,_)=>b.bs===_.bs&&b.be===_.be&&ls(b.toks,_.toks),g=[],f=new Set;for(let b of l){let _=r.find(oe=>!f.has(oe)&&C(b,oe));_?(f.add(_),g.push({bs:b.bs,be:b.be,side:"both",l:b,r:_,toks:b.toks})):g.push({bs:b.bs,be:b.be,side:"L",l:b,toks:b.toks,lead:!!b.lead})}for(let b of r)f.has(b)||g.push({bs:b.bs,be:b.be,side:"R",r:b,toks:b.toks,lead:!!b.lead});g.sort((b,_)=>b.bs-_.bs||b.be-_.be||_.lead-b.lead);let m=0,R=0;for(let b of g)b.side==="both"&&(m+=b.toks.length-(b.be-b.bs));let S=g.map((b,_)=>_),O=b=>S[b]===b?b:S[b]=O(S[b]),E=(b,_)=>(b=O(b),_=O(_),b===_?!1:(S[b]=_,!0)),P=g.map(b=>bi({bs:b.bs,be:b.be,toks:b.toks},e)),v={L:new Map,R:new Map};g.forEach((b,_)=>{let oe=b.side==="both"?["L","R"]:[b.side];for(let ee of oe)for(let Pe of P[_])v[ee].has(Pe)||v[ee].set(Pe,[]),v[ee].get(Pe).push(_)});for(let b of[v.L,v.R])for(let _ of b.values())for(let oe=1;oe<_.length;oe++)E(_[0],_[oe]);for(let b=0;b<g.length;b++)for(let _=b+1;_<g.length;_++){let oe=g[b],ee=g[_];oe.side===ee.side&&oe.side!=="both"||oe.bs>ee.be||(p(oe,ee)||y(oe,ee)?E(b,_):oe.bs===ee.bs&&w(oe)&&w(ee)&&R++)}let N=(b,_)=>{let oe=b==="L"?l:r;for(let ee of oe)if(ee.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===_.el))return ee.bs;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="close"&&e[ee].k.el===_.el)return ee;return-1};g.forEach((b,_)=>{if(!(!h(b)||b.side==="both"))for(let oe of b.toks){if(oe.kind!=="open")continue;let ee=N(b.side,oe.k);if(ee<=b.bs)continue;let Pe=new Uint8Array(ee-b.bs),Ke=[];if(g.forEach((Ne,ot)=>{if(!(Ne.side===b.side||w(Ne))&&Ne.bs<ee&&Ne.be>b.bs){Ke.push(ot);for(let Qe=Math.max(Ne.bs,b.bs);Qe<Math.min(Ne.be,ee);Qe++)Pe[Qe-b.bs]=1}}),Ke.length&&Pe.every(Ne=>Ne===1))for(let Ne of Ke)E(_,Ne)}});let L=!0;for(;L;){L=!1;let b=new Map;g.forEach((_,oe)=>{let ee=O(oe),Pe=b.get(ee)||{bs:_.bs,be:_.be,L:!1,R:!1};Pe.bs=Math.min(Pe.bs,_.bs),Pe.be=Math.max(Pe.be,_.be),_.side!=="R"&&(Pe.L=!0),_.side!=="L"&&(Pe.R=!0),b.set(ee,Pe)}),g.forEach((_,oe)=>{for(let[ee,Pe]of b){if(O(oe)===O(ee)||!(Pe.L&&Pe.R))continue;let Ke=_.bs<Pe.be&&_.be>Pe.bs,Ne=w(_)&&c(_)&&(_.bs===Pe.be||_.bs===Pe.bs);(Ke||Ne)&&E(oe,ee)&&(L=!0)}})}let D=new Map;g.forEach((b,_)=>{let oe=O(_);D.has(oe)||D.set(oe,[]),D.get(oe).push(b)});let B=[];for(let b of D.values()){let _=b.some(ee=>ee.side==="L"),oe=b.some(ee=>ee.side==="R");if(_&&oe){let ee=Math.min(...b.map(ot=>ot.bs)),Pe=Math.max(...b.map(ot=>ot.be)),Ke=b.filter(ot=>ot.side!=="R").map(ot=>ot.l).sort((ot,Qe)=>ot.bs-Qe.bs),Ne=b.filter(ot=>ot.side!=="L").map(ot=>ot.r).sort((ot,Qe)=>ot.bs-Qe.bs);B.push({bs:ee,be:Pe,kind:"conflict",localHunks:Ke,remoteHunks:Ne})}else for(let ee of b)B.push({bs:ee.bs,be:ee.be,kind:ee.side,u:ee})}let M=(b,_)=>{let oe=b==="L"?l:r;for(let ee of oe)if(ee.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===_.el))return ee.bs+.5;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="close"&&e[ee].k.el===_.el)return ee;return 1/0},x=(b,_)=>{let oe=b==="L"?l:r;for(let ee of oe)if(ee.toks.some(Pe=>Pe.kind==="open"&&Pe.k.el===_.el))return ee.bs-.5;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="open"&&e[ee].k.el===_.el)return ee;return-1/0},k=b=>b.kind==="R"?"R":"L",z=b=>b.kind==="R"?1:0;B.sort((b,_)=>{if(b.bs!==_.bs)return b.bs-_.bs;let oe=b.bs===b.be,ee=_.bs===_.be;if(oe!==ee)return oe?-1:1;if(oe&&ee&&b.kind!=="conflict"&&_.kind!=="conflict"){let Ke=b.u.toks,Ne=_.u.toks,ot=Ze=>Ze.length&&Ze.every(Xe=>Xe.kind==="open"),Qe=Ze=>Ze.length&&Ze.every(Xe=>Xe.kind==="close");if(ot(Ke)&&ot(Ne)){let Ze=Math.max(...Ke.map(wt=>M(k(b),wt.k))),Xe=Math.max(...Ne.map(wt=>M(k(_),wt.k)));if(Ze!==Xe)return Xe-Ze}if(Qe(Ke)&&Qe(Ne)){let Ze=Math.min(...Ke.map(wt=>x(k(b),wt.k))),Xe=Math.min(...Ne.map(wt=>x(k(_),wt.k)));return Ze!==Xe?Xe-Ze:z(_)-z(b)}}let Pe=Ke=>Ke.u&&Ke.u.lead?1:0;return Pe(_)-Pe(b)||z(b)-z(_)||b.be-_.be});let U=[],K=[],Ae=0,Me=b=>{b>Ae&&(U.push({bs:Ae,be:b,toks:e.slice(Ae,b),source:"base"}),Ae=b)};for(let b of B){if(Me(b.bs),b.kind==="conflict"){let _=rs(e,b.localHunks,b.bs,b.be),oe=rs(e,b.remoteHunks,b.bs,b.be),ee=n==="local"?_:n==="both"?_.concat(oe):oe,Pe=(ot,Qe)=>{let Ze=0;for(let Xe of ot)Xe.be<=b.bs&&!Qe.includes(Xe)&&(Ze+=Xe.toks.length-(Xe.be-Xe.bs));return Ze},Ke=b.bs+Pe(l,b.localHunks),Ne=b.bs+Pe(r,b.remoteHunks);K.push({bs:b.bs,be:b.be,ls:Ke,le:Ke+_.length,rs:Ne,re:Ne+oe.length,ms:0,me:0,base:e.slice(b.bs,b.be),local:_,remote:oe,resolved:ee}),U.push({bs:b.bs,be:b.be,toks:ee,source:"conflict",localHunks:b.localHunks,localToks:_,keepsLocal:n!=="remote"})}else U.push({bs:b.bs,be:b.be,toks:b.u.toks,source:b.kind==="R"?"remote":"local",localHunks:b.kind==="R"?[]:[b.u.l]});Ae=Math.max(Ae,b.be)}Me(e.length);let Be=0,te=0;for(let b of U)b.source==="conflict"&&(K[te].ms=Be,K[te].me=Be+b.toks.length,te++),Be+=b.toks.length;let ve=new Map(i.map(b=>[b.bi,b.tok])),ze=new Map(u.map(b=>[b.bi,b.tok])),re=[];for(let b of U){b.source==="base"&&(b.toks=b.toks.map((_,oe)=>{let ee=b.bs+oe,Pe=ve.get(ee),Ke=ze.get(ee),Ne=Pe&&Ke?n==="remote"?Ke:Pe:Pe||Ke||_;return Ne===_?_:{...Ne,cosmetic:!0}}));for(let _ of b.toks)re.push({..._,src:b.source})}return{tokens:re,segments:U,conflicts:K,localHunks:l,remoteHunks:r,collapsedDelta:m,samePoint:R,mapLocalOffset:wi(e,l,U)}}function rs(e,o,t,n){let s=[],d=t;for(let l of o)s=s.concat(e.slice(d,l.bs),l.toks),d=l.be;return s.concat(e.slice(d,n))}var os=e=>e.reduce((o,t)=>o+t.len,0);function wi(e,o,t){let n=new Int32Array(e.length+1);for(let l=0;l<e.length;l++)n[l+1]=n[l]+e[l].len;let s=o.map(l=>({bs:n[l.bs],be:n[l.be],text:l.toks.map(r=>r.raw).join(""),ref:l})),d=t.map(l=>({bs:n[l.bs],be:n[l.be],len:os(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?os(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let r=null,i=null,u=0,w=0,c=0;for(let p of s){let y=p.bs-c;if(l<=w+y){r=c+(l-w);break}if(w+=y,c=p.bs,l<=w+p.text.length){i=p,u=l-w,r=p.bs;break}w+=p.text.length,c=p.be}r===null&&(r=c+(l-w));let h=0;for(let p of d){if(!i&&r<=p.bs)return h;if(!(i?p.localHunks.includes(i.ref):r<p.be)){h+=p.len;continue}if(p.source==="base")return h+(r-p.bs);if(p.source==="remote")return h+p.len;if(p.source==="local")return h+Math.min(u,p.len);if(!p.keepsLocal||!i)return h+p.len;let C=p.localHunks.indexOf(i.ref),g=os(rs(e,p.localHunks.slice(0,C),p.ref.bs,i.ref.bs));return h+Math.min(g+u,p.localLen)}return h}}function no(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:f=>Math.min(f,o.length),granularity:"word"};let s=bn(e,o,t),d=rn(e,s),l=rn(o,s),r=rn(t,s),i=d.length<=2e4&&l.length<=2e4&&r.length<=2e4?Bs(d,l,r,n):null,u="word",w=d;if(!i){let f=m=>m.split(/(?<=\n)/).map(R=>({k:R,raw:R,len:R.length}));w=f(e),i=Bs(w,f(o),f(t),n),u="line"}let c=f=>f.map(m=>m.raw).join(""),h=f=>{let m=[0];for(let R of f)m.push(m[m.length-1]+R.len);return m},p=h(w),y=null,C=null,g=null;if(i.conflicts.length){let f=m=>m.split(/(?<=\n)/).map(R=>({k:R,raw:R,len:R.length}));y=h(u==="line"?f(o):l),C=h(u==="line"?f(t):r),g=h(i.tokens)}return{text:c(i.tokens),conflicts:i.conflicts.map(f=>({bs:p[f.bs],be:p[f.be],ls:y[f.ls],le:y[f.le],rs:C[f.rs],re:C[f.re],ms:g[f.ms],me:g[f.me],base:c(f.base),local:c(f.local),remote:c(f.remote),resolved:c(f.resolved)})),mapLocalOffset:i.mapLocalOffset,granularity:u}}function Fn(e,o,t=4e3){if(e===o)return[];let n=bn(e,o),s=rn(e,n),d=rn(o,n),l=Un(s,d,t),r=[0];for(let i of s)r.push(r[r.length-1]+i.len);return l.hunks.map(i=>({bs:r[i.bs],be:r[i.be],text:i.toks.map(u=>u.raw).join("")}))}function qt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Ln({base:e,side:o,retained:t,transfers:n,baseAtomKey:s=r=>r.el,sideAtomKey:d=r=>r.el,budget:l=qt()}){let r=[],i=O=>({status:"fallback",reason:O}),u=O=>O>l.remaining?!1:(l.remaining-=O,!0);if(!u((t.length+n.length)*3))return i("work-limit");for(let[O,E]of[["retained",t],["transfer",n]])for(let P of E){let{from:v,to:N,target:L}=P;if(!Number.isInteger(v)||!Number.isInteger(N)||!Number.isInteger(L)||v<0||N<=v||N>e.text.length||L<0||L+N-v>o.text.length)return i("invalid-range");r.push({...P,kind:O})}let w=Symbol(),c=O=>(E,P)=>{if(!u(1))throw w;return l.sortComparisons++,O(E,P)},h,p;try{h=r.slice().sort(c((O,E)=>O.from-E.from||O.to-E.to)),p=r.slice().sort(c((O,E)=>O.target-E.target||O.to-O.from-(E.to-E.from)))}catch(O){if(O===w)return i("work-limit");throw O}if(!u(r.length*2))return i("work-limit");for(let O=1;O<h.length;O++)if(h[O].from<h[O-1].to)return i("source-overlap");for(let O=1;O<p.length;O++)if(p[O].target<p[O-1].target+p[O-1].to-p[O-1].from)return i("target-overlap");for(let O of h){let E=O.to-O.from;if(!u(E))return i("work-limit");for(let P=0;P<E;P++){let v=O.from+P,N=O.target+P;if(l.comparisons++,e.text[v]!==o.text[N])return i("unequal-occurrence");let L=e.atomAt.get(v),D=o.atomAt.get(N);if(!!L!=!!D||L&&s(L)!==d(D))return i("different-atom")}}let y=e.text.length+o.text.length+2,C=r.reduce((O,E)=>O+(E.to-E.from)*2,2);if(!u(y+C+r.length))return i("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),f=new Int32Array(o.text.length+1).fill(-1);l.mapCells+=y,l.mapWrites+=C;let m=-1,R=!0;for(let O of h){O.target<m&&(R=!1),m=O.target+O.to-O.from;for(let E=0;E<O.to-O.from;E++)g[O.from+E]=O.target+E,f[O.target+E]=O.from+E}return g[e.text.length]=o.text.length,f[o.text.length]=e.text.length,{status:"ready",runs:h,bTo:g,toB:f,monotone:R,covers:(O,E)=>{if(!u(E-O))return null;l.coverageChecks+=E-O;for(let P=O;P<E;P++)if(e.text[P]!==yt&&!/\s/.test(e.text[P])&&g[P]<0)return!1;return!0}}}function as({base:e,side:o,baseOf:t=()=>null,budget:n=qt()}){if(e.text===o.text||!e.text.includes(yt)&&!o.text.includes(yt))return{status:"none"};let s=(e.text.length+o.text.length)*8;if(s>n.remaining)return{status:"fallback",reason:"work-limit"};n.remaining-=s,n.boundarySteps=(n.boundarySteps||0)+s;let d=(y,C)=>C<y.length&&(y[C]===yt||/\s/.test(y[C])),l=new Map,r=Symbol(),i=(y,C)=>{let g=y.stackAt[C]||[];if(!l.has(g)){if(g.length>n.remaining)throw r;n.remaining-=g.length,n.boundarySteps+=g.length,l.set(g,g.find(f=>f.block)?.el||null)}return l.get(g)},u=[],w=(y,C)=>{let g=i(e,y),f=i(o,C),m=g&&f&&t(f)!==g?"transfer":"retained",R=u[u.length-1];R&&R.to===y&&R.target+R.to-R.from===C&&R.kind===m&&R.destination===f?R.to++:u.push({from:y,to:y+1,target:C,destination:f,kind:m})},c=0,h=0,p=!1;try{for(;c<e.text.length||h<o.text.length;){if(c<e.text.length&&h<o.text.length&&e.text[c]===o.text[h]){let R=e.atomAt.get(c),S=o.atomAt.get(h);if(!!R!=!!S||R&&t(S.el)!==R.el)return{status:"none"};w(c++,h++);continue}if(!d(e.text,c)&&!d(o.text,h))return{status:"none"};let y=c,C=h;for(;d(e.text,c);)c++;for(;d(o.text,h);)h++;let g=e.text.slice(y,c),f=o.text.slice(C,h);(g.includes(yt)||f.includes(yt))&&(p=!0);let m=0;for(;m<c-y&&m<h-C&&e.text[c-m-1]===o.text[h-m-1];)m++;for(let R=m;R>0;R--)w(c-R,h-R)}}catch(y){if(y===r)return{status:"fallback",reason:"work-limit"};throw y}return p?Ln({base:e,side:o,retained:u.filter(y=>y.kind==="retained"),transfers:u.filter(y=>y.kind==="transfer"),sideAtomKey:y=>t(y.el)||y.el,budget:n}):{status:"none"}}var js=/\s/,Lo=/\S/;function Nn(e,o,t,n,s,d,l=-1,r=-1){if(!e.length)return-1;s(n,e.length);let i=new Int32Array(e.length),u=0;for(let p=1;p<e.length;p++){for(s(n,1);u&&(s(n,1),e[u]!==e[p]);)u=i[u-1];s(n,1),e[u]===e[p]&&u++,i[p]=u}let w=-1,c=0,h=0;u=0;for(let p=0;p<o.length;p++){for(s(n,1);u&&(s(n,1),e[u]!==o[p]);)u=i[u-1];if(s(n,1),e[u]===o[p]&&u++,u!==e.length)continue;let y=p+1-e.length,C=p+1;for(u=i[u-1];c<t.length&&t[c].from<y;)s(n,1),c++;for(;h<t.length&&t[h].to<C;)s(n,1),h++;if(s(n,6),!(c===t.length||h===t.length||t[c].from!==y||t[h].to!==C||l>=0&&y<r&&C>l)){if(!d)return y;if(w>=0)return-1;w=y}}return w}function yo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function cs(e,o,t,n){let s=null;for(let l of o)if(n(t,1),!(l.source!==e.source||l.side!==e.side))for(let r of l.runs){if(n(t,1),r.source!==e.source)continue;let i=Math.max(e.from,r.from),u=Math.min(e.to,r.to);i>=u||(s||(n(t,e.to-e.from),s=new Uint8Array(e.to-e.from)),n(t,u-i),s.fill(1,i-e.from,u-e.from))}if(!s)return!1;n(t,e.to-e.from);let d=!1;for(let l=e.from;l<e.to;l++)if(Lo.test(e.flat.text[l])){if(!s[l-e.from])return!1;d=!0}return d}function fs({source:e,side:o,views:t,eligible:n,blocked:s,baseId:d,model:l,tokensOf:r,budget:i,charge:u}){let{V:w,A:c,idOf:h}=t[o],p=t[1-o];if(e.nodeType!==1||c.identical.has(e)||p.A.identical.has(e)||s.has(e)||!n(e))return null;let y=w.twin(e),C=p.V.twin(e);if(!y||!C||c.map.get(e)!==y||c.reverse.get(y)!==e||p.A.map.get(e)!==C||p.A.reverse.get(C)!==e||!w.here(y)||!p.V.here(C)||!n(y)||!n(C))return null;let g=d(e);if(g!==h(y)||g!==p.idOf(C))return null;let f=l(e,null,i),m=l(y,c,i),R=l(C,p.A,i);if(!yo(f)||!yo(m)||!yo(R))return null;let S=f.flat.text,O=m.flat.text;if(u(i,S.length+O.length*3),!Lo.test(O)||O.length>=S.length)return null;let E=S.startsWith(O),P=S.endsWith(O);if(E===P)return null;let v=E?O.length:0,N=E?S.length:S.length-O.length,L=v,D=N;for(;L<D&&(u(i,1),!!js.test(S[L]));)L++;for(;D>L&&(u(i,1),!!js.test(S[D-1]));)D--;if(L===D)return null;let B=r(f,i),M=!1,x=!1;for(let k of B)u(i,1),k.from===L&&(M=!0),k.to===D&&(x=!0);return!M||!x?null:{source:e,side:o,flat:f.flat,from:v,to:N}}function Ds({base:e,views:o,side:t,attempt:n,eligible:s,blocked:d,baseId:l,model:r,tokensOf:i,certificates:u,charge:w,exhausted:c,limit:h}){if(h<=0)return null;let p=qt(h),{V:y,A:C,idOf:g}=o[t],f=o[1-t],[m,R,S,O]=n,E=null;try{for(let P=m;P<=R;P++){w(p,1);let v=e[P];if(v.nodeType!==1||C.identical.has(v)||f.A.identical.has(v)||d.has(v)||!s(v))continue;let N=fs({source:v,side:t,views:o,eligible:s,blocked:d,baseId:l,model:r,tokensOf:i,budget:p,charge:w});if(!N||cs(N,u,p,w))continue;let{flat:L,from:D,to:B}=N;w(p,(B-D)*2);let M=L.text.slice(D,B).trim();for(let x=S;x<=O;x++){w(p,1);let k=y.units[x],z=y.baseOf(k);if(!z||z===v||z.nodeType!==1||k.nodeType!==1||z.parentNode!==v.parentNode||k.parentNode!==C.map.get(v).parentNode||C.map.get(z)!==k||C.reverse.get(k)!==z||d.has(z)||!s(z)||!s(k)||l(z)!==g(k))continue;let U=r(z,null,p),K=r(k,C,p);if(!yo(U)||!yo(K))continue;let Ae=U.flat.text,Me=K.flat.text;if(w(p,Ae.length),!Lo.test(Ae)||Me.length<=Ae.length)continue;let Be=i(K,p),te=Nn(Ae,Me,Be,p,w,!0);if(!(te<0)&&!(Nn(M,Me,Be,p,w,!1,te,te+Ae.length)<0)){(E||=[]).push(N);break}}}}catch(P){if(P!==c)throw P}return E}function Us(e,o,t,n,s,d,l){if(d==="both"||t.atoms.length||n.atoms.length||s.atoms.length)return d;let r=d==="remote";if(r?l.rss!==l.rse||l.lss===l.lse||l.local===l.base:l.lss!==l.lse||l.rss===l.rse||l.remote===l.base)return d;for(let i of e){if(i.source!==o||i.side!==(r?1:0)||i.flat.text!==t.text||i.flat.nodes.length!==t.nodes.length||l.be<=i.from||l.bs>=i.to)continue;let u=!0;for(let c=0;c<t.nodes.length;c++){let h=i.flat.nodes[c],p=t.nodes[c];if(h.node!==p.node||h.s!==p.s||h.e!==p.e){u=!1;break}}if(!u)continue;let w=!1;for(let c=l.bs;c<l.be;c++)if(Lo.test(t.text[c])){if(c<i.from||c>=i.to){u=!1;break}w=!0}if(u&&w)return r?"local":"remote"}return d}var Rn="\uFFFC";var yi={caret:0},wn=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),zs=new Set(["BR","WBR","IMG"]),us=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function Pn(e,o={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(o.ignored&&o.ignored(e)||zs.has(e.tagName))return!0;if(!wn.has(e.tagName))return!us.has(e.tagName);if(o.remoteWins&&o.remoteWins(e))return!1;let t=o.inlineCache&&o.inlineCache.get(e);if(t!==void 0)return t;let n=!0;for(let s of e.childNodes)if(!Pn(s,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function ki(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function en(e,o={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},n=(s,d)=>{for(let l of s){if(l.nodeType===3){let c=l.nodeValue;if(!c)continue;t.nodes.push({node:l,s:t.text.length,e:t.text.length+c.length}),t.text+=c;for(let h=0;h<c.length;h++)t.stackAt.push(d);continue}if(l.nodeType!==1)continue;if(o.ignored&&o.ignored(l)){t.pins.push({el:l,i:t.text.length});continue}if(o.skip&&o.skip.has(l))continue;let r=o.via&&o.via(l)||l;r!==l&&(t.via||(t.via=new Map)).set(r,l);let i=l.tagName;if(o.blocks&&o.blocks.has(l)){t.text.length&&t.text[t.text.length-1]!==yt&&(t.stackAt.push(d),t.text+=yt);let c={el:l,tag:i,from:t.text.length,to:-1,depth:d.length,block:!0};t.marks.push(c);let h=d.concat([c]);n(r.childNodes,h),t.stackAt.push(h),t.text+=yt,c.to=t.text.length;continue}let u=wn.has(i)&&ki(r);if(zs.has(i)||!wn.has(i)||o.remoteWins&&o.remoteWins(l)||o.atomize&&o.atomize(l)||u){t.atoms.push({i:t.text.length,el:l,key:u?i+":empty":i,stack:d}),t.stackAt.push(d),t.text+=Rn;continue}let w={el:l,tag:i,from:t.text.length,to:-1,depth:d.length};t.marks.push(w),n(r.childNodes,d.concat([w])),w.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&Bo(t).trim()===""){let s=t.atoms[0];t.placeholder=s.el,t.text=t.text.slice(0,s.i)+t.text.slice(s.i+1),t.stackAt.splice(s.i,1);for(let d of t.nodes)d.s>s.i&&(d.s--,d.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(s=>[s.i,s])),t}function xi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function Ti(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,""")}"`;return o+">"}function so(e,o,t){let n="",s=[];for(let d=o;d<t;d++){let l=e.stackAt[d],r=0;for(;r<s.length&&r<l.length&&s[r]===l[r];)r++;for(;s.length>r;)n+=`</${s.pop().tag.toLowerCase()}>`;for(;s.length<l.length;){let u=l[s.length];n+=Ti(u.el),s.push(u)}let i=e.atomAt.get(d);n+=i?i.el.outerHTML:e.text[d]===yt?"":xi(e.text[d])}for(;s.length;)n+=`</${s.pop().tag.toLowerCase()}>`;return n}function vi(e,o){let t=[...e.el.attributes].filter(n=>!o(e.el,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tag+"|"+t}function $s(e,o){let t=[...e.attributes].filter(n=>!o(e,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function Hs(e,o=()=>!1){let t=new Map,n=d=>{let l=t.get(d);return l===void 0&&(l="{"+d.map(r=>vi(r,o)).sort().join(",")+"}",t.set(d,l)),l},s="";for(let d=0;d<e.text.length;d++){let l=e.atomAt.get(d);s+=(l?"["+$s(l.el,o)+"]":e.text[d])+n(e.stackAt[d])}return e.text.length===0&&e.placeholder&&(s+="[br]"),s}function oo(e,o,t,n=s=>s.key){let s=[],d=e.text,l=0,r=i=>{if(i<=l)return;let u=d.slice(l,i);if(t)for(let w of u.split(/(?<=\n)/))s.push({k:w,raw:w,len:w.length});else for(let w of rn(u,o))s.push(w)};for(let i of e.atoms)r(i.i),s.push({k:"\0"+n(i),raw:Rn,len:1,atom:!0}),l=i.i+1;return r(d.length),s}function Bo(e){if(!e.atoms.length)return e.text;let o="",t=0;for(let n of e.atoms)o+=e.text.slice(t,n.i),t=n.i+1;return o+e.text.slice(t)}var ro=e=>{let o=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)o[t+1]=o[t]+e[t].len;return o};function Ro(e,o,t,n){let s=ro(o),d=ro(t),l=[],r=0,i=0;for(let w of n.hunks){i+=w.bs-r;let c=i+w.toks.length;l.push({bs:s[w.bs],be:s[w.be],ss:d[i],se:d[c],text:e.text.slice(d[i],d[c]),toks:w.toks,lead:!!w.lead}),i=c,r=w.be}let u=new Map;for(let w of n.cosmetic)u.set(w.bi,w.tok.raw);return{hunks:l,respell:u}}function Vs(e,o,t){let n=l=>l===yt||/\s/.test(l),s=l=>l.replace(/[\u001E\s]/g,""),d=[];for(let l of e){let r=o.slice(l.bs,l.be),i=t.slice(l.ss,l.se);if(!r.includes(yt)&&!i.includes(yt)||r.includes(Rn)||i.includes(Rn)||s(r)!==s(i)){d.push(l);continue}let u=0,w=0;for(;;){let c=u,h=w;for(;c<r.length&&n(r[c]);)c++;for(;h<i.length&&n(i[h]);)h++;let p=u,y=w;for(;p<c&&y<h&&r[p]===i[y];)p++,y++;let C=c,g=h;for(;C>p&&g>y&&r[C-1]===i[g-1];)C--,g--;if(C>p||g>y){let f=i.slice(y,g);d.push({bs:l.bs+p,be:l.bs+C,ss:l.ss+y,se:l.ss+g,text:f,toks:[...f].map(m=>({k:m,raw:m,len:1})),lead:l.lead})}if(c>=r.length)break;u=c+1,w=h+1}}return d}function Ws(e,o,t){let n=new Int32Array(o+1).fill(-1),s=new Int32Array(t+1).fill(-1),d=0,l=0,r=i=>{for(;d<i;)n[d]=l,s[l]=d,d++,l++};for(let i of e)r(i.bs),d=i.be,l=i.se;return r(o),n[o]=l,s[l]=o,{bTo:n,toB:s}}function Ks(e,o,t){let n=[],s=0,d=0,l=(r,i)=>{if(s===r&&d===i)return;let u=o.text.slice(d,i);n.push({bs:s,be:r,ss:d,se:i,text:u,toks:rn(u,bn(u)),lead:!1})};for(let r of t.runs)l(r.from,r.target),s=r.to,d=r.target+r.to-r.from;return l(e.text.length,o.text.length),{hunks:n,respell:new Map}}function Fs(e,o,t,n){let s=ro(o),d=ro(t),l=(i,u)=>{let w=0,c=i.length;for(;w<c;){let h=w+c>>>1;i[h]<u?w=h+1:c=h}return i[w]===u?w:-1};for(let i of e.hunks)if(l(s,i.bs)<0||l(s,i.be)<0)return null;if(e.hunks.some(i=>l(d,i.ss)<0||l(d,i.se)<0)){if(!n)return null;let i=[];for(let h of e.hunks)i.push(h.ss,h.se);let u=[],w=0,c=0;for(let h of t){let p=c+h.len;for(;w<i.length&&i[w]<=c;)w++;let y=c;for(;w<i.length&&i[w]<p;){let C=i[w++];if(C>y){let g=h.raw.slice(y-c,C-c);u.push(...rn(g,bn(g))),y=C}}if(y===c)u.push(h);else{let C=h.raw.slice(y-c);u.push(...rn(C,bn(C)))}c=p}t=u,d=ro(t)}let r=[];for(let i of e.hunks){let u=l(s,i.bs),w=l(s,i.be),c=l(d,i.ss),h=l(d,i.se);if(u<0||w<0||c<0||h<0)return null;r.push({bs:u,be:w,toks:t.slice(c,h),gap:[],group:r.length})}return{parts:r,cosmeticEq:[],tokens:t}}function ds(e,o,t,n={},s=null){return Gs(e,o,t,n.base,n.local,n.remote,s,{})}function Gs(e,o,t,n,s,d,l,r){let i=bn(Bo(e),Bo(o),Bo(t)),u=oo(e,i,!1,n),w=oo(o,i,!1,s),c=oo(t,i,!1,d),h=u.length>2e4||w.length>2e4||c.length>2e4;h&&(u=oo(e,i,!0,n),w=oo(o,i,!0,s),c=oo(t,i,!0,d));let p=l?.local?Ks(e,o,l.local):null,y=l?.remote?Ks(e,t,l.remote):null,C=p?Fs(p,u,w,!h):Un(u,w),g=y?Fs(y,u,c,!h):Un(u,c);p&&C&&(w=C.tokens),y&&g&&(c=g.tokens);let f,m;if(C&&g){let R=is(C,g,u);f=Ro(o,u,w,{hunks:R.lh,cosmetic:R.cosL}),m=Ro(t,u,c,{hunks:R.rh,cosmetic:R.cosR})}else f=p||Ro(o,u,w,C),m=y||Ro(t,u,c,g);return f.hunks=Vs(f.hunks,e.text,o.text),m.hunks=Vs(m.hunks,e.text,t.text),r.base=e,r.local=o,r.remote=t,r.lines=h,r.baseTokens=u,r.localEdits=f,r.remoteEdits=m,r.localMap=Ws(f.hunks,e.text.length,o.text.length),r.remoteMap=Ws(m.hunks,e.text.length,t.text.length),r.full=null,r}function _s(e,o){if(e.size!==o.size)return!1;for(let t of e)if(!o.has(t))return!1;return!0}var io=/\s/;function Po(e,o,t){for(let n=o;n<t;n++)if(!io.test(e[n]))return!1;return!0}function Si(e,o,t){let n=e.cache[t]||(e.cache[t]=new Map);if(n.has(o))return n.get(o);let s=t===0?"local":"remote",d=t===0?"remote":"local",l=o.baseMark,r=o[d+"Mark"],i=!o.block&&!o[s]&&!!r&&l.to>l.from;if(i){let u=t===0?e.ML:e.MR,w=t===0?e.MR:e.ML,c=t===0?e.fr:e.fl,h=!1;for(let p=l.from;p<l.to;p++){if(u.bTo[p]>=0){i=!1;break}w.bTo[p]<0&&!io.test(e.fb.text[p])&&(h=!0)}if(i&&!h){for(let p=r.from;p<r.to;p++)if(w.toB[p]<0&&!io.test(c.text[p])){h=!0;break}}i&&=h}return n.set(o,i),i}function qs(e,o,t,n,s,d,l,r,i){let u=r===0?e.fl:e.fr,w=null;for(let c=t;c<n;c++){let h=o[c];if(!Po(u.text,h.ss,h.se))return null;if(Po(e.fb.text,h.bs,h.be)){if(h.bs<h.be&&h.ss<h.se||io.test(e.fb.text[h.bs-1]||"")||io.test(e.fb.text[h.be]||""))continue;return null}let p=!1;for(let y=h.bs;y<h.be;y++){if(io.test(e.fb.text[y]))continue;let C=null;for(let g of e.fb.stackAt[y]){let f=e.byEl.get(g.el);if(f&&Si(e,f,r)){C=f;break}}if(!C)return null;(w||(w=new Set)).add(C),p=!0}if(!p)return null}if(!w){if((r===0?"local":"remote")!==i)return null;let c=r===0?e.fr:e.fl,h=!1;for(let p=d;p<l;p++){let y=s[p];if(!Po(e.fb.text,y.bs,y.be))return null;Po(c.text,y.ss,y.se)||(h=!0)}if(!h)return null}return w||0}function Gn(e){let{out:o,policy:t="remote",L:n,R:s}=e,d=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,r=e.conflicts||[],i=e.decisions||[],u=r.length,w=e.conflict||(a=>r.push(a)),c={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},h=[],p=!!(n&&n.reverse&&n.map&&s&&s.reverse&&s.map),y={base:null,local:null,remote:null};if(!e.prepared&&p&&e.moveIn){let a=Se=>We=>Se.some(Le=>Le===We||Le.nodeType===1&&Le.contains(We)),I=a(e.local),V=a(e.remote),W=a(e.base),X=new Set,he=Se=>{if(!wn.has(Se.tagName))return;let We=n.map.get(Se),Le=s.map.get(Se);(We&&!I(We)||Le&&!V(Le))&&X.add(Se);for(let Fe of Se.children)he(Fe)};for(let Se of e.base)Se.nodeType===1&&he(Se);let ke=Se=>We=>{if(!wn.has(We.tagName))return!1;let Le=Se.reverse.get(We);return!!Le&&(X.has(Le)||!W(Le))};X.size&&(y.base=Se=>X.has(Se)),y.local=ke(n),y.remote=ke(s)}let C={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&p&&e.moveIn){let a=W=>X=>W.some(he=>he===X||he.nodeType===1&&he.contains(X)),I=a(e.local),V=a(e.remote);for(let W of en(e.base,{...e,atomize:y.base}).atoms){let X=n.map.get(W.el),he=s.map.get(W.el),ke=!!X&&!I(X),Se=!!he&&!V(he);!ke&&!Se||(ke&&e.movePlanned?.(W.el,"local",X,null),Se&&e.movePlanned?.(W.el,"remote",he,null),C.base.add(W.el),X&&!ke&&C.local.add(X),he&&!Se&&C.remote.add(he),I(W.el)&&C.local.add(W.el),V(W.el)&&C.remote.add(W.el))}}let g=e.prepared?.base||en(e.base,{...e,atomize:y.base,skip:C.base}),f=e.prepared?.local||en(e.local,{...e,atomize:y.local,skip:C.local}),m=e.prepared?.remote||en(e.remote,{...e,atomize:y.remote,skip:C.remote}),R=new Map(g.atoms.map(a=>[a.el,a])),S={},O=a=>e.prepared?e.prepared.full?.(a)||null:C[a].size?(S[a]||(S[a]=en(e[a],{...e,atomize:y[a]})),S[a]):null,E=(a,I,V)=>{I.namespaceURI?a.setAttributeNS(I.namespaceURI,I.name,V):a.setAttribute(I.name,V)},P=(a,I,V,W)=>{if(!I&&(!V||!W)){for(let he of(V||W).attributes)E(a,he,he.value);return}let X=new Map;for(let he of[I,V,W])if(he)for(let ke of he.attributes)X.set(ke.name,ke);for(let[he,ke]of X){let Se=I?I.getAttribute(he):null,We=V?V.getAttribute(he):Se,Le=W?W.getAttribute(he):Se,Fe;We===Le?Fe=We:We===Se?(Fe=Le,i.push({kind:"attr",el:a,name:he,source:"remote"})):Le===Se?(Fe=We,i.push({kind:"attr",el:a,name:he,source:"local"})):(Fe=t==="local"?We:Le,w({kind:"attr",el:a,name:he,base:Se,local:We,remote:Le,resolved:Fe},{el:a,sample:ke}),i.push({kind:"attr",el:a,name:he,source:"both"})),Fe!=null&&E(a,ke,Fe)}},v=(a,I,V,W)=>a&&e.mergeAttrs?e.mergeAttrs(a,I,V,W):P(W,a,I,V),N=e.mergeElement||((a,I,V)=>{let W=o.createElement(a.tagName);v(a,I,V,W);let X=I||a,he=V||a,ke=t==="local"?X.isEqualNode(a)?he:X:he.isEqualNode(a)?X:he;for(let Se of ke.childNodes)W.appendChild(o.importNode(Se,!0));return d.set(W,{base:a,local:I,remote:V}),W}),L=e.cloneUnit||((a,I)=>{let V=o.importNode(a,!0);return d.set(V,{base:null,local:I==="local"?a:null,remote:I==="remote"?a:null}),V}),D=e.atomKey||(a=>$s(a,()=>!1)),B=(a,I)=>{let V=new Map;for(let W of a.atoms)if(e.remoteWins&&e.remoteWins(W.el)&&wn.has(W.el.tagName))V.set(W,"w"+W.el.tagName+"#"+(W.el.id||""));else if(!p)V.set(W,W.key);else if(a===g)V.set(W,"="+D(W.el));else{let X=I.reverse.get(W.el),he=X?R.get(X):null;he?V.set(W,"="+D(he.el)):X?V.set(W,"m"+D(W.el)):V.set(W,"="+D(W.el))}return W=>V.get(W)},M=B(g,null),x=B(f,n),k=B(m,s),z=e.certifiedOrigins?e.certifiedOrigins(g,f,m,M,x,k):null;if(z?.fallback)return null;if(!z&&!e.prepared&&e.blocks){let a=qt(),I=as({base:g,side:f,baseOf:W=>n?.reverse?.get(W)||null,budget:a}),V=as({base:g,side:m,baseOf:W=>s?.reverse?.get(W)||null,budget:a});(I.status==="ready"||V.status==="ready")&&(z={local:I.status==="ready"?I:null,remote:V.status==="ready"?V:null})}let U=e.prepared||Gs(g,f,m,M,x,k,z,c),K=U.lines,Ae=U.baseTokens,Me=U.localEdits,Be=U.remoteEdits,te=U.localMap,ve=U.remoteMap,ze=g.text.length,re=a=>new Map(a.atoms.map(I=>[I.el,I])),b=re(f),_=re(m),oe=(a,I,V)=>{let W=new Set;if(!p)return W;for(let X of a.atoms){let he=R.get(I.reverse.get(X.el));he&&V.bTo[he.i]<0&&W.add(he)}return W},ee=oe(f,n,te),Pe=oe(m,s,ve),Ke=a=>!Pn(a,{...e,remoteWins:null}),Ne=new Set;if(p)for(let a of g.atoms){if(!Ke(a.el))continue;let I=n.map.get(a.el)||null,V=s.map.get(a.el)||null,W=I&&!V?I:V&&!I?V:null;W&&(b.has(W)||_.has(W))&&!W.isEqualNode(a.el)&&Ne.add(a)}let ot=1,Qe=(a,I)=>({id:ot++,tag:a,base:null,local:null,remote:null,rank:I}),Ze=new Map,Xe=[];for(let a of g.marks){let I=Qe(a.tag,a.depth);I.block=!!a.block,I.base=a.el,I.baseMark=a,Ze.set(a.el,I),Xe.push(I)}let wt=(a,I)=>{let V=-1,W=-1;for(let X=a.from;X<a.to;X++){let he=I[X];he>=0&&(V<0&&(V=he),W=he+1)}return V<0?null:[V,W]},dt=(a,I,V,W)=>{for(let X of a.marks){let he=V?V.reverse.get(X.el):null;he&&V.identical.has(he)&&V.pairIdenticalChildren&&V.pairIdenticalChildren(he);let ke=he?Ze.get(he):null;if(ke&&ke[I]&&(ke=null),!ke){let Se=wt(X,W),We=0;if(Se)for(let Le of Xe){if(Le.tag!==X.tag||Le[I]||!!Le.block!=!!X.block)continue;let Fe=Math.min(Se[1],Le.baseMark.to)-Math.max(Se[0],Le.baseMark.from);(Fe>We||Fe===We&&Fe>0&&Math.abs(Le.rank-X.depth)<Math.abs(ke.rank-X.depth))&&(ke=Le,We=Fe)}}ke||(ke=Qe(X.tag,X.depth),ke.block=!!X.block,ke.new=I),ke[I]=X.el,ke[I+"Mark"]=X,Ze.set(X.el,ke)}};dt(f,"local",n,te.toB),dt(m,"remote",s,ve.toB);let gt=a=>a.merged||a,zt=a=>{let I=new Set;for(let V of a)V.block||I.add(Ze.get(V.el));return I},_t=new Map,Ht=a=>{let I=_t.get(a);return I||(I=zt(a),_t.set(a,I)),I},Bt=(a,I)=>{let V=[],W=null;for(let X=0;X<ze;X++){let he=I[X];if(he<0){W&&V.push(W),W=null;continue}let ke=Ht(g.stackAt[X]),Se=Ht(a.stackAt[he]),We=new Set,Le=new Set;for(let Fe of Se)ke.has(Fe)||We.add(Fe);for(let Fe of ke)Se.has(Fe)||Le.add(Fe);if(!We.size&&!Le.size){W&&V.push(W),W=null;continue}if(W&&_s(W.added,We)&&_s(W.removed,Le)){W.be=X+1;continue}W&&V.push(W),W={bs:X,be:X+1,added:We,removed:Le}}return W&&V.push(W),V},an=Bt(f,te.bTo),Kt=Bt(m,ve.bTo),$t=a=>a.be>a.bs?[a.bs,a.be-1]:[a.bs-1,a.bs],F=(a,I)=>{if(ze===0)return null;let[V,W]=$t(a);for(let X of I){if(X.be<=V)continue;if(X.bs>W)break;let he=X.bs<=V&&W<X.be;return he&&a.text===""&&X.bs===a.bs&&X.be===a.be?"straddle":he?X:a.be>a.bs?"straddle":null}return null},le=a=>a.bs===a.be,ge=(a,I,V=null)=>{let W=!1;for(let X=a.bs;X<a.be;X++){let he=g.text[X];if(he===yt)W=!0;else if(!/\s/.test(he))return!1}for(let X=a.ss;X<a.se;X++){let he=I.text[X];if(he===yt)W=!0;else if(!/\s/.test(he)){let ke=V&&e.scopeUnits&&le(a)&&I.atomAt.get(X);if(!ke||!Ke(ke.el)||V.ss!==V.se||V.bs>=V.be)return!1;for(let We=V.bs;We<V.be;We++)if(!/\s/.test(g.text[We]))return!1;let Se=I===f?1:2;if(!e.scopeUnits[Se].includes(ke.el)||(Se===1?n:s)?.reverse.has(ke.el))return!1;W=!0}}return W},me=(a,I)=>a.bs<I.be&&I.bs<a.be,Te=(a,I)=>a.bs<=I.be&&I.bs<=a.be&&le(a)!==le(I),A=(a,I)=>g.text.slice(a.bs,a.be).includes(yt)||I.text.slice(a.ss,a.se).includes(yt),j=a=>{if(le(a))return!1;let I=a.bs,V=a.be;for(;I>0&&/\s/.test(g.text[I-1]);)I--;for(;V<g.text.length&&/\s/.test(g.text[V]);)V++;return(I===0||g.text[I-1]===yt)&&(V===g.text.length||g.text[V]===yt)},Y=(a,I)=>!A(a,I)&&!j(a),J=(a,I)=>me(a,I)||Te(a,I)&&!(a.transferIn||a.transferOut||I.transferIn||I.transferOut)&&!(ge(a,f,I)&&Y(I,m))&&!(ge(I,m,a)&&Y(a,f)),se=(a,I)=>{if(a.bs!==I.bs||a.be!==I.be||a.toks.length!==I.toks.length)return!1;let V=a.ss,W=I.ss;for(let X=0;X<a.toks.length;X++){let he=a.toks[X],ke=I.toks[X];if(he.k!==ke.k||he.atom&&!f.atomAt.get(V).el.isEqualNode(m.atomAt.get(W).el))return!1;V+=he.len,W+=ke.len}return!0},je=(a,I,V,W)=>{for(let X of g.atoms){if(X.i<a.bs||X.i>=a.be||W.has(X)||Ne.has(X))continue;let he=I.bTo[X.i],ke=he>=0?V.atomAt.get(he):null;if(ke&&!ke.el.isEqualNode(X.el))return!0}return!1},Z=[],Ie=null,He=null,Ce=Me.hunks,be=Be.hunks,H=0,G=0,de=0,pe=0,ce=0,xe=a=>{a>de&&(Z.push({src:"base",from:de,to:a,dL:pe,dR:ce}),de=a)};for(;H<Ce.length||G<be.length;){let a=Ce[H],I=be[G],V=!!a&&(!I||a.bs<I.bs||a.bs===I.bs&&a.be<=I.be&&!I.lead);if(a&&I&&a.bs===I.bs&&le(a)&&le(I)){let Ft=ge(a,f),wo=ge(I,m);Ft!==wo&&(V=wo)}let W=V?a:I,X=V?I:a,he=!!X&&se(a,I),ke=!!X&&(V?!!Ce[H+1]&&se(Ce[H+1],I):!!be[G+1]&&se(a,be[G+1])),Se=!!X&&!he&&!ke&&(ze===0||J(a,I)),We=Se,Le=F(W,V?Kt:an);if(Le==="straddle"&&(We=!0),!We&&W.be>W.bs&&(We=je(W,V?ve:te,V?m:f,V?ee:Pe)),!We&&he){xe(W.bs),Z.push({src:"both",lfrom:a.ss,rfrom:I.ss,len:W.text.length,owner:a.owner||I.owner||null,transfer:a.transferIn||I.transferIn||null}),de=W.be,pe+=W.text.length-(W.be-W.bs),ce+=W.text.length-(W.be-W.bs),H++,G++;continue}if(!We){xe(W.bs),Z.push({src:V?"local":"remote",from:W.ss,to:W.se,inherit:Le&&Le!=="straddle"?Le:null,owner:W.owner||null,transfer:W.transferIn||null}),de=W.be,V?(pe+=W.text.length-(W.be-W.bs),H++):(ce+=W.text.length-(W.be-W.bs),G++);continue}let Fe=W.bs,ht=W.be,lt=H,ft=G,Ut=Ft=>Ft.bs<ht&&Ft.be>Fe||le(Ft)&&(Ft.bs===Fe||Ft.bs===ht);V?lt++:ft++,Se&&(Fe=Math.min(Fe,X.bs),ht=Math.max(ht,X.be),V?ft++:lt++);let Pt=!0;for(;Pt;){for(Pt=!1;lt<Ce.length&&Ut(Ce[lt]);)Fe=Math.min(Fe,Ce[lt].bs),ht=Math.max(ht,Ce[lt].be),lt++,Pt=!0;for(;ft<be.length&&Ut(be[ft]);)Fe=Math.min(Fe,be[ft].bs),ht=Math.max(ht,be[ft].be),ft++,Pt=!0}let un=Fe+pe,on=Fe+ce,mn=ht-Fe,xn=ht-Fe;for(let Ft=H;Ft<lt;Ft++)mn+=Ce[Ft].text.length-(Ce[Ft].be-Ce[Ft].bs);for(let Ft=G;Ft<ft;Ft++)xn+=be[Ft].text.length-(be[Ft].be-be[Ft].bs);let Cn=un+mn,En=on+xn;if(xe(Fe),H<lt&&G<ft&&!z&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!f.atoms.length&&!m.atoms.length&&!g.pins.length&&!f.pins.length&&!m.pins.length){Ie||={fb:g,fl:f,fr:m,ML:te,MR:ve,byEl:Ze,cache:[null,null]};let Ft=qs(Ie,Ce,H,lt,be,G,ft,0,t),wo=qs(Ie,be,G,ft,Ce,H,lt,1,t);if(Ft===null!=(wo===null)){let $o=Ft!==null,Ms=$o?Ft:wo;if(Ms){He||=new Map;for(let Fr of Ms)He.set(Fr,$o?"local":"remote")}Z.push($o?{src:"remote",from:on,to:En}:{src:"local",from:un,to:Cn}),de=ht,pe+=mn-(ht-Fe),ce+=xn-(ht-Fe),H=lt,G=ft;continue}}let Zt={kind:"text",node:e.node||null,base:so(g,Fe,ht),local:so(f,un,Cn),remote:so(m,on,En),resolved:null,range:null,bs:Fe,be:ht,lss:un,lse:Cn,rss:on,rse:En},zn=e.sourceRetentions?Us(e.sourceRetentions,e.scope?.base,g,f,m,t,Zt):t;Zt.resolved=zn==="local"?Zt.local:zn==="remote"?Zt.remote:Zt.local+Zt.remote,zn!=="remote"&&Z.push({src:"local",from:un,to:Cn,conflict:Zt}),zn!=="local"&&Z.push({src:"remote",from:on,to:En,conflict:Zt});let $n={site:"inline",policy:zn,fb:g,fl:f,fr:m,scope:e.scope||null,synthetic:!!e.synthetic,full:O,merged:c};h.push($n),w(Zt,$n),de=ht,pe+=mn-(ht-Fe),ce+=xn-(ht-Fe),H=lt,G=ft}xe(ze);let ne=g.text,$=[];if(Me.respell.size||Be.respell.size){let a=ro(Ae),I=[];for(let V=0;V<Ae.length;V++){let W=Ae[V].raw,X=Me.respell.get(V)??W,he=Be.respell.get(V)??W;(X!==W||he!==W)&&$.push([a[V],X!==W&&he!==W?"both":X!==W?"local":"remote"]),I.push(X===he?X:X===W?he:he===W||t==="local"?X:he)}ne=I.join("")}let fe="",Ee=[],Re=[],Ve=[],Oe=[];for(let a of Z){let I=fe.length;if(a.src==="base"){for(let V=a.from;V<a.to;V++)Ee.push(V),Re.push(e.nativeTransfers?te.bTo[V]:V+a.dL),Ve.push(e.nativeTransfers?ve.bTo[V]:V+a.dR),Oe.push(a);fe+=ne.slice(a.from,a.to)}else if(a.src==="both"){for(let V=0;V<a.len;V++){let W=a.transfer&&(a.transfer.side==="remote"?a.rfrom+V:a.lfrom+V);Ee.push(a.transfer&&W>=a.transfer.ss&&W<a.transfer.se?a.transfer.bs+W-a.transfer.ss:-1),Re.push(a.lfrom+V),Ve.push(a.rfrom+V),Oe.push(a)}fe+=f.text.slice(a.lfrom,a.lfrom+a.len)}else{let V=a.src==="local"?f:m,W=a.transfer&&e.nativeTransfers.byOrigin[a.src==="local"?"remote":"local"].get(a.transfer.key);for(let X=a.from;X<a.to;X++){let he=a.transfer&&X>=a.transfer.ss&&X<a.transfer.se?a.transfer.bs+X-a.transfer.ss:-1,ke=he>=0&&(!W||W.destination===a.owner)?(a.src==="local"?ve:te).bTo[he]:-1;Ee.push(he),Re.push(a.src==="local"?X:ke),Ve.push(a.src==="remote"?X:ke),Oe.push(a)}fe+=V.text.slice(a.from,a.to)}a.ms=I,a.me=fe.length,a.conflict&&(a.conflict.range||(a.conflict.range=[I,I]),a.conflict.range[1]=fe.length)}let $e=fe.length,tt=new Int32Array(ze+1).fill(-1),T=new Int32Array(f.text.length+1).fill(-1),q=new Int32Array(m.text.length+1).fill(-1);for(let a=0;a<$e;a++)Ee[a]>=0&&(tt[Ee[a]]=a),Re[a]>=0&&(T[Re[a]]=a),Ve[a]>=0&&(q[Ve[a]]=a);let Q=(a,I)=>{let V=-1,W=-1;for(let X=a.from;X<a.to;X++){let he=I[X];he>=0&&(V<0&&(V=he),W=he+1)}return V<0?null:[V,W]},we=[],ue=[];for(let a of new Set(Ze.values()))a.new==="local"?we.push(a):a.new==="remote"&&ue.push(a);let ie=(a,I)=>{a.remote=I.remote,a.remoteMark=I.remoteMark,a.new="both",I.merged=a,Ze.set(I.remote,a)};if(we.length&&ue.length){let a=e.idOf;for(let I of we){let V=a?a.local(I.local):null;if(!V)continue;let W=ue.find(X=>!X.merged&&X.tag===I.tag&&!!X.block==!!I.block&&a.remote(X.remote)===V);W&&ie(I,W)}for(let I of we){if(I.remote)continue;let V=Q(I.localMark,T);if(V)for(let W of ue){if(W.merged||W.tag!==I.tag||!!W.block!=!!I.block)continue;let X=Q(W.remoteMark,q);if(X&&Math.min(V[1],X[1])-Math.max(V[0],X[0])>0){ie(I,W);break}}}}_t.clear();let ae=a=>{for(let I of a)if(I.block)return gt(Ze.get(I.el));return null},De=g.marks.some(a=>a.block)||f.marks.some(a=>a.block)||m.marks.some(a=>a.block),qe=new Array($e).fill(null),Ue=new Set;if(e.nativeTransfers)for(let a=0;a<$e;a++){let I=Oe[a].owner;qe[a]=I?gt(Ze.get(I)):Ee[a]>=0?ae(g.stackAt[Ee[a]]):null}else if(De){let a=(Le,Fe,ht)=>{let lt=new Set([Le,Fe,ht]);lt.delete(null);let ft=[];for(let Pt of lt){let un=Pt===Le,on=Pt===Fe,mn=Pt===ht;(on===mn?on:on===un?mn:on)&&ft.push(Pt)}if(ft.length<=1)return ft[0]||null;let Ut=t==="local"?Fe:ht;return ft.includes(Ut)?Ut:ft[0]},I=(Le,Fe)=>Fe>=0?ae(Le.stackAt[Fe]):null,V=new Map;for(let Le=0;Le<$e;Le++){if(fe[Le]!==yt)continue;let Fe=Ee[Le]>=0?I(g,Ee[Le]):null,ht=I(f,Re[Le]),lt=I(m,Ve[Le]);V.set(Le,[Fe,Ee[Le]>=0?a(Fe,ht,lt):ht||lt])}let W=new Set([...V.values()].map(Le=>Le[1])),X=Le=>Le!==yt&&Le!==Rn&&!/\s/.test(Le),he=(Le,Fe)=>{let ht=Le;for(;ht<Fe&&!X(fe[ht]);)ht++;return ht<Fe&&Ee[ht]>=0?I(g,Ee[ht]):null},ke=new Map,Se=0;for(let Le=0;Le<$e;Le++){if(fe[Le]!==yt)continue;let[Fe,ht]=V.get(Le),lt=he(Se,Le),ft=ht,Ut=ke.get(ft)===ft&<===ft;ft&&ke.has(ft)&&!Ut&&Fe&&!ke.has(Fe)&&!W.has(Fe)&&(ft=Fe),ft&&!ke.has(ft)&&ke.set(ft,lt);for(let Pt=Se;Pt<=Le;Pt++)qe[Pt]=ft;Se=Le+1}let We=Le=>{for(let Fe=0;Fe<Le.text.length;Fe++)if(X(Le.text[Fe])&&!I(Le,Fe))return!0;return!1};if(!We(g)&&!We(f)&&!We(m)){let Le=[],Fe=0;for(let lt=0;lt<$e;lt++)(fe[lt]===yt||lt===$e-1)&&(Le.push([Fe,lt]),Fe=lt+1);let ht=new Set(qe);for(let lt=0;lt<Le.length;lt++){let[ft,Ut]=Le[lt];if(qe[Ut])continue;let Pt=ft;for(;Pt<=Ut&&!X(fe[Pt]);)Pt++;if(Pt>Ut)continue;let un=I(g,Ee[Pt]),on=I(f,Re[Pt]),mn=I(m,Ve[Pt]),xn=a(un,on,mn)||on||mn||un;if(xn&&!ht.has(xn)){ht.add(xn);for(let Zt=ft;Zt<=Ut;Zt++)qe[Zt]=xn;continue}let Cn=lt>0&&qe[Le[lt-1][1]],En=lt+1<Le.length&&qe[Le[lt+1][1]];if(Cn)Ue.add(Le[lt-1][1]);else if(En&&fe[Ut]===yt)Ue.add(Ut);else continue;for(let Zt=ft;Zt<=Ut;Zt++)qe[Zt]=Cn||En}}}let _e=new Map,Ge=a=>{let I=_e.get(a);if(I)return I;I=[1/0,-1/0];for(let[V,W]of[[a.baseMark,tt],[a.localMark,T],[a.remoteMark,q]]){let X=V&&Q(V,W);X&&(I[0]=Math.min(I[0],X[0]),I[1]=Math.max(I[1],X[1]))}return _e.set(a,I),I},et=(a,I,V)=>{let W=-1,X=-1;for(let he=0;he<a.length;he++){let ke=Ze.get(a[he].el);ke===I&&(W=he),ke===V&&(X=he)}return W>=0&&X>=0?W-X:0},Mt=(a,I)=>[...a].sort((V,W)=>{for(let ke of I){let Se=et(ke,V,W);if(Se)return Se}let X=Ge(V),he=Ge(W);return X[0]-he[0]||he[1]-X[1]||V.rank-W.rank||V.id-W.id}),kt=new Map,Jt=new Map,Ot=e.nativeTransfers?[]:null,pt=a=>{if(Ot)return Ot;let I=Ee[a],V=Re[a],W=Ve[a],X=Oe[a];if(I>=0){let lt=g.stackAt[I],ft=f.stackAt[V],Ut=m.stackAt[W],Pt=kt.get(lt);Pt||kt.set(lt,Pt=new Map);let un=Pt.get(ft);un||Pt.set(ft,un=new Map);let on=un.get(Ut);if(on)return on;let mn=Ht(lt),xn=Ht(ft),Cn=Ht(Ut),En=new Set;for(let Zt of new Set([...mn,...xn,...Cn])){let zn=mn.has(Zt),$n=xn.has(Zt),Ft=Cn.has(Zt);($n===Ft?$n:$n===zn?Ft:$n)&&En.add(Zt)}return on=Mt(En,[ft,Ut,lt]),un.set(Ut,on),on}if(X.src==="both"){let lt=f.stackAt[V],ft=m.stackAt[W];return Mt(new Set([...Ht(lt),...Ht(ft)]),[lt,ft])}let ke=(X.src==="local"?f:m).stackAt[X.src==="local"?V:W];if(!X.inherit)return Mt(Ht(ke),[ke]);let Se=Jt.get(X);Se||Jt.set(X,Se=new Map);let We=Se.get(ke);if(We)return We;let Le=new Set(Ht(ke));for(let lt of X.inherit.added)Le.add(gt(lt));for(let lt of X.inherit.removed)Le.delete(gt(lt));let Fe=X.src==="local"?m:f,ht=(X.src==="local"?ve.bTo:te.bTo)[X.inherit.bs];return We=Mt(Le,[ke,Fe.stackAt[ht]]),Se.set(ke,We),We},bt=new Int32Array(f.text.length+1);bt[f.text.length]=$e;for(let a=f.text.length-1;a>=0;a--)bt[a]=T[a]>=0?T[a]:bt[a+1];yi.caret+=f.text.length;let mt=a=>a<=0?0:(a>f.text.length&&(a=f.text.length),T[a-1]>=0?T[a-1]+1:bt[a]),Ct=[],at=[],Vt=null,St=[],cn="",Gt=-1,jn=a=>{Vt?Vt.appendChild(a):Ct.push(a)},On=a=>{if(!cn)return;let I=o.createTextNode(cn);jn(I),at.push({node:I,ms:Gt,me:a,local:[],u:St.length?St[St.length-1].u:null}),cn=""},Ao=new Set,Dn=new Map,go=new Set,zo=a=>{let I=o.createElement(a.tag);if(a.block&&Et.add(I),!Dn.has(a)){Dn.set(a,I),v(a.base,a.local,a.remote,I),d.set(I,{base:a.base,local:a.local,remote:a.remote});let W=(ke,Se)=>p&&a[Se]&&ke.reverse.get(a[Se])?Se:null,X=!a.base&&(W(n,"local")||W(s,"remote"));if(X){let ke=X==="local"?n.reverse.get(a.local):s.reverse.get(a.remote),Se=d.get(I);Se.local=Se.local||n.map.get(ke)||null,Se.remote=Se.remote||s.map.get(ke)||null,i.push({kind:"move",el:I,source:X}),e.moveBuilt?.(ke,X,a[X],I)}else a.base||i.push({kind:"insert",el:I,source:a.local&&a.remote?"both":a.local?"local":"remote"});let he=d.get(I);he.local&&(go.has(he.local)?he.local=null:go.add(he.local))}else{let W=Dn.get(a);for(let X of W.attributes)X.name!=="id"&&X.name!=="data-id"&&E(I,X,X.value);d.set(I,{base:null,local:null,remote:null})}jn(I),St.push({u:a,el:I}),Vt=I},ye=new Set,Je=new Map;for(let a of f.pins){let I=mt(a.i);Je.has(I)||Je.set(I,[]),Je.get(I).push(a)}let Ye=a=>{let I=Je.get(a);if(I){On(a);for(let V of I){let W=V.el.namespaceURI&&V.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(V.el.namespaceURI,V.el.tagName):o.createElement(V.el.tagName);d.set(W,{base:null,local:V.el,remote:null,pinned:!0}),ye.add(W),jn(W)}}},xt=g.atoms.length||f.atoms.length||m.atoms.length,jt=a=>{if(!xt)return null;let I=Ee[a]>=0?g.atomAt.get(Ee[a]):null,V=Re[a]>=0?f.atomAt.get(Re[a]):null,W=Ve[a]>=0?m.atomAt.get(Ve[a]):null;return I||V||W?{ab:I,al:V,ar:W}:null},st=(a,I,V)=>{let W=e.idOf;if(!W||!W.base)return!1;let X=W.base(a.el);return X!=null&&X===W[V](I.el)},vt=(a,I,V,W,X)=>{if(!a||!p)return null;let he=R.get(I.reverse.get(a.el))||null;return!he||he===W||(W?he.el.isEqualNode(W.el)&&!st(he,a,X):V.bTo[he.i]>=0)?null:he},Rt=(a,I)=>{if(!a||!p||!e.moveIn)return null;let V=I.reverse.get(a.el);return V&&!R.has(V)?V:null},ct=(a,I)=>{let V=new Map;for(let W of a.atoms)V.set(I(W),(V.get(I(W))||0)+1);return V},Nt=ct(g,M),sn=ct(f,x),fn=ct(m,k),yn=a=>{let I=M(a);return Nt.get(I)===1&&(sn.get(I)||0)<=1&&(fn.get(I)||0)<=1},pn=new Map,kn=new Set,In=new Set,Mo=new Set,it=null;for(let a=0;a<$e;a++){let I=jt(a);if(!I)continue;let{ab:V,al:W,ar:X}=I,he=vt(X,s,ve,V,"remote"),ke=vt(W,n,te,V,"local"),Se=V,We=null;if(he?(Se=he,We="remote"):ke&&(Se=ke,We="local"),Se){V&&Se!==V&&(it||=new Map).set(V,We),kn.has(Se)?pn.set(a,{dup:Se.el}):(kn.add(Se),pn.set(a,{bk:Se,from:We,al:W,ar:X}));continue}let Le=Rt(X,s),Fe=Rt(W,n),ht=Le||Fe;if(ht){In.has(ht)?pn.set(a,{dup:ht}):(In.add(ht),pn.set(a,{moveIn:ht,side:Le?"remote":"local",sideEl:Le?X.el:W.el}));continue}let lt=(Ut,Pt)=>Ut&&p&&R.get(Pt.reverse.get(Ut.el))||null,ft=lt(X,s)||lt(W,n);if(ft&&(Mo.add(ft),Oe[a].conflict&&(yn(ft)||X&&(X.el===ft.el||s.identityPaired?.has(ft.el))&&st(ft,X,"remote")||W&&(W.el===ft.el||n.identityPaired?.has(ft.el))&&st(ft,W,"local")))){if(kn.has(ft)){pn.set(a,{dup:ft.el});continue}kn.add(ft)}pn.set(a,{al:W,ar:X})}let nt=new Map,Lt,rt,It=(a,I)=>{if(a[I]>=0)return a[I];for(let V=I-1;V>=0;V--)if(a[V]>=0)return a[V]+1;return 0};if(p)for(let a of g.atoms){if(kn.has(a)||Mo.has(a))continue;let I=n.map.get(a.el)||null,V=s.map.get(a.el)||null,W=I&&b.get(I),X=V&&_.get(V);if(I&&!W||V&&!X)continue;let he=!(W&&X)&&Ne.has(a);if(!he&&!(W&&X&&(yn(a)||it?.has(a)||(W.el===a.el||n.identityPaired?.has(a.el))&&(X.el===a.el||s.identityPaired?.has(a.el))&&st(a,W,"local")&&st(a,X,"remote"))))continue;let ke=it?.get(a),Se=t;if(ke){let lt=ke==="local"?m:f,ft=ke==="local"?s:n,Ut=ke==="local"?rt:Lt;if(Ut===void 0){Ut=lt.atoms.length===g.atoms.length;for(let Pt=0;Ut&&Pt<g.atoms.length;Pt++)Ut=ft.reverse.get(lt.atoms[Pt].el)===g.atoms[Pt].el;ke==="local"?rt=Ut:Lt=Ut}Ut&&(Se=ke)}let We=Se==="local"?[[W,T],[X,q]]:[[X,q],[W,T]],[Le,Fe]=We.find(([lt])=>lt),ht=It(Fe,Le.i);nt.has(ht)||nt.set(ht,[]),nt.get(ht).push({a,lt:I,rt:V,edited:he}),kn.add(a)}if(p&&e.moveIn){let a=[[f,n,T,"local"],[m,s,q,"remote"]];t!=="local"&&a.reverse();for(let[I,V,W,X]of a)for(let he of I.atoms){let ke=Rt(he,V);if(!ke||In.has(ke))continue;In.add(ke);let Se=It(W,he.i);nt.has(Se)||nt.set(Se,[]),nt.get(Se).push({move:ke,side:X,sideEl:he.el})}}let Yt=a=>{let I=nt.get(a);if(I){if(On(a),I.some(V=>Ke(V.move?V.sideEl:V.a.el)))for(;St.length;)St.pop(),Vt=St.length?St[St.length-1].el:null;for(let{a:V,lt:W,rt:X,edited:he,move:ke,side:Se,sideEl:We}of I){if(ke){let Fe=e.moveIn(ke,Se,We);Fe&&jn(Fe);continue}Ao.add(V);let Le=N(V.el,W,X);he&&(w({kind:"structure",el:Le,detail:"edit-beats-delete",base:V.el},{subject:V.el,deleted:W?"remote":"local"}),i.push({kind:"insert",el:Le,source:W?"local":"remote"})),jn(Le)}}},Et=new Set,tn=r.length>u;for(let a=0;a<$e;a++){let I=jt(a),V=e.scopeUnits&&I&&(I.ab?.stack.some(ke=>ke.block)||I.al?.stack.some(ke=>ke.block)||I.ar?.stack.some(ke=>ke.block)),X=!!I&&Ke((I.ab||I.al||I.ar).el)&&!V?[]:qe[a]?[qe[a],...pt(a)]:pt(a),he=0;for(;he<St.length&&he<X.length&&St[he].u===X[he];)he++;if(he<St.length)for(On(a);St.length>he;)St.pop(),Vt=St.length?St[St.length-1].el:null;if(Ye(a),Yt(a),X.length>St.length)for(On(a);St.length<X.length;)zo(X[St.length]);if(fe[a]===yt){if(Ue.has(a))continue;On(a);let ke=St.length;for(;ke>0&&!St[ke-1].u.block;)ke--;if(ke>0)for(tn&&c.breakOut.set(a,St[ke-1].el);St.length>=ke;)St.pop(),Vt=St.length?St[St.length-1].el:null;continue}if(I){On(a);let ke=pn.get(a),Se;if(ke.dup){w({kind:"structure",el:null,detail:"both-moved",base:ke.dup},{subject:ke.dup});continue}if(ke.moveIn){if(Se=e.moveIn(ke.moveIn,ke.side,ke.sideEl),!Se)continue}else if(ke.bk){let We=ke.bk;if(Ao.add(We),We===I.ab)Se=N(We.el,ke.al.el,ke.ar.el);else{let Le=n.map.get(We.el)||null,Fe=s.map.get(We.el)||null;Se=N(We.el,Le,Fe),(!Le||!Fe)&&w({kind:"structure",el:null,detail:"move-beats-delete",base:We.el},{subject:We.el,deleted:Le?"remote":"local"}),i.push({kind:"move",el:Se,source:ke.from})}}else ke.al?(Se=L(ke.al.el,"local"),ke.ar&&(d.get(Se).remote=ke.ar.el),i.push({kind:"insert",el:Se,source:ke.ar?"both":"local"})):(Se=L(ke.ar.el,"remote"),i.push({kind:"insert",el:Se,source:"remote"}));tn&&c.atomOut.set(a,Se),jn(Se);continue}cn||(Gt=a),cn+=fe[a]}if(On($e),(Je.has($e)||nt.has($e))&&(St.length=0,Vt=null,Ye($e),Yt($e)),$e===0&&(f.placeholder||m.placeholder||g.placeholder)){let a=o.createElement("br");d.set(a,{base:g.placeholder,local:f.placeholder,remote:m.placeholder}),Ct.push(a)}let Wt=0,At=a=>{for(;Wt>0&&at[Wt-1].me>=a;)Wt--;for(;Wt<at.length&&at[Wt].me<a;)Wt++;let I=at[Wt];if(!I)return at[at.length-1]||null;let V=at[Wt+1];return I.me===a&&V&&V.ms===a?V:I},Tt=new Map,Dt={},Qt=(a,I,V)=>{let W=At(a)||(V?Dt:null);if(!W)return;let X=Tt.get(W)||{l:!1,r:!1};I!=="remote"&&(X.l=!0),I!=="local"&&(X.r=!0),Tt.set(W,X)},Hn=a=>{if(a.conflict)return!0;let I=a.src==="local"?f.text:a.src==="remote"?m.text:"";for(let V=a.from;V<a.to;V++)if(I[V]!==Rn&&I[V]!==yt)return!0;return!1};for(let a of Z)a.src!=="base"&&Qt(a.ms,a.conflict?"both":a.src,Hn(a));for(let[a,I]of $)tt[a]>=0&&Qt(tt[a],I);for(let a of at.length?at:[Dt]){let I=Tt.get(a);I&&i.push({kind:"text",node:a.node||null,source:I.l&&I.r?"both":I.l?"local":"remote"})}for(let a of Xe){if(Dn.has(a))continue;let I=!a.local&&!(p&&n.map.get(a.base)),V=!a.remote&&!(p&&s.map.get(a.base));!I&&!V||i.push({kind:"remove",source:I&&V?"both":I?"local":"remote",base:a.base})}if(He)for(let[a,I]of He)Dn.has(a)&&w({kind:"structure",el:Dn.get(a),detail:"edit-beats-delete",base:a.base},{subject:a.base,deleted:I});let Vn=(a,I,V)=>{if(I<=a)return!1;for(let W=a;W<I;W++)if(V[W]>=0)return!1;return!0};for(let a of Xe)for(let I of["local","remote"]){let V=a[I+"Mark"],W=a.baseMark;if(!V)continue;let X=I==="local"?te:ve;if(!Vn(W.from,W.to,X.bTo)||!Vn(V.from,V.to,X.toB))continue;let he=(I==="local"?Ce:be).find(ke=>ke.ss<=V.from&&V.from<ke.se);he&&(he.be<=W.from||he.bs>=W.to)&&i.push({kind:"move",el:Dn.get(a)||null,source:I})}let Hr=a=>{let I=Ze.get(a.node.parentNode);return I?gt(I):null};for(let a of f.nodes){let I=-1;for(let W=a.s;W<a.e;W++)if(T[W]>=0){I=T[W];break}let V;if(I>=0)V=At(I);else{let W=mt(a.s),X=Hr(a);V=at.find(he=>he.u===X&&he.me>=W)||at.filter(he=>he.u===X).pop()}V&&V.local.push(a)}let bo=new Map,Vr=at[at.length-1]||null,Sn=0;for(let a of f.nodes){let I=null;for(let V=a.s;V<=a.e;V++){let W=mt(V);for(;Sn>0&&at[Sn-1].me>=W;)Sn--;for(;Sn<at.length&&at[Sn].me<W;)Sn++;let X=ke=>ke&&W>=ke.ms&&W<=ke.me&&(W<ke.me||V===a.e||ke===I),he=X(at[Sn])?at[Sn]:X(at[Sn+1])?at[Sn+1]:at[Sn]||Vr;if(!he)break;if(I===he){let ke=bo.get(he);ke[ke.length-1].to=V-a.s;continue}I=he,bo.has(he)||bo.set(he,[]),bo.get(he).push({node:a.node,from:V-a.s,to:V-a.s,flatStart:a.s})}}for(let a of at){let I=a.local,V=!1;for(let ke of I)for(let Se=ke.s;Se<ke.e&&!V;Se++)(T[Se]<a.ms||T[Se]>=a.me)&&(V=!0);d.set(a.node,{base:null,local:I.map(ke=>ke.node),remote:null,caret:bo.get(a)||[],partial:V});let W=a.ms,X=a.me-a.ms,he=ke=>{let Se=0,We=-1;for(let Le of I){let Fe=Le.e-Le.s;if(ke<=Se+Fe){We=Le.s+(ke-Se);break}Se+=Fe}return We<0&&(We=I.length?I[I.length-1].e:0),Math.max(0,Math.min(mt(We)-W,X))};he.flat=ke=>Math.max(0,Math.min(mt(ke)-W,X)),l.set(a.node,he)}function Wr(){if(!f.text.includes(yt))return[{flatLocal:f.text,localNodes:f.nodes,textNodes:at,lToM:T,mapLocal:mt}];let a=[],I=0,V=0;for(let W=0;W<=f.text.length;W++){if(W<f.text.length&&f.text[W]!==yt)continue;let X=I,he=W;if(he>X){let ke=[];for(;V<f.nodes.length&&f.nodes[V].e<=X;)V++;for(let Se=V;Se<f.nodes.length&&f.nodes[Se].s<he;Se++){let We=f.nodes[Se],Le=Math.max(We.s,X),Fe=Math.min(We.e,he);Le<Fe&&ke.push({node:We.node,s:Le-X,e:Fe-X})}a.push({flatLocal:f.text.slice(X,he),localNodes:ke,textNodes:at,lToM:T.subarray?T.subarray(X,he+1):T.slice(X,he+1),mapLocal:Se=>mt(X+Math.max(0,Math.min(Se,he-X)))})}I=W+1}return a}let Ns={...e,blocks:Et,ignored:a=>ye.has(a)||(e.ignored?e.ignored(a):!1)},As=e.ignoreAttribute||(()=>!1),Kr=Hs(en(Ct,Ns),As)!==Hs(m,As);if(h.length){let a=I=>{let V=d.get(I);return V&&V.unchanged?V.remote:null};c.text=fe,c.textNodes=at,c.out=en(Ct,{...Ns,via:a})}let Zn=null;if(e.scopeUnits){Zn=new Map;let a=new Set(Ct),I=Se=>{for(;Se&&!a.has(Se);)Se=Se.parentNode;return Se},V=e.scopeUnits.map(Se=>{let We=new Map;for(let Le of Se)if(Le.nodeType===1)We.set(Le,Le);else for(let Fe of Le.nodes)We.set(Fe,Le);return We}),W=(Se,We)=>{for(;Se&&!We.has(Se);)Se=Se.parentNode;return Se?We.get(Se):null},X=[g,f,m].map((Se,We)=>{let Le=new Array(Se.text.length);for(let Fe of Se.nodes){let ht=W(Fe.node,V[We]);ht&&Le.fill(ht,Fe.s,Fe.e)}for(let Fe of Se.atoms)Le[Fe.i]=W(Fe.el,V[We]);return Le}),he=(Se,We)=>{if(!Se||!We)return;let Le=Zn.get(Se);Le||Zn.set(Se,Le=new Set),Le.add(We)};for(let Se of Ct){let We=d.get(Se);We&&(he(W(We.base,V[0]),Se),he(W(We.local,V[1]),Se),he(W(We.remote,V[2]),Se))}for(let Se of at){let We=I(Se.node);for(let Le=Se.ms;Le<Se.me;Le++)he(X[0][Ee[Le]],We),he(X[1][Re[Le]],We),he(X[2][Ve[Le]],We)}let ke=new Map(Ct.map((Se,We)=>[Se,We]));for(let[Se,We]of Zn)Zn.set(Se,Array.from(We).sort((Le,Fe)=>ke.get(Le)-ke.get(Fe)))}return{unitOutputs:Zn,nodes:Ct,text:fe,textNodes:at,localDiverged:Kr,mapLocal:mt,conflicts:r.slice(u),granularity:K?"line":"word",segments:Wr(),localHunks:Ce,remoteHunks:be,lToM:T}}function Ys(e,o,t,n,s){if(!s(e.length*8+1))return null;let d=0,l=o===0,r=!1;for(let i of rn(e,n)){if(!s(1))return null;if(d+=i.len,d===o&&(l=!0),d===t&&(r=!0),d>=t)break}return l&&r}function Ni(e,o,t,n,s,d,l){if(!l(o.length*2))return!1;let r=new Map,i=new Map,u=new Set;for(let w of o){let c=w.bs<w.be,h=c?t[w.ownerIndex].text.base:t[w.ownerIndex].text[e],p=c?w.bs:w.ss,y=c?w.be:w.se;if(!l((y-p)*4+1))return!1;for(;p<y&&/\s/.test(h[p]);)p++;for(;y>p&&/\s/.test(h[y-1]);)y--;if(p===y)continue;let C=h.slice(p,y),g=c?r:i;c&&w.text&&u.add(C),g.has(C)?g.set(C,null):g.set(C,{h:w,from:p,to:y})}for(let w of n){if(!l(1))return!1;if(w.side!==e)continue;let c=w.deletion,h=t[c.ownerIndex].text.base;if(!l((c.be-c.bs)*3)||u.has(h.slice(c.bs,c.be).trim()))return!1}for(let[w,c]of r){if(!l(w.length+1))return!1;let h=i.get(w);if(!c||!h)continue;let p=c.h,y=h.h;if(!p.text||p.transferOut||y.transferIn||p.owner===y.owner)continue;let C=t[p.ownerIndex],g=t[y.ownerIndex];if(!l(C.text.base.length))return!1;if(!/\S/.test(C.text.base.slice(0,p.bs)+C.text.base.slice(p.be)))continue;let f=Ys(C.text.base,c.from,c.to,d,l),m=Ys(g.text[e],h.from,h.to,d,l);if(f===null||m===null)return!1;if(!f||!m)continue;let R=`${C.index}:${c.from}:${c.to}`,S={key:R,side:e,source:p.owner,destination:y.owner,deletion:p,insertion:y,sourceOffset:c.from-p.bs,targetOffset:h.from-y.ss,length:c.to-c.from};p.transferOut=S,y.transferIn=S,s[e].set(R,S),n.push(S)}return!0}function Xs({base:e,local:o,remote:t,localTwin:n,remoteTwin:s,eligible:d,nodes:l,budget:r=qt(2e4*32)}){let i=v=>v>r.remaining?!1:(r.remaining-=v,r.nativeSteps=(r.nativeSteps||0)+v,!0);if(e.length<2||o.length!==e.length||t.length!==e.length||!i(e.length*12))return null;for(let[v,N]of[["base",e],["local",o],["remote",t]]){let L=l[v];if(L.length!==N.length||L.some((D,B)=>D!==N[B]))return null}let u=[],w=0;for(let v=0;v<e.length;v++){let N=e[v],L=o[v],D=t[v];if(n(N)!==L||s(N)!==D)return null;let B={};for(let[M,x]of[["base",N],["local",L],["remote",D]]){if(!d(x)||x.tagName!==N.tagName||x.namespaceURI!==N.namespaceURI||!i(x.childNodes.length+1))return null;let k="";for(let z of x.childNodes){if(z.nodeType!==3||!i(z.data.length*4+1))return null;k+=z.data}if(k.includes(yt)||(w+=k.length+1,w>2e4))return null;B[M]=k}u.push({base:N,local:L,remote:D,index:v,text:B})}let c=u.every(v=>bn(v.text.base,v.text.local,v.text.remote)),h={local:[],remote:[]};for(let v of u){v.hunks={local:[],remote:[]};for(let N of["local","remote"]){let L=v.text.base,D=v.text[N];if(L===D)continue;let B=L.length+D.length+4,M=B*8;if(!i(M))return null;let x=Math.floor(r.remaining/8),k=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(B*B+x)-B)/2)));if(k<1||!i(4*(k+1)*(B+k+1)))return null;let z=0;for(let U of Fn(L,D,k)){if(!i(U.text.length+1))return null;let K=U.bs+z,Ae={...U,ss:K,se:K+U.text.length,toks:rn(U.text,c),owner:v.base,ownerIndex:v.index};v.hunks[N].push(Ae),h[N].push(Ae),z+=U.text.length-(U.be-U.bs)}}}let p=[],y={local:new Map,remote:new Map};for(let v of["local","remote"]){let N=new Map,L=new Map,D=!1,B=(M,x,k)=>{M.has(x)?M.set(x,null):M.set(x,k)};for(let M of h[v]){if(!i(1))return null;let x=u[M.ownerIndex].text.base;if(M.bs<M.be&&M.text===""){let k=x.slice(M.bs,M.be);if(!i(k.length*2))return null;/\S/.test(k)&&B(N,k,M)}else if(M.bs===M.be&&/\S/.test(M.text)){if(!i(M.text.length*2))return null;B(L,M.text,M)}else M.bs<M.be&&(D=!0)}for(let[M,x]of N){if(!i(M.length+1))return null;let k=L.get(M);if(!x||!k||x.owner===k.owner)continue;let z=u[x.ownerIndex];if(!i(z.text.base.length))return null;if(!/\S/.test(z.text.base.slice(0,x.bs)+z.text.base.slice(x.be)))continue;let U=`${z.index}:${x.bs}:${x.be}`,K={key:U,side:v,source:x.owner,destination:k.owner,deletion:x,insertion:k};x.transferOut=K,k.transferIn=K,y[v].set(U,K),p.push(K)}if(D&&L.size&&!Ni(v,h[v],u,p,y,c,i))return null}if(!p.length)return null;let C=(v,N)=>v.bs<N.be&&N.bs<v.be,g=v=>v.bs===v.be,f=(v,N)=>v.bs<=N.be&&N.bs<=v.be&&g(v)!==g(N),m=(v,N)=>v.bs===N.bs&&v.be===N.be&&v.text===N.text,R=(v,N)=>!!(v.transferIn||v.transferOut&&(!v.text||N.bs===v.be&&/\s/.test(N.text[0])||N.bs===v.bs&&/\s/.test(N.text[N.text.length-1])));for(let v of p){let N=v.side==="local"?"remote":"local",L=u[v.deletion.ownerIndex];for(let D of L.hunks[N])if(!i(1)||C(v.deletion,D)&&D.transferOut?.key!==v.key)return null}for(let v of u)for(let N of v.hunks.local)for(let L of v.hunks.remote){if(!i(1))return null;if(m(N,L)){if(N.transferIn?.key!==L.transferIn?.key)return null;continue}if(C(N,L)||f(N,L)&&!R(N,L)&&!R(L,N))return null}if(!i(w*8))return null;let S=new Set([...e,...o,...t]),O={base:en(e,{blocks:S}),local:en(o,{blocks:S}),remote:en(t,{blocks:S})},E={};for(let v of["base","local","remote"]){let N=O[v];if(N.atoms.length||N.pins.length)return null;E[v]=new Map(N.marks.filter(L=>L.block).map(L=>[L.el,L.from]))}for(let v of u){let N=E.base.get(v.base);if(N===void 0)return null;for(let L of["local","remote"]){let D=E[L].get(v[L]);if(D===void 0)return null;for(let B of v.hunks[L])B.bs+=N,B.be+=N,B.ss+=D,B.se+=D}}for(let v of p)v.bs=v.deletion.bs+(v.sourceOffset||0),v.be=v.length===void 0?v.deletion.be:v.bs+v.length,v.ss=v.insertion.ss+(v.targetOffset||0),v.se=v.length===void 0?v.insertion.se:v.ss+v.length;let P={};for(let v of["local","remote"]){let N=0,L=0,D=[];for(let M of h[v]){if(!i(1))return null;M.bs>N&&D.push({from:N,to:M.bs,target:L}),N=M.be,L=M.se}N<O.base.text.length&&D.push({from:N,to:O.base.text.length,target:L});let B=p.filter(M=>M.side===v).map(M=>({from:M.bs,to:M.be,target:M.ss,destination:M.destination}));if(P[v]=Ln({base:O.base,side:O[v],retained:D,transfers:B,budget:r}),P[v].status!=="ready")return null}return i(O.base.text.length)?{owners:u,blocks:S,transfers:p,byOrigin:y,budget:r,prepared:{base:O.base,local:O.local,remote:O.remote,lines:!1,baseTokens:rn(O.base.text,c),localEdits:{hunks:h.local,respell:new Map},remoteEdits:{hunks:h.remote,respell:new Map},localMap:P.local,remoteMap:P.remote,full:null}}:null}var hs=/\S/;function Js({certificates:e,scopes:o,views:t,eligible:n,baseId:s,limit:d=2e4*32}){let l=qt(d),r=Symbol(),i=[],u=c=>{if(c>l.remaining)throw r;l.remaining-=c},w=(c,h=null)=>{if(u(1),!c||c.nodeType!==1||c.parentNode?.nodeType!==1||!n(c))return null;for(let C=c.parentNode;C;C=C.parentNode)if(u(1),C.nodeType===11)return null;let p="",y=0;for(let C of c.childNodes){if(u(1),C.nodeType!==3)return null;if(u(C.data.length*4+1),h){let g=h.flat.nodes[y++];if(!g||g.node!==C||g.s!==p.length||g.e!==p.length+C.data.length)return null}p+=C.data}return u(p.length*3+1),h&&(h.flat.atoms.length||h.flat.pins?.length||y!==h.flat.nodes.length||h.flat.text!==p)?null:hs.test(p)?p:null};try{u(o[0].length+o[1].length+o[2].length+e.length);let c=o.map(p=>new Set(p)),h=new Map;for(let p of e){u(1);let y=h.get(p.source);y||h.set(p.source,y=[]),y.push(p)}for(let p of h.values()){let y=[null,null],C=[];for(let g of p){u(1);let{source:f,target:m,side:R,models:S,runs:O}=g;if(R!==0&&R!==1||!c[0].has(f)||!c[R+1].has(m))continue;let{V:E,A:P,idOf:v}=t[R],N=t[1-R],L=E.twin(f),D=N.V.twin(f),B=E.baseOf(m);if(!L||!D||!B||B===f||!c[0].has(B)||!c[R+1].has(L)||!c[2-R].has(D)||P.map.get(f)!==L||P.reverse.get(L)!==f||N.A.map.get(f)!==D||N.A.reverse.get(D)!==f||P.map.get(B)!==m||P.reverse.get(m)!==B||m.parentNode!==L.parentNode||B.parentNode!==f.parentNode||f.tagName!==L.tagName||f.tagName!==D.tagName||s(f)!==v(L)||s(f)!==N.idOf(D)||s(B)!==v(m))continue;let M=S.get(f),x=S.get(m);if(!M||!x)continue;let k=w(f,M),z=w(m,x),U=w(L),K=w(D);if(u((k?.length||0)+(K?.length||0)),k===null||z===null||U===null||K===null||K===k)continue;let Ae=O.length>0,Me=!1;for(let te of O){if(u(1),te.source!==f||te.target!==m||!Number.isInteger(te.from)||!Number.isInteger(te.to)||!Number.isInteger(te.targetFrom)||te.from<0||te.to<=te.from||te.to>k.length||te.targetFrom<0||te.targetFrom+te.to-te.from>z.length){Ae=!1;break}u((te.to-te.from)*3);for(let ve=te.from;ve<te.to;ve++){if(k[ve]!==z[te.targetFrom+ve-te.from]){Ae=!1;break}hs.test(k[ve])&&(Me=!0)}if(!Ae)break}if(!Ae||!Me)continue;let Be=y[R];Be||(u(k.length),Be=y[R]={source:f,side:R,flat:M.flat,before:k,covered:new Uint8Array(k.length)});for(let te of O)u(te.to-te.from),Be.covered.fill(1,te.from,te.to)}for(let g of y){if(!g)continue;let{source:f,side:m,flat:R,before:S,covered:O}=g;u(S.length*3+1);let E=-1,P=-1;for(let v=0;v<=S.length;v++)v<S.length&&O[v]?(E<0&&(E=v),P=v+1):(v===S.length||hs.test(S[v]))&&E>=0&&(C.push({source:f,side:m,flat:R,from:E,to:P}),E=P=-1)}u(C.length),i.push(...C)}}catch(c){if(c!==r)throw c}return{records:i,budget:l}}var Ai="http://www.w3.org/1999/xhtml";function Mi(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function dn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Ai}function Oi(e){let o=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return o==="application/json"||o.endsWith("+json")}function Do(e,o){let t=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let s=t;try{let d=new URL(t,o);s=d.origin+d.pathname+d.search}catch{}return"script|src|"+n+"|"+s}return"script|inline|"+n+"|"+Mi(e.textContent.trim())}var Ii={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function lo(e,o=[],t=!1){if(!dn(e)||e.hasAttribute("src"))return null;let n=[Ii,...o];for(let s=0;s<n.length;s++){let d=n[s];if(!d.match(e))continue;if(!Oi(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=d.identity(e);return l==null||l===""?null:{key:s+":"+l,raw:l,recognizer:d}}return null}function Qs(e,o,t){let n=new Set,s=d=>{dn(d)&&!o(d)&&n.add(Do(d,t))};s(e);for(let d of e.querySelectorAll("script"))s(d);return n}function ko(e,o){let t=o.createElement("div");t.innerHTML="<script><\/script>";let n=t.firstChild;for(let s of e.attributes)n.setAttribute(s.name,s.value);return n.textContent=e.textContent,n}function Zs(e,o,t){let n=[],s=[],d=new Map,l=t.trackRecovery?new Set:null,r=Array.from(e.querySelectorAll("script"));dn(e)&&r.unshift(e);for(let i of r){if(!dn(i)||t.ignored(i)||t.skip.has(i)||o.has(Do(i,t.baseURI)))continue;let u=i.ownerDocument.createElement("script");for(let w of i.attributes)u.setAttribute(w.name,w.value);if(u.textContent=i.textContent,t.beforeNodeAdded(u)===!1){l?.add(i);continue}u.hasAttribute("src")&&s.push(new Promise(w=>{u.addEventListener("load",()=>w()),u.addEventListener("error",()=>w())})),i.replaceWith(u),d.set(i,u),t.afterNodeAdded(u),n.push(u)}return{executed:n,loads:s,swapped:d,vetoed:l}}function Ci(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function Ei(e,o){try{let t=new URL(e,o);return t.origin+t.pathname+t.search}catch{return e}}function er(e,o){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return Do(e,o);if(t==="LINK"){let n=e.getAttribute("href");return n?"link|"+(e.getAttribute("rel")||"")+"|"+Ei(n,o):e.outerHTML}if(t==="META"){for(let n of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(n))return"meta|"+n+"="+e.getAttribute(n);return e.outerHTML}return t==="STYLE"?"style|"+Ci(e.textContent):e.outerHTML}function ps(e,o){for(;;){for(;o<e.length&&/\s/.test(e[o]);)o++;if(e[o]==="/"&&e[o+1]==="/"){for(;o<e.length&&e[o]!==`
|
|
4
|
-
`;)o++;continue}if(e[o]==="/"&&e[o+1]==="*"){let t=e.indexOf("*/",o+2);if(t===-1)return e.length;o=t+2;continue}return o}}function tr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(o,t)=>t.length%2===0?t+'\\"':o)}var Li=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Ri=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Uo(e){try{return JSON.parse(e)}catch{return JSON.parse(Pi(e))}}function Pi(e){let o="",t=0,n=(s,d)=>{throw new Error(`Invalid relaxed JSON: ${s} at position ${d}`)};for(;t<e.length&&(t=ps(e,t),!(t>=e.length));){let s=e[t];if("{}[]:".includes(s)){o+=s,t++;continue}if(s===","){let r=ps(e,t+1);if(e[r]==="}"||e[r]==="]"){t++;continue}o+=s,t++;continue}if(s==='"'||s==="'"){let r=t+1;for(;r<e.length&&e[r]!==s;)e[r]==="\\"&&r++,r++;r>=e.length&&n("unterminated string",t);let i=e.slice(t+1,r);s==="'"&&(i=tr(i)),o+='"'+i+'"',t=r+1;continue}let d=t;for(;d<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[d]);)d++;d===t&&n("unexpected character "+JSON.stringify(s),t);let l=e.slice(t,d);if(l==="true"||l==="false"||l==="null"||Li.test(l)){o+=l,t=d;continue}if(Ri.test(l)){if(e[ps(e,d)]===":"){o+='"'+l+'"',t=d;continue}n("unquoted value "+JSON.stringify(l),t)}n("invalid token "+JSON.stringify(l),t)}return o}function nr(e){try{return JSON.parse(e)}catch{}let o={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(s){let d=[],l=0;for(;l<s.length;){let r=s[l];if(/\s/.test(r)){l++;continue}if("{}".includes(r)){d.push({type:r,value:r}),l++;continue}if(r==="["){let c=!1,h=l+1;for(;h<s.length&&/\s/.test(s[h]);)h++;if(h<s.length&&/[a-zA-Z_]/.test(s[h])&&(c=!0),!c){d.push({type:r,value:r}),l++;continue}}if(r==="]"){d.push({type:r,value:r}),l++;continue}if(r===":"){d.push({type:o.COLON,value:r}),l++;continue}if(r===","){d.push({type:o.COMMA,value:r}),l++;continue}if(r==='"'||r==="'"){let c=r,h=l+1;for(;h<s.length&&s[h]!==c;)s[h]==="\\"&&h++,h++;d.push({type:o.STRING,value:s.substring(l+1,h),quoted:!0,sourceQuote:c}),l=h+1;continue}let i=l,u;for(;i<s.length&&!/[{},]/.test(s[i]);)if(s[i]===":"){let c=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let p of c){let y=p.substring(1);if(s.substring(i+1,i+1+y.length)===y){h=!0,i+=y.length;break}}if(!h)break}else if(s[i]==="["){for(i++;i<s.length&&s[i]!=="]";){if(s[i]==='"'||s[i]==="'"){let c=s[i];for(i++;i<s.length&&s[i]!==c;)s[i]==="\\"&&i++,i++}i++}i<s.length&&s[i]==="]"&&i++}else i++;u=s.substring(l,i);let w=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?w=o.NUMBER:u==="true"||u==="false"||u==="null"?w=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(w=o.SELECTOR),d.push({type:w,value:u,quoted:!1}),l=i}return d}function n(s){let d="";for(let l=0;l<s.length;l++){let r=s[l];if("{}".includes(r.type)||"[]".includes(r.type)){d+=r.value;continue}if(r.type===o.COLON){d+=r.value;continue}if(r.type===o.COMMA){let i=s[l+1];if(i&&(i.type==="}"||i.type==="]"))continue;d+=r.value;continue}if(r.type===o.STRING){let i=r.value;r.sourceQuote==="'"&&(i=tr(i)),d+=`"${i}"`;continue}if(r.type===o.NUMBER||r.type===o.BOOLEAN){d+=r.value;continue}d+=`"${r.value}"`}return d}try{let s=t(e),d=n(s);return JSON.parse(d)}catch(s){throw new Error("Invalid extraction rules syntax: "+s.message)}}var Xt=Symbol("hyper-morph-json-merge:missing"),or=["id","_id","uuid","key","slug","code","name"];function ao(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xo(e,o){return Object.prototype.hasOwnProperty.call(e,o)}function Bi(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}function _n(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o)){if(e.length!==o.length)return!1;for(let t=0;t<e.length;t++)if(!_n(e[t],o[t]))return!1;return!0}if(ao(e)&&ao(o)){let t=Object.keys(e);if(t.length!==Object.keys(o).length)return!1;for(let n of t)if(!xo(o,n)||!_n(e[n],o[n]))return!1;return!0}return!1}function sr(e,o,t,n){return _n(o,t)?o:_n(o,e)?t:_n(t,e)?o:ao(o)&&ao(t)?ji(ao(e)?e:{},o,t,n):Array.isArray(o)&&Array.isArray(t)?Vi(Array.isArray(e)?e:[],o,t,n):t}function rr(e,o,t,n){return o===Xt&&t===Xt?Xt:o===Xt?e===Xt?t:_n(t,e)?Xt:t:t===Xt?e===Xt?o:Xt:sr(e,o,t,n)}function ji(e,o,t,n){let s={},d=new Set([...Object.keys(e),...Object.keys(o),...Object.keys(t)]);for(let l of d){let r=rr(xo(e,l)?e[l]:Xt,xo(o,l)?o[l]:Xt,xo(t,l)?t[l]:Xt,n);r!==Xt&&Bi(s,l,r)}return s}function Di(e){return e===null||typeof e!="object"}function Ho(e){return typeof e+":"+String(e)}function Ui(e,o){for(let t of o){let n=new Set;for(let s of t){if(!xo(s,e))return!1;let d=s[e];if(typeof d!="string"&&typeof d!="number")return!1;let l=Ho(d);if(n.has(l))return!1;n.add(l)}}return!0}function Hi(e,o,t,n){let s=[e,o,t],d=!0;for(let l of s)for(let r of l)ao(r)||(d=!1);if(d){for(let l of n.keyCandidates)if(Ui(l,s))return{kind:"keyed",field:l};return null}for(let l of s){let r=new Set;for(let i of l){if(!Di(i))return null;let u=Ho(i);if(r.has(u))return null;r.add(u)}}return{kind:"self"}}function Vi(e,o,t,n){let s=Hi(e,o,t,n);if(!s)return t;let d=s.kind==="self"?Ho:p=>Ho(p[s.field]),l=p=>{let y=new Map;for(let C of p)y.set(d(C),C);return y},r=l(e),i=l(o),u=l(t),w=new Map,c=new Set([...r.keys(),...i.keys(),...u.keys()]);for(let p of c){let y=rr(r.has(p)?r.get(p):Xt,i.has(p)?i.get(p):Xt,u.has(p)?u.get(p):Xt,n);y!==Xt&&w.set(p,y)}let h=[];for(let p of t){let y=d(p);w.has(y)&&h.push(y)}for(let p=0;p<o.length;p++){let y=d(o[p]);if(!w.has(y)||h.includes(y))continue;let C=0;for(let g=p-1;g>=0;g--){let f=h.indexOf(d(o[g]));if(f!==-1){C=f+1;break}}h.splice(C,0,y)}return h.map(p=>w.get(p))}function ms(e,o,t,n={}){let s=n.keyCandidates?[...n.keyCandidates,...or]:or;return sr(e===void 0?Xt:e,o,t,{keyCandidates:s})}function Vo(e,o,t,n={}){let s=n.parse||Uo,d=[],l=(c,h)=>{if(typeof c!="string")return Xt;try{return s(c)}catch(p){return d.push(`${h} side is not valid JSON (${p.message})`),Xt}},r=l(o,"local"),i=l(t,"remote");if(r===Xt)return{text:t,warnings:d};if(i===Xt)return{text:o,warnings:d};let u=l(e,"base"),w=ms(u===Xt?void 0:u,r,i,n);return _n(w,i)?{text:t,warnings:d}:_n(w,r)?{text:o,warnings:d}:{text:JSON.stringify(w,null,2),warnings:d}}var ir=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Xn(e){if(!e)return!1;let{startContainer:o,startOffset:t,endContainer:n,endOffset:s}=e;if(!o||!n||!Number.isInteger(t)||!Number.isInteger(s)||t<0||s<0||t>ir(o)||s>ir(n)||o.getRootNode()!==n.getRootNode())return!1;let d=o.ownerDocument.createRange();return d.setStart(o,t),d.setEnd(n,s),d.startContainer===o&&d.startOffset===t}function qn(e,o,t={}){if(!Xn(e))return null;let{startContainer:n,startOffset:s,endContainer:d,endOffset:l}=e;if(n===d&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(s,l);if(n===d&&s===l)return"";let r=new Set;for(let g=n;g;g=g.parentNode)r.add(g);let i=d;for(;!r.has(i);)i=i.parentNode;let u=(g,f)=>{let m=i.ownerDocument.createRange(),R=i.ownerDocument.createRange();return m.setStart(g[0],g[1]),m.collapse(!0),R.setStart(f[0],f[1]),R.collapse(!0),m.compareBoundaryPoints(0,R)},w=(g,f=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(f)],c=[],h;if(o==="plain"){h="";let g=f=>{if(f.nodeType===3||f.nodeType===8){let m=h.length;h+=f.nodeValue,c.push({s:m,e:h.length,a:[f,0],b:[f,f.nodeValue.length],node:f})}else for(let m of f.childNodes)g(m)};g(i)}else{let g=t.blocks;if(!g){g=new Set;let m=R=>{R!==i&&R.nodeType===1&&us.has(R.tagName)&&g.add(R);for(let S of R.childNodes)m(S)};m(i)}let f=en(Array.from(i.childNodes),{blocks:g,atomize:m=>!!t.atoms?.has(m),ignored:t.ignored});h=f.text;for(let m of f.nodes)c.push({s:m.s,e:m.e,a:[m.node,0],b:[m.node,m.e-m.s],node:m.node});for(let m of f.atoms)c.push({s:m.i,e:m.i+1,a:w(m.el),b:w(m.el,!0)});for(let m=0;m<f.text.length;m++){if(f.text[m]!==yt)continue;let R=f.marks.find(O=>O.block&&O.to===m+1),S=f.marks.find(O=>O.block&&O.from===m+1);if(R)c.push({s:m,e:m+1,a:[R.el,R.el.childNodes.length],b:w(R.el,!0)});else if(S)c.push({s:m,e:m+1,a:w(S.el),b:[S.el,0]});else return null}}c.sort((g,f)=>g.s-f.s);let p=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let m=c.find(R=>R.node===g[0]);return m?m.s+g[1]:null}let f=0;for(let m of c){if(u(g,m.a)<=0)return m.s;if(u(g,m.b)<0)return null;f=m.e}return f},y=p([n,s]),C=p([d,l]);return y!==null&&C!==null&&y<=C?h.slice(y,C):null}function Yn(e,o){let t=e;for(let n of o.path)if(t=n==="content"?t?.content:t?.childNodes[n],!t)return null;return[t,o.offset]}function lr(e,o){if(!e||!o)return null;let t=Yn(e,o.start),n=Yn(e,o.end);return t&&n?{startContainer:t[0],startOffset:t[1],endContainer:n[0],endOffset:n[1]}:null}var ar=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function cr(e,o,t){if(!o)return;let n=new Map,s=new Map,d=r=>{if(!r)return null;if(s.has(r))return s.get(r);let u=r.local.map(w=>Yn(o.localRoot,{path:w,offset:0})?.[0]).map(w=>w&&t(w)).filter(Boolean).map(w=>({node:w,parent:w.parentNode,previous:w.previousSibling,next:w.nextSibling,fragment:ar(w)}));return s.set(r,u),u},l=r=>{let i=lr(o.localRoot,r);if(!i)return null;let u=t(i.startContainer),w=t(i.endContainer);if(!u||!w)return null;let c={...i,startContainer:u,endContainer:w};return Xn(c)?c:null};for(let r of e){let i=r.recovery;if(!i||n.has(i))continue;let u={subject:d(i.subject),span:null,scope:null,touched:new Set};if(i.text){u.span=l(i.text.local.span),u.scope=l(i.text.local.scope);let w=u.span;if(w){let c=w.startContainer.ownerDocument.createRange();c.setStart(w.startContainer,w.startOffset),c.setEnd(w.endContainer,w.endOffset);let h=p=>{if(c.intersectsNode(p)){u.touched.add(p);for(let y of p.childNodes)h(y)}};h(c.commonAncestorContainer)}}if(i.structure){for(let w of[i.structure.localPlacement])w&&(d(w.parent),w.before.forEach(d),w.after.forEach(d));for(let w of i.structure.localOrder||[])d(w)}n.set(i,u)}o.localState={states:n,refs:s}}function fr(e,o,t,n){let s=t.localState?.states.get(e);if(!s)return!1;let d=r=>{let i=r.node;if(!n(i)||i.parentNode!==r.parent)return!1;let u=w=>Array.prototype.indexOf.call(i.parentNode.childNodes,w);return!(r.previous&&n(r.previous)&&r.previous.parentNode===i.parentNode&&u(r.previous)>=u(i)||r.next&&n(r.next)&&r.next.parentNode===i.parentNode&&u(r.next)<=u(i))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!s.subject.length||!s.subject.every(d))return!1;if(e.text){let r=e.text.local,i=u=>u&&n(u.startContainer)&&n(u.endContainer);return i(s.span)&&i(s.scope)&&qn(s.scope,e.text.encoding)===r.text&&qn(s.span,e.text.encoding)===r.text.slice(r.start,r.end)}if(e.attribute){let r=e.attribute,i=s.subject[0].node;return(r.namespaceURI?i.getAttributeNS(r.namespaceURI,r.localName):i.getAttribute(r.qualifiedName))===o.local}let l=e.structure;if(l.localOrder){let r=-1,i=null;for(let u of l.localOrder){let w=t.localState.refs.get(u)?.[0]?.node;if(!w||!n(w)||i&&w.parentNode!==i)return!1;let c=Array.prototype.indexOf.call(w.parentNode.childNodes,w);if(c<=r)return!1;i=w.parentNode,r=c}return!0}return l.localAction==="moved"||s.subject.every(r=>ar(r.node)===r.fragment)}var Wi=1,ln=e=>!!e&&e.nodeType===1,Wo=e=>ln(e)&&e.tagName==="TEMPLATE"&&!!e.content;function Jn(e,o=null,t=null){let n=new Map,s=new Map,d=w=>{if(!o){o=new WeakMap;let c=[e];for(;c.length;){let h=c.pop();Wo(h)&&(o.set(h.content,h),c.push(h.content));for(let p=h.firstChild;p;p=p.nextSibling)p.nodeType===1&&c.push(p)}}return o.get(w)||null},l=(w,c)=>{let h=s.get(w);if(!h){h=new Map;let p=0;for(let y=w.firstChild;y;y=y.nextSibling)h.set(y,p++);s.set(w,h)}return h.get(c)},r=w=>{if(!w)return null;if(t&&t.has(w))return r(t.get(w));if(w===e)return[];let c=n.get(w);if(c!==void 0)return c;let h=w.parentNode,p=null;if(h&&h.nodeType===11){let y=d(h),C=y?r(y):null;C&&(p=C.concat(["content",l(h,w)]))}else if(h){let y=r(h);y&&(p=y.concat([l(h,w)]))}return n.set(w,p),p};return{root:e,pathOf:r,logicalParent:w=>{let c=w.parentNode;return c&&c.nodeType===11?d(c):c},indexIn:l,containerPath:w=>{if(w.nodeType===11){let h=d(w),p=r(h);return p?p.concat(["content"]):null}let c=r(w);return c&&Wo(w)?c.concat(["content"]):c},ownerOf:d}}var An=e=>Wo(e)?e.content:e;function ur(e){let{L:o,R:t,unitsOf:n,provenance:s,policy:d}=e,l=[];return{note:(w,c)=>{l.push([w,c])},finish:w=>l.length?u(w):null};function u(w){let c={base:Jn(e.roots.base),local:Jn(e.roots.local),remote:Jn(e.roots.remote)},h=A=>A==="local"?o:t,p=(A,j)=>{if(!j)return null;if(A.map.has(j))return A.map.get(j);let Y=[],J=ln(j)?c.base.logicalParent(j):j.parent;for(;J&&!A.map.has(J);J=c.base.logicalParent(J))Y.push(J);if(!J||!A.identical.has(J))return null;let se=A.map.get(J);for(let je=Y.length-1;je>=0&&se;je--)se=An(se).childNodes[c.base.indexIn(Y[je].parentNode,Y[je])];return se?ln(j)?An(se).childNodes[c.base.indexIn(j.parentNode,j)]||null:n(se)[n(j.parent).indexOf(j)]||null:null},y=new Map,C=new Map,g=new WeakMap,f=0,m=(A,j)=>{let Y=y.get(A);Y||y.set(A,Y=[]),Y.push(j)};(function A(j){C.set(j,f++);let Y=s.get(j);if(Y&&!Y.pinned){for(let J of[Y.base,Y.local,Y.remote])if(J)if(Array.isArray(J))for(let se of J)m(se,j);else m(J,j)}if(Wo(j)){g.set(j.content,j);for(let J=j.content.firstChild;J;J=J.nextSibling)A(J)}for(let J=j.firstChild;J;J=J.nextSibling)A(J)})(w);let R=new Map;c.out=Jn(w,g,R);let S={refs:new Map,spans:new Map,anchors:new Map,via:R,outOwners:g,outRoot:w,localRoot:e.roots.local},O=A=>ln(A)?[A]:A.nodes,E=(A,j)=>{let Y=c[j].logicalParent(A);if(!Y)return null;for(let J of n(Y))if(!ln(J)&&J.nodes.includes(A))return J;return null},P=(A,j)=>A==null?null:Array.isArray(A)?A.length?E(A[0],j):null:A,v=A=>{let j=new Set,Y=[];for(let J of A)for(let se of y.get(J)||[])j.has(se)||(j.add(se),Y.push(se));return Y.sort((J,se)=>C.get(J)-C.get(se))},N=new Map,L=A=>{let j=A.b||A.l||A.r,Y=N.get(j);if(Y)return Y;let J=[];for(let se of[A.b,A.l,A.r])se&&J.push(...O(se));return Y=v(J),N.set(j,Y),Y},D=A=>({b:A,l:p(o,A),r:p(t,A)}),B=(A,j)=>{let Y=h(j).reverse.get(A);if(Y)return D(Y);for(let J of v(O(A))){let se=s.get(J);if(se&&!se.base&&se.local&&se.remote)return{b:null,l:P(se.local,"local"),r:P(se.remote,"remote")}}return j==="local"?{b:null,l:A,r:null}:{b:null,l:null,r:A}},M=new Map,x=A=>{let j=s.get(A);if(!j||j.pinned)return null;let Y=P(j.base,"base");if(Y)return D(Y);let J=P(j.local,"local"),se=P(j.remote,"remote");if(J){let je=o.reverse.get(J);if(je)return D(je)}if(se){let je=t.reverse.get(se);if(je)return D(je)}return J||se?{b:null,l:J,r:se}:null},k=A=>(M.has(A)||M.set(A,x(A)),M.get(A)),z=(A,j)=>ln(A)?c[j].logicalParent(A):A.parent,U=new Map,K=new Map,Ae=(A,j)=>(ln(A)?[c[j].pathOf(A)]:A.nodes.map(Y=>c[j].pathOf(Y))).filter(Boolean),Me=A=>{let j=A.b||A.l||A.r,Y=A.b?"base":A.l?"local":"remote",J=K.get(j);if(J)return J;let se=!ln(j),je=Ae(j,Y)[0],Z=`${Y[0]}:${JSON.stringify(je===void 0?null:je)}${se?":run":""}`,Ie=U.get(Z);if(Ie)return K.set(j,Ie),Ie;let He=L(A);return Ie={key:Z,nodeType:ln(j)?1:j.kind==="comment"?8:3,base:A.b?Ae(A.b,"base"):[],local:A.l?Ae(A.l,"local"):[],remote:A.r?Ae(A.r,"remote"):[],merged:He.map(Ce=>c.out.pathOf(Ce)).filter(Boolean),live:[]},U.set(Z,Ie),K.set(j,Ie),S.refs.set(Ie,He),Ie},Be={base:new Map,local:new Map,remote:new Map},te=new Map,ve=(A,j)=>{let Y=z(A,j);if(!Y||Y.nodeType!==1)return null;let J=Be[j].get(Y);if(!J){let je=n(Y),Z=Ie=>Me(j==="base"?D(Ie):B(Ie,j));J={parent:Z(Y),refs:je.map(Z),index:new Map(je.map((Ie,He)=>[Ie,He]))},Be[j].set(Y,J)}let se=J.index.get(A)??-1;return{parent:J.parent,before:J.refs.slice(se+1),after:J.refs.slice(0,Math.max(0,se)).reverse()}},ze=A=>{let j=A.parentNode;if(!j)return null;let Y=te.get(j);if(!Y){let se=j.nodeType===11?g.get(j):j,je=se&&se.nodeType===1?k(se):null;if(!je)return null;let Z=[],Ie=[],He=new Map;for(let be of j.childNodes){let H=k(be),G=H&&Me(H),de=Z.length,pe=Z.length-1;G&&G!==Z[pe]&&(Z.push(G),pe++);let ce={ref:G,group:pe,after:de};Ie.push(ce),He.set(be,ce)}let Ce=Z.length;for(let be=Ie.length-1;be>=0;be--){let H=Ie[be];H.before=Ce,H.ref&&(Ce=H.group)}Y={parent:Me(je),refs:Z,index:He},te.set(j,Y)}let J=Y.index.get(A);return{parent:Y.parent,before:Y.refs.slice(J.before),after:Y.refs.slice(0,J.after).reverse()}},re=A=>ln(A)?A.outerHTML:A.value,b=A=>ln(A)?"element":A.kind==="comment"?"comment":"text",_=(A,j)=>({path:A,offset:j}),oe=(A,j,Y)=>{if(!A)return null;let J=c[Y],se=0;if(j){let je=ln(j)?j:j.nodes[j.nodes.length-1];je.parentNode&&(se=J.indexIn(je.parentNode,je)+1)}return _(J.containerPath(A),se)},ee=(A,j)=>{let Y=z(A,"base"),J=Y?p(h(j),Y):null;if(!ln(J))return null;let se=n(Y),je=null;for(let Z=se.indexOf(A)-1;Z>=0&&!je;Z--){let Ie=p(h(j),se[Z]);Ie&&z(Ie,j)===J&&(je=Ie)}return oe(J,je,j)},Pe=(A,j,Y,J)=>{let se=c[J],je=0;for(let Z=0;Z<A.nodes.length;Z++){let Ie=A.nodes[Z],He=Ie.nodeValue.length,Ce=Z===A.nodes.length-1;if((Y==="start"?j<je+He:j<=je+He)||Ce)return _(se.pathOf(Ie),Math.max(0,Math.min(j-je,He)));je+=He}return null},Ke=(A,j)=>{let Y=c[j],J=A.firstChild,se=A.lastChild;return J&&J.nodeType===3&&se.nodeType===3?{start:_(Y.pathOf(J),0),end:_(Y.pathOf(se),se.nodeValue.length)}:{start:_(Y.pathOf(A),0),end:_(Y.pathOf(A),A.childNodes.length)}},Ne=(A,j,Y)=>{for(let Z of A.nodes)if(Y==="start"?Z.s<=j&&j<Z.e:Z.s<j&&j<=Z.e)return{kind:"text",node:Z.node,offset:j-Z.s};let J=Y==="start"?j:j-1,se=()=>{for(let Z of A.nodes)if(Z.s===j||Z.e===j)return{kind:"text",node:Z.node,offset:j-Z.s};return null},je=A.atomAt.get(J);if(je)return{kind:Y==="start"?"before":"after",node:je.el};if(A.text[J]===yt){let Z=A.marks.find(He=>He.block&&He.to===J+1);if(Z)return Y==="start"?{kind:"end",node:Z.el}:{kind:"after",node:Z.el};let Ie=A.marks.find(He=>He.block&&He.from===J+1);if(Ie)return Y==="start"?{kind:"before",node:Ie.el}:{kind:"startOf",node:Ie.el}}return se()},ot=(A,j)=>Ne(A,j,"end")||Ne(A,j,"start"),Qe=(A,j)=>{switch(j.kind){case"text":return _(A.pathOf(j.node),j.offset);case"end":return _(A.containerPath(j.node),An(j.node).childNodes.length);case"startOf":return _(A.containerPath(j.node),0);default:{let Y=j.node.parentNode;return _(A.containerPath(Y),A.indexIn(Y,j.node)+(j.kind==="after"?1:0))}}},Ze=(A,j,Y,J,se)=>{let je=Ne(A,j,Y);return je?Qe(c[J],je):se()},Xe=(A,j,Y,J)=>{let se=A.textNodes.map(Ce=>({s:Ce.ms,e:Ce.me,start:{kind:"text",node:Ce.node,offset:0},end:{kind:"text",node:Ce.node,offset:Ce.me-Ce.ms}}));for(let[Ce,be]of A.atomOut)se.push({s:Ce,e:Ce+1,start:{kind:"before",node:be},end:{kind:"after",node:be}});for(let[Ce,be]of A.breakOut)se.push({s:Ce,e:Ce+1,start:{kind:"end",node:be},end:{kind:"after",node:be}});for(let Ce of se)if(Ce.start.kind==="text"&&Ce.s<j&&j<Ce.e)return{kind:"text",node:Ce.start.node,offset:j-Ce.s};if(Y!=="empty"){let Ce=se.find(be=>Y==="start"?be.s===j:be.e===j);if(Ce)return Y==="start"?Ce.start:Ce.end}let je=se.find(Ce=>Ce.e===j);if(je)return je.end;let Z=se.find(Ce=>Ce.s===j);if(Z)return Z.start;let Ie=null,He=null;for(let Ce of se)Ce.e<=j&&(!Ie||Ce.e>Ie.e)&&(Ie=Ce),Ce.s>=j&&(!He||Ce.s<He.s)&&(He=Ce);return Ie?Ie.end:He?He.start:J()},wt=(A,j)=>{if(!j)return null;if(j.kind==="text"){let se=A.nodes.find(je=>je.node===j.node);return se?se.s+Math.min(j.offset,se.e-se.s):null}let Y=A.atoms.find(se=>se.el===j.node);if(Y)return j.kind==="after"?Y.i+1:Y.i;let J=A.marks.find(se=>se.el===j.node);return J?j.kind==="before"&&J.block&&A.text[J.from-1]===yt&&!A.marks.some(se=>se.block&&se.to===J.from)?J.from-1:j.kind==="startOf"||j.kind==="before"?J.from:j.kind==="end"&&J.block?J.to-1:J.to:null},dt=(A,j,Y,J)=>{for(let Ie of A.nodes)if(Y==="start"?Ie.s<=j&&j<Ie.e:Ie.s<j&&j<=Ie.e)return{kind:"text",node:Ie.node,offset:j-Ie.s};let se=Y==="start"?j:j-1;if(!A.atomAt.has(se)&&A.text[se]!==yt){for(let Ie of A.nodes)if(Ie.s===j||Ie.e===j)return{kind:"text",node:Ie.node,offset:j-Ie.s}}let je=A.atomAt.get(se);if(je)return{kind:Y==="start"?"before":"after",node:je.el};if(A.text[se]===yt){let Ie=A.marks.find(Ce=>Ce.block&&Ce.to===se+1);if(Ie)return Y==="start"?{kind:"end",node:Ie.el}:{kind:"after",node:Ie.el};let He=A.marks.find(Ce=>Ce.block&&Ce.from===se+1);if(He)return Y==="start"?{kind:"before",node:He.el}:{kind:"startOf",node:He.el}}let Z=A.marks.find(Ie=>Ie.block&&Ie.from===j);return Z?{kind:"startOf",node:Z.el}:J?{kind:Y==="start"?"startOf":"end",node:J}:null},gt=A=>{if(!A)return null;if(A.kind==="wholeStart"||A.kind==="wholeEnd"){let j=zt(A.node);return A.kind==="wholeStart"?j.start:j.end}return Qe(c.out,A)},zt=A=>{let j=A.firstChild,Y=A.lastChild;return j&&j.nodeType===3&&Y.nodeType===3?{start:_(c.out.pathOf(j),0),end:_(c.out.pathOf(Y),Y.nodeValue.length)}:{start:_(c.out.pathOf(A),0),end:_(c.out.pathOf(A),A.childNodes.length)}},_t=A=>{let j=z(A,"base"),Y=j?L(D(j))[0]:null;if(!Y)return null;let J=An(Y),se=n(j);for(let je=se.indexOf(A)-1;je>=0;je--){let Z=L(D(se[je])).filter(Ie=>Ie.parentNode===J);if(Z.length)return{kind:"after",node:Z[Z.length-1]}}return{kind:"startOf",node:Y}},Ht=(A,j,Y,J,se,je)=>({text:A,start:j,end:Y,fragment:J,span:se,scope:je}),Bt=(A,j,Y,J,se)=>Ht(A,j,Y,A.slice(j,Y),J,se),an=(A,j,Y,J,se)=>(S.spans.set(A,{start:j,end:Y,scopeStart:J,scopeEnd:se}),A),Kt=new Map,$t=new Map,F=(A,j,Y)=>{let J=`text:${A.key}:${j}:${Y}`,se=$t.get(J)||0;return $t.set(J,se+1),`${J}:${se}`},le=(A,j)=>{let Y,J,se,je="plain",Z,Ie,He,Ce,be,H=(pe,ce,xe,ne,$)=>{if(!pe){let fe=ee($,ne);return Bt("",0,0,{start:fe,end:fe},{start:fe,end:fe})}return Bt(pe.value,ce,xe,{start:Pe(pe,ce,ce===xe?"end":"start",ne),end:Pe(pe,xe,"end",ne)},{start:Pe(pe,0,"start",ne),end:Pe(pe,pe.value.length,"end",ne)})};if(j.site==="run"){let{bRun:pe,lRun:ce,rRun:xe,node:ne,c:$}=j;Y=D(pe),J=$.bs,se=$.be,Z=H(pe,$.bs,$.be,"base",pe),Ie=H(ce,$.ls,$.le,"local",pe),He=H(xe,$.rs,$.re,"remote",pe);let fe=ne?ne.nodeValue:"",Ee=Re=>ne?{kind:"text",node:ne,offset:Re}:_t(pe);Ce=an(Bt(fe,$.ms,$.me,{start:gt(Ee($.ms)),end:gt(Ee($.me))},{start:gt(Ee(0)),end:gt(Ee(fe.length))}),Ee($.ms),Ee($.me),Ee(0),Ee(fe.length)),be=ne||(_t(pe)||{}).node||null}else if(j.site==="whole"){let pe=j.el,ce=s.get(pe);Y=D(ce.base),J=0,se=A.base.length;let xe=($,fe,Ee)=>{let Re=Ke(fe,Ee);return Bt($,0,$.length,Re,Re)};Z=xe(A.base,ce.base,"base"),Ie=xe(A.local,ce.local,"local"),He=xe(A.remote,ce.remote,"remote");let ne=zt(pe);Ce=an(Bt(A.resolved,0,A.resolved.length,ne,ne),{kind:"wholeStart",node:pe},{kind:"wholeEnd",node:pe},{kind:"wholeStart",node:pe},{kind:"wholeEnd",node:pe}),be=pe}else if(j.site==="comment"){let{bRun:pe,lRun:ce,rRun:xe,node:ne}=j;Y=D(pe),J=0,se=A.base.length;let $=(Ve,Oe)=>{if(!Ve){let T=ee(pe,Oe);return Bt("",0,0,{start:T,end:T},{start:T,end:T})}let $e=Ve.nodes[0],tt={start:_(c[Oe].pathOf($e),0),end:_(c[Oe].pathOf($e),Ve.value.length)};return Bt(Ve.value,0,Ve.value.length,tt,tt)};Z=$(pe,"base"),Ie=$(ce,"local"),He=$(xe,"remote");let fe=A.resolved,Ee=Ve=>ne?{kind:"text",node:ne,offset:Ve}:_t(pe),Re={start:gt(Ee(0)),end:gt(Ee(fe.length))};Ce=an(Bt(fe,0,fe.length,Re,Re),Ee(0),Ee(fe.length),Ee(0),Ee(fe.length)),be=ne||(_t(pe)||{}).node||null}else{let{fb:pe,fl:ce,fr:xe,scope:ne}=j,$=j.merged;je="html",Y=ne.base?D(ne.base):B(ne.local,"local"),J=A.bs,se=A.be;let fe=Ue=>{let _e=ne[Ue];for(let Ge=ne.at-1;Ge>=0;Ge--){let et=ne.units[Ge],Mt=Ue==="base"?et:p(h(Ue),et);if(Mt&&z(Mt,Ue)===_e)return Mt}return null},Ee=Ue=>()=>oe(ne[Ue],fe(Ue),Ue),Re=(Ue,_e,Ge,et,Mt)=>{let kt=Gt=>Gt?Qe(c[Mt],Gt):Ee(Mt)(),Jt=_e===Ge?ot(Ue,_e):Ne(Ue,_e,"start"),Ot=_e===Ge?ot(Ue,_e):Ne(Ue,Ge,"end"),pt=kt(Jt),bt={start:pt,end:_e===Ge?pt:kt(Ot)},mt=j.full?j.full(Mt):null;if(!mt)return Ht(Ue.text,_e,Ge,et,bt,{start:kt(Ne(Ue,0,"start")),end:kt(Ne(Ue,Ue.text.length,"end"))});let Ct=Jt?wt(mt,Jt):null,at=Ot?wt(mt,Ot):null,Vt=Ct===null?0:Ct,St=Math.max(Vt,at===null?mt.text.length:at),cn=kt(Ne(mt,0,"start"));return Ht(mt.text,Vt,St,so(mt,Vt,St),bt,{start:cn,end:mt.text.length?kt(Ne(mt,mt.text.length,"end")):cn})};Z=j.synthetic?null:Re(pe,A.bs,A.be,A.base,"base"),Ie=Re(ce,A.lss,A.lse,A.local,"local"),He=Re(xe,A.rss,A.rse,A.remote,"remote");let[Ve,Oe]=A.range||[0,0],$e=$.out,tt=()=>{let Ue=An($.node);for(let _e=ne.at-1;_e>=0;_e--){let Ge=L(D(ne.units[_e])).filter(et=>et.parentNode===Ue);if(Ge.length)return{kind:"after",node:Ge[Ge.length-1]}}for(let _e=ne.at;_e<ne.units.length;_e++){let Ge=L(D(ne.units[_e])).filter(et=>et.parentNode===Ue);if(Ge.length)return{kind:"before",node:Ge[0]}}return{kind:"startOf",node:$.node}};if($e.via)for(let[Ue,_e]of $e.via)R.set(Ue,_e);let T=Xe($,Ve,Ve===Oe?"empty":"start",tt),q=Ve===Oe?T:Xe($,Oe,"end",tt),Q=$e.text.length?dt($e,0,"start",$.node):tt(),we=$e.text.length?dt($e,$e.text.length,"end",$.node):Q,ue=wt($e,T),ie=wt($e,q),ae=ue===null?0:ue,De=Math.max(ae,ie===null?$e.text.length:ie);Ce=an(Ht($e.text,ae,De,so($e,ae,De),{start:gt(T),end:gt(q)},{start:gt(Q),end:gt(we)}),T,q,Q,we);let qe=S.spans.get(Ce);if(qe.flat=$e,!$e.text.length){let Ue=gt(Q),_e=Yn(w,Ue),Ge=_e[0],et=_e[1];qe.empty={parent:Ge.nodeType===11?g.get(Ge):Ge,previous:Ge.childNodes[et-1]||null,next:Ge.childNodes[et]||null}}be=T?T.node:$.node}let G=Me(Y),de=(j.site==="whole"||j.site==="comment"||(j.policy||d)!=="both")&&A.resolved!==A.local;return{key:j.site==="comment"&&Kt.get(Y.b||Y.l||Y.r)||F(G,J,se),subject:G,localLost:de,anchor:be,text:{encoding:je,base:Z,local:Ie,remote:He,merged:Ce,liveSpan:null,liveScope:null}}},ge=(A,j)=>{let Y=k(j.el),J=Me(Y),se=j.sample;return{key:`attr:${J.key}:${se.namespaceURI||""}:${se.localName}`,subject:J,localLost:A.resolved!==A.local,anchor:j.el,attribute:{namespaceURI:se.namespaceURI||null,localName:se.localName,qualifiedName:se.name}}},me=(A,j)=>{let Y=A.detail,J=j.unit||D(j.subject),se=Me(J),je=S.refs.get(se),Z=J.l?ve(J.l,"local"):null,Ie=J.r?ve(J.r,"remote"):null,He=je.length?ze(je[0]):null,Ce,be,H,G=null,de=null,pe=j.deleted;switch(Y){case"both-reordered":{Ce=be="reordered";let ce=new Set(j.rKept),xe=j.lKept.filter(Re=>ce.has(Re)&&L(D(Re)).length),ne=Re=>C.get(L(D(Re))[0]);G=xe.map(Re=>Me(D(Re))),de=xe.slice().sort((Re,Ve)=>ne(Re)-ne(Ve)).map(Re=>Me(D(Re)));let $=Re=>!ln(Re)&&Re.kind!=="comment"&&Re.nodes.every(Ve=>!/[^\t\n\f\r ]/.test(Ve.data)),fe=xe.filter(Re=>!$(Re)),Ee=fe.slice().sort((Re,Ve)=>ne(Re)-ne(Ve));H=fe.some((Re,Ve)=>Re!==Ee[Ve]);break}case"both-moved":Ce=be="moved",H=!Z||!je.some(ce=>{let xe=ce===je[0]?He:ze(ce);return xe&&xe.parent===Z.parent});break;case"edit-beats-delete":Ce=pe==="local"?"deleted":"edited",be=pe==="remote"?"deleted":"edited",H=pe==="local";break;case"move-beats-delete":Ce=pe==="local"?"deleted":"moved",be=pe==="remote"?"deleted":"moved",H=pe==="local";break;case"remote-wins":Ce="edited",be="edited",H=!0;break;default:Ce=be="inserted",H=j.localLost}return{key:`structure:${se.key}:${Y}`,subject:se,localLost:H,anchor:je[0]||null,structure:{localAction:Ce,remoteAction:be,localPlacement:Z,remotePlacement:Ie,mergedPlacement:He,localOrder:G,mergedOrder:de,localFragment:Y==="both-reordered"||!J.l?null:re(J.l),fragmentKind:b(J.b||J.l||J.r)}}};for(let[A,j]of l){if(A.kind!=="structure")continue;let Y=j.unit||D(j.subject),J=Y.b||Y.l||Y.r;!ln(J)&&J.kind==="comment"&&Kt.set(J,`structure:${Me(Y).key}:${A.detail}`)}let Te=new Map;for(let[A,j]of l){if(A.kind==="structure"){let je=Me(j.unit||D(j.subject)),Z=`structure:${je.key}:${A.detail}`,Ie=Te.get(Z);if(Ie&&Ie.structure){A.recovery=Ie;let He=S.refs.get(je);A.el==null&&He.length&&(A.el=ln(He[0])?He[0]:c.out.logicalParent(He[0]));continue}}let Y=A.kind==="text"?le(A,j):A.kind==="attr"?ge(A,j):me(A,j),J=Te.get(Y.key);J||(J={version:Wi,key:Y.key,localLost:Y.localLost,subject:Y.subject,applied:!1,unavailable:null},Te.set(Y.key,J),S.anchors.set(J,Y.anchor)),Y.text&&(J.text=Y.text),Y.attribute&&(J.attribute=Y.attribute),Y.structure&&(J.structure=Y.structure),Y.text&&(J.localLost=Y.localLost),A.recovery=J;let se=S.refs.get(Y.subject);A.kind==="structure"&&A.el==null&&se.length&&(A.el=ln(se[0])?se[0]:c.out.logicalParent(se[0])),A.kind==="text"&&A.node==null&&se.length&&Y.subject.nodeType===8&&(A.node=se[0])}return S}}function dr(e,o,t){if(!o)return;let{lookup:n,vetoed:s,vetoedAttrs:d,liveAttr:l}=t,r=t.ignored||(()=>!1),i=Jn(t.liveRoot),u=x=>!!x&&i.containerPath(x)!==null,w=x=>{let k=x.parentNode;return k&&k.nodeType===11?o.outOwners.get(k)||null:k},c=x=>{for(let k=x;k;k=w(k))if(o.via.has(k)&&(k=o.via.get(k)),s.has(k)||t.vetoedLive?.has(f(k)))return!0;return!1},h=x=>Array.from(An(x).children).filter(k=>!r(k)),p=(x,k)=>h(x)[h(k.parentNode).indexOf(k)],y=(x,k)=>{let z=null,U=null,K=0;for(let te=k.previousSibling;te;te=te.previousSibling){if(te.nodeType===1&&!r(te)){z=te;break}te.nodeType===3&&(K+=te.nodeValue.length)}for(let te=k.nextSibling;te&&!U;te=te.nextSibling)te.nodeType===1&&!r(te)&&(U=te);let Ae=z?p(x,z):null,Me=U?p(x,U):null;if(z&&!Ae||U&&!Me)return null;let Be=[];for(let te=Ae?Ae.nextSibling:An(x).firstChild;te&&te!==Me;te=te.nextSibling)te.nodeType===3&&Be.push(te);return Be.length?{nodes:Be,lead:K}:null},C=x=>{let k=[],z=x;for(;z&&!o.via.has(z);z=z.parentNode)k.push(z);if(!z||!k.length)return null;let U=f(o.via.get(z));for(let Me=k.length-1;Me>0&&U;Me--)U=p(U,k[Me]);if(!U)return null;let K=k[0];if(K.nodeType===3)return y(U,K);let Ae=K.nodeType===1?p(U,K):null;return Ae?{nodes:[Ae],lead:0}:null},g=x=>{let k=n(x),z=k?{nodes:Array.isArray(k)?k:[k],lead:0}:o.via.size?C(x):null;if(!z)return null;let U=z.nodes.filter(u);return U.length?{nodes:U,lead:z.lead}:null},f=x=>{let k=g(x);return k?k.nodes[0]:null},m=x=>{if(!x)return null;if(x.kind==="text"){let K=g(x.node);if(!K)return null;let Ae=K.nodes,Me=x.offset+K.lead,Be=0;for(let te=0;te<Ae.length;te++){let ve=Ae[te].nodeValue.length;if(Me<=Be+ve||te===Ae.length-1)return Me>=Be&&Me<=Be+ve?[Ae[te],Me-Be]:null;Be+=ve}return null}let k=f(x.node);if(!k)return null;if(x.kind==="end")return[An(k),An(k).childNodes.length];if(x.kind==="startOf")return[An(k),0];if(x.kind==="wholeStart")return k.firstChild?[k.firstChild,0]:[k,0];if(x.kind==="wholeEnd")return k.lastChild?[k.lastChild,k.lastChild.nodeValue.length]:[k,k.childNodes.length];let z=k.parentNode;if(!z)return null;let U=Array.prototype.indexOf.call(z.childNodes,k);return[z,x.kind==="after"?U+1:U]},R=x=>({blocks:new Set((x.flat?.marks||[]).filter(k=>k.block).map(k=>f(k.el)).filter(Boolean)),atoms:new Set((x.flat?.atoms||[]).map(k=>f(k.el)).filter(Boolean)),ignored:r}),S=(x,k,z,U)=>{if(!x||!k||!Xn(x)||!Xn(k))return!1;for(let Me of[x,k])if(!u(Me.startContainer)||!u(Me.endContainer))return!1;let K=z.merged;if(K.start===K.end&&(x.startContainer!==x.endContainer||x.startOffset!==x.endOffset))return!1;let Ae=R(U);return qn(k,z.encoding,Ae)===K.text&&qn(x,z.encoding,Ae)===K.text.slice(K.start,K.end)},O=new Map,E=x=>{let k=x.parentNode;return k?(O.has(k)||O.set(k,new Map(Array.from(k.childNodes,(z,U)=>[z,U]))),O.get(k).get(x)):-1},P=(x,k)=>{if(!k)return!1;let z=i.logicalParent(x);if(!k.parent.live.includes(z))return!1;let U=E(x);for(let[K,Ae]of[["before",1],["after",-1]]){let Me=U;for(let Be of k[K]){if(Be.live.includes(x))continue;let te=Be.live.filter(ze=>ze!==x&&ze.parentNode===x.parentNode);if(!te.length)continue;let ve=Ae===1?Math.min(...te.map(E)):Math.max(...te.map(E));if(Ae*(ve-Me)<=0)return!1;Me=ve}}return!0},v=x=>{let k=x.structure;if(k.mergedOrder){let z=new Set(x.subject.live.map(An)),U=null,K=-1;for(let Ae of k.mergedOrder){let Me=Ae.live.find(Be=>z.has(Be.parentNode));if(!Me||U&&Me.parentNode!==U||E(Me)<=K)return!1;U=Me.parentNode,K=E(Me)}return x.subject.live.length>0}return x.subject.live.some(z=>P(z,k.mergedPlacement))},N=(x,k)=>{let z=m(x),U=m(k);return z&&U?{startContainer:z[0],startOffset:z[1],endContainer:U[0],endOffset:U[1]}:null},L=new Set,D=x=>{if(!x||L.has(x))return;L.add(x);let k=[];for(let z of o.refs.get(x)||[]){let U=g(z);if(U)for(let K of U.nodes)k.includes(K)||k.push(K)}x.live=k},B=x=>{x&&(D(x.parent),x.before.forEach(D),x.after.forEach(D))},M=new Set;for(let x of e){let k=x.recovery;if(!k||M.has(k))continue;M.add(k),D(k.subject),k.structure&&(B(k.structure.localPlacement),B(k.structure.remotePlacement),B(k.structure.mergedPlacement),(k.structure.localOrder||[]).forEach(D),(k.structure.mergedOrder||[]).forEach(D));let z=o.anchors.get(k),U=z?f(z):null,K=!!U;if(k.text){let b=o.spans.get(k.text.merged),_=b?N(b.start,b.end):null,oe=b?N(b.scopeStart,b.scopeEnd):null;if(b?.empty){let ee=b.empty,Pe=ee.previous?{kind:"after",node:ee.previous}:{kind:"startOf",node:ee.parent},Ke=ee.next?{kind:"before",node:ee.next}:{kind:"end",node:ee.parent},Ne=N(Pe,Ke);!Ne||Ne.startContainer!==Ne.endContainer||Ne.startOffset!==Ne.endOffset?_=null:_=oe=Ne}S(_,oe,k.text,b)||(_=oe=null),k.text.liveSpan=_,k.text.liveScope=_?oe:null,_||(K=!1)}k.structure&&K&&(K=v(k)),k.attribute&&K&&(K=l(U,k.attribute,x.resolved));let Ae=(!!k.attribute||!!k.text&&U?.tagName==="TEXTAREA")&&!!d&&[z,U].some(b=>d.get(b)?.has(k.attribute?k.attribute.qualifiedName:"value")),Me=o.localState?.states.get(k),Be=!!k.text&&[...t.removedVetoes||[]].some(b=>Me?.touched.has(b)),te=k.structure?.localAction==="inserted"&&[...s].some(b=>b===z||z?.contains(b)),ve=z&&c(z)||Ae||Be||te,ze=ve&&fr(k,x,o,u);ze&&(Be||te&&k.localLost)&&(K=!1);let re=!K&&ze&&ve;k.applied=K,k.unavailable=K?null:re?"hook-veto":"missing-output",re&&(k.localLost=!1),!K&&k.text&&(k.text.liveSpan=k.text.liveScope=null)}}function Ko(e,o,t){let n=Jn(o),s=Jn(t),d=c=>!!c&&s.containerPath(c)!==null,l=c=>{if(c===o)return t;let h=n.pathOf(c);if(h&&o!==t){let p=Yn(t,{path:h,offset:0});if(p&&p[0].nodeType===c.nodeType)return p[0]}return c},r=new Set,i=c=>{!c||r.has(c)||(r.add(c),c.live=c.live.map(l).filter(d))},u=c=>{c&&(c.startContainer=l(c.startContainer),c.endContainer=l(c.endContainer))},w=new Set;for(let c of e){c.node===o&&t.tagName==="SCRIPT"&&(c.node=t),c.el===o&&c.kind==="structure"&&(c.el=t);let h=c.recovery;if(!h||w.has(h))continue;if(w.add(h),i(h.subject),h.text){u(h.text.liveSpan),u(h.text.liveScope);let y=h.text.liveSpan,C=h.text.liveScope,g=h.text.merged,f=m=>!!m&&Xn(m)&&d(m.startContainer)&&d(m.endContainer);(!f(y)||!f(C)||qn(C,h.text.encoding)!==g.text||qn(y,h.text.encoding)!==g.text.slice(g.start,g.end))&&(h.text.liveSpan=null,h.text.liveScope=null,h.applied=!1,h.unavailable="missing-output")}let p=h.structure;if(p){for(let y of[p.localPlacement,p.remotePlacement,p.mergedPlacement])y&&(i(y.parent),y.before.forEach(i),y.after.forEach(i));(p.localOrder||[]).forEach(i),(p.mergedOrder||[]).forEach(i),h.subject.live.length||(h.applied=!1,h.unavailable="missing-output")}}}var co=e=>e?.nodeType===1,To=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function Ki({provenance:e,parentOf:o,twins:t,baseOf:n,build:s,ignored:d,remoteWins:l,discarded:r}){let i=new Map,u=new WeakMap;function w(p,y,C,g=!1){if(!co(p)||!co(C))return null;let f=i.get(p);if(f)(g||!f.selected&&y==="remote")&&(f.parent=o(C),f.port=C,f.sourceSide=y,f.selected=g);else{let m=u.get(p)||null;f={owner:p,parent:o(C),port:C,sourceSide:y,originalParent:o(p),originalPort:p,selected:g,state:m?"built":"planned",output:m,disposition:null},i.set(p,f)}return f}function c(p,y){if(!co(p)||!co(y))return;u.has(p)||u.set(p,y);let C=i.get(p);C&&C.state!=="attached"&&!C.output&&(C.output=y,C.state="built")}function h(p){if(!i.size)return;let y=new Map,C=new WeakMap,g=new WeakMap,f=new WeakSet,m=new Set,R=(B,M)=>{if(!B)return;if(Array.isArray(B)){for(let k of B)R(k,M);return}let x=y.get(B);x||y.set(B,x=[]),x.push(M)},S=(B,M)=>{if(!B)return;let x=[B];for(;x.length;){let k=x.pop();R(k,M);for(let z of To(k).childNodes)x.push(z)}};function O(B,M=null,x=!1){if(f.has(B))return;f.add(B),C.set(B,M);let k=e.get(B),z=x||!!(k&&l(k.remote||k.base));g.set(B,z);let U={node:B,kind:"node",authority:z};if(k?.pinned)S(k.local,{...U,kind:"ignored"});else if(k?.unchanged)for(let K of[k.base,k.local,k.remote])S(K,{...U,kind:"unchanged"});else if(k){for(let K of[k.base,k.local,k.remote])R(K,U);if(co(k.local))for(let K of To(k.local).children)d(K)&&S(K,{...U,kind:"ignored"})}for(let K of To(B).childNodes)O(K,B,z)}let E=B=>{if(B.output&&f.has(B.output))return B.state="attached",B.disposition="node",!0;let{local:M,remote:x}=t(B.owner);for(let k of[B.owner,M,x]){let z=y.get(k);if(z?.length){let U=z.find(K=>K.kind==="node")||z[0];return B.output=U.node,B.state="attached",B.disposition=U.kind,!0}}return!1},P=(B,M)=>(y.get(B)||[]).find(k=>k.kind==="node"&&co(k.node)&&(!k.authority||M.sourceSide==="remote"))?.node,v=(B,M,x)=>{let k=y.get(B)||[],z=x?[...k].reverse():k;for(let U of z){if(U.kind!=="node")continue;let K=U.node;for(;K&&C.get(K)!==M;)K=C.get(K);if(K)return K}return null},N=(B,M,x)=>{let k=To(M);for(let z=x?.previousSibling;z;z=z.previousSibling){let U=v(z,M,!0);if(U){k.insertBefore(B,U.nextSibling);return}}for(let z=x?.nextSibling;z;z=z.nextSibling){let U=v(z,M,!1);if(U){k.insertBefore(B,U);return}}k.appendChild(B)};function L(B,M,x){let k=M==="base"?B:n(B,M),z=i.get(k);z&&z!==x&&D(z)}function D(B){if(B.state==="attached"||B.disposition==="remote-wins"||m.has(B)||E(B))return;m.add(B);let{local:M,remote:x}=t(B.owner);if(l(x||B.owner)){if(!x){B.disposition="remote-wins",r(B.owner,M),m.delete(B);return}B.parent=o(x),B.port=x,B.sourceSide="remote"}if(L(B.parent,B.sourceSide,B),E(B)){m.delete(B);return}let k=P(B.parent,B),z=B.port;if(!k){if(L(B.originalParent,"base",B),E(B)){m.delete(B);return}let K=B.originalParent;for(z=B.originalPort;K&&!k;)k=P(K,B),k||(z=K,K=o(K))}if(!k)throw new Error("A planned move has no allowed surviving parent");let U=B.output||s(B.owner);B.output=U,B.state="built",N(U,k,z),O(U,k,g.get(k)||!1),E(B),m.delete(B)}O(p);for(let B of i.values())D(B)}return{planned:i,has:p=>i.has(p),plan:w,produced:c,drain:h}}function fo(e,o,t,n,s,d,l,r,i,u,w,c,h){let p=null;return Ki({provenance:e,parentOf:g=>{if(!g)return null;let f=o(g);if(f||g.parentNode?.nodeType!==11)return f;if(!p){p=new WeakMap;let m=[c,h];for(;m.length;){let R=m.pop(),S=To(R);S!==R&&p.set(S,R);for(let O of S.children)m.push(O)}}return p.get(g.parentNode)||null},twins:g=>({local:s(t,g),remote:s(n,g)}),baseOf:(g,f)=>g&&(f==="local"?t:n).reverse.get(g)||null,build:g=>d(g,s(t,g),s(n,g),!1),ignored:l,remoteWins:r,discarded:(g,f)=>{f&&w(g,f,t)&&!i.some(m=>m.detail==="remote-wins"&&m.base===g)&&u({kind:"structure",el:null,detail:"remote-wins",base:g,local:f,remote:null},{subject:g})}})}function Fi({parent:e,base:o,views:t,eligible:n,ignored:s,remoteWins:d,budget:l=qt(2e4*32),maxUnits:r=256,maxCharacters:i=2e4}){let u=(f,m=null)=>({status:f,reason:m,parent:e,records:[]});if(t.some(({V:f})=>f.asBase)||s(e)||d(e)||t.some(({V:f})=>!f.el||s(f.el)||d(f.el)))return u("none");let w=o.length+t[0].V.units.length+t[1].V.units.length;if(w>r)return u("fallback","unit-limit");let c=Symbol(),h=f=>{if(f>l.remaining)throw c;l.remaining-=f,l.crossParentSteps=(l.crossParentSteps||0)+f},p=new Map,y=0,C=f=>{if(h(1),p.has(f))return p.get(f);let m=f.nodeType===1?f.childNodes:f.nodes;h(m.length*4+1);let R=f.nodeType===1?Array.from(m):m,S=0;for(let P=0;P<R.length;P++){let v=R[P];if(v.nodeType!==3||P&&R[P-1].nextSibling!==v)return p.set(f,null),null;S+=v.data.length}if(S>i-y)throw c;h(S*8+1),y+=S;let O=en(R);if(O.text.includes(yt))return p.set(f,null),null;let E={unit:f,nodes:R,flat:O};return p.set(f,E),E},g=[];try{h(w*8+1);for(let f=0;f<2;f++){let m=t[f].V,R=t[1-f].V,S=[],O=new Map;for(let E=0;E<o.length;E++){h(1);let P=o[E];if(P.kind!=="text"||m.twin(P))continue;let v=R.twin(P);if(!v||v.kind!=="text"||!R.here(v))continue;let N=C(P),L=C(v);if(!N||!L||!/\S/.test(N.flat.text))continue;h(N.flat.text.length*2+1);let D=N.flat.text;O.set(D,(O.get(D)||0)+1),S.push({source:P,opposite:v,sourceModel:N,oppositeModel:L,index:E})}for(let E of S){let{source:P,opposite:v,sourceModel:N,oppositeModel:L,index:D}=E,B=[];for(let _ of[-1,1]){h(1);let oe=o[D+_];if(!oe||oe.nodeType!==1||!n(oe)||s(oe)||d(oe))continue;let ee=N.nodes[0],Pe=N.nodes.at(-1);if(_===-1?ee?.previousSibling!==oe:Pe?.nextSibling!==oe)continue;let Ke=m.twin(oe),Ne=R.twin(oe);if(!Ke||!Ne||!m.here(Ke)||R.here(Ne)||m.baseOf(Ke)!==oe||R.baseOf(Ne)!==oe||!n(Ke)||!n(Ne)||s(Ke)||s(Ne)||d(Ke)||d(Ne)||Ke.tagName!==oe.tagName||Ne.tagName!==oe.tagName||Ke.namespaceURI!==oe.namespaceURI||Ne.namespaceURI!==oe.namespaceURI)continue;let ot=C(oe),Qe=C(Ke),Ze=C(Ne);if(!ot||!Qe||!Ze||!/\S/.test(ot.flat.text))continue;let Xe=ot.flat.text,wt=N.flat.text,dt=Qe.flat.text;if(h((Xe.length+wt.length+dt.length)*3+1),dt.length!==Xe.length+wt.length)continue;let gt=_===-1;(gt?!dt.startsWith(Xe)||!dt.endsWith(wt):!dt.startsWith(wt)||!dt.endsWith(Xe))||B.push({owner:oe,target:Ke,moved:Ne,ownerBase:ot,joined:Qe,ownerOther:Ze,targetFrom:gt?Xe.length:0,retainedFrom:gt?0:wt.length})}if(!B.length)continue;if(B.length!==1||O.get(N.flat.text)!==1)return u("fallback","ambiguous-origin");let M=B[0],{owner:x,target:k,moved:z,ownerBase:U,joined:K,ownerOther:Ae,targetFrom:Me,retainedFrom:Be}=M;if(h(g.length+1),g.some(_=>_.owner===x))return u("fallback","ambiguous-owner");let te={source:P,target:k,from:0,to:N.flat.text.length,targetFrom:Me},ve=Ln({base:N.flat,side:K.flat,retained:[],transfers:[{from:te.from,to:te.to,target:Me,destination:x}],budget:l});if(ve.status!=="ready"||ve.covers(te.from,te.to)!==!0)return u("fallback",ve.reason||"work-limit");let ze=[{unit:P,model:N,from:0,to:N.flat.text.length},null,null];ze[f+1]={unit:k,model:K,from:Me,to:Me+N.flat.text.length},ze[2-f]={unit:v,model:L,from:0,to:L.flat.text.length};let re=[U,null,null];re[f+1]=K,re[2-f]=Ae;let b=[x,null,null];b[f+1]=k,b[2-f]=z,g.push({side:f,parent:e,source:P,target:k,owner:x,owners:b,ownerModels:re,native:ze,models:p,runs:[te],proof:ve,retained:[{source:x,target:k,from:0,to:U.flat.text.length,targetFrom:Be}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:u("none")}catch(f){if(f!==c)throw f;return u("fallback","work-limit")}}function hr({describe:e,parentOf:o,...t}){let n=new WeakMap,s=new WeakMap,d=t.budget||qt(2e4*32),l=r=>{if(!r)return null;if(n.has(r))return n.get(r);n.set(r,{status:"planning",parent:r,records:[]});let i=e(r),u=i?Fi({...t,...i,parent:r,budget:d}):{status:"none",reason:null,parent:r,records:[]};if(n.set(r,u),u.status==="ready")for(let w of u.records)s.set(w.owner,[w]);return u};return{get:l,forOwner(r){return l(o(r))?.status==="ready"&&s.get(r)||null}}}function _i(e,o){if(e.side!==0)return null;let t=e.native[0].model,n=e.ownerModels[0],s=e.native[1].from!==0,d=(R,S)=>s?[...R.nodes,...S.nodes]:[...S.nodes,...R.nodes],l=e.ownerModels.reduce((R,S)=>R+S.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(l*8>o.remaining)return null;o.remaining-=l*8;let r={base:d(n,t),local:e.ownerModels[1].nodes,remote:d(e.ownerModels[2],e.native[2].model)},i=en(r.base),u=e.ownerModels[1].flat,w=en(r.remote),c=s?n.flat.text.length:0,h=s?0:t.flat.text.length,p=Ln({base:i,side:u,retained:e.retained.map(R=>({from:h+R.from,to:h+R.to,target:R.targetFrom})),transfers:e.runs.map(R=>({from:c+R.from,to:c+R.to,target:R.targetFrom,destination:e.owner})),budget:o});if(p.status!=="ready"||p.covers(0,i.text.length)!==!0)return null;let y=e.ownerModels[2].flat,C=e.native[2].model.flat,g=[];for(let[R,S,O,E]of[[n.flat,y,h,s?0:C.text.length],[t.flat,C,c,s?y.text.length:0]]){let P=ds(R,R,S).remoteMap.bTo,v=-1;for(let N=0;N<R.text.length;N++){if(P[N]<0){v=-1;continue}let L=g.at(-1);v>=0&&L.to===O+N&&L.target+L.to-L.from===E+P[N]?L.to++:(g.push({from:O+N,to:O+N+1,target:E+P[N]}),v=N)}}let f=Ln({base:i,side:w,retained:g,transfers:[],budget:o});if(f.status!=="ready")return null;let m=ds(i,u,w,{},{local:p,remote:f});return m.localEdits.hunks.length?null:(m.localMap=p,m.remoteMap=f,{nodes:r,prepared:m})}function pr({L:e,R:o,twinIn:t,unitsOf:n,view:s,parentOf:d,ignored:l,remoteWins:r,eligible:i,build:u,out:w,policy:c,provenance:h,textMappers:p,segments:y,conflicts:C,conflict:g,decisions:f}){let m=qt(2e4*32),R=B=>{let M=0;for(let x=B;x;x=d(x))if(++M>64||x.nodeType===1&&(l(x)||r(x)))return!1;return!0},S=hr({parentOf:d,eligible:i,ignored:l,remoteWins:r,budget:m,describe(B){let M=t(e,B),x=t(o,B);return!M||!x||!R(B)||!R(M)||!R(x)?null:{base:n(B),views:[{A:e,V:s(e,M,B,!1)},{A:o,V:s(o,x,B,!1)}]}}}),O=new WeakSet,E=new WeakMap,P=new WeakSet,v=[];function N(B){if(!B||O.has(B))return;O.add(B);let M=S.get(B);if(M?.status==="ready")for(let x of M.records){if((B.tagName==="TEMPLATE"&&B.content?B.content:B).childNodes.length!==x.native[0].model.nodes.length+1||!x.owners.every(R))continue;let z=_i(x,m);if(!z)continue;let U={record:x,payload:z,state:"planned",output:null,result:null};E.set(x.owner,U),P.add(x.source),P.add(x.native[2].unit),v.push(U)}}function L(B,M){let x=E.get(B);if(!x)return!1;if(!x.result){if(x.result=Gn({...x.payload.nodes,prepared:x.payload.prepared,out:w,policy:c,provenance:h,textMappers:p,conflicts:C,conflict:g,decisions:f,node:M}),x.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");y.push(...x.result.segments),x.decision={kind:"text",node:M,source:"local"},f.push(x.decision)}return x.decision.node=M,M.replaceChildren(...x.result.nodes),x.output=M,x.state="built",!0}function D(B){if(!v.length)return;let M=new WeakSet,x=new WeakMap,k=new WeakMap,z=new WeakMap,U=ve=>ve.tagName==="TEMPLATE"&&ve.content?ve.content:ve,K=(ve,ze)=>{if(!ve)return;if(Array.isArray(ve)){for(let b of ve)K(b,ze);return}let re=z.get(ve);re||z.set(ve,re=[]),re.push(ze)},Ae=(ve,ze=null,re=!1)=>{M.add(ve),x.set(ve,ze);let b=h.get(ve),_=re||!!(b&&r(b.remote||b.base));if(k.set(ve,_),b)for(let oe of[b.base,b.local,b.remote])K(oe,ve);if(!(b?.pinned||b?.unchanged))for(let oe of U(ve).childNodes)Ae(oe,ve,_)},Me=ve=>(z.get(ve)||[]).find(ze=>ze.nodeType===1&&!k.get(ze)&&!h.get(ze)?.pinned&&!h.get(ze)?.unchanged),Be=(ve,ze)=>{for(let re of z.get(ve)||[]){let b=re;for(;b&&x.get(b)!==ze;)b=x.get(b);if(b)return b}return null},te=(ve,ze,re)=>{let b=U(ze);for(let _=re.nextSibling;_;_=_.nextSibling){let oe=Be(_,ze);if(oe){b.insertBefore(ve,oe);return}}for(let _=re.previousSibling;_;_=_.previousSibling){let oe=Be(_,ze);if(oe){b.insertBefore(ve,oe.nextSibling);return}}b.appendChild(ve)};Ae(B);for(let ve of v){let{record:ze}=ve,re=Me(ze.owner)||Me(ze.owners[1])||Me(ze.owners[2]);if(re)(!ve.result||ve.output!==re||ve.result.nodes.some(b=>!M.has(b)||x.get(b)!==re)||re.textContent!==ve.result.text)&&(L(ze.owner,re),Ae(re,x.get(re),k.get(re)));else{let b=ze.parent,_=ze.owner,oe=null;for(;b&&!oe;)oe=Me(b),oe||(_=b,b=d(b));if(!oe)throw new Error("A cross-parent payload has no allowed surviving parent");re=ve.output||u(ze.owner,ze.owners[1],ze.owners[2],!1),ve.result||L(ze.owner,re),te(re,oe,_),Ae(re,oe,k.get(oe))}ve.state="attached"}}return{ensureParent:N,ensureOwner(B){N(d(B))},consumes(B){return P.has(B)},render:L,drain:D}}var Tn=/\S/,mr=/[\p{L}\p{N}]/u;function Qn(e,o,t,n){if(e?.nodeType!==1||!o(e))return!1;for(let s=e.firstChild;s;s=s.nextSibling)if(n(t,1),s.nodeType!==3)return!1;return!!e.firstChild}function gs(e,o,t){for(let n=e.parentNode;n;n=n.parentNode)if(t(o,1),n.nodeType===11)return!1;return!0}function gr(e,o,t,n,s){let d=t(e,n),l=t(o,n),r=null,i=null,u=null,w=null;s(n,d.length+l.length);for(let c of d)mr.test(c.raw)&&(r||=c,i=c);for(let c of l)mr.test(c.raw)&&(u||=c,w=c);return!!(r&&u&&(r.raw===u.raw||i.raw===w.raw))}function qi({base:e,V:o,A:t,source:n,original:s,current:d,edited:l,destination:r,at:i,ownLength:u,eligible:w,model:c,tokensOf:h,budget:p,charge:y}){let C=s.flat.text,g=d.flat.text,f=l.flat.text,m=r.flat.text;if(y(p,C.length+g.length+m.length),C.startsWith(g)||C.endsWith(g))return!1;let R=Tn.test(m.slice(0,i)),S=Tn.test(m.slice(i+u));if(R===S)return!1;let O=R?0:i+u,E=R?i:m.length;for(;O<E&&!Tn.test(m[O]);)O++;for(;E>O&&!Tn.test(m[E-1]);)E--;let P=m.slice(O,E);if(Nn(P,m,h(r,p),p,y,!0)!==O)return!1;let v=Nn(P,C,h(s,p),p,y,!0);if(v<0)return!1;let N=v+P.length,L=!Tn.test(C.slice(0,v)),D=!Tn.test(C.slice(N));if(L===D||Nn(P,g,h(d,p),p,y,!1)>=0)return!1;let B=L?C.slice(N):C.slice(0,v),M=L?f.length-B.length:0;if(y(p,C.length+f.length),M<0||!Tn.test(B)||Nn(B,f,h(l,p),p,y,!0)!==M||!Tn.test(L?f.slice(0,M):f.slice(B.length)))return!1;for(let x of e){if(y(p,1),x===n||!Qn(x,w,p,y))continue;let k=c(x,null,p);if(Nn(P,k.flat.text,h(k,p),p,y,!1)>=0)return!1}for(let x of o.units){if(y(p,1),x===d.unit||x===r.unit||!Qn(x,w,p,y))continue;let k=c(x,t,p);if(Nn(P,k.flat.text,h(k,p),p,y,!1)>=0)return!1}return!0}function br({base:e,views:o,side:t,attempt:n,eligible:s,blocked:d,baseId:l,model:r,tokensOf:i,charge:u,exhausted:w,limit:c}){if(c<=0)return null;let h=qt(c),{V:p,A:y,idOf:C}=o[t],g=o[1-t],[f,m,R,S]=n,O=null;try{for(let E=f;E<=m;E++){u(h,1);let P=e[E];if(P.parentNode?.nodeType!==1||d.has(P)||y.identical.has(P)||g.A.identical.has(P)||!Qn(P,s,h,u)||l(P))continue;let v=p.twin(P),N=g.V.twin(P);if(!v||!N||!p.here(v)||!g.V.here(N)||y.map.get(P)!==v||y.reverse.get(v)!==P||g.A.map.get(P)!==N||g.A.reverse.get(N)!==P||C(v)||g.idOf(N)||v.tagName!==P.tagName||N.tagName!==P.tagName||!Qn(v,s,h,u)||!Qn(N,s,h,u)||!gs(P,h,u)||!gs(v,h,u)||!gs(N,h,u))continue;let L=r(P,null,h),D=r(v,y,h),B=r(N,g.A,h),M=L.flat.text,x=D.flat.text,k=B.flat.text;if(u(h,M.length+x.length+k.length),!Tn.test(M)||!Tn.test(x)||!Tn.test(k)||M===x||M===k||x===k||!gr(L,D,i,h,u)||!gr(L,B,i,h,u))continue;let z=null,U=!1;for(let Me=R;Me<=S;Me++){u(h,1);let Be=p.units[Me],te=p.baseOf(Be);if(!te||te===P||d.has(te)||te.parentNode!==P.parentNode||Be.parentNode!==v.parentNode||te.tagName!==P.tagName||Be.tagName!==P.tagName||y.map.get(te)!==Be||y.reverse.get(Be)!==te||l(te)!==C(Be)||!Qn(te,s,h,u)||!Qn(Be,s,h,u))continue;let ve=r(te,null,h),ze=r(Be,y,h),re=ve.flat.text,b=ze.flat.text;if(u(h,re.length),!Tn.test(re)||b.length<=re.length)continue;let _=i(ze,h),oe=Nn(re,b,_,h,u,!0);if(!(oe<0||Nn(M,b,_,h,u,!0,oe,oe+re.length)<0&&!qi({base:e,V:p,A:y,source:P,original:L,current:D,edited:B,destination:ze,at:oe,ownLength:re.length,eligible:s,model:r,tokensOf:i,budget:h,charge:u}))){if(z){U=!0;break}z=Be}}if(!z||U)continue;let K=t===0?v:N,Ae=t===0?N:v;(O||=[]).push({source:P,local:K,remote:Ae,models:[L,t===0?D:B,t===0?B:D]})}}catch(E){if(E!==w)throw E}return O}var Bn=/\S/,hn=/\s/,zi=/[\s\u001e]/g,bs=/[^\s\p{P}\u001e\ufffc]/u;function $i(e,o,t,n,s,d,l){let r=0;for(let i of e)l(d,1),i.nodeType===1&&!n.baseOf(i)&&r++;if(r<2)return!1;for(let i of e){if(i.nodeType!==1||n.baseOf(i))continue;let u=s.get(i).flat;if(u.atoms.length||u.pins?.length)continue;l(d,u.text.length*2+o.length+t.length);let w=new Uint8Array(u.text.length);for(let c of t)c.target===i&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c of o)c.target===i&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c=0;c<u.text.length;c++)if(!w[c]&&Bn.test(u.text[c]))return!0}return!1}function Gi(e,o,t){let{source:n,models:s,retained:d,runs:l}=e,r=s.get(n).flat.text;t(o,r.length*2+d.length+l.length);let i=new Uint8Array(r.length);for(let u of d)u.source===n&&(t(o,u.to-u.from),i.fill(1,u.from,u.to));for(let u of l)t(o,u.to-u.from),i.fill(1,u.from,u.to);for(let u=0;u<r.length;u++)if(!i[u]&&Bn.test(r[u]))return!1;return!0}function Yi(e,o,t,n,s,d,l,r,i,u){let w=d.get(e),c=d.get(o),h=w.flat.text,p=l.get(e);i(u,h.length*2+t.length);let y=h.length,C=0;for(let m=0;m<h.length;m++)!hn.test(h[m])&&!p[m]&&(y=Math.min(y,m),C=m+1);if(y>=C)return null;for(let m=y;m<C;m++)if(!hn.test(h[m])&&p[m])return null;let g=-1;for(let m of t)if(m.target===o&&m.from<=y&&m.to>y){g=m.targetFrom+y-m.from;break}if(g<0)return null;let f=h.slice(y,C);if(i(u,f.length*(t.length+2)),c.flat.text.slice(g,g+f.length)!==f)return null;for(let m=y;m<C;m++){if(hn.test(h[m]))continue;let R=!1;for(let S of t)if(S.target===o&&S.from<=m&&S.to>m&&S.targetFrom+m-S.from===g+m-y){R=!0;break}if(!R)return null}if(w.flat.atoms.length||c.flat.atoms.length){i(u,w.flat.atoms.length+c.flat.atoms.length);let m=0,R=c.flat.atoms;for(;m<R.length&&R[m].i<g;)m++;for(let S of w.flat.atoms){if(S.i<y||S.i>=C)continue;let O=R[m++];if(!O||O.i!==g+S.i-y||c.alignment?.reverse.get(O.el)!==S.el)return null}if(m<R.length&&R[m].i<g+C-y)return null}for(let[m,R,S]of[[n,e,y],[s,o,g]]){let O=!1;for(let E of m){let P=d.get(E),v=l.get(E),N=r(P,u);for(let L=0;L<N.length;L++){let D=N[L].from,B=D+f.length;if(i(u,f.length*2+1),P.flat.text.slice(D,B)!==f)continue;let M=L;for(;M<N.length&&N[M].to<B;)i(u,1),M++;if(M===N.length||N[M].to!==B)continue;let x=!0;for(let k=D;k<B;k++)if(!hn.test(P.flat.text[k])&&v[k]){x=!1;break}if(x){if(O||E!==R||D!==S)return null;O=!0}}}if(!O)return null}return f}function Xi(e,o,t,n,s,d,l,r){if(l(r,s.length+d.length+(n.length+1)*t.length*2),!t)return!1;let i=n.indexOf(t);return i<0||n.lastIndexOf(t)!==i||!d.some(u=>u.from===i)||!d.some(u=>u.to===i+t.length)?!1:s.some(u=>u.source===e&&u.target===o&&u.from===0&&u.to===t.length&&u.targetFrom===i)}function wr({base:e,views:o,eligible:t,baseId:n,ignored:s,remoteWins:d,atomKey:l,limit:r=2e4*8}){if(r<=0)return null;let i=Symbol(),u=(S,O)=>{if(O>S.remaining)throw i;S.remaining-=O},w=[new Map,new Map];for(let S=0;S<2;S++)for(let O=0;O<o[S].V.units.length;O++)w[S].set(o[S].V.units[O],O);let c=new Int32Array(e.length),h=new Int32Array(e.length),p=S=>o.every(({V:O},E)=>{let P=O.twin(S);return P&&w[E].has(P)}),y=-1;for(let S=0;S<e.length;S++)c[S]=y,p(e[S])&&(y=S);y=e.length;for(let S=e.length-1;S>=0;S--)h[S]=y,p(e[S])&&(y=S);let C=new Map,g=(S,O)=>{if(u(O,1),C.has(S))return C.get(S);let E=S.firstChild,P=1;for(;E;){if(u(O,P*8+8),E.nodeType===3&&u(O,E.data.length*8),E.nodeType===1&&wn.has(E.tagName)&&!s(E)&&!d(E)&&E.firstChild){E=E.firstChild,P++;continue}for(;E&&E!==S&&!E.nextSibling;)E=E.parentNode,P--;E=!E||E===S?null:E.nextSibling}let v=en(Array.from(S.childNodes),{ignored:s,remoteWins:d});return C.set(S,v),v},f=(S,O,E,P,v,N)=>{for(let L of S.atoms){u(N,1);let D=O.atomAt.get(L.i+E);if(!D)return!1;let B=P?.reverse.get(L.el)||l(L.el),M=v?.reverse.get(D.el)||l(D.el);if(B!==M)return!1}return!0},m=(S,O,E,P,v)=>{let N=S.text.length<=O.text.length?S:O,L=N===S?O:S;if(u(v,N.text.length+L.text.length),!N.text||!Bn.test(N.text.replaceAll(Rn,"")))return!1;let D;if(N.text===L.text)D=0;else{let B=L.text.length-N.text.length;if(u(v,(B+1)*N.text.length*2),L.text.startsWith(N.text))D=0;else if(L.text.endsWith(N.text))D=B;else return!1;if(L.text.indexOf(N.text)!==D||L.text.lastIndexOf(N.text)!==D)return!1;u(v,L.text.length*2);let M=0,x=D===0,k=!1;for(let z of rn(L.text,bn(L.text)))M+=z.len,M===D&&(x=!0),M===D+N.text.length&&(k=!0);if(!x||!k)return!1}return N===S?f(N,L,D,E,P,v):f(N,L,D,P,E,v)},R=null;for(let S=0;S<2;S++){let{V:O,A:E,idOf:P}=o[S],v=o[1-S];if(!O.asBase)for(let N=0;N<e.length;N++){let L=e[N];if(O.twin(L)||!t(L))continue;let D=v.V.twin(L);if(!D||!w[1-S].has(D)||!t(D))continue;let B={remaining:r};try{let M=c[N],x=h[N],k=0;for(let Ae=M+1;Ae<x;Ae++)u(B,1),!O.twin(e[Ae])&&v.V.twin(e[Ae])&&t(e[Ae])&&k++;if(k!==1||g(L,B).text===g(D,B).text)continue;let z=M<0?-1:w[S].get(O.twin(e[M])),U=x===e.length?O.units.length:w[S].get(O.twin(e[x]));if(z===void 0||U===void 0||z>=U)continue;let K=null;for(let Ae=z+1;Ae<U;Ae++){u(B,1);let Me=O.units[Ae];if(O.baseOf(Me)||!t(Me)||Me.tagName!==L.tagName||Me.namespaceURI!==L.namespaceURI)continue;let Be=n(L),te=v.idOf(D),ve=P(Me);if(!(Be&&te&&Be!==te||Be&&ve&&Be!==ve||te&&ve&&te!==ve)&&m(g(D,B),g(Me,B),v.A,E,B)){if(K){K=null;break}K=Me}}if(!K)continue;R||(R=[new Map,new Map]),R[S].set(L,K)}catch(M){if(M!==i)throw M}}}return R?o.map(({V:S},O)=>{let E=R[O];if(!E.size)return S;let P=new Map;for(let[v,N]of E)P.set(N,v);return{...S,twin:v=>E.get(v)||S.twin(v),baseOf:v=>P.get(v)||S.baseOf(v)}}):null}function yr({onUncertainSource:e,onUncertainOwner:o,base:t,views:n,eligible:s,ignored:d,remoteWins:l,baseId:r,atomKey:i,limit:u=2e4*32}){if(u<=0)return null;let w=new Set(t),c=new Map(t.map((M,x)=>[M,x])),h=new Map,p=[],y=null,C=null,g=null,f=new Set;for(let M of t)for(let{V:x}of n){let k=x.twin(M);k&&!x.asBase&&!x.here(k)&&f.add(M)}let m=new Set,R=Symbol(),S=(M,x)=>{if(x>M.remaining)throw R;M.remaining-=x},O=(M,x,k)=>{S(k,1);let z=h.get(M);if(z)return z;if(M.nodeType===1){let Ae=M.firstChild,Me=1;for(;Ae;){if(S(k,Me*8+8),Ae.nodeType===3&&S(k,Ae.data.length*8),Ae.nodeType===1&&wn.has(Ae.tagName)&&!d(Ae)&&!l(Ae)&&Ae.firstChild){Ae=Ae.firstChild,Me++;continue}for(;Ae&&Ae!==M&&!Ae.nextSibling;)Ae=Ae.parentNode,Me--;Ae=!Ae||Ae===M?null:Ae.nextSibling}}else S(k,M.value.length*8+M.nodes.length);let U=M.nodeType===1?Array.from(M.childNodes):M.nodes,K=U.length===1&&U[0].nodeType===3?{text:U[0].data,nodes:[{node:U[0],s:0,e:U[0].data.length}],atoms:[]}:en(U,{ignored:d,remoteWins:l});return z={unit:M,flat:K,alignment:x,tokens:null},h.set(M,z),z},E=(M,x)=>{if(M.tokens)return M.tokens;S(x,M.flat.text.length*8);let{unit:k,flat:z,alignment:U}=M,K=[],Ae=bn(z.text),Me=0,Be=te=>{for(let ve of rn(z.text.slice(Me,te),Ae))ve.from=Me,ve.to=Me+ve.len,ve.unit=k,K.push(ve),Me+=ve.len};for(let te of z.atoms){Be(te.i);let ve=l(te.el)&&te.el.nodeType===1?"w"+te.el.tagName+"#"+(te.el.id||""):i(U?.reverse.get(te.el)||te.el);K.push({k:ve,raw:Rn,len:1,from:Me,to:Me+1,unit:k,atom:!0}),Me++}return Be(z.text.length),M.tokens=K,K},P=(M,x,k,z,U)=>{if(!M.flat.atoms.length&&!x.flat.atoms.length)return!0;let K=E(M,U),Ae=E(x,U);S(U,K.length+Ae.length);let Me=0;for(let Be of Ae){if(!Be.atom||Be.from<k||Be.from>=k+z)continue;for(;Me<K.length&&!K[Me].atom;)Me++;let te=K[Me++];if(!te||te.from!==Be.from-k||te.k!==Be.k)return!1}for(;Me<K.length;)if(K[Me++].atom)return!1;return!0},v=(M,x,k)=>{let z=M.length+x.length+4;if(z*8>k.remaining)return null;k.remaining-=z*8;let U=Math.floor(k.remaining/8),K=Math.min(M.length+x.length,4e3,Math.floor((Math.sqrt(z*z+U)-z)/2)),Ae=4*(K+1)*(z+K+1);if(K<1||Ae>k.remaining)return null;k.remaining-=Ae;let Me=Un(M,x,K),Be=[],te=0,ve=0;for(let ze of Me.hunks){for(;te<ze.bs;)M[te].raw===x[ve].raw&&Be.push([M[te],x[ve]]),te++,ve++;te=ze.be,ve+=ze.toks.length}for(;te<M.length&&ve<x.length;)M[te].raw===x[ve].raw&&Be.push([M[te],x[ve]]),te++,ve++;return Be},N=(M,x,k,z,U,K,Ae)=>{if(U<=z)return;let Me=M[M.length-1];if(Me&&Me.source===x&&Me.target===k&&Me.to<=z&&Me.targetFrom-Me.from===K-z){S(Ae,(z-Me.to)*3);let Be=h.get(x).flat.text,te=h.get(k).flat.text,ve=!0;for(let ze=Me.to;ze<z;ze++)if(!hn.test(Be[ze])||Be[ze]!==te[K+ze-z]){ve=!1;break}if(ve){Me.to=U;return}}M.push({source:x,target:k,from:z,to:U,targetFrom:K})},L=M=>M.replace(zi,"");for(let M=0;M<n.length;M++){let{V:x,A:k,idOf:z}=n[M];if(x.asBase)continue;let U=new Map(x.units.map((b,_)=>[b,_])),K=b=>{let _=x.twin(b);return _&&U.has(_)?_:null},Ae=(b,_)=>{let oe=new Int32Array(b.length),ee=new Int32Array(b.length),Pe=-1;for(let Ke=0;Ke<b.length;Ke++)oe[Ke]=Pe,_(b[Ke])&&(Pe=Ke);Pe=b.length;for(let Ke=b.length-1;Ke>=0;Ke--)ee[Ke]=Pe,_(b[Ke])&&(Pe=Ke);return{prev:oe,next:ee}},Me=Ae(t,b=>(b.nodeType===1||b.kind==="text"&&Bn.test(b.value))&&K(b)),Be=Ae(x.units,b=>(b.nodeType===1||b.kind==="text"&&Bn.test(b.value))&&w.has(x.baseOf(b))),te=new Map,ve=(b,_,oe,ee)=>{if(b>_||oe>ee)return;let Pe=`${b}:${_}:${oe}:${ee}`;te.set(Pe,[b,_,oe,ee])};for(let b=0;b<x.units.length;b++){let _=x.units[b];if(x.baseOf(_)||!s(_))continue;let oe=Be.prev[b],ee=Be.next[b],Pe=oe<0?0:c.get(x.baseOf(x.units[oe])),Ke=ee===x.units.length?t.length-1:c.get(x.baseOf(x.units[ee]));ve(Pe,Ke,Math.max(0,oe),Math.min(x.units.length-1,ee))}for(let b=0;b<t.length;b++){let _=t[b];if(f.has(_)||!s(_))continue;if(!x.twin(_)){let ot=Me.prev[b],Qe=Me.next[b],Ze=ot<0?0:U.get(K(t[ot])),Xe=Qe===t.length?x.units.length-1:U.get(K(t[Qe]));ve(Math.max(0,ot),Math.min(t.length-1,Qe),Ze,Xe)}let oe=K(_);if(!oe||k.identical.has(_)||!s(oe))continue;let ee=b+1;for(;ee<t.length&&t[ee].kind==="text"&&!t[ee].value.trim();)ee++;if(ee>=t.length||!s(t[ee]))continue;let Pe=K(t[ee]);if(!Pe||k.identical.has(t[ee])||!s(Pe))continue;let Ke=U.get(oe),Ne=U.get(Pe);Ke<Ne&&ve(b,ee,Ke,Ne)}let ze=Array.from(te.values()),re=new Set;if(ze.length>1){let b=qt(u);try{S(b,ze.length*4);let _=ze.slice().sort((Pe,Ke)=>(S(b,1),Pe[0]-Ke[0]||Pe[2]-Ke[2])),oe=[],ee=null;for(let Pe of _)S(b,1),ee&&Pe[0]<=ee[1]&&Pe[2]<=ee[3]&&Pe[3]>=ee[2]?(ee[1]=Math.max(ee[1],Pe[1]),ee[2]=Math.min(ee[2],Pe[2]),ee[3]=Math.max(ee[3],Pe[3]),ee[4].push(Pe)):(ee?.[4].length>1&&oe.push(ee),ee=[Pe[0],Pe[1],Pe[2],Pe[3],[Pe]]);ee?.[4].length>1&&oe.push(ee),ze=oe.concat(ze)}catch(_){if(_!==R)throw _}}for(let b of ze){if(re.has(b))continue;let[_,oe,ee,Pe,Ke]=b,Ne=qt(u),ot=[],Qe=new Set,Ze=!1;try{S(Ne,(oe-_+Pe-ee+2)*4);let Xe=t.slice(_,oe+1).filter(Z=>!k.identical.has(Z)&&s(Z)&&!f.has(Z)),wt=x.units.slice(ee,Pe+1).filter(Z=>s(Z)&&(!x.baseOf(Z)||w.has(x.baseOf(Z)))&&!k.identical.has(x.baseOf(Z))&&!f.has(x.baseOf(Z))),dt=new Set(wt),gt=!1,zt="",_t="",Ht=0;for(let Z of Xe){let Ie=O(Z,null,Ne);zt+=Ie.flat.text,Ht+=Ie.flat.text.length}for(let Z of wt){let Ie=O(Z,k,Ne);_t+=Ie.flat.text,Ht+=Ie.flat.text.length}S(Ne,Ht);let Bt=L(zt),an=L(_t),Kt=Bt===an;if(Ze=Kt,Ke&&!Kt)continue;let $t=Kt?null:new Map;if($t)for(let Z of Xe.concat(wt)){let Ie=h.get(Z).flat.text.length;S(Ne,Ie*16),$t.set(Z,new Uint8Array(Ie))}let F=Z=>{let Ie=[];for(let He of Z){let Ce=h.get(He);Ce.flat.atoms.length?Ie.push(...E(Ce,Ne)):Ie.push({unit:He,raw:Ce.flat.text,from:0})}return Ie},le=[];for(let Z of Kt?[]:Xe){let Ie=K(Z);if(!dt.has(Ie))continue;let He=O(Z,null,Ne),Ce=O(Ie,k,Ne);S(Ne,He.flat.text.length+Ce.flat.text.length);let be=He.flat.text&&Ce.flat.text.startsWith(He.flat.text)?0:He.flat.text&&Ce.flat.text.endsWith(He.flat.text)?Ce.flat.text.length-He.flat.text.length:-1;if(be>=0&&P(He,Ce,be,He.flat.text.length,Ne)){$t.get(Z).fill(1),$t.get(Ie).fill(1,be,be+He.flat.text.length),N(le,Z,Ie,0,He.flat.text.length,be,Ne);continue}let H=v(E(He,Ne),E(Ce,Ne),Ne);if(!H){gt=!0;break}for(let[G,de]of H)$t.get(Z).fill(1,G.from,G.to),$t.get(Ie).fill(1,de.from,de.to),N(le,Z,Ie,G.from,G.to,de.from,Ne)}if(gt)continue;let ge=null,me=null;if(!Kt)for(let Z of Xe){let Ie=K(Z),He=h.get(Z);if(!Ie||He.flat.atoms.length||!dt.has(Ie))continue;let Ce=He.flat.text,be=$t.get(Z);S(Ne,Ce.length*3+wt.length);let H=-1,G=-1,de=!1;for(let Ve=0;Ve<Ce.length;Ve++)hn.test(Ce[Ve])||(be[Ve]?de=!0:(H<0&&(H=Ve),G=Ve+1));if(!de||H<0)continue;let pe=!0;for(let Ve=H;Ve<G;Ve++)if(be[Ve]&&!hn.test(Ce[Ve])){pe=!1;break}if(!pe)continue;let ce=L(Ce.slice(H,G)),xe=null,ne=!1;for(let Ve of wt){if(x.baseOf(Ve))continue;let Oe=h.get(Ve);if(!Oe.flat.atoms.length&&(S(Ne,Oe.flat.text.length),L(Oe.flat.text)===ce)){if(xe){ne=!0;break}xe=Ve}}if(ne){(me||=new Set).add(Z);continue}if(!xe||me?.has(Z))continue;let $=!1;for(let Ve of Xe){if(Ve===Z||!dt.has(K(Ve)))continue;let Oe=h.get(Ve);if(Oe.flat.atoms.length)continue;let $e=$t.get(Ve);S(Ne,Oe.flat.text.length*3);let tt="",T=!1;for(let q=0;q<Oe.flat.text.length;q++)hn.test(Oe.flat.text[q])||($e[q]?T=!0:tt+=Oe.flat.text[q]);T&&tt===ce&&(me||=new Set,me.add(Z),me.add(Ve),$=!0)}if($)continue;let fe=h.get(xe).flat.text;S(Ne,G-H+fe.length);let Ee=H,Re=0;for(;Ee<G&&Re<fe.length;){for(;Ee<G&&hn.test(Ce[Ee]);)Ee++;for(;Re<fe.length&&hn.test(fe[Re]);)Re++;if(Ee>=G||Re>=fe.length)break;N(ge||=[],Z,xe,Ee,Ee+1,Re,Ne),Ee++,Re++}be.fill(1,H,G),$t.get(xe).fill(1)}let Te=Z=>{let Ie=[];for(let He of Z){let Ce=O(He,w.has(He)?null:k,Ne),be=$t.get(He);for(let H of E(Ce,Ne)){let G=H.from;for(;G<H.to;){for(;G<H.to&&be[G];)G++;let de=G;for(;G<H.to&&!be[G];)G++;if(G>de){let pe=Ce.flat.text.slice(de,G);Bn.test(pe)&&Ie.push({...H,raw:pe,len:G-de,k:H.atom?H.k:pe,from:de,to:G})}}}}return Ie},A=Kt?F(Xe):Te(Xe),j=Kt?F(wt):Te(wt),Y=Kt?Bt:A.map(Z=>L(Z.raw)).join(""),J=Kt?an:j.map(Z=>L(Z.raw)).join("");if((!Y||!J)&&!ge)continue;let se=ge||[];if(Y&&J&&Y===J){let Z=0,Ie=0,He=0,Ce=0;for(;Z<A.length&&Ie<j.length;){let be=A[Z],H=j[Ie];for(;He<be.raw.length&&hn.test(be.raw[He]);)He++;for(;Ce<H.raw.length&&hn.test(H.raw[Ce]);)Ce++;if(He===be.raw.length){Z++,He=0;continue}if(Ce===H.raw.length){Ie++,Ce=0;continue}if((be.atom||H.atom)&&be.k!==H.k){gt=!0;break}N(se,be.unit,H.unit,be.from+He,be.from+He+1,H.from+Ce,Ne),He++,Ce++}}else if(Y&&J){let Z=v(A,j,Ne);if(!Z)continue;for(let[Ie,He]of Z)N(se,Ie.unit,He.unit,Ie.from,Ie.to,He.from,Ne)}if(gt)continue;let je=new Map;for(let Z of se)if(!me?.has(Z.source)){if(K(Z.source)===Z.target){Kt&&le.push(Z);continue}je.has(Z.source)||je.set(Z.source,[]),je.get(Z.source).push(Z)}for(let[Z,Ie]of je){let He=O(Z,null,Ne),Ce=K(Z),be=He.flat.text,H=[],G=new Set,de=n[1-M],pe=de.V.twin(Z),ce=pe&&de.V.here(pe)?O(pe,de.A,Ne):null,xe=(Oe,$e)=>{let tt=E(Oe,Ne),T=E($e,Ne);return S(Ne,Oe.flat.text.length+$e.flat.text.length+tt.length+T.length),Oe.flat.text===$e.flat.text&&tt.length===T.length&&tt.every((q,Q)=>q.k===T[Q].k)},ne=Ce&&ce&&ce.flat.text!==be&&xe(O(Ce,k,Ne),ce);for(let Oe of new Set(Ie.map($e=>$e.target))){if(Z.nodeType!==1&&Oe.nodeType!==1)continue;let $e=O(Oe,k,Ne),tt=x.baseOf(Oe);if(Z.nodeType!==1&&tt||(S(Ne,be.length*2+$e.flat.text.length*3+le.length*2),Ce&&L(be)===L($e.flat.text)&&O(Ce,k,Ne).flat.text.trim()))continue;if(!Ce&&!tt&&Z.nodeType===1&&Oe.nodeType===1){let ue=r(Z),ie=z(Oe);if(ue&&ie&&ue!==ie)continue}let T=$e.flat.text,q=be&&(T.startsWith(be)||T.endsWith(be)),Q=!1;if(!Ce&&ce&&tt&&ce.flat.text!==be){let ue=O(tt,null,Ne).flat.text,ie=c.get(Z)<c.get(tt)?ce.flat.text:ue,ae=c.get(Z)<c.get(tt)?ue:ce.flat.text;S(Ne,ie.length+ae.length+T.length),Q=!!ie&&!!ae&&ie.length+ae.length<=T.length&&T.startsWith(ie)&&T.endsWith(ae)&&!T.slice(ie.length,T.length-ae.length).trim()}let we=!He.flat.atoms.length&&!ce?.flat.atoms.length&&!$e.flat.atoms.length&&(ne&&q||Q);if(Ce&&tt){let ue=O(Ce,k,Ne).flat.text,ie=be.startsWith(ue)||be.endsWith(ue),ae=O(tt,null,Ne).flat.text,De=$e.flat.text,qe=De.startsWith(ae)||De.endsWith(ae),Ue=!n[1-M].V.twin(tt)&&!le.some(_e=>_e.source===tt&&Bn.test(ae.slice(_e.from,_e.to)));if(!Kt&&(!ie&&!we||!qe&&!Ue)){let _e=Yi(Z,Oe,Ie,Xe,wt,h,$t,E,S,Ne);if(!_e)continue;let Ge=k.weak?.has(Z)&&!k.identityPaired?.has(Z)&&be.trim()===_e;if(!ie&&!we&&!Ge)continue;let et=k.weak?.has(tt)&&!k.identityPaired?.has(tt)&&T.trim()===_e&&!h.get(tt).flat.atoms.length&&!le.some(Mt=>Mt.source===tt&&Bn.test(ae.slice(Mt.from,Mt.to)));if(!qe&&!Ue&&!et&&!Xi(tt,Oe,ae,T,le,E($e,Ne),S,Ne))continue;Ge&&G.add(Oe)}}we&&G.add(Oe),S(Ne,Ie.length),H.push(...Ie.filter(ue=>ue.target===Oe))}if(!H.length)continue;let $=new Uint8Array(be.length);S(Ne,be.length*4+le.length);for(let Oe of H)$.fill(1,Oe.from,Oe.to);let fe=[];for(let Oe=0;Oe<be.length;Oe++)hn.test(be[Oe])||fe.push(Oe);if(!fe.length)continue;let Ee=new Set(H.map(Oe=>Oe.target));if(!Kt&&Ce&&Ee.size>1&&$i(Ee,se,le,x,h,Ne,S)){if(g||=new Map,g.set(Z,(g.get(Z)||0)|1<<M),e){let Oe=fs({source:Z,side:M,views:n,eligible:s,blocked:f,baseId:r,model:O,tokensOf:E,budget:Ne,charge:S});if(Oe){S(Ne,Oe.to-Oe.from);let $e=!0;for(let tt=Oe.from;tt<Oe.to;tt++)if(Bn.test(be[tt])&&!$[tt]){$e=!1;break}$e&&(y||=[]).push(Oe)}}continue}let Re=fe.filter(Oe=>bs.test(be[Oe]));if(!H.some(Oe=>bs.test(be.slice(Oe.from,Oe.to)))&&!fe.every(Oe=>$[Oe]))continue;if(!Ce&&!Array.from(Ee).some(Oe=>G.has(Oe))&&!fe.every(Oe=>$[Oe])&&!(Re.length&&$[Re[0]]&&$[Re[Re.length-1]]&&Ee.size===1)){let Oe=null,$e=0,tt=0,T=null,q=null;if(!Ce&&ce&&Z.nodeType===1&&!He.flat.atoms.length){let Q=E(He,Ne).filter(we=>bs.test(we.raw));S(Ne,wt.length+be.length);for(let we of wt){let ue=x.baseOf(we);if(!ue||ue===Z||ue.nodeType!==1||we.nodeType!==1||ue.tagName!==Z.tagName||we.tagName!==ue.tagName)continue;let ie=c.get(Z),ae=c.get(ue),De=!0;for(let Jt=Math.min(ie,ae)+1;Jt<Math.max(ie,ae);Jt++){let Ot=t[Jt];if(S(Ne,Ot.nodeType===1?1:Ot.value.length+1),Ot.nodeType===1||Ot.value.trim()){De=!1;break}}if(!De)continue;let qe=O(ue,null,Ne),Ue=O(we,k,Ne);if(qe.flat.atoms.length||Ue.flat.atoms.length)continue;let _e=qe.flat.text,Ge=Ue.flat.text;if(S(Ne,_e.length+Ge.length+be.length),!_e||!Q.length)continue;let et=0,Mt=Ge.length;if(ie<ae&&Ge.endsWith(_e))Mt-=_e.length;else if(ie>ae&&Ge.startsWith(_e))et=_e.length;else continue;for(;et<Mt&&hn.test(Ge[et]);)et++;for(;Mt>et&&hn.test(Ge[Mt-1]);)Mt--;let kt=Ge.slice(et,Mt);if(!(!kt||!(kt.startsWith(Q[0].raw)||kt.endsWith(Q[Q.length-1].raw)))){if(Oe){Oe=null;break}Oe=we,$e=et,tt=Mt,T=Q[0],q=Q[Q.length-1]}}}if(S(Ne,H.length),!Oe||!Ee.has(Oe)||!H.some(Q=>Q.target===Oe&&(Q.from<=T.from&&Q.to>=T.to&&Q.targetFrom+T.from-Q.from===$e||Q.from<=q.from&&Q.to>=q.to&&Q.targetFrom+q.to-Q.from===tt)))continue}if(Ce&&!(fe.every(Oe=>$[Oe])&&(Kt||Array.from(Ee).some(Oe=>G.has(Oe))))&&!le.some(Oe=>Oe.source===Z&&Bn.test(be.slice(Oe.from,Oe.to))))continue;let Ve=!1;if(Kt){S(Ne,le.length+fe.length);for(let Oe of le)Oe.source===Z&&(S(Ne,Oe.to-Oe.from),$.fill(1,Oe.from,Oe.to));Ve=!0;for(let Oe of fe)if(!$[Oe]){Ve=!1;break}}for(let Oe of Ee){S(Ne,H.length);let $e=H.filter(T=>T.target===Oe);ot.push({side:M,source:Z,target:Oe,runs:$e,models:h,retained:le,conservedSource:Ve}),Z.nodeType===1&&Qe.add(Z),Oe.nodeType===1&&Qe.add(Oe);let tt=x.baseOf(Oe);tt?.nodeType===1&&Qe.add(tt)}}if(p.push(...ot),Ke&&ot.length)for(let Z of Ke)re.add(Z);for(let Z of Qe)m.add(Z)}catch(Xe){if(Xe!==R)throw Xe}finally{if(o&&!Ke&&!Ze){let Xe=br({base:t,views:n,side:M,attempt:b,eligible:s,blocked:f,baseId:r,model:O,tokensOf:E,charge:S,exhausted:R,limit:u});Xe&&(C||=[]).push(...Xe)}if(e&&!Ke&&!Ze){let Xe=Ds({base:t,views:n,side:M,attempt:b,eligible:s,blocked:f,baseId:r,model:O,tokensOf:E,certificates:p,charge:S,exhausted:R,limit:u});Xe&&(y||=[]).push(...Xe)}}}}let D=p.length?new Map:null;for(let M of p){let x=D.get(M.source);x||D.set(M.source,x=[]),x.push(M)}let B=null;if(D){let M=null;for(let[x,k]of D){let z=g?.get(x)||0;if(k.length<2&&!z)continue;let U=0;for(let K of k)K.conservedSource&&(U|=1<<K.side);for(let K of k){if(K.conservedSource)continue;let Ae=1<<K.side,Me=!0;if(U&Ae)Me=!1;else if(z&Ae){Me=!1;try{Me=Gi(K,M||=qt(u),S)}catch(Be){if(Be!==R)throw Be}}Me||(B||=new Set).add(K)}}}if(B){let M=0;for(let x of p)B.has(x)||(p[M++]=x);p.length=M;for(let[x,k]of D){M=0;for(let z of k)B.has(z)||(k[M++]=z);k.length=M,M||D.delete(x)}m.clear();for(let x of p){let{source:k,target:z,side:U}=x;k.nodeType===1&&m.add(k),z.nodeType===1&&m.add(z);let K=n[U].V.baseOf(z);K?.nodeType===1&&m.add(K)}}if(y){let M=qt(u),x=!1;for(let k of y){let z=!1,U=D?.get(k.source);if(U&&!x)try{z=cs(k,U,M,S)}catch(K){if(K!==R)throw K;x=!0}z||e(k)}}if(C){let M=new Set,x=qt(u);try{for(let k of C){if(S(x,1),M.has(k.source))continue;M.add(k.source);let z=!1;for(let U of p)if(S(x,1),U.source===k.source||U.target===k.local||U.target===k.remote){z=!0;break}z||o(k)}}catch(k){if(k!==R)throw k}}for(let M of t)if(m.has(M))for(let{V:x}of n){let k=x.twin(M);k&&x.here(k)&&m.add(k)}return p.length?{blocks:m,certificates:p,certificatesBySource:D,models:h}:null}function kr({certificates:e,scopes:o,flats:t,keys:n,limit:s=2e4*32}){let d=Symbol(),l=qt(s),r=g=>{if(g>l.remaining)throw d;l.remaining-=g},i=o.map(g=>new Set(g)),u=new Map,w=new Map,c=(g,f)=>{let m=u.get(g);if(m||u.set(g,m=new Map),m.has(f))return m.get(f);r(g.text.length);let R=w.get(f);if(!R){r(f.nodes.length+f.atoms.length),R={nodes:new Map,atoms:new Map};for(let P of f.nodes)R.nodes.set(P.node,P);for(let P of f.atoms)R.atoms.set(P.el,P.i);w.set(f,R)}let{nodes:S,atoms:O}=R,E=new Int32Array(g.text.length).fill(-1);for(let P of g.nodes){let v=S.get(P.node);if(!(!v||P.e-P.s!==v.e-v.s)){r(P.e-P.s);for(let N=P.s;N<P.e;N++)E[N]=v.s+N-P.s}}for(let P of g.atoms){let v=O.get(P.el);v!==void 0&&(E[P.i]=v)}return m.set(f,E),E},h=(g,f,m,R,S)=>{let O=g[g.length-1];O&&O.to===f&&O.target+O.to-O.from===R&&O.kind===S?O.to=m:g.push({from:f,to:m,target:R,kind:S})},p=(g,f,m,R)=>{r((R-m)*4);let S=[],O=m,E=N=>{let L=g.text.slice(O,N);for(let D of rn(L,bn(L)))D.from=O,D.to=O+D.len,S.push(D),O+=D.len},P=0,v=g.atoms.length;for(;P<v;){r(1);let N=P+v>>>1;g.atoms[N].i<m?P=N+1:v=N}for(let N=P;N<g.atoms.length&&g.atoms[N].i<R;N++){r(1);let L=g.atoms[N];E(L.i),S.push({k:f(L),raw:Rn,len:1,from:O,to:O+1}),O++}return E(R),S},y=(g,f,m,R,S,O)=>{if(m===R||S===O)return;if(R-m===O-S){r((R-m)*4);let x=!0;for(let k=m,z=S;k<R;k++,z++){if(t[0].text[k]!==t[f].text[z]){x=!1;break}let U=t[0].atomAt.get(k),K=t[f].atomAt.get(z);if(!!U!=!!K||U&&n[0](U)!==n[f](K)){x=!1;break}}if(x){h(g,m,R,S,"retained");return}}let E=p(t[0],n[0],m,R),P=p(t[f],n[f],S,O),v=E.length+P.length+4,N=Math.min(E.length+P.length,4e3,Math.floor((Math.sqrt(v*v+l.remaining/2)-v)/2));if(N<1)throw d;r(4*(N+1)*(v+N+1));let L=Un(E,P,N),D=0,B=0,M=()=>{let x=E[D++],k=P[B++];r(x.len),x.raw===k.raw&&h(g,x.from,x.to,k.from,"retained")};for(let x of L.hunks){for(;D<x.bs;)M();D=x.be,B+=x.toks.length}for(;D<E.length&&B<P.length;)M()},C=g=>{let f=e.filter(L=>L.side===g-1&&i[0].has(L.source)&&i[g].has(L.target));if(!f.length)return null;let m=[],R=(L,D,B)=>{if(!i[0].has(L.source)||!i[g].has(L.target))return;let M=c(D.get(L.source).flat,t[0]),x=c(D.get(L.target).flat,t[g]);r(L.to-L.from);for(let k=0;k<L.to-L.from;k++){let z=M[L.from+k],U=x[L.targetFrom+k];if(z<0||U<0)throw d;h(m,z,z+1,U,B)}},S=new Set;for(let L of f){if(!S.has(L.retained)){S.add(L.retained);for(let D of L.retained)R(D,L.models,"retained")}for(let D of L.runs)R(D,L.models,"transfer")}m.sort((L,D)=>(r(1),L.from-D.from||L.target-D.target));let O=[];for(let L of m){r(1);let D=O[O.length-1];if(D&&L.from<D.to){if(L.target-L.from!==D.target-D.from)throw d;D.to=Math.max(D.to,L.to),L.kind==="transfer"&&(D.kind="transfer")}else O.push(L)}let E=[],P=0,v=0;for(let L of O){if(L.target<v)throw d;y(E,g,P,L.from,v,L.target),E.push(L),P=L.to,v=L.target+L.to-L.from}y(E,g,P,t[0].text.length,v,t[g].text.length);let N=Ln({base:t[0],side:t[g],retained:E.filter(L=>L.kind==="retained"),transfers:E.filter(L=>L.kind==="transfer"),baseAtomKey:n[0],sideAtomKey:n[g],budget:l});if(N.status!=="ready"||!N.monotone)throw d;return N};try{let g=C(1),f=C(2);return g||f?{local:g,remote:f}:{fallback:!0}}catch(g){if(g!==d)throw g;return{fallback:!0}}}function ws(e,o,t=!1){let n=-1,s=-1;for(let l=0;l<e.list.length;l++){let r=e.list[l];r.bLo<o.lo||r.bLo>o.hi||(n<0&&(n=l),s=l)}let d=[];for(let l=n;l>=0&&l<=s;l++){let r=e.list[l],i=!t&&l===n?r.inlineStart<0?r.to:r.inlineStart:r.from,u=!t&&l===s?r.inlineEnd<0?r.from:r.inlineEnd:r.to;for(let w=i;w<u;w++)d.push(e.units[w]);l<s&&d.push(e.units[r.next])}return d}var ut=e=>!!e&&e.nodeType===1,Mn=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function ys(e){for(let o of e)if(Mn.has(o.tagName))return!0;return!1}function Ji(e,o,t){let n=null;for(let s of o.childNodes)if(!(!ut(s)||!t(s)||!s.isEqualNode(e))){if(n)return null;n=s}if(!n)return null;for(let s of e.parentNode.childNodes)if(s!==e&&s.isEqualNode(e))return null;return n}var vo="[id],[data-id],script,head>*";function ks(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=lo(t,e);if(n)return"merge:"+n.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?er(t,o):null}}function Fo(e,o,t,n){let s=n.ignored,d=n.stats||Wn(),l=Ls({ignored:s,ignoreAttribute:n.ignoreAttribute,stats:d}),{unitsOf:r,meta:i}=l,u=n.baseURI,w=n.mergeTags!==null,c=ks(n.mergeTags,u),h=T=>q=>{let Q=c(q);return Q!==null?Q:T(q)},p=h(n.identity.base),y=h(n.identity.local),C=h(n.identity.remote),g=n.authored||n.identity,f=T=>T&&T.nodeType===9?T.documentElement:T,m=f(e),R=f(o),S=f(t),O=globalThis.__hyperMorphProfile,E=O?performance.now():0,P=T=>T===gn?vo:null,v=n.scope||null,N=v?v.baseDropped:new Set,L=new Set,D=v?v.remoteDropped:new Set,B=v?v.baseIndex:Eo(m,p,s,P(n.identity.base),N),M=n.localIsBase||m===R?null:Eo(R,y,s,P(n.identity.local),L),x=v?v.remoteIndex:Eo(S,C,s,P(n.identity.remote),D),k=T=>{let q=ut(T)&&y(T);return q&&M?.get(q)===T&&!B.has(q)?q:null},z=T=>{let q=ut(T)&&C(T);return q&&x.get(q)===T&&!B.has(q)?q:null},U=M?es(m,R,{analyzer:l,baseIndex:B,sideIndex:M,baseId:g.base,sideId:g.local,baseKey:p,sideKey:y,baseDropped:N,sideDropped:L,stats:d}):Tr(),K=es(m,S,{analyzer:l,baseIndex:B,sideIndex:x,baseId:g.base,sideId:g.remote,baseKey:p,sideKey:C,baseDropped:N,sideDropped:D,stats:d,scope:v,comparisons:n.comparisons});if(v){if(!v.held(K))return null;for(let T of v.dropped)Qo(T)}let Ae=null;function Me(T){if(!Ae){Ae=new WeakMap;let q=[m];for(;q.length;){let Q=q.pop();Q.tagName==="TEMPLATE"&&Q.content&&Ae.set(Q.content,Q);for(let we of l.childrenOf(Q))we.nodeType===1&&q.push(we)}}return Ae.get(T)||null}let Be=T=>{let q=ut(T)||T.nodeType?T.parentNode:T.parent;return q&&q.nodeType===11?Me(q):q};if(K.moved.size){let T=!1;for(let q of Array.from(K.moved))!ut(q)||K.identityPaired.has(q)||!g.base(q)||me(K,Be(q))||(K.unpair(q),T=!0);T&&K.rematch()}le(),ge(U,K),ge(K,U);for(let T of[U,K])if(T.refused)for(let q of T.refused)T.moved.has(q)||d.ambiguousMoves++;O&&(O.alignTotal=(O.alignTotal||0)+(performance.now()-E),E=performance.now());let te=m.ownerDocument.implementation.createHTMLDocument(""),ve=new WeakMap,ze=new WeakMap,re=[],b=[],_=new Set,oe=[],ee=new Set,Pe=new Set,Ke=new Set,Ne=new WeakMap,ot=null,Qe=n.conflicts||"remote",Ze=T=>re.push(T),Xe=T=>re.push(T),wt=ur({roots:{base:m,local:R,remote:S},L:U,R:K,unitsOf:r,provenance:ve,policy:Qe}),dt=(T,q)=>{b.push(T),q&&wt.note(T,q)},gt=null,zt=null,_t=$t(),Ht=null,Bt=J(m,U.map.get(m),K.map.get(m),!!n.localIsBase,!!n.childrenOnly);Bt.tagName==="HTML"?te.replaceChild(Bt,te.documentElement):te.body.appendChild(Bt),gt?.drain(Bt),zt?.drain(Bt),O&&(O.build=(O.build||0)+(performance.now()-E));let an=n.childrenOnly?!fe(ne(Bt),ne(S)):!pe(Bt,S),Kt=wt.finish(Bt);return{doc:te,root:Bt,provenance:ve,textMappers:ze,decisions:re,conflicts:b,recoveryLinks:Kt,localDiverged:an,mergedScripts:_,segments:oe,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==gn,L:U,R:K,stats:d};function $t(){let T=new Map,q=new Set;if(n.localIsBase||!U.insertedByHash)return{partner:T,drop:q};let Q=U.insertedByHash(),we=K.insertedByHash();if(!Q.size||!we.size)return{partner:T,drop:q};let ue={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ie=pt=>{let bt=0;for(let mt=pt.parentNode;mt;mt=mt.parentNode)bt++;return bt},ae=[],De=pt=>{let bt=pt.textContent.trim();return bt.split(/\s+/).length>=3||bt.replace(/\s/g,"").length>=12},qe=pt=>{let bt=me(U,pt),mt=me(K,pt);return bt&&U.reverse.get(bt.parentNode)!==pt.parentNode||mt&&K.reverse.get(mt.parentNode)!==pt.parentNode},Ue=(pt,bt,mt)=>{for(let at of mt.parentNode.children){let Vt=at!==mt&&pt.reverse.get(at);if(Vt&&qe(Vt))return!0}let Ct=pt.reverse.get(mt.parentNode);if(Ct){for(let at of Ct.children)if(!me(bt,at)&&!s(at))return!0}return!1},_e=new Map([[U,new Map],[K,new Map]]),Ge=(pt,bt)=>{let mt=_e.get(pt),Ct=mt.get(bt);if(Ct===void 0){Ct=!1;for(let at of bt.children)if(pt.reverse.has(at)||Ge(pt,at)){Ct=!0;break}mt.set(bt,Ct)}return Ct},et=new Map;for(let pt of we.values())for(let bt of pt){let mt=z(bt);mt&&et.set(mt,bt)}for(let pt of Q.values())for(let bt of pt){let mt=k(bt),Ct=mt?et.get(mt):null;Ct&&Ct.tagName===bt.tagName&&!Pn(bt,ue)&&!Pn(Ct,ue)&&!n.remoteWins(bt)&&!n.remoteWins(Ct)&&ae.push([bt,[Ct],ie(bt),!0,!0])}for(let[pt,bt]of Q){let mt=we.get(pt);if(!mt)continue;let Ct=bt.length===1&&mt.length===1;for(let at of bt)!Pn(at,ue)&&!k(at)&&ae.push([at,mt,ie(at),Ct&&(De(at)||Ue(U,K,at)||Ue(K,U,mt[0]))])}if(!ae.length)return{partner:T,drop:q};ae.sort((pt,bt)=>pt[2]-bt[2]);let Mt=new Set,kt=new Set,Jt=pt=>{for(let bt of pt.querySelectorAll("*"))Mt.add(bt)},Ot=(pt,bt)=>pt.reverse.get(bt.parentNode)||null;for(let[pt,bt,,mt,Ct]of ae){if(Mt.has(pt)||kt.has(pt)||Ct&&(Ge(U,pt)||Ge(K,bt[0])))continue;let at=Ot(U,pt),Vt=Gt=>!kt.has(Gt)&&!Mt.has(Gt)&&(Ct||Gt.tagName===pt.tagName&&!z(Gt)&&l.equalUnits(pt,Gt)),St=bt.find(Gt=>at&&Ot(K,Gt)===at&&Vt(Gt))||(mt?bt.find(Vt):null);if(!St)continue;kt.add(pt),kt.add(St);let cn=at&&Ot(K,St)===at;(!Ct||!cn||l.equalUnits(pt,St))&&(Jt(pt),Jt(St)),!cn&&(T.set(pt,St),T.set(St,pt),q.add(Qe==="local"?St:pt))}return{partner:T,drop:q}}function F(T,q,Q){if(ee.add(T),_t.drop.has(T))return null;ee.add(Q);let we=q==="local"?T:Q,ue=q==="local"?Q:T,ie;return l.equalUnits(we,ue)?(ie=G(we,"local",!0),ve.get(ie).remote=ue):ie=H(we,ue),dt({kind:"structure",el:ie,detail:"both-moved",base:null,local:we,remote:ue},{unit:{b:null,l:we,r:ue}}),Ze({kind:"insert",el:ie,source:"both"}),ie}function le(){if(!U.weak||!K.weak||!U.weak.size||!K.weak.size||!U.unpair)return;let T=new Map;for(let Q of U.weak){let we=me(U,Q);ut(Q)&&ut(we)&&T.set(l.unitHash(we),Q)}let q=!1;for(let Q of Array.from(K.weak)){let we=me(K,Q);if(!ut(Q)||!ut(we))continue;let ue=T.get(l.unitHash(we));if(!ue||ue===Q||!U.weak.has(ue)||me(U,Q)&&me(K,ue))continue;let ie=me(U,ue);ie.tagName===we.tagName&&l.equalUnits(ie,we)&&(U.unpair(ue),K.unpair(Q),q=!0)}q&&(U.rematch(),K.rematch())}function ge(T,q){if(!T.weak||!T.weak.size||!q.insertedByHash)return;let Q=q.insertedByHash();if(!Q.size)return;let we=!1;for(let ue of Array.from(T.weak)){let ie=me(T,ue);if(!ie)continue;let ae=T===U?k(ie):z(ie);if(ae){let qe=(T===U?x:M)?.get(ae);qe&&qe.tagName===ie.tagName&&!q.reverse.has(qe)&&(T.unpair(ue),we=!0);continue}let De=Q.get(l.unitHash(ie));De&&De.some(qe=>qe.tagName===ie.tagName&&l.equalUnits(qe,ie))&&(T.unpair(ue),we=!0)}we&&T.rematch()}function me(T,q){if(!q)return null;if(T.map.has(q))return T.map.get(q);let Q=[],we=Be(q);for(;we&&!T.map.has(we);we=Be(we))Q.push(we);let ue=we;if(!ue||!T.identical.has(ue))return null;T.pairIdenticalChildren(ue);for(let ae=Q.length-1;ae>=0;ae--)T.pairIdenticalChildren(Q[ae]);let ie=T.map.get(q)||null;return ie&&d.lazyTwins++,ie}function Te(T,q,Q,we){if(ut(T)&&Mn.has(T.tagName)&&!U.identical.has(T)&&(T.previousSibling?.nodeType===3||T.nextSibling?.nodeType===3)){let De=Be(T),qe=me(U,T),Ue=me(K,T);qe&&Ue&&$e(qe,me(U,De),U)&&!$e(Ue,me(K,De),K)&&(zt||=pr({L:U,R:K,twinIn:me,unitsOf:r,view:A,parentOf:Be,ignored:s,remoteWins:n.remoteWins,eligible:_e=>ut(_e)&&Mn.has(_e.tagName),build:J,out:te,policy:Qe,provenance:ve,textMappers:ze,segments:oe,conflicts:b,conflict:dt,decisions:re}),zt.ensureOwner(T))}if(q===null)return null;if(we!==void 0)return gt||=fo(ve,Be,U,K,me,J,s,n.remoteWins,b,dt,j,R,S),gt.plan(T,q,Q,!!we),we&&(gt.produced(T,we),Pe.add(T)),we;if(Pe.has(T)||Ke.has(T))return dt({kind:"structure",el:null,detail:"both-moved",base:T},{subject:T}),Pe.has(T)?null:G(Q,q);gt||=fo(ve,Be,U,K,me,J,s,n.remoteWins,b,dt,j,R,S),gt.plan(T,q,Q,!0);let ue=me(U,T),ie=me(K,T);(!ue||!ie)&&dt({kind:"structure",el:null,detail:"move-beats-delete",base:T},{subject:T,deleted:ue?"remote":"local"});let ae=J(T,ue,ie,!1);return(q==="local"?Ze:Xe)({kind:"move",el:ae,source:q}),ae}function A(T,q,Q,we){return we||!q||q===Q?{el:Q,asBase:!0,twin:ue=>ue,baseOf:ue=>ue,units:r(Q),here:()=>!0,parentOfTwin:()=>Q}:{el:q,asBase:!1,twin:ue=>me(T,ue),baseOf:ue=>T.reverse.get(ue),units:r(q),here:ue=>ut(ue)?ue.parentNode===q||q.tagName==="TEMPLATE"&&ue.parentNode===q.content:ue.parent===q||q.tagName==="TEMPLATE"&&ue.parent===q.content}}function j(T,q,Q){return!q||Q&&Q.identical.has(T)?!1:ut(T)?!l.equalUnits(T,q)||!Y(T,q,Q):T.value!==q.value}function Y(T,q,Q){if(!Q||T===q)return!0;let we=[[T,q]];for(;we.length;){let[ue,ie]=we.pop(),ae=r(ue),De=r(ie);for(let qe=0;qe<ae.length&&qe<De.length;qe++){let Ue=ae[qe],_e=De[qe];if(!ut(Ue)||!ut(_e))continue;let Ge=Q.map.get(Ue);if(Ge!==void 0&&Ge!==_e)return!1;let et=Q.reverse.get(_e);if(et!==void 0&&et!==Ue)return!1;we.push([Ue,_e])}}return!0}function J(T,q,Q,we,ue=!1){let ie=we||(Q?n.remoteWins(Q):n.remoteWins(T)),ae=T.namespaceURI&&T.namespaceURI!=="http://www.w3.org/1999/xhtml"?te.createElementNS(T.namespaceURI,T.tagName):te.createElement(T.tagName),De={base:T,local:q||null,remote:Q||null};if(ve.set(ae,De),ie&&!we&&q&&j(T,q,U)&&(!Q||!l.equalUnits(q,Q))&&dt({kind:"structure",el:ae,detail:"remote-wins",base:T,local:q,remote:Q||null},{subject:T}),ee.add(T),Pe.add(T),q&&ee.add(q),Q&&ee.add(Q),n.skipUnchanged&&!ue&&(n.localIsBase||U.identical.has(T))&&Q&&K.identical.has(T)&&!n.remoteWins(T)){De.unchanged=!0;for(let Ue of T.attributes)Ue.namespaceURI?ae.setAttributeNS(Ue.namespaceURI,Ue.name,Ue.value):ae.setAttribute(Ue.name,Ue.value);return gt?.produced(T,ae),ae}Ke.add(T),ue||Z(T,ie?T:q,Q,ae);let qe=T.tagName;if(dn(T))je(T,ie?T:q,Q,ae);else if(qe==="TEXTAREA")ae.textContent=se(T.textContent,(ie?T:q)?(ie?T:q).textContent:T.textContent,Q?Q.textContent:T.textContent,ae,"text");else if(!zt?.render(T,ae)){let Ue=de(T,q,Q,ie,ae),_e=qe==="TEMPLATE"&&ae.content?ae.content:ae;for(let Ge of Ue)_e.appendChild(Ge)}return Ke.delete(T),gt?.produced(T,ae),ae}function se(T,q,Q,we,ue){if(q===Q)return q;if(q===T)return Q!==T&&Xe({kind:ue,node:we,source:"remote"}),Q;if(Q===T)return Ze({kind:ue,node:we,source:"local"}),q;let ie=Qe==="local"?q:Q;return dt({kind:ue,node:we,base:T,local:q,remote:Q,resolved:ie},{site:"whole",el:we}),re.push({kind:ue,node:we,source:"both"}),ie}function je(T,q,Q,we){let ue=T.textContent,ie=q?q.textContent:ue,ae=Q?Q.textContent:ue,De=w?lo(T,n.mergeTags,!0):null;if(De&&ie!==ae){let qe=Q&&Q.getAttribute("merge-key")||T.getAttribute("merge-key"),{text:Ue,warnings:_e}=Vo(n.localIsBase?void 0:ue,ie,ae,{parse:De.recognizer.parse,keyCandidates:qe?qe.split(/[\s,]+/).filter(Boolean):void 0});for(let Ge of _e)console.warn(`[hyper-morph] merge "${De.raw}": ${Ge}`);we.textContent=Ue,_.add(we),Ue!==ae?Ze({kind:"text",node:we,source:Ue===ie?"local":"both"}):Ue!==ue&&Xe({kind:"text",node:we,source:"remote"});return}we.textContent=se(ue,ie,ae,we,"text")}function Z(T,q,Q,we){let ue=new Map;for(let ie of[T,q,Q])if(ie)for(let ae of ie.attributes)n.ignoreAttribute(ie,ae.name)||ue.set(ae.name,ae);for(let[ie,ae]of ue){let De=T?T.getAttribute(ie):null,qe=q?q.getAttribute(ie):De,Ue=Q?Q.getAttribute(ie):De,_e;qe===Ue?_e=qe:qe===De?(_e=Ue,Xe({kind:"attr",el:we,name:ie,source:"remote"})):Ue===De?(_e=qe,Ze({kind:"attr",el:we,name:ie,source:"local"})):(_e=Ie(ie,De,qe,Ue),_e===void 0&&(_e=Qe==="local"?qe:Ue,dt({kind:"attr",el:we,name:ie,base:De,local:qe,remote:Ue,resolved:_e},{el:we,sample:ae})),re.push({kind:"attr",el:we,name:ie,source:"both"})),_e!=null&&(ae.namespaceURI?we.setAttributeNS(ae.namespaceURI,ae.name,_e):we.setAttribute(ie,_e))}}function Ie(T,q,Q,we){if(T==="class"){let ue=Ue=>new Set((Ue||"").split(/\s+/).filter(Boolean)),ie=ue(q),ae=ue(Q),De=ue(we),qe=new Set;for(let Ue of new Set([...ie,...ae,...De])){let _e=ie.has(Ue),Ge=ae.has(Ue),et=De.has(Ue);(Ge===et?Ge:Ge===_e?et:Ge)&&qe.add(Ue)}return[...qe].join(" ")}if(T==="style"){let ue=_e=>{let Ge=new Map;if(!_e)return Ge;let et=0,Mt=null,kt="",Jt=()=>{let Ot=kt.indexOf(":");Ot>0&&Ge.set(kt.slice(0,Ot).trim(),kt.slice(Ot+1).trim()),kt=""};for(let Ot of _e){if(Mt){kt+=Ot,Ot===Mt&&(Mt=null);continue}if(Ot==='"'||Ot==="'"){Mt=Ot,kt+=Ot;continue}if(Ot==="("?et++:Ot===")"&&et--,Ot===";"&&et===0){Jt();continue}kt+=Ot}return kt.trim()&&Jt(),Ge},ie=ue(q),ae=ue(Q),De=ue(we),qe=new Map,Ue=!1;for(let _e of new Set([...ie.keys(),...ae.keys(),...De.keys()])){let Ge=ie.get(_e)??null,et=ae.get(_e)??null,Mt=De.get(_e)??null,kt;et===Mt?kt=et:et===Ge?kt=Mt:Mt===Ge?kt=et:(kt=Qe==="local"?et:Mt,Ue=!0),kt!=null&&qe.set(_e,kt)}return Ue?void 0:[...qe].map(([_e,Ge])=>`${_e}: ${Ge}`).join("; ")}}function He(T,q,Q,we){let ue=T.value,ie=we?ue:q?q.value:"",ae=Q?Q.value:"";ee.add(T),q&&ee.add(q),Q&&ee.add(Q);let De=no(ue,ie,ae,Qe),qe=De.text===""?null:te.createTextNode(De.text);qe&&(ve.set(qe,{base:T.nodes,local:q?q.nodes:null,remote:Q?Q.nodes:null}),ze.set(qe,De.mapLocalOffset)),ie!==ue&&ae!==ue?re.push({kind:"text",node:qe,source:"both"}):ie!==ue?Ze({kind:"text",node:qe,source:"local"}):ae!==ue&&Xe({kind:"text",node:qe,source:"remote"});for(let Ue of De.conflicts)dt({kind:"text",node:qe,base:ue.slice(Ue.bs,Ue.be),local:Ue.local,remote:Ue.remote,resolved:Ue.resolved},{site:"run",bRun:T,lRun:q,rRun:Q,node:qe,c:Ue});return qe}function Ce(T,q){return Fn(T,q).every(Q=>Q.bs===Q.be)}function be(T,q){let Q=T?T.value:"",we=q?q.value:"",ue;if(Q===we||!we?ue=Q:Q?Ce(Q,we)?ue=we:Ce(we,Q)?ue=Q:(ue=Qe==="local"?Q:Qe==="both"?Q+we:we,dt({kind:"structure",el:null,detail:"insert-collision",local:Q,remote:we,resolved:ue},{unit:{b:null,l:T,r:q},localLost:Qe==="remote"})):ue=we,T&&ee.add(T),q&&ee.add(q),ue==="")return null;let ie=te.createTextNode(ue);return ve.set(ie,{base:null,local:T?T.nodes:null,remote:q?q.nodes:null}),Q?Ze({kind:"insert",el:ie,source:we&&Q===we?"both":"local"}):Xe({kind:"insert",el:ie,source:"remote"}),ie}function H(T,q){let Q={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},we=De=>r(De).every(qe=>ut(qe)?Pn(qe,Q):qe.kind==="text"),ue=null;if(we(T)&&we(q)){let De=T.textContent,qe=q.textContent;De===qe||Ce(qe,De)?ue=q:Ce(De,qe)&&(ue=T)}if(!ue){let De=Qe==="local",qe=G(De?T:q,De?"local":"remote",!0),Ue=ve.get(qe);return De?Ue.remote=q:Ue.local=T,dt({kind:"structure",el:qe,detail:"insert-collision",local:T,remote:q,resolved:De?T:q},{unit:{b:null,l:T,r:q},localLost:!De}),qe}let ie=T.namespaceURI&&T.namespaceURI!=="http://www.w3.org/1999/xhtml"?te.createElementNS(T.namespaceURI,T.tagName):te.createElement(T.tagName);Z(null,T,q,ie),ve.set(ie,{base:null,local:T,remote:q}),ee.add(T),ee.add(q);let ae=Gn({base:Array.from(ue.childNodes),local:Array.from(T.childNodes),remote:Array.from(q.childNodes),out:te,policy:Qe,idOf:{local:y,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:ve,textMappers:ze,conflicts:b,conflict:dt,scope:{base:null,local:T,remote:q,units:[],at:0},synthetic:!0,decisions:re,node:ie});oe.push(...ae.segments);for(let De of ae.nodes)ie.appendChild(De);return ie}function G(T,q,Q=!1){if(!Q&&ut(T)){let ae=_t.partner.get(T);if(ae)return F(T,q,ae)}if(!ut(T)){if(T.value==="")return null;let ae=T.kind==="comment"?te.createComment(T.value):te.createTextNode(T.value);return ve.set(ae,{base:null,local:q==="local"?T.nodes:null,remote:q==="remote"?T.nodes:null}),ee.add(T),ae}let we=T.namespaceURI&&T.namespaceURI!=="http://www.w3.org/1999/xhtml"?te.createElementNS(T.namespaceURI,T.tagName):te.createElement(T.tagName);for(let ae of T.attributes)ae.namespaceURI?we.setAttributeNS(ae.namespaceURI,ae.name,ae.value):we.setAttribute(ae.name,ae.value);ve.set(we,{base:null,local:q==="local"?T:null,remote:q==="remote"?T:null}),ee.add(T);let ue=T.tagName==="TEMPLATE"&&we.content?we.content:we,ie=q==="local"?U:K;for(let ae of r(T)){let De=ut(ae)?ie.reverse.get(ae):null;if(De&&Te(De,null,null),De&&Pe.has(De)){dt({kind:"structure",el:null,detail:"both-moved",base:De},{subject:De});continue}if(De&&!Ke.has(De)){let Ue=me(U,De)||null,_e=me(K,De)||null;if(Ue||_e){gt||=fo(ve,Be,U,K,me,J,s,n.remoteWins,b,dt,j,R,S),gt.plan(De,q,ae,!0);let Ge=J(De,Ue,_e,!1);q==="local"?Ze({kind:"move",el:Ge,source:"local"}):Xe({kind:"move",el:Ge,source:"remote"}),ue.appendChild(Ge);continue}}let qe=G(ae,q);qe&&ue.appendChild(qe)}if(!Q&&_t.drop.size&&T.tagName==="DIV"&&!ue.firstChild&&!T.attributes.length&&!(q==="local"?y(T):C(T))&&!ie.reverse.has(T)&&!s(T)&&!n.remoteWins(T)){let ae=T.firstChild;if(ae&&ae===T.lastChild&&ut(ae)&&(_t.drop.has(ae)||Ht?.has(ae)))return(Ht||=new WeakSet).add(T),null}return we}function de(T,q,Q,we,ue){q&&U.identical.has(T)&&U.pairIdenticalChildren(T),Q&&K.identical.has(T)&&K.pairIdenticalChildren(T);let ie=A(U,q,T,we),ae=A(K,Q,T,!1),De=r(T),qe=new Set(De),Ue=new Map;for(let ye=0;ye<De.length;ye++)Ue.set(De[ye],ye);let _e=[],Ge=new Set,et=new Map,Mt=new Set,kt=new Set,Jt=[],Ot=null;if(!ie.asBase&&!ae.asBase&&!U.identical.has(T)&&!K.identical.has(T))for(let ye of De){if(!ut(ye)||!Mn.has(ye.tagName))continue;let Je=ie.twin(ye),Ye=ae.twin(ye);Je&&Ye&&(!ie.here(Je)||!ae.here(Ye))&&Te(ye,null,null)}zo();let pt=ye=>{let Je=[];for(let Ye of ye.units){if(kt.has(Ye))continue;let xt=ye.baseOf(Ye);xt&&qe.has(xt)&&Je.push(xt)}return Je},bt=ye=>pt(ye).map(Je=>Ue.get(Je)),mt=ye=>ye.every((Je,Ye)=>Ye===0||Je>=ye[Ye-1]),Ct=!ie.asBase&&!mt(bt(ie)),at=!ae.asBase&&!mt(bt(ae));Ct&&at&&dt({kind:"structure",el:ue,detail:"both-reordered",base:T},{subject:T,lKept:pt(ie),rKept:pt(ae)});let Vt=at||!Ct?{V:ae,A:K,side:"remote",other:ie,otherA:U,otherSide:"local"}:{V:ie,A:U,side:"local",other:ae,otherA:K,otherSide:"remote"};Ct?Ze({kind:"move",el:null,source:at?"both":"local",base:T}):at&&Xe({kind:"move",el:null,source:"remote",base:T});let St=ie.asBase?[]:ie.units.filter(ye=>!ie.baseOf(ye)&&!kt.has(ye)&&!_t.partner.has(ye)),cn=ae.asBase?[]:ae.units.filter(ye=>!ae.baseOf(ye)&&!kt.has(ye)&&!_t.partner.has(ye)),Gt=new Map;if(St.length&&cn.length){let ye=new Map,Je=new Map;for(let st of cn){if(ut(st)){let Rt=C(st);Rt&&ye.set(Rt,st)}let vt=l.unitHash(st);Je.has(vt)||Je.set(vt,[]),Je.get(vt).push(st)}let Ye=(st,vt)=>{let Rt=st.units.indexOf(vt);for(let ct=Rt-1;ct>=0;ct--){let Nt=st.baseOf(st.units[ct]);if(Nt)return Nt}return"start"},xt=new Map,jt=new Map;for(let st of cn){let vt=Ye(ae,st);ut(st)?(jt.has(vt)||jt.set(vt,[]),jt.get(vt).push(st)):st.kind==="text"&&!xt.has(vt)&&xt.set(vt,st)}for(let st of St){let vt=null;if(ut(st)){let ct=y(st);ct&&ye.has(ct)&&!Gt.has(ye.get(ct))&&(vt=ye.get(ct))}else if(st.kind==="text"){let ct=xt.get(Ye(ie,st));ct&&!Gt.has(ct)&&(vt=ct)}let Rt=!!k(st);if(!vt&&!Rt){let ct=Je.get(l.unitHash(st));ct&&(vt=ct.find(Nt=>!Gt.has(Nt)&&ut(Nt)===ut(st)&&(ut(Nt)?Nt.tagName===st.tagName&&!z(Nt):Nt.kind===st.kind)&&l.equalUnits(st,Nt))||null)}if(!vt&&ut(st)&&!Rt){let ct=g.local(st),Nt=(jt.get(Ye(ie,st))||[]).filter(sn=>{let fn=g.remote(sn);return!Gt.has(sn)&&sn.tagName===st.tagName&&!z(sn)&&!(ct&&fn&&ct!==fn)&&l.similar(st,sn)});Nt.length===1&&(vt=Nt[0])}vt&&(Gt.set(vt,st),Gt.set(st,vt))}}let jn=ye=>{if(zt?.consumes(ye))return null;if(ee.has(ye)||gt?.has(ye))return et.get(ye)||null;let Je=ie.twin(ye),Ye=ae.twin(ye),xt=Je&&!ie.asBase&&!ie.here(Je),jt=Ye&&!ae.asBase&&!ae.here(Ye);if(xt||jt){if((!Je||!Ye)&&dt({kind:"structure",el:null,detail:"move-beats-delete",base:ye},{subject:ye,deleted:Je?"remote":"local"}),!Oe(ye))return ut(ye)?(gt||=fo(ve,Be,U,K,me,J,s,n.remoteWins,b,dt,j,R,S),xt&>.plan(ye,"local",Je),jt&>.plan(ye,"remote",Ye)):ee.add(ye),null;dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye})}if(Je&&!Ye&&!ie.asBase&&!ae.asBase&&ut(ye)&&Mn.has(ye.tagName)&&!n.remoteWins(ye)&&!n.remoteWins(Je)&&j(ye,Je,U)&&Ji(ye,ne(ae.el),s)){let Nt={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},sn=fn=>ut(fn)?Pn(fn,Nt):fn.kind==="text";if(r(ye).every(sn)&&r(Je).every(sn)){let fn=Gn({base:[ye],local:[Je],remote:[],blocks:new Set([ye,Je]),out:te,policy:Qe,L:U,R:K,idOf:{base:p,local:y,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(pn,kn,In)=>J(pn,kn,In,!1),cloneUnit:G,mergeAttrs:Z,atomKey:l.exactUnitKey,moveIn:Te,moveBuilt:Te,movePlanned:Te,provenance:ve,textMappers:ze,conflicts:b,conflict:dt,scope:{base:T,local:ie.el,remote:ae.el,units:De,at:Ue.get(ye)},decisions:re,node:ue});oe.push(...fn.segments),ee.add(ye),ee.add(Je);let yn=te.createDocumentFragment();for(let pn of fn.nodes)yn.appendChild(pn);return et.set(ye,yn),et.set(Je,yn),yn}}if(!Je&&!Ye)return ee.add(ye),Xe({kind:"remove",source:"both",base:ye}),null;if(!Je&&!j(ye,Ye,K))return ee.add(ye),Ze({kind:"remove",source:"local",base:ye}),null;if(!Ye&&!j(ye,Je,U))return ee.add(ye),Xe({kind:"remove",source:"remote",base:ye}),null;let st=!Je||!Ye,vt=ie.asBase?me(U,ye)||null:Je,Rt=ae.asBase&&ut(ye)&&(K.identityPaired.has(ye)||!g.base(ye))&&me(K,ye)||Ye,ct;return ut(ye)?ct=J(ye,vt,Rt,ie.asBase):ye.kind==="comment"?ct=Re(ye,vt,Ye,ie.asBase):ct=He(ye,vt,Ye,ie.asBase),ee.add(ye),ct&&(et.set(ye,ct),Je&&et.set(Je,ct),Ye&&et.set(Ye,ct),st&&(dt({kind:"structure",el:ct,detail:"edit-beats-delete",base:ye},{subject:ye,deleted:Je?"remote":"local"}),Je?Ze({kind:"insert",el:ct,source:"local"}):Xe({kind:"insert",el:ct,source:"remote"}))),ct},On=(ye,Je,Ye,xt)=>{if(zt?.consumes(ye))return null;if(ee.has(ye))return et.get(ye)||null;let jt=Je.baseOf(ye);if(jt&&qe.has(jt))return kt.has(jt)&&!kt.has(ye)?Ao(jt,ye,xt):jn(jt);if(jt)return Dn(jt,ye,xt);let st=Gt.get(ye);if(st){let Rt=xt==="local"?ye:st,ct=xt==="local"?st:ye,Nt;return ut(Rt)?l.equalUnits(Rt,ct)?(Nt=G(Rt,"local"),Nt&&(ve.get(Nt).remote=ct)):Nt=H(Rt,ct):Nt=be(Rt,ct),ee.add(Rt),ee.add(ct),Nt&&(et.set(Rt,Nt),et.set(ct,Nt),ut(Rt)&&Ze({kind:"insert",el:Nt,source:"both"})),Nt}let vt=G(ye,xt);return vt&&(et.set(ye,vt),xt==="local"?Ze({kind:"insert",el:vt,source:"local"}):Xe({kind:"insert",el:vt,source:"remote"})),vt},Ao=(ye,Je,Ye)=>{let xt;return ut(ye)?(xt=Te(ye,Ye,Je),xt&&ee.add(Je)):(xt=G(Je,Ye),ee.add(Je),xt&&(Ye==="local"?Ze:Xe)({kind:"insert",el:xt,source:Ye})),xt&&et.set(Je,xt),xt},Dn=(ye,Je,Ye)=>{Te(ye,null,null);let jt=me(Ye==="local"?K:U,ye),st=Je,vt=jt?$e(jt,Ye==="local"?Q:q,Ye==="local"?K:U):!1,Rt=jt&&!vt&&!tt(ye,jt);if(Rt&&Ye===Vt.otherSide)return dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye}),null;if(Rt&&dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye}),jt||dt({kind:"structure",el:null,detail:"move-beats-delete",base:ye},{subject:ye,deleted:Ye==="local"?"remote":"local"}),Ke.has(ye)){dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye});let Nt=G(st,Ye);return Nt&&et.set(Je,Nt),Nt}ut(ye)&&(gt||=fo(ve,Be,U,K,me,J,s,n.remoteWins,b,dt,j,R,S),gt.plan(ye,Ye,st,!0));let ct=ut(ye)?J(ye,Ye==="local"?st:me(U,ye)||null,Ye==="remote"?st:me(K,ye)||null,!1):null;return ct&&(et.set(ye,ct),et.set(Je,ct),jt&&et.set(jt,ct),Ye==="local"?Ze({kind:"move",el:ct,source:"local"}):Xe({kind:"move",el:ct,source:"remote"})),ct};for(let ye of Vt.V.units){if(kt.has(ye)){if(Ot?.has(ye)){for(let xt of Ot.get(ye))Ge.has(xt)||(_e.push(xt),Ge.add(xt));continue}let Ye=et.get(ye);Ge.has(Ye)||(_e.push(Ye),Ge.add(Ye));continue}if(ee.has(ye)&&!(et.get(ye)&&Ge.has(et.get(ye)))){let Ye=Vt.V.baseOf(ye);Ye&&!qe.has(Ye)&&dt({kind:"structure",el:null,detail:"both-moved",base:Ye},{subject:Ye});continue}let Je=On(ye,Vt.V,Vt.A,Vt.side);Je&&!Ge.has(Je)&&(_e.push(Je),Ge.add(Je),!Vt.V.baseOf(ye)&&!Gt.has(ye)&&!kt.has(ye)&&Mt.add(Je))}for(let ye of Jt)Ge.has(ye.frag)||(_e.splice(ye.previous&&Ge.has(ye.previous)?_e.indexOf(ye.previous)+1:go(ye.at),0,ye.frag),Ge.add(ye.frag));if(!Vt.other.asBase){let ye=Vt.other,Je=Vt.otherSide,Ye=Vt.otherA,xt=null,jt=0,st=null;for(let vt of ye.units){let Rt=et.get(vt);if(Rt&&Ge.has(Rt)){xt=Rt,st=null;continue}if(ee.has(vt)){let sn=ye.baseOf(vt);sn&&!qe.has(sn)&&dt({kind:"structure",el:null,detail:"both-moved",base:sn},{subject:sn});continue}let ct=On(vt,ye,Ye,Je);if(!ct)continue;let Nt;if(st)Nt=_e.indexOf(st)+1;else if(xt){if(Nt=_e.indexOf(xt)+1,Je==="remote")for(;Nt<_e.length&&Mt.has(_e[Nt]);)Nt++}else Nt=jt++;_e.splice(Nt,0,ct),Ge.add(ct),st=ct}}for(let ye=0;ye<De.length;ye++){let Je=De[ye];if(ee.has(Je))continue;let Ye=jn(Je);Ye&&_e.splice(go(ye),0,Ye)}return _e;function go(ye){for(let Je=ye-1;Je>=0;Je--){let Ye=et.get(De[Je]);if(Ye){let xt=_e.indexOf(Ye);if(xt>=0)return xt+1}}return 0}function zo(){if((ie.asBase||U.identical.has(T))&&(ae.asBase||K.identical.has(T)))return;let ye={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},Je=it=>ut(it)?Pn(it,ye):it.kind==="text";if(!ie.asBase&&!ae.asBase)for(let it of De){if(!ut(it)||!Mn.has(it.tagName))continue;let nt=ie.twin(it),Lt=ae.twin(it);if(!nt&&Lt||nt&&!Lt){let rt=wr({base:De,views:[{V:ie,A:U,idOf:g.local},{V:ae,A:K,idOf:g.remote}],eligible:It=>ut(It)&&Mn.has(It.tagName)&&!s(It)&&!n.remoteWins(It),baseId:g.base,ignored:s,remoteWins:n.remoteWins,atomKey:l.exactUnitKey});rt&&(ie=rt[0],ae=rt[1]);break}}let Ye=!ie.asBase&&!ae.asBase&&De.length>=2&&Mn.has(De[0].tagName)&&ie.units.length===De.length&&ae.units.length===De.length?Xs({base:De,local:ie.units,remote:ae.units,localTwin:ie.twin,remoteTwin:ae.twin,eligible:it=>ut(it)&&Mn.has(it.tagName)&&!s(it)&&!n.remoteWins(it),nodes:{base:Array.from(ne(T).childNodes),local:Array.from(ne(ie.el).childNodes),remote:Array.from(ne(ae.el).childNodes)}}):null,xt=null,jt=null;if(!Ye&&!ie.asBase&&!ae.asBase&&(ys(De)||ys(ie.units)||ys(ae.units))){let it={ignored:s,remoteWins:()=>!1},nt=rt=>Je(rt)||ut(rt)&&n.remoteWins(rt)&&wn.has(rt.tagName)&&Pn(rt,it),Lt=rt=>ut(rt)?Mn.has(rt.tagName)&&!s(rt)&&!n.remoteWins(rt)&&r(rt).every(nt):rt.kind==="text";xt=yr({onUncertainOwner:rt=>{let It=n.identity.local(rt.local);It&&It===n.identity.remote(rt.remote)||(jt||=[]).push(rt)},onUncertainSource:rt=>{ot||(ot=new Map);let It=ot.get(rt.source);It||ot.set(rt.source,It=[]);for(let Yt of It)if(Yt.side===rt.side&&Yt.from===rt.from&&Yt.to===rt.to)return;It.push(rt)},base:De,views:[{V:ie,A:U,idOf:g.local},{V:ae,A:K,idOf:g.remote}],eligible:Lt,ignored:s,remoteWins:n.remoteWins,baseId:g.base,atomKey:l.exactUnitKey})}if(jt){Ot||=new Map;for(let it of jt){let{source:nt,local:Lt,remote:rt}=it,It={map:new Map,reverse:new Map,identical:new Set},Yt=Gn({base:[nt],local:[Lt],remote:[rt],out:te,policy:"both",L:It,R:It,ignored:s,remoteWins:n.remoteWins,atomKey:l.exactUnitKey,cloneUnit:G,provenance:ve,textMappers:ze,conflicts:b,decisions:re,conflict:(Et,tn)=>dt(Et,{...tn,policy:"both"}),scope:{base:T,local:ie.el,remote:ae.el,units:De,at:Ue.get(nt)},node:ue});oe.push(...Yt.segments);for(let Et of[nt,Lt,rt])ee.add(Et),kt.add(Et),Ot.set(Et,Yt.nodes),et.set(Et,Yt.nodes[Yt.nodes.length-1]);for(let Et=0;Et<Yt.nodes.length;Et++)Jt.push({frag:Yt.nodes[Et],at:Ue.get(nt),previous:Et?Yt.nodes[Et-1]:null})}}let st=Ye?Ye.blocks:null;if(xt){st=new Set;for(let it of xt.blocks)st.add(it)}let vt=it=>!zt?.consumes(it)&&(st&&st.has(it)||Je(it)),Rt=De.map(vt);if(!Rt.includes(!0))return;let ct=it=>{let nt=it.units,Lt=new Map;for(let Wt=0;Wt<nt.length;Wt++)Lt.set(nt[Wt],Wt);let rt=[],It=-1;for(let Wt=0;Wt<De.length;Wt++){if(Rt[Wt])continue;let At=it.twin(De[Wt]),Tt=At?Lt.get(At):void 0;Tt===void 0||Tt<=It||vt(At)||(rt.push([Wt,Tt]),It=Tt)}let Yt=[],Et=-1,tn=-1;for(let Wt=0;Wt<=rt.length;Wt++){let[At,Tt]=Wt<rt.length?rt[Wt]:[De.length,nt.length],Dt={bLo:-1,bHi:-1,from:tn+1,to:Tt,inlineStart:-1,inlineEnd:-1,next:Tt};for(let Qt=Et+1;Qt<At;Qt++)Rt[Qt]&&(Dt.bLo<0&&(Dt.bLo=Qt),Dt.bHi=Qt);for(let Qt=tn+1;Qt<Tt;Qt++){let Hn=nt[Qt];vt(Hn)&&(Dt.inlineStart<0&&(Dt.inlineStart=Qt),Dt.inlineEnd=Qt+1)}Yt.push(Dt),Et=At,tn=Tt}return{units:nt,list:Yt}},Nt=ct(ie),sn=ct(ae),fn=[];for(let it of[Nt,sn])for(let nt of it.list)nt.bLo>=0&&fn.push([nt.bLo,nt.bHi]);fn.sort((it,nt)=>it[0]-nt[0]);let yn=[];for(let[it,nt]of fn){let Lt=yn[yn.length-1];Lt&&it<=Lt.hi?Lt.hi=Math.max(Lt.hi,nt):yn.push({lo:it,hi:nt})}let pn=(it,nt)=>it.length===nt.length&&it.every((Lt,rt)=>l.equalUnits(Lt,nt[rt])),kn=it=>!ut(it)&&it.kind==="comment",In=it=>{if(!it.length)return[];let nt=(Et,tn)=>ut(Et)?Et:Et.nodes[tn?Et.nodes.length-1:0],Lt=nt(it[0]),rt=nt(it[it.length-1],!0),It=Et=>Et&&ut(Et)&&s(Et);for(;It(Lt.previousSibling);)Lt=Lt.previousSibling;for(;It(rt.nextSibling);)rt=rt.nextSibling;let Yt=[];for(let Et=Lt;Et&&(Yt.push(Et),Et!==rt);Et=Et.nextSibling);return Yt},Mo=it=>it.some(nt=>ut(nt)&&s(nt));for(let it of yn){let nt=De.slice(it.lo,it.hi+1),Lt=null;if(xt)for(let At of nt){let Tt=xt.certificatesBySource.get(At);Tt&&(Lt||=[]).push(...Tt)}let rt=ie.asBase?null:ws(Nt,it),It=ae.asBase?null:ws(sn,it);if(Lt){let At=[new Set(rt||nt),new Set(It||nt)],Tt=Lt.some(Dt=>!At[Dt.side].has(Dt.target));for(let Dt of nt)if(st.has(Dt))for(let[Qt,Hn]of[[0,ie],[1,ae]]){let Vn=Hn.twin(Dt);Vn&&Hn.here(Vn)&&!At[Qt].has(Vn)&&(Tt=!0)}if(Tt)continue}if(nt.some(kn)||rt&&rt.some(kn)||It&&It.some(kn))continue;let Yt=In(rt||nt),Et=In(It||nt);if((!rt||pn(nt,rt))&&(!It||pn(nt,It))&&!(rt&&Mo(Yt)))continue;let tn=Gn({base:In(nt),sourceRetentions:ot?.get(T),local:Yt,remote:Et,out:te,policy:Qe,blocks:st,scopeUnits:Lt?[nt,rt||nt,It||nt]:null,certifiedOrigins:Lt?(At,Tt,Dt,Qt,Hn,Vn)=>kr({certificates:Lt,scopes:[nt,rt||nt,It||nt],flats:[At,Tt,Dt],keys:[Qt,Hn,Vn]}):null,prepared:Ye?Ye.prepared:null,nativeTransfers:Ye,L:rt?U:xr(U,T),R:It?K:xr(K,T),idOf:{base:p,local:y,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(At,Tt,Dt)=>J(At,Tt,Dt,!1),cloneUnit:G,mergeAttrs:Z,atomKey:l.exactUnitKey,moveIn:Te,moveBuilt:Te,movePlanned:Te,provenance:ve,textMappers:ze,conflicts:b,conflict:dt,scope:{base:T,local:ie.asBase?null:ie.el,remote:ae.asBase?null:ae.el,units:De,at:it.lo},decisions:re,node:ue});if(!tn){if(Lt){let At=Js({certificates:Lt,scopes:[nt,rt||nt,It||nt],views:[{V:ie,A:U,idOf:g.local},{V:ae,A:K,idOf:g.remote}],eligible:Tt=>ut(Tt)&&Mn.has(Tt.tagName)&&!s(Tt)&&!n.remoteWins(Tt),baseId:g.base});for(let Tt of At.records){ot||=new Map;let Dt=ot.get(Tt.source);Dt||ot.set(Tt.source,Dt=[]),Dt.push(Tt)}}continue}if(oe.push(...tn.segments),Ye){let At=new Map;for(let Tt of tn.nodes){let Dt=ve.get(Tt)?.base;if(!Dt||At.has(Dt))throw new Error("Invalid native transfer owner output");At.set(Dt,Tt)}if(At.size!==Ye.owners.length)throw new Error("Incomplete native transfer owner output");for(let Tt of Ye.owners){let Dt=At.get(Tt.base);if(!Dt)throw new Error("Missing native transfer owner output");for(let Qt of[Tt.base,Tt.local,Tt.remote])ee.add(Qt),kt.add(Qt),et.set(Qt,Dt);Jt.push({frag:Dt,at:Ue.get(Tt.base)})}continue}if(tn.unitOutputs){Ot||=new Map;for(let At of[...nt,...rt||[],...It||[]]){let Tt=tn.unitOutputs.get(At)||[];ee.add(At),kt.add(At),Ot.set(At,Tt),Tt.length&&et.set(At,Tt[Tt.length-1])}for(let At=0;At<tn.nodes.length;At++)Jt.push({frag:tn.nodes[At],at:it.lo,previous:At>0?tn.nodes[At-1]:null});continue}let Wt=te.createDocumentFragment();for(let At of tn.nodes)Wt.appendChild(At);for(let At of[...nt,...rt||[],...It||[]])ee.add(At),kt.add(At),et.set(At,Wt);Jt.push({frag:Wt,at:it.lo})}}}function pe(T,q){let Q=ve.get(T);return Q&&Q.unchanged?!Q.remote||Q.remote===q?!0:ce(Q.remote,q):T.tagName!==q.tagName||!$(T,q)?!1:fe(ne(T),ne(q))}function ce(T,q){return T===q?!0:T.tagName!==q.tagName||T.namespaceURI!==q.namespaceURI||!$(T,q)?!1:xe(ne(T),ne(q))}function xe(T,q){let Q=Ee(T,s),we=Ee(q,s);if(Q.length!==we.length)return!1;for(let ue=0;ue<Q.length;ue++){let ie=Q[ue],ae=we[ue];if(typeof ie=="string"||typeof ae=="string"){if(ie!==ae)return!1}else{if(ie.nodeType!==ae.nodeType)return!1;if(ie.nodeType===1){if(!ce(ie,ae))return!1}else if(ie.nodeValue!==ae.nodeValue)return!1}}return!0}function ne(T){return T.tagName==="TEMPLATE"&&T.content?T.content:T}function $(T,q){let Q=0;for(let we of T.attributes)if(!n.ignoreAttribute(T,we.name)&&(Q++,q.getAttribute(we.name)!==we.value))return!1;for(let we of q.attributes)n.ignoreAttribute(q,we.name)||Q--;return Q===0}function fe(T,q){let Q=Ee(T,ue=>{let ie=ve.get(ue);return!!(ie&&ie.pinned)}),we=Ee(q,s);if(Q.length!==we.length)return!1;for(let ue=0;ue<Q.length;ue++){let ie=Q[ue],ae=we[ue];if(typeof ie=="string"||typeof ae=="string"){if(ie!==ae)return!1}else{if(ie.nodeType!==ae.nodeType)return!1;if(ie.nodeType===1){if(!pe(ie,ae))return!1}else if(ie.nodeValue!==ae.nodeValue)return!1}}return!0}function Ee(T,q){let Q=[],we=null;for(let ue=T.firstChild;ue;ue=ue.nextSibling){if(ue.nodeType===3){we=we===null?ue.nodeValue:we+ue.nodeValue;continue}ue.nodeType===1&&q(ue)||(we!==null&&(we!==""&&Q.push(we),we=null),Q.push(ue))}return we!==null&&we!==""&&Q.push(we),Q}function Re(T,q,Q,we){let ue=T.value,ie=we?ue:q?q.value:"",ae=Q?Q.value:"";ee.add(T),q&&ee.add(q),Q&&ee.add(Q);let De=ie===ae?ie:ie===ue?ae:ae===ue||Qe==="local"?ie:ae,qe={site:"comment",bRun:T,lRun:q,rRun:Q,node:null};if(ie!==ue&&ae!==ue&&ie!==ae&&dt({kind:"text",node:null,base:ue,local:ie,remote:ae,resolved:De},qe),!q&&!Q)return null;let Ue=te.createComment(De);return qe.node=Ue,ve.set(Ue,{base:T.nodes,local:q?q.nodes:null,remote:Q?Q.nodes:null}),Ue}function Ve(T,q){let Q=me(q,T);if(!Q)return null;let we=ut(Q)?Q.parentNode:Q.parent,ue=ut(T)?T.parentNode:T.parent;return me(q,ue)===we?null:q.reverse.get(we)||null}function Oe(T){let q=new Set([T]),Q=T;for(let we=0;we<64;we++){let ue=Ve(Q,U)||Ve(Q,K);if(!ue)return!1;if(ue===T||ut(T)&&ut(ue)&&T.contains(ue)||q.has(ue))return!0;q.add(ue),Q=ue}return!0}function $e(T,q,Q){if(!q)return!1;let we=ut(T)?T.parentNode:T.parent;return we===q||q.tagName==="TEMPLATE"&&we===q.content}function tt(T,q){let Q=Be(T),we=me(U,Q);if(we&&$e(q,we,U))return!0;let ue=me(K,Q);return!!(ue&&$e(q,ue,K))}}function xr(e,o){return e.map.get(o)?Tr():{map:{get:n=>n&&n.nodeType===1&&e.map.get(n)||n,has:()=>!0},reverse:{get:n=>e.reverse.get(n)||n,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Tr(){let e={get:o=>o,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var vr=new Set(["INPUT","OPTION","TEXTAREA"]),xs=/[\t\n\f\r ]+/;function Sr(e,o,t,n){let s=e.ownerDocument,{provenance:d,textMappers:l}=t,r=n.hooks,i=[],u=[],w=[],c=new Set,h=[],p=[],y=new Map,C=new Set,g=new Map,f=t.conflicts.length>0,m=new Map,R=new Set,S=new Map,O=(F,le)=>{let ge=S.get(F);ge||S.set(F,ge=new Set),ge.add(le)},E=f?new Set:null,P=(F,le,ge)=>{let me=r.beforeAttributeUpdated(F,le,ge);return f&&me===!1&&O(le,F),me},v=F=>!!F&&(F===e||e.contains(F)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(F)),N=new Map,L=new Map,D=new Map,B=new Set,M=new Map;(function F(le){let ge=d.get(le);if(ge){if(le.nodeType===1){let Te=ge.local?n.toLive(ge.local):null;Te&&v(Te)&&Te.nodeType===1&&(N.set(le,Te),L.set(Te,le))}else if(Array.isArray(ge.local)){let Te=K(ge.local,ge.local.map(A=>n.toLive(A)).filter(A=>A&&v(A)&&A.nodeType===le.nodeType));if(Te.length&&(N.set(le,Te[0]),L.set(Te[0],le),D.set(le,Te)),Array.isArray(ge.caret))for(let A of ge.caret){let j=n.toLive(A.node);if(!j||!v(j)||j.nodeType!==3)continue;let Y=M.get(j);Array.isArray(Y)||M.set(j,Y=[]),Y.push({merged:le,from:A.from,to:A.to,flatStart:A.flatStart})}else{let A=0;for(let j of Te)M.set(j,{merged:le,shift:A}),A+=j.nodeValue.length}}}let me=le.nodeType===1&&le.tagName==="TEMPLATE"&&le.content?le.content.childNodes:le.childNodes;for(let Te of me)F(Te)})(o);let x=new Set;for(let F of N.values())x.add(F);for(let F of D.values())for(let le of F)x.add(le);let k=n.localRoot&&n.localRoot!==e?new Set:null;if(k){for(let F=n.localRoot.firstElementChild;F;F=F.nextElementSibling)if(F.tagName==="HEAD")for(let le=F.firstElementChild;le;le=le.nextElementSibling){let ge=n.toLive(le);ge&&k.add(ge)}}for(let F of t.segments||[])Ae(F);let z=n.restoreFocus===!1?null:Qi(s,M);n.childrenOnly?ve(Me(e),Me(o)):Be(e,o);for(let{node:F,parent:le}of h)c.has(F)||!F.parentNode||F.nodeType===1&&(n.ignored(F)||ze(F))||ot(F,le);return Zi(s,z,M,l,D,g,B),{applied:i,moved:u,replaced:w,identities:p,mergedScriptsLive:C,liveOf:N,heldBy:g,runOf:D,keptRuns:B,insertedLive:m,vetoed:R,vetoedAttrs:S,removedVetoes:E};function U(F,le){let ge=F.slice(le.bs,le.be),me=0;for(;me<ge.length&&me<le.text.length&&ge[me]===le.text[me];)me++;let Te=0;for(;Te<ge.length-me&&Te<le.text.length-me&&ge[ge.length-1-Te]===le.text[le.text.length-1-Te];)Te++;return{bs:le.bs+me,be:le.be-Te,text:le.text.slice(me,le.text.length-Te)}}function K(F,le){if(!le.length)return le;let ge=[];for(let A of F){let j=A.parentNode;if(!j)continue;let Y=y.get(j);if(!Y){Y=new Set;for(let J=j.firstChild;J;J=J.nextSibling)J.nodeType===3&&Y.add(n.toLive(J));y.set(j,Y)}ge.includes(Y)||ge.push(Y)}let me={has:A=>ge.some(j=>j.has(A))},Te=[];for(let A of le){Te.push(A);for(let j=A.nextSibling;j&&j.nodeType===3&&!me.has(j)&&!Te.includes(j);j=j.nextSibling)Te.push(j)}return Te}function Ae(F){let le=[];for(let be of F.localNodes){let H=n.toLive(be.node);if(!H||!v(H)||H.nodeType!==3)return;le.push(H)}let ge=K(F.localNodes.map(be=>be.node),le);if(!ge.length)return;let me=ge.map(be=>be.nodeValue).join(""),{flatLocal:Te,lToM:A,mapLocal:j}=F;if(me===Te)return;let Y=F.textNodes.map(be=>({node:be.node,ms:be.ms,me:be.me})),J=[],se=0;for(let be of ge)J.push(se),se+=be.nodeValue.length;let je=(be,H)=>ge.find((G,de)=>J[de]<=be&&be+H<=J[de]+G.nodeValue.length)||null,Z=[],Ie=0;for(let be of Fn(Te,me).map(H=>U(Te,H))){let H=be.bs+Ie;Ie+=be.text.length-(be.be-be.bs);let G,de;if(be.be>be.bs){G=A[be.bs];let pe=G>=0;for(let ce=be.bs;pe&&ce<be.be;ce++)A[ce]!==G+(ce-be.bs)&&(pe=!1);if(!pe)continue;de=G+(be.be-be.bs)}else{let pe=be.bs>0?A[be.bs-1]:0,ce=be.bs<Te.length?A[be.bs]:0;if(pe<0||ce<0)continue;G=de=j(be.bs)}Z.push({ms:G,me:de,text:be.text,live:de===G?je(H,be.text.length):null})}Z.sort((be,H)=>H.ms-be.ms);let He=(be,H)=>(D.get(be.node)||[N.get(be.node)]).includes(H),Ce=be=>!!be&&be.nodeType===1&&wn.has(be.tagName);for(let be of Z){let H=Y.find(de=>de.ms<=be.ms&&be.me<=de.me&&be.ms<de.me);if(H&&be.live&&H.ms===be.ms&&!He(H,be.live)){let de=Y.find(pe=>pe.me===be.ms&&He(pe,be.live));de&&(H=de)}if(!H&&be.me===be.ms){let de=Y.find(ne=>ne.me===be.ms),pe=Y.find(ne=>ne.ms===be.ms),ce=de||pe;if(!ce)continue;let xe=ce.node;for(;Ce(xe.parentNode)&&(de?xe.parentNode.lastChild:xe.parentNode.firstChild)===xe;)xe=xe.parentNode;if(xe===ce.node)H=ce;else{let ne=xe.ownerDocument.createTextNode(be.text);xe.parentNode.insertBefore(ne,de?xe.nextSibling:xe);continue}}if(!H)continue;let G=H.node.nodeValue;H.node.nodeValue=G.slice(0,be.ms-H.ms)+be.text+G.slice(be.me-H.ms),H.me+=be.text.length-(be.me-be.ms)}}function Me(F){return F.nodeType===1&&F.tagName==="TEMPLATE"&&F.content?F.content:F}function Be(F,le){c.add(F);let ge=d.get(le);if(ge&&ge.remote&&t.remoteIdOf){let Te=t.remoteIdOf(ge.remote);Te&&p.push([F,Te])}if(ge&&ge.unchanged){t.customIdentity&&ge.remote&&oe(F,ge.remote),ge.remote&&_(F,ge.remote);return}if(r.beforeNodeMorphed(F,le)===!1){R.add(le);return}gt(F,le,n.keepLiveOnly&&ge&&ge.local&&ge.local.nodeType===1&&ge.local!==F?ge.local:null);let me=F.tagName;if(dn(F))F.textContent!==le.textContent&&(i.push({kind:"text",node:F,before:F.textContent,after:le.textContent}),F.textContent=le.textContent),t.mergedScripts.has(le)&&C.add(F);else if(me==="TEXTAREA")$t(F,le,ge);else{an(F,le,ge);let Te=me==="TEMPLATE"&&F.content?F.content:F,A=me==="TEMPLATE"&&le.content?le.content:le;n.protectFocusedValue==="subtree"&&_t(F)&&F!==s.body?te(Te):ve(Te,A)}r.afterNodeMorphed(F,le)}function te(F){for(let le=F.firstChild;le;le=le.nextSibling){let ge=L.get(le);ge&&N.get(ge.parentNode)!==F||(c.add(le),le.nodeType===1&&te(le))}}function ve(F,le){let ge=Ke(F.firstChild),me=new Set;for(let Te of Array.from(le.childNodes)){let A=N.get(Te);A&&c.has(A)&&!me.has(A)&&(A=null);let j=d.get(Te);if(j&&j.pinned){A&&A.nodeType===1&&((A.parentNode!==F||Ke(A.nextSibling)!==ge)&&Ne(F,A,ge),c.add(A),me.add(A));continue}if(A&&A.nodeType===1){if(A!==ge){let se=A.parentNode;if(se===F&&ge&&Ht(A)){let je=A.nextSibling;for(let Z=ge;Z&&Z!==A;){let Ie=Z.nextSibling;Ne(F,Z,je),Z=Ie}}else Ne(F,A,ge),se!==F&&(u.push(A),i.push({kind:"move",el:A,from:se,to:F}))}me.add(A),Be(A,Te),ge=Ke(A.nextSibling);continue}if(A&&A.nodeType!==1){let se=D.get(Te)||[A],je=se.map(Ie=>Ie.nodeValue).join(""),Z=Te.nodeValue;if(Te.nodeType===3){let Ie=re(Te);Ie!=null&&je!==Ie&&(Z=no(Ie,je,Te.nodeValue).text)}if(se.length>1&&je===Z&&!se.includes(ge,1)&&se.every((Ie,He)=>Ie.parentNode===F&&(He===0||se[He-1].nextSibling===Ie))){if(A!==ge)for(let Ie of se)Ne(F,Ie,ge);r.beforeNodeMorphed(A,Te)!==!1?r.afterNodeMorphed(A,Te):f&&R.add(Te);for(let Ie of se)c.add(Ie),me.add(Ie);g.set(Te,A),B.add(Te),ge=Ke(se[se.length-1].nextSibling);continue}A!==ge&&Ne(F,A,ge),r.beforeNodeMorphed(A,Te)!==!1?(A.nodeValue!==Z&&(i.push({kind:"text",node:A,before:A.nodeValue,after:Z}),A.nodeValue=Z),r.afterNodeMorphed(A,Te)):R.add(Te),c.add(A),me.add(A),g.set(Te,A),ge=Ke(A.nextSibling);continue}if(Te.nodeType===3&&ge&&ge.nodeType===3&&!c.has(ge)&&!M.has(ge)){ge.nodeValue!==Te.nodeValue&&(i.push({kind:"text",node:ge,before:ge.nodeValue,after:Te.nodeValue}),ge.nodeValue=Te.nodeValue),c.add(ge),g.set(Te,ge),ge=Ke(ge.nextSibling);continue}let Y=d.get(Te),J=Qe(Y&&Y.unchanged&&Y.remote?Y.remote:Te);if(r.beforeNodeAdded(J)===!1){R.add(Te);continue}F.insertBefore(J,ge),c.add(J),f&&m.set(Te,J),J.nodeType===3&&g.set(Te,J),J.nodeType===1&&(w.push(J),Pe(J,Te),t.customIdentity&&Y&&Y.unchanged&&Y.remote&&oe(J,Y.remote),dn(J)||Ze(J,Te),n.formState==="property"&&Bt(Y)&&_(J,Y.remote)),ge=Ke(J.nextSibling),i.push({kind:"insert",node:J,parent:F}),r.afterNodeAdded(J)}for(let Te of Array.from(F.childNodes))c.has(Te)||me.has(Te)||Te.nodeType===1&&(n.ignored(Te)||ze(Te))||(x.has(Te)?h.push({node:Te,parent:F}):ot(Te,F))}function ze(F){return F.parentNode&&F.parentNode.nodeType===1&&F.parentNode.tagName==="HEAD"&&(k&&!k.has(F)||n.preserve&&n.preserve(F)===!0)}function re(F){let le=d.get(F);return!le||!Array.isArray(le.local)?null:le.local.map(ge=>ge.nodeValue).join("")}function b(F){return d.get(F)}function _(F,le){if(!vr.has(F.tagName)&&!F.querySelector("input,option,textarea"))return;let ge=(me,Te)=>{if(me.tagName!==Te.tagName)return;me.tagName==="TEXTAREA"?$t(me,Te,{remote:Te}):vr.has(me.tagName)&&an(me,Te,{remote:Te});let A=ee(me),j=ee(Te);if(A.length===j.length)for(let Y=0;Y<A.length;Y++)ge(A[Y],j[Y])};ge(F,le)}function oe(F,le){let ge=ee(F),me=ee(le);if(ge.length===me.length)for(let Te=0;Te<ge.length;Te++){let A=t.remoteIdOf(me[Te]);A&&p.push([ge[Te],A]),oe(ge[Te],me[Te])}}function ee(F){let le=F.tagName==="TEMPLATE"&&F.content?F.content:F;return Array.from(le.children).filter(ge=>!n.ignored(ge))}function Pe(F,le){if(!t.remoteIdOf)return;let ge=(me,Te)=>{let A=d.get(Te);if(A&&A.remote&&Te.nodeType===1){let J=t.remoteIdOf(A.remote);J&&p.push([me,J])}let j=me.childNodes,Y=Te.childNodes;for(let J=0;J<j.length&&J<Y.length;J++)ge(j[J],Y[J])};ge(F,le)}function Ke(F){for(;F&&F.nodeType===1&&n.ignored(F);)F=F.nextSibling;return F}function Ne(F,le,ge){if(typeof F.moveBefore=="function"&&le.ownerDocument===F.ownerDocument)try{F.moveBefore(le,ge);return}catch{}F.insertBefore(le,ge)}function ot(F,le){if(r.beforeNodeRemoved(F)===!1){f&&E.add(F);return}F.parentNode.removeChild(F),i.push({kind:"remove",node:F,parent:le}),r.afterNodeRemoved(F)}function Qe(F){if(dn(F))return ko(F,s);let le=s.importNode(F,!0);if(le.nodeType===1)for(let ge of Array.from(le.querySelectorAll("script")))dn(ge)&&ge.replaceWith(ko(ge,s));return le}function Ze(F,le){let ge=F.tagName==="TEMPLATE"&&F.content?F.content:F,me=le.tagName==="TEMPLATE"&&le.content?le.content:le,Te=Array.from(ge.childNodes),A=Array.from(me.childNodes);for(let j=0;j<A.length&&j<Te.length;j++){let Y=A[j],J=Te[j],se=N.get(Y);se&&c.has(se)&&(se=null);let je=d.get(Y);if(je&&je.pinned){if(se&&se.nodeType===1){let Z=se.parentNode;Ne(ge,se,J),Z!==ge&&(u.push(se),i.push({kind:"move",el:se,from:Z,to:ge})),c.add(se)}J.remove();continue}if(se){let Z=se.parentNode;Ne(ge,se,J),J.remove(),se.nodeType===1?(Z!==ge&&(u.push(se),i.push({kind:"move",el:se,from:Z,to:ge})),Be(se,Y)):(c.add(se),g.set(Y,se),se.nodeValue!==Y.nodeValue&&(i.push({kind:"text",node:se,before:se.nodeValue,after:Y.nodeValue}),se.nodeValue=Y.nodeValue));continue}c.add(J),f&&m.set(Y,J),J.nodeType===3&&g.set(Y,J),je&&je.unchanged&&je.remote?(Xe(J,je.remote),t.customIdentity&&oe(J,je.remote)):Y.nodeType===1&&!dn(Y)&&Ze(J,Y)}}function Xe(F,le){let ge=F.tagName==="TEMPLATE"&&F.content?F.content:F,me=le.tagName==="TEMPLATE"&&le.content?le.content:le;for(let Te of Array.from(me.childNodes))ge.appendChild(Qe(Te))}function wt(F,le){return le.namespaceURI?F.getAttributeNS(le.namespaceURI,le.localName):F.getAttribute(le.name)}function dt(F,le){let ge=new Set((le||"").split(xs).filter(Boolean));return(F||"").split(xs).filter(me=>me&&!ge.has(me))}function gt(F,le,ge){for(let me of Array.from(le.attributes)){if(zt(F,me.name)||n.ignoreAttribute(F,me.name))continue;let Te=wt(F,me);if(Te===me.value||ge&&wt(ge,me)===me.value)continue;let A=me.value;if(ge&&me.name==="class"&&!me.namespaceURI){let j=me.value.split(xs).filter(Boolean),Y=dt(Te,ge.getAttribute("class")).filter(J=>!j.includes(J));Y.length&&(A=[...j,...Y].join(" "))}if(Te!==A){if(r.beforeAttributeUpdated(me.name,F,"update")===!1){f&&O(le,me.name);continue}me.namespaceURI?F.setAttributeNS(me.namespaceURI,me.name,A):F.setAttribute(me.name,A),i.push({kind:"attr",el:F,name:me.name,before:Te,after:A})}}for(let me of Array.from(F.attributes)){if(zt(F,me.name)||n.ignoreAttribute(F,me.name)||(me.namespaceURI?le.hasAttributeNS(me.namespaceURI,me.localName):le.hasAttribute(me.name)))continue;if(ge&&me.name==="class"&&!me.namespaceURI){let j=dt(me.value,ge.getAttribute("class"));if(j.length){let Y=j.join(" ");if(Y===me.value)continue;if(r.beforeAttributeUpdated("class",F,"update")===!1){f&&O(le,"class");continue}F.setAttribute("class",Y),i.push({kind:"attr",el:F,name:"class",before:me.value,after:Y});continue}}if(ge&&wt(ge,me)===null)continue;if(r.beforeAttributeUpdated(me.name,F,"remove")===!1){f&&O(le,me.name);continue}let A=me.value;me.namespaceURI?F.removeAttributeNS(me.namespaceURI,me.localName):F.removeAttribute(me.name),i.push({kind:"attr",el:F,name:me.name,before:A,after:null})}}function zt(F,le){let ge=F.tagName;return ge==="INPUT"?le==="value"||le==="checked"||le==="disabled":ge==="OPTION"?le==="selected":!1}function _t(F){return F===s.activeElement}function Ht(F){let le=s.activeElement;return!!le&&le!==s.body&&F.contains(le)}function Bt(F){let le=F&&F.remote;return le&&le.nodeType===1?le:null}function an(F,le,ge){let me=F.tagName,Te=Bt(ge),A=n.formState==="property"&&Te?Te:le;if(me==="INPUT"){let j=n.protectFocusedValue&&_t(F),Y=(F.getAttribute("type")||"").toLowerCase(),J=Y!=="file"&&Y!=="checkbox"&&Y!=="radio",se=Te&&Te.hasAttribute("value")&&Te.value!==Te.getAttribute("value")?Te.value:null;if(J&&!j)if(n.formState==="property"){let je=le.getAttribute("value"),Z=F.getAttribute("value");(Z!==je||F.value!==A.value)&&P("value",F,je==null?"remove":"update")!==!1&&(Z!==je&&(je==null?F.removeAttribute("value"):F.setAttribute("value",je),i.push({kind:"attr",el:F,name:"value",before:Z,after:je})),F.value!==A.value&&(F.value=A.value))}else if(le.hasAttribute("value")||se!=null){let je=se??le.getAttribute("value");F.getAttribute("value")!==je&&P("value",F,"update")!==!1?(F.setAttribute("value",je),F.value!==je&&(F.value=je),i.push({kind:"attr",el:F,name:"value",before:null,after:je})):F.value!==je&&F.getAttribute("value")===je&&(F.value=je)}else(F.hasAttribute("value")||F.value!=="")&&P("value",F,"remove")!==!1&&(F.removeAttribute("value"),F.value="",i.push({kind:"attr",el:F,name:"value",before:"",after:null}));if(!J&&Y!=="file"){let je=le.getAttribute("value");je==null?F.hasAttribute("value")&&P("value",F,"remove")!==!1&&F.removeAttribute("value"):F.getAttribute("value")!==je&&P("value",F,"update")!==!1&&F.setAttribute("value",je)}j||(Kt(F,A,"checked"),n.formState==="property"&&F.indeterminate!==A.indeterminate&&(F.indeterminate=A.indeterminate)),Kt(F,A,"disabled")}else if(me==="OPTION"){let j=F.parentNode&&F.closest("select");n.protectFocusedValue&&j&&_t(j)||Kt(F,A,"selected")}}function Kt(F,le,ge){let me=n.formState==="property"?!!le[ge]:le.hasAttribute(ge);if(n.formState!=="property"){let Te=F.hasAttribute(ge);if(Te!==me){if(P(ge,F,me?"update":"remove")===!1)return;me?F.setAttribute(ge,""):F.removeAttribute(ge),i.push({kind:"attr",el:F,name:ge,before:Te?"":null,after:me?"":null})}}F[ge]!==me&&(F[ge]=me)}function $t(F,le,ge){if(n.protectFocusedValue&&_t(F)||P("value",F,"update")===!1)return;let me=Bt(ge),Te=le.textContent,A=me&&me.value!==me.defaultValue?me.value:Te;n.formState!=="property"&&F.textContent!==Te&&(i.push({kind:"text",node:F,before:F.textContent,after:Te}),F.textContent=Te),F.value!==A&&(F.value=A)}}function Qi(e,o){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let n={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{n.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return n}let s=e.getSelection&&e.getSelection();if(s&&s.rangeCount){let d=s.getRangeAt(0);n.range={sc:d.startContainer,so:d.startOffset,ec:d.endContainer,eo:d.endOffset}}return n}function Zi(e,o,t,n,s,d,l){if(!o)return;let r=o.el;if(!r.isConnected&&o.id&&(r=e.getElementById(o.id)),!r||!r.isConnected)return;if(e.activeElement!==r)try{r.focus({preventScroll:!0})}catch{}try{r.scrollTop=o.scrollTop,r.scrollLeft=o.scrollLeft}catch{}if(o.selection){try{r.setSelectionRange&&!r.selectionEnd&&o.selection[1]!=null&&r.setSelectionRange(o.selection[0],o.selection[1],o.selection[2]||"none")}catch{}return}if(!o.range)return;let i=(c,h)=>{let p=t.get(c);if(Array.isArray(p)){let y=p.find(m=>h>=m.from&&h<m.to)||p.find(m=>h===m.to)||p[p.length-1],C=d.get(y.merged);if(!C||!C.isConnected)return null;let g=n.get(y.merged),f=g&&g.flat?g.flat(y.flatStart+h):h;return[C,Math.max(0,Math.min(f,C.nodeValue.length))]}if(p&&!l.has(p.merged)){let y=(s.get(p.merged)||[c])[0];if(!y.isConnected)return null;let C=n.get(p.merged),g=p.shift+h,f=C?C(g):g;return[y,Math.max(0,Math.min(f,y.nodeValue.length))]}return c.isConnected?[c,Math.min(h,c.nodeType===3?c.nodeValue.length:c.childNodes.length)]:null},u=i(o.range.sc,o.range.so),w=i(o.range.ec,o.range.eo);if(!(!u||!w))try{let c=e.createRange();c.setStart(u[0],u[1]),c.setEnd(w[0],w[1]);let h=e.getSelection();h.removeAllRanges(),h.addRange(c)}catch{}}var el={compared:0},tl=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function nl(e,o,t){let n=0;for(let s of e.attributes)if(!t(e,s.name)&&(n++,o.getAttribute(s.name)!==s.value))return!1;for(let s of o.attributes)t(o,s.name)||n--;return n===0}function Ts(e,o){if(e.namespaceURI!==o.namespaceURI||e.prefix!==o.prefix||e.localName!==o.localName)return!1;let t=e.attributes;if(t.length!==o.attributes.length)return!1;for(let n of t)if(o.getAttributeNS(n.namespaceURI,n.localName)!==n.value)return!1;return!0}function Nr(e,o,t,n,s,d,l,r){let i=new Map,u=new Set,w=c=>{if(n(c))return;let h=t(c);h&&(d.add(h),s.has(h)||i.has(h)?u.add(h):i.set(h,c))};for(let c of e)w(c);w(o);for(let c of l||o.querySelectorAll("*"))w(c);for(let c of u)i.delete(c),r.add(c);return i}function Ar(e,o,t,n,s,d){let l=!1;for(let w of s)w.startsWith("merge:")&&(l=!0);if(!l)return[...n];let r=new Map,i=[],u=d===gn?vo:"*";for(let w of[e,...e.querySelectorAll(u)]){if(t(w))continue;let c=o(w);if(!c||!(n.has(c)||s.has(c)))continue;let h=(r.get(c)||0)+1;r.set(c,h),h===2&&i.push(c)}return i}function Mr({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:s,identity:d,baseURI:l}){if(e.tagName!==o.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||o.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!nl(e,o,s.ignoreAttribute))return{bail:"root-attrs"};let{ignored:r,remoteWins:i}=s,u=ks(s.scripts.merge===!1?null:s.scripts.mergeTags,l),w=re=>{let b=u(re);return b!==null?b:d.base(re)||null},c=re=>{let b=u(re);return b!==null?b:d.remote(re)||null},h=[],p=[],y=new Map,C=new Map,g={same:y,differ:C},f=re=>({bail:re,comparisons:g}),m=(re,b,_=!0)=>{if(y.get(re)===b)return!0;if(C.get(re)===b)return!1;if(el.compared++,_&&re.isEqualNode(b))return y.set(re,b),!0;let oe=re.nodeType===b.nodeType;if(oe&&re.nodeType===1){if(oe=Ts(re,b),oe){let ee=re.firstChild,Pe=b.firstChild;for(;ee&&Pe;ee=ee.nextSibling,Pe=Pe.nextSibling)if(!m(ee,Pe,!1)){oe=!1;break}(ee||Pe)&&(oe=!1)}}else oe&&(oe=re.isEqualNode(b));return(oe?y:C).set(re,b),oe},R=e,S=o,O=!1,E=()=>{y.set(R,S);for(let re=0;re<h.length;re++)y.set(h[re],p[re]);return f("equal")};for(;;){let re=R.childNodes,b=S.childNodes;if(re.length!==b.length)break;let _=Qe=>m(re[Qe],b[Qe])?(y.set(re[Qe],b[Qe]),!1):!0,oe=-1,ee=-1;for(let Qe=0;Qe<re.length;Qe++){if(re[Qe].nodeType!==1)continue;let Ze=0;for(let Xe=re[Qe].firstElementChild;Xe;Xe=Xe.nextElementSibling)Ze++;Ze>=ee&&(ee=Ze,oe=Qe)}let Pe=[],Ke=!1;for(let Qe=0;Qe<re.length&&Pe.length<2;Qe++)Qe!==oe&&_(Qe)&&Pe.push(Qe);if(oe>=0&&Pe.length<2&&(Pe.length===0&&Ts(R,S)?(Pe.push(oe),Ke=!0):_(oe)&&Pe.push(oe)),Pe.length!==1){if(!O&&Pe.length===0&&Ts(R,S))return E();break}let Ne=re[Pe[0]],ot=b[Pe[0]];if(O=O||!Ke,O&&C.set(Ne,ot),Ne.nodeType!==1||ot.nodeType!==1||Ne.tagName!==ot.tagName)break;if(w(Ne)!==c(ot)){if(!O&&m(Ne,ot))return E();break}h.push(R),p.push(S),R=Ne,S=ot}C.set(R,S);for(let re=0;re<h.length;re++)C.set(h[re],p[re]);if(R===e||R.tagName==="HEAD"||R.tagName==="BODY")return f("root-level");if(h.length<2||h[1].tagName!=="BODY")return f("not-in-body");if(r(R)||r(S))return f("ignored-ancestor");if(i(R)||i(S))return f("remote-wins-ancestor");for(let re of h)if(tl.has(re.tagName))return f("form-ancestor");if(R.tagName==="SCRIPT"||R.getElementsByTagName("script").length||S.getElementsByTagName("script").length)return f("script-or-template");let P=n(R);if(!P||P.nodeType!==1||P.tagName!==R.tagName)return f("no-live-twin");if(!t.contains(P))return f("live-detached");for(let re of h){let b=n(re);if(!b||b.nodeType!==1)return f("ancestor-live")}let v=d.base===gn&&d.remote===gn&&r===Yo,N=new Set,L=new Set,D=[],B=null,M=re=>{re&&(N.has(re)?L.add(re):N.add(re))},x=(re,b)=>{let _=u(re),oe=_!==null?_:d.base(re)||null;return oe!==(_!==null?_:d.remote(b)||null)?!1:(M(oe),!0)},k=(re,b)=>{for(let _=re.firstElementChild,oe=b.firstElementChild;_;_=_.nextElementSibling,oe=oe.nextElementSibling){let ee=r(_);if(ee!==r(oe))return!1;if(!ee&&(!x(_,oe)||!k(_,oe)))return!1}return!0},z=re=>{let b=re+1<h.length?h[re+1]:R;for(let _=h[re].firstElementChild,oe=p[re].firstElementChild;_;_=_.nextElementSibling,oe=oe.nextElementSibling){if(_===b){let Ke=re+1<h.length?z(re+1):null;if(Ke)return Ke;continue}let ee=r(_);if(ee!==r(oe))return"outside-id-changed";if(ee)continue;let Pe=n(_);if(!Pe||Pe.nodeType!==1)return"sibling-live";if(D.push([_,oe]),!v&&(!x(_,oe)||!k(_,oe)))return"outside-id-changed";re===0&&_.tagName==="HEAD"&&w(_)&&(B=[_,oe])}return null},U=z(0);if(U)return f(U);let K=new Set(h),Ae=null;if(d.base===gn){Ae=[];for(let re of e.querySelectorAll(vo))re===R||K.has(re)||(R.contains(re)?Ae.push(re):v&&M(w(re)))}let Me=new Set,Be=new Set,te=new Set,ve=Nr(h,R,w,r,N,Me,Ae,Be),ze=Nr(p,S,c,r,N,Me,d.remote===gn&&S.querySelectorAll(vo),te);return B&&(L.has(w(B[0]))||Me.has(w(B[0])))&&(B=null),{scope:{chain:h,root:R,onChain:K,baseIndex:ve,remoteIndex:ze,baseDropped:Be,remoteDropped:te,head:B,same:y,differ:C,dropped:[...Ar(e,w,r,L,Be,d.base),...Ar(o,c,r,L,te,d.remote)],held:re=>{for(let b=1;b<h.length;b++)if(re.map.get(h[b])!==p[b])return!1;for(let[b,_]of D)if(re.map.get(b)!==_)return!1;return!0}}}}var Or=Symbol("hyper-morph-duplicate-key"),Ir=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function So(e,o){return o.map(t=>{let n=new Map;for(let s of e){if(s.nodeType!==1)continue;let d=t(s);d==null||d===""||n.set(d,n.has(d)?Or:s)}return n})}function Cr(e,o,t,n){for(let s=0;s<n.length;s++){let d=n[s](e);if(d==null||d===""||o[s].get(d)!==e)continue;let l=t[s].get(d);if(!(!l||l===Or)&&l.tagName===e.tagName)return l}return null}function uo(e,o,t){for(let n=0;n<t.length;n++){let s=t[n](e);if(!(s==null||s==="")&&o[n].get(s)===e)return!0}return!1}function Er(e,o,t={}){let n=t.skip||(()=>!1),s=t.ignoreAttr||(()=>!1),d=t.tiers&&t.tiers.length?t.tiers:Ir,l=null;function r(){return l||(l=So([e,...e.querySelectorAll("*")],d)),l}let i=null;function u(){return i||(i=So([o,...o.querySelectorAll("*")],d)),i}function w(N){return!N.parentElement||!N.parentElement.parentElement}function c(N,L,D){return w(N)||uo(N,r(),d)?(D.push({type:"subtree",el:N,base:L}),!1):!0}function h(N,L){let D=[];for(let B of N.attributes)s(N,B.name)||L.getAttribute(B.name)!==B.value&&D.push(B.name);for(let B of L.attributes)s(N,B.name)||N.hasAttribute(B.name)||D.push(B.name);return D}function p(N){let L=[],D=null,B=()=>{D!==null&&(L.push({nodeType:3,nodeValue:D}),D=null)};for(let M of N.childNodes){if(M.nodeType===3){D=(D===null?"":D)+M.nodeValue;continue}M.nodeType===1&&n(M)||(B(),(M.nodeType===1||M.nodeType===8)&&L.push(M))}return B(),L}function y(N,L){if(N.nodeType!==L.nodeType)return!1;if(N.nodeType!==1)return!0;if(N.tagName!==L.tagName)return!1;for(let D of d){let B=D(N),M=D(L);if(B!=null&&B!==""&&M!=null&&M!==""&&B!==M)return!1}return!0}function C(N){let L="";for(let D of N)D.nodeType===3&&D.nodeValue.trim()!==""?L+="\0"+D.nodeValue:D.nodeType===8&&(L+=""+D.nodeValue);return L}function g(N,L,D){let B=p(N),M=p(L);if(B.length===M.length){let re=!0;for(let b=0;b<B.length;b++)if(!y(B[b],M[b])){re=!1;break}if(re){for(let b=0;b<B.length;b++){let _=B[b];if(_.nodeType===1){if(f(_,M[b],D))return!0}else if(_.nodeValue!==M[b].nodeValue)return!0}return!1}}let x=B.filter(re=>re.nodeType===1),k=M.filter(re=>re.nodeType===1);if(C(B)!==C(M))return!0;let z=So(x,d),U=So(k,d),K=[],Ae=new Set,Me=[];for(let re of x){let b=Cr(re,z,U,d);b&&!Ae.has(b)?(K.push([re,b]),Ae.add(b)):Me.push(re)}let Be=[];for(let re of Me)uo(re,z,d)?D.push({type:"subtree",el:re,base:null}):Be.push(re);let te=[];for(let re of k)Ae.has(re)||(uo(re,U,d)?D.push({type:"deletion",el:re}):te.push(re));if(Be.length!==te.length)return!0;for(let re=0;re<Be.length;re++)if(!y(Be[re],te[re]))return!0;let ve=new Map(K);for(let re=0;re<Be.length;re++)ve.set(Be[re],te[re]);let ze=-1;for(let re of x){let b=ve.get(re);if(!b)continue;let _=k.indexOf(b);if(_<ze)return!0;ze=_}for(let re=0;re<Be.length;re++)if(f(Be[re],te[re],D))return!0;for(let[re,b]of K)if(f(re,b,D))return!0;return!1}function f(N,L,D){if(N.tagName!==L.tagName)return c(N,L,D);let B=h(N,L),M=[];if(g(N,L,M))return c(N,L,D);if(B.length){if(!w(N)&&!uo(L,u(),d))return!0;D.push({type:"attrs",el:N,names:B,base:L})}return D.push(...M),!1}let m=[],R=h(e,o);R.length&&m.push({type:"attrs",el:e,names:R});let S=(N,L)=>Array.from(N.children).find(D=>D.tagName===L)||null,O=S(e,"HEAD"),E=S(o,"HEAD");if(O&&E){let N=[];f(O,E,N),N.length&&m.push({type:"head",el:O})}else(O||E)&&O&&m.push({type:"head",el:O});let P=S(e,"BODY"),v=S(o,"BODY");return P&&v?f(P,v,m):P&&m.push({type:"subtree",el:P,base:null}),{entries:m}}function Lr(e,o,t={}){let n=t.tiers&&t.tiers.length?t.tiers:Ir,s=e.documentElement,d=[],l=0,r=f=>({ok:!1,placed:d,held:f,skippedAttrs:l});if(!s)return r(null);function i(f){let m=[f,...f.querySelectorAll("*")];return So(m,n)}let u=i(s),w=new Map,c=f=>{let m=f.getRootNode(),R=w.get(m);if(!R){let S=m.nodeType===9?m.documentElement:m;R=i(S),w.set(m,R)}return R};function h(f){if(!f.parentElement&&f.tagName==="HTML")return s;if(f.parentElement&&!f.parentElement.parentElement&&f.parentElement.tagName==="HTML"){if(f.tagName==="BODY")return e.body||null;if(f.tagName==="HEAD")return e.head||null}return null}function p(f){let m=h(f);return m||Cr(f,c(f),u,n)}function y(f){if(!f)return null;let m=p(f);return m&&m.isConnected?m:null}function C(f){for(let m=0;m<n.length;m++){let R=n[m](f);R!=null&&R!==""&&u[m].set(R,f)}}for(let f of o){if(f.type!=="deletion")continue;let m=p(f.el);m&&m!==s&&m.remove()}let g=o.filter(f=>f.type!=="deletion").sort((f,m)=>f.el===m.el?0:f.el.compareDocumentPosition(m.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let f of g){if(f.type==="head"){let v=e.importNode(f.el,!0);e.head?e.head.replaceWith(v):s.insertBefore(v,s.firstChild),d.push({entry:f,imported:v});continue}if(f.type==="attrs"){let v=y(f.el)||y(f.base);if(!v){l++;continue}for(let N of f.names)f.el.hasAttribute(N)?v.setAttribute(N,f.el.getAttribute(N)):v.removeAttribute(N);continue}let m=f.el;if(h(m))return r(f);let R=y(m)||y(f.base);if(R){let v=e.importNode(m,!0);R.replaceWith(v),C(v),d.push({entry:f,imported:v});continue}if(f.base!=null&&!uo(f.base,c(f.base),n)||!uo(m,c(m),n))return r(f);let S=m.parentElement;if(!S)return r(f);let O=y(S);if(!O)return r(f);let E=null;for(let v=m.previousElementSibling;v;v=v.previousElementSibling){let N=y(v);if(N&&N.parentNode===O){E=N;break}}let P=e.importNode(m,!0);if(E)O.insertBefore(P,E.nextSibling);else{let v=Array.prototype.indexOf.call(S.children,m);O.insertBefore(P,O.children[v]||null)}C(P),d.push({entry:f,imported:P})}return{ok:!0,placed:d,held:null,skippedAttrs:l}}var ol='[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"]',sl='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',rl='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function il(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let o=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(o)}function ll(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let s=o;if(s.nodeType===9){let d=e.getAttribute("id");s=d&&s.getElementById(d)||(e.tagName==="BODY"?s.body:e.tagName==="HTML"?s.documentElement:s.body&&s.body.firstElementChild)}if((!s||s.nodeType!==1||s.tagName!==e.tagName)&&(s=al(e,o,n)),!!s)return t?Array.from(s.childNodes):s}function al(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let s=new Map,d=[n,...n.querySelectorAll("script")];for(let i of d){let u=lo(i,t);u&&!s.has(u.key)&&s.set(u.key,i.textContent)}if(!s.size)return null;let l=e.cloneNode(!0),r=!1;for(let i of[l,...l.querySelectorAll("script")]){let u=lo(i,t);u&&s.has(u.key)&&(i.textContent=s.get(u.key),r=!0)}return r?l:null}function Rr(e,o){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=o.implementation.createHTMLDocument(""),n=e.nodeType===1&&e.tagName==="HTML"?e:null;if(n)return t.replaceChild(t.adoptNode(n),t.documentElement),t;let s=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let d of s)t.body.appendChild(t.adoptNode(d));return t}function _o(e,o,t={}){let n=t||{};if(!n.head?.block)return Pr(e,o,n);try{return Pr(e,o,n)}catch(s){return Promise.reject(s)}}function Pr(e,o,t){let n=t.policy||"sync",s=n==="raw"?void 0:(i,u)=>il(i)||(n==="history"?!(u&&i.matches(rl))&&i.matches(sl):i.matches(ol)),d=t.callbacks||{},l={ignore:s,hooks:d,protectFocusedValue:t.ignoreActiveValue===!0?"subtree":!1,restoreFocus:t.restoreFocus!==!1,formState:t.formStateSync||"attribute",scripts:{execute:t.scripts?.handle!==!1,merge:t.scripts?.merge!==!1,mergeTags:t.scripts?.mergeTags||[]},head:{awaitLoads:!!t.head?.block,preserve:t.head?.shouldPreserve||(()=>!1)}};if(typeof t.key=="function"&&(l.identity={base:t.key,local:t.key,remote:t.key}),e&&e.nodeType===9)return ho(Object.assign({},l,{live:e,base:t.scripts?.mergeBase||null,remote:Rr(o,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let i=Object.assign({},l,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Rr(o,e.ownerDocument)});return ho(i)}t.morphStyle==="innerHTML"&&(l.children=!0);let r=ll(e,t.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return r!==void 0&&(l.base=r),qo(e,o,l)}var cl=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),vn=()=>{};function No(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!cl.has(l))throw new TypeError(`unknown option "${l}"`);let t=Object.assign({beforeNodeAdded:vn,afterNodeAdded:vn,beforeNodeRemoved:vn,afterNodeRemoved:vn,beforeNodeMorphed:vn,afterNodeMorphed:vn,beforeAttributeUpdated:vn},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let s=e.formState||"attribute";if(!["attribute","property"].includes(s))throw new TypeError("formState must be attribute or property");let d=e.protectFocusedValue;if(d!==void 0&&typeof d!="boolean"&&d!=="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:Xo(e.ignore,o),remoteWins:Xo(e.remoteWins,o),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:n,protectFocusedValue:d===void 0?!0:d,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:s,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0}}function po(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 gn}function mo(e,o){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=Co(o,e.map),n=typeof e.then=="function"?e.then:gn;if(typeof e.first=="function"){let s=e.first;return d=>s(d)||t.get(d)||n(d)}return s=>t.get(s)||n(s)}return gn}function Dr(e,o,t,n={}){let s=p=>p&&p.nodeType===9?p.documentElement:p,d=s(o),l=s(t),r=s(e)||d,i=Object.assign({},n);delete i.live,delete i.base,delete i.remote;let u=No(i,[r,d,l].filter(Boolean)),w=n.identity||{},c=Wn(),h=Fo(r,d,l,{identity:{base:mo(w.base,r),local:mo(w.local,d),remote:mo(w.remote,l)},authored:{base:po(w.base),local:po(w.local),remote:po(w.remote)},skipUnchanged:u.hooks.beforeNodeMorphed===vn&&u.hooks.afterNodeMorphed===vn,ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:d.ownerDocument&&d.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:u.children,stats:c});return delete h.recoveryLinks,h}function vs({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:s,options:d,identity:l,childrenOnly:r,isDocument:i}){let u=No(d,[e,o,t,n].filter(Boolean));if(u.ignored(e))return{report:Ss(),loads:[]};let w=e.ownerDocument,c=u.scripts.execute?Qs(e,u.ignored,w.baseURI):null,h=Wn(),p=u.hooks.beforeNodeMorphed===vn&&u.hooks.afterNodeMorphed===vn,y={identity:{base:mo(l.base,o||t),local:mo(l.local,t),remote:mo(l.remote,n)},authored:{base:po(l.base),local:po(l.local),remote:po(l.remote)},ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:w.baseURI,localIsBase:!o,childrenOnly:r,skipUnchanged:p},C=u.fastPath&&i&&!r&&p&&o===t,g=null,f=null;if(C){let M=Mr({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:s,o:u,identity:y.identity,baseURI:w.baseURI});y.comparisons=M.comparisons||M.scope,M.bail?f=M.bail:(g=Fo(o,t,n,Object.assign({},y,{stats:h,scope:M.scope})),g||(f="chain-unpaired",h=Wn()))}g||(g=Fo(o||t,t,n,Object.assign({},y,{stats:h}))),C&&(h.fastPathAttempted=1,h.fastPathTaken=f?0:1,h.fastPathFallback=f),g.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(M=>u.hooks[M]!==vn)&&cr(g.conflicts,g.recoveryLinks,s),u.beforeApply&&u.beforeApply(g.doc);let m=globalThis.__hyperMorphProfile,R=m?performance.now():0,S=Sr(e,g.root,g,{toLive:s,localRoot:t,ignored:u.ignored,ignoreAttribute:u.ignoreAttribute,formState:u.formState,protectFocusedValue:u.protectFocusedValue,restoreFocus:u.restoreFocus,preserve:u.head.preserve,hooks:u.hooks,childrenOnly:r,keepLiveOnly:u.keepLiveOnly});m&&(m.apply=(m.apply||0)+(performance.now()-R));let O=[];if(u.head.awaitLoads)for(let M of S.applied){if(M.kind!=="insert"||M.node.nodeType!==1)continue;let x=M.node;x.tagName==="LINK"&&/\bstylesheet\b/i.test(x.getAttribute("rel")||"")&&x.getAttribute("href")&&x.closest("head")&&O.push(new Promise(z=>{x.addEventListener("load",()=>z()),x.addEventListener("error",()=>z())}))}let E=null,P=null;if(c){let M=Zs(e,c,{ignored:u.ignored,skip:S.mergedScriptsLive,baseURI:w.baseURI,beforeNodeAdded:u.hooks.beforeNodeAdded,afterNodeAdded:u.hooks.afterNodeAdded,trackRecovery:!!g.recoveryLinks});O.push(...M.loads),E=M.swapped,P=M.vetoed}let v=M=>E&&E.get(M)||M,N=M=>{if(S.keptRuns.has(M))return S.runOf.get(M);let x=S.liveOf.get(M)||S.heldBy.get(M)||S.insertedLive.get(M);return x?v(x):null},L=M=>{let x=M&&S.liveOf.get(M);return x?v(x):null},D=M=>{let x=M&&N(M);return Array.isArray(x)?x[0]:x};if(g.recoveryLinks){let M=(x,k,z)=>(k.namespaceURI?x.getAttributeNS(k.namespaceURI,k.localName):x.getAttribute(k.qualifiedName))===z;dr(g.conflicts,g.recoveryLinks,{lookup:N,vetoed:S.vetoed,vetoedAttrs:S.vetoedAttrs,removedVetoes:S.removedVetoes,vetoedLive:P,liveAttr:M,ignored:u.ignored,liveRoot:e})}return{report:{applied:S.applied,decisions:g.decisions.map(M=>Object.assign({},M,{node:M.node?L(M.node):null,el:M.el?L(M.el):null,applied:!!(M.node?L(M.node):M.el&&L(M.el))})),conflicts:g.conflicts.map(M=>Object.assign({},M,{node:M.node?M.kind==="text"&&M.recovery.subject.nodeType===8?D(M.node):L(M.node):M.node,el:M.el?M.kind==="structure"?D(M.el):L(M.el):M.el})),localDiverged:g.localDiverged,identities:S.identities,moved:S.moved,replaced:S.replaced,stats:h},loads:O}}var Br=new WeakMap;function Ss(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Wn()}}function ho(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let n=Br.get(t);n||(n=Io(t),Br.set(t,n));let s=n("remote",o.remote),d=typeof o.base=="string"&&o.base===""?null:o.base,l=d?n("base",d):null,r=o.local?o.local.root:t.documentElement,i=o.local?o.local.toLive:c=>c;Os(t,s);let{report:u,loads:w}=vs({liveRoot:t.documentElement,baseRoot:l?l.documentElement:null,localRoot:r,remoteRoot:s.documentElement,toLive:i,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(w).then(()=>u)}function Ur(e,o,t={}){return ho(Object.assign({},t,{live:e,base:null,remote:o}))}function jr(e,o){if(e==null)return{root:o.createElement("template"),first:null};if(typeof e=="string"){let n=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(n){let d=Oo(e,o),l=n[1].toLowerCase()==="html"?d.documentElement:d.body;return{root:l,first:l}}let s=o.createElement("template");return s.innerHTML=e,{root:s,first:s.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let n=o.createElement("template"),s=e.isConnected;return n.content.appendChild(s?o.importNode(e,!0):e),{root:n,first:e}}if(e.nodeType===11){let n=o.createElement("template");return n.content.appendChild(e),{root:n,first:n.content.firstElementChild}}let t=o.createElement("template");for(let n of Array.from(e))t.content.appendChild(n.parentNode?o.importNode(n,!0):n);return{root:t,first:t.content.firstElementChild}}function qo(e,o,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let n=e.ownerDocument,{base:s,...d}=t,l=!!d.children;if(No(d,[e]).ignored(e))return Promise.resolve(Ss());let r=jr(o,n),i=s!=null?jr(s,n):null,u,w=null;if(l)u=r.root,w=i?i.root:null;else{if(u=r.first,w=i?i.first:null,!u){let p=No(d);return p.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),p.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Wn()})}if(u.tagName!==e.tagName){let p=No(d,[e,u]);if(p.hooks.beforeNodeMorphed(e,u)===!1)return Promise.resolve(Ss());let y=vs({liveRoot:e,baseRoot:w&&w.tagName===e.tagName?w:null,localRoot:e,remoteRoot:u,toLive:g=>g,options:d,identity:d.identity||{},childrenOnly:!0,isDocument:!1}),C=dn(u)?ko(u,n):n.importNode(u,!1);if(!dn(C))for(;e.firstChild;)C.appendChild(e.firstChild);return p.hooks.beforeNodeAdded(C)===!1?(Ko(y.report.conflicts,e,e),Promise.resolve(y.report)):p.hooks.beforeNodeRemoved(e)===!1?(Ko(y.report.conflicts,e,e),Promise.resolve(y.report)):(e.replaceWith(C),Ko(y.report.conflicts,e,C),p.hooks.afterNodeRemoved(e),p.hooks.afterNodeAdded(C),p.hooks.afterNodeMorphed(e,u),y.report.replaced.push(C),y.report.applied.push({kind:"insert",node:C,parent:C.parentNode},{kind:"remove",node:e,parent:C.parentNode}),Promise.all(y.loads).then(()=>y.report))}}let{report:c,loads:h}=vs({liveRoot:e,baseRoot:w,localRoot:e,remoteRoot:u,toLive:p=>p,options:d,identity:d.identity||{},childrenOnly:l,isDocument:!1});return Promise.all(h).then(()=>c)}var fl={mergeDocument:ho,morphDocument:Ur,morphElement:qo,merge3:Dr,morph:_o};return Yr(ul);})();
|
|
1
|
+
var HyperMorph=(()=>{var ns=Object.defineProperty;var oi=Object.getOwnPropertyDescriptor;var si=Object.getOwnPropertyNames;var ri=Object.prototype.hasOwnProperty;var ii=(e,o)=>{for(var t in o)ns(e,t,{get:o[t],enumerable:!0})},li=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of si(o))!ri.call(e,s)&&s!==t&&ns(e,s,{get:()=>o[s],enumerable:!(n=oi(o,s))||n.enumerable});return e};var ai=e=>li(ns({},"__esModule",{value:!0}),e);var Ml={};ii(Ml,{createIdentityStore:()=>Us,createParseCache:()=>Do,default:()=>Al,diff:()=>_n,findChangedRoots:()=>Gr,importMap:()=>jo,merge3:()=>ei,merge3Text:()=>ro,mergeDocument:()=>go,mergeJson:()=>As,mergeScriptText:()=>Go,morph:()=>Qo,morphDocument:()=>ti,morphElement:()=>Zo,parseJsonRelaxed:()=>zo,parseRulesRelaxed:()=>yr,spliceProtected:()=>Yr,tieredIdentity:()=>rs});function Bo(e,o){if(typeof e=="string"){let t=o&&o.defaultView,n=t&&t.DOMParser||globalThis.DOMParser;return new n().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Do(e){let o=new Map;return(t,n)=>{if(typeof n!="string")return Bo(n,e);let s=o.get(t);if(s&&s.text===n)return s.doc;let d=Bo(n,e);return o.set(t,{text:n,doc:d}),d}}function js(e,o){let t=o.doctype;if(!t)return!1;let n=e.doctype;if(n&&n.name===t.name&&n.publicId===t.publicId&&n.systemId===t.systemId)return!1;let s=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return n?e.replaceChild(s,n):e.insertBefore(s,e.documentElement),!0}var os=()=>!1;function ss(e,o=[]){if(typeof e!="function")return os;let t=new WeakMap,n=new Set(o);return s=>{if(!s||s.nodeType!==1)return!1;let d=t.get(s);if(d!==void 0)return d;let i=[],r=s,l=!1;for(;r&&r.nodeType===1;){let u=t.get(r);if(u!==void 0){l=u;break}if(i.push(r),e(r,n.has(r))){l=!0;break}if(n.has(r))break;r=r.parentElement}for(let u of i)t.set(u,l);return l}}var Cl=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 Fn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Us(e){let o=new WeakMap,t=0,n=r=>o.get(r)||null,s=r=>{let l=o.get(r);return l||(l=`${e}:${++t}`,o.set(r,l)),l};return{idOf:n,ensure:s,adopt:(r,l)=>{r&&typeof l=="string"&&l&&o.set(r,l)},exportMap:(r,l)=>{let u={},b=[],a=[],h=(p,v)=>{let O=l(p);O&&(u[v]=s(O));let m=p.children;b.push(m.length),a.push(p.tagName.toLowerCase());for(let c=0;c<m.length;c++)h(m[c],v===""?String(c):`${v}.${c}`)};return h(r,""),u["~"]=b.join(","),u["^"]=a.join(","),u}}}function jo(e,o){let t=new WeakMap;if(!e||!o||typeof o!="object"||Array.isArray(o))return t;let n=o["~"],s=typeof n=="string"?n.split(",").map(Number):null,d=s&&typeof o["^"]=="string"?o["^"].split(","):null,i=a=>Number.isInteger(a)&&a>=0,r=0,l=!1,u=a=>{let h=a;for(;h>0;){let p=s[r++];if(r>s.length||!i(p))return!1;h+=p-1}return!0},b=(a,h)=>{if(l)return;if(s){let O=r++,m=s[O];if(O>=s.length||!i(m)){l=!0;return}let c=!d||d[O]===a.tagName.toLowerCase();if(!c||m!==a.children.length){let g=c&&o[h];typeof g=="string"&&g&&t.set(a,g),u(m)||(l=!0);return}}let p=o[h];typeof p=="string"&&p&&t.set(a,p);let v=a.children;for(let O=0;O<v.length;O++)b(v[O],h===""?String(O):`${h}.${O}`)};return b(e,""),t}function rs(e){return o=>{for(let t of e){let n=t(o);if(typeof n=="string"&&n!=="")return n}return null}}var kn=rs([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Uo(e,o,t,n=null,s=null){let d=new Map,i=new Set,r=l=>{if(t(l))return;let u=o(l);u&&(d.has(u)?i.add(u):d.set(u,l))};if(n){let l=u=>{for(let b of u.querySelectorAll(n))r(b);for(let b of u.querySelectorAll("template"))b.content&&l(b.content)};r(e),l(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let l=u=>{r(u);let b=u.tagName==="TEMPLATE"&&u.content?u.content.children:u.children;for(let a=0;a<b.length;a++)l(b[a])};l(e)}for(let l of i)d.delete(l),s&&s.add(l),is(l);return d}function is(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var ci=new Set(["href","src","name","type","role"]),Hs=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function oo(e,o=5381){let t=o;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return t>>>0}function Vs(e){return e.replace(/\s+/g," ")}var fi=0;function Ws({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,s=new WeakMap;function d(A){let E=A.attributes,S=E.length;if(S===0)return{all:"",sig:A.tagName+"|"};let N=[],C="",j=[];for(let D=0;D<S;D++){let B=E[D],w=B.name;o(A,w)||N.push(w+"="+B.value),w==="class"?C=B.value.indexOf(" ")<0?B.value:B.value.split(/\s+/).filter(Boolean).sort().join(" "):ci.has(w)&&j.push(w+"="+B.value)}return N.length>1&&N.sort(),j.length>1&&j.sort(),{all:N.join(""),sig:A.tagName+"|"+C+(j.length?"|"+j.join("|"):"")}}function i(A){return A.nodeType===1&&A.tagName==="TEMPLATE"&&A.content?A.content.childNodes:A.childNodes}function r(A){let E=n.get(A);if(E)return E;if(A.nodeType===3)E={hash:"T"+oo(A.nodeValue),hint:Vs(A.nodeValue).slice(0,64),sig:null,tok:null};else if(A.nodeType===8)E={hash:"C"+oo(A.nodeValue),hint:"",sig:null,tok:null};else if(A.nodeType===1){let S=d(A),N=oo(A.tagName+""+S.all),C="";for(let j of u(A))if(j.nodeType===1){let D=r(j);N=oo(D.hash,N),C.length<64&&(C+=" "+D.hint)}else N=oo(b(j),N),j.kind==="text"&&C.length<64&&(C+=j.value.slice(0,64));E={hash:"E"+N,hint:Vs(C).trim().slice(0,64),sig:S.sig,tok:null}}else E={hash:"N"+A.nodeType,hint:"",sig:null,tok:null};return n.set(A,E),E}function l(A){if(!A.tok){A.tok=new Set;for(let E of A.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))E&&A.tok.add(E)}return A.tok}function u(A){let E=s.get(A);if(E)return E;E=[];let S=null,N=()=>{S&&(S.value=S.nodes.map(C=>C.nodeValue).join(""),E.push(S),S=null)};for(let C of i(A)){if(C.nodeType===3){S||(S={kind:"text",nodes:[],value:"",parent:A,hash:void 0}),S.nodes.push(C);continue}N(),C.nodeType===8?E.push({kind:"comment",nodes:[C],value:C.nodeValue,parent:A,hash:void 0}):C.nodeType===1&&!e(C)&&E.push(C)}return N(),s.set(A,E),E}function b(A){return A.nodeType===1?r(A).hash:(A.hash===void 0&&(A.hash=(A.kind==="text"?"T":"C")+oo(A.value)),A.hash)}function a(A,E){let S=l(r(A)),N=l(r(E));if(S.size===0&&N.size===0)return{coef:1,share:1};if(S.size===0||N.size===0)return null;let C=0;for(let j of S)N.has(j)&&C++;return{coef:C/Math.min(S.size,N.size),share:C/Math.max(S.size,N.size)}}function h(A,E){let S=a(A,E);return!!S&&S.coef>=.5}let p=new WeakMap;function v(A){let E=p.get(A);if(E)return E;E=[];for(let S of A.attributes)o(A,S.name)||E.push([S.namespaceURI||"",S.localName,S.value]);return E.sort((S,N)=>S[0]<N[0]?-1:S[0]>N[0]?1:S[1]<N[1]?-1:S[1]>N[1]?1:0),p.set(A,E),E}let O=new WeakMap;function m(A,E){if(A===E)return!0;if(b(A)!==b(E))return!1;let S=O.get(A);if(S&&S.has(E))return S.get(E);let N=O.get(E);if(N&&N.has(A))return N.get(A);let C=c(A,E),j=C===!0;return C===!1&&t&&t.hashRejected++,S||O.set(A,S=new WeakMap),S.set(E,j),j}function c(A,E){if(A.nodeType===1){if(E.nodeType!==1||A.tagName!==E.tagName||A.namespaceURI!==E.namespaceURI)return!1;let S=v(A),N=v(E);if(S.length!==N.length)return!1;for(let D=0;D<S.length;D++)if(S[D][0]!==N[D][0]||S[D][1]!==N[D][1]||S[D][2]!==N[D][2])return!1;let C=u(A),j=u(E);if(C.length!==j.length)return!1;for(let D=0;D<C.length;D++){if(b(C[D])!==b(j[D]))return!1;if(!m(C[D],j[D]))return fi}return!0}return E.nodeType===1?!1:A.kind===E.kind&&A.value===E.value}let g=new WeakMap,P=new Map,T=0;function x(A){let E=g.get(A);if(E)return E;let S=b(A),N=P.get(S);N||P.set(S,N=[]);let C=N.find(j=>m(j.unit,A));return E=C?C.key:"K"+T++,C||N.push({unit:A,key:E}),g.set(A,E),E}return{meta:r,unitsOf:u,unitHash:b,similar:h,score:a,childrenOf:i,equalUnits:m,exactUnitKey:x,ignored:e}}var Ks=16,ui=2e3,di=3,ls={align:0,certifyVisited:0,certifyScheduled:0};function as(e,o,t){let{meta:n,unitsOf:s,unitHash:d,similar:i,score:r,childrenOf:l,equalUnits:u,ignored:b}=t.analyzer,a=t.baseId||(()=>null),h=t.sideId||(()=>null),p=t.baseKey||(()=>null),v=t.sideKey||(()=>null),O=t.baseDropped||new Set,m=t.sideDropped||new Set,c=t.stats||null,g=c?new Set:null,P=c?new Set:null,T=new Map,x=new Map,A=new Set,E=new Map,S=new Set,N=new Set,C=new Set,j=[],D=[],B=[],w=[],y=ui,$=new Map,U=new Map,V=(H,X)=>{T.set(H,X),x.set(X,H)},Ne=new Set,Ae=new Set,De=null,oe=H=>{let X=H.nodeType?H.parentNode:H.parent;if(!X||X.nodeType!==11)return X;if(!De){De=new WeakMap;let de=pe=>{for(let se of pe.querySelectorAll("template"))se.content&&(De.set(se.content,se),de(se.content))};for(let pe of[e,o])de(pe.tagName==="TEMPLATE"&&pe.content?pe.content:pe)}return De.get(X)||null},xe=(H,X)=>{for(let de=oe(H);de&&!Ne.has(de);de=oe(de))Ne.add(de);for(let de=oe(X);de&&!Ae.has(de);de=oe(de))Ae.add(de)},$e=H=>{for(let X=oe(H);X;X=oe(X))if(T.has(X))return N.has(X);return!1},ae=H=>{for(let X=oe(H);X;X=oe(X)){let de=x.get(X);if(de!==void 0)return N.has(de)}return!1},k=H=>!!H&&H.nodeType===1,_=(H,X)=>{let de=E.get(H);return!!de&&de.has(X)},re=H=>Hs.has(H.tagName),Z=t.comparisons||t.scope,Be=(H,X)=>{if(Z){if(Z.same.get(H)===X)return!0;if(Z.differ.get(H)===X)return!1}if(!H.isEqualNode(X))return!1;if(H.tagName==="TEMPLATE")return u(H,X);let de=H.getElementsByTagName("template");if(de.length===0)return!0;let pe=X.getElementsByTagName("template");if(de.length!==pe.length)return!1;for(let se=0;se<de.length;se++)if(!u(de[se],pe[se]))return!1;return!0},Ke=(H,X)=>{let de=a(H);if(!de)return!0;let pe=h(X);return!pe||de===pe},Te=H=>{let X=p(H);return X&&t.baseIndex.get(X)===H&&!m.has(X)?X:null},it=H=>{let X=v(H);return X&&t.sideIndex.get(X)===H&&!O.has(X)?X:null},et=(H,X)=>{let de=Te(H);if(!de)return!0;let pe=it(X);return!pe||de===pe},mt=globalThis.__hyperMorphProfile,Ze=mt?performance.now():0;mt&&!t.scope&&(n(e),n(o),mt.meta=(mt.meta||0)+(performance.now()-Ze),Ze=performance.now()),V(e,o);let ft=new Set;for(let[H,X]of t.baseIndex){let de=t.sideIndex.get(H);de&&de.tagName===X.tagName&&!T.has(X)&&!x.has(de)&&(V(X,de),xe(X,de),ft.add(X))}if(ft.size){let H=[];if(t.scope)for(let se of t.scope.chain)ft.has(se)&&H.push(se);let X=[t.scope?t.scope.root:e];for(;X.length;){let se=X.pop();ft.has(se)&&H.push(se);let ke=l(se);for(let fe=ke.length-1;fe>=0;fe--)ke[fe].nodeType===1&&X.push(ke[fe])}let de=new Set;for(let se=H.length-1;se>=0;se--){let ke=H[se];t.scope&&t.scope.onChain.has(ke)?de.add(ke):ce(ke,T.get(ke),de)?(N.add(ke),C.add(ke),c&&c.certificationPairs++):de.add(ke)}let pe=new Set;for(let se of H)N.has(se)&&!pe.has(se)&&Ct(se,pe)}t.scope&&t.scope.head&&Le(t.scope.head[0],t.scope.head[1]);function Ct(H,X){let de=[H];for(;de.length;){let pe=de.pop();if(!X.has(pe)){X.add(pe),z(pe);for(let se of s(pe))k(se)&&T.has(se)&&de.push(se)}}}w.push([e,o]);for(let[H,X]of T)k(H)&&H!==e&&w.push([H,X]);return jt(),Dt(),mt&&(mt.align=(mt.align||0)+(performance.now()-Ze)),{map:T,reverse:x,moved:S,identical:N,pairIdenticalChildren:z,weak:A,unpair:Tt,rematch:Dt,insertedByHash:Rt,refused:P,identityPaired:ft};function Dt(){be(),jt();for(let H=0;H<B.length;){let X=B.length;Lt(H,X),H=X,jt(),be(),jt()}}function Tt(H){let X=T.get(H);if(!X)return;E.has(H)||E.set(H,new Set),E.get(H).add(X);let de=(se,ke)=>{T.delete(se),x.delete(ke),S.delete(se),N.delete(se),A.delete(se),C.delete(se)},pe=(se,ke)=>{for(let fe of s(se)){let G=T.get(fe);!G||ft.has(fe)||!(k(G)?ke.contains(G):ke.contains(G.nodes[0]))||(de(fe,G),k(fe)&&pe(fe,G))}};de(H,X),k(H)&&pe(H,X),j.push(H),D.push(X)}function Rt(){let H=new Map;for(let X of new Set(D)){if(x.has(X))continue;let de=n(X).hash;H.has(de)||H.set(de,[]),H.get(de).push(X)}return H}function jt(){for(;w.length;){let[H,X]=w.shift();T.get(H)!==X||C.has(H)||N.has(H)||un(H,X)}}function qt(H,X){if(!re(H))for(let de of s(H))k(de)&&(X.push(de),qt(de,X))}function un(H,X){C.add(H);let de=s(H),pe=s(X);ls.align+=de.length+pe.length,$=new Map,U=new Map;for(let ue=0;ue<de.length;ue++)$.set(de[ue],ue);for(let ue=0;ue<pe.length;ue++)U.set(pe[ue],ue);if(H.tagName==="HTML")for(let ue of["HEAD","BODY"]){let Ie=de.find(He=>k(He)&&He.tagName===ue),Pe=pe.find(He=>k(He)&&He.tagName===ue);Ie&&Pe&&!T.has(Ie)&&!x.has(Pe)&&V(Ie,Pe)}for(let ue=0;ue<de.length&&ue<pe.length;ue++){let Ie=de[ue],Pe=pe[ue];T.has(Ie)||x.has(Pe)||(k(Ie)?k(Pe)&&Ie.tagName===Pe.tagName&&Be(Ie,Pe)&&Le(Ie,Pe):!k(Pe)&&Ie.kind===Pe.kind&&Ie.value===Pe.value&&Le(Ie,Pe))}Ce(de,pe);let se=de.filter(ue=>!T.has(ue)),ke=pe.filter(ue=>!x.has(ue));se.length&&ke.length&&(F(se,ke),J(se,ke),ne(se,ke,de,pe),Oe(de,pe));let fe=!1,G=!1;for(let ue of de){if(!T.has(ue)){k(ue)&&(j.push(ue),qt(ue,j),fe=!0);continue}k(ue)&&!N.has(ue)&&w.push([ue,T.get(ue)])}for(let ue of pe)!x.has(ue)&&k(ue)&&(D.push(ue),qt(ue,D),G=!0);fe&&G&&B.push([H,X])}function Lt(H,X){for(let de=H;de<X;de++){let[pe,se]=B[de];if(T.get(pe)!==se)continue;let ke=s(pe),fe=s(se),G=new Map,ue=new Map,Ie=null;for(let Pe of ke)k(Pe)&&(T.has(Pe)?Ie=Pe:(G.has(Ie)||G.set(Ie,[]),G.get(Ie).push(Pe)));Ie=null;for(let Pe of fe)k(Pe)&&(x.has(Pe)?Ie=x.get(Pe):(ue.has(Ie)||ue.set(Ie,[]),ue.get(Ie).push(Pe)));for(let[Pe,He]of G){let Se=ue.get(Pe);if(!(!Se||He.length!==Se.length)&&He.every((Je,nt)=>Se[nt].tagName===Je.tagName&&Ke(Je,Se[nt])&&!_(Je,Se[nt])))for(let Je=0;Je<He.length;Je++)Jt(He[Je],Se[Je])}}}function Jt(H,X){V(H,X),A.add(H),w.push([H,X]),jt()}function F(H,X){let de=so(H,d),pe=so(X,d),se=new Map;for(let ke of X){let fe=d(ke);pe.get(fe)===1&&se.set(fe,ke)}for(let ke of H){if(T.has(ke))continue;let fe=d(ke);if(de.get(fe)!==1)continue;let G=se.get(fe);G&&!x.has(G)&&u(ke,G)&&Le(ke,G)}}function ce(H,X,de){let pe=[[H,X]];for(;pe.length;){let[se,ke]=pe.pop();if(ls.certifyVisited++,c&&c.certificationVisited++,se.nodeType!==ke.nodeType)return!1;if(se.nodeType===3||se.nodeType===8){if(se.nodeValue!==ke.nodeValue)return!1;continue}if(se.nodeType!==1){if(!se.isEqualNode(ke))return!1;continue}if(se.tagName!==ke.tagName||se.namespaceURI!==ke.namespaceURI||b(se)!==b(ke))return!1;let fe=se.attributes,G=ke.attributes;if(fe.length!==G.length)return!1;for(let Se=0;Se<fe.length;Se++){let Je=fe[Se];if(ke.getAttributeNS(Je.namespaceURI,Je.localName)!==Je.value)return!1}let ue=T.get(se);if(ue!==void 0&&ue!==ke)return!1;let Ie=x.get(ke);if(Ie!==void 0&&Ie!==se)return!1;if(se!==H){if(N.has(se))continue;if(de.has(se))return!1}let Pe=l(se),He=l(ke);if(Pe.length!==He.length)return!1;ls.certifyScheduled+=Pe.length;for(let Se=Pe.length-1;Se>=0;Se--)pe.push([Pe[Se],He[Se]])}return!0}function ge(H,X){return!k(H)||!(Ne.has(H)||Ae.has(X))?!0:!!M(H,X)||!(Te(H)||it(X))}function Le(H,X){if(k(H)&&(Ne.has(H)||Ae.has(X))){let de=M(H,X);if(!de){if(Te(H)||it(X))return;V(H,X),w.push([H,X]);return}for(let pe=0;pe<de.length;pe+=2){let se=de[pe],ke=de[pe+1],fe=T.get(se);fe!==void 0&&fe!==ke&&Me(se,fe);let G=x.get(ke);G!==void 0&&G!==se&&Me(G,ke),T.get(se)===ke&&(S.delete(se),A.delete(se),N.add(se),C.add(se))}}R(H,X)}function Me(H,X){T.delete(H),x.delete(X),S.delete(H),N.delete(H),A.delete(H),C.delete(H)}function M(H,X){let de=[H,X,!1],pe=[];for(;de.length;){let se=de.pop(),ke=de.pop(),fe=de.pop(),G=T.get(fe),ue=x.get(ke);if(fe!==H&&(G!==void 0&&G!==ke&&ft.has(fe)||ue!==void 0&&ue!==fe&&ft.has(ue)))return null;if(!(G===ke&&N.has(fe))&&((G!==void 0||ue!==void 0)&&pe.push(fe,ke),!!k(fe))){if(se||G!==void 0&&G!==ke||ue!==void 0&&ue!==fe){let Ie=s(fe),Pe=s(ke);for(let He=0;He<Ie.length&&He<Pe.length;He++)de.push(Ie[He],Pe[He],!0)}else if(Ne.has(fe)||Ae.has(ke)){let Ie=fe.tagName==="TEMPLATE"?fe.content:fe,Pe=ke.tagName==="TEMPLATE"?ke.content:ke;for(let He=Ie.firstElementChild,Se=Pe.firstElementChild;He&&Se;){if(b(He)){He=He.nextElementSibling;continue}if(b(Se)){Se=Se.nextElementSibling;continue}(T.has(He)||x.has(Se)||Ne.has(He)||Ae.has(Se))&&de.push(He,Se,!1),He=He.nextElementSibling,Se=Se.nextElementSibling}}}}return pe}function R(H,X){V(H,X),N.add(H),k(H)&&C.add(H)}function z(H){let X=T.get(H);if(!X||!k(H))return;let de=s(H),pe=s(X);for(let se=0;se<de.length&&se<pe.length;se++)T.has(de[se])||R(de[se],pe[se])}function J(H,X){let de=fe=>k(fe)&&!re(fe)?n(fe).sig+""+n(fe).hint:null,pe=so(H,de),se=so(X,de),ke=new Map;for(let fe of X){let G=de(fe);G!=null&&se.get(G)===1&&ke.set(G,fe)}for(let fe of H){if(T.has(fe))continue;let G=de(fe);if(G==null||pe.get(G)!==1)continue;let ue=ke.get(G);ue&&!x.has(ue)&&Ke(fe,ue)&&V(fe,ue)}}function ne(H,X,de,pe){let se=new Map;for(let fe of X){if(!k(fe)||x.has(fe)||re(fe))continue;let G=n(fe).sig;se.has(G)||se.set(G,[]),se.get(G).push({el:fe,index:U.get(fe)})}let ke=[];for(let fe of H){if(T.has(fe)||!k(fe)||re(fe))continue;let G=se.get(n(fe).sig);if(!G||!G.length)continue;let ue=$.get(fe),Ie=G.filter(Pe=>!x.has(Pe.el)).map(Pe=>({c:Pe,d:Math.abs(Pe.index-ue)}));Ie.sort((Pe,He)=>Pe.d-He.d),Ie.length>Ks&&(Ie=Ie.slice(0,Ks));for(let{c:Pe,d:He}of Ie){if(!Ke(fe,Pe.el))continue;let Se=r(fe,Pe.el);Se&&Se.coef>=.5&&ke.push({b:fe,s:Pe.el,coef:Se.coef,share:Se.share,d:He,bi:ue})}}if(ke.sort((fe,G)=>G.coef-fe.coef||G.share-fe.share||fe.d-G.d||fe.bi-G.bi),c&&ke.length>1){let fe=new Map;for(let G of ke){let ue=fe.get(G.b);ue?ue.coef===G.coef&&(ue.share===G.share?ue.strict++:ue.loose++):fe.set(G.b,{coef:G.coef,share:G.share,strict:0,loose:0})}for(let[G,ue]of fe)g.has(G)||!(ue.strict||ue.loose)||(g.add(G),ue.strict?c.similarTiesStrict++:c.similarTiesLoose++)}for(let fe of ke)!T.has(fe.b)&&!x.has(fe.s)&&V(fe.b,fe.s)}function je(H,X){return k(H)!==k(X)?!1:k(H)?H.tagName!==X.tagName||!Ke(H,X)?!1:re(H)||n(H).hint===""||n(X).hint===""?!0:i(H,X):H.kind===X.kind}function Q(H,X){let de=(se,ke)=>{let fe=ke===null?-1:se===X?U.get(ke):$.get(ke),G=se[fe+1];return G&&!k(G)?G:null},pe=null;for(let se of H){if(k(se)){pe=se;continue}if(T.has(se))continue;let ke=pe===null?null:T.get(pe);if(pe!==null&&!ke)continue;let fe=de(X,ke);fe&&!x.has(fe)&&fe.kind===se.kind&&V(se,fe)}}function Oe(H,X){Q(H,X);let de=Ve(H,X),pe=(ke,fe)=>k(ke)&&n(ke).hint!==""&&n(fe).hint===""&&!!fe.querySelector("br")&&!de(ke,fe),se=0;for(let ke of H){if(T.has(ke)){let G=U.get(T.get(ke));G!==void 0&&G>=se&&(se=G+1);continue}let fe=0;for(let G=se;G<X.length&&fe<di;G++){let ue=X[G];if(!x.has(ue)&&(fe++,je(ke,ue)&&!_(ke,ue)&&!pe(ke,ue))){V(ke,ue),k(ke)&&(n(ke).hint===""||n(ue).hint==="")&&A.add(ke),se=G+1;break}}}Ce(H,X)}function Ve(H,X){let de=(pe,se,ke)=>{for(let fe=se-1;fe>=0;fe--)if(k(pe[fe])&&ke(pe[fe]))return pe[fe];return null};return(pe,se)=>{let ke=$.get(pe),fe=U.get(se);if(ke===fe)return!0;let G=de(H,ke,Ie=>T.has(Ie)),ue=de(X,fe,Ie=>x.has(Ie));return G?T.get(G)===ue:!ue}}function Ce(H,X){let de=H.filter(G=>k(G)&&!T.has(G)),pe=X.filter(G=>k(G)&&!x.has(G));if(!de.length||!pe.length)return;let se=so(de,G=>G.tagName),ke=so(pe,G=>G.tagName),fe=Ve(H,X);for(let G of de){let ue=G.tagName;if(se.get(ue)!==1||ke.get(ue)!==1)continue;let Ie=pe.find(Pe=>Pe.tagName===ue);Ie&&!x.has(Ie)&&fe(G,Ie)&&Ke(G,Ie)&&!_(G,Ie)&&(u(G,Ie)?Le(G,Ie):(V(G,Ie),A.add(G)))}}function be(){let H=new Map;for(let G of A)if(k(G)&&k(T.get(G))){let ue=n(G).hash;H.has(ue)||H.set(ue,[]),H.get(ue).push(G)}if(H.size)for(let G of D){if(x.has(G)||!k(G)||ae(G))continue;let ue=H.get(n(G).hash),Ie=ue&&ue.find(Pe=>A.has(Pe)&&!_(Pe,G)&&Ke(Pe,G)&&et(Pe,G)&&u(Pe,G)&&ge(Pe,G));Ie&&(Tt(Ie),Le(Ie,G),xe(Ie,G),S.add(Ie))}let X=new Map,de=new Map,pe=new Map;for(let G of A){let ue=T.get(G);k(G)&&k(ue)&&pe.set(ue,G)}let se=(G,ue)=>{if(!x.has(G))return!ae(G);let Ie=pe.get(G);return Ie===x.get(G)&&Ie!==ue&&!Ie.contains(ue)},ke=G=>{if(x.has(G)){let ue=pe.get(G);pe.delete(G),Tt(ue)}};for(let G of[...D,...pe.keys()]){if(x.has(G)&&!pe.has(G))continue;let ue=n(G).hash;if(X.has(ue)||X.set(ue,[]),X.get(ue).push(G),re(G))continue;let Ie=n(G).sig;de.has(Ie)||de.set(Ie,[]),de.get(Ie).push(G)}let fe=new Set;for(let G of A){let ue=T.get(G);!k(G)||!k(ue)||re(G)||n(G).hint===""||n(ue).hint===""||i(G,ue)||fe.add(G)}for(let G of[...j,...fe]){let ue=T.get(G);if(ue?!(A.has(G)&&fe.has(G)):$e(G))continue;let Ie=nt=>{ue&&Tt(G),ke(nt)},Pe=X.get(n(G).hash);if(Pe){let nt=Pe.find(ot=>ot!==ue&&se(ot,G)&&!_(G,ot)&&et(G,ot)&&u(G,ot)&&ge(G,ot));if(nt){Ie(nt),Le(G,nt),xe(G,nt),S.add(G);continue}}if(re(G)||y<=0)continue;let He=de.get(n(G).sig);if(!He)continue;let Se=null,Je=0;for(let nt of He)if(!(nt===ue||!se(nt,G)||!Ke(G,nt)||!et(G,nt)||_(G,nt))&&(y--<=0||i(G,nt)&&(Je++,Se=nt,Je>1)))break;Je>1&&P&&P.add(G),Je===1&&(Ie(Se),V(G,Se),xe(G,Se),S.add(G),w.push([G,Se]))}}}function so(e,o){let t=new Map;for(let n of e){let s=o(n);s!=null&&t.set(s,(t.get(s)||0)+1)}return t}var hi={diff:0},Fs=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,pi=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,mi=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,gi=/\P{M}\p{M}*/gu;function bi(e){if(e==="")return[];if(Fs){let t=[];for(let n of Fs.segment(e))t.push(n.segment);return t}let o=[];for(let t of e.match(mi))if(pi.test(t))for(let n of t.match(gi))o.push(n);else o.push(t);return o}var wi=/^[ ]+$/,yi=e=>wi.test(e)?" ".repeat(e.length):e,qn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),Nt="",cs=e=>e.every(o=>qn(o)||o.k===Nt),ki=/^[\x00-\x7f\u00A0]*$/,xi=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function vi(e){return e===""?[]:e.match(xi)}function fn(e,o=!1){return(o?vi(e):bi(e)).map(t=>({k:yi(t),raw:t,len:t.length}))}var xn=(...e)=>e.every(o=>ki.test(o));function fs(e,o,t){let n=e.length,s=o.length,d=Math.min(n+s,t),i=d+1,r=new Int32Array(2*d+3),l=[],u=n===0&&s===0;for(let p=0;p<=d&&!u;p++){l.push(r.slice(i-p,i+p+1));for(let v=-p;v<=p;v+=2){let O;v===-p||v!==p&&r[i+v-1]<r[i+v+1]?O=r[i+v+1]:O=r[i+v-1]+1;let m=O-v,c=O;for(;O<n&&m<s&&e[O].k===o[m].k;)O++,m++;if(hi.diff+=1+O-c,r[i+v]=O,O>=n&&m>=s){u=!0;break}}}if(!u)return null;let b=[],a=n,h=s;for(let p=l.length-1;p>0;p--){let v=l[p],O=a-h,m=O+p,c=O===-p||O!==p&&v[m-1]<v[m+1]?O+1:O-1,g=v[c+p],P=g-c;for(;a>g&&h>P;)b.push([0,a-1,h-1]),a--,h--;a===g?(b.push([1,a,h-1]),h--):(b.push([-1,a-1,h]),a--)}for(;a>0&&h>0;)b.push([0,a-1,h-1]),a--,h--;return b.reverse(),b}function Ti(e,o,t){let n=a=>a.k===Nt;if(!e.some(n)&&!o.some(n))return fs(e,o,t);let s=[],d=[];for(let a=0;a<e.length;a++)n(e[a])||s.push(a);for(let a=0;a<o.length;a++)n(o[a])||d.push(a);let i=fs(s.map(a=>e[a]),d.map(a=>o[a]),t);if(!i)return null;let r=[],l=0,u=0,b=(a,h)=>{for(;l<a&&u<h&&e[l].k===o[u].k;)r.push([0,l++,u++]);let p=fs(e.slice(l,a),o.slice(u,h),t);if(!p)return!1;for(let[v,O,m]of p)r.push([v,O+l,m+u]);return l=a,u=h,!0};for(let[a,h,p]of i)if(a===0){if(!b(s[h],d[p]))return null;r.push([0,l,u]),l++,u++}return b(e.length,o.length)?r:null}function Hn(e,o,t=4e3){let n=[],s=0;for(;s<e.length&&s<o.length&&e[s].k===o[s].k;)e[s].raw!==o[s].raw&&n.push({bi:s,tok:o[s]}),s++;let d=0;for(;d<e.length-s&&d<o.length-s&&e[e.length-1-d].k===o[o.length-1-d].k;)e[e.length-1-d].raw!==o[o.length-1-d].raw&&n.push({bi:e.length-1-d,tok:o[o.length-1-d]}),d++;let i=e.slice(s,e.length-d),r=o.slice(s,o.length-d),l=Ii(i,r)?null:Ti(i,r,t);if(!l){let c=i.length||r.length?[{bs:s,be:s+i.length,toks:r}]:[];return{hunks:c,cosmetic:n,coarse:!0,parts:c.map(g=>({...g,gap:[],group:0})),cosmeticEq:n}}let u=[],b=(c,g)=>{i[c].raw!==r[g].raw&&n.push({bi:s+c,tok:r[g]})},a=null,h=[],p=0,v=0,O=()=>{a&&u.push(a),a=null;for(let[c,g]of h)b(c,g);h=[],p++};for(let[c,g,P]of l){if(c===0){a&&qn(i[g])&&!i[g].k.includes(`
|
|
2
|
+
`)?h.push([g,P]):(O(),b(g,P)),v=g+1;continue}(!a||h.length)&&(a&&u.push(a),a={bs:s+v,be:s+v,toks:[],gap:h.map(([T,x])=>({bi:s+T,tok:r[x]})),group:p},h=[]),c===-1?(a.be=s+v+1,v=g+1):a.toks.push(r[P])}O(),Si(u,e);let m=ds(u);return{hunks:m.hunks,cosmetic:n.concat(m.cosmetic),parts:u,cosmeticEq:n}}function Si(e,o){for(let t=0;t<e.length;t++){let n=e[t];if(n.gap.length)continue;let s=t+1<e.length?e[t+1].bs:1/0;if(n.toks.length){if(n.bs===n.be)for(;n.bs+1<s&&n.bs<o.length&&n.toks[0].k===Nt&&o[n.bs].k===Nt;)n.toks=[...n.toks.slice(1),n.toks[0]],n.bs++,n.be++}else for(;n.be+1<s&&n.be<o.length&&o[n.bs].k===Nt&&o[n.be].k===Nt;)n.bs++,n.be++}}function ds(e,o=()=>!1){let t=[],n=[],s=null,d=-1;for(let i of e){let r=o(i);if(s&&!s.alone&&!r&&i.group===d){s.be=i.be;for(let l of i.gap)s.toks.push(l.tok);for(let l of i.toks)s.toks.push(l);continue}s&&t.push({bs:s.bs,be:s.be,toks:s.toks});for(let l of i.gap)n.push(l);s={bs:i.bs,be:i.be,toks:i.toks.slice(),alone:r},d=i.group}return s&&t.push({bs:s.bs,be:s.be,toks:s.toks}),{hunks:t,cosmetic:n}}var Ni=(e,o)=>e.bs===o.bs&&e.be===o.be&&ms(e.toks,o.toks);function ps(e,o,t){let n=b=>a=>b.some(h=>Ni(a,h)),s=ds(e.parts,n(o.parts)),d=ds(o.parts,n(e.parts)),i=e.cosmeticEq.concat(s.cosmetic),r=o.cosmeticEq.concat(d.cosmetic),[l,u]=t?Ai(s.hunks,d.hunks,t,i,r):[s.hunks,d.hunks];return{lh:l,rh:u,cosL:i,cosR:r}}function Ai(e,o,t,n,s){let d=(v,O)=>v.k===O.k&&v.raw===O.raw,i=[{list:e.map(v=>({...v})),resp:new Set(n.map(v=>v.bi)),raw:new Map(n.map(v=>[v.bi,v.tok]))},{list:o.map(v=>({...v})),resp:new Set(s.map(v=>v.bi)),raw:new Map(s.map(v=>[v.bi,v.tok]))}],r=v=>v.bs===v.be,l=(v,O,m,c)=>{let g=v.list[O];if(!r(g))return c(g)===m?g.toks:null;let P=O?v.list[O-1].be:0,T=O+1<v.list.length?v.list[O+1].bs:t.length;if(m<P||m>T)return null;let x=g.toks,A=g.bs;for(;A>m;){let E=x[x.length-1];if(!d(E,t[A-1])||v.resp.has(A-1))return null;x=[E,...x.slice(0,-1)],A--}for(;A<m;){if(!d(x[0],t[A])||v.resp.has(A))return null;x=[...x.slice(1),x[0]],A++}return x},u=(v,O,m,c,g,P)=>{let T=v.list[O],x=g?m.slice(m.length-c):m.slice(0,c),A=g?m.slice(0,m.length-c):m.slice(c),E={bs:P,be:P,toks:x};if(r(T)){if(!A.length){v.list[O]=E;return}let N={bs:P,be:P,toks:A};g&&(N.lead=!0),v.list.splice(O,1,...g?[N,E]:[E,N]);return}let S={bs:T.bs,be:T.be,toks:A};v.list.splice(O,1,...g?[S,E]:[E,S])},b=(v,O,m,c,g)=>{let P=v.list[O],T=g?m.slice(m.length-c):m.slice(0,c),x=g?m.slice(0,m.length-c):m.slice(c),A={bs:P.bs,be:P.be,toks:T};if(!x.length){v.list[O]=A;return}let E=g?{bs:P.bs,be:P.bs,toks:x,lead:!0}:{bs:P.be,be:P.be,toks:x};v.list.splice(O,1,...g?[E,A]:[A,E])},a=(v,O,m,c)=>{let g=v.list[O],P=m.list[c],T=g.be,x=P.bs;if(T>=x||O+1<v.list.length&&v.list[O+1].bs<=P.be||c>0&&m.list[c-1].be>=g.bs)return!1;for(let U=T;U<x;U++)if(!qn(t[U])||t[U].k.includes(`
|
|
3
|
+
`))return!1;let A=U=>t.slice(T,x).map((V,Ne)=>U.raw.get(T+Ne)||V),E=[...g.toks,...A(v)],S=[...A(m),...P.toks],N=(U,V,Ne)=>V>=0&&V+Ne.length<=U.length&&Ne.every((Ae,De)=>U[V+De].k===Ae.k),C=(U,V,Ne)=>cs(U)&&t.slice(V,Ne).some(Ae=>!qn(Ae)),j=U=>U.some(V=>!qn(V)),D,B,w,y;if(r(g)&&j(g.toks)&&N(S,0,g.toks)){let U=S.slice(g.toks.length);C(U,T,P.be)||(D=T,B=g.toks,w=S.slice(0,g.toks.length),y=[null,{bs:T,be:P.be,toks:U}])}if(D===void 0&&r(P)&&j(P.toks)){let U=E.length-P.toks.length,V=E.slice(0,U);N(E,U,P.toks)&&!C(V,g.bs,x)&&(D=x,B=E.slice(U),w=P.toks,y=[{bs:g.bs,be:x,toks:V},null])}if(D===void 0)return!1;let $=U=>U&&(U.bs<U.be||U.toks.length);return v.list.splice(O,1,...[y[0],{bs:D,be:D,toks:B}].filter($)),m.list.splice(c,1,...[{bs:D,be:D,toks:w},y[1]].filter($)),!0},h=i[0],p=i[1];for(let v=0;v<64;v++){let O=!1;e:for(let m=0;m<h.list.length;m++)for(let c=0;c<p.list.length;c++){let g=h.list[m],P=p.list[c];if(!(g.bs===P.bs&&g.be===P.be&&ms(g.toks,P.toks))){for(let T of[!0,!1]){let x=E=>T?E.be:E.bs,A=r(g)?[x(P),g.bs]:[x(g)];for(let E of A){let S=l(h,m,E,x),N=S&&l(p,c,E,x);if(!N)continue;let C=(y,$)=>T?y[y.length-1-$]:y[$],j=0;for(;j<S.length&&j<N.length&&C(S,j).k===C(N,j).k;)j++;if(!j)continue;let D=T?S.slice(0,S.length-j):S.slice(j),B=T?N.slice(0,N.length-j):N.slice(j);if(!(j<S.length&&j<N.length&&!cs(D)&&!cs(B)&&(r(g)&&r(P)||g.bs===P.bs&&g.be===P.be)||!(T?S.slice(S.length-j):S.slice(0,j)).some(y=>!qn(y)))){if(j===S.length&&j===N.length&&r(g)&&r(P)){if(g.bs===E&&P.bs===E)continue;h.list[m]={bs:E,be:E,toks:S},p.list[c]={bs:E,be:E,toks:N}}else!r(g)&&g.bs===P.bs&&g.be===P.be?(b(h,m,S,j,T),b(p,c,N,j,T)):(u(h,m,S,j,T,E),u(p,c,N,j,T,E));O=!0;break e}}}if(a(h,m,p,c)||a(p,c,h,m)){O=!0;break e}}}if(!O)break}return[h.list,p.list]}var Mi=48,Oi=.3;function Ii(e,o){let t=e.filter(i=>!qn(i)),n=o.filter(i=>!qn(i));if(Math.min(t.length,n.length)<Mi)return!1;let s=new Map;for(let i of t)s.set(i.k,(s.get(i.k)||0)+1);let d=0;for(let i of n){let r=s.get(i.k);r>0&&(d++,s.set(i.k,r-1))}return d/Math.min(t.length,n.length)<Oi}var Ei=(e,o)=>{let t=new Set;for(let n of e.toks)typeof n.k!="string"&&t.add(n.k.el);for(let n=e.bs;n<e.be;n++)typeof o[n].k!="string"&&t.add(o[n].k.el);return t},ms=(e,o)=>e.length===o.length&&e.every((t,n)=>t.k===o[n].k);function qs(e,o,t,n="remote"){let s=Hn(e,o),d=Hn(e,t),{lh:i,rh:r,cosL:l,cosR:u}=ps(s,d,e),b=k=>k.bs===k.be,a=k=>k.toks.some(_=>typeof _.k=="string"),h=k=>b(k)&&!a(k),p=(k,_)=>_.bs<k.be&&k.bs<_.be,v=(k,_)=>!p(k,_)&&_.bs<=k.be&&k.bs<=_.be&&(b(k)&&a(k)||b(_)&&a(_))&&!(b(k)&&b(_)),O=(k,_)=>k.bs===_.bs&&k.be===_.be&&ms(k.toks,_.toks),m=[],c=new Set;for(let k of i){let _=r.find(re=>!c.has(re)&&O(k,re));_?(c.add(_),m.push({bs:k.bs,be:k.be,side:"both",l:k,r:_,toks:k.toks})):m.push({bs:k.bs,be:k.be,side:"L",l:k,toks:k.toks,lead:!!k.lead})}for(let k of r)c.has(k)||m.push({bs:k.bs,be:k.be,side:"R",r:k,toks:k.toks,lead:!!k.lead});m.sort((k,_)=>k.bs-_.bs||k.be-_.be||_.lead-k.lead);let g=0,P=0;for(let k of m)k.side==="both"&&(g+=k.toks.length-(k.be-k.bs));let T=m.map((k,_)=>_),x=k=>T[k]===k?k:T[k]=x(T[k]),A=(k,_)=>(k=x(k),_=x(_),k===_?!1:(T[k]=_,!0)),E=m.map(k=>Ei({bs:k.bs,be:k.be,toks:k.toks},e)),S={L:new Map,R:new Map};m.forEach((k,_)=>{let re=k.side==="both"?["L","R"]:[k.side];for(let Z of re)for(let Be of E[_])S[Z].has(Be)||S[Z].set(Be,[]),S[Z].get(Be).push(_)});for(let k of[S.L,S.R])for(let _ of k.values())for(let re=1;re<_.length;re++)A(_[0],_[re]);for(let k=0;k<m.length;k++)for(let _=k+1;_<m.length;_++){let re=m[k],Z=m[_];re.side===Z.side&&re.side!=="both"||re.bs>Z.be||(p(re,Z)||v(re,Z)?A(k,_):re.bs===Z.bs&&b(re)&&b(Z)&&P++)}let N=(k,_)=>{let re=k==="L"?i:r;for(let Z of re)if(Z.toks.some(Be=>Be.kind==="close"&&Be.k.el===_.el))return Z.bs;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="close"&&e[Z].k.el===_.el)return Z;return-1};m.forEach((k,_)=>{if(!(!h(k)||k.side==="both"))for(let re of k.toks){if(re.kind!=="open")continue;let Z=N(k.side,re.k);if(Z<=k.bs)continue;let Be=new Uint8Array(Z-k.bs),Ke=[];if(m.forEach((Te,it)=>{if(!(Te.side===k.side||b(Te))&&Te.bs<Z&&Te.be>k.bs){Ke.push(it);for(let et=Math.max(Te.bs,k.bs);et<Math.min(Te.be,Z);et++)Be[et-k.bs]=1}}),Ke.length&&Be.every(Te=>Te===1))for(let Te of Ke)A(_,Te)}});let C=!0;for(;C;){C=!1;let k=new Map;m.forEach((_,re)=>{let Z=x(re),Be=k.get(Z)||{bs:_.bs,be:_.be,L:!1,R:!1};Be.bs=Math.min(Be.bs,_.bs),Be.be=Math.max(Be.be,_.be),_.side!=="R"&&(Be.L=!0),_.side!=="L"&&(Be.R=!0),k.set(Z,Be)}),m.forEach((_,re)=>{for(let[Z,Be]of k){if(x(re)===x(Z)||!(Be.L&&Be.R))continue;let Ke=_.bs<Be.be&&_.be>Be.bs,Te=b(_)&&a(_)&&(_.bs===Be.be||_.bs===Be.bs);(Ke||Te)&&A(re,Z)&&(C=!0)}})}let j=new Map;m.forEach((k,_)=>{let re=x(_);j.has(re)||j.set(re,[]),j.get(re).push(k)});let D=[];for(let k of j.values()){let _=k.some(Z=>Z.side==="L"),re=k.some(Z=>Z.side==="R");if(_&&re){let Z=Math.min(...k.map(it=>it.bs)),Be=Math.max(...k.map(it=>it.be)),Ke=k.filter(it=>it.side!=="R").map(it=>it.l).sort((it,et)=>it.bs-et.bs),Te=k.filter(it=>it.side!=="L").map(it=>it.r).sort((it,et)=>it.bs-et.bs);D.push({bs:Z,be:Be,kind:"conflict",localHunks:Ke,remoteHunks:Te})}else for(let Z of k)D.push({bs:Z.bs,be:Z.be,kind:Z.side,u:Z})}let B=(k,_)=>{let re=k==="L"?i:r;for(let Z of re)if(Z.toks.some(Be=>Be.kind==="close"&&Be.k.el===_.el))return Z.bs+.5;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="close"&&e[Z].k.el===_.el)return Z;return 1/0},w=(k,_)=>{let re=k==="L"?i:r;for(let Z of re)if(Z.toks.some(Be=>Be.kind==="open"&&Be.k.el===_.el))return Z.bs-.5;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="open"&&e[Z].k.el===_.el)return Z;return-1/0},y=k=>k.kind==="R"?"R":"L",$=k=>k.kind==="R"?1:0;D.sort((k,_)=>{if(k.bs!==_.bs)return k.bs-_.bs;let re=k.bs===k.be,Z=_.bs===_.be;if(re!==Z)return re?-1:1;if(re&&Z&&k.kind!=="conflict"&&_.kind!=="conflict"){let Ke=k.u.toks,Te=_.u.toks,it=mt=>mt.length&&mt.every(Ze=>Ze.kind==="open"),et=mt=>mt.length&&mt.every(Ze=>Ze.kind==="close");if(it(Ke)&&it(Te)){let mt=Math.max(...Ke.map(ft=>B(y(k),ft.k))),Ze=Math.max(...Te.map(ft=>B(y(_),ft.k)));if(mt!==Ze)return Ze-mt}if(et(Ke)&&et(Te)){let mt=Math.min(...Ke.map(ft=>w(y(k),ft.k))),Ze=Math.min(...Te.map(ft=>w(y(_),ft.k)));return mt!==Ze?Ze-mt:$(_)-$(k)}}let Be=Ke=>Ke.u&&Ke.u.lead?1:0;return Be(_)-Be(k)||$(k)-$(_)||k.be-_.be});let U=[],V=[],Ne=0,Ae=k=>{k>Ne&&(U.push({bs:Ne,be:k,toks:e.slice(Ne,k),source:"base"}),Ne=k)};for(let k of D){if(Ae(k.bs),k.kind==="conflict"){let _=hs(e,k.localHunks,k.bs,k.be),re=hs(e,k.remoteHunks,k.bs,k.be),Z=n==="local"?_:n==="both"?_.concat(re):re,Be=(it,et)=>{let mt=0;for(let Ze of it)Ze.be<=k.bs&&!et.includes(Ze)&&(mt+=Ze.toks.length-(Ze.be-Ze.bs));return mt},Ke=k.bs+Be(i,k.localHunks),Te=k.bs+Be(r,k.remoteHunks);V.push({bs:k.bs,be:k.be,ls:Ke,le:Ke+_.length,rs:Te,re:Te+re.length,ms:0,me:0,base:e.slice(k.bs,k.be),local:_,remote:re,resolved:Z}),U.push({bs:k.bs,be:k.be,toks:Z,source:"conflict",localHunks:k.localHunks,localToks:_,keepsLocal:n!=="remote"})}else U.push({bs:k.bs,be:k.be,toks:k.u.toks,source:k.kind==="R"?"remote":"local",localHunks:k.kind==="R"?[]:[k.u.l]});Ne=Math.max(Ne,k.be)}Ae(e.length);let De=0,oe=0;for(let k of U)k.source==="conflict"&&(V[oe].ms=De,V[oe].me=De+k.toks.length,oe++),De+=k.toks.length;let xe=new Map(l.map(k=>[k.bi,k.tok])),$e=new Map(u.map(k=>[k.bi,k.tok])),ae=[];for(let k of U){k.source==="base"&&(k.toks=k.toks.map((_,re)=>{let Z=k.bs+re,Be=xe.get(Z),Ke=$e.get(Z),Te=Be&&Ke?n==="remote"?Ke:Be:Be||Ke||_;return Te===_?_:{...Te,cosmetic:!0}}));for(let _ of k.toks)ae.push({..._,src:k.source})}return{tokens:ae,segments:U,conflicts:V,localHunks:i,remoteHunks:r,collapsedDelta:g,samePoint:P,mapLocalOffset:Ci(e,i,U)}}function hs(e,o,t,n){let s=[],d=t;for(let i of o)s=s.concat(e.slice(d,i.bs),i.toks),d=i.be;return s.concat(e.slice(d,n))}var us=e=>e.reduce((o,t)=>o+t.len,0);function Ci(e,o,t){let n=new Int32Array(e.length+1);for(let i=0;i<e.length;i++)n[i+1]=n[i]+e[i].len;let s=o.map(i=>({bs:n[i.bs],be:n[i.be],text:i.toks.map(r=>r.raw).join(""),ref:i})),d=t.map(i=>({bs:n[i.bs],be:n[i.be],len:us(i.toks),source:i.source,localHunks:i.localHunks||[],localLen:i.localToks?us(i.localToks):0,keepsLocal:i.keepsLocal,ref:i}));return i=>{let r=null,l=null,u=0,b=0,a=0;for(let p of s){let v=p.bs-a;if(i<=b+v){r=a+(i-b);break}if(b+=v,a=p.bs,i<=b+p.text.length){l=p,u=i-b,r=p.bs;break}b+=p.text.length,a=p.be}r===null&&(r=a+(i-b));let h=0;for(let p of d){if(!l&&r<=p.bs)return h;if(!(l?p.localHunks.includes(l.ref):r<p.be)){h+=p.len;continue}if(p.source==="base")return h+(r-p.bs);if(p.source==="remote")return h+p.len;if(p.source==="local")return h+Math.min(u,p.len);if(!p.keepsLocal||!l)return h+p.len;let O=p.localHunks.indexOf(l.ref),m=us(hs(e,p.localHunks.slice(0,O),p.ref.bs,l.ref.bs));return h+Math.min(m+u,p.localLen)}return h}}function ro(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:c=>Math.min(c,o.length),granularity:"word"};let s=xn(e,o,t),d=fn(e,s),i=fn(o,s),r=fn(t,s),l=d.length<=2e4&&i.length<=2e4&&r.length<=2e4?qs(d,i,r,n):null,u="word",b=d;if(!l){let c=g=>g.split(/(?<=\n)/).map(P=>({k:P,raw:P,len:P.length}));b=c(e),l=qs(b,c(o),c(t),n),u="line"}let a=c=>c.map(g=>g.raw).join(""),h=c=>{let g=[0];for(let P of c)g.push(g[g.length-1]+P.len);return g},p=h(b),v=null,O=null,m=null;if(l.conflicts.length){let c=g=>g.split(/(?<=\n)/).map(P=>({k:P,raw:P,len:P.length}));v=h(u==="line"?c(o):i),O=h(u==="line"?c(t):r),m=h(l.tokens)}return{text:a(l.tokens),conflicts:l.conflicts.map(c=>({bs:p[c.bs],be:p[c.be],ls:v[c.ls],le:v[c.le],rs:O[c.rs],re:O[c.re],ms:m[c.ms],me:m[c.me],base:a(c.base),local:a(c.local),remote:a(c.remote),resolved:a(c.resolved)})),mapLocalOffset:l.mapLocalOffset,granularity:u}}function _n(e,o,t=4e3){if(e===o)return[];let n=xn(e,o),s=fn(e,n),d=fn(o,n),i=Hn(s,d,t),r=[0];for(let l of s)r.push(r[r.length-1]+l.len);return i.hunks.map(l=>({bs:r[l.bs],be:r[l.be],text:l.toks.map(u=>u.raw).join("")}))}function Xt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Bn({base:e,side:o,retained:t,transfers:n,baseAtomKey:s=r=>r.el,sideAtomKey:d=r=>r.el,budget:i=Xt()}){let r=[],l=x=>({status:"fallback",reason:x}),u=x=>x>i.remaining?!1:(i.remaining-=x,!0);if(!u((t.length+n.length)*3))return l("work-limit");for(let[x,A]of[["retained",t],["transfer",n]])for(let E of A){let{from:S,to:N,target:C}=E;if(!Number.isInteger(S)||!Number.isInteger(N)||!Number.isInteger(C)||S<0||N<=S||N>e.text.length||C<0||C+N-S>o.text.length)return l("invalid-range");r.push({...E,kind:x})}let b=Symbol(),a=x=>(A,E)=>{if(!u(1))throw b;return i.sortComparisons++,x(A,E)},h,p;try{h=r.slice().sort(a((x,A)=>x.from-A.from||x.to-A.to)),p=r.slice().sort(a((x,A)=>x.target-A.target||x.to-x.from-(A.to-A.from)))}catch(x){if(x===b)return l("work-limit");throw x}if(!u(r.length*2))return l("work-limit");for(let x=1;x<h.length;x++)if(h[x].from<h[x-1].to)return l("source-overlap");for(let x=1;x<p.length;x++)if(p[x].target<p[x-1].target+p[x-1].to-p[x-1].from)return l("target-overlap");for(let x of h){let A=x.to-x.from;if(!u(A))return l("work-limit");for(let E=0;E<A;E++){let S=x.from+E,N=x.target+E;if(i.comparisons++,e.text[S]!==o.text[N])return l("unequal-occurrence");let C=e.atomAt.get(S),j=o.atomAt.get(N);if(!!C!=!!j||C&&s(C)!==d(j))return l("different-atom")}}let v=e.text.length+o.text.length+2,O=r.reduce((x,A)=>x+(A.to-A.from)*2,2);if(!u(v+O+r.length))return l("work-limit");let m=new Int32Array(e.text.length+1).fill(-1),c=new Int32Array(o.text.length+1).fill(-1);i.mapCells+=v,i.mapWrites+=O;let g=-1,P=!0;for(let x of h){x.target<g&&(P=!1),g=x.target+x.to-x.from;for(let A=0;A<x.to-x.from;A++)m[x.from+A]=x.target+A,c[x.target+A]=x.from+A}return m[e.text.length]=o.text.length,c[o.text.length]=e.text.length,{status:"ready",runs:h,bTo:m,toB:c,monotone:P,covers:(x,A)=>{if(!u(A-x))return null;i.coverageChecks+=A-x;for(let E=x;E<A;E++)if(e.text[E]!==Nt&&!/\s/.test(e.text[E])&&m[E]<0)return!1;return!0}}}function gs({base:e,side:o,baseOf:t=()=>null,budget:n=Xt()}){if(e.text===o.text||!e.text.includes(Nt)&&!o.text.includes(Nt))return{status:"none"};let s=(e.text.length+o.text.length)*8;if(s>n.remaining)return{status:"fallback",reason:"work-limit"};n.remaining-=s,n.boundarySteps=(n.boundarySteps||0)+s;let d=(v,O)=>O<v.length&&(v[O]===Nt||/\s/.test(v[O])),i=new Map,r=Symbol(),l=(v,O)=>{let m=v.stackAt[O]||[];if(!i.has(m)){if(m.length>n.remaining)throw r;n.remaining-=m.length,n.boundarySteps+=m.length,i.set(m,m.find(c=>c.block)?.el||null)}return i.get(m)},u=[],b=(v,O)=>{let m=l(e,v),c=l(o,O),g=m&&c&&t(c)!==m?"transfer":"retained",P=u[u.length-1];P&&P.to===v&&P.target+P.to-P.from===O&&P.kind===g&&P.destination===c?P.to++:u.push({from:v,to:v+1,target:O,destination:c,kind:g})},a=0,h=0,p=!1;try{for(;a<e.text.length||h<o.text.length;){if(a<e.text.length&&h<o.text.length&&e.text[a]===o.text[h]){let P=e.atomAt.get(a),T=o.atomAt.get(h);if(!!P!=!!T||P&&t(T.el)!==P.el)return{status:"none"};b(a++,h++);continue}if(!d(e.text,a)&&!d(o.text,h))return{status:"none"};let v=a,O=h;for(;d(e.text,a);)a++;for(;d(o.text,h);)h++;let m=e.text.slice(v,a),c=o.text.slice(O,h);(m.includes(Nt)||c.includes(Nt))&&(p=!0);let g=0;for(;g<a-v&&g<h-O&&e.text[a-g-1]===o.text[h-g-1];)g++;for(let P=g;P>0;P--)b(a-P,h-P)}}catch(v){if(v===r)return{status:"fallback",reason:"work-limit"};throw v}return p?Bn({base:e,side:o,retained:u.filter(v=>v.kind==="retained"),transfers:u.filter(v=>v.kind==="transfer"),sideAtomKey:v=>t(v.el)||v.el,budget:n}):{status:"none"}}var _s=/\s/,Vo=/\S/;function En(e,o,t,n,s,d,i=-1,r=-1){if(!e.length)return-1;s(n,e.length);let l=new Int32Array(e.length),u=0;for(let p=1;p<e.length;p++){for(s(n,1);u&&(s(n,1),e[u]!==e[p]);)u=l[u-1];s(n,1),e[u]===e[p]&&u++,l[p]=u}let b=-1,a=0,h=0;u=0;for(let p=0;p<o.length;p++){for(s(n,1);u&&(s(n,1),e[u]!==o[p]);)u=l[u-1];if(s(n,1),e[u]===o[p]&&u++,u!==e.length)continue;let v=p+1-e.length,O=p+1;for(u=l[u-1];a<t.length&&t[a].from<v;)s(n,1),a++;for(;h<t.length&&t[h].to<O;)s(n,1),h++;if(s(n,6),!(a===t.length||h===t.length||t[a].from!==v||t[h].to!==O||i>=0&&v<r&&O>i)){if(!d)return v;if(b>=0)return-1;b=v}}return b}function So(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function bs(e,o,t,n){let s=null;for(let i of o)if(n(t,1),!(i.source!==e.source||i.side!==e.side))for(let r of i.runs){if(n(t,1),r.source!==e.source)continue;let l=Math.max(e.from,r.from),u=Math.min(e.to,r.to);l>=u||(s||(n(t,e.to-e.from),s=new Uint8Array(e.to-e.from)),n(t,u-l),s.fill(1,l-e.from,u-e.from))}if(!s)return!1;n(t,e.to-e.from);let d=!1;for(let i=e.from;i<e.to;i++)if(Vo.test(e.flat.text[i])){if(!s[i-e.from])return!1;d=!0}return d}function ws({source:e,side:o,views:t,eligible:n,blocked:s,baseId:d,model:i,tokensOf:r,budget:l,charge:u}){let{V:b,A:a,idOf:h}=t[o],p=t[1-o];if(e.nodeType!==1||a.identical.has(e)||p.A.identical.has(e)||s.has(e)||!n(e))return null;let v=b.twin(e),O=p.V.twin(e);if(!v||!O||a.map.get(e)!==v||a.reverse.get(v)!==e||p.A.map.get(e)!==O||p.A.reverse.get(O)!==e||!b.here(v)||!p.V.here(O)||!n(v)||!n(O))return null;let m=d(e);if(m!==h(v)||m!==p.idOf(O))return null;let c=i(e,null,l),g=i(v,a,l),P=i(O,p.A,l);if(!So(c)||!So(g)||!So(P))return null;let T=c.flat.text,x=g.flat.text;if(u(l,T.length+x.length*3),!Vo.test(x)||x.length>=T.length)return null;let A=T.startsWith(x),E=T.endsWith(x);if(A===E)return null;let S=A?x.length:0,N=A?T.length:T.length-x.length,C=S,j=N;for(;C<j&&(u(l,1),!!_s.test(T[C]));)C++;for(;j>C&&(u(l,1),!!_s.test(T[j-1]));)j--;if(C===j)return null;let D=r(c,l),B=!1,w=!1;for(let y of D)u(l,1),y.from===C&&(B=!0),y.to===j&&(w=!0);return!B||!w?null:{source:e,side:o,flat:c.flat,from:S,to:N}}function zs({base:e,views:o,side:t,attempt:n,eligible:s,blocked:d,baseId:i,model:r,tokensOf:l,certificates:u,charge:b,exhausted:a,limit:h}){if(h<=0)return null;let p=Xt(h),{V:v,A:O,idOf:m}=o[t],c=o[1-t],[g,P,T,x]=n,A=null;try{for(let E=g;E<=P;E++){b(p,1);let S=e[E];if(S.nodeType!==1||O.identical.has(S)||c.A.identical.has(S)||d.has(S)||!s(S))continue;let N=ws({source:S,side:t,views:o,eligible:s,blocked:d,baseId:i,model:r,tokensOf:l,budget:p,charge:b});if(!N||bs(N,u,p,b))continue;let{flat:C,from:j,to:D}=N;b(p,(D-j)*2);let B=C.text.slice(j,D).trim();for(let w=T;w<=x;w++){b(p,1);let y=v.units[w],$=v.baseOf(y);if(!$||$===S||$.nodeType!==1||y.nodeType!==1||$.parentNode!==S.parentNode||y.parentNode!==O.map.get(S).parentNode||O.map.get($)!==y||O.reverse.get(y)!==$||d.has($)||!s($)||!s(y)||i($)!==m(y))continue;let U=r($,null,p),V=r(y,O,p);if(!So(U)||!So(V))continue;let Ne=U.flat.text,Ae=V.flat.text;if(b(p,Ne.length),!Vo.test(Ne)||Ae.length<=Ne.length)continue;let De=l(V,p),oe=En(Ne,Ae,De,p,b,!0);if(!(oe<0)&&!(En(B,Ae,De,p,b,!1,oe,oe+Ne.length)<0)){(A||=[]).push(N);break}}}}catch(E){if(E!==a)throw E}return A}function $s(e,o,t,n,s,d,i){if(d==="both"||t.atoms.length||n.atoms.length||s.atoms.length)return d;let r=d==="remote";if(r?i.rss!==i.rse||i.lss===i.lse||i.local===i.base:i.lss!==i.lse||i.rss===i.rse||i.remote===i.base)return d;for(let l of e){if(l.source!==o||l.side!==(r?1:0)||l.flat.text!==t.text||l.flat.nodes.length!==t.nodes.length||i.be<=l.from||i.bs>=l.to)continue;let u=!0;for(let a=0;a<t.nodes.length;a++){let h=l.flat.nodes[a],p=t.nodes[a];if(h.node!==p.node||h.s!==p.s||h.e!==p.e){u=!1;break}}if(!u)continue;let b=!1;for(let a=i.bs;a<i.be;a++)if(Vo.test(t.text[a])){if(a<l.from||a>=l.to){u=!1;break}b=!0}if(u&&b)return r?"local":"remote"}return d}var Dn="\uFFFC";var Li={caret:0},vn=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(" ")),tr=new Set(["BR","WBR","IMG"]),ys=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 jn(e,o={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(o.ignored&&o.ignored(e)||tr.has(e.tagName))return!0;if(!vn.has(e.tagName))return!ys.has(e.tagName);if(o.remoteWins&&o.remoteWins(e))return!1;let t=o.inlineCache&&o.inlineCache.get(e);if(t!==void 0)return t;let n=!0;for(let s of e.childNodes)if(!jn(s,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Ri(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ln(e,o={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},n=(s,d)=>{for(let i of s){if(i.nodeType===3){let a=i.nodeValue;if(!a)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+a.length}),t.text+=a;for(let h=0;h<a.length;h++)t.stackAt.push(d);continue}if(i.nodeType!==1)continue;if(o.ignored&&o.ignored(i)){t.pins.push({el:i,i:t.text.length});continue}if(o.skip&&o.skip.has(i))continue;let r=o.via&&o.via(i)||i;r!==i&&(t.via||(t.via=new Map)).set(r,i);let l=i.tagName;if(o.blocks&&o.blocks.has(i)){t.text.length&&t.text[t.text.length-1]!==Nt&&(t.stackAt.push(d),t.text+=Nt);let a={el:i,tag:l,from:t.text.length,to:-1,depth:d.length,block:!0};t.marks.push(a);let h=d.concat([a]);n(r.childNodes,h),t.stackAt.push(h),t.text+=Nt,a.to=t.text.length;continue}let u=vn.has(l)&&Ri(r);if(tr.has(l)||!vn.has(l)||o.remoteWins&&o.remoteWins(i)||o.atomize&&o.atomize(i)||u){t.atoms.push({i:t.text.length,el:i,key:u?l+":empty":l,stack:d}),t.stackAt.push(d),t.text+=Dn;continue}let b={el:i,tag:l,from:t.text.length,to:-1,depth:d.length};t.marks.push(b),n(r.childNodes,d.concat([b])),b.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&Ko(t).trim()===""){let s=t.atoms[0];t.placeholder=s.el,t.text=t.text.slice(0,s.i)+t.text.slice(s.i+1),t.stackAt.splice(s.i,1);for(let d of t.nodes)d.s>s.i&&(d.s--,d.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(s=>[s.i,s])),t}function Pi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function Bi(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,""")}"`;return o+">"}function lo(e,o,t){let n="",s=[];for(let d=o;d<t;d++){let i=e.stackAt[d],r=0;for(;r<s.length&&r<i.length&&s[r]===i[r];)r++;for(;s.length>r;)n+=`</${s.pop().tag.toLowerCase()}>`;for(;s.length<i.length;){let u=i[s.length];n+=Bi(u.el),s.push(u)}let l=e.atomAt.get(d);n+=l?l.el.outerHTML:e.text[d]===Nt?"":Pi(e.text[d])}for(;s.length;)n+=`</${s.pop().tag.toLowerCase()}>`;return n}function Di(e,o){let t=[...e.el.attributes].filter(n=>!o(e.el,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tag+"|"+t}function nr(e,o){let t=[...e.attributes].filter(n=>!o(e,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function Gs(e,o=()=>!1){let t=new Map,n=d=>{let i=t.get(d);return i===void 0&&(i="{"+d.map(r=>Di(r,o)).sort().join(",")+"}",t.set(d,i)),i},s="";for(let d=0;d<e.text.length;d++){let i=e.atomAt.get(d);s+=(i?"["+nr(i.el,o)+"]":e.text[d])+n(e.stackAt[d])}return e.text.length===0&&e.placeholder&&(s+="[br]"),s}function io(e,o,t,n=s=>s.key){let s=[],d=e.text,i=0,r=l=>{if(l<=i)return;let u=d.slice(i,l);if(t)for(let b of u.split(/(?<=\n)/))s.push({k:b,raw:b,len:b.length});else for(let b of fn(u,o))s.push(b)};for(let l of e.atoms)r(l.i),s.push({k:"\0"+n(l),raw:Dn,len:1,atom:!0}),i=l.i+1;return r(d.length),s}function Ko(e){if(!e.atoms.length)return e.text;let o="",t=0;for(let n of e.atoms)o+=e.text.slice(t,n.i),t=n.i+1;return o+e.text.slice(t)}var ao=e=>{let o=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)o[t+1]=o[t]+e[t].len;return o};function Ho(e,o,t,n){let s=ao(o),d=ao(t),i=[],r=0,l=0;for(let b of n.hunks){l+=b.bs-r;let a=l+b.toks.length;i.push({bs:s[b.bs],be:s[b.be],ss:d[l],se:d[a],text:e.text.slice(d[l],d[a]),toks:b.toks,lead:!!b.lead}),l=a,r=b.be}let u=new Map;for(let b of n.cosmetic)u.set(b.bi,b.tok.raw);return{hunks:i,respell:u}}function Ys(e,o,t){let n=i=>i===Nt||/\s/.test(i),s=i=>i.replace(/[\u001E\s]/g,""),d=[];for(let i of e){let r=o.slice(i.bs,i.be),l=t.slice(i.ss,i.se);if(!r.includes(Nt)&&!l.includes(Nt)||r.includes(Dn)||l.includes(Dn)||s(r)!==s(l)){d.push(i);continue}let u=0,b=0;for(;;){let a=u,h=b;for(;a<r.length&&n(r[a]);)a++;for(;h<l.length&&n(l[h]);)h++;let p=u,v=b;for(;p<a&&v<h&&r[p]===l[v];)p++,v++;let O=a,m=h;for(;O>p&&m>v&&r[O-1]===l[m-1];)O--,m--;if(O>p||m>v){let c=l.slice(v,m);d.push({bs:i.bs+p,be:i.bs+O,ss:i.ss+v,se:i.ss+m,text:c,toks:[...c].map(g=>({k:g,raw:g,len:1})),lead:i.lead})}if(a>=r.length)break;u=a+1,b=h+1}}return d}function Xs(e,o,t){let n=new Int32Array(o+1).fill(-1),s=new Int32Array(t+1).fill(-1),d=0,i=0,r=l=>{for(;d<l;)n[d]=i,s[i]=d,d++,i++};for(let l of e)r(l.bs),d=l.be,i=l.se;return r(o),n[o]=i,s[i]=o,{bTo:n,toB:s}}function Js(e,o,t){let n=[],s=0,d=0,i=(r,l)=>{if(s===r&&d===l)return;let u=o.text.slice(d,l);n.push({bs:s,be:r,ss:d,se:l,text:u,toks:fn(u,xn(u)),lead:!1})};for(let r of t.runs)i(r.from,r.target),s=r.to,d=r.target+r.to-r.from;return i(e.text.length,o.text.length),{hunks:n,respell:new Map}}function Qs(e,o,t,n){let s=ao(o),d=ao(t),i=(l,u)=>{let b=0,a=l.length;for(;b<a;){let h=b+a>>>1;l[h]<u?b=h+1:a=h}return l[b]===u?b:-1};for(let l of e.hunks)if(i(s,l.bs)<0||i(s,l.be)<0)return null;if(e.hunks.some(l=>i(d,l.ss)<0||i(d,l.se)<0)){if(!n)return null;let l=[];for(let h of e.hunks)l.push(h.ss,h.se);let u=[],b=0,a=0;for(let h of t){let p=a+h.len;for(;b<l.length&&l[b]<=a;)b++;let v=a;for(;b<l.length&&l[b]<p;){let O=l[b++];if(O>v){let m=h.raw.slice(v-a,O-a);u.push(...fn(m,xn(m))),v=O}}if(v===a)u.push(h);else{let O=h.raw.slice(v-a);u.push(...fn(O,xn(O)))}a=p}t=u,d=ao(t)}let r=[];for(let l of e.hunks){let u=i(s,l.bs),b=i(s,l.be),a=i(d,l.ss),h=i(d,l.se);if(u<0||b<0||a<0||h<0)return null;r.push({bs:u,be:b,toks:t.slice(a,h),gap:[],group:r.length})}return{parts:r,cosmeticEq:[],tokens:t}}function ks(e,o,t,n={},s=null){return or(e,o,t,n.base,n.local,n.remote,s,{})}function or(e,o,t,n,s,d,i,r){let l=xn(Ko(e),Ko(o),Ko(t)),u=io(e,l,!1,n),b=io(o,l,!1,s),a=io(t,l,!1,d),h=u.length>2e4||b.length>2e4||a.length>2e4;h&&(u=io(e,l,!0,n),b=io(o,l,!0,s),a=io(t,l,!0,d));let p=i?.local?Js(e,o,i.local):null,v=i?.remote?Js(e,t,i.remote):null,O=p?Qs(p,u,b,!h):Hn(u,b),m=v?Qs(v,u,a,!h):Hn(u,a);p&&O&&(b=O.tokens),v&&m&&(a=m.tokens);let c,g;if(O&&m){let P=ps(O,m,u);c=Ho(o,u,b,{hunks:P.lh,cosmetic:P.cosL}),g=Ho(t,u,a,{hunks:P.rh,cosmetic:P.cosR})}else c=p||Ho(o,u,b,O),g=v||Ho(t,u,a,m);return c.hunks=Ys(c.hunks,e.text,o.text),g.hunks=Ys(g.hunks,e.text,t.text),r.base=e,r.local=o,r.remote=t,r.lines=h,r.baseTokens=u,r.localEdits=c,r.remoteEdits=g,r.localMap=Xs(c.hunks,e.text.length,o.text.length),r.remoteMap=Xs(g.hunks,e.text.length,t.text.length),r.full=null,r}function Zs(e,o){if(e.size!==o.size)return!1;for(let t of e)if(!o.has(t))return!1;return!0}var co=/\s/;function Wo(e,o,t){for(let n=o;n<t;n++)if(!co.test(e[n]))return!1;return!0}function ji(e,o,t){let n=e.cache[t]||(e.cache[t]=new Map);if(n.has(o))return n.get(o);let s=t===0?"local":"remote",d=t===0?"remote":"local",i=o.baseMark,r=o[d+"Mark"],l=!o.block&&!o[s]&&!!r&&i.to>i.from;if(l){let u=t===0?e.ML:e.MR,b=t===0?e.MR:e.ML,a=t===0?e.fr:e.fl,h=!1;for(let p=i.from;p<i.to;p++){if(u.bTo[p]>=0){l=!1;break}b.bTo[p]<0&&!co.test(e.fb.text[p])&&(h=!0)}if(l&&!h){for(let p=r.from;p<r.to;p++)if(b.toB[p]<0&&!co.test(a.text[p])){h=!0;break}}l&&=h}return n.set(o,l),l}function er(e,o,t,n,s,d,i,r,l){let u=r===0?e.fl:e.fr,b=null;for(let a=t;a<n;a++){let h=o[a];if(!Wo(u.text,h.ss,h.se))return null;if(Wo(e.fb.text,h.bs,h.be)){if(h.bs<h.be&&h.ss<h.se||co.test(e.fb.text[h.bs-1]||"")||co.test(e.fb.text[h.be]||""))continue;return null}let p=!1;for(let v=h.bs;v<h.be;v++){if(co.test(e.fb.text[v]))continue;let O=null;for(let m of e.fb.stackAt[v]){let c=e.byEl.get(m.el);if(c&&ji(e,c,r)){O=c;break}}if(!O)return null;(b||(b=new Set)).add(O),p=!0}if(!p)return null}if(!b){if((r===0?"local":"remote")!==l)return null;let a=r===0?e.fr:e.fl,h=!1;for(let p=d;p<i;p++){let v=s[p];if(!Wo(e.fb.text,v.bs,v.be))return null;Wo(a.text,v.ss,v.se)||(h=!0)}if(!h)return null}return b||0}function Fo(e){let{out:o,policy:t="remote",L:n,R:s}=e,d=e.provenance||new WeakMap,i=e.textMappers||new WeakMap,r=e.conflicts||[],l=e.decisions||[],u=r.length,b=e.conflict||(f=>r.push(f)),a={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},h=[],p=!!(n&&n.reverse&&n.map&&s&&s.reverse&&s.map),v={base:null,local:null,remote:null};if(!e.prepared&&p&&e.moveIn){let f=ve=>We=>ve.some(Re=>Re===We||Re.nodeType===1&&Re.contains(We)),L=f(e.local),W=f(e.remote),K=f(e.base),Y=new Set,he=ve=>{if(!vn.has(ve.tagName))return;let We=n.map.get(ve),Re=s.map.get(ve);(We&&!L(We)||Re&&!W(Re))&&Y.add(ve);for(let Fe of ve.children)he(Fe)};for(let ve of e.base)ve.nodeType===1&&he(ve);let ye=ve=>We=>{if(!vn.has(We.tagName))return!1;let Re=ve.reverse.get(We);return!!Re&&(Y.has(Re)||!K(Re))};Y.size&&(v.base=ve=>Y.has(ve)),v.local=ye(n),v.remote=ye(s)}let O={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&p&&e.moveIn){let f=K=>Y=>K.some(he=>he===Y||he.nodeType===1&&he.contains(Y)),L=f(e.local),W=f(e.remote);for(let K of ln(e.base,{...e,atomize:v.base}).atoms){let Y=n.map.get(K.el),he=s.map.get(K.el),ye=!!Y&&!L(Y),ve=!!he&&!W(he);!ye&&!ve||(ye&&e.movePlanned?.(K.el,"local",Y,null),ve&&e.movePlanned?.(K.el,"remote",he,null),O.base.add(K.el),Y&&!ye&&O.local.add(Y),he&&!ve&&O.remote.add(he),L(K.el)&&O.local.add(K.el),W(K.el)&&O.remote.add(K.el))}}let m=e.prepared?.base||ln(e.base,{...e,atomize:v.base,skip:O.base}),c=e.prepared?.local||ln(e.local,{...e,atomize:v.local,skip:O.local}),g=e.prepared?.remote||ln(e.remote,{...e,atomize:v.remote,skip:O.remote}),P=new Map(m.atoms.map(f=>[f.el,f])),T={},x=f=>e.prepared?e.prepared.full?.(f)||null:O[f].size?(T[f]||(T[f]=ln(e[f],{...e,atomize:v[f]})),T[f]):null,A=(f,L,W)=>{L.namespaceURI?f.setAttributeNS(L.namespaceURI,L.name,W):f.setAttribute(L.name,W)},E=(f,L,W,K)=>{if(!L&&(!W||!K)){for(let he of(W||K).attributes)A(f,he,he.value);return}let Y=new Map;for(let he of[L,W,K])if(he)for(let ye of he.attributes)Y.set(ye.name,ye);for(let[he,ye]of Y){let ve=L?L.getAttribute(he):null,We=W?W.getAttribute(he):ve,Re=K?K.getAttribute(he):ve,Fe;We===Re?Fe=We:We===ve?(Fe=Re,l.push({kind:"attr",el:f,name:he,source:"remote"})):Re===ve?(Fe=We,l.push({kind:"attr",el:f,name:he,source:"local"})):(Fe=t==="local"?We:Re,b({kind:"attr",el:f,name:he,base:ve,local:We,remote:Re,resolved:Fe},{el:f,sample:ye}),l.push({kind:"attr",el:f,name:he,source:"both"})),Fe!=null&&A(f,ye,Fe)}},S=(f,L,W,K)=>f&&e.mergeAttrs?e.mergeAttrs(f,L,W,K):E(K,f,L,W),N=e.mergeElement||((f,L,W)=>{let K=o.createElement(f.tagName);S(f,L,W,K);let Y=L||f,he=W||f,ye=t==="local"?Y.isEqualNode(f)?he:Y:he.isEqualNode(f)?Y:he;for(let ve of ye.childNodes)K.appendChild(o.importNode(ve,!0));return d.set(K,{base:f,local:L,remote:W}),K}),C=e.cloneUnit||((f,L)=>{let W=o.importNode(f,!0);return d.set(W,{base:null,local:L==="local"?f:null,remote:L==="remote"?f:null}),W}),j=e.atomKey||(f=>nr(f,()=>!1)),D=(f,L)=>{let W=new Map;for(let K of f.atoms)if(e.remoteWins&&e.remoteWins(K.el)&&vn.has(K.el.tagName))W.set(K,"w"+K.el.tagName+"#"+(K.el.id||""));else if(!p)W.set(K,K.key);else if(f===m)W.set(K,"="+j(K.el));else{let Y=L.reverse.get(K.el),he=Y?P.get(Y):null;he?W.set(K,"="+j(he.el)):Y?W.set(K,"m"+j(K.el)):W.set(K,"="+j(K.el))}return K=>W.get(K)},B=D(m,null),w=D(c,n),y=D(g,s),$=e.certifiedOrigins?e.certifiedOrigins(m,c,g,B,w,y):null;if($?.fallback)return null;if(!$&&!e.prepared&&e.blocks){let f=Xt(),L=gs({base:m,side:c,baseOf:K=>n?.reverse?.get(K)||null,budget:f}),W=gs({base:m,side:g,baseOf:K=>s?.reverse?.get(K)||null,budget:f});(L.status==="ready"||W.status==="ready")&&($={local:L.status==="ready"?L:null,remote:W.status==="ready"?W:null})}let U=e.prepared||or(m,c,g,B,w,y,$,a),V=U.lines,Ne=U.baseTokens,Ae=U.localEdits,De=U.remoteEdits,oe=U.localMap,xe=U.remoteMap,$e=m.text.length,ae=f=>new Map(f.atoms.map(L=>[L.el,L])),k=ae(c),_=ae(g),re=(f,L,W)=>{let K=new Set;if(!p)return K;for(let Y of f.atoms){let he=P.get(L.reverse.get(Y.el));he&&W.bTo[he.i]<0&&K.add(he)}return K},Z=re(c,n,oe),Be=re(g,s,xe),Ke=f=>!jn(f,{...e,remoteWins:null}),Te=new Set;if(p)for(let f of m.atoms){if(!Ke(f.el))continue;let L=n.map.get(f.el)||null,W=s.map.get(f.el)||null,K=L&&!W?L:W&&!L?W:null;K&&(k.has(K)||_.has(K))&&!K.isEqualNode(f.el)&&Te.add(f)}let it=1,et=(f,L)=>({id:it++,tag:f,base:null,local:null,remote:null,rank:L}),mt=new Map,Ze=[];for(let f of m.marks){let L=et(f.tag,f.depth);L.block=!!f.block,L.base=f.el,L.baseMark=f,mt.set(f.el,L),Ze.push(L)}let ft=(f,L)=>{let W=-1,K=-1;for(let Y=f.from;Y<f.to;Y++){let he=L[Y];he>=0&&(W<0&&(W=he),K=he+1)}return W<0?null:[W,K]},Ct=(f,L,W,K)=>{for(let Y of f.marks){let he=W?W.reverse.get(Y.el):null;he&&W.identical.has(he)&&W.pairIdenticalChildren&&W.pairIdenticalChildren(he);let ye=he?mt.get(he):null;if(ye&&ye[L]&&(ye=null),!ye){let ve=ft(Y,K),We=0;if(ve)for(let Re of Ze){if(Re.tag!==Y.tag||Re[L]||!!Re.block!=!!Y.block)continue;let Fe=Math.min(ve[1],Re.baseMark.to)-Math.max(ve[0],Re.baseMark.from);(Fe>We||Fe===We&&Fe>0&&Math.abs(Re.rank-Y.depth)<Math.abs(ye.rank-Y.depth))&&(ye=Re,We=Fe)}}ye||(ye=et(Y.tag,Y.depth),ye.block=!!Y.block,ye.new=L),ye[L]=Y.el,ye[L+"Mark"]=Y,mt.set(Y.el,ye)}};Ct(c,"local",n,oe.toB),Ct(g,"remote",s,xe.toB);let Dt=f=>f.merged||f,Tt=f=>{let L=new Set;for(let W of f)W.block||L.add(mt.get(W.el));return L},Rt=new Map,jt=f=>{let L=Rt.get(f);return L||(L=Tt(f),Rt.set(f,L)),L},qt=(f,L)=>{let W=[],K=null;for(let Y=0;Y<$e;Y++){let he=L[Y];if(he<0){K&&W.push(K),K=null;continue}let ye=jt(m.stackAt[Y]),ve=jt(f.stackAt[he]),We=new Set,Re=new Set;for(let Fe of ve)ye.has(Fe)||We.add(Fe);for(let Fe of ye)ve.has(Fe)||Re.add(Fe);if(!We.size&&!Re.size){K&&W.push(K),K=null;continue}if(K&&Zs(K.added,We)&&Zs(K.removed,Re)){K.be=Y+1;continue}K&&W.push(K),K={bs:Y,be:Y+1,added:We,removed:Re}}return K&&W.push(K),W},un=qt(c,oe.bTo),Lt=qt(g,xe.bTo),Jt=f=>f.be>f.bs?[f.bs,f.be-1]:[f.bs-1,f.bs],F=(f,L)=>{if($e===0)return null;let[W,K]=Jt(f);for(let Y of L){if(Y.be<=W)continue;if(Y.bs>K)break;let he=Y.bs<=W&&K<Y.be;return he&&f.text===""&&Y.bs===f.bs&&Y.be===f.be?"straddle":he?Y:f.be>f.bs?"straddle":null}return null},ce=f=>f.bs===f.be,ge=(f,L,W=null)=>{let K=!1;for(let Y=f.bs;Y<f.be;Y++){let he=m.text[Y];if(he===Nt)K=!0;else if(!/\s/.test(he))return!1}for(let Y=f.ss;Y<f.se;Y++){let he=L.text[Y];if(he===Nt)K=!0;else if(!/\s/.test(he)){let ye=W&&e.scopeUnits&&ce(f)&&L.atomAt.get(Y);if(!ye||!Ke(ye.el)||W.ss!==W.se||W.bs>=W.be)return!1;for(let We=W.bs;We<W.be;We++)if(!/\s/.test(m.text[We]))return!1;let ve=L===c?1:2;if(!e.scopeUnits[ve].includes(ye.el)||(ve===1?n:s)?.reverse.has(ye.el))return!1;K=!0}}return K},Le=(f,L)=>f.bs<L.be&&L.bs<f.be,Me=(f,L)=>f.bs<=L.be&&L.bs<=f.be&&ce(f)!==ce(L),M=(f,L)=>m.text.slice(f.bs,f.be).includes(Nt)||L.text.slice(f.ss,f.se).includes(Nt),R=f=>{if(ce(f))return!1;let L=f.bs,W=f.be;for(;L>0&&/\s/.test(m.text[L-1]);)L--;for(;W<m.text.length&&/\s/.test(m.text[W]);)W++;return(L===0||m.text[L-1]===Nt)&&(W===m.text.length||m.text[W]===Nt)},z=(f,L)=>!M(f,L)&&!R(f),J=(f,L)=>Le(f,L)||Me(f,L)&&!(f.transferIn||f.transferOut||L.transferIn||L.transferOut)&&!(ge(f,c,L)&&z(L,g))&&!(ge(L,g,f)&&z(f,c)),ne=(f,L)=>{if(f.bs!==L.bs||f.be!==L.be||f.toks.length!==L.toks.length)return!1;let W=f.ss,K=L.ss;for(let Y=0;Y<f.toks.length;Y++){let he=f.toks[Y],ye=L.toks[Y];if(he.k!==ye.k||he.atom&&!c.atomAt.get(W).el.isEqualNode(g.atomAt.get(K).el))return!1;W+=he.len,K+=ye.len}return!0},je=(f,L,W,K)=>{for(let Y of m.atoms){if(Y.i<f.bs||Y.i>=f.be||K.has(Y)||Te.has(Y))continue;let he=L.bTo[Y.i],ye=he>=0?W.atomAt.get(he):null;if(ye&&!ye.el.isEqualNode(Y.el))return!0}return!1},Q=[],Oe=null,Ve=null,Ce=Ae.hunks,be=De.hunks,H=0,X=0,de=0,pe=0,se=0,ke=f=>{f>de&&(Q.push({src:"base",from:de,to:f,dL:pe,dR:se}),de=f)};for(;H<Ce.length||X<be.length;){let f=Ce[H],L=be[X],W=!!f&&(!L||f.bs<L.bs||f.bs===L.bs&&f.be<=L.be&&!L.lead);if(f&&L&&f.bs===L.bs&&ce(f)&&ce(L)){let Gt=ge(f,c),To=ge(L,g);Gt!==To&&(W=To)}let K=W?f:L,Y=W?L:f,he=!!Y&&ne(f,L),ye=!!Y&&(W?!!Ce[H+1]&&ne(Ce[H+1],L):!!be[X+1]&&ne(f,be[X+1])),ve=!!Y&&!he&&!ye&&($e===0||J(f,L)),We=ve,Re=F(K,W?Lt:un);if(Re==="straddle"&&(We=!0),!We&&K.be>K.bs&&(We=je(K,W?xe:oe,W?g:c,W?Z:Be)),!We&&he){ke(K.bs),Q.push({src:"both",lfrom:f.ss,rfrom:L.ss,len:K.text.length,owner:f.owner||L.owner||null,transfer:f.transferIn||L.transferIn||null}),de=K.be,pe+=K.text.length-(K.be-K.bs),se+=K.text.length-(K.be-K.bs),H++,X++;continue}if(!We){ke(K.bs),Q.push({src:W?"local":"remote",from:K.ss,to:K.se,inherit:Re&&Re!=="straddle"?Re:null,owner:K.owner||null,transfer:K.transferIn||null}),de=K.be,W?(pe+=K.text.length-(K.be-K.bs),H++):(se+=K.text.length-(K.be-K.bs),X++);continue}let Fe=K.bs,xt=K.be,ht=H,pt=X,Ft=Gt=>Gt.bs<xt&&Gt.be>Fe||ce(Gt)&&(Gt.bs===Fe||Gt.bs===xt);W?ht++:pt++,ve&&(Fe=Math.min(Fe,Y.bs),xt=Math.max(xt,Y.be),W?pt++:ht++);let Vt=!0;for(;Vt;){for(Vt=!1;ht<Ce.length&&Ft(Ce[ht]);)Fe=Math.min(Fe,Ce[ht].bs),xt=Math.max(xt,Ce[ht].be),ht++,Vt=!0;for(;pt<be.length&&Ft(be[pt]);)Fe=Math.min(Fe,be[pt].bs),xt=Math.max(xt,be[pt].be),pt++,Vt=!0}let gn=Fe+pe,cn=Fe+se,yn=xt-Fe,Sn=xt-Fe;for(let Gt=H;Gt<ht;Gt++)yn+=Ce[Gt].text.length-(Ce[Gt].be-Ce[Gt].bs);for(let Gt=X;Gt<pt;Gt++)Sn+=be[Gt].text.length-(be[Gt].be-be[Gt].bs);let Rn=gn+yn,Pn=cn+Sn;if(ke(Fe),H<ht&&X<pt&&!$&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!m.atoms.length&&!c.atoms.length&&!g.atoms.length&&!m.pins.length&&!c.pins.length&&!g.pins.length){Oe||={fb:m,fl:c,fr:g,ML:oe,MR:xe,byEl:mt,cache:[null,null]};let Gt=er(Oe,Ce,H,ht,be,X,pt,0,t),To=er(Oe,be,X,pt,Ce,H,ht,1,t);if(Gt===null!=(To===null)){let ts=Gt!==null,Ds=ts?Gt:To;if(Ds){Ve||=new Map;for(let ni of Ds)Ve.set(ni,ts?"local":"remote")}Q.push(ts?{src:"remote",from:cn,to:Pn}:{src:"local",from:gn,to:Rn}),de=xt,pe+=yn-(xt-Fe),se+=Sn-(xt-Fe),H=ht,X=pt;continue}}let on={kind:"text",node:e.node||null,base:lo(m,Fe,xt),local:lo(c,gn,Rn),remote:lo(g,cn,Pn),resolved:null,range:null,bs:Fe,be:xt,lss:gn,lse:Rn,rss:cn,rse:Pn},Xn=e.sourceRetentions?$s(e.sourceRetentions,e.scope?.base,m,c,g,t,on):t;on.resolved=Xn==="local"?on.local:Xn==="remote"?on.remote:on.local+on.remote,Xn!=="remote"&&Q.push({src:"local",from:gn,to:Rn,conflict:on}),Xn!=="local"&&Q.push({src:"remote",from:cn,to:Pn,conflict:on});let Jn={site:"inline",policy:Xn,fb:m,fl:c,fr:g,scope:e.scope||null,synthetic:!!e.synthetic,full:x,merged:a};h.push(Jn),b(on,Jn),de=xt,pe+=yn-(xt-Fe),se+=Sn-(xt-Fe),H=ht,X=pt}ke($e);let fe=m.text,G=[];if(Ae.respell.size||De.respell.size){let f=ao(Ne),L=[];for(let W=0;W<Ne.length;W++){let K=Ne[W].raw,Y=Ae.respell.get(W)??K,he=De.respell.get(W)??K;(Y!==K||he!==K)&&G.push([f[W],Y!==K&&he!==K?"both":Y!==K?"local":"remote"]),L.push(Y===he?Y:Y===K?he:he===K||t==="local"?Y:he)}fe=L.join("")}let ue="",Ie=[],Pe=[],He=[],Se=[];for(let f of Q){let L=ue.length;if(f.src==="base"){for(let W=f.from;W<f.to;W++)Ie.push(W),Pe.push(e.nativeTransfers?oe.bTo[W]:W+f.dL),He.push(e.nativeTransfers?xe.bTo[W]:W+f.dR),Se.push(f);ue+=fe.slice(f.from,f.to)}else if(f.src==="both"){for(let W=0;W<f.len;W++){let K=f.transfer&&(f.transfer.side==="remote"?f.rfrom+W:f.lfrom+W);Ie.push(f.transfer&&K>=f.transfer.ss&&K<f.transfer.se?f.transfer.bs+K-f.transfer.ss:-1),Pe.push(f.lfrom+W),He.push(f.rfrom+W),Se.push(f)}ue+=c.text.slice(f.lfrom,f.lfrom+f.len)}else{let W=f.src==="local"?c:g,K=f.transfer&&e.nativeTransfers.byOrigin[f.src==="local"?"remote":"local"].get(f.transfer.key);for(let Y=f.from;Y<f.to;Y++){let he=f.transfer&&Y>=f.transfer.ss&&Y<f.transfer.se?f.transfer.bs+Y-f.transfer.ss:-1,ye=he>=0&&(!K||K.destination===f.owner)?(f.src==="local"?xe:oe).bTo[he]:-1;Ie.push(he),Pe.push(f.src==="local"?Y:ye),He.push(f.src==="remote"?Y:ye),Se.push(f)}ue+=W.text.slice(f.from,f.to)}f.ms=L,f.me=ue.length,f.conflict&&(f.conflict.range||(f.conflict.range=[L,L]),f.conflict.range[1]=ue.length)}let Je=ue.length,nt=new Int32Array($e+1).fill(-1),ot=new Int32Array(c.text.length+1).fill(-1),Wt=new Int32Array(g.text.length+1).fill(-1);for(let f=0;f<Je;f++)Ie[f]>=0&&(nt[Ie[f]]=f),Pe[f]>=0&&(ot[Pe[f]]=f),He[f]>=0&&(Wt[He[f]]=f);let Ut=(f,L)=>{let W=-1,K=-1;for(let Y=f.from;Y<f.to;Y++){let he=L[Y];he>=0&&(W<0&&(W=he),K=he+1)}return W<0?null:[W,K]},I=[],q=[];for(let f of new Set(mt.values()))f.new==="local"?I.push(f):f.new==="remote"&&q.push(f);let te=(f,L)=>{f.remote=L.remote,f.remoteMark=L.remoteMark,f.new="both",L.merged=f,mt.set(L.remote,f)};if(I.length&&q.length){let f=e.idOf;for(let L of I){let W=f?f.local(L.local):null;if(!W)continue;let K=q.find(Y=>!Y.merged&&Y.tag===L.tag&&!!Y.block==!!L.block&&f.remote(Y.remote)===W);K&&te(L,K)}for(let L of I){if(L.remote)continue;let W=Ut(L.localMark,ot);if(W)for(let K of q){if(K.merged||K.tag!==L.tag||!!K.block!=!!L.block)continue;let Y=Ut(K.remoteMark,Wt);if(Y&&Math.min(W[1],Y[1])-Math.max(W[0],Y[0])>0){te(L,K);break}}}}Rt.clear();let me=f=>{for(let L of f)if(L.block)return Dt(mt.get(L.el));return null},we=m.marks.some(f=>f.block)||c.marks.some(f=>f.block)||g.marks.some(f=>f.block),ie=new Array(Je).fill(null),ee=new Set;if(e.nativeTransfers)for(let f=0;f<Je;f++){let L=Se[f].owner;ie[f]=L?Dt(mt.get(L)):Ie[f]>=0?me(m.stackAt[Ie[f]]):null}else if(we){let f=(Re,Fe,xt)=>{let ht=new Set([Re,Fe,xt]);ht.delete(null);let pt=[];for(let Vt of ht){let gn=Vt===Re,cn=Vt===Fe,yn=Vt===xt;(cn===yn?cn:cn===gn?yn:cn)&&pt.push(Vt)}if(pt.length<=1)return pt[0]||null;let Ft=t==="local"?Fe:xt;return pt.includes(Ft)?Ft:pt[0]},L=(Re,Fe)=>Fe>=0?me(Re.stackAt[Fe]):null,W=new Map;for(let Re=0;Re<Je;Re++){if(ue[Re]!==Nt)continue;let Fe=Ie[Re]>=0?L(m,Ie[Re]):null,xt=L(c,Pe[Re]),ht=L(g,He[Re]);W.set(Re,[Fe,Ie[Re]>=0?f(Fe,xt,ht):xt||ht])}let K=new Set([...W.values()].map(Re=>Re[1])),Y=Re=>Re!==Nt&&Re!==Dn&&!/\s/.test(Re),he=(Re,Fe)=>{let xt=Re;for(;xt<Fe&&!Y(ue[xt]);)xt++;return xt<Fe&&Ie[xt]>=0?L(m,Ie[xt]):null},ye=new Map,ve=0;for(let Re=0;Re<Je;Re++){if(ue[Re]!==Nt)continue;let[Fe,xt]=W.get(Re),ht=he(ve,Re),pt=xt,Ft=ye.get(pt)===pt&&ht===pt;pt&&ye.has(pt)&&!Ft&&Fe&&!ye.has(Fe)&&!K.has(Fe)&&(pt=Fe),pt&&!ye.has(pt)&&ye.set(pt,ht);for(let Vt=ve;Vt<=Re;Vt++)ie[Vt]=pt;ve=Re+1}let We=Re=>{for(let Fe=0;Fe<Re.text.length;Fe++)if(Y(Re.text[Fe])&&!L(Re,Fe))return!0;return!1};if(!We(m)&&!We(c)&&!We(g)){let Re=[],Fe=0;for(let ht=0;ht<Je;ht++)(ue[ht]===Nt||ht===Je-1)&&(Re.push([Fe,ht]),Fe=ht+1);let xt=new Set(ie);for(let ht=0;ht<Re.length;ht++){let[pt,Ft]=Re[ht];if(ie[Ft])continue;let Vt=pt;for(;Vt<=Ft&&!Y(ue[Vt]);)Vt++;if(Vt>Ft)continue;let gn=L(m,Ie[Vt]),cn=L(c,Pe[Vt]),yn=L(g,He[Vt]),Sn=f(gn,cn,yn)||cn||yn||gn;if(Sn&&!xt.has(Sn)){xt.add(Sn);for(let on=pt;on<=Ft;on++)ie[on]=Sn;continue}let Rn=ht>0&&ie[Re[ht-1][1]],Pn=ht+1<Re.length&&ie[Re[ht+1][1]];if(Rn)ee.add(Re[ht-1][1]);else if(Pn&&ue[Ft]===Nt)ee.add(Ft);else continue;for(let on=pt;on<=Ft;on++)ie[on]=Rn||Pn}}}let Ee=new Map,Ue=f=>{let L=Ee.get(f);if(L)return L;L=[1/0,-1/0];for(let[W,K]of[[f.baseMark,nt],[f.localMark,ot],[f.remoteMark,Wt]]){let Y=W&&Ut(W,K);Y&&(L[0]=Math.min(L[0],Y[0]),L[1]=Math.max(L[1],Y[1]))}return Ee.set(f,L),L},_e=(f,L,W)=>{let K=-1,Y=-1;for(let he=0;he<f.length;he++){let ye=mt.get(f[he].el);ye===L&&(K=he),ye===W&&(Y=he)}return K>=0&&Y>=0?K-Y:0},Ye=(f,L)=>[...f].sort((W,K)=>{for(let ye of L){let ve=_e(ye,W,K);if(ve)return ve}let Y=Ue(W),he=Ue(K);return Y[0]-he[0]||he[1]-Y[1]||W.rank-K.rank||W.id-K.id}),yt=new Map,gt=new Map,$t=e.nativeTransfers?[]:null,_t=f=>{if($t)return $t;let L=Ie[f],W=Pe[f],K=He[f],Y=Se[f];if(L>=0){let ht=m.stackAt[L],pt=c.stackAt[W],Ft=g.stackAt[K],Vt=yt.get(ht);Vt||yt.set(ht,Vt=new Map);let gn=Vt.get(pt);gn||Vt.set(pt,gn=new Map);let cn=gn.get(Ft);if(cn)return cn;let yn=jt(ht),Sn=jt(pt),Rn=jt(Ft),Pn=new Set;for(let on of new Set([...yn,...Sn,...Rn])){let Xn=yn.has(on),Jn=Sn.has(on),Gt=Rn.has(on);(Jn===Gt?Jn:Jn===Xn?Gt:Jn)&&Pn.add(on)}return cn=Ye(Pn,[pt,Ft,ht]),gn.set(Ft,cn),cn}if(Y.src==="both"){let ht=c.stackAt[W],pt=g.stackAt[K];return Ye(new Set([...jt(ht),...jt(pt)]),[ht,pt])}let ye=(Y.src==="local"?c:g).stackAt[Y.src==="local"?W:K];if(!Y.inherit)return Ye(jt(ye),[ye]);let ve=gt.get(Y);ve||gt.set(Y,ve=new Map);let We=ve.get(ye);if(We)return We;let Re=new Set(jt(ye));for(let ht of Y.inherit.added)Re.add(Dt(ht));for(let ht of Y.inherit.removed)Re.delete(Dt(ht));let Fe=Y.src==="local"?g:c,xt=(Y.src==="local"?xe.bTo:oe.bTo)[Y.inherit.bs];return We=Ye(Re,[ye,Fe.stackAt[xt]]),ve.set(ye,We),We},dn=new Int32Array(c.text.length+1);dn[c.text.length]=Je;for(let f=c.text.length-1;f>=0;f--)dn[f]=ot[f]>=0?ot[f]:dn[f+1];Li.caret+=c.text.length;let vt=f=>f<=0?0:(f>c.text.length&&(f=c.text.length),ot[f-1]>=0?ot[f-1]+1:dn[f]),dt=[],Qe=[],Mt=null,bt=[],Ht="",pn=-1,sn=f=>{Mt?Mt.appendChild(f):dt.push(f)},Zt=f=>{if(!Ht)return;let L=o.createTextNode(Ht);sn(L),Qe.push({node:L,ms:pn,me:f,local:[],u:bt.length?bt[bt.length-1].u:null}),Ht=""},wn=new Set,On=new Map,In=new Set,Lo=f=>{let L=o.createElement(f.tag);if(f.block&&Kn.add(L),!On.has(f)){On.set(f,L),S(f.base,f.local,f.remote,L),d.set(L,{base:f.base,local:f.local,remote:f.remote});let K=(ye,ve)=>p&&f[ve]&&ye.reverse.get(f[ve])?ve:null,Y=!f.base&&(K(n,"local")||K(s,"remote"));if(Y){let ye=Y==="local"?n.reverse.get(f.local):s.reverse.get(f.remote),ve=d.get(L);ve.local=ve.local||n.map.get(ye)||null,ve.remote=ve.remote||s.map.get(ye)||null,l.push({kind:"move",el:L,source:Y}),e.moveBuilt?.(ye,Y,f[Y],L)}else f.base||l.push({kind:"insert",el:L,source:f.local&&f.remote?"both":f.local?"local":"remote"});let he=d.get(L);he.local&&(In.has(he.local)?he.local=null:In.add(he.local))}else{let K=On.get(f);for(let Y of K.attributes)Y.name!=="id"&&Y.name!=="data-id"&&A(L,Y,Y.value);d.set(L,{base:null,local:null,remote:null})}sn(L),bt.push({u:f,el:L}),Mt=L},yo=new Set,Gn=new Map;for(let f of c.pins){let L=vt(f.i);Gn.has(L)||Gn.set(L,[]),Gn.get(L).push(f)}let Ro=f=>{let L=Gn.get(f);if(L){Zt(f);for(let W of L){let K=W.el.namespaceURI&&W.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(W.el.namespaceURI,W.el.tagName):o.createElement(W.el.tagName);d.set(K,{base:null,local:W.el,remote:null,pinned:!0}),yo.add(K),sn(K)}}},es=m.atoms.length||c.atoms.length||g.atoms.length,ko=f=>{if(!es)return null;let L=Ie[f]>=0?m.atomAt.get(Ie[f]):null,W=Pe[f]>=0?c.atomAt.get(Pe[f]):null,K=He[f]>=0?g.atomAt.get(He[f]):null;return L||W||K?{ab:L,al:W,ar:K}:null},Wn=(f,L,W)=>{let K=e.idOf;if(!K||!K.base)return!1;let Y=K.base(f.el);return Y!=null&&Y===K[W](L.el)},xo=(f,L,W,K,Y)=>{if(!f||!p)return null;let he=P.get(L.reverse.get(f.el))||null;return!he||he===K||(K?he.el.isEqualNode(K.el)&&!Wn(he,f,Y):W.bTo[he.i]>=0)?null:he},vo=(f,L)=>{if(!f||!p||!e.moveIn)return null;let W=L.reverse.get(f.el);return W&&!P.has(W)?W:null},le=(f,L)=>{let W=new Map;for(let K of f.atoms)W.set(L(K),(W.get(L(K))||0)+1);return W},ze=le(m,B),qe=le(c,w),st=le(g,y),At=f=>{let L=B(f);return ze.get(L)===1&&(qe.get(L)||0)<=1&&(st.get(L)||0)<=1},Ge=new Map,Xe=new Set,St=new Set,tt=new Set,wt=null;for(let f=0;f<Je;f++){let L=ko(f);if(!L)continue;let{ab:W,al:K,ar:Y}=L,he=xo(Y,s,xe,W,"remote"),ye=xo(K,n,oe,W,"local"),ve=W,We=null;if(he?(ve=he,We="remote"):ye&&(ve=ye,We="local"),ve){W&&ve!==W&&(wt||=new Map).set(W,We),Xe.has(ve)?Ge.set(f,{dup:ve.el}):(Xe.add(ve),Ge.set(f,{bk:ve,from:We,al:K,ar:Y}));continue}let Re=vo(Y,s),Fe=vo(K,n),xt=Re||Fe;if(xt){St.has(xt)?Ge.set(f,{dup:xt}):(St.add(xt),Ge.set(f,{moveIn:xt,side:Re?"remote":"local",sideEl:Re?Y.el:K.el}));continue}let ht=(Ft,Vt)=>Ft&&p&&P.get(Vt.reverse.get(Ft.el))||null,pt=ht(Y,s)||ht(K,n);if(pt&&(tt.add(pt),Se[f].conflict&&(At(pt)||Y&&(Y.el===pt.el||s.identityPaired?.has(pt.el))&&Wn(pt,Y,"remote")||K&&(K.el===pt.el||n.identityPaired?.has(pt.el))&&Wn(pt,K,"local")))){if(Xe.has(pt)){Ge.set(f,{dup:pt.el});continue}Xe.add(pt)}Ge.set(f,{al:K,ar:Y})}let lt=new Map,zt,Et,en=(f,L)=>{if(f[L]>=0)return f[L];for(let W=L-1;W>=0;W--)if(f[W]>=0)return f[W]+1;return 0};if(p)for(let f of m.atoms){if(Xe.has(f)||tt.has(f))continue;let L=n.map.get(f.el)||null,W=s.map.get(f.el)||null,K=L&&k.get(L),Y=W&&_.get(W);if(L&&!K||W&&!Y)continue;let he=!(K&&Y)&&Te.has(f);if(!he&&!(K&&Y&&(At(f)||wt?.has(f)||(K.el===f.el||n.identityPaired?.has(f.el))&&(Y.el===f.el||s.identityPaired?.has(f.el))&&Wn(f,K,"local")&&Wn(f,Y,"remote"))))continue;let ye=wt?.get(f),ve=t;if(ye){let ht=ye==="local"?g:c,pt=ye==="local"?s:n,Ft=ye==="local"?Et:zt;if(Ft===void 0){Ft=ht.atoms.length===m.atoms.length;for(let Vt=0;Ft&&Vt<m.atoms.length;Vt++)Ft=pt.reverse.get(ht.atoms[Vt].el)===m.atoms[Vt].el;ye==="local"?Et=Ft:zt=Ft}Ft&&(ve=ye)}let We=ve==="local"?[[K,ot],[Y,Wt]]:[[Y,Wt],[K,ot]],[Re,Fe]=We.find(([ht])=>ht),xt=en(Fe,Re.i);lt.has(xt)||lt.set(xt,[]),lt.get(xt).push({a:f,lt:L,rt:W,edited:he}),Xe.add(f)}if(p&&e.moveIn){let f=[[c,n,ot,"local"],[g,s,Wt,"remote"]];t!=="local"&&f.reverse();for(let[L,W,K,Y]of f)for(let he of L.atoms){let ye=vo(he,W);if(!ye||St.has(ye))continue;St.add(ye);let ve=en(K,he.i);lt.has(ve)||lt.set(ve,[]),lt.get(ve).push({move:ye,side:Y,sideEl:he.el})}}let Tn=f=>{let L=lt.get(f);if(L){if(Zt(f),L.some(W=>Ke(W.move?W.sideEl:W.a.el)))for(;bt.length;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;for(let{a:W,lt:K,rt:Y,edited:he,move:ye,side:ve,sideEl:We}of L){if(ye){let Fe=e.moveIn(ye,ve,We);Fe&&sn(Fe);continue}wn.add(W);let Re=N(W.el,K,Y);he&&(b({kind:"structure",el:Re,detail:"edit-beats-delete",base:W.el},{subject:W.el,deleted:K?"remote":"local"}),l.push({kind:"insert",el:Re,source:K?"local":"remote"})),sn(Re)}}},Kn=new Set,Po=r.length>u;for(let f=0;f<Je;f++){let L=ko(f),W=e.scopeUnits&&L&&(L.ab?.stack.some(ye=>ye.block)||L.al?.stack.some(ye=>ye.block)||L.ar?.stack.some(ye=>ye.block)),Y=!!L&&Ke((L.ab||L.al||L.ar).el)&&!W?[]:ie[f]?[ie[f],..._t(f)]:_t(f),he=0;for(;he<bt.length&&he<Y.length&&bt[he].u===Y[he];)he++;if(he<bt.length)for(Zt(f);bt.length>he;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;if(Ro(f),Tn(f),Y.length>bt.length)for(Zt(f);bt.length<Y.length;)Lo(Y[bt.length]);if(ue[f]===Nt){if(ee.has(f))continue;Zt(f);let ye=bt.length;for(;ye>0&&!bt[ye-1].u.block;)ye--;if(ye>0)for(Po&&a.breakOut.set(f,bt[ye-1].el);bt.length>=ye;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;continue}if(L){Zt(f);let ye=Ge.get(f),ve;if(ye.dup){b({kind:"structure",el:null,detail:"both-moved",base:ye.dup},{subject:ye.dup});continue}if(ye.moveIn){if(ve=e.moveIn(ye.moveIn,ye.side,ye.sideEl),!ve)continue}else if(ye.bk){let We=ye.bk;if(wn.add(We),We===L.ab)ve=N(We.el,ye.al.el,ye.ar.el);else{let Re=n.map.get(We.el)||null,Fe=s.map.get(We.el)||null;ve=N(We.el,Re,Fe),(!Re||!Fe)&&b({kind:"structure",el:null,detail:"move-beats-delete",base:We.el},{subject:We.el,deleted:Re?"remote":"local"}),l.push({kind:"move",el:ve,source:ye.from})}}else ye.al?(ve=C(ye.al.el,"local"),ye.ar&&(d.get(ve).remote=ye.ar.el),l.push({kind:"insert",el:ve,source:ye.ar?"both":"local"})):(ve=C(ye.ar.el,"remote"),l.push({kind:"insert",el:ve,source:"remote"}));Po&&a.atomOut.set(f,ve),sn(ve);continue}Ht||(pn=f),Ht+=ue[f]}if(Zt(Je),(Gn.has(Je)||lt.has(Je))&&(bt.length=0,Mt=null,Ro(Je),Tn(Je)),Je===0&&(c.placeholder||g.placeholder||m.placeholder)){let f=o.createElement("br");d.set(f,{base:m.placeholder,local:c.placeholder,remote:g.placeholder}),dt.push(f)}let at=0,rt=f=>{for(;at>0&&Qe[at-1].me>=f;)at--;for(;at<Qe.length&&Qe[at].me<f;)at++;let L=Qe[at];if(!L)return Qe[Qe.length-1]||null;let W=Qe[at+1];return L.me===f&&W&&W.ms===f?W:L},Pt=new Map,ct={},It=(f,L,W)=>{let K=rt(f)||(W?ct:null);if(!K)return;let Y=Pt.get(K)||{l:!1,r:!1};L!=="remote"&&(Y.l=!0),L!=="local"&&(Y.r=!0),Pt.set(K,Y)},tn=f=>{if(f.conflict)return!0;let L=f.src==="local"?c.text:f.src==="remote"?g.text:"";for(let W=f.from;W<f.to;W++)if(L[W]!==Dn&&L[W]!==Nt)return!0;return!1};for(let f of Q)f.src!=="base"&&It(f.ms,f.conflict?"both":f.src,tn(f));for(let[f,L]of G)nt[f]>=0&&It(nt[f],L);for(let f of Qe.length?Qe:[ct]){let L=Pt.get(f);L&&l.push({kind:"text",node:f.node||null,source:L.l&&L.r?"both":L.l?"local":"remote"})}for(let f of Ze){if(On.has(f))continue;let L=!f.local&&!(p&&n.map.get(f.base)),W=!f.remote&&!(p&&s.map.get(f.base));!L&&!W||l.push({kind:"remove",source:L&&W?"both":L?"local":"remote",base:f.base})}if(Ve)for(let[f,L]of Ve)On.has(f)&&b({kind:"structure",el:On.get(f),detail:"edit-beats-delete",base:f.base},{subject:f.base,deleted:L});let Bt=(f,L,W)=>{if(L<=f)return!1;for(let K=f;K<L;K++)if(W[K]>=0)return!1;return!0};for(let f of Ze)for(let L of["local","remote"]){let W=f[L+"Mark"],K=f.baseMark;if(!W)continue;let Y=L==="local"?oe:xe;if(!Bt(K.from,K.to,Y.bTo)||!Bt(W.from,W.to,Y.toB))continue;let he=(L==="local"?Ce:be).find(ye=>ye.ss<=W.from&&W.from<ye.se);he&&(he.be<=K.from||he.bs>=K.to)&&l.push({kind:"move",el:On.get(f)||null,source:L})}let rn=f=>{let L=mt.get(f.node.parentNode);return L?Dt(L):null};for(let f of c.nodes){let L=-1;for(let K=f.s;K<f.e;K++)if(ot[K]>=0){L=ot[K];break}let W;if(L>=0)W=rt(L);else{let K=vt(f.s),Y=rn(f);W=Qe.find(he=>he.u===Y&&he.me>=K)||Qe.filter(he=>he.u===Y).pop()}W&&W.local.push(f)}let Yt=new Map,Ot=Qe[Qe.length-1]||null,kt=0;for(let f of c.nodes){let L=null;for(let W=f.s;W<=f.e;W++){let K=vt(W);for(;kt>0&&Qe[kt-1].me>=K;)kt--;for(;kt<Qe.length&&Qe[kt].me<K;)kt++;let Y=ye=>ye&&K>=ye.ms&&K<=ye.me&&(K<ye.me||W===f.e||ye===L),he=Y(Qe[kt])?Qe[kt]:Y(Qe[kt+1])?Qe[kt+1]:Qe[kt]||Ot;if(!he)break;if(L===he){let ye=Yt.get(he);ye[ye.length-1].to=W-f.s;continue}L=he,Yt.has(he)||Yt.set(he,[]),Yt.get(he).push({node:f.node,from:W-f.s,to:W-f.s,flatStart:f.s})}}for(let f of Qe){let L=f.local,W=!1;for(let ye of L)for(let ve=ye.s;ve<ye.e&&!W;ve++)(ot[ve]<f.ms||ot[ve]>=f.me)&&(W=!0);d.set(f.node,{base:null,local:L.map(ye=>ye.node),remote:null,caret:Yt.get(f)||[],partial:W});let K=f.ms,Y=f.me-f.ms,he=ye=>{let ve=0,We=-1;for(let Re of L){let Fe=Re.e-Re.s;if(ye<=ve+Fe){We=Re.s+(ye-ve);break}ve+=Fe}return We<0&&(We=L.length?L[L.length-1].e:0),Math.max(0,Math.min(vt(We)-K,Y))};he.flat=ye=>Math.max(0,Math.min(vt(ye)-K,Y)),i.set(f.node,he)}function Kt(){if(!c.text.includes(Nt))return[{flatLocal:c.text,localNodes:c.nodes,textNodes:Qe,lToM:ot,mapLocal:vt}];let f=[],L=0,W=0;for(let K=0;K<=c.text.length;K++){if(K<c.text.length&&c.text[K]!==Nt)continue;let Y=L,he=K;if(he>Y){let ye=[];for(;W<c.nodes.length&&c.nodes[W].e<=Y;)W++;for(let ve=W;ve<c.nodes.length&&c.nodes[ve].s<he;ve++){let We=c.nodes[ve],Re=Math.max(We.s,Y),Fe=Math.min(We.e,he);Re<Fe&&ye.push({node:We.node,s:Re-Y,e:Fe-Y})}f.push({flatLocal:c.text.slice(Y,he),localNodes:ye,textNodes:Qe,lToM:ot.subarray?ot.subarray(Y,he+1):ot.slice(Y,he+1),mapLocal:ve=>vt(Y+Math.max(0,Math.min(ve,he-Y)))})}L=K+1}return f}let nn={...e,blocks:Kn,ignored:f=>yo.has(f)||(e.ignored?e.ignored(f):!1)},Vn=e.ignoreAttribute||(()=>!1),Yn=Gs(ln(dt,nn),Vn)!==Gs(g,Vn);if(h.length){let f=L=>{let W=d.get(L);return W&&W.unchanged?W.remote:null};a.text=ue,a.textNodes=Qe,a.out=ln(dt,{...nn,via:f})}let no=null;if(e.scopeUnits){no=new Map;let f=new Set(dt),L=ve=>{for(;ve&&!f.has(ve);)ve=ve.parentNode;return ve},W=e.scopeUnits.map(ve=>{let We=new Map;for(let Re of ve)if(Re.nodeType===1)We.set(Re,Re);else for(let Fe of Re.nodes)We.set(Fe,Re);return We}),K=(ve,We)=>{for(;ve&&!We.has(ve);)ve=ve.parentNode;return ve?We.get(ve):null},Y=[m,c,g].map((ve,We)=>{let Re=new Array(ve.text.length);for(let Fe of ve.nodes){let xt=K(Fe.node,W[We]);xt&&Re.fill(xt,Fe.s,Fe.e)}for(let Fe of ve.atoms)Re[Fe.i]=K(Fe.el,W[We]);return Re}),he=(ve,We)=>{if(!ve||!We)return;let Re=no.get(ve);Re||no.set(ve,Re=new Set),Re.add(We)};for(let ve of dt){let We=d.get(ve);We&&(he(K(We.base,W[0]),ve),he(K(We.local,W[1]),ve),he(K(We.remote,W[2]),ve))}for(let ve of Qe){let We=L(ve.node);for(let Re=ve.ms;Re<ve.me;Re++)he(Y[0][Ie[Re]],We),he(Y[1][Pe[Re]],We),he(Y[2][He[Re]],We)}let ye=new Map(dt.map((ve,We)=>[ve,We]));for(let[ve,We]of no)no.set(ve,Array.from(We).sort((Re,Fe)=>ye.get(Re)-ye.get(Fe)))}return{unitOutputs:no,nodes:dt,text:ue,textNodes:Qe,localDiverged:Yn,mapLocal:vt,conflicts:r.slice(u),granularity:V?"line":"word",segments:Kt(),localHunks:Ce,remoteHunks:be,lToM:ot}}var xs=Symbol("lost");function rr(){return{links:new Map,removed:new Set,consumed:new Set,link(e,o){this.links.set(e,o)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let o of e.nodes)this.removed.add(o)},consume(e){for(let o of e)this.consumed.add(o)}}}var sr=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function ir({locals:e,rec:o,root:t,provenance:n,segments:s,ignored:d}){let i=new Map,r=(T,x)=>{let A=i.get(T);A||i.set(T,A=new Set),A.add(x)},l=new Set,u=new Set;for(let T of s){let x=T.textNodes;for(let A of x)l.add(A.node);for(let A of T.localNodes){u.add(A.node);let E=0,S=null;for(let N=A.s;N<A.e;N++){let C=T.lToM[N];if(C<0)continue;for((!x[E]||C<x[E].ms)&&(E=0);E<x.length&&x[E].me<=C;)E++;let j=x[E]&&x[E].ms<=C?x[E].node:xs;j!==S&&r(A.node,j),S=j}}}let b=new Set,a=new Map,h=new Set;(function T(x){b.add(x);let A=n.get(x);if(x.nodeType===1)A&&A.local&&A.local.nodeType===1&&(r(A.local,x),A.unchanged&&h.add(A.local)),x.tagName==="TEMPLATE"&&x.content&&a.set(x.content,x);else if(A&&Array.isArray(A.local)&&!l.has(x))for(let E of A.local)r(E,x);for(let E=sr(x).firstChild;E;E=E.nextSibling)T(E)})(t);let p=new Set;for(let[T,x]of o.links)r(T,x),p.add(T);let v=T=>{let x=T.parentNode;return x&&x.nodeType===11?a.get(x)||null:x},O=(T,x)=>{for(let A=T;A;A=v(A))if(A===x)return!0;return!1},m=T=>o.removed.has(T)||o.consumed.has(T),c=T=>{for(let x=T.parentNode;x&&x.nodeType===1;x=x.parentNode){if(h.has(x))return"kept";if(m(x))return"decided";if(i.has(x))return null}return null},g=new Map;for(let T of e)g.set(T,P(T));return g;function P(T){let x=i.get(T);if(x&&(x.size!==1||x.has(xs)))return{kind:"unknown",reason:"several-outputs"};let A=x?x.values().next().value:null;if(A&&(A.nodeType!==1||!b.has(A)))return{kind:"unknown",reason:"output-not-placed"};if(!A){let C=m(T)?"decided":c(T);if(C==="kept")return{kind:"untouched"};if(C!=="decided")return{kind:"unknown",reason:"unmapped"}}let E=[],S=N(T,!!A&&(h.has(T)||p.has(T)),!A||m(T));if(S)return{kind:"unknown",reason:S};return A?{kind:"single",output:A,owned:E,carried:p.has(T)}:{kind:"removed"};function N(C,j,D){for(let B=sr(C).firstChild;B;B=B.nextSibling){if(B.nodeType===1?d(B):B.nodeType!==3&&B.nodeType!==8)continue;let w=i.get(B);if(w)for(let y of w){if(y===xs||!b.has(y))return"output-not-placed";if(!A)return"survives-elsewhere";if(!O(y,A))return"escaped";E.push(y)}else if(!j&&!D&&!m(B)&&!u.has(B))return"unmapped";if(B.nodeType===1){let y=N(B,j||h.has(B)||p.has(B),D||m(B));if(y)return y}}return null}}}function lr(e,o){if(!o)return!1;let t=o.nodeType===1&&o.tagName==="TEMPLATE"?[o,...o.querySelectorAll("template")]:[...o.querySelectorAll("template")];for(let n of t)if(n.content.contains(e)||lr(e,n.content))return!0;return!1}function ar(e,o){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let t=[],n=new Set;for(let s of Array.from(e.elements)){if(!s||s.nodeType!==1||s.ownerDocument!==o&&!lr(s,o.documentElement))throw new TypeError("lineage.elements must be elements of the live document");n.has(s)||(n.add(s),t.push(s))}return t}var cr=new WeakMap;function fr(e){let o=new Map;for(let t of e){let n=[],s=!1;(function d(i){i.nodeType===1&&i.namespaceURI==="http://www.w3.org/1999/xhtml"&&i.localName==="template"&&(s=!0);for(let r=i.firstChild;r;r=r.nextSibling)n.push(r),r.nodeType===1&&d(r)})(t),o.set(t,{nodes:n,opaque:s})}return o}function vs(e,o,t){if(e.lineage===void 0)return t(e);if(!o||o.nodeType!==1)throw new TypeError("lineage requires an element root");let n=e.lineage,s=ar(n,o.ownerDocument),d=!1,i={...e,lineage:{elements:s,onResult(r,l){if(!d)return d=!0,n.onResult(r,l)}}};try{return cr.set(i.lineage,fr(s)),t(i)}catch(r){if(!d){d=!0;try{n.onResult({version:1,root:o,status:"incomplete",entries:s.map(Nn)},null)}catch{}}throw r}}function Ts(e,{liveRoot:o,localRoot:t,toLive:n}){let s=ar(e,o.ownerDocument),d=u=>u===o||o.contains(u),i=new Map,r=new Set(s.filter(d));if(r.size&&t===o)for(let u of r)i.set(u,u);else r.size&&(function u(b){let a=n(b);r.delete(a)&&i.set(a,b);for(let h=b.firstElementChild;h&&r.size;h=h.nextElementSibling)u(h)})(t);return{spec:e,watched:s,root:o,locals:Array.from(new Set(i.values())),before:cr.get(e)||fr(s),delivered:!1,result:null,finish(u,b){return this.resolve=b,this.plans=u,this.result={version:1,root:this.root,status:"complete",entries:s.map(a=>Ui(a,i.get(a),u,b,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(u,b){this.root=b;let a=this.resolve,h=v=>{let O=a(v);return O===u?b:O};return this.finish(this.plans,h)},deliver(u){this.delivered||(this.delivered=!0,e.onResult(this.result,u))}}}var Nn=e=>({from:e,to:[],kind:"unknown",complete:!1});function Ui(e,o,t,n,s){let d=s.root,i=h=>!!h&&(h===d||d.contains(h)),r=o&&t?t.get(o):null;if(!r||r.kind==="unknown")return Nn(e);let l=s.before.get(e);if(!l||l.opaque)return Nn(e);let u=l.nodes,b=h=>i(h)||!!(h&&h.ownerDocument===d.ownerDocument&&d.ownerDocument.documentElement?.contains(h));if(r.kind==="untouched"){if(!i(e))return Nn(e);for(let h of u)if(b(h)&&!e.contains(h))return Nn(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(r.kind==="removed")return b(e)||u.some(b)?Nn(e):{from:e,to:[],kind:"removed",complete:!0};let a=n(r.output);if(!a||a.nodeType!==1||!i(a)||a!==e&&b(e))return Nn(e);for(let h of u)if(b(h)&&!a.contains(h))return Nn(e);for(let h of r.owned){let p=n(h),v=Array.isArray(p)?p:[p];for(let O of v)if(!O||!i(O)||!a.contains(O))return Nn(e)}return r.carried&&!ur(a,r.output,n)?Nn(e):{from:e,to:[a],kind:a===e?"retained":"replaced",complete:!0}}function ur(e,o,t){for(let n=o.firstChild;n;n=n.nextSibling){let s=t(n),d=Array.isArray(s)?s:[s];for(let i of d)if(!i||!e.contains(i))return!1;if(n.nodeType===1&&!ur(e,n,t))return!1}return!0}function No(e,o,t){let n=Ts(e,{liveRoot:o,localRoot:o,toLive:s=>s});return n.result={version:1,root:o,status:"complete",entries:n.watched.map(s=>Nn(s))},t.lineage=n.result,n}function dr(e,o,t,n,s){if(!s(e.length*8+1))return null;let d=0,i=o===0,r=!1;for(let l of fn(e,n)){if(!s(1))return null;if(d+=l.len,d===o&&(i=!0),d===t&&(r=!0),d>=t)break}return i&&r}function Vi(e,o,t,n,s,d,i){if(!i(o.length*2))return!1;let r=new Map,l=new Map,u=new Set;for(let b of o){let a=b.bs<b.be,h=a?t[b.ownerIndex].text.base:t[b.ownerIndex].text[e],p=a?b.bs:b.ss,v=a?b.be:b.se;if(!i((v-p)*4+1))return!1;for(;p<v&&/\s/.test(h[p]);)p++;for(;v>p&&/\s/.test(h[v-1]);)v--;if(p===v)continue;let O=h.slice(p,v),m=a?r:l;a&&b.text&&u.add(O),m.has(O)?m.set(O,null):m.set(O,{h:b,from:p,to:v})}for(let b of n){if(!i(1))return!1;if(b.side!==e)continue;let a=b.deletion,h=t[a.ownerIndex].text.base;if(!i((a.be-a.bs)*3)||u.has(h.slice(a.bs,a.be).trim()))return!1}for(let[b,a]of r){if(!i(b.length+1))return!1;let h=l.get(b);if(!a||!h)continue;let p=a.h,v=h.h;if(!p.text||p.transferOut||v.transferIn||p.owner===v.owner)continue;let O=t[p.ownerIndex],m=t[v.ownerIndex];if(!i(O.text.base.length))return!1;if(!/\S/.test(O.text.base.slice(0,p.bs)+O.text.base.slice(p.be)))continue;let c=dr(O.text.base,a.from,a.to,d,i),g=dr(m.text[e],h.from,h.to,d,i);if(c===null||g===null)return!1;if(!c||!g)continue;let P=`${O.index}:${a.from}:${a.to}`,T={key:P,side:e,source:p.owner,destination:v.owner,deletion:p,insertion:v,sourceOffset:a.from-p.bs,targetOffset:h.from-v.ss,length:a.to-a.from};p.transferOut=T,v.transferIn=T,s[e].set(P,T),n.push(T)}return!0}function hr({base:e,local:o,remote:t,localTwin:n,remoteTwin:s,eligible:d,nodes:i,budget:r=Xt(2e4*32)}){let l=S=>S>r.remaining?!1:(r.remaining-=S,r.nativeSteps=(r.nativeSteps||0)+S,!0);if(e.length<2||o.length!==e.length||t.length!==e.length||!l(e.length*12))return null;for(let[S,N]of[["base",e],["local",o],["remote",t]]){let C=i[S];if(C.length!==N.length||C.some((j,D)=>j!==N[D]))return null}let u=[],b=0;for(let S=0;S<e.length;S++){let N=e[S],C=o[S],j=t[S];if(n(N)!==C||s(N)!==j)return null;let D={};for(let[B,w]of[["base",N],["local",C],["remote",j]]){if(!d(w)||w.tagName!==N.tagName||w.namespaceURI!==N.namespaceURI||!l(w.childNodes.length+1))return null;let y="";for(let $ of w.childNodes){if($.nodeType!==3||!l($.data.length*4+1))return null;y+=$.data}if(y.includes(Nt)||(b+=y.length+1,b>2e4))return null;D[B]=y}u.push({base:N,local:C,remote:j,index:S,text:D})}let a=u.every(S=>xn(S.text.base,S.text.local,S.text.remote)),h={local:[],remote:[]};for(let S of u){S.hunks={local:[],remote:[]};for(let N of["local","remote"]){let C=S.text.base,j=S.text[N];if(C===j)continue;let D=C.length+j.length+4,B=D*8;if(!l(B))return null;let w=Math.floor(r.remaining/8),y=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(D*D+w)-D)/2)));if(y<1||!l(4*(y+1)*(D+y+1)))return null;let $=0;for(let U of _n(C,j,y)){if(!l(U.text.length+1))return null;let V=U.bs+$,Ne={...U,ss:V,se:V+U.text.length,toks:fn(U.text,a),owner:S.base,ownerIndex:S.index};S.hunks[N].push(Ne),h[N].push(Ne),$+=U.text.length-(U.be-U.bs)}}}let p=[],v={local:new Map,remote:new Map};for(let S of["local","remote"]){let N=new Map,C=new Map,j=!1,D=(B,w,y)=>{B.has(w)?B.set(w,null):B.set(w,y)};for(let B of h[S]){if(!l(1))return null;let w=u[B.ownerIndex].text.base;if(B.bs<B.be&&B.text===""){let y=w.slice(B.bs,B.be);if(!l(y.length*2))return null;/\S/.test(y)&&D(N,y,B)}else if(B.bs===B.be&&/\S/.test(B.text)){if(!l(B.text.length*2))return null;D(C,B.text,B)}else B.bs<B.be&&(j=!0)}for(let[B,w]of N){if(!l(B.length+1))return null;let y=C.get(B);if(!w||!y||w.owner===y.owner)continue;let $=u[w.ownerIndex];if(!l($.text.base.length))return null;if(!/\S/.test($.text.base.slice(0,w.bs)+$.text.base.slice(w.be)))continue;let U=`${$.index}:${w.bs}:${w.be}`,V={key:U,side:S,source:w.owner,destination:y.owner,deletion:w,insertion:y};w.transferOut=V,y.transferIn=V,v[S].set(U,V),p.push(V)}if(j&&C.size&&!Vi(S,h[S],u,p,v,a,l))return null}if(!p.length)return null;let O=(S,N)=>S.bs<N.be&&N.bs<S.be,m=S=>S.bs===S.be,c=(S,N)=>S.bs<=N.be&&N.bs<=S.be&&m(S)!==m(N),g=(S,N)=>S.bs===N.bs&&S.be===N.be&&S.text===N.text,P=(S,N)=>!!(S.transferIn||S.transferOut&&(!S.text||N.bs===S.be&&/\s/.test(N.text[0])||N.bs===S.bs&&/\s/.test(N.text[N.text.length-1])));for(let S of p){let N=S.side==="local"?"remote":"local",C=u[S.deletion.ownerIndex];for(let j of C.hunks[N])if(!l(1)||O(S.deletion,j)&&j.transferOut?.key!==S.key)return null}for(let S of u)for(let N of S.hunks.local)for(let C of S.hunks.remote){if(!l(1))return null;if(g(N,C)){if(N.transferIn?.key!==C.transferIn?.key)return null;continue}if(O(N,C)||c(N,C)&&!P(N,C)&&!P(C,N))return null}if(!l(b*8))return null;let T=new Set([...e,...o,...t]),x={base:ln(e,{blocks:T}),local:ln(o,{blocks:T}),remote:ln(t,{blocks:T})},A={};for(let S of["base","local","remote"]){let N=x[S];if(N.atoms.length||N.pins.length)return null;A[S]=new Map(N.marks.filter(C=>C.block).map(C=>[C.el,C.from]))}for(let S of u){let N=A.base.get(S.base);if(N===void 0)return null;for(let C of["local","remote"]){let j=A[C].get(S[C]);if(j===void 0)return null;for(let D of S.hunks[C])D.bs+=N,D.be+=N,D.ss+=j,D.se+=j}}for(let S of p)S.bs=S.deletion.bs+(S.sourceOffset||0),S.be=S.length===void 0?S.deletion.be:S.bs+S.length,S.ss=S.insertion.ss+(S.targetOffset||0),S.se=S.length===void 0?S.insertion.se:S.ss+S.length;let E={};for(let S of["local","remote"]){let N=0,C=0,j=[];for(let B of h[S]){if(!l(1))return null;B.bs>N&&j.push({from:N,to:B.bs,target:C}),N=B.be,C=B.se}N<x.base.text.length&&j.push({from:N,to:x.base.text.length,target:C});let D=p.filter(B=>B.side===S).map(B=>({from:B.bs,to:B.be,target:B.ss,destination:B.destination}));if(E[S]=Bn({base:x.base,side:x[S],retained:j,transfers:D,budget:r}),E[S].status!=="ready")return null}return l(x.base.text.length)?{owners:u,blocks:T,transfers:p,byOrigin:v,budget:r,prepared:{base:x.base,local:x.local,remote:x.remote,lines:!1,baseTokens:fn(x.base.text,a),localEdits:{hunks:h.local,respell:new Map},remoteEdits:{hunks:h.remote,respell:new Map},localMap:E.local,remoteMap:E.remote,full:null}}:null}var Ss=/\S/;function pr({certificates:e,scopes:o,views:t,eligible:n,baseId:s,limit:d=2e4*32}){let i=Xt(d),r=Symbol(),l=[],u=a=>{if(a>i.remaining)throw r;i.remaining-=a},b=(a,h=null)=>{if(u(1),!a||a.nodeType!==1||a.parentNode?.nodeType!==1||!n(a))return null;for(let O=a.parentNode;O;O=O.parentNode)if(u(1),O.nodeType===11)return null;let p="",v=0;for(let O of a.childNodes){if(u(1),O.nodeType!==3)return null;if(u(O.data.length*4+1),h){let m=h.flat.nodes[v++];if(!m||m.node!==O||m.s!==p.length||m.e!==p.length+O.data.length)return null}p+=O.data}return u(p.length*3+1),h&&(h.flat.atoms.length||h.flat.pins?.length||v!==h.flat.nodes.length||h.flat.text!==p)?null:Ss.test(p)?p:null};try{u(o[0].length+o[1].length+o[2].length+e.length);let a=o.map(p=>new Set(p)),h=new Map;for(let p of e){u(1);let v=h.get(p.source);v||h.set(p.source,v=[]),v.push(p)}for(let p of h.values()){let v=[null,null],O=[];for(let m of p){u(1);let{source:c,target:g,side:P,models:T,runs:x}=m;if(P!==0&&P!==1||!a[0].has(c)||!a[P+1].has(g))continue;let{V:A,A:E,idOf:S}=t[P],N=t[1-P],C=A.twin(c),j=N.V.twin(c),D=A.baseOf(g);if(!C||!j||!D||D===c||!a[0].has(D)||!a[P+1].has(C)||!a[2-P].has(j)||E.map.get(c)!==C||E.reverse.get(C)!==c||N.A.map.get(c)!==j||N.A.reverse.get(j)!==c||E.map.get(D)!==g||E.reverse.get(g)!==D||g.parentNode!==C.parentNode||D.parentNode!==c.parentNode||c.tagName!==C.tagName||c.tagName!==j.tagName||s(c)!==S(C)||s(c)!==N.idOf(j)||s(D)!==S(g))continue;let B=T.get(c),w=T.get(g);if(!B||!w)continue;let y=b(c,B),$=b(g,w),U=b(C),V=b(j);if(u((y?.length||0)+(V?.length||0)),y===null||$===null||U===null||V===null||V===y)continue;let Ne=x.length>0,Ae=!1;for(let oe of x){if(u(1),oe.source!==c||oe.target!==g||!Number.isInteger(oe.from)||!Number.isInteger(oe.to)||!Number.isInteger(oe.targetFrom)||oe.from<0||oe.to<=oe.from||oe.to>y.length||oe.targetFrom<0||oe.targetFrom+oe.to-oe.from>$.length){Ne=!1;break}u((oe.to-oe.from)*3);for(let xe=oe.from;xe<oe.to;xe++){if(y[xe]!==$[oe.targetFrom+xe-oe.from]){Ne=!1;break}Ss.test(y[xe])&&(Ae=!0)}if(!Ne)break}if(!Ne||!Ae)continue;let De=v[P];De||(u(y.length),De=v[P]={source:c,side:P,flat:B.flat,before:y,covered:new Uint8Array(y.length)});for(let oe of x)u(oe.to-oe.from),De.covered.fill(1,oe.from,oe.to)}for(let m of v){if(!m)continue;let{source:c,side:g,flat:P,before:T,covered:x}=m;u(T.length*3+1);let A=-1,E=-1;for(let S=0;S<=T.length;S++)S<T.length&&x[S]?(A<0&&(A=S),E=S+1):(S===T.length||Ss.test(T[S]))&&A>=0&&(O.push({source:c,side:g,flat:P,from:A,to:E}),A=E=-1)}u(O.length),l.push(...O)}}catch(a){if(a!==r)throw a}return{records:l,budget:i}}var Hi="http://www.w3.org/1999/xhtml";function Wi(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function mn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Hi}function Ki(e){let o=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return o==="application/json"||o.endsWith("+json")}function _o(e,o){let t=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let s=t;try{let d=new URL(t,o);s=d.origin+d.pathname+d.search}catch{}return"script|src|"+n+"|"+s}return"script|inline|"+n+"|"+Wi(e.textContent.trim())}var Fi={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function fo(e,o=[],t=!1){if(!mn(e)||e.hasAttribute("src"))return null;let n=[Fi,...o];for(let s=0;s<n.length;s++){let d=n[s];if(!d.match(e))continue;if(!Ki(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let i=d.identity(e);return i==null||i===""?null:{key:s+":"+i,raw:i,recognizer:d}}return null}function mr(e,o,t){let n=new Set,s=d=>{mn(d)&&!o(d)&&n.add(_o(d,t))};s(e);for(let d of e.querySelectorAll("script"))s(d);return n}function Ao(e,o){let t=o.createElement("div");t.innerHTML="<script><\/script>";let n=t.firstChild;for(let s of e.attributes)n.setAttribute(s.name,s.value);return n.textContent=e.textContent,n}function gr(e,o,t){let n=[],s=[],d=new Map,i=t.trackRecovery?new Set:null,r=Array.from(e.querySelectorAll("script"));mn(e)&&r.unshift(e);for(let l of r){if(!mn(l)||t.ignored(l)||t.skip.has(l)||o.has(_o(l,t.baseURI)))continue;let u=l.ownerDocument.createElement("script");for(let b of l.attributes)u.setAttribute(b.name,b.value);if(u.textContent=l.textContent,t.beforeNodeAdded(u)===!1){i?.add(l);continue}u.hasAttribute("src")&&s.push(new Promise(b=>{u.addEventListener("load",()=>b()),u.addEventListener("error",()=>b())})),l.replaceWith(u),d.set(l,u),t.afterNodeAdded(u),n.push(u)}return{executed:n,loads:s,swapped:d,vetoed:i}}function qi(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function _i(e,o){try{let t=new URL(e,o);return t.origin+t.pathname+t.search}catch{return e}}function br(e,o){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return _o(e,o);if(t==="LINK"){let n=e.getAttribute("href");return n?"link|"+(e.getAttribute("rel")||"")+"|"+_i(n,o):e.outerHTML}if(t==="META"){for(let n of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(n))return"meta|"+n+"="+e.getAttribute(n);return e.outerHTML}return t==="STYLE"?"style|"+qi(e.textContent):e.outerHTML}function Ns(e,o){for(;;){for(;o<e.length&&/\s/.test(e[o]);)o++;if(e[o]==="/"&&e[o+1]==="/"){for(;o<e.length&&e[o]!==`
|
|
4
|
+
`;)o++;continue}if(e[o]==="/"&&e[o+1]==="*"){let t=e.indexOf("*/",o+2);if(t===-1)return e.length;o=t+2;continue}return o}}function wr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(o,t)=>t.length%2===0?t+'\\"':o)}var zi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,$i=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function zo(e){try{return JSON.parse(e)}catch{return JSON.parse(Gi(e))}}function Gi(e){let o="",t=0,n=(s,d)=>{throw new Error(`Invalid relaxed JSON: ${s} at position ${d}`)};for(;t<e.length&&(t=Ns(e,t),!(t>=e.length));){let s=e[t];if("{}[]:".includes(s)){o+=s,t++;continue}if(s===","){let r=Ns(e,t+1);if(e[r]==="}"||e[r]==="]"){t++;continue}o+=s,t++;continue}if(s==='"'||s==="'"){let r=t+1;for(;r<e.length&&e[r]!==s;)e[r]==="\\"&&r++,r++;r>=e.length&&n("unterminated string",t);let l=e.slice(t+1,r);s==="'"&&(l=wr(l)),o+='"'+l+'"',t=r+1;continue}let d=t;for(;d<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[d]);)d++;d===t&&n("unexpected character "+JSON.stringify(s),t);let i=e.slice(t,d);if(i==="true"||i==="false"||i==="null"||zi.test(i)){o+=i,t=d;continue}if($i.test(i)){if(e[Ns(e,d)]===":"){o+='"'+i+'"',t=d;continue}n("unquoted value "+JSON.stringify(i),t)}n("invalid token "+JSON.stringify(i),t)}return o}function yr(e){try{return JSON.parse(e)}catch{}let o={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(s){let d=[],i=0;for(;i<s.length;){let r=s[i];if(/\s/.test(r)){i++;continue}if("{}".includes(r)){d.push({type:r,value:r}),i++;continue}if(r==="["){let a=!1,h=i+1;for(;h<s.length&&/\s/.test(s[h]);)h++;if(h<s.length&&/[a-zA-Z_]/.test(s[h])&&(a=!0),!a){d.push({type:r,value:r}),i++;continue}}if(r==="]"){d.push({type:r,value:r}),i++;continue}if(r===":"){d.push({type:o.COLON,value:r}),i++;continue}if(r===","){d.push({type:o.COMMA,value:r}),i++;continue}if(r==='"'||r==="'"){let a=r,h=i+1;for(;h<s.length&&s[h]!==a;)s[h]==="\\"&&h++,h++;d.push({type:o.STRING,value:s.substring(i+1,h),quoted:!0,sourceQuote:a}),i=h+1;continue}let l=i,u;for(;l<s.length&&!/[{},]/.test(s[l]);)if(s[l]===":"){let a=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let p of a){let v=p.substring(1);if(s.substring(l+1,l+1+v.length)===v){h=!0,l+=v.length;break}}if(!h)break}else if(s[l]==="["){for(l++;l<s.length&&s[l]!=="]";){if(s[l]==='"'||s[l]==="'"){let a=s[l];for(l++;l<s.length&&s[l]!==a;)s[l]==="\\"&&l++,l++}l++}l<s.length&&s[l]==="]"&&l++}else l++;u=s.substring(i,l);let b=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?b=o.NUMBER:u==="true"||u==="false"||u==="null"?b=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(b=o.SELECTOR),d.push({type:b,value:u,quoted:!1}),i=l}return d}function n(s){let d="";for(let i=0;i<s.length;i++){let r=s[i];if("{}".includes(r.type)||"[]".includes(r.type)){d+=r.value;continue}if(r.type===o.COLON){d+=r.value;continue}if(r.type===o.COMMA){let l=s[i+1];if(l&&(l.type==="}"||l.type==="]"))continue;d+=r.value;continue}if(r.type===o.STRING){let l=r.value;r.sourceQuote==="'"&&(l=wr(l)),d+=`"${l}"`;continue}if(r.type===o.NUMBER||r.type===o.BOOLEAN){d+=r.value;continue}d+=`"${r.value}"`}return d}try{let s=t(e),d=n(s);return JSON.parse(d)}catch(s){throw new Error("Invalid extraction rules syntax: "+s.message)}}var Qt=Symbol("hyper-morph-json-merge:missing"),kr=["id","_id","uuid","key","slug","code","name"];function uo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mo(e,o){return Object.prototype.hasOwnProperty.call(e,o)}function Yi(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}function zn(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o)){if(e.length!==o.length)return!1;for(let t=0;t<e.length;t++)if(!zn(e[t],o[t]))return!1;return!0}if(uo(e)&&uo(o)){let t=Object.keys(e);if(t.length!==Object.keys(o).length)return!1;for(let n of t)if(!Mo(o,n)||!zn(e[n],o[n]))return!1;return!0}return!1}function xr(e,o,t,n){return zn(o,t)?o:zn(o,e)?t:zn(t,e)?o:uo(o)&&uo(t)?Xi(uo(e)?e:{},o,t,n):Array.isArray(o)&&Array.isArray(t)?el(Array.isArray(e)?e:[],o,t,n):t}function vr(e,o,t,n){return o===Qt&&t===Qt?Qt:o===Qt?e===Qt?t:zn(t,e)?Qt:t:t===Qt?e===Qt?o:Qt:xr(e,o,t,n)}function Xi(e,o,t,n){let s={},d=new Set([...Object.keys(e),...Object.keys(o),...Object.keys(t)]);for(let i of d){let r=vr(Mo(e,i)?e[i]:Qt,Mo(o,i)?o[i]:Qt,Mo(t,i)?t[i]:Qt,n);r!==Qt&&Yi(s,i,r)}return s}function Ji(e){return e===null||typeof e!="object"}function $o(e){return typeof e+":"+String(e)}function Qi(e,o){for(let t of o){let n=new Set;for(let s of t){if(!Mo(s,e))return!1;let d=s[e];if(typeof d!="string"&&typeof d!="number")return!1;let i=$o(d);if(n.has(i))return!1;n.add(i)}}return!0}function Zi(e,o,t,n){let s=[e,o,t],d=!0;for(let i of s)for(let r of i)uo(r)||(d=!1);if(d){for(let i of n.keyCandidates)if(Qi(i,s))return{kind:"keyed",field:i};return null}for(let i of s){let r=new Set;for(let l of i){if(!Ji(l))return null;let u=$o(l);if(r.has(u))return null;r.add(u)}}return{kind:"self"}}function el(e,o,t,n){let s=Zi(e,o,t,n);if(!s)return t;let d=s.kind==="self"?$o:p=>$o(p[s.field]),i=p=>{let v=new Map;for(let O of p)v.set(d(O),O);return v},r=i(e),l=i(o),u=i(t),b=new Map,a=new Set([...r.keys(),...l.keys(),...u.keys()]);for(let p of a){let v=vr(r.has(p)?r.get(p):Qt,l.has(p)?l.get(p):Qt,u.has(p)?u.get(p):Qt,n);v!==Qt&&b.set(p,v)}let h=[];for(let p of t){let v=d(p);b.has(v)&&h.push(v)}for(let p=0;p<o.length;p++){let v=d(o[p]);if(!b.has(v)||h.includes(v))continue;let O=0;for(let m=p-1;m>=0;m--){let c=h.indexOf(d(o[m]));if(c!==-1){O=c+1;break}}h.splice(O,0,v)}return h.map(p=>b.get(p))}function As(e,o,t,n={}){let s=n.keyCandidates?[...n.keyCandidates,...kr]:kr;return xr(e===void 0?Qt:e,o,t,{keyCandidates:s})}function Go(e,o,t,n={}){let s=n.parse||zo,d=[],i=(a,h)=>{if(typeof a!="string")return Qt;try{return s(a)}catch(p){return d.push(`${h} side is not valid JSON (${p.message})`),Qt}},r=i(o,"local"),l=i(t,"remote");if(r===Qt)return{text:t,warnings:d};if(l===Qt)return{text:o,warnings:d};let u=i(e,"base"),b=As(u===Qt?void 0:u,r,l,n);return zn(b,l)?{text:t,warnings:d}:zn(b,r)?{text:o,warnings:d}:{text:JSON.stringify(b,null,2),warnings:d}}var Tr=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Zn(e){if(!e)return!1;let{startContainer:o,startOffset:t,endContainer:n,endOffset:s}=e;if(!o||!n||!Number.isInteger(t)||!Number.isInteger(s)||t<0||s<0||t>Tr(o)||s>Tr(n)||o.getRootNode()!==n.getRootNode())return!1;let d=o.ownerDocument.createRange();return d.setStart(o,t),d.setEnd(n,s),d.startContainer===o&&d.startOffset===t}function $n(e,o,t={}){if(!Zn(e))return null;let{startContainer:n,startOffset:s,endContainer:d,endOffset:i}=e;if(n===d&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(s,i);if(n===d&&s===i)return"";let r=new Set;for(let m=n;m;m=m.parentNode)r.add(m);let l=d;for(;!r.has(l);)l=l.parentNode;let u=(m,c)=>{let g=l.ownerDocument.createRange(),P=l.ownerDocument.createRange();return g.setStart(m[0],m[1]),g.collapse(!0),P.setStart(c[0],c[1]),P.collapse(!0),g.compareBoundaryPoints(0,P)},b=(m,c=!1)=>[m.parentNode,Array.prototype.indexOf.call(m.parentNode.childNodes,m)+Number(c)],a=[],h;if(o==="plain"){h="";let m=c=>{if(c.nodeType===3||c.nodeType===8){let g=h.length;h+=c.nodeValue,a.push({s:g,e:h.length,a:[c,0],b:[c,c.nodeValue.length],node:c})}else for(let g of c.childNodes)m(g)};m(l)}else{let m=t.blocks;if(!m){m=new Set;let g=P=>{P!==l&&P.nodeType===1&&ys.has(P.tagName)&&m.add(P);for(let T of P.childNodes)g(T)};g(l)}let c=ln(Array.from(l.childNodes),{blocks:m,atomize:g=>!!t.atoms?.has(g),ignored:t.ignored});h=c.text;for(let g of c.nodes)a.push({s:g.s,e:g.e,a:[g.node,0],b:[g.node,g.e-g.s],node:g.node});for(let g of c.atoms)a.push({s:g.i,e:g.i+1,a:b(g.el),b:b(g.el,!0)});for(let g=0;g<c.text.length;g++){if(c.text[g]!==Nt)continue;let P=c.marks.find(x=>x.block&&x.to===g+1),T=c.marks.find(x=>x.block&&x.from===g+1);if(P)a.push({s:g,e:g+1,a:[P.el,P.el.childNodes.length],b:b(P.el,!0)});else if(T)a.push({s:g,e:g+1,a:b(T.el),b:[T.el,0]});else return null}}a.sort((m,c)=>m.s-c.s);let p=m=>{if(m[0].nodeType===3||m[0].nodeType===8){let g=a.find(P=>P.node===m[0]);return g?g.s+m[1]:null}let c=0;for(let g of a){if(u(m,g.a)<=0)return g.s;if(u(m,g.b)<0)return null;c=g.e}return c},v=p([n,s]),O=p([d,i]);return v!==null&&O!==null&&v<=O?h.slice(v,O):null}function Qn(e,o){let t=e;for(let n of o.path)if(t=n==="content"?t?.content:t?.childNodes[n],!t)return null;return[t,o.offset]}function Sr(e,o){if(!e||!o)return null;let t=Qn(e,o.start),n=Qn(e,o.end);return t&&n?{startContainer:t[0],startOffset:t[1],endContainer:n[0],endOffset:n[1]}:null}var Nr=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ar(e,o,t){if(!o)return;let n=new Map,s=new Map,d=r=>{if(!r)return null;if(s.has(r))return s.get(r);let u=r.local.map(b=>Qn(o.localRoot,{path:b,offset:0})?.[0]).map(b=>b&&t(b)).filter(Boolean).map(b=>({node:b,parent:b.parentNode,previous:b.previousSibling,next:b.nextSibling,fragment:Nr(b)}));return s.set(r,u),u},i=r=>{let l=Sr(o.localRoot,r);if(!l)return null;let u=t(l.startContainer),b=t(l.endContainer);if(!u||!b)return null;let a={...l,startContainer:u,endContainer:b};return Zn(a)?a:null};for(let r of e){let l=r.recovery;if(!l||n.has(l))continue;let u={subject:d(l.subject),span:null,scope:null,touched:new Set};if(l.text){u.span=i(l.text.local.span),u.scope=i(l.text.local.scope);let b=u.span;if(b){let a=b.startContainer.ownerDocument.createRange();a.setStart(b.startContainer,b.startOffset),a.setEnd(b.endContainer,b.endOffset);let h=p=>{if(a.intersectsNode(p)){u.touched.add(p);for(let v of p.childNodes)h(v)}};h(a.commonAncestorContainer)}}if(l.structure){for(let b of[l.structure.localPlacement])b&&(d(b.parent),b.before.forEach(d),b.after.forEach(d));for(let b of l.structure.localOrder||[])d(b)}n.set(l,u)}o.localState={states:n,refs:s}}function Mr(e,o,t,n){let s=t.localState?.states.get(e);if(!s)return!1;let d=r=>{let l=r.node;if(!n(l)||l.parentNode!==r.parent)return!1;let u=b=>Array.prototype.indexOf.call(l.parentNode.childNodes,b);return!(r.previous&&n(r.previous)&&r.previous.parentNode===l.parentNode&&u(r.previous)>=u(l)||r.next&&n(r.next)&&r.next.parentNode===l.parentNode&&u(r.next)<=u(l))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!s.subject.length||!s.subject.every(d))return!1;if(e.text){let r=e.text.local,l=u=>u&&n(u.startContainer)&&n(u.endContainer);return l(s.span)&&l(s.scope)&&$n(s.scope,e.text.encoding)===r.text&&$n(s.span,e.text.encoding)===r.text.slice(r.start,r.end)}if(e.attribute){let r=e.attribute,l=s.subject[0].node;return(r.namespaceURI?l.getAttributeNS(r.namespaceURI,r.localName):l.getAttribute(r.qualifiedName))===o.local}let i=e.structure;if(i.localOrder){let r=-1,l=null;for(let u of i.localOrder){let b=t.localState.refs.get(u)?.[0]?.node;if(!b||!n(b)||l&&b.parentNode!==l)return!1;let a=Array.prototype.indexOf.call(b.parentNode.childNodes,b);if(a<=r)return!1;l=b.parentNode,r=a}return!0}return i.localAction==="moved"||s.subject.every(r=>Nr(r.node)===r.fragment)}var tl=1,hn=e=>!!e&&e.nodeType===1,Yo=e=>hn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function eo(e,o=null,t=null){let n=new Map,s=new Map,d=b=>{if(!o){o=new WeakMap;let a=[e];for(;a.length;){let h=a.pop();Yo(h)&&(o.set(h.content,h),a.push(h.content));for(let p=h.firstChild;p;p=p.nextSibling)p.nodeType===1&&a.push(p)}}return o.get(b)||null},i=(b,a)=>{let h=s.get(b);if(!h){h=new Map;let p=0;for(let v=b.firstChild;v;v=v.nextSibling)h.set(v,p++);s.set(b,h)}return h.get(a)},r=b=>{if(!b)return null;if(t&&t.has(b))return r(t.get(b));if(b===e)return[];let a=n.get(b);if(a!==void 0)return a;let h=b.parentNode,p=null;if(h&&h.nodeType===11){let v=d(h),O=v?r(v):null;O&&(p=O.concat(["content",i(h,b)]))}else if(h){let v=r(h);v&&(p=v.concat([i(h,b)]))}return n.set(b,p),p};return{root:e,pathOf:r,logicalParent:b=>{let a=b.parentNode;return a&&a.nodeType===11?d(a):a},indexIn:i,containerPath:b=>{if(b.nodeType===11){let h=d(b),p=r(h);return p?p.concat(["content"]):null}let a=r(b);return a&&Yo(b)?a.concat(["content"]):a},ownerOf:d}}var Cn=e=>Yo(e)?e.content:e;function Or(e){let{L:o,R:t,unitsOf:n,provenance:s,policy:d}=e,i=[];return{note:(b,a)=>{i.push([b,a])},finish:b=>i.length?u(b):null};function u(b){let a={base:eo(e.roots.base),local:eo(e.roots.local),remote:eo(e.roots.remote)},h=M=>M==="local"?o:t,p=(M,R)=>{if(!R)return null;if(M.map.has(R))return M.map.get(R);let z=[],J=hn(R)?a.base.logicalParent(R):R.parent;for(;J&&!M.map.has(J);J=a.base.logicalParent(J))z.push(J);if(!J||!M.identical.has(J))return null;let ne=M.map.get(J);for(let je=z.length-1;je>=0&≠je--)ne=Cn(ne).childNodes[a.base.indexIn(z[je].parentNode,z[je])];return ne?hn(R)?Cn(ne).childNodes[a.base.indexIn(R.parentNode,R)]||null:n(ne)[n(R.parent).indexOf(R)]||null:null},v=new Map,O=new Map,m=new WeakMap,c=0,g=(M,R)=>{let z=v.get(M);z||v.set(M,z=[]),z.push(R)};(function M(R){O.set(R,c++);let z=s.get(R);if(z&&!z.pinned){for(let J of[z.base,z.local,z.remote])if(J)if(Array.isArray(J))for(let ne of J)g(ne,R);else g(J,R)}if(Yo(R)){m.set(R.content,R);for(let J=R.content.firstChild;J;J=J.nextSibling)M(J)}for(let J=R.firstChild;J;J=J.nextSibling)M(J)})(b);let P=new Map;a.out=eo(b,m,P);let T={refs:new Map,spans:new Map,anchors:new Map,via:P,outOwners:m,outRoot:b,localRoot:e.roots.local},x=M=>hn(M)?[M]:M.nodes,A=(M,R)=>{let z=a[R].logicalParent(M);if(!z)return null;for(let J of n(z))if(!hn(J)&&J.nodes.includes(M))return J;return null},E=(M,R)=>M==null?null:Array.isArray(M)?M.length?A(M[0],R):null:M,S=M=>{let R=new Set,z=[];for(let J of M)for(let ne of v.get(J)||[])R.has(ne)||(R.add(ne),z.push(ne));return z.sort((J,ne)=>O.get(J)-O.get(ne))},N=new Map,C=M=>{let R=M.b||M.l||M.r,z=N.get(R);if(z)return z;let J=[];for(let ne of[M.b,M.l,M.r])ne&&J.push(...x(ne));return z=S(J),N.set(R,z),z},j=M=>({b:M,l:p(o,M),r:p(t,M)}),D=(M,R)=>{let z=h(R).reverse.get(M);if(z)return j(z);for(let J of S(x(M))){let ne=s.get(J);if(ne&&!ne.base&&ne.local&&ne.remote)return{b:null,l:E(ne.local,"local"),r:E(ne.remote,"remote")}}return R==="local"?{b:null,l:M,r:null}:{b:null,l:null,r:M}},B=new Map,w=M=>{let R=s.get(M);if(!R||R.pinned)return null;let z=E(R.base,"base");if(z)return j(z);let J=E(R.local,"local"),ne=E(R.remote,"remote");if(J){let je=o.reverse.get(J);if(je)return j(je)}if(ne){let je=t.reverse.get(ne);if(je)return j(je)}return J||ne?{b:null,l:J,r:ne}:null},y=M=>(B.has(M)||B.set(M,w(M)),B.get(M)),$=(M,R)=>hn(M)?a[R].logicalParent(M):M.parent,U=new Map,V=new Map,Ne=(M,R)=>(hn(M)?[a[R].pathOf(M)]:M.nodes.map(z=>a[R].pathOf(z))).filter(Boolean),Ae=M=>{let R=M.b||M.l||M.r,z=M.b?"base":M.l?"local":"remote",J=V.get(R);if(J)return J;let ne=!hn(R),je=Ne(R,z)[0],Q=`${z[0]}:${JSON.stringify(je===void 0?null:je)}${ne?":run":""}`,Oe=U.get(Q);if(Oe)return V.set(R,Oe),Oe;let Ve=C(M);return Oe={key:Q,nodeType:hn(R)?1:R.kind==="comment"?8:3,base:M.b?Ne(M.b,"base"):[],local:M.l?Ne(M.l,"local"):[],remote:M.r?Ne(M.r,"remote"):[],merged:Ve.map(Ce=>a.out.pathOf(Ce)).filter(Boolean),live:[]},U.set(Q,Oe),V.set(R,Oe),T.refs.set(Oe,Ve),Oe},De={base:new Map,local:new Map,remote:new Map},oe=new Map,xe=(M,R)=>{let z=$(M,R);if(!z||z.nodeType!==1)return null;let J=De[R].get(z);if(!J){let je=n(z),Q=Oe=>Ae(R==="base"?j(Oe):D(Oe,R));J={parent:Q(z),refs:je.map(Q),index:new Map(je.map((Oe,Ve)=>[Oe,Ve]))},De[R].set(z,J)}let ne=J.index.get(M)??-1;return{parent:J.parent,before:J.refs.slice(ne+1),after:J.refs.slice(0,Math.max(0,ne)).reverse()}},$e=M=>{let R=M.parentNode;if(!R)return null;let z=oe.get(R);if(!z){let ne=R.nodeType===11?m.get(R):R,je=ne&&ne.nodeType===1?y(ne):null;if(!je)return null;let Q=[],Oe=[],Ve=new Map;for(let be of R.childNodes){let H=y(be),X=H&&Ae(H),de=Q.length,pe=Q.length-1;X&&X!==Q[pe]&&(Q.push(X),pe++);let se={ref:X,group:pe,after:de};Oe.push(se),Ve.set(be,se)}let Ce=Q.length;for(let be=Oe.length-1;be>=0;be--){let H=Oe[be];H.before=Ce,H.ref&&(Ce=H.group)}z={parent:Ae(je),refs:Q,index:Ve},oe.set(R,z)}let J=z.index.get(M);return{parent:z.parent,before:z.refs.slice(J.before),after:z.refs.slice(0,J.after).reverse()}},ae=M=>hn(M)?M.outerHTML:M.value,k=M=>hn(M)?"element":M.kind==="comment"?"comment":"text",_=(M,R)=>({path:M,offset:R}),re=(M,R,z)=>{if(!M)return null;let J=a[z],ne=0;if(R){let je=hn(R)?R:R.nodes[R.nodes.length-1];je.parentNode&&(ne=J.indexIn(je.parentNode,je)+1)}return _(J.containerPath(M),ne)},Z=(M,R)=>{let z=$(M,"base"),J=z?p(h(R),z):null;if(!hn(J))return null;let ne=n(z),je=null;for(let Q=ne.indexOf(M)-1;Q>=0&&!je;Q--){let Oe=p(h(R),ne[Q]);Oe&&$(Oe,R)===J&&(je=Oe)}return re(J,je,R)},Be=(M,R,z,J)=>{let ne=a[J],je=0;for(let Q=0;Q<M.nodes.length;Q++){let Oe=M.nodes[Q],Ve=Oe.nodeValue.length,Ce=Q===M.nodes.length-1;if((z==="start"?R<je+Ve:R<=je+Ve)||Ce)return _(ne.pathOf(Oe),Math.max(0,Math.min(R-je,Ve)));je+=Ve}return null},Ke=(M,R)=>{let z=a[R],J=M.firstChild,ne=M.lastChild;return J&&J.nodeType===3&&ne.nodeType===3?{start:_(z.pathOf(J),0),end:_(z.pathOf(ne),ne.nodeValue.length)}:{start:_(z.pathOf(M),0),end:_(z.pathOf(M),M.childNodes.length)}},Te=(M,R,z)=>{for(let Q of M.nodes)if(z==="start"?Q.s<=R&&R<Q.e:Q.s<R&&R<=Q.e)return{kind:"text",node:Q.node,offset:R-Q.s};let J=z==="start"?R:R-1,ne=()=>{for(let Q of M.nodes)if(Q.s===R||Q.e===R)return{kind:"text",node:Q.node,offset:R-Q.s};return null},je=M.atomAt.get(J);if(je)return{kind:z==="start"?"before":"after",node:je.el};if(M.text[J]===Nt){let Q=M.marks.find(Ve=>Ve.block&&Ve.to===J+1);if(Q)return z==="start"?{kind:"end",node:Q.el}:{kind:"after",node:Q.el};let Oe=M.marks.find(Ve=>Ve.block&&Ve.from===J+1);if(Oe)return z==="start"?{kind:"before",node:Oe.el}:{kind:"startOf",node:Oe.el}}return ne()},it=(M,R)=>Te(M,R,"end")||Te(M,R,"start"),et=(M,R)=>{switch(R.kind){case"text":return _(M.pathOf(R.node),R.offset);case"end":return _(M.containerPath(R.node),Cn(R.node).childNodes.length);case"startOf":return _(M.containerPath(R.node),0);default:{let z=R.node.parentNode;return _(M.containerPath(z),M.indexIn(z,R.node)+(R.kind==="after"?1:0))}}},mt=(M,R,z,J,ne)=>{let je=Te(M,R,z);return je?et(a[J],je):ne()},Ze=(M,R,z,J)=>{let ne=M.textNodes.map(Ce=>({s:Ce.ms,e:Ce.me,start:{kind:"text",node:Ce.node,offset:0},end:{kind:"text",node:Ce.node,offset:Ce.me-Ce.ms}}));for(let[Ce,be]of M.atomOut)ne.push({s:Ce,e:Ce+1,start:{kind:"before",node:be},end:{kind:"after",node:be}});for(let[Ce,be]of M.breakOut)ne.push({s:Ce,e:Ce+1,start:{kind:"end",node:be},end:{kind:"after",node:be}});for(let Ce of ne)if(Ce.start.kind==="text"&&Ce.s<R&&R<Ce.e)return{kind:"text",node:Ce.start.node,offset:R-Ce.s};if(z!=="empty"){let Ce=ne.find(be=>z==="start"?be.s===R:be.e===R);if(Ce)return z==="start"?Ce.start:Ce.end}let je=ne.find(Ce=>Ce.e===R);if(je)return je.end;let Q=ne.find(Ce=>Ce.s===R);if(Q)return Q.start;let Oe=null,Ve=null;for(let Ce of ne)Ce.e<=R&&(!Oe||Ce.e>Oe.e)&&(Oe=Ce),Ce.s>=R&&(!Ve||Ce.s<Ve.s)&&(Ve=Ce);return Oe?Oe.end:Ve?Ve.start:J()},ft=(M,R)=>{if(!R)return null;if(R.kind==="text"){let ne=M.nodes.find(je=>je.node===R.node);return ne?ne.s+Math.min(R.offset,ne.e-ne.s):null}let z=M.atoms.find(ne=>ne.el===R.node);if(z)return R.kind==="after"?z.i+1:z.i;let J=M.marks.find(ne=>ne.el===R.node);return J?R.kind==="before"&&J.block&&M.text[J.from-1]===Nt&&!M.marks.some(ne=>ne.block&&ne.to===J.from)?J.from-1:R.kind==="startOf"||R.kind==="before"?J.from:R.kind==="end"&&J.block?J.to-1:J.to:null},Ct=(M,R,z,J)=>{for(let Oe of M.nodes)if(z==="start"?Oe.s<=R&&R<Oe.e:Oe.s<R&&R<=Oe.e)return{kind:"text",node:Oe.node,offset:R-Oe.s};let ne=z==="start"?R:R-1;if(!M.atomAt.has(ne)&&M.text[ne]!==Nt){for(let Oe of M.nodes)if(Oe.s===R||Oe.e===R)return{kind:"text",node:Oe.node,offset:R-Oe.s}}let je=M.atomAt.get(ne);if(je)return{kind:z==="start"?"before":"after",node:je.el};if(M.text[ne]===Nt){let Oe=M.marks.find(Ce=>Ce.block&&Ce.to===ne+1);if(Oe)return z==="start"?{kind:"end",node:Oe.el}:{kind:"after",node:Oe.el};let Ve=M.marks.find(Ce=>Ce.block&&Ce.from===ne+1);if(Ve)return z==="start"?{kind:"before",node:Ve.el}:{kind:"startOf",node:Ve.el}}let Q=M.marks.find(Oe=>Oe.block&&Oe.from===R);return Q?{kind:"startOf",node:Q.el}:J?{kind:z==="start"?"startOf":"end",node:J}:null},Dt=M=>{if(!M)return null;if(M.kind==="wholeStart"||M.kind==="wholeEnd"){let R=Tt(M.node);return M.kind==="wholeStart"?R.start:R.end}return et(a.out,M)},Tt=M=>{let R=M.firstChild,z=M.lastChild;return R&&R.nodeType===3&&z.nodeType===3?{start:_(a.out.pathOf(R),0),end:_(a.out.pathOf(z),z.nodeValue.length)}:{start:_(a.out.pathOf(M),0),end:_(a.out.pathOf(M),M.childNodes.length)}},Rt=M=>{let R=$(M,"base"),z=R?C(j(R))[0]:null;if(!z)return null;let J=Cn(z),ne=n(R);for(let je=ne.indexOf(M)-1;je>=0;je--){let Q=C(j(ne[je])).filter(Oe=>Oe.parentNode===J);if(Q.length)return{kind:"after",node:Q[Q.length-1]}}return{kind:"startOf",node:z}},jt=(M,R,z,J,ne,je)=>({text:M,start:R,end:z,fragment:J,span:ne,scope:je}),qt=(M,R,z,J,ne)=>jt(M,R,z,M.slice(R,z),J,ne),un=(M,R,z,J,ne)=>(T.spans.set(M,{start:R,end:z,scopeStart:J,scopeEnd:ne}),M),Lt=new Map,Jt=new Map,F=(M,R,z)=>{let J=`text:${M.key}:${R}:${z}`,ne=Jt.get(J)||0;return Jt.set(J,ne+1),`${J}:${ne}`},ce=(M,R)=>{let z,J,ne,je="plain",Q,Oe,Ve,Ce,be,H=(pe,se,ke,fe,G)=>{if(!pe){let ue=Z(G,fe);return qt("",0,0,{start:ue,end:ue},{start:ue,end:ue})}return qt(pe.value,se,ke,{start:Be(pe,se,se===ke?"end":"start",fe),end:Be(pe,ke,"end",fe)},{start:Be(pe,0,"start",fe),end:Be(pe,pe.value.length,"end",fe)})};if(R.site==="run"){let{bRun:pe,lRun:se,rRun:ke,node:fe,c:G}=R;z=j(pe),J=G.bs,ne=G.be,Q=H(pe,G.bs,G.be,"base",pe),Oe=H(se,G.ls,G.le,"local",pe),Ve=H(ke,G.rs,G.re,"remote",pe);let ue=fe?fe.nodeValue:"",Ie=Pe=>fe?{kind:"text",node:fe,offset:Pe}:Rt(pe);Ce=un(qt(ue,G.ms,G.me,{start:Dt(Ie(G.ms)),end:Dt(Ie(G.me))},{start:Dt(Ie(0)),end:Dt(Ie(ue.length))}),Ie(G.ms),Ie(G.me),Ie(0),Ie(ue.length)),be=fe||(Rt(pe)||{}).node||null}else if(R.site==="whole"){let pe=R.el,se=s.get(pe);z=j(se.base),J=0,ne=M.base.length;let ke=(G,ue,Ie)=>{let Pe=Ke(ue,Ie);return qt(G,0,G.length,Pe,Pe)};Q=ke(M.base,se.base,"base"),Oe=ke(M.local,se.local,"local"),Ve=ke(M.remote,se.remote,"remote");let fe=Tt(pe);Ce=un(qt(M.resolved,0,M.resolved.length,fe,fe),{kind:"wholeStart",node:pe},{kind:"wholeEnd",node:pe},{kind:"wholeStart",node:pe},{kind:"wholeEnd",node:pe}),be=pe}else if(R.site==="comment"){let{bRun:pe,lRun:se,rRun:ke,node:fe}=R;z=j(pe),J=0,ne=M.base.length;let G=(He,Se)=>{if(!He){let ot=Z(pe,Se);return qt("",0,0,{start:ot,end:ot},{start:ot,end:ot})}let Je=He.nodes[0],nt={start:_(a[Se].pathOf(Je),0),end:_(a[Se].pathOf(Je),He.value.length)};return qt(He.value,0,He.value.length,nt,nt)};Q=G(pe,"base"),Oe=G(se,"local"),Ve=G(ke,"remote");let ue=M.resolved,Ie=He=>fe?{kind:"text",node:fe,offset:He}:Rt(pe),Pe={start:Dt(Ie(0)),end:Dt(Ie(ue.length))};Ce=un(qt(ue,0,ue.length,Pe,Pe),Ie(0),Ie(ue.length),Ie(0),Ie(ue.length)),be=fe||(Rt(pe)||{}).node||null}else{let{fb:pe,fl:se,fr:ke,scope:fe}=R,G=R.merged;je="html",z=fe.base?j(fe.base):D(fe.local,"local"),J=M.bs,ne=M.be;let ue=ee=>{let Ee=fe[ee];for(let Ue=fe.at-1;Ue>=0;Ue--){let _e=fe.units[Ue],Ye=ee==="base"?_e:p(h(ee),_e);if(Ye&&$(Ye,ee)===Ee)return Ye}return null},Ie=ee=>()=>re(fe[ee],ue(ee),ee),Pe=(ee,Ee,Ue,_e,Ye)=>{let yt=pn=>pn?et(a[Ye],pn):Ie(Ye)(),gt=Ee===Ue?it(ee,Ee):Te(ee,Ee,"start"),$t=Ee===Ue?it(ee,Ee):Te(ee,Ue,"end"),_t=yt(gt),dn={start:_t,end:Ee===Ue?_t:yt($t)},vt=R.full?R.full(Ye):null;if(!vt)return jt(ee.text,Ee,Ue,_e,dn,{start:yt(Te(ee,0,"start")),end:yt(Te(ee,ee.text.length,"end"))});let dt=gt?ft(vt,gt):null,Qe=$t?ft(vt,$t):null,Mt=dt===null?0:dt,bt=Math.max(Mt,Qe===null?vt.text.length:Qe),Ht=yt(Te(vt,0,"start"));return jt(vt.text,Mt,bt,lo(vt,Mt,bt),dn,{start:Ht,end:vt.text.length?yt(Te(vt,vt.text.length,"end")):Ht})};Q=R.synthetic?null:Pe(pe,M.bs,M.be,M.base,"base"),Oe=Pe(se,M.lss,M.lse,M.local,"local"),Ve=Pe(ke,M.rss,M.rse,M.remote,"remote");let[He,Se]=M.range||[0,0],Je=G.out,nt=()=>{let ee=Cn(G.node);for(let Ee=fe.at-1;Ee>=0;Ee--){let Ue=C(j(fe.units[Ee])).filter(_e=>_e.parentNode===ee);if(Ue.length)return{kind:"after",node:Ue[Ue.length-1]}}for(let Ee=fe.at;Ee<fe.units.length;Ee++){let Ue=C(j(fe.units[Ee])).filter(_e=>_e.parentNode===ee);if(Ue.length)return{kind:"before",node:Ue[0]}}return{kind:"startOf",node:G.node}};if(Je.via)for(let[ee,Ee]of Je.via)P.set(ee,Ee);let ot=Ze(G,He,He===Se?"empty":"start",nt),Wt=He===Se?ot:Ze(G,Se,"end",nt),Ut=Je.text.length?Ct(Je,0,"start",G.node):nt(),I=Je.text.length?Ct(Je,Je.text.length,"end",G.node):Ut,q=ft(Je,ot),te=ft(Je,Wt),me=q===null?0:q,we=Math.max(me,te===null?Je.text.length:te);Ce=un(jt(Je.text,me,we,lo(Je,me,we),{start:Dt(ot),end:Dt(Wt)},{start:Dt(Ut),end:Dt(I)}),ot,Wt,Ut,I);let ie=T.spans.get(Ce);if(ie.flat=Je,!Je.text.length){let ee=Dt(Ut),Ee=Qn(b,ee),Ue=Ee[0],_e=Ee[1];ie.empty={parent:Ue.nodeType===11?m.get(Ue):Ue,previous:Ue.childNodes[_e-1]||null,next:Ue.childNodes[_e]||null}}be=ot?ot.node:G.node}let X=Ae(z),de=(R.site==="whole"||R.site==="comment"||(R.policy||d)!=="both")&&M.resolved!==M.local;return{key:R.site==="comment"&&Lt.get(z.b||z.l||z.r)||F(X,J,ne),subject:X,localLost:de,anchor:be,text:{encoding:je,base:Q,local:Oe,remote:Ve,merged:Ce,liveSpan:null,liveScope:null}}},ge=(M,R)=>{let z=y(R.el),J=Ae(z),ne=R.sample;return{key:`attr:${J.key}:${ne.namespaceURI||""}:${ne.localName}`,subject:J,localLost:M.resolved!==M.local,anchor:R.el,attribute:{namespaceURI:ne.namespaceURI||null,localName:ne.localName,qualifiedName:ne.name}}},Le=(M,R)=>{let z=M.detail,J=R.unit||j(R.subject),ne=Ae(J),je=T.refs.get(ne),Q=J.l?xe(J.l,"local"):null,Oe=J.r?xe(J.r,"remote"):null,Ve=je.length?$e(je[0]):null,Ce,be,H,X=null,de=null,pe=R.deleted;switch(z){case"both-reordered":{Ce=be="reordered";let se=new Set(R.rKept),ke=R.lKept.filter(Pe=>se.has(Pe)&&C(j(Pe)).length),fe=Pe=>O.get(C(j(Pe))[0]);X=ke.map(Pe=>Ae(j(Pe))),de=ke.slice().sort((Pe,He)=>fe(Pe)-fe(He)).map(Pe=>Ae(j(Pe)));let G=Pe=>!hn(Pe)&&Pe.kind!=="comment"&&Pe.nodes.every(He=>!/[^\t\n\f\r ]/.test(He.data)),ue=ke.filter(Pe=>!G(Pe)),Ie=ue.slice().sort((Pe,He)=>fe(Pe)-fe(He));H=ue.some((Pe,He)=>Pe!==Ie[He]);break}case"both-moved":Ce=be="moved",H=!Q||!je.some(se=>{let ke=se===je[0]?Ve:$e(se);return ke&&ke.parent===Q.parent});break;case"edit-beats-delete":Ce=pe==="local"?"deleted":"edited",be=pe==="remote"?"deleted":"edited",H=pe==="local";break;case"move-beats-delete":Ce=pe==="local"?"deleted":"moved",be=pe==="remote"?"deleted":"moved",H=pe==="local";break;case"remote-wins":Ce="edited",be="edited",H=!0;break;default:Ce=be="inserted",H=R.localLost}return{key:`structure:${ne.key}:${z}`,subject:ne,localLost:H,anchor:je[0]||null,structure:{localAction:Ce,remoteAction:be,localPlacement:Q,remotePlacement:Oe,mergedPlacement:Ve,localOrder:X,mergedOrder:de,localFragment:z==="both-reordered"||!J.l?null:ae(J.l),fragmentKind:k(J.b||J.l||J.r)}}};for(let[M,R]of i){if(M.kind!=="structure")continue;let z=R.unit||j(R.subject),J=z.b||z.l||z.r;!hn(J)&&J.kind==="comment"&&Lt.set(J,`structure:${Ae(z).key}:${M.detail}`)}let Me=new Map;for(let[M,R]of i){if(M.kind==="structure"){let je=Ae(R.unit||j(R.subject)),Q=`structure:${je.key}:${M.detail}`,Oe=Me.get(Q);if(Oe&&Oe.structure){M.recovery=Oe;let Ve=T.refs.get(je);M.el==null&&Ve.length&&(M.el=hn(Ve[0])?Ve[0]:a.out.logicalParent(Ve[0]));continue}}let z=M.kind==="text"?ce(M,R):M.kind==="attr"?ge(M,R):Le(M,R),J=Me.get(z.key);J||(J={version:tl,key:z.key,localLost:z.localLost,subject:z.subject,applied:!1,unavailable:null},Me.set(z.key,J),T.anchors.set(J,z.anchor)),z.text&&(J.text=z.text),z.attribute&&(J.attribute=z.attribute),z.structure&&(J.structure=z.structure),z.text&&(J.localLost=z.localLost),M.recovery=J;let ne=T.refs.get(z.subject);M.kind==="structure"&&M.el==null&&ne.length&&(M.el=hn(ne[0])?ne[0]:a.out.logicalParent(ne[0])),M.kind==="text"&&M.node==null&&ne.length&&z.subject.nodeType===8&&(M.node=ne[0])}return T}}function Ir(e,o,t){if(!o)return;let{lookup:n,vetoed:s,vetoedAttrs:d,liveAttr:i}=t,r=t.ignored||(()=>!1),l=eo(t.liveRoot),u=w=>!!w&&l.containerPath(w)!==null,b=w=>{let y=w.parentNode;return y&&y.nodeType===11?o.outOwners.get(y)||null:y},a=w=>{for(let y=w;y;y=b(y))if(o.via.has(y)&&(y=o.via.get(y)),s.has(y)||t.vetoedLive?.has(c(y)))return!0;return!1},h=w=>Array.from(Cn(w).children).filter(y=>!r(y)),p=(w,y)=>h(w)[h(y.parentNode).indexOf(y)],v=(w,y)=>{let $=null,U=null,V=0;for(let oe=y.previousSibling;oe;oe=oe.previousSibling){if(oe.nodeType===1&&!r(oe)){$=oe;break}oe.nodeType===3&&(V+=oe.nodeValue.length)}for(let oe=y.nextSibling;oe&&!U;oe=oe.nextSibling)oe.nodeType===1&&!r(oe)&&(U=oe);let Ne=$?p(w,$):null,Ae=U?p(w,U):null;if($&&!Ne||U&&!Ae)return null;let De=[];for(let oe=Ne?Ne.nextSibling:Cn(w).firstChild;oe&&oe!==Ae;oe=oe.nextSibling)oe.nodeType===3&&De.push(oe);return De.length?{nodes:De,lead:V}:null},O=w=>{let y=[],$=w;for(;$&&!o.via.has($);$=$.parentNode)y.push($);if(!$||!y.length)return null;let U=c(o.via.get($));for(let Ae=y.length-1;Ae>0&&U;Ae--)U=p(U,y[Ae]);if(!U)return null;let V=y[0];if(V.nodeType===3)return v(U,V);let Ne=V.nodeType===1?p(U,V):null;return Ne?{nodes:[Ne],lead:0}:null},m=w=>{let y=n(w),$=y?{nodes:Array.isArray(y)?y:[y],lead:0}:o.via.size?O(w):null;if(!$)return null;let U=$.nodes.filter(u);return U.length?{nodes:U,lead:$.lead}:null},c=w=>{let y=m(w);return y?y.nodes[0]:null},g=w=>{if(!w)return null;if(w.kind==="text"){let V=m(w.node);if(!V)return null;let Ne=V.nodes,Ae=w.offset+V.lead,De=0;for(let oe=0;oe<Ne.length;oe++){let xe=Ne[oe].nodeValue.length;if(Ae<=De+xe||oe===Ne.length-1)return Ae>=De&&Ae<=De+xe?[Ne[oe],Ae-De]:null;De+=xe}return null}let y=c(w.node);if(!y)return null;if(w.kind==="end")return[Cn(y),Cn(y).childNodes.length];if(w.kind==="startOf")return[Cn(y),0];if(w.kind==="wholeStart")return y.firstChild?[y.firstChild,0]:[y,0];if(w.kind==="wholeEnd")return y.lastChild?[y.lastChild,y.lastChild.nodeValue.length]:[y,y.childNodes.length];let $=y.parentNode;if(!$)return null;let U=Array.prototype.indexOf.call($.childNodes,y);return[$,w.kind==="after"?U+1:U]},P=w=>({blocks:new Set((w.flat?.marks||[]).filter(y=>y.block).map(y=>c(y.el)).filter(Boolean)),atoms:new Set((w.flat?.atoms||[]).map(y=>c(y.el)).filter(Boolean)),ignored:r}),T=(w,y,$,U)=>{if(!w||!y||!Zn(w)||!Zn(y))return!1;for(let Ae of[w,y])if(!u(Ae.startContainer)||!u(Ae.endContainer))return!1;let V=$.merged;if(V.start===V.end&&(w.startContainer!==w.endContainer||w.startOffset!==w.endOffset))return!1;let Ne=P(U);return $n(y,$.encoding,Ne)===V.text&&$n(w,$.encoding,Ne)===V.text.slice(V.start,V.end)},x=new Map,A=w=>{let y=w.parentNode;return y?(x.has(y)||x.set(y,new Map(Array.from(y.childNodes,($,U)=>[$,U]))),x.get(y).get(w)):-1},E=(w,y)=>{if(!y)return!1;let $=l.logicalParent(w);if(!y.parent.live.includes($))return!1;let U=A(w);for(let[V,Ne]of[["before",1],["after",-1]]){let Ae=U;for(let De of y[V]){if(De.live.includes(w))continue;let oe=De.live.filter($e=>$e!==w&&$e.parentNode===w.parentNode);if(!oe.length)continue;let xe=Ne===1?Math.min(...oe.map(A)):Math.max(...oe.map(A));if(Ne*(xe-Ae)<=0)return!1;Ae=xe}}return!0},S=w=>{let y=w.structure;if(y.mergedOrder){let $=new Set(w.subject.live.map(Cn)),U=null,V=-1;for(let Ne of y.mergedOrder){let Ae=Ne.live.find(De=>$.has(De.parentNode));if(!Ae||U&&Ae.parentNode!==U||A(Ae)<=V)return!1;U=Ae.parentNode,V=A(Ae)}return w.subject.live.length>0}return w.subject.live.some($=>E($,y.mergedPlacement))},N=(w,y)=>{let $=g(w),U=g(y);return $&&U?{startContainer:$[0],startOffset:$[1],endContainer:U[0],endOffset:U[1]}:null},C=new Set,j=w=>{if(!w||C.has(w))return;C.add(w);let y=[];for(let $ of o.refs.get(w)||[]){let U=m($);if(U)for(let V of U.nodes)y.includes(V)||y.push(V)}w.live=y},D=w=>{w&&(j(w.parent),w.before.forEach(j),w.after.forEach(j))},B=new Set;for(let w of e){let y=w.recovery;if(!y||B.has(y))continue;B.add(y),j(y.subject),y.structure&&(D(y.structure.localPlacement),D(y.structure.remotePlacement),D(y.structure.mergedPlacement),(y.structure.localOrder||[]).forEach(j),(y.structure.mergedOrder||[]).forEach(j));let $=o.anchors.get(y),U=$?c($):null,V=!!U;if(y.text){let k=o.spans.get(y.text.merged),_=k?N(k.start,k.end):null,re=k?N(k.scopeStart,k.scopeEnd):null;if(k?.empty){let Z=k.empty,Be=Z.previous?{kind:"after",node:Z.previous}:{kind:"startOf",node:Z.parent},Ke=Z.next?{kind:"before",node:Z.next}:{kind:"end",node:Z.parent},Te=N(Be,Ke);!Te||Te.startContainer!==Te.endContainer||Te.startOffset!==Te.endOffset?_=null:_=re=Te}T(_,re,y.text,k)||(_=re=null),y.text.liveSpan=_,y.text.liveScope=_?re:null,_||(V=!1)}y.structure&&V&&(V=S(y)),y.attribute&&V&&(V=i(U,y.attribute,w.resolved));let Ne=(!!y.attribute||!!y.text&&U?.tagName==="TEXTAREA")&&!!d&&[$,U].some(k=>d.get(k)?.has(y.attribute?y.attribute.qualifiedName:"value")),Ae=o.localState?.states.get(y),De=!!y.text&&[...t.removedVetoes||[]].some(k=>Ae?.touched.has(k)),oe=y.structure?.localAction==="inserted"&&[...s].some(k=>k===$||$?.contains(k)),xe=$&&a($)||Ne||De||oe,$e=xe&&Mr(y,w,o,u);$e&&(De||oe&&y.localLost)&&(V=!1);let ae=!V&&$e&&xe;y.applied=V,y.unavailable=V?null:ae?"hook-veto":"missing-output",ae&&(y.localLost=!1),!V&&y.text&&(y.text.liveSpan=y.text.liveScope=null)}}function Xo(e,o,t){let n=eo(o),s=eo(t),d=a=>!!a&&s.containerPath(a)!==null,i=a=>{if(a===o)return t;let h=n.pathOf(a);if(h&&o!==t){let p=Qn(t,{path:h,offset:0});if(p&&p[0].nodeType===a.nodeType)return p[0]}return a},r=new Set,l=a=>{!a||r.has(a)||(r.add(a),a.live=a.live.map(i).filter(d))},u=a=>{a&&(a.startContainer=i(a.startContainer),a.endContainer=i(a.endContainer))},b=new Set;for(let a of e){a.node===o&&t.tagName==="SCRIPT"&&(a.node=t),a.el===o&&a.kind==="structure"&&(a.el=t);let h=a.recovery;if(!h||b.has(h))continue;if(b.add(h),l(h.subject),h.text){u(h.text.liveSpan),u(h.text.liveScope);let v=h.text.liveSpan,O=h.text.liveScope,m=h.text.merged,c=g=>!!g&&Zn(g)&&d(g.startContainer)&&d(g.endContainer);(!c(v)||!c(O)||$n(O,h.text.encoding)!==m.text||$n(v,h.text.encoding)!==m.text.slice(m.start,m.end))&&(h.text.liveSpan=null,h.text.liveScope=null,h.applied=!1,h.unavailable="missing-output")}let p=h.structure;if(p){for(let v of[p.localPlacement,p.remotePlacement,p.mergedPlacement])v&&(l(v.parent),v.before.forEach(l),v.after.forEach(l));(p.localOrder||[]).forEach(l),(p.mergedOrder||[]).forEach(l),h.subject.live.length||(h.applied=!1,h.unavailable="missing-output")}}}var ho=e=>e?.nodeType===1,Oo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function nl({provenance:e,parentOf:o,twins:t,baseOf:n,build:s,ignored:d,remoteWins:i,discarded:r}){let l=new Map,u=new WeakMap;function b(p,v,O,m=!1){if(!ho(p)||!ho(O))return null;let c=l.get(p);if(c)(m||!c.selected&&v==="remote")&&(c.parent=o(O),c.port=O,c.sourceSide=v,c.selected=m);else{let g=u.get(p)||null;c={owner:p,parent:o(O),port:O,sourceSide:v,originalParent:o(p),originalPort:p,selected:m,state:g?"built":"planned",output:g,disposition:null},l.set(p,c)}return c}function a(p,v){if(!ho(p)||!ho(v))return;u.has(p)||u.set(p,v);let O=l.get(p);O&&O.state!=="attached"&&!O.output&&(O.output=v,O.state="built")}function h(p){if(!l.size)return;let v=new Map,O=new WeakMap,m=new WeakMap,c=new WeakSet,g=new Set,P=(D,B)=>{if(!D)return;if(Array.isArray(D)){for(let y of D)P(y,B);return}let w=v.get(D);w||v.set(D,w=[]),w.push(B)},T=(D,B)=>{if(!D)return;let w=[D];for(;w.length;){let y=w.pop();P(y,B);for(let $ of Oo(y).childNodes)w.push($)}};function x(D,B=null,w=!1){if(c.has(D))return;c.add(D),O.set(D,B);let y=e.get(D),$=w||!!(y&&i(y.remote||y.base));m.set(D,$);let U={node:D,kind:"node",authority:$};if(y?.pinned)T(y.local,{...U,kind:"ignored"});else if(y?.unchanged)for(let V of[y.base,y.local,y.remote])T(V,{...U,kind:"unchanged"});else if(y){for(let V of[y.base,y.local,y.remote])P(V,U);if(ho(y.local))for(let V of Oo(y.local).children)d(V)&&T(V,{...U,kind:"ignored"})}for(let V of Oo(D).childNodes)x(V,D,$)}let A=D=>{if(D.output&&c.has(D.output))return D.state="attached",D.disposition="node",!0;let{local:B,remote:w}=t(D.owner);for(let y of[D.owner,B,w]){let $=v.get(y);if($?.length){let U=$.find(V=>V.kind==="node")||$[0];return D.output=U.node,D.state="attached",D.disposition=U.kind,!0}}return!1},E=(D,B)=>(v.get(D)||[]).find(y=>y.kind==="node"&&ho(y.node)&&(!y.authority||B.sourceSide==="remote"))?.node,S=(D,B,w)=>{let y=v.get(D)||[],$=w?[...y].reverse():y;for(let U of $){if(U.kind!=="node")continue;let V=U.node;for(;V&&O.get(V)!==B;)V=O.get(V);if(V)return V}return null},N=(D,B,w)=>{let y=Oo(B);for(let $=w?.previousSibling;$;$=$.previousSibling){let U=S($,B,!0);if(U){y.insertBefore(D,U.nextSibling);return}}for(let $=w?.nextSibling;$;$=$.nextSibling){let U=S($,B,!1);if(U){y.insertBefore(D,U);return}}y.appendChild(D)};function C(D,B,w){let y=B==="base"?D:n(D,B),$=l.get(y);$&&$!==w&&j($)}function j(D){if(D.state==="attached"||D.disposition==="remote-wins"||g.has(D)||A(D))return;g.add(D);let{local:B,remote:w}=t(D.owner);if(i(w||D.owner)){if(!w){D.disposition="remote-wins",r(D.owner,B),g.delete(D);return}D.parent=o(w),D.port=w,D.sourceSide="remote"}if(C(D.parent,D.sourceSide,D),A(D)){g.delete(D);return}let y=E(D.parent,D),$=D.port;if(!y){if(C(D.originalParent,"base",D),A(D)){g.delete(D);return}let V=D.originalParent;for($=D.originalPort;V&&!y;)y=E(V,D),y||($=V,V=o(V))}if(!y)throw new Error("A planned move has no allowed surviving parent");let U=D.output||s(D.owner);D.output=U,D.state="built",N(U,y,$),x(U,y,m.get(y)||!1),A(D),g.delete(D)}x(p);for(let D of l.values())j(D)}return{planned:l,has:p=>l.has(p),plan:b,produced:a,drain:h}}function po(e,o,t,n,s,d,i,r,l,u,b,a,h){let p=null;return nl({provenance:e,parentOf:m=>{if(!m)return null;let c=o(m);if(c||m.parentNode?.nodeType!==11)return c;if(!p){p=new WeakMap;let g=[a,h];for(;g.length;){let P=g.pop(),T=Oo(P);T!==P&&p.set(T,P);for(let x of T.children)g.push(x)}}return p.get(m.parentNode)||null},twins:m=>({local:s(t,m),remote:s(n,m)}),baseOf:(m,c)=>m&&(c==="local"?t:n).reverse.get(m)||null,build:m=>d(m,s(t,m),s(n,m),!1),ignored:i,remoteWins:r,discarded:(m,c)=>{c&&b(m,c,t)&&!l.some(g=>g.detail==="remote-wins"&&g.base===m)&&u({kind:"structure",el:null,detail:"remote-wins",base:m,local:c,remote:null},{subject:m})}})}function ol({parent:e,base:o,views:t,eligible:n,ignored:s,remoteWins:d,budget:i=Xt(2e4*32),maxUnits:r=256,maxCharacters:l=2e4}){let u=(c,g=null)=>({status:c,reason:g,parent:e,records:[]});if(t.some(({V:c})=>c.asBase)||s(e)||d(e)||t.some(({V:c})=>!c.el||s(c.el)||d(c.el)))return u("none");let b=o.length+t[0].V.units.length+t[1].V.units.length;if(b>r)return u("fallback","unit-limit");let a=Symbol(),h=c=>{if(c>i.remaining)throw a;i.remaining-=c,i.crossParentSteps=(i.crossParentSteps||0)+c},p=new Map,v=0,O=c=>{if(h(1),p.has(c))return p.get(c);let g=c.nodeType===1?c.childNodes:c.nodes;h(g.length*4+1);let P=c.nodeType===1?Array.from(g):g,T=0;for(let E=0;E<P.length;E++){let S=P[E];if(S.nodeType!==3||E&&P[E-1].nextSibling!==S)return p.set(c,null),null;T+=S.data.length}if(T>l-v)throw a;h(T*8+1),v+=T;let x=ln(P);if(x.text.includes(Nt))return p.set(c,null),null;let A={unit:c,nodes:P,flat:x};return p.set(c,A),A},m=[];try{h(b*8+1);for(let c=0;c<2;c++){let g=t[c].V,P=t[1-c].V,T=[],x=new Map;for(let A=0;A<o.length;A++){h(1);let E=o[A];if(E.kind!=="text"||g.twin(E))continue;let S=P.twin(E);if(!S||S.kind!=="text"||!P.here(S))continue;let N=O(E),C=O(S);if(!N||!C||!/\S/.test(N.flat.text))continue;h(N.flat.text.length*2+1);let j=N.flat.text;x.set(j,(x.get(j)||0)+1),T.push({source:E,opposite:S,sourceModel:N,oppositeModel:C,index:A})}for(let A of T){let{source:E,opposite:S,sourceModel:N,oppositeModel:C,index:j}=A,D=[];for(let _ of[-1,1]){h(1);let re=o[j+_];if(!re||re.nodeType!==1||!n(re)||s(re)||d(re))continue;let Z=N.nodes[0],Be=N.nodes.at(-1);if(_===-1?Z?.previousSibling!==re:Be?.nextSibling!==re)continue;let Ke=g.twin(re),Te=P.twin(re);if(!Ke||!Te||!g.here(Ke)||P.here(Te)||g.baseOf(Ke)!==re||P.baseOf(Te)!==re||!n(Ke)||!n(Te)||s(Ke)||s(Te)||d(Ke)||d(Te)||Ke.tagName!==re.tagName||Te.tagName!==re.tagName||Ke.namespaceURI!==re.namespaceURI||Te.namespaceURI!==re.namespaceURI)continue;let it=O(re),et=O(Ke),mt=O(Te);if(!it||!et||!mt||!/\S/.test(it.flat.text))continue;let Ze=it.flat.text,ft=N.flat.text,Ct=et.flat.text;if(h((Ze.length+ft.length+Ct.length)*3+1),Ct.length!==Ze.length+ft.length)continue;let Dt=_===-1;(Dt?!Ct.startsWith(Ze)||!Ct.endsWith(ft):!Ct.startsWith(ft)||!Ct.endsWith(Ze))||D.push({owner:re,target:Ke,moved:Te,ownerBase:it,joined:et,ownerOther:mt,targetFrom:Dt?Ze.length:0,retainedFrom:Dt?0:ft.length})}if(!D.length)continue;if(D.length!==1||x.get(N.flat.text)!==1)return u("fallback","ambiguous-origin");let B=D[0],{owner:w,target:y,moved:$,ownerBase:U,joined:V,ownerOther:Ne,targetFrom:Ae,retainedFrom:De}=B;if(h(m.length+1),m.some(_=>_.owner===w))return u("fallback","ambiguous-owner");let oe={source:E,target:y,from:0,to:N.flat.text.length,targetFrom:Ae},xe=Bn({base:N.flat,side:V.flat,retained:[],transfers:[{from:oe.from,to:oe.to,target:Ae,destination:w}],budget:i});if(xe.status!=="ready"||xe.covers(oe.from,oe.to)!==!0)return u("fallback",xe.reason||"work-limit");let $e=[{unit:E,model:N,from:0,to:N.flat.text.length},null,null];$e[c+1]={unit:y,model:V,from:Ae,to:Ae+N.flat.text.length},$e[2-c]={unit:S,model:C,from:0,to:C.flat.text.length};let ae=[U,null,null];ae[c+1]=V,ae[2-c]=Ne;let k=[w,null,null];k[c+1]=y,k[2-c]=$,m.push({side:c,parent:e,source:E,target:y,owner:w,owners:k,ownerModels:ae,native:$e,models:p,runs:[oe],proof:xe,retained:[{source:w,target:y,from:0,to:U.flat.text.length,targetFrom:De}]})}}return m.length?{status:"ready",reason:null,parent:e,records:m}:u("none")}catch(c){if(c!==a)throw c;return u("fallback","work-limit")}}function Er({describe:e,parentOf:o,...t}){let n=new WeakMap,s=new WeakMap,d=t.budget||Xt(2e4*32),i=r=>{if(!r)return null;if(n.has(r))return n.get(r);n.set(r,{status:"planning",parent:r,records:[]});let l=e(r),u=l?ol({...t,...l,parent:r,budget:d}):{status:"none",reason:null,parent:r,records:[]};if(n.set(r,u),u.status==="ready")for(let b of u.records)s.set(b.owner,[b]);return u};return{get:i,forOwner(r){return i(o(r))?.status==="ready"&&s.get(r)||null}}}function sl(e,o){if(e.side!==0)return null;let t=e.native[0].model,n=e.ownerModels[0],s=e.native[1].from!==0,d=(P,T)=>s?[...P.nodes,...T.nodes]:[...T.nodes,...P.nodes],i=e.ownerModels.reduce((P,T)=>P+T.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(i*8>o.remaining)return null;o.remaining-=i*8;let r={base:d(n,t),local:e.ownerModels[1].nodes,remote:d(e.ownerModels[2],e.native[2].model)},l=ln(r.base),u=e.ownerModels[1].flat,b=ln(r.remote),a=s?n.flat.text.length:0,h=s?0:t.flat.text.length,p=Bn({base:l,side:u,retained:e.retained.map(P=>({from:h+P.from,to:h+P.to,target:P.targetFrom})),transfers:e.runs.map(P=>({from:a+P.from,to:a+P.to,target:P.targetFrom,destination:e.owner})),budget:o});if(p.status!=="ready"||p.covers(0,l.text.length)!==!0)return null;let v=e.ownerModels[2].flat,O=e.native[2].model.flat,m=[];for(let[P,T,x,A]of[[n.flat,v,h,s?0:O.text.length],[t.flat,O,a,s?v.text.length:0]]){let E=ks(P,P,T).remoteMap.bTo,S=-1;for(let N=0;N<P.text.length;N++){if(E[N]<0){S=-1;continue}let C=m.at(-1);S>=0&&C.to===x+N&&C.target+C.to-C.from===A+E[N]?C.to++:(m.push({from:x+N,to:x+N+1,target:A+E[N]}),S=N)}}let c=Bn({base:l,side:b,retained:m,transfers:[],budget:o});if(c.status!=="ready")return null;let g=ks(l,u,b,{},{local:p,remote:c});return g.localEdits.hunks.length?null:(g.localMap=p,g.remoteMap=c,{nodes:r,prepared:g})}function Cr({L:e,R:o,twinIn:t,unitsOf:n,view:s,parentOf:d,ignored:i,remoteWins:r,eligible:l,build:u,out:b,policy:a,provenance:h,textMappers:p,segments:v,conflicts:O,conflict:m,decisions:c}){let g=Xt(2e4*32),P=D=>{let B=0;for(let w=D;w;w=d(w))if(++B>64||w.nodeType===1&&(i(w)||r(w)))return!1;return!0},T=Er({parentOf:d,eligible:l,ignored:i,remoteWins:r,budget:g,describe(D){let B=t(e,D),w=t(o,D);return!B||!w||!P(D)||!P(B)||!P(w)?null:{base:n(D),views:[{A:e,V:s(e,B,D,!1)},{A:o,V:s(o,w,D,!1)}]}}}),x=new WeakSet,A=new WeakMap,E=new WeakSet,S=[];function N(D){if(!D||x.has(D))return;x.add(D);let B=T.get(D);if(B?.status==="ready")for(let w of B.records){if((D.tagName==="TEMPLATE"&&D.content?D.content:D).childNodes.length!==w.native[0].model.nodes.length+1||!w.owners.every(P))continue;let $=sl(w,g);if(!$)continue;let U={record:w,payload:$,state:"planned",output:null,result:null};A.set(w.owner,U),E.add(w.source),E.add(w.native[2].unit),S.push(U)}}function C(D,B){let w=A.get(D);if(!w)return!1;if(!w.result){if(w.result=Fo({...w.payload.nodes,prepared:w.payload.prepared,out:b,policy:a,provenance:h,textMappers:p,conflicts:O,conflict:m,decisions:c,node:B}),w.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");v.push(...w.result.segments),w.decision={kind:"text",node:B,source:"local"},c.push(w.decision)}return w.decision.node=B,B.replaceChildren(...w.result.nodes),w.output=B,w.state="built",!0}function j(D){if(!S.length)return;let B=new WeakSet,w=new WeakMap,y=new WeakMap,$=new WeakMap,U=xe=>xe.tagName==="TEMPLATE"&&xe.content?xe.content:xe,V=(xe,$e)=>{if(!xe)return;if(Array.isArray(xe)){for(let k of xe)V(k,$e);return}let ae=$.get(xe);ae||$.set(xe,ae=[]),ae.push($e)},Ne=(xe,$e=null,ae=!1)=>{B.add(xe),w.set(xe,$e);let k=h.get(xe),_=ae||!!(k&&r(k.remote||k.base));if(y.set(xe,_),k)for(let re of[k.base,k.local,k.remote])V(re,xe);if(!(k?.pinned||k?.unchanged))for(let re of U(xe).childNodes)Ne(re,xe,_)},Ae=xe=>($.get(xe)||[]).find($e=>$e.nodeType===1&&!y.get($e)&&!h.get($e)?.pinned&&!h.get($e)?.unchanged),De=(xe,$e)=>{for(let ae of $.get(xe)||[]){let k=ae;for(;k&&w.get(k)!==$e;)k=w.get(k);if(k)return k}return null},oe=(xe,$e,ae)=>{let k=U($e);for(let _=ae.nextSibling;_;_=_.nextSibling){let re=De(_,$e);if(re){k.insertBefore(xe,re);return}}for(let _=ae.previousSibling;_;_=_.previousSibling){let re=De(_,$e);if(re){k.insertBefore(xe,re.nextSibling);return}}k.appendChild(xe)};Ne(D);for(let xe of S){let{record:$e}=xe,ae=Ae($e.owner)||Ae($e.owners[1])||Ae($e.owners[2]);if(ae)(!xe.result||xe.output!==ae||xe.result.nodes.some(k=>!B.has(k)||w.get(k)!==ae)||ae.textContent!==xe.result.text)&&(C($e.owner,ae),Ne(ae,w.get(ae),y.get(ae)));else{let k=$e.parent,_=$e.owner,re=null;for(;k&&!re;)re=Ae(k),re||(_=k,k=d(k));if(!re)throw new Error("A cross-parent payload has no allowed surviving parent");ae=xe.output||u($e.owner,$e.owners[1],$e.owners[2],!1),xe.result||C($e.owner,ae),oe(ae,re,_),Ne(ae,re,y.get(re))}xe.state="attached"}}return{ensureParent:N,ensureOwner(D){N(d(D))},consumes(D){return E.has(D)},render:C,drain:j}}var An=/\S/,Lr=/[\p{L}\p{N}]/u;function to(e,o,t,n){if(e?.nodeType!==1||!o(e))return!1;for(let s=e.firstChild;s;s=s.nextSibling)if(n(t,1),s.nodeType!==3)return!1;return!!e.firstChild}function Ms(e,o,t){for(let n=e.parentNode;n;n=n.parentNode)if(t(o,1),n.nodeType===11)return!1;return!0}function Rr(e,o,t,n,s){let d=t(e,n),i=t(o,n),r=null,l=null,u=null,b=null;s(n,d.length+i.length);for(let a of d)Lr.test(a.raw)&&(r||=a,l=a);for(let a of i)Lr.test(a.raw)&&(u||=a,b=a);return!!(r&&u&&(r.raw===u.raw||l.raw===b.raw))}function rl({base:e,V:o,A:t,source:n,original:s,current:d,edited:i,destination:r,at:l,ownLength:u,eligible:b,model:a,tokensOf:h,budget:p,charge:v}){let O=s.flat.text,m=d.flat.text,c=i.flat.text,g=r.flat.text;if(v(p,O.length+m.length+g.length),O.startsWith(m)||O.endsWith(m))return!1;let P=An.test(g.slice(0,l)),T=An.test(g.slice(l+u));if(P===T)return!1;let x=P?0:l+u,A=P?l:g.length;for(;x<A&&!An.test(g[x]);)x++;for(;A>x&&!An.test(g[A-1]);)A--;let E=g.slice(x,A);if(En(E,g,h(r,p),p,v,!0)!==x)return!1;let S=En(E,O,h(s,p),p,v,!0);if(S<0)return!1;let N=S+E.length,C=!An.test(O.slice(0,S)),j=!An.test(O.slice(N));if(C===j||En(E,m,h(d,p),p,v,!1)>=0)return!1;let D=C?O.slice(N):O.slice(0,S),B=C?c.length-D.length:0;if(v(p,O.length+c.length),B<0||!An.test(D)||En(D,c,h(i,p),p,v,!0)!==B||!An.test(C?c.slice(0,B):c.slice(D.length)))return!1;for(let w of e){if(v(p,1),w===n||!to(w,b,p,v))continue;let y=a(w,null,p);if(En(E,y.flat.text,h(y,p),p,v,!1)>=0)return!1}for(let w of o.units){if(v(p,1),w===d.unit||w===r.unit||!to(w,b,p,v))continue;let y=a(w,t,p);if(En(E,y.flat.text,h(y,p),p,v,!1)>=0)return!1}return!0}function Pr({base:e,views:o,side:t,attempt:n,eligible:s,blocked:d,baseId:i,model:r,tokensOf:l,charge:u,exhausted:b,limit:a}){if(a<=0)return null;let h=Xt(a),{V:p,A:v,idOf:O}=o[t],m=o[1-t],[c,g,P,T]=n,x=null;try{for(let A=c;A<=g;A++){u(h,1);let E=e[A];if(E.parentNode?.nodeType!==1||d.has(E)||v.identical.has(E)||m.A.identical.has(E)||!to(E,s,h,u)||i(E))continue;let S=p.twin(E),N=m.V.twin(E);if(!S||!N||!p.here(S)||!m.V.here(N)||v.map.get(E)!==S||v.reverse.get(S)!==E||m.A.map.get(E)!==N||m.A.reverse.get(N)!==E||O(S)||m.idOf(N)||S.tagName!==E.tagName||N.tagName!==E.tagName||!to(S,s,h,u)||!to(N,s,h,u)||!Ms(E,h,u)||!Ms(S,h,u)||!Ms(N,h,u))continue;let C=r(E,null,h),j=r(S,v,h),D=r(N,m.A,h),B=C.flat.text,w=j.flat.text,y=D.flat.text;if(u(h,B.length+w.length+y.length),!An.test(B)||!An.test(w)||!An.test(y)||B===w||B===y||w===y||!Rr(C,j,l,h,u)||!Rr(C,D,l,h,u))continue;let $=null,U=!1;for(let Ae=P;Ae<=T;Ae++){u(h,1);let De=p.units[Ae],oe=p.baseOf(De);if(!oe||oe===E||d.has(oe)||oe.parentNode!==E.parentNode||De.parentNode!==S.parentNode||oe.tagName!==E.tagName||De.tagName!==E.tagName||v.map.get(oe)!==De||v.reverse.get(De)!==oe||i(oe)!==O(De)||!to(oe,s,h,u)||!to(De,s,h,u))continue;let xe=r(oe,null,h),$e=r(De,v,h),ae=xe.flat.text,k=$e.flat.text;if(u(h,ae.length),!An.test(ae)||k.length<=ae.length)continue;let _=l($e,h),re=En(ae,k,_,h,u,!0);if(!(re<0||En(B,k,_,h,u,!0,re,re+ae.length)<0&&!rl({base:e,V:p,A:v,source:E,original:C,current:j,edited:D,destination:$e,at:re,ownLength:ae.length,eligible:s,model:r,tokensOf:l,budget:h,charge:u}))){if($){U=!0;break}$=De}}if(!$||U)continue;let V=t===0?S:N,Ne=t===0?N:S;(x||=[]).push({source:E,local:V,remote:Ne,models:[C,t===0?j:D,t===0?D:j]})}}catch(A){if(A!==b)throw A}return x}var Un=/\S/,bn=/\s/,il=/[\s\u001e]/g,Os=/[^\s\p{P}\u001e\ufffc]/u;function ll(e,o,t,n,s,d,i){let r=0;for(let l of e)i(d,1),l.nodeType===1&&!n.baseOf(l)&&r++;if(r<2)return!1;for(let l of e){if(l.nodeType!==1||n.baseOf(l))continue;let u=s.get(l).flat;if(u.atoms.length||u.pins?.length)continue;i(d,u.text.length*2+o.length+t.length);let b=new Uint8Array(u.text.length);for(let a of t)a.target===l&&b.fill(1,a.targetFrom,a.targetFrom+a.to-a.from);for(let a of o)a.target===l&&b.fill(1,a.targetFrom,a.targetFrom+a.to-a.from);for(let a=0;a<u.text.length;a++)if(!b[a]&&Un.test(u.text[a]))return!0}return!1}function al(e,o,t){let{source:n,models:s,retained:d,runs:i}=e,r=s.get(n).flat.text;t(o,r.length*2+d.length+i.length);let l=new Uint8Array(r.length);for(let u of d)u.source===n&&(t(o,u.to-u.from),l.fill(1,u.from,u.to));for(let u of i)t(o,u.to-u.from),l.fill(1,u.from,u.to);for(let u=0;u<r.length;u++)if(!l[u]&&Un.test(r[u]))return!1;return!0}function cl(e,o,t,n,s,d,i,r,l,u){let b=d.get(e),a=d.get(o),h=b.flat.text,p=i.get(e);l(u,h.length*2+t.length);let v=h.length,O=0;for(let g=0;g<h.length;g++)!bn.test(h[g])&&!p[g]&&(v=Math.min(v,g),O=g+1);if(v>=O)return null;for(let g=v;g<O;g++)if(!bn.test(h[g])&&p[g])return null;let m=-1;for(let g of t)if(g.target===o&&g.from<=v&&g.to>v){m=g.targetFrom+v-g.from;break}if(m<0)return null;let c=h.slice(v,O);if(l(u,c.length*(t.length+2)),a.flat.text.slice(m,m+c.length)!==c)return null;for(let g=v;g<O;g++){if(bn.test(h[g]))continue;let P=!1;for(let T of t)if(T.target===o&&T.from<=g&&T.to>g&&T.targetFrom+g-T.from===m+g-v){P=!0;break}if(!P)return null}if(b.flat.atoms.length||a.flat.atoms.length){l(u,b.flat.atoms.length+a.flat.atoms.length);let g=0,P=a.flat.atoms;for(;g<P.length&&P[g].i<m;)g++;for(let T of b.flat.atoms){if(T.i<v||T.i>=O)continue;let x=P[g++];if(!x||x.i!==m+T.i-v||a.alignment?.reverse.get(x.el)!==T.el)return null}if(g<P.length&&P[g].i<m+O-v)return null}for(let[g,P,T]of[[n,e,v],[s,o,m]]){let x=!1;for(let A of g){let E=d.get(A),S=i.get(A),N=r(E,u);for(let C=0;C<N.length;C++){let j=N[C].from,D=j+c.length;if(l(u,c.length*2+1),E.flat.text.slice(j,D)!==c)continue;let B=C;for(;B<N.length&&N[B].to<D;)l(u,1),B++;if(B===N.length||N[B].to!==D)continue;let w=!0;for(let y=j;y<D;y++)if(!bn.test(E.flat.text[y])&&S[y]){w=!1;break}if(w){if(x||A!==P||j!==T)return null;x=!0}}}if(!x)return null}return c}function fl(e,o,t,n,s,d,i,r){if(i(r,s.length+d.length+(n.length+1)*t.length*2),!t)return!1;let l=n.indexOf(t);return l<0||n.lastIndexOf(t)!==l||!d.some(u=>u.from===l)||!d.some(u=>u.to===l+t.length)?!1:s.some(u=>u.source===e&&u.target===o&&u.from===0&&u.to===t.length&&u.targetFrom===l)}function Br({base:e,views:o,eligible:t,baseId:n,ignored:s,remoteWins:d,atomKey:i,limit:r=2e4*8}){if(r<=0)return null;let l=Symbol(),u=(T,x)=>{if(x>T.remaining)throw l;T.remaining-=x},b=[new Map,new Map];for(let T=0;T<2;T++)for(let x=0;x<o[T].V.units.length;x++)b[T].set(o[T].V.units[x],x);let a=new Int32Array(e.length),h=new Int32Array(e.length),p=T=>o.every(({V:x},A)=>{let E=x.twin(T);return E&&b[A].has(E)}),v=-1;for(let T=0;T<e.length;T++)a[T]=v,p(e[T])&&(v=T);v=e.length;for(let T=e.length-1;T>=0;T--)h[T]=v,p(e[T])&&(v=T);let O=new Map,m=(T,x)=>{if(u(x,1),O.has(T))return O.get(T);let A=T.firstChild,E=1;for(;A;){if(u(x,E*8+8),A.nodeType===3&&u(x,A.data.length*8),A.nodeType===1&&vn.has(A.tagName)&&!s(A)&&!d(A)&&A.firstChild){A=A.firstChild,E++;continue}for(;A&&A!==T&&!A.nextSibling;)A=A.parentNode,E--;A=!A||A===T?null:A.nextSibling}let S=ln(Array.from(T.childNodes),{ignored:s,remoteWins:d});return O.set(T,S),S},c=(T,x,A,E,S,N)=>{for(let C of T.atoms){u(N,1);let j=x.atomAt.get(C.i+A);if(!j)return!1;let D=E?.reverse.get(C.el)||i(C.el),B=S?.reverse.get(j.el)||i(j.el);if(D!==B)return!1}return!0},g=(T,x,A,E,S)=>{let N=T.text.length<=x.text.length?T:x,C=N===T?x:T;if(u(S,N.text.length+C.text.length),!N.text||!Un.test(N.text.replaceAll(Dn,"")))return!1;let j;if(N.text===C.text)j=0;else{let D=C.text.length-N.text.length;if(u(S,(D+1)*N.text.length*2),C.text.startsWith(N.text))j=0;else if(C.text.endsWith(N.text))j=D;else return!1;if(C.text.indexOf(N.text)!==j||C.text.lastIndexOf(N.text)!==j)return!1;u(S,C.text.length*2);let B=0,w=j===0,y=!1;for(let $ of fn(C.text,xn(C.text)))B+=$.len,B===j&&(w=!0),B===j+N.text.length&&(y=!0);if(!w||!y)return!1}return N===T?c(N,C,j,A,E,S):c(N,C,j,E,A,S)},P=null;for(let T=0;T<2;T++){let{V:x,A,idOf:E}=o[T],S=o[1-T];if(!x.asBase)for(let N=0;N<e.length;N++){let C=e[N];if(x.twin(C)||!t(C))continue;let j=S.V.twin(C);if(!j||!b[1-T].has(j)||!t(j))continue;let D={remaining:r};try{let B=a[N],w=h[N],y=0;for(let Ne=B+1;Ne<w;Ne++)u(D,1),!x.twin(e[Ne])&&S.V.twin(e[Ne])&&t(e[Ne])&&y++;if(y!==1||m(C,D).text===m(j,D).text)continue;let $=B<0?-1:b[T].get(x.twin(e[B])),U=w===e.length?x.units.length:b[T].get(x.twin(e[w]));if($===void 0||U===void 0||$>=U)continue;let V=null;for(let Ne=$+1;Ne<U;Ne++){u(D,1);let Ae=x.units[Ne];if(x.baseOf(Ae)||!t(Ae)||Ae.tagName!==C.tagName||Ae.namespaceURI!==C.namespaceURI)continue;let De=n(C),oe=S.idOf(j),xe=E(Ae);if(!(De&&oe&&De!==oe||De&&xe&&De!==xe||oe&&xe&&oe!==xe)&&g(m(j,D),m(Ae,D),S.A,A,D)){if(V){V=null;break}V=Ae}}if(!V)continue;P||(P=[new Map,new Map]),P[T].set(C,V)}catch(B){if(B!==l)throw B}}}return P?o.map(({V:T},x)=>{let A=P[x];if(!A.size)return T;let E=new Map;for(let[S,N]of A)E.set(N,S);return{...T,twin:S=>A.get(S)||T.twin(S),baseOf:S=>E.get(S)||T.baseOf(S)}}):null}function Dr({onUncertainSource:e,onUncertainOwner:o,base:t,views:n,eligible:s,ignored:d,remoteWins:i,baseId:r,atomKey:l,limit:u=2e4*32}){if(u<=0)return null;let b=new Set(t),a=new Map(t.map((B,w)=>[B,w])),h=new Map,p=[],v=null,O=null,m=null,c=new Set;for(let B of t)for(let{V:w}of n){let y=w.twin(B);y&&!w.asBase&&!w.here(y)&&c.add(B)}let g=new Set,P=Symbol(),T=(B,w)=>{if(w>B.remaining)throw P;B.remaining-=w},x=(B,w,y)=>{T(y,1);let $=h.get(B);if($)return $;if(B.nodeType===1){let Ne=B.firstChild,Ae=1;for(;Ne;){if(T(y,Ae*8+8),Ne.nodeType===3&&T(y,Ne.data.length*8),Ne.nodeType===1&&vn.has(Ne.tagName)&&!d(Ne)&&!i(Ne)&&Ne.firstChild){Ne=Ne.firstChild,Ae++;continue}for(;Ne&&Ne!==B&&!Ne.nextSibling;)Ne=Ne.parentNode,Ae--;Ne=!Ne||Ne===B?null:Ne.nextSibling}}else T(y,B.value.length*8+B.nodes.length);let U=B.nodeType===1?Array.from(B.childNodes):B.nodes,V=U.length===1&&U[0].nodeType===3?{text:U[0].data,nodes:[{node:U[0],s:0,e:U[0].data.length}],atoms:[]}:ln(U,{ignored:d,remoteWins:i});return $={unit:B,flat:V,alignment:w,tokens:null},h.set(B,$),$},A=(B,w)=>{if(B.tokens)return B.tokens;T(w,B.flat.text.length*8);let{unit:y,flat:$,alignment:U}=B,V=[],Ne=xn($.text),Ae=0,De=oe=>{for(let xe of fn($.text.slice(Ae,oe),Ne))xe.from=Ae,xe.to=Ae+xe.len,xe.unit=y,V.push(xe),Ae+=xe.len};for(let oe of $.atoms){De(oe.i);let xe=i(oe.el)&&oe.el.nodeType===1?"w"+oe.el.tagName+"#"+(oe.el.id||""):l(U?.reverse.get(oe.el)||oe.el);V.push({k:xe,raw:Dn,len:1,from:Ae,to:Ae+1,unit:y,atom:!0}),Ae++}return De($.text.length),B.tokens=V,V},E=(B,w,y,$,U)=>{if(!B.flat.atoms.length&&!w.flat.atoms.length)return!0;let V=A(B,U),Ne=A(w,U);T(U,V.length+Ne.length);let Ae=0;for(let De of Ne){if(!De.atom||De.from<y||De.from>=y+$)continue;for(;Ae<V.length&&!V[Ae].atom;)Ae++;let oe=V[Ae++];if(!oe||oe.from!==De.from-y||oe.k!==De.k)return!1}for(;Ae<V.length;)if(V[Ae++].atom)return!1;return!0},S=(B,w,y)=>{let $=B.length+w.length+4;if($*8>y.remaining)return null;y.remaining-=$*8;let U=Math.floor(y.remaining/8),V=Math.min(B.length+w.length,4e3,Math.floor((Math.sqrt($*$+U)-$)/2)),Ne=4*(V+1)*($+V+1);if(V<1||Ne>y.remaining)return null;y.remaining-=Ne;let Ae=Hn(B,w,V),De=[],oe=0,xe=0;for(let $e of Ae.hunks){for(;oe<$e.bs;)B[oe].raw===w[xe].raw&&De.push([B[oe],w[xe]]),oe++,xe++;oe=$e.be,xe+=$e.toks.length}for(;oe<B.length&&xe<w.length;)B[oe].raw===w[xe].raw&&De.push([B[oe],w[xe]]),oe++,xe++;return De},N=(B,w,y,$,U,V,Ne)=>{if(U<=$)return;let Ae=B[B.length-1];if(Ae&&Ae.source===w&&Ae.target===y&&Ae.to<=$&&Ae.targetFrom-Ae.from===V-$){T(Ne,($-Ae.to)*3);let De=h.get(w).flat.text,oe=h.get(y).flat.text,xe=!0;for(let $e=Ae.to;$e<$;$e++)if(!bn.test(De[$e])||De[$e]!==oe[V+$e-$]){xe=!1;break}if(xe){Ae.to=U;return}}B.push({source:w,target:y,from:$,to:U,targetFrom:V})},C=B=>B.replace(il,"");for(let B=0;B<n.length;B++){let{V:w,A:y,idOf:$}=n[B];if(w.asBase)continue;let U=new Map(w.units.map((k,_)=>[k,_])),V=k=>{let _=w.twin(k);return _&&U.has(_)?_:null},Ne=(k,_)=>{let re=new Int32Array(k.length),Z=new Int32Array(k.length),Be=-1;for(let Ke=0;Ke<k.length;Ke++)re[Ke]=Be,_(k[Ke])&&(Be=Ke);Be=k.length;for(let Ke=k.length-1;Ke>=0;Ke--)Z[Ke]=Be,_(k[Ke])&&(Be=Ke);return{prev:re,next:Z}},Ae=Ne(t,k=>(k.nodeType===1||k.kind==="text"&&Un.test(k.value))&&V(k)),De=Ne(w.units,k=>(k.nodeType===1||k.kind==="text"&&Un.test(k.value))&&b.has(w.baseOf(k))),oe=new Map,xe=(k,_,re,Z)=>{if(k>_||re>Z)return;let Be=`${k}:${_}:${re}:${Z}`;oe.set(Be,[k,_,re,Z])};for(let k=0;k<w.units.length;k++){let _=w.units[k];if(w.baseOf(_)||!s(_))continue;let re=De.prev[k],Z=De.next[k],Be=re<0?0:a.get(w.baseOf(w.units[re])),Ke=Z===w.units.length?t.length-1:a.get(w.baseOf(w.units[Z]));xe(Be,Ke,Math.max(0,re),Math.min(w.units.length-1,Z))}for(let k=0;k<t.length;k++){let _=t[k];if(c.has(_)||!s(_))continue;if(!w.twin(_)){let it=Ae.prev[k],et=Ae.next[k],mt=it<0?0:U.get(V(t[it])),Ze=et===t.length?w.units.length-1:U.get(V(t[et]));xe(Math.max(0,it),Math.min(t.length-1,et),mt,Ze)}let re=V(_);if(!re||y.identical.has(_)||!s(re))continue;let Z=k+1;for(;Z<t.length&&t[Z].kind==="text"&&!t[Z].value.trim();)Z++;if(Z>=t.length||!s(t[Z]))continue;let Be=V(t[Z]);if(!Be||y.identical.has(t[Z])||!s(Be))continue;let Ke=U.get(re),Te=U.get(Be);Ke<Te&&xe(k,Z,Ke,Te)}let $e=Array.from(oe.values()),ae=new Set;if($e.length>1){let k=Xt(u);try{T(k,$e.length*4);let _=$e.slice().sort((Be,Ke)=>(T(k,1),Be[0]-Ke[0]||Be[2]-Ke[2])),re=[],Z=null;for(let Be of _)T(k,1),Z&&Be[0]<=Z[1]&&Be[2]<=Z[3]&&Be[3]>=Z[2]?(Z[1]=Math.max(Z[1],Be[1]),Z[2]=Math.min(Z[2],Be[2]),Z[3]=Math.max(Z[3],Be[3]),Z[4].push(Be)):(Z?.[4].length>1&&re.push(Z),Z=[Be[0],Be[1],Be[2],Be[3],[Be]]);Z?.[4].length>1&&re.push(Z),$e=re.concat($e)}catch(_){if(_!==P)throw _}}for(let k of $e){if(ae.has(k))continue;let[_,re,Z,Be,Ke]=k,Te=Xt(u),it=[],et=new Set,mt=!1;try{T(Te,(re-_+Be-Z+2)*4);let Ze=t.slice(_,re+1).filter(Q=>!y.identical.has(Q)&&s(Q)&&!c.has(Q)),ft=w.units.slice(Z,Be+1).filter(Q=>s(Q)&&(!w.baseOf(Q)||b.has(w.baseOf(Q)))&&!y.identical.has(w.baseOf(Q))&&!c.has(w.baseOf(Q))),Ct=new Set(ft),Dt=!1,Tt="",Rt="",jt=0;for(let Q of Ze){let Oe=x(Q,null,Te);Tt+=Oe.flat.text,jt+=Oe.flat.text.length}for(let Q of ft){let Oe=x(Q,y,Te);Rt+=Oe.flat.text,jt+=Oe.flat.text.length}T(Te,jt);let qt=C(Tt),un=C(Rt),Lt=qt===un;if(mt=Lt,Ke&&!Lt)continue;let Jt=Lt?null:new Map;if(Jt)for(let Q of Ze.concat(ft)){let Oe=h.get(Q).flat.text.length;T(Te,Oe*16),Jt.set(Q,new Uint8Array(Oe))}let F=Q=>{let Oe=[];for(let Ve of Q){let Ce=h.get(Ve);Ce.flat.atoms.length?Oe.push(...A(Ce,Te)):Oe.push({unit:Ve,raw:Ce.flat.text,from:0})}return Oe},ce=[];for(let Q of Lt?[]:Ze){let Oe=V(Q);if(!Ct.has(Oe))continue;let Ve=x(Q,null,Te),Ce=x(Oe,y,Te);T(Te,Ve.flat.text.length+Ce.flat.text.length);let be=Ve.flat.text&&Ce.flat.text.startsWith(Ve.flat.text)?0:Ve.flat.text&&Ce.flat.text.endsWith(Ve.flat.text)?Ce.flat.text.length-Ve.flat.text.length:-1;if(be>=0&&E(Ve,Ce,be,Ve.flat.text.length,Te)){Jt.get(Q).fill(1),Jt.get(Oe).fill(1,be,be+Ve.flat.text.length),N(ce,Q,Oe,0,Ve.flat.text.length,be,Te);continue}let H=S(A(Ve,Te),A(Ce,Te),Te);if(!H){Dt=!0;break}for(let[X,de]of H)Jt.get(Q).fill(1,X.from,X.to),Jt.get(Oe).fill(1,de.from,de.to),N(ce,Q,Oe,X.from,X.to,de.from,Te)}if(Dt)continue;let ge=null,Le=null;if(!Lt)for(let Q of Ze){let Oe=V(Q),Ve=h.get(Q);if(!Oe||Ve.flat.atoms.length||!Ct.has(Oe))continue;let Ce=Ve.flat.text,be=Jt.get(Q);T(Te,Ce.length*3+ft.length);let H=-1,X=-1,de=!1;for(let He=0;He<Ce.length;He++)bn.test(Ce[He])||(be[He]?de=!0:(H<0&&(H=He),X=He+1));if(!de||H<0)continue;let pe=!0;for(let He=H;He<X;He++)if(be[He]&&!bn.test(Ce[He])){pe=!1;break}if(!pe)continue;let se=C(Ce.slice(H,X)),ke=null,fe=!1;for(let He of ft){if(w.baseOf(He))continue;let Se=h.get(He);if(!Se.flat.atoms.length&&(T(Te,Se.flat.text.length),C(Se.flat.text)===se)){if(ke){fe=!0;break}ke=He}}if(fe){(Le||=new Set).add(Q);continue}if(!ke||Le?.has(Q))continue;let G=!1;for(let He of Ze){if(He===Q||!Ct.has(V(He)))continue;let Se=h.get(He);if(Se.flat.atoms.length)continue;let Je=Jt.get(He);T(Te,Se.flat.text.length*3);let nt="",ot=!1;for(let Wt=0;Wt<Se.flat.text.length;Wt++)bn.test(Se.flat.text[Wt])||(Je[Wt]?ot=!0:nt+=Se.flat.text[Wt]);ot&&nt===se&&(Le||=new Set,Le.add(Q),Le.add(He),G=!0)}if(G)continue;let ue=h.get(ke).flat.text;T(Te,X-H+ue.length);let Ie=H,Pe=0;for(;Ie<X&&Pe<ue.length;){for(;Ie<X&&bn.test(Ce[Ie]);)Ie++;for(;Pe<ue.length&&bn.test(ue[Pe]);)Pe++;if(Ie>=X||Pe>=ue.length)break;N(ge||=[],Q,ke,Ie,Ie+1,Pe,Te),Ie++,Pe++}be.fill(1,H,X),Jt.get(ke).fill(1)}let Me=Q=>{let Oe=[];for(let Ve of Q){let Ce=x(Ve,b.has(Ve)?null:y,Te),be=Jt.get(Ve);for(let H of A(Ce,Te)){let X=H.from;for(;X<H.to;){for(;X<H.to&&be[X];)X++;let de=X;for(;X<H.to&&!be[X];)X++;if(X>de){let pe=Ce.flat.text.slice(de,X);Un.test(pe)&&Oe.push({...H,raw:pe,len:X-de,k:H.atom?H.k:pe,from:de,to:X})}}}}return Oe},M=Lt?F(Ze):Me(Ze),R=Lt?F(ft):Me(ft),z=Lt?qt:M.map(Q=>C(Q.raw)).join(""),J=Lt?un:R.map(Q=>C(Q.raw)).join("");if((!z||!J)&&!ge)continue;let ne=ge||[];if(z&&J&&z===J){let Q=0,Oe=0,Ve=0,Ce=0;for(;Q<M.length&&Oe<R.length;){let be=M[Q],H=R[Oe];for(;Ve<be.raw.length&&bn.test(be.raw[Ve]);)Ve++;for(;Ce<H.raw.length&&bn.test(H.raw[Ce]);)Ce++;if(Ve===be.raw.length){Q++,Ve=0;continue}if(Ce===H.raw.length){Oe++,Ce=0;continue}if((be.atom||H.atom)&&be.k!==H.k){Dt=!0;break}N(ne,be.unit,H.unit,be.from+Ve,be.from+Ve+1,H.from+Ce,Te),Ve++,Ce++}}else if(z&&J){let Q=S(M,R,Te);if(!Q)continue;for(let[Oe,Ve]of Q)N(ne,Oe.unit,Ve.unit,Oe.from,Oe.to,Ve.from,Te)}if(Dt)continue;let je=new Map;for(let Q of ne)if(!Le?.has(Q.source)){if(V(Q.source)===Q.target){Lt&&ce.push(Q);continue}je.has(Q.source)||je.set(Q.source,[]),je.get(Q.source).push(Q)}for(let[Q,Oe]of je){let Ve=x(Q,null,Te),Ce=V(Q),be=Ve.flat.text,H=[],X=new Set,de=n[1-B],pe=de.V.twin(Q),se=pe&&de.V.here(pe)?x(pe,de.A,Te):null,ke=(Se,Je)=>{let nt=A(Se,Te),ot=A(Je,Te);return T(Te,Se.flat.text.length+Je.flat.text.length+nt.length+ot.length),Se.flat.text===Je.flat.text&&nt.length===ot.length&&nt.every((Wt,Ut)=>Wt.k===ot[Ut].k)},fe=Ce&&se&&se.flat.text!==be&&ke(x(Ce,y,Te),se);for(let Se of new Set(Oe.map(Je=>Je.target))){if(Q.nodeType!==1&&Se.nodeType!==1)continue;let Je=x(Se,y,Te),nt=w.baseOf(Se);if(Q.nodeType!==1&&nt||(T(Te,be.length*2+Je.flat.text.length*3+ce.length*2),Ce&&C(be)===C(Je.flat.text)&&x(Ce,y,Te).flat.text.trim()))continue;if(!Ce&&!nt&&Q.nodeType===1&&Se.nodeType===1){let q=r(Q),te=$(Se);if(q&&te&&q!==te)continue}let ot=Je.flat.text,Wt=be&&(ot.startsWith(be)||ot.endsWith(be)),Ut=!1;if(!Ce&&se&&nt&&se.flat.text!==be){let q=x(nt,null,Te).flat.text,te=a.get(Q)<a.get(nt)?se.flat.text:q,me=a.get(Q)<a.get(nt)?q:se.flat.text;T(Te,te.length+me.length+ot.length),Ut=!!te&&!!me&&te.length+me.length<=ot.length&&ot.startsWith(te)&&ot.endsWith(me)&&!ot.slice(te.length,ot.length-me.length).trim()}let I=!Ve.flat.atoms.length&&!se?.flat.atoms.length&&!Je.flat.atoms.length&&(fe&&Wt||Ut);if(Ce&&nt){let q=x(Ce,y,Te).flat.text,te=be.startsWith(q)||be.endsWith(q),me=x(nt,null,Te).flat.text,we=Je.flat.text,ie=we.startsWith(me)||we.endsWith(me),ee=!n[1-B].V.twin(nt)&&!ce.some(Ee=>Ee.source===nt&&Un.test(me.slice(Ee.from,Ee.to)));if(!Lt&&(!te&&!I||!ie&&!ee)){let Ee=cl(Q,Se,Oe,Ze,ft,h,Jt,A,T,Te);if(!Ee)continue;let Ue=y.weak?.has(Q)&&!y.identityPaired?.has(Q)&&be.trim()===Ee;if(!te&&!I&&!Ue)continue;let _e=y.weak?.has(nt)&&!y.identityPaired?.has(nt)&&ot.trim()===Ee&&!h.get(nt).flat.atoms.length&&!ce.some(Ye=>Ye.source===nt&&Un.test(me.slice(Ye.from,Ye.to)));if(!ie&&!ee&&!_e&&!fl(nt,Se,me,ot,ce,A(Je,Te),T,Te))continue;Ue&&X.add(Se)}}I&&X.add(Se),T(Te,Oe.length),H.push(...Oe.filter(q=>q.target===Se))}if(!H.length)continue;let G=new Uint8Array(be.length);T(Te,be.length*4+ce.length);for(let Se of H)G.fill(1,Se.from,Se.to);let ue=[];for(let Se=0;Se<be.length;Se++)bn.test(be[Se])||ue.push(Se);if(!ue.length)continue;let Ie=new Set(H.map(Se=>Se.target));if(!Lt&&Ce&&Ie.size>1&&ll(Ie,ne,ce,w,h,Te,T)){if(m||=new Map,m.set(Q,(m.get(Q)||0)|1<<B),e){let Se=ws({source:Q,side:B,views:n,eligible:s,blocked:c,baseId:r,model:x,tokensOf:A,budget:Te,charge:T});if(Se){T(Te,Se.to-Se.from);let Je=!0;for(let nt=Se.from;nt<Se.to;nt++)if(Un.test(be[nt])&&!G[nt]){Je=!1;break}Je&&(v||=[]).push(Se)}}continue}let Pe=ue.filter(Se=>Os.test(be[Se]));if(!H.some(Se=>Os.test(be.slice(Se.from,Se.to)))&&!ue.every(Se=>G[Se]))continue;if(!Ce&&!Array.from(Ie).some(Se=>X.has(Se))&&!ue.every(Se=>G[Se])&&!(Pe.length&&G[Pe[0]]&&G[Pe[Pe.length-1]]&&Ie.size===1)){let Se=null,Je=0,nt=0,ot=null,Wt=null;if(!Ce&&se&&Q.nodeType===1&&!Ve.flat.atoms.length){let Ut=A(Ve,Te).filter(I=>Os.test(I.raw));T(Te,ft.length+be.length);for(let I of ft){let q=w.baseOf(I);if(!q||q===Q||q.nodeType!==1||I.nodeType!==1||q.tagName!==Q.tagName||I.tagName!==q.tagName)continue;let te=a.get(Q),me=a.get(q),we=!0;for(let gt=Math.min(te,me)+1;gt<Math.max(te,me);gt++){let $t=t[gt];if(T(Te,$t.nodeType===1?1:$t.value.length+1),$t.nodeType===1||$t.value.trim()){we=!1;break}}if(!we)continue;let ie=x(q,null,Te),ee=x(I,y,Te);if(ie.flat.atoms.length||ee.flat.atoms.length)continue;let Ee=ie.flat.text,Ue=ee.flat.text;if(T(Te,Ee.length+Ue.length+be.length),!Ee||!Ut.length)continue;let _e=0,Ye=Ue.length;if(te<me&&Ue.endsWith(Ee))Ye-=Ee.length;else if(te>me&&Ue.startsWith(Ee))_e=Ee.length;else continue;for(;_e<Ye&&bn.test(Ue[_e]);)_e++;for(;Ye>_e&&bn.test(Ue[Ye-1]);)Ye--;let yt=Ue.slice(_e,Ye);if(!(!yt||!(yt.startsWith(Ut[0].raw)||yt.endsWith(Ut[Ut.length-1].raw)))){if(Se){Se=null;break}Se=I,Je=_e,nt=Ye,ot=Ut[0],Wt=Ut[Ut.length-1]}}}if(T(Te,H.length),!Se||!Ie.has(Se)||!H.some(Ut=>Ut.target===Se&&(Ut.from<=ot.from&&Ut.to>=ot.to&&Ut.targetFrom+ot.from-Ut.from===Je||Ut.from<=Wt.from&&Ut.to>=Wt.to&&Ut.targetFrom+Wt.to-Ut.from===nt)))continue}if(Ce&&!(ue.every(Se=>G[Se])&&(Lt||Array.from(Ie).some(Se=>X.has(Se))))&&!ce.some(Se=>Se.source===Q&&Un.test(be.slice(Se.from,Se.to))))continue;let He=!1;if(Lt){T(Te,ce.length+ue.length);for(let Se of ce)Se.source===Q&&(T(Te,Se.to-Se.from),G.fill(1,Se.from,Se.to));He=!0;for(let Se of ue)if(!G[Se]){He=!1;break}}for(let Se of Ie){T(Te,H.length);let Je=H.filter(ot=>ot.target===Se);it.push({side:B,source:Q,target:Se,runs:Je,models:h,retained:ce,conservedSource:He}),Q.nodeType===1&&et.add(Q),Se.nodeType===1&&et.add(Se);let nt=w.baseOf(Se);nt?.nodeType===1&&et.add(nt)}}if(p.push(...it),Ke&&it.length)for(let Q of Ke)ae.add(Q);for(let Q of et)g.add(Q)}catch(Ze){if(Ze!==P)throw Ze}finally{if(o&&!Ke&&!mt){let Ze=Pr({base:t,views:n,side:B,attempt:k,eligible:s,blocked:c,baseId:r,model:x,tokensOf:A,charge:T,exhausted:P,limit:u});Ze&&(O||=[]).push(...Ze)}if(e&&!Ke&&!mt){let Ze=zs({base:t,views:n,side:B,attempt:k,eligible:s,blocked:c,baseId:r,model:x,tokensOf:A,certificates:p,charge:T,exhausted:P,limit:u});Ze&&(v||=[]).push(...Ze)}}}}let j=p.length?new Map:null;for(let B of p){let w=j.get(B.source);w||j.set(B.source,w=[]),w.push(B)}let D=null;if(j){let B=null;for(let[w,y]of j){let $=m?.get(w)||0;if(y.length<2&&!$)continue;let U=0;for(let V of y)V.conservedSource&&(U|=1<<V.side);for(let V of y){if(V.conservedSource)continue;let Ne=1<<V.side,Ae=!0;if(U&Ne)Ae=!1;else if($&Ne){Ae=!1;try{Ae=al(V,B||=Xt(u),T)}catch(De){if(De!==P)throw De}}Ae||(D||=new Set).add(V)}}}if(D){let B=0;for(let w of p)D.has(w)||(p[B++]=w);p.length=B;for(let[w,y]of j){B=0;for(let $ of y)D.has($)||(y[B++]=$);y.length=B,B||j.delete(w)}g.clear();for(let w of p){let{source:y,target:$,side:U}=w;y.nodeType===1&&g.add(y),$.nodeType===1&&g.add($);let V=n[U].V.baseOf($);V?.nodeType===1&&g.add(V)}}if(v){let B=Xt(u),w=!1;for(let y of v){let $=!1,U=j?.get(y.source);if(U&&!w)try{$=bs(y,U,B,T)}catch(V){if(V!==P)throw V;w=!0}$||e(y)}}if(O){let B=new Set,w=Xt(u);try{for(let y of O){if(T(w,1),B.has(y.source))continue;B.add(y.source);let $=!1;for(let U of p)if(T(w,1),U.source===y.source||U.target===y.local||U.target===y.remote){$=!0;break}$||o(y)}}catch(y){if(y!==P)throw y}}for(let B of t)if(g.has(B))for(let{V:w}of n){let y=w.twin(B);y&&w.here(y)&&g.add(y)}return p.length?{blocks:g,certificates:p,certificatesBySource:j,models:h}:null}function jr({certificates:e,scopes:o,flats:t,keys:n,limit:s=2e4*32}){let d=Symbol(),i=Xt(s),r=m=>{if(m>i.remaining)throw d;i.remaining-=m},l=o.map(m=>new Set(m)),u=new Map,b=new Map,a=(m,c)=>{let g=u.get(m);if(g||u.set(m,g=new Map),g.has(c))return g.get(c);r(m.text.length);let P=b.get(c);if(!P){r(c.nodes.length+c.atoms.length),P={nodes:new Map,atoms:new Map};for(let E of c.nodes)P.nodes.set(E.node,E);for(let E of c.atoms)P.atoms.set(E.el,E.i);b.set(c,P)}let{nodes:T,atoms:x}=P,A=new Int32Array(m.text.length).fill(-1);for(let E of m.nodes){let S=T.get(E.node);if(!(!S||E.e-E.s!==S.e-S.s)){r(E.e-E.s);for(let N=E.s;N<E.e;N++)A[N]=S.s+N-E.s}}for(let E of m.atoms){let S=x.get(E.el);S!==void 0&&(A[E.i]=S)}return g.set(c,A),A},h=(m,c,g,P,T)=>{let x=m[m.length-1];x&&x.to===c&&x.target+x.to-x.from===P&&x.kind===T?x.to=g:m.push({from:c,to:g,target:P,kind:T})},p=(m,c,g,P)=>{r((P-g)*4);let T=[],x=g,A=N=>{let C=m.text.slice(x,N);for(let j of fn(C,xn(C)))j.from=x,j.to=x+j.len,T.push(j),x+=j.len},E=0,S=m.atoms.length;for(;E<S;){r(1);let N=E+S>>>1;m.atoms[N].i<g?E=N+1:S=N}for(let N=E;N<m.atoms.length&&m.atoms[N].i<P;N++){r(1);let C=m.atoms[N];A(C.i),T.push({k:c(C),raw:Dn,len:1,from:x,to:x+1}),x++}return A(P),T},v=(m,c,g,P,T,x)=>{if(g===P||T===x)return;if(P-g===x-T){r((P-g)*4);let w=!0;for(let y=g,$=T;y<P;y++,$++){if(t[0].text[y]!==t[c].text[$]){w=!1;break}let U=t[0].atomAt.get(y),V=t[c].atomAt.get($);if(!!U!=!!V||U&&n[0](U)!==n[c](V)){w=!1;break}}if(w){h(m,g,P,T,"retained");return}}let A=p(t[0],n[0],g,P),E=p(t[c],n[c],T,x),S=A.length+E.length+4,N=Math.min(A.length+E.length,4e3,Math.floor((Math.sqrt(S*S+i.remaining/2)-S)/2));if(N<1)throw d;r(4*(N+1)*(S+N+1));let C=Hn(A,E,N),j=0,D=0,B=()=>{let w=A[j++],y=E[D++];r(w.len),w.raw===y.raw&&h(m,w.from,w.to,y.from,"retained")};for(let w of C.hunks){for(;j<w.bs;)B();j=w.be,D+=w.toks.length}for(;j<A.length&&D<E.length;)B()},O=m=>{let c=e.filter(C=>C.side===m-1&&l[0].has(C.source)&&l[m].has(C.target));if(!c.length)return null;let g=[],P=(C,j,D)=>{if(!l[0].has(C.source)||!l[m].has(C.target))return;let B=a(j.get(C.source).flat,t[0]),w=a(j.get(C.target).flat,t[m]);r(C.to-C.from);for(let y=0;y<C.to-C.from;y++){let $=B[C.from+y],U=w[C.targetFrom+y];if($<0||U<0)throw d;h(g,$,$+1,U,D)}},T=new Set;for(let C of c){if(!T.has(C.retained)){T.add(C.retained);for(let j of C.retained)P(j,C.models,"retained")}for(let j of C.runs)P(j,C.models,"transfer")}g.sort((C,j)=>(r(1),C.from-j.from||C.target-j.target));let x=[];for(let C of g){r(1);let j=x[x.length-1];if(j&&C.from<j.to){if(C.target-C.from!==j.target-j.from)throw d;j.to=Math.max(j.to,C.to),C.kind==="transfer"&&(j.kind="transfer")}else x.push(C)}let A=[],E=0,S=0;for(let C of x){if(C.target<S)throw d;v(A,m,E,C.from,S,C.target),A.push(C),E=C.to,S=C.target+C.to-C.from}v(A,m,E,t[0].text.length,S,t[m].text.length);let N=Bn({base:t[0],side:t[m],retained:A.filter(C=>C.kind==="retained"),transfers:A.filter(C=>C.kind==="transfer"),baseAtomKey:n[0],sideAtomKey:n[m],budget:i});if(N.status!=="ready"||!N.monotone)throw d;return N};try{let m=O(1),c=O(2);return m||c?{local:m,remote:c}:{fallback:!0}}catch(m){if(m!==d)throw m;return{fallback:!0}}}function Is(e,o,t=!1){let n=-1,s=-1;for(let i=0;i<e.list.length;i++){let r=e.list[i];r.bLo<o.lo||r.bLo>o.hi||(n<0&&(n=i),s=i)}let d=[];for(let i=n;i>=0&&i<=s;i++){let r=e.list[i],l=!t&&i===n?r.inlineStart<0?r.to:r.inlineStart:r.from,u=!t&&i===s?r.inlineEnd<0?r.from:r.inlineEnd:r.to;for(let b=l;b<u;b++)d.push(e.units[b]);i<s&&d.push(e.units[r.next])}return d}var ut=e=>!!e&&e.nodeType===1,Ln=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function Es(e){for(let o of e)if(Ln.has(o.tagName))return!0;return!1}function ul(e,o,t){let n=null;for(let s of o.childNodes)if(!(!ut(s)||!t(s)||!s.isEqualNode(e))){if(n)return null;n=s}if(!n)return null;for(let s of e.parentNode.childNodes)if(s!==e&&s.isEqualNode(e))return null;return n}var Io="[id],[data-id],script,head>*";function Cs(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=fo(t,e);if(n)return"merge:"+n.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?br(t,o):null}}function Jo(e,o,t,n){let s=n.ignored,d=n.stats||Fn(),i=Ws({ignored:s,ignoreAttribute:n.ignoreAttribute,stats:d}),{unitsOf:r,meta:l}=i,u=n.baseURI,b=n.mergeTags!==null,a=Cs(n.mergeTags,u),h=I=>q=>{let te=a(q);return te!==null?te:I(q)},p=h(n.identity.base),v=h(n.identity.local),O=h(n.identity.remote),m=n.authored||n.identity,c=I=>I&&I.nodeType===9?I.documentElement:I,g=c(e),P=c(o),T=c(t),x=globalThis.__hyperMorphProfile,A=x?performance.now():0,E=I=>I===kn?Io:null,S=n.scope||null,N=S?S.baseDropped:new Set,C=new Set,j=S?S.remoteDropped:new Set,D=S?S.baseIndex:Uo(g,p,s,E(n.identity.base),N),B=n.localIsBase||g===P?null:Uo(P,v,s,E(n.identity.local),C),w=S?S.remoteIndex:Uo(T,O,s,E(n.identity.remote),j),y=I=>{let q=ut(I)&&v(I);return q&&B?.get(q)===I&&!D.has(q)?q:null},$=I=>{let q=ut(I)&&O(I);return q&&w.get(q)===I&&!D.has(q)?q:null},U=B?as(g,P,{analyzer:i,baseIndex:D,sideIndex:B,baseId:m.base,sideId:m.local,baseKey:p,sideKey:v,baseDropped:N,sideDropped:C,stats:d}):Vr(),V=as(g,T,{analyzer:i,baseIndex:D,sideIndex:w,baseId:m.base,sideId:m.remote,baseKey:p,sideKey:O,baseDropped:N,sideDropped:j,stats:d,scope:S,comparisons:n.comparisons});if(S){if(!S.held(V))return null;for(let I of S.dropped)is(I)}let Ne=null;function Ae(I){if(!Ne){Ne=new WeakMap;let q=[g];for(;q.length;){let te=q.pop();te.tagName==="TEMPLATE"&&te.content&&Ne.set(te.content,te);for(let me of i.childrenOf(te))me.nodeType===1&&q.push(me)}}return Ne.get(I)||null}let De=I=>{let q=ut(I)||I.nodeType?I.parentNode:I.parent;return q&&q.nodeType===11?Ae(q):q};if(V.moved.size){let I=!1;for(let q of Array.from(V.moved))!ut(q)||V.identityPaired.has(q)||!m.base(q)||R(V,De(q))||(V.unpair(q),I=!0);I&&V.rematch()}Me(),M(U,V),M(V,U);for(let I of[U,V])if(I.refused)for(let q of I.refused)I.moved.has(q)||d.ambiguousMoves++;x&&(x.alignTotal=(x.alignTotal||0)+(performance.now()-A),A=performance.now());let oe=g.ownerDocument.implementation.createHTMLDocument(""),xe=new WeakMap,$e=new WeakMap,ae=[],k=[],_=new Set,re=[],Z=new Set,Be=new Set,Ke=new Set,Te=new WeakMap,it=null,et=n.lineage?.locals.length?rr():null,mt=I=>{let q=Fo(I);return q&&et&&et.consume(I.local),q},Ze=n.conflicts||"remote",ft=I=>ae.push(I),Ct=I=>ae.push(I),Dt=Or({roots:{base:g,local:P,remote:T},L:U,R:V,unitsOf:r,provenance:xe,policy:Ze}),Tt=(I,q)=>{k.push(I),q&&Dt.note(I,q)},Rt=null,jt=null,qt=ge(),un=null,Lt=Q(g,U.map.get(g),V.map.get(g),!!n.localIsBase,!!n.childrenOnly);Lt.tagName==="HTML"?oe.replaceChild(Lt,oe.documentElement):oe.body.appendChild(Lt),Rt?.drain(Lt),jt?.drain(Lt),x&&(x.build=(x.build||0)+(performance.now()-A));let Jt=n.childrenOnly?!He(Ie(Lt),Ie(T)):!fe(Lt,T),F=Dt.finish(Lt),ce=et?ir({locals:n.lineage.locals,rec:et,root:Lt,provenance:xe,segments:re,ignored:s}):null;return{doc:oe,root:Lt,provenance:xe,textMappers:$e,decisions:ae,conflicts:k,recoveryLinks:F,localDiverged:Jt,mergedScripts:_,segments:re,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==kn,L:U,R:V,stats:d,lineage:ce};function ge(){let I=new Map,q=new Set;if(n.localIsBase||!U.insertedByHash)return{partner:I,drop:q};let te=U.insertedByHash(),me=V.insertedByHash();if(!te.size||!me.size)return{partner:I,drop:q};let we={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},ie=dt=>{let Qe=0;for(let Mt=dt.parentNode;Mt;Mt=Mt.parentNode)Qe++;return Qe},ee=[],Ee=dt=>{let Qe=dt.textContent.trim();return Qe.split(/\s+/).length>=3||Qe.replace(/\s/g,"").length>=12},Ue=dt=>{let Qe=R(U,dt),Mt=R(V,dt);return Qe&&U.reverse.get(Qe.parentNode)!==dt.parentNode||Mt&&V.reverse.get(Mt.parentNode)!==dt.parentNode},_e=(dt,Qe,Mt)=>{for(let Ht of Mt.parentNode.children){let pn=Ht!==Mt&&dt.reverse.get(Ht);if(pn&&Ue(pn))return!0}let bt=dt.reverse.get(Mt.parentNode);if(bt){for(let Ht of bt.children)if(!R(Qe,Ht)&&!s(Ht))return!0}return!1},Ye=new Map([[U,new Map],[V,new Map]]),yt=(dt,Qe)=>{let Mt=Ye.get(dt),bt=Mt.get(Qe);if(bt===void 0){bt=!1;for(let Ht of Qe.children)if(dt.reverse.has(Ht)||yt(dt,Ht)){bt=!0;break}Mt.set(Qe,bt)}return bt},gt=new Map;for(let dt of me.values())for(let Qe of dt){let Mt=$(Qe);Mt&>.set(Mt,Qe)}for(let dt of te.values())for(let Qe of dt){let Mt=y(Qe),bt=Mt?gt.get(Mt):null;bt&&bt.tagName===Qe.tagName&&!jn(Qe,we)&&!jn(bt,we)&&!n.remoteWins(Qe)&&!n.remoteWins(bt)&&ee.push([Qe,[bt],ie(Qe),!0,!0])}for(let[dt,Qe]of te){let Mt=me.get(dt);if(!Mt)continue;let bt=Qe.length===1&&Mt.length===1;for(let Ht of Qe)!jn(Ht,we)&&!y(Ht)&&ee.push([Ht,Mt,ie(Ht),bt&&(Ee(Ht)||_e(U,V,Ht)||_e(V,U,Mt[0]))])}if(!ee.length)return{partner:I,drop:q};ee.sort((dt,Qe)=>dt[2]-Qe[2]);let $t=new Set,_t=new Set,dn=dt=>{for(let Qe of dt.querySelectorAll("*"))$t.add(Qe)},vt=(dt,Qe)=>dt.reverse.get(Qe.parentNode)||null;for(let[dt,Qe,,Mt,bt]of ee){if($t.has(dt)||_t.has(dt)||bt&&(yt(U,dt)||yt(V,Qe[0])))continue;let Ht=vt(U,dt),pn=wn=>!_t.has(wn)&&!$t.has(wn)&&(bt||wn.tagName===dt.tagName&&!$(wn)&&i.equalUnits(dt,wn)),sn=Qe.find(wn=>Ht&&vt(V,wn)===Ht&&pn(wn))||(Mt?Qe.find(pn):null);if(!sn)continue;_t.add(dt),_t.add(sn);let Zt=Ht&&vt(V,sn)===Ht;(!bt||!Zt||i.equalUnits(dt,sn))&&(dn(dt),dn(sn)),!Zt&&(I.set(dt,sn),I.set(sn,dt),q.add(Ze==="local"?sn:dt))}return{partner:I,drop:q}}function Le(I,q,te){if(Z.add(I),qt.drop.has(I))return null;Z.add(te);let me=q==="local"?I:te,we=q==="local"?te:I,ie;return i.equalUnits(me,we)?(ie=se(me,"local",!0),xe.get(ie).remote=we):ie=pe(me,we),Tt({kind:"structure",el:ie,detail:"both-moved",base:null,local:me,remote:we},{unit:{b:null,l:me,r:we}}),ft({kind:"insert",el:ie,source:"both"}),ie}function Me(){if(!U.weak||!V.weak||!U.weak.size||!V.weak.size||!U.unpair)return;let I=new Map;for(let te of U.weak){let me=R(U,te);ut(te)&&ut(me)&&I.set(i.unitHash(me),te)}let q=!1;for(let te of Array.from(V.weak)){let me=R(V,te);if(!ut(te)||!ut(me))continue;let we=I.get(i.unitHash(me));if(!we||we===te||!U.weak.has(we)||R(U,te)&&R(V,we))continue;let ie=R(U,we);ie.tagName===me.tagName&&i.equalUnits(ie,me)&&(U.unpair(we),V.unpair(te),q=!0)}q&&(U.rematch(),V.rematch())}function M(I,q){if(!I.weak||!I.weak.size||!q.insertedByHash)return;let te=q.insertedByHash();if(!te.size)return;let me=!1;for(let we of Array.from(I.weak)){let ie=R(I,we);if(!ie)continue;let ee=I===U?y(ie):$(ie);if(ee){let Ue=(I===U?w:B)?.get(ee);Ue&&Ue.tagName===ie.tagName&&!q.reverse.has(Ue)&&(I.unpair(we),me=!0);continue}let Ee=te.get(i.unitHash(ie));Ee&&Ee.some(Ue=>Ue.tagName===ie.tagName&&i.equalUnits(Ue,ie))&&(I.unpair(we),me=!0)}me&&I.rematch()}function R(I,q){if(!q)return null;if(I.map.has(q))return I.map.get(q);let te=[],me=De(q);for(;me&&!I.map.has(me);me=De(me))te.push(me);let we=me;if(!we||!I.identical.has(we))return null;I.pairIdenticalChildren(we);for(let ee=te.length-1;ee>=0;ee--)I.pairIdenticalChildren(te[ee]);let ie=I.map.get(q)||null;return ie&&d.lazyTwins++,ie}function z(I,q,te,me){if(ut(I)&&Ln.has(I.tagName)&&!U.identical.has(I)&&(I.previousSibling?.nodeType===3||I.nextSibling?.nodeType===3)){let Ee=De(I),Ue=R(U,I),_e=R(V,I);Ue&&_e&&Wt(Ue,R(U,Ee),U)&&!Wt(_e,R(V,Ee),V)&&(jt||=Cr({L:U,R:V,twinIn:R,unitsOf:r,view:J,parentOf:De,ignored:s,remoteWins:n.remoteWins,eligible:Ye=>ut(Ye)&&Ln.has(Ye.tagName),build:Q,out:oe,policy:Ze,provenance:xe,textMappers:$e,segments:re,conflicts:k,conflict:Tt,decisions:ae}),jt.ensureOwner(I))}if(q===null)return null;if(me!==void 0)return Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(I,q,te,!!me),me&&(Rt.produced(I,me),Be.add(I)),me;if(Be.has(I)||Ke.has(I))return Tt({kind:"structure",el:null,detail:"both-moved",base:I},{subject:I}),Be.has(I)?null:se(te,q);Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(I,q,te,!0);let we=R(U,I),ie=R(V,I);(!we||!ie)&&Tt({kind:"structure",el:null,detail:"move-beats-delete",base:I},{subject:I,deleted:we?"remote":"local"});let ee=Q(I,we,ie,!1);return(q==="local"?ft:Ct)({kind:"move",el:ee,source:q}),ee}function J(I,q,te,me){return me||!q||q===te?{el:te,asBase:!0,twin:we=>we,baseOf:we=>we,units:r(te),here:()=>!0,parentOfTwin:()=>te}:{el:q,asBase:!1,twin:we=>R(I,we),baseOf:we=>I.reverse.get(we),units:r(q),here:we=>ut(we)?we.parentNode===q||q.tagName==="TEMPLATE"&&we.parentNode===q.content:we.parent===q||q.tagName==="TEMPLATE"&&we.parent===q.content}}function ne(I,q,te){return!q||te&&te.identical.has(I)?!1:ut(I)?!i.equalUnits(I,q)||!je(I,q,te):I.value!==q.value}function je(I,q,te){if(!te||I===q)return!0;let me=[[I,q]];for(;me.length;){let[we,ie]=me.pop(),ee=r(we),Ee=r(ie);for(let Ue=0;Ue<ee.length&&Ue<Ee.length;Ue++){let _e=ee[Ue],Ye=Ee[Ue];if(!ut(_e)||!ut(Ye))continue;let yt=te.map.get(_e);if(yt!==void 0&&yt!==Ye)return!1;let gt=te.reverse.get(Ye);if(gt!==void 0&>!==_e)return!1;me.push([_e,Ye])}}return!0}function Q(I,q,te,me,we=!1){let ie=me||(te?n.remoteWins(te):n.remoteWins(I)),ee=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?oe.createElementNS(I.namespaceURI,I.tagName):oe.createElement(I.tagName),Ee={base:I,local:q||null,remote:te||null};if(xe.set(ee,Ee),ie&&!me&&q&&ne(I,q,U)&&(!te||!i.equalUnits(q,te))&&Tt({kind:"structure",el:ee,detail:"remote-wins",base:I,local:q,remote:te||null},{subject:I}),Z.add(I),Be.add(I),q&&Z.add(q),te&&Z.add(te),n.skipUnchanged&&!we&&(n.localIsBase||U.identical.has(I))&&te&&V.identical.has(I)&&!n.remoteWins(I)){Ee.unchanged=!0;for(let _e of I.attributes)_e.namespaceURI?ee.setAttributeNS(_e.namespaceURI,_e.name,_e.value):ee.setAttribute(_e.name,_e.value);return Rt?.produced(I,ee),ee}Ke.add(I),we||Ce(I,ie?I:q,te,ee);let Ue=I.tagName;if(mn(I))Ve(I,ie?I:q,te,ee);else if(Ue==="TEXTAREA")ee.textContent=Oe(I.textContent,(ie?I:q)?(ie?I:q).textContent:I.textContent,te?te.textContent:I.textContent,ee,"text");else if(!jt?.render(I,ee)){let _e=ke(I,q,te,ie,ee),Ye=Ue==="TEMPLATE"&&ee.content?ee.content:ee;for(let yt of _e)Ye.appendChild(yt)}return Ke.delete(I),Rt?.produced(I,ee),ee}function Oe(I,q,te,me,we){if(q===te)return q;if(q===I)return te!==I&&Ct({kind:we,node:me,source:"remote"}),te;if(te===I)return ft({kind:we,node:me,source:"local"}),q;let ie=Ze==="local"?q:te;return Tt({kind:we,node:me,base:I,local:q,remote:te,resolved:ie},{site:"whole",el:me}),ae.push({kind:we,node:me,source:"both"}),ie}function Ve(I,q,te,me){let we=I.textContent,ie=q?q.textContent:we,ee=te?te.textContent:we,Ee=b?fo(I,n.mergeTags,!0):null;if(Ee&&ie!==ee){let Ue=te&&te.getAttribute("merge-key")||I.getAttribute("merge-key"),{text:_e,warnings:Ye}=Go(n.localIsBase?void 0:we,ie,ee,{parse:Ee.recognizer.parse,keyCandidates:Ue?Ue.split(/[\s,]+/).filter(Boolean):void 0});for(let yt of Ye)console.warn(`[hyper-morph] merge "${Ee.raw}": ${yt}`);me.textContent=_e,_.add(me),_e!==ee?ft({kind:"text",node:me,source:_e===ie?"local":"both"}):_e!==we&&Ct({kind:"text",node:me,source:"remote"});return}me.textContent=Oe(we,ie,ee,me,"text")}function Ce(I,q,te,me){let we=new Map;for(let ie of[I,q,te])if(ie)for(let ee of ie.attributes)n.ignoreAttribute(ie,ee.name)||we.set(ee.name,ee);for(let[ie,ee]of we){let Ee=I?I.getAttribute(ie):null,Ue=q?q.getAttribute(ie):Ee,_e=te?te.getAttribute(ie):Ee,Ye;Ue===_e?Ye=Ue:Ue===Ee?(Ye=_e,Ct({kind:"attr",el:me,name:ie,source:"remote"})):_e===Ee?(Ye=Ue,ft({kind:"attr",el:me,name:ie,source:"local"})):(Ye=be(ie,Ee,Ue,_e),Ye===void 0&&(Ye=Ze==="local"?Ue:_e,Tt({kind:"attr",el:me,name:ie,base:Ee,local:Ue,remote:_e,resolved:Ye},{el:me,sample:ee})),ae.push({kind:"attr",el:me,name:ie,source:"both"})),Ye!=null&&(ee.namespaceURI?me.setAttributeNS(ee.namespaceURI,ee.name,Ye):me.setAttribute(ie,Ye))}}function be(I,q,te,me){if(I==="class"){let we=_e=>new Set((_e||"").split(/\s+/).filter(Boolean)),ie=we(q),ee=we(te),Ee=we(me),Ue=new Set;for(let _e of new Set([...ie,...ee,...Ee])){let Ye=ie.has(_e),yt=ee.has(_e),gt=Ee.has(_e);(yt===gt?yt:yt===Ye?gt:yt)&&Ue.add(_e)}return[...Ue].join(" ")}if(I==="style"){let we=Ye=>{let yt=new Map;if(!Ye)return yt;let gt=0,$t=null,_t="",dn=()=>{let vt=_t.indexOf(":");vt>0&&yt.set(_t.slice(0,vt).trim(),_t.slice(vt+1).trim()),_t=""};for(let vt of Ye){if($t){_t+=vt,vt===$t&&($t=null);continue}if(vt==='"'||vt==="'"){$t=vt,_t+=vt;continue}if(vt==="("?gt++:vt===")"&>--,vt===";"&>===0){dn();continue}_t+=vt}return _t.trim()&&dn(),yt},ie=we(q),ee=we(te),Ee=we(me),Ue=new Map,_e=!1;for(let Ye of new Set([...ie.keys(),...ee.keys(),...Ee.keys()])){let yt=ie.get(Ye)??null,gt=ee.get(Ye)??null,$t=Ee.get(Ye)??null,_t;gt===$t?_t=gt:gt===yt?_t=$t:$t===yt?_t=gt:(_t=Ze==="local"?gt:$t,_e=!0),_t!=null&&Ue.set(Ye,_t)}return _e?void 0:[...Ue].map(([Ye,yt])=>`${Ye}: ${yt}`).join("; ")}}function H(I,q,te,me){let we=I.value,ie=me?we:q?q.value:"",ee=te?te.value:"";Z.add(I),q&&Z.add(q),te&&Z.add(te);let Ee=ro(we,ie,ee,Ze),Ue=Ee.text===""?null:oe.createTextNode(Ee.text);Ue&&(xe.set(Ue,{base:I.nodes,local:q?q.nodes:null,remote:te?te.nodes:null}),$e.set(Ue,Ee.mapLocalOffset)),ie!==we&&ee!==we?ae.push({kind:"text",node:Ue,source:"both"}):ie!==we?ft({kind:"text",node:Ue,source:"local"}):ee!==we&&Ct({kind:"text",node:Ue,source:"remote"});for(let _e of Ee.conflicts)Tt({kind:"text",node:Ue,base:we.slice(_e.bs,_e.be),local:_e.local,remote:_e.remote,resolved:_e.resolved},{site:"run",bRun:I,lRun:q,rRun:te,node:Ue,c:_e});return Ue}function X(I,q){return _n(I,q).every(te=>te.bs===te.be)}function de(I,q){let te=I?I.value:"",me=q?q.value:"",we;if(te===me||!me?we=te:te?X(te,me)?we=me:X(me,te)?we=te:(we=Ze==="local"?te:Ze==="both"?te+me:me,Tt({kind:"structure",el:null,detail:"insert-collision",local:te,remote:me,resolved:we},{unit:{b:null,l:I,r:q},localLost:Ze==="remote"})):we=me,I&&Z.add(I),q&&Z.add(q),we==="")return null;let ie=oe.createTextNode(we);return xe.set(ie,{base:null,local:I?I.nodes:null,remote:q?q.nodes:null}),te?ft({kind:"insert",el:ie,source:me&&te===me?"both":"local"}):Ct({kind:"insert",el:ie,source:"remote"}),ie}function pe(I,q){let te={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},me=Ee=>r(Ee).every(Ue=>ut(Ue)?jn(Ue,te):Ue.kind==="text"),we=null;if(me(I)&&me(q)){let Ee=I.textContent,Ue=q.textContent;Ee===Ue||X(Ue,Ee)?we=q:X(Ee,Ue)&&(we=I)}if(!we){let Ee=Ze==="local",Ue=se(Ee?I:q,Ee?"local":"remote",!0),_e=xe.get(Ue);return Ee?_e.remote=q:_e.local=I,Tt({kind:"structure",el:Ue,detail:"insert-collision",local:I,remote:q,resolved:Ee?I:q},{unit:{b:null,l:I,r:q},localLost:!Ee}),Ue}let ie=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?oe.createElementNS(I.namespaceURI,I.tagName):oe.createElement(I.tagName);Ce(null,I,q,ie),xe.set(ie,{base:null,local:I,remote:q}),Z.add(I),Z.add(q);let ee=mt({base:Array.from(we.childNodes),local:Array.from(I.childNodes),remote:Array.from(q.childNodes),out:oe,policy:Ze,idOf:{local:v,remote:O},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:xe,textMappers:$e,conflicts:k,conflict:Tt,scope:{base:null,local:I,remote:q,units:[],at:0},synthetic:!0,decisions:ae,node:ie});re.push(...ee.segments);for(let Ee of ee.nodes)ie.appendChild(Ee);return ie}function se(I,q,te=!1){if(!te&&ut(I)){let ee=qt.partner.get(I);if(ee)return Le(I,q,ee)}if(!ut(I)){if(I.value==="")return null;let ee=I.kind==="comment"?oe.createComment(I.value):oe.createTextNode(I.value);return xe.set(ee,{base:null,local:q==="local"?I.nodes:null,remote:q==="remote"?I.nodes:null}),Z.add(I),ee}let me=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?oe.createElementNS(I.namespaceURI,I.tagName):oe.createElement(I.tagName);for(let ee of I.attributes)ee.namespaceURI?me.setAttributeNS(ee.namespaceURI,ee.name,ee.value):me.setAttribute(ee.name,ee.value);xe.set(me,{base:null,local:q==="local"?I:null,remote:q==="remote"?I:null}),Z.add(I);let we=I.tagName==="TEMPLATE"&&me.content?me.content:me,ie=q==="local"?U:V;for(let ee of r(I)){let Ee=ut(ee)?ie.reverse.get(ee):null;if(Ee&&z(Ee,null,null),Ee&&Be.has(Ee)){Tt({kind:"structure",el:null,detail:"both-moved",base:Ee},{subject:Ee});continue}if(Ee&&!Ke.has(Ee)){let _e=R(U,Ee)||null,Ye=R(V,Ee)||null;if(_e||Ye){Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(Ee,q,ee,!0);let yt=Q(Ee,_e,Ye,!1);q==="local"?ft({kind:"move",el:yt,source:"local"}):Ct({kind:"move",el:yt,source:"remote"}),we.appendChild(yt);continue}}let Ue=se(ee,q);Ue&&we.appendChild(Ue)}if(!te&&qt.drop.size&&I.tagName==="DIV"&&!we.firstChild&&!I.attributes.length&&!(q==="local"?v(I):O(I))&&!ie.reverse.has(I)&&!s(I)&&!n.remoteWins(I)){let ee=I.firstChild;if(ee&&ee===I.lastChild&&ut(ee)&&(qt.drop.has(ee)||un?.has(ee)))return(un||=new WeakSet).add(I),null}return me}function ke(I,q,te,me,we){q&&U.identical.has(I)&&U.pairIdenticalChildren(I),te&&V.identical.has(I)&&V.pairIdenticalChildren(I);let ie=J(U,q,I,me),ee=J(V,te,I,!1),Ee=r(I),Ue=new Set(Ee),_e=new Map;for(let le=0;le<Ee.length;le++)_e.set(Ee[le],le);let Ye=[],yt=new Set,gt=new Map,$t=new Set,_t=et&&[],dn=et&&[],vt=new Set,dt=[],Qe=null;if(!ie.asBase&&!ee.asBase&&!U.identical.has(I)&&!V.identical.has(I))for(let le of Ee){if(!ut(le)||!Ln.has(le.tagName))continue;let ze=ie.twin(le),qe=ee.twin(le);ze&&qe&&(!ie.here(ze)||!ee.here(qe))&&z(le,null,null)}vo();let Mt=le=>{let ze=[];for(let qe of le.units){if(vt.has(qe))continue;let st=le.baseOf(qe);st&&Ue.has(st)&&ze.push(st)}return ze},bt=le=>Mt(le).map(ze=>_e.get(ze)),Ht=le=>le.every((ze,qe)=>qe===0||ze>=le[qe-1]),pn=!ie.asBase&&!Ht(bt(ie)),sn=!ee.asBase&&!Ht(bt(ee));pn&&sn&&Tt({kind:"structure",el:we,detail:"both-reordered",base:I},{subject:I,lKept:Mt(ie),rKept:Mt(ee)});let Zt=sn||!pn?{V:ee,A:V,side:"remote",other:ie,otherA:U,otherSide:"local"}:{V:ie,A:U,side:"local",other:ee,otherA:V,otherSide:"remote"};pn?ft({kind:"move",el:null,source:sn?"both":"local",base:I}):sn&&Ct({kind:"move",el:null,source:"remote",base:I});let wn=ie.asBase?[]:ie.units.filter(le=>!ie.baseOf(le)&&!vt.has(le)&&!qt.partner.has(le)),On=ee.asBase?[]:ee.units.filter(le=>!ee.baseOf(le)&&!vt.has(le)&&!qt.partner.has(le)),In=new Map;if(wn.length&&On.length){let le=new Map,ze=new Map;for(let Ge of On){if(ut(Ge)){let St=O(Ge);St&&le.set(St,Ge)}let Xe=i.unitHash(Ge);ze.has(Xe)||ze.set(Xe,[]),ze.get(Xe).push(Ge)}let qe=(Ge,Xe)=>{let St=Ge.units.indexOf(Xe);for(let tt=St-1;tt>=0;tt--){let wt=Ge.baseOf(Ge.units[tt]);if(wt)return wt}return"start"},st=new Map,At=new Map;for(let Ge of On){let Xe=qe(ee,Ge);ut(Ge)?(At.has(Xe)||At.set(Xe,[]),At.get(Xe).push(Ge)):Ge.kind==="text"&&!st.has(Xe)&&st.set(Xe,Ge)}for(let Ge of wn){let Xe=null;if(ut(Ge)){let tt=v(Ge);tt&&le.has(tt)&&!In.has(le.get(tt))&&(Xe=le.get(tt))}else if(Ge.kind==="text"){let tt=st.get(qe(ie,Ge));tt&&!In.has(tt)&&(Xe=tt)}let St=!!y(Ge);if(!Xe&&!St){let tt=ze.get(i.unitHash(Ge));tt&&(Xe=tt.find(wt=>!In.has(wt)&&ut(wt)===ut(Ge)&&(ut(wt)?wt.tagName===Ge.tagName&&!$(wt):wt.kind===Ge.kind)&&i.equalUnits(Ge,wt))||null)}if(!Xe&&ut(Ge)&&!St){let tt=m.local(Ge),wt=(At.get(qe(ie,Ge))||[]).filter(lt=>{let zt=m.remote(lt);return!In.has(lt)&<.tagName===Ge.tagName&&!$(lt)&&!(tt&&zt&&tt!==zt)&&i.similar(Ge,lt)});wt.length===1&&(Xe=wt[0])}Xe&&(In.set(Xe,Ge),In.set(Ge,Xe))}}let Lo=le=>{if(jt?.consumes(le))return null;if(Z.has(le)||Rt?.has(le))return gt.get(le)||null;let ze=ie.twin(le),qe=ee.twin(le),st=ze&&!ie.asBase&&!ie.here(ze),At=qe&&!ee.asBase&&!ee.here(qe);if(st||At){if((!ze||!qe)&&Tt({kind:"structure",el:null,detail:"move-beats-delete",base:le},{subject:le,deleted:ze?"remote":"local"}),!ot(le))return ut(le)?(Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),st&&Rt.plan(le,"local",ze),At&&Rt.plan(le,"remote",qe)):Z.add(le),null;Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le})}if(ze&&!qe&&!ie.asBase&&!ee.asBase&&ut(le)&&Ln.has(le.tagName)&&!n.remoteWins(le)&&!n.remoteWins(ze)&&ne(le,ze,U)&&ul(le,Ie(ee.el),s)){let wt={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},lt=zt=>ut(zt)?jn(zt,wt):zt.kind==="text";if(r(le).every(lt)&&r(ze).every(lt)){let zt=mt({base:[le],local:[ze],remote:[],blocks:new Set([le,ze]),out:oe,policy:Ze,L:U,R:V,idOf:{base:p,local:v,remote:O},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(en,Tn,Kn)=>Q(en,Tn,Kn,!1),cloneUnit:se,mergeAttrs:Ce,atomKey:i.exactUnitKey,moveIn:z,moveBuilt:z,movePlanned:z,provenance:xe,textMappers:$e,conflicts:k,conflict:Tt,scope:{base:I,local:ie.el,remote:ee.el,units:Ee,at:_e.get(le)},decisions:ae,node:we});re.push(...zt.segments),Z.add(le),Z.add(ze);let Et=oe.createDocumentFragment();for(let en of zt.nodes)Et.appendChild(en);return gt.set(le,Et),gt.set(ze,Et),Et}}if(!ze&&!qe)return Z.add(le),Ct({kind:"remove",source:"both",base:le}),null;if(!ze&&!ne(le,qe,V))return Z.add(le),ft({kind:"remove",source:"local",base:le}),null;if(!qe&&!ne(le,ze,U))return Z.add(le),Ct({kind:"remove",source:"remote",base:le}),et&&(et.remove(ze),_t.push({bk:le,lk:ze})),null;let Ge=!ze||!qe,Xe=ie.asBase?R(U,le)||null:ze,St=ee.asBase&&ut(le)&&(V.identityPaired.has(le)||!m.base(le))&&R(V,le)||qe,tt;return ut(le)?tt=Q(le,Xe,St,ie.asBase):le.kind==="comment"?tt=Je(le,Xe,qe,ie.asBase):tt=H(le,Xe,qe,ie.asBase),Z.add(le),tt&&(gt.set(le,tt),ze&>.set(ze,tt),qe&>.set(qe,tt),Ge&&(Tt({kind:"structure",el:tt,detail:"edit-beats-delete",base:le},{subject:le,deleted:ze?"remote":"local"}),ze?ft({kind:"insert",el:tt,source:"local"}):Ct({kind:"insert",el:tt,source:"remote"}))),tt},yo=(le,ze,qe,st)=>{if(jt?.consumes(le))return null;if(Z.has(le))return gt.get(le)||null;let At=ze.baseOf(le);if(At&&Ue.has(At))return vt.has(At)&&!vt.has(le)?Gn(At,le,st):Lo(At);if(At)return Ro(At,le,st);let Ge=In.get(le);if(Ge){let St=st==="local"?le:Ge,tt=st==="local"?Ge:le,wt;return ut(St)?i.equalUnits(St,tt)?(wt=se(St,"local"),wt&&(xe.get(wt).remote=tt)):wt=pe(St,tt):wt=de(St,tt),Z.add(St),Z.add(tt),wt&&(gt.set(St,wt),gt.set(tt,wt),ut(St)&&ft({kind:"insert",el:wt,source:"both"})),wt}let Xe=se(le,st);return Xe&&(gt.set(le,Xe),st==="local"?ft({kind:"insert",el:Xe,source:"local"}):(Ct({kind:"insert",el:Xe,source:"remote"}),et&&ut(le)&&!qt.partner.has(le)&&dn.push({su:le,node:Xe}))),Xe},Gn=(le,ze,qe)=>{let st;return ut(le)?(st=z(le,qe,ze),st&&Z.add(ze)):(st=se(ze,qe),Z.add(ze),st&&(qe==="local"?ft:Ct)({kind:"insert",el:st,source:qe})),st&>.set(ze,st),st},Ro=(le,ze,qe)=>{z(le,null,null);let At=R(qe==="local"?V:U,le),Ge=ze,Xe=At?Wt(At,qe==="local"?te:q,qe==="local"?V:U):!1,St=At&&!Xe&&!Ut(le,At);if(St&&qe===Zt.otherSide)return Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le}),null;if(St&&Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le}),At||Tt({kind:"structure",el:null,detail:"move-beats-delete",base:le},{subject:le,deleted:qe==="local"?"remote":"local"}),Ke.has(le)){Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le});let wt=se(Ge,qe);return wt&>.set(ze,wt),wt}ut(le)&&(Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(le,qe,Ge,!0));let tt=ut(le)?Q(le,qe==="local"?Ge:R(U,le)||null,qe==="remote"?Ge:R(V,le)||null,!1):null;return tt&&(gt.set(le,tt),gt.set(ze,tt),At&>.set(At,tt),qe==="local"?ft({kind:"move",el:tt,source:"local"}):Ct({kind:"move",el:tt,source:"remote"})),tt};for(let le of Zt.V.units){if(vt.has(le)){if(Qe?.has(le)){for(let st of Qe.get(le))yt.has(st)||(Ye.push(st),yt.add(st));continue}let qe=gt.get(le);yt.has(qe)||(Ye.push(qe),yt.add(qe));continue}if(Z.has(le)&&!(gt.get(le)&&yt.has(gt.get(le)))){let qe=Zt.V.baseOf(le);qe&&!Ue.has(qe)&&Tt({kind:"structure",el:null,detail:"both-moved",base:qe},{subject:qe});continue}let ze=yo(le,Zt.V,Zt.A,Zt.side);ze&&!yt.has(ze)&&(Ye.push(ze),yt.add(ze),!Zt.V.baseOf(le)&&!In.has(le)&&!vt.has(le)&&$t.add(ze))}for(let le of dt)yt.has(le.frag)||(Ye.splice(le.previous&&yt.has(le.previous)?Ye.indexOf(le.previous)+1:xo(le.at),0,le.frag),yt.add(le.frag));if(!Zt.other.asBase){let le=Zt.other,ze=Zt.otherSide,qe=Zt.otherA,st=null,At=0,Ge=null;for(let Xe of le.units){let St=gt.get(Xe);if(St&&yt.has(St)){st=St,Ge=null;continue}if(Z.has(Xe)){let lt=le.baseOf(Xe);lt&&!Ue.has(lt)&&Tt({kind:"structure",el:null,detail:"both-moved",base:lt},{subject:lt});continue}let tt=yo(Xe,le,qe,ze);if(!tt)continue;let wt;if(Ge)wt=Ye.indexOf(Ge)+1;else if(st){if(wt=Ye.indexOf(st)+1,ze==="remote")for(;wt<Ye.length&&$t.has(Ye[wt]);)wt++}else wt=At++;Ye.splice(wt,0,tt),yt.add(tt),Ge=tt}}for(let le=0;le<Ee.length;le++){let ze=Ee[le];if(Z.has(ze))continue;let qe=Lo(ze);qe&&Ye.splice(xo(le),0,qe)}return et&&_t.length&&dn.length&&es(),Ye;function es(){if(pn||sn)return;let le=new Set(Ye),ze=lt=>lt&&Ue.has(lt)&&le.has(gt.get(lt))?lt:null,qe=(lt,zt)=>{let Et=[{prev:null,units:[]}];for(let en of lt){let Tn=ze(zt(en));Tn?Et.push({prev:Tn,units:[]}):Et[Et.length-1].units.push(en)}return Et},st=qe(Ee,lt=>lt),At=qe(ee.units,ee.baseOf),Ge=ie.asBase?null:qe(ie.units,ie.baseOf),Xe=lt=>lt.length===st.length&<.every((zt,Et)=>zt.prev===st[Et].prev);if(!Xe(At)||Ge&&!Xe(Ge))return;let St=new Map(_t.map(lt=>[lt.bk,lt])),tt=new Map(dn.map(lt=>[lt.su,lt])),wt=lt=>lt?Ye.indexOf(gt.get(lt)):-1;for(let lt=0;lt<st.length;lt++){if(st[lt].units.length!==1||At[lt].units.length!==1)continue;let zt=St.get(st[lt].units[0]),Et=tt.get(At[lt].units[0]);if(!zt||!Et||Ge&&(Ge[lt].units.length!==1||Ge[lt].units[0]!==zt.lk))continue;let en=wt(st[lt].prev);(lt+1<st.length?wt(st[lt+1].prev):Ye.length)-en!==2||Ye[en+1]!==Et.node||Wn(zt.bk,zt.lk,Et.su)&&et.link(zt.lk,Et.node)}}function ko(le,ze,qe,st){let At=Et=>{let en=Et.filter(ut);return en.length===1?en[0]:null},Ge=At(le),Xe=At(ze),St=At(qe);if(!Ge||!Xe||!St)return;let tt=le.indexOf(Ge);if(ze.indexOf(Xe)!==tt||qe.indexOf(St)!==tt||le.length!==ze.length||le.length!==qe.length)return;for(let Et=0;Et<le.length;Et++)if(Et!==tt&&(le[Et].value!==ze[Et].value||le[Et].value!==qe[Et].value))return;if((ie.asBase?Ge:ie.twin(Ge))!==Xe||ee.twin(Ge)||V.reverse.get(St)||Xe!==Ge&&ne(Ge,Xe,U))return;let wt=st.filter(Et=>Et.nodeType===1);if(wt.length!==1||xe.get(wt[0])?.remote!==St)return;let lt=Et=>Et.map(en=>ut(en)?"":en.value??en.nodeValue).join(""),zt=st.indexOf(wt[0]);lt(st.slice(0,zt))!==lt(le.slice(0,tt))||lt(st.slice(zt+1))!==lt(le.slice(tt+1))||Wn(Ge,Xe,St)&&et.link(Xe,wt[0])}function Wn(le,ze,qe){if(!ut(ze)||!ut(qe)||!ut(le)||ze.namespaceURI!==qe.namespaceURI||ze.localName===qe.localName)return!1;for(let Xe of[ze,qe])if(Xe.tagName==="TEMPLATE"||mn(Xe)||Xe.querySelector("template"))return!1;if(n.remoteWins(le)||n.remoteWins(qe)||s(qe)||ze.attributes.length!==qe.attributes.length)return!1;for(let Xe of ze.attributes)if(qe.getAttributeNS(Xe.namespaceURI,Xe.localName)!==Xe.value)return!1;let st=ze.childNodes,At=qe.childNodes;if(st.length!==At.length)return!1;for(let Xe=0;Xe<st.length;Xe++)if(!st[Xe].isEqualNode(At[Xe]))return!1;let Ge=[[le,qe]];for(;Ge.length;){let[Xe,St]=Ge.pop();if(Xe.children.length!==St.children.length)return!1;for(let tt=0;tt<St.children.length;tt++){let wt=V.reverse.get(St.children[tt]);if(wt!==void 0&&wt!==Xe.children[tt])return!1;Ge.push([Xe.children[tt],St.children[tt]])}}return!0}function xo(le){for(let ze=le-1;ze>=0;ze--){let qe=gt.get(Ee[ze]);if(qe){let st=Ye.indexOf(qe);if(st>=0)return st+1}}return 0}function vo(){if((ie.asBase||U.identical.has(I))&&(ee.asBase||V.identical.has(I)))return;let le={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},ze=at=>ut(at)?jn(at,le):at.kind==="text";if(!ie.asBase&&!ee.asBase)for(let at of Ee){if(!ut(at)||!Ln.has(at.tagName))continue;let rt=ie.twin(at),Pt=ee.twin(at);if(!rt&&Pt||rt&&!Pt){let ct=Br({base:Ee,views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:It=>ut(It)&&Ln.has(It.tagName)&&!s(It)&&!n.remoteWins(It),baseId:m.base,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey});ct&&(ie=ct[0],ee=ct[1]);break}}let qe=!ie.asBase&&!ee.asBase&&Ee.length>=2&&Ln.has(Ee[0].tagName)&&ie.units.length===Ee.length&&ee.units.length===Ee.length?hr({base:Ee,local:ie.units,remote:ee.units,localTwin:ie.twin,remoteTwin:ee.twin,eligible:at=>ut(at)&&Ln.has(at.tagName)&&!s(at)&&!n.remoteWins(at),nodes:{base:Array.from(Ie(I).childNodes),local:Array.from(Ie(ie.el).childNodes),remote:Array.from(Ie(ee.el).childNodes)}}):null,st=null,At=null;if(!qe&&!ie.asBase&&!ee.asBase&&(Es(Ee)||Es(ie.units)||Es(ee.units))){let at={ignored:s,remoteWins:()=>!1},rt=ct=>ze(ct)||ut(ct)&&n.remoteWins(ct)&&vn.has(ct.tagName)&&jn(ct,at),Pt=ct=>ut(ct)?Ln.has(ct.tagName)&&!s(ct)&&!n.remoteWins(ct)&&r(ct).every(rt):ct.kind==="text";st=Dr({onUncertainOwner:ct=>{let It=n.identity.local(ct.local);It&&It===n.identity.remote(ct.remote)||(At||=[]).push(ct)},onUncertainSource:ct=>{it||(it=new Map);let It=it.get(ct.source);It||it.set(ct.source,It=[]);for(let tn of It)if(tn.side===ct.side&&tn.from===ct.from&&tn.to===ct.to)return;It.push(ct)},base:Ee,views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:Pt,ignored:s,remoteWins:n.remoteWins,baseId:m.base,atomKey:i.exactUnitKey})}if(At){Qe||=new Map;for(let at of At){let{source:rt,local:Pt,remote:ct}=at,It={map:new Map,reverse:new Map,identical:new Set},tn=mt({base:[rt],local:[Pt],remote:[ct],out:oe,policy:"both",L:It,R:It,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey,cloneUnit:se,provenance:xe,textMappers:$e,conflicts:k,decisions:ae,conflict:(Bt,rn)=>Tt(Bt,{...rn,policy:"both"}),scope:{base:I,local:ie.el,remote:ee.el,units:Ee,at:_e.get(rt)},node:we});re.push(...tn.segments);for(let Bt of[rt,Pt,ct])Z.add(Bt),vt.add(Bt),Qe.set(Bt,tn.nodes),gt.set(Bt,tn.nodes[tn.nodes.length-1]);for(let Bt=0;Bt<tn.nodes.length;Bt++)dt.push({frag:tn.nodes[Bt],at:_e.get(rt),previous:Bt?tn.nodes[Bt-1]:null})}}let Ge=qe?qe.blocks:null;if(st){Ge=new Set;for(let at of st.blocks)Ge.add(at)}let Xe=at=>!jt?.consumes(at)&&(Ge&&Ge.has(at)||ze(at)),St=Ee.map(Xe);if(!St.includes(!0))return;let tt=at=>{let rt=at.units,Pt=new Map;for(let Yt=0;Yt<rt.length;Yt++)Pt.set(rt[Yt],Yt);let ct=[],It=-1;for(let Yt=0;Yt<Ee.length;Yt++){if(St[Yt])continue;let Ot=at.twin(Ee[Yt]),kt=Ot?Pt.get(Ot):void 0;kt===void 0||kt<=It||Xe(Ot)||(ct.push([Yt,kt]),It=kt)}let tn=[],Bt=-1,rn=-1;for(let Yt=0;Yt<=ct.length;Yt++){let[Ot,kt]=Yt<ct.length?ct[Yt]:[Ee.length,rt.length],Kt={bLo:-1,bHi:-1,from:rn+1,to:kt,inlineStart:-1,inlineEnd:-1,next:kt};for(let nn=Bt+1;nn<Ot;nn++)St[nn]&&(Kt.bLo<0&&(Kt.bLo=nn),Kt.bHi=nn);for(let nn=rn+1;nn<kt;nn++){let Vn=rt[nn];Xe(Vn)&&(Kt.inlineStart<0&&(Kt.inlineStart=nn),Kt.inlineEnd=nn+1)}tn.push(Kt),Bt=Ot,rn=kt}return{units:rt,list:tn}},wt=tt(ie),lt=tt(ee),zt=[];for(let at of[wt,lt])for(let rt of at.list)rt.bLo>=0&&zt.push([rt.bLo,rt.bHi]);zt.sort((at,rt)=>at[0]-rt[0]);let Et=[];for(let[at,rt]of zt){let Pt=Et[Et.length-1];Pt&&at<=Pt.hi?Pt.hi=Math.max(Pt.hi,rt):Et.push({lo:at,hi:rt})}let en=(at,rt)=>at.length===rt.length&&at.every((Pt,ct)=>i.equalUnits(Pt,rt[ct])),Tn=at=>!ut(at)&&at.kind==="comment",Kn=at=>{if(!at.length)return[];let rt=(Bt,rn)=>ut(Bt)?Bt:Bt.nodes[rn?Bt.nodes.length-1:0],Pt=rt(at[0]),ct=rt(at[at.length-1],!0),It=Bt=>Bt&&ut(Bt)&&s(Bt);for(;It(Pt.previousSibling);)Pt=Pt.previousSibling;for(;It(ct.nextSibling);)ct=ct.nextSibling;let tn=[];for(let Bt=Pt;Bt&&(tn.push(Bt),Bt!==ct);Bt=Bt.nextSibling);return tn},Po=at=>at.some(rt=>ut(rt)&&s(rt));for(let at of Et){let rt=Ee.slice(at.lo,at.hi+1),Pt=null;if(st)for(let Ot of rt){let kt=st.certificatesBySource.get(Ot);kt&&(Pt||=[]).push(...kt)}let ct=ie.asBase?null:Is(wt,at),It=ee.asBase?null:Is(lt,at);if(Pt){let Ot=[new Set(ct||rt),new Set(It||rt)],kt=Pt.some(Kt=>!Ot[Kt.side].has(Kt.target));for(let Kt of rt)if(Ge.has(Kt))for(let[nn,Vn]of[[0,ie],[1,ee]]){let Yn=Vn.twin(Kt);Yn&&Vn.here(Yn)&&!Ot[nn].has(Yn)&&(kt=!0)}if(kt)continue}if(rt.some(Tn)||ct&&ct.some(Tn)||It&&It.some(Tn))continue;let tn=Kn(ct||rt),Bt=Kn(It||rt);if((!ct||en(rt,ct))&&(!It||en(rt,It))&&!(ct&&Po(tn)))continue;let rn=mt({base:Kn(rt),sourceRetentions:it?.get(I),local:tn,remote:Bt,out:oe,policy:Ze,blocks:Ge,scopeUnits:Pt?[rt,ct||rt,It||rt]:null,certifiedOrigins:Pt?(Ot,kt,Kt,nn,Vn,Yn)=>jr({certificates:Pt,scopes:[rt,ct||rt,It||rt],flats:[Ot,kt,Kt],keys:[nn,Vn,Yn]}):null,prepared:qe?qe.prepared:null,nativeTransfers:qe,L:ct?U:Ur(U,I),R:It?V:Ur(V,I),idOf:{base:p,local:v,remote:O},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Ot,kt,Kt)=>Q(Ot,kt,Kt,!1),cloneUnit:se,mergeAttrs:Ce,atomKey:i.exactUnitKey,moveIn:z,moveBuilt:z,movePlanned:z,provenance:xe,textMappers:$e,conflicts:k,conflict:Tt,scope:{base:I,local:ie.asBase?null:ie.el,remote:ee.asBase?null:ee.el,units:Ee,at:at.lo},decisions:ae,node:we});if(!rn){if(Pt){let Ot=pr({certificates:Pt,scopes:[rt,ct||rt,It||rt],views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:kt=>ut(kt)&&Ln.has(kt.tagName)&&!s(kt)&&!n.remoteWins(kt),baseId:m.base});for(let kt of Ot.records){it||=new Map;let Kt=it.get(kt.source);Kt||it.set(kt.source,Kt=[]),Kt.push(kt)}}continue}if(re.push(...rn.segments),qe){let Ot=new Map;for(let kt of rn.nodes){let Kt=xe.get(kt)?.base;if(!Kt||Ot.has(Kt))throw new Error("Invalid native transfer owner output");Ot.set(Kt,kt)}if(Ot.size!==qe.owners.length)throw new Error("Incomplete native transfer owner output");for(let kt of qe.owners){let Kt=Ot.get(kt.base);if(!Kt)throw new Error("Missing native transfer owner output");for(let nn of[kt.base,kt.local,kt.remote])Z.add(nn),vt.add(nn),gt.set(nn,Kt);dt.push({frag:Kt,at:_e.get(kt.base)})}continue}if(et&&ko(rt,ct||rt,It||rt,rn.nodes),rn.unitOutputs){Qe||=new Map;for(let Ot of[...rt,...ct||[],...It||[]]){let kt=rn.unitOutputs.get(Ot)||[];Z.add(Ot),vt.add(Ot),Qe.set(Ot,kt),kt.length&>.set(Ot,kt[kt.length-1])}for(let Ot=0;Ot<rn.nodes.length;Ot++)dt.push({frag:rn.nodes[Ot],at:at.lo,previous:Ot>0?rn.nodes[Ot-1]:null});continue}et&&ko(rt,ct||rt,It||rt,rn.nodes);let Yt=oe.createDocumentFragment();for(let Ot of rn.nodes)Yt.appendChild(Ot);for(let Ot of[...rt,...ct||[],...It||[]])Z.add(Ot),vt.add(Ot),gt.set(Ot,Yt);dt.push({frag:Yt,at:at.lo})}}}function fe(I,q){let te=xe.get(I);return te&&te.unchanged?!te.remote||te.remote===q?!0:G(te.remote,q):I.tagName!==q.tagName||!Pe(I,q)?!1:He(Ie(I),Ie(q))}function G(I,q){return I===q?!0:I.tagName!==q.tagName||I.namespaceURI!==q.namespaceURI||!Pe(I,q)?!1:ue(Ie(I),Ie(q))}function ue(I,q){let te=Se(I,s),me=Se(q,s);if(te.length!==me.length)return!1;for(let we=0;we<te.length;we++){let ie=te[we],ee=me[we];if(typeof ie=="string"||typeof ee=="string"){if(ie!==ee)return!1}else{if(ie.nodeType!==ee.nodeType)return!1;if(ie.nodeType===1){if(!G(ie,ee))return!1}else if(ie.nodeValue!==ee.nodeValue)return!1}}return!0}function Ie(I){return I.tagName==="TEMPLATE"&&I.content?I.content:I}function Pe(I,q){let te=0;for(let me of I.attributes)if(!n.ignoreAttribute(I,me.name)&&(te++,q.getAttribute(me.name)!==me.value))return!1;for(let me of q.attributes)n.ignoreAttribute(q,me.name)||te--;return te===0}function He(I,q){let te=Se(I,we=>{let ie=xe.get(we);return!!(ie&&ie.pinned)}),me=Se(q,s);if(te.length!==me.length)return!1;for(let we=0;we<te.length;we++){let ie=te[we],ee=me[we];if(typeof ie=="string"||typeof ee=="string"){if(ie!==ee)return!1}else{if(ie.nodeType!==ee.nodeType)return!1;if(ie.nodeType===1){if(!fe(ie,ee))return!1}else if(ie.nodeValue!==ee.nodeValue)return!1}}return!0}function Se(I,q){let te=[],me=null;for(let we=I.firstChild;we;we=we.nextSibling){if(we.nodeType===3){me=me===null?we.nodeValue:me+we.nodeValue;continue}we.nodeType===1&&q(we)||(me!==null&&(me!==""&&te.push(me),me=null),te.push(we))}return me!==null&&me!==""&&te.push(me),te}function Je(I,q,te,me){let we=I.value,ie=me?we:q?q.value:"",ee=te?te.value:"";Z.add(I),q&&Z.add(q),te&&Z.add(te);let Ee=ie===ee?ie:ie===we?ee:ee===we||Ze==="local"?ie:ee,Ue={site:"comment",bRun:I,lRun:q,rRun:te,node:null};if(ie!==we&&ee!==we&&ie!==ee&&Tt({kind:"text",node:null,base:we,local:ie,remote:ee,resolved:Ee},Ue),!q&&!te)return null;let _e=oe.createComment(Ee);return Ue.node=_e,xe.set(_e,{base:I.nodes,local:q?q.nodes:null,remote:te?te.nodes:null}),_e}function nt(I,q){let te=R(q,I);if(!te)return null;let me=ut(te)?te.parentNode:te.parent,we=ut(I)?I.parentNode:I.parent;return R(q,we)===me?null:q.reverse.get(me)||null}function ot(I){let q=new Set([I]),te=I;for(let me=0;me<64;me++){let we=nt(te,U)||nt(te,V);if(!we)return!1;if(we===I||ut(I)&&ut(we)&&I.contains(we)||q.has(we))return!0;q.add(we),te=we}return!0}function Wt(I,q,te){if(!q)return!1;let me=ut(I)?I.parentNode:I.parent;return me===q||q.tagName==="TEMPLATE"&&me===q.content}function Ut(I,q){let te=De(I),me=R(U,te);if(me&&Wt(q,me,U))return!0;let we=R(V,te);return!!(we&&Wt(q,we,V))}}function Ur(e,o){return e.map.get(o)?Vr():{map:{get:n=>n&&n.nodeType===1&&e.map.get(n)||n,has:()=>!0},reverse:{get:n=>e.reverse.get(n)||n,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Vr(){let e={get:o=>o,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Hr=new Set(["INPUT","OPTION","TEXTAREA"]),Ls=/[\t\n\f\r ]+/;function Wr(e,o,t,n){let s=e.ownerDocument,{provenance:d,textMappers:i}=t,r=n.hooks,l=[],u=[],b=[],a=new Set,h=[],p=[],v=new Map,O=new Set,m=new Map,c=t.conflicts.length>0||n.trackInserted===!0,g=new Map,P=new Set,T=new Map,x=(F,ce)=>{let ge=T.get(F);ge||T.set(F,ge=new Set),ge.add(ce)},A=c?new Set:null,E=(F,ce,ge)=>{let Le=r.beforeAttributeUpdated(F,ce,ge);return c&&Le===!1&&x(ce,F),Le},S=F=>!!F&&(F===e||e.contains(F)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(F)),N=new Map,C=new Map,j=new Map,D=new Set,B=new Map;(function F(ce){let ge=d.get(ce);if(ge){if(ce.nodeType===1){let Me=ge.local?n.toLive(ge.local):null;Me&&S(Me)&&Me.nodeType===1&&(N.set(ce,Me),C.set(Me,ce))}else if(Array.isArray(ge.local)){let Me=V(ge.local,ge.local.map(M=>n.toLive(M)).filter(M=>M&&S(M)&&M.nodeType===ce.nodeType));if(Me.length&&(N.set(ce,Me[0]),C.set(Me[0],ce),j.set(ce,Me)),Array.isArray(ge.caret))for(let M of ge.caret){let R=n.toLive(M.node);if(!R||!S(R)||R.nodeType!==3)continue;let z=B.get(R);Array.isArray(z)||B.set(R,z=[]),z.push({merged:ce,from:M.from,to:M.to,flatStart:M.flatStart})}else{let M=0;for(let R of Me)B.set(R,{merged:ce,shift:M}),M+=R.nodeValue.length}}}let Le=ce.nodeType===1&&ce.tagName==="TEMPLATE"&&ce.content?ce.content.childNodes:ce.childNodes;for(let Me of Le)F(Me)})(o);let w=new Set;for(let F of N.values())w.add(F);for(let F of j.values())for(let ce of F)w.add(ce);let y=n.localRoot&&n.localRoot!==e?new Set:null;if(y){for(let F=n.localRoot.firstElementChild;F;F=F.nextElementSibling)if(F.tagName==="HEAD")for(let ce=F.firstElementChild;ce;ce=ce.nextElementSibling){let ge=n.toLive(ce);ge&&y.add(ge)}}for(let F of t.segments||[])Ne(F);let $=n.restoreFocus===!1?null:dl(s,B);n.childrenOnly?xe(Ae(e),Ae(o)):De(e,o);for(let{node:F,parent:ce}of h)a.has(F)||!F.parentNode||F.nodeType===1&&(n.ignored(F)||$e(F))||it(F,ce);return hl(s,$,B,i,j,m,D),{applied:l,moved:u,replaced:b,identities:p,mergedScriptsLive:O,liveOf:N,heldBy:m,runOf:j,keptRuns:D,insertedLive:g,vetoed:P,vetoedAttrs:T,removedVetoes:A};function U(F,ce){let ge=F.slice(ce.bs,ce.be),Le=0;for(;Le<ge.length&&Le<ce.text.length&&ge[Le]===ce.text[Le];)Le++;let Me=0;for(;Me<ge.length-Le&&Me<ce.text.length-Le&&ge[ge.length-1-Me]===ce.text[ce.text.length-1-Me];)Me++;return{bs:ce.bs+Le,be:ce.be-Me,text:ce.text.slice(Le,ce.text.length-Me)}}function V(F,ce){if(!ce.length)return ce;let ge=[];for(let M of F){let R=M.parentNode;if(!R)continue;let z=v.get(R);if(!z){z=new Set;for(let J=R.firstChild;J;J=J.nextSibling)J.nodeType===3&&z.add(n.toLive(J));v.set(R,z)}ge.includes(z)||ge.push(z)}let Le={has:M=>ge.some(R=>R.has(M))},Me=[];for(let M of ce){Me.push(M);for(let R=M.nextSibling;R&&R.nodeType===3&&!Le.has(R)&&!Me.includes(R);R=R.nextSibling)Me.push(R)}return Me}function Ne(F){let ce=[];for(let be of F.localNodes){let H=n.toLive(be.node);if(!H||!S(H)||H.nodeType!==3)return;ce.push(H)}let ge=V(F.localNodes.map(be=>be.node),ce);if(!ge.length)return;let Le=ge.map(be=>be.nodeValue).join(""),{flatLocal:Me,lToM:M,mapLocal:R}=F;if(Le===Me)return;let z=F.textNodes.map(be=>({node:be.node,ms:be.ms,me:be.me})),J=[],ne=0;for(let be of ge)J.push(ne),ne+=be.nodeValue.length;let je=(be,H)=>ge.find((X,de)=>J[de]<=be&&be+H<=J[de]+X.nodeValue.length)||null,Q=[],Oe=0;for(let be of _n(Me,Le).map(H=>U(Me,H))){let H=be.bs+Oe;Oe+=be.text.length-(be.be-be.bs);let X,de;if(be.be>be.bs){X=M[be.bs];let pe=X>=0;for(let se=be.bs;pe&&se<be.be;se++)M[se]!==X+(se-be.bs)&&(pe=!1);if(!pe)continue;de=X+(be.be-be.bs)}else{let pe=be.bs>0?M[be.bs-1]:0,se=be.bs<Me.length?M[be.bs]:0;if(pe<0||se<0)continue;X=de=R(be.bs)}Q.push({ms:X,me:de,text:be.text,live:de===X?je(H,be.text.length):null})}Q.sort((be,H)=>H.ms-be.ms);let Ve=(be,H)=>(j.get(be.node)||[N.get(be.node)]).includes(H),Ce=be=>!!be&&be.nodeType===1&&vn.has(be.tagName);for(let be of Q){let H=z.find(de=>de.ms<=be.ms&&be.me<=de.me&&be.ms<de.me);if(H&&be.live&&H.ms===be.ms&&!Ve(H,be.live)){let de=z.find(pe=>pe.me===be.ms&&Ve(pe,be.live));de&&(H=de)}if(!H&&be.me===be.ms){let de=z.find(fe=>fe.me===be.ms),pe=z.find(fe=>fe.ms===be.ms),se=de||pe;if(!se)continue;let ke=se.node;for(;Ce(ke.parentNode)&&(de?ke.parentNode.lastChild:ke.parentNode.firstChild)===ke;)ke=ke.parentNode;if(ke===se.node)H=se;else{let fe=ke.ownerDocument.createTextNode(be.text);ke.parentNode.insertBefore(fe,de?ke.nextSibling:ke);continue}}if(!H)continue;let X=H.node.nodeValue;H.node.nodeValue=X.slice(0,be.ms-H.ms)+be.text+X.slice(be.me-H.ms),H.me+=be.text.length-(be.me-be.ms)}}function Ae(F){return F.nodeType===1&&F.tagName==="TEMPLATE"&&F.content?F.content:F}function De(F,ce){a.add(F);let ge=d.get(ce);if(ge&&ge.remote&&t.remoteIdOf){let Me=t.remoteIdOf(ge.remote);Me&&p.push([F,Me])}if(ge&&ge.unchanged){t.customIdentity&&ge.remote&&re(F,ge.remote),ge.remote&&_(F,ge.remote);return}if(r.beforeNodeMorphed(F,ce)===!1){P.add(ce);return}Dt(F,ce,n.keepLiveOnly&&ge&&ge.local&&ge.local.nodeType===1&&ge.local!==F?ge.local:null);let Le=F.tagName;if(mn(F))F.textContent!==ce.textContent&&(l.push({kind:"text",node:F,before:F.textContent,after:ce.textContent}),F.textContent=ce.textContent),t.mergedScripts.has(ce)&&O.add(F);else if(Le==="TEXTAREA")Jt(F,ce,ge);else{un(F,ce,ge);let Me=Le==="TEMPLATE"&&F.content?F.content:F,M=Le==="TEMPLATE"&&ce.content?ce.content:ce;n.protectFocusedValue==="subtree"&&Rt(F)&&F!==s.body?oe(Me):xe(Me,M)}r.afterNodeMorphed(F,ce)}function oe(F){for(let ce=F.firstChild;ce;ce=ce.nextSibling){let ge=C.get(ce);ge&&N.get(ge.parentNode)!==F||(a.add(ce),ce.nodeType===1&&oe(ce))}}function xe(F,ce){let ge=Ke(F.firstChild),Le=new Set;for(let Me of Array.from(ce.childNodes)){let M=N.get(Me);M&&a.has(M)&&!Le.has(M)&&(M=null);let R=d.get(Me);if(R&&R.pinned){M&&M.nodeType===1&&((M.parentNode!==F||Ke(M.nextSibling)!==ge)&&Te(F,M,ge),a.add(M),Le.add(M));continue}if(M&&M.nodeType===1){if(M!==ge){let ne=M.parentNode;if(ne===F&&ge&&jt(M)){let je=M.nextSibling;for(let Q=ge;Q&&Q!==M;){let Oe=Q.nextSibling;Te(F,Q,je),Q=Oe}}else Te(F,M,ge),ne!==F&&(u.push(M),l.push({kind:"move",el:M,from:ne,to:F}))}Le.add(M),De(M,Me),ge=Ke(M.nextSibling);continue}if(M&&M.nodeType!==1){let ne=j.get(Me)||[M],je=ne.map(Oe=>Oe.nodeValue).join(""),Q=Me.nodeValue;if(Me.nodeType===3){let Oe=ae(Me);Oe!=null&&je!==Oe&&(Q=ro(Oe,je,Me.nodeValue).text)}if(ne.length>1&&je===Q&&!ne.includes(ge,1)&&ne.every((Oe,Ve)=>Oe.parentNode===F&&(Ve===0||ne[Ve-1].nextSibling===Oe))){if(M!==ge)for(let Oe of ne)Te(F,Oe,ge);r.beforeNodeMorphed(M,Me)!==!1?r.afterNodeMorphed(M,Me):c&&P.add(Me);for(let Oe of ne)a.add(Oe),Le.add(Oe);m.set(Me,M),D.add(Me),ge=Ke(ne[ne.length-1].nextSibling);continue}M!==ge&&Te(F,M,ge),r.beforeNodeMorphed(M,Me)!==!1?(M.nodeValue!==Q&&(l.push({kind:"text",node:M,before:M.nodeValue,after:Q}),M.nodeValue=Q),r.afterNodeMorphed(M,Me)):P.add(Me),a.add(M),Le.add(M),m.set(Me,M),ge=Ke(M.nextSibling);continue}if(Me.nodeType===3&&ge&&ge.nodeType===3&&!a.has(ge)&&!B.has(ge)){ge.nodeValue!==Me.nodeValue&&(l.push({kind:"text",node:ge,before:ge.nodeValue,after:Me.nodeValue}),ge.nodeValue=Me.nodeValue),a.add(ge),m.set(Me,ge),ge=Ke(ge.nextSibling);continue}let z=d.get(Me),J=et(z&&z.unchanged&&z.remote?z.remote:Me);if(r.beforeNodeAdded(J)===!1){P.add(Me);continue}F.insertBefore(J,ge),a.add(J),c&&g.set(Me,J),J.nodeType===3&&m.set(Me,J),J.nodeType===1&&(b.push(J),Be(J,Me),t.customIdentity&&z&&z.unchanged&&z.remote&&re(J,z.remote),mn(J)||mt(J,Me),n.formState==="property"&&qt(z)&&_(J,z.remote)),ge=Ke(J.nextSibling),l.push({kind:"insert",node:J,parent:F}),r.afterNodeAdded(J)}for(let Me of Array.from(F.childNodes))a.has(Me)||Le.has(Me)||Me.nodeType===1&&(n.ignored(Me)||$e(Me))||(w.has(Me)?h.push({node:Me,parent:F}):it(Me,F))}function $e(F){return F.parentNode&&F.parentNode.nodeType===1&&F.parentNode.tagName==="HEAD"&&(y&&!y.has(F)||n.preserve&&n.preserve(F)===!0)}function ae(F){let ce=d.get(F);return!ce||!Array.isArray(ce.local)?null:ce.local.map(ge=>ge.nodeValue).join("")}function k(F){return d.get(F)}function _(F,ce){if(!Hr.has(F.tagName)&&!F.querySelector("input,option,textarea"))return;let ge=(Le,Me)=>{if(Le.tagName!==Me.tagName)return;Le.tagName==="TEXTAREA"?Jt(Le,Me,{remote:Me}):Hr.has(Le.tagName)&&un(Le,Me,{remote:Me});let M=Z(Le),R=Z(Me);if(M.length===R.length)for(let z=0;z<M.length;z++)ge(M[z],R[z])};ge(F,ce)}function re(F,ce){let ge=Z(F),Le=Z(ce);if(ge.length===Le.length)for(let Me=0;Me<ge.length;Me++){let M=t.remoteIdOf(Le[Me]);M&&p.push([ge[Me],M]),re(ge[Me],Le[Me])}}function Z(F){let ce=F.tagName==="TEMPLATE"&&F.content?F.content:F;return Array.from(ce.children).filter(ge=>!n.ignored(ge))}function Be(F,ce){if(!t.remoteIdOf)return;let ge=(Le,Me)=>{let M=d.get(Me);if(M&&M.remote&&Me.nodeType===1){let J=t.remoteIdOf(M.remote);J&&p.push([Le,J])}let R=Le.childNodes,z=Me.childNodes;for(let J=0;J<R.length&&J<z.length;J++)ge(R[J],z[J])};ge(F,ce)}function Ke(F){for(;F&&F.nodeType===1&&n.ignored(F);)F=F.nextSibling;return F}function Te(F,ce,ge){if(typeof F.moveBefore=="function"&&ce.ownerDocument===F.ownerDocument)try{F.moveBefore(ce,ge);return}catch{}F.insertBefore(ce,ge)}function it(F,ce){if(r.beforeNodeRemoved(F)===!1){c&&A.add(F);return}F.parentNode.removeChild(F),l.push({kind:"remove",node:F,parent:ce}),r.afterNodeRemoved(F)}function et(F){if(mn(F))return Ao(F,s);let ce=s.importNode(F,!0);if(ce.nodeType===1)for(let ge of Array.from(ce.querySelectorAll("script")))mn(ge)&&ge.replaceWith(Ao(ge,s));return ce}function mt(F,ce){let ge=F.tagName==="TEMPLATE"&&F.content?F.content:F,Le=ce.tagName==="TEMPLATE"&&ce.content?ce.content:ce,Me=Array.from(ge.childNodes),M=Array.from(Le.childNodes);for(let R=0;R<M.length&&R<Me.length;R++){let z=M[R],J=Me[R],ne=N.get(z);ne&&a.has(ne)&&(ne=null);let je=d.get(z);if(je&&je.pinned){if(ne&&ne.nodeType===1){let Q=ne.parentNode;Te(ge,ne,J),Q!==ge&&(u.push(ne),l.push({kind:"move",el:ne,from:Q,to:ge})),a.add(ne)}J.remove();continue}if(ne){let Q=ne.parentNode;Te(ge,ne,J),J.remove(),ne.nodeType===1?(Q!==ge&&(u.push(ne),l.push({kind:"move",el:ne,from:Q,to:ge})),De(ne,z)):(a.add(ne),m.set(z,ne),ne.nodeValue!==z.nodeValue&&(l.push({kind:"text",node:ne,before:ne.nodeValue,after:z.nodeValue}),ne.nodeValue=z.nodeValue));continue}a.add(J),c&&g.set(z,J),J.nodeType===3&&m.set(z,J),je&&je.unchanged&&je.remote?(Ze(J,je.remote),t.customIdentity&&re(J,je.remote)):z.nodeType===1&&!mn(z)&&mt(J,z)}}function Ze(F,ce){let ge=F.tagName==="TEMPLATE"&&F.content?F.content:F,Le=ce.tagName==="TEMPLATE"&&ce.content?ce.content:ce;for(let Me of Array.from(Le.childNodes))ge.appendChild(et(Me))}function ft(F,ce){return ce.namespaceURI?F.getAttributeNS(ce.namespaceURI,ce.localName):F.getAttribute(ce.name)}function Ct(F,ce){let ge=new Set((ce||"").split(Ls).filter(Boolean));return(F||"").split(Ls).filter(Le=>Le&&!ge.has(Le))}function Dt(F,ce,ge){for(let Le of Array.from(ce.attributes)){if(Tt(F,Le.name)||n.ignoreAttribute(F,Le.name))continue;let Me=ft(F,Le);if(Me===Le.value||ge&&ft(ge,Le)===Le.value)continue;let M=Le.value;if(ge&&Le.name==="class"&&!Le.namespaceURI){let R=Le.value.split(Ls).filter(Boolean),z=Ct(Me,ge.getAttribute("class")).filter(J=>!R.includes(J));z.length&&(M=[...R,...z].join(" "))}if(Me!==M){if(r.beforeAttributeUpdated(Le.name,F,"update")===!1){c&&x(ce,Le.name);continue}Le.namespaceURI?F.setAttributeNS(Le.namespaceURI,Le.name,M):F.setAttribute(Le.name,M),l.push({kind:"attr",el:F,name:Le.name,before:Me,after:M})}}for(let Le of Array.from(F.attributes)){if(Tt(F,Le.name)||n.ignoreAttribute(F,Le.name)||(Le.namespaceURI?ce.hasAttributeNS(Le.namespaceURI,Le.localName):ce.hasAttribute(Le.name)))continue;if(ge&&Le.name==="class"&&!Le.namespaceURI){let R=Ct(Le.value,ge.getAttribute("class"));if(R.length){let z=R.join(" ");if(z===Le.value)continue;if(r.beforeAttributeUpdated("class",F,"update")===!1){c&&x(ce,"class");continue}F.setAttribute("class",z),l.push({kind:"attr",el:F,name:"class",before:Le.value,after:z});continue}}if(ge&&ft(ge,Le)===null)continue;if(r.beforeAttributeUpdated(Le.name,F,"remove")===!1){c&&x(ce,Le.name);continue}let M=Le.value;Le.namespaceURI?F.removeAttributeNS(Le.namespaceURI,Le.localName):F.removeAttribute(Le.name),l.push({kind:"attr",el:F,name:Le.name,before:M,after:null})}}function Tt(F,ce){let ge=F.tagName;return ge==="INPUT"?ce==="value"||ce==="checked"||ce==="disabled":ge==="OPTION"?ce==="selected":!1}function Rt(F){return F===s.activeElement}function jt(F){let ce=s.activeElement;return!!ce&&ce!==s.body&&F.contains(ce)}function qt(F){let ce=F&&F.remote;return ce&&ce.nodeType===1?ce:null}function un(F,ce,ge){let Le=F.tagName,Me=qt(ge),M=n.formState==="property"&&Me?Me:ce;if(Le==="INPUT"){let R=n.protectFocusedValue&&Rt(F),z=(F.getAttribute("type")||"").toLowerCase(),J=z!=="file"&&z!=="checkbox"&&z!=="radio",ne=Me&&Me.hasAttribute("value")&&Me.value!==Me.getAttribute("value")?Me.value:null;if(J&&!R)if(n.formState==="property"){let je=ce.getAttribute("value"),Q=F.getAttribute("value");(Q!==je||F.value!==M.value)&&E("value",F,je==null?"remove":"update")!==!1&&(Q!==je&&(je==null?F.removeAttribute("value"):F.setAttribute("value",je),l.push({kind:"attr",el:F,name:"value",before:Q,after:je})),F.value!==M.value&&(F.value=M.value))}else if(ce.hasAttribute("value")||ne!=null){let je=ne??ce.getAttribute("value");F.getAttribute("value")!==je&&E("value",F,"update")!==!1?(F.setAttribute("value",je),F.value!==je&&(F.value=je),l.push({kind:"attr",el:F,name:"value",before:null,after:je})):F.value!==je&&F.getAttribute("value")===je&&(F.value=je)}else(F.hasAttribute("value")||F.value!=="")&&E("value",F,"remove")!==!1&&(F.removeAttribute("value"),F.value="",l.push({kind:"attr",el:F,name:"value",before:"",after:null}));if(!J&&z!=="file"){let je=ce.getAttribute("value");je==null?F.hasAttribute("value")&&E("value",F,"remove")!==!1&&F.removeAttribute("value"):F.getAttribute("value")!==je&&E("value",F,"update")!==!1&&F.setAttribute("value",je)}R||(Lt(F,M,"checked"),n.formState==="property"&&F.indeterminate!==M.indeterminate&&(F.indeterminate=M.indeterminate)),Lt(F,M,"disabled")}else if(Le==="OPTION"){let R=F.parentNode&&F.closest("select");n.protectFocusedValue&&R&&Rt(R)||Lt(F,M,"selected")}}function Lt(F,ce,ge){let Le=n.formState==="property"?!!ce[ge]:ce.hasAttribute(ge);if(n.formState!=="property"){let Me=F.hasAttribute(ge);if(Me!==Le){if(E(ge,F,Le?"update":"remove")===!1)return;Le?F.setAttribute(ge,""):F.removeAttribute(ge),l.push({kind:"attr",el:F,name:ge,before:Me?"":null,after:Le?"":null})}}F[ge]!==Le&&(F[ge]=Le)}function Jt(F,ce,ge){if(n.protectFocusedValue&&Rt(F)||E("value",F,"update")===!1)return;let Le=qt(ge),Me=ce.textContent,M=Le&&Le.value!==Le.defaultValue?Le.value:Me;n.formState!=="property"&&F.textContent!==Me&&(l.push({kind:"text",node:F,before:F.textContent,after:Me}),F.textContent=Me),F.value!==M&&(F.value=M)}}function dl(e,o){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let n={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{n.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return n}let s=e.getSelection&&e.getSelection();if(s&&s.rangeCount){let d=s.getRangeAt(0);n.range={sc:d.startContainer,so:d.startOffset,ec:d.endContainer,eo:d.endOffset}}return n}function hl(e,o,t,n,s,d,i){if(!o)return;let r=o.el;if(!r.isConnected&&o.id&&(r=e.getElementById(o.id)),!r||!r.isConnected)return;if(e.activeElement!==r)try{r.focus({preventScroll:!0})}catch{}try{r.scrollTop=o.scrollTop,r.scrollLeft=o.scrollLeft}catch{}if(o.selection){try{r.setSelectionRange&&!r.selectionEnd&&o.selection[1]!=null&&r.setSelectionRange(o.selection[0],o.selection[1],o.selection[2]||"none")}catch{}return}if(!o.range)return;let l=(a,h)=>{let p=t.get(a);if(Array.isArray(p)){let v=p.find(g=>h>=g.from&&h<g.to)||p.find(g=>h===g.to)||p[p.length-1],O=d.get(v.merged);if(!O||!O.isConnected)return null;let m=n.get(v.merged),c=m&&m.flat?m.flat(v.flatStart+h):h;return[O,Math.max(0,Math.min(c,O.nodeValue.length))]}if(p&&!i.has(p.merged)){let v=(s.get(p.merged)||[a])[0];if(!v.isConnected)return null;let O=n.get(p.merged),m=p.shift+h,c=O?O(m):m;return[v,Math.max(0,Math.min(c,v.nodeValue.length))]}return a.isConnected?[a,Math.min(h,a.nodeType===3?a.nodeValue.length:a.childNodes.length)]:null},u=l(o.range.sc,o.range.so),b=l(o.range.ec,o.range.eo);if(!(!u||!b))try{let a=e.createRange();a.setStart(u[0],u[1]),a.setEnd(b[0],b[1]);let h=e.getSelection();h.removeAllRanges(),h.addRange(a)}catch{}}var pl={compared:0},ml=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function gl(e,o,t){let n=0;for(let s of e.attributes)if(!t(e,s.name)&&(n++,o.getAttribute(s.name)!==s.value))return!1;for(let s of o.attributes)t(o,s.name)||n--;return n===0}function Rs(e,o){if(e.namespaceURI!==o.namespaceURI||e.prefix!==o.prefix||e.localName!==o.localName)return!1;let t=e.attributes;if(t.length!==o.attributes.length)return!1;for(let n of t)if(o.getAttributeNS(n.namespaceURI,n.localName)!==n.value)return!1;return!0}function Kr(e,o,t,n,s,d,i,r){let l=new Map,u=new Set,b=a=>{if(n(a))return;let h=t(a);h&&(d.add(h),s.has(h)||l.has(h)?u.add(h):l.set(h,a))};for(let a of e)b(a);b(o);for(let a of i||o.querySelectorAll("*"))b(a);for(let a of u)l.delete(a),r.add(a);return l}function Fr(e,o,t,n,s,d){let i=!1;for(let b of s)b.startsWith("merge:")&&(i=!0);if(!i)return[...n];let r=new Map,l=[],u=d===kn?Io:"*";for(let b of[e,...e.querySelectorAll(u)]){if(t(b))continue;let a=o(b);if(!a||!(n.has(a)||s.has(a)))continue;let h=(r.get(a)||0)+1;r.set(a,h),h===2&&l.push(a)}return l}function qr({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:s,identity:d,baseURI:i}){if(e.tagName!==o.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||o.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!gl(e,o,s.ignoreAttribute))return{bail:"root-attrs"};let{ignored:r,remoteWins:l}=s,u=Cs(s.scripts.merge===!1?null:s.scripts.mergeTags,i),b=ae=>{let k=u(ae);return k!==null?k:d.base(ae)||null},a=ae=>{let k=u(ae);return k!==null?k:d.remote(ae)||null},h=[],p=[],v=new Map,O=new Map,m={same:v,differ:O},c=ae=>({bail:ae,comparisons:m}),g=(ae,k,_=!0)=>{if(v.get(ae)===k)return!0;if(O.get(ae)===k)return!1;if(pl.compared++,_&&ae.isEqualNode(k))return v.set(ae,k),!0;let re=ae.nodeType===k.nodeType;if(re&&ae.nodeType===1){if(re=Rs(ae,k),re){let Z=ae.firstChild,Be=k.firstChild;for(;Z&&Be;Z=Z.nextSibling,Be=Be.nextSibling)if(!g(Z,Be,!1)){re=!1;break}(Z||Be)&&(re=!1)}}else re&&(re=ae.isEqualNode(k));return(re?v:O).set(ae,k),re},P=e,T=o,x=!1,A=()=>{v.set(P,T);for(let ae=0;ae<h.length;ae++)v.set(h[ae],p[ae]);return c("equal")};for(;;){let ae=P.childNodes,k=T.childNodes;if(ae.length!==k.length)break;let _=et=>g(ae[et],k[et])?(v.set(ae[et],k[et]),!1):!0,re=-1,Z=-1;for(let et=0;et<ae.length;et++){if(ae[et].nodeType!==1)continue;let mt=0;for(let Ze=ae[et].firstElementChild;Ze;Ze=Ze.nextElementSibling)mt++;mt>=Z&&(Z=mt,re=et)}let Be=[],Ke=!1;for(let et=0;et<ae.length&&Be.length<2;et++)et!==re&&_(et)&&Be.push(et);if(re>=0&&Be.length<2&&(Be.length===0&&Rs(P,T)?(Be.push(re),Ke=!0):_(re)&&Be.push(re)),Be.length!==1){if(!x&&Be.length===0&&Rs(P,T))return A();break}let Te=ae[Be[0]],it=k[Be[0]];if(x=x||!Ke,x&&O.set(Te,it),Te.nodeType!==1||it.nodeType!==1||Te.tagName!==it.tagName)break;if(b(Te)!==a(it)){if(!x&&g(Te,it))return A();break}h.push(P),p.push(T),P=Te,T=it}O.set(P,T);for(let ae=0;ae<h.length;ae++)O.set(h[ae],p[ae]);if(P===e||P.tagName==="HEAD"||P.tagName==="BODY")return c("root-level");if(h.length<2||h[1].tagName!=="BODY")return c("not-in-body");if(r(P)||r(T))return c("ignored-ancestor");if(l(P)||l(T))return c("remote-wins-ancestor");for(let ae of h)if(ml.has(ae.tagName))return c("form-ancestor");if(P.tagName==="SCRIPT"||P.getElementsByTagName("script").length||T.getElementsByTagName("script").length)return c("script-or-template");let E=n(P);if(!E||E.nodeType!==1||E.tagName!==P.tagName)return c("no-live-twin");if(!t.contains(E))return c("live-detached");for(let ae of h){let k=n(ae);if(!k||k.nodeType!==1)return c("ancestor-live")}let S=d.base===kn&&d.remote===kn&&r===os,N=new Set,C=new Set,j=[],D=null,B=ae=>{ae&&(N.has(ae)?C.add(ae):N.add(ae))},w=(ae,k)=>{let _=u(ae),re=_!==null?_:d.base(ae)||null;return re!==(_!==null?_:d.remote(k)||null)?!1:(B(re),!0)},y=(ae,k)=>{for(let _=ae.firstElementChild,re=k.firstElementChild;_;_=_.nextElementSibling,re=re.nextElementSibling){let Z=r(_);if(Z!==r(re))return!1;if(!Z&&(!w(_,re)||!y(_,re)))return!1}return!0},$=ae=>{let k=ae+1<h.length?h[ae+1]:P;for(let _=h[ae].firstElementChild,re=p[ae].firstElementChild;_;_=_.nextElementSibling,re=re.nextElementSibling){if(_===k){let Ke=ae+1<h.length?$(ae+1):null;if(Ke)return Ke;continue}let Z=r(_);if(Z!==r(re))return"outside-id-changed";if(Z)continue;let Be=n(_);if(!Be||Be.nodeType!==1)return"sibling-live";if(j.push([_,re]),!S&&(!w(_,re)||!y(_,re)))return"outside-id-changed";ae===0&&_.tagName==="HEAD"&&b(_)&&(D=[_,re])}return null},U=$(0);if(U)return c(U);let V=new Set(h),Ne=null;if(d.base===kn){Ne=[];for(let ae of e.querySelectorAll(Io))ae===P||V.has(ae)||(P.contains(ae)?Ne.push(ae):S&&B(b(ae)))}let Ae=new Set,De=new Set,oe=new Set,xe=Kr(h,P,b,r,N,Ae,Ne,De),$e=Kr(p,T,a,r,N,Ae,d.remote===kn&&T.querySelectorAll(Io),oe);return D&&(C.has(b(D[0]))||Ae.has(b(D[0])))&&(D=null),{scope:{chain:h,root:P,onChain:V,baseIndex:xe,remoteIndex:$e,baseDropped:De,remoteDropped:oe,head:D,same:v,differ:O,dropped:[...Fr(e,b,r,C,De,d.base),...Fr(o,a,r,C,oe,d.remote)],held:ae=>{for(let k=1;k<h.length;k++)if(ae.map.get(h[k])!==p[k])return!1;for(let[k,_]of j)if(ae.map.get(k)!==_)return!1;return!0}}}}var _r=Symbol("hyper-morph-duplicate-key"),zr=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function Eo(e,o){return o.map(t=>{let n=new Map;for(let s of e){if(s.nodeType!==1)continue;let d=t(s);d==null||d===""||n.set(d,n.has(d)?_r:s)}return n})}function $r(e,o,t,n){for(let s=0;s<n.length;s++){let d=n[s](e);if(d==null||d===""||o[s].get(d)!==e)continue;let i=t[s].get(d);if(!(!i||i===_r)&&i.tagName===e.tagName)return i}return null}function mo(e,o,t){for(let n=0;n<t.length;n++){let s=t[n](e);if(!(s==null||s==="")&&o[n].get(s)===e)return!0}return!1}function Gr(e,o,t={}){let n=t.skip||(()=>!1),s=t.ignoreAttr||(()=>!1),d=t.tiers&&t.tiers.length?t.tiers:zr,i=null;function r(){return i||(i=Eo([e,...e.querySelectorAll("*")],d)),i}let l=null;function u(){return l||(l=Eo([o,...o.querySelectorAll("*")],d)),l}function b(N){return!N.parentElement||!N.parentElement.parentElement}function a(N,C,j){return b(N)||mo(N,r(),d)?(j.push({type:"subtree",el:N,base:C}),!1):!0}function h(N,C){let j=[];for(let D of N.attributes)s(N,D.name)||C.getAttribute(D.name)!==D.value&&j.push(D.name);for(let D of C.attributes)s(N,D.name)||N.hasAttribute(D.name)||j.push(D.name);return j}function p(N){let C=[],j=null,D=()=>{j!==null&&(C.push({nodeType:3,nodeValue:j}),j=null)};for(let B of N.childNodes){if(B.nodeType===3){j=(j===null?"":j)+B.nodeValue;continue}B.nodeType===1&&n(B)||(D(),(B.nodeType===1||B.nodeType===8)&&C.push(B))}return D(),C}function v(N,C){if(N.nodeType!==C.nodeType)return!1;if(N.nodeType!==1)return!0;if(N.tagName!==C.tagName)return!1;for(let j of d){let D=j(N),B=j(C);if(D!=null&&D!==""&&B!=null&&B!==""&&D!==B)return!1}return!0}function O(N){let C="";for(let j of N)j.nodeType===3&&j.nodeValue.trim()!==""?C+="\0"+j.nodeValue:j.nodeType===8&&(C+=""+j.nodeValue);return C}function m(N,C,j){let D=p(N),B=p(C);if(D.length===B.length){let ae=!0;for(let k=0;k<D.length;k++)if(!v(D[k],B[k])){ae=!1;break}if(ae){for(let k=0;k<D.length;k++){let _=D[k];if(_.nodeType===1){if(c(_,B[k],j))return!0}else if(_.nodeValue!==B[k].nodeValue)return!0}return!1}}let w=D.filter(ae=>ae.nodeType===1),y=B.filter(ae=>ae.nodeType===1);if(O(D)!==O(B))return!0;let $=Eo(w,d),U=Eo(y,d),V=[],Ne=new Set,Ae=[];for(let ae of w){let k=$r(ae,$,U,d);k&&!Ne.has(k)?(V.push([ae,k]),Ne.add(k)):Ae.push(ae)}let De=[];for(let ae of Ae)mo(ae,$,d)?j.push({type:"subtree",el:ae,base:null}):De.push(ae);let oe=[];for(let ae of y)Ne.has(ae)||(mo(ae,U,d)?j.push({type:"deletion",el:ae}):oe.push(ae));if(De.length!==oe.length)return!0;for(let ae=0;ae<De.length;ae++)if(!v(De[ae],oe[ae]))return!0;let xe=new Map(V);for(let ae=0;ae<De.length;ae++)xe.set(De[ae],oe[ae]);let $e=-1;for(let ae of w){let k=xe.get(ae);if(!k)continue;let _=y.indexOf(k);if(_<$e)return!0;$e=_}for(let ae=0;ae<De.length;ae++)if(c(De[ae],oe[ae],j))return!0;for(let[ae,k]of V)if(c(ae,k,j))return!0;return!1}function c(N,C,j){if(N.tagName!==C.tagName)return a(N,C,j);let D=h(N,C),B=[];if(m(N,C,B))return a(N,C,j);if(D.length){if(!b(N)&&!mo(C,u(),d))return!0;j.push({type:"attrs",el:N,names:D,base:C})}return j.push(...B),!1}let g=[],P=h(e,o);P.length&&g.push({type:"attrs",el:e,names:P});let T=(N,C)=>Array.from(N.children).find(j=>j.tagName===C)||null,x=T(e,"HEAD"),A=T(o,"HEAD");if(x&&A){let N=[];c(x,A,N),N.length&&g.push({type:"head",el:x})}else(x||A)&&x&&g.push({type:"head",el:x});let E=T(e,"BODY"),S=T(o,"BODY");return E&&S?c(E,S,g):E&&g.push({type:"subtree",el:E,base:null}),{entries:g}}function Yr(e,o,t={}){let n=t.tiers&&t.tiers.length?t.tiers:zr,s=e.documentElement,d=[],i=0,r=c=>({ok:!1,placed:d,held:c,skippedAttrs:i});if(!s)return r(null);function l(c){let g=[c,...c.querySelectorAll("*")];return Eo(g,n)}let u=l(s),b=new Map,a=c=>{let g=c.getRootNode(),P=b.get(g);if(!P){let T=g.nodeType===9?g.documentElement:g;P=l(T),b.set(g,P)}return P};function h(c){if(!c.parentElement&&c.tagName==="HTML")return s;if(c.parentElement&&!c.parentElement.parentElement&&c.parentElement.tagName==="HTML"){if(c.tagName==="BODY")return e.body||null;if(c.tagName==="HEAD")return e.head||null}return null}function p(c){let g=h(c);return g||$r(c,a(c),u,n)}function v(c){if(!c)return null;let g=p(c);return g&&g.isConnected?g:null}function O(c){for(let g=0;g<n.length;g++){let P=n[g](c);P!=null&&P!==""&&u[g].set(P,c)}}for(let c of o){if(c.type!=="deletion")continue;let g=p(c.el);g&&g!==s&&g.remove()}let m=o.filter(c=>c.type!=="deletion").sort((c,g)=>c.el===g.el?0:c.el.compareDocumentPosition(g.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let c of m){if(c.type==="head"){let S=e.importNode(c.el,!0);e.head?e.head.replaceWith(S):s.insertBefore(S,s.firstChild),d.push({entry:c,imported:S});continue}if(c.type==="attrs"){let S=v(c.el)||v(c.base);if(!S){i++;continue}for(let N of c.names)c.el.hasAttribute(N)?S.setAttribute(N,c.el.getAttribute(N)):S.removeAttribute(N);continue}let g=c.el;if(h(g))return r(c);let P=v(g)||v(c.base);if(P){let S=e.importNode(g,!0);P.replaceWith(S),O(S),d.push({entry:c,imported:S});continue}if(c.base!=null&&!mo(c.base,a(c.base),n)||!mo(g,a(g),n))return r(c);let T=g.parentElement;if(!T)return r(c);let x=v(T);if(!x)return r(c);let A=null;for(let S=g.previousElementSibling;S;S=S.previousElementSibling){let N=v(S);if(N&&N.parentNode===x){A=N;break}}let E=e.importNode(g,!0);if(A)x.insertBefore(E,A.nextSibling);else{let S=Array.prototype.indexOf.call(T.children,g);x.insertBefore(E,x.children[S]||null)}O(E),d.push({entry:c,imported:E})}return{ok:!0,placed:d,held:null,skippedAttrs:i}}var bl='[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"]',wl='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',yl='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function kl(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let o=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(o)}function xl(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let s=o;if(s.nodeType===9){let d=e.getAttribute("id");s=d&&s.getElementById(d)||(e.tagName==="BODY"?s.body:e.tagName==="HTML"?s.documentElement:s.body&&s.body.firstElementChild)}if((!s||s.nodeType!==1||s.tagName!==e.tagName)&&(s=vl(e,o,n)),!!s)return t?Array.from(s.childNodes):s}function vl(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let s=new Map,d=[n,...n.querySelectorAll("script")];for(let l of d){let u=fo(l,t);u&&!s.has(u.key)&&s.set(u.key,l.textContent)}if(!s.size)return null;let i=e.cloneNode(!0),r=!1;for(let l of[i,...i.querySelectorAll("script")]){let u=fo(l,t);u&&s.has(u.key)&&(l.textContent=s.get(u.key),r=!0)}return r?i:null}function Xr(e,o){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=o.implementation.createHTMLDocument(""),n=e.nodeType===1&&e.tagName==="HTML"?e:null;if(n)return t.replaceChild(t.adoptNode(n),t.documentElement),t;let s=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let d of s)t.body.appendChild(t.adoptNode(d));return t}function Qo(e,o,t={}){let n=t||{};if(!n.head?.block)return Jr(e,o,n);try{return Jr(e,o,n)}catch(s){return Promise.reject(s)}}function Jr(e,o,t){let n=t.policy||"sync",s=n==="raw"?void 0:(l,u)=>kl(l)||(n==="history"?!(u&&l.matches(yl))&&l.matches(wl):l.matches(bl)),d=t.callbacks||{},i={ignore:s,hooks:d,protectFocusedValue:t.ignoreActiveValue===!0?"subtree":!1,restoreFocus:t.restoreFocus!==!1,formState:t.formStateSync||"attribute",scripts:{execute:t.scripts?.handle!==!1,merge:t.scripts?.merge!==!1,mergeTags:t.scripts?.mergeTags||[]},head:{awaitLoads:!!t.head?.block,preserve:t.head?.shouldPreserve||(()=>!1)}};if(typeof t.key=="function"&&(i.identity={base:t.key,local:t.key,remote:t.key}),e&&e.nodeType===9)return go(Object.assign({},i,{live:e,base:t.scripts?.mergeBase||null,remote:Xr(o,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let l=Object.assign({},i,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Xr(o,e.ownerDocument)});return go(l)}t.morphStyle==="innerHTML"&&(i.children=!0);let r=xl(e,t.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return r!==void 0&&(i.base=r),Zo(e,o,i)}var Tl=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),Mn=()=>{};function Co(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let r of Object.keys(e))if(!Tl.has(r))throw new TypeError(`unknown option "${r}"`);let t=Object.assign({beforeNodeAdded:Mn,afterNodeAdded:Mn,beforeNodeRemoved:Mn,afterNodeRemoved:Mn,beforeNodeMorphed:Mn,afterNodeMorphed:Mn,beforeAttributeUpdated:Mn},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let s=e.formState||"attribute";if(!["attribute","property"].includes(s))throw new TypeError("formState must be attribute or property");let d=e.protectFocusedValue;if(d!==void 0&&typeof d!="boolean"&&d!=="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 i=e.lineage;if(i!==void 0&&(!i||typeof i!="object"||typeof i.onResult!="function"||!i.elements||typeof i.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:ss(e.ignore,o),remoteWins:ss(e.remoteWins,o),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:n,protectFocusedValue:d===void 0?!0:d,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:s,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:i||null}}function bo(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 wo(e,o){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=jo(o,e.map),n=typeof e.then=="function"?e.then:kn;if(typeof e.first=="function"){let s=e.first;return d=>s(d)||t.get(d)||n(d)}return s=>t.get(s)||n(s)}return kn}function ei(e,o,t,n={}){let s=p=>p&&p.nodeType===9?p.documentElement:p,d=s(o),i=s(t),r=s(e)||d;if(n.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let l=Object.assign({},n);delete l.live,delete l.base,delete l.remote;let u=Co(l,[r,d,i].filter(Boolean)),b=n.identity||{},a=Fn(),h=Jo(r,d,i,{identity:{base:wo(b.base,r),local:wo(b.local,d),remote:wo(b.remote,i)},authored:{base:bo(b.base),local:bo(b.local),remote:bo(b.remote)},skipUnchanged:u.hooks.beforeNodeMorphed===Mn&&u.hooks.afterNodeMorphed===Mn,ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:d.ownerDocument&&d.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:u.children,stats:a});return delete h.recoveryLinks,delete h.lineage,h}function Ps({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:s,options:d,identity:i,childrenOnly:r,isDocument:l}){let u=Co(d,[e,o,t,n].filter(Boolean));if(u.ignored(e)){let w=Bs(),y=u.lineage?No(u.lineage,e,w):null;return{report:w,loads:[],lineage:y}}let b=e.ownerDocument,a=u.lineage?Ts(u.lineage,{liveRoot:e,localRoot:t,toLive:s}):null,h=u.scripts.execute?mr(e,u.ignored,b.baseURI):null,p=Fn(),v=u.hooks.beforeNodeMorphed===Mn&&u.hooks.afterNodeMorphed===Mn,O={identity:{base:wo(i.base,o||t),local:wo(i.local,t),remote:wo(i.remote,n)},authored:{base:bo(i.base),local:bo(i.local),remote:bo(i.remote)},ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:b.baseURI,localIsBase:!o,childrenOnly:r,skipUnchanged:v,lineage:a?{locals:a.locals}:null},m=u.fastPath&&l&&!r&&v&&o===t,c=null,g=null;if(m){let w=qr({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:s,o:u,identity:O.identity,baseURI:b.baseURI});O.comparisons=w.comparisons||w.scope,w.bail?g=w.bail:(c=Jo(o,t,n,Object.assign({},O,{stats:p,scope:w.scope})),c||(g="chain-unpaired",p=Fn()))}c||(c=Jo(o||t,t,n,Object.assign({},O,{stats:p}))),m&&(p.fastPathAttempted=1,p.fastPathTaken=g?0:1,p.fastPathFallback=g),c.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(w=>u.hooks[w]!==Mn)&&Ar(c.conflicts,c.recoveryLinks,s),u.beforeApply&&u.beforeApply(c.doc);let P=globalThis.__hyperMorphProfile,T=P?performance.now():0,x=Wr(e,c.root,c,{toLive:s,localRoot:t,ignored:u.ignored,ignoreAttribute:u.ignoreAttribute,formState:u.formState,protectFocusedValue:u.protectFocusedValue,restoreFocus:u.restoreFocus,preserve:u.head.preserve,hooks:u.hooks,childrenOnly:r,keepLiveOnly:u.keepLiveOnly,trackInserted:!!a});P&&(P.apply=(P.apply||0)+(performance.now()-T));let A=[];if(u.head.awaitLoads)for(let w of x.applied){if(w.kind!=="insert"||w.node.nodeType!==1)continue;let y=w.node;y.tagName==="LINK"&&/\bstylesheet\b/i.test(y.getAttribute("rel")||"")&&y.getAttribute("href")&&y.closest("head")&&A.push(new Promise(U=>{y.addEventListener("load",()=>U()),y.addEventListener("error",()=>U())}))}let E=null,S=null;if(h){let w=gr(e,h,{ignored:u.ignored,skip:x.mergedScriptsLive,baseURI:b.baseURI,beforeNodeAdded:u.hooks.beforeNodeAdded,afterNodeAdded:u.hooks.afterNodeAdded,trackRecovery:!!c.recoveryLinks});A.push(...w.loads),E=w.swapped,S=w.vetoed}let N=w=>E&&E.get(w)||w,C=w=>{if(x.keptRuns.has(w))return x.runOf.get(w);let y=x.liveOf.get(w)||x.heldBy.get(w)||x.insertedLive.get(w);return y?N(y):null},j=w=>{let y=w&&x.liveOf.get(w);return y?N(y):null},D=w=>{let y=w&&C(w);return Array.isArray(y)?y[0]:y};if(c.recoveryLinks){let w=(y,$,U)=>($.namespaceURI?y.getAttributeNS($.namespaceURI,$.localName):y.getAttribute($.qualifiedName))===U;Ir(c.conflicts,c.recoveryLinks,{lookup:C,vetoed:x.vetoed,vetoedAttrs:x.vetoedAttrs,removedVetoes:x.removedVetoes,vetoedLive:S,liveAttr:w,ignored:u.ignored,liveRoot:e})}let B={applied:x.applied,decisions:c.decisions.map(w=>Object.assign({},w,{node:w.node?j(w.node):null,el:w.el?j(w.el):null,applied:!!(w.node?j(w.node):w.el&&j(w.el))})),conflicts:c.conflicts.map(w=>Object.assign({},w,{node:w.node?w.kind==="text"&&w.recovery.subject.nodeType===8?D(w.node):j(w.node):w.node,el:w.el?w.kind==="structure"?D(w.el):j(w.el):w.el})),localDiverged:c.localDiverged,identities:x.identities,moved:x.moved,replaced:x.replaced,stats:p};return a&&(B.lineage=a.finish(c.lineage,C)),{report:B,loads:A,lineage:a}}var Qr=new WeakMap;function Bs(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Fn()}}function go(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");return vs(o,o.live.documentElement,n=>Sl(n))}function Sl(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let n=Qr.get(t);n||(n=Do(t),Qr.set(t,n));let s=n("remote",o.remote),d=typeof o.base=="string"&&o.base===""?null:o.base,i=d?n("base",d):null,r=o.local?o.local.root:t.documentElement,l=o.local?o.local.toLive:h=>h;js(t,s);let{report:u,loads:b,lineage:a}=Ps({liveRoot:t.documentElement,baseRoot:i?i.documentElement:null,localRoot:r,remoteRoot:s.documentElement,toLive:l,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return a?.deliver(u),Promise.all(b).then(()=>u)}function ti(e,o,t={}){return go(Object.assign({},t,{live:e,base:null,remote:o}))}function Zr(e,o){if(e==null)return{root:o.createElement("template"),first:null};if(typeof e=="string"){let n=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(n){let d=Bo(e,o),i=n[1].toLowerCase()==="html"?d.documentElement:d.body;return{root:i,first:i}}let s=o.createElement("template");return s.innerHTML=e,{root:s,first:s.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let n=o.createElement("template"),s=e.isConnected;return n.content.appendChild(s?o.importNode(e,!0):e),{root:n,first:e}}if(e.nodeType===11){let n=o.createElement("template");return n.content.appendChild(e),{root:n,first:n.content.firstElementChild}}let t=o.createElement("template");for(let n of Array.from(e))t.content.appendChild(n.parentNode?o.importNode(n,!0):n);return{root:t,first:t.content.firstElementChild}}function Zo(e,o,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return vs(t,e,n=>Nl(e,o,n))}function Nl(e,o,t={}){let n=e.ownerDocument,{base:s,...d}=t,i=!!d.children,r=Co(d,[e]);if(r.ignored(e)){let O=Bs();return r.lineage&&No(r.lineage,e,O).deliver(O),Promise.resolve(O)}let l=Zr(o,n),u=s!=null?Zr(s,n):null,b,a=null;if(i)b=l.root,a=u?u.root:null;else{if(b=l.first,a=u?u.first:null,!b){let O=Co(d),m=O.lineage?No(O.lineage,e,{}):null;O.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),O.hooks.afterNodeRemoved(e));let c={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Fn()};return m&&(c.lineage=m.result,m.deliver(c)),Promise.resolve(c)}if(b.tagName!==e.tagName){let O=Co(d,[e,b]);if(O.hooks.beforeNodeMorphed(e,b)===!1){let g=Bs();return O.lineage&&No(O.lineage,e,g).deliver(g),Promise.resolve(g)}let m=Ps({liveRoot:e,baseRoot:a&&a.tagName===e.tagName?a:null,localRoot:e,remoteRoot:b,toLive:g=>g,options:d,identity:d.identity||{},childrenOnly:!0,isDocument:!1}),c=mn(b)?Ao(b,n):n.importNode(b,!1);if(!mn(c))for(;e.firstChild;)c.appendChild(e.firstChild);return O.hooks.beforeNodeAdded(c)===!1?(Xo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):O.hooks.beforeNodeRemoved(e)===!1?(Xo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):(e.replaceWith(c),Xo(m.report.conflicts,e,c),O.hooks.afterNodeRemoved(e),O.hooks.afterNodeAdded(c),O.hooks.afterNodeMorphed(e,b),m.report.replaced.push(c),m.report.applied.push({kind:"insert",node:c,parent:c.parentNode},{kind:"remove",node:e,parent:c.parentNode}),m.lineage&&(m.report.lineage=m.lineage.remapRoot(e,c),m.lineage.deliver(m.report)),Promise.all(m.loads).then(()=>m.report))}}let{report:h,loads:p,lineage:v}=Ps({liveRoot:e,baseRoot:a,localRoot:e,remoteRoot:b,toLive:O=>O,options:d,identity:d.identity||{},childrenOnly:i,isDocument:!1});return v?.deliver(h),Promise.all(p).then(()=>h)}var Al={mergeDocument:go,morphDocument:ti,morphElement:Zo,merge3:ei,morph:Qo};return ai(Ml);})();
|
|
5
5
|
|
|
6
6
|
var morph = HyperMorph.morph;
|
|
7
7
|
|