const e=require("../../StyleContext.js"),t=require("../../../../node_modules/.pnpm/@emotion_hash@0.9.2/node_modules/@emotion/hash/dist/emotion-hash.esm.js"),n=require("../../../canUseDom.js"),r=require("../../../../vc-util/Dom/dynamicCSS.js"),i=require("../../util.js"),a=require("../useGlobalCache.js"),o=require("../../../../node_modules/.pnpm/@emotion_unitless@0.10.0/node_modules/@emotion/unitless/dist/emotion-unitless.esm.js"),s=require("../../../../node_modules/.pnpm/stylis@4.3.6/node_modules/stylis/src/Parser.js"),c=require("../../../../node_modules/.pnpm/stylis@4.3.6/node_modules/stylis/src/Serializer.js"),l=require("./cacheMapUtil.js");let u=require("vue");var d=n.default(),f=`_skip_check_`,p=`_multi_value_`;function m(e){return c.serialize(s.compile(e),c.stringify).replace(/\{%%%:[^;];\}/g,`;`)}function h(e){return typeof e==`object`&&e&&(f in e||p in e)}function g(e,t,n){if(!t)return e;let r=`.${t}`,i=n===`low`?`:where(${r})`:r;return e.split(`,`).map(e=>{let t=e.trim().split(/\s+/),n=t[0]||``,r=n.match(/^\w+/)?.[0]||``;return n=`${r}${i}${n.slice(r.length)}`,[n,...t.slice(1)].join(` `)}).join(`,`)}var _=new Set,v=(e,t={},{root:n,injectHash:r,parentSelectors:a}={root:!0,parentSelectors:[]})=>{let{hashId:s,layer:c,path:l,hashPriority:u,transformers:d=[],linters:f=[]}=t,m=``,_={};function y(e){let n=e.getName(s);if(!_[n]){let[r]=v(e.style,t,{root:!1,parentSelectors:a});_[n]=`@keyframes ${e.getName(s)}${r}`}}function b(e,t=[]){return e.forEach(e=>{Array.isArray(e)?b(e,t):e&&t.push(e)}),t}if(b(Array.isArray(e)?e:[e]).forEach(e=>{let i=typeof e==`string`&&!n?{}:e;if(typeof i==`string`)m+=`${i}\n`;else if(i._keyframe)y(i);else{let e=d.reduce((e,t)=>t?.visit?.(e)||e,i);Object.keys(e).forEach(i=>{let c=e[i];if(typeof c==`object`&&c&&(i!==`animationName`||!c._keyframe)&&!h(c)){let e=!1,o=i.trim(),l=!1;(n||r)&&s?o.startsWith(`@`)?e=!0:o=g(i,s,u):n&&!s&&(o===`&`||o===``)&&(o=``,l=!0);let[d,f]=v(c,t,{root:l,injectHash:e,parentSelectors:[...a,o]});_={..._,...f},m+=`${o}${d}`}else{function l(e,t){let n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),r=t;!o.default[e]&&typeof r==`number`&&r!==0&&(r=`${r}px`),e===`animationName`&&t?._keyframe&&(y(t),r=t.getName(s)),m+=`${n}:${r};`}let e=c?.value??c;typeof c==`object`&&c?.[p]&&Array.isArray(e)?e.forEach(e=>{l(i,e)}):l(i,e)}})}}),!n)m=`{${m}}`;else if(c&&i.supportLayer()){let e=c.split(`,`);m=`@layer ${e[e.length-1].trim()} {${m}}`,e.length>1&&(m=`@layer ${c}{%%%:%}${m}`)}return[m,_]};function y(e,n){return t.default(`${e.join(`%`)}${n}`)}function b(t,n){let i=e.useStyleInject(),o=(0,u.computed)(()=>t.value.token._tokenKey),s=(0,u.computed)(()=>[o.value,...t.value.path]),c=d;return a.default(`style`,s,()=>{let{path:a,hashId:u,layer:d,nonce:f,clientOnly:p,order:h=0}=t.value,g=s.value.join(`|`);if(l.existPath(g)){let[e,t]=l.getStyleAndHash(g);if(e)return[e,o.value,t,{},p,h]}let b=n(),{hashPriority:x,container:S,transformers:C,linters:w,cache:T}=i.value,[E,D]=v(b,{hashId:u,hashPriority:x,layer:d,path:a.join(`-`),transformers:C,linters:w}),O=m(E),k=y(s.value,O);if(c){let t={mark:e.ATTR_MARK,prepend:`queue`,attachTo:S,priority:h},n=typeof f==`function`?f():f;n&&(t.csp={nonce:n});let i=r.updateCSS(O,k,t);i[e.CSS_IN_JS_INSTANCE]=T.instanceId,i.setAttribute(e.ATTR_TOKEN,o.value),Object.keys(D).forEach(t=>{_.has(t)||(_.add(t),r.updateCSS(m(D[t]),`_effect-${t}`,{mark:e.ATTR_MARK,prepend:`queue`,attachTo:S}))})}return[O,o.value,k,D,p,h]},([,,t],n)=>{(n||i.value.autoClear)&&d&&r.removeCSS(t,{mark:e.ATTR_MARK})}),e=>e}function x(t,n=!1){let r=Array.from(t.cache.keys()).filter(e=>e.startsWith(`style%`)),i={},a={},o=``;function s(t,r,i,a={}){let o={...a,[e.ATTR_TOKEN]:r,[e.ATTR_MARK]:i},s=Object.keys(o).map(e=>{let t=o[e];return t?`${e}="${t}"`:null}).filter(e=>e).join(` `);return n?t:`<style ${s}>${t}</style>`}return r.map(e=>{let n=e.slice(6).replace(/%/g,`|`),[r,o,c,l,u,d]=t.cache.get(e)[1];if(u)return null;let f={"data-vc-order":`prependQueue`,"data-vc-priority":`${d}`},p=s(r,o,c,f);return a[n]=c,l&&Object.keys(l).forEach(e=>{i[e]||(i[e]=!0,p+=s(m(l[e]),o,`_effect-${e}`,f))}),[d,p]}).filter(e=>e).sort((e,t)=>e[0]-t[0]).forEach(([,e])=>{o+=e}),o+=s(`.${l.ATTR_CACHE_MAP}{content:"${l.serialize(a)}";}`,void 0,void 0,{[l.ATTR_CACHE_MAP]:l.ATTR_CACHE_MAP}),o}exports.default=b,exports.extractStyle=x,exports.normalizeStyle=m,exports.parseStyle=v;