hyper-html-api 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/conformance/MANIFEST.json +2 -2
- package/conformance/cases/no-data-list-skipped.expected.json +6 -0
- package/conformance/cases/no-data-list-skipped.html +1 -0
- package/conformance/cases/no-data-list-skipped.meta +4 -0
- package/conformance/cases/no-data-list-skipped.parsed.json +3 -0
- package/conformance/cases/no-data-list-skipped.rules +1 -0
- package/conformance/cases/no-data-text-projected.expected.json +3 -0
- package/conformance/cases/no-data-text-projected.html +1 -0
- package/conformance/cases/no-data-text-projected.meta +4 -0
- package/conformance/cases/no-data-text-projected.parsed.json +3 -0
- package/conformance/cases/no-data-text-projected.rules +1 -0
- package/conformance/cases/props-type-is-attribute.expected.json +5 -0
- package/conformance/cases/props-type-is-attribute.meta +4 -0
- package/conformance/cases/write-attr-app-scheme.after.html +1 -0
- package/conformance/cases/write-attr-app-scheme.after.json +3 -0
- package/conformance/cases/write-attr-app-scheme.data.json +1 -0
- package/conformance/cases/write-attr-app-scheme.html +1 -0
- package/conformance/cases/write-attr-app-scheme.meta +4 -0
- package/conformance/cases/write-attr-app-scheme.write.json +4 -0
- package/conformance/cases/write-attr-href.after.html +1 -0
- package/conformance/cases/write-attr-href.after.json +3 -0
- package/conformance/cases/write-attr-href.data.json +1 -0
- package/conformance/cases/write-attr-href.html +1 -0
- package/conformance/cases/write-attr-href.meta +4 -0
- package/conformance/cases/write-attr-href.write.json +4 -0
- package/conformance/cases/write-checked-false.after.html +1 -0
- package/conformance/cases/write-checked-false.after.json +3 -0
- package/conformance/cases/write-checked-false.data.json +1 -0
- package/conformance/cases/write-checked-false.html +1 -0
- package/conformance/cases/write-checked-false.meta +4 -0
- package/conformance/cases/write-checked-false.write.json +4 -0
- package/conformance/cases/write-checked-true.after.html +1 -0
- package/conformance/cases/write-checked-true.after.json +3 -0
- package/conformance/cases/write-checked-true.data.json +1 -0
- package/conformance/cases/write-checked-true.html +1 -0
- package/conformance/cases/write-checked-true.meta +4 -0
- package/conformance/cases/write-checked-true.write.json +4 -0
- package/conformance/cases/write-crlf-multi.after.html +12 -0
- package/conformance/cases/write-crlf-multi.after.json +8 -0
- package/conformance/cases/write-crlf-multi.data.json +1 -0
- package/conformance/cases/write-crlf-multi.html +12 -0
- package/conformance/cases/write-crlf-multi.meta +4 -0
- package/conformance/cases/write-crlf-multi.write.json +4 -0
- package/conformance/cases/write-fallback-implied.after.html +1 -0
- package/conformance/cases/write-fallback-implied.after.json +3 -0
- package/conformance/cases/write-fallback-implied.data.json +1 -0
- package/conformance/cases/write-fallback-implied.html +1 -0
- package/conformance/cases/write-fallback-implied.meta +4 -0
- package/conformance/cases/write-fallback-implied.write.json +4 -0
- package/conformance/cases/write-flatten.after.html +1 -0
- package/conformance/cases/write-flatten.after.json +3 -0
- package/conformance/cases/write-flatten.data.json +1 -0
- package/conformance/cases/write-flatten.html +1 -0
- package/conformance/cases/write-flatten.meta +4 -0
- package/conformance/cases/write-flatten.write.json +4 -0
- package/conformance/cases/write-list-empty-no-seed.data.json +1 -0
- package/conformance/cases/write-list-empty-no-seed.error.json +8 -0
- package/conformance/cases/write-list-empty-no-seed.html +1 -0
- package/conformance/cases/write-list-empty-no-seed.meta +4 -0
- package/conformance/cases/write-list-grow-from-template.after.html +1 -0
- package/conformance/cases/write-list-grow-from-template.after.json +5 -0
- package/conformance/cases/write-list-grow-from-template.data.json +1 -0
- package/conformance/cases/write-list-grow-from-template.html +1 -0
- package/conformance/cases/write-list-grow-from-template.meta +4 -0
- package/conformance/cases/write-list-grow-from-template.write.json +4 -0
- package/conformance/cases/write-list-object-clone.after.html +1 -0
- package/conformance/cases/write-list-object-clone.after.json +12 -0
- package/conformance/cases/write-list-object-clone.data.json +1 -0
- package/conformance/cases/write-list-object-clone.html +1 -0
- package/conformance/cases/write-list-object-clone.meta +4 -0
- package/conformance/cases/write-list-object-clone.write.json +4 -0
- package/conformance/cases/write-list-scalar-grow.after.html +4 -0
- package/conformance/cases/write-list-scalar-grow.after.json +7 -0
- package/conformance/cases/write-list-scalar-grow.data.json +1 -0
- package/conformance/cases/write-list-scalar-grow.html +4 -0
- package/conformance/cases/write-list-scalar-grow.meta +4 -0
- package/conformance/cases/write-list-scalar-grow.write.json +4 -0
- package/conformance/cases/write-list-scalar-shrink.after.html +4 -0
- package/conformance/cases/write-list-scalar-shrink.after.json +5 -0
- package/conformance/cases/write-list-scalar-shrink.data.json +1 -0
- package/conformance/cases/write-list-scalar-shrink.html +4 -0
- package/conformance/cases/write-list-scalar-shrink.meta +4 -0
- package/conformance/cases/write-list-scalar-shrink.write.json +4 -0
- package/conformance/cases/write-list-shrink-zero.after.html +1 -0
- package/conformance/cases/write-list-shrink-zero.after.json +3 -0
- package/conformance/cases/write-list-shrink-zero.data.json +1 -0
- package/conformance/cases/write-list-shrink-zero.html +1 -0
- package/conformance/cases/write-list-shrink-zero.meta +4 -0
- package/conformance/cases/write-list-shrink-zero.write.json +4 -0
- package/conformance/cases/write-no-data-kept.after.html +1 -0
- package/conformance/cases/write-no-data-kept.after.json +3 -0
- package/conformance/cases/write-no-data-kept.data.json +1 -0
- package/conformance/cases/write-no-data-kept.html +1 -0
- package/conformance/cases/write-no-data-kept.meta +4 -0
- package/conformance/cases/write-no-data-kept.write.json +4 -0
- package/conformance/cases/write-no-rules-tag.data.json +1 -0
- package/conformance/cases/write-no-rules-tag.error.json +6 -0
- package/conformance/cases/write-no-rules-tag.html +1 -0
- package/conformance/cases/write-no-rules-tag.meta +4 -0
- package/conformance/cases/write-noop.after.html +3 -0
- package/conformance/cases/write-noop.after.json +3 -0
- package/conformance/cases/write-noop.data.json +1 -0
- package/conformance/cases/write-noop.html +3 -0
- package/conformance/cases/write-noop.meta +4 -0
- package/conformance/cases/write-noop.write.json +4 -0
- package/conformance/cases/write-outerhtml-unchanged.after.html +1 -0
- package/conformance/cases/write-outerhtml-unchanged.after.json +3 -0
- package/conformance/cases/write-outerhtml-unchanged.data.json +1 -0
- package/conformance/cases/write-outerhtml-unchanged.html +1 -0
- package/conformance/cases/write-outerhtml-unchanged.meta +4 -0
- package/conformance/cases/write-outerhtml-unchanged.write.json +4 -0
- package/conformance/cases/write-readonly-changed.data.json +1 -0
- package/conformance/cases/write-readonly-changed.error.json +6 -0
- package/conformance/cases/write-readonly-changed.html +1 -0
- package/conformance/cases/write-readonly-changed.meta +4 -0
- package/conformance/cases/write-readonly-unchanged.after.html +1 -0
- package/conformance/cases/write-readonly-unchanged.after.json +4 -0
- package/conformance/cases/write-readonly-unchanged.data.json +1 -0
- package/conformance/cases/write-readonly-unchanged.html +1 -0
- package/conformance/cases/write-readonly-unchanged.meta +4 -0
- package/conformance/cases/write-readonly-unchanged.write.json +4 -0
- package/conformance/cases/write-refused-animate.data.json +1 -0
- package/conformance/cases/write-refused-animate.error.json +11 -0
- package/conformance/cases/write-refused-animate.html +1 -0
- package/conformance/cases/write-refused-animate.meta +4 -0
- package/conformance/cases/write-refused-attr-name.data.json +1 -0
- package/conformance/cases/write-refused-attr-name.error.json +11 -0
- package/conformance/cases/write-refused-attr-name.html +1 -0
- package/conformance/cases/write-refused-attr-name.meta +4 -0
- package/conformance/cases/write-refused-data-url.data.json +1 -0
- package/conformance/cases/write-refused-data-url.error.json +11 -0
- package/conformance/cases/write-refused-data-url.html +1 -0
- package/conformance/cases/write-refused-data-url.meta +4 -0
- package/conformance/cases/write-refused-innerhtml.data.json +1 -0
- package/conformance/cases/write-refused-innerhtml.error.json +11 -0
- package/conformance/cases/write-refused-innerhtml.html +1 -0
- package/conformance/cases/write-refused-innerhtml.meta +4 -0
- package/conformance/cases/write-refused-javascript-url.data.json +1 -0
- package/conformance/cases/write-refused-javascript-url.error.json +11 -0
- package/conformance/cases/write-refused-javascript-url.html +1 -0
- package/conformance/cases/write-refused-javascript-url.meta +4 -0
- package/conformance/cases/write-refused-list-removes-rules-tag.data.json +1 -0
- package/conformance/cases/write-refused-list-removes-rules-tag.error.json +11 -0
- package/conformance/cases/write-refused-list-removes-rules-tag.html +1 -0
- package/conformance/cases/write-refused-list-removes-rules-tag.meta +4 -0
- package/conformance/cases/write-refused-multiple.data.json +1 -0
- package/conformance/cases/write-refused-multiple.error.json +15 -0
- package/conformance/cases/write-refused-multiple.html +1 -0
- package/conformance/cases/write-refused-multiple.meta +4 -0
- package/conformance/cases/write-refused-onclick.data.json +1 -0
- package/conformance/cases/write-refused-onclick.error.json +11 -0
- package/conformance/cases/write-refused-onclick.html +1 -0
- package/conformance/cases/write-refused-onclick.meta +4 -0
- package/conformance/cases/write-refused-rules-tag-ancestor.data.json +1 -0
- package/conformance/cases/write-refused-rules-tag-ancestor.error.json +11 -0
- package/conformance/cases/write-refused-rules-tag-ancestor.html +1 -0
- package/conformance/cases/write-refused-rules-tag-ancestor.meta +4 -0
- package/conformance/cases/write-refused-script.data.json +1 -0
- package/conformance/cases/write-refused-script.error.json +11 -0
- package/conformance/cases/write-refused-script.html +1 -0
- package/conformance/cases/write-refused-script.meta +4 -0
- package/conformance/cases/write-shape-mismatch.data.json +1 -0
- package/conformance/cases/write-shape-mismatch.error.json +12 -0
- package/conformance/cases/write-shape-mismatch.html +1 -0
- package/conformance/cases/write-shape-mismatch.meta +4 -0
- package/conformance/cases/write-text-basic.after.html +3 -0
- package/conformance/cases/write-text-basic.after.json +3 -0
- package/conformance/cases/write-text-basic.data.json +1 -0
- package/conformance/cases/write-text-basic.html +3 -0
- package/conformance/cases/write-text-basic.meta +4 -0
- package/conformance/cases/write-text-basic.write.json +4 -0
- package/conformance/cases/write-text-escape.after.html +1 -0
- package/conformance/cases/write-text-escape.after.json +3 -0
- package/conformance/cases/write-text-escape.data.json +1 -0
- package/conformance/cases/write-text-escape.html +1 -0
- package/conformance/cases/write-text-escape.meta +4 -0
- package/conformance/cases/write-text-escape.write.json +4 -0
- package/conformance/cases/write-text-null-clears.after.html +1 -0
- package/conformance/cases/write-text-null-clears.after.json +3 -0
- package/conformance/cases/write-text-null-clears.data.json +1 -0
- package/conformance/cases/write-text-null-clears.html +1 -0
- package/conformance/cases/write-text-null-clears.meta +4 -0
- package/conformance/cases/write-text-null-clears.write.json +4 -0
- package/conformance/cases/write-type-attribute.after.html +1 -0
- package/conformance/cases/write-type-attribute.after.json +3 -0
- package/conformance/cases/write-type-attribute.data.json +1 -0
- package/conformance/cases/write-type-attribute.html +1 -0
- package/conformance/cases/write-type-attribute.meta +4 -0
- package/conformance/cases/write-type-attribute.write.json +4 -0
- package/conformance/cases/write-unknown-key.data.json +1 -0
- package/conformance/cases/write-unknown-key.error.json +11 -0
- package/conformance/cases/write-unknown-key.html +3 -0
- package/conformance/cases/write-unknown-key.meta +4 -0
- package/conformance/cases/write-unmatched.data.json +1 -0
- package/conformance/cases/write-unmatched.error.json +14 -0
- package/conformance/cases/write-unmatched.html +1 -0
- package/conformance/cases/write-unmatched.meta +4 -0
- package/conformance/write-policy.json +78 -0
- package/dist/hyper-html-api.engine.min.js +1 -1
- package/dist/hyper-html-api.min.js +6 -4
- package/dist/hyper-html-api.upgrade.min.js +2 -2
- package/package.json +4 -3
- package/packed-contract.json +1 -1
- package/src/adapters/cheerio.js +105 -10
- package/src/engine/apply.js +2 -0
- package/src/engine/errors.js +25 -0
- package/src/engine/index.js +3 -0
- package/src/engine/splice.js +118 -0
- package/src/engine/write-plan.js +52 -0
- package/src/engine/write-policy.js +136 -0
- package/src/lib/content-dom.js +4 -2
- package/src/write.js +29 -0
- package/conformance/cases/props-type-is-node-type.expected.json +0 -5
- package/conformance/cases/props-type-is-node-type.meta +0 -11
- /package/conformance/cases/{props-type-is-node-type.html → props-type-is-attribute.html} +0 -0
- /package/conformance/cases/{props-type-is-node-type.parsed.json → props-type-is-attribute.parsed.json} +0 -0
- /package/conformance/cases/{props-type-is-node-type.rules → props-type-is-attribute.rules} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
var HyperHtmlApi=(()=>{var
|
|
2
|
-
`)?{type:"textarea"}:{type:"text"}}function lr(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=Ne(e).selector;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function ur(e){if(e.type==="textarea")return document.createElement("textarea");if(e.type==="select")return document.createElement("select");let t=document.createElement("input");return t.type=e.type==="checkbox"?"checkbox":e.type==="number"?"number":"text",t}function et(e){return typeof e=="number"?`#${e+1}`:String(e).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^\w/,t=>t.toUpperCase())}function fr(e){return` \xB7 ${e}`}var nn={includeClasses:!0,includeAttributes:["href","src","name","type","role","aria-label","alt","title"],excludeAttributePrefixes:["data-morph-","data-hyper-","data-im-"],textHintLength:64,excludeIds:!0,maxPathDepth:4,landmarks:["HEADER","NAV","MAIN","ASIDE","FOOTER","SECTION","ARTICLE"],weights:{signature:100,pathSegment:10,textMatch:20,textMismatch:25,uniqueCandidate:50,positionPenalty:1,maxDriftPenalty:19,slotMatch:30},minConfidence:101,maxScoredCandidates:16};function dr(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t).toString(36)}function pr(e){if(e.classList&&e.classList.length>0)return Array.from(e.classList).sort().join(" ");let t=e.getAttribute?.("class");return t?t.split(/\s+/).filter(Boolean).sort().join(" "):""}function hr(e,t){let n=[];for(let o of e.attributes||[]){let r=o.name;r==="id"||r==="class"||t.excludeAttributePrefixes.some(s=>r.startsWith(s))||t.includeAttributes.includes(r)&&n.push(`${r}=${o.value}`)}return n.sort().join("|")}function mr(e,t){return(e.textContent||"").replace(/\s+/g," ").trim().slice(0,t.textHintLength)}function gr(e,t){let n=[e.tagName];return t.includeClasses&&n.push(pr(e)),n.push(hr(e,t)),dr(n.join("|"))}function yr(e){let t=e.tagName,n=1,o=e.previousElementSibling;for(;o;)o.tagName===t&&n++,o=o.previousElementSibling;return n}function br(e,t){return e.getAttribute?.("id")||e.getAttribute?.("role")?!0:t.landmarks.includes(e.tagName)}function Ar(e){let t=e.getAttribute?.("id");if(t)return`#${t}`;let n=e.getAttribute?.("role");return n?`@${n}`:e.tagName}function Sr(e,t){let n=[],o=e;for(;o&&o.tagName&&n.length<t.maxPathDepth;){let r=`${o.tagName}:${yr(o)}`;if(n.unshift(r),o!==e&&br(o,t)){n.unshift(Ar(o));break}o=o.parentElement}return n}function Er(e,t){let n=0,o=e.length-1,r=t.length-1;for(;o>=0&&r>=0&&e[o]===t[r];)n++,o--,r--;return n}function se(e,t,n){if(n.has(e))return n.get(e);let o={signature:gr(e,t),path:Sr(e,t),textHint:mr(e,t)};return n.set(e,o),o}function cn(e,t,n,o){if(o.has(e))return o.get(e);let r=new Map,s=e.querySelectorAll("*"),c=0;for(let i of s){let a=se(i,t,n);a.domIndex=c++,!t.shouldIgnore?.(i)&&(r.has(a.signature)||r.set(a.signature,[]),r.get(a.signature).push(i))}return o.set(e,r),r}function wr(e,t,n){n.delete(e),t.delete(e);let o=e.querySelectorAll("*");for(let r of o)t.delete(r)}function mt(e,t,n,o,r){let s=se(e,n,o),c=se(t,n,o),i=n.weights,a={},m=0;if(s.signature!==c.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};m+=i.signature,a.signature=i.signature;let w=Er(s.path,c.path)*i.pathSegment;m+=w,a.path=w;let d=!0;if(s.textHint&&c.textHint?s.textHint===c.textHint?(m+=i.textMatch,a.text=i.textMatch):(m-=i.textMismatch,a.text=-i.textMismatch,d=!1):s.textHint!==c.textHint&&(m-=i.textMismatch,a.text=-i.textMismatch,d=!1),r.candidateCount===1&&d&&(m+=i.uniqueCandidate,a.unique=i.uniqueCandidate),typeof s.domIndex=="number"&&typeof c.domIndex=="number"){let E=Math.abs(s.domIndex-c.domIndex),p=Math.min(E*i.positionPenalty,i.maxDriftPenalty);m-=p,a.drift=-p}return{score:m,breakdown:a}}function rn(e,t,n,o,r){if(n.excludeIds&&e.getAttribute("id"))return null;let s=cn(t,n,o,r),c=se(e,n,o);if(typeof c.domIndex!="number"){let d=0,E=e.previousElementSibling;for(;E;)d++,E=E.previousElementSibling;c.domIndex=d}let i=s.get(c.signature)||[],a=n.excludeIds?i.filter(d=>!d.getAttribute("id")):i;if(a.length===0)return null;let m=null,A=0,w=null;for(let d of a){let{score:E,breakdown:p}=mt(e,d,n,o,{candidateCount:a.length});E>A&&(A=E,m=d,w=p)}return A<n.minConfidence?null:{element:m,confidence:A,breakdown:w}}function Tr(e,t,n,o){let r=[],s=n.weights.signature+n.weights.slotMatch,c={slot:s};function i(w){if(w.children)return w.children;let d=w.childNodes;if(!d)return[];let E=[];for(let p=0;p<d.length;p++)d[p].nodeType===1&&E.push(d[p]);return E}function a(w,d){let E=i(w),p=i(d);if(E.length===p.length)for(let R=0;R<E.length;R++){let x=E[R],k=p[R];if(n.shouldIgnore?.(x)||n.shouldIgnore?.(k)||n.excludeIds&&(x.getAttribute("id")||k.getAttribute("id"))||x.tagName!==k.tagName)continue;let P=se(x,n,o).signature,W=se(k,n,o).signature;P!==W&&r.push({newEl:x,oldEl:k,score:s,breakdown:c}),a(x,k)}}function m(w,d){for(;;){if(w.tagName===d.tagName)return[w,d];let E=i(w);if(!w.tagName&&E.length===1){w=E[0];continue}let p=i(d);if(p.length===1&&p[0].tagName===w.tagName){d=p[0];continue}return null}}let A=m(e,t);return A&&a(A[0],A[1]),r}function on(e,t,n,o,r){let s=t.querySelectorAll("*"),c=cn(e,n,o,r),i=0;for(let E of s){let p=se(E,n,o);p.domIndex=i++}let a=[],m=new Map;function A(E,p,R){let x=new Set;if(E.textHint){let $=m.get(E.signature);if(!$){$=new Map;for(let z of p){let oe=se(z,n,o).textHint,ae=$.get(oe);ae||(ae=[],$.set(oe,ae)),ae.push(z)}m.set(E.signature,$)}let G=$.get(E.textHint);if(G)for(let z=0;z<G.length&&z<R;z++)x.add(G[z])}let k=0,P=p.length;for(;k<P;){let $=k+P>>1;se(p[$],n,o).domIndex<E.domIndex?k=$+1:P=$}let W=Math.max(0,Math.min(k-(R>>1),p.length-R)),K=Math.min(W+R,p.length);for(let $=W;$<K;$++)x.add(p[$]);return[...x]}for(let E of s){if(n.shouldIgnore?.(E)||n.excludeIds&&E.getAttribute("id"))continue;let p=se(E,n,o),R=c.get(p.signature)||[],x=n.excludeIds?R.filter(W=>!W.getAttribute("id")):R,k=n.maxScoredCandidates,P=k&&x.length>k?A(p,x,k):x;for(let W of P){let{score:K,breakdown:$}=mt(E,W,n,o,{candidateCount:x.length});K>=n.minConfidence&&a.push({newEl:E,oldEl:W,score:K,breakdown:$})}}if(n.weights.slotMatch>0){let E=Tr(t,e,n,o);for(let p of E)a.push(p)}a.sort((E,p)=>p.score-E.score);let w=new Map,d=new Set;for(let{newEl:E,oldEl:p}of a)w.has(E)||d.has(p)||(w.set(E,p),d.add(p));return w}function sn(e,t,n,o){let r=se(e,n,o),s=se(t,n,o),{score:c,breakdown:i}=mt(e,t,n,o,{candidateCount:1});return{matches:c>=n.minConfidence,score:c,breakdown:i,newMeta:{signature:r.signature,path:r.path,textHint:r.textHint},oldMeta:{signature:s.signature,path:s.path,textHint:s.textHint}}}function an(e={}){let t={...nn,...e,weights:{...nn.weights,...e.weights}},n=new WeakMap,o=new WeakMap;return{findMatch:(r,s)=>rn(r,s,t,n,o),computeMatches:(r,s)=>on(r,s,t,n,o),explain:(r,s)=>sn(r,s,t,n),invalidate:r=>wr(r,n,o),session:()=>{let r=new WeakMap,s=new WeakMap;return{findMatch:(c,i)=>rn(c,i,t,r,s),computeMatches:(c,i)=>on(c,i,t,r,s),explain:(c,i)=>sn(c,i,t,r)}},getConfig:()=>({...t})}}function gt(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
|
|
3
|
-
`;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);if(n===-1)return e.length;t=n+2;continue}return t}}function ln(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var xr=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Mr=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function tt(e){try{return JSON.parse(e)}catch{return JSON.parse(vr(e))}}function vr(e){let t="",n=0,o=(r,s)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${s}`)};for(;n<e.length&&(n=gt(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let i=gt(e,n+1);if(e[i]==="}"||e[i]==="]"){n++;continue}t+=r,n++;continue}if(r==='"'||r==="'"){let i=n+1;for(;i<e.length&&e[i]!==r;)e[i]==="\\"&&i++,i++;i>=e.length&&o("unterminated string",n);let a=e.slice(n+1,i);r==="'"&&(a=ln(a)),t+='"'+a+'"',n=i+1;continue}let s=n;for(;s<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[s]);)s++;s===n&&o("unexpected character "+JSON.stringify(r),n);let c=e.slice(n,s);if(c==="true"||c==="false"||c==="null"||xr.test(c)){t+=c,n=s;continue}if(Mr.test(c)){if(e[gt(e,s)]===":"){t+='"'+c+'"',n=s;continue}o("unquoted value "+JSON.stringify(c),n)}o("invalid token "+JSON.stringify(c),n)}return t}function un(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let s=[],c=0;for(;c<r.length;){let i=r[c];if(/\s/.test(i)){c++;continue}if("{}".includes(i)){s.push({type:i,value:i}),c++;continue}if(i==="["){let w=!1,d=c+1;for(;d<r.length&&/\s/.test(r[d]);)d++;if(d<r.length&&/[a-zA-Z_]/.test(r[d])&&(w=!0),!w){s.push({type:i,value:i}),c++;continue}}if(i==="]"){s.push({type:i,value:i}),c++;continue}if(i===":"){s.push({type:t.COLON,value:i}),c++;continue}if(i===","){s.push({type:t.COMMA,value:i}),c++;continue}if(i==='"'||i==="'"){let w=i,d=c+1;for(;d<r.length&&r[d]!==w;)r[d]==="\\"&&d++,d++;s.push({type:t.STRING,value:r.substring(c+1,d),quoted:!0,sourceQuote:w}),c=d+1;continue}let a=c,m;for(;a<r.length&&!/[{},]/.test(r[a]);)if(r[a]===":"){let w=[":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"],d=!1;for(let E of w){let p=E.substring(1);if(r.substring(a+1,a+1+p.length)===p){d=!0,a+=p.length;break}}if(!d)break}else if(r[a]==="["){for(a++;a<r.length&&r[a]!=="]";){if(r[a]==='"'||r[a]==="'"){let w=r[a];for(a++;a<r.length&&r[a]!==w;)r[a]==="\\"&&a++,a++}a++}a<r.length&&r[a]==="]"&&a++}else a++;m=r.substring(c,a);let A=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(m)?A=t.NUMBER:m==="true"||m==="false"||m==="null"?A=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(m)&&(A=t.SELECTOR),s.push({type:A,value:m,quoted:!1}),c=a}return s}function o(r){let s="";for(let c=0;c<r.length;c++){let i=r[c];if("{}".includes(i.type)||"[]".includes(i.type)){s+=i.value;continue}if(i.type===t.COLON){s+=i.value;continue}if(i.type===t.COMMA){let a=r[c+1];if(a&&(a.type==="}"||a.type==="]"))continue;s+=i.value;continue}if(i.type===t.STRING){let a=i.value;i.sourceQuote==="'"&&(a=ln(a)),s+=`"${a}"`;continue}if(i.type===t.NUMBER||i.type===t.BOOLEAN){s+=i.value;continue}s+=`"${i.value}"`}return s}try{let r=n(e),s=o(r);return JSON.parse(s)}catch(r){throw new Error("Invalid extraction rules syntax: "+r.message)}}var Q=Symbol("hyper-morph-json-merge:missing"),fn=["id","_id","uuid","key","slug","code","name"];function ke(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function He(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Or(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function he(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!he(e[n],t[n]))return!1;return!0}if(ke(e)&&ke(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!He(t,o)||!he(e[o],t[o]))return!1;return!0}return!1}function dn(e,t,n,o){return he(t,n)?t:he(t,e)?n:he(n,e)?t:ke(t)&&ke(n)?Nr(ke(e)?e:{},t,n,o):Array.isArray(t)&&Array.isArray(n)?Ir(Array.isArray(e)?e:[],t,n,o):n}function pn(e,t,n,o){return t===Q&&n===Q?Q:t===Q?e===Q?n:he(n,e)?Q:n:n===Q?e===Q?t:Q:dn(e,t,n,o)}function Nr(e,t,n,o){let r={},s=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let c of s){let i=pn(He(e,c)?e[c]:Q,He(t,c)?t[c]:Q,He(n,c)?n[c]:Q,o);i!==Q&&Or(r,c,i)}return r}function kr(e){return e===null||typeof e!="object"}function nt(e){return typeof e+":"+String(e)}function Cr(e,t){for(let n of t){let o=new Set;for(let r of n){if(!He(r,e))return!1;let s=r[e];if(typeof s!="string"&&typeof s!="number")return!1;let c=nt(s);if(o.has(c))return!1;o.add(c)}}return!0}function Rr(e,t,n,o){let r=[e,t,n],s=!0;for(let c of r)for(let i of c)ke(i)||(s=!1);if(s){for(let c of o.keyCandidates)if(Cr(c,r))return{kind:"keyed",field:c};return null}for(let c of r){let i=new Set;for(let a of c){if(!kr(a))return null;let m=nt(a);if(i.has(m))return null;i.add(m)}}return{kind:"self"}}function Ir(e,t,n,o){let r=Rr(e,t,n,o);if(!r)return n;let s=r.kind==="self"?nt:E=>nt(E[r.field]),c=E=>{let p=new Map;for(let R of E)p.set(s(R),R);return p},i=c(e),a=c(t),m=c(n),A=new Map,w=new Set([...i.keys(),...a.keys(),...m.keys()]);for(let E of w){let p=pn(i.has(E)?i.get(E):Q,a.has(E)?a.get(E):Q,m.has(E)?m.get(E):Q,o);p!==Q&&A.set(E,p)}let d=[];for(let E of n){let p=s(E);A.has(p)&&d.push(p)}for(let E=0;E<t.length;E++){let p=s(t[E]);if(!A.has(p)||d.includes(p))continue;let R=0;for(let x=E-1;x>=0;x--){let k=d.indexOf(s(t[x]));if(k!==-1){R=k+1;break}}d.splice(R,0,p)}return d.map(E=>A.get(E))}function yt(e,t,n,o={}){let r=o.keyCandidates?[...o.keyCandidates,...fn]:fn;return dn(e===void 0?Q:e,t,n,{keyCandidates:r})}function bt(e,t,n,o={}){let r=o.parse||tt,s=[],c=(w,d)=>{if(typeof w!="string")return Q;try{return r(w)}catch(E){return s.push(`${d} side is not valid JSON (${E.message})`),Q}},i=c(t,"local"),a=c(n,"remote");if(i===Q)return{text:n,warnings:s};if(a===Q)return{text:t,warnings:s};let m=c(e,"base"),A=yt(m===Q?void 0:m,i,a,o);return he(A,a)?{text:n,warnings:s}:he(A,i)?{text:t,warnings:s}:{text:JSON.stringify(A,null,2),warnings:s}}var Lr=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),wo=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),To=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function hn(e){let t=Lr[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}var $e=function(){"use strict";let e=()=>{},t='[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"]',n=`${hn("history")},[no-undo],[clay~="no-undo"]`;function o(l){if(l?.nodeType!==1)return!1;if(l.matches(t))return!0;if(l.tagName==="LINK"||l.tagName==="SCRIPT"){let M=l.getAttribute("src")||l.getAttribute("href")||"";if(M.startsWith("chrome-extension://")||M.startsWith("moz-extension://")||M.startsWith("safari-web-extension://"))return!0}return!1}function r(l){return l?.nodeType!==1?!1:l.closest(t)?!0:o(l)}function s(l,M,T){if(T){let L=T.identityOf(l);if(L&&!T.disabled.has(L.key))return"hm-merge:"+L.key}if(M!=="smart")return l.outerHTML;let I=l.getAttribute("src"),N=l.getAttribute("type")||"text/javascript";if(I)try{let L=new URL(I,window.location.href);return`ext:${N}:${L.origin}${L.pathname}${L.search}`}catch{return`ext:${N}:${I}`}else{let L=l.textContent.trim(),g=5381;for(let y=0;y<L.length;y++)g=(g<<5)+g^L.charCodeAt(y);return`inline:${N}:${Math.abs(g).toString(36)}`}}let c="http://www.w3.org/1999/xhtml";function i(l){return l?.nodeType===1&&l.tagName==="SCRIPT"&&l.namespaceURI===c}function a(l){let M=document.createElement("div");M.innerHTML="<script><\/script>";let T=M.firstChild;for(let I of l.attributes)T.setAttribute(I.name,I.value);return T.textContent=l.textContent,T}function m(l){if(i(l))return a(l);if(l?.nodeType===1)for(let M of l.querySelectorAll("script"))i(M)&&M.replaceWith(a(M));return l}function A(l){let M=(l.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return M==="application/json"||M.endsWith("+json")}let w={match:l=>l.hasAttribute("merge"),identity:l=>l.getAttribute("merge")};function d(l,M,T){if(T.merge===!1)return null;let I=[w,...T.mergeTags||[]],N=new WeakMap,L=f=>{if(N.has(f))return N.get(f);let v=null;if(i(f)&&!f.getAttribute("src")&&!r(f)){let O=f;for(let j=0;j<I.length;j++)if(I[j].match(O)){if(!A(O))console.warn("[hyper-morph] merge ignored: script type is not JSON",O);else{let U=I[j].identity(O);U!=null&&U!==""&&(v={key:j+":"+U,raw:U,recognizer:I[j]})}break}}return N.set(f,v),v},g=new Set,y=f=>{let v=new Map,O=j=>{let U=L(j);U&&(v.has(U.key)?(g.add(U.key),console.warn(`[hyper-morph] merge disabled for duplicate identity "${U.raw}"`)):v.set(U.key,j))};i(f)&&O(f);for(let j of f.querySelectorAll("script"))O(j);return v},b=y(l),u=y(M.__hyperMorphRoot||M);if(b.size===0&&u.size===0)return null;let h=null;return{identityOf:L,disabled:g,oldByKey:b,newByKey:u,baseTexts:()=>{if(h)return h;h=new Map;let f=T.mergeBase;if(!f)return h;let v;typeof f=="string"?v=new DOMParser().parseFromString(f,"text/html").documentElement:f?.nodeType===9?v=f.documentElement:v=f;let O=j=>{let U=L(j);U&&!h.has(U.key)&&h.set(U.key,j.textContent)};i(v)&&O(v);for(let j of v.querySelectorAll("script"))O(j);return h}}}function E(l,M,T){let I=l.merge;if(!I)return!1;let N=I.identityOf(M);if(!N||I.disabled.has(N.key))return!1;let L=I.identityOf(T);if(!L||L.key!==N.key)return!1;let g=M,y=T,b=y.getAttribute("merge-key")||g.getAttribute("merge-key"),{text:u,warnings:h}=bt(I.baseTexts().get(N.key),g.textContent,y.textContent,{parse:N.recognizer.parse,keyCandidates:b?b.split(/[\s,]+/).filter(Boolean):void 0});for(let S of h)console.warn(`[hyper-morph] merge "${N.raw}": ${S}`);return g.textContent!==u&&(g.textContent=u),!0}let p={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:l=>l.getAttribute("im-preserve")==="true",shouldReAppend:l=>l.getAttribute("im-re-append")==="true",shouldRemove:e,afterHeadMorphed:e},scripts:{handle:!0,matchMode:"outerHTML",shouldPreserve:l=>l.getAttribute("im-preserve")==="true",shouldReAppend:l=>l.getAttribute("im-re-append")==="true",shouldRemove:e,afterScriptsHandled:e},restoreFocus:!0},R={computeMatches(l,M,T=r){let{computeMatches:I}=an({shouldIgnore:T}).session();return I(l,M)}};function x(l,M,T={}){l=zn(l);let I=qt(M),N=qn(l,I,T),L=N.scripts.handle?new Set(Array.from(l.querySelectorAll("script")).map(u=>s(u,N.scripts.matchMode,N.merge))):null,g=z(N),y;try{y=Bn(N,l,I,u=>u.morphStyle==="innerHTML"?(ae(u,l,I),Array.from(l.childNodes)):G(u,l,I))}catch(u){throw P(N),u}let b=u=>{g&&oe(N,g),k(N);let h=L?Fn(u,L,N):[];return h.length>0?Promise.all(h).then(()=>u):u};if(y instanceof Promise)return y.then(u=>{try{return b(u)}catch(h){throw P(N),h}},u=>{throw P(N),u});try{return b(y)}catch(u){throw P(N),u}}function k(l){let M=l.pantry;if(M){for(let T of Array.from(M.childNodes))l.callbacks.beforeNodeRemoved(T)!==!1&&l.callbacks.afterNodeRemoved(T);for(let T of Array.from(M.childNodes))M.removeChild(T);M.remove(),l.pantry=null,l.stagedNodes.clear()}}function P(l){let M=l.pantry;if(!M)return;let T=Array.from(l.stagedNodes.entries()).reverse();for(let[I,N]of T){if(!M.contains(I))continue;let L=N.nextSibling?.parentNode===N.parent?N.nextSibling:null;try{K(N.parent,I,L)}catch{}}for(let I of Array.from(M.childNodes))M.removeChild(I);M.remove(),l.pantry=null,l.stagedNodes.clear()}function W(l){if(l.pantry)return l.pantry;let M=l.target.ownerDocument,T=M.createElement("div");return T.hidden=!0,T.setAttribute("mutations-ignore",""),M.body.insertAdjacentElement("afterend",T),l.pantry=T,T}function K(l,M,T){if(l.moveBefore)try{l.moveBefore(M,T)}catch{l.insertBefore(M,T)}else l.insertBefore(M,T)}function $(l,M){!l.stagedNodes.has(M)&&M.parentNode&&l.stagedNodes.set(M,{parent:M.parentNode,nextSibling:M.nextSibling}),K(W(l),M,null)}function G(l,M,T){let I=qt(M);return ae(l,I,T,M,M.nextSibling),Array.from(I.childNodes)}function z(l){if(!l.config.restoreFocus)return null;let M=document.activeElement;if(!(M instanceof HTMLInputElement||M instanceof HTMLTextAreaElement))return null;let{id:T,selectionStart:I,selectionEnd:N}=M;return{element:M,id:T,selectionStart:I,selectionEnd:N}}function oe(l,M){let T=M.element;if(M.id&&M.id!==document.activeElement?.getAttribute("id")&&(T=l.target.querySelector(`[id="${CSS.escape(M.id)}"]`),T?.focus()),T&&!T.selectionEnd&&M.selectionEnd!=null)try{T.setSelectionRange(M.selectionStart,M.selectionEnd)}catch{}}let ae=function(){function l(u,h,S,f=null,v=null){h?.tagName==="TEMPLATE"&&S?.tagName==="TEMPLATE"&&(h=h.content,S=S.content),f||=h.firstChild;for(let O of S.childNodes){if(u.shouldIgnore(O))continue;if(f&&f!=v){let U=I(u,O,f,v);if(U){U!==f&&L(u,f,U),xe(U,O,u),f=U.nextSibling;continue}}if(O?.nodeType===1){let U=O.getAttribute("id");if(u.persistentIds.has(U)){let C=g(h,U,f,u);xe(C,O,u),f=C.nextSibling;continue}if(!u.idMap.has(O)){let C=u.hyperMatches.get(O);if(C&&!u.idMap.has(C)&&!b(C,h)){K(h,C,f),xe(C,O,u),f=C.nextSibling;continue}}}let j=M(h,O,f,u);j&&(f=j.nextSibling)}for(;f&&f!=v;){let O=f;f=f.nextSibling,u.shouldIgnore(O)||N(u,O)}}function M(u,h,S,f){if(f.callbacks.beforeNodeAdded(h)===!1)return null;let v=u.ownerDocument||u.realParentNode?.ownerDocument||f.target.ownerDocument;if(f.idMap.has(h)){let O=h,j=v.createElementNS(O.namespaceURI,O.localName);return u.insertBefore(j,S),xe(j,h,f),f.callbacks.afterNodeAdded(j),j}else{let O=m(T(h,v,f));return O?(u.insertBefore(O,S),f.callbacks.afterNodeAdded(O),O):null}}function T(u,h,S){if(S.shouldIgnore(u))return null;let f=h.importNode(u,!1),v=u.nodeType===1&&u.tagName==="TEMPLATE"?u.content:u,O=f.nodeType===1&&f.tagName==="TEMPLATE"?f.content:f;for(let j of Array.from(v.childNodes||[])){let U=T(j,h,S);U&&O.appendChild(U)}return f}let I=function(){function u(f,v,O,j){let U=v?.nodeType===1&&!f.idMap.has(v)?f.hyperMatches.get(v):null,C=null,D=v.nextSibling,V=0,F=O;for(;F&&F!=j;){if(f.shouldIgnore(F)){F=F.nextSibling;continue}if(S(F,v)){if(h(f,F,v)||F===U&&!f.idMap.has(F))return F;if(C===null){let Z=F?.nodeType===1&&f.hyperMatchedOldElements.has(F);!f.idMap.has(F)&&!Z&&(C=F)}}if(C===null&&D&&S(F,D)&&(V++,D=D.nextSibling,V>=2&&(C=void 0)),f.activeElementAndParents.includes(F))break;F=F.nextSibling}return C||null}function h(f,v,O){let j=f.idMap.get(v),U=f.idMap.get(O);if(!U||!j)return!1;for(let C of j)if(U.has(C))return!0;return!1}function S(f,v){let O=f,j=v;return O.nodeType===j.nodeType&&O.tagName===j.tagName&&(!O.getAttribute?.("id")||O.getAttribute?.("id")===j.getAttribute?.("id"))}return u}();function N(u,h){let S=h?.nodeType===1&&u.hyperMatchedOldElements.has(h)&&!u.idMap.has(h);if(u.idMap.has(h)||S)$(u,h);else{if(u.callbacks.beforeNodeRemoved(h)===!1)return;h.parentNode?.removeChild(h),u.callbacks.afterNodeRemoved(h)}}function L(u,h,S){let f=h;for(;f&&f!==S;){let v=f;f=f.nextSibling,u.shouldIgnore(v)||N(u,v)}return f}function g(u,h,S,f){let v=f.target.ownerDocument?.defaultView?.CSS?.escape?f.target.ownerDocument.defaultView.CSS.escape(h):String(h).replace(/["\\]/g,"\\$&"),O=f.target.getAttribute?.("id")===h&&f.target||f.target.querySelector(`[id="${v}"]`)||f.pantry?.querySelector(`[id="${v}"]`);return y(O,f),K(u,O,S),O}function y(u,h){let S=u.getAttribute("id");for(;u=u.parentNode;){let f=h.idMap.get(u);f&&(f.delete(S),f.size||h.idMap.delete(u))}}function b(u,h){let S=h?.nodeType===1?h:h.realParentNode;return!!S&&u.contains(S)}return l}(),xe=function(){function l(g,y,b){return b.ignoreActive&&g===document.activeElement?null:(b.callbacks.beforeNodeMorphed(g,y)===!1||(g?.tagName==="HEAD"&&b.head.ignore||(g?.tagName==="HEAD"&&b.head.style!=="morph"?Ft(g,y,b):(M(g,y,b),E(b,g,y)||L(g,b)||ae(b,g,y))),b.callbacks.afterNodeMorphed(g,y)),g)}function M(g,y,b){let u=y.nodeType;if(u===1){let h=g,S=y,f=h.attributes,v=S.attributes;for(let O of v)N(O.name,h,"update",b)||h.getAttribute(O.name)!==O.value&&h.setAttribute(O.name,O.value);for(let O=f.length-1;0<=O;O--){let j=f[O];if(j&&!S.hasAttribute(j.name)){if(N(j.name,h,"remove",b))continue;h.removeAttribute(j.name)}}L(h,b)||T(h,S,b)}(u===8||u===3)&&g.nodeValue!==y.nodeValue&&(g.nodeValue=y.nodeValue)}function T(g,y,b){if(g.tagName==="INPUT"&&y.tagName==="INPUT"&&y.type!=="file"){let u=y.value,h=g.value;I(g,y,"checked",b),I(g,y,"disabled",b),b.formStateSync==="property"&&g.indeterminate!==y.indeterminate&&(g.indeterminate=y.indeterminate),b.formStateSync==="property"?h!==u&&(N("value",g,"update",b)||(g.value=u)):y.hasAttribute("value")?h!==u&&(N("value",g,"update",b)||(g.setAttribute("value",u),g.value=u)):N("value",g,"remove",b)||(g.value="",g.removeAttribute("value"))}else if(g.tagName==="OPTION"&&y.tagName==="OPTION")I(g,y,"selected",b);else if(g.tagName==="TEXTAREA"&&y.tagName==="TEXTAREA"){let u=y.value,h=g.value;if(N("value",g,"update",b)||(u!==h&&(g.value=u),b.formStateSync==="property"))return;g.firstChild&&g.firstChild.nodeValue!==u&&(g.firstChild.nodeValue=u)}}function I(g,y,b,u){let h=y[b],S=g[b];if(h!==S){let f=N(b,g,"update",u);if(f||(g[b]=y[b]),u.formStateSync==="property")return;h?f||g.setAttribute(b,""):N(b,g,"remove",u)||g.removeAttribute(b)}}function N(g,y,b,u){return g==="value"&&u.ignoreActiveValue&&y===document.activeElement?!0:u.callbacks.beforeAttributeUpdated(g,y,b)===!1}function L(g,y){return!!y.ignoreActiveValue&&g===document.activeElement&&g!==document.body}return l}();function Bn(l,M,T,I){if(l.head.block){let N=M.querySelector("head"),L=T.querySelector("head");if(N&&L){let g=Ft(N,L,l);return Promise.all(g).then(()=>(l.head.block=!1,l.head.ignore=!0,I(l)))}}return I(l)}function Un(l){return l.tagName==="SCRIPT"?!!l.getAttribute("src"):l.tagName==="LINK"?(l.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet")&&!!l.getAttribute("href"):!1}function Ft(l,M,T){let I=[],N=[],L=[],g=[],y=T.scripts.matchMode,b=S=>{if(S.tagName==="SCRIPT")return s(S,y,T.merge);if(S.tagName==="LINK"&&y==="smart"){let f=S.getAttribute("href");if(f)try{let v=new URL(f,window.location.href);return`link:${S.getAttribute("rel")||""}:${v.origin}${v.pathname}${v.search}`}catch{}}return S.outerHTML},u=new Map;for(let S of M.children){if(T.shouldIgnore(S))continue;let f=b(S),v=u.get(f);v||(v=[],u.set(f,v)),v.push(S)}for(let S of l.children){let f=b(S),v=u.get(f),O=!!(v&&v.length),j=T.head.shouldReAppend(S),U=T.head.shouldPreserve(S);if(O||U)if(j)N.push(S);else{if(v&&v.length){let C=v.pop();v.length||u.delete(f),E(T,S,C)}L.push(S)}else T.head.style==="append"?j&&(N.push(S),g.push(S)):T.head.shouldRemove(S)!==!1&&!T.shouldIgnore(S)&&N.push(S)}for(let S of u.values())g.push(...S);let h=[];for(let S of g){let f=document.createRange().createContextualFragment(S.outerHTML).firstChild;if(T.callbacks.beforeNodeAdded(f)!==!1){if(f instanceof Element&&Un(f)){let v,O=new Promise(function(j){v=j});f.addEventListener("load",function(){v()}),f.addEventListener("error",function(){v()}),h.push(O)}l.appendChild(f),T.callbacks.afterNodeAdded(f),I.push(f)}}for(let S of N)T.callbacks.beforeNodeRemoved(S)!==!1&&(l.removeChild(S),T.callbacks.afterNodeRemoved(S));return T.head.afterHeadMorphed(l,{added:I,kept:L,removed:N}),h}function Fn(l,M,T){if(!T.scripts.handle)return[];let I=[],N=[],L=[],g=[],y=T.scripts.matchMode,b=[];for(let h of l)if(h instanceof Element){i(h)&&b.push(h);for(let S of h.querySelectorAll("script"))i(S)&&b.push(S)}for(let h of b){if(h.closest("head")||T.shouldIgnore(h))continue;let S=s(h,y,T.merge),f=M.has(S),v=T.scripts.shouldPreserve(h),O=T.scripts.shouldReAppend(h);f||v?O?(N.push(h),g.push(h)):L.push(h):g.push(h)}let u=[];for(let h of g){if(T.callbacks.beforeNodeAdded(h)===!1)continue;let S=document.createElement("script");for(let f of h.attributes)S.setAttribute(f.name,f.value);if(S.textContent=h.textContent,S.src){let f,v=new Promise(function(O){f=O});S.addEventListener("load",function(){f()}),S.addEventListener("error",function(){f()}),u.push(v)}h.replaceWith(S),T.callbacks.afterNodeAdded(S),I.push(S)}return T.scripts.afterScriptsHandled(T.target,{added:I,kept:L,removed:N}),u}let qn=function(){function l(y,b,u){let h=u.policy==="history"?n:t,S=u.policy==="raw"?()=>!1:V=>{if(V?.nodeType!==1)return!1;if(u.policy!=="history"&&r(V))return!0;let F=V.closest(h);return!(!F||u.policy==="history"&&F===y&&F.matches('[no-undo],[clay~="no-undo"]')&&!F.matches('[editor-ui],[clay~="editor-ui"]'))},{persistentIds:f,idMap:v}=L(y,b,S),O=R.computeMatches(y,b,S);if(typeof u.key=="function"){let V=new Map,F=new Set,Z=H=>{let B=u.key(H);B!=null&&(V.has(B)?F.add(B):V.set(B,H))};y instanceof Element&&Z(y);for(let H of y.querySelectorAll("*"))Z(H);for(let H of F)V.delete(H);let ne=new Map;for(let[H,B]of O)ne.set(B,H);let re=b.__hyperMorphRoot||b,Y=new Map,_=new Set,J=H=>{let B=u.key(H);B!=null&&(Y.has(B)?_.add(B):Y.set(B,H))};re instanceof Element&&J(re);for(let H of re.querySelectorAll("*"))J(H);for(let H of _)Y.delete(H);for(let[H,B]of Y){let X=V.get(H);if(!X||X.tagName!==B.tagName)continue;let ye=ne.get(X);ye&&ye!==B&&O.delete(ye);let be=O.get(B);be&&be!==X&&ne.delete(be),O.set(B,X),ne.set(X,B)}}let j=M(u),U=d(y,b,j.scripts);if(U){let V=new Map;for(let[F,Z]of O)V.set(Z,F);for(let[F,Z]of U.newByKey){if(U.disabled.has(F))continue;let ne=U.oldByKey.get(F);if(!ne)continue;let re=V.get(ne);re&&re!==Z&&O.delete(re);let Y=O.get(Z);Y&&Y!==ne&&V.delete(Y),O.set(Z,ne),V.set(ne,Z)}}let C=new Set;for(let V of O.values())C.add(V);let D=j.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(D))throw new Error(`Do not understand how to morph style ${D}`);return{target:y,newContent:b,config:j,morphStyle:D,ignoreActive:j.ignoreActive,ignoreActiveValue:j.ignoreActiveValue,restoreFocus:j.restoreFocus,formStateSync:j.formStateSync||"attribute",idMap:v,persistentIds:f,hyperMatches:O,hyperMatchedOldElements:C,merge:U,pantry:null,stagedNodes:new Map,activeElementAndParents:T(y),callbacks:j.callbacks,head:j.head,scripts:j.scripts,shouldIgnore:S}}function M(y){let b=Object.assign({},p);return Object.assign(b,y),b.callbacks=Object.assign({},p.callbacks,y.callbacks),b.head=Object.assign({},p.head,y.head),b.scripts=Object.assign({},p.scripts,y.scripts),b}function T(y){let b=[],u=y.ownerDocument?.activeElement;if(u?.tagName!=="BODY"&&y.contains(u))for(;u&&(b.push(u),u!==y);)u=u.parentElement;return b}function I(y){let b=Array.from(y.querySelectorAll("[id]"));return y.getAttribute?.("id")&&b.push(y),b}function N(y,b,u,h){for(let S of h){let f=S.getAttribute("id");if(b.has(f)){let v=S;for(;v;){let O=y.get(v);if(O==null&&(O=new Set,y.set(v,O)),O.add(f),v===u)break;v=v.parentElement}}}}function L(y,b,u){let h=I(y).filter(j=>!u(j)),S=I(b).filter(j=>!u(j)),f=g(h,S),v=new Map;N(v,f,y,h);let O=b.__hyperMorphRoot||b;return N(v,f,O,S),{persistentIds:f,idMap:v}}function g(y,b){let u=new Set,h=new Map;for(let f of y){let v=f.getAttribute("id");h.has(v)?u.add(v):h.set(v,f.tagName)}let S=new Set;for(let f of b){let v=f.getAttribute("id");S.has(v)?u.add(v):h.get(v)===f.tagName&&S.add(v)}for(let f of u)S.delete(f);return S}return l}(),{normalizeElement:zn,normalizeParent:qt}=function(){let l=new WeakSet;function M(g){return g?.nodeType===9?g.documentElement:g}function T(g){if(g==null)return document.createElement("div");if(typeof g=="string")return T(L(g));if(l.has(g))return g;if(g&&typeof g=="object"&&"nodeType"in g){if(g.parentNode)return new I(g);{let y=g.ownerDocument.createElement("div");return y.append(g),y}}else{let b=[...g][0]?.ownerDocument?.createElement("div")||document.createElement("div");for(let u of[...g])b.append(u);return b}}class I{constructor(y){this.originalNode=y,this.realParentNode=y.parentNode,this.previousSibling=y.previousSibling,this.nextSibling=y.nextSibling}get childNodes(){let y=[],b=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;b&&b!=this.nextSibling;)y.push(b),b=b.nextSibling;return y}querySelectorAll(y){return this.childNodes.reduce((b,u)=>{if(u instanceof Element){u.matches(y)&&b.push(u);let h=u.querySelectorAll(y);for(let S=0;S<h.length;S++)b.push(h[S])}return b},[])}insertBefore(y,b){return this.realParentNode.insertBefore(y,b)}moveBefore(y,b){return this.realParentNode.moveBefore(y,b)}get __hyperMorphRoot(){return this.originalNode}}function N(g){let y=S=>`<${S}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,b=g.replace(/<!--[\s\S]*?-->/g,"");for(let S of["script","style","textarea","title"])b=b.replace(new RegExp(`${y(S)}[\\s\\S]*?</${S}\\s*>`,"gi"),"");let u=new RegExp(`${y("svg")}[\\s\\S]*?</svg\\s*>`,"gi"),h;do h=b,b=b.replace(u,"");while(b!==h);return b}function L(g){let y=new DOMParser,b=N(g);if(b.match(/<\/html>/)||b.match(/<\/head>/)||b.match(/<\/body>/)){let u=y.parseFromString(g,"text/html");if(b.match(/<\/html>/))return l.add(u),u;{let h=u.firstChild;return h&&l.add(h),h}}else{let h=y.parseFromString("<body><template>"+g+"</template></body>","text/html").body.querySelector("template").content;return l.add(h),h}}return{normalizeElement:M,normalizeParent:T}}(),zt=Symbol("hyper-morph-duplicate-key"),Vt=[l=>l.getAttribute("data-id"),l=>l.getAttribute("id")];function je(l,M){return M.map(T=>{let I=new Map;for(let N of l){if(N.nodeType!==1)continue;let L=T(N);L==null||L===""||I.set(L,I.has(L)?zt:N)}return I})}function Wt(l,M,T,I){for(let N=0;N<I.length;N++){let L=I[N](l);if(L==null||L===""||M[N].get(L)!==l)continue;let g=T[N].get(L);if(!(!g||g===zt)&&g.tagName===l.tagName)return g}return null}function Me(l,M,T){for(let I=0;I<T.length;I++){let N=T[I](l);if(!(N==null||N==="")&&M[I].get(N)===l)return!0}return!1}function Vn(l,M,T={}){let I=T.skip||(()=>!1),N=T.ignoreAttr||(()=>!1),L=T.tiers&&T.tiers.length?T.tiers:Vt,g=null;function y(){return g||(g=je([l,...l.querySelectorAll("*")],L)),g}let b=null;function u(){return b||(b=je([M,...M.querySelectorAll("*")],L)),b}function h(_){return!_.parentElement||!_.parentElement.parentElement}function S(_,J,H){return h(_)||Me(_,y(),L)?(H.push({type:"subtree",el:_,base:J}),!1):!0}function f(_,J){let H=[];for(let B of _.attributes)N(_,B.name)||J.getAttribute(B.name)!==B.value&&H.push(B.name);for(let B of J.attributes)N(_,B.name)||_.hasAttribute(B.name)||H.push(B.name);return H}function v(_){let J=[],H=null,B=()=>{H!==null&&(J.push({nodeType:3,nodeValue:H}),H=null)};for(let X of _.childNodes){if(X.nodeType===3){H=(H===null?"":H)+X.nodeValue;continue}X.nodeType===1&&I(X)||(B(),(X.nodeType===1||X.nodeType===8)&&J.push(X))}return B(),J}function O(_,J){if(_.nodeType!==J.nodeType)return!1;if(_.nodeType!==1)return!0;if(_.tagName!==J.tagName)return!1;for(let H of L){let B=H(_),X=H(J);if(B!=null&&B!==""&&X!=null&&X!==""&&B!==X)return!1}return!0}function j(_){let J="";for(let H of _)H.nodeType===3&&H.nodeValue.trim()!==""?J+="\0"+H.nodeValue:H.nodeType===8&&(J+=""+H.nodeValue);return J}function U(_,J,H){let B=v(_),X=v(J);if(B.length===X.length){let q=!0;for(let ee=0;ee<B.length;ee++)if(!O(B[ee],X[ee])){q=!1;break}if(q){for(let ee=0;ee<B.length;ee++){let ve=B[ee];if(ve.nodeType===1){if(C(ve,X[ee],H))return!0}else if(ve.nodeValue!==X[ee].nodeValue)return!0}return!1}}let ye=B.filter(q=>q.nodeType===1),be=X.filter(q=>q.nodeType===1);if(j(B)!==j(X))return!0;let Kt=je(ye,L),Jt=je(be,L),ct=[],at=new Set,Yt=[];for(let q of ye){let ee=Wt(q,Kt,Jt,L);ee&&!at.has(ee)?(ct.push([q,ee]),at.add(ee)):Yt.push(q)}let fe=[];for(let q of Yt)Me(q,Kt,L)?H.push({type:"subtree",el:q,base:null}):fe.push(q);let Pe=[];for(let q of be)at.has(q)||(Me(q,Jt,L)?H.push({type:"deletion",el:q}):Pe.push(q));if(fe.length!==Pe.length)return!0;for(let q=0;q<fe.length;q++)if(!O(fe[q],Pe[q]))return!0;let Gt=new Map(ct);for(let q=0;q<fe.length;q++)Gt.set(fe[q],Pe[q]);let Xt=-1;for(let q of ye){let ee=Gt.get(q);if(!ee)continue;let ve=be.indexOf(ee);if(ve<Xt)return!0;Xt=ve}for(let q=0;q<fe.length;q++)if(C(fe[q],Pe[q],H))return!0;for(let[q,ee]of ct)if(C(q,ee,H))return!0;return!1}function C(_,J,H){if(_.tagName!==J.tagName)return S(_,J,H);let B=f(_,J),X=[];if(U(_,J,X))return S(_,J,H);if(B.length){if(!h(_)&&!Me(J,u(),L))return!0;H.push({type:"attrs",el:_,names:B,base:J})}return H.push(...X),!1}let D=[],V=f(l,M);V.length&&D.push({type:"attrs",el:l,names:V});let F=(_,J)=>Array.from(_.children).find(H=>H.tagName===J)||null,Z=F(l,"HEAD"),ne=F(M,"HEAD");if(Z&&ne){let _=[];C(Z,ne,_),_.length&&D.push({type:"head",el:Z})}else(Z||ne)&&Z&&D.push({type:"head",el:Z});let re=F(l,"BODY"),Y=F(M,"BODY");return re&&Y?C(re,Y,D):re&&D.push({type:"subtree",el:re,base:null}),{entries:D}}function Wn(l,M,T={}){let I=T.tiers&&T.tiers.length?T.tiers:Vt,N=l.documentElement,L=[],g=0,y=C=>({ok:!1,placed:L,held:C,skippedAttrs:g});if(!N)return y(null);function b(C){let D=[C,...C.querySelectorAll("*")];return je(D,I)}let u=b(N),h=new Map,S=C=>{let D=C.getRootNode(),V=h.get(D);if(!V){let F=D.nodeType===9?D.documentElement:D;V=b(F),h.set(D,V)}return V};function f(C){if(!C.parentElement&&C.tagName==="HTML")return N;if(C.parentElement&&!C.parentElement.parentElement&&C.parentElement.tagName==="HTML"){if(C.tagName==="BODY")return l.body||null;if(C.tagName==="HEAD")return l.head||null}return null}function v(C){let D=f(C);return D||Wt(C,S(C),u,I)}function O(C){if(!C)return null;let D=v(C);return D&&D.isConnected?D:null}function j(C){for(let D=0;D<I.length;D++){let V=I[D](C);V!=null&&V!==""&&u[D].set(V,C)}}for(let C of M){if(C.type!=="deletion")continue;let D=v(C.el);D&&D!==N&&D.remove()}let U=M.filter(C=>C.type!=="deletion").sort((C,D)=>C.el===D.el?0:C.el.compareDocumentPosition(D.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let C of U){if(C.type==="head"){let Y=l.importNode(C.el,!0);l.head?l.head.replaceWith(Y):N.insertBefore(Y,N.firstChild),L.push({entry:C,imported:Y});continue}if(C.type==="attrs"){let Y=O(C.el)||O(C.base);if(!Y){g++;continue}for(let _ of C.names)C.el.hasAttribute(_)?Y.setAttribute(_,C.el.getAttribute(_)):Y.removeAttribute(_);continue}let D=C.el;if(f(D))return y(C);let V=O(D)||O(C.base);if(V){let Y=l.importNode(D,!0);V.replaceWith(Y),j(Y),L.push({entry:C,imported:Y});continue}if(C.base!=null&&!Me(C.base,S(C.base),I)||!Me(D,S(D),I))return y(C);let F=D.parentElement;if(!F)return y(C);let Z=O(F);if(!Z)return y(C);let ne=null;for(let Y=D.previousElementSibling;Y;Y=Y.previousElementSibling){let _=O(Y);if(_&&_.parentNode===Z){ne=_;break}}let re=l.importNode(D,!0);if(ne)Z.insertBefore(re,ne.nextSibling);else{let Y=Array.prototype.indexOf.call(F.children,D);Z.insertBefore(re,Z.children[Y]||null)}j(re),L.push({entry:C,imported:re})}return{ok:!0,placed:L,held:null,skippedAttrs:g}}return{morph:x,defaults:p,findChangedRoots:Vn,spliceProtected:Wn,mergeJson:yt,mergeScriptText:bt,parseJsonRelaxed:tt,parseRulesRelaxed:un}}();var ko=$e.morph,Co=$e.defaults,Ro=$e.findChangedRoots,Io=$e.spliceProtected;var mn=$e;function At(e,t,{onWidgetRemoved:n}={}){mn.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=Qe.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var Pr="hha:upgrade-check:";function le(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function St(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function gn(e,t){let n=St(e),o=St(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let s=0;s<r;s++){let c=n[s]||0,i=o[s]||0;if(c!==i)return c>i}return!1}function Dr(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Hr(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Et({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:s=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(d=>fetch(d)),r=r??Date.now(),!t)return null;let c=le(t,"hyper-source");if(!c)return null;let i=le(t,"hyper-version"),a;try{a=new URL(c,n?n.href:void 0)}catch{return null}if(n&&a.origin===n.origin&&a.pathname===n.pathname)return null;let m=`${Pr}${a.href}:${i||"none"}`,A,w=e?null:Dr(m);if(w&&typeof w.checkedAt=="number"&&r-w.checkedAt<s)A=w.sourceVersion;else{try{let d=await o(a.href);if(!d.ok)throw new Error(`HTTP ${d.status}`);let E=await d.text(),p=new DOMParser().parseFromString(E,"text/html");A=le(p,"hyper-version")}catch{A=null}Hr(m,{checkedAt:r,sourceVersion:A})}return A?{available:gn(A,i||"0.0.0"),currentVersion:i,sourceVersion:A,sourceUrl:a.href}:null}var rt=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],wt=new Set(rt),yn=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Tt=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var ot={};ut(ot,{EmptyListInsert:()=>Be,MAX_RULE_DEPTH:()=>Re,MaxRuleDepthExceeded:()=>Se,RuleTargetReadOnly:()=>Ue,RulesParseError:()=>Ce,ShapeMismatch:()=>_e,UnknownRulesVersion:()=>Ae});var Ce=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},Ae=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},Re=20,Se=class extends Error{constructor(t){super(`rule depth exceeded ${Re} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},_e=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},Be=class extends Error{constructor(t){super(`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},Ue=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}};function ue(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return xt(e,t,n,{depth:0,path:[]},o)}function xt(e,t,n,o,r){if(o.depth>Re)throw new Se(o.path);if(typeof n=="string")return $r(e,t,n,o,r);if(Array.isArray(n)){let[s,c]=n,i=e.find(t,s,r);return An(r,o,i),i.map((a,m)=>xt(e,a,c,{depth:o.depth+1,path:[...o.path,m]},r))}if(typeof n=="object"&&n!==null){let s={};for(let[c,i]of Object.entries(n))s[c]=xt(e,t,i,{depth:o.depth+1,path:[...o.path,c]},r);return s}return null}function $r(e,t,n,o,r){if(n.endsWith("[]")){let i=n.slice(0,-2),a=e.find(t,i,r);return An(r,o,a),a.map(m=>e.text(m))}if(n.startsWith("@"))return bn(e,t,n.slice(1));let s=pe(n);if(s!==-1){let i=n.slice(0,s),a=n.slice(s+1),m=i?e.find(t,i,r):[t];return m.length===0?null:bn(e,m[0],a)}if(n===".")return e.text(t);let c=e.find(t,n,r);return c.length===0?null:e.text(c[0])}function An(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function bn(e,t,n){if(wt.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}var Sn=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),_r=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Wo=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function Mt(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Br(e,t){if(Mt(e,t))return!0;for(let[n,o]of Object.entries(_r))if(o.includes(t)&&Mt(e,n))return!0;return!1}function Fe(e){let t=Sn[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Ur(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=Sn[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Br(n,r))||o.bundles.some(r=>Mt(n,r)))return n;n=n.parentElement}return null}function En(e,t){return!!Ur(e,t)}var Fr=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function wn(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)t.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Tn(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function xn(e,t,n,o,r,s,c,i){if(e.nodeType===1&&((c?En(e,n):Tn(e,o,s,!1))||r&&Tn(e,r,s,c)))return null;let a=t.importNode(e,!1);i.cloneToLive.set(a,e),i.liveToClone.set(e,a);let m=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,A=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;m!==e&&(i.cloneToLive.set(A,m),i.liveToClone.set(m,A));for(let w of m.childNodes||[]){let d=xn(w,t,n,o,r,s,c,i);d&&(A.appendChild(d),w.nodeType===1&&wn(w,d))}return e.nodeType===1&&wn(e,a),a}function qe(e,{capability:t="data",exclude:n=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=r.implementation.createHTMLDocument(""),c=new WeakMap,i=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let m=Fe(t),A=xn(a,s,t,m,n,a,o,{cloneToLive:c,liveToClone:i});e.nodeType===9&&A&&(s.replaceChild(A,s.documentElement),i.set(e,s),c.set(s,e));let w=d=>{if(Fr.test(d))throw new Error(`Filtered content queries do not support stateful selector: ${d}`)};return{root:A,document:s,capability:t,selector:Fe(t),cloneToLive:c,liveToClone:i,original(d){return c.get(d)||null},cloneOf(d){return i.get(d)||null},query(d,E=A){return w(d),Array.from(E.querySelectorAll(d),p=>c.get(p)||p)},text(d=A){return(d===A?A:i.get(d))?.textContent||""},html(d=A){return(d===A?A:i.get(d))?.innerHTML??""},clone(d=A){let E=d===A?A:i.get(d);return E?s.importNode(E,!0):null}}}function Mn(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function qr(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var te={semanticExclude:!0,find(e,t,n={}){let o=qr(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(i=>!Mn(i)));let s=[];n.skip&&s.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&s.push("["+c+"]"),s.length){let i=s.join(", ");r=r.filter(a=>!a.closest||!a.closest(i))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Ee(e,t={}){if(t.exclude===null)return te;let n=[Fe("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return te;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,i=null,a=()=>i||(i=qe(s,{capability:"data",exclude:t.exclude||null})),m=p=>{let R=a();return p===e?R.cloneOf(e):R.cloneOf(p)||p},A=p=>i?.original(p)||p,w=(p,R)=>{a().liveToClone.set(p,R),a().cloneToLive.set(R,p);let x=p.childNodes||[],k=R.childNodes||[];for(let P=0;P<Math.min(x.length,k.length);P++)w(x[P],k[P])},d=(p,R,x,k)=>{let P=Array.from(p.childNodes).filter(z=>i.cloneOf(z)),K=P[0];for(;K&&P.includes(K);)K=K.nextSibling;for(let z of P)z.remove();if(x==="innerHTML"){let z=c.createElement("template");z.innerHTML=k;for(let oe of Array.from(z.content.childNodes))p.insertBefore(oe,K||null)}else p.insertBefore(c.createTextNode(k),K||null);let $=qe(p,{capability:"data",exclude:t.exclude||null});R.replaceChildren(...Array.from($.root?.childNodes||[]));let G=z=>{let oe=$.original(z);oe&&(i.liveToClone.set(oe,z),i.cloneToLive.set(z,oe));for(let ae of Array.from(z.childNodes||[]))G(ae)};for(let z of Array.from(R.childNodes))G(z)},E={...te,find(p,R,x={}){let k=m(p);if(!k?.querySelectorAll)return[];let P=a().query(R,k);x.includeRulesTag||(P=P.filter($=>!Mn($)));let W=[];x.skip&&W.push(x.skip);let K=x.templateAttr===null?null:x.templateAttr||"cms-template";if(K&&W.push(`[${K}]`),W.length){let $=W.join(", ");P=P.filter(G=>!G.closest?.($))}return P},parent(p){let R=m(p)?.parentElement;return R?A(R):null},children(p){return Array.from(m(p)?.children||[],A)},text(p,R){if(R===void 0){let P=A(p);return!P?.matches?.(n)&&!P?.querySelector?.(n)?te.text(P):(m(p)?.textContent||"").trim()}let x=A(p);if(!x?.matches?.(n)&&!x?.querySelector?.(n)&&!i){te.text(x,R);return}let k=a().cloneOf(x);k?d(x,k,"textContent",R):te.text(x,R)},attr(p,R,x){let k=A(p);if(x===void 0)return te.attr(k,R);te.attr(k,R,x);let P=i?.cloneOf(k);P&&(te.attr(P,R,x),qe(k,{capability:"data",exclude:t.exclude||null}).root===null&&(P.remove(),i.liveToClone.delete(k),i.cloneToLive.delete(P)))},removeAttr(p,R){let x=A(p);te.removeAttr(x,R);let k=i?.cloneOf(x);k&&te.removeAttr(k,R)},prop(p,R,x){let k=A(p);if(x===void 0)return R==="innerHTML"||R==="outerHTML"||R==="textContent"||R==="innerText"?te.prop(m(k),R):te.prop(k,R);let P=R==="innerHTML"||R==="textContent"||R==="innerText",W=P?a().cloneOf(k):i?.cloneOf(k);W&&P?d(k,W,R,x):(te.prop(k,R,x),W&&te.prop(W,R,x))},clone(p){let R=m(p);return R===p?te.clone(p):c.importNode(R,!0)},insertAt(p,R,x){let k=A(p),W=E.children(k)[x]||(()=>{for(let G=k.children.length-1;G>=0;G--){let z=k.children[G];if(a().cloneOf(z))return z.nextElementSibling}return k.firstElementChild})(),K=A(R);k.insertBefore(K,W||null);let $=a().cloneOf(k);if($){let G=a().cloneOf(K);G||(G=c.importNode(K,!0),w(K,G));let z=Array.from($.children);$.insertBefore(G,z[x]||null)}},remove(p){let R=A(p),x=a().cloneOf(R);te.remove(R),x&&te.remove(x)},replaceWith(p,R){let x=A(p),k=a().cloneOf(x),P=te.replaceWith(x,R);if(k){let W=qe(P,{capability:"data",exclude:t.exclude||null});if(!W.root)k.remove();else{k.replaceWith(W.root);let K=$=>{let G=W.original($);G&&(i.liveToClone.set(G,$),i.cloneToLive.set($,G));for(let z of Array.from($.childNodes||[]))K(z)};K(W.root)}}return P}};return E}var ce=te;function vt(e){try{return JSON.parse(e)}catch(t){throw new Ce(`Invalid strict JSON: ${t.message}`,t)}}function we(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let s=[],c=0;for(;c<r.length;){let i=r[c];if(/\s/.test(i)){c++;continue}if("{}".includes(i)){s.push({type:i,value:i}),c++;continue}if(i==="["){let w=!1,d=c+1;for(;d<r.length&&/\s/.test(r[d]);)d++;if(d<r.length&&/[a-zA-Z_]/.test(r[d])&&(w=!0),!w){s.push({type:i,value:i}),c++;continue}}if(i==="]"){s.push({type:i,value:i}),c++;continue}if(i===":"){s.push({type:t.COLON,value:i}),c++;continue}if(i===","){s.push({type:t.COMMA,value:i}),c++;continue}if(i==='"'||i==="'"){let w=i,d=c+1;for(;d<r.length&&r[d]!==w;)r[d]==="\\"&&d++,d++;s.push({type:t.STRING,value:r.substring(c+1,d),quoted:!0,sourceQuote:w}),c=d+1;continue}let a=c,m;for(;a<r.length&&!/[{},]/.test(r[a]);)if(r[a]===":"){let w=[":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"],d=!1;for(let E of w){let p=E.substring(1);if(r.substring(a+1,a+1+p.length)===p){d=!0,a+=p.length;break}}if(!d)break}else if(r[a]==="["){for(a++;a<r.length&&r[a]!=="]";){if(r[a]==='"'||r[a]==="'"){let w=r[a];for(a++;a<r.length&&r[a]!==w;)r[a]==="\\"&&a++,a++}a++}a<r.length&&r[a]==="]"&&a++}else a++;m=r.substring(c,a);let A=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(m)?A=t.NUMBER:m==="true"||m==="false"||m==="null"?A=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(m)&&(A=t.SELECTOR),s.push({type:A,value:m,quoted:!1}),c=a}return s}function o(r){let s="";for(let c=0;c<r.length;c++){let i=r[c];if("{}".includes(i.type)||"[]".includes(i.type)){s+=i.value;continue}if(i.type===t.COLON){s+=i.value;continue}if(i.type===t.COMMA){let a=r[c+1];if(a&&(a.type==="}"||a.type==="]"))continue;s+=i.value;continue}if(i.type===t.STRING&&i.quoted){let a=i.value;i.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(m,A)=>A.length%2===0?A+'\\"':m)),s+=`"${a}"`;continue}if(i.type===t.NUMBER||i.type===t.BOOLEAN){s+=i.value;continue}if(i.type===t.SELECTOR||i.type===t.IDENTIFIER){s+=`"${i.value}"`;continue}s+=`"${i.value}"`}return s}try{let r=n(e),s=o(r);return JSON.parse(s)}catch(r){throw new Ce("Invalid extraction rules syntax: "+r.message,r)}}var Ot="1",vn=/^[a-zA-Z0-9_-]+$/;function Ie(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!vn.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${vn})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=r[0],c=e.attr(s,"data-rules-version");if(c!==Ot)throw new Ae(c);return{rules:we(e.text(s)),tagNode:s}}var zr="script[data-rules-name]";function On(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ze(e,t){let n=e.find(t,zr,{includeRulesTag:!0}),o=new Set,r=[];for(let s of n){let c=On(e.attr(s,"data-rules-name"));if(!c)continue;if(o.has(c)){console.warn(`hyper-html-api: duplicate rules tag name "${c}"; using the first.`);continue}let i=e.attr(s,"data-rules-version");if(i!==Ot)throw new Ae(i);o.add(c),r.push({name:c,rules:we(e.text(s))})}return r}function it(e,t){let n={};for(let{name:o,rules:r}of ze(e,t))n[o]=ue(e,t,r);return n}function Nt(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:it(ce,t),version:le(n,"hyper-version")}}var Le=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},Ve=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},me=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},We=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var Nn="text/hyper-upgrade";function kt(e,t){let n=e.find(t,`script[type="${Nn}"]`);if(n.length===0)return null;if(n.length>1)throw new We(n.length);return e.text(n[0])||null}var Vr=new Function("url","return import(url)");async function Ct(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await Vr(n)}catch(r){throw new me(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new me("transform must `export default` a function");return o.default}function Rn(e,t,n,o){let r=e.length,s=t.length,c=new Array(r).fill(-1);if(o){let x=new Set;for(let k=0;k<r;k++){let P=o[k];!(P>=0&&P<s)||x.has(P)||(c[k]=P,x.add(P))}}if(r===0||s===0)return c;let i=e.map(x=>kn(x,n)),a=t.map(x=>kn(x,n)),m=new Array(s).fill(!1);for(let x of c)x>=0&&(m[x]=!0);let A=new Map;a.forEach((x,k)=>{m[k]||A.set(x,A.has(x)?-1:k)});let w=new Map;i.forEach((x,k)=>{c[k]>=0||w.set(x,(w.get(x)||0)+1)}),i.forEach((x,k)=>{if(c[k]>=0||w.get(x)!==1)return;let P=A.get(x);P===void 0||P===-1||m[P]||(c[k]=P,m[P]=!0)});let d=[];for(let x=0;x<r;x++)c[x]<0&&d.push(x);let E=[];for(let x=0;x<s;x++)m[x]||E.push(x);if(d.length===0||E.length===0)return c;let p=r*s+1,R=(x,k)=>Wr(e[x],t[k],n)*p+Math.abs(x-k);for(let[x,k]of Kr(d,E,R))c[x]=k;return c}var In=e=>typeof e=="object"&&e!==null;function kn(e,t){if(!In(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function Wr(e,t,n){if(!In(n))return e===t?0:1;let o=Object.keys(n);if(o.length===0)return 0;let r=0;for(let s of o){let c=JSON.stringify(e?.[s]),i=JSON.stringify(t?.[s]);c!==i&&r++}return r}function Kr(e,t,n){return e.length<=t.length?Cn(e,t,n,!1):Cn(t,e,(o,r)=>n(r,o),!0)}function Cn(e,t,n,o){let r=e.length,s=t.length,c=[];for(let w=0;w<=r;w++)c.push(new Float64Array(s+1).fill(1/0));let i=[];for(let w=0;w<=r;w++)i.push(new Uint8Array(s+1));for(let w=0;w<=s;w++)c[r][w]=0;for(let w=r-1;w>=0;w--)for(let d=s-1;d>=0;d--){let E=n(e[w],t[d])+c[w+1][d+1],p=c[w][d+1];E<=p?(c[w][d]=E,i[w][d]=1):c[w][d]=p}let a=[],m=0,A=0;for(;m<r&&A<s;)i[m][A]&&(a.push(o?[t[A],e[m]]:[e[m],t[A]]),m++),A++;return a}function It(e,t,n,o,r,s,c,i={}){let a=e.find(t,n,i);if(r.length===0){a.forEach($=>e.remove($)),Rt(i,"onRowsApplied",s.path,[]);return}let m=r.length>a.length,A=a[0]||null;if(m&&!A&&(A=Xr(e,t,n,i),!A))throw new Be(s.path);let w=a.map($=>Gr(e,$,o,i)),d=null;if(m&&A){d=e.clone(A),i.templateAttr&&e.removeAttr(d,i.templateAttr);let $=e.stripIds(d);$>0&&console.warn(`[hyper-html-api] stripped ${$} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let E=Rn(r,w,o,Jr(e,a,r,s,i)),p=a[0]||A,R=e.parent(p),x=a.length>0?Ln(e,R,p):0,k=Zr(e,a),P=new Set,W=[],K=r.map(($,G)=>{let z=E[G];if(z>=0)return P.add(z),W.push(!1),a[z];W.push(!0);let oe=e.clone(d);return e.stripIds(oe),oe});a.forEach(($,G)=>{P.has(G)||e.remove($)}),k?K.forEach(($,G)=>{let z=x+G;e.children(R).findIndex(xe=>e.sameNode(xe,$))!==z&&e.insertAt(R,$,z)}):Qr(e,K,W,R,x),Yr(e,K,o,r,s,c,i),Rt(i,"onRowsApplied",s.path,K)}function Rt(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function Jr(e,t,n,o,r){let s=Rt(r,"identifyRows",o.path,n);if(!Array.isArray(s))return null;let c=new Array(n.length).fill(-1),i=new Set;for(let a=0;a<n.length;a++)if(s[a]){for(let m=0;m<t.length;m++)if(!(i.has(m)||!e.sameNode(t[m],s[a]))){c[a]=m,i.add(m);break}}return c}function Yr(e,t,n,o,r,s,c){t.forEach((i,a)=>{if(n===null){let m=o[a],A=m==null?"":String(m);e.text(i)!==A&&e.text(i,A)}else{let m=s(e,i,n,o[a],{depth:r.depth+1,path:[...r.path,a]},c);m&&m!==i&&(t[a]=m)}})}function Gr(e,t,n,o){return n===null?e.text(t):ue(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Ln(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Xr(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let s=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let c of s)if(e.attr(c,o.templateAttr)!=null)return c;r=e.parent(r)}return null}function Zr(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=e.children(n),r=[];for(let s of t){let c=o.findIndex(i=>e.sameNode(i,s));if(c===-1)return!1;r.push(c)}return r.sort((s,c)=>s-c),r[r.length-1]-r[0]===r.length-1}function Qr(e,t,n,o,r){let s=null,c=r;for(let i=0;i<t.length;i++){if(!n[i]){s=t[i];continue}let a=s?e.parent(s):o;if(!a)continue;let m=s?Ln(e,a,s)+1:c++;e.insertAt(a,t[i],m),s=t[i]}}var jn=new Set(["checked","selected","disabled","readOnly","paused"]);function ge(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let s=[];if(Lt(n,o,[],s),s.length)throw new _e(s);st(e,t,n,o,{depth:0,path:[]},r)}function st(e,t,n,o,r,s={}){if(r.depth>Re)throw new Se(r.path);if(o===void 0)return t;if(typeof n=="string")return eo(e,t,n,o,r,s);if(Array.isArray(n)){let[c,i]=n;return It(e,t,c,i,o,r,st,s),t}if(typeof n=="object"&&n!==null){for(let[c,i]of Object.entries(n)){let a=st(e,t,i,o==null?o:o[c],{depth:r.depth+1,path:[...r.path,c]},s);a&&a!==t&&(t=a)}return t}return t}function eo(e,t,n,o,r,s){if(n.endsWith("[]")){let a=n.slice(0,-2);return It(e,t,a,null,o,r,st,s),t}if(n.startsWith("@"))return Dn(e,t,n.slice(1),o);let c=pe(n);if(c!==-1){let a=n.slice(0,c),m=n.slice(c+1),A=a?e.find(t,a,s):[t];return A.length===0||Dn(e,A[0],m,o),t}if(n===".")return Pn(e,t,o),t;let i=e.find(t,n,s);return i.length===0||Pn(e,i[0],o),t}function Pn(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Dn(e,t,n,o){if(Tt.has(n))throw new Ue(n);if(n==="outerHTML"){let s=o==null?"":String(o);return e.replaceWith(t,s)}if(yn.has(n)){let s=to(n,o);return e.prop(t,n)!==s&&e.prop(t,n,s),t}let r=o==null?"":String(o);return e.attr(t,n)!==r&&e.attr(t,n,r),t}function to(e,t){return t==null?jn.has(e)?!1:"":jn.has(e)?t==="false"?!1:!!t:t}function Lt(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,s)=>{typeof r=="object"&&r!==null&&o.push({path:Je([...n,s]),expected:"scalar",got:Ke(r)})}):o.push({path:Je(n),expected:"array",got:Ke(t)});return}t!==null&&typeof t=="object"&&o.push({path:Je(n),expected:"scalar",got:Ke(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:Je(n),expected:"array",got:Ke(t)});return}let r=e[1];t.forEach((s,c)=>Lt(r,s,[...n,c],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:Je(n),expected:"object",got:Ke(t)});return}for(let[r,s]of Object.entries(e))Lt(s,t[r],[...n,r],o)}}}function Ke(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Je(e){return e.join(".")}function Ye(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=jt(t,e,n);return Pt(t,e,n),{data:o,summary:n}}function jt(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>jt(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,s]of Object.entries(e)){let c=jt(s,t?.[r],n);c!==void 0&&(o[r]=c)}return o}}function Pt(e,t,n){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let r of Object.keys(t))o.has(r)?Pt(e[r],t[r],n):n.discarded+=Te(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>Pt(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=Te(t))}}function Te(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+Te(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+Te(n),0):1}function Dt(e,t,n){let o=ze(e,t),r={carriedOver:0,discarded:0,listItems:0},s={},c=new Set;for(let{name:i,rules:a}of o){if(c.add(i),!Object.prototype.hasOwnProperty.call(n,i)){s[i]={carriedOver:0,discarded:0,listItems:0};continue}let{data:m,summary:A}=Ye(n[i],a);ge(e,t,a,m),s[i]=A,r.carriedOver+=A.carriedOver,r.discarded+=A.discarded,r.listItems+=A.listItems}for(let i of Object.keys(n))c.has(i)||(r.discarded+=Te(n[i]));return{totals:r,byName:s,rulesTagCount:o.length}}async function Ht({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:s}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),s=s||(k=>fetch(k)),!o)throw new Error("upgrade.run requires a document context");if(e=e||le(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let c=new URL(e,r?r.href:void 0);n=n!==void 0?n:le(o,"hyper-version"),t=t||it(ce,o);let i;try{i=await s(c.href)}catch(k){throw new Le(c.href,k)}if(!i.ok)throw new Le(c.href,new Error(`HTTP ${i.status}`));let a=await i.text(),m=new DOMParser().parseFromString(a,"text/html"),A=le(m,"hyper-version"),w=t,d=!1,E=kt(ce,m);if(E){let P=await(await Ct(E))(w,{fromVersion:n,toVersion:A});if(!P||typeof P!="object"||Array.isArray(P))throw new me("transform must return a plain object map of { rulesName: data }");w=P,d=!0}let{totals:p,byName:R,rulesTagCount:x}=Dt(ce,m,w);if(x===0&&Object.keys(w).length>0)throw new Ve(c.href);return{html:no(m),fromVersion:n,toVersion:A,summary:{transformApplied:d,totals:p,byName:R}}}function no(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
4
|
-
`+e.documentElement.outerHTML}function $t(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return Ie(e,o,n)}return null}var Ge={extract:(e,t,n={})=>ue(Ee(e,n),e,t,n),apply:(e,t,n,o={})=>ge(Ee(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>Ie(ce,e,t),findRules:(e,t)=>$t(ce,e,t),bind:(e,t,n={})=>{let o=$t(ce,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>ue(Ee(e,n),e,o.rules,n),set:r=>ge(Ee(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:vt,parseRelaxed:we,ruleAttrIndex:pe,splitRule:Ne,errors:ot,DOM_PROPERTIES:rt},_t=e=>!!e&&typeof e.nodeType=="number";function Hn(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=ce.find(t,"script[data-rules-name]",{includeRulesTag:!0});if(n.length===0)throw new Error('hyper-html-api: no rules tag found. Add <script type="application/json" data-rules-name="\u2026" data-rules-version="1"> or pass rules.');if(n.length>1)throw new Error('hyper-html-api: multiple rules tags found; pass a name, e.g. extractData("api").');return Ie(ce,t).rules}function Bt(e,t){let n=_t(e)?e:document,o=_t(e)?t:e;return o===void 0?ue(Ee(n),n,Hn(n)):Ge.bind(n,o).get()}function Ut(e,t,n){if(!_t(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");return n===void 0?ge(Ee(e),e,Hn(e),t):Ge.bind(e,n).set(t),e}var $n={buildForm:dt,bindFormEvents:pt,scaffold:Oe,morphForm:At,path:Ze},_n={checkForUpdate:Et,run:Ht,extractAll:Nt,shapeMatch:Ye};var io={engine:Ge,cms:$n,upgrade:_n,extractData:Bt,applyData:Ut},so=io;return Xn(co);})();
|
|
1
|
+
var HyperHtmlApi=(()=>{var ir=Object.defineProperty;var Ii=Object.getOwnPropertyDescriptor;var Ci=Object.getOwnPropertyNames;var Li=Object.prototype.hasOwnProperty;var cr=(e,t)=>{for(var n in t)ir(e,n,{get:t[n],enumerable:!0})},Ri=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ci(t))!Li.call(e,r)&&r!==n&&ir(e,r,{get:()=>t[r],enumerable:!(o=Ii(t,r))||o.enumerable});return e};var Pi=e=>Ri(ir({},"__esModule",{value:!0}),e);var El={};cr(El,{applyData:()=>us,cms:()=>Mi,default:()=>Ml,engine:()=>Bo,extractData:()=>fs,upgrade:()=>Ei});var $o={};cr($o,{fromString:()=>Wo,getRuleAtPath:()=>lr,getValueAtPath:()=>ko,parseConfigKey:()=>Di,setAtPath:()=>Pn,toConfigKey:()=>ji,toString:()=>hn});function hn(e){return e.map(String).join(".")}function ji(e){return e.map(t=>typeof t=="number"?"*":String(t)).join(".")}function Di(e){return e===""?[]:e.split(".")}function Wo(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function lr(e,t){let n=e;for(let o of t){if(n==null||typeof n=="string")return;if(Array.isArray(n)){if(typeof o!="number"&&o!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof o=="number"||!(o in n))return;n=n[o];continue}return}return n}function ko(e,t){let n=e;for(let o of t){if(n==null)return;n=n[o]}return n}function Pn(e,t,n){if(t.length===0)return n;let[o,...r]=t;if(typeof o=="number"){let i=Array.isArray(e)?[...e]:[];return i[o]=Pn(i[o],r,n),i}return{...e&&typeof e=="object"?e:{},[o]:Pn((e||{})[o],r,n)}}function eo(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[n,o]of Object.entries(e))t[n]=eo(o);return t}return""}var qo=new WeakMap;function Mn(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}function to(e){let t=Mn(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}var Hi=new Set(["checked","selected","disabled","readOnly","paused"]);function ar({rules:e,data:t,appRoot:n,cmsRoot:o}){let r=document.createDocumentFragment(),i={rules:e,appRoot:n,cmsRoot:o};return r.appendChild(ur({rule:e,value:t,path:[],ctx:i})),r}function fr(e,{rules:t,getData:n,onChange:o}){e.setAttribute("data-hha-form-root",""),hs.set(e,{rules:t,getData:n,onChange:o}),Bi()}var hs=new WeakMap,ds=!1;function Bi(){ds||(document.addEventListener("input",ps,!0),document.addEventListener("change",ps,!0),document.addEventListener("click",Ui,!0),ds=!0)}function ms(e){if(!(e instanceof Element))return null;let t=e.closest("[data-hha-form-root]");return t&&hs.get(t)||null}function Ui(e){if(!(e.target instanceof Element))return;let t=e.target.closest("[data-hha-action]");if(!t||e.defaultPrevented)return;let n=ms(t);if(!n)return;let{rules:o,getData:r,onChange:i}=n,c=t.getAttribute("data-hha-action"),s=Wo(t.getAttribute("data-hha-path")||"");if(c==="scalar-array-add"){let a=ko(r(),s)||[];i(Pn(r(),s,[...a,""]),{structural:!0});return}if(c==="object-array-add"){let a=lr(o,s);if(!Array.isArray(a))return;let m=ko(r(),s)||[];i(Pn(r(),s,[...m,eo(a[1])]),{structural:!0});return}if(c==="array-remove"){if(s.length===0)return;let a=s.slice(0,-1),m=s[s.length-1],h=ko(r(),a)||[];if(typeof m!="number")return;let d=h.filter((b,A)=>A!==m);i(Pn(r(),a,d),{structural:!0})}}function ps(e){let t=e.target;if(!t?.matches?.("input, textarea, select"))return;let n=ms(t);if(!n)return;let{getData:o,onChange:r}=n,i=t.closest("[data-hha-path]");if(!i)return;let c=Wo(i.getAttribute("data-hha-path")||""),s=t.type==="checkbox"?t.checked:t.value;r(Pn(o(),c,s),{structural:!1})}function ur({rule:e,value:t,path:n,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?Wi({rule:e,value:t,path:n,ctx:o}):Vi({rule:e,value:t,path:n,ctx:o});if(Array.isArray(e))return $i({rule:e,value:t,path:n,ctx:o});if(typeof e=="object"&&e!==null)return _i({rule:e,value:t,path:n,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function _i({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",hn(n)),n.length>0){let i=document.createElement("div");i.className="form-section-label",i.textContent=Fo(n[n.length-1]),r.appendChild(i)}for(let[i,c]of Object.entries(e)){let s=[...n,i],a=t?.[i];r.appendChild(ur({rule:c,value:a,path:s,ctx:o}))}return r}function Vi({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",hn(n));let i=document.createElement("div");i.className="field-body";let c=document.createElement("label");c.className="field-label",c.textContent=Fo(n[n.length-1]||".")+Gi(e);let s=Fi(e,o.appRoot),a=qi(s,{value:t,rule:e,path:n,appRoot:o.appRoot}),m=a.el;return m.classList.add(s.type==="textarea"?"field-textarea":"field-input"),i.appendChild(c),i.appendChild(m),r.appendChild(i),qo.set(r,a),r}function Wi({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",hn(n));let i=document.createElement("div");i.className="form-section-label",i.textContent=Fo(n[n.length-1]),r.appendChild(i);let c=Array.isArray(t)?t:[],s=document.createElement("div");r.appendChild(s),c.forEach((m,h)=>{let d=[...n,h],b=document.createElement("div");b.className="scalar-array-row",b.setAttribute("data-hha-path",hn(d));let A=document.createElement("input");A.type="text",A.className="field-input",A.value=m==null?"":String(m);let S=document.createElement("button");S.type="button",S.className="array-remove",S.textContent="\xD7",S.title="remove",S.setAttribute("data-hha-action","array-remove"),S.setAttribute("data-hha-path",hn(d)),b.appendChild(A),b.appendChild(S),s.appendChild(b)});let a=document.createElement("button");return a.type="button",a.className="array-add",a.textContent="+ add",a.setAttribute("data-hha-action","scalar-array-add"),a.setAttribute("data-hha-path",hn(n)),r.appendChild(a),r}function $i({rule:e,value:t,path:n,ctx:o}){let[,r]=e,i=Array.isArray(t)?t:[],c=document.createElement("div");c.className="form-section",c.setAttribute("data-hha-path",hn(n));let s=document.createElement("div");s.className="form-section-label",s.textContent=Fo(n[n.length-1]),c.appendChild(s),i.forEach((m,h)=>{let d=[...n,h],b=document.createElement("div");b.className="array-card",b.setAttribute("data-hha-path",hn(d));let A=document.createElement("button");A.type="button",A.className="array-remove",A.textContent="\xD7",A.title="remove item",A.setAttribute("data-hha-action","array-remove"),A.setAttribute("data-hha-path",hn(d)),b.appendChild(A);let S=ur({rule:r,value:m,path:d,ctx:o});S.querySelector(".form-section-label")?.remove(),b.appendChild(S),c.appendChild(b)});let a=document.createElement("button");return a.type="button",a.className="array-add",a.textContent="+ add",a.setAttribute("data-hha-action","object-array-add"),a.setAttribute("data-hha-path",hn(n)),c.appendChild(a),c}function qi(e,t){let n=zi(e);if(e.type==="select"&&e.options)for(let o of e.options){let r=document.createElement("option");r.value=o.value,r.textContent=o.text,String(t.value)===o.value&&(r.selected=!0),n.appendChild(r)}else e.type==="checkbox"?n.checked=t.value===!0||t.value==="true"||t.value==="checked":(e.type,n.value=t.value==null?"":String(t.value));return{el:n,destroy(){},focus(){n.focus()},validate(){}}}function Fi(e,t){let n=null;if(e.startsWith("@")?n=e.slice(1):n=to(e).prop,n&&Hi.has(n))return{type:"checkbox"};if(n==="innerHTML")return{type:"textarea"};let o=Ki(e,t);if(!o)return{type:"text"};let r=(o.tagName||"").toLowerCase();if(r==="textarea")return{type:"textarea"};if(r==="select")return{type:"select",options:Array.from(o.querySelectorAll("option")).map(s=>({value:s.getAttribute("value")||s.textContent,text:s.textContent.trim()||s.getAttribute("value")||""}))};if(r==="input"){let c=(o.getAttribute("type")||"text").toLowerCase();if(c==="checkbox"||c==="radio")return{type:"checkbox"};if(c==="number")return{type:"number"}}let i=(o.textContent||"").trim();return i.length>60||i.includes(`
|
|
2
|
+
`)?{type:"textarea"}:{type:"text"}}function Ki(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=to(e).selector;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function zi(e){if(e.type==="textarea")return document.createElement("textarea");if(e.type==="select")return document.createElement("select");let t=document.createElement("input");return t.type=e.type==="checkbox"?"checkbox":e.type==="number"?"number":"text",t}function Fo(e){return typeof e=="number"?`#${e+1}`:String(e).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^\w/,t=>t.toUpperCase())}function Gi(e){return` \xB7 ${e}`}function Ko(e,t){if(typeof e=="string"){let n=t&&t.defaultView,o=n&&n.DOMParser||globalThis.DOMParser;return new o().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function dr(e){let t=new Map;return(n,o)=>{if(typeof o!="string")return Ko(o,e);let r=t.get(n);if(r&&r.text===o)return r.doc;let i=Ko(o,e);return t.set(n,{text:o,doc:i}),i}}function gs(e,t){let n=t.doctype;if(!n)return!1;let o=e.doctype;if(o&&o.name===n.name&&o.publicId===n.publicId&&o.systemId===n.systemId)return!1;let r=e.implementation.createDocumentType(n.name,n.publicId,n.systemId);return o?e.replaceChild(r,o):e.insertBefore(r,e.documentElement),!0}var pr=()=>!1;function hr(e,t=[]){if(typeof e!="function")return pr;let n=new WeakMap,o=new Set(t);return r=>{if(!r||r.nodeType!==1)return!1;let i=n.get(r);if(i!==void 0)return i;let c=[],s=r,a=!1;for(;s&&s.nodeType===1;){let m=n.get(s);if(m!==void 0){a=m;break}if(c.push(s),e(s,o.has(s))){a=!0;break}if(o.has(s))break;s=s.parentElement}for(let m of c)n.set(m,a);return a}}var Vl=Object.freeze(["root-tag","equal","root-attrs","root-level","not-in-body","ignored-ancestor","remote-wins-ancestor","form-ancestor","script-or-template","no-live-twin","live-detached","ancestor-live","sibling-live","outside-id-changed","chain-unpaired"]);function jn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var Yi="~",bs="^";function mr(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let o=t[Yi],r=typeof o=="string"?o.split(",").map(Number):null,i=r&&typeof t[bs]=="string"?t[bs].split(","):null,c=d=>Number.isInteger(d)&&d>=0,s=0,a=!1,m=d=>{let b=d;for(;b>0;){let A=r[s++];if(s>r.length||!c(A))return!1;b+=A-1}return!0},h=(d,b)=>{if(a)return;if(r){let L=s++,f=r[L];if(L>=r.length||!c(f)){a=!0;return}let g=!i||i[L]===d.tagName.toLowerCase();if(!g||f!==d.children.length){let x=g&&t[b];typeof x=="string"&&x&&n.set(d,x),m(f)||(a=!0);return}}let A=t[b];typeof A=="string"&&A&&n.set(d,A);let S=d.children;for(let L=0;L<S.length;L++)h(S[L],b===""?String(L):`${b}.${L}`)};return h(e,""),n}function ys(e){return t=>{for(let n of e){let o=n(t);if(typeof o=="string"&&o!=="")return o}return null}}var fn=ys([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function zo(e,t,n,o=null){let r=new Map,i=new Set,c=s=>{if(n(s))return;let a=t(s);a&&(r.has(a)?i.add(a):r.set(a,s))};if(o){let s=a=>{for(let m of a.querySelectorAll(o))c(m);for(let m of a.querySelectorAll("template"))m.content&&s(m.content)};c(e),s(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let s=a=>{c(a);let m=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let h=0;h<m.length;h++)s(m[h])};s(e)}for(let s of i)r.delete(s),gr(s);return r}function gr(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var Ji=new Set(["href","src","name","type","role"]),ws=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function no(e,t=5381){let n=t;for(let o=0;o<e.length;o++)n=(n<<5)+n^e.charCodeAt(o);return n>>>0}function ks(e){return e.replace(/\s+/g," ")}var Xi=0;function xs({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let o=new WeakMap,r=new WeakMap;function i(q){let z=q.attributes,ce=z.length;if(ce===0)return{all:"",sig:q.tagName+"|"};let xe=[],te="",J=[];for(let Ce=0;Ce<ce;Ce++){let we=z[Ce],ne=we.name;t(q,ne)||xe.push(ne+"="+we.value),ne==="class"?te=we.value.indexOf(" ")<0?we.value:we.value.split(/\s+/).filter(Boolean).sort().join(" "):Ji.has(ne)&&J.push(ne+"="+we.value)}return xe.length>1&&xe.sort(),J.length>1&&J.sort(),{all:xe.join(""),sig:q.tagName+"|"+te+(J.length?"|"+J.join("|"):"")}}function c(q){return q.nodeType===1&&q.tagName==="TEMPLATE"&&q.content?q.content.childNodes:q.childNodes}function s(q){let z=o.get(q);if(z)return z;if(q.nodeType===3)z={hash:"T"+no(q.nodeValue),hint:ks(q.nodeValue).slice(0,64),sig:null,tok:null};else if(q.nodeType===8)z={hash:"C"+no(q.nodeValue),hint:"",sig:null,tok:null};else if(q.nodeType===1){let ce=i(q),xe=no(q.tagName+""+ce.all),te="";for(let J of m(q))if(J.nodeType===1){let Ce=s(J);xe=no(Ce.hash,xe),te.length<64&&(te+=" "+Ce.hint)}else xe=no(h(J),xe),J.kind==="text"&&te.length<64&&(te+=J.value.slice(0,64));z={hash:"E"+xe,hint:ks(te).trim().slice(0,64),sig:ce.sig,tok:null}}else z={hash:"N"+q.nodeType,hint:"",sig:null,tok:null};return o.set(q,z),z}function a(q){if(!q.tok){q.tok=new Set;for(let z of q.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))z&&q.tok.add(z)}return q.tok}function m(q){let z=r.get(q);if(z)return z;z=[];let ce=null,xe=()=>{ce&&(ce.value=ce.nodes.map(te=>te.nodeValue).join(""),z.push(ce),ce=null)};for(let te of c(q)){if(te.nodeType===3){ce||(ce={kind:"text",nodes:[],value:"",parent:q,hash:void 0}),ce.nodes.push(te);continue}xe(),te.nodeType===8?z.push({kind:"comment",nodes:[te],value:te.nodeValue,parent:q,hash:void 0}):te.nodeType===1&&!e(te)&&z.push(te)}return xe(),r.set(q,z),z}function h(q){return q.nodeType===1?s(q).hash:(q.hash===void 0&&(q.hash=(q.kind==="text"?"T":"C")+no(q.value)),q.hash)}function d(q,z){let ce=a(s(q)),xe=a(s(z));if(ce.size===0&&xe.size===0)return{coef:1,share:1};if(ce.size===0||xe.size===0)return null;let te=0;for(let J of ce)xe.has(J)&&te++;return{coef:te/Math.min(ce.size,xe.size),share:te/Math.max(ce.size,xe.size)}}function b(q,z){let ce=d(q,z);return!!ce&&ce.coef>=.5}let A=new WeakMap;function S(q){let z=A.get(q);if(z)return z;z=[];for(let ce of q.attributes)t(q,ce.name)||z.push([ce.namespaceURI||"",ce.localName,ce.value]);return z.sort((ce,xe)=>ce[0]<xe[0]?-1:ce[0]>xe[0]?1:ce[1]<xe[1]?-1:ce[1]>xe[1]?1:0),A.set(q,z),z}let L=new WeakMap;function f(q,z){if(q===z)return!0;if(h(q)!==h(z))return!1;let ce=L.get(q);if(ce&&ce.has(z))return ce.get(z);let xe=L.get(z);if(xe&&xe.has(q))return xe.get(q);let te=g(q,z),J=te===!0;return te===!1&&n&&n.hashRejected++,ce||L.set(q,ce=new WeakMap),ce.set(z,J),J}function g(q,z){if(q.nodeType===1){if(z.nodeType!==1||q.tagName!==z.tagName||q.namespaceURI!==z.namespaceURI)return!1;let ce=S(q),xe=S(z);if(ce.length!==xe.length)return!1;for(let Ce=0;Ce<ce.length;Ce++)if(ce[Ce][0]!==xe[Ce][0]||ce[Ce][1]!==xe[Ce][1]||ce[Ce][2]!==xe[Ce][2])return!1;let te=m(q),J=m(z);if(te.length!==J.length)return!1;for(let Ce=0;Ce<te.length;Ce++){if(h(te[Ce])!==h(J[Ce]))return!1;if(!f(te[Ce],J[Ce]))return Xi}return!0}return z.nodeType===1?!1:q.kind===z.kind&&q.value===z.value}let x=new WeakMap,Q=new Map,se=0;function le(q){let z=x.get(q);if(z)return z;let ce=h(q),xe=Q.get(ce);xe||Q.set(ce,xe=[]);let te=xe.find(J=>f(J.unit,q));return z=te?te.key:"K"+se++,te||xe.push({unit:q,key:z}),x.set(q,z),z}return{meta:s,unitsOf:m,unitHash:h,similar:b,score:d,childrenOf:c,equalUnits:f,exactUnitKey:le,ignored:e}}var Ts=16,Qi=2e3,Zi=3,br={align:0,certifyVisited:0,certifyScheduled:0};function yr(e,t,n){let{meta:o,unitsOf:r,unitHash:i,similar:c,score:s,childrenOf:a,equalUnits:m,ignored:h}=n.analyzer,d=n.baseId||(()=>null),b=n.sideId||(()=>null),A=n.stats||null,S=A?new Set:null,L=A?new Set:null,f=new Map,g=new Map,x=new Set,Q=new Map,se=new Set,le=new Set,q=new Set,z=[],ce=[],xe=[],te=[],J=Qi,Ce=new Map,we=new Map,ne=(p,k)=>{f.set(p,k),g.set(k,p)},_=new Set,ye=new Set,ge=null,Oe=p=>{let k=p.nodeType?p.parentNode:p.parent;if(!k||k.nodeType!==11)return k;if(!ge){ge=new WeakMap;let R=$=>{for(let H of $.querySelectorAll("template"))H.content&&(ge.set(H.content,H),R(H.content))};for(let $ of[e,t])R($.tagName==="TEMPLATE"&&$.content?$.content:$)}return ge.get(k)||null},Be=(p,k)=>{for(let R=Oe(p);R&&!_.has(R);R=Oe(R))_.add(R);for(let R=Oe(k);R&&!ye.has(R);R=Oe(R))ye.add(R)},We=p=>{for(let k=Oe(p);k;k=Oe(k))if(f.has(k))return le.has(k);return!1},rt=p=>{for(let k=Oe(p);k;k=Oe(k)){let R=g.get(k);if(R!==void 0)return le.has(R)}return!1},re=p=>!!p&&p.nodeType===1,ut=(p,k)=>{let R=Q.get(p);return!!R&&R.has(k)},dt=p=>ws.has(p.tagName),Se=n.comparisons||n.scope,O=(p,k)=>{if(Se){if(Se.same.get(p)===k)return!0;if(Se.differ.get(p)===k)return!1}if(!p.isEqualNode(k))return!1;if(p.tagName==="TEMPLATE")return m(p,k);let R=p.getElementsByTagName("template");if(R.length===0)return!0;let $=k.getElementsByTagName("template");if(R.length!==$.length)return!1;for(let H=0;H<R.length;H++)if(!m(R[H],$[H]))return!1;return!0},B=(p,k)=>{let R=d(p);if(!R)return!0;let $=b(k);return!$||R===$},ae=globalThis.__hyperMorphProfile,be=ae?performance.now():0;ae&&!n.scope&&(o(e),o(t),ae.meta=(ae.meta||0)+(performance.now()-be),be=performance.now()),ne(e,t);let de=new Set;for(let[p,k]of n.baseIndex){let R=n.sideIndex.get(p);R&&R.tagName===k.tagName&&!f.has(k)&&!g.has(R)&&(ne(k,R),Be(k,R),de.add(k))}if(de.size){let p=[];if(n.scope)for(let H of n.scope.chain)de.has(H)&&p.push(H);let k=[n.scope?n.scope.root:e];for(;k.length;){let H=k.pop();de.has(H)&&p.push(H);let F=a(H);for(let N=F.length-1;N>=0;N--)F[N].nodeType===1&&k.push(F[N])}let R=new Set;for(let H=p.length-1;H>=0;H--){let F=p[H];n.scope&&n.scope.onChain.has(F)?R.add(F):Xt(F,f.get(F),R)?(le.add(F),q.add(F),A&&A.certificationPairs++):R.add(F)}let $=new Set;for(let H of p)le.has(H)&&!$.has(H)&&ze(H,$)}n.scope&&n.scope.head&&Bt(n.scope.head[0],n.scope.head[1]);function ze(p,k){let R=[p];for(;R.length;){let $=R.pop();if(!k.has($)){k.add($),M($);for(let H of r($))re(H)&&f.has(H)&&R.push(H)}}}te.push([e,t]);for(let[p,k]of f)re(p)&&p!==e&&te.push([p,k]);return wt(),De(),ae&&(ae.align=(ae.align||0)+(performance.now()-be)),{map:f,reverse:g,moved:se,identical:le,pairIdenticalChildren:M,weak:x,unpair:Qe,rematch:De,insertedByHash:st,refused:L,identityPaired:de};function De(){P(),wt();for(let p=0;p<xe.length;){let k=xe.length;nn(p,k),p=k,wt(),P(),wt()}}function Qe(p){let k=f.get(p);if(!k)return;Q.has(p)||Q.set(p,new Set),Q.get(p).add(k);let R=(H,F)=>{f.delete(H),g.delete(F),se.delete(H),le.delete(H),x.delete(H),q.delete(H)},$=(H,F)=>{for(let N of r(H)){let E=f.get(N);!E||de.has(N)||!(re(E)?F.contains(E):F.contains(E.nodes[0]))||(R(N,E),re(N)&&$(N,E))}};R(p,k),re(p)&&$(p,k),z.push(p),ce.push(k)}function st(){let p=new Map;for(let k of new Set(ce)){if(g.has(k))continue;let R=o(k).hash;p.has(R)||p.set(R,[]),p.get(R).push(k)}return p}function wt(){for(;te.length;){let[p,k]=te.shift();f.get(p)!==k||q.has(p)||le.has(p)||Tt(p,k)}}function bt(p,k){if(!dt(p))for(let R of r(p))re(R)&&(k.push(R),bt(R,k))}function Tt(p,k){q.add(p);let R=r(p),$=r(k);br.align+=R.length+$.length,Ce=new Map,we=new Map;for(let G=0;G<R.length;G++)Ce.set(R[G],G);for(let G=0;G<$.length;G++)we.set($[G],G);if(p.tagName==="HTML")for(let G of["HEAD","BODY"]){let he=R.find(u=>re(u)&&u.tagName===G),ve=$.find(u=>re(u)&&u.tagName===G);he&&ve&&!f.has(he)&&!g.has(ve)&&ne(he,ve)}for(let G=0;G<R.length&&G<$.length;G++){let he=R[G],ve=$[G];f.has(he)||g.has(ve)||(re(he)?re(ve)&&he.tagName===ve.tagName&&O(he,ve)&&Bt(he,ve):!re(ve)&&he.kind===ve.kind&&he.value===ve.value&&Bt(he,ve))}T(R,$);let H=R.filter(G=>!f.has(G)),F=$.filter(G=>!g.has(G));H.length&&F.length&&(Qt(H,F),Z(H,F),ee(H,F,R,$),fe(R,$));let N=!1,E=!1;for(let G of R){if(!f.has(G)){re(G)&&(z.push(G),bt(G,z),N=!0);continue}re(G)&&!le.has(G)&&te.push([G,f.get(G)])}for(let G of $)!g.has(G)&&re(G)&&(ce.push(G),bt(G,ce),E=!0);N&&E&&xe.push([p,k])}function nn(p,k){for(let R=p;R<k;R++){let[$,H]=xe[R];if(f.get($)!==H)continue;let F=r($),N=r(H),E=new Map,G=new Map,he=null;for(let ve of F)re(ve)&&(f.has(ve)?he=ve:(E.has(he)||E.set(he,[]),E.get(he).push(ve)));he=null;for(let ve of N)re(ve)&&(g.has(ve)?he=g.get(ve):(G.has(he)||G.set(he,[]),G.get(he).push(ve)));for(let[ve,u]of E){let v=G.get(ve);if(!(!v||u.length!==v.length)&&u.every((j,U)=>v[U].tagName===j.tagName&&B(j,v[U])&&!ut(j,v[U])))for(let j=0;j<u.length;j++)Fe(u[j],v[j])}}}function Fe(p,k){ne(p,k),x.add(p),te.push([p,k]),wt()}function Qt(p,k){let R=oo(p,i),$=oo(k,i),H=new Map;for(let F of k){let N=i(F);$.get(N)===1&&H.set(N,F)}for(let F of p){if(f.has(F))continue;let N=i(F);if(R.get(N)!==1)continue;let E=H.get(N);E&&!g.has(E)&&m(F,E)&&Bt(F,E)}}function Xt(p,k,R){let $=[[p,k]];for(;$.length;){let[H,F]=$.pop();if(br.certifyVisited++,A&&A.certificationVisited++,H.nodeType!==F.nodeType)return!1;if(H.nodeType===3||H.nodeType===8){if(H.nodeValue!==F.nodeValue)return!1;continue}if(H.nodeType!==1){if(!H.isEqualNode(F))return!1;continue}if(H.tagName!==F.tagName||H.namespaceURI!==F.namespaceURI||h(H)!==h(F))return!1;let N=H.attributes,E=F.attributes;if(N.length!==E.length)return!1;for(let v=0;v<N.length;v++){let j=N[v];if(F.getAttributeNS(j.namespaceURI,j.localName)!==j.value)return!1}let G=f.get(H);if(G!==void 0&&G!==F)return!1;let he=g.get(F);if(he!==void 0&&he!==H)return!1;if(H!==p){if(le.has(H))continue;if(R.has(H))return!1}let ve=a(H),u=a(F);if(ve.length!==u.length)return!1;br.certifyScheduled+=ve.length;for(let v=ve.length-1;v>=0;v--)$.push([ve[v],u[v]])}return!0}function Bt(p,k){if(re(p)&&(_.has(p)||ye.has(k))){let R=Lt(p,k);if(!R){ne(p,k),te.push([p,k]);return}for(let $=0;$<R.length;$+=2){let H=R[$],F=R[$+1],N=f.get(H);N!==void 0&&N!==F&&Et(H,N);let E=g.get(F);E!==void 0&&E!==H&&Et(E,F),f.get(H)===F&&(se.delete(H),x.delete(H),le.add(H),q.add(H))}}sn(p,k)}function Et(p,k){f.delete(p),g.delete(k),se.delete(p),le.delete(p),x.delete(p),q.delete(p)}function Lt(p,k){let R=[p,k,!1],$=[];for(;R.length;){let H=R.pop(),F=R.pop(),N=R.pop(),E=f.get(N),G=g.get(F);if(N!==p&&(E!==void 0&&E!==F&&de.has(N)||G!==void 0&&G!==N&&de.has(G)))return null;if(!(E===F&&le.has(N))&&((E!==void 0||G!==void 0)&&$.push(N,F),!!re(N))){if(H||E!==void 0&&E!==F||G!==void 0&&G!==N){let he=r(N),ve=r(F);for(let u=0;u<he.length&&u<ve.length;u++)R.push(he[u],ve[u],!0)}else if(_.has(N)||ye.has(F)){let he=N.tagName==="TEMPLATE"?N.content:N,ve=F.tagName==="TEMPLATE"?F.content:F;for(let u=he.firstElementChild,v=ve.firstElementChild;u&&v;){if(h(u)){u=u.nextElementSibling;continue}if(h(v)){v=v.nextElementSibling;continue}(f.has(u)||g.has(v)||_.has(u)||ye.has(v))&&R.push(u,v,!1),u=u.nextElementSibling,v=v.nextElementSibling}}}}return $}function sn(p,k){ne(p,k),le.add(p),re(p)&&q.add(p)}function M(p){let k=f.get(p);if(!k||!re(p))return;let R=r(p),$=r(k);for(let H=0;H<R.length&&H<$.length;H++)f.has(R[H])||sn(R[H],$[H])}function Z(p,k){let R=N=>re(N)&&!dt(N)?o(N).sig+""+o(N).hint:null,$=oo(p,R),H=oo(k,R),F=new Map;for(let N of k){let E=R(N);E!=null&&H.get(E)===1&&F.set(E,N)}for(let N of p){if(f.has(N))continue;let E=R(N);if(E==null||$.get(E)!==1)continue;let G=F.get(E);G&&!g.has(G)&&B(N,G)&&ne(N,G)}}function ee(p,k,R,$){let H=new Map;for(let N of k){if(!re(N)||g.has(N)||dt(N))continue;let E=o(N).sig;H.has(E)||H.set(E,[]),H.get(E).push({el:N,index:we.get(N)})}let F=[];for(let N of p){if(f.has(N)||!re(N)||dt(N))continue;let E=H.get(o(N).sig);if(!E||!E.length)continue;let G=Ce.get(N),he=E.filter(ve=>!g.has(ve.el)).map(ve=>({c:ve,d:Math.abs(ve.index-G)}));he.sort((ve,u)=>ve.d-u.d),he.length>Ts&&(he=he.slice(0,Ts));for(let{c:ve,d:u}of he){if(!B(N,ve.el))continue;let v=s(N,ve.el);v&&v.coef>=.5&&F.push({b:N,s:ve.el,coef:v.coef,share:v.share,d:u,bi:G})}}if(F.sort((N,E)=>E.coef-N.coef||E.share-N.share||N.d-E.d||N.bi-E.bi),A&&F.length>1){let N=new Map;for(let E of F){let G=N.get(E.b);G?G.coef===E.coef&&(G.share===E.share?G.strict++:G.loose++):N.set(E.b,{coef:E.coef,share:E.share,strict:0,loose:0})}for(let[E,G]of N)S.has(E)||!(G.strict||G.loose)||(S.add(E),G.strict?A.similarTiesStrict++:A.similarTiesLoose++)}for(let N of F)!f.has(N.b)&&!g.has(N.s)&&ne(N.b,N.s)}function ue(p,k){return re(p)!==re(k)?!1:re(p)?p.tagName!==k.tagName||!B(p,k)?!1:dt(p)||o(p).hint===""||o(k).hint===""?!0:c(p,k):p.kind===k.kind}function oe(p,k){let R=(H,F)=>{let N=F===null?-1:H===k?we.get(F):Ce.get(F),E=H[N+1];return E&&!re(E)?E:null},$=null;for(let H of p){if(re(H)){$=H;continue}if(f.has(H))continue;let F=$===null?null:f.get($);if($!==null&&!F)continue;let N=R(k,F);N&&!g.has(N)&&N.kind===H.kind&&ne(H,N)}}function fe(p,k){oe(p,k);let R=y(p,k),$=(F,N)=>re(F)&&o(F).hint!==""&&o(N).hint===""&&!!N.querySelector("br")&&!R(F,N),H=0;for(let F of p){if(f.has(F)){let E=we.get(f.get(F));E!==void 0&&E>=H&&(H=E+1);continue}let N=0;for(let E=H;E<k.length&&N<Zi;E++){let G=k[E];if(!g.has(G)&&(N++,ue(F,G)&&!ut(F,G)&&!$(F,G))){ne(F,G),re(F)&&(o(F).hint===""||o(G).hint==="")&&x.add(F),H=E+1;break}}}T(p,k)}function y(p,k){let R=($,H,F)=>{for(let N=H-1;N>=0;N--)if(re($[N])&&F($[N]))return $[N];return null};return($,H)=>{let F=Ce.get($),N=we.get(H);if(F===N)return!0;let E=R(p,F,he=>f.has(he)),G=R(k,N,he=>g.has(he));return E?f.get(E)===G:!G}}function T(p,k){let R=p.filter(E=>re(E)&&!f.has(E)),$=k.filter(E=>re(E)&&!g.has(E));if(!R.length||!$.length)return;let H=oo(R,E=>E.tagName),F=oo($,E=>E.tagName),N=y(p,k);for(let E of R){let G=E.tagName;if(H.get(G)!==1||F.get(G)!==1)continue;let he=$.find(ve=>ve.tagName===G);he&&!g.has(he)&&N(E,he)&&B(E,he)&&!ut(E,he)&&(m(E,he)?Bt(E,he):(ne(E,he),x.add(E)))}}function P(){let p=new Map;for(let E of x)if(re(E)&&re(f.get(E))){let G=o(E).hash;p.has(G)||p.set(G,[]),p.get(G).push(E)}if(p.size)for(let E of ce){if(g.has(E)||!re(E)||rt(E))continue;let G=p.get(o(E).hash),he=G&&G.find(ve=>x.has(ve)&&!ut(ve,E)&&B(ve,E)&&m(ve,E));he&&(Qe(he),Bt(he,E),Be(he,E),se.add(he))}let k=new Map,R=new Map,$=new Map;for(let E of x){let G=f.get(E);re(E)&&re(G)&&$.set(G,E)}let H=(E,G)=>{if(!g.has(E))return!rt(E);let he=$.get(E);return he===g.get(E)&&he!==G&&!he.contains(G)},F=E=>{if(g.has(E)){let G=$.get(E);$.delete(E),Qe(G)}};for(let E of[...ce,...$.keys()]){if(g.has(E)&&!$.has(E))continue;let G=o(E).hash;if(k.has(G)||k.set(G,[]),k.get(G).push(E),dt(E))continue;let he=o(E).sig;R.has(he)||R.set(he,[]),R.get(he).push(E)}let N=new Set;for(let E of x){let G=f.get(E);!re(E)||!re(G)||dt(E)||o(E).hint===""||o(G).hint===""||c(E,G)||N.add(E)}for(let E of[...z,...N]){let G=f.get(E);if(G?!(x.has(E)&&N.has(E)):We(E))continue;let he=U=>{G&&Qe(E),F(U)},ve=k.get(o(E).hash);if(ve){let U=ve.find(V=>V!==G&&H(V,E)&&!ut(E,V)&&m(E,V));if(U){he(U),Bt(E,U),Be(E,U),se.add(E);continue}}if(dt(E)||J<=0)continue;let u=R.get(o(E).sig);if(!u)continue;let v=null,j=0;for(let U of u)if(!(U===G||!H(U,E)||!B(E,U)||ut(E,U))&&(J--<=0||c(E,U)&&(j++,v=U,j>1)))break;j>1&&L&&L.add(E),j===1&&(he(v),ne(E,v),Be(E,v),se.add(E),te.push([E,v]))}}}function oo(e,t){let n=new Map;for(let o of e){let r=t(o);r!=null&&n.set(r,(n.get(r)||0)+1)}return n}var ec={diff:0},As=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,tc=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,nc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,oc=/\P{M}\p{M}*/gu;function Sr(e){if(e==="")return[];if(As){let n=[];for(let o of As.segment(e))n.push(o.segment);return n}let t=[];for(let n of e.match(nc))if(tc.test(n))for(let o of n.match(oc))t.push(o);else t.push(n);return t}var rc=/^[ ]+$/,sc=e=>rc.test(e)?" ".repeat(e.length):e,Dn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),gt="",kr=e=>e.every(t=>Dn(t)||t.k===gt),ic=/^[\x00-\x7f\u00A0]*$/,cc=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function lc(e){return e===""?[]:e.match(cc)}function $n(e,t=!1){return(t?lc(e):Sr(e)).map(n=>({k:sc(n),raw:n,len:n.length}))}var Go=(...e)=>e.every(t=>ic.test(t));function wr(e,t,n){let o=e.length,r=t.length,i=Math.min(o+r,n),c=i+1,s=new Int32Array(2*i+3),a=[],m=o===0&&r===0;for(let A=0;A<=i&&!m;A++){a.push(s.slice(c-A,c+A+1));for(let S=-A;S<=A;S+=2){let L;S===-A||S!==A&&s[c+S-1]<s[c+S+1]?L=s[c+S+1]:L=s[c+S-1]+1;let f=L-S,g=L;for(;L<o&&f<r&&e[L].k===t[f].k;)L++,f++;if(ec.diff+=1+L-g,s[c+S]=L,L>=o&&f>=r){m=!0;break}}}if(!m)return null;let h=[],d=o,b=r;for(let A=a.length-1;A>0;A--){let S=a[A],L=d-b,f=L+A,g=L===-A||L!==A&&S[f-1]<S[f+1]?L+1:L-1,x=S[g+A],Q=x-g;for(;d>x&&b>Q;)h.push([0,d-1,b-1]),d--,b--;d===x?(h.push([1,d,b-1]),b--):(h.push([-1,d-1,b]),d--)}for(;d>0&&b>0;)h.push([0,d-1,b-1]),d--,b--;return h.reverse(),h}function ac(e,t,n){let o=d=>d.k===gt;if(!e.some(o)&&!t.some(o))return wr(e,t,n);let r=[],i=[];for(let d=0;d<e.length;d++)o(e[d])||r.push(d);for(let d=0;d<t.length;d++)o(t[d])||i.push(d);let c=wr(r.map(d=>e[d]),i.map(d=>t[d]),n);if(!c)return null;let s=[],a=0,m=0,h=(d,b)=>{for(;a<d&&m<b&&e[a].k===t[m].k;)s.push([0,a++,m++]);let A=wr(e.slice(a,d),t.slice(m,b),n);if(!A)return!1;for(let[S,L,f]of A)s.push([S,L+a,f+m]);return a=d,m=b,!0};for(let[d,b,A]of c)if(d===0){if(!h(r[b],i[A]))return null;s.push([0,a,m]),a++,m++}return h(e.length,t.length)?s:null}function ro(e,t,n=4e3){let o=[],r=0;for(;r<e.length&&r<t.length&&e[r].k===t[r].k;)e[r].raw!==t[r].raw&&o.push({bi:r,tok:t[r]}),r++;let i=0;for(;i<e.length-r&&i<t.length-r&&e[e.length-1-i].k===t[t.length-1-i].k;)e[e.length-1-i].raw!==t[t.length-1-i].raw&&o.push({bi:e.length-1-i,tok:t[t.length-1-i]}),i++;let c=e.slice(r,e.length-i),s=t.slice(r,t.length-i),a=mc(c,s)?null:ac(c,s,n);if(!a){let g=c.length||s.length?[{bs:r,be:r+c.length,toks:s}]:[];return{hunks:g,cosmetic:o,coarse:!0,parts:g.map(x=>({...x,gap:[],group:0})),cosmeticEq:o}}let m=[],h=(g,x)=>{c[g].raw!==s[x].raw&&o.push({bi:r+g,tok:s[x]})},d=null,b=[],A=0,S=0,L=()=>{d&&m.push(d),d=null;for(let[g,x]of b)h(g,x);b=[],A++};for(let[g,x,Q]of a){if(g===0){d&&Dn(c[x])&&!c[x].k.includes(`
|
|
3
|
+
`)?b.push([x,Q]):(L(),h(x,Q)),S=x+1;continue}(!d||b.length)&&(d&&m.push(d),d={bs:r+S,be:r+S,toks:[],gap:b.map(([se,le])=>({bi:r+se,tok:s[le]})),group:A},b=[]),g===-1?(d.be=r+S+1,S=x+1):d.toks.push(s[Q])}L(),fc(m,e);let f=Tr(m);return{hunks:f.hunks,cosmetic:o.concat(f.cosmetic),parts:m,cosmeticEq:o}}function fc(e,t){for(let n=0;n<e.length;n++){let o=e[n];if(o.gap.length)continue;let r=n+1<e.length?e[n+1].bs:1/0;if(o.toks.length){if(o.bs===o.be)for(;o.bs+1<r&&o.bs<t.length&&o.toks[0].k===gt&&t[o.bs].k===gt;)o.toks=[...o.toks.slice(1),o.toks[0]],o.bs++,o.be++}else for(;o.be+1<r&&o.be<t.length&&t[o.bs].k===gt&&t[o.be].k===gt;)o.bs++,o.be++}}function Tr(e,t=()=>!1){let n=[],o=[],r=null,i=-1;for(let c of e){let s=t(c);if(r&&!r.alone&&!s&&c.group===i){r.be=c.be;for(let a of c.gap)r.toks.push(a.tok);for(let a of c.toks)r.toks.push(a);continue}r&&n.push({bs:r.bs,be:r.be,toks:r.toks});for(let a of c.gap)o.push(a);r={bs:c.bs,be:c.be,toks:c.toks.slice(),alone:s},i=c.group}return r&&n.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:n,cosmetic:o}}var uc=(e,t)=>e.bs===t.bs&&e.be===t.be&&Or(e.toks,t.toks);function Nr(e,t,n){let o=h=>d=>h.some(b=>uc(d,b)),r=Tr(e.parts,o(t.parts)),i=Tr(t.parts,o(e.parts)),c=e.cosmeticEq.concat(r.cosmetic),s=t.cosmeticEq.concat(i.cosmetic),[a,m]=n?dc(r.hunks,i.hunks,n,c,s):[r.hunks,i.hunks];return{lh:a,rh:m,cosL:c,cosR:s}}function dc(e,t,n,o,r){let i=(S,L)=>S.k===L.k&&S.raw===L.raw,c=[{list:e.map(S=>({...S})),resp:new Set(o.map(S=>S.bi)),raw:new Map(o.map(S=>[S.bi,S.tok]))},{list:t.map(S=>({...S})),resp:new Set(r.map(S=>S.bi)),raw:new Map(r.map(S=>[S.bi,S.tok]))}],s=S=>S.bs===S.be,a=(S,L,f,g)=>{let x=S.list[L];if(!s(x))return g(x)===f?x.toks:null;let Q=L?S.list[L-1].be:0,se=L+1<S.list.length?S.list[L+1].bs:n.length;if(f<Q||f>se)return null;let le=x.toks,q=x.bs;for(;q>f;){let z=le[le.length-1];if(!i(z,n[q-1])||S.resp.has(q-1))return null;le=[z,...le.slice(0,-1)],q--}for(;q<f;){if(!i(le[0],n[q])||S.resp.has(q))return null;le=[...le.slice(1),le[0]],q++}return le},m=(S,L,f,g,x,Q)=>{let se=S.list[L],le=x?f.slice(f.length-g):f.slice(0,g),q=x?f.slice(0,f.length-g):f.slice(g),z={bs:Q,be:Q,toks:le};if(s(se)){if(!q.length){S.list[L]=z;return}let xe={bs:Q,be:Q,toks:q};x&&(xe.lead=!0),S.list.splice(L,1,...x?[xe,z]:[z,xe]);return}let ce={bs:se.bs,be:se.be,toks:q};S.list.splice(L,1,...x?[ce,z]:[z,ce])},h=(S,L,f,g,x)=>{let Q=S.list[L],se=x?f.slice(f.length-g):f.slice(0,g),le=x?f.slice(0,f.length-g):f.slice(g),q={bs:Q.bs,be:Q.be,toks:se};if(!le.length){S.list[L]=q;return}let z=x?{bs:Q.bs,be:Q.bs,toks:le,lead:!0}:{bs:Q.be,be:Q.be,toks:le};S.list.splice(L,1,...x?[z,q]:[q,z])},d=(S,L,f,g)=>{let x=S.list[L],Q=f.list[g],se=x.be,le=Q.bs;if(se>=le||L+1<S.list.length&&S.list[L+1].bs<=Q.be||g>0&&f.list[g-1].be>=x.bs)return!1;for(let ge=se;ge<le;ge++)if(!Dn(n[ge])||n[ge].k.includes(`
|
|
4
|
+
`))return!1;let q=ge=>n.slice(se,le).map((Oe,Be)=>ge.raw.get(se+Be)||Oe),z=[...x.toks,...q(S)],ce=[...q(f),...Q.toks],xe=(ge,Oe,Be)=>Oe>=0&&Oe+Be.length<=ge.length&&Be.every((We,rt)=>ge[Oe+rt].k===We.k),te=(ge,Oe,Be)=>kr(ge)&&n.slice(Oe,Be).some(We=>!Dn(We)),J=ge=>ge.some(Oe=>!Dn(Oe)),Ce,we,ne,_;if(s(x)&&J(x.toks)&&xe(ce,0,x.toks)){let ge=ce.slice(x.toks.length);te(ge,se,Q.be)||(Ce=se,we=x.toks,ne=ce.slice(0,x.toks.length),_=[null,{bs:se,be:Q.be,toks:ge}])}if(Ce===void 0&&s(Q)&&J(Q.toks)){let ge=z.length-Q.toks.length,Oe=z.slice(0,ge);xe(z,ge,Q.toks)&&!te(Oe,x.bs,le)&&(Ce=le,we=z.slice(ge),ne=Q.toks,_=[{bs:x.bs,be:le,toks:Oe},null])}if(Ce===void 0)return!1;let ye=ge=>ge&&(ge.bs<ge.be||ge.toks.length);return S.list.splice(L,1,...[_[0],{bs:Ce,be:Ce,toks:we}].filter(ye)),f.list.splice(g,1,...[{bs:Ce,be:Ce,toks:ne},_[1]].filter(ye)),!0},b=c[0],A=c[1];for(let S=0;S<64;S++){let L=!1;e:for(let f=0;f<b.list.length;f++)for(let g=0;g<A.list.length;g++){let x=b.list[f],Q=A.list[g];if(!(x.bs===Q.bs&&x.be===Q.be&&Or(x.toks,Q.toks))){for(let se of[!0,!1]){let le=z=>se?z.be:z.bs,q=s(x)?[le(Q),x.bs]:[le(x)];for(let z of q){let ce=a(b,f,z,le),xe=ce&&a(A,g,z,le);if(!xe)continue;let te=(_,ye)=>se?_[_.length-1-ye]:_[ye],J=0;for(;J<ce.length&&J<xe.length&&te(ce,J).k===te(xe,J).k;)J++;if(!J)continue;let Ce=se?ce.slice(0,ce.length-J):ce.slice(J),we=se?xe.slice(0,xe.length-J):xe.slice(J);if(!(J<ce.length&&J<xe.length&&!kr(Ce)&&!kr(we)&&(s(x)&&s(Q)||x.bs===Q.bs&&x.be===Q.be)||!(se?ce.slice(ce.length-J):ce.slice(0,J)).some(_=>!Dn(_)))){if(J===ce.length&&J===xe.length&&s(x)&&s(Q)){if(x.bs===z&&Q.bs===z)continue;b.list[f]={bs:z,be:z,toks:ce},A.list[g]={bs:z,be:z,toks:xe}}else!s(x)&&x.bs===Q.bs&&x.be===Q.be?(h(b,f,ce,J,se),h(A,g,xe,J,se)):(m(b,f,ce,J,se,z),m(A,g,xe,J,se,z));L=!0;break e}}}if(d(b,f,A,g)||d(A,g,b,f)){L=!0;break e}}}if(!L)break}return[b.list,A.list]}var pc=48,hc=.3;function mc(e,t){let n=e.filter(c=>!Dn(c)),o=t.filter(c=>!Dn(c));if(Math.min(n.length,o.length)<pc)return!1;let r=new Map;for(let c of n)r.set(c.k,(r.get(c.k)||0)+1);let i=0;for(let c of o){let s=r.get(c.k);s>0&&(i++,r.set(c.k,s-1))}return i/Math.min(n.length,o.length)<hc}var gc=(e,t)=>{let n=new Set;for(let o of e.toks)typeof o.k!="string"&&n.add(o.k.el);for(let o=e.bs;o<e.be;o++)typeof t[o].k!="string"&&n.add(t[o].k.el);return n},Or=(e,t)=>e.length===t.length&&e.every((n,o)=>n.k===t[o].k);function Ss(e,t,n,o="remote"){let r=ro(e,t),i=ro(e,n),{lh:c,rh:s,cosL:a,cosR:m}=Nr(r,i,e),h=O=>O.bs===O.be,d=O=>O.toks.some(B=>typeof B.k=="string"),b=O=>h(O)&&!d(O),A=(O,B)=>B.bs<O.be&&O.bs<B.be,S=(O,B)=>!A(O,B)&&B.bs<=O.be&&O.bs<=B.be&&(h(O)&&d(O)||h(B)&&d(B))&&!(h(O)&&h(B)),L=(O,B)=>O.bs===B.bs&&O.be===B.be&&Or(O.toks,B.toks),f=[],g=new Set;for(let O of c){let B=s.find(ae=>!g.has(ae)&&L(O,ae));B?(g.add(B),f.push({bs:O.bs,be:O.be,side:"both",l:O,r:B,toks:O.toks})):f.push({bs:O.bs,be:O.be,side:"L",l:O,toks:O.toks,lead:!!O.lead})}for(let O of s)g.has(O)||f.push({bs:O.bs,be:O.be,side:"R",r:O,toks:O.toks,lead:!!O.lead});f.sort((O,B)=>O.bs-B.bs||O.be-B.be||B.lead-O.lead);let x=0,Q=0;for(let O of f)O.side==="both"&&(x+=O.toks.length-(O.be-O.bs));let se=f.map((O,B)=>B),le=O=>se[O]===O?O:se[O]=le(se[O]),q=(O,B)=>(O=le(O),B=le(B),O===B?!1:(se[O]=B,!0)),z=f.map(O=>gc({bs:O.bs,be:O.be,toks:O.toks},e)),ce={L:new Map,R:new Map};f.forEach((O,B)=>{let ae=O.side==="both"?["L","R"]:[O.side];for(let be of ae)for(let de of z[B])ce[be].has(de)||ce[be].set(de,[]),ce[be].get(de).push(B)});for(let O of[ce.L,ce.R])for(let B of O.values())for(let ae=1;ae<B.length;ae++)q(B[0],B[ae]);for(let O=0;O<f.length;O++)for(let B=O+1;B<f.length;B++){let ae=f[O],be=f[B];ae.side===be.side&&ae.side!=="both"||ae.bs>be.be||(A(ae,be)||S(ae,be)?q(O,B):ae.bs===be.bs&&h(ae)&&h(be)&&Q++)}let xe=(O,B)=>{let ae=O==="L"?c:s;for(let be of ae)if(be.toks.some(de=>de.kind==="close"&&de.k.el===B.el))return be.bs;for(let be=0;be<e.length;be++)if(e[be].kind==="close"&&e[be].k.el===B.el)return be;return-1};f.forEach((O,B)=>{if(!(!b(O)||O.side==="both"))for(let ae of O.toks){if(ae.kind!=="open")continue;let be=xe(O.side,ae.k);if(be<=O.bs)continue;let de=new Uint8Array(be-O.bs),ze=[];if(f.forEach((De,Qe)=>{if(!(De.side===O.side||h(De))&&De.bs<be&&De.be>O.bs){ze.push(Qe);for(let st=Math.max(De.bs,O.bs);st<Math.min(De.be,be);st++)de[st-O.bs]=1}}),ze.length&&de.every(De=>De===1))for(let De of ze)q(B,De)}});let te=!0;for(;te;){te=!1;let O=new Map;f.forEach((B,ae)=>{let be=le(ae),de=O.get(be)||{bs:B.bs,be:B.be,L:!1,R:!1};de.bs=Math.min(de.bs,B.bs),de.be=Math.max(de.be,B.be),B.side!=="R"&&(de.L=!0),B.side!=="L"&&(de.R=!0),O.set(be,de)}),f.forEach((B,ae)=>{for(let[be,de]of O){if(le(ae)===le(be)||!(de.L&&de.R))continue;let ze=B.bs<de.be&&B.be>de.bs,De=h(B)&&d(B)&&(B.bs===de.be||B.bs===de.bs);(ze||De)&&q(ae,be)&&(te=!0)}})}let J=new Map;f.forEach((O,B)=>{let ae=le(B);J.has(ae)||J.set(ae,[]),J.get(ae).push(O)});let Ce=[];for(let O of J.values()){let B=O.some(be=>be.side==="L"),ae=O.some(be=>be.side==="R");if(B&&ae){let be=Math.min(...O.map(Qe=>Qe.bs)),de=Math.max(...O.map(Qe=>Qe.be)),ze=O.filter(Qe=>Qe.side!=="R").map(Qe=>Qe.l).sort((Qe,st)=>Qe.bs-st.bs),De=O.filter(Qe=>Qe.side!=="L").map(Qe=>Qe.r).sort((Qe,st)=>Qe.bs-st.bs);Ce.push({bs:be,be:de,kind:"conflict",localHunks:ze,remoteHunks:De})}else for(let be of O)Ce.push({bs:be.bs,be:be.be,kind:be.side,u:be})}let we=(O,B)=>{let ae=O==="L"?c:s;for(let be of ae)if(be.toks.some(de=>de.kind==="close"&&de.k.el===B.el))return be.bs+.5;for(let be=0;be<e.length;be++)if(e[be].kind==="close"&&e[be].k.el===B.el)return be;return 1/0},ne=(O,B)=>{let ae=O==="L"?c:s;for(let be of ae)if(be.toks.some(de=>de.kind==="open"&&de.k.el===B.el))return be.bs-.5;for(let be=0;be<e.length;be++)if(e[be].kind==="open"&&e[be].k.el===B.el)return be;return-1/0},_=O=>O.kind==="R"?"R":"L",ye=O=>O.kind==="R"?1:0;Ce.sort((O,B)=>{if(O.bs!==B.bs)return O.bs-B.bs;let ae=O.bs===O.be,be=B.bs===B.be;if(ae!==be)return ae?-1:1;if(ae&&be&&O.kind!=="conflict"&&B.kind!=="conflict"){let ze=O.u.toks,De=B.u.toks,Qe=wt=>wt.length&&wt.every(bt=>bt.kind==="open"),st=wt=>wt.length&&wt.every(bt=>bt.kind==="close");if(Qe(ze)&&Qe(De)){let wt=Math.max(...ze.map(Tt=>we(_(O),Tt.k))),bt=Math.max(...De.map(Tt=>we(_(B),Tt.k)));if(wt!==bt)return bt-wt}if(st(ze)&&st(De)){let wt=Math.min(...ze.map(Tt=>ne(_(O),Tt.k))),bt=Math.min(...De.map(Tt=>ne(_(B),Tt.k)));return wt!==bt?bt-wt:ye(B)-ye(O)}}let de=ze=>ze.u&&ze.u.lead?1:0;return de(B)-de(O)||ye(O)-ye(B)||O.be-B.be});let ge=[],Oe=[],Be=0,We=O=>{O>Be&&(ge.push({bs:Be,be:O,toks:e.slice(Be,O),source:"base"}),Be=O)};for(let O of Ce){if(We(O.bs),O.kind==="conflict"){let B=Ar(e,O.localHunks,O.bs,O.be),ae=Ar(e,O.remoteHunks,O.bs,O.be),be=o==="local"?B:o==="both"?B.concat(ae):ae,de=(Qe,st)=>{let wt=0;for(let bt of Qe)bt.be<=O.bs&&!st.includes(bt)&&(wt+=bt.toks.length-(bt.be-bt.bs));return wt},ze=O.bs+de(c,O.localHunks),De=O.bs+de(s,O.remoteHunks);Oe.push({bs:O.bs,be:O.be,ls:ze,le:ze+B.length,rs:De,re:De+ae.length,ms:0,me:0,base:e.slice(O.bs,O.be),local:B,remote:ae,resolved:be}),ge.push({bs:O.bs,be:O.be,toks:be,source:"conflict",localHunks:O.localHunks,localToks:B,keepsLocal:o!=="remote"})}else ge.push({bs:O.bs,be:O.be,toks:O.u.toks,source:O.kind==="R"?"remote":"local",localHunks:O.kind==="R"?[]:[O.u.l]});Be=Math.max(Be,O.be)}We(e.length);let rt=0,re=0;for(let O of ge)O.source==="conflict"&&(Oe[re].ms=rt,Oe[re].me=rt+O.toks.length,re++),rt+=O.toks.length;let ut=new Map(a.map(O=>[O.bi,O.tok])),dt=new Map(m.map(O=>[O.bi,O.tok])),Se=[];for(let O of ge){O.source==="base"&&(O.toks=O.toks.map((B,ae)=>{let be=O.bs+ae,de=ut.get(be),ze=dt.get(be),De=de&&ze?o==="remote"?ze:de:de||ze||B;return De===B?B:{...De,cosmetic:!0}}));for(let B of O.toks)Se.push({...B,src:O.source})}return{tokens:Se,segments:ge,conflicts:Oe,localHunks:c,remoteHunks:s,collapsedDelta:x,samePoint:Q,mapLocalOffset:bc(e,c,ge)}}function Ar(e,t,n,o){let r=[],i=n;for(let c of t)r=r.concat(e.slice(i,c.bs),c.toks),i=c.be;return r.concat(e.slice(i,o))}var xr=e=>e.reduce((t,n)=>t+n.len,0);function bc(e,t,n){let o=new Int32Array(e.length+1);for(let c=0;c<e.length;c++)o[c+1]=o[c]+e[c].len;let r=t.map(c=>({bs:o[c.bs],be:o[c.be],text:c.toks.map(s=>s.raw).join(""),ref:c})),i=n.map(c=>({bs:o[c.bs],be:o[c.be],len:xr(c.toks),source:c.source,localHunks:c.localHunks||[],localLen:c.localToks?xr(c.localToks):0,keepsLocal:c.keepsLocal,ref:c}));return c=>{let s=null,a=null,m=0,h=0,d=0;for(let A of r){let S=A.bs-d;if(c<=h+S){s=d+(c-h);break}if(h+=S,d=A.bs,c<=h+A.text.length){a=A,m=c-h,s=A.bs;break}h+=A.text.length,d=A.be}s===null&&(s=d+(c-h));let b=0;for(let A of i){if(!a&&s<=A.bs)return b;if(!(a?A.localHunks.includes(a.ref):s<A.be)){b+=A.len;continue}if(A.source==="base")return b+(s-A.bs);if(A.source==="remote")return b+A.len;if(A.source==="local")return b+Math.min(m,A.len);if(!A.keepsLocal||!a)return b+A.len;let L=A.localHunks.indexOf(a.ref),f=xr(Ar(e,A.localHunks.slice(0,L),A.ref.bs,a.ref.bs));return b+Math.min(f+m,A.localLen)}return b}}function wo(e,t,n,o="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:g=>Math.min(g,t.length),granularity:"word"};let r=Go(e,t,n),i=$n(e,r),c=$n(t,r),s=$n(n,r),a=i.length<=2e4&&c.length<=2e4&&s.length<=2e4?Ss(i,c,s,o):null,m="word",h=i;if(!a){let g=x=>x.split(/(?<=\n)/).map(Q=>({k:Q,raw:Q,len:Q.length}));h=g(e),a=Ss(h,g(t),g(n),o),m="line"}let d=g=>g.map(x=>x.raw).join(""),b=g=>{let x=[0];for(let Q of g)x.push(x[x.length-1]+Q.len);return x},A=b(h),S=null,L=null,f=null;if(a.conflicts.length){let g=x=>x.split(/(?<=\n)/).map(Q=>({k:Q,raw:Q,len:Q.length}));S=b(m==="line"?g(t):c),L=b(m==="line"?g(n):s),f=b(a.tokens)}return{text:d(a.tokens),conflicts:a.conflicts.map(g=>({bs:A[g.bs],be:A[g.be],ls:S[g.ls],le:S[g.le],rs:L[g.rs],re:L[g.re],ms:f[g.ms],me:f[g.me],base:d(g.base),local:d(g.local),remote:d(g.remote),resolved:d(g.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:m}}function xo(e,t,n=4e3){if(e===t)return[];let o=Go(e,t),r=$n(e,o),i=$n(t,o),c=ro(r,i,n),s=[0];for(let a of r)s.push(s[s.length-1]+a.len);return c.hunks.map(a=>({bs:s[a.bs],be:s[a.be],text:a.toks.map(m=>m.raw).join("")}))}var co="\uFFFC";var yc={caret:0},An=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),Is=new Set(["BR","WBR","IMG"]),Er=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function qn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||Is.has(e.tagName))return!0;if(!An.has(e.tagName))return!Er.has(e.tagName);if(t.remoteWins&&t.remoteWins(e))return!1;let n=t.inlineCache&&t.inlineCache.get(e);if(n!==void 0)return n;let o=!0;for(let r of e.childNodes)if(!qn(r,t)){o=!1;break}return t.inlineCache&&t.inlineCache.set(e,o),o}function kc(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function En(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,i)=>{for(let c of r){if(c.nodeType===3){let d=c.nodeValue;if(!d)continue;n.nodes.push({node:c,s:n.text.length,e:n.text.length+d.length}),n.text+=d;for(let b=0;b<d.length;b++)n.stackAt.push(i);continue}if(c.nodeType!==1)continue;if(t.ignored&&t.ignored(c)){n.pins.push({el:c,i:n.text.length});continue}if(t.skip&&t.skip.has(c))continue;let s=t.via&&t.via(c)||c;s!==c&&(n.via||(n.via=new Map)).set(s,c);let a=c.tagName;if(t.blocks&&t.blocks.has(c)){n.text.length&&n.text[n.text.length-1]!==gt&&(n.stackAt.push(i),n.text+=gt);let d={el:c,tag:a,from:n.text.length,to:-1,depth:i.length,block:!0};n.marks.push(d);let b=i.concat([d]);o(s.childNodes,b),n.stackAt.push(b),n.text+=gt,d.to=n.text.length;continue}let m=An.has(a)&&kc(s);if(Is.has(a)||!An.has(a)||t.remoteWins&&t.remoteWins(c)||t.atomize&&t.atomize(c)||m){n.atoms.push({i:n.text.length,el:c,key:m?a+":empty":a,stack:i}),n.stackAt.push(i),n.text+=co;continue}let h={el:c,tag:a,from:n.text.length,to:-1,depth:i.length};n.marks.push(h),o(s.childNodes,i.concat([h])),h.to=n.text.length}};if(o(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&Yo(n).trim()===""){let r=n.atoms[0];n.placeholder=r.el,n.text=n.text.slice(0,r.i)+n.text.slice(r.i+1),n.stackAt.splice(r.i,1);for(let i of n.nodes)i.s>r.i&&(i.s--,i.e--);n.atoms=[]}return n.atomAt=new Map(n.atoms.map(r=>[r.i,r])),n}function wc(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function xc(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,""")}"`;return t+">"}function io(e,t,n){let o="",r=[];for(let i=t;i<n;i++){let c=e.stackAt[i],s=0;for(;s<r.length&&s<c.length&&r[s]===c[s];)s++;for(;r.length>s;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<c.length;){let m=c[r.length];o+=xc(m.el),r.push(m)}let a=e.atomAt.get(i);o+=a?a.el.outerHTML:e.text[i]===gt?"":wc(e.text[i])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function Tc(e,t){let n=[...e.el.attributes].filter(o=>!t(e.el,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tag+"|"+n}function Cs(e,t){let n=[...e.attributes].filter(o=>!t(e,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tagName+"|"+n+"|"+e.innerHTML}function Ns(e,t=()=>!1){let n=new Map,o=i=>{let c=n.get(i);return c===void 0&&(c="{"+i.map(s=>Tc(s,t)).sort().join(",")+"}",n.set(i,c)),c},r="";for(let i=0;i<e.text.length;i++){let c=e.atomAt.get(i);r+=(c?"["+Cs(c.el,t)+"]":e.text[i])+o(e.stackAt[i])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function so(e,t,n,o=r=>r.key){let r=[],i=e.text,c=0,s=a=>{if(a<=c)return;let m=i.slice(c,a);if(n)for(let h of m.split(/(?<=\n)/))r.push({k:h,raw:h,len:h.length});else for(let h of $n(m,t))r.push(h)};for(let a of e.atoms)s(a.i),r.push({k:"\0"+o(a),raw:co,len:1,atom:!0}),c=a.i+1;return s(i.length),r}function Yo(e){if(!e.atoms.length)return e.text;let t="",n=0;for(let o of e.atoms)t+=e.text.slice(n,o.i),n=o.i+1;return t+e.text.slice(n)}var Mr=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n].len;return t};function Os(e,t,n,o){let r=Mr(t),i=Mr(n),c=[],s=0,a=0;for(let h of o.hunks){a+=h.bs-s;let d=a+h.toks.length;c.push({bs:r[h.bs],be:r[h.be],ss:i[a],se:i[d],text:e.text.slice(i[a],i[d]),toks:h.toks,lead:!!h.lead}),a=d,s=h.be}let m=new Map;for(let h of o.cosmetic)m.set(h.bi,h.tok.raw);return{hunks:c,respell:m}}function vs(e,t,n){let o=c=>c===gt||/\s/.test(c),r=c=>c.replace(/[\u001E\s]/g,""),i=[];for(let c of e){let s=t.slice(c.bs,c.be),a=n.slice(c.ss,c.se);if(!s.includes(gt)&&!a.includes(gt)||s.includes(co)||a.includes(co)||r(s)!==r(a)){i.push(c);continue}let m=0,h=0;for(;;){let d=m,b=h;for(;d<s.length&&o(s[d]);)d++;for(;b<a.length&&o(a[b]);)b++;let A=m,S=h;for(;A<d&&S<b&&s[A]===a[S];)A++,S++;let L=d,f=b;for(;L>A&&f>S&&s[L-1]===a[f-1];)L--,f--;if(L>A||f>S){let g=a.slice(S,f);i.push({bs:c.bs+A,be:c.bs+L,ss:c.ss+S,se:c.ss+f,text:g,toks:[...g].map(x=>({k:x,raw:x,len:1})),lead:c.lead})}if(d>=s.length)break;m=d+1,h=b+1}}return i}function Ms(e,t,n){let o=new Int32Array(t+1).fill(-1),r=new Int32Array(n+1).fill(-1),i=0,c=0,s=a=>{for(;i<a;)o[i]=c,r[c]=i,i++,c++};for(let a of e)s(a.bs),i=a.be,c=a.se;return s(t),o[t]=c,r[c]=t,{bTo:o,toB:r}}function Es(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ir(e){let{out:t,policy:n="remote",L:o,R:r}=e,i=e.provenance||new WeakMap,c=e.textMappers||new WeakMap,s=e.conflicts||[],a=e.decisions||[],m=s.length,h=e.conflict||(l=>s.push(l)),d={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},b=[],A=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),S={base:null,local:null,remote:null};if(A&&e.moveIn){let l=Te=>Ve=>Te.some(ke=>ke===Ve||ke.nodeType===1&&ke.contains(Ve)),w=l(e.local),C=l(e.remote),I=l(e.base),D=new Set,K=Te=>{if(!An.has(Te.tagName))return;let Ve=o.map.get(Te),ke=r.map.get(Te);(Ve&&!w(Ve)||ke&&!C(ke))&&D.add(Te);for(let Ee of Te.children)K(Ee)};for(let Te of e.base)Te.nodeType===1&&K(Te);let pe=Te=>Ve=>{if(!An.has(Ve.tagName))return!1;let ke=Te.reverse.get(Ve);return!!ke&&(D.has(ke)||!I(ke))};D.size&&(S.base=Te=>D.has(Te)),S.local=pe(o),S.remote=pe(r)}let L={base:new Set,local:new Set,remote:new Set};if(A&&e.moveIn){let l=I=>D=>I.some(K=>K===D||K.nodeType===1&&K.contains(D)),w=l(e.local),C=l(e.remote);for(let I of En(e.base,{...e,atomize:S.base}).atoms){let D=o.map.get(I.el),K=r.map.get(I.el),pe=!!D&&!w(D),Te=!!K&&!C(K);!pe&&!Te||(L.base.add(I.el),D&&!pe&&L.local.add(D),K&&!Te&&L.remote.add(K),w(I.el)&&L.local.add(I.el),C(I.el)&&L.remote.add(I.el))}}let f=En(e.base,{...e,atomize:S.base,skip:L.base}),g=En(e.local,{...e,atomize:S.local,skip:L.local}),x=En(e.remote,{...e,atomize:S.remote,skip:L.remote}),Q=new Map(f.atoms.map(l=>[l.el,l])),se={},le=l=>L[l].size?(se[l]||(se[l]=En(e[l],{...e,atomize:S[l]})),se[l]):null,q=(l,w,C)=>{w.namespaceURI?l.setAttributeNS(w.namespaceURI,w.name,C):l.setAttribute(w.name,C)},z=(l,w,C,I)=>{if(!w&&(!C||!I)){for(let K of(C||I).attributes)q(l,K,K.value);return}let D=new Map;for(let K of[w,C,I])if(K)for(let pe of K.attributes)D.set(pe.name,pe);for(let[K,pe]of D){let Te=w?w.getAttribute(K):null,Ve=C?C.getAttribute(K):Te,ke=I?I.getAttribute(K):Te,Ee;Ve===ke?Ee=Ve:Ve===Te?(Ee=ke,a.push({kind:"attr",el:l,name:K,source:"remote"})):ke===Te?(Ee=Ve,a.push({kind:"attr",el:l,name:K,source:"local"})):(Ee=n==="local"?Ve:ke,h({kind:"attr",el:l,name:K,base:Te,local:Ve,remote:ke,resolved:Ee},{el:l,sample:pe}),a.push({kind:"attr",el:l,name:K,source:"both"})),Ee!=null&&q(l,pe,Ee)}},ce=(l,w,C,I)=>l&&e.mergeAttrs?e.mergeAttrs(l,w,C,I):z(I,l,w,C),xe=e.mergeElement||((l,w,C)=>{let I=t.createElement(l.tagName);ce(l,w,C,I);let D=w||l,K=C||l,pe=n==="local"?D.isEqualNode(l)?K:D:K.isEqualNode(l)?D:K;for(let Te of pe.childNodes)I.appendChild(t.importNode(Te,!0));return i.set(I,{base:l,local:w,remote:C}),I}),te=e.cloneUnit||((l,w)=>{let C=t.importNode(l,!0);return i.set(C,{base:null,local:w==="local"?l:null,remote:w==="remote"?l:null}),C}),J=e.atomKey||(l=>Cs(l,()=>!1)),Ce=(l,w)=>{let C=new Map;for(let I of l.atoms)if(e.remoteWins&&e.remoteWins(I.el)&&An.has(I.el.tagName))C.set(I,"w"+I.el.tagName+"#"+(I.el.id||""));else if(!A)C.set(I,I.key);else if(l===f)C.set(I,"="+J(I.el));else{let D=w.reverse.get(I.el),K=D?Q.get(D):null;K?C.set(I,"="+J(K.el)):D?C.set(I,"m"+J(I.el)):C.set(I,"="+J(I.el))}return I=>C.get(I)},we=Ce(f,null),ne=Ce(g,o),_=Ce(x,r),ye=Go(Yo(f),Yo(g),Yo(x)),ge=so(f,ye,!1,we),Oe=so(g,ye,!1,ne),Be=so(x,ye,!1,_),We=ge.length>2e4||Oe.length>2e4||Be.length>2e4;We&&(ge=so(f,ye,!0,we),Oe=so(g,ye,!0,ne),Be=so(x,ye,!0,_));let rt=Nr(ro(ge,Oe),ro(ge,Be),ge),re=Os(g,ge,Oe,{hunks:rt.lh,cosmetic:rt.cosL}),ut=Os(x,ge,Be,{hunks:rt.rh,cosmetic:rt.cosR});re.hunks=vs(re.hunks,f.text,g.text),ut.hunks=vs(ut.hunks,f.text,x.text);let dt=Ms(re.hunks,f.text.length,g.text.length),Se=Ms(ut.hunks,f.text.length,x.text.length),O=f.text.length,B=l=>new Map(l.atoms.map(w=>[w.el,w])),ae=B(g),be=B(x),de=(l,w,C)=>{let I=new Set;if(!A)return I;for(let D of l.atoms){let K=Q.get(w.reverse.get(D.el));K&&C.bTo[K.i]<0&&I.add(K)}return I},ze=de(g,o,dt),De=de(x,r,Se),Qe=l=>!qn(l,{...e,remoteWins:null}),st=new Set;if(A)for(let l of f.atoms){if(!Qe(l.el))continue;let w=o.map.get(l.el)||null,C=r.map.get(l.el)||null,I=w&&!C?w:C&&!w?C:null;I&&(ae.has(I)||be.has(I))&&!I.isEqualNode(l.el)&&st.add(l)}let wt=1,bt=(l,w)=>({id:wt++,tag:l,base:null,local:null,remote:null,rank:w}),Tt=new Map,nn=[];for(let l of f.marks){let w=bt(l.tag,l.depth);w.block=!!l.block,w.base=l.el,w.baseMark=l,Tt.set(l.el,w),nn.push(w)}let Fe=(l,w)=>{let C=-1,I=-1;for(let D=l.from;D<l.to;D++){let K=w[D];K>=0&&(C<0&&(C=K),I=K+1)}return C<0?null:[C,I]},Qt=(l,w,C,I)=>{for(let D of l.marks){let K=C?C.reverse.get(D.el):null;K&&C.identical.has(K)&&C.pairIdenticalChildren&&C.pairIdenticalChildren(K);let pe=K?Tt.get(K):null;if(pe&&pe[w]&&(pe=null),!pe){let Te=Fe(D,I),Ve=0;if(Te)for(let ke of nn){if(ke.tag!==D.tag||ke[w]||!!ke.block!=!!D.block)continue;let Ee=Math.min(Te[1],ke.baseMark.to)-Math.max(Te[0],ke.baseMark.from);(Ee>Ve||Ee===Ve&&Ee>0&&Math.abs(ke.rank-D.depth)<Math.abs(pe.rank-D.depth))&&(pe=ke,Ve=Ee)}}pe||(pe=bt(D.tag,D.depth),pe.block=!!D.block,pe.new=w),pe[w]=D.el,pe[w+"Mark"]=D,Tt.set(D.el,pe)}};Qt(g,"local",o,dt.toB),Qt(x,"remote",r,Se.toB);let Xt=l=>l.merged||l,Bt=l=>{let w=new Set;for(let C of l)C.block||w.add(Tt.get(C.el));return w},Et=new Map,Lt=l=>{let w=Et.get(l);return w||(w=Bt(l),Et.set(l,w)),w},sn=(l,w)=>{let C=[],I=null;for(let D=0;D<O;D++){let K=w[D];if(K<0){I&&C.push(I),I=null;continue}let pe=Lt(f.stackAt[D]),Te=Lt(l.stackAt[K]),Ve=new Set,ke=new Set;for(let Ee of Te)pe.has(Ee)||Ve.add(Ee);for(let Ee of pe)Te.has(Ee)||ke.add(Ee);if(!Ve.size&&!ke.size){I&&C.push(I),I=null;continue}if(I&&Es(I.added,Ve)&&Es(I.removed,ke)){I.be=D+1;continue}I&&C.push(I),I={bs:D,be:D+1,added:Ve,removed:ke}}return I&&C.push(I),C},M=sn(g,dt.bTo),Z=sn(x,Se.bTo),ee=l=>l.be>l.bs?[l.bs,l.be-1]:[l.bs-1,l.bs],ue=(l,w)=>{if(O===0)return null;let[C,I]=ee(l);for(let D of w){if(D.be<=C)continue;if(D.bs>I)break;let K=D.bs<=C&&I<D.be;return K&&l.text===""&&D.bs===l.bs&&D.be===l.be?"straddle":K?D:l.be>l.bs?"straddle":null}return null},oe=l=>l.bs===l.be,fe=(l,w)=>{let C=!1;for(let I=l.bs;I<l.be;I++){let D=f.text[I];if(D===gt)C=!0;else if(!/\s/.test(D))return!1}for(let I=l.ss;I<l.se;I++){let D=w.text[I];if(D===gt)C=!0;else if(!/\s/.test(D))return!1}return C},y=(l,w)=>l.bs<w.be&&w.bs<l.be,T=(l,w)=>l.bs<=w.be&&w.bs<=l.be&&oe(l)!==oe(w),P=(l,w)=>f.text.slice(l.bs,l.be).includes(gt)||w.text.slice(l.ss,l.se).includes(gt),p=l=>{if(oe(l))return!1;let w=l.bs,C=l.be;for(;w>0&&/\s/.test(f.text[w-1]);)w--;for(;C<f.text.length&&/\s/.test(f.text[C]);)C++;return(w===0||f.text[w-1]===gt)&&(C===f.text.length||f.text[C]===gt)},k=(l,w)=>!P(l,w)&&!p(l),R=(l,w)=>y(l,w)||T(l,w)&&!(fe(l,g)&&k(w,x))&&!(fe(w,x)&&k(l,g)),$=(l,w)=>{if(l.bs!==w.bs||l.be!==w.be||l.toks.length!==w.toks.length)return!1;let C=l.ss,I=w.ss;for(let D=0;D<l.toks.length;D++){let K=l.toks[D],pe=w.toks[D];if(K.k!==pe.k||K.atom&&!g.atomAt.get(C).el.isEqualNode(x.atomAt.get(I).el))return!1;C+=K.len,I+=pe.len}return!0},H=(l,w,C,I)=>{for(let D of f.atoms){if(D.i<l.bs||D.i>=l.be||I.has(D)||st.has(D))continue;let K=w.bTo[D.i],pe=K>=0?C.atomAt.get(K):null;if(pe&&!pe.el.isEqualNode(D.el))return!0}return!1},F=[],N=re.hunks,E=ut.hunks,G=0,he=0,ve=0,u=0,v=0,j=l=>{l>ve&&(F.push({src:"base",from:ve,to:l,dL:u,dR:v}),ve=l)};for(;G<N.length||he<E.length;){let l=N[G],w=E[he],C=!!l&&(!w||l.bs<w.bs||l.bs===w.bs&&l.be<=w.be&&!w.lead);if(l&&w&&l.bs===w.bs&&oe(l)&&oe(w)){let Ct=fe(l,g),yo=fe(w,x);Ct!==yo&&(C=yo)}let I=C?l:w,D=C?w:l,K=!!D&&$(l,w),pe=!!D&&(C?!!N[G+1]&&$(N[G+1],w):!!E[he+1]&&$(l,E[he+1])),Te=!!D&&!K&&!pe&&(O===0||R(l,w)),Ve=Te,ke=ue(I,C?Z:M);if(ke==="straddle"&&(Ve=!0),!Ve&&I.be>I.bs&&(Ve=H(I,C?Se:dt,C?x:g,C?ze:De)),!Ve&&K){j(I.bs),F.push({src:"both",lfrom:l.ss,rfrom:w.ss,len:I.text.length}),ve=I.be,u+=I.text.length-(I.be-I.bs),v+=I.text.length-(I.be-I.bs),G++,he++;continue}if(!Ve){j(I.bs),F.push({src:C?"local":"remote",from:I.ss,to:I.se,inherit:ke&&ke!=="straddle"?ke:null}),ve=I.be,C?(u+=I.text.length-(I.be-I.bs),G++):(v+=I.text.length-(I.be-I.bs),he++);continue}let Ee=I.bs,lt=I.be,Ye=G,ot=he,jt=Ct=>Ct.bs<lt&&Ct.be>Ee||oe(Ct)&&(Ct.bs===Ee||Ct.bs===lt);C?Ye++:ot++,Te&&(Ee=Math.min(Ee,D.bs),lt=Math.max(lt,D.be),C?ot++:Ye++);let Nt=!0;for(;Nt;){for(Nt=!1;Ye<N.length&&jt(N[Ye]);)Ee=Math.min(Ee,N[Ye].bs),lt=Math.max(lt,N[Ye].be),Ye++,Nt=!0;for(;ot<E.length&&jt(E[ot]);)Ee=Math.min(Ee,E[ot].bs),lt=Math.max(lt,E[ot].be),ot++,Nt=!0}let rn=Ee+u,Yt=Ee+v,pn=lt-Ee,kn=lt-Ee;for(let Ct=G;Ct<Ye;Ct++)pn+=N[Ct].text.length-(N[Ct].be-N[Ct].bs);for(let Ct=he;Ct<ot;Ct++)kn+=E[Ct].text.length-(E[Ct].be-E[Ct].bs);let On=rn+pn,vn=Yt+kn;j(Ee);let Wt={kind:"text",node:e.node||null,base:io(f,Ee,lt),local:io(g,rn,On),remote:io(x,Yt,vn),resolved:null,range:null,bs:Ee,be:lt,lss:rn,lse:On,rss:Yt,rse:vn};Wt.resolved=n==="local"?Wt.local:n==="remote"?Wt.remote:Wt.local+Wt.remote,n!=="remote"&&F.push({src:"local",from:rn,to:On,conflict:Wt}),n!=="local"&&F.push({src:"remote",from:Yt,to:vn,conflict:Wt});let Vo={site:"inline",fb:f,fl:g,fr:x,scope:e.scope||null,synthetic:!!e.synthetic,full:le,merged:d};b.push(Vo),h(Wt,Vo),ve=lt,u+=pn-(lt-Ee),v+=kn-(lt-Ee),G=Ye,he=ot}j(O);let U=f.text,V=[];if(re.respell.size||ut.respell.size){let l=Mr(ge),w=[];for(let C=0;C<ge.length;C++){let I=ge[C].raw,D=re.respell.get(C)??I,K=ut.respell.get(C)??I;(D!==I||K!==I)&&V.push([l[C],D!==I&&K!==I?"both":D!==I?"local":"remote"]),w.push(D===K?D:D===I?K:K===I||n==="local"?D:K)}U=w.join("")}let W="",Y=[],ie=[],Ne=[],Le=[];for(let l of F){let w=W.length;if(l.src==="base"){for(let C=l.from;C<l.to;C++)Y.push(C),ie.push(C+l.dL),Ne.push(C+l.dR),Le.push(l);W+=U.slice(l.from,l.to)}else if(l.src==="both"){for(let C=0;C<l.len;C++)Y.push(-1),ie.push(l.lfrom+C),Ne.push(l.rfrom+C),Le.push(l);W+=g.text.slice(l.lfrom,l.lfrom+l.len)}else{let C=l.src==="local"?g:x;for(let I=l.from;I<l.to;I++)Y.push(-1),ie.push(l.src==="local"?I:-1),Ne.push(l.src==="remote"?I:-1),Le.push(l);W+=C.text.slice(l.from,l.to)}l.ms=w,l.me=W.length,l.conflict&&(l.conflict.range||(l.conflict.range=[w,w]),l.conflict.range[1]=W.length)}let Me=W.length,Ze=new Int32Array(O+1).fill(-1),je=new Int32Array(g.text.length+1).fill(-1),Ot=new Int32Array(x.text.length+1).fill(-1);for(let l=0;l<Me;l++)Y[l]>=0&&(Ze[Y[l]]=l),ie[l]>=0&&(je[ie[l]]=l),Ne[l]>=0&&(Ot[Ne[l]]=l);let Ue=(l,w)=>{let C=-1,I=-1;for(let D=l.from;D<l.to;D++){let K=w[D];K>=0&&(C<0&&(C=K),I=K+1)}return C<0?null:[C,I]},ht=[],it=[];for(let l of new Set(Tt.values()))l.new==="local"?ht.push(l):l.new==="remote"&&it.push(l);let Kt=(l,w)=>{l.remote=w.remote,l.remoteMark=w.remoteMark,l.new="both",w.merged=l,Tt.set(w.remote,l)};if(ht.length&&it.length){let l=e.idOf;for(let w of ht){let C=l?l.local(w.local):null;if(!C)continue;let I=it.find(D=>!D.merged&&D.tag===w.tag&&!!D.block==!!w.block&&l.remote(D.remote)===C);I&&Kt(w,I)}for(let w of ht){if(w.remote)continue;let C=Ue(w.localMark,je);if(C)for(let I of it){if(I.merged||I.tag!==w.tag||!!I.block!=!!w.block)continue;let D=Ue(I.remoteMark,Ot);if(D&&Math.min(C[1],D[1])-Math.max(C[0],D[0])>0){Kt(w,I);break}}}}Et.clear();let Rt=l=>{for(let w of l)if(w.block)return Xt(Tt.get(w.el));return null},qt=f.marks.some(l=>l.block)||g.marks.some(l=>l.block)||x.marks.some(l=>l.block),It=new Array(Me).fill(null),at=new Set;if(qt){let l=(ke,Ee,lt)=>{let Ye=new Set([ke,Ee,lt]);Ye.delete(null);let ot=[];for(let Nt of Ye){let rn=Nt===ke,Yt=Nt===Ee,pn=Nt===lt;(Yt===pn?Yt:Yt===rn?pn:Yt)&&ot.push(Nt)}if(ot.length<=1)return ot[0]||null;let jt=n==="local"?Ee:lt;return ot.includes(jt)?jt:ot[0]},w=(ke,Ee)=>Ee>=0?Rt(ke.stackAt[Ee]):null,C=new Map;for(let ke=0;ke<Me;ke++){if(W[ke]!==gt)continue;let Ee=Y[ke]>=0?w(f,Y[ke]):null,lt=w(g,ie[ke]),Ye=w(x,Ne[ke]);C.set(ke,[Ee,Y[ke]>=0?l(Ee,lt,Ye):lt||Ye])}let I=new Set([...C.values()].map(ke=>ke[1])),D=ke=>ke!==gt&&ke!==co&&!/\s/.test(ke),K=(ke,Ee)=>{let lt=ke;for(;lt<Ee&&!D(W[lt]);)lt++;return lt<Ee&&Y[lt]>=0?w(f,Y[lt]):null},pe=new Map,Te=0;for(let ke=0;ke<Me;ke++){if(W[ke]!==gt)continue;let[Ee,lt]=C.get(ke),Ye=K(Te,ke),ot=lt,jt=pe.get(ot)===ot&&Ye===ot;ot&&pe.has(ot)&&!jt&&Ee&&!pe.has(Ee)&&!I.has(Ee)&&(ot=Ee),ot&&!pe.has(ot)&&pe.set(ot,Ye);for(let Nt=Te;Nt<=ke;Nt++)It[Nt]=ot;Te=ke+1}let Ve=ke=>{for(let Ee=0;Ee<ke.text.length;Ee++)if(D(ke.text[Ee])&&!w(ke,Ee))return!0;return!1};if(!Ve(f)&&!Ve(g)&&!Ve(x)){let ke=[],Ee=0;for(let Ye=0;Ye<Me;Ye++)(W[Ye]===gt||Ye===Me-1)&&(ke.push([Ee,Ye]),Ee=Ye+1);let lt=new Set(It);for(let Ye=0;Ye<ke.length;Ye++){let[ot,jt]=ke[Ye];if(It[jt])continue;let Nt=ot;for(;Nt<=jt&&!D(W[Nt]);)Nt++;if(Nt>jt)continue;let rn=w(f,Y[Nt]),Yt=w(g,ie[Nt]),pn=w(x,Ne[Nt]),kn=l(rn,Yt,pn)||Yt||pn||rn;if(kn&&!lt.has(kn)){lt.add(kn);for(let Wt=ot;Wt<=jt;Wt++)It[Wt]=kn;continue}let On=Ye>0&&It[ke[Ye-1][1]],vn=Ye+1<ke.length&&It[ke[Ye+1][1]];if(On)at.add(ke[Ye-1][1]);else if(vn&&W[jt]===gt)at.add(jt);else continue;for(let Wt=ot;Wt<=jt;Wt++)It[Wt]=On||vn}}}let St=new Map,At=l=>{let w=St.get(l);if(w)return w;w=[1/0,-1/0];for(let[C,I]of[[l.baseMark,Ze],[l.localMark,je],[l.remoteMark,Ot]]){let D=C&&Ue(C,I);D&&(w[0]=Math.min(w[0],D[0]),w[1]=Math.max(w[1],D[1]))}return St.set(l,w),w},Ht=(l,w,C)=>{let I=-1,D=-1;for(let K=0;K<l.length;K++){let pe=Tt.get(l[K].el);pe===w&&(I=K),pe===C&&(D=K)}return I>=0&&D>=0?I-D:0},Zt=(l,w)=>[...l].sort((C,I)=>{for(let pe of w){let Te=Ht(pe,C,I);if(Te)return Te}let D=At(C),K=At(I);return D[0]-K[0]||K[1]-D[1]||C.rank-I.rank||C.id-I.id}),un=new Map,In=new Map,Cn=l=>{let w=Y[l],C=ie[l],I=Ne[l],D=Le[l];if(w>=0){let Ye=f.stackAt[w],ot=g.stackAt[C],jt=x.stackAt[I],Nt=un.get(Ye);Nt||un.set(Ye,Nt=new Map);let rn=Nt.get(ot);rn||Nt.set(ot,rn=new Map);let Yt=rn.get(jt);if(Yt)return Yt;let pn=Lt(Ye),kn=Lt(ot),On=Lt(jt),vn=new Set;for(let Wt of new Set([...pn,...kn,...On])){let Vo=pn.has(Wt),Ct=kn.has(Wt),yo=On.has(Wt);(Ct===yo?Ct:Ct===Vo?yo:Ct)&&vn.add(Wt)}return Yt=Zt(vn,[ot,jt,Ye]),rn.set(jt,Yt),Yt}if(D.src==="both"){let Ye=g.stackAt[C],ot=x.stackAt[I];return Zt(new Set([...Lt(Ye),...Lt(ot)]),[Ye,ot])}let pe=(D.src==="local"?g:x).stackAt[D.src==="local"?C:I];if(!D.inherit)return Zt(Lt(pe),[pe]);let Te=In.get(D);Te||In.set(D,Te=new Map);let Ve=Te.get(pe);if(Ve)return Ve;let ke=new Set(Lt(pe));for(let Ye of D.inherit.added)ke.add(Xt(Ye));for(let Ye of D.inherit.removed)ke.delete(Xt(Ye));let Ee=D.src==="local"?x:g,lt=(D.src==="local"?Se.bTo:dt.bTo)[D.inherit.bs];return Ve=Zt(ke,[pe,Ee.stackAt[lt]]),Te.set(pe,Ve),Ve},xn=new Int32Array(g.text.length+1);xn[g.text.length]=Me;for(let l=g.text.length-1;l>=0;l--)xn[l]=je[l]>=0?je[l]:xn[l+1];yc.caret+=g.text.length;let cn=l=>l<=0?0:(l>g.text.length&&(l=g.text.length),je[l-1]>=0?je[l-1]+1:xn[l]),zt=[],X=[],Re=null,Ae=[],Ge="",ct=-1,He=l=>{Re?Re.appendChild(l):zt.push(l)},$e=l=>{if(!Ge)return;let w=t.createTextNode(Ge);He(w),X.push({node:w,ms:ct,me:l,local:[],u:Ae.length?Ae[Ae.length-1].u:null}),Ge=""},et=new Set,_e=new Map,nt=new Set,en=l=>{let w=t.createElement(l.tag);if(l.block&&_t.add(w),!_e.has(l)){_e.set(l,w),ce(l.base,l.local,l.remote,w),i.set(w,{base:l.base,local:l.local,remote:l.remote});let I=(pe,Te)=>A&&l[Te]&&pe.reverse.get(l[Te])?Te:null,D=!l.base&&(I(o,"local")||I(r,"remote"));if(D){let pe=D==="local"?o.reverse.get(l.local):r.reverse.get(l.remote),Te=i.get(w);Te.local=Te.local||o.map.get(pe)||null,Te.remote=Te.remote||r.map.get(pe)||null,a.push({kind:"move",el:w,source:D})}else l.base||a.push({kind:"insert",el:w,source:l.local&&l.remote?"both":l.local?"local":"remote"});let K=i.get(w);K.local&&(nt.has(K.local)?K.local=null:nt.add(K.local))}else{let I=_e.get(l);for(let D of I.attributes)D.name!=="id"&&D.name!=="data-id"&&q(w,D,D.value);i.set(w,{base:null,local:null,remote:null})}He(w),Ae.push({u:l,el:w}),Re=w},Vn=new Set,dn=new Map;for(let l of g.pins){let w=cn(l.i);dn.has(w)||dn.set(w,[]),dn.get(w).push(l)}let ln=l=>{let w=dn.get(l);if(w){$e(l);for(let C of w){let I=C.el.namespaceURI&&C.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(C.el.namespaceURI,C.el.tagName):t.createElement(C.el.tagName);i.set(I,{base:null,local:C.el,remote:null,pinned:!0}),Vn.add(I),He(I)}}},Wn=f.atoms.length||g.atoms.length||x.atoms.length,Je=l=>{if(!Wn)return null;let w=Y[l]>=0?f.atomAt.get(Y[l]):null,C=ie[l]>=0?g.atomAt.get(ie[l]):null,I=Ne[l]>=0?x.atomAt.get(Ne[l]):null;return w||C||I?{ab:w,al:C,ar:I}:null},ft=(l,w,C,I)=>{if(!l||!A)return null;let D=Q.get(w.reverse.get(l.el))||null;return!D||D===I||(I?D.el.isEqualNode(I.el):C.bTo[D.i]>=0)?null:D},me=(l,w)=>{if(!l||!A||!e.moveIn)return null;let C=w.reverse.get(l.el);return C&&!Q.has(C)?C:null},Ie=(l,w)=>{let C=new Map;for(let I of l.atoms)C.set(w(I),(C.get(w(I))||0)+1);return C},qe=Ie(f,we),tt=Ie(g,ne),Ke=Ie(x,_),kt=l=>{let w=we(l);return qe.get(w)===1&&(tt.get(w)||0)<=1&&(Ke.get(w)||0)<=1},yt=new Map,Pt=new Set,Ft=new Set,on=new Set;for(let l=0;l<Me;l++){let w=Je(l);if(!w)continue;let{ab:C,al:I,ar:D}=w,K=ft(D,r,Se,C),pe=ft(I,o,dt,C),Te=C,Ve=null;if(K?(Te=K,Ve="remote"):pe&&(Te=pe,Ve="local"),Te){Pt.has(Te)?yt.set(l,{dup:Te.el}):(Pt.add(Te),yt.set(l,{bk:Te,from:Ve,al:I,ar:D}));continue}let ke=me(D,r),Ee=me(I,o),lt=ke||Ee;if(lt){Ft.has(lt)?yt.set(l,{dup:lt}):(Ft.add(lt),yt.set(l,{moveIn:lt,side:ke?"remote":"local",sideEl:ke?D.el:I.el}));continue}let Ye=(jt,Nt)=>jt&&A&&Q.get(Nt.reverse.get(jt.el))||null,ot=Ye(D,r)||Ye(I,o);if(ot&&(on.add(ot),Le[l].conflict&&kt(ot))){if(Pt.has(ot)){yt.set(l,{dup:ot.el});continue}Pt.add(ot)}yt.set(l,{al:I,ar:D})}let vt=new Map,Ln=(l,w)=>{if(l[w]>=0)return l[w];for(let C=w-1;C>=0;C--)if(l[C]>=0)return l[C]+1;return 0};if(A)for(let l of f.atoms){if(Pt.has(l)||on.has(l))continue;let w=o.map.get(l.el)||null,C=r.map.get(l.el)||null,I=w&&ae.get(w),D=C&&be.get(C);if(w&&!I||C&&!D)continue;let K=!(I&&D)&&st.has(l);if(!K&&!(I&&D&&kt(l)))continue;let pe=n==="local"?[[I,je],[D,Ot]]:[[D,Ot],[I,je]],[Te,Ve]=pe.find(([Ee])=>Ee),ke=Ln(Ve,Te.i);vt.has(ke)||vt.set(ke,[]),vt.get(ke).push({a:l,lt:w,rt:C,edited:K}),Pt.add(l)}if(A&&e.moveIn){let l=[[g,o,je,"local"],[x,r,Ot,"remote"]];n!=="local"&&l.reverse();for(let[w,C,I,D]of l)for(let K of w.atoms){let pe=me(K,C);if(!pe||Ft.has(pe))continue;Ft.add(pe);let Te=Ln(I,K.i);vt.has(Te)||vt.set(Te,[]),vt.get(Te).push({move:pe,side:D,sideEl:K.el})}}let Ut=l=>{let w=vt.get(l);if(w){if($e(l),w.some(C=>Qe(C.move?C.sideEl:C.a.el)))for(;Ae.length;)Ae.pop(),Re=Ae.length?Ae[Ae.length-1].el:null;for(let{a:C,lt:I,rt:D,edited:K,move:pe,side:Te,sideEl:Ve}of w){if(pe){let Ee=e.moveIn(pe,Te,Ve);Ee&&He(Ee);continue}et.add(C);let ke=xe(C.el,I,D);K&&(h({kind:"structure",el:ke,detail:"edit-beats-delete",base:C.el},{subject:C.el,deleted:I?"remote":"local"}),a.push({kind:"insert",el:ke,source:I?"local":"remote"})),He(ke)}}},_t=new Set,an=s.length>m;for(let l=0;l<Me;l++){let w=Je(l),I=!!w&&Qe((w.ab||w.al||w.ar).el)?[]:It[l]?[It[l],...Cn(l)]:Cn(l),D=0;for(;D<Ae.length&&D<I.length&&Ae[D].u===I[D];)D++;if(D<Ae.length)for($e(l);Ae.length>D;)Ae.pop(),Re=Ae.length?Ae[Ae.length-1].el:null;if(ln(l),Ut(l),I.length>Ae.length)for($e(l);Ae.length<I.length;)en(I[Ae.length]);if(W[l]===gt){if(at.has(l))continue;$e(l);let K=Ae.length;for(;K>0&&!Ae[K-1].u.block;)K--;if(K>0)for(an&&d.breakOut.set(l,Ae[K-1].el);Ae.length>=K;)Ae.pop(),Re=Ae.length?Ae[Ae.length-1].el:null;continue}if(w){$e(l);let K=yt.get(l),pe;if(K.dup){h({kind:"structure",el:null,detail:"both-moved",base:K.dup},{subject:K.dup});continue}if(K.moveIn){if(pe=e.moveIn(K.moveIn,K.side,K.sideEl),!pe)continue}else if(K.bk){let Te=K.bk;if(et.add(Te),Te===w.ab)pe=xe(Te.el,K.al.el,K.ar.el);else{let Ve=o.map.get(Te.el)||null,ke=r.map.get(Te.el)||null;pe=xe(Te.el,Ve,ke),(!Ve||!ke)&&h({kind:"structure",el:null,detail:"move-beats-delete",base:Te.el},{subject:Te.el,deleted:Ve?"remote":"local"}),a.push({kind:"move",el:pe,source:K.from})}}else K.al?(pe=te(K.al.el,"local"),K.ar&&(i.get(pe).remote=K.ar.el),a.push({kind:"insert",el:pe,source:K.ar?"both":"local"})):(pe=te(K.ar.el,"remote"),a.push({kind:"insert",el:pe,source:"remote"}));an&&d.atomOut.set(l,pe),He(pe);continue}Ge||(ct=l),Ge+=W[l]}if($e(Me),(dn.has(Me)||vt.has(Me))&&(Ae.length=0,Re=null,ln(Me),Ut(Me)),Me===0&&(g.placeholder||x.placeholder||f.placeholder)){let l=t.createElement("br");i.set(l,{base:f.placeholder,local:g.placeholder,remote:x.placeholder}),zt.push(l)}let bn=0,Uo=l=>{for(;bn>0&&X[bn-1].me>=l;)bn--;for(;bn<X.length&&X[bn].me<l;)bn++;let w=X[bn];if(!w)return X[X.length-1]||null;let C=X[bn+1];return w.me===l&&C&&C.ms===l?C:w},Zn=new Map,bo={},Pe=(l,w,C)=>{let I=Uo(l)||(C?bo:null);if(!I)return;let D=Zn.get(I)||{l:!1,r:!1};w!=="remote"&&(D.l=!0),w!=="local"&&(D.r=!0),Zn.set(I,D)},pt=l=>{if(l.conflict)return!0;let w=l.src==="local"?g.text:l.src==="remote"?x.text:"";for(let C=l.from;C<l.to;C++)if(w[C]!==co&&w[C]!==gt)return!0;return!1};for(let l of F)l.src!=="base"&&Pe(l.ms,l.conflict?"both":l.src,pt(l));for(let[l,w]of V)Ze[l]>=0&&Pe(Ze[l],w);for(let l of X.length?X:[bo]){let w=Zn.get(l);w&&a.push({kind:"text",node:l.node||null,source:w.l&&w.r?"both":w.l?"local":"remote"})}for(let l of nn){if(_e.has(l))continue;let w=!l.local&&!(A&&o.map.get(l.base)),C=!l.remote&&!(A&&r.map.get(l.base));!w&&!C||a.push({kind:"remove",source:w&&C?"both":w?"local":"remote",base:l.base})}let Mt=(l,w,C)=>{if(w<=l)return!1;for(let I=l;I<w;I++)if(C[I]>=0)return!1;return!0};for(let l of nn)for(let w of["local","remote"]){let C=l[w+"Mark"],I=l.baseMark;if(!C)continue;let D=w==="local"?dt:Se;if(!Mt(I.from,I.to,D.bTo)||!Mt(C.from,C.to,D.toB))continue;let K=(w==="local"?N:E).find(pe=>pe.ss<=C.from&&C.from<pe.se);K&&(K.be<=I.from||K.bs>=I.to)&&a.push({kind:"move",el:_e.get(l)||null,source:w})}let xt=l=>{let w=Tt.get(l.node.parentNode);return w?Xt(w):null};for(let l of g.nodes){let w=-1;for(let I=l.s;I<l.e;I++)if(je[I]>=0){w=je[I];break}let C;if(w>=0)C=Uo(w);else{let I=cn(l.s),D=xt(l);C=X.find(K=>K.u===D&&K.me>=I)||X.filter(K=>K.u===D).pop()}C&&C.local.push(l)}let mt=new Map,yn=X[X.length-1]||null,Vt=0;for(let l of g.nodes){let w=null;for(let C=l.s;C<=l.e;C++){let I=cn(C);for(;Vt>0&&X[Vt-1].me>=I;)Vt--;for(;Vt<X.length&&X[Vt].me<I;)Vt++;let D=pe=>pe&&I>=pe.ms&&I<=pe.me&&(I<pe.me||C===l.e||pe===w),K=D(X[Vt])?X[Vt]:D(X[Vt+1])?X[Vt+1]:X[Vt]||yn;if(!K)break;if(w===K){let pe=mt.get(K);pe[pe.length-1].to=C-l.s;continue}w=K,mt.has(K)||mt.set(K,[]),mt.get(K).push({node:l.node,from:C-l.s,to:C-l.s,flatStart:l.s})}}for(let l of X){let w=l.local,C=!1;for(let pe of w)for(let Te=pe.s;Te<pe.e&&!C;Te++)(je[Te]<l.ms||je[Te]>=l.me)&&(C=!0);i.set(l.node,{base:null,local:w.map(pe=>pe.node),remote:null,caret:mt.get(l)||[],partial:C});let I=l.ms,D=l.me-l.ms,K=pe=>{let Te=0,Ve=-1;for(let ke of w){let Ee=ke.e-ke.s;if(pe<=Te+Ee){Ve=ke.s+(pe-Te);break}Te+=Ee}return Ve<0&&(Ve=w.length?w[w.length-1].e:0),Math.max(0,Math.min(cn(Ve)-I,D))};K.flat=pe=>Math.max(0,Math.min(cn(pe)-I,D)),c.set(l.node,K)}function Rn(){if(!g.text.includes(gt))return[{flatLocal:g.text,localNodes:g.nodes,textNodes:X,lToM:je,mapLocal:cn}];let l=[],w=0,C=0;for(let I=0;I<=g.text.length;I++){if(I<g.text.length&&g.text[I]!==gt)continue;let D=w,K=I;if(K>D){let pe=[];for(;C<g.nodes.length&&g.nodes[C].e<=D;)C++;for(let Te=C;Te<g.nodes.length&&g.nodes[Te].s<K;Te++){let Ve=g.nodes[Te],ke=Math.max(Ve.s,D),Ee=Math.min(Ve.e,K);ke<Ee&&pe.push({node:Ve.node,s:ke-D,e:Ee-D})}l.push({flatLocal:g.text.slice(D,K),localNodes:pe,textNodes:X,lToM:je.subarray?je.subarray(D,K+1):je.slice(D,K+1),mapLocal:Te=>cn(D+Math.max(0,Math.min(Te,K-D)))})}w=I+1}return l}let Tn={...e,blocks:_t,ignored:l=>Vn.has(l)||(e.ignored?e.ignored(l):!1)},Gt=e.ignoreAttribute||(()=>!1),_o=Ns(En(zt,Tn),Gt)!==Ns(x,Gt);if(b.length){let l=w=>{let C=i.get(w);return C&&C.unchanged?C.remote:null};d.text=W,d.textNodes=X,d.out=En(zt,{...Tn,via:l})}return{nodes:zt,text:W,textNodes:X,localDiverged:_o,mapLocal:cn,conflicts:s.slice(m),granularity:We?"line":"word",segments:Rn(),localHunks:N,remoteHunks:E,lToM:je}}var Ac="http://www.w3.org/1999/xhtml";function Sc(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function tn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Ac}function Nc(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Jo(e,t){let n=e.getAttribute("src"),o=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(n){let r=n;try{let i=new URL(n,t);r=i.origin+i.pathname+i.search}catch{}return"script|src|"+o+"|"+r}return"script|inline|"+o+"|"+Sc(e.textContent.trim())}var Oc={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function lo(e,t=[],n=!1){if(!tn(e)||e.hasAttribute("src"))return null;let o=[Oc,...t];for(let r=0;r<o.length;r++){let i=o[r];if(!i.match(e))continue;if(!Nc(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let c=i.identity(e);return c==null||c===""?null:{key:r+":"+c,raw:c,recognizer:i}}return null}function Ls(e,t,n){let o=new Set,r=i=>{tn(i)&&!t(i)&&o.add(Jo(i,n))};r(e);for(let i of e.querySelectorAll("script"))r(i);return o}function To(e,t){let n=t.createElement("div");n.innerHTML="<script><\/script>";let o=n.firstChild;for(let r of e.attributes)o.setAttribute(r.name,r.value);return o.textContent=e.textContent,o}function Rs(e,t,n){let o=[],r=[],i=new Map,c=n.trackRecovery?new Set:null,s=Array.from(e.querySelectorAll("script"));tn(e)&&s.unshift(e);for(let a of s){if(!tn(a)||n.ignored(a)||n.skip.has(a)||t.has(Jo(a,n.baseURI)))continue;let m=a.ownerDocument.createElement("script");for(let h of a.attributes)m.setAttribute(h.name,h.value);if(m.textContent=a.textContent,n.beforeNodeAdded(m)===!1){c?.add(a);continue}m.hasAttribute("src")&&r.push(new Promise(h=>{m.addEventListener("load",()=>h()),m.addEventListener("error",()=>h())})),a.replaceWith(m),i.set(a,m),n.afterNodeAdded(m),o.push(m)}return{executed:o,loads:r,swapped:i,vetoed:c}}function vc(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function Mc(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function Ps(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Jo(e,t);if(n==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+Mc(o,t):e.outerHTML}if(n==="META"){for(let o of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(o))return"meta|"+o+"="+e.getAttribute(o);return e.outerHTML}return n==="STYLE"?"style|"+vc(e.textContent):e.outerHTML}function Cr(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
|
|
5
|
+
`;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);if(n===-1)return e.length;t=n+2;continue}return t}}function Ec(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var Ic=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Cc=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Lr(e){try{return JSON.parse(e)}catch{return JSON.parse(Lc(e))}}function Lc(e){let t="",n=0,o=(r,i)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${i}`)};for(;n<e.length&&(n=Cr(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let s=Cr(e,n+1);if(e[s]==="}"||e[s]==="]"){n++;continue}t+=r,n++;continue}if(r==='"'||r==="'"){let s=n+1;for(;s<e.length&&e[s]!==r;)e[s]==="\\"&&s++,s++;s>=e.length&&o("unterminated string",n);let a=e.slice(n+1,s);r==="'"&&(a=Ec(a)),t+='"'+a+'"',n=s+1;continue}let i=n;for(;i<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[i]);)i++;i===n&&o("unexpected character "+JSON.stringify(r),n);let c=e.slice(n,i);if(c==="true"||c==="false"||c==="null"||Ic.test(c)){t+=c,n=i;continue}if(Cc.test(c)){if(e[Cr(e,i)]===":"){t+='"'+c+'"',n=i;continue}o("unquoted value "+JSON.stringify(c),n)}o("invalid token "+JSON.stringify(c),n)}return t}var Dt=Symbol("hyper-morph-json-merge:missing"),js=["id","_id","uuid","key","slug","code","name"];function ao(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ao(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rc(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function Hn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Hn(e[n],t[n]))return!1;return!0}if(ao(e)&&ao(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Ao(t,o)||!Hn(e[o],t[o]))return!1;return!0}return!1}function Ds(e,t,n,o){return Hn(t,n)?t:Hn(t,e)?n:Hn(n,e)?t:ao(t)&&ao(n)?Pc(ao(e)?e:{},t,n,o):Array.isArray(t)&&Array.isArray(n)?Bc(Array.isArray(e)?e:[],t,n,o):n}function Hs(e,t,n,o){return t===Dt&&n===Dt?Dt:t===Dt?e===Dt?n:Hn(n,e)?Dt:n:n===Dt?e===Dt?t:Dt:Ds(e,t,n,o)}function Pc(e,t,n,o){let r={},i=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let c of i){let s=Hs(Ao(e,c)?e[c]:Dt,Ao(t,c)?t[c]:Dt,Ao(n,c)?n[c]:Dt,o);s!==Dt&&Rc(r,c,s)}return r}function jc(e){return e===null||typeof e!="object"}function Xo(e){return typeof e+":"+String(e)}function Dc(e,t){for(let n of t){let o=new Set;for(let r of n){if(!Ao(r,e))return!1;let i=r[e];if(typeof i!="string"&&typeof i!="number")return!1;let c=Xo(i);if(o.has(c))return!1;o.add(c)}}return!0}function Hc(e,t,n,o){let r=[e,t,n],i=!0;for(let c of r)for(let s of c)ao(s)||(i=!1);if(i){for(let c of o.keyCandidates)if(Dc(c,r))return{kind:"keyed",field:c};return null}for(let c of r){let s=new Set;for(let a of c){if(!jc(a))return null;let m=Xo(a);if(s.has(m))return null;s.add(m)}}return{kind:"self"}}function Bc(e,t,n,o){let r=Hc(e,t,n,o);if(!r)return n;let i=r.kind==="self"?Xo:A=>Xo(A[r.field]),c=A=>{let S=new Map;for(let L of A)S.set(i(L),L);return S},s=c(e),a=c(t),m=c(n),h=new Map,d=new Set([...s.keys(),...a.keys(),...m.keys()]);for(let A of d){let S=Hs(s.has(A)?s.get(A):Dt,a.has(A)?a.get(A):Dt,m.has(A)?m.get(A):Dt,o);S!==Dt&&h.set(A,S)}let b=[];for(let A of n){let S=i(A);h.has(S)&&b.push(S)}for(let A=0;A<t.length;A++){let S=i(t[A]);if(!h.has(S)||b.includes(S))continue;let L=0;for(let f=A-1;f>=0;f--){let g=b.indexOf(i(t[f]));if(g!==-1){L=g+1;break}}b.splice(L,0,S)}return b.map(A=>h.get(A))}function Bs(e,t,n,o={}){let r=o.keyCandidates?[...o.keyCandidates,...js]:js;return Ds(e===void 0?Dt:e,t,n,{keyCandidates:r})}function Rr(e,t,n,o={}){let r=o.parse||Lr,i=[],c=(d,b)=>{if(typeof d!="string")return Dt;try{return r(d)}catch(A){return i.push(`${b} side is not valid JSON (${A.message})`),Dt}},s=c(t,"local"),a=c(n,"remote");if(s===Dt)return{text:n,warnings:i};if(a===Dt)return{text:t,warnings:i};let m=c(e,"base"),h=Bs(m===Dt?void 0:m,s,a,o);return Hn(h,a)?{text:n,warnings:i}:Hn(h,s)?{text:t,warnings:i}:{text:JSON.stringify(h,null,2),warnings:i}}var Us=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Kn(e){if(!e)return!1;let{startContainer:t,startOffset:n,endContainer:o,endOffset:r}=e;if(!t||!o||!Number.isInteger(n)||!Number.isInteger(r)||n<0||r<0||n>Us(t)||r>Us(o)||t.getRootNode()!==o.getRootNode())return!1;let i=t.ownerDocument.createRange();return i.setStart(t,n),i.setEnd(o,r),i.startContainer===t&&i.startOffset===n}function Bn(e,t,n={}){if(!Kn(e))return null;let{startContainer:o,startOffset:r,endContainer:i,endOffset:c}=e;if(o===i&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,c);if(o===i&&r===c)return"";let s=new Set;for(let f=o;f;f=f.parentNode)s.add(f);let a=i;for(;!s.has(a);)a=a.parentNode;let m=(f,g)=>{let x=a.ownerDocument.createRange(),Q=a.ownerDocument.createRange();return x.setStart(f[0],f[1]),x.collapse(!0),Q.setStart(g[0],g[1]),Q.collapse(!0),x.compareBoundaryPoints(0,Q)},h=(f,g=!1)=>[f.parentNode,Array.prototype.indexOf.call(f.parentNode.childNodes,f)+Number(g)],d=[],b;if(t==="plain"){b="";let f=g=>{if(g.nodeType===3||g.nodeType===8){let x=b.length;b+=g.nodeValue,d.push({s:x,e:b.length,a:[g,0],b:[g,g.nodeValue.length],node:g})}else for(let x of g.childNodes)f(x)};f(a)}else{let f=n.blocks;if(!f){f=new Set;let x=Q=>{Q!==a&&Q.nodeType===1&&Er.has(Q.tagName)&&f.add(Q);for(let se of Q.childNodes)x(se)};x(a)}let g=En(Array.from(a.childNodes),{blocks:f,atomize:x=>!!n.atoms?.has(x),ignored:n.ignored});b=g.text;for(let x of g.nodes)d.push({s:x.s,e:x.e,a:[x.node,0],b:[x.node,x.e-x.s],node:x.node});for(let x of g.atoms)d.push({s:x.i,e:x.i+1,a:h(x.el),b:h(x.el,!0)});for(let x=0;x<g.text.length;x++){if(g.text[x]!==gt)continue;let Q=g.marks.find(le=>le.block&&le.to===x+1),se=g.marks.find(le=>le.block&&le.from===x+1);if(Q)d.push({s:x,e:x+1,a:[Q.el,Q.el.childNodes.length],b:h(Q.el,!0)});else if(se)d.push({s:x,e:x+1,a:h(se.el),b:[se.el,0]});else return null}}d.sort((f,g)=>f.s-g.s);let A=f=>{if(f[0].nodeType===3||f[0].nodeType===8){let x=d.find(Q=>Q.node===f[0]);return x?x.s+f[1]:null}let g=0;for(let x of d){if(m(f,x.a)<=0)return x.s;if(m(f,x.b)<0)return null;g=x.e}return g},S=A([o,r]),L=A([i,c]);return S!==null&&L!==null&&S<=L?b.slice(S,L):null}function Fn(e,t){let n=e;for(let o of t.path)if(n=o==="content"?n?.content:n?.childNodes[o],!n)return null;return[n,t.offset]}function _s(e,t){if(!e||!t)return null;let n=Fn(e,t.start),o=Fn(e,t.end);return n&&o?{startContainer:n[0],startOffset:n[1],endContainer:o[0],endOffset:o[1]}:null}var Vs=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ws(e,t,n){if(!t)return;let o=new Map,r=new Map,i=s=>{if(!s)return null;if(r.has(s))return r.get(s);let m=s.local.map(h=>Fn(t.localRoot,{path:h,offset:0})?.[0]).map(h=>h&&n(h)).filter(Boolean).map(h=>({node:h,parent:h.parentNode,previous:h.previousSibling,next:h.nextSibling,fragment:Vs(h)}));return r.set(s,m),m},c=s=>{let a=_s(t.localRoot,s);if(!a)return null;let m=n(a.startContainer),h=n(a.endContainer);if(!m||!h)return null;let d={...a,startContainer:m,endContainer:h};return Kn(d)?d:null};for(let s of e){let a=s.recovery;if(o.has(a))continue;let m={subject:i(a.subject),span:null,scope:null,touched:new Set};if(a.text){m.span=c(a.text.local.span),m.scope=c(a.text.local.scope);let h=m.span;if(h){let d=h.startContainer.ownerDocument.createRange();d.setStart(h.startContainer,h.startOffset),d.setEnd(h.endContainer,h.endOffset);let b=A=>{if(d.intersectsNode(A)){m.touched.add(A);for(let S of A.childNodes)b(S)}};b(d.commonAncestorContainer)}}if(a.structure){for(let h of[a.structure.localPlacement])h&&(i(h.parent),h.before.forEach(i),h.after.forEach(i));for(let h of a.structure.localOrder||[])i(h)}o.set(a,m)}t.localState={states:o,refs:r}}function $s(e,t,n,o){let r=n.localState?.states.get(e);if(!r)return!1;let i=s=>{let a=s.node;if(!o(a)||a.parentNode!==s.parent)return!1;let m=h=>Array.prototype.indexOf.call(a.parentNode.childNodes,h);return!(s.previous&&o(s.previous)&&s.previous.parentNode===a.parentNode&&m(s.previous)>=m(a)||s.next&&o(s.next)&&s.next.parentNode===a.parentNode&&m(s.next)<=m(a))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!r.subject.length||!r.subject.every(i))return!1;if(e.text){let s=e.text.local,a=m=>m&&o(m.startContainer)&&o(m.endContainer);return a(r.span)&&a(r.scope)&&Bn(r.scope,e.text.encoding)===s.text&&Bn(r.span,e.text.encoding)===s.text.slice(s.start,s.end)}if(e.attribute){let s=e.attribute,a=r.subject[0].node;return(s.namespaceURI?a.getAttributeNS(s.namespaceURI,s.localName):a.getAttribute(s.qualifiedName))===t.local}let c=e.structure;if(c.localOrder){let s=-1,a=null;for(let m of c.localOrder){let h=n.localState.refs.get(m)?.[0]?.node;if(!h||!o(h)||a&&h.parentNode!==a)return!1;let d=Array.prototype.indexOf.call(h.parentNode.childNodes,h);if(d<=s)return!1;a=h.parentNode,s=d}return!0}return c.localAction==="moved"||r.subject.every(s=>Vs(s.node)===s.fragment)}var Uc=1,Jt=e=>!!e&&e.nodeType===1,Qo=e=>Jt(e)&&e.tagName==="TEMPLATE"&&!!e.content;function zn(e,t=null,n=null){let o=new Map,r=new Map,i=h=>{if(!t){t=new WeakMap;let d=[e];for(;d.length;){let b=d.pop();Qo(b)&&(t.set(b.content,b),d.push(b.content));for(let A=b.firstChild;A;A=A.nextSibling)A.nodeType===1&&d.push(A)}}return t.get(h)||null},c=(h,d)=>{let b=r.get(h);if(!b){b=new Map;let A=0;for(let S=h.firstChild;S;S=S.nextSibling)b.set(S,A++);r.set(h,b)}return b.get(d)},s=h=>{if(!h)return null;if(n&&n.has(h))return s(n.get(h));if(h===e)return[];let d=o.get(h);if(d!==void 0)return d;let b=h.parentNode,A=null;if(b&&b.nodeType===11){let S=i(b),L=S?s(S):null;L&&(A=L.concat(["content",c(b,h)]))}else if(b){let S=s(b);S&&(A=S.concat([c(b,h)]))}return o.set(h,A),A};return{root:e,pathOf:s,logicalParent:h=>{let d=h.parentNode;return d&&d.nodeType===11?i(d):d},indexIn:c,containerPath:h=>{if(h.nodeType===11){let b=i(h),A=s(b);return A?A.concat(["content"]):null}let d=s(h);return d&&Qo(h)?d.concat(["content"]):d},ownerOf:i}}var wn=e=>Qo(e)?e.content:e;function qs(e){let{L:t,R:n,unitsOf:o,provenance:r,policy:i}=e,c=[];return{note:(h,d)=>{c.push([h,d])},finish:h=>c.length?m(h):null};function m(h){let d={base:zn(e.roots.base),local:zn(e.roots.local),remote:zn(e.roots.remote)},b=y=>y==="local"?t:n,A=(y,T)=>{if(!T)return null;if(y.map.has(T))return y.map.get(T);let P=[],p=Jt(T)?d.base.logicalParent(T):T.parent;for(;p&&!y.map.has(p);p=d.base.logicalParent(p))P.push(p);if(!p||!y.identical.has(p))return null;let k=y.map.get(p);for(let R=P.length-1;R>=0&&k;R--)k=wn(k).childNodes[d.base.indexIn(P[R].parentNode,P[R])];return k?Jt(T)?wn(k).childNodes[d.base.indexIn(T.parentNode,T)]||null:o(k)[o(T.parent).indexOf(T)]||null:null},S=new Map,L=new Map,f=new WeakMap,g=0,x=(y,T)=>{let P=S.get(y);P||S.set(y,P=[]),P.push(T)};(function y(T){L.set(T,g++);let P=r.get(T);if(P&&!P.pinned){for(let p of[P.base,P.local,P.remote])if(p)if(Array.isArray(p))for(let k of p)x(k,T);else x(p,T)}if(Qo(T)){f.set(T.content,T);for(let p=T.content.firstChild;p;p=p.nextSibling)y(p)}for(let p=T.firstChild;p;p=p.nextSibling)y(p)})(h);let Q=new Map;d.out=zn(h,f,Q);let se={refs:new Map,spans:new Map,anchors:new Map,via:Q,outOwners:f,outRoot:h,localRoot:e.roots.local},le=y=>Jt(y)?[y]:y.nodes,q=(y,T)=>{let P=d[T].logicalParent(y);if(!P)return null;for(let p of o(P))if(!Jt(p)&&p.nodes.includes(y))return p;return null},z=(y,T)=>y==null?null:Array.isArray(y)?y.length?q(y[0],T):null:y,ce=y=>{let T=new Set,P=[];for(let p of y)for(let k of S.get(p)||[])T.has(k)||(T.add(k),P.push(k));return P.sort((p,k)=>L.get(p)-L.get(k))},xe=new Map,te=y=>{let T=y.b||y.l||y.r,P=xe.get(T);if(P)return P;let p=[];for(let k of[y.b,y.l,y.r])k&&p.push(...le(k));return P=ce(p),xe.set(T,P),P},J=y=>({b:y,l:A(t,y),r:A(n,y)}),Ce=(y,T)=>{let P=b(T).reverse.get(y);if(P)return J(P);for(let p of ce(le(y))){let k=r.get(p);if(k&&!k.base&&k.local&&k.remote)return{b:null,l:z(k.local,"local"),r:z(k.remote,"remote")}}return T==="local"?{b:null,l:y,r:null}:{b:null,l:null,r:y}},we=new Map,ne=y=>{let T=r.get(y);if(!T||T.pinned)return null;let P=z(T.base,"base");if(P)return J(P);let p=z(T.local,"local"),k=z(T.remote,"remote");if(p){let R=t.reverse.get(p);if(R)return J(R)}if(k){let R=n.reverse.get(k);if(R)return J(R)}return p||k?{b:null,l:p,r:k}:null},_=y=>(we.has(y)||we.set(y,ne(y)),we.get(y)),ye=(y,T)=>Jt(y)?d[T].logicalParent(y):y.parent,ge=new Map,Oe=new Map,Be=(y,T)=>(Jt(y)?[d[T].pathOf(y)]:y.nodes.map(P=>d[T].pathOf(P))).filter(Boolean),We=y=>{let T=y.b||y.l||y.r,P=y.b?"base":y.l?"local":"remote",p=Oe.get(T);if(p)return p;let k=!Jt(T),R=Be(T,P)[0],$=`${P[0]}:${JSON.stringify(R===void 0?null:R)}${k?":run":""}`,H=ge.get($);if(H)return Oe.set(T,H),H;let F=te(y);return H={key:$,nodeType:Jt(T)?1:T.kind==="comment"?8:3,base:y.b?Be(y.b,"base"):[],local:y.l?Be(y.l,"local"):[],remote:y.r?Be(y.r,"remote"):[],merged:F.map(N=>d.out.pathOf(N)).filter(Boolean),live:[]},ge.set($,H),Oe.set(T,H),se.refs.set(H,F),H},rt={base:new Map,local:new Map,remote:new Map},re=new Map,ut=(y,T)=>{let P=ye(y,T);if(!P||P.nodeType!==1)return null;let p=rt[T].get(P);if(!p){let R=o(P),$=H=>We(T==="base"?J(H):Ce(H,T));p={parent:$(P),refs:R.map($),index:new Map(R.map((H,F)=>[H,F]))},rt[T].set(P,p)}let k=p.index.get(y)??-1;return{parent:p.parent,before:p.refs.slice(k+1),after:p.refs.slice(0,Math.max(0,k)).reverse()}},dt=y=>{let T=y.parentNode;if(!T)return null;let P=re.get(T);if(!P){let k=T.nodeType===11?f.get(T):T,R=k&&k.nodeType===1?_(k):null;if(!R)return null;let $=[],H=[],F=new Map;for(let E of T.childNodes){let G=_(E),he=G&&We(G),ve=$.length,u=$.length-1;he&&he!==$[u]&&($.push(he),u++);let v={ref:he,group:u,after:ve};H.push(v),F.set(E,v)}let N=$.length;for(let E=H.length-1;E>=0;E--){let G=H[E];G.before=N,G.ref&&(N=G.group)}P={parent:We(R),refs:$,index:F},re.set(T,P)}let p=P.index.get(y);return{parent:P.parent,before:P.refs.slice(p.before),after:P.refs.slice(0,p.after).reverse()}},Se=y=>Jt(y)?y.outerHTML:y.value,O=y=>Jt(y)?"element":y.kind==="comment"?"comment":"text",B=(y,T)=>({path:y,offset:T}),ae=(y,T,P)=>{if(!y)return null;let p=d[P],k=0;if(T){let R=Jt(T)?T:T.nodes[T.nodes.length-1];R.parentNode&&(k=p.indexIn(R.parentNode,R)+1)}return B(p.containerPath(y),k)},be=(y,T)=>{let P=ye(y,"base"),p=P?A(b(T),P):null;if(!Jt(p))return null;let k=o(P),R=null;for(let $=k.indexOf(y)-1;$>=0&&!R;$--){let H=A(b(T),k[$]);H&&ye(H,T)===p&&(R=H)}return ae(p,R,T)},de=(y,T,P,p)=>{let k=d[p],R=0;for(let $=0;$<y.nodes.length;$++){let H=y.nodes[$],F=H.nodeValue.length,N=$===y.nodes.length-1;if((P==="start"?T<R+F:T<=R+F)||N)return B(k.pathOf(H),Math.max(0,Math.min(T-R,F)));R+=F}return null},ze=(y,T)=>{let P=d[T],p=y.firstChild,k=y.lastChild;return p&&p.nodeType===3&&k.nodeType===3?{start:B(P.pathOf(p),0),end:B(P.pathOf(k),k.nodeValue.length)}:{start:B(P.pathOf(y),0),end:B(P.pathOf(y),y.childNodes.length)}},De=(y,T,P)=>{for(let $ of y.nodes)if(P==="start"?$.s<=T&&T<$.e:$.s<T&&T<=$.e)return{kind:"text",node:$.node,offset:T-$.s};let p=P==="start"?T:T-1,k=()=>{for(let $ of y.nodes)if($.s===T||$.e===T)return{kind:"text",node:$.node,offset:T-$.s};return null},R=y.atomAt.get(p);if(R)return{kind:P==="start"?"before":"after",node:R.el};if(y.text[p]===gt){let $=y.marks.find(F=>F.block&&F.to===p+1);if($)return P==="start"?{kind:"end",node:$.el}:{kind:"after",node:$.el};let H=y.marks.find(F=>F.block&&F.from===p+1);if(H)return P==="start"?{kind:"before",node:H.el}:{kind:"startOf",node:H.el}}return k()},Qe=(y,T)=>De(y,T,"end")||De(y,T,"start"),st=(y,T)=>{switch(T.kind){case"text":return B(y.pathOf(T.node),T.offset);case"end":return B(y.containerPath(T.node),wn(T.node).childNodes.length);case"startOf":return B(y.containerPath(T.node),0);default:{let P=T.node.parentNode;return B(y.containerPath(P),y.indexIn(P,T.node)+(T.kind==="after"?1:0))}}},wt=(y,T,P,p,k)=>{let R=De(y,T,P);return R?st(d[p],R):k()},bt=(y,T,P,p)=>{let k=y.textNodes.map(N=>({s:N.ms,e:N.me,start:{kind:"text",node:N.node,offset:0},end:{kind:"text",node:N.node,offset:N.me-N.ms}}));for(let[N,E]of y.atomOut)k.push({s:N,e:N+1,start:{kind:"before",node:E},end:{kind:"after",node:E}});for(let[N,E]of y.breakOut)k.push({s:N,e:N+1,start:{kind:"end",node:E},end:{kind:"after",node:E}});for(let N of k)if(N.start.kind==="text"&&N.s<T&&T<N.e)return{kind:"text",node:N.start.node,offset:T-N.s};if(P!=="empty"){let N=k.find(E=>P==="start"?E.s===T:E.e===T);if(N)return P==="start"?N.start:N.end}let R=k.find(N=>N.e===T);if(R)return R.end;let $=k.find(N=>N.s===T);if($)return $.start;let H=null,F=null;for(let N of k)N.e<=T&&(!H||N.e>H.e)&&(H=N),N.s>=T&&(!F||N.s<F.s)&&(F=N);return H?H.end:F?F.start:p()},Tt=(y,T)=>{if(!T)return null;if(T.kind==="text"){let k=y.nodes.find(R=>R.node===T.node);return k?k.s+Math.min(T.offset,k.e-k.s):null}let P=y.atoms.find(k=>k.el===T.node);if(P)return T.kind==="after"?P.i+1:P.i;let p=y.marks.find(k=>k.el===T.node);return p?T.kind==="before"&&p.block&&y.text[p.from-1]===gt&&!y.marks.some(k=>k.block&&k.to===p.from)?p.from-1:T.kind==="startOf"||T.kind==="before"?p.from:T.kind==="end"&&p.block?p.to-1:p.to:null},nn=(y,T,P,p)=>{for(let H of y.nodes)if(P==="start"?H.s<=T&&T<H.e:H.s<T&&T<=H.e)return{kind:"text",node:H.node,offset:T-H.s};let k=P==="start"?T:T-1;if(!y.atomAt.has(k)&&y.text[k]!==gt){for(let H of y.nodes)if(H.s===T||H.e===T)return{kind:"text",node:H.node,offset:T-H.s}}let R=y.atomAt.get(k);if(R)return{kind:P==="start"?"before":"after",node:R.el};if(y.text[k]===gt){let H=y.marks.find(N=>N.block&&N.to===k+1);if(H)return P==="start"?{kind:"end",node:H.el}:{kind:"after",node:H.el};let F=y.marks.find(N=>N.block&&N.from===k+1);if(F)return P==="start"?{kind:"before",node:F.el}:{kind:"startOf",node:F.el}}let $=y.marks.find(H=>H.block&&H.from===T);return $?{kind:"startOf",node:$.el}:p?{kind:P==="start"?"startOf":"end",node:p}:null},Fe=y=>{if(!y)return null;if(y.kind==="wholeStart"||y.kind==="wholeEnd"){let T=Qt(y.node);return y.kind==="wholeStart"?T.start:T.end}return st(d.out,y)},Qt=y=>{let T=y.firstChild,P=y.lastChild;return T&&T.nodeType===3&&P.nodeType===3?{start:B(d.out.pathOf(T),0),end:B(d.out.pathOf(P),P.nodeValue.length)}:{start:B(d.out.pathOf(y),0),end:B(d.out.pathOf(y),y.childNodes.length)}},Xt=y=>{let T=ye(y,"base"),P=T?te(J(T))[0]:null;if(!P)return null;let p=wn(P),k=o(T);for(let R=k.indexOf(y)-1;R>=0;R--){let $=te(J(k[R])).filter(H=>H.parentNode===p);if($.length)return{kind:"after",node:$[$.length-1]}}return{kind:"startOf",node:P}},Bt=(y,T,P,p,k,R)=>({text:y,start:T,end:P,fragment:p,span:k,scope:R}),Et=(y,T,P,p,k)=>Bt(y,T,P,y.slice(T,P),p,k),Lt=(y,T,P,p,k)=>(se.spans.set(y,{start:T,end:P,scopeStart:p,scopeEnd:k}),y),sn=new Map,M=new Map,Z=(y,T,P)=>{let p=`text:${y.key}:${T}:${P}`,k=M.get(p)||0;return M.set(p,k+1),`${p}:${k}`},ee=(y,T)=>{let P,p,k,R="plain",$,H,F,N,E,G=(u,v,j,U,V)=>{if(!u){let W=be(V,U);return Et("",0,0,{start:W,end:W},{start:W,end:W})}return Et(u.value,v,j,{start:de(u,v,v===j?"end":"start",U),end:de(u,j,"end",U)},{start:de(u,0,"start",U),end:de(u,u.value.length,"end",U)})};if(T.site==="run"){let{bRun:u,lRun:v,rRun:j,node:U,c:V}=T;P=J(u),p=V.bs,k=V.be,$=G(u,V.bs,V.be,"base",u),H=G(v,V.ls,V.le,"local",u),F=G(j,V.rs,V.re,"remote",u);let W=U?U.nodeValue:"",Y=ie=>U?{kind:"text",node:U,offset:ie}:Xt(u);N=Lt(Et(W,V.ms,V.me,{start:Fe(Y(V.ms)),end:Fe(Y(V.me))},{start:Fe(Y(0)),end:Fe(Y(W.length))}),Y(V.ms),Y(V.me),Y(0),Y(W.length)),E=U||(Xt(u)||{}).node||null}else if(T.site==="whole"){let u=T.el,v=r.get(u);P=J(v.base),p=0,k=y.base.length;let j=(V,W,Y)=>{let ie=ze(W,Y);return Et(V,0,V.length,ie,ie)};$=j(y.base,v.base,"base"),H=j(y.local,v.local,"local"),F=j(y.remote,v.remote,"remote");let U=Qt(u);N=Lt(Et(y.resolved,0,y.resolved.length,U,U),{kind:"wholeStart",node:u},{kind:"wholeEnd",node:u},{kind:"wholeStart",node:u},{kind:"wholeEnd",node:u}),E=u}else if(T.site==="comment"){let{bRun:u,lRun:v,rRun:j,node:U}=T;P=J(u),p=0,k=y.base.length;let V=(Ne,Le)=>{if(!Ne){let je=be(u,Le);return Et("",0,0,{start:je,end:je},{start:je,end:je})}let Me=Ne.nodes[0],Ze={start:B(d[Le].pathOf(Me),0),end:B(d[Le].pathOf(Me),Ne.value.length)};return Et(Ne.value,0,Ne.value.length,Ze,Ze)};$=V(u,"base"),H=V(v,"local"),F=V(j,"remote");let W=y.resolved,Y=Ne=>U?{kind:"text",node:U,offset:Ne}:Xt(u),ie={start:Fe(Y(0)),end:Fe(Y(W.length))};N=Lt(Et(W,0,W.length,ie,ie),Y(0),Y(W.length),Y(0),Y(W.length)),E=U||(Xt(u)||{}).node||null}else{let{fb:u,fl:v,fr:j,scope:U}=T,V=T.merged;R="html",P=U.base?J(U.base):Ce(U.local,"local"),p=y.bs,k=y.be;let W=at=>{let St=U[at];for(let At=U.at-1;At>=0;At--){let Ht=U.units[At],Zt=at==="base"?Ht:A(b(at),Ht);if(Zt&&ye(Zt,at)===St)return Zt}return null},Y=at=>()=>ae(U[at],W(at),at),ie=(at,St,At,Ht,Zt)=>{let un=He=>He?st(d[Zt],He):Y(Zt)(),In=St===At?Qe(at,St):De(at,St,"start"),Cn=St===At?Qe(at,St):De(at,At,"end"),xn=un(In),cn={start:xn,end:St===At?xn:un(Cn)},zt=T.full?T.full(Zt):null;if(!zt)return Bt(at.text,St,At,Ht,cn,{start:un(De(at,0,"start")),end:un(De(at,at.text.length,"end"))});let X=In?Tt(zt,In):null,Re=Cn?Tt(zt,Cn):null,Ae=X===null?0:X,Ge=Math.max(Ae,Re===null?zt.text.length:Re),ct=un(De(zt,0,"start"));return Bt(zt.text,Ae,Ge,io(zt,Ae,Ge),cn,{start:ct,end:zt.text.length?un(De(zt,zt.text.length,"end")):ct})};$=T.synthetic?null:ie(u,y.bs,y.be,y.base,"base"),H=ie(v,y.lss,y.lse,y.local,"local"),F=ie(j,y.rss,y.rse,y.remote,"remote");let[Ne,Le]=y.range||[0,0],Me=V.out,Ze=()=>{let at=wn(V.node);for(let St=U.at-1;St>=0;St--){let At=te(J(U.units[St])).filter(Ht=>Ht.parentNode===at);if(At.length)return{kind:"after",node:At[At.length-1]}}for(let St=U.at;St<U.units.length;St++){let At=te(J(U.units[St])).filter(Ht=>Ht.parentNode===at);if(At.length)return{kind:"before",node:At[0]}}return{kind:"startOf",node:V.node}};if(Me.via)for(let[at,St]of Me.via)Q.set(at,St);let je=bt(V,Ne,Ne===Le?"empty":"start",Ze),Ot=Ne===Le?je:bt(V,Le,"end",Ze),Ue=Me.text.length?nn(Me,0,"start",V.node):Ze(),ht=Me.text.length?nn(Me,Me.text.length,"end",V.node):Ue,it=Tt(Me,je),Kt=Tt(Me,Ot),Rt=it===null?0:it,qt=Math.max(Rt,Kt===null?Me.text.length:Kt);N=Lt(Bt(Me.text,Rt,qt,io(Me,Rt,qt),{start:Fe(je),end:Fe(Ot)},{start:Fe(Ue),end:Fe(ht)}),je,Ot,Ue,ht);let It=se.spans.get(N);if(It.flat=Me,!Me.text.length){let at=Fe(Ue),St=Fn(h,at),At=St[0],Ht=St[1];It.empty={parent:At.nodeType===11?f.get(At):At,previous:At.childNodes[Ht-1]||null,next:At.childNodes[Ht]||null}}E=je?je.node:V.node}let he=We(P),ve=(T.site==="whole"||T.site==="comment"||i!=="both")&&y.resolved!==y.local;return{key:T.site==="comment"&&sn.get(P.b||P.l||P.r)||Z(he,p,k),subject:he,localLost:ve,anchor:E,text:{encoding:R,base:$,local:H,remote:F,merged:N,liveSpan:null,liveScope:null}}},ue=(y,T)=>{let P=_(T.el),p=We(P),k=T.sample;return{key:`attr:${p.key}:${k.namespaceURI||""}:${k.localName}`,subject:p,localLost:y.resolved!==y.local,anchor:T.el,attribute:{namespaceURI:k.namespaceURI||null,localName:k.localName,qualifiedName:k.name}}},oe=(y,T)=>{let P=y.detail,p=T.unit||J(T.subject),k=We(p),R=se.refs.get(k),$=p.l?ut(p.l,"local"):null,H=p.r?ut(p.r,"remote"):null,F=R.length?dt(R[0]):null,N,E,G,he=null,ve=null,u=T.deleted;switch(P){case"both-reordered":{N=E="reordered";let v=new Set(T.rKept),j=T.lKept.filter(ie=>v.has(ie)&&te(J(ie)).length),U=ie=>L.get(te(J(ie))[0]);he=j.map(ie=>We(J(ie))),ve=j.slice().sort((ie,Ne)=>U(ie)-U(Ne)).map(ie=>We(J(ie)));let V=ie=>!Jt(ie)&&ie.kind!=="comment"&&ie.nodes.every(Ne=>!/[^\t\n\f\r ]/.test(Ne.data)),W=j.filter(ie=>!V(ie)),Y=W.slice().sort((ie,Ne)=>U(ie)-U(Ne));G=W.some((ie,Ne)=>ie!==Y[Ne]);break}case"both-moved":N=E="moved",G=!$||!R.some(v=>{let j=v===R[0]?F:dt(v);return j&&j.parent===$.parent});break;case"edit-beats-delete":N=u==="local"?"deleted":"edited",E=u==="remote"?"deleted":"edited",G=u==="local";break;case"move-beats-delete":N=u==="local"?"deleted":"moved",E=u==="remote"?"deleted":"moved",G=u==="local";break;default:N=E="inserted",G=T.localLost}return{key:`structure:${k.key}:${P}`,subject:k,localLost:G,anchor:R[0]||null,structure:{localAction:N,remoteAction:E,localPlacement:$,remotePlacement:H,mergedPlacement:F,localOrder:he,mergedOrder:ve,localFragment:P==="both-reordered"||!p.l?null:Se(p.l),fragmentKind:O(p.b||p.l||p.r)}}};for(let[y,T]of c){if(y.kind!=="structure")continue;let P=T.unit||J(T.subject),p=P.b||P.l||P.r;!Jt(p)&&p.kind==="comment"&&sn.set(p,`structure:${We(P).key}:${y.detail}`)}let fe=new Map;for(let[y,T]of c){if(y.kind==="structure"){let R=We(T.unit||J(T.subject)),$=`structure:${R.key}:${y.detail}`,H=fe.get($);if(H&&H.structure){y.recovery=H;let F=se.refs.get(R);y.el==null&&F.length&&(y.el=Jt(F[0])?F[0]:d.out.logicalParent(F[0]));continue}}let P=y.kind==="text"?ee(y,T):y.kind==="attr"?ue(y,T):oe(y,T),p=fe.get(P.key);p||(p={version:Uc,key:P.key,localLost:P.localLost,subject:P.subject,applied:!1,unavailable:null},fe.set(P.key,p),se.anchors.set(p,P.anchor)),P.text&&(p.text=P.text),P.attribute&&(p.attribute=P.attribute),P.structure&&(p.structure=P.structure),P.text&&(p.localLost=P.localLost),y.recovery=p;let k=se.refs.get(P.subject);y.kind==="structure"&&y.el==null&&k.length&&(y.el=Jt(k[0])?k[0]:d.out.logicalParent(k[0])),y.kind==="text"&&y.node==null&&k.length&&P.subject.nodeType===8&&(y.node=k[0])}return se}}function Fs(e,t,n){if(!t)return;let{lookup:o,vetoed:r,vetoedAttrs:i,liveAttr:c}=n,s=n.ignored||(()=>!1),a=zn(n.liveRoot),m=ne=>!!ne&&a.containerPath(ne)!==null,h=ne=>{let _=ne.parentNode;return _&&_.nodeType===11?t.outOwners.get(_)||null:_},d=ne=>{for(let _=ne;_;_=h(_))if(t.via.has(_)&&(_=t.via.get(_)),r.has(_)||n.vetoedLive?.has(g(_)))return!0;return!1},b=ne=>Array.from(wn(ne).children).filter(_=>!s(_)),A=(ne,_)=>b(ne)[b(_.parentNode).indexOf(_)],S=(ne,_)=>{let ye=null,ge=null,Oe=0;for(let re=_.previousSibling;re;re=re.previousSibling){if(re.nodeType===1&&!s(re)){ye=re;break}re.nodeType===3&&(Oe+=re.nodeValue.length)}for(let re=_.nextSibling;re&&!ge;re=re.nextSibling)re.nodeType===1&&!s(re)&&(ge=re);let Be=ye?A(ne,ye):null,We=ge?A(ne,ge):null;if(ye&&!Be||ge&&!We)return null;let rt=[];for(let re=Be?Be.nextSibling:wn(ne).firstChild;re&&re!==We;re=re.nextSibling)re.nodeType===3&&rt.push(re);return rt.length?{nodes:rt,lead:Oe}:null},L=ne=>{let _=[],ye=ne;for(;ye&&!t.via.has(ye);ye=ye.parentNode)_.push(ye);if(!ye||!_.length)return null;let ge=g(t.via.get(ye));for(let We=_.length-1;We>0&≥We--)ge=A(ge,_[We]);if(!ge)return null;let Oe=_[0];if(Oe.nodeType===3)return S(ge,Oe);let Be=Oe.nodeType===1?A(ge,Oe):null;return Be?{nodes:[Be],lead:0}:null},f=ne=>{let _=o(ne),ye=_?{nodes:Array.isArray(_)?_:[_],lead:0}:t.via.size?L(ne):null;if(!ye)return null;let ge=ye.nodes.filter(m);return ge.length?{nodes:ge,lead:ye.lead}:null},g=ne=>{let _=f(ne);return _?_.nodes[0]:null},x=ne=>{if(!ne)return null;if(ne.kind==="text"){let Oe=f(ne.node);if(!Oe)return null;let Be=Oe.nodes,We=ne.offset+Oe.lead,rt=0;for(let re=0;re<Be.length;re++){let ut=Be[re].nodeValue.length;if(We<=rt+ut||re===Be.length-1)return We>=rt&&We<=rt+ut?[Be[re],We-rt]:null;rt+=ut}return null}let _=g(ne.node);if(!_)return null;if(ne.kind==="end")return[wn(_),wn(_).childNodes.length];if(ne.kind==="startOf")return[wn(_),0];if(ne.kind==="wholeStart")return _.firstChild?[_.firstChild,0]:[_,0];if(ne.kind==="wholeEnd")return _.lastChild?[_.lastChild,_.lastChild.nodeValue.length]:[_,_.childNodes.length];let ye=_.parentNode;if(!ye)return null;let ge=Array.prototype.indexOf.call(ye.childNodes,_);return[ye,ne.kind==="after"?ge+1:ge]},Q=ne=>({blocks:new Set((ne.flat?.marks||[]).filter(_=>_.block).map(_=>g(_.el)).filter(Boolean)),atoms:new Set((ne.flat?.atoms||[]).map(_=>g(_.el)).filter(Boolean)),ignored:s}),se=(ne,_,ye,ge)=>{if(!ne||!_||!Kn(ne)||!Kn(_))return!1;for(let We of[ne,_])if(!m(We.startContainer)||!m(We.endContainer))return!1;let Oe=ye.merged;if(Oe.start===Oe.end&&(ne.startContainer!==ne.endContainer||ne.startOffset!==ne.endOffset))return!1;let Be=Q(ge);return Bn(_,ye.encoding,Be)===Oe.text&&Bn(ne,ye.encoding,Be)===Oe.text.slice(Oe.start,Oe.end)},le=new Map,q=ne=>{let _=ne.parentNode;return _?(le.has(_)||le.set(_,new Map(Array.from(_.childNodes,(ye,ge)=>[ye,ge]))),le.get(_).get(ne)):-1},z=(ne,_)=>{if(!_)return!1;let ye=a.logicalParent(ne);if(!_.parent.live.includes(ye))return!1;let ge=q(ne);for(let[Oe,Be]of[["before",1],["after",-1]]){let We=ge;for(let rt of _[Oe]){if(rt.live.includes(ne))continue;let re=rt.live.filter(dt=>dt!==ne&&dt.parentNode===ne.parentNode);if(!re.length)continue;let ut=Be===1?Math.min(...re.map(q)):Math.max(...re.map(q));if(Be*(ut-We)<=0)return!1;We=ut}}return!0},ce=ne=>{let _=ne.structure;if(_.mergedOrder){let ye=new Set(ne.subject.live.map(wn)),ge=null,Oe=-1;for(let Be of _.mergedOrder){let We=Be.live.find(rt=>ye.has(rt.parentNode));if(!We||ge&&We.parentNode!==ge||q(We)<=Oe)return!1;ge=We.parentNode,Oe=q(We)}return ne.subject.live.length>0}return ne.subject.live.some(ye=>z(ye,_.mergedPlacement))},xe=(ne,_)=>{let ye=x(ne),ge=x(_);return ye&&ge?{startContainer:ye[0],startOffset:ye[1],endContainer:ge[0],endOffset:ge[1]}:null},te=new Set,J=ne=>{if(!ne||te.has(ne))return;te.add(ne);let _=[];for(let ye of t.refs.get(ne)||[]){let ge=f(ye);if(ge)for(let Oe of ge.nodes)_.includes(Oe)||_.push(Oe)}ne.live=_},Ce=ne=>{ne&&(J(ne.parent),ne.before.forEach(J),ne.after.forEach(J))},we=new Set;for(let ne of e){let _=ne.recovery;if(!_||we.has(_))continue;we.add(_),J(_.subject),_.structure&&(Ce(_.structure.localPlacement),Ce(_.structure.remotePlacement),Ce(_.structure.mergedPlacement),(_.structure.localOrder||[]).forEach(J),(_.structure.mergedOrder||[]).forEach(J));let ye=t.anchors.get(_),ge=ye?g(ye):null,Oe=!!ge;if(_.text){let O=t.spans.get(_.text.merged),B=O?xe(O.start,O.end):null,ae=O?xe(O.scopeStart,O.scopeEnd):null;if(O?.empty){let be=O.empty,de=be.previous?{kind:"after",node:be.previous}:{kind:"startOf",node:be.parent},ze=be.next?{kind:"before",node:be.next}:{kind:"end",node:be.parent},De=xe(de,ze);!De||De.startContainer!==De.endContainer||De.startOffset!==De.endOffset?B=null:B=ae=De}se(B,ae,_.text,O)||(B=ae=null),_.text.liveSpan=B,_.text.liveScope=B?ae:null,B||(Oe=!1)}_.structure&&Oe&&(Oe=ce(_)),_.attribute&&Oe&&(Oe=c(ge,_.attribute,ne.resolved));let Be=(!!_.attribute||!!_.text&&ge?.tagName==="TEXTAREA")&&!!i&&[ye,ge].some(O=>i.get(O)?.has(_.attribute?_.attribute.qualifiedName:"value")),We=t.localState?.states.get(_),rt=!!_.text&&[...n.removedVetoes||[]].some(O=>We?.touched.has(O)),re=_.structure?.localAction==="inserted"&&[...r].some(O=>O===ye||ye?.contains(O)),ut=ye&&d(ye)||Be||rt||re,dt=ut&&$s(_,ne,t,m);dt&&(rt||re&&_.localLost)&&(Oe=!1);let Se=!Oe&&dt&&ut;_.applied=Oe,_.unavailable=Oe?null:Se?"hook-veto":"missing-output",Se&&(_.localLost=!1),!Oe&&_.text&&(_.text.liveSpan=_.text.liveScope=null)}}function Zo(e,t,n){let o=zn(t),r=zn(n),i=d=>!!d&&r.containerPath(d)!==null,c=d=>{if(d===t)return n;let b=o.pathOf(d);if(b&&t!==n){let A=Fn(n,{path:b,offset:0});if(A&&A[0].nodeType===d.nodeType)return A[0]}return d},s=new Set,a=d=>{!d||s.has(d)||(s.add(d),d.live=d.live.map(c).filter(i))},m=d=>{d&&(d.startContainer=c(d.startContainer),d.endContainer=c(d.endContainer))},h=new Set;for(let d of e){d.node===t&&n.tagName==="SCRIPT"&&(d.node=n),d.el===t&&d.kind==="structure"&&(d.el=n);let b=d.recovery;if(!b||h.has(b))continue;if(h.add(b),a(b.subject),b.text){m(b.text.liveSpan),m(b.text.liveScope);let S=b.text.liveSpan,L=b.text.liveScope,f=b.text.merged,g=x=>!!x&&Kn(x)&&i(x.startContainer)&&i(x.endContainer);(!g(S)||!g(L)||Bn(L,b.text.encoding)!==f.text||Bn(S,b.text.encoding)!==f.text.slice(f.start,f.end))&&(b.text.liveSpan=null,b.text.liveScope=null,b.applied=!1,b.unavailable="missing-output")}let A=b.structure;if(A){for(let S of[A.localPlacement,A.remotePlacement,A.mergedPlacement])S&&(a(S.parent),S.before.forEach(a),S.after.forEach(a));(A.localOrder||[]).forEach(a),(A.mergedOrder||[]).forEach(a),b.subject.live.length||(b.applied=!1,b.unavailable="missing-output")}}}var Xe=e=>!!e&&e.nodeType===1,_c=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),Ks=5e4,So="[id],[data-id],script,head>*";function Pr(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let o=lo(n,e);if(o)return"merge:"+o.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?Ps(n,t):null}}function er(e,t,n,o){let r=o.ignored,i=o.stats||jn(),c=xs({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:i}),{unitsOf:s,meta:a}=c,m=o.baseURI,h=o.mergeTags!==null,d=Pr(o.mergeTags,m),b=u=>v=>{let j=d(v);return j!==null?j:u(v)},A=b(o.identity.base),S=b(o.identity.local),L=b(o.identity.remote),f=o.authored||o.identity,g=u=>u&&u.nodeType===9?u.documentElement:u,x=g(e),Q=g(t),se=g(n),le=globalThis.__hyperMorphProfile,q=le?performance.now():0,z=u=>u===fn?So:null,ce=o.scope||null,xe=ce?ce.baseIndex:zo(x,A,r,z(o.identity.base)),te=o.localIsBase||x===Q?Gs():yr(x,Q,{analyzer:c,baseIndex:xe,sideIndex:zo(Q,S,r,z(o.identity.local)),baseId:f.base,sideId:f.local,stats:i}),J=yr(x,se,{analyzer:c,baseIndex:xe,sideIndex:ce?ce.remoteIndex:zo(se,L,r,z(o.identity.remote)),baseId:f.base,sideId:f.remote,stats:i,scope:ce,comparisons:o.comparisons});if(ce){if(!ce.held(J))return null;for(let u of ce.dropped)gr(u)}let Ce=null;function we(u){if(!Ce){Ce=new WeakMap;let v=[x];for(;v.length;){let j=v.pop();j.tagName==="TEMPLATE"&&j.content&&Ce.set(j.content,j);for(let U of c.childrenOf(j))U.nodeType===1&&v.push(U)}}return Ce.get(u)||null}let ne=u=>{let v=Xe(u)||u.nodeType?u.parentNode:u.parent;return v&&v.nodeType===11?we(v):v};Tt(),nn(te,J),nn(J,te);for(let u of[te,J])if(u.refused)for(let v of u.refused)u.moved.has(v)||i.ambiguousMoves++;le&&(le.alignTotal=(le.alignTotal||0)+(performance.now()-q),q=performance.now());let _=x.ownerDocument.implementation.createHTMLDocument(""),ye=new WeakMap,ge=new WeakMap,Oe=[],Be=[],We=new Set,rt=[],re=new Set,ut=new Set,dt=new Set,Se=new WeakMap,O=o.conflicts||"remote",B=u=>Oe.push(u),ae=u=>Oe.push(u),be=qs({roots:{base:x,local:Q,remote:se},L:te,R:J,unitsOf:s,provenance:ye,policy:O}),de=(u,v)=>{Be.push(u),v&&be.note(u,v)},ze=wt(),De=Et(x,te.map.get(x),J.map.get(x),!!o.localIsBase,!!o.childrenOnly);De.tagName==="HTML"?_.replaceChild(De,_.documentElement):_.body.appendChild(De),le&&(le.build=(le.build||0)+(performance.now()-q));let Qe=o.childrenOnly?!H(R(De),R(se)):!P(De,se),st=be.finish(De);return{doc:_,root:De,provenance:ye,textMappers:ge,decisions:Oe,conflicts:Be,recoveryLinks:st,localDiverged:Qe,mergedScripts:We,segments:rt,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==fn,L:te,R:J,stats:i};function wt(){let u=new Map,v=new Set;if(o.localIsBase||!te.insertedByHash)return{partner:u,drop:v};let j=te.insertedByHash(),U=J.insertedByHash();if(!j.size||!U.size)return{partner:u,drop:v};let V={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},W=Ue=>{let ht=0;for(let it=Ue.parentNode;it;it=it.parentNode)ht++;return ht},Y=[],ie=Ue=>{let ht=Ue.textContent.trim();return ht.split(/\s+/).length>=3||ht.replace(/\s/g,"").length>=12},Ne=Ue=>{let ht=Fe(te,Ue),it=Fe(J,Ue);return ht&&te.reverse.get(ht.parentNode)!==Ue.parentNode||it&&J.reverse.get(it.parentNode)!==Ue.parentNode},Le=(Ue,ht,it)=>{for(let Rt of it.parentNode.children){let qt=Rt!==it&&Ue.reverse.get(Rt);if(qt&&Ne(qt))return!0}let Kt=Ue.reverse.get(it.parentNode);if(Kt){for(let Rt of Kt.children)if(!Fe(ht,Rt)&&!r(Rt))return!0}return!1};for(let[Ue,ht]of j){let it=U.get(Ue);if(!it)continue;let Kt=ht.length===1&&it.length===1;for(let Rt of ht)qn(Rt,V)||Y.push([Rt,it,W(Rt),Kt&&(ie(Rt)||Le(te,J,Rt)||Le(J,te,it[0]))])}if(!Y.length)return{partner:u,drop:v};Y.sort((Ue,ht)=>Ue[2]-ht[2]);let Me=new Set,Ze=new Set,je=Ue=>{for(let ht of Ue.querySelectorAll("*"))Me.add(ht)},Ot=(Ue,ht)=>Ue.reverse.get(ht.parentNode)||null;for(let[Ue,ht,,it]of Y){if(Me.has(Ue))continue;let Kt=Ot(te,Ue),Rt=It=>!Ze.has(It)&&!Me.has(It)&&It.tagName===Ue.tagName&&c.equalUnits(Ue,It),qt=ht.find(It=>Kt&&Ot(J,It)===Kt&&Rt(It))||(it?ht.find(Rt):null);qt&&(Ze.add(qt),je(Ue),je(qt),!(Kt&&Ot(J,qt)===Kt)&&(u.set(Ue,qt),u.set(qt,Ue),v.add(O==="local"?qt:Ue)))}return{partner:u,drop:v}}function bt(u,v,j){if(re.add(u),ze.drop.has(u))return null;re.add(j);let U=v==="local"?u:j,V=v==="local"?j:u,W;return c.equalUnits(U,V)?(W=y(U,"local",!0),ye.get(W).remote=V):W=fe(U,V),de({kind:"structure",el:W,detail:"both-moved",base:null,local:U,remote:V},{unit:{b:null,l:U,r:V}}),B({kind:"insert",el:W,source:"both"}),W}function Tt(){if(!te.weak||!J.weak||!te.weak.size||!J.weak.size||!te.unpair)return;let u=new Map;for(let j of te.weak){let U=Fe(te,j);Xe(j)&&Xe(U)&&u.set(c.unitHash(U),j)}let v=!1;for(let j of Array.from(J.weak)){let U=Fe(J,j);if(!Xe(j)||!Xe(U))continue;let V=u.get(c.unitHash(U));if(!V||V===j||!te.weak.has(V)||Fe(te,j)&&Fe(J,V))continue;let W=Fe(te,V);W.tagName===U.tagName&&c.equalUnits(W,U)&&(te.unpair(V),J.unpair(j),v=!0)}v&&(te.rematch(),J.rematch())}function nn(u,v){if(!u.weak||!u.weak.size||!v.insertedByHash)return;let j=v.insertedByHash();if(!j.size)return;let U=!1;for(let V of Array.from(u.weak)){let W=Fe(u,V);if(!W)continue;let Y=j.get(c.unitHash(W));Y&&Y.some(ie=>ie.tagName===W.tagName&&c.equalUnits(ie,W))&&(u.unpair(V),U=!0)}U&&u.rematch()}function Fe(u,v){if(!v)return null;if(u.map.has(v))return u.map.get(v);let j=[],U=ne(v);for(;U&&!u.map.has(U);U=ne(U))j.push(U);let V=U;if(!V||!u.identical.has(V))return null;u.pairIdenticalChildren(V);for(let Y=j.length-1;Y>=0;Y--)u.pairIdenticalChildren(j[Y]);let W=u.map.get(v)||null;return W&&i.lazyTwins++,W}function Qt(u,v,j){if(ut.has(u)||dt.has(u))return de({kind:"structure",el:null,detail:"both-moved",base:u},{subject:u}),ut.has(u)?null:y(j,v);let U=Fe(te,u),V=Fe(J,u);(!U||!V)&&de({kind:"structure",el:null,detail:"move-beats-delete",base:u},{subject:u,deleted:U?"remote":"local"});let W=Et(u,U,V,!1);return(v==="local"?B:ae)({kind:"move",el:W,source:v}),W}function Xt(u,v,j,U){return U||!v||v===j?{el:j,asBase:!0,twin:V=>V,baseOf:V=>V,units:s(j),here:()=>!0,parentOfTwin:()=>j}:{el:v,asBase:!1,twin:V=>Fe(u,V),baseOf:V=>u.reverse.get(V),units:s(v),here:V=>Xe(V)?V.parentNode===v||v.tagName==="TEMPLATE"&&V.parentNode===v.content:V.parent===v||v.tagName==="TEMPLATE"&&V.parent===v.content}}function Bt(u,v,j){return!v||j&&j.identical.has(u)?!1:Xe(u)?!c.equalUnits(u,v):u.value!==v.value}function Et(u,v,j,U,V=!1){let W=U||o.remoteWins(u),Y=u.namespaceURI&&u.namespaceURI!=="http://www.w3.org/1999/xhtml"?_.createElementNS(u.namespaceURI,u.tagName):_.createElement(u.tagName),ie={base:u,local:v||null,remote:j||null};if(ye.set(Y,ie),re.add(u),ut.add(u),v&&re.add(v),j&&re.add(j),o.skipUnchanged&&!V&&(o.localIsBase||te.identical.has(u))&&j&&J.identical.has(u)&&!o.remoteWins(u)){ie.unchanged=!0;for(let Le of u.attributes)Le.namespaceURI?Y.setAttributeNS(Le.namespaceURI,Le.name,Le.value):Y.setAttribute(Le.name,Le.value);return Y}dt.add(u),V||M(u,W?u:v,j,Y);let Ne=u.tagName;if(tn(u))sn(u,W?u:v,j,Y);else if(Ne==="TEXTAREA")Y.textContent=Lt(u.textContent,(W?u:v)?(W?u:v).textContent:u.textContent,j?j.textContent:u.textContent,Y,"text");else{let Le=T(u,v,j,W,Y),Me=Ne==="TEMPLATE"&&Y.content?Y.content:Y;for(let Ze of Le)Me.appendChild(Ze)}return dt.delete(u),Y}function Lt(u,v,j,U,V){if(v===j)return v;if(v===u)return j!==u&&ae({kind:V,node:U,source:"remote"}),j;if(j===u)return B({kind:V,node:U,source:"local"}),v;let W=O==="local"?v:j;return de({kind:V,node:U,base:u,local:v,remote:j,resolved:W},{site:"whole",el:U}),Oe.push({kind:V,node:U,source:"both"}),W}function sn(u,v,j,U){let V=u.textContent,W=v?v.textContent:V,Y=j?j.textContent:V,ie=h?lo(u,o.mergeTags,!0):null;if(ie&&W!==Y){let Ne=j&&j.getAttribute("merge-key")||u.getAttribute("merge-key"),{text:Le,warnings:Me}=Rr(o.localIsBase?void 0:V,W,Y,{parse:ie.recognizer.parse,keyCandidates:Ne?Ne.split(/[\s,]+/).filter(Boolean):void 0});for(let Ze of Me)console.warn(`[hyper-morph] merge "${ie.raw}": ${Ze}`);U.textContent=Le,We.add(U),Le!==Y?B({kind:"text",node:U,source:Le===W?"local":"both"}):Le!==V&&ae({kind:"text",node:U,source:"remote"});return}U.textContent=Lt(V,W,Y,U,"text")}function M(u,v,j,U){let V=new Map;for(let W of[u,v,j])if(W)for(let Y of W.attributes)o.ignoreAttribute(W,Y.name)||V.set(Y.name,Y);for(let[W,Y]of V){let ie=u?u.getAttribute(W):null,Ne=v?v.getAttribute(W):ie,Le=j?j.getAttribute(W):ie,Me;Ne===Le?Me=Ne:Ne===ie?(Me=Le,ae({kind:"attr",el:U,name:W,source:"remote"})):Le===ie?(Me=Ne,B({kind:"attr",el:U,name:W,source:"local"})):(Me=Z(W,ie,Ne,Le),Me===void 0&&(Me=O==="local"?Ne:Le,de({kind:"attr",el:U,name:W,base:ie,local:Ne,remote:Le,resolved:Me},{el:U,sample:Y})),Oe.push({kind:"attr",el:U,name:W,source:"both"})),Me!=null&&(Y.namespaceURI?U.setAttributeNS(Y.namespaceURI,Y.name,Me):U.setAttribute(W,Me))}}function Z(u,v,j,U){if(u==="class"){let V=Le=>new Set((Le||"").split(/\s+/).filter(Boolean)),W=V(v),Y=V(j),ie=V(U),Ne=new Set;for(let Le of new Set([...W,...Y,...ie])){let Me=W.has(Le),Ze=Y.has(Le),je=ie.has(Le);(Ze===je?Ze:Ze===Me?je:Ze)&&Ne.add(Le)}return[...Ne].join(" ")}if(u==="style"){let V=Me=>{let Ze=new Map;if(!Me)return Ze;let je=0,Ot=null,Ue="",ht=()=>{let it=Ue.indexOf(":");it>0&&Ze.set(Ue.slice(0,it).trim(),Ue.slice(it+1).trim()),Ue=""};for(let it of Me){if(Ot){Ue+=it,it===Ot&&(Ot=null);continue}if(it==='"'||it==="'"){Ot=it,Ue+=it;continue}if(it==="("?je++:it===")"&&je--,it===";"&&je===0){ht();continue}Ue+=it}return Ue.trim()&&ht(),Ze},W=V(v),Y=V(j),ie=V(U),Ne=new Map,Le=!1;for(let Me of new Set([...W.keys(),...Y.keys(),...ie.keys()])){let Ze=W.get(Me)??null,je=Y.get(Me)??null,Ot=ie.get(Me)??null,Ue;je===Ot?Ue=je:je===Ze?Ue=Ot:Ot===Ze?Ue=je:(Ue=O==="local"?je:Ot,Le=!0),Ue!=null&&Ne.set(Me,Ue)}return Le?void 0:[...Ne].map(([Me,Ze])=>`${Me}: ${Ze}`).join("; ")}}function ee(u,v,j,U){let V=u.value,W=U?V:v?v.value:"",Y=j?j.value:"";re.add(u),v&&re.add(v),j&&re.add(j);let ie=wo(V,W,Y,O),Ne=ie.text===""?null:_.createTextNode(ie.text);Ne&&(ye.set(Ne,{base:u.nodes,local:v?v.nodes:null,remote:j?j.nodes:null}),ge.set(Ne,ie.mapLocalOffset)),W!==V&&Y!==V?Oe.push({kind:"text",node:Ne,source:"both"}):W!==V?B({kind:"text",node:Ne,source:"local"}):Y!==V&&ae({kind:"text",node:Ne,source:"remote"});for(let Le of ie.conflicts)de({kind:"text",node:Ne,base:V.slice(Le.bs,Le.be),local:Le.local,remote:Le.remote,resolved:Le.resolved},{site:"run",bRun:u,lRun:v,rRun:j,node:Ne,c:Le});return Ne}function ue(u,v){return xo(u,v).every(j=>j.bs===j.be)}function oe(u,v){let j=u?u.value:"",U=v?v.value:"",V;if(j===U||!U?V=j:j?ue(j,U)?V=U:ue(U,j)?V=j:(V=O==="local"?j:O==="both"?j+U:U,de({kind:"structure",el:null,detail:"insert-collision",local:j,remote:U,resolved:V},{unit:{b:null,l:u,r:v},localLost:O==="remote"})):V=U,u&&re.add(u),v&&re.add(v),V==="")return null;let W=_.createTextNode(V);return ye.set(W,{base:null,local:u?u.nodes:null,remote:v?v.nodes:null}),j?B({kind:"insert",el:W,source:U&&j===U?"both":"local"}):ae({kind:"insert",el:W,source:"remote"}),W}function fe(u,v){let j={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},U=ie=>s(ie).every(Ne=>Xe(Ne)?qn(Ne,j):Ne.kind==="text"),V=null;if(U(u)&&U(v)){let ie=u.textContent,Ne=v.textContent;ie===Ne||ue(Ne,ie)?V=v:ue(ie,Ne)&&(V=u)}if(!V){let ie=O==="local",Ne=y(ie?u:v,ie?"local":"remote",!0),Le=ye.get(Ne);return ie?Le.remote=v:Le.local=u,de({kind:"structure",el:Ne,detail:"insert-collision",local:u,remote:v,resolved:ie?u:v},{unit:{b:null,l:u,r:v},localLost:!ie}),Ne}let W=u.namespaceURI&&u.namespaceURI!=="http://www.w3.org/1999/xhtml"?_.createElementNS(u.namespaceURI,u.tagName):_.createElement(u.tagName);M(null,u,v,W),ye.set(W,{base:null,local:u,remote:v}),re.add(u),re.add(v);let Y=Ir({base:Array.from(V.childNodes),local:Array.from(u.childNodes),remote:Array.from(v.childNodes),out:_,policy:O,idOf:{local:S,remote:L},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:ye,textMappers:ge,conflicts:Be,conflict:de,scope:{base:null,local:u,remote:v,units:[],at:0},synthetic:!0,decisions:Oe,node:W});rt.push(...Y.segments);for(let ie of Y.nodes)W.appendChild(ie);return W}function y(u,v,j=!1){if(!j&&Xe(u)){let Y=ze.partner.get(u);if(Y)return bt(u,v,Y)}if(!Xe(u)){if(u.value==="")return null;let Y=u.kind==="comment"?_.createComment(u.value):_.createTextNode(u.value);return ye.set(Y,{base:null,local:v==="local"?u.nodes:null,remote:v==="remote"?u.nodes:null}),re.add(u),Y}let U=u.namespaceURI&&u.namespaceURI!=="http://www.w3.org/1999/xhtml"?_.createElementNS(u.namespaceURI,u.tagName):_.createElement(u.tagName);for(let Y of u.attributes)Y.namespaceURI?U.setAttributeNS(Y.namespaceURI,Y.name,Y.value):U.setAttribute(Y.name,Y.value);ye.set(U,{base:null,local:v==="local"?u:null,remote:v==="remote"?u:null}),re.add(u);let V=u.tagName==="TEMPLATE"&&U.content?U.content:U,W=v==="local"?te:J;for(let Y of s(u)){let ie=Xe(Y)?W.reverse.get(Y):null;if(ie&&ut.has(ie)){de({kind:"structure",el:null,detail:"both-moved",base:ie},{subject:ie});continue}if(ie&&!dt.has(ie)){let Le=Fe(te,ie)||null,Me=Fe(J,ie)||null;if(Le||Me){let Ze=Et(ie,Le,Me,!1);v==="local"?B({kind:"move",el:Ze,source:"local"}):ae({kind:"move",el:Ze,source:"remote"}),V.appendChild(Ze);continue}}let Ne=y(Y,v);Ne&&V.appendChild(Ne)}return U}function T(u,v,j,U,V){v&&te.identical.has(u)&&te.pairIdenticalChildren(u),j&&J.identical.has(u)&&J.pairIdenticalChildren(u);let W=Xt(te,v,u,U),Y=Xt(J,j,u,!1),ie=s(u),Ne=new Set(ie),Le=new Map;for(let X=0;X<ie.length;X++)Le.set(ie[X],X);let Me=[],Ze=new Set,je=new Map,Ot=new Set,Ue=new Set,ht=[];zt();let it=X=>{let Re=[];for(let Ae of X.units){if(Ue.has(Ae))continue;let Ge=X.baseOf(Ae);Ge&&Ne.has(Ge)&&Re.push(Ge)}return Re},Kt=X=>it(X).map(Re=>Le.get(Re)),Rt=X=>X.every((Re,Ae)=>Ae===0||Re>=X[Ae-1]),qt=!W.asBase&&!Rt(Kt(W)),It=!Y.asBase&&!Rt(Kt(Y));qt&&It&&de({kind:"structure",el:V,detail:"both-reordered",base:u},{subject:u,lKept:it(W),rKept:it(Y)});let at=It||!qt?{V:Y,A:J,side:"remote",other:W,otherA:te,otherSide:"local"}:{V:W,A:te,side:"local",other:Y,otherA:J,otherSide:"remote"};qt?B({kind:"move",el:null,source:It?"both":"local",base:u}):It&&ae({kind:"move",el:null,source:"remote",base:u});let St=W.asBase?[]:W.units.filter(X=>!W.baseOf(X)&&!Ue.has(X)&&!ze.partner.has(X)),At=Y.asBase?[]:Y.units.filter(X=>!Y.baseOf(X)&&!Ue.has(X)&&!ze.partner.has(X)),Ht=new Map;if(St.length&&At.length){let X=new Map,Re=new Map;for(let He of At){if(Xe(He)){let et=L(He);et&&X.set(et,He)}let $e=c.unitHash(He);Re.has($e)||Re.set($e,[]),Re.get($e).push(He)}let Ae=(He,$e)=>{let et=He.units.indexOf($e);for(let _e=et-1;_e>=0;_e--){let nt=He.baseOf(He.units[_e]);if(nt)return nt}return"start"},Ge=new Map,ct=new Map;for(let He of At){let $e=Ae(Y,He);Xe(He)?(ct.has($e)||ct.set($e,[]),ct.get($e).push(He)):He.kind==="text"&&!Ge.has($e)&&Ge.set($e,He)}for(let He of St){let $e=null;if(Xe(He)){let et=S(He);et&&X.has(et)&&!Ht.has(X.get(et))&&($e=X.get(et))}else if(He.kind==="text"){let et=Ge.get(Ae(W,He));et&&!Ht.has(et)&&($e=et)}if(!$e){let et=Re.get(c.unitHash(He));et&&($e=et.find(_e=>!Ht.has(_e)&&Xe(_e)===Xe(He)&&(Xe(_e)?_e.tagName===He.tagName:_e.kind===He.kind)&&c.equalUnits(He,_e))||null)}if(!$e&&Xe(He)){let et=f.local(He),_e=(ct.get(Ae(W,He))||[]).filter(nt=>{let en=f.remote(nt);return!Ht.has(nt)&&nt.tagName===He.tagName&&!(et&&en&&et!==en)&&c.similar(He,nt)});_e.length===1&&($e=_e[0])}$e&&(Ht.set($e,He),Ht.set(He,$e))}}let Zt=X=>{if(re.has(X))return je.get(X)||null;let Re=W.twin(X),Ae=Y.twin(X),Ge=Re&&!W.asBase&&!W.here(Re),ct=Ae&&!Y.asBase&&!Y.here(Ae);if(Ge||ct){if((!Re||!Ae)&&de({kind:"structure",el:null,detail:"move-beats-delete",base:X},{subject:X,deleted:Re?"remote":"local"}),!G(X))return re.add(X),null;de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X})}if(!Re&&!Ae)return re.add(X),ae({kind:"remove",source:"both",base:X}),null;if(!Re&&!Bt(X,Ae,J))return re.add(X),B({kind:"remove",source:"local",base:X}),null;if(!Ae&&!Bt(X,Re,te))return re.add(X),ae({kind:"remove",source:"remote",base:X}),null;let He=!Re||!Ae,$e=W.asBase?Fe(te,X)||null:Re,et=Y.asBase&&Xe(X)&&(J.identityPaired.has(X)||!f.base(X))&&Fe(J,X)||Ae,_e;return Xe(X)?_e=Et(X,$e,et,W.asBase):X.kind==="comment"?_e=N(X,$e,Ae,W.asBase):_e=ee(X,$e,Ae,W.asBase),re.add(X),_e&&(je.set(X,_e),Re&&je.set(Re,_e),Ae&&je.set(Ae,_e),He&&(de({kind:"structure",el:_e,detail:"edit-beats-delete",base:X},{subject:X,deleted:Re?"remote":"local"}),Re?B({kind:"insert",el:_e,source:"local"}):ae({kind:"insert",el:_e,source:"remote"}))),_e},un=(X,Re,Ae,Ge)=>{if(re.has(X))return je.get(X)||null;let ct=Re.baseOf(X);if(ct&&Ne.has(ct))return Ue.has(ct)&&!Ue.has(X)?In(ct,X,Ge):Zt(ct);if(ct)return Cn(ct,X,Ge);let He=Ht.get(X);if(He){let et=Ge==="local"?X:He,_e=Ge==="local"?He:X,nt;return Xe(et)?c.equalUnits(et,_e)?(nt=y(et,"local"),ye.get(nt).remote=_e):nt=fe(et,_e):nt=oe(et,_e),re.add(et),re.add(_e),nt&&(je.set(et,nt),je.set(_e,nt),Xe(et)&&B({kind:"insert",el:nt,source:"both"})),nt}let $e=y(X,Ge);return $e&&(je.set(X,$e),Ge==="local"?B({kind:"insert",el:$e,source:"local"}):ae({kind:"insert",el:$e,source:"remote"})),$e},In=(X,Re,Ae)=>{let Ge;return Xe(X)?(Ge=Qt(X,Ae,Re),Ge&&re.add(Re)):(Ge=y(Re,Ae),re.add(Re),Ge&&(Ae==="local"?B:ae)({kind:"insert",el:Ge,source:Ae})),Ge&&je.set(Re,Ge),Ge},Cn=(X,Re,Ae)=>{let ct=Fe(Ae==="local"?J:te,X),He=Re,$e=ct?he(ct,Ae==="local"?j:v,Ae==="local"?J:te):!1,et=ct&&!$e&&!ve(X,ct);if(et&&Ae===at.otherSide)return de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X}),null;if(et&&de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X}),ct||de({kind:"structure",el:null,detail:"move-beats-delete",base:X},{subject:X,deleted:Ae==="local"?"remote":"local"}),dt.has(X)){de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X});let nt=y(He,Ae);return nt&&je.set(Re,nt),nt}let _e=Xe(X)?Et(X,Ae==="local"?He:Fe(te,X)||null,Ae==="remote"?He:Fe(J,X)||null,!1):null;return _e&&(je.set(X,_e),je.set(Re,_e),ct&&je.set(ct,_e),Ae==="local"?B({kind:"move",el:_e,source:"local"}):ae({kind:"move",el:_e,source:"remote"})),_e};for(let X of at.V.units){if(Ue.has(X)){let Ae=je.get(X);Ze.has(Ae)||(Me.push(Ae),Ze.add(Ae));continue}if(re.has(X)&&!(je.get(X)&&Ze.has(je.get(X)))){let Ae=at.V.baseOf(X);Ae&&!Ne.has(Ae)&&de({kind:"structure",el:null,detail:"both-moved",base:Ae},{subject:Ae});continue}let Re=un(X,at.V,at.A,at.side);Re&&!Ze.has(Re)&&(Me.push(Re),Ze.add(Re),!at.V.baseOf(X)&&!Ht.has(X)&&!Ue.has(X)&&Ot.add(Re))}for(let X of ht)Ze.has(X.frag)||(Me.splice(xn(X.at),0,X.frag),Ze.add(X.frag));if(!at.other.asBase){let X=at.other,Re=at.otherSide,Ae=at.otherA,Ge=null,ct=0,He=null;for(let $e of X.units){let et=je.get($e);if(et&&Ze.has(et)){Ge=et,He=null;continue}if(re.has($e)){let en=X.baseOf($e);en&&!Ne.has(en)&&de({kind:"structure",el:null,detail:"both-moved",base:en},{subject:en});continue}let _e=un($e,X,Ae,Re);if(!_e)continue;let nt;if(He)nt=Me.indexOf(He)+1;else if(Ge){if(nt=Me.indexOf(Ge)+1,Re==="remote")for(;nt<Me.length&&Ot.has(Me[nt]);)nt++}else nt=ct++;Me.splice(nt,0,_e),Ze.add(_e),He=_e}}for(let X=0;X<ie.length;X++){let Re=ie[X];if(re.has(Re))continue;let Ae=Zt(Re);Ae&&Me.splice(xn(X),0,Ae)}return Me;function xn(X){for(let Re=X-1;Re>=0;Re--){let Ae=je.get(ie[Re]);if(Ae){let Ge=Me.indexOf(Ae);if(Ge>=0)return Ge+1}}return 0}function cn(X){let Re={ignored:r,remoteWins:()=>!1},Ae=me=>X(me)||Xe(me)&&o.remoteWins(me)&&An.has(me.tagName)&&qn(me,Re),Ge=new Map,ct=me=>{if(!Xe(me)||!_c.has(me.tagName))return!1;let Ie=Ge.get(me);return Ie===void 0&&(Ie=!r(me)&&!o.remoteWins(me)&&s(me).every(Ae),Ge.set(me,Ie)),Ie},He=me=>!Xe(me)&&me.kind==="text",$e=null,et=new Map,_e=me=>{let Ie=et.get(me);if(Ie)return Ie;let qe=Xe(me)?me.textContent:me.value;Ie=new Set;let tt=qe.toLowerCase();if(!(qe.length>Ks))if(/^[\x00-\x7f]*$/.test(tt))for(let Ke of tt.split(/[^\p{L}\p{N}]+/u))Ke&&Ie.add(Ke);else for(let Ke of Sr(tt))/^[\s\p{P}]+$/u.test(Ke)||Ie.add(Ke);return et.set(me,Ie),Ie},nt=me=>(Xe(me)?me.textContent:me.value).toLowerCase().replace(/\s+/g," ").trim(),en=new Map,Vn=me=>{let Ie=en.get(me);if(Ie)return Ie;Ie=new Set(_e(me));let qe=Ke=>{if(Ke)for(let kt of _e(Ke))Ie.add(kt)},tt=Ne.has(me)?me:!W.asBase&&W.baseOf(me)||!Y.asBase&&Y.baseOf(me);return tt&&(qe(tt),qe(Fe(te,tt)),qe(Fe(J,tt))),en.set(me,Ie),Ie},dn=(me,Ie)=>{let qe=nt(Ie),tt=Ne.has(me)?me:!W.asBase&&W.baseOf(me)||!Y.asBase&&Y.baseOf(me),Ke=Ut=>qe?Ut.split(qe).length-1:0;if(tt&&Xe(Ie)&&!Ne.has(Ie)){let Ut=Ke(nt(tt));for(let _t of[Fe(te,tt),Fe(J,tt)]){if(!_t||_t===Ie||_t.ownerDocument!==Ie.ownerDocument)continue;let an=nt(_t);if(an.length>qe.length&&Ke(an)>=Ut&&(an.startsWith(qe)||an.endsWith(qe)))return!1}}let kt=_e(Ie),yt=Vn(me),Pt=0;for(let Ut of kt)yt.has(Ut)&&Pt++;if(kt.size&&Pt*2>=kt.size)return!0;if(!qe||qe.length>Ks)return!1;let Ft=tt?[me,tt,Fe(te,tt),Fe(J,tt)]:[me],on=(Ut,_t)=>Ut!==_t&&(Ut.startsWith(_t)||Ut.endsWith(_t));if(Ft.some(Ut=>Ut&&on(nt(Ut),qe)))return!0;if(!Ne.has(Ie)||!tt)return!1;let vt=nt(me),Ln=nt(tt);return[Fe(te,Ie),Fe(J,Ie)].some(Ut=>{let _t=Ut&&nt(Ut);return!!_t&&vt!==_t&&(vt.startsWith(_t)&&!Ln.startsWith(_t)||vt.endsWith(_t)&&!Ln.endsWith(_t))})},ln=me=>{$e||($e=new Set),$e.add(me)},Wn=me=>{ln(me);for(let[Ie,qe]of[[te,W],[J,Y]]){if(qe.asBase)continue;let tt=Fe(Ie,me);tt&&qe.here(tt)&&ln(tt)}},Je=(me,Ie)=>me.asBase||ie.every(qe=>!Xe(qe)||Ie.identical.has(qe)&&me.here(Fe(Ie,qe)))&&me.units.every(qe=>!Xe(qe)||me.baseOf(qe));if(Je(W,te)&&Je(Y,J))return null;let ft=me=>{if(me.asBase)return!1;let Ie=-1;for(let qe of me.units){let tt=Xe(qe)?me.baseOf(qe):null;if(!tt||!Ne.has(tt))continue;let Ke=Le.get(tt);if(Ke<Ie)return!0;Ie=Ke}return!1};if(ft(W)||ft(Y))return null;for(let[me,Ie]of[[W,te],[Y,J]]){if(me.asBase||Je(me,Ie))continue;let qe=me.units,tt=Ie===te?f.local:f.remote,Ke=(Pe,pt)=>{let Mt=Xe(Pe)&&f.base(Pe),xt=Xe(pt)&&tt(pt);return!Mt||!xt||Mt===xt},kt=new Map;for(let Pe=0;Pe<qe.length;Pe++)kt.set(qe[Pe],Pe);let yt=Pe=>!!Pe&&(Xe(Pe)?me.here(Pe):kt.has(Pe)),Pt=Pe=>{let pt=me.twin(Pe);return yt(pt)?pt:null},Ft=ie.filter(Pe=>!me.twin(Pe)&&ct(Pe)),on=qe.filter(Pe=>!me.baseOf(Pe)&&ct(Pe)),vt=(Pe,pt)=>pt===ie?!!Pt(Pe):Ne.has(me.baseOf(Pe)),Ln=Pe=>{let pt=new Int32Array(Pe.length),Mt=new Int32Array(Pe.length),xt=-1;for(let mt=0;mt<Pe.length;mt++)pt[mt]=xt,vt(Pe[mt],Pe)&&(xt=mt);xt=Pe.length;for(let mt=Pe.length-1;mt>=0;mt--)Mt[mt]=xt,vt(Pe[mt],Pe)&&(xt=mt);return{prev:pt,next:Mt}},Ut=Ln(qe),_t=Ln(ie),an=(Pe,pt)=>{Wn(Pe),ln(pt)};for(let Pe of on){let pt=kt.get(Pe),Mt=Ut.prev[pt],xt=Ut.next[pt],mt=Mt>=0?me.baseOf(qe[Mt]):null,yn=xt<qe.length?me.baseOf(qe[xt]):null,Vt=mt?Le.get(mt):-1,Rn=yn?Le.get(yn):ie.length;for(let Tn=Math.max(0,Vt);Tn<=Math.min(Rn,ie.length-1);Tn++){let Gt=ie[Tn];(ct(Gt)||He(Gt))&&(!Ke(Gt,Pe)||!dn(Gt,Pe)||(He(Gt)?ln(Pe):an(Gt,Pe)))}}let bn=(Pe,pt,Mt)=>{for(let xt=pt+Mt;xt>=0&&xt<Pe.length;xt+=Mt){let mt=Pe[xt];if(ct(mt))return mt;if(Xe(mt)||mt.value.trim())return null}return null},Uo=Pe=>{let pt=new Set;for(let Mt of s(Pe))if(!Xe(Mt)&&Mt.kind==="text")for(let xt of _e(Mt))pt.add(xt);return pt},Zn=(Pe,pt)=>{let Mt=_e(pt),xt=new Set;for(let mt of Uo(Pe))Mt.has(mt)||xt.add(mt);return xt},bo=(Pe,pt)=>{if(!Pe.size)return!1;let Mt=_e(pt),xt=0;for(let mt of Pe)Mt.has(mt)&&xt++;return xt*2>=Pe.size};for(let Pe of ie){if(Ie.identical.has(Pe)||!ct(Pe))continue;let pt=Pt(Pe);if(!pt||!ct(pt))continue;let Mt=Zn(pt,Pe),xt=Zn(Pe,pt);for(let mt of[-1,1]){let yn=bn(ie,Le.get(Pe),mt);yn&&bo(Mt,yn)&&(an(Pe,pt),Wn(yn));let Vt=bn(qe,kt.get(pt)??-1,mt);if(Vt&&bo(xt,Vt)){an(Pe,pt);let Rn=me.baseOf(Vt);Rn?an(Rn,Vt):ln(Vt)}}}for(let Pe of Ft){let pt=Le.get(Pe),Mt=_t.prev[pt],xt=_t.next[pt],mt=Mt>=0?Pt(ie[Mt]):null,yn=xt<ie.length?Pt(ie[xt]):null,Vt=mt?kt.get(mt)??-1:-1,Rn=yn?kt.get(yn)??-1:qe.length;for(let Tn=Math.max(0,Vt);Tn<=Math.min(Rn,qe.length-1);Tn++){let Gt=qe[Tn];if((ct(Gt)||He(Gt))&&!(!Ke(Pe,Gt)||!dn(Gt,Pe))&&(Wn(Pe),!He(Gt))){let _o=me.baseOf(Gt);_o?an(_o,Gt):ln(Gt)}}}}if(!$e)return null;for(let me of Array.from($e))if(Ne.has(me))for(let Ie of[te,J]){let qe=Fe(Ie,me);qe&&!he(qe,Ie===te?v:j,Ie)&&!(Ie===te?W:Y).asBase&&($e.delete(me),$e.delete(Fe(te,me)),$e.delete(Fe(J,me)))}return $e.size?$e:null}function zt(){if((W.asBase||te.identical.has(u))&&(Y.asBase||J.identical.has(u)))return;let X={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},Re=Je=>Xe(Je)?qn(Je,X):Je.kind==="text",Ae=cn(Re),Ge=Je=>Ae&&Ae.has(Je)||Re(Je),ct=ie.map(Ge);if(!ct.includes(!0))return;let He=Je=>{let ft=Je.units,me=new Map;for(let yt=0;yt<ft.length;yt++)me.set(ft[yt],yt);let Ie=[],qe=-1;for(let yt=0;yt<ie.length;yt++){if(ct[yt])continue;let Pt=Je.twin(ie[yt]),Ft=Pt?me.get(Pt):void 0;Ft===void 0||Ft<=qe||Ge(Pt)||(Ie.push([yt,Ft]),qe=Ft)}let tt=[],Ke=-1,kt=-1;for(let yt=0;yt<=Ie.length;yt++){let[Pt,Ft]=yt<Ie.length?Ie[yt]:[ie.length,ft.length],on={bLo:-1,bHi:-1,sLo:-1,sHi:-1,next:Ft};for(let vt=Ke+1;vt<Pt;vt++)ct[vt]&&(on.bLo<0&&(on.bLo=vt),on.bHi=vt);for(let vt=kt+1;vt<Ft;vt++)Ge(ft[vt])&&(on.sLo<0&&(on.sLo=vt),on.sHi=vt);tt.push(on),Ke=Pt,kt=Ft}return{units:ft,list:tt}},$e=He(W),et=He(Y),_e=[];for(let Je of[$e,et])for(let ft of Je.list)ft.bLo>=0&&_e.push([ft.bLo,ft.bHi]);_e.sort((Je,ft)=>Je[0]-ft[0]);let nt=[];for(let[Je,ft]of _e){let me=nt[nt.length-1];me&&Je<=me.hi?me.hi=Math.max(me.hi,ft):nt.push({lo:Je,hi:ft})}let en=(Je,ft)=>{let me=-1,Ie=-1;for(let Ke=0;Ke<Je.list.length;Ke++){let kt=Je.list[Ke];kt.bLo<ft.lo||kt.bLo>ft.hi||(me<0&&(me=Ke),Ie=Ke)}let qe=1/0,tt=-1;for(let Ke=me;Ke>=0&&Ke<=Ie;Ke++){let kt=Je.list[Ke];kt.sLo>=0&&(qe=Math.min(qe,kt.sLo),tt=Math.max(tt,kt.sHi)),Ke<Ie&&(qe=Math.min(qe,kt.next),tt=Math.max(tt,kt.next))}return tt<0?[]:Je.units.slice(qe,tt+1)},Vn=(Je,ft)=>Je.length===ft.length&&Je.every((me,Ie)=>c.equalUnits(me,ft[Ie])),dn=Je=>!Xe(Je)&&Je.kind==="comment",ln=Je=>{if(!Je.length)return[];let ft=(Ke,kt)=>Xe(Ke)?Ke:Ke.nodes[kt?Ke.nodes.length-1:0],me=ft(Je[0]),Ie=ft(Je[Je.length-1],!0),qe=Ke=>Ke&&Xe(Ke)&&r(Ke);for(;qe(me.previousSibling);)me=me.previousSibling;for(;qe(Ie.nextSibling);)Ie=Ie.nextSibling;let tt=[];for(let Ke=me;Ke&&(tt.push(Ke),Ke!==Ie);Ke=Ke.nextSibling);return tt},Wn=Je=>Je.some(ft=>Xe(ft)&&r(ft));for(let Je of nt){let ft=ie.slice(Je.lo,Je.hi+1),me=W.asBase?null:en($e,Je),Ie=Y.asBase?null:en(et,Je);if(ft.some(dn)||me&&me.some(dn)||Ie&&Ie.some(dn))continue;let qe=ln(me||ft),tt=ln(Ie||ft);if((!me||Vn(ft,me))&&(!Ie||Vn(ft,Ie))&&!(me&&Wn(qe)))continue;let Ke=Ir({base:ln(ft),local:qe,remote:tt,out:_,policy:O,blocks:Ae,L:me?te:zs(te,u),R:Ie?J:zs(J,u),idOf:{local:S,remote:L},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(yt,Pt,Ft)=>Et(yt,Pt,Ft,!1),cloneUnit:y,mergeAttrs:M,atomKey:c.exactUnitKey,moveIn:Qt,provenance:ye,textMappers:ge,conflicts:Be,conflict:de,scope:{base:u,local:W.asBase?null:W.el,remote:Y.asBase?null:Y.el,units:ie,at:Je.lo},decisions:Oe,node:V});rt.push(...Ke.segments);let kt=_.createDocumentFragment();for(let yt of Ke.nodes)kt.appendChild(yt);for(let yt of[...ft,...me||[],...Ie||[]])re.add(yt),Ue.add(yt),je.set(yt,kt);ht.push({frag:kt,at:Je.lo})}}}function P(u,v){let j=ye.get(u);return j&&j.unchanged?!j.remote||j.remote===v?!0:p(j.remote,v):u.tagName!==v.tagName||!$(u,v)?!1:H(R(u),R(v))}function p(u,v){return u===v?!0:u.tagName!==v.tagName||u.namespaceURI!==v.namespaceURI||!$(u,v)?!1:k(R(u),R(v))}function k(u,v){let j=F(u,r),U=F(v,r);if(j.length!==U.length)return!1;for(let V=0;V<j.length;V++){let W=j[V],Y=U[V];if(typeof W=="string"||typeof Y=="string"){if(W!==Y)return!1}else{if(W.nodeType!==Y.nodeType)return!1;if(W.nodeType===1){if(!p(W,Y))return!1}else if(W.nodeValue!==Y.nodeValue)return!1}}return!0}function R(u){return u.tagName==="TEMPLATE"&&u.content?u.content:u}function $(u,v){let j=0;for(let U of u.attributes)if(!o.ignoreAttribute(u,U.name)&&(j++,v.getAttribute(U.name)!==U.value))return!1;for(let U of v.attributes)o.ignoreAttribute(v,U.name)||j--;return j===0}function H(u,v){let j=F(u,V=>{let W=ye.get(V);return!!(W&&W.pinned)}),U=F(v,r);if(j.length!==U.length)return!1;for(let V=0;V<j.length;V++){let W=j[V],Y=U[V];if(typeof W=="string"||typeof Y=="string"){if(W!==Y)return!1}else{if(W.nodeType!==Y.nodeType)return!1;if(W.nodeType===1){if(!P(W,Y))return!1}else if(W.nodeValue!==Y.nodeValue)return!1}}return!0}function F(u,v){let j=[],U=null;for(let V=u.firstChild;V;V=V.nextSibling){if(V.nodeType===3){U=U===null?V.nodeValue:U+V.nodeValue;continue}V.nodeType===1&&v(V)||(U!==null&&(U!==""&&j.push(U),U=null),j.push(V))}return U!==null&&U!==""&&j.push(U),j}function N(u,v,j,U){let V=u.value,W=U?V:v?v.value:"",Y=j?j.value:"";re.add(u),v&&re.add(v),j&&re.add(j);let ie=W===Y?W:W===V?Y:Y===V||O==="local"?W:Y,Ne={site:"comment",bRun:u,lRun:v,rRun:j,node:null};if(W!==V&&Y!==V&&W!==Y&&de({kind:"text",node:null,base:V,local:W,remote:Y,resolved:ie},Ne),!v&&!j)return null;let Le=_.createComment(ie);return Ne.node=Le,ye.set(Le,{base:u.nodes,local:v?v.nodes:null,remote:j?j.nodes:null}),Le}function E(u,v){let j=Fe(v,u);if(!j)return null;let U=Xe(j)?j.parentNode:j.parent,V=Xe(u)?u.parentNode:u.parent;return Fe(v,V)===U?null:v.reverse.get(U)||null}function G(u){let v=new Set([u]),j=u;for(let U=0;U<64;U++){let V=E(j,te)||E(j,J);if(!V)return!1;if(V===u||Xe(u)&&Xe(V)&&u.contains(V)||v.has(V))return!0;v.add(V),j=V}return!0}function he(u,v,j){if(!v)return!1;let U=Xe(u)?u.parentNode:u.parent;return U===v||v.tagName==="TEMPLATE"&&U===v.content}function ve(u,v){let j=ne(u),U=Fe(te,j);if(U&&he(v,U,te))return!0;let V=Fe(J,j);return!!(V&&he(v,V,J))}}function zs(e,t){return e.map.get(t)?Gs():{map:{get:o=>o&&o.nodeType===1&&e.map.get(o)||o,has:()=>!0},reverse:{get:o=>e.reverse.get(o)||o,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Gs(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Ys=new Set(["INPUT","OPTION","TEXTAREA"]),jr=/[\t\n\f\r ]+/;function Js(e,t,n,o){let r=e.ownerDocument,{provenance:i,textMappers:c}=n,s=o.hooks,a=[],m=[],h=[],d=new Set,b=[],A=[],S=new Map,L=new Set,f=new Map,g=n.conflicts.length>0,x=new Map,Q=new Set,se=new Map,le=(M,Z)=>{let ee=se.get(M);ee||se.set(M,ee=new Set),ee.add(Z)},q=g?new Set:null,z=(M,Z,ee)=>{let ue=s.beforeAttributeUpdated(M,Z,ee);return g&&ue===!1&&le(Z,M),ue},ce=M=>!!M&&(M===e||e.contains(M)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(M)),xe=new Map,te=new Map,J=new Map,Ce=new Set,we=new Map;(function M(Z){let ee=i.get(Z);if(ee){if(Z.nodeType===1){let oe=ee.local?o.toLive(ee.local):null;oe&&ce(oe)&&oe.nodeType===1&&(xe.set(Z,oe),te.set(oe,Z))}else if(Array.isArray(ee.local)){let oe=ge(ee.local,ee.local.map(fe=>o.toLive(fe)).filter(fe=>fe&&ce(fe)&&fe.nodeType===Z.nodeType));if(oe.length&&(xe.set(Z,oe[0]),te.set(oe[0],Z),J.set(Z,oe)),Array.isArray(ee.caret))for(let fe of ee.caret){let y=o.toLive(fe.node);if(!y||!ce(y)||y.nodeType!==3)continue;let T=we.get(y);Array.isArray(T)||we.set(y,T=[]),T.push({merged:Z,from:fe.from,to:fe.to,flatStart:fe.flatStart})}else{let fe=0;for(let y of oe)we.set(y,{merged:Z,shift:fe}),fe+=y.nodeValue.length}}}let ue=Z.nodeType===1&&Z.tagName==="TEMPLATE"&&Z.content?Z.content.childNodes:Z.childNodes;for(let oe of ue)M(oe)})(t);let ne=new Set;for(let M of xe.values())ne.add(M);for(let M of J.values())for(let Z of M)ne.add(Z);for(let M of n.segments||[])Oe(M);let _=o.restoreFocus===!1?null:Vc(r,we);o.childrenOnly?re(Be(e),Be(t)):We(e,t);for(let{node:M,parent:Z}of b)d.has(M)||!M.parentNode||M.nodeType===1&&(o.ignored(M)||ut(M))||De(M,Z);return Wc(r,_,we,c,J,f,Ce),{applied:a,moved:m,replaced:h,identities:A,mergedScriptsLive:L,liveOf:xe,heldBy:f,runOf:J,keptRuns:Ce,insertedLive:x,vetoed:Q,vetoedAttrs:se,removedVetoes:q};function ye(M,Z){let ee=M.slice(Z.bs,Z.be),ue=0;for(;ue<ee.length&&ue<Z.text.length&&ee[ue]===Z.text[ue];)ue++;let oe=0;for(;oe<ee.length-ue&&oe<Z.text.length-ue&&ee[ee.length-1-oe]===Z.text[Z.text.length-1-oe];)oe++;return{bs:Z.bs+ue,be:Z.be-oe,text:Z.text.slice(ue,Z.text.length-oe)}}function ge(M,Z){if(!Z.length)return Z;let ee=[];for(let fe of M){let y=fe.parentNode;if(!y)continue;let T=S.get(y);if(!T){T=new Set;for(let P=y.firstChild;P;P=P.nextSibling)P.nodeType===3&&T.add(o.toLive(P));S.set(y,T)}ee.includes(T)||ee.push(T)}let ue={has:fe=>ee.some(y=>y.has(fe))},oe=[];for(let fe of Z){oe.push(fe);for(let y=fe.nextSibling;y&&y.nodeType===3&&!ue.has(y)&&!oe.includes(y);y=y.nextSibling)oe.push(y)}return oe}function Oe(M){let Z=[];for(let N of M.localNodes){let E=o.toLive(N.node);if(!E||!ce(E)||E.nodeType!==3)return;Z.push(E)}let ee=ge(M.localNodes.map(N=>N.node),Z);if(!ee.length)return;let ue=ee.map(N=>N.nodeValue).join(""),{flatLocal:oe,lToM:fe,mapLocal:y}=M;if(ue===oe)return;let T=M.textNodes.map(N=>({node:N.node,ms:N.ms,me:N.me})),P=[],p=0;for(let N of ee)P.push(p),p+=N.nodeValue.length;let k=(N,E)=>ee.find((G,he)=>P[he]<=N&&N+E<=P[he]+G.nodeValue.length)||null,R=[],$=0;for(let N of xo(oe,ue).map(E=>ye(oe,E))){let E=N.bs+$;$+=N.text.length-(N.be-N.bs);let G,he;if(N.be>N.bs){G=fe[N.bs];let ve=G>=0;for(let u=N.bs;ve&&u<N.be;u++)fe[u]!==G+(u-N.bs)&&(ve=!1);if(!ve)continue;he=G+(N.be-N.bs)}else{let ve=N.bs>0?fe[N.bs-1]:0,u=N.bs<oe.length?fe[N.bs]:0;if(ve<0||u<0)continue;G=he=y(N.bs)}R.push({ms:G,me:he,text:N.text,live:he===G?k(E,N.text.length):null})}R.sort((N,E)=>E.ms-N.ms);let H=(N,E)=>(J.get(N.node)||[xe.get(N.node)]).includes(E),F=N=>!!N&&N.nodeType===1&&An.has(N.tagName);for(let N of R){let E=T.find(he=>he.ms<=N.ms&&N.me<=he.me&&N.ms<he.me);if(E&&N.live&&E.ms===N.ms&&!H(E,N.live)){let he=T.find(ve=>ve.me===N.ms&&H(ve,N.live));he&&(E=he)}if(!E&&N.me===N.ms){let he=T.find(j=>j.me===N.ms),ve=T.find(j=>j.ms===N.ms),u=he||ve;if(!u)continue;let v=u.node;for(;F(v.parentNode)&&(he?v.parentNode.lastChild:v.parentNode.firstChild)===v;)v=v.parentNode;if(v===u.node)E=u;else{let j=v.ownerDocument.createTextNode(N.text);v.parentNode.insertBefore(j,he?v.nextSibling:v);continue}}if(!E)continue;let G=E.node.nodeValue;E.node.nodeValue=G.slice(0,N.ms-E.ms)+N.text+G.slice(N.me-E.ms),E.me+=N.text.length-(N.me-N.ms)}}function Be(M){return M.nodeType===1&&M.tagName==="TEMPLATE"&&M.content?M.content:M}function We(M,Z){d.add(M);let ee=i.get(Z);if(ee&&ee.remote&&n.remoteIdOf){let oe=n.remoteIdOf(ee.remote);oe&&A.push([M,oe])}if(ee&&ee.unchanged){n.customIdentity&&ee.remote&&B(M,ee.remote),ee.remote&&O(M,ee.remote);return}if(s.beforeNodeMorphed(M,Z)===!1){Q.add(Z);return}nn(M,Z,o.keepLiveOnly&&ee&&ee.local&&ee.local.nodeType===1&&ee.local!==M?ee.local:null);let ue=M.tagName;if(tn(M))M.textContent!==Z.textContent&&(a.push({kind:"text",node:M,before:M.textContent,after:Z.textContent}),M.textContent=Z.textContent),n.mergedScripts.has(Z)&&L.add(M);else if(ue==="TEXTAREA")sn(M,Z,ee);else{Et(M,Z,ee);let oe=ue==="TEMPLATE"&&M.content?M.content:M,fe=ue==="TEMPLATE"&&Z.content?Z.content:Z;o.protectFocusedValue==="subtree"&&Qt(M)&&M!==r.body?rt(oe):re(oe,fe)}s.afterNodeMorphed(M,Z)}function rt(M){for(let Z=M.firstChild;Z;Z=Z.nextSibling){let ee=te.get(Z);ee&&xe.get(ee.parentNode)!==M||(d.add(Z),Z.nodeType===1&&rt(Z))}}function re(M,Z){let ee=de(M.firstChild),ue=new Set;for(let oe of Array.from(Z.childNodes)){let fe=xe.get(oe);fe&&d.has(fe)&&!ue.has(fe)&&(fe=null);let y=i.get(oe);if(y&&y.pinned){fe&&fe.nodeType===1&&((fe.parentNode!==M||de(fe.nextSibling)!==ee)&&ze(M,fe,ee),d.add(fe),ue.add(fe));continue}if(fe&&fe.nodeType===1){if(fe!==ee){let p=fe.parentNode;if(p===M&&ee&&Xt(fe)){let k=fe.nextSibling;for(let R=ee;R&&R!==fe;){let $=R.nextSibling;ze(M,R,k),R=$}}else ze(M,fe,ee),p!==M&&(m.push(fe),a.push({kind:"move",el:fe,from:p,to:M}))}ue.add(fe),We(fe,oe),ee=de(fe.nextSibling);continue}if(fe&&fe.nodeType!==1){let p=J.get(oe)||[fe],k=p.map($=>$.nodeValue).join(""),R=oe.nodeValue;if(oe.nodeType===3){let $=dt(oe);$!=null&&k!==$&&(R=wo($,k,oe.nodeValue).text)}if(p.length>1&&k===R&&!p.includes(ee,1)&&p.every(($,H)=>$.parentNode===M&&(H===0||p[H-1].nextSibling===$))){if(fe!==ee)for(let $ of p)ze(M,$,ee);s.beforeNodeMorphed(fe,oe)!==!1?s.afterNodeMorphed(fe,oe):g&&Q.add(oe);for(let $ of p)d.add($),ue.add($);f.set(oe,fe),Ce.add(oe),ee=de(p[p.length-1].nextSibling);continue}fe!==ee&&ze(M,fe,ee),s.beforeNodeMorphed(fe,oe)!==!1?(fe.nodeValue!==R&&(a.push({kind:"text",node:fe,before:fe.nodeValue,after:R}),fe.nodeValue=R),s.afterNodeMorphed(fe,oe)):Q.add(oe),d.add(fe),ue.add(fe),f.set(oe,fe),ee=de(fe.nextSibling);continue}if(oe.nodeType===3&&ee&&ee.nodeType===3&&!d.has(ee)&&!we.has(ee)){ee.nodeValue!==oe.nodeValue&&(a.push({kind:"text",node:ee,before:ee.nodeValue,after:oe.nodeValue}),ee.nodeValue=oe.nodeValue),d.add(ee),f.set(oe,ee),ee=de(ee.nextSibling);continue}let T=i.get(oe),P=Qe(T&&T.unchanged&&T.remote?T.remote:oe);if(s.beforeNodeAdded(P)===!1){Q.add(oe);continue}M.insertBefore(P,ee),d.add(P),g&&x.set(oe,P),P.nodeType===3&&f.set(oe,P),P.nodeType===1&&(h.push(P),be(P,oe),n.customIdentity&&T&&T.unchanged&&T.remote&&B(P,T.remote),tn(P)||st(P,oe),o.formState==="property"&&Bt(T)&&O(P,T.remote)),ee=de(P.nextSibling),a.push({kind:"insert",node:P,parent:M}),s.afterNodeAdded(P)}for(let oe of Array.from(M.childNodes))d.has(oe)||ue.has(oe)||oe.nodeType===1&&(o.ignored(oe)||ut(oe))||(ne.has(oe)?b.push({node:oe,parent:M}):De(oe,M))}function ut(M){return o.preserve&&M.parentNode&&M.parentNode.nodeType===1&&M.parentNode.tagName==="HEAD"&&o.preserve(M)===!0}function dt(M){let Z=i.get(M);return!Z||!Array.isArray(Z.local)?null:Z.local.map(ee=>ee.nodeValue).join("")}function Se(M){return i.get(M)}function O(M,Z){if(!Ys.has(M.tagName)&&!M.querySelector("input,option,textarea"))return;let ee=(ue,oe)=>{if(ue.tagName!==oe.tagName)return;ue.tagName==="TEXTAREA"?sn(ue,oe,{remote:oe}):Ys.has(ue.tagName)&&Et(ue,oe,{remote:oe});let fe=ae(ue),y=ae(oe);if(fe.length===y.length)for(let T=0;T<fe.length;T++)ee(fe[T],y[T])};ee(M,Z)}function B(M,Z){let ee=ae(M),ue=ae(Z);if(ee.length===ue.length)for(let oe=0;oe<ee.length;oe++){let fe=n.remoteIdOf(ue[oe]);fe&&A.push([ee[oe],fe]),B(ee[oe],ue[oe])}}function ae(M){let Z=M.tagName==="TEMPLATE"&&M.content?M.content:M;return Array.from(Z.children).filter(ee=>!o.ignored(ee))}function be(M,Z){if(!n.remoteIdOf)return;let ee=(ue,oe)=>{let fe=i.get(oe);if(fe&&fe.remote&&oe.nodeType===1){let P=n.remoteIdOf(fe.remote);P&&A.push([ue,P])}let y=ue.childNodes,T=oe.childNodes;for(let P=0;P<y.length&&P<T.length;P++)ee(y[P],T[P])};ee(M,Z)}function de(M){for(;M&&M.nodeType===1&&o.ignored(M);)M=M.nextSibling;return M}function ze(M,Z,ee){if(typeof M.moveBefore=="function"&&Z.ownerDocument===M.ownerDocument)try{M.moveBefore(Z,ee);return}catch{}M.insertBefore(Z,ee)}function De(M,Z){if(s.beforeNodeRemoved(M)===!1){g&&q.add(M);return}M.parentNode.removeChild(M),a.push({kind:"remove",node:M,parent:Z}),s.afterNodeRemoved(M)}function Qe(M){if(tn(M))return To(M,r);let Z=r.importNode(M,!0);if(Z.nodeType===1)for(let ee of Array.from(Z.querySelectorAll("script")))tn(ee)&&ee.replaceWith(To(ee,r));return Z}function st(M,Z){let ee=M.tagName==="TEMPLATE"&&M.content?M.content:M,ue=Z.tagName==="TEMPLATE"&&Z.content?Z.content:Z,oe=Array.from(ee.childNodes),fe=Array.from(ue.childNodes);for(let y=0;y<fe.length&&y<oe.length;y++){let T=fe[y],P=oe[y],p=xe.get(T);p&&d.has(p)&&(p=null);let k=i.get(T);if(k&&k.pinned){if(p&&p.nodeType===1){let R=p.parentNode;ze(ee,p,P),R!==ee&&(m.push(p),a.push({kind:"move",el:p,from:R,to:ee})),d.add(p)}P.remove();continue}if(p){let R=p.parentNode;ze(ee,p,P),P.remove(),p.nodeType===1?(R!==ee&&(m.push(p),a.push({kind:"move",el:p,from:R,to:ee})),We(p,T)):(d.add(p),f.set(T,p),p.nodeValue!==T.nodeValue&&(a.push({kind:"text",node:p,before:p.nodeValue,after:T.nodeValue}),p.nodeValue=T.nodeValue));continue}d.add(P),g&&x.set(T,P),P.nodeType===3&&f.set(T,P),k&&k.unchanged&&k.remote?(wt(P,k.remote),n.customIdentity&&B(P,k.remote)):T.nodeType===1&&!tn(T)&&st(P,T)}}function wt(M,Z){let ee=M.tagName==="TEMPLATE"&&M.content?M.content:M,ue=Z.tagName==="TEMPLATE"&&Z.content?Z.content:Z;for(let oe of Array.from(ue.childNodes))ee.appendChild(Qe(oe))}function bt(M,Z){return Z.namespaceURI?M.getAttributeNS(Z.namespaceURI,Z.localName):M.getAttribute(Z.name)}function Tt(M,Z){let ee=new Set((Z||"").split(jr).filter(Boolean));return(M||"").split(jr).filter(ue=>ue&&!ee.has(ue))}function nn(M,Z,ee){for(let ue of Array.from(Z.attributes)){if(Fe(M,ue.name)||o.ignoreAttribute(M,ue.name))continue;let oe=bt(M,ue);if(oe===ue.value||ee&&bt(ee,ue)===ue.value)continue;let fe=ue.value;if(ee&&ue.name==="class"&&!ue.namespaceURI){let y=ue.value.split(jr).filter(Boolean),T=Tt(oe,ee.getAttribute("class")).filter(P=>!y.includes(P));T.length&&(fe=[...y,...T].join(" "))}if(oe!==fe){if(s.beforeAttributeUpdated(ue.name,M,"update")===!1){g&&le(Z,ue.name);continue}ue.namespaceURI?M.setAttributeNS(ue.namespaceURI,ue.name,fe):M.setAttribute(ue.name,fe),a.push({kind:"attr",el:M,name:ue.name,before:oe,after:fe})}}for(let ue of Array.from(M.attributes)){if(Fe(M,ue.name)||o.ignoreAttribute(M,ue.name)||(ue.namespaceURI?Z.hasAttributeNS(ue.namespaceURI,ue.localName):Z.hasAttribute(ue.name)))continue;if(ee&&ue.name==="class"&&!ue.namespaceURI){let y=Tt(ue.value,ee.getAttribute("class"));if(y.length){let T=y.join(" ");if(T===ue.value)continue;if(s.beforeAttributeUpdated("class",M,"update")===!1){g&&le(Z,"class");continue}M.setAttribute("class",T),a.push({kind:"attr",el:M,name:"class",before:ue.value,after:T});continue}}if(ee&&bt(ee,ue)===null)continue;if(s.beforeAttributeUpdated(ue.name,M,"remove")===!1){g&&le(Z,ue.name);continue}let fe=ue.value;ue.namespaceURI?M.removeAttributeNS(ue.namespaceURI,ue.localName):M.removeAttribute(ue.name),a.push({kind:"attr",el:M,name:ue.name,before:fe,after:null})}}function Fe(M,Z){let ee=M.tagName;return ee==="INPUT"?Z==="value"||Z==="checked"||Z==="disabled":ee==="OPTION"?Z==="selected":!1}function Qt(M){return M===r.activeElement}function Xt(M){let Z=r.activeElement;return!!Z&&Z!==r.body&&M.contains(Z)}function Bt(M){let Z=M&&M.remote;return Z&&Z.nodeType===1?Z:null}function Et(M,Z,ee){let ue=M.tagName,oe=Bt(ee),fe=o.formState==="property"&&oe?oe:Z;if(ue==="INPUT"){let y=o.protectFocusedValue&&Qt(M),T=(M.getAttribute("type")||"").toLowerCase(),P=T!=="file"&&T!=="checkbox"&&T!=="radio",p=oe&&oe.hasAttribute("value")&&oe.value!==oe.getAttribute("value")?oe.value:null;if(P&&!y)if(o.formState==="property"){let k=Z.getAttribute("value"),R=M.getAttribute("value");(R!==k||M.value!==fe.value)&&z("value",M,k==null?"remove":"update")!==!1&&(R!==k&&(k==null?M.removeAttribute("value"):M.setAttribute("value",k),a.push({kind:"attr",el:M,name:"value",before:R,after:k})),M.value!==fe.value&&(M.value=fe.value))}else if(Z.hasAttribute("value")||p!=null){let k=p??Z.getAttribute("value");M.getAttribute("value")!==k&&z("value",M,"update")!==!1?(M.setAttribute("value",k),M.value!==k&&(M.value=k),a.push({kind:"attr",el:M,name:"value",before:null,after:k})):M.value!==k&&M.getAttribute("value")===k&&(M.value=k)}else(M.hasAttribute("value")||M.value!=="")&&z("value",M,"remove")!==!1&&(M.removeAttribute("value"),M.value="",a.push({kind:"attr",el:M,name:"value",before:"",after:null}));if(!P&&T!=="file"){let k=Z.getAttribute("value");k==null?M.hasAttribute("value")&&z("value",M,"remove")!==!1&&M.removeAttribute("value"):M.getAttribute("value")!==k&&z("value",M,"update")!==!1&&M.setAttribute("value",k)}y||(Lt(M,fe,"checked"),o.formState==="property"&&M.indeterminate!==fe.indeterminate&&(M.indeterminate=fe.indeterminate)),Lt(M,fe,"disabled")}else if(ue==="OPTION"){let y=M.parentNode&&M.closest("select");o.protectFocusedValue&&y&&Qt(y)||Lt(M,fe,"selected")}}function Lt(M,Z,ee){let ue=o.formState==="property"?!!Z[ee]:Z.hasAttribute(ee);if(o.formState!=="property"){let oe=M.hasAttribute(ee);if(oe!==ue){if(z(ee,M,ue?"update":"remove")===!1)return;ue?M.setAttribute(ee,""):M.removeAttribute(ee),a.push({kind:"attr",el:M,name:ee,before:oe?"":null,after:ue?"":null})}}M[ee]!==ue&&(M[ee]=ue)}function sn(M,Z,ee){if(o.protectFocusedValue&&Qt(M)||z("value",M,"update")===!1)return;let ue=Bt(ee),oe=Z.textContent,fe=ue&&ue.value!==ue.defaultValue?ue.value:oe;o.formState!=="property"&&M.textContent!==oe&&(a.push({kind:"text",node:M,before:M.textContent,after:oe}),M.textContent=oe),M.value!==fe&&(M.value=fe)}}function Vc(e,t){let n=e.activeElement;if(!n||n===e.body||n===e.documentElement)return null;let o={el:n,id:n.getAttribute&&n.getAttribute("id"),scrollTop:n.scrollTop,scrollLeft:n.scrollLeft};if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"){try{o.selection=[n.selectionStart,n.selectionEnd,n.selectionDirection]}catch{}return o}let r=e.getSelection&&e.getSelection();if(r&&r.rangeCount){let i=r.getRangeAt(0);o.range={sc:i.startContainer,so:i.startOffset,ec:i.endContainer,eo:i.endOffset}}return o}function Wc(e,t,n,o,r,i,c){if(!t)return;let s=t.el;if(!s.isConnected&&t.id&&(s=e.getElementById(t.id)),!s||!s.isConnected)return;if(e.activeElement!==s)try{s.focus({preventScroll:!0})}catch{}try{s.scrollTop=t.scrollTop,s.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{s.setSelectionRange&&!s.selectionEnd&&t.selection[1]!=null&&s.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let a=(d,b)=>{let A=n.get(d);if(Array.isArray(A)){let S=A.find(x=>b>=x.from&&b<x.to)||A.find(x=>b===x.to)||A[A.length-1],L=i.get(S.merged);if(!L||!L.isConnected)return null;let f=o.get(S.merged),g=f&&f.flat?f.flat(S.flatStart+b):b;return[L,Math.max(0,Math.min(g,L.nodeValue.length))]}if(A&&!c.has(A.merged)){let S=(r.get(A.merged)||[d])[0];if(!S.isConnected)return null;let L=o.get(A.merged),f=A.shift+b,g=L?L(f):f;return[S,Math.max(0,Math.min(g,S.nodeValue.length))]}return d.isConnected?[d,Math.min(b,d.nodeType===3?d.nodeValue.length:d.childNodes.length)]:null},m=a(t.range.sc,t.range.so),h=a(t.range.ec,t.range.eo);if(!(!m||!h))try{let d=e.createRange();d.setStart(m[0],m[1]),d.setEnd(h[0],h[1]);let b=e.getSelection();b.removeAllRanges(),b.addRange(d)}catch{}}var $c={compared:0},qc=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Fc(e,t,n){let o=0;for(let r of e.attributes)if(!n(e,r.name)&&(o++,t.getAttribute(r.name)!==r.value))return!1;for(let r of t.attributes)n(t,r.name)||o--;return o===0}function Dr(e,t){if(e.namespaceURI!==t.namespaceURI||e.prefix!==t.prefix||e.localName!==t.localName)return!1;let n=e.attributes;if(n.length!==t.attributes.length)return!1;for(let o of n)if(t.getAttributeNS(o.namespaceURI,o.localName)!==o.value)return!1;return!0}function Xs(e,t,n,o,r,i,c,s){let a=new Map,m=new Set,h=d=>{if(o(d))return;let b=n(d);b&&(i.add(b),r.has(b)||a.has(b)?m.add(b):a.set(b,d))};for(let d of e)h(d);h(t);for(let d of c||t.querySelectorAll("*"))h(d);for(let d of m)a.delete(d),s.add(d);return a}function Qs(e,t,n,o,r,i){let c=!1;for(let h of r)h.startsWith("merge:")&&(c=!0);if(!c)return[...o];let s=new Map,a=[],m=i===fn?So:"*";for(let h of[e,...e.querySelectorAll(m)]){if(n(h))continue;let d=t(h);if(!d||!(o.has(d)||r.has(d)))continue;let b=(s.get(d)||0)+1;s.set(d,b),b===2&&a.push(d)}return a}function Zs({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:o,o:r,identity:i,baseURI:c}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!Fc(e,t,r.ignoreAttribute))return{bail:"root-attrs"};let{ignored:s,remoteWins:a}=r,m=Pr(r.scripts.merge===!1?null:r.scripts.mergeTags,c),h=Se=>{let O=m(Se);return O!==null?O:i.base(Se)||null},d=Se=>{let O=m(Se);return O!==null?O:i.remote(Se)||null},b=[],A=[],S=new Map,L=new Map,f={same:S,differ:L},g=Se=>({bail:Se,comparisons:f}),x=(Se,O,B=!0)=>{if(S.get(Se)===O)return!0;if(L.get(Se)===O)return!1;if($c.compared++,B&&Se.isEqualNode(O))return S.set(Se,O),!0;let ae=Se.nodeType===O.nodeType;if(ae&&Se.nodeType===1){if(ae=Dr(Se,O),ae){let be=Se.firstChild,de=O.firstChild;for(;be&&de;be=be.nextSibling,de=de.nextSibling)if(!x(be,de,!1)){ae=!1;break}(be||de)&&(ae=!1)}}else ae&&(ae=Se.isEqualNode(O));return(ae?S:L).set(Se,O),ae},Q=e,se=t,le=!1,q=()=>{S.set(Q,se);for(let Se=0;Se<b.length;Se++)S.set(b[Se],A[Se]);return g("equal")};for(;;){let Se=Q.childNodes,O=se.childNodes;if(Se.length!==O.length)break;let B=st=>x(Se[st],O[st])?(S.set(Se[st],O[st]),!1):!0,ae=-1,be=-1;for(let st=0;st<Se.length;st++){if(Se[st].nodeType!==1)continue;let wt=0;for(let bt=Se[st].firstElementChild;bt;bt=bt.nextElementSibling)wt++;wt>=be&&(be=wt,ae=st)}let de=[],ze=!1;for(let st=0;st<Se.length&&de.length<2;st++)st!==ae&&B(st)&&de.push(st);if(ae>=0&&de.length<2&&(de.length===0&&Dr(Q,se)?(de.push(ae),ze=!0):B(ae)&&de.push(ae)),de.length!==1){if(!le&&de.length===0&&Dr(Q,se))return q();break}let De=Se[de[0]],Qe=O[de[0]];if(le=le||!ze,le&&L.set(De,Qe),De.nodeType!==1||Qe.nodeType!==1||De.tagName!==Qe.tagName)break;if(h(De)!==d(Qe)){if(!le&&x(De,Qe))return q();break}b.push(Q),A.push(se),Q=De,se=Qe}L.set(Q,se);for(let Se=0;Se<b.length;Se++)L.set(b[Se],A[Se]);if(Q===e||Q.tagName==="HEAD"||Q.tagName==="BODY")return g("root-level");if(b.length<2||b[1].tagName!=="BODY")return g("not-in-body");if(s(Q)||s(se))return g("ignored-ancestor");if(a(Q)||a(se))return g("remote-wins-ancestor");for(let Se of b)if(qc.has(Se.tagName))return g("form-ancestor");if(Q.tagName==="SCRIPT"||Q.getElementsByTagName("script").length||se.getElementsByTagName("script").length)return g("script-or-template");let z=o(Q);if(!z||z.nodeType!==1||z.tagName!==Q.tagName)return g("no-live-twin");if(!n.contains(z))return g("live-detached");for(let Se of b){let O=o(Se);if(!O||O.nodeType!==1)return g("ancestor-live")}let ce=i.base===fn&&i.remote===fn&&s===pr,xe=new Set,te=new Set,J=[],Ce=null,we=Se=>{Se&&(xe.has(Se)?te.add(Se):xe.add(Se))},ne=(Se,O)=>{let B=m(Se),ae=B!==null?B:i.base(Se)||null;return ae!==(B!==null?B:i.remote(O)||null)?!1:(we(ae),!0)},_=(Se,O)=>{for(let B=Se.firstElementChild,ae=O.firstElementChild;B;B=B.nextElementSibling,ae=ae.nextElementSibling){let be=s(B);if(be!==s(ae))return!1;if(!be&&(!ne(B,ae)||!_(B,ae)))return!1}return!0},ye=Se=>{let O=Se+1<b.length?b[Se+1]:Q;for(let B=b[Se].firstElementChild,ae=A[Se].firstElementChild;B;B=B.nextElementSibling,ae=ae.nextElementSibling){if(B===O){let ze=Se+1<b.length?ye(Se+1):null;if(ze)return ze;continue}let be=s(B);if(be!==s(ae))return"outside-id-changed";if(be)continue;let de=o(B);if(!de||de.nodeType!==1)return"sibling-live";if(J.push([B,ae]),!ce&&(!ne(B,ae)||!_(B,ae)))return"outside-id-changed";Se===0&&B.tagName==="HEAD"&&h(B)&&(Ce=[B,ae])}return null},ge=ye(0);if(ge)return g(ge);let Oe=new Set(b),Be=null;if(i.base===fn){Be=[];for(let Se of e.querySelectorAll(So))Se===Q||Oe.has(Se)||(Q.contains(Se)?Be.push(Se):ce&&we(h(Se)))}let We=new Set,rt=new Set,re=new Set,ut=Xs(b,Q,h,s,xe,We,Be,rt),dt=Xs(A,se,d,s,xe,We,i.remote===fn&&se.querySelectorAll(So),re);return Ce&&(te.has(h(Ce[0]))||We.has(h(Ce[0])))&&(Ce=null),{scope:{chain:b,root:Q,onChain:Oe,baseIndex:ut,remoteIndex:dt,head:Ce,same:S,differ:L,dropped:[...Qs(e,h,s,te,rt,i.base),...Qs(t,d,s,te,re,i.remote)],held:Se=>{for(let O=1;O<b.length;O++)if(Se.map.get(b[O])!==A[O])return!1;for(let[O,B]of J)if(Se.map.get(O)!==B)return!1;return!0}}}}var Ca=Symbol("hyper-morph-duplicate-key");var Kc='[editor-ui],[clay~="editor-ui"],[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]',zc='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Gc='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Yc(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let t=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(t)}function Jc(e,t,n,o){if(t==null)return;if(typeof t=="string")return t;let r=t;if(r.nodeType===9){let i=e.getAttribute("id");r=i&&r.getElementById(i)||(e.tagName==="BODY"?r.body:e.tagName==="HTML"?r.documentElement:r.body&&r.body.firstElementChild)}if((!r||r.nodeType!==1||r.tagName!==e.tagName)&&(r=Xc(e,t,o)),!!r)return n?Array.from(r.childNodes):r}function Xc(e,t,n){let o=t.nodeType===9?t.documentElement:t;if(!o||o.nodeType!==1)return null;let r=new Map,i=[o,...o.querySelectorAll("script")];for(let a of i){let m=lo(a,n);m&&!r.has(m.key)&&r.set(m.key,a.textContent)}if(!r.size)return null;let c=e.cloneNode(!0),s=!1;for(let a of[c,...c.querySelectorAll("script")]){let m=lo(a,n);m&&r.has(m.key)&&(a.textContent=r.get(m.key),s=!0)}return s?c:null}function ei(e,t){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let n=t.implementation.createHTMLDocument(""),o=e.nodeType===1&&e.tagName==="HTML"?e:null;if(o)return n.replaceChild(n.adoptNode(o),n.documentElement),n;let r=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let i of r)n.body.appendChild(n.adoptNode(i));return n}function Hr(e,t,n={}){let o=n||{};if(!o.head?.block)return ti(e,t,o);try{return ti(e,t,o)}catch(r){return Promise.reject(r)}}function ti(e,t,n){let o=n.policy||"sync",r=o==="raw"?void 0:(a,m)=>Yc(a)||(o==="history"?!(m&&a.matches(Gc))&&a.matches(zc):a.matches(Kc)),i=n.callbacks||{},c={ignore:r,hooks:i,protectFocusedValue:n.ignoreActiveValue===!0?"subtree":!1,restoreFocus:n.restoreFocus!==!1,formState:n.formStateSync||"attribute",scripts:{execute:n.scripts?.handle!==!1,merge:n.scripts?.merge!==!1,mergeTags:n.scripts?.mergeTags||[]},head:{awaitLoads:!!n.head?.block,preserve:n.head?.shouldPreserve||(()=>!1)}};if(typeof n.key=="function"&&(c.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return No(Object.assign({},c,{live:e,base:n.scripts?.mergeBase||null,remote:ei(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let a=Object.assign({},c,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:ei(t,e.ownerDocument)});return No(a)}n.morphStyle==="innerHTML"&&(c.children=!0);let s=Jc(e,n.scripts?.mergeBase,!!c.children,c.scripts.mergeTags);return s!==void 0&&(c.base=s),Br(e,t,c)}var Qc=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),mn=()=>{};function Oo(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let c of Object.keys(e))if(!Qc.has(c))throw new TypeError(`unknown option "${c}"`);let n=Object.assign({beforeNodeAdded:mn,afterNodeAdded:mn,beforeNodeRemoved:mn,afterNodeRemoved:mn,beforeNodeMorphed:mn,afterNodeMorphed:mn,beforeAttributeUpdated:mn},e.hooks||{}),o=e.conflicts||"remote";if(!["remote","local","both"].includes(o))throw new TypeError("conflicts must be remote, local or both");let r=e.formState||"attribute";if(!["attribute","property"].includes(r))throw new TypeError("formState must be attribute or property");let i=e.protectFocusedValue;if(i!==void 0&&typeof i!="boolean"&&i!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");return{ignored:hr(e.ignore,t),remoteWins:hr(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:o,protectFocusedValue:i===void 0?!0:i,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:r,hooks:n,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0}}function fo(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return fn}function uo(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=mr(t,e.map),o=typeof e.then=="function"?e.then:fn;if(typeof e.first=="function"){let r=e.first;return i=>r(i)||n.get(i)||o(i)}return r=>n.get(r)||o(r)}return fn}function Zc(e,t,n,o={}){let r=A=>A&&A.nodeType===9?A.documentElement:A,i=r(t),c=r(n),s=r(e)||i,a=Object.assign({},o);delete a.live,delete a.base,delete a.remote;let m=Oo(a,[s,i,c].filter(Boolean)),h=o.identity||{},d=jn(),b=er(s,i,c,{identity:{base:uo(h.base,s),local:uo(h.local,i),remote:uo(h.remote,c)},authored:{base:fo(h.base),local:fo(h.local),remote:fo(h.remote)},skipUnchanged:m.hooks.beforeNodeMorphed===mn&&m.hooks.afterNodeMorphed===mn,ignored:m.ignored,remoteWins:m.remoteWins,ignoreAttribute:m.ignoreAttribute,conflicts:m.conflicts,mergeTags:m.scripts.merge===!1?null:m.scripts.mergeTags,baseURI:i.ownerDocument&&i.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:m.children,stats:d});return delete b.recoveryLinks,b}function Ur({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:o,toLive:r,options:i,identity:c,childrenOnly:s,isDocument:a}){let m=Oo(i,[e,t,n,o].filter(Boolean));if(m.ignored(e))return{report:_r(),loads:[]};let h=e.ownerDocument,d=m.scripts.execute?Ls(e,m.ignored,h.baseURI):null,b=jn(),A=m.hooks.beforeNodeMorphed===mn&&m.hooks.afterNodeMorphed===mn,S={identity:{base:uo(c.base,t||n),local:uo(c.local,n),remote:uo(c.remote,o)},authored:{base:fo(c.base),local:fo(c.local),remote:fo(c.remote)},ignored:m.ignored,remoteWins:m.remoteWins,ignoreAttribute:m.ignoreAttribute,conflicts:m.conflicts,mergeTags:m.scripts.merge===!1?null:m.scripts.mergeTags,baseURI:h.baseURI,localIsBase:!t,childrenOnly:s,skipUnchanged:A},L=m.fastPath&&a&&!s&&A&&t===n,f=null,g=null;if(L){let we=Zs({baseRoot:t,remoteRoot:o,liveRoot:e,toLive:r,o:m,identity:S.identity,baseURI:h.baseURI});S.comparisons=we.comparisons||we.scope,we.bail?g=we.bail:(f=er(t,n,o,Object.assign({},S,{stats:b,scope:we.scope})),f||(g="chain-unpaired",b=jn()))}f||(f=er(t||n,n,o,Object.assign({},S,{stats:b}))),L&&(b.fastPathAttempted=1,b.fastPathTaken=g?0:1,b.fastPathFallback=g),f.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(we=>m.hooks[we]!==mn)&&Ws(f.conflicts,f.recoveryLinks,r),m.beforeApply&&m.beforeApply(f.doc);let x=globalThis.__hyperMorphProfile,Q=x?performance.now():0,se=Js(e,f.root,f,{toLive:r,ignored:m.ignored,ignoreAttribute:m.ignoreAttribute,formState:m.formState,protectFocusedValue:m.protectFocusedValue,restoreFocus:m.restoreFocus,preserve:m.head.preserve,hooks:m.hooks,childrenOnly:s,keepLiveOnly:m.keepLiveOnly});x&&(x.apply=(x.apply||0)+(performance.now()-Q));let le=[];if(m.head.awaitLoads)for(let we of se.applied){if(we.kind!=="insert"||we.node.nodeType!==1)continue;let ne=we.node;ne.tagName==="LINK"&&/\bstylesheet\b/i.test(ne.getAttribute("rel")||"")&&ne.getAttribute("href")&&ne.closest("head")&&le.push(new Promise(ye=>{ne.addEventListener("load",()=>ye()),ne.addEventListener("error",()=>ye())}))}let q=null,z=null;if(d){let we=Rs(e,d,{ignored:m.ignored,skip:se.mergedScriptsLive,baseURI:h.baseURI,beforeNodeAdded:m.hooks.beforeNodeAdded,afterNodeAdded:m.hooks.afterNodeAdded,trackRecovery:!!f.recoveryLinks});le.push(...we.loads),q=we.swapped,z=we.vetoed}let ce=we=>q&&q.get(we)||we,xe=we=>{if(se.keptRuns.has(we))return se.runOf.get(we);let ne=se.liveOf.get(we)||se.heldBy.get(we)||se.insertedLive.get(we);return ne?ce(ne):null},te=we=>{let ne=we&&se.liveOf.get(we);return ne?ce(ne):null},J=we=>{let ne=we&&xe(we);return Array.isArray(ne)?ne[0]:ne};if(f.recoveryLinks){let we=(ne,_,ye)=>(_.namespaceURI?ne.getAttributeNS(_.namespaceURI,_.localName):ne.getAttribute(_.qualifiedName))===ye;Fs(f.conflicts,f.recoveryLinks,{lookup:xe,vetoed:se.vetoed,vetoedAttrs:se.vetoedAttrs,removedVetoes:se.removedVetoes,vetoedLive:z,liveAttr:we,ignored:m.ignored,liveRoot:e})}return{report:{applied:se.applied,decisions:f.decisions.map(we=>Object.assign({},we,{node:we.node?te(we.node):null,el:we.el?te(we.el):null,applied:!!(we.node?te(we.node):we.el&&te(we.el))})),conflicts:f.conflicts.map(we=>Object.assign({},we,{node:we.node?we.kind==="text"&&we.recovery.subject.nodeType===8?J(we.node):te(we.node):we.node,el:we.el?we.kind==="structure"?J(we.el):te(we.el):we.el})),localDiverged:f.localDiverged,identities:se.identities,moved:se.moved,replaced:se.replaced,stats:b},loads:le}}var ni=new WeakMap;function _r(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:jn()}}function No(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let o=ni.get(n);o||(o=dr(n),ni.set(n,o));let r=o("remote",t.remote),i=typeof t.base=="string"&&t.base===""?null:t.base,c=i?o("base",i):null,s=t.local?t.local.root:n.documentElement,a=t.local?t.local.toLive:d=>d;gs(n,r);let{report:m,loads:h}=Ur({liveRoot:n.documentElement,baseRoot:c?c.documentElement:null,localRoot:s,remoteRoot:r.documentElement,toLive:a,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(h).then(()=>m)}function el(e,t,n={}){return No(Object.assign({},n,{live:e,base:null,remote:t}))}function oi(e,t){if(e==null)return{root:t.createElement("template"),first:null};if(typeof e=="string"){let o=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(o){let i=Ko(e,t),c=o[1].toLowerCase()==="html"?i.documentElement:i.body;return{root:c,first:c}}let r=t.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let o=t.createElement("template"),r=e.isConnected;return o.content.appendChild(r?t.importNode(e,!0):e),{root:o,first:e}}if(e.nodeType===11){let o=t.createElement("template");return o.content.appendChild(e),{root:o,first:o.content.firstElementChild}}let n=t.createElement("template");for(let o of Array.from(e))n.content.appendChild(o.parentNode?t.importNode(o,!0):o);return{root:n,first:n.content.firstElementChild}}function Br(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let o=e.ownerDocument,{base:r,...i}=n,c=!!i.children;if(Oo(i,[e]).ignored(e))return Promise.resolve(_r());let s=oi(t,o),a=r!=null?oi(r,o):null,m,h=null;if(c)m=s.root,h=a?a.root:null;else{if(m=s.first,h=a?a.first:null,!m){let A=Oo(i);return A.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),A.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:jn()})}if(m.tagName!==e.tagName){let A=Oo(i,[e,m]);if(A.hooks.beforeNodeMorphed(e,m)===!1)return Promise.resolve(_r());let S=Ur({liveRoot:e,baseRoot:h&&h.tagName===e.tagName?h:null,localRoot:e,remoteRoot:m,toLive:f=>f,options:i,identity:i.identity||{},childrenOnly:!0,isDocument:!1}),L=tn(m)?To(m,o):o.importNode(m,!1);if(!tn(L))for(;e.firstChild;)L.appendChild(e.firstChild);return A.hooks.beforeNodeAdded(L)===!1?(Zo(S.report.conflicts,e,e),Promise.resolve(S.report)):A.hooks.beforeNodeRemoved(e)===!1?(Zo(S.report.conflicts,e,e),Promise.resolve(S.report)):(e.replaceWith(L),Zo(S.report.conflicts,e,L),A.hooks.afterNodeRemoved(e),A.hooks.afterNodeAdded(L),A.hooks.afterNodeMorphed(e,m),S.report.replaced.push(L),S.report.applied.push({kind:"insert",node:L,parent:L.parentNode},{kind:"remove",node:e,parent:L.parentNode}),Promise.all(S.loads).then(()=>S.report))}}let{report:d,loads:b}=Ur({liveRoot:e,baseRoot:h,localRoot:e,remoteRoot:m,toLive:A=>A,options:i,identity:i.identity||{},childrenOnly:c,isDocument:!1});return Promise.all(b).then(()=>d)}var ri={mergeDocument:No,morphDocument:el,morphElement:Br,merge3:Zc,morph:Hr};function Vr(e,t,{onWidgetRemoved:n}={}){ri.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=qo.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var nl="hha:upgrade-check:";function Sn(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function Wr(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function si(e,t){let n=Wr(e),o=Wr(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let c=n[i]||0,s=o[i]||0;if(c!==s)return c>s}return!1}function ol(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function rl(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function $r({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(b=>fetch(b)),r=r??Date.now(),!t)return null;let c=Sn(t,"hyper-source");if(!c)return null;let s=Sn(t,"hyper-version"),a;try{a=new URL(c,n?n.href:void 0)}catch{return null}if(n&&a.origin===n.origin&&a.pathname===n.pathname)return null;let m=`${nl}${a.href}:${s||"none"}`,h,d=e?null:ol(m);if(d&&typeof d.checkedAt=="number"&&r-d.checkedAt<i)h=d.sourceVersion;else{try{let b=await o(a.href);if(!b.ok)throw new Error(`HTTP ${b.status}`);let A=await b.text(),S=new DOMParser().parseFromString(A,"text/html");h=Sn(S,"hyper-version")}catch{h=null}rl(m,{checkedAt:r,sourceVersion:h})}return h?{available:si(h,s||"0.0.0"),currentVersion:s,sourceVersion:h,sourceUrl:a.href}:null}var tr=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],qr=new Set(tr),ii=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Fr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var or={};cr(or,{EmptyListInsert:()=>Mo,MAX_RULE_DEPTH:()=>ho,MaxRuleDepthExceeded:()=>Yn,NoRulesTag:()=>Kr,RuleTargetReadOnly:()=>Eo,RulesParseError:()=>po,ShapeMismatch:()=>vo,UnknownRulesVersion:()=>Gn,WriteRefused:()=>nr,WriteRejected:()=>zr});var po=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},Gn=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},ho=20,Yn=class extends Error{constructor(t){super(`rule depth exceeded ${ho} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},vo=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},Mo=class extends Error{constructor(t){super(`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},Eo=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},nr=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}},Kr=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},zr=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};function Nn(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Gr(e,t,n,{depth:0,path:[]},o)}function Gr(e,t,n,o,r){if(o.depth>ho)throw new Yn(o.path);if(typeof n=="string")return sl(e,t,n,o,r);if(Array.isArray(n)){let[i,c]=n,s=e.find(t,i,r);return li(r,o,s),s.map((a,m)=>Gr(e,a,c,{depth:o.depth+1,path:[...o.path,m]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[c,s]of Object.entries(n))i[c]=Gr(e,t,s,{depth:o.depth+1,path:[...o.path,c]},r);return i}return null}function sl(e,t,n,o,r){if(n.endsWith("[]")){let s=n.slice(0,-2),a=e.find(t,s,r);return li(r,o,a),a.map(m=>e.text(m))}if(n.startsWith("@"))return ci(e,t,n.slice(1));let i=Mn(n);if(i!==-1){let s=n.slice(0,i),a=n.slice(i+1),m=s?e.find(t,s,r):[t];return m.length===0?null:ci(e,m[0],a)}if(n===".")return e.text(t);let c=e.find(t,n,r);return c.length===0?null:e.text(c[0])}function li(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function ci(e,t,n){if(qr.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}var ai=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),il=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),fi=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function Yr(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function cl(e,t){if(Yr(e,t))return!0;for(let[n,o]of Object.entries(il))if(o.includes(t)&&Yr(e,n))return!0;return!1}function Io(e){let t=ai[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function ll(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=ai[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>cl(n,r))||o.bundles.some(r=>Yr(n,r)))return n;n=n.parentElement}return null}function ui(e,t){return!!ll(e,t)}var al=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function di(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)t.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function pi(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function hi(e,t,n,o,r,i,c,s){if(e.nodeType===1&&((c?ui(e,n):pi(e,o,i,!1))||r&&(c&&e!==i?e.matches(r):pi(e,r,i,c))))return null;let a=t.importNode(e,!1);s.cloneToLive.set(a,e),s.liveToClone.set(e,a);let m=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,h=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;m!==e&&(s.cloneToLive.set(h,m),s.liveToClone.set(m,h));for(let d of m.childNodes||[]){let b=hi(d,t,n,o,r,i,c,s);b&&(h.appendChild(b),d.nodeType===1&&di(d,b))}return e.nodeType===1&&di(e,a),a}function Co(e,{capability:t="data",exclude:n=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=r.implementation.createHTMLDocument(""),c=new WeakMap,s=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let m=Io(t),h=hi(a,i,t,m,n,a,o,{cloneToLive:c,liveToClone:s});e.nodeType===9&&h&&(i.replaceChild(h,i.documentElement),s.set(e,i),c.set(i,e));let d=b=>{if(al.test(b))throw new Error(`Filtered content queries do not support stateful selector: ${b}`)};return{root:h,document:i,capability:t,selector:Io(t),cloneToLive:c,liveToClone:s,original(b){return c.get(b)||null},cloneOf(b){return s.get(b)||null},query(b,A=h){return d(b),Array.from(A.querySelectorAll(b),S=>c.get(S)||S)},text(b=h){return(b===h?h:s.get(b))?.textContent||""},html(b=h){return(b===h?h:s.get(b))?.innerHTML??""},clone(b=h){let A=b===h?h:s.get(b);return A?i.importNode(A,!0):null}}}function mi(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function fl(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var $t={semanticExclude:!0,find(e,t,n={}){let o=fl(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(s=>!mi(s)));let i=[];n.skip&&i.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&i.push("["+c+"]"),i.length){let s=i.join(", ");r=r.filter(a=>!a.closest||!a.closest(s))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Jn(e,t={}){if(t.exclude===null)return $t;let n=[Io("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return $t;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,s=null,a=()=>s||(s=Co(i,{capability:"data",exclude:t.exclude||null})),m=S=>{let L=a();return S===e?L.cloneOf(e):L.cloneOf(S)||S},h=S=>s?.original(S)||S,d=(S,L)=>{a().liveToClone.set(S,L),a().cloneToLive.set(L,S);let f=S.childNodes||[],g=L.childNodes||[];for(let x=0;x<Math.min(f.length,g.length);x++)d(f[x],g[x])},b=(S,L,f,g)=>{let x=Array.from(S.childNodes).filter(z=>s.cloneOf(z)),se=x[0];for(;se&&x.includes(se);)se=se.nextSibling;for(let z of x)z.remove();if(f==="innerHTML"){let z=c.createElement("template");z.innerHTML=g;for(let ce of Array.from(z.content.childNodes))S.insertBefore(ce,se||null)}else S.insertBefore(c.createTextNode(g),se||null);let le=Co(S,{capability:"data",exclude:t.exclude||null});L.replaceChildren(...Array.from(le.root?.childNodes||[]));let q=z=>{let ce=le.original(z);ce&&(s.liveToClone.set(ce,z),s.cloneToLive.set(z,ce));for(let xe of Array.from(z.childNodes||[]))q(xe)};for(let z of Array.from(L.childNodes))q(z)},A={...$t,find(S,L,f={}){let g=m(S);if(!g?.querySelectorAll)return[];let x=a().query(L,g);f.includeRulesTag||(x=x.filter(le=>!mi(le)));let Q=[];f.skip&&Q.push(f.skip);let se=f.templateAttr===null?null:f.templateAttr||"cms-template";if(se&&Q.push(`[${se}]`),Q.length){let le=Q.join(", ");x=x.filter(q=>!q.closest?.(le))}return x},parent(S){let L=m(S)?.parentElement;return L?h(L):null},children(S){return Array.from(m(S)?.children||[],h)},text(S,L){if(L===void 0){let x=h(S);return!x?.matches?.(n)&&!x?.querySelector?.(n)?$t.text(x):(m(S)?.textContent||"").trim()}let f=h(S);if(!f?.matches?.(n)&&!f?.querySelector?.(n)&&!s){$t.text(f,L);return}let g=a().cloneOf(f);g?b(f,g,"textContent",L):$t.text(f,L)},attr(S,L,f){let g=h(S);if(f===void 0)return $t.attr(g,L);$t.attr(g,L,f);let x=s?.cloneOf(g);x&&($t.attr(x,L,f),Co(g,{capability:"data",exclude:t.exclude||null}).root===null&&(x.remove(),s.liveToClone.delete(g),s.cloneToLive.delete(x)))},removeAttr(S,L){let f=h(S);$t.removeAttr(f,L);let g=s?.cloneOf(f);g&&$t.removeAttr(g,L)},prop(S,L,f){let g=h(S);if(f===void 0)return L==="innerHTML"||L==="outerHTML"||L==="textContent"||L==="innerText"?$t.prop(m(g),L):$t.prop(g,L);let x=L==="innerHTML"||L==="textContent"||L==="innerText",Q=x?a().cloneOf(g):s?.cloneOf(g);Q&&x?b(g,Q,L,f):($t.prop(g,L,f),Q&&$t.prop(Q,L,f))},clone(S){let L=m(S);return L===S?$t.clone(S):c.importNode(L,!0)},insertAt(S,L,f){let g=h(S),Q=A.children(g)[f]||(()=>{for(let q=g.children.length-1;q>=0;q--){let z=g.children[q];if(a().cloneOf(z))return z.nextElementSibling}return g.firstElementChild})(),se=h(L);g.insertBefore(se,Q||null);let le=a().cloneOf(g);if(le){let q=a().cloneOf(se);q||(q=c.importNode(se,!0),d(se,q));let z=Array.from(le.children);le.insertBefore(q,z[f]||null)}},remove(S){let L=h(S),f=a().cloneOf(L);$t.remove(L),f&&$t.remove(f)},replaceWith(S,L){let f=h(S),g=a().cloneOf(f),x=$t.replaceWith(f,L);if(g){let Q=Co(x,{capability:"data",exclude:t.exclude||null});if(!Q.root)g.remove();else{g.replaceWith(Q.root);let se=le=>{let q=Q.original(le);q&&(s.liveToClone.set(q,le),s.cloneToLive.set(le,q));for(let z of Array.from(le.childNodes||[]))se(z)};se(Q.root)}}return x}};return A}var gn=$t;function Jr(e){try{return JSON.parse(e)}catch(t){throw new po(`Invalid strict JSON: ${t.message}`,t)}}function Xn(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let i=[],c=0;for(;c<r.length;){let s=r[c];if(/\s/.test(s)){c++;continue}if("{}".includes(s)){i.push({type:s,value:s}),c++;continue}if(s==="["){let d=!1,b=c+1;for(;b<r.length&&/\s/.test(r[b]);)b++;if(b<r.length&&/[a-zA-Z_]/.test(r[b])&&(d=!0),!d){i.push({type:s,value:s}),c++;continue}}if(s==="]"){i.push({type:s,value:s}),c++;continue}if(s===":"){i.push({type:t.COLON,value:s}),c++;continue}if(s===","){i.push({type:t.COMMA,value:s}),c++;continue}if(s==='"'||s==="'"){let d=s,b=c+1;for(;b<r.length&&r[b]!==d;)r[b]==="\\"&&b++,b++;i.push({type:t.STRING,value:r.substring(c+1,b),quoted:!0,sourceQuote:d}),c=b+1;continue}let a=c,m;for(;a<r.length&&!/[{},]/.test(r[a]);)if(r[a]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],b=!1;for(let A of d){let S=A.substring(1);if(r.substring(a+1,a+1+S.length)===S){b=!0,a+=S.length;break}}if(!b)break}else if(r[a]==="["){for(a++;a<r.length&&r[a]!=="]";){if(r[a]==='"'||r[a]==="'"){let d=r[a];for(a++;a<r.length&&r[a]!==d;)r[a]==="\\"&&a++,a++}a++}a<r.length&&r[a]==="]"&&a++}else a++;m=r.substring(c,a);let h=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(m)?h=t.NUMBER:m==="true"||m==="false"||m==="null"?h=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(m)&&(h=t.SELECTOR),i.push({type:h,value:m,quoted:!1}),c=a}return i}function o(r){let i="";for(let c=0;c<r.length;c++){let s=r[c];if("{}".includes(s.type)||"[]".includes(s.type)){i+=s.value;continue}if(s.type===t.COLON){i+=s.value;continue}if(s.type===t.COMMA){let a=r[c+1];if(a&&(a.type==="}"||a.type==="]"))continue;i+=s.value;continue}if(s.type===t.STRING&&s.quoted){let a=s.value;s.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(m,h)=>h.length%2===0?h+'\\"':m)),i+=`"${a}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){i+=s.value;continue}if(s.type===t.SELECTOR||s.type===t.IDENTIFIER){i+=`"${s.value}"`;continue}i+=`"${s.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new po("Invalid extraction rules syntax: "+r.message,r)}}var Xr="1",gi=/^[a-zA-Z0-9_-]+$/;function mo(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!gi.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${gi})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],c=e.attr(i,"data-rules-version");if(c!==Xr)throw new Gn(c);return{rules:Xn(e.text(i)),tagNode:i}}var ul="script[data-rules-name]";function bi(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function Lo(e,t){let n=e.find(t,ul,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let c=bi(e.attr(i,"data-rules-name"));if(!c)continue;if(o.has(c)){console.warn(`hyper-html-api: duplicate rules tag name "${c}"; using the first.`);continue}let s=e.attr(i,"data-rules-version");if(s!==Xr)throw new Gn(s);o.add(c),r.push({name:c,rules:Xn(e.text(i))})}return r}function rr(e,t){let n={};for(let{name:o,rules:r}of Lo(e,t))n[o]=Nn(e,t,r);return n}function Qr(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:rr(gn,t),version:Sn(n,"hyper-version")}}var go=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},Ro=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},Un=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},Po=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var yi="text/hyper-upgrade";function Zr(e,t){let n=e.find(t,`script[type="${yi}"]`);if(n.length===0)return null;if(n.length>1)throw new Po(n.length);return e.text(n[0])||null}var dl=new Function("url","return import(url)");async function es(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await dl(n)}catch(r){throw new Un(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new Un("transform must `export default` a function");return o.default}function xi(e,t,n,o){let r=e.length,i=t.length,c=new Array(r).fill(-1);if(o){let f=new Set;for(let g=0;g<r;g++){let x=o[g];!(x>=0&&x<i)||f.has(x)||(c[g]=x,f.add(x))}}if(r===0||i===0)return c;let s=e.map(f=>ki(f,n)),a=t.map(f=>ki(f,n)),m=new Array(i).fill(!1);for(let f of c)f>=0&&(m[f]=!0);let h=new Map;a.forEach((f,g)=>{m[g]||h.set(f,h.has(f)?-1:g)});let d=new Map;s.forEach((f,g)=>{c[g]>=0||d.set(f,(d.get(f)||0)+1)}),s.forEach((f,g)=>{if(c[g]>=0||d.get(f)!==1)return;let x=h.get(f);x===void 0||x===-1||m[x]||(c[g]=x,m[x]=!0)});let b=[];for(let f=0;f<r;f++)c[f]<0&&b.push(f);let A=[];for(let f=0;f<i;f++)m[f]||A.push(f);if(b.length===0||A.length===0)return c;let S=r*i+1,L=(f,g)=>pl(e[f],t[g],n)*S+Math.abs(f-g);for(let[f,g]of hl(b,A,L))c[f]=g;return c}var Ti=e=>typeof e=="object"&&e!==null;function ki(e,t){if(!Ti(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function pl(e,t,n){if(!Ti(n))return e===t?0:1;let o=Object.keys(n);if(o.length===0)return 0;let r=0;for(let i of o){let c=JSON.stringify(e?.[i]),s=JSON.stringify(t?.[i]);c!==s&&r++}return r}function hl(e,t,n){return e.length<=t.length?wi(e,t,n,!1):wi(t,e,(o,r)=>n(r,o),!0)}function wi(e,t,n,o){let r=e.length,i=t.length,c=[];for(let d=0;d<=r;d++)c.push(new Float64Array(i+1).fill(1/0));let s=[];for(let d=0;d<=r;d++)s.push(new Uint8Array(i+1));for(let d=0;d<=i;d++)c[r][d]=0;for(let d=r-1;d>=0;d--)for(let b=i-1;b>=0;b--){let A=n(e[d],t[b])+c[d+1][b+1],S=c[d][b+1];A<=S?(c[d][b]=A,s[d][b]=1):c[d][b]=S}let a=[],m=0,h=0;for(;m<r&&h<i;)s[m][h]&&(a.push(o?[t[h],e[m]]:[e[m],t[h]]),m++),h++;return a}function ns(e,t,n,o,r,i,c,s={}){let a=e.find(t,n,s);if(r.length===0){a.forEach(le=>e.remove(le)),ts(s,"onRowsApplied",i.path,[]);return}let m=r.length>a.length,h=a[0]||null;if(m&&!h&&(h=yl(e,t,n,s),!h))throw new Mo(i.path);let d=a.map(le=>bl(e,le,o,s)),b=null;if(m&&h){b=e.clone(h),s.templateAttr&&e.removeAttr(b,s.templateAttr);let le=e.stripIds(b);le>0&&console.warn(`[hyper-html-api] stripped ${le} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let A=xi(r,d,o,ml(e,a,r,i,s)),S=a[0]||h,L=e.parent(S),f=a.length>0?Ai(e,L,S):0,g=kl(e,a),x=new Set,Q=[],se=r.map((le,q)=>{let z=A[q];if(z>=0)return x.add(z),Q.push(!1),a[z];Q.push(!0);let ce=e.clone(b);return e.stripIds(ce),ce});a.forEach((le,q)=>{x.has(q)||e.remove(le)}),g?se.forEach((le,q)=>{let z=f+q;e.children(L).findIndex(te=>e.sameNode(te,le))!==z&&e.insertAt(L,le,z)}):wl(e,se,Q,L,f),gl(e,se,o,r,i,c,s),ts(s,"onRowsApplied",i.path,se)}function ts(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function ml(e,t,n,o,r){let i=ts(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let c=new Array(n.length).fill(-1),s=new Set;for(let a=0;a<n.length;a++)if(i[a]){for(let m=0;m<t.length;m++)if(!(s.has(m)||!e.sameNode(t[m],i[a]))){c[a]=m,s.add(m);break}}return c}function gl(e,t,n,o,r,i,c){t.forEach((s,a)=>{if(n===null){let m=o[a],h=m==null?"":String(m);e.text(s)!==h&&e.text(s,h)}else{let m=i(e,s,n,o[a],{depth:r.depth+1,path:[...r.path,a]},c);m&&m!==s&&(t[a]=m)}})}function bl(e,t,n,o){return n===null?e.text(t):Nn(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Ai(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function yl(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let i=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let c of i)if(e.attr(c,o.templateAttr)!=null)return c;r=e.parent(r)}return null}function kl(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=e.children(n),r=[];for(let i of t){let c=o.findIndex(s=>e.sameNode(s,i));if(c===-1)return!1;r.push(c)}return r.sort((i,c)=>i-c),r[r.length-1]-r[0]===r.length-1}function wl(e,t,n,o,r){let i=null,c=r;for(let s=0;s<t.length;s++){if(!n[s]){i=t[s];continue}let a=i?e.parent(i):o;if(!a)continue;let m=i?Ai(e,a,i)+1:c++;e.insertAt(a,t[s],m),i=t[s]}}var Si=new Set(["checked","selected","disabled","readOnly","paused"]);function _n(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let i=[];if(os(n,o,[],i),i.length)throw new vo(i);sr(e,t,n,o,{depth:0,path:[]},r)}function sr(e,t,n,o,r,i={}){if(r.depth>ho)throw new Yn(r.path);if(o===void 0)return t;if(typeof n=="string")return xl(e,t,n,o,r,i);if(Array.isArray(n)){let[c,s]=n;return ns(e,t,c,s,o,r,sr,i),t}if(typeof n=="object"&&n!==null){for(let[c,s]of Object.entries(n)){let a=sr(e,t,s,o==null?o:o[c],{depth:r.depth+1,path:[...r.path,c]},i);a&&a!==t&&(t=a)}return t}return t}function xl(e,t,n,o,r,i){if(n.endsWith("[]")){let a=n.slice(0,-2);return ns(e,t,a,null,o,r,sr,i),t}if(n.startsWith("@"))return Oi(e,t,n.slice(1),o);let c=Mn(n);if(c!==-1){let a=n.slice(0,c),m=n.slice(c+1),h=a?e.find(t,a,i):[t];return h.length===0||Oi(e,h[0],m,o),t}if(n===".")return Ni(e,t,o),t;let s=e.find(t,n,i);return s.length===0||Ni(e,s[0],o),t}function Ni(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Oi(e,t,n,o){if(Fr.has(n)){let i=e.prop(t,n);if(i===o||i!=null&&o!=null&&String(i)===String(o))return t;throw new Eo(n)}if(n==="outerHTML"){let i=o==null?"":String(o);return e.replaceWith(t,i)}if(ii.has(n)){let i=Tl(n,o);return e.prop(t,n)!==i&&e.prop(t,n,i),t}let r=o==null?"":String(o);return e.attr(t,n)!==r&&e.attr(t,n,r),t}function Tl(e,t){return t==null?Si.has(e)?!1:"":Si.has(e)?t==="false"?!1:!!t:t}function os(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:Do([...n,i]),expected:"scalar",got:jo(r)})}):o.push({path:Do(n),expected:"array",got:jo(t)});return}t!==null&&typeof t=="object"&&o.push({path:Do(n),expected:"scalar",got:jo(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:Do(n),expected:"array",got:jo(t)});return}let r=e[1];t.forEach((i,c)=>os(r,i,[...n,c],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:Do(n),expected:"object",got:jo(t)});return}for(let[r,i]of Object.entries(e))os(i,t[r],[...n,r],o)}}}function jo(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Do(e){return e.join(".")}function Ho(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=rs(t,e,n);return ss(t,e,n),{data:o,summary:n}}function rs(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>rs(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,i]of Object.entries(e)){let c=rs(i,t?.[r],n);c!==void 0&&(o[r]=c)}return o}}function ss(e,t,n){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let r of Object.keys(t))o.has(r)?ss(e[r],t[r],n):n.discarded+=Qn(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>ss(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=Qn(t))}}function Qn(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+Qn(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+Qn(n),0):1}function is(e,t,n){let o=Lo(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},c=new Set;for(let{name:s,rules:a}of o){if(c.add(s),!Object.prototype.hasOwnProperty.call(n,s)){i[s]={carriedOver:0,discarded:0,listItems:0};continue}let{data:m,summary:h}=Ho(n[s],a);_n(e,t,a,m),i[s]=h,r.carriedOver+=h.carriedOver,r.discarded+=h.discarded,r.listItems+=h.listItems}for(let s of Object.keys(n))c.has(s)||(r.discarded+=Qn(n[s]));return{totals:r,byName:i,rulesTagCount:o.length}}async function cs({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(g=>fetch(g)),!o)throw new Error("upgrade.run requires a document context");if(e=e||Sn(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let c=new URL(e,r?r.href:void 0);n=n!==void 0?n:Sn(o,"hyper-version"),t=t||rr(gn,o);let s;try{s=await i(c.href)}catch(g){throw new go(c.href,g)}if(!s.ok)throw new go(c.href,new Error(`HTTP ${s.status}`));let a=await s.text(),m=new DOMParser().parseFromString(a,"text/html"),h=Sn(m,"hyper-version"),d=t,b=!1,A=Zr(gn,m);if(A){let x=await(await es(A))(d,{fromVersion:n,toVersion:h});if(!x||typeof x!="object"||Array.isArray(x))throw new Un("transform must return a plain object map of { rulesName: data }");d=x,b=!0}let{totals:S,byName:L,rulesTagCount:f}=is(gn,m,d);if(f===0&&Object.keys(d).length>0)throw new Ro(c.href);return{html:Al(m),fromVersion:n,toVersion:h,summary:{transformApplied:b,totals:S,byName:L}}}function Al(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
6
|
+
`+e.documentElement.outerHTML}var Nl=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...fi],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]});function ls(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return mo(e,o,n)}return null}var Bo={extract:(e,t,n={})=>Nn(Jn(e,n),e,t,n),apply:(e,t,n,o={})=>_n(Jn(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>mo(gn,e,t),findRules:(e,t)=>ls(gn,e,t),bind:(e,t,n={})=>{let o=ls(gn,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>Nn(Jn(e,n),e,o.rules,n),set:r=>_n(Jn(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:Jr,parseRelaxed:Xn,ruleAttrIndex:Mn,splitRule:to,errors:or,DOM_PROPERTIES:tr},as=e=>!!e&&typeof e.nodeType=="number";function vi(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=gn.find(t,"script[data-rules-name]",{includeRulesTag:!0});if(n.length===0)throw new Error('hyper-html-api: no rules tag found. Add <script type="application/json" data-rules-name="\u2026" data-rules-version="1"> or pass rules.');if(n.length>1)throw new Error('hyper-html-api: multiple rules tags found; pass a name, e.g. extractData("api").');return mo(gn,t).rules}function fs(e,t){let n=as(e)?e:document,o=as(e)?t:e;return o===void 0?Nn(Jn(n),n,vi(n)):Bo.bind(n,o).get()}function us(e,t,n){if(!as(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");return n===void 0?_n(Jn(e),e,vi(e),t):Bo.bind(e,n).set(t),e}var Mi={buildForm:ar,bindFormEvents:fr,scaffold:eo,morphForm:Vr,path:$o},Ei={checkForUpdate:$r,run:cs,extractAll:Qr,shapeMatch:Ho};var vl={engine:Bo,cms:Mi,upgrade:Ei,extractData:fs,applyData:us},Ml=vl;return Pi(El);})();
|