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