hyper-html-api 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +4 -1
  2. package/conformance/MANIFEST.json +2 -2
  3. package/conformance/cases/all-matches-read-quoted.expected.json +3 -0
  4. package/conformance/cases/all-matches-read-quoted.html +5 -0
  5. package/conformance/cases/all-matches-read-quoted.meta +7 -0
  6. package/conformance/cases/all-matches-read-quoted.parsed.json +3 -0
  7. package/conformance/cases/all-matches-read.expected.json +3 -0
  8. package/conformance/cases/all-matches-read.html +6 -0
  9. package/conformance/cases/all-matches-read.meta +7 -0
  10. package/conformance/cases/all-matches-read.parsed.json +3 -0
  11. package/conformance/cases/write-all-matches-attr.after.html +1 -0
  12. package/conformance/cases/write-all-matches-attr.after.json +3 -0
  13. package/conformance/cases/write-all-matches-attr.data.json +1 -0
  14. package/conformance/cases/write-all-matches-attr.html +1 -0
  15. package/conformance/cases/write-all-matches-attr.meta +6 -0
  16. package/conformance/cases/write-all-matches-attr.write.json +4 -0
  17. package/conformance/cases/write-all-matches-group.after.html +1 -0
  18. package/conformance/cases/write-all-matches-group.after.json +3 -0
  19. package/conformance/cases/write-all-matches-group.data.json +1 -0
  20. package/conformance/cases/write-all-matches-group.html +1 -0
  21. package/conformance/cases/write-all-matches-group.meta +6 -0
  22. package/conformance/cases/write-all-matches-group.write.json +4 -0
  23. package/conformance/cases/write-all-matches-text.after.html +1 -0
  24. package/conformance/cases/write-all-matches-text.after.json +3 -0
  25. package/conformance/cases/write-all-matches-text.data.json +1 -0
  26. package/conformance/cases/write-all-matches-text.html +1 -0
  27. package/conformance/cases/write-all-matches-text.meta +6 -0
  28. package/conformance/cases/write-all-matches-text.write.json +4 -0
  29. package/conformance/cases/write-all-matches-unmatched.data.json +1 -0
  30. package/conformance/cases/write-all-matches-unmatched.error.json +14 -0
  31. package/conformance/cases/write-all-matches-unmatched.html +1 -0
  32. package/conformance/cases/write-all-matches-unmatched.meta +6 -0
  33. package/dist/hyper-html-api.engine.esm.js +1 -1
  34. package/dist/hyper-html-api.engine.min.js +1 -1
  35. package/dist/hyper-html-api.min.js +8 -8
  36. package/dist/hyper-html-api.upgrade.min.js +2 -2
  37. package/package.json +3 -2
  38. package/src/engine/apply.js +6 -7
  39. package/src/engine/extract.js +6 -3
  40. package/src/engine/round-trip.js +9 -1
  41. package/src/engine/rule-syntax.js +13 -3
  42. package/src/engine/write-plan.js +2 -3
  43. package/src/page.js +15 -5
  44. package/src/site.js +164 -0
  45. package/src/upgrade/migrate.js +2 -1
  46. package/src/upgrade/shape-match.js +32 -13
  47. package/src/write.js +1 -1
@@ -1,8 +1,8 @@
1
- var HyperHtmlApi=(()=>{var Yr=Object.defineProperty;var xc=Object.getOwnPropertyDescriptor;var kc=Object.getOwnPropertyNames;var Ac=Object.prototype.hasOwnProperty;var Jr=(e,t)=>{for(var n in t)Yr(e,n,{get:t[n],enumerable:!0})},Tc=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of kc(t))!Ac.call(e,r)&&r!==n&&Yr(e,r,{get:()=>t[r],enumerable:!(o=xc(t,r))||o.enumerable});return e};var Sc=e=>Tc(Yr({},"__esModule",{value:!0}),e);var gu={};Jr(gu,{applyData:()=>mi,cms:()=>bc,default:()=>mu,engine:()=>gr,extractData:()=>pi,upgrade:()=>yc});var Ar={};Jr(Ar,{fromString:()=>kr,getRuleAtPath:()=>Zr,getValueAtPath:()=>Ko,parseConfigKey:()=>vc,setAtPath:()=>zn,toConfigKey:()=>Nc,toString:()=>mn});function mn(e){return e.map(String).join(".")}function Nc(e){return e.map(t=>typeof t=="number"?"*":String(t)).join(".")}function vc(e){return e===""?[]:e.split(".")}function kr(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function Zr(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 zn(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]=zn(i[o],r,n),i}return{...e&&typeof e=="object"?e:{},[o]:zn((e||{})[o],r,n)}}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"],xo=new Set(Tr),Qr=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),zo=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),bi=new Set(["checked","selected","disabled","readOnly","paused"]);function es(e,t){return t==null?bi.has(e)?!1:"":bi.has(e)?t==="false"?!1:!!t:t}function gn(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 Vn(e){let t=gn(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function ts(e){let t=0,n=null,o=-1,r=!1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=i:t===0&&s===","&&(r=!0)}return r||o===-1||!Oc(e,o+1)?null:e.slice(0,o).trim()||null}function Oc(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,i=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(i)s===i&&(i=null);else if(s==='"'||s==="'")i=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}function ko(e,t){if(typeof e=="string")return e.endsWith("[]")?[]:Mc(e)?Ec(t,Vn(e).prop)?"":null:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let n={};for(let[o,r]of Object.entries(e))n[o]=ko(r,t);return n}return""}function Mc(e){let{prop:t}=Vn(e);return t!==null&&!xo.has(t)}function Ec(e,t){if(!e||!t)return!1;let n=Ic(e),o=t.toLowerCase();for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]==="["){let i=n.indexOf("]",r);if(i===-1)return!1;let s=/^\s*([^\s\]=~^|*$]+)/.exec(n.slice(r+1,i));if(s&&s[1].toLowerCase()===o)return!0;r=i}return!1}function Ic(e){let t=0,n=null,o=0;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--:t===0&&(i===">"||i==="+"||i==="~"||/\s/.test(i))&&(o=r+1)}return e.slice(o)}var Sr=new WeakMap;var Cc=new Set(["checked","selected","disabled","readOnly","paused"]);function ns({rules:e,data:t,appRoot:n,cmsRoot:o}){let r=document.createDocumentFragment(),i={rules:e,appRoot:n,cmsRoot:o};return r.appendChild(rs({rule:e,value:t,path:[],ctx:i})),r}function os(e,{rules:t,getData:n,onChange:o}){e.setAttribute("data-hha-form-root",""),xi.set(e,{rules:t,getData:n,onChange:o}),Rc()}var xi=new WeakMap,yi=!1;function Rc(){yi||(document.addEventListener("input",wi,!0),document.addEventListener("change",wi,!0),document.addEventListener("click",Lc,!0),yi=!0)}function ki(e){if(!(e instanceof Element))return null;let t=e.closest("[data-hha-form-root]");return t&&xi.get(t)||null}function Lc(e){if(!(e.target instanceof Element))return;let t=e.target.closest("[data-hha-action]");if(!t||e.defaultPrevented)return;let n=ki(t);if(!n)return;let{rules:o,getData:r,onChange:i}=n,s=t.getAttribute("data-hha-action"),c=kr(t.getAttribute("data-hha-path")||"");if(s==="scalar-array-add"){let l=Ko(r(),c)||[];i(zn(r(),c,[...l,""]),{structural:!0});return}if(s==="object-array-add"){let l=Zr(o,c);if(!Array.isArray(l))return;let a=Ko(r(),c)||[];i(zn(r(),c,[...a,ko(l[1],l[0])]),{structural:!0});return}if(s==="array-remove"){if(c.length===0)return;let l=c.slice(0,-1),a=c[c.length-1],p=Ko(r(),l)||[];if(typeof a!="number")return;let f=p.filter((h,w)=>w!==a);i(zn(r(),l,f),{structural:!0})}}function wi(e){let t=e.target;if(!t?.matches?.("input, textarea, select"))return;let n=ki(t);if(!n)return;let{getData:o,onChange:r}=n,i=t.closest("[data-hha-path]");if(!i)return;let s=kr(i.getAttribute("data-hha-path")||""),c=t.type==="checkbox"?t.checked:t.value;r(zn(o(),s,c),{structural:!1})}function rs({rule:e,value:t,path:n,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?Dc({rule:e,value:t,path:n,ctx:o}):jc({rule:e,value:t,path:n,ctx:o});if(Array.isArray(e))return Bc({rule:e,value:t,path:n,ctx:o});if(typeof e=="object"&&e!==null)return Pc({rule:e,value:t,path:n,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function Pc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",mn(n)),n.length>0){let i=document.createElement("div");i.className="form-section-label",i.textContent=Nr(n[n.length-1]),r.appendChild(i)}for(let[i,s]of Object.entries(e)){let c=[...n,i],l=t?.[i];r.appendChild(rs({rule:s,value:l,path:c,ctx:o}))}return r}function jc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",mn(n));let i=document.createElement("div");i.className="field-body";let s=document.createElement("label");s.className="field-label",s.textContent=Nr(n[n.length-1]||".")+_c(e);let c=Hc(e,o.appRoot),l=Uc(c,{value:t,rule:e,path:n,appRoot:o.appRoot}),a=l.el;return a.classList.add(c.type==="textarea"?"field-textarea":"field-input"),i.appendChild(s),i.appendChild(a),r.appendChild(i),Sr.set(r,l),r}function Dc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",mn(n));let i=document.createElement("div");i.className="form-section-label",i.textContent=Nr(n[n.length-1]),r.appendChild(i);let s=Array.isArray(t)?t:[],c=document.createElement("div");r.appendChild(c),s.forEach((a,p)=>{let f=[...n,p],h=document.createElement("div");h.className="scalar-array-row",h.setAttribute("data-hha-path",mn(f));let w=document.createElement("input");w.type="text",w.className="field-input",w.value=a==null?"":String(a);let b=document.createElement("button");b.type="button",b.className="array-remove",b.textContent="\xD7",b.title="remove",b.setAttribute("data-hha-action","array-remove"),b.setAttribute("data-hha-path",mn(f)),h.appendChild(w),h.appendChild(b),c.appendChild(h)});let l=document.createElement("button");return l.type="button",l.className="array-add",l.textContent="+ add",l.setAttribute("data-hha-action","scalar-array-add"),l.setAttribute("data-hha-path",mn(n)),r.appendChild(l),r}function Bc({rule:e,value:t,path:n,ctx:o}){let[,r]=e,i=Array.isArray(t)?t:[],s=document.createElement("div");s.className="form-section",s.setAttribute("data-hha-path",mn(n));let c=document.createElement("div");c.className="form-section-label",c.textContent=Nr(n[n.length-1]),s.appendChild(c),i.forEach((a,p)=>{let f=[...n,p],h=document.createElement("div");h.className="array-card",h.setAttribute("data-hha-path",mn(f));let w=document.createElement("button");w.type="button",w.className="array-remove",w.textContent="\xD7",w.title="remove item",w.setAttribute("data-hha-action","array-remove"),w.setAttribute("data-hha-path",mn(f)),h.appendChild(w);let b=rs({rule:r,value:a,path:f,ctx:o});b.querySelector(".form-section-label")?.remove(),h.appendChild(b),s.appendChild(h)});let l=document.createElement("button");return l.type="button",l.className="array-add",l.textContent="+ add",l.setAttribute("data-hha-action","object-array-add"),l.setAttribute("data-hha-path",mn(n)),s.appendChild(l),s}function Uc(e,t){let n=Wc(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 Hc(e,t){let n=null;if(e.startsWith("@")?n=e.slice(1):n=Vn(e).prop,n&&Cc.has(n))return{type:"checkbox"};if(n==="innerHTML")return{type:"textarea"};let o=Vc(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(c=>({value:c.getAttribute("value")||c.textContent,text:c.textContent.trim()||c.getAttribute("value")||""}))};if(r==="input"){let s=(o.getAttribute("type")||"text").toLowerCase();if(s==="checkbox"||s==="radio")return{type:"checkbox"};if(s==="number")return{type:"number"}}let i=(o.textContent||"").trim();return i.length>60||i.includes(`
2
- `)?{type:"textarea"}:{type:"text"}}function Vc(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=Vn(e).selector;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function Wc(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 Nr(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 _c(e){return` \xB7 ${e}`}function vr(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 ss(e){let t=new Map;return(n,o)=>{if(typeof o!="string")return vr(o,e);let r=t.get(n);if(r&&r.text===o)return r.doc;let i=vr(o,e);return t.set(n,{text:o,doc:i}),i}}function Ai(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 is=()=>!1;function ls(e,t=[]){if(typeof e!="function")return is;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 s=[],c=r,l=!1;for(;c&&c.nodeType===1;){let a=n.get(c);if(a!==void 0){l=a;break}if(s.push(c),e(c,o.has(c))){l=!0;break}if(o.has(c))break;c=c.parentElement}for(let a of s)n.set(a,l);return l}}var Cu=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 Gn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var $c="~",Ti="^";function cs(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let o=t[$c],r=typeof o=="string"?o.split(",").map(Number):null,i=r&&typeof t[Ti]=="string"?t[Ti].split(","):null,s=f=>Number.isInteger(f)&&f>=0,c=0,l=!1,a=f=>{let h=f;for(;h>0;){let w=r[c++];if(c>r.length||!s(w))return!1;h+=w-1}return!0},p=(f,h)=>{if(l)return;if(r){let T=c++,g=r[T];if(T>=r.length||!s(g)){l=!0;return}let d=!i||i[T]===f.tagName.toLowerCase();if(!d||g!==f.children.length){let y=d&&t[h];typeof y=="string"&&y&&n.set(f,y),a(g)||(l=!0);return}}let w=t[h];typeof w=="string"&&w&&n.set(f,w);let b=f.children;for(let T=0;T<b.length;T++)p(b[T],h===""?String(T):`${h}.${T}`)};return p(e,""),n}function Si(e){return t=>{for(let n of e){let o=n(t);if(typeof o=="string"&&o!=="")return o}return null}}var un=Si([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Or(e,t,n,o=null,r=null){let i=new Map,s=new Set,c=l=>{if(n(l))return;let a=t(l);a&&(i.has(a)?s.add(a):i.set(a,l))};if(o){let l=a=>{for(let p of a.querySelectorAll(o))c(p);for(let p of a.querySelectorAll("template"))p.content&&l(p.content)};c(e),l(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let l=a=>{c(a);let p=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let f=0;f<p.length;f++)l(p[f])};l(e)}for(let l of s)i.delete(l),r&&r.add(l),as(l);return i}function as(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var Fc=new Set(["href","src","name","type","role"]),vi=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function Ao(e,t=5381){let n=t;for(let o=0;o<e.length;o++)n=(n<<5)+n^e.charCodeAt(o);return n>>>0}function Ni(e){return e.replace(/\s+/g," ")}var qc=0;function Oi({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let o=new WeakMap,r=new WeakMap;function i(O){let R=O.attributes,M=R.length;if(M===0)return{all:"",sig:O.tagName+"|"};let j=[],U="",K=[];for(let _=0;_<M;_++){let H=R[_],k=H.name;t(O,k)||j.push(k+"="+H.value),k==="class"?U=H.value.indexOf(" ")<0?H.value:H.value.split(/\s+/).filter(Boolean).sort().join(" "):Fc.has(k)&&K.push(k+"="+H.value)}return j.length>1&&j.sort(),K.length>1&&K.sort(),{all:j.join(""),sig:O.tagName+"|"+U+(K.length?"|"+K.join("|"):"")}}function s(O){return O.nodeType===1&&O.tagName==="TEMPLATE"&&O.content?O.content.childNodes:O.childNodes}function c(O){let R=o.get(O);if(R)return R;if(O.nodeType===3)R={hash:"T"+Ao(O.nodeValue),hint:Ni(O.nodeValue).slice(0,64),sig:null,tok:null};else if(O.nodeType===8)R={hash:"C"+Ao(O.nodeValue),hint:"",sig:null,tok:null};else if(O.nodeType===1){let M=i(O),j=Ao(O.tagName+""+M.all),U="";for(let K of a(O))if(K.nodeType===1){let _=c(K);j=Ao(_.hash,j),U.length<64&&(U+=" "+_.hint)}else j=Ao(p(K),j),K.kind==="text"&&U.length<64&&(U+=K.value.slice(0,64));R={hash:"E"+j,hint:Ni(U).trim().slice(0,64),sig:M.sig,tok:null}}else R={hash:"N"+O.nodeType,hint:"",sig:null,tok:null};return o.set(O,R),R}function l(O){if(!O.tok){O.tok=new Set;for(let R of O.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))R&&O.tok.add(R)}return O.tok}function a(O){let R=r.get(O);if(R)return R;R=[];let M=null,j=()=>{M&&(M.value=M.nodes.map(U=>U.nodeValue).join(""),R.push(M),M=null)};for(let U of s(O)){if(U.nodeType===3){M||(M={kind:"text",nodes:[],value:"",parent:O,hash:void 0}),M.nodes.push(U);continue}j(),U.nodeType===8?R.push({kind:"comment",nodes:[U],value:U.nodeValue,parent:O,hash:void 0}):U.nodeType===1&&!e(U)&&R.push(U)}return j(),r.set(O,R),R}function p(O){return O.nodeType===1?c(O).hash:(O.hash===void 0&&(O.hash=(O.kind==="text"?"T":"C")+Ao(O.value)),O.hash)}function f(O,R){let M=l(c(O)),j=l(c(R));if(M.size===0&&j.size===0)return{coef:1,share:1};if(M.size===0||j.size===0)return null;let U=0;for(let K of M)j.has(K)&&U++;return{coef:U/Math.min(M.size,j.size),share:U/Math.max(M.size,j.size)}}function h(O,R){let M=f(O,R);return!!M&&M.coef>=.5}let w=new WeakMap;function b(O){let R=w.get(O);if(R)return R;R=[];for(let M of O.attributes)t(O,M.name)||R.push([M.namespaceURI||"",M.localName,M.value]);return R.sort((M,j)=>M[0]<j[0]?-1:M[0]>j[0]?1:M[1]<j[1]?-1:M[1]>j[1]?1:0),w.set(O,R),R}let T=new WeakMap;function g(O,R){if(O===R)return!0;if(p(O)!==p(R))return!1;let M=T.get(O);if(M&&M.has(R))return M.get(R);let j=T.get(R);if(j&&j.has(O))return j.get(O);let U=d(O,R),K=U===!0;return U===!1&&n&&n.hashRejected++,M||T.set(O,M=new WeakMap),M.set(R,K),K}function d(O,R){if(O.nodeType===1){if(R.nodeType!==1||O.tagName!==R.tagName||O.namespaceURI!==R.namespaceURI)return!1;let M=b(O),j=b(R);if(M.length!==j.length)return!1;for(let _=0;_<M.length;_++)if(M[_][0]!==j[_][0]||M[_][1]!==j[_][1]||M[_][2]!==j[_][2])return!1;let U=a(O),K=a(R);if(U.length!==K.length)return!1;for(let _=0;_<U.length;_++){if(p(U[_])!==p(K[_]))return!1;if(!g(U[_],K[_]))return qc}return!0}return R.nodeType===1?!1:O.kind===R.kind&&O.value===R.value}let y=new WeakMap,N=new Map,x=0;function S(O){let R=y.get(O);if(R)return R;let M=p(O),j=N.get(M);j||N.set(M,j=[]);let U=j.find(K=>g(K.unit,O));return R=U?U.key:"K"+x++,U||j.push({unit:O,key:R}),y.set(O,R),R}return{meta:c,unitsOf:a,unitHash:p,similar:h,score:f,childrenOf:s,equalUnits:g,exactUnitKey:S,ignored:e}}var Mi=16,Kc=2e3,zc=3,fs={align:0,certifyVisited:0,certifyScheduled:0};function us(e,t,n){let{meta:o,unitsOf:r,unitHash:i,similar:s,score:c,childrenOf:l,equalUnits:a,ignored:p}=n.analyzer,f=n.baseId||(()=>null),h=n.sideId||(()=>null),w=n.baseKey||(()=>null),b=n.sideKey||(()=>null),T=n.baseDropped||new Set,g=n.sideDropped||new Set,d=n.stats||null,y=d?new Set:null,N=d?new Set:null,x=new Map,S=new Map,O=new Set,R=new Map,M=new Set,j=new Set,U=new Set,K=[],_=[],H=[],k=[],A=Kc,J=new Map,W=new Map,F=(V,Z)=>{x.set(V,Z),S.set(Z,V)},Oe=new Set,Ce=new Set,De=null,pe=V=>{let Z=V.nodeType?V.parentNode:V.parent;if(!Z||Z.nodeType!==11)return Z;if(!De){De=new WeakMap;let be=ke=>{for(let we of ke.querySelectorAll("template"))we.content&&(De.set(we.content,we),be(we.content))};for(let ke of[e,t])be(ke.tagName==="TEMPLATE"&&ke.content?ke.content:ke)}return De.get(Z)||null},Te=(V,Z)=>{for(let be=pe(V);be&&!Oe.has(be);be=pe(be))Oe.add(be);for(let be=pe(Z);be&&!Ce.has(be);be=pe(be))Ce.add(be)},ze=V=>{for(let Z=pe(V);Z;Z=pe(Z))if(x.has(Z))return j.has(Z);return!1},Me=V=>{for(let Z=pe(V);Z;Z=pe(Z)){let be=S.get(Z);if(be!==void 0)return j.has(be)}return!1},v=V=>!!V&&V.nodeType===1,G=(V,Z)=>{let be=R.get(V);return!!be&&be.has(Z)},ue=V=>vi.has(V.tagName),ae=n.comparisons||n.scope,Pe=(V,Z)=>{if(ae){if(ae.same.get(V)===Z)return!0;if(ae.differ.get(V)===Z)return!1}if(!V.isEqualNode(Z))return!1;if(V.tagName==="TEMPLATE")return a(V,Z);let be=V.getElementsByTagName("template");if(be.length===0)return!0;let ke=Z.getElementsByTagName("template");if(be.length!==ke.length)return!1;for(let we=0;we<be.length;we++)if(!a(be[we],ke[we]))return!1;return!0},He=(V,Z)=>{let be=f(V);if(!be)return!0;let ke=h(Z);return!ke||be===ke},ve=V=>{let Z=w(V);return Z&&n.baseIndex.get(Z)===V&&!g.has(Z)?Z:null},Ze=V=>{let Z=b(V);return Z&&n.sideIndex.get(Z)===V&&!T.has(Z)?Z:null},Je=(V,Z)=>{let be=ve(V);if(!be)return!0;let ke=Ze(Z);return!ke||be===ke},pt=globalThis.__hyperMorphProfile,Xe=pt?performance.now():0;pt&&!n.scope&&(o(e),o(t),pt.meta=(pt.meta||0)+(performance.now()-Xe),Xe=performance.now()),F(e,t);let dt=new Set;for(let[V,Z]of n.baseIndex){let be=n.sideIndex.get(V);be&&be.tagName===Z.tagName&&!x.has(Z)&&!S.has(be)&&(F(Z,be),Te(Z,be),dt.add(Z))}if(dt.size){let V=[];if(n.scope)for(let we of n.scope.chain)dt.has(we)&&V.push(we);let Z=[n.scope?n.scope.root:e];for(;Z.length;){let we=Z.pop();dt.has(we)&&V.push(we);let te=l(we);for(let re=te.length-1;re>=0;re--)te[re].nodeType===1&&Z.push(te[re])}let be=new Set;for(let we=V.length-1;we>=0;we--){let te=V[we];n.scope&&n.scope.onChain.has(te)?be.add(te):Pt(te,x.get(te),be)?(j.add(te),U.add(te),d&&d.certificationPairs++):be.add(te)}let ke=new Set;for(let we of V)j.has(we)&&!ke.has(we)&&St(we,ke)}n.scope&&n.scope.head&&Ft(n.scope.head[0],n.scope.head[1]);function St(V,Z){let be=[V];for(;be.length;){let ke=be.pop();if(!Z.has(ke)){Z.add(ke),I(ke);for(let we of r(ke))v(we)&&x.has(we)&&be.push(we)}}}k.push([e,t]);for(let[V,Z]of x)v(V)&&V!==e&&k.push([V,Z]);return Ot(),vt(),pt&&(pt.align=(pt.align||0)+(performance.now()-Xe)),{map:x,reverse:S,moved:M,identical:j,pairIdenticalChildren:I,weak:O,unpair:bt,rematch:vt,insertedByHash:At,refused:N,identityPaired:dt};function vt(){Se(),Ot();for(let V=0;V<H.length;){let Z=H.length;Nt(V,Z),V=Z,Ot(),Se(),Ot()}}function bt(V){let Z=x.get(V);if(!Z)return;R.has(V)||R.set(V,new Set),R.get(V).add(Z);let be=(we,te)=>{x.delete(we),S.delete(te),M.delete(we),j.delete(we),O.delete(we),U.delete(we)},ke=(we,te)=>{for(let re of r(we)){let q=x.get(re);!q||dt.has(re)||!(v(q)?te.contains(q):te.contains(q.nodes[0]))||(be(re,q),v(re)&&ke(re,q))}};be(V,Z),v(V)&&ke(V,Z),K.push(V),_.push(Z)}function At(){let V=new Map;for(let Z of new Set(_)){if(S.has(Z))continue;let be=o(Z).hash;V.has(be)||V.set(be,[]),V.get(be).push(Z)}return V}function Ot(){for(;k.length;){let[V,Z]=k.shift();x.get(V)!==Z||U.has(V)||j.has(V)||tn(V,Z)}}function Bt(V,Z){if(!ue(V))for(let be of r(V))v(be)&&(Z.push(be),Bt(be,Z))}function tn(V,Z){U.add(V);let be=r(V),ke=r(Z);fs.align+=be.length+ke.length,J=new Map,W=new Map;for(let le=0;le<be.length;le++)J.set(be[le],le);for(let le=0;le<ke.length;le++)W.set(ke[le],le);if(V.tagName==="HTML")for(let le of["HEAD","BODY"]){let Ne=be.find(je=>v(je)&&je.tagName===le),Le=ke.find(je=>v(je)&&je.tagName===le);Ne&&Le&&!x.has(Ne)&&!S.has(Le)&&F(Ne,Le)}for(let le=0;le<be.length&&le<ke.length;le++){let Ne=be[le],Le=ke[le];x.has(Ne)||S.has(Le)||(v(Ne)?v(Le)&&Ne.tagName===Le.tagName&&Pe(Ne,Le)&&Ft(Ne,Le):!v(Le)&&Ne.kind===Le.kind&&Ne.value===Le.value&&Ft(Ne,Le))}fe(be,ke);let we=be.filter(le=>!x.has(le)),te=ke.filter(le=>!S.has(le));we.length&&te.length&&(cn(we,te),P(we,te),$(we,te,be,ke),me(be,ke));let re=!1,q=!1;for(let le of be){if(!x.has(le)){v(le)&&(K.push(le),Bt(le,K),re=!0);continue}v(le)&&!j.has(le)&&k.push([le,x.get(le)])}for(let le of ke)!S.has(le)&&v(le)&&(_.push(le),Bt(le,_),q=!0);re&&q&&H.push([V,Z])}function Nt(V,Z){for(let be=V;be<Z;be++){let[ke,we]=H[be];if(x.get(ke)!==we)continue;let te=r(ke),re=r(we),q=new Map,le=new Map,Ne=null;for(let Le of te)v(Le)&&(x.has(Le)?Ne=Le:(q.has(Ne)||q.set(Ne,[]),q.get(Ne).push(Le)));Ne=null;for(let Le of re)v(Le)&&(S.has(Le)?Ne=S.get(Le):(le.has(Ne)||le.set(Ne,[]),le.get(Ne).push(Le)));for(let[Le,je]of q){let Ae=le.get(Le);if(!(!Ae||je.length!==Ae.length)&&je.every((Ge,et)=>Ae[et].tagName===Ge.tagName&&He(Ge,Ae[et])&&!G(Ge,Ae[et])))for(let Ge=0;Ge<je.length;Ge++)$t(je[Ge],Ae[Ge])}}}function $t(V,Z){F(V,Z),O.add(V),k.push([V,Z]),Ot()}function cn(V,Z){let be=To(V,i),ke=To(Z,i),we=new Map;for(let te of Z){let re=i(te);ke.get(re)===1&&we.set(re,te)}for(let te of V){if(x.has(te))continue;let re=i(te);if(be.get(re)!==1)continue;let q=we.get(re);q&&!S.has(q)&&a(te,q)&&Ft(te,q)}}function Pt(V,Z,be){let ke=[[V,Z]];for(;ke.length;){let[we,te]=ke.pop();if(fs.certifyVisited++,d&&d.certificationVisited++,we.nodeType!==te.nodeType)return!1;if(we.nodeType===3||we.nodeType===8){if(we.nodeValue!==te.nodeValue)return!1;continue}if(we.nodeType!==1){if(!we.isEqualNode(te))return!1;continue}if(we.tagName!==te.tagName||we.namespaceURI!==te.namespaceURI||p(we)!==p(te))return!1;let re=we.attributes,q=te.attributes;if(re.length!==q.length)return!1;for(let Ae=0;Ae<re.length;Ae++){let Ge=re[Ae];if(te.getAttributeNS(Ge.namespaceURI,Ge.localName)!==Ge.value)return!1}let le=x.get(we);if(le!==void 0&&le!==te)return!1;let Ne=S.get(te);if(Ne!==void 0&&Ne!==we)return!1;if(we!==V){if(j.has(we))continue;if(be.has(we))return!1}let Le=l(we),je=l(te);if(Le.length!==je.length)return!1;fs.certifyScheduled+=Le.length;for(let Ae=Le.length-1;Ae>=0;Ae--)ke.push([Le[Ae],je[Ae]])}return!0}function Jt(V,Z){return!v(V)||!(Oe.has(V)||Ce.has(Z))?!0:!!X(V,Z)||!(ve(V)||Ze(Z))}function Ft(V,Z){if(v(V)&&(Oe.has(V)||Ce.has(Z))){let be=X(V,Z);if(!be){if(ve(V)||Ze(Z))return;F(V,Z),k.push([V,Z]);return}for(let ke=0;ke<be.length;ke+=2){let we=be[ke],te=be[ke+1],re=x.get(we);re!==void 0&&re!==te&&nn(we,re);let q=S.get(te);q!==void 0&&q!==we&&nn(q,te),x.get(we)===te&&(M.delete(we),O.delete(we),j.add(we),U.add(we))}}m(V,Z)}function nn(V,Z){x.delete(V),S.delete(Z),M.delete(V),j.delete(V),O.delete(V),U.delete(V)}function X(V,Z){let be=[V,Z,!1],ke=[];for(;be.length;){let we=be.pop(),te=be.pop(),re=be.pop(),q=x.get(re),le=S.get(te);if(re!==V&&(q!==void 0&&q!==te&&dt.has(re)||le!==void 0&&le!==re&&dt.has(le)))return null;if(!(q===te&&j.has(re))&&((q!==void 0||le!==void 0)&&ke.push(re,te),!!v(re))){if(we||q!==void 0&&q!==te||le!==void 0&&le!==re){let Ne=r(re),Le=r(te);for(let je=0;je<Ne.length&&je<Le.length;je++)be.push(Ne[je],Le[je],!0)}else if(Oe.has(re)||Ce.has(te)){let Ne=re.tagName==="TEMPLATE"?re.content:re,Le=te.tagName==="TEMPLATE"?te.content:te;for(let je=Ne.firstElementChild,Ae=Le.firstElementChild;je&&Ae;){if(p(je)){je=je.nextElementSibling;continue}if(p(Ae)){Ae=Ae.nextElementSibling;continue}(x.has(je)||S.has(Ae)||Oe.has(je)||Ce.has(Ae))&&be.push(je,Ae,!1),je=je.nextElementSibling,Ae=Ae.nextElementSibling}}}}return ke}function m(V,Z){F(V,Z),j.add(V),v(V)&&U.add(V)}function I(V){let Z=x.get(V);if(!Z||!v(V))return;let be=r(V),ke=r(Z);for(let we=0;we<be.length&&we<ke.length;we++)x.has(be[we])||m(be[we],ke[we])}function P(V,Z){let be=re=>v(re)&&!ue(re)?o(re).sig+""+o(re).hint:null,ke=To(V,be),we=To(Z,be),te=new Map;for(let re of Z){let q=be(re);q!=null&&we.get(q)===1&&te.set(q,re)}for(let re of V){if(x.has(re))continue;let q=be(re);if(q==null||ke.get(q)!==1)continue;let le=te.get(q);le&&!S.has(le)&&He(re,le)&&F(re,le)}}function $(V,Z,be,ke){let we=new Map;for(let re of Z){if(!v(re)||S.has(re)||ue(re))continue;let q=o(re).sig;we.has(q)||we.set(q,[]),we.get(q).push({el:re,index:W.get(re)})}let te=[];for(let re of V){if(x.has(re)||!v(re)||ue(re))continue;let q=we.get(o(re).sig);if(!q||!q.length)continue;let le=J.get(re),Ne=q.filter(Le=>!S.has(Le.el)).map(Le=>({c:Le,d:Math.abs(Le.index-le)}));Ne.sort((Le,je)=>Le.d-je.d),Ne.length>Mi&&(Ne=Ne.slice(0,Mi));for(let{c:Le,d:je}of Ne){if(!He(re,Le.el))continue;let Ae=c(re,Le.el);Ae&&Ae.coef>=.5&&te.push({b:re,s:Le.el,coef:Ae.coef,share:Ae.share,d:je,bi:le})}}if(te.sort((re,q)=>q.coef-re.coef||q.share-re.share||re.d-q.d||re.bi-q.bi),d&&te.length>1){let re=new Map;for(let q of te){let le=re.get(q.b);le?le.coef===q.coef&&(le.share===q.share?le.strict++:le.loose++):re.set(q.b,{coef:q.coef,share:q.share,strict:0,loose:0})}for(let[q,le]of re)y.has(q)||!(le.strict||le.loose)||(y.add(q),le.strict?d.similarTiesStrict++:d.similarTiesLoose++)}for(let re of te)!x.has(re.b)&&!S.has(re.s)&&F(re.b,re.s)}function Q(V,Z){return v(V)!==v(Z)?!1:v(V)?V.tagName!==Z.tagName||!He(V,Z)?!1:ue(V)||o(V).hint===""||o(Z).hint===""?!0:s(V,Z):V.kind===Z.kind}function B(V,Z){let be=(we,te)=>{let re=te===null?-1:we===Z?W.get(te):J.get(te),q=we[re+1];return q&&!v(q)?q:null},ke=null;for(let we of V){if(v(we)){ke=we;continue}if(x.has(we))continue;let te=ke===null?null:x.get(ke);if(ke!==null&&!te)continue;let re=be(Z,te);re&&!S.has(re)&&re.kind===we.kind&&F(we,re)}}function me(V,Z){B(V,Z);let be=xe(V,Z),ke=(te,re)=>v(te)&&o(te).hint!==""&&o(re).hint===""&&!!re.querySelector("br")&&!be(te,re),we=0;for(let te of V){if(x.has(te)){let q=W.get(x.get(te));q!==void 0&&q>=we&&(we=q+1);continue}let re=0;for(let q=we;q<Z.length&&re<zc;q++){let le=Z[q];if(!S.has(le)&&(re++,Q(te,le)&&!G(te,le)&&!ke(te,le))){F(te,le),v(te)&&(o(te).hint===""||o(le).hint==="")&&O.add(te),we=q+1;break}}}fe(V,Z)}function xe(V,Z){let be=(ke,we,te)=>{for(let re=we-1;re>=0;re--)if(v(ke[re])&&te(ke[re]))return ke[re];return null};return(ke,we)=>{let te=J.get(ke),re=W.get(we);if(te===re)return!0;let q=be(V,te,Ne=>x.has(Ne)),le=be(Z,re,Ne=>S.has(Ne));return q?x.get(q)===le:!le}}function fe(V,Z){let be=V.filter(q=>v(q)&&!x.has(q)),ke=Z.filter(q=>v(q)&&!S.has(q));if(!be.length||!ke.length)return;let we=To(be,q=>q.tagName),te=To(ke,q=>q.tagName),re=xe(V,Z);for(let q of be){let le=q.tagName;if(we.get(le)!==1||te.get(le)!==1)continue;let Ne=ke.find(Le=>Le.tagName===le);Ne&&!S.has(Ne)&&re(q,Ne)&&He(q,Ne)&&!G(q,Ne)&&(a(q,Ne)?Ft(q,Ne):(F(q,Ne),O.add(q)))}}function Se(){let V=new Map;for(let q of O)if(v(q)&&v(x.get(q))){let le=o(q).hash;V.has(le)||V.set(le,[]),V.get(le).push(q)}if(V.size)for(let q of _){if(S.has(q)||!v(q)||Me(q))continue;let le=V.get(o(q).hash),Ne=le&&le.find(Le=>O.has(Le)&&!G(Le,q)&&He(Le,q)&&Je(Le,q)&&a(Le,q)&&Jt(Le,q));Ne&&(bt(Ne),Ft(Ne,q),Te(Ne,q),M.add(Ne))}let Z=new Map,be=new Map,ke=new Map;for(let q of O){let le=x.get(q);v(q)&&v(le)&&ke.set(le,q)}let we=(q,le)=>{if(!S.has(q))return!Me(q);let Ne=ke.get(q);return Ne===S.get(q)&&Ne!==le&&!Ne.contains(le)},te=q=>{if(S.has(q)){let le=ke.get(q);ke.delete(q),bt(le)}};for(let q of[..._,...ke.keys()]){if(S.has(q)&&!ke.has(q))continue;let le=o(q).hash;if(Z.has(le)||Z.set(le,[]),Z.get(le).push(q),ue(q))continue;let Ne=o(q).sig;be.has(Ne)||be.set(Ne,[]),be.get(Ne).push(q)}let re=new Set;for(let q of O){let le=x.get(q);!v(q)||!v(le)||ue(q)||o(q).hint===""||o(le).hint===""||s(q,le)||re.add(q)}for(let q of[...K,...re]){let le=x.get(q);if(le?!(O.has(q)&&re.has(q)):ze(q))continue;let Ne=et=>{le&&bt(q),te(et)},Le=Z.get(o(q).hash);if(Le){let et=Le.find(Qe=>Qe!==le&&we(Qe,q)&&!G(q,Qe)&&Je(q,Qe)&&a(q,Qe)&&Jt(q,Qe));if(et){Ne(et),Ft(q,et),Te(q,et),M.add(q);continue}}if(ue(q)||A<=0)continue;let je=be.get(o(q).sig);if(!je)continue;let Ae=null,Ge=0;for(let et of je)if(!(et===le||!we(et,q)||!He(q,et)||!Je(q,et)||G(q,et))&&(A--<=0||s(q,et)&&(Ge++,Ae=et,Ge>1)))break;Ge>1&&N&&N.add(q),Ge===1&&(Ne(Ae),F(q,Ae),Te(q,Ae),M.add(q),k.push([q,Ae]))}}}function To(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 Gc={diff:0},Ei=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,Xc=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,Yc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,Jc=/\P{M}\p{M}*/gu;function Zc(e){if(e==="")return[];if(Ei){let n=[];for(let o of Ei.segment(e))n.push(o.segment);return n}let t=[];for(let n of e.match(Yc))if(Xc.test(n))for(let o of n.match(Jc))t.push(o);else t.push(n);return t}var Qc=/^[  ]+$/,ea=e=>Qc.test(e)?" ".repeat(e.length):e,Xn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),wt="",ds=e=>e.every(t=>Xn(t)||t.k===wt),ta=/^[\x00-\x7f\u00A0]*$/,na=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function oa(e){return e===""?[]:e.match(na)}function en(e,t=!1){return(t?oa(e):Zc(e)).map(n=>({k:ea(n),raw:n,len:n.length}))}var dn=(...e)=>e.every(t=>ta.test(t));function hs(e,t,n){let o=e.length,r=t.length,i=Math.min(o+r,n),s=i+1,c=new Int32Array(2*i+3),l=[],a=o===0&&r===0;for(let w=0;w<=i&&!a;w++){l.push(c.slice(s-w,s+w+1));for(let b=-w;b<=w;b+=2){let T;b===-w||b!==w&&c[s+b-1]<c[s+b+1]?T=c[s+b+1]:T=c[s+b-1]+1;let g=T-b,d=T;for(;T<o&&g<r&&e[T].k===t[g].k;)T++,g++;if(Gc.diff+=1+T-d,c[s+b]=T,T>=o&&g>=r){a=!0;break}}}if(!a)return null;let p=[],f=o,h=r;for(let w=l.length-1;w>0;w--){let b=l[w],T=f-h,g=T+w,d=T===-w||T!==w&&b[g-1]<b[g+1]?T+1:T-1,y=b[d+w],N=y-d;for(;f>y&&h>N;)p.push([0,f-1,h-1]),f--,h--;f===y?(p.push([1,f,h-1]),h--):(p.push([-1,f-1,h]),f--)}for(;f>0&&h>0;)p.push([0,f-1,h-1]),f--,h--;return p.reverse(),p}function ra(e,t,n){let o=f=>f.k===wt;if(!e.some(o)&&!t.some(o))return hs(e,t,n);let r=[],i=[];for(let f=0;f<e.length;f++)o(e[f])||r.push(f);for(let f=0;f<t.length;f++)o(t[f])||i.push(f);let s=hs(r.map(f=>e[f]),i.map(f=>t[f]),n);if(!s)return null;let c=[],l=0,a=0,p=(f,h)=>{for(;l<f&&a<h&&e[l].k===t[a].k;)c.push([0,l++,a++]);let w=hs(e.slice(l,f),t.slice(a,h),n);if(!w)return!1;for(let[b,T,g]of w)c.push([b,T+l,g+a]);return l=f,a=h,!0};for(let[f,h,w]of s)if(f===0){if(!p(r[h],i[w]))return null;c.push([0,l,a]),l++,a++}return p(e.length,t.length)?c:null}function Wn(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 s=e.slice(r,e.length-i),c=t.slice(r,t.length-i),l=fa(s,c)?null:ra(s,c,n);if(!l){let d=s.length||c.length?[{bs:r,be:r+s.length,toks:c}]:[];return{hunks:d,cosmetic:o,coarse:!0,parts:d.map(y=>({...y,gap:[],group:0})),cosmeticEq:o}}let a=[],p=(d,y)=>{s[d].raw!==c[y].raw&&o.push({bi:r+d,tok:c[y]})},f=null,h=[],w=0,b=0,T=()=>{f&&a.push(f),f=null;for(let[d,y]of h)p(d,y);h=[],w++};for(let[d,y,N]of l){if(d===0){f&&Xn(s[y])&&!s[y].k.includes(`
3
- `)?h.push([y,N]):(T(),p(y,N)),b=y+1;continue}(!f||h.length)&&(f&&a.push(f),f={bs:r+b,be:r+b,toks:[],gap:h.map(([x,S])=>({bi:r+x,tok:c[S]})),group:w},h=[]),d===-1?(f.be=r+b+1,b=y+1):f.toks.push(c[N])}T(),sa(a,e);let g=ms(a);return{hunks:g.hunks,cosmetic:o.concat(g.cosmetic),parts:a,cosmeticEq:o}}function sa(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===wt&&t[o.bs].k===wt;)o.toks=[...o.toks.slice(1),o.toks[0]],o.bs++,o.be++}else for(;o.be+1<r&&o.be<t.length&&t[o.bs].k===wt&&t[o.be].k===wt;)o.bs++,o.be++}}function ms(e,t=()=>!1){let n=[],o=[],r=null,i=-1;for(let s of e){let c=t(s);if(r&&!r.alone&&!c&&s.group===i){r.be=s.be;for(let l of s.gap)r.toks.push(l.tok);for(let l of s.toks)r.toks.push(l);continue}r&&n.push({bs:r.bs,be:r.be,toks:r.toks});for(let l of s.gap)o.push(l);r={bs:s.bs,be:s.be,toks:s.toks.slice(),alone:c},i=s.group}return r&&n.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:n,cosmetic:o}}var ia=(e,t)=>e.bs===t.bs&&e.be===t.be&&ys(e.toks,t.toks);function bs(e,t,n){let o=p=>f=>p.some(h=>ia(f,h)),r=ms(e.parts,o(t.parts)),i=ms(t.parts,o(e.parts)),s=e.cosmeticEq.concat(r.cosmetic),c=t.cosmeticEq.concat(i.cosmetic),[l,a]=n?la(r.hunks,i.hunks,n,s,c):[r.hunks,i.hunks];return{lh:l,rh:a,cosL:s,cosR:c}}function la(e,t,n,o,r){let i=(b,T)=>b.k===T.k&&b.raw===T.raw,s=[{list:e.map(b=>({...b})),resp:new Set(o.map(b=>b.bi)),raw:new Map(o.map(b=>[b.bi,b.tok]))},{list:t.map(b=>({...b})),resp:new Set(r.map(b=>b.bi)),raw:new Map(r.map(b=>[b.bi,b.tok]))}],c=b=>b.bs===b.be,l=(b,T,g,d)=>{let y=b.list[T];if(!c(y))return d(y)===g?y.toks:null;let N=T?b.list[T-1].be:0,x=T+1<b.list.length?b.list[T+1].bs:n.length;if(g<N||g>x)return null;let S=y.toks,O=y.bs;for(;O>g;){let R=S[S.length-1];if(!i(R,n[O-1])||b.resp.has(O-1))return null;S=[R,...S.slice(0,-1)],O--}for(;O<g;){if(!i(S[0],n[O])||b.resp.has(O))return null;S=[...S.slice(1),S[0]],O++}return S},a=(b,T,g,d,y,N)=>{let x=b.list[T],S=y?g.slice(g.length-d):g.slice(0,d),O=y?g.slice(0,g.length-d):g.slice(d),R={bs:N,be:N,toks:S};if(c(x)){if(!O.length){b.list[T]=R;return}let j={bs:N,be:N,toks:O};y&&(j.lead=!0),b.list.splice(T,1,...y?[j,R]:[R,j]);return}let M={bs:x.bs,be:x.be,toks:O};b.list.splice(T,1,...y?[M,R]:[R,M])},p=(b,T,g,d,y)=>{let N=b.list[T],x=y?g.slice(g.length-d):g.slice(0,d),S=y?g.slice(0,g.length-d):g.slice(d),O={bs:N.bs,be:N.be,toks:x};if(!S.length){b.list[T]=O;return}let R=y?{bs:N.bs,be:N.bs,toks:S,lead:!0}:{bs:N.be,be:N.be,toks:S};b.list.splice(T,1,...y?[R,O]:[O,R])},f=(b,T,g,d)=>{let y=b.list[T],N=g.list[d],x=y.be,S=N.bs;if(x>=S||T+1<b.list.length&&b.list[T+1].bs<=N.be||d>0&&g.list[d-1].be>=y.bs)return!1;for(let W=x;W<S;W++)if(!Xn(n[W])||n[W].k.includes(`
4
- `))return!1;let O=W=>n.slice(x,S).map((F,Oe)=>W.raw.get(x+Oe)||F),R=[...y.toks,...O(b)],M=[...O(g),...N.toks],j=(W,F,Oe)=>F>=0&&F+Oe.length<=W.length&&Oe.every((Ce,De)=>W[F+De].k===Ce.k),U=(W,F,Oe)=>ds(W)&&n.slice(F,Oe).some(Ce=>!Xn(Ce)),K=W=>W.some(F=>!Xn(F)),_,H,k,A;if(c(y)&&K(y.toks)&&j(M,0,y.toks)){let W=M.slice(y.toks.length);U(W,x,N.be)||(_=x,H=y.toks,k=M.slice(0,y.toks.length),A=[null,{bs:x,be:N.be,toks:W}])}if(_===void 0&&c(N)&&K(N.toks)){let W=R.length-N.toks.length,F=R.slice(0,W);j(R,W,N.toks)&&!U(F,y.bs,S)&&(_=S,H=R.slice(W),k=N.toks,A=[{bs:y.bs,be:S,toks:F},null])}if(_===void 0)return!1;let J=W=>W&&(W.bs<W.be||W.toks.length);return b.list.splice(T,1,...[A[0],{bs:_,be:_,toks:H}].filter(J)),g.list.splice(d,1,...[{bs:_,be:_,toks:k},A[1]].filter(J)),!0},h=s[0],w=s[1];for(let b=0;b<64;b++){let T=!1;e:for(let g=0;g<h.list.length;g++)for(let d=0;d<w.list.length;d++){let y=h.list[g],N=w.list[d];if(!(y.bs===N.bs&&y.be===N.be&&ys(y.toks,N.toks))){for(let x of[!0,!1]){let S=R=>x?R.be:R.bs,O=c(y)?[S(N),y.bs]:[S(y)];for(let R of O){let M=l(h,g,R,S),j=M&&l(w,d,R,S);if(!j)continue;let U=(A,J)=>x?A[A.length-1-J]:A[J],K=0;for(;K<M.length&&K<j.length&&U(M,K).k===U(j,K).k;)K++;if(!K)continue;let _=x?M.slice(0,M.length-K):M.slice(K),H=x?j.slice(0,j.length-K):j.slice(K);if(!(K<M.length&&K<j.length&&!ds(_)&&!ds(H)&&(c(y)&&c(N)||y.bs===N.bs&&y.be===N.be)||!(x?M.slice(M.length-K):M.slice(0,K)).some(A=>!Xn(A)))){if(K===M.length&&K===j.length&&c(y)&&c(N)){if(y.bs===R&&N.bs===R)continue;h.list[g]={bs:R,be:R,toks:M},w.list[d]={bs:R,be:R,toks:j}}else!c(y)&&y.bs===N.bs&&y.be===N.be?(p(h,g,M,K,x),p(w,d,j,K,x)):(a(h,g,M,K,x,R),a(w,d,j,K,x,R));T=!0;break e}}}if(f(h,g,w,d)||f(w,d,h,g)){T=!0;break e}}}if(!T)break}return[h.list,w.list]}var ca=48,aa=.3;function fa(e,t){let n=e.filter(s=>!Xn(s)),o=t.filter(s=>!Xn(s));if(Math.min(n.length,o.length)<ca)return!1;let r=new Map;for(let s of n)r.set(s.k,(r.get(s.k)||0)+1);let i=0;for(let s of o){let c=r.get(s.k);c>0&&(i++,r.set(s.k,c-1))}return i/Math.min(n.length,o.length)<aa}var ua=(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},ys=(e,t)=>e.length===t.length&&e.every((n,o)=>n.k===t[o].k);function Ii(e,t,n,o="remote"){let r=Wn(e,t),i=Wn(e,n),{lh:s,rh:c,cosL:l,cosR:a}=bs(r,i,e),p=v=>v.bs===v.be,f=v=>v.toks.some(G=>typeof G.k=="string"),h=v=>p(v)&&!f(v),w=(v,G)=>G.bs<v.be&&v.bs<G.be,b=(v,G)=>!w(v,G)&&G.bs<=v.be&&v.bs<=G.be&&(p(v)&&f(v)||p(G)&&f(G))&&!(p(v)&&p(G)),T=(v,G)=>v.bs===G.bs&&v.be===G.be&&ys(v.toks,G.toks),g=[],d=new Set;for(let v of s){let G=c.find(ue=>!d.has(ue)&&T(v,ue));G?(d.add(G),g.push({bs:v.bs,be:v.be,side:"both",l:v,r:G,toks:v.toks})):g.push({bs:v.bs,be:v.be,side:"L",l:v,toks:v.toks,lead:!!v.lead})}for(let v of c)d.has(v)||g.push({bs:v.bs,be:v.be,side:"R",r:v,toks:v.toks,lead:!!v.lead});g.sort((v,G)=>v.bs-G.bs||v.be-G.be||G.lead-v.lead);let y=0,N=0;for(let v of g)v.side==="both"&&(y+=v.toks.length-(v.be-v.bs));let x=g.map((v,G)=>G),S=v=>x[v]===v?v:x[v]=S(x[v]),O=(v,G)=>(v=S(v),G=S(G),v===G?!1:(x[v]=G,!0)),R=g.map(v=>ua({bs:v.bs,be:v.be,toks:v.toks},e)),M={L:new Map,R:new Map};g.forEach((v,G)=>{let ue=v.side==="both"?["L","R"]:[v.side];for(let ae of ue)for(let Pe of R[G])M[ae].has(Pe)||M[ae].set(Pe,[]),M[ae].get(Pe).push(G)});for(let v of[M.L,M.R])for(let G of v.values())for(let ue=1;ue<G.length;ue++)O(G[0],G[ue]);for(let v=0;v<g.length;v++)for(let G=v+1;G<g.length;G++){let ue=g[v],ae=g[G];ue.side===ae.side&&ue.side!=="both"||ue.bs>ae.be||(w(ue,ae)||b(ue,ae)?O(v,G):ue.bs===ae.bs&&p(ue)&&p(ae)&&N++)}let j=(v,G)=>{let ue=v==="L"?s:c;for(let ae of ue)if(ae.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===G.el))return ae.bs;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="close"&&e[ae].k.el===G.el)return ae;return-1};g.forEach((v,G)=>{if(!(!h(v)||v.side==="both"))for(let ue of v.toks){if(ue.kind!=="open")continue;let ae=j(v.side,ue.k);if(ae<=v.bs)continue;let Pe=new Uint8Array(ae-v.bs),He=[];if(g.forEach((ve,Ze)=>{if(!(ve.side===v.side||p(ve))&&ve.bs<ae&&ve.be>v.bs){He.push(Ze);for(let Je=Math.max(ve.bs,v.bs);Je<Math.min(ve.be,ae);Je++)Pe[Je-v.bs]=1}}),He.length&&Pe.every(ve=>ve===1))for(let ve of He)O(G,ve)}});let U=!0;for(;U;){U=!1;let v=new Map;g.forEach((G,ue)=>{let ae=S(ue),Pe=v.get(ae)||{bs:G.bs,be:G.be,L:!1,R:!1};Pe.bs=Math.min(Pe.bs,G.bs),Pe.be=Math.max(Pe.be,G.be),G.side!=="R"&&(Pe.L=!0),G.side!=="L"&&(Pe.R=!0),v.set(ae,Pe)}),g.forEach((G,ue)=>{for(let[ae,Pe]of v){if(S(ue)===S(ae)||!(Pe.L&&Pe.R))continue;let He=G.bs<Pe.be&&G.be>Pe.bs,ve=p(G)&&f(G)&&(G.bs===Pe.be||G.bs===Pe.bs);(He||ve)&&O(ue,ae)&&(U=!0)}})}let K=new Map;g.forEach((v,G)=>{let ue=S(G);K.has(ue)||K.set(ue,[]),K.get(ue).push(v)});let _=[];for(let v of K.values()){let G=v.some(ae=>ae.side==="L"),ue=v.some(ae=>ae.side==="R");if(G&&ue){let ae=Math.min(...v.map(Ze=>Ze.bs)),Pe=Math.max(...v.map(Ze=>Ze.be)),He=v.filter(Ze=>Ze.side!=="R").map(Ze=>Ze.l).sort((Ze,Je)=>Ze.bs-Je.bs),ve=v.filter(Ze=>Ze.side!=="L").map(Ze=>Ze.r).sort((Ze,Je)=>Ze.bs-Je.bs);_.push({bs:ae,be:Pe,kind:"conflict",localHunks:He,remoteHunks:ve})}else for(let ae of v)_.push({bs:ae.bs,be:ae.be,kind:ae.side,u:ae})}let H=(v,G)=>{let ue=v==="L"?s:c;for(let ae of ue)if(ae.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===G.el))return ae.bs+.5;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="close"&&e[ae].k.el===G.el)return ae;return 1/0},k=(v,G)=>{let ue=v==="L"?s:c;for(let ae of ue)if(ae.toks.some(Pe=>Pe.kind==="open"&&Pe.k.el===G.el))return ae.bs-.5;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="open"&&e[ae].k.el===G.el)return ae;return-1/0},A=v=>v.kind==="R"?"R":"L",J=v=>v.kind==="R"?1:0;_.sort((v,G)=>{if(v.bs!==G.bs)return v.bs-G.bs;let ue=v.bs===v.be,ae=G.bs===G.be;if(ue!==ae)return ue?-1:1;if(ue&&ae&&v.kind!=="conflict"&&G.kind!=="conflict"){let He=v.u.toks,ve=G.u.toks,Ze=pt=>pt.length&&pt.every(Xe=>Xe.kind==="open"),Je=pt=>pt.length&&pt.every(Xe=>Xe.kind==="close");if(Ze(He)&&Ze(ve)){let pt=Math.max(...He.map(dt=>H(A(v),dt.k))),Xe=Math.max(...ve.map(dt=>H(A(G),dt.k)));if(pt!==Xe)return Xe-pt}if(Je(He)&&Je(ve)){let pt=Math.min(...He.map(dt=>k(A(v),dt.k))),Xe=Math.min(...ve.map(dt=>k(A(G),dt.k)));return pt!==Xe?Xe-pt:J(G)-J(v)}}let Pe=He=>He.u&&He.u.lead?1:0;return Pe(G)-Pe(v)||J(v)-J(G)||v.be-G.be});let W=[],F=[],Oe=0,Ce=v=>{v>Oe&&(W.push({bs:Oe,be:v,toks:e.slice(Oe,v),source:"base"}),Oe=v)};for(let v of _){if(Ce(v.bs),v.kind==="conflict"){let G=gs(e,v.localHunks,v.bs,v.be),ue=gs(e,v.remoteHunks,v.bs,v.be),ae=o==="local"?G:o==="both"?G.concat(ue):ue,Pe=(Ze,Je)=>{let pt=0;for(let Xe of Ze)Xe.be<=v.bs&&!Je.includes(Xe)&&(pt+=Xe.toks.length-(Xe.be-Xe.bs));return pt},He=v.bs+Pe(s,v.localHunks),ve=v.bs+Pe(c,v.remoteHunks);F.push({bs:v.bs,be:v.be,ls:He,le:He+G.length,rs:ve,re:ve+ue.length,ms:0,me:0,base:e.slice(v.bs,v.be),local:G,remote:ue,resolved:ae}),W.push({bs:v.bs,be:v.be,toks:ae,source:"conflict",localHunks:v.localHunks,localToks:G,keepsLocal:o!=="remote"})}else W.push({bs:v.bs,be:v.be,toks:v.u.toks,source:v.kind==="R"?"remote":"local",localHunks:v.kind==="R"?[]:[v.u.l]});Oe=Math.max(Oe,v.be)}Ce(e.length);let De=0,pe=0;for(let v of W)v.source==="conflict"&&(F[pe].ms=De,F[pe].me=De+v.toks.length,pe++),De+=v.toks.length;let Te=new Map(l.map(v=>[v.bi,v.tok])),ze=new Map(a.map(v=>[v.bi,v.tok])),Me=[];for(let v of W){v.source==="base"&&(v.toks=v.toks.map((G,ue)=>{let ae=v.bs+ue,Pe=Te.get(ae),He=ze.get(ae),ve=Pe&&He?o==="remote"?He:Pe:Pe||He||G;return ve===G?G:{...ve,cosmetic:!0}}));for(let G of v.toks)Me.push({...G,src:v.source})}return{tokens:Me,segments:W,conflicts:F,localHunks:s,remoteHunks:c,collapsedDelta:y,samePoint:N,mapLocalOffset:da(e,s,W)}}function gs(e,t,n,o){let r=[],i=n;for(let s of t)r=r.concat(e.slice(i,s.bs),s.toks),i=s.be;return r.concat(e.slice(i,o))}var ps=e=>e.reduce((t,n)=>t+n.len,0);function da(e,t,n){let o=new Int32Array(e.length+1);for(let s=0;s<e.length;s++)o[s+1]=o[s]+e[s].len;let r=t.map(s=>({bs:o[s.bs],be:o[s.be],text:s.toks.map(c=>c.raw).join(""),ref:s})),i=n.map(s=>({bs:o[s.bs],be:o[s.be],len:ps(s.toks),source:s.source,localHunks:s.localHunks||[],localLen:s.localToks?ps(s.localToks):0,keepsLocal:s.keepsLocal,ref:s}));return s=>{let c=null,l=null,a=0,p=0,f=0;for(let w of r){let b=w.bs-f;if(s<=p+b){c=f+(s-p);break}if(p+=b,f=w.bs,s<=p+w.text.length){l=w,a=s-p,c=w.bs;break}p+=w.text.length,f=w.be}c===null&&(c=f+(s-p));let h=0;for(let w of i){if(!l&&c<=w.bs)return h;if(!(l?w.localHunks.includes(l.ref):c<w.be)){h+=w.len;continue}if(w.source==="base")return h+(c-w.bs);if(w.source==="remote")return h+w.len;if(w.source==="local")return h+Math.min(a,w.len);if(!w.keepsLocal||!l)return h+w.len;let T=w.localHunks.indexOf(l.ref),g=ps(gs(e,w.localHunks.slice(0,T),w.ref.bs,l.ref.bs));return h+Math.min(g+a,w.localLen)}return h}}function Go(e,t,n,o="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:d=>Math.min(d,t.length),granularity:"word"};let r=dn(e,t,n),i=en(e,r),s=en(t,r),c=en(n,r),l=i.length<=2e4&&s.length<=2e4&&c.length<=2e4?Ii(i,s,c,o):null,a="word",p=i;if(!l){let d=y=>y.split(/(?<=\n)/).map(N=>({k:N,raw:N,len:N.length}));p=d(e),l=Ii(p,d(t),d(n),o),a="line"}let f=d=>d.map(y=>y.raw).join(""),h=d=>{let y=[0];for(let N of d)y.push(y[y.length-1]+N.len);return y},w=h(p),b=null,T=null,g=null;if(l.conflicts.length){let d=y=>y.split(/(?<=\n)/).map(N=>({k:N,raw:N,len:N.length}));b=h(a==="line"?d(t):s),T=h(a==="line"?d(n):c),g=h(l.tokens)}return{text:f(l.tokens),conflicts:l.conflicts.map(d=>({bs:w[d.bs],be:w[d.be],ls:b[d.ls],le:b[d.le],rs:T[d.rs],re:T[d.re],ms:g[d.ms],me:g[d.me],base:f(d.base),local:f(d.local),remote:f(d.remote),resolved:f(d.resolved)})),mapLocalOffset:l.mapLocalOffset,granularity:a}}function io(e,t,n=4e3){if(e===t)return[];let o=dn(e,t),r=en(e,o),i=en(t,o),s=Wn(r,i,n),c=[0];for(let l of r)c.push(c[c.length-1]+l.len);return s.hunks.map(l=>({bs:c[l.bs],be:c[l.be],text:l.toks.map(a=>a.raw).join("")}))}function _t(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Cn({base:e,side:t,retained:n,transfers:o,baseAtomKey:r=c=>c.el,sideAtomKey:i=c=>c.el,budget:s=_t()}){let c=[],l=S=>({status:"fallback",reason:S}),a=S=>S>s.remaining?!1:(s.remaining-=S,!0);if(!a((n.length+o.length)*3))return l("work-limit");for(let[S,O]of[["retained",n],["transfer",o]])for(let R of O){let{from:M,to:j,target:U}=R;if(!Number.isInteger(M)||!Number.isInteger(j)||!Number.isInteger(U)||M<0||j<=M||j>e.text.length||U<0||U+j-M>t.text.length)return l("invalid-range");c.push({...R,kind:S})}let p=Symbol(),f=S=>(O,R)=>{if(!a(1))throw p;return s.sortComparisons++,S(O,R)},h,w;try{h=c.slice().sort(f((S,O)=>S.from-O.from||S.to-O.to)),w=c.slice().sort(f((S,O)=>S.target-O.target||S.to-S.from-(O.to-O.from)))}catch(S){if(S===p)return l("work-limit");throw S}if(!a(c.length*2))return l("work-limit");for(let S=1;S<h.length;S++)if(h[S].from<h[S-1].to)return l("source-overlap");for(let S=1;S<w.length;S++)if(w[S].target<w[S-1].target+w[S-1].to-w[S-1].from)return l("target-overlap");for(let S of h){let O=S.to-S.from;if(!a(O))return l("work-limit");for(let R=0;R<O;R++){let M=S.from+R,j=S.target+R;if(s.comparisons++,e.text[M]!==t.text[j])return l("unequal-occurrence");let U=e.atomAt.get(M),K=t.atomAt.get(j);if(!!U!=!!K||U&&r(U)!==i(K))return l("different-atom")}}let b=e.text.length+t.text.length+2,T=c.reduce((S,O)=>S+(O.to-O.from)*2,2);if(!a(b+T+c.length))return l("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),d=new Int32Array(t.text.length+1).fill(-1);s.mapCells+=b,s.mapWrites+=T;let y=-1,N=!0;for(let S of h){S.target<y&&(N=!1),y=S.target+S.to-S.from;for(let O=0;O<S.to-S.from;O++)g[S.from+O]=S.target+O,d[S.target+O]=S.from+O}return g[e.text.length]=t.text.length,d[t.text.length]=e.text.length,{status:"ready",runs:h,bTo:g,toB:d,monotone:N,covers:(S,O)=>{if(!a(O-S))return null;s.coverageChecks+=O-S;for(let R=S;R<O;R++)if(e.text[R]!==wt&&!/\s/.test(e.text[R])&&g[R]<0)return!1;return!0}}}function ws({base:e,side:t,baseOf:n=()=>null,budget:o=_t()}){if(e.text===t.text||!e.text.includes(wt)&&!t.text.includes(wt))return{status:"none"};let r=(e.text.length+t.text.length)*8;if(r>o.remaining)return{status:"fallback",reason:"work-limit"};o.remaining-=r,o.boundarySteps=(o.boundarySteps||0)+r;let i=(b,T)=>T<b.length&&(b[T]===wt||/\s/.test(b[T])),s=new Map,c=Symbol(),l=(b,T)=>{let g=b.stackAt[T]||[];if(!s.has(g)){if(g.length>o.remaining)throw c;o.remaining-=g.length,o.boundarySteps+=g.length,s.set(g,g.find(d=>d.block)?.el||null)}return s.get(g)},a=[],p=(b,T)=>{let g=l(e,b),d=l(t,T),y=g&&d&&n(d)!==g?"transfer":"retained",N=a[a.length-1];N&&N.to===b&&N.target+N.to-N.from===T&&N.kind===y&&N.destination===d?N.to++:a.push({from:b,to:b+1,target:T,destination:d,kind:y})},f=0,h=0,w=!1;try{for(;f<e.text.length||h<t.text.length;){if(f<e.text.length&&h<t.text.length&&e.text[f]===t.text[h]){let N=e.atomAt.get(f),x=t.atomAt.get(h);if(!!N!=!!x||N&&n(x.el)!==N.el)return{status:"none"};p(f++,h++);continue}if(!i(e.text,f)&&!i(t.text,h))return{status:"none"};let b=f,T=h;for(;i(e.text,f);)f++;for(;i(t.text,h);)h++;let g=e.text.slice(b,f),d=t.text.slice(T,h);(g.includes(wt)||d.includes(wt))&&(w=!0);let y=0;for(;y<f-b&&y<h-T&&e.text[f-y-1]===t.text[h-y-1];)y++;for(let N=y;N>0;N--)p(f-N,h-N)}}catch(b){if(b===c)return{status:"fallback",reason:"work-limit"};throw b}return w?Cn({base:e,side:t,retained:a.filter(b=>b.kind==="retained"),transfers:a.filter(b=>b.kind==="transfer"),sideAtomKey:b=>n(b.el)||b.el,budget:o}):{status:"none"}}var Ci=/\s/,Mr=/\S/;function An(e,t,n,o,r,i,s=-1,c=-1){if(!e.length)return-1;r(o,e.length);let l=new Int32Array(e.length),a=0;for(let w=1;w<e.length;w++){for(r(o,1);a&&(r(o,1),e[a]!==e[w]);)a=l[a-1];r(o,1),e[a]===e[w]&&a++,l[w]=a}let p=-1,f=0,h=0;a=0;for(let w=0;w<t.length;w++){for(r(o,1);a&&(r(o,1),e[a]!==t[w]);)a=l[a-1];if(r(o,1),e[a]===t[w]&&a++,a!==e.length)continue;let b=w+1-e.length,T=w+1;for(a=l[a-1];f<n.length&&n[f].from<b;)r(o,1),f++;for(;h<n.length&&n[h].to<T;)r(o,1),h++;if(r(o,6),!(f===n.length||h===n.length||n[f].from!==b||n[h].to!==T||s>=0&&b<c&&T>s)){if(!i)return b;if(p>=0)return-1;p=b}}return p}function Xo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function xs(e,t,n,o){let r=null;for(let s of t)if(o(n,1),!(s.source!==e.source||s.side!==e.side))for(let c of s.runs){if(o(n,1),c.source!==e.source)continue;let l=Math.max(e.from,c.from),a=Math.min(e.to,c.to);l>=a||(r||(o(n,e.to-e.from),r=new Uint8Array(e.to-e.from)),o(n,a-l),r.fill(1,l-e.from,a-e.from))}if(!r)return!1;o(n,e.to-e.from);let i=!1;for(let s=e.from;s<e.to;s++)if(Mr.test(e.flat.text[s])){if(!r[s-e.from])return!1;i=!0}return i}function ks({source:e,side:t,views:n,eligible:o,blocked:r,baseId:i,model:s,tokensOf:c,budget:l,charge:a}){let{V:p,A:f,idOf:h}=n[t],w=n[1-t];if(e.nodeType!==1||f.identical.has(e)||w.A.identical.has(e)||r.has(e)||!o(e))return null;let b=p.twin(e),T=w.V.twin(e);if(!b||!T||f.map.get(e)!==b||f.reverse.get(b)!==e||w.A.map.get(e)!==T||w.A.reverse.get(T)!==e||!p.here(b)||!w.V.here(T)||!o(b)||!o(T))return null;let g=i(e);if(g!==h(b)||g!==w.idOf(T))return null;let d=s(e,null,l),y=s(b,f,l),N=s(T,w.A,l);if(!Xo(d)||!Xo(y)||!Xo(N))return null;let x=d.flat.text,S=y.flat.text;if(a(l,x.length+S.length*3),!Mr.test(S)||S.length>=x.length)return null;let O=x.startsWith(S),R=x.endsWith(S);if(O===R)return null;let M=O?S.length:0,j=O?x.length:x.length-S.length,U=M,K=j;for(;U<K&&(a(l,1),!!Ci.test(x[U]));)U++;for(;K>U&&(a(l,1),!!Ci.test(x[K-1]));)K--;if(U===K)return null;let _=c(d,l),H=!1,k=!1;for(let A of _)a(l,1),A.from===U&&(H=!0),A.to===K&&(k=!0);return!H||!k?null:{source:e,side:t,flat:d.flat,from:M,to:j}}function Ri({base:e,views:t,side:n,attempt:o,eligible:r,blocked:i,baseId:s,model:c,tokensOf:l,certificates:a,charge:p,exhausted:f,limit:h}){if(h<=0)return null;let w=_t(h),{V:b,A:T,idOf:g}=t[n],d=t[1-n],[y,N,x,S]=o,O=null;try{for(let R=y;R<=N;R++){p(w,1);let M=e[R];if(M.nodeType!==1||T.identical.has(M)||d.A.identical.has(M)||i.has(M)||!r(M))continue;let j=ks({source:M,side:n,views:t,eligible:r,blocked:i,baseId:s,model:c,tokensOf:l,budget:w,charge:p});if(!j||xs(j,a,w,p))continue;let{flat:U,from:K,to:_}=j;p(w,(_-K)*2);let H=U.text.slice(K,_).trim();for(let k=x;k<=S;k++){p(w,1);let A=b.units[k],J=b.baseOf(A);if(!J||J===M||J.nodeType!==1||A.nodeType!==1||J.parentNode!==M.parentNode||A.parentNode!==T.map.get(M).parentNode||T.map.get(J)!==A||T.reverse.get(A)!==J||i.has(J)||!r(J)||!r(A)||s(J)!==g(A))continue;let W=c(J,null,w),F=c(A,T,w);if(!Xo(W)||!Xo(F))continue;let Oe=W.flat.text,Ce=F.flat.text;if(p(w,Oe.length),!Mr.test(Oe)||Ce.length<=Oe.length)continue;let De=l(F,w),pe=An(Oe,Ce,De,w,p,!0);if(!(pe<0)&&!(An(H,Ce,De,w,p,!1,pe,pe+Oe.length)<0)){(O||=[]).push(j);break}}}}catch(R){if(R!==f)throw R}return O}function Li(e,t,n,o,r,i,s){if(i==="both"||n.atoms.length||o.atoms.length||r.atoms.length)return i;let c=i==="remote";if(c?s.rss!==s.rse||s.lss===s.lse||s.local===s.base:s.lss!==s.lse||s.rss===s.rse||s.remote===s.base)return i;for(let l of e){if(l.source!==t||l.side!==(c?1:0)||l.flat.text!==n.text||l.flat.nodes.length!==n.nodes.length||s.be<=l.from||s.bs>=l.to)continue;let a=!0;for(let f=0;f<n.nodes.length;f++){let h=l.flat.nodes[f],w=n.nodes[f];if(h.node!==w.node||h.s!==w.s||h.e!==w.e){a=!1;break}}if(!a)continue;let p=!1;for(let f=s.bs;f<s.be;f++)if(Mr.test(n.text[f])){if(f<l.from||f>=l.to){a=!1;break}p=!0}if(a&&p)return c?"local":"remote"}return i}var Rn="\uFFFC";var ha={caret:0},hn=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(" ")),Wi=new Set(["BR","WBR","IMG"]),As=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 Ln(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||Wi.has(e.tagName))return!0;if(!hn.has(e.tagName))return!As.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(!Ln(r,t)){o=!1;break}return t.inlineCache&&t.inlineCache.set(e,o),o}function pa(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function zt(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,i)=>{for(let s of r){if(s.nodeType===3){let f=s.nodeValue;if(!f)continue;n.nodes.push({node:s,s:n.text.length,e:n.text.length+f.length}),n.text+=f;for(let h=0;h<f.length;h++)n.stackAt.push(i);continue}if(s.nodeType!==1)continue;if(t.ignored&&t.ignored(s)){n.pins.push({el:s,i:n.text.length});continue}if(t.skip&&t.skip.has(s))continue;let c=t.via&&t.via(s)||s;c!==s&&(n.via||(n.via=new Map)).set(c,s);let l=s.tagName;if(t.blocks&&t.blocks.has(s)){n.text.length&&n.text[n.text.length-1]!==wt&&(n.stackAt.push(i),n.text+=wt);let f={el:s,tag:l,from:n.text.length,to:-1,depth:i.length,block:!0};n.marks.push(f);let h=i.concat([f]);o(c.childNodes,h),n.stackAt.push(h),n.text+=wt,f.to=n.text.length;continue}let a=hn.has(l)&&pa(c);if(Wi.has(l)||!hn.has(l)||t.remoteWins&&t.remoteWins(s)||t.atomize&&t.atomize(s)||a){n.atoms.push({i:n.text.length,el:s,key:a?l+":empty":l,stack:i}),n.stackAt.push(i),n.text+=Rn;continue}let p={el:s,tag:l,from:n.text.length,to:-1,depth:i.length};n.marks.push(p),o(c.childNodes,i.concat([p])),p.to=n.text.length}};if(o(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&Cr(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 ma(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function ga(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,"&quot;")}"`;return t+">"}function No(e,t,n){let o="",r=[];for(let i=t;i<n;i++){let s=e.stackAt[i],c=0;for(;c<r.length&&c<s.length&&r[c]===s[c];)c++;for(;r.length>c;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<s.length;){let a=s[r.length];o+=ga(a.el),r.push(a)}let l=e.atomAt.get(i);o+=l?l.el.outerHTML:e.text[i]===wt?"":ma(e.text[i])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function ba(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 _i(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 Pi(e,t=()=>!1){let n=new Map,o=i=>{let s=n.get(i);return s===void 0&&(s="{"+i.map(c=>ba(c,t)).sort().join(",")+"}",n.set(i,s)),s},r="";for(let i=0;i<e.text.length;i++){let s=e.atomAt.get(i);r+=(s?"["+_i(s.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,s=0,c=l=>{if(l<=s)return;let a=i.slice(s,l);if(n)for(let p of a.split(/(?<=\n)/))r.push({k:p,raw:p,len:p.length});else for(let p of en(a,t))r.push(p)};for(let l of e.atoms)c(l.i),r.push({k:"\0"+o(l),raw:Rn,len:1,atom:!0}),s=l.i+1;return c(i.length),r}function Cr(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 vo=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 Er(e,t,n,o){let r=vo(t),i=vo(n),s=[],c=0,l=0;for(let p of o.hunks){l+=p.bs-c;let f=l+p.toks.length;s.push({bs:r[p.bs],be:r[p.be],ss:i[l],se:i[f],text:e.text.slice(i[l],i[f]),toks:p.toks,lead:!!p.lead}),l=f,c=p.be}let a=new Map;for(let p of o.cosmetic)a.set(p.bi,p.tok.raw);return{hunks:s,respell:a}}function ji(e,t,n){let o=s=>s===wt||/\s/.test(s),r=s=>s.replace(/[\u001E\s]/g,""),i=[];for(let s of e){let c=t.slice(s.bs,s.be),l=n.slice(s.ss,s.se);if(!c.includes(wt)&&!l.includes(wt)||c.includes(Rn)||l.includes(Rn)||r(c)!==r(l)){i.push(s);continue}let a=0,p=0;for(;;){let f=a,h=p;for(;f<c.length&&o(c[f]);)f++;for(;h<l.length&&o(l[h]);)h++;let w=a,b=p;for(;w<f&&b<h&&c[w]===l[b];)w++,b++;let T=f,g=h;for(;T>w&&g>b&&c[T-1]===l[g-1];)T--,g--;if(T>w||g>b){let d=l.slice(b,g);i.push({bs:s.bs+w,be:s.bs+T,ss:s.ss+b,se:s.ss+g,text:d,toks:[...d].map(y=>({k:y,raw:y,len:1})),lead:s.lead})}if(f>=c.length)break;a=f+1,p=h+1}}return i}function Di(e,t,n){let o=new Int32Array(t+1).fill(-1),r=new Int32Array(n+1).fill(-1),i=0,s=0,c=l=>{for(;i<l;)o[i]=s,r[s]=i,i++,s++};for(let l of e)c(l.bs),i=l.be,s=l.se;return c(t),o[t]=s,r[s]=t,{bTo:o,toB:r}}function Bi(e,t,n){let o=[],r=0,i=0,s=(c,l)=>{if(r===c&&i===l)return;let a=t.text.slice(i,l);o.push({bs:r,be:c,ss:i,se:l,text:a,toks:en(a,dn(a)),lead:!1})};for(let c of n.runs)s(c.from,c.target),r=c.to,i=c.target+c.to-c.from;return s(e.text.length,t.text.length),{hunks:o,respell:new Map}}function Ui(e,t,n,o){let r=vo(t),i=vo(n),s=(l,a)=>{let p=0,f=l.length;for(;p<f;){let h=p+f>>>1;l[h]<a?p=h+1:f=h}return l[p]===a?p:-1};for(let l of e.hunks)if(s(r,l.bs)<0||s(r,l.be)<0)return null;if(e.hunks.some(l=>s(i,l.ss)<0||s(i,l.se)<0)){if(!o)return null;let l=[];for(let h of e.hunks)l.push(h.ss,h.se);let a=[],p=0,f=0;for(let h of n){let w=f+h.len;for(;p<l.length&&l[p]<=f;)p++;let b=f;for(;p<l.length&&l[p]<w;){let T=l[p++];if(T>b){let g=h.raw.slice(b-f,T-f);a.push(...en(g,dn(g))),b=T}}if(b===f)a.push(h);else{let T=h.raw.slice(b-f);a.push(...en(T,dn(T)))}f=w}n=a,i=vo(n)}let c=[];for(let l of e.hunks){let a=s(r,l.bs),p=s(r,l.be),f=s(i,l.ss),h=s(i,l.se);if(a<0||p<0||f<0||h<0)return null;c.push({bs:a,be:p,toks:n.slice(f,h),gap:[],group:c.length})}return{parts:c,cosmeticEq:[],tokens:n}}function Ts(e,t,n,o={},r=null){return $i(e,t,n,o.base,o.local,o.remote,r,{})}function $i(e,t,n,o,r,i,s,c){let l=dn(Cr(e),Cr(t),Cr(n)),a=So(e,l,!1,o),p=So(t,l,!1,r),f=So(n,l,!1,i),h=a.length>2e4||p.length>2e4||f.length>2e4;h&&(a=So(e,l,!0,o),p=So(t,l,!0,r),f=So(n,l,!0,i));let w=s?.local?Bi(e,t,s.local):null,b=s?.remote?Bi(e,n,s.remote):null,T=w?Ui(w,a,p,!h):Wn(a,p),g=b?Ui(b,a,f,!h):Wn(a,f);w&&T&&(p=T.tokens),b&&g&&(f=g.tokens);let d,y;if(T&&g){let N=bs(T,g,a);d=Er(t,a,p,{hunks:N.lh,cosmetic:N.cosL}),y=Er(n,a,f,{hunks:N.rh,cosmetic:N.cosR})}else d=w||Er(t,a,p,T),y=b||Er(n,a,f,g);return d.hunks=ji(d.hunks,e.text,t.text),y.hunks=ji(y.hunks,e.text,n.text),c.base=e,c.local=t,c.remote=n,c.lines=h,c.baseTokens=a,c.localEdits=d,c.remoteEdits=y,c.localMap=Di(d.hunks,e.text.length,t.text.length),c.remoteMap=Di(y.hunks,e.text.length,n.text.length),c.full=null,c}function Hi(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Oo=/\s/;function Ir(e,t,n){for(let o=t;o<n;o++)if(!Oo.test(e[o]))return!1;return!0}function ya(e,t,n){let o=e.cache[n]||(e.cache[n]=new Map);if(o.has(t))return o.get(t);let r=n===0?"local":"remote",i=n===0?"remote":"local",s=t.baseMark,c=t[i+"Mark"],l=!t.block&&!t[r]&&!!c&&s.to>s.from;if(l){let a=n===0?e.ML:e.MR,p=n===0?e.MR:e.ML,f=n===0?e.fr:e.fl,h=!1;for(let w=s.from;w<s.to;w++){if(a.bTo[w]>=0){l=!1;break}p.bTo[w]<0&&!Oo.test(e.fb.text[w])&&(h=!0)}if(l&&!h){for(let w=c.from;w<c.to;w++)if(p.toB[w]<0&&!Oo.test(f.text[w])){h=!0;break}}l&&=h}return o.set(t,l),l}function Vi(e,t,n,o,r,i,s,c,l){let a=c===0?e.fl:e.fr,p=null;for(let f=n;f<o;f++){let h=t[f];if(!Ir(a.text,h.ss,h.se))return null;if(Ir(e.fb.text,h.bs,h.be)){if(h.bs<h.be&&h.ss<h.se||Oo.test(e.fb.text[h.bs-1]||"")||Oo.test(e.fb.text[h.be]||""))continue;return null}let w=!1;for(let b=h.bs;b<h.be;b++){if(Oo.test(e.fb.text[b]))continue;let T=null;for(let g of e.fb.stackAt[b]){let d=e.byEl.get(g.el);if(d&&ya(e,d,c)){T=d;break}}if(!T)return null;(p||(p=new Set)).add(T),w=!0}if(!w)return null}if(!p){if((c===0?"local":"remote")!==l)return null;let f=c===0?e.fr:e.fl,h=!1;for(let w=i;w<s;w++){let b=r[w];if(!Ir(e.fb.text,b.bs,b.be))return null;Ir(f.text,b.ss,b.se)||(h=!0)}if(!h)return null}return p||0}function Rr(e){let{out:t,policy:n="remote",L:o,R:r}=e,i=e.provenance||new WeakMap,s=e.textMappers||new WeakMap,c=e.conflicts||[],l=e.decisions||[],a=c.length,p=e.conflict||(u=>c.push(u)),f={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},h=[],w=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),b={base:null,local:null,remote:null};if(!e.prepared&&w&&e.moveIn){let u=ye=>Re=>ye.some(he=>he===Re||he.nodeType===1&&he.contains(Re)),E=u(e.local),L=u(e.remote),D=u(e.base),z=new Set,oe=ye=>{if(!hn.has(ye.tagName))return;let Re=o.map.get(ye),he=r.map.get(ye);(Re&&!E(Re)||he&&!L(he))&&z.add(ye);for(let Ie of ye.children)oe(Ie)};for(let ye of e.base)ye.nodeType===1&&oe(ye);let ge=ye=>Re=>{if(!hn.has(Re.tagName))return!1;let he=ye.reverse.get(Re);return!!he&&(z.has(he)||!D(he))};z.size&&(b.base=ye=>z.has(ye)),b.local=ge(o),b.remote=ge(r)}let T={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&w&&e.moveIn){let u=D=>z=>D.some(oe=>oe===z||oe.nodeType===1&&oe.contains(z)),E=u(e.local),L=u(e.remote);for(let D of zt(e.base,{...e,atomize:b.base}).atoms){let z=o.map.get(D.el),oe=r.map.get(D.el),ge=!!z&&!E(z),ye=!!oe&&!L(oe);!ge&&!ye||(ge&&e.movePlanned?.(D.el,"local",z,null),ye&&e.movePlanned?.(D.el,"remote",oe,null),T.base.add(D.el),z&&!ge&&T.local.add(z),oe&&!ye&&T.remote.add(oe),E(D.el)&&T.local.add(D.el),L(D.el)&&T.remote.add(D.el))}}let g=e.prepared?.base||zt(e.base,{...e,atomize:b.base,skip:T.base}),d=e.prepared?.local||zt(e.local,{...e,atomize:b.local,skip:T.local}),y=e.prepared?.remote||zt(e.remote,{...e,atomize:b.remote,skip:T.remote}),N=new Map(g.atoms.map(u=>[u.el,u])),x={},S=u=>e.prepared?e.prepared.full?.(u)||null:T[u].size?(x[u]||(x[u]=zt(e[u],{...e,atomize:b[u]})),x[u]):null,O=(u,E,L)=>{E.namespaceURI?u.setAttributeNS(E.namespaceURI,E.name,L):u.setAttribute(E.name,L)},R=(u,E,L,D)=>{if(!E&&(!L||!D)){for(let oe of(L||D).attributes)O(u,oe,oe.value);return}let z=new Map;for(let oe of[E,L,D])if(oe)for(let ge of oe.attributes)z.set(ge.name,ge);for(let[oe,ge]of z){let ye=E?E.getAttribute(oe):null,Re=L?L.getAttribute(oe):ye,he=D?D.getAttribute(oe):ye,Ie;Re===he?Ie=Re:Re===ye?(Ie=he,l.push({kind:"attr",el:u,name:oe,source:"remote"})):he===ye?(Ie=Re,l.push({kind:"attr",el:u,name:oe,source:"local"})):(Ie=n==="local"?Re:he,p({kind:"attr",el:u,name:oe,base:ye,local:Re,remote:he,resolved:Ie},{el:u,sample:ge}),l.push({kind:"attr",el:u,name:oe,source:"both"})),Ie!=null&&O(u,ge,Ie)}},M=(u,E,L,D)=>u&&e.mergeAttrs?e.mergeAttrs(u,E,L,D):R(D,u,E,L),j=e.mergeElement||((u,E,L)=>{let D=t.createElement(u.tagName);M(u,E,L,D);let z=E||u,oe=L||u,ge=n==="local"?z.isEqualNode(u)?oe:z:oe.isEqualNode(u)?z:oe;for(let ye of ge.childNodes)D.appendChild(t.importNode(ye,!0));return i.set(D,{base:u,local:E,remote:L}),D}),U=e.cloneUnit||((u,E)=>{let L=t.importNode(u,!0);return i.set(L,{base:null,local:E==="local"?u:null,remote:E==="remote"?u:null}),L}),K=e.atomKey||(u=>_i(u,()=>!1)),_=(u,E)=>{let L=new Map;for(let D of u.atoms)if(e.remoteWins&&e.remoteWins(D.el)&&hn.has(D.el.tagName))L.set(D,"w"+D.el.tagName+"#"+(D.el.id||""));else if(!w)L.set(D,D.key);else if(u===g)L.set(D,"="+K(D.el));else{let z=E.reverse.get(D.el),oe=z?N.get(z):null;oe?L.set(D,"="+K(oe.el)):z?L.set(D,"m"+K(D.el)):L.set(D,"="+K(D.el))}return D=>L.get(D)},H=_(g,null),k=_(d,o),A=_(y,r),J=e.certifiedOrigins?e.certifiedOrigins(g,d,y,H,k,A):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let u=_t(),E=ws({base:g,side:d,baseOf:D=>o?.reverse?.get(D)||null,budget:u}),L=ws({base:g,side:y,baseOf:D=>r?.reverse?.get(D)||null,budget:u});(E.status==="ready"||L.status==="ready")&&(J={local:E.status==="ready"?E:null,remote:L.status==="ready"?L:null})}let W=e.prepared||$i(g,d,y,H,k,A,J,f),F=W.lines,Oe=W.baseTokens,Ce=W.localEdits,De=W.remoteEdits,pe=W.localMap,Te=W.remoteMap,ze=g.text.length,Me=u=>new Map(u.atoms.map(E=>[E.el,E])),v=Me(d),G=Me(y),ue=(u,E,L)=>{let D=new Set;if(!w)return D;for(let z of u.atoms){let oe=N.get(E.reverse.get(z.el));oe&&L.bTo[oe.i]<0&&D.add(oe)}return D},ae=ue(d,o,pe),Pe=ue(y,r,Te),He=u=>!Ln(u,{...e,remoteWins:null}),ve=new Set;if(w)for(let u of g.atoms){if(!He(u.el))continue;let E=o.map.get(u.el)||null,L=r.map.get(u.el)||null,D=E&&!L?E:L&&!E?L:null;D&&(v.has(D)||G.has(D))&&!D.isEqualNode(u.el)&&ve.add(u)}let Ze=1,Je=(u,E)=>({id:Ze++,tag:u,base:null,local:null,remote:null,rank:E}),pt=new Map,Xe=[];for(let u of g.marks){let E=Je(u.tag,u.depth);E.block=!!u.block,E.base=u.el,E.baseMark=u,pt.set(u.el,E),Xe.push(E)}let dt=(u,E)=>{let L=-1,D=-1;for(let z=u.from;z<u.to;z++){let oe=E[z];oe>=0&&(L<0&&(L=oe),D=oe+1)}return L<0?null:[L,D]},St=(u,E,L,D)=>{for(let z of u.marks){let oe=L?L.reverse.get(z.el):null;oe&&L.identical.has(oe)&&L.pairIdenticalChildren&&L.pairIdenticalChildren(oe);let ge=oe?pt.get(oe):null;if(ge&&ge[E]&&(ge=null),!ge){let ye=dt(z,D),Re=0;if(ye)for(let he of Xe){if(he.tag!==z.tag||he[E]||!!he.block!=!!z.block)continue;let Ie=Math.min(ye[1],he.baseMark.to)-Math.max(ye[0],he.baseMark.from);(Ie>Re||Ie===Re&&Ie>0&&Math.abs(he.rank-z.depth)<Math.abs(ge.rank-z.depth))&&(ge=he,Re=Ie)}}ge||(ge=Je(z.tag,z.depth),ge.block=!!z.block,ge.new=E),ge[E]=z.el,ge[E+"Mark"]=z,pt.set(z.el,ge)}};St(d,"local",o,pe.toB),St(y,"remote",r,Te.toB);let vt=u=>u.merged||u,bt=u=>{let E=new Set;for(let L of u)L.block||E.add(pt.get(L.el));return E},At=new Map,Ot=u=>{let E=At.get(u);return E||(E=bt(u),At.set(u,E)),E},Bt=(u,E)=>{let L=[],D=null;for(let z=0;z<ze;z++){let oe=E[z];if(oe<0){D&&L.push(D),D=null;continue}let ge=Ot(g.stackAt[z]),ye=Ot(u.stackAt[oe]),Re=new Set,he=new Set;for(let Ie of ye)ge.has(Ie)||Re.add(Ie);for(let Ie of ge)ye.has(Ie)||he.add(Ie);if(!Re.size&&!he.size){D&&L.push(D),D=null;continue}if(D&&Hi(D.added,Re)&&Hi(D.removed,he)){D.be=z+1;continue}D&&L.push(D),D={bs:z,be:z+1,added:Re,removed:he}}return D&&L.push(D),L},tn=Bt(d,pe.bTo),Nt=Bt(y,Te.bTo),$t=u=>u.be>u.bs?[u.bs,u.be-1]:[u.bs-1,u.bs],cn=(u,E)=>{if(ze===0)return null;let[L,D]=$t(u);for(let z of E){if(z.be<=L)continue;if(z.bs>D)break;let oe=z.bs<=L&&D<z.be;return oe&&u.text===""&&z.bs===u.bs&&z.be===u.be?"straddle":oe?z:u.be>u.bs?"straddle":null}return null},Pt=u=>u.bs===u.be,Jt=(u,E,L=null)=>{let D=!1;for(let z=u.bs;z<u.be;z++){let oe=g.text[z];if(oe===wt)D=!0;else if(!/\s/.test(oe))return!1}for(let z=u.ss;z<u.se;z++){let oe=E.text[z];if(oe===wt)D=!0;else if(!/\s/.test(oe)){let ge=L&&e.scopeUnits&&Pt(u)&&E.atomAt.get(z);if(!ge||!He(ge.el)||L.ss!==L.se||L.bs>=L.be)return!1;for(let Re=L.bs;Re<L.be;Re++)if(!/\s/.test(g.text[Re]))return!1;let ye=E===d?1:2;if(!e.scopeUnits[ye].includes(ge.el)||(ye===1?o:r)?.reverse.has(ge.el))return!1;D=!0}}return D},Ft=(u,E)=>u.bs<E.be&&E.bs<u.be,nn=(u,E)=>u.bs<=E.be&&E.bs<=u.be&&Pt(u)!==Pt(E),X=(u,E)=>g.text.slice(u.bs,u.be).includes(wt)||E.text.slice(u.ss,u.se).includes(wt),m=u=>{if(Pt(u))return!1;let E=u.bs,L=u.be;for(;E>0&&/\s/.test(g.text[E-1]);)E--;for(;L<g.text.length&&/\s/.test(g.text[L]);)L++;return(E===0||g.text[E-1]===wt)&&(L===g.text.length||g.text[L]===wt)},I=(u,E)=>!X(u,E)&&!m(u),P=(u,E)=>Ft(u,E)||nn(u,E)&&!(u.transferIn||u.transferOut||E.transferIn||E.transferOut)&&!(Jt(u,d,E)&&I(E,y))&&!(Jt(E,y,u)&&I(u,d)),$=(u,E)=>{if(u.bs!==E.bs||u.be!==E.be||u.toks.length!==E.toks.length)return!1;let L=u.ss,D=E.ss;for(let z=0;z<u.toks.length;z++){let oe=u.toks[z],ge=E.toks[z];if(oe.k!==ge.k||oe.atom&&!d.atomAt.get(L).el.isEqualNode(y.atomAt.get(D).el))return!1;L+=oe.len,D+=ge.len}return!0},Q=(u,E,L,D)=>{for(let z of g.atoms){if(z.i<u.bs||z.i>=u.be||D.has(z)||ve.has(z))continue;let oe=E.bTo[z.i],ge=oe>=0?L.atomAt.get(oe):null;if(ge&&!ge.el.isEqualNode(z.el))return!0}return!1},B=[],me=null,xe=null,fe=Ce.hunks,Se=De.hunks,V=0,Z=0,be=0,ke=0,we=0,te=u=>{u>be&&(B.push({src:"base",from:be,to:u,dL:ke,dR:we}),be=u)};for(;V<fe.length||Z<Se.length;){let u=fe[V],E=Se[Z],L=!!u&&(!E||u.bs<E.bs||u.bs===E.bs&&u.be<=E.be&&!E.lead);if(u&&E&&u.bs===E.bs&&Pt(u)&&Pt(E)){let Ht=Jt(u,d),qo=Jt(E,y);Ht!==qo&&(L=qo)}let D=L?u:E,z=L?E:u,oe=!!z&&$(u,E),ge=!!z&&(L?!!fe[V+1]&&$(fe[V+1],E):!!Se[Z+1]&&$(u,Se[Z+1])),ye=!!z&&!oe&&!ge&&(ze===0||P(u,E)),Re=ye,he=cn(D,L?Nt:tn);if(he==="straddle"&&(Re=!0),!Re&&D.be>D.bs&&(Re=Q(D,L?Te:pe,L?y:d,L?ae:Pe)),!Re&&oe){te(D.bs),B.push({src:"both",lfrom:u.ss,rfrom:E.ss,len:D.text.length,owner:u.owner||E.owner||null,transfer:u.transferIn||E.transferIn||null}),be=D.be,ke+=D.text.length-(D.be-D.bs),we+=D.text.length-(D.be-D.bs),V++,Z++;continue}if(!Re){te(D.bs),B.push({src:L?"local":"remote",from:D.ss,to:D.se,inherit:he&&he!=="straddle"?he:null,owner:D.owner||null,transfer:D.transferIn||null}),be=D.be,L?(ke+=D.text.length-(D.be-D.bs),V++):(we+=D.text.length-(D.be-D.bs),Z++);continue}let Ie=D.bs,Ye=D.be,nt=V,at=Z,jt=Ht=>Ht.bs<Ye&&Ht.be>Ie||Pt(Ht)&&(Ht.bs===Ie||Ht.bs===Ye);L?nt++:at++,ye&&(Ie=Math.min(Ie,z.bs),Ye=Math.max(Ye,z.be),L?at++:nt++);let Rt=!0;for(;Rt;){for(Rt=!1;nt<fe.length&&jt(fe[nt]);)Ie=Math.min(Ie,fe[nt].bs),Ye=Math.max(Ye,fe[nt].be),nt++,Rt=!0;for(;at<Se.length&&jt(Se[at]);)Ie=Math.min(Ie,Se[at].bs),Ye=Math.max(Ye,Se[at].be),at++,Rt=!0}let sn=Ie+ke,Qt=Ie+we,fn=Ye-Ie,pn=Ye-Ie;for(let Ht=V;Ht<nt;Ht++)fn+=fe[Ht].text.length-(fe[Ht].be-fe[Ht].bs);for(let Ht=Z;Ht<at;Ht++)pn+=Se[Ht].text.length-(Se[Ht].be-Se[Ht].bs);let En=sn+fn,In=Qt+pn;if(te(Ie),V<nt&&Z<at&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!d.atoms.length&&!y.atoms.length&&!g.pins.length&&!d.pins.length&&!y.pins.length){me||={fb:g,fl:d,fr:y,ML:pe,MR:Te,byEl:pt,cache:[null,null]};let Ht=Vi(me,fe,V,nt,Se,Z,at,0,n),qo=Vi(me,Se,Z,at,fe,V,nt,1,n);if(Ht===null!=(qo===null)){let Xr=Ht!==null,gi=Xr?Ht:qo;if(gi){xe||=new Map;for(let wc of gi)xe.set(wc,Xr?"local":"remote")}B.push(Xr?{src:"remote",from:Qt,to:In}:{src:"local",from:sn,to:En}),be=Ye,ke+=fn-(Ye-Ie),we+=pn-(Ye-Ie),V=nt,Z=at;continue}}let qt={kind:"text",node:e.node||null,base:No(g,Ie,Ye),local:No(d,sn,En),remote:No(y,Qt,In),resolved:null,range:null,bs:Ie,be:Ye,lss:sn,lse:En,rss:Qt,rse:In},ro=e.sourceRetentions?Li(e.sourceRetentions,e.scope?.base,g,d,y,n,qt):n;qt.resolved=ro==="local"?qt.local:ro==="remote"?qt.remote:qt.local+qt.remote,ro!=="remote"&&B.push({src:"local",from:sn,to:En,conflict:qt}),ro!=="local"&&B.push({src:"remote",from:Qt,to:In,conflict:qt});let so={site:"inline",policy:ro,fb:g,fl:d,fr:y,scope:e.scope||null,synthetic:!!e.synthetic,full:S,merged:f};h.push(so),p(qt,so),be=Ye,ke+=fn-(Ye-Ie),we+=pn-(Ye-Ie),V=nt,Z=at}te(ze);let re=g.text,q=[];if(Ce.respell.size||De.respell.size){let u=vo(Oe),E=[];for(let L=0;L<Oe.length;L++){let D=Oe[L].raw,z=Ce.respell.get(L)??D,oe=De.respell.get(L)??D;(z!==D||oe!==D)&&q.push([u[L],z!==D&&oe!==D?"both":z!==D?"local":"remote"]),E.push(z===oe?z:z===D?oe:oe===D||n==="local"?z:oe)}re=E.join("")}let le="",Ne=[],Le=[],je=[],Ae=[];for(let u of B){let E=le.length;if(u.src==="base"){for(let L=u.from;L<u.to;L++)Ne.push(L),Le.push(e.nativeTransfers?pe.bTo[L]:L+u.dL),je.push(e.nativeTransfers?Te.bTo[L]:L+u.dR),Ae.push(u);le+=re.slice(u.from,u.to)}else if(u.src==="both"){for(let L=0;L<u.len;L++){let D=u.transfer&&(u.transfer.side==="remote"?u.rfrom+L:u.lfrom+L);Ne.push(u.transfer&&D>=u.transfer.ss&&D<u.transfer.se?u.transfer.bs+D-u.transfer.ss:-1),Le.push(u.lfrom+L),je.push(u.rfrom+L),Ae.push(u)}le+=d.text.slice(u.lfrom,u.lfrom+u.len)}else{let L=u.src==="local"?d:y,D=u.transfer&&e.nativeTransfers.byOrigin[u.src==="local"?"remote":"local"].get(u.transfer.key);for(let z=u.from;z<u.to;z++){let oe=u.transfer&&z>=u.transfer.ss&&z<u.transfer.se?u.transfer.bs+z-u.transfer.ss:-1,ge=oe>=0&&(!D||D.destination===u.owner)?(u.src==="local"?Te:pe).bTo[oe]:-1;Ne.push(oe),Le.push(u.src==="local"?z:ge),je.push(u.src==="remote"?z:ge),Ae.push(u)}le+=L.text.slice(u.from,u.to)}u.ms=E,u.me=le.length,u.conflict&&(u.conflict.range||(u.conflict.range=[E,E]),u.conflict.range[1]=le.length)}let Ge=le.length,et=new Int32Array(ze+1).fill(-1),Qe=new Int32Array(d.text.length+1).fill(-1),Ut=new Int32Array(y.text.length+1).fill(-1);for(let u=0;u<Ge;u++)Ne[u]>=0&&(et[Ne[u]]=u),Le[u]>=0&&(Qe[Le[u]]=u),je[u]>=0&&(Ut[je[u]]=u);let Mt=(u,E)=>{let L=-1,D=-1;for(let z=u.from;z<u.to;z++){let oe=E[z];oe>=0&&(L<0&&(L=oe),D=oe+1)}return L<0?null:[L,D]},Kt=[],Lt=[];for(let u of new Set(pt.values()))u.new==="local"?Kt.push(u):u.new==="remote"&&Lt.push(u);let Wt=(u,E)=>{u.remote=E.remote,u.remoteMark=E.remoteMark,u.new="both",E.merged=u,pt.set(E.remote,u)};if(Kt.length&&Lt.length){let u=e.idOf;for(let E of Kt){let L=u?u.local(E.local):null;if(!L)continue;let D=Lt.find(z=>!z.merged&&z.tag===E.tag&&!!z.block==!!E.block&&u.remote(z.remote)===L);D&&Wt(E,D)}for(let E of Kt){if(E.remote)continue;let L=Mt(E.localMark,Qe);if(L)for(let D of Lt){if(D.merged||D.tag!==E.tag||!!D.block!=!!E.block)continue;let z=Mt(D.remoteMark,Ut);if(z&&Math.min(L[1],z[1])-Math.max(L[0],z[0])>0){Wt(E,D);break}}}}At.clear();let C=u=>{for(let E of u)if(E.block)return vt(pt.get(E.el));return null},Y=g.marks.some(u=>u.block)||d.marks.some(u=>u.block)||y.marks.some(u=>u.block),ce=new Array(Ge).fill(null),de=new Set;if(e.nativeTransfers)for(let u=0;u<Ge;u++){let E=Ae[u].owner;ce[u]=E?vt(pt.get(E)):Ne[u]>=0?C(g.stackAt[Ne[u]]):null}else if(Y){let u=(he,Ie,Ye)=>{let nt=new Set([he,Ie,Ye]);nt.delete(null);let at=[];for(let Rt of nt){let sn=Rt===he,Qt=Rt===Ie,fn=Rt===Ye;(Qt===fn?Qt:Qt===sn?fn:Qt)&&at.push(Rt)}if(at.length<=1)return at[0]||null;let jt=n==="local"?Ie:Ye;return at.includes(jt)?jt:at[0]},E=(he,Ie)=>Ie>=0?C(he.stackAt[Ie]):null,L=new Map;for(let he=0;he<Ge;he++){if(le[he]!==wt)continue;let Ie=Ne[he]>=0?E(g,Ne[he]):null,Ye=E(d,Le[he]),nt=E(y,je[he]);L.set(he,[Ie,Ne[he]>=0?u(Ie,Ye,nt):Ye||nt])}let D=new Set([...L.values()].map(he=>he[1])),z=he=>he!==wt&&he!==Rn&&!/\s/.test(he),oe=(he,Ie)=>{let Ye=he;for(;Ye<Ie&&!z(le[Ye]);)Ye++;return Ye<Ie&&Ne[Ye]>=0?E(g,Ne[Ye]):null},ge=new Map,ye=0;for(let he=0;he<Ge;he++){if(le[he]!==wt)continue;let[Ie,Ye]=L.get(he),nt=oe(ye,he),at=Ye,jt=ge.get(at)===at&&nt===at;at&&ge.has(at)&&!jt&&Ie&&!ge.has(Ie)&&!D.has(Ie)&&(at=Ie),at&&!ge.has(at)&&ge.set(at,nt);for(let Rt=ye;Rt<=he;Rt++)ce[Rt]=at;ye=he+1}let Re=he=>{for(let Ie=0;Ie<he.text.length;Ie++)if(z(he.text[Ie])&&!E(he,Ie))return!0;return!1};if(!Re(g)&&!Re(d)&&!Re(y)){let he=[],Ie=0;for(let nt=0;nt<Ge;nt++)(le[nt]===wt||nt===Ge-1)&&(he.push([Ie,nt]),Ie=nt+1);let Ye=new Set(ce);for(let nt=0;nt<he.length;nt++){let[at,jt]=he[nt];if(ce[jt])continue;let Rt=at;for(;Rt<=jt&&!z(le[Rt]);)Rt++;if(Rt>jt)continue;let sn=E(g,Ne[Rt]),Qt=E(d,Le[Rt]),fn=E(y,je[Rt]),pn=u(sn,Qt,fn)||Qt||fn||sn;if(pn&&!Ye.has(pn)){Ye.add(pn);for(let qt=at;qt<=jt;qt++)ce[qt]=pn;continue}let En=nt>0&&ce[he[nt-1][1]],In=nt+1<he.length&&ce[he[nt+1][1]];if(En)de.add(he[nt-1][1]);else if(In&&le[jt]===wt)de.add(jt);else continue;for(let qt=at;qt<=jt;qt++)ce[qt]=En||In}}}let ie=new Map,ee=u=>{let E=ie.get(u);if(E)return E;E=[1/0,-1/0];for(let[L,D]of[[u.baseMark,et],[u.localMark,Qe],[u.remoteMark,Ut]]){let z=L&&Mt(L,D);z&&(E[0]=Math.min(E[0],z[0]),E[1]=Math.max(E[1],z[1]))}return ie.set(u,E),E},se=(u,E,L)=>{let D=-1,z=-1;for(let oe=0;oe<u.length;oe++){let ge=pt.get(u[oe].el);ge===E&&(D=oe),ge===L&&(z=oe)}return D>=0&&z>=0?D-z:0},Ee=(u,E)=>[...u].sort((L,D)=>{for(let ge of E){let ye=se(ge,L,D);if(ye)return ye}let z=ee(L),oe=ee(D);return z[0]-oe[0]||oe[1]-z[1]||L.rank-D.rank||L.id-D.id}),We=new Map,Fe=new Map,tt=e.nativeTransfers?[]:null,st=u=>{if(tt)return tt;let E=Ne[u],L=Le[u],D=je[u],z=Ae[u];if(E>=0){let nt=g.stackAt[E],at=d.stackAt[L],jt=y.stackAt[D],Rt=We.get(nt);Rt||We.set(nt,Rt=new Map);let sn=Rt.get(at);sn||Rt.set(at,sn=new Map);let Qt=sn.get(jt);if(Qt)return Qt;let fn=Ot(nt),pn=Ot(at),En=Ot(jt),In=new Set;for(let qt of new Set([...fn,...pn,...En])){let ro=fn.has(qt),so=pn.has(qt),Ht=En.has(qt);(so===Ht?so:so===ro?Ht:so)&&In.add(qt)}return Qt=Ee(In,[at,jt,nt]),sn.set(jt,Qt),Qt}if(z.src==="both"){let nt=d.stackAt[L],at=y.stackAt[D];return Ee(new Set([...Ot(nt),...Ot(at)]),[nt,at])}let ge=(z.src==="local"?d:y).stackAt[z.src==="local"?L:D];if(!z.inherit)return Ee(Ot(ge),[ge]);let ye=Fe.get(z);ye||Fe.set(z,ye=new Map);let Re=ye.get(ge);if(Re)return Re;let he=new Set(Ot(ge));for(let nt of z.inherit.added)he.add(vt(nt));for(let nt of z.inherit.removed)he.delete(vt(nt));let Ie=z.src==="local"?y:d,Ye=(z.src==="local"?Te.bTo:pe.bTo)[z.inherit.bs];return Re=Ee(he,[ge,Ie.stackAt[Ye]]),ye.set(ge,Re),Re},it=new Int32Array(d.text.length+1);it[d.text.length]=Ge;for(let u=d.text.length-1;u>=0;u--)it[u]=Qe[u]>=0?Qe[u]:it[u+1];ha.caret+=d.text.length;let rt=u=>u<=0?0:(u>d.text.length&&(u=d.text.length),Qe[u-1]>=0?Qe[u-1]+1:it[u]),kt=[],xt=[],Et=null,$e=[],mt="",Tt=-1,Dt=u=>{Et?Et.appendChild(u):kt.push(u)},It=u=>{if(!mt)return;let E=t.createTextNode(mt);Dt(E),xt.push({node:E,ms:Tt,me:u,local:[],u:$e.length?$e[$e.length-1].u:null}),mt=""},xn=new Set,Zt=new Map,Fn=new Set,an=u=>{let E=t.createElement(u.tag);if(u.block&&Be.add(E),!Zt.has(u)){Zt.set(u,E),M(u.base,u.local,u.remote,E),i.set(E,{base:u.base,local:u.local,remote:u.remote});let D=(ge,ye)=>w&&u[ye]&&ge.reverse.get(u[ye])?ye:null,z=!u.base&&(D(o,"local")||D(r,"remote"));if(z){let ge=z==="local"?o.reverse.get(u.local):r.reverse.get(u.remote),ye=i.get(E);ye.local=ye.local||o.map.get(ge)||null,ye.remote=ye.remote||r.map.get(ge)||null,l.push({kind:"move",el:E,source:z}),e.moveBuilt?.(ge,z,u[z],E)}else u.base||l.push({kind:"insert",el:E,source:u.local&&u.remote?"both":u.local?"local":"remote"});let oe=i.get(E);oe.local&&(Fn.has(oe.local)?oe.local=null:Fn.add(oe.local))}else{let D=Zt.get(u);for(let z of D.attributes)z.name!=="id"&&z.name!=="data-id"&&O(E,z,z.value);i.set(E,{base:null,local:null,remote:null})}Dt(E),$e.push({u,el:E}),Et=E},to=new Set,kn=new Map;for(let u of d.pins){let E=rt(u.i);kn.has(E)||kn.set(E,[]),kn.get(E).push(u)}let go=u=>{let E=kn.get(u);if(E){It(u);for(let L of E){let D=L.el.namespaceURI&&L.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(L.el.namespaceURI,L.el.tagName):t.createElement(L.el.tagName);i.set(D,{base:null,local:L.el,remote:null,pinned:!0}),to.add(D),Dt(D)}}},Vo=g.atoms.length||d.atoms.length||y.atoms.length,Gt=u=>{if(!Vo)return null;let E=Ne[u]>=0?g.atomAt.get(Ne[u]):null,L=Le[u]>=0?d.atomAt.get(Le[u]):null,D=je[u]>=0?y.atomAt.get(je[u]):null;return E||L||D?{ab:E,al:L,ar:D}:null},Un=(u,E,L)=>{let D=e.idOf;if(!D||!D.base)return!1;let z=D.base(u.el);return z!=null&&z===D[L](E.el)},Wo=(u,E,L,D,z)=>{if(!u||!w)return null;let oe=N.get(E.reverse.get(u.el))||null;return!oe||oe===D||(D?oe.el.isEqualNode(D.el)&&!Un(oe,u,z):L.bTo[oe.i]>=0)?null:oe},bo=(u,E)=>{if(!u||!w||!e.moveIn)return null;let L=E.reverse.get(u.el);return L&&!N.has(L)?L:null},no=(u,E)=>{let L=new Map;for(let D of u.atoms)L.set(E(D),(L.get(E(D))||0)+1);return L},vn=no(g,H),br=no(d,k),yr=no(y,A),wr=u=>{let E=H(u);return vn.get(E)===1&&(br.get(E)||0)<=1&&(yr.get(E)||0)<=1},Hn=new Map,qn=new Set,oo=new Set,_o=new Set,yo=null;for(let u=0;u<Ge;u++){let E=Gt(u);if(!E)continue;let{ab:L,al:D,ar:z}=E,oe=Wo(z,r,Te,L,"remote"),ge=Wo(D,o,pe,L,"local"),ye=L,Re=null;if(oe?(ye=oe,Re="remote"):ge&&(ye=ge,Re="local"),ye){L&&ye!==L&&(yo||=new Map).set(L,Re),qn.has(ye)?Hn.set(u,{dup:ye.el}):(qn.add(ye),Hn.set(u,{bk:ye,from:Re,al:D,ar:z}));continue}let he=bo(z,r),Ie=bo(D,o),Ye=he||Ie;if(Ye){oo.has(Ye)?Hn.set(u,{dup:Ye}):(oo.add(Ye),Hn.set(u,{moveIn:Ye,side:he?"remote":"local",sideEl:he?z.el:D.el}));continue}let nt=(jt,Rt)=>jt&&w&&N.get(Rt.reverse.get(jt.el))||null,at=nt(z,r)||nt(D,o);if(at&&(_o.add(at),Ae[u].conflict&&(wr(at)||z&&(z.el===at.el||r.identityPaired?.has(at.el))&&Un(at,z,"remote")||D&&(D.el===at.el||o.identityPaired?.has(at.el))&&Un(at,D,"local")))){if(qn.has(at)){Hn.set(u,{dup:at.el});continue}qn.add(at)}Hn.set(u,{al:D,ar:z})}let On=new Map,$o,Fo,xr=(u,E)=>{if(u[E]>=0)return u[E];for(let L=E-1;L>=0;L--)if(u[L]>=0)return u[L]+1;return 0};if(w)for(let u of g.atoms){if(qn.has(u)||_o.has(u))continue;let E=o.map.get(u.el)||null,L=r.map.get(u.el)||null,D=E&&v.get(E),z=L&&G.get(L);if(E&&!D||L&&!z)continue;let oe=!(D&&z)&&ve.has(u);if(!oe&&!(D&&z&&(wr(u)||yo?.has(u)||(D.el===u.el||o.identityPaired?.has(u.el))&&(z.el===u.el||r.identityPaired?.has(u.el))&&Un(u,D,"local")&&Un(u,z,"remote"))))continue;let ge=yo?.get(u),ye=n;if(ge){let nt=ge==="local"?y:d,at=ge==="local"?r:o,jt=ge==="local"?Fo:$o;if(jt===void 0){jt=nt.atoms.length===g.atoms.length;for(let Rt=0;jt&&Rt<g.atoms.length;Rt++)jt=at.reverse.get(nt.atoms[Rt].el)===g.atoms[Rt].el;ge==="local"?Fo=jt:$o=jt}jt&&(ye=ge)}let Re=ye==="local"?[[D,Qe],[z,Ut]]:[[z,Ut],[D,Qe]],[he,Ie]=Re.find(([nt])=>nt),Ye=xr(Ie,he.i);On.has(Ye)||On.set(Ye,[]),On.get(Ye).push({a:u,lt:E,rt:L,edited:oe}),qn.add(u)}if(w&&e.moveIn){let u=[[d,o,Qe,"local"],[y,r,Ut,"remote"]];n!=="local"&&u.reverse();for(let[E,L,D,z]of u)for(let oe of E.atoms){let ge=bo(oe,L);if(!ge||oo.has(ge))continue;oo.add(ge);let ye=xr(D,oe.i);On.has(ye)||On.set(ye,[]),On.get(ye).push({move:ge,side:z,sideEl:oe.el})}}let ne=u=>{let E=On.get(u);if(E){if(It(u),E.some(L=>He(L.move?L.sideEl:L.a.el)))for(;$e.length;)$e.pop(),Et=$e.length?$e[$e.length-1].el:null;for(let{a:L,lt:D,rt:z,edited:oe,move:ge,side:ye,sideEl:Re}of E){if(ge){let Ie=e.moveIn(ge,ye,Re);Ie&&Dt(Ie);continue}xn.add(L);let he=j(L.el,D,z);oe&&(p({kind:"structure",el:he,detail:"edit-beats-delete",base:L.el},{subject:L.el,deleted:D?"remote":"local"}),l.push({kind:"insert",el:he,source:D?"local":"remote"})),Dt(he)}}},Be=new Set,Ue=c.length>a;for(let u=0;u<Ge;u++){let E=Gt(u),L=e.scopeUnits&&E&&(E.ab?.stack.some(ge=>ge.block)||E.al?.stack.some(ge=>ge.block)||E.ar?.stack.some(ge=>ge.block)),z=!!E&&He((E.ab||E.al||E.ar).el)&&!L?[]:ce[u]?[ce[u],...st(u)]:st(u),oe=0;for(;oe<$e.length&&oe<z.length&&$e[oe].u===z[oe];)oe++;if(oe<$e.length)for(It(u);$e.length>oe;)$e.pop(),Et=$e.length?$e[$e.length-1].el:null;if(go(u),ne(u),z.length>$e.length)for(It(u);$e.length<z.length;)an(z[$e.length]);if(le[u]===wt){if(de.has(u))continue;It(u);let ge=$e.length;for(;ge>0&&!$e[ge-1].u.block;)ge--;if(ge>0)for(Ue&&f.breakOut.set(u,$e[ge-1].el);$e.length>=ge;)$e.pop(),Et=$e.length?$e[$e.length-1].el:null;continue}if(E){It(u);let ge=Hn.get(u),ye;if(ge.dup){p({kind:"structure",el:null,detail:"both-moved",base:ge.dup},{subject:ge.dup});continue}if(ge.moveIn){if(ye=e.moveIn(ge.moveIn,ge.side,ge.sideEl),!ye)continue}else if(ge.bk){let Re=ge.bk;if(xn.add(Re),Re===E.ab)ye=j(Re.el,ge.al.el,ge.ar.el);else{let he=o.map.get(Re.el)||null,Ie=r.map.get(Re.el)||null;ye=j(Re.el,he,Ie),(!he||!Ie)&&p({kind:"structure",el:null,detail:"move-beats-delete",base:Re.el},{subject:Re.el,deleted:he?"remote":"local"}),l.push({kind:"move",el:ye,source:ge.from})}}else ge.al?(ye=U(ge.al.el,"local"),ge.ar&&(i.get(ye).remote=ge.ar.el),l.push({kind:"insert",el:ye,source:ge.ar?"both":"local"})):(ye=U(ge.ar.el,"remote"),l.push({kind:"insert",el:ye,source:"remote"}));Ue&&f.atomOut.set(u,ye),Dt(ye);continue}mt||(Tt=u),mt+=le[u]}if(It(Ge),(kn.has(Ge)||On.has(Ge))&&($e.length=0,Et=null,go(Ge),ne(Ge)),Ge===0&&(d.placeholder||y.placeholder||g.placeholder)){let u=t.createElement("br");i.set(u,{base:g.placeholder,local:d.placeholder,remote:y.placeholder}),kt.push(u)}let qe=0,ht=u=>{for(;qe>0&&xt[qe-1].me>=u;)qe--;for(;qe<xt.length&&xt[qe].me<u;)qe++;let E=xt[qe];if(!E)return xt[xt.length-1]||null;let L=xt[qe+1];return E.me===u&&L&&L.ms===u?L:E},_e=new Map,Ve={},lt=(u,E,L)=>{let D=ht(u)||(L?Ve:null);if(!D)return;let z=_e.get(D)||{l:!1,r:!1};E!=="remote"&&(z.l=!0),E!=="local"&&(z.r=!0),_e.set(D,z)},Ke=u=>{if(u.conflict)return!0;let E=u.src==="local"?d.text:u.src==="remote"?y.text:"";for(let L=u.from;L<u.to;L++)if(E[L]!==Rn&&E[L]!==wt)return!0;return!1};for(let u of B)u.src!=="base"&&lt(u.ms,u.conflict?"both":u.src,Ke(u));for(let[u,E]of q)et[u]>=0&&lt(et[u],E);for(let u of xt.length?xt:[Ve]){let E=_e.get(u);E&&l.push({kind:"text",node:u.node||null,source:E.l&&E.r?"both":E.l?"local":"remote"})}for(let u of Xe){if(Zt.has(u))continue;let E=!u.local&&!(w&&o.map.get(u.base)),L=!u.remote&&!(w&&r.map.get(u.base));!E&&!L||l.push({kind:"remove",source:E&&L?"both":E?"local":"remote",base:u.base})}if(xe)for(let[u,E]of xe)Zt.has(u)&&p({kind:"structure",el:Zt.get(u),detail:"edit-beats-delete",base:u.base},{subject:u.base,deleted:E});let ct=(u,E,L)=>{if(E<=u)return!1;for(let D=u;D<E;D++)if(L[D]>=0)return!1;return!0};for(let u of Xe)for(let E of["local","remote"]){let L=u[E+"Mark"],D=u.baseMark;if(!L)continue;let z=E==="local"?pe:Te;if(!ct(D.from,D.to,z.bTo)||!ct(L.from,L.to,z.toB))continue;let oe=(E==="local"?fe:Se).find(ge=>ge.ss<=L.from&&L.from<ge.se);oe&&(oe.be<=D.from||oe.bs>=D.to)&&l.push({kind:"move",el:Zt.get(u)||null,source:E})}let ft=u=>{let E=pt.get(u.node.parentNode);return E?vt(E):null};for(let u of d.nodes){let E=-1;for(let D=u.s;D<u.e;D++)if(Qe[D]>=0){E=Qe[D];break}let L;if(E>=0)L=ht(E);else{let D=rt(u.s),z=ft(u);L=xt.find(oe=>oe.u===z&&oe.me>=D)||xt.filter(oe=>oe.u===z).pop()}L&&L.local.push(u)}let yt=new Map,gt=xt[xt.length-1]||null,Ct=0;for(let u of d.nodes){let E=null;for(let L=u.s;L<=u.e;L++){let D=rt(L);for(;Ct>0&&xt[Ct-1].me>=D;)Ct--;for(;Ct<xt.length&&xt[Ct].me<D;)Ct++;let z=ge=>ge&&D>=ge.ms&&D<=ge.me&&(D<ge.me||L===u.e||ge===E),oe=z(xt[Ct])?xt[Ct]:z(xt[Ct+1])?xt[Ct+1]:xt[Ct]||gt;if(!oe)break;if(E===oe){let ge=yt.get(oe);ge[ge.length-1].to=L-u.s;continue}E=oe,yt.has(oe)||yt.set(oe,[]),yt.get(oe).push({node:u.node,from:L-u.s,to:L-u.s,flatStart:u.s})}}for(let u of xt){let E=u.local,L=!1;for(let ge of E)for(let ye=ge.s;ye<ge.e&&!L;ye++)(Qe[ye]<u.ms||Qe[ye]>=u.me)&&(L=!0);i.set(u.node,{base:null,local:E.map(ge=>ge.node),remote:null,caret:yt.get(u)||[],partial:L});let D=u.ms,z=u.me-u.ms,oe=ge=>{let ye=0,Re=-1;for(let he of E){let Ie=he.e-he.s;if(ge<=ye+Ie){Re=he.s+(ge-ye);break}ye+=Ie}return Re<0&&(Re=E.length?E[E.length-1].e:0),Math.max(0,Math.min(rt(Re)-D,z))};oe.flat=ge=>Math.max(0,Math.min(rt(ge)-D,z)),s.set(u.node,oe)}function Mn(){if(!d.text.includes(wt))return[{flatLocal:d.text,localNodes:d.nodes,textNodes:xt,lToM:Qe,mapLocal:rt}];let u=[],E=0,L=0;for(let D=0;D<=d.text.length;D++){if(D<d.text.length&&d.text[D]!==wt)continue;let z=E,oe=D;if(oe>z){let ge=[];for(;L<d.nodes.length&&d.nodes[L].e<=z;)L++;for(let ye=L;ye<d.nodes.length&&d.nodes[ye].s<oe;ye++){let Re=d.nodes[ye],he=Math.max(Re.s,z),Ie=Math.min(Re.e,oe);he<Ie&&ge.push({node:Re.node,s:he-z,e:Ie-z})}u.push({flatLocal:d.text.slice(z,oe),localNodes:ge,textNodes:xt,lToM:Qe.subarray?Qe.subarray(z,oe+1):Qe.slice(z,oe+1),mapLocal:ye=>rt(z+Math.max(0,Math.min(ye,oe-z)))})}E=D+1}return u}let Kn={...e,blocks:Be,ignored:u=>to.has(u)||(e.ignored?e.ignored(u):!1)},wo=e.ignoreAttribute||(()=>!1),Gr=Pi(zt(kt,Kn),wo)!==Pi(y,wo);if(h.length){let u=E=>{let L=i.get(E);return L&&L.unchanged?L.remote:null};f.text=le,f.textNodes=xt,f.out=zt(kt,{...Kn,via:u})}let ut=null;if(e.scopeUnits){ut=new Map;let u=new Set(kt),E=ye=>{for(;ye&&!u.has(ye);)ye=ye.parentNode;return ye},L=e.scopeUnits.map(ye=>{let Re=new Map;for(let he of ye)if(he.nodeType===1)Re.set(he,he);else for(let Ie of he.nodes)Re.set(Ie,he);return Re}),D=(ye,Re)=>{for(;ye&&!Re.has(ye);)ye=ye.parentNode;return ye?Re.get(ye):null},z=[g,d,y].map((ye,Re)=>{let he=new Array(ye.text.length);for(let Ie of ye.nodes){let Ye=D(Ie.node,L[Re]);Ye&&he.fill(Ye,Ie.s,Ie.e)}for(let Ie of ye.atoms)he[Ie.i]=D(Ie.el,L[Re]);return he}),oe=(ye,Re)=>{if(!ye||!Re)return;let he=ut.get(ye);he||ut.set(ye,he=new Set),he.add(Re)};for(let ye of kt){let Re=i.get(ye);Re&&(oe(D(Re.base,L[0]),ye),oe(D(Re.local,L[1]),ye),oe(D(Re.remote,L[2]),ye))}for(let ye of xt){let Re=E(ye.node);for(let he=ye.ms;he<ye.me;he++)oe(z[0][Ne[he]],Re),oe(z[1][Le[he]],Re),oe(z[2][je[he]],Re)}let ge=new Map(kt.map((ye,Re)=>[ye,Re]));for(let[ye,Re]of ut)ut.set(ye,Array.from(Re).sort((he,Ie)=>ge.get(he)-ge.get(Ie)))}return{unitOutputs:ut,nodes:kt,text:le,textNodes:xt,localDiverged:Gr,mapLocal:rt,conflicts:c.slice(a),granularity:F?"line":"word",segments:Mn(),localHunks:fe,remoteHunks:Se,lToM:Qe}}var Ss=Symbol("lost");function qi(){return{links:new Map,removed:new Set,consumed:new Set,link(e,t){this.links.set(e,t)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let t of e.nodes)this.removed.add(t)},consume(e){for(let t of e)this.consumed.add(t)}}}var Fi=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function Ki({locals:e,rec:t,root:n,provenance:o,segments:r,ignored:i}){let s=new Map,c=(x,S)=>{let O=s.get(x);O||s.set(x,O=new Set),O.add(S)},l=new Set,a=new Set;for(let x of r){let S=x.textNodes;for(let O of S)l.add(O.node);for(let O of x.localNodes){a.add(O.node);let R=0,M=null;for(let j=O.s;j<O.e;j++){let U=x.lToM[j];if(U<0)continue;for((!S[R]||U<S[R].ms)&&(R=0);R<S.length&&S[R].me<=U;)R++;let K=S[R]&&S[R].ms<=U?S[R].node:Ss;K!==M&&c(O.node,K),M=K}}}let p=new Set,f=new Map,h=new Set;(function x(S){p.add(S);let O=o.get(S);if(S.nodeType===1)O&&O.local&&O.local.nodeType===1&&(c(O.local,S),O.unchanged&&h.add(O.local)),S.tagName==="TEMPLATE"&&S.content&&f.set(S.content,S);else if(O&&Array.isArray(O.local)&&!l.has(S))for(let R of O.local)c(R,S);for(let R=Fi(S).firstChild;R;R=R.nextSibling)x(R)})(n);let w=new Set;for(let[x,S]of t.links)c(x,S),w.add(x);let b=x=>{let S=x.parentNode;return S&&S.nodeType===11?f.get(S)||null:S},T=(x,S)=>{for(let O=x;O;O=b(O))if(O===S)return!0;return!1},g=x=>t.removed.has(x)||t.consumed.has(x),d=x=>{for(let S=x.parentNode;S&&S.nodeType===1;S=S.parentNode){if(h.has(S))return"kept";if(g(S))return"decided";if(s.has(S))return null}return null},y=new Map;for(let x of e)y.set(x,N(x));return y;function N(x){let S=s.get(x);if(S&&(S.size!==1||S.has(Ss)))return{kind:"unknown",reason:"several-outputs"};let O=S?S.values().next().value:null;if(O&&(O.nodeType!==1||!p.has(O)))return{kind:"unknown",reason:"output-not-placed"};if(!O){let U=g(x)?"decided":d(x);if(U==="kept")return{kind:"untouched"};if(U!=="decided")return{kind:"unknown",reason:"unmapped"}}let R=[],M=j(x,!!O&&(h.has(x)||w.has(x)),!O||g(x));if(M)return{kind:"unknown",reason:M};return O?{kind:"single",output:O,owned:R,carried:w.has(x)}:{kind:"removed"};function j(U,K,_){for(let H=Fi(U).firstChild;H;H=H.nextSibling){if(H.nodeType===1?i(H):H.nodeType!==3&&H.nodeType!==8)continue;let k=s.get(H);if(k)for(let A of k){if(A===Ss||!p.has(A))return"output-not-placed";if(!O)return"survives-elsewhere";if(!T(A,O))return"escaped";R.push(A)}else if(!K&&!_&&!g(H)&&!a.has(H))return"unmapped";if(H.nodeType===1){let A=j(H,K||h.has(H)||w.has(H),_||g(H));if(A)return A}}return null}}}function zi(e,t){if(!t)return!1;let n=t.nodeType===1&&t.tagName==="TEMPLATE"?[t,...t.querySelectorAll("template")]:[...t.querySelectorAll("template")];for(let o of n)if(o.content.contains(e)||zi(e,o.content))return!0;return!1}function Gi(e,t){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let n=[],o=new Set;for(let r of Array.from(e.elements)){if(!r||r.nodeType!==1||r.ownerDocument!==t&&!zi(r,t.documentElement))throw new TypeError("lineage.elements must be elements of the live document");o.has(r)||(o.add(r),n.push(r))}return n}var Xi=new WeakMap;function Yi(e){let t=new Map;for(let n of e){let o=[],r=!1;(function i(s){s.nodeType===1&&s.namespaceURI==="http://www.w3.org/1999/xhtml"&&s.localName==="template"&&(r=!0);for(let c=s.firstChild;c;c=c.nextSibling)o.push(c),c.nodeType===1&&i(c)})(n),t.set(n,{nodes:o,opaque:r})}return t}function Ns(e,t,n){if(e.lineage===void 0)return n(e);if(!t||t.nodeType!==1)throw new TypeError("lineage requires an element root");let o=e.lineage,r=Gi(o,t.ownerDocument),i=!1,s={...e,lineage:{elements:r,onResult(c,l){if(!i)return i=!0,o.onResult(c,l)}}};try{return Xi.set(s.lineage,Yi(r)),n(s)}catch(c){if(!i){i=!0;try{o.onResult({version:1,root:t,status:"incomplete",entries:r.map(bn)},null)}catch{}}throw c}}function vs(e,{liveRoot:t,localRoot:n,toLive:o}){let r=Gi(e,t.ownerDocument),i=a=>a===t||t.contains(a),s=new Map,c=new Set(r.filter(i));if(c.size&&n===t)for(let a of c)s.set(a,a);else c.size&&function a(p){let f=o(p);c.delete(f)&&s.set(f,p);for(let h=p.firstElementChild;h&&c.size;h=h.nextElementSibling)a(h)}(n);return{spec:e,watched:r,root:t,locals:Array.from(new Set(s.values())),before:Xi.get(e)||Yi(r),delivered:!1,result:null,finish(a,p){return this.resolve=p,this.plans=a,this.result={version:1,root:this.root,status:"complete",entries:r.map(f=>wa(f,s.get(f),a,p,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(a,p){this.root=p;let f=this.resolve,h=b=>{let T=f(b);return T===a?p:T};return this.finish(this.plans,h)},deliver(a){this.delivered||(this.delivered=!0,e.onResult(this.result,a))}}}var bn=e=>({from:e,to:[],kind:"unknown",complete:!1});function wa(e,t,n,o,r){let i=r.root,s=h=>!!h&&(h===i||i.contains(h)),c=t&&n?n.get(t):null;if(!c||c.kind==="unknown")return bn(e);let l=r.before.get(e);if(!l||l.opaque)return bn(e);let a=l.nodes,p=h=>s(h)||!!(h&&h.ownerDocument===i.ownerDocument&&i.ownerDocument.documentElement?.contains(h));if(c.kind==="untouched"){if(!s(e))return bn(e);for(let h of a)if(p(h)&&!e.contains(h))return bn(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(c.kind==="removed")return p(e)||a.some(p)?bn(e):{from:e,to:[],kind:"removed",complete:!0};let f=o(c.output);if(!f||f.nodeType!==1||!s(f)||f!==e&&p(e))return bn(e);for(let h of a)if(p(h)&&!f.contains(h))return bn(e);for(let h of c.owned){let w=o(h),b=Array.isArray(w)?w:[w];for(let T of b)if(!T||!s(T)||!f.contains(T))return bn(e)}return c.carried&&!Ji(f,c.output,o)?bn(e):{from:e,to:[f],kind:f===e?"retained":"replaced",complete:!0}}function Ji(e,t,n){for(let o=t.firstChild;o;o=o.nextSibling){let r=n(o),i=Array.isArray(r)?r:[r];for(let s of i)if(!s||!e.contains(s))return!1;if(o.nodeType===1&&!Ji(e,o,n))return!1}return!0}function Yo(e,t,n){let o=vs(e,{liveRoot:t,localRoot:t,toLive:r=>r});return o.result={version:1,root:t,status:"complete",entries:o.watched.map(r=>bn(r))},n.lineage=o.result,o}function Zi(e,t,n,o,r){if(!r(e.length*8+1))return null;let i=0,s=t===0,c=!1;for(let l of en(e,o)){if(!r(1))return null;if(i+=l.len,i===t&&(s=!0),i===n&&(c=!0),i>=n)break}return s&&c}function xa(e,t,n,o,r,i,s){if(!s(t.length*2))return!1;let c=new Map,l=new Map,a=new Set;for(let p of t){let f=p.bs<p.be,h=f?n[p.ownerIndex].text.base:n[p.ownerIndex].text[e],w=f?p.bs:p.ss,b=f?p.be:p.se;if(!s((b-w)*4+1))return!1;for(;w<b&&/\s/.test(h[w]);)w++;for(;b>w&&/\s/.test(h[b-1]);)b--;if(w===b)continue;let T=h.slice(w,b),g=f?c:l;f&&p.text&&a.add(T),g.has(T)?g.set(T,null):g.set(T,{h:p,from:w,to:b})}for(let p of o){if(!s(1))return!1;if(p.side!==e)continue;let f=p.deletion,h=n[f.ownerIndex].text.base;if(!s((f.be-f.bs)*3)||a.has(h.slice(f.bs,f.be).trim()))return!1}for(let[p,f]of c){if(!s(p.length+1))return!1;let h=l.get(p);if(!f||!h)continue;let w=f.h,b=h.h;if(!w.text||w.transferOut||b.transferIn||w.owner===b.owner)continue;let T=n[w.ownerIndex],g=n[b.ownerIndex];if(!s(T.text.base.length))return!1;if(!/\S/.test(T.text.base.slice(0,w.bs)+T.text.base.slice(w.be)))continue;let d=Zi(T.text.base,f.from,f.to,i,s),y=Zi(g.text[e],h.from,h.to,i,s);if(d===null||y===null)return!1;if(!d||!y)continue;let N=`${T.index}:${f.from}:${f.to}`,x={key:N,side:e,source:w.owner,destination:b.owner,deletion:w,insertion:b,sourceOffset:f.from-w.bs,targetOffset:h.from-b.ss,length:f.to-f.from};w.transferOut=x,b.transferIn=x,r[e].set(N,x),o.push(x)}return!0}function Qi({base:e,local:t,remote:n,localTwin:o,remoteTwin:r,eligible:i,nodes:s,budget:c=_t(2e4*32)}){let l=M=>M>c.remaining?!1:(c.remaining-=M,c.nativeSteps=(c.nativeSteps||0)+M,!0);if(e.length<2||t.length!==e.length||n.length!==e.length||!l(e.length*12))return null;for(let[M,j]of[["base",e],["local",t],["remote",n]]){let U=s[M];if(U.length!==j.length||U.some((K,_)=>K!==j[_]))return null}let a=[],p=0;for(let M=0;M<e.length;M++){let j=e[M],U=t[M],K=n[M];if(o(j)!==U||r(j)!==K)return null;let _={};for(let[H,k]of[["base",j],["local",U],["remote",K]]){if(!i(k)||k.tagName!==j.tagName||k.namespaceURI!==j.namespaceURI||!l(k.childNodes.length+1))return null;let A="";for(let J of k.childNodes){if(J.nodeType!==3||!l(J.data.length*4+1))return null;A+=J.data}if(A.includes(wt)||(p+=A.length+1,p>2e4))return null;_[H]=A}a.push({base:j,local:U,remote:K,index:M,text:_})}let f=a.every(M=>dn(M.text.base,M.text.local,M.text.remote)),h={local:[],remote:[]};for(let M of a){M.hunks={local:[],remote:[]};for(let j of["local","remote"]){let U=M.text.base,K=M.text[j];if(U===K)continue;let _=U.length+K.length+4,H=_*8;if(!l(H))return null;let k=Math.floor(c.remaining/8),A=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(_*_+k)-_)/2)));if(A<1||!l(4*(A+1)*(_+A+1)))return null;let J=0;for(let W of io(U,K,A)){if(!l(W.text.length+1))return null;let F=W.bs+J,Oe={...W,ss:F,se:F+W.text.length,toks:en(W.text,f),owner:M.base,ownerIndex:M.index};M.hunks[j].push(Oe),h[j].push(Oe),J+=W.text.length-(W.be-W.bs)}}}let w=[],b={local:new Map,remote:new Map};for(let M of["local","remote"]){let j=new Map,U=new Map,K=!1,_=(H,k,A)=>{H.has(k)?H.set(k,null):H.set(k,A)};for(let H of h[M]){if(!l(1))return null;let k=a[H.ownerIndex].text.base;if(H.bs<H.be&&H.text===""){let A=k.slice(H.bs,H.be);if(!l(A.length*2))return null;/\S/.test(A)&&_(j,A,H)}else if(H.bs===H.be&&/\S/.test(H.text)){if(!l(H.text.length*2))return null;_(U,H.text,H)}else H.bs<H.be&&(K=!0)}for(let[H,k]of j){if(!l(H.length+1))return null;let A=U.get(H);if(!k||!A||k.owner===A.owner)continue;let J=a[k.ownerIndex];if(!l(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,k.bs)+J.text.base.slice(k.be)))continue;let W=`${J.index}:${k.bs}:${k.be}`,F={key:W,side:M,source:k.owner,destination:A.owner,deletion:k,insertion:A};k.transferOut=F,A.transferIn=F,b[M].set(W,F),w.push(F)}if(K&&U.size&&!xa(M,h[M],a,w,b,f,l))return null}if(!w.length)return null;let T=(M,j)=>M.bs<j.be&&j.bs<M.be,g=M=>M.bs===M.be,d=(M,j)=>M.bs<=j.be&&j.bs<=M.be&&g(M)!==g(j),y=(M,j)=>M.bs===j.bs&&M.be===j.be&&M.text===j.text,N=(M,j)=>!!(M.transferIn||M.transferOut&&(!M.text||j.bs===M.be&&/\s/.test(j.text[0])||j.bs===M.bs&&/\s/.test(j.text[j.text.length-1])));for(let M of w){let j=M.side==="local"?"remote":"local",U=a[M.deletion.ownerIndex];for(let K of U.hunks[j])if(!l(1)||T(M.deletion,K)&&K.transferOut?.key!==M.key)return null}for(let M of a)for(let j of M.hunks.local)for(let U of M.hunks.remote){if(!l(1))return null;if(y(j,U)){if(j.transferIn?.key!==U.transferIn?.key)return null;continue}if(T(j,U)||d(j,U)&&!N(j,U)&&!N(U,j))return null}if(!l(p*8))return null;let x=new Set([...e,...t,...n]),S={base:zt(e,{blocks:x}),local:zt(t,{blocks:x}),remote:zt(n,{blocks:x})},O={};for(let M of["base","local","remote"]){let j=S[M];if(j.atoms.length||j.pins.length)return null;O[M]=new Map(j.marks.filter(U=>U.block).map(U=>[U.el,U.from]))}for(let M of a){let j=O.base.get(M.base);if(j===void 0)return null;for(let U of["local","remote"]){let K=O[U].get(M[U]);if(K===void 0)return null;for(let _ of M.hunks[U])_.bs+=j,_.be+=j,_.ss+=K,_.se+=K}}for(let M of w)M.bs=M.deletion.bs+(M.sourceOffset||0),M.be=M.length===void 0?M.deletion.be:M.bs+M.length,M.ss=M.insertion.ss+(M.targetOffset||0),M.se=M.length===void 0?M.insertion.se:M.ss+M.length;let R={};for(let M of["local","remote"]){let j=0,U=0,K=[];for(let H of h[M]){if(!l(1))return null;H.bs>j&&K.push({from:j,to:H.bs,target:U}),j=H.be,U=H.se}j<S.base.text.length&&K.push({from:j,to:S.base.text.length,target:U});let _=w.filter(H=>H.side===M).map(H=>({from:H.bs,to:H.be,target:H.ss,destination:H.destination}));if(R[M]=Cn({base:S.base,side:S[M],retained:K,transfers:_,budget:c}),R[M].status!=="ready")return null}return l(S.base.text.length)?{owners:a,blocks:x,transfers:w,byOrigin:b,budget:c,prepared:{base:S.base,local:S.local,remote:S.remote,lines:!1,baseTokens:en(S.base.text,f),localEdits:{hunks:h.local,respell:new Map},remoteEdits:{hunks:h.remote,respell:new Map},localMap:R.local,remoteMap:R.remote,full:null}}:null}var Os=/\S/;function el({certificates:e,scopes:t,views:n,eligible:o,baseId:r,limit:i=2e4*32}){let s=_t(i),c=Symbol(),l=[],a=f=>{if(f>s.remaining)throw c;s.remaining-=f},p=(f,h=null)=>{if(a(1),!f||f.nodeType!==1||f.parentNode?.nodeType!==1||!o(f))return null;for(let T=f.parentNode;T;T=T.parentNode)if(a(1),T.nodeType===11)return null;let w="",b=0;for(let T of f.childNodes){if(a(1),T.nodeType!==3)return null;if(a(T.data.length*4+1),h){let g=h.flat.nodes[b++];if(!g||g.node!==T||g.s!==w.length||g.e!==w.length+T.data.length)return null}w+=T.data}return a(w.length*3+1),h&&(h.flat.atoms.length||h.flat.pins?.length||b!==h.flat.nodes.length||h.flat.text!==w)?null:Os.test(w)?w:null};try{a(t[0].length+t[1].length+t[2].length+e.length);let f=t.map(w=>new Set(w)),h=new Map;for(let w of e){a(1);let b=h.get(w.source);b||h.set(w.source,b=[]),b.push(w)}for(let w of h.values()){let b=[null,null],T=[];for(let g of w){a(1);let{source:d,target:y,side:N,models:x,runs:S}=g;if(N!==0&&N!==1||!f[0].has(d)||!f[N+1].has(y))continue;let{V:O,A:R,idOf:M}=n[N],j=n[1-N],U=O.twin(d),K=j.V.twin(d),_=O.baseOf(y);if(!U||!K||!_||_===d||!f[0].has(_)||!f[N+1].has(U)||!f[2-N].has(K)||R.map.get(d)!==U||R.reverse.get(U)!==d||j.A.map.get(d)!==K||j.A.reverse.get(K)!==d||R.map.get(_)!==y||R.reverse.get(y)!==_||y.parentNode!==U.parentNode||_.parentNode!==d.parentNode||d.tagName!==U.tagName||d.tagName!==K.tagName||r(d)!==M(U)||r(d)!==j.idOf(K)||r(_)!==M(y))continue;let H=x.get(d),k=x.get(y);if(!H||!k)continue;let A=p(d,H),J=p(y,k),W=p(U),F=p(K);if(a((A?.length||0)+(F?.length||0)),A===null||J===null||W===null||F===null||F===A)continue;let Oe=S.length>0,Ce=!1;for(let pe of S){if(a(1),pe.source!==d||pe.target!==y||!Number.isInteger(pe.from)||!Number.isInteger(pe.to)||!Number.isInteger(pe.targetFrom)||pe.from<0||pe.to<=pe.from||pe.to>A.length||pe.targetFrom<0||pe.targetFrom+pe.to-pe.from>J.length){Oe=!1;break}a((pe.to-pe.from)*3);for(let Te=pe.from;Te<pe.to;Te++){if(A[Te]!==J[pe.targetFrom+Te-pe.from]){Oe=!1;break}Os.test(A[Te])&&(Ce=!0)}if(!Oe)break}if(!Oe||!Ce)continue;let De=b[N];De||(a(A.length),De=b[N]={source:d,side:N,flat:H.flat,before:A,covered:new Uint8Array(A.length)});for(let pe of S)a(pe.to-pe.from),De.covered.fill(1,pe.from,pe.to)}for(let g of b){if(!g)continue;let{source:d,side:y,flat:N,before:x,covered:S}=g;a(x.length*3+1);let O=-1,R=-1;for(let M=0;M<=x.length;M++)M<x.length&&S[M]?(O<0&&(O=M),R=M+1):(M===x.length||Os.test(x[M]))&&O>=0&&(T.push({source:d,side:y,flat:N,from:O,to:R}),O=R=-1)}a(T.length),l.push(...T)}}catch(f){if(f!==c)throw f}return{records:l,budget:s}}var ka="http://www.w3.org/1999/xhtml";function Aa(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 rn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===ka}function Ta(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Pr(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+"|"+Aa(e.textContent.trim())}var Sa={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function Mo(e,t=[],n=!1){if(!rn(e)||e.hasAttribute("src"))return null;let o=[Sa,...t];for(let r=0;r<o.length;r++){let i=o[r];if(!i.match(e))continue;if(!Ta(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let s=i.identity(e);return s==null||s===""?null:{key:r+":"+s,raw:s,recognizer:i}}return null}function tl(e,t,n){let o=new Set,r=i=>{rn(i)&&!t(i)&&o.add(Pr(i,n))};r(e);for(let i of e.querySelectorAll("script"))r(i);return o}function Jo(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 nl(e,t,n){let o=[],r=[],i=new Map,s=n.trackRecovery?new Set:null,c=Array.from(e.querySelectorAll("script"));rn(e)&&c.unshift(e);for(let l of c){if(!rn(l)||n.ignored(l)||n.skip.has(l)||t.has(Pr(l,n.baseURI)))continue;let a=l.ownerDocument.createElement("script");for(let p of l.attributes)a.setAttribute(p.name,p.value);if(a.textContent=l.textContent,n.beforeNodeAdded(a)===!1){s?.add(l);continue}a.hasAttribute("src")&&r.push(new Promise(p=>{a.addEventListener("load",()=>p()),a.addEventListener("error",()=>p())})),l.replaceWith(a),i.set(l,a),n.afterNodeAdded(a),o.push(a)}return{executed:o,loads:r,swapped:i,vetoed:s}}function Na(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 va(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function ol(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Pr(e,t);if(n==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+va(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|"+Na(e.textContent):e.outerHTML}function Ms(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
5
- `;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);if(n===-1)return e.length;t=n+2;continue}return t}}function Oa(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var Ma=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Ea=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Es(e){try{return JSON.parse(e)}catch{return JSON.parse(Ia(e))}}function Ia(e){let t="",n=0,o=(r,i)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${i}`)};for(;n<e.length&&(n=Ms(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let c=Ms(e,n+1);if(e[c]==="}"||e[c]==="]"){n++;continue}t+=r,n++;continue}if(r==='"'||r==="'"){let c=n+1;for(;c<e.length&&e[c]!==r;)e[c]==="\\"&&c++,c++;c>=e.length&&o("unterminated string",n);let l=e.slice(n+1,c);r==="'"&&(l=Oa(l)),t+='"'+l+'"',n=c+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 s=e.slice(n,i);if(s==="true"||s==="false"||s==="null"||Ma.test(s)){t+=s,n=i;continue}if(Ea.test(s)){if(e[Ms(e,i)]===":"){t+='"'+s+'"',n=i;continue}o("unquoted value "+JSON.stringify(s),n)}o("invalid token "+JSON.stringify(s),n)}return t}var Vt=Symbol("hyper-morph-json-merge:missing"),Ca=["id","_id","uuid","key","slug","code","name"];function Eo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Zo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ra(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}var La=/^[A-Za-z_$][\w$]*$/;function Pa(e,t){return La.test(t)?e===""?t:e+"."+t:e+"["+JSON.stringify(t)+"]"}function ja(e,t){return e===""?t:e+"."+t}function jr(e,t,n,o,r,i){if(e.onConflict){let s=c=>c===Vt?void 0:c;e.onConflict({path:t,base:s(n),local:s(o),remote:s(r),resolved:s(i)})}return i}function _n(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(!_n(e[n],t[n]))return!1;return!0}if(Eo(e)&&Eo(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Zo(t,o)||!_n(e[o],t[o]))return!1;return!0}return!1}function Is(e,t,n,o,r,i){return _n(t,n)?t:_n(t,e)?n:_n(n,e)?t:Eo(t)&&Eo(n)?Da(Eo(e)?e:{},t,n,o,r,i):Array.isArray(t)&&Array.isArray(n)?Va(e,t,n,o,r,i):jr(o,r,e,t,n,n)}function rl(e,t,n,o,r,i){return t===Vt&&n===Vt?Vt:t===Vt?e===Vt?n:_n(n,e)?Vt:jr(o,r,e,t,n,n):n===Vt?e===Vt?t:_n(t,e)?Vt:jr(o,r,e,t,n,Vt):Is(e,t,n,o,r,i)}function Da(e,t,n,o,r,i){let s={},c=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let l of c){let a=rl(Zo(e,l)?e[l]:Vt,Zo(t,l)?t[l]:Vt,Zo(n,l)?n[l]:Vt,o,Pa(r,l),ja(i,l));a!==Vt&&Ra(s,l,a)}return s}function Ba(e){return e===null||typeof e!="object"}function Dr(e){return typeof e+":"+String(e)}function Ua(e,t){for(let n of t){let o=new Set;for(let r of n){if(!Zo(r,e))return!1;let i=r[e];if(typeof i!="string"&&typeof i!="number")return!1;let s=Dr(i);if(o.has(s))return!1;o.add(s)}}return!0}function Ha(e,t,n,o,r){let i=[e,t,n],s=!0;for(let c of i)for(let l of c)Eo(l)||(s=!1);if(s){let c=o.keyPaths.get(r),l=c!==void 0?[c]:o.keyCandidates;for(let a of l)if(Ua(a,i))return{kind:"keyed",field:a};return null}for(let c of i){let l=new Set;for(let a of c){if(!Ba(a))return null;let p=Dr(a);if(l.has(p))return null;l.add(p)}}return{kind:"self"}}function Va(e,t,n,o,r,i){let s=Array.isArray(e)?e:[],c=Ha(s,t,n,o,i),l=Array.isArray(e)&&e.length===t.length&&e.length===n.length;if(!c||c.kind==="self"&&l)return l?t.map((N,x)=>Is(e[x],N,n[x],o,r+"["+x+"]",i)):jr(o,r,e,t,n,n);let a=c.kind==="self"?Dr:N=>Dr(N[c.field]),p=N=>c.kind==="self"?r+"["+JSON.stringify(N)+"]":r+"["+c.field+"="+JSON.stringify(N[c.field])+"]",f=new Map,h=N=>{let x=new Map;for(let S of N){let O=a(S);x.set(O,S),f.has(O)||f.set(O,p(S))}return x},w=h(s),b=h(t),T=h(n),g=new Map,d=new Set([...w.keys(),...b.keys(),...T.keys()]);for(let N of d){let x=rl(w.has(N)?w.get(N):Vt,b.has(N)?b.get(N):Vt,T.has(N)?T.get(N):Vt,o,f.get(N),i);x!==Vt&&g.set(N,x)}let y=[];for(let N of n){let x=a(N);g.has(x)&&y.push(x)}for(let N=0;N<t.length;N++){let x=a(t[N]);if(!g.has(x)||y.includes(x))continue;let S=0;for(let O=N-1;O>=0;O--){let R=y.indexOf(a(t[O]));if(R!==-1){S=R+1;break}}y.splice(S,0,x)}return y.map(N=>g.get(N))}function Wa(e){let t=new Map,n=[];for(let o of e.keyCandidates||[]){let r=o.lastIndexOf(":");r>=0?t.set(o.slice(0,r),o.slice(r+1)):n.push(o)}return{keyCandidates:[...n,...Ca],keyPaths:t,onConflict:e.onConflict||null}}function sl(e,t,n,o={}){return Is(e===void 0?Vt:e,t,n,Wa(o),"","")}function _a(e,t){let n=/^\s*/.exec(t)[0],o=/\s*$/.exec(t.slice(n.length))[0],r=t.slice(n.length,t.length-o.length),i=n.slice(n.lastIndexOf(`
6
- `)+1),s=/\n([ \t]+)\S/.exec(r),c;if(!s)c=JSON.stringify(e);else{let l=s[1],a=l.length>i.length&&l.startsWith(i)?l.slice(i.length):" ";c=JSON.stringify(e,null,a).replace(/\n/g,`
7
- `+i)}return n+c.replace(/</g,"\\u003c")+o}function Cs(e,t,n,o={}){let r=o.parse||Es,i=[],s=[],c=(h,w)=>{if(typeof h!="string")return Vt;try{return r(h)}catch(b){return i.push(`${w} side is not valid JSON (${b.message})`),Vt}},l=c(t,"local"),a=c(n,"remote");if(l===Vt)return{text:n,warnings:i,conflicts:s};if(a===Vt)return{text:t,warnings:i,conflicts:s};let p=c(e,"base"),f=sl(p===Vt?void 0:p,l,a,{...o,onConflict:h=>{s.push(h),o.onConflict?.(h)}});return _n(f,a)?{text:n,warnings:i,conflicts:s}:_n(f,l)?{text:t,warnings:i,conflicts:s}:{text:_a(f,n),warnings:i,conflicts:s}}var il=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function co(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>il(t)||r>il(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 Yn(e,t,n={}){if(!co(e))return null;let{startContainer:o,startOffset:r,endContainer:i,endOffset:s}=e;if(o===i&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,s);if(o===i&&r===s)return"";let c=new Set;for(let g=o;g;g=g.parentNode)c.add(g);let l=i;for(;!c.has(l);)l=l.parentNode;let a=(g,d)=>{let y=l.ownerDocument.createRange(),N=l.ownerDocument.createRange();return y.setStart(g[0],g[1]),y.collapse(!0),N.setStart(d[0],d[1]),N.collapse(!0),y.compareBoundaryPoints(0,N)},p=(g,d=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(d)],f=[],h;if(t==="plain"){h="";let g=d=>{if(d.nodeType===3||d.nodeType===8){let y=h.length;h+=d.nodeValue,f.push({s:y,e:h.length,a:[d,0],b:[d,d.nodeValue.length],node:d})}else for(let y of d.childNodes)g(y)};g(l)}else{let g=n.blocks;if(!g){g=new Set;let y=N=>{N!==l&&N.nodeType===1&&As.has(N.tagName)&&g.add(N);for(let x of N.childNodes)y(x)};y(l)}let d=zt(Array.from(l.childNodes),{blocks:g,atomize:y=>!!n.atoms?.has(y),ignored:n.ignored});h=d.text;for(let y of d.nodes)f.push({s:y.s,e:y.e,a:[y.node,0],b:[y.node,y.e-y.s],node:y.node});for(let y of d.atoms)f.push({s:y.i,e:y.i+1,a:p(y.el),b:p(y.el,!0)});for(let y=0;y<d.text.length;y++){if(d.text[y]!==wt)continue;let N=d.marks.find(S=>S.block&&S.to===y+1),x=d.marks.find(S=>S.block&&S.from===y+1);if(N)f.push({s:y,e:y+1,a:[N.el,N.el.childNodes.length],b:p(N.el,!0)});else if(x)f.push({s:y,e:y+1,a:p(x.el),b:[x.el,0]});else return null}}f.sort((g,d)=>g.s-d.s);let w=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let y=f.find(N=>N.node===g[0]);return y?y.s+g[1]:null}let d=0;for(let y of f){if(a(g,y.a)<=0)return y.s;if(a(g,y.b)<0)return null;d=y.e}return d},b=w([o,r]),T=w([i,s]);return b!==null&&T!==null&&b<=T?h.slice(b,T):null}function lo(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 ll(e,t){if(!e||!t)return null;let n=lo(e,t.start),o=lo(e,t.end);return n&&o?{startContainer:n[0],startOffset:n[1],endContainer:o[0],endOffset:o[1]}:null}var cl=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function al(e,t,n){if(!t)return;let o=new Map,r=new Map,i=c=>{if(!c)return null;if(r.has(c))return r.get(c);let a=c.local.map(p=>lo(t.localRoot,{path:p,offset:0})?.[0]).map(p=>p&&n(p)).filter(Boolean).map(p=>({node:p,parent:p.parentNode,previous:p.previousSibling,next:p.nextSibling,fragment:cl(p)}));return r.set(c,a),a},s=c=>{let l=ll(t.localRoot,c);if(!l)return null;let a=n(l.startContainer),p=n(l.endContainer);if(!a||!p)return null;let f={...l,startContainer:a,endContainer:p};return co(f)?f:null};for(let c of e){let l=c.recovery;if(!l||o.has(l))continue;let a={subject:i(l.subject),span:null,scope:null,touched:new Set};if(l.text){a.span=s(l.text.local.span),a.scope=s(l.text.local.scope);let p=a.span;if(p){let f=p.startContainer.ownerDocument.createRange();f.setStart(p.startContainer,p.startOffset),f.setEnd(p.endContainer,p.endOffset);let h=w=>{if(f.intersectsNode(w)){a.touched.add(w);for(let b of w.childNodes)h(b)}};h(f.commonAncestorContainer)}}if(l.structure){for(let p of[l.structure.localPlacement])p&&(i(p.parent),p.before.forEach(i),p.after.forEach(i));for(let p of l.structure.localOrder||[])i(p)}o.set(l,a)}t.localState={states:o,refs:r}}function fl(e,t,n,o){let r=n.localState?.states.get(e);if(!r)return!1;let i=c=>{let l=c.node;if(!o(l)||l.parentNode!==c.parent)return!1;let a=p=>Array.prototype.indexOf.call(l.parentNode.childNodes,p);return!(c.previous&&o(c.previous)&&c.previous.parentNode===l.parentNode&&a(c.previous)>=a(l)||c.next&&o(c.next)&&c.next.parentNode===l.parentNode&&a(c.next)<=a(l))};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 c=e.text.local,l=a=>a&&o(a.startContainer)&&o(a.endContainer);return l(r.span)&&l(r.scope)&&Yn(r.scope,e.text.encoding)===c.text&&Yn(r.span,e.text.encoding)===c.text.slice(c.start,c.end)}if(e.attribute){let c=e.attribute,l=r.subject[0].node;return(c.namespaceURI?l.getAttributeNS(c.namespaceURI,c.localName):l.getAttribute(c.qualifiedName))===t.local}let s=e.structure;if(s.localOrder){let c=-1,l=null;for(let a of s.localOrder){let p=n.localState.refs.get(a)?.[0]?.node;if(!p||!o(p)||l&&p.parentNode!==l)return!1;let f=Array.prototype.indexOf.call(p.parentNode.childNodes,p);if(f<=c)return!1;l=p.parentNode,c=f}return!0}return s.localAction==="moved"||r.subject.every(c=>cl(c.node)===c.fragment)}var $a=1,on=e=>!!e&&e.nodeType===1,Br=e=>on(e)&&e.tagName==="TEMPLATE"&&!!e.content;function ao(e,t=null,n=null){let o=new Map,r=new Map,i=p=>{if(!t){t=new WeakMap;let f=[e];for(;f.length;){let h=f.pop();Br(h)&&(t.set(h.content,h),f.push(h.content));for(let w=h.firstChild;w;w=w.nextSibling)w.nodeType===1&&f.push(w)}}return t.get(p)||null},s=(p,f)=>{let h=r.get(p);if(!h){h=new Map;let w=0;for(let b=p.firstChild;b;b=b.nextSibling)h.set(b,w++);r.set(p,h)}return h.get(f)},c=p=>{if(!p)return null;if(n&&n.has(p))return c(n.get(p));if(p===e)return[];let f=o.get(p);if(f!==void 0)return f;let h=p.parentNode,w=null;if(h&&h.nodeType===11){let b=i(h),T=b?c(b):null;T&&(w=T.concat(["content",s(h,p)]))}else if(h){let b=c(h);b&&(w=b.concat([s(h,p)]))}return o.set(p,w),w};return{root:e,pathOf:c,logicalParent:p=>{let f=p.parentNode;return f&&f.nodeType===11?i(f):f},indexIn:s,containerPath:p=>{if(p.nodeType===11){let h=i(p),w=c(h);return w?w.concat(["content"]):null}let f=c(p);return f&&Br(p)?f.concat(["content"]):f},ownerOf:i}}var Tn=e=>Br(e)?e.content:e;function ul(e){let{L:t,R:n,unitsOf:o,provenance:r,policy:i}=e,s=[];return{note:(p,f)=>{s.push([p,f])},finish:p=>s.length?a(p):null};function a(p){let f={base:ao(e.roots.base),local:ao(e.roots.local),remote:ao(e.roots.remote)},h=X=>X==="local"?t:n,w=(X,m)=>{if(!m)return null;if(X.map.has(m))return X.map.get(m);let I=[],P=on(m)?f.base.logicalParent(m):m.parent;for(;P&&!X.map.has(P);P=f.base.logicalParent(P))I.push(P);if(!P||!X.identical.has(P))return null;let $=X.map.get(P);for(let Q=I.length-1;Q>=0&&$;Q--)$=Tn($).childNodes[f.base.indexIn(I[Q].parentNode,I[Q])];return $?on(m)?Tn($).childNodes[f.base.indexIn(m.parentNode,m)]||null:o($)[o(m.parent).indexOf(m)]||null:null},b=new Map,T=new Map,g=new WeakMap,d=0,y=(X,m)=>{let I=b.get(X);I||b.set(X,I=[]),I.push(m)};(function X(m){T.set(m,d++);let I=r.get(m);if(I&&!I.pinned){for(let P of[I.base,I.local,I.remote])if(P)if(Array.isArray(P))for(let $ of P)y($,m);else y(P,m)}if(Br(m)){g.set(m.content,m);for(let P=m.content.firstChild;P;P=P.nextSibling)X(P)}for(let P=m.firstChild;P;P=P.nextSibling)X(P)})(p);let N=new Map;f.out=ao(p,g,N);let x={refs:new Map,spans:new Map,anchors:new Map,via:N,outOwners:g,outRoot:p,localRoot:e.roots.local},S=X=>on(X)?[X]:X.nodes,O=(X,m)=>{let I=f[m].logicalParent(X);if(!I)return null;for(let P of o(I))if(!on(P)&&P.nodes.includes(X))return P;return null},R=(X,m)=>X==null?null:Array.isArray(X)?X.length?O(X[0],m):null:X,M=X=>{let m=new Set,I=[];for(let P of X)for(let $ of b.get(P)||[])m.has($)||(m.add($),I.push($));return I.sort((P,$)=>T.get(P)-T.get($))},j=new Map,U=X=>{let m=X.b||X.l||X.r,I=j.get(m);if(I)return I;let P=[];for(let $ of[X.b,X.l,X.r])$&&P.push(...S($));return I=M(P),j.set(m,I),I},K=X=>({b:X,l:w(t,X),r:w(n,X)}),_=(X,m)=>{let I=h(m).reverse.get(X);if(I)return K(I);for(let P of M(S(X))){let $=r.get(P);if($&&!$.base&&$.local&&$.remote)return{b:null,l:R($.local,"local"),r:R($.remote,"remote")}}return m==="local"?{b:null,l:X,r:null}:{b:null,l:null,r:X}},H=new Map,k=X=>{let m=r.get(X);if(!m||m.pinned)return null;let I=R(m.base,"base");if(I)return K(I);let P=R(m.local,"local"),$=R(m.remote,"remote");if(P){let Q=t.reverse.get(P);if(Q)return K(Q)}if($){let Q=n.reverse.get($);if(Q)return K(Q)}return P||$?{b:null,l:P,r:$}:null},A=X=>(H.has(X)||H.set(X,k(X)),H.get(X)),J=(X,m)=>on(X)?f[m].logicalParent(X):X.parent,W=new Map,F=new Map,Oe=(X,m)=>(on(X)?[f[m].pathOf(X)]:X.nodes.map(I=>f[m].pathOf(I))).filter(Boolean),Ce=X=>{let m=X.b||X.l||X.r,I=X.b?"base":X.l?"local":"remote",P=F.get(m);if(P)return P;let $=!on(m),Q=Oe(m,I)[0],B=`${I[0]}:${JSON.stringify(Q===void 0?null:Q)}${$?":run":""}`,me=W.get(B);if(me)return F.set(m,me),me;let xe=U(X);return me={key:B,nodeType:on(m)?1:m.kind==="comment"?8:3,base:X.b?Oe(X.b,"base"):[],local:X.l?Oe(X.l,"local"):[],remote:X.r?Oe(X.r,"remote"):[],merged:xe.map(fe=>f.out.pathOf(fe)).filter(Boolean),live:[]},W.set(B,me),F.set(m,me),x.refs.set(me,xe),me},De={base:new Map,local:new Map,remote:new Map},pe=new Map,Te=(X,m)=>{let I=J(X,m);if(!I||I.nodeType!==1)return null;let P=De[m].get(I);if(!P){let Q=o(I),B=me=>Ce(m==="base"?K(me):_(me,m));P={parent:B(I),refs:Q.map(B),index:new Map(Q.map((me,xe)=>[me,xe]))},De[m].set(I,P)}let $=P.index.get(X)??-1;return{parent:P.parent,before:P.refs.slice($+1),after:P.refs.slice(0,Math.max(0,$)).reverse()}},ze=X=>{let m=X.parentNode;if(!m)return null;let I=pe.get(m);if(!I){let $=m.nodeType===11?g.get(m):m,Q=$&&$.nodeType===1?A($):null;if(!Q)return null;let B=[],me=[],xe=new Map;for(let Se of m.childNodes){let V=A(Se),Z=V&&Ce(V),be=B.length,ke=B.length-1;Z&&Z!==B[ke]&&(B.push(Z),ke++);let we={ref:Z,group:ke,after:be};me.push(we),xe.set(Se,we)}let fe=B.length;for(let Se=me.length-1;Se>=0;Se--){let V=me[Se];V.before=fe,V.ref&&(fe=V.group)}I={parent:Ce(Q),refs:B,index:xe},pe.set(m,I)}let P=I.index.get(X);return{parent:I.parent,before:I.refs.slice(P.before),after:I.refs.slice(0,P.after).reverse()}},Me=X=>on(X)?X.outerHTML:X.value,v=X=>on(X)?"element":X.kind==="comment"?"comment":"text",G=(X,m)=>({path:X,offset:m}),ue=(X,m,I)=>{if(!X)return null;let P=f[I],$=0;if(m){let Q=on(m)?m:m.nodes[m.nodes.length-1];Q.parentNode&&($=P.indexIn(Q.parentNode,Q)+1)}return G(P.containerPath(X),$)},ae=(X,m)=>{let I=J(X,"base"),P=I?w(h(m),I):null;if(!on(P))return null;let $=o(I),Q=null;for(let B=$.indexOf(X)-1;B>=0&&!Q;B--){let me=w(h(m),$[B]);me&&J(me,m)===P&&(Q=me)}return ue(P,Q,m)},Pe=(X,m,I,P)=>{let $=f[P],Q=0;for(let B=0;B<X.nodes.length;B++){let me=X.nodes[B],xe=me.nodeValue.length,fe=B===X.nodes.length-1;if((I==="start"?m<Q+xe:m<=Q+xe)||fe)return G($.pathOf(me),Math.max(0,Math.min(m-Q,xe)));Q+=xe}return null},He=(X,m)=>{let I=f[m],P=X.firstChild,$=X.lastChild;return P&&P.nodeType===3&&$.nodeType===3?{start:G(I.pathOf(P),0),end:G(I.pathOf($),$.nodeValue.length)}:{start:G(I.pathOf(X),0),end:G(I.pathOf(X),X.childNodes.length)}},ve=(X,m,I)=>{for(let B of X.nodes)if(I==="start"?B.s<=m&&m<B.e:B.s<m&&m<=B.e)return{kind:"text",node:B.node,offset:m-B.s};let P=I==="start"?m:m-1,$=()=>{for(let B of X.nodes)if(B.s===m||B.e===m)return{kind:"text",node:B.node,offset:m-B.s};return null},Q=X.atomAt.get(P);if(Q)return{kind:I==="start"?"before":"after",node:Q.el};if(X.text[P]===wt){let B=X.marks.find(xe=>xe.block&&xe.to===P+1);if(B)return I==="start"?{kind:"end",node:B.el}:{kind:"after",node:B.el};let me=X.marks.find(xe=>xe.block&&xe.from===P+1);if(me)return I==="start"?{kind:"before",node:me.el}:{kind:"startOf",node:me.el}}return $()},Ze=(X,m)=>ve(X,m,"end")||ve(X,m,"start"),Je=(X,m)=>{switch(m.kind){case"text":return G(X.pathOf(m.node),m.offset);case"end":return G(X.containerPath(m.node),Tn(m.node).childNodes.length);case"startOf":return G(X.containerPath(m.node),0);default:{let I=m.node.parentNode;return G(X.containerPath(I),X.indexIn(I,m.node)+(m.kind==="after"?1:0))}}},pt=(X,m,I,P,$)=>{let Q=ve(X,m,I);return Q?Je(f[P],Q):$()},Xe=(X,m,I,P)=>{let $=X.textNodes.map(fe=>({s:fe.ms,e:fe.me,start:{kind:"text",node:fe.node,offset:0},end:{kind:"text",node:fe.node,offset:fe.me-fe.ms}}));for(let[fe,Se]of X.atomOut)$.push({s:fe,e:fe+1,start:{kind:"before",node:Se},end:{kind:"after",node:Se}});for(let[fe,Se]of X.breakOut)$.push({s:fe,e:fe+1,start:{kind:"end",node:Se},end:{kind:"after",node:Se}});for(let fe of $)if(fe.start.kind==="text"&&fe.s<m&&m<fe.e)return{kind:"text",node:fe.start.node,offset:m-fe.s};if(I!=="empty"){let fe=$.find(Se=>I==="start"?Se.s===m:Se.e===m);if(fe)return I==="start"?fe.start:fe.end}let Q=$.find(fe=>fe.e===m);if(Q)return Q.end;let B=$.find(fe=>fe.s===m);if(B)return B.start;let me=null,xe=null;for(let fe of $)fe.e<=m&&(!me||fe.e>me.e)&&(me=fe),fe.s>=m&&(!xe||fe.s<xe.s)&&(xe=fe);return me?me.end:xe?xe.start:P()},dt=(X,m)=>{if(!m)return null;if(m.kind==="text"){let $=X.nodes.find(Q=>Q.node===m.node);return $?$.s+Math.min(m.offset,$.e-$.s):null}let I=X.atoms.find($=>$.el===m.node);if(I)return m.kind==="after"?I.i+1:I.i;let P=X.marks.find($=>$.el===m.node);return P?m.kind==="before"&&P.block&&X.text[P.from-1]===wt&&!X.marks.some($=>$.block&&$.to===P.from)?P.from-1:m.kind==="startOf"||m.kind==="before"?P.from:m.kind==="end"&&P.block?P.to-1:P.to:null},St=(X,m,I,P)=>{for(let me of X.nodes)if(I==="start"?me.s<=m&&m<me.e:me.s<m&&m<=me.e)return{kind:"text",node:me.node,offset:m-me.s};let $=I==="start"?m:m-1;if(!X.atomAt.has($)&&X.text[$]!==wt){for(let me of X.nodes)if(me.s===m||me.e===m)return{kind:"text",node:me.node,offset:m-me.s}}let Q=X.atomAt.get($);if(Q)return{kind:I==="start"?"before":"after",node:Q.el};if(X.text[$]===wt){let me=X.marks.find(fe=>fe.block&&fe.to===$+1);if(me)return I==="start"?{kind:"end",node:me.el}:{kind:"after",node:me.el};let xe=X.marks.find(fe=>fe.block&&fe.from===$+1);if(xe)return I==="start"?{kind:"before",node:xe.el}:{kind:"startOf",node:xe.el}}let B=X.marks.find(me=>me.block&&me.from===m);return B?{kind:"startOf",node:B.el}:P?{kind:I==="start"?"startOf":"end",node:P}:null},vt=X=>{if(!X)return null;if(X.kind==="wholeStart"||X.kind==="wholeEnd"){let m=bt(X.node);return X.kind==="wholeStart"?m.start:m.end}return Je(f.out,X)},bt=X=>{let m=X.firstChild,I=X.lastChild;return m&&m.nodeType===3&&I.nodeType===3?{start:G(f.out.pathOf(m),0),end:G(f.out.pathOf(I),I.nodeValue.length)}:{start:G(f.out.pathOf(X),0),end:G(f.out.pathOf(X),X.childNodes.length)}},At=X=>{let m=J(X,"base"),I=m?U(K(m))[0]:null;if(!I)return null;let P=Tn(I),$=o(m);for(let Q=$.indexOf(X)-1;Q>=0;Q--){let B=U(K($[Q])).filter(me=>me.parentNode===P);if(B.length)return{kind:"after",node:B[B.length-1]}}return{kind:"startOf",node:I}},Ot=(X,m,I,P,$,Q)=>({text:X,start:m,end:I,fragment:P,span:$,scope:Q}),Bt=(X,m,I,P,$)=>Ot(X,m,I,X.slice(m,I),P,$),tn=(X,m,I,P,$)=>(x.spans.set(X,{start:m,end:I,scopeStart:P,scopeEnd:$}),X),Nt=new Map,$t=new Map,cn=(X,m,I)=>{let P=`text:${X.key}:${m}:${I}`,$=$t.get(P)||0;return $t.set(P,$+1),`${P}:${$}`},Pt=(X,m)=>{let I,P,$,Q="plain",B,me,xe,fe,Se,V=(ke,we,te,re,q)=>{if(!ke){let le=ae(q,re);return Bt("",0,0,{start:le,end:le},{start:le,end:le})}return Bt(ke.value,we,te,{start:Pe(ke,we,we===te?"end":"start",re),end:Pe(ke,te,"end",re)},{start:Pe(ke,0,"start",re),end:Pe(ke,ke.value.length,"end",re)})};if(m.site==="run"){let{bRun:ke,lRun:we,rRun:te,node:re,c:q}=m;I=K(ke),P=q.bs,$=q.be,B=V(ke,q.bs,q.be,"base",ke),me=V(we,q.ls,q.le,"local",ke),xe=V(te,q.rs,q.re,"remote",ke);let le=re?re.nodeValue:"",Ne=Le=>re?{kind:"text",node:re,offset:Le}:At(ke);fe=tn(Bt(le,q.ms,q.me,{start:vt(Ne(q.ms)),end:vt(Ne(q.me))},{start:vt(Ne(0)),end:vt(Ne(le.length))}),Ne(q.ms),Ne(q.me),Ne(0),Ne(le.length)),Se=re||(At(ke)||{}).node||null}else if(m.site==="whole"){let ke=m.el,we=r.get(ke);I=K(we.base),P=0,$=X.base.length;let te=(q,le,Ne)=>{let Le=He(le,Ne);return Bt(q,0,q.length,Le,Le)};B=te(X.base,we.base,"base"),me=te(X.local,we.local,"local"),xe=te(X.remote,we.remote,"remote");let re=bt(ke);fe=tn(Bt(X.resolved,0,X.resolved.length,re,re),{kind:"wholeStart",node:ke},{kind:"wholeEnd",node:ke},{kind:"wholeStart",node:ke},{kind:"wholeEnd",node:ke}),Se=ke}else if(m.site==="comment"){let{bRun:ke,lRun:we,rRun:te,node:re}=m;I=K(ke),P=0,$=X.base.length;let q=(je,Ae)=>{if(!je){let Qe=ae(ke,Ae);return Bt("",0,0,{start:Qe,end:Qe},{start:Qe,end:Qe})}let Ge=je.nodes[0],et={start:G(f[Ae].pathOf(Ge),0),end:G(f[Ae].pathOf(Ge),je.value.length)};return Bt(je.value,0,je.value.length,et,et)};B=q(ke,"base"),me=q(we,"local"),xe=q(te,"remote");let le=X.resolved,Ne=je=>re?{kind:"text",node:re,offset:je}:At(ke),Le={start:vt(Ne(0)),end:vt(Ne(le.length))};fe=tn(Bt(le,0,le.length,Le,Le),Ne(0),Ne(le.length),Ne(0),Ne(le.length)),Se=re||(At(ke)||{}).node||null}else{let{fb:ke,fl:we,fr:te,scope:re}=m,q=m.merged;Q="html",I=re.base?K(re.base):_(re.local,"local"),P=X.bs,$=X.be;let le=de=>{let ie=re[de];for(let ee=re.at-1;ee>=0;ee--){let se=re.units[ee],Ee=de==="base"?se:w(h(de),se);if(Ee&&J(Ee,de)===ie)return Ee}return null},Ne=de=>()=>ue(re[de],le(de),de),Le=(de,ie,ee,se,Ee)=>{let We=Tt=>Tt?Je(f[Ee],Tt):Ne(Ee)(),Fe=ie===ee?Ze(de,ie):ve(de,ie,"start"),tt=ie===ee?Ze(de,ie):ve(de,ee,"end"),st=We(Fe),it={start:st,end:ie===ee?st:We(tt)},rt=m.full?m.full(Ee):null;if(!rt)return Ot(de.text,ie,ee,se,it,{start:We(ve(de,0,"start")),end:We(ve(de,de.text.length,"end"))});let kt=Fe?dt(rt,Fe):null,xt=tt?dt(rt,tt):null,Et=kt===null?0:kt,$e=Math.max(Et,xt===null?rt.text.length:xt),mt=We(ve(rt,0,"start"));return Ot(rt.text,Et,$e,No(rt,Et,$e),it,{start:mt,end:rt.text.length?We(ve(rt,rt.text.length,"end")):mt})};B=m.synthetic?null:Le(ke,X.bs,X.be,X.base,"base"),me=Le(we,X.lss,X.lse,X.local,"local"),xe=Le(te,X.rss,X.rse,X.remote,"remote");let[je,Ae]=X.range||[0,0],Ge=q.out,et=()=>{let de=Tn(q.node);for(let ie=re.at-1;ie>=0;ie--){let ee=U(K(re.units[ie])).filter(se=>se.parentNode===de);if(ee.length)return{kind:"after",node:ee[ee.length-1]}}for(let ie=re.at;ie<re.units.length;ie++){let ee=U(K(re.units[ie])).filter(se=>se.parentNode===de);if(ee.length)return{kind:"before",node:ee[0]}}return{kind:"startOf",node:q.node}};if(Ge.via)for(let[de,ie]of Ge.via)N.set(de,ie);let Qe=Xe(q,je,je===Ae?"empty":"start",et),Ut=je===Ae?Qe:Xe(q,Ae,"end",et),Mt=Ge.text.length?St(Ge,0,"start",q.node):et(),Kt=Ge.text.length?St(Ge,Ge.text.length,"end",q.node):Mt,Lt=dt(Ge,Qe),Wt=dt(Ge,Ut),C=Lt===null?0:Lt,Y=Math.max(C,Wt===null?Ge.text.length:Wt);fe=tn(Ot(Ge.text,C,Y,No(Ge,C,Y),{start:vt(Qe),end:vt(Ut)},{start:vt(Mt),end:vt(Kt)}),Qe,Ut,Mt,Kt);let ce=x.spans.get(fe);if(ce.flat=Ge,!Ge.text.length){let de=vt(Mt),ie=lo(p,de),ee=ie[0],se=ie[1];ce.empty={parent:ee.nodeType===11?g.get(ee):ee,previous:ee.childNodes[se-1]||null,next:ee.childNodes[se]||null}}Se=Qe?Qe.node:q.node}let Z=Ce(I),be=(m.site==="whole"||m.site==="comment"||(m.policy||i)!=="both")&&X.resolved!==X.local;return{key:m.site==="comment"&&Nt.get(I.b||I.l||I.r)||cn(Z,P,$),subject:Z,localLost:be,anchor:Se,text:{encoding:Q,base:B,local:me,remote:xe,merged:fe,liveSpan:null,liveScope:null}}},Jt=(X,m)=>{let I=A(m.el),P=Ce(I),$=m.sample;return{key:`attr:${P.key}:${$.namespaceURI||""}:${$.localName}`,subject:P,localLost:X.resolved!==X.local,anchor:m.el,attribute:{namespaceURI:$.namespaceURI||null,localName:$.localName,qualifiedName:$.name}}},Ft=(X,m)=>{let I=X.detail,P=m.unit||K(m.subject),$=Ce(P),Q=x.refs.get($),B=P.l?Te(P.l,"local"):null,me=P.r?Te(P.r,"remote"):null,xe=Q.length?ze(Q[0]):null,fe,Se,V,Z=null,be=null,ke=m.deleted;switch(I){case"both-reordered":{fe=Se="reordered";let we=new Set(m.rKept),te=m.lKept.filter(Le=>we.has(Le)&&U(K(Le)).length),re=Le=>T.get(U(K(Le))[0]);Z=te.map(Le=>Ce(K(Le))),be=te.slice().sort((Le,je)=>re(Le)-re(je)).map(Le=>Ce(K(Le)));let q=Le=>!on(Le)&&Le.kind!=="comment"&&Le.nodes.every(je=>!/[^\t\n\f\r ]/.test(je.data)),le=te.filter(Le=>!q(Le)),Ne=le.slice().sort((Le,je)=>re(Le)-re(je));V=le.some((Le,je)=>Le!==Ne[je]);break}case"both-moved":fe=Se="moved",V=!B||!Q.some(we=>{let te=we===Q[0]?xe:ze(we);return te&&te.parent===B.parent});break;case"edit-beats-delete":fe=ke==="local"?"deleted":"edited",Se=ke==="remote"?"deleted":"edited",V=ke==="local";break;case"move-beats-delete":fe=ke==="local"?"deleted":"moved",Se=ke==="remote"?"deleted":"moved",V=ke==="local";break;case"remote-wins":fe="edited",Se="edited",V=!0;break;default:fe=Se="inserted",V=m.localLost}return{key:`structure:${$.key}:${I}`,subject:$,localLost:V,anchor:Q[0]||null,structure:{localAction:fe,remoteAction:Se,localPlacement:B,remotePlacement:me,mergedPlacement:xe,localOrder:Z,mergedOrder:be,localFragment:I==="both-reordered"||!P.l?null:Me(P.l),fragmentKind:v(P.b||P.l||P.r)}}};for(let[X,m]of s){if(X.kind!=="structure")continue;let I=m.unit||K(m.subject),P=I.b||I.l||I.r;!on(P)&&P.kind==="comment"&&Nt.set(P,`structure:${Ce(I).key}:${X.detail}`)}let nn=new Map;for(let[X,m]of s){if(X.kind==="structure"){let Q=Ce(m.unit||K(m.subject)),B=`structure:${Q.key}:${X.detail}`,me=nn.get(B);if(me&&me.structure){X.recovery=me;let xe=x.refs.get(Q);X.el==null&&xe.length&&(X.el=on(xe[0])?xe[0]:f.out.logicalParent(xe[0]));continue}}let I=X.kind==="text"?Pt(X,m):X.kind==="attr"?Jt(X,m):Ft(X,m),P=nn.get(I.key);P||(P={version:$a,key:I.key,localLost:I.localLost,subject:I.subject,applied:!1,unavailable:null},nn.set(I.key,P),x.anchors.set(P,I.anchor)),I.text&&(P.text=I.text),I.attribute&&(P.attribute=I.attribute),I.structure&&(P.structure=I.structure),I.text&&(P.localLost=I.localLost),X.recovery=P;let $=x.refs.get(I.subject);X.kind==="structure"&&X.el==null&&$.length&&(X.el=on($[0])?$[0]:f.out.logicalParent($[0])),X.kind==="text"&&X.node==null&&$.length&&I.subject.nodeType===8&&(X.node=$[0])}return x}}function dl(e,t,n){if(!t)return;let{lookup:o,vetoed:r,vetoedAttrs:i,liveAttr:s}=n,c=n.ignored||(()=>!1),l=ao(n.liveRoot),a=k=>!!k&&l.containerPath(k)!==null,p=k=>{let A=k.parentNode;return A&&A.nodeType===11?t.outOwners.get(A)||null:A},f=k=>{for(let A=k;A;A=p(A))if(t.via.has(A)&&(A=t.via.get(A)),r.has(A)||n.vetoedLive?.has(d(A)))return!0;return!1},h=k=>Array.from(Tn(k).children).filter(A=>!c(A)),w=(k,A)=>h(k)[h(A.parentNode).indexOf(A)],b=(k,A)=>{let J=null,W=null,F=0;for(let pe=A.previousSibling;pe;pe=pe.previousSibling){if(pe.nodeType===1&&!c(pe)){J=pe;break}pe.nodeType===3&&(F+=pe.nodeValue.length)}for(let pe=A.nextSibling;pe&&!W;pe=pe.nextSibling)pe.nodeType===1&&!c(pe)&&(W=pe);let Oe=J?w(k,J):null,Ce=W?w(k,W):null;if(J&&!Oe||W&&!Ce)return null;let De=[];for(let pe=Oe?Oe.nextSibling:Tn(k).firstChild;pe&&pe!==Ce;pe=pe.nextSibling)pe.nodeType===3&&De.push(pe);return De.length?{nodes:De,lead:F}:null},T=k=>{let A=[],J=k;for(;J&&!t.via.has(J);J=J.parentNode)A.push(J);if(!J||!A.length)return null;let W=d(t.via.get(J));for(let Ce=A.length-1;Ce>0&&W;Ce--)W=w(W,A[Ce]);if(!W)return null;let F=A[0];if(F.nodeType===3)return b(W,F);let Oe=F.nodeType===1?w(W,F):null;return Oe?{nodes:[Oe],lead:0}:null},g=k=>{let A=o(k),J=A?{nodes:Array.isArray(A)?A:[A],lead:0}:t.via.size?T(k):null;if(!J)return null;let W=J.nodes.filter(a);return W.length?{nodes:W,lead:J.lead}:null},d=k=>{let A=g(k);return A?A.nodes[0]:null},y=k=>{if(!k)return null;if(k.kind==="text"){let F=g(k.node);if(!F)return null;let Oe=F.nodes,Ce=k.offset+F.lead,De=0;for(let pe=0;pe<Oe.length;pe++){let Te=Oe[pe].nodeValue.length;if(Ce<=De+Te||pe===Oe.length-1)return Ce>=De&&Ce<=De+Te?[Oe[pe],Ce-De]:null;De+=Te}return null}let A=d(k.node);if(!A)return null;if(k.kind==="end")return[Tn(A),Tn(A).childNodes.length];if(k.kind==="startOf")return[Tn(A),0];if(k.kind==="wholeStart")return A.firstChild?[A.firstChild,0]:[A,0];if(k.kind==="wholeEnd")return A.lastChild?[A.lastChild,A.lastChild.nodeValue.length]:[A,A.childNodes.length];let J=A.parentNode;if(!J)return null;let W=Array.prototype.indexOf.call(J.childNodes,A);return[J,k.kind==="after"?W+1:W]},N=k=>({blocks:new Set((k.flat?.marks||[]).filter(A=>A.block).map(A=>d(A.el)).filter(Boolean)),atoms:new Set((k.flat?.atoms||[]).map(A=>d(A.el)).filter(Boolean)),ignored:c}),x=(k,A,J,W)=>{if(!k||!A||!co(k)||!co(A))return!1;for(let Ce of[k,A])if(!a(Ce.startContainer)||!a(Ce.endContainer))return!1;let F=J.merged;if(F.start===F.end&&(k.startContainer!==k.endContainer||k.startOffset!==k.endOffset))return!1;let Oe=N(W);return Yn(A,J.encoding,Oe)===F.text&&Yn(k,J.encoding,Oe)===F.text.slice(F.start,F.end)},S=new Map,O=k=>{let A=k.parentNode;return A?(S.has(A)||S.set(A,new Map(Array.from(A.childNodes,(J,W)=>[J,W]))),S.get(A).get(k)):-1},R=(k,A)=>{if(!A)return!1;let J=l.logicalParent(k);if(!A.parent.live.includes(J))return!1;let W=O(k);for(let[F,Oe]of[["before",1],["after",-1]]){let Ce=W;for(let De of A[F]){if(De.live.includes(k))continue;let pe=De.live.filter(ze=>ze!==k&&ze.parentNode===k.parentNode);if(!pe.length)continue;let Te=Oe===1?Math.min(...pe.map(O)):Math.max(...pe.map(O));if(Oe*(Te-Ce)<=0)return!1;Ce=Te}}return!0},M=k=>{let A=k.structure;if(A.mergedOrder){let J=new Set(k.subject.live.map(Tn)),W=null,F=-1;for(let Oe of A.mergedOrder){let Ce=Oe.live.find(De=>J.has(De.parentNode));if(!Ce||W&&Ce.parentNode!==W||O(Ce)<=F)return!1;W=Ce.parentNode,F=O(Ce)}return k.subject.live.length>0}return k.subject.live.some(J=>R(J,A.mergedPlacement))},j=(k,A)=>{let J=y(k),W=y(A);return J&&W?{startContainer:J[0],startOffset:J[1],endContainer:W[0],endOffset:W[1]}:null},U=new Set,K=k=>{if(!k||U.has(k))return;U.add(k);let A=[];for(let J of t.refs.get(k)||[]){let W=g(J);if(W)for(let F of W.nodes)A.includes(F)||A.push(F)}k.live=A},_=k=>{k&&(K(k.parent),k.before.forEach(K),k.after.forEach(K))},H=new Set;for(let k of e){let A=k.recovery;if(!A||H.has(A))continue;H.add(A),K(A.subject),A.structure&&(_(A.structure.localPlacement),_(A.structure.remotePlacement),_(A.structure.mergedPlacement),(A.structure.localOrder||[]).forEach(K),(A.structure.mergedOrder||[]).forEach(K));let J=t.anchors.get(A),W=J?d(J):null,F=!!W;if(A.text){let G=t.spans.get(A.text.merged),ue=G?j(G.start,G.end):null,ae=G?j(G.scopeStart,G.scopeEnd):null;if(G?.empty){let Pe=G.empty,He=Pe.previous?{kind:"after",node:Pe.previous}:{kind:"startOf",node:Pe.parent},ve=Pe.next?{kind:"before",node:Pe.next}:{kind:"end",node:Pe.parent},Ze=j(He,ve);!Ze||Ze.startContainer!==Ze.endContainer||Ze.startOffset!==Ze.endOffset?ue=null:ue=ae=Ze}x(ue,ae,A.text,G)||(ue=ae=null),A.text.liveSpan=ue,A.text.liveScope=ue?ae:null,ue||(F=!1)}A.structure&&F&&(F=M(A)),A.attribute&&F&&(F=s(W,A.attribute,k.resolved));let Oe=G=>G?.tagName==="TEXTAREA"?G:G?.parentNode?.tagName==="TEXTAREA"?G.parentNode:null,Ce=(!!A.attribute||!!A.text&&!!(Oe(W)||Oe(J)))&&!!i&&[J,W,Oe(W),Oe(J)].some(G=>i.get(G)?.has(A.attribute?A.attribute.qualifiedName:"value")),De=t.localState?.states.get(A),pe=!!A.text&&[...n.removedVetoes||[]].some(G=>De?.touched.has(G)),Te=A.structure?.localAction==="inserted"&&[...r].some(G=>G===J||J?.contains(G)),ze=J&&f(J)||Ce||pe||Te,Me=ze&&fl(A,k,t,a);Me&&(pe||Te&&A.localLost)&&(F=!1);let v=!F&&Me&&ze;A.applied=F,A.unavailable=F?null:v?"hook-veto":"missing-output",v&&(A.localLost=!1),!F&&A.text&&(A.text.liveSpan=A.text.liveScope=null)}}function Ur(e,t,n){let o=ao(t),r=ao(n),i=f=>!!f&&r.containerPath(f)!==null,s=f=>{if(f===t)return n;let h=o.pathOf(f);if(h&&t!==n){let w=lo(n,{path:h,offset:0});if(w&&w[0].nodeType===f.nodeType)return w[0]}return f},c=new Set,l=f=>{!f||c.has(f)||(c.add(f),f.live=f.live.map(s).filter(i))},a=f=>{f&&(f.startContainer=s(f.startContainer),f.endContainer=s(f.endContainer))},p=new Set;for(let f of e){f.node===t&&n.tagName==="SCRIPT"&&(f.node=n),f.el===t&&f.kind==="structure"&&(f.el=n);let h=f.recovery;if(!h||p.has(h))continue;if(p.add(h),l(h.subject),h.text){a(h.text.liveSpan),a(h.text.liveScope);let b=h.text.liveSpan,T=h.text.liveScope,g=h.text.merged,d=y=>!!y&&co(y)&&i(y.startContainer)&&i(y.endContainer);(!d(b)||!d(T)||Yn(T,h.text.encoding)!==g.text||Yn(b,h.text.encoding)!==g.text.slice(g.start,g.end))&&(h.text.liveSpan=null,h.text.liveScope=null,h.applied=!1,h.unavailable="missing-output")}let w=h.structure;if(w){for(let b of[w.localPlacement,w.remotePlacement,w.mergedPlacement])b&&(l(b.parent),b.before.forEach(l),b.after.forEach(l));(w.localOrder||[]).forEach(l),(w.mergedOrder||[]).forEach(l),h.subject.live.length||(h.applied=!1,h.unavailable="missing-output")}}}var Io=e=>e?.nodeType===1,Qo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function Fa({provenance:e,parentOf:t,twins:n,baseOf:o,build:r,ignored:i,remoteWins:s,discarded:c}){let l=new Map,a=new WeakMap;function p(w,b,T,g=!1){if(!Io(w)||!Io(T))return null;let d=l.get(w);if(d)(g||!d.selected&&b==="remote")&&(d.parent=t(T),d.port=T,d.sourceSide=b,d.selected=g);else{let y=a.get(w)||null;d={owner:w,parent:t(T),port:T,sourceSide:b,originalParent:t(w),originalPort:w,selected:g,state:y?"built":"planned",output:y,disposition:null},l.set(w,d)}return d}function f(w,b){if(!Io(w)||!Io(b))return;a.has(w)||a.set(w,b);let T=l.get(w);T&&T.state!=="attached"&&!T.output&&(T.output=b,T.state="built")}function h(w){if(!l.size)return;let b=new Map,T=new WeakMap,g=new WeakMap,d=new WeakSet,y=new Set,N=(_,H)=>{if(!_)return;if(Array.isArray(_)){for(let A of _)N(A,H);return}let k=b.get(_);k||b.set(_,k=[]),k.push(H)},x=(_,H)=>{if(!_)return;let k=[_];for(;k.length;){let A=k.pop();N(A,H);for(let J of Qo(A).childNodes)k.push(J)}};function S(_,H=null,k=!1){if(d.has(_))return;d.add(_),T.set(_,H);let A=e.get(_),J=k||!!(A&&s(A.remote||A.base));g.set(_,J);let W={node:_,kind:"node",authority:J};if(A?.pinned)x(A.local,{...W,kind:"ignored"});else if(A?.unchanged)for(let F of[A.base,A.local,A.remote])x(F,{...W,kind:"unchanged"});else if(A){for(let F of[A.base,A.local,A.remote])N(F,W);if(Io(A.local))for(let F of Qo(A.local).children)i(F)&&x(F,{...W,kind:"ignored"})}for(let F of Qo(_).childNodes)S(F,_,J)}let O=_=>{if(_.output&&d.has(_.output))return _.state="attached",_.disposition="node",!0;let{local:H,remote:k}=n(_.owner);for(let A of[_.owner,H,k]){let J=b.get(A);if(J?.length){let W=J.find(F=>F.kind==="node")||J[0];return _.output=W.node,_.state="attached",_.disposition=W.kind,!0}}return!1},R=(_,H)=>(b.get(_)||[]).find(A=>A.kind==="node"&&Io(A.node)&&(!A.authority||H.sourceSide==="remote"))?.node,M=(_,H,k)=>{let A=b.get(_)||[],J=k?[...A].reverse():A;for(let W of J){if(W.kind!=="node")continue;let F=W.node;for(;F&&T.get(F)!==H;)F=T.get(F);if(F)return F}return null},j=(_,H,k)=>{let A=Qo(H);for(let J=k?.previousSibling;J;J=J.previousSibling){let W=M(J,H,!0);if(W){A.insertBefore(_,W.nextSibling);return}}for(let J=k?.nextSibling;J;J=J.nextSibling){let W=M(J,H,!1);if(W){A.insertBefore(_,W);return}}A.appendChild(_)};function U(_,H,k){let A=H==="base"?_:o(_,H),J=l.get(A);J&&J!==k&&K(J)}function K(_){if(_.state==="attached"||_.disposition==="remote-wins"||y.has(_)||O(_))return;y.add(_);let{local:H,remote:k}=n(_.owner);if(s(k||_.owner)){if(!k){_.disposition="remote-wins",c(_.owner,H),y.delete(_);return}_.parent=t(k),_.port=k,_.sourceSide="remote"}if(U(_.parent,_.sourceSide,_),O(_)){y.delete(_);return}let A=R(_.parent,_),J=_.port;if(!A){if(U(_.originalParent,"base",_),O(_)){y.delete(_);return}let F=_.originalParent;for(J=_.originalPort;F&&!A;)A=R(F,_),A||(J=F,F=t(F))}if(!A)throw new Error("A planned move has no allowed surviving parent");let W=_.output||r(_.owner);_.output=W,_.state="built",j(W,A,J),S(W,A,g.get(A)||!1),O(_),y.delete(_)}S(w);for(let _ of l.values())K(_)}return{planned:l,has:w=>l.has(w),plan:p,produced:f,drain:h}}function Co(e,t,n,o,r,i,s,c,l,a,p,f,h){let w=null;return Fa({provenance:e,parentOf:g=>{if(!g)return null;let d=t(g);if(d||g.parentNode?.nodeType!==11)return d;if(!w){w=new WeakMap;let y=[f,h];for(;y.length;){let N=y.pop(),x=Qo(N);x!==N&&w.set(x,N);for(let S of x.children)y.push(S)}}return w.get(g.parentNode)||null},twins:g=>({local:r(n,g),remote:r(o,g)}),baseOf:(g,d)=>g&&(d==="local"?n:o).reverse.get(g)||null,build:g=>i(g,r(n,g),r(o,g),!1),ignored:s,remoteWins:c,discarded:(g,d)=>{d&&p(g,d,n)&&!l.some(y=>y.detail==="remote-wins"&&y.base===g)&&a({kind:"structure",el:null,detail:"remote-wins",base:g,local:d,remote:null},{subject:g})}})}function qa({parent:e,base:t,views:n,eligible:o,ignored:r,remoteWins:i,budget:s=_t(2e4*32),maxUnits:c=256,maxCharacters:l=2e4}){let a=(d,y=null)=>({status:d,reason:y,parent:e,records:[]});if(n.some(({V:d})=>d.asBase)||r(e)||i(e)||n.some(({V:d})=>!d.el||r(d.el)||i(d.el)))return a("none");let p=t.length+n[0].V.units.length+n[1].V.units.length;if(p>c)return a("fallback","unit-limit");let f=Symbol(),h=d=>{if(d>s.remaining)throw f;s.remaining-=d,s.crossParentSteps=(s.crossParentSteps||0)+d},w=new Map,b=0,T=d=>{if(h(1),w.has(d))return w.get(d);let y=d.nodeType===1?d.childNodes:d.nodes;h(y.length*4+1);let N=d.nodeType===1?Array.from(y):y,x=0;for(let R=0;R<N.length;R++){let M=N[R];if(M.nodeType!==3||R&&N[R-1].nextSibling!==M)return w.set(d,null),null;x+=M.data.length}if(x>l-b)throw f;h(x*8+1),b+=x;let S=zt(N);if(S.text.includes(wt))return w.set(d,null),null;let O={unit:d,nodes:N,flat:S};return w.set(d,O),O},g=[];try{h(p*8+1);for(let d=0;d<2;d++){let y=n[d].V,N=n[1-d].V,x=[],S=new Map;for(let O=0;O<t.length;O++){h(1);let R=t[O];if(R.kind!=="text"||y.twin(R))continue;let M=N.twin(R);if(!M||M.kind!=="text"||!N.here(M))continue;let j=T(R),U=T(M);if(!j||!U||!/\S/.test(j.flat.text))continue;h(j.flat.text.length*2+1);let K=j.flat.text;S.set(K,(S.get(K)||0)+1),x.push({source:R,opposite:M,sourceModel:j,oppositeModel:U,index:O})}for(let O of x){let{source:R,opposite:M,sourceModel:j,oppositeModel:U,index:K}=O,_=[];for(let G of[-1,1]){h(1);let ue=t[K+G];if(!ue||ue.nodeType!==1||!o(ue)||r(ue)||i(ue))continue;let ae=j.nodes[0],Pe=j.nodes.at(-1);if(G===-1?ae?.previousSibling!==ue:Pe?.nextSibling!==ue)continue;let He=y.twin(ue),ve=N.twin(ue);if(!He||!ve||!y.here(He)||N.here(ve)||y.baseOf(He)!==ue||N.baseOf(ve)!==ue||!o(He)||!o(ve)||r(He)||r(ve)||i(He)||i(ve)||He.tagName!==ue.tagName||ve.tagName!==ue.tagName||He.namespaceURI!==ue.namespaceURI||ve.namespaceURI!==ue.namespaceURI)continue;let Ze=T(ue),Je=T(He),pt=T(ve);if(!Ze||!Je||!pt||!/\S/.test(Ze.flat.text))continue;let Xe=Ze.flat.text,dt=j.flat.text,St=Je.flat.text;if(h((Xe.length+dt.length+St.length)*3+1),St.length!==Xe.length+dt.length)continue;let vt=G===-1;(vt?!St.startsWith(Xe)||!St.endsWith(dt):!St.startsWith(dt)||!St.endsWith(Xe))||_.push({owner:ue,target:He,moved:ve,ownerBase:Ze,joined:Je,ownerOther:pt,targetFrom:vt?Xe.length:0,retainedFrom:vt?0:dt.length})}if(!_.length)continue;if(_.length!==1||S.get(j.flat.text)!==1)return a("fallback","ambiguous-origin");let H=_[0],{owner:k,target:A,moved:J,ownerBase:W,joined:F,ownerOther:Oe,targetFrom:Ce,retainedFrom:De}=H;if(h(g.length+1),g.some(G=>G.owner===k))return a("fallback","ambiguous-owner");let pe={source:R,target:A,from:0,to:j.flat.text.length,targetFrom:Ce},Te=Cn({base:j.flat,side:F.flat,retained:[],transfers:[{from:pe.from,to:pe.to,target:Ce,destination:k}],budget:s});if(Te.status!=="ready"||Te.covers(pe.from,pe.to)!==!0)return a("fallback",Te.reason||"work-limit");let ze=[{unit:R,model:j,from:0,to:j.flat.text.length},null,null];ze[d+1]={unit:A,model:F,from:Ce,to:Ce+j.flat.text.length},ze[2-d]={unit:M,model:U,from:0,to:U.flat.text.length};let Me=[W,null,null];Me[d+1]=F,Me[2-d]=Oe;let v=[k,null,null];v[d+1]=A,v[2-d]=J,g.push({side:d,parent:e,source:R,target:A,owner:k,owners:v,ownerModels:Me,native:ze,models:w,runs:[pe],proof:Te,retained:[{source:k,target:A,from:0,to:W.flat.text.length,targetFrom:De}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:a("none")}catch(d){if(d!==f)throw d;return a("fallback","work-limit")}}function hl({describe:e,parentOf:t,...n}){let o=new WeakMap,r=new WeakMap,i=n.budget||_t(2e4*32),s=c=>{if(!c)return null;if(o.has(c))return o.get(c);o.set(c,{status:"planning",parent:c,records:[]});let l=e(c),a=l?qa({...n,...l,parent:c,budget:i}):{status:"none",reason:null,parent:c,records:[]};if(o.set(c,a),a.status==="ready")for(let p of a.records)r.set(p.owner,[p]);return a};return{get:s,forOwner(c){return s(t(c))?.status==="ready"&&r.get(c)||null}}}function Ka(e,t){if(e.side!==0)return null;let n=e.native[0].model,o=e.ownerModels[0],r=e.native[1].from!==0,i=(N,x)=>r?[...N.nodes,...x.nodes]:[...x.nodes,...N.nodes],s=e.ownerModels.reduce((N,x)=>N+x.flat.text.length,0)+n.flat.text.length+e.native[2].model.flat.text.length;if(s*8>t.remaining)return null;t.remaining-=s*8;let c={base:i(o,n),local:e.ownerModels[1].nodes,remote:i(e.ownerModels[2],e.native[2].model)},l=zt(c.base),a=e.ownerModels[1].flat,p=zt(c.remote),f=r?o.flat.text.length:0,h=r?0:n.flat.text.length,w=Cn({base:l,side:a,retained:e.retained.map(N=>({from:h+N.from,to:h+N.to,target:N.targetFrom})),transfers:e.runs.map(N=>({from:f+N.from,to:f+N.to,target:N.targetFrom,destination:e.owner})),budget:t});if(w.status!=="ready"||w.covers(0,l.text.length)!==!0)return null;let b=e.ownerModels[2].flat,T=e.native[2].model.flat,g=[];for(let[N,x,S,O]of[[o.flat,b,h,r?0:T.text.length],[n.flat,T,f,r?b.text.length:0]]){let R=Ts(N,N,x).remoteMap.bTo,M=-1;for(let j=0;j<N.text.length;j++){if(R[j]<0){M=-1;continue}let U=g.at(-1);M>=0&&U.to===S+j&&U.target+U.to-U.from===O+R[j]?U.to++:(g.push({from:S+j,to:S+j+1,target:O+R[j]}),M=j)}}let d=Cn({base:l,side:p,retained:g,transfers:[],budget:t});if(d.status!=="ready")return null;let y=Ts(l,a,p,{},{local:w,remote:d});return y.localEdits.hunks.length?null:(y.localMap=w,y.remoteMap=d,{nodes:c,prepared:y})}function pl({L:e,R:t,twinIn:n,unitsOf:o,view:r,parentOf:i,ignored:s,remoteWins:c,eligible:l,build:a,out:p,policy:f,provenance:h,textMappers:w,segments:b,conflicts:T,conflict:g,decisions:d}){let y=_t(2e4*32),N=_=>{let H=0;for(let k=_;k;k=i(k))if(++H>64||k.nodeType===1&&(s(k)||c(k)))return!1;return!0},x=hl({parentOf:i,eligible:l,ignored:s,remoteWins:c,budget:y,describe(_){let H=n(e,_),k=n(t,_);return!H||!k||!N(_)||!N(H)||!N(k)?null:{base:o(_),views:[{A:e,V:r(e,H,_,!1)},{A:t,V:r(t,k,_,!1)}]}}}),S=new WeakSet,O=new WeakMap,R=new WeakSet,M=[];function j(_){if(!_||S.has(_))return;S.add(_);let H=x.get(_);if(H?.status==="ready")for(let k of H.records){if((_.tagName==="TEMPLATE"&&_.content?_.content:_).childNodes.length!==k.native[0].model.nodes.length+1||!k.owners.every(N))continue;let J=Ka(k,y);if(!J)continue;let W={record:k,payload:J,state:"planned",output:null,result:null};O.set(k.owner,W),R.add(k.source),R.add(k.native[2].unit),M.push(W)}}function U(_,H){let k=O.get(_);if(!k)return!1;if(!k.result){if(k.result=Rr({...k.payload.nodes,prepared:k.payload.prepared,out:p,policy:f,provenance:h,textMappers:w,conflicts:T,conflict:g,decisions:d,node:H}),k.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");b.push(...k.result.segments),k.decision={kind:"text",node:H,source:"local"},d.push(k.decision)}return k.decision.node=H,H.replaceChildren(...k.result.nodes),k.output=H,k.state="built",!0}function K(_){if(!M.length)return;let H=new WeakSet,k=new WeakMap,A=new WeakMap,J=new WeakMap,W=Te=>Te.tagName==="TEMPLATE"&&Te.content?Te.content:Te,F=(Te,ze)=>{if(!Te)return;if(Array.isArray(Te)){for(let v of Te)F(v,ze);return}let Me=J.get(Te);Me||J.set(Te,Me=[]),Me.push(ze)},Oe=(Te,ze=null,Me=!1)=>{H.add(Te),k.set(Te,ze);let v=h.get(Te),G=Me||!!(v&&c(v.remote||v.base));if(A.set(Te,G),v)for(let ue of[v.base,v.local,v.remote])F(ue,Te);if(!(v?.pinned||v?.unchanged))for(let ue of W(Te).childNodes)Oe(ue,Te,G)},Ce=Te=>(J.get(Te)||[]).find(ze=>ze.nodeType===1&&!A.get(ze)&&!h.get(ze)?.pinned&&!h.get(ze)?.unchanged),De=(Te,ze)=>{for(let Me of J.get(Te)||[]){let v=Me;for(;v&&k.get(v)!==ze;)v=k.get(v);if(v)return v}return null},pe=(Te,ze,Me)=>{let v=W(ze);for(let G=Me.nextSibling;G;G=G.nextSibling){let ue=De(G,ze);if(ue){v.insertBefore(Te,ue);return}}for(let G=Me.previousSibling;G;G=G.previousSibling){let ue=De(G,ze);if(ue){v.insertBefore(Te,ue.nextSibling);return}}v.appendChild(Te)};Oe(_);for(let Te of M){let{record:ze}=Te,Me=Ce(ze.owner)||Ce(ze.owners[1])||Ce(ze.owners[2]);if(Me)(!Te.result||Te.output!==Me||Te.result.nodes.some(v=>!H.has(v)||k.get(v)!==Me)||Me.textContent!==Te.result.text)&&(U(ze.owner,Me),Oe(Me,k.get(Me),A.get(Me)));else{let v=ze.parent,G=ze.owner,ue=null;for(;v&&!ue;)ue=Ce(v),ue||(G=v,v=i(v));if(!ue)throw new Error("A cross-parent payload has no allowed surviving parent");Me=Te.output||a(ze.owner,ze.owners[1],ze.owners[2],!1),Te.result||U(ze.owner,Me),pe(Me,ue,G),Oe(Me,ue,A.get(ue))}Te.state="attached"}}return{ensureParent:j,ensureOwner(_){j(i(_))},consumes(_){return R.has(_)},render:U,drain:K}}var yn=/\S/,ml=/[\p{L}\p{N}]/u;function fo(e,t,n,o){if(e?.nodeType!==1||!t(e))return!1;for(let r=e.firstChild;r;r=r.nextSibling)if(o(n,1),r.nodeType!==3)return!1;return!!e.firstChild}function Rs(e,t,n){for(let o=e.parentNode;o;o=o.parentNode)if(n(t,1),o.nodeType===11)return!1;return!0}function gl(e,t,n,o,r){let i=n(e,o),s=n(t,o),c=null,l=null,a=null,p=null;r(o,i.length+s.length);for(let f of i)ml.test(f.raw)&&(c||=f,l=f);for(let f of s)ml.test(f.raw)&&(a||=f,p=f);return!!(c&&a&&(c.raw===a.raw||l.raw===p.raw))}function za({base:e,V:t,A:n,source:o,original:r,current:i,edited:s,destination:c,at:l,ownLength:a,eligible:p,model:f,tokensOf:h,budget:w,charge:b}){let T=r.flat.text,g=i.flat.text,d=s.flat.text,y=c.flat.text;if(b(w,T.length+g.length+y.length),T.startsWith(g)||T.endsWith(g))return!1;let N=yn.test(y.slice(0,l)),x=yn.test(y.slice(l+a));if(N===x)return!1;let S=N?0:l+a,O=N?l:y.length;for(;S<O&&!yn.test(y[S]);)S++;for(;O>S&&!yn.test(y[O-1]);)O--;let R=y.slice(S,O);if(An(R,y,h(c,w),w,b,!0)!==S)return!1;let M=An(R,T,h(r,w),w,b,!0);if(M<0)return!1;let j=M+R.length,U=!yn.test(T.slice(0,M)),K=!yn.test(T.slice(j));if(U===K||An(R,g,h(i,w),w,b,!1)>=0)return!1;let _=U?T.slice(j):T.slice(0,M),H=U?d.length-_.length:0;if(b(w,T.length+d.length),H<0||!yn.test(_)||An(_,d,h(s,w),w,b,!0)!==H||!yn.test(U?d.slice(0,H):d.slice(_.length)))return!1;for(let k of e){if(b(w,1),k===o||!fo(k,p,w,b))continue;let A=f(k,null,w);if(An(R,A.flat.text,h(A,w),w,b,!1)>=0)return!1}for(let k of t.units){if(b(w,1),k===i.unit||k===c.unit||!fo(k,p,w,b))continue;let A=f(k,n,w);if(An(R,A.flat.text,h(A,w),w,b,!1)>=0)return!1}return!0}function bl({base:e,views:t,side:n,attempt:o,eligible:r,blocked:i,baseId:s,model:c,tokensOf:l,charge:a,exhausted:p,limit:f}){if(f<=0)return null;let h=_t(f),{V:w,A:b,idOf:T}=t[n],g=t[1-n],[d,y,N,x]=o,S=null;try{for(let O=d;O<=y;O++){a(h,1);let R=e[O];if(R.parentNode?.nodeType!==1||i.has(R)||b.identical.has(R)||g.A.identical.has(R)||!fo(R,r,h,a)||s(R))continue;let M=w.twin(R),j=g.V.twin(R);if(!M||!j||!w.here(M)||!g.V.here(j)||b.map.get(R)!==M||b.reverse.get(M)!==R||g.A.map.get(R)!==j||g.A.reverse.get(j)!==R||T(M)||g.idOf(j)||M.tagName!==R.tagName||j.tagName!==R.tagName||!fo(M,r,h,a)||!fo(j,r,h,a)||!Rs(R,h,a)||!Rs(M,h,a)||!Rs(j,h,a))continue;let U=c(R,null,h),K=c(M,b,h),_=c(j,g.A,h),H=U.flat.text,k=K.flat.text,A=_.flat.text;if(a(h,H.length+k.length+A.length),!yn.test(H)||!yn.test(k)||!yn.test(A)||H===k||H===A||k===A||!gl(U,K,l,h,a)||!gl(U,_,l,h,a))continue;let J=null,W=!1;for(let Ce=N;Ce<=x;Ce++){a(h,1);let De=w.units[Ce],pe=w.baseOf(De);if(!pe||pe===R||i.has(pe)||pe.parentNode!==R.parentNode||De.parentNode!==M.parentNode||pe.tagName!==R.tagName||De.tagName!==R.tagName||b.map.get(pe)!==De||b.reverse.get(De)!==pe||s(pe)!==T(De)||!fo(pe,r,h,a)||!fo(De,r,h,a))continue;let Te=c(pe,null,h),ze=c(De,b,h),Me=Te.flat.text,v=ze.flat.text;if(a(h,Me.length),!yn.test(Me)||v.length<=Me.length)continue;let G=l(ze,h),ue=An(Me,v,G,h,a,!0);if(!(ue<0||An(H,v,G,h,a,!0,ue,ue+Me.length)<0&&!za({base:e,V:w,A:b,source:R,original:U,current:K,edited:_,destination:ze,at:ue,ownLength:Me.length,eligible:r,model:c,tokensOf:l,budget:h,charge:a}))){if(J){W=!0;break}J=De}}if(!J||W)continue;let F=n===0?M:j,Oe=n===0?j:M;(S||=[]).push({source:R,local:F,remote:Oe,models:[U,n===0?K:_,n===0?_:K]})}}catch(O){if(O!==p)throw O}return S}var Pn=/\S/,ln=/\s/,Ga=/[\s\u001e]/g,Ls=/[^\s\p{P}\u001e\ufffc]/u;function Xa(e,t,n,o,r,i,s){let c=0;for(let l of e)s(i,1),l.nodeType===1&&!o.baseOf(l)&&c++;if(c<2)return!1;for(let l of e){if(l.nodeType!==1||o.baseOf(l))continue;let a=r.get(l).flat;if(a.atoms.length||a.pins?.length)continue;s(i,a.text.length*2+t.length+n.length);let p=new Uint8Array(a.text.length);for(let f of n)f.target===l&&p.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f of t)f.target===l&&p.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f=0;f<a.text.length;f++)if(!p[f]&&Pn.test(a.text[f]))return!0}return!1}function Ya(e,t,n){let{source:o,models:r,retained:i,runs:s}=e,c=r.get(o).flat.text;n(t,c.length*2+i.length+s.length);let l=new Uint8Array(c.length);for(let a of i)a.source===o&&(n(t,a.to-a.from),l.fill(1,a.from,a.to));for(let a of s)n(t,a.to-a.from),l.fill(1,a.from,a.to);for(let a=0;a<c.length;a++)if(!l[a]&&Pn.test(c[a]))return!1;return!0}function Ja(e,t,n,o,r,i,s,c,l,a){let p=i.get(e),f=i.get(t),h=p.flat.text,w=s.get(e);l(a,h.length*2+n.length);let b=h.length,T=0;for(let y=0;y<h.length;y++)!ln.test(h[y])&&!w[y]&&(b=Math.min(b,y),T=y+1);if(b>=T)return null;for(let y=b;y<T;y++)if(!ln.test(h[y])&&w[y])return null;let g=-1;for(let y of n)if(y.target===t&&y.from<=b&&y.to>b){g=y.targetFrom+b-y.from;break}if(g<0)return null;let d=h.slice(b,T);if(l(a,d.length*(n.length+2)),f.flat.text.slice(g,g+d.length)!==d)return null;for(let y=b;y<T;y++){if(ln.test(h[y]))continue;let N=!1;for(let x of n)if(x.target===t&&x.from<=y&&x.to>y&&x.targetFrom+y-x.from===g+y-b){N=!0;break}if(!N)return null}if(p.flat.atoms.length||f.flat.atoms.length){l(a,p.flat.atoms.length+f.flat.atoms.length);let y=0,N=f.flat.atoms;for(;y<N.length&&N[y].i<g;)y++;for(let x of p.flat.atoms){if(x.i<b||x.i>=T)continue;let S=N[y++];if(!S||S.i!==g+x.i-b||f.alignment?.reverse.get(S.el)!==x.el)return null}if(y<N.length&&N[y].i<g+T-b)return null}for(let[y,N,x]of[[o,e,b],[r,t,g]]){let S=!1;for(let O of y){let R=i.get(O),M=s.get(O),j=c(R,a);for(let U=0;U<j.length;U++){let K=j[U].from,_=K+d.length;if(l(a,d.length*2+1),R.flat.text.slice(K,_)!==d)continue;let H=U;for(;H<j.length&&j[H].to<_;)l(a,1),H++;if(H===j.length||j[H].to!==_)continue;let k=!0;for(let A=K;A<_;A++)if(!ln.test(R.flat.text[A])&&M[A]){k=!1;break}if(k){if(S||O!==N||K!==x)return null;S=!0}}}if(!S)return null}return d}function Za(e,t,n,o,r,i,s,c){if(s(c,r.length+i.length+(o.length+1)*n.length*2),!n)return!1;let l=o.indexOf(n);return l<0||o.lastIndexOf(n)!==l||!i.some(a=>a.from===l)||!i.some(a=>a.to===l+n.length)?!1:r.some(a=>a.source===e&&a.target===t&&a.from===0&&a.to===n.length&&a.targetFrom===l)}function yl({base:e,views:t,eligible:n,baseId:o,ignored:r,remoteWins:i,atomKey:s,limit:c=2e4*8}){if(c<=0)return null;let l=Symbol(),a=(x,S)=>{if(S>x.remaining)throw l;x.remaining-=S},p=[new Map,new Map];for(let x=0;x<2;x++)for(let S=0;S<t[x].V.units.length;S++)p[x].set(t[x].V.units[S],S);let f=new Int32Array(e.length),h=new Int32Array(e.length),w=x=>t.every(({V:S},O)=>{let R=S.twin(x);return R&&p[O].has(R)}),b=-1;for(let x=0;x<e.length;x++)f[x]=b,w(e[x])&&(b=x);b=e.length;for(let x=e.length-1;x>=0;x--)h[x]=b,w(e[x])&&(b=x);let T=new Map,g=(x,S)=>{if(a(S,1),T.has(x))return T.get(x);let O=x.firstChild,R=1;for(;O;){if(a(S,R*8+8),O.nodeType===3&&a(S,O.data.length*8),O.nodeType===1&&hn.has(O.tagName)&&!r(O)&&!i(O)&&O.firstChild){O=O.firstChild,R++;continue}for(;O&&O!==x&&!O.nextSibling;)O=O.parentNode,R--;O=!O||O===x?null:O.nextSibling}let M=zt(Array.from(x.childNodes),{ignored:r,remoteWins:i});return T.set(x,M),M},d=(x,S,O,R,M,j)=>{for(let U of x.atoms){a(j,1);let K=S.atomAt.get(U.i+O);if(!K)return!1;let _=R?.reverse.get(U.el)||s(U.el),H=M?.reverse.get(K.el)||s(K.el);if(_!==H)return!1}return!0},y=(x,S,O,R,M)=>{let j=x.text.length<=S.text.length?x:S,U=j===x?S:x;if(a(M,j.text.length+U.text.length),!j.text||!Pn.test(j.text.replaceAll(Rn,"")))return!1;let K;if(j.text===U.text)K=0;else{let _=U.text.length-j.text.length;if(a(M,(_+1)*j.text.length*2),U.text.startsWith(j.text))K=0;else if(U.text.endsWith(j.text))K=_;else return!1;if(U.text.indexOf(j.text)!==K||U.text.lastIndexOf(j.text)!==K)return!1;a(M,U.text.length*2);let H=0,k=K===0,A=!1;for(let J of en(U.text,dn(U.text)))H+=J.len,H===K&&(k=!0),H===K+j.text.length&&(A=!0);if(!k||!A)return!1}return j===x?d(j,U,K,O,R,M):d(j,U,K,R,O,M)},N=null;for(let x=0;x<2;x++){let{V:S,A:O,idOf:R}=t[x],M=t[1-x];if(!S.asBase)for(let j=0;j<e.length;j++){let U=e[j];if(S.twin(U)||!n(U))continue;let K=M.V.twin(U);if(!K||!p[1-x].has(K)||!n(K))continue;let _={remaining:c};try{let H=f[j],k=h[j],A=0;for(let Oe=H+1;Oe<k;Oe++)a(_,1),!S.twin(e[Oe])&&M.V.twin(e[Oe])&&n(e[Oe])&&A++;if(A!==1||g(U,_).text===g(K,_).text)continue;let J=H<0?-1:p[x].get(S.twin(e[H])),W=k===e.length?S.units.length:p[x].get(S.twin(e[k]));if(J===void 0||W===void 0||J>=W)continue;let F=null;for(let Oe=J+1;Oe<W;Oe++){a(_,1);let Ce=S.units[Oe];if(S.baseOf(Ce)||!n(Ce)||Ce.tagName!==U.tagName||Ce.namespaceURI!==U.namespaceURI)continue;let De=o(U),pe=M.idOf(K),Te=R(Ce);if(!(De&&pe&&De!==pe||De&&Te&&De!==Te||pe&&Te&&pe!==Te)&&y(g(K,_),g(Ce,_),M.A,O,_)){if(F){F=null;break}F=Ce}}if(!F)continue;N||(N=[new Map,new Map]),N[x].set(U,F)}catch(H){if(H!==l)throw H}}}return N?t.map(({V:x},S)=>{let O=N[S];if(!O.size)return x;let R=new Map;for(let[M,j]of O)R.set(j,M);return{...x,twin:M=>O.get(M)||x.twin(M),baseOf:M=>R.get(M)||x.baseOf(M)}}):null}function wl({onUncertainSource:e,onUncertainOwner:t,base:n,views:o,eligible:r,ignored:i,remoteWins:s,baseId:c,atomKey:l,limit:a=2e4*32}){if(a<=0)return null;let p=new Set(n),f=new Map(n.map((H,k)=>[H,k])),h=new Map,w=[],b=null,T=null,g=null,d=new Set;for(let H of n)for(let{V:k}of o){let A=k.twin(H);A&&!k.asBase&&!k.here(A)&&d.add(H)}let y=new Set,N=Symbol(),x=(H,k)=>{if(k>H.remaining)throw N;H.remaining-=k},S=(H,k,A)=>{x(A,1);let J=h.get(H);if(J)return J;if(H.nodeType===1){let Oe=H.firstChild,Ce=1;for(;Oe;){if(x(A,Ce*8+8),Oe.nodeType===3&&x(A,Oe.data.length*8),Oe.nodeType===1&&hn.has(Oe.tagName)&&!i(Oe)&&!s(Oe)&&Oe.firstChild){Oe=Oe.firstChild,Ce++;continue}for(;Oe&&Oe!==H&&!Oe.nextSibling;)Oe=Oe.parentNode,Ce--;Oe=!Oe||Oe===H?null:Oe.nextSibling}}else x(A,H.value.length*8+H.nodes.length);let W=H.nodeType===1?Array.from(H.childNodes):H.nodes,F=W.length===1&&W[0].nodeType===3?{text:W[0].data,nodes:[{node:W[0],s:0,e:W[0].data.length}],atoms:[]}:zt(W,{ignored:i,remoteWins:s});return J={unit:H,flat:F,alignment:k,tokens:null},h.set(H,J),J},O=(H,k)=>{if(H.tokens)return H.tokens;x(k,H.flat.text.length*8);let{unit:A,flat:J,alignment:W}=H,F=[],Oe=dn(J.text),Ce=0,De=pe=>{for(let Te of en(J.text.slice(Ce,pe),Oe))Te.from=Ce,Te.to=Ce+Te.len,Te.unit=A,F.push(Te),Ce+=Te.len};for(let pe of J.atoms){De(pe.i);let Te=s(pe.el)&&pe.el.nodeType===1?"w"+pe.el.tagName+"#"+(pe.el.id||""):l(W?.reverse.get(pe.el)||pe.el);F.push({k:Te,raw:Rn,len:1,from:Ce,to:Ce+1,unit:A,atom:!0}),Ce++}return De(J.text.length),H.tokens=F,F},R=(H,k,A,J,W)=>{if(!H.flat.atoms.length&&!k.flat.atoms.length)return!0;let F=O(H,W),Oe=O(k,W);x(W,F.length+Oe.length);let Ce=0;for(let De of Oe){if(!De.atom||De.from<A||De.from>=A+J)continue;for(;Ce<F.length&&!F[Ce].atom;)Ce++;let pe=F[Ce++];if(!pe||pe.from!==De.from-A||pe.k!==De.k)return!1}for(;Ce<F.length;)if(F[Ce++].atom)return!1;return!0},M=(H,k,A)=>{let J=H.length+k.length+4;if(J*8>A.remaining)return null;A.remaining-=J*8;let W=Math.floor(A.remaining/8),F=Math.min(H.length+k.length,4e3,Math.floor((Math.sqrt(J*J+W)-J)/2)),Oe=4*(F+1)*(J+F+1);if(F<1||Oe>A.remaining)return null;A.remaining-=Oe;let Ce=Wn(H,k,F),De=[],pe=0,Te=0;for(let ze of Ce.hunks){for(;pe<ze.bs;)H[pe].raw===k[Te].raw&&De.push([H[pe],k[Te]]),pe++,Te++;pe=ze.be,Te+=ze.toks.length}for(;pe<H.length&&Te<k.length;)H[pe].raw===k[Te].raw&&De.push([H[pe],k[Te]]),pe++,Te++;return De},j=(H,k,A,J,W,F,Oe)=>{if(W<=J)return;let Ce=H[H.length-1];if(Ce&&Ce.source===k&&Ce.target===A&&Ce.to<=J&&Ce.targetFrom-Ce.from===F-J){x(Oe,(J-Ce.to)*3);let De=h.get(k).flat.text,pe=h.get(A).flat.text,Te=!0;for(let ze=Ce.to;ze<J;ze++)if(!ln.test(De[ze])||De[ze]!==pe[F+ze-J]){Te=!1;break}if(Te){Ce.to=W;return}}H.push({source:k,target:A,from:J,to:W,targetFrom:F})},U=H=>H.replace(Ga,"");for(let H=0;H<o.length;H++){let{V:k,A,idOf:J}=o[H];if(k.asBase)continue;let W=new Map(k.units.map((v,G)=>[v,G])),F=v=>{let G=k.twin(v);return G&&W.has(G)?G:null},Oe=(v,G)=>{let ue=new Int32Array(v.length),ae=new Int32Array(v.length),Pe=-1;for(let He=0;He<v.length;He++)ue[He]=Pe,G(v[He])&&(Pe=He);Pe=v.length;for(let He=v.length-1;He>=0;He--)ae[He]=Pe,G(v[He])&&(Pe=He);return{prev:ue,next:ae}},Ce=Oe(n,v=>(v.nodeType===1||v.kind==="text"&&Pn.test(v.value))&&F(v)),De=Oe(k.units,v=>(v.nodeType===1||v.kind==="text"&&Pn.test(v.value))&&p.has(k.baseOf(v))),pe=new Map,Te=(v,G,ue,ae)=>{if(v>G||ue>ae)return;let Pe=`${v}:${G}:${ue}:${ae}`;pe.set(Pe,[v,G,ue,ae])};for(let v=0;v<k.units.length;v++){let G=k.units[v];if(k.baseOf(G)||!r(G))continue;let ue=De.prev[v],ae=De.next[v],Pe=ue<0?0:f.get(k.baseOf(k.units[ue])),He=ae===k.units.length?n.length-1:f.get(k.baseOf(k.units[ae]));Te(Pe,He,Math.max(0,ue),Math.min(k.units.length-1,ae))}for(let v=0;v<n.length;v++){let G=n[v];if(d.has(G)||!r(G))continue;if(!k.twin(G)){let Ze=Ce.prev[v],Je=Ce.next[v],pt=Ze<0?0:W.get(F(n[Ze])),Xe=Je===n.length?k.units.length-1:W.get(F(n[Je]));Te(Math.max(0,Ze),Math.min(n.length-1,Je),pt,Xe)}let ue=F(G);if(!ue||A.identical.has(G)||!r(ue))continue;let ae=v+1;for(;ae<n.length&&n[ae].kind==="text"&&!n[ae].value.trim();)ae++;if(ae>=n.length||!r(n[ae]))continue;let Pe=F(n[ae]);if(!Pe||A.identical.has(n[ae])||!r(Pe))continue;let He=W.get(ue),ve=W.get(Pe);He<ve&&Te(v,ae,He,ve)}let ze=Array.from(pe.values()),Me=new Set;if(ze.length>1){let v=_t(a);try{x(v,ze.length*4);let G=ze.slice().sort((Pe,He)=>(x(v,1),Pe[0]-He[0]||Pe[2]-He[2])),ue=[],ae=null;for(let Pe of G)x(v,1),ae&&Pe[0]<=ae[1]&&Pe[2]<=ae[3]&&Pe[3]>=ae[2]?(ae[1]=Math.max(ae[1],Pe[1]),ae[2]=Math.min(ae[2],Pe[2]),ae[3]=Math.max(ae[3],Pe[3]),ae[4].push(Pe)):(ae?.[4].length>1&&ue.push(ae),ae=[Pe[0],Pe[1],Pe[2],Pe[3],[Pe]]);ae?.[4].length>1&&ue.push(ae),ze=ue.concat(ze)}catch(G){if(G!==N)throw G}}for(let v of ze){if(Me.has(v))continue;let[G,ue,ae,Pe,He]=v,ve=_t(a),Ze=[],Je=new Set,pt=!1;try{x(ve,(ue-G+Pe-ae+2)*4);let Xe=n.slice(G,ue+1).filter(B=>!A.identical.has(B)&&r(B)&&!d.has(B)),dt=k.units.slice(ae,Pe+1).filter(B=>r(B)&&(!k.baseOf(B)||p.has(k.baseOf(B)))&&!A.identical.has(k.baseOf(B))&&!d.has(k.baseOf(B))),St=new Set(dt),vt=!1,bt="",At="",Ot=0;for(let B of Xe){let me=S(B,null,ve);bt+=me.flat.text,Ot+=me.flat.text.length}for(let B of dt){let me=S(B,A,ve);At+=me.flat.text,Ot+=me.flat.text.length}x(ve,Ot);let Bt=U(bt),tn=U(At),Nt=Bt===tn;if(pt=Nt,He&&!Nt)continue;let $t=Nt?null:new Map;if($t)for(let B of Xe.concat(dt)){let me=h.get(B).flat.text.length;x(ve,me*16),$t.set(B,new Uint8Array(me))}let cn=B=>{let me=[];for(let xe of B){let fe=h.get(xe);fe.flat.atoms.length?me.push(...O(fe,ve)):me.push({unit:xe,raw:fe.flat.text,from:0})}return me},Pt=[];for(let B of Nt?[]:Xe){let me=F(B);if(!St.has(me))continue;let xe=S(B,null,ve),fe=S(me,A,ve);x(ve,xe.flat.text.length+fe.flat.text.length);let Se=xe.flat.text&&fe.flat.text.startsWith(xe.flat.text)?0:xe.flat.text&&fe.flat.text.endsWith(xe.flat.text)?fe.flat.text.length-xe.flat.text.length:-1;if(Se>=0&&R(xe,fe,Se,xe.flat.text.length,ve)){$t.get(B).fill(1),$t.get(me).fill(1,Se,Se+xe.flat.text.length),j(Pt,B,me,0,xe.flat.text.length,Se,ve);continue}let V=M(O(xe,ve),O(fe,ve),ve);if(!V){vt=!0;break}for(let[Z,be]of V)$t.get(B).fill(1,Z.from,Z.to),$t.get(me).fill(1,be.from,be.to),j(Pt,B,me,Z.from,Z.to,be.from,ve)}if(vt)continue;let Jt=null,Ft=null;if(!Nt)for(let B of Xe){let me=F(B),xe=h.get(B);if(!me||xe.flat.atoms.length||!St.has(me))continue;let fe=xe.flat.text,Se=$t.get(B);x(ve,fe.length*3+dt.length);let V=-1,Z=-1,be=!1;for(let je=0;je<fe.length;je++)ln.test(fe[je])||(Se[je]?be=!0:(V<0&&(V=je),Z=je+1));if(!be||V<0)continue;let ke=!0;for(let je=V;je<Z;je++)if(Se[je]&&!ln.test(fe[je])){ke=!1;break}if(!ke)continue;let we=U(fe.slice(V,Z)),te=null,re=!1;for(let je of dt){if(k.baseOf(je))continue;let Ae=h.get(je);if(!Ae.flat.atoms.length&&(x(ve,Ae.flat.text.length),U(Ae.flat.text)===we)){if(te){re=!0;break}te=je}}if(re){(Ft||=new Set).add(B);continue}if(!te||Ft?.has(B))continue;let q=!1;for(let je of Xe){if(je===B||!St.has(F(je)))continue;let Ae=h.get(je);if(Ae.flat.atoms.length)continue;let Ge=$t.get(je);x(ve,Ae.flat.text.length*3);let et="",Qe=!1;for(let Ut=0;Ut<Ae.flat.text.length;Ut++)ln.test(Ae.flat.text[Ut])||(Ge[Ut]?Qe=!0:et+=Ae.flat.text[Ut]);Qe&&et===we&&(Ft||=new Set,Ft.add(B),Ft.add(je),q=!0)}if(q)continue;let le=h.get(te).flat.text;x(ve,Z-V+le.length);let Ne=V,Le=0;for(;Ne<Z&&Le<le.length;){for(;Ne<Z&&ln.test(fe[Ne]);)Ne++;for(;Le<le.length&&ln.test(le[Le]);)Le++;if(Ne>=Z||Le>=le.length)break;j(Jt||=[],B,te,Ne,Ne+1,Le,ve),Ne++,Le++}Se.fill(1,V,Z),$t.get(te).fill(1)}let nn=B=>{let me=[];for(let xe of B){let fe=S(xe,p.has(xe)?null:A,ve),Se=$t.get(xe);for(let V of O(fe,ve)){let Z=V.from;for(;Z<V.to;){for(;Z<V.to&&Se[Z];)Z++;let be=Z;for(;Z<V.to&&!Se[Z];)Z++;if(Z>be){let ke=fe.flat.text.slice(be,Z);Pn.test(ke)&&me.push({...V,raw:ke,len:Z-be,k:V.atom?V.k:ke,from:be,to:Z})}}}}return me},X=Nt?cn(Xe):nn(Xe),m=Nt?cn(dt):nn(dt),I=Nt?Bt:X.map(B=>U(B.raw)).join(""),P=Nt?tn:m.map(B=>U(B.raw)).join("");if((!I||!P)&&!Jt)continue;let $=Jt||[];if(I&&P&&I===P){let B=0,me=0,xe=0,fe=0;for(;B<X.length&&me<m.length;){let Se=X[B],V=m[me];for(;xe<Se.raw.length&&ln.test(Se.raw[xe]);)xe++;for(;fe<V.raw.length&&ln.test(V.raw[fe]);)fe++;if(xe===Se.raw.length){B++,xe=0;continue}if(fe===V.raw.length){me++,fe=0;continue}if((Se.atom||V.atom)&&Se.k!==V.k){vt=!0;break}j($,Se.unit,V.unit,Se.from+xe,Se.from+xe+1,V.from+fe,ve),xe++,fe++}}else if(I&&P){let B=M(X,m,ve);if(!B)continue;for(let[me,xe]of B)j($,me.unit,xe.unit,me.from,me.to,xe.from,ve)}if(vt)continue;let Q=new Map;for(let B of $)if(!Ft?.has(B.source)){if(F(B.source)===B.target){Nt&&Pt.push(B);continue}Q.has(B.source)||Q.set(B.source,[]),Q.get(B.source).push(B)}for(let[B,me]of Q){let xe=S(B,null,ve),fe=F(B),Se=xe.flat.text,V=[],Z=new Set,be=o[1-H],ke=be.V.twin(B),we=ke&&be.V.here(ke)?S(ke,be.A,ve):null,te=(Ae,Ge)=>{let et=O(Ae,ve),Qe=O(Ge,ve);return x(ve,Ae.flat.text.length+Ge.flat.text.length+et.length+Qe.length),Ae.flat.text===Ge.flat.text&&et.length===Qe.length&&et.every((Ut,Mt)=>Ut.k===Qe[Mt].k)},re=fe&&we&&we.flat.text!==Se&&te(S(fe,A,ve),we);for(let Ae of new Set(me.map(Ge=>Ge.target))){if(B.nodeType!==1&&Ae.nodeType!==1)continue;let Ge=S(Ae,A,ve),et=k.baseOf(Ae);if(B.nodeType!==1&&et||(x(ve,Se.length*2+Ge.flat.text.length*3+Pt.length*2),fe&&U(Se)===U(Ge.flat.text)&&S(fe,A,ve).flat.text.trim()))continue;if(!fe&&!et&&B.nodeType===1&&Ae.nodeType===1){let Lt=c(B),Wt=J(Ae);if(Lt&&Wt&&Lt!==Wt)continue}let Qe=Ge.flat.text,Ut=Se&&(Qe.startsWith(Se)||Qe.endsWith(Se)),Mt=!1;if(!fe&&we&&et&&we.flat.text!==Se){let Lt=S(et,null,ve).flat.text,Wt=f.get(B)<f.get(et)?we.flat.text:Lt,C=f.get(B)<f.get(et)?Lt:we.flat.text;x(ve,Wt.length+C.length+Qe.length),Mt=!!Wt&&!!C&&Wt.length+C.length<=Qe.length&&Qe.startsWith(Wt)&&Qe.endsWith(C)&&!Qe.slice(Wt.length,Qe.length-C.length).trim()}let Kt=!xe.flat.atoms.length&&!we?.flat.atoms.length&&!Ge.flat.atoms.length&&(re&&Ut||Mt);if(fe&&et){let Lt=S(fe,A,ve).flat.text,Wt=Se.startsWith(Lt)||Se.endsWith(Lt),C=S(et,null,ve).flat.text,Y=Ge.flat.text,ce=Y.startsWith(C)||Y.endsWith(C),de=!o[1-H].V.twin(et)&&!Pt.some(ie=>ie.source===et&&Pn.test(C.slice(ie.from,ie.to)));if(!Nt&&(!Wt&&!Kt||!ce&&!de)){let ie=Ja(B,Ae,me,Xe,dt,h,$t,O,x,ve);if(!ie)continue;let ee=A.weak?.has(B)&&!A.identityPaired?.has(B)&&Se.trim()===ie;if(!Wt&&!Kt&&!ee)continue;let se=A.weak?.has(et)&&!A.identityPaired?.has(et)&&Qe.trim()===ie&&!h.get(et).flat.atoms.length&&!Pt.some(Ee=>Ee.source===et&&Pn.test(C.slice(Ee.from,Ee.to)));if(!ce&&!de&&!se&&!Za(et,Ae,C,Qe,Pt,O(Ge,ve),x,ve))continue;ee&&Z.add(Ae)}}Kt&&Z.add(Ae),x(ve,me.length),V.push(...me.filter(Lt=>Lt.target===Ae))}if(!V.length)continue;let q=new Uint8Array(Se.length);x(ve,Se.length*4+Pt.length);for(let Ae of V)q.fill(1,Ae.from,Ae.to);let le=[];for(let Ae=0;Ae<Se.length;Ae++)ln.test(Se[Ae])||le.push(Ae);if(!le.length)continue;let Ne=new Set(V.map(Ae=>Ae.target));if(!Nt&&fe&&Ne.size>1&&Xa(Ne,$,Pt,k,h,ve,x)){if(g||=new Map,g.set(B,(g.get(B)||0)|1<<H),e){let Ae=ks({source:B,side:H,views:o,eligible:r,blocked:d,baseId:c,model:S,tokensOf:O,budget:ve,charge:x});if(Ae){x(ve,Ae.to-Ae.from);let Ge=!0;for(let et=Ae.from;et<Ae.to;et++)if(Pn.test(Se[et])&&!q[et]){Ge=!1;break}Ge&&(b||=[]).push(Ae)}}continue}let Le=le.filter(Ae=>Ls.test(Se[Ae]));if(!V.some(Ae=>Ls.test(Se.slice(Ae.from,Ae.to)))&&!le.every(Ae=>q[Ae]))continue;if(!fe&&!Array.from(Ne).some(Ae=>Z.has(Ae))&&!le.every(Ae=>q[Ae])&&!(Le.length&&q[Le[0]]&&q[Le[Le.length-1]]&&Ne.size===1)){let Ae=null,Ge=0,et=0,Qe=null,Ut=null;if(!fe&&we&&B.nodeType===1&&!xe.flat.atoms.length){let Mt=O(xe,ve).filter(Kt=>Ls.test(Kt.raw));x(ve,dt.length+Se.length);for(let Kt of dt){let Lt=k.baseOf(Kt);if(!Lt||Lt===B||Lt.nodeType!==1||Kt.nodeType!==1||Lt.tagName!==B.tagName||Kt.tagName!==Lt.tagName)continue;let Wt=f.get(B),C=f.get(Lt),Y=!0;for(let Fe=Math.min(Wt,C)+1;Fe<Math.max(Wt,C);Fe++){let tt=n[Fe];if(x(ve,tt.nodeType===1?1:tt.value.length+1),tt.nodeType===1||tt.value.trim()){Y=!1;break}}if(!Y)continue;let ce=S(Lt,null,ve),de=S(Kt,A,ve);if(ce.flat.atoms.length||de.flat.atoms.length)continue;let ie=ce.flat.text,ee=de.flat.text;if(x(ve,ie.length+ee.length+Se.length),!ie||!Mt.length)continue;let se=0,Ee=ee.length;if(Wt<C&&ee.endsWith(ie))Ee-=ie.length;else if(Wt>C&&ee.startsWith(ie))se=ie.length;else continue;for(;se<Ee&&ln.test(ee[se]);)se++;for(;Ee>se&&ln.test(ee[Ee-1]);)Ee--;let We=ee.slice(se,Ee);if(!(!We||!(We.startsWith(Mt[0].raw)||We.endsWith(Mt[Mt.length-1].raw)))){if(Ae){Ae=null;break}Ae=Kt,Ge=se,et=Ee,Qe=Mt[0],Ut=Mt[Mt.length-1]}}}if(x(ve,V.length),!Ae||!Ne.has(Ae)||!V.some(Mt=>Mt.target===Ae&&(Mt.from<=Qe.from&&Mt.to>=Qe.to&&Mt.targetFrom+Qe.from-Mt.from===Ge||Mt.from<=Ut.from&&Mt.to>=Ut.to&&Mt.targetFrom+Ut.to-Mt.from===et)))continue}if(fe&&!(le.every(Ae=>q[Ae])&&(Nt||Array.from(Ne).some(Ae=>Z.has(Ae))))&&!Pt.some(Ae=>Ae.source===B&&Pn.test(Se.slice(Ae.from,Ae.to))))continue;let je=!1;if(Nt){x(ve,Pt.length+le.length);for(let Ae of Pt)Ae.source===B&&(x(ve,Ae.to-Ae.from),q.fill(1,Ae.from,Ae.to));je=!0;for(let Ae of le)if(!q[Ae]){je=!1;break}}for(let Ae of Ne){x(ve,V.length);let Ge=V.filter(Qe=>Qe.target===Ae);Ze.push({side:H,source:B,target:Ae,runs:Ge,models:h,retained:Pt,conservedSource:je}),B.nodeType===1&&Je.add(B),Ae.nodeType===1&&Je.add(Ae);let et=k.baseOf(Ae);et?.nodeType===1&&Je.add(et)}}if(w.push(...Ze),He&&Ze.length)for(let B of He)Me.add(B);for(let B of Je)y.add(B)}catch(Xe){if(Xe!==N)throw Xe}finally{if(t&&!He&&!pt){let Xe=bl({base:n,views:o,side:H,attempt:v,eligible:r,blocked:d,baseId:c,model:S,tokensOf:O,charge:x,exhausted:N,limit:a});Xe&&(T||=[]).push(...Xe)}if(e&&!He&&!pt){let Xe=Ri({base:n,views:o,side:H,attempt:v,eligible:r,blocked:d,baseId:c,model:S,tokensOf:O,certificates:w,charge:x,exhausted:N,limit:a});Xe&&(b||=[]).push(...Xe)}}}}let K=w.length?new Map:null;for(let H of w){let k=K.get(H.source);k||K.set(H.source,k=[]),k.push(H)}let _=null;if(K){let H=null;for(let[k,A]of K){let J=g?.get(k)||0;if(A.length<2&&!J)continue;let W=0;for(let F of A)F.conservedSource&&(W|=1<<F.side);for(let F of A){if(F.conservedSource)continue;let Oe=1<<F.side,Ce=!0;if(W&Oe)Ce=!1;else if(J&Oe){Ce=!1;try{Ce=Ya(F,H||=_t(a),x)}catch(De){if(De!==N)throw De}}Ce||(_||=new Set).add(F)}}}if(_){let H=0;for(let k of w)_.has(k)||(w[H++]=k);w.length=H;for(let[k,A]of K){H=0;for(let J of A)_.has(J)||(A[H++]=J);A.length=H,H||K.delete(k)}y.clear();for(let k of w){let{source:A,target:J,side:W}=k;A.nodeType===1&&y.add(A),J.nodeType===1&&y.add(J);let F=o[W].V.baseOf(J);F?.nodeType===1&&y.add(F)}}if(b){let H=_t(a),k=!1;for(let A of b){let J=!1,W=K?.get(A.source);if(W&&!k)try{J=xs(A,W,H,x)}catch(F){if(F!==N)throw F;k=!0}J||e(A)}}if(T){let H=new Set,k=_t(a);try{for(let A of T){if(x(k,1),H.has(A.source))continue;H.add(A.source);let J=!1;for(let W of w)if(x(k,1),W.source===A.source||W.target===A.local||W.target===A.remote){J=!0;break}J||t(A)}}catch(A){if(A!==N)throw A}}for(let H of n)if(y.has(H))for(let{V:k}of o){let A=k.twin(H);A&&k.here(A)&&y.add(A)}return w.length?{blocks:y,certificates:w,certificatesBySource:K,models:h}:null}function xl({certificates:e,scopes:t,flats:n,keys:o,limit:r=2e4*32}){let i=Symbol(),s=_t(r),c=g=>{if(g>s.remaining)throw i;s.remaining-=g},l=t.map(g=>new Set(g)),a=new Map,p=new Map,f=(g,d)=>{let y=a.get(g);if(y||a.set(g,y=new Map),y.has(d))return y.get(d);c(g.text.length);let N=p.get(d);if(!N){c(d.nodes.length+d.atoms.length),N={nodes:new Map,atoms:new Map};for(let R of d.nodes)N.nodes.set(R.node,R);for(let R of d.atoms)N.atoms.set(R.el,R.i);p.set(d,N)}let{nodes:x,atoms:S}=N,O=new Int32Array(g.text.length).fill(-1);for(let R of g.nodes){let M=x.get(R.node);if(!(!M||R.e-R.s!==M.e-M.s)){c(R.e-R.s);for(let j=R.s;j<R.e;j++)O[j]=M.s+j-R.s}}for(let R of g.atoms){let M=S.get(R.el);M!==void 0&&(O[R.i]=M)}return y.set(d,O),O},h=(g,d,y,N,x)=>{let S=g[g.length-1];S&&S.to===d&&S.target+S.to-S.from===N&&S.kind===x?S.to=y:g.push({from:d,to:y,target:N,kind:x})},w=(g,d,y,N)=>{c((N-y)*4);let x=[],S=y,O=j=>{let U=g.text.slice(S,j);for(let K of en(U,dn(U)))K.from=S,K.to=S+K.len,x.push(K),S+=K.len},R=0,M=g.atoms.length;for(;R<M;){c(1);let j=R+M>>>1;g.atoms[j].i<y?R=j+1:M=j}for(let j=R;j<g.atoms.length&&g.atoms[j].i<N;j++){c(1);let U=g.atoms[j];O(U.i),x.push({k:d(U),raw:Rn,len:1,from:S,to:S+1}),S++}return O(N),x},b=(g,d,y,N,x,S)=>{if(y===N||x===S)return;if(N-y===S-x){c((N-y)*4);let k=!0;for(let A=y,J=x;A<N;A++,J++){if(n[0].text[A]!==n[d].text[J]){k=!1;break}let W=n[0].atomAt.get(A),F=n[d].atomAt.get(J);if(!!W!=!!F||W&&o[0](W)!==o[d](F)){k=!1;break}}if(k){h(g,y,N,x,"retained");return}}let O=w(n[0],o[0],y,N),R=w(n[d],o[d],x,S),M=O.length+R.length+4,j=Math.min(O.length+R.length,4e3,Math.floor((Math.sqrt(M*M+s.remaining/2)-M)/2));if(j<1)throw i;c(4*(j+1)*(M+j+1));let U=Wn(O,R,j),K=0,_=0,H=()=>{let k=O[K++],A=R[_++];c(k.len),k.raw===A.raw&&h(g,k.from,k.to,A.from,"retained")};for(let k of U.hunks){for(;K<k.bs;)H();K=k.be,_+=k.toks.length}for(;K<O.length&&_<R.length;)H()},T=g=>{let d=e.filter(U=>U.side===g-1&&l[0].has(U.source)&&l[g].has(U.target));if(!d.length)return null;let y=[],N=(U,K,_)=>{if(!l[0].has(U.source)||!l[g].has(U.target))return;let H=f(K.get(U.source).flat,n[0]),k=f(K.get(U.target).flat,n[g]);c(U.to-U.from);for(let A=0;A<U.to-U.from;A++){let J=H[U.from+A],W=k[U.targetFrom+A];if(J<0||W<0)throw i;h(y,J,J+1,W,_)}},x=new Set;for(let U of d){if(!x.has(U.retained)){x.add(U.retained);for(let K of U.retained)N(K,U.models,"retained")}for(let K of U.runs)N(K,U.models,"transfer")}y.sort((U,K)=>(c(1),U.from-K.from||U.target-K.target));let S=[];for(let U of y){c(1);let K=S[S.length-1];if(K&&U.from<K.to){if(U.target-U.from!==K.target-K.from)throw i;K.to=Math.max(K.to,U.to),U.kind==="transfer"&&(K.kind="transfer")}else S.push(U)}let O=[],R=0,M=0;for(let U of S){if(U.target<M)throw i;b(O,g,R,U.from,M,U.target),O.push(U),R=U.to,M=U.target+U.to-U.from}b(O,g,R,n[0].text.length,M,n[g].text.length);let j=Cn({base:n[0],side:n[g],retained:O.filter(U=>U.kind==="retained"),transfers:O.filter(U=>U.kind==="transfer"),baseAtomKey:o[0],sideAtomKey:o[g],budget:s});if(j.status!=="ready"||!j.monotone)throw i;return j};try{let g=T(1),d=T(2);return g||d?{local:g,remote:d}:{fallback:!0}}catch(g){if(g!==i)throw g;return{fallback:!0}}}function Ps(e,t,n=!1){let o=-1,r=-1;for(let s=0;s<e.list.length;s++){let c=e.list[s];c.bLo<t.lo||c.bLo>t.hi||(o<0&&(o=s),r=s)}let i=[];for(let s=o;s>=0&&s<=r;s++){let c=e.list[s],l=!n&&s===o?c.inlineStart<0?c.to:c.inlineStart:c.from,a=!n&&s===r?c.inlineEnd<0?c.from:c.inlineEnd:c.to;for(let p=l;p<a;p++)i.push(e.units[p]);s<r&&i.push(e.units[c.next])}return i}var ot=e=>!!e&&e.nodeType===1,Hr=e=>ot(e)?e.getAttribute("data-id")||e.textContent||"":e.value!==void 0?e.value:e.nodeValue||"",Sn=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function js(e){for(let t of e)if(Sn.has(t.tagName))return!0;return!1}function Qa(e,t,n){let o=null;for(let r of t.childNodes)if(!(!ot(r)||!n(r)||!r.isEqualNode(e))){if(o)return null;o=r}if(!o)return null;for(let r of e.parentNode.childNodes)if(r!==e&&r.isEqualNode(e))return null;return o}var er="[id],[data-id],script,head>*";function Bs(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let o=Mo(n,e);if(o)return"merge:"+o.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?ol(n,t):null}}function Vr(e,t,n,o){let r=o.ignored,i=o.stats||Gn(),s=Oi({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:i}),{unitsOf:c,meta:l}=s,a=o.baseURI,p=o.mergeTags!==null,f=Bs(o.mergeTags,a),h=C=>Y=>{let ce=f(Y);return ce!==null?ce:C(Y)},w=h(o.identity.base),b=h(o.identity.local),T=h(o.identity.remote),g=o.authored||o.identity,d=C=>C&&C.nodeType===9?C.documentElement:C,y=d(e),N=d(t),x=d(n),S=globalThis.__hyperMorphProfile,O=S?performance.now():0,R=C=>C===un?er:null,M=o.scope||null,j=M?M.baseDropped:new Set,U=new Set,K=M?M.remoteDropped:new Set,_=M?M.baseIndex:Or(y,w,r,R(o.identity.base),j),H=o.localIsBase||y===N?null:Or(N,b,r,R(o.identity.local),U),k=M?M.remoteIndex:Or(x,T,r,R(o.identity.remote),K),A=C=>{let Y=ot(C)&&b(C);return Y&&H?.get(Y)===C&&!_.has(Y)?Y:null},J=C=>{let Y=ot(C)&&T(C);return Y&&k.get(Y)===C&&!_.has(Y)?Y:null},W=H?us(y,N,{analyzer:s,baseIndex:_,sideIndex:H,baseId:g.base,sideId:g.local,baseKey:w,sideKey:b,baseDropped:j,sideDropped:U,stats:i}):Tl(),F=us(y,x,{analyzer:s,baseIndex:_,sideIndex:k,baseId:g.base,sideId:g.remote,baseKey:w,sideKey:T,baseDropped:j,sideDropped:K,stats:i,scope:M,comparisons:o.comparisons});if(M){if(!M.held(F))return null;for(let C of M.dropped)as(C)}let Oe=null;function Ce(C){if(!Oe){Oe=new WeakMap;let Y=[y];for(;Y.length;){let ce=Y.pop();ce.tagName==="TEMPLATE"&&ce.content&&Oe.set(ce.content,ce);for(let de of s.childrenOf(ce))de.nodeType===1&&Y.push(de)}}return Oe.get(C)||null}let De=C=>{let Y=ot(C)||C.nodeType?C.parentNode:C.parent;return Y&&Y.nodeType===11?Ce(Y):Y};if(F.moved.size){let C=!1;for(let Y of Array.from(F.moved))!ot(Y)||F.identityPaired.has(Y)||!g.base(Y)||m(F,De(Y))||(F.unpair(Y),C=!0);C&&F.rematch()}nn(),X(W,F),X(F,W);for(let C of[W,F])if(C.refused)for(let Y of C.refused)C.moved.has(Y)||i.ambiguousMoves++;S&&(S.alignTotal=(S.alignTotal||0)+(performance.now()-O),O=performance.now());let pe=y.ownerDocument.implementation.createHTMLDocument(""),Te=new WeakMap,ze=new WeakMap,Me=[],v=[],G=new Set,ue=[],ae=new Set,Pe=new Set,He=new Set,ve=new WeakMap,Ze=null,Je=o.lineage?.locals.length?qi():null,pt=C=>{let Y=Rr(C);return Y&&Je&&Je.consume(C.local),Y},Xe=o.conflicts||"remote",dt=C=>Me.push(C),St=C=>Me.push(C),vt=ul({roots:{base:y,local:N,remote:x},L:W,R:F,unitsOf:c,provenance:Te,policy:Xe}),bt=(C,Y)=>{v.push(C),Y&&vt.note(C,Y)},At=null,Ot=null,Bt=Jt(),tn=null,Nt=B(y,W.map.get(y),F.map.get(y),!!o.localIsBase,!!o.childrenOnly);Nt.tagName==="HTML"?pe.replaceChild(Nt,pe.documentElement):pe.body.appendChild(Nt),At?.drain(Nt),Ot?.drain(Nt),S&&(S.build=(S.build||0)+(performance.now()-O));let $t=o.childrenOnly?!et(Ae(Nt),Ae(x)):!Ne(Nt,x),cn=vt.finish(Nt),Pt=Je?Ki({locals:o.lineage.locals,rec:Je,root:Nt,provenance:Te,segments:ue,ignored:r}):null;return{doc:pe,root:Nt,provenance:Te,textMappers:ze,decisions:Me,conflicts:v,recoveryLinks:cn,localDiverged:$t,mergedScripts:G,segments:ue,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==un,L:W,R:F,stats:i,lineage:Pt};function Jt(){let C=new Map,Y=new Set;if(o.localIsBase||!W.insertedByHash)return{partner:C,drop:Y};let ce=W.insertedByHash(),de=F.insertedByHash();if(!ce.size||!de.size)return{partner:C,drop:Y};let ie={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},ee=$e=>{let mt=0;for(let Tt=$e.parentNode;Tt;Tt=Tt.parentNode)mt++;return mt},se=[],Ee=$e=>{let mt=$e.textContent.trim();return mt.split(/\s+/).length>=3||mt.replace(/\s/g,"").length>=12},We=$e=>{let mt=m(W,$e),Tt=m(F,$e);return mt&&W.reverse.get(mt.parentNode)!==$e.parentNode||Tt&&F.reverse.get(Tt.parentNode)!==$e.parentNode},Fe=($e,mt,Tt)=>{for(let It of Tt.parentNode.children){let xn=It!==Tt&&$e.reverse.get(It);if(xn&&We(xn))return!0}let Dt=$e.reverse.get(Tt.parentNode);if(Dt){for(let It of Dt.children)if(!m(mt,It)&&!r(It))return!0}return!1},tt=new Map([[W,new Map],[F,new Map]]),st=($e,mt)=>{let Tt=tt.get($e),Dt=Tt.get(mt);if(Dt===void 0){Dt=!1;for(let It of mt.children)if($e.reverse.has(It)||st($e,It)){Dt=!0;break}Tt.set(mt,Dt)}return Dt},it=new Map;for(let $e of de.values())for(let mt of $e){let Tt=J(mt);Tt&&it.set(Tt,mt)}for(let $e of ce.values())for(let mt of $e){let Tt=A(mt),Dt=Tt?it.get(Tt):null;Dt&&Dt.tagName===mt.tagName&&!Ln(mt,ie)&&!Ln(Dt,ie)&&!o.remoteWins(mt)&&!o.remoteWins(Dt)&&se.push([mt,[Dt],ee(mt),!0,!0])}for(let[$e,mt]of ce){let Tt=de.get($e);if(!Tt)continue;let Dt=mt.length===1&&Tt.length===1;for(let It of mt)!Ln(It,ie)&&!A(It)&&se.push([It,Tt,ee(It),Dt&&(Ee(It)||Fe(W,F,It)||Fe(F,W,Tt[0]))])}if(!se.length)return{partner:C,drop:Y};se.sort(($e,mt)=>$e[2]-mt[2]);let rt=new Set,kt=new Set,xt=$e=>{for(let mt of $e.querySelectorAll("*"))rt.add(mt)},Et=($e,mt)=>$e.reverse.get(mt.parentNode)||null;for(let[$e,mt,,Tt,Dt]of se){if(rt.has($e)||kt.has($e)||Dt&&(st(W,$e)||st(F,mt[0])))continue;let It=Et(W,$e),xn=an=>!kt.has(an)&&!rt.has(an)&&(Dt||an.tagName===$e.tagName&&!J(an)&&s.equalUnits($e,an)),Zt=mt.find(an=>It&&Et(F,an)===It&&xn(an))||(Tt?mt.find(xn):null);if(!Zt)continue;kt.add($e),kt.add(Zt);let Fn=It&&Et(F,Zt)===It;(!Dt||!Fn||s.equalUnits($e,Zt))&&(xt($e),xt(Zt)),!Fn&&(C.set($e,Zt),C.set(Zt,$e),Y.add(Xe==="local"?Zt:$e))}return{partner:C,drop:Y}}function Ft(C,Y,ce){if(ae.add(C),Bt.drop.has(C))return null;ae.add(ce);let de=Y==="local"?C:ce,ie=Y==="local"?ce:C,ee;return s.equalUnits(de,ie)?(ee=q(de,"local",!0),Te.get(ee).remote=ie):ee=re(de,ie),bt({kind:"structure",el:ee,detail:"both-moved",base:null,local:de,remote:ie},{unit:{b:null,l:de,r:ie}}),dt({kind:"insert",el:ee,source:"both"}),ee}function nn(){if(!W.weak||!F.weak||!W.weak.size||!F.weak.size||!W.unpair)return;let C=new Map;for(let ce of W.weak){let de=m(W,ce);ot(ce)&&ot(de)&&C.set(s.unitHash(de),ce)}let Y=!1;for(let ce of Array.from(F.weak)){let de=m(F,ce);if(!ot(ce)||!ot(de))continue;let ie=C.get(s.unitHash(de));if(!ie||ie===ce||!W.weak.has(ie)||m(W,ce)&&m(F,ie))continue;let ee=m(W,ie);ee.tagName===de.tagName&&s.equalUnits(ee,de)&&(W.unpair(ie),F.unpair(ce),Y=!0)}Y&&(W.rematch(),F.rematch())}function X(C,Y){if(!C.weak||!C.weak.size||!Y.insertedByHash)return;let ce=Y.insertedByHash();if(!ce.size)return;let de=!1;for(let ie of Array.from(C.weak)){let ee=m(C,ie);if(!ee)continue;let se=C===W?A(ee):J(ee);if(se){let We=(C===W?k:H)?.get(se);We&&We.tagName===ee.tagName&&!Y.reverse.has(We)&&(C.unpair(ie),de=!0);continue}let Ee=ce.get(s.unitHash(ee));Ee&&Ee.some(We=>We.tagName===ee.tagName&&s.equalUnits(We,ee))&&(C.unpair(ie),de=!0)}de&&C.rematch()}function m(C,Y){if(!Y)return null;if(C.map.has(Y))return C.map.get(Y);let ce=[],de=De(Y);for(;de&&!C.map.has(de);de=De(de))ce.push(de);let ie=de;if(!ie||!C.identical.has(ie))return null;C.pairIdenticalChildren(ie);for(let se=ce.length-1;se>=0;se--)C.pairIdenticalChildren(ce[se]);let ee=C.map.get(Y)||null;return ee&&i.lazyTwins++,ee}function I(C,Y,ce,de){if(ot(C)&&Sn.has(C.tagName)&&!W.identical.has(C)&&(C.previousSibling?.nodeType===3||C.nextSibling?.nodeType===3)){let Ee=De(C),We=m(W,C),Fe=m(F,C);We&&Fe&&Lt(We,m(W,Ee),W)&&!Lt(Fe,m(F,Ee),F)&&(Ot||=pl({L:W,R:F,twinIn:m,unitsOf:c,view:P,parentOf:De,ignored:r,remoteWins:o.remoteWins,eligible:tt=>ot(tt)&&Sn.has(tt.tagName),build:B,out:pe,policy:Xe,provenance:Te,textMappers:ze,segments:ue,conflicts:v,conflict:bt,decisions:Me}),Ot.ensureOwner(C))}if(Y===null)return null;if(de!==void 0)return At||=Co(Te,De,W,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(C,Y,ce,!!de),de&&(At.produced(C,de),Pe.add(C)),de;if(Pe.has(C)||He.has(C))return bt({kind:"structure",el:null,detail:"both-moved",base:C},{subject:C}),Pe.has(C)?null:q(ce,Y);At||=Co(Te,De,W,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(C,Y,ce,!0);let ie=m(W,C),ee=m(F,C);(!ie||!ee)&&bt({kind:"structure",el:null,detail:"move-beats-delete",base:C},{subject:C,deleted:ie?"remote":"local"});let se=B(C,ie,ee,!1);return(Y==="local"?dt:St)({kind:"move",el:se,source:Y}),se}function P(C,Y,ce,de){return de||!Y||Y===ce?{el:ce,asBase:!0,twin:ie=>ie,baseOf:ie=>ie,units:c(ce),here:()=>!0,parentOfTwin:()=>ce}:{el:Y,asBase:!1,twin:ie=>m(C,ie),baseOf:ie=>C.reverse.get(ie),units:c(Y),here:ie=>ot(ie)?ie.parentNode===Y||Y.tagName==="TEMPLATE"&&ie.parentNode===Y.content:ie.parent===Y||Y.tagName==="TEMPLATE"&&ie.parent===Y.content}}function $(C,Y,ce){return!Y||ce&&ce.identical.has(C)?!1:ot(C)?!s.equalUnits(C,Y)||!Q(C,Y,ce):C.value!==Y.value}function Q(C,Y,ce){if(!ce||C===Y)return!0;let de=[[C,Y]];for(;de.length;){let[ie,ee]=de.pop(),se=c(ie),Ee=c(ee);for(let We=0;We<se.length&&We<Ee.length;We++){let Fe=se[We],tt=Ee[We];if(!ot(Fe)||!ot(tt))continue;let st=ce.map.get(Fe);if(st!==void 0&&st!==tt)return!1;let it=ce.reverse.get(tt);if(it!==void 0&&it!==Fe)return!1;de.push([Fe,tt])}}return!0}function B(C,Y,ce,de,ie=!1){let ee=de||(ce?o.remoteWins(ce):o.remoteWins(C)),se=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?pe.createElementNS(C.namespaceURI,C.tagName):pe.createElement(C.tagName),Ee={base:C,local:Y||null,remote:ce||null};if(Te.set(se,Ee),ee&&!de&&Y&&$(C,Y,W)&&(!ce||!s.equalUnits(Y,ce))&&bt({kind:"structure",el:se,detail:"remote-wins",base:C,local:Y,remote:ce||null},{subject:C}),ae.add(C),Pe.add(C),Y&&ae.add(Y),ce&&ae.add(ce),o.skipUnchanged&&!ie&&(o.localIsBase||W.identical.has(C))&&ce&&F.identical.has(C)&&!o.remoteWins(C)){Ee.unchanged=!0;for(let Fe of C.attributes)Fe.namespaceURI?se.setAttributeNS(Fe.namespaceURI,Fe.name,Fe.value):se.setAttribute(Fe.name,Fe.value);return At?.produced(C,se),se}He.add(C),ie||Se(C,ee?C:Y,ce,se);let We=C.tagName;if(rn(C))fe(C,ee?C:Y,ce,se);else if(We==="TEXTAREA"){let Fe=ee?C:Y,tt=C.textContent,st=Fe?Fe.textContent:tt,it=ce?ce.textContent:tt,rt=me(C);if(rt&&st!==tt&&it!==tt){let kt=ke(rt,me(Fe),me(ce),ee);kt&&se.appendChild(kt)}else se.textContent=xe(tt,st,it,se,"text")}else if(!Ot?.render(C,se)){let Fe=le(C,Y,ce,ee,se),tt=We==="TEMPLATE"&&se.content?se.content:se;for(let st of Fe)tt.appendChild(st)}return He.delete(C),At?.produced(C,se),se}function me(C){if(!C)return null;let Y=c(C)[0];return Y&&!ot(Y)&&Y.kind==="text"?Y:null}function xe(C,Y,ce,de,ie){if(Y===ce)return Y;if(Y===C)return ce!==C&&St({kind:ie,node:de,source:"remote"}),ce;if(ce===C)return dt({kind:ie,node:de,source:"local"}),Y;let ee=Xe==="local"?Y:ce;return bt({kind:ie,node:de,base:C,local:Y,remote:ce,resolved:ee},{site:"whole",el:de}),Me.push({kind:ie,node:de,source:"both"}),ee}function fe(C,Y,ce,de){let ie=C.textContent,ee=Y?Y.textContent:ie,se=ce?ce.textContent:ie,Ee=p?Mo(C,o.mergeTags,!0):null;if(Ee&&ee!==se){let We=ce&&ce.getAttribute("merge-key")||C.getAttribute("merge-key"),{text:Fe,warnings:tt,conflicts:st}=Cs(o.localIsBase?void 0:ie,ee,se,{parse:Ee.recognizer.parse,keyCandidates:We?We.split(/[\s,]+/).filter(Boolean):void 0});for(let it of tt)console.warn(`[hyper-morph] merge "${Ee.raw}": ${it}`);for(let it of o.localIsBase?[]:st)bt({kind:"json",node:de,name:Ee.raw,path:it.path,base:it.base,local:it.local,remote:it.remote,resolved:it.resolved});de.textContent=Fe,G.add(de),Fe!==se?dt({kind:"text",node:de,source:Fe===ee?"local":"both"}):Fe!==ie&&St({kind:"text",node:de,source:"remote"});return}de.textContent=xe(ie,ee,se,de,"text")}function Se(C,Y,ce,de){let ie=new Map;for(let ee of[C,Y,ce])if(ee)for(let se of ee.attributes)o.ignoreAttribute(ee,se.name)||ie.set(se.name,se);for(let[ee,se]of ie){let Ee=C?C.getAttribute(ee):null,We=Y?Y.getAttribute(ee):Ee,Fe=ce?ce.getAttribute(ee):Ee,tt;We===Fe?tt=We:We===Ee?(tt=Fe,St({kind:"attr",el:de,name:ee,source:"remote"})):Fe===Ee?(tt=We,dt({kind:"attr",el:de,name:ee,source:"local"})):(tt=be(ee,Ee,We,Fe)??V(ee,[C,Y,ce],Ee,We,Fe),tt===void 0&&(tt=Xe==="local"?We:Fe,bt({kind:"attr",el:de,name:ee,base:Ee,local:We,remote:Fe,resolved:tt},{el:de,sample:se})),Me.push({kind:"attr",el:de,name:ee,source:"both"})),tt!=null&&(se.namespaceURI?de.setAttributeNS(se.namespaceURI,se.name,tt):de.setAttribute(ee,tt))}}function V(C,Y,ce,de,ie){let ee=o.attributeMerge;if(typeof ee!="function")return;let se=Y.filter(Boolean).map(Ee=>ee(Ee,C));if(!(!se.length||se.some(Ee=>Ee!==se[0]))){if(se[0]==="tokens")return Z(ce,de,ie);if(se[0]==="max"){let Ee=Number(de),We=Number(ie);return Number.isFinite(Ee)&&Number.isFinite(We)&&de!==""&&ie!==""?String(Math.max(Ee,We)):void 0}}}function Z(C,Y,ce){let de=it=>[...new Set((it||"").split(/\s+/).filter(Boolean))],ie=de(C),ee=new Set(ie),se=new Set(de(Y)),Ee=new Set(de(ce)),We=it=>se.has(it)===Ee.has(it)?se.has(it):se.has(it)===ee.has(it)?Ee.has(it):se.has(it),Fe=ie.filter(We),tt=[...new Set([...se,...Ee])].filter(it=>!ee.has(it)&&We(it)).sort(),st=[...Fe,...tt];return st.length?st.join(" "):null}function be(C,Y,ce,de){if(C==="class"){let ie=Fe=>new Set((Fe||"").split(/\s+/).filter(Boolean)),ee=ie(Y),se=ie(ce),Ee=ie(de),We=new Set;for(let Fe of new Set([...ee,...se,...Ee])){let tt=ee.has(Fe),st=se.has(Fe),it=Ee.has(Fe);(st===it?st:st===tt?it:st)&&We.add(Fe)}return[...We].join(" ")}if(C==="style"){let ie=tt=>{let st=new Map;if(!tt)return st;let it=0,rt=null,kt="",xt=()=>{let Et=kt.indexOf(":");Et>0&&st.set(kt.slice(0,Et).trim(),kt.slice(Et+1).trim()),kt=""};for(let Et of tt){if(rt){kt+=Et,Et===rt&&(rt=null);continue}if(Et==='"'||Et==="'"){rt=Et,kt+=Et;continue}if(Et==="("?it++:Et===")"&&it--,Et===";"&&it===0){xt();continue}kt+=Et}return kt.trim()&&xt(),st},ee=ie(Y),se=ie(ce),Ee=ie(de),We=new Map,Fe=!1;for(let tt of new Set([...ee.keys(),...se.keys(),...Ee.keys()])){let st=ee.get(tt)??null,it=se.get(tt)??null,rt=Ee.get(tt)??null,kt;it===rt?kt=it:it===st?kt=rt:rt===st?kt=it:(kt=Xe==="local"?it:rt,Fe=!0),kt!=null&&We.set(tt,kt)}return Fe?void 0:[...We].map(([tt,st])=>`${tt}: ${st}`).join("; ")}}function ke(C,Y,ce,de){let ie=C.value,ee=de?ie:Y?Y.value:"",se=ce?ce.value:"";ae.add(C),Y&&ae.add(Y),ce&&ae.add(ce);let Ee=Go(ie,ee,se,Xe),We=Ee.text===""?null:pe.createTextNode(Ee.text);We&&(Te.set(We,{base:C.nodes,local:Y?Y.nodes:null,remote:ce?ce.nodes:null}),ze.set(We,Ee.mapLocalOffset)),ee!==ie&&se!==ie?Me.push({kind:"text",node:We,source:"both"}):ee!==ie?dt({kind:"text",node:We,source:"local"}):se!==ie&&St({kind:"text",node:We,source:"remote"});for(let Fe of Ee.conflicts)bt({kind:"text",node:We,base:ie.slice(Fe.bs,Fe.be),local:Fe.local,remote:Fe.remote,resolved:Fe.resolved},{site:"run",bRun:C,lRun:Y,rRun:ce,node:We,c:Fe});return We}function we(C,Y){return io(C,Y).every(ce=>ce.bs===ce.be)}function te(C,Y){let ce=C?C.value:"",de=Y?Y.value:"",ie;if(ce===de||!de?ie=ce:ce?we(ce,de)?ie=de:we(de,ce)?ie=ce:(ie=Xe==="local"?ce:Xe==="both"?ce+de:de,bt({kind:"structure",el:null,detail:"insert-collision",local:ce,remote:de,resolved:ie},{unit:{b:null,l:C,r:Y},localLost:Xe==="remote"})):ie=de,C&&ae.add(C),Y&&ae.add(Y),ie==="")return null;let ee=pe.createTextNode(ie);return Te.set(ee,{base:null,local:C?C.nodes:null,remote:Y?Y.nodes:null}),ce?dt({kind:"insert",el:ee,source:de&&ce===de?"both":"local"}):St({kind:"insert",el:ee,source:"remote"}),ee}function re(C,Y){let ce={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},de=Ee=>c(Ee).every(We=>ot(We)?Ln(We,ce):We.kind==="text"),ie=null;if(de(C)&&de(Y)){let Ee=C.textContent,We=Y.textContent;Ee===We||we(We,Ee)?ie=Y:we(Ee,We)&&(ie=C)}if(!ie){let Ee=Xe==="local",We=q(Ee?C:Y,Ee?"local":"remote",!0),Fe=Te.get(We);return Ee?Fe.remote=Y:Fe.local=C,bt({kind:"structure",el:We,detail:"insert-collision",local:C,remote:Y,resolved:Ee?C:Y},{unit:{b:null,l:C,r:Y},localLost:!Ee}),We}let ee=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?pe.createElementNS(C.namespaceURI,C.tagName):pe.createElement(C.tagName);Se(null,C,Y,ee),Te.set(ee,{base:null,local:C,remote:Y}),ae.add(C),ae.add(Y);let se=pt({base:Array.from(ie.childNodes),local:Array.from(C.childNodes),remote:Array.from(Y.childNodes),out:pe,policy:Xe,idOf:{local:b,remote:T},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:Te,textMappers:ze,conflicts:v,conflict:bt,scope:{base:null,local:C,remote:Y,units:[],at:0},synthetic:!0,decisions:Me,node:ee});ue.push(...se.segments);for(let Ee of se.nodes)ee.appendChild(Ee);return ee}function q(C,Y,ce=!1){if(!ce&&ot(C)){let se=Bt.partner.get(C);if(se)return Ft(C,Y,se)}if(!ot(C)){if(C.value==="")return null;let se=C.kind==="comment"?pe.createComment(C.value):pe.createTextNode(C.value);return Te.set(se,{base:null,local:Y==="local"?C.nodes:null,remote:Y==="remote"?C.nodes:null}),ae.add(C),se}let de=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?pe.createElementNS(C.namespaceURI,C.tagName):pe.createElement(C.tagName);for(let se of C.attributes)se.namespaceURI?de.setAttributeNS(se.namespaceURI,se.name,se.value):de.setAttribute(se.name,se.value);Te.set(de,{base:null,local:Y==="local"?C:null,remote:Y==="remote"?C:null}),ae.add(C);let ie=C.tagName==="TEMPLATE"&&de.content?de.content:de,ee=Y==="local"?W:F;for(let se of c(C)){let Ee=ot(se)?ee.reverse.get(se):null;if(Ee&&I(Ee,null,null),Ee&&Pe.has(Ee)){bt({kind:"structure",el:null,detail:"both-moved",base:Ee},{subject:Ee});continue}if(Ee&&!He.has(Ee)){let Fe=m(W,Ee)||null,tt=m(F,Ee)||null;if(Fe||tt){At||=Co(Te,De,W,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(Ee,Y,se,!0);let st=B(Ee,Fe,tt,!1);Y==="local"?dt({kind:"move",el:st,source:"local"}):St({kind:"move",el:st,source:"remote"}),ie.appendChild(st);continue}}let We=q(se,Y);We&&ie.appendChild(We)}if(!ce&&Bt.drop.size&&C.tagName==="DIV"&&!ie.firstChild&&!C.attributes.length&&!(Y==="local"?b(C):T(C))&&!ee.reverse.has(C)&&!r(C)&&!o.remoteWins(C)){let se=C.firstChild;if(se&&se===C.lastChild&&ot(se)&&(Bt.drop.has(se)||tn?.has(se)))return(tn||=new WeakSet).add(C),null}return de}function le(C,Y,ce,de,ie){Y&&W.identical.has(C)&&W.pairIdenticalChildren(C),ce&&F.identical.has(C)&&F.pairIdenticalChildren(C);let ee=P(W,Y,C,de),se=P(F,ce,C,!1),Ee=c(C),We=new Set(Ee),Fe=new Map;for(let ne=0;ne<Ee.length;ne++)Fe.set(Ee[ne],ne);let tt=ne=>!ot(ne)&&ne.kind==="text"&&!/[^\t\n\f\r ]/.test(ne.value),st=[],it=new Set,rt=new Map,kt=new Set,xt=Je&&[],Et=Je&&[],$e=new Set,mt=[],Tt=null,Dt=new Map;if(!ee.asBase&&!se.asBase&&!W.identical.has(C)&&!F.identical.has(C))for(let ne of Ee){if(!ot(ne)||!Sn.has(ne.tagName))continue;let Be=ee.twin(ne),Ue=se.twin(ne);Be&&Ue&&(!ee.here(Be)||!se.here(Ue))&&I(ne,null,null)}let It=(ne,Be=!1)=>{let Ue=[];for(let qe of ne.units){if($e.has(qe)||!Be&&tt(qe))continue;let ht=ne.baseOf(qe);ht&&We.has(ht)&&Ue.push(ht)}return Ue},xn=ne=>It(ne).map(Be=>Fe.get(Be)),Zt=ne=>ne.every((Be,Ue)=>Ue===0||Be>=ne[Ue-1]),Fn=()=>{let ne=!ee.asBase&&!Zt(xn(ee)),Be=!se.asBase&&!Zt(xn(se)),Ue=null;if(ne&&Be){let qe=It(ee),ht=It(se);if(Ue=tf(Ee.filter(_e=>!$e.has(_e)&&!tt(_e)),Fe,qe,ht),Ue){let _e=Ds(qe.map(lt=>Fe.get(lt))),Ve=Ds(ht.map(lt=>Fe.get(lt)));for(let lt of _e)Ve.has(lt)&&(Ue=null)}}return{lRe:ne,rRe:Be,settled:Ue}},an=Fn();xr(an.lRe&&an.rRe);let{lRe:to,rRe:kn,settled:go}=Fn(),Vo=to&&kn;Vo&&!go&&bt({kind:"structure",el:ie,detail:"both-reordered",base:C},{subject:C,lKept:It(ee,!0),rKept:It(se,!0)});let Gt=kn||!to?{V:se,A:F,side:"remote",other:ee,otherA:W,otherSide:"local"}:{V:ee,A:W,side:"local",other:se,otherA:F,otherSide:"remote"},Un=null,Wo=null;if(Vo){Un=yo(Gt.V.units),Wo=Gt.V.units,go&&(Gt.V=nf(Gt.V,go));for(let ne of Ee)tt(ne)&&ae.add(ne);for(let ne of[ee,se])for(let Be of ne.units)tt(Be)&&ae.add(Be)}to?dt({kind:"move",el:null,source:kn?"both":"local",base:C}):kn&&St({kind:"move",el:null,source:"remote",base:C});let bo=ee.asBase?[]:ee.units.filter(ne=>!ee.baseOf(ne)&&!$e.has(ne)&&!Bt.partner.has(ne)),no=se.asBase?[]:se.units.filter(ne=>!se.baseOf(ne)&&!$e.has(ne)&&!Bt.partner.has(ne)),vn=new Map;if(bo.length&&no.length){let ne=new Map,Be=new Map;for(let _e of no){if(ot(_e)){let lt=T(_e);lt&&ne.set(lt,_e)}let Ve=s.unitHash(_e);Be.has(Ve)||Be.set(Ve,[]),Be.get(Ve).push(_e)}let Ue=(_e,Ve)=>{let lt=_e.units.indexOf(Ve);for(let Ke=lt-1;Ke>=0;Ke--){let ct=_e.baseOf(_e.units[Ke]);if(ct)return ct}return"start"},qe=new Map,ht=new Map;for(let _e of no){let Ve=Ue(se,_e);ot(_e)?(ht.has(Ve)||ht.set(Ve,[]),ht.get(Ve).push(_e)):_e.kind==="text"&&!qe.has(Ve)&&qe.set(Ve,_e)}for(let _e of bo){let Ve=null;if(ot(_e)){let Ke=b(_e);Ke&&ne.has(Ke)&&!vn.has(ne.get(Ke))&&(Ve=ne.get(Ke))}else if(_e.kind==="text"){let Ke=qe.get(Ue(ee,_e));Ke&&!vn.has(Ke)&&(Ve=Ke)}let lt=!!A(_e);if(!Ve&&!lt){let Ke=Be.get(s.unitHash(_e));Ke&&(Ve=Ke.find(ct=>!vn.has(ct)&&ot(ct)===ot(_e)&&(ot(ct)?ct.tagName===_e.tagName&&!J(ct):ct.kind===_e.kind)&&s.equalUnits(_e,ct))||null)}if(!Ve&&ot(_e)&&!lt){let Ke=g.local(_e),ct=(ht.get(Ue(ee,_e))||[]).filter(ft=>{let yt=g.remote(ft);return!vn.has(ft)&&ft.tagName===_e.tagName&&!J(ft)&&!(Ke&&yt&&Ke!==yt)&&s.similar(_e,ft)});ct.length===1&&(Ve=ct[0])}Ve&&(vn.set(Ve,_e),vn.set(_e,Ve))}}let br=ne=>{if(Ot?.consumes(ne))return null;if(ae.has(ne)||At?.has(ne))return rt.get(ne)||null;let Be=ee.twin(ne),Ue=se.twin(ne),qe=Be&&!ee.asBase&&!ee.here(Be),ht=Ue&&!se.asBase&&!se.here(Ue);if(qe||ht){if((!Be||!Ue)&&bt({kind:"structure",el:null,detail:"move-beats-delete",base:ne},{subject:ne,deleted:Be?"remote":"local"}),!Kt(ne))return ot(ne)?(At||=Co(Te,De,W,F,m,B,r,o.remoteWins,v,bt,$,N,x),qe&&At.plan(ne,"local",Be),ht&&At.plan(ne,"remote",Ue)):ae.add(ne),null;bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne})}if(Be&&!Ue&&!ee.asBase&&!se.asBase&&ot(ne)&&Sn.has(ne.tagName)&&!o.remoteWins(ne)&&!o.remoteWins(Be)&&$(ne,Be,W)&&Qa(ne,Ae(se.el),r)){let ct={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},ft=yt=>ot(yt)?Ln(yt,ct):yt.kind==="text";if(c(ne).every(ft)&&c(Be).every(ft)){let yt=pt({base:[ne],local:[Be],remote:[],blocks:new Set([ne,Be]),out:pe,policy:Xe,L:W,R:F,idOf:{base:w,local:b,remote:T},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Ct,Mn,Kn)=>B(Ct,Mn,Kn,!1),cloneUnit:q,mergeAttrs:Se,atomKey:s.exactUnitKey,moveIn:I,moveBuilt:I,movePlanned:I,provenance:Te,textMappers:ze,conflicts:v,conflict:bt,scope:{base:C,local:ee.el,remote:se.el,units:Ee,at:Fe.get(ne)},decisions:Me,node:ie});ue.push(...yt.segments),ae.add(ne),ae.add(Be);let gt=pe.createDocumentFragment();for(let Ct of yt.nodes)gt.appendChild(Ct);return rt.set(ne,gt),rt.set(Be,gt),gt}}if(!Be&&!Ue)return ae.add(ne),St({kind:"remove",source:"both",base:ne}),null;if(!Be&&!$(ne,Ue,F))return ae.add(ne),dt({kind:"remove",source:"local",base:ne}),null;if(!Ue&&!$(ne,Be,W))return ae.add(ne),St({kind:"remove",source:"remote",base:ne}),Je&&(Je.remove(Be),xt.push({bk:ne,lk:Be})),null;let _e=!Be||!Ue,Ve=ee.asBase?m(W,ne)||null:Be,lt=se.asBase&&ot(ne)&&(F.identityPaired.has(ne)||!g.base(ne))&&m(F,ne)||Ue,Ke;return ot(ne)?Ke=B(ne,Ve,lt,ee.asBase):ne.kind==="comment"?Ke=Ut(ne,Ve,Ue,ee.asBase):Ke=ke(ne,Ve,Ue,ee.asBase),ae.add(ne),Ke&&(rt.set(ne,Ke),Be&&rt.set(Be,Ke),Ue&&rt.set(Ue,Ke),_e&&(bt({kind:"structure",el:Ke,detail:"edit-beats-delete",base:ne},{subject:ne,deleted:Be?"remote":"local"}),Be?dt({kind:"insert",el:Ke,source:"local"}):St({kind:"insert",el:Ke,source:"remote"}))),Ke},yr=(ne,Be,Ue,qe)=>{if(Ot?.consumes(ne))return null;if(ae.has(ne))return rt.get(ne)||null;let ht=Be.baseOf(ne);if(ht&&We.has(ht))return $e.has(ht)&&!$e.has(ne)?wr(ht,ne,qe):br(ht);if(ht)return Hn(ht,ne,qe);let _e=vn.get(ne);if(_e){let lt=qe==="local"?ne:_e,Ke=qe==="local"?_e:ne,ct;return ot(lt)?s.equalUnits(lt,Ke)?(ct=q(lt,"local"),ct&&(Te.get(ct).remote=Ke)):ct=re(lt,Ke):ct=te(lt,Ke),ae.add(lt),ae.add(Ke),ct&&(rt.set(lt,ct),rt.set(Ke,ct),ot(lt)&&dt({kind:"insert",el:ct,source:"both"})),ct}let Ve=q(ne,qe);return Ve&&(rt.set(ne,Ve),qe==="local"?dt({kind:"insert",el:Ve,source:"local"}):(St({kind:"insert",el:Ve,source:"remote"}),Je&&ot(ne)&&!Bt.partner.has(ne)&&Et.push({su:ne,node:Ve}))),Ve},wr=(ne,Be,Ue)=>{let qe;return ot(ne)?(qe=I(ne,Ue,Be),qe&&ae.add(Be)):(qe=q(Be,Ue),ae.add(Be),qe&&(Ue==="local"?dt:St)({kind:"insert",el:qe,source:Ue})),qe&&rt.set(Be,qe),qe},Hn=(ne,Be,Ue)=>{I(ne,null,null);let ht=m(Ue==="local"?F:W,ne),_e=Be,Ve=ht?Lt(ht,Ue==="local"?ce:Y,Ue==="local"?F:W):!1,lt=ht&&!Ve&&!Wt(ne,ht);if(lt&&Ue===Gt.otherSide)return bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne}),null;if(lt&&bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne}),ht||bt({kind:"structure",el:null,detail:"move-beats-delete",base:ne},{subject:ne,deleted:Ue==="local"?"remote":"local"}),He.has(ne)){bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne});let ct=q(_e,Ue);return ct&&rt.set(Be,ct),ct}ot(ne)&&(At||=Co(Te,De,W,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(ne,Ue,_e,!0));let Ke=ot(ne)?B(ne,Ue==="local"?_e:m(W,ne)||null,Ue==="remote"?_e:m(F,ne)||null,!1):null;return Ke&&(rt.set(ne,Ke),rt.set(Be,Ke),ht&&rt.set(ht,Ke),Ue==="local"?dt({kind:"move",el:Ke,source:"local"}):St({kind:"move",el:Ke,source:"remote"})),Ke};for(let ne of Gt.V.units){if($e.has(ne)){if(Tt?.has(ne)){for(let qe of Tt.get(ne))it.has(qe)||(st.push(qe),it.add(qe));continue}let Ue=rt.get(ne);it.has(Ue)||(st.push(Ue),it.add(Ue));continue}if(ae.has(ne)&&!(rt.get(ne)&&it.has(rt.get(ne)))){let Ue=Gt.V.baseOf(ne);Ue&&!We.has(Ue)&&bt({kind:"structure",el:null,detail:"both-moved",base:Ue},{subject:Ue});continue}let Be=yr(ne,Gt.V,Gt.A,Gt.side);Be&&!it.has(Be)&&(st.push(Be),it.add(Be),!Gt.V.baseOf(ne)&&!vn.has(ne)&&!$e.has(ne)&&kt.add(Be))}for(let ne of mt)it.has(ne.frag)||(st.splice(ne.previous&&it.has(ne.previous)?st.indexOf(ne.previous)+1:Fo(ne.at),0,ne.frag),it.add(ne.frag));if(!Gt.other.asBase){let ne=Gt.other,Be=Gt.otherSide,Ue=Gt.otherA,qe=null,ht=0,_e=null;for(let Ve of ne.units){let lt=Dt.get(Ve)||rt.get(Ve);if(lt&&it.has(lt)){qe=lt,_e=null;continue}if(ae.has(Ve)){let gt=ne.baseOf(Ve);gt&&!We.has(gt)&&bt({kind:"structure",el:null,detail:"both-moved",base:gt},{subject:gt});continue}let Ke=yr(Ve,ne,Ue,Be);if(!Ke)continue;let ct=!ne.baseOf(Ve)&&!$e.has(Ve),ft=!qe&&!_e,yt=_e?st.indexOf(_e)+1:qe?st.indexOf(qe)+1:ht;if(ct&&ot(Ke)){let gt=Hr(Ke);for(;yt<st.length&&kt.has(st[yt])&&ot(st[yt])&&Hr(st[yt])<gt;)yt++}else if(qe&&!_e&&Be==="remote")for(;yt<st.length&&kt.has(st[yt]);)yt++;st.splice(yt,0,Ke),it.add(Ke),ct&&kt.add(Ke),ft&&(ht=yt+1),_e=Ke}}for(let ne=0;ne<Ee.length;ne++){let Be=Ee[ne];if(ae.has(Be))continue;let Ue=br(Be);Ue&&st.splice(Fo(ne),0,Ue)}return Je&&xt.length&&Et.length&&qn(),Vo?On(st):st;function qn(){if(to||kn)return;let ne=new Set(st),Be=ft=>ft&&We.has(ft)&&ne.has(rt.get(ft))?ft:null,Ue=(ft,yt)=>{let gt=[{prev:null,units:[]}];for(let Ct of ft){let Mn=Be(yt(Ct));Mn?gt.push({prev:Mn,units:[]}):gt[gt.length-1].units.push(Ct)}return gt},qe=Ue(Ee,ft=>ft),ht=Ue(se.units,se.baseOf),_e=ee.asBase?null:Ue(ee.units,ee.baseOf),Ve=ft=>ft.length===qe.length&&ft.every((yt,gt)=>yt.prev===qe[gt].prev);if(!Ve(ht)||_e&&!Ve(_e))return;let lt=new Map(xt.map(ft=>[ft.bk,ft])),Ke=new Map(Et.map(ft=>[ft.su,ft])),ct=ft=>ft?st.indexOf(rt.get(ft)):-1;for(let ft=0;ft<qe.length;ft++){if(qe[ft].units.length!==1||ht[ft].units.length!==1)continue;let yt=lt.get(qe[ft].units[0]),gt=Ke.get(ht[ft].units[0]);if(!yt||!gt||_e&&(_e[ft].units.length!==1||_e[ft].units[0]!==yt.lk))continue;let Ct=ct(qe[ft].prev);(ft+1<qe.length?ct(qe[ft+1].prev):st.length)-Ct!==2||st[Ct+1]!==gt.node||_o(yt.bk,yt.lk,gt.su)&&Je.link(yt.lk,gt.node)}}function oo(ne,Be,Ue,qe){let ht=gt=>{let Ct=gt.filter(ot);return Ct.length===1?Ct[0]:null},_e=ht(ne),Ve=ht(Be),lt=ht(Ue);if(!_e||!Ve||!lt)return;let Ke=ne.indexOf(_e);if(Be.indexOf(Ve)!==Ke||Ue.indexOf(lt)!==Ke||ne.length!==Be.length||ne.length!==Ue.length)return;for(let gt=0;gt<ne.length;gt++)if(gt!==Ke&&(ne[gt].value!==Be[gt].value||ne[gt].value!==Ue[gt].value))return;if((ee.asBase?_e:ee.twin(_e))!==Ve||se.twin(_e)||F.reverse.get(lt)||Ve!==_e&&$(_e,Ve,W))return;let ct=qe.filter(gt=>gt.nodeType===1);if(ct.length!==1||Te.get(ct[0])?.remote!==lt)return;let ft=gt=>gt.map(Ct=>ot(Ct)?"":Ct.value??Ct.nodeValue).join(""),yt=qe.indexOf(ct[0]);ft(qe.slice(0,yt))!==ft(ne.slice(0,Ke))||ft(qe.slice(yt+1))!==ft(ne.slice(Ke+1))||_o(_e,Ve,lt)&&Je.link(Ve,ct[0])}function _o(ne,Be,Ue){if(!ot(Be)||!ot(Ue)||!ot(ne)||Be.namespaceURI!==Ue.namespaceURI||Be.localName===Ue.localName)return!1;for(let Ve of[Be,Ue])if(Ve.tagName==="TEMPLATE"||rn(Ve)||Ve.querySelector("template"))return!1;if(o.remoteWins(ne)||o.remoteWins(Ue)||r(Ue)||Be.attributes.length!==Ue.attributes.length)return!1;for(let Ve of Be.attributes)if(Ue.getAttributeNS(Ve.namespaceURI,Ve.localName)!==Ve.value)return!1;let qe=Be.childNodes,ht=Ue.childNodes;if(qe.length!==ht.length)return!1;for(let Ve=0;Ve<qe.length;Ve++)if(!qe[Ve].isEqualNode(ht[Ve]))return!1;let _e=[[ne,Ue]];for(;_e.length;){let[Ve,lt]=_e.pop();if(Ve.children.length!==lt.children.length)return!1;for(let Ke=0;Ke<lt.children.length;Ke++){let ct=F.reverse.get(lt.children[Ke]);if(ct!==void 0&&ct!==Ve.children[Ke])return!1;_e.push([Ve.children[Ke],lt.children[Ke]])}}return!0}function yo(ne){let Be=[[]];for(let Ue of ne)tt(Ue)?Be[Be.length-1].push(Ue):Be.push([]);return Be}function On(ne){let Be=yo(Ee),Ue=(Ke,ct)=>{let ft=new Map,yt=Ke.filter(gt=>!tt(gt));for(let gt=0;gt<yt.length;gt++)ft.set(yt[gt],ct[gt+1]);return ft},qe=Ue(Ee,Be),ht=Ue(Wo,Un),_e=new Map;for(let[Ke,ct]of rt){if(!ct||_e.has(ct))continue;let ft=qe.get(Ke),yt=ht.get(Ke);(ft||yt)&&_e.set(ct,[ft,yt])}let Ve=[],lt=$o(Be[0],Un[0]);lt&&Ve.push(lt);for(let Ke of ne){Ve.push(Ke);let ct=_e.get(Ke),ft=ct?$o(ct[0],ct[1]):null;ft&&Ve.push(ft)}return Ve}function $o(ne,Be){let Ue=!!ne&&ne.length>0,qe=Ue?ne:Be||[],ht=qe.map(lt=>lt.value).join("");if(ht==="")return null;let _e=pe.createTextNode(ht),Ve=lt=>{let Ke=[];for(let ct of lt||[])ct&&Ke.push(...ct.nodes);return Ke.length?Ke:null};return Te.set(_e,Ue?{base:Ve(ne),local:Ve(ne.map(lt=>ee.asBase?null:ee.twin(lt))),remote:Ve(ne.map(lt=>se.asBase?null:se.twin(lt)))}:{base:null,local:Gt.side==="local"?Ve(qe):null,remote:Gt.side==="remote"?Ve(qe):null}),_e}function Fo(ne){for(let Be=ne-1;Be>=0;Be--){let Ue=rt.get(Ee[Be]);if(Ue){let qe=st.indexOf(Ue);if(qe>=0)return qe+1}}return 0}function xr(ne){if((ee.asBase||W.identical.has(C))&&(se.asBase||F.identical.has(C)))return;let Be={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},Ue=ut=>ot(ut)?Ln(ut,Be):ut.kind==="text";if(!ee.asBase&&!se.asBase)for(let ut of Ee){if(!ot(ut)||!Sn.has(ut.tagName))continue;let u=ee.twin(ut),E=se.twin(ut);if(!u&&E||u&&!E){let L=yl({base:Ee,views:[{V:ee,A:W,idOf:g.local},{V:se,A:F,idOf:g.remote}],eligible:D=>ot(D)&&Sn.has(D.tagName)&&!r(D)&&!o.remoteWins(D),baseId:g.base,ignored:r,remoteWins:o.remoteWins,atomKey:s.exactUnitKey});L&&(ee=L[0],se=L[1]);break}}let qe=!ee.asBase&&!se.asBase&&Ee.length>=2&&Sn.has(Ee[0].tagName)&&ee.units.length===Ee.length&&se.units.length===Ee.length?Qi({base:Ee,local:ee.units,remote:se.units,localTwin:ee.twin,remoteTwin:se.twin,eligible:ut=>ot(ut)&&Sn.has(ut.tagName)&&!r(ut)&&!o.remoteWins(ut),nodes:{base:Array.from(Ae(C).childNodes),local:Array.from(Ae(ee.el).childNodes),remote:Array.from(Ae(se.el).childNodes)}}):null,ht=null,_e=null;if(!qe&&!ee.asBase&&!se.asBase&&(js(Ee)||js(ee.units)||js(se.units))){let ut={ignored:r,remoteWins:()=>!1},u=L=>Ue(L)||ot(L)&&o.remoteWins(L)&&hn.has(L.tagName)&&Ln(L,ut),E=L=>ot(L)?Sn.has(L.tagName)&&!r(L)&&!o.remoteWins(L)&&c(L).every(u):L.kind==="text";ht=wl({onUncertainOwner:L=>{let D=o.identity.local(L.local);D&&D===o.identity.remote(L.remote)||(_e||=[]).push(L)},onUncertainSource:L=>{Ze||(Ze=new Map);let D=Ze.get(L.source);D||Ze.set(L.source,D=[]);for(let z of D)if(z.side===L.side&&z.from===L.from&&z.to===L.to)return;D.push(L)},base:Ee,views:[{V:ee,A:W,idOf:g.local},{V:se,A:F,idOf:g.remote}],eligible:E,ignored:r,remoteWins:o.remoteWins,baseId:g.base,atomKey:s.exactUnitKey})}if(_e){Tt||=new Map;for(let ut of _e){let{source:u,local:E,remote:L}=ut,D={map:new Map,reverse:new Map,identical:new Set},z=pt({base:[u],local:[E],remote:[L],out:pe,policy:"both",L:D,R:D,ignored:r,remoteWins:o.remoteWins,atomKey:s.exactUnitKey,cloneUnit:q,provenance:Te,textMappers:ze,conflicts:v,decisions:Me,conflict:(oe,ge)=>bt(oe,{...ge,policy:"both"}),scope:{base:C,local:ee.el,remote:se.el,units:Ee,at:Fe.get(u)},node:ie});ue.push(...z.segments);for(let oe of[u,E,L])ae.add(oe),$e.add(oe),Tt.set(oe,z.nodes),rt.set(oe,z.nodes[z.nodes.length-1]);for(let oe=0;oe<z.nodes.length;oe++)mt.push({frag:z.nodes[oe],at:Fe.get(u),previous:oe?z.nodes[oe-1]:null})}}let Ve=qe?qe.blocks:null;if(ht){Ve=new Set;for(let ut of ht.blocks)Ve.add(ut)}let lt=ut=>!Ot?.consumes(ut)&&(Ve&&Ve.has(ut)||Ue(ut)),Ke=Ee.map(lt);if(!Ke.includes(!0))return;let ct=ut=>{let u=ut.units,E=new Map;for(let ye=0;ye<u.length;ye++)E.set(u[ye],ye);let L=[],D=-1;for(let ye=0;ye<Ee.length;ye++){if(Ke[ye])continue;let Re=ut.twin(Ee[ye]),he=Re?E.get(Re):void 0;he===void 0||he<=D||lt(Re)||(L.push([ye,he]),D=he)}let z=[],oe=-1,ge=-1;for(let ye=0;ye<=L.length;ye++){let[Re,he]=ye<L.length?L[ye]:[Ee.length,u.length],Ie={bLo:-1,bHi:-1,from:ge+1,to:he,inlineStart:-1,inlineEnd:-1,next:he};for(let Ye=oe+1;Ye<Re;Ye++)Ke[Ye]&&(Ie.bLo<0&&(Ie.bLo=Ye),Ie.bHi=Ye);for(let Ye=ge+1;Ye<he;Ye++){let nt=u[Ye];lt(nt)&&(Ie.inlineStart<0&&(Ie.inlineStart=Ye),Ie.inlineEnd=Ye+1)}z.push(Ie),oe=Re,ge=he}return{units:u,list:z}},ft=ct(ee),yt=ct(se),gt=[];for(let ut of[ft,yt])for(let u of ut.list)u.bLo>=0&&gt.push([u.bLo,u.bHi]);gt.sort((ut,u)=>ut[0]-u[0]);let Ct=[];for(let[ut,u]of gt){let E=Ct[Ct.length-1];E&&ut<=E.hi?E.hi=Math.max(E.hi,u):Ct.push({lo:ut,hi:u})}let Mn=(ut,u)=>ut.length===u.length&&ut.every((E,L)=>s.equalUnits(E,u[L])),Kn=ut=>!ot(ut)&&ut.kind==="comment",wo=ut=>{if(!ut.length)return[];let u=(oe,ge)=>ot(oe)?oe:oe.nodes[ge?oe.nodes.length-1:0],E=u(ut[0]),L=u(ut[ut.length-1],!0),D=oe=>oe&&ot(oe)&&r(oe);for(;D(E.previousSibling);)E=E.previousSibling;for(;D(L.nextSibling);)L=L.nextSibling;let z=[];for(let oe=E;oe&&(z.push(oe),oe!==L);oe=oe.nextSibling);return z},Gr=ut=>ut.some(u=>ot(u)&&r(u));for(let ut of Ct){let u=Ee.slice(ut.lo,ut.hi+1);if(ne&&!u.some(Re=>lt(Re)&&!tt(Re)))continue;let E=null;if(ht)for(let Re of u){let he=ht.certificatesBySource.get(Re);he&&(E||=[]).push(...he)}let L=ee.asBase?null:Ps(ft,ut),D=se.asBase?null:Ps(yt,ut);if(E){let Re=[new Set(L||u),new Set(D||u)],he=E.some(Ie=>!Re[Ie.side].has(Ie.target));for(let Ie of u)if(Ve.has(Ie))for(let[Ye,nt]of[[0,ee],[1,se]]){let at=nt.twin(Ie);at&&nt.here(at)&&!Re[Ye].has(at)&&(he=!0)}if(he)continue}if(u.some(Kn)||L&&L.some(Kn)||D&&D.some(Kn))continue;let z=wo(L||u),oe=wo(D||u);if((!L||Mn(u,L))&&(!D||Mn(u,D))&&!(L&&Gr(z)))continue;let ge=pt({base:wo(u),sourceRetentions:Ze?.get(C),local:z,remote:oe,out:pe,policy:Xe,blocks:Ve,scopeUnits:E?[u,L||u,D||u]:null,certifiedOrigins:E?(Re,he,Ie,Ye,nt,at)=>xl({certificates:E,scopes:[u,L||u,D||u],flats:[Re,he,Ie],keys:[Ye,nt,at]}):null,prepared:qe?qe.prepared:null,nativeTransfers:qe,L:L?W:kl(W,C),R:D?F:kl(F,C),idOf:{base:w,local:b,remote:T},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Re,he,Ie)=>B(Re,he,Ie,!1),cloneUnit:q,mergeAttrs:Se,atomKey:s.exactUnitKey,moveIn:I,moveBuilt:I,movePlanned:I,provenance:Te,textMappers:ze,conflicts:v,conflict:bt,scope:{base:C,local:ee.asBase?null:ee.el,remote:se.asBase?null:se.el,units:Ee,at:ut.lo},decisions:Me,node:ie});if(!ge){if(E){let Re=el({certificates:E,scopes:[u,L||u,D||u],views:[{V:ee,A:W,idOf:g.local},{V:se,A:F,idOf:g.remote}],eligible:he=>ot(he)&&Sn.has(he.tagName)&&!r(he)&&!o.remoteWins(he),baseId:g.base});for(let he of Re.records){Ze||=new Map;let Ie=Ze.get(he.source);Ie||Ze.set(he.source,Ie=[]),Ie.push(he)}}continue}if(ue.push(...ge.segments),qe){let Re=new Map;for(let he of ge.nodes){let Ie=Te.get(he)?.base;if(!Ie||Re.has(Ie))throw new Error("Invalid native transfer owner output");Re.set(Ie,he)}if(Re.size!==qe.owners.length)throw new Error("Incomplete native transfer owner output");for(let he of qe.owners){let Ie=Re.get(he.base);if(!Ie)throw new Error("Missing native transfer owner output");for(let Ye of[he.base,he.local,he.remote])ae.add(Ye),$e.add(Ye),rt.set(Ye,Ie);mt.push({frag:Ie,at:Fe.get(he.base)})}continue}if(Je&&oo(u,L||u,D||u,ge.nodes),ge.unitOutputs){Tt||=new Map;for(let he of[...u,...L||[],...D||[]]){let Ie=ge.unitOutputs.get(he)||[];ae.add(he),$e.add(he),Tt.set(he,Ie),Ie.length&&rt.set(he,Ie[Ie.length-1])}let Re=ge.nodes[ge.nodes.length-1];if(Re)for(let he of[L||u,D||u]){let Ie=he[he.length-1];Ie&&Dt.set(Ie,Re)}for(let he=0;he<ge.nodes.length;he++)mt.push({frag:ge.nodes[he],at:ut.lo,previous:he>0?ge.nodes[he-1]:null});continue}Je&&oo(u,L||u,D||u,ge.nodes);let ye=pe.createDocumentFragment();for(let Re of ge.nodes)ye.appendChild(Re);for(let Re of[...u,...L||[],...D||[]])ae.add(Re),$e.add(Re),rt.set(Re,ye);mt.push({frag:ye,at:ut.lo})}}}function Ne(C,Y){let ce=Te.get(C);return ce&&ce.unchanged?!ce.remote||ce.remote===Y?!0:Le(ce.remote,Y):C.tagName!==Y.tagName||!Ge(C,Y)?!1:et(Ae(C),Ae(Y))}function Le(C,Y){return C===Y?!0:C.tagName!==Y.tagName||C.namespaceURI!==Y.namespaceURI||!Ge(C,Y)?!1:je(Ae(C),Ae(Y))}function je(C,Y){let ce=Qe(C,r),de=Qe(Y,r);if(ce.length!==de.length)return!1;for(let ie=0;ie<ce.length;ie++){let ee=ce[ie],se=de[ie];if(typeof ee=="string"||typeof se=="string"){if(ee!==se)return!1}else{if(ee.nodeType!==se.nodeType)return!1;if(ee.nodeType===1){if(!Le(ee,se))return!1}else if(ee.nodeValue!==se.nodeValue)return!1}}return!0}function Ae(C){return C.tagName==="TEMPLATE"&&C.content?C.content:C}function Ge(C,Y){let ce=0;for(let de of C.attributes)if(!o.ignoreAttribute(C,de.name)&&(ce++,Y.getAttribute(de.name)!==de.value))return!1;for(let de of Y.attributes)o.ignoreAttribute(Y,de.name)||ce--;return ce===0}function et(C,Y){let ce=Qe(C,ie=>{let ee=Te.get(ie);return!!(ee&&ee.pinned)}),de=Qe(Y,r);if(ce.length!==de.length)return!1;for(let ie=0;ie<ce.length;ie++){let ee=ce[ie],se=de[ie];if(typeof ee=="string"||typeof se=="string"){if(ee!==se)return!1}else{if(ee.nodeType!==se.nodeType)return!1;if(ee.nodeType===1){if(!Ne(ee,se))return!1}else if(ee.nodeValue!==se.nodeValue)return!1}}return!0}function Qe(C,Y){let ce=[],de=null;for(let ie=C.firstChild;ie;ie=ie.nextSibling){if(ie.nodeType===3){de=de===null?ie.nodeValue:de+ie.nodeValue;continue}ie.nodeType===1&&Y(ie)||(de!==null&&(de!==""&&ce.push(de),de=null),ce.push(ie))}return de!==null&&de!==""&&ce.push(de),ce}function Ut(C,Y,ce,de){let ie=C.value,ee=de?ie:Y?Y.value:"",se=ce?ce.value:"";ae.add(C),Y&&ae.add(Y),ce&&ae.add(ce);let Ee=ee===se?ee:ee===ie?se:se===ie||Xe==="local"?ee:se,We={site:"comment",bRun:C,lRun:Y,rRun:ce,node:null};if(ee!==ie&&se!==ie&&ee!==se&&bt({kind:"text",node:null,base:ie,local:ee,remote:se,resolved:Ee},We),!Y&&!ce)return null;let Fe=pe.createComment(Ee);return We.node=Fe,Te.set(Fe,{base:C.nodes,local:Y?Y.nodes:null,remote:ce?ce.nodes:null}),Fe}function Mt(C,Y){let ce=m(Y,C);if(!ce)return null;let de=ot(ce)?ce.parentNode:ce.parent,ie=ot(C)?C.parentNode:C.parent;return m(Y,ie)===de?null:Y.reverse.get(de)||null}function Kt(C){let Y=new Set([C]),ce=C;for(let de=0;de<64;de++){let ie=Mt(ce,W)||Mt(ce,F);if(!ie)return!1;if(ie===C||ot(C)&&ot(ie)&&C.contains(ie)||Y.has(ie))return!0;Y.add(ie),ce=ie}return!0}function Lt(C,Y,ce){if(!Y)return!1;let de=ot(C)?C.parentNode:C.parent;return de===Y||Y.tagName==="TEMPLATE"&&de===Y.content}function Wt(C,Y){let ce=De(C),de=m(W,ce);if(de&&Lt(Y,de,W))return!0;let ie=m(F,ce);return!!(ie&&Lt(Y,ie,F))}}function kl(e,t){return e.map.get(t)?Tl():{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 Tl(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function ef(e){let t=[],n=[],o=new Array(e.length).fill(-1);for(let i=0;i<e.length;i++){let s=0,c=t.length;for(;s<c;){let l=s+c>>1;t[l]<e[i]?s=l+1:c=l}t[s]=e[i],n[s]=i,o[i]=s>0?n[s-1]:-1}let r=new Set;for(let i=n[t.length-1];i!==void 0&&i>=0;i=o[i])r.add(i);return r}function Al(e){let t=[],n=new Array(e.length);for(let o=0;o<e.length;o++){let r=0,i=t.length;for(;r<i;){let s=r+i>>1;t[s]<e[o]?r=s+1:i=s}t[r]=e[o],n[o]=r+1}return n}function Ds(e){let t=Al(e),n=Al(e.map(s=>-s).reverse()).reverse(),o=0;for(let s=0;s<t.length;s++)t[s]>o&&(o=t[s]);let r=new Map;for(let s=0;s<e.length;s++)t[s]+n[s]-1===o&&r.set(t[s],(r.get(t[s])||0)+1);let i=new Set;for(let s=0;s<e.length;s++)(!(t[s]+n[s]-1===o)||r.get(t[s])>1)&&i.add(e[s]);return i}function tf(e,t,n,o){let r=g=>{let d=ef(g.map(y=>t.get(y)));return new Set(g.filter((y,N)=>!d.has(N)))},i=r(n),s=r(o);for(let g of i)if(s.has(g))return null;let c=new Set(n),l=new Set(o),a=e.filter(g=>c.has(g)&&l.has(g)&&!i.has(g)&&!s.has(g)),p=new Set(a),f=(g,d)=>{let y=new Map,N=null;for(let x of g){if(p.has(x)){N=x;continue}d.has(x)&&(y.has(N)||y.set(N,[]),y.get(N).push(x))}return y},h=(g,d)=>Ds(g.map(y=>t.get(y))).size>d.size,w=[{at:f(o,s),ambiguous:h(o,s)},{at:f(n,i),ambiguous:h(n,i)}],b=g=>w.map(d=>{let y=d.at.get(g);return y?{group:y,ambiguous:d.ambiguous}:null}).filter(Boolean).sort((d,y)=>d.ambiguous-y.ambiguous||t.get(d.group[0])-t.get(y.group[0])).flatMap(d=>d.group),T=b(null);for(let g of a)T.push(g,...b(g));return new Map(T.map((g,d)=>[g,d]))}function nf(e,t){let n=[],o=new Map,r=null;for(let c of e.units){let l=e.baseOf(c);if(l&&t.has(l)){r=c,o.set(c,[]);continue}(r?o.get(r):n).push(c)}let i=[...o.keys()].sort((c,l)=>t.get(e.baseOf(c))-t.get(e.baseOf(l))),s=c=>{let l=[],a=[],p=()=>{a.length&&l.push(...a.sort((f,h)=>Hr(f)<Hr(h)?-1:1)),a=[]};for(let f of c){if(e.baseOf(f)){p(),l.push(f);continue}a.push(f)}return p(),l};return{...e,units:[...s(n),...i.flatMap(c=>[c,...s(o.get(c))])]}}var Sl=new Set(["INPUT","OPTION","TEXTAREA"]),Us=/[\t\n\f\r ]+/;function Nl(e,t,n,o){let r=e.ownerDocument,{provenance:i,textMappers:s}=n,c=o.hooks,l=[],a=[],p=[],f=new Set,h=[],w=[],b=new Map,T=new Set,g=new Map,d=n.conflicts.length>0||o.trackInserted===!0,y=new Map,N=new Set,x=new Map,S=(m,I)=>{let P=x.get(m);P||x.set(m,P=new Set),P.add(I)},O=d?new Set:null,R=(m,I,P)=>{let $=c.beforeAttributeUpdated(m,I,P);return d&&$===!1&&S(I,m),$},M=m=>!!m&&(m===e||e.contains(m)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(m)),j=new Map,U=new Map,K=new Map,_=new Set,H=new Map;(function m(I){let P=i.get(I);if(P){if(I.nodeType===1){let Q=P.local?o.toLive(P.local):null;Q&&M(Q)&&Q.nodeType===1&&(j.set(I,Q),U.set(Q,I))}else if(Array.isArray(P.local)){let Q=F(P.local,P.local.map(B=>o.toLive(B)).filter(B=>B&&M(B)&&B.nodeType===I.nodeType));if(Q.length&&(j.set(I,Q[0]),U.set(Q[0],I),K.set(I,Q)),Array.isArray(P.caret))for(let B of P.caret){let me=o.toLive(B.node);if(!me||!M(me)||me.nodeType!==3)continue;let xe=H.get(me);Array.isArray(xe)||H.set(me,xe=[]),xe.push({merged:I,from:B.from,to:B.to,flatStart:B.flatStart})}else{let B=0;for(let me of Q)H.set(me,{merged:I,shift:B}),B+=me.nodeValue.length}}}let $=I.nodeType===1&&I.tagName==="TEMPLATE"&&I.content?I.content.childNodes:I.childNodes;for(let Q of $)m(Q)})(t);let k=new Set;for(let m of j.values())k.add(m);for(let m of K.values())for(let I of m)k.add(I);let A=o.localRoot&&o.localRoot!==e?new Set:null;if(A){for(let m=o.localRoot.firstElementChild;m;m=m.nextElementSibling)if(m.tagName==="HEAD")for(let I=m.firstElementChild;I;I=I.nextElementSibling){let P=o.toLive(I);P&&A.add(P)}}for(let m of n.segments||[])Oe(m);let J=o.restoreFocus===!1?null:of(r,H);o.childrenOnly?Te(Ce(e),Ce(t)):De(e,t);for(let{node:m,parent:I}of h)f.has(m)||!m.parentNode||m.nodeType===1&&(o.ignored(m)||ze(m))||Ze(m,I);return rf(r,J,H,s,K,g,_),{applied:l,moved:a,replaced:p,identities:w,mergedScriptsLive:T,liveOf:j,heldBy:g,runOf:K,keptRuns:_,insertedLive:y,vetoed:N,vetoedAttrs:x,removedVetoes:O};function W(m,I){let P=m.slice(I.bs,I.be),$=0;for(;$<P.length&&$<I.text.length&&P[$]===I.text[$];)$++;let Q=0;for(;Q<P.length-$&&Q<I.text.length-$&&P[P.length-1-Q]===I.text[I.text.length-1-Q];)Q++;return{bs:I.bs+$,be:I.be-Q,text:I.text.slice($,I.text.length-Q)}}function F(m,I){if(!I.length)return I;let P=[];for(let B of m){let me=B.parentNode;if(!me)continue;let xe=b.get(me);if(!xe){xe=new Set;for(let fe=me.firstChild;fe;fe=fe.nextSibling)fe.nodeType===3&&xe.add(o.toLive(fe));b.set(me,xe)}P.includes(xe)||P.push(xe)}let $={has:B=>P.some(me=>me.has(B))},Q=[];for(let B of I){Q.push(B);for(let me=B.nextSibling;me&&me.nodeType===3&&!$.has(me)&&!Q.includes(me);me=me.nextSibling)Q.push(me)}return Q}function Oe(m){let I=[];for(let te of m.localNodes){let re=o.toLive(te.node);if(!re||!M(re)||re.nodeType!==3)return;I.push(re)}let P=F(m.localNodes.map(te=>te.node),I);if(!P.length)return;let $=P.map(te=>te.nodeValue).join(""),{flatLocal:Q,lToM:B,mapLocal:me}=m;if($===Q)return;let xe=m.textNodes.map(te=>({node:te.node,ms:te.ms,me:te.me})),fe=[],Se=0;for(let te of P)fe.push(Se),Se+=te.nodeValue.length;let V=(te,re)=>P.find((q,le)=>fe[le]<=te&&te+re<=fe[le]+q.nodeValue.length)||null,Z=[],be=0;for(let te of io(Q,$).map(re=>W(Q,re))){let re=te.bs+be;be+=te.text.length-(te.be-te.bs);let q,le;if(te.be>te.bs){q=B[te.bs];let Ne=q>=0;for(let Le=te.bs;Ne&&Le<te.be;Le++)B[Le]!==q+(Le-te.bs)&&(Ne=!1);if(!Ne)continue;le=q+(te.be-te.bs)}else{let Ne=te.bs>0?B[te.bs-1]:0,Le=te.bs<Q.length?B[te.bs]:0;if(Ne<0||Le<0)continue;q=le=me(te.bs)}Z.push({ms:q,me:le,text:te.text,live:le===q?V(re,te.text.length):null})}Z.sort((te,re)=>re.ms-te.ms);let ke=(te,re)=>(K.get(te.node)||[j.get(te.node)]).includes(re),we=te=>!!te&&te.nodeType===1&&hn.has(te.tagName);for(let te of Z){let re=xe.find(le=>le.ms<=te.ms&&te.me<=le.me&&te.ms<le.me);if(re&&te.live&&re.ms===te.ms&&!ke(re,te.live)){let le=xe.find(Ne=>Ne.me===te.ms&&ke(Ne,te.live));le&&(re=le)}if(!re&&te.me===te.ms){let le=xe.find(Ae=>Ae.me===te.ms),Ne=xe.find(Ae=>Ae.ms===te.ms),Le=le||Ne;if(!Le)continue;let je=Le.node;for(;we(je.parentNode)&&(le?je.parentNode.lastChild:je.parentNode.firstChild)===je;)je=je.parentNode;if(je===Le.node)re=Le;else{let Ae=je.ownerDocument.createTextNode(te.text);je.parentNode.insertBefore(Ae,le?je.nextSibling:je);continue}}if(!re)continue;let q=re.node.nodeValue;re.node.nodeValue=q.slice(0,te.ms-re.ms)+te.text+q.slice(te.me-re.ms),re.me+=te.text.length-(te.me-te.ms)}}function Ce(m){return m.nodeType===1&&m.tagName==="TEMPLATE"&&m.content?m.content:m}function De(m,I){f.add(m);let P=i.get(I);if(P&&P.remote&&n.remoteIdOf){let Q=n.remoteIdOf(P.remote);Q&&w.push([m,Q])}if(P&&P.unchanged){o.opaque&&o.opaque(m)||(n.customIdentity&&P.remote&&ue(m,P.remote),P.remote&&G(m,P.remote));return}if(c.beforeNodeMorphed(m,I)===!1){N.add(I);return}vt(m,I,o.keepLiveOnly&&P&&P.local&&P.local.nodeType===1&&P.local!==m?P.local:null);let $=m.tagName;if(rn(m))m.textContent!==I.textContent&&(l.push({kind:"text",node:m,before:m.textContent,after:I.textContent}),m.textContent=I.textContent),n.mergedScripts.has(I)&&T.add(m);else if($==="TEXTAREA")X(m,I,P);else{Ft(m,I,P);let Q=$==="TEMPLATE"&&m.content?m.content:m,B=$==="TEMPLATE"&&I.content?I.content:I;o.opaque&&o.opaque(m)||o.protectFocusedValue==="subtree"&&At(m)&&m!==r.body?pe(Q):Te(Q,B)}c.afterNodeMorphed(m,I)}function pe(m){for(let I=m.firstChild;I;I=I.nextSibling){let P=U.get(I);P&&j.get(P.parentNode)!==m||(f.add(I),I.nodeType===1&&pe(I))}}function Te(m,I){let P=He(m.firstChild),$=new Set;for(let Q of Array.from(I.childNodes)){let B=j.get(Q);B&&f.has(B)&&!$.has(B)&&(B=null);let me=i.get(Q);if(me&&me.pinned){B&&B.nodeType===1&&((B.parentNode!==m||He(B.nextSibling)!==P)&&ve(m,B,P),f.add(B),$.add(B));continue}if(B&&B.nodeType===1){if(B!==P){let Se=B.parentNode;if(Se===m&&P&&Ot(B)){let V=B.nextSibling;for(let Z=P;Z&&Z!==B;){let be=Z.nextSibling;ve(m,Z,V),Z=be}}else ve(m,B,P),Se!==m&&(a.push(B),l.push({kind:"move",el:B,from:Se,to:m}))}$.add(B),De(B,Q),P=He(B.nextSibling);continue}if(B&&B.nodeType!==1){let Se=K.get(Q)||[B],V=Se.map(be=>be.nodeValue).join(""),Z=Q.nodeValue;if(Q.nodeType===3){let be=Me(Q);be!=null&&V!==be&&(Z=Go(be,V,Q.nodeValue).text)}if(Se.length>1&&V===Z&&!Se.includes(P,1)&&Se.every((be,ke)=>be.parentNode===m&&(ke===0||Se[ke-1].nextSibling===be))){if(B!==P)for(let be of Se)ve(m,be,P);c.beforeNodeMorphed(B,Q)!==!1?c.afterNodeMorphed(B,Q):d&&N.add(Q);for(let be of Se)f.add(be),$.add(be);g.set(Q,B),_.add(Q),P=He(Se[Se.length-1].nextSibling);continue}B!==P&&ve(m,B,P),c.beforeNodeMorphed(B,Q)!==!1?(B.nodeValue!==Z&&(l.push({kind:"text",node:B,before:B.nodeValue,after:Z}),B.nodeValue=Z),c.afterNodeMorphed(B,Q)):N.add(Q),f.add(B),$.add(B),g.set(Q,B),P=He(B.nextSibling);continue}if(Q.nodeType===3&&P&&P.nodeType===3&&!f.has(P)&&!H.has(P)){P.nodeValue!==Q.nodeValue&&(l.push({kind:"text",node:P,before:P.nodeValue,after:Q.nodeValue}),P.nodeValue=Q.nodeValue),f.add(P),g.set(Q,P),P=He(P.nextSibling);continue}let xe=i.get(Q),fe=Je(xe&&xe.unchanged&&xe.remote?xe.remote:Q);if(c.beforeNodeAdded(fe)===!1){N.add(Q);continue}m.insertBefore(fe,P),f.add(fe),d&&y.set(Q,fe),fe.nodeType===3&&g.set(Q,fe),fe.nodeType===1&&(p.push(fe),Pe(fe,Q),n.customIdentity&&xe&&xe.unchanged&&xe.remote&&ue(fe,xe.remote),rn(fe)||pt(fe,Q),o.formState==="property"&&Jt(xe)&&G(fe,xe.remote)),P=He(fe.nextSibling),l.push({kind:"insert",node:fe,parent:m}),c.afterNodeAdded(fe)}for(let Q of Array.from(m.childNodes))f.has(Q)||$.has(Q)||Q.nodeType===1&&(o.ignored(Q)||ze(Q))||(k.has(Q)?h.push({node:Q,parent:m}):Ze(Q,m))}function ze(m){return m.parentNode&&m.parentNode.nodeType===1&&m.parentNode.tagName==="HEAD"&&(A&&!A.has(m)||o.preserve&&o.preserve(m)===!0)}function Me(m){let I=i.get(m);return!I||!Array.isArray(I.local)?null:I.local.map(P=>P.nodeValue).join("")}function v(m){return i.get(m)}function G(m,I){if(!Sl.has(m.tagName)&&!m.querySelector("input,option,textarea"))return;let P=($,Q)=>{if($.tagName!==Q.tagName||($.tagName==="TEXTAREA"?X($,Q,{remote:Q}):Sl.has($.tagName)&&Ft($,Q,{remote:Q}),o.opaque&&o.opaque($)))return;let B=ae($),me=ae(Q);if(B.length===me.length)for(let xe=0;xe<B.length;xe++)P(B[xe],me[xe])};P(m,I)}function ue(m,I){if(o.opaque&&o.opaque(m))return;let P=ae(m),$=ae(I);if(P.length===$.length)for(let Q=0;Q<P.length;Q++){let B=n.remoteIdOf($[Q]);B&&w.push([P[Q],B]),ue(P[Q],$[Q])}}function ae(m){let I=m.tagName==="TEMPLATE"&&m.content?m.content:m;return Array.from(I.children).filter(P=>!o.ignored(P))}function Pe(m,I){if(!n.remoteIdOf)return;let P=($,Q)=>{let B=i.get(Q);if(B&&B.remote&&Q.nodeType===1){let fe=n.remoteIdOf(B.remote);fe&&w.push([$,fe])}let me=$.childNodes,xe=Q.childNodes;for(let fe=0;fe<me.length&&fe<xe.length;fe++)P(me[fe],xe[fe])};P(m,I)}function He(m){for(;m&&m.nodeType===1&&o.ignored(m);)m=m.nextSibling;return m}function ve(m,I,P){if(typeof m.moveBefore=="function"&&I.ownerDocument===m.ownerDocument)try{m.moveBefore(I,P);return}catch{}m.insertBefore(I,P)}function Ze(m,I){if(c.beforeNodeRemoved(m)===!1){d&&O.add(m);return}m.parentNode.removeChild(m),l.push({kind:"remove",node:m,parent:I}),c.afterNodeRemoved(m)}function Je(m){if(rn(m))return Jo(m,r);let I=r.importNode(m,!0);if(I.nodeType===1)for(let P of Array.from(I.querySelectorAll("script")))rn(P)&&P.replaceWith(Jo(P,r));return I}function pt(m,I){let P=m.tagName==="TEMPLATE"&&m.content?m.content:m,$=I.tagName==="TEMPLATE"&&I.content?I.content:I,Q=Array.from(P.childNodes),B=Array.from($.childNodes);for(let me=0;me<B.length&&me<Q.length;me++){let xe=B[me],fe=Q[me],Se=j.get(xe);Se&&f.has(Se)&&(Se=null);let V=i.get(xe);if(V&&V.pinned){if(Se&&Se.nodeType===1){let Z=Se.parentNode;ve(P,Se,fe),Z!==P&&(a.push(Se),l.push({kind:"move",el:Se,from:Z,to:P})),f.add(Se)}fe.remove();continue}if(Se){let Z=Se.parentNode;ve(P,Se,fe),fe.remove(),Se.nodeType===1?(Z!==P&&(a.push(Se),l.push({kind:"move",el:Se,from:Z,to:P})),De(Se,xe)):(f.add(Se),g.set(xe,Se),Se.nodeValue!==xe.nodeValue&&(l.push({kind:"text",node:Se,before:Se.nodeValue,after:xe.nodeValue}),Se.nodeValue=xe.nodeValue));continue}f.add(fe),d&&y.set(xe,fe),fe.nodeType===3&&g.set(xe,fe),V&&V.unchanged&&V.remote?(Xe(fe,V.remote),n.customIdentity&&ue(fe,V.remote)):xe.nodeType===1&&!rn(xe)&&pt(fe,xe)}}function Xe(m,I){let P=m.tagName==="TEMPLATE"&&m.content?m.content:m,$=I.tagName==="TEMPLATE"&&I.content?I.content:I;for(let Q of Array.from($.childNodes))P.appendChild(Je(Q))}function dt(m,I){return I.namespaceURI?m.getAttributeNS(I.namespaceURI,I.localName):m.getAttribute(I.name)}function St(m,I){let P=new Set((I||"").split(Us).filter(Boolean));return(m||"").split(Us).filter($=>$&&!P.has($))}function vt(m,I,P){for(let $ of Array.from(I.attributes)){if(bt(m,$.name)||o.ignoreAttribute(m,$.name,I))continue;let Q=dt(m,$);if(Q===$.value||P&&dt(P,$)===$.value)continue;let B=$.value;if(P&&$.name==="class"&&!$.namespaceURI){let me=$.value.split(Us).filter(Boolean),xe=St(Q,P.getAttribute("class")).filter(fe=>!me.includes(fe));xe.length&&(B=[...me,...xe].join(" "))}if(Q!==B){if(c.beforeAttributeUpdated($.name,m,"update")===!1){d&&S(I,$.name);continue}$.namespaceURI?m.setAttributeNS($.namespaceURI,$.name,B):m.setAttribute($.name,B),l.push({kind:"attr",el:m,name:$.name,before:Q,after:B})}}for(let $ of Array.from(m.attributes)){if(bt(m,$.name)||o.ignoreAttribute(m,$.name,I)||($.namespaceURI?I.hasAttributeNS($.namespaceURI,$.localName):I.hasAttribute($.name)))continue;if(P&&$.name==="class"&&!$.namespaceURI){let me=St($.value,P.getAttribute("class"));if(me.length){let xe=me.join(" ");if(xe===$.value)continue;if(c.beforeAttributeUpdated("class",m,"update")===!1){d&&S(I,"class");continue}m.setAttribute("class",xe),l.push({kind:"attr",el:m,name:"class",before:$.value,after:xe});continue}}if(P&&dt(P,$)===null&&!o.ignoreAttribute(P,$.name))continue;if(c.beforeAttributeUpdated($.name,m,"remove")===!1){d&&S(I,$.name);continue}let B=$.value;$.namespaceURI?m.removeAttributeNS($.namespaceURI,$.localName):m.removeAttribute($.name),l.push({kind:"attr",el:m,name:$.name,before:B,after:null})}}function bt(m,I){let P=m.tagName;return P==="INPUT"?I==="value"||I==="checked"||I==="disabled":P==="OPTION"?I==="selected":!1}function At(m){return m===r.activeElement}function Ot(m){let I=r.activeElement;return!!I&&I!==r.body&&m.contains(I)}function Bt(m,I){let P=I&&I.local&&I.local.nodeType===1&&I.local!==m?I.local:null;if(!P)return!0;let $=m.tagName==="TEXTAREA"?P.textContent:P.getAttribute("value")??"";return m.value!==$}function tn(m,I){return!!o.protectFocusedValue&&At(m)&&Bt(m,I)}function Nt(m,I,P){let $=Math.min(m.length,I.length),Q=0;for(;Q<$&&m[Q]===I[Q];)Q++;if(P<=Q)return P;let B=0;for(;B<$-Q&&m[m.length-1-B]===I[I.length-1-B];)B++;return P>=m.length-B?P+I.length-m.length:I.length-B}function $t(m){try{return m.selectionStart==null?null:[m.selectionStart,m.selectionEnd,m.selectionDirection]}catch{return null}}function cn(m,I,P,$){try{m.setSelectionRange(Nt(I,P,$[0]),Nt(I,P,$[1]),$[2]||"none")}catch{}}function Pt(m,I){let P=m.value,$=$t(m);m.value=I,$&&cn(m,P,I,$)}function Jt(m){let I=m&&m.remote;return I&&I.nodeType===1?I:null}function Ft(m,I,P){let $=m.tagName,Q=Jt(P),B=o.formState==="property"&&Q?Q:I;if($==="INPUT"){let me=tn(m,P),xe=(m.getAttribute("type")||"").toLowerCase(),fe=xe!=="file"&&xe!=="checkbox"&&xe!=="radio",Se=Q&&Q.hasAttribute("value")&&Q.value!==Q.getAttribute("value")?Q.value:null;if(fe&&!me)if(o.formState==="property"){let V=I.getAttribute("value"),Z=m.getAttribute("value");(Z!==V||m.value!==B.value)&&R("value",m,V==null?"remove":"update")!==!1&&(Z!==V&&(V==null?m.removeAttribute("value"):m.setAttribute("value",V),l.push({kind:"attr",el:m,name:"value",before:Z,after:V})),m.value!==B.value&&(At(m)?Pt(m,B.value):m.value=B.value))}else if(I.hasAttribute("value")||Se!=null){let V=Se??I.getAttribute("value");m.getAttribute("value")!==V&&R("value",m,"update")!==!1?(m.setAttribute("value",V),m.value!==V&&(At(m)?Pt(m,V):m.value=V),l.push({kind:"attr",el:m,name:"value",before:null,after:V})):m.value!==V&&m.getAttribute("value")===V&&(At(m)?Pt(m,V):m.value=V)}else(m.hasAttribute("value")||m.value!=="")&&R("value",m,"remove")!==!1&&(m.removeAttribute("value"),m.value="",l.push({kind:"attr",el:m,name:"value",before:"",after:null}));if(!fe&&xe!=="file"){let V=I.getAttribute("value");V==null?m.hasAttribute("value")&&R("value",m,"remove")!==!1&&m.removeAttribute("value"):m.getAttribute("value")!==V&&R("value",m,"update")!==!1&&m.setAttribute("value",V)}o.protectFocusedValue&&At(m)||(nn(m,B,"checked"),o.formState==="property"&&m.indeterminate!==B.indeterminate&&(m.indeterminate=B.indeterminate)),nn(m,B,"disabled")}else if($==="OPTION"){let me=m.parentNode&&m.closest("select");o.protectFocusedValue&&me&&At(me)||nn(m,B,"selected")}}function nn(m,I,P){if(o.ignoreAttribute(m,P,I))return;let $=o.formState==="property"?!!I[P]:I.hasAttribute(P);if(o.formState!=="property"){let Q=m.hasAttribute(P);if(Q!==$){if(R(P,m,$?"update":"remove")===!1)return;$?m.setAttribute(P,""):m.removeAttribute(P),l.push({kind:"attr",el:m,name:P,before:Q?"":null,after:$?"":null})}}m[P]!==$&&(m[P]=$)}function X(m,I,P){if(tn(m,P)||R("value",m,"update")===!1)return;let $=Jt(P),Q=I.textContent,B=$&&$.value!==$.defaultValue?$.value:Q,me=At(m)?$t(m):null,xe=m.value;if(o.formState!=="property"&&m.textContent!==Q){l.push({kind:"text",node:m,before:m.textContent,after:Q});let fe=m.firstChild;fe&&fe.nodeType===3&&!fe.nextSibling?fe.data=Q:m.textContent=Q}m.value!==B&&(m.value=B),me&&m.value!==xe&&cn(m,xe,m.value,me)}}function of(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 rf(e,t,n,o,r,i,s){if(!t)return;let c=t.el;if(!c.isConnected&&t.id&&(c=e.getElementById(t.id)),!c||!c.isConnected)return;if(e.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}try{c.scrollTop=t.scrollTop,c.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{c.setSelectionRange&&!c.selectionEnd&&t.selection[1]!=null&&c.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let l=(f,h)=>{let w=n.get(f);if(Array.isArray(w)){let b=w.find(y=>h>=y.from&&h<y.to)||w.find(y=>h===y.to)||w[w.length-1],T=i.get(b.merged);if(!T||!T.isConnected)return null;let g=o.get(b.merged),d=g&&g.flat?g.flat(b.flatStart+h):h;return[T,Math.max(0,Math.min(d,T.nodeValue.length))]}if(w&&!s.has(w.merged)){let b=(r.get(w.merged)||[f])[0];if(!b.isConnected)return null;let T=o.get(w.merged),g=w.shift+h,d=T?T(g):g;return[b,Math.max(0,Math.min(d,b.nodeValue.length))]}return f.isConnected?[f,Math.min(h,f.nodeType===3?f.nodeValue.length:f.childNodes.length)]:null},a=l(t.range.sc,t.range.so),p=l(t.range.ec,t.range.eo);if(!(!a||!p))try{let f=e.createRange();f.setStart(a[0],a[1]),f.setEnd(p[0],p[1]);let h=e.getSelection();h.removeAllRanges(),h.addRange(f)}catch{}}var sf={compared:0},lf=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function cf(e,t,n,o){let r=(s,c)=>t.getAttribute(c)!==null&&typeof o=="function"&&!!o(s,c),i=0;for(let s of e.attributes)if(!(n(e,s.name)||r(e,s.name))&&(i++,t.getAttribute(s.name)!==s.value))return!1;for(let s of t.attributes)!n(t,s.name)&&!r(t,s.name)&&i--;return i===0}function Hs(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 vl(e,t,n,o,r,i,s,c){let l=new Map,a=new Set,p=f=>{if(o(f))return;let h=n(f);h&&(i.add(h),r.has(h)||l.has(h)?a.add(h):l.set(h,f))};for(let f of e)p(f);p(t);for(let f of s||t.querySelectorAll("*"))p(f);for(let f of a)l.delete(f),c.add(f);return l}function Ol(e,t,n,o,r,i){let s=!1;for(let p of r)p.startsWith("merge:")&&(s=!0);if(!s)return[...o];let c=new Map,l=[],a=i===un?er:"*";for(let p of[e,...e.querySelectorAll(a)]){if(n(p))continue;let f=t(p);if(!f||!(o.has(f)||r.has(f)))continue;let h=(c.get(f)||0)+1;c.set(f,h),h===2&&l.push(f)}return l}function Ml({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:o,o:r,identity:i,baseURI:s}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!cf(e,t,r.ignoreAttribute,r.attributeMerge))return{bail:"root-attrs"};let{ignored:c,remoteWins:l}=r,a=Bs(r.scripts.merge===!1?null:r.scripts.mergeTags,s),p=Me=>{let v=a(Me);return v!==null?v:i.base(Me)||null},f=Me=>{let v=a(Me);return v!==null?v:i.remote(Me)||null},h=[],w=[],b=new Map,T=new Map,g={same:b,differ:T},d=Me=>({bail:Me,comparisons:g}),y=(Me,v,G=!0)=>{if(b.get(Me)===v)return!0;if(T.get(Me)===v)return!1;if(sf.compared++,G&&Me.isEqualNode(v))return b.set(Me,v),!0;let ue=Me.nodeType===v.nodeType;if(ue&&Me.nodeType===1){if(ue=Hs(Me,v),ue){let ae=Me.firstChild,Pe=v.firstChild;for(;ae&&Pe;ae=ae.nextSibling,Pe=Pe.nextSibling)if(!y(ae,Pe,!1)){ue=!1;break}(ae||Pe)&&(ue=!1)}}else ue&&(ue=Me.isEqualNode(v));return(ue?b:T).set(Me,v),ue},N=e,x=t,S=!1,O=()=>{b.set(N,x);for(let Me=0;Me<h.length;Me++)b.set(h[Me],w[Me]);return d("equal")};for(;;){let Me=N.childNodes,v=x.childNodes;if(Me.length!==v.length)break;let G=Je=>y(Me[Je],v[Je])?(b.set(Me[Je],v[Je]),!1):!0,ue=-1,ae=-1;for(let Je=0;Je<Me.length;Je++){if(Me[Je].nodeType!==1)continue;let pt=0;for(let Xe=Me[Je].firstElementChild;Xe;Xe=Xe.nextElementSibling)pt++;pt>=ae&&(ae=pt,ue=Je)}let Pe=[],He=!1;for(let Je=0;Je<Me.length&&Pe.length<2;Je++)Je!==ue&&G(Je)&&Pe.push(Je);if(ue>=0&&Pe.length<2&&(Pe.length===0&&Hs(N,x)?(Pe.push(ue),He=!0):G(ue)&&Pe.push(ue)),Pe.length!==1){if(!S&&Pe.length===0&&Hs(N,x))return O();break}let ve=Me[Pe[0]],Ze=v[Pe[0]];if(S=S||!He,S&&T.set(ve,Ze),ve.nodeType!==1||Ze.nodeType!==1||ve.tagName!==Ze.tagName)break;if(p(ve)!==f(Ze)){if(!S&&y(ve,Ze))return O();break}h.push(N),w.push(x),N=ve,x=Ze}T.set(N,x);for(let Me=0;Me<h.length;Me++)T.set(h[Me],w[Me]);if(N===e||N.tagName==="HEAD"||N.tagName==="BODY")return d("root-level");if(h.length<2||h[1].tagName!=="BODY")return d("not-in-body");if(c(N)||c(x))return d("ignored-ancestor");if(l(N)||l(x))return d("remote-wins-ancestor");for(let Me of h)if(lf.has(Me.tagName))return d("form-ancestor");if(N.tagName==="SCRIPT"||N.getElementsByTagName("script").length||x.getElementsByTagName("script").length)return d("script-or-template");let R=o(N);if(!R||R.nodeType!==1||R.tagName!==N.tagName)return d("no-live-twin");if(!n.contains(R))return d("live-detached");for(let Me of h){let v=o(Me);if(!v||v.nodeType!==1)return d("ancestor-live")}let M=i.base===un&&i.remote===un&&c===is,j=new Set,U=new Set,K=[],_=null,H=Me=>{Me&&(j.has(Me)?U.add(Me):j.add(Me))},k=(Me,v)=>{let G=a(Me),ue=G!==null?G:i.base(Me)||null;return ue!==(G!==null?G:i.remote(v)||null)?!1:(H(ue),!0)},A=(Me,v)=>{for(let G=Me.firstElementChild,ue=v.firstElementChild;G;G=G.nextElementSibling,ue=ue.nextElementSibling){let ae=c(G);if(ae!==c(ue))return!1;if(!ae&&(!k(G,ue)||!A(G,ue)))return!1}return!0},J=Me=>{let v=Me+1<h.length?h[Me+1]:N;for(let G=h[Me].firstElementChild,ue=w[Me].firstElementChild;G;G=G.nextElementSibling,ue=ue.nextElementSibling){if(G===v){let He=Me+1<h.length?J(Me+1):null;if(He)return He;continue}let ae=c(G);if(ae!==c(ue))return"outside-id-changed";if(ae)continue;let Pe=o(G);if(!Pe||Pe.nodeType!==1)return"sibling-live";if(K.push([G,ue]),!M&&(!k(G,ue)||!A(G,ue)))return"outside-id-changed";Me===0&&G.tagName==="HEAD"&&p(G)&&(_=[G,ue])}return null},W=J(0);if(W)return d(W);let F=new Set(h),Oe=null;if(i.base===un){Oe=[];for(let Me of e.querySelectorAll(er))Me===N||F.has(Me)||(N.contains(Me)?Oe.push(Me):M&&H(p(Me)))}let Ce=new Set,De=new Set,pe=new Set,Te=vl(h,N,p,c,j,Ce,Oe,De),ze=vl(w,x,f,c,j,Ce,i.remote===un&&x.querySelectorAll(er),pe);return _&&(U.has(p(_[0]))||Ce.has(p(_[0])))&&(_=null),{scope:{chain:h,root:N,onChain:F,baseIndex:Te,remoteIndex:ze,baseDropped:De,remoteDropped:pe,head:_,same:b,differ:T,dropped:[...Ol(e,p,c,U,De,i.base),...Ol(t,f,c,U,pe,i.remote)],held:Me=>{for(let v=1;v<h.length;v++)if(Me.map.get(h[v])!==w[v])return!1;for(let[v,G]of K)if(Me.map.get(v)!==G)return!1;return!0}}}}var ih=Symbol("hyper-morph-duplicate-key");var af='[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"]',ff='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',uf='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function df(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 hf(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=pf(e,t,o)),!!r)return n?Array.from(r.childNodes):r}function pf(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 l of i){let a=Mo(l,n);a&&!r.has(a.key)&&r.set(a.key,l.textContent)}if(!r.size)return null;let s=e.cloneNode(!0),c=!1;for(let l of[s,...s.querySelectorAll("script")]){let a=Mo(l,n);a&&r.has(a.key)&&(l.textContent=r.get(a.key),c=!0)}return c?s:null}function El(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 Vs(e,t,n={}){let o=n||{};if(!o.head?.block)return Il(e,t,o);try{return Il(e,t,o)}catch(r){return Promise.reject(r)}}function Il(e,t,n){let o=n.policy||"sync",r=o==="raw"?void 0:(l,a)=>df(l)||(o==="history"?!(a&&l.matches(uf))&&l.matches(ff):l.matches(af)),i=n.callbacks||{},s={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"&&(s.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return tr(Object.assign({},s,{live:e,base:n.scripts?.mergeBase||null,remote:El(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let l=Object.assign({},s,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:El(t,e.ownerDocument)});return tr(l)}n.morphStyle==="innerHTML"&&(s.children=!0);let c=hf(e,n.scripts?.mergeBase,!!s.children,s.scripts.mergeTags);return c!==void 0&&(s.base=c),Ws(e,t,s)}var mf=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","attributeMerge","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),wn=()=>{};function nr(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let c of Object.keys(e))if(!mf.has(c))throw new TypeError(`unknown option "${c}"`);let n=Object.assign({beforeNodeAdded:wn,afterNodeAdded:wn,beforeNodeRemoved:wn,afterNodeRemoved:wn,beforeNodeMorphed:wn,afterNodeMorphed:wn,beforeAttributeUpdated:wn},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");if(e.attributeMerge!==void 0&&typeof e.attributeMerge!="function")throw new TypeError("attributeMerge must be a function");let s=e.lineage;if(s!==void 0&&(!s||typeof s!="object"||typeof s.onResult!="function"||!s.elements||typeof s.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:ls(e.ignore,t),remoteWins:ls(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,attributeMerge:typeof e.attributeMerge=="function"?e.attributeMerge:()=>null,opaque:typeof e.opaque=="function"?e.opaque:()=>!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,lineage:s||null}}function Ro(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 un}function Lo(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=cs(t,e.map),o=typeof e.then=="function"?e.then:un;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 un}function gf(e,t,n,o={}){let r=w=>w&&w.nodeType===9?w.documentElement:w,i=r(t),s=r(n),c=r(e)||i;if(o.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let l=Object.assign({},o);delete l.live,delete l.base,delete l.remote;let a=nr(l,[c,i,s].filter(Boolean)),p=o.identity||{},f=Gn(),h=Vr(c,i,s,{identity:{base:Lo(p.base,c),local:Lo(p.local,i),remote:Lo(p.remote,s)},authored:{base:Ro(p.base),local:Ro(p.local),remote:Ro(p.remote)},skipUnchanged:a.hooks.beforeNodeMorphed===wn&&a.hooks.afterNodeMorphed===wn,ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,attributeMerge:a.attributeMerge,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:i.ownerDocument&&i.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:a.children,stats:f});return delete h.recoveryLinks,delete h.lineage,h}function _s({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:o,toLive:r,options:i,identity:s,childrenOnly:c,isDocument:l}){let a=nr(i,[e,t,n,o].filter(Boolean));if(a.ignored(e)){let k=$s(),A=a.lineage?Yo(a.lineage,e,k):null;return{report:k,loads:[],lineage:A}}let p=e.ownerDocument,f=a.lineage?vs(a.lineage,{liveRoot:e,localRoot:n,toLive:r}):null,h=a.scripts.execute?tl(e,a.ignored,p.baseURI):null,w=Gn(),b=a.hooks.beforeNodeMorphed===wn&&a.hooks.afterNodeMorphed===wn,T={identity:{base:Lo(s.base,t||n),local:Lo(s.local,n),remote:Lo(s.remote,o)},authored:{base:Ro(s.base),local:Ro(s.local),remote:Ro(s.remote)},ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,attributeMerge:a.attributeMerge,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:p.baseURI,localIsBase:!t,childrenOnly:c,skipUnchanged:b,lineage:f?{locals:f.locals}:null},g=a.fastPath&&l&&!c&&b&&t===n,d=null,y=null;if(g){let k=Ml({baseRoot:t,remoteRoot:o,liveRoot:e,toLive:r,o:a,identity:T.identity,baseURI:p.baseURI});T.comparisons=k.comparisons||k.scope,k.bail?y=k.bail:(d=Vr(t,n,o,Object.assign({},T,{stats:w,scope:k.scope})),d||(y="chain-unpaired",w=Gn()))}d||(d=Vr(t||n,n,o,Object.assign({},T,{stats:w}))),g&&(w.fastPathAttempted=1,w.fastPathTaken=y?0:1,w.fastPathFallback=y),d.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(k=>a.hooks[k]!==wn)&&al(d.conflicts,d.recoveryLinks,r),a.beforeApply&&a.beforeApply(d.doc);let N=globalThis.__hyperMorphProfile,x=N?performance.now():0,S=Nl(e,d.root,d,{toLive:r,localRoot:n,ignored:a.ignored,ignoreAttribute:a.ignoreAttribute,opaque:a.opaque,formState:a.formState,protectFocusedValue:a.protectFocusedValue,restoreFocus:a.restoreFocus,preserve:a.head.preserve,hooks:a.hooks,childrenOnly:c,keepLiveOnly:a.keepLiveOnly,trackInserted:!!f});N&&(N.apply=(N.apply||0)+(performance.now()-x));let O=[];if(a.head.awaitLoads)for(let k of S.applied){if(k.kind!=="insert"||k.node.nodeType!==1)continue;let A=k.node;A.tagName==="LINK"&&/\bstylesheet\b/i.test(A.getAttribute("rel")||"")&&A.getAttribute("href")&&A.closest("head")&&O.push(new Promise(W=>{A.addEventListener("load",()=>W()),A.addEventListener("error",()=>W())}))}let R=null,M=null;if(h){let k=nl(e,h,{ignored:a.ignored,skip:S.mergedScriptsLive,baseURI:p.baseURI,beforeNodeAdded:a.hooks.beforeNodeAdded,afterNodeAdded:a.hooks.afterNodeAdded,trackRecovery:!!d.recoveryLinks});O.push(...k.loads),R=k.swapped,M=k.vetoed}let j=k=>R&&R.get(k)||k,U=k=>{if(S.keptRuns.has(k))return S.runOf.get(k);let A=S.liveOf.get(k)||S.heldBy.get(k)||S.insertedLive.get(k);return A?j(A):null},K=k=>{let A=k&&S.liveOf.get(k);return A?j(A):null},_=k=>{let A=k&&U(k);return Array.isArray(A)?A[0]:A};if(d.recoveryLinks){let k=(A,J,W)=>(J.namespaceURI?A.getAttributeNS(J.namespaceURI,J.localName):A.getAttribute(J.qualifiedName))===W;dl(d.conflicts,d.recoveryLinks,{lookup:U,vetoed:S.vetoed,vetoedAttrs:S.vetoedAttrs,removedVetoes:S.removedVetoes,vetoedLive:M,liveAttr:k,ignored:a.ignored,liveRoot:e})}let H={applied:S.applied,decisions:d.decisions.map(k=>Object.assign({},k,{node:k.node?K(k.node):null,el:k.el?K(k.el):null,applied:!!(k.node?K(k.node):k.el&&K(k.el))})),conflicts:d.conflicts.map(k=>Object.assign({},k,{node:k.node?k.kind==="text"&&k.recovery.subject.nodeType===8?_(k.node):K(k.node):k.node,el:k.el?k.kind==="structure"?_(k.el):K(k.el):k.el})),localDiverged:d.localDiverged,identities:S.identities,moved:S.moved,replaced:S.replaced,stats:w};return f&&(H.lineage=f.finish(d.lineage,U)),{report:H,loads:O,lineage:f}}var Cl=new WeakMap;function $s(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Gn()}}function tr(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");return t.lineage===void 0?Rl(t):Ns(t,t.live.documentElement,o=>Rl(o))}function Rl(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let o=Cl.get(n);o||(o=ss(n),Cl.set(n,o));let r=o("remote",t.remote),i=typeof t.base=="string"&&t.base===""?null:t.base,s=i?o("base",i):null,c=t.local?t.local.root:n.documentElement,l=t.local?t.local.toLive:h=>h;Ai(n,r);let{report:a,loads:p,lineage:f}=_s({liveRoot:n.documentElement,baseRoot:s?s.documentElement:null,localRoot:c,remoteRoot:r.documentElement,toLive:l,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return f?.deliver(a),Promise.all(p).then(()=>a)}function bf(e,t,n={}){return tr(Object.assign({},n,{live:e,base:null,remote:t}))}function Ll(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=vr(e,t),s=o[1].toLowerCase()==="html"?i.documentElement:i.body;return{root:s,first:s}}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 Ws(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return n.lineage===void 0?Pl(e,t,n):Ns(n,e,o=>Pl(e,t,o))}function Pl(e,t,n={}){let o=e.ownerDocument,{base:r,...i}=n,s=!!i.children,c=nr(i,[e]);if(c.ignored(e)){let T=$s();return c.lineage&&Yo(c.lineage,e,T).deliver(T),Promise.resolve(T)}let l=Ll(t,o),a=r!=null?Ll(r,o):null,p,f=null;if(s)p=l.root,f=a?a.root:null;else{if(p=l.first,f=a?a.first:null,!p){let T=nr(i),g=T.lineage?Yo(T.lineage,e,{}):null;T.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),T.hooks.afterNodeRemoved(e));let d={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Gn()};return g&&(d.lineage=g.result,g.deliver(d)),Promise.resolve(d)}if(p.tagName!==e.tagName){let T=nr(i,[e,p]);if(T.hooks.beforeNodeMorphed(e,p)===!1){let y=$s();return T.lineage&&Yo(T.lineage,e,y).deliver(y),Promise.resolve(y)}let g=_s({liveRoot:e,baseRoot:f&&f.tagName===e.tagName?f:null,localRoot:e,remoteRoot:p,toLive:y=>y,options:i,identity:i.identity||{},childrenOnly:!0,isDocument:!1}),d=rn(p)?Jo(p,o):o.importNode(p,!1);if(!rn(d))for(;e.firstChild;)d.appendChild(e.firstChild);return T.hooks.beforeNodeAdded(d)===!1?(Ur(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):T.hooks.beforeNodeRemoved(e)===!1?(Ur(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(d),Ur(g.report.conflicts,e,d),T.hooks.afterNodeRemoved(e),T.hooks.afterNodeAdded(d),T.hooks.afterNodeMorphed(e,p),g.report.replaced.push(d),g.report.applied.push({kind:"insert",node:d,parent:d.parentNode},{kind:"remove",node:e,parent:d.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,d),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:h,loads:w,lineage:b}=_s({liveRoot:e,baseRoot:f,localRoot:e,remoteRoot:p,toLive:T=>T,options:i,identity:i.identity||{},childrenOnly:s,isDocument:!1});return b?.deliver(h),Promise.all(w).then(()=>h)}var jl={mergeDocument:tr,morphDocument:bf,morphElement:Ws,merge3:gf,morph:Vs};function Fs(e,t,{onWidgetRemoved:n}={}){jl.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=Sr.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var wf="hha:upgrade-check:";function jn(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function qs(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Dl(e,t){let n=qs(e),o=qs(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let s=n[i]||0,c=o[i]||0;if(s!==c)return s>c}return!1}function xf(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function kf(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Ks({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||(h=>fetch(h)),r=r??Date.now(),!t)return null;let s=jn(t,"hyper-source");if(!s)return null;let c=jn(t,"hyper-version"),l;try{l=new URL(s,n?n.href:void 0)}catch{return null}if(n&&l.origin===n.origin&&l.pathname===n.pathname)return null;let a=`${wf}${l.href}:${c||"none"}`,p,f=e?null:xf(a);if(f&&typeof f.checkedAt=="number"&&r-f.checkedAt<i)p=f.sourceVersion;else{try{let h=await o(l.href);if(!h.ok)throw new Error(`HTTP ${h.status}`);let w=await h.text(),b=new DOMParser().parseFromString(w,"text/html");p=jn(b,"hyper-version")}catch{p=null}kf(a,{checkedAt:r,sourceVersion:p})}return p?{available:Dl(p,c||"0.0.0"),currentVersion:c,sourceVersion:p,sourceUrl:l.href}:null}var Dn={};Jr(Dn,{EmptyListInsert:()=>Jn,MAX_RULE_DEPTH:()=>jo,MaxRuleDepthExceeded:()=>ho,NoRulesTag:()=>zs,RuleTargetReadOnly:()=>rr,RulesParseError:()=>Po,ShapeMismatch:()=>or,UnknownRulesVersion:()=>uo,WriteNotRoundTripped:()=>Wr,WriteRefused:()=>sr,WriteRejected:()=>Gs});var Po=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},uo=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},jo=20,ho=class extends Error{constructor(t){super(`rule depth exceeded ${jo} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},or=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},Jn=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`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}},rr=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},sr=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Af(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var Wr=class extends Error{constructor(t){super(`write did not round-trip at "${Af(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},zs=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Gs=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}};var Tf=/^--[A-Za-z0-9_-]+$/;function Zn(e){return typeof e=="string"&&Tf.test(e)}function Bl(e){let t=[],n=[],o=null,r=0;for(let i=0;i<e.length;i++){let s=e[i];if(o){s==="\\"?i++:s===o&&(o=null);continue}if(s==="/"&&e[i+1]==="*"){let c=e.indexOf("*/",i+2);i=c===-1?e.length:c+1;continue}s==='"'||s==="'"?o=s:s==="("?n.push(")"):s==="["?n.push("]"):s==="{"?n.push("}"):(s===")"||s==="]"||s==="}")&&n[n.length-1]===s?n.pop():s===";"&&n.length===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function Sf(e){let t="",n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){t+=r,r==="\\"&&o+1<e.length?t+=e[++o]:r===n&&(n=null);continue}if(r==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Ul(e){e=Sf(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(o);return r&&(o=o.slice(0,r.index).trim()),{name:n,value:o,important:!!r}}function Do(e,t){if(e==null)return null;let n=null;for(let o of Bl(String(e))){let r=Ul(o);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function Hl(e,t,n){let o=e==null?"":String(e),r=n==null||n==="",i=Bl(o),s=i.map(Ul),c=s.some(f=>f&&f.name===t&&f.important),l=[],a=!1;i.forEach((f,h)=>{let w=s[h];if(!w||w.name!==t){l.push(f);return}if(r||a)return;let b=/^\s*/.exec(f)[0];l.push(`${b}${t}: ${n}${c?" !important":""}`),a=!0});let p=l.join(";");if(!r&&!a){let f=p.trimEnd();p=f===""?`${t}: ${n}`:`${f}${f.endsWith(";")?" ":"; "}${t}: ${n}`}return p.trim()===""?null:p}function _r(e,t,n,o){let r=e.attr(t,"style");if((Do(r,n)??"")===o)return;let i=Hl(r,n,o);i==null?e.removeAttr(t,"style"):e.attr(t,"style",i)}function Bn(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 Xs(e,t,n,{depth:0,path:[]},o)}function Xs(e,t,n,o,r){if(o.depth>jo)throw new ho(o.path);if(typeof n=="string")return Nf(e,t,n,o,r);if(Array.isArray(n)){let[i,s]=n,c=e.find(t,i,r);return Wl(r,o,c),c.map((l,a)=>Xs(e,l,s,{depth:o.depth+1,path:[...o.path,a]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[s,c]of Object.entries(n))i[s]=Xs(e,t,c,{depth:o.depth+1,path:[...o.path,s]},r);return i}return null}function Nf(e,t,n,o,r){if(n.endsWith("[]")){let c=n.slice(0,-2),l=e.find(t,c,r);return Wl(r,o,l),l.map(a=>e.text(a))}if(n.startsWith("@"))return Vl(e,t,n.slice(1));let i=gn(n);if(i!==-1){let c=n.slice(0,i),l=n.slice(i+1),a=c?e.find(t,c,r):[t];return a.length===0?null:Vl(e,a[0],l)}if(n===".")return e.text(t);let s=e.find(t,n,r);return s.length===0?null:e.text(s[0])}function Wl(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 Vl(e,t,n){if(Zn(n))return Do(e.attr(t,"style"),n);if(xo.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}var $r=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"]})}),vf=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),_l=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function ir(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 Ys(e,t){if(ir(e,t))return!0;for(let[n,o]of Object.entries(vf))if(o.includes(t)&&ir(e,n))return!0;return!1}function lr(e){let t=$r[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Of(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=$r[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Ys(n,r))||o.bundles.some(r=>ir(n,r)))return n;n=n.parentElement}return null}function $l(e,t){return!!Of(e,t)}var Mf=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Ef(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Fl(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 ql(e,t,n,o,r,i){return(i?$l(e,t):Fl(e,n,r,!1))||!!(o&&(i&&e!==r?e.matches(o):Fl(e,o,r,i)))}function If(e,t){let n=$r[t];return n.tokens.some(o=>Ys(e,o))||n.bundles.some(o=>ir(e,o))}var Cf=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Kl(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,i=t;if(e.nodeType===1){if(Cf.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,i=t.content,n.cloneToLive.set(i,r),n.liveToClone.set(r,i)}}else if(e.nodeType!==11)return;let s=i.firstChild;for(let c=r.firstChild;c&&s;c=c.nextSibling)Kl(c,s,n,o),s=s.nextSibling}function cr(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=i.implementation.createHTMLDocument(""),c=r||new WeakMap,l=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let p=lr(t),f=o?b=>If(b,t)||!!(n&&b.matches(n)):b=>ql(b,t,p,n,a,!1),h=null;if(a.nodeType!==1||!ql(a,t,p,n,a,o)){h=s.importNode(a,!0);let b={cloneToLive:c,liveToClone:l,dropped:[],controls:[]};Kl(a,h,b,f);for(let T of b.dropped)T.remove();for(let T=0;T<b.controls.length;T+=2)Ef(b.controls[T],b.controls[T+1])}e.nodeType===9&&h&&(s.replaceChild(h,s.documentElement),l.set(e,s),c.set(s,e));let w=b=>{if(Mf.test(b))throw new Error(`Filtered content queries do not support stateful selector: ${b}`)};return{root:h,document:s,capability:t,selector:lr(t),cloneToLive:c,liveToClone:l,original(b){return c.get(b)||null},cloneOf(b){return l.get(b)||null},query(b,T=h){return w(b),Array.from(T.querySelectorAll(b),g=>c.get(g)||g)},text(b=h){return(b===h?h:l.get(b))?.textContent||""},html(b=h){return(b===h?h:l.get(b))?.innerHTML??""},clone(b=h){let T=b===h?h:l.get(b);return T?s.importNode(T,!0):null}}}function Gl(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Rf(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function zl(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function Xl(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Yl(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var Yt={semanticExclude:!0,find(e,t,n={}){let o=Rf(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!Gl(c)));let i=[];n.skip&&i.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&i.push("["+s+"]"),i.length){let c=i.join(", ");r=r.filter(l=>!l.closest||!l.closest(c))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Xl(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),zl(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),zl(e,t,null)},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){let t=e.cloneNode(!0);return Yl(t),t},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Qn(e,t={}){if(t.exclude===null)return Yt;let n=[lr("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 Yt;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,c=null,l=()=>c||(c=cr(i,{capability:"data",exclude:t.exclude||null})),a=b=>{let T=l();return b===e?T.cloneOf(e):T.cloneOf(b)||b},p=b=>c?.original(b)||b,f=(b,T)=>{l().liveToClone.set(b,T),l().cloneToLive.set(T,b);let g=b.childNodes||[],d=T.childNodes||[];for(let y=0;y<Math.min(g.length,d.length);y++)f(g[y],d[y])},h=(b,T,g,d)=>{let y=Array.from(b.childNodes).filter(R=>c.cloneOf(R)),x=y[0];for(;x&&y.includes(x);)x=x.nextSibling;for(let R of y)R.remove();if(g==="innerHTML"){let R=s.createElement("template");R.innerHTML=d;for(let M of Array.from(R.content.childNodes))b.insertBefore(M,x||null)}else b.insertBefore(s.createTextNode(d),x||null),Xl(b,d);let S=cr(b,{capability:"data",exclude:t.exclude||null});T.replaceChildren(...Array.from(S.root?.childNodes||[]));let O=R=>{let M=S.original(R);M&&(c.liveToClone.set(M,R),c.cloneToLive.set(R,M));for(let j of Array.from(R.childNodes||[]))O(j)};for(let R of Array.from(T.childNodes))O(R)},w={...Yt,find(b,T,g={}){let d=a(b);if(!d?.querySelectorAll)return[];let y=l().query(T,d);g.includeRulesTag||(y=y.filter(S=>!Gl(S)));let N=[];g.skip&&N.push(g.skip);let x=g.templateAttr===null?null:g.templateAttr||"cms-template";if(x&&N.push(`[${x}]`),N.length){let S=N.join(", ");y=y.filter(O=>!O.closest?.(S))}return y},parent(b){let T=a(b)?.parentElement;return T?p(T):null},children(b){return Array.from(a(b)?.children||[],p)},text(b,T){if(T===void 0){let y=p(b);return!y?.matches?.(n)&&!y?.querySelector?.(n)?Yt.text(y):(a(b)?.textContent||"").trim()}let g=p(b);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){Yt.text(g,T);return}let d=l().cloneOf(g);d?h(g,d,"textContent",T):Yt.text(g,T)},attr(b,T,g){let d=p(b);if(g===void 0)return Yt.attr(d,T);Yt.attr(d,T,g);let y=c?.cloneOf(d);y&&(Yt.attr(y,T,g),cr(d,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(d),c.cloneToLive.delete(y)))},removeAttr(b,T){let g=p(b);Yt.removeAttr(g,T);let d=c?.cloneOf(g);d&&Yt.removeAttr(d,T)},prop(b,T,g){let d=p(b);if(g===void 0)return T==="innerHTML"||T==="outerHTML"||T==="textContent"||T==="innerText"?Yt.prop(a(d),T):Yt.prop(d,T);let y=T==="innerHTML"||T==="textContent"||T==="innerText",N=y?l().cloneOf(d):c?.cloneOf(d);N&&y?h(d,N,T,g):(Yt.prop(d,T,g),N&&Yt.prop(N,T,g))},clone(b){let T=a(b);if(T===b)return Yt.clone(b);let g=s.importNode(T,!0);return Yl(g),g},insertAt(b,T,g){let d=p(b),N=w.children(d)[g]||(()=>{for(let O=d.children.length-1;O>=0;O--){let R=d.children[O];if(l().cloneOf(R))return R.nextElementSibling}return d.firstElementChild})(),x=p(T);d.insertBefore(x,N||null);let S=l().cloneOf(d);if(S){let O=l().cloneOf(x);O||(O=s.importNode(x,!0),f(x,O));let R=Array.from(S.children);S.insertBefore(O,R[g]||null)}},insertBefore(b,T){let g=p(b),d=p(T);g.parentNode.insertBefore(d,g);let y=l().cloneOf(g.parentNode);if(y){let N=l().cloneOf(d);N||(N=s.importNode(d,!0),f(d,N));let x=l().cloneOf(g);x?x.before(N):y.appendChild(N)}},insertAfter(b,T){let g=p(b),d=p(T);g.parentNode.insertBefore(d,g.nextSibling);let y=l().cloneOf(g.parentNode);if(y){let N=l().cloneOf(d);N||(N=s.importNode(d,!0),f(d,N));let x=l().cloneOf(g);x?x.after(N):y.appendChild(N)}},identity(b){return p(b)||null},remove(b){let T=p(b),g=l().cloneOf(T);Yt.remove(T),g&&Yt.remove(g)},replaceWith(b,T){let g=p(b),d=l().cloneOf(g),y=Yt.replaceWith(g,T);if(d){let N=cr(y,{capability:"data",exclude:t.exclude||null});if(!N.root)d.remove();else{d.replaceWith(N.root);let x=S=>{let O=N.original(S);O&&(c.liveToClone.set(O,S),c.cloneToLive.set(S,O));for(let R of Array.from(S.childNodes||[]))x(R)};x(N.root)}}return y}};return w}var Nn=Yt;function Js(e){try{return JSON.parse(e)}catch(t){throw new Po(`Invalid strict JSON: ${t.message}`,t)}}function po(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=[],s=0;for(;s<r.length;){let c=r[s];if(/\s/.test(c)){s++;continue}if("{}".includes(c)){i.push({type:c,value:c}),s++;continue}if(c==="["){let f=!1,h=s+1;for(;h<r.length&&/\s/.test(r[h]);)h++;if(h<r.length&&/[a-zA-Z_]/.test(r[h])&&(f=!0),!f){i.push({type:c,value:c}),s++;continue}}if(c==="]"){i.push({type:c,value:c}),s++;continue}if(c===":"){i.push({type:t.COLON,value:c}),s++;continue}if(c===","){i.push({type:t.COMMA,value:c}),s++;continue}if(c==='"'||c==="'"){let f=c,h=s+1;for(;h<r.length&&r[h]!==f;)r[h]==="\\"&&h++,h++;i.push({type:t.STRING,value:r.substring(s+1,h),quoted:!0,sourceQuote:f}),s=h+1;continue}let l=s,a;for(;l<r.length&&!/[{},]/.test(r[l]);)if(r[l]===":"){let f=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let w of f){let b=w.substring(1);if(r.substring(l+1,l+1+b.length)===b){h=!0,l+=b.length;break}}if(!h)break}else if(r[l]==="["){for(l++;l<r.length&&r[l]!=="]";){if(r[l]==='"'||r[l]==="'"){let f=r[l];for(l++;l<r.length&&r[l]!==f;)r[l]==="\\"&&l++,l++}l++}l<r.length&&r[l]==="]"&&l++}else l++;a=r.substring(s,l);let p=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(a)?p=t.NUMBER:a==="true"||a==="false"||a==="null"?p=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(a)&&(p=t.SELECTOR),i.push({type:p,value:a,quoted:!1}),s=l}return i}function o(r){let i="";for(let s=0;s<r.length;s++){let c=r[s];if("{}".includes(c.type)||"[]".includes(c.type)){i+=c.value;continue}if(c.type===t.COLON){i+=c.value;continue}if(c.type===t.COMMA){let l=r[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;i+=c.value;continue}if(c.type===t.STRING&&c.quoted){let l=c.value;c.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(a,p)=>p.length%2===0?p+'\\"':a)),i+=`"${l}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){i+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){i+=`"${c.value}"`;continue}i+=`"${c.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 Zs="1",Jl=/^[a-zA-Z0-9_-]+$/;function Bo(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!Jl.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Jl})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],s=e.attr(i,"data-rules-version");if(s!==Zs)throw new uo(s);return{rules:po(e.text(i)),tagNode:i}}var Lf="script[data-rules-name]";function Zl(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ar(e,t){let n=e.find(t,Lf,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let s=Zl(e.attr(i,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let c=e.attr(i,"data-rules-version");if(c!==Zs)throw new uo(c);o.add(s),r.push({name:s,rules:po(e.text(i))})}return r}function Fr(e,t){let n={};for(let{name:o,rules:r}of ar(e,t))n[o]=Bn(e,t,r);return n}function Qs(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Fr(Nn,t),version:jn(n,"hyper-version")}}var Uo=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},fr=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}},eo=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},ur=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 Ql="text/hyper-upgrade";function ei(e,t){let n=e.find(t,`script[type="${Ql}"]`);if(n.length===0)return null;if(n.length>1)throw new ur(n.length);return e.text(n[0])||null}var Pf=new Function("url","return import(url)");async function ti(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await Pf(n)}catch(r){throw new eo(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new eo("transform must `export default` a function");return o.default}function nc(e,t,n,o){let r=e.length,i=t.length,s=new Array(r).fill(-1);if(o){let d=new Set;for(let y=0;y<r;y++){let N=o[y];!(N>=0&&N<i)||d.has(N)||(s[y]=N,d.add(N))}}if(r===0||i===0)return s;let c=e.map(d=>ec(d,n)),l=t.map(d=>ec(d,n)),a=new Array(i).fill(!1);for(let d of s)d>=0&&(a[d]=!0);let p=new Map;l.forEach((d,y)=>{a[y]||p.set(d,p.has(d)?-1:y)});let f=new Map;c.forEach((d,y)=>{s[y]>=0||f.set(d,(f.get(d)||0)+1)}),c.forEach((d,y)=>{if(s[y]>=0||f.get(d)!==1)return;let N=p.get(d);N===void 0||N===-1||a[N]||(s[y]=N,a[N]=!0)});let h=[];for(let d=0;d<r;d++)s[d]<0&&h.push(d);let w=[];for(let d=0;d<i;d++)a[d]||w.push(d);if(h.length===0||w.length===0)return s;let b=r*i+1,T=jf(e,t,n),g=(d,y)=>T(d,y)*b+Math.abs(d-y);for(let[d,y]of Df(h,w,g))s[d]=y;return s}var oc=e=>typeof e=="object"&&e!==null;function ec(e,t){if(!oc(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 jf(e,t,n){if(!oc(n))return(c,l)=>e[c]===t[l]?0:1;let o=Object.keys(n),r=c=>o.map(l=>JSON.stringify(c?.[l])),i=e.map(r),s=t.map(r);return(c,l)=>{let a=i[c],p=s[l],f=0;for(let h=0;h<o.length;h++)a[h]!==p[h]&&f++;return f}}function Df(e,t,n){return e.length<=t.length?tc(e,t,n,!1):tc(t,e,(o,r)=>n(r,o),!0)}function tc(e,t,n,o){let r=e.length,i=t.length,s=[];for(let f=0;f<=r;f++)s.push(new Float64Array(i+1).fill(1/0));let c=[];for(let f=0;f<=r;f++)c.push(new Uint8Array(i+1));for(let f=0;f<=i;f++)s[r][f]=0;for(let f=r-1;f>=0;f--)for(let h=i-1;h>=0;h--){let w=n(e[f],t[h])+s[f+1][h+1],b=s[f][h+1];w<=b?(s[f][h]=w,c[f][h]=1):s[f][h]=b}let l=[],a=0,p=0;for(;a<r&&p<i;)c[a][p]&&(l.push(o?[t[p],e[a]]:[e[a],t[p]]),a++),p++;return l}function oi(e,t,n,o,r,i,s,c={}){let l=e.find(t,n,c);if(r.length===0){l.forEach(x=>e.remove(x)),ni(c,"onRowsApplied",i.path,[]);return}let a=r.length>l.length,p=l[0]||null;if(a&&!p&&(p=Vf(e,t,n,c),!p))throw new Jn(i.path);let f=l.map(x=>Hf(e,x,o,c)),h=null;if(a&&p){h=e.clone(p),c.templateAttr&&e.removeAttr(h,c.templateAttr);let x=e.stripIds(h);x>0&&console.warn(`[hyper-html-api] stripped ${x} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let w=nc(r,f,o,Bf(e,l,r,i,c)),b=l.length>0?e.parent(l[0]):Ff(e,t,n,p,i,c),T=l.length>0?cc(e,b,l[0]):0,g=zf(e,l),d=new Set,y=[],N=r.map((x,S)=>{let O=w[S];if(O>=0)return d.add(O),y.push(!1),l[O];y.push(!0);let R=e.clone(h);return e.stripIds(R),R});l.forEach((x,S)=>{d.has(S)||e.remove(x)}),g?Kf(e,b,T,N,y):Gf(e,N,y,b,T),Uf(e,N,o,r,i,s,c),ni(c,"onRowsApplied",i.path,N)}function ni(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 Bf(e,t,n,o,r){let i=ni(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let s=new Array(n.length).fill(-1),c=new Set,l=new Map(t.map((a,p)=>[e.identity(a),p]));for(let a=0;a<n.length;a++){if(!i[a])continue;let p=l.get(e.identity(i[a]));p===void 0||c.has(p)||(s[a]=p,c.add(p))}return s}function Uf(e,t,n,o,r,i,s){t.forEach((c,l)=>{if(n===null){let a=o[l],p=a==null?"":String(a);e.text(c)!==p&&e.text(c,p)}else{let a=i(e,c,n,o[l],{depth:r.depth+1,path:[...r.path,l]},s);a&&a!==c&&(t[l]=a)}})}function Hf(e,t,n,o){return n===null?e.text(t):Bn(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function cc(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 Vf(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),i=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(i,""),c=r?Wf(s):0,l=ts(s),a=t;for(;a;){let p=e.find(a,s,{includeRulesTag:!1,templateAttr:null});for(let f of p)if(e.attr(f,o.templateAttr)!=null&&!(r&&!$f(e,t,f,c))&&!(l&&!e.matches(e.parent(f),l)))return f;a=e.parent(a)}return null}function Wf(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\")r++;else if(n)i===n&&(n=null);else if(i==='"'||i==="'")n=i;else if(i==="["||i==="(")t++;else if(i==="]"||i===")")t>0&&t--;else if(t===0&&i===">")o++;else{if(t===0&&(i==="+"||i==="~"))return null;if(t===0&&/\s/.test(i)){if(!_f(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function _f(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return rc(o)||rc(r)}function rc(e){return e===">"||e==="+"||e==="~"}function $f(e,t,n,o){if(o===null)return!0;let r=n;for(let l=0;l<o;l++)if(r=e.parent(r),!r)return!1;let i=e.prop(t,"tagName");if(!i)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(i).toLowerCase())return!1;let c=new Set(sc(e,r));return sc(e,t).every(l=>c.has(l))}function sc(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Ff(e,t,n,o,r,i){let s=e.parent(o);if(s&&qf(e,t,s)&&!lc(e,s,i))return s;let c=ts(n);if(!c)throw new Jn(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let a=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,i)).filter(p=>!lc(e,p,i));if(a.length===0)throw new Jn(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(a.length>1)throw new Jn(r.path,`"${c}" matches ${a.length} containers inside this context, so the new rows have no single destination`);return a[0]}function qf(e,t,n){let o=n;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var ic=["no-data","editor-ui"];function lc(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||ic.some(i=>e.attr(o,i)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(i=>ic.includes(i)))return!0;o=e.parent(o)}return!1}function Kf(e,t,n,o,r){let i=e.children(t),s=i.map(l=>e.identity(l)),c=!1;o.forEach((l,a)=>{let p=e.identity(l),f=n+a;if(s[f]===p)return;if(!r[a]){let w=s.indexOf(p);w!==-1&&(s.splice(w,1),i.splice(w,1))}let h=Math.min(f,i.length);h<i.length?e.insertBefore(i[h],l):i.length?c?e.insertAfter(i[i.length-1],l):(e.insertAt(t,l,f),c=!0):e.insertAt(t,l,0),s.splice(h,0,p),i.splice(h,0,l)})}function zf(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((i,s)=>[e.identity(i),s])),r=[];for(let i of t){let s=o.get(e.identity(i));if(s===void 0)return!1;r.push(s)}return r.sort((i,s)=>i-s),r[r.length-1]-r[0]===r.length-1}function Gf(e,t,n,o,r){let i=null,s=r;for(let c=0;c<t.length;c++){if(!n[c]){i=t[c];continue}let l=i?e.parent(i):o;if(!l)continue;let a=i?cc(e,l,i)+1:s++;e.insertAt(l,t[c],a),i=t[c]}}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(ri(n,o,[],i),i.length)throw new or(i);qr(e,t,n,o,{depth:0,path:[]},r)}function qr(e,t,n,o,r,i={}){if(r.depth>jo)throw new ho(r.path);if(o===void 0)return t;if(typeof n=="string")return Xf(e,t,n,o,r,i);if(Array.isArray(n)){let[s,c]=n;return oi(e,t,s,c,o,r,qr,i),t}if(typeof n=="object"&&n!==null){for(let[s,c]of Object.entries(n)){let l=qr(e,t,c,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},i);l&&l!==t&&(t=l)}return t}return t}function Xf(e,t,n,o,r,i){if(n.endsWith("[]")){let l=n.slice(0,-2);return oi(e,t,l,null,o,r,qr,i),t}if(n.startsWith("@"))return fc(e,t,n.slice(1),o);let s=gn(n);if(s!==-1){let l=n.slice(0,s),a=n.slice(s+1),p=l?e.find(t,l,i):[t];return p.length===0||fc(e,p[0],a,o),t}if(n===".")return ac(e,t,o),t;let c=e.find(t,n,i);return c.length===0||ac(e,c[0],o),t}function ac(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Yf(e,t,n,o){if(e.styleVar){e.styleVar(t,n,o);return}_r(e,t,n,o)}function fc(e,t,n,o){if(Zn(n))return Yf(e,t,n,o==null?"":String(o).trim()),t;if(zo.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new rr(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(Qr.has(n)){let r=es(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function ri(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:hr([...n,i]),expected:"scalar",got:dr(r)})}):o.push({path:hr(n),expected:"array",got:dr(t)});return}t!==null&&typeof t=="object"&&o.push({path:hr(n),expected:"scalar",got:dr(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:hr(n),expected:"array",got:dr(t)});return}let r=e[1];t.forEach((i,s)=>ri(r,i,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:hr(n),expected:"object",got:dr(t)});return}for(let[r,i]of Object.entries(e))ri(i,t[r],[...n,r],o)}}}function dr(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function hr(e){return e.join(".")}function pr(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=si(t,e,n);return ii(t,e,n),{data:o,summary:n}}function si(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=>si(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,i]of Object.entries(e)){let s=si(i,t?.[r],n);s!==void 0&&(o[r]=s)}return o}}function ii(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)?ii(e[r],t[r],n):n.discarded+=mo(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>ii(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=mo(t))}}function mo(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+mo(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+mo(n),0):1}function li(e,t,n){let o=ar(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},s=new Set;for(let{name:c,rules:l}of o){if(s.add(c),!Object.prototype.hasOwnProperty.call(n,c)){i[c]={carriedOver:0,discarded:0,listItems:0};continue}let{data:a,summary:p}=pr(n[c],l);$n(e,t,l,a),i[c]=p,r.carriedOver+=p.carriedOver,r.discarded+=p.discarded,r.listItems+=p.listItems}for(let c of Object.keys(n))s.has(c)||(r.discarded+=mo(n[c]));return{totals:r,byName:i,rulesTagCount:o.length}}async function ci({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||(d=>fetch(d)),!o)throw new Error("upgrade.run requires a document context");if(e=e||jn(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:jn(o,"hyper-version"),t=t||Fr(Nn,o);let c;try{c=await i(s.href)}catch(d){throw new Uo(s.href,d)}if(!c.ok)throw new Uo(s.href,new Error(`HTTP ${c.status}`));let l=await c.text(),a=new DOMParser().parseFromString(l,"text/html"),p=jn(a,"hyper-version"),f=t,h=!1,w=ei(Nn,a);if(w){let y=await(await ti(w))(f,{fromVersion:n,toVersion:p});if(!y||typeof y!="object"||Array.isArray(y))throw new eo("transform must return a plain object map of { rulesName: data }");f=y,h=!0}let{totals:b,byName:T,rulesTagCount:g}=li(Nn,a,f);if(g===0&&Object.keys(f).length>0)throw new fr(s.href);return{html:Zf(a),fromVersion:n,toVersion:p,summary:{transformApplied:h,totals:b,byName:T}}}function Jf(e){for(let t of e.querySelectorAll("input")){let n=(t.getAttribute("type")||"").toLowerCase();n!=="file"&&(n==="checkbox"||n==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let n=[...t.options];if(!t.multiple){let o=n.findIndex(r=>r.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of n)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function Zf(e){return Jf(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
8
- `+e.documentElement.outerHTML}var Kr=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",..._l],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})}),eu=new Set(["textContent","innerText"]);function uc(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var tu=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function dc(e,t,n=Kr){if(!tu.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>o.startsWith(r)))return`attribute "${o}" can run script`;if(n.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(n.urlAttributes.includes(o)&&t!=null){let r=o==="srcset"?String(t).split(",").map(i=>i.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let i of r){let s=uc(i);if(s&&n.refusedSchemes.includes(s))return`"${s}:" URLs are not allowed in "${o}"`}}return null}function ai(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function nu(e,t){let n=ai(e,t)||"node",o=e.attr(t,"id");return o?`<${n}#${o}>`:`<${n}>`}function ou(e,t,n){let o=t;for(;o;){let r=ai(e,o);if(r&&n.refusedTargets.includes(r))return r;o=e.parent(o)}return null}function hc(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function ru(e,t){return ai(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:hc(e,t)}function su(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'")n=r;else{if(r==="/"&&e[o+1]==="*")return"comments are not allowed in a custom property value";if(r==="(")t.push(")");else if(r==="[")t.push("]");else if((r===")"||r==="]")&&t.pop()!==r)return`"${r}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function pc(e,t=Kr){let n=t.customPropertyValues,o=String(e);if(o.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let r=n.refusedCharacters.find(l=>o.includes(l));if(r)return`${JSON.stringify(r)} is not allowed in a custom property value`;let i=su(o);if(i)return i;let s=o.toLowerCase(),c=n.refusedFunctions.find(l=>new RegExp(`(^|[^a-z0-9_-])${l.replace(/[-]/g,"\\-")}\\s*\\(`).test(s));return c?`"${c}()" is not allowed in a custom property value`:null}function zr(e,t=Kr){let n=[],o=(l,a)=>(n.push({target:nu(e,l),reason:a}),!1),r=l=>{let a=ou(e,l,t);return a?o(l,`inside <${a}>, which is not content`):!0},i=l=>r(l)?hc(e,l)?o(l,"a text write here would delete the data rules tag"):!0:!1,s=(l,a,p)=>{if(!r(l))return!1;let f=dc(a,p,t);return f?o(l,f):!0};return{...e,text(l,a){if(a===void 0)return e.text(l);i(l)&&e.text(l,a)},attr(l,a,p){if(p===void 0)return e.attr(l,a);s(l,a,p)&&e.attr(l,a,p)},removeAttr(l,a){s(l,a,null)&&e.removeAttr(l,a)},styleVar(l,a,p){if((Do(e.attr(l,"style"),a)??"")!==p&&r(l)){if(!Zn(a))return o(l,`"${a}" is not a custom property`);if(p!==""){let f=pc(p,t);if(f)return o(l,f)}_r(e,l,a,p)}},prop(l,a,p){if(p===void 0)return e.prop(l,a);if(t.refusedRuleForms.includes(a))return o(l,`"@${a}" writes HTML, only text is allowed`);if(eu.has(a)){i(l)&&e.prop(l,a,p);return}s(l,a==="className"?"class":a,p)&&e.prop(l,a,p)},remove(l){if(ru(e,l)){o(l,"removing this would delete the data rules tag");return}e.remove(l)},replaceWith(l,a){return a===e.prop(l,"outerHTML")||o(l,'"@outerHTML" writes HTML, only text is allowed'),l},refusals:n,assertClean(){if(n.length)throw new sr(n.slice())}}}function mr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mc(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function fi(e,t,n,o,r={}){let i=[],s=[];function c(a,p,f){if(Array.isArray(a)){let[,h]=a;if(!Array.isArray(p)||!mr(h))return;p.forEach((w,b)=>c(h,w,[...f,b]));return}if(!(!mr(a)||!mr(p)))for(let h of Object.keys(p))Object.prototype.hasOwnProperty.call(a,h)?c(a[h],p[h],[...f,h]):i.push(mc([...f,h]))}function l(a,p,f,h){if(f!==void 0){if(typeof p=="string"){if(p.endsWith("[]")||p==="."||p.startsWith("@"))return;let w=gn(p),b=w===-1?p:p.slice(0,w);if(!b)return;e.find(a,b,r).length===0&&s.push({path:mc(h),selector:b});return}if(!Array.isArray(p)&&mr(p)&&mr(f))for(let[w,b]of Object.entries(p))l(a,b,f[w],[...h,w])}}return c(n,o,[]),l(t,n,o,[]),{unknownKeys:i,unmatched:s}}function ui(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return Bo(e,o,n)}return null}var gr={extract:(e,t,n={})=>Bn(Qn(e,n),e,t,n),apply:(e,t,n,o={})=>$n(Qn(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>Bo(Nn,e,t),findRules:(e,t)=>ui(Nn,e,t),bind:(e,t,n={})=>{let o=ui(Nn,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:()=>Bn(Qn(e,n),e,o.rules,n),set:r=>$n(Qn(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:Js,parseRelaxed:po,ruleAttrIndex:gn,splitRule:Vn,errors:Dn,DOM_PROPERTIES:Tr},di=e=>!!e&&typeof e.nodeType=="number";function gc(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=Bo(Nn,t,"api");if(!n)throw new Dn.NoRulesTag("api");return n.rules}function lu(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function cu(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function au(e,t){let n=[];for(;t!==e;){let o=t.parentNode;n.push(Array.prototype.indexOf.call(o.childNodes,t)),t=o}return n.reverse()}function fu(e,t){return t.reduce((n,o)=>n.childNodes[o],e)}function Ho(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function uu(e,t){let n=Ho(e,"option"),o=Ho(t,"option");n.forEach((l,a)=>o[a].selected=l.selected);let r=Ho(e,"input"),i=Ho(t,"input");r.forEach((l,a)=>{let p=l.type.toLowerCase();p!=="file"&&(i[a].value=l.value),(p==="checkbox"||p==="radio")&&(i[a].checked=l.checked)});let s=Ho(e,"textarea"),c=Ho(t,"textarea");s.forEach((l,a)=>c[a].value=l.value)}function hi(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:gn(e);if(n===-1)return;let o=e.slice(n+1);if(zo.has(o))throw new Dn.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>hi(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,o]of Object.entries(e))hi(o,t[n])}}function du(e,t,n){let o={templateAttr:"cms-template"},r=lu(e),i=au(r,e),s=cu(r);uu(r,s);let c=fu(s,i),l=Qn(s,{...o,_write:!0}),a=fi(l,c,t,n,o);if(a.unknownKeys.length||a.unmatched.length)throw new Dn.WriteRejected(a.unknownKeys,a.unmatched);let p=zr(l);$n(p,c,t,n,o),p.assertClean(),hi(t,n);let f=zr(Qn(r,{...o,_write:!0}));$n(f,e,t,n,o),f.assertClean()}function hu(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof Dn.WriteRefused?e.details=e.refusals:e instanceof Dn.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof Dn.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function pi(e,t){let n=di(e)?e:document,o=di(e)?t:e;return o===void 0?Bn(Qn(n),n,gc(n)):gr.bind(n,o).get()}function mi(e,t,n){try{if(!di(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=n===void 0?gc(e):gr.bind(e,n).rules;du(e,o,t)}catch(o){throw hu(o)}return e}var bc={buildForm:ns,bindFormEvents:os,scaffold:ko,morphForm:Fs,path:Ar},yc={checkForUpdate:Ks,run:ci,extractAll:Qs,shapeMatch:pr};var pu={engine:gr,cms:bc,upgrade:yc,extractData:pi,applyData:mi},mu=pu;return Sc(gu);})();
1
+ var HyperHtmlApi=(()=>{var Xr=Object.defineProperty;var kc=Object.getOwnPropertyDescriptor;var Ac=Object.getOwnPropertyNames;var Tc=Object.prototype.hasOwnProperty;var Jr=(e,t)=>{for(var n in t)Xr(e,n,{get:t[n],enumerable:!0})},Sc=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ac(t))!Tc.call(e,r)&&r!==n&&Xr(e,r,{get:()=>t[r],enumerable:!(o=kc(t,r))||o.enumerable});return e};var Nc=e=>Sc(Xr({},"__esModule",{value:!0}),e);var yu={};Jr(yu,{applyData:()=>gi,cms:()=>yc,default:()=>bu,engine:()=>gr,extractData:()=>mi,upgrade:()=>wc});var Ar={};Jr(Ar,{fromString:()=>kr,getRuleAtPath:()=>Zr,getValueAtPath:()=>zo,parseConfigKey:()=>Oc,setAtPath:()=>zn,toConfigKey:()=>vc,toString:()=>gn});function gn(e){return e.map(String).join(".")}function vc(e){return e.map(t=>typeof t=="number"?"*":String(t)).join(".")}function Oc(e){return e===""?[]:e.split(".")}function kr(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function Zr(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 zo(e,t){let n=e;for(let o of t){if(n==null)return;n=n[o]}return n}function zn(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]=zn(i[o],r,n),i}return{...e&&typeof e=="object"?e:{},[o]:zn((e||{})[o],r,n)}}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"],ko=new Set(Tr),Qr=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),io=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),yi=new Set(["checked","selected","disabled","readOnly","paused"]);function es(e,t){return t==null?yi.has(e)?!1:"":yi.has(e)?t==="false"?!1:!!t:t}function bn(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}var wi="[*]";function en(e){let t=bn(e),n=t===-1?e:e.slice(0,t),o=n.endsWith(wi),r={selector:o?n.slice(0,-wi.length):n,prop:t===-1?null:e.slice(t+1)||null};return o&&(r.all=!0),r}function ts(e){let t=0,n=null,o=-1,r=!1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=i:t===0&&s===","&&(r=!0)}return r||o===-1||!Mc(e,o+1)?null:e.slice(0,o).trim()||null}function Mc(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,i=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(i)s===i&&(i=null);else if(s==='"'||s==="'")i=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}function Ao(e,t){if(typeof e=="string")return e.endsWith("[]")?[]:Ec(e)?Ic(t,en(e).prop)?"":null:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let n={};for(let[o,r]of Object.entries(e))n[o]=Ao(r,t);return n}return""}function Ec(e){let{prop:t}=en(e);return t!==null&&!ko.has(t)}function Ic(e,t){if(!e||!t)return!1;let n=Cc(e),o=t.toLowerCase();for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]==="["){let i=n.indexOf("]",r);if(i===-1)return!1;let s=/^\s*([^\s\]=~^|*$]+)/.exec(n.slice(r+1,i));if(s&&s[1].toLowerCase()===o)return!0;r=i}return!1}function Cc(e){let t=0,n=null,o=0;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--:t===0&&(i===">"||i==="+"||i==="~"||/\s/.test(i))&&(o=r+1)}return e.slice(o)}var Sr=new WeakMap;var Rc=new Set(["checked","selected","disabled","readOnly","paused"]);function ns({rules:e,data:t,appRoot:n,cmsRoot:o}){let r=document.createDocumentFragment(),i={rules:e,appRoot:n,cmsRoot:o};return r.appendChild(rs({rule:e,value:t,path:[],ctx:i})),r}function os(e,{rules:t,getData:n,onChange:o}){e.setAttribute("data-hha-form-root",""),Ai.set(e,{rules:t,getData:n,onChange:o}),Lc()}var Ai=new WeakMap,xi=!1;function Lc(){xi||(document.addEventListener("input",ki,!0),document.addEventListener("change",ki,!0),document.addEventListener("click",Pc,!0),xi=!0)}function Ti(e){if(!(e instanceof Element))return null;let t=e.closest("[data-hha-form-root]");return t&&Ai.get(t)||null}function Pc(e){if(!(e.target instanceof Element))return;let t=e.target.closest("[data-hha-action]");if(!t||e.defaultPrevented)return;let n=Ti(t);if(!n)return;let{rules:o,getData:r,onChange:i}=n,s=t.getAttribute("data-hha-action"),l=kr(t.getAttribute("data-hha-path")||"");if(s==="scalar-array-add"){let c=zo(r(),l)||[];i(zn(r(),l,[...c,""]),{structural:!0});return}if(s==="object-array-add"){let c=Zr(o,l);if(!Array.isArray(c))return;let a=zo(r(),l)||[];i(zn(r(),l,[...a,Ao(c[1],c[0])]),{structural:!0});return}if(s==="array-remove"){if(l.length===0)return;let c=l.slice(0,-1),a=l[l.length-1],p=zo(r(),c)||[];if(typeof a!="number")return;let f=p.filter((d,w)=>w!==a);i(zn(r(),c,f),{structural:!0})}}function ki(e){let t=e.target;if(!t?.matches?.("input, textarea, select"))return;let n=Ti(t);if(!n)return;let{getData:o,onChange:r}=n,i=t.closest("[data-hha-path]");if(!i)return;let s=kr(i.getAttribute("data-hha-path")||""),l=t.type==="checkbox"?t.checked:t.value;r(zn(o(),s,l),{structural:!1})}function rs({rule:e,value:t,path:n,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?Bc({rule:e,value:t,path:n,ctx:o}):Dc({rule:e,value:t,path:n,ctx:o});if(Array.isArray(e))return Uc({rule:e,value:t,path:n,ctx:o});if(typeof e=="object"&&e!==null)return jc({rule:e,value:t,path:n,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function jc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",gn(n)),n.length>0){let i=document.createElement("div");i.className="form-section-label",i.textContent=Nr(n[n.length-1]),r.appendChild(i)}for(let[i,s]of Object.entries(e)){let l=[...n,i],c=t?.[i];r.appendChild(rs({rule:s,value:c,path:l,ctx:o}))}return r}function Dc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",gn(n));let i=document.createElement("div");i.className="field-body";let s=document.createElement("label");s.className="field-label",s.textContent=Nr(n[n.length-1]||".")+$c(e);let l=Vc(e,o.appRoot),c=Hc(l,{value:t,rule:e,path:n,appRoot:o.appRoot}),a=c.el;return a.classList.add(l.type==="textarea"?"field-textarea":"field-input"),i.appendChild(s),i.appendChild(a),r.appendChild(i),Sr.set(r,c),r}function Bc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",gn(n));let i=document.createElement("div");i.className="form-section-label",i.textContent=Nr(n[n.length-1]),r.appendChild(i);let s=Array.isArray(t)?t:[],l=document.createElement("div");r.appendChild(l),s.forEach((a,p)=>{let f=[...n,p],d=document.createElement("div");d.className="scalar-array-row",d.setAttribute("data-hha-path",gn(f));let w=document.createElement("input");w.type="text",w.className="field-input",w.value=a==null?"":String(a);let b=document.createElement("button");b.type="button",b.className="array-remove",b.textContent="\xD7",b.title="remove",b.setAttribute("data-hha-action","array-remove"),b.setAttribute("data-hha-path",gn(f)),d.appendChild(w),d.appendChild(b),l.appendChild(d)});let c=document.createElement("button");return c.type="button",c.className="array-add",c.textContent="+ add",c.setAttribute("data-hha-action","scalar-array-add"),c.setAttribute("data-hha-path",gn(n)),r.appendChild(c),r}function Uc({rule:e,value:t,path:n,ctx:o}){let[,r]=e,i=Array.isArray(t)?t:[],s=document.createElement("div");s.className="form-section",s.setAttribute("data-hha-path",gn(n));let l=document.createElement("div");l.className="form-section-label",l.textContent=Nr(n[n.length-1]),s.appendChild(l),i.forEach((a,p)=>{let f=[...n,p],d=document.createElement("div");d.className="array-card",d.setAttribute("data-hha-path",gn(f));let w=document.createElement("button");w.type="button",w.className="array-remove",w.textContent="\xD7",w.title="remove item",w.setAttribute("data-hha-action","array-remove"),w.setAttribute("data-hha-path",gn(f)),d.appendChild(w);let b=rs({rule:r,value:a,path:f,ctx:o});b.querySelector(".form-section-label")?.remove(),d.appendChild(b),s.appendChild(d)});let c=document.createElement("button");return c.type="button",c.className="array-add",c.textContent="+ add",c.setAttribute("data-hha-action","object-array-add"),c.setAttribute("data-hha-path",gn(n)),s.appendChild(c),s}function Hc(e,t){let n=Wc(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 Vc(e,t){let n=null;if(e.startsWith("@")?n=e.slice(1):n=en(e).prop,n&&Rc.has(n))return{type:"checkbox"};if(n==="innerHTML")return{type:"textarea"};let o=_c(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(l=>({value:l.getAttribute("value")||l.textContent,text:l.textContent.trim()||l.getAttribute("value")||""}))};if(r==="input"){let s=(o.getAttribute("type")||"text").toLowerCase();if(s==="checkbox"||s==="radio")return{type:"checkbox"};if(s==="number")return{type:"number"}}let i=(o.textContent||"").trim();return i.length>60||i.includes(`
2
+ `)?{type:"textarea"}:{type:"text"}}function _c(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=en(e).selector;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function Wc(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 Nr(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 $c(e){return` \xB7 ${e}`}function vr(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 ss(e){let t=new Map;return(n,o)=>{if(typeof o!="string")return vr(o,e);let r=t.get(n);if(r&&r.text===o)return r.doc;let i=vr(o,e);return t.set(n,{text:o,doc:i}),i}}function Si(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 is=()=>!1;function ls(e,t=[]){if(typeof e!="function")return is;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 s=[],l=r,c=!1;for(;l&&l.nodeType===1;){let a=n.get(l);if(a!==void 0){c=a;break}if(s.push(l),e(l,o.has(l))){c=!0;break}if(o.has(l))break;l=l.parentElement}for(let a of s)n.set(a,c);return c}}var Lu=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 Gn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var Fc="~",Ni="^";function cs(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let o=t[Fc],r=typeof o=="string"?o.split(",").map(Number):null,i=r&&typeof t[Ni]=="string"?t[Ni].split(","):null,s=f=>Number.isInteger(f)&&f>=0,l=0,c=!1,a=f=>{let d=f;for(;d>0;){let w=r[l++];if(l>r.length||!s(w))return!1;d+=w-1}return!0},p=(f,d)=>{if(c)return;if(r){let T=l++,g=r[T];if(T>=r.length||!s(g)){c=!0;return}let h=!i||i[T]===f.tagName.toLowerCase();if(!h||g!==f.children.length){let y=h&&t[d];typeof y=="string"&&y&&n.set(f,y),a(g)||(c=!0);return}}let w=t[d];typeof w=="string"&&w&&n.set(f,w);let b=f.children;for(let T=0;T<b.length;T++)p(b[T],d===""?String(T):`${d}.${T}`)};return p(e,""),n}function vi(e){return t=>{for(let n of e){let o=n(t);if(typeof o=="string"&&o!=="")return o}return null}}var dn=vi([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Or(e,t,n,o=null,r=null){let i=new Map,s=new Set,l=c=>{if(n(c))return;let a=t(c);a&&(i.has(a)?s.add(a):i.set(a,c))};if(o){let c=a=>{for(let p of a.querySelectorAll(o))l(p);for(let p of a.querySelectorAll("template"))p.content&&c(p.content)};l(e),c(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let c=a=>{l(a);let p=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let f=0;f<p.length;f++)c(p[f])};c(e)}for(let c of s)i.delete(c),r&&r.add(c),as(c);return i}function as(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var qc=new Set(["href","src","name","type","role"]),Mi=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function To(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 Oi(e){return e.replace(/\s+/g," ")}var Kc=0;function Ei({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let o=new WeakMap,r=new WeakMap;function i(O){let R=O.attributes,M=R.length;if(M===0)return{all:"",sig:O.tagName+"|"};let j=[],U="",K=[];for(let W=0;W<M;W++){let H=R[W],k=H.name;t(O,k)||j.push(k+"="+H.value),k==="class"?U=H.value.indexOf(" ")<0?H.value:H.value.split(/\s+/).filter(Boolean).sort().join(" "):qc.has(k)&&K.push(k+"="+H.value)}return j.length>1&&j.sort(),K.length>1&&K.sort(),{all:j.join(""),sig:O.tagName+"|"+U+(K.length?"|"+K.join("|"):"")}}function s(O){return O.nodeType===1&&O.tagName==="TEMPLATE"&&O.content?O.content.childNodes:O.childNodes}function l(O){let R=o.get(O);if(R)return R;if(O.nodeType===3)R={hash:"T"+To(O.nodeValue),hint:Oi(O.nodeValue).slice(0,64),sig:null,tok:null};else if(O.nodeType===8)R={hash:"C"+To(O.nodeValue),hint:"",sig:null,tok:null};else if(O.nodeType===1){let M=i(O),j=To(O.tagName+""+M.all),U="";for(let K of a(O))if(K.nodeType===1){let W=l(K);j=To(W.hash,j),U.length<64&&(U+=" "+W.hint)}else j=To(p(K),j),K.kind==="text"&&U.length<64&&(U+=K.value.slice(0,64));R={hash:"E"+j,hint:Oi(U).trim().slice(0,64),sig:M.sig,tok:null}}else R={hash:"N"+O.nodeType,hint:"",sig:null,tok:null};return o.set(O,R),R}function c(O){if(!O.tok){O.tok=new Set;for(let R of O.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))R&&O.tok.add(R)}return O.tok}function a(O){let R=r.get(O);if(R)return R;R=[];let M=null,j=()=>{M&&(M.value=M.nodes.map(U=>U.nodeValue).join(""),R.push(M),M=null)};for(let U of s(O)){if(U.nodeType===3){M||(M={kind:"text",nodes:[],value:"",parent:O,hash:void 0}),M.nodes.push(U);continue}j(),U.nodeType===8?R.push({kind:"comment",nodes:[U],value:U.nodeValue,parent:O,hash:void 0}):U.nodeType===1&&!e(U)&&R.push(U)}return j(),r.set(O,R),R}function p(O){return O.nodeType===1?l(O).hash:(O.hash===void 0&&(O.hash=(O.kind==="text"?"T":"C")+To(O.value)),O.hash)}function f(O,R){let M=c(l(O)),j=c(l(R));if(M.size===0&&j.size===0)return{coef:1,share:1};if(M.size===0||j.size===0)return null;let U=0;for(let K of M)j.has(K)&&U++;return{coef:U/Math.min(M.size,j.size),share:U/Math.max(M.size,j.size)}}function d(O,R){let M=f(O,R);return!!M&&M.coef>=.5}let w=new WeakMap;function b(O){let R=w.get(O);if(R)return R;R=[];for(let M of O.attributes)t(O,M.name)||R.push([M.namespaceURI||"",M.localName,M.value]);return R.sort((M,j)=>M[0]<j[0]?-1:M[0]>j[0]?1:M[1]<j[1]?-1:M[1]>j[1]?1:0),w.set(O,R),R}let T=new WeakMap;function g(O,R){if(O===R)return!0;if(p(O)!==p(R))return!1;let M=T.get(O);if(M&&M.has(R))return M.get(R);let j=T.get(R);if(j&&j.has(O))return j.get(O);let U=h(O,R),K=U===!0;return U===!1&&n&&n.hashRejected++,M||T.set(O,M=new WeakMap),M.set(R,K),K}function h(O,R){if(O.nodeType===1){if(R.nodeType!==1||O.tagName!==R.tagName||O.namespaceURI!==R.namespaceURI)return!1;let M=b(O),j=b(R);if(M.length!==j.length)return!1;for(let W=0;W<M.length;W++)if(M[W][0]!==j[W][0]||M[W][1]!==j[W][1]||M[W][2]!==j[W][2])return!1;let U=a(O),K=a(R);if(U.length!==K.length)return!1;for(let W=0;W<U.length;W++){if(p(U[W])!==p(K[W]))return!1;if(!g(U[W],K[W]))return Kc}return!0}return R.nodeType===1?!1:O.kind===R.kind&&O.value===R.value}let y=new WeakMap,N=new Map,x=0;function S(O){let R=y.get(O);if(R)return R;let M=p(O),j=N.get(M);j||N.set(M,j=[]);let U=j.find(K=>g(K.unit,O));return R=U?U.key:"K"+x++,U||j.push({unit:O,key:R}),y.set(O,R),R}return{meta:l,unitsOf:a,unitHash:p,similar:d,score:f,childrenOf:s,equalUnits:g,exactUnitKey:S,ignored:e}}var Ii=16,zc=2e3,Gc=3,fs={align:0,certifyVisited:0,certifyScheduled:0};function us(e,t,n){let{meta:o,unitsOf:r,unitHash:i,similar:s,score:l,childrenOf:c,equalUnits:a,ignored:p}=n.analyzer,f=n.baseId||(()=>null),d=n.sideId||(()=>null),w=n.baseKey||(()=>null),b=n.sideKey||(()=>null),T=n.baseDropped||new Set,g=n.sideDropped||new Set,h=n.stats||null,y=h?new Set:null,N=h?new Set:null,x=new Map,S=new Map,O=new Set,R=new Map,M=new Set,j=new Set,U=new Set,K=[],W=[],H=[],k=[],A=zc,J=new Map,_=new Map,F=(V,Z)=>{x.set(V,Z),S.set(Z,V)},Oe=new Set,Ce=new Set,De=null,pe=V=>{let Z=V.nodeType?V.parentNode:V.parent;if(!Z||Z.nodeType!==11)return Z;if(!De){De=new WeakMap;let be=ke=>{for(let we of ke.querySelectorAll("template"))we.content&&(De.set(we.content,we),be(we.content))};for(let ke of[e,t])be(ke.tagName==="TEMPLATE"&&ke.content?ke.content:ke)}return De.get(Z)||null},Te=(V,Z)=>{for(let be=pe(V);be&&!Oe.has(be);be=pe(be))Oe.add(be);for(let be=pe(Z);be&&!Ce.has(be);be=pe(be))Ce.add(be)},ze=V=>{for(let Z=pe(V);Z;Z=pe(Z))if(x.has(Z))return j.has(Z);return!1},Me=V=>{for(let Z=pe(V);Z;Z=pe(Z)){let be=S.get(Z);if(be!==void 0)return j.has(be)}return!1},v=V=>!!V&&V.nodeType===1,G=(V,Z)=>{let be=R.get(V);return!!be&&be.has(Z)},ue=V=>Mi.has(V.tagName),ae=n.comparisons||n.scope,Pe=(V,Z)=>{if(ae){if(ae.same.get(V)===Z)return!0;if(ae.differ.get(V)===Z)return!1}if(!V.isEqualNode(Z))return!1;if(V.tagName==="TEMPLATE")return a(V,Z);let be=V.getElementsByTagName("template");if(be.length===0)return!0;let ke=Z.getElementsByTagName("template");if(be.length!==ke.length)return!1;for(let we=0;we<be.length;we++)if(!a(be[we],ke[we]))return!1;return!0},He=(V,Z)=>{let be=f(V);if(!be)return!0;let ke=d(Z);return!ke||be===ke},ve=V=>{let Z=w(V);return Z&&n.baseIndex.get(Z)===V&&!g.has(Z)?Z:null},Ze=V=>{let Z=b(V);return Z&&n.sideIndex.get(Z)===V&&!T.has(Z)?Z:null},Je=(V,Z)=>{let be=ve(V);if(!be)return!0;let ke=Ze(Z);return!ke||be===ke},pt=globalThis.__hyperMorphProfile,Ye=pt?performance.now():0;pt&&!n.scope&&(o(e),o(t),pt.meta=(pt.meta||0)+(performance.now()-Ye),Ye=performance.now()),F(e,t);let dt=new Set;for(let[V,Z]of n.baseIndex){let be=n.sideIndex.get(V);be&&be.tagName===Z.tagName&&!x.has(Z)&&!S.has(be)&&(F(Z,be),Te(Z,be),dt.add(Z))}if(dt.size){let V=[];if(n.scope)for(let we of n.scope.chain)dt.has(we)&&V.push(we);let Z=[n.scope?n.scope.root:e];for(;Z.length;){let we=Z.pop();dt.has(we)&&V.push(we);let te=c(we);for(let re=te.length-1;re>=0;re--)te[re].nodeType===1&&Z.push(te[re])}let be=new Set;for(let we=V.length-1;we>=0;we--){let te=V[we];n.scope&&n.scope.onChain.has(te)?be.add(te):Pt(te,x.get(te),be)?(j.add(te),U.add(te),h&&h.certificationPairs++):be.add(te)}let ke=new Set;for(let we of V)j.has(we)&&!ke.has(we)&&St(we,ke)}n.scope&&n.scope.head&&Ft(n.scope.head[0],n.scope.head[1]);function St(V,Z){let be=[V];for(;be.length;){let ke=be.pop();if(!Z.has(ke)){Z.add(ke),I(ke);for(let we of r(ke))v(we)&&x.has(we)&&be.push(we)}}}k.push([e,t]);for(let[V,Z]of x)v(V)&&V!==e&&k.push([V,Z]);return Ot(),vt(),pt&&(pt.align=(pt.align||0)+(performance.now()-Ye)),{map:x,reverse:S,moved:M,identical:j,pairIdenticalChildren:I,weak:O,unpair:bt,rematch:vt,insertedByHash:At,refused:N,identityPaired:dt};function vt(){Se(),Ot();for(let V=0;V<H.length;){let Z=H.length;Nt(V,Z),V=Z,Ot(),Se(),Ot()}}function bt(V){let Z=x.get(V);if(!Z)return;R.has(V)||R.set(V,new Set),R.get(V).add(Z);let be=(we,te)=>{x.delete(we),S.delete(te),M.delete(we),j.delete(we),O.delete(we),U.delete(we)},ke=(we,te)=>{for(let re of r(we)){let q=x.get(re);!q||dt.has(re)||!(v(q)?te.contains(q):te.contains(q.nodes[0]))||(be(re,q),v(re)&&ke(re,q))}};be(V,Z),v(V)&&ke(V,Z),K.push(V),W.push(Z)}function At(){let V=new Map;for(let Z of new Set(W)){if(S.has(Z))continue;let be=o(Z).hash;V.has(be)||V.set(be,[]),V.get(be).push(Z)}return V}function Ot(){for(;k.length;){let[V,Z]=k.shift();x.get(V)!==Z||U.has(V)||j.has(V)||nn(V,Z)}}function Bt(V,Z){if(!ue(V))for(let be of r(V))v(be)&&(Z.push(be),Bt(be,Z))}function nn(V,Z){U.add(V);let be=r(V),ke=r(Z);fs.align+=be.length+ke.length,J=new Map,_=new Map;for(let le=0;le<be.length;le++)J.set(be[le],le);for(let le=0;le<ke.length;le++)_.set(ke[le],le);if(V.tagName==="HTML")for(let le of["HEAD","BODY"]){let Ne=be.find(je=>v(je)&&je.tagName===le),Le=ke.find(je=>v(je)&&je.tagName===le);Ne&&Le&&!x.has(Ne)&&!S.has(Le)&&F(Ne,Le)}for(let le=0;le<be.length&&le<ke.length;le++){let Ne=be[le],Le=ke[le];x.has(Ne)||S.has(Le)||(v(Ne)?v(Le)&&Ne.tagName===Le.tagName&&Pe(Ne,Le)&&Ft(Ne,Le):!v(Le)&&Ne.kind===Le.kind&&Ne.value===Le.value&&Ft(Ne,Le))}fe(be,ke);let we=be.filter(le=>!x.has(le)),te=ke.filter(le=>!S.has(le));we.length&&te.length&&(an(we,te),P(we,te),$(we,te,be,ke),me(be,ke));let re=!1,q=!1;for(let le of be){if(!x.has(le)){v(le)&&(K.push(le),Bt(le,K),re=!0);continue}v(le)&&!j.has(le)&&k.push([le,x.get(le)])}for(let le of ke)!S.has(le)&&v(le)&&(W.push(le),Bt(le,W),q=!0);re&&q&&H.push([V,Z])}function Nt(V,Z){for(let be=V;be<Z;be++){let[ke,we]=H[be];if(x.get(ke)!==we)continue;let te=r(ke),re=r(we),q=new Map,le=new Map,Ne=null;for(let Le of te)v(Le)&&(x.has(Le)?Ne=Le:(q.has(Ne)||q.set(Ne,[]),q.get(Ne).push(Le)));Ne=null;for(let Le of re)v(Le)&&(S.has(Le)?Ne=S.get(Le):(le.has(Ne)||le.set(Ne,[]),le.get(Ne).push(Le)));for(let[Le,je]of q){let Ae=le.get(Le);if(!(!Ae||je.length!==Ae.length)&&je.every((Ge,et)=>Ae[et].tagName===Ge.tagName&&He(Ge,Ae[et])&&!G(Ge,Ae[et])))for(let Ge=0;Ge<je.length;Ge++)$t(je[Ge],Ae[Ge])}}}function $t(V,Z){F(V,Z),O.add(V),k.push([V,Z]),Ot()}function an(V,Z){let be=So(V,i),ke=So(Z,i),we=new Map;for(let te of Z){let re=i(te);ke.get(re)===1&&we.set(re,te)}for(let te of V){if(x.has(te))continue;let re=i(te);if(be.get(re)!==1)continue;let q=we.get(re);q&&!S.has(q)&&a(te,q)&&Ft(te,q)}}function Pt(V,Z,be){let ke=[[V,Z]];for(;ke.length;){let[we,te]=ke.pop();if(fs.certifyVisited++,h&&h.certificationVisited++,we.nodeType!==te.nodeType)return!1;if(we.nodeType===3||we.nodeType===8){if(we.nodeValue!==te.nodeValue)return!1;continue}if(we.nodeType!==1){if(!we.isEqualNode(te))return!1;continue}if(we.tagName!==te.tagName||we.namespaceURI!==te.namespaceURI||p(we)!==p(te))return!1;let re=we.attributes,q=te.attributes;if(re.length!==q.length)return!1;for(let Ae=0;Ae<re.length;Ae++){let Ge=re[Ae];if(te.getAttributeNS(Ge.namespaceURI,Ge.localName)!==Ge.value)return!1}let le=x.get(we);if(le!==void 0&&le!==te)return!1;let Ne=S.get(te);if(Ne!==void 0&&Ne!==we)return!1;if(we!==V){if(j.has(we))continue;if(be.has(we))return!1}let Le=c(we),je=c(te);if(Le.length!==je.length)return!1;fs.certifyScheduled+=Le.length;for(let Ae=Le.length-1;Ae>=0;Ae--)ke.push([Le[Ae],je[Ae]])}return!0}function Jt(V,Z){return!v(V)||!(Oe.has(V)||Ce.has(Z))?!0:!!Y(V,Z)||!(ve(V)||Ze(Z))}function Ft(V,Z){if(v(V)&&(Oe.has(V)||Ce.has(Z))){let be=Y(V,Z);if(!be){if(ve(V)||Ze(Z))return;F(V,Z),k.push([V,Z]);return}for(let ke=0;ke<be.length;ke+=2){let we=be[ke],te=be[ke+1],re=x.get(we);re!==void 0&&re!==te&&on(we,re);let q=S.get(te);q!==void 0&&q!==we&&on(q,te),x.get(we)===te&&(M.delete(we),O.delete(we),j.add(we),U.add(we))}}m(V,Z)}function on(V,Z){x.delete(V),S.delete(Z),M.delete(V),j.delete(V),O.delete(V),U.delete(V)}function Y(V,Z){let be=[V,Z,!1],ke=[];for(;be.length;){let we=be.pop(),te=be.pop(),re=be.pop(),q=x.get(re),le=S.get(te);if(re!==V&&(q!==void 0&&q!==te&&dt.has(re)||le!==void 0&&le!==re&&dt.has(le)))return null;if(!(q===te&&j.has(re))&&((q!==void 0||le!==void 0)&&ke.push(re,te),!!v(re))){if(we||q!==void 0&&q!==te||le!==void 0&&le!==re){let Ne=r(re),Le=r(te);for(let je=0;je<Ne.length&&je<Le.length;je++)be.push(Ne[je],Le[je],!0)}else if(Oe.has(re)||Ce.has(te)){let Ne=re.tagName==="TEMPLATE"?re.content:re,Le=te.tagName==="TEMPLATE"?te.content:te;for(let je=Ne.firstElementChild,Ae=Le.firstElementChild;je&&Ae;){if(p(je)){je=je.nextElementSibling;continue}if(p(Ae)){Ae=Ae.nextElementSibling;continue}(x.has(je)||S.has(Ae)||Oe.has(je)||Ce.has(Ae))&&be.push(je,Ae,!1),je=je.nextElementSibling,Ae=Ae.nextElementSibling}}}}return ke}function m(V,Z){F(V,Z),j.add(V),v(V)&&U.add(V)}function I(V){let Z=x.get(V);if(!Z||!v(V))return;let be=r(V),ke=r(Z);for(let we=0;we<be.length&&we<ke.length;we++)x.has(be[we])||m(be[we],ke[we])}function P(V,Z){let be=re=>v(re)&&!ue(re)?o(re).sig+""+o(re).hint:null,ke=So(V,be),we=So(Z,be),te=new Map;for(let re of Z){let q=be(re);q!=null&&we.get(q)===1&&te.set(q,re)}for(let re of V){if(x.has(re))continue;let q=be(re);if(q==null||ke.get(q)!==1)continue;let le=te.get(q);le&&!S.has(le)&&He(re,le)&&F(re,le)}}function $(V,Z,be,ke){let we=new Map;for(let re of Z){if(!v(re)||S.has(re)||ue(re))continue;let q=o(re).sig;we.has(q)||we.set(q,[]),we.get(q).push({el:re,index:_.get(re)})}let te=[];for(let re of V){if(x.has(re)||!v(re)||ue(re))continue;let q=we.get(o(re).sig);if(!q||!q.length)continue;let le=J.get(re),Ne=q.filter(Le=>!S.has(Le.el)).map(Le=>({c:Le,d:Math.abs(Le.index-le)}));Ne.sort((Le,je)=>Le.d-je.d),Ne.length>Ii&&(Ne=Ne.slice(0,Ii));for(let{c:Le,d:je}of Ne){if(!He(re,Le.el))continue;let Ae=l(re,Le.el);Ae&&Ae.coef>=.5&&te.push({b:re,s:Le.el,coef:Ae.coef,share:Ae.share,d:je,bi:le})}}if(te.sort((re,q)=>q.coef-re.coef||q.share-re.share||re.d-q.d||re.bi-q.bi),h&&te.length>1){let re=new Map;for(let q of te){let le=re.get(q.b);le?le.coef===q.coef&&(le.share===q.share?le.strict++:le.loose++):re.set(q.b,{coef:q.coef,share:q.share,strict:0,loose:0})}for(let[q,le]of re)y.has(q)||!(le.strict||le.loose)||(y.add(q),le.strict?h.similarTiesStrict++:h.similarTiesLoose++)}for(let re of te)!x.has(re.b)&&!S.has(re.s)&&F(re.b,re.s)}function Q(V,Z){return v(V)!==v(Z)?!1:v(V)?V.tagName!==Z.tagName||!He(V,Z)?!1:ue(V)||o(V).hint===""||o(Z).hint===""?!0:s(V,Z):V.kind===Z.kind}function B(V,Z){let be=(we,te)=>{let re=te===null?-1:we===Z?_.get(te):J.get(te),q=we[re+1];return q&&!v(q)?q:null},ke=null;for(let we of V){if(v(we)){ke=we;continue}if(x.has(we))continue;let te=ke===null?null:x.get(ke);if(ke!==null&&!te)continue;let re=be(Z,te);re&&!S.has(re)&&re.kind===we.kind&&F(we,re)}}function me(V,Z){B(V,Z);let be=xe(V,Z),ke=(te,re)=>v(te)&&o(te).hint!==""&&o(re).hint===""&&!!re.querySelector("br")&&!be(te,re),we=0;for(let te of V){if(x.has(te)){let q=_.get(x.get(te));q!==void 0&&q>=we&&(we=q+1);continue}let re=0;for(let q=we;q<Z.length&&re<Gc;q++){let le=Z[q];if(!S.has(le)&&(re++,Q(te,le)&&!G(te,le)&&!ke(te,le))){F(te,le),v(te)&&(o(te).hint===""||o(le).hint==="")&&O.add(te),we=q+1;break}}}fe(V,Z)}function xe(V,Z){let be=(ke,we,te)=>{for(let re=we-1;re>=0;re--)if(v(ke[re])&&te(ke[re]))return ke[re];return null};return(ke,we)=>{let te=J.get(ke),re=_.get(we);if(te===re)return!0;let q=be(V,te,Ne=>x.has(Ne)),le=be(Z,re,Ne=>S.has(Ne));return q?x.get(q)===le:!le}}function fe(V,Z){let be=V.filter(q=>v(q)&&!x.has(q)),ke=Z.filter(q=>v(q)&&!S.has(q));if(!be.length||!ke.length)return;let we=So(be,q=>q.tagName),te=So(ke,q=>q.tagName),re=xe(V,Z);for(let q of be){let le=q.tagName;if(we.get(le)!==1||te.get(le)!==1)continue;let Ne=ke.find(Le=>Le.tagName===le);Ne&&!S.has(Ne)&&re(q,Ne)&&He(q,Ne)&&!G(q,Ne)&&(a(q,Ne)?Ft(q,Ne):(F(q,Ne),O.add(q)))}}function Se(){let V=new Map;for(let q of O)if(v(q)&&v(x.get(q))){let le=o(q).hash;V.has(le)||V.set(le,[]),V.get(le).push(q)}if(V.size)for(let q of W){if(S.has(q)||!v(q)||Me(q))continue;let le=V.get(o(q).hash),Ne=le&&le.find(Le=>O.has(Le)&&!G(Le,q)&&He(Le,q)&&Je(Le,q)&&a(Le,q)&&Jt(Le,q));Ne&&(bt(Ne),Ft(Ne,q),Te(Ne,q),M.add(Ne))}let Z=new Map,be=new Map,ke=new Map;for(let q of O){let le=x.get(q);v(q)&&v(le)&&ke.set(le,q)}let we=(q,le)=>{if(!S.has(q))return!Me(q);let Ne=ke.get(q);return Ne===S.get(q)&&Ne!==le&&!Ne.contains(le)},te=q=>{if(S.has(q)){let le=ke.get(q);ke.delete(q),bt(le)}};for(let q of[...W,...ke.keys()]){if(S.has(q)&&!ke.has(q))continue;let le=o(q).hash;if(Z.has(le)||Z.set(le,[]),Z.get(le).push(q),ue(q))continue;let Ne=o(q).sig;be.has(Ne)||be.set(Ne,[]),be.get(Ne).push(q)}let re=new Set;for(let q of O){let le=x.get(q);!v(q)||!v(le)||ue(q)||o(q).hint===""||o(le).hint===""||s(q,le)||re.add(q)}for(let q of[...K,...re]){let le=x.get(q);if(le?!(O.has(q)&&re.has(q)):ze(q))continue;let Ne=et=>{le&&bt(q),te(et)},Le=Z.get(o(q).hash);if(Le){let et=Le.find(Qe=>Qe!==le&&we(Qe,q)&&!G(q,Qe)&&Je(q,Qe)&&a(q,Qe)&&Jt(q,Qe));if(et){Ne(et),Ft(q,et),Te(q,et),M.add(q);continue}}if(ue(q)||A<=0)continue;let je=be.get(o(q).sig);if(!je)continue;let Ae=null,Ge=0;for(let et of je)if(!(et===le||!we(et,q)||!He(q,et)||!Je(q,et)||G(q,et))&&(A--<=0||s(q,et)&&(Ge++,Ae=et,Ge>1)))break;Ge>1&&N&&N.add(q),Ge===1&&(Ne(Ae),F(q,Ae),Te(q,Ae),M.add(q),k.push([q,Ae]))}}}function So(e,t){let n=new Map;for(let o of e){let r=t(o);r!=null&&n.set(r,(n.get(r)||0)+1)}return n}var Yc={diff:0},Ci=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,Xc=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,Jc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,Zc=/\P{M}\p{M}*/gu;function Qc(e){if(e==="")return[];if(Ci){let n=[];for(let o of Ci.segment(e))n.push(o.segment);return n}let t=[];for(let n of e.match(Jc))if(Xc.test(n))for(let o of n.match(Zc))t.push(o);else t.push(n);return t}var ea=/^[  ]+$/,ta=e=>ea.test(e)?" ".repeat(e.length):e,Yn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),wt="",ds=e=>e.every(t=>Yn(t)||t.k===wt),na=/^[\x00-\x7f\u00A0]*$/,oa=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function ra(e){return e===""?[]:e.match(oa)}function tn(e,t=!1){return(t?ra(e):Qc(e)).map(n=>({k:ta(n),raw:n,len:n.length}))}var hn=(...e)=>e.every(t=>na.test(t));function hs(e,t,n){let o=e.length,r=t.length,i=Math.min(o+r,n),s=i+1,l=new Int32Array(2*i+3),c=[],a=o===0&&r===0;for(let w=0;w<=i&&!a;w++){c.push(l.slice(s-w,s+w+1));for(let b=-w;b<=w;b+=2){let T;b===-w||b!==w&&l[s+b-1]<l[s+b+1]?T=l[s+b+1]:T=l[s+b-1]+1;let g=T-b,h=T;for(;T<o&&g<r&&e[T].k===t[g].k;)T++,g++;if(Yc.diff+=1+T-h,l[s+b]=T,T>=o&&g>=r){a=!0;break}}}if(!a)return null;let p=[],f=o,d=r;for(let w=c.length-1;w>0;w--){let b=c[w],T=f-d,g=T+w,h=T===-w||T!==w&&b[g-1]<b[g+1]?T+1:T-1,y=b[h+w],N=y-h;for(;f>y&&d>N;)p.push([0,f-1,d-1]),f--,d--;f===y?(p.push([1,f,d-1]),d--):(p.push([-1,f-1,d]),f--)}for(;f>0&&d>0;)p.push([0,f-1,d-1]),f--,d--;return p.reverse(),p}function sa(e,t,n){let o=f=>f.k===wt;if(!e.some(o)&&!t.some(o))return hs(e,t,n);let r=[],i=[];for(let f=0;f<e.length;f++)o(e[f])||r.push(f);for(let f=0;f<t.length;f++)o(t[f])||i.push(f);let s=hs(r.map(f=>e[f]),i.map(f=>t[f]),n);if(!s)return null;let l=[],c=0,a=0,p=(f,d)=>{for(;c<f&&a<d&&e[c].k===t[a].k;)l.push([0,c++,a++]);let w=hs(e.slice(c,f),t.slice(a,d),n);if(!w)return!1;for(let[b,T,g]of w)l.push([b,T+c,g+a]);return c=f,a=d,!0};for(let[f,d,w]of s)if(f===0){if(!p(r[d],i[w]))return null;l.push([0,c,a]),c++,a++}return p(e.length,t.length)?l:null}function _n(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 s=e.slice(r,e.length-i),l=t.slice(r,t.length-i),c=ua(s,l)?null:sa(s,l,n);if(!c){let h=s.length||l.length?[{bs:r,be:r+s.length,toks:l}]:[];return{hunks:h,cosmetic:o,coarse:!0,parts:h.map(y=>({...y,gap:[],group:0})),cosmeticEq:o}}let a=[],p=(h,y)=>{s[h].raw!==l[y].raw&&o.push({bi:r+h,tok:l[y]})},f=null,d=[],w=0,b=0,T=()=>{f&&a.push(f),f=null;for(let[h,y]of d)p(h,y);d=[],w++};for(let[h,y,N]of c){if(h===0){f&&Yn(s[y])&&!s[y].k.includes(`
3
+ `)?d.push([y,N]):(T(),p(y,N)),b=y+1;continue}(!f||d.length)&&(f&&a.push(f),f={bs:r+b,be:r+b,toks:[],gap:d.map(([x,S])=>({bi:r+x,tok:l[S]})),group:w},d=[]),h===-1?(f.be=r+b+1,b=y+1):f.toks.push(l[N])}T(),ia(a,e);let g=ms(a);return{hunks:g.hunks,cosmetic:o.concat(g.cosmetic),parts:a,cosmeticEq:o}}function ia(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===wt&&t[o.bs].k===wt;)o.toks=[...o.toks.slice(1),o.toks[0]],o.bs++,o.be++}else for(;o.be+1<r&&o.be<t.length&&t[o.bs].k===wt&&t[o.be].k===wt;)o.bs++,o.be++}}function ms(e,t=()=>!1){let n=[],o=[],r=null,i=-1;for(let s of e){let l=t(s);if(r&&!r.alone&&!l&&s.group===i){r.be=s.be;for(let c of s.gap)r.toks.push(c.tok);for(let c of s.toks)r.toks.push(c);continue}r&&n.push({bs:r.bs,be:r.be,toks:r.toks});for(let c of s.gap)o.push(c);r={bs:s.bs,be:s.be,toks:s.toks.slice(),alone:l},i=s.group}return r&&n.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:n,cosmetic:o}}var la=(e,t)=>e.bs===t.bs&&e.be===t.be&&ys(e.toks,t.toks);function bs(e,t,n){let o=p=>f=>p.some(d=>la(f,d)),r=ms(e.parts,o(t.parts)),i=ms(t.parts,o(e.parts)),s=e.cosmeticEq.concat(r.cosmetic),l=t.cosmeticEq.concat(i.cosmetic),[c,a]=n?ca(r.hunks,i.hunks,n,s,l):[r.hunks,i.hunks];return{lh:c,rh:a,cosL:s,cosR:l}}function ca(e,t,n,o,r){let i=(b,T)=>b.k===T.k&&b.raw===T.raw,s=[{list:e.map(b=>({...b})),resp:new Set(o.map(b=>b.bi)),raw:new Map(o.map(b=>[b.bi,b.tok]))},{list:t.map(b=>({...b})),resp:new Set(r.map(b=>b.bi)),raw:new Map(r.map(b=>[b.bi,b.tok]))}],l=b=>b.bs===b.be,c=(b,T,g,h)=>{let y=b.list[T];if(!l(y))return h(y)===g?y.toks:null;let N=T?b.list[T-1].be:0,x=T+1<b.list.length?b.list[T+1].bs:n.length;if(g<N||g>x)return null;let S=y.toks,O=y.bs;for(;O>g;){let R=S[S.length-1];if(!i(R,n[O-1])||b.resp.has(O-1))return null;S=[R,...S.slice(0,-1)],O--}for(;O<g;){if(!i(S[0],n[O])||b.resp.has(O))return null;S=[...S.slice(1),S[0]],O++}return S},a=(b,T,g,h,y,N)=>{let x=b.list[T],S=y?g.slice(g.length-h):g.slice(0,h),O=y?g.slice(0,g.length-h):g.slice(h),R={bs:N,be:N,toks:S};if(l(x)){if(!O.length){b.list[T]=R;return}let j={bs:N,be:N,toks:O};y&&(j.lead=!0),b.list.splice(T,1,...y?[j,R]:[R,j]);return}let M={bs:x.bs,be:x.be,toks:O};b.list.splice(T,1,...y?[M,R]:[R,M])},p=(b,T,g,h,y)=>{let N=b.list[T],x=y?g.slice(g.length-h):g.slice(0,h),S=y?g.slice(0,g.length-h):g.slice(h),O={bs:N.bs,be:N.be,toks:x};if(!S.length){b.list[T]=O;return}let R=y?{bs:N.bs,be:N.bs,toks:S,lead:!0}:{bs:N.be,be:N.be,toks:S};b.list.splice(T,1,...y?[R,O]:[O,R])},f=(b,T,g,h)=>{let y=b.list[T],N=g.list[h],x=y.be,S=N.bs;if(x>=S||T+1<b.list.length&&b.list[T+1].bs<=N.be||h>0&&g.list[h-1].be>=y.bs)return!1;for(let _=x;_<S;_++)if(!Yn(n[_])||n[_].k.includes(`
4
+ `))return!1;let O=_=>n.slice(x,S).map((F,Oe)=>_.raw.get(x+Oe)||F),R=[...y.toks,...O(b)],M=[...O(g),...N.toks],j=(_,F,Oe)=>F>=0&&F+Oe.length<=_.length&&Oe.every((Ce,De)=>_[F+De].k===Ce.k),U=(_,F,Oe)=>ds(_)&&n.slice(F,Oe).some(Ce=>!Yn(Ce)),K=_=>_.some(F=>!Yn(F)),W,H,k,A;if(l(y)&&K(y.toks)&&j(M,0,y.toks)){let _=M.slice(y.toks.length);U(_,x,N.be)||(W=x,H=y.toks,k=M.slice(0,y.toks.length),A=[null,{bs:x,be:N.be,toks:_}])}if(W===void 0&&l(N)&&K(N.toks)){let _=R.length-N.toks.length,F=R.slice(0,_);j(R,_,N.toks)&&!U(F,y.bs,S)&&(W=S,H=R.slice(_),k=N.toks,A=[{bs:y.bs,be:S,toks:F},null])}if(W===void 0)return!1;let J=_=>_&&(_.bs<_.be||_.toks.length);return b.list.splice(T,1,...[A[0],{bs:W,be:W,toks:H}].filter(J)),g.list.splice(h,1,...[{bs:W,be:W,toks:k},A[1]].filter(J)),!0},d=s[0],w=s[1];for(let b=0;b<64;b++){let T=!1;e:for(let g=0;g<d.list.length;g++)for(let h=0;h<w.list.length;h++){let y=d.list[g],N=w.list[h];if(!(y.bs===N.bs&&y.be===N.be&&ys(y.toks,N.toks))){for(let x of[!0,!1]){let S=R=>x?R.be:R.bs,O=l(y)?[S(N),y.bs]:[S(y)];for(let R of O){let M=c(d,g,R,S),j=M&&c(w,h,R,S);if(!j)continue;let U=(A,J)=>x?A[A.length-1-J]:A[J],K=0;for(;K<M.length&&K<j.length&&U(M,K).k===U(j,K).k;)K++;if(!K)continue;let W=x?M.slice(0,M.length-K):M.slice(K),H=x?j.slice(0,j.length-K):j.slice(K);if(!(K<M.length&&K<j.length&&!ds(W)&&!ds(H)&&(l(y)&&l(N)||y.bs===N.bs&&y.be===N.be)||!(x?M.slice(M.length-K):M.slice(0,K)).some(A=>!Yn(A)))){if(K===M.length&&K===j.length&&l(y)&&l(N)){if(y.bs===R&&N.bs===R)continue;d.list[g]={bs:R,be:R,toks:M},w.list[h]={bs:R,be:R,toks:j}}else!l(y)&&y.bs===N.bs&&y.be===N.be?(p(d,g,M,K,x),p(w,h,j,K,x)):(a(d,g,M,K,x,R),a(w,h,j,K,x,R));T=!0;break e}}}if(f(d,g,w,h)||f(w,h,d,g)){T=!0;break e}}}if(!T)break}return[d.list,w.list]}var aa=48,fa=.3;function ua(e,t){let n=e.filter(s=>!Yn(s)),o=t.filter(s=>!Yn(s));if(Math.min(n.length,o.length)<aa)return!1;let r=new Map;for(let s of n)r.set(s.k,(r.get(s.k)||0)+1);let i=0;for(let s of o){let l=r.get(s.k);l>0&&(i++,r.set(s.k,l-1))}return i/Math.min(n.length,o.length)<fa}var da=(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},ys=(e,t)=>e.length===t.length&&e.every((n,o)=>n.k===t[o].k);function Ri(e,t,n,o="remote"){let r=_n(e,t),i=_n(e,n),{lh:s,rh:l,cosL:c,cosR:a}=bs(r,i,e),p=v=>v.bs===v.be,f=v=>v.toks.some(G=>typeof G.k=="string"),d=v=>p(v)&&!f(v),w=(v,G)=>G.bs<v.be&&v.bs<G.be,b=(v,G)=>!w(v,G)&&G.bs<=v.be&&v.bs<=G.be&&(p(v)&&f(v)||p(G)&&f(G))&&!(p(v)&&p(G)),T=(v,G)=>v.bs===G.bs&&v.be===G.be&&ys(v.toks,G.toks),g=[],h=new Set;for(let v of s){let G=l.find(ue=>!h.has(ue)&&T(v,ue));G?(h.add(G),g.push({bs:v.bs,be:v.be,side:"both",l:v,r:G,toks:v.toks})):g.push({bs:v.bs,be:v.be,side:"L",l:v,toks:v.toks,lead:!!v.lead})}for(let v of l)h.has(v)||g.push({bs:v.bs,be:v.be,side:"R",r:v,toks:v.toks,lead:!!v.lead});g.sort((v,G)=>v.bs-G.bs||v.be-G.be||G.lead-v.lead);let y=0,N=0;for(let v of g)v.side==="both"&&(y+=v.toks.length-(v.be-v.bs));let x=g.map((v,G)=>G),S=v=>x[v]===v?v:x[v]=S(x[v]),O=(v,G)=>(v=S(v),G=S(G),v===G?!1:(x[v]=G,!0)),R=g.map(v=>da({bs:v.bs,be:v.be,toks:v.toks},e)),M={L:new Map,R:new Map};g.forEach((v,G)=>{let ue=v.side==="both"?["L","R"]:[v.side];for(let ae of ue)for(let Pe of R[G])M[ae].has(Pe)||M[ae].set(Pe,[]),M[ae].get(Pe).push(G)});for(let v of[M.L,M.R])for(let G of v.values())for(let ue=1;ue<G.length;ue++)O(G[0],G[ue]);for(let v=0;v<g.length;v++)for(let G=v+1;G<g.length;G++){let ue=g[v],ae=g[G];ue.side===ae.side&&ue.side!=="both"||ue.bs>ae.be||(w(ue,ae)||b(ue,ae)?O(v,G):ue.bs===ae.bs&&p(ue)&&p(ae)&&N++)}let j=(v,G)=>{let ue=v==="L"?s:l;for(let ae of ue)if(ae.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===G.el))return ae.bs;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="close"&&e[ae].k.el===G.el)return ae;return-1};g.forEach((v,G)=>{if(!(!d(v)||v.side==="both"))for(let ue of v.toks){if(ue.kind!=="open")continue;let ae=j(v.side,ue.k);if(ae<=v.bs)continue;let Pe=new Uint8Array(ae-v.bs),He=[];if(g.forEach((ve,Ze)=>{if(!(ve.side===v.side||p(ve))&&ve.bs<ae&&ve.be>v.bs){He.push(Ze);for(let Je=Math.max(ve.bs,v.bs);Je<Math.min(ve.be,ae);Je++)Pe[Je-v.bs]=1}}),He.length&&Pe.every(ve=>ve===1))for(let ve of He)O(G,ve)}});let U=!0;for(;U;){U=!1;let v=new Map;g.forEach((G,ue)=>{let ae=S(ue),Pe=v.get(ae)||{bs:G.bs,be:G.be,L:!1,R:!1};Pe.bs=Math.min(Pe.bs,G.bs),Pe.be=Math.max(Pe.be,G.be),G.side!=="R"&&(Pe.L=!0),G.side!=="L"&&(Pe.R=!0),v.set(ae,Pe)}),g.forEach((G,ue)=>{for(let[ae,Pe]of v){if(S(ue)===S(ae)||!(Pe.L&&Pe.R))continue;let He=G.bs<Pe.be&&G.be>Pe.bs,ve=p(G)&&f(G)&&(G.bs===Pe.be||G.bs===Pe.bs);(He||ve)&&O(ue,ae)&&(U=!0)}})}let K=new Map;g.forEach((v,G)=>{let ue=S(G);K.has(ue)||K.set(ue,[]),K.get(ue).push(v)});let W=[];for(let v of K.values()){let G=v.some(ae=>ae.side==="L"),ue=v.some(ae=>ae.side==="R");if(G&&ue){let ae=Math.min(...v.map(Ze=>Ze.bs)),Pe=Math.max(...v.map(Ze=>Ze.be)),He=v.filter(Ze=>Ze.side!=="R").map(Ze=>Ze.l).sort((Ze,Je)=>Ze.bs-Je.bs),ve=v.filter(Ze=>Ze.side!=="L").map(Ze=>Ze.r).sort((Ze,Je)=>Ze.bs-Je.bs);W.push({bs:ae,be:Pe,kind:"conflict",localHunks:He,remoteHunks:ve})}else for(let ae of v)W.push({bs:ae.bs,be:ae.be,kind:ae.side,u:ae})}let H=(v,G)=>{let ue=v==="L"?s:l;for(let ae of ue)if(ae.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===G.el))return ae.bs+.5;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="close"&&e[ae].k.el===G.el)return ae;return 1/0},k=(v,G)=>{let ue=v==="L"?s:l;for(let ae of ue)if(ae.toks.some(Pe=>Pe.kind==="open"&&Pe.k.el===G.el))return ae.bs-.5;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="open"&&e[ae].k.el===G.el)return ae;return-1/0},A=v=>v.kind==="R"?"R":"L",J=v=>v.kind==="R"?1:0;W.sort((v,G)=>{if(v.bs!==G.bs)return v.bs-G.bs;let ue=v.bs===v.be,ae=G.bs===G.be;if(ue!==ae)return ue?-1:1;if(ue&&ae&&v.kind!=="conflict"&&G.kind!=="conflict"){let He=v.u.toks,ve=G.u.toks,Ze=pt=>pt.length&&pt.every(Ye=>Ye.kind==="open"),Je=pt=>pt.length&&pt.every(Ye=>Ye.kind==="close");if(Ze(He)&&Ze(ve)){let pt=Math.max(...He.map(dt=>H(A(v),dt.k))),Ye=Math.max(...ve.map(dt=>H(A(G),dt.k)));if(pt!==Ye)return Ye-pt}if(Je(He)&&Je(ve)){let pt=Math.min(...He.map(dt=>k(A(v),dt.k))),Ye=Math.min(...ve.map(dt=>k(A(G),dt.k)));return pt!==Ye?Ye-pt:J(G)-J(v)}}let Pe=He=>He.u&&He.u.lead?1:0;return Pe(G)-Pe(v)||J(v)-J(G)||v.be-G.be});let _=[],F=[],Oe=0,Ce=v=>{v>Oe&&(_.push({bs:Oe,be:v,toks:e.slice(Oe,v),source:"base"}),Oe=v)};for(let v of W){if(Ce(v.bs),v.kind==="conflict"){let G=gs(e,v.localHunks,v.bs,v.be),ue=gs(e,v.remoteHunks,v.bs,v.be),ae=o==="local"?G:o==="both"?G.concat(ue):ue,Pe=(Ze,Je)=>{let pt=0;for(let Ye of Ze)Ye.be<=v.bs&&!Je.includes(Ye)&&(pt+=Ye.toks.length-(Ye.be-Ye.bs));return pt},He=v.bs+Pe(s,v.localHunks),ve=v.bs+Pe(l,v.remoteHunks);F.push({bs:v.bs,be:v.be,ls:He,le:He+G.length,rs:ve,re:ve+ue.length,ms:0,me:0,base:e.slice(v.bs,v.be),local:G,remote:ue,resolved:ae}),_.push({bs:v.bs,be:v.be,toks:ae,source:"conflict",localHunks:v.localHunks,localToks:G,keepsLocal:o!=="remote"})}else _.push({bs:v.bs,be:v.be,toks:v.u.toks,source:v.kind==="R"?"remote":"local",localHunks:v.kind==="R"?[]:[v.u.l]});Oe=Math.max(Oe,v.be)}Ce(e.length);let De=0,pe=0;for(let v of _)v.source==="conflict"&&(F[pe].ms=De,F[pe].me=De+v.toks.length,pe++),De+=v.toks.length;let Te=new Map(c.map(v=>[v.bi,v.tok])),ze=new Map(a.map(v=>[v.bi,v.tok])),Me=[];for(let v of _){v.source==="base"&&(v.toks=v.toks.map((G,ue)=>{let ae=v.bs+ue,Pe=Te.get(ae),He=ze.get(ae),ve=Pe&&He?o==="remote"?He:Pe:Pe||He||G;return ve===G?G:{...ve,cosmetic:!0}}));for(let G of v.toks)Me.push({...G,src:v.source})}return{tokens:Me,segments:_,conflicts:F,localHunks:s,remoteHunks:l,collapsedDelta:y,samePoint:N,mapLocalOffset:ha(e,s,_)}}function gs(e,t,n,o){let r=[],i=n;for(let s of t)r=r.concat(e.slice(i,s.bs),s.toks),i=s.be;return r.concat(e.slice(i,o))}var ps=e=>e.reduce((t,n)=>t+n.len,0);function ha(e,t,n){let o=new Int32Array(e.length+1);for(let s=0;s<e.length;s++)o[s+1]=o[s]+e[s].len;let r=t.map(s=>({bs:o[s.bs],be:o[s.be],text:s.toks.map(l=>l.raw).join(""),ref:s})),i=n.map(s=>({bs:o[s.bs],be:o[s.be],len:ps(s.toks),source:s.source,localHunks:s.localHunks||[],localLen:s.localToks?ps(s.localToks):0,keepsLocal:s.keepsLocal,ref:s}));return s=>{let l=null,c=null,a=0,p=0,f=0;for(let w of r){let b=w.bs-f;if(s<=p+b){l=f+(s-p);break}if(p+=b,f=w.bs,s<=p+w.text.length){c=w,a=s-p,l=w.bs;break}p+=w.text.length,f=w.be}l===null&&(l=f+(s-p));let d=0;for(let w of i){if(!c&&l<=w.bs)return d;if(!(c?w.localHunks.includes(c.ref):l<w.be)){d+=w.len;continue}if(w.source==="base")return d+(l-w.bs);if(w.source==="remote")return d+w.len;if(w.source==="local")return d+Math.min(a,w.len);if(!w.keepsLocal||!c)return d+w.len;let T=w.localHunks.indexOf(c.ref),g=ps(gs(e,w.localHunks.slice(0,T),w.ref.bs,c.ref.bs));return d+Math.min(g+a,w.localLen)}return d}}function Go(e,t,n,o="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:h=>Math.min(h,t.length),granularity:"word"};let r=hn(e,t,n),i=tn(e,r),s=tn(t,r),l=tn(n,r),c=i.length<=2e4&&s.length<=2e4&&l.length<=2e4?Ri(i,s,l,o):null,a="word",p=i;if(!c){let h=y=>y.split(/(?<=\n)/).map(N=>({k:N,raw:N,len:N.length}));p=h(e),c=Ri(p,h(t),h(n),o),a="line"}let f=h=>h.map(y=>y.raw).join(""),d=h=>{let y=[0];for(let N of h)y.push(y[y.length-1]+N.len);return y},w=d(p),b=null,T=null,g=null;if(c.conflicts.length){let h=y=>y.split(/(?<=\n)/).map(N=>({k:N,raw:N,len:N.length}));b=d(a==="line"?h(t):s),T=d(a==="line"?h(n):l),g=d(c.tokens)}return{text:f(c.tokens),conflicts:c.conflicts.map(h=>({bs:w[h.bs],be:w[h.be],ls:b[h.ls],le:b[h.le],rs:T[h.rs],re:T[h.re],ms:g[h.ms],me:g[h.me],base:f(h.base),local:f(h.local),remote:f(h.remote),resolved:f(h.resolved)})),mapLocalOffset:c.mapLocalOffset,granularity:a}}function lo(e,t,n=4e3){if(e===t)return[];let o=hn(e,t),r=tn(e,o),i=tn(t,o),s=_n(r,i,n),l=[0];for(let c of r)l.push(l[l.length-1]+c.len);return s.hunks.map(c=>({bs:l[c.bs],be:l[c.be],text:c.toks.map(a=>a.raw).join("")}))}function Wt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Rn({base:e,side:t,retained:n,transfers:o,baseAtomKey:r=l=>l.el,sideAtomKey:i=l=>l.el,budget:s=Wt()}){let l=[],c=S=>({status:"fallback",reason:S}),a=S=>S>s.remaining?!1:(s.remaining-=S,!0);if(!a((n.length+o.length)*3))return c("work-limit");for(let[S,O]of[["retained",n],["transfer",o]])for(let R of O){let{from:M,to:j,target:U}=R;if(!Number.isInteger(M)||!Number.isInteger(j)||!Number.isInteger(U)||M<0||j<=M||j>e.text.length||U<0||U+j-M>t.text.length)return c("invalid-range");l.push({...R,kind:S})}let p=Symbol(),f=S=>(O,R)=>{if(!a(1))throw p;return s.sortComparisons++,S(O,R)},d,w;try{d=l.slice().sort(f((S,O)=>S.from-O.from||S.to-O.to)),w=l.slice().sort(f((S,O)=>S.target-O.target||S.to-S.from-(O.to-O.from)))}catch(S){if(S===p)return c("work-limit");throw S}if(!a(l.length*2))return c("work-limit");for(let S=1;S<d.length;S++)if(d[S].from<d[S-1].to)return c("source-overlap");for(let S=1;S<w.length;S++)if(w[S].target<w[S-1].target+w[S-1].to-w[S-1].from)return c("target-overlap");for(let S of d){let O=S.to-S.from;if(!a(O))return c("work-limit");for(let R=0;R<O;R++){let M=S.from+R,j=S.target+R;if(s.comparisons++,e.text[M]!==t.text[j])return c("unequal-occurrence");let U=e.atomAt.get(M),K=t.atomAt.get(j);if(!!U!=!!K||U&&r(U)!==i(K))return c("different-atom")}}let b=e.text.length+t.text.length+2,T=l.reduce((S,O)=>S+(O.to-O.from)*2,2);if(!a(b+T+l.length))return c("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),h=new Int32Array(t.text.length+1).fill(-1);s.mapCells+=b,s.mapWrites+=T;let y=-1,N=!0;for(let S of d){S.target<y&&(N=!1),y=S.target+S.to-S.from;for(let O=0;O<S.to-S.from;O++)g[S.from+O]=S.target+O,h[S.target+O]=S.from+O}return g[e.text.length]=t.text.length,h[t.text.length]=e.text.length,{status:"ready",runs:d,bTo:g,toB:h,monotone:N,covers:(S,O)=>{if(!a(O-S))return null;s.coverageChecks+=O-S;for(let R=S;R<O;R++)if(e.text[R]!==wt&&!/\s/.test(e.text[R])&&g[R]<0)return!1;return!0}}}function ws({base:e,side:t,baseOf:n=()=>null,budget:o=Wt()}){if(e.text===t.text||!e.text.includes(wt)&&!t.text.includes(wt))return{status:"none"};let r=(e.text.length+t.text.length)*8;if(r>o.remaining)return{status:"fallback",reason:"work-limit"};o.remaining-=r,o.boundarySteps=(o.boundarySteps||0)+r;let i=(b,T)=>T<b.length&&(b[T]===wt||/\s/.test(b[T])),s=new Map,l=Symbol(),c=(b,T)=>{let g=b.stackAt[T]||[];if(!s.has(g)){if(g.length>o.remaining)throw l;o.remaining-=g.length,o.boundarySteps+=g.length,s.set(g,g.find(h=>h.block)?.el||null)}return s.get(g)},a=[],p=(b,T)=>{let g=c(e,b),h=c(t,T),y=g&&h&&n(h)!==g?"transfer":"retained",N=a[a.length-1];N&&N.to===b&&N.target+N.to-N.from===T&&N.kind===y&&N.destination===h?N.to++:a.push({from:b,to:b+1,target:T,destination:h,kind:y})},f=0,d=0,w=!1;try{for(;f<e.text.length||d<t.text.length;){if(f<e.text.length&&d<t.text.length&&e.text[f]===t.text[d]){let N=e.atomAt.get(f),x=t.atomAt.get(d);if(!!N!=!!x||N&&n(x.el)!==N.el)return{status:"none"};p(f++,d++);continue}if(!i(e.text,f)&&!i(t.text,d))return{status:"none"};let b=f,T=d;for(;i(e.text,f);)f++;for(;i(t.text,d);)d++;let g=e.text.slice(b,f),h=t.text.slice(T,d);(g.includes(wt)||h.includes(wt))&&(w=!0);let y=0;for(;y<f-b&&y<d-T&&e.text[f-y-1]===t.text[d-y-1];)y++;for(let N=y;N>0;N--)p(f-N,d-N)}}catch(b){if(b===l)return{status:"fallback",reason:"work-limit"};throw b}return w?Rn({base:e,side:t,retained:a.filter(b=>b.kind==="retained"),transfers:a.filter(b=>b.kind==="transfer"),sideAtomKey:b=>n(b.el)||b.el,budget:o}):{status:"none"}}var Li=/\s/,Mr=/\S/;function Tn(e,t,n,o,r,i,s=-1,l=-1){if(!e.length)return-1;r(o,e.length);let c=new Int32Array(e.length),a=0;for(let w=1;w<e.length;w++){for(r(o,1);a&&(r(o,1),e[a]!==e[w]);)a=c[a-1];r(o,1),e[a]===e[w]&&a++,c[w]=a}let p=-1,f=0,d=0;a=0;for(let w=0;w<t.length;w++){for(r(o,1);a&&(r(o,1),e[a]!==t[w]);)a=c[a-1];if(r(o,1),e[a]===t[w]&&a++,a!==e.length)continue;let b=w+1-e.length,T=w+1;for(a=c[a-1];f<n.length&&n[f].from<b;)r(o,1),f++;for(;d<n.length&&n[d].to<T;)r(o,1),d++;if(r(o,6),!(f===n.length||d===n.length||n[f].from!==b||n[d].to!==T||s>=0&&b<l&&T>s)){if(!i)return b;if(p>=0)return-1;p=b}}return p}function Yo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function xs(e,t,n,o){let r=null;for(let s of t)if(o(n,1),!(s.source!==e.source||s.side!==e.side))for(let l of s.runs){if(o(n,1),l.source!==e.source)continue;let c=Math.max(e.from,l.from),a=Math.min(e.to,l.to);c>=a||(r||(o(n,e.to-e.from),r=new Uint8Array(e.to-e.from)),o(n,a-c),r.fill(1,c-e.from,a-e.from))}if(!r)return!1;o(n,e.to-e.from);let i=!1;for(let s=e.from;s<e.to;s++)if(Mr.test(e.flat.text[s])){if(!r[s-e.from])return!1;i=!0}return i}function ks({source:e,side:t,views:n,eligible:o,blocked:r,baseId:i,model:s,tokensOf:l,budget:c,charge:a}){let{V:p,A:f,idOf:d}=n[t],w=n[1-t];if(e.nodeType!==1||f.identical.has(e)||w.A.identical.has(e)||r.has(e)||!o(e))return null;let b=p.twin(e),T=w.V.twin(e);if(!b||!T||f.map.get(e)!==b||f.reverse.get(b)!==e||w.A.map.get(e)!==T||w.A.reverse.get(T)!==e||!p.here(b)||!w.V.here(T)||!o(b)||!o(T))return null;let g=i(e);if(g!==d(b)||g!==w.idOf(T))return null;let h=s(e,null,c),y=s(b,f,c),N=s(T,w.A,c);if(!Yo(h)||!Yo(y)||!Yo(N))return null;let x=h.flat.text,S=y.flat.text;if(a(c,x.length+S.length*3),!Mr.test(S)||S.length>=x.length)return null;let O=x.startsWith(S),R=x.endsWith(S);if(O===R)return null;let M=O?S.length:0,j=O?x.length:x.length-S.length,U=M,K=j;for(;U<K&&(a(c,1),!!Li.test(x[U]));)U++;for(;K>U&&(a(c,1),!!Li.test(x[K-1]));)K--;if(U===K)return null;let W=l(h,c),H=!1,k=!1;for(let A of W)a(c,1),A.from===U&&(H=!0),A.to===K&&(k=!0);return!H||!k?null:{source:e,side:t,flat:h.flat,from:M,to:j}}function Pi({base:e,views:t,side:n,attempt:o,eligible:r,blocked:i,baseId:s,model:l,tokensOf:c,certificates:a,charge:p,exhausted:f,limit:d}){if(d<=0)return null;let w=Wt(d),{V:b,A:T,idOf:g}=t[n],h=t[1-n],[y,N,x,S]=o,O=null;try{for(let R=y;R<=N;R++){p(w,1);let M=e[R];if(M.nodeType!==1||T.identical.has(M)||h.A.identical.has(M)||i.has(M)||!r(M))continue;let j=ks({source:M,side:n,views:t,eligible:r,blocked:i,baseId:s,model:l,tokensOf:c,budget:w,charge:p});if(!j||xs(j,a,w,p))continue;let{flat:U,from:K,to:W}=j;p(w,(W-K)*2);let H=U.text.slice(K,W).trim();for(let k=x;k<=S;k++){p(w,1);let A=b.units[k],J=b.baseOf(A);if(!J||J===M||J.nodeType!==1||A.nodeType!==1||J.parentNode!==M.parentNode||A.parentNode!==T.map.get(M).parentNode||T.map.get(J)!==A||T.reverse.get(A)!==J||i.has(J)||!r(J)||!r(A)||s(J)!==g(A))continue;let _=l(J,null,w),F=l(A,T,w);if(!Yo(_)||!Yo(F))continue;let Oe=_.flat.text,Ce=F.flat.text;if(p(w,Oe.length),!Mr.test(Oe)||Ce.length<=Oe.length)continue;let De=c(F,w),pe=Tn(Oe,Ce,De,w,p,!0);if(!(pe<0)&&!(Tn(H,Ce,De,w,p,!1,pe,pe+Oe.length)<0)){(O||=[]).push(j);break}}}}catch(R){if(R!==f)throw R}return O}function ji(e,t,n,o,r,i,s){if(i==="both"||n.atoms.length||o.atoms.length||r.atoms.length)return i;let l=i==="remote";if(l?s.rss!==s.rse||s.lss===s.lse||s.local===s.base:s.lss!==s.lse||s.rss===s.rse||s.remote===s.base)return i;for(let c of e){if(c.source!==t||c.side!==(l?1:0)||c.flat.text!==n.text||c.flat.nodes.length!==n.nodes.length||s.be<=c.from||s.bs>=c.to)continue;let a=!0;for(let f=0;f<n.nodes.length;f++){let d=c.flat.nodes[f],w=n.nodes[f];if(d.node!==w.node||d.s!==w.s||d.e!==w.e){a=!1;break}}if(!a)continue;let p=!1;for(let f=s.bs;f<s.be;f++)if(Mr.test(n.text[f])){if(f<c.from||f>=c.to){a=!1;break}p=!0}if(a&&p)return l?"local":"remote"}return i}var Ln="\uFFFC";var pa={caret:0},pn=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(" ")),$i=new Set(["BR","WBR","IMG"]),As=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function Pn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||$i.has(e.tagName))return!0;if(!pn.has(e.tagName))return!As.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(!Pn(r,t)){o=!1;break}return t.inlineCache&&t.inlineCache.set(e,o),o}function ma(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function zt(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,i)=>{for(let s of r){if(s.nodeType===3){let f=s.nodeValue;if(!f)continue;n.nodes.push({node:s,s:n.text.length,e:n.text.length+f.length}),n.text+=f;for(let d=0;d<f.length;d++)n.stackAt.push(i);continue}if(s.nodeType!==1)continue;if(t.ignored&&t.ignored(s)){n.pins.push({el:s,i:n.text.length});continue}if(t.skip&&t.skip.has(s))continue;let l=t.via&&t.via(s)||s;l!==s&&(n.via||(n.via=new Map)).set(l,s);let c=s.tagName;if(t.blocks&&t.blocks.has(s)){n.text.length&&n.text[n.text.length-1]!==wt&&(n.stackAt.push(i),n.text+=wt);let f={el:s,tag:c,from:n.text.length,to:-1,depth:i.length,block:!0};n.marks.push(f);let d=i.concat([f]);o(l.childNodes,d),n.stackAt.push(d),n.text+=wt,f.to=n.text.length;continue}let a=pn.has(c)&&ma(l);if($i.has(c)||!pn.has(c)||t.remoteWins&&t.remoteWins(s)||t.atomize&&t.atomize(s)||a){n.atoms.push({i:n.text.length,el:s,key:a?c+":empty":c,stack:i}),n.stackAt.push(i),n.text+=Ln;continue}let p={el:s,tag:c,from:n.text.length,to:-1,depth:i.length};n.marks.push(p),o(l.childNodes,i.concat([p])),p.to=n.text.length}};if(o(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&Cr(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 ga(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function ba(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,"&quot;")}"`;return t+">"}function vo(e,t,n){let o="",r=[];for(let i=t;i<n;i++){let s=e.stackAt[i],l=0;for(;l<r.length&&l<s.length&&r[l]===s[l];)l++;for(;r.length>l;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<s.length;){let a=s[r.length];o+=ba(a.el),r.push(a)}let c=e.atomAt.get(i);o+=c?c.el.outerHTML:e.text[i]===wt?"":ga(e.text[i])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function ya(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 Fi(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 Di(e,t=()=>!1){let n=new Map,o=i=>{let s=n.get(i);return s===void 0&&(s="{"+i.map(l=>ya(l,t)).sort().join(",")+"}",n.set(i,s)),s},r="";for(let i=0;i<e.text.length;i++){let s=e.atomAt.get(i);r+=(s?"["+Fi(s.el,t)+"]":e.text[i])+o(e.stackAt[i])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function No(e,t,n,o=r=>r.key){let r=[],i=e.text,s=0,l=c=>{if(c<=s)return;let a=i.slice(s,c);if(n)for(let p of a.split(/(?<=\n)/))r.push({k:p,raw:p,len:p.length});else for(let p of tn(a,t))r.push(p)};for(let c of e.atoms)l(c.i),r.push({k:"\0"+o(c),raw:Ln,len:1,atom:!0}),s=c.i+1;return l(i.length),r}function Cr(e){if(!e.atoms.length)return e.text;let t="",n=0;for(let o of e.atoms)t+=e.text.slice(n,o.i),n=o.i+1;return t+e.text.slice(n)}var Oo=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n].len;return t};function Er(e,t,n,o){let r=Oo(t),i=Oo(n),s=[],l=0,c=0;for(let p of o.hunks){c+=p.bs-l;let f=c+p.toks.length;s.push({bs:r[p.bs],be:r[p.be],ss:i[c],se:i[f],text:e.text.slice(i[c],i[f]),toks:p.toks,lead:!!p.lead}),c=f,l=p.be}let a=new Map;for(let p of o.cosmetic)a.set(p.bi,p.tok.raw);return{hunks:s,respell:a}}function Bi(e,t,n){let o=s=>s===wt||/\s/.test(s),r=s=>s.replace(/[\u001E\s]/g,""),i=[];for(let s of e){let l=t.slice(s.bs,s.be),c=n.slice(s.ss,s.se);if(!l.includes(wt)&&!c.includes(wt)||l.includes(Ln)||c.includes(Ln)||r(l)!==r(c)){i.push(s);continue}let a=0,p=0;for(;;){let f=a,d=p;for(;f<l.length&&o(l[f]);)f++;for(;d<c.length&&o(c[d]);)d++;let w=a,b=p;for(;w<f&&b<d&&l[w]===c[b];)w++,b++;let T=f,g=d;for(;T>w&&g>b&&l[T-1]===c[g-1];)T--,g--;if(T>w||g>b){let h=c.slice(b,g);i.push({bs:s.bs+w,be:s.bs+T,ss:s.ss+b,se:s.ss+g,text:h,toks:[...h].map(y=>({k:y,raw:y,len:1})),lead:s.lead})}if(f>=l.length)break;a=f+1,p=d+1}}return i}function Ui(e,t,n){let o=new Int32Array(t+1).fill(-1),r=new Int32Array(n+1).fill(-1),i=0,s=0,l=c=>{for(;i<c;)o[i]=s,r[s]=i,i++,s++};for(let c of e)l(c.bs),i=c.be,s=c.se;return l(t),o[t]=s,r[s]=t,{bTo:o,toB:r}}function Hi(e,t,n){let o=[],r=0,i=0,s=(l,c)=>{if(r===l&&i===c)return;let a=t.text.slice(i,c);o.push({bs:r,be:l,ss:i,se:c,text:a,toks:tn(a,hn(a)),lead:!1})};for(let l of n.runs)s(l.from,l.target),r=l.to,i=l.target+l.to-l.from;return s(e.text.length,t.text.length),{hunks:o,respell:new Map}}function Vi(e,t,n,o){let r=Oo(t),i=Oo(n),s=(c,a)=>{let p=0,f=c.length;for(;p<f;){let d=p+f>>>1;c[d]<a?p=d+1:f=d}return c[p]===a?p:-1};for(let c of e.hunks)if(s(r,c.bs)<0||s(r,c.be)<0)return null;if(e.hunks.some(c=>s(i,c.ss)<0||s(i,c.se)<0)){if(!o)return null;let c=[];for(let d of e.hunks)c.push(d.ss,d.se);let a=[],p=0,f=0;for(let d of n){let w=f+d.len;for(;p<c.length&&c[p]<=f;)p++;let b=f;for(;p<c.length&&c[p]<w;){let T=c[p++];if(T>b){let g=d.raw.slice(b-f,T-f);a.push(...tn(g,hn(g))),b=T}}if(b===f)a.push(d);else{let T=d.raw.slice(b-f);a.push(...tn(T,hn(T)))}f=w}n=a,i=Oo(n)}let l=[];for(let c of e.hunks){let a=s(r,c.bs),p=s(r,c.be),f=s(i,c.ss),d=s(i,c.se);if(a<0||p<0||f<0||d<0)return null;l.push({bs:a,be:p,toks:n.slice(f,d),gap:[],group:l.length})}return{parts:l,cosmeticEq:[],tokens:n}}function Ts(e,t,n,o={},r=null){return qi(e,t,n,o.base,o.local,o.remote,r,{})}function qi(e,t,n,o,r,i,s,l){let c=hn(Cr(e),Cr(t),Cr(n)),a=No(e,c,!1,o),p=No(t,c,!1,r),f=No(n,c,!1,i),d=a.length>2e4||p.length>2e4||f.length>2e4;d&&(a=No(e,c,!0,o),p=No(t,c,!0,r),f=No(n,c,!0,i));let w=s?.local?Hi(e,t,s.local):null,b=s?.remote?Hi(e,n,s.remote):null,T=w?Vi(w,a,p,!d):_n(a,p),g=b?Vi(b,a,f,!d):_n(a,f);w&&T&&(p=T.tokens),b&&g&&(f=g.tokens);let h,y;if(T&&g){let N=bs(T,g,a);h=Er(t,a,p,{hunks:N.lh,cosmetic:N.cosL}),y=Er(n,a,f,{hunks:N.rh,cosmetic:N.cosR})}else h=w||Er(t,a,p,T),y=b||Er(n,a,f,g);return h.hunks=Bi(h.hunks,e.text,t.text),y.hunks=Bi(y.hunks,e.text,n.text),l.base=e,l.local=t,l.remote=n,l.lines=d,l.baseTokens=a,l.localEdits=h,l.remoteEdits=y,l.localMap=Ui(h.hunks,e.text.length,t.text.length),l.remoteMap=Ui(y.hunks,e.text.length,n.text.length),l.full=null,l}function _i(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Mo=/\s/;function Ir(e,t,n){for(let o=t;o<n;o++)if(!Mo.test(e[o]))return!1;return!0}function wa(e,t,n){let o=e.cache[n]||(e.cache[n]=new Map);if(o.has(t))return o.get(t);let r=n===0?"local":"remote",i=n===0?"remote":"local",s=t.baseMark,l=t[i+"Mark"],c=!t.block&&!t[r]&&!!l&&s.to>s.from;if(c){let a=n===0?e.ML:e.MR,p=n===0?e.MR:e.ML,f=n===0?e.fr:e.fl,d=!1;for(let w=s.from;w<s.to;w++){if(a.bTo[w]>=0){c=!1;break}p.bTo[w]<0&&!Mo.test(e.fb.text[w])&&(d=!0)}if(c&&!d){for(let w=l.from;w<l.to;w++)if(p.toB[w]<0&&!Mo.test(f.text[w])){d=!0;break}}c&&=d}return o.set(t,c),c}function Wi(e,t,n,o,r,i,s,l,c){let a=l===0?e.fl:e.fr,p=null;for(let f=n;f<o;f++){let d=t[f];if(!Ir(a.text,d.ss,d.se))return null;if(Ir(e.fb.text,d.bs,d.be)){if(d.bs<d.be&&d.ss<d.se||Mo.test(e.fb.text[d.bs-1]||"")||Mo.test(e.fb.text[d.be]||""))continue;return null}let w=!1;for(let b=d.bs;b<d.be;b++){if(Mo.test(e.fb.text[b]))continue;let T=null;for(let g of e.fb.stackAt[b]){let h=e.byEl.get(g.el);if(h&&wa(e,h,l)){T=h;break}}if(!T)return null;(p||(p=new Set)).add(T),w=!0}if(!w)return null}if(!p){if((l===0?"local":"remote")!==c)return null;let f=l===0?e.fr:e.fl,d=!1;for(let w=i;w<s;w++){let b=r[w];if(!Ir(e.fb.text,b.bs,b.be))return null;Ir(f.text,b.ss,b.se)||(d=!0)}if(!d)return null}return p||0}function Rr(e){let{out:t,policy:n="remote",L:o,R:r}=e,i=e.provenance||new WeakMap,s=e.textMappers||new WeakMap,l=e.conflicts||[],c=e.decisions||[],a=l.length,p=e.conflict||(u=>l.push(u)),f={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},d=[],w=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),b={base:null,local:null,remote:null};if(!e.prepared&&w&&e.moveIn){let u=ye=>Re=>ye.some(he=>he===Re||he.nodeType===1&&he.contains(Re)),E=u(e.local),L=u(e.remote),D=u(e.base),z=new Set,oe=ye=>{if(!pn.has(ye.tagName))return;let Re=o.map.get(ye),he=r.map.get(ye);(Re&&!E(Re)||he&&!L(he))&&z.add(ye);for(let Ie of ye.children)oe(Ie)};for(let ye of e.base)ye.nodeType===1&&oe(ye);let ge=ye=>Re=>{if(!pn.has(Re.tagName))return!1;let he=ye.reverse.get(Re);return!!he&&(z.has(he)||!D(he))};z.size&&(b.base=ye=>z.has(ye)),b.local=ge(o),b.remote=ge(r)}let T={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&w&&e.moveIn){let u=D=>z=>D.some(oe=>oe===z||oe.nodeType===1&&oe.contains(z)),E=u(e.local),L=u(e.remote);for(let D of zt(e.base,{...e,atomize:b.base}).atoms){let z=o.map.get(D.el),oe=r.map.get(D.el),ge=!!z&&!E(z),ye=!!oe&&!L(oe);!ge&&!ye||(ge&&e.movePlanned?.(D.el,"local",z,null),ye&&e.movePlanned?.(D.el,"remote",oe,null),T.base.add(D.el),z&&!ge&&T.local.add(z),oe&&!ye&&T.remote.add(oe),E(D.el)&&T.local.add(D.el),L(D.el)&&T.remote.add(D.el))}}let g=e.prepared?.base||zt(e.base,{...e,atomize:b.base,skip:T.base}),h=e.prepared?.local||zt(e.local,{...e,atomize:b.local,skip:T.local}),y=e.prepared?.remote||zt(e.remote,{...e,atomize:b.remote,skip:T.remote}),N=new Map(g.atoms.map(u=>[u.el,u])),x={},S=u=>e.prepared?e.prepared.full?.(u)||null:T[u].size?(x[u]||(x[u]=zt(e[u],{...e,atomize:b[u]})),x[u]):null,O=(u,E,L)=>{E.namespaceURI?u.setAttributeNS(E.namespaceURI,E.name,L):u.setAttribute(E.name,L)},R=(u,E,L,D)=>{if(!E&&(!L||!D)){for(let oe of(L||D).attributes)O(u,oe,oe.value);return}let z=new Map;for(let oe of[E,L,D])if(oe)for(let ge of oe.attributes)z.set(ge.name,ge);for(let[oe,ge]of z){let ye=E?E.getAttribute(oe):null,Re=L?L.getAttribute(oe):ye,he=D?D.getAttribute(oe):ye,Ie;Re===he?Ie=Re:Re===ye?(Ie=he,c.push({kind:"attr",el:u,name:oe,source:"remote"})):he===ye?(Ie=Re,c.push({kind:"attr",el:u,name:oe,source:"local"})):(Ie=n==="local"?Re:he,p({kind:"attr",el:u,name:oe,base:ye,local:Re,remote:he,resolved:Ie},{el:u,sample:ge}),c.push({kind:"attr",el:u,name:oe,source:"both"})),Ie!=null&&O(u,ge,Ie)}},M=(u,E,L,D)=>u&&e.mergeAttrs?e.mergeAttrs(u,E,L,D):R(D,u,E,L),j=e.mergeElement||((u,E,L)=>{let D=t.createElement(u.tagName);M(u,E,L,D);let z=E||u,oe=L||u,ge=n==="local"?z.isEqualNode(u)?oe:z:oe.isEqualNode(u)?z:oe;for(let ye of ge.childNodes)D.appendChild(t.importNode(ye,!0));return i.set(D,{base:u,local:E,remote:L}),D}),U=e.cloneUnit||((u,E)=>{let L=t.importNode(u,!0);return i.set(L,{base:null,local:E==="local"?u:null,remote:E==="remote"?u:null}),L}),K=e.atomKey||(u=>Fi(u,()=>!1)),W=(u,E)=>{let L=new Map;for(let D of u.atoms)if(e.remoteWins&&e.remoteWins(D.el)&&pn.has(D.el.tagName))L.set(D,"w"+D.el.tagName+"#"+(D.el.id||""));else if(!w)L.set(D,D.key);else if(u===g)L.set(D,"="+K(D.el));else{let z=E.reverse.get(D.el),oe=z?N.get(z):null;oe?L.set(D,"="+K(oe.el)):z?L.set(D,"m"+K(D.el)):L.set(D,"="+K(D.el))}return D=>L.get(D)},H=W(g,null),k=W(h,o),A=W(y,r),J=e.certifiedOrigins?e.certifiedOrigins(g,h,y,H,k,A):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let u=Wt(),E=ws({base:g,side:h,baseOf:D=>o?.reverse?.get(D)||null,budget:u}),L=ws({base:g,side:y,baseOf:D=>r?.reverse?.get(D)||null,budget:u});(E.status==="ready"||L.status==="ready")&&(J={local:E.status==="ready"?E:null,remote:L.status==="ready"?L:null})}let _=e.prepared||qi(g,h,y,H,k,A,J,f),F=_.lines,Oe=_.baseTokens,Ce=_.localEdits,De=_.remoteEdits,pe=_.localMap,Te=_.remoteMap,ze=g.text.length,Me=u=>new Map(u.atoms.map(E=>[E.el,E])),v=Me(h),G=Me(y),ue=(u,E,L)=>{let D=new Set;if(!w)return D;for(let z of u.atoms){let oe=N.get(E.reverse.get(z.el));oe&&L.bTo[oe.i]<0&&D.add(oe)}return D},ae=ue(h,o,pe),Pe=ue(y,r,Te),He=u=>!Pn(u,{...e,remoteWins:null}),ve=new Set;if(w)for(let u of g.atoms){if(!He(u.el))continue;let E=o.map.get(u.el)||null,L=r.map.get(u.el)||null,D=E&&!L?E:L&&!E?L:null;D&&(v.has(D)||G.has(D))&&!D.isEqualNode(u.el)&&ve.add(u)}let Ze=1,Je=(u,E)=>({id:Ze++,tag:u,base:null,local:null,remote:null,rank:E}),pt=new Map,Ye=[];for(let u of g.marks){let E=Je(u.tag,u.depth);E.block=!!u.block,E.base=u.el,E.baseMark=u,pt.set(u.el,E),Ye.push(E)}let dt=(u,E)=>{let L=-1,D=-1;for(let z=u.from;z<u.to;z++){let oe=E[z];oe>=0&&(L<0&&(L=oe),D=oe+1)}return L<0?null:[L,D]},St=(u,E,L,D)=>{for(let z of u.marks){let oe=L?L.reverse.get(z.el):null;oe&&L.identical.has(oe)&&L.pairIdenticalChildren&&L.pairIdenticalChildren(oe);let ge=oe?pt.get(oe):null;if(ge&&ge[E]&&(ge=null),!ge){let ye=dt(z,D),Re=0;if(ye)for(let he of Ye){if(he.tag!==z.tag||he[E]||!!he.block!=!!z.block)continue;let Ie=Math.min(ye[1],he.baseMark.to)-Math.max(ye[0],he.baseMark.from);(Ie>Re||Ie===Re&&Ie>0&&Math.abs(he.rank-z.depth)<Math.abs(ge.rank-z.depth))&&(ge=he,Re=Ie)}}ge||(ge=Je(z.tag,z.depth),ge.block=!!z.block,ge.new=E),ge[E]=z.el,ge[E+"Mark"]=z,pt.set(z.el,ge)}};St(h,"local",o,pe.toB),St(y,"remote",r,Te.toB);let vt=u=>u.merged||u,bt=u=>{let E=new Set;for(let L of u)L.block||E.add(pt.get(L.el));return E},At=new Map,Ot=u=>{let E=At.get(u);return E||(E=bt(u),At.set(u,E)),E},Bt=(u,E)=>{let L=[],D=null;for(let z=0;z<ze;z++){let oe=E[z];if(oe<0){D&&L.push(D),D=null;continue}let ge=Ot(g.stackAt[z]),ye=Ot(u.stackAt[oe]),Re=new Set,he=new Set;for(let Ie of ye)ge.has(Ie)||Re.add(Ie);for(let Ie of ge)ye.has(Ie)||he.add(Ie);if(!Re.size&&!he.size){D&&L.push(D),D=null;continue}if(D&&_i(D.added,Re)&&_i(D.removed,he)){D.be=z+1;continue}D&&L.push(D),D={bs:z,be:z+1,added:Re,removed:he}}return D&&L.push(D),L},nn=Bt(h,pe.bTo),Nt=Bt(y,Te.bTo),$t=u=>u.be>u.bs?[u.bs,u.be-1]:[u.bs-1,u.bs],an=(u,E)=>{if(ze===0)return null;let[L,D]=$t(u);for(let z of E){if(z.be<=L)continue;if(z.bs>D)break;let oe=z.bs<=L&&D<z.be;return oe&&u.text===""&&z.bs===u.bs&&z.be===u.be?"straddle":oe?z:u.be>u.bs?"straddle":null}return null},Pt=u=>u.bs===u.be,Jt=(u,E,L=null)=>{let D=!1;for(let z=u.bs;z<u.be;z++){let oe=g.text[z];if(oe===wt)D=!0;else if(!/\s/.test(oe))return!1}for(let z=u.ss;z<u.se;z++){let oe=E.text[z];if(oe===wt)D=!0;else if(!/\s/.test(oe)){let ge=L&&e.scopeUnits&&Pt(u)&&E.atomAt.get(z);if(!ge||!He(ge.el)||L.ss!==L.se||L.bs>=L.be)return!1;for(let Re=L.bs;Re<L.be;Re++)if(!/\s/.test(g.text[Re]))return!1;let ye=E===h?1:2;if(!e.scopeUnits[ye].includes(ge.el)||(ye===1?o:r)?.reverse.has(ge.el))return!1;D=!0}}return D},Ft=(u,E)=>u.bs<E.be&&E.bs<u.be,on=(u,E)=>u.bs<=E.be&&E.bs<=u.be&&Pt(u)!==Pt(E),Y=(u,E)=>g.text.slice(u.bs,u.be).includes(wt)||E.text.slice(u.ss,u.se).includes(wt),m=u=>{if(Pt(u))return!1;let E=u.bs,L=u.be;for(;E>0&&/\s/.test(g.text[E-1]);)E--;for(;L<g.text.length&&/\s/.test(g.text[L]);)L++;return(E===0||g.text[E-1]===wt)&&(L===g.text.length||g.text[L]===wt)},I=(u,E)=>!Y(u,E)&&!m(u),P=(u,E)=>Ft(u,E)||on(u,E)&&!(u.transferIn||u.transferOut||E.transferIn||E.transferOut)&&!(Jt(u,h,E)&&I(E,y))&&!(Jt(E,y,u)&&I(u,h)),$=(u,E)=>{if(u.bs!==E.bs||u.be!==E.be||u.toks.length!==E.toks.length)return!1;let L=u.ss,D=E.ss;for(let z=0;z<u.toks.length;z++){let oe=u.toks[z],ge=E.toks[z];if(oe.k!==ge.k||oe.atom&&!h.atomAt.get(L).el.isEqualNode(y.atomAt.get(D).el))return!1;L+=oe.len,D+=ge.len}return!0},Q=(u,E,L,D)=>{for(let z of g.atoms){if(z.i<u.bs||z.i>=u.be||D.has(z)||ve.has(z))continue;let oe=E.bTo[z.i],ge=oe>=0?L.atomAt.get(oe):null;if(ge&&!ge.el.isEqualNode(z.el))return!0}return!1},B=[],me=null,xe=null,fe=Ce.hunks,Se=De.hunks,V=0,Z=0,be=0,ke=0,we=0,te=u=>{u>be&&(B.push({src:"base",from:be,to:u,dL:ke,dR:we}),be=u)};for(;V<fe.length||Z<Se.length;){let u=fe[V],E=Se[Z],L=!!u&&(!E||u.bs<E.bs||u.bs===E.bs&&u.be<=E.be&&!E.lead);if(u&&E&&u.bs===E.bs&&Pt(u)&&Pt(E)){let Ht=Jt(u,h),Ko=Jt(E,y);Ht!==Ko&&(L=Ko)}let D=L?u:E,z=L?E:u,oe=!!z&&$(u,E),ge=!!z&&(L?!!fe[V+1]&&$(fe[V+1],E):!!Se[Z+1]&&$(u,Se[Z+1])),ye=!!z&&!oe&&!ge&&(ze===0||P(u,E)),Re=ye,he=an(D,L?Nt:nn);if(he==="straddle"&&(Re=!0),!Re&&D.be>D.bs&&(Re=Q(D,L?Te:pe,L?y:h,L?ae:Pe)),!Re&&oe){te(D.bs),B.push({src:"both",lfrom:u.ss,rfrom:E.ss,len:D.text.length,owner:u.owner||E.owner||null,transfer:u.transferIn||E.transferIn||null}),be=D.be,ke+=D.text.length-(D.be-D.bs),we+=D.text.length-(D.be-D.bs),V++,Z++;continue}if(!Re){te(D.bs),B.push({src:L?"local":"remote",from:D.ss,to:D.se,inherit:he&&he!=="straddle"?he:null,owner:D.owner||null,transfer:D.transferIn||null}),be=D.be,L?(ke+=D.text.length-(D.be-D.bs),V++):(we+=D.text.length-(D.be-D.bs),Z++);continue}let Ie=D.bs,Xe=D.be,nt=V,at=Z,jt=Ht=>Ht.bs<Xe&&Ht.be>Ie||Pt(Ht)&&(Ht.bs===Ie||Ht.bs===Xe);L?nt++:at++,ye&&(Ie=Math.min(Ie,z.bs),Xe=Math.max(Xe,z.be),L?at++:nt++);let Rt=!0;for(;Rt;){for(Rt=!1;nt<fe.length&&jt(fe[nt]);)Ie=Math.min(Ie,fe[nt].bs),Xe=Math.max(Xe,fe[nt].be),nt++,Rt=!0;for(;at<Se.length&&jt(Se[at]);)Ie=Math.min(Ie,Se[at].bs),Xe=Math.max(Xe,Se[at].be),at++,Rt=!0}let ln=Ie+ke,Qt=Ie+we,un=Xe-Ie,mn=Xe-Ie;for(let Ht=V;Ht<nt;Ht++)un+=fe[Ht].text.length-(fe[Ht].be-fe[Ht].bs);for(let Ht=Z;Ht<at;Ht++)mn+=Se[Ht].text.length-(Se[Ht].be-Se[Ht].bs);let In=ln+un,Cn=Qt+mn;if(te(Ie),V<nt&&Z<at&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!h.atoms.length&&!y.atoms.length&&!g.pins.length&&!h.pins.length&&!y.pins.length){me||={fb:g,fl:h,fr:y,ML:pe,MR:Te,byEl:pt,cache:[null,null]};let Ht=Wi(me,fe,V,nt,Se,Z,at,0,n),Ko=Wi(me,Se,Z,at,fe,V,nt,1,n);if(Ht===null!=(Ko===null)){let Yr=Ht!==null,bi=Yr?Ht:Ko;if(bi){xe||=new Map;for(let xc of bi)xe.set(xc,Yr?"local":"remote")}B.push(Yr?{src:"remote",from:Qt,to:Cn}:{src:"local",from:ln,to:In}),be=Xe,ke+=un-(Xe-Ie),we+=mn-(Xe-Ie),V=nt,Z=at;continue}}let qt={kind:"text",node:e.node||null,base:vo(g,Ie,Xe),local:vo(h,ln,In),remote:vo(y,Qt,Cn),resolved:null,range:null,bs:Ie,be:Xe,lss:ln,lse:In,rss:Qt,rse:Cn},ro=e.sourceRetentions?ji(e.sourceRetentions,e.scope?.base,g,h,y,n,qt):n;qt.resolved=ro==="local"?qt.local:ro==="remote"?qt.remote:qt.local+qt.remote,ro!=="remote"&&B.push({src:"local",from:ln,to:In,conflict:qt}),ro!=="local"&&B.push({src:"remote",from:Qt,to:Cn,conflict:qt});let so={site:"inline",policy:ro,fb:g,fl:h,fr:y,scope:e.scope||null,synthetic:!!e.synthetic,full:S,merged:f};d.push(so),p(qt,so),be=Xe,ke+=un-(Xe-Ie),we+=mn-(Xe-Ie),V=nt,Z=at}te(ze);let re=g.text,q=[];if(Ce.respell.size||De.respell.size){let u=Oo(Oe),E=[];for(let L=0;L<Oe.length;L++){let D=Oe[L].raw,z=Ce.respell.get(L)??D,oe=De.respell.get(L)??D;(z!==D||oe!==D)&&q.push([u[L],z!==D&&oe!==D?"both":z!==D?"local":"remote"]),E.push(z===oe?z:z===D?oe:oe===D||n==="local"?z:oe)}re=E.join("")}let le="",Ne=[],Le=[],je=[],Ae=[];for(let u of B){let E=le.length;if(u.src==="base"){for(let L=u.from;L<u.to;L++)Ne.push(L),Le.push(e.nativeTransfers?pe.bTo[L]:L+u.dL),je.push(e.nativeTransfers?Te.bTo[L]:L+u.dR),Ae.push(u);le+=re.slice(u.from,u.to)}else if(u.src==="both"){for(let L=0;L<u.len;L++){let D=u.transfer&&(u.transfer.side==="remote"?u.rfrom+L:u.lfrom+L);Ne.push(u.transfer&&D>=u.transfer.ss&&D<u.transfer.se?u.transfer.bs+D-u.transfer.ss:-1),Le.push(u.lfrom+L),je.push(u.rfrom+L),Ae.push(u)}le+=h.text.slice(u.lfrom,u.lfrom+u.len)}else{let L=u.src==="local"?h:y,D=u.transfer&&e.nativeTransfers.byOrigin[u.src==="local"?"remote":"local"].get(u.transfer.key);for(let z=u.from;z<u.to;z++){let oe=u.transfer&&z>=u.transfer.ss&&z<u.transfer.se?u.transfer.bs+z-u.transfer.ss:-1,ge=oe>=0&&(!D||D.destination===u.owner)?(u.src==="local"?Te:pe).bTo[oe]:-1;Ne.push(oe),Le.push(u.src==="local"?z:ge),je.push(u.src==="remote"?z:ge),Ae.push(u)}le+=L.text.slice(u.from,u.to)}u.ms=E,u.me=le.length,u.conflict&&(u.conflict.range||(u.conflict.range=[E,E]),u.conflict.range[1]=le.length)}let Ge=le.length,et=new Int32Array(ze+1).fill(-1),Qe=new Int32Array(h.text.length+1).fill(-1),Ut=new Int32Array(y.text.length+1).fill(-1);for(let u=0;u<Ge;u++)Ne[u]>=0&&(et[Ne[u]]=u),Le[u]>=0&&(Qe[Le[u]]=u),je[u]>=0&&(Ut[je[u]]=u);let Mt=(u,E)=>{let L=-1,D=-1;for(let z=u.from;z<u.to;z++){let oe=E[z];oe>=0&&(L<0&&(L=oe),D=oe+1)}return L<0?null:[L,D]},Kt=[],Lt=[];for(let u of new Set(pt.values()))u.new==="local"?Kt.push(u):u.new==="remote"&&Lt.push(u);let _t=(u,E)=>{u.remote=E.remote,u.remoteMark=E.remoteMark,u.new="both",E.merged=u,pt.set(E.remote,u)};if(Kt.length&&Lt.length){let u=e.idOf;for(let E of Kt){let L=u?u.local(E.local):null;if(!L)continue;let D=Lt.find(z=>!z.merged&&z.tag===E.tag&&!!z.block==!!E.block&&u.remote(z.remote)===L);D&&_t(E,D)}for(let E of Kt){if(E.remote)continue;let L=Mt(E.localMark,Qe);if(L)for(let D of Lt){if(D.merged||D.tag!==E.tag||!!D.block!=!!E.block)continue;let z=Mt(D.remoteMark,Ut);if(z&&Math.min(L[1],z[1])-Math.max(L[0],z[0])>0){_t(E,D);break}}}}At.clear();let C=u=>{for(let E of u)if(E.block)return vt(pt.get(E.el));return null},X=g.marks.some(u=>u.block)||h.marks.some(u=>u.block)||y.marks.some(u=>u.block),ce=new Array(Ge).fill(null),de=new Set;if(e.nativeTransfers)for(let u=0;u<Ge;u++){let E=Ae[u].owner;ce[u]=E?vt(pt.get(E)):Ne[u]>=0?C(g.stackAt[Ne[u]]):null}else if(X){let u=(he,Ie,Xe)=>{let nt=new Set([he,Ie,Xe]);nt.delete(null);let at=[];for(let Rt of nt){let ln=Rt===he,Qt=Rt===Ie,un=Rt===Xe;(Qt===un?Qt:Qt===ln?un:Qt)&&at.push(Rt)}if(at.length<=1)return at[0]||null;let jt=n==="local"?Ie:Xe;return at.includes(jt)?jt:at[0]},E=(he,Ie)=>Ie>=0?C(he.stackAt[Ie]):null,L=new Map;for(let he=0;he<Ge;he++){if(le[he]!==wt)continue;let Ie=Ne[he]>=0?E(g,Ne[he]):null,Xe=E(h,Le[he]),nt=E(y,je[he]);L.set(he,[Ie,Ne[he]>=0?u(Ie,Xe,nt):Xe||nt])}let D=new Set([...L.values()].map(he=>he[1])),z=he=>he!==wt&&he!==Ln&&!/\s/.test(he),oe=(he,Ie)=>{let Xe=he;for(;Xe<Ie&&!z(le[Xe]);)Xe++;return Xe<Ie&&Ne[Xe]>=0?E(g,Ne[Xe]):null},ge=new Map,ye=0;for(let he=0;he<Ge;he++){if(le[he]!==wt)continue;let[Ie,Xe]=L.get(he),nt=oe(ye,he),at=Xe,jt=ge.get(at)===at&&nt===at;at&&ge.has(at)&&!jt&&Ie&&!ge.has(Ie)&&!D.has(Ie)&&(at=Ie),at&&!ge.has(at)&&ge.set(at,nt);for(let Rt=ye;Rt<=he;Rt++)ce[Rt]=at;ye=he+1}let Re=he=>{for(let Ie=0;Ie<he.text.length;Ie++)if(z(he.text[Ie])&&!E(he,Ie))return!0;return!1};if(!Re(g)&&!Re(h)&&!Re(y)){let he=[],Ie=0;for(let nt=0;nt<Ge;nt++)(le[nt]===wt||nt===Ge-1)&&(he.push([Ie,nt]),Ie=nt+1);let Xe=new Set(ce);for(let nt=0;nt<he.length;nt++){let[at,jt]=he[nt];if(ce[jt])continue;let Rt=at;for(;Rt<=jt&&!z(le[Rt]);)Rt++;if(Rt>jt)continue;let ln=E(g,Ne[Rt]),Qt=E(h,Le[Rt]),un=E(y,je[Rt]),mn=u(ln,Qt,un)||Qt||un||ln;if(mn&&!Xe.has(mn)){Xe.add(mn);for(let qt=at;qt<=jt;qt++)ce[qt]=mn;continue}let In=nt>0&&ce[he[nt-1][1]],Cn=nt+1<he.length&&ce[he[nt+1][1]];if(In)de.add(he[nt-1][1]);else if(Cn&&le[jt]===wt)de.add(jt);else continue;for(let qt=at;qt<=jt;qt++)ce[qt]=In||Cn}}}let ie=new Map,ee=u=>{let E=ie.get(u);if(E)return E;E=[1/0,-1/0];for(let[L,D]of[[u.baseMark,et],[u.localMark,Qe],[u.remoteMark,Ut]]){let z=L&&Mt(L,D);z&&(E[0]=Math.min(E[0],z[0]),E[1]=Math.max(E[1],z[1]))}return ie.set(u,E),E},se=(u,E,L)=>{let D=-1,z=-1;for(let oe=0;oe<u.length;oe++){let ge=pt.get(u[oe].el);ge===E&&(D=oe),ge===L&&(z=oe)}return D>=0&&z>=0?D-z:0},Ee=(u,E)=>[...u].sort((L,D)=>{for(let ge of E){let ye=se(ge,L,D);if(ye)return ye}let z=ee(L),oe=ee(D);return z[0]-oe[0]||oe[1]-z[1]||L.rank-D.rank||L.id-D.id}),_e=new Map,Fe=new Map,tt=e.nativeTransfers?[]:null,st=u=>{if(tt)return tt;let E=Ne[u],L=Le[u],D=je[u],z=Ae[u];if(E>=0){let nt=g.stackAt[E],at=h.stackAt[L],jt=y.stackAt[D],Rt=_e.get(nt);Rt||_e.set(nt,Rt=new Map);let ln=Rt.get(at);ln||Rt.set(at,ln=new Map);let Qt=ln.get(jt);if(Qt)return Qt;let un=Ot(nt),mn=Ot(at),In=Ot(jt),Cn=new Set;for(let qt of new Set([...un,...mn,...In])){let ro=un.has(qt),so=mn.has(qt),Ht=In.has(qt);(so===Ht?so:so===ro?Ht:so)&&Cn.add(qt)}return Qt=Ee(Cn,[at,jt,nt]),ln.set(jt,Qt),Qt}if(z.src==="both"){let nt=h.stackAt[L],at=y.stackAt[D];return Ee(new Set([...Ot(nt),...Ot(at)]),[nt,at])}let ge=(z.src==="local"?h:y).stackAt[z.src==="local"?L:D];if(!z.inherit)return Ee(Ot(ge),[ge]);let ye=Fe.get(z);ye||Fe.set(z,ye=new Map);let Re=ye.get(ge);if(Re)return Re;let he=new Set(Ot(ge));for(let nt of z.inherit.added)he.add(vt(nt));for(let nt of z.inherit.removed)he.delete(vt(nt));let Ie=z.src==="local"?y:h,Xe=(z.src==="local"?Te.bTo:pe.bTo)[z.inherit.bs];return Re=Ee(he,[ge,Ie.stackAt[Xe]]),ye.set(ge,Re),Re},it=new Int32Array(h.text.length+1);it[h.text.length]=Ge;for(let u=h.text.length-1;u>=0;u--)it[u]=Qe[u]>=0?Qe[u]:it[u+1];pa.caret+=h.text.length;let rt=u=>u<=0?0:(u>h.text.length&&(u=h.text.length),Qe[u-1]>=0?Qe[u-1]+1:it[u]),kt=[],xt=[],Et=null,$e=[],mt="",Tt=-1,Dt=u=>{Et?Et.appendChild(u):kt.push(u)},It=u=>{if(!mt)return;let E=t.createTextNode(mt);Dt(E),xt.push({node:E,ms:Tt,me:u,local:[],u:$e.length?$e[$e.length-1].u:null}),mt=""},kn=new Set,Zt=new Map,Fn=new Set,fn=u=>{let E=t.createElement(u.tag);if(u.block&&Be.add(E),!Zt.has(u)){Zt.set(u,E),M(u.base,u.local,u.remote,E),i.set(E,{base:u.base,local:u.local,remote:u.remote});let D=(ge,ye)=>w&&u[ye]&&ge.reverse.get(u[ye])?ye:null,z=!u.base&&(D(o,"local")||D(r,"remote"));if(z){let ge=z==="local"?o.reverse.get(u.local):r.reverse.get(u.remote),ye=i.get(E);ye.local=ye.local||o.map.get(ge)||null,ye.remote=ye.remote||r.map.get(ge)||null,c.push({kind:"move",el:E,source:z}),e.moveBuilt?.(ge,z,u[z],E)}else u.base||c.push({kind:"insert",el:E,source:u.local&&u.remote?"both":u.local?"local":"remote"});let oe=i.get(E);oe.local&&(Fn.has(oe.local)?oe.local=null:Fn.add(oe.local))}else{let D=Zt.get(u);for(let z of D.attributes)z.name!=="id"&&z.name!=="data-id"&&O(E,z,z.value);i.set(E,{base:null,local:null,remote:null})}Dt(E),$e.push({u,el:E}),Et=E},to=new Set,An=new Map;for(let u of h.pins){let E=rt(u.i);An.has(E)||An.set(E,[]),An.get(E).push(u)}let bo=u=>{let E=An.get(u);if(E){It(u);for(let L of E){let D=L.el.namespaceURI&&L.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(L.el.namespaceURI,L.el.tagName):t.createElement(L.el.tagName);i.set(D,{base:null,local:L.el,remote:null,pinned:!0}),to.add(D),Dt(D)}}},_o=g.atoms.length||h.atoms.length||y.atoms.length,Gt=u=>{if(!_o)return null;let E=Ne[u]>=0?g.atomAt.get(Ne[u]):null,L=Le[u]>=0?h.atomAt.get(Le[u]):null,D=je[u]>=0?y.atomAt.get(je[u]):null;return E||L||D?{ab:E,al:L,ar:D}:null},Hn=(u,E,L)=>{let D=e.idOf;if(!D||!D.base)return!1;let z=D.base(u.el);return z!=null&&z===D[L](E.el)},Wo=(u,E,L,D,z)=>{if(!u||!w)return null;let oe=N.get(E.reverse.get(u.el))||null;return!oe||oe===D||(D?oe.el.isEqualNode(D.el)&&!Hn(oe,u,z):L.bTo[oe.i]>=0)?null:oe},yo=(u,E)=>{if(!u||!w||!e.moveIn)return null;let L=E.reverse.get(u.el);return L&&!N.has(L)?L:null},no=(u,E)=>{let L=new Map;for(let D of u.atoms)L.set(E(D),(L.get(E(D))||0)+1);return L},On=no(g,H),br=no(h,k),yr=no(y,A),wr=u=>{let E=H(u);return On.get(E)===1&&(br.get(E)||0)<=1&&(yr.get(E)||0)<=1},Vn=new Map,qn=new Set,oo=new Set,$o=new Set,wo=null;for(let u=0;u<Ge;u++){let E=Gt(u);if(!E)continue;let{ab:L,al:D,ar:z}=E,oe=Wo(z,r,Te,L,"remote"),ge=Wo(D,o,pe,L,"local"),ye=L,Re=null;if(oe?(ye=oe,Re="remote"):ge&&(ye=ge,Re="local"),ye){L&&ye!==L&&(wo||=new Map).set(L,Re),qn.has(ye)?Vn.set(u,{dup:ye.el}):(qn.add(ye),Vn.set(u,{bk:ye,from:Re,al:D,ar:z}));continue}let he=yo(z,r),Ie=yo(D,o),Xe=he||Ie;if(Xe){oo.has(Xe)?Vn.set(u,{dup:Xe}):(oo.add(Xe),Vn.set(u,{moveIn:Xe,side:he?"remote":"local",sideEl:he?z.el:D.el}));continue}let nt=(jt,Rt)=>jt&&w&&N.get(Rt.reverse.get(jt.el))||null,at=nt(z,r)||nt(D,o);if(at&&($o.add(at),Ae[u].conflict&&(wr(at)||z&&(z.el===at.el||r.identityPaired?.has(at.el))&&Hn(at,z,"remote")||D&&(D.el===at.el||o.identityPaired?.has(at.el))&&Hn(at,D,"local")))){if(qn.has(at)){Vn.set(u,{dup:at.el});continue}qn.add(at)}Vn.set(u,{al:D,ar:z})}let Mn=new Map,Fo,qo,xr=(u,E)=>{if(u[E]>=0)return u[E];for(let L=E-1;L>=0;L--)if(u[L]>=0)return u[L]+1;return 0};if(w)for(let u of g.atoms){if(qn.has(u)||$o.has(u))continue;let E=o.map.get(u.el)||null,L=r.map.get(u.el)||null,D=E&&v.get(E),z=L&&G.get(L);if(E&&!D||L&&!z)continue;let oe=!(D&&z)&&ve.has(u);if(!oe&&!(D&&z&&(wr(u)||wo?.has(u)||(D.el===u.el||o.identityPaired?.has(u.el))&&(z.el===u.el||r.identityPaired?.has(u.el))&&Hn(u,D,"local")&&Hn(u,z,"remote"))))continue;let ge=wo?.get(u),ye=n;if(ge){let nt=ge==="local"?y:h,at=ge==="local"?r:o,jt=ge==="local"?qo:Fo;if(jt===void 0){jt=nt.atoms.length===g.atoms.length;for(let Rt=0;jt&&Rt<g.atoms.length;Rt++)jt=at.reverse.get(nt.atoms[Rt].el)===g.atoms[Rt].el;ge==="local"?qo=jt:Fo=jt}jt&&(ye=ge)}let Re=ye==="local"?[[D,Qe],[z,Ut]]:[[z,Ut],[D,Qe]],[he,Ie]=Re.find(([nt])=>nt),Xe=xr(Ie,he.i);Mn.has(Xe)||Mn.set(Xe,[]),Mn.get(Xe).push({a:u,lt:E,rt:L,edited:oe}),qn.add(u)}if(w&&e.moveIn){let u=[[h,o,Qe,"local"],[y,r,Ut,"remote"]];n!=="local"&&u.reverse();for(let[E,L,D,z]of u)for(let oe of E.atoms){let ge=yo(oe,L);if(!ge||oo.has(ge))continue;oo.add(ge);let ye=xr(D,oe.i);Mn.has(ye)||Mn.set(ye,[]),Mn.get(ye).push({move:ge,side:z,sideEl:oe.el})}}let ne=u=>{let E=Mn.get(u);if(E){if(It(u),E.some(L=>He(L.move?L.sideEl:L.a.el)))for(;$e.length;)$e.pop(),Et=$e.length?$e[$e.length-1].el:null;for(let{a:L,lt:D,rt:z,edited:oe,move:ge,side:ye,sideEl:Re}of E){if(ge){let Ie=e.moveIn(ge,ye,Re);Ie&&Dt(Ie);continue}kn.add(L);let he=j(L.el,D,z);oe&&(p({kind:"structure",el:he,detail:"edit-beats-delete",base:L.el},{subject:L.el,deleted:D?"remote":"local"}),c.push({kind:"insert",el:he,source:D?"local":"remote"})),Dt(he)}}},Be=new Set,Ue=l.length>a;for(let u=0;u<Ge;u++){let E=Gt(u),L=e.scopeUnits&&E&&(E.ab?.stack.some(ge=>ge.block)||E.al?.stack.some(ge=>ge.block)||E.ar?.stack.some(ge=>ge.block)),z=!!E&&He((E.ab||E.al||E.ar).el)&&!L?[]:ce[u]?[ce[u],...st(u)]:st(u),oe=0;for(;oe<$e.length&&oe<z.length&&$e[oe].u===z[oe];)oe++;if(oe<$e.length)for(It(u);$e.length>oe;)$e.pop(),Et=$e.length?$e[$e.length-1].el:null;if(bo(u),ne(u),z.length>$e.length)for(It(u);$e.length<z.length;)fn(z[$e.length]);if(le[u]===wt){if(de.has(u))continue;It(u);let ge=$e.length;for(;ge>0&&!$e[ge-1].u.block;)ge--;if(ge>0)for(Ue&&f.breakOut.set(u,$e[ge-1].el);$e.length>=ge;)$e.pop(),Et=$e.length?$e[$e.length-1].el:null;continue}if(E){It(u);let ge=Vn.get(u),ye;if(ge.dup){p({kind:"structure",el:null,detail:"both-moved",base:ge.dup},{subject:ge.dup});continue}if(ge.moveIn){if(ye=e.moveIn(ge.moveIn,ge.side,ge.sideEl),!ye)continue}else if(ge.bk){let Re=ge.bk;if(kn.add(Re),Re===E.ab)ye=j(Re.el,ge.al.el,ge.ar.el);else{let he=o.map.get(Re.el)||null,Ie=r.map.get(Re.el)||null;ye=j(Re.el,he,Ie),(!he||!Ie)&&p({kind:"structure",el:null,detail:"move-beats-delete",base:Re.el},{subject:Re.el,deleted:he?"remote":"local"}),c.push({kind:"move",el:ye,source:ge.from})}}else ge.al?(ye=U(ge.al.el,"local"),ge.ar&&(i.get(ye).remote=ge.ar.el),c.push({kind:"insert",el:ye,source:ge.ar?"both":"local"})):(ye=U(ge.ar.el,"remote"),c.push({kind:"insert",el:ye,source:"remote"}));Ue&&f.atomOut.set(u,ye),Dt(ye);continue}mt||(Tt=u),mt+=le[u]}if(It(Ge),(An.has(Ge)||Mn.has(Ge))&&($e.length=0,Et=null,bo(Ge),ne(Ge)),Ge===0&&(h.placeholder||y.placeholder||g.placeholder)){let u=t.createElement("br");i.set(u,{base:g.placeholder,local:h.placeholder,remote:y.placeholder}),kt.push(u)}let qe=0,ht=u=>{for(;qe>0&&xt[qe-1].me>=u;)qe--;for(;qe<xt.length&&xt[qe].me<u;)qe++;let E=xt[qe];if(!E)return xt[xt.length-1]||null;let L=xt[qe+1];return E.me===u&&L&&L.ms===u?L:E},We=new Map,Ve={},lt=(u,E,L)=>{let D=ht(u)||(L?Ve:null);if(!D)return;let z=We.get(D)||{l:!1,r:!1};E!=="remote"&&(z.l=!0),E!=="local"&&(z.r=!0),We.set(D,z)},Ke=u=>{if(u.conflict)return!0;let E=u.src==="local"?h.text:u.src==="remote"?y.text:"";for(let L=u.from;L<u.to;L++)if(E[L]!==Ln&&E[L]!==wt)return!0;return!1};for(let u of B)u.src!=="base"&&lt(u.ms,u.conflict?"both":u.src,Ke(u));for(let[u,E]of q)et[u]>=0&&lt(et[u],E);for(let u of xt.length?xt:[Ve]){let E=We.get(u);E&&c.push({kind:"text",node:u.node||null,source:E.l&&E.r?"both":E.l?"local":"remote"})}for(let u of Ye){if(Zt.has(u))continue;let E=!u.local&&!(w&&o.map.get(u.base)),L=!u.remote&&!(w&&r.map.get(u.base));!E&&!L||c.push({kind:"remove",source:E&&L?"both":E?"local":"remote",base:u.base})}if(xe)for(let[u,E]of xe)Zt.has(u)&&p({kind:"structure",el:Zt.get(u),detail:"edit-beats-delete",base:u.base},{subject:u.base,deleted:E});let ct=(u,E,L)=>{if(E<=u)return!1;for(let D=u;D<E;D++)if(L[D]>=0)return!1;return!0};for(let u of Ye)for(let E of["local","remote"]){let L=u[E+"Mark"],D=u.baseMark;if(!L)continue;let z=E==="local"?pe:Te;if(!ct(D.from,D.to,z.bTo)||!ct(L.from,L.to,z.toB))continue;let oe=(E==="local"?fe:Se).find(ge=>ge.ss<=L.from&&L.from<ge.se);oe&&(oe.be<=D.from||oe.bs>=D.to)&&c.push({kind:"move",el:Zt.get(u)||null,source:E})}let ft=u=>{let E=pt.get(u.node.parentNode);return E?vt(E):null};for(let u of h.nodes){let E=-1;for(let D=u.s;D<u.e;D++)if(Qe[D]>=0){E=Qe[D];break}let L;if(E>=0)L=ht(E);else{let D=rt(u.s),z=ft(u);L=xt.find(oe=>oe.u===z&&oe.me>=D)||xt.filter(oe=>oe.u===z).pop()}L&&L.local.push(u)}let yt=new Map,gt=xt[xt.length-1]||null,Ct=0;for(let u of h.nodes){let E=null;for(let L=u.s;L<=u.e;L++){let D=rt(L);for(;Ct>0&&xt[Ct-1].me>=D;)Ct--;for(;Ct<xt.length&&xt[Ct].me<D;)Ct++;let z=ge=>ge&&D>=ge.ms&&D<=ge.me&&(D<ge.me||L===u.e||ge===E),oe=z(xt[Ct])?xt[Ct]:z(xt[Ct+1])?xt[Ct+1]:xt[Ct]||gt;if(!oe)break;if(E===oe){let ge=yt.get(oe);ge[ge.length-1].to=L-u.s;continue}E=oe,yt.has(oe)||yt.set(oe,[]),yt.get(oe).push({node:u.node,from:L-u.s,to:L-u.s,flatStart:u.s})}}for(let u of xt){let E=u.local,L=!1;for(let ge of E)for(let ye=ge.s;ye<ge.e&&!L;ye++)(Qe[ye]<u.ms||Qe[ye]>=u.me)&&(L=!0);i.set(u.node,{base:null,local:E.map(ge=>ge.node),remote:null,caret:yt.get(u)||[],partial:L});let D=u.ms,z=u.me-u.ms,oe=ge=>{let ye=0,Re=-1;for(let he of E){let Ie=he.e-he.s;if(ge<=ye+Ie){Re=he.s+(ge-ye);break}ye+=Ie}return Re<0&&(Re=E.length?E[E.length-1].e:0),Math.max(0,Math.min(rt(Re)-D,z))};oe.flat=ge=>Math.max(0,Math.min(rt(ge)-D,z)),s.set(u.node,oe)}function En(){if(!h.text.includes(wt))return[{flatLocal:h.text,localNodes:h.nodes,textNodes:xt,lToM:Qe,mapLocal:rt}];let u=[],E=0,L=0;for(let D=0;D<=h.text.length;D++){if(D<h.text.length&&h.text[D]!==wt)continue;let z=E,oe=D;if(oe>z){let ge=[];for(;L<h.nodes.length&&h.nodes[L].e<=z;)L++;for(let ye=L;ye<h.nodes.length&&h.nodes[ye].s<oe;ye++){let Re=h.nodes[ye],he=Math.max(Re.s,z),Ie=Math.min(Re.e,oe);he<Ie&&ge.push({node:Re.node,s:he-z,e:Ie-z})}u.push({flatLocal:h.text.slice(z,oe),localNodes:ge,textNodes:xt,lToM:Qe.subarray?Qe.subarray(z,oe+1):Qe.slice(z,oe+1),mapLocal:ye=>rt(z+Math.max(0,Math.min(ye,oe-z)))})}E=D+1}return u}let Kn={...e,blocks:Be,ignored:u=>to.has(u)||(e.ignored?e.ignored(u):!1)},xo=e.ignoreAttribute||(()=>!1),Gr=Di(zt(kt,Kn),xo)!==Di(y,xo);if(d.length){let u=E=>{let L=i.get(E);return L&&L.unchanged?L.remote:null};f.text=le,f.textNodes=xt,f.out=zt(kt,{...Kn,via:u})}let ut=null;if(e.scopeUnits){ut=new Map;let u=new Set(kt),E=ye=>{for(;ye&&!u.has(ye);)ye=ye.parentNode;return ye},L=e.scopeUnits.map(ye=>{let Re=new Map;for(let he of ye)if(he.nodeType===1)Re.set(he,he);else for(let Ie of he.nodes)Re.set(Ie,he);return Re}),D=(ye,Re)=>{for(;ye&&!Re.has(ye);)ye=ye.parentNode;return ye?Re.get(ye):null},z=[g,h,y].map((ye,Re)=>{let he=new Array(ye.text.length);for(let Ie of ye.nodes){let Xe=D(Ie.node,L[Re]);Xe&&he.fill(Xe,Ie.s,Ie.e)}for(let Ie of ye.atoms)he[Ie.i]=D(Ie.el,L[Re]);return he}),oe=(ye,Re)=>{if(!ye||!Re)return;let he=ut.get(ye);he||ut.set(ye,he=new Set),he.add(Re)};for(let ye of kt){let Re=i.get(ye);Re&&(oe(D(Re.base,L[0]),ye),oe(D(Re.local,L[1]),ye),oe(D(Re.remote,L[2]),ye))}for(let ye of xt){let Re=E(ye.node);for(let he=ye.ms;he<ye.me;he++)oe(z[0][Ne[he]],Re),oe(z[1][Le[he]],Re),oe(z[2][je[he]],Re)}let ge=new Map(kt.map((ye,Re)=>[ye,Re]));for(let[ye,Re]of ut)ut.set(ye,Array.from(Re).sort((he,Ie)=>ge.get(he)-ge.get(Ie)))}return{unitOutputs:ut,nodes:kt,text:le,textNodes:xt,localDiverged:Gr,mapLocal:rt,conflicts:l.slice(a),granularity:F?"line":"word",segments:En(),localHunks:fe,remoteHunks:Se,lToM:Qe}}var Ss=Symbol("lost");function zi(){return{links:new Map,removed:new Set,consumed:new Set,link(e,t){this.links.set(e,t)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let t of e.nodes)this.removed.add(t)},consume(e){for(let t of e)this.consumed.add(t)}}}var Ki=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function Gi({locals:e,rec:t,root:n,provenance:o,segments:r,ignored:i}){let s=new Map,l=(x,S)=>{let O=s.get(x);O||s.set(x,O=new Set),O.add(S)},c=new Set,a=new Set;for(let x of r){let S=x.textNodes;for(let O of S)c.add(O.node);for(let O of x.localNodes){a.add(O.node);let R=0,M=null;for(let j=O.s;j<O.e;j++){let U=x.lToM[j];if(U<0)continue;for((!S[R]||U<S[R].ms)&&(R=0);R<S.length&&S[R].me<=U;)R++;let K=S[R]&&S[R].ms<=U?S[R].node:Ss;K!==M&&l(O.node,K),M=K}}}let p=new Set,f=new Map,d=new Set;(function x(S){p.add(S);let O=o.get(S);if(S.nodeType===1)O&&O.local&&O.local.nodeType===1&&(l(O.local,S),O.unchanged&&d.add(O.local)),S.tagName==="TEMPLATE"&&S.content&&f.set(S.content,S);else if(O&&Array.isArray(O.local)&&!c.has(S))for(let R of O.local)l(R,S);for(let R=Ki(S).firstChild;R;R=R.nextSibling)x(R)})(n);let w=new Set;for(let[x,S]of t.links)l(x,S),w.add(x);let b=x=>{let S=x.parentNode;return S&&S.nodeType===11?f.get(S)||null:S},T=(x,S)=>{for(let O=x;O;O=b(O))if(O===S)return!0;return!1},g=x=>t.removed.has(x)||t.consumed.has(x),h=x=>{for(let S=x.parentNode;S&&S.nodeType===1;S=S.parentNode){if(d.has(S))return"kept";if(g(S))return"decided";if(s.has(S))return null}return null},y=new Map;for(let x of e)y.set(x,N(x));return y;function N(x){let S=s.get(x);if(S&&(S.size!==1||S.has(Ss)))return{kind:"unknown",reason:"several-outputs"};let O=S?S.values().next().value:null;if(O&&(O.nodeType!==1||!p.has(O)))return{kind:"unknown",reason:"output-not-placed"};if(!O){let U=g(x)?"decided":h(x);if(U==="kept")return{kind:"untouched"};if(U!=="decided")return{kind:"unknown",reason:"unmapped"}}let R=[],M=j(x,!!O&&(d.has(x)||w.has(x)),!O||g(x));if(M)return{kind:"unknown",reason:M};return O?{kind:"single",output:O,owned:R,carried:w.has(x)}:{kind:"removed"};function j(U,K,W){for(let H=Ki(U).firstChild;H;H=H.nextSibling){if(H.nodeType===1?i(H):H.nodeType!==3&&H.nodeType!==8)continue;let k=s.get(H);if(k)for(let A of k){if(A===Ss||!p.has(A))return"output-not-placed";if(!O)return"survives-elsewhere";if(!T(A,O))return"escaped";R.push(A)}else if(!K&&!W&&!g(H)&&!a.has(H))return"unmapped";if(H.nodeType===1){let A=j(H,K||d.has(H)||w.has(H),W||g(H));if(A)return A}}return null}}}function Yi(e,t){if(!t)return!1;let n=t.nodeType===1&&t.tagName==="TEMPLATE"?[t,...t.querySelectorAll("template")]:[...t.querySelectorAll("template")];for(let o of n)if(o.content.contains(e)||Yi(e,o.content))return!0;return!1}function Xi(e,t){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let n=[],o=new Set;for(let r of Array.from(e.elements)){if(!r||r.nodeType!==1||r.ownerDocument!==t&&!Yi(r,t.documentElement))throw new TypeError("lineage.elements must be elements of the live document");o.has(r)||(o.add(r),n.push(r))}return n}var Ji=new WeakMap;function Zi(e){let t=new Map;for(let n of e){let o=[],r=!1;(function i(s){s.nodeType===1&&s.namespaceURI==="http://www.w3.org/1999/xhtml"&&s.localName==="template"&&(r=!0);for(let l=s.firstChild;l;l=l.nextSibling)o.push(l),l.nodeType===1&&i(l)})(n),t.set(n,{nodes:o,opaque:r})}return t}function Ns(e,t,n){if(e.lineage===void 0)return n(e);if(!t||t.nodeType!==1)throw new TypeError("lineage requires an element root");let o=e.lineage,r=Xi(o,t.ownerDocument),i=!1,s={...e,lineage:{elements:r,onResult(l,c){if(!i)return i=!0,o.onResult(l,c)}}};try{return Ji.set(s.lineage,Zi(r)),n(s)}catch(l){if(!i){i=!0;try{o.onResult({version:1,root:t,status:"incomplete",entries:r.map(yn)},null)}catch{}}throw l}}function vs(e,{liveRoot:t,localRoot:n,toLive:o}){let r=Xi(e,t.ownerDocument),i=a=>a===t||t.contains(a),s=new Map,l=new Set(r.filter(i));if(l.size&&n===t)for(let a of l)s.set(a,a);else l.size&&function a(p){let f=o(p);l.delete(f)&&s.set(f,p);for(let d=p.firstElementChild;d&&l.size;d=d.nextElementSibling)a(d)}(n);return{spec:e,watched:r,root:t,locals:Array.from(new Set(s.values())),before:Ji.get(e)||Zi(r),delivered:!1,result:null,finish(a,p){return this.resolve=p,this.plans=a,this.result={version:1,root:this.root,status:"complete",entries:r.map(f=>xa(f,s.get(f),a,p,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(a,p){this.root=p;let f=this.resolve,d=b=>{let T=f(b);return T===a?p:T};return this.finish(this.plans,d)},deliver(a){this.delivered||(this.delivered=!0,e.onResult(this.result,a))}}}var yn=e=>({from:e,to:[],kind:"unknown",complete:!1});function xa(e,t,n,o,r){let i=r.root,s=d=>!!d&&(d===i||i.contains(d)),l=t&&n?n.get(t):null;if(!l||l.kind==="unknown")return yn(e);let c=r.before.get(e);if(!c||c.opaque)return yn(e);let a=c.nodes,p=d=>s(d)||!!(d&&d.ownerDocument===i.ownerDocument&&i.ownerDocument.documentElement?.contains(d));if(l.kind==="untouched"){if(!s(e))return yn(e);for(let d of a)if(p(d)&&!e.contains(d))return yn(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(l.kind==="removed")return p(e)||a.some(p)?yn(e):{from:e,to:[],kind:"removed",complete:!0};let f=o(l.output);if(!f||f.nodeType!==1||!s(f)||f!==e&&p(e))return yn(e);for(let d of a)if(p(d)&&!f.contains(d))return yn(e);for(let d of l.owned){let w=o(d),b=Array.isArray(w)?w:[w];for(let T of b)if(!T||!s(T)||!f.contains(T))return yn(e)}return l.carried&&!Qi(f,l.output,o)?yn(e):{from:e,to:[f],kind:f===e?"retained":"replaced",complete:!0}}function Qi(e,t,n){for(let o=t.firstChild;o;o=o.nextSibling){let r=n(o),i=Array.isArray(r)?r:[r];for(let s of i)if(!s||!e.contains(s))return!1;if(o.nodeType===1&&!Qi(e,o,n))return!1}return!0}function Xo(e,t,n){let o=vs(e,{liveRoot:t,localRoot:t,toLive:r=>r});return o.result={version:1,root:t,status:"complete",entries:o.watched.map(r=>yn(r))},n.lineage=o.result,o}function el(e,t,n,o,r){if(!r(e.length*8+1))return null;let i=0,s=t===0,l=!1;for(let c of tn(e,o)){if(!r(1))return null;if(i+=c.len,i===t&&(s=!0),i===n&&(l=!0),i>=n)break}return s&&l}function ka(e,t,n,o,r,i,s){if(!s(t.length*2))return!1;let l=new Map,c=new Map,a=new Set;for(let p of t){let f=p.bs<p.be,d=f?n[p.ownerIndex].text.base:n[p.ownerIndex].text[e],w=f?p.bs:p.ss,b=f?p.be:p.se;if(!s((b-w)*4+1))return!1;for(;w<b&&/\s/.test(d[w]);)w++;for(;b>w&&/\s/.test(d[b-1]);)b--;if(w===b)continue;let T=d.slice(w,b),g=f?l:c;f&&p.text&&a.add(T),g.has(T)?g.set(T,null):g.set(T,{h:p,from:w,to:b})}for(let p of o){if(!s(1))return!1;if(p.side!==e)continue;let f=p.deletion,d=n[f.ownerIndex].text.base;if(!s((f.be-f.bs)*3)||a.has(d.slice(f.bs,f.be).trim()))return!1}for(let[p,f]of l){if(!s(p.length+1))return!1;let d=c.get(p);if(!f||!d)continue;let w=f.h,b=d.h;if(!w.text||w.transferOut||b.transferIn||w.owner===b.owner)continue;let T=n[w.ownerIndex],g=n[b.ownerIndex];if(!s(T.text.base.length))return!1;if(!/\S/.test(T.text.base.slice(0,w.bs)+T.text.base.slice(w.be)))continue;let h=el(T.text.base,f.from,f.to,i,s),y=el(g.text[e],d.from,d.to,i,s);if(h===null||y===null)return!1;if(!h||!y)continue;let N=`${T.index}:${f.from}:${f.to}`,x={key:N,side:e,source:w.owner,destination:b.owner,deletion:w,insertion:b,sourceOffset:f.from-w.bs,targetOffset:d.from-b.ss,length:f.to-f.from};w.transferOut=x,b.transferIn=x,r[e].set(N,x),o.push(x)}return!0}function tl({base:e,local:t,remote:n,localTwin:o,remoteTwin:r,eligible:i,nodes:s,budget:l=Wt(2e4*32)}){let c=M=>M>l.remaining?!1:(l.remaining-=M,l.nativeSteps=(l.nativeSteps||0)+M,!0);if(e.length<2||t.length!==e.length||n.length!==e.length||!c(e.length*12))return null;for(let[M,j]of[["base",e],["local",t],["remote",n]]){let U=s[M];if(U.length!==j.length||U.some((K,W)=>K!==j[W]))return null}let a=[],p=0;for(let M=0;M<e.length;M++){let j=e[M],U=t[M],K=n[M];if(o(j)!==U||r(j)!==K)return null;let W={};for(let[H,k]of[["base",j],["local",U],["remote",K]]){if(!i(k)||k.tagName!==j.tagName||k.namespaceURI!==j.namespaceURI||!c(k.childNodes.length+1))return null;let A="";for(let J of k.childNodes){if(J.nodeType!==3||!c(J.data.length*4+1))return null;A+=J.data}if(A.includes(wt)||(p+=A.length+1,p>2e4))return null;W[H]=A}a.push({base:j,local:U,remote:K,index:M,text:W})}let f=a.every(M=>hn(M.text.base,M.text.local,M.text.remote)),d={local:[],remote:[]};for(let M of a){M.hunks={local:[],remote:[]};for(let j of["local","remote"]){let U=M.text.base,K=M.text[j];if(U===K)continue;let W=U.length+K.length+4,H=W*8;if(!c(H))return null;let k=Math.floor(l.remaining/8),A=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(W*W+k)-W)/2)));if(A<1||!c(4*(A+1)*(W+A+1)))return null;let J=0;for(let _ of lo(U,K,A)){if(!c(_.text.length+1))return null;let F=_.bs+J,Oe={..._,ss:F,se:F+_.text.length,toks:tn(_.text,f),owner:M.base,ownerIndex:M.index};M.hunks[j].push(Oe),d[j].push(Oe),J+=_.text.length-(_.be-_.bs)}}}let w=[],b={local:new Map,remote:new Map};for(let M of["local","remote"]){let j=new Map,U=new Map,K=!1,W=(H,k,A)=>{H.has(k)?H.set(k,null):H.set(k,A)};for(let H of d[M]){if(!c(1))return null;let k=a[H.ownerIndex].text.base;if(H.bs<H.be&&H.text===""){let A=k.slice(H.bs,H.be);if(!c(A.length*2))return null;/\S/.test(A)&&W(j,A,H)}else if(H.bs===H.be&&/\S/.test(H.text)){if(!c(H.text.length*2))return null;W(U,H.text,H)}else H.bs<H.be&&(K=!0)}for(let[H,k]of j){if(!c(H.length+1))return null;let A=U.get(H);if(!k||!A||k.owner===A.owner)continue;let J=a[k.ownerIndex];if(!c(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,k.bs)+J.text.base.slice(k.be)))continue;let _=`${J.index}:${k.bs}:${k.be}`,F={key:_,side:M,source:k.owner,destination:A.owner,deletion:k,insertion:A};k.transferOut=F,A.transferIn=F,b[M].set(_,F),w.push(F)}if(K&&U.size&&!ka(M,d[M],a,w,b,f,c))return null}if(!w.length)return null;let T=(M,j)=>M.bs<j.be&&j.bs<M.be,g=M=>M.bs===M.be,h=(M,j)=>M.bs<=j.be&&j.bs<=M.be&&g(M)!==g(j),y=(M,j)=>M.bs===j.bs&&M.be===j.be&&M.text===j.text,N=(M,j)=>!!(M.transferIn||M.transferOut&&(!M.text||j.bs===M.be&&/\s/.test(j.text[0])||j.bs===M.bs&&/\s/.test(j.text[j.text.length-1])));for(let M of w){let j=M.side==="local"?"remote":"local",U=a[M.deletion.ownerIndex];for(let K of U.hunks[j])if(!c(1)||T(M.deletion,K)&&K.transferOut?.key!==M.key)return null}for(let M of a)for(let j of M.hunks.local)for(let U of M.hunks.remote){if(!c(1))return null;if(y(j,U)){if(j.transferIn?.key!==U.transferIn?.key)return null;continue}if(T(j,U)||h(j,U)&&!N(j,U)&&!N(U,j))return null}if(!c(p*8))return null;let x=new Set([...e,...t,...n]),S={base:zt(e,{blocks:x}),local:zt(t,{blocks:x}),remote:zt(n,{blocks:x})},O={};for(let M of["base","local","remote"]){let j=S[M];if(j.atoms.length||j.pins.length)return null;O[M]=new Map(j.marks.filter(U=>U.block).map(U=>[U.el,U.from]))}for(let M of a){let j=O.base.get(M.base);if(j===void 0)return null;for(let U of["local","remote"]){let K=O[U].get(M[U]);if(K===void 0)return null;for(let W of M.hunks[U])W.bs+=j,W.be+=j,W.ss+=K,W.se+=K}}for(let M of w)M.bs=M.deletion.bs+(M.sourceOffset||0),M.be=M.length===void 0?M.deletion.be:M.bs+M.length,M.ss=M.insertion.ss+(M.targetOffset||0),M.se=M.length===void 0?M.insertion.se:M.ss+M.length;let R={};for(let M of["local","remote"]){let j=0,U=0,K=[];for(let H of d[M]){if(!c(1))return null;H.bs>j&&K.push({from:j,to:H.bs,target:U}),j=H.be,U=H.se}j<S.base.text.length&&K.push({from:j,to:S.base.text.length,target:U});let W=w.filter(H=>H.side===M).map(H=>({from:H.bs,to:H.be,target:H.ss,destination:H.destination}));if(R[M]=Rn({base:S.base,side:S[M],retained:K,transfers:W,budget:l}),R[M].status!=="ready")return null}return c(S.base.text.length)?{owners:a,blocks:x,transfers:w,byOrigin:b,budget:l,prepared:{base:S.base,local:S.local,remote:S.remote,lines:!1,baseTokens:tn(S.base.text,f),localEdits:{hunks:d.local,respell:new Map},remoteEdits:{hunks:d.remote,respell:new Map},localMap:R.local,remoteMap:R.remote,full:null}}:null}var Os=/\S/;function nl({certificates:e,scopes:t,views:n,eligible:o,baseId:r,limit:i=2e4*32}){let s=Wt(i),l=Symbol(),c=[],a=f=>{if(f>s.remaining)throw l;s.remaining-=f},p=(f,d=null)=>{if(a(1),!f||f.nodeType!==1||f.parentNode?.nodeType!==1||!o(f))return null;for(let T=f.parentNode;T;T=T.parentNode)if(a(1),T.nodeType===11)return null;let w="",b=0;for(let T of f.childNodes){if(a(1),T.nodeType!==3)return null;if(a(T.data.length*4+1),d){let g=d.flat.nodes[b++];if(!g||g.node!==T||g.s!==w.length||g.e!==w.length+T.data.length)return null}w+=T.data}return a(w.length*3+1),d&&(d.flat.atoms.length||d.flat.pins?.length||b!==d.flat.nodes.length||d.flat.text!==w)?null:Os.test(w)?w:null};try{a(t[0].length+t[1].length+t[2].length+e.length);let f=t.map(w=>new Set(w)),d=new Map;for(let w of e){a(1);let b=d.get(w.source);b||d.set(w.source,b=[]),b.push(w)}for(let w of d.values()){let b=[null,null],T=[];for(let g of w){a(1);let{source:h,target:y,side:N,models:x,runs:S}=g;if(N!==0&&N!==1||!f[0].has(h)||!f[N+1].has(y))continue;let{V:O,A:R,idOf:M}=n[N],j=n[1-N],U=O.twin(h),K=j.V.twin(h),W=O.baseOf(y);if(!U||!K||!W||W===h||!f[0].has(W)||!f[N+1].has(U)||!f[2-N].has(K)||R.map.get(h)!==U||R.reverse.get(U)!==h||j.A.map.get(h)!==K||j.A.reverse.get(K)!==h||R.map.get(W)!==y||R.reverse.get(y)!==W||y.parentNode!==U.parentNode||W.parentNode!==h.parentNode||h.tagName!==U.tagName||h.tagName!==K.tagName||r(h)!==M(U)||r(h)!==j.idOf(K)||r(W)!==M(y))continue;let H=x.get(h),k=x.get(y);if(!H||!k)continue;let A=p(h,H),J=p(y,k),_=p(U),F=p(K);if(a((A?.length||0)+(F?.length||0)),A===null||J===null||_===null||F===null||F===A)continue;let Oe=S.length>0,Ce=!1;for(let pe of S){if(a(1),pe.source!==h||pe.target!==y||!Number.isInteger(pe.from)||!Number.isInteger(pe.to)||!Number.isInteger(pe.targetFrom)||pe.from<0||pe.to<=pe.from||pe.to>A.length||pe.targetFrom<0||pe.targetFrom+pe.to-pe.from>J.length){Oe=!1;break}a((pe.to-pe.from)*3);for(let Te=pe.from;Te<pe.to;Te++){if(A[Te]!==J[pe.targetFrom+Te-pe.from]){Oe=!1;break}Os.test(A[Te])&&(Ce=!0)}if(!Oe)break}if(!Oe||!Ce)continue;let De=b[N];De||(a(A.length),De=b[N]={source:h,side:N,flat:H.flat,before:A,covered:new Uint8Array(A.length)});for(let pe of S)a(pe.to-pe.from),De.covered.fill(1,pe.from,pe.to)}for(let g of b){if(!g)continue;let{source:h,side:y,flat:N,before:x,covered:S}=g;a(x.length*3+1);let O=-1,R=-1;for(let M=0;M<=x.length;M++)M<x.length&&S[M]?(O<0&&(O=M),R=M+1):(M===x.length||Os.test(x[M]))&&O>=0&&(T.push({source:h,side:y,flat:N,from:O,to:R}),O=R=-1)}a(T.length),c.push(...T)}}catch(f){if(f!==l)throw f}return{records:c,budget:s}}var Aa="http://www.w3.org/1999/xhtml";function Ta(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function sn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Aa}function Sa(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Pr(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+"|"+Ta(e.textContent.trim())}var Na={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function Eo(e,t=[],n=!1){if(!sn(e)||e.hasAttribute("src"))return null;let o=[Na,...t];for(let r=0;r<o.length;r++){let i=o[r];if(!i.match(e))continue;if(!Sa(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let s=i.identity(e);return s==null||s===""?null:{key:r+":"+s,raw:s,recognizer:i}}return null}function ol(e,t,n){let o=new Set,r=i=>{sn(i)&&!t(i)&&o.add(Pr(i,n))};r(e);for(let i of e.querySelectorAll("script"))r(i);return o}function Jo(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 rl(e,t,n){let o=[],r=[],i=new Map,s=n.trackRecovery?new Set:null,l=Array.from(e.querySelectorAll("script"));sn(e)&&l.unshift(e);for(let c of l){if(!sn(c)||n.ignored(c)||n.skip.has(c)||t.has(Pr(c,n.baseURI)))continue;let a=c.ownerDocument.createElement("script");for(let p of c.attributes)a.setAttribute(p.name,p.value);if(a.textContent=c.textContent,n.beforeNodeAdded(a)===!1){s?.add(c);continue}a.hasAttribute("src")&&r.push(new Promise(p=>{a.addEventListener("load",()=>p()),a.addEventListener("error",()=>p())})),c.replaceWith(a),i.set(c,a),n.afterNodeAdded(a),o.push(a)}return{executed:o,loads:r,swapped:i,vetoed:s}}function va(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 Oa(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function sl(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Pr(e,t);if(n==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+Oa(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|"+va(e.textContent):e.outerHTML}function Ms(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 Ma(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var Ea=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Ia=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Es(e){try{return JSON.parse(e)}catch{return JSON.parse(Ca(e))}}function Ca(e){let t="",n=0,o=(r,i)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${i}`)};for(;n<e.length&&(n=Ms(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let l=Ms(e,n+1);if(e[l]==="}"||e[l]==="]"){n++;continue}t+=r,n++;continue}if(r==='"'||r==="'"){let l=n+1;for(;l<e.length&&e[l]!==r;)e[l]==="\\"&&l++,l++;l>=e.length&&o("unterminated string",n);let c=e.slice(n+1,l);r==="'"&&(c=Ma(c)),t+='"'+c+'"',n=l+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 s=e.slice(n,i);if(s==="true"||s==="false"||s==="null"||Ea.test(s)){t+=s,n=i;continue}if(Ia.test(s)){if(e[Ms(e,i)]===":"){t+='"'+s+'"',n=i;continue}o("unquoted value "+JSON.stringify(s),n)}o("invalid token "+JSON.stringify(s),n)}return t}var Vt=Symbol("hyper-morph-json-merge:missing"),Ra=["id","_id","uuid","key","slug","code","name"];function Io(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Zo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function La(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}var Pa=/^[A-Za-z_$][\w$]*$/;function ja(e,t){return Pa.test(t)?e===""?t:e+"."+t:e+"["+JSON.stringify(t)+"]"}function Da(e,t){return e===""?t:e+"."+t}function jr(e,t,n,o,r,i){if(e.onConflict){let s=l=>l===Vt?void 0:l;e.onConflict({path:t,base:s(n),local:s(o),remote:s(r),resolved:s(i)})}return i}function Wn(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(!Wn(e[n],t[n]))return!1;return!0}if(Io(e)&&Io(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Zo(t,o)||!Wn(e[o],t[o]))return!1;return!0}return!1}function Is(e,t,n,o,r,i){return Wn(t,n)?t:Wn(t,e)?n:Wn(n,e)?t:Io(t)&&Io(n)?Ba(Io(e)?e:{},t,n,o,r,i):Array.isArray(t)&&Array.isArray(n)?_a(e,t,n,o,r,i):jr(o,r,e,t,n,n)}function il(e,t,n,o,r,i){return t===Vt&&n===Vt?Vt:t===Vt?e===Vt?n:Wn(n,e)?Vt:jr(o,r,e,t,n,n):n===Vt?e===Vt?t:Wn(t,e)?Vt:jr(o,r,e,t,n,Vt):Is(e,t,n,o,r,i)}function Ba(e,t,n,o,r,i){let s={},l=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let c of l){let a=il(Zo(e,c)?e[c]:Vt,Zo(t,c)?t[c]:Vt,Zo(n,c)?n[c]:Vt,o,ja(r,c),Da(i,c));a!==Vt&&La(s,c,a)}return s}function Ua(e){return e===null||typeof e!="object"}function Dr(e){return typeof e+":"+String(e)}function Ha(e,t){for(let n of t){let o=new Set;for(let r of n){if(!Zo(r,e))return!1;let i=r[e];if(typeof i!="string"&&typeof i!="number")return!1;let s=Dr(i);if(o.has(s))return!1;o.add(s)}}return!0}function Va(e,t,n,o,r){let i=[e,t,n],s=!0;for(let l of i)for(let c of l)Io(c)||(s=!1);if(s){let l=o.keyPaths.get(r),c=l!==void 0?[l]:o.keyCandidates;for(let a of c)if(Ha(a,i))return{kind:"keyed",field:a};return null}for(let l of i){let c=new Set;for(let a of l){if(!Ua(a))return null;let p=Dr(a);if(c.has(p))return null;c.add(p)}}return{kind:"self"}}function _a(e,t,n,o,r,i){let s=Array.isArray(e)?e:[],l=Va(s,t,n,o,i),c=Array.isArray(e)&&e.length===t.length&&e.length===n.length;if(!l||l.kind==="self"&&c)return c?t.map((N,x)=>Is(e[x],N,n[x],o,r+"["+x+"]",i)):jr(o,r,e,t,n,n);let a=l.kind==="self"?Dr:N=>Dr(N[l.field]),p=N=>l.kind==="self"?r+"["+JSON.stringify(N)+"]":r+"["+l.field+"="+JSON.stringify(N[l.field])+"]",f=new Map,d=N=>{let x=new Map;for(let S of N){let O=a(S);x.set(O,S),f.has(O)||f.set(O,p(S))}return x},w=d(s),b=d(t),T=d(n),g=new Map,h=new Set([...w.keys(),...b.keys(),...T.keys()]);for(let N of h){let x=il(w.has(N)?w.get(N):Vt,b.has(N)?b.get(N):Vt,T.has(N)?T.get(N):Vt,o,f.get(N),i);x!==Vt&&g.set(N,x)}let y=[];for(let N of n){let x=a(N);g.has(x)&&y.push(x)}for(let N=0;N<t.length;N++){let x=a(t[N]);if(!g.has(x)||y.includes(x))continue;let S=0;for(let O=N-1;O>=0;O--){let R=y.indexOf(a(t[O]));if(R!==-1){S=R+1;break}}y.splice(S,0,x)}return y.map(N=>g.get(N))}function Wa(e){let t=new Map,n=[];for(let o of e.keyCandidates||[]){let r=o.lastIndexOf(":");r>=0?t.set(o.slice(0,r),o.slice(r+1)):n.push(o)}return{keyCandidates:[...n,...Ra],keyPaths:t,onConflict:e.onConflict||null}}function ll(e,t,n,o={}){return Is(e===void 0?Vt:e,t,n,Wa(o),"","")}function $a(e,t){let n=/^\s*/.exec(t)[0],o=/\s*$/.exec(t.slice(n.length))[0],r=t.slice(n.length,t.length-o.length),i=n.slice(n.lastIndexOf(`
6
+ `)+1),s=/\n([ \t]+)\S/.exec(r),l;if(!s)l=JSON.stringify(e);else{let c=s[1],a=c.length>i.length&&c.startsWith(i)?c.slice(i.length):" ";l=JSON.stringify(e,null,a).replace(/\n/g,`
7
+ `+i)}return n+l.replace(/</g,"\\u003c")+o}function Cs(e,t,n,o={}){let r=o.parse||Es,i=[],s=[],l=(d,w)=>{if(typeof d!="string")return Vt;try{return r(d)}catch(b){return i.push(`${w} side is not valid JSON (${b.message})`),Vt}},c=l(t,"local"),a=l(n,"remote");if(c===Vt)return{text:n,warnings:i,conflicts:s};if(a===Vt)return{text:t,warnings:i,conflicts:s};let p=l(e,"base"),f=ll(p===Vt?void 0:p,c,a,{...o,onConflict:d=>{s.push(d),o.onConflict?.(d)}});return Wn(f,a)?{text:n,warnings:i,conflicts:s}:Wn(f,c)?{text:t,warnings:i,conflicts:s}:{text:$a(f,n),warnings:i,conflicts:s}}var cl=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function ao(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>cl(t)||r>cl(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 Xn(e,t,n={}){if(!ao(e))return null;let{startContainer:o,startOffset:r,endContainer:i,endOffset:s}=e;if(o===i&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,s);if(o===i&&r===s)return"";let l=new Set;for(let g=o;g;g=g.parentNode)l.add(g);let c=i;for(;!l.has(c);)c=c.parentNode;let a=(g,h)=>{let y=c.ownerDocument.createRange(),N=c.ownerDocument.createRange();return y.setStart(g[0],g[1]),y.collapse(!0),N.setStart(h[0],h[1]),N.collapse(!0),y.compareBoundaryPoints(0,N)},p=(g,h=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(h)],f=[],d;if(t==="plain"){d="";let g=h=>{if(h.nodeType===3||h.nodeType===8){let y=d.length;d+=h.nodeValue,f.push({s:y,e:d.length,a:[h,0],b:[h,h.nodeValue.length],node:h})}else for(let y of h.childNodes)g(y)};g(c)}else{let g=n.blocks;if(!g){g=new Set;let y=N=>{N!==c&&N.nodeType===1&&As.has(N.tagName)&&g.add(N);for(let x of N.childNodes)y(x)};y(c)}let h=zt(Array.from(c.childNodes),{blocks:g,atomize:y=>!!n.atoms?.has(y),ignored:n.ignored});d=h.text;for(let y of h.nodes)f.push({s:y.s,e:y.e,a:[y.node,0],b:[y.node,y.e-y.s],node:y.node});for(let y of h.atoms)f.push({s:y.i,e:y.i+1,a:p(y.el),b:p(y.el,!0)});for(let y=0;y<h.text.length;y++){if(h.text[y]!==wt)continue;let N=h.marks.find(S=>S.block&&S.to===y+1),x=h.marks.find(S=>S.block&&S.from===y+1);if(N)f.push({s:y,e:y+1,a:[N.el,N.el.childNodes.length],b:p(N.el,!0)});else if(x)f.push({s:y,e:y+1,a:p(x.el),b:[x.el,0]});else return null}}f.sort((g,h)=>g.s-h.s);let w=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let y=f.find(N=>N.node===g[0]);return y?y.s+g[1]:null}let h=0;for(let y of f){if(a(g,y.a)<=0)return y.s;if(a(g,y.b)<0)return null;h=y.e}return h},b=w([o,r]),T=w([i,s]);return b!==null&&T!==null&&b<=T?d.slice(b,T):null}function co(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 al(e,t){if(!e||!t)return null;let n=co(e,t.start),o=co(e,t.end);return n&&o?{startContainer:n[0],startOffset:n[1],endContainer:o[0],endOffset:o[1]}:null}var fl=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function ul(e,t,n){if(!t)return;let o=new Map,r=new Map,i=l=>{if(!l)return null;if(r.has(l))return r.get(l);let a=l.local.map(p=>co(t.localRoot,{path:p,offset:0})?.[0]).map(p=>p&&n(p)).filter(Boolean).map(p=>({node:p,parent:p.parentNode,previous:p.previousSibling,next:p.nextSibling,fragment:fl(p)}));return r.set(l,a),a},s=l=>{let c=al(t.localRoot,l);if(!c)return null;let a=n(c.startContainer),p=n(c.endContainer);if(!a||!p)return null;let f={...c,startContainer:a,endContainer:p};return ao(f)?f:null};for(let l of e){let c=l.recovery;if(!c||o.has(c))continue;let a={subject:i(c.subject),span:null,scope:null,touched:new Set};if(c.text){a.span=s(c.text.local.span),a.scope=s(c.text.local.scope);let p=a.span;if(p){let f=p.startContainer.ownerDocument.createRange();f.setStart(p.startContainer,p.startOffset),f.setEnd(p.endContainer,p.endOffset);let d=w=>{if(f.intersectsNode(w)){a.touched.add(w);for(let b of w.childNodes)d(b)}};d(f.commonAncestorContainer)}}if(c.structure){for(let p of[c.structure.localPlacement])p&&(i(p.parent),p.before.forEach(i),p.after.forEach(i));for(let p of c.structure.localOrder||[])i(p)}o.set(c,a)}t.localState={states:o,refs:r}}function dl(e,t,n,o){let r=n.localState?.states.get(e);if(!r)return!1;let i=l=>{let c=l.node;if(!o(c)||c.parentNode!==l.parent)return!1;let a=p=>Array.prototype.indexOf.call(c.parentNode.childNodes,p);return!(l.previous&&o(l.previous)&&l.previous.parentNode===c.parentNode&&a(l.previous)>=a(c)||l.next&&o(l.next)&&l.next.parentNode===c.parentNode&&a(l.next)<=a(c))};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 l=e.text.local,c=a=>a&&o(a.startContainer)&&o(a.endContainer);return c(r.span)&&c(r.scope)&&Xn(r.scope,e.text.encoding)===l.text&&Xn(r.span,e.text.encoding)===l.text.slice(l.start,l.end)}if(e.attribute){let l=e.attribute,c=r.subject[0].node;return(l.namespaceURI?c.getAttributeNS(l.namespaceURI,l.localName):c.getAttribute(l.qualifiedName))===t.local}let s=e.structure;if(s.localOrder){let l=-1,c=null;for(let a of s.localOrder){let p=n.localState.refs.get(a)?.[0]?.node;if(!p||!o(p)||c&&p.parentNode!==c)return!1;let f=Array.prototype.indexOf.call(p.parentNode.childNodes,p);if(f<=l)return!1;c=p.parentNode,l=f}return!0}return s.localAction==="moved"||r.subject.every(l=>fl(l.node)===l.fragment)}var Fa=1,rn=e=>!!e&&e.nodeType===1,Br=e=>rn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function fo(e,t=null,n=null){let o=new Map,r=new Map,i=p=>{if(!t){t=new WeakMap;let f=[e];for(;f.length;){let d=f.pop();Br(d)&&(t.set(d.content,d),f.push(d.content));for(let w=d.firstChild;w;w=w.nextSibling)w.nodeType===1&&f.push(w)}}return t.get(p)||null},s=(p,f)=>{let d=r.get(p);if(!d){d=new Map;let w=0;for(let b=p.firstChild;b;b=b.nextSibling)d.set(b,w++);r.set(p,d)}return d.get(f)},l=p=>{if(!p)return null;if(n&&n.has(p))return l(n.get(p));if(p===e)return[];let f=o.get(p);if(f!==void 0)return f;let d=p.parentNode,w=null;if(d&&d.nodeType===11){let b=i(d),T=b?l(b):null;T&&(w=T.concat(["content",s(d,p)]))}else if(d){let b=l(d);b&&(w=b.concat([s(d,p)]))}return o.set(p,w),w};return{root:e,pathOf:l,logicalParent:p=>{let f=p.parentNode;return f&&f.nodeType===11?i(f):f},indexIn:s,containerPath:p=>{if(p.nodeType===11){let d=i(p),w=l(d);return w?w.concat(["content"]):null}let f=l(p);return f&&Br(p)?f.concat(["content"]):f},ownerOf:i}}var Sn=e=>Br(e)?e.content:e;function hl(e){let{L:t,R:n,unitsOf:o,provenance:r,policy:i}=e,s=[];return{note:(p,f)=>{s.push([p,f])},finish:p=>s.length?a(p):null};function a(p){let f={base:fo(e.roots.base),local:fo(e.roots.local),remote:fo(e.roots.remote)},d=Y=>Y==="local"?t:n,w=(Y,m)=>{if(!m)return null;if(Y.map.has(m))return Y.map.get(m);let I=[],P=rn(m)?f.base.logicalParent(m):m.parent;for(;P&&!Y.map.has(P);P=f.base.logicalParent(P))I.push(P);if(!P||!Y.identical.has(P))return null;let $=Y.map.get(P);for(let Q=I.length-1;Q>=0&&$;Q--)$=Sn($).childNodes[f.base.indexIn(I[Q].parentNode,I[Q])];return $?rn(m)?Sn($).childNodes[f.base.indexIn(m.parentNode,m)]||null:o($)[o(m.parent).indexOf(m)]||null:null},b=new Map,T=new Map,g=new WeakMap,h=0,y=(Y,m)=>{let I=b.get(Y);I||b.set(Y,I=[]),I.push(m)};(function Y(m){T.set(m,h++);let I=r.get(m);if(I&&!I.pinned){for(let P of[I.base,I.local,I.remote])if(P)if(Array.isArray(P))for(let $ of P)y($,m);else y(P,m)}if(Br(m)){g.set(m.content,m);for(let P=m.content.firstChild;P;P=P.nextSibling)Y(P)}for(let P=m.firstChild;P;P=P.nextSibling)Y(P)})(p);let N=new Map;f.out=fo(p,g,N);let x={refs:new Map,spans:new Map,anchors:new Map,via:N,outOwners:g,outRoot:p,localRoot:e.roots.local},S=Y=>rn(Y)?[Y]:Y.nodes,O=(Y,m)=>{let I=f[m].logicalParent(Y);if(!I)return null;for(let P of o(I))if(!rn(P)&&P.nodes.includes(Y))return P;return null},R=(Y,m)=>Y==null?null:Array.isArray(Y)?Y.length?O(Y[0],m):null:Y,M=Y=>{let m=new Set,I=[];for(let P of Y)for(let $ of b.get(P)||[])m.has($)||(m.add($),I.push($));return I.sort((P,$)=>T.get(P)-T.get($))},j=new Map,U=Y=>{let m=Y.b||Y.l||Y.r,I=j.get(m);if(I)return I;let P=[];for(let $ of[Y.b,Y.l,Y.r])$&&P.push(...S($));return I=M(P),j.set(m,I),I},K=Y=>({b:Y,l:w(t,Y),r:w(n,Y)}),W=(Y,m)=>{let I=d(m).reverse.get(Y);if(I)return K(I);for(let P of M(S(Y))){let $=r.get(P);if($&&!$.base&&$.local&&$.remote)return{b:null,l:R($.local,"local"),r:R($.remote,"remote")}}return m==="local"?{b:null,l:Y,r:null}:{b:null,l:null,r:Y}},H=new Map,k=Y=>{let m=r.get(Y);if(!m||m.pinned)return null;let I=R(m.base,"base");if(I)return K(I);let P=R(m.local,"local"),$=R(m.remote,"remote");if(P){let Q=t.reverse.get(P);if(Q)return K(Q)}if($){let Q=n.reverse.get($);if(Q)return K(Q)}return P||$?{b:null,l:P,r:$}:null},A=Y=>(H.has(Y)||H.set(Y,k(Y)),H.get(Y)),J=(Y,m)=>rn(Y)?f[m].logicalParent(Y):Y.parent,_=new Map,F=new Map,Oe=(Y,m)=>(rn(Y)?[f[m].pathOf(Y)]:Y.nodes.map(I=>f[m].pathOf(I))).filter(Boolean),Ce=Y=>{let m=Y.b||Y.l||Y.r,I=Y.b?"base":Y.l?"local":"remote",P=F.get(m);if(P)return P;let $=!rn(m),Q=Oe(m,I)[0],B=`${I[0]}:${JSON.stringify(Q===void 0?null:Q)}${$?":run":""}`,me=_.get(B);if(me)return F.set(m,me),me;let xe=U(Y);return me={key:B,nodeType:rn(m)?1:m.kind==="comment"?8:3,base:Y.b?Oe(Y.b,"base"):[],local:Y.l?Oe(Y.l,"local"):[],remote:Y.r?Oe(Y.r,"remote"):[],merged:xe.map(fe=>f.out.pathOf(fe)).filter(Boolean),live:[]},_.set(B,me),F.set(m,me),x.refs.set(me,xe),me},De={base:new Map,local:new Map,remote:new Map},pe=new Map,Te=(Y,m)=>{let I=J(Y,m);if(!I||I.nodeType!==1)return null;let P=De[m].get(I);if(!P){let Q=o(I),B=me=>Ce(m==="base"?K(me):W(me,m));P={parent:B(I),refs:Q.map(B),index:new Map(Q.map((me,xe)=>[me,xe]))},De[m].set(I,P)}let $=P.index.get(Y)??-1;return{parent:P.parent,before:P.refs.slice($+1),after:P.refs.slice(0,Math.max(0,$)).reverse()}},ze=Y=>{let m=Y.parentNode;if(!m)return null;let I=pe.get(m);if(!I){let $=m.nodeType===11?g.get(m):m,Q=$&&$.nodeType===1?A($):null;if(!Q)return null;let B=[],me=[],xe=new Map;for(let Se of m.childNodes){let V=A(Se),Z=V&&Ce(V),be=B.length,ke=B.length-1;Z&&Z!==B[ke]&&(B.push(Z),ke++);let we={ref:Z,group:ke,after:be};me.push(we),xe.set(Se,we)}let fe=B.length;for(let Se=me.length-1;Se>=0;Se--){let V=me[Se];V.before=fe,V.ref&&(fe=V.group)}I={parent:Ce(Q),refs:B,index:xe},pe.set(m,I)}let P=I.index.get(Y);return{parent:I.parent,before:I.refs.slice(P.before),after:I.refs.slice(0,P.after).reverse()}},Me=Y=>rn(Y)?Y.outerHTML:Y.value,v=Y=>rn(Y)?"element":Y.kind==="comment"?"comment":"text",G=(Y,m)=>({path:Y,offset:m}),ue=(Y,m,I)=>{if(!Y)return null;let P=f[I],$=0;if(m){let Q=rn(m)?m:m.nodes[m.nodes.length-1];Q.parentNode&&($=P.indexIn(Q.parentNode,Q)+1)}return G(P.containerPath(Y),$)},ae=(Y,m)=>{let I=J(Y,"base"),P=I?w(d(m),I):null;if(!rn(P))return null;let $=o(I),Q=null;for(let B=$.indexOf(Y)-1;B>=0&&!Q;B--){let me=w(d(m),$[B]);me&&J(me,m)===P&&(Q=me)}return ue(P,Q,m)},Pe=(Y,m,I,P)=>{let $=f[P],Q=0;for(let B=0;B<Y.nodes.length;B++){let me=Y.nodes[B],xe=me.nodeValue.length,fe=B===Y.nodes.length-1;if((I==="start"?m<Q+xe:m<=Q+xe)||fe)return G($.pathOf(me),Math.max(0,Math.min(m-Q,xe)));Q+=xe}return null},He=(Y,m)=>{let I=f[m],P=Y.firstChild,$=Y.lastChild;return P&&P.nodeType===3&&$.nodeType===3?{start:G(I.pathOf(P),0),end:G(I.pathOf($),$.nodeValue.length)}:{start:G(I.pathOf(Y),0),end:G(I.pathOf(Y),Y.childNodes.length)}},ve=(Y,m,I)=>{for(let B of Y.nodes)if(I==="start"?B.s<=m&&m<B.e:B.s<m&&m<=B.e)return{kind:"text",node:B.node,offset:m-B.s};let P=I==="start"?m:m-1,$=()=>{for(let B of Y.nodes)if(B.s===m||B.e===m)return{kind:"text",node:B.node,offset:m-B.s};return null},Q=Y.atomAt.get(P);if(Q)return{kind:I==="start"?"before":"after",node:Q.el};if(Y.text[P]===wt){let B=Y.marks.find(xe=>xe.block&&xe.to===P+1);if(B)return I==="start"?{kind:"end",node:B.el}:{kind:"after",node:B.el};let me=Y.marks.find(xe=>xe.block&&xe.from===P+1);if(me)return I==="start"?{kind:"before",node:me.el}:{kind:"startOf",node:me.el}}return $()},Ze=(Y,m)=>ve(Y,m,"end")||ve(Y,m,"start"),Je=(Y,m)=>{switch(m.kind){case"text":return G(Y.pathOf(m.node),m.offset);case"end":return G(Y.containerPath(m.node),Sn(m.node).childNodes.length);case"startOf":return G(Y.containerPath(m.node),0);default:{let I=m.node.parentNode;return G(Y.containerPath(I),Y.indexIn(I,m.node)+(m.kind==="after"?1:0))}}},pt=(Y,m,I,P,$)=>{let Q=ve(Y,m,I);return Q?Je(f[P],Q):$()},Ye=(Y,m,I,P)=>{let $=Y.textNodes.map(fe=>({s:fe.ms,e:fe.me,start:{kind:"text",node:fe.node,offset:0},end:{kind:"text",node:fe.node,offset:fe.me-fe.ms}}));for(let[fe,Se]of Y.atomOut)$.push({s:fe,e:fe+1,start:{kind:"before",node:Se},end:{kind:"after",node:Se}});for(let[fe,Se]of Y.breakOut)$.push({s:fe,e:fe+1,start:{kind:"end",node:Se},end:{kind:"after",node:Se}});for(let fe of $)if(fe.start.kind==="text"&&fe.s<m&&m<fe.e)return{kind:"text",node:fe.start.node,offset:m-fe.s};if(I!=="empty"){let fe=$.find(Se=>I==="start"?Se.s===m:Se.e===m);if(fe)return I==="start"?fe.start:fe.end}let Q=$.find(fe=>fe.e===m);if(Q)return Q.end;let B=$.find(fe=>fe.s===m);if(B)return B.start;let me=null,xe=null;for(let fe of $)fe.e<=m&&(!me||fe.e>me.e)&&(me=fe),fe.s>=m&&(!xe||fe.s<xe.s)&&(xe=fe);return me?me.end:xe?xe.start:P()},dt=(Y,m)=>{if(!m)return null;if(m.kind==="text"){let $=Y.nodes.find(Q=>Q.node===m.node);return $?$.s+Math.min(m.offset,$.e-$.s):null}let I=Y.atoms.find($=>$.el===m.node);if(I)return m.kind==="after"?I.i+1:I.i;let P=Y.marks.find($=>$.el===m.node);return P?m.kind==="before"&&P.block&&Y.text[P.from-1]===wt&&!Y.marks.some($=>$.block&&$.to===P.from)?P.from-1:m.kind==="startOf"||m.kind==="before"?P.from:m.kind==="end"&&P.block?P.to-1:P.to:null},St=(Y,m,I,P)=>{for(let me of Y.nodes)if(I==="start"?me.s<=m&&m<me.e:me.s<m&&m<=me.e)return{kind:"text",node:me.node,offset:m-me.s};let $=I==="start"?m:m-1;if(!Y.atomAt.has($)&&Y.text[$]!==wt){for(let me of Y.nodes)if(me.s===m||me.e===m)return{kind:"text",node:me.node,offset:m-me.s}}let Q=Y.atomAt.get($);if(Q)return{kind:I==="start"?"before":"after",node:Q.el};if(Y.text[$]===wt){let me=Y.marks.find(fe=>fe.block&&fe.to===$+1);if(me)return I==="start"?{kind:"end",node:me.el}:{kind:"after",node:me.el};let xe=Y.marks.find(fe=>fe.block&&fe.from===$+1);if(xe)return I==="start"?{kind:"before",node:xe.el}:{kind:"startOf",node:xe.el}}let B=Y.marks.find(me=>me.block&&me.from===m);return B?{kind:"startOf",node:B.el}:P?{kind:I==="start"?"startOf":"end",node:P}:null},vt=Y=>{if(!Y)return null;if(Y.kind==="wholeStart"||Y.kind==="wholeEnd"){let m=bt(Y.node);return Y.kind==="wholeStart"?m.start:m.end}return Je(f.out,Y)},bt=Y=>{let m=Y.firstChild,I=Y.lastChild;return m&&m.nodeType===3&&I.nodeType===3?{start:G(f.out.pathOf(m),0),end:G(f.out.pathOf(I),I.nodeValue.length)}:{start:G(f.out.pathOf(Y),0),end:G(f.out.pathOf(Y),Y.childNodes.length)}},At=Y=>{let m=J(Y,"base"),I=m?U(K(m))[0]:null;if(!I)return null;let P=Sn(I),$=o(m);for(let Q=$.indexOf(Y)-1;Q>=0;Q--){let B=U(K($[Q])).filter(me=>me.parentNode===P);if(B.length)return{kind:"after",node:B[B.length-1]}}return{kind:"startOf",node:I}},Ot=(Y,m,I,P,$,Q)=>({text:Y,start:m,end:I,fragment:P,span:$,scope:Q}),Bt=(Y,m,I,P,$)=>Ot(Y,m,I,Y.slice(m,I),P,$),nn=(Y,m,I,P,$)=>(x.spans.set(Y,{start:m,end:I,scopeStart:P,scopeEnd:$}),Y),Nt=new Map,$t=new Map,an=(Y,m,I)=>{let P=`text:${Y.key}:${m}:${I}`,$=$t.get(P)||0;return $t.set(P,$+1),`${P}:${$}`},Pt=(Y,m)=>{let I,P,$,Q="plain",B,me,xe,fe,Se,V=(ke,we,te,re,q)=>{if(!ke){let le=ae(q,re);return Bt("",0,0,{start:le,end:le},{start:le,end:le})}return Bt(ke.value,we,te,{start:Pe(ke,we,we===te?"end":"start",re),end:Pe(ke,te,"end",re)},{start:Pe(ke,0,"start",re),end:Pe(ke,ke.value.length,"end",re)})};if(m.site==="run"){let{bRun:ke,lRun:we,rRun:te,node:re,c:q}=m;I=K(ke),P=q.bs,$=q.be,B=V(ke,q.bs,q.be,"base",ke),me=V(we,q.ls,q.le,"local",ke),xe=V(te,q.rs,q.re,"remote",ke);let le=re?re.nodeValue:"",Ne=Le=>re?{kind:"text",node:re,offset:Le}:At(ke);fe=nn(Bt(le,q.ms,q.me,{start:vt(Ne(q.ms)),end:vt(Ne(q.me))},{start:vt(Ne(0)),end:vt(Ne(le.length))}),Ne(q.ms),Ne(q.me),Ne(0),Ne(le.length)),Se=re||(At(ke)||{}).node||null}else if(m.site==="whole"){let ke=m.el,we=r.get(ke);I=K(we.base),P=0,$=Y.base.length;let te=(q,le,Ne)=>{let Le=He(le,Ne);return Bt(q,0,q.length,Le,Le)};B=te(Y.base,we.base,"base"),me=te(Y.local,we.local,"local"),xe=te(Y.remote,we.remote,"remote");let re=bt(ke);fe=nn(Bt(Y.resolved,0,Y.resolved.length,re,re),{kind:"wholeStart",node:ke},{kind:"wholeEnd",node:ke},{kind:"wholeStart",node:ke},{kind:"wholeEnd",node:ke}),Se=ke}else if(m.site==="comment"){let{bRun:ke,lRun:we,rRun:te,node:re}=m;I=K(ke),P=0,$=Y.base.length;let q=(je,Ae)=>{if(!je){let Qe=ae(ke,Ae);return Bt("",0,0,{start:Qe,end:Qe},{start:Qe,end:Qe})}let Ge=je.nodes[0],et={start:G(f[Ae].pathOf(Ge),0),end:G(f[Ae].pathOf(Ge),je.value.length)};return Bt(je.value,0,je.value.length,et,et)};B=q(ke,"base"),me=q(we,"local"),xe=q(te,"remote");let le=Y.resolved,Ne=je=>re?{kind:"text",node:re,offset:je}:At(ke),Le={start:vt(Ne(0)),end:vt(Ne(le.length))};fe=nn(Bt(le,0,le.length,Le,Le),Ne(0),Ne(le.length),Ne(0),Ne(le.length)),Se=re||(At(ke)||{}).node||null}else{let{fb:ke,fl:we,fr:te,scope:re}=m,q=m.merged;Q="html",I=re.base?K(re.base):W(re.local,"local"),P=Y.bs,$=Y.be;let le=de=>{let ie=re[de];for(let ee=re.at-1;ee>=0;ee--){let se=re.units[ee],Ee=de==="base"?se:w(d(de),se);if(Ee&&J(Ee,de)===ie)return Ee}return null},Ne=de=>()=>ue(re[de],le(de),de),Le=(de,ie,ee,se,Ee)=>{let _e=Tt=>Tt?Je(f[Ee],Tt):Ne(Ee)(),Fe=ie===ee?Ze(de,ie):ve(de,ie,"start"),tt=ie===ee?Ze(de,ie):ve(de,ee,"end"),st=_e(Fe),it={start:st,end:ie===ee?st:_e(tt)},rt=m.full?m.full(Ee):null;if(!rt)return Ot(de.text,ie,ee,se,it,{start:_e(ve(de,0,"start")),end:_e(ve(de,de.text.length,"end"))});let kt=Fe?dt(rt,Fe):null,xt=tt?dt(rt,tt):null,Et=kt===null?0:kt,$e=Math.max(Et,xt===null?rt.text.length:xt),mt=_e(ve(rt,0,"start"));return Ot(rt.text,Et,$e,vo(rt,Et,$e),it,{start:mt,end:rt.text.length?_e(ve(rt,rt.text.length,"end")):mt})};B=m.synthetic?null:Le(ke,Y.bs,Y.be,Y.base,"base"),me=Le(we,Y.lss,Y.lse,Y.local,"local"),xe=Le(te,Y.rss,Y.rse,Y.remote,"remote");let[je,Ae]=Y.range||[0,0],Ge=q.out,et=()=>{let de=Sn(q.node);for(let ie=re.at-1;ie>=0;ie--){let ee=U(K(re.units[ie])).filter(se=>se.parentNode===de);if(ee.length)return{kind:"after",node:ee[ee.length-1]}}for(let ie=re.at;ie<re.units.length;ie++){let ee=U(K(re.units[ie])).filter(se=>se.parentNode===de);if(ee.length)return{kind:"before",node:ee[0]}}return{kind:"startOf",node:q.node}};if(Ge.via)for(let[de,ie]of Ge.via)N.set(de,ie);let Qe=Ye(q,je,je===Ae?"empty":"start",et),Ut=je===Ae?Qe:Ye(q,Ae,"end",et),Mt=Ge.text.length?St(Ge,0,"start",q.node):et(),Kt=Ge.text.length?St(Ge,Ge.text.length,"end",q.node):Mt,Lt=dt(Ge,Qe),_t=dt(Ge,Ut),C=Lt===null?0:Lt,X=Math.max(C,_t===null?Ge.text.length:_t);fe=nn(Ot(Ge.text,C,X,vo(Ge,C,X),{start:vt(Qe),end:vt(Ut)},{start:vt(Mt),end:vt(Kt)}),Qe,Ut,Mt,Kt);let ce=x.spans.get(fe);if(ce.flat=Ge,!Ge.text.length){let de=vt(Mt),ie=co(p,de),ee=ie[0],se=ie[1];ce.empty={parent:ee.nodeType===11?g.get(ee):ee,previous:ee.childNodes[se-1]||null,next:ee.childNodes[se]||null}}Se=Qe?Qe.node:q.node}let Z=Ce(I),be=(m.site==="whole"||m.site==="comment"||(m.policy||i)!=="both")&&Y.resolved!==Y.local;return{key:m.site==="comment"&&Nt.get(I.b||I.l||I.r)||an(Z,P,$),subject:Z,localLost:be,anchor:Se,text:{encoding:Q,base:B,local:me,remote:xe,merged:fe,liveSpan:null,liveScope:null}}},Jt=(Y,m)=>{let I=A(m.el),P=Ce(I),$=m.sample;return{key:`attr:${P.key}:${$.namespaceURI||""}:${$.localName}`,subject:P,localLost:Y.resolved!==Y.local,anchor:m.el,attribute:{namespaceURI:$.namespaceURI||null,localName:$.localName,qualifiedName:$.name}}},Ft=(Y,m)=>{let I=Y.detail,P=m.unit||K(m.subject),$=Ce(P),Q=x.refs.get($),B=P.l?Te(P.l,"local"):null,me=P.r?Te(P.r,"remote"):null,xe=Q.length?ze(Q[0]):null,fe,Se,V,Z=null,be=null,ke=m.deleted;switch(I){case"both-reordered":{fe=Se="reordered";let we=new Set(m.rKept),te=m.lKept.filter(Le=>we.has(Le)&&U(K(Le)).length),re=Le=>T.get(U(K(Le))[0]);Z=te.map(Le=>Ce(K(Le))),be=te.slice().sort((Le,je)=>re(Le)-re(je)).map(Le=>Ce(K(Le)));let q=Le=>!rn(Le)&&Le.kind!=="comment"&&Le.nodes.every(je=>!/[^\t\n\f\r ]/.test(je.data)),le=te.filter(Le=>!q(Le)),Ne=le.slice().sort((Le,je)=>re(Le)-re(je));V=le.some((Le,je)=>Le!==Ne[je]);break}case"both-moved":fe=Se="moved",V=!B||!Q.some(we=>{let te=we===Q[0]?xe:ze(we);return te&&te.parent===B.parent});break;case"edit-beats-delete":fe=ke==="local"?"deleted":"edited",Se=ke==="remote"?"deleted":"edited",V=ke==="local";break;case"move-beats-delete":fe=ke==="local"?"deleted":"moved",Se=ke==="remote"?"deleted":"moved",V=ke==="local";break;case"remote-wins":fe="edited",Se="edited",V=!0;break;default:fe=Se="inserted",V=m.localLost}return{key:`structure:${$.key}:${I}`,subject:$,localLost:V,anchor:Q[0]||null,structure:{localAction:fe,remoteAction:Se,localPlacement:B,remotePlacement:me,mergedPlacement:xe,localOrder:Z,mergedOrder:be,localFragment:I==="both-reordered"||!P.l?null:Me(P.l),fragmentKind:v(P.b||P.l||P.r)}}};for(let[Y,m]of s){if(Y.kind!=="structure")continue;let I=m.unit||K(m.subject),P=I.b||I.l||I.r;!rn(P)&&P.kind==="comment"&&Nt.set(P,`structure:${Ce(I).key}:${Y.detail}`)}let on=new Map;for(let[Y,m]of s){if(Y.kind==="structure"){let Q=Ce(m.unit||K(m.subject)),B=`structure:${Q.key}:${Y.detail}`,me=on.get(B);if(me&&me.structure){Y.recovery=me;let xe=x.refs.get(Q);Y.el==null&&xe.length&&(Y.el=rn(xe[0])?xe[0]:f.out.logicalParent(xe[0]));continue}}let I=Y.kind==="text"?Pt(Y,m):Y.kind==="attr"?Jt(Y,m):Ft(Y,m),P=on.get(I.key);P||(P={version:Fa,key:I.key,localLost:I.localLost,subject:I.subject,applied:!1,unavailable:null},on.set(I.key,P),x.anchors.set(P,I.anchor)),I.text&&(P.text=I.text),I.attribute&&(P.attribute=I.attribute),I.structure&&(P.structure=I.structure),I.text&&(P.localLost=I.localLost),Y.recovery=P;let $=x.refs.get(I.subject);Y.kind==="structure"&&Y.el==null&&$.length&&(Y.el=rn($[0])?$[0]:f.out.logicalParent($[0])),Y.kind==="text"&&Y.node==null&&$.length&&I.subject.nodeType===8&&(Y.node=$[0])}return x}}function pl(e,t,n){if(!t)return;let{lookup:o,vetoed:r,vetoedAttrs:i,liveAttr:s}=n,l=n.ignored||(()=>!1),c=fo(n.liveRoot),a=k=>!!k&&c.containerPath(k)!==null,p=k=>{let A=k.parentNode;return A&&A.nodeType===11?t.outOwners.get(A)||null:A},f=k=>{for(let A=k;A;A=p(A))if(t.via.has(A)&&(A=t.via.get(A)),r.has(A)||n.vetoedLive?.has(h(A)))return!0;return!1},d=k=>Array.from(Sn(k).children).filter(A=>!l(A)),w=(k,A)=>d(k)[d(A.parentNode).indexOf(A)],b=(k,A)=>{let J=null,_=null,F=0;for(let pe=A.previousSibling;pe;pe=pe.previousSibling){if(pe.nodeType===1&&!l(pe)){J=pe;break}pe.nodeType===3&&(F+=pe.nodeValue.length)}for(let pe=A.nextSibling;pe&&!_;pe=pe.nextSibling)pe.nodeType===1&&!l(pe)&&(_=pe);let Oe=J?w(k,J):null,Ce=_?w(k,_):null;if(J&&!Oe||_&&!Ce)return null;let De=[];for(let pe=Oe?Oe.nextSibling:Sn(k).firstChild;pe&&pe!==Ce;pe=pe.nextSibling)pe.nodeType===3&&De.push(pe);return De.length?{nodes:De,lead:F}:null},T=k=>{let A=[],J=k;for(;J&&!t.via.has(J);J=J.parentNode)A.push(J);if(!J||!A.length)return null;let _=h(t.via.get(J));for(let Ce=A.length-1;Ce>0&&_;Ce--)_=w(_,A[Ce]);if(!_)return null;let F=A[0];if(F.nodeType===3)return b(_,F);let Oe=F.nodeType===1?w(_,F):null;return Oe?{nodes:[Oe],lead:0}:null},g=k=>{let A=o(k),J=A?{nodes:Array.isArray(A)?A:[A],lead:0}:t.via.size?T(k):null;if(!J)return null;let _=J.nodes.filter(a);return _.length?{nodes:_,lead:J.lead}:null},h=k=>{let A=g(k);return A?A.nodes[0]:null},y=k=>{if(!k)return null;if(k.kind==="text"){let F=g(k.node);if(!F)return null;let Oe=F.nodes,Ce=k.offset+F.lead,De=0;for(let pe=0;pe<Oe.length;pe++){let Te=Oe[pe].nodeValue.length;if(Ce<=De+Te||pe===Oe.length-1)return Ce>=De&&Ce<=De+Te?[Oe[pe],Ce-De]:null;De+=Te}return null}let A=h(k.node);if(!A)return null;if(k.kind==="end")return[Sn(A),Sn(A).childNodes.length];if(k.kind==="startOf")return[Sn(A),0];if(k.kind==="wholeStart")return A.firstChild?[A.firstChild,0]:[A,0];if(k.kind==="wholeEnd")return A.lastChild?[A.lastChild,A.lastChild.nodeValue.length]:[A,A.childNodes.length];let J=A.parentNode;if(!J)return null;let _=Array.prototype.indexOf.call(J.childNodes,A);return[J,k.kind==="after"?_+1:_]},N=k=>({blocks:new Set((k.flat?.marks||[]).filter(A=>A.block).map(A=>h(A.el)).filter(Boolean)),atoms:new Set((k.flat?.atoms||[]).map(A=>h(A.el)).filter(Boolean)),ignored:l}),x=(k,A,J,_)=>{if(!k||!A||!ao(k)||!ao(A))return!1;for(let Ce of[k,A])if(!a(Ce.startContainer)||!a(Ce.endContainer))return!1;let F=J.merged;if(F.start===F.end&&(k.startContainer!==k.endContainer||k.startOffset!==k.endOffset))return!1;let Oe=N(_);return Xn(A,J.encoding,Oe)===F.text&&Xn(k,J.encoding,Oe)===F.text.slice(F.start,F.end)},S=new Map,O=k=>{let A=k.parentNode;return A?(S.has(A)||S.set(A,new Map(Array.from(A.childNodes,(J,_)=>[J,_]))),S.get(A).get(k)):-1},R=(k,A)=>{if(!A)return!1;let J=c.logicalParent(k);if(!A.parent.live.includes(J))return!1;let _=O(k);for(let[F,Oe]of[["before",1],["after",-1]]){let Ce=_;for(let De of A[F]){if(De.live.includes(k))continue;let pe=De.live.filter(ze=>ze!==k&&ze.parentNode===k.parentNode);if(!pe.length)continue;let Te=Oe===1?Math.min(...pe.map(O)):Math.max(...pe.map(O));if(Oe*(Te-Ce)<=0)return!1;Ce=Te}}return!0},M=k=>{let A=k.structure;if(A.mergedOrder){let J=new Set(k.subject.live.map(Sn)),_=null,F=-1;for(let Oe of A.mergedOrder){let Ce=Oe.live.find(De=>J.has(De.parentNode));if(!Ce||_&&Ce.parentNode!==_||O(Ce)<=F)return!1;_=Ce.parentNode,F=O(Ce)}return k.subject.live.length>0}return k.subject.live.some(J=>R(J,A.mergedPlacement))},j=(k,A)=>{let J=y(k),_=y(A);return J&&_?{startContainer:J[0],startOffset:J[1],endContainer:_[0],endOffset:_[1]}:null},U=new Set,K=k=>{if(!k||U.has(k))return;U.add(k);let A=[];for(let J of t.refs.get(k)||[]){let _=g(J);if(_)for(let F of _.nodes)A.includes(F)||A.push(F)}k.live=A},W=k=>{k&&(K(k.parent),k.before.forEach(K),k.after.forEach(K))},H=new Set;for(let k of e){let A=k.recovery;if(!A||H.has(A))continue;H.add(A),K(A.subject),A.structure&&(W(A.structure.localPlacement),W(A.structure.remotePlacement),W(A.structure.mergedPlacement),(A.structure.localOrder||[]).forEach(K),(A.structure.mergedOrder||[]).forEach(K));let J=t.anchors.get(A),_=J?h(J):null,F=!!_;if(A.text){let G=t.spans.get(A.text.merged),ue=G?j(G.start,G.end):null,ae=G?j(G.scopeStart,G.scopeEnd):null;if(G?.empty){let Pe=G.empty,He=Pe.previous?{kind:"after",node:Pe.previous}:{kind:"startOf",node:Pe.parent},ve=Pe.next?{kind:"before",node:Pe.next}:{kind:"end",node:Pe.parent},Ze=j(He,ve);!Ze||Ze.startContainer!==Ze.endContainer||Ze.startOffset!==Ze.endOffset?ue=null:ue=ae=Ze}x(ue,ae,A.text,G)||(ue=ae=null),A.text.liveSpan=ue,A.text.liveScope=ue?ae:null,ue||(F=!1)}A.structure&&F&&(F=M(A)),A.attribute&&F&&(F=s(_,A.attribute,k.resolved));let Oe=G=>G?.tagName==="TEXTAREA"?G:G?.parentNode?.tagName==="TEXTAREA"?G.parentNode:null,Ce=(!!A.attribute||!!A.text&&!!(Oe(_)||Oe(J)))&&!!i&&[J,_,Oe(_),Oe(J)].some(G=>i.get(G)?.has(A.attribute?A.attribute.qualifiedName:"value")),De=t.localState?.states.get(A),pe=!!A.text&&[...n.removedVetoes||[]].some(G=>De?.touched.has(G)),Te=A.structure?.localAction==="inserted"&&[...r].some(G=>G===J||J?.contains(G)),ze=J&&f(J)||Ce||pe||Te,Me=ze&&dl(A,k,t,a);Me&&(pe||Te&&A.localLost)&&(F=!1);let v=!F&&Me&&ze;A.applied=F,A.unavailable=F?null:v?"hook-veto":"missing-output",v&&(A.localLost=!1),!F&&A.text&&(A.text.liveSpan=A.text.liveScope=null)}}function Ur(e,t,n){let o=fo(t),r=fo(n),i=f=>!!f&&r.containerPath(f)!==null,s=f=>{if(f===t)return n;let d=o.pathOf(f);if(d&&t!==n){let w=co(n,{path:d,offset:0});if(w&&w[0].nodeType===f.nodeType)return w[0]}return f},l=new Set,c=f=>{!f||l.has(f)||(l.add(f),f.live=f.live.map(s).filter(i))},a=f=>{f&&(f.startContainer=s(f.startContainer),f.endContainer=s(f.endContainer))},p=new Set;for(let f of e){f.node===t&&n.tagName==="SCRIPT"&&(f.node=n),f.el===t&&f.kind==="structure"&&(f.el=n);let d=f.recovery;if(!d||p.has(d))continue;if(p.add(d),c(d.subject),d.text){a(d.text.liveSpan),a(d.text.liveScope);let b=d.text.liveSpan,T=d.text.liveScope,g=d.text.merged,h=y=>!!y&&ao(y)&&i(y.startContainer)&&i(y.endContainer);(!h(b)||!h(T)||Xn(T,d.text.encoding)!==g.text||Xn(b,d.text.encoding)!==g.text.slice(g.start,g.end))&&(d.text.liveSpan=null,d.text.liveScope=null,d.applied=!1,d.unavailable="missing-output")}let w=d.structure;if(w){for(let b of[w.localPlacement,w.remotePlacement,w.mergedPlacement])b&&(c(b.parent),b.before.forEach(c),b.after.forEach(c));(w.localOrder||[]).forEach(c),(w.mergedOrder||[]).forEach(c),d.subject.live.length||(d.applied=!1,d.unavailable="missing-output")}}}var Co=e=>e?.nodeType===1,Qo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function qa({provenance:e,parentOf:t,twins:n,baseOf:o,build:r,ignored:i,remoteWins:s,discarded:l}){let c=new Map,a=new WeakMap;function p(w,b,T,g=!1){if(!Co(w)||!Co(T))return null;let h=c.get(w);if(h)(g||!h.selected&&b==="remote")&&(h.parent=t(T),h.port=T,h.sourceSide=b,h.selected=g);else{let y=a.get(w)||null;h={owner:w,parent:t(T),port:T,sourceSide:b,originalParent:t(w),originalPort:w,selected:g,state:y?"built":"planned",output:y,disposition:null},c.set(w,h)}return h}function f(w,b){if(!Co(w)||!Co(b))return;a.has(w)||a.set(w,b);let T=c.get(w);T&&T.state!=="attached"&&!T.output&&(T.output=b,T.state="built")}function d(w){if(!c.size)return;let b=new Map,T=new WeakMap,g=new WeakMap,h=new WeakSet,y=new Set,N=(W,H)=>{if(!W)return;if(Array.isArray(W)){for(let A of W)N(A,H);return}let k=b.get(W);k||b.set(W,k=[]),k.push(H)},x=(W,H)=>{if(!W)return;let k=[W];for(;k.length;){let A=k.pop();N(A,H);for(let J of Qo(A).childNodes)k.push(J)}};function S(W,H=null,k=!1){if(h.has(W))return;h.add(W),T.set(W,H);let A=e.get(W),J=k||!!(A&&s(A.remote||A.base));g.set(W,J);let _={node:W,kind:"node",authority:J};if(A?.pinned)x(A.local,{..._,kind:"ignored"});else if(A?.unchanged)for(let F of[A.base,A.local,A.remote])x(F,{..._,kind:"unchanged"});else if(A){for(let F of[A.base,A.local,A.remote])N(F,_);if(Co(A.local))for(let F of Qo(A.local).children)i(F)&&x(F,{..._,kind:"ignored"})}for(let F of Qo(W).childNodes)S(F,W,J)}let O=W=>{if(W.output&&h.has(W.output))return W.state="attached",W.disposition="node",!0;let{local:H,remote:k}=n(W.owner);for(let A of[W.owner,H,k]){let J=b.get(A);if(J?.length){let _=J.find(F=>F.kind==="node")||J[0];return W.output=_.node,W.state="attached",W.disposition=_.kind,!0}}return!1},R=(W,H)=>(b.get(W)||[]).find(A=>A.kind==="node"&&Co(A.node)&&(!A.authority||H.sourceSide==="remote"))?.node,M=(W,H,k)=>{let A=b.get(W)||[],J=k?[...A].reverse():A;for(let _ of J){if(_.kind!=="node")continue;let F=_.node;for(;F&&T.get(F)!==H;)F=T.get(F);if(F)return F}return null},j=(W,H,k)=>{let A=Qo(H);for(let J=k?.previousSibling;J;J=J.previousSibling){let _=M(J,H,!0);if(_){A.insertBefore(W,_.nextSibling);return}}for(let J=k?.nextSibling;J;J=J.nextSibling){let _=M(J,H,!1);if(_){A.insertBefore(W,_);return}}A.appendChild(W)};function U(W,H,k){let A=H==="base"?W:o(W,H),J=c.get(A);J&&J!==k&&K(J)}function K(W){if(W.state==="attached"||W.disposition==="remote-wins"||y.has(W)||O(W))return;y.add(W);let{local:H,remote:k}=n(W.owner);if(s(k||W.owner)){if(!k){W.disposition="remote-wins",l(W.owner,H),y.delete(W);return}W.parent=t(k),W.port=k,W.sourceSide="remote"}if(U(W.parent,W.sourceSide,W),O(W)){y.delete(W);return}let A=R(W.parent,W),J=W.port;if(!A){if(U(W.originalParent,"base",W),O(W)){y.delete(W);return}let F=W.originalParent;for(J=W.originalPort;F&&!A;)A=R(F,W),A||(J=F,F=t(F))}if(!A)throw new Error("A planned move has no allowed surviving parent");let _=W.output||r(W.owner);W.output=_,W.state="built",j(_,A,J),S(_,A,g.get(A)||!1),O(W),y.delete(W)}S(w);for(let W of c.values())K(W)}return{planned:c,has:w=>c.has(w),plan:p,produced:f,drain:d}}function Ro(e,t,n,o,r,i,s,l,c,a,p,f,d){let w=null;return qa({provenance:e,parentOf:g=>{if(!g)return null;let h=t(g);if(h||g.parentNode?.nodeType!==11)return h;if(!w){w=new WeakMap;let y=[f,d];for(;y.length;){let N=y.pop(),x=Qo(N);x!==N&&w.set(x,N);for(let S of x.children)y.push(S)}}return w.get(g.parentNode)||null},twins:g=>({local:r(n,g),remote:r(o,g)}),baseOf:(g,h)=>g&&(h==="local"?n:o).reverse.get(g)||null,build:g=>i(g,r(n,g),r(o,g),!1),ignored:s,remoteWins:l,discarded:(g,h)=>{h&&p(g,h,n)&&!c.some(y=>y.detail==="remote-wins"&&y.base===g)&&a({kind:"structure",el:null,detail:"remote-wins",base:g,local:h,remote:null},{subject:g})}})}function Ka({parent:e,base:t,views:n,eligible:o,ignored:r,remoteWins:i,budget:s=Wt(2e4*32),maxUnits:l=256,maxCharacters:c=2e4}){let a=(h,y=null)=>({status:h,reason:y,parent:e,records:[]});if(n.some(({V:h})=>h.asBase)||r(e)||i(e)||n.some(({V:h})=>!h.el||r(h.el)||i(h.el)))return a("none");let p=t.length+n[0].V.units.length+n[1].V.units.length;if(p>l)return a("fallback","unit-limit");let f=Symbol(),d=h=>{if(h>s.remaining)throw f;s.remaining-=h,s.crossParentSteps=(s.crossParentSteps||0)+h},w=new Map,b=0,T=h=>{if(d(1),w.has(h))return w.get(h);let y=h.nodeType===1?h.childNodes:h.nodes;d(y.length*4+1);let N=h.nodeType===1?Array.from(y):y,x=0;for(let R=0;R<N.length;R++){let M=N[R];if(M.nodeType!==3||R&&N[R-1].nextSibling!==M)return w.set(h,null),null;x+=M.data.length}if(x>c-b)throw f;d(x*8+1),b+=x;let S=zt(N);if(S.text.includes(wt))return w.set(h,null),null;let O={unit:h,nodes:N,flat:S};return w.set(h,O),O},g=[];try{d(p*8+1);for(let h=0;h<2;h++){let y=n[h].V,N=n[1-h].V,x=[],S=new Map;for(let O=0;O<t.length;O++){d(1);let R=t[O];if(R.kind!=="text"||y.twin(R))continue;let M=N.twin(R);if(!M||M.kind!=="text"||!N.here(M))continue;let j=T(R),U=T(M);if(!j||!U||!/\S/.test(j.flat.text))continue;d(j.flat.text.length*2+1);let K=j.flat.text;S.set(K,(S.get(K)||0)+1),x.push({source:R,opposite:M,sourceModel:j,oppositeModel:U,index:O})}for(let O of x){let{source:R,opposite:M,sourceModel:j,oppositeModel:U,index:K}=O,W=[];for(let G of[-1,1]){d(1);let ue=t[K+G];if(!ue||ue.nodeType!==1||!o(ue)||r(ue)||i(ue))continue;let ae=j.nodes[0],Pe=j.nodes.at(-1);if(G===-1?ae?.previousSibling!==ue:Pe?.nextSibling!==ue)continue;let He=y.twin(ue),ve=N.twin(ue);if(!He||!ve||!y.here(He)||N.here(ve)||y.baseOf(He)!==ue||N.baseOf(ve)!==ue||!o(He)||!o(ve)||r(He)||r(ve)||i(He)||i(ve)||He.tagName!==ue.tagName||ve.tagName!==ue.tagName||He.namespaceURI!==ue.namespaceURI||ve.namespaceURI!==ue.namespaceURI)continue;let Ze=T(ue),Je=T(He),pt=T(ve);if(!Ze||!Je||!pt||!/\S/.test(Ze.flat.text))continue;let Ye=Ze.flat.text,dt=j.flat.text,St=Je.flat.text;if(d((Ye.length+dt.length+St.length)*3+1),St.length!==Ye.length+dt.length)continue;let vt=G===-1;(vt?!St.startsWith(Ye)||!St.endsWith(dt):!St.startsWith(dt)||!St.endsWith(Ye))||W.push({owner:ue,target:He,moved:ve,ownerBase:Ze,joined:Je,ownerOther:pt,targetFrom:vt?Ye.length:0,retainedFrom:vt?0:dt.length})}if(!W.length)continue;if(W.length!==1||S.get(j.flat.text)!==1)return a("fallback","ambiguous-origin");let H=W[0],{owner:k,target:A,moved:J,ownerBase:_,joined:F,ownerOther:Oe,targetFrom:Ce,retainedFrom:De}=H;if(d(g.length+1),g.some(G=>G.owner===k))return a("fallback","ambiguous-owner");let pe={source:R,target:A,from:0,to:j.flat.text.length,targetFrom:Ce},Te=Rn({base:j.flat,side:F.flat,retained:[],transfers:[{from:pe.from,to:pe.to,target:Ce,destination:k}],budget:s});if(Te.status!=="ready"||Te.covers(pe.from,pe.to)!==!0)return a("fallback",Te.reason||"work-limit");let ze=[{unit:R,model:j,from:0,to:j.flat.text.length},null,null];ze[h+1]={unit:A,model:F,from:Ce,to:Ce+j.flat.text.length},ze[2-h]={unit:M,model:U,from:0,to:U.flat.text.length};let Me=[_,null,null];Me[h+1]=F,Me[2-h]=Oe;let v=[k,null,null];v[h+1]=A,v[2-h]=J,g.push({side:h,parent:e,source:R,target:A,owner:k,owners:v,ownerModels:Me,native:ze,models:w,runs:[pe],proof:Te,retained:[{source:k,target:A,from:0,to:_.flat.text.length,targetFrom:De}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:a("none")}catch(h){if(h!==f)throw h;return a("fallback","work-limit")}}function ml({describe:e,parentOf:t,...n}){let o=new WeakMap,r=new WeakMap,i=n.budget||Wt(2e4*32),s=l=>{if(!l)return null;if(o.has(l))return o.get(l);o.set(l,{status:"planning",parent:l,records:[]});let c=e(l),a=c?Ka({...n,...c,parent:l,budget:i}):{status:"none",reason:null,parent:l,records:[]};if(o.set(l,a),a.status==="ready")for(let p of a.records)r.set(p.owner,[p]);return a};return{get:s,forOwner(l){return s(t(l))?.status==="ready"&&r.get(l)||null}}}function za(e,t){if(e.side!==0)return null;let n=e.native[0].model,o=e.ownerModels[0],r=e.native[1].from!==0,i=(N,x)=>r?[...N.nodes,...x.nodes]:[...x.nodes,...N.nodes],s=e.ownerModels.reduce((N,x)=>N+x.flat.text.length,0)+n.flat.text.length+e.native[2].model.flat.text.length;if(s*8>t.remaining)return null;t.remaining-=s*8;let l={base:i(o,n),local:e.ownerModels[1].nodes,remote:i(e.ownerModels[2],e.native[2].model)},c=zt(l.base),a=e.ownerModels[1].flat,p=zt(l.remote),f=r?o.flat.text.length:0,d=r?0:n.flat.text.length,w=Rn({base:c,side:a,retained:e.retained.map(N=>({from:d+N.from,to:d+N.to,target:N.targetFrom})),transfers:e.runs.map(N=>({from:f+N.from,to:f+N.to,target:N.targetFrom,destination:e.owner})),budget:t});if(w.status!=="ready"||w.covers(0,c.text.length)!==!0)return null;let b=e.ownerModels[2].flat,T=e.native[2].model.flat,g=[];for(let[N,x,S,O]of[[o.flat,b,d,r?0:T.text.length],[n.flat,T,f,r?b.text.length:0]]){let R=Ts(N,N,x).remoteMap.bTo,M=-1;for(let j=0;j<N.text.length;j++){if(R[j]<0){M=-1;continue}let U=g.at(-1);M>=0&&U.to===S+j&&U.target+U.to-U.from===O+R[j]?U.to++:(g.push({from:S+j,to:S+j+1,target:O+R[j]}),M=j)}}let h=Rn({base:c,side:p,retained:g,transfers:[],budget:t});if(h.status!=="ready")return null;let y=Ts(c,a,p,{},{local:w,remote:h});return y.localEdits.hunks.length?null:(y.localMap=w,y.remoteMap=h,{nodes:l,prepared:y})}function gl({L:e,R:t,twinIn:n,unitsOf:o,view:r,parentOf:i,ignored:s,remoteWins:l,eligible:c,build:a,out:p,policy:f,provenance:d,textMappers:w,segments:b,conflicts:T,conflict:g,decisions:h}){let y=Wt(2e4*32),N=W=>{let H=0;for(let k=W;k;k=i(k))if(++H>64||k.nodeType===1&&(s(k)||l(k)))return!1;return!0},x=ml({parentOf:i,eligible:c,ignored:s,remoteWins:l,budget:y,describe(W){let H=n(e,W),k=n(t,W);return!H||!k||!N(W)||!N(H)||!N(k)?null:{base:o(W),views:[{A:e,V:r(e,H,W,!1)},{A:t,V:r(t,k,W,!1)}]}}}),S=new WeakSet,O=new WeakMap,R=new WeakSet,M=[];function j(W){if(!W||S.has(W))return;S.add(W);let H=x.get(W);if(H?.status==="ready")for(let k of H.records){if((W.tagName==="TEMPLATE"&&W.content?W.content:W).childNodes.length!==k.native[0].model.nodes.length+1||!k.owners.every(N))continue;let J=za(k,y);if(!J)continue;let _={record:k,payload:J,state:"planned",output:null,result:null};O.set(k.owner,_),R.add(k.source),R.add(k.native[2].unit),M.push(_)}}function U(W,H){let k=O.get(W);if(!k)return!1;if(!k.result){if(k.result=Rr({...k.payload.nodes,prepared:k.payload.prepared,out:p,policy:f,provenance:d,textMappers:w,conflicts:T,conflict:g,decisions:h,node:H}),k.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");b.push(...k.result.segments),k.decision={kind:"text",node:H,source:"local"},h.push(k.decision)}return k.decision.node=H,H.replaceChildren(...k.result.nodes),k.output=H,k.state="built",!0}function K(W){if(!M.length)return;let H=new WeakSet,k=new WeakMap,A=new WeakMap,J=new WeakMap,_=Te=>Te.tagName==="TEMPLATE"&&Te.content?Te.content:Te,F=(Te,ze)=>{if(!Te)return;if(Array.isArray(Te)){for(let v of Te)F(v,ze);return}let Me=J.get(Te);Me||J.set(Te,Me=[]),Me.push(ze)},Oe=(Te,ze=null,Me=!1)=>{H.add(Te),k.set(Te,ze);let v=d.get(Te),G=Me||!!(v&&l(v.remote||v.base));if(A.set(Te,G),v)for(let ue of[v.base,v.local,v.remote])F(ue,Te);if(!(v?.pinned||v?.unchanged))for(let ue of _(Te).childNodes)Oe(ue,Te,G)},Ce=Te=>(J.get(Te)||[]).find(ze=>ze.nodeType===1&&!A.get(ze)&&!d.get(ze)?.pinned&&!d.get(ze)?.unchanged),De=(Te,ze)=>{for(let Me of J.get(Te)||[]){let v=Me;for(;v&&k.get(v)!==ze;)v=k.get(v);if(v)return v}return null},pe=(Te,ze,Me)=>{let v=_(ze);for(let G=Me.nextSibling;G;G=G.nextSibling){let ue=De(G,ze);if(ue){v.insertBefore(Te,ue);return}}for(let G=Me.previousSibling;G;G=G.previousSibling){let ue=De(G,ze);if(ue){v.insertBefore(Te,ue.nextSibling);return}}v.appendChild(Te)};Oe(W);for(let Te of M){let{record:ze}=Te,Me=Ce(ze.owner)||Ce(ze.owners[1])||Ce(ze.owners[2]);if(Me)(!Te.result||Te.output!==Me||Te.result.nodes.some(v=>!H.has(v)||k.get(v)!==Me)||Me.textContent!==Te.result.text)&&(U(ze.owner,Me),Oe(Me,k.get(Me),A.get(Me)));else{let v=ze.parent,G=ze.owner,ue=null;for(;v&&!ue;)ue=Ce(v),ue||(G=v,v=i(v));if(!ue)throw new Error("A cross-parent payload has no allowed surviving parent");Me=Te.output||a(ze.owner,ze.owners[1],ze.owners[2],!1),Te.result||U(ze.owner,Me),pe(Me,ue,G),Oe(Me,ue,A.get(ue))}Te.state="attached"}}return{ensureParent:j,ensureOwner(W){j(i(W))},consumes(W){return R.has(W)},render:U,drain:K}}var wn=/\S/,bl=/[\p{L}\p{N}]/u;function uo(e,t,n,o){if(e?.nodeType!==1||!t(e))return!1;for(let r=e.firstChild;r;r=r.nextSibling)if(o(n,1),r.nodeType!==3)return!1;return!!e.firstChild}function Rs(e,t,n){for(let o=e.parentNode;o;o=o.parentNode)if(n(t,1),o.nodeType===11)return!1;return!0}function yl(e,t,n,o,r){let i=n(e,o),s=n(t,o),l=null,c=null,a=null,p=null;r(o,i.length+s.length);for(let f of i)bl.test(f.raw)&&(l||=f,c=f);for(let f of s)bl.test(f.raw)&&(a||=f,p=f);return!!(l&&a&&(l.raw===a.raw||c.raw===p.raw))}function Ga({base:e,V:t,A:n,source:o,original:r,current:i,edited:s,destination:l,at:c,ownLength:a,eligible:p,model:f,tokensOf:d,budget:w,charge:b}){let T=r.flat.text,g=i.flat.text,h=s.flat.text,y=l.flat.text;if(b(w,T.length+g.length+y.length),T.startsWith(g)||T.endsWith(g))return!1;let N=wn.test(y.slice(0,c)),x=wn.test(y.slice(c+a));if(N===x)return!1;let S=N?0:c+a,O=N?c:y.length;for(;S<O&&!wn.test(y[S]);)S++;for(;O>S&&!wn.test(y[O-1]);)O--;let R=y.slice(S,O);if(Tn(R,y,d(l,w),w,b,!0)!==S)return!1;let M=Tn(R,T,d(r,w),w,b,!0);if(M<0)return!1;let j=M+R.length,U=!wn.test(T.slice(0,M)),K=!wn.test(T.slice(j));if(U===K||Tn(R,g,d(i,w),w,b,!1)>=0)return!1;let W=U?T.slice(j):T.slice(0,M),H=U?h.length-W.length:0;if(b(w,T.length+h.length),H<0||!wn.test(W)||Tn(W,h,d(s,w),w,b,!0)!==H||!wn.test(U?h.slice(0,H):h.slice(W.length)))return!1;for(let k of e){if(b(w,1),k===o||!uo(k,p,w,b))continue;let A=f(k,null,w);if(Tn(R,A.flat.text,d(A,w),w,b,!1)>=0)return!1}for(let k of t.units){if(b(w,1),k===i.unit||k===l.unit||!uo(k,p,w,b))continue;let A=f(k,n,w);if(Tn(R,A.flat.text,d(A,w),w,b,!1)>=0)return!1}return!0}function wl({base:e,views:t,side:n,attempt:o,eligible:r,blocked:i,baseId:s,model:l,tokensOf:c,charge:a,exhausted:p,limit:f}){if(f<=0)return null;let d=Wt(f),{V:w,A:b,idOf:T}=t[n],g=t[1-n],[h,y,N,x]=o,S=null;try{for(let O=h;O<=y;O++){a(d,1);let R=e[O];if(R.parentNode?.nodeType!==1||i.has(R)||b.identical.has(R)||g.A.identical.has(R)||!uo(R,r,d,a)||s(R))continue;let M=w.twin(R),j=g.V.twin(R);if(!M||!j||!w.here(M)||!g.V.here(j)||b.map.get(R)!==M||b.reverse.get(M)!==R||g.A.map.get(R)!==j||g.A.reverse.get(j)!==R||T(M)||g.idOf(j)||M.tagName!==R.tagName||j.tagName!==R.tagName||!uo(M,r,d,a)||!uo(j,r,d,a)||!Rs(R,d,a)||!Rs(M,d,a)||!Rs(j,d,a))continue;let U=l(R,null,d),K=l(M,b,d),W=l(j,g.A,d),H=U.flat.text,k=K.flat.text,A=W.flat.text;if(a(d,H.length+k.length+A.length),!wn.test(H)||!wn.test(k)||!wn.test(A)||H===k||H===A||k===A||!yl(U,K,c,d,a)||!yl(U,W,c,d,a))continue;let J=null,_=!1;for(let Ce=N;Ce<=x;Ce++){a(d,1);let De=w.units[Ce],pe=w.baseOf(De);if(!pe||pe===R||i.has(pe)||pe.parentNode!==R.parentNode||De.parentNode!==M.parentNode||pe.tagName!==R.tagName||De.tagName!==R.tagName||b.map.get(pe)!==De||b.reverse.get(De)!==pe||s(pe)!==T(De)||!uo(pe,r,d,a)||!uo(De,r,d,a))continue;let Te=l(pe,null,d),ze=l(De,b,d),Me=Te.flat.text,v=ze.flat.text;if(a(d,Me.length),!wn.test(Me)||v.length<=Me.length)continue;let G=c(ze,d),ue=Tn(Me,v,G,d,a,!0);if(!(ue<0||Tn(H,v,G,d,a,!0,ue,ue+Me.length)<0&&!Ga({base:e,V:w,A:b,source:R,original:U,current:K,edited:W,destination:ze,at:ue,ownLength:Me.length,eligible:r,model:l,tokensOf:c,budget:d,charge:a}))){if(J){_=!0;break}J=De}}if(!J||_)continue;let F=n===0?M:j,Oe=n===0?j:M;(S||=[]).push({source:R,local:F,remote:Oe,models:[U,n===0?K:W,n===0?W:K]})}}catch(O){if(O!==p)throw O}return S}var jn=/\S/,cn=/\s/,Ya=/[\s\u001e]/g,Ls=/[^\s\p{P}\u001e\ufffc]/u;function Xa(e,t,n,o,r,i,s){let l=0;for(let c of e)s(i,1),c.nodeType===1&&!o.baseOf(c)&&l++;if(l<2)return!1;for(let c of e){if(c.nodeType!==1||o.baseOf(c))continue;let a=r.get(c).flat;if(a.atoms.length||a.pins?.length)continue;s(i,a.text.length*2+t.length+n.length);let p=new Uint8Array(a.text.length);for(let f of n)f.target===c&&p.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f of t)f.target===c&&p.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f=0;f<a.text.length;f++)if(!p[f]&&jn.test(a.text[f]))return!0}return!1}function Ja(e,t,n){let{source:o,models:r,retained:i,runs:s}=e,l=r.get(o).flat.text;n(t,l.length*2+i.length+s.length);let c=new Uint8Array(l.length);for(let a of i)a.source===o&&(n(t,a.to-a.from),c.fill(1,a.from,a.to));for(let a of s)n(t,a.to-a.from),c.fill(1,a.from,a.to);for(let a=0;a<l.length;a++)if(!c[a]&&jn.test(l[a]))return!1;return!0}function Za(e,t,n,o,r,i,s,l,c,a){let p=i.get(e),f=i.get(t),d=p.flat.text,w=s.get(e);c(a,d.length*2+n.length);let b=d.length,T=0;for(let y=0;y<d.length;y++)!cn.test(d[y])&&!w[y]&&(b=Math.min(b,y),T=y+1);if(b>=T)return null;for(let y=b;y<T;y++)if(!cn.test(d[y])&&w[y])return null;let g=-1;for(let y of n)if(y.target===t&&y.from<=b&&y.to>b){g=y.targetFrom+b-y.from;break}if(g<0)return null;let h=d.slice(b,T);if(c(a,h.length*(n.length+2)),f.flat.text.slice(g,g+h.length)!==h)return null;for(let y=b;y<T;y++){if(cn.test(d[y]))continue;let N=!1;for(let x of n)if(x.target===t&&x.from<=y&&x.to>y&&x.targetFrom+y-x.from===g+y-b){N=!0;break}if(!N)return null}if(p.flat.atoms.length||f.flat.atoms.length){c(a,p.flat.atoms.length+f.flat.atoms.length);let y=0,N=f.flat.atoms;for(;y<N.length&&N[y].i<g;)y++;for(let x of p.flat.atoms){if(x.i<b||x.i>=T)continue;let S=N[y++];if(!S||S.i!==g+x.i-b||f.alignment?.reverse.get(S.el)!==x.el)return null}if(y<N.length&&N[y].i<g+T-b)return null}for(let[y,N,x]of[[o,e,b],[r,t,g]]){let S=!1;for(let O of y){let R=i.get(O),M=s.get(O),j=l(R,a);for(let U=0;U<j.length;U++){let K=j[U].from,W=K+h.length;if(c(a,h.length*2+1),R.flat.text.slice(K,W)!==h)continue;let H=U;for(;H<j.length&&j[H].to<W;)c(a,1),H++;if(H===j.length||j[H].to!==W)continue;let k=!0;for(let A=K;A<W;A++)if(!cn.test(R.flat.text[A])&&M[A]){k=!1;break}if(k){if(S||O!==N||K!==x)return null;S=!0}}}if(!S)return null}return h}function Qa(e,t,n,o,r,i,s,l){if(s(l,r.length+i.length+(o.length+1)*n.length*2),!n)return!1;let c=o.indexOf(n);return c<0||o.lastIndexOf(n)!==c||!i.some(a=>a.from===c)||!i.some(a=>a.to===c+n.length)?!1:r.some(a=>a.source===e&&a.target===t&&a.from===0&&a.to===n.length&&a.targetFrom===c)}function xl({base:e,views:t,eligible:n,baseId:o,ignored:r,remoteWins:i,atomKey:s,limit:l=2e4*8}){if(l<=0)return null;let c=Symbol(),a=(x,S)=>{if(S>x.remaining)throw c;x.remaining-=S},p=[new Map,new Map];for(let x=0;x<2;x++)for(let S=0;S<t[x].V.units.length;S++)p[x].set(t[x].V.units[S],S);let f=new Int32Array(e.length),d=new Int32Array(e.length),w=x=>t.every(({V:S},O)=>{let R=S.twin(x);return R&&p[O].has(R)}),b=-1;for(let x=0;x<e.length;x++)f[x]=b,w(e[x])&&(b=x);b=e.length;for(let x=e.length-1;x>=0;x--)d[x]=b,w(e[x])&&(b=x);let T=new Map,g=(x,S)=>{if(a(S,1),T.has(x))return T.get(x);let O=x.firstChild,R=1;for(;O;){if(a(S,R*8+8),O.nodeType===3&&a(S,O.data.length*8),O.nodeType===1&&pn.has(O.tagName)&&!r(O)&&!i(O)&&O.firstChild){O=O.firstChild,R++;continue}for(;O&&O!==x&&!O.nextSibling;)O=O.parentNode,R--;O=!O||O===x?null:O.nextSibling}let M=zt(Array.from(x.childNodes),{ignored:r,remoteWins:i});return T.set(x,M),M},h=(x,S,O,R,M,j)=>{for(let U of x.atoms){a(j,1);let K=S.atomAt.get(U.i+O);if(!K)return!1;let W=R?.reverse.get(U.el)||s(U.el),H=M?.reverse.get(K.el)||s(K.el);if(W!==H)return!1}return!0},y=(x,S,O,R,M)=>{let j=x.text.length<=S.text.length?x:S,U=j===x?S:x;if(a(M,j.text.length+U.text.length),!j.text||!jn.test(j.text.replaceAll(Ln,"")))return!1;let K;if(j.text===U.text)K=0;else{let W=U.text.length-j.text.length;if(a(M,(W+1)*j.text.length*2),U.text.startsWith(j.text))K=0;else if(U.text.endsWith(j.text))K=W;else return!1;if(U.text.indexOf(j.text)!==K||U.text.lastIndexOf(j.text)!==K)return!1;a(M,U.text.length*2);let H=0,k=K===0,A=!1;for(let J of tn(U.text,hn(U.text)))H+=J.len,H===K&&(k=!0),H===K+j.text.length&&(A=!0);if(!k||!A)return!1}return j===x?h(j,U,K,O,R,M):h(j,U,K,R,O,M)},N=null;for(let x=0;x<2;x++){let{V:S,A:O,idOf:R}=t[x],M=t[1-x];if(!S.asBase)for(let j=0;j<e.length;j++){let U=e[j];if(S.twin(U)||!n(U))continue;let K=M.V.twin(U);if(!K||!p[1-x].has(K)||!n(K))continue;let W={remaining:l};try{let H=f[j],k=d[j],A=0;for(let Oe=H+1;Oe<k;Oe++)a(W,1),!S.twin(e[Oe])&&M.V.twin(e[Oe])&&n(e[Oe])&&A++;if(A!==1||g(U,W).text===g(K,W).text)continue;let J=H<0?-1:p[x].get(S.twin(e[H])),_=k===e.length?S.units.length:p[x].get(S.twin(e[k]));if(J===void 0||_===void 0||J>=_)continue;let F=null;for(let Oe=J+1;Oe<_;Oe++){a(W,1);let Ce=S.units[Oe];if(S.baseOf(Ce)||!n(Ce)||Ce.tagName!==U.tagName||Ce.namespaceURI!==U.namespaceURI)continue;let De=o(U),pe=M.idOf(K),Te=R(Ce);if(!(De&&pe&&De!==pe||De&&Te&&De!==Te||pe&&Te&&pe!==Te)&&y(g(K,W),g(Ce,W),M.A,O,W)){if(F){F=null;break}F=Ce}}if(!F)continue;N||(N=[new Map,new Map]),N[x].set(U,F)}catch(H){if(H!==c)throw H}}}return N?t.map(({V:x},S)=>{let O=N[S];if(!O.size)return x;let R=new Map;for(let[M,j]of O)R.set(j,M);return{...x,twin:M=>O.get(M)||x.twin(M),baseOf:M=>R.get(M)||x.baseOf(M)}}):null}function kl({onUncertainSource:e,onUncertainOwner:t,base:n,views:o,eligible:r,ignored:i,remoteWins:s,baseId:l,atomKey:c,limit:a=2e4*32}){if(a<=0)return null;let p=new Set(n),f=new Map(n.map((H,k)=>[H,k])),d=new Map,w=[],b=null,T=null,g=null,h=new Set;for(let H of n)for(let{V:k}of o){let A=k.twin(H);A&&!k.asBase&&!k.here(A)&&h.add(H)}let y=new Set,N=Symbol(),x=(H,k)=>{if(k>H.remaining)throw N;H.remaining-=k},S=(H,k,A)=>{x(A,1);let J=d.get(H);if(J)return J;if(H.nodeType===1){let Oe=H.firstChild,Ce=1;for(;Oe;){if(x(A,Ce*8+8),Oe.nodeType===3&&x(A,Oe.data.length*8),Oe.nodeType===1&&pn.has(Oe.tagName)&&!i(Oe)&&!s(Oe)&&Oe.firstChild){Oe=Oe.firstChild,Ce++;continue}for(;Oe&&Oe!==H&&!Oe.nextSibling;)Oe=Oe.parentNode,Ce--;Oe=!Oe||Oe===H?null:Oe.nextSibling}}else x(A,H.value.length*8+H.nodes.length);let _=H.nodeType===1?Array.from(H.childNodes):H.nodes,F=_.length===1&&_[0].nodeType===3?{text:_[0].data,nodes:[{node:_[0],s:0,e:_[0].data.length}],atoms:[]}:zt(_,{ignored:i,remoteWins:s});return J={unit:H,flat:F,alignment:k,tokens:null},d.set(H,J),J},O=(H,k)=>{if(H.tokens)return H.tokens;x(k,H.flat.text.length*8);let{unit:A,flat:J,alignment:_}=H,F=[],Oe=hn(J.text),Ce=0,De=pe=>{for(let Te of tn(J.text.slice(Ce,pe),Oe))Te.from=Ce,Te.to=Ce+Te.len,Te.unit=A,F.push(Te),Ce+=Te.len};for(let pe of J.atoms){De(pe.i);let Te=s(pe.el)&&pe.el.nodeType===1?"w"+pe.el.tagName+"#"+(pe.el.id||""):c(_?.reverse.get(pe.el)||pe.el);F.push({k:Te,raw:Ln,len:1,from:Ce,to:Ce+1,unit:A,atom:!0}),Ce++}return De(J.text.length),H.tokens=F,F},R=(H,k,A,J,_)=>{if(!H.flat.atoms.length&&!k.flat.atoms.length)return!0;let F=O(H,_),Oe=O(k,_);x(_,F.length+Oe.length);let Ce=0;for(let De of Oe){if(!De.atom||De.from<A||De.from>=A+J)continue;for(;Ce<F.length&&!F[Ce].atom;)Ce++;let pe=F[Ce++];if(!pe||pe.from!==De.from-A||pe.k!==De.k)return!1}for(;Ce<F.length;)if(F[Ce++].atom)return!1;return!0},M=(H,k,A)=>{let J=H.length+k.length+4;if(J*8>A.remaining)return null;A.remaining-=J*8;let _=Math.floor(A.remaining/8),F=Math.min(H.length+k.length,4e3,Math.floor((Math.sqrt(J*J+_)-J)/2)),Oe=4*(F+1)*(J+F+1);if(F<1||Oe>A.remaining)return null;A.remaining-=Oe;let Ce=_n(H,k,F),De=[],pe=0,Te=0;for(let ze of Ce.hunks){for(;pe<ze.bs;)H[pe].raw===k[Te].raw&&De.push([H[pe],k[Te]]),pe++,Te++;pe=ze.be,Te+=ze.toks.length}for(;pe<H.length&&Te<k.length;)H[pe].raw===k[Te].raw&&De.push([H[pe],k[Te]]),pe++,Te++;return De},j=(H,k,A,J,_,F,Oe)=>{if(_<=J)return;let Ce=H[H.length-1];if(Ce&&Ce.source===k&&Ce.target===A&&Ce.to<=J&&Ce.targetFrom-Ce.from===F-J){x(Oe,(J-Ce.to)*3);let De=d.get(k).flat.text,pe=d.get(A).flat.text,Te=!0;for(let ze=Ce.to;ze<J;ze++)if(!cn.test(De[ze])||De[ze]!==pe[F+ze-J]){Te=!1;break}if(Te){Ce.to=_;return}}H.push({source:k,target:A,from:J,to:_,targetFrom:F})},U=H=>H.replace(Ya,"");for(let H=0;H<o.length;H++){let{V:k,A,idOf:J}=o[H];if(k.asBase)continue;let _=new Map(k.units.map((v,G)=>[v,G])),F=v=>{let G=k.twin(v);return G&&_.has(G)?G:null},Oe=(v,G)=>{let ue=new Int32Array(v.length),ae=new Int32Array(v.length),Pe=-1;for(let He=0;He<v.length;He++)ue[He]=Pe,G(v[He])&&(Pe=He);Pe=v.length;for(let He=v.length-1;He>=0;He--)ae[He]=Pe,G(v[He])&&(Pe=He);return{prev:ue,next:ae}},Ce=Oe(n,v=>(v.nodeType===1||v.kind==="text"&&jn.test(v.value))&&F(v)),De=Oe(k.units,v=>(v.nodeType===1||v.kind==="text"&&jn.test(v.value))&&p.has(k.baseOf(v))),pe=new Map,Te=(v,G,ue,ae)=>{if(v>G||ue>ae)return;let Pe=`${v}:${G}:${ue}:${ae}`;pe.set(Pe,[v,G,ue,ae])};for(let v=0;v<k.units.length;v++){let G=k.units[v];if(k.baseOf(G)||!r(G))continue;let ue=De.prev[v],ae=De.next[v],Pe=ue<0?0:f.get(k.baseOf(k.units[ue])),He=ae===k.units.length?n.length-1:f.get(k.baseOf(k.units[ae]));Te(Pe,He,Math.max(0,ue),Math.min(k.units.length-1,ae))}for(let v=0;v<n.length;v++){let G=n[v];if(h.has(G)||!r(G))continue;if(!k.twin(G)){let Ze=Ce.prev[v],Je=Ce.next[v],pt=Ze<0?0:_.get(F(n[Ze])),Ye=Je===n.length?k.units.length-1:_.get(F(n[Je]));Te(Math.max(0,Ze),Math.min(n.length-1,Je),pt,Ye)}let ue=F(G);if(!ue||A.identical.has(G)||!r(ue))continue;let ae=v+1;for(;ae<n.length&&n[ae].kind==="text"&&!n[ae].value.trim();)ae++;if(ae>=n.length||!r(n[ae]))continue;let Pe=F(n[ae]);if(!Pe||A.identical.has(n[ae])||!r(Pe))continue;let He=_.get(ue),ve=_.get(Pe);He<ve&&Te(v,ae,He,ve)}let ze=Array.from(pe.values()),Me=new Set;if(ze.length>1){let v=Wt(a);try{x(v,ze.length*4);let G=ze.slice().sort((Pe,He)=>(x(v,1),Pe[0]-He[0]||Pe[2]-He[2])),ue=[],ae=null;for(let Pe of G)x(v,1),ae&&Pe[0]<=ae[1]&&Pe[2]<=ae[3]&&Pe[3]>=ae[2]?(ae[1]=Math.max(ae[1],Pe[1]),ae[2]=Math.min(ae[2],Pe[2]),ae[3]=Math.max(ae[3],Pe[3]),ae[4].push(Pe)):(ae?.[4].length>1&&ue.push(ae),ae=[Pe[0],Pe[1],Pe[2],Pe[3],[Pe]]);ae?.[4].length>1&&ue.push(ae),ze=ue.concat(ze)}catch(G){if(G!==N)throw G}}for(let v of ze){if(Me.has(v))continue;let[G,ue,ae,Pe,He]=v,ve=Wt(a),Ze=[],Je=new Set,pt=!1;try{x(ve,(ue-G+Pe-ae+2)*4);let Ye=n.slice(G,ue+1).filter(B=>!A.identical.has(B)&&r(B)&&!h.has(B)),dt=k.units.slice(ae,Pe+1).filter(B=>r(B)&&(!k.baseOf(B)||p.has(k.baseOf(B)))&&!A.identical.has(k.baseOf(B))&&!h.has(k.baseOf(B))),St=new Set(dt),vt=!1,bt="",At="",Ot=0;for(let B of Ye){let me=S(B,null,ve);bt+=me.flat.text,Ot+=me.flat.text.length}for(let B of dt){let me=S(B,A,ve);At+=me.flat.text,Ot+=me.flat.text.length}x(ve,Ot);let Bt=U(bt),nn=U(At),Nt=Bt===nn;if(pt=Nt,He&&!Nt)continue;let $t=Nt?null:new Map;if($t)for(let B of Ye.concat(dt)){let me=d.get(B).flat.text.length;x(ve,me*16),$t.set(B,new Uint8Array(me))}let an=B=>{let me=[];for(let xe of B){let fe=d.get(xe);fe.flat.atoms.length?me.push(...O(fe,ve)):me.push({unit:xe,raw:fe.flat.text,from:0})}return me},Pt=[];for(let B of Nt?[]:Ye){let me=F(B);if(!St.has(me))continue;let xe=S(B,null,ve),fe=S(me,A,ve);x(ve,xe.flat.text.length+fe.flat.text.length);let Se=xe.flat.text&&fe.flat.text.startsWith(xe.flat.text)?0:xe.flat.text&&fe.flat.text.endsWith(xe.flat.text)?fe.flat.text.length-xe.flat.text.length:-1;if(Se>=0&&R(xe,fe,Se,xe.flat.text.length,ve)){$t.get(B).fill(1),$t.get(me).fill(1,Se,Se+xe.flat.text.length),j(Pt,B,me,0,xe.flat.text.length,Se,ve);continue}let V=M(O(xe,ve),O(fe,ve),ve);if(!V){vt=!0;break}for(let[Z,be]of V)$t.get(B).fill(1,Z.from,Z.to),$t.get(me).fill(1,be.from,be.to),j(Pt,B,me,Z.from,Z.to,be.from,ve)}if(vt)continue;let Jt=null,Ft=null;if(!Nt)for(let B of Ye){let me=F(B),xe=d.get(B);if(!me||xe.flat.atoms.length||!St.has(me))continue;let fe=xe.flat.text,Se=$t.get(B);x(ve,fe.length*3+dt.length);let V=-1,Z=-1,be=!1;for(let je=0;je<fe.length;je++)cn.test(fe[je])||(Se[je]?be=!0:(V<0&&(V=je),Z=je+1));if(!be||V<0)continue;let ke=!0;for(let je=V;je<Z;je++)if(Se[je]&&!cn.test(fe[je])){ke=!1;break}if(!ke)continue;let we=U(fe.slice(V,Z)),te=null,re=!1;for(let je of dt){if(k.baseOf(je))continue;let Ae=d.get(je);if(!Ae.flat.atoms.length&&(x(ve,Ae.flat.text.length),U(Ae.flat.text)===we)){if(te){re=!0;break}te=je}}if(re){(Ft||=new Set).add(B);continue}if(!te||Ft?.has(B))continue;let q=!1;for(let je of Ye){if(je===B||!St.has(F(je)))continue;let Ae=d.get(je);if(Ae.flat.atoms.length)continue;let Ge=$t.get(je);x(ve,Ae.flat.text.length*3);let et="",Qe=!1;for(let Ut=0;Ut<Ae.flat.text.length;Ut++)cn.test(Ae.flat.text[Ut])||(Ge[Ut]?Qe=!0:et+=Ae.flat.text[Ut]);Qe&&et===we&&(Ft||=new Set,Ft.add(B),Ft.add(je),q=!0)}if(q)continue;let le=d.get(te).flat.text;x(ve,Z-V+le.length);let Ne=V,Le=0;for(;Ne<Z&&Le<le.length;){for(;Ne<Z&&cn.test(fe[Ne]);)Ne++;for(;Le<le.length&&cn.test(le[Le]);)Le++;if(Ne>=Z||Le>=le.length)break;j(Jt||=[],B,te,Ne,Ne+1,Le,ve),Ne++,Le++}Se.fill(1,V,Z),$t.get(te).fill(1)}let on=B=>{let me=[];for(let xe of B){let fe=S(xe,p.has(xe)?null:A,ve),Se=$t.get(xe);for(let V of O(fe,ve)){let Z=V.from;for(;Z<V.to;){for(;Z<V.to&&Se[Z];)Z++;let be=Z;for(;Z<V.to&&!Se[Z];)Z++;if(Z>be){let ke=fe.flat.text.slice(be,Z);jn.test(ke)&&me.push({...V,raw:ke,len:Z-be,k:V.atom?V.k:ke,from:be,to:Z})}}}}return me},Y=Nt?an(Ye):on(Ye),m=Nt?an(dt):on(dt),I=Nt?Bt:Y.map(B=>U(B.raw)).join(""),P=Nt?nn:m.map(B=>U(B.raw)).join("");if((!I||!P)&&!Jt)continue;let $=Jt||[];if(I&&P&&I===P){let B=0,me=0,xe=0,fe=0;for(;B<Y.length&&me<m.length;){let Se=Y[B],V=m[me];for(;xe<Se.raw.length&&cn.test(Se.raw[xe]);)xe++;for(;fe<V.raw.length&&cn.test(V.raw[fe]);)fe++;if(xe===Se.raw.length){B++,xe=0;continue}if(fe===V.raw.length){me++,fe=0;continue}if((Se.atom||V.atom)&&Se.k!==V.k){vt=!0;break}j($,Se.unit,V.unit,Se.from+xe,Se.from+xe+1,V.from+fe,ve),xe++,fe++}}else if(I&&P){let B=M(Y,m,ve);if(!B)continue;for(let[me,xe]of B)j($,me.unit,xe.unit,me.from,me.to,xe.from,ve)}if(vt)continue;let Q=new Map;for(let B of $)if(!Ft?.has(B.source)){if(F(B.source)===B.target){Nt&&Pt.push(B);continue}Q.has(B.source)||Q.set(B.source,[]),Q.get(B.source).push(B)}for(let[B,me]of Q){let xe=S(B,null,ve),fe=F(B),Se=xe.flat.text,V=[],Z=new Set,be=o[1-H],ke=be.V.twin(B),we=ke&&be.V.here(ke)?S(ke,be.A,ve):null,te=(Ae,Ge)=>{let et=O(Ae,ve),Qe=O(Ge,ve);return x(ve,Ae.flat.text.length+Ge.flat.text.length+et.length+Qe.length),Ae.flat.text===Ge.flat.text&&et.length===Qe.length&&et.every((Ut,Mt)=>Ut.k===Qe[Mt].k)},re=fe&&we&&we.flat.text!==Se&&te(S(fe,A,ve),we);for(let Ae of new Set(me.map(Ge=>Ge.target))){if(B.nodeType!==1&&Ae.nodeType!==1)continue;let Ge=S(Ae,A,ve),et=k.baseOf(Ae);if(B.nodeType!==1&&et||(x(ve,Se.length*2+Ge.flat.text.length*3+Pt.length*2),fe&&U(Se)===U(Ge.flat.text)&&S(fe,A,ve).flat.text.trim()))continue;if(!fe&&!et&&B.nodeType===1&&Ae.nodeType===1){let Lt=l(B),_t=J(Ae);if(Lt&&_t&&Lt!==_t)continue}let Qe=Ge.flat.text,Ut=Se&&(Qe.startsWith(Se)||Qe.endsWith(Se)),Mt=!1;if(!fe&&we&&et&&we.flat.text!==Se){let Lt=S(et,null,ve).flat.text,_t=f.get(B)<f.get(et)?we.flat.text:Lt,C=f.get(B)<f.get(et)?Lt:we.flat.text;x(ve,_t.length+C.length+Qe.length),Mt=!!_t&&!!C&&_t.length+C.length<=Qe.length&&Qe.startsWith(_t)&&Qe.endsWith(C)&&!Qe.slice(_t.length,Qe.length-C.length).trim()}let Kt=!xe.flat.atoms.length&&!we?.flat.atoms.length&&!Ge.flat.atoms.length&&(re&&Ut||Mt);if(fe&&et){let Lt=S(fe,A,ve).flat.text,_t=Se.startsWith(Lt)||Se.endsWith(Lt),C=S(et,null,ve).flat.text,X=Ge.flat.text,ce=X.startsWith(C)||X.endsWith(C),de=!o[1-H].V.twin(et)&&!Pt.some(ie=>ie.source===et&&jn.test(C.slice(ie.from,ie.to)));if(!Nt&&(!_t&&!Kt||!ce&&!de)){let ie=Za(B,Ae,me,Ye,dt,d,$t,O,x,ve);if(!ie)continue;let ee=A.weak?.has(B)&&!A.identityPaired?.has(B)&&Se.trim()===ie;if(!_t&&!Kt&&!ee)continue;let se=A.weak?.has(et)&&!A.identityPaired?.has(et)&&Qe.trim()===ie&&!d.get(et).flat.atoms.length&&!Pt.some(Ee=>Ee.source===et&&jn.test(C.slice(Ee.from,Ee.to)));if(!ce&&!de&&!se&&!Qa(et,Ae,C,Qe,Pt,O(Ge,ve),x,ve))continue;ee&&Z.add(Ae)}}Kt&&Z.add(Ae),x(ve,me.length),V.push(...me.filter(Lt=>Lt.target===Ae))}if(!V.length)continue;let q=new Uint8Array(Se.length);x(ve,Se.length*4+Pt.length);for(let Ae of V)q.fill(1,Ae.from,Ae.to);let le=[];for(let Ae=0;Ae<Se.length;Ae++)cn.test(Se[Ae])||le.push(Ae);if(!le.length)continue;let Ne=new Set(V.map(Ae=>Ae.target));if(!Nt&&fe&&Ne.size>1&&Xa(Ne,$,Pt,k,d,ve,x)){if(g||=new Map,g.set(B,(g.get(B)||0)|1<<H),e){let Ae=ks({source:B,side:H,views:o,eligible:r,blocked:h,baseId:l,model:S,tokensOf:O,budget:ve,charge:x});if(Ae){x(ve,Ae.to-Ae.from);let Ge=!0;for(let et=Ae.from;et<Ae.to;et++)if(jn.test(Se[et])&&!q[et]){Ge=!1;break}Ge&&(b||=[]).push(Ae)}}continue}let Le=le.filter(Ae=>Ls.test(Se[Ae]));if(!V.some(Ae=>Ls.test(Se.slice(Ae.from,Ae.to)))&&!le.every(Ae=>q[Ae]))continue;if(!fe&&!Array.from(Ne).some(Ae=>Z.has(Ae))&&!le.every(Ae=>q[Ae])&&!(Le.length&&q[Le[0]]&&q[Le[Le.length-1]]&&Ne.size===1)){let Ae=null,Ge=0,et=0,Qe=null,Ut=null;if(!fe&&we&&B.nodeType===1&&!xe.flat.atoms.length){let Mt=O(xe,ve).filter(Kt=>Ls.test(Kt.raw));x(ve,dt.length+Se.length);for(let Kt of dt){let Lt=k.baseOf(Kt);if(!Lt||Lt===B||Lt.nodeType!==1||Kt.nodeType!==1||Lt.tagName!==B.tagName||Kt.tagName!==Lt.tagName)continue;let _t=f.get(B),C=f.get(Lt),X=!0;for(let Fe=Math.min(_t,C)+1;Fe<Math.max(_t,C);Fe++){let tt=n[Fe];if(x(ve,tt.nodeType===1?1:tt.value.length+1),tt.nodeType===1||tt.value.trim()){X=!1;break}}if(!X)continue;let ce=S(Lt,null,ve),de=S(Kt,A,ve);if(ce.flat.atoms.length||de.flat.atoms.length)continue;let ie=ce.flat.text,ee=de.flat.text;if(x(ve,ie.length+ee.length+Se.length),!ie||!Mt.length)continue;let se=0,Ee=ee.length;if(_t<C&&ee.endsWith(ie))Ee-=ie.length;else if(_t>C&&ee.startsWith(ie))se=ie.length;else continue;for(;se<Ee&&cn.test(ee[se]);)se++;for(;Ee>se&&cn.test(ee[Ee-1]);)Ee--;let _e=ee.slice(se,Ee);if(!(!_e||!(_e.startsWith(Mt[0].raw)||_e.endsWith(Mt[Mt.length-1].raw)))){if(Ae){Ae=null;break}Ae=Kt,Ge=se,et=Ee,Qe=Mt[0],Ut=Mt[Mt.length-1]}}}if(x(ve,V.length),!Ae||!Ne.has(Ae)||!V.some(Mt=>Mt.target===Ae&&(Mt.from<=Qe.from&&Mt.to>=Qe.to&&Mt.targetFrom+Qe.from-Mt.from===Ge||Mt.from<=Ut.from&&Mt.to>=Ut.to&&Mt.targetFrom+Ut.to-Mt.from===et)))continue}if(fe&&!(le.every(Ae=>q[Ae])&&(Nt||Array.from(Ne).some(Ae=>Z.has(Ae))))&&!Pt.some(Ae=>Ae.source===B&&jn.test(Se.slice(Ae.from,Ae.to))))continue;let je=!1;if(Nt){x(ve,Pt.length+le.length);for(let Ae of Pt)Ae.source===B&&(x(ve,Ae.to-Ae.from),q.fill(1,Ae.from,Ae.to));je=!0;for(let Ae of le)if(!q[Ae]){je=!1;break}}for(let Ae of Ne){x(ve,V.length);let Ge=V.filter(Qe=>Qe.target===Ae);Ze.push({side:H,source:B,target:Ae,runs:Ge,models:d,retained:Pt,conservedSource:je}),B.nodeType===1&&Je.add(B),Ae.nodeType===1&&Je.add(Ae);let et=k.baseOf(Ae);et?.nodeType===1&&Je.add(et)}}if(w.push(...Ze),He&&Ze.length)for(let B of He)Me.add(B);for(let B of Je)y.add(B)}catch(Ye){if(Ye!==N)throw Ye}finally{if(t&&!He&&!pt){let Ye=wl({base:n,views:o,side:H,attempt:v,eligible:r,blocked:h,baseId:l,model:S,tokensOf:O,charge:x,exhausted:N,limit:a});Ye&&(T||=[]).push(...Ye)}if(e&&!He&&!pt){let Ye=Pi({base:n,views:o,side:H,attempt:v,eligible:r,blocked:h,baseId:l,model:S,tokensOf:O,certificates:w,charge:x,exhausted:N,limit:a});Ye&&(b||=[]).push(...Ye)}}}}let K=w.length?new Map:null;for(let H of w){let k=K.get(H.source);k||K.set(H.source,k=[]),k.push(H)}let W=null;if(K){let H=null;for(let[k,A]of K){let J=g?.get(k)||0;if(A.length<2&&!J)continue;let _=0;for(let F of A)F.conservedSource&&(_|=1<<F.side);for(let F of A){if(F.conservedSource)continue;let Oe=1<<F.side,Ce=!0;if(_&Oe)Ce=!1;else if(J&Oe){Ce=!1;try{Ce=Ja(F,H||=Wt(a),x)}catch(De){if(De!==N)throw De}}Ce||(W||=new Set).add(F)}}}if(W){let H=0;for(let k of w)W.has(k)||(w[H++]=k);w.length=H;for(let[k,A]of K){H=0;for(let J of A)W.has(J)||(A[H++]=J);A.length=H,H||K.delete(k)}y.clear();for(let k of w){let{source:A,target:J,side:_}=k;A.nodeType===1&&y.add(A),J.nodeType===1&&y.add(J);let F=o[_].V.baseOf(J);F?.nodeType===1&&y.add(F)}}if(b){let H=Wt(a),k=!1;for(let A of b){let J=!1,_=K?.get(A.source);if(_&&!k)try{J=xs(A,_,H,x)}catch(F){if(F!==N)throw F;k=!0}J||e(A)}}if(T){let H=new Set,k=Wt(a);try{for(let A of T){if(x(k,1),H.has(A.source))continue;H.add(A.source);let J=!1;for(let _ of w)if(x(k,1),_.source===A.source||_.target===A.local||_.target===A.remote){J=!0;break}J||t(A)}}catch(A){if(A!==N)throw A}}for(let H of n)if(y.has(H))for(let{V:k}of o){let A=k.twin(H);A&&k.here(A)&&y.add(A)}return w.length?{blocks:y,certificates:w,certificatesBySource:K,models:d}:null}function Al({certificates:e,scopes:t,flats:n,keys:o,limit:r=2e4*32}){let i=Symbol(),s=Wt(r),l=g=>{if(g>s.remaining)throw i;s.remaining-=g},c=t.map(g=>new Set(g)),a=new Map,p=new Map,f=(g,h)=>{let y=a.get(g);if(y||a.set(g,y=new Map),y.has(h))return y.get(h);l(g.text.length);let N=p.get(h);if(!N){l(h.nodes.length+h.atoms.length),N={nodes:new Map,atoms:new Map};for(let R of h.nodes)N.nodes.set(R.node,R);for(let R of h.atoms)N.atoms.set(R.el,R.i);p.set(h,N)}let{nodes:x,atoms:S}=N,O=new Int32Array(g.text.length).fill(-1);for(let R of g.nodes){let M=x.get(R.node);if(!(!M||R.e-R.s!==M.e-M.s)){l(R.e-R.s);for(let j=R.s;j<R.e;j++)O[j]=M.s+j-R.s}}for(let R of g.atoms){let M=S.get(R.el);M!==void 0&&(O[R.i]=M)}return y.set(h,O),O},d=(g,h,y,N,x)=>{let S=g[g.length-1];S&&S.to===h&&S.target+S.to-S.from===N&&S.kind===x?S.to=y:g.push({from:h,to:y,target:N,kind:x})},w=(g,h,y,N)=>{l((N-y)*4);let x=[],S=y,O=j=>{let U=g.text.slice(S,j);for(let K of tn(U,hn(U)))K.from=S,K.to=S+K.len,x.push(K),S+=K.len},R=0,M=g.atoms.length;for(;R<M;){l(1);let j=R+M>>>1;g.atoms[j].i<y?R=j+1:M=j}for(let j=R;j<g.atoms.length&&g.atoms[j].i<N;j++){l(1);let U=g.atoms[j];O(U.i),x.push({k:h(U),raw:Ln,len:1,from:S,to:S+1}),S++}return O(N),x},b=(g,h,y,N,x,S)=>{if(y===N||x===S)return;if(N-y===S-x){l((N-y)*4);let k=!0;for(let A=y,J=x;A<N;A++,J++){if(n[0].text[A]!==n[h].text[J]){k=!1;break}let _=n[0].atomAt.get(A),F=n[h].atomAt.get(J);if(!!_!=!!F||_&&o[0](_)!==o[h](F)){k=!1;break}}if(k){d(g,y,N,x,"retained");return}}let O=w(n[0],o[0],y,N),R=w(n[h],o[h],x,S),M=O.length+R.length+4,j=Math.min(O.length+R.length,4e3,Math.floor((Math.sqrt(M*M+s.remaining/2)-M)/2));if(j<1)throw i;l(4*(j+1)*(M+j+1));let U=_n(O,R,j),K=0,W=0,H=()=>{let k=O[K++],A=R[W++];l(k.len),k.raw===A.raw&&d(g,k.from,k.to,A.from,"retained")};for(let k of U.hunks){for(;K<k.bs;)H();K=k.be,W+=k.toks.length}for(;K<O.length&&W<R.length;)H()},T=g=>{let h=e.filter(U=>U.side===g-1&&c[0].has(U.source)&&c[g].has(U.target));if(!h.length)return null;let y=[],N=(U,K,W)=>{if(!c[0].has(U.source)||!c[g].has(U.target))return;let H=f(K.get(U.source).flat,n[0]),k=f(K.get(U.target).flat,n[g]);l(U.to-U.from);for(let A=0;A<U.to-U.from;A++){let J=H[U.from+A],_=k[U.targetFrom+A];if(J<0||_<0)throw i;d(y,J,J+1,_,W)}},x=new Set;for(let U of h){if(!x.has(U.retained)){x.add(U.retained);for(let K of U.retained)N(K,U.models,"retained")}for(let K of U.runs)N(K,U.models,"transfer")}y.sort((U,K)=>(l(1),U.from-K.from||U.target-K.target));let S=[];for(let U of y){l(1);let K=S[S.length-1];if(K&&U.from<K.to){if(U.target-U.from!==K.target-K.from)throw i;K.to=Math.max(K.to,U.to),U.kind==="transfer"&&(K.kind="transfer")}else S.push(U)}let O=[],R=0,M=0;for(let U of S){if(U.target<M)throw i;b(O,g,R,U.from,M,U.target),O.push(U),R=U.to,M=U.target+U.to-U.from}b(O,g,R,n[0].text.length,M,n[g].text.length);let j=Rn({base:n[0],side:n[g],retained:O.filter(U=>U.kind==="retained"),transfers:O.filter(U=>U.kind==="transfer"),baseAtomKey:o[0],sideAtomKey:o[g],budget:s});if(j.status!=="ready"||!j.monotone)throw i;return j};try{let g=T(1),h=T(2);return g||h?{local:g,remote:h}:{fallback:!0}}catch(g){if(g!==i)throw g;return{fallback:!0}}}function Ps(e,t,n=!1){let o=-1,r=-1;for(let s=0;s<e.list.length;s++){let l=e.list[s];l.bLo<t.lo||l.bLo>t.hi||(o<0&&(o=s),r=s)}let i=[];for(let s=o;s>=0&&s<=r;s++){let l=e.list[s],c=!n&&s===o?l.inlineStart<0?l.to:l.inlineStart:l.from,a=!n&&s===r?l.inlineEnd<0?l.from:l.inlineEnd:l.to;for(let p=c;p<a;p++)i.push(e.units[p]);s<r&&i.push(e.units[l.next])}return i}var ot=e=>!!e&&e.nodeType===1,Hr=e=>ot(e)?e.getAttribute("data-id")||e.textContent||"":e.value!==void 0?e.value:e.nodeValue||"",Nn=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function js(e){for(let t of e)if(Nn.has(t.tagName))return!0;return!1}function ef(e,t,n){let o=null;for(let r of t.childNodes)if(!(!ot(r)||!n(r)||!r.isEqualNode(e))){if(o)return null;o=r}if(!o)return null;for(let r of e.parentNode.childNodes)if(r!==e&&r.isEqualNode(e))return null;return o}var er="[id],[data-id],script,head>*";function Bs(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let o=Eo(n,e);if(o)return"merge:"+o.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?sl(n,t):null}}function Vr(e,t,n,o){let r=o.ignored,i=o.stats||Gn(),s=Ei({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:i}),{unitsOf:l,meta:c}=s,a=o.baseURI,p=o.mergeTags!==null,f=Bs(o.mergeTags,a),d=C=>X=>{let ce=f(X);return ce!==null?ce:C(X)},w=d(o.identity.base),b=d(o.identity.local),T=d(o.identity.remote),g=o.authored||o.identity,h=C=>C&&C.nodeType===9?C.documentElement:C,y=h(e),N=h(t),x=h(n),S=globalThis.__hyperMorphProfile,O=S?performance.now():0,R=C=>C===dn?er:null,M=o.scope||null,j=M?M.baseDropped:new Set,U=new Set,K=M?M.remoteDropped:new Set,W=M?M.baseIndex:Or(y,w,r,R(o.identity.base),j),H=o.localIsBase||y===N?null:Or(N,b,r,R(o.identity.local),U),k=M?M.remoteIndex:Or(x,T,r,R(o.identity.remote),K),A=C=>{let X=ot(C)&&b(C);return X&&H?.get(X)===C&&!W.has(X)?X:null},J=C=>{let X=ot(C)&&T(C);return X&&k.get(X)===C&&!W.has(X)?X:null},_=H?us(y,N,{analyzer:s,baseIndex:W,sideIndex:H,baseId:g.base,sideId:g.local,baseKey:w,sideKey:b,baseDropped:j,sideDropped:U,stats:i}):Nl(),F=us(y,x,{analyzer:s,baseIndex:W,sideIndex:k,baseId:g.base,sideId:g.remote,baseKey:w,sideKey:T,baseDropped:j,sideDropped:K,stats:i,scope:M,comparisons:o.comparisons});if(M){if(!M.held(F))return null;for(let C of M.dropped)as(C)}let Oe=null;function Ce(C){if(!Oe){Oe=new WeakMap;let X=[y];for(;X.length;){let ce=X.pop();ce.tagName==="TEMPLATE"&&ce.content&&Oe.set(ce.content,ce);for(let de of s.childrenOf(ce))de.nodeType===1&&X.push(de)}}return Oe.get(C)||null}let De=C=>{let X=ot(C)||C.nodeType?C.parentNode:C.parent;return X&&X.nodeType===11?Ce(X):X};if(F.moved.size){let C=!1;for(let X of Array.from(F.moved))!ot(X)||F.identityPaired.has(X)||!g.base(X)||m(F,De(X))||(F.unpair(X),C=!0);C&&F.rematch()}on(),Y(_,F),Y(F,_);for(let C of[_,F])if(C.refused)for(let X of C.refused)C.moved.has(X)||i.ambiguousMoves++;S&&(S.alignTotal=(S.alignTotal||0)+(performance.now()-O),O=performance.now());let pe=y.ownerDocument.implementation.createHTMLDocument(""),Te=new WeakMap,ze=new WeakMap,Me=[],v=[],G=new Set,ue=[],ae=new Set,Pe=new Set,He=new Set,ve=new WeakMap,Ze=null,Je=o.lineage?.locals.length?zi():null,pt=C=>{let X=Rr(C);return X&&Je&&Je.consume(C.local),X},Ye=o.conflicts||"remote",dt=C=>Me.push(C),St=C=>Me.push(C),vt=hl({roots:{base:y,local:N,remote:x},L:_,R:F,unitsOf:l,provenance:Te,policy:Ye}),bt=(C,X)=>{v.push(C),X&&vt.note(C,X)},At=null,Ot=null,Bt=Jt(),nn=null,Nt=B(y,_.map.get(y),F.map.get(y),!!o.localIsBase,!!o.childrenOnly);Nt.tagName==="HTML"?pe.replaceChild(Nt,pe.documentElement):pe.body.appendChild(Nt),At?.drain(Nt),Ot?.drain(Nt),S&&(S.build=(S.build||0)+(performance.now()-O));let $t=o.childrenOnly?!et(Ae(Nt),Ae(x)):!Ne(Nt,x),an=vt.finish(Nt),Pt=Je?Gi({locals:o.lineage.locals,rec:Je,root:Nt,provenance:Te,segments:ue,ignored:r}):null;return{doc:pe,root:Nt,provenance:Te,textMappers:ze,decisions:Me,conflicts:v,recoveryLinks:an,localDiverged:$t,mergedScripts:G,segments:ue,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==dn,L:_,R:F,stats:i,lineage:Pt};function Jt(){let C=new Map,X=new Set;if(o.localIsBase||!_.insertedByHash)return{partner:C,drop:X};let ce=_.insertedByHash(),de=F.insertedByHash();if(!ce.size||!de.size)return{partner:C,drop:X};let ie={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},ee=$e=>{let mt=0;for(let Tt=$e.parentNode;Tt;Tt=Tt.parentNode)mt++;return mt},se=[],Ee=$e=>{let mt=$e.textContent.trim();return mt.split(/\s+/).length>=3||mt.replace(/\s/g,"").length>=12},_e=$e=>{let mt=m(_,$e),Tt=m(F,$e);return mt&&_.reverse.get(mt.parentNode)!==$e.parentNode||Tt&&F.reverse.get(Tt.parentNode)!==$e.parentNode},Fe=($e,mt,Tt)=>{for(let It of Tt.parentNode.children){let kn=It!==Tt&&$e.reverse.get(It);if(kn&&_e(kn))return!0}let Dt=$e.reverse.get(Tt.parentNode);if(Dt){for(let It of Dt.children)if(!m(mt,It)&&!r(It))return!0}return!1},tt=new Map([[_,new Map],[F,new Map]]),st=($e,mt)=>{let Tt=tt.get($e),Dt=Tt.get(mt);if(Dt===void 0){Dt=!1;for(let It of mt.children)if($e.reverse.has(It)||st($e,It)){Dt=!0;break}Tt.set(mt,Dt)}return Dt},it=new Map;for(let $e of de.values())for(let mt of $e){let Tt=J(mt);Tt&&it.set(Tt,mt)}for(let $e of ce.values())for(let mt of $e){let Tt=A(mt),Dt=Tt?it.get(Tt):null;Dt&&Dt.tagName===mt.tagName&&!Pn(mt,ie)&&!Pn(Dt,ie)&&!o.remoteWins(mt)&&!o.remoteWins(Dt)&&se.push([mt,[Dt],ee(mt),!0,!0])}for(let[$e,mt]of ce){let Tt=de.get($e);if(!Tt)continue;let Dt=mt.length===1&&Tt.length===1;for(let It of mt)!Pn(It,ie)&&!A(It)&&se.push([It,Tt,ee(It),Dt&&(Ee(It)||Fe(_,F,It)||Fe(F,_,Tt[0]))])}if(!se.length)return{partner:C,drop:X};se.sort(($e,mt)=>$e[2]-mt[2]);let rt=new Set,kt=new Set,xt=$e=>{for(let mt of $e.querySelectorAll("*"))rt.add(mt)},Et=($e,mt)=>$e.reverse.get(mt.parentNode)||null;for(let[$e,mt,,Tt,Dt]of se){if(rt.has($e)||kt.has($e)||Dt&&(st(_,$e)||st(F,mt[0])))continue;let It=Et(_,$e),kn=fn=>!kt.has(fn)&&!rt.has(fn)&&(Dt||fn.tagName===$e.tagName&&!J(fn)&&s.equalUnits($e,fn)),Zt=mt.find(fn=>It&&Et(F,fn)===It&&kn(fn))||(Tt?mt.find(kn):null);if(!Zt)continue;kt.add($e),kt.add(Zt);let Fn=It&&Et(F,Zt)===It;(!Dt||!Fn||s.equalUnits($e,Zt))&&(xt($e),xt(Zt)),!Fn&&(C.set($e,Zt),C.set(Zt,$e),X.add(Ye==="local"?Zt:$e))}return{partner:C,drop:X}}function Ft(C,X,ce){if(ae.add(C),Bt.drop.has(C))return null;ae.add(ce);let de=X==="local"?C:ce,ie=X==="local"?ce:C,ee;return s.equalUnits(de,ie)?(ee=q(de,"local",!0),Te.get(ee).remote=ie):ee=re(de,ie),bt({kind:"structure",el:ee,detail:"both-moved",base:null,local:de,remote:ie},{unit:{b:null,l:de,r:ie}}),dt({kind:"insert",el:ee,source:"both"}),ee}function on(){if(!_.weak||!F.weak||!_.weak.size||!F.weak.size||!_.unpair)return;let C=new Map;for(let ce of _.weak){let de=m(_,ce);ot(ce)&&ot(de)&&C.set(s.unitHash(de),ce)}let X=!1;for(let ce of Array.from(F.weak)){let de=m(F,ce);if(!ot(ce)||!ot(de))continue;let ie=C.get(s.unitHash(de));if(!ie||ie===ce||!_.weak.has(ie)||m(_,ce)&&m(F,ie))continue;let ee=m(_,ie);ee.tagName===de.tagName&&s.equalUnits(ee,de)&&(_.unpair(ie),F.unpair(ce),X=!0)}X&&(_.rematch(),F.rematch())}function Y(C,X){if(!C.weak||!C.weak.size||!X.insertedByHash)return;let ce=X.insertedByHash();if(!ce.size)return;let de=!1;for(let ie of Array.from(C.weak)){let ee=m(C,ie);if(!ee)continue;let se=C===_?A(ee):J(ee);if(se){let _e=(C===_?k:H)?.get(se);_e&&_e.tagName===ee.tagName&&!X.reverse.has(_e)&&(C.unpair(ie),de=!0);continue}let Ee=ce.get(s.unitHash(ee));Ee&&Ee.some(_e=>_e.tagName===ee.tagName&&s.equalUnits(_e,ee))&&(C.unpair(ie),de=!0)}de&&C.rematch()}function m(C,X){if(!X)return null;if(C.map.has(X))return C.map.get(X);let ce=[],de=De(X);for(;de&&!C.map.has(de);de=De(de))ce.push(de);let ie=de;if(!ie||!C.identical.has(ie))return null;C.pairIdenticalChildren(ie);for(let se=ce.length-1;se>=0;se--)C.pairIdenticalChildren(ce[se]);let ee=C.map.get(X)||null;return ee&&i.lazyTwins++,ee}function I(C,X,ce,de){if(ot(C)&&Nn.has(C.tagName)&&!_.identical.has(C)&&(C.previousSibling?.nodeType===3||C.nextSibling?.nodeType===3)){let Ee=De(C),_e=m(_,C),Fe=m(F,C);_e&&Fe&&Lt(_e,m(_,Ee),_)&&!Lt(Fe,m(F,Ee),F)&&(Ot||=gl({L:_,R:F,twinIn:m,unitsOf:l,view:P,parentOf:De,ignored:r,remoteWins:o.remoteWins,eligible:tt=>ot(tt)&&Nn.has(tt.tagName),build:B,out:pe,policy:Ye,provenance:Te,textMappers:ze,segments:ue,conflicts:v,conflict:bt,decisions:Me}),Ot.ensureOwner(C))}if(X===null)return null;if(de!==void 0)return At||=Ro(Te,De,_,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(C,X,ce,!!de),de&&(At.produced(C,de),Pe.add(C)),de;if(Pe.has(C)||He.has(C))return bt({kind:"structure",el:null,detail:"both-moved",base:C},{subject:C}),Pe.has(C)?null:q(ce,X);At||=Ro(Te,De,_,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(C,X,ce,!0);let ie=m(_,C),ee=m(F,C);(!ie||!ee)&&bt({kind:"structure",el:null,detail:"move-beats-delete",base:C},{subject:C,deleted:ie?"remote":"local"});let se=B(C,ie,ee,!1);return(X==="local"?dt:St)({kind:"move",el:se,source:X}),se}function P(C,X,ce,de){return de||!X||X===ce?{el:ce,asBase:!0,twin:ie=>ie,baseOf:ie=>ie,units:l(ce),here:()=>!0,parentOfTwin:()=>ce}:{el:X,asBase:!1,twin:ie=>m(C,ie),baseOf:ie=>C.reverse.get(ie),units:l(X),here:ie=>ot(ie)?ie.parentNode===X||X.tagName==="TEMPLATE"&&ie.parentNode===X.content:ie.parent===X||X.tagName==="TEMPLATE"&&ie.parent===X.content}}function $(C,X,ce){return!X||ce&&ce.identical.has(C)?!1:ot(C)?!s.equalUnits(C,X)||!Q(C,X,ce):C.value!==X.value}function Q(C,X,ce){if(!ce||C===X)return!0;let de=[[C,X]];for(;de.length;){let[ie,ee]=de.pop(),se=l(ie),Ee=l(ee);for(let _e=0;_e<se.length&&_e<Ee.length;_e++){let Fe=se[_e],tt=Ee[_e];if(!ot(Fe)||!ot(tt))continue;let st=ce.map.get(Fe);if(st!==void 0&&st!==tt)return!1;let it=ce.reverse.get(tt);if(it!==void 0&&it!==Fe)return!1;de.push([Fe,tt])}}return!0}function B(C,X,ce,de,ie=!1){let ee=de||(ce?o.remoteWins(ce):o.remoteWins(C)),se=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?pe.createElementNS(C.namespaceURI,C.tagName):pe.createElement(C.tagName),Ee={base:C,local:X||null,remote:ce||null};if(Te.set(se,Ee),ee&&!de&&X&&$(C,X,_)&&(!ce||!s.equalUnits(X,ce))&&bt({kind:"structure",el:se,detail:"remote-wins",base:C,local:X,remote:ce||null},{subject:C}),ae.add(C),Pe.add(C),X&&ae.add(X),ce&&ae.add(ce),o.skipUnchanged&&!ie&&(o.localIsBase||_.identical.has(C))&&ce&&F.identical.has(C)&&!o.remoteWins(C)){Ee.unchanged=!0;for(let Fe of C.attributes)Fe.namespaceURI?se.setAttributeNS(Fe.namespaceURI,Fe.name,Fe.value):se.setAttribute(Fe.name,Fe.value);return At?.produced(C,se),se}He.add(C),ie||Se(C,ee?C:X,ce,se);let _e=C.tagName;if(sn(C))fe(C,ee?C:X,ce,se);else if(_e==="TEXTAREA"){let Fe=ee?C:X,tt=C.textContent,st=Fe?Fe.textContent:tt,it=ce?ce.textContent:tt,rt=me(C);if(rt&&st!==tt&&it!==tt){let kt=ke(rt,me(Fe),me(ce),ee);kt&&se.appendChild(kt)}else se.textContent=xe(tt,st,it,se,"text")}else if(!Ot?.render(C,se)){let Fe=le(C,X,ce,ee,se),tt=_e==="TEMPLATE"&&se.content?se.content:se;for(let st of Fe)tt.appendChild(st)}return He.delete(C),At?.produced(C,se),se}function me(C){if(!C)return null;let X=l(C)[0];return X&&!ot(X)&&X.kind==="text"?X:null}function xe(C,X,ce,de,ie){if(X===ce)return X;if(X===C)return ce!==C&&St({kind:ie,node:de,source:"remote"}),ce;if(ce===C)return dt({kind:ie,node:de,source:"local"}),X;let ee=Ye==="local"?X:ce;return bt({kind:ie,node:de,base:C,local:X,remote:ce,resolved:ee},{site:"whole",el:de}),Me.push({kind:ie,node:de,source:"both"}),ee}function fe(C,X,ce,de){let ie=C.textContent,ee=X?X.textContent:ie,se=ce?ce.textContent:ie,Ee=p?Eo(C,o.mergeTags,!0):null;if(Ee&&ee!==se){let _e=ce&&ce.getAttribute("merge-key")||C.getAttribute("merge-key"),{text:Fe,warnings:tt,conflicts:st}=Cs(o.localIsBase?void 0:ie,ee,se,{parse:Ee.recognizer.parse,keyCandidates:_e?_e.split(/[\s,]+/).filter(Boolean):void 0});for(let it of tt)console.warn(`[hyper-morph] merge "${Ee.raw}": ${it}`);for(let it of o.localIsBase?[]:st)bt({kind:"json",node:de,name:Ee.raw,path:it.path,base:it.base,local:it.local,remote:it.remote,resolved:it.resolved});de.textContent=Fe,G.add(de),Fe!==se?dt({kind:"text",node:de,source:Fe===ee?"local":"both"}):Fe!==ie&&St({kind:"text",node:de,source:"remote"});return}de.textContent=xe(ie,ee,se,de,"text")}function Se(C,X,ce,de){let ie=new Map;for(let ee of[C,X,ce])if(ee)for(let se of ee.attributes)o.ignoreAttribute(ee,se.name)||ie.set(se.name,se);for(let[ee,se]of ie){let Ee=C?C.getAttribute(ee):null,_e=X?X.getAttribute(ee):Ee,Fe=ce?ce.getAttribute(ee):Ee,tt;_e===Fe?tt=_e:_e===Ee?(tt=Fe,St({kind:"attr",el:de,name:ee,source:"remote"})):Fe===Ee?(tt=_e,dt({kind:"attr",el:de,name:ee,source:"local"})):(tt=be(ee,Ee,_e,Fe)??V(ee,[C,X,ce],Ee,_e,Fe),tt===void 0&&(tt=Ye==="local"?_e:Fe,bt({kind:"attr",el:de,name:ee,base:Ee,local:_e,remote:Fe,resolved:tt},{el:de,sample:se})),Me.push({kind:"attr",el:de,name:ee,source:"both"})),tt!=null&&(se.namespaceURI?de.setAttributeNS(se.namespaceURI,se.name,tt):de.setAttribute(ee,tt))}}function V(C,X,ce,de,ie){let ee=o.attributeMerge;if(typeof ee!="function")return;let se=X.filter(Boolean).map(Ee=>ee(Ee,C));if(!(!se.length||se.some(Ee=>Ee!==se[0]))){if(se[0]==="tokens")return Z(ce,de,ie);if(se[0]==="max"){let Ee=Number(de),_e=Number(ie);return Number.isFinite(Ee)&&Number.isFinite(_e)&&de!==""&&ie!==""?String(Math.max(Ee,_e)):void 0}}}function Z(C,X,ce){let de=it=>[...new Set((it||"").split(/\s+/).filter(Boolean))],ie=de(C),ee=new Set(ie),se=new Set(de(X)),Ee=new Set(de(ce)),_e=it=>se.has(it)===Ee.has(it)?se.has(it):se.has(it)===ee.has(it)?Ee.has(it):se.has(it),Fe=ie.filter(_e),tt=[...new Set([...se,...Ee])].filter(it=>!ee.has(it)&&_e(it)).sort(),st=[...Fe,...tt];return st.length?st.join(" "):null}function be(C,X,ce,de){if(C==="class"){let ie=Fe=>new Set((Fe||"").split(/\s+/).filter(Boolean)),ee=ie(X),se=ie(ce),Ee=ie(de),_e=new Set;for(let Fe of new Set([...ee,...se,...Ee])){let tt=ee.has(Fe),st=se.has(Fe),it=Ee.has(Fe);(st===it?st:st===tt?it:st)&&_e.add(Fe)}return[..._e].join(" ")}if(C==="style"){let ie=tt=>{let st=new Map;if(!tt)return st;let it=0,rt=null,kt="",xt=()=>{let Et=kt.indexOf(":");Et>0&&st.set(kt.slice(0,Et).trim(),kt.slice(Et+1).trim()),kt=""};for(let Et of tt){if(rt){kt+=Et,Et===rt&&(rt=null);continue}if(Et==='"'||Et==="'"){rt=Et,kt+=Et;continue}if(Et==="("?it++:Et===")"&&it--,Et===";"&&it===0){xt();continue}kt+=Et}return kt.trim()&&xt(),st},ee=ie(X),se=ie(ce),Ee=ie(de),_e=new Map,Fe=!1;for(let tt of new Set([...ee.keys(),...se.keys(),...Ee.keys()])){let st=ee.get(tt)??null,it=se.get(tt)??null,rt=Ee.get(tt)??null,kt;it===rt?kt=it:it===st?kt=rt:rt===st?kt=it:(kt=Ye==="local"?it:rt,Fe=!0),kt!=null&&_e.set(tt,kt)}return Fe?void 0:[..._e].map(([tt,st])=>`${tt}: ${st}`).join("; ")}}function ke(C,X,ce,de){let ie=C.value,ee=de?ie:X?X.value:"",se=ce?ce.value:"";ae.add(C),X&&ae.add(X),ce&&ae.add(ce);let Ee=Go(ie,ee,se,Ye),_e=Ee.text===""?null:pe.createTextNode(Ee.text);_e&&(Te.set(_e,{base:C.nodes,local:X?X.nodes:null,remote:ce?ce.nodes:null}),ze.set(_e,Ee.mapLocalOffset)),ee!==ie&&se!==ie?Me.push({kind:"text",node:_e,source:"both"}):ee!==ie?dt({kind:"text",node:_e,source:"local"}):se!==ie&&St({kind:"text",node:_e,source:"remote"});for(let Fe of Ee.conflicts)bt({kind:"text",node:_e,base:ie.slice(Fe.bs,Fe.be),local:Fe.local,remote:Fe.remote,resolved:Fe.resolved},{site:"run",bRun:C,lRun:X,rRun:ce,node:_e,c:Fe});return _e}function we(C,X){return lo(C,X).every(ce=>ce.bs===ce.be)}function te(C,X){let ce=C?C.value:"",de=X?X.value:"",ie;if(ce===de||!de?ie=ce:ce?we(ce,de)?ie=de:we(de,ce)?ie=ce:(ie=Ye==="local"?ce:Ye==="both"?ce+de:de,bt({kind:"structure",el:null,detail:"insert-collision",local:ce,remote:de,resolved:ie},{unit:{b:null,l:C,r:X},localLost:Ye==="remote"})):ie=de,C&&ae.add(C),X&&ae.add(X),ie==="")return null;let ee=pe.createTextNode(ie);return Te.set(ee,{base:null,local:C?C.nodes:null,remote:X?X.nodes:null}),ce?dt({kind:"insert",el:ee,source:de&&ce===de?"both":"local"}):St({kind:"insert",el:ee,source:"remote"}),ee}function re(C,X){let ce={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},de=Ee=>l(Ee).every(_e=>ot(_e)?Pn(_e,ce):_e.kind==="text"),ie=null;if(de(C)&&de(X)){let Ee=C.textContent,_e=X.textContent;Ee===_e||we(_e,Ee)?ie=X:we(Ee,_e)&&(ie=C)}if(!ie){let Ee=Ye==="local",_e=q(Ee?C:X,Ee?"local":"remote",!0),Fe=Te.get(_e);return Ee?Fe.remote=X:Fe.local=C,bt({kind:"structure",el:_e,detail:"insert-collision",local:C,remote:X,resolved:Ee?C:X},{unit:{b:null,l:C,r:X},localLost:!Ee}),_e}let ee=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?pe.createElementNS(C.namespaceURI,C.tagName):pe.createElement(C.tagName);Se(null,C,X,ee),Te.set(ee,{base:null,local:C,remote:X}),ae.add(C),ae.add(X);let se=pt({base:Array.from(ie.childNodes),local:Array.from(C.childNodes),remote:Array.from(X.childNodes),out:pe,policy:Ye,idOf:{local:b,remote:T},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:Te,textMappers:ze,conflicts:v,conflict:bt,scope:{base:null,local:C,remote:X,units:[],at:0},synthetic:!0,decisions:Me,node:ee});ue.push(...se.segments);for(let Ee of se.nodes)ee.appendChild(Ee);return ee}function q(C,X,ce=!1){if(!ce&&ot(C)){let se=Bt.partner.get(C);if(se)return Ft(C,X,se)}if(!ot(C)){if(C.value==="")return null;let se=C.kind==="comment"?pe.createComment(C.value):pe.createTextNode(C.value);return Te.set(se,{base:null,local:X==="local"?C.nodes:null,remote:X==="remote"?C.nodes:null}),ae.add(C),se}let de=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?pe.createElementNS(C.namespaceURI,C.tagName):pe.createElement(C.tagName);for(let se of C.attributes)se.namespaceURI?de.setAttributeNS(se.namespaceURI,se.name,se.value):de.setAttribute(se.name,se.value);Te.set(de,{base:null,local:X==="local"?C:null,remote:X==="remote"?C:null}),ae.add(C);let ie=C.tagName==="TEMPLATE"&&de.content?de.content:de,ee=X==="local"?_:F;for(let se of l(C)){let Ee=ot(se)?ee.reverse.get(se):null;if(Ee&&I(Ee,null,null),Ee&&Pe.has(Ee)){bt({kind:"structure",el:null,detail:"both-moved",base:Ee},{subject:Ee});continue}if(Ee&&!He.has(Ee)){let Fe=m(_,Ee)||null,tt=m(F,Ee)||null;if(Fe||tt){At||=Ro(Te,De,_,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(Ee,X,se,!0);let st=B(Ee,Fe,tt,!1);X==="local"?dt({kind:"move",el:st,source:"local"}):St({kind:"move",el:st,source:"remote"}),ie.appendChild(st);continue}}let _e=q(se,X);_e&&ie.appendChild(_e)}if(!ce&&Bt.drop.size&&C.tagName==="DIV"&&!ie.firstChild&&!C.attributes.length&&!(X==="local"?b(C):T(C))&&!ee.reverse.has(C)&&!r(C)&&!o.remoteWins(C)){let se=C.firstChild;if(se&&se===C.lastChild&&ot(se)&&(Bt.drop.has(se)||nn?.has(se)))return(nn||=new WeakSet).add(C),null}return de}function le(C,X,ce,de,ie){X&&_.identical.has(C)&&_.pairIdenticalChildren(C),ce&&F.identical.has(C)&&F.pairIdenticalChildren(C);let ee=P(_,X,C,de),se=P(F,ce,C,!1),Ee=l(C),_e=new Set(Ee),Fe=new Map;for(let ne=0;ne<Ee.length;ne++)Fe.set(Ee[ne],ne);let tt=ne=>!ot(ne)&&ne.kind==="text"&&!/[^\t\n\f\r ]/.test(ne.value),st=[],it=new Set,rt=new Map,kt=new Set,xt=Je&&[],Et=Je&&[],$e=new Set,mt=[],Tt=null,Dt=new Map;if(!ee.asBase&&!se.asBase&&!_.identical.has(C)&&!F.identical.has(C))for(let ne of Ee){if(!ot(ne)||!Nn.has(ne.tagName))continue;let Be=ee.twin(ne),Ue=se.twin(ne);Be&&Ue&&(!ee.here(Be)||!se.here(Ue))&&I(ne,null,null)}let It=(ne,Be=!1)=>{let Ue=[];for(let qe of ne.units){if($e.has(qe)||!Be&&tt(qe))continue;let ht=ne.baseOf(qe);ht&&_e.has(ht)&&Ue.push(ht)}return Ue},kn=ne=>It(ne).map(Be=>Fe.get(Be)),Zt=ne=>ne.every((Be,Ue)=>Ue===0||Be>=ne[Ue-1]),Fn=()=>{let ne=!ee.asBase&&!Zt(kn(ee)),Be=!se.asBase&&!Zt(kn(se)),Ue=null;if(ne&&Be){let qe=It(ee),ht=It(se);if(Ue=nf(Ee.filter(We=>!$e.has(We)&&!tt(We)),Fe,qe,ht),Ue){let We=Ds(qe.map(lt=>Fe.get(lt))),Ve=Ds(ht.map(lt=>Fe.get(lt)));for(let lt of We)Ve.has(lt)&&(Ue=null)}}return{lRe:ne,rRe:Be,settled:Ue}},fn=Fn();xr(fn.lRe&&fn.rRe);let{lRe:to,rRe:An,settled:bo}=Fn(),_o=to&&An;_o&&!bo&&bt({kind:"structure",el:ie,detail:"both-reordered",base:C},{subject:C,lKept:It(ee,!0),rKept:It(se,!0)});let Gt=An||!to?{V:se,A:F,side:"remote",other:ee,otherA:_,otherSide:"local"}:{V:ee,A:_,side:"local",other:se,otherA:F,otherSide:"remote"},Hn=null,Wo=null;if(_o){Hn=wo(Gt.V.units),Wo=Gt.V.units,bo&&(Gt.V=of(Gt.V,bo));for(let ne of Ee)tt(ne)&&ae.add(ne);for(let ne of[ee,se])for(let Be of ne.units)tt(Be)&&ae.add(Be)}to?dt({kind:"move",el:null,source:An?"both":"local",base:C}):An&&St({kind:"move",el:null,source:"remote",base:C});let yo=ee.asBase?[]:ee.units.filter(ne=>!ee.baseOf(ne)&&!$e.has(ne)&&!Bt.partner.has(ne)),no=se.asBase?[]:se.units.filter(ne=>!se.baseOf(ne)&&!$e.has(ne)&&!Bt.partner.has(ne)),On=new Map;if(yo.length&&no.length){let ne=new Map,Be=new Map;for(let We of no){if(ot(We)){let lt=T(We);lt&&ne.set(lt,We)}let Ve=s.unitHash(We);Be.has(Ve)||Be.set(Ve,[]),Be.get(Ve).push(We)}let Ue=(We,Ve)=>{let lt=We.units.indexOf(Ve);for(let Ke=lt-1;Ke>=0;Ke--){let ct=We.baseOf(We.units[Ke]);if(ct)return ct}return"start"},qe=new Map,ht=new Map;for(let We of no){let Ve=Ue(se,We);ot(We)?(ht.has(Ve)||ht.set(Ve,[]),ht.get(Ve).push(We)):We.kind==="text"&&!qe.has(Ve)&&qe.set(Ve,We)}for(let We of yo){let Ve=null;if(ot(We)){let Ke=b(We);Ke&&ne.has(Ke)&&!On.has(ne.get(Ke))&&(Ve=ne.get(Ke))}else if(We.kind==="text"){let Ke=qe.get(Ue(ee,We));Ke&&!On.has(Ke)&&(Ve=Ke)}let lt=!!A(We);if(!Ve&&!lt){let Ke=Be.get(s.unitHash(We));Ke&&(Ve=Ke.find(ct=>!On.has(ct)&&ot(ct)===ot(We)&&(ot(ct)?ct.tagName===We.tagName&&!J(ct):ct.kind===We.kind)&&s.equalUnits(We,ct))||null)}if(!Ve&&ot(We)&&!lt){let Ke=g.local(We),ct=(ht.get(Ue(ee,We))||[]).filter(ft=>{let yt=g.remote(ft);return!On.has(ft)&&ft.tagName===We.tagName&&!J(ft)&&!(Ke&&yt&&Ke!==yt)&&s.similar(We,ft)});ct.length===1&&(Ve=ct[0])}Ve&&(On.set(Ve,We),On.set(We,Ve))}}let br=ne=>{if(Ot?.consumes(ne))return null;if(ae.has(ne)||At?.has(ne))return rt.get(ne)||null;let Be=ee.twin(ne),Ue=se.twin(ne),qe=Be&&!ee.asBase&&!ee.here(Be),ht=Ue&&!se.asBase&&!se.here(Ue);if(qe||ht){if((!Be||!Ue)&&bt({kind:"structure",el:null,detail:"move-beats-delete",base:ne},{subject:ne,deleted:Be?"remote":"local"}),!Kt(ne))return ot(ne)?(At||=Ro(Te,De,_,F,m,B,r,o.remoteWins,v,bt,$,N,x),qe&&At.plan(ne,"local",Be),ht&&At.plan(ne,"remote",Ue)):ae.add(ne),null;bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne})}if(Be&&!Ue&&!ee.asBase&&!se.asBase&&ot(ne)&&Nn.has(ne.tagName)&&!o.remoteWins(ne)&&!o.remoteWins(Be)&&$(ne,Be,_)&&ef(ne,Ae(se.el),r)){let ct={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},ft=yt=>ot(yt)?Pn(yt,ct):yt.kind==="text";if(l(ne).every(ft)&&l(Be).every(ft)){let yt=pt({base:[ne],local:[Be],remote:[],blocks:new Set([ne,Be]),out:pe,policy:Ye,L:_,R:F,idOf:{base:w,local:b,remote:T},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Ct,En,Kn)=>B(Ct,En,Kn,!1),cloneUnit:q,mergeAttrs:Se,atomKey:s.exactUnitKey,moveIn:I,moveBuilt:I,movePlanned:I,provenance:Te,textMappers:ze,conflicts:v,conflict:bt,scope:{base:C,local:ee.el,remote:se.el,units:Ee,at:Fe.get(ne)},decisions:Me,node:ie});ue.push(...yt.segments),ae.add(ne),ae.add(Be);let gt=pe.createDocumentFragment();for(let Ct of yt.nodes)gt.appendChild(Ct);return rt.set(ne,gt),rt.set(Be,gt),gt}}if(!Be&&!Ue)return ae.add(ne),St({kind:"remove",source:"both",base:ne}),null;if(!Be&&!$(ne,Ue,F))return ae.add(ne),dt({kind:"remove",source:"local",base:ne}),null;if(!Ue&&!$(ne,Be,_))return ae.add(ne),St({kind:"remove",source:"remote",base:ne}),Je&&(Je.remove(Be),xt.push({bk:ne,lk:Be})),null;let We=!Be||!Ue,Ve=ee.asBase?m(_,ne)||null:Be,lt=se.asBase&&ot(ne)&&(F.identityPaired.has(ne)||!g.base(ne))&&m(F,ne)||Ue,Ke;return ot(ne)?Ke=B(ne,Ve,lt,ee.asBase):ne.kind==="comment"?Ke=Ut(ne,Ve,Ue,ee.asBase):Ke=ke(ne,Ve,Ue,ee.asBase),ae.add(ne),Ke&&(rt.set(ne,Ke),Be&&rt.set(Be,Ke),Ue&&rt.set(Ue,Ke),We&&(bt({kind:"structure",el:Ke,detail:"edit-beats-delete",base:ne},{subject:ne,deleted:Be?"remote":"local"}),Be?dt({kind:"insert",el:Ke,source:"local"}):St({kind:"insert",el:Ke,source:"remote"}))),Ke},yr=(ne,Be,Ue,qe)=>{if(Ot?.consumes(ne))return null;if(ae.has(ne))return rt.get(ne)||null;let ht=Be.baseOf(ne);if(ht&&_e.has(ht))return $e.has(ht)&&!$e.has(ne)?wr(ht,ne,qe):br(ht);if(ht)return Vn(ht,ne,qe);let We=On.get(ne);if(We){let lt=qe==="local"?ne:We,Ke=qe==="local"?We:ne,ct;return ot(lt)?s.equalUnits(lt,Ke)?(ct=q(lt,"local"),ct&&(Te.get(ct).remote=Ke)):ct=re(lt,Ke):ct=te(lt,Ke),ae.add(lt),ae.add(Ke),ct&&(rt.set(lt,ct),rt.set(Ke,ct),ot(lt)&&dt({kind:"insert",el:ct,source:"both"})),ct}let Ve=q(ne,qe);return Ve&&(rt.set(ne,Ve),qe==="local"?dt({kind:"insert",el:Ve,source:"local"}):(St({kind:"insert",el:Ve,source:"remote"}),Je&&ot(ne)&&!Bt.partner.has(ne)&&Et.push({su:ne,node:Ve}))),Ve},wr=(ne,Be,Ue)=>{let qe;return ot(ne)?(qe=I(ne,Ue,Be),qe&&ae.add(Be)):(qe=q(Be,Ue),ae.add(Be),qe&&(Ue==="local"?dt:St)({kind:"insert",el:qe,source:Ue})),qe&&rt.set(Be,qe),qe},Vn=(ne,Be,Ue)=>{I(ne,null,null);let ht=m(Ue==="local"?F:_,ne),We=Be,Ve=ht?Lt(ht,Ue==="local"?ce:X,Ue==="local"?F:_):!1,lt=ht&&!Ve&&!_t(ne,ht);if(lt&&Ue===Gt.otherSide)return bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne}),null;if(lt&&bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne}),ht||bt({kind:"structure",el:null,detail:"move-beats-delete",base:ne},{subject:ne,deleted:Ue==="local"?"remote":"local"}),He.has(ne)){bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne});let ct=q(We,Ue);return ct&&rt.set(Be,ct),ct}ot(ne)&&(At||=Ro(Te,De,_,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(ne,Ue,We,!0));let Ke=ot(ne)?B(ne,Ue==="local"?We:m(_,ne)||null,Ue==="remote"?We:m(F,ne)||null,!1):null;return Ke&&(rt.set(ne,Ke),rt.set(Be,Ke),ht&&rt.set(ht,Ke),Ue==="local"?dt({kind:"move",el:Ke,source:"local"}):St({kind:"move",el:Ke,source:"remote"})),Ke};for(let ne of Gt.V.units){if($e.has(ne)){if(Tt?.has(ne)){for(let qe of Tt.get(ne))it.has(qe)||(st.push(qe),it.add(qe));continue}let Ue=rt.get(ne);it.has(Ue)||(st.push(Ue),it.add(Ue));continue}if(ae.has(ne)&&!(rt.get(ne)&&it.has(rt.get(ne)))){let Ue=Gt.V.baseOf(ne);Ue&&!_e.has(Ue)&&bt({kind:"structure",el:null,detail:"both-moved",base:Ue},{subject:Ue});continue}let Be=yr(ne,Gt.V,Gt.A,Gt.side);Be&&!it.has(Be)&&(st.push(Be),it.add(Be),!Gt.V.baseOf(ne)&&!On.has(ne)&&!$e.has(ne)&&kt.add(Be))}for(let ne of mt)it.has(ne.frag)||(st.splice(ne.previous&&it.has(ne.previous)?st.indexOf(ne.previous)+1:qo(ne.at),0,ne.frag),it.add(ne.frag));if(!Gt.other.asBase){let ne=Gt.other,Be=Gt.otherSide,Ue=Gt.otherA,qe=null,ht=0,We=null;for(let Ve of ne.units){let lt=Dt.get(Ve)||rt.get(Ve);if(lt&&it.has(lt)){qe=lt,We=null;continue}if(ae.has(Ve)){let gt=ne.baseOf(Ve);gt&&!_e.has(gt)&&bt({kind:"structure",el:null,detail:"both-moved",base:gt},{subject:gt});continue}let Ke=yr(Ve,ne,Ue,Be);if(!Ke)continue;let ct=!ne.baseOf(Ve)&&!$e.has(Ve),ft=!qe&&!We,yt=We?st.indexOf(We)+1:qe?st.indexOf(qe)+1:ht;if(ct&&ot(Ke)){let gt=Hr(Ke);for(;yt<st.length&&kt.has(st[yt])&&ot(st[yt])&&Hr(st[yt])<gt;)yt++}else if(qe&&!We&&Be==="remote")for(;yt<st.length&&kt.has(st[yt]);)yt++;st.splice(yt,0,Ke),it.add(Ke),ct&&kt.add(Ke),ft&&(ht=yt+1),We=Ke}}for(let ne=0;ne<Ee.length;ne++){let Be=Ee[ne];if(ae.has(Be))continue;let Ue=br(Be);Ue&&st.splice(qo(ne),0,Ue)}return Je&&xt.length&&Et.length&&qn(),_o?Mn(st):st;function qn(){if(to||An)return;let ne=new Set(st),Be=ft=>ft&&_e.has(ft)&&ne.has(rt.get(ft))?ft:null,Ue=(ft,yt)=>{let gt=[{prev:null,units:[]}];for(let Ct of ft){let En=Be(yt(Ct));En?gt.push({prev:En,units:[]}):gt[gt.length-1].units.push(Ct)}return gt},qe=Ue(Ee,ft=>ft),ht=Ue(se.units,se.baseOf),We=ee.asBase?null:Ue(ee.units,ee.baseOf),Ve=ft=>ft.length===qe.length&&ft.every((yt,gt)=>yt.prev===qe[gt].prev);if(!Ve(ht)||We&&!Ve(We))return;let lt=new Map(xt.map(ft=>[ft.bk,ft])),Ke=new Map(Et.map(ft=>[ft.su,ft])),ct=ft=>ft?st.indexOf(rt.get(ft)):-1;for(let ft=0;ft<qe.length;ft++){if(qe[ft].units.length!==1||ht[ft].units.length!==1)continue;let yt=lt.get(qe[ft].units[0]),gt=Ke.get(ht[ft].units[0]);if(!yt||!gt||We&&(We[ft].units.length!==1||We[ft].units[0]!==yt.lk))continue;let Ct=ct(qe[ft].prev);(ft+1<qe.length?ct(qe[ft+1].prev):st.length)-Ct!==2||st[Ct+1]!==gt.node||$o(yt.bk,yt.lk,gt.su)&&Je.link(yt.lk,gt.node)}}function oo(ne,Be,Ue,qe){let ht=gt=>{let Ct=gt.filter(ot);return Ct.length===1?Ct[0]:null},We=ht(ne),Ve=ht(Be),lt=ht(Ue);if(!We||!Ve||!lt)return;let Ke=ne.indexOf(We);if(Be.indexOf(Ve)!==Ke||Ue.indexOf(lt)!==Ke||ne.length!==Be.length||ne.length!==Ue.length)return;for(let gt=0;gt<ne.length;gt++)if(gt!==Ke&&(ne[gt].value!==Be[gt].value||ne[gt].value!==Ue[gt].value))return;if((ee.asBase?We:ee.twin(We))!==Ve||se.twin(We)||F.reverse.get(lt)||Ve!==We&&$(We,Ve,_))return;let ct=qe.filter(gt=>gt.nodeType===1);if(ct.length!==1||Te.get(ct[0])?.remote!==lt)return;let ft=gt=>gt.map(Ct=>ot(Ct)?"":Ct.value??Ct.nodeValue).join(""),yt=qe.indexOf(ct[0]);ft(qe.slice(0,yt))!==ft(ne.slice(0,Ke))||ft(qe.slice(yt+1))!==ft(ne.slice(Ke+1))||$o(We,Ve,lt)&&Je.link(Ve,ct[0])}function $o(ne,Be,Ue){if(!ot(Be)||!ot(Ue)||!ot(ne)||Be.namespaceURI!==Ue.namespaceURI||Be.localName===Ue.localName)return!1;for(let Ve of[Be,Ue])if(Ve.tagName==="TEMPLATE"||sn(Ve)||Ve.querySelector("template"))return!1;if(o.remoteWins(ne)||o.remoteWins(Ue)||r(Ue)||Be.attributes.length!==Ue.attributes.length)return!1;for(let Ve of Be.attributes)if(Ue.getAttributeNS(Ve.namespaceURI,Ve.localName)!==Ve.value)return!1;let qe=Be.childNodes,ht=Ue.childNodes;if(qe.length!==ht.length)return!1;for(let Ve=0;Ve<qe.length;Ve++)if(!qe[Ve].isEqualNode(ht[Ve]))return!1;let We=[[ne,Ue]];for(;We.length;){let[Ve,lt]=We.pop();if(Ve.children.length!==lt.children.length)return!1;for(let Ke=0;Ke<lt.children.length;Ke++){let ct=F.reverse.get(lt.children[Ke]);if(ct!==void 0&&ct!==Ve.children[Ke])return!1;We.push([Ve.children[Ke],lt.children[Ke]])}}return!0}function wo(ne){let Be=[[]];for(let Ue of ne)tt(Ue)?Be[Be.length-1].push(Ue):Be.push([]);return Be}function Mn(ne){let Be=wo(Ee),Ue=(Ke,ct)=>{let ft=new Map,yt=Ke.filter(gt=>!tt(gt));for(let gt=0;gt<yt.length;gt++)ft.set(yt[gt],ct[gt+1]);return ft},qe=Ue(Ee,Be),ht=Ue(Wo,Hn),We=new Map;for(let[Ke,ct]of rt){if(!ct||We.has(ct))continue;let ft=qe.get(Ke),yt=ht.get(Ke);(ft||yt)&&We.set(ct,[ft,yt])}let Ve=[],lt=Fo(Be[0],Hn[0]);lt&&Ve.push(lt);for(let Ke of ne){Ve.push(Ke);let ct=We.get(Ke),ft=ct?Fo(ct[0],ct[1]):null;ft&&Ve.push(ft)}return Ve}function Fo(ne,Be){let Ue=!!ne&&ne.length>0,qe=Ue?ne:Be||[],ht=qe.map(lt=>lt.value).join("");if(ht==="")return null;let We=pe.createTextNode(ht),Ve=lt=>{let Ke=[];for(let ct of lt||[])ct&&Ke.push(...ct.nodes);return Ke.length?Ke:null};return Te.set(We,Ue?{base:Ve(ne),local:Ve(ne.map(lt=>ee.asBase?null:ee.twin(lt))),remote:Ve(ne.map(lt=>se.asBase?null:se.twin(lt)))}:{base:null,local:Gt.side==="local"?Ve(qe):null,remote:Gt.side==="remote"?Ve(qe):null}),We}function qo(ne){for(let Be=ne-1;Be>=0;Be--){let Ue=rt.get(Ee[Be]);if(Ue){let qe=st.indexOf(Ue);if(qe>=0)return qe+1}}return 0}function xr(ne){if((ee.asBase||_.identical.has(C))&&(se.asBase||F.identical.has(C)))return;let Be={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},Ue=ut=>ot(ut)?Pn(ut,Be):ut.kind==="text";if(!ee.asBase&&!se.asBase)for(let ut of Ee){if(!ot(ut)||!Nn.has(ut.tagName))continue;let u=ee.twin(ut),E=se.twin(ut);if(!u&&E||u&&!E){let L=xl({base:Ee,views:[{V:ee,A:_,idOf:g.local},{V:se,A:F,idOf:g.remote}],eligible:D=>ot(D)&&Nn.has(D.tagName)&&!r(D)&&!o.remoteWins(D),baseId:g.base,ignored:r,remoteWins:o.remoteWins,atomKey:s.exactUnitKey});L&&(ee=L[0],se=L[1]);break}}let qe=!ee.asBase&&!se.asBase&&Ee.length>=2&&Nn.has(Ee[0].tagName)&&ee.units.length===Ee.length&&se.units.length===Ee.length?tl({base:Ee,local:ee.units,remote:se.units,localTwin:ee.twin,remoteTwin:se.twin,eligible:ut=>ot(ut)&&Nn.has(ut.tagName)&&!r(ut)&&!o.remoteWins(ut),nodes:{base:Array.from(Ae(C).childNodes),local:Array.from(Ae(ee.el).childNodes),remote:Array.from(Ae(se.el).childNodes)}}):null,ht=null,We=null;if(!qe&&!ee.asBase&&!se.asBase&&(js(Ee)||js(ee.units)||js(se.units))){let ut={ignored:r,remoteWins:()=>!1},u=L=>Ue(L)||ot(L)&&o.remoteWins(L)&&pn.has(L.tagName)&&Pn(L,ut),E=L=>ot(L)?Nn.has(L.tagName)&&!r(L)&&!o.remoteWins(L)&&l(L).every(u):L.kind==="text";ht=kl({onUncertainOwner:L=>{let D=o.identity.local(L.local);D&&D===o.identity.remote(L.remote)||(We||=[]).push(L)},onUncertainSource:L=>{Ze||(Ze=new Map);let D=Ze.get(L.source);D||Ze.set(L.source,D=[]);for(let z of D)if(z.side===L.side&&z.from===L.from&&z.to===L.to)return;D.push(L)},base:Ee,views:[{V:ee,A:_,idOf:g.local},{V:se,A:F,idOf:g.remote}],eligible:E,ignored:r,remoteWins:o.remoteWins,baseId:g.base,atomKey:s.exactUnitKey})}if(We){Tt||=new Map;for(let ut of We){let{source:u,local:E,remote:L}=ut,D={map:new Map,reverse:new Map,identical:new Set},z=pt({base:[u],local:[E],remote:[L],out:pe,policy:"both",L:D,R:D,ignored:r,remoteWins:o.remoteWins,atomKey:s.exactUnitKey,cloneUnit:q,provenance:Te,textMappers:ze,conflicts:v,decisions:Me,conflict:(oe,ge)=>bt(oe,{...ge,policy:"both"}),scope:{base:C,local:ee.el,remote:se.el,units:Ee,at:Fe.get(u)},node:ie});ue.push(...z.segments);for(let oe of[u,E,L])ae.add(oe),$e.add(oe),Tt.set(oe,z.nodes),rt.set(oe,z.nodes[z.nodes.length-1]);for(let oe=0;oe<z.nodes.length;oe++)mt.push({frag:z.nodes[oe],at:Fe.get(u),previous:oe?z.nodes[oe-1]:null})}}let Ve=qe?qe.blocks:null;if(ht){Ve=new Set;for(let ut of ht.blocks)Ve.add(ut)}let lt=ut=>!Ot?.consumes(ut)&&(Ve&&Ve.has(ut)||Ue(ut)),Ke=Ee.map(lt);if(!Ke.includes(!0))return;let ct=ut=>{let u=ut.units,E=new Map;for(let ye=0;ye<u.length;ye++)E.set(u[ye],ye);let L=[],D=-1;for(let ye=0;ye<Ee.length;ye++){if(Ke[ye])continue;let Re=ut.twin(Ee[ye]),he=Re?E.get(Re):void 0;he===void 0||he<=D||lt(Re)||(L.push([ye,he]),D=he)}let z=[],oe=-1,ge=-1;for(let ye=0;ye<=L.length;ye++){let[Re,he]=ye<L.length?L[ye]:[Ee.length,u.length],Ie={bLo:-1,bHi:-1,from:ge+1,to:he,inlineStart:-1,inlineEnd:-1,next:he};for(let Xe=oe+1;Xe<Re;Xe++)Ke[Xe]&&(Ie.bLo<0&&(Ie.bLo=Xe),Ie.bHi=Xe);for(let Xe=ge+1;Xe<he;Xe++){let nt=u[Xe];lt(nt)&&(Ie.inlineStart<0&&(Ie.inlineStart=Xe),Ie.inlineEnd=Xe+1)}z.push(Ie),oe=Re,ge=he}return{units:u,list:z}},ft=ct(ee),yt=ct(se),gt=[];for(let ut of[ft,yt])for(let u of ut.list)u.bLo>=0&&gt.push([u.bLo,u.bHi]);gt.sort((ut,u)=>ut[0]-u[0]);let Ct=[];for(let[ut,u]of gt){let E=Ct[Ct.length-1];E&&ut<=E.hi?E.hi=Math.max(E.hi,u):Ct.push({lo:ut,hi:u})}let En=(ut,u)=>ut.length===u.length&&ut.every((E,L)=>s.equalUnits(E,u[L])),Kn=ut=>!ot(ut)&&ut.kind==="comment",xo=ut=>{if(!ut.length)return[];let u=(oe,ge)=>ot(oe)?oe:oe.nodes[ge?oe.nodes.length-1:0],E=u(ut[0]),L=u(ut[ut.length-1],!0),D=oe=>oe&&ot(oe)&&r(oe);for(;D(E.previousSibling);)E=E.previousSibling;for(;D(L.nextSibling);)L=L.nextSibling;let z=[];for(let oe=E;oe&&(z.push(oe),oe!==L);oe=oe.nextSibling);return z},Gr=ut=>ut.some(u=>ot(u)&&r(u));for(let ut of Ct){let u=Ee.slice(ut.lo,ut.hi+1);if(ne&&!u.some(Re=>lt(Re)&&!tt(Re)))continue;let E=null;if(ht)for(let Re of u){let he=ht.certificatesBySource.get(Re);he&&(E||=[]).push(...he)}let L=ee.asBase?null:Ps(ft,ut),D=se.asBase?null:Ps(yt,ut);if(E){let Re=[new Set(L||u),new Set(D||u)],he=E.some(Ie=>!Re[Ie.side].has(Ie.target));for(let Ie of u)if(Ve.has(Ie))for(let[Xe,nt]of[[0,ee],[1,se]]){let at=nt.twin(Ie);at&&nt.here(at)&&!Re[Xe].has(at)&&(he=!0)}if(he)continue}if(u.some(Kn)||L&&L.some(Kn)||D&&D.some(Kn))continue;let z=xo(L||u),oe=xo(D||u);if((!L||En(u,L))&&(!D||En(u,D))&&!(L&&Gr(z)))continue;let ge=pt({base:xo(u),sourceRetentions:Ze?.get(C),local:z,remote:oe,out:pe,policy:Ye,blocks:Ve,scopeUnits:E?[u,L||u,D||u]:null,certifiedOrigins:E?(Re,he,Ie,Xe,nt,at)=>Al({certificates:E,scopes:[u,L||u,D||u],flats:[Re,he,Ie],keys:[Xe,nt,at]}):null,prepared:qe?qe.prepared:null,nativeTransfers:qe,L:L?_:Tl(_,C),R:D?F:Tl(F,C),idOf:{base:w,local:b,remote:T},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Re,he,Ie)=>B(Re,he,Ie,!1),cloneUnit:q,mergeAttrs:Se,atomKey:s.exactUnitKey,moveIn:I,moveBuilt:I,movePlanned:I,provenance:Te,textMappers:ze,conflicts:v,conflict:bt,scope:{base:C,local:ee.asBase?null:ee.el,remote:se.asBase?null:se.el,units:Ee,at:ut.lo},decisions:Me,node:ie});if(!ge){if(E){let Re=nl({certificates:E,scopes:[u,L||u,D||u],views:[{V:ee,A:_,idOf:g.local},{V:se,A:F,idOf:g.remote}],eligible:he=>ot(he)&&Nn.has(he.tagName)&&!r(he)&&!o.remoteWins(he),baseId:g.base});for(let he of Re.records){Ze||=new Map;let Ie=Ze.get(he.source);Ie||Ze.set(he.source,Ie=[]),Ie.push(he)}}continue}if(ue.push(...ge.segments),qe){let Re=new Map;for(let he of ge.nodes){let Ie=Te.get(he)?.base;if(!Ie||Re.has(Ie))throw new Error("Invalid native transfer owner output");Re.set(Ie,he)}if(Re.size!==qe.owners.length)throw new Error("Incomplete native transfer owner output");for(let he of qe.owners){let Ie=Re.get(he.base);if(!Ie)throw new Error("Missing native transfer owner output");for(let Xe of[he.base,he.local,he.remote])ae.add(Xe),$e.add(Xe),rt.set(Xe,Ie);mt.push({frag:Ie,at:Fe.get(he.base)})}continue}if(Je&&oo(u,L||u,D||u,ge.nodes),ge.unitOutputs){Tt||=new Map;for(let he of[...u,...L||[],...D||[]]){let Ie=ge.unitOutputs.get(he)||[];ae.add(he),$e.add(he),Tt.set(he,Ie),Ie.length&&rt.set(he,Ie[Ie.length-1])}let Re=ge.nodes[ge.nodes.length-1];if(Re)for(let he of[L||u,D||u]){let Ie=he[he.length-1];Ie&&Dt.set(Ie,Re)}for(let he=0;he<ge.nodes.length;he++)mt.push({frag:ge.nodes[he],at:ut.lo,previous:he>0?ge.nodes[he-1]:null});continue}Je&&oo(u,L||u,D||u,ge.nodes);let ye=pe.createDocumentFragment();for(let Re of ge.nodes)ye.appendChild(Re);for(let Re of[...u,...L||[],...D||[]])ae.add(Re),$e.add(Re),rt.set(Re,ye);mt.push({frag:ye,at:ut.lo})}}}function Ne(C,X){let ce=Te.get(C);return ce&&ce.unchanged?!ce.remote||ce.remote===X?!0:Le(ce.remote,X):C.tagName!==X.tagName||!Ge(C,X)?!1:et(Ae(C),Ae(X))}function Le(C,X){return C===X?!0:C.tagName!==X.tagName||C.namespaceURI!==X.namespaceURI||!Ge(C,X)?!1:je(Ae(C),Ae(X))}function je(C,X){let ce=Qe(C,r),de=Qe(X,r);if(ce.length!==de.length)return!1;for(let ie=0;ie<ce.length;ie++){let ee=ce[ie],se=de[ie];if(typeof ee=="string"||typeof se=="string"){if(ee!==se)return!1}else{if(ee.nodeType!==se.nodeType)return!1;if(ee.nodeType===1){if(!Le(ee,se))return!1}else if(ee.nodeValue!==se.nodeValue)return!1}}return!0}function Ae(C){return C.tagName==="TEMPLATE"&&C.content?C.content:C}function Ge(C,X){let ce=0;for(let de of C.attributes)if(!o.ignoreAttribute(C,de.name)&&(ce++,X.getAttribute(de.name)!==de.value))return!1;for(let de of X.attributes)o.ignoreAttribute(X,de.name)||ce--;return ce===0}function et(C,X){let ce=Qe(C,ie=>{let ee=Te.get(ie);return!!(ee&&ee.pinned)}),de=Qe(X,r);if(ce.length!==de.length)return!1;for(let ie=0;ie<ce.length;ie++){let ee=ce[ie],se=de[ie];if(typeof ee=="string"||typeof se=="string"){if(ee!==se)return!1}else{if(ee.nodeType!==se.nodeType)return!1;if(ee.nodeType===1){if(!Ne(ee,se))return!1}else if(ee.nodeValue!==se.nodeValue)return!1}}return!0}function Qe(C,X){let ce=[],de=null;for(let ie=C.firstChild;ie;ie=ie.nextSibling){if(ie.nodeType===3){de=de===null?ie.nodeValue:de+ie.nodeValue;continue}ie.nodeType===1&&X(ie)||(de!==null&&(de!==""&&ce.push(de),de=null),ce.push(ie))}return de!==null&&de!==""&&ce.push(de),ce}function Ut(C,X,ce,de){let ie=C.value,ee=de?ie:X?X.value:"",se=ce?ce.value:"";ae.add(C),X&&ae.add(X),ce&&ae.add(ce);let Ee=ee===se?ee:ee===ie?se:se===ie||Ye==="local"?ee:se,_e={site:"comment",bRun:C,lRun:X,rRun:ce,node:null};if(ee!==ie&&se!==ie&&ee!==se&&bt({kind:"text",node:null,base:ie,local:ee,remote:se,resolved:Ee},_e),!X&&!ce)return null;let Fe=pe.createComment(Ee);return _e.node=Fe,Te.set(Fe,{base:C.nodes,local:X?X.nodes:null,remote:ce?ce.nodes:null}),Fe}function Mt(C,X){let ce=m(X,C);if(!ce)return null;let de=ot(ce)?ce.parentNode:ce.parent,ie=ot(C)?C.parentNode:C.parent;return m(X,ie)===de?null:X.reverse.get(de)||null}function Kt(C){let X=new Set([C]),ce=C;for(let de=0;de<64;de++){let ie=Mt(ce,_)||Mt(ce,F);if(!ie)return!1;if(ie===C||ot(C)&&ot(ie)&&C.contains(ie)||X.has(ie))return!0;X.add(ie),ce=ie}return!0}function Lt(C,X,ce){if(!X)return!1;let de=ot(C)?C.parentNode:C.parent;return de===X||X.tagName==="TEMPLATE"&&de===X.content}function _t(C,X){let ce=De(C),de=m(_,ce);if(de&&Lt(X,de,_))return!0;let ie=m(F,ce);return!!(ie&&Lt(X,ie,F))}}function Tl(e,t){return e.map.get(t)?Nl():{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 Nl(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function tf(e){let t=[],n=[],o=new Array(e.length).fill(-1);for(let i=0;i<e.length;i++){let s=0,l=t.length;for(;s<l;){let c=s+l>>1;t[c]<e[i]?s=c+1:l=c}t[s]=e[i],n[s]=i,o[i]=s>0?n[s-1]:-1}let r=new Set;for(let i=n[t.length-1];i!==void 0&&i>=0;i=o[i])r.add(i);return r}function Sl(e){let t=[],n=new Array(e.length);for(let o=0;o<e.length;o++){let r=0,i=t.length;for(;r<i;){let s=r+i>>1;t[s]<e[o]?r=s+1:i=s}t[r]=e[o],n[o]=r+1}return n}function Ds(e){let t=Sl(e),n=Sl(e.map(s=>-s).reverse()).reverse(),o=0;for(let s=0;s<t.length;s++)t[s]>o&&(o=t[s]);let r=new Map;for(let s=0;s<e.length;s++)t[s]+n[s]-1===o&&r.set(t[s],(r.get(t[s])||0)+1);let i=new Set;for(let s=0;s<e.length;s++)(!(t[s]+n[s]-1===o)||r.get(t[s])>1)&&i.add(e[s]);return i}function nf(e,t,n,o){let r=g=>{let h=tf(g.map(y=>t.get(y)));return new Set(g.filter((y,N)=>!h.has(N)))},i=r(n),s=r(o);for(let g of i)if(s.has(g))return null;let l=new Set(n),c=new Set(o),a=e.filter(g=>l.has(g)&&c.has(g)&&!i.has(g)&&!s.has(g)),p=new Set(a),f=(g,h)=>{let y=new Map,N=null;for(let x of g){if(p.has(x)){N=x;continue}h.has(x)&&(y.has(N)||y.set(N,[]),y.get(N).push(x))}return y},d=(g,h)=>Ds(g.map(y=>t.get(y))).size>h.size,w=[{at:f(o,s),ambiguous:d(o,s)},{at:f(n,i),ambiguous:d(n,i)}],b=g=>w.map(h=>{let y=h.at.get(g);return y?{group:y,ambiguous:h.ambiguous}:null}).filter(Boolean).sort((h,y)=>h.ambiguous-y.ambiguous||t.get(h.group[0])-t.get(y.group[0])).flatMap(h=>h.group),T=b(null);for(let g of a)T.push(g,...b(g));return new Map(T.map((g,h)=>[g,h]))}function of(e,t){let n=[],o=new Map,r=null;for(let l of e.units){let c=e.baseOf(l);if(c&&t.has(c)){r=l,o.set(l,[]);continue}(r?o.get(r):n).push(l)}let i=[...o.keys()].sort((l,c)=>t.get(e.baseOf(l))-t.get(e.baseOf(c))),s=l=>{let c=[],a=[],p=()=>{a.length&&c.push(...a.sort((f,d)=>Hr(f)<Hr(d)?-1:1)),a=[]};for(let f of l){if(e.baseOf(f)){p(),c.push(f);continue}a.push(f)}return p(),c};return{...e,units:[...s(n),...i.flatMap(l=>[l,...s(o.get(l))])]}}var vl=new Set(["INPUT","OPTION","TEXTAREA"]),Us=/[\t\n\f\r ]+/;function Ol(e,t,n,o){let r=e.ownerDocument,{provenance:i,textMappers:s}=n,l=o.hooks,c=[],a=[],p=[],f=new Set,d=[],w=[],b=new Map,T=new Set,g=new Map,h=n.conflicts.length>0||o.trackInserted===!0,y=new Map,N=new Set,x=new Map,S=(m,I)=>{let P=x.get(m);P||x.set(m,P=new Set),P.add(I)},O=h?new Set:null,R=(m,I,P)=>{let $=l.beforeAttributeUpdated(m,I,P);return h&&$===!1&&S(I,m),$},M=m=>!!m&&(m===e||e.contains(m)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(m)),j=new Map,U=new Map,K=new Map,W=new Set,H=new Map;(function m(I){let P=i.get(I);if(P){if(I.nodeType===1){let Q=P.local?o.toLive(P.local):null;Q&&M(Q)&&Q.nodeType===1&&(j.set(I,Q),U.set(Q,I))}else if(Array.isArray(P.local)){let Q=F(P.local,P.local.map(B=>o.toLive(B)).filter(B=>B&&M(B)&&B.nodeType===I.nodeType));if(Q.length&&(j.set(I,Q[0]),U.set(Q[0],I),K.set(I,Q)),Array.isArray(P.caret))for(let B of P.caret){let me=o.toLive(B.node);if(!me||!M(me)||me.nodeType!==3)continue;let xe=H.get(me);Array.isArray(xe)||H.set(me,xe=[]),xe.push({merged:I,from:B.from,to:B.to,flatStart:B.flatStart})}else{let B=0;for(let me of Q)H.set(me,{merged:I,shift:B}),B+=me.nodeValue.length}}}let $=I.nodeType===1&&I.tagName==="TEMPLATE"&&I.content?I.content.childNodes:I.childNodes;for(let Q of $)m(Q)})(t);let k=new Set;for(let m of j.values())k.add(m);for(let m of K.values())for(let I of m)k.add(I);let A=o.localRoot&&o.localRoot!==e?new Set:null;if(A){for(let m=o.localRoot.firstElementChild;m;m=m.nextElementSibling)if(m.tagName==="HEAD")for(let I=m.firstElementChild;I;I=I.nextElementSibling){let P=o.toLive(I);P&&A.add(P)}}for(let m of n.segments||[])Oe(m);let J=o.restoreFocus===!1?null:rf(r,H);o.childrenOnly?Te(Ce(e),Ce(t)):De(e,t);for(let{node:m,parent:I}of d)f.has(m)||!m.parentNode||m.nodeType===1&&(o.ignored(m)||ze(m))||Ze(m,I);return sf(r,J,H,s,K,g,W),{applied:c,moved:a,replaced:p,identities:w,mergedScriptsLive:T,liveOf:j,heldBy:g,runOf:K,keptRuns:W,insertedLive:y,vetoed:N,vetoedAttrs:x,removedVetoes:O};function _(m,I){let P=m.slice(I.bs,I.be),$=0;for(;$<P.length&&$<I.text.length&&P[$]===I.text[$];)$++;let Q=0;for(;Q<P.length-$&&Q<I.text.length-$&&P[P.length-1-Q]===I.text[I.text.length-1-Q];)Q++;return{bs:I.bs+$,be:I.be-Q,text:I.text.slice($,I.text.length-Q)}}function F(m,I){if(!I.length)return I;let P=[];for(let B of m){let me=B.parentNode;if(!me)continue;let xe=b.get(me);if(!xe){xe=new Set;for(let fe=me.firstChild;fe;fe=fe.nextSibling)fe.nodeType===3&&xe.add(o.toLive(fe));b.set(me,xe)}P.includes(xe)||P.push(xe)}let $={has:B=>P.some(me=>me.has(B))},Q=[];for(let B of I){Q.push(B);for(let me=B.nextSibling;me&&me.nodeType===3&&!$.has(me)&&!Q.includes(me);me=me.nextSibling)Q.push(me)}return Q}function Oe(m){let I=[];for(let te of m.localNodes){let re=o.toLive(te.node);if(!re||!M(re)||re.nodeType!==3)return;I.push(re)}let P=F(m.localNodes.map(te=>te.node),I);if(!P.length)return;let $=P.map(te=>te.nodeValue).join(""),{flatLocal:Q,lToM:B,mapLocal:me}=m;if($===Q)return;let xe=m.textNodes.map(te=>({node:te.node,ms:te.ms,me:te.me})),fe=[],Se=0;for(let te of P)fe.push(Se),Se+=te.nodeValue.length;let V=(te,re)=>P.find((q,le)=>fe[le]<=te&&te+re<=fe[le]+q.nodeValue.length)||null,Z=[],be=0;for(let te of lo(Q,$).map(re=>_(Q,re))){let re=te.bs+be;be+=te.text.length-(te.be-te.bs);let q,le;if(te.be>te.bs){q=B[te.bs];let Ne=q>=0;for(let Le=te.bs;Ne&&Le<te.be;Le++)B[Le]!==q+(Le-te.bs)&&(Ne=!1);if(!Ne)continue;le=q+(te.be-te.bs)}else{let Ne=te.bs>0?B[te.bs-1]:0,Le=te.bs<Q.length?B[te.bs]:0;if(Ne<0||Le<0)continue;q=le=me(te.bs)}Z.push({ms:q,me:le,text:te.text,live:le===q?V(re,te.text.length):null})}Z.sort((te,re)=>re.ms-te.ms);let ke=(te,re)=>(K.get(te.node)||[j.get(te.node)]).includes(re),we=te=>!!te&&te.nodeType===1&&pn.has(te.tagName);for(let te of Z){let re=xe.find(le=>le.ms<=te.ms&&te.me<=le.me&&te.ms<le.me);if(re&&te.live&&re.ms===te.ms&&!ke(re,te.live)){let le=xe.find(Ne=>Ne.me===te.ms&&ke(Ne,te.live));le&&(re=le)}if(!re&&te.me===te.ms){let le=xe.find(Ae=>Ae.me===te.ms),Ne=xe.find(Ae=>Ae.ms===te.ms),Le=le||Ne;if(!Le)continue;let je=Le.node;for(;we(je.parentNode)&&(le?je.parentNode.lastChild:je.parentNode.firstChild)===je;)je=je.parentNode;if(je===Le.node)re=Le;else{let Ae=je.ownerDocument.createTextNode(te.text);je.parentNode.insertBefore(Ae,le?je.nextSibling:je);continue}}if(!re)continue;let q=re.node.nodeValue;re.node.nodeValue=q.slice(0,te.ms-re.ms)+te.text+q.slice(te.me-re.ms),re.me+=te.text.length-(te.me-te.ms)}}function Ce(m){return m.nodeType===1&&m.tagName==="TEMPLATE"&&m.content?m.content:m}function De(m,I){f.add(m);let P=i.get(I);if(P&&P.remote&&n.remoteIdOf){let Q=n.remoteIdOf(P.remote);Q&&w.push([m,Q])}if(P&&P.unchanged){o.opaque&&o.opaque(m)||(n.customIdentity&&P.remote&&ue(m,P.remote),P.remote&&G(m,P.remote));return}if(l.beforeNodeMorphed(m,I)===!1){N.add(I);return}vt(m,I,o.keepLiveOnly&&P&&P.local&&P.local.nodeType===1&&P.local!==m?P.local:null);let $=m.tagName;if(sn(m))m.textContent!==I.textContent&&(c.push({kind:"text",node:m,before:m.textContent,after:I.textContent}),m.textContent=I.textContent),n.mergedScripts.has(I)&&T.add(m);else if($==="TEXTAREA")Y(m,I,P);else{Ft(m,I,P);let Q=$==="TEMPLATE"&&m.content?m.content:m,B=$==="TEMPLATE"&&I.content?I.content:I;o.opaque&&o.opaque(m)||o.protectFocusedValue==="subtree"&&At(m)&&m!==r.body?pe(Q):Te(Q,B)}l.afterNodeMorphed(m,I)}function pe(m){for(let I=m.firstChild;I;I=I.nextSibling){let P=U.get(I);P&&j.get(P.parentNode)!==m||(f.add(I),I.nodeType===1&&pe(I))}}function Te(m,I){let P=He(m.firstChild),$=new Set;for(let Q of Array.from(I.childNodes)){let B=j.get(Q);B&&f.has(B)&&!$.has(B)&&(B=null);let me=i.get(Q);if(me&&me.pinned){B&&B.nodeType===1&&((B.parentNode!==m||He(B.nextSibling)!==P)&&ve(m,B,P),f.add(B),$.add(B));continue}if(B&&B.nodeType===1){if(B!==P){let Se=B.parentNode;if(Se===m&&P&&Ot(B)){let V=B.nextSibling;for(let Z=P;Z&&Z!==B;){let be=Z.nextSibling;ve(m,Z,V),Z=be}}else ve(m,B,P),Se!==m&&(a.push(B),c.push({kind:"move",el:B,from:Se,to:m}))}$.add(B),De(B,Q),P=He(B.nextSibling);continue}if(B&&B.nodeType!==1){let Se=K.get(Q)||[B],V=Se.map(be=>be.nodeValue).join(""),Z=Q.nodeValue;if(Q.nodeType===3){let be=Me(Q);be!=null&&V!==be&&(Z=Go(be,V,Q.nodeValue).text)}if(Se.length>1&&V===Z&&!Se.includes(P,1)&&Se.every((be,ke)=>be.parentNode===m&&(ke===0||Se[ke-1].nextSibling===be))){if(B!==P)for(let be of Se)ve(m,be,P);l.beforeNodeMorphed(B,Q)!==!1?l.afterNodeMorphed(B,Q):h&&N.add(Q);for(let be of Se)f.add(be),$.add(be);g.set(Q,B),W.add(Q),P=He(Se[Se.length-1].nextSibling);continue}B!==P&&ve(m,B,P),l.beforeNodeMorphed(B,Q)!==!1?(B.nodeValue!==Z&&(c.push({kind:"text",node:B,before:B.nodeValue,after:Z}),B.nodeValue=Z),l.afterNodeMorphed(B,Q)):N.add(Q),f.add(B),$.add(B),g.set(Q,B),P=He(B.nextSibling);continue}if(Q.nodeType===3&&P&&P.nodeType===3&&!f.has(P)&&!H.has(P)){P.nodeValue!==Q.nodeValue&&(c.push({kind:"text",node:P,before:P.nodeValue,after:Q.nodeValue}),P.nodeValue=Q.nodeValue),f.add(P),g.set(Q,P),P=He(P.nextSibling);continue}let xe=i.get(Q),fe=Je(xe&&xe.unchanged&&xe.remote?xe.remote:Q);if(l.beforeNodeAdded(fe)===!1){N.add(Q);continue}m.insertBefore(fe,P),f.add(fe),h&&y.set(Q,fe),fe.nodeType===3&&g.set(Q,fe),fe.nodeType===1&&(p.push(fe),Pe(fe,Q),n.customIdentity&&xe&&xe.unchanged&&xe.remote&&ue(fe,xe.remote),sn(fe)||pt(fe,Q),o.formState==="property"&&Jt(xe)&&G(fe,xe.remote)),P=He(fe.nextSibling),c.push({kind:"insert",node:fe,parent:m}),l.afterNodeAdded(fe)}for(let Q of Array.from(m.childNodes))f.has(Q)||$.has(Q)||Q.nodeType===1&&(o.ignored(Q)||ze(Q))||(k.has(Q)?d.push({node:Q,parent:m}):Ze(Q,m))}function ze(m){return m.parentNode&&m.parentNode.nodeType===1&&m.parentNode.tagName==="HEAD"&&(A&&!A.has(m)||o.preserve&&o.preserve(m)===!0)}function Me(m){let I=i.get(m);return!I||!Array.isArray(I.local)?null:I.local.map(P=>P.nodeValue).join("")}function v(m){return i.get(m)}function G(m,I){if(!vl.has(m.tagName)&&!m.querySelector("input,option,textarea"))return;let P=($,Q)=>{if($.tagName!==Q.tagName||($.tagName==="TEXTAREA"?Y($,Q,{remote:Q}):vl.has($.tagName)&&Ft($,Q,{remote:Q}),o.opaque&&o.opaque($)))return;let B=ae($),me=ae(Q);if(B.length===me.length)for(let xe=0;xe<B.length;xe++)P(B[xe],me[xe])};P(m,I)}function ue(m,I){if(o.opaque&&o.opaque(m))return;let P=ae(m),$=ae(I);if(P.length===$.length)for(let Q=0;Q<P.length;Q++){let B=n.remoteIdOf($[Q]);B&&w.push([P[Q],B]),ue(P[Q],$[Q])}}function ae(m){let I=m.tagName==="TEMPLATE"&&m.content?m.content:m;return Array.from(I.children).filter(P=>!o.ignored(P))}function Pe(m,I){if(!n.remoteIdOf)return;let P=($,Q)=>{let B=i.get(Q);if(B&&B.remote&&Q.nodeType===1){let fe=n.remoteIdOf(B.remote);fe&&w.push([$,fe])}let me=$.childNodes,xe=Q.childNodes;for(let fe=0;fe<me.length&&fe<xe.length;fe++)P(me[fe],xe[fe])};P(m,I)}function He(m){for(;m&&m.nodeType===1&&o.ignored(m);)m=m.nextSibling;return m}function ve(m,I,P){if(typeof m.moveBefore=="function"&&I.ownerDocument===m.ownerDocument)try{m.moveBefore(I,P);return}catch{}m.insertBefore(I,P)}function Ze(m,I){if(l.beforeNodeRemoved(m)===!1){h&&O.add(m);return}m.parentNode.removeChild(m),c.push({kind:"remove",node:m,parent:I}),l.afterNodeRemoved(m)}function Je(m){if(sn(m))return Jo(m,r);let I=r.importNode(m,!0);if(I.nodeType===1)for(let P of Array.from(I.querySelectorAll("script")))sn(P)&&P.replaceWith(Jo(P,r));return I}function pt(m,I){let P=m.tagName==="TEMPLATE"&&m.content?m.content:m,$=I.tagName==="TEMPLATE"&&I.content?I.content:I,Q=Array.from(P.childNodes),B=Array.from($.childNodes);for(let me=0;me<B.length&&me<Q.length;me++){let xe=B[me],fe=Q[me],Se=j.get(xe);Se&&f.has(Se)&&(Se=null);let V=i.get(xe);if(V&&V.pinned){if(Se&&Se.nodeType===1){let Z=Se.parentNode;ve(P,Se,fe),Z!==P&&(a.push(Se),c.push({kind:"move",el:Se,from:Z,to:P})),f.add(Se)}fe.remove();continue}if(Se){let Z=Se.parentNode;ve(P,Se,fe),fe.remove(),Se.nodeType===1?(Z!==P&&(a.push(Se),c.push({kind:"move",el:Se,from:Z,to:P})),De(Se,xe)):(f.add(Se),g.set(xe,Se),Se.nodeValue!==xe.nodeValue&&(c.push({kind:"text",node:Se,before:Se.nodeValue,after:xe.nodeValue}),Se.nodeValue=xe.nodeValue));continue}f.add(fe),h&&y.set(xe,fe),fe.nodeType===3&&g.set(xe,fe),V&&V.unchanged&&V.remote?(Ye(fe,V.remote),n.customIdentity&&ue(fe,V.remote)):xe.nodeType===1&&!sn(xe)&&pt(fe,xe)}}function Ye(m,I){let P=m.tagName==="TEMPLATE"&&m.content?m.content:m,$=I.tagName==="TEMPLATE"&&I.content?I.content:I;for(let Q of Array.from($.childNodes))P.appendChild(Je(Q))}function dt(m,I){return I.namespaceURI?m.getAttributeNS(I.namespaceURI,I.localName):m.getAttribute(I.name)}function St(m,I){let P=new Set((I||"").split(Us).filter(Boolean));return(m||"").split(Us).filter($=>$&&!P.has($))}function vt(m,I,P){for(let $ of Array.from(I.attributes)){if(bt(m,$.name)||o.ignoreAttribute(m,$.name,I))continue;let Q=dt(m,$);if(Q===$.value||P&&dt(P,$)===$.value)continue;let B=$.value;if(P&&$.name==="class"&&!$.namespaceURI){let me=$.value.split(Us).filter(Boolean),xe=St(Q,P.getAttribute("class")).filter(fe=>!me.includes(fe));xe.length&&(B=[...me,...xe].join(" "))}if(Q!==B){if(l.beforeAttributeUpdated($.name,m,"update")===!1){h&&S(I,$.name);continue}$.namespaceURI?m.setAttributeNS($.namespaceURI,$.name,B):m.setAttribute($.name,B),c.push({kind:"attr",el:m,name:$.name,before:Q,after:B})}}for(let $ of Array.from(m.attributes)){if(bt(m,$.name)||o.ignoreAttribute(m,$.name,I)||($.namespaceURI?I.hasAttributeNS($.namespaceURI,$.localName):I.hasAttribute($.name)))continue;if(P&&$.name==="class"&&!$.namespaceURI){let me=St($.value,P.getAttribute("class"));if(me.length){let xe=me.join(" ");if(xe===$.value)continue;if(l.beforeAttributeUpdated("class",m,"update")===!1){h&&S(I,"class");continue}m.setAttribute("class",xe),c.push({kind:"attr",el:m,name:"class",before:$.value,after:xe});continue}}if(P&&dt(P,$)===null&&!o.ignoreAttribute(P,$.name))continue;if(l.beforeAttributeUpdated($.name,m,"remove")===!1){h&&S(I,$.name);continue}let B=$.value;$.namespaceURI?m.removeAttributeNS($.namespaceURI,$.localName):m.removeAttribute($.name),c.push({kind:"attr",el:m,name:$.name,before:B,after:null})}}function bt(m,I){let P=m.tagName;return P==="INPUT"?I==="value"||I==="checked"||I==="disabled":P==="OPTION"?I==="selected":!1}function At(m){return m===r.activeElement}function Ot(m){let I=r.activeElement;return!!I&&I!==r.body&&m.contains(I)}function Bt(m,I){let P=I&&I.local&&I.local.nodeType===1&&I.local!==m?I.local:null;if(!P)return!0;let $=m.tagName==="TEXTAREA"?P.textContent:P.getAttribute("value")??"";return m.value!==$}function nn(m,I){return!!o.protectFocusedValue&&At(m)&&Bt(m,I)}function Nt(m,I,P){let $=Math.min(m.length,I.length),Q=0;for(;Q<$&&m[Q]===I[Q];)Q++;if(P<=Q)return P;let B=0;for(;B<$-Q&&m[m.length-1-B]===I[I.length-1-B];)B++;return P>=m.length-B?P+I.length-m.length:I.length-B}function $t(m){try{return m.selectionStart==null?null:[m.selectionStart,m.selectionEnd,m.selectionDirection]}catch{return null}}function an(m,I,P,$){try{m.setSelectionRange(Nt(I,P,$[0]),Nt(I,P,$[1]),$[2]||"none")}catch{}}function Pt(m,I){let P=m.value,$=$t(m);m.value=I,$&&an(m,P,I,$)}function Jt(m){let I=m&&m.remote;return I&&I.nodeType===1?I:null}function Ft(m,I,P){let $=m.tagName,Q=Jt(P),B=o.formState==="property"&&Q?Q:I;if($==="INPUT"){let me=nn(m,P),xe=(m.getAttribute("type")||"").toLowerCase(),fe=xe!=="file"&&xe!=="checkbox"&&xe!=="radio",Se=Q&&Q.hasAttribute("value")&&Q.value!==Q.getAttribute("value")?Q.value:null;if(fe&&!me)if(o.formState==="property"){let V=I.getAttribute("value"),Z=m.getAttribute("value");(Z!==V||m.value!==B.value)&&R("value",m,V==null?"remove":"update")!==!1&&(Z!==V&&(V==null?m.removeAttribute("value"):m.setAttribute("value",V),c.push({kind:"attr",el:m,name:"value",before:Z,after:V})),m.value!==B.value&&(At(m)?Pt(m,B.value):m.value=B.value))}else if(I.hasAttribute("value")||Se!=null){let V=Se??I.getAttribute("value");m.getAttribute("value")!==V&&R("value",m,"update")!==!1?(m.setAttribute("value",V),m.value!==V&&(At(m)?Pt(m,V):m.value=V),c.push({kind:"attr",el:m,name:"value",before:null,after:V})):m.value!==V&&m.getAttribute("value")===V&&(At(m)?Pt(m,V):m.value=V)}else(m.hasAttribute("value")||m.value!=="")&&R("value",m,"remove")!==!1&&(m.removeAttribute("value"),m.value="",c.push({kind:"attr",el:m,name:"value",before:"",after:null}));if(!fe&&xe!=="file"){let V=I.getAttribute("value");V==null?m.hasAttribute("value")&&R("value",m,"remove")!==!1&&m.removeAttribute("value"):m.getAttribute("value")!==V&&R("value",m,"update")!==!1&&m.setAttribute("value",V)}o.protectFocusedValue&&At(m)||(on(m,B,"checked"),o.formState==="property"&&m.indeterminate!==B.indeterminate&&(m.indeterminate=B.indeterminate)),on(m,B,"disabled")}else if($==="OPTION"){let me=m.parentNode&&m.closest("select");o.protectFocusedValue&&me&&At(me)||on(m,B,"selected")}}function on(m,I,P){if(o.ignoreAttribute(m,P,I))return;let $=o.formState==="property"?!!I[P]:I.hasAttribute(P);if(o.formState!=="property"){let Q=m.hasAttribute(P);if(Q!==$){if(R(P,m,$?"update":"remove")===!1)return;$?m.setAttribute(P,""):m.removeAttribute(P),c.push({kind:"attr",el:m,name:P,before:Q?"":null,after:$?"":null})}}m[P]!==$&&(m[P]=$)}function Y(m,I,P){if(nn(m,P)||R("value",m,"update")===!1)return;let $=Jt(P),Q=I.textContent,B=$&&$.value!==$.defaultValue?$.value:Q,me=At(m)?$t(m):null,xe=m.value;if(o.formState!=="property"&&m.textContent!==Q){c.push({kind:"text",node:m,before:m.textContent,after:Q});let fe=m.firstChild;fe&&fe.nodeType===3&&!fe.nextSibling?fe.data=Q:m.textContent=Q}m.value!==B&&(m.value=B),me&&m.value!==xe&&an(m,xe,m.value,me)}}function rf(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 sf(e,t,n,o,r,i,s){if(!t)return;let l=t.el;if(!l.isConnected&&t.id&&(l=e.getElementById(t.id)),!l||!l.isConnected)return;if(e.activeElement!==l)try{l.focus({preventScroll:!0})}catch{}try{l.scrollTop=t.scrollTop,l.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{l.setSelectionRange&&!l.selectionEnd&&t.selection[1]!=null&&l.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let c=(f,d)=>{let w=n.get(f);if(Array.isArray(w)){let b=w.find(y=>d>=y.from&&d<y.to)||w.find(y=>d===y.to)||w[w.length-1],T=i.get(b.merged);if(!T||!T.isConnected)return null;let g=o.get(b.merged),h=g&&g.flat?g.flat(b.flatStart+d):d;return[T,Math.max(0,Math.min(h,T.nodeValue.length))]}if(w&&!s.has(w.merged)){let b=(r.get(w.merged)||[f])[0];if(!b.isConnected)return null;let T=o.get(w.merged),g=w.shift+d,h=T?T(g):g;return[b,Math.max(0,Math.min(h,b.nodeValue.length))]}return f.isConnected?[f,Math.min(d,f.nodeType===3?f.nodeValue.length:f.childNodes.length)]:null},a=c(t.range.sc,t.range.so),p=c(t.range.ec,t.range.eo);if(!(!a||!p))try{let f=e.createRange();f.setStart(a[0],a[1]),f.setEnd(p[0],p[1]);let d=e.getSelection();d.removeAllRanges(),d.addRange(f)}catch{}}var lf={compared:0},cf=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function af(e,t,n,o){let r=(s,l)=>t.getAttribute(l)!==null&&typeof o=="function"&&!!o(s,l),i=0;for(let s of e.attributes)if(!(n(e,s.name)||r(e,s.name))&&(i++,t.getAttribute(s.name)!==s.value))return!1;for(let s of t.attributes)!n(t,s.name)&&!r(t,s.name)&&i--;return i===0}function Hs(e,t){if(e.namespaceURI!==t.namespaceURI||e.prefix!==t.prefix||e.localName!==t.localName)return!1;let n=e.attributes;if(n.length!==t.attributes.length)return!1;for(let o of n)if(t.getAttributeNS(o.namespaceURI,o.localName)!==o.value)return!1;return!0}function Ml(e,t,n,o,r,i,s,l){let c=new Map,a=new Set,p=f=>{if(o(f))return;let d=n(f);d&&(i.add(d),r.has(d)||c.has(d)?a.add(d):c.set(d,f))};for(let f of e)p(f);p(t);for(let f of s||t.querySelectorAll("*"))p(f);for(let f of a)c.delete(f),l.add(f);return c}function El(e,t,n,o,r,i){let s=!1;for(let p of r)p.startsWith("merge:")&&(s=!0);if(!s)return[...o];let l=new Map,c=[],a=i===dn?er:"*";for(let p of[e,...e.querySelectorAll(a)]){if(n(p))continue;let f=t(p);if(!f||!(o.has(f)||r.has(f)))continue;let d=(l.get(f)||0)+1;l.set(f,d),d===2&&c.push(f)}return c}function Il({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:o,o:r,identity:i,baseURI:s}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!af(e,t,r.ignoreAttribute,r.attributeMerge))return{bail:"root-attrs"};let{ignored:l,remoteWins:c}=r,a=Bs(r.scripts.merge===!1?null:r.scripts.mergeTags,s),p=Me=>{let v=a(Me);return v!==null?v:i.base(Me)||null},f=Me=>{let v=a(Me);return v!==null?v:i.remote(Me)||null},d=[],w=[],b=new Map,T=new Map,g={same:b,differ:T},h=Me=>({bail:Me,comparisons:g}),y=(Me,v,G=!0)=>{if(b.get(Me)===v)return!0;if(T.get(Me)===v)return!1;if(lf.compared++,G&&Me.isEqualNode(v))return b.set(Me,v),!0;let ue=Me.nodeType===v.nodeType;if(ue&&Me.nodeType===1){if(ue=Hs(Me,v),ue){let ae=Me.firstChild,Pe=v.firstChild;for(;ae&&Pe;ae=ae.nextSibling,Pe=Pe.nextSibling)if(!y(ae,Pe,!1)){ue=!1;break}(ae||Pe)&&(ue=!1)}}else ue&&(ue=Me.isEqualNode(v));return(ue?b:T).set(Me,v),ue},N=e,x=t,S=!1,O=()=>{b.set(N,x);for(let Me=0;Me<d.length;Me++)b.set(d[Me],w[Me]);return h("equal")};for(;;){let Me=N.childNodes,v=x.childNodes;if(Me.length!==v.length)break;let G=Je=>y(Me[Je],v[Je])?(b.set(Me[Je],v[Je]),!1):!0,ue=-1,ae=-1;for(let Je=0;Je<Me.length;Je++){if(Me[Je].nodeType!==1)continue;let pt=0;for(let Ye=Me[Je].firstElementChild;Ye;Ye=Ye.nextElementSibling)pt++;pt>=ae&&(ae=pt,ue=Je)}let Pe=[],He=!1;for(let Je=0;Je<Me.length&&Pe.length<2;Je++)Je!==ue&&G(Je)&&Pe.push(Je);if(ue>=0&&Pe.length<2&&(Pe.length===0&&Hs(N,x)?(Pe.push(ue),He=!0):G(ue)&&Pe.push(ue)),Pe.length!==1){if(!S&&Pe.length===0&&Hs(N,x))return O();break}let ve=Me[Pe[0]],Ze=v[Pe[0]];if(S=S||!He,S&&T.set(ve,Ze),ve.nodeType!==1||Ze.nodeType!==1||ve.tagName!==Ze.tagName)break;if(p(ve)!==f(Ze)){if(!S&&y(ve,Ze))return O();break}d.push(N),w.push(x),N=ve,x=Ze}T.set(N,x);for(let Me=0;Me<d.length;Me++)T.set(d[Me],w[Me]);if(N===e||N.tagName==="HEAD"||N.tagName==="BODY")return h("root-level");if(d.length<2||d[1].tagName!=="BODY")return h("not-in-body");if(l(N)||l(x))return h("ignored-ancestor");if(c(N)||c(x))return h("remote-wins-ancestor");for(let Me of d)if(cf.has(Me.tagName))return h("form-ancestor");if(N.tagName==="SCRIPT"||N.getElementsByTagName("script").length||x.getElementsByTagName("script").length)return h("script-or-template");let R=o(N);if(!R||R.nodeType!==1||R.tagName!==N.tagName)return h("no-live-twin");if(!n.contains(R))return h("live-detached");for(let Me of d){let v=o(Me);if(!v||v.nodeType!==1)return h("ancestor-live")}let M=i.base===dn&&i.remote===dn&&l===is,j=new Set,U=new Set,K=[],W=null,H=Me=>{Me&&(j.has(Me)?U.add(Me):j.add(Me))},k=(Me,v)=>{let G=a(Me),ue=G!==null?G:i.base(Me)||null;return ue!==(G!==null?G:i.remote(v)||null)?!1:(H(ue),!0)},A=(Me,v)=>{for(let G=Me.firstElementChild,ue=v.firstElementChild;G;G=G.nextElementSibling,ue=ue.nextElementSibling){let ae=l(G);if(ae!==l(ue))return!1;if(!ae&&(!k(G,ue)||!A(G,ue)))return!1}return!0},J=Me=>{let v=Me+1<d.length?d[Me+1]:N;for(let G=d[Me].firstElementChild,ue=w[Me].firstElementChild;G;G=G.nextElementSibling,ue=ue.nextElementSibling){if(G===v){let He=Me+1<d.length?J(Me+1):null;if(He)return He;continue}let ae=l(G);if(ae!==l(ue))return"outside-id-changed";if(ae)continue;let Pe=o(G);if(!Pe||Pe.nodeType!==1)return"sibling-live";if(K.push([G,ue]),!M&&(!k(G,ue)||!A(G,ue)))return"outside-id-changed";Me===0&&G.tagName==="HEAD"&&p(G)&&(W=[G,ue])}return null},_=J(0);if(_)return h(_);let F=new Set(d),Oe=null;if(i.base===dn){Oe=[];for(let Me of e.querySelectorAll(er))Me===N||F.has(Me)||(N.contains(Me)?Oe.push(Me):M&&H(p(Me)))}let Ce=new Set,De=new Set,pe=new Set,Te=Ml(d,N,p,l,j,Ce,Oe,De),ze=Ml(w,x,f,l,j,Ce,i.remote===dn&&x.querySelectorAll(er),pe);return W&&(U.has(p(W[0]))||Ce.has(p(W[0])))&&(W=null),{scope:{chain:d,root:N,onChain:F,baseIndex:Te,remoteIndex:ze,baseDropped:De,remoteDropped:pe,head:W,same:b,differ:T,dropped:[...El(e,p,l,U,De,i.base),...El(t,f,l,U,pe,i.remote)],held:Me=>{for(let v=1;v<d.length;v++)if(Me.map.get(d[v])!==w[v])return!1;for(let[v,G]of K)if(Me.map.get(v)!==G)return!1;return!0}}}}var ch=Symbol("hyper-morph-duplicate-key");var ff='[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"]',uf='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',df='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function hf(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 pf(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=mf(e,t,o)),!!r)return n?Array.from(r.childNodes):r}function mf(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 c of i){let a=Eo(c,n);a&&!r.has(a.key)&&r.set(a.key,c.textContent)}if(!r.size)return null;let s=e.cloneNode(!0),l=!1;for(let c of[s,...s.querySelectorAll("script")]){let a=Eo(c,n);a&&r.has(a.key)&&(c.textContent=r.get(a.key),l=!0)}return l?s:null}function Cl(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 Vs(e,t,n={}){let o=n||{};if(!o.head?.block)return Rl(e,t,o);try{return Rl(e,t,o)}catch(r){return Promise.reject(r)}}function Rl(e,t,n){let o=n.policy||"sync",r=o==="raw"?void 0:(c,a)=>hf(c)||(o==="history"?!(a&&c.matches(df))&&c.matches(uf):c.matches(ff)),i=n.callbacks||{},s={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"&&(s.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return tr(Object.assign({},s,{live:e,base:n.scripts?.mergeBase||null,remote:Cl(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let c=Object.assign({},s,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:Cl(t,e.ownerDocument)});return tr(c)}n.morphStyle==="innerHTML"&&(s.children=!0);let l=pf(e,n.scripts?.mergeBase,!!s.children,s.scripts.mergeTags);return l!==void 0&&(s.base=l),_s(e,t,s)}var gf=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","attributeMerge","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),xn=()=>{};function nr(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!gf.has(l))throw new TypeError(`unknown option "${l}"`);let n=Object.assign({beforeNodeAdded:xn,afterNodeAdded:xn,beforeNodeRemoved:xn,afterNodeRemoved:xn,beforeNodeMorphed:xn,afterNodeMorphed:xn,beforeAttributeUpdated:xn},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");if(e.attributeMerge!==void 0&&typeof e.attributeMerge!="function")throw new TypeError("attributeMerge must be a function");let s=e.lineage;if(s!==void 0&&(!s||typeof s!="object"||typeof s.onResult!="function"||!s.elements||typeof s.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:ls(e.ignore,t),remoteWins:ls(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,attributeMerge:typeof e.attributeMerge=="function"?e.attributeMerge:()=>null,opaque:typeof e.opaque=="function"?e.opaque:()=>!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,lineage:s||null}}function Lo(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return dn}function Po(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=cs(t,e.map),o=typeof e.then=="function"?e.then:dn;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 dn}function bf(e,t,n,o={}){let r=w=>w&&w.nodeType===9?w.documentElement:w,i=r(t),s=r(n),l=r(e)||i;if(o.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let c=Object.assign({},o);delete c.live,delete c.base,delete c.remote;let a=nr(c,[l,i,s].filter(Boolean)),p=o.identity||{},f=Gn(),d=Vr(l,i,s,{identity:{base:Po(p.base,l),local:Po(p.local,i),remote:Po(p.remote,s)},authored:{base:Lo(p.base),local:Lo(p.local),remote:Lo(p.remote)},skipUnchanged:a.hooks.beforeNodeMorphed===xn&&a.hooks.afterNodeMorphed===xn,ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,attributeMerge:a.attributeMerge,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:i.ownerDocument&&i.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:a.children,stats:f});return delete d.recoveryLinks,delete d.lineage,d}function Ws({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:o,toLive:r,options:i,identity:s,childrenOnly:l,isDocument:c}){let a=nr(i,[e,t,n,o].filter(Boolean));if(a.ignored(e)){let k=$s(),A=a.lineage?Xo(a.lineage,e,k):null;return{report:k,loads:[],lineage:A}}let p=e.ownerDocument,f=a.lineage?vs(a.lineage,{liveRoot:e,localRoot:n,toLive:r}):null,d=a.scripts.execute?ol(e,a.ignored,p.baseURI):null,w=Gn(),b=a.hooks.beforeNodeMorphed===xn&&a.hooks.afterNodeMorphed===xn,T={identity:{base:Po(s.base,t||n),local:Po(s.local,n),remote:Po(s.remote,o)},authored:{base:Lo(s.base),local:Lo(s.local),remote:Lo(s.remote)},ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,attributeMerge:a.attributeMerge,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:p.baseURI,localIsBase:!t,childrenOnly:l,skipUnchanged:b,lineage:f?{locals:f.locals}:null},g=a.fastPath&&c&&!l&&b&&t===n,h=null,y=null;if(g){let k=Il({baseRoot:t,remoteRoot:o,liveRoot:e,toLive:r,o:a,identity:T.identity,baseURI:p.baseURI});T.comparisons=k.comparisons||k.scope,k.bail?y=k.bail:(h=Vr(t,n,o,Object.assign({},T,{stats:w,scope:k.scope})),h||(y="chain-unpaired",w=Gn()))}h||(h=Vr(t||n,n,o,Object.assign({},T,{stats:w}))),g&&(w.fastPathAttempted=1,w.fastPathTaken=y?0:1,w.fastPathFallback=y),h.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(k=>a.hooks[k]!==xn)&&ul(h.conflicts,h.recoveryLinks,r),a.beforeApply&&a.beforeApply(h.doc);let N=globalThis.__hyperMorphProfile,x=N?performance.now():0,S=Ol(e,h.root,h,{toLive:r,localRoot:n,ignored:a.ignored,ignoreAttribute:a.ignoreAttribute,opaque:a.opaque,formState:a.formState,protectFocusedValue:a.protectFocusedValue,restoreFocus:a.restoreFocus,preserve:a.head.preserve,hooks:a.hooks,childrenOnly:l,keepLiveOnly:a.keepLiveOnly,trackInserted:!!f});N&&(N.apply=(N.apply||0)+(performance.now()-x));let O=[];if(a.head.awaitLoads)for(let k of S.applied){if(k.kind!=="insert"||k.node.nodeType!==1)continue;let A=k.node;A.tagName==="LINK"&&/\bstylesheet\b/i.test(A.getAttribute("rel")||"")&&A.getAttribute("href")&&A.closest("head")&&O.push(new Promise(_=>{A.addEventListener("load",()=>_()),A.addEventListener("error",()=>_())}))}let R=null,M=null;if(d){let k=rl(e,d,{ignored:a.ignored,skip:S.mergedScriptsLive,baseURI:p.baseURI,beforeNodeAdded:a.hooks.beforeNodeAdded,afterNodeAdded:a.hooks.afterNodeAdded,trackRecovery:!!h.recoveryLinks});O.push(...k.loads),R=k.swapped,M=k.vetoed}let j=k=>R&&R.get(k)||k,U=k=>{if(S.keptRuns.has(k))return S.runOf.get(k);let A=S.liveOf.get(k)||S.heldBy.get(k)||S.insertedLive.get(k);return A?j(A):null},K=k=>{let A=k&&S.liveOf.get(k);return A?j(A):null},W=k=>{let A=k&&U(k);return Array.isArray(A)?A[0]:A};if(h.recoveryLinks){let k=(A,J,_)=>(J.namespaceURI?A.getAttributeNS(J.namespaceURI,J.localName):A.getAttribute(J.qualifiedName))===_;pl(h.conflicts,h.recoveryLinks,{lookup:U,vetoed:S.vetoed,vetoedAttrs:S.vetoedAttrs,removedVetoes:S.removedVetoes,vetoedLive:M,liveAttr:k,ignored:a.ignored,liveRoot:e})}let H={applied:S.applied,decisions:h.decisions.map(k=>Object.assign({},k,{node:k.node?K(k.node):null,el:k.el?K(k.el):null,applied:!!(k.node?K(k.node):k.el&&K(k.el))})),conflicts:h.conflicts.map(k=>Object.assign({},k,{node:k.node?k.kind==="text"&&k.recovery.subject.nodeType===8?W(k.node):K(k.node):k.node,el:k.el?k.kind==="structure"?W(k.el):K(k.el):k.el})),localDiverged:h.localDiverged,identities:S.identities,moved:S.moved,replaced:S.replaced,stats:w};return f&&(H.lineage=f.finish(h.lineage,U)),{report:H,loads:O,lineage:f}}var Ll=new WeakMap;function $s(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Gn()}}function tr(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");return t.lineage===void 0?Pl(t):Ns(t,t.live.documentElement,o=>Pl(o))}function Pl(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let o=Ll.get(n);o||(o=ss(n),Ll.set(n,o));let r=o("remote",t.remote),i=typeof t.base=="string"&&t.base===""?null:t.base,s=i?o("base",i):null,l=t.local?t.local.root:n.documentElement,c=t.local?t.local.toLive:d=>d;Si(n,r);let{report:a,loads:p,lineage:f}=Ws({liveRoot:n.documentElement,baseRoot:s?s.documentElement:null,localRoot:l,remoteRoot:r.documentElement,toLive:c,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return f?.deliver(a),Promise.all(p).then(()=>a)}function yf(e,t,n={}){return tr(Object.assign({},n,{live:e,base:null,remote:t}))}function jl(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=vr(e,t),s=o[1].toLowerCase()==="html"?i.documentElement:i.body;return{root:s,first:s}}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 _s(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return n.lineage===void 0?Dl(e,t,n):Ns(n,e,o=>Dl(e,t,o))}function Dl(e,t,n={}){let o=e.ownerDocument,{base:r,...i}=n,s=!!i.children,l=nr(i,[e]);if(l.ignored(e)){let T=$s();return l.lineage&&Xo(l.lineage,e,T).deliver(T),Promise.resolve(T)}let c=jl(t,o),a=r!=null?jl(r,o):null,p,f=null;if(s)p=c.root,f=a?a.root:null;else{if(p=c.first,f=a?a.first:null,!p){let T=nr(i),g=T.lineage?Xo(T.lineage,e,{}):null;T.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),T.hooks.afterNodeRemoved(e));let h={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Gn()};return g&&(h.lineage=g.result,g.deliver(h)),Promise.resolve(h)}if(p.tagName!==e.tagName){let T=nr(i,[e,p]);if(T.hooks.beforeNodeMorphed(e,p)===!1){let y=$s();return T.lineage&&Xo(T.lineage,e,y).deliver(y),Promise.resolve(y)}let g=Ws({liveRoot:e,baseRoot:f&&f.tagName===e.tagName?f:null,localRoot:e,remoteRoot:p,toLive:y=>y,options:i,identity:i.identity||{},childrenOnly:!0,isDocument:!1}),h=sn(p)?Jo(p,o):o.importNode(p,!1);if(!sn(h))for(;e.firstChild;)h.appendChild(e.firstChild);return T.hooks.beforeNodeAdded(h)===!1?(Ur(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):T.hooks.beforeNodeRemoved(e)===!1?(Ur(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(h),Ur(g.report.conflicts,e,h),T.hooks.afterNodeRemoved(e),T.hooks.afterNodeAdded(h),T.hooks.afterNodeMorphed(e,p),g.report.replaced.push(h),g.report.applied.push({kind:"insert",node:h,parent:h.parentNode},{kind:"remove",node:e,parent:h.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,h),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:d,loads:w,lineage:b}=Ws({liveRoot:e,baseRoot:f,localRoot:e,remoteRoot:p,toLive:T=>T,options:i,identity:i.identity||{},childrenOnly:s,isDocument:!1});return b?.deliver(d),Promise.all(w).then(()=>d)}var Bl={mergeDocument:tr,morphDocument:yf,morphElement:_s,merge3:bf,morph:Vs};function Fs(e,t,{onWidgetRemoved:n}={}){Bl.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=Sr.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var xf="hha:upgrade-check:";function Dn(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function qs(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Ul(e,t){let n=qs(e),o=qs(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let s=n[i]||0,l=o[i]||0;if(s!==l)return s>l}return!1}function kf(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Af(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Ks({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||(d=>fetch(d)),r=r??Date.now(),!t)return null;let s=Dn(t,"hyper-source");if(!s)return null;let l=Dn(t,"hyper-version"),c;try{c=new URL(s,n?n.href:void 0)}catch{return null}if(n&&c.origin===n.origin&&c.pathname===n.pathname)return null;let a=`${xf}${c.href}:${l||"none"}`,p,f=e?null:kf(a);if(f&&typeof f.checkedAt=="number"&&r-f.checkedAt<i)p=f.sourceVersion;else{try{let d=await o(c.href);if(!d.ok)throw new Error(`HTTP ${d.status}`);let w=await d.text(),b=new DOMParser().parseFromString(w,"text/html");p=Dn(b,"hyper-version")}catch{p=null}Af(a,{checkedAt:r,sourceVersion:p})}return p?{available:Ul(p,l||"0.0.0"),currentVersion:l,sourceVersion:p,sourceUrl:c.href}:null}var Bn={};Jr(Bn,{EmptyListInsert:()=>Jn,MAX_RULE_DEPTH:()=>Do,MaxRuleDepthExceeded:()=>po,NoRulesTag:()=>zs,RuleTargetReadOnly:()=>rr,RulesParseError:()=>jo,ShapeMismatch:()=>or,UnknownRulesVersion:()=>ho,WriteNotRoundTripped:()=>_r,WriteRefused:()=>sr,WriteRejected:()=>Gs});var jo=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},ho=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},Do=20,po=class extends Error{constructor(t){super(`rule depth exceeded ${Do} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},or=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},Jn=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`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}},rr=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},sr=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Tf(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var _r=class extends Error{constructor(t){super(`write did not round-trip at "${Tf(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},zs=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Gs=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}};var Sf=/^--[A-Za-z0-9_-]+$/;function Zn(e){return typeof e=="string"&&Sf.test(e)}function Hl(e){let t=[],n=[],o=null,r=0;for(let i=0;i<e.length;i++){let s=e[i];if(o){s==="\\"?i++:s===o&&(o=null);continue}if(s==="/"&&e[i+1]==="*"){let l=e.indexOf("*/",i+2);i=l===-1?e.length:l+1;continue}s==='"'||s==="'"?o=s:s==="("?n.push(")"):s==="["?n.push("]"):s==="{"?n.push("}"):(s===")"||s==="]"||s==="}")&&n[n.length-1]===s?n.pop():s===";"&&n.length===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function Nf(e){let t="",n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){t+=r,r==="\\"&&o+1<e.length?t+=e[++o]:r===n&&(n=null);continue}if(r==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Vl(e){e=Nf(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(o);return r&&(o=o.slice(0,r.index).trim()),{name:n,value:o,important:!!r}}function Bo(e,t){if(e==null)return null;let n=null;for(let o of Hl(String(e))){let r=Vl(o);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function _l(e,t,n){let o=e==null?"":String(e),r=n==null||n==="",i=Hl(o),s=i.map(Vl),l=s.some(f=>f&&f.name===t&&f.important),c=[],a=!1;i.forEach((f,d)=>{let w=s[d];if(!w||w.name!==t){c.push(f);return}if(r||a)return;let b=/^\s*/.exec(f)[0];c.push(`${b}${t}: ${n}${l?" !important":""}`),a=!0});let p=c.join(";");if(!r&&!a){let f=p.trimEnd();p=f===""?`${t}: ${n}`:`${f}${f.endsWith(";")?" ":"; "}${t}: ${n}`}return p.trim()===""?null:p}function Wr(e,t,n,o){let r=e.attr(t,"style");if((Bo(r,n)??"")===o)return;let i=_l(r,n,o);i==null?e.removeAttr(t,"style"):e.attr(t,"style",i)}function Un(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 Xs(e,t,n,{depth:0,path:[]},o)}function Xs(e,t,n,o,r){if(o.depth>Do)throw new po(o.path);if(typeof n=="string")return vf(e,t,n,o,r);if(Array.isArray(n)){let[i,s]=n,l=e.find(t,i,r);return Wl(r,o,l),l.map((c,a)=>Xs(e,c,s,{depth:o.depth+1,path:[...o.path,a]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[s,l]of Object.entries(n))i[s]=Xs(e,t,l,{depth:o.depth+1,path:[...o.path,s]},r);return i}return null}function vf(e,t,n,o,r){if(n.endsWith("[]")){let a=n.slice(0,-2),p=e.find(t,a,r);return Wl(r,o,p),p.map(f=>e.text(f))}if(n.startsWith("@"))return Ys(e,t,n.slice(1));let i=bn(n);if(i!==-1){let{selector:a,all:p}=en(n),f=n.slice(i+1),d=a?e.find(t,a,r):[t];return p&&r.allMatches?d.map(w=>Ys(e,w,f)):d.length===0?null:Ys(e,d[0],f)}if(n===".")return e.text(t);let{selector:s,all:l}=en(n),c=e.find(t,s,r);return l&&r.allMatches?c.map(a=>e.text(a)):c.length===0?null:e.text(c[0])}function Wl(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 Ys(e,t,n){if(Zn(n))return Bo(e.attr(t,"style"),n);if(ko.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}var $r=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"]})}),Of=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),$l=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function ir(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 Js(e,t){if(ir(e,t))return!0;for(let[n,o]of Object.entries(Of))if(o.includes(t)&&ir(e,n))return!0;return!1}function lr(e){let t=$r[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Mf(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=$r[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Js(n,r))||o.bundles.some(r=>ir(n,r)))return n;n=n.parentElement}return null}function Fl(e,t){return!!Mf(e,t)}var Ef=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function If(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function ql(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 Kl(e,t,n,o,r,i){return(i?Fl(e,t):ql(e,n,r,!1))||!!(o&&(i&&e!==r?e.matches(o):ql(e,o,r,i)))}function Cf(e,t){let n=$r[t];return n.tokens.some(o=>Js(e,o))||n.bundles.some(o=>ir(e,o))}var Rf=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function zl(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,i=t;if(e.nodeType===1){if(Rf.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,i=t.content,n.cloneToLive.set(i,r),n.liveToClone.set(r,i)}}else if(e.nodeType!==11)return;let s=i.firstChild;for(let l=r.firstChild;l&&s;l=l.nextSibling)zl(l,s,n,o),s=s.nextSibling}function cr(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=i.implementation.createHTMLDocument(""),l=r||new WeakMap,c=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let p=lr(t),f=o?b=>Cf(b,t)||!!(n&&b.matches(n)):b=>Kl(b,t,p,n,a,!1),d=null;if(a.nodeType!==1||!Kl(a,t,p,n,a,o)){d=s.importNode(a,!0);let b={cloneToLive:l,liveToClone:c,dropped:[],controls:[]};zl(a,d,b,f);for(let T of b.dropped)T.remove();for(let T=0;T<b.controls.length;T+=2)If(b.controls[T],b.controls[T+1])}e.nodeType===9&&d&&(s.replaceChild(d,s.documentElement),c.set(e,s),l.set(s,e));let w=b=>{if(Ef.test(b))throw new Error(`Filtered content queries do not support stateful selector: ${b}`)};return{root:d,document:s,capability:t,selector:lr(t),cloneToLive:l,liveToClone:c,original(b){return l.get(b)||null},cloneOf(b){return c.get(b)||null},query(b,T=d){return w(b),Array.from(T.querySelectorAll(b),g=>l.get(g)||g)},text(b=d){return(b===d?d:c.get(b))?.textContent||""},html(b=d){return(b===d?d:c.get(b))?.innerHTML??""},clone(b=d){let T=b===d?d:c.get(b);return T?s.importNode(T,!0):null}}}function Yl(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Lf(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Gl(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function Xl(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Jl(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var Xt={semanticExclude:!0,find(e,t,n={}){let o=Lf(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!Yl(l)));let i=[];n.skip&&i.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&i.push("["+s+"]"),i.length){let l=i.join(", ");r=r.filter(c=>!c.closest||!c.closest(l))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Xl(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Gl(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Gl(e,t,null)},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){let t=e.cloneNode(!0);return Jl(t),t},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Qn(e,t={}){if(t.exclude===null)return Xt;let n=[lr("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 Xt;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,l=null,c=()=>l||(l=cr(i,{capability:"data",exclude:t.exclude||null})),a=b=>{let T=c();return b===e?T.cloneOf(e):T.cloneOf(b)||b},p=b=>l?.original(b)||b,f=(b,T)=>{c().liveToClone.set(b,T),c().cloneToLive.set(T,b);let g=b.childNodes||[],h=T.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)f(g[y],h[y])},d=(b,T,g,h)=>{let y=Array.from(b.childNodes).filter(R=>l.cloneOf(R)),x=y[0];for(;x&&y.includes(x);)x=x.nextSibling;for(let R of y)R.remove();if(g==="innerHTML"){let R=s.createElement("template");R.innerHTML=h;for(let M of Array.from(R.content.childNodes))b.insertBefore(M,x||null)}else b.insertBefore(s.createTextNode(h),x||null),Xl(b,h);let S=cr(b,{capability:"data",exclude:t.exclude||null});T.replaceChildren(...Array.from(S.root?.childNodes||[]));let O=R=>{let M=S.original(R);M&&(l.liveToClone.set(M,R),l.cloneToLive.set(R,M));for(let j of Array.from(R.childNodes||[]))O(j)};for(let R of Array.from(T.childNodes))O(R)},w={...Xt,find(b,T,g={}){let h=a(b);if(!h?.querySelectorAll)return[];let y=c().query(T,h);g.includeRulesTag||(y=y.filter(S=>!Yl(S)));let N=[];g.skip&&N.push(g.skip);let x=g.templateAttr===null?null:g.templateAttr||"cms-template";if(x&&N.push(`[${x}]`),N.length){let S=N.join(", ");y=y.filter(O=>!O.closest?.(S))}return y},parent(b){let T=a(b)?.parentElement;return T?p(T):null},children(b){return Array.from(a(b)?.children||[],p)},text(b,T){if(T===void 0){let y=p(b);return!y?.matches?.(n)&&!y?.querySelector?.(n)?Xt.text(y):(a(b)?.textContent||"").trim()}let g=p(b);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){Xt.text(g,T);return}let h=c().cloneOf(g);h?d(g,h,"textContent",T):Xt.text(g,T)},attr(b,T,g){let h=p(b);if(g===void 0)return Xt.attr(h,T);Xt.attr(h,T,g);let y=l?.cloneOf(h);y&&(Xt.attr(y,T,g),cr(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(h),l.cloneToLive.delete(y)))},removeAttr(b,T){let g=p(b);Xt.removeAttr(g,T);let h=l?.cloneOf(g);h&&Xt.removeAttr(h,T)},prop(b,T,g){let h=p(b);if(g===void 0)return T==="innerHTML"||T==="outerHTML"||T==="textContent"||T==="innerText"?Xt.prop(a(h),T):Xt.prop(h,T);let y=T==="innerHTML"||T==="textContent"||T==="innerText",N=y?c().cloneOf(h):l?.cloneOf(h);N&&y?d(h,N,T,g):(Xt.prop(h,T,g),N&&Xt.prop(N,T,g))},clone(b){let T=a(b);if(T===b)return Xt.clone(b);let g=s.importNode(T,!0);return Jl(g),g},insertAt(b,T,g){let h=p(b),N=w.children(h)[g]||(()=>{for(let O=h.children.length-1;O>=0;O--){let R=h.children[O];if(c().cloneOf(R))return R.nextElementSibling}return h.firstElementChild})(),x=p(T);h.insertBefore(x,N||null);let S=c().cloneOf(h);if(S){let O=c().cloneOf(x);O||(O=s.importNode(x,!0),f(x,O));let R=Array.from(S.children);S.insertBefore(O,R[g]||null)}},insertBefore(b,T){let g=p(b),h=p(T);g.parentNode.insertBefore(h,g);let y=c().cloneOf(g.parentNode);if(y){let N=c().cloneOf(h);N||(N=s.importNode(h,!0),f(h,N));let x=c().cloneOf(g);x?x.before(N):y.appendChild(N)}},insertAfter(b,T){let g=p(b),h=p(T);g.parentNode.insertBefore(h,g.nextSibling);let y=c().cloneOf(g.parentNode);if(y){let N=c().cloneOf(h);N||(N=s.importNode(h,!0),f(h,N));let x=c().cloneOf(g);x?x.after(N):y.appendChild(N)}},identity(b){return p(b)||null},remove(b){let T=p(b),g=c().cloneOf(T);Xt.remove(T),g&&Xt.remove(g)},replaceWith(b,T){let g=p(b),h=c().cloneOf(g),y=Xt.replaceWith(g,T);if(h){let N=cr(y,{capability:"data",exclude:t.exclude||null});if(!N.root)h.remove();else{h.replaceWith(N.root);let x=S=>{let O=N.original(S);O&&(l.liveToClone.set(O,S),l.cloneToLive.set(S,O));for(let R of Array.from(S.childNodes||[]))x(R)};x(N.root)}}return y}};return w}var vn=Xt;function Zs(e){try{return JSON.parse(e)}catch(t){throw new jo(`Invalid strict JSON: ${t.message}`,t)}}function mo(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=[],s=0;for(;s<r.length;){let l=r[s];if(/\s/.test(l)){s++;continue}if("{}".includes(l)){i.push({type:l,value:l}),s++;continue}if(l==="["){let f=!1,d=s+1;for(;d<r.length&&/\s/.test(r[d]);)d++;if(d<r.length&&/[a-zA-Z_]/.test(r[d])&&(f=!0),!f){i.push({type:l,value:l}),s++;continue}}if(l==="]"){i.push({type:l,value:l}),s++;continue}if(l===":"){i.push({type:t.COLON,value:l}),s++;continue}if(l===","){i.push({type:t.COMMA,value:l}),s++;continue}if(l==='"'||l==="'"){let f=l,d=s+1;for(;d<r.length&&r[d]!==f;)r[d]==="\\"&&d++,d++;i.push({type:t.STRING,value:r.substring(s+1,d),quoted:!0,sourceQuote:f}),s=d+1;continue}let c=s,a;for(;c<r.length&&!/[{},]/.test(r[c]);)if(r[c]===":"){let f=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let w of f){let b=w.substring(1);if(r.substring(c+1,c+1+b.length)===b){d=!0,c+=b.length;break}}if(!d)break}else if(r[c]==="["){for(c++;c<r.length&&r[c]!=="]";){if(r[c]==='"'||r[c]==="'"){let f=r[c];for(c++;c<r.length&&r[c]!==f;)r[c]==="\\"&&c++,c++}c++}c<r.length&&r[c]==="]"&&c++}else c++;a=r.substring(s,c);let p=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(a)?p=t.NUMBER:a==="true"||a==="false"||a==="null"?p=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(a)&&(p=t.SELECTOR),i.push({type:p,value:a,quoted:!1}),s=c}return i}function o(r){let i="";for(let s=0;s<r.length;s++){let l=r[s];if("{}".includes(l.type)||"[]".includes(l.type)){i+=l.value;continue}if(l.type===t.COLON){i+=l.value;continue}if(l.type===t.COMMA){let c=r[s+1];if(c&&(c.type==="}"||c.type==="]"))continue;i+=l.value;continue}if(l.type===t.STRING&&l.quoted){let c=l.value;l.sourceQuote==="'"&&(c=c.replace(/\\'/g,"'"),c=c.replace(/(\\*)"/g,(a,p)=>p.length%2===0?p+'\\"':a)),i+=`"${c}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){i+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){i+=`"${l.value}"`;continue}i+=`"${l.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new jo("Invalid extraction rules syntax: "+r.message,r)}}var Qs="1",Zl=/^[a-zA-Z0-9_-]+$/;function Uo(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!Zl.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Zl})`);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],s=e.attr(i,"data-rules-version");if(s!==Qs)throw new ho(s);return{rules:mo(e.text(i)),tagNode:i}}var Pf="script[data-rules-name]";function Ql(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ar(e,t){let n=e.find(t,Pf,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let s=Ql(e.attr(i,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let l=e.attr(i,"data-rules-version");if(l!==Qs)throw new ho(l);o.add(s),r.push({name:s,rules:mo(e.text(i))})}return r}function Fr(e,t){let n={};for(let{name:o,rules:r}of ar(e,t))n[o]=Un(e,t,r);return n}function ei(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Fr(vn,t),version:Dn(n,"hyper-version")}}var Ho=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},fr=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}},eo=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},ur=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 ec="text/hyper-upgrade";function ti(e,t){let n=e.find(t,`script[type="${ec}"]`);if(n.length===0)return null;if(n.length>1)throw new ur(n.length);return e.text(n[0])||null}var jf=new Function("url","return import(url)");async function ni(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await jf(n)}catch(r){throw new eo(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new eo("transform must `export default` a function");return o.default}function oc(e,t,n,o){let r=e.length,i=t.length,s=new Array(r).fill(-1);if(o){let h=new Set;for(let y=0;y<r;y++){let N=o[y];!(N>=0&&N<i)||h.has(N)||(s[y]=N,h.add(N))}}if(r===0||i===0)return s;let l=e.map(h=>tc(h,n)),c=t.map(h=>tc(h,n)),a=new Array(i).fill(!1);for(let h of s)h>=0&&(a[h]=!0);let p=new Map;c.forEach((h,y)=>{a[y]||p.set(h,p.has(h)?-1:y)});let f=new Map;l.forEach((h,y)=>{s[y]>=0||f.set(h,(f.get(h)||0)+1)}),l.forEach((h,y)=>{if(s[y]>=0||f.get(h)!==1)return;let N=p.get(h);N===void 0||N===-1||a[N]||(s[y]=N,a[N]=!0)});let d=[];for(let h=0;h<r;h++)s[h]<0&&d.push(h);let w=[];for(let h=0;h<i;h++)a[h]||w.push(h);if(d.length===0||w.length===0)return s;let b=r*i+1,T=Df(e,t,n),g=(h,y)=>T(h,y)*b+Math.abs(h-y);for(let[h,y]of Bf(d,w,g))s[h]=y;return s}var rc=e=>typeof e=="object"&&e!==null;function tc(e,t){if(!rc(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 Df(e,t,n){if(!rc(n))return(l,c)=>e[l]===t[c]?0:1;let o=Object.keys(n),r=l=>o.map(c=>JSON.stringify(l?.[c])),i=e.map(r),s=t.map(r);return(l,c)=>{let a=i[l],p=s[c],f=0;for(let d=0;d<o.length;d++)a[d]!==p[d]&&f++;return f}}function Bf(e,t,n){return e.length<=t.length?nc(e,t,n,!1):nc(t,e,(o,r)=>n(r,o),!0)}function nc(e,t,n,o){let r=e.length,i=t.length,s=[];for(let f=0;f<=r;f++)s.push(new Float64Array(i+1).fill(1/0));let l=[];for(let f=0;f<=r;f++)l.push(new Uint8Array(i+1));for(let f=0;f<=i;f++)s[r][f]=0;for(let f=r-1;f>=0;f--)for(let d=i-1;d>=0;d--){let w=n(e[f],t[d])+s[f+1][d+1],b=s[f][d+1];w<=b?(s[f][d]=w,l[f][d]=1):s[f][d]=b}let c=[],a=0,p=0;for(;a<r&&p<i;)l[a][p]&&(c.push(o?[t[p],e[a]]:[e[a],t[p]]),a++),p++;return c}function ri(e,t,n,o,r,i,s,l={}){let c=e.find(t,n,l);if(r.length===0){c.forEach(x=>e.remove(x)),oi(l,"onRowsApplied",i.path,[]);return}let a=r.length>c.length,p=c[0]||null;if(a&&!p&&(p=_f(e,t,n,l),!p))throw new Jn(i.path);let f=c.map(x=>Vf(e,x,o,l)),d=null;if(a&&p){d=e.clone(p),l.templateAttr&&e.removeAttr(d,l.templateAttr);let x=e.stripIds(d);x>0&&console.warn(`[hyper-html-api] stripped ${x} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let w=oc(r,f,o,Uf(e,c,r,i,l)),b=c.length>0?e.parent(c[0]):qf(e,t,n,p,i,l),T=c.length>0?ac(e,b,c[0]):0,g=Gf(e,c),h=new Set,y=[],N=r.map((x,S)=>{let O=w[S];if(O>=0)return h.add(O),y.push(!1),c[O];y.push(!0);let R=e.clone(d);return e.stripIds(R),R});c.forEach((x,S)=>{h.has(S)||e.remove(x)}),g?zf(e,b,T,N,y):Yf(e,N,y,b,T),Hf(e,N,o,r,i,s,l),oi(l,"onRowsApplied",i.path,N)}function oi(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 Uf(e,t,n,o,r){let i=oi(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let s=new Array(n.length).fill(-1),l=new Set,c=new Map(t.map((a,p)=>[e.identity(a),p]));for(let a=0;a<n.length;a++){if(!i[a])continue;let p=c.get(e.identity(i[a]));p===void 0||l.has(p)||(s[a]=p,l.add(p))}return s}function Hf(e,t,n,o,r,i,s){t.forEach((l,c)=>{if(n===null){let a=o[c],p=a==null?"":String(a);e.text(l)!==p&&e.text(l,p)}else{let a=i(e,l,n,o[c],{depth:r.depth+1,path:[...r.path,c]},s);a&&a!==l&&(t[c]=a)}})}function Vf(e,t,n,o){return n===null?e.text(t):Un(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function ac(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 _f(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),i=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(i,""),l=r?Wf(s):0,c=ts(s),a=t;for(;a;){let p=e.find(a,s,{includeRulesTag:!1,templateAttr:null});for(let f of p)if(e.attr(f,o.templateAttr)!=null&&!(r&&!Ff(e,t,f,l))&&!(c&&!e.matches(e.parent(f),c)))return f;a=e.parent(a)}return null}function Wf(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\")r++;else if(n)i===n&&(n=null);else if(i==='"'||i==="'")n=i;else if(i==="["||i==="(")t++;else if(i==="]"||i===")")t>0&&t--;else if(t===0&&i===">")o++;else{if(t===0&&(i==="+"||i==="~"))return null;if(t===0&&/\s/.test(i)){if(!$f(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function $f(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return sc(o)||sc(r)}function sc(e){return e===">"||e==="+"||e==="~"}function Ff(e,t,n,o){if(o===null)return!0;let r=n;for(let c=0;c<o;c++)if(r=e.parent(r),!r)return!1;let i=e.prop(t,"tagName");if(!i)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(i).toLowerCase())return!1;let l=new Set(ic(e,r));return ic(e,t).every(c=>l.has(c))}function ic(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function qf(e,t,n,o,r,i){let s=e.parent(o);if(s&&Kf(e,t,s)&&!cc(e,s,i))return s;let l=ts(n);if(!l)throw new Jn(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let a=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,i)).filter(p=>!cc(e,p,i));if(a.length===0)throw new Jn(r.path,`no container matching "${l}" inside this context to hold the new rows`);if(a.length>1)throw new Jn(r.path,`"${l}" matches ${a.length} containers inside this context, so the new rows have no single destination`);return a[0]}function Kf(e,t,n){let o=n;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var lc=["no-data","editor-ui"];function cc(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||lc.some(i=>e.attr(o,i)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(i=>lc.includes(i)))return!0;o=e.parent(o)}return!1}function zf(e,t,n,o,r){let i=e.children(t),s=i.map(c=>e.identity(c)),l=!1;o.forEach((c,a)=>{let p=e.identity(c),f=n+a;if(s[f]===p)return;if(!r[a]){let w=s.indexOf(p);w!==-1&&(s.splice(w,1),i.splice(w,1))}let d=Math.min(f,i.length);d<i.length?e.insertBefore(i[d],c):i.length?l?e.insertAfter(i[i.length-1],c):(e.insertAt(t,c,f),l=!0):e.insertAt(t,c,0),s.splice(d,0,p),i.splice(d,0,c)})}function Gf(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((i,s)=>[e.identity(i),s])),r=[];for(let i of t){let s=o.get(e.identity(i));if(s===void 0)return!1;r.push(s)}return r.sort((i,s)=>i-s),r[r.length-1]-r[0]===r.length-1}function Yf(e,t,n,o,r){let i=null,s=r;for(let l=0;l<t.length;l++){if(!n[l]){i=t[l];continue}let c=i?e.parent(i):o;if(!c)continue;let a=i?ac(e,c,i)+1:s++;e.insertAt(c,t[l],a),i=t[l]}}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(si(n,o,[],i),i.length)throw new or(i);qr(e,t,n,o,{depth:0,path:[]},r)}function qr(e,t,n,o,r,i={}){if(r.depth>Do)throw new po(r.path);if(o===void 0)return t;if(typeof n=="string")return Xf(e,t,n,o,r,i);if(Array.isArray(n)){let[s,l]=n;return ri(e,t,s,l,o,r,qr,i),t}if(typeof n=="object"&&n!==null){for(let[s,l]of Object.entries(n)){let c=qr(e,t,l,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},i);c&&c!==t&&(t=c)}return t}return t}function Xf(e,t,n,o,r,i){if(n.endsWith("[]")){let p=n.slice(0,-2);return ri(e,t,p,null,o,r,qr,i),t}if(n.startsWith("@"))return uc(e,t,n.slice(1),o);let s=bn(n);if(s!==-1){let{selector:p,all:f}=en(n),d=n.slice(s+1),w=p?e.find(t,p,i):[t];for(let b of f?w:w.slice(0,1))uc(e,b,d,o);return t}if(n===".")return fc(e,t,o),t;let{selector:l,all:c}=en(n),a=e.find(t,l,i);for(let p of c?a:a.slice(0,1))fc(e,p,o);return t}function fc(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Jf(e,t,n,o){if(e.styleVar){e.styleVar(t,n,o);return}Wr(e,t,n,o)}function uc(e,t,n,o){if(Zn(n))return Jf(e,t,n,o==null?"":String(o).trim()),t;if(io.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new rr(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(Qr.has(n)){let r=es(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function si(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:hr([...n,i]),expected:"scalar",got:dr(r)})}):o.push({path:hr(n),expected:"array",got:dr(t)});return}t!==null&&typeof t=="object"&&o.push({path:hr(n),expected:"scalar",got:dr(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:hr(n),expected:"array",got:dr(t)});return}let r=e[1];t.forEach((i,s)=>si(r,i,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:hr(n),expected:"object",got:dr(t)});return}for(let[r,i]of Object.entries(e))si(i,t[r],[...n,r],o)}}}function dr(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function hr(e){return e.join(".")}function pr(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=ii(t,e,n);return li(t,e,n),{data:o,summary:n}}function ii(e,t,n,o=!1){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):o?[]:void 0:t==null||typeof t=="object"?o&&!Zf(e)?null:void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,r]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(i=>ii(r,i,n,!0))):o?[]:void 0}if(typeof e=="object"&&e!==null){let r={};for(let[i,s]of Object.entries(e)){let l=ii(s,t?.[i],n,o);l!==void 0&&(r[i]=l)}return r}}function Zf(e){let t=bn(e);return t!==-1&&io.has(e.slice(t+1))}function li(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)?li(e[r],t[r],n):n.discarded+=go(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>li(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=go(t))}}function go(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+go(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+go(n),0):1}function ci(e,t,n){let o=ar(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},s=new Set;for(let{name:l,rules:c}of o){if(s.add(l),!Object.prototype.hasOwnProperty.call(n,l)){i[l]={carriedOver:0,discarded:0,listItems:0};continue}let{data:a,summary:p}=pr(n[l],c);$n(e,t,c,a,{templateAttr:"cms-template"}),i[l]=p,r.carriedOver+=p.carriedOver,r.discarded+=p.discarded,r.listItems+=p.listItems}for(let l of Object.keys(n))s.has(l)||(r.discarded+=go(n[l]));return{totals:r,byName:i,rulesTagCount:o.length}}async function ai({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||(h=>fetch(h)),!o)throw new Error("upgrade.run requires a document context");if(e=e||Dn(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:Dn(o,"hyper-version"),t=t||Fr(vn,o);let l;try{l=await i(s.href)}catch(h){throw new Ho(s.href,h)}if(!l.ok)throw new Ho(s.href,new Error(`HTTP ${l.status}`));let c=await l.text(),a=new DOMParser().parseFromString(c,"text/html"),p=Dn(a,"hyper-version"),f=t,d=!1,w=ti(vn,a);if(w){let y=await(await ni(w))(f,{fromVersion:n,toVersion:p});if(!y||typeof y!="object"||Array.isArray(y))throw new eo("transform must return a plain object map of { rulesName: data }");f=y,d=!0}let{totals:b,byName:T,rulesTagCount:g}=ci(vn,a,f);if(g===0&&Object.keys(f).length>0)throw new fr(s.href);return{html:eu(a),fromVersion:n,toVersion:p,summary:{transformApplied:d,totals:b,byName:T}}}function Qf(e){for(let t of e.querySelectorAll("input")){let n=(t.getAttribute("type")||"").toLowerCase();n!=="file"&&(n==="checkbox"||n==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let n=[...t.options];if(!t.multiple){let o=n.findIndex(r=>r.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of n)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function eu(e){return Qf(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
8
+ `+e.documentElement.outerHTML}var Kr=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",...$l],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})}),nu=new Set(["textContent","innerText"]);function dc(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var ou=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function hc(e,t,n=Kr){if(!ou.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>o.startsWith(r)))return`attribute "${o}" can run script`;if(n.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(n.urlAttributes.includes(o)&&t!=null){let r=o==="srcset"?String(t).split(",").map(i=>i.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let i of r){let s=dc(i);if(s&&n.refusedSchemes.includes(s))return`"${s}:" URLs are not allowed in "${o}"`}}return null}function fi(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function ru(e,t){let n=fi(e,t)||"node",o=e.attr(t,"id");return o?`<${n}#${o}>`:`<${n}>`}function su(e,t,n){let o=t;for(;o;){let r=fi(e,o);if(r&&n.refusedTargets.includes(r))return r;o=e.parent(o)}return null}function pc(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function iu(e,t){return fi(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:pc(e,t)}function lu(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'")n=r;else{if(r==="/"&&e[o+1]==="*")return"comments are not allowed in a custom property value";if(r==="(")t.push(")");else if(r==="[")t.push("]");else if((r===")"||r==="]")&&t.pop()!==r)return`"${r}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function mc(e,t=Kr){let n=t.customPropertyValues,o=String(e);if(o.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let r=n.refusedCharacters.find(c=>o.includes(c));if(r)return`${JSON.stringify(r)} is not allowed in a custom property value`;let i=lu(o);if(i)return i;let s=o.toLowerCase(),l=n.refusedFunctions.find(c=>new RegExp(`(^|[^a-z0-9_-])${c.replace(/[-]/g,"\\-")}\\s*\\(`).test(s));return l?`"${l}()" is not allowed in a custom property value`:null}function zr(e,t=Kr){let n=[],o=(c,a)=>(n.push({target:ru(e,c),reason:a}),!1),r=c=>{let a=su(e,c,t);return a?o(c,`inside <${a}>, which is not content`):!0},i=c=>r(c)?pc(e,c)?o(c,"a text write here would delete the data rules tag"):!0:!1,s=(c,a,p)=>{if(!r(c))return!1;let f=hc(a,p,t);return f?o(c,f):!0};return{...e,text(c,a){if(a===void 0)return e.text(c);i(c)&&e.text(c,a)},attr(c,a,p){if(p===void 0)return e.attr(c,a);s(c,a,p)&&e.attr(c,a,p)},removeAttr(c,a){s(c,a,null)&&e.removeAttr(c,a)},styleVar(c,a,p){if((Bo(e.attr(c,"style"),a)??"")!==p&&r(c)){if(!Zn(a))return o(c,`"${a}" is not a custom property`);if(p!==""){let f=mc(p,t);if(f)return o(c,f)}Wr(e,c,a,p)}},prop(c,a,p){if(p===void 0)return e.prop(c,a);if(t.refusedRuleForms.includes(a))return o(c,`"@${a}" writes HTML, only text is allowed`);if(nu.has(a)){i(c)&&e.prop(c,a,p);return}s(c,a==="className"?"class":a,p)&&e.prop(c,a,p)},remove(c){if(iu(e,c)){o(c,"removing this would delete the data rules tag");return}e.remove(c)},replaceWith(c,a){return a===e.prop(c,"outerHTML")||o(c,'"@outerHTML" writes HTML, only text is allowed'),c},refusals:n,assertClean(){if(n.length)throw new sr(n.slice())}}}function mr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function gc(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function ui(e,t,n,o,r={}){let i=[],s=[];function l(a,p,f){if(Array.isArray(a)){let[,d]=a;if(!Array.isArray(p)||!mr(d))return;p.forEach((w,b)=>l(d,w,[...f,b]));return}if(!(!mr(a)||!mr(p)))for(let d of Object.keys(p))Object.prototype.hasOwnProperty.call(a,d)?l(a[d],p[d],[...f,d]):i.push(gc([...f,d]))}function c(a,p,f,d){if(f!==void 0){if(typeof p=="string"){if(p.endsWith("[]")||p==="."||p.startsWith("@"))return;let{selector:w}=en(p);if(!w)return;e.find(a,w,r).length===0&&s.push({path:gc(d),selector:w});return}if(!Array.isArray(p)&&mr(p)&&mr(f))for(let[w,b]of Object.entries(p))c(a,b,f[w],[...d,w])}}return l(n,o,[]),c(t,n,o,[]),{unknownKeys:i,unmatched:s}}function di(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 Uo(e,o,n)}return null}var gr={extract:(e,t,n={})=>Un(Qn(e,n),e,t,n),apply:(e,t,n,o={})=>$n(Qn(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>Uo(vn,e,t),findRules:(e,t)=>di(vn,e,t),bind:(e,t,n={})=>{let o=di(vn,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:()=>Un(Qn(e,n),e,o.rules,n),set:r=>$n(Qn(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:Zs,parseRelaxed:mo,ruleAttrIndex:bn,splitRule:en,errors:Bn,DOM_PROPERTIES:Tr},hi=e=>!!e&&typeof e.nodeType=="number";function bc(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=Uo(vn,t,"api");if(!n)throw new Bn.NoRulesTag("api");return n.rules}function au(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function fu(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function uu(e,t){let n=[];for(;t!==e;){let o=t.parentNode;n.push(Array.prototype.indexOf.call(o.childNodes,t)),t=o}return n.reverse()}function du(e,t){return t.reduce((n,o)=>n.childNodes[o],e)}function Vo(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function hu(e,t){let n=Vo(e,"option"),o=Vo(t,"option");n.forEach((c,a)=>o[a].selected=c.selected);let r=Vo(e,"input"),i=Vo(t,"input");r.forEach((c,a)=>{let p=c.type.toLowerCase();p!=="file"&&(i[a].value=c.value),(p==="checkbox"||p==="radio")&&(i[a].checked=c.checked)});let s=Vo(e,"textarea"),l=Vo(t,"textarea");s.forEach((c,a)=>l[a].value=c.value)}function pi(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:bn(e);if(n===-1)return;let o=e.slice(n+1);if(io.has(o))throw new Bn.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>pi(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,o]of Object.entries(e))pi(o,t[n])}}function pu(e,t,n){let o={templateAttr:"cms-template"},r=au(e),i=uu(r,e),s=fu(r);hu(r,s);let l=du(s,i),c=Qn(s,{...o,_write:!0}),a=ui(c,l,t,n,o);if(a.unknownKeys.length||a.unmatched.length)throw new Bn.WriteRejected(a.unknownKeys,a.unmatched);let p=zr(c);$n(p,l,t,n,o),p.assertClean(),pi(t,n);let f=zr(Qn(r,{...o,_write:!0}));$n(f,e,t,n,o),f.assertClean()}function mu(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof Bn.WriteRefused?e.details=e.refusals:e instanceof Bn.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof Bn.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function mi(e,t){let n=hi(e)?e:document,o=hi(e)?t:e;return o===void 0?Un(Qn(n),n,bc(n)):gr.bind(n,o).get()}function gi(e,t,n){try{if(!hi(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=n===void 0?bc(e):gr.bind(e,n).rules;pu(e,o,t)}catch(o){throw mu(o)}return e}var yc={buildForm:ns,bindFormEvents:os,scaffold:Ao,morphForm:Fs,path:Ar},wc={checkForUpdate:Ks,run:ai,extractAll:ei,shapeMatch:pr};var gu={engine:gr,cms:yc,upgrade:wc,extractData:mi,applyData:gi},bu=gu;return Nc(yu);})();