effcss 4.6.2 → 4.8.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/README.md CHANGED
@@ -142,7 +142,7 @@ export type TCardMaker = {
142
142
  };
143
143
  }
144
144
 
145
- const myStyleSheetMaker: TStyleSheetMaker = ({ select, pseudo, at: { keyframes, property }, merge, palette, coef, size, units: {px} }) = {
145
+ const myStyleSheetMaker: TStyleSheetMaker = ({ select, pseudo: {h}, at: { keyframes, property }, merge, palette, coef, size, units: {px} }) = {
146
146
  // specify selector variants via generic
147
147
  const selector = select<TCardMaker>;
148
148
  // create property with unique identifier
@@ -164,16 +164,16 @@ const myStyleSheetMaker: TStyleSheetMaker = ({ select, pseudo, at: { keyframes,
164
164
  const cardLogoStyles = merge({
165
165
  width: widthProperty,
166
166
  animation: `20s linear infinite ${spin}`,
167
- [pseudo.h()]: {
167
+ ...h({
168
168
  filter: "drop-shadow(0 0 2em #61dafbaa)",
169
- }
169
+ })
170
170
  }, {
171
171
  border: 'none',
172
172
  background: palette.pale.xl.alpha(0.8),
173
173
  aspectRatio: 1,
174
- [pseudo.h()]: {
174
+ ...h({
175
175
  opacity: 0.5
176
- }
176
+ })
177
177
  });
178
178
  return {
179
179
  ...sizeProperty,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * EffCSS v4.6.2
2
+ * EffCSS v4.8.0
3
3
  * {@link https://sourcecraft.dev/msabitov/effcss}
4
4
  * Copyright (c) Marat Sabitov
5
5
  * @license Apache-2.0
6
6
  */
7
- const e=(e,t,r)=>Object.entries(e).reduce(t,r),t=(e,t)=>{return`${r=e,r.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))}:${""+t};`;var r},r=Symbol("noParse"),s=(n,i,a)=>{let o=""+n;return null==i?"":Array.isArray(i)?i.map((e=>t(o,e))).join(""):"object"!=typeof i||i.hasOwnProperty(r)?""===i?o+";":t(o,i):(!a||a.startsWith?.("@")||o.startsWith?.("&")||o.startsWith?.("@")?"":"&")+o+`{${e(i,((e,t)=>e+s(...t,o)),"")}}`},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=g(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=>g(e))).join(" or ")}}),not:e=>"object"==typeof e&&"not"===e.type?e.value[0]:Object.defineProperties({type:"not",value:[e]},{toString:{value:()=>`not (${g(e,!0)})`}})},c=e=>{const t=t=>({toString:()=>`(min-${e}:${o(t)?t:t+"rem"})`}),r=t=>({toString:()=>`(max-${e}:${o(t)?t:t+"rem"})`}),s=(e,s)=>({toString:()=>`${t(e)} and ${r(s)}`});return{up:t,down:r,between:s,only:e=>s(e,e)}},u=c("width"),h=c("height"),m=c("inline-size"),d=c("block-size"),g=(e,t)=>e?"string"==typeof e?e.includes("(")||t?e:a(e):e+"":"",p=(e={})=>{const{type:t,condition:r}=e,s=g(r),n="object"==typeof r&&"or"===r.type,i=`@media${t?" "+t:""}${t&&s?" and":""}${s?" "+(t&&n?a(s):s):""}`;return Object.defineProperties((e=>({[i]:e})),{all:{get:()=>p({condition:r,type:"all"})},print:{get:()=>p({condition:r,type:"print"})},screen:{get:()=>p({condition:r,type:"screen"})},where:{value:e=>p({condition:e,type:t})},toString:{value:()=>i}})},b=p({}),f=({condition:e}={})=>{const t=g(e),r="@supports"+(t?" "+t:"");return Object.defineProperties((e=>({[r]:e})),{where:{value:e=>f({condition:e})},toString:{value:()=>r}})},$=f(),y=e=>({[i]:e});y.toString=i;const v=e=>{const{root:t="",limit:r="",mode:s=[!1,!1]}=e,n=`@scope ${t?`(${t}${s[0]?" > *":""})`:""}${t&&r?" ":""}${r?`to (${r}${s[1]?" > *":""})`:""}`;return Object.defineProperties((e=>({[n]:e})),{limit:{value:e=>v({root:t,limit:e,mode:s})},root:{value:e=>v({root:e,limit:r,mode:s})},both:{value:()=>v({root:t,limit:r,mode:[!1,!0]})},none:{value:()=>v({root:t,limit:r,mode:[!0,!1]})},low:{value:()=>v({root:t,limit:r,mode:[!0,!0]})},high:{value:()=>v({root:t,limit:r,mode:[!1,!1]})},toString:{value:()=>n}})},x=v({}),w=(e,t)=>`calc(${e} * 1${t})`,S=e=>w(e,"px"),k=e=>w(e,"vh"),j=e=>w(e,"vw"),_=e=>w(e,"vmin"),O=e=>w(e,"vmax"),A=e=>w(e,"em"),z=e=>w(e,"rem"),C=e=>w(e,"deg"),q=e=>w(e,"rad"),P=e=>w(e,"rad"),T=e=>w(e,"ms"),E=e=>w(e,"s"),N=e=>w(e,"%"),M=e=>w(e,"cqw"),R=e=>w(e,"cqh"),B=e=>w(e,"cqi"),W=e=>w(e,"cqb"),I=e=>w(e,"cqmin"),V=e=>w(e,"cqmax"),J=Object.fromEntries,L=Object.entries,H=":first-",D=":last-",K=":only-",U="child",F=":nth-",Z="of-type",G=F+U,Q=":focus",X="valid",Y="in"+X,ee=":user-",te={r:":root",h:":hover",f:Q,fv:Q+"-visible",a:":active",v:":visited",val:":"+X,inv:":"+Y,uval:ee+X,uinv:ee+Y,e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:H+U,lc:D+U,oc:K+U,odd:G+"(odd)",even:G+"(even)",ft:H+Z,lt:D+Z,ot:K+Z,bef:"::before",aft:"::after",bd:"::backdrop"},re={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:G,ntho:F+Z,dir:":dir",lang:":lang"},se=e=>`oklch(${e})`,ne=e=>se(`from ${e}`),ie=(e,t=.1)=>ne(`${e} calc(l + ${t}) c h / alpha`),ae=(e,t=.1)=>ne(`${e} calc(l - ${t}) c h / alpha`),oe=(e,t=.1)=>ne(`${e} l c h / calc(alpha + ${t})`),le=(e,t=.1)=>ne(`${e} l c h / calc(alpha - ${t})`),ce=(e,t=.04)=>ne(`${e} l calc(c + ${t}) h / alpha`),ue=(e,t=.04)=>ne(`${e} l calc(c - ${t}) h / alpha`),he=(e,t=30)=>ne(`${e} l c calc(h${"number"==typeof t?t>0?" + "+t:" - "+-t:t}) / alpha`),me=e=>{const t=e("color");return{root:e=>e?ne(t+` ${e.l||"l"} ${e.c||"c"} ${e.h||"h"} / ${e.a||"1"}`):t,oklch:se,lighten:ie,darken:ae,saturate:ce,desaturate:ue,fadein:oe,fadeout:le,spin:he}},de=e=>{class t{state={l:"l",c:"base",h:"pri",a:"1",m:"bg"};constructor(e={}){Object.assign(this,{[r]:!0}),this.state=Object.assign(this.state,e)}get xs(){return new t({...this.state,l:"xs"})}get s(){return new t({...this.state,l:"s"})}get m(){return new t({...this.state,l:"m"})}get l(){return new t({...this.state,l:"l"})}get xl(){return new t({...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({...this.state,c:"gray"})}get pale(){return new t({...this.state,c:"pale"})}get base(){return new t({...this.state,c:"base"})}get rich(){return new t({...this.state,c:"rich"})}get chroma(){return{gray:this.gray,pale:this.pale,base:this.base,rich:this.rich}}get pri(){return new t({...this.state,h:"pri"})}get sec(){return new t({...this.state,h:"sec"})}get suc(){return new t({...this.state,h:"suc"})}get inf(){return new t({...this.state,h:"inf"})}get war(){return new t({...this.state,h:"war"})}get dan(){return new t({...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({...this.state,a:e+""})}get bg(){return new t({...this.state,m:"bg"})}get fg(){return new t({...this.state,m:"fg"})}toString(){const{l:t,c:r,h:s,a:n,m:i}=this.state;return`oklch(${e(`lightness.${i}.${t}`)} ${e(`chroma.${i}.${r}`)} ${e(`hue.${s}`)} / ${n})`}}return new t},ge=e=>{const t=(t,r=0)=>e(`coef.${t.state.center+r}`);class r{state={center:8};constructor(e={}){this.state=Object.assign(this.state,e)}get min(){return t(this,-4)}get xxs(){return t(this,-3)}get xs(){return t(this,-2)}get s(){return t(this,-1)}get m(){return t(this)}get l(){return t(this,1)}get xl(){return t(this,2)}get xxl(){return t(this,3)}get max(){return t(this,4)}get $xxs(){return new r({center:4})}get $xs(){return new r({center:8})}get $s(){return new r({center:12})}get $m(){return new r({center:16})}get $l(){return new r({center:20})}get $xl(){return new r({center:24})}get $xxl(){return new r({center:28})}get short(){return{s:this.s,m:this.m,l:this.l}}get base(){return{xs:this.xs,...this.short,xl:this.xl}}get long(){return{xxs:this.xxs,...this.base,xxl:this.xxl}}get full(){return{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 r},pe=Object.assign,be=Object.entries,fe=Array.isArray,$e=e=>"object"==typeof e,ye=(e,t)=>Array.from(Array(e).entries()).reduce(((e,[r])=>pe(e,t(r+1))),{}),ve=(e,t)=>be(e).reduce(((e,[r,s])=>pe(e,t(r,s))),{}),xe=(e,t,r={})=>e?t:r,we=(...e)=>e.join("-"),Se=(...e)=>e.join(),ke=(...e)=>e.join(" "),je=(e,...t)=>t.length?t.reduce(((e,t)=>(t&&e&&$e(t)&&be(t).forEach((([t,r])=>{r&&$e(r)&&e[t]?fe(e[t])&&fe(r)?e[t]=[...e[t],...r]:je(e[t],r||{}):e[t]=r})),e)),e):e,_e=Object.assign(J(L(te).map((([e,t])=>{function r(e=""){return e+t}return r.toString=()=>t,[e,r]}))),J(L(re).map((([e,t])=>{function r(e,r=""){return r+t+`(${e})`}return r.toString=()=>t,[e,r]})))),Oe={px:S,vh:k,vw:j,vmin:_,vmax:O,em:A,rem:z,deg:C,rad:q,turn:P,ms:T,s:E,pc:N,cqw:M,cqh:R,cqb:W,cqi:B,cqmin:I,cqmax:V},Ae=e=>1!==e?e+" * ":"",ze=t=>{const{scope:i,globalKey:a}=t,o=i(a).varExp,c=(e=1)=>Oe.ms(Ae(e)+o("time")),p=(e=1)=>Oe.deg(Ae(e)+o("angle")),f=(e=1)=>Oe.px(Ae(e)+o("size")),v=e=>e?`cubic-bezier(${e.x1||0},${e.y1||0},${e.x2||1},${e.y2||1})`:o("easing");return{compile:({key:t,maker:a})=>{const w=i(t),S=w.selector,k=w.select,j=(e=>{const t={cp:1,lay:1,kf:1,cq:1},s=(n={})=>{const{scroll:i,type:a,name:o,condition:l}=n,c=g(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}})},i=({name:r}={})=>{const s=`${n}${r?" "+r:""}`,a=e=>({[s]:e});return a.toString=()=>s,Object.defineProperties(a,{named:{get:()=>i({name:r||e.name(["lay",t.lay++])})},list:{value:(...e)=>({[n+(e.map((e=>(e+"").split(n)[1])).filter(Boolean).join(",")||r)]:""})}})};return{layer:i(),supports:$,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:r,del:s,ic:i,dir:a,ps:o,fm:l}=e;return{animation:[t,r,s,i,a,o,l,n].filter(Boolean).join(" ")}}),{[i]:{value:s,enumerable:!0},toString:{value:()=>n},[r]:{value:!0}})},property:(s={})=>{let n,i,a='"*"',o=!0;"object"==typeof s?({syn:a=a,inh:o=o,ini:n,def:i}=s):(i=s,n=s,o=!1);const l="--"+e.name(["cp",t.cp++]),c=`var(${l}${void 0!==i?","+i:""})`,u="@property "+l;return Object.defineProperties((e=>({[l]:e})),{[u]:{value:{syntax:a,inherits:o,initialValue:n},enumerable:!0},toString:{value:()=>c},fallback:{value:e=>`var(${l},${e})`},[r]:{value:!0}})},scope:x,media:b,container:s({}),startingStyle:y,$logic:l,$width:u,$height:h,$block:d,$inline:m}})(w),_=a({dash:we,comma:Se,space:ke,range:ye,each:ve,when:xe,merge:je,themeVar:o,size:f,time:c,angle:p,easing:v,bem:S,select:k,pseudo:_e,color:me(o),palette:de(o),coef:ge(o),units:Oe,at:j});return"string"==typeof _?_:(t=>e(t,((e,t)=>e+s(...t)),""))(_)}}},Ce=Symbol("effcss-stylesheet");class qe{disabled=!1;cssRules=[];replaceSync(e){e&&(this.cssRules=[{cssText:e}])}}function Pe({initStyles:e,emulate:t}={}){const r={};e?.forEach((e=>{const t=e?.dataset?.effcss;t&&(r[t]=e)}));let s={},n={},i=[],a=[];const o=(e,t)=>t.hasOwnProperty(Ce)?t:Object.defineProperties(t,{[Ce]:{value:e}}),l=e=>e.adoptedStyleSheets=[...e.adoptedStyleSheets?.length?[...e.adoptedStyleSheets].filter((e=>!e.hasOwnProperty(Ce))):[],...i],c=()=>{a=a.reduce(((e,t)=>{const r=t.deref();return r&&(l(r),e.push(t)),e}),[])},u=e=>e?s[e]:void 0,h=(e,t)=>{if(!s[e]){s[e]=o(e,t),i.push(s[e]);const n=r[e];return n&&(n.disabled=!0),c(),!0}};return{get:u,all:()=>s,add:h,status:e=>{const t=u(e);return!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 r=(a=t,i.findIndex((e=>e===a)));var a;return r>-1&&(i.splice(r,1),delete s[e],delete n[e]),c(),!0},removeAll:()=>(i.splice(0),s={},n={},c(),!0),pack:(e,r)=>{let n=s[e]||(!t&&globalThis.CSSStyleSheet?new globalThis.CSSStyleSheet:new qe);return n.replaceSync(r),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=>r[e]&&!r[e].disabled&&r[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}}},Ee=({prefix:e})=>{const t=new Set,r=new Map,s=Te({prefix:e});return{use(e){let n=this.key(e);return n||(n=s.current,t.add(n),r.set(e,n),s.next(),n)},remake(e,t){const s=r.get(t);return s?(r.delete(t),r.set(e,s),s):this.use(e)},key:e=>e?r.get(e)||"":s.initial,get keys(){return[...t]},get makers(){return Object.fromEntries(r.entries().map((([e,t])=>[t,e])))}}},Ne=void 0,Me=Object.entries,Re=Object.defineProperties,Be=e=>"string"==typeof e,We=e=>null!==e&&"object"==typeof e,Ie=e=>e.split("."),Ve=(e,t="")=>Me(e).reduce(((e,[r,s])=>{const n=t?`${t}-${r}`:r;return"object"==typeof s?(e.add(n),e=e.union(Ve(s,n))):e.add(n+`_${s}`),e}),new Set),Je=(e,t="")=>Me(e).reduce(((e,[r,s])=>{const n=t?`${t}-${r}`:r;if("object"==typeof s){const t=Je(s,n);t.size||e.add(n),e=e.union(t)}else t&&e.add(t),e.add(n+`_${s}`);return e}),new Set),Le=(e,t)=>Me(e).reduce(((e,[r,s])=>{if(We(s)){const n=Me(s);n.length?e.push(...n.reduce(((e,[s,n])=>{if((e=>null!==e&&e!==Ne)(s)&&t&&e.push([r,s,Ne,Ne]),We(n)){const t=Me(n);t.length&&e.push(...t.reduce(((e,[t,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||e.push([r,s,t,n]),e}),[]))}return e}),[])):e.push([r,Ne,Ne,Ne])}return e}),[]),He=(e,t,r,s)=>""+(((e,t)=>`${e||""}${t?"__"+t:""}`)(e,t)+(r?"_"+r:"")+(r&&s?"_"+s:""))||"_",De=(e,t)=>"."+(t?e+(t.startsWith("_")?"":"-")+t:e),Ke=(e,t)=>`[data-${e}${t?`~="${t}"`:""}]`;const Ue=e=>e||"",Fe=Object.assign,Ze=Object.entries,Ge="theme",Qe="delete",Xe="update",Ye="$light",et="$dark",tt="lightness",rt="chroma",st=e=>Number((.1*184+.9*e).toFixed(2)),nt={time:200,size:16,angle:30,color:"#2192a7",easing:"linear",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:3,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:st(142),inf:st(264),war:st(109),dan:st(29)},[Ye]:{[tt]:{bg:{xl:1,l:.94,m:.88,s:.83,xs:.78},fg:{xl:0,l:.12,m:.24,s:.36,xs:.48}},[rt]:{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:1,l:.93,m:.86,s:.79,xs:.72}},[rt]:{bg:{pale:.02,base:.06,rich:.1},fg:{pale:.06,base:.1,rich:.14}}}},it=({provider:e,init:t,scope:r,onChange:s})=>{const n={"":nt},i=[],a=({$light:e={},$dark:t={},...s})=>{function n(e,t=[]){return Ze(e).reduce(((e,[s,i])=>i&&"object"==typeof i?Fe(e,n(i,[...t,s])):(e[r.varName([...t,s])]=i,e)),{})}return{...n(s),[Ye]:n(e),[et]:n(t)}},o={get:(e="")=>n[e],add(e,t){n[t]||(n[t]=je({[Ye]:{},[et]:{}},e),i.push({type:"add",payload:{params:e,name:t}}),s?.())},delete(e){e&&n[e]&&(this.current===e&&this.switch(),delete n[e],i.push({type:Qe,payload:{name:e}}),s?.())},update(e,t=""){n[t]&&(n[t]=je({[Ye]:{},[et]:{}},n[t],e),i.push({type:Xe,payload:{params:e,name:t}}),s?.())},switch(t=""){n[t]&&e.setAttribute(Ge,t)},vars(e=""){const t=this.get(e);return t?a(t):{[Ye]:{},[et]:{}}},makeThemeVars:a,get list(){const{"":e,...t}=n;return Object.keys(t)},get current(){return e.getAttribute(Ge)||""},get all(){return n},get actions(){return i}};return t?.forEach((({type:e,payload:t})=>{switch(e){case"add":o.add(t.params,t.name);break;case Qe:o.delete(t.name);break;case Xe:o.update(t.params,t.name)}})),o},at="effcss",ot=at+"-provider",lt=at+"-override",ct="values",ut=":host",ht="display:contents;",mt="@media",dt="script",gt="style",pt="size",bt="time",ft="angle",$t="color",yt="easing",vt=at+"changes",xt="data-"+at,wt="prefers-color-scheme",St=`${wt}: light`,kt=`${wt}: dark`,jt={mode:"a",pre:"f"},_t=e=>"boolean"==typeof e,Ot=(e,t)=>{const r=((e,t)=>e.getAttribute(t)||jt[t])(e,t);return(e=>"string"==typeof e?Number(e):null)(r)},At=(e,t,r)=>null===r?e.removeAttribute(t):e.setAttribute(t,r+""),zt=e=>`:root:has([is=${ot}]${e?`[${e}]`:""})`,Ct=e=>Object.entries(e).reduce(((e,[t,r])=>e+t+":"+r+";"),""),qt=({theme:e,attrs:t,scope:r})=>({bem:s,each:n,themeVar:i,merge:a,pseudo:{r:o},at:{media:l},units:{px:c}})=>{const u=t.size,h=t.time,m=t.angle,d=t.color,g=t.easing,{$dark:p={},$light:b={},...f}=e.vars();return a({[zt()]:{...f,...l.where(St)(b),...l.where(kt)(p),[o()]:{fontSize:c(i("size"))}}},n(e.list,((t,r)=>{const{$dark:n={},$light:i={},...a}=e.vars(r),o={...a,...l.where(St)(i),...l.where(kt)(n)};return{[zt(`theme=${t}`)]:o,[s(`..theme.${t}`)]:o}})),u&&{[zt(pt)]:{[r.varName(pt)]:u}},h&&{[zt(bt)]:{[r.varName(bt)]:h}},m&&{[zt(ft)]:{[r.varName(ft)]:m}},d&&{[zt($t)]:{[r.varName($t)]:d}},g&&{[zt(yt)]:{[r.varName(yt)]:g}})},Pt=(e,t)=>({set(r){At(e,t,r)},get:()=>Ot(e,t)}),Tt=(e,t)=>({set(r){At(e,t,r)},get:()=>e.getAttribute(t)}),Et=(e,{initStyles:t,emulate:r,onChange:s,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:Pt(e,pt),time:Pt(e,bt),angle:Pt(e,ft),color:Tt(e,$t),easing:Tt(e,yt)});const o=Ee({prefix:e.pre}),l=((e={})=>{const{mode:t,min:r,dict:s={}}=e;let n;n="a"===t?Ke:De;const i=e=>{let r=0,s=Ue,a=Ue;const o=i.dict;o&&(o[e]||(o[e]={}),s=t=>o[e][t]??(o[e][t]=(r++).toString(36)),a=t=>o[e][t]);let l=t=>[e,...Be(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=Ue);const h=e=>"--"+l(Be(e)?e.split("."):e),m=e=>Re({[c]:e},{toString:{value:()=>`${c}="${e}"`},$:{value:e}}),d=e=>{if(void 0===e)return function(e){const t=({b:r,e:s,m:n})=>({b:e=>t({b:e,e:"",m:{}}),e:e=>t({b:r,e:e,m:{}}),m:(e={})=>t({b:r,e:s,m:e}),get $(){return e({[r]:{[s]:n}})}});return t({b:"",e:"",m:{}})}(d);let t,r,s,n,i="";const o=Be(e);return i=o||Array.isArray(e)?[...(o?[e]:e).reduce(((e,i)=>([t,r,s,n]=Ie(i),e.add(u(a(He(t,r)))),s&&e.add(u(a(He(t,r,s,n)))),e)),new Set).values()].join(" "):e&&Le(e,!0).map((([e,t,r,s])=>u(a(He(e,t,r,s))))).join(" "),m(i)};return d.list=(...e)=>{const t=[...e.reduce(((e,t)=>{const[r,s]=t.split(":");if(!r)return e;if(void 0===s)return e.add(r.replaceAll(".","-")),e;const n=r.split("."),i=n.pop(),a=n.join("-");return n.length?(e.add(a),e.add(a+`-${i}_${s}`)):e.add(`${i}_${s}`),e}),new Set).keys()].map((e=>u(a(e)))).join(" ");return m(t)},d.obj=(e,t)=>{let r=Je;"full"===t&&(r=Ve);const s=[...r(e).values()].map((e=>u(a(e)))).join(" ");return m(s)},{select:t=>{const r=t.replaceAll(".","-").replace(":","_");return n(e,s(r))},selector:t=>{const[r,i,a,o]=Ie(t);return n(e,s(He(r,i,a,o)))},attr:d,name:l,varName:h,varExp:(e,t)=>`var(${h(e)}${void 0!==t?","+t:""})`}};return r&&(i.dict=s),i})({mode:e.mode,min:e.min,dict:a?.dict}),c=l(o.key()),u=ze({scope:l,globalKey:o.key()}),h=Pe({initStyles:t,emulate:r});e.theme=it({provider:e,init:a?.theme,onChange:s,scope:c});const m=(({scope:e,collector:t,manager:r,processor:s,globalMaker:n})=>{const i=e=>"string"==typeof e?e:t.key(e),a=r=>e(r||t.key()).attr,o=(e,t)=>s.compile({key:t,maker:e}),l=e=>{let s=t.use(e);return r&&!r.get(s)&&r.pack(s,r.hydrate(s)||o(e,s)),a(s)},c=(...e)=>0===e.length?[l(n)]:e.map((e=>l(e)));return{use:c,remake:(e,s)=>{let n=t.key(s||e);return r&&r.get(n)?(s&&t.remake(e,s),r.pack(n,r.hydrate(n)||o(e,n)),a(n)):c(e)[0]},css:o,status:e=>{const t=i(e);return!!t&&r.status(t)},on:(...e)=>r.on(...e.map(i)),off:(...e)=>r.off(...e.map(i)),stylesheets:(e=t.keys)=>e.map((e=>r.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={...h.all()},r=Object.entries(t).filter((([e,t])=>!t.disabled)).map((([e,t])=>`<style ${xt}="${e}">${[...t.cssRules].map((e=>e.cssText)).join("")}</style>`)).join("");let s=gt,n="";const a={is:ot,min:e.getAttribute("min"),mode:e.getAttribute("mode"),size:e.getAttribute(pt),time:e.getAttribute(bt),angle:e.getAttribute(ft),color:e.getAttribute($t),easing:e.getAttribute(yt)};if(!i){s=dt,a.type="application/json";const t={theme:e.theme.actions,dict:l.dict};n=JSON.stringify(t)}return r+`<${s} ${Object.entries(a).map((([e,t])=>null!=t&&t!==jt[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${n}</${s}>`}}}),Object.assign(e,m)},Nt=Symbol(ot),Mt=[pt,bt,ft,$t,yt],Rt=new Set(Mt),Bt=()=>globalThis?.document.querySelector(`[is=${ot}]`);const Wt=(e={})=>{let{noscript:t,attrs:r={}}=e,{mode:s=jt.mode,min:n,pre:i=jt.prefix,size:a=null,time:o=null,angle:l=null,color:c=null,easing:u=null}=r;return new class{get tagName(){return""}get textContent(){return""}attributes={size:a?a+"":null,time:o?o+"":null,angle:l?l+"":null,color:c||null,easing:u||null,pre:i,mode:s,min:n?"":null};getAttribute(e){const t=this.attributes[e];return null!=t?_t(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",Rt.has(e)&&this._customize()}removeAttribute(e){delete this.attributes[e]}theme;pre;mode;min;size;angle;time;color;easing;use;remake;css;get makers(){return this._c.makers}status;on;off;stylesheets;_c;_m;_s;_p;_;_n;_customize=()=>{const e=this.size,t=this.time,r=this.angle,s=this.color,n=this.easing,i=qt({theme:this.theme,attrs:{size:e,time:t,angle:r,color:s,easing:n},scope:this._s(this._c.key())});this.remake(i,this._),this._=i};constructor(){Et(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},It=(e={})=>{const{emulate:t,global:r,...s}=e,n=globalThis?.document;let i;const a=globalThis[Nt];if(r&&a)i=a;else if(n&&!t){void 0===It.isDefined&&(It.isDefined=function(){const e=globalThis.document,t=globalThis.customElements;if(t?.get(ot))return!1;{class r extends HTMLScriptElement{static get observedAttributes(){return Mt}theme;pre;mode;min;size;angle;time;color;easing;use;remake;css;get makers(){return this._c.makers}status;on;off;stylesheets;_c;_m;_s;_p;_;_n;_customize=()=>{const e=this.size,t=this.time,r=this.angle,s=this.color,n=this.easing,i=qt({theme:this.theme,attrs:{size:e,time:t,angle:r,color:s,easing:n},scope:this._s(this._c.key())});this.remake(i,this._),this._=i};attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){Et(this,{initStyles:[...e.querySelectorAll(gt+`[${xt}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const t=this;this._n={set adoptedStyleSheets(e){t.dispatchEvent(new CustomEvent(vt,{detail:{styles:e},bubbles:!0}))}},this._m.register(this._n),this._m.register(e)}disconnectedCallback(){delete globalThis[Nt]}}t.define(ot,r,{extends:dt});class s extends HTMLElement{static get observedAttributes(){return[ct]}_customize(){const e=Bt();if(this.shadowRoot&&e){const t=this.getAttribute(ct),r=new CSSStyleSheet;if(t){const{$dark:s={},$light:n={},...i}=e.theme.makeThemeVars(JSON.parse(decodeURIComponent(t)));r.replaceSync(ut+`{${ht+Ct(i)}}`+mt+`(${St}){${ut}{${Ct(n)}}}`+mt+`(${kt}){${ut}{${Ct(s)}}}`)}else r.replaceSync(ut+`{${ht}}`);this.shadowRoot.adoptedStyleSheets=[r]}}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){this.attachShadow({mode:"open"}).innerHTML="<slot></slot>",this._customize()}}return t.define(lt,s),!0}}());const e=Bt();if(e)i=e;else{const e=n.createElement(dt,{is:ot});e.setAttribute("is",ot);const t=s?.attrs;t&&Object.entries(t).map((([t,r])=>r&&jt[t]!==r&&e.setAttribute(t,_t(r)?"":r+""))),n.head.appendChild(e),i=e}}else i=Wt(s);return r&&!a&&(globalThis[Nt]=i),i},Vt=e=>encodeURIComponent(JSON.stringify(e));export{jt as DEFAULT_ATTRS,ot as TAG_NAME,lt as TAG_NAME_OVERRIDE,Vt as prepareOverrideValues,It as useStyleProvider};
7
+ const e=(e,t,r)=>Object.entries(e).reduce(t,r),t=(e,t)=>{return`${r=e,r.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))}:${""+t};`;var r},r=Symbol("noParse"),s=(n,i,a)=>{let o=""+n;return null==i?"":Array.isArray(i)?i.map((e=>t(o,e))).join(""):"object"!=typeof i||i.hasOwnProperty(r)?""===i?o+";":t(o,i):(!a||a.startsWith?.("@")||o.startsWith?.("&")||o.startsWith?.("@")?"":"&")+o+`{${e(i,((e,t)=>e+s(...t,o)),"")}}`},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=g(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=>g(e))).join(" or ")}}),not:e=>"object"==typeof e&&"not"===e.type?e.value[0]:Object.defineProperties({type:"not",value:[e]},{toString:{value:()=>`not (${g(e,!0)})`}})},c=e=>{const t=t=>({toString:()=>`(min-${e}:${o(t)?t:t+"rem"})`}),r=t=>({toString:()=>`(max-${e}:${o(t)?t:t+"rem"})`}),s=(e,s)=>({toString:()=>`${t(e)} and ${r(s)}`});return{up:t,down:r,between:s,only:e=>s(e,e)}},u=c("width"),h=c("height"),m=c("inline-size"),d=c("block-size"),g=(e,t)=>e?"string"==typeof e?e.includes("(")||t?e:a(e):e+"":"",p=(e={})=>{const{type:t,condition:r}=e,s=g(r),n="object"==typeof r&&"or"===r.type,i=`@media${t?" "+t:""}${t&&s?" and":""}${s?" "+(t&&n?a(s):s):""}`;return Object.defineProperties((e=>({[i]:e})),{all:{get:()=>p({condition:r,type:"all"})},print:{get:()=>p({condition:r,type:"print"})},screen:{get:()=>p({condition:r,type:"screen"})},where:{value:e=>p({condition:e,type:t})},toString:{value:()=>i}})},b=p({}),f=({condition:e}={})=>{const t=g(e),r="@supports"+(t?" "+t:"");return Object.defineProperties((e=>({[r]:e})),{where:{value:e=>f({condition:e})},toString:{value:()=>r}})},$=f(),y=e=>({[i]:e});y.toString=i;const v=e=>{const{root:t="",limit:r="",mode:s=[!1,!1]}=e,n=`@scope ${t?`(${t}${s[0]?" > *":""})`:""}${t&&r?" ":""}${r?`to (${r}${s[1]?" > *":""})`:""}`;return Object.defineProperties((e=>({[n]:e})),{limit:{value:e=>v({root:t,limit:e,mode:s})},root:{value:e=>v({root:e,limit:r,mode:s})},both:{value:()=>v({root:t,limit:r,mode:[!1,!0]})},none:{value:()=>v({root:t,limit:r,mode:[!0,!1]})},low:{value:()=>v({root:t,limit:r,mode:[!0,!0]})},high:{value:()=>v({root:t,limit:r,mode:[!1,!1]})},toString:{value:()=>n}})},x=v({}),w=(e,t)=>`calc(${e} * 1${t})`,k=e=>w(e,"px"),S=e=>w(e,"vh"),j=e=>w(e,"vw"),_=e=>w(e,"vmin"),A=e=>w(e,"vmax"),O=e=>w(e,"em"),z=e=>w(e,"rem"),C=e=>w(e,"deg"),q=e=>w(e,"rad"),P=e=>w(e,"rad"),N=e=>w(e,"ms"),E=e=>w(e,"s"),T=e=>w(e,"%"),M=e=>w(e,"cqw"),R=e=>w(e,"cqh"),B=e=>w(e,"cqi"),W=e=>w(e,"cqb"),I=e=>w(e,"cqmin"),V=e=>w(e,"cqmax"),J=Object.fromEntries,L=Object.entries,H=":first-",D=":last-",K=":only-",U="child",F=":nth-",Z="of-type",G=F+U,Q=":focus",X="valid",Y="in"+X,ee=":user-",te="placeholder",re={r:":root",h:":hover",f:Q,fv:Q+"-visible",a:":active",v:":visited",val:":"+X,inv:":"+Y,uval:ee+X,uinv:ee+Y,e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",phs:`:${te}-shown`,ch:":checked",po:":popover-open",fc:H+U,lc:D+U,oc:K+U,odd:G+"(odd)",even:G+"(even)",ft:H+Z,lt:D+Z,ot:K+Z,bef:"::before",aft:"::after",ph:`::${te}`,bd:"::backdrop",fl:"::first-line",dc:"::details-content",sel:"::selection"},se={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:G,ntho:F+Z,dir:":dir",lang:":lang"},ne=e=>`oklch(${e})`,ie=e=>ne(`from ${e}`),ae=e=>t=>t?ie(e+` ${t.l||"l"} ${t.c||"c"} ${t.h||"h"} / ${t.a||"1"}`):e,oe=(e,t=.1)=>ie(`${e} calc(l + ${t}) c h / alpha`),le=(e,t=.1)=>ie(`${e} calc(l - ${t}) c h / alpha`),ce=(e,t=.1)=>ie(`${e} l c h / calc(alpha + ${t})`),ue=(e,t=.1)=>ie(`${e} l c h / calc(alpha - ${t})`),he=(e,t=.04)=>ie(`${e} l calc(c + ${t}) h / alpha`),me=(e,t=.04)=>ie(`${e} l calc(c - ${t}) h / alpha`),de=e=>ie(`${e} l c calc(h + 180) / alpha`),ge=e=>ie(`${e} l 0 h / alpha`),pe=(e,t=30)=>ie(`${e} l c calc(h${"number"==typeof t?t>0?" + "+t:" - "+-t:t}) / alpha`),be=e=>{const t=e("color"),r=e("contrast"),s=e("neutral");return{root:ae(t),contrast:ae(r),neutral:ae(s),oklch:ne,lighten:oe,darken:le,saturate:he,desaturate:me,fadein:ce,fadeout:ue,spin:pe,complement:de,grayscale:ge}},fe=e=>{class t{state={l:"l",c:"base",h:"pri",a:"1",m:"bg"};constructor(e={}){Object.assign(this,{[r]:!0}),this.state=Object.assign(this.state,e)}get xs(){return new t({...this.state,l:"xs"})}get s(){return new t({...this.state,l:"s"})}get m(){return new t({...this.state,l:"m"})}get l(){return new t({...this.state,l:"l"})}get xl(){return new t({...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({...this.state,c:"gray"})}get pale(){return new t({...this.state,c:"pale"})}get base(){return new t({...this.state,c:"base"})}get rich(){return new t({...this.state,c:"rich"})}get chroma(){return{gray:this.gray,pale:this.pale,base:this.base,rich:this.rich}}get pri(){return new t({...this.state,h:"pri"})}get sec(){return new t({...this.state,h:"sec"})}get suc(){return new t({...this.state,h:"suc"})}get inf(){return new t({...this.state,h:"inf"})}get war(){return new t({...this.state,h:"war"})}get dan(){return new t({...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({...this.state,a:e+""})}get bg(){return new t({...this.state,m:"bg"})}get fg(){return new t({...this.state,m:"fg"})}toString(){const{l:t,c:r,h:s,a:n,m:i}=this.state;return`oklch(${e(`lightness.${i}.${t}`)} ${e(`chroma.${i}.${r}`)} ${e(`hue.${s}`)} / ${n})`}}return new t},$e=e=>{const t=(t,r=0)=>e(`coef.${t.state.center+r}`);class r{state={center:8};constructor(e={}){this.state=Object.assign(this.state,e)}get min(){return t(this,-4)}get xxs(){return t(this,-3)}get xs(){return t(this,-2)}get s(){return t(this,-1)}get m(){return t(this)}get l(){return t(this,1)}get xl(){return t(this,2)}get xxl(){return t(this,3)}get max(){return t(this,4)}get $xxs(){return new r({center:4})}get $xs(){return new r({center:8})}get $s(){return new r({center:12})}get $m(){return new r({center:16})}get $l(){return new r({center:20})}get $xl(){return new r({center:24})}get $xxl(){return new r({center:28})}get short(){return{s:this.s,m:this.m,l:this.l}}get base(){return{xs:this.xs,...this.short,xl:this.xl}}get long(){return{xxs:this.xxs,...this.base,xxl:this.xxl}}get full(){return{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 r},ye=Object.assign,ve=Object.entries,xe=Array.isArray,we=e=>"object"==typeof e,ke=(e,t)=>Array.from(Array(e).entries()).reduce(((e,[r])=>ye(e,t(r+1))),{}),Se=(e,t)=>ve(e).reduce(((e,[r,s])=>ye(e,t(r,s))),{}),je=(e,t,r={})=>e?t:r,_e=(...e)=>e.join("-"),Ae=(...e)=>e.join(),Oe=(...e)=>e.join(" "),ze=(e,...t)=>t.length?t.reduce(((e,t)=>(t&&e&&we(t)&&ve(t).forEach((([t,r])=>{r&&we(r)&&e[t]?xe(e[t])&&xe(r)?e[t]=[...e[t],...r]:ze(e[t],r||{}):e[t]=r})),e)),e):e,Ce=Object.assign(J(L(re).map((([e,t])=>{function r(e=""){return e&&"object"==typeof e?{[t]:e}:e+t}return r.toString=()=>t,[e,r]}))),J(L(se).map((([e,t])=>{function r(e,r=""){const s=t+`(${e})`;return r&&"object"==typeof r?{[s]:r}:r+s}return r.toString=()=>t,[e,r]})))),qe={px:k,vh:S,vw:j,vmin:_,vmax:A,em:O,rem:z,deg:C,rad:q,turn:P,ms:N,s:E,pc:T,cqw:M,cqh:R,cqb:W,cqi:B,cqmin:I,cqmax:V},Pe=e=>1!==e?e+" * ":"",Ne=t=>{const{scope:i,globalKey:a}=t,o=i(a).varExp,c=(e=1)=>qe.ms(Pe(e)+o("time")),p=(e=1)=>qe.deg(Pe(e)+o("angle")),f=(e=1)=>qe.px(Pe(e)+o("size")),v=e=>e?`cubic-bezier(${e.x1||0},${e.y1||0},${e.x2||1},${e.y2||1})`:o("easing");return{compile:({key:t,maker:a})=>{const w=i(t),k=w.selector,S=w.select,j=(e=>{const t={cp:1,lay:1,kf:1,cq:1},s=(n={})=>{const{scroll:i,type:a,name:o,condition:l}=n,c=g(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}})},i=({name:r}={})=>{const s=`${n}${r?" "+r:""}`,a=e=>({[s]:e});return a.toString=()=>s,Object.defineProperties(a,{named:{get:()=>i({name:r||e.name(["lay",t.lay++])})},list:{value:(...e)=>({[n+(e.map((e=>(e+"").split(n)[1])).filter(Boolean).join(",")||r)]:""})}})};return{layer:i(),supports:$,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:r,del:s,ic:i,dir:a,ps:o,fm:l}=e;return{animation:[t,r,s,i,a,o,l,n].filter(Boolean).join(" ")}}),{[i]:{value:s,enumerable:!0},toString:{value:()=>n},[r]:{value:!0}})},property:(s={})=>{let n,i,a='"*"',o=!0;"object"==typeof s?({syn:a=a,inh:o=o,ini:n,def:i}=s):(i=s,n=s,o=!1);const l="--"+e.name(["cp",t.cp++]),c=`var(${l}${void 0!==i?","+i:""})`,u="@property "+l;return Object.defineProperties((e=>({[l]:e})),{[u]:{value:{syntax:a,inherits:o,initialValue:n},enumerable:!0},toString:{value:()=>c},fallback:{value:e=>`var(${l},${e})`},[r]:{value:!0}})},scope:x,media:b,container:s({}),startingStyle:y,$logic:l,$width:u,$height:h,$block:d,$inline:m}})(w),_=a({dash:_e,comma:Ae,space:Oe,range:ke,each:Se,when:je,merge:ze,themeVar:o,size:f,time:c,angle:p,easing:v,bem:k,select:S,pseudo:Ce,color:be(o),palette:fe(o),coef:$e(o),units:qe,at:j});return"string"==typeof _?_:(t=>e(t,((e,t)=>e+s(...t)),""))(_)}}},Ee=Symbol("effcss-stylesheet");class Te{disabled=!1;cssRules=[];replaceSync(e){e&&(this.cssRules=[{cssText:e}])}}function Me({initStyles:e,emulate:t}={}){const r={};e?.forEach((e=>{const t=e?.dataset?.effcss;t&&(r[t]=e)}));let s={},n={},i=[],a=[];const o=(e,t)=>t.hasOwnProperty(Ee)?t:Object.defineProperties(t,{[Ee]:{value:e}}),l=e=>e.adoptedStyleSheets=[...e.adoptedStyleSheets?.length?[...e.adoptedStyleSheets].filter((e=>!e.hasOwnProperty(Ee))):[],...i],c=()=>{a=a.reduce(((e,t)=>{const r=t.deref();return r&&(l(r),e.push(t)),e}),[])},u=e=>e?s[e]:void 0,h=(e,t)=>{if(!s[e]){s[e]=o(e,t),i.push(s[e]);const n=r[e];return n&&(n.disabled=!0),c(),!0}};return{get:u,all:()=>s,add:h,status:e=>{const t=u(e);return!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 r=(a=t,i.findIndex((e=>e===a)));var a;return r>-1&&(i.splice(r,1),delete s[e],delete n[e]),c(),!0},removeAll:()=>(i.splice(0),s={},n={},c(),!0),pack:(e,r)=>{let n=s[e]||(!t&&globalThis.CSSStyleSheet?new globalThis.CSSStyleSheet:new Te);return n.replaceSync(r),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=>r[e]&&!r[e].disabled&&r[e].textContent||void 0}}const Re=({prefix:e})=>{let t=0;return{get initial(){return e+0},get current(){return e+t},next(){return t++,this.current}}},Be=({prefix:e})=>{const t=new Set,r=new Map,s=Re({prefix:e});return{use(e){let n=this.key(e);return n||(n=s.current,t.add(n),r.set(e,n),s.next(),n)},remake(e,t){const s=r.get(t);return s?(r.delete(t),r.set(e,s),s):this.use(e)},key:e=>e?r.get(e)||"":s.initial,get keys(){return[...t]},get makers(){return Object.fromEntries(r.entries().map((([e,t])=>[t,e])))}}},We=void 0,Ie=Object.entries,Ve=Object.defineProperties,Je=e=>"string"==typeof e,Le=e=>null!==e&&"object"==typeof e,He=e=>e.split("."),De=(e,t="")=>Ie(e).reduce(((e,[r,s])=>{const n=t?`${t}-${r}`:r;return"object"==typeof s?(e.add(n),e=e.union(De(s,n))):e.add(n+`_${s}`),e}),new Set),Ke=(e,t="")=>Ie(e).reduce(((e,[r,s])=>{const n=t?`${t}-${r}`:r;if("object"==typeof s){const t=Ke(s,n);t.size||e.add(n),e=e.union(t)}else t&&e.add(t),e.add(n+`_${s}`);return e}),new Set),Ue=(e,t)=>Ie(e).reduce(((e,[r,s])=>{if(Le(s)){const n=Ie(s);n.length?e.push(...n.reduce(((e,[s,n])=>{if((e=>null!==e&&e!==We)(s)&&t&&e.push([r,s,We,We]),Le(n)){const t=Ie(n);t.length&&e.push(...t.reduce(((e,[t,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||e.push([r,s,t,n]),e}),[]))}return e}),[])):e.push([r,We,We,We])}return e}),[]),Fe=(e,t,r,s)=>""+(((e,t)=>`${e||""}${t?"__"+t:""}`)(e,t)+(r?"_"+r:"")+(r&&s?"_"+s:""))||"_",Ze=(e,t)=>"."+(t?e+(t.startsWith("_")?"":"-")+t:e),Ge=(e,t)=>`[data-${e}${t?`~="${t}"`:""}]`;const Qe=e=>e||"",Xe=Object.assign,Ye=Object.entries,et="theme",tt="delete",rt="update",st="$light",nt="$dark",it="lightness",at="chroma",ot=e=>Number((.1*184+.9*e).toFixed(2)),lt={time:200,size:16,angle:30,color:"#2192a7",contrast:"light-dark(black, white)",neutral:"light-dark(white, #1b1f1f)",easing:"linear",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:3,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:ot(142),inf:ot(264),war:ot(109),dan:ot(29)},[st]:{[it]:{bg:{xl:1,l:.94,m:.88,s:.83,xs:.78},fg:{xl:0,l:.12,m:.24,s:.36,xs:.48}},[at]:{bg:{gray:0,pale:.01,base:.04,rich:.7},fg:{gray:0,pale:.07,base:.11,rich:.15}}},[nt]:{[it]:{bg:{xl:.24,l:.3,m:.36,s:.42,xs:.48},fg:{xl:1,l:.93,m:.86,s:.79,xs:.72}},[at]:{bg:{pale:.02,base:.06,rich:.1},fg:{pale:.06,base:.1,rich:.14}}}},ct=({provider:e,init:t,scope:r,onChange:s})=>{const n={"":lt},i=[],a=({$light:e={},$dark:t={},...s})=>{function n(e,t=[]){return Ye(e).reduce(((e,[s,i])=>i&&"object"==typeof i?Xe(e,n(i,[...t,s])):(e[r.varName([...t,s])]=i,e)),{})}return{...n(s),[st]:n(e),[nt]:n(t)}},o={get:(e="")=>n[e],add(e,t){n[t]||(n[t]=ze({[st]:{},[nt]:{}},e),i.push({type:"add",payload:{params:e,name:t}}),s?.())},delete(e){e&&n[e]&&(this.current===e&&this.switch(),delete n[e],i.push({type:tt,payload:{name:e}}),s?.())},update(e,t=""){n[t]&&(n[t]=ze({[st]:{},[nt]:{}},n[t],e),i.push({type:rt,payload:{params:e,name:t}}),s?.())},switch(t=""){n[t]&&e.setAttribute(et,t)},vars(e=""){const t=this.get(e);return t?a(t):{[st]:{},[nt]:{}}},makeThemeVars:a,get list(){const{"":e,...t}=n;return Object.keys(t)},get current(){return e.getAttribute(et)||""},get all(){return n},get actions(){return i}};return t?.forEach((({type:e,payload:t})=>{switch(e){case"add":o.add(t.params,t.name);break;case tt:o.delete(t.name);break;case rt:o.update(t.params,t.name)}})),o},ut="effcss",ht=ut+"-provider",mt=ut+"-override",dt="values",gt=":host",pt="@media",bt="script",ft="style",$t="size",yt="time",vt="angle",xt="color",wt="contrast",kt="neutral",St="easing",jt=ut+"changes",_t="data-"+ut,At="prefers-color-scheme",Ot=`${At}: light`,zt=`${At}: dark`,Ct={mode:"a",pre:"f"},qt=e=>"boolean"==typeof e,Pt=(e,t)=>{const r=((e,t)=>e.getAttribute(t)||Ct[t])(e,t);return(e=>"string"==typeof e?Number(e):null)(r)},Nt=(e,t,r)=>null===r?e.removeAttribute(t):e.setAttribute(t,r+""),Et=e=>`:root:has([is=${ht}]${e?`[${e}]`:""})`,Tt=e=>Object.entries(e).reduce(((e,[t,r])=>e+t+":"+r+";"),""),Mt=({theme:e,attrs:t,scope:r})=>({bem:s,each:n,themeVar:i,merge:a,pseudo:{r:o},at:{media:l},units:{px:c}})=>{const u=t.size,h=t.time,m=t.angle,d=t.color,g=t.easing,p=t.contrast,b=t.neutral,{$dark:f={},$light:$={},...y}=e.vars();return a({[Et()]:{...y,...l.where(Ot)($),...l.where(zt)(f),[o()]:{fontSize:c(i("size"))}}},n(e.list,((t,r)=>{const{$dark:n={},$light:i={},...a}=e.vars(r),o={...a,...l.where(Ot)(i),...l.where(zt)(n)};return{[Et(`theme=${t}`)]:o,[s(`..theme.${t}`)]:o}})),u&&{[Et($t)]:{[r.varName($t)]:u}},h&&{[Et(yt)]:{[r.varName(yt)]:h}},m&&{[Et(vt)]:{[r.varName(vt)]:m}},d&&{[Et(xt)]:{[r.varName(xt)]:d}},g&&{[Et(St)]:{[r.varName(St)]:g}},p&&{[Et(wt)]:{[r.varName(wt)]:p}},b&&{[Et(kt)]:{[r.varName(kt)]:b}})},Rt=(e,t)=>({set(r){Nt(e,t,r)},get:()=>Pt(e,t)}),Bt=(e,t)=>({set(r){Nt(e,t,r)},get:()=>e.getAttribute(t)}),Wt=(e,{initStyles:t,emulate:r,onChange:s,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:Rt(e,$t),time:Rt(e,yt),angle:Rt(e,vt),color:Bt(e,xt),easing:Bt(e,St),contrast:Bt(e,wt),neutral:Bt(e,kt)});const o=Be({prefix:e.pre}),l=((e={})=>{const{mode:t,min:r,dict:s={}}=e;let n;n="a"===t?Ge:Ze;const i=e=>{let r=0,s=Qe,a=Qe;const o=i.dict;o&&(o[e]||(o[e]={}),s=t=>o[e][t]??(o[e][t]=(r++).toString(36)),a=t=>o[e][t]);let l=t=>[e,...Je(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=Qe);const h=e=>"--"+l(Je(e)?e.split("."):e),m=e=>Ve({[c]:e},{toString:{value:()=>`${c}="${e}"`},$:{value:e}}),d=e=>{if(void 0===e)return function(e){const t=({b:r,e:s,m:n})=>({b:e=>t({b:e,e:"",m:{}}),e:e=>t({b:r,e:e,m:{}}),m:(e={})=>t({b:r,e:s,m:e}),get $(){return e({[r]:{[s]:n}})}});return t({b:"",e:"",m:{}})}(d);let t,r,s,n,i="";const o=Je(e);return i=o||Array.isArray(e)?[...(o?[e]:e).reduce(((e,i)=>([t,r,s,n]=He(i),e.add(u(a(Fe(t,r)))),s&&e.add(u(a(Fe(t,r,s,n)))),e)),new Set).values()].join(" "):e&&Ue(e,!0).map((([e,t,r,s])=>u(a(Fe(e,t,r,s))))).join(" "),m(i)};return d.list=(...e)=>{const t=[...e.reduce(((e,t)=>{const[r,s]=t.split(":");if(!r)return e;if(void 0===s)return e.add(r.replaceAll(".","-")),e;const n=r.split("."),i=n.pop(),a=n.join("-");return n.length?(e.add(a),e.add(a+`-${i}_${s}`)):e.add(`${i}_${s}`),e}),new Set).keys()].map((e=>u(a(e)))).join(" ");return m(t)},d.obj=(e,t)=>{let r=Ke;"full"===t&&(r=De);const s=[...r(e).values()].map((e=>u(a(e)))).join(" ");return m(s)},{select:t=>{const r=t.replaceAll(".","-").replace(":","_");return n(e,s(r))},selector:t=>{const[r,i,a,o]=He(t);return n(e,s(Fe(r,i,a,o)))},attr:d,name:l,varName:h,varExp:(e,t)=>`var(${h(e)}${void 0!==t?","+t:""})`}};return r&&(i.dict=s),i})({mode:e.mode,min:e.min,dict:a?.dict}),c=l(o.key()),u=Ne({scope:l,globalKey:o.key()}),h=Me({initStyles:t,emulate:r});e.theme=ct({provider:e,init:a?.theme,onChange:s,scope:c});const m=(({scope:e,collector:t,manager:r,processor:s,globalMaker:n})=>{const i=e=>"string"==typeof e?e:t.key(e),a=r=>e(r||t.key()).attr,o=(e,t)=>s.compile({key:t,maker:e}),l=e=>{let s=t.use(e);return r&&!r.get(s)&&r.pack(s,r.hydrate(s)||o(e,s)),a(s)},c=(...e)=>0===e.length?[l(n)]:e.map((e=>l(e)));return{use:c,remake:(e,s)=>{let n=t.key(s||e);return r&&r.get(n)?(s&&t.remake(e,s),r.pack(n,r.hydrate(n)||o(e,n)),a(n)):c(e)[0]},css:o,status:e=>{const t=i(e);return!!t&&r.status(t)},on:(...e)=>r.on(...e.map(i)),off:(...e)=>r.off(...e.map(i)),stylesheets:(e=t.keys)=>e.map((e=>r.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={...h.all()},r=Object.entries(t).filter((([e,t])=>!t.disabled)).map((([e,t])=>`<style ${_t}="${e}">${[...t.cssRules].map((e=>e.cssText)).join("")}</style>`)).join("");let s=ft,n="";const a={is:ht,min:e.getAttribute("min"),mode:e.getAttribute("mode"),size:e.getAttribute($t),time:e.getAttribute(yt),angle:e.getAttribute(vt),color:e.getAttribute(xt),easing:e.getAttribute(St),contrast:e.getAttribute(wt),neutral:e.getAttribute(kt)};if(!i){s=bt,a.type="application/json";const t={theme:e.theme.actions,dict:l.dict};n=JSON.stringify(t)}return r+`<${s} ${Object.entries(a).map((([e,t])=>null!=t&&t!==Ct[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${n}</${s}>`}}}),Object.assign(e,m)},It=Symbol(ht),Vt=[$t,yt,vt,xt,St,wt,kt],Jt=new Set(Vt),Lt=()=>globalThis?.document.querySelector(`[is=${ht}]`);const Ht=(e={})=>{let{noscript:t,attrs:r={}}=e,{mode:s=Ct.mode,min:n,pre:i=Ct.prefix,size:a=null,time:o=null,angle:l=null,color:c=null,easing:u=null,contrast:h=null,neutral:m=null}=r;return new class{get tagName(){return""}get textContent(){return""}attributes={size:a?a+"":null,time:o?o+"":null,angle:l?l+"":null,color:c||null,easing:u||null,contrast:h||null,neutral:m||null,pre:i,mode:s,min:n?"":null};getAttribute(e){const t=this.attributes[e];return null!=t?qt(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",Jt.has(e)&&this._customize()}removeAttribute(e){delete this.attributes[e]}theme;pre;mode;min;size;angle;time;color;easing;contrast;neutral;use;remake;css;get makers(){return this._c.makers}status;on;off;stylesheets;_c;_m;_s;_p;_;_n;_customize=()=>{const e=this.size,t=this.time,r=this.angle,s=this.color,n=this.easing,i=this.contrast,a=this.neutral,o=Mt({theme:this.theme,attrs:{size:e,time:t,angle:r,color:s,easing:n,contrast:i,neutral:a},scope:this._s(this._c.key())});this.remake(o,this._),this._=o};constructor(){Wt(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},Dt=(e={})=>{const{emulate:t,global:r,...s}=e,n=globalThis?.document;let i;const a=globalThis[It];if(r&&a)i=a;else if(n&&!t){void 0===Dt.isDefined&&(Dt.isDefined=function(){const e=globalThis.document,t=globalThis.customElements;if(t?.get(ht))return!1;{class r extends HTMLScriptElement{static get observedAttributes(){return Vt}theme;pre;mode;min;size;angle;time;color;easing;contrast;neutral;use;remake;css;get makers(){return this._c.makers}status;on;off;stylesheets;_c;_m;_s;_p;_;_n;_customize=()=>{const e=this.size,t=this.time,r=this.angle,s=this.color,n=this.easing,i=this.contrast,a=this.neutral,o=Mt({theme:this.theme,attrs:{size:e,time:t,angle:r,color:s,easing:n,contrast:i,neutral:a},scope:this._s(this._c.key())});this.remake(o,this._),this._=o};attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){Wt(this,{initStyles:[...e.querySelectorAll(ft+`[${_t}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const t=this;this._n={set adoptedStyleSheets(e){t.dispatchEvent(new CustomEvent(jt,{detail:{styles:e},bubbles:!0}))}},this._m.register(this._n),this._m.register(e)}disconnectedCallback(){delete globalThis[It]}}t.define(ht,r,{extends:bt});class s extends HTMLElement{static get observedAttributes(){return[dt,...Vt]}_customize(){const e=Lt();if(this.shadowRoot&&e){const t=this.getAttribute(dt),r=new CSSStyleSheet,s=t?JSON.parse(decodeURIComponent(t)):{};Vt.forEach((e=>{const t=this.getAttribute(e);t&&(s[e]=t)}));const{$dark:n={},$light:i={},...a}=e.theme.makeThemeVars(s);r.replaceSync(gt+`{${"display:contents;"+Tt(a)}}`+pt+`(${Ot}){${gt}{${Tt(i)}}}`+pt+`(${zt}){${gt}{${Tt(n)}}}`),this.shadowRoot.adoptedStyleSheets=[r]}}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){this.attachShadow({mode:"open"}).innerHTML="<slot></slot>",this._customize()}}return t.define(mt,s),!0}}());const e=Lt();if(e)i=e;else{const e=n.createElement(bt,{is:ht});e.setAttribute("is",ht);const t=s?.attrs;t&&Object.entries(t).map((([t,r])=>r&&Ct[t]!==r&&e.setAttribute(t,qt(r)?"":r+""))),n.head.appendChild(e),i=e}}else i=Ht(s);return r&&!a&&(globalThis[It]=i),i},Kt=e=>encodeURIComponent(JSON.stringify(e));export{Ct as DEFAULT_ATTRS,ht as TAG_NAME,mt as TAG_NAME_OVERRIDE,Kt as prepareOverrideValues,Dt as useStyleProvider};
@@ -1,17 +1,40 @@
1
1
  import type { TCreateScope } from '../../_provider/scope';
2
+ type TOKLCH = {
3
+ /**
4
+ * Lightness
5
+ */
6
+ l?: string | number;
7
+ /**
8
+ * Chroma
9
+ */
10
+ c?: string | number;
11
+ /**
12
+ * Hue
13
+ */
14
+ h?: string | number;
15
+ /**
16
+ * Alpha
17
+ */
18
+ a?: string | number;
19
+ };
2
20
  type TChangeStr = (val: string) => string;
3
21
  type TChangeColor = (color: string | object, val?: number | string) => string;
4
22
  export declare const resolveColor: (varExp: ReturnType<ReturnType<TCreateScope>>["varExp"]) => {
5
23
  /**
6
- * Root color
7
- * @param p - oklch params
24
+ * Theme root color
25
+ * @param params - oklch params
8
26
  */
9
- root: (p?: {
10
- l?: string | number;
11
- c?: string | number;
12
- h?: string | number;
13
- a?: string | number;
14
- }) => string;
27
+ root: (params?: TOKLCH) => string;
28
+ /**
29
+ * Theme contrast color
30
+ * @param params - oklch params
31
+ */
32
+ contrast: (params?: TOKLCH) => string;
33
+ /**
34
+ * Theme neutral color
35
+ * @param params - oklch params
36
+ */
37
+ neutral: (params?: TOKLCH) => string;
15
38
  /**
16
39
  * oklch()
17
40
  */
@@ -44,5 +67,13 @@ export declare const resolveColor: (varExp: ReturnType<ReturnType<TCreateScope>>
44
67
  * Rotate color hue
45
68
  */
46
69
  spin: TChangeColor;
70
+ /**
71
+ * Get complement color
72
+ */
73
+ complement: (color: string | object) => string;
74
+ /**
75
+ * Get grayscale color
76
+ */
77
+ grayscale: (color: string | object) => string;
47
78
  };
48
79
  export {};
@@ -1,5 +1,11 @@
1
- type TSimplePseudo = (val?: string | number) => string;
2
- type TComplexPseudo = (content: string | number, val?: string | number) => string;
1
+ type TSimplePseudo = {
2
+ (val?: string | number): string;
3
+ (val: object): object;
4
+ };
5
+ type TComplexPseudo = {
6
+ (content: string | number, val?: string | number): string;
7
+ (content: string | number, val: object): object;
8
+ };
3
9
  type TPseudo = {
4
10
  /**
5
11
  * :root
@@ -66,9 +72,9 @@ type TPseudo = {
66
72
  */
67
73
  l: TSimplePseudo;
68
74
  /**
69
- * :placeholder
75
+ * :placeholder-shown
70
76
  */
71
- ph: TSimplePseudo;
77
+ phs: TSimplePseudo;
72
78
  /**
73
79
  * :checked
74
80
  */
@@ -121,6 +127,22 @@ type TPseudo = {
121
127
  * ::backdrop
122
128
  */
123
129
  bd: TSimplePseudo;
130
+ /**
131
+ * ::placeholder
132
+ */
133
+ ph: TSimplePseudo;
134
+ /**
135
+ * ::first-line
136
+ */
137
+ fl: TSimplePseudo;
138
+ /**
139
+ * ::details-content
140
+ */
141
+ dc: TSimplePseudo;
142
+ /**
143
+ * ::selection
144
+ */
145
+ sel: TSimplePseudo;
124
146
  /**
125
147
  * :has
126
148
  */
@@ -36,13 +36,21 @@ export type TProviderAttrs = {
36
36
  */
37
37
  angle: number;
38
38
  /**
39
- * Root color string
39
+ * Root color
40
40
  */
41
41
  color: string;
42
42
  /**
43
43
  * Root easing function
44
44
  */
45
45
  easing: string;
46
+ /**
47
+ * Root contrast color
48
+ */
49
+ contrast: string;
50
+ /**
51
+ * Root neutral color
52
+ */
53
+ neutral: string;
46
54
  };
47
55
  type TResolveAttr = ReturnType<TScopeResolver>['attr'];
48
56
  /**
@@ -131,14 +139,32 @@ export interface IStyleProvider {
131
139
  */
132
140
  set angle(val: TNumberOrNull);
133
141
  /**
134
- * Get root color value
142
+ * Get brand color value
135
143
  */
136
144
  get color(): TStringOrNull;
137
145
  /**
138
- * Set root color value
139
- * @param val - angle value in ms
146
+ * Set brand color value
147
+ * @param val - color string
140
148
  */
141
149
  set color(val: TStringOrNull);
150
+ /**
151
+ * Get neutral color value
152
+ */
153
+ get neutral(): TStringOrNull;
154
+ /**
155
+ * Set neutral color value
156
+ * @param val - color string
157
+ */
158
+ set neutral(val: TStringOrNull);
159
+ /**
160
+ * Get contrast color value
161
+ */
162
+ get contrast(): TStringOrNull;
163
+ /**
164
+ * Set contrast color value
165
+ * @param val - color string
166
+ */
167
+ set contrast(val: TStringOrNull);
142
168
  /**
143
169
  * Get root easing function
144
170
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effcss",
3
- "version": "4.6.2",
3
+ "version": "4.8.0",
4
4
  "description": "Self-confident CSS-in-JS",
5
5
  "type": "module",
6
6
  "scripts": {