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