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