const e=require("../type.js"),t=require("./Cache.js");let n=require("vue");var r=`data-token-hash`,i=`data-css-hash`,a=`__cssinjs_instance__`;function o(){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[a]=t.__cssinjs_instance__||e,t.__cssinjs_instance__===e&&document.head.insertBefore(t,n)});let r={};Array.from(document.querySelectorAll(`style[${i}]`)).forEach(t=>{let n=t.getAttribute(i);r[n]?t.__cssinjs_instance__===e&&t.parentNode?.removeChild(t):r[n]=!0})}return new t.default(e)}var s=Symbol(`StyleContextKey`),c=()=>{let e=(0,n.getCurrentInstance)(),t;if(e&&e.appContext){let n=e.appContext?.config?.globalProperties?.__ANTDV_CSSINJS_CACHE__;n?t=n:(t=o(),e.appContext.config.globalProperties&&(e.appContext.config.globalProperties.__ANTDV_CSSINJS_CACHE__=t))}else t=o();return t},l={cache:o(),defaultCache:!0,hashPriority:`low`},u=()=>{let e=c();return(0,n.inject)(s,(0,n.shallowRef)({...l,cache:e}))},d=e=>{let t=u(),r=(0,n.shallowRef)({...l,cache:o()});return(0,n.watch)([()=>(0,n.unref)(e),t],()=>{let i={...t.value},a=(0,n.unref)(e);Object.keys(a).forEach(e=>{let t=a[e];a[e]!==void 0&&(i[e]=t)});let{cache:s}=a;i.cache=i.cache||o(),i.defaultCache=!s&&t.value.defaultCache,r.value=i},{immediate:!0}),(0,n.provide)(s,r),r},f=()=>({autoClear:e.booleanType(),mock:e.stringType(),cache:e.objectType(),defaultCache:e.booleanType(),hashPriority:e.stringType(),container:e.someType(),ssrInline:e.booleanType(),transformers:e.arrayType(),linters:e.arrayType()}),p=e.withInstall((0,n.defineComponent)({name:`AStyleProvider`,inheritAttrs:!1,props:f(),setup(e,{slots:t}){return d(e),()=>t.default?.()}}));exports.ATTR_MARK=i,exports.ATTR_TOKEN=r,exports.CSS_IN_JS_INSTANCE=a,exports.StyleProvider=p,exports.createCache=o,exports.styleProviderProps=f,exports.useStyleInject=u,exports.useStyleProvider=d;