@symbo.ls/scratch 3.14.781 → 3.14.783

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.
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var i=(e,t)=>{for(var p in t)m(e,p,{get:t[p],enumerable:!0})},f=(e,t,p,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let x of n(t))!a.call(e,x)&&x!==p&&m(e,x,{get:()=>t[x],enumerable:!(s=c(t,x))||s.enumerable});return e},r=(e,t,p)=>(f(e,t,"default"),p&&f(p,t,"default"));var h=e=>f(m({},"__esModule",{value:!0}),e);var o={};i(o,{reset:()=>u,shape:()=>b,sizes:()=>z,vars:()=>v});module.exports=h(o);r(o,require("./sequence.js"),module.exports);r(o,require("./unit.js"),module.exports);r(o,require("./typography.js"),module.exports);r(o,require("./font.js"),module.exports);r(o,require("./font-family.js"),module.exports);r(o,require("./media.js"),module.exports);r(o,require("./spacing.js"),module.exports);r(o,require("./color.js"),module.exports);r(o,require("./theme.js"),module.exports);r(o,require("./shadow.js"),module.exports);r(o,require("./icons.js"),module.exports);r(o,require("./timing.js"),module.exports);r(o,require("./document.js"),module.exports);r(o,require("./responsive.js"),module.exports);r(o,require("./animation.js"),module.exports);r(o,require("./svg.js"),module.exports);r(o,require("./templates.js"),module.exports);r(o,require("./grid.js"),module.exports);r(o,require("./class.js"),module.exports);const u={},v={},z={},b={};
1
+ "use strict";var m=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var a=(e,t)=>{for(var p in t)m(e,p,{get:t[p],enumerable:!0})},f=(e,t,p,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let x of n(t))!i.call(e,x)&&x!==p&&m(e,x,{get:()=>t[x],enumerable:!(s=c(t,x))||s.enumerable});return e},r=(e,t,p)=>(f(e,t,"default"),p&&f(p,t,"default"));var h=e=>f(m({},"__esModule",{value:!0}),e);var o={};a(o,{reset:()=>k,shape:()=>z,sizes:()=>v,skins:()=>b,vars:()=>u});module.exports=h(o);r(o,require("./sequence.js"),module.exports);r(o,require("./unit.js"),module.exports);r(o,require("./typography.js"),module.exports);r(o,require("./font.js"),module.exports);r(o,require("./font-family.js"),module.exports);r(o,require("./media.js"),module.exports);r(o,require("./spacing.js"),module.exports);r(o,require("./color.js"),module.exports);r(o,require("./theme.js"),module.exports);r(o,require("./shadow.js"),module.exports);r(o,require("./icons.js"),module.exports);r(o,require("./timing.js"),module.exports);r(o,require("./document.js"),module.exports);r(o,require("./responsive.js"),module.exports);r(o,require("./animation.js"),module.exports);r(o,require("./svg.js"),module.exports);r(o,require("./templates.js"),module.exports);r(o,require("./grid.js"),module.exports);r(o,require("./class.js"),module.exports);const k={},u={},v={},z={},b={};
@@ -1 +1 @@
1
- "use strict";var A=Object.create;var m=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},T=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of V(t))!F.call(e,n)&&n!==o&&m(e,n,{get:()=>t[n],enumerable:!(s=y(t,n))||s.enumerable});return e};var I=(e,t,o)=>(o=e!=null?A(R(e)):{},T(t||!e||!e.__esModule?m(o,"default",{value:e,enumerable:!0}):o,e)),D=e=>T(m({},"__esModule",{value:!0}),e);var X={};P(X,{CONFIG:()=>i,CONFIG_MERGE_EXL:()=>b,FACTORY:()=>l,activateConfig:()=>G,aliasCaseVariants:()=>C,createConfig:()=>B,cssMediaVars:()=>d,cssVars:()=>v,defineResolvedThemeSignal:()=>p,defineThemeSignal:()=>f,getActiveConfig:()=>O,getResolvedThemeSignal:()=>E,getThemeSignal:()=>j,popConfig:()=>w,pushConfig:()=>L,setActiveConfig:()=>N,toCamel:()=>x});module.exports=D(X);var r=require("@symbo.ls/utils"),h=require("@symbo.ls/signal"),M=I(require("./defaultConfig/index.js"),1);const v={},d={},b=new Set,g=M,_={},x=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in g){const t=e.toLowerCase();_[t]=g[e];const o=x(t);o!==t&&(_[o]=g[e]),t!==e&&(_[e]=g[e])}const i={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:v,cssMediaVars:d,CSS_VARS:v,CSS_MEDIA_VARS:d,_scratchConfig:!0,..._},f=(e,t)=>{if(!e)return null;if(e.__globalThemeSignal)return(0,r.isDefined)(t)&&e.__globalThemeSignal.set(t),e.__globalThemeSignal;const o=(0,r.isDefined)(t)?t:e.globalTheme,s=(0,h.createSignal)((0,r.isDefined)(o)?o:"auto");return Object.defineProperty(e,"globalTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},j=e=>e?f(e):null,p=(e,t)=>{if(!e)return null;if(e.__resolvedThemeSignal)return(0,r.isDefined)(t)&&e.__resolvedThemeSignal.set(t),e.__resolvedThemeSignal;const o=(0,r.isDefined)(t)?t:e.resolvedTheme,s=(0,h.createSignal)((0,r.isDefined)(o)?o:null);return Object.defineProperty(e,"resolvedTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"__resolvedThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},E=e=>e?p(e):null;f(i),p(i);const S=(0,r.deepClone)(i),l={active:"0",0:i},G=e=>((0,r.isDefined)(e)&&(l.active=e),l[e||l.active]),u=[],L=e=>{e&&e._scratchConfig&&u.push(e)},w=()=>{u.pop()},O=e=>u.length?u[u.length-1]:l[e||l.active]||i,N=e=>{if((0,r.isObject)(e))return l.active="1",l[1]=(0,r.deepMerge)(e,(0,r.deepClone)(S),b),C(l[1]),f(l[1]),p(l[1]),e},k=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],U=["useVariable","globalTheme","verbose"],z=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],C=e=>{for(const t of z){let o;for(const s of t){const n=e[s];(0,r.isObject)(n)&&(o=o?(0,r.deepMerge)(o,n,b):n)}if(o)for(const s of t)(0,r.isObject)(e[s])&&(e[s]=o)}},B=(e,t,{cleanBase:o=!1}={})=>{const s=o?null:O(),n=(0,r.deepClone)(!o&&s&&s._scratchConfig?s:S);for(const c of k)delete n[c];for(const c of U)Object.prototype.hasOwnProperty.call(S,c)?n[c]=S[c]:delete n[c];const a=(0,r.deepMerge)(t||{},n,b);return a.cssVars={},a.cssMediaVars={},a.CSS_VARS=a.cssVars,a.CSS_MEDIA_VARS=a.cssMediaVars,a._scratchConfig=!0,C(a),f(a),p(a),e&&(l[e]=a),a};
1
+ "use strict";var A=Object.create;var m=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},T=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of y(t))!R.call(e,n)&&n!==o&&m(e,n,{get:()=>t[n],enumerable:!(s=V(t,n))||s.enumerable});return e};var I=(e,t,o)=>(o=e!=null?A(F(e)):{},T(t||!e||!e.__esModule?m(o,"default",{value:e,enumerable:!0}):o,e)),k=e=>T(m({},"__esModule",{value:!0}),e);var X={};P(X,{CONFIG:()=>i,CONFIG_MERGE_EXL:()=>b,FACTORY:()=>l,activateConfig:()=>E,aliasCaseVariants:()=>C,createConfig:()=>B,cssMediaVars:()=>d,cssVars:()=>v,defineResolvedThemeSignal:()=>p,defineThemeSignal:()=>f,getActiveConfig:()=>O,getResolvedThemeSignal:()=>j,getThemeSignal:()=>M,popConfig:()=>L,pushConfig:()=>G,setActiveConfig:()=>w,toCamel:()=>x});module.exports=k(X);var r=require("@symbo.ls/utils"),h=require("@symbo.ls/signal"),D=I(require("./defaultConfig/index.js"),1);const v={},d={},b=new Set,g=D,S={},x=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in g){const t=e.toLowerCase();S[t]=g[e];const o=x(t);o!==t&&(S[o]=g[e]),t!==e&&(S[e]=g[e])}const i={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:v,cssMediaVars:d,CSS_VARS:v,CSS_MEDIA_VARS:d,cssSkinVars:{},cssSkinFallback:{},_scratchConfig:!0,...S},f=(e,t)=>{if(!e)return null;if(e.__globalThemeSignal)return(0,r.isDefined)(t)&&e.__globalThemeSignal.set(t),e.__globalThemeSignal;const o=(0,r.isDefined)(t)?t:e.globalTheme,s=(0,h.createSignal)((0,r.isDefined)(o)?o:"auto");return Object.defineProperty(e,"globalTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},M=e=>e?f(e):null,p=(e,t)=>{if(!e)return null;if(e.__resolvedThemeSignal)return(0,r.isDefined)(t)&&e.__resolvedThemeSignal.set(t),e.__resolvedThemeSignal;const o=(0,r.isDefined)(t)?t:e.resolvedTheme,s=(0,h.createSignal)((0,r.isDefined)(o)?o:null);return Object.defineProperty(e,"resolvedTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"__resolvedThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},j=e=>e?p(e):null;f(i),p(i);const _=(0,r.deepClone)(i),l={active:"0",0:i},E=e=>((0,r.isDefined)(e)&&(l.active=e),l[e||l.active]),u=[],G=e=>{e&&e._scratchConfig&&u.push(e)},L=()=>{u.pop()},O=e=>u.length?u[u.length-1]:l[e||l.active]||i,w=e=>{if((0,r.isObject)(e))return l.active="1",l[1]=(0,r.deepMerge)(e,(0,r.deepClone)(_),b),C(l[1]),f(l[1]),p(l[1]),e},N=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],U=["useVariable","globalTheme","verbose"],z=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],C=e=>{for(const t of z){let o;for(const s of t){const n=e[s];(0,r.isObject)(n)&&(o=o?(0,r.deepMerge)(o,n,b):n)}if(o)for(const s of t)(0,r.isObject)(e[s])&&(e[s]=o)}},B=(e,t,{cleanBase:o=!1}={})=>{const s=o?null:O(),n=(0,r.deepClone)(!o&&s&&s._scratchConfig?s:_);for(const c of N)delete n[c];for(const c of U)Object.prototype.hasOwnProperty.call(_,c)?n[c]=_[c]:delete n[c];const a=(0,r.deepMerge)(t||{},n,b);return a.cssVars={},a.cssMediaVars={},a.CSS_VARS=a.cssVars,a.CSS_MEDIA_VARS=a.cssMediaVars,a.cssSkinVars={},a.cssSkinFallback={},a._scratchConfig=!0,C(a),f(a),p(a),e&&(l[e]=a),a};
@@ -1 +1 @@
1
- "use strict";var R=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var B=(t,s)=>{for(var e in s)R(t,e,{get:s[e],enumerable:!0})},K=(t,s,e,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of $(s))!z.call(t,r)&&r!==e&&R(t,r,{get:()=>s[r],enumerable:!(o=Y(s,r))||o.enumerable});return t};var U=t=>K(R({},"__esModule",{value:!0}),t);var N={};B(N,{VALUE_TRANSFORMERS:()=>D,changeGlobalTheme:()=>Q,set:()=>G,setEach:()=>I,setValue:()=>F});module.exports=U(N);var m=require("./factory.js"),n=require("./system/index.js"),_=require("@symbo.ls/utils"),g=require("./utils/host.js");const T="__smblsThemeRootOwner",w=t=>{const s=t&&t.__prefersListener,e=t&&t.__prefersMq;if(s&&e)try{typeof e.removeEventListener=="function"?e.removeEventListener("change",s):typeof e.removeListener=="function"&&e.removeListener(s)}catch{try{e.removeListener(s)}catch{}}t&&(t.__prefersListener=null,t.__prefersMq=null)},W=(t,s,e)=>{if(!(!t||!s)){w(t),t.__prefersListener=e,t.__prefersMq=s;try{s.addEventListener("change",e)}catch{s.addListener(e)}}},X=(t,s)=>{const e=(0,m.getActiveConfig)(),{cssVars:o}=e,r=s.startsWith("--")?s:`--${s}`;return o[r]=t,t},d=t=>t,D={color:n.setColor,gradient:n.setGradient,font:n.setFont,fontFamily:n.setFontFamily,fontfamily:n.setFontFamily,theme:n.setTheme,icons:n.setSvgIcon,semanticIcons:d,semanticicons:d,svg:n.setSVG,svgData:d,typography:d,shadow:n.setShadow,spacing:d,media:d,grid:d,class:d,timing:d,reset:d,unit:d,animation:d,vars:X,sizes:d,shape:d},J=(t,s,e,o)=>{(0,g.parkHostObject)(t,e,s);const r={};for(const i of o)t[i]===s&&(t[i]=r);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),r},F=(t,s,e)=>{const o=(0,m.getActiveConfig)(),r=(0,m.toCamel)(t),i=r.toLowerCase(),u=o[r]||o[i]||o[t],c=(0,g.isHostObject)(u)?J(o,u,i,[r,i,t]):u,h=D[r]||D[i];if(h)try{const l=h(s,e);return c&&(c[e]=l),c}catch(l){o.verbose&&console.warn("Error setting",i,"value",s,e,l)}if(!h){const l=c||(o[i]={});return l[e]=s,l}o.verbose&&console.warn("Can not find",i,"method in scratch")},I=(t,s)=>{const e=(0,m.getActiveConfig)(),o=t.toLowerCase();return(0,g.isHostObject)(s)?((0,g.parkHostObject)(e,o,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",o,"design-system family"),e[o]||e[t]):s==null?(e.verbose&&console.warn("[scratch] skipping empty design-system family",o),e[o]||e[t]):(Object.keys(s).sort((i,u)=>{const c=(0,_.isObject)(s[i])||(0,_.isArray)(s[i])?1:0,h=(0,_.isObject)(s[u])||(0,_.isArray)(s[u])?1:0;return c-h}).forEach(i=>{try{return F(o,s[i],i)}catch(u){e.verbose&&console.warn("Error setting",o,"value",s[i],i,u)}}),e[o]||e[t])},Q=(t,s)=>{const e=s||(0,m.getActiveConfig)();e.globalTheme=t;const r=(0,g.resolveConfigDocument)(e)||(typeof document<"u"?document:null),i=r&&r.defaultView||(typeof window<"u"?window:null);if(r){const c=e.themeRoot||r.documentElement,h=t&&t!=="auto";if(c[T]=e,h)w(e),c.setAttribute("data-theme",t),e.resolvedTheme=t,t==="dark"||t==="light"?c.style.colorScheme=t:c.style.colorScheme="light dark";else if(i&&i.matchMedia){const l=y=>{const S=y.matches?"dark":"light";c.setAttribute("data-theme",S),e.resolvedTheme=S},v=i.matchMedia("(prefers-color-scheme: dark)");l(v),c.style.colorScheme="light dark",W(e,v,l)}else w(e),c.setAttribute("data-theme","light"),e.resolvedTheme="light",c.style.colorScheme="light"}const u=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const c in e.cssVars)c.startsWith(u)&&delete e.cssVars[c];for(const c in e.cssMediaVars)delete e.cssMediaVars[c];if(r&&e.cssVars){const c=e.scopeSelector||":root",h=r.styleSheets;for(let l=0;l<h.length;l++)try{const v=h[l].cssRules;for(let y=0;y<v.length;y++)if(v[y].selectorText===c){for(const S in e.cssVars)v[y].style.setProperty(S,e.cssVars[S]);return e}}catch{}}return e},Z={},G=(t,s=Z)=>{let e=s.config||(0,m.getActiveConfig)();const{version:o,verbose:r,useVariable:i,useReset:u,useSvgSprite:c,useFontImport:h,useIconSprite:l,globalTheme:v,themeRoot:y,useDocumentTheme:S,useDefaultConfig:L,semanticIcons:A,hoverMedia:C,files:M,assets:P,...p}=t;s.newConfig&&(e=(0,m.setActiveConfig)(s.newConfig)),(0,g.isDomDocument)(p.document)&&(e.__domDocument=p.document,delete p.document),(0,g.isDomDocument)(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),M!==void 0&&(e.files=M),P!==void 0&&(e.assets=P),r!==void 0&&(e.verbose=r),i!==void 0&&(e.useVariable=i),u!==void 0&&(e.useReset=u),h!==void 0&&(e.useFontImport=h),c!==void 0&&(e.useSvgSprite=c),l!==void 0&&(e.useIconSprite=l),S!==void 0&&(e.useDocumentTheme=S),v!==void 0&&(e.globalTheme=v),y!==void 0&&(e.themeRoot=y),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),L!==void 0&&(e.useDefaultConfig=L),A!==void 0&&(e.semanticIcons=A),C!==void 0&&(e.hoverMedia=C),e.verbose&&console.log(e);const E=(0,g.resolveConfigDocument)(e)||(typeof document<"u"?document:null),V=E&&E.defaultView||(typeof window<"u"?window:null),f=E&&(e.themeRoot||E.documentElement);if(f&&typeof f.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")w(e),f.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,f[T]=e,e.globalTheme==="dark"||e.globalTheme==="light"?f.style.colorScheme=e.globalTheme:f.style.colorScheme="light dark";else if(f[T]&&f[T]!==e&&f.hasAttribute("data-theme"))w(e),e.resolvedTheme=f.getAttribute("data-theme");else if(V&&V.matchMedia){const b=H=>{const O=H.matches?"dark":"light";f.setAttribute("data-theme",O),e.resolvedTheme=O},j=V.matchMedia("(prefers-color-scheme: dark)");b(j),f.style.colorScheme="light dark",f[T]=e,W(e,j,b)}else w(e),f.setAttribute("data-theme","light"),e.resolvedTheme="light",f.style.colorScheme="light",f[T]=e;e.__svgCache||(e.__svgCache={}),(0,m.aliasCaseVariants)(p);const x=Object.keys(p).filter(a=>!a.startsWith("__")),k=new Set(x);if(x.forEach(a=>{const b=a.toLowerCase();b!==a&&k.has(b)&&(0,_.deepMerge)(p[b],p[a],m.CONFIG_MERGE_EXL)}),x.map(a=>{const b=a.toLowerCase();if(!(b!==a&&k.has(b)))return I(a,p[a])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),p.typography)try{(0,n.applyTypographySequence)()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(p.spacing)try{(0,n.applySpacingSequence)()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(p.timing)try{(0,n.applyTimingSequence)()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}(0,n.applyDocument)();const q=(0,n.applyReset)();return q&&(e.reset=q),e};
1
+ "use strict";var R=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var B=(t,s)=>{for(var e in s)R(t,e,{get:s[e],enumerable:!0})},K=(t,s,e,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of $(s))!z.call(t,n)&&n!==e&&R(t,n,{get:()=>s[n],enumerable:!(r=Y(s,n))||r.enumerable});return t};var U=t=>K(R({},"__esModule",{value:!0}),t);var N={};B(N,{VALUE_TRANSFORMERS:()=>D,changeGlobalTheme:()=>Q,set:()=>G,setEach:()=>I,setValue:()=>F});module.exports=U(N);var m=require("./factory.js"),o=require("./system/index.js"),_=require("@symbo.ls/utils"),g=require("./utils/host.js");const T="__smblsThemeRootOwner",w=t=>{const s=t&&t.__prefersListener,e=t&&t.__prefersMq;if(s&&e)try{typeof e.removeEventListener=="function"?e.removeEventListener("change",s):typeof e.removeListener=="function"&&e.removeListener(s)}catch{try{e.removeListener(s)}catch{}}t&&(t.__prefersListener=null,t.__prefersMq=null)},W=(t,s,e)=>{if(!(!t||!s)){w(t),t.__prefersListener=e,t.__prefersMq=s;try{s.addEventListener("change",e)}catch{s.addListener(e)}}},X=(t,s)=>{const e=(0,m.getActiveConfig)(),{cssVars:r}=e,n=s.startsWith("--")?s:`--${s}`;return r[n]=t,t},d=t=>t,D={color:o.setColor,gradient:o.setGradient,font:o.setFont,fontFamily:o.setFontFamily,fontfamily:o.setFontFamily,theme:o.setTheme,icons:o.setSvgIcon,semanticIcons:d,semanticicons:d,svg:o.setSVG,svgData:d,typography:d,shadow:o.setShadow,spacing:d,media:d,grid:d,class:d,timing:d,reset:d,unit:d,animation:d,vars:X,sizes:d,shape:d,skins:d},J=(t,s,e,r)=>{(0,g.parkHostObject)(t,e,s);const n={};for(const i of r)t[i]===s&&(t[i]=n);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),n},F=(t,s,e)=>{const r=(0,m.getActiveConfig)(),n=(0,m.toCamel)(t),i=n.toLowerCase(),u=r[n]||r[i]||r[t],c=(0,g.isHostObject)(u)?J(r,u,i,[n,i,t]):u,h=D[n]||D[i];if(h)try{const l=h(s,e);return c&&(c[e]=l),c}catch(l){r.verbose&&console.warn("Error setting",i,"value",s,e,l)}if(!h){const l=c||(r[i]={});return l[e]=s,l}r.verbose&&console.warn("Can not find",i,"method in scratch")},I=(t,s)=>{const e=(0,m.getActiveConfig)(),r=t.toLowerCase();return(0,g.isHostObject)(s)?((0,g.parkHostObject)(e,r,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",r,"design-system family"),e[r]||e[t]):s==null?(e.verbose&&console.warn("[scratch] skipping empty design-system family",r),e[r]||e[t]):(Object.keys(s).sort((i,u)=>{const c=(0,_.isObject)(s[i])||(0,_.isArray)(s[i])?1:0,h=(0,_.isObject)(s[u])||(0,_.isArray)(s[u])?1:0;return c-h}).forEach(i=>{try{return F(r,s[i],i)}catch(u){e.verbose&&console.warn("Error setting",r,"value",s[i],i,u)}}),e[r]||e[t])},Q=(t,s)=>{const e=s||(0,m.getActiveConfig)();e.globalTheme=t;const n=(0,g.resolveConfigDocument)(e)||(typeof document<"u"?document:null),i=n&&n.defaultView||(typeof window<"u"?window:null);if(n){const c=e.themeRoot||n.documentElement,h=t&&t!=="auto";if(c[T]=e,h)w(e),c.setAttribute("data-theme",t),e.resolvedTheme=t,t==="dark"||t==="light"?c.style.colorScheme=t:c.style.colorScheme="light dark";else if(i&&i.matchMedia){const l=y=>{const S=y.matches?"dark":"light";c.setAttribute("data-theme",S),e.resolvedTheme=S},v=i.matchMedia("(prefers-color-scheme: dark)");l(v),c.style.colorScheme="light dark",W(e,v,l)}else w(e),c.setAttribute("data-theme","light"),e.resolvedTheme="light",c.style.colorScheme="light"}const u=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const c in e.cssVars)c.startsWith(u)&&delete e.cssVars[c];for(const c in e.cssMediaVars)delete e.cssMediaVars[c];if(n&&e.cssVars){const c=e.scopeSelector||":root",h=n.styleSheets;for(let l=0;l<h.length;l++)try{const v=h[l].cssRules;for(let y=0;y<v.length;y++)if(v[y].selectorText===c){for(const S in e.cssVars)v[y].style.setProperty(S,e.cssVars[S]);return e}}catch{}}return e},Z={},G=(t,s=Z)=>{let e=s.config||(0,m.getActiveConfig)();const{version:r,verbose:n,useVariable:i,useReset:u,useSvgSprite:c,useFontImport:h,useIconSprite:l,globalTheme:v,themeRoot:y,useDocumentTheme:S,useDefaultConfig:L,semanticIcons:A,hoverMedia:k,files:C,assets:M,...p}=t;s.newConfig&&(e=(0,m.setActiveConfig)(s.newConfig)),(0,g.isDomDocument)(p.document)&&(e.__domDocument=p.document,delete p.document),(0,g.isDomDocument)(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),C!==void 0&&(e.files=C),M!==void 0&&(e.assets=M),n!==void 0&&(e.verbose=n),i!==void 0&&(e.useVariable=i),u!==void 0&&(e.useReset=u),h!==void 0&&(e.useFontImport=h),c!==void 0&&(e.useSvgSprite=c),l!==void 0&&(e.useIconSprite=l),S!==void 0&&(e.useDocumentTheme=S),v!==void 0&&(e.globalTheme=v),y!==void 0&&(e.themeRoot=y),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),L!==void 0&&(e.useDefaultConfig=L),A!==void 0&&(e.semanticIcons=A),k!==void 0&&(e.hoverMedia=k),e.verbose&&console.log(e);const E=(0,g.resolveConfigDocument)(e)||(typeof document<"u"?document:null),V=E&&E.defaultView||(typeof window<"u"?window:null),f=E&&(e.themeRoot||E.documentElement);if(f&&typeof f.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")w(e),f.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,f[T]=e,e.globalTheme==="dark"||e.globalTheme==="light"?f.style.colorScheme=e.globalTheme:f.style.colorScheme="light dark";else if(f[T]&&f[T]!==e&&f.hasAttribute("data-theme"))w(e),e.resolvedTheme=f.getAttribute("data-theme");else if(V&&V.matchMedia){const b=H=>{const O=H.matches?"dark":"light";f.setAttribute("data-theme",O),e.resolvedTheme=O},j=V.matchMedia("(prefers-color-scheme: dark)");b(j),f.style.colorScheme="light dark",f[T]=e,W(e,j,b)}else w(e),f.setAttribute("data-theme","light"),e.resolvedTheme="light",f.style.colorScheme="light",f[T]=e;e.__svgCache||(e.__svgCache={}),(0,m.aliasCaseVariants)(p);const x=Object.keys(p).filter(a=>!a.startsWith("__")),P=new Set(x);if(x.forEach(a=>{const b=a.toLowerCase();b!==a&&P.has(b)&&(0,_.deepMerge)(p[b],p[a],m.CONFIG_MERGE_EXL)}),x.map(a=>{const b=a.toLowerCase();if(!(b!==a&&P.has(b)))return I(a,p[a])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),p.typography)try{(0,o.applyTypographySequence)()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(p.spacing)try{(0,o.applySpacingSequence)()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(p.timing)try{(0,o.applyTimingSequence)()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}try{(0,o.applySkins)()}catch(a){e.verbose&&console.warn("Error applying skins",a)}(0,o.applyDocument)();const q=(0,o.applyReset)();return q&&(e.reset=q),e};
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t,m,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of i(t))!u.call(e,f)&&f!==m&&s(e,f,{get:()=>t[f],enumerable:!(x=c(t,f))||x.enumerable});return e},o=(e,t,m)=>(p(e,t,"default"),m&&p(m,t,"default"));var a=e=>p(s({},"__esModule",{value:!0}),e);var r={};module.exports=a(r);o(r,require("./color.js"),module.exports);o(r,require("./ink.js"),module.exports);o(r,require("./theme.js"),module.exports);o(r,require("./font.js"),module.exports);o(r,require("./typography.js"),module.exports);o(r,require("./spacing.js"),module.exports);o(r,require("./shape.js"),module.exports);o(r,require("./shadow.js"),module.exports);o(r,require("./border.js"),module.exports);o(r,require("./timing.js"),module.exports);o(r,require("./document.js"),module.exports);o(r,require("./svg.js"),module.exports);o(r,require("./reset.js"),module.exports);
1
+ "use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t,m,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of i(t))!u.call(e,f)&&f!==m&&s(e,f,{get:()=>t[f],enumerable:!(x=c(t,f))||x.enumerable});return e},o=(e,t,m)=>(p(e,t,"default"),m&&p(m,t,"default"));var a=e=>p(s({},"__esModule",{value:!0}),e);var r={};module.exports=a(r);o(r,require("./color.js"),module.exports);o(r,require("./ink.js"),module.exports);o(r,require("./theme.js"),module.exports);o(r,require("./font.js"),module.exports);o(r,require("./typography.js"),module.exports);o(r,require("./spacing.js"),module.exports);o(r,require("./shape.js"),module.exports);o(r,require("./shadow.js"),module.exports);o(r,require("./border.js"),module.exports);o(r,require("./timing.js"),module.exports);o(r,require("./document.js"),module.exports);o(r,require("./svg.js"),module.exports);o(r,require("./reset.js"),module.exports);o(r,require("./skin.js"),module.exports);
@@ -0,0 +1 @@
1
+ "use strict";var h=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var g=(n,e)=>{for(var t in e)h(n,t,{get:e[t],enumerable:!0})},x=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!V.call(n,r)&&r!==t&&h(n,r,{get:()=>e[r],enumerable:!(o=O(e,r))||o.enumerable});return n};var R=n=>x(h({},"__esModule",{value:!0}),n);var j={};g(j,{__resetSkinWarnings:()=>F,applySkins:()=>P,buildSkinVarStyles:()=>_});module.exports=R(j);var c=require("@symbo.ls/utils"),w=require("../factory.js");const C=new Set(["fallback"]),S=new Set,u=(n,e)=>{S.has(n)||(S.add(n),(0,c.isLoudDevRuntime)()&&console.warn(e))},F=()=>{S.clear()},p=n=>{for(const e in n)delete n[e];return n},P=()=>{const n=(0,w.getActiveConfig)(),e=(0,c.isObject)(n.cssSkinVars)?p(n.cssSkinVars):n.cssSkinVars={},t=(0,c.isObject)(n.cssSkinFallback)?p(n.cssSkinFallback):n.cssSkinFallback={},o=n.skins;if(!(0,c.isObject)(o))return e;const r=n.varPrefix?n.varPrefix+"-":"",i=n.color||{},k=n.cssVars||{},y=s=>(0,c.isString)(s)&&Object.prototype.hasOwnProperty.call(i,s)?`var(--${r}color-${s})`:s;for(const s in o){const a=o[s];if(!(0,c.isObject)(a))continue;const m={};for(const l in a){if(C.has(l))continue;const $=a[l];if((0,c.isObject)($))for(const f in $){const d=`--${r}theme-${l}-${f}`;n.useVariable!==!1&&!(d in k)&&u(`${s}/${l}/${f}`,`[scratch] skin "${s}" rewrites theme "${l}" param "${f}", which the theme does not declare \u2014 no element reads ${d}, so the skin changes nothing there. Declare "${f}" on the "${l}" theme (its no-skin value).`),m[d]=y($[f])}}e[s]=m,(0,c.isString)(a.fallback)&&(t[s]=a.fallback)}for(const s in t){const a=t[s];e[a]||(u(`${s}/fallback/${a}`,`[scratch] skin "${s}" falls back to "${a}", which is not a declared skin \u2014 the reduced-transparency fallback is skipped.`),delete t[s])}return e},b=(n,e)=>{const t=`[data-skin="${n}"]`;return!e||e===":root"?`:root${t}, ${t}`:`${e}${t}, ${t} ${e}, ${e} ${t}`},_=(n,e,t)=>{const o={};if(!(0,c.isObject)(n))return o;for(const i in n)o[b(i,t)]=n[i];const r={};for(const i in e||{}){const k=n[e[i]];k&&(r[b(i,t)]=k)}return Object.keys(r).length&&(o["@media (prefers-reduced-transparency: reduce)"]=r),o};
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},C=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of q(e))!G.call(t,i)&&i!==n&&p(t,i,{get:()=>e[i],enumerable:!(s=I(e,i))||s.enumerable});return t};var f=t=>C(p({},"__esModule",{value:!0}),t);var M={};B(M,{applySpacingSequence:()=>A,checkIfBoxSize:()=>y,getSpacingBasedOnRatio:()=>N,getSpacingByKey:()=>h,splitSpacedValue:()=>F});module.exports=f(M);var m=require("@symbo.ls/utils"),u=require("@symbo.ls/utils"),g=require("../factory.js"),o=require("../utils/index.js");const b=t=>{const n=(0,g.getActiveConfig)().spacing||{},s=parseFloat(t.spacingRatio),i={...n,ratio:Number.isFinite(s)?s:n.ratio,sequence:{},scales:{}};return(0,o.generateSequence)(i),i},k=t=>{for(const e in t){const n=t[e];if(!(e.slice(0,1)==="@"))continue;const{type:i,base:r,ratio:c,range:a,subSequence:S,h1Matches:l,unit:d}=t;(0,u.merge)(n,{type:i,base:r,ratio:c,range:a,subSequence:S,h1Matches:l,unit:d,sequence:{},scales:{},templates:{},vars:{}}),(0,o.generateSequence)(n),(0,o.applyMediaSequenceVars)(t,e)}},y=t=>{const e=t.toLowerCase(),n=e.includes("width")||e.includes("height"),s=e.includes("border")||e.includes("outline");return n&&!s},A=()=>{const t=(0,g.getActiveConfig)(),{spacing:e}=t;(0,o.generateSequence)(e),(0,o.applySequenceVars)(e),k(e)},V=t=>{const e=(0,g.getActiveConfig)(),{spacing:n}=e;return!t||!t.sequence?n:Object.keys(t.sequence).length>0?t:(0,o.generateSequence)(t)},h=(t,e="padding",n,s)=>{const i=V(n);if((0,u.isString)(t)){if(!s&&/^(?:env|var)\(/.test(t.trim()))return{[e]:t};if(!s&&t.includes("(")){const c=(0,o.getFnPrefixAndValue)(t);s=c[0],t=c[1]}}const r=s?[t]:(0,m.arrayzeValue)(t);if((0,u.isArray)(r)){if(r.length>1){let c="";e==="borderWidth"&&(e="border",c="Width");const a={2:["Block","Inline"],3:["BlockStart","Inline","BlockEnd"],4:["BlockStart","InlineEnd","BlockEnd","InlineStart"]},S=(l,d)=>(0,o.getSequenceValuePropertyPair)(r[d],e+l+c,i,s);return a[r.length].map((l,d)=>S(l,d))}return(0,o.getSequenceValuePropertyPair)(t,e,i,s)}},N=(t,e,n,s)=>{const i=(0,g.getActiveConfig)(),{spacing:r}=i;let c=n||t[e];if(!s&&(0,u.isString)(c)&&/^(?:env|var)\(/.test(c.trim()))return{[e]:c};if(!s&&(0,u.isString)(c)&&c.includes("(")){const a=(0,o.getFnPrefixAndValue)(c);s=a[0],c=a[1]}if(t.spacingRatio){const a=b(t);return h(c,e,a,s)}return h(c,e,r,s)},F=t=>{const e=n=>{const s=["+","-","*","/"].includes(n),i=o.CSS_UNITS.some(c=>t.includes(c));return s||i?n:n.length<3&&/[A-Z]/.test(n)?n+"_default":n};return t.split(",").map(n=>n.trim()).map(e).join(",").split(" ").map(e).join(" ")};
1
+ "use strict";var p=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},C=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of q(e))!G.call(t,o)&&o!==n&&p(t,o,{get:()=>e[o],enumerable:!(s=I(e,o))||s.enumerable});return t};var f=t=>C(p({},"__esModule",{value:!0}),t);var M={};B(M,{applySpacingSequence:()=>A,checkIfBoxSize:()=>y,getSpacingBasedOnRatio:()=>N,getSpacingByKey:()=>h,splitSpacedValue:()=>F});module.exports=f(M);var m=require("@symbo.ls/utils"),a=require("@symbo.ls/utils"),g=require("../factory.js"),i=require("../utils/index.js");const b=t=>{const n=(0,g.getActiveConfig)().spacing||{},s=parseFloat(t.spacingRatio),o={...n,ratio:Number.isFinite(s)?s:n.ratio,sequence:{},scales:{}};return(0,i.generateSequence)(o),o},k=t=>{for(const e in t){const n=t[e];if(!(e.slice(0,1)==="@"))continue;const{type:o,base:r,ratio:c,range:u,subSequence:S,h1Matches:l,unit:d}=t;(0,a.merge)(n,{type:o,base:r,ratio:c,range:u,subSequence:S,h1Matches:l,unit:d,sequence:{},scales:{},templates:{},vars:{}}),(0,i.generateSequence)(n),(0,i.applyMediaSequenceVars)(t,e)}},y=t=>{const e=t.toLowerCase(),n=e.includes("width")||e.includes("height"),s=e.includes("border")||e.includes("outline");return n&&!s},A=()=>{const t=(0,g.getActiveConfig)(),{spacing:e}=t;(0,i.generateSequence)(e),(0,i.applySequenceVars)(e),k(e)},V=t=>{const e=(0,g.getActiveConfig)(),{spacing:n}=e;return!t||!t.sequence?n:Object.keys(t.sequence).length>0?t:(0,i.generateSequence)(t)},h=(t,e="padding",n,s)=>{const o=V(n);if((0,a.isString)(t)){if(!s&&/^(?:env|var)\(/.test(t.trim()))return{[e]:t};if(!s&&t.includes("(")){const c=(0,i.getFnPrefixAndValue)(t);s=c[0],t=c[1]}}const r=s?[t]:(0,a.isString)(t)&&t.includes("(")?(0,i.splitTopLevelSpaces)(t):(0,m.arrayzeValue)(t);if((0,a.isArray)(r)){if(r.length>1){let c="";e==="borderWidth"&&(e="border",c="Width");const u={2:["Block","Inline"],3:["BlockStart","Inline","BlockEnd"],4:["BlockStart","InlineEnd","BlockEnd","InlineStart"]},S=(l,d)=>(0,i.getSequenceValuePropertyPair)(r[d],e+l+c,o,s);return u[r.length].map((l,d)=>S(l,d))}return(0,i.getSequenceValuePropertyPair)(t,e,o,s)}},N=(t,e,n,s)=>{const o=(0,g.getActiveConfig)(),{spacing:r}=o;let c=n||t[e];if(!s&&(0,a.isString)(c)&&/^(?:env|var)\(/.test(c.trim()))return{[e]:c};if(!s&&(0,a.isString)(c)&&c.includes("(")){const u=(0,i.getFnPrefixAndValue)(c);s=u[0],c=u[1]}if(t.spacingRatio){const u=b(t);return h(c,e,u,s)}return h(c,e,r,s)},F=t=>{const e=n=>{const s=["+","-","*","/"].includes(n),o=i.CSS_UNITS.some(c=>t.includes(c));return s||o?n:n.length<3&&/[A-Z]/.test(n)?n+"_default":n};return t.split(",").map(n=>n.trim()).map(e).join(",").split(" ").map(e).join(" ")};
@@ -1 +1 @@
1
- "use strict";var A=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var Z=(e,o)=>{for(var r in o)A(e,r,{get:o[r],enumerable:!0})},J=(e,o,r,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of U(o))!Q.call(e,i)&&i!==r&&A(e,i,{get:()=>o[i],enumerable:!(t=H(o,i))||t.enumerable});return e};var X=e=>J(A({},"__esModule",{value:!0}),e);var ie={};Z(ie,{getMediaTheme:()=>R,getTheme:()=>G,setMediaTheme:()=>v,setTheme:()=>oe});module.exports=X(ie);var $=require("./color.js"),O=require("./shadow.js"),w=require("./border.js"),j=require("../factory.js"),V=require("../utils/color.js"),l=require("@symbo.ls/utils");const Y=new Set(["black","white","red","green","blue","yellow","orange","purple","pink","brown","gray","grey","cyan","magenta","lime","olive","navy","teal","aqua","maroon","silver","fuchsia","transparent","currentColor","currentcolor","inherit","initial","unset","none","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","rebeccapurple"]),_=["color","Color","background","Background","fill","Fill","stroke","Stroke"],E=e=>{for(let o=0;o<_.length;o++)if(e.includes(_[o]))return!0;return!1},K={boxShadow:O.resolveShadowValue,textShadow:O.resolveShadowValue,border:w.resolveBorderValue,borderTop:w.resolveBorderValue,borderRight:w.resolveBorderValue,borderBottom:w.resolveBorderValue,borderLeft:w.resolveBorderValue,outline:w.resolveBorderValue,columnRule:w.resolveBorderValue},N=e=>{if(!e)return!1;const o=(0,V.parseColorToken)(e);return!o||!o.name||o.passthrough||o.cssVar?!1:o.alpha!==void 0||o.tone!==void 0},P=new Set,F=(e,o,r,t,i,a)=>{if(!(0,l.isLoudDevRuntime)())return;const s=`${e}::${o}::${r||""}::${t}`;P.has(s)||(P.add(s),console.warn(`[smbls/scratch] theme param "${o}" on "${e}"`+(r?` (${r})`:"")+` did not fully resolve: "${t}" -> "${i}" still contains the unresolved token "${a}". This is not valid CSS \u2014 the browser will drop the whole declaration. Register "${a}" as a design-system color token or fix the typo.`))},C=(e,o,r,t)=>{const i=K[o];if(!i)return(0,$.getColor)(r,t);let a=null;const s=i(r,t,h=>{!a&&N(h)&&(a=h)});return a&&F(e,o,t,r,s,a),s},G=(e,o)=>R(e,o),I=e=>(0,l.isObject)(e)&&(0,l.isObjectLike)(e.value),ee=e=>{for(const o in e){const r=e[o];if((0,l.isString)(r)&&r.startsWith("var(--"))return!0}return!1},oe=(e,o)=>{const r=(0,j.getActiveConfig)();return I(e)?!r.useVariable&&ee(e)?e:v(e.value,o):v(e,o)},L=(e,o)=>{const r=new Set;for(const t of o){const i=t.slice(0,1);if(!(i==="@"||i==="."||i===":")&&E(t))for(const a in e){if(r.has(a))continue;const s=e[a]?.[t];if(s===void 0)continue;const h=(0,$.getColor)(s,`@${a}`);h!==void 0&&(0,l.isString)(h)&&/^[a-z][a-zA-Z]+$/.test(h)&&!Y.has(h)&&r.add(a)}}return r},ne=e=>e.startsWith("[data-theme=")||e.startsWith("@media"),M=(e,o)=>{for(const r in o){const t=o[r];(0,l.isObject)(t)?M(e[r]||(e[r]={}),t):e[r]=t}return e},B=(e,o,r,t)=>{if(M(e,{[`[data-theme="${o}"] &`]:r}),o!=="light"&&o!=="dark")return;const i=(0,$.schemeMediaQuery)(o,t);i&&M(e,{[i]:{[(0,$.schemeGuardSelector)(t)]:r}})},D=(e,o,r,t)=>{const i=r.globalTheme!==void 0?r.globalTheme:"auto",a=i&&i!=="auto"?String(i).replace(/^'|'$/g,""):null,s=new Set(t?Object.keys(t):[]);for(const n in e)if(e[n])for(const c of Object.keys(e[n]))s.add(c);const h=L(e,s),g={};for(const n of s){const c=n.slice(0,1);if(c==="@")continue;if(c==="."||c===":"){const u={};for(const T in e)(0,l.isObjectLike)(e[T]?.[n])&&(u[T]=e[T][n]);const m=t&&(0,l.isObjectLike)(t[n])?t[n]:void 0;if(!Object.keys(u).length&&!m)continue;const b=c==="."?n.slice(1):n.replace(/^:+/,"");g[n]=D(u,`${o}-${b}`,r,m);continue}const k=t&&!(0,l.isObjectLike)(t[n])?t[n]:void 0,p=new Set(Object.keys(e));k!==void 0&&(p.add("light"),p.add("dark"),a&&p.add(a));const d={};let f;for(const u of p){if(h.has(u))continue;let m=e[u]?.[n];if((m===void 0||(0,l.isObjectLike)(m))&&(m=k),m===void 0)continue;const b=C(o,n,m,`@${u}`);b!==void 0&&(d[u]=b,(a&&u===a||!a&&(u==="light"||f===void 0))&&(f=b))}const y={},S=Object.keys(d).filter(u=>d[u]!==f);if(S.length){const u=d.light!==void 0?d.light:f,m=d.dark!==void 0?d.dark:f;if(E(n)&&(0,$.isPlainColor)(u)&&(0,$.isPlainColor)(m)){y[n]=u===m?u:`light-dark(${u}, ${m})`;for(const b in d)b==="light"||b==="dark"||B(y,b,{[n]:d[b]},r)}else{f!==void 0&&(y[n]=f);for(const b of S)B(y,b,{[n]:d[b]},r)}}else{if(f===void 0)continue;y[n]=f}M(g,y),g[`.${n}`]=y}return(g.background||g.color||g.backgroundColor)&&(g[".inversed"]={color:g.background||g.backgroundColor,background:g.color}),g},q=(e,o,r)=>{const{cssVars:t}=r;r.cssMediaVars||(r.cssMediaVars={});const i=r.cssMediaVars,a=r.globalTheme!==void 0?r.globalTheme:"auto",s={},h=new Set;for(const n in e)if(e[n])for(const c of Object.keys(e[n]))h.add(c);const g=L(e,h);for(const n of h){const c=n.slice(0,1),k=Object.values(e).some(p=>(0,l.isObjectLike)(p?.[n]));if(c==="."&&k){const p=n.slice(1),d={};for(const f in e)(0,l.isObjectLike)(e[f]?.[n])&&(d[f]=e[f][n]);s[n]=q(d,`${o}-${p}`,r)}else if(c===":"&&k){const p=n.replace(/^:+/,""),d={};for(const f in e)(0,l.isObjectLike)(e[f]?.[n])&&(d[f]=e[f][n]);s[n]=q(d,`${o}-${p}`,r)}else if(c!=="@"&&c!=="."&&c!==":"){const d=`--${r.varPrefix?r.varPrefix+"-":""}theme-${o}-${n}`,f=a&&a!=="auto"?String(a).replace(/^'|'$/g,""):null;let y;for(const S in e){if(g.has(S))continue;const u=e[S]?.[n];if(u===void 0)continue;const m=C(o,n,u,`@${S}`);if(m===void 0)continue;(f&&S===f||!f&&(S==="light"||y===void 0))&&(y=m);const b=`[data-theme="${S}"]`;if(i[b]||(i[b]={}),i[b][d]=m,S==="dark"||S==="light"){const T=`@media (prefers-color-scheme: ${S})`;i[T]||(i[T]={}),i[T][d]=m}}y!==void 0&&(t[d]=y),s[n]=`var(${d})`,s[`.${n}`]={[n]:s[n]}}}return(s.background||s.color||s.backgroundColor)&&(s[".inversed"]={color:s.background||s.backgroundColor,background:s.color}),s},v=(e,o,r,t)=>{const i=(0,j.getActiveConfig)(),{cssVars:a}=i,s={value:e},h=!r&&!t;let g;if((0,l.isObjectLike)(e)){if(h&&i.useVariable){const n={};for(const c in e)c.startsWith("@")&&(0,l.isObjectLike)(e[c])&&(n[c.slice(1)]=e[c]);if(Object.keys(n).length){const c=q(n,o,i);Object.assign(s,c)}}else if(h){const n={},c={};for(const k in e)k.startsWith("@")?(0,l.isObjectLike)(e[k])&&(n[k.slice(1)]=e[k]):c[k]=e[k];g=D(n,o,i,c),Object.assign(s,g)}for(const n in e){const c=n.slice(0,1),k=e[n];if(c==="@"||c===":"||c==="."){const p=c==="@"&&n;s[n]=v(k,o,n,t||p)}else if(!h){const p=C(o,n,k,t),d=[...new Set([t,r].filter(u=>u).map(u=>u.slice(1)))],f=d.length?"-"+d.join("-"):"",S=`--${i.varPrefix?i.varPrefix+"-":""}theme-${o}${f}-${n}`;i.useVariable?(i.useThemeSuffixedVars&&(a[S]=p),s[n]=`var(${S})`):s[n]=p,s[`.${n}`]={[n]:s[n]}}}if(g)for(const n in g){const c=n.slice(0,1);(c==="."||c===":")&&(0,l.isObjectLike)(e[n])&&(s[n]=g[n])}!s[".inversed"]&&(s.background||s.color||s.backgroundColor)&&(s[".inversed"]={color:s.background||s.backgroundColor,background:s.color})}if((0,l.isString)(e)&&(0,V.isCSSVar)(e)){const c=i.theme[e.slice(2)];return R(c,t)}return s},x=(e,o)=>{const r={};for(const t in e){const i=t.slice(0,1);if((0,l.isObjectLike)(e[t]))if(o&&ne(t))r[t]=M({},e[t]);else{if(i==="@")continue;i===":"?r[`&${t}`]=x(e[t],o):i==="."&&(r[`&${t}`]=x(e[t],o))}else r[t]=e[t]}return r},W=(e,o)=>{const r=o.shift();return e[r]?W(e[r],o):e},z=(e,o)=>(0,l.isArray)(o)?W(e,o):(0,l.isString)(o)&&e[o]?e[o]:e,re=(e,o)=>(0,l.isString)(e)&&(0,V.isCSSVar)(e)?R(e.slice(2)):e,te=e=>re(e,te),R=(e,o)=>{const r=(0,j.getActiveConfig)();if((0,l.isString)(e)&&(0,V.isCSSVar)(e)&&(e=R(e.slice(2))),!e||!(0,l.isString)(e)){r.verbose&&console.warn(`${e} - Theme is not a string`);return}const[t,...i]=(0,l.isArray)(e)?e:e.split(" ");let a=r.theme[t];return a&&i.length?a=z(a,i):a&&o&&(a=z(a,o)),x(a,!r.useVariable)};
1
+ "use strict";var x=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var K=(e,n)=>{for(var o in n)x(e,o,{get:n[o],enumerable:!0})},N=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of X(n))!Y.call(e,i)&&i!==o&&x(e,i,{get:()=>n[i],enumerable:!(r=J(n,i))||r.enumerable});return e};var F=e=>N(x({},"__esModule",{value:!0}),e);var le={};K(le,{getMediaTheme:()=>M,getTheme:()=>oe,setMediaTheme:()=>A,setTheme:()=>ie});module.exports=F(le);var $=require("./color.js"),B=require("./shadow.js"),T=require("./border.js"),O=require("../factory.js"),V=require("../utils/color.js"),a=require("@symbo.ls/utils");const G=new Set(["black","white","red","green","blue","yellow","orange","purple","pink","brown","gray","grey","cyan","magenta","lime","olive","navy","teal","aqua","maroon","silver","fuchsia","transparent","currentColor","currentcolor","inherit","initial","unset","none","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","rebeccapurple"]),L=["color","Color","background","Background","fill","Fill","stroke","Stroke"],D=e=>{for(let n=0;n<L.length;n++)if(e.includes(L[n]))return!0;return!1},I={boxShadow:B.resolveShadowValue,textShadow:B.resolveShadowValue,border:T.resolveBorderValue,borderTop:T.resolveBorderValue,borderRight:T.resolveBorderValue,borderBottom:T.resolveBorderValue,borderLeft:T.resolveBorderValue,outline:T.resolveBorderValue,columnRule:T.resolveBorderValue},ee=e=>{if(!e)return!1;const n=(0,V.parseColorToken)(e);return!n||!n.name||n.passthrough||n.cssVar?!1:n.alpha!==void 0||n.tone!==void 0},W=new Set,ne=(e,n,o,r,i,l)=>{if(!(0,a.isLoudDevRuntime)())return;const c=`${e}::${n}::${o||""}::${r}`;W.has(c)||(W.add(c),console.warn(`[smbls/scratch] theme param "${n}" on "${e}"`+(o?` (${o})`:"")+` did not fully resolve: "${r}" -> "${i}" still contains the unresolved token "${l}". This is not valid CSS \u2014 the browser will drop the whole declaration. Register "${l}" as a design-system color token or fix the typo.`))},_=(e,n,o,r)=>{const i=I[n];if(!i)return(0,$.getColor)(o,r);let l=null;const c=i(o,r,b=>{!l&&ee(b)&&(l=b)});return l&&ne(e,n,r,o,c,l),c},oe=(e,n)=>M(e,n),re=e=>(0,a.isObject)(e)&&(0,a.isObjectLike)(e.value),te=e=>{for(const n in e){const o=e[n];if((0,a.isString)(o)&&o.startsWith("var(--"))return!0}return!1},ie=(e,n)=>{const o=(0,O.getActiveConfig)();return re(e)?!o.useVariable&&te(e)?e:A(e.value,n):A(e,n)},z=(e,n)=>{const o=new Set;for(const r of n){const i=r.slice(0,1);if(!(i==="@"||i==="."||i===":")&&D(r))for(const l in e){if(o.has(l))continue;const c=e[l]?.[r];if(c===void 0)continue;const b=(0,$.getColor)(c,`@${l}`);b!==void 0&&(0,a.isString)(b)&&/^[a-z][a-zA-Z]+$/.test(b)&&!G.has(b)&&o.add(l)}}return o},se=e=>e.startsWith("[data-theme=")||e.startsWith("@media"),R=(e,n)=>{for(const o in n){const r=n[o];(0,a.isObject)(r)?R(e[o]||(e[o]={}),r):e[o]=r}return e},H=(e,n,o,r)=>{if(R(e,{[`[data-theme="${n}"] &`]:o}),n!=="light"&&n!=="dark")return;const i=(0,$.schemeMediaQuery)(n,r);i&&R(e,{[i]:{[(0,$.schemeGuardSelector)(r)]:o}})},U=(e,n,o,r)=>{const i=o.globalTheme!==void 0?o.globalTheme:"auto",l=i&&i!=="auto"?String(i).replace(/^'|'$/g,""):null,c=new Set(r?Object.keys(r):[]);for(const u in e)if(e[u])for(const s of Object.keys(e[u]))c.add(s);const b=z(e,c),f={};for(const u of c){const s=u.slice(0,1);if(s==="@")continue;if(s==="."||s===":"){const d={};for(const S in e)(0,a.isObjectLike)(e[S]?.[u])&&(d[S]=e[S][u]);const h=r&&(0,a.isObjectLike)(r[u])?r[u]:void 0;if(!Object.keys(d).length&&!h)continue;const y=s==="."?u.slice(1):u.replace(/^:+/,"");f[u]=U(d,`${n}-${y}`,o,h);continue}const t=r&&!(0,a.isObjectLike)(r[u])?r[u]:void 0,g=new Set(Object.keys(e));t!==void 0&&(g.add("light"),g.add("dark"),l&&g.add(l));const p={};let k;for(const d of g){if(b.has(d))continue;let h=e[d]?.[u];if((h===void 0||(0,a.isObjectLike)(h))&&(h=t),h===void 0)continue;const y=_(n,u,h,`@${d}`);y!==void 0&&(p[d]=y,(l&&d===l||!l&&(d==="light"||k===void 0))&&(k=y))}const m={},w=Object.keys(p).filter(d=>p[d]!==k);if(w.length){const d=p.light!==void 0?p.light:k,h=p.dark!==void 0?p.dark:k;if(D(u)&&(0,$.isPlainColor)(d)&&(0,$.isPlainColor)(h)){m[u]=d===h?d:`light-dark(${d}, ${h})`;for(const y in p)y==="light"||y==="dark"||H(m,y,{[u]:p[y]},o)}else{k!==void 0&&(m[u]=k);for(const y of w)H(m,y,{[u]:p[y]},o)}}else{if(k===void 0)continue;m[u]=k}R(f,m),f[`.${u}`]=m}return(f.background||f.color||f.backgroundColor)&&(f[".inversed"]={color:f.background||f.backgroundColor,background:f.color}),f},E=(e,n,o,r)=>{const{cssVars:i}=o;o.cssMediaVars||(o.cssMediaVars={});const l=o.cssMediaVars,c=o.globalTheme!==void 0?o.globalTheme:"auto",b=c&&c!=="auto"?String(c).replace(/^'|'$/g,""):null,f={},u=new Set(r?Object.keys(r):[]);for(const t in e)if(e[t])for(const g of Object.keys(e[t]))u.add(g);const s=z(e,u);for(const t of u){const g=t.slice(0,1),p=(0,a.isObjectLike)(r?.[t])||Object.values(e).some(k=>(0,a.isObjectLike)(k?.[t]));if(g==="."&&p){const k=t.slice(1),m={};for(const d in e)(0,a.isObjectLike)(e[d]?.[t])&&(m[d]=e[d][t]);const w=(0,a.isObjectLike)(r?.[t])?r[t]:void 0;f[t]=E(m,`${n}-${k}`,o,w)}else if(g===":"&&p){const k=t.replace(/^:+/,""),m={};for(const d in e)(0,a.isObjectLike)(e[d]?.[t])&&(m[d]=e[d][t]);const w=(0,a.isObjectLike)(r?.[t])?r[t]:void 0;f[t]=E(m,`${n}-${k}`,o,w)}else if(g!=="@"&&g!=="."&&g!==":"){const m=`--${o.varPrefix?o.varPrefix+"-":""}theme-${n}-${t}`,w=r&&!(0,a.isObjectLike)(r[t])?r[t]:void 0,d=new Set(Object.keys(e));w!==void 0&&(d.add("light"),d.add("dark"),b&&d.add(b));let h,y=!1;for(const S of d){if(s.has(S))continue;let j=e[S]?.[t];if((j===void 0||(0,a.isObjectLike)(j))&&(j=w),j===void 0)continue;const v=_(n,t,j,`@${S}`);if(v===void 0)continue;y=!0,(b&&S===b||!b&&(S==="light"||h===void 0))&&(h=v);const C=`[data-theme="${S}"]`;if(l[C]||(l[C]={}),l[C][m]=v,S==="dark"||S==="light"){const q=`@media (prefers-color-scheme: ${S})`;l[q]||(l[q]={}),l[q][m]=v}}if(h!==void 0&&(i[m]=h),!y)continue;f[t]=`var(${m})`,f[`.${t}`]={[t]:f[t]}}}return(f.background||f.color||f.backgroundColor)&&(f[".inversed"]={color:f.background||f.backgroundColor,background:f.color}),f},A=(e,n,o,r)=>{const i=(0,O.getActiveConfig)(),{cssVars:l}=i,c={value:e},b=!o&&!r;let f,u;if((0,a.isObjectLike)(e)){if(b&&i.useVariable){const s={},t={};for(const g in e)g.startsWith("@")?(0,a.isObjectLike)(e[g])&&(s[g.slice(1)]=e[g]):t[g]=e[g];(Object.keys(s).length||Object.keys(t).length)&&(u=E(s,n,i,t),Object.assign(c,u))}else if(b){const s={},t={};for(const g in e)g.startsWith("@")?(0,a.isObjectLike)(e[g])&&(s[g.slice(1)]=e[g]):t[g]=e[g];f=U(s,n,i,t),Object.assign(c,f)}for(const s in e){const t=s.slice(0,1),g=e[s];if(t==="@"||t===":"||t==="."){const p=t==="@"&&s;c[s]=A(g,n,s,r||p)}else if(!b){const p=_(n,s,g,r),k=[...new Set([r,o].filter(h=>h).map(h=>h.slice(1)))],m=k.length?"-"+k.join("-"):"",d=`--${i.varPrefix?i.varPrefix+"-":""}theme-${n}${m}-${s}`;i.useVariable?(i.useThemeSuffixedVars&&(l[d]=p),c[s]=`var(${d})`):c[s]=p,c[`.${s}`]={[s]:c[s]}}}if(f)for(const s in f){const t=s.slice(0,1);(t==="."||t===":")&&(0,a.isObjectLike)(e[s])&&(c[s]=f[s])}if(u)for(const s in u){const t=s.slice(0,1);(t==="."||t===":")&&(0,a.isObjectLike)(e[s])&&(c[s]=u[s])}!c[".inversed"]&&(c.background||c.color||c.backgroundColor)&&(c[".inversed"]={color:c.background||c.backgroundColor,background:c.color})}if((0,a.isString)(e)&&(0,V.isCSSVar)(e)){const t=i.theme[e.slice(2)];return M(t,r)}return c},P=(e,n)=>{const o={};for(const r in e){const i=r.slice(0,1);if((0,a.isObjectLike)(e[r]))if(n&&se(r))o[r]=R({},e[r]);else{if(i==="@")continue;i===":"?o[`&${r}`]=P(e[r],n):i==="."&&(o[`&${r}`]=P(e[r],n))}else o[r]=e[r]}return o},Q=(e,n)=>{const o=n.shift();return e[o]?Q(e[o],n):e},Z=(e,n)=>(0,a.isArray)(n)?Q(e,n):(0,a.isString)(n)&&e[n]?e[n]:e,ce=(e,n)=>(0,a.isString)(e)&&(0,V.isCSSVar)(e)?M(e.slice(2)):e,ae=e=>ce(e,ae),M=(e,n)=>{const o=(0,O.getActiveConfig)();if((0,a.isString)(e)&&(0,V.isCSSVar)(e)&&(e=M(e.slice(2))),!e||!(0,a.isString)(e)){o.verbose&&console.warn(`${e} - Theme is not a string`);return}const[r,...i]=(0,a.isArray)(e)?e:e.split(" ");let l=o.theme[r];return l&&i.length?l=Z(l,i):l&&n&&(l=Z(l,n)),P(l,!o.useVariable)};
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var R=(r,t)=>{for(var e in t)m(r,e,{get:t[e],enumerable:!0})},T=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of C(t))!E.call(r,n)&&n!==e&&m(r,n,{get:()=>t[n],enumerable:!(i=B(t,n))||i.enumerable});return r};var O=r=>T(m({},"__esModule",{value:!0}),r);var b={};R(b,{resolveColorsInGradient:()=>g,splitTransition:()=>L,transformBackgroundImage:()=>V,transformBorder:()=>G,transformBorderRadius:()=>D,transformBoxShadow:()=>z,transformDuration:()=>K,transformGridTemplate:()=>F,transformShadow:()=>_,transformSize:()=>h,transformSizeRatio:()=>W,transformTextStroke:()=>I,transformTransition:()=>j,transfromGap:()=>$});module.exports=O(b);var f=require("@symbo.ls/utils"),d=require("../factory.js"),s=require("../system/index.js"),o=require("../utils/index.js");const A=new Set(["to","top","bottom","left","right","center","at","circle","ellipse","closest-side","farthest-side","closest-corner","farthest-corner"]),S=/^-?[A-Z][0-9]?$/,G=r=>(0,s.resolveBorderValue)(r),I=r=>{if((0,f.isString)(r))return o.CSS_NATIVE_COLOR_REGEX.test(r)?r:r.split(/\s+/).map(t=>{if(t=t.trim(),!t)return"";if((0,o.isCSSVar)(t))return`var(${t})`;if(/^\d/.test(t)||t.includes("px")||t==="0")return t;const e=(0,s.getColor)(t);return(0,o.isResolvedColor)(e)?e:t}).join(" ")},_=(r,t)=>(0,s.getShadow)(r,t),z=(r,t)=>{if((0,f.isString)(r))return o.CSS_NATIVE_COLOR_REGEX.test(r)?r:(0,o.splitTopLevelCommas)(r).map(e=>(e=e.trim(),e?e.split(/\s+/).map(i=>{if(i=i.trim(),!i)return"";if((0,o.isCSSVar)(i))return`var(${i})`;if(i==="inset"||i==="none")return i;const n=(0,s.getColor)(i);if((0,o.isResolvedColor)(n)){const l=(0,s.getMediaColor)(i,t);return(0,f.isObject)(l)?Object.values(l).filter(p=>p.includes(": "+t))[0]:l}if(/^\d/.test(i)||i==="0"||i.includes("px")||i.slice(-2)==="em")return i;const u=(0,s.getSpacingByKey)(i,"shadow");return u&&u.shadow?u.shadow:i}).join(" "):"")).join(", ")},g=(r,t)=>{const e=r.indexOf("(");if(e===-1)return r;const i=r.slice(0,e+1),n=r.slice(e+1,r.lastIndexOf(")")),u=")",p=(0,o.splitTopLevelCommas)(n).map(a=>(a=a.trim(),a.split(/\s+/).map(c=>{if(!c||/^\d/.test(c)||c==="0"||A.has(c)||c==="transparent"||o.CSS_NATIVE_COLOR_REGEX.test(c))return c;const x=(0,s.getColor)(c);return(0,o.isResolvedColor)(x)?x:c}).join(" ")));return i+p.join(", ")+u},V=(r,t)=>{if(!(0,f.isString)(r))return;const e=(0,d.getActiveConfig)();return(0,o.splitTopLevelCommas)(r).map(i=>{const n=i.trim();if((0,o.isCSSVar)(n))return`var(${n})`;if(/^var\(/.test(n)||n.includes("url"))return n;if(e.gradient?.[n]){const u=(0,s.getMediaColor)(n,t);if((0,f.isString)(u))return u;if((0,f.isObject)(u)){for(const l in u)if((0,f.isString)(u[l]))return u[l]}return n}return n.includes("gradient")?g(n,t):n.includes("/")||n.startsWith("http")||n.includes(".")&&!(0,o.parseColorToken)(n)?`url(${n})`:n}).join(", ")},$=r=>(0,f.isString)(r)&&r.split(" ").map(t=>(0,s.getSpacingByKey)(t,"gap").gap).join(" "),F=r=>{if(!(0,f.isString)(r))return r;const t=(0,d.getActiveConfig)();return(0,o.splitTopLevelSpaces)(r).map(e=>S.test(e)?(0,o.getSequenceValue)(e,t.spacing):e).join(" ")},j=r=>{if(!(0,f.isString)(r))return;const t=r.split(" ");return t.length?t.map(e=>(0,o.isCSSVar)(e)?`var(${e})`:e.length<3||e.includes("ms")?(0,s.getTimingByKey)(e).timing||e:(0,s.getTimingFunction)(e)?(0,s.getTimingFunction)(e):e).join(" "):r},K=(r,t,e)=>{if((0,f.isString)(r))return r.split(",").map(i=>(0,s.getTimingByKey)(i).timing||i).join(",")},L=r=>{if(!(0,f.isString)(r))return;const t=r.split(",");if(t.length)return t.map(j).join(",")};function h(r,t,e={},i={}){let n=f.exec.call(this,t||e[r]);if(n==null)return;let u;if((0,f.isString)(n)){if(/^(?:env|var)\(/.test(n.trim()))return{[r]:n};if(n.includes("(")){const a=(0,o.getFnPrefixAndValue)(n);u=a[0],n=a[1]}const l=e.scaleBoxSize,p=(0,s.checkIfBoxSize)(r);!l&&p&&!i.ratio&&(n=(0,s.splitSpacedValue)(n))}return i.ratio?(0,s.getSpacingBasedOnRatio)(e,r,n,u):(0,s.getSpacingByKey)(n,r,void 0,u)}const W=(r,t=null,e)=>h(r,t,e,{ratio:!0}),q=(r,t,e)=>(0,f.isString)(r)?r.split(" ").map(i=>S.test(i)?(0,s.getSpacingBasedOnRatio)(t,e,i)[e]:i).join(" "):r,D=(r,t,e,i="borderRadius")=>{if((0,f.isString)(r))return{[i]:r.split(" ").map(n=>{const u=(0,s.getShapeByKey)(n);return u!==void 0?q(u,t,e):(0,s.getSpacingBasedOnRatio)(t,e,n)[e]}).join(" ")}};
1
+ "use strict";var m=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var R=(r,t)=>{for(var e in t)m(r,e,{get:t[e],enumerable:!0})},T=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of C(t))!E.call(r,n)&&n!==e&&m(r,n,{get:()=>t[n],enumerable:!(i=B(t,n))||i.enumerable});return r};var O=r=>T(m({},"__esModule",{value:!0}),r);var b={};R(b,{resolveColorsInGradient:()=>g,splitTransition:()=>L,transformBackgroundImage:()=>V,transformBorder:()=>G,transformBorderRadius:()=>D,transformBoxShadow:()=>z,transformDuration:()=>K,transformGridTemplate:()=>F,transformShadow:()=>_,transformSize:()=>h,transformSizeRatio:()=>W,transformTextStroke:()=>I,transformTransition:()=>j,transfromGap:()=>$});module.exports=O(b);var f=require("@symbo.ls/utils"),d=require("../factory.js"),s=require("../system/index.js"),o=require("../utils/index.js");const A=new Set(["to","top","bottom","left","right","center","at","circle","ellipse","closest-side","farthest-side","closest-corner","farthest-corner"]),S=/^-?[A-Z][0-9]?$/,G=r=>(0,s.resolveBorderValue)(r),I=r=>{if((0,f.isString)(r))return o.CSS_NATIVE_COLOR_REGEX.test(r)?r:r.split(/\s+/).map(t=>{if(t=t.trim(),!t)return"";if((0,o.isCSSVar)(t))return`var(${t})`;if(/^\d/.test(t)||t.includes("px")||t==="0")return t;const e=(0,s.getColor)(t);return(0,o.isResolvedColor)(e)?e:t}).join(" ")},_=(r,t)=>(0,s.getShadow)(r,t),z=(r,t)=>{if((0,f.isString)(r))return o.CSS_NATIVE_COLOR_REGEX.test(r)?r:(0,o.splitTopLevelCommas)(r).map(e=>(e=e.trim(),e?e.split(/\s+/).map(i=>{if(i=i.trim(),!i)return"";if((0,o.isCSSVar)(i))return`var(${i})`;if(i==="inset"||i==="none")return i;const n=(0,s.getColor)(i);if((0,o.isResolvedColor)(n)){const l=(0,s.getMediaColor)(i,t);return(0,f.isObject)(l)?Object.values(l).filter(p=>p.includes(": "+t))[0]:l}if(/^\d/.test(i)||i==="0"||i.includes("px")||i.slice(-2)==="em")return i;const u=(0,s.getSpacingByKey)(i,"shadow");return u&&u.shadow?u.shadow:i}).join(" "):"")).join(", ")},g=(r,t)=>{const e=r.indexOf("(");if(e===-1)return r;const i=r.slice(0,e+1),n=r.slice(e+1,r.lastIndexOf(")")),u=")",p=(0,o.splitTopLevelCommas)(n).map(a=>(a=a.trim(),a.split(/\s+/).map(c=>{if(!c||/^\d/.test(c)||c==="0"||A.has(c)||c==="transparent"||o.CSS_NATIVE_COLOR_REGEX.test(c))return c;const x=(0,s.getColor)(c);return(0,o.isResolvedColor)(x)?x:c}).join(" ")));return i+p.join(", ")+u},V=(r,t)=>{if(!(0,f.isString)(r))return;const e=(0,d.getActiveConfig)();return(0,o.splitTopLevelCommas)(r).map(i=>{const n=i.trim();if((0,o.isCSSVar)(n))return`var(${n})`;if(/^var\(/.test(n)||n.includes("url"))return n;if(e.gradient?.[n]){const u=(0,s.getMediaColor)(n,t);if((0,f.isString)(u))return u;if((0,f.isObject)(u)){for(const l in u)if((0,f.isString)(u[l]))return u[l]}return n}return n.includes("gradient")?g(n,t):n.includes("/")||n.startsWith("http")||n.includes(".")&&!(0,o.parseColorToken)(n)?`url(${n})`:n}).join(", ")},$=r=>(0,f.isString)(r)&&(0,o.splitTopLevelSpaces)(r).map(t=>(0,s.getSpacingByKey)(t,"gap").gap).join(" "),F=r=>{if(!(0,f.isString)(r))return r;const t=(0,d.getActiveConfig)();return(0,o.splitTopLevelSpaces)(r).map(e=>S.test(e)?(0,o.getSequenceValue)(e,t.spacing):e).join(" ")},j=r=>{if(!(0,f.isString)(r))return;const t=r.split(" ");return t.length?t.map(e=>(0,o.isCSSVar)(e)?`var(${e})`:e.length<3||e.includes("ms")?(0,s.getTimingByKey)(e).timing||e:(0,s.getTimingFunction)(e)?(0,s.getTimingFunction)(e):e).join(" "):r},K=(r,t,e)=>{if((0,f.isString)(r))return r.split(",").map(i=>(0,s.getTimingByKey)(i).timing||i).join(",")},L=r=>{if(!(0,f.isString)(r))return;const t=r.split(",");if(t.length)return t.map(j).join(",")};function h(r,t,e={},i={}){let n=f.exec.call(this,t||e[r]);if(n==null)return;let u;if((0,f.isString)(n)){if(/^(?:env|var)\(/.test(n.trim()))return{[r]:n};if(n.includes("(")){const a=(0,o.getFnPrefixAndValue)(n);u=a[0],n=a[1]}const l=e.scaleBoxSize,p=(0,s.checkIfBoxSize)(r);!l&&p&&!i.ratio&&(n=(0,s.splitSpacedValue)(n))}return i.ratio?(0,s.getSpacingBasedOnRatio)(e,r,n,u):(0,s.getSpacingByKey)(n,r,void 0,u)}const W=(r,t=null,e)=>h(r,t,e,{ratio:!0}),q=(r,t,e)=>(0,f.isString)(r)?(0,o.splitTopLevelSpaces)(r).map(i=>S.test(i)?(0,s.getSpacingBasedOnRatio)(t,e,i)[e]:i).join(" "):r,D=(r,t,e,i="borderRadius")=>{if((0,f.isString)(r))return{[i]:(0,o.splitTopLevelSpaces)(r).map(n=>{const u=(0,s.getShapeByKey)(n);return u!==void 0?q(u,t,e):(0,s.getSpacingBasedOnRatio)(t,e,n)[e]}).join(" ")}};
@@ -1 +1 @@
1
- "use strict";var M=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var H=(t,n)=>{for(var e in n)M(t,e,{get:n[e],enumerable:!0})},Z=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of W(n))!G.call(t,r)&&r!==e&&M(t,r,{get:()=>n[r],enumerable:!(s=E(n,r))||s.enumerable});return t};var k=t=>Z(M({},"__esModule",{value:!0}),t);var P={};H(P,{findHeadingLetter:()=>_,findHeadings:()=>q,generateSequence:()=>Q,generateSequencePosition:()=>X,generateSubSequence:()=>O,getFnPrefixAndValue:()=>D,getSequenceValue:()=>U,getSequenceValueBySymbols:()=>N,getSequenceValuePropertyPair:()=>Y,getSubratio:()=>B,getSubratioDifference:()=>C,numToLetterMap:()=>S,setScalingVar:()=>I,setSubScalingVar:()=>F});module.exports=k(P);var w=require("@symbo.ls/utils"),T=require("@symbo.ls/utils"),j=require("@symbo.ls/utils"),L=require("../factory.js"),y=require("./unit.js"),z=require("./color.js");const S={"-6":"U","-5":"V","-4":"W","-3":"X","-2":"Y","-1":"Z",0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T"},A=(t,n)=>{const{key:e,variable:s,value:r,scaling:i,index:o,scalingVariable:p}=t;n.sequence[e]={key:e,decimal:~~(r*100)/100,val:~~r,scaling:i,index:o,scalingVariable:p,variable:s},n.scales[e]=i;const l=R.has(n.unit)?"rem":n.unit;n.vars[s]=i+l},D=t=>{if(!t.includes("("))return t;const n=t.split("(")[0],e=t.slice(t.indexOf("(")+1,t.lastIndexOf(")"));return[n,e]},R=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),I=(t,n)=>{const{base:e,type:s,unit:r}=n,i=R.has(r)?"rem":r,o=((0,y.isScalingUnit)(i)?1:e)+i;if(t===0)return o;const l="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),d=`${l}-ratio`;if(t>0){const f=S[t-1];return`calc(var(${l}-${f}) * var(${d}))`}if(t<0){const f=S[t+1],g=Math.abs(t),h=Math.pow(K,2*g),m=S[g];return m?`max(calc(var(${l}-${f}) / var(${d})), calc(var(${l}-${m}) / ${h.toFixed(4)}))`:`calc(var(${l}-${f}) / var(${d}))`}},F=(t,n,e,s)=>{const{type:r}=s,o=t===2&&n.length===2?t+1:t,d=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(r&&r.replace(".","-"))}-sub-ratio-`;return`calc(var(${e}) * var(${d+o}))`},C=(t,n)=>{const s=(t*n-t)/1.618,r=t*n-s,i=t+s,o=(r+i)/2;return[r,o,i]},B=(t,n)=>C(t,n).map(e=>e/t),O=(t,n)=>{const{key:e,base:s,value:r,ratio:i,variable:o,index:p}=t,d=~~(r*i)-~~r;let f;const[g,h,m]=C(r,i);d>16?f=[g,h,m]:f=[g,m],f.forEach((u,c)=>{const $=~~(u/s*1e3)/1e3,v=o+(c+1),V=p+(c+1)/10,a=F(c+1,f,o,n),x={key:e+(c+1),variable:v,value:u,scaling:$,scalingVariable:a,index:V};A(x,n)})},K=1.618,J=(t,n,e)=>{if(t>=0)return n*Math.pow(e,t);const s=Math.abs(t),r=n*Math.pow(e,t),i=n*Math.pow(e,s)/Math.pow(K,2*s);return Math.max(r,i)},Q=t=>{const{type:n,base:e,ratio:s,range:r,subSequence:i}=t,o=Math.abs(r[0])+Math.abs(r[1]),l="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let d=0;d<=o;d++){const f=r[1]-d,g=S[f],h=J(f,e,s),m=~~(h/e*100)/100,u=l+g,c=I(f,t),$={key:g,variable:u,value:h,base:e,scaling:m,scalingVariable:c,ratio:s,index:f};A($,t),i&&O($,t)}return t},X=(t,n=0)=>{const{type:e,base:s,ratio:r,subSequence:i}=t,o=(0,w.isString)(n)?n:S[n],p=(0,w.isString)(n)?Object.entries(S).find(([,$])=>$===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const l={sequence:{},scales:{},vars:{},...t},d=s*Math.pow(r,p),f=~~(d/s*100)/100,m="--"+(t.varPrefix?t.varPrefix+"-":"")+(e&&e.replace(".","-"))+"-"+o,u=I(p,t),c={key:o,variable:m,value:d,base:s,scaling:f,scalingVariable:u,ratio:r,index:p};return A(c,l),i&&O(c,l),l},U=(t="A",n)=>{const e=(0,L.getActiveConfig)(),{unit:s}=e;if((0,w.isString)(t)&&(0,z.isCSSVar)(t))return`var(${t})`;if((0,w.isString)(t)&&/^(?:env|var|calc|min|max|clamp)\(/.test(t.trim()))return t;if((0,w.isString)(t)){const a=e.sizes;if(a){const x=a[t]||a[t.toLowerCase()];if(x!==void 0)return t.slice(0,1)==="-"?`calc(${x} * -1)`:x}}const{sequence:r,unit:i=s.default,useVariable:o}=n,p=/^-?[a-zA-Z]/i,l=p.test(t);if((0,y.isRawUnitValue)(t)||!l||["none","auto","max-content","min-content","fit-content","inherit","initial","unset","revert","revert-layer"].includes(t))return t;const h=`--${n.varPrefix?n.varPrefix+"-":""}${(0,T.toDashCase)(n.type.replace(".","-"))}-`,m=t.toUpperCase(),u=m.slice(0,1)==="-"?"-":"";let c=u?m.slice(1):m,$="";c.includes("_")&&($="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const v=a=>p.test(a)?`var(${h}${a}${$})`:a;if(c.includes("+")){const[a,x]=c.split("+"),b=`${v(a)} + ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}else if(c.includes("*")){const[a,x]=c.split("*"),b=`${v(a)} * ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}else if(c.includes("-")){const[a,x]=c.split("-"),b=`${v(a)} - ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}if(!r[c]&&c.length===2&&(e.verbose&&console.warn(c,"- value is not found because `subSequence` is set to false"),c=c.slice(0,1)),o||e.useVariable){const a=`var(${h}${c}${$})`;return u?`calc(${a} * -1)`:a}const V=r?r[c]:null;if(!V){if(console.warn("can't find",r,c),(0,j.isLoudDevRuntime)())throw new Error(`[smbls] Unresolvable design-system token "${t}"`+(n.type?` for sequence "${n.type}"`:"")+" \u2014 not a registered `sizes` name and not a valid spacing/typography/timing sequence letter. The CSS property using it would silently be dropped in production. Register the token in `designSystem/sizes.js` (or the relevant sequence family) or fix the typo.");return}return i==="ms"||i==="s"?u+V.val+i:u+V.scaling+i},N=(t,n)=>{if(!["+","-","*","/",","].filter(i=>t.includes(i+" ")).length)return t;const s=/(\s+-\s+|\s*[+*/,]\s*)/;return t.split(s).map(i=>{const o=i.trim();return!o||["+","-","*","/",","].includes(o)?i:U(o,n)}).join("")},Y=(t,n,e,s)=>{if(typeof t!="string")return(0,L.getActiveConfig)().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!s&&t.includes("(")){if(/^(?:env|var)\(/.test(t.trim()))return{[n]:t};const i=D(t);s=i[0],t=i[1]}return["+","-","*","/",","].filter(i=>t.includes(i+" ")).length?t=N(t,e):t=U(t,e),{[n]:s?`${s}(${t})`:t}},_=(t,n)=>S[t-n],q=t=>{const{h1Matches:n,sequence:e}=t;return new Array(6).fill(null).map((s,r)=>{const i=_(n,r);return e[i]})};
1
+ "use strict";var M=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var W=(t,n)=>{for(var e in n)M(t,e,{get:n[e],enumerable:!0})},B=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of k(n))!H.call(t,r)&&r!==e&&M(t,r,{get:()=>n[r],enumerable:!(s=G(n,r))||s.enumerable});return t};var Z=t=>B(M({},"__esModule",{value:!0}),t);var st={};W(st,{findHeadingLetter:()=>F,findHeadings:()=>rt,generateSequence:()=>tt,generateSequencePosition:()=>nt,generateSubSequence:()=>I,getFnPrefixAndValue:()=>z,getSequenceValue:()=>U,getSequenceValueBySymbols:()=>K,getSequenceValuePropertyPair:()=>et,getSubratio:()=>P,getSubratioDifference:()=>R,numToLetterMap:()=>S,setScalingVar:()=>O,setSubScalingVar:()=>D});module.exports=Z(st);var w=require("@symbo.ls/utils"),N=require("@symbo.ls/utils"),E=require("@symbo.ls/utils"),C=require("../factory.js"),y=require("./unit.js"),j=require("./color.js");const S={"-6":"U","-5":"V","-4":"W","-3":"X","-2":"Y","-1":"Z",0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T"},A=(t,n)=>{const{key:e,variable:s,value:r,scaling:i,index:o,scalingVariable:l}=t;n.sequence[e]={key:e,decimal:~~(r*100)/100,val:~~r,scaling:i,index:o,scalingVariable:l,variable:s},n.scales[e]=i;const a=T.has(n.unit)?"rem":n.unit;n.vars[s]=i+a},z=t=>{if(!t.includes("("))return t;const n=t.trim(),e=n.indexOf("("),s=n.slice(0,e);let r=0,i=-1;for(let o=e;o<n.length;o++){const l=n[o];if(l==="(")r++;else if(l===")"&&(r--,r===0)){i=o;break}}return i===-1||/\s/.test(s)||n.slice(i+1).trim()!==""?[void 0,t]:[s,n.slice(e+1,i)]},L="\0",J=(t,n)=>{let e="",s=0,r="";for(const i of t){if(s===0&&i!=="("){e+=i;continue}r+=i,i==="("?s++:i===")"&&(s--,s===0&&(e+=L+n.length+L,n.push(r),r=""))}return e+r},Q=(t,n)=>t.indexOf(L)===-1?t:t.replace(/\u0000(\d+)\u0000/g,(e,s)=>n[Number(s)]),X=/^(calc|min|max|clamp)\((.*)\)$/,Y=(t,n)=>{const e=X.exec(t);return e?`${e[1]}(${K(e[2],n)})`:t.indexOf("(")!==-1?t:U(t,n)},T=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),O=(t,n)=>{const{base:e,type:s,unit:r}=n,i=T.has(r)?"rem":r,o=((0,y.isScalingUnit)(i)?1:e)+i;if(t===0)return o;const a="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),d=`${a}-ratio`;if(t>0){const u=S[t-1];return`calc(var(${a}-${u}) * var(${d}))`}if(t<0){const u=S[t+1],g=Math.abs(t),h=Math.pow(_,2*g),m=S[g];return m?`max(calc(var(${a}-${u}) / var(${d})), calc(var(${a}-${m}) / ${h.toFixed(4)}))`:`calc(var(${a}-${u}) / var(${d}))`}},D=(t,n,e,s)=>{const{type:r}=s,o=t===2&&n.length===2?t+1:t,d=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(r&&r.replace(".","-"))}-sub-ratio-`;return`calc(var(${e}) * var(${d+o}))`},R=(t,n)=>{const s=(t*n-t)/1.618,r=t*n-s,i=t+s,o=(r+i)/2;return[r,o,i]},P=(t,n)=>R(t,n).map(e=>e/t),I=(t,n)=>{const{key:e,base:s,value:r,ratio:i,variable:o,index:l}=t,d=~~(r*i)-~~r;let u;const[g,h,m]=R(r,i);d>16?u=[g,h,m]:u=[g,m],u.forEach((p,c)=>{const $=~~(p/s*1e3)/1e3,b=o+(c+1),V=l+(c+1)/10,f=D(c+1,u,o,n),x={key:e+(c+1),variable:b,value:p,scaling:$,scalingVariable:f,index:V};A(x,n)})},_=1.618,q=(t,n,e)=>{if(t>=0)return n*Math.pow(e,t);const s=Math.abs(t),r=n*Math.pow(e,t),i=n*Math.pow(e,s)/Math.pow(_,2*s);return Math.max(r,i)},tt=t=>{const{type:n,base:e,ratio:s,range:r,subSequence:i}=t,o=Math.abs(r[0])+Math.abs(r[1]),a="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let d=0;d<=o;d++){const u=r[1]-d,g=S[u],h=q(u,e,s),m=~~(h/e*100)/100,p=a+g,c=O(u,t),$={key:g,variable:p,value:h,base:e,scaling:m,scalingVariable:c,ratio:s,index:u};A($,t),i&&I($,t)}return t},nt=(t,n=0)=>{const{type:e,base:s,ratio:r,subSequence:i}=t,o=(0,w.isString)(n)?n:S[n],l=(0,w.isString)(n)?Object.entries(S).find(([,$])=>$===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const a={sequence:{},scales:{},vars:{},...t},d=s*Math.pow(r,l),u=~~(d/s*100)/100,m="--"+(t.varPrefix?t.varPrefix+"-":"")+(e&&e.replace(".","-"))+"-"+o,p=O(l,t),c={key:o,variable:m,value:d,base:s,scaling:u,scalingVariable:p,ratio:r,index:l};return A(c,a),i&&I(c,a),a},U=(t="A",n)=>{const e=(0,C.getActiveConfig)(),{unit:s}=e;if((0,w.isString)(t)&&(0,j.isCSSVar)(t))return`var(${t})`;if((0,w.isString)(t)&&/^(?:env|var|calc|min|max|clamp)\(/.test(t.trim()))return t;if((0,w.isString)(t)){const f=e.sizes;if(f){const x=f[t]||f[t.toLowerCase()];if(x!==void 0)return t.slice(0,1)==="-"?`calc(${x} * -1)`:x}}const{sequence:r,unit:i=s.default,useVariable:o}=n,l=/^-?[a-zA-Z]/i,a=l.test(t);if((0,y.isRawUnitValue)(t)||!a||["none","auto","max-content","min-content","fit-content","inherit","initial","unset","revert","revert-layer"].includes(t))return t;const h=`--${n.varPrefix?n.varPrefix+"-":""}${(0,N.toDashCase)(n.type.replace(".","-"))}-`,m=t.toUpperCase(),p=m.slice(0,1)==="-"?"-":"";let c=p?m.slice(1):m,$="";c.includes("_")&&($="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const b=f=>l.test(f)?`var(${h}${f}${$})`:f;if(c.includes("+")){const[f,x]=c.split("+"),v=`${b(f)} + ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("*")){const[f,x]=c.split("*"),v=`${b(f)} * ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("-")){const[f,x]=c.split("-"),v=`${b(f)} - ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}if(!r[c]&&c.length===2&&(e.verbose&&console.warn(c,"- value is not found because `subSequence` is set to false"),c=c.slice(0,1)),o||e.useVariable){const f=`var(${h}${c}${$})`;return p?`calc(${f} * -1)`:f}const V=r?r[c]:null;if(!V){if(console.warn("can't find",r,c),(0,E.isLoudDevRuntime)())throw new Error(`[smbls] Unresolvable design-system token "${t}"`+(n.type?` for sequence "${n.type}"`:"")+" \u2014 not a registered `sizes` name and not a valid spacing/typography/timing sequence letter. The CSS property using it would silently be dropped in production. Register the token in `designSystem/sizes.js` (or the relevant sequence family) or fix the typo.");return}return i==="ms"||i==="s"?p+V.val+i:p+V.scaling+i},K=(t,n)=>{if(!["+","-","*","/",","].filter(o=>t.includes(o+" ")).length)return t;const s=/(\s+-\s+|\s*[+*/,]\s*)/,r=[];return J(t,r).split(s).map(o=>{const l=Q(o,r),a=l.trim();return!a||["+","-","*","/",","].includes(a)?l:Y(a,n)}).join("")},et=(t,n,e,s)=>{if(typeof t!="string")return(0,C.getActiveConfig)().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!s&&t.includes("(")){if(/^(?:env|var)\(/.test(t.trim()))return{[n]:t};const i=z(t);s=i[0],t=i[1]}return["+","-","*","/",","].filter(i=>t.includes(i+" ")).length?t=K(t,e):t=U(t,e),{[n]:s?`${s}(${t})`:t}},F=(t,n)=>S[t-n],rt=t=>{const{h1Matches:n,sequence:e}=t;return new Array(6).fill(null).map((s,r)=>{const i=F(n,r);return e[i]})};
@@ -1 +1 @@
1
- export*from"./sequence.js";export*from"./unit.js";export*from"./typography.js";export*from"./font.js";export*from"./font-family.js";export*from"./media.js";export*from"./spacing.js";export*from"./color.js";export*from"./theme.js";export*from"./shadow.js";export*from"./icons.js";export*from"./timing.js";export*from"./document.js";export*from"./responsive.js";export*from"./animation.js";export*from"./svg.js";export*from"./templates.js";export*from"./grid.js";export*from"./class.js";const o={},r={},t={},e={};export{o as reset,e as shape,t as sizes,r as vars};
1
+ export*from"./sequence.js";export*from"./unit.js";export*from"./typography.js";export*from"./font.js";export*from"./font-family.js";export*from"./media.js";export*from"./spacing.js";export*from"./color.js";export*from"./theme.js";export*from"./shadow.js";export*from"./icons.js";export*from"./timing.js";export*from"./document.js";export*from"./responsive.js";export*from"./animation.js";export*from"./svg.js";export*from"./templates.js";export*from"./grid.js";export*from"./class.js";const o={},r={},t={},e={},p={};export{o as reset,e as shape,t as sizes,p as skins,r as vars};
@@ -1 +1 @@
1
- import{deepClone as S,deepMerge as b,isDefined as l,isObject as h}from"@symbo.ls/utils";import{createSignal as d}from"@symbo.ls/signal";import*as O from"./defaultConfig/index.js";const C={},T={},v=new Set,f=O,p={},A=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in f){const t=e.toLowerCase();p[t]=f[e];const o=A(t);o!==t&&(p[o]=f[e]),t!==e&&(p[e]=f[e])}const i={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:C,cssMediaVars:T,CSS_VARS:C,CSS_MEDIA_VARS:T,_scratchConfig:!0,...p},m=(e,t)=>{if(!e)return null;if(e.__globalThemeSignal)return l(t)&&e.__globalThemeSignal.set(t),e.__globalThemeSignal;const o=l(t)?t:e.globalTheme,s=d(l(o)?o:"auto");return Object.defineProperty(e,"globalTheme",{get(){return s.get()},set(r){s.set(r)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},D=e=>e?m(e):null,g=(e,t)=>{if(!e)return null;if(e.__resolvedThemeSignal)return l(t)&&e.__resolvedThemeSignal.set(t),e.__resolvedThemeSignal;const o=l(t)?t:e.resolvedTheme,s=d(l(o)?o:null);return Object.defineProperty(e,"resolvedTheme",{get(){return s.get()},set(r){s.set(r)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"__resolvedThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},M=e=>e?g(e):null;m(i),g(i);const _=S(i),a={active:"0",0:i},j=e=>(l(e)&&(a.active=e),a[e||a.active]),u=[],E=e=>{e&&e._scratchConfig&&u.push(e)},G=()=>{u.pop()},y=e=>u.length?u[u.length-1]:a[e||a.active]||i,L=e=>{if(h(e))return a.active="1",a[1]=b(e,S(_),v),x(a[1]),m(a[1]),g(a[1]),e},V=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],R=["useVariable","globalTheme","verbose"],F=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],x=e=>{for(const t of F){let o;for(const s of t){const r=e[s];h(r)&&(o=o?b(o,r,v):r)}if(o)for(const s of t)h(e[s])&&(e[s]=o)}},w=(e,t,{cleanBase:o=!1}={})=>{const s=o?null:y(),r=S(!o&&s&&s._scratchConfig?s:_);for(const c of V)delete r[c];for(const c of R)Object.prototype.hasOwnProperty.call(_,c)?r[c]=_[c]:delete r[c];const n=b(t||{},r,v);return n.cssVars={},n.cssMediaVars={},n.CSS_VARS=n.cssVars,n.CSS_MEDIA_VARS=n.cssMediaVars,n._scratchConfig=!0,x(n),m(n),g(n),e&&(a[e]=n),n};export{i as CONFIG,v as CONFIG_MERGE_EXL,a as FACTORY,j as activateConfig,x as aliasCaseVariants,w as createConfig,T as cssMediaVars,C as cssVars,g as defineResolvedThemeSignal,m as defineThemeSignal,y as getActiveConfig,M as getResolvedThemeSignal,D as getThemeSignal,G as popConfig,E as pushConfig,L as setActiveConfig,A as toCamel};
1
+ import{deepClone as _,deepMerge as b,isDefined as l,isObject as h}from"@symbo.ls/utils";import{createSignal as d}from"@symbo.ls/signal";import*as O from"./defaultConfig/index.js";const C={},T={},v=new Set,f=O,p={},A=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in f){const t=e.toLowerCase();p[t]=f[e];const o=A(t);o!==t&&(p[o]=f[e]),t!==e&&(p[e]=f[e])}const i={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:C,cssMediaVars:T,CSS_VARS:C,CSS_MEDIA_VARS:T,cssSkinVars:{},cssSkinFallback:{},_scratchConfig:!0,...p},m=(e,t)=>{if(!e)return null;if(e.__globalThemeSignal)return l(t)&&e.__globalThemeSignal.set(t),e.__globalThemeSignal;const o=l(t)?t:e.globalTheme,s=d(l(o)?o:"auto");return Object.defineProperty(e,"globalTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},k=e=>e?m(e):null,g=(e,t)=>{if(!e)return null;if(e.__resolvedThemeSignal)return l(t)&&e.__resolvedThemeSignal.set(t),e.__resolvedThemeSignal;const o=l(t)?t:e.resolvedTheme,s=d(l(o)?o:null);return Object.defineProperty(e,"resolvedTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"__resolvedThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},D=e=>e?g(e):null;m(i),g(i);const S=_(i),a={active:"0",0:i},M=e=>(l(e)&&(a.active=e),a[e||a.active]),u=[],j=e=>{e&&e._scratchConfig&&u.push(e)},E=()=>{u.pop()},V=e=>u.length?u[u.length-1]:a[e||a.active]||i,G=e=>{if(h(e))return a.active="1",a[1]=b(e,_(S),v),x(a[1]),m(a[1]),g(a[1]),e},y=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],F=["useVariable","globalTheme","verbose"],R=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],x=e=>{for(const t of R){let o;for(const s of t){const n=e[s];h(n)&&(o=o?b(o,n,v):n)}if(o)for(const s of t)h(e[s])&&(e[s]=o)}},L=(e,t,{cleanBase:o=!1}={})=>{const s=o?null:V(),n=_(!o&&s&&s._scratchConfig?s:S);for(const c of y)delete n[c];for(const c of F)Object.prototype.hasOwnProperty.call(S,c)?n[c]=S[c]:delete n[c];const r=b(t||{},n,v);return r.cssVars={},r.cssMediaVars={},r.CSS_VARS=r.cssVars,r.CSS_MEDIA_VARS=r.cssMediaVars,r.cssSkinVars={},r.cssSkinFallback={},r._scratchConfig=!0,x(r),m(r),g(r),e&&(a[e]=r),r};export{i as CONFIG,v as CONFIG_MERGE_EXL,a as FACTORY,M as activateConfig,x as aliasCaseVariants,L as createConfig,T as cssMediaVars,C as cssVars,g as defineResolvedThemeSignal,m as defineThemeSignal,V as getActiveConfig,D as getResolvedThemeSignal,k as getThemeSignal,E as popConfig,j as pushConfig,G as setActiveConfig,A as toCamel};
@@ -1 +1 @@
1
- import{CONFIG_MERGE_EXL as $,aliasCaseVariants as z,getActiveConfig as S,setActiveConfig as B,toCamel as K}from"./factory.js";import{setColor as U,setGradient as X,setFont as J,setFontFamily as P,setTheme as Q,setSvgIcon as Z,setSVG as G,applyTypographySequence as N,applySpacingSequence as ee,applyReset as te,applyTimingSequence as se,applyDocument as oe,setShadow as re}from"./system/index.js";import{deepMerge as ne,isObject as k,isArray as q}from"@symbo.ls/utils";import{isDomDocument as j,isHostObject as O,parkHostObject as W,resolveConfigDocument as F}from"./utils/host.js";const y="__smblsThemeRootOwner",b=t=>{const s=t&&t.__prefersListener,e=t&&t.__prefersMq;if(s&&e)try{typeof e.removeEventListener=="function"?e.removeEventListener("change",s):typeof e.removeListener=="function"&&e.removeListener(s)}catch{try{e.removeListener(s)}catch{}}t&&(t.__prefersListener=null,t.__prefersMq=null)},I=(t,s,e)=>{if(!(!t||!s)){b(t),t.__prefersListener=e,t.__prefersMq=s;try{s.addEventListener("change",e)}catch{s.addListener(e)}}},ie=(t,s)=>{const e=S(),{cssVars:n}=e,i=s.startsWith("--")?s:`--${s}`;return n[i]=t,t},f=t=>t,H={color:U,gradient:X,font:J,fontFamily:P,fontfamily:P,theme:Q,icons:Z,semanticIcons:f,semanticicons:f,svg:G,svgData:f,typography:f,shadow:re,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:ie,sizes:f,shape:f},ce=(t,s,e,n)=>{W(t,e,s);const i={};for(const o of n)t[o]===s&&(t[o]=i);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),i},ae=(t,s,e)=>{const n=S(),i=K(t),o=i.toLowerCase(),d=n[i]||n[o]||n[t],r=O(d)?ce(n,d,o,[i,o,t]):d,m=H[i]||H[o];if(m)try{const a=m(s,e);return r&&(r[e]=a),r}catch(a){n.verbose&&console.warn("Error setting",o,"value",s,e,a)}if(!m){const a=r||(n[o]={});return a[e]=s,a}n.verbose&&console.warn("Can not find",o,"method in scratch")},le=(t,s)=>{const e=S(),n=t.toLowerCase();return O(s)?(W(e,n,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",n,"design-system family"),e[n]||e[t]):s==null?(e.verbose&&console.warn("[scratch] skipping empty design-system family",n),e[n]||e[t]):(Object.keys(s).sort((o,d)=>{const r=k(s[o])||q(s[o])?1:0,m=k(s[d])||q(s[d])?1:0;return r-m}).forEach(o=>{try{return ae(n,s[o],o)}catch(d){e.verbose&&console.warn("Error setting",n,"value",s[o],o,d)}}),e[n]||e[t])},ve=(t,s)=>{const e=s||S();e.globalTheme=t;const i=F(e)||(typeof document<"u"?document:null),o=i&&i.defaultView||(typeof window<"u"?window:null);if(i){const r=e.themeRoot||i.documentElement,m=t&&t!=="auto";if(r[y]=e,m)b(e),r.setAttribute("data-theme",t),e.resolvedTheme=t,t==="dark"||t==="light"?r.style.colorScheme=t:r.style.colorScheme="light dark";else if(o&&o.matchMedia){const a=g=>{const v=g.matches?"dark":"light";r.setAttribute("data-theme",v),e.resolvedTheme=v},h=o.matchMedia("(prefers-color-scheme: dark)");a(h),r.style.colorScheme="light dark",I(e,h,a)}else b(e),r.setAttribute("data-theme","light"),e.resolvedTheme="light",r.style.colorScheme="light"}const d=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const r in e.cssVars)r.startsWith(d)&&delete e.cssVars[r];for(const r in e.cssMediaVars)delete e.cssMediaVars[r];if(i&&e.cssVars){const r=e.scopeSelector||":root",m=i.styleSheets;for(let a=0;a<m.length;a++)try{const h=m[a].cssRules;for(let g=0;g<h.length;g++)if(h[g].selectorText===r){for(const v in e.cssVars)h[g].style.setProperty(v,e.cssVars[v]);return e}}catch{}}return e},fe={},ye=(t,s=fe)=>{let e=s.config||S();const{version:n,verbose:i,useVariable:o,useReset:d,useSvgSprite:r,useFontImport:m,useIconSprite:a,globalTheme:h,themeRoot:g,useDocumentTheme:v,useDefaultConfig:E,semanticIcons:V,hoverMedia:x,files:R,assets:D,...u}=t;s.newConfig&&(e=B(s.newConfig)),j(u.document)&&(e.__domDocument=u.document,delete u.document),j(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),R!==void 0&&(e.files=R),D!==void 0&&(e.assets=D),i!==void 0&&(e.verbose=i),o!==void 0&&(e.useVariable=o),d!==void 0&&(e.useReset=d),m!==void 0&&(e.useFontImport=m),r!==void 0&&(e.useSvgSprite=r),a!==void 0&&(e.useIconSprite=a),v!==void 0&&(e.useDocumentTheme=v),h!==void 0&&(e.globalTheme=h),g!==void 0&&(e.themeRoot=g),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),E!==void 0&&(e.useDefaultConfig=E),V!==void 0&&(e.semanticIcons=V),x!==void 0&&(e.hoverMedia=x),e.verbose&&console.log(e);const _=F(e)||(typeof document<"u"?document:null),T=_&&_.defaultView||(typeof window<"u"?window:null),l=_&&(e.themeRoot||_.documentElement);if(l&&typeof l.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")b(e),l.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,l[y]=e,e.globalTheme==="dark"||e.globalTheme==="light"?l.style.colorScheme=e.globalTheme:l.style.colorScheme="light dark";else if(l[y]&&l[y]!==e&&l.hasAttribute("data-theme"))b(e),e.resolvedTheme=l.getAttribute("data-theme");else if(T&&T.matchMedia){const p=Y=>{const M=Y.matches?"dark":"light";l.setAttribute("data-theme",M),e.resolvedTheme=M},C=T.matchMedia("(prefers-color-scheme: dark)");p(C),l.style.colorScheme="light dark",l[y]=e,I(e,C,p)}else b(e),l.setAttribute("data-theme","light"),e.resolvedTheme="light",l.style.colorScheme="light",l[y]=e;e.__svgCache||(e.__svgCache={}),z(u);const w=Object.keys(u).filter(c=>!c.startsWith("__")),L=new Set(w);if(w.forEach(c=>{const p=c.toLowerCase();p!==c&&L.has(p)&&ne(u[p],u[c],$)}),w.map(c=>{const p=c.toLowerCase();if(!(p!==c&&L.has(p)))return le(c,u[c])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),u.typography)try{N()}catch(c){e.verbose&&console.warn("Error applying typography sequence",c)}if(u.spacing)try{ee()}catch(c){e.verbose&&console.warn("Error applying spacing sequence",c)}if(u.timing)try{se()}catch(c){e.verbose&&console.warn("Error applying timing sequence",c)}oe();const A=te();return A&&(e.reset=A),e};export{H as VALUE_TRANSFORMERS,ve as changeGlobalTheme,ye as set,le as setEach,ae as setValue};
1
+ import{CONFIG_MERGE_EXL as $,aliasCaseVariants as z,getActiveConfig as S,setActiveConfig as B,toCamel as K}from"./factory.js";import{setColor as U,setGradient as X,setFont as J,setFontFamily as M,setTheme as Q,setSvgIcon as Z,setSVG as G,applyTypographySequence as N,applySpacingSequence as ee,applyReset as te,applyTimingSequence as se,applyDocument as oe,applySkins as re,setShadow as ne}from"./system/index.js";import{deepMerge as ie,isObject as P,isArray as q}from"@symbo.ls/utils";import{isDomDocument as j,isHostObject as O,parkHostObject as W,resolveConfigDocument as F}from"./utils/host.js";const y="__smblsThemeRootOwner",b=t=>{const s=t&&t.__prefersListener,e=t&&t.__prefersMq;if(s&&e)try{typeof e.removeEventListener=="function"?e.removeEventListener("change",s):typeof e.removeListener=="function"&&e.removeListener(s)}catch{try{e.removeListener(s)}catch{}}t&&(t.__prefersListener=null,t.__prefersMq=null)},I=(t,s,e)=>{if(!(!t||!s)){b(t),t.__prefersListener=e,t.__prefersMq=s;try{s.addEventListener("change",e)}catch{s.addListener(e)}}},ce=(t,s)=>{const e=S(),{cssVars:n}=e,i=s.startsWith("--")?s:`--${s}`;return n[i]=t,t},f=t=>t,H={color:U,gradient:X,font:J,fontFamily:M,fontfamily:M,theme:Q,icons:Z,semanticIcons:f,semanticicons:f,svg:G,svgData:f,typography:f,shadow:ne,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:ce,sizes:f,shape:f,skins:f},ae=(t,s,e,n)=>{W(t,e,s);const i={};for(const o of n)t[o]===s&&(t[o]=i);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),i},le=(t,s,e)=>{const n=S(),i=K(t),o=i.toLowerCase(),d=n[i]||n[o]||n[t],r=O(d)?ae(n,d,o,[i,o,t]):d,m=H[i]||H[o];if(m)try{const a=m(s,e);return r&&(r[e]=a),r}catch(a){n.verbose&&console.warn("Error setting",o,"value",s,e,a)}if(!m){const a=r||(n[o]={});return a[e]=s,a}n.verbose&&console.warn("Can not find",o,"method in scratch")},fe=(t,s)=>{const e=S(),n=t.toLowerCase();return O(s)?(W(e,n,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",n,"design-system family"),e[n]||e[t]):s==null?(e.verbose&&console.warn("[scratch] skipping empty design-system family",n),e[n]||e[t]):(Object.keys(s).sort((o,d)=>{const r=P(s[o])||q(s[o])?1:0,m=P(s[d])||q(s[d])?1:0;return r-m}).forEach(o=>{try{return le(n,s[o],o)}catch(d){e.verbose&&console.warn("Error setting",n,"value",s[o],o,d)}}),e[n]||e[t])},ye=(t,s)=>{const e=s||S();e.globalTheme=t;const i=F(e)||(typeof document<"u"?document:null),o=i&&i.defaultView||(typeof window<"u"?window:null);if(i){const r=e.themeRoot||i.documentElement,m=t&&t!=="auto";if(r[y]=e,m)b(e),r.setAttribute("data-theme",t),e.resolvedTheme=t,t==="dark"||t==="light"?r.style.colorScheme=t:r.style.colorScheme="light dark";else if(o&&o.matchMedia){const a=g=>{const v=g.matches?"dark":"light";r.setAttribute("data-theme",v),e.resolvedTheme=v},h=o.matchMedia("(prefers-color-scheme: dark)");a(h),r.style.colorScheme="light dark",I(e,h,a)}else b(e),r.setAttribute("data-theme","light"),e.resolvedTheme="light",r.style.colorScheme="light"}const d=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const r in e.cssVars)r.startsWith(d)&&delete e.cssVars[r];for(const r in e.cssMediaVars)delete e.cssMediaVars[r];if(i&&e.cssVars){const r=e.scopeSelector||":root",m=i.styleSheets;for(let a=0;a<m.length;a++)try{const h=m[a].cssRules;for(let g=0;g<h.length;g++)if(h[g].selectorText===r){for(const v in e.cssVars)h[g].style.setProperty(v,e.cssVars[v]);return e}}catch{}}return e},de={},be=(t,s=de)=>{let e=s.config||S();const{version:n,verbose:i,useVariable:o,useReset:d,useSvgSprite:r,useFontImport:m,useIconSprite:a,globalTheme:h,themeRoot:g,useDocumentTheme:v,useDefaultConfig:E,semanticIcons:V,hoverMedia:x,files:R,assets:D,...u}=t;s.newConfig&&(e=B(s.newConfig)),j(u.document)&&(e.__domDocument=u.document,delete u.document),j(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),R!==void 0&&(e.files=R),D!==void 0&&(e.assets=D),i!==void 0&&(e.verbose=i),o!==void 0&&(e.useVariable=o),d!==void 0&&(e.useReset=d),m!==void 0&&(e.useFontImport=m),r!==void 0&&(e.useSvgSprite=r),a!==void 0&&(e.useIconSprite=a),v!==void 0&&(e.useDocumentTheme=v),h!==void 0&&(e.globalTheme=h),g!==void 0&&(e.themeRoot=g),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),E!==void 0&&(e.useDefaultConfig=E),V!==void 0&&(e.semanticIcons=V),x!==void 0&&(e.hoverMedia=x),e.verbose&&console.log(e);const _=F(e)||(typeof document<"u"?document:null),T=_&&_.defaultView||(typeof window<"u"?window:null),l=_&&(e.themeRoot||_.documentElement);if(l&&typeof l.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")b(e),l.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,l[y]=e,e.globalTheme==="dark"||e.globalTheme==="light"?l.style.colorScheme=e.globalTheme:l.style.colorScheme="light dark";else if(l[y]&&l[y]!==e&&l.hasAttribute("data-theme"))b(e),e.resolvedTheme=l.getAttribute("data-theme");else if(T&&T.matchMedia){const p=Y=>{const C=Y.matches?"dark":"light";l.setAttribute("data-theme",C),e.resolvedTheme=C},k=T.matchMedia("(prefers-color-scheme: dark)");p(k),l.style.colorScheme="light dark",l[y]=e,I(e,k,p)}else b(e),l.setAttribute("data-theme","light"),e.resolvedTheme="light",l.style.colorScheme="light",l[y]=e;e.__svgCache||(e.__svgCache={}),z(u);const w=Object.keys(u).filter(c=>!c.startsWith("__")),L=new Set(w);if(w.forEach(c=>{const p=c.toLowerCase();p!==c&&L.has(p)&&ie(u[p],u[c],$)}),w.map(c=>{const p=c.toLowerCase();if(!(p!==c&&L.has(p)))return fe(c,u[c])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),u.typography)try{N()}catch(c){e.verbose&&console.warn("Error applying typography sequence",c)}if(u.spacing)try{ee()}catch(c){e.verbose&&console.warn("Error applying spacing sequence",c)}if(u.timing)try{se()}catch(c){e.verbose&&console.warn("Error applying timing sequence",c)}try{re()}catch(c){e.verbose&&console.warn("Error applying skins",c)}oe();const A=te();return A&&(e.reset=A),e};export{H as VALUE_TRANSFORMERS,ye as changeGlobalTheme,be as set,fe as setEach,le as setValue};
@@ -1 +1 @@
1
- export*from"./color.js";export*from"./ink.js";export*from"./theme.js";export*from"./font.js";export*from"./typography.js";export*from"./spacing.js";export*from"./shape.js";export*from"./shadow.js";export*from"./border.js";export*from"./timing.js";export*from"./document.js";export*from"./svg.js";export*from"./reset.js";
1
+ export*from"./color.js";export*from"./ink.js";export*from"./theme.js";export*from"./font.js";export*from"./typography.js";export*from"./spacing.js";export*from"./shape.js";export*from"./shadow.js";export*from"./border.js";export*from"./timing.js";export*from"./document.js";export*from"./svg.js";export*from"./reset.js";export*from"./skin.js";
@@ -0,0 +1 @@
1
+ import{isObject as l,isString as m,isLoudDevRuntime as y}from"@symbo.ls/utils";import{getActiveConfig as O}from"../factory.js";const v=new Set(["fallback"]),h=new Set,u=(n,e)=>{h.has(n)||(h.add(n),y()&&console.warn(e))},x=()=>{h.clear()},p=n=>{for(const e in n)delete n[e];return n},R=()=>{const n=O(),e=l(n.cssSkinVars)?p(n.cssSkinVars):n.cssSkinVars={},s=l(n.cssSkinFallback)?p(n.cssSkinFallback):n.cssSkinFallback={},c=n.skins;if(!l(c))return e;const a=n.varPrefix?n.varPrefix+"-":"",o=n.color||{},k=n.cssVars||{},w=t=>m(t)&&Object.prototype.hasOwnProperty.call(o,t)?`var(--${a}color-${t})`:t;for(const t in c){const r=c[t];if(!l(r))continue;const S={};for(const i in r){if(v.has(i))continue;const $=r[i];if(l($))for(const f in $){const d=`--${a}theme-${i}-${f}`;n.useVariable!==!1&&!(d in k)&&u(`${t}/${i}/${f}`,`[scratch] skin "${t}" rewrites theme "${i}" param "${f}", which the theme does not declare \u2014 no element reads ${d}, so the skin changes nothing there. Declare "${f}" on the "${i}" theme (its no-skin value).`),S[d]=w($[f])}}e[t]=S,m(r.fallback)&&(s[t]=r.fallback)}for(const t in s){const r=s[t];e[r]||(u(`${t}/fallback/${r}`,`[scratch] skin "${t}" falls back to "${r}", which is not a declared skin \u2014 the reduced-transparency fallback is skipped.`),delete s[t])}return e},b=(n,e)=>{const s=`[data-skin="${n}"]`;return!e||e===":root"?`:root${s}, ${s}`:`${e}${s}, ${s} ${e}, ${e} ${s}`},C=(n,e,s)=>{const c={};if(!l(n))return c;for(const o in n)c[b(o,s)]=n[o];const a={};for(const o in e||{}){const k=n[e[o]];k&&(a[b(o,s)]=k)}return Object.keys(a).length&&(c["@media (prefers-reduced-transparency: reduce)"]=a),c};export{x as __resetSkinWarnings,R as applySkins,C as buildSkinVarStyles};
@@ -1 +1 @@
1
- import{arrayzeValue as I}from"@symbo.ls/utils";import{isArray as q,isString as S,merge as G}from"@symbo.ls/utils";import{getActiveConfig as l}from"../factory.js";import{CSS_UNITS as B,applyMediaSequenceVars as C,applySequenceVars as f,generateSequence as d,getFnPrefixAndValue as p,getSequenceValuePropertyPair as h}from"../utils/index.js";const b=t=>{const n=l().spacing||{},s=parseFloat(t.spacingRatio),i={...n,ratio:Number.isFinite(s)?s:n.ratio,sequence:{},scales:{}};return d(i),i},k=t=>{for(const e in t){const n=t[e];if(!(e.slice(0,1)==="@"))continue;const{type:i,base:o,ratio:c,range:r,subSequence:g,h1Matches:a,unit:u}=t;G(n,{type:i,base:o,ratio:c,range:r,subSequence:g,h1Matches:a,unit:u,sequence:{},scales:{},templates:{},vars:{}}),d(n),C(t,e)}},M=t=>{const e=t.toLowerCase(),n=e.includes("width")||e.includes("height"),s=e.includes("border")||e.includes("outline");return n&&!s},O=()=>{const t=l(),{spacing:e}=t;d(e),f(e),k(e)},y=t=>{const e=l(),{spacing:n}=e;return!t||!t.sequence?n:Object.keys(t.sequence).length>0?t:d(t)},m=(t,e="padding",n,s)=>{const i=y(n);if(S(t)){if(!s&&/^(?:env|var)\(/.test(t.trim()))return{[e]:t};if(!s&&t.includes("(")){const c=p(t);s=c[0],t=c[1]}}const o=s?[t]:I(t);if(q(o)){if(o.length>1){let c="";e==="borderWidth"&&(e="border",c="Width");const r={2:["Block","Inline"],3:["BlockStart","Inline","BlockEnd"],4:["BlockStart","InlineEnd","BlockEnd","InlineStart"]},g=(a,u)=>h(o[u],e+a+c,i,s);return r[o.length].map((a,u)=>g(a,u))}return h(t,e,i,s)}},j=(t,e,n,s)=>{const i=l(),{spacing:o}=i;let c=n||t[e];if(!s&&S(c)&&/^(?:env|var)\(/.test(c.trim()))return{[e]:c};if(!s&&S(c)&&c.includes("(")){const r=p(c);s=r[0],c=r[1]}if(t.spacingRatio){const r=b(t);return m(c,e,r,s)}return m(c,e,o,s)},w=t=>{const e=n=>{const s=["+","-","*","/"].includes(n),i=B.some(c=>t.includes(c));return s||i?n:n.length<3&&/[A-Z]/.test(n)?n+"_default":n};return t.split(",").map(n=>n.trim()).map(e).join(",").split(" ").map(e).join(" ")};export{O as applySpacingSequence,M as checkIfBoxSize,j as getSpacingBasedOnRatio,m as getSpacingByKey,w as splitSpacedValue};
1
+ import{arrayzeValue as I}from"@symbo.ls/utils";import{isArray as q,isString as l,merge as G}from"@symbo.ls/utils";import{getActiveConfig as d}from"../factory.js";import{CSS_UNITS as B,applyMediaSequenceVars as C,applySequenceVars as f,generateSequence as g,getFnPrefixAndValue as p,getSequenceValuePropertyPair as h,splitTopLevelSpaces as b}from"../utils/index.js";const k=t=>{const n=d().spacing||{},s=parseFloat(t.spacingRatio),i={...n,ratio:Number.isFinite(s)?s:n.ratio,sequence:{},scales:{}};return g(i),i},y=t=>{for(const e in t){const n=t[e];if(!(e.slice(0,1)==="@"))continue;const{type:i,base:o,ratio:c,range:r,subSequence:S,h1Matches:a,unit:u}=t;G(n,{type:i,base:o,ratio:c,range:r,subSequence:S,h1Matches:a,unit:u,sequence:{},scales:{},templates:{},vars:{}}),g(n),C(t,e)}},L=t=>{const e=t.toLowerCase(),n=e.includes("width")||e.includes("height"),s=e.includes("border")||e.includes("outline");return n&&!s},O=()=>{const t=d(),{spacing:e}=t;g(e),f(e),y(e)},A=t=>{const e=d(),{spacing:n}=e;return!t||!t.sequence?n:Object.keys(t.sequence).length>0?t:g(t)},m=(t,e="padding",n,s)=>{const i=A(n);if(l(t)){if(!s&&/^(?:env|var)\(/.test(t.trim()))return{[e]:t};if(!s&&t.includes("(")){const c=p(t);s=c[0],t=c[1]}}const o=s?[t]:l(t)&&t.includes("(")?b(t):I(t);if(q(o)){if(o.length>1){let c="";e==="borderWidth"&&(e="border",c="Width");const r={2:["Block","Inline"],3:["BlockStart","Inline","BlockEnd"],4:["BlockStart","InlineEnd","BlockEnd","InlineStart"]},S=(a,u)=>h(o[u],e+a+c,i,s);return r[o.length].map((a,u)=>S(a,u))}return h(t,e,i,s)}},j=(t,e,n,s)=>{const i=d(),{spacing:o}=i;let c=n||t[e];if(!s&&l(c)&&/^(?:env|var)\(/.test(c.trim()))return{[e]:c};if(!s&&l(c)&&c.includes("(")){const r=p(c);s=r[0],c=r[1]}if(t.spacingRatio){const r=k(t);return m(c,e,r,s)}return m(c,e,o,s)},w=t=>{const e=n=>{const s=["+","-","*","/"].includes(n),i=B.some(c=>t.includes(c));return s||i?n:n.length<3&&/[A-Z]/.test(n)?n+"_default":n};return t.split(",").map(n=>n.trim()).map(e).join(",").split(" ").map(e).join(" ")};export{O as applySpacingSequence,L as checkIfBoxSize,j as getSpacingBasedOnRatio,m as getSpacingByKey,w as splitSpacedValue};
@@ -1 +1 @@
1
- import{getColor as x,isPlainColor as O,schemeMediaQuery as Z,schemeGuardSelector as J}from"./color.js";import{resolveShadowValue as _}from"./shadow.js";import{resolveBorderValue as w}from"./border.js";import{getActiveConfig as R}from"../factory.js";import{isCSSVar as j,parseColorToken as X}from"../utils/color.js";import{isObject as E,isString as T,isObjectLike as y,isArray as P,isLoudDevRuntime as Y}from"@symbo.ls/utils";const K=new Set(["black","white","red","green","blue","yellow","orange","purple","pink","brown","gray","grey","cyan","magenta","lime","olive","navy","teal","aqua","maroon","silver","fuchsia","transparent","currentColor","currentcolor","inherit","initial","unset","none","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","rebeccapurple"]),L=["color","Color","background","Background","fill","Fill","stroke","Stroke"],B=e=>{for(let n=0;n<L.length;n++)if(e.includes(L[n]))return!0;return!1},N={boxShadow:_,textShadow:_,border:w,borderTop:w,borderRight:w,borderBottom:w,borderLeft:w,outline:w,columnRule:w},F=e=>{if(!e)return!1;const n=X(e);return!n||!n.name||n.passthrough||n.cssVar?!1:n.alpha!==void 0||n.tone!==void 0},D=new Set,G=(e,n,r,t,s,a)=>{if(!Y())return;const i=`${e}::${n}::${r||""}::${t}`;D.has(i)||(D.add(i),console.warn(`[smbls/scratch] theme param "${n}" on "${e}"`+(r?` (${r})`:"")+` did not fully resolve: "${t}" -> "${s}" still contains the unresolved token "${a}". This is not valid CSS \u2014 the browser will drop the whole declaration. Register "${a}" as a design-system color token or fix the typo.`))},v=(e,n,r,t)=>{const s=N[n];if(!s)return x(r,t);let a=null;const i=s(r,t,g=>{!a&&F(g)&&(a=g)});return a&&G(e,n,t,r,i,a),i},de=(e,n)=>M(e,n),I=e=>E(e)&&y(e.value),ee=e=>{for(const n in e){const r=e[n];if(T(r)&&r.startsWith("var(--"))return!0}return!1},ue=(e,n)=>{const r=R();return I(e)?!r.useVariable&&ee(e)?e:C(e.value,n):C(e,n)},W=(e,n)=>{const r=new Set;for(const t of n){const s=t.slice(0,1);if(!(s==="@"||s==="."||s===":")&&B(t))for(const a in e){if(r.has(a))continue;const i=e[a]?.[t];if(i===void 0)continue;const g=x(i,`@${a}`);g!==void 0&&T(g)&&/^[a-z][a-zA-Z]+$/.test(g)&&!K.has(g)&&r.add(a)}}return r},oe=e=>e.startsWith("[data-theme=")||e.startsWith("@media"),V=(e,n)=>{for(const r in n){const t=n[r];E(t)?V(e[r]||(e[r]={}),t):e[r]=t}return e},z=(e,n,r,t)=>{if(V(e,{[`[data-theme="${n}"] &`]:r}),n!=="light"&&n!=="dark")return;const s=Z(n,t);s&&V(e,{[s]:{[J(t)]:r}})},H=(e,n,r,t)=>{const s=r.globalTheme!==void 0?r.globalTheme:"auto",a=s&&s!=="auto"?String(s).replace(/^'|'$/g,""):null,i=new Set(t?Object.keys(t):[]);for(const o in e)if(e[o])for(const c of Object.keys(e[o]))i.add(c);const g=W(e,i),f={};for(const o of i){const c=o.slice(0,1);if(c==="@")continue;if(c==="."||c===":"){const d={};for(const $ in e)y(e[$]?.[o])&&(d[$]=e[$][o]);const h=t&&y(t[o])?t[o]:void 0;if(!Object.keys(d).length&&!h)continue;const m=c==="."?o.slice(1):o.replace(/^:+/,"");f[o]=H(d,`${n}-${m}`,r,h);continue}const b=t&&!y(t[o])?t[o]:void 0,k=new Set(Object.keys(e));b!==void 0&&(k.add("light"),k.add("dark"),a&&k.add(a));const l={};let u;for(const d of k){if(g.has(d))continue;let h=e[d]?.[o];if((h===void 0||y(h))&&(h=b),h===void 0)continue;const m=v(n,o,h,`@${d}`);m!==void 0&&(l[d]=m,(a&&d===a||!a&&(d==="light"||u===void 0))&&(u=m))}const S={},p=Object.keys(l).filter(d=>l[d]!==u);if(p.length){const d=l.light!==void 0?l.light:u,h=l.dark!==void 0?l.dark:u;if(B(o)&&O(d)&&O(h)){S[o]=d===h?d:`light-dark(${d}, ${h})`;for(const m in l)m==="light"||m==="dark"||z(S,m,{[o]:l[m]},r)}else{u!==void 0&&(S[o]=u);for(const m of p)z(S,m,{[o]:l[m]},r)}}else{if(u===void 0)continue;S[o]=u}V(f,S),f[`.${o}`]=S}return(f.background||f.color||f.backgroundColor)&&(f[".inversed"]={color:f.background||f.backgroundColor,background:f.color}),f},A=(e,n,r)=>{const{cssVars:t}=r;r.cssMediaVars||(r.cssMediaVars={});const s=r.cssMediaVars,a=r.globalTheme!==void 0?r.globalTheme:"auto",i={},g=new Set;for(const o in e)if(e[o])for(const c of Object.keys(e[o]))g.add(c);const f=W(e,g);for(const o of g){const c=o.slice(0,1),b=Object.values(e).some(k=>y(k?.[o]));if(c==="."&&b){const k=o.slice(1),l={};for(const u in e)y(e[u]?.[o])&&(l[u]=e[u][o]);i[o]=A(l,`${n}-${k}`,r)}else if(c===":"&&b){const k=o.replace(/^:+/,""),l={};for(const u in e)y(e[u]?.[o])&&(l[u]=e[u][o]);i[o]=A(l,`${n}-${k}`,r)}else if(c!=="@"&&c!=="."&&c!==":"){const l=`--${r.varPrefix?r.varPrefix+"-":""}theme-${n}-${o}`,u=a&&a!=="auto"?String(a).replace(/^'|'$/g,""):null;let S;for(const p in e){if(f.has(p))continue;const d=e[p]?.[o];if(d===void 0)continue;const h=v(n,o,d,`@${p}`);if(h===void 0)continue;(u&&p===u||!u&&(p==="light"||S===void 0))&&(S=h);const m=`[data-theme="${p}"]`;if(s[m]||(s[m]={}),s[m][l]=h,p==="dark"||p==="light"){const $=`@media (prefers-color-scheme: ${p})`;s[$]||(s[$]={}),s[$][l]=h}}S!==void 0&&(t[l]=S),i[o]=`var(${l})`,i[`.${o}`]={[o]:i[o]}}}return(i.background||i.color||i.backgroundColor)&&(i[".inversed"]={color:i.background||i.backgroundColor,background:i.color}),i},C=(e,n,r,t)=>{const s=R(),{cssVars:a}=s,i={value:e},g=!r&&!t;let f;if(y(e)){if(g&&s.useVariable){const o={};for(const c in e)c.startsWith("@")&&y(e[c])&&(o[c.slice(1)]=e[c]);if(Object.keys(o).length){const c=A(o,n,s);Object.assign(i,c)}}else if(g){const o={},c={};for(const b in e)b.startsWith("@")?y(e[b])&&(o[b.slice(1)]=e[b]):c[b]=e[b];f=H(o,n,s,c),Object.assign(i,f)}for(const o in e){const c=o.slice(0,1),b=e[o];if(c==="@"||c===":"||c==="."){const k=c==="@"&&o;i[o]=C(b,n,o,t||k)}else if(!g){const k=v(n,o,b,t),l=[...new Set([t,r].filter(d=>d).map(d=>d.slice(1)))],u=l.length?"-"+l.join("-"):"",p=`--${s.varPrefix?s.varPrefix+"-":""}theme-${n}${u}-${o}`;s.useVariable?(s.useThemeSuffixedVars&&(a[p]=k),i[o]=`var(${p})`):i[o]=k,i[`.${o}`]={[o]:i[o]}}}if(f)for(const o in f){const c=o.slice(0,1);(c==="."||c===":")&&y(e[o])&&(i[o]=f[o])}!i[".inversed"]&&(i.background||i.color||i.backgroundColor)&&(i[".inversed"]={color:i.background||i.backgroundColor,background:i.color})}if(T(e)&&j(e)){const c=s.theme[e.slice(2)];return M(c,t)}return i},q=(e,n)=>{const r={};for(const t in e){const s=t.slice(0,1);if(y(e[t]))if(n&&oe(t))r[t]=V({},e[t]);else{if(s==="@")continue;s===":"?r[`&${t}`]=q(e[t],n):s==="."&&(r[`&${t}`]=q(e[t],n))}else r[t]=e[t]}return r},U=(e,n)=>{const r=n.shift();return e[r]?U(e[r],n):e},Q=(e,n)=>P(n)?U(e,n):T(n)&&e[n]?e[n]:e,ne=(e,n)=>T(e)&&j(e)?M(e.slice(2)):e,re=e=>ne(e,re),M=(e,n)=>{const r=R();if(T(e)&&j(e)&&(e=M(e.slice(2))),!e||!T(e)){r.verbose&&console.warn(`${e} - Theme is not a string`);return}const[t,...s]=P(e)?e:e.split(" ");let a=r.theme[t];return a&&s.length?a=Q(a,s):a&&n&&(a=Q(a,n)),q(a,!r.useVariable)};export{M as getMediaTheme,de as getTheme,C as setMediaTheme,ue as setTheme};
1
+ import{getColor as P,isPlainColor as B,schemeMediaQuery as K,schemeGuardSelector as N}from"./color.js";import{resolveShadowValue as L}from"./shadow.js";import{resolveBorderValue as $}from"./border.js";import{getActiveConfig as A}from"../factory.js";import{isCSSVar as C,parseColorToken as F}from"../utils/color.js";import{isObject as D,isString as T,isObjectLike as k,isArray as W,isLoudDevRuntime as G}from"@symbo.ls/utils";const I=new Set(["black","white","red","green","blue","yellow","orange","purple","pink","brown","gray","grey","cyan","magenta","lime","olive","navy","teal","aqua","maroon","silver","fuchsia","transparent","currentColor","currentcolor","inherit","initial","unset","none","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","rebeccapurple"]),z=["color","Color","background","Background","fill","Fill","stroke","Stroke"],H=e=>{for(let n=0;n<z.length;n++)if(e.includes(z[n]))return!0;return!1},ee={boxShadow:L,textShadow:L,border:$,borderTop:$,borderRight:$,borderBottom:$,borderLeft:$,outline:$,columnRule:$},ne=e=>{if(!e)return!1;const n=F(e);return!n||!n.name||n.passthrough||n.cssVar?!1:n.alpha!==void 0||n.tone!==void 0},U=new Set,oe=(e,n,o,r,a,c)=>{if(!G())return;const s=`${e}::${n}::${o||""}::${r}`;U.has(s)||(U.add(s),console.warn(`[smbls/scratch] theme param "${n}" on "${e}"`+(o?` (${o})`:"")+` did not fully resolve: "${r}" -> "${a}" still contains the unresolved token "${c}". This is not valid CSS \u2014 the browser will drop the whole declaration. Register "${c}" as a design-system color token or fix the typo.`))},q=(e,n,o,r)=>{const a=ee[n];if(!a)return P(o,r);let c=null;const s=a(o,r,m=>{!c&&ne(m)&&(c=m)});return c&&oe(e,n,r,o,s,c),s},he=(e,n)=>M(e,n),re=e=>D(e)&&k(e.value),te=e=>{for(const n in e){const o=e[n];if(T(o)&&o.startsWith("var(--"))return!0}return!1},me=(e,n)=>{const o=A();return re(e)?!o.useVariable&&te(e)?e:_(e.value,n):_(e,n)},Q=(e,n)=>{const o=new Set;for(const r of n){const a=r.slice(0,1);if(!(a==="@"||a==="."||a===":")&&H(r))for(const c in e){if(o.has(c))continue;const s=e[c]?.[r];if(s===void 0)continue;const m=P(s,`@${c}`);m!==void 0&&T(m)&&/^[a-z][a-zA-Z]+$/.test(m)&&!I.has(m)&&o.add(c)}}return o},ie=e=>e.startsWith("[data-theme=")||e.startsWith("@media"),j=(e,n)=>{for(const o in n){const r=n[o];D(r)?j(e[o]||(e[o]={}),r):e[o]=r}return e},Z=(e,n,o,r)=>{if(j(e,{[`[data-theme="${n}"] &`]:o}),n!=="light"&&n!=="dark")return;const a=K(n,r);a&&j(e,{[a]:{[N(r)]:o}})},J=(e,n,o,r)=>{const a=o.globalTheme!==void 0?o.globalTheme:"auto",c=a&&a!=="auto"?String(a).replace(/^'|'$/g,""):null,s=new Set(r?Object.keys(r):[]);for(const d in e)if(e[d])for(const i of Object.keys(e[d]))s.add(i);const m=Q(e,s),u={};for(const d of s){const i=d.slice(0,1);if(i==="@")continue;if(i==="."||i===":"){const l={};for(const S in e)k(e[S]?.[d])&&(l[S]=e[S][d]);const g=r&&k(r[d])?r[d]:void 0;if(!Object.keys(l).length&&!g)continue;const y=i==="."?d.slice(1):d.replace(/^:+/,"");u[d]=J(l,`${n}-${y}`,o,g);continue}const t=r&&!k(r[d])?r[d]:void 0,f=new Set(Object.keys(e));t!==void 0&&(f.add("light"),f.add("dark"),c&&f.add(c));const p={};let b;for(const l of f){if(m.has(l))continue;let g=e[l]?.[d];if((g===void 0||k(g))&&(g=t),g===void 0)continue;const y=q(n,d,g,`@${l}`);y!==void 0&&(p[l]=y,(c&&l===c||!c&&(l==="light"||b===void 0))&&(b=y))}const h={},w=Object.keys(p).filter(l=>p[l]!==b);if(w.length){const l=p.light!==void 0?p.light:b,g=p.dark!==void 0?p.dark:b;if(H(d)&&B(l)&&B(g)){h[d]=l===g?l:`light-dark(${l}, ${g})`;for(const y in p)y==="light"||y==="dark"||Z(h,y,{[d]:p[y]},o)}else{b!==void 0&&(h[d]=b);for(const y of w)Z(h,y,{[d]:p[y]},o)}}else{if(b===void 0)continue;h[d]=b}j(u,h),u[`.${d}`]=h}return(u.background||u.color||u.backgroundColor)&&(u[".inversed"]={color:u.background||u.backgroundColor,background:u.color}),u},x=(e,n,o,r)=>{const{cssVars:a}=o;o.cssMediaVars||(o.cssMediaVars={});const c=o.cssMediaVars,s=o.globalTheme!==void 0?o.globalTheme:"auto",m=s&&s!=="auto"?String(s).replace(/^'|'$/g,""):null,u={},d=new Set(r?Object.keys(r):[]);for(const t in e)if(e[t])for(const f of Object.keys(e[t]))d.add(f);const i=Q(e,d);for(const t of d){const f=t.slice(0,1),p=k(r?.[t])||Object.values(e).some(b=>k(b?.[t]));if(f==="."&&p){const b=t.slice(1),h={};for(const l in e)k(e[l]?.[t])&&(h[l]=e[l][t]);const w=k(r?.[t])?r[t]:void 0;u[t]=x(h,`${n}-${b}`,o,w)}else if(f===":"&&p){const b=t.replace(/^:+/,""),h={};for(const l in e)k(e[l]?.[t])&&(h[l]=e[l][t]);const w=k(r?.[t])?r[t]:void 0;u[t]=x(h,`${n}-${b}`,o,w)}else if(f!=="@"&&f!=="."&&f!==":"){const h=`--${o.varPrefix?o.varPrefix+"-":""}theme-${n}-${t}`,w=r&&!k(r[t])?r[t]:void 0,l=new Set(Object.keys(e));w!==void 0&&(l.add("light"),l.add("dark"),m&&l.add(m));let g,y=!1;for(const S of l){if(i.has(S))continue;let V=e[S]?.[t];if((V===void 0||k(V))&&(V=w),V===void 0)continue;const R=q(n,t,V,`@${S}`);if(R===void 0)continue;y=!0,(m&&S===m||!m&&(S==="light"||g===void 0))&&(g=R);const v=`[data-theme="${S}"]`;if(c[v]||(c[v]={}),c[v][h]=R,S==="dark"||S==="light"){const O=`@media (prefers-color-scheme: ${S})`;c[O]||(c[O]={}),c[O][h]=R}}if(g!==void 0&&(a[h]=g),!y)continue;u[t]=`var(${h})`,u[`.${t}`]={[t]:u[t]}}}return(u.background||u.color||u.backgroundColor)&&(u[".inversed"]={color:u.background||u.backgroundColor,background:u.color}),u},_=(e,n,o,r)=>{const a=A(),{cssVars:c}=a,s={value:e},m=!o&&!r;let u,d;if(k(e)){if(m&&a.useVariable){const i={},t={};for(const f in e)f.startsWith("@")?k(e[f])&&(i[f.slice(1)]=e[f]):t[f]=e[f];(Object.keys(i).length||Object.keys(t).length)&&(d=x(i,n,a,t),Object.assign(s,d))}else if(m){const i={},t={};for(const f in e)f.startsWith("@")?k(e[f])&&(i[f.slice(1)]=e[f]):t[f]=e[f];u=J(i,n,a,t),Object.assign(s,u)}for(const i in e){const t=i.slice(0,1),f=e[i];if(t==="@"||t===":"||t==="."){const p=t==="@"&&i;s[i]=_(f,n,i,r||p)}else if(!m){const p=q(n,i,f,r),b=[...new Set([r,o].filter(g=>g).map(g=>g.slice(1)))],h=b.length?"-"+b.join("-"):"",l=`--${a.varPrefix?a.varPrefix+"-":""}theme-${n}${h}-${i}`;a.useVariable?(a.useThemeSuffixedVars&&(c[l]=p),s[i]=`var(${l})`):s[i]=p,s[`.${i}`]={[i]:s[i]}}}if(u)for(const i in u){const t=i.slice(0,1);(t==="."||t===":")&&k(e[i])&&(s[i]=u[i])}if(d)for(const i in d){const t=i.slice(0,1);(t==="."||t===":")&&k(e[i])&&(s[i]=d[i])}!s[".inversed"]&&(s.background||s.color||s.backgroundColor)&&(s[".inversed"]={color:s.background||s.backgroundColor,background:s.color})}if(T(e)&&C(e)){const t=a.theme[e.slice(2)];return M(t,r)}return s},E=(e,n)=>{const o={};for(const r in e){const a=r.slice(0,1);if(k(e[r]))if(n&&ie(r))o[r]=j({},e[r]);else{if(a==="@")continue;a===":"?o[`&${r}`]=E(e[r],n):a==="."&&(o[`&${r}`]=E(e[r],n))}else o[r]=e[r]}return o},X=(e,n)=>{const o=n.shift();return e[o]?X(e[o],n):e},Y=(e,n)=>W(n)?X(e,n):T(n)&&e[n]?e[n]:e,se=(e,n)=>T(e)&&C(e)?M(e.slice(2)):e,ce=e=>se(e,ce),M=(e,n)=>{const o=A();if(T(e)&&C(e)&&(e=M(e.slice(2))),!e||!T(e)){o.verbose&&console.warn(`${e} - Theme is not a string`);return}const[r,...a]=W(e)?e:e.split(" ");let c=o.theme[r];return c&&a.length?c=Y(c,a):c&&n&&(c=Y(c,n)),E(c,!o.useVariable)};export{M as getMediaTheme,he as getTheme,_ as setMediaTheme,me as setTheme};
@@ -1 +1 @@
1
- import{isString as u,isObject as h,exec as O}from"@symbo.ls/utils";import{getActiveConfig as B}from"../factory.js";import{getSpacingByKey as p,getColor as m,getShadow as A,getShapeByKey as G,getMediaColor as C,getTimingByKey as E,getTimingFunction as R,getSpacingBasedOnRatio as d,checkIfBoxSize as I,splitSpacedValue as _,resolveBorderValue as z}from"../system/index.js";import{getFnPrefixAndValue as V,isResolvedColor as x,isCSSVar as a,CSS_NATIVE_COLOR_REGEX as S,splitTopLevelCommas as g,splitTopLevelSpaces as $,parseColorToken as F,getSequenceValue as K}from"../utils/index.js";const L=new Set(["to","top","bottom","left","right","center","at","circle","ellipse","closest-side","farthest-side","closest-corner","farthest-corner"]),T=/^-?[A-Z][0-9]?$/,X=r=>z(r),Y=r=>{if(u(r))return S.test(r)?r:r.split(/\s+/).map(e=>{if(e=e.trim(),!e)return"";if(a(e))return`var(${e})`;if(/^\d/.test(e)||e.includes("px")||e==="0")return e;const t=m(e);return x(t)?t:e}).join(" ")},Z=(r,e)=>A(r,e),y=(r,e)=>{if(u(r))return S.test(r)?r:g(r).map(t=>(t=t.trim(),t?t.split(/\s+/).map(i=>{if(i=i.trim(),!i)return"";if(a(i))return`var(${i})`;if(i==="inset"||i==="none")return i;const n=m(i);if(x(n)){const f=C(i,e);return h(f)?Object.values(f).filter(l=>l.includes(": "+e))[0]:f}if(/^\d/.test(i)||i==="0"||i.includes("px")||i.slice(-2)==="em")return i;const s=p(i,"shadow");return s&&s.shadow?s.shadow:i}).join(" "):"")).join(", ")},W=(r,e)=>{const t=r.indexOf("(");if(t===-1)return r;const i=r.slice(0,t+1),n=r.slice(t+1,r.lastIndexOf(")")),s=")",l=g(n).map(c=>(c=c.trim(),c.split(/\s+/).map(o=>{if(!o||/^\d/.test(o)||o==="0"||L.has(o)||o==="transparent"||S.test(o))return o;const j=m(o);return x(j)?j:o}).join(" ")));return i+l.join(", ")+s},H=(r,e)=>{if(!u(r))return;const t=B();return g(r).map(i=>{const n=i.trim();if(a(n))return`var(${n})`;if(/^var\(/.test(n)||n.includes("url"))return n;if(t.gradient?.[n]){const s=C(n,e);if(u(s))return s;if(h(s)){for(const f in s)if(u(s[f]))return s[f]}return n}return n.includes("gradient")?W(n,e):n.includes("/")||n.startsWith("http")||n.includes(".")&&!F(n)?`url(${n})`:n}).join(", ")},J=r=>u(r)&&r.split(" ").map(e=>p(e,"gap").gap).join(" "),N=r=>{if(!u(r))return r;const e=B();return $(r).map(t=>T.test(t)?K(t,e.spacing):t).join(" ")},q=r=>{if(!u(r))return;const e=r.split(" ");return e.length?e.map(t=>a(t)?`var(${t})`:t.length<3||t.includes("ms")?E(t).timing||t:R(t)?R(t):t).join(" "):r},k=(r,e,t)=>{if(u(r))return r.split(",").map(i=>E(i).timing||i).join(",")},v=r=>{if(!u(r))return;const e=r.split(",");if(e.length)return e.map(q).join(",")};function D(r,e,t={},i={}){let n=O.call(this,e||t[r]);if(n==null)return;let s;if(u(n)){if(/^(?:env|var)\(/.test(n.trim()))return{[r]:n};if(n.includes("(")){const c=V(n);s=c[0],n=c[1]}const f=t.scaleBoxSize,l=I(r);!f&&l&&!i.ratio&&(n=_(n))}return i.ratio?d(t,r,n,s):p(n,r,void 0,s)}const rr=(r,e=null,t)=>D(r,e,t,{ratio:!0}),b=(r,e,t)=>u(r)?r.split(" ").map(i=>T.test(i)?d(e,t,i)[t]:i).join(" "):r,tr=(r,e,t,i="borderRadius")=>{if(u(r))return{[i]:r.split(" ").map(n=>{const s=G(n);return s!==void 0?b(s,e,t):d(e,t,n)[t]}).join(" ")}};export{W as resolveColorsInGradient,v as splitTransition,H as transformBackgroundImage,X as transformBorder,tr as transformBorderRadius,y as transformBoxShadow,k as transformDuration,N as transformGridTemplate,Z as transformShadow,D as transformSize,rr as transformSizeRatio,Y as transformTextStroke,q as transformTransition,J as transfromGap};
1
+ import{isString as u,isObject as B,exec as A}from"@symbo.ls/utils";import{getActiveConfig as C}from"../factory.js";import{getSpacingByKey as m,getColor as d,getShadow as G,getShapeByKey as I,getMediaColor as E,getTimingByKey as R,getTimingFunction as T,getSpacingBasedOnRatio as x,checkIfBoxSize as _,splitSpacedValue as z,resolveBorderValue as V}from"../system/index.js";import{getFnPrefixAndValue as $,isResolvedColor as S,isCSSVar as a,CSS_NATIVE_COLOR_REGEX as g,splitTopLevelCommas as j,splitTopLevelSpaces as p,parseColorToken as F,getSequenceValue as K}from"../utils/index.js";const L=new Set(["to","top","bottom","left","right","center","at","circle","ellipse","closest-side","farthest-side","closest-corner","farthest-corner"]),O=/^-?[A-Z][0-9]?$/,X=r=>V(r),Y=r=>{if(u(r))return g.test(r)?r:r.split(/\s+/).map(e=>{if(e=e.trim(),!e)return"";if(a(e))return`var(${e})`;if(/^\d/.test(e)||e.includes("px")||e==="0")return e;const t=d(e);return S(t)?t:e}).join(" ")},Z=(r,e)=>G(r,e),y=(r,e)=>{if(u(r))return g.test(r)?r:j(r).map(t=>(t=t.trim(),t?t.split(/\s+/).map(i=>{if(i=i.trim(),!i)return"";if(a(i))return`var(${i})`;if(i==="inset"||i==="none")return i;const n=d(i);if(S(n)){const f=E(i,e);return B(f)?Object.values(f).filter(l=>l.includes(": "+e))[0]:f}if(/^\d/.test(i)||i==="0"||i.includes("px")||i.slice(-2)==="em")return i;const s=m(i,"shadow");return s&&s.shadow?s.shadow:i}).join(" "):"")).join(", ")},W=(r,e)=>{const t=r.indexOf("(");if(t===-1)return r;const i=r.slice(0,t+1),n=r.slice(t+1,r.lastIndexOf(")")),s=")",l=j(n).map(c=>(c=c.trim(),c.split(/\s+/).map(o=>{if(!o||/^\d/.test(o)||o==="0"||L.has(o)||o==="transparent"||g.test(o))return o;const h=d(o);return S(h)?h:o}).join(" ")));return i+l.join(", ")+s},H=(r,e)=>{if(!u(r))return;const t=C();return j(r).map(i=>{const n=i.trim();if(a(n))return`var(${n})`;if(/^var\(/.test(n)||n.includes("url"))return n;if(t.gradient?.[n]){const s=E(n,e);if(u(s))return s;if(B(s)){for(const f in s)if(u(s[f]))return s[f]}return n}return n.includes("gradient")?W(n,e):n.includes("/")||n.startsWith("http")||n.includes(".")&&!F(n)?`url(${n})`:n}).join(", ")},J=r=>u(r)&&p(r).map(e=>m(e,"gap").gap).join(" "),N=r=>{if(!u(r))return r;const e=C();return p(r).map(t=>O.test(t)?K(t,e.spacing):t).join(" ")},q=r=>{if(!u(r))return;const e=r.split(" ");return e.length?e.map(t=>a(t)?`var(${t})`:t.length<3||t.includes("ms")?R(t).timing||t:T(t)?T(t):t).join(" "):r},k=(r,e,t)=>{if(u(r))return r.split(",").map(i=>R(i).timing||i).join(",")},v=r=>{if(!u(r))return;const e=r.split(",");if(e.length)return e.map(q).join(",")};function D(r,e,t={},i={}){let n=A.call(this,e||t[r]);if(n==null)return;let s;if(u(n)){if(/^(?:env|var)\(/.test(n.trim()))return{[r]:n};if(n.includes("(")){const c=$(n);s=c[0],n=c[1]}const f=t.scaleBoxSize,l=_(r);!f&&l&&!i.ratio&&(n=z(n))}return i.ratio?x(t,r,n,s):m(n,r,void 0,s)}const rr=(r,e=null,t)=>D(r,e,t,{ratio:!0}),b=(r,e,t)=>u(r)?p(r).map(i=>O.test(i)?x(e,t,i)[t]:i).join(" "):r,tr=(r,e,t,i="borderRadius")=>{if(u(r))return{[i]:p(r).map(n=>{const s=I(n);return s!==void 0?b(s,e,t):x(e,t,n)[t]}).join(" ")}};export{W as resolveColorsInGradient,v as splitTransition,H as transformBackgroundImage,X as transformBorder,tr as transformBorderRadius,y as transformBoxShadow,k as transformDuration,N as transformGridTemplate,Z as transformShadow,D as transformSize,rr as transformSizeRatio,Y as transformTextStroke,q as transformTransition,J as transfromGap};
@@ -1 +1 @@
1
- import{isString as V}from"@symbo.ls/utils";import{toDashCase as R}from"@symbo.ls/utils";import{isLoudDevRuntime as K}from"@symbo.ls/utils";import{getActiveConfig as M}from"../factory.js";import{isRawUnitValue as T,isScalingUnit as j}from"./unit.js";import{isCSSVar as z}from"./color.js";const S={"-6":"U","-5":"V","-4":"W","-3":"X","-2":"Y","-1":"Z",0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T"},y=(t,n)=>{const{key:r,variable:s,value:i,scaling:e,index:o,scalingVariable:p}=t;n.sequence[r]={key:r,decimal:~~(i*100)/100,val:~~i,scaling:e,index:o,scalingVariable:p,variable:s},n.scales[r]=e;const l=A.has(n.unit)?"rem":n.unit;n.vars[s]=e+l},D=t=>{if(!t.includes("("))return t;const n=t.split("(")[0],r=t.slice(t.indexOf("(")+1,t.lastIndexOf(")"));return[n,r]},A=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),L=(t,n)=>{const{base:r,type:s,unit:i}=n,e=A.has(i)?"rem":i,o=(j(e)?1:r)+e;if(t===0)return o;const l="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),d=`${l}-ratio`;if(t>0){const f=S[t-1];return`calc(var(${l}-${f}) * var(${d}))`}if(t<0){const f=S[t+1],g=Math.abs(t),h=Math.pow(O,2*g),m=S[g];return m?`max(calc(var(${l}-${f}) / var(${d})), calc(var(${l}-${m}) / ${h.toFixed(4)}))`:`calc(var(${l}-${f}) / var(${d}))`}},F=(t,n,r,s)=>{const{type:i}=s,o=t===2&&n.length===2?t+1:t,d=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(i&&i.replace(".","-"))}-sub-ratio-`;return`calc(var(${r}) * var(${d+o}))`},I=(t,n)=>{const s=(t*n-t)/1.618,i=t*n-s,e=t+s,o=(i+e)/2;return[i,o,e]},J=(t,n)=>I(t,n).map(r=>r/t),C=(t,n)=>{const{key:r,base:s,value:i,ratio:e,variable:o,index:p}=t,d=~~(i*e)-~~i;let f;const[g,h,m]=I(i,e);d>16?f=[g,h,m]:f=[g,m],f.forEach((u,c)=>{const $=~~(u/s*1e3)/1e3,v=o+(c+1),w=p+(c+1)/10,a=F(c+1,f,o,n),x={key:r+(c+1),variable:v,value:u,scaling:$,scalingVariable:a,index:w};y(x,n)})},O=1.618,N=(t,n,r)=>{if(t>=0)return n*Math.pow(r,t);const s=Math.abs(t),i=n*Math.pow(r,t),e=n*Math.pow(r,s)/Math.pow(O,2*s);return Math.max(i,e)},Q=t=>{const{type:n,base:r,ratio:s,range:i,subSequence:e}=t,o=Math.abs(i[0])+Math.abs(i[1]),l="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let d=0;d<=o;d++){const f=i[1]-d,g=S[f],h=N(f,r,s),m=~~(h/r*100)/100,u=l+g,c=L(f,t),$={key:g,variable:u,value:h,base:r,scaling:m,scalingVariable:c,ratio:s,index:f};y($,t),e&&C($,t)}return t},X=(t,n=0)=>{const{type:r,base:s,ratio:i,subSequence:e}=t,o=V(n)?n:S[n],p=V(n)?Object.entries(S).find(([,$])=>$===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const l={sequence:{},scales:{},vars:{},...t},d=s*Math.pow(i,p),f=~~(d/s*100)/100,m="--"+(t.varPrefix?t.varPrefix+"-":"")+(r&&r.replace(".","-"))+"-"+o,u=L(p,t),c={key:o,variable:m,value:d,base:s,scaling:f,scalingVariable:u,ratio:i,index:p};return y(c,l),e&&C(c,l),l},U=(t="A",n)=>{const r=M(),{unit:s}=r;if(V(t)&&z(t))return`var(${t})`;if(V(t)&&/^(?:env|var|calc|min|max|clamp)\(/.test(t.trim()))return t;if(V(t)){const a=r.sizes;if(a){const x=a[t]||a[t.toLowerCase()];if(x!==void 0)return t.slice(0,1)==="-"?`calc(${x} * -1)`:x}}const{sequence:i,unit:e=s.default,useVariable:o}=n,p=/^-?[a-zA-Z]/i,l=p.test(t);if(T(t)||!l||["none","auto","max-content","min-content","fit-content","inherit","initial","unset","revert","revert-layer"].includes(t))return t;const h=`--${n.varPrefix?n.varPrefix+"-":""}${R(n.type.replace(".","-"))}-`,m=t.toUpperCase(),u=m.slice(0,1)==="-"?"-":"";let c=u?m.slice(1):m,$="";c.includes("_")&&($="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const v=a=>p.test(a)?`var(${h}${a}${$})`:a;if(c.includes("+")){const[a,x]=c.split("+"),b=`${v(a)} + ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}else if(c.includes("*")){const[a,x]=c.split("*"),b=`${v(a)} * ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}else if(c.includes("-")){const[a,x]=c.split("-"),b=`${v(a)} - ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}if(!i[c]&&c.length===2&&(r.verbose&&console.warn(c,"- value is not found because `subSequence` is set to false"),c=c.slice(0,1)),o||r.useVariable){const a=`var(${h}${c}${$})`;return u?`calc(${a} * -1)`:a}const w=i?i[c]:null;if(!w){if(console.warn("can't find",i,c),K())throw new Error(`[smbls] Unresolvable design-system token "${t}"`+(n.type?` for sequence "${n.type}"`:"")+" \u2014 not a registered `sizes` name and not a valid spacing/typography/timing sequence letter. The CSS property using it would silently be dropped in production. Register the token in `designSystem/sizes.js` (or the relevant sequence family) or fix the typo.");return}return e==="ms"||e==="s"?u+w.val+e:u+w.scaling+e},_=(t,n)=>{if(!["+","-","*","/",","].filter(e=>t.includes(e+" ")).length)return t;const s=/(\s+-\s+|\s*[+*/,]\s*)/;return t.split(s).map(e=>{const o=e.trim();return!o||["+","-","*","/",","].includes(o)?e:U(o,n)}).join("")},Y=(t,n,r,s)=>{if(typeof t!="string")return M().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!s&&t.includes("(")){if(/^(?:env|var)\(/.test(t.trim()))return{[n]:t};const e=D(t);s=e[0],t=e[1]}return["+","-","*","/",","].filter(e=>t.includes(e+" ")).length?t=_(t,r):t=U(t,r),{[n]:s?`${s}(${t})`:t}},E=(t,n)=>S[t-n],q=t=>{const{h1Matches:n,sequence:r}=t;return new Array(6).fill(null).map((s,i)=>{const e=E(n,i);return r[e]})};export{E as findHeadingLetter,q as findHeadings,Q as generateSequence,X as generateSequencePosition,C as generateSubSequence,D as getFnPrefixAndValue,U as getSequenceValue,_ as getSequenceValueBySymbols,Y as getSequenceValuePropertyPair,J as getSubratio,I as getSubratioDifference,S as numToLetterMap,L as setScalingVar,F as setSubScalingVar};
1
+ import{isString as V}from"@symbo.ls/utils";import{toDashCase as T}from"@symbo.ls/utils";import{isLoudDevRuntime as _}from"@symbo.ls/utils";import{getActiveConfig as A}from"../factory.js";import{isRawUnitValue as N,isScalingUnit as E}from"./unit.js";import{isCSSVar as j}from"./color.js";const S={"-6":"U","-5":"V","-4":"W","-3":"X","-2":"Y","-1":"Z",0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T"},y=(t,n)=>{const{key:e,variable:r,value:s,scaling:i,index:o,scalingVariable:l}=t;n.sequence[e]={key:e,decimal:~~(s*100)/100,val:~~s,scaling:i,index:o,scalingVariable:l,variable:r},n.scales[e]=i;const a=L.has(n.unit)?"rem":n.unit;n.vars[r]=i+a},z=t=>{if(!t.includes("("))return t;const n=t.trim(),e=n.indexOf("("),r=n.slice(0,e);let s=0,i=-1;for(let o=e;o<n.length;o++){const l=n[o];if(l==="(")s++;else if(l===")"&&(s--,s===0)){i=o;break}}return i===-1||/\s/.test(r)||n.slice(i+1).trim()!==""?[void 0,t]:[r,n.slice(e+1,i)]},M="\0",D=(t,n)=>{let e="",r=0,s="";for(const i of t){if(r===0&&i!=="("){e+=i;continue}s+=i,i==="("?r++:i===")"&&(r--,r===0&&(e+=M+n.length+M,n.push(s),s=""))}return e+s},F=(t,n)=>t.indexOf(M)===-1?t:t.replace(/\u0000(\d+)\u0000/g,(e,r)=>n[Number(r)]),G=/^(calc|min|max|clamp)\((.*)\)$/,k=(t,n)=>{const e=G.exec(t);return e?`${e[1]}(${K(e[2],n)})`:t.indexOf("(")!==-1?t:U(t,n)},L=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),C=(t,n)=>{const{base:e,type:r,unit:s}=n,i=L.has(s)?"rem":s,o=(E(i)?1:e)+i;if(t===0)return o;const a="--"+(n.varPrefix?n.varPrefix+"-":"")+(r&&r.replace(".","-")),d=`${a}-ratio`;if(t>0){const u=S[t-1];return`calc(var(${a}-${u}) * var(${d}))`}if(t<0){const u=S[t+1],g=Math.abs(t),h=Math.pow(I,2*g),m=S[g];return m?`max(calc(var(${a}-${u}) / var(${d})), calc(var(${a}-${m}) / ${h.toFixed(4)}))`:`calc(var(${a}-${u}) / var(${d}))`}},H=(t,n,e,r)=>{const{type:s}=r,o=t===2&&n.length===2?t+1:t,d=`${"--"+(r.varPrefix?r.varPrefix+"-":"")+(s&&s.replace(".","-"))}-sub-ratio-`;return`calc(var(${e}) * var(${d+o}))`},O=(t,n)=>{const r=(t*n-t)/1.618,s=t*n-r,i=t+r,o=(s+i)/2;return[s,o,i]},q=(t,n)=>O(t,n).map(e=>e/t),R=(t,n)=>{const{key:e,base:r,value:s,ratio:i,variable:o,index:l}=t,d=~~(s*i)-~~s;let u;const[g,h,m]=O(s,i);d>16?u=[g,h,m]:u=[g,m],u.forEach((p,c)=>{const $=~~(p/r*1e3)/1e3,b=o+(c+1),w=l+(c+1)/10,f=H(c+1,u,o,n),x={key:e+(c+1),variable:b,value:p,scaling:$,scalingVariable:f,index:w};y(x,n)})},I=1.618,W=(t,n,e)=>{if(t>=0)return n*Math.pow(e,t);const r=Math.abs(t),s=n*Math.pow(e,t),i=n*Math.pow(e,r)/Math.pow(I,2*r);return Math.max(s,i)},tt=t=>{const{type:n,base:e,ratio:r,range:s,subSequence:i}=t,o=Math.abs(s[0])+Math.abs(s[1]),a="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let d=0;d<=o;d++){const u=s[1]-d,g=S[u],h=W(u,e,r),m=~~(h/e*100)/100,p=a+g,c=C(u,t),$={key:g,variable:p,value:h,base:e,scaling:m,scalingVariable:c,ratio:r,index:u};y($,t),i&&R($,t)}return t},nt=(t,n=0)=>{const{type:e,base:r,ratio:s,subSequence:i}=t,o=V(n)?n:S[n],l=V(n)?Object.entries(S).find(([,$])=>$===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const a={sequence:{},scales:{},vars:{},...t},d=r*Math.pow(s,l),u=~~(d/r*100)/100,m="--"+(t.varPrefix?t.varPrefix+"-":"")+(e&&e.replace(".","-"))+"-"+o,p=C(l,t),c={key:o,variable:m,value:d,base:r,scaling:u,scalingVariable:p,ratio:s,index:l};return y(c,a),i&&R(c,a),a},U=(t="A",n)=>{const e=A(),{unit:r}=e;if(V(t)&&j(t))return`var(${t})`;if(V(t)&&/^(?:env|var|calc|min|max|clamp)\(/.test(t.trim()))return t;if(V(t)){const f=e.sizes;if(f){const x=f[t]||f[t.toLowerCase()];if(x!==void 0)return t.slice(0,1)==="-"?`calc(${x} * -1)`:x}}const{sequence:s,unit:i=r.default,useVariable:o}=n,l=/^-?[a-zA-Z]/i,a=l.test(t);if(N(t)||!a||["none","auto","max-content","min-content","fit-content","inherit","initial","unset","revert","revert-layer"].includes(t))return t;const h=`--${n.varPrefix?n.varPrefix+"-":""}${T(n.type.replace(".","-"))}-`,m=t.toUpperCase(),p=m.slice(0,1)==="-"?"-":"";let c=p?m.slice(1):m,$="";c.includes("_")&&($="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const b=f=>l.test(f)?`var(${h}${f}${$})`:f;if(c.includes("+")){const[f,x]=c.split("+"),v=`${b(f)} + ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("*")){const[f,x]=c.split("*"),v=`${b(f)} * ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("-")){const[f,x]=c.split("-"),v=`${b(f)} - ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}if(!s[c]&&c.length===2&&(e.verbose&&console.warn(c,"- value is not found because `subSequence` is set to false"),c=c.slice(0,1)),o||e.useVariable){const f=`var(${h}${c}${$})`;return p?`calc(${f} * -1)`:f}const w=s?s[c]:null;if(!w){if(console.warn("can't find",s,c),_())throw new Error(`[smbls] Unresolvable design-system token "${t}"`+(n.type?` for sequence "${n.type}"`:"")+" \u2014 not a registered `sizes` name and not a valid spacing/typography/timing sequence letter. The CSS property using it would silently be dropped in production. Register the token in `designSystem/sizes.js` (or the relevant sequence family) or fix the typo.");return}return i==="ms"||i==="s"?p+w.val+i:p+w.scaling+i},K=(t,n)=>{if(!["+","-","*","/",","].filter(o=>t.includes(o+" ")).length)return t;const r=/(\s+-\s+|\s*[+*/,]\s*)/,s=[];return D(t,s).split(r).map(o=>{const l=F(o,s),a=l.trim();return!a||["+","-","*","/",","].includes(a)?l:k(a,n)}).join("")},et=(t,n,e,r)=>{if(typeof t!="string")return A().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!r&&t.includes("(")){if(/^(?:env|var)\(/.test(t.trim()))return{[n]:t};const i=z(t);r=i[0],t=i[1]}return["+","-","*","/",","].filter(i=>t.includes(i+" ")).length?t=K(t,e):t=U(t,e),{[n]:r?`${r}(${t})`:t}},B=(t,n)=>S[t-n],rt=t=>{const{h1Matches:n,sequence:e}=t;return new Array(6).fill(null).map((r,s)=>{const i=B(n,s);return e[i]})};export{B as findHeadingLetter,rt as findHeadings,tt as generateSequence,nt as generateSequencePosition,R as generateSubSequence,z as getFnPrefixAndValue,U as getSequenceValue,K as getSequenceValueBySymbols,et as getSequenceValuePropertyPair,q as getSubratio,O as getSubratioDifference,S as numToLetterMap,C as setScalingVar,H as setSubScalingVar};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/scratch",
3
3
  "description": "Φ / CSS framework and methodology.",
4
4
  "author": "symbo.ls",
5
- "version": "3.14.781",
5
+ "version": "3.14.783",
6
6
  "files": [
7
7
  "dist",
8
8
  "*.js",