@oddbird/css-anchor-positioning
Version:
Polyfill for the proposed CSS anchor positioning spec
18 lines • 127 kB
JavaScript
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();const Xe=Math.min,Mt=Math.max,me=Math.round,re=Math.floor,ht=t=>({x:t,y:t});function mo(t,e){return typeof t=="function"?t(e):t}function yo(t){return{top:0,right:0,bottom:0,left:0,...t}}function So(t){return typeof t!="number"?yo(t):{top:t,right:t,bottom:t,left:t}}function ye(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}async function ko(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:a,elements:l,strategy:u}=t,{boundary:o="clippingAncestors",rootBoundary:c="viewport",elementContext:h="floating",altBoundary:g=!1,padding:p=0}=mo(e,t),m=So(p),w=l[g?h==="floating"?"reference":"floating":h],S=ye(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:o,rootBoundary:c,strategy:u})),v=h==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),x=await(s.isElement==null?void 0:s.isElement(A))?await(s.getScale==null?void 0:s.getScale(A))||{x:1,y:1}:{x:1,y:1},$=ye(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:A,strategy:u}):v);return{top:(S.top-$.top+m.top)/x.y,bottom:($.bottom-S.bottom+m.bottom)/x.y,left:(S.left-$.left+m.left)/x.x,right:($.right-S.right+m.right)/x.x}}function we(){return typeof window<"u"}function Gt(t){return Nr(t)?(t.nodeName||"").toLowerCase():"#document"}function Z(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function pt(t){var e;return(e=(Nr(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Nr(t){return we()?t instanceof Node||t instanceof Z(t).Node:!1}function rt(t){return we()?t instanceof Element||t instanceof Z(t).Element:!1}function ft(t){return we()?t instanceof HTMLElement||t instanceof Z(t).HTMLElement:!1}function wn(t){return!we()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Z(t).ShadowRoot}function ne(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=it(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(i)}function bo(t){return["table","td","th"].includes(Gt(t))}function Ae(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function fn(t){const e=pn(),n=rt(t)?it(t):t;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Co(t){let e=vt(t);for(;ft(e)&&!Wt(e);){if(fn(e))return e;if(Ae(e))return null;e=vt(e)}return null}function pn(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Wt(t){return["html","body","#document"].includes(Gt(t))}function it(t){return Z(t).getComputedStyle(t)}function Le(t){return rt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function vt(t){if(Gt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||wn(t)&&t.host||pt(t);return wn(e)?e.host:e}function Rr(t){const e=vt(t);return Wt(e)?t.ownerDocument?t.ownerDocument.body:t.body:ft(e)&&ne(e)?e:Rr(e)}function Zt(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=Rr(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),a=Z(i);if(s){const l=Je(a);return e.concat(a,a.visualViewport||[],ne(i)?i:[],l&&n?Zt(l):[])}return e.concat(i,Zt(i,[],n))}function Je(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Dr(t){const e=it(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=ft(t),s=i?t.offsetWidth:n,a=i?t.offsetHeight:r,l=me(n)!==s||me(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function dn(t){return rt(t)?t:t.contextElement}function jt(t){const e=dn(t);if(!ft(e))return ht(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=Dr(e);let a=(s?me(n.width):n.width)/r,l=(s?me(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const vo=ht(0);function Fr(t){const e=Z(t);return!pn()||!e.visualViewport?vo:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function xo(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Z(t)?!1:e}function _t(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=dn(t);let a=ht(1);e&&(r?rt(r)&&(a=jt(r)):a=jt(t));const l=xo(s,n,r)?Fr(s):ht(0);let u=(i.left+l.x)/a.x,o=(i.top+l.y)/a.y,c=i.width/a.x,h=i.height/a.y;if(s){const g=Z(s),p=r&&rt(r)?Z(r):r;let m=g,C=Je(m);for(;C&&r&&p!==m;){const w=jt(C),S=C.getBoundingClientRect(),v=it(C),A=S.left+(C.clientLeft+parseFloat(v.paddingLeft))*w.x,x=S.top+(C.clientTop+parseFloat(v.paddingTop))*w.y;u*=w.x,o*=w.y,c*=w.x,h*=w.y,u+=A,o+=x,m=Z(C),C=Je(m)}}return ye({width:c,height:h,x:u,y:o})}function gn(t,e){const n=Le(t).scrollLeft;return e?e.left+n:_t(pt(t)).left+n}function Mr(t,e,n){n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=r.left+e.scrollLeft-(n?0:gn(t,r)),s=r.top+e.scrollTop;return{x:i,y:s}}function wo(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",a=pt(r),l=e?Ae(e.floating):!1;if(r===a||l&&s)return n;let u={scrollLeft:0,scrollTop:0},o=ht(1);const c=ht(0),h=ft(r);if((h||!h&&!s)&&((Gt(r)!=="body"||ne(a))&&(u=Le(r)),ft(r))){const p=_t(r);o=jt(r),c.x=p.x+r.clientLeft,c.y=p.y+r.clientTop}const g=a&&!h&&!s?Mr(a,u,!0):ht(0);return{width:n.width*o.x,height:n.height*o.y,x:n.x*o.x-u.scrollLeft*o.x+c.x+g.x,y:n.y*o.y-u.scrollTop*o.y+c.y+g.y}}function Ao(t){return Array.from(t.getClientRects())}function Lo(t){const e=pt(t),n=Le(t),r=t.ownerDocument.body,i=Mt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Mt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+gn(t);const l=-n.scrollTop;return it(r).direction==="rtl"&&(a+=Mt(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:l}}function To(t,e){const n=Z(t),r=pt(t),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,l=0,u=0;if(i){s=i.width,a=i.height;const o=pn();(!o||o&&e==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}return{width:s,height:a,x:l,y:u}}function _o(t,e){const n=_t(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=ft(t)?jt(t):ht(1),a=t.clientWidth*s.x,l=t.clientHeight*s.y,u=i*s.x,o=r*s.y;return{width:a,height:l,x:u,y:o}}function An(t,e,n){let r;if(e==="viewport")r=To(t,n);else if(e==="document")r=Lo(pt(t));else if(rt(e))r=_o(e,n);else{const i=Fr(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return ye(r)}function jr(t,e){const n=vt(t);return n===e||!rt(n)||Wt(n)?!1:it(n).position==="fixed"||jr(n,e)}function Eo(t,e){const n=e.get(t);if(n)return n;let r=Zt(t,[],!1).filter(l=>rt(l)&&Gt(l)!=="body"),i=null;const s=it(t).position==="fixed";let a=s?vt(t):t;for(;rt(a)&&!Wt(a);){const l=it(a),u=fn(a);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||ne(a)&&!u&&jr(t,a))?r=r.filter(c=>c!==a):i=l,a=vt(a)}return e.set(t,r),r}function Oo(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const a=[...n==="clippingAncestors"?Ae(e)?[]:Eo(e,this._c):[].concat(n),r],l=a[0],u=a.reduce((o,c)=>{const h=An(e,c,i);return o.top=Mt(h.top,o.top),o.right=Xe(h.right,o.right),o.bottom=Xe(h.bottom,o.bottom),o.left=Mt(h.left,o.left),o},An(e,l,i));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function $o(t){const{width:e,height:n}=Dr(t);return{width:e,height:n}}function Po(t,e,n){const r=ft(e),i=pt(e),s=n==="fixed",a=_t(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const u=ht(0);function o(){u.x=gn(i)}if(r||!r&&!s)if((Gt(e)!=="body"||ne(i))&&(l=Le(e)),r){const p=_t(e,!0,s,e);u.x=p.x+e.clientLeft,u.y=p.y+e.clientTop}else i&&o();s&&!r&&i&&o();const c=i&&!r&&!s?Mr(i,l):ht(0),h=a.left+l.scrollLeft-u.x-c.x,g=a.top+l.scrollTop-u.y-c.y;return{x:h,y:g,width:a.width,height:a.height}}function _e(t){return it(t).position==="static"}function Ln(t,e){if(!ft(t)||it(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return pt(t)===n&&(n=n.ownerDocument.body),n}function Br(t,e){const n=Z(t);if(Ae(t))return n;if(!ft(t)){let i=vt(t);for(;i&&!Wt(i);){if(rt(i)&&!_e(i))return i;i=vt(i)}return n}let r=Ln(t,e);for(;r&&bo(r)&&_e(r);)r=Ln(r,e);return r&&Wt(r)&&_e(r)&&!fn(r)?n:r||Co(t)||n}const Io=async function(t){const e=this.getOffsetParent||Br,n=this.getDimensions,r=await n(t.floating);return{reference:Po(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function No(t){return it(t).direction==="rtl"}const z={convertOffsetParentRelativeRectToViewportRelativeRect:wo,getDocumentElement:pt,getClippingRect:Oo,getOffsetParent:Br,getElementRects:Io,getClientRects:Ao,getDimensions:$o,getScale:jt,isElement:rt,isRTL:No};function Wr(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ro(t,e){let n=null,r;const i=pt(t);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),s();const o=t.getBoundingClientRect(),{left:c,top:h,width:g,height:p}=o;if(l||e(),!g||!p)return;const m=re(h),C=re(i.clientWidth-(c+g)),w=re(i.clientHeight-(h+p)),S=re(c),A={rootMargin:-m+"px "+-C+"px "+-w+"px "+-S+"px",threshold:Mt(0,Xe(1,u))||1};let x=!0;function $(O){const L=O[0].intersectionRatio;if(L!==u){if(!x)return a();L?a(!1,L):r=setTimeout(()=>{a(!1,1e-7)},1e3)}L===1&&!Wr(o,t.getBoundingClientRect())&&a(),x=!1}try{n=new IntersectionObserver($,{...A,root:i.ownerDocument})}catch{n=new IntersectionObserver($,A)}n.observe(t)}return a(!0),s}function Ze(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,o=dn(t),c=i||s?[...o?Zt(o):[],...Zt(e)]:[];c.forEach(S=>{i&&S.addEventListener("scroll",n,{passive:!0}),s&&S.addEventListener("resize",n)});const h=o&&l?Ro(o,n):null;let g=-1,p=null;a&&(p=new ResizeObserver(S=>{let[v]=S;v&&v.target===o&&p&&(p.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var A;(A=p)==null||A.observe(e)})),n()}),o&&!u&&p.observe(o),p.observe(e));let m,C=u?_t(t):null;u&&w();function w(){const S=_t(t);C&&!Wr(C,S)&&n(),C=S,m=requestAnimationFrame(w)}return n(),()=>{var S;c.forEach(v=>{i&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),h==null||h(),(S=p)==null||S.disconnect(),p=null,u&&cancelAnimationFrame(m)}}const Do=ko,{hasOwnProperty:mn}=Object.prototype,Qt=function(){};function Tn(t){return typeof t=="function"?t:Qt}function _n(t,e){return function(n,r,i){n.type===e&&t.call(this,n,r,i)}}function Fo(t,e){const n=e.structure,r=[];for(const i in n){if(mn.call(n,i)===!1)continue;let s=n[i];const a={name:i,type:!1,nullable:!1};Array.isArray(s)||(s=[s]);for(const l of s)l===null?a.nullable=!0:typeof l=="string"?a.type="node":Array.isArray(l)&&(a.type="list");a.type&&r.push(a)}return r.length?{context:e.walkContext,fields:r}:null}function Mo(t){const e={};for(const n in t.node)if(mn.call(t.node,n)){const r=t.node[n];if(!r.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");e[n]=Fo(n,r)}return e}function En(t,e){const n=t.fields.slice(),r=t.context,i=typeof r=="string";return e&&n.reverse(),function(s,a,l,u){let o;i&&(o=a[r],a[r]=s);for(const c of n){const h=s[c.name];if(!c.nullable||h){if(c.type==="list"){if(e?h.reduceRight(u,!1):h.reduce(u,!1))return!0}else if(l(h))return!0}}i&&(a[r]=o)}}function On({StyleSheet:t,Atrule:e,Rule:n,Block:r,DeclarationList:i}){return{Atrule:{StyleSheet:t,Atrule:e,Rule:n,Block:r},Rule:{StyleSheet:t,Atrule:e,Rule:n,Block:r},Declaration:{StyleSheet:t,Atrule:e,Rule:n,Block:r,DeclarationList:i}}}function jo(t){const e=Mo(t),n={},r={},i=Symbol("break-walk"),s=Symbol("skip-node");for(const o in e)mn.call(e,o)&&e[o]!==null&&(n[o]=En(e[o],!1),r[o]=En(e[o],!0));const a=On(n),l=On(r),u=function(o,c){function h(S,v,A){const x=g.call(w,S,v,A);return x===i?!0:x===s?!1:!!(m.hasOwnProperty(S.type)&&m[S.type](S,w,h,C)||p.call(w,S,v,A)===i)}let g=Qt,p=Qt,m=n,C=(S,v,A,x)=>S||h(v,A,x);const w={break:i,skip:s,root:o,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof c=="function")g=c;else if(c&&(g=Tn(c.enter),p=Tn(c.leave),c.reverse&&(m=r),c.visit)){if(a.hasOwnProperty(c.visit))m=c.reverse?l[c.visit]:a[c.visit];else if(!e.hasOwnProperty(c.visit))throw new Error("Bad value `"+c.visit+"` for `visit` option (should be: "+Object.keys(e).sort().join(", ")+")");g=_n(g,c.visit),p=_n(p,c.visit)}if(g===Qt&&p===Qt)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");h(o)};return u.break=i,u.skip=s,u.find=function(o,c){let h=null;return u(o,function(g,p,m){if(c.call(this,g,p,m))return h=g,i}),h},u.findLast=function(o,c){let h=null;return u(o,{reverse:!0,enter(g,p,m){if(c.call(this,g,p,m))return h=g,i}}),h},u.findAll=function(o,c){const h=[];return u(o,function(g,p,m){c.call(this,g,p,m)&&h.push(g)}),h},u}const St=0,b=1,P=2,W=3,D=4,mt=5,Bo=6,H=7,et=8,N=9,_=10,M=11,I=12,j=13,Te=14,Y=15,q=16,K=17,ot=18,qt=19,te=20,R=21,T=22,st=23,zt=24,G=25,Wo=0;function J(t){return t>=48&&t<=57}function Ut(t){return J(t)||t>=65&&t<=70||t>=97&&t<=102}function yn(t){return t>=65&&t<=90}function zo(t){return t>=97&&t<=122}function Uo(t){return yn(t)||zo(t)}function Vo(t){return t>=128}function Se(t){return Uo(t)||Vo(t)||t===95}function zr(t){return Se(t)||J(t)||t===45}function Ho(t){return t>=0&&t<=8||t===11||t>=14&&t<=31||t===127}function ke(t){return t===10||t===13||t===12}function Et(t){return ke(t)||t===32||t===9}function ut(t,e){return!(t!==92||ke(e)||e===Wo)}function Ee(t,e,n){return t===45?Se(e)||e===45||ut(e,n):Se(t)?!0:t===92?ut(t,e):!1}function Oe(t,e,n){return t===43||t===45?J(e)?2:e===46&&J(n)?3:0:t===46?J(e)?2:0:J(t)?1:0}function Ur(t){return t===65279||t===65534?1:0}const tn=new Array(128),Go=128,he=130,Vr=131,Sn=132,Hr=133;for(let t=0;t<tn.length;t++)tn[t]=Et(t)&&he||J(t)&&Vr||Se(t)&&Sn||Ho(t)&&Hr||t||Go;function $e(t){return t<128?tn[t]:Sn}function Bt(t,e){return e<t.length?t.charCodeAt(e):0}function en(t,e,n){return n===13&&Bt(t,e+1)===10?2:1}function Gr(t,e,n){let r=t.charCodeAt(e);return yn(r)&&(r=r|32),r===n}function be(t,e,n,r){if(n-e!==r.length||e<0||n>t.length)return!1;for(let i=e;i<n;i++){const s=r.charCodeAt(i-e);let a=t.charCodeAt(i);if(yn(a)&&(a=a|32),a!==s)return!1}return!0}function qo(t,e){for(;e>=0&&Et(t.charCodeAt(e));e--);return e+1}function ie(t,e){for(;e<t.length&&Et(t.charCodeAt(e));e++);return e}function Pe(t,e){for(;e<t.length&&J(t.charCodeAt(e));e++);return e}function Vt(t,e){if(e+=2,Ut(Bt(t,e-1))){for(const r=Math.min(t.length,e+5);e<r&&Ut(Bt(t,e));e++);const n=Bt(t,e);Et(n)&&(e+=en(t,e,n))}return e}function se(t,e){for(;e<t.length;e++){const n=t.charCodeAt(e);if(!zr(n)){if(ut(n,Bt(t,e+1))){e=Vt(t,e)-1;continue}break}}return e}function qr(t,e){let n=t.charCodeAt(e);if((n===43||n===45)&&(n=t.charCodeAt(e+=1)),J(n)&&(e=Pe(t,e+1),n=t.charCodeAt(e)),n===46&&J(t.charCodeAt(e+1))&&(e+=2,e=Pe(t,e)),Gr(t,e,101)){let r=0;n=t.charCodeAt(e+1),(n===45||n===43)&&(r=1,n=t.charCodeAt(e+2)),J(n)&&(e=Pe(t,e+1+r+1))}return e}function Ie(t,e){for(;e<t.length;e++){const n=t.charCodeAt(e);if(n===41){e++;break}ut(n,Bt(t,e+1))&&(e=Vt(t,e))}return e}function Qr(t){if(t.length===1&&!Ut(t.charCodeAt(0)))return t[0];let e=parseInt(t,16);return(e===0||e>=55296&&e<=57343||e>1114111)&&(e=65533),String.fromCodePoint(e)}const Kr=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"],Qo=16*1024;function Ce(t=null,e){return t===null||t.length<e?new Uint32Array(Math.max(e+1024,Qo)):t}const $n=10,Ko=12,Pn=13;function In(t){const e=t.source,n=e.length,r=e.length>0?Ur(e.charCodeAt(0)):0,i=Ce(t.lines,n),s=Ce(t.columns,n);let a=t.startLine,l=t.startColumn;for(let u=r;u<n;u++){const o=e.charCodeAt(u);i[u]=a,s[u]=l++,(o===$n||o===Pn||o===Ko)&&(o===Pn&&u+1<n&&e.charCodeAt(u+1)===$n&&(u++,i[u]=a,s[u]=l),a++,l=1)}i[n]=a,s[n]=l,t.lines=i,t.columns=s,t.computed=!0}class Yo{constructor(e,n,r,i){this.setSource(e,n,r,i),this.lines=null,this.columns=null}setSource(e="",n=0,r=1,i=1){this.source=e,this.startOffset=n,this.startLine=r,this.startColumn=i,this.computed=!1}getLocation(e,n){return this.computed||In(this),{source:n,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,n,r){return this.computed||In(this),{source:r,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+n,line:this.lines[n],column:this.columns[n]}}}}const at=16777215,lt=24,Ot=new Uint8Array(32);Ot[P]=T;Ot[R]=T;Ot[qt]=te;Ot[st]=zt;function Nn(t){return Ot[t]!==0}class Xo{constructor(e,n){this.setSource(e,n)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(e="",n=()=>{}){e=String(e||"");const r=e.length,i=Ce(this.offsetAndType,e.length+1),s=Ce(this.balance,e.length+1);let a=0,l=-1,u=0,o=e.length;this.offsetAndType=null,this.balance=null,s.fill(0),n(e,(c,h,g)=>{const p=a++;if(i[p]=c<<lt|g,l===-1&&(l=h),s[p]=o,c===u){const m=s[o];s[o]=p,o=m,u=Ot[i[m]>>lt]}else Nn(c)&&(o=p,u=Ot[c])}),i[a]=St<<lt|r,s[a]=a;for(let c=0;c<a;c++){const h=s[c];if(h<=c){const g=s[h];g!==c&&(s[c]=g)}else h>a&&(s[c]=a)}this.source=e,this.firstCharOffset=l===-1?0:l,this.tokenCount=a,this.offsetAndType=i,this.balance=s,this.reset(),this.next()}lookupType(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e]>>lt:St}lookupTypeNonSC(e){for(let n=this.tokenIndex;n<this.tokenCount;n++){const r=this.offsetAndType[n]>>lt;if(r!==j&&r!==G&&e--===0)return r}return St}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&at:this.source.length}lookupOffsetNonSC(e){for(let n=this.tokenIndex;n<this.tokenCount;n++){const r=this.offsetAndType[n]>>lt;if(r!==j&&r!==G&&e--===0)return n-this.tokenIndex}return St}lookupValue(e,n){return e+=this.tokenIndex,e<this.tokenCount?be(this.source,this.offsetAndType[e-1]&at,this.offsetAndType[e]&at,n):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&at:this.offsetAndType[this.tokenCount]&at:this.firstCharOffset}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBalanceEdge(e){return this.balance[this.tokenIndex]<e}isDelim(e,n){return n?this.lookupType(n)===N&&this.source.charCodeAt(this.lookupOffset(n))===e:this.tokenType===N&&this.source.charCodeAt(this.tokenStart)===e}skip(e){let n=this.tokenIndex+e;n<this.tokenCount?(this.tokenIndex=n,this.tokenStart=this.offsetAndType[n-1]&at,n=this.offsetAndType[n],this.tokenType=n>>lt,this.tokenEnd=n&at):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>lt,this.tokenEnd=e&at):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=St,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===j||this.tokenType===G;)this.next()}skipUntilBalanced(e,n){let r=e,i=0,s=0;t:for(;r<this.tokenCount;r++){if(i=this.balance[r],i<e)break t;switch(s=r>0?this.offsetAndType[r-1]&at:this.firstCharOffset,n(this.source.charCodeAt(s))){case 1:break t;case 2:r++;break t;default:Nn(this.offsetAndType[r]>>lt)&&(r=i)}}this.skip(r-this.tokenIndex)}forEachToken(e){for(let n=0,r=this.firstCharOffset;n<this.tokenCount;n++){const i=r,s=this.offsetAndType[n],a=s&at,l=s>>lt;r=a,e(l,i,a,n)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((n,r,i,s)=>{e[s]={idx:s,type:Kr[n],chunk:this.source.substring(r,i),balance:this.balance[s]}}),e}}function Yr(t,e){function n(h){return h<l?t.charCodeAt(h):0}function r(){if(o=qr(t,o),Ee(n(o),n(o+1),n(o+2))){c=I,o=se(t,o);return}if(n(o)===37){c=M,o++;return}c=_}function i(){const h=o;if(o=se(t,o),be(t,h,o,"url")&&n(o)===40){if(o=ie(t,o+1),n(o)===34||n(o)===39){c=P,o=h+4;return}a();return}if(n(o)===40){c=P,o++;return}c=b}function s(h){for(h||(h=n(o++)),c=mt;o<t.length;o++){const g=t.charCodeAt(o);switch($e(g)){case h:o++;return;case he:if(ke(g)){o+=en(t,o,g),c=Bo;return}break;case 92:if(o===t.length-1)break;const p=n(o+1);ke(p)?o+=en(t,o+1,p):ut(g,p)&&(o=Vt(t,o)-1);break}}}function a(){for(c=H,o=ie(t,o);o<t.length;o++){const h=t.charCodeAt(o);switch($e(h)){case 41:o++;return;case he:if(o=ie(t,o),n(o)===41||o>=t.length){o<t.length&&o++;return}o=Ie(t,o),c=et;return;case 34:case 39:case 40:case Hr:o=Ie(t,o),c=et;return;case 92:if(ut(h,n(o+1))){o=Vt(t,o)-1;break}o=Ie(t,o),c=et;return}}}t=String(t||"");const l=t.length;let u=Ur(n(0)),o=u,c;for(;o<l;){const h=t.charCodeAt(o);switch($e(h)){case he:c=j,o=ie(t,o+1);break;case 34:s();break;case 35:zr(n(o+1))||ut(n(o+1),n(o+2))?(c=D,o=se(t,o+1)):(c=N,o++);break;case 39:s();break;case 40:c=R,o++;break;case 41:c=T,o++;break;case 43:Oe(h,n(o+1),n(o+2))?r():(c=N,o++);break;case 44:c=ot,o++;break;case 45:Oe(h,n(o+1),n(o+2))?r():n(o+1)===45&&n(o+2)===62?(c=Y,o=o+3):Ee(h,n(o+1),n(o+2))?i():(c=N,o++);break;case 46:Oe(h,n(o+1),n(o+2))?r():(c=N,o++);break;case 47:n(o+1)===42?(c=G,o=t.indexOf("*/",o+2),o=o===-1?t.length:o+2):(c=N,o++);break;case 58:c=q,o++;break;case 59:c=K,o++;break;case 60:n(o+1)===33&&n(o+2)===45&&n(o+3)===45?(c=Te,o=o+4):(c=N,o++);break;case 64:Ee(n(o+1),n(o+2),n(o+3))?(c=W,o=se(t,o+1)):(c=N,o++);break;case 91:c=qt,o++;break;case 92:ut(h,n(o+1))?i():(c=N,o++);break;case 93:c=te,o++;break;case 123:c=st,o++;break;case 125:c=zt,o++;break;case Vr:r();break;case Sn:i();break;default:c=N,o++}e(c,u,u=o)}}const ct=43,X=45,fe=110,At=!0,Jo=!1;function pe(t,e){let n=this.tokenStart+t;const r=this.charCodeAt(n);for((r===ct||r===X)&&(e&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)J(this.charCodeAt(n))||this.error("Integer is expected",n)}function Dt(t){return pe.call(this,0,t)}function yt(t,e){if(!this.cmpChar(this.tokenStart+t,e)){let n="";switch(e){case fe:n="N is expected";break;case X:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+t)}}function Ne(){let t=0,e=0,n=this.tokenType;for(;n===j||n===G;)n=this.lookupType(++t);if(n!==_)if(this.isDelim(ct,t)||this.isDelim(X,t)){e=this.isDelim(ct,t)?ct:X;do n=this.lookupType(++t);while(n===j||n===G);n!==_&&(this.skip(t),Dt.call(this,At))}else return null;return t>0&&this.skip(t),e===0&&(n=this.charCodeAt(this.tokenStart),n!==ct&&n!==X&&this.error("Number sign is expected")),Dt.call(this,e!==0),e===X?"-"+this.consume(_):this.consume(_)}const Zo="AnPlusB",ta={a:[String,null],b:[String,null]};function Xr(){const t=this.tokenStart;let e=null,n=null;if(this.tokenType===_)Dt.call(this,Jo),n=this.consume(_);else if(this.tokenType===b&&this.cmpChar(this.tokenStart,X))switch(e="-1",yt.call(this,1,fe),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Ne.call(this);break;case 3:yt.call(this,2,X),this.next(),this.skipSC(),Dt.call(this,At),n="-"+this.consume(_);break;default:yt.call(this,2,X),pe.call(this,3,At),this.next(),n=this.substrToCursor(t+2)}else if(this.tokenType===b||this.isDelim(ct)&&this.lookupType(1)===b){let r=0;switch(e="1",this.isDelim(ct)&&(r=1,this.next()),yt.call(this,0,fe),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Ne.call(this);break;case 2:yt.call(this,1,X),this.next(),this.skipSC(),Dt.call(this,At),n="-"+this.consume(_);break;default:yt.call(this,1,X),pe.call(this,2,At),this.next(),n=this.substrToCursor(t+r+1)}}else if(this.tokenType===I){const r=this.charCodeAt(this.tokenStart),i=r===ct||r===X;let s=this.tokenStart+i;for(;s<this.tokenEnd&&J(this.charCodeAt(s));s++);s===this.tokenStart+i&&this.error("Integer is expected",this.tokenStart+i),yt.call(this,s-this.tokenStart,fe),e=this.substring(t,s),s+1===this.tokenEnd?(this.next(),n=Ne.call(this)):(yt.call(this,s-this.tokenStart+1,X),s+2===this.tokenEnd?(this.next(),this.skipSC(),Dt.call(this,At),n="-"+this.consume(_)):(pe.call(this,s-this.tokenStart+2,At),this.next(),n=this.substrToCursor(s+1)))}else this.error();return e!==null&&e.charCodeAt(0)===ct&&(e=e.substr(1)),n!==null&&n.charCodeAt(0)===ct&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(t,this.tokenStart),a:e,b:n}}function Jr(t){if(t.a){const e=t.a==="+1"&&"n"||t.a==="1"&&"n"||t.a==="-1"&&"-n"||t.a+"n";if(t.b){const n=t.b[0]==="-"||t.b[0]==="+"?t.b:"+"+t.b;this.tokenize(e+n)}else this.tokenize(e)}else this.tokenize(t.b)}const ea=Object.freeze(Object.defineProperty({__proto__:null,generate:Jr,name:Zo,parse:Xr,structure:ta},Symbol.toStringTag,{value:"Module"}));function Rn(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function na(){for(let t=1,e;e=this.lookupType(t);t++){if(e===zt)return!0;if(e===st||e===W)return!1}return!1}const ra="Atrule",ia="atrule",sa={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function Zr(t=!1){const e=this.tokenStart;let n,r,i=null,s=null;switch(this.eat(W),n=this.substrToCursor(e+1),r=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==st&&this.tokenType!==K&&(this.parseAtrulePrelude?i=this.parseWithFallback(this.AtrulePrelude.bind(this,n,t),Rn):i=Rn.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case K:this.next();break;case st:hasOwnProperty.call(this.atrule,r)&&typeof this.atrule[r].block=="function"?s=this.atrule[r].block.call(this,t):s=this.Block(na.call(this));break}return{type:"Atrule",loc:this.getLocation(e,this.tokenStart),name:n,prelude:i,block:s}}function ti(t){this.token(W,"@"+t.name),t.prelude!==null&&this.node(t.prelude),t.block?this.node(t.block):this.token(K,";")}const oa=Object.freeze(Object.defineProperty({__proto__:null,generate:ti,name:ra,parse:Zr,structure:sa,walkContext:ia},Symbol.toStringTag,{value:"Module"})),aa="AtrulePrelude",la="atrulePrelude",ca={children:[[]]};function ei(t){let e=null;return t!==null&&(t=t.toLowerCase()),this.skipSC(),hasOwnProperty.call(this.atrule,t)&&typeof this.atrule[t].prelude=="function"?e=this.atrule[t].prelude.call(this):e=this.readSequence(this.scope.AtrulePrelude),this.skipSC(),this.eof!==!0&&this.tokenType!==st&&this.tokenType!==K&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(e),children:e}}function ni(t){this.children(t)}const ua=Object.freeze(Object.defineProperty({__proto__:null,generate:ni,name:aa,parse:ei,structure:ca,walkContext:la},Symbol.toStringTag,{value:"Module"})),ha=36,ri=42,de=61,fa=94,nn=124,pa=126;function da(){this.eof&&this.error("Unexpected end of input");const t=this.tokenStart;let e=!1;return this.isDelim(ri)?(e=!0,this.next()):this.isDelim(nn)||this.eat(b),this.isDelim(nn)?this.charCodeAt(this.tokenStart+1)!==de?(this.next(),this.eat(b)):e&&this.error("Identifier is expected",this.tokenEnd):e&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t)}}function ga(){const t=this.tokenStart,e=this.charCodeAt(t);return e!==de&&e!==pa&&e!==fa&&e!==ha&&e!==ri&&e!==nn&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),e!==de&&(this.isDelim(de)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(t)}const ma="AttributeSelector",ya={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function ii(){const t=this.tokenStart;let e,n=null,r=null,i=null;return this.eat(qt),this.skipSC(),e=da.call(this),this.skipSC(),this.tokenType!==te&&(this.tokenType!==b&&(n=ga.call(this),this.skipSC(),r=this.tokenType===mt?this.String():this.Identifier(),this.skipSC()),this.tokenType===b&&(i=this.consume(b),this.skipSC())),this.eat(te),{type:"AttributeSelector",loc:this.getLocation(t,this.tokenStart),name:e,matcher:n,value:r,flags:i}}function si(t){this.token(N,"["),this.node(t.name),t.matcher!==null&&(this.tokenize(t.matcher),this.node(t.value)),t.flags!==null&&this.token(b,t.flags),this.token(N,"]")}const Sa=Object.freeze(Object.defineProperty({__proto__:null,generate:si,name:ma,parse:ii,structure:ya},Symbol.toStringTag,{value:"Module"})),ka=38;function oi(){return this.Raw(null,!0)}function Dn(){return this.parseWithFallback(this.Rule,oi)}function Fn(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function ba(){if(this.tokenType===K)return Fn.call(this,this.tokenIndex);const t=this.parseWithFallback(this.Declaration,Fn);return this.tokenType===K&&this.next(),t}const Ca="Block",va="block",xa={children:[["Atrule","Rule","Declaration"]]};function ai(t){const e=t?ba:Dn,n=this.tokenStart;let r=this.createList();this.eat(st);t:for(;!this.eof;)switch(this.tokenType){case zt:break t;case j:case G:this.next();break;case W:r.push(this.parseWithFallback(this.Atrule.bind(this,t),oi));break;default:t&&this.isDelim(ka)?r.push(Dn.call(this)):r.push(e.call(this))}return this.eof||this.eat(zt),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function li(t){this.token(st,"{"),this.children(t,e=>{e.type==="Declaration"&&this.token(K,";")}),this.token(zt,"}")}const wa=Object.freeze(Object.defineProperty({__proto__:null,generate:li,name:Ca,parse:ai,structure:xa,walkContext:va},Symbol.toStringTag,{value:"Module"})),Aa="Brackets",La={children:[[]]};function ci(t,e){const n=this.tokenStart;let r=null;return this.eat(qt),r=t.call(this,e),this.eof||this.eat(te),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:r}}function ui(t){this.token(N,"["),this.children(t),this.token(N,"]")}const Ta=Object.freeze(Object.defineProperty({__proto__:null,generate:ui,name:Aa,parse:ci,structure:La},Symbol.toStringTag,{value:"Module"})),_a="CDC",Ea=[];function hi(){const t=this.tokenStart;return this.eat(Y),{type:"CDC",loc:this.getLocation(t,this.tokenStart)}}function fi(){this.token(Y,"-->")}const Oa=Object.freeze(Object.defineProperty({__proto__:null,generate:fi,name:_a,parse:hi,structure:Ea},Symbol.toStringTag,{value:"Module"})),$a="CDO",Pa=[];function pi(){const t=this.tokenStart;return this.eat(Te),{type:"CDO",loc:this.getLocation(t,this.tokenStart)}}function di(){this.token(Te,"<!--")}const Ia=Object.freeze(Object.defineProperty({__proto__:null,generate:di,name:$a,parse:pi,structure:Pa},Symbol.toStringTag,{value:"Module"})),Na=46,Ra="ClassSelector",Da={name:String};function gi(){return this.eatDelim(Na),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(b)}}function mi(t){this.token(N,"."),this.token(b,t.name)}const Fa=Object.freeze(Object.defineProperty({__proto__:null,generate:mi,name:Ra,parse:gi,structure:Da},Symbol.toStringTag,{value:"Module"})),Ma=43,Mn=47,ja=62,Ba=126,Wa="Combinator",za={name:String};function yi(){const t=this.tokenStart;let e;switch(this.tokenType){case j:e=" ";break;case N:switch(this.charCodeAt(this.tokenStart)){case ja:case Ma:case Ba:this.next();break;case Mn:this.next(),this.eatIdent("deep"),this.eatDelim(Mn);break;default:this.error("Combinator is expected")}e=this.substrToCursor(t);break}return{type:"Combinator",loc:this.getLocation(t,this.tokenStart),name:e}}function Si(t){this.tokenize(t.name)}const Ua=Object.freeze(Object.defineProperty({__proto__:null,generate:Si,name:Wa,parse:yi,structure:za},Symbol.toStringTag,{value:"Module"})),Va=42,Ha=47,Ga="Comment",qa={value:String};function ki(){const t=this.tokenStart;let e=this.tokenEnd;return this.eat(G),e-t+2>=2&&this.charCodeAt(e-2)===Va&&this.charCodeAt(e-1)===Ha&&(e-=2),{type:"Comment",loc:this.getLocation(t,this.tokenStart),value:this.substring(t+2,e)}}function bi(t){this.token(G,"/*"+t.value+"*/")}const Qa=Object.freeze(Object.defineProperty({__proto__:null,generate:bi,name:Ga,parse:ki,structure:qa},Symbol.toStringTag,{value:"Module"})),Ka=new Set([q,T,St]),Ya="Condition",Xa={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};function jn(t){return this.lookupTypeNonSC(1)===b&&Ka.has(this.lookupTypeNonSC(2))?this.Feature(t):this.FeatureRange(t)}const Ja={media:jn,container:jn,supports(){return this.SupportsDeclaration()}};function Ci(t="media"){const e=this.createList();t:for(;!this.eof;)switch(this.tokenType){case G:case j:this.next();continue;case b:e.push(this.Identifier());break;case R:{let n=this.parseWithFallback(()=>Ja[t].call(this,t),()=>null);n||(n=this.parseWithFallback(()=>{this.eat(R);const r=this.Condition(t);return this.eat(T),r},()=>this.GeneralEnclosed(t))),e.push(n);break}case P:{let n=this.parseWithFallback(()=>this.FeatureFunction(t),()=>null);n||(n=this.GeneralEnclosed(t)),e.push(n);break}default:break t}return e.isEmpty&&this.error("Condition is expected"),{type:"Condition",loc:this.getLocationFromList(e),kind:t,children:e}}function vi(t){t.children.forEach(e=>{e.type==="Condition"?(this.token(R,"("),this.node(e),this.token(T,")")):this.node(e)})}const Za=Object.freeze(Object.defineProperty({__proto__:null,generate:vi,name:Ya,parse:Ci,structure:Xa},Symbol.toStringTag,{value:"Module"})),Bn=45;function tl(t,e){return e=e||0,t.length-e>=2&&t.charCodeAt(e)===Bn&&t.charCodeAt(e+1)===Bn}const xi=33,el=35,nl=36,rl=38,il=42,sl=43,Wn=47;function ol(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function al(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function ll(){const t=this.tokenIndex,e=this.Value();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==K&&this.isDelim(xi)===!1&&this.isBalanceEdge(t)===!1&&this.error(),e}const cl="Declaration",ul="declaration",hl={important:[Boolean,String],property:String,value:["Value","Raw"]};function wi(){const t=this.tokenStart,e=this.tokenIndex,n=fl.call(this),r=tl(n),i=r?this.parseCustomProperty:this.parseValue,s=r?al:ol;let a=!1,l;this.skipSC(),this.eat(q);const u=this.tokenIndex;if(r||this.skipSC(),i?l=this.parseWithFallback(ll,s):l=s.call(this,this.tokenIndex),r&&l.type==="Value"&&l.children.isEmpty){for(let o=u-this.tokenIndex;o<=0;o++)if(this.lookupType(o)===j){l.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(xi)&&(a=pl.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==K&&this.isBalanceEdge(e)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(t,this.tokenStart),important:a,property:n,value:l}}function Ai(t){this.token(b,t.property),this.token(q,":"),this.node(t.value),t.important&&(this.token(N,"!"),this.token(b,t.important===!0?"important":t.important))}function fl(){const t=this.tokenStart;if(this.tokenType===N)switch(this.charCodeAt(this.tokenStart)){case il:case nl:case sl:case el:case rl:this.next();break;case Wn:this.next(),this.isDelim(Wn)&&this.next();break}return this.tokenType===D?this.eat(D):this.eat(b),this.substrToCursor(t)}function pl(){this.eat(N),this.skipSC();const t=this.consume(b);return t==="important"?!0:t}const dl=Object.freeze(Object.defineProperty({__proto__:null,generate:Ai,name:cl,parse:wi,structure:hl,walkContext:ul},Symbol.toStringTag,{value:"Module"})),gl=38;function Re(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}const ml="DeclarationList",yl={children:[["Declaration","Atrule","Rule"]]};function Li(){const t=this.createList();for(;!this.eof;)switch(this.tokenType){case j:case G:case K:this.next();break;case W:t.push(this.parseWithFallback(this.Atrule.bind(this,!0),Re));break;default:this.isDelim(gl)?t.push(this.parseWithFallback(this.Rule,Re)):t.push(this.parseWithFallback(this.Declaration,Re))}return{type:"DeclarationList",loc:this.getLocationFromList(t),children:t}}function Ti(t){this.children(t,e=>{e.type==="Declaration"&&this.token(K,";")})}const Sl=Object.freeze(Object.defineProperty({__proto__:null,generate:Ti,name:ml,parse:Li,structure:yl},Symbol.toStringTag,{value:"Module"})),kl="Dimension",bl={value:String,unit:String};function _i(){const t=this.tokenStart,e=this.consumeNumber(I);return{type:"Dimension",loc:this.getLocation(t,this.tokenStart),value:e,unit:this.substring(t+e.length,this.tokenStart)}}function Ei(t){this.token(I,t.value+t.unit)}const Cl=Object.freeze(Object.defineProperty({__proto__:null,generate:Ei,name:kl,parse:_i,structure:bl},Symbol.toStringTag,{value:"Module"})),vl=47,xl="Feature",wl={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]};function Oi(t){const e=this.tokenStart;let n,r=null;if(this.eat(R),this.skipSC(),n=this.consume(b),this.skipSC(),this.tokenType!==T){switch(this.eat(q),this.skipSC(),this.tokenType){case _:this.lookupNonWSType(1)===N?r=this.Ratio():r=this.Number();break;case I:r=this.Dimension();break;case b:r=this.Identifier();break;case P:r=this.parseWithFallback(()=>{const i=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(vl)&&this.error(),i},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(T),{type:"Feature",loc:this.getLocation(e,this.tokenStart),kind:t,name:n,value:r}}function $i(t){this.token(R,"("),this.token(b,t.name),t.value!==null&&(this.token(q,":"),this.node(t.value)),this.token(T,")")}const Al=Object.freeze(Object.defineProperty({__proto__:null,generate:$i,name:xl,parse:Oi,structure:wl},Symbol.toStringTag,{value:"Module"})),Ll="FeatureFunction",Tl={kind:String,feature:String,value:["Declaration","Selector"]};function _l(t,e){const r=(this.features[t]||{})[e];return typeof r!="function"&&this.error(`Unknown feature ${e}()`),r}function Pi(t="unknown"){const e=this.tokenStart,n=this.consumeFunctionName(),r=_l.call(this,t,n.toLowerCase());this.skipSC();const i=this.parseWithFallback(()=>{const s=this.tokenIndex,a=r.call(this);return this.eof===!1&&this.isBalanceEdge(s)===!1&&this.error(),a},()=>this.Raw(null,!1));return this.eof||this.eat(T),{type:"FeatureFunction",loc:this.getLocation(e,this.tokenStart),kind:t,feature:n,value:i}}function Ii(t){this.token(P,t.feature+"("),this.node(t.value),this.token(T,")")}const El=Object.freeze(Object.defineProperty({__proto__:null,generate:Ii,name:Ll,parse:Pi,structure:Tl},Symbol.toStringTag,{value:"Module"})),zn=47,Ol=60,Un=61,$l=62,Pl="FeatureRange",Il={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]};function De(){switch(this.skipSC(),this.tokenType){case _:return this.isDelim(zn,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case I:return this.Dimension();case b:return this.Identifier();case P:return this.parseWithFallback(()=>{const t=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(zn)&&this.error(),t},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function Vn(t){if(this.skipSC(),this.isDelim(Ol)||this.isDelim($l)){const e=this.source[this.tokenStart];return this.next(),this.isDelim(Un)?(this.next(),e+"="):e}if(this.isDelim(Un))return"=";this.error(`Expected ${t?'":", ':""}"<", ">", "=" or ")"`)}function Ni(t="unknown"){const e=this.tokenStart;this.skipSC(),this.eat(R);const n=De.call(this),r=Vn.call(this,n.type==="Identifier"),i=De.call(this);let s=null,a=null;return this.lookupNonWSType(0)!==T&&(s=Vn.call(this),a=De.call(this)),this.skipSC(),this.eat(T),{type:"FeatureRange",loc:this.getLocation(e,this.tokenStart),kind:t,left:n,leftComparison:r,middle:i,rightComparison:s,right:a}}function Ri(t){this.token(R,"("),this.node(t.left),this.tokenize(t.leftComparison),this.node(t.middle),t.right&&(this.tokenize(t.rightComparison),this.node(t.right)),this.token(T,")")}const Nl=Object.freeze(Object.defineProperty({__proto__:null,generate:Ri,name:Pl,parse:Ni,structure:Il},Symbol.toStringTag,{value:"Module"})),Rl="Function",Dl="function",Fl={name:String,children:[[]]};function Di(t,e){const n=this.tokenStart,r=this.consumeFunctionName(),i=r.toLowerCase();let s;return s=e.hasOwnProperty(i)?e[i].call(this,e):t.call(this,e),this.eof||this.eat(T),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:r,children:s}}function Fi(t){this.token(P,t.name+"("),this.children(t),this.token(T,")")}const Ml=Object.freeze(Object.defineProperty({__proto__:null,generate:Fi,name:Rl,parse:Di,structure:Fl,walkContext:Dl},Symbol.toStringTag,{value:"Module"})),jl="GeneralEnclosed",Bl={kind:String,function:[String,null],children:[[]]};function Mi(t){const e=this.tokenStart;let n=null;this.tokenType===P?n=this.consumeFunctionName():this.eat(R);const r=this.parseWithFallback(()=>{const i=this.tokenIndex,s=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(i)===!1&&this.error(),s},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(T),{type:"GeneralEnclosed",loc:this.getLocation(e,this.tokenStart),kind:t,function:n,children:r}}function ji(t){t.function?this.token(P,t.function+"("):this.token(R,"("),this.children(t),this.token(T,")")}const Wl=Object.freeze(Object.defineProperty({__proto__:null,generate:ji,name:jl,parse:Mi,structure:Bl},Symbol.toStringTag,{value:"Module"})),zl="XXX",Ul="Hash",Vl={value:String};function Bi(){const t=this.tokenStart;return this.eat(D),{type:"Hash",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t+1)}}function Wi(t){this.token(D,"#"+t.value)}const Hl=Object.freeze(Object.defineProperty({__proto__:null,generate:Wi,name:Ul,parse:Bi,structure:Vl,xxx:zl},Symbol.toStringTag,{value:"Module"})),Gl="Identifier",ql={name:String};function zi(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(b)}}function Ui(t){this.token(b,t.name)}const Ql=Object.freeze(Object.defineProperty({__proto__:null,generate:Ui,name:Gl,parse:zi,structure:ql},Symbol.toStringTag,{value:"Module"})),Kl="IdSelector",Yl={name:String};function Vi(){const t=this.tokenStart;return this.eat(D),{type:"IdSelector",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t+1)}}function Hi(t){this.token(N,"#"+t.name)}const Xl=Object.freeze(Object.defineProperty({__proto__:null,generate:Hi,name:Kl,parse:Vi,structure:Yl},Symbol.toStringTag,{value:"Module"})),Jl=46,Zl="Layer",tc={name:String};function Gi(){let t=this.tokenStart,e=this.consume(b);for(;this.isDelim(Jl);)this.eat(N),e+="."+this.consume(b);return{type:"Layer",loc:this.getLocation(t,this.tokenStart),name:e}}function qi(t){this.tokenize(t.name)}const ec=Object.freeze(Object.defineProperty({__proto__:null,generate:qi,name:Zl,parse:Gi,structure:tc},Symbol.toStringTag,{value:"Module"})),nc="LayerList",rc={children:[["Layer"]]};function Qi(){const t=this.createList();for(this.skipSC();!this.eof&&(t.push(this.Layer()),this.lookupTypeNonSC(0)===ot);)this.skipSC(),this.next(),this.skipSC();return{type:"LayerList",loc:this.getLocationFromList(t),children:t}}function Ki(t){this.children(t,()=>this.token(ot,","))}const ic=Object.freeze(Object.defineProperty({__proto__:null,generate:Ki,name:nc,parse:Qi,structure:rc},Symbol.toStringTag,{value:"Module"})),sc="MediaQuery",oc={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]};function Yi(){const t=this.tokenStart;let e=null,n=null,r=null;if(this.skipSC(),this.tokenType===b&&this.lookupTypeNonSC(1)!==R){const i=this.consume(b),s=i.toLowerCase();switch(s==="not"||s==="only"?(this.skipSC(),e=s,n=this.consume(b)):n=i,this.lookupTypeNonSC(0)){case b:{this.skipSC(),this.eatIdent("and"),r=this.Condition("media");break}case st:case K:case ot:case St:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case b:case R:case P:{r=this.Condition("media");break}case st:case K:case St:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(t,this.tokenStart),modifier:e,mediaType:n,condition:r}}function Xi(t){t.mediaType?(t.modifier&&this.token(b,t.modifier),this.token(b,t.mediaType),t.condition&&(this.token(b,"and"),this.node(t.condition))):t.condition&&this.node(t.condition)}const ac=Object.freeze(Object.defineProperty({__proto__:null,generate:Xi,name:sc,parse:Yi,structure:oc},Symbol.toStringTag,{value:"Module"})),lc="MediaQueryList",cc={children:[["MediaQuery"]]};function Ji(){const t=this.createList();for(this.skipSC();!this.eof&&(t.push(this.MediaQuery()),this.tokenType===ot);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(t),children:t}}function Zi(t){this.children(t,()=>this.token(ot,","))}const uc=Object.freeze(Object.defineProperty({__proto__:null,generate:Zi,name:lc,parse:Ji,structure:cc},Symbol.toStringTag,{value:"Module"})),hc=38,fc="NestingSelector",pc={};function ts(){const t=this.tokenStart;return this.eatDelim(hc),{type:"NestingSelector",loc:this.getLocation(t,this.tokenStart)}}function es(){this.token(N,"&")}const dc=Object.freeze(Object.defineProperty({__proto__:null,generate:es,name:fc,parse:ts,structure:pc},Symbol.toStringTag,{value:"Module"})),gc="Nth",mc={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function ns(){this.skipSC();const t=this.tokenStart;let e=t,n=null,r;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?r=this.Identifier():r=this.AnPlusB(),e=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),n=this.SelectorList(),e=this.tokenStart),{type:"Nth",loc:this.getLocation(t,e),nth:r,selector:n}}function rs(t){this.node(t.nth),t.selector!==null&&(this.token(b,"of"),this.node(t.selector))}const yc=Object.freeze(Object.defineProperty({__proto__:null,generate:rs,name:gc,parse:ns,structure:mc},Symbol.toStringTag,{value:"Module"})),Sc="Number",kc={value:String};function is(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(_)}}function ss(t){this.token(_,t.value)}const bc=Object.freeze(Object.defineProperty({__proto__:null,generate:ss,name:Sc,parse:is,structure:kc},Symbol.toStringTag,{value:"Module"})),Cc="Operator",vc={value:String};function os(){const t=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t)}}function as(t){this.tokenize(t.value)}const xc=Object.freeze(Object.defineProperty({__proto__:null,generate:as,name:Cc,parse:os,structure:vc},Symbol.toStringTag,{value:"Module"})),wc="Parentheses",Ac={children:[[]]};function ls(t,e){const n=this.tokenStart;let r=null;return this.eat(R),r=t.call(this,e),this.eof||this.eat(T),{type:"Parentheses",loc:this.getLocation(n,this.tokenStart),children:r}}function cs(t){this.token(R,"("),this.children(t),this.token(T,")")}const Lc=Object.freeze(Object.defineProperty({__proto__:null,generate:cs,name:wc,parse:ls,structure:Ac},Symbol.toStringTag,{value:"Module"})),Tc="Percentage",_c={value:String};function us(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(M)}}function hs(t){this.token(M,t.value+"%")}const Ec=Object.freeze(Object.defineProperty({__proto__:null,generate:hs,name:Tc,parse:us,structure:_c},Symbol.toStringTag,{value:"Module"})),Oc="PseudoClassSelector",$c="function",Pc={name:String,children:[["Raw"],null]};function fs(){const t=this.tokenStart;let e=null,n,r;return this.eat(q),this.tokenType===P?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==T?e=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),e=this.pseudo[r].call(this),this.skipSC()):(e=this.createList(),e.push(this.Raw(null,!1))),this.eat(T)):n=this.consume(b),{type:"PseudoClassSelector",loc:this.getLocation(t,this.tokenStart),name:n,children:e}}function ps(t){this.token(q,":"),t.children===null?this.token(b,t.name):(this.token(P,t.name+"("),this.children(t),this.token(T,")"))}const Ic=Object.freeze(Object.defineProperty({__proto__:null,generate:ps,name:Oc,parse:fs,structure:Pc,walkContext:$c},Symbol.toStringTag,{value:"Module"})),Nc="PseudoElementSelector",Rc="function",Dc={name:String,children:[["Raw"],null]};function ds(){const t=this.tokenStart;let e=null,n,r;return this.eat(q),this.eat(q),this.tokenType===P?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==T?e=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),e=this.pseudo[r].call(this),this.skipSC()):(e=this.createList(),e.push(this.Raw(null,!1))),this.eat(T)):n=this.consume(b),{type:"PseudoElementSelector",loc:this.getLocation(t,this.tokenStart),name:n,children:e}}function gs(t){this.token(q,":"),this.token(q,":"),t.children===null?this.token(b,t.name):(this.token(P,t.name+"("),this.children(t),this.token(T,")"))}const Fc=Object.freeze(Object.defineProperty({__proto__:null,generate:gs,name:Nc,parse:ds,structure:Dc,walkContext:Rc},Symbol.toStringTag,{value:"Module"})),Hn=47;function Gn(){switch(this.skipSC(),this.tokenType){case _:return this.Number();case P:return this.Function(this.readSequence,this.scope.Value);default:this.error("Number of function is expected")}}const Mc="Ratio",jc={left:["Number","Function"],right:["Number","Function",null]};function ms(){const t=this.tokenStart,e=Gn.call(this);let n=null;return this.skipSC(),this.isDelim(Hn)&&(this.eatDelim(Hn),n=Gn.call(this)),{type:"Ratio",loc:this.getLocation(t,this.tokenStart),left:e,right:n}}function ys(t){this.node(t.left),this.token(N,"/"),t.right?this.node(t.right):this.node(_,1)}const Bc=Object.freeze(Object.defineProperty({__proto__:null,generate:ys,name:Mc,parse:ms,structure:jc},Symbol.toStringTag,{value:"Module"}));function Wc(){return this.tokenIndex>0&&this.lookupType(-1)===j?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}const zc="Raw",Uc={value:String};function Ss(t,e){const n=this.getTokenStart(this.tokenIndex);let r;return this.skipUntilBalanced(this.tokenIndex,t||this.consumeUntilBalanceEnd),e&&this.tokenStart>n?r=Wc.call(this):r=this.tokenStart,{type:"Raw",loc:this.getLocation(n,r),value:this.substring(n,r)}}function ks(t){this.tokenize(t.value)}const Vc=Object.freeze(Object.defineProperty({__proto__:null,generate:ks,name:zc,parse:Ss,structure:Uc},Symbol.toStringTag,{value:"Module"}));function qn(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function Hc(){const t=this.SelectorList();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==st&&this.error(),t}const Gc="Rule",qc="rule",Qc={prelude:["SelectorList","Raw"],block:["Block"]};function bs(){const t=this.tokenIndex,e=this.tokenStart;let n,r;return this.parseRulePrelude?n=this.parseWithFallback(Hc,qn):n=qn.call(this,t),r=this.Block(!0),{type:"Rule",loc:this.getLocation(e,this.tokenStart),prelude:n,block:r}}function Cs(t){this.node(t.prelude),this.node(t.block)}const Kc=Object.freeze(Object.defineProperty({__proto__:null,generate:Cs,name:Gc,parse:bs,structure:Qc,walkContext:qc},Symbol.toStringTag,{value:"Module"})),Yc="Scope",Xc={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]};function vs(){let t=null,e=null;this.skipSC();const n=this.tokenStart;return this.tokenType===R&&(this.next(),this.skipSC(),t=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(T)),this.lookupNonWSType(0)===b&&(this.skipSC(),this.eatIdent("to"),this.skipSC(),this.eat(R),this.skipSC(),e=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(T)),{type:"Scope",loc:this.getLocation(n,this.tokenStart),root:t,limit:e}}function xs(t){t.root&&(this.token(R,"("),this.node(t.root),this.token(T,")")),t.limit&&(this.token(b,"to"),this.token(R,"("),this.node(t.limit),this.token(T,")"))}const Jc=Object.freeze(Object.defineProperty({__proto__:null,generate:xs,name:Yc,parse:vs,structure:Xc},Symbol.toStringTag,{value:"Module"})),Zc="Selector",tu={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]};function ws(){const t=this.readSequence(this.scope.Selector);return this.getFirstListNode(t)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(t),children:t}}function As(t){this.children(t)}const eu=Object.freeze(Object.defineProperty({__proto__:null,generate:As,name:Zc,parse:ws,structure:tu},Symbol.toStringTag,{value:"Module"})),nu="SelectorList",ru="selector",iu={children:[["Selector","Raw"]]};function Ls(){const t=this.createList();for(;!this.eof;){if(t.push(this.Selector()),this.tokenType===ot){this.next();continue}break}return{type:"SelectorList",loc:this.getLocationFromList(t),children:t}}function Ts(t){this.children(t,()=>this.token(ot,","))}const su=Object.freeze(Object.defineProperty({__proto__:null,generate:Ts,name:nu,parse:Ls,structure:iu,walkContext:ru},Symbol.toStringTag,{value:"Module"})),rn=92,_s=34,ou=39;function Es(t){const e=t.length,n=t.charCodeAt(0),r=n===_s||n===ou?1:0,i=r===1&&e>1&&t.charCodeAt(e-1)===n?e-2:e-1;let s="";for(let a=r;a<=i;a++){let l=t.charCodeAt(a);if(l===rn){if(a===i){a!==e-1&&(s=t.substr(a+1));break}if(l=t.charCodeAt(++a),ut(rn,l)){const u=a-1,o=Vt(t,u);a=o-1,s+=Qr(t.substring(u+1,o))}else l===13&&t.charCodeAt(a+1)===10&&a++}else s+=t[a]}return s}function au(t,e){const n='"',r=_s;let i="",s=!1;for(let a=0;a<t.length;a++){const l=t.charCodeAt(a);if(l===0){i+="�";continue}if(l<=31||l===127){i+="\\"+l.toString(16),s=!0;continue}l===r||l===rn?(i+="\\"+t.charAt(a),s=!1):(s&&(Ut(l)||Et(l))&&(i+=" "),i+=t.charAt(a),s=!1)}return n+i+n}const lu="String",cu={value:String};function Os(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:Es(this.consume(mt))}}function $s(t){this.token(mt,au(t.value))}const uu=Object.freeze(Object.defineProperty({__proto__:null,generate:$s,name:lu,parse:Os,structure:cu},Symbol.toStringTag,{value:"Module"})),hu=33;function Qn(){return this.Raw(null,!1)}const fu="StyleSheet",pu="stylesheet",du={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]};function Ps(){const t=this.tokenStart,e=this.createList();let n;for(;!this.eof;){switch(this.tokenType){case j:this.next();continue;case G:if(this.charCodeAt(this.tokenStart+2)!==hu){this.next();continue}n=this.Comment();break;case Te:n=this.CDO();break;case Y:n=this.CDC();break;case W:n=this.parseWithFallback(this.Atrule,Qn);break;default:n=this.parseWithFallback(this.Rule,Qn)}e.push(n)}return{type:"StyleSheet",loc:this.getLocation(t,this.tokenStart),children:e}}function Is(t){this.children(t)}const gu=Object.freeze(Object.defineProperty({__proto__:null,generate:Is,name:fu,parse:Ps,structure:du,walkContext:pu},Symbol.toStringTag,{value:"Module"})),mu="SupportsDeclaration",yu={declaration:"Declaration"};function Ns(){const t=this.tokenStart;this.eat(R),this.skipSC();const e=this.Declaration();return this.eof||this.eat(T),{type:"SupportsDeclaration",loc:this.getLocation(t,this.tokenStart),declaration:e}}function Rs(t){this.token(R,"("),this.node(t.declaration),this.token(T,")")}const Su=Object.freeze(Object.defineProperty({__proto__:null,generate:Rs,name:mu,parse:Ns,structure:yu},Symbol.toStringTag,{value:"Module"})),ku=42,Kn=124;function Fe(){this.tokenType!==b&&this.isDelim(ku)===!1&&this.error("Identifier or asterisk is expected"),this.next()}const bu="TypeSelector",Cu={name:String};function Ds(){const t=this.tokenStart;return this.isDelim(Kn)?(this.next(),Fe.call(this)):(Fe.call(this),this.isDelim(Kn)&&(this.next(),Fe.call(this))),{type:"TypeSelector",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t)}}function Fs(t){this.tokenize(t.name)}const vu=Object.freeze(Object.defineProperty({__proto__:null,generate:Fs,name:bu,parse:Ds,structure:Cu},Symbol.toStringTag,{value:"Module"})),Ms=43,js=45,sn=63;function Kt(t,e){let n=0;for(let r=this.tokenStart+t;r<this.tokenEnd;r++){const i=this.charCodeAt(r);if(i===js&&e&&n!==0)return Kt.call(this,t+n+1,!1),-1;Ut(i)||this.error(e&&n!==0?"Hyphen minus"+(n<6?" or hex digit":"")+" is expected":n<6?"Hex digit is expected":"Unexpected input",r),++n>6&&this.error("Too many hex digits",r)}return this.next(),n}function oe(t){let e=0;for(;this.isDelim(sn);)++e>t&&this.error("Too many question marks"),this.next()}function xu(t){this.charCodeAt(this.tokenStart)!==t&&this.error((t===Ms?"Plus sign":"Hyphen minus")+" is expected")}function wu(){let t=0;switch(this.tokenType){case _:if(t=Kt.call(this,1,!0),this.isDelim(sn)){oe.call(this,6-t);break}if(this.tokenType===I||this.tokenType===_){xu.call(this,js),Kt.call(this,1,!1);break}break;case I:t=Kt.call(this,1,!0),t>0&&oe.call(this,6-t);break;default:if(this.eatDelim(Ms),this.tokenType===b){t=Kt.call(this,0,!0),t>0&&oe.call(this,6-t);break}if(this.isDelim(sn)){this.next(),oe.call(this,5);break}this.error("Hex digit or question mark is expected")}}const Au="UnicodeRange",Lu={value:String};function Bs(){const t=this.tokenStart;return this.eatIdent("u"),wu.call(this),{type:"UnicodeRange",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t)}}function Ws(t){this.tokenize(t.value)}const Tu=Object.freeze(Object.defineProperty({__proto__:null,generate:Ws,name:Au,parse:Bs,structure:Lu},Symbol.toStringTag,{value:"Module"})),_u=32,on=92,Eu=34,Ou=39,$u=40,zs=41;function Pu(t){const e=t.length;let n=4,r=t.charCodeAt(e-1)===zs?e-2:e-1,i="";for(;n<r&&Et(t.charCodeAt(n));)n++;for(;n<r&&Et(t.charCodeAt(r));)r--;for(let s=n;s<=r;s++){let a=t.charCodeAt(s);if(a===on){if(s===r){s!==e-1&&(i=t.substr(s+1));break}if(a=t.charCodeAt(++s),ut(on,a)){const l=s-1,u=Vt(t,l);s=u-1,i+=Qr(t.substring(l+1,u))}else a===13&&t.charCodeAt(s+1)===10&&s++}else i+=t[s]}return i}function Iu(t){let e="",n=!1;for(let r=0;r<t.length;r++){const i=t.charCodeAt(r);if(i===0){e+="�";continue}if(i<=31||i===127){e+="\\"+i.toString(16),n=!0;continue}i===_u||i===on||i===Eu||i===Ou||i===$u||i===zs?(e+="\\"+t.charAt(r),n=!1):(n&&Ut(i)&&(e+=" "),e+=t.charAt(r),n=!1)}return"url("+e+")"}const Nu="Url",Ru={value:String};function Us(){const t=this.tokenStart;let e;switch(this.tokenType){case H:e=Pu(this.consume(H));break;case P:this.cmpStr(this.tokenStart,this.tokenEnd,"url(")||this.error("Function name must be `url`"),this.eat(P),this.skipSC(),e=Es(this.consume(mt)),this.skipSC(),this.eof||this.eat(T);break;default:this.error("Url or Function is expected")}return{type:"Url",loc:this.getLocation(t,this.tokenStart),value:e}}function Vs(t){this.token(H,Iu(t.value))}const Du=Object.freeze(Object.defineProperty({__proto__:null,generate:Vs,name:Nu,parse:Us,structure:Ru},Symbol.toStringTag,{value:"Module"})),Fu="Value",Mu={children:[[]]};function Hs(){const t=this.tokenStart,e=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(t,this.tokenStart),children:e}}function Gs(t){this.children(t)}const ju=Object.freeze(Object.defineProperty({__proto__:null,generate:Gs,name:Fu,parse:Hs,structure:Mu},Symbol.toStringTag,{value:"Module"})),Bu=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),Wu="WhiteSpace",zu={value:String};function qs(){return this.eat(j),Bu}function Qs(t){this.token(j,t.value)}const Uu=Object.freeze(Object.defineProperty({__proto__:null,generate:Qs,name:Wu,parse:qs,structure:zu},Symbol.toStringTag,{value:"Module"})),Vu=Object.freeze(Object.defineProperty({__proto__:null,AnPlusB:ea,Atrule:oa,AtrulePrelude:ua,AttributeSelector:Sa,Block:wa,Brackets:Ta,CDC:Oa,CDO:Ia,ClassSelector:Fa,Combinator:Ua,Comment:Qa,Condition:Za,Declaration:dl,DeclarationList:Sl,Dimension:Cl,Feature:Al,FeatureFunction:El,FeatureRange:Nl,Function:Ml,GeneralEnclosed:Wl,Hash:Hl,IdSelector:Xl,Identifier:Ql,Layer:ec,LayerList:ic,MediaQuery:ac,MediaQueryList:uc,NestingSelector:dc,Nth:yc,Number:bc,Operator:xc,Parentheses:Lc,Percentage:Ec,PseudoClassSelector:Ic,PseudoElementSelector:Fc,Ratio:Bc,Raw:Vc,Rule:Kc,Scope:Jc,Selector:eu,SelectorList:su,String:uu,StyleSheet:gu,SupportsDeclaration:Su,TypeSelector:vu,UnicodeRange:Tu,Url:Du,Value:ju,WhiteSpace:Uu},Symbol.toStringTag,{value:"Module"})),Hu={node:Vu},bt=jo(Hu),kn=["left","right","top","bottom","inset-block-start","inset-block-end","inset-inline-start","inset-inline-end","inset-block","inset-inline","inset"];function ee(t){return kn.includes(t)}const bn=["margin-block-start","margin-block-end","margin-block","margin-inline-start","margin-inline-end","margin-inline","margin-bottom","margin-left","margin-right","margin-top","margin"];function Gu(t){return bn.includes(t)}const Cn=["width","height","min-width","min-height","max-width","max-height","block-size","inline-size","min-block-size","min-inline-size","max-block-size","max-inline-size"];function Ks(t){return Cn.includes(t)}const Ys=["justify-self","align-self","place-self"];function qu(t){return Ys.includes(t)}const Xs=[...kn,...bn,...Cn,...Ys,"position-anchor","position-area"],Qu=[...Cn,...kn,...bn];function Js(t){return Qu.includes(t)}const Ku=["top","left","right","bottom","start","end","self-start","self-end","center","inside","outside"];function Zs(t){return Ku.includes(t)}const Yu=["width","height","block","inline","self-block","self-inline"];function Xu(t){return Yu.includes(t)}var Me={},ae={},le={},Yn;function Ju(){if(Yn)return le;Yn=1;var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return le.encode=function(e){if(0<=e&&e<t.length)return t[e];throw new TypeError("Must be between 0 and 63: "+e)},le.decode=function(e){var n=65,r=90,i=97,s=122,a=48,l=57,u=43,o=47,c=26,h=52;return n<=e&&e<=r?e-n:i<=e&&e<=s?e-i+c:a<=e&&e<=l?e-a+h:e==u?62:e==o?63:-1},le}var Xn;function Zu(){if(Xn)return ae;Xn=1;var t=Ju(),e=5,n=1<<e,r=n-1,i=n;function s(l){return l<0?(-l<<1)+1:(l<<1)+0}function a(l){var u=(l&1)===1,o=l>>1;return u?-o:o}return ae.encode=function(u){var o="",c,h=s(u);do c=h&r,h>>>=e,h>0&&(c|=i),o+=t.encode(c);while(h>0);return o},ae.decode=function(u,o,c){var h=u.length,g=0,p=0,m,C;do{if(o>=h)throw new Error("Expected more digits in base 64 VLQ value.");if(C=t.decode(u.charCodeAt(o++)),C===-1)throw new Error("Invalid base64 digit: "+u.charAt(o-1));m=!!(C&i),C&=r,g=g+(C<<p),p+=e}while(m);c.value=a(g),c.rest=o},ae}var je={},Jn;function vn(){return Jn||(Jn=1,function(t){function e(f,d,k){if(d in f)return f[d];if(arguments.length===3)return k;throw new Error('"'+d+'" is a required argument.')}t.getArg=e;var n=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,r=/^data:.+\,.+$/;function i(f){var d=f.match(n);return d?{scheme:d[1],auth:d[2],host:d[3],port:d[4],path:d[5]}:null}t.urlParse=i;function s(f){var d="";return f.scheme&&(d+=f.scheme+":"),d+="//",f.auth&&(d+=f.auth+"@"),f.host&&(d+=f.host),f.port&&(d+=":"+f.port),f.path&&(d+=f.path),d}t.urlGenerate=s;var a=32;function l(f){var d=[];return function(k){for(var y=0;y<d.length;y++)if(d[y].input===k){var B=d[0];return d[0]=d[y],d[y]=B,d[0].result}var E=f(k);return d.unshift({input:k,result:E}),d.length>a&&d.pop(),E}}var u=l(function(d){var k=d,y=i(d);if(y){if(!y.path)return d;k=y.path}for(var B=t.isAbsolute(k),E=[],dt=0,F=0;;)if(dt=F,F=k.indexOf("/",dt),F===-1){E.push(k.slice(dt));break}else for(E.push(k.slice(dt,F));F<k.length&&k[F]==="/";)F++;for(var gt,xt=0,F=E.length-1;F>=0;F--)gt=E[F],gt==="."?E.splice(F,1):gt===".."?xt++:xt>0&&(gt===""?(E.splice(F+1,xt),xt=0):(E.splice(F,2),xt--));return k=E.join("/"),k===""&&(k=B?"/":"."),y?(y.path=k,s(y)):k});t.normalize=u;function o(f,d){f===""&&(f="."),d===""&&(d=".");var k=i(d),y=i(f);if(y&&(f=y.path||"/"),k&&!k.scheme)return y&&(k.scheme=y.scheme),s(k);if(k||d.match(r))return d;if(y&&!y.host&&!y.path)return y.host=d,s(y);var B=d.charAt(0)==="/"?d:u(f.replace(/\/+$/,"")+"/"+d);return y?(y.path=B,s(y)):B}t.join=o,t.isAbsolute=function(f){return f.charAt(0)==="/"||n.test(f)};function c(f,d){f===""&&(f="."),f=f.replace(/\/$/,"");for(var k=0;d.indexOf(f+"/")!==0;){var y=f.lastIndexOf("/");if(y<0||(f=f.slice(0,y),f.match(/^([^\/]+:\/)?\/*$/)))return d;++k}return Array(k+1).join("../")+d.substr(f.length+1)}t.relative=c;var h=function(){var f=Object.create(null);return!("__proto__"in f)}();function g(f){return f}function p(f){return C(f)?"$"+f:f}t.toSetString=h?g:p;function m(f){return C(f)?f.slice(1):f}t.fromSetString=h?g:m;function C(f){if(!f)return!1;var d=f.length;if(d<9||f.charCodeAt(d-1)!==95||f.charCodeAt(d-2)!==95||f.charCodeAt(d-3)!==111||f.charCodeAt(d-4)!==116||f.charCodeAt(d-5)!==111||f.charCodeAt(d-6)!==114||f.charCodeAt(d-7)!==112||f.charCodeAt(d-8)!==95||f.charCodeAt(d-9)!==95)return!1;for(var k=d-10;k>=0;k--)if(f.charCodeAt(k)!==36)return!1;return!0}function w(f,d,k){var y=x(f.source,d.source);return y!==0||(y=f.originalLine-d.originalLine,y!==0)||(y=f.originalColumn-d.originalColumn,y!==0||k)||(y=f.generatedColumn-d.generatedColumn,y!==0)||(y=f.generatedLine-d.generatedLine,y!==0)?y:x(f.name,d.name)}t.compareByOriginalPositions=w;function S(f,d,k){var y;return y=f.originalLine-d.originalLine,y!==0||(y=f.originalColumn-d.originalColumn,y!==0||k)||(y=f.generatedColumn-d.generatedColumn,y!==0)||(y=f.generatedLine-d.generatedLine,y!==0)?y:x(f.name,d.name)}t.compareByOriginalPositionsNoSource=S;function v(f,d,k){var y=f.generatedLine-d.generatedLine;return y!==0||(y=f.generatedColumn-d.generatedColumn,y!==0||k)||(y=x(f.source,d.source),y!==0)||(y=f.originalLine-d.originalLine,y!==0)||(y=f.originalColumn-d.originalColumn,y!==0)?y:x(f.name,d.name)}t.compareByGeneratedPositionsDeflated=v;function A(f,d,k){var y=f.generatedColumn-d.generatedColumn;return y!==0||k||(y=x(f.source,d.source),y!==0)||(y=f.originalLine-d.originalLine,y!==0)||(y=f.originalColumn-d.originalColumn,y!==0)?y:x(f.name,d.name)}t.compareByGeneratedPositionsDeflatedNoLine=A;function x(f,d){return f===d?0:f===null?1:d===null?-1:f>d?1:-1}function $(f,d){var k=f.generatedLine-d.generatedLine;return k!==0||(k=f.generatedColumn-d.generatedColumn,k!==0)||(k=x(f.source,d.source),k!==0)||(k=f.originalLine-d.originalLine,k!==0)||(k=f.originalColumn-d.originalColumn,k!==0)?k:x(f.name,d.name)}t.compareByGeneratedPositionsInflated=$;function O(f){return JSON.parse(f.replace(/^\)]}'[^\n]*\n/,""))}t.parseSourceMapInput=O;function L(f,d,k){if(d=d||"",f&&(f[f.length-1]!=="/"&&d[0]!=="/"&&(f+="/"),d=f+d),k){var y=i(k);if(!y)throw new Error("sourceMapURL could not be parsed");if(y.path){var B=y.path.lastIndexOf("/");B>=0&&(y.path=y.path.substring(0,B+1))}d=o(s(y),d)}return u(d)}t.computeSourceURL=L}(je)),je}var Be={},Zn;function th(){if(Zn)return Be;Zn=1;var t=vn(),e=Object.prototype.hasOwnProperty,n=typeof Map<"u";function r(){this._array=[],this._set=n?new Map:Object.create(null)}return r.fromArray=function(s,a){for(var l=new r,u=0,o=s.length;u<o;u++)l.add(s[u],a);return l},r.prototype.size=function(){return n?this._set.size:Object.getOwnPropertyNames(this._set).length},r.prototype.add=function(s,a){var l=n?s:t.toSetString(s),u=n?this.has(s):e.call(this._set,l),o=this._array.length;(!u||a)&&this._array.push(s),u||(n?this._set.set(s,o):this._set[l]=o)},r.prototype.has=function(s){if(n)return this._set.has(s);var a=t.toSetString(s);return e.call(this._set,a)},r.prototype.indexOf=function(s){if(n){var a=this._set.get(s);if(a>=0)return a}else{var l=t.toSetString(s);if(e.call(this._set,l))return this._set[l]}throw new Error('"'+s+'" is not in the set.')},r.prototype.at=function(s){if(s>=0&&s<this._array.length)return this._array[s];throw new Error("No element indexed by "+s)},r.prototype.toArray=function(){return this._array.slice()},Be.ArraySet=r,Be}var We={},tr;function eh(){if(tr)return We;tr=1;var t=vn();function e(r,i){var s=r.generatedLine,a=i.generatedLine,l=r.generatedColumn,u=i.generatedColumn;return a>s||a==s&&u>=l||t.compareByGeneratedPositionsInflated(r,i)<=0}function n(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return n.prototype.unsortedForEach=function(i,s){this._array.forEach(i,s)},n.prototype.add=function(i){e(this._last,i)?(this._last=i,this._array.push(i)):(this._sorted=!1,this._array.push(i))},n.prototype.toArray=function(){return this._sorted||(this._array.sort(t.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},We.MappingList=n,We}var er;function nh(){if(er)return Me;er=1;var t=Zu(),e=vn(),n=th().ArraySet,r=eh().MappingList;function i(s){s||(s={}),this._file=e.getArg(s,"file",null),this._sourceRoot=e.getArg(s,"sourceRoot",null),this._skipValidation=e.getArg(s,"skipValidation",!1),this._ignoreInvalidMapping=e.getArg(s,"ignoreInvalidMapping",!1),this._sources=new n,this._names=new n,this._mappings=new r,this._sourcesContents=null}return i.prototype._version=3,i.fromSourceMap=function(a,l){var u=a.sourceRoot,o=new i(Object.assign(l||{},{file:a.file,sourceRoot:u}));return a.eachMapping(function(c){var h={generated:{line:c.generatedLine,column:c.generatedColumn}};c.source!=null&&(h.source=c.source,u!=null&&(h.source=e.relative(u,h.source)),h.original={line:c.originalLine,column:c.originalColumn},c.name!=null&&(h.name=c.name)),o.addMapping(h)}),a.sources.forEach(function(c){var h=c;u!==null&&(h=e.relative(u,c)),o._sources.has(h)||o._sources.add(h);var g=a.sourceContentFor(c);g!=null&&o.setSourceContent(c,g)}),o},i.prototype.addMapping=function(a){var l=e.getArg(a,"generated"),u=e.getArg(a,"original",null),o=e.getArg(a,"source",null),c=e.getArg(a,"name",null);!this._skipValidation&&this._validateMapping(l,u,o,c)===!1||(o!=null&&(o=String(o),this._sources.has(o)||this._sources.add(o)),c!=null&&(c=String(c),this._names.has(c)||this._names.add(c)),this._mappings.add({generatedLine:l.line,generatedColumn:l.column,originalLine:u!=null&&u.line,originalColumn:u!=null&&u.column,source:o,name:c}))},i.prototype.setSourceContent=function(a,l){var u=a;this._sourceRoot!=null&&(u=e.relative(this._sourceRoot,u)),l!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[e.toSetString(u)]=l):this._sourcesContents&&(delete this._sourcesContents[e.toSetString(u)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},i.prototype.applySourceMap=function(a,l,u){var o=l;if(l==null){if(a.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);o=a.file}var c=this._sourceRoot;c!=null&&(o=e.relative(c,o));var h=new n,g=new n;this._mappings.unsortedForEach(function(p){if(p.source===o&&p.originalLine!=null){var m=a.originalPositionFor({line:p.originalLine,column:p.originalColumn});m.source!=null&&(p.source=m.source,u!=null&&(p.source=e.join(u,p.source)),c!=null&&(p.source=e.relative(c,p.source)),p.originalLine=m.line,p.originalColumn=m.column,m.name!=null&&(p.name=m.name))}var C=p.source;C!=null&&!h.has(C)&&h.add(C);var w=p.name;w!=null&&!g.has(w)&&g.add(w)},this),this._sources=h,this._names=g,a.sources.forEach(function(p){var m=a.sourceContentFor(p);m!=null&&(u!=null&&(p=e.join(u,p)),c!=null&&(p=e.relative(c,p)),this.setSourceContent(p,m))},this)},i.prototype._validateMapping=function(a,l,u,o){if(l&&typeof l.line!="number"&&typeof l.column!="number"){var c="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(c),!1;throw new Error(c)}if(!(a&&"line"in a&&"column"in a&&a.line>0&&a.column>=0&&!l&&!u&&!o)){if(a&&"line"in a&&"column"in a&&l&&"line"in l&&"column"in l&&a.line>0&&a.column>=0&&l.line>0&&l.column>=0&&u)return;var c="Invalid mapping: "+JSON.stringify({generated:a,source:u,original:l,name:o});if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(c),!1;throw new Error(c)}},i.prototype._serializeMappings=function(){for(var a=0,l=1,u=0,o=0,c=0,h=0,g="",p,m,C,w,S=this._mappings.toArray(),v=0,A=S.length;v<A;v++){if(m=S[v],p="",m.generatedLine!==l)for(a=0;m.generatedLine!==l;)p+=";",l++;else if(v>0){if(!e.compareByGeneratedPositionsInflated(m,S[v-1]))continue;p+=","}p+=t.encode(m.generatedColumn-a),a=m.generatedColumn,m.source!=null&&(w=this._sources.indexOf(m.source),p+=t.encode(w-h),h=w,p+=t.encode(m.originalLine-1-o),o=m.originalLine-1,p+=t.encode(m.originalColumn-u),u=m.originalColumn,m.name!=null&&(C=this._names.indexOf(m.name),p+=t.encode(C-c),c=C)),g+=p}return g},i.prototype._generateSourcesContent=function(a,l){return a.map(function(u){if(!this._sourcesContents)return null;l!=null&&(u=e.relative(l,u));var o=e.toSetString(u);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)},i.prototype.toJSON=function(){var a={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(a.file=this._file),this._sourceRoot!=null&&(a.sourceRoot=this._sourceRoot),this._sourcesContents&&(a.sourcesContent=this._generateSourcesContent(a.sources,a.sourceRoot)),a},i.prototype.toString=function(){return JSON.stringify(this.toJSON())},Me.SourceMapGenerator=i,Me}var rh=nh();const nr=new Set(["Atrule","Selector","Declaration"]);function ih(t){const e=new rh.SourceMapGenerator,n={line:1,column:0},r={line:0,column:0},i={line:1,column:0},s={generated:i};let a=1,l=0,u=!1;const o=t.node;t.node=function(g){if(g.loc&&g.loc.start&&nr.has(g.type)){const p=g.loc.start.line,m=g.loc.start.column-1;(r.line!==p||r.column!==m)&&(r.line=p,r.column=m,n.line=a,n.column=l,u&&(u=!1,(n.line!==i.line||n.column!==i.column)&&e.addMapping(s)),u=!0,e.addMapping({source:g.loc.source,original:r,generated:n}))}o.call(this,g),u&&nr.has(g.type)&&(i.line=a,i.column=l)};const c=t.emit;t.emit=function(g,p,m){for(let C=0;C<g.length;C++)g.charCodeAt(C)===10?(a++,l=0):l++;c(g,p,m)};const h=t.result;return t.result=function(){return u&&e.addMapping(s),{css:h(),map:e}},t}const sh=43,oh=45,ze=(t,e)=>{if(t===N&&(t=e),typeof t=="string"){const n=t.charCodeAt(0);return n>127?32768:n<<8}return t},to=[[b,b],[b,P],[b,H],[b,et],[b,"-"],[b,_],[b,M],[b,I],[b,Y],[b,R],[W,b],[W,P],[W,H],[W,et],[W,"-"],[W,_],[W,M],[W,I],[W,Y],[D,b],[D,P],[D,H],[D,et],[D,"-"],[D,_],[D,M],[D,I],[D,Y],[I,b],[I,P],[I,H],[I,et],[I,"-"],[I,_],[I,M],[I,I],[I,Y],["#",b],["#",P],["#",H],["#",et],["#","-"],["#",_],["#",M],["#",I],["#",Y],["-",b],["-",P],["-",H],["-",et],["-","-"],["-",_],["-",M],["-",I],["-",Y],[_,b],[_,P],[_,H],[_,et],[_,_],[_,M],[_,I],[_,"%"],[_,Y],["@",b],["@",P],["@",H],["@",et],["@","-"],["@",Y],[".",_],[".",M],[".",I],["+",_],["+",M],["+",I],["/","*"]],ah=to.concat([[b,D],[I,D],[D,D],[W,R],[W,mt],[W,q],[M,M],[M,I],[M,P],[M,"-"],[T,b],[T,P],[T,M],[T,I],[T,D],[T,"-"]]);function eo(t){const e=new Set(t.map(([n,r])=>ze(n)<<16|ze(r)));return function(n,r,i){const s=ze(r,i),a=i.charCodeAt(0);return(a===oh&&r!==b&&r!==P&&r!==Y||a===sh?e.has(n<<16|a<<8):e.has(n<<16|s))&&this.emit(" ",j,!0),s}}const lh=eo(to),no=eo(ah),rr=Object.freeze(Object.defineProperty({__proto__:null,safe:no,spec:lh},Symbol.toStringTag,{value:"Module"})),ch=92;function uh(t,e){if(typeof e=="function"){let n=null;t.children.forEach(r=>{n!==null&&e.call(this,n),this.node(r),n=r});return}t.children.forEach(this.node,this)}function hh(t){Yr(t,(e,n,r)=>{this.token(e,t.slice(n,r))})}function fh(t){const e=new Map;for(let[n,r]of Object.entries(t.node))typeof(r.generate||r)=="function"&&e.set(n,r.generate||r);return function(n,r){let i="",s=0,a={node(u){if(e.has(u.type))e.get(u.type).call(l,u);else throw new Error("Unknown node type: "+u.type)},tokenBefore:no,token(u,o){s=this.tokenBefore(s,u,o),this.emit(o,u,!1),u===N&&o.charCodeAt(0)===ch&&this.emit(`
`,j,!0)},emit(u){i+=u},result(){return i}};r&&(typeof r.decorator=="function"&&(a=r.decorator(a)),r.sourceMap&&(a=ih(a)),r.mode in rr&&(a.tokenBefore=rr[r.mode]));const l={node:u=>a.node(u),children:uh,token:(u,o)=>a.token(u,o),tokenize:hh};return a.node(n),a.result()}}const ph=Object.freeze(Object.defineProperty({__proto__:null,AnPlusB:Jr,Atrule:ti,AtrulePrelude:ni,AttributeSelector:si,Block:li,Brackets:ui,CDC:fi,CDO:di,ClassSelector:mi,Combinator:Si,Comment:bi,Condition:vi,Declaration:Ai,DeclarationList:Ti,Dimension:Ei,Feature:$i,FeatureFunction:Ii,FeatureRange:Ri,Function:Fi,GeneralEnclosed:ji,Hash:Wi,IdSelector:Hi,Identifier:Ui,Layer:qi,LayerList:Ki,MediaQuery:Xi,MediaQueryList:Zi,NestingSelector:es,Nth:rs,Number:ss,Operator:as,Parentheses:cs,Percentage:hs,PseudoClassSelector:ps,PseudoElementSelector:gs,Ratio:ys,Raw:ks,Rule:Cs,Scope:xs,Selector:As,SelectorList:Ts,String:$s,StyleSheet:Is,SupportsDeclaration:Rs,TypeSelector:Fs,UnicodeRange:Ws,Url:Vs,Value:Gs,WhiteSpace:Qs},Symbol.toStringTag,{value:"Module"})),dh={node:ph},gh=fh(dh);let Rt=null;class V{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return V.createItem(e)}allocateCursor(e,n){let r;return Rt!==null?(r=Rt,Rt=Rt.cursor,r.prev=e,r.next=n,r.cursor=this.cursor):r={prev:e,next:n,cursor:this.cursor},this.cursor=r,r}releaseCursor(){const{cursor:e}=this;this.cursor=e.cursor,e.prev=null,e.next=null,e.cursor=Rt,Rt=e}updateCursors(e,n,r,i){let{cursor:s}=this;for(;s!==null;)s.prev===e&&(s.prev=n),s.next===r&&(s.next=i),s=s.cursor}*[Symbol.iterator](){for(let e=this.head;e!==null;e=e.next)yield e.data}get size(){let e=0;for(let n=this.head;n!==null;n=n.next)e++;return e}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(e){let n=null;this.head=null;for(let r of e){const i=V.createItem(r);n!==null?n.next=i:this.head=i,i.prev=n,n=i}return this.tail=n,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(e,n=this){const r=this.allocateCursor(null,this.head);for(;r.next!==null;){const i=r.next;r.next=i.next,e.call(n,i.data,i,this)}this.releaseCursor()}forEachRight(e,n=this){const r=this.allocateCursor(this.tail,null);for(;r.prev!==null;){const i=r.prev;r.prev=i.prev,e.call(n,i.data,i,this)}this.releaseCursor()}reduce(e,n,r=this){let i=this.allocateCursor(null,this.head),s=n,a;for(;i.next!==null;)a=i.next,i.next=a.next,s=e.call(r,s,a.data,a,this);return this.releaseCursor(),s}reduceRight(e,n,r=this){let i=this.allocateCursor(this.tail,null),s=n,a;for(;i.prev!==null;)a=i.prev,i.prev=a.prev,s=e.call(r,s,a.data,a,this);return this.releaseCursor(),s}some(e,n=this){for(let r=this.head;r!==null;r=r.next)if(e.call(n,r.data,r,this))return!0;return!1}map(e,n=this){const r=new V;for(let i=this.head;i!==null;i=i.next)r.appendData(e.call(n,i.data,i,this));return r}filter(e,n=this){const r=new V;for(let i=this.head;i!==null;i=i.next)e.call(n,i.data,i,this)&&r.appendData(i.data);return r}nextUntil(e,n,r=this){if(e===null)return;const i=this.allocateCursor(null,e);for(;i.next!==null;){const s=i.next;if(i.next=s.next,n.call(r,s.data,s,this))break}this.releaseCursor()}prevUntil(e,n,r=this){if(e===null)return;const i=this.allocateCursor(e,null);for(;i.prev!==null;){const s=i.prev;if(i.prev=s.prev,n.call(r,s.data,s,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){const e=new V;for(let n of this)e.appendData(n);return e}prepend(e){return this.updateCursors(null,e,this.head,e),this.head!==null?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this}prependData(e){return this.prepend(V.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert(V.createItem(e))}insert(e,n=null){if(n!==null)if(this.updateCursors(n.prev,e,n,e),n.prev===null){if(this.head!==n)throw new Error("before doesn't belong to list");this.head=e,n.prev=e,e.next=n,this.updateCursors(null,e)}else n.prev.next=e,e.prev=n.prev,n.prev=e,e.next=n;else this.updateCursors(this.tail,e,null,e),this.tail!==null?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this}insertData(e,n){return this.insert(V.createItem(e),n)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(e.next!==null)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e}push(e){this.insert(V.createItem(e))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(e){this.prepend(V.createItem(e))}shift(){return this.head!==null?this.remove(this.head):null}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e)}insertList(e,n){return e.head===null?this:(n!=null?(this.updateCursors(n.prev,e.tail,n,e.head),n.prev!==null?(n.prev.next=e.head,e.head.prev=n.prev):this.head=e.head,n.prev=e.tail,e.tail.next=n):(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null,this)}replace(e,n){"head"in n?this.insertList(n,e):this.insert(n,e),this.remove(e)}}function mh(t,e){const n=Object.create(SyntaxError.prototype),r=new Error;return Object.assign(n,{name:t,message:e,get stack(){return(r.stack||"").replace(/^(.+\n){1,3}/,`${t}: ${e}
`)}})}const Ue=100,ir=60,sr=" ";function or({source:t,line:e,column:n,baseLine:r,baseColumn:i},s){function a(m,C){return o.slice(m,C).map((w,S)=>String(m+S+1).padStart(g)+" |"+w).join(`
`)}const l=`
`.repeat(Math.max(r-1,0)),u=" ".repeat(Math.max(i-1,0)),o=(l+u+t).split(/\r\n?|\n|\f/),c=Math.max(1,e-s)-1,h=Math.min(e+s,o.length+1),g=Math.max(4,String(h).length)+1;let p=0;n+=(sr.length-1)*(o[e-1].substr(0,n-1).match(/\t/g)||[]).length,n>Ue&&(p=n-ir+3,n=ir-2);for(let m=c;m<=h;m++)m>=0&&m<o.length&&(o[m]=o[m].replace(/\t/g,sr),o[m]=(p>0&&o[m].length>p?"…":"")+o[m].substr(p,Ue-2)+(o[m].length>p+Ue-1?"…":""));return[a(c,e),new Array(n+g+2).join("-")+"^",a(e,h)].filter(Boolean).join(`
`).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function ar(t,e,n,r,i,s=1,a=1){return Object.assign(mh("SyntaxError",t),{source:e,offset:n,line:r,column:i,sourceFragment(u){return or({source:e,line:r,column:i,baseLine:s,baseColumn:a},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${t}
`+or({source:e,line:r,column:i,baseLine:s,baseColumn:a},2)}})}function yh(t){const e=this.createList();let n=!1;const r={recognizer:t};for(;!this.eof;){switch(this.tokenType){case G:this.next();continue;case j:n=!0,this.next();continue}let i=t.getNode.call(this,r);if(i===void 0)break;n&&(t.onWhiteSpace&&t.onWhiteSpace.call(this,i,e,r),n=!1),e.push(i)}return n&&t.onWhiteSpace&&t.onWhiteSpace.call(this,null,e,r),e}const lr=()=>{},Sh=33,kh=35,Ve=59,cr=123,ur=0;function bh(t){return function(){return this[t]()}}function He(t){const e=Object.create(null);for(const n of Object.keys(t)){const r=t[n],i=r.parse||r;i&&(e[n]=i)}return e}function Ch(t){const e={context:Object.create(null),features:Object.assign(Object.create(null),t.features),scope:Object.assign(Object.create(null),t.scope),atrule:He(t.atrule),pseudo:He(t.pseudo),node:He(t.node)};for(const[n,r]of Object.entries(t.parseContext))switch(typeof r){case"function":e.context[n]=r;break;case"string":e.context[n]=bh(r);break}return{config:e,...e,...e.node}}function vh(t){let e="",n="<unknown>",r=!1,i=lr,s=!1;const a=new Yo,l=Object.assign(new Xo,Ch(t||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:yh,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(o){return o===cr?1:0},consumeUntilLeftCurlyBracketOrSemicolon(o){return o===cr||o===Ve?1:0},consumeUntilExclamationMarkOrSemicolon(o){return o===Sh||o===Ve?1:0},consumeUntilSemicolonIncluded(o){return o===Ve?2:0},createList(){return new V},createSingleNodeList(o){return new V().appendData(o)},getFirstListNode(o){return o&&o.first},getLastListNode(o){return o&&o.last},parseWithFallback(o,c){const h=this.tokenIndex;try{return o.call(this)}catch(g){if(s)throw g;this.skip(h-this.tokenIndex);const p=c.call(this);return s=!0,i(g,p),s=!1,p}},lookupNonWSType(o){let c;do if(c=this.lookupType(o++),c!==j&&c!==G)return c;while(c!==ur);return ur},charCodeAt(o){return o>=0&&o<e.length?e.charCodeAt(o):0},substring(o,c){return e.substring(o,c)},substrToCursor(o){return this.source.substring(o,this.tokenStart)},cmpChar(o,c){return Gr(e,o,c)},cmpStr(o,c,h){return be(e,o,c,h)},consume(o){const c=this.tokenStart;return this.eat(o),this.substrToCursor(c)},consumeFunctionName(){const o=e.substring(this.tokenStart,this.tokenEnd-1);return this.eat(P),o},consumeNumber(o){const c=e.substring(this.tokenStart,qr(e,this.tokenStart));return this.eat(o),c},eat(o){if(this.tokenType!==o){const c=Kr[o].slice(0,-6).replace(/-/g," ").replace(/^./,p=>p.toUpperCase());let h=`${/[[\](){}]/.test(c)?`"${c}"`:c} is expected`,g=this.tokenStart;switch(o){case b:this.tokenType===P||this.tokenType===H?(g=this.tokenEnd-1,h="Identifier is expected but function found"):h="Identifier is expected";break;case D:this.isDelim(kh)&&(this.next(),g++,h="Name is expected");break;case M:this.tokenType===_&&(g=this.tokenEnd,h="Percent sign is expected");break}this.error(h,g)}this.next()},eatIdent(o){(this.tokenType!==b||this.lookupValue(0,o)===!1)&&this.error(`Identifier "${o}" is expected`),this.next()},eatDelim(o){this.isDelim(o)||this.error(`Delim "${String.fromCharCode(o)}" is expected`),this.next()},getLocation(o,c){return r?a.getLocationRange(o,c,n):null},getLocationFromList(o){if(r){const c=this.getFirstListNode(o),h=this.getLastListNode(o);return a.getLocationRange(c!==null?c.loc.start.offset-a.startOffset:this.tokenStart,h!==null?h.loc.end.offset-a.startOffset:this.tokenStart,n)}return null},error(o,c){const h=typeof c<"u"&&c<e.length?a.getLocation(c):this.eof?a.getLocation(qo(e,e.length-1)):a.getLocation(this.tokenStart);throw new ar(o||"Unexpected input",e,h.offset,h.line,h.column,a.startLine,a.startColumn)}});return Object.assign(function(o,c){e=o,c=c||{},l.setSource(e,Yr),a.setSource(e,c.offset,c.line,c.column),n=c.filename||"<unknown>",r=!!c.positions,i=typeof c.onParseError=="function"?c.onParseError:lr,s=!1,l.parseAtrulePrelude="parseAtrulePrelude"in c?!!c.parseAtrulePrelude:!0,l.parseRulePrelude="parseRulePrelude"in c?!!c.parseRulePrelude:!0,l.parseValue="parseValue"in c?!!c.parseValue:!0,l.parseCustomProperty="parseCustomProperty"in c?!!c.parseCustomProperty:!1;const{context:h="default",onComment:g}=c;if(!(h in l.context))throw new Error("Unknown context `"+h+"`");typeof g=="function"&&l.forEachToken((m,C,w)=>{if(m===G){const S=l.getLocation(C,w),v=be(e,w-2,w,"*/")?e.slice(C+2,w-2):e.slice(C+2,w);g(v,S)}});const p=l.context[h].call(l,c);return l.eof||l.error(),p},{SyntaxError:ar,config:l.config})}const xh=35,wh=42,hr=43,Ah=45,Lh=47,Th=117;function ro(t){switch(this.tokenType){case D:return this.Hash();case ot:return this.Operator();case R:return this.Parentheses(this.readSequence,t.recognizer);case qt:return this.Brackets(this.readSequence,t.recognizer);case mt:return this.String();case I:return this.Dimension();case M:return this.Percentage();case _:return this.Number();case P:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,t.recognizer);case H:return this.Url();case b:return this.cmpChar(this.tokenStart,Th)&&this.cmpChar(this.tokenStart+1,hr)?this.UnicodeRange():this.Identifier();case N:{const e=this.charCodeAt(this.tokenStart);if(e===Lh||e===wh||e===hr||e===Ah)return this.Operator();e===xh&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}const _h={getNode:ro},Eh=35,Oh=38,$h=42,Ph=43,Ih=47,fr=46,Nh=62,Rh=124,Dh=126;function Fh(t,e){e.last!==null&&e.last.type!=="Combinator"&&t!==null&&t.type!=="Combinator"&&e.push({type:"Combinator",loc:null,name:" "})}function Mh(){switch(this.tokenType){case qt:return this.AttributeSelector();case D:return this.IdSelector();case q:return this.lookupType(1)===q?this.PseudoElementSelector():this.PseudoClassSelector();case b:return this.TypeSelector();case _:case M:return this.Percentage();case I:this.charCodeAt(this.tokenStart)===fr&&this.error("Identifier is expected",this.tokenStart+1);break;case N:{switch(this.charCodeAt(this.tokenStart)){case Ph:case Nh:case Dh:case Ih:return this.Combinator();case fr:return this.ClassSelector();case $h:case Rh:return this.TypeSelector();case Eh:return this.IdSelector();case Oh:return this.NestingSelector()}break}}}const jh={onWhiteSpace:Fh,getNode:Mh};function Bh(){return this.createSingleNodeList(this.Raw(null,!1))}function Wh(){const t=this.createList();if(this.skipSC(),t.push(this.Identifier()),this.skipSC(),this.tokenType===ot){t.push(this.Operator());const e=this.tokenIndex,n=this.parseCustomProperty?this.Value(null):this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1);if(n.type==="Value"&&n.children.isEmpty){for(let r=e-this.tokenIndex;r<=0;r++)if(this.lookupType(r)===j){n.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}t.push(n)}return t}function pr(t){return t!==null&&t.type==="Operator"&&(t.value[t.value.length-1]==="-"||t.value[t.value.length-1]==="+")}const zh={getNode:ro,onWhiteSpace(t,e){pr(t)&&(t.value=" "+t.value),pr(e.last)&&(e.last.value+=" ")},expression:Bh,var:Wh},Uh=Object.freeze(Object.defineProperty({__proto__:null,AtrulePrelude:_h,Selector:jh,Value:zh},Symbol.toStringTag,{value:"Module"})),Vh=new Set(["none","and","not","or"]),Hh={parse:{prelude(){const t=this.createList();if(this.tokenType===b){const e=this.substring(this.tokenStart,this.tokenEnd);Vh.has(e.toLowerCase())||t.push(this.Identifier())}return t.push(this.Condition("container")),t},block(t=!1){return this.Block(t)}}},Gh={parse:{prelude:null,block(){return this.Block(!0)}}};function Ge(t,e){return this.parseWithFallback(()=>{try{return t.call(this)}finally{this.skipSC(),this.lookupNonWSType(0)!==T&&this.error()}},e||(()=>this.Raw(null,!0)))}const dr={layer(){this.skipSC();const t=this.createList(),e=Ge.call(this,this.Layer);return(e.type!=="Raw"||e.value!=="")&&t.push(e),t},supports(){this.skipSC();const t=this.createList(),e=Ge.call(this,this.Declaration,()=>Ge.call(this,()=>this.Condition("supports")));return(e.type!=="Raw"||e.value!=="")&&t.push(e),t}},qh={parse:{prelude(){const t=this.createList();switch(this.tokenType){case mt:t.push(this.String());break;case H:case P:t.push(this.Url());break;default:this.error("String or url() is expected")}return this.skipSC(),this.tokenType===b&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer")?t.push(this.Identifier()):this.tokenType===P&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer(")&&t.push(this.Function(null,dr)),this.skipSC(),this.tokenType===P&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&t.push(this.Function(null,dr)),(this.lookupNonWSType(0)===b||this.lookupNonWSType(0)===R)&&t.push(this.MediaQueryList()),t},block:null}},Qh={parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}},Kh={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(t=!1){return this.Block(t)}}},Yh={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}},Xh={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}},Jh={parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(t=!1){return this.Block(t)}}},Zh={parse:{prelude:null,block(t=!1){return this.Block(t)}}},tf={parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(t=!1){return this.Block(t)}}},ef={container:Hh,"font-face":Gh,import:qh,layer:Qh,media:Kh,nest:Yh,page:Xh,scope:Jh,"starting-style":Zh,supports:tf};function nf(){const t=this.createList();this.skipSC();t:for(;!this.eof;){switch(this.tokenType){case b:t.push(this.Identifier());break;case mt:t.push(this.String());break;case ot:t.push(this.Operator());break;case T:break t;default:this.error("Identifier, string or comma is expected")}this.skipSC()}return t}const wt={parse(){return this.createSingleNodeList(this.SelectorList())}},qe={parse(){return this.createSingleNodeList(this.Selector())}},rf={parse(){return this.createSingleNodeList(this.Identifier())}},sf={parse:nf},ce={parse(){return this.createSingleNodeList(this.Nth())}},of={dir:rf,has:wt,lang:sf,matches:wt,is:wt,"-moz-any":wt,"-webkit-any":wt,where:wt,not:wt,"nth-child":ce,"nth-last-child":ce,"nth-last-of-type":ce,"nth-of-type":ce,slotted:qe,host:qe,"host-context":qe},af=Object.freeze(Object.defineProperty({__proto__:null,AnPlusB:Xr,Atrule:Zr,AtrulePrelude:ei,AttributeSelector:ii,Block:ai,Brackets:ci,CDC:hi,CDO:pi,ClassSelector:gi,Combinator:yi,Comment:ki,Condition:Ci,Declaration:wi,DeclarationList:Li,Dimension:_i,Feature:Oi,FeatureFunction:Pi,FeatureRange:Ni,Function:Di,GeneralEnclosed:Mi,Hash:Bi,IdSelector:Vi,Identifier:zi,Layer:Gi,LayerList:Qi,MediaQuery:Yi,MediaQueryList:Ji,NestingSelector:ts,Nth:ns,Number:is,Operator:os,Parentheses:ls,Percentage:us,PseudoClassSelector:fs,PseudoElementSelector:ds,Ratio:ms,Raw:Ss,Rule:bs,Scope:vs,Selector:ws,SelectorList:Ls,String:Os,StyleSheet:Ps,SupportsDeclaration:Ns,TypeSelector:Ds,UnicodeRange:Bs,Url:Us,Value:Hs,WhiteSpace:qs},Symbol.toStringTag,{value:"Module"})),lf={parseContext:{default:"StyleSheet",stylesheet:"StyleSheet",atrule:"Atrule",atrulePrelude(t){return this.AtrulePrelude(t.atrule?String(t.atrule):null)},mediaQueryList:"MediaQueryList",mediaQuery:"MediaQuery",condition(t){return this.Condition(t.kind)},rule:"Rule",selectorList:"SelectorList",selector:"Selector",block(){return this.Block(!0)},declarationList:"DeclarationList",declaration:"Declaration",value:"Value"},features:{supports:{selector(){return this.Selector()}},container:{style(){return this.Declaration()}}},scope:Uh,atrule:ef,pseudo:of,node:af},cf=vh(lf);function ve(t){const e={};for(const n of Object.keys(t)){let r=t[n];r&&(Array.isArray(r)||r instanceof V?r=r.map(ve):r.constructor===Object&&(r=ve(r))),e[n]=r}return e}let uf="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",nt=(t=21)=>{let e="",n=t|0;for(;n--;)e+=uf[Math.random()*64|0];return e};const io=nt(),Yt=new Set;function xe(t){return!!(t&&t.type==="Function"&&t.name==="anchor")}function Ct(t,e=!1){return cf(t,{parseAtrulePrelude:!1,parseCustomProperty:!0,onParseError:n=>{e&&Yt.add(n)}})}function Q(t){return gh(t,{mode:"spec"})}function hf(t){return t.type==="Declaration"}function ff(t){return t.toArray().reduce((e,n)=>n.type==="Operator"&&n.value===","?(e.push([]),e):(n.type==="Identifier"&&e[e.length-1].push(n),e),[[]])}function an(t){return t?t.children.map(e=>{var i;let n;((i=e.children.last)==null?void 0:i.type)==="PseudoElementSelector"&&(e=ve(e),n=Q(e.children.last),e.children.pop());const r=Q(e);return{selector:r+(n??""),elementPart:r,pseudoElementPart:n}}).toArray():[]}function pf(){Yt.size>0&&(console.group(`The CSS anchor positioning polyfill was not applied due to ${Yt.size===1?"a CSS parse error":"CSS parse errors"}.`),Yt.forEach(t=>{console.warn(t.formattedMessage)}),console.groupEnd())}function df(){Yt.clear()}const ln=[...Xs,"anchor-scope","anchor-name"].reduce((t,e)=>(t[e]=`--${e}-${io}`,t),{});function gf(t,e){return hf(t)&&ln[t.property]&&e?(e.children.appendData({...t,property:ln[t.property]}),{updated:!0}):{}}function mf(t){for(const e of t){let n=!1;const r=Ct(e.css,!0);bt(r,{visit:"Declaration",enter(i){var l;const s=(l=this.rule)==null?void 0:l.block,{updated:a}=gf(i,s);a&&(n=!0)}}),n&&(e.css=Q(r),e.changed=!0)}return t.some(e=>e.changed===!0)}var so=(t=>(t.All="all",t.None="none",t))(so||{});function tt(t,e){return e=ln[e]??e,(t instanceof HTMLElement?getComputedStyle(t):t.computedStyle).getPropertyValue(e).trim()}function Ht(t,e,n){return tt(t,e)===n}function yf(t,{selector:e,pseudoElementPart:n}){const r=getComputedStyle(t,n),i=document.createElement("div"),s=document.createElement("style");i.id=`fake-pseudo-element-${nt()}`;for(const l of Array.from(r)){const u=r.getPropertyValue(l);i.style.setProperty(l,u)}s.textContent+=`#${i.id}${n} { content: ${r.content}; }`,s.textContent+=`${e} { display: none !important; }`,document.head.append(s);const a=n==="::before"?"afterbegin":"beforeend";return t.insertAdjacentElement(a,i),{fakePseudoElement:i,sheet:s,computedStyle:r}}function Sf(t){let e=t;for(;e;){if(Ht(e,"overflow","scroll"))return e;e=e.parentElement}return e}function kf(t){let e=Sf(t);return e===document.documentElement&&(e=null),e??{scrollTop:0,scrollLeft:0}}function bf(t){const{elementPart:e,pseudoElementPart:n}=t,r=[];if(n&&!(n==="::before"||n==="::after"))return r;const a=Array.from(document.querySelectorAll(e));if(!n)return r.push(...a),r;for(const l of a){const{fakePseudoElement:u,sheet:o,computedStyle:c}=yf(l,t),h=u.getBoundingClientRect(),{scrollY:g,scrollX:p}=globalThis,m=kf(l);r.push({fakePseudoElement:u,computedStyle:c,removeFakePseudoElement(){u.remove(),o.remove()},contextElement:l,getBoundingClientRect(){const{scrollY:C,scrollX:w}=globalThis,{scrollTop:S,scrollLeft:v}=m;return DOMRect.fromRect({y:h.y+(g-C)+(m.scrollTop-S),x:h.x+(p-w)+(m.scrollLeft-v),width:h.width,height:h.height})}})}return r}function Cf(t,e){const n=tt(t,"anchor-name");return e?n.split(",").map(r=>r.trim()).includes(e):!n}function vf(t,e){const n=tt(t,"anchor-scope");return n===e||n==="all"}const xn=async t=>{var n,r,i;let e=await((n=z.getOffsetParent)==null?void 0:n.call(z,t));return await((r=z.isElement)==null?void 0:r.call(z,e))||(e=await((i=z.getDocumentElement)==null?void 0:i.call(z,t))||window.document.documentElement),e},gr="InvalidMimeType";function xf(t){return!!((t.type==="text/css"||t.rel==="stylesheet")&&t.href)}function wf(t){const e=new URL(t.href,document.baseURI);if(xf(t)&&e.origin===location.origin)return e}async function Af(t){return(await Promise.all(t.map(async n=>{var r;if(!n.url)return n;if((r=n.el)!=null&&r.disabled)return null;try{const i=await fetch(n.url.toString()),s=i.headers.get("content-type");if(!(s!=null&&s.startsWith("text/css"))){const l=new Error(`Error loading ${n.url}: expected content-type "text/css", got "${s}".`);throw l.name=gr,l}const a=await i.text();return{...n,css:a}}catch(i){if(i instanceof Error&&i.name===gr)return console.warn(i),null;throw i}}))).filter(n=>n!==null)}const mr='[style*="anchor"]',yr='[style*="position-area"]';function Lf(t){const e=t?t.filter(r=>r instanceof HTMLElement&&(r.matches(mr)||r.matches(yr))):Array.from(document.querySelectorAll([mr,yr].join(","))),n=[];return e.filter(r=>r instanceof HTMLElement).forEach(r=>{const i=nt(12),s="data-has-inline-styles";r.setAttribute(s,i);const a=r.getAttribute("style"),l=`[${s}="${i}"] { ${a} }`;n.push({el:r,css:l})}),n}async function Tf(t,e){const n=t??Array.from(document.querySelectorAll("link, style")),r=[];n.filter(a=>a instanceof HTMLElement).forEach(a=>{if(a.tagName.toLowerCase()==="link"){const l=wf(a);l&&r.push({el:a,url:l})}a.tagName.toLowerCase()==="style"&&r.push({el:a,css:a.innerHTML})});const s=Lf(e?t??[]:void 0);return await Af([...r,...s])}const _f="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let oo=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=_f[n[t]&63];return e};const ao="--pa-cascade-property",lo="data-anchor-position-wrapper",co="data-pa-wrapper-for-",Sr="POLYFILL-POSITION-AREA",Ef=["left","center","right","span-left","span-right","x-start","x-end","span-x-start","span-x-end","x-self-start","x-self-end","span-x-self-start","span-x-self-end","span-all","top","bottom","span-top","span-bottom","y-start","y-end","span-y-start","span-y-end","y-self-start","y-self-end","span-y-self-start","span-y-self-end","block-start","block-end","span-block-start","span-block-end","inline-start","inline-end","span-inline-start","span-inline-end","self-block-start","self-block-end","span-self-block-start","span-self-block-end","self-inline-start","self-inline-end","span-self-inline-start","span-self-inline-end","start","end","span-start","span-end","self-start","self-end","span-self-start","span-self-end"];function uo(t){return Ef.includes(t)}const kr={left:[0,1,"Irrelevant"],center:[1,2,"Irrelevant"],right:[2,3,"Irrelevant"],"span-left":[0,2,"Irrelevant"],"span-right":[1,3,"Irrelevant"],"x-start":[0,1,"Physical"],"x-end":[2,3,"Physical"],"span-x-start":[0,2,"Physical"],"span-x-end":[1,3,"Physical"],"x-self-start":[0,1,"PhysicalSelf"],"x-self-end":[2,3,"PhysicalSelf"],"span-x-self-start":[0,2,"PhysicalSelf"],"span-x-self-end":[1,3,"PhysicalSelf"],"span-all":[0,3,"Irrelevant"],top:[0,1,"Irrelevant"],bottom:[2,3,"Irrelevant"],"span-top":[0,2,"Irrelevant"],"span-bottom":[1,3,"Irrelevant"],"y-start":[0,1,"Physical"],"y-end":[2,3,"Physical"],"span-y-start":[0,2,"Physical"],"span-y-end":[1,3,"Physical"],"y-self-start":[0,1,"PhysicalSelf"],"y-self-end":[2,3,"PhysicalSelf"],"span-y-self-start":[0,2,"PhysicalSelf"],"span-y-self-end":[1,3,"PhysicalSelf"],"block-start":[0,1,"Logical"],"block-end":[2,3,"Logical"],"span-block-start":[0,2,"Logical"],"span-block-end":[1,3,"Logical"],"inline-start":[0,1,"Logical"],"inline-end":[2,3,"Logical"],"span-inline-start":[0,2,"Logical"],"span-inline-end":[1,3,"Logical"],"self-block-start":[0,1,"LogicalSelf"],"self-block-end":[2,3,"LogicalSelf"],"span-self-block-start":[0,2,"LogicalSelf"],"span-self-block-end":[1,3,"LogicalSelf"],"self-inline-start":[0,1,"LogicalSelf"],"self-inline-end":[2,3,"LogicalSelf"],"span-self-inline-start":[0,2,"LogicalSelf"],"span-self-inline-end":[1,3,"LogicalSelf"],start:[0,1,"Logical"],end:[2,3,"Logical"],"span-start":[0,2,"Logical"],"span-end":[1,3,"Logical"],"self-start":[0,1,"LogicalSelf"],"self-end":[2,3,"LogicalSelf"],"span-self-start":[0,2,"LogicalSelf"],"span-self-end":[1,3,"LogicalSelf"]},Of=["left","center","right","span-left","span-right","x-start","x-end","span-x-start","span-x-end","x-self-start","x-self-end","span-x-self-start","span-x-self-end","span-all"],$f=["top","center","bottom","span-top","span-bottom","y-start","y-end","span-y-start","span-y-end","y-self-start","y-self-end","span-y-self-start","span-y-self-end","span-all"],Pf=["block-start","center","block-end","span-block-start","span-block-end","span-all"],If=["inline-start","center","inline-end","span-inline-start","span-inline-end","span-all"],Nf=["self-block-start","center","self-block-end","span-self-block-start","span-self-block-end","span-all"],Rf=["self-inline-start","center","self-inline-end","span-self-inline-start","span-self-inline-end","span-all"],br=["start","center","end","span-start","span-end","span-all"],Cr=["self-start","center","self-end","span-self-start","span-self-end","span-all"],Df=["block","top","bottom","y"],Ff=["inline","left","right","x"];function cn(t){const e=t.split("-");for(const n of e){if(Df.includes(n))return"block";if(Ff.includes(n))return"inline"}return"ambiguous"}function Mf(t,e){return e[0].includes(t[0])&&e[1].includes(t[1])||e[0].includes(t[1])&&e[1].includes(t[0])}const jf=[[Of,$f],[Pf,If],[Nf,Rf],[br,br],[Cr,Cr]];function Bf(t){for(const e of jf)if(Mf(t,e))return!0;return!1}const vr=t=>{const e=getComputedStyle(t);return{writingMode:e.writingMode,direction:e.direction}},Wf=async(t,e)=>{const n=await xn(t);switch(e){case"Logical":case"Physical":return vr(n);case"LogicalSelf":case"PhysicalSelf":return vr(t);default:return null}},Qe=t=>t.reverse().map(e=>3-e),ho=(t,e)=>t==="Irrelevant"?e:t,zf=async({block:t,inline:e},n)=>{const r=ho(t[2],e[2]),i=await Wf(n,r),s={block:[t[0],t[1]],inline:[e[0],e[1]]};if(i){if(i.direction==="rtl"&&(s.inline=Qe(s.inline)),i.writingMode.startsWith("vertical")){const a=s.block;s.block=s.inline,s.inline=a}if(i.writingMode.startsWith("sideways")){const a=s.block;s.block=s.inline,s.inline=a,i.writingMode.endsWith("lr")&&(s.block=Qe(s.block))}i.writingMode.endsWith("rl")&&(s.inline=Qe(s.inline))}return s},Uf=({block:t,inline:e})=>{const n=[0,"top","bottom",0],r=[0,"left","right",0];return{block:[n[t[0]],n[t[1]]],inline:[r[e[0]],r[e[1]]]}};function xr([t,e]){return t===0&&e===3?"center":t===0?"end":e===3?"start":"center"}function Vf(t){return t.type==="Declaration"&&t.property==="position-area"}function Hf(t){const e=t.value.children.toArray().map(({name:n})=>n);return e.length===1&&(cn(e[0])==="ambiguous"?e.push(e[0]):e.push("span-all")),e}function Gf(t){if(!Vf(t))return;const e=Hf(t);if(!Bf(e))return;const n={};switch(cn(e[0])){case"block":n.block=e[0],n.inline=e[1];break;case"inline":n.inline=e[0],n.block=e[1];break;case"ambiguous":cn(e[1])=="block"?(n.block=e[1],n.inline=e[0]):(n.inline=e[1],n.block=e[0]);break}const r={block:kr[n.block],inline:kr[n.inline]},i=`--pa-declaration-${oo(12)}`;return{values:n,grid:r,selectorUUID:i}}function qf(t,e){["justify-self","align-self"].forEach(n=>{e.children.appendData({type:"Declaration",property:n,value:{type:"Raw",value:`var(--pa-value-${n})`},important:!1})}),e.children.appendData({type:"Declaration",property:ao,value:{type:"Raw",value:t.selectorUUID},important:!1})}function Qf(t,e){var r,i;let n;if(((r=t.parentElement)==null?void 0:r.tagName)===Sr)n=t.parentElement;else{n=document.createElement(Sr),n.style.display="grid",n.style.position="absolute";const s=getComputedStyle(t).pointerEvents;n.style.pointerEvents="none",t.style.pointerEvents=s,["top","left","right","bottom"].forEach(a=>{n.style.setProperty(a,`var(--pa-value-${a})`)}),(i=t.parentElement)==null||i.insertBefore(n,t),n.appendChild(t)}return n.setAttribute(`${co}${e}`,""),n}async function Kf(t,e,n){const r=`--pa-target-${oo(12)}`,i=await zf(e.grid,t),s=Uf(i),a=ho(e.grid.block[2],e.grid.inline[2]),l=["LogicalSelf","PhysicalSelf"].includes(a)?i:e.grid,u={block:xr([l.block[0],l.block[1]]),inline:xr([l.inline[0],l.inline[1]])};return{insets:s,alignments:u,targetUUID:r,targetEl:t,anchorEl:n,wrapperEl:Qf(t,r),values:e.values,grid:e.grid,selectorUUID:e.selectorUUID}}function Yf(t,e){return`
[${lo}="${e}"][${co}${t}] {
--pa-value-top: var(${t}-top);
--pa-value-left: var(${t}-left);
--pa-value-right: var(${t}-right);
--pa-value-bottom: var(${t}-bottom);
--pa-value-justify-self: var(${t}-justify-self);
--pa-value-align-self: var(${t}-align-self);
}
`.replaceAll(`
`,"")}const Xf=["normal","most-width","most-height","most-block-size","most-inline-size"],Jf=["flip-block","flip-inline","flip-start"];function Zf(t){return t.type==="Declaration"}function tp(t){return t.type==="Declaration"&&t.property==="position-try-fallbacks"}function ep(t){return t.type==="Declaration"&&t.property==="position-try-order"}function np(t){return t.type==="Declaration"&&t.property==="position-try"}function rp(t){return t.type==="Atrule"&&t.name==="position-try"}function ip(t){return Jf.includes(t)}function sp(t){return Xf.includes(t)}function op(t,e){const n=document.querySelector(t);if(n){let r=lp(n);return e.forEach(i=>{r=fo(r,i)}),r}}function ap(t,e){let n=t.declarations;return e.forEach(r=>{n=fo(n,r)}),n}function lp(t){const e={};return Xs.forEach(n=>{const r=tt(t,`--${n}-${io}`);r&&(e[n]=r)}),e}const cp={"flip-block":{top:"bottom",bottom:"top","inset-block-start":"inset-block-end","inset-block-end":"inset-block-start","margin-top":"margin-bottom","margin-bottom":"margin-top"},"flip-inline":{left:"right",right:"left","inset-inline-start":"inset-inline-end","inset-inline-end":"inset-inline-start","margin-left":"margin-right","margin-right":"margin-left"},"flip-start":{left:"top",right:"bottom",top:"left",bottom:"right","inset-block-start":"inset-block-end","inset-block-end":"inset-block-start","inset-inline-start":"inset-inline-end","inset-inline-end":"inset-inline-start","inset-block":"inset-inline","inset-inline":"inset-block"}},up={"flip-block":{top:"bottom",bottom:"top",start:"end",end:"start","self-end":"self-start","self-start":"self-end"},"flip-inline":{left:"right",right:"left",start:"end",end:"start","self-end":"self-start","self-start":"self-end"},"flip-start":{top:"left",left:"top",right:"bottom",bottom:"right"}},hp={"flip-block":{top:"bottom",bottom:"top",start:"end",end:"start"},"flip-inline":{left:"right",right:"left",start:"end",end:"start"},"flip-start":{}};function fp(t,e){return cp[e][t]||t}function pp(t,e){return up[e][t]||t}function dp(t,e){if(e==="flip-start")return t;{const n=hp[e];return t.split("-").map(r=>n[r]||r).join("-")}}function gp(t,e,n){if(t==="margin"){const[r,i,s,a]=e.children.toArray();n==="flip-block"?a?e.children.fromArray([s,i,r,a]):s&&e.children.fromArray([s,i,r]):n==="flip-inline"&&a&&e.children.fromArray([r,a,s,i])}else if(t==="margin-block"){const[r,i]=e.children.toArray();n==="flip-block"&&i&&e.children.fromArray([i,r])}else if(t==="margin-inline"){const[r,i]=e.children.toArray();n==="flip-inline"&&i&&e.children.fromArray([i,r])}}const mp=(t,e)=>{var i;return((i=Ct(`#id{${t}: ${e};}`).children.first)==null?void 0:i.block.children.first).value};function fo(t,e){const n={};return Object.entries(t).forEach(([r,i])=>{const s=r,a=mp(s,i),l=fp(s,e);l!==s&&(n[s]??(n[s]="revert")),bt(a,{visit:"Function",enter(u){xe(u)&&u.children.forEach(o=>{Xt(o)&&Zs(o.name)&&(o.name=pp(o.name,e))})}}),s==="position-area"&&a.children.forEach(u=>{Xt(u)&&uo(u.name)&&(u.name=dp(u.name,e))}),s.startsWith("margin")&&gp(s,a,e),n[l]=Q(a)}),n}function po(t){const e=ff(t),n=[];return e.forEach(r=>{const i={atRules:[],tactics:[],positionAreas:[]};r.forEach(s=>{ip(s.name)?i.tactics.push(s.name):s.name.startsWith("--")?i.atRules.push(s.name):uo(s.name)&&i.positionAreas.push(s.name)}),i.positionAreas.length?n.push({positionArea:i.positionAreas[0],type:"position-area"}):i.atRules.length&&i.tactics.length?n.push({tactics:i.tactics,atRule:i.atRules[0],type:"at-rule-with-try-tactic"}):i.atRules.length?n.push({atRule:i.atRules[0],type:"at-rule"}):i.tactics.length&&n.push({tactics:i.tactics,type:"try-tactic"})}),n}function yp(t){return tp(t)&&t.value.children.first?po(t.value.children):[]}function Sp(t){if(np(t)&&t.value.children.first){const e=ve(t);let n;const r=e.value.children.first.name;r&&sp(r)&&(n=r,e.value.children.shift());const i=po(e.value.children);return{order:n,options:i}}return{}}function kp(t){return ep(t)&&t.value.children.first?{order:t.value.children.first.name}:{}}function bp(t){const{order:e,options:n}=Sp(t);if(e||n)return{order:e,options:n};const{order:r}=kp(t),i=yp(t);return r||i?{order:r,options:i}:{}}function Cp(t){return ee(t.property)||Gu(t.property)||Ks(t.property)||qu(t.property)||["position-anchor","position-area"].includes(t.property)}function vp(t){var e,n;if(rp(t)&&((e=t.prelude)!=null&&e.value)&&((n=t.block)!=null&&n.children)){const r=t.prelude.value,i=t.block.children.filter(a=>Zf(a)&&Cp(a)),s={uuid:`${r}-try-${nt(12)}`,declarations:Object.fromEntries(i.map(a=>[a.property,Q(a.value)]))};return{name:r,tryBlock:s}}return{}}function xp(t){const e={},n={},r={};for(const i of t){const s=Ct(i.css);bt(s,{visit:"Atrule",enter(a){const{name:l,tryBlock:u}=vp(a);l&&u&&(e[l]=u)}})}for(const i of t){let s=!1;const a=new Set,l=Ct(i.css);bt(l,{visit:"Declaration",enter(u){var m;const o=(m=this.rule)==null?void 0:m.prelude,c=an(o);if(!c.length)return;const{order:h,options:g}=bp(u),p={};h&&(p.order=h),c.forEach(({selector:C})=>{var w;g==null||g.forEach(S=>{var A;let v;if(S.type==="at-rule")v=S.atRule;else if(S.type==="try-tactic"){v=`${C}-${S.tactics.join("-")}`;const x=op(C,S.tactics);x&&(e[v]={uuid:`${C}-${S.tactics.join("-")}-try-${nt(12)}`,declarations:x})}else if(S.type==="at-rule-with-try-tactic"){v=`${C}-${S.atRule}-${S.tactics.join("-")}`;const x=e[S.atRule],$=ap(x,S.tactics);$&&(e[v]={uuid:`${C}-${S.atRule}-${S.tactics.join("-")}-try-${nt(12)}`,declarations:$})}if(v&&e[v]){const x=`[data-anchor-polyfill="${e[v].uuid}"]`;n[x]??(n[x]=[]),n[x].push(C),a.has(v)||(p.fallbacks??(p.fallbacks=[]),p.fallbacks.push(e[v]),a.add(v),(A=this.stylesheet)==null||A.children.prependData({type:"Rule",prelude:{type:"Raw",value:x},block:{type:"Block",children:new V().fromArray(Object.entries(e[v].declarations).map(([$,O])=>({type:"Declaration",important:!0,property:$,value:{type:"Raw",value:O}})))}}),s=!0)}}),Object.keys(p).length>0&&(r[C]?(p.order&&(r[C].order=p.order),p.fallbacks&&((w=r[C]).fallbacks??(w.fallbacks=[]),r[C].fallbacks.push(...p.fallbacks))):r[C]=p)})}}),s&&(i.css=Q(l),i.changed=!0)}return{fallbackTargets:n,validPositions:r}}function wp(t,e){return!t||t===e?!1:go(t)?t.document.contains(e):t.contains(e)}function go(t){return!!(t&&t===t.window)}function Ap(t){return Ht(t,"position","fixed")}function un(t){return!!(t&&(Ap(t)||Ht(t,"position","absolute")))}function wr(t,e){return t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING}async function Lp(t){return await z.getOffsetParent(t)}async function Ke(t){if(!["absolute","fixed"].includes(tt(t,"position")))return await Lp(t);let e=t.parentElement;for(;e;){if(!Ht(e,"position","static")&&Ht(e,"display","block"))return e;e=e.parentElement}return window}async function Tp(t,e,n,r){const i=await Ke(t),s=await Ke(n);if(!(wp(s,t)||go(s))||i===s&&!(!un(t)||wr(t,n)))return!1;if(i!==s){let a;const l=[];for(a=i;a&&a!==s&&a!==window;)l.push(a),a=await Ke(a);const u=l[l.length-1];if(u instanceof HTMLElement&&!(!un(u)||wr(u,n)))return!1}{let a=t.parentElement;for(;a;){if(Ht(a,"content-visibility","hidden"))return!1;a=a.parentElement}}return!(e&&r&&Ar(t,e,r)!==Ar(n,e,r))}function Ar(t,e,n){for(;!(t.matches(n)&&vf(t,e));){if(!t.parentElement)return null;t=t.parentElement}return t}async function _p(t,e,n,r){if(!(t instanceof HTMLElement&&n.length&&un(t)))return null;const i=n.flatMap(bf).filter(a=>Cf(a,e)),s=r.map(a=>a.selector).join(",")||null;for(let a=i.length-1;a>=0;a--){const l=i[a],u="fakePseudoElement"in l;if(await Tp(u?l.fakePseudoElement:l,e,t,s))return u&&l.removeFakePseudoElement(),l}return null}function Ep(t){return t.type==="Declaration"&&t.property==="anchor-name"}function Op(t){return t.type==="Declaration"&&t.property==="anchor-scope"}function hn(t){return!!(t&&t.type==="Function"&&t.name==="anchor-size")}function ge(t){return!!(t&&t.type==="Function"&&t.name==="var")}function Xt(t){return!!(t.type==="Identifier"&&t.name)}function $p(t){return!!(t.type==="Percentage"&&t.value)}function Lr(t,e){let n,r,i,s="",a=!1,l;const u=[];t.children.toArray().forEach(g=>{if(a){s=`${s}${Q(g)}`;return}if(g.type==="Operator"&&g.value===","){a=!0;return}u.push(g)});let[o,c]=u;if(c||(c=o,o=void 0),o&&(Xt(o)&&o.name.startsWith("--")?n=o.name:ge(o)&&o.children.first&&(l=o.children.first.name)),c)if(xe(t)){if(Xt(c)&&Zs(c.name))r=c.name;else if($p(c)){const g=Number(c.value);r=Number.isNaN(g)?void 0:g}}else hn(t)&&Xt(c)&&Xu(c.name)&&(i=c.name);const h=`--anchor-${nt(12)}`;return Object.assign(t,{type:"Raw",value:`var(${h})`,children:null}),Reflect.deleteProperty(t,"name"),{anchorName:n,anchorSide:r,anchorSize:i,fallbackValue:s||"0px",customPropName:l,uuid:h}}function Tr(t){return t.value.children.map(({name:e})=>e)}let Ft={},kt={},Tt={},Jt={},Lt={};function Pp(){Ft={},kt={},Tt={},Jt={},Lt={}}function Ip(t,e){if((xe(t)||hn(t))&&e){if(e.property.startsWith("--")){const n=Q(e.value),r=Lr(t);return Jt[r.uuid]=n,Tt[e.property]=[...Tt[e.property]??[],r],{changed:!0}}if(xe(t)&&ee(e.property)||hn(t)&&Js(e.property)){const n=Lr(t);return{prop:e.property,data:n,changed:!0}}}return{}}async function _r(t,e){let n=e==null?void 0:e.anchorName;const r=e==null?void 0:e.customPropName;if(t&&!n){const l=tt(t,"position-anchor");l?n=l:r&&(n=tt(t,r))}const i=n?Ft[n]||[]:[],s=n?kt[so.All]||[]:[],a=n?kt[n]||[]:[];return await _p(t,n||null,i,[...s,...a])}async function Np(t){var c,h,g,p,m,C,w;const e={},n={};Pp();const{fallbackTargets:r,validPositions:i}=xp(t);for(const S of t){let v=!1;const A=Ct(S.css);bt(A,function(x){var y,B;const $=(y=this.rule)==null?void 0:y.prelude,O=an($);if(Ep(x)&&O.length)for(const E of Tr(x))Ft[E]??(Ft[E]=[]),Ft[E].push(...O);if(Op(x)&&O.length)for(const E of Tr(x))kt[E]??(kt[E]=[]),kt[E].push(...O);const{prop:L,data:f,changed:d}=Ip(x,this.declaration);if(L&&f&&O.length)for(const{selector:E}of O)e[E]={...e[E],[L]:[...((B=e[E])==null?void 0:B[L])??[],f]};let k;if(this.block&&(k=Gf(x),k)){qf(k,this.block);for(const{selector:E}of O)n[E]=[...n[E]??[],k]}(d||k)&&(v=!0)}),v&&(S.css=Q(A),S.changed=!0)}const s=new Set(Object.keys(Tt)),a={},l=S=>{var x,$,O;const v=[],A=new Set(((x=a[S])==null?void 0:x.names)??[]);for(;A.size>0;)for(const L of A)v.push(...Tt[L]??[]),A.delete(L),(O=($=a[L])==null?void 0:$.names)!=null&&O.length&&a[L].names.forEach(f=>A.add(f));return v};for(;s.size>0;){const S=[];for(const v of t){let A=!1;const x=Ct(v.css);bt(x,{visit:"Function",enter($){var d;const O=(d=this.rule)==null?void 0:d.prelude,L=this.declaration,f=L==null?void 0:L.property;if((O==null?void 0:O.children.isEmpty)===!1&&ge($)&&L&&f&&$.children.first&&s.has($.children.first.name)&&f.startsWith("--")){const k=$.children.first,y=Tt[k.name]??[],B=l(k.name);if(!(y.length||B.length))return;const E=`${k.name}-anchor-${nt(12)}`,dt=Q(L.value);Jt[E]=dt,a[f]||(a[f]={names:[],uuids:[]});const F=a[f];F.names.includes(k.name)||F.names.push(k.name),F.uuids.push(E),S.push(f),k.name=E,A=!0}}}),A&&(v.css=Q(x),v.changed=!0)}s.clear(),S.forEach(v=>s.add(v))}for(const S of t){let v=!1;const A=Ct(S.css);bt(A,{visit:"Function",enter(x){var f,d,k,y,B;const $=(f=this.rule)==null?void 0:f.prelude,O=this.declaration,L=O==null?void 0:O.property;if(($==null?void 0:$.children.isEmpty)===!1&&ge(x)&&O&&L&&x.children.first&&(ee(L)||Ks(L))){const E=x.children.first,dt=Tt[E.name]??[],F=l(E.name);if(!(dt.length||F.length))return;const gt=`${L}-${nt(12)}`;if(F.length){const $t=new Set([E.name]);for(;$t.size>0;)for(const Pt of $t){const U=a[Pt];if((d=U==null?void 0:U.names)!=null&&d.length&&((k=U==null?void 0:U.uuids)!=null&&k.length))for(const It of U.names)for(const Nt of U.uuids)Lt[Nt]={...Lt[Nt],[gt]:`${It}-${gt}`};$t.delete(Pt),(y=U==null?void 0:U.names)!=null&&y.length&&U.names.forEach(It=>$t.add(It))}}const xt=an($);for(const $t of[...dt,...F]){const Pt={...$t},U=`--anchor-${nt(12)}-${L}`,It=Pt.uuid;Pt.uuid=U;for(const{selector:Nt}of xt)e[Nt]={...e[Nt],[L]:[...((B=e[Nt])==null?void 0:B[L])??[],Pt]};Lt[It]={...Lt[It],[gt]:U}}E.name=`${E.name}-${gt}`,v=!0}}}),v&&(S.css=Q(A),S.changed=!0)}if(Object.keys(Lt).length>0)for(const S of t){let v=!1;const A=Ct(S.css);bt(A,{visit:"Function",enter(x){var $,O,L,f;if(ge(x)&&((O=($=x.children.first)==null?void 0:$.name)!=null&&O.startsWith("--"))&&((f=(L=this.declaration)==null?void 0:L.property)!=null&&f.startsWith("--"))&&this.block){const d=x.children.first,k=Lt[d.name];if(k)for(const[y,B]of Object.entries(k))this.block.children.appendData({type:"Declaration",important:!1,property:`${this.declaration.property}-${y}`,value:{type:"Raw",value:Q(this.declaration.value).replace(`var(${d.name})`,`var(${B})`)}}),v=!0;Jt[d.name]&&(this.declaration.value={type:"Raw",value:Jt[d.name]},v=!0)}}}),v&&(S.css=Q(A),S.changed=!0)}const u=new Map;for(const[S,v]of Object.entries(e)){let A;S.startsWith("[data-anchor-polyfill=")&&((c=r[S])!=null&&c.length)?A=document.querySelectorAll(r[S].join(",")):A=document.querySelectorAll(S);for(const[x,$]of Object.entries(v))for(const O of $)for(const L of A){const f=await _r(L,O),d=`--anchor-${nt(12)}`;u.set(L,{...u.get(L)??{},[O.uuid]:d}),L.setAttribute("style",`${O.uuid}: var(${d}); ${L.getAttribute("style")??""}`),i[S]={...i[S],declarations:{...(h=i[S])==null?void 0:h.declarations,[x]:[...((p=(g=i[S])==null?void 0:g.declarations)==null?void 0:p[x])??[],{...O,anchorEl:f,targetEl:L,uuid:d}]}}}}const o={el:document.createElement("link"),changed:!1,created:!0,css:""};t.push(o);for(const[S,v]of Object.entries(n)){const A=document.querySelectorAll(S);for(const x of A){const $=await _r(x);for(const O of v){const L=await Kf(x,O,$);o.css+=Yf(L.targetUUID,O.selectorUUID),o.changed=!0,i[S]={...i[S],declarations:{...(m=i[S])==null?void 0:m.declarations,"position-area":[...((w=(C=i[S])==null?void 0:C.declarations)==null?void 0:w["position-area"])??[],L]}}}}}return{rules:i,inlineStyles:u,anchorScopes:kt}}const Rp=["as","blocking","crossorigin","disabled","fetchpriority","href","hreflang","integrity","referrerpolicy","rel","type"];function Er(t,e,n=!1){const r=[];for(const{el:i,css:s,changed:a,created:l=!1}of t){const u={el:i,css:s,changed:!1};if(a){if(i.tagName.toLowerCase()==="style")i.innerHTML=s;else if(i instanceof HTMLLinkElement){const o=document.createElement("style");o.textContent=s;for(const c of i.getAttributeNames())if(!c.startsWith("on")&&!Rp.includes(c)){const h=i.getAttribute(c);h!==null&&o.setAttribute(c,h)}i.hasAttribute("href")&&o.setAttribute("data-original-href",i.getAttribute("href")),l?(o.setAttribute("data-generated-by-polyfill","true"),document.head.insertAdjacentElement("beforeend",o)):(i.insertAdjacentElement("beforebegin",o),i.remove()),u.el=o}else if(i.hasAttribute("data-has-inline-styles")){const o=i.getAttribute("data-has-inline-styles");if(o){const c=`[data-has-inline-styles="${o}"]{`;let g=s.slice(c.length,0-"}".length);const p=e==null?void 0:e.get(i);if(p)for(const[m,C]of Object.entries(p))g=`${m}: var(${C}); ${g}`;i.setAttribute("style",g)}}}n&&i.hasAttribute("data-has-inline-styles")&&i.removeAttribute("data-has-inline-styles"),r.push(u)}return r}const Dp={...z,_c:new Map},Fp=(t,e)=>{let n;switch(t){case"start":case"self-start":n=0;break;case"end":case"self-end":n=100;break;default:typeof t=="number"&&!Number.isNaN(t)&&(n=t)}if(n!==void 0)return e?100-n:n},Mp=(t,e)=>{let n;switch(t){case"block":case"self-block":n=e?"width":"height";break;case"inline":case"self-inline":n=e?"height":"width";break}return n},Or=t=>{switch(t){case"top":case"bottom":return"y";case"left":case"right":return"x"}return null},jp=t=>{switch(t){case"x":return"width";case"y":return"height"}return null},$r=t=>tt(t,"display")==="inline",Pr=(t,e)=>(e==="x"?["border-left-width","border-right-width"]:["border-top-width","border-bottom-width"]).reduce((r,i)=>r+parseInt(tt(t,i),10),0)||0,ue=(t,e)=>parseInt(tt(t,`margin-${e}`),10)||0,Bp=t=>({top:ue(t,"top"),right:ue(t,"right"),bottom:ue(t,"bottom"),left:ue(t,"left")}),Ye=async({targetEl:t,targetProperty:e,anchorRect:n,anchorSide:r,anchorSize:i,fallback:s=null})=>{var a;if(!((i||r!==void 0)&&t&&n))return s;if(i){if(!Js(e))return s;let l;switch(i){case"width":case"height":l=i;break;default:{let u=!1;const o=tt(t,"writing-mode");u=o.startsWith("vertical-")||o.startsWith("sideways-"),l=Mp(i,u)}}return l?`${n[l]}px`:s}if(r!==void 0){let l,u;const o=Or(e);if(!(ee(e)&&o&&(!ee(r)||o===Or(r))))return s;const c=["top","left"];switch(r){case"left":case"top":l=0;break;case"right":case"bottom":l=100;break;case"center":l=50;break;case"inside":l=c.includes(e)?0:100;break;case"outside":l=c.includes(e)?100:0;break;default:if(t){const p=await((a=z.isRTL)==null?void 0:a.call(z,t))||!1;l=Fp(r,p)}}const h=typeof l=="number"&&!Number.isNaN(l),g=jp(o);if(h&&g){(e==="bottom"||e==="right")&&(u=await xn(t));let p=n[o]+n[g]*(l/100);switch(e){case"bottom":{if(!u)break;let m=u.clientHeight;if(m===0&&$r(u)){const C=Pr(u,o);m=u.offsetHeight-C}p=m-p;break}case"right":{if(!u)break;let m=u.clientWidth;if(m===0&&$r(u)){const C=Pr(u,o);m=u.offsetWidth-C}p=m-p;break}}return`${p}px`}}return s},Wp=t=>"wrapperEl"in t,zp=t=>"uuid"in t;async function Up(t,e=!1){const n=document.documentElement;for(const[r,i]of Object.entries(t))for(const s of i){const a=s.anchorEl,l=s.targetEl;if(a&&l)if(Wp(s)){const u=s.wrapperEl,o=async(c,h,g)=>c===0?"0px":await Ye({targetEl:u,targetProperty:h,anchorRect:g,anchorSide:c});Ze(a,u,async()=>{const c=tt(l,ao);u.setAttribute(lo,c);const h=await z.getElementRects({reference:a,floating:u,strategy:"absolute"}),g=s.insets,p=await o(g.block[0],"top",h.reference),m=await o(g.block[1],"bottom",h.reference),C=await o(g.inline[0],"left",h.reference),w=await o(g.inline[1],"right",h.reference);n.style.setProperty(`${s.targetUUID}-top`,p||null),n.style.setProperty(`${s.targetUUID}-left`,C||null),n.style.setProperty(`${s.targetUUID}-right`,w||null),n.style.setProperty(`${s.targetUUID}-bottom`,m||null),n.style.setProperty(`${s.targetUUID}-justify-self`,s.alignments.inline),n.style.setProperty(`${s.targetUUID}-align-self`,s.alignments.block)},{animationFrame:e})}else Ze(a,l,async()=>{const u=await z.getElementRects({reference:a,floating:l,strategy:"absolute"}),o=await Ye({targetEl:l,targetProperty:r,anchorRect:u.reference,anchorSide:s.anchorSide,anchorSize:s.anchorSize,fallback:s.fallbackValue});n.style.setProperty(s.uuid,o)},{animationFrame:e});else if(zp(s)){const u=await Ye({targetProperty:r,anchorSide:s.anchorSide,anchorSize:s.anchorSize,fallback:s.fallbackValue});n.style.setProperty(s.uuid,u)}}}async function Ir(t,e){const n=await z.getElementRects({reference:t,floating:t,strategy:"absolute"});return await Do({x:t.offsetLeft,y:t.offsetTop,platform:Dp,rects:n,elements:{floating:t,reference:e},strategy:"absolute"},{padding:Bp(t)})}async function Vp(t,e,n=!1){if(!e.length)return;const r=document.querySelectorAll(t);for(const i of r){let s=!1;const a=await xn(i);Ze({},i,async()=>{if(s)return;s=!0,i.removeAttribute("data-anchor-polyfill");const l=await Ir(i,a);if(Object.values(l).every(u=>u<=0)){i.removeAttribute("data-anchor-polyfill-last-successful"),s=!1;return}for(const[u,{uuid:o}]of e.entries()){i.setAttribute("data-anchor-polyfill",o);const c=await Ir(i,a);if(Object.values(c).every(h=>h<=0)){i.setAttribute("data-anchor-polyfill-last-successful",o),s=!1;break}if(u===e.length-1){const h=i.getAttribute("data-anchor-polyfill-last-successful");h?i.setAttribute("data-anchor-polyfill",h):i.removeAttribute("data-anchor-polyfill"),s=!1;break}}},{animationFrame:n,layoutShift:!1})}}async function Hp(t,e=!1){for(const n of Object.values(t))await Up(n.declarations??{},e);for(const[n,r]of Object.entries(t))await Vp(n,r.fallbacks??[],e)}function Gp(t={}){const e=typeof t=="boolean"?{useAnimationFrame:t}:t,n=e.useAnimationFrame===void 0?!!window.UPDATE_ANCHOR_ON_ANIMATION_FRAME:e.useAnimationFrame;return Array.isArray(e.elements)||(e.elements=void 0),Object.assign(e,{useAnimationFrame:n})}async function qp(t){const e=Gp(t??window.ANCHOR_POSITIONING_POLYFILL_OPTIONS);let n=await Tf(e.elements,e.excludeInlineStyles),r={},i;df();try{mf(n)&&(n=Er(n));const a=await Np(n);r=a.rules,i=a.inlineStyles}catch(s){throw pf(),s}return Object.values(r).length&&(Er(n,i,!0),await Hp(r,e.useAnimationFrame)),r}export{qp as p};