import{arrayType as e,booleanType as t,objectType as n,someType as r,stringType as i,withInstall as a}from"../type.mjs";import o from"./Cache.mjs";import{defineComponent as s,getCurrentInstance as c,inject as l,provide as u,shallowRef as d,unref as f,watch as p}from"vue";var m=`data-token-hash`,h=`data-css-hash`,g=`__cssinjs_instance__`;function _(){let e=Math.random().toString(12).slice(2);if(typeof document<`u`&&document.head&&document.body){let t=document.body.querySelectorAll(`style[data-css-hash]`)||[],{firstChild:n}=document.head;Array.from(t).forEach(t=>{t[g]=t.__cssinjs_instance__||e,t.__cssinjs_instance__===e&&document.head.insertBefore(t,n)});let r={};Array.from(document.querySelectorAll(`style[${h}]`)).forEach(t=>{let n=t.getAttribute(h);r[n]?t.__cssinjs_instance__===e&&t.parentNode?.removeChild(t):r[n]=!0})}return new o(e)}var v=Symbol(`StyleContextKey`),y=()=>{let e=c(),t;if(e&&e.appContext){let n=e.appContext?.config?.globalProperties?.__ANTDV_CSSINJS_CACHE__;n?t=n:(t=_(),e.appContext.config.globalProperties&&(e.appContext.config.globalProperties.__ANTDV_CSSINJS_CACHE__=t))}else t=_();return t},b={cache:_(),defaultCache:!0,hashPriority:`low`},x=()=>{let e=y();return l(v,d({...b,cache:e}))},S=e=>{let t=x(),n=d({...b,cache:_()});return p([()=>f(e),t],()=>{let r={...t.value},i=f(e);Object.keys(i).forEach(e=>{let t=i[e];i[e]!==void 0&&(r[e]=t)});let{cache:a}=i;r.cache=r.cache||_(),r.defaultCache=!a&&t.value.defaultCache,n.value=r},{immediate:!0}),u(v,n),n},C=()=>({autoClear:t(),mock:i(),cache:n(),defaultCache:t(),hashPriority:i(),container:r(),ssrInline:t(),transformers:e(),linters:e()}),w=a(s({name:`AStyleProvider`,inheritAttrs:!1,props:C(),setup(e,{slots:t}){return S(e),()=>t.default?.()}}));export{h as ATTR_MARK,m as ATTR_TOKEN,g as CSS_IN_JS_INSTANCE,w as StyleProvider,_ as createCache,C as styleProviderProps,x as useStyleInject,S as useStyleProvider};