gp-designer 1.0.49 → 1.0.51

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.
@@ -5,7 +5,7 @@
5
5
  fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
6
6
  )`,enabled:":not(:disabled)",checked:":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",required:":is(input, select, textarea)[required]",optional:":is(input, select, textarea):not([required])",selected:"option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",checkbox:"[type=checkbox]",file:"[type=file]",password:"[type=password]",radio:"[type=radio]",reset:"[type=reset]",image:"[type=image]",submit:"[type=submit]",parent:":not(:empty)",header:":is(h1, h2, h3, h4, h5, h6)",button:":is(button, input[type=button])",input:":is(input, textarea, select, button)",text:"input:is(:not([type!='']), [type=text])"},qi={};function vf(A,e){return A===J.falseFunc?J.falseFunc:t=>e.isTag(t)&&A(t)}function ji(A,e){const t=e.getSiblings(A);if(t.length<=1)return[];const r=t.indexOf(A);return r<0||r===t.length-1?[]:t.slice(r+1).filter(e.isTag)}function ys(A){return{xmlMode:!!A.xmlMode,lowerCaseAttributeNames:!!A.lowerCaseAttributeNames,lowerCaseTags:!!A.lowerCaseTags,quirksMode:!!A.quirksMode,cacheResults:!!A.cacheResults,pseudos:A.pseudos,adapter:A.adapter,equals:A.equals}}const Ns=(A,e,t,r,n)=>{const s=n(e,ys(t),r);return s===J.trueFunc?A:s===J.falseFunc?J.falseFunc:a=>s(a)&&A(a)},Ss={is:Ns,matches:Ns,where:Ns,not(A,e,t,r,n){const s=n(e,ys(t),r);return s===J.falseFunc?A:s===J.trueFunc?J.falseFunc:a=>!s(a)&&A(a)},has(A,e,t,r,n){const{adapter:s}=t,a=ys(t);a.relativeSelector=!0;const u=e.some(f=>f.some(Fs))?[qi]:void 0,o=n(e,a,u);if(o===J.falseFunc)return J.falseFunc;const c=vf(o,s);if(u&&o!==J.trueFunc){const{shouldTestNextSiblings:f=!1}=o;return h=>{if(!A(h))return!1;u[0]=h;const d=s.getChildren(h),C=f?[...d,...ji(h,s)]:d;return s.existsOne(c,C)}}return f=>A(f)&&s.existsOne(c,s.getChildren(f))}};function Lf(A,e,t,r,n){var s;const{name:a,data:u}=e;if(Array.isArray(u)){if(!(a in Ss))throw new Error(`Unknown pseudo-class :${a}(${u})`);return Ss[a](A,u,t,r,n)}const o=(s=t.pseudos)===null||s===void 0?void 0:s[a],c=typeof o=="string"?o:Sf[a];if(typeof c=="string"){if(u!=null)throw new Error(`Pseudo ${a} doesn't have any arguments`);const f=Vr(c);return Ss.is(A,f,t,r,n)}if(typeof o=="function")return Ji(o,a,u,1),f=>o(f,u)&&A(f);if(a in Is)return Is[a](A,u,t,r);if(a in Wi){const f=Wi[a];return Ji(f,a,u,2),h=>f(h,t,u)&&A(h)}throw new Error(`Unknown pseudo-class :${a}`)}function vs(A,e){const t=e.getParent(A);return t&&e.isTag(t)?t:null}function Hf(A,e,t,r,n){const{adapter:s,equals:a}=t;switch(e.type){case V.PseudoElement:throw new Error("Pseudo-elements are not supported by css-select");case V.ColumnCombinator:throw new Error("Column combinators are not yet supported by css-select");case V.Attribute:{if(e.namespace!=null)throw new Error("Namespaced attributes are not yet supported by css-select");return(!t.xmlMode||t.lowerCaseAttributeNames)&&(e.name=e.name.toLowerCase()),Ff[e.action](A,e,t)}case V.Pseudo:return Lf(A,e,t,r,n);case V.Tag:{if(e.namespace!=null)throw new Error("Namespaced tag names are not yet supported by css-select");let{name:u}=e;return(!t.xmlMode||t.lowerCaseTags)&&(u=u.toLowerCase()),function(c){return s.getName(c)===u&&A(c)}}case V.Descendant:{if(t.cacheResults===!1||typeof WeakSet>"u")return function(c){let f=c;for(;f=vs(f,s);)if(A(f))return!0;return!1};const u=new WeakSet;return function(c){let f=c;for(;f=vs(f,s);)if(!u.has(f)){if(s.isTag(f)&&A(f))return!0;u.add(f)}return!1}}case"_flexibleDescendant":return function(o){let c=o;do if(A(c))return!0;while(c=vs(c,s));return!1};case V.Parent:return function(o){return s.getChildren(o).some(c=>s.isTag(c)&&A(c))};case V.Child:return function(o){const c=s.getParent(o);return c!=null&&s.isTag(c)&&A(c)};case V.Sibling:return function(o){const c=s.getSiblings(o);for(let f=0;f<c.length;f++){const h=c[f];if(a(o,h))break;if(s.isTag(h)&&A(h))return!0}return!1};case V.Adjacent:return s.prevElementSibling?function(o){const c=s.prevElementSibling(o);return c!=null&&A(c)}:function(o){const c=s.getSiblings(o);let f;for(let h=0;h<c.length;h++){const d=c[h];if(a(o,d))break;s.isTag(d)&&(f=d)}return!!f&&A(f)};case V.Universal:{if(e.namespace!=null&&e.namespace!=="*")throw new Error("Namespaced universal selectors are not yet supported by css-select");return A}}}function Zi(A){return A.type===V.Pseudo&&(A.name==="scope"||Array.isArray(A.data)&&A.data.some(e=>e.some(Zi)))}const xf={type:V.Descendant},Df={type:"_flexibleDescendant"},Of={type:V.Pseudo,name:"scope",data:null};function Rf(A,{adapter:e},t){const r=!!(t!=null&&t.every(n=>{const s=e.isTag(n)&&e.getParent(n);return n===qi||s&&e.isTag(s)}));for(const n of A){if(!(n.length>0&&Fs(n[0])&&n[0].type!==V.Descendant))if(r&&!n.some(Zi))n.unshift(xf);else continue;n.unshift(Of)}}function $i(A,e,t){var r;A.forEach(bf),t=(r=e.context)!==null&&r!==void 0?r:t;const n=Array.isArray(t),s=t&&(Array.isArray(t)?t:[t]);if(e.relativeSelector!==!1)Rf(A,e,s);else if(A.some(o=>o.length>0&&Fs(o[0])))throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");let a=!1;const u=A.map(o=>{if(o.length>=2){const[c,f]=o;c.type!==V.Pseudo||c.name!=="scope"||(n&&f.type===V.Descendant?o[1]=Df:(f.type===V.Adjacent||f.type===V.Sibling)&&(a=!0))}return Mf(o,e,s)}).reduce(kf,J.falseFunc);return u.shouldTestNextSiblings=a,u}function Mf(A,e,t){var r;return A.reduce((n,s)=>n===J.falseFunc?J.falseFunc:Hf(n,s,e,t,$i),(r=e.rootFunc)!==null&&r!==void 0?r:J.trueFunc)}function kf(A,e){return e===J.falseFunc||A===J.trueFunc?A:A===J.falseFunc||e===J.trueFunc?e:function(r){return A(r)||e(r)}}const zi=(A,e)=>A===e,Pf={adapter:kr,equals:zi};function Kf(A){var e,t,r,n;const s=A??Pf;return(e=s.adapter)!==null&&e!==void 0||(s.adapter=kr),(t=s.equals)!==null&&t!==void 0||(s.equals=(n=(r=s.adapter)===null||r===void 0?void 0:r.equals)!==null&&n!==void 0?n:zi),s}function Vf(A){return function(t,r,n){const s=Kf(r);return A(t,s,n)}}const Ls=Vf($i);function Au(A,e,t=!1){return t&&(A=Gf(A,e)),Array.isArray(A)?e.removeSubsets(A):e.getChildren(A)}function Gf(A,e){const t=Array.isArray(A)?A.slice(0):[A],r=t.length;for(let n=0;n<r;n++){const s=ji(t[n],e);t.push(...s)}return t}const Yf=new Set(["first","last","eq","gt","nth","lt","even","odd"]);function Wr(A){return A.type!=="pseudo"?!1:Yf.has(A.name)?!0:A.name==="not"&&Array.isArray(A.data)?A.data.some(e=>e.some(Wr)):!1}function Xf(A,e,t){const r=e!=null?parseInt(e,10):NaN;switch(A){case"first":return 1;case"nth":case"eq":return isFinite(r)?r>=0?r+1:1/0:0;case"lt":return isFinite(r)?r>=0?Math.min(r,t):1/0:0;case"gt":return isFinite(r)?1/0:0;case"odd":return 2*t;case"even":return 2*t-1;case"last":case"not":return 1/0}}function Wf(A){for(;A.parent;)A=A.parent;return A}function Hs(A){const e=[],t=[];for(const r of A)r.some(Wr)?e.push(r):t.push(r);return[t,e]}const Jf={type:V.Universal,namespace:null},qf={type:V.Pseudo,name:"scope",data:null};function eu(A,e,t={}){return tu([A],e,t)}function tu(A,e,t={}){if(typeof e=="function")return A.some(e);const[r,n]=Hs(Vr(e));return r.length>0&&A.some(Ls(r,t))||n.some(s=>su(s,A,t).length>0)}function jf(A,e,t,r){const n=typeof t=="string"?parseInt(t,10):NaN;switch(A){case"first":case"lt":return e;case"last":return e.length>0?[e[e.length-1]]:e;case"nth":case"eq":return isFinite(n)&&Math.abs(n)<e.length?[n<0?e[e.length+n]:e[n]]:[];case"gt":return isFinite(n)?e.slice(n+1):[];case"even":return e.filter((s,a)=>a%2===0);case"odd":return e.filter((s,a)=>a%2===1);case"not":{const s=new Set(nu(t,e,r));return e.filter(a=>!s.has(a))}}}function ru(A,e,t={}){return nu(Vr(A),e,t)}function nu(A,e,t){if(e.length===0)return[];const[r,n]=Hs(A);let s;if(r.length){const a=Ds(e,r,t);if(n.length===0)return a;a.length&&(s=new Set(a))}for(let a=0;a<n.length&&(s==null?void 0:s.size)!==e.length;a++){const u=n[a];if((s?e.filter(f=>X(f)&&!s.has(f)):e).length===0)break;const c=su(u,e,t);if(c.length)if(s)c.forEach(f=>s.add(f));else{if(a===n.length-1)return c;s=new Set(c)}}return typeof s<"u"?s.size===e.length?e:e.filter(a=>s.has(a)):[]}function su(A,e,t){var r;if(A.some(Pt)){const n=(r=t.root)!==null&&r!==void 0?r:Wf(e[0]),s={...t,context:e,relativeSelector:!1};return A.push(qf),Jr(n,A,s,!0,e.length)}return Jr(e,A,t,!1,e.length)}function Zf(A,e,t={},r=1/0){if(typeof A=="function")return au(e,A);const[n,s]=Hs(Vr(A)),a=s.map(u=>Jr(e,u,t,!0,r));return n.length&&a.push(xs(e,n,t,r)),a.length===0?[]:a.length===1?a[0]:ht(a.reduce((u,o)=>[...u,...o]))}function Jr(A,e,t,r,n){const s=e.findIndex(Wr),a=e.slice(0,s),u=e[s],o=e.length-1===s?n:1/0,c=Xf(u.name,u.data,o);if(c===0)return[];const h=(a.length===0&&!Array.isArray(A)?Dr(A).filter(X):a.length===0?(Array.isArray(A)?A:[A]).filter(X):r||a.some(Pt)?xs(A,[a],t,c):Ds(A,[a],t)).slice(0,c);let d=jf(u.name,h,u.data,t);if(d.length===0||e.length===s+1)return d;const C=e.slice(s+1),m=C.some(Pt);if(m){if(Pt(C[0])){const{type:T}=C[0];(T===V.Sibling||T===V.Adjacent)&&(d=Au(d,kr,!0)),C.unshift(Jf)}t={...t,relativeSelector:!1,rootFunc:T=>d.includes(T)}}else t.rootFunc&&t.rootFunc!==Gr.trueFunc&&(t={...t,rootFunc:Gr.trueFunc});return C.some(Wr)?Jr(d,C,t,!1,n):m?xs(d,[C],t,n):Ds(d,[C],t)}function xs(A,e,t,r){const n=Ls(e,t,A);return au(A,n,r)}function au(A,e,t=1/0){const r=Au(A,kr,e.shouldTestNextSiblings);return ps(n=>X(n)&&e(n),r,!0,t)}function Ds(A,e,t){const r=(Array.isArray(A)?A:[A]).filter(X);if(r.length===0)return r;const n=Ls(e,t);return n===Gr.trueFunc?r:r.filter(n)}const $f=/^\s*[+~]/;function zf(A){if(!A)return this._make([]);if(typeof A!="string"){const e=Ce(A)?A.toArray():[A],t=this.toArray();return this._make(e.filter(r=>t.some(n=>Si(n,r))))}return this._findBySelector(A,Number.POSITIVE_INFINITY)}function Ah(A,e){var t;const r=this.toArray(),n=$f.test(A)?r:this.children().toArray(),s={context:r,root:(t=this._root)===null||t===void 0?void 0:t[0],xmlMode:this.options.xmlMode,lowerCaseTags:this.options.lowerCaseTags,lowerCaseAttributeNames:this.options.lowerCaseAttributeNames,pseudos:this.options.pseudos,quirksMode:this.options.quirksMode};return this._make(Zf(A,n,s,e))}function Os(A){return function(e,...t){return function(r){var n;let s=A(e,this);return r&&(s=ks(s,r,this.options.xmlMode,(n=this._root)===null||n===void 0?void 0:n[0])),this._make(this.length>1&&s.length>1?t.reduce((a,u)=>u(a),s):s)}}}const Vt=Os((A,e)=>{let t=[];for(let r=0;r<e.length;r++){const n=A(e[r]);n.length>0&&(t=t.concat(n))}return t}),Rs=Os((A,e)=>{const t=[];for(let r=0;r<e.length;r++){const n=A(e[r]);n!==null&&t.push(n)}return t});function Ms(A,...e){let t=null;const r=Os((n,s)=>{const a=[];return gA(s,u=>{for(let o;(o=n(u))&&!(t!=null&&t(o,a.length));u=o)a.push(o)}),a})(A,...e);return function(n,s){t=typeof n=="string"?u=>eu(u,n,this.options):n?Gt(n):null;const a=r.call(this,s);return t=null,a}}function Bt(A){return A.length>1?Array.from(new Set(A)):A}const eh=Rs(({parent:A})=>A&&!_e(A)?A:null,Bt),th=Vt(A=>{const e=[];for(;A.parent&&!_e(A.parent);)e.push(A.parent),A=A.parent;return e},ht,A=>A.reverse()),rh=Ms(({parent:A})=>A&&!_e(A)?A:null,ht,A=>A.reverse());function nh(A){var e;const t=[];if(!A)return this._make(t);const r={xmlMode:this.options.xmlMode,root:(e=this._root)===null||e===void 0?void 0:e[0]},n=typeof A=="string"?s=>eu(s,A,r):Gt(A);return gA(this,s=>{for(s&&!_e(s)&&!X(s)&&(s=s.parent);s&&X(s);){if(n(s,0)){t.includes(s)||t.push(s);break}s=s.parent}}),this._make(t)}const sh=Rs(A=>gs(A)),ah=Vt(A=>{const e=[];for(;A.next;)A=A.next,X(A)&&e.push(A);return e},Bt),ih=Ms(A=>gs(A),Bt),uh=Rs(A=>Es(A)),oh=Vt(A=>{const e=[];for(;A.prev;)A=A.prev,X(A)&&e.push(A);return e},Bt),ch=Ms(A=>Es(A),Bt),lh=Vt(A=>Ui(A).filter(e=>X(e)&&e!==A),ht),fh=Vt(A=>Dr(A).filter(X),Bt);function hh(){const A=this.toArray().reduce((e,t)=>FA(t)?e.concat(t.children):e,[]);return this._make(A)}function dh(A){let e=0;const t=this.length;for(;e<t&&A.call(this[e],e,this[e])!==!1;)++e;return this}function Bh(A){let e=[];for(let t=0;t<this.length;t++){const r=this[t],n=A.call(r,t,r);n!=null&&(e=e.concat(n))}return this._make(e)}function Gt(A){return typeof A=="function"?(e,t)=>A.call(e,t,e):Ce(A)?e=>Array.prototype.includes.call(A,e):function(e){return A===e}}function gh(A){var e;return this._make(ks(this.toArray(),A,this.options.xmlMode,(e=this._root)===null||e===void 0?void 0:e[0]))}function ks(A,e,t,r){return typeof e=="string"?ru(e,A,{xmlMode:t,root:r}):A.filter(Gt(e))}function Eh(A){const e=this.toArray();return typeof A=="string"?tu(e.filter(X),A,this.options):A?e.some(Gt(A)):!1}function ph(A){let e=this.toArray();if(typeof A=="string"){const t=new Set(ru(A,e,this.options));e=e.filter(r=>!t.has(r))}else{const t=Gt(A);e=e.filter((r,n)=>!t(r,n))}return this._make(e)}function mh(A){return this.filter(typeof A=="string"?`:has(${A})`:(e,t)=>this._make(t).find(A).length>0)}function Ch(){return this.length>1?this._make(this[0]):this}function wh(){return this.length>0?this._make(this[this.length-1]):this}function Th(A){var e;return A=+A,A===0&&this.length<=1?this:(A<0&&(A=this.length+A),this._make((e=this[A])!==null&&e!==void 0?e:[]))}function bh(A){return A==null?this.toArray():this[A<0?this.length+A:A]}function Uh(){return Array.prototype.slice.call(this)}function Qh(A){let e,t;return A==null?(e=this.parent().children(),t=this[0]):typeof A=="string"?(e=this._make(A),t=this[0]):(e=this,t=Ce(A)?A[0]:A),Array.prototype.indexOf.call(e,t)}function Fh(A,e){return this._make(Array.prototype.slice.call(this,A,e))}function Ih(){var A;return(A=this.prevObject)!==null&&A!==void 0?A:this._make([])}function _h(A,e){const t=this._make(A,e),r=ht([...this.get(),...t.get()]);return this._make(r)}function yh(A){return this.prevObject?this.add(A?this.prevObject.filter(A):this.prevObject):this}const Nh=Object.freeze(Object.defineProperty({__proto__:null,_findBySelector:Ah,add:_h,addBack:yh,children:fh,closest:nh,contents:hh,each:dh,end:Ih,eq:Th,filter:gh,filterArray:ks,find:zf,first:Ch,get:bh,has:mh,index:Qh,is:Eh,last:wh,map:Bh,next:sh,nextAll:ah,nextUntil:ih,not:ph,parent:eh,parents:th,parentsUntil:rh,prev:uh,prevAll:oh,prevUntil:ch,siblings:lh,slice:Fh,toArray:Uh},Symbol.toStringTag,{value:"Module"}));function Sh(A){return function(t,r,n,s){if(typeof Buffer<"u"&&Buffer.isBuffer(t)&&(t=t.toString()),typeof t=="string")return A(t,r,n,s);const a=t;if(!Array.isArray(a)&&_e(a))return a;const u=new Je([]);return $e(a,u),u}}function $e(A,e){const t=Array.isArray(A)?A:[A];e?e.children=t:e=null;for(let r=0;r<t.length;r++){const n=t[r];n.parent&&n.parent.children!==t&&qe(n),e?(n.prev=t[r-1]||null,n.next=t[r+1]||null):n.prev=n.next=null,n.parent=e}return e}function vh(A,e){if(A==null)return[];if(typeof A=="string")return this._parse(A,this.options,!1,null).children.slice(0);if("length"in A){if(A.length===1)return this._makeDomArray(A[0],e);const t=[];for(let r=0;r<A.length;r++){const n=A[r];if(typeof n=="object"){if(n==null)continue;if(!("length"in n)){t.push(e?Ot(n,!0):n);continue}}t.push(...this._makeDomArray(n,e))}return t}return[e?Ot(A,!0):A]}function iu(A){return function(...e){const t=this.length-1;return gA(this,(r,n)=>{if(!FA(r))return;const s=typeof e[0]=="function"?e[0].call(r,n,this._render(r.children)):e,a=this._makeDomArray(s,n<t);A(a,r.children,r)})}}function Se(A,e,t,r,n){var s,a;const u=[e,t,...r],o=e===0?null:A[e-1],c=e+t>=A.length?null:A[e+t];for(let f=0;f<r.length;++f){const h=r[f],d=h.parent;if(d){const m=d.children.indexOf(h);m>-1&&(d.children.splice(m,1),n===d&&e>m&&u[0]--)}h.parent=n,h.prev&&(h.prev.next=(s=h.next)!==null&&s!==void 0?s:null),h.next&&(h.next.prev=(a=h.prev)!==null&&a!==void 0?a:null),h.prev=f===0?o:r[f-1],h.next=f===r.length-1?c:r[f+1]}return o&&(o.next=r[0]),c&&(c.prev=r[r.length-1]),A.splice(...u)}function Lh(A){return(Ce(A)?A:this._make(A)).append(this),this}function Hh(A){return(Ce(A)?A:this._make(A)).prepend(this),this}const xh=iu((A,e,t)=>{Se(e,e.length,0,A,t)}),Dh=iu((A,e,t)=>{Se(e,0,0,A,t)});function uu(A){return function(e){const t=this.length-1,r=this.parents().last();for(let n=0;n<this.length;n++){const s=this[n],a=typeof e=="function"?e.call(s,n,s):typeof e=="string"&&!ws(e)?r.find(e).clone():e,[u]=this._makeDomArray(a,n<t);if(!u||!FA(u))continue;let o=u,c=0;for(;c<o.children.length;){const f=o.children[c];X(f)?(o=f,c=0):c++}A(s,o,[u])}return this}}const Oh=uu((A,e,t)=>{const{parent:r}=A;if(!r)return;const n=r.children,s=n.indexOf(A);$e([A],e),Se(n,s,0,t,r)}),Rh=uu((A,e,t)=>{FA(A)&&($e(A.children,e),$e(t,A))});function Mh(A){return this.parent(A).not("body").each((e,t)=>{this._make(t).replaceWith(t.children)}),this}function kh(A){const e=this[0];if(e){const t=this._make(typeof A=="function"?A.call(e,0,e):A).insertBefore(e);let r;for(let s=0;s<t.length;s++)t[s].type==="tag"&&(r=t[s]);let n=0;for(;r&&n<r.children.length;){const s=r.children[n];s.type==="tag"?(r=s,n=0):n++}r&&this._make(r).append(this)}return this}function Ph(...A){const e=this.length-1;return gA(this,(t,r)=>{if(!FA(t)||!t.parent)return;const n=t.parent.children,s=n.indexOf(t);if(s<0)return;const a=typeof A[0]=="function"?A[0].call(t,r,this._render(t.children)):A,u=this._makeDomArray(a,r<e);Se(n,s+1,0,u,t.parent)})}function Kh(A){typeof A=="string"&&(A=this._make(A)),this.remove();const e=[];for(const t of this._makeDomArray(A)){const r=this.clone().toArray(),{parent:n}=t;if(!n)continue;const s=n.children,a=s.indexOf(t);a<0||(Se(s,a+1,0,r,n),e.push(...r))}return this._make(e)}function Vh(...A){const e=this.length-1;return gA(this,(t,r)=>{if(!FA(t)||!t.parent)return;const n=t.parent.children,s=n.indexOf(t);if(s<0)return;const a=typeof A[0]=="function"?A[0].call(t,r,this._render(t.children)):A,u=this._makeDomArray(a,r<e);Se(n,s,0,u,t.parent)})}function Gh(A){const e=this._make(A);this.remove();const t=[];return gA(e,r=>{const n=this.clone().toArray(),{parent:s}=r;if(!s)return;const a=s.children,u=a.indexOf(r);u<0||(Se(a,u,0,n,s),t.push(...n))}),this._make(t)}function Yh(A){const e=A?this.filter(A):this;return gA(e,t=>{qe(t),t.prev=t.next=t.parent=null}),this}function Xh(A){return gA(this,(e,t)=>{const{parent:r}=e;if(!r)return;const n=r.children,s=typeof A=="function"?A.call(e,t,e):A,a=this._makeDomArray(s);$e(a,null);const u=n.indexOf(e);Se(n,u,1,a,r),a.includes(e)||(e.parent=e.prev=e.next=null)})}function Wh(){return gA(this,A=>{if(FA(A)){for(const e of A.children)e.next=e.prev=e.parent=null;A.children.length=0}})}function Jh(A){if(A===void 0){const e=this[0];return!e||!FA(e)?null:this._render(e.children)}return gA(this,e=>{if(!FA(e))return;for(const r of e.children)r.next=r.prev=r.parent=null;const t=Ce(A)?A.toArray():this._parse(`${A}`,this.options,!1,e).children;$e(t,e)})}function qh(){return this._render(this)}function jh(A){return A===void 0?Rt(this):typeof A=="function"?gA(this,(e,t)=>this._make(e).text(A.call(e,t,Rt([e])))):gA(this,e=>{if(!FA(e))return;for(const r of e.children)r.next=r.prev=r.parent=null;const t=new Dt(`${A}`);$e(t,e)})}function Zh(){const A=Array.prototype.map.call(this.get(),t=>Ot(t,!0)),e=new Je(A);for(const t of A)t.parent=e;return this._make(A)}const $h=Object.freeze(Object.defineProperty({__proto__:null,_makeDomArray:vh,after:Ph,append:xh,appendTo:Lh,before:Vh,clone:Zh,empty:Wh,html:Jh,insertAfter:Kh,insertBefore:Gh,prepend:Dh,prependTo:Hh,remove:Yh,replaceWith:Xh,text:jh,toString:qh,unwrap:Mh,wrap:Oh,wrapAll:kh,wrapInner:Rh},Symbol.toStringTag,{value:"Module"}));function zh(A,e){if(A!=null&&e!=null||typeof A=="object"&&!Array.isArray(A))return gA(this,(t,r)=>{X(t)&&ou(t,A,e,r)});if(this.length!==0)return cu(this[0],A)}function ou(A,e,t,r){if(typeof e=="string"){const n=cu(A),s=typeof t=="function"?t.call(A,r,n[e]):t;s===""?delete n[e]:s!=null&&(n[e]=s),A.attribs.style=Ad(n)}else if(typeof e=="object"){const n=Object.keys(e);for(let s=0;s<n.length;s++){const a=n[s];ou(A,a,e[a],s)}}}function cu(A,e){if(!A||!X(A))return;const t=ed(A.attribs.style);if(typeof e=="string")return t[e];if(Array.isArray(e)){const r={};for(const n of e)t[n]!=null&&(r[n]=t[n]);return r}return t}function Ad(A){return Object.keys(A).reduce((e,t)=>`${e}${e?" ":""}${t}: ${A[t]};`,"")}function ed(A){if(A=(A||"").trim(),!A)return{};const e={};let t;for(const r of A.split(";")){const n=r.indexOf(":");if(n<1||n===r.length-1){const s=r.trimEnd();s.length>0&&t!==void 0&&(e[t]+=`;${s}`)}else t=r.slice(0,n).trim(),e[t]=r.slice(n+1).trim()}return e}const td=Object.freeze(Object.defineProperty({__proto__:null,css:zh},Symbol.toStringTag,{value:"Module"})),lu="input,select,textarea,keygen",rd=/%20/g,fu=/\r?\n/g;function nd(){return this.serializeArray().map(t=>`${encodeURIComponent(t.name)}=${encodeURIComponent(t.value)}`).join("&").replace(rd,"+")}function sd(){return this.map((A,e)=>{const t=this._make(e);return X(e)&&e.name==="form"?t.find(lu).toArray():t.filter(lu).toArray()}).filter('[name!=""]:enabled:not(:submit, :button, :image, :reset, :file):matches([checked], :not(:checkbox, :radio))').map((A,e)=>{var t;const r=this._make(e),n=r.attr("name"),s=(t=r.val())!==null&&t!==void 0?t:"";return Array.isArray(s)?s.map(a=>({name:n,value:a.replace(fu,`\r
7
7
  `)})):{name:n,value:s.replace(fu,`\r
8
- `)}}).toArray()}const ad=Object.freeze(Object.defineProperty({__proto__:null,serialize:nd,serializeArray:sd},Symbol.toStringTag,{value:"Module"}));function id(A){var e;return typeof A=="string"?{selector:A,value:"textContent"}:{selector:A.selector,value:(e=A.value)!==null&&e!==void 0?e:"textContent"}}function ud(A){const e={};for(const t in A){const r=A[t],n=Array.isArray(r),{selector:s,value:a}=id(n?r[0]:r),u=typeof a=="function"?a:typeof a=="string"?o=>this._make(o).prop(a):o=>this._make(o).extract(a);if(n)e[t]=this._findBySelector(s,Number.POSITIVE_INFINITY).map((o,c)=>u(c,t,e)).get();else{const o=this._findBySelector(s,1);e[t]=o.length>0?u(o[0],t,e):void 0}}return e}const od=Object.freeze(Object.defineProperty({__proto__:null,extract:ud},Symbol.toStringTag,{value:"Module"}));class Yt{constructor(e,t,r){if(this.length=0,this.options=r,this._root=t,e){for(let n=0;n<e.length;n++)this[n]=e[n];this.length=e.length}}}Yt.prototype.cheerio="[cheerio object]",Yt.prototype.splice=Array.prototype.splice,Yt.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator],Object.assign(Yt.prototype,Bf,Nh,$h,td,ad,od);function cd(A,e){return function t(r,n,s=!0){if(r==null)throw new Error("cheerio.load() expects a string");const a=Cs(n),u=A(r,a,s,null);class o extends Yt{_make(h,d){const C=c(h,d);return C.prevObject=this,C}_parse(h,d,C,m){return A(h,d,C,m)}_render(h){return e(h,this.options)}}function c(f,h,d=u,C){if(f&&Ce(f))return f;const m=Cs(C,a),T=typeof d=="string"?[A(d,m,!1,null)]:"length"in d?d:[d],F=Ce(T)?T:new o(T,null,m);if(F._root=F,!f)return new o(void 0,F,m);const Q=typeof f=="string"&&ws(f)?A(f,m,!1,null).children:ld(f)?[f]:Array.isArray(f)?f:void 0,I=new o(Q,F,m);if(Q)return I;if(typeof f!="string")throw new TypeError("Unexpected type of selector");let H=f;const M=h?typeof h=="string"?ws(h)?new o([A(h,m,!1,null)],F,m):(H=`${h} ${H}`,F):Ce(h)?h:new o(Array.isArray(h)?h:[h],F,m):F;return M?M.find(H):I}return Object.assign(c,tf,{load:t,_root:u,_options:a,fn:o.prototype,prototype:o.prototype}),c}}function ld(A){return!!A.name||A.type==="root"||A.type==="text"||A.type==="comment"}const fd=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),fA="�";var B;(function(A){A[A.EOF=-1]="EOF",A[A.NULL=0]="NULL",A[A.TABULATION=9]="TABULATION",A[A.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",A[A.LINE_FEED=10]="LINE_FEED",A[A.FORM_FEED=12]="FORM_FEED",A[A.SPACE=32]="SPACE",A[A.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",A[A.QUOTATION_MARK=34]="QUOTATION_MARK",A[A.AMPERSAND=38]="AMPERSAND",A[A.APOSTROPHE=39]="APOSTROPHE",A[A.HYPHEN_MINUS=45]="HYPHEN_MINUS",A[A.SOLIDUS=47]="SOLIDUS",A[A.DIGIT_0=48]="DIGIT_0",A[A.DIGIT_9=57]="DIGIT_9",A[A.SEMICOLON=59]="SEMICOLON",A[A.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",A[A.EQUALS_SIGN=61]="EQUALS_SIGN",A[A.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",A[A.QUESTION_MARK=63]="QUESTION_MARK",A[A.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",A[A.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",A[A.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",A[A.GRAVE_ACCENT=96]="GRAVE_ACCENT",A[A.LATIN_SMALL_A=97]="LATIN_SMALL_A",A[A.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(B||(B={}));const VA={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function hu(A){return A>=55296&&A<=57343}function hd(A){return A>=56320&&A<=57343}function dd(A,e){return(A-55296)*1024+9216+e}function du(A){return A!==32&&A!==10&&A!==13&&A!==9&&A!==12&&A>=1&&A<=31||A>=127&&A<=159}function Bu(A){return A>=64976&&A<=65007||fd.has(A)}var b;(function(A){A.controlCharacterInInputStream="control-character-in-input-stream",A.noncharacterInInputStream="noncharacter-in-input-stream",A.surrogateInInputStream="surrogate-in-input-stream",A.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",A.endTagWithAttributes="end-tag-with-attributes",A.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",A.unexpectedSolidusInTag="unexpected-solidus-in-tag",A.unexpectedNullCharacter="unexpected-null-character",A.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",A.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",A.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",A.missingEndTagName="missing-end-tag-name",A.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",A.unknownNamedCharacterReference="unknown-named-character-reference",A.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",A.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",A.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",A.eofBeforeTagName="eof-before-tag-name",A.eofInTag="eof-in-tag",A.missingAttributeValue="missing-attribute-value",A.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",A.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",A.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",A.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",A.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",A.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",A.missingDoctypePublicIdentifier="missing-doctype-public-identifier",A.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",A.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",A.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",A.cdataInHtmlContent="cdata-in-html-content",A.incorrectlyOpenedComment="incorrectly-opened-comment",A.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",A.eofInDoctype="eof-in-doctype",A.nestedComment="nested-comment",A.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",A.eofInComment="eof-in-comment",A.incorrectlyClosedComment="incorrectly-closed-comment",A.eofInCdata="eof-in-cdata",A.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",A.nullCharacterReference="null-character-reference",A.surrogateCharacterReference="surrogate-character-reference",A.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",A.controlCharacterReference="control-character-reference",A.noncharacterCharacterReference="noncharacter-character-reference",A.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",A.missingDoctypeName="missing-doctype-name",A.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",A.duplicateAttribute="duplicate-attribute",A.nonConformingDoctype="non-conforming-doctype",A.missingDoctype="missing-doctype",A.misplacedDoctype="misplaced-doctype",A.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",A.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",A.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",A.openElementsLeftAfterEof="open-elements-left-after-eof",A.abandonedHeadElementChild="abandoned-head-element-child",A.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",A.nestedNoscriptInHead="nested-noscript-in-head",A.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(b||(b={}));const Bd=65536;class gd{constructor(e){this.handler=e,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=Bd,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(e,t){const{line:r,col:n,offset:s}=this,a=n+t,u=s+t;return{code:e,startLine:r,endLine:r,startCol:a,endCol:a,startOffset:u,endOffset:u}}_err(e){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(e,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(e){if(this.pos!==this.html.length-1){const t=this.html.charCodeAt(this.pos+1);if(hd(t))return this.pos++,this._addGap(),dd(e,t)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,B.EOF;return this._err(b.surrogateInInputStream),e}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(e,t){this.html.length>0?this.html+=e:this.html=e,this.endOfChunkHit=!1,this.lastChunkWritten=t}insertHtmlAtCurrentPos(e){this.html=this.html.substring(0,this.pos+1)+e+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(e,t){if(this.pos+e.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(t)return this.html.startsWith(e,this.pos);for(let r=0;r<e.length;r++)if((this.html.charCodeAt(this.pos+r)|32)!==e.charCodeAt(r))return!1;return!0}peek(e){const t=this.pos+e;if(t>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,B.EOF;const r=this.html.charCodeAt(t);return r===B.CARRIAGE_RETURN?B.LINE_FEED:r}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,B.EOF;let e=this.html.charCodeAt(this.pos);return e===B.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,B.LINE_FEED):e===B.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,hu(e)&&(e=this._processSurrogate(e)),this.handler.onParseError===null||e>31&&e<127||e===B.LINE_FEED||e===B.CARRIAGE_RETURN||e>159&&e<64976||this._checkForProblematicCharacters(e),e)}_checkForProblematicCharacters(e){du(e)?this._err(b.controlCharacterInInputStream):Bu(e)&&this._err(b.noncharacterInInputStream)}retreat(e){for(this.pos-=e;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var eA;(function(A){A[A.CHARACTER=0]="CHARACTER",A[A.NULL_CHARACTER=1]="NULL_CHARACTER",A[A.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",A[A.START_TAG=3]="START_TAG",A[A.END_TAG=4]="END_TAG",A[A.COMMENT=5]="COMMENT",A[A.DOCTYPE=6]="DOCTYPE",A[A.EOF=7]="EOF",A[A.HIBERNATION=8]="HIBERNATION"})(eA||(eA={}));function gu(A,e){for(let t=A.attrs.length-1;t>=0;t--)if(A.attrs[t].name===e)return A.attrs[t].value;return null}var U;(function(A){A.HTML="http://www.w3.org/1999/xhtml",A.MATHML="http://www.w3.org/1998/Math/MathML",A.SVG="http://www.w3.org/2000/svg",A.XLINK="http://www.w3.org/1999/xlink",A.XML="http://www.w3.org/XML/1998/namespace",A.XMLNS="http://www.w3.org/2000/xmlns/"})(U||(U={}));var ze;(function(A){A.TYPE="type",A.ACTION="action",A.ENCODING="encoding",A.PROMPT="prompt",A.NAME="name",A.COLOR="color",A.FACE="face",A.SIZE="size"})(ze||(ze={}));var qA;(function(A){A.NO_QUIRKS="no-quirks",A.QUIRKS="quirks",A.LIMITED_QUIRKS="limited-quirks"})(qA||(qA={}));var w;(function(A){A.A="a",A.ADDRESS="address",A.ANNOTATION_XML="annotation-xml",A.APPLET="applet",A.AREA="area",A.ARTICLE="article",A.ASIDE="aside",A.B="b",A.BASE="base",A.BASEFONT="basefont",A.BGSOUND="bgsound",A.BIG="big",A.BLOCKQUOTE="blockquote",A.BODY="body",A.BR="br",A.BUTTON="button",A.CAPTION="caption",A.CENTER="center",A.CODE="code",A.COL="col",A.COLGROUP="colgroup",A.DD="dd",A.DESC="desc",A.DETAILS="details",A.DIALOG="dialog",A.DIR="dir",A.DIV="div",A.DL="dl",A.DT="dt",A.EM="em",A.EMBED="embed",A.FIELDSET="fieldset",A.FIGCAPTION="figcaption",A.FIGURE="figure",A.FONT="font",A.FOOTER="footer",A.FOREIGN_OBJECT="foreignObject",A.FORM="form",A.FRAME="frame",A.FRAMESET="frameset",A.H1="h1",A.H2="h2",A.H3="h3",A.H4="h4",A.H5="h5",A.H6="h6",A.HEAD="head",A.HEADER="header",A.HGROUP="hgroup",A.HR="hr",A.HTML="html",A.I="i",A.IMG="img",A.IMAGE="image",A.INPUT="input",A.IFRAME="iframe",A.KEYGEN="keygen",A.LABEL="label",A.LI="li",A.LINK="link",A.LISTING="listing",A.MAIN="main",A.MALIGNMARK="malignmark",A.MARQUEE="marquee",A.MATH="math",A.MENU="menu",A.META="meta",A.MGLYPH="mglyph",A.MI="mi",A.MO="mo",A.MN="mn",A.MS="ms",A.MTEXT="mtext",A.NAV="nav",A.NOBR="nobr",A.NOFRAMES="noframes",A.NOEMBED="noembed",A.NOSCRIPT="noscript",A.OBJECT="object",A.OL="ol",A.OPTGROUP="optgroup",A.OPTION="option",A.P="p",A.PARAM="param",A.PLAINTEXT="plaintext",A.PRE="pre",A.RB="rb",A.RP="rp",A.RT="rt",A.RTC="rtc",A.RUBY="ruby",A.S="s",A.SCRIPT="script",A.SEARCH="search",A.SECTION="section",A.SELECT="select",A.SOURCE="source",A.SMALL="small",A.SPAN="span",A.STRIKE="strike",A.STRONG="strong",A.STYLE="style",A.SUB="sub",A.SUMMARY="summary",A.SUP="sup",A.TABLE="table",A.TBODY="tbody",A.TEMPLATE="template",A.TEXTAREA="textarea",A.TFOOT="tfoot",A.TD="td",A.TH="th",A.THEAD="thead",A.TITLE="title",A.TR="tr",A.TRACK="track",A.TT="tt",A.U="u",A.UL="ul",A.SVG="svg",A.VAR="var",A.WBR="wbr",A.XMP="xmp"})(w||(w={}));var i;(function(A){A[A.UNKNOWN=0]="UNKNOWN",A[A.A=1]="A",A[A.ADDRESS=2]="ADDRESS",A[A.ANNOTATION_XML=3]="ANNOTATION_XML",A[A.APPLET=4]="APPLET",A[A.AREA=5]="AREA",A[A.ARTICLE=6]="ARTICLE",A[A.ASIDE=7]="ASIDE",A[A.B=8]="B",A[A.BASE=9]="BASE",A[A.BASEFONT=10]="BASEFONT",A[A.BGSOUND=11]="BGSOUND",A[A.BIG=12]="BIG",A[A.BLOCKQUOTE=13]="BLOCKQUOTE",A[A.BODY=14]="BODY",A[A.BR=15]="BR",A[A.BUTTON=16]="BUTTON",A[A.CAPTION=17]="CAPTION",A[A.CENTER=18]="CENTER",A[A.CODE=19]="CODE",A[A.COL=20]="COL",A[A.COLGROUP=21]="COLGROUP",A[A.DD=22]="DD",A[A.DESC=23]="DESC",A[A.DETAILS=24]="DETAILS",A[A.DIALOG=25]="DIALOG",A[A.DIR=26]="DIR",A[A.DIV=27]="DIV",A[A.DL=28]="DL",A[A.DT=29]="DT",A[A.EM=30]="EM",A[A.EMBED=31]="EMBED",A[A.FIELDSET=32]="FIELDSET",A[A.FIGCAPTION=33]="FIGCAPTION",A[A.FIGURE=34]="FIGURE",A[A.FONT=35]="FONT",A[A.FOOTER=36]="FOOTER",A[A.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",A[A.FORM=38]="FORM",A[A.FRAME=39]="FRAME",A[A.FRAMESET=40]="FRAMESET",A[A.H1=41]="H1",A[A.H2=42]="H2",A[A.H3=43]="H3",A[A.H4=44]="H4",A[A.H5=45]="H5",A[A.H6=46]="H6",A[A.HEAD=47]="HEAD",A[A.HEADER=48]="HEADER",A[A.HGROUP=49]="HGROUP",A[A.HR=50]="HR",A[A.HTML=51]="HTML",A[A.I=52]="I",A[A.IMG=53]="IMG",A[A.IMAGE=54]="IMAGE",A[A.INPUT=55]="INPUT",A[A.IFRAME=56]="IFRAME",A[A.KEYGEN=57]="KEYGEN",A[A.LABEL=58]="LABEL",A[A.LI=59]="LI",A[A.LINK=60]="LINK",A[A.LISTING=61]="LISTING",A[A.MAIN=62]="MAIN",A[A.MALIGNMARK=63]="MALIGNMARK",A[A.MARQUEE=64]="MARQUEE",A[A.MATH=65]="MATH",A[A.MENU=66]="MENU",A[A.META=67]="META",A[A.MGLYPH=68]="MGLYPH",A[A.MI=69]="MI",A[A.MO=70]="MO",A[A.MN=71]="MN",A[A.MS=72]="MS",A[A.MTEXT=73]="MTEXT",A[A.NAV=74]="NAV",A[A.NOBR=75]="NOBR",A[A.NOFRAMES=76]="NOFRAMES",A[A.NOEMBED=77]="NOEMBED",A[A.NOSCRIPT=78]="NOSCRIPT",A[A.OBJECT=79]="OBJECT",A[A.OL=80]="OL",A[A.OPTGROUP=81]="OPTGROUP",A[A.OPTION=82]="OPTION",A[A.P=83]="P",A[A.PARAM=84]="PARAM",A[A.PLAINTEXT=85]="PLAINTEXT",A[A.PRE=86]="PRE",A[A.RB=87]="RB",A[A.RP=88]="RP",A[A.RT=89]="RT",A[A.RTC=90]="RTC",A[A.RUBY=91]="RUBY",A[A.S=92]="S",A[A.SCRIPT=93]="SCRIPT",A[A.SEARCH=94]="SEARCH",A[A.SECTION=95]="SECTION",A[A.SELECT=96]="SELECT",A[A.SOURCE=97]="SOURCE",A[A.SMALL=98]="SMALL",A[A.SPAN=99]="SPAN",A[A.STRIKE=100]="STRIKE",A[A.STRONG=101]="STRONG",A[A.STYLE=102]="STYLE",A[A.SUB=103]="SUB",A[A.SUMMARY=104]="SUMMARY",A[A.SUP=105]="SUP",A[A.TABLE=106]="TABLE",A[A.TBODY=107]="TBODY",A[A.TEMPLATE=108]="TEMPLATE",A[A.TEXTAREA=109]="TEXTAREA",A[A.TFOOT=110]="TFOOT",A[A.TD=111]="TD",A[A.TH=112]="TH",A[A.THEAD=113]="THEAD",A[A.TITLE=114]="TITLE",A[A.TR=115]="TR",A[A.TRACK=116]="TRACK",A[A.TT=117]="TT",A[A.U=118]="U",A[A.UL=119]="UL",A[A.SVG=120]="SVG",A[A.VAR=121]="VAR",A[A.WBR=122]="WBR",A[A.XMP=123]="XMP"})(i||(i={}));const Ed=new Map([[w.A,i.A],[w.ADDRESS,i.ADDRESS],[w.ANNOTATION_XML,i.ANNOTATION_XML],[w.APPLET,i.APPLET],[w.AREA,i.AREA],[w.ARTICLE,i.ARTICLE],[w.ASIDE,i.ASIDE],[w.B,i.B],[w.BASE,i.BASE],[w.BASEFONT,i.BASEFONT],[w.BGSOUND,i.BGSOUND],[w.BIG,i.BIG],[w.BLOCKQUOTE,i.BLOCKQUOTE],[w.BODY,i.BODY],[w.BR,i.BR],[w.BUTTON,i.BUTTON],[w.CAPTION,i.CAPTION],[w.CENTER,i.CENTER],[w.CODE,i.CODE],[w.COL,i.COL],[w.COLGROUP,i.COLGROUP],[w.DD,i.DD],[w.DESC,i.DESC],[w.DETAILS,i.DETAILS],[w.DIALOG,i.DIALOG],[w.DIR,i.DIR],[w.DIV,i.DIV],[w.DL,i.DL],[w.DT,i.DT],[w.EM,i.EM],[w.EMBED,i.EMBED],[w.FIELDSET,i.FIELDSET],[w.FIGCAPTION,i.FIGCAPTION],[w.FIGURE,i.FIGURE],[w.FONT,i.FONT],[w.FOOTER,i.FOOTER],[w.FOREIGN_OBJECT,i.FOREIGN_OBJECT],[w.FORM,i.FORM],[w.FRAME,i.FRAME],[w.FRAMESET,i.FRAMESET],[w.H1,i.H1],[w.H2,i.H2],[w.H3,i.H3],[w.H4,i.H4],[w.H5,i.H5],[w.H6,i.H6],[w.HEAD,i.HEAD],[w.HEADER,i.HEADER],[w.HGROUP,i.HGROUP],[w.HR,i.HR],[w.HTML,i.HTML],[w.I,i.I],[w.IMG,i.IMG],[w.IMAGE,i.IMAGE],[w.INPUT,i.INPUT],[w.IFRAME,i.IFRAME],[w.KEYGEN,i.KEYGEN],[w.LABEL,i.LABEL],[w.LI,i.LI],[w.LINK,i.LINK],[w.LISTING,i.LISTING],[w.MAIN,i.MAIN],[w.MALIGNMARK,i.MALIGNMARK],[w.MARQUEE,i.MARQUEE],[w.MATH,i.MATH],[w.MENU,i.MENU],[w.META,i.META],[w.MGLYPH,i.MGLYPH],[w.MI,i.MI],[w.MO,i.MO],[w.MN,i.MN],[w.MS,i.MS],[w.MTEXT,i.MTEXT],[w.NAV,i.NAV],[w.NOBR,i.NOBR],[w.NOFRAMES,i.NOFRAMES],[w.NOEMBED,i.NOEMBED],[w.NOSCRIPT,i.NOSCRIPT],[w.OBJECT,i.OBJECT],[w.OL,i.OL],[w.OPTGROUP,i.OPTGROUP],[w.OPTION,i.OPTION],[w.P,i.P],[w.PARAM,i.PARAM],[w.PLAINTEXT,i.PLAINTEXT],[w.PRE,i.PRE],[w.RB,i.RB],[w.RP,i.RP],[w.RT,i.RT],[w.RTC,i.RTC],[w.RUBY,i.RUBY],[w.S,i.S],[w.SCRIPT,i.SCRIPT],[w.SEARCH,i.SEARCH],[w.SECTION,i.SECTION],[w.SELECT,i.SELECT],[w.SOURCE,i.SOURCE],[w.SMALL,i.SMALL],[w.SPAN,i.SPAN],[w.STRIKE,i.STRIKE],[w.STRONG,i.STRONG],[w.STYLE,i.STYLE],[w.SUB,i.SUB],[w.SUMMARY,i.SUMMARY],[w.SUP,i.SUP],[w.TABLE,i.TABLE],[w.TBODY,i.TBODY],[w.TEMPLATE,i.TEMPLATE],[w.TEXTAREA,i.TEXTAREA],[w.TFOOT,i.TFOOT],[w.TD,i.TD],[w.TH,i.TH],[w.THEAD,i.THEAD],[w.TITLE,i.TITLE],[w.TR,i.TR],[w.TRACK,i.TRACK],[w.TT,i.TT],[w.U,i.U],[w.UL,i.UL],[w.SVG,i.SVG],[w.VAR,i.VAR],[w.WBR,i.WBR],[w.XMP,i.XMP]]);function qr(A){var e;return(e=Ed.get(A))!==null&&e!==void 0?e:i.UNKNOWN}const S=i,pd={[U.HTML]:new Set([S.ADDRESS,S.APPLET,S.AREA,S.ARTICLE,S.ASIDE,S.BASE,S.BASEFONT,S.BGSOUND,S.BLOCKQUOTE,S.BODY,S.BR,S.BUTTON,S.CAPTION,S.CENTER,S.COL,S.COLGROUP,S.DD,S.DETAILS,S.DIR,S.DIV,S.DL,S.DT,S.EMBED,S.FIELDSET,S.FIGCAPTION,S.FIGURE,S.FOOTER,S.FORM,S.FRAME,S.FRAMESET,S.H1,S.H2,S.H3,S.H4,S.H5,S.H6,S.HEAD,S.HEADER,S.HGROUP,S.HR,S.HTML,S.IFRAME,S.IMG,S.INPUT,S.LI,S.LINK,S.LISTING,S.MAIN,S.MARQUEE,S.MENU,S.META,S.NAV,S.NOEMBED,S.NOFRAMES,S.NOSCRIPT,S.OBJECT,S.OL,S.P,S.PARAM,S.PLAINTEXT,S.PRE,S.SCRIPT,S.SECTION,S.SELECT,S.SOURCE,S.STYLE,S.SUMMARY,S.TABLE,S.TBODY,S.TD,S.TEMPLATE,S.TEXTAREA,S.TFOOT,S.TH,S.THEAD,S.TITLE,S.TR,S.TRACK,S.UL,S.WBR,S.XMP]),[U.MATHML]:new Set([S.MI,S.MO,S.MN,S.MS,S.MTEXT,S.ANNOTATION_XML]),[U.SVG]:new Set([S.TITLE,S.FOREIGN_OBJECT,S.DESC]),[U.XLINK]:new Set,[U.XML]:new Set,[U.XMLNS]:new Set},Ps=new Set([S.H1,S.H2,S.H3,S.H4,S.H5,S.H6]),md=new Set([w.STYLE,w.SCRIPT,w.XMP,w.IFRAME,w.NOEMBED,w.NOFRAMES,w.PLAINTEXT]);function Cd(A,e){return md.has(A)||e&&A===w.NOSCRIPT}var g;(function(A){A[A.DATA=0]="DATA",A[A.RCDATA=1]="RCDATA",A[A.RAWTEXT=2]="RAWTEXT",A[A.SCRIPT_DATA=3]="SCRIPT_DATA",A[A.PLAINTEXT=4]="PLAINTEXT",A[A.TAG_OPEN=5]="TAG_OPEN",A[A.END_TAG_OPEN=6]="END_TAG_OPEN",A[A.TAG_NAME=7]="TAG_NAME",A[A.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",A[A.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",A[A.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",A[A.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",A[A.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",A[A.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",A[A.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",A[A.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",A[A.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",A[A.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",A[A.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",A[A.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",A[A.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",A[A.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",A[A.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",A[A.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",A[A.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",A[A.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",A[A.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",A[A.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",A[A.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",A[A.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",A[A.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",A[A.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",A[A.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",A[A.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",A[A.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",A[A.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",A[A.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",A[A.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",A[A.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",A[A.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",A[A.BOGUS_COMMENT=40]="BOGUS_COMMENT",A[A.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",A[A.COMMENT_START=42]="COMMENT_START",A[A.COMMENT_START_DASH=43]="COMMENT_START_DASH",A[A.COMMENT=44]="COMMENT",A[A.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",A[A.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",A[A.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",A[A.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",A[A.COMMENT_END_DASH=49]="COMMENT_END_DASH",A[A.COMMENT_END=50]="COMMENT_END",A[A.COMMENT_END_BANG=51]="COMMENT_END_BANG",A[A.DOCTYPE=52]="DOCTYPE",A[A.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",A[A.DOCTYPE_NAME=54]="DOCTYPE_NAME",A[A.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",A[A.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",A[A.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",A[A.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",A[A.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",A[A.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",A[A.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",A[A.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",A[A.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",A[A.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",A[A.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",A[A.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",A[A.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",A[A.CDATA_SECTION=68]="CDATA_SECTION",A[A.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",A[A.CDATA_SECTION_END=70]="CDATA_SECTION_END",A[A.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",A[A.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(g||(g={}));const GA={DATA:g.DATA,RCDATA:g.RCDATA,RAWTEXT:g.RAWTEXT,SCRIPT_DATA:g.SCRIPT_DATA,PLAINTEXT:g.PLAINTEXT,CDATA_SECTION:g.CDATA_SECTION};function wd(A){return A>=B.DIGIT_0&&A<=B.DIGIT_9}function Xt(A){return A>=B.LATIN_CAPITAL_A&&A<=B.LATIN_CAPITAL_Z}function Td(A){return A>=B.LATIN_SMALL_A&&A<=B.LATIN_SMALL_Z}function ve(A){return Td(A)||Xt(A)}function Eu(A){return ve(A)||wd(A)}function jr(A){return A+32}function pu(A){return A===B.SPACE||A===B.LINE_FEED||A===B.TABULATION||A===B.FORM_FEED}function mu(A){return pu(A)||A===B.SOLIDUS||A===B.GREATER_THAN_SIGN}function bd(A){return A===B.NULL?b.nullCharacterReference:A>1114111?b.characterReferenceOutsideUnicodeRange:hu(A)?b.surrogateCharacterReference:Bu(A)?b.noncharacterCharacterReference:du(A)||A===B.CARRIAGE_RETURN?b.controlCharacterReference:null}let Ud=class{constructor(e,t){this.options=e,this.handler=t,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=g.DATA,this.returnState=g.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new gd(t),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new Bs(ls,(r,n)=>{this.preprocessor.pos=this.entityStartPos+n-1,this._flushCodePointConsumedAsCharacterReference(r)},t.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(b.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:r=>{this._err(b.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+r)},validateNumericCharacterReference:r=>{const n=bd(r);n&&this._err(n,1)}}:void 0)}_err(e,t=0){var r,n;(n=(r=this.handler).onParseError)===null||n===void 0||n.call(r,this.preprocessor.getError(e,t))}getCurrentLocation(e){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-e,startOffset:this.preprocessor.offset-e,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const e=this._consume();this._ensureHibernation()||this._callState(e)}this.inLoop=!1}}pause(){this.paused=!0}resume(e){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||e==null||e())}write(e,t,r){this.active=!0,this.preprocessor.write(e,t),this._runParsingLoop(),this.paused||r==null||r()}insertHtmlAtCurrentPos(e){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(e),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(e){this.consumedAfterSnapshot+=e;for(let t=0;t<e;t++)this.preprocessor.advance()}_consumeSequenceIfMatch(e,t){return this.preprocessor.startsWith(e,t)?(this._advanceBy(e.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:eA.START_TAG,tagName:"",tagID:i.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:eA.END_TAG,tagName:"",tagID:i.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(e){this.currentToken={type:eA.COMMENT,data:"",location:this.getCurrentLocation(e)}}_createDoctypeToken(e){this.currentToken={type:eA.DOCTYPE,name:e,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(e,t){this.currentCharacterToken={type:e,chars:t,location:this.currentLocation}}_createAttr(e){this.currentAttr={name:e,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var e,t;const r=this.currentToken;if(gu(r,this.currentAttr.name)===null){if(r.attrs.push(this.currentAttr),r.location&&this.currentLocation){const n=(e=(t=r.location).attrs)!==null&&e!==void 0?e:t.attrs=Object.create(null);n[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(b.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(e){this._emitCurrentCharacterToken(e.location),this.currentToken=null,e.location&&(e.location.endLine=this.preprocessor.line,e.location.endCol=this.preprocessor.col+1,e.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const e=this.currentToken;this.prepareToken(e),e.tagID=qr(e.tagName),e.type===eA.START_TAG?(this.lastStartTagName=e.tagName,this.handler.onStartTag(e)):(e.attrs.length>0&&this._err(b.endTagWithAttributes),e.selfClosing&&this._err(b.endTagWithTrailingSolidus),this.handler.onEndTag(e)),this.preprocessor.dropParsedChunk()}emitCurrentComment(e){this.prepareToken(e),this.handler.onComment(e),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(e){this.prepareToken(e),this.handler.onDoctype(e),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(e){if(this.currentCharacterToken){switch(e&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=e.startLine,this.currentCharacterToken.location.endCol=e.startCol,this.currentCharacterToken.location.endOffset=e.startOffset),this.currentCharacterToken.type){case eA.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case eA.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case eA.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const e=this.getCurrentLocation(0);e&&(e.endLine=e.startLine,e.endCol=e.startCol,e.endOffset=e.startOffset),this._emitCurrentCharacterToken(e),this.handler.onEof({type:eA.EOF,location:e}),this.active=!1}_appendCharToCurrentCharacterToken(e,t){if(this.currentCharacterToken)if(this.currentCharacterToken.type===e){this.currentCharacterToken.chars+=t;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(e,t)}_emitCodePoint(e){const t=pu(e)?eA.WHITESPACE_CHARACTER:e===B.NULL?eA.NULL_CHARACTER:eA.CHARACTER;this._appendCharToCurrentCharacterToken(t,String.fromCodePoint(e))}_emitChars(e){this._appendCharToCurrentCharacterToken(eA.CHARACTER,e)}_startCharacterReference(){this.returnState=this.state,this.state=g.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?$A.Attribute:$A.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===g.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===g.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===g.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(e){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(e):this._emitCodePoint(e)}_callState(e){switch(this.state){case g.DATA:{this._stateData(e);break}case g.RCDATA:{this._stateRcdata(e);break}case g.RAWTEXT:{this._stateRawtext(e);break}case g.SCRIPT_DATA:{this._stateScriptData(e);break}case g.PLAINTEXT:{this._statePlaintext(e);break}case g.TAG_OPEN:{this._stateTagOpen(e);break}case g.END_TAG_OPEN:{this._stateEndTagOpen(e);break}case g.TAG_NAME:{this._stateTagName(e);break}case g.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(e);break}case g.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(e);break}case g.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(e);break}case g.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(e);break}case g.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(e);break}case g.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(e);break}case g.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(e);break}case g.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(e);break}case g.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(e);break}case g.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(e);break}case g.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(e);break}case g.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(e);break}case g.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(e);break}case g.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(e);break}case g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(e);break}case g.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(e);break}case g.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(e);break}case g.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(e);break}case g.ATTRIBUTE_NAME:{this._stateAttributeName(e);break}case g.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(e);break}case g.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(e);break}case g.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(e);break}case g.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(e);break}case g.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(e);break}case g.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(e);break}case g.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(e);break}case g.BOGUS_COMMENT:{this._stateBogusComment(e);break}case g.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(e);break}case g.COMMENT_START:{this._stateCommentStart(e);break}case g.COMMENT_START_DASH:{this._stateCommentStartDash(e);break}case g.COMMENT:{this._stateComment(e);break}case g.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(e);break}case g.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(e);break}case g.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(e);break}case g.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(e);break}case g.COMMENT_END_DASH:{this._stateCommentEndDash(e);break}case g.COMMENT_END:{this._stateCommentEnd(e);break}case g.COMMENT_END_BANG:{this._stateCommentEndBang(e);break}case g.DOCTYPE:{this._stateDoctype(e);break}case g.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(e);break}case g.DOCTYPE_NAME:{this._stateDoctypeName(e);break}case g.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(e);break}case g.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(e);break}case g.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(e);break}case g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(e);break}case g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(e);break}case g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(e);break}case g.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(e);break}case g.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(e);break}case g.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(e);break}case g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(e);break}case g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(e);break}case g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(e);break}case g.BOGUS_DOCTYPE:{this._stateBogusDoctype(e);break}case g.CDATA_SECTION:{this._stateCdataSection(e);break}case g.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(e);break}case g.CDATA_SECTION_END:{this._stateCdataSectionEnd(e);break}case g.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case g.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(e);break}default:throw new Error("Unknown state")}}_stateData(e){switch(e){case B.LESS_THAN_SIGN:{this.state=g.TAG_OPEN;break}case B.AMPERSAND:{this._startCharacterReference();break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitCodePoint(e);break}case B.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateRcdata(e){switch(e){case B.AMPERSAND:{this._startCharacterReference();break}case B.LESS_THAN_SIGN:{this.state=g.RCDATA_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateRawtext(e){switch(e){case B.LESS_THAN_SIGN:{this.state=g.RAWTEXT_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateScriptData(e){switch(e){case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(e)}}_statePlaintext(e){switch(e){case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateTagOpen(e){if(ve(e))this._createStartTagToken(),this.state=g.TAG_NAME,this._stateTagName(e);else switch(e){case B.EXCLAMATION_MARK:{this.state=g.MARKUP_DECLARATION_OPEN;break}case B.SOLIDUS:{this.state=g.END_TAG_OPEN;break}case B.QUESTION_MARK:{this._err(b.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=g.BOGUS_COMMENT,this._stateBogusComment(e);break}case B.EOF:{this._err(b.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(b.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=g.DATA,this._stateData(e)}}_stateEndTagOpen(e){if(ve(e))this._createEndTagToken(),this.state=g.TAG_NAME,this._stateTagName(e);else switch(e){case B.GREATER_THAN_SIGN:{this._err(b.missingEndTagName),this.state=g.DATA;break}case B.EOF:{this._err(b.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(b.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=g.BOGUS_COMMENT,this._stateBogusComment(e)}}_stateTagName(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.BEFORE_ATTRIBUTE_NAME;break}case B.SOLIDUS:{this.state=g.SELF_CLOSING_START_TAG;break}case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentTagToken();break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.tagName+=fA;break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:t.tagName+=String.fromCodePoint(Xt(e)?jr(e):e)}}_stateRcdataLessThanSign(e){e===B.SOLIDUS?this.state=g.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=g.RCDATA,this._stateRcdata(e))}_stateRcdataEndTagOpen(e){ve(e)?(this.state=g.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(e)):(this._emitChars("</"),this.state=g.RCDATA,this._stateRcdata(e))}handleSpecialEndTag(e){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const t=this.currentToken;switch(t.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=g.BEFORE_ATTRIBUTE_NAME,!1;case B.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=g.SELF_CLOSING_START_TAG,!1;case B.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=g.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=g.RCDATA,this._stateRcdata(e))}_stateRawtextLessThanSign(e){e===B.SOLIDUS?this.state=g.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=g.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagOpen(e){ve(e)?(this.state=g.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(e)):(this._emitChars("</"),this.state=g.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=g.RAWTEXT,this._stateRawtext(e))}_stateScriptDataLessThanSign(e){switch(e){case B.SOLIDUS:{this.state=g.SCRIPT_DATA_END_TAG_OPEN;break}case B.EXCLAMATION_MARK:{this.state=g.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=g.SCRIPT_DATA,this._stateScriptData(e)}}_stateScriptDataEndTagOpen(e){ve(e)?(this.state=g.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(e)):(this._emitChars("</"),this.state=g.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=g.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStart(e){e===B.HYPHEN_MINUS?(this.state=g.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=g.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStartDash(e){e===B.HYPHEN_MINUS?(this.state=g.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=g.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscaped(e){switch(e){case B.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateScriptDataEscapedDash(e){switch(e){case B.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_ESCAPED,this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedDashDash(e){switch(e){case B.HYPHEN_MINUS:{this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case B.GREATER_THAN_SIGN:{this.state=g.SCRIPT_DATA,this._emitChars(">");break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_ESCAPED,this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedLessThanSign(e){e===B.SOLIDUS?this.state=g.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:ve(e)?(this._emitChars("<"),this.state=g.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(e)):(this._emitChars("<"),this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagOpen(e){ve(e)?(this.state=g.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(e)):(this._emitChars("</"),this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscapeStart(e){if(this.preprocessor.startsWith(VA.SCRIPT,!1)&&mu(this.preprocessor.peek(VA.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<VA.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscaped(e){switch(e){case B.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDash(e){switch(e){case B.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDashDash(e){switch(e){case B.HYPHEN_MINUS:{this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case B.GREATER_THAN_SIGN:{this.state=g.SCRIPT_DATA,this._emitChars(">");break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedLessThanSign(e){e===B.SOLIDUS?(this.state=g.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateScriptDataDoubleEscapeEnd(e){if(this.preprocessor.startsWith(VA.SCRIPT,!1)&&mu(this.preprocessor.peek(VA.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<VA.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=g.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateBeforeAttributeName(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.SOLIDUS:case B.GREATER_THAN_SIGN:case B.EOF:{this.state=g.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break}case B.EQUALS_SIGN:{this._err(b.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=g.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=g.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateAttributeName(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:case B.SOLIDUS:case B.GREATER_THAN_SIGN:case B.EOF:{this._leaveAttrName(),this.state=g.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break}case B.EQUALS_SIGN:{this._leaveAttrName(),this.state=g.BEFORE_ATTRIBUTE_VALUE;break}case B.QUOTATION_MARK:case B.APOSTROPHE:case B.LESS_THAN_SIGN:{this._err(b.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(e);break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.currentAttr.name+=fA;break}default:this.currentAttr.name+=String.fromCodePoint(Xt(e)?jr(e):e)}}_stateAfterAttributeName(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.SOLIDUS:{this.state=g.SELF_CLOSING_START_TAG;break}case B.EQUALS_SIGN:{this.state=g.BEFORE_ATTRIBUTE_VALUE;break}case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentTagToken();break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=g.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateBeforeAttributeValue(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.QUOTATION_MARK:{this.state=g.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case B.APOSTROPHE:{this.state=g.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case B.GREATER_THAN_SIGN:{this._err(b.missingAttributeValue),this.state=g.DATA,this.emitCurrentTagToken();break}default:this.state=g.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(e)}}_stateAttributeValueDoubleQuoted(e){switch(e){case B.QUOTATION_MARK:{this.state=g.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case B.AMPERSAND:{this._startCharacterReference();break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.currentAttr.value+=fA;break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueSingleQuoted(e){switch(e){case B.APOSTROPHE:{this.state=g.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case B.AMPERSAND:{this._startCharacterReference();break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.currentAttr.value+=fA;break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueUnquoted(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this._leaveAttrValue(),this.state=g.BEFORE_ATTRIBUTE_NAME;break}case B.AMPERSAND:{this._startCharacterReference();break}case B.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=g.DATA,this.emitCurrentTagToken();break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.currentAttr.value+=fA;break}case B.QUOTATION_MARK:case B.APOSTROPHE:case B.LESS_THAN_SIGN:case B.EQUALS_SIGN:case B.GRAVE_ACCENT:{this._err(b.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(e);break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAfterAttributeValueQuoted(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this._leaveAttrValue(),this.state=g.BEFORE_ATTRIBUTE_NAME;break}case B.SOLIDUS:{this._leaveAttrValue(),this.state=g.SELF_CLOSING_START_TAG;break}case B.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=g.DATA,this.emitCurrentTagToken();break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this._err(b.missingWhitespaceBetweenAttributes),this.state=g.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateSelfClosingStartTag(e){switch(e){case B.GREATER_THAN_SIGN:{const t=this.currentToken;t.selfClosing=!0,this.state=g.DATA,this.emitCurrentTagToken();break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this._err(b.unexpectedSolidusInTag),this.state=g.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateBogusComment(e){const t=this.currentToken;switch(e){case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentComment(t);break}case B.EOF:{this.emitCurrentComment(t),this._emitEOFToken();break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.data+=fA;break}default:t.data+=String.fromCodePoint(e)}}_stateMarkupDeclarationOpen(e){this._consumeSequenceIfMatch(VA.DASH_DASH,!0)?(this._createCommentToken(VA.DASH_DASH.length+1),this.state=g.COMMENT_START):this._consumeSequenceIfMatch(VA.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(VA.DOCTYPE.length+1),this.state=g.DOCTYPE):this._consumeSequenceIfMatch(VA.CDATA_START,!0)?this.inForeignNode?this.state=g.CDATA_SECTION:(this._err(b.cdataInHtmlContent),this._createCommentToken(VA.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=g.BOGUS_COMMENT):this._ensureHibernation()||(this._err(b.incorrectlyOpenedComment),this._createCommentToken(2),this.state=g.BOGUS_COMMENT,this._stateBogusComment(e))}_stateCommentStart(e){switch(e){case B.HYPHEN_MINUS:{this.state=g.COMMENT_START_DASH;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptClosingOfEmptyComment),this.state=g.DATA;const t=this.currentToken;this.emitCurrentComment(t);break}default:this.state=g.COMMENT,this._stateComment(e)}}_stateCommentStartDash(e){const t=this.currentToken;switch(e){case B.HYPHEN_MINUS:{this.state=g.COMMENT_END;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptClosingOfEmptyComment),this.state=g.DATA,this.emitCurrentComment(t);break}case B.EOF:{this._err(b.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break}default:t.data+="-",this.state=g.COMMENT,this._stateComment(e)}}_stateComment(e){const t=this.currentToken;switch(e){case B.HYPHEN_MINUS:{this.state=g.COMMENT_END_DASH;break}case B.LESS_THAN_SIGN:{t.data+="<",this.state=g.COMMENT_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.data+=fA;break}case B.EOF:{this._err(b.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break}default:t.data+=String.fromCodePoint(e)}}_stateCommentLessThanSign(e){const t=this.currentToken;switch(e){case B.EXCLAMATION_MARK:{t.data+="!",this.state=g.COMMENT_LESS_THAN_SIGN_BANG;break}case B.LESS_THAN_SIGN:{t.data+="<";break}default:this.state=g.COMMENT,this._stateComment(e)}}_stateCommentLessThanSignBang(e){e===B.HYPHEN_MINUS?this.state=g.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=g.COMMENT,this._stateComment(e))}_stateCommentLessThanSignBangDash(e){e===B.HYPHEN_MINUS?this.state=g.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=g.COMMENT_END_DASH,this._stateCommentEndDash(e))}_stateCommentLessThanSignBangDashDash(e){e!==B.GREATER_THAN_SIGN&&e!==B.EOF&&this._err(b.nestedComment),this.state=g.COMMENT_END,this._stateCommentEnd(e)}_stateCommentEndDash(e){const t=this.currentToken;switch(e){case B.HYPHEN_MINUS:{this.state=g.COMMENT_END;break}case B.EOF:{this._err(b.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break}default:t.data+="-",this.state=g.COMMENT,this._stateComment(e)}}_stateCommentEnd(e){const t=this.currentToken;switch(e){case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentComment(t);break}case B.EXCLAMATION_MARK:{this.state=g.COMMENT_END_BANG;break}case B.HYPHEN_MINUS:{t.data+="-";break}case B.EOF:{this._err(b.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break}default:t.data+="--",this.state=g.COMMENT,this._stateComment(e)}}_stateCommentEndBang(e){const t=this.currentToken;switch(e){case B.HYPHEN_MINUS:{t.data+="--!",this.state=g.COMMENT_END_DASH;break}case B.GREATER_THAN_SIGN:{this._err(b.incorrectlyClosedComment),this.state=g.DATA,this.emitCurrentComment(t);break}case B.EOF:{this._err(b.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break}default:t.data+="--!",this.state=g.COMMENT,this._stateComment(e)}}_stateDoctype(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.BEFORE_DOCTYPE_NAME;break}case B.GREATER_THAN_SIGN:{this.state=g.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e);break}case B.EOF:{this._err(b.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingWhitespaceBeforeDoctypeName),this.state=g.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e)}}_stateBeforeDoctypeName(e){if(Xt(e))this._createDoctypeToken(String.fromCharCode(jr(e))),this.state=g.DOCTYPE_NAME;else switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.NULL:{this._err(b.unexpectedNullCharacter),this._createDoctypeToken(fA),this.state=g.DOCTYPE_NAME;break}case B.GREATER_THAN_SIGN:{this._err(b.missingDoctypeName),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(e)),this.state=g.DOCTYPE_NAME}}_stateDoctypeName(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.AFTER_DOCTYPE_NAME;break}case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.name+=fA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:t.name+=String.fromCodePoint(Xt(e)?jr(e):e)}}_stateAfterDoctypeName(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(VA.PUBLIC,!1)?this.state=g.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(VA.SYSTEM,!1)?this.state=g.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(b.invalidCharacterSequenceAfterDoctypeName),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e))}}_stateAfterDoctypePublicKeyword(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case B.QUOTATION_MARK:{this._err(b.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{this._err(b.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case B.GREATER_THAN_SIGN:{this._err(b.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.QUOTATION_MARK:{t.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{t.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case B.GREATER_THAN_SIGN:{this._err(b.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypePublicIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case B.QUOTATION_MARK:{this.state=g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.publicId+=fA;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:t.publicId+=String.fromCodePoint(e)}}_stateDoctypePublicIdentifierSingleQuoted(e){const t=this.currentToken;switch(e){case B.APOSTROPHE:{this.state=g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.publicId+=fA;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:t.publicId+=String.fromCodePoint(e)}}_stateAfterDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.QUOTATION_MARK:{this._err(b.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{this._err(b.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBetweenDoctypePublicAndSystemIdentifiers(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.GREATER_THAN_SIGN:{this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.QUOTATION_MARK:{t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateAfterDoctypeSystemKeyword(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case B.QUOTATION_MARK:{this._err(b.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{this._err(b.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case B.GREATER_THAN_SIGN:{this._err(b.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.QUOTATION_MARK:{t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case B.GREATER_THAN_SIGN:{this._err(b.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypeSystemIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case B.QUOTATION_MARK:{this.state=g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.systemId+=fA;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:t.systemId+=String.fromCodePoint(e)}}_stateDoctypeSystemIdentifierSingleQuoted(e){const t=this.currentToken;switch(e){case B.APOSTROPHE:{this.state=g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.systemId+=fA;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:t.systemId+=String.fromCodePoint(e)}}_stateAfterDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.GREATER_THAN_SIGN:{this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBogusDoctype(e){const t=this.currentToken;switch(e){case B.GREATER_THAN_SIGN:{this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.NULL:{this._err(b.unexpectedNullCharacter);break}case B.EOF:{this.emitCurrentDoctype(t),this._emitEOFToken();break}}}_stateCdataSection(e){switch(e){case B.RIGHT_SQUARE_BRACKET:{this.state=g.CDATA_SECTION_BRACKET;break}case B.EOF:{this._err(b.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateCdataSectionBracket(e){e===B.RIGHT_SQUARE_BRACKET?this.state=g.CDATA_SECTION_END:(this._emitChars("]"),this.state=g.CDATA_SECTION,this._stateCdataSection(e))}_stateCdataSectionEnd(e){switch(e){case B.GREATER_THAN_SIGN:{this.state=g.DATA;break}case B.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=g.CDATA_SECTION,this._stateCdataSection(e)}}_stateCharacterReference(){let e=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(e<0)if(this.preprocessor.lastChunkWritten)e=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}e===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(B.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&Eu(this.preprocessor.peek(1))?g.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(e){Eu(e)?this._flushCodePointConsumedAsCharacterReference(e):(e===B.SEMICOLON&&this._err(b.unknownNamedCharacterReference),this.state=this.returnState,this._callState(e))}};const Cu=new Set([i.DD,i.DT,i.LI,i.OPTGROUP,i.OPTION,i.P,i.RB,i.RP,i.RT,i.RTC]),wu=new Set([...Cu,i.CAPTION,i.COLGROUP,i.TBODY,i.TD,i.TFOOT,i.TH,i.THEAD,i.TR]),Zr=new Set([i.APPLET,i.CAPTION,i.HTML,i.MARQUEE,i.OBJECT,i.TABLE,i.TD,i.TEMPLATE,i.TH]),Qd=new Set([...Zr,i.OL,i.UL]),Fd=new Set([...Zr,i.BUTTON]),Tu=new Set([i.ANNOTATION_XML,i.MI,i.MN,i.MO,i.MS,i.MTEXT]),bu=new Set([i.DESC,i.FOREIGN_OBJECT,i.TITLE]),Id=new Set([i.TR,i.TEMPLATE,i.HTML]),_d=new Set([i.TBODY,i.TFOOT,i.THEAD,i.TEMPLATE,i.HTML]),yd=new Set([i.TABLE,i.TEMPLATE,i.HTML]),Nd=new Set([i.TD,i.TH]);class Sd{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(e,t,r){this.treeAdapter=t,this.handler=r,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=i.UNKNOWN,this.current=e}_indexOf(e){return this.items.lastIndexOf(e,this.stackTop)}_isInTemplate(){return this.currentTagId===i.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===U.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(e,t){this.stackTop++,this.items[this.stackTop]=e,this.current=e,this.tagIDs[this.stackTop]=t,this.currentTagId=t,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(e,t,!0)}pop(){const e=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!0)}replace(e,t){const r=this._indexOf(e);this.items[r]=t,r===this.stackTop&&(this.current=t)}insertAfter(e,t,r){const n=this._indexOf(e)+1;this.items.splice(n,0,t),this.tagIDs.splice(n,0,r),this.stackTop++,n===this.stackTop&&this._updateCurrentElement(),this.handler.onItemPush(this.current,this.currentTagId,n===this.stackTop)}popUntilTagNamePopped(e){let t=this.stackTop+1;do t=this.tagIDs.lastIndexOf(e,t-1);while(t>0&&this.treeAdapter.getNamespaceURI(this.items[t])!==U.HTML);this.shortenToLength(t<0?0:t)}shortenToLength(e){for(;this.stackTop>=e;){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,this.stackTop<e)}}popUntilElementPopped(e){const t=this._indexOf(e);this.shortenToLength(t<0?0:t)}popUntilPopped(e,t){const r=this._indexOfTagNames(e,t);this.shortenToLength(r<0?0:r)}popUntilNumberedHeaderPopped(){this.popUntilPopped(Ps,U.HTML)}popUntilTableCellPopped(){this.popUntilPopped(Nd,U.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(e,t){for(let r=this.stackTop;r>=0;r--)if(e.has(this.tagIDs[r])&&this.treeAdapter.getNamespaceURI(this.items[r])===t)return r;return-1}clearBackTo(e,t){const r=this._indexOfTagNames(e,t);this.shortenToLength(r+1)}clearBackToTableContext(){this.clearBackTo(yd,U.HTML)}clearBackToTableBodyContext(){this.clearBackTo(_d,U.HTML)}clearBackToTableRowContext(){this.clearBackTo(Id,U.HTML)}remove(e){const t=this._indexOf(e);t>=0&&(t===this.stackTop?this.pop():(this.items.splice(t,1),this.tagIDs.splice(t,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===i.BODY?this.items[1]:null}contains(e){return this._indexOf(e)>-1}getCommonAncestor(e){const t=this._indexOf(e)-1;return t>=0?this.items[t]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===i.HTML}hasInDynamicScope(e,t){for(let r=this.stackTop;r>=0;r--){const n=this.tagIDs[r];switch(this.treeAdapter.getNamespaceURI(this.items[r])){case U.HTML:{if(n===e)return!0;if(t.has(n))return!1;break}case U.SVG:{if(bu.has(n))return!1;break}case U.MATHML:{if(Tu.has(n))return!1;break}}}return!0}hasInScope(e){return this.hasInDynamicScope(e,Zr)}hasInListItemScope(e){return this.hasInDynamicScope(e,Qd)}hasInButtonScope(e){return this.hasInDynamicScope(e,Fd)}hasNumberedHeaderInScope(){for(let e=this.stackTop;e>=0;e--){const t=this.tagIDs[e];switch(this.treeAdapter.getNamespaceURI(this.items[e])){case U.HTML:{if(Ps.has(t))return!0;if(Zr.has(t))return!1;break}case U.SVG:{if(bu.has(t))return!1;break}case U.MATHML:{if(Tu.has(t))return!1;break}}}return!0}hasInTableScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===U.HTML)switch(this.tagIDs[t]){case e:return!0;case i.TABLE:case i.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let e=this.stackTop;e>=0;e--)if(this.treeAdapter.getNamespaceURI(this.items[e])===U.HTML)switch(this.tagIDs[e]){case i.TBODY:case i.THEAD:case i.TFOOT:return!0;case i.TABLE:case i.HTML:return!1}return!0}hasInSelectScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===U.HTML)switch(this.tagIDs[t]){case e:return!0;case i.OPTION:case i.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;Cu.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;wu.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(e){for(;this.currentTagId!==e&&wu.has(this.currentTagId);)this.pop()}}const Ks=3;var fe;(function(A){A[A.Marker=0]="Marker",A[A.Element=1]="Element"})(fe||(fe={}));const Uu={type:fe.Marker};class vd{constructor(e){this.treeAdapter=e,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(e,t){const r=[],n=t.length,s=this.treeAdapter.getTagName(e),a=this.treeAdapter.getNamespaceURI(e);for(let u=0;u<this.entries.length;u++){const o=this.entries[u];if(o.type===fe.Marker)break;const{element:c}=o;if(this.treeAdapter.getTagName(c)===s&&this.treeAdapter.getNamespaceURI(c)===a){const f=this.treeAdapter.getAttrList(c);f.length===n&&r.push({idx:u,attrs:f})}}return r}_ensureNoahArkCondition(e){if(this.entries.length<Ks)return;const t=this.treeAdapter.getAttrList(e),r=this._getNoahArkConditionCandidates(e,t);if(r.length<Ks)return;const n=new Map(t.map(a=>[a.name,a.value]));let s=0;for(let a=0;a<r.length;a++){const u=r[a];u.attrs.every(o=>n.get(o.name)===o.value)&&(s+=1,s>=Ks&&this.entries.splice(u.idx,1))}}insertMarker(){this.entries.unshift(Uu)}pushElement(e,t){this._ensureNoahArkCondition(e),this.entries.unshift({type:fe.Element,element:e,token:t})}insertElementAfterBookmark(e,t){const r=this.entries.indexOf(this.bookmark);this.entries.splice(r,0,{type:fe.Element,element:e,token:t})}removeEntry(e){const t=this.entries.indexOf(e);t>=0&&this.entries.splice(t,1)}clearToLastMarker(){const e=this.entries.indexOf(Uu);e>=0?this.entries.splice(0,e+1):this.entries.length=0}getElementEntryInScopeWithTagName(e){const t=this.entries.find(r=>r.type===fe.Marker||this.treeAdapter.getTagName(r.element)===e);return t&&t.type===fe.Element?t:null}getElementEntry(e){return this.entries.find(t=>t.type===fe.Element&&t.element===e)}}const we={createDocument(){return{nodeName:"#document",mode:qA.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(A,e,t){return{nodeName:A,tagName:A,attrs:t,namespaceURI:e,childNodes:[],parentNode:null}},createCommentNode(A){return{nodeName:"#comment",data:A,parentNode:null}},createTextNode(A){return{nodeName:"#text",value:A,parentNode:null}},appendChild(A,e){A.childNodes.push(e),e.parentNode=A},insertBefore(A,e,t){const r=A.childNodes.indexOf(t);A.childNodes.splice(r,0,e),e.parentNode=A},setTemplateContent(A,e){A.content=e},getTemplateContent(A){return A.content},setDocumentType(A,e,t,r){const n=A.childNodes.find(s=>s.nodeName==="#documentType");if(n)n.name=e,n.publicId=t,n.systemId=r;else{const s={nodeName:"#documentType",name:e,publicId:t,systemId:r,parentNode:null};we.appendChild(A,s)}},setDocumentMode(A,e){A.mode=e},getDocumentMode(A){return A.mode},detachNode(A){if(A.parentNode){const e=A.parentNode.childNodes.indexOf(A);A.parentNode.childNodes.splice(e,1),A.parentNode=null}},insertText(A,e){if(A.childNodes.length>0){const t=A.childNodes[A.childNodes.length-1];if(we.isTextNode(t)){t.value+=e;return}}we.appendChild(A,we.createTextNode(e))},insertTextBefore(A,e,t){const r=A.childNodes[A.childNodes.indexOf(t)-1];r&&we.isTextNode(r)?r.value+=e:we.insertBefore(A,we.createTextNode(e),t)},adoptAttributes(A,e){const t=new Set(A.attrs.map(r=>r.name));for(let r=0;r<e.length;r++)t.has(e[r].name)||A.attrs.push(e[r])},getFirstChild(A){return A.childNodes[0]},getChildNodes(A){return A.childNodes},getParentNode(A){return A.parentNode},getAttrList(A){return A.attrs},getTagName(A){return A.tagName},getNamespaceURI(A){return A.namespaceURI},getTextNodeContent(A){return A.value},getCommentNodeContent(A){return A.data},getDocumentTypeNodeName(A){return A.name},getDocumentTypeNodePublicId(A){return A.publicId},getDocumentTypeNodeSystemId(A){return A.systemId},isTextNode(A){return A.nodeName==="#text"},isCommentNode(A){return A.nodeName==="#comment"},isDocumentTypeNode(A){return A.nodeName==="#documentType"},isElementNode(A){return Object.prototype.hasOwnProperty.call(A,"tagName")},setNodeSourceCodeLocation(A,e){A.sourceCodeLocation=e},getNodeSourceCodeLocation(A){return A.sourceCodeLocation},updateNodeSourceCodeLocation(A,e){A.sourceCodeLocation={...A.sourceCodeLocation,...e}}},Qu="html",Ld="about:legacy-compat",Hd="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",Fu=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],xd=[...Fu,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],Dd=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),Iu=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],Od=[...Iu,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function _u(A,e){return e.some(t=>A.startsWith(t))}function Rd(A){return A.name===Qu&&A.publicId===null&&(A.systemId===null||A.systemId===Ld)}function Md(A){if(A.name!==Qu)return qA.QUIRKS;const{systemId:e}=A;if(e&&e.toLowerCase()===Hd)return qA.QUIRKS;let{publicId:t}=A;if(t!==null){if(t=t.toLowerCase(),Dd.has(t))return qA.QUIRKS;let r=e===null?xd:Fu;if(_u(t,r))return qA.QUIRKS;if(r=e===null?Iu:Od,_u(t,r))return qA.LIMITED_QUIRKS}return qA.NO_QUIRKS}const yu={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},kd="definitionurl",Pd="definitionURL",Kd=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(A=>[A.toLowerCase(),A])),Vd=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:U.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:U.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:U.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:U.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:U.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:U.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:U.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:U.XML}],["xml:space",{prefix:"xml",name:"space",namespace:U.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:U.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:U.XMLNS}]]),Gd=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(A=>[A.toLowerCase(),A])),Yd=new Set([i.B,i.BIG,i.BLOCKQUOTE,i.BODY,i.BR,i.CENTER,i.CODE,i.DD,i.DIV,i.DL,i.DT,i.EM,i.EMBED,i.H1,i.H2,i.H3,i.H4,i.H5,i.H6,i.HEAD,i.HR,i.I,i.IMG,i.LI,i.LISTING,i.MENU,i.META,i.NOBR,i.OL,i.P,i.PRE,i.RUBY,i.S,i.SMALL,i.SPAN,i.STRONG,i.STRIKE,i.SUB,i.SUP,i.TABLE,i.TT,i.U,i.UL,i.VAR]);function Xd(A){const e=A.tagID;return e===i.FONT&&A.attrs.some(({name:r})=>r===ze.COLOR||r===ze.SIZE||r===ze.FACE)||Yd.has(e)}function Nu(A){for(let e=0;e<A.attrs.length;e++)if(A.attrs[e].name===kd){A.attrs[e].name=Pd;break}}function Su(A){for(let e=0;e<A.attrs.length;e++){const t=Kd.get(A.attrs[e].name);t!=null&&(A.attrs[e].name=t)}}function Vs(A){for(let e=0;e<A.attrs.length;e++){const t=Vd.get(A.attrs[e].name);t&&(A.attrs[e].prefix=t.prefix,A.attrs[e].name=t.name,A.attrs[e].namespace=t.namespace)}}function Wd(A){const e=Gd.get(A.tagName);e!=null&&(A.tagName=e,A.tagID=qr(A.tagName))}function Jd(A,e){return e===U.MATHML&&(A===i.MI||A===i.MO||A===i.MN||A===i.MS||A===i.MTEXT)}function qd(A,e,t){if(e===U.MATHML&&A===i.ANNOTATION_XML){for(let r=0;r<t.length;r++)if(t[r].name===ze.ENCODING){const n=t[r].value.toLowerCase();return n===yu.TEXT_HTML||n===yu.APPLICATION_XML}}return e===U.SVG&&(A===i.FOREIGN_OBJECT||A===i.DESC||A===i.TITLE)}function jd(A,e,t,r){return(!r||r===U.HTML)&&qd(A,e,t)||(!r||r===U.MATHML)&&Jd(A,e)}const Zd="hidden",$d=8,zd=3;var E;(function(A){A[A.INITIAL=0]="INITIAL",A[A.BEFORE_HTML=1]="BEFORE_HTML",A[A.BEFORE_HEAD=2]="BEFORE_HEAD",A[A.IN_HEAD=3]="IN_HEAD",A[A.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",A[A.AFTER_HEAD=5]="AFTER_HEAD",A[A.IN_BODY=6]="IN_BODY",A[A.TEXT=7]="TEXT",A[A.IN_TABLE=8]="IN_TABLE",A[A.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",A[A.IN_CAPTION=10]="IN_CAPTION",A[A.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",A[A.IN_TABLE_BODY=12]="IN_TABLE_BODY",A[A.IN_ROW=13]="IN_ROW",A[A.IN_CELL=14]="IN_CELL",A[A.IN_SELECT=15]="IN_SELECT",A[A.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",A[A.IN_TEMPLATE=17]="IN_TEMPLATE",A[A.AFTER_BODY=18]="AFTER_BODY",A[A.IN_FRAMESET=19]="IN_FRAMESET",A[A.AFTER_FRAMESET=20]="AFTER_FRAMESET",A[A.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",A[A.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(E||(E={}));const AB={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},vu=new Set([i.TABLE,i.TBODY,i.TFOOT,i.THEAD,i.TR]),Lu={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:we,onParseError:null};let Hu=class{constructor(e,t,r=null,n=null){this.fragmentContext=r,this.scriptHandler=n,this.currentToken=null,this.stopped=!1,this.insertionMode=E.INITIAL,this.originalInsertionMode=E.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...Lu,...e},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=t??this.treeAdapter.createDocument(),this.tokenizer=new Ud(this.options,this),this.activeFormattingElements=new vd(this.treeAdapter),this.fragmentContextID=r?qr(this.treeAdapter.getTagName(r)):i.UNKNOWN,this._setContextModes(r??this.document,this.fragmentContextID),this.openElements=new Sd(this.document,this.treeAdapter,this)}static parse(e,t){const r=new this(t);return r.tokenizer.write(e,!0),r.document}static getFragmentParser(e,t){const r={...Lu,...t};e??(e=r.treeAdapter.createElement(w.TEMPLATE,U.HTML,[]));const n=r.treeAdapter.createElement("documentmock",U.HTML,[]),s=new this(r,n,e);return s.fragmentContextID===i.TEMPLATE&&s.tmplInsertionModeStack.unshift(E.IN_TEMPLATE),s._initTokenizerForFragmentParsing(),s._insertFakeRootElement(),s._resetInsertionMode(),s._findFormInFragmentContext(),s}getFragment(){const e=this.treeAdapter.getFirstChild(this.document),t=this.treeAdapter.createDocumentFragment();return this._adoptNodes(e,t),t}_err(e,t,r){var n;if(!this.onParseError)return;const s=(n=e.location)!==null&&n!==void 0?n:AB,a={code:t,startLine:s.startLine,startCol:s.startCol,startOffset:s.startOffset,endLine:r?s.startLine:s.endLine,endCol:r?s.startCol:s.endCol,endOffset:r?s.startOffset:s.endOffset};this.onParseError(a)}onItemPush(e,t,r){var n,s;(s=(n=this.treeAdapter).onItemPush)===null||s===void 0||s.call(n,e),r&&this.openElements.stackTop>0&&this._setContextModes(e,t)}onItemPop(e,t){var r,n;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(e,this.currentToken),(n=(r=this.treeAdapter).onItemPop)===null||n===void 0||n.call(r,e,this.openElements.current),t){let s,a;this.openElements.stackTop===0&&this.fragmentContext?(s=this.fragmentContext,a=this.fragmentContextID):{current:s,currentTagId:a}=this.openElements,this._setContextModes(s,a)}}_setContextModes(e,t){const r=e===this.document||this.treeAdapter.getNamespaceURI(e)===U.HTML;this.currentNotInHTML=!r,this.tokenizer.inForeignNode=!r&&!this._isIntegrationPoint(t,e)}_switchToTextParsing(e,t){this._insertElement(e,U.HTML),this.tokenizer.state=t,this.originalInsertionMode=this.insertionMode,this.insertionMode=E.TEXT}switchToPlaintextParsing(){this.insertionMode=E.TEXT,this.originalInsertionMode=E.IN_BODY,this.tokenizer.state=GA.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let e=this.fragmentContext;for(;e;){if(this.treeAdapter.getTagName(e)===w.FORM){this.formElement=e;break}e=this.treeAdapter.getParentNode(e)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==U.HTML))switch(this.fragmentContextID){case i.TITLE:case i.TEXTAREA:{this.tokenizer.state=GA.RCDATA;break}case i.STYLE:case i.XMP:case i.IFRAME:case i.NOEMBED:case i.NOFRAMES:case i.NOSCRIPT:{this.tokenizer.state=GA.RAWTEXT;break}case i.SCRIPT:{this.tokenizer.state=GA.SCRIPT_DATA;break}case i.PLAINTEXT:{this.tokenizer.state=GA.PLAINTEXT;break}}}_setDocumentType(e){const t=e.name||"",r=e.publicId||"",n=e.systemId||"";if(this.treeAdapter.setDocumentType(this.document,t,r,n),e.location){const a=this.treeAdapter.getChildNodes(this.document).find(u=>this.treeAdapter.isDocumentTypeNode(u));a&&this.treeAdapter.setNodeSourceCodeLocation(a,e.location)}}_attachElementToTree(e,t){if(this.options.sourceCodeLocationInfo){const r=t&&{...t,startTag:t};this.treeAdapter.setNodeSourceCodeLocation(e,r)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(e);else{const r=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(r,e)}}_appendElement(e,t){const r=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(r,e.location)}_insertElement(e,t){const r=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(r,e.location),this.openElements.push(r,e.tagID)}_insertFakeElement(e,t){const r=this.treeAdapter.createElement(e,U.HTML,[]);this._attachElementToTree(r,null),this.openElements.push(r,t)}_insertTemplate(e){const t=this.treeAdapter.createElement(e.tagName,U.HTML,e.attrs),r=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(t,r),this._attachElementToTree(t,e.location),this.openElements.push(t,e.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,null)}_insertFakeRootElement(){const e=this.treeAdapter.createElement(w.HTML,U.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(e,null),this.treeAdapter.appendChild(this.openElements.current,e),this.openElements.push(e,i.HTML)}_appendCommentNode(e,t){const r=this.treeAdapter.createCommentNode(e.data);this.treeAdapter.appendChild(t,r),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,e.location)}_insertCharacters(e){let t,r;if(this._shouldFosterParentOnInsertion()?({parent:t,beforeElement:r}=this._findFosterParentingLocation(),r?this.treeAdapter.insertTextBefore(t,e.chars,r):this.treeAdapter.insertText(t,e.chars)):(t=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(t,e.chars)),!e.location)return;const n=this.treeAdapter.getChildNodes(t),s=r?n.lastIndexOf(r):n.length,a=n[s-1];if(this.treeAdapter.getNodeSourceCodeLocation(a)){const{endLine:o,endCol:c,endOffset:f}=e.location;this.treeAdapter.updateNodeSourceCodeLocation(a,{endLine:o,endCol:c,endOffset:f})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,e.location)}_adoptNodes(e,t){for(let r=this.treeAdapter.getFirstChild(e);r;r=this.treeAdapter.getFirstChild(e))this.treeAdapter.detachNode(r),this.treeAdapter.appendChild(t,r)}_setEndLocation(e,t){if(this.treeAdapter.getNodeSourceCodeLocation(e)&&t.location){const r=t.location,n=this.treeAdapter.getTagName(e),s=t.type===eA.END_TAG&&n===t.tagName?{endTag:{...r},endLine:r.endLine,endCol:r.endCol,endOffset:r.endOffset}:{endLine:r.startLine,endCol:r.startCol,endOffset:r.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(e,s)}}shouldProcessStartTagTokenInForeignContent(e){if(!this.currentNotInHTML)return!1;let t,r;return this.openElements.stackTop===0&&this.fragmentContext?(t=this.fragmentContext,r=this.fragmentContextID):{current:t,currentTagId:r}=this.openElements,e.tagID===i.SVG&&this.treeAdapter.getTagName(t)===w.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(t)===U.MATHML?!1:this.tokenizer.inForeignNode||(e.tagID===i.MGLYPH||e.tagID===i.MALIGNMARK)&&!this._isIntegrationPoint(r,t,U.HTML)}_processToken(e){switch(e.type){case eA.CHARACTER:{this.onCharacter(e);break}case eA.NULL_CHARACTER:{this.onNullCharacter(e);break}case eA.COMMENT:{this.onComment(e);break}case eA.DOCTYPE:{this.onDoctype(e);break}case eA.START_TAG:{this._processStartTag(e);break}case eA.END_TAG:{this.onEndTag(e);break}case eA.EOF:{this.onEof(e);break}case eA.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(e);break}}}_isIntegrationPoint(e,t,r){const n=this.treeAdapter.getNamespaceURI(t),s=this.treeAdapter.getAttrList(t);return jd(e,n,s,r)}_reconstructActiveFormattingElements(){const e=this.activeFormattingElements.entries.length;if(e){const t=this.activeFormattingElements.entries.findIndex(n=>n.type===fe.Marker||this.openElements.contains(n.element)),r=t<0?e-1:t-1;for(let n=r;n>=0;n--){const s=this.activeFormattingElements.entries[n];this._insertElement(s.token,this.treeAdapter.getNamespaceURI(s.element)),s.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=E.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(i.P),this.openElements.popUntilTagNamePopped(i.P)}_resetInsertionMode(){for(let e=this.openElements.stackTop;e>=0;e--)switch(e===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[e]){case i.TR:{this.insertionMode=E.IN_ROW;return}case i.TBODY:case i.THEAD:case i.TFOOT:{this.insertionMode=E.IN_TABLE_BODY;return}case i.CAPTION:{this.insertionMode=E.IN_CAPTION;return}case i.COLGROUP:{this.insertionMode=E.IN_COLUMN_GROUP;return}case i.TABLE:{this.insertionMode=E.IN_TABLE;return}case i.BODY:{this.insertionMode=E.IN_BODY;return}case i.FRAMESET:{this.insertionMode=E.IN_FRAMESET;return}case i.SELECT:{this._resetInsertionModeForSelect(e);return}case i.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case i.HTML:{this.insertionMode=this.headElement?E.AFTER_HEAD:E.BEFORE_HEAD;return}case i.TD:case i.TH:{if(e>0){this.insertionMode=E.IN_CELL;return}break}case i.HEAD:{if(e>0){this.insertionMode=E.IN_HEAD;return}break}}this.insertionMode=E.IN_BODY}_resetInsertionModeForSelect(e){if(e>0)for(let t=e-1;t>0;t--){const r=this.openElements.tagIDs[t];if(r===i.TEMPLATE)break;if(r===i.TABLE){this.insertionMode=E.IN_SELECT_IN_TABLE;return}}this.insertionMode=E.IN_SELECT}_isElementCausesFosterParenting(e){return vu.has(e)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let e=this.openElements.stackTop;e>=0;e--){const t=this.openElements.items[e];switch(this.openElements.tagIDs[e]){case i.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(t)===U.HTML)return{parent:this.treeAdapter.getTemplateContent(t),beforeElement:null};break}case i.TABLE:{const r=this.treeAdapter.getParentNode(t);return r?{parent:r,beforeElement:t}:{parent:this.openElements.items[e-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(e){const t=this._findFosterParentingLocation();t.beforeElement?this.treeAdapter.insertBefore(t.parent,e,t.beforeElement):this.treeAdapter.appendChild(t.parent,e)}_isSpecialElement(e,t){const r=this.treeAdapter.getNamespaceURI(e);return pd[r].has(t)}onCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Ng(this,e);return}switch(this.insertionMode){case E.INITIAL:{Wt(this,e);break}case E.BEFORE_HTML:{Jt(this,e);break}case E.BEFORE_HEAD:{qt(this,e);break}case E.IN_HEAD:{jt(this,e);break}case E.IN_HEAD_NO_SCRIPT:{Zt(this,e);break}case E.AFTER_HEAD:{$t(this,e);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:{Du(this,e);break}case E.TEXT:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{this._insertCharacters(e);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Ws(this,e);break}case E.IN_TABLE_TEXT:{Gu(this,e);break}case E.IN_COLUMN_GROUP:{An(this,e);break}case E.AFTER_BODY:{rn(this,e);break}case E.AFTER_AFTER_BODY:{nn(this,e);break}}}onNullCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){yg(this,e);return}switch(this.insertionMode){case E.INITIAL:{Wt(this,e);break}case E.BEFORE_HTML:{Jt(this,e);break}case E.BEFORE_HEAD:{qt(this,e);break}case E.IN_HEAD:{jt(this,e);break}case E.IN_HEAD_NO_SCRIPT:{Zt(this,e);break}case E.AFTER_HEAD:{$t(this,e);break}case E.TEXT:{this._insertCharacters(e);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Ws(this,e);break}case E.IN_COLUMN_GROUP:{An(this,e);break}case E.AFTER_BODY:{rn(this,e);break}case E.AFTER_AFTER_BODY:{nn(this,e);break}}}onComment(e){if(this.skipNextNewLine=!1,this.currentNotInHTML){Ys(this,e);return}switch(this.insertionMode){case E.INITIAL:case E.BEFORE_HTML:case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_TEMPLATE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{Ys(this,e);break}case E.IN_TABLE_TEXT:{er(this,e);break}case E.AFTER_BODY:{iB(this,e);break}case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{uB(this,e);break}}}onDoctype(e){switch(this.skipNextNewLine=!1,this.insertionMode){case E.INITIAL:{oB(this,e);break}case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:{this._err(e,b.misplacedDoctype);break}case E.IN_TABLE_TEXT:{er(this,e);break}}}onStartTag(e){this.skipNextNewLine=!1,this.currentToken=e,this._processStartTag(e),e.selfClosing&&!e.ackSelfClosing&&this._err(e,b.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(e){this.shouldProcessStartTagTokenInForeignContent(e)?Sg(this,e):this._startTagOutsideForeignContent(e)}_startTagOutsideForeignContent(e){switch(this.insertionMode){case E.INITIAL:{Wt(this,e);break}case E.BEFORE_HTML:{cB(this,e);break}case E.BEFORE_HEAD:{fB(this,e);break}case E.IN_HEAD:{se(this,e);break}case E.IN_HEAD_NO_SCRIPT:{BB(this,e);break}case E.AFTER_HEAD:{EB(this,e);break}case E.IN_BODY:{xA(this,e);break}case E.IN_TABLE:{gt(this,e);break}case E.IN_TABLE_TEXT:{er(this,e);break}case E.IN_CAPTION:{hg(this,e);break}case E.IN_COLUMN_GROUP:{Js(this,e);break}case E.IN_TABLE_BODY:{en(this,e);break}case E.IN_ROW:{tn(this,e);break}case E.IN_CELL:{gg(this,e);break}case E.IN_SELECT:{Wu(this,e);break}case E.IN_SELECT_IN_TABLE:{pg(this,e);break}case E.IN_TEMPLATE:{Cg(this,e);break}case E.AFTER_BODY:{Tg(this,e);break}case E.IN_FRAMESET:{bg(this,e);break}case E.AFTER_FRAMESET:{Qg(this,e);break}case E.AFTER_AFTER_BODY:{Ig(this,e);break}case E.AFTER_AFTER_FRAMESET:{_g(this,e);break}}}onEndTag(e){this.skipNextNewLine=!1,this.currentToken=e,this.currentNotInHTML?vg(this,e):this._endTagOutsideForeignContent(e)}_endTagOutsideForeignContent(e){switch(this.insertionMode){case E.INITIAL:{Wt(this,e);break}case E.BEFORE_HTML:{lB(this,e);break}case E.BEFORE_HEAD:{hB(this,e);break}case E.IN_HEAD:{dB(this,e);break}case E.IN_HEAD_NO_SCRIPT:{gB(this,e);break}case E.AFTER_HEAD:{pB(this,e);break}case E.IN_BODY:{zr(this,e);break}case E.TEXT:{rg(this,e);break}case E.IN_TABLE:{zt(this,e);break}case E.IN_TABLE_TEXT:{er(this,e);break}case E.IN_CAPTION:{dg(this,e);break}case E.IN_COLUMN_GROUP:{Bg(this,e);break}case E.IN_TABLE_BODY:{qs(this,e);break}case E.IN_ROW:{Xu(this,e);break}case E.IN_CELL:{Eg(this,e);break}case E.IN_SELECT:{Ju(this,e);break}case E.IN_SELECT_IN_TABLE:{mg(this,e);break}case E.IN_TEMPLATE:{wg(this,e);break}case E.AFTER_BODY:{ju(this,e);break}case E.IN_FRAMESET:{Ug(this,e);break}case E.AFTER_FRAMESET:{Fg(this,e);break}case E.AFTER_AFTER_BODY:{nn(this,e);break}}}onEof(e){switch(this.insertionMode){case E.INITIAL:{Wt(this,e);break}case E.BEFORE_HTML:{Jt(this,e);break}case E.BEFORE_HEAD:{qt(this,e);break}case E.IN_HEAD:{jt(this,e);break}case E.IN_HEAD_NO_SCRIPT:{Zt(this,e);break}case E.AFTER_HEAD:{$t(this,e);break}case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{Ku(this,e);break}case E.TEXT:{ng(this,e);break}case E.IN_TABLE_TEXT:{er(this,e);break}case E.IN_TEMPLATE:{qu(this,e);break}case E.AFTER_BODY:case E.IN_FRAMESET:case E.AFTER_FRAMESET:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{Xs(this,e);break}}}onWhitespaceCharacter(e){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,e.chars.charCodeAt(0)===B.LINE_FEED)){if(e.chars.length===1)return;e.chars=e.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(e);return}switch(this.insertionMode){case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.TEXT:case E.IN_COLUMN_GROUP:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{this._insertCharacters(e);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:case E.AFTER_BODY:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{xu(this,e);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Ws(this,e);break}case E.IN_TABLE_TEXT:{Vu(this,e);break}}}};function eB(A,e){let t=A.activeFormattingElements.getElementEntryInScopeWithTagName(e.tagName);return t?A.openElements.contains(t.element)?A.openElements.hasInScope(e.tagID)||(t=null):(A.activeFormattingElements.removeEntry(t),t=null):Pu(A,e),t}function tB(A,e){let t=null,r=A.openElements.stackTop;for(;r>=0;r--){const n=A.openElements.items[r];if(n===e.element)break;A._isSpecialElement(n,A.openElements.tagIDs[r])&&(t=n)}return t||(A.openElements.shortenToLength(r<0?0:r),A.activeFormattingElements.removeEntry(e)),t}function rB(A,e,t){let r=e,n=A.openElements.getCommonAncestor(e);for(let s=0,a=n;a!==t;s++,a=n){n=A.openElements.getCommonAncestor(a);const u=A.activeFormattingElements.getElementEntry(a),o=u&&s>=zd;!u||o?(o&&A.activeFormattingElements.removeEntry(u),A.openElements.remove(a)):(a=nB(A,u),r===e&&(A.activeFormattingElements.bookmark=u),A.treeAdapter.detachNode(r),A.treeAdapter.appendChild(a,r),r=a)}return r}function nB(A,e){const t=A.treeAdapter.getNamespaceURI(e.element),r=A.treeAdapter.createElement(e.token.tagName,t,e.token.attrs);return A.openElements.replace(e.element,r),e.element=r,r}function sB(A,e,t){const r=A.treeAdapter.getTagName(e),n=qr(r);if(A._isElementCausesFosterParenting(n))A._fosterParentElement(t);else{const s=A.treeAdapter.getNamespaceURI(e);n===i.TEMPLATE&&s===U.HTML&&(e=A.treeAdapter.getTemplateContent(e)),A.treeAdapter.appendChild(e,t)}}function aB(A,e,t){const r=A.treeAdapter.getNamespaceURI(t.element),{token:n}=t,s=A.treeAdapter.createElement(n.tagName,r,n.attrs);A._adoptNodes(e,s),A.treeAdapter.appendChild(e,s),A.activeFormattingElements.insertElementAfterBookmark(s,n),A.activeFormattingElements.removeEntry(t),A.openElements.remove(t.element),A.openElements.insertAfter(e,s,n.tagID)}function Gs(A,e){for(let t=0;t<$d;t++){const r=eB(A,e);if(!r)break;const n=tB(A,r);if(!n)break;A.activeFormattingElements.bookmark=r;const s=rB(A,n,r.element),a=A.openElements.getCommonAncestor(r.element);A.treeAdapter.detachNode(s),a&&sB(A,a,s),aB(A,n,r)}}function Ys(A,e){A._appendCommentNode(e,A.openElements.currentTmplContentOrNode)}function iB(A,e){A._appendCommentNode(e,A.openElements.items[0])}function uB(A,e){A._appendCommentNode(e,A.document)}function Xs(A,e){if(A.stopped=!0,e.location){const t=A.fragmentContext?0:2;for(let r=A.openElements.stackTop;r>=t;r--)A._setEndLocation(A.openElements.items[r],e);if(!A.fragmentContext&&A.openElements.stackTop>=0){const r=A.openElements.items[0],n=A.treeAdapter.getNodeSourceCodeLocation(r);if(n&&!n.endTag&&(A._setEndLocation(r,e),A.openElements.stackTop>=1)){const s=A.openElements.items[1],a=A.treeAdapter.getNodeSourceCodeLocation(s);a&&!a.endTag&&A._setEndLocation(s,e)}}}}function oB(A,e){A._setDocumentType(e);const t=e.forceQuirks?qA.QUIRKS:Md(e);Rd(e)||A._err(e,b.nonConformingDoctype),A.treeAdapter.setDocumentMode(A.document,t),A.insertionMode=E.BEFORE_HTML}function Wt(A,e){A._err(e,b.missingDoctype,!0),A.treeAdapter.setDocumentMode(A.document,qA.QUIRKS),A.insertionMode=E.BEFORE_HTML,A._processToken(e)}function cB(A,e){e.tagID===i.HTML?(A._insertElement(e,U.HTML),A.insertionMode=E.BEFORE_HEAD):Jt(A,e)}function lB(A,e){const t=e.tagID;(t===i.HTML||t===i.HEAD||t===i.BODY||t===i.BR)&&Jt(A,e)}function Jt(A,e){A._insertFakeRootElement(),A.insertionMode=E.BEFORE_HEAD,A._processToken(e)}function fB(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.HEAD:{A._insertElement(e,U.HTML),A.headElement=A.openElements.current,A.insertionMode=E.IN_HEAD;break}default:qt(A,e)}}function hB(A,e){const t=e.tagID;t===i.HEAD||t===i.BODY||t===i.HTML||t===i.BR?qt(A,e):A._err(e,b.endTagWithoutMatchingOpenElement)}function qt(A,e){A._insertFakeElement(w.HEAD,i.HEAD),A.headElement=A.openElements.current,A.insertionMode=E.IN_HEAD,A._processToken(e)}function se(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.BASE:case i.BASEFONT:case i.BGSOUND:case i.LINK:case i.META:{A._appendElement(e,U.HTML),e.ackSelfClosing=!0;break}case i.TITLE:{A._switchToTextParsing(e,GA.RCDATA);break}case i.NOSCRIPT:{A.options.scriptingEnabled?A._switchToTextParsing(e,GA.RAWTEXT):(A._insertElement(e,U.HTML),A.insertionMode=E.IN_HEAD_NO_SCRIPT);break}case i.NOFRAMES:case i.STYLE:{A._switchToTextParsing(e,GA.RAWTEXT);break}case i.SCRIPT:{A._switchToTextParsing(e,GA.SCRIPT_DATA);break}case i.TEMPLATE:{A._insertTemplate(e),A.activeFormattingElements.insertMarker(),A.framesetOk=!1,A.insertionMode=E.IN_TEMPLATE,A.tmplInsertionModeStack.unshift(E.IN_TEMPLATE);break}case i.HEAD:{A._err(e,b.misplacedStartTagForHeadElement);break}default:jt(A,e)}}function dB(A,e){switch(e.tagID){case i.HEAD:{A.openElements.pop(),A.insertionMode=E.AFTER_HEAD;break}case i.BODY:case i.BR:case i.HTML:{jt(A,e);break}case i.TEMPLATE:{At(A,e);break}default:A._err(e,b.endTagWithoutMatchingOpenElement)}}function At(A,e){A.openElements.tmplCount>0?(A.openElements.generateImpliedEndTagsThoroughly(),A.openElements.currentTagId!==i.TEMPLATE&&A._err(e,b.closingOfElementWithOpenChildElements),A.openElements.popUntilTagNamePopped(i.TEMPLATE),A.activeFormattingElements.clearToLastMarker(),A.tmplInsertionModeStack.shift(),A._resetInsertionMode()):A._err(e,b.endTagWithoutMatchingOpenElement)}function jt(A,e){A.openElements.pop(),A.insertionMode=E.AFTER_HEAD,A._processToken(e)}function BB(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.BASEFONT:case i.BGSOUND:case i.HEAD:case i.LINK:case i.META:case i.NOFRAMES:case i.STYLE:{se(A,e);break}case i.NOSCRIPT:{A._err(e,b.nestedNoscriptInHead);break}default:Zt(A,e)}}function gB(A,e){switch(e.tagID){case i.NOSCRIPT:{A.openElements.pop(),A.insertionMode=E.IN_HEAD;break}case i.BR:{Zt(A,e);break}default:A._err(e,b.endTagWithoutMatchingOpenElement)}}function Zt(A,e){const t=e.type===eA.EOF?b.openElementsLeftAfterEof:b.disallowedContentInNoscriptInHead;A._err(e,t),A.openElements.pop(),A.insertionMode=E.IN_HEAD,A._processToken(e)}function EB(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.BODY:{A._insertElement(e,U.HTML),A.framesetOk=!1,A.insertionMode=E.IN_BODY;break}case i.FRAMESET:{A._insertElement(e,U.HTML),A.insertionMode=E.IN_FRAMESET;break}case i.BASE:case i.BASEFONT:case i.BGSOUND:case i.LINK:case i.META:case i.NOFRAMES:case i.SCRIPT:case i.STYLE:case i.TEMPLATE:case i.TITLE:{A._err(e,b.abandonedHeadElementChild),A.openElements.push(A.headElement,i.HEAD),se(A,e),A.openElements.remove(A.headElement);break}case i.HEAD:{A._err(e,b.misplacedStartTagForHeadElement);break}default:$t(A,e)}}function pB(A,e){switch(e.tagID){case i.BODY:case i.HTML:case i.BR:{$t(A,e);break}case i.TEMPLATE:{At(A,e);break}default:A._err(e,b.endTagWithoutMatchingOpenElement)}}function $t(A,e){A._insertFakeElement(w.BODY,i.BODY),A.insertionMode=E.IN_BODY,$r(A,e)}function $r(A,e){switch(e.type){case eA.CHARACTER:{Du(A,e);break}case eA.WHITESPACE_CHARACTER:{xu(A,e);break}case eA.COMMENT:{Ys(A,e);break}case eA.START_TAG:{xA(A,e);break}case eA.END_TAG:{zr(A,e);break}case eA.EOF:{Ku(A,e);break}}}function xu(A,e){A._reconstructActiveFormattingElements(),A._insertCharacters(e)}function Du(A,e){A._reconstructActiveFormattingElements(),A._insertCharacters(e),A.framesetOk=!1}function mB(A,e){A.openElements.tmplCount===0&&A.treeAdapter.adoptAttributes(A.openElements.items[0],e.attrs)}function CB(A,e){const t=A.openElements.tryPeekProperlyNestedBodyElement();t&&A.openElements.tmplCount===0&&(A.framesetOk=!1,A.treeAdapter.adoptAttributes(t,e.attrs))}function wB(A,e){const t=A.openElements.tryPeekProperlyNestedBodyElement();A.framesetOk&&t&&(A.treeAdapter.detachNode(t),A.openElements.popAllUpToHtmlElement(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_FRAMESET)}function TB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML)}function bB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),Ps.has(A.openElements.currentTagId)&&A.openElements.pop(),A._insertElement(e,U.HTML)}function UB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML),A.skipNextNewLine=!0,A.framesetOk=!1}function QB(A,e){const t=A.openElements.tmplCount>0;(!A.formElement||t)&&(A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML),t||(A.formElement=A.openElements.current))}function FB(A,e){A.framesetOk=!1;const t=e.tagID;for(let r=A.openElements.stackTop;r>=0;r--){const n=A.openElements.tagIDs[r];if(t===i.LI&&n===i.LI||(t===i.DD||t===i.DT)&&(n===i.DD||n===i.DT)){A.openElements.generateImpliedEndTagsWithExclusion(n),A.openElements.popUntilTagNamePopped(n);break}if(n!==i.ADDRESS&&n!==i.DIV&&n!==i.P&&A._isSpecialElement(A.openElements.items[r],n))break}A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML)}function IB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML),A.tokenizer.state=GA.PLAINTEXT}function _B(A,e){A.openElements.hasInScope(i.BUTTON)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(i.BUTTON)),A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML),A.framesetOk=!1}function yB(A,e){const t=A.activeFormattingElements.getElementEntryInScopeWithTagName(w.A);t&&(Gs(A,e),A.openElements.remove(t.element),A.activeFormattingElements.removeEntry(t)),A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML),A.activeFormattingElements.pushElement(A.openElements.current,e)}function NB(A,e){A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML),A.activeFormattingElements.pushElement(A.openElements.current,e)}function SB(A,e){A._reconstructActiveFormattingElements(),A.openElements.hasInScope(i.NOBR)&&(Gs(A,e),A._reconstructActiveFormattingElements()),A._insertElement(e,U.HTML),A.activeFormattingElements.pushElement(A.openElements.current,e)}function vB(A,e){A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML),A.activeFormattingElements.insertMarker(),A.framesetOk=!1}function LB(A,e){A.treeAdapter.getDocumentMode(A.document)!==qA.QUIRKS&&A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML),A.framesetOk=!1,A.insertionMode=E.IN_TABLE}function Ou(A,e){A._reconstructActiveFormattingElements(),A._appendElement(e,U.HTML),A.framesetOk=!1,e.ackSelfClosing=!0}function Ru(A){const e=gu(A,ze.TYPE);return e!=null&&e.toLowerCase()===Zd}function HB(A,e){A._reconstructActiveFormattingElements(),A._appendElement(e,U.HTML),Ru(e)||(A.framesetOk=!1),e.ackSelfClosing=!0}function xB(A,e){A._appendElement(e,U.HTML),e.ackSelfClosing=!0}function DB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._appendElement(e,U.HTML),A.framesetOk=!1,e.ackSelfClosing=!0}function OB(A,e){e.tagName=w.IMG,e.tagID=i.IMG,Ou(A,e)}function RB(A,e){A._insertElement(e,U.HTML),A.skipNextNewLine=!0,A.tokenizer.state=GA.RCDATA,A.originalInsertionMode=A.insertionMode,A.framesetOk=!1,A.insertionMode=E.TEXT}function MB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._reconstructActiveFormattingElements(),A.framesetOk=!1,A._switchToTextParsing(e,GA.RAWTEXT)}function kB(A,e){A.framesetOk=!1,A._switchToTextParsing(e,GA.RAWTEXT)}function Mu(A,e){A._switchToTextParsing(e,GA.RAWTEXT)}function PB(A,e){A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML),A.framesetOk=!1,A.insertionMode=A.insertionMode===E.IN_TABLE||A.insertionMode===E.IN_CAPTION||A.insertionMode===E.IN_TABLE_BODY||A.insertionMode===E.IN_ROW||A.insertionMode===E.IN_CELL?E.IN_SELECT_IN_TABLE:E.IN_SELECT}function KB(A,e){A.openElements.currentTagId===i.OPTION&&A.openElements.pop(),A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML)}function VB(A,e){A.openElements.hasInScope(i.RUBY)&&A.openElements.generateImpliedEndTags(),A._insertElement(e,U.HTML)}function GB(A,e){A.openElements.hasInScope(i.RUBY)&&A.openElements.generateImpliedEndTagsWithExclusion(i.RTC),A._insertElement(e,U.HTML)}function YB(A,e){A._reconstructActiveFormattingElements(),Nu(e),Vs(e),e.selfClosing?A._appendElement(e,U.MATHML):A._insertElement(e,U.MATHML),e.ackSelfClosing=!0}function XB(A,e){A._reconstructActiveFormattingElements(),Su(e),Vs(e),e.selfClosing?A._appendElement(e,U.SVG):A._insertElement(e,U.SVG),e.ackSelfClosing=!0}function ku(A,e){A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML)}function xA(A,e){switch(e.tagID){case i.I:case i.S:case i.B:case i.U:case i.EM:case i.TT:case i.BIG:case i.CODE:case i.FONT:case i.SMALL:case i.STRIKE:case i.STRONG:{NB(A,e);break}case i.A:{yB(A,e);break}case i.H1:case i.H2:case i.H3:case i.H4:case i.H5:case i.H6:{bB(A,e);break}case i.P:case i.DL:case i.OL:case i.UL:case i.DIV:case i.DIR:case i.NAV:case i.MAIN:case i.MENU:case i.ASIDE:case i.CENTER:case i.FIGURE:case i.FOOTER:case i.HEADER:case i.HGROUP:case i.DIALOG:case i.DETAILS:case i.ADDRESS:case i.ARTICLE:case i.SEARCH:case i.SECTION:case i.SUMMARY:case i.FIELDSET:case i.BLOCKQUOTE:case i.FIGCAPTION:{TB(A,e);break}case i.LI:case i.DD:case i.DT:{FB(A,e);break}case i.BR:case i.IMG:case i.WBR:case i.AREA:case i.EMBED:case i.KEYGEN:{Ou(A,e);break}case i.HR:{DB(A,e);break}case i.RB:case i.RTC:{VB(A,e);break}case i.RT:case i.RP:{GB(A,e);break}case i.PRE:case i.LISTING:{UB(A,e);break}case i.XMP:{MB(A,e);break}case i.SVG:{XB(A,e);break}case i.HTML:{mB(A,e);break}case i.BASE:case i.LINK:case i.META:case i.STYLE:case i.TITLE:case i.SCRIPT:case i.BGSOUND:case i.BASEFONT:case i.TEMPLATE:{se(A,e);break}case i.BODY:{CB(A,e);break}case i.FORM:{QB(A,e);break}case i.NOBR:{SB(A,e);break}case i.MATH:{YB(A,e);break}case i.TABLE:{LB(A,e);break}case i.INPUT:{HB(A,e);break}case i.PARAM:case i.TRACK:case i.SOURCE:{xB(A,e);break}case i.IMAGE:{OB(A,e);break}case i.BUTTON:{_B(A,e);break}case i.APPLET:case i.OBJECT:case i.MARQUEE:{vB(A,e);break}case i.IFRAME:{kB(A,e);break}case i.SELECT:{PB(A,e);break}case i.OPTION:case i.OPTGROUP:{KB(A,e);break}case i.NOEMBED:case i.NOFRAMES:{Mu(A,e);break}case i.FRAMESET:{wB(A,e);break}case i.TEXTAREA:{RB(A,e);break}case i.NOSCRIPT:{A.options.scriptingEnabled?Mu(A,e):ku(A,e);break}case i.PLAINTEXT:{IB(A,e);break}case i.COL:case i.TH:case i.TD:case i.TR:case i.HEAD:case i.FRAME:case i.TBODY:case i.TFOOT:case i.THEAD:case i.CAPTION:case i.COLGROUP:break;default:ku(A,e)}}function WB(A,e){if(A.openElements.hasInScope(i.BODY)&&(A.insertionMode=E.AFTER_BODY,A.options.sourceCodeLocationInfo)){const t=A.openElements.tryPeekProperlyNestedBodyElement();t&&A._setEndLocation(t,e)}}function JB(A,e){A.openElements.hasInScope(i.BODY)&&(A.insertionMode=E.AFTER_BODY,ju(A,e))}function qB(A,e){const t=e.tagID;A.openElements.hasInScope(t)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(t))}function jB(A){const e=A.openElements.tmplCount>0,{formElement:t}=A;e||(A.formElement=null),(t||e)&&A.openElements.hasInScope(i.FORM)&&(A.openElements.generateImpliedEndTags(),e?A.openElements.popUntilTagNamePopped(i.FORM):t&&A.openElements.remove(t))}function ZB(A){A.openElements.hasInButtonScope(i.P)||A._insertFakeElement(w.P,i.P),A._closePElement()}function $B(A){A.openElements.hasInListItemScope(i.LI)&&(A.openElements.generateImpliedEndTagsWithExclusion(i.LI),A.openElements.popUntilTagNamePopped(i.LI))}function zB(A,e){const t=e.tagID;A.openElements.hasInScope(t)&&(A.openElements.generateImpliedEndTagsWithExclusion(t),A.openElements.popUntilTagNamePopped(t))}function Ag(A){A.openElements.hasNumberedHeaderInScope()&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilNumberedHeaderPopped())}function eg(A,e){const t=e.tagID;A.openElements.hasInScope(t)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(t),A.activeFormattingElements.clearToLastMarker())}function tg(A){A._reconstructActiveFormattingElements(),A._insertFakeElement(w.BR,i.BR),A.openElements.pop(),A.framesetOk=!1}function Pu(A,e){const t=e.tagName,r=e.tagID;for(let n=A.openElements.stackTop;n>0;n--){const s=A.openElements.items[n],a=A.openElements.tagIDs[n];if(r===a&&(r!==i.UNKNOWN||A.treeAdapter.getTagName(s)===t)){A.openElements.generateImpliedEndTagsWithExclusion(r),A.openElements.stackTop>=n&&A.openElements.shortenToLength(n);break}if(A._isSpecialElement(s,a))break}}function zr(A,e){switch(e.tagID){case i.A:case i.B:case i.I:case i.S:case i.U:case i.EM:case i.TT:case i.BIG:case i.CODE:case i.FONT:case i.NOBR:case i.SMALL:case i.STRIKE:case i.STRONG:{Gs(A,e);break}case i.P:{ZB(A);break}case i.DL:case i.UL:case i.OL:case i.DIR:case i.DIV:case i.NAV:case i.PRE:case i.MAIN:case i.MENU:case i.ASIDE:case i.BUTTON:case i.CENTER:case i.FIGURE:case i.FOOTER:case i.HEADER:case i.HGROUP:case i.DIALOG:case i.ADDRESS:case i.ARTICLE:case i.DETAILS:case i.SEARCH:case i.SECTION:case i.SUMMARY:case i.LISTING:case i.FIELDSET:case i.BLOCKQUOTE:case i.FIGCAPTION:{qB(A,e);break}case i.LI:{$B(A);break}case i.DD:case i.DT:{zB(A,e);break}case i.H1:case i.H2:case i.H3:case i.H4:case i.H5:case i.H6:{Ag(A);break}case i.BR:{tg(A);break}case i.BODY:{WB(A,e);break}case i.HTML:{JB(A,e);break}case i.FORM:{jB(A);break}case i.APPLET:case i.OBJECT:case i.MARQUEE:{eg(A,e);break}case i.TEMPLATE:{At(A,e);break}default:Pu(A,e)}}function Ku(A,e){A.tmplInsertionModeStack.length>0?qu(A,e):Xs(A,e)}function rg(A,e){var t;e.tagID===i.SCRIPT&&((t=A.scriptHandler)===null||t===void 0||t.call(A,A.openElements.current)),A.openElements.pop(),A.insertionMode=A.originalInsertionMode}function ng(A,e){A._err(e,b.eofInElementThatCanContainOnlyText),A.openElements.pop(),A.insertionMode=A.originalInsertionMode,A.onEof(e)}function Ws(A,e){if(vu.has(A.openElements.currentTagId))switch(A.pendingCharacterTokens.length=0,A.hasNonWhitespacePendingCharacterToken=!1,A.originalInsertionMode=A.insertionMode,A.insertionMode=E.IN_TABLE_TEXT,e.type){case eA.CHARACTER:{Gu(A,e);break}case eA.WHITESPACE_CHARACTER:{Vu(A,e);break}}else Ar(A,e)}function sg(A,e){A.openElements.clearBackToTableContext(),A.activeFormattingElements.insertMarker(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_CAPTION}function ag(A,e){A.openElements.clearBackToTableContext(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_COLUMN_GROUP}function ig(A,e){A.openElements.clearBackToTableContext(),A._insertFakeElement(w.COLGROUP,i.COLGROUP),A.insertionMode=E.IN_COLUMN_GROUP,Js(A,e)}function ug(A,e){A.openElements.clearBackToTableContext(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_TABLE_BODY}function og(A,e){A.openElements.clearBackToTableContext(),A._insertFakeElement(w.TBODY,i.TBODY),A.insertionMode=E.IN_TABLE_BODY,en(A,e)}function cg(A,e){A.openElements.hasInTableScope(i.TABLE)&&(A.openElements.popUntilTagNamePopped(i.TABLE),A._resetInsertionMode(),A._processStartTag(e))}function lg(A,e){Ru(e)?A._appendElement(e,U.HTML):Ar(A,e),e.ackSelfClosing=!0}function fg(A,e){!A.formElement&&A.openElements.tmplCount===0&&(A._insertElement(e,U.HTML),A.formElement=A.openElements.current,A.openElements.pop())}function gt(A,e){switch(e.tagID){case i.TD:case i.TH:case i.TR:{og(A,e);break}case i.STYLE:case i.SCRIPT:case i.TEMPLATE:{se(A,e);break}case i.COL:{ig(A,e);break}case i.FORM:{fg(A,e);break}case i.TABLE:{cg(A,e);break}case i.TBODY:case i.TFOOT:case i.THEAD:{ug(A,e);break}case i.INPUT:{lg(A,e);break}case i.CAPTION:{sg(A,e);break}case i.COLGROUP:{ag(A,e);break}default:Ar(A,e)}}function zt(A,e){switch(e.tagID){case i.TABLE:{A.openElements.hasInTableScope(i.TABLE)&&(A.openElements.popUntilTagNamePopped(i.TABLE),A._resetInsertionMode());break}case i.TEMPLATE:{At(A,e);break}case i.BODY:case i.CAPTION:case i.COL:case i.COLGROUP:case i.HTML:case i.TBODY:case i.TD:case i.TFOOT:case i.TH:case i.THEAD:case i.TR:break;default:Ar(A,e)}}function Ar(A,e){const t=A.fosterParentingEnabled;A.fosterParentingEnabled=!0,$r(A,e),A.fosterParentingEnabled=t}function Vu(A,e){A.pendingCharacterTokens.push(e)}function Gu(A,e){A.pendingCharacterTokens.push(e),A.hasNonWhitespacePendingCharacterToken=!0}function er(A,e){let t=0;if(A.hasNonWhitespacePendingCharacterToken)for(;t<A.pendingCharacterTokens.length;t++)Ar(A,A.pendingCharacterTokens[t]);else for(;t<A.pendingCharacterTokens.length;t++)A._insertCharacters(A.pendingCharacterTokens[t]);A.insertionMode=A.originalInsertionMode,A._processToken(e)}const Yu=new Set([i.CAPTION,i.COL,i.COLGROUP,i.TBODY,i.TD,i.TFOOT,i.TH,i.THEAD,i.TR]);function hg(A,e){const t=e.tagID;Yu.has(t)?A.openElements.hasInTableScope(i.CAPTION)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(i.CAPTION),A.activeFormattingElements.clearToLastMarker(),A.insertionMode=E.IN_TABLE,gt(A,e)):xA(A,e)}function dg(A,e){const t=e.tagID;switch(t){case i.CAPTION:case i.TABLE:{A.openElements.hasInTableScope(i.CAPTION)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(i.CAPTION),A.activeFormattingElements.clearToLastMarker(),A.insertionMode=E.IN_TABLE,t===i.TABLE&&zt(A,e));break}case i.BODY:case i.COL:case i.COLGROUP:case i.HTML:case i.TBODY:case i.TD:case i.TFOOT:case i.TH:case i.THEAD:case i.TR:break;default:zr(A,e)}}function Js(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.COL:{A._appendElement(e,U.HTML),e.ackSelfClosing=!0;break}case i.TEMPLATE:{se(A,e);break}default:An(A,e)}}function Bg(A,e){switch(e.tagID){case i.COLGROUP:{A.openElements.currentTagId===i.COLGROUP&&(A.openElements.pop(),A.insertionMode=E.IN_TABLE);break}case i.TEMPLATE:{At(A,e);break}case i.COL:break;default:An(A,e)}}function An(A,e){A.openElements.currentTagId===i.COLGROUP&&(A.openElements.pop(),A.insertionMode=E.IN_TABLE,A._processToken(e))}function en(A,e){switch(e.tagID){case i.TR:{A.openElements.clearBackToTableBodyContext(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_ROW;break}case i.TH:case i.TD:{A.openElements.clearBackToTableBodyContext(),A._insertFakeElement(w.TR,i.TR),A.insertionMode=E.IN_ROW,tn(A,e);break}case i.CAPTION:case i.COL:case i.COLGROUP:case i.TBODY:case i.TFOOT:case i.THEAD:{A.openElements.hasTableBodyContextInTableScope()&&(A.openElements.clearBackToTableBodyContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE,gt(A,e));break}default:gt(A,e)}}function qs(A,e){const t=e.tagID;switch(e.tagID){case i.TBODY:case i.TFOOT:case i.THEAD:{A.openElements.hasInTableScope(t)&&(A.openElements.clearBackToTableBodyContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE);break}case i.TABLE:{A.openElements.hasTableBodyContextInTableScope()&&(A.openElements.clearBackToTableBodyContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE,zt(A,e));break}case i.BODY:case i.CAPTION:case i.COL:case i.COLGROUP:case i.HTML:case i.TD:case i.TH:case i.TR:break;default:zt(A,e)}}function tn(A,e){switch(e.tagID){case i.TH:case i.TD:{A.openElements.clearBackToTableRowContext(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_CELL,A.activeFormattingElements.insertMarker();break}case i.CAPTION:case i.COL:case i.COLGROUP:case i.TBODY:case i.TFOOT:case i.THEAD:case i.TR:{A.openElements.hasInTableScope(i.TR)&&(A.openElements.clearBackToTableRowContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE_BODY,en(A,e));break}default:gt(A,e)}}function Xu(A,e){switch(e.tagID){case i.TR:{A.openElements.hasInTableScope(i.TR)&&(A.openElements.clearBackToTableRowContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE_BODY);break}case i.TABLE:{A.openElements.hasInTableScope(i.TR)&&(A.openElements.clearBackToTableRowContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE_BODY,qs(A,e));break}case i.TBODY:case i.TFOOT:case i.THEAD:{(A.openElements.hasInTableScope(e.tagID)||A.openElements.hasInTableScope(i.TR))&&(A.openElements.clearBackToTableRowContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE_BODY,qs(A,e));break}case i.BODY:case i.CAPTION:case i.COL:case i.COLGROUP:case i.HTML:case i.TD:case i.TH:break;default:zt(A,e)}}function gg(A,e){const t=e.tagID;Yu.has(t)?(A.openElements.hasInTableScope(i.TD)||A.openElements.hasInTableScope(i.TH))&&(A._closeTableCell(),tn(A,e)):xA(A,e)}function Eg(A,e){const t=e.tagID;switch(t){case i.TD:case i.TH:{A.openElements.hasInTableScope(t)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(t),A.activeFormattingElements.clearToLastMarker(),A.insertionMode=E.IN_ROW);break}case i.TABLE:case i.TBODY:case i.TFOOT:case i.THEAD:case i.TR:{A.openElements.hasInTableScope(t)&&(A._closeTableCell(),Xu(A,e));break}case i.BODY:case i.CAPTION:case i.COL:case i.COLGROUP:case i.HTML:break;default:zr(A,e)}}function Wu(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.OPTION:{A.openElements.currentTagId===i.OPTION&&A.openElements.pop(),A._insertElement(e,U.HTML);break}case i.OPTGROUP:{A.openElements.currentTagId===i.OPTION&&A.openElements.pop(),A.openElements.currentTagId===i.OPTGROUP&&A.openElements.pop(),A._insertElement(e,U.HTML);break}case i.HR:{A.openElements.currentTagId===i.OPTION&&A.openElements.pop(),A.openElements.currentTagId===i.OPTGROUP&&A.openElements.pop(),A._appendElement(e,U.HTML),e.ackSelfClosing=!0;break}case i.INPUT:case i.KEYGEN:case i.TEXTAREA:case i.SELECT:{A.openElements.hasInSelectScope(i.SELECT)&&(A.openElements.popUntilTagNamePopped(i.SELECT),A._resetInsertionMode(),e.tagID!==i.SELECT&&A._processStartTag(e));break}case i.SCRIPT:case i.TEMPLATE:{se(A,e);break}}}function Ju(A,e){switch(e.tagID){case i.OPTGROUP:{A.openElements.stackTop>0&&A.openElements.currentTagId===i.OPTION&&A.openElements.tagIDs[A.openElements.stackTop-1]===i.OPTGROUP&&A.openElements.pop(),A.openElements.currentTagId===i.OPTGROUP&&A.openElements.pop();break}case i.OPTION:{A.openElements.currentTagId===i.OPTION&&A.openElements.pop();break}case i.SELECT:{A.openElements.hasInSelectScope(i.SELECT)&&(A.openElements.popUntilTagNamePopped(i.SELECT),A._resetInsertionMode());break}case i.TEMPLATE:{At(A,e);break}}}function pg(A,e){const t=e.tagID;t===i.CAPTION||t===i.TABLE||t===i.TBODY||t===i.TFOOT||t===i.THEAD||t===i.TR||t===i.TD||t===i.TH?(A.openElements.popUntilTagNamePopped(i.SELECT),A._resetInsertionMode(),A._processStartTag(e)):Wu(A,e)}function mg(A,e){const t=e.tagID;t===i.CAPTION||t===i.TABLE||t===i.TBODY||t===i.TFOOT||t===i.THEAD||t===i.TR||t===i.TD||t===i.TH?A.openElements.hasInTableScope(t)&&(A.openElements.popUntilTagNamePopped(i.SELECT),A._resetInsertionMode(),A.onEndTag(e)):Ju(A,e)}function Cg(A,e){switch(e.tagID){case i.BASE:case i.BASEFONT:case i.BGSOUND:case i.LINK:case i.META:case i.NOFRAMES:case i.SCRIPT:case i.STYLE:case i.TEMPLATE:case i.TITLE:{se(A,e);break}case i.CAPTION:case i.COLGROUP:case i.TBODY:case i.TFOOT:case i.THEAD:{A.tmplInsertionModeStack[0]=E.IN_TABLE,A.insertionMode=E.IN_TABLE,gt(A,e);break}case i.COL:{A.tmplInsertionModeStack[0]=E.IN_COLUMN_GROUP,A.insertionMode=E.IN_COLUMN_GROUP,Js(A,e);break}case i.TR:{A.tmplInsertionModeStack[0]=E.IN_TABLE_BODY,A.insertionMode=E.IN_TABLE_BODY,en(A,e);break}case i.TD:case i.TH:{A.tmplInsertionModeStack[0]=E.IN_ROW,A.insertionMode=E.IN_ROW,tn(A,e);break}default:A.tmplInsertionModeStack[0]=E.IN_BODY,A.insertionMode=E.IN_BODY,xA(A,e)}}function wg(A,e){e.tagID===i.TEMPLATE&&At(A,e)}function qu(A,e){A.openElements.tmplCount>0?(A.openElements.popUntilTagNamePopped(i.TEMPLATE),A.activeFormattingElements.clearToLastMarker(),A.tmplInsertionModeStack.shift(),A._resetInsertionMode(),A.onEof(e)):Xs(A,e)}function Tg(A,e){e.tagID===i.HTML?xA(A,e):rn(A,e)}function ju(A,e){var t;if(e.tagID===i.HTML){if(A.fragmentContext||(A.insertionMode=E.AFTER_AFTER_BODY),A.options.sourceCodeLocationInfo&&A.openElements.tagIDs[0]===i.HTML){A._setEndLocation(A.openElements.items[0],e);const r=A.openElements.items[1];r&&!(!((t=A.treeAdapter.getNodeSourceCodeLocation(r))===null||t===void 0)&&t.endTag)&&A._setEndLocation(r,e)}}else rn(A,e)}function rn(A,e){A.insertionMode=E.IN_BODY,$r(A,e)}function bg(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.FRAMESET:{A._insertElement(e,U.HTML);break}case i.FRAME:{A._appendElement(e,U.HTML),e.ackSelfClosing=!0;break}case i.NOFRAMES:{se(A,e);break}}}function Ug(A,e){e.tagID===i.FRAMESET&&!A.openElements.isRootHtmlElementCurrent()&&(A.openElements.pop(),!A.fragmentContext&&A.openElements.currentTagId!==i.FRAMESET&&(A.insertionMode=E.AFTER_FRAMESET))}function Qg(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.NOFRAMES:{se(A,e);break}}}function Fg(A,e){e.tagID===i.HTML&&(A.insertionMode=E.AFTER_AFTER_FRAMESET)}function Ig(A,e){e.tagID===i.HTML?xA(A,e):nn(A,e)}function nn(A,e){A.insertionMode=E.IN_BODY,$r(A,e)}function _g(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.NOFRAMES:{se(A,e);break}}}function yg(A,e){e.chars=fA,A._insertCharacters(e)}function Ng(A,e){A._insertCharacters(e),A.framesetOk=!1}function Zu(A){for(;A.treeAdapter.getNamespaceURI(A.openElements.current)!==U.HTML&&!A._isIntegrationPoint(A.openElements.currentTagId,A.openElements.current);)A.openElements.pop()}function Sg(A,e){if(Xd(e))Zu(A),A._startTagOutsideForeignContent(e);else{const t=A._getAdjustedCurrentElement(),r=A.treeAdapter.getNamespaceURI(t);r===U.MATHML?Nu(e):r===U.SVG&&(Wd(e),Su(e)),Vs(e),e.selfClosing?A._appendElement(e,r):A._insertElement(e,r),e.ackSelfClosing=!0}}function vg(A,e){if(e.tagID===i.P||e.tagID===i.BR){Zu(A),A._endTagOutsideForeignContent(e);return}for(let t=A.openElements.stackTop;t>0;t--){const r=A.openElements.items[t];if(A.treeAdapter.getNamespaceURI(r)===U.HTML){A._endTagOutsideForeignContent(e);break}const n=A.treeAdapter.getTagName(r);if(n.toLowerCase()===e.tagName){e.tagName=n,A.openElements.shortenToLength(t);break}}}const Lg=new Set([w.AREA,w.BASE,w.BASEFONT,w.BGSOUND,w.BR,w.COL,w.EMBED,w.FRAME,w.HR,w.IMG,w.INPUT,w.KEYGEN,w.LINK,w.META,w.PARAM,w.SOURCE,w.TRACK,w.WBR]);function Hg(A,e){return e.treeAdapter.isElementNode(A)&&e.treeAdapter.getNamespaceURI(A)===U.HTML&&Lg.has(e.treeAdapter.getTagName(A))}const xg={treeAdapter:we,scriptingEnabled:!0};function Dg(A,e){const t={...xg,...e};return $u(A,t)}function Og(A,e){let t="";const r=e.treeAdapter.isElementNode(A)&&e.treeAdapter.getTagName(A)===w.TEMPLATE&&e.treeAdapter.getNamespaceURI(A)===U.HTML?e.treeAdapter.getTemplateContent(A):A,n=e.treeAdapter.getChildNodes(r);if(n)for(const s of n)t+=$u(s,e);return t}function $u(A,e){return e.treeAdapter.isElementNode(A)?Rg(A,e):e.treeAdapter.isTextNode(A)?kg(A,e):e.treeAdapter.isCommentNode(A)?Pg(A,e):e.treeAdapter.isDocumentTypeNode(A)?Kg(A,e):""}function Rg(A,e){const t=e.treeAdapter.getTagName(A);return`<${t}${Mg(A,e)}>${Hg(A,e)?"":`${Og(A,e)}</${t}>`}`}function Mg(A,{treeAdapter:e}){let t="";for(const r of e.getAttrList(A)){if(t+=" ",r.namespace)switch(r.namespace){case U.XML:{t+=`xml:${r.name}`;break}case U.XMLNS:{r.name!=="xmlns"&&(t+="xmlns:"),t+=r.name;break}case U.XLINK:{t+=`xlink:${r.name}`;break}default:t+=`${r.prefix}:${r.name}`}else t+=r.name;t+=`="${mi(r.value)}"`}return t}function kg(A,e){const{treeAdapter:t}=e,r=t.getTextNodeContent(A),n=t.getParentNode(A),s=n&&t.isElementNode(n)&&t.getTagName(n);return s&&t.getNamespaceURI(n)===U.HTML&&Cd(s,e.scriptingEnabled)?r:Ci(r)}function Pg(A,{treeAdapter:e}){return`<!--${e.getCommentNodeContent(A)}-->`}function Kg(A,{treeAdapter:e}){return`<!DOCTYPE ${e.getDocumentTypeNodeName(A)}>`}function Vg(A,e){return Hu.parse(A,e)}function Gg(A,e,t){typeof A=="string"&&(t=e,e=A,A=null);const r=Hu.getFragmentParser(A,t);return r.tokenizer.write(e,!0),r.getFragment()}function zu(A){const e=A.includes('"')?"'":'"';return e+A+e}function Yg(A,e,t){let r="!DOCTYPE ";return A&&(r+=A),e?r+=` PUBLIC ${zu(e)}`:t&&(r+=" SYSTEM"),t&&(r+=` ${zu(t)}`),r}const Le={isCommentNode:vr,isElementNode:X,isTextNode:le,createDocument(){const A=new Je([]);return A["x-mode"]=qA.NO_QUIRKS,A},createDocumentFragment(){return new Je([])},createElement(A,e,t){const r=Object.create(null),n=Object.create(null),s=Object.create(null);for(let u=0;u<t.length;u++){const o=t[u].name;r[o]=t[u].value,n[o]=t[u].namespace,s[o]=t[u].prefix}const a=new us(A,r,[]);return a.namespace=e,a["x-attribsNamespace"]=n,a["x-attribsPrefix"]=s,a},createCommentNode(A){return new ss(A)},createTextNode(A){return new Dt(A)},appendChild(A,e){const t=A.children[A.children.length-1];t&&(t.next=e,e.prev=t),A.children.push(e),e.parent=A},insertBefore(A,e,t){const r=A.children.indexOf(t),{prev:n}=t;n&&(n.next=e,e.prev=n),t.prev=e,e.next=t,A.children.splice(r,0,e),e.parent=A},setTemplateContent(A,e){Le.appendChild(A,e)},getTemplateContent(A){return A.children[0]},setDocumentType(A,e,t,r){const n=Yg(e,t,r);let s=A.children.find(a=>os(a)&&a.name==="!doctype");s?s.data=n??null:(s=new as("!doctype",n),Le.appendChild(A,s)),s["x-name"]=e,s["x-publicId"]=t,s["x-systemId"]=r},setDocumentMode(A,e){A["x-mode"]=e},getDocumentMode(A){return A["x-mode"]},detachNode(A){if(A.parent){const e=A.parent.children.indexOf(A),{prev:t,next:r}=A;A.prev=null,A.next=null,t&&(t.next=r),r&&(r.prev=t),A.parent.children.splice(e,1),A.parent=null}},insertText(A,e){const t=A.children[A.children.length-1];t&&le(t)?t.data+=e:Le.appendChild(A,Le.createTextNode(e))},insertTextBefore(A,e,t){const r=A.children[A.children.indexOf(t)-1];r&&le(r)?r.data+=e:Le.insertBefore(A,Le.createTextNode(e),t)},adoptAttributes(A,e){for(let t=0;t<e.length;t++){const r=e[t].name;A.attribs[r]===void 0&&(A.attribs[r]=e[t].value,A["x-attribsNamespace"][r]=e[t].namespace,A["x-attribsPrefix"][r]=e[t].prefix)}},getFirstChild(A){return A.children[0]},getChildNodes(A){return A.children},getParentNode(A){return A.parent},getAttrList(A){return A.attributes},getTagName(A){return A.name},getNamespaceURI(A){return A.namespace},getTextNodeContent(A){return A.data},getCommentNodeContent(A){return A.data},getDocumentTypeNodeName(A){var e;return(e=A["x-name"])!==null&&e!==void 0?e:""},getDocumentTypeNodePublicId(A){var e;return(e=A["x-publicId"])!==null&&e!==void 0?e:""},getDocumentTypeNodeSystemId(A){var e;return(e=A["x-systemId"])!==null&&e!==void 0?e:""},isDocumentTypeNode(A){return os(A)&&A.name==="!doctype"},setNodeSourceCodeLocation(A,e){e&&(A.startIndex=e.startOffset,A.endIndex=e.endOffset),A.sourceCodeLocation=e},getNodeSourceCodeLocation(A){return A.sourceCodeLocation},updateNodeSourceCodeLocation(A,e){e.endOffset!=null&&(A.endIndex=e.endOffset),A.sourceCodeLocation={...A.sourceCodeLocation,...e}}};function Xg(A,e,t,r){var n;return(n=e.treeAdapter)!==null&&n!==void 0||(e.treeAdapter=Le),e.scriptingEnabled!==!1&&(e.scriptingEnabled=!0),t?Vg(A,e):Gg(r,A,e)}const Wg={treeAdapter:Le};function Jg(A){const e="length"in A?A:[A];for(let r=0;r<e.length;r+=1){const n=e[r];_e(n)&&Array.prototype.splice.call(e,r,1,...n.children)}let t="";for(let r=0;r<e.length;r+=1){const n=e[r];t+=Dg(n,Wg)}return t}var G;(function(A){A[A.Tab=9]="Tab",A[A.NewLine=10]="NewLine",A[A.FormFeed=12]="FormFeed",A[A.CarriageReturn=13]="CarriageReturn",A[A.Space=32]="Space",A[A.ExclamationMark=33]="ExclamationMark",A[A.Number=35]="Number",A[A.Amp=38]="Amp",A[A.SingleQuote=39]="SingleQuote",A[A.DoubleQuote=34]="DoubleQuote",A[A.Dash=45]="Dash",A[A.Slash=47]="Slash",A[A.Zero=48]="Zero",A[A.Nine=57]="Nine",A[A.Semi=59]="Semi",A[A.Lt=60]="Lt",A[A.Eq=61]="Eq",A[A.Gt=62]="Gt",A[A.Questionmark=63]="Questionmark",A[A.UpperA=65]="UpperA",A[A.LowerA=97]="LowerA",A[A.UpperF=70]="UpperF",A[A.LowerF=102]="LowerF",A[A.UpperZ=90]="UpperZ",A[A.LowerZ=122]="LowerZ",A[A.LowerX=120]="LowerX",A[A.OpeningSquareBracket=91]="OpeningSquareBracket"})(G||(G={}));var _;(function(A){A[A.Text=1]="Text",A[A.BeforeTagName=2]="BeforeTagName",A[A.InTagName=3]="InTagName",A[A.InSelfClosingTag=4]="InSelfClosingTag",A[A.BeforeClosingTagName=5]="BeforeClosingTagName",A[A.InClosingTagName=6]="InClosingTagName",A[A.AfterClosingTagName=7]="AfterClosingTagName",A[A.BeforeAttributeName=8]="BeforeAttributeName",A[A.InAttributeName=9]="InAttributeName",A[A.AfterAttributeName=10]="AfterAttributeName",A[A.BeforeAttributeValue=11]="BeforeAttributeValue",A[A.InAttributeValueDq=12]="InAttributeValueDq",A[A.InAttributeValueSq=13]="InAttributeValueSq",A[A.InAttributeValueNq=14]="InAttributeValueNq",A[A.BeforeDeclaration=15]="BeforeDeclaration",A[A.InDeclaration=16]="InDeclaration",A[A.InProcessingInstruction=17]="InProcessingInstruction",A[A.BeforeComment=18]="BeforeComment",A[A.CDATASequence=19]="CDATASequence",A[A.InSpecialComment=20]="InSpecialComment",A[A.InCommentLike=21]="InCommentLike",A[A.BeforeSpecialS=22]="BeforeSpecialS",A[A.BeforeSpecialT=23]="BeforeSpecialT",A[A.SpecialStartSequence=24]="SpecialStartSequence",A[A.InSpecialTag=25]="InSpecialTag",A[A.InEntity=26]="InEntity"})(_||(_={}));function Te(A){return A===G.Space||A===G.NewLine||A===G.Tab||A===G.FormFeed||A===G.CarriageReturn}function sn(A){return A===G.Slash||A===G.Gt||Te(A)}function qg(A){return A>=G.LowerA&&A<=G.LowerZ||A>=G.UpperA&&A<=G.UpperZ}var he;(function(A){A[A.NoValue=0]="NoValue",A[A.Unquoted=1]="Unquoted",A[A.Single=2]="Single",A[A.Double=3]="Double"})(he||(he={}));const SA={Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,62]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101]),TextareaEnd:new Uint8Array([60,47,116,101,120,116,97,114,101,97])};let jg=class{constructor({xmlMode:e=!1,decodeEntities:t=!0},r){this.cbs=r,this.state=_.Text,this.buffer="",this.sectionStart=0,this.index=0,this.entityStart=0,this.baseState=_.Text,this.isSpecial=!1,this.running=!0,this.offset=0,this.currentSequence=void 0,this.sequenceIndex=0,this.xmlMode=e,this.decodeEntities=t,this.entityDecoder=new Bs(e?di:ls,(n,s)=>this.emitCodePoint(n,s))}reset(){this.state=_.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=_.Text,this.currentSequence=void 0,this.running=!0,this.offset=0}write(e){this.offset+=this.buffer.length,this.buffer=e,this.parse()}end(){this.running&&this.finish()}pause(){this.running=!1}resume(){this.running=!0,this.index<this.buffer.length+this.offset&&this.parse()}stateText(e){e===G.Lt||!this.decodeEntities&&this.fastForwardTo(G.Lt)?(this.index>this.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=_.BeforeTagName,this.sectionStart=this.index):this.decodeEntities&&e===G.Amp&&this.startEntity()}stateSpecialStartSequence(e){const t=this.sequenceIndex===this.currentSequence.length;if(!(t?sn(e):(e|32)===this.currentSequence[this.sequenceIndex]))this.isSpecial=!1;else if(!t){this.sequenceIndex++;return}this.sequenceIndex=0,this.state=_.InTagName,this.stateInTagName(e)}stateInSpecialTag(e){if(this.sequenceIndex===this.currentSequence.length){if(e===G.Gt||Te(e)){const t=this.index-this.currentSequence.length;if(this.sectionStart<t){const r=this.index;this.index=t,this.cbs.ontext(this.sectionStart,t),this.index=r}this.isSpecial=!1,this.sectionStart=t+2,this.stateInClosingTagName(e);return}this.sequenceIndex=0}(e|32)===this.currentSequence[this.sequenceIndex]?this.sequenceIndex+=1:this.sequenceIndex===0?this.currentSequence===SA.TitleEnd?this.decodeEntities&&e===G.Amp&&this.startEntity():this.fastForwardTo(G.Lt)&&(this.sequenceIndex=1):this.sequenceIndex=+(e===G.Lt)}stateCDATASequence(e){e===SA.Cdata[this.sequenceIndex]?++this.sequenceIndex===SA.Cdata.length&&(this.state=_.InCommentLike,this.currentSequence=SA.CdataEnd,this.sequenceIndex=0,this.sectionStart=this.index+1):(this.sequenceIndex=0,this.state=_.InDeclaration,this.stateInDeclaration(e))}fastForwardTo(e){for(;++this.index<this.buffer.length+this.offset;)if(this.buffer.charCodeAt(this.index-this.offset)===e)return!0;return this.index=this.buffer.length+this.offset-1,!1}stateInCommentLike(e){e===this.currentSequence[this.sequenceIndex]?++this.sequenceIndex===this.currentSequence.length&&(this.currentSequence===SA.CdataEnd?this.cbs.oncdata(this.sectionStart,this.index,2):this.cbs.oncomment(this.sectionStart,this.index,2),this.sequenceIndex=0,this.sectionStart=this.index+1,this.state=_.Text):this.sequenceIndex===0?this.fastForwardTo(this.currentSequence[0])&&(this.sequenceIndex=1):e!==this.currentSequence[this.sequenceIndex-1]&&(this.sequenceIndex=0)}isTagStartChar(e){return this.xmlMode?!sn(e):qg(e)}startSpecial(e,t){this.isSpecial=!0,this.currentSequence=e,this.sequenceIndex=t,this.state=_.SpecialStartSequence}stateBeforeTagName(e){if(e===G.ExclamationMark)this.state=_.BeforeDeclaration,this.sectionStart=this.index+1;else if(e===G.Questionmark)this.state=_.InProcessingInstruction,this.sectionStart=this.index+1;else if(this.isTagStartChar(e)){const t=e|32;this.sectionStart=this.index,this.xmlMode?this.state=_.InTagName:t===SA.ScriptEnd[2]?this.state=_.BeforeSpecialS:t===SA.TitleEnd[2]?this.state=_.BeforeSpecialT:this.state=_.InTagName}else e===G.Slash?this.state=_.BeforeClosingTagName:(this.state=_.Text,this.stateText(e))}stateInTagName(e){sn(e)&&(this.cbs.onopentagname(this.sectionStart,this.index),this.sectionStart=-1,this.state=_.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateBeforeClosingTagName(e){Te(e)||(e===G.Gt?this.state=_.Text:(this.state=this.isTagStartChar(e)?_.InClosingTagName:_.InSpecialComment,this.sectionStart=this.index))}stateInClosingTagName(e){(e===G.Gt||Te(e))&&(this.cbs.onclosetag(this.sectionStart,this.index),this.sectionStart=-1,this.state=_.AfterClosingTagName,this.stateAfterClosingTagName(e))}stateAfterClosingTagName(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.state=_.Text,this.sectionStart=this.index+1)}stateBeforeAttributeName(e){e===G.Gt?(this.cbs.onopentagend(this.index),this.isSpecial?(this.state=_.InSpecialTag,this.sequenceIndex=0):this.state=_.Text,this.sectionStart=this.index+1):e===G.Slash?this.state=_.InSelfClosingTag:Te(e)||(this.state=_.InAttributeName,this.sectionStart=this.index)}stateInSelfClosingTag(e){e===G.Gt?(this.cbs.onselfclosingtag(this.index),this.state=_.Text,this.sectionStart=this.index+1,this.isSpecial=!1):Te(e)||(this.state=_.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateInAttributeName(e){(e===G.Eq||sn(e))&&(this.cbs.onattribname(this.sectionStart,this.index),this.sectionStart=this.index,this.state=_.AfterAttributeName,this.stateAfterAttributeName(e))}stateAfterAttributeName(e){e===G.Eq?this.state=_.BeforeAttributeValue:e===G.Slash||e===G.Gt?(this.cbs.onattribend(he.NoValue,this.sectionStart),this.sectionStart=-1,this.state=_.BeforeAttributeName,this.stateBeforeAttributeName(e)):Te(e)||(this.cbs.onattribend(he.NoValue,this.sectionStart),this.state=_.InAttributeName,this.sectionStart=this.index)}stateBeforeAttributeValue(e){e===G.DoubleQuote?(this.state=_.InAttributeValueDq,this.sectionStart=this.index+1):e===G.SingleQuote?(this.state=_.InAttributeValueSq,this.sectionStart=this.index+1):Te(e)||(this.sectionStart=this.index,this.state=_.InAttributeValueNq,this.stateInAttributeValueNoQuotes(e))}handleInAttributeValue(e,t){e===t||!this.decodeEntities&&this.fastForwardTo(t)?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(t===G.DoubleQuote?he.Double:he.Single,this.index+1),this.state=_.BeforeAttributeName):this.decodeEntities&&e===G.Amp&&this.startEntity()}stateInAttributeValueDoubleQuotes(e){this.handleInAttributeValue(e,G.DoubleQuote)}stateInAttributeValueSingleQuotes(e){this.handleInAttributeValue(e,G.SingleQuote)}stateInAttributeValueNoQuotes(e){Te(e)||e===G.Gt?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(he.Unquoted,this.index),this.state=_.BeforeAttributeName,this.stateBeforeAttributeName(e)):this.decodeEntities&&e===G.Amp&&this.startEntity()}stateBeforeDeclaration(e){e===G.OpeningSquareBracket?(this.state=_.CDATASequence,this.sequenceIndex=0):this.state=e===G.Dash?_.BeforeComment:_.InDeclaration}stateInDeclaration(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.cbs.ondeclaration(this.sectionStart,this.index),this.state=_.Text,this.sectionStart=this.index+1)}stateInProcessingInstruction(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.cbs.onprocessinginstruction(this.sectionStart,this.index),this.state=_.Text,this.sectionStart=this.index+1)}stateBeforeComment(e){e===G.Dash?(this.state=_.InCommentLike,this.currentSequence=SA.CommentEnd,this.sequenceIndex=2,this.sectionStart=this.index+1):this.state=_.InDeclaration}stateInSpecialComment(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=_.Text,this.sectionStart=this.index+1)}stateBeforeSpecialS(e){const t=e|32;t===SA.ScriptEnd[3]?this.startSpecial(SA.ScriptEnd,4):t===SA.StyleEnd[3]?this.startSpecial(SA.StyleEnd,4):(this.state=_.InTagName,this.stateInTagName(e))}stateBeforeSpecialT(e){const t=e|32;t===SA.TitleEnd[3]?this.startSpecial(SA.TitleEnd,4):t===SA.TextareaEnd[3]?this.startSpecial(SA.TextareaEnd,4):(this.state=_.InTagName,this.stateInTagName(e))}startEntity(){this.baseState=this.state,this.state=_.InEntity,this.entityStart=this.index,this.entityDecoder.startEntity(this.xmlMode?$A.Strict:this.baseState===_.Text||this.baseState===_.InSpecialTag?$A.Legacy:$A.Attribute)}stateInEntity(){const e=this.entityDecoder.write(this.buffer,this.index-this.offset);e>=0?(this.state=this.baseState,e===0&&(this.index=this.entityStart)):this.index=this.offset+this.buffer.length-1}cleanup(){this.running&&this.sectionStart!==this.index&&(this.state===_.Text||this.state===_.InSpecialTag&&this.sequenceIndex===0?(this.cbs.ontext(this.sectionStart,this.index),this.sectionStart=this.index):(this.state===_.InAttributeValueDq||this.state===_.InAttributeValueSq||this.state===_.InAttributeValueNq)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=this.index))}shouldContinue(){return this.index<this.buffer.length+this.offset&&this.running}parse(){for(;this.shouldContinue();){const e=this.buffer.charCodeAt(this.index-this.offset);switch(this.state){case _.Text:{this.stateText(e);break}case _.SpecialStartSequence:{this.stateSpecialStartSequence(e);break}case _.InSpecialTag:{this.stateInSpecialTag(e);break}case _.CDATASequence:{this.stateCDATASequence(e);break}case _.InAttributeValueDq:{this.stateInAttributeValueDoubleQuotes(e);break}case _.InAttributeName:{this.stateInAttributeName(e);break}case _.InCommentLike:{this.stateInCommentLike(e);break}case _.InSpecialComment:{this.stateInSpecialComment(e);break}case _.BeforeAttributeName:{this.stateBeforeAttributeName(e);break}case _.InTagName:{this.stateInTagName(e);break}case _.InClosingTagName:{this.stateInClosingTagName(e);break}case _.BeforeTagName:{this.stateBeforeTagName(e);break}case _.AfterAttributeName:{this.stateAfterAttributeName(e);break}case _.InAttributeValueSq:{this.stateInAttributeValueSingleQuotes(e);break}case _.BeforeAttributeValue:{this.stateBeforeAttributeValue(e);break}case _.BeforeClosingTagName:{this.stateBeforeClosingTagName(e);break}case _.AfterClosingTagName:{this.stateAfterClosingTagName(e);break}case _.BeforeSpecialS:{this.stateBeforeSpecialS(e);break}case _.BeforeSpecialT:{this.stateBeforeSpecialT(e);break}case _.InAttributeValueNq:{this.stateInAttributeValueNoQuotes(e);break}case _.InSelfClosingTag:{this.stateInSelfClosingTag(e);break}case _.InDeclaration:{this.stateInDeclaration(e);break}case _.BeforeDeclaration:{this.stateBeforeDeclaration(e);break}case _.BeforeComment:{this.stateBeforeComment(e);break}case _.InProcessingInstruction:{this.stateInProcessingInstruction(e);break}case _.InEntity:{this.stateInEntity();break}}this.index++}this.cleanup()}finish(){this.state===_.InEntity&&(this.entityDecoder.end(),this.state=this.baseState),this.handleTrailingData(),this.cbs.onend()}handleTrailingData(){const e=this.buffer.length+this.offset;this.sectionStart>=e||(this.state===_.InCommentLike?this.currentSequence===SA.CdataEnd?this.cbs.oncdata(this.sectionStart,e,0):this.cbs.oncomment(this.sectionStart,e,0):this.state===_.InTagName||this.state===_.BeforeAttributeName||this.state===_.BeforeAttributeValue||this.state===_.AfterAttributeName||this.state===_.InAttributeName||this.state===_.InAttributeValueSq||this.state===_.InAttributeValueDq||this.state===_.InAttributeValueNq||this.state===_.InClosingTagName||this.cbs.ontext(this.sectionStart,e))}emitCodePoint(e,t){this.baseState!==_.Text&&this.baseState!==_.InSpecialTag?(this.sectionStart<this.entityStart&&this.cbs.onattribdata(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+t,this.index=this.sectionStart-1,this.cbs.onattribentity(e)):(this.sectionStart<this.entityStart&&this.cbs.ontext(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+t,this.index=this.sectionStart-1,this.cbs.ontextentity(e,this.sectionStart))}};const Et=new Set(["input","option","optgroup","select","button","datalist","textarea"]),aA=new Set(["p"]),Ao=new Set(["thead","tbody"]),eo=new Set(["dd","dt"]),to=new Set(["rt","rp"]),Zg=new Map([["tr",new Set(["tr","th","td"])],["th",new Set(["th"])],["td",new Set(["thead","th","td"])],["body",new Set(["head","link","script"])],["li",new Set(["li"])],["p",aA],["h1",aA],["h2",aA],["h3",aA],["h4",aA],["h5",aA],["h6",aA],["select",Et],["input",Et],["output",Et],["button",Et],["datalist",Et],["textarea",Et],["option",new Set(["option"])],["optgroup",new Set(["optgroup","option"])],["dd",eo],["dt",eo],["address",aA],["article",aA],["aside",aA],["blockquote",aA],["details",aA],["div",aA],["dl",aA],["fieldset",aA],["figcaption",aA],["figure",aA],["footer",aA],["form",aA],["header",aA],["hr",aA],["main",aA],["nav",aA],["ol",aA],["pre",aA],["section",aA],["table",aA],["ul",aA],["rt",to],["rp",to],["tbody",Ao],["tfoot",Ao]]),$g=new Set(["area","base","basefont","br","col","command","embed","frame","hr","img","input","isindex","keygen","link","meta","param","source","track","wbr"]),ro=new Set(["math","svg"]),no=new Set(["mi","mo","mn","ms","mtext","annotation-xml","foreignobject","desc","title"]),zg=/\s|\//;let AE=class{constructor(e,t={}){var r,n,s,a,u,o;this.options=t,this.startIndex=0,this.endIndex=0,this.openTagStart=0,this.tagname="",this.attribname="",this.attribvalue="",this.attribs=null,this.stack=[],this.buffers=[],this.bufferOffset=0,this.writeIndex=0,this.ended=!1,this.cbs=e??{},this.htmlMode=!this.options.xmlMode,this.lowerCaseTagNames=(r=t.lowerCaseTags)!==null&&r!==void 0?r:this.htmlMode,this.lowerCaseAttributeNames=(n=t.lowerCaseAttributeNames)!==null&&n!==void 0?n:this.htmlMode,this.recognizeSelfClosing=(s=t.recognizeSelfClosing)!==null&&s!==void 0?s:!this.htmlMode,this.tokenizer=new((a=t.Tokenizer)!==null&&a!==void 0?a:jg)(this.options,this),this.foreignContext=[!this.htmlMode],(o=(u=this.cbs).onparserinit)===null||o===void 0||o.call(u,this)}ontext(e,t){var r,n;const s=this.getSlice(e,t);this.endIndex=t-1,(n=(r=this.cbs).ontext)===null||n===void 0||n.call(r,s),this.startIndex=t}ontextentity(e,t){var r,n;this.endIndex=t-1,(n=(r=this.cbs).ontext)===null||n===void 0||n.call(r,hs(e)),this.startIndex=t}isVoidElement(e){return this.htmlMode&&$g.has(e)}onopentagname(e,t){this.endIndex=t;let r=this.getSlice(e,t);this.lowerCaseTagNames&&(r=r.toLowerCase()),this.emitOpenTag(r)}emitOpenTag(e){var t,r,n,s;this.openTagStart=this.startIndex,this.tagname=e;const a=this.htmlMode&&Zg.get(e);if(a)for(;this.stack.length>0&&a.has(this.stack[0]);){const u=this.stack.shift();(r=(t=this.cbs).onclosetag)===null||r===void 0||r.call(t,u,!0)}this.isVoidElement(e)||(this.stack.unshift(e),this.htmlMode&&(ro.has(e)?this.foreignContext.unshift(!0):no.has(e)&&this.foreignContext.unshift(!1))),(s=(n=this.cbs).onopentagname)===null||s===void 0||s.call(n,e),this.cbs.onopentag&&(this.attribs={})}endOpenTag(e){var t,r;this.startIndex=this.openTagStart,this.attribs&&((r=(t=this.cbs).onopentag)===null||r===void 0||r.call(t,this.tagname,this.attribs,e),this.attribs=null),this.cbs.onclosetag&&this.isVoidElement(this.tagname)&&this.cbs.onclosetag(this.tagname,!0),this.tagname=""}onopentagend(e){this.endIndex=e,this.endOpenTag(!1),this.startIndex=e+1}onclosetag(e,t){var r,n,s,a,u,o,c,f;this.endIndex=t;let h=this.getSlice(e,t);if(this.lowerCaseTagNames&&(h=h.toLowerCase()),this.htmlMode&&(ro.has(h)||no.has(h))&&this.foreignContext.shift(),this.isVoidElement(h))this.htmlMode&&h==="br"&&((a=(s=this.cbs).onopentagname)===null||a===void 0||a.call(s,"br"),(o=(u=this.cbs).onopentag)===null||o===void 0||o.call(u,"br",{},!0),(f=(c=this.cbs).onclosetag)===null||f===void 0||f.call(c,"br",!1));else{const d=this.stack.indexOf(h);if(d!==-1)for(let C=0;C<=d;C++){const m=this.stack.shift();(n=(r=this.cbs).onclosetag)===null||n===void 0||n.call(r,m,C!==d)}else this.htmlMode&&h==="p"&&(this.emitOpenTag("p"),this.closeCurrentTag(!0))}this.startIndex=t+1}onselfclosingtag(e){this.endIndex=e,this.recognizeSelfClosing||this.foreignContext[0]?(this.closeCurrentTag(!1),this.startIndex=e+1):this.onopentagend(e)}closeCurrentTag(e){var t,r;const n=this.tagname;this.endOpenTag(e),this.stack[0]===n&&((r=(t=this.cbs).onclosetag)===null||r===void 0||r.call(t,n,!e),this.stack.shift())}onattribname(e,t){this.startIndex=e;const r=this.getSlice(e,t);this.attribname=this.lowerCaseAttributeNames?r.toLowerCase():r}onattribdata(e,t){this.attribvalue+=this.getSlice(e,t)}onattribentity(e){this.attribvalue+=hs(e)}onattribend(e,t){var r,n;this.endIndex=t,(n=(r=this.cbs).onattribute)===null||n===void 0||n.call(r,this.attribname,this.attribvalue,e===he.Double?'"':e===he.Single?"'":e===he.NoValue?void 0:null),this.attribs&&!Object.prototype.hasOwnProperty.call(this.attribs,this.attribname)&&(this.attribs[this.attribname]=this.attribvalue),this.attribvalue=""}getInstructionName(e){const t=e.search(zg);let r=t<0?e:e.substr(0,t);return this.lowerCaseTagNames&&(r=r.toLowerCase()),r}ondeclaration(e,t){this.endIndex=t;const r=this.getSlice(e,t);if(this.cbs.onprocessinginstruction){const n=this.getInstructionName(r);this.cbs.onprocessinginstruction(`!${n}`,`!${r}`)}this.startIndex=t+1}onprocessinginstruction(e,t){this.endIndex=t;const r=this.getSlice(e,t);if(this.cbs.onprocessinginstruction){const n=this.getInstructionName(r);this.cbs.onprocessinginstruction(`?${n}`,`?${r}`)}this.startIndex=t+1}oncomment(e,t,r){var n,s,a,u;this.endIndex=t,(s=(n=this.cbs).oncomment)===null||s===void 0||s.call(n,this.getSlice(e,t-r)),(u=(a=this.cbs).oncommentend)===null||u===void 0||u.call(a),this.startIndex=t+1}oncdata(e,t,r){var n,s,a,u,o,c,f,h,d,C;this.endIndex=t;const m=this.getSlice(e,t-r);!this.htmlMode||this.options.recognizeCDATA?((s=(n=this.cbs).oncdatastart)===null||s===void 0||s.call(n),(u=(a=this.cbs).ontext)===null||u===void 0||u.call(a,m),(c=(o=this.cbs).oncdataend)===null||c===void 0||c.call(o)):((h=(f=this.cbs).oncomment)===null||h===void 0||h.call(f,`[CDATA[${m}]]`),(C=(d=this.cbs).oncommentend)===null||C===void 0||C.call(d)),this.startIndex=t+1}onend(){var e,t;if(this.cbs.onclosetag){this.endIndex=this.startIndex;for(let r=0;r<this.stack.length;r++)this.cbs.onclosetag(this.stack[r],!0)}(t=(e=this.cbs).onend)===null||t===void 0||t.call(e)}reset(){var e,t,r,n;(t=(e=this.cbs).onreset)===null||t===void 0||t.call(e),this.tokenizer.reset(),this.tagname="",this.attribname="",this.attribs=null,this.stack.length=0,this.startIndex=0,this.endIndex=0,(n=(r=this.cbs).onparserinit)===null||n===void 0||n.call(r,this),this.buffers.length=0,this.foreignContext.length=0,this.foreignContext.unshift(!this.htmlMode),this.bufferOffset=0,this.writeIndex=0,this.ended=!1}parseComplete(e){this.reset(),this.end(e)}getSlice(e,t){for(;e-this.bufferOffset>=this.buffers[0].length;)this.shiftBuffer();let r=this.buffers[0].slice(e-this.bufferOffset,t-this.bufferOffset);for(;t-this.bufferOffset>this.buffers[0].length;)this.shiftBuffer(),r+=this.buffers[0].slice(0,t-this.bufferOffset);return r}shiftBuffer(){this.bufferOffset+=this.buffers[0].length,this.writeIndex--,this.buffers.shift()}write(e){var t,r;if(this.ended){(r=(t=this.cbs).onerror)===null||r===void 0||r.call(t,new Error(".write() after done!"));return}this.buffers.push(e),this.tokenizer.running&&(this.tokenizer.write(e),this.writeIndex++)}end(e){var t,r;if(this.ended){(r=(t=this.cbs).onerror)===null||r===void 0||r.call(t,new Error(".end() after done!"));return}e&&this.write(e),this.ended=!0,this.tokenizer.end()}pause(){this.tokenizer.pause()}resume(){for(this.tokenizer.resume();this.tokenizer.running&&this.writeIndex<this.buffers.length;)this.tokenizer.write(this.buffers[this.writeIndex++]);this.ended&&this.tokenizer.end()}parseChunk(e){this.write(e)}done(e){this.end(e)}};function eE(A,e){const t=new t0(void 0,e);return new AE(t,e).end(A),t.root}const tE=Sh((A,e,t,r)=>e._useHtmlParser2?eE(A,e):Xg(A,e,t,r)),so=cd(tE,(A,e)=>e._useHtmlParser2?Lr(A,e):Jg(A));var q=(A=>(A[A.None=0]="None",A[A.Text=1]="Text",A[A.Image=2]="Image",A[A.Video=3]="Video",A[A.Icon=4]="Icon",A[A.Link=5]="Link",A[A.Button=6]="Button",A[A.Block=10]="Block",A))(q||{}),ae;(A=>{A.THEME_TEXT_COLOR_CLASS="gp-designer-theme-text",A.THEME_BUTTON_COLOR_CLASS="gp-designer-theme-button",A.THEME_ICON_COLOR_CLASS="gp-designer-theme-icon",A.THEME_COLOR="#3574e6"})(ae||(ae={}));const rE={key:0,"date-action":"1",contenteditable:"false",class:"text-red-500 text-xs mt-1"},nE=l.defineComponent({__name:"ElementRenderer",props:{element:{type:Object,required:!0},selectedElement:Object,hoveredElement:Object,uploadByFile:{type:Function,required:!1},icons:{type:Array,default:()=>[]},mode:{type:String,default:"edit"},cropper:{type:Object,required:!1},icon:{type:Object,required:!1},upload:{type:Object,required:!1},r:{type:String,required:!1}},emits:["selectElement","hoverElement","updateText","contentUpdated","blockAction","addIcon"],setup(A,{emit:e}){const t=A,r=e,n=l.computed(()=>t.selectedElement===t.element),s=l.computed(()=>t.hoveredElement===t.element),a=l.ref(!1),u=l.ref(!1),o=l.ref(""),c=l.computed(()=>t.element.rule.minText||0),f=l.computed(()=>t.element.rule.maxText||1/0);l.watch(()=>t.r,()=>{r("contentUpdated",Q())},{immediate:!0});function h(R){R.xpath!="/div[1]"&&t.mode!=="preview"&&(t.mode==="edit"?R.type===q.Text&&r("selectElement",R):r("selectElement",R),!R.rule.isReadOnly&&R.type===q.Text&&(a.value=!0))}function d(R){r("selectElement",R)}function C(R,P){r("hoverElement",R,P)}function m(R){r("hoverElement",R)}function T(R){R.currentTarget.contains(R.relatedTarget)?r("hoverElement",null):t.hoveredElement?r("hoverElement",null,t.hoveredElement.parentxpath):r("hoverElement",null)}function F(){a.value=!1,r("contentUpdated",Q())}function Q(){function R(z){var PA;const rA=z,lA=rA.rule.isThemeColor&&rA.type==q.Text?ae.THEME_TEXT_COLOR_CLASS:rA.rule.isThemeColor&&rA.type==q.Button?ae.THEME_BUTTON_COLOR_CLASS:rA.rule.isThemeColor&&rA.type==q.Icon?ae.THEME_ICON_COLOR_CLASS:"";lA?rA.attrs.class=rA.attrs.class?rA.attrs.class+" "+lA:lA:rA.attrs.class=(PA=rA.attrs.class)==null?void 0:PA.replace(new RegExp(`${ae.THEME_TEXT_COLOR_CLASS}|${ae.THEME_BUTTON_COLOR_CLASS}|${ae.THEME_ICON_COLOR_CLASS}`,"g"),"");const UA=Object.entries(z.attrs||{}).map(([wA,ce])=>`${wA}="${ce}"`).join(" "),HA=`<${z.tag}${UA?" "+UA:""}>`,RA=`</${z.tag}>`,QA=(z.children||[]).map(wA=>R(wA)).join("");return`${HA}${z.editText||z.text||""}${QA}${RA}`}return R(t.element)}function I(R){var lA;R.stopPropagation();const P=R.target,z=((lA=P.firstChild)==null?void 0:lA.nodeType)===Node.TEXT_NODE&&P.firstChild.nodeValue||"";if(z.length<c.value){u.value=!0,o.value=`最少输入 ${c.value} 个字符`;return}else if(z.length>f.value){u.value=!0,o.value=`最多输入 ${f.value} 个字符`;return}else u.value=!1,o.value="";r("updateText",{element:t.element,newText:z}),r("contentUpdated",Q());const rA=l.toRaw(t.element);rA.editText=z}function H(R){r("updateText",R),r("contentUpdated",Q())}function M(){const R={...t.element};r("blockAction",{action:"add",element:t.element,newBlock:R})}function y(){p(t.element),r("blockAction",{action:"moveUp",element:t.element})}function p(R){R.children&&R.children.length>0&&R.children.forEach(P=>{P.type==q.Text&&(P.text!==P.editText&&(P.text=P.editText),p(P))})}function v(){p(t.element),r("blockAction",{action:"moveDown",element:t.element})}function k(){r("blockAction",{action:"delete",element:t.element})}function O(R){r("blockAction",R),r("contentUpdated",Q())}function AA(R){W.value.openModal(R)}function oA(R){tA.value.openModal(R)}function cA(R,P){r("addIcon",R,P),r("contentUpdated",Q())}const W=l.ref(t.icon);l.watch(()=>t.icon,R=>{W.value=R},{immediate:!0});const tA=l.ref(t.upload);return l.watch(()=>t.upload,R=>{tA.value=R},{immediate:!0}),(R,P)=>{const z=l.resolveComponent("ElementRenderer",!0);return l.openBlock(),l.createElementBlock(l.Fragment,null,[(l.openBlock(),l.createBlock(l.resolveDynamicComponent(t.element.tag),l.mergeProps({class:["relative",A.mode==="design"?"m-2 p-1 border-dashed border-2":"",s.value?"border-dashed border-blue-500":"",n.value?"border-dashed border-green-500 z-10 border-2":"",u.value?"border-dashed border-red-500":"",(!s.value&&!n.value&&!u.value,""),t.element.rule&&t.element.rule.isReadOnly?"cursor-not-allowed":"",t.element.rule.isThemeColor&&t.element.type===l.unref(q).Text?l.unref(ae).THEME_TEXT_COLOR_CLASS:"",t.element.rule.isThemeColor&&t.element.type===l.unref(q).Button?l.unref(ae).THEME_BUTTON_COLOR_CLASS:"",t.element.rule.isThemeColor&&t.element.type===l.unref(q).Icon?l.unref(ae).THEME_ICON_COLOR_CLASS:""]},t.element.attrs,{contenteditable:a.value,onClick:P[2]||(P[2]=l.withModifiers(()=>h(t.element),["stop"])),onMouseenter:P[3]||(P[3]=()=>m(t.element)),onMouseleave:T,onBlur:F,onInput:I}),{default:l.withCtx(()=>[l.createTextVNode(l.toDisplayString(t.element.text),1),t.element.children&&t.element.children.length?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(t.element.children,(rA,lA)=>(l.openBlock(),l.createBlock(z,{key:lA,r:A.r,mode:A.mode,icons:A.icons,element:rA,selectedElement:t.selectedElement,hoveredElement:t.hoveredElement,cropper:A.cropper,icon:A.icon,upload:A.upload,"upload-by-file":A.uploadByFile,onSelectElement:d,onHoverElement:C,onUpdateText:H,onBlockAction:O,onAddIcon:cA},null,8,["r","mode","icons","element","selectedElement","hoveredElement","cropper","icon","upload","upload-by-file"]))),128)),t.element.type===l.unref(q).Block?(l.openBlock(),l.createElementBlock("div",{key:0,"date-action":"1",contenteditable:"false",onClick:P[0]||(P[0]=l.withModifiers(()=>{},["stop"])),class:"z-10 flex space-x-1 flex-none flex-nowrap overflow-visible absolute left-2 top-2 text-sm"},[l.createElementVNode("button",{class:"flex-none content-center items-center p-1 bg-green-500/80 text-white rounded hover:bg-green-500",onClick:l.withModifiers(M,["stop"])},P[6]||(P[6]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("rect",{width:"336",height:"336",x:"128",y:"128",fill:"none",stroke:"white","stroke-linejoin":"round","stroke-width":"32",rx:"57",ry:"57"}),l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"m383.5 128l.5-24a56.16 56.16 0 0 0-56-56H112a64.19 64.19 0 0 0-64 64v216a56.16 56.16 0 0 0 56 56h24"})],-1)])),l.createElementVNode("button",{class:"flex-none content-center items-center p-1 bg-blue-500/80 text-white rounded hover:bg-blue-500",onClick:l.withModifiers(y,["stop"])},P[7]||(P[7]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"48",d:"M244 400L100 256l144-144M120 256h292"})],-1)])),l.createElementVNode("button",{class:"flex-none content-center items-center p-1 bg-blue-500/80 text-white rounded hover:bg-blue-500",onClick:l.withModifiers(v,["stop"])},P[8]||(P[8]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"48",d:"m268 112l144 144l-144 144m124-144H100"})],-1)])),l.createElementVNode("button",{class:"flex-none content-center items-center p-1 bg-red-500/80 text-white rounded hover:bg-red-500",onClick:l.withModifiers(k,["stop"])},P[9]||(P[9]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M400 256H112"})],-1)]))])):l.createCommentVNode("",!0)],64)):l.createCommentVNode("",!0),t.element.type===l.unref(q).Icon?(l.openBlock(),l.createElementBlock("div",{key:1,class:"cursor-pointer rounded-sm w-5 h-5 flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-sm text-gray-50 z-10 bg-black/80 hover:bg-black",contenteditable:"false",onClick:P[1]||(P[1]=l.withModifiers(()=>AA(t.element),["stop"]))},P[10]||(P[10]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M320 367.79h76c55 0 100-29.21 100-83.6s-53-81.47-96-83.6c-8.89-85.06-71-136.8-144-136.8c-69 0-113.44 45.79-128 91.2c-60 5.7-112 43.88-112 106.4s54 106.4 120 106.4h56"}),l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"m320 255.79l-64-64l-64 64m64 192.42V207.79"})],-1)]))):l.createCommentVNode("",!0)]),_:1},16,["class","contenteditable"])),t.element.type==l.unref(q).Text&&u.value?(l.openBlock(),l.createElementBlock("div",rE,l.toDisplayString(o.value),1)):l.createCommentVNode("",!0),t.element.type===l.unref(q).Image?(l.openBlock(),l.createElementBlock("div",{key:1,class:"cursor-pointer rounded-sm flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-sm text-gray-50 z-10 bg-black/80 hover:bg-black",onClick:P[5]||(P[5]=l.withModifiers(()=>{},["stop"])),contenteditable:"false"},[l.createElementVNode("div",{class:"p-1",onClick:P[4]||(P[4]=l.withModifiers(()=>oA(t.element),["stop"]))},P[11]||(P[11]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M320 367.79h76c55 0 100-29.21 100-83.6s-53-81.47-96-83.6c-8.89-85.06-71-136.8-144-136.8c-69 0-113.44 45.79-128 91.2c-60 5.7-112 43.88-112 106.4s54 106.4 120 106.4h56"}),l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"m320 255.79l-64-64l-64 64m64 192.42V207.79"})],-1)]))])):l.createCommentVNode("",!0)],64)}}}),He=(A,e)=>{const t=A.__vccOpts||A;for(const[r,n]of e)t[r]=n;return t},sE=He(nE,[["__scopeId","data-v-1786f281"]]),aE=l.defineComponent({name:"GpCheckbox",props:{modelValue:{type:Boolean,required:!0},label:{type:String,default:""}},emits:["update:modelValue"],setup(A,{emit:e}){return{updateValue:r=>{e("update:modelValue",r.target.checked)}}}}),iE={class:"form-group"},uE={class:"flex items-center space-x-2 cursor-pointer"},oE=["checked","aria-checked"],cE={class:"checkbox-label text-sm text-gray-700"};function lE(A,e,t,r,n,s){return l.openBlock(),l.createElementBlock("div",iE,[l.createElementVNode("label",uE,[l.createElementVNode("input",{type:"checkbox",checked:A.modelValue,onChange:e[0]||(e[0]=(...a)=>A.updateValue&&A.updateValue(...a)),class:"custom-checkbox","aria-checked":A.modelValue},null,40,oE),l.createElementVNode("span",cE,l.toDisplayString(A.label),1)])])}const tr=He(aE,[["render",lE],["__scopeId","data-v-68b8f276"]]),fE=l.defineComponent({name:"GpMessage",props:{message:{type:String,required:!0},type:{type:String,default:"info"},position:{type:String,default:"top-right"},duration:{type:Number,default:3e3},onClose:{type:Function,required:!0},icon:{type:Boolean,default:!0}},setup(A){const e=l.ref(!1),t=l.computed(()=>({success:"bg-green-100 text-green-800",error:"bg-red-100 text-red-800",info:"bg-blue-100 text-blue-800",warning:"bg-yellow-100 text-yellow-800"})[A.type]),r=()=>{e.value=!1,A.onClose()};return setTimeout(()=>{r()},A.duration),e.value=!0,{visible:e,typeClass:t,closeMessage:r}}}),hE={key:0,class:"gp-message"},dE={key:0,class:"mr-2"},BE={key:0,class:"text-green-500"},gE={key:1,class:"text-red-500"},EE={key:2,class:"text-blue-500"},pE={key:3,class:"text-yellow-500"};function mE(A,e,t,r,n,s){return l.openBlock(),l.createBlock(l.Transition,{name:"fade"},{default:l.withCtx(()=>[A.visible?(l.openBlock(),l.createElementBlock("div",hE,[l.createElementVNode("div",{class:l.normalizeClass([A.typeClass,"message-content"])},[A.icon?(l.openBlock(),l.createElementBlock("span",dE,[l.renderSlot(A.$slots,"icon",{},()=>[A.type==="success"?(l.openBlock(),l.createElementBlock("span",BE,"✔")):l.createCommentVNode("",!0),A.type==="error"?(l.openBlock(),l.createElementBlock("span",gE,"✖")):l.createCommentVNode("",!0),A.type==="info"?(l.openBlock(),l.createElementBlock("span",EE,"ℹ")):l.createCommentVNode("",!0),A.type==="warning"?(l.openBlock(),l.createElementBlock("span",pE,"⚠")):l.createCommentVNode("",!0)],!0)])):l.createCommentVNode("",!0),l.createElementVNode("span",null,l.toDisplayString(A.message),1),l.createElementVNode("button",{class:"close-btn hover:text-gray-800 font-bold",onClick:e[0]||(e[0]=(...a)=>A.closeMessage&&A.closeMessage(...a))}," × ")],2)])):l.createCommentVNode("",!0)]),_:3})}const CE=He(fE,[["render",mE],["__scopeId","data-v-12cd136f"]]),pt=l.reactive([]);let js=null;const wE=()=>{const A=document.createElement("div");return A.id="global-message-container",document.body.appendChild(A),A},TE=()=>{if(js)return;const A=wE();js=l.createApp({setup(){return{messageQueue:pt}},render(){const e=l.computed(()=>{var r;return{"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4","top-center":"top-4 left-1/2 transform -translate-x-1/2","bottom-center":"bottom-4 left-1/2 transform -translate-x-1/2"}[((r=pt[0])==null?void 0:r.options.position)||"top-right"]});return l.h("div",{class:`fixed flex flex-col gap-2 ${e.value}`},pt.map(t=>l.h(CE,{key:t.id,...t.options,onClose:()=>ao(t.id)})))}}),js.mount(A)},ao=A=>{const e=pt.findIndex(t=>t.id===A);e!==-1&&pt.splice(e,1)};let bE=0;const j=A=>{TE();const e=bE++;pt.push({id:e,options:A}),setTimeout(()=>{ao(e)},A.duration||3e3)};j.success=(A,e=3e3,t=!0)=>{j(typeof A=="string"?{message:A,type:"success",duration:e,icon:t}:{...A,type:"success"})},j.error=(A,e=3e3,t=!0)=>{j(typeof A=="string"?{message:A,type:"error",duration:e,icon:t}:{...A,type:"error"})},j.info=(A,e=3e3,t=!0)=>{j(typeof A=="string"?{message:A,type:"info",duration:e,icon:t}:{...A,type:"info"})},j.warning=(A,e=3e3,t=!0)=>{j(typeof A=="string"?{message:A,type:"warning",duration:e,icon:t}:{...A,type:"warning"})};const UE={key:0},QE={key:0},FE={class:"text-gray-500 my-2"},IE={class:"text-gray-500 my-2"},_E={key:1},yE={key:2},NE={key:3},SE={key:4},vE={key:5},LE={key:6},HE={key:7},xE={key:8},DE={key:9},OE={key:10},RE=He(l.defineComponent({__name:"EditorPanel",props:{element:Object},emits:["updateElement"],setup(A,{emit:e}){const t=A,r=e,n=l.ref({rule:{},...t.element});l.watch(()=>t.element,a=>{n.value={rule:{},...a}},{immediate:!0});function s(){if(n.value.type===q.Icon&&!n.value.attrs.class.includes("iconfont")){j.error("图标仅支持 iconfont 图标");return}if(n.value.type===q.Image&&n.value.tag!=="img"){j.error("节点类型错误");return}if(n.value.type===q.Video&&n.value.tag!=="video"){j.error("节点类型错误");return}if(n.value.type===q.Link&&n.value.tag!=="a"){j.error("节点类型错误");return}if(n.value.type===q.Text){if(Number(n.value.rule.minText)>Number(n.value.rule.maxText)){j.error("最小文本长度不能大于最大文本长度");return}if(n.value.tag!=="p"&&n.value.tag!=="div"&&n.value.tag!=="span"&&n.value.tag!=="h1"&&n.value.tag!=="h2"&&n.value.tag!=="h3"&&n.value.tag!=="h4"&&n.value.tag!=="h5"&&n.value.tag!=="h6"){j.error("节点类型错误");return}}if(n.value.type===q.Block){if(Number(n.value.rule.minBlock)>Number(n.value.rule.maxBlock)){j.error("最小块数量不能大于最大块数量");return}if(n.value.tag!=="div"&&n.value.tag!=="section"&&n.value.tag!=="article"&&n.value.tag!=="nav"&&n.value.tag!=="header"&&n.value.tag!=="footer"&&n.value.tag!=="span"&&n.value.tag!=="p"&&n.value.tag!=="img"){j.error("节点类型错误");return}if(!n.value.children||n.value.children.length<1){j.error("节点错误,必须包含子元素");return}}r("updateElement",n.value)}return(a,u)=>(l.openBlock(),l.createElementBlock("div",null,[n.value?(l.openBlock(),l.createElementBlock("div",UE,[n.value.text!==void 0?(l.openBlock(),l.createElementBlock("div",QE,[u[13]||(u[13]=l.createElementVNode("label",{class:"block"},"内容",-1)),l.createElementVNode("div",FE,l.toDisplayString(n.value.text||"-"),1)])):l.createCommentVNode("",!0),l.createElementVNode("div",null,[u[14]||(u[14]=l.createElementVNode("label",{class:"block mt-4"},"节点",-1)),l.createElementVNode("div",IE,l.toDisplayString(n.value.xpath),1)]),l.createElementVNode("div",null,[u[16]||(u[16]=l.createElementVNode("label",{class:"block mt-4"},"类型",-1)),l.withDirectives(l.createElementVNode("select",{"onUpdate:modelValue":u[0]||(u[0]=o=>n.value.type=o),class:"border rounded p-1 w-full"},u[15]||(u[15]=[l.createElementVNode("option",{value:0},"无",-1),l.createElementVNode("option",{value:1},"文本",-1),l.createElementVNode("option",{value:2},"图片",-1),l.createElementVNode("option",{value:3},"视频",-1),l.createElementVNode("option",{value:4},"图标",-1),l.createElementVNode("option",{value:5},"链接",-1),l.createElementVNode("option",{value:6},"按钮",-1),l.createElementVNode("option",{value:10},"块",-1)]),512),[[l.vModelSelect,n.value.type]])]),n.value.type==l.unref(q).Text?(l.openBlock(),l.createElementBlock("div",_E,[u[17]||(u[17]=l.createElementVNode("label",{class:"block mt-4"},"最小文本长度",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[1]||(u[1]=o=>n.value.rule.minText=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.minText]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Text?(l.openBlock(),l.createElementBlock("div",yE,[u[18]||(u[18]=l.createElementVNode("label",{class:"block mt-4"},"最大文本长度",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[2]||(u[2]=o=>n.value.rule.maxText=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.maxText]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Image?(l.openBlock(),l.createElementBlock("div",NE,[u[19]||(u[19]=l.createElementVNode("label",{class:"block mt-4"},"是否裁剪",-1)),l.createVNode(tr,{class:"py-2",modelValue:n.value.rule.crop,"onUpdate:modelValue":u[3]||(u[3]=o=>n.value.rule.crop=o),label:"是"},null,8,["modelValue"])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Image?(l.openBlock(),l.createElementBlock("div",SE,[u[20]||(u[20]=l.createElementVNode("label",{class:"block mt-4"},"图片宽度",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[4]||(u[4]=o=>n.value.rule.minImageWidth=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.minImageWidth]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Image?(l.openBlock(),l.createElementBlock("div",vE,[u[21]||(u[21]=l.createElementVNode("label",{class:"block mt-4"},"图片高度",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=o=>n.value.rule.maxImageHeight=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.maxImageHeight]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Block?(l.openBlock(),l.createElementBlock("div",LE,[u[22]||(u[22]=l.createElementVNode("label",{class:"block mt-4"},"块最小数量",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[6]||(u[6]=o=>n.value.rule.minBlock=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.minBlock]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Block?(l.openBlock(),l.createElementBlock("div",HE,[u[23]||(u[23]=l.createElementVNode("label",{class:"block mt-4"},"块最大数量",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[7]||(u[7]=o=>n.value.rule.maxBlock=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.maxBlock]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Text||n.value.type==l.unref(q).Icon||n.value.type==l.unref(q).Button?(l.openBlock(),l.createElementBlock("div",xE,[u[24]||(u[24]=l.createElementVNode("label",{class:"block mt-4"},"主题色",-1)),l.createVNode(tr,{class:"py-2",modelValue:n.value.rule.isThemeColor,"onUpdate:modelValue":u[8]||(u[8]=o=>n.value.rule.isThemeColor=o),label:"是"},null,8,["modelValue"])])):l.createCommentVNode("",!0),l.createElementVNode("div",null,[u[25]||(u[25]=l.createElementVNode("label",{class:"block mt-4"},"是否必填",-1)),l.createVNode(tr,{class:"py-2",modelValue:n.value.rule.isRequired,"onUpdate:modelValue":u[9]||(u[9]=o=>n.value.rule.isRequired=o),label:"是"},null,8,["modelValue"])]),l.createElementVNode("div",null,[u[26]||(u[26]=l.createElementVNode("label",{class:"block mt-4"},"是否只读",-1)),l.createVNode(tr,{class:"py-2",modelValue:n.value.rule.isReadOnly,"onUpdate:modelValue":u[10]||(u[10]=o=>n.value.rule.isReadOnly=o),label:"是"},null,8,["modelValue"])]),n.value.type==l.unref(q).Link||n.value.type==l.unref(q).Button?(l.openBlock(),l.createElementBlock("div",DE,[u[27]||(u[27]=l.createElementVNode("label",{class:"block mt-4"},"打开美洽",-1)),l.createVNode(tr,{class:"py-2",modelValue:n.value.rule.openMeiqia,"onUpdate:modelValue":u[11]||(u[11]=o=>n.value.rule.openMeiqia=o),label:"是"},null,8,["modelValue"])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Link||n.value.type==l.unref(q).Button?(l.openBlock(),l.createElementBlock("div",OE,[u[28]||(u[28]=l.createElementVNode("label",{class:"block mt-4"},"链接",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[12]||(u[12]=o=>n.value.rule.linkUrl=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.linkUrl]])])):l.createCommentVNode("",!0)])):l.createCommentVNode("",!0),l.createElementVNode("button",{onClick:s,class:"mt-4 p-2 bg-green-500 text-white rounded"}," 保存 ")]))}}),[["__scopeId","data-v-7395db8a"]]);/*!
8
+ `)}}).toArray()}const ad=Object.freeze(Object.defineProperty({__proto__:null,serialize:nd,serializeArray:sd},Symbol.toStringTag,{value:"Module"}));function id(A){var e;return typeof A=="string"?{selector:A,value:"textContent"}:{selector:A.selector,value:(e=A.value)!==null&&e!==void 0?e:"textContent"}}function ud(A){const e={};for(const t in A){const r=A[t],n=Array.isArray(r),{selector:s,value:a}=id(n?r[0]:r),u=typeof a=="function"?a:typeof a=="string"?o=>this._make(o).prop(a):o=>this._make(o).extract(a);if(n)e[t]=this._findBySelector(s,Number.POSITIVE_INFINITY).map((o,c)=>u(c,t,e)).get();else{const o=this._findBySelector(s,1);e[t]=o.length>0?u(o[0],t,e):void 0}}return e}const od=Object.freeze(Object.defineProperty({__proto__:null,extract:ud},Symbol.toStringTag,{value:"Module"}));class Yt{constructor(e,t,r){if(this.length=0,this.options=r,this._root=t,e){for(let n=0;n<e.length;n++)this[n]=e[n];this.length=e.length}}}Yt.prototype.cheerio="[cheerio object]",Yt.prototype.splice=Array.prototype.splice,Yt.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator],Object.assign(Yt.prototype,Bf,Nh,$h,td,ad,od);function cd(A,e){return function t(r,n,s=!0){if(r==null)throw new Error("cheerio.load() expects a string");const a=Cs(n),u=A(r,a,s,null);class o extends Yt{_make(h,d){const C=c(h,d);return C.prevObject=this,C}_parse(h,d,C,m){return A(h,d,C,m)}_render(h){return e(h,this.options)}}function c(f,h,d=u,C){if(f&&Ce(f))return f;const m=Cs(C,a),T=typeof d=="string"?[A(d,m,!1,null)]:"length"in d?d:[d],F=Ce(T)?T:new o(T,null,m);if(F._root=F,!f)return new o(void 0,F,m);const Q=typeof f=="string"&&ws(f)?A(f,m,!1,null).children:ld(f)?[f]:Array.isArray(f)?f:void 0,I=new o(Q,F,m);if(Q)return I;if(typeof f!="string")throw new TypeError("Unexpected type of selector");let H=f;const M=h?typeof h=="string"?ws(h)?new o([A(h,m,!1,null)],F,m):(H=`${h} ${H}`,F):Ce(h)?h:new o(Array.isArray(h)?h:[h],F,m):F;return M?M.find(H):I}return Object.assign(c,tf,{load:t,_root:u,_options:a,fn:o.prototype,prototype:o.prototype}),c}}function ld(A){return!!A.name||A.type==="root"||A.type==="text"||A.type==="comment"}const fd=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),fA="�";var B;(function(A){A[A.EOF=-1]="EOF",A[A.NULL=0]="NULL",A[A.TABULATION=9]="TABULATION",A[A.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",A[A.LINE_FEED=10]="LINE_FEED",A[A.FORM_FEED=12]="FORM_FEED",A[A.SPACE=32]="SPACE",A[A.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",A[A.QUOTATION_MARK=34]="QUOTATION_MARK",A[A.AMPERSAND=38]="AMPERSAND",A[A.APOSTROPHE=39]="APOSTROPHE",A[A.HYPHEN_MINUS=45]="HYPHEN_MINUS",A[A.SOLIDUS=47]="SOLIDUS",A[A.DIGIT_0=48]="DIGIT_0",A[A.DIGIT_9=57]="DIGIT_9",A[A.SEMICOLON=59]="SEMICOLON",A[A.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",A[A.EQUALS_SIGN=61]="EQUALS_SIGN",A[A.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",A[A.QUESTION_MARK=63]="QUESTION_MARK",A[A.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",A[A.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",A[A.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",A[A.GRAVE_ACCENT=96]="GRAVE_ACCENT",A[A.LATIN_SMALL_A=97]="LATIN_SMALL_A",A[A.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(B||(B={}));const VA={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function hu(A){return A>=55296&&A<=57343}function hd(A){return A>=56320&&A<=57343}function dd(A,e){return(A-55296)*1024+9216+e}function du(A){return A!==32&&A!==10&&A!==13&&A!==9&&A!==12&&A>=1&&A<=31||A>=127&&A<=159}function Bu(A){return A>=64976&&A<=65007||fd.has(A)}var b;(function(A){A.controlCharacterInInputStream="control-character-in-input-stream",A.noncharacterInInputStream="noncharacter-in-input-stream",A.surrogateInInputStream="surrogate-in-input-stream",A.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",A.endTagWithAttributes="end-tag-with-attributes",A.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",A.unexpectedSolidusInTag="unexpected-solidus-in-tag",A.unexpectedNullCharacter="unexpected-null-character",A.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",A.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",A.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",A.missingEndTagName="missing-end-tag-name",A.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",A.unknownNamedCharacterReference="unknown-named-character-reference",A.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",A.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",A.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",A.eofBeforeTagName="eof-before-tag-name",A.eofInTag="eof-in-tag",A.missingAttributeValue="missing-attribute-value",A.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",A.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",A.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",A.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",A.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",A.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",A.missingDoctypePublicIdentifier="missing-doctype-public-identifier",A.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",A.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",A.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",A.cdataInHtmlContent="cdata-in-html-content",A.incorrectlyOpenedComment="incorrectly-opened-comment",A.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",A.eofInDoctype="eof-in-doctype",A.nestedComment="nested-comment",A.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",A.eofInComment="eof-in-comment",A.incorrectlyClosedComment="incorrectly-closed-comment",A.eofInCdata="eof-in-cdata",A.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",A.nullCharacterReference="null-character-reference",A.surrogateCharacterReference="surrogate-character-reference",A.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",A.controlCharacterReference="control-character-reference",A.noncharacterCharacterReference="noncharacter-character-reference",A.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",A.missingDoctypeName="missing-doctype-name",A.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",A.duplicateAttribute="duplicate-attribute",A.nonConformingDoctype="non-conforming-doctype",A.missingDoctype="missing-doctype",A.misplacedDoctype="misplaced-doctype",A.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",A.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",A.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",A.openElementsLeftAfterEof="open-elements-left-after-eof",A.abandonedHeadElementChild="abandoned-head-element-child",A.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",A.nestedNoscriptInHead="nested-noscript-in-head",A.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(b||(b={}));const Bd=65536;class gd{constructor(e){this.handler=e,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=Bd,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(e,t){const{line:r,col:n,offset:s}=this,a=n+t,u=s+t;return{code:e,startLine:r,endLine:r,startCol:a,endCol:a,startOffset:u,endOffset:u}}_err(e){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(e,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(e){if(this.pos!==this.html.length-1){const t=this.html.charCodeAt(this.pos+1);if(hd(t))return this.pos++,this._addGap(),dd(e,t)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,B.EOF;return this._err(b.surrogateInInputStream),e}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(e,t){this.html.length>0?this.html+=e:this.html=e,this.endOfChunkHit=!1,this.lastChunkWritten=t}insertHtmlAtCurrentPos(e){this.html=this.html.substring(0,this.pos+1)+e+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(e,t){if(this.pos+e.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(t)return this.html.startsWith(e,this.pos);for(let r=0;r<e.length;r++)if((this.html.charCodeAt(this.pos+r)|32)!==e.charCodeAt(r))return!1;return!0}peek(e){const t=this.pos+e;if(t>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,B.EOF;const r=this.html.charCodeAt(t);return r===B.CARRIAGE_RETURN?B.LINE_FEED:r}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,B.EOF;let e=this.html.charCodeAt(this.pos);return e===B.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,B.LINE_FEED):e===B.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,hu(e)&&(e=this._processSurrogate(e)),this.handler.onParseError===null||e>31&&e<127||e===B.LINE_FEED||e===B.CARRIAGE_RETURN||e>159&&e<64976||this._checkForProblematicCharacters(e),e)}_checkForProblematicCharacters(e){du(e)?this._err(b.controlCharacterInInputStream):Bu(e)&&this._err(b.noncharacterInInputStream)}retreat(e){for(this.pos-=e;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var eA;(function(A){A[A.CHARACTER=0]="CHARACTER",A[A.NULL_CHARACTER=1]="NULL_CHARACTER",A[A.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",A[A.START_TAG=3]="START_TAG",A[A.END_TAG=4]="END_TAG",A[A.COMMENT=5]="COMMENT",A[A.DOCTYPE=6]="DOCTYPE",A[A.EOF=7]="EOF",A[A.HIBERNATION=8]="HIBERNATION"})(eA||(eA={}));function gu(A,e){for(let t=A.attrs.length-1;t>=0;t--)if(A.attrs[t].name===e)return A.attrs[t].value;return null}var U;(function(A){A.HTML="http://www.w3.org/1999/xhtml",A.MATHML="http://www.w3.org/1998/Math/MathML",A.SVG="http://www.w3.org/2000/svg",A.XLINK="http://www.w3.org/1999/xlink",A.XML="http://www.w3.org/XML/1998/namespace",A.XMLNS="http://www.w3.org/2000/xmlns/"})(U||(U={}));var ze;(function(A){A.TYPE="type",A.ACTION="action",A.ENCODING="encoding",A.PROMPT="prompt",A.NAME="name",A.COLOR="color",A.FACE="face",A.SIZE="size"})(ze||(ze={}));var qA;(function(A){A.NO_QUIRKS="no-quirks",A.QUIRKS="quirks",A.LIMITED_QUIRKS="limited-quirks"})(qA||(qA={}));var w;(function(A){A.A="a",A.ADDRESS="address",A.ANNOTATION_XML="annotation-xml",A.APPLET="applet",A.AREA="area",A.ARTICLE="article",A.ASIDE="aside",A.B="b",A.BASE="base",A.BASEFONT="basefont",A.BGSOUND="bgsound",A.BIG="big",A.BLOCKQUOTE="blockquote",A.BODY="body",A.BR="br",A.BUTTON="button",A.CAPTION="caption",A.CENTER="center",A.CODE="code",A.COL="col",A.COLGROUP="colgroup",A.DD="dd",A.DESC="desc",A.DETAILS="details",A.DIALOG="dialog",A.DIR="dir",A.DIV="div",A.DL="dl",A.DT="dt",A.EM="em",A.EMBED="embed",A.FIELDSET="fieldset",A.FIGCAPTION="figcaption",A.FIGURE="figure",A.FONT="font",A.FOOTER="footer",A.FOREIGN_OBJECT="foreignObject",A.FORM="form",A.FRAME="frame",A.FRAMESET="frameset",A.H1="h1",A.H2="h2",A.H3="h3",A.H4="h4",A.H5="h5",A.H6="h6",A.HEAD="head",A.HEADER="header",A.HGROUP="hgroup",A.HR="hr",A.HTML="html",A.I="i",A.IMG="img",A.IMAGE="image",A.INPUT="input",A.IFRAME="iframe",A.KEYGEN="keygen",A.LABEL="label",A.LI="li",A.LINK="link",A.LISTING="listing",A.MAIN="main",A.MALIGNMARK="malignmark",A.MARQUEE="marquee",A.MATH="math",A.MENU="menu",A.META="meta",A.MGLYPH="mglyph",A.MI="mi",A.MO="mo",A.MN="mn",A.MS="ms",A.MTEXT="mtext",A.NAV="nav",A.NOBR="nobr",A.NOFRAMES="noframes",A.NOEMBED="noembed",A.NOSCRIPT="noscript",A.OBJECT="object",A.OL="ol",A.OPTGROUP="optgroup",A.OPTION="option",A.P="p",A.PARAM="param",A.PLAINTEXT="plaintext",A.PRE="pre",A.RB="rb",A.RP="rp",A.RT="rt",A.RTC="rtc",A.RUBY="ruby",A.S="s",A.SCRIPT="script",A.SEARCH="search",A.SECTION="section",A.SELECT="select",A.SOURCE="source",A.SMALL="small",A.SPAN="span",A.STRIKE="strike",A.STRONG="strong",A.STYLE="style",A.SUB="sub",A.SUMMARY="summary",A.SUP="sup",A.TABLE="table",A.TBODY="tbody",A.TEMPLATE="template",A.TEXTAREA="textarea",A.TFOOT="tfoot",A.TD="td",A.TH="th",A.THEAD="thead",A.TITLE="title",A.TR="tr",A.TRACK="track",A.TT="tt",A.U="u",A.UL="ul",A.SVG="svg",A.VAR="var",A.WBR="wbr",A.XMP="xmp"})(w||(w={}));var i;(function(A){A[A.UNKNOWN=0]="UNKNOWN",A[A.A=1]="A",A[A.ADDRESS=2]="ADDRESS",A[A.ANNOTATION_XML=3]="ANNOTATION_XML",A[A.APPLET=4]="APPLET",A[A.AREA=5]="AREA",A[A.ARTICLE=6]="ARTICLE",A[A.ASIDE=7]="ASIDE",A[A.B=8]="B",A[A.BASE=9]="BASE",A[A.BASEFONT=10]="BASEFONT",A[A.BGSOUND=11]="BGSOUND",A[A.BIG=12]="BIG",A[A.BLOCKQUOTE=13]="BLOCKQUOTE",A[A.BODY=14]="BODY",A[A.BR=15]="BR",A[A.BUTTON=16]="BUTTON",A[A.CAPTION=17]="CAPTION",A[A.CENTER=18]="CENTER",A[A.CODE=19]="CODE",A[A.COL=20]="COL",A[A.COLGROUP=21]="COLGROUP",A[A.DD=22]="DD",A[A.DESC=23]="DESC",A[A.DETAILS=24]="DETAILS",A[A.DIALOG=25]="DIALOG",A[A.DIR=26]="DIR",A[A.DIV=27]="DIV",A[A.DL=28]="DL",A[A.DT=29]="DT",A[A.EM=30]="EM",A[A.EMBED=31]="EMBED",A[A.FIELDSET=32]="FIELDSET",A[A.FIGCAPTION=33]="FIGCAPTION",A[A.FIGURE=34]="FIGURE",A[A.FONT=35]="FONT",A[A.FOOTER=36]="FOOTER",A[A.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",A[A.FORM=38]="FORM",A[A.FRAME=39]="FRAME",A[A.FRAMESET=40]="FRAMESET",A[A.H1=41]="H1",A[A.H2=42]="H2",A[A.H3=43]="H3",A[A.H4=44]="H4",A[A.H5=45]="H5",A[A.H6=46]="H6",A[A.HEAD=47]="HEAD",A[A.HEADER=48]="HEADER",A[A.HGROUP=49]="HGROUP",A[A.HR=50]="HR",A[A.HTML=51]="HTML",A[A.I=52]="I",A[A.IMG=53]="IMG",A[A.IMAGE=54]="IMAGE",A[A.INPUT=55]="INPUT",A[A.IFRAME=56]="IFRAME",A[A.KEYGEN=57]="KEYGEN",A[A.LABEL=58]="LABEL",A[A.LI=59]="LI",A[A.LINK=60]="LINK",A[A.LISTING=61]="LISTING",A[A.MAIN=62]="MAIN",A[A.MALIGNMARK=63]="MALIGNMARK",A[A.MARQUEE=64]="MARQUEE",A[A.MATH=65]="MATH",A[A.MENU=66]="MENU",A[A.META=67]="META",A[A.MGLYPH=68]="MGLYPH",A[A.MI=69]="MI",A[A.MO=70]="MO",A[A.MN=71]="MN",A[A.MS=72]="MS",A[A.MTEXT=73]="MTEXT",A[A.NAV=74]="NAV",A[A.NOBR=75]="NOBR",A[A.NOFRAMES=76]="NOFRAMES",A[A.NOEMBED=77]="NOEMBED",A[A.NOSCRIPT=78]="NOSCRIPT",A[A.OBJECT=79]="OBJECT",A[A.OL=80]="OL",A[A.OPTGROUP=81]="OPTGROUP",A[A.OPTION=82]="OPTION",A[A.P=83]="P",A[A.PARAM=84]="PARAM",A[A.PLAINTEXT=85]="PLAINTEXT",A[A.PRE=86]="PRE",A[A.RB=87]="RB",A[A.RP=88]="RP",A[A.RT=89]="RT",A[A.RTC=90]="RTC",A[A.RUBY=91]="RUBY",A[A.S=92]="S",A[A.SCRIPT=93]="SCRIPT",A[A.SEARCH=94]="SEARCH",A[A.SECTION=95]="SECTION",A[A.SELECT=96]="SELECT",A[A.SOURCE=97]="SOURCE",A[A.SMALL=98]="SMALL",A[A.SPAN=99]="SPAN",A[A.STRIKE=100]="STRIKE",A[A.STRONG=101]="STRONG",A[A.STYLE=102]="STYLE",A[A.SUB=103]="SUB",A[A.SUMMARY=104]="SUMMARY",A[A.SUP=105]="SUP",A[A.TABLE=106]="TABLE",A[A.TBODY=107]="TBODY",A[A.TEMPLATE=108]="TEMPLATE",A[A.TEXTAREA=109]="TEXTAREA",A[A.TFOOT=110]="TFOOT",A[A.TD=111]="TD",A[A.TH=112]="TH",A[A.THEAD=113]="THEAD",A[A.TITLE=114]="TITLE",A[A.TR=115]="TR",A[A.TRACK=116]="TRACK",A[A.TT=117]="TT",A[A.U=118]="U",A[A.UL=119]="UL",A[A.SVG=120]="SVG",A[A.VAR=121]="VAR",A[A.WBR=122]="WBR",A[A.XMP=123]="XMP"})(i||(i={}));const Ed=new Map([[w.A,i.A],[w.ADDRESS,i.ADDRESS],[w.ANNOTATION_XML,i.ANNOTATION_XML],[w.APPLET,i.APPLET],[w.AREA,i.AREA],[w.ARTICLE,i.ARTICLE],[w.ASIDE,i.ASIDE],[w.B,i.B],[w.BASE,i.BASE],[w.BASEFONT,i.BASEFONT],[w.BGSOUND,i.BGSOUND],[w.BIG,i.BIG],[w.BLOCKQUOTE,i.BLOCKQUOTE],[w.BODY,i.BODY],[w.BR,i.BR],[w.BUTTON,i.BUTTON],[w.CAPTION,i.CAPTION],[w.CENTER,i.CENTER],[w.CODE,i.CODE],[w.COL,i.COL],[w.COLGROUP,i.COLGROUP],[w.DD,i.DD],[w.DESC,i.DESC],[w.DETAILS,i.DETAILS],[w.DIALOG,i.DIALOG],[w.DIR,i.DIR],[w.DIV,i.DIV],[w.DL,i.DL],[w.DT,i.DT],[w.EM,i.EM],[w.EMBED,i.EMBED],[w.FIELDSET,i.FIELDSET],[w.FIGCAPTION,i.FIGCAPTION],[w.FIGURE,i.FIGURE],[w.FONT,i.FONT],[w.FOOTER,i.FOOTER],[w.FOREIGN_OBJECT,i.FOREIGN_OBJECT],[w.FORM,i.FORM],[w.FRAME,i.FRAME],[w.FRAMESET,i.FRAMESET],[w.H1,i.H1],[w.H2,i.H2],[w.H3,i.H3],[w.H4,i.H4],[w.H5,i.H5],[w.H6,i.H6],[w.HEAD,i.HEAD],[w.HEADER,i.HEADER],[w.HGROUP,i.HGROUP],[w.HR,i.HR],[w.HTML,i.HTML],[w.I,i.I],[w.IMG,i.IMG],[w.IMAGE,i.IMAGE],[w.INPUT,i.INPUT],[w.IFRAME,i.IFRAME],[w.KEYGEN,i.KEYGEN],[w.LABEL,i.LABEL],[w.LI,i.LI],[w.LINK,i.LINK],[w.LISTING,i.LISTING],[w.MAIN,i.MAIN],[w.MALIGNMARK,i.MALIGNMARK],[w.MARQUEE,i.MARQUEE],[w.MATH,i.MATH],[w.MENU,i.MENU],[w.META,i.META],[w.MGLYPH,i.MGLYPH],[w.MI,i.MI],[w.MO,i.MO],[w.MN,i.MN],[w.MS,i.MS],[w.MTEXT,i.MTEXT],[w.NAV,i.NAV],[w.NOBR,i.NOBR],[w.NOFRAMES,i.NOFRAMES],[w.NOEMBED,i.NOEMBED],[w.NOSCRIPT,i.NOSCRIPT],[w.OBJECT,i.OBJECT],[w.OL,i.OL],[w.OPTGROUP,i.OPTGROUP],[w.OPTION,i.OPTION],[w.P,i.P],[w.PARAM,i.PARAM],[w.PLAINTEXT,i.PLAINTEXT],[w.PRE,i.PRE],[w.RB,i.RB],[w.RP,i.RP],[w.RT,i.RT],[w.RTC,i.RTC],[w.RUBY,i.RUBY],[w.S,i.S],[w.SCRIPT,i.SCRIPT],[w.SEARCH,i.SEARCH],[w.SECTION,i.SECTION],[w.SELECT,i.SELECT],[w.SOURCE,i.SOURCE],[w.SMALL,i.SMALL],[w.SPAN,i.SPAN],[w.STRIKE,i.STRIKE],[w.STRONG,i.STRONG],[w.STYLE,i.STYLE],[w.SUB,i.SUB],[w.SUMMARY,i.SUMMARY],[w.SUP,i.SUP],[w.TABLE,i.TABLE],[w.TBODY,i.TBODY],[w.TEMPLATE,i.TEMPLATE],[w.TEXTAREA,i.TEXTAREA],[w.TFOOT,i.TFOOT],[w.TD,i.TD],[w.TH,i.TH],[w.THEAD,i.THEAD],[w.TITLE,i.TITLE],[w.TR,i.TR],[w.TRACK,i.TRACK],[w.TT,i.TT],[w.U,i.U],[w.UL,i.UL],[w.SVG,i.SVG],[w.VAR,i.VAR],[w.WBR,i.WBR],[w.XMP,i.XMP]]);function qr(A){var e;return(e=Ed.get(A))!==null&&e!==void 0?e:i.UNKNOWN}const S=i,pd={[U.HTML]:new Set([S.ADDRESS,S.APPLET,S.AREA,S.ARTICLE,S.ASIDE,S.BASE,S.BASEFONT,S.BGSOUND,S.BLOCKQUOTE,S.BODY,S.BR,S.BUTTON,S.CAPTION,S.CENTER,S.COL,S.COLGROUP,S.DD,S.DETAILS,S.DIR,S.DIV,S.DL,S.DT,S.EMBED,S.FIELDSET,S.FIGCAPTION,S.FIGURE,S.FOOTER,S.FORM,S.FRAME,S.FRAMESET,S.H1,S.H2,S.H3,S.H4,S.H5,S.H6,S.HEAD,S.HEADER,S.HGROUP,S.HR,S.HTML,S.IFRAME,S.IMG,S.INPUT,S.LI,S.LINK,S.LISTING,S.MAIN,S.MARQUEE,S.MENU,S.META,S.NAV,S.NOEMBED,S.NOFRAMES,S.NOSCRIPT,S.OBJECT,S.OL,S.P,S.PARAM,S.PLAINTEXT,S.PRE,S.SCRIPT,S.SECTION,S.SELECT,S.SOURCE,S.STYLE,S.SUMMARY,S.TABLE,S.TBODY,S.TD,S.TEMPLATE,S.TEXTAREA,S.TFOOT,S.TH,S.THEAD,S.TITLE,S.TR,S.TRACK,S.UL,S.WBR,S.XMP]),[U.MATHML]:new Set([S.MI,S.MO,S.MN,S.MS,S.MTEXT,S.ANNOTATION_XML]),[U.SVG]:new Set([S.TITLE,S.FOREIGN_OBJECT,S.DESC]),[U.XLINK]:new Set,[U.XML]:new Set,[U.XMLNS]:new Set},Ps=new Set([S.H1,S.H2,S.H3,S.H4,S.H5,S.H6]),md=new Set([w.STYLE,w.SCRIPT,w.XMP,w.IFRAME,w.NOEMBED,w.NOFRAMES,w.PLAINTEXT]);function Cd(A,e){return md.has(A)||e&&A===w.NOSCRIPT}var g;(function(A){A[A.DATA=0]="DATA",A[A.RCDATA=1]="RCDATA",A[A.RAWTEXT=2]="RAWTEXT",A[A.SCRIPT_DATA=3]="SCRIPT_DATA",A[A.PLAINTEXT=4]="PLAINTEXT",A[A.TAG_OPEN=5]="TAG_OPEN",A[A.END_TAG_OPEN=6]="END_TAG_OPEN",A[A.TAG_NAME=7]="TAG_NAME",A[A.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",A[A.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",A[A.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",A[A.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",A[A.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",A[A.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",A[A.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",A[A.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",A[A.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",A[A.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",A[A.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",A[A.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",A[A.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",A[A.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",A[A.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",A[A.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",A[A.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",A[A.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",A[A.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",A[A.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",A[A.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",A[A.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",A[A.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",A[A.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",A[A.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",A[A.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",A[A.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",A[A.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",A[A.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",A[A.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",A[A.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",A[A.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",A[A.BOGUS_COMMENT=40]="BOGUS_COMMENT",A[A.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",A[A.COMMENT_START=42]="COMMENT_START",A[A.COMMENT_START_DASH=43]="COMMENT_START_DASH",A[A.COMMENT=44]="COMMENT",A[A.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",A[A.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",A[A.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",A[A.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",A[A.COMMENT_END_DASH=49]="COMMENT_END_DASH",A[A.COMMENT_END=50]="COMMENT_END",A[A.COMMENT_END_BANG=51]="COMMENT_END_BANG",A[A.DOCTYPE=52]="DOCTYPE",A[A.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",A[A.DOCTYPE_NAME=54]="DOCTYPE_NAME",A[A.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",A[A.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",A[A.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",A[A.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",A[A.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",A[A.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",A[A.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",A[A.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",A[A.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",A[A.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",A[A.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",A[A.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",A[A.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",A[A.CDATA_SECTION=68]="CDATA_SECTION",A[A.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",A[A.CDATA_SECTION_END=70]="CDATA_SECTION_END",A[A.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",A[A.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(g||(g={}));const GA={DATA:g.DATA,RCDATA:g.RCDATA,RAWTEXT:g.RAWTEXT,SCRIPT_DATA:g.SCRIPT_DATA,PLAINTEXT:g.PLAINTEXT,CDATA_SECTION:g.CDATA_SECTION};function wd(A){return A>=B.DIGIT_0&&A<=B.DIGIT_9}function Xt(A){return A>=B.LATIN_CAPITAL_A&&A<=B.LATIN_CAPITAL_Z}function Td(A){return A>=B.LATIN_SMALL_A&&A<=B.LATIN_SMALL_Z}function ve(A){return Td(A)||Xt(A)}function Eu(A){return ve(A)||wd(A)}function jr(A){return A+32}function pu(A){return A===B.SPACE||A===B.LINE_FEED||A===B.TABULATION||A===B.FORM_FEED}function mu(A){return pu(A)||A===B.SOLIDUS||A===B.GREATER_THAN_SIGN}function bd(A){return A===B.NULL?b.nullCharacterReference:A>1114111?b.characterReferenceOutsideUnicodeRange:hu(A)?b.surrogateCharacterReference:Bu(A)?b.noncharacterCharacterReference:du(A)||A===B.CARRIAGE_RETURN?b.controlCharacterReference:null}let Ud=class{constructor(e,t){this.options=e,this.handler=t,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=g.DATA,this.returnState=g.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new gd(t),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new Bs(ls,(r,n)=>{this.preprocessor.pos=this.entityStartPos+n-1,this._flushCodePointConsumedAsCharacterReference(r)},t.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(b.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:r=>{this._err(b.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+r)},validateNumericCharacterReference:r=>{const n=bd(r);n&&this._err(n,1)}}:void 0)}_err(e,t=0){var r,n;(n=(r=this.handler).onParseError)===null||n===void 0||n.call(r,this.preprocessor.getError(e,t))}getCurrentLocation(e){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-e,startOffset:this.preprocessor.offset-e,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const e=this._consume();this._ensureHibernation()||this._callState(e)}this.inLoop=!1}}pause(){this.paused=!0}resume(e){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||e==null||e())}write(e,t,r){this.active=!0,this.preprocessor.write(e,t),this._runParsingLoop(),this.paused||r==null||r()}insertHtmlAtCurrentPos(e){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(e),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(e){this.consumedAfterSnapshot+=e;for(let t=0;t<e;t++)this.preprocessor.advance()}_consumeSequenceIfMatch(e,t){return this.preprocessor.startsWith(e,t)?(this._advanceBy(e.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:eA.START_TAG,tagName:"",tagID:i.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:eA.END_TAG,tagName:"",tagID:i.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(e){this.currentToken={type:eA.COMMENT,data:"",location:this.getCurrentLocation(e)}}_createDoctypeToken(e){this.currentToken={type:eA.DOCTYPE,name:e,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(e,t){this.currentCharacterToken={type:e,chars:t,location:this.currentLocation}}_createAttr(e){this.currentAttr={name:e,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var e,t;const r=this.currentToken;if(gu(r,this.currentAttr.name)===null){if(r.attrs.push(this.currentAttr),r.location&&this.currentLocation){const n=(e=(t=r.location).attrs)!==null&&e!==void 0?e:t.attrs=Object.create(null);n[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(b.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(e){this._emitCurrentCharacterToken(e.location),this.currentToken=null,e.location&&(e.location.endLine=this.preprocessor.line,e.location.endCol=this.preprocessor.col+1,e.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const e=this.currentToken;this.prepareToken(e),e.tagID=qr(e.tagName),e.type===eA.START_TAG?(this.lastStartTagName=e.tagName,this.handler.onStartTag(e)):(e.attrs.length>0&&this._err(b.endTagWithAttributes),e.selfClosing&&this._err(b.endTagWithTrailingSolidus),this.handler.onEndTag(e)),this.preprocessor.dropParsedChunk()}emitCurrentComment(e){this.prepareToken(e),this.handler.onComment(e),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(e){this.prepareToken(e),this.handler.onDoctype(e),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(e){if(this.currentCharacterToken){switch(e&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=e.startLine,this.currentCharacterToken.location.endCol=e.startCol,this.currentCharacterToken.location.endOffset=e.startOffset),this.currentCharacterToken.type){case eA.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case eA.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case eA.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const e=this.getCurrentLocation(0);e&&(e.endLine=e.startLine,e.endCol=e.startCol,e.endOffset=e.startOffset),this._emitCurrentCharacterToken(e),this.handler.onEof({type:eA.EOF,location:e}),this.active=!1}_appendCharToCurrentCharacterToken(e,t){if(this.currentCharacterToken)if(this.currentCharacterToken.type===e){this.currentCharacterToken.chars+=t;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(e,t)}_emitCodePoint(e){const t=pu(e)?eA.WHITESPACE_CHARACTER:e===B.NULL?eA.NULL_CHARACTER:eA.CHARACTER;this._appendCharToCurrentCharacterToken(t,String.fromCodePoint(e))}_emitChars(e){this._appendCharToCurrentCharacterToken(eA.CHARACTER,e)}_startCharacterReference(){this.returnState=this.state,this.state=g.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?$A.Attribute:$A.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===g.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===g.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===g.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(e){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(e):this._emitCodePoint(e)}_callState(e){switch(this.state){case g.DATA:{this._stateData(e);break}case g.RCDATA:{this._stateRcdata(e);break}case g.RAWTEXT:{this._stateRawtext(e);break}case g.SCRIPT_DATA:{this._stateScriptData(e);break}case g.PLAINTEXT:{this._statePlaintext(e);break}case g.TAG_OPEN:{this._stateTagOpen(e);break}case g.END_TAG_OPEN:{this._stateEndTagOpen(e);break}case g.TAG_NAME:{this._stateTagName(e);break}case g.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(e);break}case g.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(e);break}case g.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(e);break}case g.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(e);break}case g.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(e);break}case g.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(e);break}case g.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(e);break}case g.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(e);break}case g.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(e);break}case g.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(e);break}case g.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(e);break}case g.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(e);break}case g.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(e);break}case g.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(e);break}case g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(e);break}case g.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(e);break}case g.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(e);break}case g.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(e);break}case g.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(e);break}case g.ATTRIBUTE_NAME:{this._stateAttributeName(e);break}case g.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(e);break}case g.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(e);break}case g.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(e);break}case g.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(e);break}case g.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(e);break}case g.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(e);break}case g.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(e);break}case g.BOGUS_COMMENT:{this._stateBogusComment(e);break}case g.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(e);break}case g.COMMENT_START:{this._stateCommentStart(e);break}case g.COMMENT_START_DASH:{this._stateCommentStartDash(e);break}case g.COMMENT:{this._stateComment(e);break}case g.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(e);break}case g.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(e);break}case g.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(e);break}case g.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(e);break}case g.COMMENT_END_DASH:{this._stateCommentEndDash(e);break}case g.COMMENT_END:{this._stateCommentEnd(e);break}case g.COMMENT_END_BANG:{this._stateCommentEndBang(e);break}case g.DOCTYPE:{this._stateDoctype(e);break}case g.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(e);break}case g.DOCTYPE_NAME:{this._stateDoctypeName(e);break}case g.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(e);break}case g.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(e);break}case g.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(e);break}case g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(e);break}case g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(e);break}case g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(e);break}case g.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(e);break}case g.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(e);break}case g.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(e);break}case g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(e);break}case g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(e);break}case g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(e);break}case g.BOGUS_DOCTYPE:{this._stateBogusDoctype(e);break}case g.CDATA_SECTION:{this._stateCdataSection(e);break}case g.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(e);break}case g.CDATA_SECTION_END:{this._stateCdataSectionEnd(e);break}case g.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case g.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(e);break}default:throw new Error("Unknown state")}}_stateData(e){switch(e){case B.LESS_THAN_SIGN:{this.state=g.TAG_OPEN;break}case B.AMPERSAND:{this._startCharacterReference();break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitCodePoint(e);break}case B.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateRcdata(e){switch(e){case B.AMPERSAND:{this._startCharacterReference();break}case B.LESS_THAN_SIGN:{this.state=g.RCDATA_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateRawtext(e){switch(e){case B.LESS_THAN_SIGN:{this.state=g.RAWTEXT_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateScriptData(e){switch(e){case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(e)}}_statePlaintext(e){switch(e){case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateTagOpen(e){if(ve(e))this._createStartTagToken(),this.state=g.TAG_NAME,this._stateTagName(e);else switch(e){case B.EXCLAMATION_MARK:{this.state=g.MARKUP_DECLARATION_OPEN;break}case B.SOLIDUS:{this.state=g.END_TAG_OPEN;break}case B.QUESTION_MARK:{this._err(b.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=g.BOGUS_COMMENT,this._stateBogusComment(e);break}case B.EOF:{this._err(b.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(b.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=g.DATA,this._stateData(e)}}_stateEndTagOpen(e){if(ve(e))this._createEndTagToken(),this.state=g.TAG_NAME,this._stateTagName(e);else switch(e){case B.GREATER_THAN_SIGN:{this._err(b.missingEndTagName),this.state=g.DATA;break}case B.EOF:{this._err(b.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(b.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=g.BOGUS_COMMENT,this._stateBogusComment(e)}}_stateTagName(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.BEFORE_ATTRIBUTE_NAME;break}case B.SOLIDUS:{this.state=g.SELF_CLOSING_START_TAG;break}case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentTagToken();break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.tagName+=fA;break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:t.tagName+=String.fromCodePoint(Xt(e)?jr(e):e)}}_stateRcdataLessThanSign(e){e===B.SOLIDUS?this.state=g.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=g.RCDATA,this._stateRcdata(e))}_stateRcdataEndTagOpen(e){ve(e)?(this.state=g.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(e)):(this._emitChars("</"),this.state=g.RCDATA,this._stateRcdata(e))}handleSpecialEndTag(e){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const t=this.currentToken;switch(t.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=g.BEFORE_ATTRIBUTE_NAME,!1;case B.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=g.SELF_CLOSING_START_TAG,!1;case B.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=g.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=g.RCDATA,this._stateRcdata(e))}_stateRawtextLessThanSign(e){e===B.SOLIDUS?this.state=g.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=g.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagOpen(e){ve(e)?(this.state=g.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(e)):(this._emitChars("</"),this.state=g.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=g.RAWTEXT,this._stateRawtext(e))}_stateScriptDataLessThanSign(e){switch(e){case B.SOLIDUS:{this.state=g.SCRIPT_DATA_END_TAG_OPEN;break}case B.EXCLAMATION_MARK:{this.state=g.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=g.SCRIPT_DATA,this._stateScriptData(e)}}_stateScriptDataEndTagOpen(e){ve(e)?(this.state=g.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(e)):(this._emitChars("</"),this.state=g.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=g.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStart(e){e===B.HYPHEN_MINUS?(this.state=g.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=g.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStartDash(e){e===B.HYPHEN_MINUS?(this.state=g.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=g.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscaped(e){switch(e){case B.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateScriptDataEscapedDash(e){switch(e){case B.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_ESCAPED,this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedDashDash(e){switch(e){case B.HYPHEN_MINUS:{this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case B.GREATER_THAN_SIGN:{this.state=g.SCRIPT_DATA,this._emitChars(">");break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_ESCAPED,this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedLessThanSign(e){e===B.SOLIDUS?this.state=g.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:ve(e)?(this._emitChars("<"),this.state=g.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(e)):(this._emitChars("<"),this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagOpen(e){ve(e)?(this.state=g.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(e)):(this._emitChars("</"),this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscapeStart(e){if(this.preprocessor.startsWith(VA.SCRIPT,!1)&&mu(this.preprocessor.peek(VA.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<VA.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscaped(e){switch(e){case B.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case B.NULL:{this._err(b.unexpectedNullCharacter),this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDash(e){switch(e){case B.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDashDash(e){switch(e){case B.HYPHEN_MINUS:{this._emitChars("-");break}case B.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case B.GREATER_THAN_SIGN:{this.state=g.SCRIPT_DATA,this._emitChars(">");break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(fA);break}case B.EOF:{this._err(b.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedLessThanSign(e){e===B.SOLIDUS?(this.state=g.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateScriptDataDoubleEscapeEnd(e){if(this.preprocessor.startsWith(VA.SCRIPT,!1)&&mu(this.preprocessor.peek(VA.SCRIPT.length))){this._emitCodePoint(e);for(let t=0;t<VA.SCRIPT.length;t++)this._emitCodePoint(this._consume());this.state=g.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateBeforeAttributeName(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.SOLIDUS:case B.GREATER_THAN_SIGN:case B.EOF:{this.state=g.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break}case B.EQUALS_SIGN:{this._err(b.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=g.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=g.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateAttributeName(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:case B.SOLIDUS:case B.GREATER_THAN_SIGN:case B.EOF:{this._leaveAttrName(),this.state=g.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break}case B.EQUALS_SIGN:{this._leaveAttrName(),this.state=g.BEFORE_ATTRIBUTE_VALUE;break}case B.QUOTATION_MARK:case B.APOSTROPHE:case B.LESS_THAN_SIGN:{this._err(b.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(e);break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.currentAttr.name+=fA;break}default:this.currentAttr.name+=String.fromCodePoint(Xt(e)?jr(e):e)}}_stateAfterAttributeName(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.SOLIDUS:{this.state=g.SELF_CLOSING_START_TAG;break}case B.EQUALS_SIGN:{this.state=g.BEFORE_ATTRIBUTE_VALUE;break}case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentTagToken();break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=g.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateBeforeAttributeValue(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.QUOTATION_MARK:{this.state=g.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case B.APOSTROPHE:{this.state=g.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case B.GREATER_THAN_SIGN:{this._err(b.missingAttributeValue),this.state=g.DATA,this.emitCurrentTagToken();break}default:this.state=g.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(e)}}_stateAttributeValueDoubleQuoted(e){switch(e){case B.QUOTATION_MARK:{this.state=g.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case B.AMPERSAND:{this._startCharacterReference();break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.currentAttr.value+=fA;break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueSingleQuoted(e){switch(e){case B.APOSTROPHE:{this.state=g.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case B.AMPERSAND:{this._startCharacterReference();break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.currentAttr.value+=fA;break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueUnquoted(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this._leaveAttrValue(),this.state=g.BEFORE_ATTRIBUTE_NAME;break}case B.AMPERSAND:{this._startCharacterReference();break}case B.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=g.DATA,this.emitCurrentTagToken();break}case B.NULL:{this._err(b.unexpectedNullCharacter),this.currentAttr.value+=fA;break}case B.QUOTATION_MARK:case B.APOSTROPHE:case B.LESS_THAN_SIGN:case B.EQUALS_SIGN:case B.GRAVE_ACCENT:{this._err(b.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(e);break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAfterAttributeValueQuoted(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this._leaveAttrValue(),this.state=g.BEFORE_ATTRIBUTE_NAME;break}case B.SOLIDUS:{this._leaveAttrValue(),this.state=g.SELF_CLOSING_START_TAG;break}case B.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=g.DATA,this.emitCurrentTagToken();break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this._err(b.missingWhitespaceBetweenAttributes),this.state=g.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateSelfClosingStartTag(e){switch(e){case B.GREATER_THAN_SIGN:{const t=this.currentToken;t.selfClosing=!0,this.state=g.DATA,this.emitCurrentTagToken();break}case B.EOF:{this._err(b.eofInTag),this._emitEOFToken();break}default:this._err(b.unexpectedSolidusInTag),this.state=g.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateBogusComment(e){const t=this.currentToken;switch(e){case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentComment(t);break}case B.EOF:{this.emitCurrentComment(t),this._emitEOFToken();break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.data+=fA;break}default:t.data+=String.fromCodePoint(e)}}_stateMarkupDeclarationOpen(e){this._consumeSequenceIfMatch(VA.DASH_DASH,!0)?(this._createCommentToken(VA.DASH_DASH.length+1),this.state=g.COMMENT_START):this._consumeSequenceIfMatch(VA.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(VA.DOCTYPE.length+1),this.state=g.DOCTYPE):this._consumeSequenceIfMatch(VA.CDATA_START,!0)?this.inForeignNode?this.state=g.CDATA_SECTION:(this._err(b.cdataInHtmlContent),this._createCommentToken(VA.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=g.BOGUS_COMMENT):this._ensureHibernation()||(this._err(b.incorrectlyOpenedComment),this._createCommentToken(2),this.state=g.BOGUS_COMMENT,this._stateBogusComment(e))}_stateCommentStart(e){switch(e){case B.HYPHEN_MINUS:{this.state=g.COMMENT_START_DASH;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptClosingOfEmptyComment),this.state=g.DATA;const t=this.currentToken;this.emitCurrentComment(t);break}default:this.state=g.COMMENT,this._stateComment(e)}}_stateCommentStartDash(e){const t=this.currentToken;switch(e){case B.HYPHEN_MINUS:{this.state=g.COMMENT_END;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptClosingOfEmptyComment),this.state=g.DATA,this.emitCurrentComment(t);break}case B.EOF:{this._err(b.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break}default:t.data+="-",this.state=g.COMMENT,this._stateComment(e)}}_stateComment(e){const t=this.currentToken;switch(e){case B.HYPHEN_MINUS:{this.state=g.COMMENT_END_DASH;break}case B.LESS_THAN_SIGN:{t.data+="<",this.state=g.COMMENT_LESS_THAN_SIGN;break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.data+=fA;break}case B.EOF:{this._err(b.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break}default:t.data+=String.fromCodePoint(e)}}_stateCommentLessThanSign(e){const t=this.currentToken;switch(e){case B.EXCLAMATION_MARK:{t.data+="!",this.state=g.COMMENT_LESS_THAN_SIGN_BANG;break}case B.LESS_THAN_SIGN:{t.data+="<";break}default:this.state=g.COMMENT,this._stateComment(e)}}_stateCommentLessThanSignBang(e){e===B.HYPHEN_MINUS?this.state=g.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=g.COMMENT,this._stateComment(e))}_stateCommentLessThanSignBangDash(e){e===B.HYPHEN_MINUS?this.state=g.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=g.COMMENT_END_DASH,this._stateCommentEndDash(e))}_stateCommentLessThanSignBangDashDash(e){e!==B.GREATER_THAN_SIGN&&e!==B.EOF&&this._err(b.nestedComment),this.state=g.COMMENT_END,this._stateCommentEnd(e)}_stateCommentEndDash(e){const t=this.currentToken;switch(e){case B.HYPHEN_MINUS:{this.state=g.COMMENT_END;break}case B.EOF:{this._err(b.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break}default:t.data+="-",this.state=g.COMMENT,this._stateComment(e)}}_stateCommentEnd(e){const t=this.currentToken;switch(e){case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentComment(t);break}case B.EXCLAMATION_MARK:{this.state=g.COMMENT_END_BANG;break}case B.HYPHEN_MINUS:{t.data+="-";break}case B.EOF:{this._err(b.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break}default:t.data+="--",this.state=g.COMMENT,this._stateComment(e)}}_stateCommentEndBang(e){const t=this.currentToken;switch(e){case B.HYPHEN_MINUS:{t.data+="--!",this.state=g.COMMENT_END_DASH;break}case B.GREATER_THAN_SIGN:{this._err(b.incorrectlyClosedComment),this.state=g.DATA,this.emitCurrentComment(t);break}case B.EOF:{this._err(b.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break}default:t.data+="--!",this.state=g.COMMENT,this._stateComment(e)}}_stateDoctype(e){switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.BEFORE_DOCTYPE_NAME;break}case B.GREATER_THAN_SIGN:{this.state=g.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e);break}case B.EOF:{this._err(b.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingWhitespaceBeforeDoctypeName),this.state=g.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e)}}_stateBeforeDoctypeName(e){if(Xt(e))this._createDoctypeToken(String.fromCharCode(jr(e))),this.state=g.DOCTYPE_NAME;else switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.NULL:{this._err(b.unexpectedNullCharacter),this._createDoctypeToken(fA),this.state=g.DOCTYPE_NAME;break}case B.GREATER_THAN_SIGN:{this._err(b.missingDoctypeName),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),this._createDoctypeToken(null);const t=this.currentToken;t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(e)),this.state=g.DOCTYPE_NAME}}_stateDoctypeName(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.AFTER_DOCTYPE_NAME;break}case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.name+=fA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:t.name+=String.fromCodePoint(Xt(e)?jr(e):e)}}_stateAfterDoctypeName(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(VA.PUBLIC,!1)?this.state=g.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(VA.SYSTEM,!1)?this.state=g.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(b.invalidCharacterSequenceAfterDoctypeName),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e))}}_stateAfterDoctypePublicKeyword(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case B.QUOTATION_MARK:{this._err(b.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{this._err(b.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case B.GREATER_THAN_SIGN:{this._err(b.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.QUOTATION_MARK:{t.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{t.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case B.GREATER_THAN_SIGN:{this._err(b.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypePublicIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case B.QUOTATION_MARK:{this.state=g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.publicId+=fA;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:t.publicId+=String.fromCodePoint(e)}}_stateDoctypePublicIdentifierSingleQuoted(e){const t=this.currentToken;switch(e){case B.APOSTROPHE:{this.state=g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.publicId+=fA;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:t.publicId+=String.fromCodePoint(e)}}_stateAfterDoctypePublicIdentifier(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case B.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.QUOTATION_MARK:{this._err(b.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{this._err(b.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBetweenDoctypePublicAndSystemIdentifiers(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.GREATER_THAN_SIGN:{this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.QUOTATION_MARK:{t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateAfterDoctypeSystemKeyword(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:{this.state=g.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case B.QUOTATION_MARK:{this._err(b.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{this._err(b.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case B.GREATER_THAN_SIGN:{this._err(b.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.QUOTATION_MARK:{t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case B.APOSTROPHE:{t.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case B.GREATER_THAN_SIGN:{this._err(b.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(t);break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypeSystemIdentifierDoubleQuoted(e){const t=this.currentToken;switch(e){case B.QUOTATION_MARK:{this.state=g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.systemId+=fA;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:t.systemId+=String.fromCodePoint(e)}}_stateDoctypeSystemIdentifierSingleQuoted(e){const t=this.currentToken;switch(e){case B.APOSTROPHE:{this.state=g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case B.NULL:{this._err(b.unexpectedNullCharacter),t.systemId+=fA;break}case B.GREATER_THAN_SIGN:{this._err(b.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:t.systemId+=String.fromCodePoint(e)}}_stateAfterDoctypeSystemIdentifier(e){const t=this.currentToken;switch(e){case B.SPACE:case B.LINE_FEED:case B.TABULATION:case B.FORM_FEED:break;case B.GREATER_THAN_SIGN:{this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.EOF:{this._err(b.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break}default:this._err(b.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBogusDoctype(e){const t=this.currentToken;switch(e){case B.GREATER_THAN_SIGN:{this.emitCurrentDoctype(t),this.state=g.DATA;break}case B.NULL:{this._err(b.unexpectedNullCharacter);break}case B.EOF:{this.emitCurrentDoctype(t),this._emitEOFToken();break}}}_stateCdataSection(e){switch(e){case B.RIGHT_SQUARE_BRACKET:{this.state=g.CDATA_SECTION_BRACKET;break}case B.EOF:{this._err(b.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(e)}}_stateCdataSectionBracket(e){e===B.RIGHT_SQUARE_BRACKET?this.state=g.CDATA_SECTION_END:(this._emitChars("]"),this.state=g.CDATA_SECTION,this._stateCdataSection(e))}_stateCdataSectionEnd(e){switch(e){case B.GREATER_THAN_SIGN:{this.state=g.DATA;break}case B.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=g.CDATA_SECTION,this._stateCdataSection(e)}}_stateCharacterReference(){let e=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(e<0)if(this.preprocessor.lastChunkWritten)e=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}e===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(B.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&Eu(this.preprocessor.peek(1))?g.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(e){Eu(e)?this._flushCodePointConsumedAsCharacterReference(e):(e===B.SEMICOLON&&this._err(b.unknownNamedCharacterReference),this.state=this.returnState,this._callState(e))}};const Cu=new Set([i.DD,i.DT,i.LI,i.OPTGROUP,i.OPTION,i.P,i.RB,i.RP,i.RT,i.RTC]),wu=new Set([...Cu,i.CAPTION,i.COLGROUP,i.TBODY,i.TD,i.TFOOT,i.TH,i.THEAD,i.TR]),Zr=new Set([i.APPLET,i.CAPTION,i.HTML,i.MARQUEE,i.OBJECT,i.TABLE,i.TD,i.TEMPLATE,i.TH]),Qd=new Set([...Zr,i.OL,i.UL]),Fd=new Set([...Zr,i.BUTTON]),Tu=new Set([i.ANNOTATION_XML,i.MI,i.MN,i.MO,i.MS,i.MTEXT]),bu=new Set([i.DESC,i.FOREIGN_OBJECT,i.TITLE]),Id=new Set([i.TR,i.TEMPLATE,i.HTML]),_d=new Set([i.TBODY,i.TFOOT,i.THEAD,i.TEMPLATE,i.HTML]),yd=new Set([i.TABLE,i.TEMPLATE,i.HTML]),Nd=new Set([i.TD,i.TH]);class Sd{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(e,t,r){this.treeAdapter=t,this.handler=r,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=i.UNKNOWN,this.current=e}_indexOf(e){return this.items.lastIndexOf(e,this.stackTop)}_isInTemplate(){return this.currentTagId===i.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===U.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(e,t){this.stackTop++,this.items[this.stackTop]=e,this.current=e,this.tagIDs[this.stackTop]=t,this.currentTagId=t,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(e,t,!0)}pop(){const e=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!0)}replace(e,t){const r=this._indexOf(e);this.items[r]=t,r===this.stackTop&&(this.current=t)}insertAfter(e,t,r){const n=this._indexOf(e)+1;this.items.splice(n,0,t),this.tagIDs.splice(n,0,r),this.stackTop++,n===this.stackTop&&this._updateCurrentElement(),this.handler.onItemPush(this.current,this.currentTagId,n===this.stackTop)}popUntilTagNamePopped(e){let t=this.stackTop+1;do t=this.tagIDs.lastIndexOf(e,t-1);while(t>0&&this.treeAdapter.getNamespaceURI(this.items[t])!==U.HTML);this.shortenToLength(t<0?0:t)}shortenToLength(e){for(;this.stackTop>=e;){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,this.stackTop<e)}}popUntilElementPopped(e){const t=this._indexOf(e);this.shortenToLength(t<0?0:t)}popUntilPopped(e,t){const r=this._indexOfTagNames(e,t);this.shortenToLength(r<0?0:r)}popUntilNumberedHeaderPopped(){this.popUntilPopped(Ps,U.HTML)}popUntilTableCellPopped(){this.popUntilPopped(Nd,U.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(e,t){for(let r=this.stackTop;r>=0;r--)if(e.has(this.tagIDs[r])&&this.treeAdapter.getNamespaceURI(this.items[r])===t)return r;return-1}clearBackTo(e,t){const r=this._indexOfTagNames(e,t);this.shortenToLength(r+1)}clearBackToTableContext(){this.clearBackTo(yd,U.HTML)}clearBackToTableBodyContext(){this.clearBackTo(_d,U.HTML)}clearBackToTableRowContext(){this.clearBackTo(Id,U.HTML)}remove(e){const t=this._indexOf(e);t>=0&&(t===this.stackTop?this.pop():(this.items.splice(t,1),this.tagIDs.splice(t,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===i.BODY?this.items[1]:null}contains(e){return this._indexOf(e)>-1}getCommonAncestor(e){const t=this._indexOf(e)-1;return t>=0?this.items[t]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===i.HTML}hasInDynamicScope(e,t){for(let r=this.stackTop;r>=0;r--){const n=this.tagIDs[r];switch(this.treeAdapter.getNamespaceURI(this.items[r])){case U.HTML:{if(n===e)return!0;if(t.has(n))return!1;break}case U.SVG:{if(bu.has(n))return!1;break}case U.MATHML:{if(Tu.has(n))return!1;break}}}return!0}hasInScope(e){return this.hasInDynamicScope(e,Zr)}hasInListItemScope(e){return this.hasInDynamicScope(e,Qd)}hasInButtonScope(e){return this.hasInDynamicScope(e,Fd)}hasNumberedHeaderInScope(){for(let e=this.stackTop;e>=0;e--){const t=this.tagIDs[e];switch(this.treeAdapter.getNamespaceURI(this.items[e])){case U.HTML:{if(Ps.has(t))return!0;if(Zr.has(t))return!1;break}case U.SVG:{if(bu.has(t))return!1;break}case U.MATHML:{if(Tu.has(t))return!1;break}}}return!0}hasInTableScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===U.HTML)switch(this.tagIDs[t]){case e:return!0;case i.TABLE:case i.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let e=this.stackTop;e>=0;e--)if(this.treeAdapter.getNamespaceURI(this.items[e])===U.HTML)switch(this.tagIDs[e]){case i.TBODY:case i.THEAD:case i.TFOOT:return!0;case i.TABLE:case i.HTML:return!1}return!0}hasInSelectScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===U.HTML)switch(this.tagIDs[t]){case e:return!0;case i.OPTION:case i.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;Cu.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;wu.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(e){for(;this.currentTagId!==e&&wu.has(this.currentTagId);)this.pop()}}const Ks=3;var fe;(function(A){A[A.Marker=0]="Marker",A[A.Element=1]="Element"})(fe||(fe={}));const Uu={type:fe.Marker};class vd{constructor(e){this.treeAdapter=e,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(e,t){const r=[],n=t.length,s=this.treeAdapter.getTagName(e),a=this.treeAdapter.getNamespaceURI(e);for(let u=0;u<this.entries.length;u++){const o=this.entries[u];if(o.type===fe.Marker)break;const{element:c}=o;if(this.treeAdapter.getTagName(c)===s&&this.treeAdapter.getNamespaceURI(c)===a){const f=this.treeAdapter.getAttrList(c);f.length===n&&r.push({idx:u,attrs:f})}}return r}_ensureNoahArkCondition(e){if(this.entries.length<Ks)return;const t=this.treeAdapter.getAttrList(e),r=this._getNoahArkConditionCandidates(e,t);if(r.length<Ks)return;const n=new Map(t.map(a=>[a.name,a.value]));let s=0;for(let a=0;a<r.length;a++){const u=r[a];u.attrs.every(o=>n.get(o.name)===o.value)&&(s+=1,s>=Ks&&this.entries.splice(u.idx,1))}}insertMarker(){this.entries.unshift(Uu)}pushElement(e,t){this._ensureNoahArkCondition(e),this.entries.unshift({type:fe.Element,element:e,token:t})}insertElementAfterBookmark(e,t){const r=this.entries.indexOf(this.bookmark);this.entries.splice(r,0,{type:fe.Element,element:e,token:t})}removeEntry(e){const t=this.entries.indexOf(e);t>=0&&this.entries.splice(t,1)}clearToLastMarker(){const e=this.entries.indexOf(Uu);e>=0?this.entries.splice(0,e+1):this.entries.length=0}getElementEntryInScopeWithTagName(e){const t=this.entries.find(r=>r.type===fe.Marker||this.treeAdapter.getTagName(r.element)===e);return t&&t.type===fe.Element?t:null}getElementEntry(e){return this.entries.find(t=>t.type===fe.Element&&t.element===e)}}const we={createDocument(){return{nodeName:"#document",mode:qA.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(A,e,t){return{nodeName:A,tagName:A,attrs:t,namespaceURI:e,childNodes:[],parentNode:null}},createCommentNode(A){return{nodeName:"#comment",data:A,parentNode:null}},createTextNode(A){return{nodeName:"#text",value:A,parentNode:null}},appendChild(A,e){A.childNodes.push(e),e.parentNode=A},insertBefore(A,e,t){const r=A.childNodes.indexOf(t);A.childNodes.splice(r,0,e),e.parentNode=A},setTemplateContent(A,e){A.content=e},getTemplateContent(A){return A.content},setDocumentType(A,e,t,r){const n=A.childNodes.find(s=>s.nodeName==="#documentType");if(n)n.name=e,n.publicId=t,n.systemId=r;else{const s={nodeName:"#documentType",name:e,publicId:t,systemId:r,parentNode:null};we.appendChild(A,s)}},setDocumentMode(A,e){A.mode=e},getDocumentMode(A){return A.mode},detachNode(A){if(A.parentNode){const e=A.parentNode.childNodes.indexOf(A);A.parentNode.childNodes.splice(e,1),A.parentNode=null}},insertText(A,e){if(A.childNodes.length>0){const t=A.childNodes[A.childNodes.length-1];if(we.isTextNode(t)){t.value+=e;return}}we.appendChild(A,we.createTextNode(e))},insertTextBefore(A,e,t){const r=A.childNodes[A.childNodes.indexOf(t)-1];r&&we.isTextNode(r)?r.value+=e:we.insertBefore(A,we.createTextNode(e),t)},adoptAttributes(A,e){const t=new Set(A.attrs.map(r=>r.name));for(let r=0;r<e.length;r++)t.has(e[r].name)||A.attrs.push(e[r])},getFirstChild(A){return A.childNodes[0]},getChildNodes(A){return A.childNodes},getParentNode(A){return A.parentNode},getAttrList(A){return A.attrs},getTagName(A){return A.tagName},getNamespaceURI(A){return A.namespaceURI},getTextNodeContent(A){return A.value},getCommentNodeContent(A){return A.data},getDocumentTypeNodeName(A){return A.name},getDocumentTypeNodePublicId(A){return A.publicId},getDocumentTypeNodeSystemId(A){return A.systemId},isTextNode(A){return A.nodeName==="#text"},isCommentNode(A){return A.nodeName==="#comment"},isDocumentTypeNode(A){return A.nodeName==="#documentType"},isElementNode(A){return Object.prototype.hasOwnProperty.call(A,"tagName")},setNodeSourceCodeLocation(A,e){A.sourceCodeLocation=e},getNodeSourceCodeLocation(A){return A.sourceCodeLocation},updateNodeSourceCodeLocation(A,e){A.sourceCodeLocation={...A.sourceCodeLocation,...e}}},Qu="html",Ld="about:legacy-compat",Hd="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",Fu=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],xd=[...Fu,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],Dd=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),Iu=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],Od=[...Iu,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function _u(A,e){return e.some(t=>A.startsWith(t))}function Rd(A){return A.name===Qu&&A.publicId===null&&(A.systemId===null||A.systemId===Ld)}function Md(A){if(A.name!==Qu)return qA.QUIRKS;const{systemId:e}=A;if(e&&e.toLowerCase()===Hd)return qA.QUIRKS;let{publicId:t}=A;if(t!==null){if(t=t.toLowerCase(),Dd.has(t))return qA.QUIRKS;let r=e===null?xd:Fu;if(_u(t,r))return qA.QUIRKS;if(r=e===null?Iu:Od,_u(t,r))return qA.LIMITED_QUIRKS}return qA.NO_QUIRKS}const yu={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},kd="definitionurl",Pd="definitionURL",Kd=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(A=>[A.toLowerCase(),A])),Vd=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:U.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:U.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:U.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:U.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:U.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:U.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:U.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:U.XML}],["xml:space",{prefix:"xml",name:"space",namespace:U.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:U.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:U.XMLNS}]]),Gd=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(A=>[A.toLowerCase(),A])),Yd=new Set([i.B,i.BIG,i.BLOCKQUOTE,i.BODY,i.BR,i.CENTER,i.CODE,i.DD,i.DIV,i.DL,i.DT,i.EM,i.EMBED,i.H1,i.H2,i.H3,i.H4,i.H5,i.H6,i.HEAD,i.HR,i.I,i.IMG,i.LI,i.LISTING,i.MENU,i.META,i.NOBR,i.OL,i.P,i.PRE,i.RUBY,i.S,i.SMALL,i.SPAN,i.STRONG,i.STRIKE,i.SUB,i.SUP,i.TABLE,i.TT,i.U,i.UL,i.VAR]);function Xd(A){const e=A.tagID;return e===i.FONT&&A.attrs.some(({name:r})=>r===ze.COLOR||r===ze.SIZE||r===ze.FACE)||Yd.has(e)}function Nu(A){for(let e=0;e<A.attrs.length;e++)if(A.attrs[e].name===kd){A.attrs[e].name=Pd;break}}function Su(A){for(let e=0;e<A.attrs.length;e++){const t=Kd.get(A.attrs[e].name);t!=null&&(A.attrs[e].name=t)}}function Vs(A){for(let e=0;e<A.attrs.length;e++){const t=Vd.get(A.attrs[e].name);t&&(A.attrs[e].prefix=t.prefix,A.attrs[e].name=t.name,A.attrs[e].namespace=t.namespace)}}function Wd(A){const e=Gd.get(A.tagName);e!=null&&(A.tagName=e,A.tagID=qr(A.tagName))}function Jd(A,e){return e===U.MATHML&&(A===i.MI||A===i.MO||A===i.MN||A===i.MS||A===i.MTEXT)}function qd(A,e,t){if(e===U.MATHML&&A===i.ANNOTATION_XML){for(let r=0;r<t.length;r++)if(t[r].name===ze.ENCODING){const n=t[r].value.toLowerCase();return n===yu.TEXT_HTML||n===yu.APPLICATION_XML}}return e===U.SVG&&(A===i.FOREIGN_OBJECT||A===i.DESC||A===i.TITLE)}function jd(A,e,t,r){return(!r||r===U.HTML)&&qd(A,e,t)||(!r||r===U.MATHML)&&Jd(A,e)}const Zd="hidden",$d=8,zd=3;var E;(function(A){A[A.INITIAL=0]="INITIAL",A[A.BEFORE_HTML=1]="BEFORE_HTML",A[A.BEFORE_HEAD=2]="BEFORE_HEAD",A[A.IN_HEAD=3]="IN_HEAD",A[A.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",A[A.AFTER_HEAD=5]="AFTER_HEAD",A[A.IN_BODY=6]="IN_BODY",A[A.TEXT=7]="TEXT",A[A.IN_TABLE=8]="IN_TABLE",A[A.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",A[A.IN_CAPTION=10]="IN_CAPTION",A[A.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",A[A.IN_TABLE_BODY=12]="IN_TABLE_BODY",A[A.IN_ROW=13]="IN_ROW",A[A.IN_CELL=14]="IN_CELL",A[A.IN_SELECT=15]="IN_SELECT",A[A.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",A[A.IN_TEMPLATE=17]="IN_TEMPLATE",A[A.AFTER_BODY=18]="AFTER_BODY",A[A.IN_FRAMESET=19]="IN_FRAMESET",A[A.AFTER_FRAMESET=20]="AFTER_FRAMESET",A[A.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",A[A.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(E||(E={}));const AB={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},vu=new Set([i.TABLE,i.TBODY,i.TFOOT,i.THEAD,i.TR]),Lu={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:we,onParseError:null};let Hu=class{constructor(e,t,r=null,n=null){this.fragmentContext=r,this.scriptHandler=n,this.currentToken=null,this.stopped=!1,this.insertionMode=E.INITIAL,this.originalInsertionMode=E.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...Lu,...e},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=t??this.treeAdapter.createDocument(),this.tokenizer=new Ud(this.options,this),this.activeFormattingElements=new vd(this.treeAdapter),this.fragmentContextID=r?qr(this.treeAdapter.getTagName(r)):i.UNKNOWN,this._setContextModes(r??this.document,this.fragmentContextID),this.openElements=new Sd(this.document,this.treeAdapter,this)}static parse(e,t){const r=new this(t);return r.tokenizer.write(e,!0),r.document}static getFragmentParser(e,t){const r={...Lu,...t};e??(e=r.treeAdapter.createElement(w.TEMPLATE,U.HTML,[]));const n=r.treeAdapter.createElement("documentmock",U.HTML,[]),s=new this(r,n,e);return s.fragmentContextID===i.TEMPLATE&&s.tmplInsertionModeStack.unshift(E.IN_TEMPLATE),s._initTokenizerForFragmentParsing(),s._insertFakeRootElement(),s._resetInsertionMode(),s._findFormInFragmentContext(),s}getFragment(){const e=this.treeAdapter.getFirstChild(this.document),t=this.treeAdapter.createDocumentFragment();return this._adoptNodes(e,t),t}_err(e,t,r){var n;if(!this.onParseError)return;const s=(n=e.location)!==null&&n!==void 0?n:AB,a={code:t,startLine:s.startLine,startCol:s.startCol,startOffset:s.startOffset,endLine:r?s.startLine:s.endLine,endCol:r?s.startCol:s.endCol,endOffset:r?s.startOffset:s.endOffset};this.onParseError(a)}onItemPush(e,t,r){var n,s;(s=(n=this.treeAdapter).onItemPush)===null||s===void 0||s.call(n,e),r&&this.openElements.stackTop>0&&this._setContextModes(e,t)}onItemPop(e,t){var r,n;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(e,this.currentToken),(n=(r=this.treeAdapter).onItemPop)===null||n===void 0||n.call(r,e,this.openElements.current),t){let s,a;this.openElements.stackTop===0&&this.fragmentContext?(s=this.fragmentContext,a=this.fragmentContextID):{current:s,currentTagId:a}=this.openElements,this._setContextModes(s,a)}}_setContextModes(e,t){const r=e===this.document||this.treeAdapter.getNamespaceURI(e)===U.HTML;this.currentNotInHTML=!r,this.tokenizer.inForeignNode=!r&&!this._isIntegrationPoint(t,e)}_switchToTextParsing(e,t){this._insertElement(e,U.HTML),this.tokenizer.state=t,this.originalInsertionMode=this.insertionMode,this.insertionMode=E.TEXT}switchToPlaintextParsing(){this.insertionMode=E.TEXT,this.originalInsertionMode=E.IN_BODY,this.tokenizer.state=GA.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let e=this.fragmentContext;for(;e;){if(this.treeAdapter.getTagName(e)===w.FORM){this.formElement=e;break}e=this.treeAdapter.getParentNode(e)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==U.HTML))switch(this.fragmentContextID){case i.TITLE:case i.TEXTAREA:{this.tokenizer.state=GA.RCDATA;break}case i.STYLE:case i.XMP:case i.IFRAME:case i.NOEMBED:case i.NOFRAMES:case i.NOSCRIPT:{this.tokenizer.state=GA.RAWTEXT;break}case i.SCRIPT:{this.tokenizer.state=GA.SCRIPT_DATA;break}case i.PLAINTEXT:{this.tokenizer.state=GA.PLAINTEXT;break}}}_setDocumentType(e){const t=e.name||"",r=e.publicId||"",n=e.systemId||"";if(this.treeAdapter.setDocumentType(this.document,t,r,n),e.location){const a=this.treeAdapter.getChildNodes(this.document).find(u=>this.treeAdapter.isDocumentTypeNode(u));a&&this.treeAdapter.setNodeSourceCodeLocation(a,e.location)}}_attachElementToTree(e,t){if(this.options.sourceCodeLocationInfo){const r=t&&{...t,startTag:t};this.treeAdapter.setNodeSourceCodeLocation(e,r)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(e);else{const r=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(r,e)}}_appendElement(e,t){const r=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(r,e.location)}_insertElement(e,t){const r=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(r,e.location),this.openElements.push(r,e.tagID)}_insertFakeElement(e,t){const r=this.treeAdapter.createElement(e,U.HTML,[]);this._attachElementToTree(r,null),this.openElements.push(r,t)}_insertTemplate(e){const t=this.treeAdapter.createElement(e.tagName,U.HTML,e.attrs),r=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(t,r),this._attachElementToTree(t,e.location),this.openElements.push(t,e.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,null)}_insertFakeRootElement(){const e=this.treeAdapter.createElement(w.HTML,U.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(e,null),this.treeAdapter.appendChild(this.openElements.current,e),this.openElements.push(e,i.HTML)}_appendCommentNode(e,t){const r=this.treeAdapter.createCommentNode(e.data);this.treeAdapter.appendChild(t,r),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,e.location)}_insertCharacters(e){let t,r;if(this._shouldFosterParentOnInsertion()?({parent:t,beforeElement:r}=this._findFosterParentingLocation(),r?this.treeAdapter.insertTextBefore(t,e.chars,r):this.treeAdapter.insertText(t,e.chars)):(t=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(t,e.chars)),!e.location)return;const n=this.treeAdapter.getChildNodes(t),s=r?n.lastIndexOf(r):n.length,a=n[s-1];if(this.treeAdapter.getNodeSourceCodeLocation(a)){const{endLine:o,endCol:c,endOffset:f}=e.location;this.treeAdapter.updateNodeSourceCodeLocation(a,{endLine:o,endCol:c,endOffset:f})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,e.location)}_adoptNodes(e,t){for(let r=this.treeAdapter.getFirstChild(e);r;r=this.treeAdapter.getFirstChild(e))this.treeAdapter.detachNode(r),this.treeAdapter.appendChild(t,r)}_setEndLocation(e,t){if(this.treeAdapter.getNodeSourceCodeLocation(e)&&t.location){const r=t.location,n=this.treeAdapter.getTagName(e),s=t.type===eA.END_TAG&&n===t.tagName?{endTag:{...r},endLine:r.endLine,endCol:r.endCol,endOffset:r.endOffset}:{endLine:r.startLine,endCol:r.startCol,endOffset:r.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(e,s)}}shouldProcessStartTagTokenInForeignContent(e){if(!this.currentNotInHTML)return!1;let t,r;return this.openElements.stackTop===0&&this.fragmentContext?(t=this.fragmentContext,r=this.fragmentContextID):{current:t,currentTagId:r}=this.openElements,e.tagID===i.SVG&&this.treeAdapter.getTagName(t)===w.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(t)===U.MATHML?!1:this.tokenizer.inForeignNode||(e.tagID===i.MGLYPH||e.tagID===i.MALIGNMARK)&&!this._isIntegrationPoint(r,t,U.HTML)}_processToken(e){switch(e.type){case eA.CHARACTER:{this.onCharacter(e);break}case eA.NULL_CHARACTER:{this.onNullCharacter(e);break}case eA.COMMENT:{this.onComment(e);break}case eA.DOCTYPE:{this.onDoctype(e);break}case eA.START_TAG:{this._processStartTag(e);break}case eA.END_TAG:{this.onEndTag(e);break}case eA.EOF:{this.onEof(e);break}case eA.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(e);break}}}_isIntegrationPoint(e,t,r){const n=this.treeAdapter.getNamespaceURI(t),s=this.treeAdapter.getAttrList(t);return jd(e,n,s,r)}_reconstructActiveFormattingElements(){const e=this.activeFormattingElements.entries.length;if(e){const t=this.activeFormattingElements.entries.findIndex(n=>n.type===fe.Marker||this.openElements.contains(n.element)),r=t<0?e-1:t-1;for(let n=r;n>=0;n--){const s=this.activeFormattingElements.entries[n];this._insertElement(s.token,this.treeAdapter.getNamespaceURI(s.element)),s.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=E.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(i.P),this.openElements.popUntilTagNamePopped(i.P)}_resetInsertionMode(){for(let e=this.openElements.stackTop;e>=0;e--)switch(e===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[e]){case i.TR:{this.insertionMode=E.IN_ROW;return}case i.TBODY:case i.THEAD:case i.TFOOT:{this.insertionMode=E.IN_TABLE_BODY;return}case i.CAPTION:{this.insertionMode=E.IN_CAPTION;return}case i.COLGROUP:{this.insertionMode=E.IN_COLUMN_GROUP;return}case i.TABLE:{this.insertionMode=E.IN_TABLE;return}case i.BODY:{this.insertionMode=E.IN_BODY;return}case i.FRAMESET:{this.insertionMode=E.IN_FRAMESET;return}case i.SELECT:{this._resetInsertionModeForSelect(e);return}case i.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case i.HTML:{this.insertionMode=this.headElement?E.AFTER_HEAD:E.BEFORE_HEAD;return}case i.TD:case i.TH:{if(e>0){this.insertionMode=E.IN_CELL;return}break}case i.HEAD:{if(e>0){this.insertionMode=E.IN_HEAD;return}break}}this.insertionMode=E.IN_BODY}_resetInsertionModeForSelect(e){if(e>0)for(let t=e-1;t>0;t--){const r=this.openElements.tagIDs[t];if(r===i.TEMPLATE)break;if(r===i.TABLE){this.insertionMode=E.IN_SELECT_IN_TABLE;return}}this.insertionMode=E.IN_SELECT}_isElementCausesFosterParenting(e){return vu.has(e)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let e=this.openElements.stackTop;e>=0;e--){const t=this.openElements.items[e];switch(this.openElements.tagIDs[e]){case i.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(t)===U.HTML)return{parent:this.treeAdapter.getTemplateContent(t),beforeElement:null};break}case i.TABLE:{const r=this.treeAdapter.getParentNode(t);return r?{parent:r,beforeElement:t}:{parent:this.openElements.items[e-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(e){const t=this._findFosterParentingLocation();t.beforeElement?this.treeAdapter.insertBefore(t.parent,e,t.beforeElement):this.treeAdapter.appendChild(t.parent,e)}_isSpecialElement(e,t){const r=this.treeAdapter.getNamespaceURI(e);return pd[r].has(t)}onCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Ng(this,e);return}switch(this.insertionMode){case E.INITIAL:{Wt(this,e);break}case E.BEFORE_HTML:{Jt(this,e);break}case E.BEFORE_HEAD:{qt(this,e);break}case E.IN_HEAD:{jt(this,e);break}case E.IN_HEAD_NO_SCRIPT:{Zt(this,e);break}case E.AFTER_HEAD:{$t(this,e);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:{Du(this,e);break}case E.TEXT:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{this._insertCharacters(e);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Ws(this,e);break}case E.IN_TABLE_TEXT:{Gu(this,e);break}case E.IN_COLUMN_GROUP:{An(this,e);break}case E.AFTER_BODY:{rn(this,e);break}case E.AFTER_AFTER_BODY:{nn(this,e);break}}}onNullCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){yg(this,e);return}switch(this.insertionMode){case E.INITIAL:{Wt(this,e);break}case E.BEFORE_HTML:{Jt(this,e);break}case E.BEFORE_HEAD:{qt(this,e);break}case E.IN_HEAD:{jt(this,e);break}case E.IN_HEAD_NO_SCRIPT:{Zt(this,e);break}case E.AFTER_HEAD:{$t(this,e);break}case E.TEXT:{this._insertCharacters(e);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Ws(this,e);break}case E.IN_COLUMN_GROUP:{An(this,e);break}case E.AFTER_BODY:{rn(this,e);break}case E.AFTER_AFTER_BODY:{nn(this,e);break}}}onComment(e){if(this.skipNextNewLine=!1,this.currentNotInHTML){Ys(this,e);return}switch(this.insertionMode){case E.INITIAL:case E.BEFORE_HTML:case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_TEMPLATE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{Ys(this,e);break}case E.IN_TABLE_TEXT:{er(this,e);break}case E.AFTER_BODY:{iB(this,e);break}case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{uB(this,e);break}}}onDoctype(e){switch(this.skipNextNewLine=!1,this.insertionMode){case E.INITIAL:{oB(this,e);break}case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:{this._err(e,b.misplacedDoctype);break}case E.IN_TABLE_TEXT:{er(this,e);break}}}onStartTag(e){this.skipNextNewLine=!1,this.currentToken=e,this._processStartTag(e),e.selfClosing&&!e.ackSelfClosing&&this._err(e,b.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(e){this.shouldProcessStartTagTokenInForeignContent(e)?Sg(this,e):this._startTagOutsideForeignContent(e)}_startTagOutsideForeignContent(e){switch(this.insertionMode){case E.INITIAL:{Wt(this,e);break}case E.BEFORE_HTML:{cB(this,e);break}case E.BEFORE_HEAD:{fB(this,e);break}case E.IN_HEAD:{se(this,e);break}case E.IN_HEAD_NO_SCRIPT:{BB(this,e);break}case E.AFTER_HEAD:{EB(this,e);break}case E.IN_BODY:{xA(this,e);break}case E.IN_TABLE:{gt(this,e);break}case E.IN_TABLE_TEXT:{er(this,e);break}case E.IN_CAPTION:{hg(this,e);break}case E.IN_COLUMN_GROUP:{Js(this,e);break}case E.IN_TABLE_BODY:{en(this,e);break}case E.IN_ROW:{tn(this,e);break}case E.IN_CELL:{gg(this,e);break}case E.IN_SELECT:{Wu(this,e);break}case E.IN_SELECT_IN_TABLE:{pg(this,e);break}case E.IN_TEMPLATE:{Cg(this,e);break}case E.AFTER_BODY:{Tg(this,e);break}case E.IN_FRAMESET:{bg(this,e);break}case E.AFTER_FRAMESET:{Qg(this,e);break}case E.AFTER_AFTER_BODY:{Ig(this,e);break}case E.AFTER_AFTER_FRAMESET:{_g(this,e);break}}}onEndTag(e){this.skipNextNewLine=!1,this.currentToken=e,this.currentNotInHTML?vg(this,e):this._endTagOutsideForeignContent(e)}_endTagOutsideForeignContent(e){switch(this.insertionMode){case E.INITIAL:{Wt(this,e);break}case E.BEFORE_HTML:{lB(this,e);break}case E.BEFORE_HEAD:{hB(this,e);break}case E.IN_HEAD:{dB(this,e);break}case E.IN_HEAD_NO_SCRIPT:{gB(this,e);break}case E.AFTER_HEAD:{pB(this,e);break}case E.IN_BODY:{zr(this,e);break}case E.TEXT:{rg(this,e);break}case E.IN_TABLE:{zt(this,e);break}case E.IN_TABLE_TEXT:{er(this,e);break}case E.IN_CAPTION:{dg(this,e);break}case E.IN_COLUMN_GROUP:{Bg(this,e);break}case E.IN_TABLE_BODY:{qs(this,e);break}case E.IN_ROW:{Xu(this,e);break}case E.IN_CELL:{Eg(this,e);break}case E.IN_SELECT:{Ju(this,e);break}case E.IN_SELECT_IN_TABLE:{mg(this,e);break}case E.IN_TEMPLATE:{wg(this,e);break}case E.AFTER_BODY:{ju(this,e);break}case E.IN_FRAMESET:{Ug(this,e);break}case E.AFTER_FRAMESET:{Fg(this,e);break}case E.AFTER_AFTER_BODY:{nn(this,e);break}}}onEof(e){switch(this.insertionMode){case E.INITIAL:{Wt(this,e);break}case E.BEFORE_HTML:{Jt(this,e);break}case E.BEFORE_HEAD:{qt(this,e);break}case E.IN_HEAD:{jt(this,e);break}case E.IN_HEAD_NO_SCRIPT:{Zt(this,e);break}case E.AFTER_HEAD:{$t(this,e);break}case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{Ku(this,e);break}case E.TEXT:{ng(this,e);break}case E.IN_TABLE_TEXT:{er(this,e);break}case E.IN_TEMPLATE:{qu(this,e);break}case E.AFTER_BODY:case E.IN_FRAMESET:case E.AFTER_FRAMESET:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{Xs(this,e);break}}}onWhitespaceCharacter(e){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,e.chars.charCodeAt(0)===B.LINE_FEED)){if(e.chars.length===1)return;e.chars=e.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(e);return}switch(this.insertionMode){case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.TEXT:case E.IN_COLUMN_GROUP:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{this._insertCharacters(e);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:case E.AFTER_BODY:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{xu(this,e);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Ws(this,e);break}case E.IN_TABLE_TEXT:{Vu(this,e);break}}}};function eB(A,e){let t=A.activeFormattingElements.getElementEntryInScopeWithTagName(e.tagName);return t?A.openElements.contains(t.element)?A.openElements.hasInScope(e.tagID)||(t=null):(A.activeFormattingElements.removeEntry(t),t=null):Pu(A,e),t}function tB(A,e){let t=null,r=A.openElements.stackTop;for(;r>=0;r--){const n=A.openElements.items[r];if(n===e.element)break;A._isSpecialElement(n,A.openElements.tagIDs[r])&&(t=n)}return t||(A.openElements.shortenToLength(r<0?0:r),A.activeFormattingElements.removeEntry(e)),t}function rB(A,e,t){let r=e,n=A.openElements.getCommonAncestor(e);for(let s=0,a=n;a!==t;s++,a=n){n=A.openElements.getCommonAncestor(a);const u=A.activeFormattingElements.getElementEntry(a),o=u&&s>=zd;!u||o?(o&&A.activeFormattingElements.removeEntry(u),A.openElements.remove(a)):(a=nB(A,u),r===e&&(A.activeFormattingElements.bookmark=u),A.treeAdapter.detachNode(r),A.treeAdapter.appendChild(a,r),r=a)}return r}function nB(A,e){const t=A.treeAdapter.getNamespaceURI(e.element),r=A.treeAdapter.createElement(e.token.tagName,t,e.token.attrs);return A.openElements.replace(e.element,r),e.element=r,r}function sB(A,e,t){const r=A.treeAdapter.getTagName(e),n=qr(r);if(A._isElementCausesFosterParenting(n))A._fosterParentElement(t);else{const s=A.treeAdapter.getNamespaceURI(e);n===i.TEMPLATE&&s===U.HTML&&(e=A.treeAdapter.getTemplateContent(e)),A.treeAdapter.appendChild(e,t)}}function aB(A,e,t){const r=A.treeAdapter.getNamespaceURI(t.element),{token:n}=t,s=A.treeAdapter.createElement(n.tagName,r,n.attrs);A._adoptNodes(e,s),A.treeAdapter.appendChild(e,s),A.activeFormattingElements.insertElementAfterBookmark(s,n),A.activeFormattingElements.removeEntry(t),A.openElements.remove(t.element),A.openElements.insertAfter(e,s,n.tagID)}function Gs(A,e){for(let t=0;t<$d;t++){const r=eB(A,e);if(!r)break;const n=tB(A,r);if(!n)break;A.activeFormattingElements.bookmark=r;const s=rB(A,n,r.element),a=A.openElements.getCommonAncestor(r.element);A.treeAdapter.detachNode(s),a&&sB(A,a,s),aB(A,n,r)}}function Ys(A,e){A._appendCommentNode(e,A.openElements.currentTmplContentOrNode)}function iB(A,e){A._appendCommentNode(e,A.openElements.items[0])}function uB(A,e){A._appendCommentNode(e,A.document)}function Xs(A,e){if(A.stopped=!0,e.location){const t=A.fragmentContext?0:2;for(let r=A.openElements.stackTop;r>=t;r--)A._setEndLocation(A.openElements.items[r],e);if(!A.fragmentContext&&A.openElements.stackTop>=0){const r=A.openElements.items[0],n=A.treeAdapter.getNodeSourceCodeLocation(r);if(n&&!n.endTag&&(A._setEndLocation(r,e),A.openElements.stackTop>=1)){const s=A.openElements.items[1],a=A.treeAdapter.getNodeSourceCodeLocation(s);a&&!a.endTag&&A._setEndLocation(s,e)}}}}function oB(A,e){A._setDocumentType(e);const t=e.forceQuirks?qA.QUIRKS:Md(e);Rd(e)||A._err(e,b.nonConformingDoctype),A.treeAdapter.setDocumentMode(A.document,t),A.insertionMode=E.BEFORE_HTML}function Wt(A,e){A._err(e,b.missingDoctype,!0),A.treeAdapter.setDocumentMode(A.document,qA.QUIRKS),A.insertionMode=E.BEFORE_HTML,A._processToken(e)}function cB(A,e){e.tagID===i.HTML?(A._insertElement(e,U.HTML),A.insertionMode=E.BEFORE_HEAD):Jt(A,e)}function lB(A,e){const t=e.tagID;(t===i.HTML||t===i.HEAD||t===i.BODY||t===i.BR)&&Jt(A,e)}function Jt(A,e){A._insertFakeRootElement(),A.insertionMode=E.BEFORE_HEAD,A._processToken(e)}function fB(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.HEAD:{A._insertElement(e,U.HTML),A.headElement=A.openElements.current,A.insertionMode=E.IN_HEAD;break}default:qt(A,e)}}function hB(A,e){const t=e.tagID;t===i.HEAD||t===i.BODY||t===i.HTML||t===i.BR?qt(A,e):A._err(e,b.endTagWithoutMatchingOpenElement)}function qt(A,e){A._insertFakeElement(w.HEAD,i.HEAD),A.headElement=A.openElements.current,A.insertionMode=E.IN_HEAD,A._processToken(e)}function se(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.BASE:case i.BASEFONT:case i.BGSOUND:case i.LINK:case i.META:{A._appendElement(e,U.HTML),e.ackSelfClosing=!0;break}case i.TITLE:{A._switchToTextParsing(e,GA.RCDATA);break}case i.NOSCRIPT:{A.options.scriptingEnabled?A._switchToTextParsing(e,GA.RAWTEXT):(A._insertElement(e,U.HTML),A.insertionMode=E.IN_HEAD_NO_SCRIPT);break}case i.NOFRAMES:case i.STYLE:{A._switchToTextParsing(e,GA.RAWTEXT);break}case i.SCRIPT:{A._switchToTextParsing(e,GA.SCRIPT_DATA);break}case i.TEMPLATE:{A._insertTemplate(e),A.activeFormattingElements.insertMarker(),A.framesetOk=!1,A.insertionMode=E.IN_TEMPLATE,A.tmplInsertionModeStack.unshift(E.IN_TEMPLATE);break}case i.HEAD:{A._err(e,b.misplacedStartTagForHeadElement);break}default:jt(A,e)}}function dB(A,e){switch(e.tagID){case i.HEAD:{A.openElements.pop(),A.insertionMode=E.AFTER_HEAD;break}case i.BODY:case i.BR:case i.HTML:{jt(A,e);break}case i.TEMPLATE:{At(A,e);break}default:A._err(e,b.endTagWithoutMatchingOpenElement)}}function At(A,e){A.openElements.tmplCount>0?(A.openElements.generateImpliedEndTagsThoroughly(),A.openElements.currentTagId!==i.TEMPLATE&&A._err(e,b.closingOfElementWithOpenChildElements),A.openElements.popUntilTagNamePopped(i.TEMPLATE),A.activeFormattingElements.clearToLastMarker(),A.tmplInsertionModeStack.shift(),A._resetInsertionMode()):A._err(e,b.endTagWithoutMatchingOpenElement)}function jt(A,e){A.openElements.pop(),A.insertionMode=E.AFTER_HEAD,A._processToken(e)}function BB(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.BASEFONT:case i.BGSOUND:case i.HEAD:case i.LINK:case i.META:case i.NOFRAMES:case i.STYLE:{se(A,e);break}case i.NOSCRIPT:{A._err(e,b.nestedNoscriptInHead);break}default:Zt(A,e)}}function gB(A,e){switch(e.tagID){case i.NOSCRIPT:{A.openElements.pop(),A.insertionMode=E.IN_HEAD;break}case i.BR:{Zt(A,e);break}default:A._err(e,b.endTagWithoutMatchingOpenElement)}}function Zt(A,e){const t=e.type===eA.EOF?b.openElementsLeftAfterEof:b.disallowedContentInNoscriptInHead;A._err(e,t),A.openElements.pop(),A.insertionMode=E.IN_HEAD,A._processToken(e)}function EB(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.BODY:{A._insertElement(e,U.HTML),A.framesetOk=!1,A.insertionMode=E.IN_BODY;break}case i.FRAMESET:{A._insertElement(e,U.HTML),A.insertionMode=E.IN_FRAMESET;break}case i.BASE:case i.BASEFONT:case i.BGSOUND:case i.LINK:case i.META:case i.NOFRAMES:case i.SCRIPT:case i.STYLE:case i.TEMPLATE:case i.TITLE:{A._err(e,b.abandonedHeadElementChild),A.openElements.push(A.headElement,i.HEAD),se(A,e),A.openElements.remove(A.headElement);break}case i.HEAD:{A._err(e,b.misplacedStartTagForHeadElement);break}default:$t(A,e)}}function pB(A,e){switch(e.tagID){case i.BODY:case i.HTML:case i.BR:{$t(A,e);break}case i.TEMPLATE:{At(A,e);break}default:A._err(e,b.endTagWithoutMatchingOpenElement)}}function $t(A,e){A._insertFakeElement(w.BODY,i.BODY),A.insertionMode=E.IN_BODY,$r(A,e)}function $r(A,e){switch(e.type){case eA.CHARACTER:{Du(A,e);break}case eA.WHITESPACE_CHARACTER:{xu(A,e);break}case eA.COMMENT:{Ys(A,e);break}case eA.START_TAG:{xA(A,e);break}case eA.END_TAG:{zr(A,e);break}case eA.EOF:{Ku(A,e);break}}}function xu(A,e){A._reconstructActiveFormattingElements(),A._insertCharacters(e)}function Du(A,e){A._reconstructActiveFormattingElements(),A._insertCharacters(e),A.framesetOk=!1}function mB(A,e){A.openElements.tmplCount===0&&A.treeAdapter.adoptAttributes(A.openElements.items[0],e.attrs)}function CB(A,e){const t=A.openElements.tryPeekProperlyNestedBodyElement();t&&A.openElements.tmplCount===0&&(A.framesetOk=!1,A.treeAdapter.adoptAttributes(t,e.attrs))}function wB(A,e){const t=A.openElements.tryPeekProperlyNestedBodyElement();A.framesetOk&&t&&(A.treeAdapter.detachNode(t),A.openElements.popAllUpToHtmlElement(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_FRAMESET)}function TB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML)}function bB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),Ps.has(A.openElements.currentTagId)&&A.openElements.pop(),A._insertElement(e,U.HTML)}function UB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML),A.skipNextNewLine=!0,A.framesetOk=!1}function QB(A,e){const t=A.openElements.tmplCount>0;(!A.formElement||t)&&(A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML),t||(A.formElement=A.openElements.current))}function FB(A,e){A.framesetOk=!1;const t=e.tagID;for(let r=A.openElements.stackTop;r>=0;r--){const n=A.openElements.tagIDs[r];if(t===i.LI&&n===i.LI||(t===i.DD||t===i.DT)&&(n===i.DD||n===i.DT)){A.openElements.generateImpliedEndTagsWithExclusion(n),A.openElements.popUntilTagNamePopped(n);break}if(n!==i.ADDRESS&&n!==i.DIV&&n!==i.P&&A._isSpecialElement(A.openElements.items[r],n))break}A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML)}function IB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML),A.tokenizer.state=GA.PLAINTEXT}function _B(A,e){A.openElements.hasInScope(i.BUTTON)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(i.BUTTON)),A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML),A.framesetOk=!1}function yB(A,e){const t=A.activeFormattingElements.getElementEntryInScopeWithTagName(w.A);t&&(Gs(A,e),A.openElements.remove(t.element),A.activeFormattingElements.removeEntry(t)),A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML),A.activeFormattingElements.pushElement(A.openElements.current,e)}function NB(A,e){A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML),A.activeFormattingElements.pushElement(A.openElements.current,e)}function SB(A,e){A._reconstructActiveFormattingElements(),A.openElements.hasInScope(i.NOBR)&&(Gs(A,e),A._reconstructActiveFormattingElements()),A._insertElement(e,U.HTML),A.activeFormattingElements.pushElement(A.openElements.current,e)}function vB(A,e){A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML),A.activeFormattingElements.insertMarker(),A.framesetOk=!1}function LB(A,e){A.treeAdapter.getDocumentMode(A.document)!==qA.QUIRKS&&A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._insertElement(e,U.HTML),A.framesetOk=!1,A.insertionMode=E.IN_TABLE}function Ou(A,e){A._reconstructActiveFormattingElements(),A._appendElement(e,U.HTML),A.framesetOk=!1,e.ackSelfClosing=!0}function Ru(A){const e=gu(A,ze.TYPE);return e!=null&&e.toLowerCase()===Zd}function HB(A,e){A._reconstructActiveFormattingElements(),A._appendElement(e,U.HTML),Ru(e)||(A.framesetOk=!1),e.ackSelfClosing=!0}function xB(A,e){A._appendElement(e,U.HTML),e.ackSelfClosing=!0}function DB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._appendElement(e,U.HTML),A.framesetOk=!1,e.ackSelfClosing=!0}function OB(A,e){e.tagName=w.IMG,e.tagID=i.IMG,Ou(A,e)}function RB(A,e){A._insertElement(e,U.HTML),A.skipNextNewLine=!0,A.tokenizer.state=GA.RCDATA,A.originalInsertionMode=A.insertionMode,A.framesetOk=!1,A.insertionMode=E.TEXT}function MB(A,e){A.openElements.hasInButtonScope(i.P)&&A._closePElement(),A._reconstructActiveFormattingElements(),A.framesetOk=!1,A._switchToTextParsing(e,GA.RAWTEXT)}function kB(A,e){A.framesetOk=!1,A._switchToTextParsing(e,GA.RAWTEXT)}function Mu(A,e){A._switchToTextParsing(e,GA.RAWTEXT)}function PB(A,e){A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML),A.framesetOk=!1,A.insertionMode=A.insertionMode===E.IN_TABLE||A.insertionMode===E.IN_CAPTION||A.insertionMode===E.IN_TABLE_BODY||A.insertionMode===E.IN_ROW||A.insertionMode===E.IN_CELL?E.IN_SELECT_IN_TABLE:E.IN_SELECT}function KB(A,e){A.openElements.currentTagId===i.OPTION&&A.openElements.pop(),A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML)}function VB(A,e){A.openElements.hasInScope(i.RUBY)&&A.openElements.generateImpliedEndTags(),A._insertElement(e,U.HTML)}function GB(A,e){A.openElements.hasInScope(i.RUBY)&&A.openElements.generateImpliedEndTagsWithExclusion(i.RTC),A._insertElement(e,U.HTML)}function YB(A,e){A._reconstructActiveFormattingElements(),Nu(e),Vs(e),e.selfClosing?A._appendElement(e,U.MATHML):A._insertElement(e,U.MATHML),e.ackSelfClosing=!0}function XB(A,e){A._reconstructActiveFormattingElements(),Su(e),Vs(e),e.selfClosing?A._appendElement(e,U.SVG):A._insertElement(e,U.SVG),e.ackSelfClosing=!0}function ku(A,e){A._reconstructActiveFormattingElements(),A._insertElement(e,U.HTML)}function xA(A,e){switch(e.tagID){case i.I:case i.S:case i.B:case i.U:case i.EM:case i.TT:case i.BIG:case i.CODE:case i.FONT:case i.SMALL:case i.STRIKE:case i.STRONG:{NB(A,e);break}case i.A:{yB(A,e);break}case i.H1:case i.H2:case i.H3:case i.H4:case i.H5:case i.H6:{bB(A,e);break}case i.P:case i.DL:case i.OL:case i.UL:case i.DIV:case i.DIR:case i.NAV:case i.MAIN:case i.MENU:case i.ASIDE:case i.CENTER:case i.FIGURE:case i.FOOTER:case i.HEADER:case i.HGROUP:case i.DIALOG:case i.DETAILS:case i.ADDRESS:case i.ARTICLE:case i.SEARCH:case i.SECTION:case i.SUMMARY:case i.FIELDSET:case i.BLOCKQUOTE:case i.FIGCAPTION:{TB(A,e);break}case i.LI:case i.DD:case i.DT:{FB(A,e);break}case i.BR:case i.IMG:case i.WBR:case i.AREA:case i.EMBED:case i.KEYGEN:{Ou(A,e);break}case i.HR:{DB(A,e);break}case i.RB:case i.RTC:{VB(A,e);break}case i.RT:case i.RP:{GB(A,e);break}case i.PRE:case i.LISTING:{UB(A,e);break}case i.XMP:{MB(A,e);break}case i.SVG:{XB(A,e);break}case i.HTML:{mB(A,e);break}case i.BASE:case i.LINK:case i.META:case i.STYLE:case i.TITLE:case i.SCRIPT:case i.BGSOUND:case i.BASEFONT:case i.TEMPLATE:{se(A,e);break}case i.BODY:{CB(A,e);break}case i.FORM:{QB(A,e);break}case i.NOBR:{SB(A,e);break}case i.MATH:{YB(A,e);break}case i.TABLE:{LB(A,e);break}case i.INPUT:{HB(A,e);break}case i.PARAM:case i.TRACK:case i.SOURCE:{xB(A,e);break}case i.IMAGE:{OB(A,e);break}case i.BUTTON:{_B(A,e);break}case i.APPLET:case i.OBJECT:case i.MARQUEE:{vB(A,e);break}case i.IFRAME:{kB(A,e);break}case i.SELECT:{PB(A,e);break}case i.OPTION:case i.OPTGROUP:{KB(A,e);break}case i.NOEMBED:case i.NOFRAMES:{Mu(A,e);break}case i.FRAMESET:{wB(A,e);break}case i.TEXTAREA:{RB(A,e);break}case i.NOSCRIPT:{A.options.scriptingEnabled?Mu(A,e):ku(A,e);break}case i.PLAINTEXT:{IB(A,e);break}case i.COL:case i.TH:case i.TD:case i.TR:case i.HEAD:case i.FRAME:case i.TBODY:case i.TFOOT:case i.THEAD:case i.CAPTION:case i.COLGROUP:break;default:ku(A,e)}}function WB(A,e){if(A.openElements.hasInScope(i.BODY)&&(A.insertionMode=E.AFTER_BODY,A.options.sourceCodeLocationInfo)){const t=A.openElements.tryPeekProperlyNestedBodyElement();t&&A._setEndLocation(t,e)}}function JB(A,e){A.openElements.hasInScope(i.BODY)&&(A.insertionMode=E.AFTER_BODY,ju(A,e))}function qB(A,e){const t=e.tagID;A.openElements.hasInScope(t)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(t))}function jB(A){const e=A.openElements.tmplCount>0,{formElement:t}=A;e||(A.formElement=null),(t||e)&&A.openElements.hasInScope(i.FORM)&&(A.openElements.generateImpliedEndTags(),e?A.openElements.popUntilTagNamePopped(i.FORM):t&&A.openElements.remove(t))}function ZB(A){A.openElements.hasInButtonScope(i.P)||A._insertFakeElement(w.P,i.P),A._closePElement()}function $B(A){A.openElements.hasInListItemScope(i.LI)&&(A.openElements.generateImpliedEndTagsWithExclusion(i.LI),A.openElements.popUntilTagNamePopped(i.LI))}function zB(A,e){const t=e.tagID;A.openElements.hasInScope(t)&&(A.openElements.generateImpliedEndTagsWithExclusion(t),A.openElements.popUntilTagNamePopped(t))}function Ag(A){A.openElements.hasNumberedHeaderInScope()&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilNumberedHeaderPopped())}function eg(A,e){const t=e.tagID;A.openElements.hasInScope(t)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(t),A.activeFormattingElements.clearToLastMarker())}function tg(A){A._reconstructActiveFormattingElements(),A._insertFakeElement(w.BR,i.BR),A.openElements.pop(),A.framesetOk=!1}function Pu(A,e){const t=e.tagName,r=e.tagID;for(let n=A.openElements.stackTop;n>0;n--){const s=A.openElements.items[n],a=A.openElements.tagIDs[n];if(r===a&&(r!==i.UNKNOWN||A.treeAdapter.getTagName(s)===t)){A.openElements.generateImpliedEndTagsWithExclusion(r),A.openElements.stackTop>=n&&A.openElements.shortenToLength(n);break}if(A._isSpecialElement(s,a))break}}function zr(A,e){switch(e.tagID){case i.A:case i.B:case i.I:case i.S:case i.U:case i.EM:case i.TT:case i.BIG:case i.CODE:case i.FONT:case i.NOBR:case i.SMALL:case i.STRIKE:case i.STRONG:{Gs(A,e);break}case i.P:{ZB(A);break}case i.DL:case i.UL:case i.OL:case i.DIR:case i.DIV:case i.NAV:case i.PRE:case i.MAIN:case i.MENU:case i.ASIDE:case i.BUTTON:case i.CENTER:case i.FIGURE:case i.FOOTER:case i.HEADER:case i.HGROUP:case i.DIALOG:case i.ADDRESS:case i.ARTICLE:case i.DETAILS:case i.SEARCH:case i.SECTION:case i.SUMMARY:case i.LISTING:case i.FIELDSET:case i.BLOCKQUOTE:case i.FIGCAPTION:{qB(A,e);break}case i.LI:{$B(A);break}case i.DD:case i.DT:{zB(A,e);break}case i.H1:case i.H2:case i.H3:case i.H4:case i.H5:case i.H6:{Ag(A);break}case i.BR:{tg(A);break}case i.BODY:{WB(A,e);break}case i.HTML:{JB(A,e);break}case i.FORM:{jB(A);break}case i.APPLET:case i.OBJECT:case i.MARQUEE:{eg(A,e);break}case i.TEMPLATE:{At(A,e);break}default:Pu(A,e)}}function Ku(A,e){A.tmplInsertionModeStack.length>0?qu(A,e):Xs(A,e)}function rg(A,e){var t;e.tagID===i.SCRIPT&&((t=A.scriptHandler)===null||t===void 0||t.call(A,A.openElements.current)),A.openElements.pop(),A.insertionMode=A.originalInsertionMode}function ng(A,e){A._err(e,b.eofInElementThatCanContainOnlyText),A.openElements.pop(),A.insertionMode=A.originalInsertionMode,A.onEof(e)}function Ws(A,e){if(vu.has(A.openElements.currentTagId))switch(A.pendingCharacterTokens.length=0,A.hasNonWhitespacePendingCharacterToken=!1,A.originalInsertionMode=A.insertionMode,A.insertionMode=E.IN_TABLE_TEXT,e.type){case eA.CHARACTER:{Gu(A,e);break}case eA.WHITESPACE_CHARACTER:{Vu(A,e);break}}else Ar(A,e)}function sg(A,e){A.openElements.clearBackToTableContext(),A.activeFormattingElements.insertMarker(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_CAPTION}function ag(A,e){A.openElements.clearBackToTableContext(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_COLUMN_GROUP}function ig(A,e){A.openElements.clearBackToTableContext(),A._insertFakeElement(w.COLGROUP,i.COLGROUP),A.insertionMode=E.IN_COLUMN_GROUP,Js(A,e)}function ug(A,e){A.openElements.clearBackToTableContext(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_TABLE_BODY}function og(A,e){A.openElements.clearBackToTableContext(),A._insertFakeElement(w.TBODY,i.TBODY),A.insertionMode=E.IN_TABLE_BODY,en(A,e)}function cg(A,e){A.openElements.hasInTableScope(i.TABLE)&&(A.openElements.popUntilTagNamePopped(i.TABLE),A._resetInsertionMode(),A._processStartTag(e))}function lg(A,e){Ru(e)?A._appendElement(e,U.HTML):Ar(A,e),e.ackSelfClosing=!0}function fg(A,e){!A.formElement&&A.openElements.tmplCount===0&&(A._insertElement(e,U.HTML),A.formElement=A.openElements.current,A.openElements.pop())}function gt(A,e){switch(e.tagID){case i.TD:case i.TH:case i.TR:{og(A,e);break}case i.STYLE:case i.SCRIPT:case i.TEMPLATE:{se(A,e);break}case i.COL:{ig(A,e);break}case i.FORM:{fg(A,e);break}case i.TABLE:{cg(A,e);break}case i.TBODY:case i.TFOOT:case i.THEAD:{ug(A,e);break}case i.INPUT:{lg(A,e);break}case i.CAPTION:{sg(A,e);break}case i.COLGROUP:{ag(A,e);break}default:Ar(A,e)}}function zt(A,e){switch(e.tagID){case i.TABLE:{A.openElements.hasInTableScope(i.TABLE)&&(A.openElements.popUntilTagNamePopped(i.TABLE),A._resetInsertionMode());break}case i.TEMPLATE:{At(A,e);break}case i.BODY:case i.CAPTION:case i.COL:case i.COLGROUP:case i.HTML:case i.TBODY:case i.TD:case i.TFOOT:case i.TH:case i.THEAD:case i.TR:break;default:Ar(A,e)}}function Ar(A,e){const t=A.fosterParentingEnabled;A.fosterParentingEnabled=!0,$r(A,e),A.fosterParentingEnabled=t}function Vu(A,e){A.pendingCharacterTokens.push(e)}function Gu(A,e){A.pendingCharacterTokens.push(e),A.hasNonWhitespacePendingCharacterToken=!0}function er(A,e){let t=0;if(A.hasNonWhitespacePendingCharacterToken)for(;t<A.pendingCharacterTokens.length;t++)Ar(A,A.pendingCharacterTokens[t]);else for(;t<A.pendingCharacterTokens.length;t++)A._insertCharacters(A.pendingCharacterTokens[t]);A.insertionMode=A.originalInsertionMode,A._processToken(e)}const Yu=new Set([i.CAPTION,i.COL,i.COLGROUP,i.TBODY,i.TD,i.TFOOT,i.TH,i.THEAD,i.TR]);function hg(A,e){const t=e.tagID;Yu.has(t)?A.openElements.hasInTableScope(i.CAPTION)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(i.CAPTION),A.activeFormattingElements.clearToLastMarker(),A.insertionMode=E.IN_TABLE,gt(A,e)):xA(A,e)}function dg(A,e){const t=e.tagID;switch(t){case i.CAPTION:case i.TABLE:{A.openElements.hasInTableScope(i.CAPTION)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(i.CAPTION),A.activeFormattingElements.clearToLastMarker(),A.insertionMode=E.IN_TABLE,t===i.TABLE&&zt(A,e));break}case i.BODY:case i.COL:case i.COLGROUP:case i.HTML:case i.TBODY:case i.TD:case i.TFOOT:case i.TH:case i.THEAD:case i.TR:break;default:zr(A,e)}}function Js(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.COL:{A._appendElement(e,U.HTML),e.ackSelfClosing=!0;break}case i.TEMPLATE:{se(A,e);break}default:An(A,e)}}function Bg(A,e){switch(e.tagID){case i.COLGROUP:{A.openElements.currentTagId===i.COLGROUP&&(A.openElements.pop(),A.insertionMode=E.IN_TABLE);break}case i.TEMPLATE:{At(A,e);break}case i.COL:break;default:An(A,e)}}function An(A,e){A.openElements.currentTagId===i.COLGROUP&&(A.openElements.pop(),A.insertionMode=E.IN_TABLE,A._processToken(e))}function en(A,e){switch(e.tagID){case i.TR:{A.openElements.clearBackToTableBodyContext(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_ROW;break}case i.TH:case i.TD:{A.openElements.clearBackToTableBodyContext(),A._insertFakeElement(w.TR,i.TR),A.insertionMode=E.IN_ROW,tn(A,e);break}case i.CAPTION:case i.COL:case i.COLGROUP:case i.TBODY:case i.TFOOT:case i.THEAD:{A.openElements.hasTableBodyContextInTableScope()&&(A.openElements.clearBackToTableBodyContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE,gt(A,e));break}default:gt(A,e)}}function qs(A,e){const t=e.tagID;switch(e.tagID){case i.TBODY:case i.TFOOT:case i.THEAD:{A.openElements.hasInTableScope(t)&&(A.openElements.clearBackToTableBodyContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE);break}case i.TABLE:{A.openElements.hasTableBodyContextInTableScope()&&(A.openElements.clearBackToTableBodyContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE,zt(A,e));break}case i.BODY:case i.CAPTION:case i.COL:case i.COLGROUP:case i.HTML:case i.TD:case i.TH:case i.TR:break;default:zt(A,e)}}function tn(A,e){switch(e.tagID){case i.TH:case i.TD:{A.openElements.clearBackToTableRowContext(),A._insertElement(e,U.HTML),A.insertionMode=E.IN_CELL,A.activeFormattingElements.insertMarker();break}case i.CAPTION:case i.COL:case i.COLGROUP:case i.TBODY:case i.TFOOT:case i.THEAD:case i.TR:{A.openElements.hasInTableScope(i.TR)&&(A.openElements.clearBackToTableRowContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE_BODY,en(A,e));break}default:gt(A,e)}}function Xu(A,e){switch(e.tagID){case i.TR:{A.openElements.hasInTableScope(i.TR)&&(A.openElements.clearBackToTableRowContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE_BODY);break}case i.TABLE:{A.openElements.hasInTableScope(i.TR)&&(A.openElements.clearBackToTableRowContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE_BODY,qs(A,e));break}case i.TBODY:case i.TFOOT:case i.THEAD:{(A.openElements.hasInTableScope(e.tagID)||A.openElements.hasInTableScope(i.TR))&&(A.openElements.clearBackToTableRowContext(),A.openElements.pop(),A.insertionMode=E.IN_TABLE_BODY,qs(A,e));break}case i.BODY:case i.CAPTION:case i.COL:case i.COLGROUP:case i.HTML:case i.TD:case i.TH:break;default:zt(A,e)}}function gg(A,e){const t=e.tagID;Yu.has(t)?(A.openElements.hasInTableScope(i.TD)||A.openElements.hasInTableScope(i.TH))&&(A._closeTableCell(),tn(A,e)):xA(A,e)}function Eg(A,e){const t=e.tagID;switch(t){case i.TD:case i.TH:{A.openElements.hasInTableScope(t)&&(A.openElements.generateImpliedEndTags(),A.openElements.popUntilTagNamePopped(t),A.activeFormattingElements.clearToLastMarker(),A.insertionMode=E.IN_ROW);break}case i.TABLE:case i.TBODY:case i.TFOOT:case i.THEAD:case i.TR:{A.openElements.hasInTableScope(t)&&(A._closeTableCell(),Xu(A,e));break}case i.BODY:case i.CAPTION:case i.COL:case i.COLGROUP:case i.HTML:break;default:zr(A,e)}}function Wu(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.OPTION:{A.openElements.currentTagId===i.OPTION&&A.openElements.pop(),A._insertElement(e,U.HTML);break}case i.OPTGROUP:{A.openElements.currentTagId===i.OPTION&&A.openElements.pop(),A.openElements.currentTagId===i.OPTGROUP&&A.openElements.pop(),A._insertElement(e,U.HTML);break}case i.HR:{A.openElements.currentTagId===i.OPTION&&A.openElements.pop(),A.openElements.currentTagId===i.OPTGROUP&&A.openElements.pop(),A._appendElement(e,U.HTML),e.ackSelfClosing=!0;break}case i.INPUT:case i.KEYGEN:case i.TEXTAREA:case i.SELECT:{A.openElements.hasInSelectScope(i.SELECT)&&(A.openElements.popUntilTagNamePopped(i.SELECT),A._resetInsertionMode(),e.tagID!==i.SELECT&&A._processStartTag(e));break}case i.SCRIPT:case i.TEMPLATE:{se(A,e);break}}}function Ju(A,e){switch(e.tagID){case i.OPTGROUP:{A.openElements.stackTop>0&&A.openElements.currentTagId===i.OPTION&&A.openElements.tagIDs[A.openElements.stackTop-1]===i.OPTGROUP&&A.openElements.pop(),A.openElements.currentTagId===i.OPTGROUP&&A.openElements.pop();break}case i.OPTION:{A.openElements.currentTagId===i.OPTION&&A.openElements.pop();break}case i.SELECT:{A.openElements.hasInSelectScope(i.SELECT)&&(A.openElements.popUntilTagNamePopped(i.SELECT),A._resetInsertionMode());break}case i.TEMPLATE:{At(A,e);break}}}function pg(A,e){const t=e.tagID;t===i.CAPTION||t===i.TABLE||t===i.TBODY||t===i.TFOOT||t===i.THEAD||t===i.TR||t===i.TD||t===i.TH?(A.openElements.popUntilTagNamePopped(i.SELECT),A._resetInsertionMode(),A._processStartTag(e)):Wu(A,e)}function mg(A,e){const t=e.tagID;t===i.CAPTION||t===i.TABLE||t===i.TBODY||t===i.TFOOT||t===i.THEAD||t===i.TR||t===i.TD||t===i.TH?A.openElements.hasInTableScope(t)&&(A.openElements.popUntilTagNamePopped(i.SELECT),A._resetInsertionMode(),A.onEndTag(e)):Ju(A,e)}function Cg(A,e){switch(e.tagID){case i.BASE:case i.BASEFONT:case i.BGSOUND:case i.LINK:case i.META:case i.NOFRAMES:case i.SCRIPT:case i.STYLE:case i.TEMPLATE:case i.TITLE:{se(A,e);break}case i.CAPTION:case i.COLGROUP:case i.TBODY:case i.TFOOT:case i.THEAD:{A.tmplInsertionModeStack[0]=E.IN_TABLE,A.insertionMode=E.IN_TABLE,gt(A,e);break}case i.COL:{A.tmplInsertionModeStack[0]=E.IN_COLUMN_GROUP,A.insertionMode=E.IN_COLUMN_GROUP,Js(A,e);break}case i.TR:{A.tmplInsertionModeStack[0]=E.IN_TABLE_BODY,A.insertionMode=E.IN_TABLE_BODY,en(A,e);break}case i.TD:case i.TH:{A.tmplInsertionModeStack[0]=E.IN_ROW,A.insertionMode=E.IN_ROW,tn(A,e);break}default:A.tmplInsertionModeStack[0]=E.IN_BODY,A.insertionMode=E.IN_BODY,xA(A,e)}}function wg(A,e){e.tagID===i.TEMPLATE&&At(A,e)}function qu(A,e){A.openElements.tmplCount>0?(A.openElements.popUntilTagNamePopped(i.TEMPLATE),A.activeFormattingElements.clearToLastMarker(),A.tmplInsertionModeStack.shift(),A._resetInsertionMode(),A.onEof(e)):Xs(A,e)}function Tg(A,e){e.tagID===i.HTML?xA(A,e):rn(A,e)}function ju(A,e){var t;if(e.tagID===i.HTML){if(A.fragmentContext||(A.insertionMode=E.AFTER_AFTER_BODY),A.options.sourceCodeLocationInfo&&A.openElements.tagIDs[0]===i.HTML){A._setEndLocation(A.openElements.items[0],e);const r=A.openElements.items[1];r&&!(!((t=A.treeAdapter.getNodeSourceCodeLocation(r))===null||t===void 0)&&t.endTag)&&A._setEndLocation(r,e)}}else rn(A,e)}function rn(A,e){A.insertionMode=E.IN_BODY,$r(A,e)}function bg(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.FRAMESET:{A._insertElement(e,U.HTML);break}case i.FRAME:{A._appendElement(e,U.HTML),e.ackSelfClosing=!0;break}case i.NOFRAMES:{se(A,e);break}}}function Ug(A,e){e.tagID===i.FRAMESET&&!A.openElements.isRootHtmlElementCurrent()&&(A.openElements.pop(),!A.fragmentContext&&A.openElements.currentTagId!==i.FRAMESET&&(A.insertionMode=E.AFTER_FRAMESET))}function Qg(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.NOFRAMES:{se(A,e);break}}}function Fg(A,e){e.tagID===i.HTML&&(A.insertionMode=E.AFTER_AFTER_FRAMESET)}function Ig(A,e){e.tagID===i.HTML?xA(A,e):nn(A,e)}function nn(A,e){A.insertionMode=E.IN_BODY,$r(A,e)}function _g(A,e){switch(e.tagID){case i.HTML:{xA(A,e);break}case i.NOFRAMES:{se(A,e);break}}}function yg(A,e){e.chars=fA,A._insertCharacters(e)}function Ng(A,e){A._insertCharacters(e),A.framesetOk=!1}function Zu(A){for(;A.treeAdapter.getNamespaceURI(A.openElements.current)!==U.HTML&&!A._isIntegrationPoint(A.openElements.currentTagId,A.openElements.current);)A.openElements.pop()}function Sg(A,e){if(Xd(e))Zu(A),A._startTagOutsideForeignContent(e);else{const t=A._getAdjustedCurrentElement(),r=A.treeAdapter.getNamespaceURI(t);r===U.MATHML?Nu(e):r===U.SVG&&(Wd(e),Su(e)),Vs(e),e.selfClosing?A._appendElement(e,r):A._insertElement(e,r),e.ackSelfClosing=!0}}function vg(A,e){if(e.tagID===i.P||e.tagID===i.BR){Zu(A),A._endTagOutsideForeignContent(e);return}for(let t=A.openElements.stackTop;t>0;t--){const r=A.openElements.items[t];if(A.treeAdapter.getNamespaceURI(r)===U.HTML){A._endTagOutsideForeignContent(e);break}const n=A.treeAdapter.getTagName(r);if(n.toLowerCase()===e.tagName){e.tagName=n,A.openElements.shortenToLength(t);break}}}const Lg=new Set([w.AREA,w.BASE,w.BASEFONT,w.BGSOUND,w.BR,w.COL,w.EMBED,w.FRAME,w.HR,w.IMG,w.INPUT,w.KEYGEN,w.LINK,w.META,w.PARAM,w.SOURCE,w.TRACK,w.WBR]);function Hg(A,e){return e.treeAdapter.isElementNode(A)&&e.treeAdapter.getNamespaceURI(A)===U.HTML&&Lg.has(e.treeAdapter.getTagName(A))}const xg={treeAdapter:we,scriptingEnabled:!0};function Dg(A,e){const t={...xg,...e};return $u(A,t)}function Og(A,e){let t="";const r=e.treeAdapter.isElementNode(A)&&e.treeAdapter.getTagName(A)===w.TEMPLATE&&e.treeAdapter.getNamespaceURI(A)===U.HTML?e.treeAdapter.getTemplateContent(A):A,n=e.treeAdapter.getChildNodes(r);if(n)for(const s of n)t+=$u(s,e);return t}function $u(A,e){return e.treeAdapter.isElementNode(A)?Rg(A,e):e.treeAdapter.isTextNode(A)?kg(A,e):e.treeAdapter.isCommentNode(A)?Pg(A,e):e.treeAdapter.isDocumentTypeNode(A)?Kg(A,e):""}function Rg(A,e){const t=e.treeAdapter.getTagName(A);return`<${t}${Mg(A,e)}>${Hg(A,e)?"":`${Og(A,e)}</${t}>`}`}function Mg(A,{treeAdapter:e}){let t="";for(const r of e.getAttrList(A)){if(t+=" ",r.namespace)switch(r.namespace){case U.XML:{t+=`xml:${r.name}`;break}case U.XMLNS:{r.name!=="xmlns"&&(t+="xmlns:"),t+=r.name;break}case U.XLINK:{t+=`xlink:${r.name}`;break}default:t+=`${r.prefix}:${r.name}`}else t+=r.name;t+=`="${mi(r.value)}"`}return t}function kg(A,e){const{treeAdapter:t}=e,r=t.getTextNodeContent(A),n=t.getParentNode(A),s=n&&t.isElementNode(n)&&t.getTagName(n);return s&&t.getNamespaceURI(n)===U.HTML&&Cd(s,e.scriptingEnabled)?r:Ci(r)}function Pg(A,{treeAdapter:e}){return`<!--${e.getCommentNodeContent(A)}-->`}function Kg(A,{treeAdapter:e}){return`<!DOCTYPE ${e.getDocumentTypeNodeName(A)}>`}function Vg(A,e){return Hu.parse(A,e)}function Gg(A,e,t){typeof A=="string"&&(t=e,e=A,A=null);const r=Hu.getFragmentParser(A,t);return r.tokenizer.write(e,!0),r.getFragment()}function zu(A){const e=A.includes('"')?"'":'"';return e+A+e}function Yg(A,e,t){let r="!DOCTYPE ";return A&&(r+=A),e?r+=` PUBLIC ${zu(e)}`:t&&(r+=" SYSTEM"),t&&(r+=` ${zu(t)}`),r}const Le={isCommentNode:vr,isElementNode:X,isTextNode:le,createDocument(){const A=new Je([]);return A["x-mode"]=qA.NO_QUIRKS,A},createDocumentFragment(){return new Je([])},createElement(A,e,t){const r=Object.create(null),n=Object.create(null),s=Object.create(null);for(let u=0;u<t.length;u++){const o=t[u].name;r[o]=t[u].value,n[o]=t[u].namespace,s[o]=t[u].prefix}const a=new us(A,r,[]);return a.namespace=e,a["x-attribsNamespace"]=n,a["x-attribsPrefix"]=s,a},createCommentNode(A){return new ss(A)},createTextNode(A){return new Dt(A)},appendChild(A,e){const t=A.children[A.children.length-1];t&&(t.next=e,e.prev=t),A.children.push(e),e.parent=A},insertBefore(A,e,t){const r=A.children.indexOf(t),{prev:n}=t;n&&(n.next=e,e.prev=n),t.prev=e,e.next=t,A.children.splice(r,0,e),e.parent=A},setTemplateContent(A,e){Le.appendChild(A,e)},getTemplateContent(A){return A.children[0]},setDocumentType(A,e,t,r){const n=Yg(e,t,r);let s=A.children.find(a=>os(a)&&a.name==="!doctype");s?s.data=n??null:(s=new as("!doctype",n),Le.appendChild(A,s)),s["x-name"]=e,s["x-publicId"]=t,s["x-systemId"]=r},setDocumentMode(A,e){A["x-mode"]=e},getDocumentMode(A){return A["x-mode"]},detachNode(A){if(A.parent){const e=A.parent.children.indexOf(A),{prev:t,next:r}=A;A.prev=null,A.next=null,t&&(t.next=r),r&&(r.prev=t),A.parent.children.splice(e,1),A.parent=null}},insertText(A,e){const t=A.children[A.children.length-1];t&&le(t)?t.data+=e:Le.appendChild(A,Le.createTextNode(e))},insertTextBefore(A,e,t){const r=A.children[A.children.indexOf(t)-1];r&&le(r)?r.data+=e:Le.insertBefore(A,Le.createTextNode(e),t)},adoptAttributes(A,e){for(let t=0;t<e.length;t++){const r=e[t].name;A.attribs[r]===void 0&&(A.attribs[r]=e[t].value,A["x-attribsNamespace"][r]=e[t].namespace,A["x-attribsPrefix"][r]=e[t].prefix)}},getFirstChild(A){return A.children[0]},getChildNodes(A){return A.children},getParentNode(A){return A.parent},getAttrList(A){return A.attributes},getTagName(A){return A.name},getNamespaceURI(A){return A.namespace},getTextNodeContent(A){return A.data},getCommentNodeContent(A){return A.data},getDocumentTypeNodeName(A){var e;return(e=A["x-name"])!==null&&e!==void 0?e:""},getDocumentTypeNodePublicId(A){var e;return(e=A["x-publicId"])!==null&&e!==void 0?e:""},getDocumentTypeNodeSystemId(A){var e;return(e=A["x-systemId"])!==null&&e!==void 0?e:""},isDocumentTypeNode(A){return os(A)&&A.name==="!doctype"},setNodeSourceCodeLocation(A,e){e&&(A.startIndex=e.startOffset,A.endIndex=e.endOffset),A.sourceCodeLocation=e},getNodeSourceCodeLocation(A){return A.sourceCodeLocation},updateNodeSourceCodeLocation(A,e){e.endOffset!=null&&(A.endIndex=e.endOffset),A.sourceCodeLocation={...A.sourceCodeLocation,...e}}};function Xg(A,e,t,r){var n;return(n=e.treeAdapter)!==null&&n!==void 0||(e.treeAdapter=Le),e.scriptingEnabled!==!1&&(e.scriptingEnabled=!0),t?Vg(A,e):Gg(r,A,e)}const Wg={treeAdapter:Le};function Jg(A){const e="length"in A?A:[A];for(let r=0;r<e.length;r+=1){const n=e[r];_e(n)&&Array.prototype.splice.call(e,r,1,...n.children)}let t="";for(let r=0;r<e.length;r+=1){const n=e[r];t+=Dg(n,Wg)}return t}var G;(function(A){A[A.Tab=9]="Tab",A[A.NewLine=10]="NewLine",A[A.FormFeed=12]="FormFeed",A[A.CarriageReturn=13]="CarriageReturn",A[A.Space=32]="Space",A[A.ExclamationMark=33]="ExclamationMark",A[A.Number=35]="Number",A[A.Amp=38]="Amp",A[A.SingleQuote=39]="SingleQuote",A[A.DoubleQuote=34]="DoubleQuote",A[A.Dash=45]="Dash",A[A.Slash=47]="Slash",A[A.Zero=48]="Zero",A[A.Nine=57]="Nine",A[A.Semi=59]="Semi",A[A.Lt=60]="Lt",A[A.Eq=61]="Eq",A[A.Gt=62]="Gt",A[A.Questionmark=63]="Questionmark",A[A.UpperA=65]="UpperA",A[A.LowerA=97]="LowerA",A[A.UpperF=70]="UpperF",A[A.LowerF=102]="LowerF",A[A.UpperZ=90]="UpperZ",A[A.LowerZ=122]="LowerZ",A[A.LowerX=120]="LowerX",A[A.OpeningSquareBracket=91]="OpeningSquareBracket"})(G||(G={}));var _;(function(A){A[A.Text=1]="Text",A[A.BeforeTagName=2]="BeforeTagName",A[A.InTagName=3]="InTagName",A[A.InSelfClosingTag=4]="InSelfClosingTag",A[A.BeforeClosingTagName=5]="BeforeClosingTagName",A[A.InClosingTagName=6]="InClosingTagName",A[A.AfterClosingTagName=7]="AfterClosingTagName",A[A.BeforeAttributeName=8]="BeforeAttributeName",A[A.InAttributeName=9]="InAttributeName",A[A.AfterAttributeName=10]="AfterAttributeName",A[A.BeforeAttributeValue=11]="BeforeAttributeValue",A[A.InAttributeValueDq=12]="InAttributeValueDq",A[A.InAttributeValueSq=13]="InAttributeValueSq",A[A.InAttributeValueNq=14]="InAttributeValueNq",A[A.BeforeDeclaration=15]="BeforeDeclaration",A[A.InDeclaration=16]="InDeclaration",A[A.InProcessingInstruction=17]="InProcessingInstruction",A[A.BeforeComment=18]="BeforeComment",A[A.CDATASequence=19]="CDATASequence",A[A.InSpecialComment=20]="InSpecialComment",A[A.InCommentLike=21]="InCommentLike",A[A.BeforeSpecialS=22]="BeforeSpecialS",A[A.BeforeSpecialT=23]="BeforeSpecialT",A[A.SpecialStartSequence=24]="SpecialStartSequence",A[A.InSpecialTag=25]="InSpecialTag",A[A.InEntity=26]="InEntity"})(_||(_={}));function Te(A){return A===G.Space||A===G.NewLine||A===G.Tab||A===G.FormFeed||A===G.CarriageReturn}function sn(A){return A===G.Slash||A===G.Gt||Te(A)}function qg(A){return A>=G.LowerA&&A<=G.LowerZ||A>=G.UpperA&&A<=G.UpperZ}var he;(function(A){A[A.NoValue=0]="NoValue",A[A.Unquoted=1]="Unquoted",A[A.Single=2]="Single",A[A.Double=3]="Double"})(he||(he={}));const SA={Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,62]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101]),TextareaEnd:new Uint8Array([60,47,116,101,120,116,97,114,101,97])};let jg=class{constructor({xmlMode:e=!1,decodeEntities:t=!0},r){this.cbs=r,this.state=_.Text,this.buffer="",this.sectionStart=0,this.index=0,this.entityStart=0,this.baseState=_.Text,this.isSpecial=!1,this.running=!0,this.offset=0,this.currentSequence=void 0,this.sequenceIndex=0,this.xmlMode=e,this.decodeEntities=t,this.entityDecoder=new Bs(e?di:ls,(n,s)=>this.emitCodePoint(n,s))}reset(){this.state=_.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=_.Text,this.currentSequence=void 0,this.running=!0,this.offset=0}write(e){this.offset+=this.buffer.length,this.buffer=e,this.parse()}end(){this.running&&this.finish()}pause(){this.running=!1}resume(){this.running=!0,this.index<this.buffer.length+this.offset&&this.parse()}stateText(e){e===G.Lt||!this.decodeEntities&&this.fastForwardTo(G.Lt)?(this.index>this.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=_.BeforeTagName,this.sectionStart=this.index):this.decodeEntities&&e===G.Amp&&this.startEntity()}stateSpecialStartSequence(e){const t=this.sequenceIndex===this.currentSequence.length;if(!(t?sn(e):(e|32)===this.currentSequence[this.sequenceIndex]))this.isSpecial=!1;else if(!t){this.sequenceIndex++;return}this.sequenceIndex=0,this.state=_.InTagName,this.stateInTagName(e)}stateInSpecialTag(e){if(this.sequenceIndex===this.currentSequence.length){if(e===G.Gt||Te(e)){const t=this.index-this.currentSequence.length;if(this.sectionStart<t){const r=this.index;this.index=t,this.cbs.ontext(this.sectionStart,t),this.index=r}this.isSpecial=!1,this.sectionStart=t+2,this.stateInClosingTagName(e);return}this.sequenceIndex=0}(e|32)===this.currentSequence[this.sequenceIndex]?this.sequenceIndex+=1:this.sequenceIndex===0?this.currentSequence===SA.TitleEnd?this.decodeEntities&&e===G.Amp&&this.startEntity():this.fastForwardTo(G.Lt)&&(this.sequenceIndex=1):this.sequenceIndex=+(e===G.Lt)}stateCDATASequence(e){e===SA.Cdata[this.sequenceIndex]?++this.sequenceIndex===SA.Cdata.length&&(this.state=_.InCommentLike,this.currentSequence=SA.CdataEnd,this.sequenceIndex=0,this.sectionStart=this.index+1):(this.sequenceIndex=0,this.state=_.InDeclaration,this.stateInDeclaration(e))}fastForwardTo(e){for(;++this.index<this.buffer.length+this.offset;)if(this.buffer.charCodeAt(this.index-this.offset)===e)return!0;return this.index=this.buffer.length+this.offset-1,!1}stateInCommentLike(e){e===this.currentSequence[this.sequenceIndex]?++this.sequenceIndex===this.currentSequence.length&&(this.currentSequence===SA.CdataEnd?this.cbs.oncdata(this.sectionStart,this.index,2):this.cbs.oncomment(this.sectionStart,this.index,2),this.sequenceIndex=0,this.sectionStart=this.index+1,this.state=_.Text):this.sequenceIndex===0?this.fastForwardTo(this.currentSequence[0])&&(this.sequenceIndex=1):e!==this.currentSequence[this.sequenceIndex-1]&&(this.sequenceIndex=0)}isTagStartChar(e){return this.xmlMode?!sn(e):qg(e)}startSpecial(e,t){this.isSpecial=!0,this.currentSequence=e,this.sequenceIndex=t,this.state=_.SpecialStartSequence}stateBeforeTagName(e){if(e===G.ExclamationMark)this.state=_.BeforeDeclaration,this.sectionStart=this.index+1;else if(e===G.Questionmark)this.state=_.InProcessingInstruction,this.sectionStart=this.index+1;else if(this.isTagStartChar(e)){const t=e|32;this.sectionStart=this.index,this.xmlMode?this.state=_.InTagName:t===SA.ScriptEnd[2]?this.state=_.BeforeSpecialS:t===SA.TitleEnd[2]?this.state=_.BeforeSpecialT:this.state=_.InTagName}else e===G.Slash?this.state=_.BeforeClosingTagName:(this.state=_.Text,this.stateText(e))}stateInTagName(e){sn(e)&&(this.cbs.onopentagname(this.sectionStart,this.index),this.sectionStart=-1,this.state=_.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateBeforeClosingTagName(e){Te(e)||(e===G.Gt?this.state=_.Text:(this.state=this.isTagStartChar(e)?_.InClosingTagName:_.InSpecialComment,this.sectionStart=this.index))}stateInClosingTagName(e){(e===G.Gt||Te(e))&&(this.cbs.onclosetag(this.sectionStart,this.index),this.sectionStart=-1,this.state=_.AfterClosingTagName,this.stateAfterClosingTagName(e))}stateAfterClosingTagName(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.state=_.Text,this.sectionStart=this.index+1)}stateBeforeAttributeName(e){e===G.Gt?(this.cbs.onopentagend(this.index),this.isSpecial?(this.state=_.InSpecialTag,this.sequenceIndex=0):this.state=_.Text,this.sectionStart=this.index+1):e===G.Slash?this.state=_.InSelfClosingTag:Te(e)||(this.state=_.InAttributeName,this.sectionStart=this.index)}stateInSelfClosingTag(e){e===G.Gt?(this.cbs.onselfclosingtag(this.index),this.state=_.Text,this.sectionStart=this.index+1,this.isSpecial=!1):Te(e)||(this.state=_.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateInAttributeName(e){(e===G.Eq||sn(e))&&(this.cbs.onattribname(this.sectionStart,this.index),this.sectionStart=this.index,this.state=_.AfterAttributeName,this.stateAfterAttributeName(e))}stateAfterAttributeName(e){e===G.Eq?this.state=_.BeforeAttributeValue:e===G.Slash||e===G.Gt?(this.cbs.onattribend(he.NoValue,this.sectionStart),this.sectionStart=-1,this.state=_.BeforeAttributeName,this.stateBeforeAttributeName(e)):Te(e)||(this.cbs.onattribend(he.NoValue,this.sectionStart),this.state=_.InAttributeName,this.sectionStart=this.index)}stateBeforeAttributeValue(e){e===G.DoubleQuote?(this.state=_.InAttributeValueDq,this.sectionStart=this.index+1):e===G.SingleQuote?(this.state=_.InAttributeValueSq,this.sectionStart=this.index+1):Te(e)||(this.sectionStart=this.index,this.state=_.InAttributeValueNq,this.stateInAttributeValueNoQuotes(e))}handleInAttributeValue(e,t){e===t||!this.decodeEntities&&this.fastForwardTo(t)?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(t===G.DoubleQuote?he.Double:he.Single,this.index+1),this.state=_.BeforeAttributeName):this.decodeEntities&&e===G.Amp&&this.startEntity()}stateInAttributeValueDoubleQuotes(e){this.handleInAttributeValue(e,G.DoubleQuote)}stateInAttributeValueSingleQuotes(e){this.handleInAttributeValue(e,G.SingleQuote)}stateInAttributeValueNoQuotes(e){Te(e)||e===G.Gt?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(he.Unquoted,this.index),this.state=_.BeforeAttributeName,this.stateBeforeAttributeName(e)):this.decodeEntities&&e===G.Amp&&this.startEntity()}stateBeforeDeclaration(e){e===G.OpeningSquareBracket?(this.state=_.CDATASequence,this.sequenceIndex=0):this.state=e===G.Dash?_.BeforeComment:_.InDeclaration}stateInDeclaration(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.cbs.ondeclaration(this.sectionStart,this.index),this.state=_.Text,this.sectionStart=this.index+1)}stateInProcessingInstruction(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.cbs.onprocessinginstruction(this.sectionStart,this.index),this.state=_.Text,this.sectionStart=this.index+1)}stateBeforeComment(e){e===G.Dash?(this.state=_.InCommentLike,this.currentSequence=SA.CommentEnd,this.sequenceIndex=2,this.sectionStart=this.index+1):this.state=_.InDeclaration}stateInSpecialComment(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=_.Text,this.sectionStart=this.index+1)}stateBeforeSpecialS(e){const t=e|32;t===SA.ScriptEnd[3]?this.startSpecial(SA.ScriptEnd,4):t===SA.StyleEnd[3]?this.startSpecial(SA.StyleEnd,4):(this.state=_.InTagName,this.stateInTagName(e))}stateBeforeSpecialT(e){const t=e|32;t===SA.TitleEnd[3]?this.startSpecial(SA.TitleEnd,4):t===SA.TextareaEnd[3]?this.startSpecial(SA.TextareaEnd,4):(this.state=_.InTagName,this.stateInTagName(e))}startEntity(){this.baseState=this.state,this.state=_.InEntity,this.entityStart=this.index,this.entityDecoder.startEntity(this.xmlMode?$A.Strict:this.baseState===_.Text||this.baseState===_.InSpecialTag?$A.Legacy:$A.Attribute)}stateInEntity(){const e=this.entityDecoder.write(this.buffer,this.index-this.offset);e>=0?(this.state=this.baseState,e===0&&(this.index=this.entityStart)):this.index=this.offset+this.buffer.length-1}cleanup(){this.running&&this.sectionStart!==this.index&&(this.state===_.Text||this.state===_.InSpecialTag&&this.sequenceIndex===0?(this.cbs.ontext(this.sectionStart,this.index),this.sectionStart=this.index):(this.state===_.InAttributeValueDq||this.state===_.InAttributeValueSq||this.state===_.InAttributeValueNq)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=this.index))}shouldContinue(){return this.index<this.buffer.length+this.offset&&this.running}parse(){for(;this.shouldContinue();){const e=this.buffer.charCodeAt(this.index-this.offset);switch(this.state){case _.Text:{this.stateText(e);break}case _.SpecialStartSequence:{this.stateSpecialStartSequence(e);break}case _.InSpecialTag:{this.stateInSpecialTag(e);break}case _.CDATASequence:{this.stateCDATASequence(e);break}case _.InAttributeValueDq:{this.stateInAttributeValueDoubleQuotes(e);break}case _.InAttributeName:{this.stateInAttributeName(e);break}case _.InCommentLike:{this.stateInCommentLike(e);break}case _.InSpecialComment:{this.stateInSpecialComment(e);break}case _.BeforeAttributeName:{this.stateBeforeAttributeName(e);break}case _.InTagName:{this.stateInTagName(e);break}case _.InClosingTagName:{this.stateInClosingTagName(e);break}case _.BeforeTagName:{this.stateBeforeTagName(e);break}case _.AfterAttributeName:{this.stateAfterAttributeName(e);break}case _.InAttributeValueSq:{this.stateInAttributeValueSingleQuotes(e);break}case _.BeforeAttributeValue:{this.stateBeforeAttributeValue(e);break}case _.BeforeClosingTagName:{this.stateBeforeClosingTagName(e);break}case _.AfterClosingTagName:{this.stateAfterClosingTagName(e);break}case _.BeforeSpecialS:{this.stateBeforeSpecialS(e);break}case _.BeforeSpecialT:{this.stateBeforeSpecialT(e);break}case _.InAttributeValueNq:{this.stateInAttributeValueNoQuotes(e);break}case _.InSelfClosingTag:{this.stateInSelfClosingTag(e);break}case _.InDeclaration:{this.stateInDeclaration(e);break}case _.BeforeDeclaration:{this.stateBeforeDeclaration(e);break}case _.BeforeComment:{this.stateBeforeComment(e);break}case _.InProcessingInstruction:{this.stateInProcessingInstruction(e);break}case _.InEntity:{this.stateInEntity();break}}this.index++}this.cleanup()}finish(){this.state===_.InEntity&&(this.entityDecoder.end(),this.state=this.baseState),this.handleTrailingData(),this.cbs.onend()}handleTrailingData(){const e=this.buffer.length+this.offset;this.sectionStart>=e||(this.state===_.InCommentLike?this.currentSequence===SA.CdataEnd?this.cbs.oncdata(this.sectionStart,e,0):this.cbs.oncomment(this.sectionStart,e,0):this.state===_.InTagName||this.state===_.BeforeAttributeName||this.state===_.BeforeAttributeValue||this.state===_.AfterAttributeName||this.state===_.InAttributeName||this.state===_.InAttributeValueSq||this.state===_.InAttributeValueDq||this.state===_.InAttributeValueNq||this.state===_.InClosingTagName||this.cbs.ontext(this.sectionStart,e))}emitCodePoint(e,t){this.baseState!==_.Text&&this.baseState!==_.InSpecialTag?(this.sectionStart<this.entityStart&&this.cbs.onattribdata(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+t,this.index=this.sectionStart-1,this.cbs.onattribentity(e)):(this.sectionStart<this.entityStart&&this.cbs.ontext(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+t,this.index=this.sectionStart-1,this.cbs.ontextentity(e,this.sectionStart))}};const Et=new Set(["input","option","optgroup","select","button","datalist","textarea"]),aA=new Set(["p"]),Ao=new Set(["thead","tbody"]),eo=new Set(["dd","dt"]),to=new Set(["rt","rp"]),Zg=new Map([["tr",new Set(["tr","th","td"])],["th",new Set(["th"])],["td",new Set(["thead","th","td"])],["body",new Set(["head","link","script"])],["li",new Set(["li"])],["p",aA],["h1",aA],["h2",aA],["h3",aA],["h4",aA],["h5",aA],["h6",aA],["select",Et],["input",Et],["output",Et],["button",Et],["datalist",Et],["textarea",Et],["option",new Set(["option"])],["optgroup",new Set(["optgroup","option"])],["dd",eo],["dt",eo],["address",aA],["article",aA],["aside",aA],["blockquote",aA],["details",aA],["div",aA],["dl",aA],["fieldset",aA],["figcaption",aA],["figure",aA],["footer",aA],["form",aA],["header",aA],["hr",aA],["main",aA],["nav",aA],["ol",aA],["pre",aA],["section",aA],["table",aA],["ul",aA],["rt",to],["rp",to],["tbody",Ao],["tfoot",Ao]]),$g=new Set(["area","base","basefont","br","col","command","embed","frame","hr","img","input","isindex","keygen","link","meta","param","source","track","wbr"]),ro=new Set(["math","svg"]),no=new Set(["mi","mo","mn","ms","mtext","annotation-xml","foreignobject","desc","title"]),zg=/\s|\//;let AE=class{constructor(e,t={}){var r,n,s,a,u,o;this.options=t,this.startIndex=0,this.endIndex=0,this.openTagStart=0,this.tagname="",this.attribname="",this.attribvalue="",this.attribs=null,this.stack=[],this.buffers=[],this.bufferOffset=0,this.writeIndex=0,this.ended=!1,this.cbs=e??{},this.htmlMode=!this.options.xmlMode,this.lowerCaseTagNames=(r=t.lowerCaseTags)!==null&&r!==void 0?r:this.htmlMode,this.lowerCaseAttributeNames=(n=t.lowerCaseAttributeNames)!==null&&n!==void 0?n:this.htmlMode,this.recognizeSelfClosing=(s=t.recognizeSelfClosing)!==null&&s!==void 0?s:!this.htmlMode,this.tokenizer=new((a=t.Tokenizer)!==null&&a!==void 0?a:jg)(this.options,this),this.foreignContext=[!this.htmlMode],(o=(u=this.cbs).onparserinit)===null||o===void 0||o.call(u,this)}ontext(e,t){var r,n;const s=this.getSlice(e,t);this.endIndex=t-1,(n=(r=this.cbs).ontext)===null||n===void 0||n.call(r,s),this.startIndex=t}ontextentity(e,t){var r,n;this.endIndex=t-1,(n=(r=this.cbs).ontext)===null||n===void 0||n.call(r,hs(e)),this.startIndex=t}isVoidElement(e){return this.htmlMode&&$g.has(e)}onopentagname(e,t){this.endIndex=t;let r=this.getSlice(e,t);this.lowerCaseTagNames&&(r=r.toLowerCase()),this.emitOpenTag(r)}emitOpenTag(e){var t,r,n,s;this.openTagStart=this.startIndex,this.tagname=e;const a=this.htmlMode&&Zg.get(e);if(a)for(;this.stack.length>0&&a.has(this.stack[0]);){const u=this.stack.shift();(r=(t=this.cbs).onclosetag)===null||r===void 0||r.call(t,u,!0)}this.isVoidElement(e)||(this.stack.unshift(e),this.htmlMode&&(ro.has(e)?this.foreignContext.unshift(!0):no.has(e)&&this.foreignContext.unshift(!1))),(s=(n=this.cbs).onopentagname)===null||s===void 0||s.call(n,e),this.cbs.onopentag&&(this.attribs={})}endOpenTag(e){var t,r;this.startIndex=this.openTagStart,this.attribs&&((r=(t=this.cbs).onopentag)===null||r===void 0||r.call(t,this.tagname,this.attribs,e),this.attribs=null),this.cbs.onclosetag&&this.isVoidElement(this.tagname)&&this.cbs.onclosetag(this.tagname,!0),this.tagname=""}onopentagend(e){this.endIndex=e,this.endOpenTag(!1),this.startIndex=e+1}onclosetag(e,t){var r,n,s,a,u,o,c,f;this.endIndex=t;let h=this.getSlice(e,t);if(this.lowerCaseTagNames&&(h=h.toLowerCase()),this.htmlMode&&(ro.has(h)||no.has(h))&&this.foreignContext.shift(),this.isVoidElement(h))this.htmlMode&&h==="br"&&((a=(s=this.cbs).onopentagname)===null||a===void 0||a.call(s,"br"),(o=(u=this.cbs).onopentag)===null||o===void 0||o.call(u,"br",{},!0),(f=(c=this.cbs).onclosetag)===null||f===void 0||f.call(c,"br",!1));else{const d=this.stack.indexOf(h);if(d!==-1)for(let C=0;C<=d;C++){const m=this.stack.shift();(n=(r=this.cbs).onclosetag)===null||n===void 0||n.call(r,m,C!==d)}else this.htmlMode&&h==="p"&&(this.emitOpenTag("p"),this.closeCurrentTag(!0))}this.startIndex=t+1}onselfclosingtag(e){this.endIndex=e,this.recognizeSelfClosing||this.foreignContext[0]?(this.closeCurrentTag(!1),this.startIndex=e+1):this.onopentagend(e)}closeCurrentTag(e){var t,r;const n=this.tagname;this.endOpenTag(e),this.stack[0]===n&&((r=(t=this.cbs).onclosetag)===null||r===void 0||r.call(t,n,!e),this.stack.shift())}onattribname(e,t){this.startIndex=e;const r=this.getSlice(e,t);this.attribname=this.lowerCaseAttributeNames?r.toLowerCase():r}onattribdata(e,t){this.attribvalue+=this.getSlice(e,t)}onattribentity(e){this.attribvalue+=hs(e)}onattribend(e,t){var r,n;this.endIndex=t,(n=(r=this.cbs).onattribute)===null||n===void 0||n.call(r,this.attribname,this.attribvalue,e===he.Double?'"':e===he.Single?"'":e===he.NoValue?void 0:null),this.attribs&&!Object.prototype.hasOwnProperty.call(this.attribs,this.attribname)&&(this.attribs[this.attribname]=this.attribvalue),this.attribvalue=""}getInstructionName(e){const t=e.search(zg);let r=t<0?e:e.substr(0,t);return this.lowerCaseTagNames&&(r=r.toLowerCase()),r}ondeclaration(e,t){this.endIndex=t;const r=this.getSlice(e,t);if(this.cbs.onprocessinginstruction){const n=this.getInstructionName(r);this.cbs.onprocessinginstruction(`!${n}`,`!${r}`)}this.startIndex=t+1}onprocessinginstruction(e,t){this.endIndex=t;const r=this.getSlice(e,t);if(this.cbs.onprocessinginstruction){const n=this.getInstructionName(r);this.cbs.onprocessinginstruction(`?${n}`,`?${r}`)}this.startIndex=t+1}oncomment(e,t,r){var n,s,a,u;this.endIndex=t,(s=(n=this.cbs).oncomment)===null||s===void 0||s.call(n,this.getSlice(e,t-r)),(u=(a=this.cbs).oncommentend)===null||u===void 0||u.call(a),this.startIndex=t+1}oncdata(e,t,r){var n,s,a,u,o,c,f,h,d,C;this.endIndex=t;const m=this.getSlice(e,t-r);!this.htmlMode||this.options.recognizeCDATA?((s=(n=this.cbs).oncdatastart)===null||s===void 0||s.call(n),(u=(a=this.cbs).ontext)===null||u===void 0||u.call(a,m),(c=(o=this.cbs).oncdataend)===null||c===void 0||c.call(o)):((h=(f=this.cbs).oncomment)===null||h===void 0||h.call(f,`[CDATA[${m}]]`),(C=(d=this.cbs).oncommentend)===null||C===void 0||C.call(d)),this.startIndex=t+1}onend(){var e,t;if(this.cbs.onclosetag){this.endIndex=this.startIndex;for(let r=0;r<this.stack.length;r++)this.cbs.onclosetag(this.stack[r],!0)}(t=(e=this.cbs).onend)===null||t===void 0||t.call(e)}reset(){var e,t,r,n;(t=(e=this.cbs).onreset)===null||t===void 0||t.call(e),this.tokenizer.reset(),this.tagname="",this.attribname="",this.attribs=null,this.stack.length=0,this.startIndex=0,this.endIndex=0,(n=(r=this.cbs).onparserinit)===null||n===void 0||n.call(r,this),this.buffers.length=0,this.foreignContext.length=0,this.foreignContext.unshift(!this.htmlMode),this.bufferOffset=0,this.writeIndex=0,this.ended=!1}parseComplete(e){this.reset(),this.end(e)}getSlice(e,t){for(;e-this.bufferOffset>=this.buffers[0].length;)this.shiftBuffer();let r=this.buffers[0].slice(e-this.bufferOffset,t-this.bufferOffset);for(;t-this.bufferOffset>this.buffers[0].length;)this.shiftBuffer(),r+=this.buffers[0].slice(0,t-this.bufferOffset);return r}shiftBuffer(){this.bufferOffset+=this.buffers[0].length,this.writeIndex--,this.buffers.shift()}write(e){var t,r;if(this.ended){(r=(t=this.cbs).onerror)===null||r===void 0||r.call(t,new Error(".write() after done!"));return}this.buffers.push(e),this.tokenizer.running&&(this.tokenizer.write(e),this.writeIndex++)}end(e){var t,r;if(this.ended){(r=(t=this.cbs).onerror)===null||r===void 0||r.call(t,new Error(".end() after done!"));return}e&&this.write(e),this.ended=!0,this.tokenizer.end()}pause(){this.tokenizer.pause()}resume(){for(this.tokenizer.resume();this.tokenizer.running&&this.writeIndex<this.buffers.length;)this.tokenizer.write(this.buffers[this.writeIndex++]);this.ended&&this.tokenizer.end()}parseChunk(e){this.write(e)}done(e){this.end(e)}};function eE(A,e){const t=new t0(void 0,e);return new AE(t,e).end(A),t.root}const tE=Sh((A,e,t,r)=>e._useHtmlParser2?eE(A,e):Xg(A,e,t,r)),so=cd(tE,(A,e)=>e._useHtmlParser2?Lr(A,e):Jg(A));var q=(A=>(A[A.None=0]="None",A[A.Text=1]="Text",A[A.Image=2]="Image",A[A.Video=3]="Video",A[A.Icon=4]="Icon",A[A.Link=5]="Link",A[A.Button=6]="Button",A[A.Block=10]="Block",A))(q||{}),ae;(A=>{A.THEME_TEXT_COLOR_CLASS="gp-designer-theme-text",A.THEME_BUTTON_COLOR_CLASS="gp-designer-theme-button",A.THEME_ICON_COLOR_CLASS="gp-designer-theme-icon",A.THEME_COLOR="#3574e6"})(ae||(ae={}));const rE={key:0,"date-action":"1",contenteditable:"false",class:"text-red-500 text-xs mt-1"},nE=l.defineComponent({__name:"ElementRenderer",props:{element:{type:Object,required:!0},selectedElement:Object,hoveredElement:Object,uploadByFile:{type:Function,required:!1},icons:{type:Array,default:()=>[]},mode:{type:String,default:"edit"},cropper:{type:Object,required:!1},icon:{type:Object,required:!1},upload:{type:Object,required:!1},r:{type:String,required:!1}},emits:["selectElement","hoverElement","updateText","contentUpdated","blockAction","addIcon"],setup(A,{emit:e}){const t=A,r=e,n=l.computed(()=>t.selectedElement===t.element),s=l.computed(()=>t.hoveredElement===t.element),a=l.ref(!1),u=l.ref(!1),o=l.ref(""),c=l.computed(()=>t.element.rule.minText||0),f=l.computed(()=>t.element.rule.maxText||1/0);l.watch(()=>t.r,()=>{r("contentUpdated",Q())},{immediate:!0});function h(R){R.xpath!="/div[1]"&&t.mode!=="preview"&&(t.mode==="edit"?R.type===q.Text&&r("selectElement",R):r("selectElement",R),!R.rule.isReadOnly&&R.type===q.Text&&(a.value=!0))}function d(R){r("selectElement",R)}function C(R,P){r("hoverElement",R,P)}function m(R){r("hoverElement",R)}function T(R){R.currentTarget.contains(R.relatedTarget)?r("hoverElement",null):t.hoveredElement?r("hoverElement",null,t.hoveredElement.parentxpath):r("hoverElement",null)}function F(){a.value=!1,r("contentUpdated",Q())}function Q(){function R(z){var PA;const rA=z,lA=rA.rule.isThemeColor&&rA.type==q.Text?ae.THEME_TEXT_COLOR_CLASS:rA.rule.isThemeColor&&rA.type==q.Button?ae.THEME_BUTTON_COLOR_CLASS:rA.rule.isThemeColor&&rA.type==q.Icon?ae.THEME_ICON_COLOR_CLASS:"";lA?rA.attrs.class=rA.attrs.class?rA.attrs.class+" "+lA:lA:rA.attrs.class=(PA=rA.attrs.class)==null?void 0:PA.replace(new RegExp(`${ae.THEME_TEXT_COLOR_CLASS}|${ae.THEME_BUTTON_COLOR_CLASS}|${ae.THEME_ICON_COLOR_CLASS}`,"g"),"");const UA=Object.entries(z.attrs||{}).map(([wA,ce])=>`${wA}="${ce}"`).join(" "),HA=`<${z.tag}${UA?" "+UA:""}>`,RA=`</${z.tag}>`,QA=(z.children||[]).map(wA=>R(wA)).join("");return`${HA}${z.editText||z.text||""}${QA}${RA}`}return R(t.element)}function I(R){var lA;R.stopPropagation();const P=R.target,z=((lA=P.firstChild)==null?void 0:lA.nodeType)===Node.TEXT_NODE&&P.firstChild.nodeValue||"";if(z.length<c.value){u.value=!0,o.value=`最少输入 ${c.value} 个字符`;return}else if(z.length>f.value){u.value=!0,o.value=`最多输入 ${f.value} 个字符`;return}else u.value=!1,o.value="";r("updateText",{element:t.element,newText:z}),r("contentUpdated",Q());const rA=l.toRaw(t.element);rA.editText=z}function H(R){r("updateText",R),r("contentUpdated",Q())}function M(){const R={...t.element};r("blockAction",{action:"add",element:t.element,newBlock:R})}function y(){p(t.element),r("blockAction",{action:"moveUp",element:t.element})}function p(R){R.children&&R.children.length>0&&R.children.forEach(P=>{P.type==q.Text&&(P.text!==P.editText&&(P.text=P.editText),p(P))})}function v(){p(t.element),r("blockAction",{action:"moveDown",element:t.element})}function k(){r("blockAction",{action:"delete",element:t.element})}function O(R){r("blockAction",R),r("contentUpdated",Q())}function AA(R){W.value.openModal(R)}function oA(R){tA.value.openModal(R)}function cA(R,P){r("addIcon",R,P),r("contentUpdated",Q())}const W=l.ref(t.icon);l.watch(()=>t.icon,R=>{W.value=R},{immediate:!0});const tA=l.ref(t.upload);return l.watch(()=>t.upload,R=>{tA.value=R},{immediate:!0}),(R,P)=>{const z=l.resolveComponent("ElementRenderer",!0);return l.openBlock(),l.createElementBlock(l.Fragment,null,[(l.openBlock(),l.createBlock(l.resolveDynamicComponent(t.element.tag),l.mergeProps({class:["relative",A.mode==="design"?"m-1 p-1 border-dashed border-2":"",s.value?"border-dashed border-blue-500":"",n.value?"border-dashed border-green-500 z-10 border-2":"",u.value?"border-dashed border-red-500":"",(!s.value&&!n.value&&!u.value,""),t.element.rule&&t.element.rule.isReadOnly?"cursor-not-allowed":"",t.element.rule.isThemeColor&&t.element.type===l.unref(q).Text?l.unref(ae).THEME_TEXT_COLOR_CLASS:"",t.element.rule.isThemeColor&&t.element.type===l.unref(q).Button?l.unref(ae).THEME_BUTTON_COLOR_CLASS:"",t.element.rule.isThemeColor&&t.element.type===l.unref(q).Icon?l.unref(ae).THEME_ICON_COLOR_CLASS:""]},t.element.attrs,{contenteditable:a.value,onClick:P[2]||(P[2]=l.withModifiers(()=>h(t.element),["stop"])),onMouseenter:P[3]||(P[3]=()=>m(t.element)),onMouseleave:T,onBlur:F,onInput:I}),{default:l.withCtx(()=>[l.createTextVNode(l.toDisplayString(t.element.text),1),t.element.children&&t.element.children.length?(l.openBlock(),l.createElementBlock(l.Fragment,{key:0},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(t.element.children,(rA,lA)=>(l.openBlock(),l.createBlock(z,{key:lA,r:A.r,mode:A.mode,icons:A.icons,element:rA,selectedElement:t.selectedElement,hoveredElement:t.hoveredElement,cropper:A.cropper,icon:A.icon,upload:A.upload,"upload-by-file":A.uploadByFile,onSelectElement:d,onHoverElement:C,onUpdateText:H,onBlockAction:O,onAddIcon:cA},null,8,["r","mode","icons","element","selectedElement","hoveredElement","cropper","icon","upload","upload-by-file"]))),128)),t.element.type===l.unref(q).Block?(l.openBlock(),l.createElementBlock("div",{key:0,"date-action":"1",contenteditable:"false",onClick:P[0]||(P[0]=l.withModifiers(()=>{},["stop"])),class:"z-10 flex space-x-1 flex-none flex-nowrap overflow-visible absolute left-2 top-2 text-sm"},[l.createElementVNode("button",{class:"flex-none content-center items-center p-1 bg-green-500/80 text-white rounded hover:bg-green-500",onClick:l.withModifiers(M,["stop"])},P[6]||(P[6]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("rect",{width:"336",height:"336",x:"128",y:"128",fill:"none",stroke:"white","stroke-linejoin":"round","stroke-width":"32",rx:"57",ry:"57"}),l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"m383.5 128l.5-24a56.16 56.16 0 0 0-56-56H112a64.19 64.19 0 0 0-64 64v216a56.16 56.16 0 0 0 56 56h24"})],-1)])),l.createElementVNode("button",{class:"flex-none content-center items-center p-1 bg-blue-500/80 text-white rounded hover:bg-blue-500",onClick:l.withModifiers(y,["stop"])},P[7]||(P[7]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"48",d:"M244 400L100 256l144-144M120 256h292"})],-1)])),l.createElementVNode("button",{class:"flex-none content-center items-center p-1 bg-blue-500/80 text-white rounded hover:bg-blue-500",onClick:l.withModifiers(v,["stop"])},P[8]||(P[8]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"48",d:"m268 112l144 144l-144 144m124-144H100"})],-1)])),l.createElementVNode("button",{class:"flex-none content-center items-center p-1 bg-red-500/80 text-white rounded hover:bg-red-500",onClick:l.withModifiers(k,["stop"])},P[9]||(P[9]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M400 256H112"})],-1)]))])):l.createCommentVNode("",!0)],64)):l.createCommentVNode("",!0),t.element.type===l.unref(q).Icon?(l.openBlock(),l.createElementBlock("div",{key:1,class:"cursor-pointer rounded-sm w-5 h-5 flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-sm text-gray-50 z-10 bg-black/80 hover:bg-black",contenteditable:"false",onClick:P[1]||(P[1]=l.withModifiers(()=>AA(t.element),["stop"]))},P[10]||(P[10]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M320 367.79h76c55 0 100-29.21 100-83.6s-53-81.47-96-83.6c-8.89-85.06-71-136.8-144-136.8c-69 0-113.44 45.79-128 91.2c-60 5.7-112 43.88-112 106.4s54 106.4 120 106.4h56"}),l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"m320 255.79l-64-64l-64 64m64 192.42V207.79"})],-1)]))):l.createCommentVNode("",!0)]),_:1},16,["class","contenteditable"])),t.element.type==l.unref(q).Text&&u.value?(l.openBlock(),l.createElementBlock("div",rE,l.toDisplayString(o.value),1)):l.createCommentVNode("",!0),t.element.type===l.unref(q).Image?(l.openBlock(),l.createElementBlock("div",{key:1,class:"cursor-pointer rounded-sm flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-sm text-gray-50 z-10 bg-black/80 hover:bg-black",onClick:P[5]||(P[5]=l.withModifiers(()=>{},["stop"])),contenteditable:"false"},[l.createElementVNode("div",{class:"p-1",onClick:P[4]||(P[4]=l.withModifiers(()=>oA(t.element),["stop"]))},P[11]||(P[11]=[l.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512"},[l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"M320 367.79h76c55 0 100-29.21 100-83.6s-53-81.47-96-83.6c-8.89-85.06-71-136.8-144-136.8c-69 0-113.44 45.79-128 91.2c-60 5.7-112 43.88-112 106.4s54 106.4 120 106.4h56"}),l.createElementVNode("path",{fill:"none",stroke:"white","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32",d:"m320 255.79l-64-64l-64 64m64 192.42V207.79"})],-1)]))])):l.createCommentVNode("",!0)],64)}}}),He=(A,e)=>{const t=A.__vccOpts||A;for(const[r,n]of e)t[r]=n;return t},sE=He(nE,[["__scopeId","data-v-dbe35211"]]),aE=l.defineComponent({name:"GpCheckbox",props:{modelValue:{type:Boolean,required:!0},label:{type:String,default:""}},emits:["update:modelValue"],setup(A,{emit:e}){return{updateValue:r=>{e("update:modelValue",r.target.checked)}}}}),iE={class:"form-group"},uE={class:"flex items-center space-x-2 cursor-pointer"},oE=["checked","aria-checked"],cE={class:"checkbox-label text-sm text-gray-700"};function lE(A,e,t,r,n,s){return l.openBlock(),l.createElementBlock("div",iE,[l.createElementVNode("label",uE,[l.createElementVNode("input",{type:"checkbox",checked:A.modelValue,onChange:e[0]||(e[0]=(...a)=>A.updateValue&&A.updateValue(...a)),class:"custom-checkbox","aria-checked":A.modelValue},null,40,oE),l.createElementVNode("span",cE,l.toDisplayString(A.label),1)])])}const tr=He(aE,[["render",lE],["__scopeId","data-v-68b8f276"]]),fE=l.defineComponent({name:"GpMessage",props:{message:{type:String,required:!0},type:{type:String,default:"info"},position:{type:String,default:"top-right"},duration:{type:Number,default:3e3},onClose:{type:Function,required:!0},icon:{type:Boolean,default:!0}},setup(A){const e=l.ref(!1),t=l.computed(()=>({success:"bg-green-100 text-green-800",error:"bg-red-100 text-red-800",info:"bg-blue-100 text-blue-800",warning:"bg-yellow-100 text-yellow-800"})[A.type]),r=()=>{e.value=!1,A.onClose()};return setTimeout(()=>{r()},A.duration),e.value=!0,{visible:e,typeClass:t,closeMessage:r}}}),hE={key:0,class:"gp-message"},dE={key:0,class:"mr-2"},BE={key:0,class:"text-green-500"},gE={key:1,class:"text-red-500"},EE={key:2,class:"text-blue-500"},pE={key:3,class:"text-yellow-500"};function mE(A,e,t,r,n,s){return l.openBlock(),l.createBlock(l.Transition,{name:"fade"},{default:l.withCtx(()=>[A.visible?(l.openBlock(),l.createElementBlock("div",hE,[l.createElementVNode("div",{class:l.normalizeClass([A.typeClass,"message-content"])},[A.icon?(l.openBlock(),l.createElementBlock("span",dE,[l.renderSlot(A.$slots,"icon",{},()=>[A.type==="success"?(l.openBlock(),l.createElementBlock("span",BE,"✔")):l.createCommentVNode("",!0),A.type==="error"?(l.openBlock(),l.createElementBlock("span",gE,"✖")):l.createCommentVNode("",!0),A.type==="info"?(l.openBlock(),l.createElementBlock("span",EE,"ℹ")):l.createCommentVNode("",!0),A.type==="warning"?(l.openBlock(),l.createElementBlock("span",pE,"⚠")):l.createCommentVNode("",!0)],!0)])):l.createCommentVNode("",!0),l.createElementVNode("span",null,l.toDisplayString(A.message),1),l.createElementVNode("button",{class:"close-btn hover:text-gray-800 font-bold",onClick:e[0]||(e[0]=(...a)=>A.closeMessage&&A.closeMessage(...a))}," × ")],2)])):l.createCommentVNode("",!0)]),_:3})}const CE=He(fE,[["render",mE],["__scopeId","data-v-12cd136f"]]),pt=l.reactive([]);let js=null;const wE=()=>{const A=document.createElement("div");return A.id="global-message-container",document.body.appendChild(A),A},TE=()=>{if(js)return;const A=wE();js=l.createApp({setup(){return{messageQueue:pt}},render(){const e=l.computed(()=>{var r;return{"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4","top-center":"top-4 left-1/2 transform -translate-x-1/2","bottom-center":"bottom-4 left-1/2 transform -translate-x-1/2"}[((r=pt[0])==null?void 0:r.options.position)||"top-right"]});return l.h("div",{class:`fixed flex flex-col gap-2 ${e.value}`},pt.map(t=>l.h(CE,{key:t.id,...t.options,onClose:()=>ao(t.id)})))}}),js.mount(A)},ao=A=>{const e=pt.findIndex(t=>t.id===A);e!==-1&&pt.splice(e,1)};let bE=0;const j=A=>{TE();const e=bE++;pt.push({id:e,options:A}),setTimeout(()=>{ao(e)},A.duration||3e3)};j.success=(A,e=3e3,t=!0)=>{j(typeof A=="string"?{message:A,type:"success",duration:e,icon:t}:{...A,type:"success"})},j.error=(A,e=3e3,t=!0)=>{j(typeof A=="string"?{message:A,type:"error",duration:e,icon:t}:{...A,type:"error"})},j.info=(A,e=3e3,t=!0)=>{j(typeof A=="string"?{message:A,type:"info",duration:e,icon:t}:{...A,type:"info"})},j.warning=(A,e=3e3,t=!0)=>{j(typeof A=="string"?{message:A,type:"warning",duration:e,icon:t}:{...A,type:"warning"})};const UE={key:0},QE={key:0},FE={class:"text-gray-500 my-2 truncate"},IE={class:"text-gray-500 my-2 break-words"},_E={key:1},yE={key:2},NE={key:3},SE={key:4},vE={key:5},LE={key:6},HE={key:7},xE={key:8},DE={key:9},OE={key:10},RE=He(l.defineComponent({__name:"EditorPanel",props:{element:Object},emits:["updateElement"],setup(A,{emit:e}){const t=A,r=e,n=l.ref({rule:{},...t.element});l.watch(()=>t.element,a=>{n.value={rule:{},...a}},{immediate:!0});function s(){if(n.value.type===q.Icon&&!n.value.attrs.class.includes("iconfont")){j.error("图标仅支持 iconfont 图标");return}if(n.value.type===q.Image&&n.value.tag!=="img"){j.error("节点类型错误");return}if(n.value.type===q.Video&&n.value.tag!=="video"){j.error("节点类型错误");return}if(n.value.type===q.Link&&n.value.tag!=="a"){j.error("节点类型错误");return}if(n.value.type===q.Text){if(Number(n.value.rule.minText)>Number(n.value.rule.maxText)){j.error("最小文本长度不能大于最大文本长度");return}if(n.value.tag!=="p"&&n.value.tag!=="div"&&n.value.tag!=="span"&&n.value.tag!=="h1"&&n.value.tag!=="h2"&&n.value.tag!=="h3"&&n.value.tag!=="h4"&&n.value.tag!=="h5"&&n.value.tag!=="h6"){j.error("节点类型错误");return}}if(n.value.type===q.Block){if(Number(n.value.rule.minBlock)>Number(n.value.rule.maxBlock)){j.error("最小块数量不能大于最大块数量");return}if(n.value.tag!=="div"&&n.value.tag!=="section"&&n.value.tag!=="article"&&n.value.tag!=="nav"&&n.value.tag!=="header"&&n.value.tag!=="footer"&&n.value.tag!=="span"&&n.value.tag!=="p"&&n.value.tag!=="img"){j.error("节点类型错误");return}if(!n.value.children||n.value.children.length<1){j.error("节点错误,必须包含子元素");return}}r("updateElement",n.value)}return(a,u)=>(l.openBlock(),l.createElementBlock("div",null,[n.value?(l.openBlock(),l.createElementBlock("div",UE,[n.value.text!==void 0?(l.openBlock(),l.createElementBlock("div",QE,[u[13]||(u[13]=l.createElementVNode("label",{class:"block"},"内容",-1)),l.createElementVNode("div",FE,l.toDisplayString(n.value.text||"-"),1)])):l.createCommentVNode("",!0),l.createElementVNode("div",null,[u[14]||(u[14]=l.createElementVNode("label",{class:"block mt-4"},"节点",-1)),l.createElementVNode("div",IE,l.toDisplayString(n.value.xpath),1)]),l.createElementVNode("div",null,[u[16]||(u[16]=l.createElementVNode("label",{class:"block mt-4"},"类型",-1)),l.withDirectives(l.createElementVNode("select",{"onUpdate:modelValue":u[0]||(u[0]=o=>n.value.type=o),class:"border rounded p-1 w-full"},u[15]||(u[15]=[l.createElementVNode("option",{value:0},"无",-1),l.createElementVNode("option",{value:1},"文本",-1),l.createElementVNode("option",{value:2},"图片",-1),l.createElementVNode("option",{value:3},"视频",-1),l.createElementVNode("option",{value:4},"图标",-1),l.createElementVNode("option",{value:5},"链接",-1),l.createElementVNode("option",{value:6},"按钮",-1),l.createElementVNode("option",{value:10},"块",-1)]),512),[[l.vModelSelect,n.value.type]])]),n.value.type==l.unref(q).Text?(l.openBlock(),l.createElementBlock("div",_E,[u[17]||(u[17]=l.createElementVNode("label",{class:"block mt-4"},"最小文本长度",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[1]||(u[1]=o=>n.value.rule.minText=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.minText]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Text?(l.openBlock(),l.createElementBlock("div",yE,[u[18]||(u[18]=l.createElementVNode("label",{class:"block mt-4"},"最大文本长度",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[2]||(u[2]=o=>n.value.rule.maxText=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.maxText]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Image?(l.openBlock(),l.createElementBlock("div",NE,[u[19]||(u[19]=l.createElementVNode("label",{class:"block mt-4"},"是否裁剪",-1)),l.createVNode(tr,{class:"py-2",modelValue:n.value.rule.crop,"onUpdate:modelValue":u[3]||(u[3]=o=>n.value.rule.crop=o),label:"是"},null,8,["modelValue"])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Image?(l.openBlock(),l.createElementBlock("div",SE,[u[20]||(u[20]=l.createElementVNode("label",{class:"block mt-4"},"图片宽度",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[4]||(u[4]=o=>n.value.rule.minImageWidth=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.minImageWidth]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Image?(l.openBlock(),l.createElementBlock("div",vE,[u[21]||(u[21]=l.createElementVNode("label",{class:"block mt-4"},"图片高度",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=o=>n.value.rule.maxImageHeight=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.maxImageHeight]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Block?(l.openBlock(),l.createElementBlock("div",LE,[u[22]||(u[22]=l.createElementVNode("label",{class:"block mt-4"},"块最小数量",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[6]||(u[6]=o=>n.value.rule.minBlock=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.minBlock]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Block?(l.openBlock(),l.createElementBlock("div",HE,[u[23]||(u[23]=l.createElementVNode("label",{class:"block mt-4"},"块最大数量",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[7]||(u[7]=o=>n.value.rule.maxBlock=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.maxBlock]])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Text||n.value.type==l.unref(q).Icon||n.value.type==l.unref(q).Button?(l.openBlock(),l.createElementBlock("div",xE,[u[24]||(u[24]=l.createElementVNode("label",{class:"block mt-4"},"主题色",-1)),l.createVNode(tr,{class:"py-2",modelValue:n.value.rule.isThemeColor,"onUpdate:modelValue":u[8]||(u[8]=o=>n.value.rule.isThemeColor=o),label:"是"},null,8,["modelValue"])])):l.createCommentVNode("",!0),l.createElementVNode("div",null,[u[25]||(u[25]=l.createElementVNode("label",{class:"block mt-4"},"是否必填",-1)),l.createVNode(tr,{class:"py-2",modelValue:n.value.rule.isRequired,"onUpdate:modelValue":u[9]||(u[9]=o=>n.value.rule.isRequired=o),label:"是"},null,8,["modelValue"])]),l.createElementVNode("div",null,[u[26]||(u[26]=l.createElementVNode("label",{class:"block mt-4"},"是否只读",-1)),l.createVNode(tr,{class:"py-2",modelValue:n.value.rule.isReadOnly,"onUpdate:modelValue":u[10]||(u[10]=o=>n.value.rule.isReadOnly=o),label:"是"},null,8,["modelValue"])]),n.value.type==l.unref(q).Link||n.value.type==l.unref(q).Button?(l.openBlock(),l.createElementBlock("div",DE,[u[27]||(u[27]=l.createElementVNode("label",{class:"block mt-4"},"打开美洽",-1)),l.createVNode(tr,{class:"py-2",modelValue:n.value.rule.openMeiqia,"onUpdate:modelValue":u[11]||(u[11]=o=>n.value.rule.openMeiqia=o),label:"是"},null,8,["modelValue"])])):l.createCommentVNode("",!0),n.value.type==l.unref(q).Link||n.value.type==l.unref(q).Button?(l.openBlock(),l.createElementBlock("div",OE,[u[28]||(u[28]=l.createElementVNode("label",{class:"block mt-4"},"链接",-1)),l.withDirectives(l.createElementVNode("input",{"onUpdate:modelValue":u[12]||(u[12]=o=>n.value.rule.linkUrl=o),class:"border rounded p-1 w-full"},null,512),[[l.vModelText,n.value.rule.linkUrl]])])):l.createCommentVNode("",!0)])):l.createCommentVNode("",!0),l.createElementVNode("button",{onClick:s,class:"mt-4 p-2 bg-green-500 text-white rounded"}," 保存 ")]))}}),[["__scopeId","data-v-b1f745aa"]]);/*!
9
9
  * Cropper.js v1.6.2
10
10
  * https://fengyuanchen.github.io/cropperjs
11
11
  *
@@ -35,4 +35,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
35
35
  content: "" !important;
36
36
  display: none !important;
37
37
  }`,Ab=function(A){eb(A,"."+si+$T+Sl+`
38
- .`+ai+zT+Sl)},eb=function(A,e){var t=A.ownerDocument;if(t){var r=t.createElement("style");r.textContent=e,A.appendChild(r)}},vl=function(){function A(){}return A.getOrigin=function(e){var t=A._link;return t?(t.href=e,t.href=t.href,t.protocol+t.hostname+t.port):"about:blank"},A.isSameOrigin=function(e){return A.getOrigin(e)===A._origin},A.setContext=function(e){A._link=e.document.createElement("a"),A._origin=A.getOrigin(e.location.href)},A._origin="about:blank",A}(),tb=function(){function A(e,t){this.context=e,this._options=t,this._cache={}}return A.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)||(ui(e)||ab(e))&&(this._cache[e]=this.loadImage(e)).catch(function(){}),t},A.prototype.match=function(e){return this._cache[e]},A.prototype.loadImage=function(e){return kA(this,void 0,void 0,function(){var t,r,n,s,a=this;return DA(this,function(u){switch(u.label){case 0:return t=vl.isSameOrigin(e),r=!ii(e)&&this._options.useCORS===!0&&LA.SUPPORT_CORS_IMAGES&&!t,n=!ii(e)&&!t&&!ui(e)&&typeof this._options.proxy=="string"&&LA.SUPPORT_CORS_XHR&&!r,!t&&this._options.allowTaint===!1&&!ii(e)&&!ui(e)&&!n&&!r?[2]:(s=e,n?[4,this.proxy(s)]:[3,2]);case 1:s=u.sent(),u.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise(function(o,c){var f=new Image;f.onload=function(){return o(f)},f.onerror=c,(ib(s)||r)&&(f.crossOrigin="anonymous"),f.src=s,f.complete===!0&&setTimeout(function(){return o(f)},500),a._options.imageTimeout>0&&setTimeout(function(){return c("Timed out ("+a._options.imageTimeout+"ms) loading image")},a._options.imageTimeout)})];case 3:return[2,u.sent()]}})})},A.prototype.has=function(e){return typeof this._cache[e]<"u"},A.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},A.prototype.proxy=function(e){var t=this,r=this._options.proxy;if(!r)throw new Error("No proxy defined");var n=e.substring(0,256);return new Promise(function(s,a){var u=LA.SUPPORT_RESPONSE_TYPE?"blob":"text",o=new XMLHttpRequest;o.onload=function(){if(o.status===200)if(u==="text")s(o.response);else{var h=new FileReader;h.addEventListener("load",function(){return s(h.result)},!1),h.addEventListener("error",function(d){return a(d)},!1),h.readAsDataURL(o.response)}else a("Failed to proxy resource "+n+" with status code "+o.status)},o.onerror=a;var c=r.indexOf("?")>-1?"&":"?";if(o.open("GET",""+r+c+"url="+encodeURIComponent(e)+"&responseType="+u),u!=="text"&&o instanceof XMLHttpRequest&&(o.responseType=u),t._options.imageTimeout){var f=t._options.imageTimeout;o.timeout=f,o.ontimeout=function(){return a("Timed out ("+f+"ms) proxying "+n)}}o.send()})},A}(),rb=/^data:image\/svg\+xml/i,nb=/^data:image\/.*;base64,/i,sb=/^data:image\/.*/i,ab=function(A){return LA.SUPPORT_SVG_DRAWING||!ub(A)},ii=function(A){return sb.test(A)},ib=function(A){return nb.test(A)},ui=function(A){return A.substr(0,4)==="blob"},ub=function(A){return A.substr(-3).toLowerCase()==="svg"||rb.test(A)},x=function(){function A(e,t){this.type=0,this.x=e,this.y=t}return A.prototype.add=function(e,t){return new A(this.x+e,this.y+t)},A}(),Lt=function(A,e,t){return new x(A.x+(e.x-A.x)*t,A.y+(e.y-A.y)*t)},Zn=function(){function A(e,t,r,n){this.type=1,this.start=e,this.startControl=t,this.endControl=r,this.end=n}return A.prototype.subdivide=function(e,t){var r=Lt(this.start,this.startControl,e),n=Lt(this.startControl,this.endControl,e),s=Lt(this.endControl,this.end,e),a=Lt(r,n,e),u=Lt(n,s,e),o=Lt(a,u,e);return t?new A(this.start,r,a,o):new A(o,u,s,this.end)},A.prototype.add=function(e,t){return new A(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))},A.prototype.reverse=function(){return new A(this.end,this.endControl,this.startControl,this.start)},A}(),re=function(A){return A.type===1},ob=function(){function A(e){var t=e.styles,r=e.bounds,n=br(t.borderTopLeftRadius,r.width,r.height),s=n[0],a=n[1],u=br(t.borderTopRightRadius,r.width,r.height),o=u[0],c=u[1],f=br(t.borderBottomRightRadius,r.width,r.height),h=f[0],d=f[1],C=br(t.borderBottomLeftRadius,r.width,r.height),m=C[0],T=C[1],F=[];F.push((s+o)/r.width),F.push((m+h)/r.width),F.push((a+T)/r.height),F.push((c+d)/r.height);var Q=Math.max.apply(Math,F);Q>1&&(s/=Q,a/=Q,o/=Q,c/=Q,h/=Q,d/=Q,m/=Q,T/=Q);var I=r.width-o,H=r.height-d,M=r.width-h,y=r.height-T,p=t.borderTopWidth,v=t.borderRightWidth,k=t.borderBottomWidth,O=t.borderLeftWidth,AA=uA(t.paddingTop,e.bounds.width),oA=uA(t.paddingRight,e.bounds.width),cA=uA(t.paddingBottom,e.bounds.width),W=uA(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=s>0||a>0?BA(r.left+O/3,r.top+p/3,s-O/3,a-p/3,sA.TOP_LEFT):new x(r.left+O/3,r.top+p/3),this.topRightBorderDoubleOuterBox=s>0||a>0?BA(r.left+I,r.top+p/3,o-v/3,c-p/3,sA.TOP_RIGHT):new x(r.left+r.width-v/3,r.top+p/3),this.bottomRightBorderDoubleOuterBox=h>0||d>0?BA(r.left+M,r.top+H,h-v/3,d-k/3,sA.BOTTOM_RIGHT):new x(r.left+r.width-v/3,r.top+r.height-k/3),this.bottomLeftBorderDoubleOuterBox=m>0||T>0?BA(r.left+O/3,r.top+y,m-O/3,T-k/3,sA.BOTTOM_LEFT):new x(r.left+O/3,r.top+r.height-k/3),this.topLeftBorderDoubleInnerBox=s>0||a>0?BA(r.left+O*2/3,r.top+p*2/3,s-O*2/3,a-p*2/3,sA.TOP_LEFT):new x(r.left+O*2/3,r.top+p*2/3),this.topRightBorderDoubleInnerBox=s>0||a>0?BA(r.left+I,r.top+p*2/3,o-v*2/3,c-p*2/3,sA.TOP_RIGHT):new x(r.left+r.width-v*2/3,r.top+p*2/3),this.bottomRightBorderDoubleInnerBox=h>0||d>0?BA(r.left+M,r.top+H,h-v*2/3,d-k*2/3,sA.BOTTOM_RIGHT):new x(r.left+r.width-v*2/3,r.top+r.height-k*2/3),this.bottomLeftBorderDoubleInnerBox=m>0||T>0?BA(r.left+O*2/3,r.top+y,m-O*2/3,T-k*2/3,sA.BOTTOM_LEFT):new x(r.left+O*2/3,r.top+r.height-k*2/3),this.topLeftBorderStroke=s>0||a>0?BA(r.left+O/2,r.top+p/2,s-O/2,a-p/2,sA.TOP_LEFT):new x(r.left+O/2,r.top+p/2),this.topRightBorderStroke=s>0||a>0?BA(r.left+I,r.top+p/2,o-v/2,c-p/2,sA.TOP_RIGHT):new x(r.left+r.width-v/2,r.top+p/2),this.bottomRightBorderStroke=h>0||d>0?BA(r.left+M,r.top+H,h-v/2,d-k/2,sA.BOTTOM_RIGHT):new x(r.left+r.width-v/2,r.top+r.height-k/2),this.bottomLeftBorderStroke=m>0||T>0?BA(r.left+O/2,r.top+y,m-O/2,T-k/2,sA.BOTTOM_LEFT):new x(r.left+O/2,r.top+r.height-k/2),this.topLeftBorderBox=s>0||a>0?BA(r.left,r.top,s,a,sA.TOP_LEFT):new x(r.left,r.top),this.topRightBorderBox=o>0||c>0?BA(r.left+I,r.top,o,c,sA.TOP_RIGHT):new x(r.left+r.width,r.top),this.bottomRightBorderBox=h>0||d>0?BA(r.left+M,r.top+H,h,d,sA.BOTTOM_RIGHT):new x(r.left+r.width,r.top+r.height),this.bottomLeftBorderBox=m>0||T>0?BA(r.left,r.top+y,m,T,sA.BOTTOM_LEFT):new x(r.left,r.top+r.height),this.topLeftPaddingBox=s>0||a>0?BA(r.left+O,r.top+p,Math.max(0,s-O),Math.max(0,a-p),sA.TOP_LEFT):new x(r.left+O,r.top+p),this.topRightPaddingBox=o>0||c>0?BA(r.left+Math.min(I,r.width-v),r.top+p,I>r.width+v?0:Math.max(0,o-v),Math.max(0,c-p),sA.TOP_RIGHT):new x(r.left+r.width-v,r.top+p),this.bottomRightPaddingBox=h>0||d>0?BA(r.left+Math.min(M,r.width-O),r.top+Math.min(H,r.height-k),Math.max(0,h-v),Math.max(0,d-k),sA.BOTTOM_RIGHT):new x(r.left+r.width-v,r.top+r.height-k),this.bottomLeftPaddingBox=m>0||T>0?BA(r.left+O,r.top+Math.min(y,r.height-k),Math.max(0,m-O),Math.max(0,T-k),sA.BOTTOM_LEFT):new x(r.left+O,r.top+r.height-k),this.topLeftContentBox=s>0||a>0?BA(r.left+O+W,r.top+p+AA,Math.max(0,s-(O+W)),Math.max(0,a-(p+AA)),sA.TOP_LEFT):new x(r.left+O+W,r.top+p+AA),this.topRightContentBox=o>0||c>0?BA(r.left+Math.min(I,r.width+O+W),r.top+p+AA,I>r.width+O+W?0:o-O+W,c-(p+AA),sA.TOP_RIGHT):new x(r.left+r.width-(v+oA),r.top+p+AA),this.bottomRightContentBox=h>0||d>0?BA(r.left+Math.min(M,r.width-(O+W)),r.top+Math.min(H,r.height+p+AA),Math.max(0,h-(v+oA)),d-(k+cA),sA.BOTTOM_RIGHT):new x(r.left+r.width-(v+oA),r.top+r.height-(k+cA)),this.bottomLeftContentBox=m>0||T>0?BA(r.left+O+W,r.top+y,Math.max(0,m-(O+W)),T-(k+cA),sA.BOTTOM_LEFT):new x(r.left+O+W,r.top+r.height-(k+cA))}return A}(),sA;(function(A){A[A.TOP_LEFT=0]="TOP_LEFT",A[A.TOP_RIGHT=1]="TOP_RIGHT",A[A.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",A[A.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(sA||(sA={}));var BA=function(A,e,t,r,n){var s=4*((Math.sqrt(2)-1)/3),a=t*s,u=r*s,o=A+t,c=e+r;switch(n){case sA.TOP_LEFT:return new Zn(new x(A,c),new x(A,c-u),new x(o-a,e),new x(o,e));case sA.TOP_RIGHT:return new Zn(new x(A,e),new x(A+a,e),new x(o,c-u),new x(o,c));case sA.BOTTOM_RIGHT:return new Zn(new x(o,e),new x(o,e+u),new x(A+a,c),new x(A,c));case sA.BOTTOM_LEFT:default:return new Zn(new x(o,c),new x(o-a,c),new x(A,e+u),new x(A,e))}},$n=function(A){return[A.topLeftBorderBox,A.topRightBorderBox,A.bottomRightBorderBox,A.bottomLeftBorderBox]},cb=function(A){return[A.topLeftContentBox,A.topRightContentBox,A.bottomRightContentBox,A.bottomLeftContentBox]},zn=function(A){return[A.topLeftPaddingBox,A.topRightPaddingBox,A.bottomRightPaddingBox,A.bottomLeftPaddingBox]},lb=function(){function A(e,t,r){this.offsetX=e,this.offsetY=t,this.matrix=r,this.type=0,this.target=6}return A}(),As=function(){function A(e,t){this.path=e,this.target=t,this.type=1}return A}(),fb=function(){function A(e){this.opacity=e,this.type=2,this.target=6}return A}(),hb=function(A){return A.type===0},Ll=function(A){return A.type===1},db=function(A){return A.type===2},Hl=function(A,e){return A.length===e.length?A.some(function(t,r){return t===e[r]}):!1},Bb=function(A,e,t,r,n){return A.map(function(s,a){switch(a){case 0:return s.add(e,t);case 1:return s.add(e+r,t);case 2:return s.add(e+r,t+n);case 3:return s.add(e,t+n)}return s})},xl=function(){function A(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return A}(),Dl=function(){function A(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new ob(this.container),this.container.styles.opacity<1&&this.effects.push(new fb(this.container.styles.opacity)),this.container.styles.transform!==null){var r=this.container.bounds.left+this.container.styles.transformOrigin[0].number,n=this.container.bounds.top+this.container.styles.transformOrigin[1].number,s=this.container.styles.transform;this.effects.push(new lb(r,n,s))}if(this.container.styles.overflowX!==0){var a=$n(this.curves),u=zn(this.curves);Hl(a,u)?this.effects.push(new As(a,6)):(this.effects.push(new As(a,2)),this.effects.push(new As(u,4)))}}return A.prototype.getEffects=function(e){for(var t=[2,3].indexOf(this.container.styles.position)===-1,r=this.parent,n=this.effects.slice(0);r;){var s=r.effects.filter(function(o){return!Ll(o)});if(t||r.container.styles.position!==0||!r.parent){if(n.unshift.apply(n,s),t=[2,3].indexOf(r.container.styles.position)===-1,r.container.styles.overflowX!==0){var a=$n(r.curves),u=zn(r.curves);Hl(a,u)||n.unshift(new As(u,6))}}else n.unshift.apply(n,s);r=r.parent}return n.filter(function(o){return bA(o.target,e)})},A}(),oi=function(A,e,t,r){A.container.elements.forEach(function(n){var s=bA(n.flags,4),a=bA(n.flags,2),u=new Dl(n,A);bA(n.styles.display,2048)&&r.push(u);var o=bA(n.flags,8)?[]:r;if(s||a){var c=s||n.styles.isPositioned()?t:e,f=new xl(u);if(n.styles.isPositioned()||n.styles.opacity<1||n.styles.isTransformed()){var h=n.styles.zIndex.order;if(h<0){var d=0;c.negativeZIndex.some(function(m,T){return h>m.element.container.styles.zIndex.order?(d=T,!1):d>0}),c.negativeZIndex.splice(d,0,f)}else if(h>0){var C=0;c.positiveZIndex.some(function(m,T){return h>=m.element.container.styles.zIndex.order?(C=T+1,!1):C>0}),c.positiveZIndex.splice(C,0,f)}else c.zeroOrAutoZIndexOrTransformedOrOpacity.push(f)}else n.styles.isFloating()?c.nonPositionedFloats.push(f):c.nonPositionedInlineLevel.push(f);oi(u,f,s?f:t,o)}else n.styles.isInlineLevel()?e.inlineLevel.push(u):e.nonInlineLevel.push(u),oi(u,e,t,o);bA(n.flags,8)&&Ol(n,o)})},Ol=function(A,e){for(var t=A instanceof $a?A.start:1,r=A instanceof $a?A.reversed:!1,n=0;n<e.length;n++){var s=e[n];s.container instanceof ul&&typeof s.container.value=="number"&&s.container.value!==0&&(t=s.container.value),s.listValue=yr(t,s.container.styles.listStyleType,!0),t+=r?-1:1}},gb=function(A){var e=new Dl(A,null),t=new xl(e),r=[];return oi(e,t,t,r),Ol(e.container,r),t},Rl=function(A,e){switch(e){case 0:return ne(A.topLeftBorderBox,A.topLeftPaddingBox,A.topRightBorderBox,A.topRightPaddingBox);case 1:return ne(A.topRightBorderBox,A.topRightPaddingBox,A.bottomRightBorderBox,A.bottomRightPaddingBox);case 2:return ne(A.bottomRightBorderBox,A.bottomRightPaddingBox,A.bottomLeftBorderBox,A.bottomLeftPaddingBox);case 3:default:return ne(A.bottomLeftBorderBox,A.bottomLeftPaddingBox,A.topLeftBorderBox,A.topLeftPaddingBox)}},Eb=function(A,e){switch(e){case 0:return ne(A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox,A.topRightBorderBox,A.topRightBorderDoubleOuterBox);case 1:return ne(A.topRightBorderBox,A.topRightBorderDoubleOuterBox,A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox);case 2:return ne(A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox,A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox);case 3:default:return ne(A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox,A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox)}},pb=function(A,e){switch(e){case 0:return ne(A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox,A.topRightBorderDoubleInnerBox,A.topRightPaddingBox);case 1:return ne(A.topRightBorderDoubleInnerBox,A.topRightPaddingBox,A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox);case 2:return ne(A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox,A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox);case 3:default:return ne(A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox,A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox)}},mb=function(A,e){switch(e){case 0:return es(A.topLeftBorderStroke,A.topRightBorderStroke);case 1:return es(A.topRightBorderStroke,A.bottomRightBorderStroke);case 2:return es(A.bottomRightBorderStroke,A.bottomLeftBorderStroke);case 3:default:return es(A.bottomLeftBorderStroke,A.topLeftBorderStroke)}},es=function(A,e){var t=[];return re(A)?t.push(A.subdivide(.5,!1)):t.push(A),re(e)?t.push(e.subdivide(.5,!0)):t.push(e),t},ne=function(A,e,t,r){var n=[];return re(A)?n.push(A.subdivide(.5,!1)):n.push(A),re(t)?n.push(t.subdivide(.5,!0)):n.push(t),re(r)?n.push(r.subdivide(.5,!0).reverse()):n.push(r),re(e)?n.push(e.subdivide(.5,!1).reverse()):n.push(e),n},Ml=function(A){var e=A.bounds,t=A.styles;return e.add(t.borderLeftWidth,t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth),-(t.borderTopWidth+t.borderBottomWidth))},ts=function(A){var e=A.styles,t=A.bounds,r=uA(e.paddingLeft,t.width),n=uA(e.paddingRight,t.width),s=uA(e.paddingTop,t.width),a=uA(e.paddingBottom,t.width);return t.add(r+e.borderLeftWidth,s+e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth+r+n),-(e.borderTopWidth+e.borderBottomWidth+s+a))},Cb=function(A,e){return A===0?e.bounds:A===2?ts(e):Ml(e)},wb=function(A,e){return A===0?e.bounds:A===2?ts(e):Ml(e)},ci=function(A,e,t){var r=Cb(xt(A.styles.backgroundOrigin,e),A),n=wb(xt(A.styles.backgroundClip,e),A),s=Tb(xt(A.styles.backgroundSize,e),t,r),a=s[0],u=s[1],o=br(xt(A.styles.backgroundPosition,e),r.width-a,r.height-u),c=bb(xt(A.styles.backgroundRepeat,e),o,s,r,n),f=Math.round(r.left+o[0]),h=Math.round(r.top+o[1]);return[c,f,h,a,u]},Ht=function(A){return iA(A)&&A.value===yt.AUTO},rs=function(A){return typeof A=="number"},Tb=function(A,e,t){var r=e[0],n=e[1],s=e[2],a=A[0],u=A[1];if(!a)return[0,0];if(CA(a)&&u&&CA(u))return[uA(a,t.width),uA(u,t.height)];var o=rs(s);if(iA(a)&&(a.value===yt.CONTAIN||a.value===yt.COVER)){if(rs(s)){var c=t.width/t.height;return c<s!=(a.value===yt.COVER)?[t.width,t.width/s]:[t.height*s,t.height]}return[t.width,t.height]}var f=rs(r),h=rs(n),d=f||h;if(Ht(a)&&(!u||Ht(u))){if(f&&h)return[r,n];if(!o&&!d)return[t.width,t.height];if(d&&o){var C=f?r:n*s,m=h?n:r/s;return[C,m]}var T=f?r:t.width,F=h?n:t.height;return[T,F]}if(o){var Q=0,I=0;return CA(a)?Q=uA(a,t.width):CA(u)&&(I=uA(u,t.height)),Ht(a)?Q=I*s:(!u||Ht(u))&&(I=Q/s),[Q,I]}var H=null,M=null;if(CA(a)?H=uA(a,t.width):u&&CA(u)&&(M=uA(u,t.height)),H!==null&&(!u||Ht(u))&&(M=f&&h?H/r*n:t.height),M!==null&&Ht(a)&&(H=f&&h?M/n*r:t.width),H!==null&&M!==null)return[H,M];throw new Error("Unable to calculate background-size for element")},xt=function(A,e){var t=A[e];return typeof t>"u"?A[0]:t},bb=function(A,e,t,r,n){var s=e[0],a=e[1],u=t[0],o=t[1];switch(A){case 2:return[new x(Math.round(r.left),Math.round(r.top+a)),new x(Math.round(r.left+r.width),Math.round(r.top+a)),new x(Math.round(r.left+r.width),Math.round(o+r.top+a)),new x(Math.round(r.left),Math.round(o+r.top+a))];case 3:return[new x(Math.round(r.left+s),Math.round(r.top)),new x(Math.round(r.left+s+u),Math.round(r.top)),new x(Math.round(r.left+s+u),Math.round(r.height+r.top)),new x(Math.round(r.left+s),Math.round(r.height+r.top))];case 1:return[new x(Math.round(r.left+s),Math.round(r.top+a)),new x(Math.round(r.left+s+u),Math.round(r.top+a)),new x(Math.round(r.left+s+u),Math.round(r.top+a+o)),new x(Math.round(r.left+s),Math.round(r.top+a+o))];default:return[new x(Math.round(n.left),Math.round(n.top)),new x(Math.round(n.left+n.width),Math.round(n.top)),new x(Math.round(n.left+n.width),Math.round(n.height+n.top)),new x(Math.round(n.left),Math.round(n.height+n.top))]}},Ub="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",kl="Hidden Text",Qb=function(){function A(e){this._data={},this._document=e}return A.prototype.parseMetrics=function(e,t){var r=this._document.createElement("div"),n=this._document.createElement("img"),s=this._document.createElement("span"),a=this._document.body;r.style.visibility="hidden",r.style.fontFamily=e,r.style.fontSize=t,r.style.margin="0",r.style.padding="0",r.style.whiteSpace="nowrap",a.appendChild(r),n.src=Ub,n.width=1,n.height=1,n.style.margin="0",n.style.padding="0",n.style.verticalAlign="baseline",s.style.fontFamily=e,s.style.fontSize=t,s.style.margin="0",s.style.padding="0",s.appendChild(this._document.createTextNode(kl)),r.appendChild(s),r.appendChild(n);var u=n.offsetTop-s.offsetTop+2;r.removeChild(s),r.appendChild(this._document.createTextNode(kl)),r.style.lineHeight="normal",n.style.verticalAlign="super";var o=n.offsetTop-r.offsetTop+2;return a.removeChild(r),{baseline:u,middle:o}},A.prototype.getMetrics=function(e,t){var r=e+" "+t;return typeof this._data[r]>"u"&&(this._data[r]=this.parseMetrics(e,t)),this._data[r]},A}(),Pl=function(){function A(e,t){this.context=e,this.options=t}return A}(),Fb=1e4,Ib=function(A){ue(e,A);function e(t,r){var n=A.call(this,t,r)||this;return n._activeEffects=[],n.canvas=r.canvas?r.canvas:document.createElement("canvas"),n.ctx=n.canvas.getContext("2d"),r.canvas||(n.canvas.width=Math.floor(r.width*r.scale),n.canvas.height=Math.floor(r.height*r.scale),n.canvas.style.width=r.width+"px",n.canvas.style.height=r.height+"px"),n.fontMetrics=new Qb(document),n.ctx.scale(n.options.scale,n.options.scale),n.ctx.translate(-r.x,-r.y),n.ctx.textBaseline="bottom",n._activeEffects=[],n.context.logger.debug("Canvas renderer initialized ("+r.width+"x"+r.height+") with scale "+r.scale),n}return e.prototype.applyEffects=function(t){for(var r=this;this._activeEffects.length;)this.popEffect();t.forEach(function(n){return r.applyEffect(n)})},e.prototype.applyEffect=function(t){this.ctx.save(),db(t)&&(this.ctx.globalAlpha=t.opacity),hb(t)&&(this.ctx.translate(t.offsetX,t.offsetY),this.ctx.transform(t.matrix[0],t.matrix[1],t.matrix[2],t.matrix[3],t.matrix[4],t.matrix[5]),this.ctx.translate(-t.offsetX,-t.offsetY)),Ll(t)&&(this.path(t.path),this.ctx.clip()),this._activeEffects.push(t)},e.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},e.prototype.renderStack=function(t){return kA(this,void 0,void 0,function(){var r;return DA(this,function(n){switch(n.label){case 0:return r=t.element.container.styles,r.isVisible()?[4,this.renderStackContent(t)]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},e.prototype.renderNode=function(t){return kA(this,void 0,void 0,function(){return DA(this,function(r){switch(r.label){case 0:if(bA(t.container.flags,16))debugger;return t.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(t)]:[3,3];case 1:return r.sent(),[4,this.renderNodeContent(t)];case 2:r.sent(),r.label=3;case 3:return[2]}})})},e.prototype.renderTextWithLetterSpacing=function(t,r,n){var s=this;if(r===0)this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+n);else{var a=Za(t.text);a.reduce(function(u,o){return s.ctx.fillText(o,u,t.bounds.top+n),u+s.ctx.measureText(o).width},t.bounds.left)}},e.prototype.createFontStyle=function(t){var r=t.fontVariant.filter(function(a){return a==="normal"||a==="small-caps"}).join(""),n=vb(t.fontFamily).join(", "),s=Tr(t.fontSize)?""+t.fontSize.number+t.fontSize.unit:t.fontSize.number+"px";return[[t.fontStyle,r,t.fontWeight,s,n].join(" "),n,s]},e.prototype.renderTextNode=function(t,r){return kA(this,void 0,void 0,function(){var n,s,a,u,o,c,f,h,d=this;return DA(this,function(C){return n=this.createFontStyle(r),s=n[0],a=n[1],u=n[2],this.ctx.font=s,this.ctx.direction=r.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",o=this.fontMetrics.getMetrics(a,u),c=o.baseline,f=o.middle,h=r.paintOrder,t.textBounds.forEach(function(m){h.forEach(function(T){switch(T){case 0:d.ctx.fillStyle=NA(r.color),d.renderTextWithLetterSpacing(m,r.letterSpacing,c);var F=r.textShadow;F.length&&m.text.trim().length&&(F.slice(0).reverse().forEach(function(Q){d.ctx.shadowColor=NA(Q.color),d.ctx.shadowOffsetX=Q.offsetX.number*d.options.scale,d.ctx.shadowOffsetY=Q.offsetY.number*d.options.scale,d.ctx.shadowBlur=Q.blur.number,d.renderTextWithLetterSpacing(m,r.letterSpacing,c)}),d.ctx.shadowColor="",d.ctx.shadowOffsetX=0,d.ctx.shadowOffsetY=0,d.ctx.shadowBlur=0),r.textDecorationLine.length&&(d.ctx.fillStyle=NA(r.textDecorationColor||r.color),r.textDecorationLine.forEach(function(Q){switch(Q){case 1:d.ctx.fillRect(m.bounds.left,Math.round(m.bounds.top+c),m.bounds.width,1);break;case 2:d.ctx.fillRect(m.bounds.left,Math.round(m.bounds.top),m.bounds.width,1);break;case 3:d.ctx.fillRect(m.bounds.left,Math.ceil(m.bounds.top+f),m.bounds.width,1);break}}));break;case 1:r.webkitTextStrokeWidth&&m.text.trim().length&&(d.ctx.strokeStyle=NA(r.webkitTextStrokeColor),d.ctx.lineWidth=r.webkitTextStrokeWidth,d.ctx.lineJoin=window.chrome?"miter":"round",d.ctx.strokeText(m.text,m.bounds.left,m.bounds.top+c)),d.ctx.strokeStyle="",d.ctx.lineWidth=0,d.ctx.lineJoin="miter";break}})}),[2]})})},e.prototype.renderReplacedElement=function(t,r,n){if(n&&t.intrinsicWidth>0&&t.intrinsicHeight>0){var s=ts(t),a=zn(r);this.path(a),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(n,0,0,t.intrinsicWidth,t.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},e.prototype.renderNodeContent=function(t){return kA(this,void 0,void 0,function(){var r,n,s,a,u,o,I,I,c,f,h,d,M,C,m,y,T,F,Q,I,H,M,y;return DA(this,function(p){switch(p.label){case 0:this.applyEffects(t.getEffects(4)),r=t.container,n=t.curves,s=r.styles,a=0,u=r.textNodes,p.label=1;case 1:return a<u.length?(o=u[a],[4,this.renderTextNode(o,s)]):[3,4];case 2:p.sent(),p.label=3;case 3:return a++,[3,1];case 4:if(!(r instanceof sl))return[3,8];p.label=5;case 5:return p.trys.push([5,7,,8]),[4,this.context.cache.match(r.src)];case 6:return I=p.sent(),this.renderReplacedElement(r,n,I),[3,8];case 7:return p.sent(),this.context.logger.error("Error loading image "+r.src),[3,8];case 8:if(r instanceof al&&this.renderReplacedElement(r,n,r.canvas),!(r instanceof il))return[3,12];p.label=9;case 9:return p.trys.push([9,11,,12]),[4,this.context.cache.match(r.svg)];case 10:return I=p.sent(),this.renderReplacedElement(r,n,I),[3,12];case 11:return p.sent(),this.context.logger.error("Error loading svg "+r.svg.substring(0,255)),[3,12];case 12:return r instanceof fl&&r.tree?(c=new e(this.context,{scale:this.options.scale,backgroundColor:r.backgroundColor,x:0,y:0,width:r.width,height:r.height}),[4,c.render(r.tree)]):[3,14];case 13:f=p.sent(),r.width&&r.height&&this.ctx.drawImage(f,0,0,r.width,r.height,r.bounds.left,r.bounds.top,r.bounds.width,r.bounds.height),p.label=14;case 14:if(r instanceof za&&(h=Math.min(r.bounds.width,r.bounds.height),r.type===Yn?r.checked&&(this.ctx.save(),this.path([new x(r.bounds.left+h*.39363,r.bounds.top+h*.79),new x(r.bounds.left+h*.16,r.bounds.top+h*.5549),new x(r.bounds.left+h*.27347,r.bounds.top+h*.44071),new x(r.bounds.left+h*.39694,r.bounds.top+h*.5649),new x(r.bounds.left+h*.72983,r.bounds.top+h*.23),new x(r.bounds.left+h*.84,r.bounds.top+h*.34085),new x(r.bounds.left+h*.39363,r.bounds.top+h*.79)]),this.ctx.fillStyle=NA(ol),this.ctx.fill(),this.ctx.restore()):r.type===Xn&&r.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(r.bounds.left+h/2,r.bounds.top+h/2,h/4,0,Math.PI*2,!0),this.ctx.fillStyle=NA(ol),this.ctx.fill(),this.ctx.restore())),_b(r)&&r.value.length){switch(d=this.createFontStyle(s),M=d[0],C=d[1],m=this.fontMetrics.getMetrics(M,C).baseline,this.ctx.font=M,this.ctx.fillStyle=NA(s.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=Nb(r.styles.textAlign),y=ts(r),T=0,r.styles.textAlign){case 1:T+=y.width/2;break;case 2:T+=y.width;break}F=y.add(T,0,0,-y.height/2+1),this.ctx.save(),this.path([new x(y.left,y.top),new x(y.left+y.width,y.top),new x(y.left+y.width,y.top+y.height),new x(y.left,y.top+y.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new Ir(r.value,F),s.letterSpacing,m),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!bA(r.styles.display,2048))return[3,20];if(r.styles.listStyleImage===null)return[3,19];if(Q=r.styles.listStyleImage,Q.type!==0)return[3,18];I=void 0,H=Q.url,p.label=15;case 15:return p.trys.push([15,17,,18]),[4,this.context.cache.match(H)];case 16:return I=p.sent(),this.ctx.drawImage(I,r.bounds.left-(I.width+10),r.bounds.top),[3,18];case 17:return p.sent(),this.context.logger.error("Error loading list-style-image "+H),[3,18];case 18:return[3,20];case 19:t.listValue&&r.styles.listStyleType!==-1&&(M=this.createFontStyle(s)[0],this.ctx.font=M,this.ctx.fillStyle=NA(s.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",y=new be(r.bounds.left,r.bounds.top+uA(r.styles.paddingTop,r.bounds.width),r.bounds.width,kc(s.lineHeight,s.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new Ir(t.listValue,y),s.letterSpacing,kc(s.lineHeight,s.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"),p.label=20;case 20:return[2]}})})},e.prototype.renderStackContent=function(t){return kA(this,void 0,void 0,function(){var r,n,Q,s,a,Q,u,o,Q,c,f,Q,h,d,Q,C,m,Q,T,F,Q;return DA(this,function(I){switch(I.label){case 0:if(bA(t.element.container.flags,16))debugger;return[4,this.renderNodeBackgroundAndBorders(t.element)];case 1:I.sent(),r=0,n=t.negativeZIndex,I.label=2;case 2:return r<n.length?(Q=n[r],[4,this.renderStack(Q)]):[3,5];case 3:I.sent(),I.label=4;case 4:return r++,[3,2];case 5:return[4,this.renderNodeContent(t.element)];case 6:I.sent(),s=0,a=t.nonInlineLevel,I.label=7;case 7:return s<a.length?(Q=a[s],[4,this.renderNode(Q)]):[3,10];case 8:I.sent(),I.label=9;case 9:return s++,[3,7];case 10:u=0,o=t.nonPositionedFloats,I.label=11;case 11:return u<o.length?(Q=o[u],[4,this.renderStack(Q)]):[3,14];case 12:I.sent(),I.label=13;case 13:return u++,[3,11];case 14:c=0,f=t.nonPositionedInlineLevel,I.label=15;case 15:return c<f.length?(Q=f[c],[4,this.renderStack(Q)]):[3,18];case 16:I.sent(),I.label=17;case 17:return c++,[3,15];case 18:h=0,d=t.inlineLevel,I.label=19;case 19:return h<d.length?(Q=d[h],[4,this.renderNode(Q)]):[3,22];case 20:I.sent(),I.label=21;case 21:return h++,[3,19];case 22:C=0,m=t.zeroOrAutoZIndexOrTransformedOrOpacity,I.label=23;case 23:return C<m.length?(Q=m[C],[4,this.renderStack(Q)]):[3,26];case 24:I.sent(),I.label=25;case 25:return C++,[3,23];case 26:T=0,F=t.positiveZIndex,I.label=27;case 27:return T<F.length?(Q=F[T],[4,this.renderStack(Q)]):[3,30];case 28:I.sent(),I.label=29;case 29:return T++,[3,27];case 30:return[2]}})})},e.prototype.mask=function(t){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(t.slice(0).reverse()),this.ctx.closePath()},e.prototype.path=function(t){this.ctx.beginPath(),this.formatPath(t),this.ctx.closePath()},e.prototype.formatPath=function(t){var r=this;t.forEach(function(n,s){var a=re(n)?n.start:n;s===0?r.ctx.moveTo(a.x,a.y):r.ctx.lineTo(a.x,a.y),re(n)&&r.ctx.bezierCurveTo(n.startControl.x,n.startControl.y,n.endControl.x,n.endControl.y,n.end.x,n.end.y)})},e.prototype.renderRepeat=function(t,r,n,s){this.path(t),this.ctx.fillStyle=r,this.ctx.translate(n,s),this.ctx.fill(),this.ctx.translate(-n,-s)},e.prototype.resizeImage=function(t,r,n){var s;if(t.width===r&&t.height===n)return t;var a=(s=this.canvas.ownerDocument)!==null&&s!==void 0?s:document,u=a.createElement("canvas");u.width=Math.max(1,r),u.height=Math.max(1,n);var o=u.getContext("2d");return o.drawImage(t,0,0,t.width,t.height,0,0,r,n),u},e.prototype.renderBackgroundImage=function(t){return kA(this,void 0,void 0,function(){var r,n,s,a,u,o;return DA(this,function(c){switch(c.label){case 0:r=t.styles.backgroundImage.length-1,n=function(f){var h,d,C,AA,P,z,W,tA,k,m,AA,P,z,W,tA,T,F,Q,I,H,M,y,p,v,k,O,AA,oA,cA,W,tA,R,P,z,rA,lA,UA,HA,RA,QA,PA,wA;return DA(this,function(ce){switch(ce.label){case 0:if(f.type!==0)return[3,5];h=void 0,d=f.url,ce.label=1;case 1:return ce.trys.push([1,3,,4]),[4,s.context.cache.match(d)];case 2:return h=ce.sent(),[3,4];case 3:return ce.sent(),s.context.logger.error("Error loading background-image "+d),[3,4];case 4:return h&&(C=ci(t,r,[h.width,h.height,h.width/h.height]),AA=C[0],P=C[1],z=C[2],W=C[3],tA=C[4],k=s.ctx.createPattern(s.resizeImage(h,W,tA),"repeat"),s.renderRepeat(AA,k,P,z)),[3,6];case 5:h1(f)?(m=ci(t,r,[null,null,null]),AA=m[0],P=m[1],z=m[2],W=m[3],tA=m[4],T=u1(f.angle,W,tA),F=T[0],Q=T[1],I=T[2],H=T[3],M=T[4],y=document.createElement("canvas"),y.width=W,y.height=tA,p=y.getContext("2d"),v=p.createLinearGradient(Q,H,I,M),yc(f.stops,F).forEach(function(We){return v.addColorStop(We.stop,NA(We.color))}),p.fillStyle=v,p.fillRect(0,0,W,tA),W>0&&tA>0&&(k=s.ctx.createPattern(y,"repeat"),s.renderRepeat(AA,k,P,z))):d1(f)&&(O=ci(t,r,[null,null,null]),AA=O[0],oA=O[1],cA=O[2],W=O[3],tA=O[4],R=f.position.length===0?[Da]:f.position,P=uA(R[0],W),z=uA(R[R.length-1],tA),rA=o1(f,P,z,W,tA),lA=rA[0],UA=rA[1],lA>0&&UA>0&&(HA=s.ctx.createRadialGradient(oA+P,cA+z,0,oA+P,cA+z,lA),yc(f.stops,lA*2).forEach(function(We){return HA.addColorStop(We.stop,NA(We.color))}),s.path(AA),s.ctx.fillStyle=HA,lA!==UA?(RA=t.bounds.left+.5*t.bounds.width,QA=t.bounds.top+.5*t.bounds.height,PA=UA/lA,wA=1/PA,s.ctx.save(),s.ctx.translate(RA,QA),s.ctx.transform(1,0,0,PA,0,0),s.ctx.translate(-RA,-QA),s.ctx.fillRect(oA,wA*(cA-QA)+QA,W,tA*wA),s.ctx.restore()):s.ctx.fill())),ce.label=6;case 6:return r--,[2]}})},s=this,a=0,u=t.styles.backgroundImage.slice(0).reverse(),c.label=1;case 1:return a<u.length?(o=u[a],[5,n(o)]):[3,4];case 2:c.sent(),c.label=3;case 3:return a++,[3,1];case 4:return[2]}})})},e.prototype.renderSolidBorder=function(t,r,n){return kA(this,void 0,void 0,function(){return DA(this,function(s){return this.path(Rl(n,r)),this.ctx.fillStyle=NA(t),this.ctx.fill(),[2]})})},e.prototype.renderDoubleBorder=function(t,r,n,s){return kA(this,void 0,void 0,function(){var a,u;return DA(this,function(o){switch(o.label){case 0:return r<3?[4,this.renderSolidBorder(t,n,s)]:[3,2];case 1:return o.sent(),[2];case 2:return a=Eb(s,n),this.path(a),this.ctx.fillStyle=NA(t),this.ctx.fill(),u=pb(s,n),this.path(u),this.ctx.fill(),[2]}})})},e.prototype.renderNodeBackgroundAndBorders=function(t){return kA(this,void 0,void 0,function(){var r,n,s,a,u,o,c,f,h=this;return DA(this,function(d){switch(d.label){case 0:return this.applyEffects(t.getEffects(2)),r=t.container.styles,n=!Ve(r.backgroundColor)||r.backgroundImage.length,s=[{style:r.borderTopStyle,color:r.borderTopColor,width:r.borderTopWidth},{style:r.borderRightStyle,color:r.borderRightColor,width:r.borderRightWidth},{style:r.borderBottomStyle,color:r.borderBottomColor,width:r.borderBottomWidth},{style:r.borderLeftStyle,color:r.borderLeftColor,width:r.borderLeftWidth}],a=yb(xt(r.backgroundClip,0),t.curves),n||r.boxShadow.length?(this.ctx.save(),this.path(a),this.ctx.clip(),Ve(r.backgroundColor)||(this.ctx.fillStyle=NA(r.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(t.container)]):[3,2];case 1:d.sent(),this.ctx.restore(),r.boxShadow.slice(0).reverse().forEach(function(C){h.ctx.save();var m=$n(t.curves),T=C.inset?0:Fb,F=Bb(m,-T+(C.inset?1:-1)*C.spread.number,(C.inset?1:-1)*C.spread.number,C.spread.number*(C.inset?-2:2),C.spread.number*(C.inset?-2:2));C.inset?(h.path(m),h.ctx.clip(),h.mask(F)):(h.mask(m),h.ctx.clip(),h.path(F)),h.ctx.shadowOffsetX=C.offsetX.number+T,h.ctx.shadowOffsetY=C.offsetY.number,h.ctx.shadowColor=NA(C.color),h.ctx.shadowBlur=C.blur.number,h.ctx.fillStyle=C.inset?NA(C.color):"rgba(0,0,0,1)",h.ctx.fill(),h.ctx.restore()}),d.label=2;case 2:u=0,o=0,c=s,d.label=3;case 3:return o<c.length?(f=c[o],f.style!==0&&!Ve(f.color)&&f.width>0?f.style!==2?[3,5]:[4,this.renderDashedDottedBorder(f.color,f.width,u,t.curves,2)]:[3,11]):[3,13];case 4:return d.sent(),[3,11];case 5:return f.style!==3?[3,7]:[4,this.renderDashedDottedBorder(f.color,f.width,u,t.curves,3)];case 6:return d.sent(),[3,11];case 7:return f.style!==4?[3,9]:[4,this.renderDoubleBorder(f.color,f.width,u,t.curves)];case 8:return d.sent(),[3,11];case 9:return[4,this.renderSolidBorder(f.color,u,t.curves)];case 10:d.sent(),d.label=11;case 11:u++,d.label=12;case 12:return o++,[3,3];case 13:return[2]}})})},e.prototype.renderDashedDottedBorder=function(t,r,n,s,a){return kA(this,void 0,void 0,function(){var u,o,c,f,h,d,C,m,T,F,Q,I,H,M,y,p,y,p;return DA(this,function(v){return this.ctx.save(),u=mb(s,n),o=Rl(s,n),a===2&&(this.path(o),this.ctx.clip()),re(o[0])?(c=o[0].start.x,f=o[0].start.y):(c=o[0].x,f=o[0].y),re(o[1])?(h=o[1].end.x,d=o[1].end.y):(h=o[1].x,d=o[1].y),n===0||n===2?C=Math.abs(c-h):C=Math.abs(f-d),this.ctx.beginPath(),a===3?this.formatPath(u):this.formatPath(o.slice(0,2)),m=r<3?r*3:r*2,T=r<3?r*2:r,a===3&&(m=r,T=r),F=!0,C<=m*2?F=!1:C<=m*2+T?(Q=C/(2*m+T),m*=Q,T*=Q):(I=Math.floor((C+T)/(m+T)),H=(C-I*m)/(I-1),M=(C-(I+1)*m)/I,T=M<=0||Math.abs(T-H)<Math.abs(T-M)?H:M),F&&(a===3?this.ctx.setLineDash([0,m+T]):this.ctx.setLineDash([m,T])),a===3?(this.ctx.lineCap="round",this.ctx.lineWidth=r):this.ctx.lineWidth=r*2+1.1,this.ctx.strokeStyle=NA(t),this.ctx.stroke(),this.ctx.setLineDash([]),a===2&&(re(o[0])&&(y=o[3],p=o[0],this.ctx.beginPath(),this.formatPath([new x(y.end.x,y.end.y),new x(p.start.x,p.start.y)]),this.ctx.stroke()),re(o[1])&&(y=o[1],p=o[2],this.ctx.beginPath(),this.formatPath([new x(y.end.x,y.end.y),new x(p.start.x,p.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]})})},e.prototype.render=function(t){return kA(this,void 0,void 0,function(){var r;return DA(this,function(n){switch(n.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=NA(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),r=gb(t),[4,this.renderStack(r)];case 1:return n.sent(),this.applyEffects([]),[2,this.canvas]}})})},e}(Pl),_b=function(A){return A instanceof ll||A instanceof cl?!0:A instanceof za&&A.type!==Xn&&A.type!==Yn},yb=function(A,e){switch(A){case 0:return $n(e);case 2:return cb(e);case 1:default:return zn(e)}},Nb=function(A){switch(A){case 1:return"center";case 2:return"right";case 0:default:return"left"}},Sb=["-apple-system","system-ui"],vb=function(A){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?A.filter(function(e){return Sb.indexOf(e)===-1}):A},Lb=function(A){ue(e,A);function e(t,r){var n=A.call(this,t,r)||this;return n.canvas=r.canvas?r.canvas:document.createElement("canvas"),n.ctx=n.canvas.getContext("2d"),n.options=r,n.canvas.width=Math.floor(r.width*r.scale),n.canvas.height=Math.floor(r.height*r.scale),n.canvas.style.width=r.width+"px",n.canvas.style.height=r.height+"px",n.ctx.scale(n.options.scale,n.options.scale),n.ctx.translate(-r.x,-r.y),n.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+r.width+"x"+r.height+" at "+r.x+","+r.y+") with scale "+r.scale),n}return e.prototype.render=function(t){return kA(this,void 0,void 0,function(){var r,n;return DA(this,function(s){switch(s.label){case 0:return r=ja(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,t),[4,Hb(r)];case 1:return n=s.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=NA(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(n,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},e}(Pl),Hb=function(A){return new Promise(function(e,t){var r=new Image;r.onload=function(){e(r)},r.onerror=t,r.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(A))})},xb=function(){function A(e){var t=e.id,r=e.enabled;this.id=t,this.enabled=r,this.start=Date.now()}return A.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console&&typeof console.debug=="function"?console.debug.apply(console,ln([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},A.prototype.getTime=function(){return Date.now()-this.start},A.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&typeof window<"u"&&window.console&&typeof console.info=="function"&&console.info.apply(console,ln([this.id,this.getTime()+"ms"],e))},A.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console&&typeof console.warn=="function"?console.warn.apply(console,ln([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},A.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console&&typeof console.error=="function"?console.error.apply(console,ln([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},A.instances={},A}(),Db=function(){function A(e,t){var r;this.windowBounds=t,this.instanceName="#"+A.instanceCount++,this.logger=new xb({id:this.instanceName,enabled:e.logging}),this.cache=(r=e.cache)!==null&&r!==void 0?r:new tb(this,e)}return A.instanceCount=1,A}(),Ob=function(A,e){return e===void 0&&(e={}),Rb(A,e)};typeof window<"u"&&vl.setContext(window);var Rb=function(A,e){return kA(void 0,void 0,void 0,function(){var t,r,n,s,a,u,o,c,f,h,d,C,m,T,F,Q,I,H,M,y,v,p,v,k,O,AA,oA,cA,W,tA,R,P,z,rA,lA,UA,HA,RA,QA,PA;return DA(this,function(wA){switch(wA.label){case 0:if(!A||typeof A!="object")return[2,Promise.reject("Invalid element provided as first argument")];if(t=A.ownerDocument,!t)throw new Error("Element is not attached to a Document");if(r=t.defaultView,!r)throw new Error("Document is not attached to a Window");return n={allowTaint:(k=e.allowTaint)!==null&&k!==void 0?k:!1,imageTimeout:(O=e.imageTimeout)!==null&&O!==void 0?O:15e3,proxy:e.proxy,useCORS:(AA=e.useCORS)!==null&&AA!==void 0?AA:!1},s=Ba({logging:(oA=e.logging)!==null&&oA!==void 0?oA:!0,cache:e.cache},n),a={windowWidth:(cA=e.windowWidth)!==null&&cA!==void 0?cA:r.innerWidth,windowHeight:(W=e.windowHeight)!==null&&W!==void 0?W:r.innerHeight,scrollX:(tA=e.scrollX)!==null&&tA!==void 0?tA:r.pageXOffset,scrollY:(R=e.scrollY)!==null&&R!==void 0?R:r.pageYOffset},u=new be(a.scrollX,a.scrollY,a.windowWidth,a.windowHeight),o=new Db(s,u),c=(P=e.foreignObjectRendering)!==null&&P!==void 0?P:!1,f={allowTaint:(z=e.allowTaint)!==null&&z!==void 0?z:!1,onclone:e.onclone,ignoreElements:e.ignoreElements,inlineImages:c,copyStyles:c},o.logger.debug("Starting document clone with size "+u.width+"x"+u.height+" scrolled to "+-u.left+","+-u.top),h=new Nl(o,A,f),d=h.clonedReferenceElement,d?[4,h.toIFrame(t,u)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return C=wA.sent(),m=ei(d)||MT(d)?Bm(d.ownerDocument):fn(o,d),T=m.width,F=m.height,Q=m.left,I=m.top,H=Mb(o,d,e.backgroundColor),M={canvas:e.canvas,backgroundColor:H,scale:(lA=(rA=e.scale)!==null&&rA!==void 0?rA:r.devicePixelRatio)!==null&&lA!==void 0?lA:1,x:((UA=e.x)!==null&&UA!==void 0?UA:0)+Q,y:((HA=e.y)!==null&&HA!==void 0?HA:0)+I,width:(RA=e.width)!==null&&RA!==void 0?RA:Math.ceil(T),height:(QA=e.height)!==null&&QA!==void 0?QA:Math.ceil(F)},c?(o.logger.debug("Document cloned, using foreign object rendering"),v=new Lb(o,M),[4,v.render(d)]):[3,3];case 2:return y=wA.sent(),[3,5];case 3:return o.logger.debug("Document cloned, element located at "+Q+","+I+" with size "+T+"x"+F+" using computed rendering"),o.logger.debug("Starting DOM parsing"),p=dl(o,d),H===p.styles.backgroundColor&&(p.styles.backgroundColor=Qe.TRANSPARENT),o.logger.debug("Starting renderer for element at "+M.x+","+M.y+" with size "+M.width+"x"+M.height),v=new Ib(o,M),[4,v.render(p)];case 4:y=wA.sent(),wA.label=5;case 5:return(!((PA=e.removeContainer)!==null&&PA!==void 0)||PA)&&(Nl.destroy(C)||o.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),o.logger.debug("Finished rendering"),[2,y]}})})},Mb=function(A,e,t){var r=e.ownerDocument,n=r.documentElement?Ur(A,getComputedStyle(r.documentElement).backgroundColor):Qe.TRANSPARENT,s=r.body?Ur(A,getComputedStyle(r.body).backgroundColor):Qe.TRANSPARENT,a=typeof t=="string"?Ur(A,t):t===null?Qe.TRANSPARENT:4294967295;return e===r.documentElement?Ve(n)?Ve(s)?a:s:n:a};const kb=l.defineComponent({name:"GpIframe",props:{htmlContent:{type:String,required:!0},jsFiles:{type:Array,default:[]},cssFiles:{type:Array,default:[]},iframeStyle:{type:Object,default:()=>({width:"100%",height:"100%",border:"none"})}},setup(A){const e=l.ref(null),t=l.ref(),r=()=>{var c;const s=e.value;if(!s)return;const a=s.contentDocument||((c=s.contentWindow)==null?void 0:c.document);if(!a)return;a.open(),a.write("<!DOCTYPE html><html><head></head><body></body></html>"),a.close();const u=a.head;A.cssFiles.forEach(f=>{const h=a.createElement("link");h.rel="stylesheet",h.href=f,u.appendChild(h)});const o=a.body;o.innerHTML=A.htmlContent,A.jsFiles.forEach(f=>{const h=a.createElement("script");h.src=f,h.async=!0,o.appendChild(h)}),t.value=o,l.nextTick(()=>{})};l.watch(t,s=>{if(!s)return;new MutationObserver(()=>{const u=e.value;u&&(console.log("iframe.style.height",s.scrollHeight,u.style.height),u.style.height=`${s.scrollHeight}px`)}).observe(s,{childList:!0,subtree:!0})});const n=async s=>{var c;const a=e.value;if(!a)return;const u=a.contentDocument||((c=a.contentWindow)==null?void 0:c.document);if(!u)return;const o=u.body;if(o)try{await l.nextTick();const f=await Ob(o,{x:0,y:0,scrollX:window.scrollX,scrollY:window.scrollY,useCORS:!0,allowTaint:!0,foreignObjectRendering:!1});s?s(f):f.toBlob(h=>{const d=URL.createObjectURL(h);window.open(d,"_blank")})}catch(f){console.error("截图生成失败:",f)}};return l.watch(()=>[A.htmlContent,A.jsFiles,A.cssFiles],r,{deep:!0}),l.onMounted(()=>{r()}),{iframeRef:e,generateCover:n}}});function Pb(A,e,t,r,n,s){return l.openBlock(),l.createElementBlock("div",null,[l.createElementVNode("iframe",{ref:"iframeRef",style:l.normalizeStyle(A.iframeStyle)},null,4)])}const Kl=He(kb,[["render",Pb],["__scopeId","data-v-c23563ae"]]),Kb={class:"flex gp-dsigner"},Vb={key:0,class:"flex items-center justify-between border-b"},Gb={class:"text-lg font-bold p-2"},Yb={class:"text-sm font-thin text-gray-500"},Xb={class:"flex-1 overflow-auto"},Wb={key:0,class:"text-lg font-bold border-b p-2"},Jb={class:"p-2"},qb={class:"sticky top-0"},jb={key:0,class:"text-lg font-bold border-b p-2"},Zb={class:"text-sm font-thin text-gray-500"},$b={class:"p-2"},Vl=He(l.defineComponent({__name:"Designer",props:{mode:{default:"design"},template:{},css:{},js:{},previewWidth:{default:375},uploadByFile:{},icons:{},rules:{},preview:{type:Boolean,default:!0},showTitle:{type:Boolean,default:!0}},emits:["update:modelValue","update:element"],setup(A,{expose:e,emit:t}){const r=A,n=t,s=l.ref(r.template),a=l.ref();let u=so("",{},!1);const o=l.ref("");l.watch(()=>r.template,N=>{s.value=N},{immediate:!0}),l.watch(()=>s.value,N=>{N&&(a.value=O(N))},{immediate:!0}),l.watch(()=>r.css,N=>{N.forEach(L=>{if(document.querySelector(`link[href="${L}"]`))return;const K=document.createElement("link");K.rel="stylesheet",K.href=L,document.head.appendChild(K)})},{immediate:!0}),l.watch(()=>r.js,N=>{!N||N.length===0||N.forEach(L=>{if(document.querySelector(`script[src="${L}"]`))return;const K=document.createElement("script");K.src=L,document.body.appendChild(K)})},{immediate:!0});const c=l.ref(r.mode);l.watch(()=>a.value,N=>{N&&n("update:element",N)},{immediate:!0});const f=l.ref("");l.watch(()=>o.value,N=>{n("update:modelValue",N)},{immediate:!0});const h=l.ref(),d=l.ref(),C=l.ref(),m=l.ref(),T=l.ref(),F=l.ref(),Q=l.ref("");function I(N=void 0){m.value&&m.value.generateCover(N)}function H(N){T.value=N}function M(N,L=""){if(L){const K=y(a.value,L);K?F.value=K:F.value=N}else F.value=N}function y(N,L){if(N.xpath===L)return N;if(N.children&&N.children.length)for(const K of N.children){const Y=y(K,L);if(Y)return Y}}function p(N,L){var K,Y;return N.tag===L.tag&&((K=N.children)==null?void 0:K.length)===((Y=L.children)==null?void 0:Y.length)}function v(N){if(T.value.xpath==N.xpath){if(T.value){if(N.type===q.Block){var L=!0;const K=y(a.value,T.value.parentxpath||"");if(K&&K.children&&K.children.forEach(Y=>{if(Y.tag!=T.value.tag||!p(Y,T.value)){L=!1;return}}),!L){j.error("同级结构不一致,错误配置!");return}}if(T.value.rule=N.rule,T.value.type=N.type,T.value.type===q.Block){const K=y(a.value,T.value.parentxpath||"");K&&K.children&&(K.children.forEach(Y=>{if(Y.tag!=T.value.tag||!p(Y,T.value)){j.error("同级结构不一致,无法配置为块类型");return}}),K.children.forEach(Y=>{Y.tag===T.value.tag&&(Y.rule=N.rule,Y.type=N.type)}))}}f.value=new Date().getTime().toString(),j.success("保存成功")}}function k(N){o.value=N}function O(N){u=so(N);const L=u("body").children().toArray().map(K=>AA(u(K)));return o.value=u("body").html()||"",L[0]}function AA(N,L=""){var ot;function K(ZA){if(!ZA||!ZA[0])return"";const JA=[];let ct=ZA;for(;ct.length&&ct[0].tagName!=="html";){const Yl=ct[0].tagName,AU=ct.parent().children(Yl).index(ct)+1;JA.unshift(`${Yl}[${AU}]`),ct=ct.parent()}return"/html/"+JA.join("/")}const Y=K(N).replace("/html/body[1]",""),MA=N.children().toArray().map(ZA=>AA(u(ZA),Y)),me=(ot=r.rules)==null?void 0:ot.find(ZA=>ZA.xpath===Y);return{tag:N[0].tagName,text:N.contents().not(N.children()).text().trim(),attrs:N[0].attribs,children:MA,xpath:Y,parentxpath:L,type:(me==null?void 0:me.type)||q.None,rule:(me==null?void 0:me.rule)||{}}}function oA(N){console.log("更新子节点的文本",N);const L=y(a.value,N.element.xpath);if(L){const K=l.toRaw(L);K.editText=N.newText}}function cA(N,L=""){function K(Y,MA){var ZA;const ot=(MA?((ZA=y(a.value,MA))==null?void 0:ZA.children)||[]:[a.value]).filter(JA=>JA.tag===Y.tag).indexOf(Y)+1;return`${MA}/${Y.tag}[${ot}]`}N.xpath=K(N,L),N.parentxpath=L,(N.children||[]).forEach(Y=>cA(Y,N.xpath))}function W({action:N,element:L,newBlock:K}){const Y=y(a.value,L.parentxpath||"");if(!Y||!Y.children)return;const MA=Y.children.findIndex(JA=>JA===L);if(MA===-1){j.error("未找到元素");return}const me=Y.children.length,{minBlock:ot,maxBlock:ZA}=L.rule;if((N==="add"||N==="copy")&&me>=(ZA||1/0)){Q.value=`无法添加更多块。最大块数量为 ${ZA}`,j.error(Q.value);return}switch(N){case"add":if(K){const JA={...K,xpath:"",children:JSON.parse(JSON.stringify(K.children))};Y.children.splice(MA+1,0,JA),j.success("添加成功")}break;case"copy":if(K){const JA={...K,xpath:"",children:JSON.parse(JSON.stringify(K.children))};Y.children.splice(MA+1,0,JA),j.success("复制成功")}break;case"moveUp":if(MA>0){const[JA]=Y.children.splice(MA,1);Y.children.splice(MA-1,0,JA),j.success("前移成功")}else j.error("已经是第一个块,无法前移");break;case"moveDown":if(MA<Y.children.length-1){const[JA]=Y.children.splice(MA,1);Y.children.splice(MA+1,0,JA),j.success("后移成功")}else j.error("已经是最后一个块,无法后移");break;case"delete":if(me<=(ot||0)){Q.value=`无法删除更多块。最小块数量为 ${ot}`,j.error(Q.value);return}Y.children.splice(MA,1),j.success("删除成功");break}Q.value="",cA(a.value)}function tA(N,L){let K=L.attrs.class.replace(/icon-\S+/g,`icon-${N}`);L.attrs.class=K}function R(N){const L=N.file,K=y(a.value,N.element.xpath);if(r.uploadByFile)r.uploadByFile(L).then(Y=>{Y.success&&(K.attrs.src=Y.file.url,f.value=new Date().getTime().toString())});else{K.attrs.alt=L.name;const Y=URL.createObjectURL(L);K.attrs.src=Y,f.value=new Date().getTime().toString()}}function P(N){const{icon:L}=N,K=y(a.value,N.element.xpath);let Y=K.attrs.class.replace(/icon-\S+/g,`icon-${L}`);K.attrs.class=Y,f.value=new Date().getTime().toString()}const z=N=>N.type.startsWith("image/")?!0:(j.error("只能上传图片文件"),!1),rA=l.ref({});function lA(N,L){if(!N||N.length===0)return;const K=N[0];if(L.rule&&(L.rule.minImageWidth||L.rule.maxImageHeight)){if(L.rule.minImageWidth&&K.width<L.rule.minImageWidth){j.error(`图片宽度不能小于 ${L.rule.minImageWidth}px`);return}if(L.rule.maxImageHeight&&K.height<L.rule.maxImageHeight){j.error(`图片高度不能小于 ${L.rule.maxImageHeight}px`);return}}L.rule.minImageWidth&&L.rule.maxImageHeight?(rA.value.width=L.rule.minImageWidth,rA.value.height=L.rule.maxImageHeight,rA.value.aspectRatio=L.rule.minImageWidth/L.rule.maxImageHeight):rA.value={},K&&(L.rule.crop?(K.thumbUrl,h.value.handleOpenCropper(rA.value,K.file,K.name,L)):r.uploadByFile?r.uploadByFile(K.file).then(Y=>{Y.success&&(L.attrs.src=Y.file.url,f.value=new Date().getTime().toString())}):(L.attrs.src=K.thumbUrl,f.value=new Date().getTime().toString()))}const UA=l.ref(r.previewWidth),HA=l.ref(375);let RA=l.ref(!1),QA=l.ref(""),PA=0,wA=0;function ce(N){QA.value=N,RA.value=!0,PA=event.clientX,N==="preview"?wA=UA.value:N==="structure"&&(wA=HA.value),window.addEventListener("mousemove",We),window.addEventListener("mouseup",Gl)}function We(N){if(!RA.value)return;const L=N.clientX-PA;QA.value==="preview"?UA.value=Math.max(200,wA+L):QA.value==="structure"&&(HA.value=Math.max(200,wA-L))}function Gl(){RA.value=!1,QA.value="",window.removeEventListener("mousemove",We),window.removeEventListener("mouseup",Gl)}return e({generateCover:I}),(N,L)=>(l.openBlock(),l.createElementBlock("div",Kb,[N.preview?(l.openBlock(),l.createElementBlock("div",{key:0,class:"border-l overflow-auto resize-area",style:l.normalizeStyle({width:UA.value+"px"})},[N.showTitle?(l.openBlock(),l.createElementBlock("div",Vb,[l.createElementVNode("h2",Gb,[L[3]||(L[3]=l.createTextVNode(" 实时预览 ")),l.createElementVNode("span",Yb,l.toDisplayString(UA.value)+"px",1)]),l.createElementVNode("div",{onClick:L[0]||(L[0]=()=>I()),class:"p-2 cursor-pointer text-blue-500"}," 封面 ")])):l.createCommentVNode("",!0),l.createElementVNode("div",null,[o.value?(l.openBlock(),l.createBlock(Kl,{key:0,"css-files":N.css,"js-files":N.js,"html-content":o.value,class:"gp-designer-preview",ref_key:"previewRef",ref:m},null,8,["css-files","js-files","html-content"])):(l.openBlock(),l.createBlock(Kl,{key:1,"css-files":N.css,"js-files":N.js,"html-content":l.unref(u)("body").html(),class:"gp-designer-preview",ref_key:"previewRef",ref:m},null,8,["css-files","js-files","html-content"]))])],4)):l.createCommentVNode("",!0),N.preview?(l.openBlock(),l.createElementBlock("div",{key:1,class:"resizer",onMousedown:L[1]||(L[1]=K=>ce("preview"))},null,32)):l.createCommentVNode("",!0),l.createElementVNode("div",Xb,[N.showTitle?(l.openBlock(),l.createElementBlock("h2",Wb,"结构渲染")):l.createCommentVNode("",!0),l.createElementVNode("div",Jb,[a.value?(l.openBlock(),l.createBlock(sE,{key:0,"upload-by-file":N.uploadByFile,cropper:h.value,icon:d.value,upload:C.value,mode:N.mode,icons:N.icons,r:f.value,element:a.value,selectedElement:T.value,hoveredElement:F.value,onSelectElement:H,onHoverElement:M,onContentUpdated:k,onUpdateText:oA,onBlockAction:W,onAddIcon:tA},null,8,["upload-by-file","cropper","icon","upload","mode","icons","r","element","selectedElement","hoveredElement"])):l.createCommentVNode("",!0)])]),c.value=="design"?(l.openBlock(),l.createElementBlock("div",{key:2,class:"resizer",onMousedown:L[2]||(L[2]=K=>ce("structure"))},null,32)):l.createCommentVNode("",!0),c.value=="design"?(l.openBlock(),l.createElementBlock("div",{key:3,class:"resize-area",style:l.normalizeStyle({width:HA.value+"px"})},[l.createElementVNode("div",qb,[N.showTitle?(l.openBlock(),l.createElementBlock("h2",jb,[L[4]||(L[4]=l.createTextVNode(" 节点属性 ")),l.createElementVNode("span",Zb,l.toDisplayString(HA.value)+"px",1)])):l.createCommentVNode("",!0),l.createElementVNode("div",$b,[T.value?(l.openBlock(),l.createBlock(RE,{key:0,element:T.value,onUpdateElement:v},null,8,["element"])):l.createCommentVNode("",!0)])])],4)):l.createCommentVNode("",!0),l.createVNode(Jp,{ref_key:"cropperRef",ref:h,onOk:R},null,512),l.createVNode(sm,{icons:N.icons,ref_key:"iconRef",ref:d,onOk:P},null,8,["icons"]),l.createVNode(dm,{ref_key:"uploadRef",ref:C,multiple:!1,show:!1,beforeUpload:z,onChange:lA},{"upload-icon":l.withCtx(()=>L[5]||(L[5]=[l.createElementVNode("div",{class:"p-2"},"上传",-1)])),_:1},512)]))}}),[["__scopeId","data-v-4385100d"]]),zb={install(A){A.component("Designer",Vl)}};Ie.Designer=Vl,Ie.default=zb,Object.defineProperties(Ie,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
38
+ .`+ai+zT+Sl)},eb=function(A,e){var t=A.ownerDocument;if(t){var r=t.createElement("style");r.textContent=e,A.appendChild(r)}},vl=function(){function A(){}return A.getOrigin=function(e){var t=A._link;return t?(t.href=e,t.href=t.href,t.protocol+t.hostname+t.port):"about:blank"},A.isSameOrigin=function(e){return A.getOrigin(e)===A._origin},A.setContext=function(e){A._link=e.document.createElement("a"),A._origin=A.getOrigin(e.location.href)},A._origin="about:blank",A}(),tb=function(){function A(e,t){this.context=e,this._options=t,this._cache={}}return A.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)||(ui(e)||ab(e))&&(this._cache[e]=this.loadImage(e)).catch(function(){}),t},A.prototype.match=function(e){return this._cache[e]},A.prototype.loadImage=function(e){return kA(this,void 0,void 0,function(){var t,r,n,s,a=this;return DA(this,function(u){switch(u.label){case 0:return t=vl.isSameOrigin(e),r=!ii(e)&&this._options.useCORS===!0&&LA.SUPPORT_CORS_IMAGES&&!t,n=!ii(e)&&!t&&!ui(e)&&typeof this._options.proxy=="string"&&LA.SUPPORT_CORS_XHR&&!r,!t&&this._options.allowTaint===!1&&!ii(e)&&!ui(e)&&!n&&!r?[2]:(s=e,n?[4,this.proxy(s)]:[3,2]);case 1:s=u.sent(),u.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise(function(o,c){var f=new Image;f.onload=function(){return o(f)},f.onerror=c,(ib(s)||r)&&(f.crossOrigin="anonymous"),f.src=s,f.complete===!0&&setTimeout(function(){return o(f)},500),a._options.imageTimeout>0&&setTimeout(function(){return c("Timed out ("+a._options.imageTimeout+"ms) loading image")},a._options.imageTimeout)})];case 3:return[2,u.sent()]}})})},A.prototype.has=function(e){return typeof this._cache[e]<"u"},A.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},A.prototype.proxy=function(e){var t=this,r=this._options.proxy;if(!r)throw new Error("No proxy defined");var n=e.substring(0,256);return new Promise(function(s,a){var u=LA.SUPPORT_RESPONSE_TYPE?"blob":"text",o=new XMLHttpRequest;o.onload=function(){if(o.status===200)if(u==="text")s(o.response);else{var h=new FileReader;h.addEventListener("load",function(){return s(h.result)},!1),h.addEventListener("error",function(d){return a(d)},!1),h.readAsDataURL(o.response)}else a("Failed to proxy resource "+n+" with status code "+o.status)},o.onerror=a;var c=r.indexOf("?")>-1?"&":"?";if(o.open("GET",""+r+c+"url="+encodeURIComponent(e)+"&responseType="+u),u!=="text"&&o instanceof XMLHttpRequest&&(o.responseType=u),t._options.imageTimeout){var f=t._options.imageTimeout;o.timeout=f,o.ontimeout=function(){return a("Timed out ("+f+"ms) proxying "+n)}}o.send()})},A}(),rb=/^data:image\/svg\+xml/i,nb=/^data:image\/.*;base64,/i,sb=/^data:image\/.*/i,ab=function(A){return LA.SUPPORT_SVG_DRAWING||!ub(A)},ii=function(A){return sb.test(A)},ib=function(A){return nb.test(A)},ui=function(A){return A.substr(0,4)==="blob"},ub=function(A){return A.substr(-3).toLowerCase()==="svg"||rb.test(A)},x=function(){function A(e,t){this.type=0,this.x=e,this.y=t}return A.prototype.add=function(e,t){return new A(this.x+e,this.y+t)},A}(),Lt=function(A,e,t){return new x(A.x+(e.x-A.x)*t,A.y+(e.y-A.y)*t)},Zn=function(){function A(e,t,r,n){this.type=1,this.start=e,this.startControl=t,this.endControl=r,this.end=n}return A.prototype.subdivide=function(e,t){var r=Lt(this.start,this.startControl,e),n=Lt(this.startControl,this.endControl,e),s=Lt(this.endControl,this.end,e),a=Lt(r,n,e),u=Lt(n,s,e),o=Lt(a,u,e);return t?new A(this.start,r,a,o):new A(o,u,s,this.end)},A.prototype.add=function(e,t){return new A(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))},A.prototype.reverse=function(){return new A(this.end,this.endControl,this.startControl,this.start)},A}(),re=function(A){return A.type===1},ob=function(){function A(e){var t=e.styles,r=e.bounds,n=br(t.borderTopLeftRadius,r.width,r.height),s=n[0],a=n[1],u=br(t.borderTopRightRadius,r.width,r.height),o=u[0],c=u[1],f=br(t.borderBottomRightRadius,r.width,r.height),h=f[0],d=f[1],C=br(t.borderBottomLeftRadius,r.width,r.height),m=C[0],T=C[1],F=[];F.push((s+o)/r.width),F.push((m+h)/r.width),F.push((a+T)/r.height),F.push((c+d)/r.height);var Q=Math.max.apply(Math,F);Q>1&&(s/=Q,a/=Q,o/=Q,c/=Q,h/=Q,d/=Q,m/=Q,T/=Q);var I=r.width-o,H=r.height-d,M=r.width-h,y=r.height-T,p=t.borderTopWidth,v=t.borderRightWidth,k=t.borderBottomWidth,O=t.borderLeftWidth,AA=uA(t.paddingTop,e.bounds.width),oA=uA(t.paddingRight,e.bounds.width),cA=uA(t.paddingBottom,e.bounds.width),W=uA(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=s>0||a>0?BA(r.left+O/3,r.top+p/3,s-O/3,a-p/3,sA.TOP_LEFT):new x(r.left+O/3,r.top+p/3),this.topRightBorderDoubleOuterBox=s>0||a>0?BA(r.left+I,r.top+p/3,o-v/3,c-p/3,sA.TOP_RIGHT):new x(r.left+r.width-v/3,r.top+p/3),this.bottomRightBorderDoubleOuterBox=h>0||d>0?BA(r.left+M,r.top+H,h-v/3,d-k/3,sA.BOTTOM_RIGHT):new x(r.left+r.width-v/3,r.top+r.height-k/3),this.bottomLeftBorderDoubleOuterBox=m>0||T>0?BA(r.left+O/3,r.top+y,m-O/3,T-k/3,sA.BOTTOM_LEFT):new x(r.left+O/3,r.top+r.height-k/3),this.topLeftBorderDoubleInnerBox=s>0||a>0?BA(r.left+O*2/3,r.top+p*2/3,s-O*2/3,a-p*2/3,sA.TOP_LEFT):new x(r.left+O*2/3,r.top+p*2/3),this.topRightBorderDoubleInnerBox=s>0||a>0?BA(r.left+I,r.top+p*2/3,o-v*2/3,c-p*2/3,sA.TOP_RIGHT):new x(r.left+r.width-v*2/3,r.top+p*2/3),this.bottomRightBorderDoubleInnerBox=h>0||d>0?BA(r.left+M,r.top+H,h-v*2/3,d-k*2/3,sA.BOTTOM_RIGHT):new x(r.left+r.width-v*2/3,r.top+r.height-k*2/3),this.bottomLeftBorderDoubleInnerBox=m>0||T>0?BA(r.left+O*2/3,r.top+y,m-O*2/3,T-k*2/3,sA.BOTTOM_LEFT):new x(r.left+O*2/3,r.top+r.height-k*2/3),this.topLeftBorderStroke=s>0||a>0?BA(r.left+O/2,r.top+p/2,s-O/2,a-p/2,sA.TOP_LEFT):new x(r.left+O/2,r.top+p/2),this.topRightBorderStroke=s>0||a>0?BA(r.left+I,r.top+p/2,o-v/2,c-p/2,sA.TOP_RIGHT):new x(r.left+r.width-v/2,r.top+p/2),this.bottomRightBorderStroke=h>0||d>0?BA(r.left+M,r.top+H,h-v/2,d-k/2,sA.BOTTOM_RIGHT):new x(r.left+r.width-v/2,r.top+r.height-k/2),this.bottomLeftBorderStroke=m>0||T>0?BA(r.left+O/2,r.top+y,m-O/2,T-k/2,sA.BOTTOM_LEFT):new x(r.left+O/2,r.top+r.height-k/2),this.topLeftBorderBox=s>0||a>0?BA(r.left,r.top,s,a,sA.TOP_LEFT):new x(r.left,r.top),this.topRightBorderBox=o>0||c>0?BA(r.left+I,r.top,o,c,sA.TOP_RIGHT):new x(r.left+r.width,r.top),this.bottomRightBorderBox=h>0||d>0?BA(r.left+M,r.top+H,h,d,sA.BOTTOM_RIGHT):new x(r.left+r.width,r.top+r.height),this.bottomLeftBorderBox=m>0||T>0?BA(r.left,r.top+y,m,T,sA.BOTTOM_LEFT):new x(r.left,r.top+r.height),this.topLeftPaddingBox=s>0||a>0?BA(r.left+O,r.top+p,Math.max(0,s-O),Math.max(0,a-p),sA.TOP_LEFT):new x(r.left+O,r.top+p),this.topRightPaddingBox=o>0||c>0?BA(r.left+Math.min(I,r.width-v),r.top+p,I>r.width+v?0:Math.max(0,o-v),Math.max(0,c-p),sA.TOP_RIGHT):new x(r.left+r.width-v,r.top+p),this.bottomRightPaddingBox=h>0||d>0?BA(r.left+Math.min(M,r.width-O),r.top+Math.min(H,r.height-k),Math.max(0,h-v),Math.max(0,d-k),sA.BOTTOM_RIGHT):new x(r.left+r.width-v,r.top+r.height-k),this.bottomLeftPaddingBox=m>0||T>0?BA(r.left+O,r.top+Math.min(y,r.height-k),Math.max(0,m-O),Math.max(0,T-k),sA.BOTTOM_LEFT):new x(r.left+O,r.top+r.height-k),this.topLeftContentBox=s>0||a>0?BA(r.left+O+W,r.top+p+AA,Math.max(0,s-(O+W)),Math.max(0,a-(p+AA)),sA.TOP_LEFT):new x(r.left+O+W,r.top+p+AA),this.topRightContentBox=o>0||c>0?BA(r.left+Math.min(I,r.width+O+W),r.top+p+AA,I>r.width+O+W?0:o-O+W,c-(p+AA),sA.TOP_RIGHT):new x(r.left+r.width-(v+oA),r.top+p+AA),this.bottomRightContentBox=h>0||d>0?BA(r.left+Math.min(M,r.width-(O+W)),r.top+Math.min(H,r.height+p+AA),Math.max(0,h-(v+oA)),d-(k+cA),sA.BOTTOM_RIGHT):new x(r.left+r.width-(v+oA),r.top+r.height-(k+cA)),this.bottomLeftContentBox=m>0||T>0?BA(r.left+O+W,r.top+y,Math.max(0,m-(O+W)),T-(k+cA),sA.BOTTOM_LEFT):new x(r.left+O+W,r.top+r.height-(k+cA))}return A}(),sA;(function(A){A[A.TOP_LEFT=0]="TOP_LEFT",A[A.TOP_RIGHT=1]="TOP_RIGHT",A[A.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",A[A.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(sA||(sA={}));var BA=function(A,e,t,r,n){var s=4*((Math.sqrt(2)-1)/3),a=t*s,u=r*s,o=A+t,c=e+r;switch(n){case sA.TOP_LEFT:return new Zn(new x(A,c),new x(A,c-u),new x(o-a,e),new x(o,e));case sA.TOP_RIGHT:return new Zn(new x(A,e),new x(A+a,e),new x(o,c-u),new x(o,c));case sA.BOTTOM_RIGHT:return new Zn(new x(o,e),new x(o,e+u),new x(A+a,c),new x(A,c));case sA.BOTTOM_LEFT:default:return new Zn(new x(o,c),new x(o-a,c),new x(A,e+u),new x(A,e))}},$n=function(A){return[A.topLeftBorderBox,A.topRightBorderBox,A.bottomRightBorderBox,A.bottomLeftBorderBox]},cb=function(A){return[A.topLeftContentBox,A.topRightContentBox,A.bottomRightContentBox,A.bottomLeftContentBox]},zn=function(A){return[A.topLeftPaddingBox,A.topRightPaddingBox,A.bottomRightPaddingBox,A.bottomLeftPaddingBox]},lb=function(){function A(e,t,r){this.offsetX=e,this.offsetY=t,this.matrix=r,this.type=0,this.target=6}return A}(),As=function(){function A(e,t){this.path=e,this.target=t,this.type=1}return A}(),fb=function(){function A(e){this.opacity=e,this.type=2,this.target=6}return A}(),hb=function(A){return A.type===0},Ll=function(A){return A.type===1},db=function(A){return A.type===2},Hl=function(A,e){return A.length===e.length?A.some(function(t,r){return t===e[r]}):!1},Bb=function(A,e,t,r,n){return A.map(function(s,a){switch(a){case 0:return s.add(e,t);case 1:return s.add(e+r,t);case 2:return s.add(e+r,t+n);case 3:return s.add(e,t+n)}return s})},xl=function(){function A(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return A}(),Dl=function(){function A(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new ob(this.container),this.container.styles.opacity<1&&this.effects.push(new fb(this.container.styles.opacity)),this.container.styles.transform!==null){var r=this.container.bounds.left+this.container.styles.transformOrigin[0].number,n=this.container.bounds.top+this.container.styles.transformOrigin[1].number,s=this.container.styles.transform;this.effects.push(new lb(r,n,s))}if(this.container.styles.overflowX!==0){var a=$n(this.curves),u=zn(this.curves);Hl(a,u)?this.effects.push(new As(a,6)):(this.effects.push(new As(a,2)),this.effects.push(new As(u,4)))}}return A.prototype.getEffects=function(e){for(var t=[2,3].indexOf(this.container.styles.position)===-1,r=this.parent,n=this.effects.slice(0);r;){var s=r.effects.filter(function(o){return!Ll(o)});if(t||r.container.styles.position!==0||!r.parent){if(n.unshift.apply(n,s),t=[2,3].indexOf(r.container.styles.position)===-1,r.container.styles.overflowX!==0){var a=$n(r.curves),u=zn(r.curves);Hl(a,u)||n.unshift(new As(u,6))}}else n.unshift.apply(n,s);r=r.parent}return n.filter(function(o){return bA(o.target,e)})},A}(),oi=function(A,e,t,r){A.container.elements.forEach(function(n){var s=bA(n.flags,4),a=bA(n.flags,2),u=new Dl(n,A);bA(n.styles.display,2048)&&r.push(u);var o=bA(n.flags,8)?[]:r;if(s||a){var c=s||n.styles.isPositioned()?t:e,f=new xl(u);if(n.styles.isPositioned()||n.styles.opacity<1||n.styles.isTransformed()){var h=n.styles.zIndex.order;if(h<0){var d=0;c.negativeZIndex.some(function(m,T){return h>m.element.container.styles.zIndex.order?(d=T,!1):d>0}),c.negativeZIndex.splice(d,0,f)}else if(h>0){var C=0;c.positiveZIndex.some(function(m,T){return h>=m.element.container.styles.zIndex.order?(C=T+1,!1):C>0}),c.positiveZIndex.splice(C,0,f)}else c.zeroOrAutoZIndexOrTransformedOrOpacity.push(f)}else n.styles.isFloating()?c.nonPositionedFloats.push(f):c.nonPositionedInlineLevel.push(f);oi(u,f,s?f:t,o)}else n.styles.isInlineLevel()?e.inlineLevel.push(u):e.nonInlineLevel.push(u),oi(u,e,t,o);bA(n.flags,8)&&Ol(n,o)})},Ol=function(A,e){for(var t=A instanceof $a?A.start:1,r=A instanceof $a?A.reversed:!1,n=0;n<e.length;n++){var s=e[n];s.container instanceof ul&&typeof s.container.value=="number"&&s.container.value!==0&&(t=s.container.value),s.listValue=yr(t,s.container.styles.listStyleType,!0),t+=r?-1:1}},gb=function(A){var e=new Dl(A,null),t=new xl(e),r=[];return oi(e,t,t,r),Ol(e.container,r),t},Rl=function(A,e){switch(e){case 0:return ne(A.topLeftBorderBox,A.topLeftPaddingBox,A.topRightBorderBox,A.topRightPaddingBox);case 1:return ne(A.topRightBorderBox,A.topRightPaddingBox,A.bottomRightBorderBox,A.bottomRightPaddingBox);case 2:return ne(A.bottomRightBorderBox,A.bottomRightPaddingBox,A.bottomLeftBorderBox,A.bottomLeftPaddingBox);case 3:default:return ne(A.bottomLeftBorderBox,A.bottomLeftPaddingBox,A.topLeftBorderBox,A.topLeftPaddingBox)}},Eb=function(A,e){switch(e){case 0:return ne(A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox,A.topRightBorderBox,A.topRightBorderDoubleOuterBox);case 1:return ne(A.topRightBorderBox,A.topRightBorderDoubleOuterBox,A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox);case 2:return ne(A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox,A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox);case 3:default:return ne(A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox,A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox)}},pb=function(A,e){switch(e){case 0:return ne(A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox,A.topRightBorderDoubleInnerBox,A.topRightPaddingBox);case 1:return ne(A.topRightBorderDoubleInnerBox,A.topRightPaddingBox,A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox);case 2:return ne(A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox,A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox);case 3:default:return ne(A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox,A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox)}},mb=function(A,e){switch(e){case 0:return es(A.topLeftBorderStroke,A.topRightBorderStroke);case 1:return es(A.topRightBorderStroke,A.bottomRightBorderStroke);case 2:return es(A.bottomRightBorderStroke,A.bottomLeftBorderStroke);case 3:default:return es(A.bottomLeftBorderStroke,A.topLeftBorderStroke)}},es=function(A,e){var t=[];return re(A)?t.push(A.subdivide(.5,!1)):t.push(A),re(e)?t.push(e.subdivide(.5,!0)):t.push(e),t},ne=function(A,e,t,r){var n=[];return re(A)?n.push(A.subdivide(.5,!1)):n.push(A),re(t)?n.push(t.subdivide(.5,!0)):n.push(t),re(r)?n.push(r.subdivide(.5,!0).reverse()):n.push(r),re(e)?n.push(e.subdivide(.5,!1).reverse()):n.push(e),n},Ml=function(A){var e=A.bounds,t=A.styles;return e.add(t.borderLeftWidth,t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth),-(t.borderTopWidth+t.borderBottomWidth))},ts=function(A){var e=A.styles,t=A.bounds,r=uA(e.paddingLeft,t.width),n=uA(e.paddingRight,t.width),s=uA(e.paddingTop,t.width),a=uA(e.paddingBottom,t.width);return t.add(r+e.borderLeftWidth,s+e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth+r+n),-(e.borderTopWidth+e.borderBottomWidth+s+a))},Cb=function(A,e){return A===0?e.bounds:A===2?ts(e):Ml(e)},wb=function(A,e){return A===0?e.bounds:A===2?ts(e):Ml(e)},ci=function(A,e,t){var r=Cb(xt(A.styles.backgroundOrigin,e),A),n=wb(xt(A.styles.backgroundClip,e),A),s=Tb(xt(A.styles.backgroundSize,e),t,r),a=s[0],u=s[1],o=br(xt(A.styles.backgroundPosition,e),r.width-a,r.height-u),c=bb(xt(A.styles.backgroundRepeat,e),o,s,r,n),f=Math.round(r.left+o[0]),h=Math.round(r.top+o[1]);return[c,f,h,a,u]},Ht=function(A){return iA(A)&&A.value===yt.AUTO},rs=function(A){return typeof A=="number"},Tb=function(A,e,t){var r=e[0],n=e[1],s=e[2],a=A[0],u=A[1];if(!a)return[0,0];if(CA(a)&&u&&CA(u))return[uA(a,t.width),uA(u,t.height)];var o=rs(s);if(iA(a)&&(a.value===yt.CONTAIN||a.value===yt.COVER)){if(rs(s)){var c=t.width/t.height;return c<s!=(a.value===yt.COVER)?[t.width,t.width/s]:[t.height*s,t.height]}return[t.width,t.height]}var f=rs(r),h=rs(n),d=f||h;if(Ht(a)&&(!u||Ht(u))){if(f&&h)return[r,n];if(!o&&!d)return[t.width,t.height];if(d&&o){var C=f?r:n*s,m=h?n:r/s;return[C,m]}var T=f?r:t.width,F=h?n:t.height;return[T,F]}if(o){var Q=0,I=0;return CA(a)?Q=uA(a,t.width):CA(u)&&(I=uA(u,t.height)),Ht(a)?Q=I*s:(!u||Ht(u))&&(I=Q/s),[Q,I]}var H=null,M=null;if(CA(a)?H=uA(a,t.width):u&&CA(u)&&(M=uA(u,t.height)),H!==null&&(!u||Ht(u))&&(M=f&&h?H/r*n:t.height),M!==null&&Ht(a)&&(H=f&&h?M/n*r:t.width),H!==null&&M!==null)return[H,M];throw new Error("Unable to calculate background-size for element")},xt=function(A,e){var t=A[e];return typeof t>"u"?A[0]:t},bb=function(A,e,t,r,n){var s=e[0],a=e[1],u=t[0],o=t[1];switch(A){case 2:return[new x(Math.round(r.left),Math.round(r.top+a)),new x(Math.round(r.left+r.width),Math.round(r.top+a)),new x(Math.round(r.left+r.width),Math.round(o+r.top+a)),new x(Math.round(r.left),Math.round(o+r.top+a))];case 3:return[new x(Math.round(r.left+s),Math.round(r.top)),new x(Math.round(r.left+s+u),Math.round(r.top)),new x(Math.round(r.left+s+u),Math.round(r.height+r.top)),new x(Math.round(r.left+s),Math.round(r.height+r.top))];case 1:return[new x(Math.round(r.left+s),Math.round(r.top+a)),new x(Math.round(r.left+s+u),Math.round(r.top+a)),new x(Math.round(r.left+s+u),Math.round(r.top+a+o)),new x(Math.round(r.left+s),Math.round(r.top+a+o))];default:return[new x(Math.round(n.left),Math.round(n.top)),new x(Math.round(n.left+n.width),Math.round(n.top)),new x(Math.round(n.left+n.width),Math.round(n.height+n.top)),new x(Math.round(n.left),Math.round(n.height+n.top))]}},Ub="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",kl="Hidden Text",Qb=function(){function A(e){this._data={},this._document=e}return A.prototype.parseMetrics=function(e,t){var r=this._document.createElement("div"),n=this._document.createElement("img"),s=this._document.createElement("span"),a=this._document.body;r.style.visibility="hidden",r.style.fontFamily=e,r.style.fontSize=t,r.style.margin="0",r.style.padding="0",r.style.whiteSpace="nowrap",a.appendChild(r),n.src=Ub,n.width=1,n.height=1,n.style.margin="0",n.style.padding="0",n.style.verticalAlign="baseline",s.style.fontFamily=e,s.style.fontSize=t,s.style.margin="0",s.style.padding="0",s.appendChild(this._document.createTextNode(kl)),r.appendChild(s),r.appendChild(n);var u=n.offsetTop-s.offsetTop+2;r.removeChild(s),r.appendChild(this._document.createTextNode(kl)),r.style.lineHeight="normal",n.style.verticalAlign="super";var o=n.offsetTop-r.offsetTop+2;return a.removeChild(r),{baseline:u,middle:o}},A.prototype.getMetrics=function(e,t){var r=e+" "+t;return typeof this._data[r]>"u"&&(this._data[r]=this.parseMetrics(e,t)),this._data[r]},A}(),Pl=function(){function A(e,t){this.context=e,this.options=t}return A}(),Fb=1e4,Ib=function(A){ue(e,A);function e(t,r){var n=A.call(this,t,r)||this;return n._activeEffects=[],n.canvas=r.canvas?r.canvas:document.createElement("canvas"),n.ctx=n.canvas.getContext("2d"),r.canvas||(n.canvas.width=Math.floor(r.width*r.scale),n.canvas.height=Math.floor(r.height*r.scale),n.canvas.style.width=r.width+"px",n.canvas.style.height=r.height+"px"),n.fontMetrics=new Qb(document),n.ctx.scale(n.options.scale,n.options.scale),n.ctx.translate(-r.x,-r.y),n.ctx.textBaseline="bottom",n._activeEffects=[],n.context.logger.debug("Canvas renderer initialized ("+r.width+"x"+r.height+") with scale "+r.scale),n}return e.prototype.applyEffects=function(t){for(var r=this;this._activeEffects.length;)this.popEffect();t.forEach(function(n){return r.applyEffect(n)})},e.prototype.applyEffect=function(t){this.ctx.save(),db(t)&&(this.ctx.globalAlpha=t.opacity),hb(t)&&(this.ctx.translate(t.offsetX,t.offsetY),this.ctx.transform(t.matrix[0],t.matrix[1],t.matrix[2],t.matrix[3],t.matrix[4],t.matrix[5]),this.ctx.translate(-t.offsetX,-t.offsetY)),Ll(t)&&(this.path(t.path),this.ctx.clip()),this._activeEffects.push(t)},e.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},e.prototype.renderStack=function(t){return kA(this,void 0,void 0,function(){var r;return DA(this,function(n){switch(n.label){case 0:return r=t.element.container.styles,r.isVisible()?[4,this.renderStackContent(t)]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},e.prototype.renderNode=function(t){return kA(this,void 0,void 0,function(){return DA(this,function(r){switch(r.label){case 0:if(bA(t.container.flags,16))debugger;return t.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(t)]:[3,3];case 1:return r.sent(),[4,this.renderNodeContent(t)];case 2:r.sent(),r.label=3;case 3:return[2]}})})},e.prototype.renderTextWithLetterSpacing=function(t,r,n){var s=this;if(r===0)this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+n);else{var a=Za(t.text);a.reduce(function(u,o){return s.ctx.fillText(o,u,t.bounds.top+n),u+s.ctx.measureText(o).width},t.bounds.left)}},e.prototype.createFontStyle=function(t){var r=t.fontVariant.filter(function(a){return a==="normal"||a==="small-caps"}).join(""),n=vb(t.fontFamily).join(", "),s=Tr(t.fontSize)?""+t.fontSize.number+t.fontSize.unit:t.fontSize.number+"px";return[[t.fontStyle,r,t.fontWeight,s,n].join(" "),n,s]},e.prototype.renderTextNode=function(t,r){return kA(this,void 0,void 0,function(){var n,s,a,u,o,c,f,h,d=this;return DA(this,function(C){return n=this.createFontStyle(r),s=n[0],a=n[1],u=n[2],this.ctx.font=s,this.ctx.direction=r.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",o=this.fontMetrics.getMetrics(a,u),c=o.baseline,f=o.middle,h=r.paintOrder,t.textBounds.forEach(function(m){h.forEach(function(T){switch(T){case 0:d.ctx.fillStyle=NA(r.color),d.renderTextWithLetterSpacing(m,r.letterSpacing,c);var F=r.textShadow;F.length&&m.text.trim().length&&(F.slice(0).reverse().forEach(function(Q){d.ctx.shadowColor=NA(Q.color),d.ctx.shadowOffsetX=Q.offsetX.number*d.options.scale,d.ctx.shadowOffsetY=Q.offsetY.number*d.options.scale,d.ctx.shadowBlur=Q.blur.number,d.renderTextWithLetterSpacing(m,r.letterSpacing,c)}),d.ctx.shadowColor="",d.ctx.shadowOffsetX=0,d.ctx.shadowOffsetY=0,d.ctx.shadowBlur=0),r.textDecorationLine.length&&(d.ctx.fillStyle=NA(r.textDecorationColor||r.color),r.textDecorationLine.forEach(function(Q){switch(Q){case 1:d.ctx.fillRect(m.bounds.left,Math.round(m.bounds.top+c),m.bounds.width,1);break;case 2:d.ctx.fillRect(m.bounds.left,Math.round(m.bounds.top),m.bounds.width,1);break;case 3:d.ctx.fillRect(m.bounds.left,Math.ceil(m.bounds.top+f),m.bounds.width,1);break}}));break;case 1:r.webkitTextStrokeWidth&&m.text.trim().length&&(d.ctx.strokeStyle=NA(r.webkitTextStrokeColor),d.ctx.lineWidth=r.webkitTextStrokeWidth,d.ctx.lineJoin=window.chrome?"miter":"round",d.ctx.strokeText(m.text,m.bounds.left,m.bounds.top+c)),d.ctx.strokeStyle="",d.ctx.lineWidth=0,d.ctx.lineJoin="miter";break}})}),[2]})})},e.prototype.renderReplacedElement=function(t,r,n){if(n&&t.intrinsicWidth>0&&t.intrinsicHeight>0){var s=ts(t),a=zn(r);this.path(a),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(n,0,0,t.intrinsicWidth,t.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},e.prototype.renderNodeContent=function(t){return kA(this,void 0,void 0,function(){var r,n,s,a,u,o,I,I,c,f,h,d,M,C,m,y,T,F,Q,I,H,M,y;return DA(this,function(p){switch(p.label){case 0:this.applyEffects(t.getEffects(4)),r=t.container,n=t.curves,s=r.styles,a=0,u=r.textNodes,p.label=1;case 1:return a<u.length?(o=u[a],[4,this.renderTextNode(o,s)]):[3,4];case 2:p.sent(),p.label=3;case 3:return a++,[3,1];case 4:if(!(r instanceof sl))return[3,8];p.label=5;case 5:return p.trys.push([5,7,,8]),[4,this.context.cache.match(r.src)];case 6:return I=p.sent(),this.renderReplacedElement(r,n,I),[3,8];case 7:return p.sent(),this.context.logger.error("Error loading image "+r.src),[3,8];case 8:if(r instanceof al&&this.renderReplacedElement(r,n,r.canvas),!(r instanceof il))return[3,12];p.label=9;case 9:return p.trys.push([9,11,,12]),[4,this.context.cache.match(r.svg)];case 10:return I=p.sent(),this.renderReplacedElement(r,n,I),[3,12];case 11:return p.sent(),this.context.logger.error("Error loading svg "+r.svg.substring(0,255)),[3,12];case 12:return r instanceof fl&&r.tree?(c=new e(this.context,{scale:this.options.scale,backgroundColor:r.backgroundColor,x:0,y:0,width:r.width,height:r.height}),[4,c.render(r.tree)]):[3,14];case 13:f=p.sent(),r.width&&r.height&&this.ctx.drawImage(f,0,0,r.width,r.height,r.bounds.left,r.bounds.top,r.bounds.width,r.bounds.height),p.label=14;case 14:if(r instanceof za&&(h=Math.min(r.bounds.width,r.bounds.height),r.type===Yn?r.checked&&(this.ctx.save(),this.path([new x(r.bounds.left+h*.39363,r.bounds.top+h*.79),new x(r.bounds.left+h*.16,r.bounds.top+h*.5549),new x(r.bounds.left+h*.27347,r.bounds.top+h*.44071),new x(r.bounds.left+h*.39694,r.bounds.top+h*.5649),new x(r.bounds.left+h*.72983,r.bounds.top+h*.23),new x(r.bounds.left+h*.84,r.bounds.top+h*.34085),new x(r.bounds.left+h*.39363,r.bounds.top+h*.79)]),this.ctx.fillStyle=NA(ol),this.ctx.fill(),this.ctx.restore()):r.type===Xn&&r.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(r.bounds.left+h/2,r.bounds.top+h/2,h/4,0,Math.PI*2,!0),this.ctx.fillStyle=NA(ol),this.ctx.fill(),this.ctx.restore())),_b(r)&&r.value.length){switch(d=this.createFontStyle(s),M=d[0],C=d[1],m=this.fontMetrics.getMetrics(M,C).baseline,this.ctx.font=M,this.ctx.fillStyle=NA(s.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=Nb(r.styles.textAlign),y=ts(r),T=0,r.styles.textAlign){case 1:T+=y.width/2;break;case 2:T+=y.width;break}F=y.add(T,0,0,-y.height/2+1),this.ctx.save(),this.path([new x(y.left,y.top),new x(y.left+y.width,y.top),new x(y.left+y.width,y.top+y.height),new x(y.left,y.top+y.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new Ir(r.value,F),s.letterSpacing,m),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!bA(r.styles.display,2048))return[3,20];if(r.styles.listStyleImage===null)return[3,19];if(Q=r.styles.listStyleImage,Q.type!==0)return[3,18];I=void 0,H=Q.url,p.label=15;case 15:return p.trys.push([15,17,,18]),[4,this.context.cache.match(H)];case 16:return I=p.sent(),this.ctx.drawImage(I,r.bounds.left-(I.width+10),r.bounds.top),[3,18];case 17:return p.sent(),this.context.logger.error("Error loading list-style-image "+H),[3,18];case 18:return[3,20];case 19:t.listValue&&r.styles.listStyleType!==-1&&(M=this.createFontStyle(s)[0],this.ctx.font=M,this.ctx.fillStyle=NA(s.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",y=new be(r.bounds.left,r.bounds.top+uA(r.styles.paddingTop,r.bounds.width),r.bounds.width,kc(s.lineHeight,s.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new Ir(t.listValue,y),s.letterSpacing,kc(s.lineHeight,s.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"),p.label=20;case 20:return[2]}})})},e.prototype.renderStackContent=function(t){return kA(this,void 0,void 0,function(){var r,n,Q,s,a,Q,u,o,Q,c,f,Q,h,d,Q,C,m,Q,T,F,Q;return DA(this,function(I){switch(I.label){case 0:if(bA(t.element.container.flags,16))debugger;return[4,this.renderNodeBackgroundAndBorders(t.element)];case 1:I.sent(),r=0,n=t.negativeZIndex,I.label=2;case 2:return r<n.length?(Q=n[r],[4,this.renderStack(Q)]):[3,5];case 3:I.sent(),I.label=4;case 4:return r++,[3,2];case 5:return[4,this.renderNodeContent(t.element)];case 6:I.sent(),s=0,a=t.nonInlineLevel,I.label=7;case 7:return s<a.length?(Q=a[s],[4,this.renderNode(Q)]):[3,10];case 8:I.sent(),I.label=9;case 9:return s++,[3,7];case 10:u=0,o=t.nonPositionedFloats,I.label=11;case 11:return u<o.length?(Q=o[u],[4,this.renderStack(Q)]):[3,14];case 12:I.sent(),I.label=13;case 13:return u++,[3,11];case 14:c=0,f=t.nonPositionedInlineLevel,I.label=15;case 15:return c<f.length?(Q=f[c],[4,this.renderStack(Q)]):[3,18];case 16:I.sent(),I.label=17;case 17:return c++,[3,15];case 18:h=0,d=t.inlineLevel,I.label=19;case 19:return h<d.length?(Q=d[h],[4,this.renderNode(Q)]):[3,22];case 20:I.sent(),I.label=21;case 21:return h++,[3,19];case 22:C=0,m=t.zeroOrAutoZIndexOrTransformedOrOpacity,I.label=23;case 23:return C<m.length?(Q=m[C],[4,this.renderStack(Q)]):[3,26];case 24:I.sent(),I.label=25;case 25:return C++,[3,23];case 26:T=0,F=t.positiveZIndex,I.label=27;case 27:return T<F.length?(Q=F[T],[4,this.renderStack(Q)]):[3,30];case 28:I.sent(),I.label=29;case 29:return T++,[3,27];case 30:return[2]}})})},e.prototype.mask=function(t){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(t.slice(0).reverse()),this.ctx.closePath()},e.prototype.path=function(t){this.ctx.beginPath(),this.formatPath(t),this.ctx.closePath()},e.prototype.formatPath=function(t){var r=this;t.forEach(function(n,s){var a=re(n)?n.start:n;s===0?r.ctx.moveTo(a.x,a.y):r.ctx.lineTo(a.x,a.y),re(n)&&r.ctx.bezierCurveTo(n.startControl.x,n.startControl.y,n.endControl.x,n.endControl.y,n.end.x,n.end.y)})},e.prototype.renderRepeat=function(t,r,n,s){this.path(t),this.ctx.fillStyle=r,this.ctx.translate(n,s),this.ctx.fill(),this.ctx.translate(-n,-s)},e.prototype.resizeImage=function(t,r,n){var s;if(t.width===r&&t.height===n)return t;var a=(s=this.canvas.ownerDocument)!==null&&s!==void 0?s:document,u=a.createElement("canvas");u.width=Math.max(1,r),u.height=Math.max(1,n);var o=u.getContext("2d");return o.drawImage(t,0,0,t.width,t.height,0,0,r,n),u},e.prototype.renderBackgroundImage=function(t){return kA(this,void 0,void 0,function(){var r,n,s,a,u,o;return DA(this,function(c){switch(c.label){case 0:r=t.styles.backgroundImage.length-1,n=function(f){var h,d,C,AA,P,z,W,tA,k,m,AA,P,z,W,tA,T,F,Q,I,H,M,y,p,v,k,O,AA,oA,cA,W,tA,R,P,z,rA,lA,UA,HA,RA,QA,PA,wA;return DA(this,function(ce){switch(ce.label){case 0:if(f.type!==0)return[3,5];h=void 0,d=f.url,ce.label=1;case 1:return ce.trys.push([1,3,,4]),[4,s.context.cache.match(d)];case 2:return h=ce.sent(),[3,4];case 3:return ce.sent(),s.context.logger.error("Error loading background-image "+d),[3,4];case 4:return h&&(C=ci(t,r,[h.width,h.height,h.width/h.height]),AA=C[0],P=C[1],z=C[2],W=C[3],tA=C[4],k=s.ctx.createPattern(s.resizeImage(h,W,tA),"repeat"),s.renderRepeat(AA,k,P,z)),[3,6];case 5:h1(f)?(m=ci(t,r,[null,null,null]),AA=m[0],P=m[1],z=m[2],W=m[3],tA=m[4],T=u1(f.angle,W,tA),F=T[0],Q=T[1],I=T[2],H=T[3],M=T[4],y=document.createElement("canvas"),y.width=W,y.height=tA,p=y.getContext("2d"),v=p.createLinearGradient(Q,H,I,M),yc(f.stops,F).forEach(function(We){return v.addColorStop(We.stop,NA(We.color))}),p.fillStyle=v,p.fillRect(0,0,W,tA),W>0&&tA>0&&(k=s.ctx.createPattern(y,"repeat"),s.renderRepeat(AA,k,P,z))):d1(f)&&(O=ci(t,r,[null,null,null]),AA=O[0],oA=O[1],cA=O[2],W=O[3],tA=O[4],R=f.position.length===0?[Da]:f.position,P=uA(R[0],W),z=uA(R[R.length-1],tA),rA=o1(f,P,z,W,tA),lA=rA[0],UA=rA[1],lA>0&&UA>0&&(HA=s.ctx.createRadialGradient(oA+P,cA+z,0,oA+P,cA+z,lA),yc(f.stops,lA*2).forEach(function(We){return HA.addColorStop(We.stop,NA(We.color))}),s.path(AA),s.ctx.fillStyle=HA,lA!==UA?(RA=t.bounds.left+.5*t.bounds.width,QA=t.bounds.top+.5*t.bounds.height,PA=UA/lA,wA=1/PA,s.ctx.save(),s.ctx.translate(RA,QA),s.ctx.transform(1,0,0,PA,0,0),s.ctx.translate(-RA,-QA),s.ctx.fillRect(oA,wA*(cA-QA)+QA,W,tA*wA),s.ctx.restore()):s.ctx.fill())),ce.label=6;case 6:return r--,[2]}})},s=this,a=0,u=t.styles.backgroundImage.slice(0).reverse(),c.label=1;case 1:return a<u.length?(o=u[a],[5,n(o)]):[3,4];case 2:c.sent(),c.label=3;case 3:return a++,[3,1];case 4:return[2]}})})},e.prototype.renderSolidBorder=function(t,r,n){return kA(this,void 0,void 0,function(){return DA(this,function(s){return this.path(Rl(n,r)),this.ctx.fillStyle=NA(t),this.ctx.fill(),[2]})})},e.prototype.renderDoubleBorder=function(t,r,n,s){return kA(this,void 0,void 0,function(){var a,u;return DA(this,function(o){switch(o.label){case 0:return r<3?[4,this.renderSolidBorder(t,n,s)]:[3,2];case 1:return o.sent(),[2];case 2:return a=Eb(s,n),this.path(a),this.ctx.fillStyle=NA(t),this.ctx.fill(),u=pb(s,n),this.path(u),this.ctx.fill(),[2]}})})},e.prototype.renderNodeBackgroundAndBorders=function(t){return kA(this,void 0,void 0,function(){var r,n,s,a,u,o,c,f,h=this;return DA(this,function(d){switch(d.label){case 0:return this.applyEffects(t.getEffects(2)),r=t.container.styles,n=!Ve(r.backgroundColor)||r.backgroundImage.length,s=[{style:r.borderTopStyle,color:r.borderTopColor,width:r.borderTopWidth},{style:r.borderRightStyle,color:r.borderRightColor,width:r.borderRightWidth},{style:r.borderBottomStyle,color:r.borderBottomColor,width:r.borderBottomWidth},{style:r.borderLeftStyle,color:r.borderLeftColor,width:r.borderLeftWidth}],a=yb(xt(r.backgroundClip,0),t.curves),n||r.boxShadow.length?(this.ctx.save(),this.path(a),this.ctx.clip(),Ve(r.backgroundColor)||(this.ctx.fillStyle=NA(r.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(t.container)]):[3,2];case 1:d.sent(),this.ctx.restore(),r.boxShadow.slice(0).reverse().forEach(function(C){h.ctx.save();var m=$n(t.curves),T=C.inset?0:Fb,F=Bb(m,-T+(C.inset?1:-1)*C.spread.number,(C.inset?1:-1)*C.spread.number,C.spread.number*(C.inset?-2:2),C.spread.number*(C.inset?-2:2));C.inset?(h.path(m),h.ctx.clip(),h.mask(F)):(h.mask(m),h.ctx.clip(),h.path(F)),h.ctx.shadowOffsetX=C.offsetX.number+T,h.ctx.shadowOffsetY=C.offsetY.number,h.ctx.shadowColor=NA(C.color),h.ctx.shadowBlur=C.blur.number,h.ctx.fillStyle=C.inset?NA(C.color):"rgba(0,0,0,1)",h.ctx.fill(),h.ctx.restore()}),d.label=2;case 2:u=0,o=0,c=s,d.label=3;case 3:return o<c.length?(f=c[o],f.style!==0&&!Ve(f.color)&&f.width>0?f.style!==2?[3,5]:[4,this.renderDashedDottedBorder(f.color,f.width,u,t.curves,2)]:[3,11]):[3,13];case 4:return d.sent(),[3,11];case 5:return f.style!==3?[3,7]:[4,this.renderDashedDottedBorder(f.color,f.width,u,t.curves,3)];case 6:return d.sent(),[3,11];case 7:return f.style!==4?[3,9]:[4,this.renderDoubleBorder(f.color,f.width,u,t.curves)];case 8:return d.sent(),[3,11];case 9:return[4,this.renderSolidBorder(f.color,u,t.curves)];case 10:d.sent(),d.label=11;case 11:u++,d.label=12;case 12:return o++,[3,3];case 13:return[2]}})})},e.prototype.renderDashedDottedBorder=function(t,r,n,s,a){return kA(this,void 0,void 0,function(){var u,o,c,f,h,d,C,m,T,F,Q,I,H,M,y,p,y,p;return DA(this,function(v){return this.ctx.save(),u=mb(s,n),o=Rl(s,n),a===2&&(this.path(o),this.ctx.clip()),re(o[0])?(c=o[0].start.x,f=o[0].start.y):(c=o[0].x,f=o[0].y),re(o[1])?(h=o[1].end.x,d=o[1].end.y):(h=o[1].x,d=o[1].y),n===0||n===2?C=Math.abs(c-h):C=Math.abs(f-d),this.ctx.beginPath(),a===3?this.formatPath(u):this.formatPath(o.slice(0,2)),m=r<3?r*3:r*2,T=r<3?r*2:r,a===3&&(m=r,T=r),F=!0,C<=m*2?F=!1:C<=m*2+T?(Q=C/(2*m+T),m*=Q,T*=Q):(I=Math.floor((C+T)/(m+T)),H=(C-I*m)/(I-1),M=(C-(I+1)*m)/I,T=M<=0||Math.abs(T-H)<Math.abs(T-M)?H:M),F&&(a===3?this.ctx.setLineDash([0,m+T]):this.ctx.setLineDash([m,T])),a===3?(this.ctx.lineCap="round",this.ctx.lineWidth=r):this.ctx.lineWidth=r*2+1.1,this.ctx.strokeStyle=NA(t),this.ctx.stroke(),this.ctx.setLineDash([]),a===2&&(re(o[0])&&(y=o[3],p=o[0],this.ctx.beginPath(),this.formatPath([new x(y.end.x,y.end.y),new x(p.start.x,p.start.y)]),this.ctx.stroke()),re(o[1])&&(y=o[1],p=o[2],this.ctx.beginPath(),this.formatPath([new x(y.end.x,y.end.y),new x(p.start.x,p.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]})})},e.prototype.render=function(t){return kA(this,void 0,void 0,function(){var r;return DA(this,function(n){switch(n.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=NA(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),r=gb(t),[4,this.renderStack(r)];case 1:return n.sent(),this.applyEffects([]),[2,this.canvas]}})})},e}(Pl),_b=function(A){return A instanceof ll||A instanceof cl?!0:A instanceof za&&A.type!==Xn&&A.type!==Yn},yb=function(A,e){switch(A){case 0:return $n(e);case 2:return cb(e);case 1:default:return zn(e)}},Nb=function(A){switch(A){case 1:return"center";case 2:return"right";case 0:default:return"left"}},Sb=["-apple-system","system-ui"],vb=function(A){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?A.filter(function(e){return Sb.indexOf(e)===-1}):A},Lb=function(A){ue(e,A);function e(t,r){var n=A.call(this,t,r)||this;return n.canvas=r.canvas?r.canvas:document.createElement("canvas"),n.ctx=n.canvas.getContext("2d"),n.options=r,n.canvas.width=Math.floor(r.width*r.scale),n.canvas.height=Math.floor(r.height*r.scale),n.canvas.style.width=r.width+"px",n.canvas.style.height=r.height+"px",n.ctx.scale(n.options.scale,n.options.scale),n.ctx.translate(-r.x,-r.y),n.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+r.width+"x"+r.height+" at "+r.x+","+r.y+") with scale "+r.scale),n}return e.prototype.render=function(t){return kA(this,void 0,void 0,function(){var r,n;return DA(this,function(s){switch(s.label){case 0:return r=ja(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,t),[4,Hb(r)];case 1:return n=s.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=NA(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(n,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},e}(Pl),Hb=function(A){return new Promise(function(e,t){var r=new Image;r.onload=function(){e(r)},r.onerror=t,r.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(A))})},xb=function(){function A(e){var t=e.id,r=e.enabled;this.id=t,this.enabled=r,this.start=Date.now()}return A.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console&&typeof console.debug=="function"?console.debug.apply(console,ln([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},A.prototype.getTime=function(){return Date.now()-this.start},A.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&typeof window<"u"&&window.console&&typeof console.info=="function"&&console.info.apply(console,ln([this.id,this.getTime()+"ms"],e))},A.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console&&typeof console.warn=="function"?console.warn.apply(console,ln([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},A.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.enabled&&(typeof window<"u"&&window.console&&typeof console.error=="function"?console.error.apply(console,ln([this.id,this.getTime()+"ms"],e)):this.info.apply(this,e))},A.instances={},A}(),Db=function(){function A(e,t){var r;this.windowBounds=t,this.instanceName="#"+A.instanceCount++,this.logger=new xb({id:this.instanceName,enabled:e.logging}),this.cache=(r=e.cache)!==null&&r!==void 0?r:new tb(this,e)}return A.instanceCount=1,A}(),Ob=function(A,e){return e===void 0&&(e={}),Rb(A,e)};typeof window<"u"&&vl.setContext(window);var Rb=function(A,e){return kA(void 0,void 0,void 0,function(){var t,r,n,s,a,u,o,c,f,h,d,C,m,T,F,Q,I,H,M,y,v,p,v,k,O,AA,oA,cA,W,tA,R,P,z,rA,lA,UA,HA,RA,QA,PA;return DA(this,function(wA){switch(wA.label){case 0:if(!A||typeof A!="object")return[2,Promise.reject("Invalid element provided as first argument")];if(t=A.ownerDocument,!t)throw new Error("Element is not attached to a Document");if(r=t.defaultView,!r)throw new Error("Document is not attached to a Window");return n={allowTaint:(k=e.allowTaint)!==null&&k!==void 0?k:!1,imageTimeout:(O=e.imageTimeout)!==null&&O!==void 0?O:15e3,proxy:e.proxy,useCORS:(AA=e.useCORS)!==null&&AA!==void 0?AA:!1},s=Ba({logging:(oA=e.logging)!==null&&oA!==void 0?oA:!0,cache:e.cache},n),a={windowWidth:(cA=e.windowWidth)!==null&&cA!==void 0?cA:r.innerWidth,windowHeight:(W=e.windowHeight)!==null&&W!==void 0?W:r.innerHeight,scrollX:(tA=e.scrollX)!==null&&tA!==void 0?tA:r.pageXOffset,scrollY:(R=e.scrollY)!==null&&R!==void 0?R:r.pageYOffset},u=new be(a.scrollX,a.scrollY,a.windowWidth,a.windowHeight),o=new Db(s,u),c=(P=e.foreignObjectRendering)!==null&&P!==void 0?P:!1,f={allowTaint:(z=e.allowTaint)!==null&&z!==void 0?z:!1,onclone:e.onclone,ignoreElements:e.ignoreElements,inlineImages:c,copyStyles:c},o.logger.debug("Starting document clone with size "+u.width+"x"+u.height+" scrolled to "+-u.left+","+-u.top),h=new Nl(o,A,f),d=h.clonedReferenceElement,d?[4,h.toIFrame(t,u)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return C=wA.sent(),m=ei(d)||MT(d)?Bm(d.ownerDocument):fn(o,d),T=m.width,F=m.height,Q=m.left,I=m.top,H=Mb(o,d,e.backgroundColor),M={canvas:e.canvas,backgroundColor:H,scale:(lA=(rA=e.scale)!==null&&rA!==void 0?rA:r.devicePixelRatio)!==null&&lA!==void 0?lA:1,x:((UA=e.x)!==null&&UA!==void 0?UA:0)+Q,y:((HA=e.y)!==null&&HA!==void 0?HA:0)+I,width:(RA=e.width)!==null&&RA!==void 0?RA:Math.ceil(T),height:(QA=e.height)!==null&&QA!==void 0?QA:Math.ceil(F)},c?(o.logger.debug("Document cloned, using foreign object rendering"),v=new Lb(o,M),[4,v.render(d)]):[3,3];case 2:return y=wA.sent(),[3,5];case 3:return o.logger.debug("Document cloned, element located at "+Q+","+I+" with size "+T+"x"+F+" using computed rendering"),o.logger.debug("Starting DOM parsing"),p=dl(o,d),H===p.styles.backgroundColor&&(p.styles.backgroundColor=Qe.TRANSPARENT),o.logger.debug("Starting renderer for element at "+M.x+","+M.y+" with size "+M.width+"x"+M.height),v=new Ib(o,M),[4,v.render(p)];case 4:y=wA.sent(),wA.label=5;case 5:return(!((PA=e.removeContainer)!==null&&PA!==void 0)||PA)&&(Nl.destroy(C)||o.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),o.logger.debug("Finished rendering"),[2,y]}})})},Mb=function(A,e,t){var r=e.ownerDocument,n=r.documentElement?Ur(A,getComputedStyle(r.documentElement).backgroundColor):Qe.TRANSPARENT,s=r.body?Ur(A,getComputedStyle(r.body).backgroundColor):Qe.TRANSPARENT,a=typeof t=="string"?Ur(A,t):t===null?Qe.TRANSPARENT:4294967295;return e===r.documentElement?Ve(n)?Ve(s)?a:s:n:a};const kb=l.defineComponent({name:"GpIframe",props:{htmlContent:{type:String,required:!0},jsFiles:{type:Array,default:[]},cssFiles:{type:Array,default:[]},iframeStyle:{type:Object,default:()=>({width:"100%",height:"100%",border:"none"})}},setup(A){const e=l.ref(null),t=l.ref(),r=()=>{var c;const s=e.value;if(!s)return;const a=s.contentDocument||((c=s.contentWindow)==null?void 0:c.document);if(!a)return;a.open(),a.write("<!DOCTYPE html><html><head></head><body></body></html>"),a.close();const u=a.head;A.cssFiles.forEach(f=>{const h=a.createElement("link");h.rel="stylesheet",h.href=f,u.appendChild(h)});const o=a.body;o.innerHTML=A.htmlContent,A.jsFiles.forEach(f=>{const h=a.createElement("script");h.src=f,h.async=!0,o.appendChild(h)}),t.value=o,l.nextTick(()=>{})};l.watch(t,s=>{if(!s)return;new MutationObserver(()=>{const u=e.value;u&&(console.log("iframe.style.height",s.scrollHeight,u.style.height),u.style.height=`${s.scrollHeight}px`)}).observe(s,{childList:!0,subtree:!0})});const n=async s=>{var c;const a=e.value;if(!a)return;const u=a.contentDocument||((c=a.contentWindow)==null?void 0:c.document);if(!u)return;const o=u.body;if(o)try{await l.nextTick();const f=await Ob(o,{x:0,y:0,scrollX:window.scrollX,scrollY:window.scrollY,useCORS:!0,allowTaint:!0,foreignObjectRendering:!1});s?s(f):f.toBlob(h=>{const d=URL.createObjectURL(h);window.open(d,"_blank")})}catch(f){console.error("截图生成失败:",f)}};return l.watch(()=>[A.htmlContent,A.jsFiles,A.cssFiles],r,{deep:!0}),l.onMounted(()=>{r()}),{iframeRef:e,generateCover:n}}});function Pb(A,e,t,r,n,s){return l.openBlock(),l.createElementBlock("div",null,[l.createElementVNode("iframe",{ref:"iframeRef",style:l.normalizeStyle(A.iframeStyle)},null,4)])}const Kl=He(kb,[["render",Pb],["__scopeId","data-v-c23563ae"]]),Kb={class:"flex gp-dsigner"},Vb={key:0,class:"flex items-center justify-between border-b"},Gb={class:"text-lg font-bold p-2"},Yb={class:"text-sm font-thin text-gray-500"},Xb={class:"flex-1 overflow-auto"},Wb={key:0,class:"text-lg font-bold border-b p-2"},Jb={class:"p-2"},qb={class:"sticky top-0"},jb={key:0,class:"text-lg font-bold border-b p-2"},Zb={class:"text-sm font-thin text-gray-500"},$b={class:"p-2"},Vl=He(l.defineComponent({__name:"Designer",props:{mode:{default:"design"},template:{},css:{},js:{},previewWidth:{default:360},uploadByFile:{},icons:{},rules:{},preview:{type:Boolean,default:!0},showTitle:{type:Boolean,default:!0}},emits:["update:modelValue","update:element"],setup(A,{expose:e,emit:t}){const r=A,n=t,s=l.ref(r.template),a=l.ref();let u=so("",{},!1);const o=l.ref("");l.watch(()=>r.template,N=>{s.value=N},{immediate:!0}),l.watch(()=>s.value,N=>{N&&(a.value=O(N))},{immediate:!0}),l.watch(()=>r.css,N=>{N.forEach(L=>{if(document.querySelector(`link[href="${L}"]`))return;const K=document.createElement("link");K.rel="stylesheet",K.href=L,document.head.appendChild(K)})},{immediate:!0}),l.watch(()=>r.js,N=>{!N||N.length===0||N.forEach(L=>{if(document.querySelector(`script[src="${L}"]`))return;const K=document.createElement("script");K.src=L,document.body.appendChild(K)})},{immediate:!0});const c=l.ref(r.mode);l.watch(()=>a.value,N=>{N&&n("update:element",N)},{immediate:!0});const f=l.ref("");l.watch(()=>o.value,N=>{n("update:modelValue",N)},{immediate:!0});const h=l.ref(),d=l.ref(),C=l.ref(),m=l.ref(),T=l.ref(),F=l.ref(),Q=l.ref("");function I(N=void 0){m.value&&m.value.generateCover(N)}function H(N){T.value=N}function M(N,L=""){if(L){const K=y(a.value,L);K?F.value=K:F.value=N}else F.value=N}function y(N,L){if(N.xpath===L)return N;if(N.children&&N.children.length)for(const K of N.children){const Y=y(K,L);if(Y)return Y}}function p(N,L){var K,Y;return N.tag===L.tag&&((K=N.children)==null?void 0:K.length)===((Y=L.children)==null?void 0:Y.length)}function v(N){if(T.value.xpath==N.xpath){if(T.value){if(N.type===q.Block){var L=!0;const K=y(a.value,T.value.parentxpath||"");if(K&&K.children&&K.children.forEach(Y=>{if(Y.tag!=T.value.tag||!p(Y,T.value)){L=!1;return}}),!L){j.error("同级结构不一致,错误配置!");return}}if(T.value.rule=N.rule,T.value.type=N.type,T.value.type===q.Block){const K=y(a.value,T.value.parentxpath||"");K&&K.children&&(K.children.forEach(Y=>{if(Y.tag!=T.value.tag||!p(Y,T.value)){j.error("同级结构不一致,无法配置为块类型");return}}),K.children.forEach(Y=>{Y.tag===T.value.tag&&(Y.rule=N.rule,Y.type=N.type)}))}}f.value=new Date().getTime().toString(),j.success("保存成功")}}function k(N){o.value=N}function O(N){u=so(N);const L=u("body").children().toArray().map(K=>AA(u(K)));return o.value=u("body").html()||"",L[0]}function AA(N,L=""){var ot;function K(ZA){if(!ZA||!ZA[0])return"";const JA=[];let ct=ZA;for(;ct.length&&ct[0].tagName!=="html";){const Yl=ct[0].tagName,AU=ct.parent().children(Yl).index(ct)+1;JA.unshift(`${Yl}[${AU}]`),ct=ct.parent()}return"/html/"+JA.join("/")}const Y=K(N).replace("/html/body[1]",""),MA=N.children().toArray().map(ZA=>AA(u(ZA),Y)),me=(ot=r.rules)==null?void 0:ot.find(ZA=>ZA.xpath===Y);return{tag:N[0].tagName,text:N.contents().not(N.children()).text().trim(),attrs:N[0].attribs,children:MA,xpath:Y,parentxpath:L,type:(me==null?void 0:me.type)||q.None,rule:(me==null?void 0:me.rule)||{}}}function oA(N){console.log("更新子节点的文本",N);const L=y(a.value,N.element.xpath);if(L){const K=l.toRaw(L);K.editText=N.newText}}function cA(N,L=""){function K(Y,MA){var ZA;const ot=(MA?((ZA=y(a.value,MA))==null?void 0:ZA.children)||[]:[a.value]).filter(JA=>JA.tag===Y.tag).indexOf(Y)+1;return`${MA}/${Y.tag}[${ot}]`}N.xpath=K(N,L),N.parentxpath=L,(N.children||[]).forEach(Y=>cA(Y,N.xpath))}function W({action:N,element:L,newBlock:K}){const Y=y(a.value,L.parentxpath||"");if(!Y||!Y.children)return;const MA=Y.children.findIndex(JA=>JA===L);if(MA===-1){j.error("未找到元素");return}const me=Y.children.length,{minBlock:ot,maxBlock:ZA}=L.rule;if((N==="add"||N==="copy")&&me>=(ZA||1/0)){Q.value=`无法添加更多块。最大块数量为 ${ZA}`,j.error(Q.value);return}switch(N){case"add":if(K){const JA={...K,xpath:"",children:JSON.parse(JSON.stringify(K.children))};Y.children.splice(MA+1,0,JA),j.success("添加成功")}break;case"copy":if(K){const JA={...K,xpath:"",children:JSON.parse(JSON.stringify(K.children))};Y.children.splice(MA+1,0,JA),j.success("复制成功")}break;case"moveUp":if(MA>0){const[JA]=Y.children.splice(MA,1);Y.children.splice(MA-1,0,JA),j.success("前移成功")}else j.error("已经是第一个块,无法前移");break;case"moveDown":if(MA<Y.children.length-1){const[JA]=Y.children.splice(MA,1);Y.children.splice(MA+1,0,JA),j.success("后移成功")}else j.error("已经是最后一个块,无法后移");break;case"delete":if(me<=(ot||0)){Q.value=`无法删除更多块。最小块数量为 ${ot}`,j.error(Q.value);return}Y.children.splice(MA,1),j.success("删除成功");break}Q.value="",cA(a.value)}function tA(N,L){let K=L.attrs.class.replace(/icon-\S+/g,`icon-${N}`);L.attrs.class=K}function R(N){const L=N.file,K=y(a.value,N.element.xpath);if(r.uploadByFile)r.uploadByFile(L).then(Y=>{Y.success&&(K.attrs.src=Y.file.url,f.value=new Date().getTime().toString())});else{K.attrs.alt=L.name;const Y=URL.createObjectURL(L);K.attrs.src=Y,f.value=new Date().getTime().toString()}}function P(N){const{icon:L}=N,K=y(a.value,N.element.xpath);let Y=K.attrs.class.replace(/icon-\S+/g,`icon-${L}`);K.attrs.class=Y,f.value=new Date().getTime().toString()}const z=N=>N.type.startsWith("image/")?!0:(j.error("只能上传图片文件"),!1),rA=l.ref({});function lA(N,L){if(!N||N.length===0)return;const K=N[0];if(L.rule&&(L.rule.minImageWidth||L.rule.maxImageHeight)){if(L.rule.minImageWidth&&K.width<L.rule.minImageWidth){j.error(`图片宽度不能小于 ${L.rule.minImageWidth}px`);return}if(L.rule.maxImageHeight&&K.height<L.rule.maxImageHeight){j.error(`图片高度不能小于 ${L.rule.maxImageHeight}px`);return}}L.rule.minImageWidth&&L.rule.maxImageHeight?(rA.value.width=L.rule.minImageWidth,rA.value.height=L.rule.maxImageHeight,rA.value.aspectRatio=L.rule.minImageWidth/L.rule.maxImageHeight):rA.value={},K&&(L.rule.crop?(K.thumbUrl,h.value.handleOpenCropper(rA.value,K.file,K.name,L)):r.uploadByFile?r.uploadByFile(K.file).then(Y=>{Y.success&&(L.attrs.src=Y.file.url,f.value=new Date().getTime().toString())}):(L.attrs.src=K.thumbUrl,f.value=new Date().getTime().toString()))}const UA=l.ref(r.previewWidth),HA=l.ref(360);let RA=l.ref(!1),QA=l.ref(""),PA=0,wA=0;function ce(N){QA.value=N,RA.value=!0,PA=event.clientX,N==="preview"?wA=UA.value:N==="structure"&&(wA=HA.value),window.addEventListener("mousemove",We),window.addEventListener("mouseup",Gl)}function We(N){if(!RA.value)return;const L=N.clientX-PA;QA.value==="preview"?UA.value=Math.max(200,wA+L):QA.value==="structure"&&(HA.value=Math.max(200,wA-L))}function Gl(){RA.value=!1,QA.value="",window.removeEventListener("mousemove",We),window.removeEventListener("mouseup",Gl)}return e({generateCover:I}),(N,L)=>(l.openBlock(),l.createElementBlock("div",Kb,[N.preview?(l.openBlock(),l.createElementBlock("div",{key:0,class:"border-l overflow-auto resize-area",style:l.normalizeStyle({width:UA.value+"px"})},[N.showTitle?(l.openBlock(),l.createElementBlock("div",Vb,[l.createElementVNode("h2",Gb,[L[3]||(L[3]=l.createTextVNode(" 实时预览 ")),l.createElementVNode("span",Yb,l.toDisplayString(UA.value)+"px",1)]),l.createElementVNode("div",{onClick:L[0]||(L[0]=()=>I()),class:"p-2 cursor-pointer text-blue-500"}," 封面 ")])):l.createCommentVNode("",!0),l.createElementVNode("div",null,[o.value?(l.openBlock(),l.createBlock(Kl,{key:0,"css-files":N.css,"js-files":N.js,"html-content":o.value,class:"gp-designer-preview",ref_key:"previewRef",ref:m},null,8,["css-files","js-files","html-content"])):(l.openBlock(),l.createBlock(Kl,{key:1,"css-files":N.css,"js-files":N.js,"html-content":l.unref(u)("body").html(),class:"gp-designer-preview",ref_key:"previewRef",ref:m},null,8,["css-files","js-files","html-content"]))])],4)):l.createCommentVNode("",!0),N.preview?(l.openBlock(),l.createElementBlock("div",{key:1,class:"resizer",onMousedown:L[1]||(L[1]=K=>ce("preview"))},null,32)):l.createCommentVNode("",!0),l.createElementVNode("div",Xb,[N.showTitle?(l.openBlock(),l.createElementBlock("h2",Wb,"结构渲染")):l.createCommentVNode("",!0),l.createElementVNode("div",Jb,[a.value?(l.openBlock(),l.createBlock(sE,{key:0,"upload-by-file":N.uploadByFile,cropper:h.value,icon:d.value,upload:C.value,mode:N.mode,icons:N.icons,r:f.value,element:a.value,selectedElement:T.value,hoveredElement:F.value,onSelectElement:H,onHoverElement:M,onContentUpdated:k,onUpdateText:oA,onBlockAction:W,onAddIcon:tA},null,8,["upload-by-file","cropper","icon","upload","mode","icons","r","element","selectedElement","hoveredElement"])):l.createCommentVNode("",!0)])]),c.value=="design"?(l.openBlock(),l.createElementBlock("div",{key:2,class:"resizer",onMousedown:L[2]||(L[2]=K=>ce("structure"))},null,32)):l.createCommentVNode("",!0),c.value=="design"?(l.openBlock(),l.createElementBlock("div",{key:3,class:"resize-area",style:l.normalizeStyle({width:HA.value+"px"})},[l.createElementVNode("div",qb,[N.showTitle?(l.openBlock(),l.createElementBlock("h2",jb,[L[4]||(L[4]=l.createTextVNode(" 节点属性 ")),l.createElementVNode("span",Zb,l.toDisplayString(HA.value)+"px",1)])):l.createCommentVNode("",!0),l.createElementVNode("div",$b,[T.value?(l.openBlock(),l.createBlock(RE,{key:0,element:T.value,onUpdateElement:v},null,8,["element"])):l.createCommentVNode("",!0)])])],4)):l.createCommentVNode("",!0),l.createVNode(Jp,{ref_key:"cropperRef",ref:h,onOk:R},null,512),l.createVNode(sm,{icons:N.icons,ref_key:"iconRef",ref:d,onOk:P},null,8,["icons"]),l.createVNode(dm,{ref_key:"uploadRef",ref:C,multiple:!1,show:!1,beforeUpload:z,onChange:lA},{"upload-icon":l.withCtx(()=>L[5]||(L[5]=[l.createElementVNode("div",{class:"p-2"},"上传",-1)])),_:1},512)]))}}),[["__scopeId","data-v-9d28b506"]]),zb={install(A){A.component("Designer",Vl)}};Ie.Designer=Vl,Ie.default=zb,Object.defineProperties(Ie,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});