effcss 4.1.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * EffCSS v4.1.0
2
+ * EffCSS v4.3.0
3
3
  * {@link https://gitverse.ru/msabitov/effcss}
4
4
  * Copyright (c) Marat Sabitov
5
5
  * @license Apache-2.0
6
6
  */
7
- function e(e,t){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(s[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(s[r[n]]=e[r[n]])}return s}"function"==typeof SuppressedError&&SuppressedError;const t=(e,t,s)=>Object.entries(e).reduce(t,s),s=Symbol("noParse"),r=(e,n,i)=>{var a,o,l;let c=""+e;return null==n?"":"object"!=typeof n||n.hasOwnProperty(s)?""===n?c+";":`${u=c,u.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))}:${""+n};`:(!i||(null===(a=i.startsWith)||void 0===a?void 0:a.call(i,"@"))||(null===(o=c.startsWith)||void 0===o?void 0:o.call(c,"&"))||(null===(l=c.startsWith)||void 0===l?void 0:l.call(c,"@"))?"":"&")+c+`{${t(n,((e,t)=>e+r(...t,c)),"")}}`;var u},n="@layer",i="@starting-style",a=e=>`(${e})`,o=e=>"string"==typeof e,l={and:(...e)=>Object.defineProperties({type:"and",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>{const t=d(e);return"object"==typeof e&&"or"===e.type?a(t):t})).join(" and ")}}),or:(...e)=>Object.defineProperties({type:"or",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>d(e))).join(" or ")}}),not:e=>"object"==typeof e&&"not"===e.type?e.value[0]:Object.defineProperties({type:"not",value:[e]},{toString:{value:()=>`not (${d(e,!0)})`}})},c=e=>{const t=t=>({toString:()=>`(min-${e}:${o(t)?t:t+"rem"})`}),s=t=>({toString:()=>`(max-${e}:${o(t)?t:t+"rem"})`}),r=(e,r)=>({toString:()=>`${t(e)} and ${s(r)}`});return{up:t,down:s,between:r,only:e=>r(e,e)}},u=c("width"),h=c("height"),g=c("inline-size"),m=c("block-size"),d=(e,t)=>e?"string"==typeof e?e.includes("(")||t?e:a(e):e+"":"",p=(e={})=>{const{type:t,condition:s}=e,r=d(s),n="object"==typeof s&&"or"===s.type,i=`@media${t?" "+t:""}${t&&r?" and":""}${r?" "+(t&&n?a(r):r):""}`;return Object.defineProperties((e=>({[i]:e})),{all:{get:()=>p({condition:s,type:"all"})},print:{get:()=>p({condition:s,type:"print"})},screen:{get:()=>p({condition:s,type:"screen"})},where:{value:e=>p({condition:e,type:t})},toString:{value:()=>i}})},b=p({}),f=({condition:e}={})=>{const t=d(e),s="@supports"+(t?" "+t:"");return Object.defineProperties((e=>({[s]:e})),{where:{value:e=>f({condition:e})},toString:{value:()=>s}})},$=f(),y=e=>({[i]:e});y.toString=i;const v=e=>{const{root:t="",limit:s="",mode:r=[!1,!1]}=e,n=`@scope ${t?`(${t}${r[0]?" > *":""})`:""}${t&&s?" ":""}${s?`to (${s}${r[1]?" > *":""})`:""}`;return Object.defineProperties((e=>({[n]:e})),{limit:{value:e=>v({root:t,limit:e,mode:r})},root:{value:e=>v({root:e,limit:s,mode:r})},both:{value:()=>v({root:t,limit:s,mode:[!1,!0]})},none:{value:()=>v({root:t,limit:s,mode:[!0,!1]})},low:{value:()=>v({root:t,limit:s,mode:[!0,!0]})},high:{value:()=>v({root:t,limit:s,mode:[!1,!1]})},toString:{value:()=>n}})},j=v({}),O=(e,t)=>`calc(${e} * 1${t})`,x=e=>O(e,"px"),w=e=>O(e,"vh"),k=e=>O(e,"vw"),S=e=>O(e,"vmin"),_=e=>O(e,"vmax"),z=e=>O(e,"em"),A=e=>O(e,"rem"),P=e=>O(e,"deg"),q=e=>O(e,"rad"),C=e=>O(e,"rad"),E=e=>O(e,"ms"),N=e=>O(e,"s"),T=e=>O(e,"%"),M=e=>O(e,"cqw"),B=e=>O(e,"cqh"),W=e=>O(e,"cqi"),R=e=>O(e,"cqb"),I=e=>O(e,"cqmin"),V=e=>O(e,"cqmax"),D=Object.fromEntries,J=Object.entries,K=":first-",L=":last-",F=":only-",H="child",Z=":nth-",G="of-type",Q=Z+H,U=":focus",X={r:":root",h:":hover",f:U,fv:U+"-visible",a:":active",v:":visited",val:":valid",inv:":invalid",e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:K+H,lc:L+H,oc:F+H,odd:Q+"(odd)",even:Q+"(even)",ft:K+G,lt:L+G,ot:F+G,bef:"::before",aft:"::after",bd:"::backdrop"},Y={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:Q,ntho:Z+G,dir:":dir",lang:":lang"},ee=e=>`oklch(${e})`,te=e=>ee(`from ${e}`),se=(e,t=.1)=>te(`${e} calc(l + ${t}) c h / alpha)`),re=(e,t=.1)=>te(`${e} calc(l - ${t}) c h / alpha)`),ne=(e,t=.1)=>te(`${e} l c h / calc(alpha + ${t}))`),ie=(e,t=.1)=>te(`${e} l c h / calc(alpha - ${t}))`),ae=(e,t=.04)=>te(`${e} l calc(c + ${t}) h / alpha)`),oe=(e,t=.04)=>te(`${e} l calc(c - ${t}) h / alpha)`),le=(e,t=30)=>te(`${e} l c calc(h${"number"==typeof t?t>0?" + "+t:" - "+-t:t}) / alpha)`),ce=e=>{class t{constructor(e={}){this.state={l:"l",c:"base",h:"pri",a:1,m:"bg"},Object.assign(this,{[s]:!0}),this.state=Object.assign(this.state,e)}get xs(){return new t(Object.assign(Object.assign({},this.state),{l:"xs"}))}get s(){return new t(Object.assign(Object.assign({},this.state),{l:"s"}))}get m(){return new t(Object.assign(Object.assign({},this.state),{l:"m"}))}get l(){return new t(Object.assign(Object.assign({},this.state),{l:"l"}))}get xl(){return new t(Object.assign(Object.assign({},this.state),{l:"xl"}))}get lightness(){return{xs:this.xs,s:this.s,m:this.m,l:this.l,xl:this.xl}}get gray(){return new t(Object.assign(Object.assign({},this.state),{c:"gray"}))}get pale(){return new t(Object.assign(Object.assign({},this.state),{c:"pale"}))}get base(){return new t(Object.assign(Object.assign({},this.state),{c:"base"}))}get rich(){return new t(Object.assign(Object.assign({},this.state),{c:"rich"}))}get chroma(){return{gray:this.gray,pale:this.pale,base:this.base,rich:this.rich}}get pri(){return new t(Object.assign(Object.assign({},this.state),{h:"pri"}))}get sec(){return new t(Object.assign(Object.assign({},this.state),{h:"sec"}))}get suc(){return new t(Object.assign(Object.assign({},this.state),{h:"suc"}))}get inf(){return new t(Object.assign(Object.assign({},this.state),{h:"inf"}))}get war(){return new t(Object.assign(Object.assign({},this.state),{h:"war"}))}get dan(){return new t(Object.assign(Object.assign({},this.state),{h:"dan"}))}get hue(){return{pri:this.pri,sec:this.sec,suc:this.suc,inf:this.inf,war:this.war,dan:this.dan}}alpha(e=1){return new t(Object.assign(Object.assign({},this.state),{a:e}))}get bg(){return new t(Object.assign(Object.assign({},this.state),{m:"bg"}))}get fg(){return new t(Object.assign(Object.assign({},this.state),{m:"fg"}))}toString(){const{l:t,c:s,h:r,a:n,m:i}=this.state;return`oklch(${e(`lightness.${i}.${t}`)} ${e(`chroma.${i}.${s}`)} ${e(`hue.${r}`)} / ${n})`}}return new t},ue="coef",he=e=>{class t{constructor(e={}){this.state={center:8},this.state=Object.assign(this.state,e)}get min(){return e(`${ue}.${this.state.center-4}`)}get xxs(){return e(`${ue}.${this.state.center-3}`)}get xs(){return e(`${ue}.${this.state.center-2}`)}get s(){return e(`${ue}.${this.state.center-1}`)}get m(){return e(`${ue}.${this.state.center}`)}get l(){return e(`${ue}.${this.state.center+1}`)}get xl(){return e(`${ue}.${this.state.center+2}`)}get xxl(){return e(`${ue}.${this.state.center+3}`)}get max(){return e(`${ue}.${this.state.center+4}`)}get $xxs(){return new t({center:4})}get $xs(){return new t({center:8})}get $s(){return new t({center:12})}get $m(){return new t({center:16})}get $l(){return new t({center:20})}get $xl(){return new t({center:24})}get $xxl(){return new t({center:28})}get short(){return{s:this.s,m:this.m,l:this.l}}get base(){return Object.assign(Object.assign({xs:this.xs},this.short),{xl:this.xl})}get long(){return Object.assign(Object.assign({xxs:this.xxs},this.base),{xxl:this.xxl})}get full(){return Object.assign(Object.assign({min:this.min},this.long),{max:this.max})}get main(){return{min:this.min,m:this.m,max:this.max}}get sparse(){return{min:this.min,xs:this.xs,m:this.m,xl:this.xl,max:this.max}}}return new t},ge=Object.assign,me=Object.entries,de=Array.isArray,pe=e=>"object"==typeof e,be=(e,t)=>Array.from(Array(e).entries()).reduce(((e,[s])=>ge(e,t(s+1))),{}),fe=(e,t)=>me(e).reduce(((e,[s,r])=>ge(e,t(s,r))),{}),$e=(e,t,s={})=>e?t:s,ye=(...e)=>e.join("-"),ve=(...e)=>e.join(),je=(...e)=>e.join(" "),Oe=(e,...t)=>t.length?t.reduce(((e,t)=>(t&&e&&pe(t)&&me(t).forEach((([t,s])=>{s&&pe(s)&&e[t]?de(e[t])&&de(s)?e[t]=[...e[t],...s]:Oe(e[t],s||{}):e[t]=s})),e)),e):e,xe=Object.assign(D(J(X).map((([e,t])=>{function s(e=""){return e+t}return s.toString=()=>t,[e,s]}))),D(J(Y).map((([e,t])=>{function s(e,s=""){return s+t+`(${e})`}return s.toString=()=>t,[e,s]})))),we={oklch:ee,lighten:se,darken:re,saturate:ae,desaturate:oe,fadein:ne,fadeout:ie,spin:le},ke={px:x,vh:w,vw:k,vmin:S,vmax:_,em:z,rem:A,deg:P,rad:q,turn:C,ms:E,s:N,pc:T,cqw:M,cqh:B,cqb:R,cqi:W,cqmin:I,cqmax:V},Se=e=>1!==e?e+" * ":"",_e=e=>{const{scope:i,globalKey:a}=e,o=i(a).varExp,c=(e=1)=>ke.ms(Se(e)+o("time")),p=(e=1)=>ke.deg(Se(e)+o("angle")),f=(e=1)=>ke.px(Se(e)+o("size"));return{compile:({key:e,maker:a})=>{const v=i(e),O=v.selector,x=(e=>{const t={cp:1,lay:1,kf:1,cq:1},r=(n={})=>{const{scroll:i,type:a,name:o,condition:l}=n,c=d(l),u=`@container${o?" "+o:""}${c?" "+c:""}`;return Object.defineProperties((e=>({[u]:e})),{container:{value:(o||"none")+" / "+(a&&i?`${a} scroll-state`:i?"scroll-state":a||"normal"),enumerable:!0},named:{get:()=>r({scroll:i,condition:l,name:o||e.name(["cq",t.cq++]),type:a})},size:{get:()=>r({name:o,scroll:i,condition:l,type:"size"})},isize:{get:()=>r({name:o,scroll:i,condition:l,type:"inline-size"})},scroll:{get:()=>r({name:o,scroll:!0,condition:l,type:a})},where:{value:e=>r({name:o,scroll:i,condition:e,type:a})},[s]:{value:!0},toString:{value:()=>u}})},i=({name:s}={})=>{const r=`${n}${s?" "+s:""}`,a=e=>({[r]:e});return a.toString=()=>r,Object.defineProperties(a,{named:{get:()=>i({name:s||e.name(["lay",t.lay++])})},list:{value:(...e)=>({[n+(e.map((e=>(e+"").split(n)[1])).filter(Boolean).join(",")||s)]:""})}})};return{layer:i(),supports:$,keyframes:r=>{const n=e.name(["kf",t.kf++]),i="@keyframes "+n;return Object.defineProperties((e=>{if(!e)return{animationName:n};const{dur:t,tf:s,del:r,ic:i,dir:a,ps:o,fm:l}=e;return{animation:[t,s,r,i,a,o,l,n].filter(Boolean).join(" ")}}),{[i]:{value:r,enumerable:!0},toString:{value:()=>n},[s]:{value:!0}})},property:(r={})=>{const{syn:n='"*"',inh:i=!0,ini:a,def:o}=r,l="--"+e.name(["cp",t.cp++]),c=`var(${l}${void 0!==o?","+o:""})`,u="@property "+l;return Object.defineProperties((e=>({[l]:e})),{[u]:{value:{syntax:n,inherits:i,initialValue:a},enumerable:!0},toString:{value:()=>c},fallback:{value:e=>`var(${l},${e})`},[s]:{value:!0}})},scope:j,media:b,container:r({}),startingStyle:y,$logic:l,$width:u,$height:h,$block:m,$inline:g}})(v);return w=a({dash:ye,comma:ve,space:je,range:be,each:fe,when:$e,merge:Oe,themeVar:o,size:f,time:c,angle:p,bem:O,pseudo:xe,color:we,palette:ce(o),coef:he(o),units:ke,at:x}),t(w,((e,t)=>e+r(...t)),"");var w}}},ze=Symbol("effcss-stylesheet");class Ae{constructor(){this.disabled=!1,this.cssRules=[]}replaceSync(e){e&&(this.cssRules=[{cssText:e}])}}function Pe({initStyles:e,emulate:t}={}){const s={};null==e||e.forEach((e=>{var t;const r=null===(t=null==e?void 0:e.dataset)||void 0===t?void 0:t.effcss;r&&(s[r]=e)}));let r={},n={},i=[],a=[];const o=(e,t)=>t.hasOwnProperty(ze)?t:Object.defineProperties(t,{[ze]:{value:e}}),l=e=>{var t;return e.adoptedStyleSheets=[...(null===(t=e.adoptedStyleSheets)||void 0===t?void 0:t.length)?[...e.adoptedStyleSheets].filter((e=>!e.hasOwnProperty(ze))):[],...i]},c=()=>{a=a.reduce(((e,t)=>{const s=t.deref();return s&&(l(s),e.push(t)),e}),[])},u=e=>e?r[e]:void 0,h=(e,t)=>{if(!r[e]){r[e]=o(e,t),i.push(r[e]);const n=s[e];return n&&(n.disabled=!0),c(),!0}};return{get:u,all:()=>r,add:h,status:e=>{const t=u(e);return!(null==t?void 0:t.disabled)},on:(...e)=>{e.forEach((e=>{const t=u(e);t&&(t.disabled=!1)})),c()},off:(...e)=>{e.forEach((e=>{const t=u(e);t&&(t.disabled=!0)})),c()},remove:e=>{const t=u(e);if(!t)return;const s=(a=t,i.findIndex((e=>e===a)));var a;return s>-1&&(i.splice(s,1),delete r[e],delete n[e]),c(),!0},removeAll:()=>(i.splice(0),r={},n={},c(),!0),pack:(e,s)=>{let n=r[e]||(!t&&globalThis.CSSStyleSheet?new globalThis.CSSStyleSheet:new Ae);return n.replaceSync(s),n=o(e,n),!!n.cssRules.length&&h(e,n)},register:e=>{a.findIndex((t=>t.deref()===e))>=0||(a.push(new WeakRef(e)),l(e))},unregister:e=>{const t=a.findIndex((t=>t.deref()===e));t>=0&&a.splice(t,1)},hydrate:e=>s[e]&&!s[e].disabled&&s[e].textContent||void 0}}const qe=({prefix:e})=>{let t=0;return{get initial(){return e+0},get current(){return e+t},next(){return t++,this.current}}},Ce=({prefix:e})=>{const t=new Set,s=new Map,r=qe({prefix:e});return{use(e){let n=this.key(e);return n||(n=r.current,t.add(n),s.set(e,n),r.next(),n)},remake(e,t){const r=s.get(t);return r?(s.delete(t),s.set(e,r),r):this.use(e)},key:e=>e?s.get(e)||"":r.initial,get keys(){return[...t]},get makers(){return Object.fromEntries(s.entries().map((([e,t])=>[t,e])))}}},Ee=void 0,Ne=Object.entries,Te=Object.defineProperties,Me=e=>"string"==typeof e,Be=e=>null!==e&&"object"==typeof e,We=e=>e.split("."),Re=(e,t)=>Ne(e).reduce(((e,[s,r])=>{if(Be(r)){const n=Ne(r);n.length?e.push(...n.reduce(((e,[r,n])=>{if((e=>null!==e&&e!==Ee)(r)&&t&&e.push([s,r,Ee,Ee]),Be(n)){const t=Ne(n);t.length&&e.push(...t.reduce(((e,[t,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||e.push([s,r,t,n]),e}),[]))}return e}),[])):e.push([s,Ee,Ee,Ee])}return e}),[]),Ie=(e,t,s,r)=>""+(((e,t)=>`${e||""}${t?"__"+t:""}`)(e,t)+(s?"_"+s:"")+(s&&r?"_"+r:""))||"_",Ve=(e,t)=>"."+(t?e+(t.startsWith("_")?"":"-")+t:e),De=(e,t)=>`[data-${e}${t?`~="${t}"`:""}]`;const Je=e=>e||"",Ke=Object.assign,Le=Object.entries,Fe="theme",He="delete",Ze="update",Ge="$light",Qe="$dark",Ue="lightness",Xe="chroma",Ye=e=>Number((.1*184+.9*e).toFixed(2)),et={time:200,size:16,angle:30,coef:{0:0,1:.0625,2:.125,3:.25,4:.5,5:.75,6:.875,7:.9375,8:1,9:1.0625,10:1.125,11:1.25,12:1.5,13:1.75,14:1.875,15:1.9375,16:2,17:2.5,18:4,19:5,20:7.5,21:10,22:12,23:15,24:16,25:20,26:28,27:36,28:48,29:64,30:80,31:120,32:150},hue:{pri:184,sec:290,suc:Ye(142),inf:Ye(264),war:Ye(109),dan:Ye(29)},[Ge]:{[Ue]:{bg:{xl:.98,l:.93,m:.88,s:.83,xs:.78},fg:{xl:0,l:.12,m:.24,s:.36,xs:.48}},[Xe]:{bg:{gray:0,pale:.01,base:.04,rich:.7},fg:{gray:0,pale:.07,base:.11,rich:.15}}},[Qe]:{[Ue]:{bg:{xl:.24,l:.3,m:.36,s:.42,xs:.48},fg:{xl:.98,l:.93,m:.86,s:.79,xs:.72}},[Xe]:{bg:{pale:.02,base:.06,rich:.1},fg:{pale:.06,base:.1,rich:.14}}}},tt=({provider:t,init:s,scope:r,onChange:n})=>{const i={"":et},a=[],o={get:(e="")=>i[e],add(e,t){i[t]||(i[t]=Oe({[Ge]:{},[Qe]:{}},e),a.push({type:"add",payload:{params:e,name:t}}),null==n||n())},delete(e){e&&i[e]&&(this.current===e&&this.switch(),delete i[e],a.push({type:He,payload:{name:e}}),null==n||n())},update(e,t=""){i[t]&&(i[t]=Oe({[Ge]:{},[Qe]:{}},i[t],e),a.push({type:Ze,payload:{params:e,name:t}}),null==n||n())},switch(e=""){i[e]&&t.setAttribute(Fe,e)},vars(t=""){const s=this.get(t);return s?(t=>{var{$light:s={},$dark:n={}}=t,i=e(t,["$light","$dark"]);function a(e,t=[]){return Le(e).reduce(((e,[s,n])=>n&&"object"==typeof n?Ke(e,a(n,[...t,s])):(e[r.varName([...t,s])]=n,e)),{})}return Object.assign(Object.assign({},a(i)),{[Ge]:a(s),[Qe]:a(n)})})(s):{[Ge]:{},[Qe]:{}}},get list(){const t=e(i,[""]);return Object.keys(t)},get current(){return t.getAttribute(Fe)||""},get all(){return i},get actions(){return a}};return null==s||s.forEach((({type:e,payload:t})=>{switch(e){case"add":o.add(t.params,t.name);break;case He:o.delete(t.name);break;case Ze:o.update(t.params,t.name)}})),o},st="effcss",rt=st+"-provider",nt="script",it="style",at="size",ot="time",lt="angle",ct=st+"changes",ut="data-"+st,ht="prefers-color-scheme",gt=`${ht}: light`,mt=`${ht}: dark`,dt={mode:"a",pre:"f"},pt=e=>"boolean"==typeof e,bt=(e,t)=>{const s=((e,t)=>e.getAttribute(t)||dt[t])(e,t);return(e=>"string"==typeof e?Number(e):null)(s)},ft=(e,t,s)=>null===s?e.removeAttribute(t):e.setAttribute(t,s+""),$t=e=>`:root:has([is=${rt}]${e?`[${e}]`:""})`,yt=({theme:t,attrs:s,scope:r})=>({bem:n,each:i,themeVar:a,merge:o,pseudo:{r:l},at:{media:c},units:{px:u}})=>{const h=s.size,g=s.time,m=s.angle,d=t.vars(),{$dark:p={},$light:b={}}=d,f=e(d,["$dark","$light"]);return o({[$t()]:Object.assign(Object.assign(Object.assign(Object.assign({},f),c.where(gt)(b)),c.where(mt)(p)),{[l()]:{fontSize:u(a("size"))}})},i(t.list,((s,r)=>{const i=t.vars(r),{$dark:a={},$light:o={}}=i,l=e(i,["$dark","$light"]),u=Object.assign(Object.assign(Object.assign({},l),c.where(gt)(o)),c.where(mt)(a));return{[$t(`theme=${s}`)]:u,[n(`..theme.${s}`)]:u}})),h&&{[$t(at)]:{[r.varName(at)]:h}},g&&{[$t(ot)]:{[r.varName(ot)]:g}},m&&{[$t(lt)]:{[r.varName(lt)]:m}})},vt=(e,{initStyles:t,emulate:s,onChange:r,globalMaker:n,noscript:i})=>{let a;e.textContent&&(a=JSON.parse(e.textContent)),Object.defineProperties(e,{pre:{get:()=>e.getAttribute("pre")||"f"},mode:{get:()=>e.getAttribute("mode")||"a"},min:{get:()=>""===e.getAttribute("min")},size:{set(t){ft(e,at,t)},get:()=>bt(e,at)},time:{set(t){ft(e,ot,t)},get:()=>bt(e,ot)},angle:{set(t){ft(e,lt,t)},get:()=>bt(e,lt)}});const o=Ce({prefix:e.pre}),l=((e={})=>{const{mode:t,min:s,dict:r={}}=e;let n;n="a"===t?De:Ve;const i=e=>{let s=0,r=Je,a=Je;const o=i.dict;o&&(o[e]||(o[e]={}),r=t=>{var r;return null!==(r=o[e][t])&&void 0!==r?r:o[e][t]=(s++).toString(36)},a=t=>o[e][t]);let l=t=>[e,...Me(t)?t.split("."):t].filter(Boolean).join("-"),c="class",u=t=>t?e+(t.startsWith("_")?"":"-")+t:void 0===t?void 0:e;"a"===t&&(c="data-"+e,u=Je);const h=e=>"--"+l(Me(e)?e.split("."):e),g=e=>{if(void 0===e)return function(e){const t=({b:s,e:r,m:n})=>({b:e=>t({b:e,e:"",m:{}}),e:e=>t({b:s,e:e,m:{}}),m:(e={})=>t({b:s,e:r,m:e}),get $(){return e({[s]:{[r]:n}})}});return t({b:"",e:"",m:{}})}(g);let t,s,r,n,i="";const o=Me(e);return i=o||Array.isArray(e)?[...(o?[e]:e).reduce(((e,i)=>([t,s,r,n]=We(i),e.add(u(a(Ie(t,s)))),r&&e.add(u(a(Ie(t,s,r,n)))),e)),new Set).values()].join(" "):e&&Re(e,!0).map((([e,t,s,r])=>u(a(Ie(e,t,s,r))))).join(" "),Te({[c]:i},{toString:{value:()=>`${c}="${i}"`},$:{value:i}})};return{selector:t=>{const[s,i,a,o]=We(t);return n(e,r(Ie(s,i,a,o)))},attr:g,name:l,varName:h,varExp:(e,t)=>`var(${h(e)}${void 0!==t?","+t:""})`}};return s&&(i.dict=r),i})({mode:e.mode,min:e.min,dict:null==a?void 0:a.dict}),c=l(o.key()),u=_e({scope:l,globalKey:o.key()}),h=Pe({initStyles:t,emulate:s});e.theme=tt({provider:e,init:null==a?void 0:a.theme,onChange:r,scope:c});const g=(({scope:e,collector:t,manager:s,processor:r,globalMaker:n})=>{const i=e=>"string"==typeof e?e:t.key(e),a=s=>e(s||t.key()).attr,o=(e,t)=>r.compile({key:t,maker:e}),l=e=>{let r=t.use(e);return s&&!s.get(r)&&s.pack(r,s.hydrate(r)||o(e,r)),a(r)},c=(...e)=>0===e.length?[l(n)]:e.map((e=>l(e)));return{use:c,remake:(e,r)=>{let n=t.key(r||e);return s&&s.get(n)?(r&&t.remake(e,r),s.pack(n,s.hydrate(n)||o(e,n)),a(n)):c(e)[0]},css:o,status:e=>{const t=i(e);return!!t&&s.status(t)},on:(...e)=>s.on(...e.map(i)),off:(...e)=>s.off(...e.map(i)),stylesheets:(e=t.keys)=>e.map((e=>s.get(i(e))))}})({scope:l,processor:u,manager:h,collector:o,globalMaker:n});Object.defineProperties(e,{_c:{value:o},_s:{value:l},_p:{value:u},_m:{value:h},toString:{value:()=>{const t=Object.assign({},h.all()),s=Object.entries(t).filter((([e,t])=>!t.disabled)).map((([e,t])=>`<style ${ut}="${e}">${[...t.cssRules].map((e=>e.cssText)).join("")}</style>`)).join("");let r=it,n="";const a={is:rt,min:e.getAttribute("min"),mode:e.getAttribute("mode"),size:e.getAttribute(at),time:e.getAttribute(ot),angle:e.getAttribute(lt)};if(!i){r=nt,a.type="application/json";const t={theme:e.theme.actions};e.min&&o.keys.length>1&&(t.dict=l.dict),n=JSON.stringify(t)}return s+`<${r} ${Object.entries(a).map((([e,t])=>null!=t&&t!==dt[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${n}</${r}>`}}}),Object.assign(e,g)};const jt=(e={})=>{let{noscript:t,attrs:s={}}=e,{mode:r=dt.mode,min:n,pre:i=dt.prefix,size:a=null,time:o=null,angle:l=null}=s;return new class{get tagName(){return""}get textContent(){return""}getAttribute(e){const t=this.attributes[e];return null!=t?pt(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",e!==at&&e!==ot&&e!==lt||this._customize()}removeAttribute(e){delete this.attributes[e]}get makers(){return this._c.makers}constructor(){this.attributes={size:a?a+"":null,time:o?o+"":null,angle:l?l+"":null,pre:i,mode:r,min:n?"":null},this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=yt({theme:this.theme,attrs:{size:e,time:t,angle:s},scope:this._s(this._c.key())});this.remake(r,this._),this._=r},vt(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},Ot=(t={})=>{const{emulate:s}=t,r=e(t,["emulate"]),n=null===globalThis||void 0===globalThis?void 0:globalThis.document;if(n&&!s){void 0===Ot.isDefined&&(Ot.isDefined=function(){const e=globalThis.document,t=globalThis.customElements;if(null==t?void 0:t.get(rt))return!1;{class s extends HTMLScriptElement{constructor(){super(...arguments),this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=yt({theme:this.theme,attrs:{size:e,time:t,angle:s},scope:this._s(this._c.key())});this.remake(r,this._),this._=r}}static get observedAttributes(){return[at,ot,lt]}get makers(){return this._c.makers}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){vt(this,{initStyles:[...e.querySelectorAll(it+`[${ut}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const t=this;this._n={set adoptedStyleSheets(e){t.dispatchEvent(new CustomEvent(ct,{detail:{styles:e},bubbles:!0}))}},this._m.register(this._n),this._m.register(e)}}return t.define(rt,s,{extends:nt}),!0}}());const e=n.querySelector(`[is=${rt}]`);if(e)return e;const t=n.createElement(nt,{is:rt});t.setAttribute("is",rt);const s=null==r?void 0:r.attrs;return s&&Object.entries(s).map((([e,s])=>s&&dt[e]!==s&&t.setAttribute(e,pt(s)?"":s+""))),n.head.appendChild(t),t}return jt(r)};export{dt as DEFAULT_ATTRS,rt as TAG_NAME,Ot as useStyleProvider};
7
+ function e(e,t){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(s[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(s[r[n]]=e[r[n]])}return s}"function"==typeof SuppressedError&&SuppressedError;const t=(e,t,s)=>Object.entries(e).reduce(t,s),s=(e,t)=>{return`${s=e,s.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))}:${""+t};`;var s},r=Symbol("noParse"),n=(e,i,a)=>{var o,l,c;let u=""+e;return null==i?"":Array.isArray(i)?i.map((e=>s(u,e))).join(""):"object"!=typeof i||i.hasOwnProperty(r)?""===i?u+";":s(u,i):(!a||(null===(o=a.startsWith)||void 0===o?void 0:o.call(a,"@"))||(null===(l=u.startsWith)||void 0===l?void 0:l.call(u,"&"))||(null===(c=u.startsWith)||void 0===c?void 0:c.call(u,"@"))?"":"&")+u+`{${t(i,((e,t)=>e+n(...t,u)),"")}}`},i="@layer",a="@starting-style",o=e=>`(${e})`,l=e=>"string"==typeof e,c={and:(...e)=>Object.defineProperties({type:"and",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>{const t=p(e);return"object"==typeof e&&"or"===e.type?o(t):t})).join(" and ")}}),or:(...e)=>Object.defineProperties({type:"or",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>p(e))).join(" or ")}}),not:e=>"object"==typeof e&&"not"===e.type?e.value[0]:Object.defineProperties({type:"not",value:[e]},{toString:{value:()=>`not (${p(e,!0)})`}})},u=e=>{const t=t=>({toString:()=>`(min-${e}:${l(t)?t:t+"rem"})`}),s=t=>({toString:()=>`(max-${e}:${l(t)?t:t+"rem"})`}),r=(e,r)=>({toString:()=>`${t(e)} and ${s(r)}`});return{up:t,down:s,between:r,only:e=>r(e,e)}},h=u("width"),g=u("height"),m=u("inline-size"),d=u("block-size"),p=(e,t)=>e?"string"==typeof e?e.includes("(")||t?e:o(e):e+"":"",b=(e={})=>{const{type:t,condition:s}=e,r=p(s),n="object"==typeof s&&"or"===s.type,i=`@media${t?" "+t:""}${t&&r?" and":""}${r?" "+(t&&n?o(r):r):""}`;return Object.defineProperties((e=>({[i]:e})),{all:{get:()=>b({condition:s,type:"all"})},print:{get:()=>b({condition:s,type:"print"})},screen:{get:()=>b({condition:s,type:"screen"})},where:{value:e=>b({condition:e,type:t})},toString:{value:()=>i}})},f=b({}),$=({condition:e}={})=>{const t=p(e),s="@supports"+(t?" "+t:"");return Object.defineProperties((e=>({[s]:e})),{where:{value:e=>$({condition:e})},toString:{value:()=>s}})},y=$(),v=e=>({[a]:e});v.toString=a;const j=e=>{const{root:t="",limit:s="",mode:r=[!1,!1]}=e,n=`@scope ${t?`(${t}${r[0]?" > *":""})`:""}${t&&s?" ":""}${s?`to (${s}${r[1]?" > *":""})`:""}`;return Object.defineProperties((e=>({[n]:e})),{limit:{value:e=>j({root:t,limit:e,mode:r})},root:{value:e=>j({root:e,limit:s,mode:r})},both:{value:()=>j({root:t,limit:s,mode:[!1,!0]})},none:{value:()=>j({root:t,limit:s,mode:[!0,!1]})},low:{value:()=>j({root:t,limit:s,mode:[!0,!0]})},high:{value:()=>j({root:t,limit:s,mode:[!1,!1]})},toString:{value:()=>n}})},O=j({}),x=(e,t)=>`calc(${e} * 1${t})`,w=e=>x(e,"px"),k=e=>x(e,"vh"),S=e=>x(e,"vw"),_=e=>x(e,"vmin"),A=e=>x(e,"vmax"),z=e=>x(e,"em"),P=e=>x(e,"rem"),q=e=>x(e,"deg"),C=e=>x(e,"rad"),E=e=>x(e,"rad"),N=e=>x(e,"ms"),T=e=>x(e,"s"),M=e=>x(e,"%"),B=e=>x(e,"cqw"),W=e=>x(e,"cqh"),R=e=>x(e,"cqi"),I=e=>x(e,"cqb"),V=e=>x(e,"cqmin"),D=e=>x(e,"cqmax"),J=Object.fromEntries,K=Object.entries,L=":first-",F=":last-",H=":only-",Z="child",G=":nth-",Q="of-type",U=G+Z,X=":focus",Y="valid",ee="in"+Y,te=":user-",se={r:":root",h:":hover",f:X,fv:X+"-visible",a:":active",v:":visited",val:":"+Y,inv:":"+ee,uval:te+Y,uinv:te+ee,e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:L+Z,lc:F+Z,oc:H+Z,odd:U+"(odd)",even:U+"(even)",ft:L+Q,lt:F+Q,ot:H+Q,bef:"::before",aft:"::after",bd:"::backdrop"},re={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:U,ntho:G+Q,dir:":dir",lang:":lang"},ne=e=>`oklch(${e})`,ie=e=>ne(`from ${e}`),ae=(e,t=.1)=>ie(`${e} calc(l + ${t}) c h / alpha`),oe=(e,t=.1)=>ie(`${e} calc(l - ${t}) c h / alpha`),le=(e,t=.1)=>ie(`${e} l c h / calc(alpha + ${t})`),ce=(e,t=.1)=>ie(`${e} l c h / calc(alpha - ${t})`),ue=(e,t=.04)=>ie(`${e} l calc(c + ${t}) h / alpha`),he=(e,t=.04)=>ie(`${e} l calc(c - ${t}) h / alpha`),ge=(e,t=30)=>ie(`${e} l c calc(h${"number"==typeof t?t>0?" + "+t:" - "+-t:t}) / alpha`),me=e=>{const t=e("color");return{root:e=>e?ie(t+` ${e.l||"l"} ${e.c||"c"} ${e.h||"h"} / ${e.a||"1"}`):t,oklch:ne,lighten:ae,darken:oe,saturate:ue,desaturate:he,fadein:le,fadeout:ce,spin:ge}},de=e=>{class t{constructor(e={}){this.state={l:"l",c:"base",h:"pri",a:1,m:"bg"},Object.assign(this,{[r]:!0}),this.state=Object.assign(this.state,e)}get xs(){return new t(Object.assign(Object.assign({},this.state),{l:"xs"}))}get s(){return new t(Object.assign(Object.assign({},this.state),{l:"s"}))}get m(){return new t(Object.assign(Object.assign({},this.state),{l:"m"}))}get l(){return new t(Object.assign(Object.assign({},this.state),{l:"l"}))}get xl(){return new t(Object.assign(Object.assign({},this.state),{l:"xl"}))}get lightness(){return{xs:this.xs,s:this.s,m:this.m,l:this.l,xl:this.xl}}get gray(){return new t(Object.assign(Object.assign({},this.state),{c:"gray"}))}get pale(){return new t(Object.assign(Object.assign({},this.state),{c:"pale"}))}get base(){return new t(Object.assign(Object.assign({},this.state),{c:"base"}))}get rich(){return new t(Object.assign(Object.assign({},this.state),{c:"rich"}))}get chroma(){return{gray:this.gray,pale:this.pale,base:this.base,rich:this.rich}}get pri(){return new t(Object.assign(Object.assign({},this.state),{h:"pri"}))}get sec(){return new t(Object.assign(Object.assign({},this.state),{h:"sec"}))}get suc(){return new t(Object.assign(Object.assign({},this.state),{h:"suc"}))}get inf(){return new t(Object.assign(Object.assign({},this.state),{h:"inf"}))}get war(){return new t(Object.assign(Object.assign({},this.state),{h:"war"}))}get dan(){return new t(Object.assign(Object.assign({},this.state),{h:"dan"}))}get hue(){return{pri:this.pri,sec:this.sec,suc:this.suc,inf:this.inf,war:this.war,dan:this.dan}}alpha(e=1){return new t(Object.assign(Object.assign({},this.state),{a:e}))}get bg(){return new t(Object.assign(Object.assign({},this.state),{m:"bg"}))}get fg(){return new t(Object.assign(Object.assign({},this.state),{m:"fg"}))}toString(){const{l:t,c:s,h:r,a:n,m:i}=this.state;return`oklch(${e(`lightness.${i}.${t}`)} ${e(`chroma.${i}.${s}`)} ${e(`hue.${r}`)} / ${n})`}}return new t},pe="coef",be=e=>{class t{constructor(e={}){this.state={center:8},this.state=Object.assign(this.state,e)}get min(){return e(`${pe}.${this.state.center-4}`)}get xxs(){return e(`${pe}.${this.state.center-3}`)}get xs(){return e(`${pe}.${this.state.center-2}`)}get s(){return e(`${pe}.${this.state.center-1}`)}get m(){return e(`${pe}.${this.state.center}`)}get l(){return e(`${pe}.${this.state.center+1}`)}get xl(){return e(`${pe}.${this.state.center+2}`)}get xxl(){return e(`${pe}.${this.state.center+3}`)}get max(){return e(`${pe}.${this.state.center+4}`)}get $xxs(){return new t({center:4})}get $xs(){return new t({center:8})}get $s(){return new t({center:12})}get $m(){return new t({center:16})}get $l(){return new t({center:20})}get $xl(){return new t({center:24})}get $xxl(){return new t({center:28})}get short(){return{s:this.s,m:this.m,l:this.l}}get base(){return Object.assign(Object.assign({xs:this.xs},this.short),{xl:this.xl})}get long(){return Object.assign(Object.assign({xxs:this.xxs},this.base),{xxl:this.xxl})}get full(){return Object.assign(Object.assign({min:this.min},this.long),{max:this.max})}get main(){return{min:this.min,m:this.m,max:this.max}}get sparse(){return{min:this.min,xs:this.xs,m:this.m,xl:this.xl,max:this.max}}}return new t},fe=Object.assign,$e=Object.entries,ye=Array.isArray,ve=e=>"object"==typeof e,je=(e,t)=>Array.from(Array(e).entries()).reduce(((e,[s])=>fe(e,t(s+1))),{}),Oe=(e,t)=>$e(e).reduce(((e,[s,r])=>fe(e,t(s,r))),{}),xe=(e,t,s={})=>e?t:s,we=(...e)=>e.join("-"),ke=(...e)=>e.join(),Se=(...e)=>e.join(" "),_e=(e,...t)=>t.length?t.reduce(((e,t)=>(t&&e&&ve(t)&&$e(t).forEach((([t,s])=>{s&&ve(s)&&e[t]?ye(e[t])&&ye(s)?e[t]=[...e[t],...s]:_e(e[t],s||{}):e[t]=s})),e)),e):e,Ae=Object.assign(J(K(se).map((([e,t])=>{function s(e=""){return e+t}return s.toString=()=>t,[e,s]}))),J(K(re).map((([e,t])=>{function s(e,s=""){return s+t+`(${e})`}return s.toString=()=>t,[e,s]})))),ze={px:w,vh:k,vw:S,vmin:_,vmax:A,em:z,rem:P,deg:q,rad:C,turn:E,ms:N,s:T,pc:M,cqw:B,cqh:W,cqb:I,cqi:R,cqmin:V,cqmax:D},Pe=e=>1!==e?e+" * ":"",qe=e=>{const{scope:s,globalKey:a}=e,o=s(a).varExp,l=(e=1)=>ze.ms(Pe(e)+o("time")),u=(e=1)=>ze.deg(Pe(e)+o("angle")),b=(e=1)=>ze.px(Pe(e)+o("size"));return{compile:({key:e,maker:a})=>{const $=s(e),j=$.selector,x=(e=>{const t={cp:1,lay:1,kf:1,cq:1},s=(n={})=>{const{scroll:i,type:a,name:o,condition:l}=n,c=p(l),u=`@container${o?" "+o:""}${c?" "+c:""}`;return Object.defineProperties((e=>({[u]:e})),{container:{value:(o||"none")+" / "+(a&&i?`${a} scroll-state`:i?"scroll-state":a||"normal"),enumerable:!0},named:{get:()=>s({scroll:i,condition:l,name:o||e.name(["cq",t.cq++]),type:a})},size:{get:()=>s({name:o,scroll:i,condition:l,type:"size"})},isize:{get:()=>s({name:o,scroll:i,condition:l,type:"inline-size"})},scroll:{get:()=>s({name:o,scroll:!0,condition:l,type:a})},where:{value:e=>s({name:o,scroll:i,condition:e,type:a})},[r]:{value:!0},toString:{value:()=>u}})},n=({name:s}={})=>{const r=`${i}${s?" "+s:""}`,a=e=>({[r]:e});return a.toString=()=>r,Object.defineProperties(a,{named:{get:()=>n({name:s||e.name(["lay",t.lay++])})},list:{value:(...e)=>({[i+(e.map((e=>(e+"").split(i)[1])).filter(Boolean).join(",")||s)]:""})}})};return{layer:n(),supports:y,keyframes:s=>{const n=e.name(["kf",t.kf++]),i="@keyframes "+n;return Object.defineProperties((e=>{if(!e)return{animationName:n};const{dur:t,tf:s,del:r,ic:i,dir:a,ps:o,fm:l}=e;return{animation:[t,s,r,i,a,o,l,n].filter(Boolean).join(" ")}}),{[i]:{value:s,enumerable:!0},toString:{value:()=>n},[r]:{value:!0}})},property:(s={})=>{const{syn:n='"*"',inh:i=!0,ini:a,def:o}=s,l="--"+e.name(["cp",t.cp++]),c=`var(${l}${void 0!==o?","+o:""})`,u="@property "+l;return Object.defineProperties((e=>({[l]:e})),{[u]:{value:{syntax:n,inherits:i,initialValue:a},enumerable:!0},toString:{value:()=>c},fallback:{value:e=>`var(${l},${e})`},[r]:{value:!0}})},scope:O,media:f,container:s({}),startingStyle:v,$logic:c,$width:h,$height:g,$block:d,$inline:m}})($);return w=a({dash:we,comma:ke,space:Se,range:je,each:Oe,when:xe,merge:_e,themeVar:o,size:b,time:l,angle:u,bem:j,pseudo:Ae,color:me(o),palette:de(o),coef:be(o),units:ze,at:x}),t(w,((e,t)=>e+n(...t)),"");var w}}},Ce=Symbol("effcss-stylesheet");class Ee{constructor(){this.disabled=!1,this.cssRules=[]}replaceSync(e){e&&(this.cssRules=[{cssText:e}])}}function Ne({initStyles:e,emulate:t}={}){const s={};null==e||e.forEach((e=>{var t;const r=null===(t=null==e?void 0:e.dataset)||void 0===t?void 0:t.effcss;r&&(s[r]=e)}));let r={},n={},i=[],a=[];const o=(e,t)=>t.hasOwnProperty(Ce)?t:Object.defineProperties(t,{[Ce]:{value:e}}),l=e=>{var t;return e.adoptedStyleSheets=[...(null===(t=e.adoptedStyleSheets)||void 0===t?void 0:t.length)?[...e.adoptedStyleSheets].filter((e=>!e.hasOwnProperty(Ce))):[],...i]},c=()=>{a=a.reduce(((e,t)=>{const s=t.deref();return s&&(l(s),e.push(t)),e}),[])},u=e=>e?r[e]:void 0,h=(e,t)=>{if(!r[e]){r[e]=o(e,t),i.push(r[e]);const n=s[e];return n&&(n.disabled=!0),c(),!0}};return{get:u,all:()=>r,add:h,status:e=>{const t=u(e);return!(null==t?void 0:t.disabled)},on:(...e)=>{e.forEach((e=>{const t=u(e);t&&(t.disabled=!1)})),c()},off:(...e)=>{e.forEach((e=>{const t=u(e);t&&(t.disabled=!0)})),c()},remove:e=>{const t=u(e);if(!t)return;const s=(a=t,i.findIndex((e=>e===a)));var a;return s>-1&&(i.splice(s,1),delete r[e],delete n[e]),c(),!0},removeAll:()=>(i.splice(0),r={},n={},c(),!0),pack:(e,s)=>{let n=r[e]||(!t&&globalThis.CSSStyleSheet?new globalThis.CSSStyleSheet:new Ee);return n.replaceSync(s),n=o(e,n),!!n.cssRules.length&&h(e,n)},register:e=>{a.findIndex((t=>t.deref()===e))>=0||(a.push(new WeakRef(e)),l(e))},unregister:e=>{const t=a.findIndex((t=>t.deref()===e));t>=0&&a.splice(t,1)},hydrate:e=>s[e]&&!s[e].disabled&&s[e].textContent||void 0}}const Te=({prefix:e})=>{let t=0;return{get initial(){return e+0},get current(){return e+t},next(){return t++,this.current}}},Me=({prefix:e})=>{const t=new Set,s=new Map,r=Te({prefix:e});return{use(e){let n=this.key(e);return n||(n=r.current,t.add(n),s.set(e,n),r.next(),n)},remake(e,t){const r=s.get(t);return r?(s.delete(t),s.set(e,r),r):this.use(e)},key:e=>e?s.get(e)||"":r.initial,get keys(){return[...t]},get makers(){return Object.fromEntries(s.entries().map((([e,t])=>[t,e])))}}},Be=void 0,We=Object.entries,Re=Object.defineProperties,Ie=e=>"string"==typeof e,Ve=e=>null!==e&&"object"==typeof e,De=e=>e.split("."),Je=(e,t)=>We(e).reduce(((e,[s,r])=>{if(Ve(r)){const n=We(r);n.length?e.push(...n.reduce(((e,[r,n])=>{if((e=>null!==e&&e!==Be)(r)&&t&&e.push([s,r,Be,Be]),Ve(n)){const t=We(n);t.length&&e.push(...t.reduce(((e,[t,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||e.push([s,r,t,n]),e}),[]))}return e}),[])):e.push([s,Be,Be,Be])}return e}),[]),Ke=(e,t,s,r)=>""+(((e,t)=>`${e||""}${t?"__"+t:""}`)(e,t)+(s?"_"+s:"")+(s&&r?"_"+r:""))||"_",Le=(e,t)=>"."+(t?e+(t.startsWith("_")?"":"-")+t:e),Fe=(e,t)=>`[data-${e}${t?`~="${t}"`:""}]`;const He=e=>e||"",Ze=Object.assign,Ge=Object.entries,Qe="theme",Ue="delete",Xe="update",Ye="$light",et="$dark",tt="lightness",st="chroma",rt=e=>Number((.1*184+.9*e).toFixed(2)),nt={time:200,size:16,angle:30,color:"#2192a7",coef:{0:0,1:.0625,2:.125,3:.25,4:.5,5:.75,6:.875,7:.9375,8:1,9:1.0625,10:1.125,11:1.25,12:1.5,13:1.75,14:1.875,15:1.9375,16:2,17:2.5,18:4,19:5,20:7.5,21:10,22:12,23:15,24:16,25:20,26:28,27:36,28:48,29:64,30:80,31:120,32:150},hue:{pri:184,sec:290,suc:rt(142),inf:rt(264),war:rt(109),dan:rt(29)},[Ye]:{[tt]:{bg:{xl:.98,l:.93,m:.88,s:.83,xs:.78},fg:{xl:0,l:.12,m:.24,s:.36,xs:.48}},[st]:{bg:{gray:0,pale:.01,base:.04,rich:.7},fg:{gray:0,pale:.07,base:.11,rich:.15}}},[et]:{[tt]:{bg:{xl:.24,l:.3,m:.36,s:.42,xs:.48},fg:{xl:.98,l:.93,m:.86,s:.79,xs:.72}},[st]:{bg:{pale:.02,base:.06,rich:.1},fg:{pale:.06,base:.1,rich:.14}}}},it=({provider:t,init:s,scope:r,onChange:n})=>{const i={"":nt},a=[],o={get:(e="")=>i[e],add(e,t){i[t]||(i[t]=_e({[Ye]:{},[et]:{}},e),a.push({type:"add",payload:{params:e,name:t}}),null==n||n())},delete(e){e&&i[e]&&(this.current===e&&this.switch(),delete i[e],a.push({type:Ue,payload:{name:e}}),null==n||n())},update(e,t=""){i[t]&&(i[t]=_e({[Ye]:{},[et]:{}},i[t],e),a.push({type:Xe,payload:{params:e,name:t}}),null==n||n())},switch(e=""){i[e]&&t.setAttribute(Qe,e)},vars(t=""){const s=this.get(t);return s?(t=>{var{$light:s={},$dark:n={}}=t,i=e(t,["$light","$dark"]);function a(e,t=[]){return Ge(e).reduce(((e,[s,n])=>n&&"object"==typeof n?Ze(e,a(n,[...t,s])):(e[r.varName([...t,s])]=n,e)),{})}return Object.assign(Object.assign({},a(i)),{[Ye]:a(s),[et]:a(n)})})(s):{[Ye]:{},[et]:{}}},get list(){const t=e(i,[""]);return Object.keys(t)},get current(){return t.getAttribute(Qe)||""},get all(){return i},get actions(){return a}};return null==s||s.forEach((({type:e,payload:t})=>{switch(e){case"add":o.add(t.params,t.name);break;case Ue:o.delete(t.name);break;case Xe:o.update(t.params,t.name)}})),o},at="effcss",ot=at+"-provider",lt="script",ct="style",ut="size",ht="time",gt="angle",mt="color",dt=at+"changes",pt="data-"+at,bt="prefers-color-scheme",ft=`${bt}: light`,$t=`${bt}: dark`,yt={mode:"a",pre:"f"},vt=e=>"boolean"==typeof e,jt=(e,t)=>{const s=((e,t)=>e.getAttribute(t)||yt[t])(e,t);return(e=>"string"==typeof e?Number(e):null)(s)},Ot=(e,t,s)=>null===s?e.removeAttribute(t):e.setAttribute(t,s+""),xt=e=>`:root:has([is=${ot}]${e?`[${e}]`:""})`,wt=({theme:t,attrs:s,scope:r})=>({bem:n,each:i,themeVar:a,merge:o,pseudo:{r:l},at:{media:c},units:{px:u}})=>{const h=s.size,g=s.time,m=s.angle,d=s.color,p=t.vars(),{$dark:b={},$light:f={}}=p,$=e(p,["$dark","$light"]);return o({[xt()]:Object.assign(Object.assign(Object.assign(Object.assign({},$),c.where(ft)(f)),c.where($t)(b)),{[l()]:{fontSize:u(a("size"))}})},i(t.list,((s,r)=>{const i=t.vars(r),{$dark:a={},$light:o={}}=i,l=e(i,["$dark","$light"]),u=Object.assign(Object.assign(Object.assign({},l),c.where(ft)(o)),c.where($t)(a));return{[xt(`theme=${s}`)]:u,[n(`..theme.${s}`)]:u}})),h&&{[xt(ut)]:{[r.varName(ut)]:h}},g&&{[xt(ht)]:{[r.varName(ht)]:g}},m&&{[xt(gt)]:{[r.varName(gt)]:m}},d&&{[xt(mt)]:{[r.varName(mt)]:d}})},kt=(e,{initStyles:t,emulate:s,onChange:r,globalMaker:n,noscript:i})=>{let a;e.textContent&&(a=JSON.parse(e.textContent)),Object.defineProperties(e,{pre:{get:()=>e.getAttribute("pre")||"f"},mode:{get:()=>e.getAttribute("mode")||"a"},min:{get:()=>""===e.getAttribute("min")},size:{set(t){Ot(e,ut,t)},get:()=>jt(e,ut)},time:{set(t){Ot(e,ht,t)},get:()=>jt(e,ht)},angle:{set(t){Ot(e,gt,t)},get:()=>jt(e,gt)},color:{set(t){Ot(e,mt,t)},get:()=>e.getAttribute(mt)}});const o=Me({prefix:e.pre}),l=((e={})=>{const{mode:t,min:s,dict:r={}}=e;let n;n="a"===t?Fe:Le;const i=e=>{let s=0,r=He,a=He;const o=i.dict;o&&(o[e]||(o[e]={}),r=t=>{var r;return null!==(r=o[e][t])&&void 0!==r?r:o[e][t]=(s++).toString(36)},a=t=>o[e][t]);let l=t=>[e,...Ie(t)?t.split("."):t].filter(Boolean).join("-"),c="class",u=t=>t?e+(t.startsWith("_")?"":"-")+t:void 0===t?void 0:e;"a"===t&&(c="data-"+e,u=He);const h=e=>"--"+l(Ie(e)?e.split("."):e),g=e=>{if(void 0===e)return function(e){const t=({b:s,e:r,m:n})=>({b:e=>t({b:e,e:"",m:{}}),e:e=>t({b:s,e:e,m:{}}),m:(e={})=>t({b:s,e:r,m:e}),get $(){return e({[s]:{[r]:n}})}});return t({b:"",e:"",m:{}})}(g);let t,s,r,n,i="";const o=Ie(e);return i=o||Array.isArray(e)?[...(o?[e]:e).reduce(((e,i)=>([t,s,r,n]=De(i),e.add(u(a(Ke(t,s)))),r&&e.add(u(a(Ke(t,s,r,n)))),e)),new Set).values()].join(" "):e&&Je(e,!0).map((([e,t,s,r])=>u(a(Ke(e,t,s,r))))).join(" "),Re({[c]:i},{toString:{value:()=>`${c}="${i}"`},$:{value:i}})};return{selector:t=>{const[s,i,a,o]=De(t);return n(e,r(Ke(s,i,a,o)))},attr:g,name:l,varName:h,varExp:(e,t)=>`var(${h(e)}${void 0!==t?","+t:""})`}};return s&&(i.dict=r),i})({mode:e.mode,min:e.min,dict:null==a?void 0:a.dict}),c=l(o.key()),u=qe({scope:l,globalKey:o.key()}),h=Ne({initStyles:t,emulate:s});e.theme=it({provider:e,init:null==a?void 0:a.theme,onChange:r,scope:c});const g=(({scope:e,collector:t,manager:s,processor:r,globalMaker:n})=>{const i=e=>"string"==typeof e?e:t.key(e),a=s=>e(s||t.key()).attr,o=(e,t)=>r.compile({key:t,maker:e}),l=e=>{let r=t.use(e);return s&&!s.get(r)&&s.pack(r,s.hydrate(r)||o(e,r)),a(r)},c=(...e)=>0===e.length?[l(n)]:e.map((e=>l(e)));return{use:c,remake:(e,r)=>{let n=t.key(r||e);return s&&s.get(n)?(r&&t.remake(e,r),s.pack(n,s.hydrate(n)||o(e,n)),a(n)):c(e)[0]},css:o,status:e=>{const t=i(e);return!!t&&s.status(t)},on:(...e)=>s.on(...e.map(i)),off:(...e)=>s.off(...e.map(i)),stylesheets:(e=t.keys)=>e.map((e=>s.get(i(e))))}})({scope:l,processor:u,manager:h,collector:o,globalMaker:n});Object.defineProperties(e,{_c:{value:o},_s:{value:l},_p:{value:u},_m:{value:h},toString:{value:()=>{const t=Object.assign({},h.all()),s=Object.entries(t).filter((([e,t])=>!t.disabled)).map((([e,t])=>`<style ${pt}="${e}">${[...t.cssRules].map((e=>e.cssText)).join("")}</style>`)).join("");let r=ct,n="";const a={is:ot,min:e.getAttribute("min"),mode:e.getAttribute("mode"),size:e.getAttribute(ut),time:e.getAttribute(ht),angle:e.getAttribute(gt),color:e.getAttribute(mt)};if(!i){r=lt,a.type="application/json";const t={theme:e.theme.actions};e.min&&o.keys.length>1&&(t.dict=l.dict),n=JSON.stringify(t)}return s+`<${r} ${Object.entries(a).map((([e,t])=>null!=t&&t!==yt[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${n}</${r}>`}}}),Object.assign(e,g)},St=Symbol(ot),_t=[ut,ht,gt,mt],At=new Set(_t);const zt=(e={})=>{let{noscript:t,attrs:s={}}=e,{mode:r=yt.mode,min:n,pre:i=yt.prefix,size:a=null,time:o=null,angle:l=null,color:c=null}=s;return new class{get tagName(){return""}get textContent(){return""}getAttribute(e){const t=this.attributes[e];return null!=t?vt(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",At.has(e)&&this._customize()}removeAttribute(e){delete this.attributes[e]}get makers(){return this._c.makers}constructor(){this.attributes={size:a?a+"":null,time:o?o+"":null,angle:l?l+"":null,color:c||null,pre:i,mode:r,min:n?"":null},this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=this.color,n=wt({theme:this.theme,attrs:{size:e,time:t,angle:s,color:r},scope:this._s(this._c.key())});this.remake(n,this._),this._=n},kt(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},Pt=(t={})=>{const{emulate:s,global:r}=t,n=e(t,["emulate","global"]),i=null===globalThis||void 0===globalThis?void 0:globalThis.document;let a;const o=globalThis[St];if(r&&o)a=o;else if(i&&!s){void 0===Pt.isDefined&&(Pt.isDefined=function(){const e=globalThis.document,t=globalThis.customElements;if(null==t?void 0:t.get(ot))return!1;{class s extends HTMLScriptElement{constructor(){super(...arguments),this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=this.color,n=wt({theme:this.theme,attrs:{size:e,time:t,angle:s,color:r},scope:this._s(this._c.key())});this.remake(n,this._),this._=n}}static get observedAttributes(){return _t}get makers(){return this._c.makers}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){kt(this,{initStyles:[...e.querySelectorAll(ct+`[${pt}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const t=this;this._n={set adoptedStyleSheets(e){t.dispatchEvent(new CustomEvent(dt,{detail:{styles:e},bubbles:!0}))}},this._m.register(this._n),this._m.register(e)}}return t.define(ot,s,{extends:lt}),!0}}());const e=i.querySelector(`[is=${ot}]`);if(e)a=e;else{const e=i.createElement(lt,{is:ot});e.setAttribute("is",ot);const t=null==n?void 0:n.attrs;t&&Object.entries(t).map((([t,s])=>s&&yt[t]!==s&&e.setAttribute(t,vt(s)?"":s+""))),i.head.appendChild(e),a=e}}else a=zt(n);return r&&!o&&(globalThis[St]=a),a};export{yt as DEFAULT_ATTRS,ot as TAG_NAME,Pt as useStyleProvider};
@@ -1,6 +1,17 @@
1
+ import type { TCreateScope } from '../../_provider/scope';
1
2
  type TChangeStr = (val: string) => string;
2
3
  type TChangeColor = (color: string | object, val?: number | string) => string;
3
- export declare const resolveColor: () => {
4
+ export declare const resolveColor: (varExp: ReturnType<ReturnType<TCreateScope>>["varExp"]) => {
5
+ /**
6
+ * Root color
7
+ * @param p - oklch params
8
+ */
9
+ root: (p?: {
10
+ l?: string | number;
11
+ c?: string | number;
12
+ h?: string | number;
13
+ a?: string | number;
14
+ }) => string;
4
15
  /**
5
16
  * oklch()
6
17
  */
@@ -33,6 +33,14 @@ type TPseudo = {
33
33
  * :invalid
34
34
  */
35
35
  inv: TSimplePseudo;
36
+ /**
37
+ * :user-valid
38
+ */
39
+ uval: TSimplePseudo;
40
+ /**
41
+ * :user-invalid
42
+ */
43
+ uinv: TSimplePseudo;
36
44
  /**
37
45
  * :empty
38
46
  */
@@ -33,6 +33,10 @@ export type TProviderAttrs = {
33
33
  * Root angle in deg
34
34
  */
35
35
  angle: number;
36
+ /**
37
+ * Root color string
38
+ */
39
+ color: string;
36
40
  };
37
41
  type TResolveAttr = ReturnType<TScopeResolver>['attr'];
38
42
  /**
@@ -104,6 +108,15 @@ export interface IStyleProvider {
104
108
  * @param val - angle value in ms
105
109
  */
106
110
  set angle(val: number | null);
111
+ /**
112
+ * Get root color value
113
+ */
114
+ get color(): string | null;
115
+ /**
116
+ * Set root color value
117
+ * @param val - angle value in ms
118
+ */
119
+ set color(val: string | null);
107
120
  /**
108
121
  * Use stylesheet makers
109
122
  * @param makers - stylesheet makers
@@ -173,6 +186,10 @@ type TUseStylePropviderParams = {
173
186
  * Create Style Provider emulation
174
187
  */
175
188
  emulate?: boolean;
189
+ /**
190
+ * Use as global object
191
+ */
192
+ global?: boolean;
176
193
  };
177
194
  type TUseStyleProvider = {
178
195
  (settings?: TUseStylePropviderParams): IStyleProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effcss",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "Self-confident CSS-in-JS",
5
5
  "type": "module",
6
6
  "scripts": {