const S="ͼ",c=typeof Symbol>"u"?"__"+S:Symbol.for(S),y=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),g=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class x{constructor(e,s){this.rules=[];let{finish:h}=s||{};function l(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function i(t,n,a,T){let f=[],d=/^@(\w+)\b/.exec(t[0]),m=d&&d[1]=="keyframes";if(d&&n==null)return a.push(t[0]+";");for(let u in n){let o=n[u];if(/&/.test(u))i(u.split(/,\s*/).map(r=>t.map(p=>r.replace(/&/,p))).reduce((r,p)=>r.concat(p)),o,a);else if(o&&typeof o=="object"){if(!d)throw new RangeError("The value of a property ("+u+") should be a primitive value.");i(l(u),o,f,m)}else o!=null&&f.push(u.replace(/_.*/,"").replace(/[A-Z]/g,r=>"-"+r.toLowerCase())+": "+o+";")}(f.length||m)&&a.push((h&&!d&&!T?t.map(h):t).join(", ")+" {"+f.join(" ")+"}")}for(let t in e)i(l(t),e[t],this.rules)}getRules(){return this.rules.join(`
`)}static newName(){let e=g[c]||1;return g[c]=e+1,S+e.toString(36)}static mount(e,s){(e[y]||new C(e)).mount(Array.isArray(s)?s:[s])}}let w=new Map;class C{constructor(e){let s=e.ownerDocument||e,h=s.defaultView;if(!e.head&&e.adoptedStyleSheets&&h.CSSStyleSheet){let l=w.get(s);if(l)return e.adoptedStyleSheets=[l.sheet,...e.adoptedStyleSheets],e[y]=l;this.sheet=new h.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],w.set(s,this)}else{this.styleTag=s.createElement("style");let l=e.head||e;l.insertBefore(this.styleTag,l.firstChild)}this.modules=[],e[y]=this}mount(e){let s=this.sheet,h=0,l=0;for(let i=0;i<e.length;i++){let t=e[i],n=this.modules.indexOf(t);if(n<l&&n>-1&&(this.modules.splice(n,1),l--,n=-1),n==-1){if(this.modules.splice(l++,0,t),s)for(let a=0;a<t.rules.length;a++)s.insertRule(t.rules[a],h++)}else{for(;l<n;)h+=this.modules[l++].rules.length;h+=t.rules.length,l++}}if(!s){let i="";for(let t=0;t<this.modules.length;t++)i+=this.modules[t].getRules()+`
`;this.styleTag.textContent=i}}}export{x as S};
