@theme-registry/refract-css 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/lowering.d.ts +2 -0
- package/package.json +4 -4
package/dist/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@theme-registry/refract"),t=require("@theme-registry/refract/color-math"),o=require("@theme-registry/refract/adapter-kit");const n=e=>null==e?"":String(e),r=e=>void 0!==e.unit?`${e.value}${e.unit}`:n(e.value),s=(e,t,o,n)=>{var r;if(!n){const n=e[t];return null!==(r=null==n?void 0:n[o])&&void 0!==r?r:""}const s={orientation:n};return"min"===o?e.min(t,s):"max"===o?e.max(t,s):e.exact(t,s)},i=(e,t)=>{const o=e=>e.replace(/^@media\s*/,"");return`@media ${o(e)} and ${o(t)}`},a=(e,t,o,n)=>{var r,a;const c=new Map,d=(e,t,o)=>{const n=`${e}||${t}`,r=c.get(n);r?Object.assign(r.variables,o):c.set(n,{media:e,selector:t,variables:{...o}})};for(const[c,f]of Object.entries(e))for(const e of null!==(r=f.responsive)&&void 0!==r?r:[]){const r=s(t,e.breakpoint,null!==(a=e.query)&&void 0!==a?a:"exact",e.orientation);if(!r)continue;const f=l(c,e,o,n);if(!Object.keys(f).length)continue;const v=e.mode;if(v){d(r,`:root[data-theme="${v}"]`,f);const e=u[v];e&&d(i(r,e),":root",f)}else d(r,":root",f)}return Array.from(c.values(),({media:e,selector:t,variables:o})=>({kind:"variables",selector:t,media:e,variables:o}))},l=(e,t,o,n)=>{var r;const{ref:s,target:i}=t,a={};void 0!==s&&(a[o(e,i)]=`var(${o(e,s)})`);for(const[s,l]of Object.entries(null!==(r=t.overrides)&&void 0!==r?r:{})){a["base"===s?o(e,i):o(e,i,s)]=n(l)}return a},c=e=>Object.keys(e).length?[{kind:"variables",selector:":root",variables:e}]:[],u={dark:"@media (prefers-color-scheme: dark)",light:"@media (prefers-color-scheme: light)"},d=(e,t)=>{let o=e.get(t);return o||(o={},e.set(t,o)),o},f=e=>{const t=[];for(const[o,n]of e){if(!Object.keys(n).length)continue;const e=u[o];e&&t.push({kind:"variables",selector:":root",media:e,variables:{...n}}),t.push({kind:"variables",selector:`:root[data-theme="${o}"]`,variables:{...n}})}return t},v=(e,t,o,n,r)=>e([t,o,n,r].filter(Boolean).join(".")),p=(e,t,o)=>{var n;const r=new Map;for(const[s,i]of Object.entries(e))if(i.modes)for(const e of i.modes){if(void 0===e.mode)continue;const i=d(r,e.mode),a=e.target,l=null!==(n=e.overrides)&&void 0!==n?n:{},c=l.base;c&&null!=c.value&&(i[v(t,"colors",s,a)]=o(c.value));for(const[e,n]of Object.entries(l))"base"!==e&&n&&null!=n.value&&""!==n.value&&(i[v(t,"colors",s,a,e)]=o(n.value))}return f(r)},m=(e,t,o)=>{var n,r,s,i;const a={};for(const[l,c]of Object.entries(t)){a[`${e}.${l}`]=null!==(n=c.base.external)&&void 0!==n?n:o(`${e}.${l}`);for(const[t,n]of Object.entries(null!==(r=c.extras)&&void 0!==r?r:{}))null!=(null==n?void 0:n.value)&&""!==n.value&&(a[`${e}.${l}.${t}`]=o(`${e}.${l}.${t}`));for(const[t,n]of Object.entries(null!==(s=c.variants)&&void 0!==s?s:{})){a[`${e}.${l}.${t}`]=o(`${e}.${l}.${t}`);for(const r of Object.keys(null!==(i=n.extras)&&void 0!==i?i:{}))a[`${e}.${l}.${t}.${r}`]=o(`${e}.${l}.${t}.${r}`)}}return a},b=(e,t,o,n)=>{var s,i,l;const{varName:u}=o,d=(t,o,n)=>v(u,e,t,o,n),f={};for(const[e,o]of Object.entries(t))if(void 0===o.base.external){f[d(e)]=n.formatRoot(e,o.base);for(const[t,r]of Object.entries(null!==(s=o.variants)&&void 0!==s?s:{})){f[d(e,t)]=n.formatRoot(e,r.base);for(const[o,s]of Object.entries(null!==(i=r.extras)&&void 0!==i?i:{}))f[d(e,t,o)]=n.formatRoot(e,s)}}const p=null!==(l=n.formatResponsive)&&void 0!==l?l:r;return[...c(f),...a(t,o.media,d,p),...h(t,(e,t)=>d(e,t),n.formatRoot)]},h=(e,t,o)=>{var n;const r=new Map;for(const[s,i]of Object.entries(e))if(i.modes)for(const e of i.modes){if(void 0===e.mode)continue;const i=null===(n=e.overrides)||void 0===n?void 0:n.base;null==i||null==i.struct&&null==i.value||(d(r,e.mode)[t(s,e.target)]=o(s,i))}return f(r)},y=(e,t,o)=>m(e,t,o),g=(e,t)=>{const o=`0${(e=>{for(const t of[e.offsetX,e.offsetY,e.blur,e.spread])if(void 0!==t&&"number"!=typeof t)return t.unit;return"px"})(e)}`,n=e=>void 0===e?o:(e=>"number"==typeof e?String(e):`${e.value}${e.unit}`)(e),r=[];return e.inset&&r.push("inset"),r.push(n(e.offsetX),n(e.offsetY)),null!=e.spread?r.push(n(e.blur),n(e.spread)):null!=e.blur&&r.push(n(e.blur)),e.color&&r.push(((e,t)=>{const o=t[e];return o?`var(${o})`:e})(e.color,t)),r.join(" ")},$=(e,t)=>e.map(e=>g(e,t)).join(", "),k=e=>{var t;const o=[e.property];return null==e.duration&&null==e.delay||o.push(`${null!==(t=e.duration)&&void 0!==t?t:0}ms`),e.timingFunction&&o.push(e.timingFunction),null!=e.delay&&o.push(`${e.delay}ms`),o.join(" ")},j=e=>e.map(k).join(", "),O=(e,t)=>{var o;const n=null!==(o=t.pathToVar)&&void 0!==o?o:{};return b("effects",e,t,{formatRoot:(e,t)=>t.struct?((e,t,o)=>"transitions"===e?j(t):$(t,o))(e,t.struct,n):r(t),formatResponsive:e=>e.struct?((e,t)=>{const o=e[0];return o&&"object"==typeof o&&"property"in o?j(e):$(e,t)})(e.struct,n):r(e)})},N=new Set(["duration","delay"]),x=(e,t)=>b("animation",e,t,{formatRoot:(e,t)=>"number"==typeof t.value&&N.has(e)?`${t.value}ms`:n(t.value),formatResponsive:e=>{return"number"==typeof(t=e.value)?`${t}ms`:n(t);var t}}),w=e=>e.includes("--"),S=e=>{const t={},o={};for(const[n,r]of Object.entries(e))w(n)?o[n]=r:t[n]=r;return{regular:t,config:o}},E=(e,t)=>b("layout",e,t,{formatRoot:(e,t)=>r(t)}),R=["spacing","gutters","aspectRatio"],T=(e,t)=>{const o=new Map;for(const[n,r]of Object.entries(e)){const e=n.split("--")[0];let s=o.get(e);s||(s={},o.set(e,s)),s[t.varName(`layout.${n}`)]=String(A(r.base,t.pathToVar))}return Array.from(o.values(),e=>({kind:"variables",selector:":root",variables:e}))},V=(e,t)=>{var o,n;const{media:r,selectorBuilder:i,pathToVar:a}=t,l=Object.entries(e),c={};for(const[e]of l)c[e]=i(e);const u=[];for(let e=l.length-1;e>=0;e--){const[t,o]=l[e],n=q(o.declarations,a);n.length&&u.push({kind:"rule",selector:i(t),declarations:n})}const d=[];for(const[e,t]of l)for(const l of t.overrides){if(void 0!==l.state||!l.breakpoint)continue;const t=s(r,l.breakpoint,null!==(o=l.query)&&void 0!==o?o:"exact",l.orientation);if(!t)continue;const c=q(null!==(n=l.declarations)&&void 0!==n?n:{},a);c.length&&d.push({kind:"rule",selector:i(e),media:t,declarations:c})}return{nodes:[...u,...d],variants:c}},A=(e,t)=>{var o;if(void 0===e.ref)return e.value;const n=`var(${null!==(o=t[e.ref])&&void 0!==o?o:e.ref})`;return e.wrap?`${e.wrap}(${n})`:n},q=(e,t)=>Object.entries(e).map(([e,o])=>({property:e,value:A(o,t)})),B=(e,t)=>e.split(",").map(e=>`${e.trim()}${t}`).join(","),C=(e,t)=>{const o=e.selector;if(!o)return[];const n=[];for(const[o,r]of Object.entries(e.declarations)){if(void 0===r.ref){n.push({property:o,value:r.value});continue}const e=t[r.ref];e&&n.push({property:o,value:`var(${e})`})}return n.length?[{kind:"rule",selector:`:where(${o})`,declarations:n}]:[]},M=(e,t,o,n,r,i,a)=>{var l,c,u,d,f;const v=q(o,r);v.length&&e.push({kind:"rule",selector:t,declarations:v});for(const o of n){if(void 0!==o.state||void 0!==o.container||!o.breakpoint)continue;const n=s(i,o.breakpoint,null!==(l=o.query)&&void 0!==l?l:"exact",o.orientation);if(!n)continue;const a=q(null!==(c=o.declarations)&&void 0!==c?c:{},r);a.length&&e.push({kind:"rule",selector:t,media:n,declarations:a})}const p=n.filter(e=>void 0!==e.state);for(const o of I(p)){const n=_[o.state];if(!n)continue;const a=q(null!==(u=o.declarations)&&void 0!==u?u:{},r);if(!a.length)continue;const l={kind:"rule",selector:B(t,n),declarations:a};if(o.breakpoint){const e=s(i,o.breakpoint,null!==(d=o.query)&&void 0!==d?d:"exact",o.orientation);e&&(l.media=e)}e.push(l)}for(const o of n){if(!o.container)continue;const n=P(o,a);if(!n)continue;const s=q(null!==(f=o.declarations)&&void 0!==f?f:{},r);s.length&&e.push({kind:"rule",selector:t,media:n,declarations:s})}},_={link:":link",visited:":visited",hover:":hover",focus:":focus",active:":active",disabled:"[disabled]",pressed:"[aria-pressed]"},F=Object.keys(_),X=F.reduce((e,t,o)=>(e[t]=o,e),{}),I=e=>[...e].map((e,t)=>({override:e,index:t})).sort((e,t)=>{var o,n;const r=null!==(o=X[e.override.state])&&void 0!==o?o:Number.MAX_SAFE_INTEGER,s=null!==(n=X[t.override.state])&&void 0!==n?n:Number.MAX_SAFE_INTEGER;if(r!==s)return r-s;const i=e.override.breakpoint?1:0,a=t.override.breakpoint?1:0;return i!==a?i-a:e.index-t.index}).map(({override:e})=>e),G=(e,t,o,n)=>{var r,i;const a=e.overrides.filter(e=>void 0!==e.state&&!e.target);if(!a.length)return[];const l=[];for(const e of I(a)){const a=_[e.state];if(!a)continue;const c=q(null!==(r=e.declarations)&&void 0!==r?r:{},n);if(!c.length)continue;const u={kind:"rule",selector:`${t}${a}`,declarations:c};if(e.breakpoint){const t=s(o,e.breakpoint,null!==(i=e.query)&&void 0!==i?i:"exact",e.orientation);t&&(u.media=t)}l.push(u)}return l},P=(e,t)=>{var o;if(!e.container||!e.size)return"";const n=null==t?void 0:t[e.container];if(!n)return"";return n[null!==(o=e.query)&&void 0!==o?o:"min"](e.size)},W=(e,t)=>{var o,n,r,i,a;const{media:l,selectorBuilder:c,pathToVar:u}=t,d=[],f={};for(const[t,r]of Object.entries(e)){const e=c(t);f[t]=e;const i=q(r.declarations,u);i.length&&d.push({kind:"rule",selector:e,declarations:i});for(const t of r.overrides){if(void 0!==t.state||!t.breakpoint)continue;const r=s(l,t.breakpoint,null!==(o=t.query)&&void 0!==o?o:"exact",t.orientation);if(!r)continue;const i=q(null!==(n=t.declarations)&&void 0!==n?n:{},u);i.length&&d.push({kind:"rule",selector:e,media:r,declarations:i})}}const v=[];for(const[t,o]of Object.entries(e))v.push(...G(o,c(t),l,u));const p=[];for(const[t,o]of Object.entries(e))for(const e of o.overrides){if(void 0===e.state||!e.target)continue;const o=_[e.state];if(!o)continue;const n=q(null!==(r=e.declarations)&&void 0!==r?r:{},u);if(!n.length)continue;const a={kind:"rule",selector:`${c(`${t}-${e.target}`)}${o}`,declarations:n};if(e.breakpoint){const t=s(l,e.breakpoint,null!==(i=e.query)&&void 0!==i?i:"exact",e.orientation);t&&(a.media=t)}p.push(a)}const m=[];for(const[o,n]of Object.entries(e)){const e=c(o);for(const o of n.overrides){if(!o.container)continue;const n=P(o,t.containers);if(!n)continue;const r=q(null!==(a=o.declarations)&&void 0!==a?a:{},u);r.length&&m.push({kind:"rule",selector:e,media:n,declarations:r})}}return{nodes:[...d,...v,...m,...p],variants:f}},z="animation.keyframes.",Y=["animation-duration","animation-timing-function","animation-delay","animation-iteration-count","animation-direction","animation-fill-mode","animation-play-state","animation-name"],H=(e,t,o)=>{const r=void 0!==e.ref?e.ref.startsWith(z)?e.ref.slice(20):e.ref:n(e.value);if(!t.has(r))throw new Error(`css adapter: animation recipe '${o}' references unknown keyframe '${r}' — no matching entry in animation.keyframes`);return r},L=(e,t)=>{var o,n,r,i,a;const{media:l,selectorBuilder:c,pathToVar:u,keyframeNames:d}=t,f=[],v={},p=(e,t,o)=>{const n=((e,t,o,n)=>{const r=[];for(const s of Y){const i=e[s];i&&r.push("animation-name"===s?H(i,o,n):String(A(i,t)))}return r.join(" ")})(t,u,d,e);if(!n)return;const r={kind:"rule",selector:e,declarations:[{property:"animation",value:n}]};return o&&(r.media=o),r};for(const[t,r]of Object.entries(e)){const e=c(t);v[t]=e;const i=p(e,r.declarations);i&&f.push(i);for(const t of r.overrides){if(void 0!==t.state||!t.breakpoint)continue;const r=s(l,t.breakpoint,null!==(o=t.query)&&void 0!==o?o:"exact",t.orientation);if(!r)continue;const i=p(e,null!==(n=t.declarations)&&void 0!==n?n:{},r);i&&f.push(i)}}const m=[];for(const[t,o]of Object.entries(e)){const e=c(t),n=o.overrides.filter(e=>void 0!==e.state);for(const t of I(n)){const o=_[t.state];if(!o)continue;let n;t.breakpoint&&(n=s(l,t.breakpoint,null!==(r=t.query)&&void 0!==r?r:"exact",t.orientation)||void 0);const a=p(`${e}${o}`,null!==(i=t.declarations)&&void 0!==i?i:{},n);a&&m.push(a)}}const b=[];for(const[o,n]of Object.entries(e)){const e=c(o);for(const o of n.overrides){if(!o.container)continue;const n=P(o,t.containers);if(!n)continue;const r=p(e,null!==(a=o.declarations)&&void 0!==a?a:{},n);r&&b.push(r)}}return{nodes:[...f,...m,...b],variants:v}},U=(e,t)=>{var o,n;const{selector:r,media:i,pathToVar:a,containers:l}=t,c=[],u=q(e.base,a);u.length&&c.push({kind:"rule",selector:r,declarations:u});for(const t of(d=Object.keys(e.states),[...d].sort((e,t)=>{var o,n;return(null!==(o=X[e])&&void 0!==o?o:Number.MAX_SAFE_INTEGER)-(null!==(n=X[t])&&void 0!==n?n:Number.MAX_SAFE_INTEGER)}))){const o=_[t];if(!o)continue;const n=q(e.states[t],a);n.length&&c.push({kind:"rule",selector:`${r}${o}`,declarations:n})}var d;for(const t of e.responsive){const e=t.container?P(t,l):s(i,t.breakpoint,null!==(o=t.query)&&void 0!==o?o:"exact",t.orientation);if(!e)continue;const u=q(t.declarations,a);if(!u.length)continue;const d=t.state&&null!==(n=_[t.state])&&void 0!==n?n:"";c.push({kind:"rule",selector:`${r}${d}`,media:e,declarations:u})}return c},D=(e,t={})=>{var o,n;const r=null!==(o=t.indent)&&void 0!==o?o:" ",s=null!==(n=t.newline)&&void 0!==n?n:"\n",i=[],a=J(e);for(const e of a){if("keyframes"===e.kind){const t=Z(e,r,s);if(!t)continue;i.push(`@keyframes ${e.name} {${s}${t}${s}}`);continue}const t="variables"===e.kind?K(e.variables,r,s):Q(e.declarations,r,s);if(!t)continue;const o=`${e.selector} {${s}${t}${s}}`;e.media?i.push(`${e.media} {${s}${ee(o,r,s)}${s}}`):i.push(o)}return i.filter(Boolean).join(`${s}${s}`)},J=e=>{const t=e=>{var t;return"variables"===e.kind?`var:${null!==(t=e.media)&&void 0!==t?t:""}:${e.selector}`:""},o=[];for(const n of e){if("variables"!==n.kind){o.push(n);continue}const e=t(n),r=o[o.length-1];r&&"variables"===r.kind&&t(r)===e?r.variables={...r.variables,...n.variables}:o.push({kind:"variables",selector:n.selector,media:n.media,variables:{...n.variables}})}return o},K=(e,t,o)=>{const n=Object.entries(e);return n.length?n.map(([e,o])=>`${t}${e}: ${o};`).join(o):""},Q=(e,t,o)=>e.length?e.map(({property:e,value:o})=>`${t}${e}: ${o};`).join(o):"",Z=(e,t,o)=>e.steps.map(e=>{if(!e.declarations.length)return"";const n=e.declarations.map(({property:e,value:o})=>`${t}${t}${e}: ${o};`).join(o);return`${t}${e.stop} {${o}${n}${o}${t}}`}).filter(Boolean).join(o),ee=(e,t,o)=>e.split(o).map(e=>e.length?`${t}${e}`:e).join(o),te=e=>{const t=[],o=[];for(const n of e)"variables"===n.kind?t.push(n):o.push(n);return{variables:t,rules:o}},oe=e=>D(te(e).variables),ne=e=>D(te(e).rules),re=/var\((--[^)]+)\)/,se=e=>{const t=new Map;for(const o of e)if("variables"===o.kind)for(const[e,n]of Object.entries(o.variables))re.test(n)||t.set(e,n);for(const o of e)if("variables"===o.kind)for(const[e,n]of Object.entries(o.variables)){if(t.has(e))continue;const o=n.match(re);if(o){const n=t.get(o[1]);n&&t.set(e,n)}}return t},ie=e=>{const t=se(e),o=e=>{if("string"!=typeof e.value)return;const o=e.value.match(re);if(!o)return;e.ref=o[1];const n=t.get(o[1]);void 0!==n&&(e.resolved=n)};for(const t of e)if("keyframes"!==t.kind){if("rule"===t.kind)for(const e of t.declarations)o(e)}else for(const e of t.steps)for(const t of e.declarations)o(t)};exports.createCssAdapter=(n={})=>{const s={name:"css",version:1,allowedStates:F,bind(s,i){var l,u,d,f,h,g,$,k,j,N,w,q,_,F,X,I,G,P,z;const Y=i.media,H=null!==(l=n.inline)&&void 0!==l&&l,J=o.resolveNaming({prefix:n.prefix,classPrefix:n.classPrefix}),K=o.createNamer(J,n.naming),Q=K.variableName,Z=null!==(u=n.colorFormat)&&void 0!==u?u:"rgb",ee=e=>{const o=null==e?"":String(e);return o&&"rgb"!==Z?"hex"===Z?t.toHexColor(o):t.toOklchColor(o):o},te={},re={},ae=(e,t,o)=>{const n=[],r={};for(const[s,a]of Object.entries(t)){const{nodes:t,variants:l}=W(a,{media:Y,selectorBuilder:t=>`.${K.className("recipe",e,s,t)}`,pathToVar:o,containers:i.containers});n.push(...t),r[s]=l}return{recipeNodes:n,selectors:r}},le=s.subsystems.colors;if(le){const e=null!==(d=le.properties)&&void 0!==d?d:{},t=((e,t)=>m("colors",e,t))(e,Q);Object.assign(re,t);const o=((e,t)=>{var o,n,r;const{varName:s,formatColor:i}=t,l=(e,t,o)=>v(s,"colors",e,t,o),u={};for(const[t,s]of Object.entries(e)){if(void 0!==s.base.external)continue;u[l(t)]=i(s.base.value);const e=null===(o=s.extras)||void 0===o?void 0:o.text;e&&null!=e.value&&""!==e.value&&(u[l(t,void 0,"text")]=i(e.value));for(const[e,o]of Object.entries(null!==(n=s.variants)&&void 0!==n?n:{})){u[l(t,e)]=i(o.base.value);for(const[n,s]of Object.entries(null!==(r=o.extras)&&void 0!==r?r:{}))null!=s.value&&""!==s.value&&(u[l(t,e,n)]=i(s.value))}}return[...c(u),...a(e,t.media,l,e=>i(e.value)),...p(e,s,i)]})(e,{varName:Q,media:Y,formatColor:ee}),{recipeNodes:n,selectors:r}=ae("colors",null!==(f=le.ruleSets)&&void 0!==f?f:{},t);te.colors={variableNodes:o,recipeNodes:n,selectors:r}}const ce=s.subsystems.typography;if(ce){const e=null!==(h=ce.properties)&&void 0!==h?h:{},t=((e,t)=>y("typography",e,t))(e,Q);Object.assign(re,t);const o=((e,t)=>b("typography",e,t,{formatRoot:(e,t)=>r(t)}))(e,{varName:Q,media:Y}),{recipeNodes:n,selectors:s}=ae("typography",null!==(g=ce.ruleSets)&&void 0!==g?g:{},t);te.typography={variableNodes:o,recipeNodes:n,selectors:s}}const ue=s.subsystems.effects;if(ue){const e=null!==($=ue.properties)&&void 0!==$?$:{},t=((e,t)=>y("effects",e,t))(e,Q);Object.assign(re,t);const o=O(e,{varName:Q,media:Y,pathToVar:re}),{recipeNodes:n,selectors:r}=ae("effects",null!==(k=ue.ruleSets)&&void 0!==k?k:{},t);te.effects={variableNodes:o,recipeNodes:n,selectors:r}}const de=s.subsystems.borders;if(de){const e=null!==(j=de.properties)&&void 0!==j?j:{},t=((e,t)=>y("borders",e,t))(e,Q);Object.assign(re,t);const o=((e,t)=>b("borders",e,t,{formatRoot:(e,t)=>r(t)}))(e,{varName:Q,media:Y}),{recipeNodes:n,selectors:s}=ae("borders",null!==(N=de.ruleSets)&&void 0!==N?N:{},re);te.borders={variableNodes:o,recipeNodes:n,selectors:s}}const fe=s.subsystems.layout;if(fe){const e=null!==(w=fe.properties)&&void 0!==w?w:{},t=((e,t)=>{const{regular:o,config:n}=S(e),r=y("layout",o,t);for(const e of R){const o=`layout.${e}`;o in r||(r[o]=t(o))}for(const e of Object.keys(n))r[`layout.${e}`]=t(`layout.${e}`);return r})(e,Q);Object.assign(re,t);const{regular:o,config:n}=S(e),r=[...E(o,{varName:Q,media:Y}),...T(n,{varName:Q,pathToVar:t})],s=[],a={};for(const[e,o]of Object.entries(null!==(q=fe.ruleSets)&&void 0!==q?q:{})){const n=t=>`.${K.className("recipe","layout",e,t)}`,r="container"===e?V:W,{nodes:l,variants:c}=r(o,{media:Y,selectorBuilder:n,pathToVar:t,containers:i.containers});s.push(...l),a[e]=c}te.layout={variableNodes:r,recipeNodes:s,selectors:a}}const ve=s.subsystems.animation;if(ve){const e=null!==(_=ve.properties)&&void 0!==_?_:{},t=((e,t)=>y("animation",e,t))(e,Q);Object.assign(re,t);const o=x(e,{varName:Q,media:Y}),n=null!==(F=ve.keyframes)&&void 0!==F?F:{},r=((e,t)=>{const o=[];for(const[n,r]of Object.entries(e)){const e=r.steps.map(e=>({stop:e.stop,declarations:Object.entries(e.declarations).map(([e,o])=>({property:e,value:A(o,t)}))}));o.push({kind:"keyframes",name:n,steps:e})}return o})(n,re),s=new Set(Object.keys(n)),a=[...r],l={};for(const[e,t]of Object.entries(null!==(X=ve.ruleSets)&&void 0!==X?X:{})){const{nodes:o,variants:n}=L(t,{media:Y,selectorBuilder:t=>`.${K.className("recipe","animation",e,t)}`,pathToVar:re,keyframeNames:s,containers:i.containers});a.push(...o),l[e]=n}te.animation={variableNodes:o,recipeNodes:a,selectors:l}}const pe={},me=s.subsystems.components;if(me){const e=[],t={},o=e=>{var t,o;const n=(e=>{const[t,o]=e.split(":");if(!t||!o)return;const n=o.indexOf(".");return n<0?void 0:{subsystem:t,group:o.slice(0,n),variant:o.slice(n+1)}})(e);if(!n)return;const r=null===(o=null===(t=te[n.subsystem])||void 0===t?void 0:t.selectors[n.group])||void 0===o?void 0:o[n.variant];return null==r?void 0:r.replace(/^\./,"")};for(const[n,r]of Object.entries(null!==(I=me.ruleSets)&&void 0!==I?I:{})){const{nodes:s,variants:a}=W(r,{media:Y,selectorBuilder:e=>`.${K.className("recipe","components",n,e)}`,pathToVar:re,containers:i.containers});e.push(...s),t[n]=a,pe[n]={};for(const[e,t]of Object.entries(r)){const r=a[e].replace(/^\./,""),s=[...(null!==(G=t.references)&&void 0!==G?G:[]).map(o).filter(e=>void 0!==e),r];pe[n][e]={className:s.join(" "),classList:s}}}te.components={variableNodes:[],recipeNodes:e,selectors:t}}const be=s.subsystems.globals;if(be){const e=((e,t,o,n)=>{var r;const s=[];for(const i of Object.values(e))for(const e of Object.values(i))if("globals"===e.kind){const i=e.selector;if(!i)continue;M(s,i,e.declarations,e.overrides,t,o,n);for(const[a,l]of Object.entries(null!==(r=e.variants)&&void 0!==r?r:{})){const e=B(i,`.${a}`);M(s,e,l.declarations,l.overrides,t,o,n)}}else s.push(...C(e,t));return s})(null!==(P=be.ruleSets)&&void 0!==P?P:{},re,Y,i.containers);te.globals={variableNodes:[],recipeNodes:e,selectors:{}}}const he=e=>K.className("container","containers","context",e),ye=((e,t)=>{const o=[];for(const[n,r]of Object.entries(null!=e?e:{}))o.push({kind:"rule",selector:`.${t(n)}`,declarations:[{property:"container-type",value:r.type},{property:"container-name",value:n}]});return o})(s.containers,he),ge=()=>{const e=[];te.globals&&e.push(...te.globals.recipeNodes),e.push(...ye);for(const t of Object.keys(s.subsystems)){if("globals"===t)continue;const o=te[t];o&&e.push(...o.variableNodes,...o.recipeNodes)}return ie(e),e},$e=!0===n.layer?"refract":"string"==typeof n.layer&&n.layer||void 0,ke=null!==(z=n.reducedMotion)&&void 0!==z&&z,je=e=>{let t=e;if($e){const o=e.trimEnd().split("\n").map(e=>e?` ${e}`:e).join("\n");t=`@layer ${$e} {\n${o}\n}\n`}return ke&&(t=`${t.trimEnd()}\n\n@media (prefers-reduced-motion: reduce) {\n *, *::before, *::after {\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n transition-duration: 0.01ms !important;\n scroll-behavior: auto !important;\n }\n}\n`),t},Oe=e=>{if(!H)return D(e);const t=se(e),o=e=>{if("string"!=typeof e.value)return{property:e.property,value:e.value};const o=e.value.replace(/var\((--[^)]+)\)/g,(e,o)=>{const n=t.get(o);return void 0!==n?String(n):e});return{property:e.property,value:o}},n=[];for(const t of e)"rule"===t.kind?n.push({...t,declarations:t.declarations.map(o)}):"keyframes"===t.kind&&n.push({...t,steps:t.steps.map(e=>({stop:e.stop,declarations:e.declarations.map(o)}))});return D(n)},Ne=()=>{const e={};for(const[t,o]of Object.entries(te)){if("globals"===t)continue;if("components"===t){e[t]=pe;continue}const n={};for(const[e,t]of Object.entries(o.selectors))n[e]=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,t.replace(/^\./,"")]));e[t]=n}if(s.containers&&Object.keys(s.containers).length){const t={};for(const e of Object.keys(s.containers))t[e]=he(e);e.containers={context:t}}return e},xe=(e,t,o)=>{var n,r;return null===(r=null===(n=te[e])||void 0===n?void 0:n.selectors[t])||void 0===r?void 0:r[o]},we=(e,t,o)=>{var n,r;const s=null===(r=null===(n=Ne()[e])||void 0===n?void 0:n[t])||void 0===r?void 0:r[o];if(void 0!==s)return"string"==typeof s?s:s.className},Se=(e,t,o)=>{const n=te[e],r=xe(e,t,o);if(!n||!r)return"";const s=n.recipeNodes.filter(e=>"rule"===e.kind&&((e,t)=>e===t||e.startsWith(`${t}:`)||e.startsWith(`${t}[`))(e.selector,r));return Oe(s)};return{recipeName(e,t,o){var n;return(null!==(n=xe(e,t,o))&&void 0!==n?n:"").replace(/^\./,"")},renderRecipe:Se,renderVariables(e){var t,o;return D(null!==(o=null===(t=te[e])||void 0===t?void 0:t.variableNodes)&&void 0!==o?o:[])},join:e=>e.filter(Boolean).join("\n\n"),renderAllVariables:()=>oe(ge()),renderAllRecipes:()=>ne(ge()),renderAll:()=>je(Oe(ge())),describeUsage(){var e;const t=[];for(const[o,n]of Object.entries(s.subsystems))for(const[r,s]of Object.entries(null!==(e=n.ruleSets)&&void 0!==e?e:{}))for(const e of Object.keys(s)){const n=we(o,r,e);n&&t.push({subsystem:o,group:r,variant:e,name:n})}return{format:"css",summary:["Import the stylesheet once, then apply the recipe class names below to your elements.",'Example: `import "./theme.css";` then `<button class="<class>">`.',"Values are CSS custom properties (`var(--…)`), so runtime theming = override the variables under a selector or `[data-theme]`."],recipes:t}},describePreview(e,t){const o=new Set(t),n=(...e)=>e.filter(e=>"string"==typeof e&&o.has(e)),r=t=>"components"!==e.type||"components"===t.subsystem,i={markup:t=>{var o;if(!r(t))return;const n="components"===e.type?(null!==(o=xe(t.subsystem,t.group,t.variant))&&void 0!==o?o:"").replace(/^\./,""):we(t.subsystem,t.group,t.variant);return n?{attrs:{class:n}}:void 0},modeAttribute:"data-theme"};switch(e.type){case"single":return{...i,stylesheets:n(e.file)};case"split":return{...i,stylesheets:n(e.variables,e.file)};case"subsystem":{const t=Object.keys(s.subsystems);return{...i,stylesheets:[...n(...t.map(t=>e.filename(t,"variables"))),...n(...t.map(t=>e.filename(t,"styles")))],groupBy:e=>e.subsystem}}case"components":{const o=t=>e.filename({group:t.group,variant:t.variant}),s=!1===e.variables?[]:n(e.variables),a=t.filter(e=>!s.includes(e));return{...i,stylesheets:[...s,...a],groupBy:e=>r(e)?o(e):"not emitted in components mode",notes:!1===e.variables&&!1===e.inline?["This target emits component rules that reference CSS variables but no variables file (`variables: false`), so the preview renders them undefined — supply the variables yourself in the consuming app."]:void 0}}}},extend:()=>({media:Y,renderRecipe:Se,getClass:we,varName:e=>re[e],get css(){return je(Oe(ge()))},get variablesCss(){return oe(ge())},get recipesCss(){return ne(ge())},get nodes(){return ge()},get classes(){return Ne()}}),emit(t){var o,n,r,a,l,c,u,d,f;const v=null!==(o=null==t?void 0:t.type)&&void 0!==o?o:"single";if(($e||ke)&&"single"!==v){const e=$e?"layer":"reducedMotion";throw new Error(`The \`${e}\` option is only supported with single-file emit (got "${v}"). Emit one file, or drop \`${e}\` for split/subsystem/components.`)}if("single"===v){const e="single"===(null==t?void 0:t.type)?t.file:"theme.css";return{files:{[e]:je(Oe(ge()))}}}if(H&&("split"===v||"subsystem"===v))throw new Error(`css adapter: emit mode '${v}' cannot be combined with the global inline option (inline bakes values, leaving no variables file)`);if("split"===(null==t?void 0:t.type)){const e=ge();return{files:{[t.file]:ne(e),[t.variables]:oe(e)}}}if("subsystem"===(null==t?void 0:t.type)){ge();const e={};for(const o of Object.keys(s.subsystems)){const n=te[o];if(!n)continue;const r=oe(n.variableNodes),s=ne(n.recipeNodes);r&&(e[t.filename(o,"variables")]=r),s&&(e[t.filename(o,"styles")]=s)}return{files:e}}if("components"===(null==t?void 0:t.type)){const o=null!==(r=null===(n=s.subsystems.components)||void 0===n?void 0:n.ruleSets)&&void 0!==r?r:{},v=[];for(const e of Object.keys(s.subsystems)){const t=te[e];t&&v.push(...t.variableNodes)}if(!1===t.inline){const n={},r=[],u=new Set;for(const[d,f]of Object.entries(o))for(const o of Object.keys(f)){const f=e.mergeComponentRuleSet(s,d,o),v=null===(l=null===(a=te.components)||void 0===a?void 0:a.selectors[d])||void 0===l?void 0:l[o];if(!v)continue;const p=U(f,{selector:v,media:Y,pathToVar:re,containers:i.containers}),m=t.filename({group:d,variant:o});(null!==(c=n[m])&&void 0!==c?c:n[m]=[]).push(D(p));for(const e of f.referencedPaths){const t=re[e];t&&!u.has(t)&&(u.add(t),r.push(t))}}const d={};for(const[e,t]of Object.entries(n))d[e]=t.join("\n\n");if(!1!==t.variables){const e=se(v.filter(e=>!e.media)),o={};for(const t of r){const n=e.get(t);void 0!==n&&(o[t]=n)}const n=[{kind:"variables",selector:":root",variables:o}];for(const e of v){if(!e.media||":root"!==e.selector)continue;const t={};for(const[o,n]of Object.entries(e.variables))u.has(o)&&(t[o]=n);Object.keys(t).length&&n.push({kind:"variables",selector:e.selector,media:e.media,variables:t})}const s=oe(n);s&&(d[t.variables]=s)}return{files:d}}const p={};for(const[n,r]of Object.entries(o))for(const o of Object.keys(r)){const r=e.mergeComponentRuleSet(s,n,o),a=null===(d=null===(u=te.components)||void 0===u?void 0:u.selectors[n])||void 0===d?void 0:d[o];if(!a)continue;const l=U(r,{selector:a,media:Y,pathToVar:re,containers:i.containers});ie([...v,...l]);const c=l.map(e=>({...e,declarations:e.declarations.map(e=>{const t=void 0!==e.resolved?e.resolved:e.value;if("string"==typeof t&&t.includes("var("))throw new Error(`css adapter: emit mode 'components' (inline): '${e.property}' on '${a}' has an unresolved token reference (${t}) — no baked value`);return{property:e.property,value:t}})})),m=t.filename({group:n,variant:o});(null!==(f=p[m])&&void 0!==f?f:p[m]=[]).push(D(c))}const m={};for(const[e,t]of Object.entries(p))m[e]=t.join("\n\n");return{files:m}}throw new Error(`css adapter: emit mode '${v}' not yet implemented`)}}}};return e.defineAdapter(s)};
|
|
1
|
+
"use strict";var e=require("@theme-registry/refract"),t=require("@theme-registry/refract/color-math"),o=require("@theme-registry/refract/adapter-kit");const n=e=>null==e?"":String(e),r=e=>void 0!==e.unit?`${e.value}${e.unit}`:n(e.value),s=(e,t,o,n)=>{var r;if(!n){const n=e[t];return null!==(r=null==n?void 0:n[o])&&void 0!==r?r:""}const s={orientation:n};return"min"===o?e.min(t,s):"max"===o?e.max(t,s):e.exact(t,s)},i=(e,t)=>{const o=e=>e.replace(/^@media\s*/,"");return`@media ${o(e)} and ${o(t)}`},a=(e,t,o,n)=>{var r,a;const c=new Map,d=(e,t,o)=>{const n=`${e}||${t}`,r=c.get(n);r?Object.assign(r.variables,o):c.set(n,{media:e,selector:t,variables:{...o}})};for(const[c,f]of Object.entries(e))for(const e of null!==(r=f.responsive)&&void 0!==r?r:[]){const r=s(t,e.breakpoint,null!==(a=e.query)&&void 0!==a?a:"exact",e.orientation);if(!r)continue;const f=l(c,e,o,n);if(!Object.keys(f).length)continue;const v=e.mode;if(v){d(r,`:root[data-theme="${v}"]`,f);const e=u[v];e&&d(i(r,e),":root",f)}else d(r,":root",f)}return Array.from(c.values(),({media:e,selector:t,variables:o})=>({kind:"variables",selector:t,media:e,variables:o}))},l=(e,t,o,n)=>{var r;const{ref:s,target:i}=t,a={};void 0!==s&&(a[o(e,i)]=`var(${o(e,s)})`);for(const[s,l]of Object.entries(null!==(r=t.overrides)&&void 0!==r?r:{})){a["base"===s?o(e,i):o(e,i,s)]=n(l)}return a},c=e=>Object.keys(e).length?[{kind:"variables",selector:":root",variables:e}]:[],u={dark:"@media (prefers-color-scheme: dark)",light:"@media (prefers-color-scheme: light)"},d=(e,t)=>{let o=e.get(t);return o||(o={},e.set(t,o)),o},f=e=>{const t=[];for(const[o,n]of e){if(!Object.keys(n).length)continue;const e=u[o];e&&t.push({kind:"variables",selector:":root",media:e,variables:{...n}}),t.push({kind:"variables",selector:`:root[data-theme="${o}"]`,variables:{...n}})}return t},v=(e,t,o,n,r)=>e([t,o,n,r].filter(Boolean).join(".")),p=(e,t,o)=>{var n;const r=new Map;for(const[s,i]of Object.entries(e))if(i.modes)for(const e of i.modes){if(void 0===e.mode)continue;const i=d(r,e.mode),a=e.target,l=null!==(n=e.overrides)&&void 0!==n?n:{},c=l.base;c&&null!=c.value&&(i[v(t,"colors",s,a)]=o(c.value));for(const[e,n]of Object.entries(l))"base"!==e&&n&&null!=n.value&&""!==n.value&&(i[v(t,"colors",s,a,e)]=o(n.value))}return f(r)},m=(e,t,o)=>{var n,r,s,i;const a={};for(const[l,c]of Object.entries(t)){a[`${e}.${l}`]=null!==(n=c.base.external)&&void 0!==n?n:o(`${e}.${l}`);for(const[t,n]of Object.entries(null!==(r=c.extras)&&void 0!==r?r:{}))null!=(null==n?void 0:n.value)&&""!==n.value&&(a[`${e}.${l}.${t}`]=o(`${e}.${l}.${t}`));for(const[t,n]of Object.entries(null!==(s=c.variants)&&void 0!==s?s:{})){a[`${e}.${l}.${t}`]=o(`${e}.${l}.${t}`);for(const r of Object.keys(null!==(i=n.extras)&&void 0!==i?i:{}))a[`${e}.${l}.${t}.${r}`]=o(`${e}.${l}.${t}.${r}`)}}return a},b=(e,t,o,n)=>{var s,i,l;const{varName:u}=o,d=(t,o,n)=>v(u,e,t,o,n),f={};for(const[e,o]of Object.entries(t))if(void 0===o.base.external){f[d(e)]=n.formatRoot(e,o.base);for(const[t,r]of Object.entries(null!==(s=o.variants)&&void 0!==s?s:{})){f[d(e,t)]=n.formatRoot(e,r.base);for(const[o,s]of Object.entries(null!==(i=r.extras)&&void 0!==i?i:{}))f[d(e,t,o)]=n.formatRoot(e,s)}}const p=null!==(l=n.formatResponsive)&&void 0!==l?l:r;return[...c(f),...a(t,o.media,d,p),...h(t,(e,t)=>d(e,t),n.formatRoot)]},h=(e,t,o)=>{var n;const r=new Map;for(const[s,i]of Object.entries(e))if(i.modes)for(const e of i.modes){if(void 0===e.mode)continue;const i=null===(n=e.overrides)||void 0===n?void 0:n.base;null==i||null==i.struct&&null==i.value||(d(r,e.mode)[t(s,e.target)]=o(s,i))}return f(r)},y=(e,t,o)=>m(e,t,o),g=(e,t)=>{const o=`0${(e=>{for(const t of[e.offsetX,e.offsetY,e.blur,e.spread])if(void 0!==t&&"number"!=typeof t)return t.unit;return"px"})(e)}`,n=e=>void 0===e?o:(e=>"number"==typeof e?String(e):`${e.value}${e.unit}`)(e),r=[];return e.inset&&r.push("inset"),r.push(n(e.offsetX),n(e.offsetY)),null!=e.spread?r.push(n(e.blur),n(e.spread)):null!=e.blur&&r.push(n(e.blur)),e.color&&r.push(((e,t)=>{const o=t[e];return o?`var(${o})`:e})(e.color,t)),r.join(" ")},$=(e,t)=>e.map(e=>g(e,t)).join(", "),k=e=>{var t;const o=[e.property];return null==e.duration&&null==e.delay||o.push(`${null!==(t=e.duration)&&void 0!==t?t:0}ms`),e.timingFunction&&o.push(e.timingFunction),null!=e.delay&&o.push(`${e.delay}ms`),o.join(" ")},j=e=>e.map(k).join(", "),O=(e,t)=>{var o;const n=null!==(o=t.pathToVar)&&void 0!==o?o:{};return b("effects",e,t,{formatRoot:(e,t)=>t.struct?((e,t,o)=>"transitions"===e?j(t):$(t,o))(e,t.struct,n):r(t),formatResponsive:e=>e.struct?((e,t)=>{const o=e[0];return o&&"object"==typeof o&&"property"in o?j(e):$(e,t)})(e.struct,n):r(e)})},N=new Set(["duration","delay"]),x=(e,t)=>b("animation",e,t,{formatRoot:(e,t)=>"number"==typeof t.value&&N.has(e)?`${t.value}ms`:n(t.value),formatResponsive:e=>{return"number"==typeof(t=e.value)?`${t}ms`:n(t);var t}}),S=e=>e.includes("--"),w=e=>{const t={},o={};for(const[n,r]of Object.entries(e))S(n)?o[n]=r:t[n]=r;return{regular:t,config:o}},E=(e,t)=>b("layout",e,t,{formatRoot:(e,t)=>r(t)}),R=["spacing","gutters","aspectRatio"],T=(e,t)=>{const o=new Map;for(const[n,r]of Object.entries(e)){const e=n.split("--")[0];let s=o.get(e);s||(s={},o.set(e,s)),s[t.varName(`layout.${n}`)]=String(A(r.base,t.pathToVar))}return Array.from(o.values(),e=>({kind:"variables",selector:":root",variables:e}))},V=(e,t)=>{var o,n;const{media:r,selectorBuilder:i,pathToVar:a}=t,l=Object.entries(e),c={};for(const[e]of l)c[e]=i(e);const u=[];for(let e=l.length-1;e>=0;e--){const[t,o]=l[e],n=q(o.declarations,a);n.length&&u.push({kind:"rule",selector:i(t),declarations:n})}const d=[];for(const[e,t]of l)for(const l of t.overrides){if(void 0!==l.state||!l.breakpoint)continue;const t=s(r,l.breakpoint,null!==(o=l.query)&&void 0!==o?o:"exact",l.orientation);if(!t)continue;const c=q(null!==(n=l.declarations)&&void 0!==n?n:{},a);c.length&&d.push({kind:"rule",selector:i(e),media:t,declarations:c})}return{nodes:[...u,...d],variants:c}},A=(e,t)=>{var o;if(void 0===e.ref)return e.value;const n=`var(${null!==(o=t[e.ref])&&void 0!==o?o:e.ref})`;return e.wrap?`${e.wrap}(${n})`:n},q=(e,t)=>Object.entries(e).map(([e,o])=>({property:e,value:A(o,t)})),C=(e,t)=>e.split(",").map(e=>`${e.trim()}${t}`).join(","),B=(e,t)=>{const o=e.selector;if(!o)return[];const n=[];for(const[o,r]of Object.entries(e.declarations)){if(void 0===r.ref){n.push({property:o,value:r.value});continue}const e=t[r.ref];e&&n.push({property:o,value:`var(${e})`})}return n.length?[{kind:"rule",selector:`:where(${o})`,declarations:n}]:[]},M=(e,t,o,n,r,i,a)=>{var l,c,u,d,f;const v=q(o,r);v.length&&e.push({kind:"rule",selector:t,declarations:v});for(const o of n){if(void 0!==o.state||void 0!==o.container||!o.breakpoint)continue;const n=s(i,o.breakpoint,null!==(l=o.query)&&void 0!==l?l:"exact",o.orientation);if(!n)continue;const a=q(null!==(c=o.declarations)&&void 0!==c?c:{},r);a.length&&e.push({kind:"rule",selector:t,media:n,declarations:a})}const p=n.filter(e=>void 0!==e.state);for(const o of X(p)){const n=_[o.state];if(!n)continue;const a=q(null!==(u=o.declarations)&&void 0!==u?u:{},r);if(!a.length)continue;const l={kind:"rule",selector:C(t,n),declarations:a};if(o.breakpoint){const e=s(i,o.breakpoint,null!==(d=o.query)&&void 0!==d?d:"exact",o.orientation);e&&(l.media=e)}e.push(l)}for(const o of n){if(!o.container)continue;const n=G(o,a);if(!n)continue;const s=q(null!==(f=o.declarations)&&void 0!==f?f:{},r);s.length&&e.push({kind:"rule",selector:t,media:n,declarations:s})}},_={link:":link",visited:":visited",hover:":hover",focus:":focus",active:":active",disabled:"[disabled]",pressed:"[aria-pressed]"},F=Object.keys(_),P=F.reduce((e,t,o)=>(e[t]=o,e),{}),X=e=>[...e].map((e,t)=>({override:e,index:t})).sort((e,t)=>{var o,n;const r=null!==(o=P[e.override.state])&&void 0!==o?o:Number.MAX_SAFE_INTEGER,s=null!==(n=P[t.override.state])&&void 0!==n?n:Number.MAX_SAFE_INTEGER;if(r!==s)return r-s;const i=e.override.breakpoint?1:0,a=t.override.breakpoint?1:0;return i!==a?i-a:e.index-t.index}).map(({override:e})=>e),I=(e,t,o,n)=>{var r,i;const a=e.overrides.filter(e=>void 0!==e.state&&!e.target);if(!a.length)return[];const l=[];for(const e of X(a)){const a=_[e.state];if(!a)continue;const c=q(null!==(r=e.declarations)&&void 0!==r?r:{},n);if(!c.length)continue;const u={kind:"rule",selector:`${t}${a}`,declarations:c};if(e.breakpoint){const t=s(o,e.breakpoint,null!==(i=e.query)&&void 0!==i?i:"exact",e.orientation);t&&(u.media=t)}l.push(u)}return l},G=(e,t)=>{var o;if(!e.container||!e.size)return"";const n=null==t?void 0:t[e.container];if(!n)return"";return n[null!==(o=e.query)&&void 0!==o?o:"min"](e.size)},W=(e,t)=>{var o,n,r,i,a;const{media:l,selectorBuilder:c,pathToVar:u}=t,d=[],f={};for(const[t,r]of Object.entries(e)){const e=c(t);f[t]=e;const i=q(r.declarations,u);i.length&&d.push({kind:"rule",selector:e,declarations:i});for(const t of r.overrides){if(void 0!==t.state||!t.breakpoint)continue;const r=s(l,t.breakpoint,null!==(o=t.query)&&void 0!==o?o:"exact",t.orientation);if(!r)continue;const i=q(null!==(n=t.declarations)&&void 0!==n?n:{},u);i.length&&d.push({kind:"rule",selector:e,media:r,declarations:i})}}const v=[];for(const[t,o]of Object.entries(e))v.push(...I(o,c(t),l,u));const p=[];for(const[t,o]of Object.entries(e))for(const e of o.overrides){if(void 0===e.state||!e.target)continue;const o=_[e.state];if(!o)continue;const n=q(null!==(r=e.declarations)&&void 0!==r?r:{},u);if(!n.length)continue;const a={kind:"rule",selector:`${c(`${t}-${e.target}`)}${o}`,declarations:n};if(e.breakpoint){const t=s(l,e.breakpoint,null!==(i=e.query)&&void 0!==i?i:"exact",e.orientation);t&&(a.media=t)}p.push(a)}const m=[];for(const[o,n]of Object.entries(e)){const e=c(o);for(const o of n.overrides){if(!o.container)continue;const n=G(o,t.containers);if(!n)continue;const r=q(null!==(a=o.declarations)&&void 0!==a?a:{},u);r.length&&m.push({kind:"rule",selector:e,media:n,declarations:r})}}return{nodes:[...d,...v,...m,...p],variants:f}},z="animation.keyframes.",L=["animation-duration","animation-timing-function","animation-delay","animation-iteration-count","animation-direction","animation-fill-mode","animation-play-state","animation-name"],Y=(e,t,o)=>{const r=void 0!==e.ref?e.ref.startsWith(z)?e.ref.slice(20):e.ref:n(e.value);if(!t.has(r))throw new Error(`css adapter: animation recipe '${o}' references unknown keyframe '${r}' — no matching entry in animation.keyframes`);return r},H=(e,t)=>{var o,n,r,i,a;const{media:l,selectorBuilder:c,pathToVar:u,keyframeNames:d}=t,f=[],v={},p=(e,t,o)=>{const n=((e,t,o,n)=>{const r=[];for(const s of L){const i=e[s];i&&r.push("animation-name"===s?Y(i,o,n):String(A(i,t)))}return r.join(" ")})(t,u,d,e);if(!n)return;const r={kind:"rule",selector:e,declarations:[{property:"animation",value:n}]};return o&&(r.media=o),r};for(const[t,r]of Object.entries(e)){const e=c(t);v[t]=e;const i=p(e,r.declarations);i&&f.push(i);for(const t of r.overrides){if(void 0!==t.state||!t.breakpoint)continue;const r=s(l,t.breakpoint,null!==(o=t.query)&&void 0!==o?o:"exact",t.orientation);if(!r)continue;const i=p(e,null!==(n=t.declarations)&&void 0!==n?n:{},r);i&&f.push(i)}}const m=[];for(const[t,o]of Object.entries(e)){const e=c(t),n=o.overrides.filter(e=>void 0!==e.state);for(const t of X(n)){const o=_[t.state];if(!o)continue;let n;t.breakpoint&&(n=s(l,t.breakpoint,null!==(r=t.query)&&void 0!==r?r:"exact",t.orientation)||void 0);const a=p(`${e}${o}`,null!==(i=t.declarations)&&void 0!==i?i:{},n);a&&m.push(a)}}const b=[];for(const[o,n]of Object.entries(e)){const e=c(o);for(const o of n.overrides){if(!o.container)continue;const n=G(o,t.containers);if(!n)continue;const r=p(e,null!==(a=o.declarations)&&void 0!==a?a:{},n);r&&b.push(r)}}return{nodes:[...f,...m,...b],variants:v}},U=(e,t)=>{var o,n;const{selector:r,media:i,pathToVar:a,containers:l}=t,c=[],u=q(e.base,a);u.length&&c.push({kind:"rule",selector:r,declarations:u});for(const t of(d=Object.keys(e.states),[...d].sort((e,t)=>{var o,n;return(null!==(o=P[e])&&void 0!==o?o:Number.MAX_SAFE_INTEGER)-(null!==(n=P[t])&&void 0!==n?n:Number.MAX_SAFE_INTEGER)}))){const o=_[t];if(!o)continue;const n=q(e.states[t],a);n.length&&c.push({kind:"rule",selector:`${r}${o}`,declarations:n})}var d;for(const t of e.responsive){const e=t.container?G(t,l):s(i,t.breakpoint,null!==(o=t.query)&&void 0!==o?o:"exact",t.orientation);if(!e)continue;const u=q(t.declarations,a);if(!u.length)continue;const d=t.state&&null!==(n=_[t.state])&&void 0!==n?n:"";c.push({kind:"rule",selector:`${r}${d}`,media:e,declarations:u})}return c},D=(e,t={})=>{var o,n;const r=null!==(o=t.indent)&&void 0!==o?o:" ",s=null!==(n=t.newline)&&void 0!==n?n:"\n",i=[],a=J(e);for(const e of a){if("keyframes"===e.kind){const t=Z(e,r,s);if(!t)continue;i.push(`@keyframes ${e.name} {${s}${t}${s}}`);continue}const t="variables"===e.kind?K(e.variables,r,s):Q(e.declarations,r,s);if(!t)continue;const o=`${e.selector} {${s}${t}${s}}`;e.media?i.push(`${e.media} {${s}${ee(o,r,s)}${s}}`):i.push(o)}return i.filter(Boolean).join(`${s}${s}`)},J=e=>{const t=e=>{var t;return"variables"===e.kind?`var:${null!==(t=e.media)&&void 0!==t?t:""}:${e.selector}`:""},o=[];for(const n of e){if("variables"!==n.kind){o.push(n);continue}const e=t(n),r=o[o.length-1];r&&"variables"===r.kind&&t(r)===e?r.variables={...r.variables,...n.variables}:o.push({kind:"variables",selector:n.selector,media:n.media,variables:{...n.variables}})}return o},K=(e,t,o)=>{const n=Object.entries(e);return n.length?n.map(([e,o])=>`${t}${e}: ${o};`).join(o):""},Q=(e,t,o)=>e.length?e.map(({property:e,value:o})=>`${t}${e}: ${o};`).join(o):"",Z=(e,t,o)=>e.steps.map(e=>{if(!e.declarations.length)return"";const n=e.declarations.map(({property:e,value:o})=>`${t}${t}${e}: ${o};`).join(o);return`${t}${e.stop} {${o}${n}${o}${t}}`}).filter(Boolean).join(o),ee=(e,t,o)=>e.split(o).map(e=>e.length?`${t}${e}`:e).join(o),te=e=>{const t=[],o=[];for(const n of e)"variables"===n.kind?t.push(n):o.push(n);return{variables:t,rules:o}},oe=e=>D(te(e).variables),ne=e=>D(te(e).rules),re=/var\((--[^)]+)\)/,se=e=>{const t=new Map;for(const o of e)if("variables"===o.kind)for(const[e,n]of Object.entries(o.variables))re.test(n)||t.set(e,n);for(const o of e)if("variables"===o.kind)for(const[e,n]of Object.entries(o.variables)){if(t.has(e))continue;const o=n.match(re);if(o){const n=t.get(o[1]);n&&t.set(e,n)}}return t},ie=e=>{const t=se(e),o=e=>{if("string"!=typeof e.value)return;const o=e.value.match(re);if(!o)return;e.ref=o[1];const n=t.get(o[1]);void 0!==n&&(e.resolved=n)};for(const t of e)if("keyframes"!==t.kind){if("rule"===t.kind)for(const e of t.declarations)o(e)}else for(const e of t.steps)for(const t of e.declarations)o(t)},ae=e=>{const[t,o]=e.split(":");if(!t||!o)return;const n=o.indexOf(".");return n<0?void 0:{subsystem:t,group:o.slice(0,n),variant:o.slice(n+1)}};exports.createCssAdapter=(n={})=>{const s={name:"css",version:1,allowedStates:F,bind(s,i){var l,u,d,f,h,g,$,k,j,N,S,q,P,X,I,G,z,L,Y;const J=i.media,K=null!==(l=n.inline)&&void 0!==l&&l,Q=o.resolveNaming({prefix:n.prefix,classPrefix:n.classPrefix}),Z=o.createNamer(Q,n.naming),ee=Z.variableName,te=null!==(u=n.colorFormat)&&void 0!==u?u:"rgb",re=e=>{const o=null==e?"":String(e);return o&&"rgb"!==te?"hex"===te?t.toHexColor(o):t.toOklchColor(o):o},le={},ce={},ue=(e,t,o)=>{const n=[],r={};for(const[s,a]of Object.entries(t)){const{nodes:t,variants:l}=W(a,{media:J,selectorBuilder:t=>`.${Z.className("recipe",e,s,t)}`,pathToVar:o,containers:i.containers});n.push(...t),r[s]=l}return{recipeNodes:n,selectors:r}},de=s.subsystems.colors;if(de){const e=null!==(d=de.properties)&&void 0!==d?d:{},t=((e,t)=>m("colors",e,t))(e,ee);Object.assign(ce,t);const o=((e,t)=>{var o,n,r;const{varName:s,formatColor:i}=t,l=(e,t,o)=>v(s,"colors",e,t,o),u={};for(const[t,s]of Object.entries(e)){if(void 0!==s.base.external)continue;u[l(t)]=i(s.base.value);const e=null===(o=s.extras)||void 0===o?void 0:o.text;e&&null!=e.value&&""!==e.value&&(u[l(t,void 0,"text")]=i(e.value));for(const[e,o]of Object.entries(null!==(n=s.variants)&&void 0!==n?n:{})){u[l(t,e)]=i(o.base.value);for(const[n,s]of Object.entries(null!==(r=o.extras)&&void 0!==r?r:{}))null!=s.value&&""!==s.value&&(u[l(t,e,n)]=i(s.value))}}return[...c(u),...a(e,t.media,l,e=>i(e.value)),...p(e,s,i)]})(e,{varName:ee,media:J,formatColor:re}),{recipeNodes:n,selectors:r}=ue("colors",null!==(f=de.ruleSets)&&void 0!==f?f:{},t);le.colors={variableNodes:o,recipeNodes:n,selectors:r}}const fe=s.subsystems.typography;if(fe){const e=null!==(h=fe.properties)&&void 0!==h?h:{},t=((e,t)=>y("typography",e,t))(e,ee);Object.assign(ce,t);const o=((e,t)=>b("typography",e,t,{formatRoot:(e,t)=>r(t)}))(e,{varName:ee,media:J}),{recipeNodes:n,selectors:s}=ue("typography",null!==(g=fe.ruleSets)&&void 0!==g?g:{},t);le.typography={variableNodes:o,recipeNodes:n,selectors:s}}const ve=s.subsystems.effects;if(ve){const e=null!==($=ve.properties)&&void 0!==$?$:{},t=((e,t)=>y("effects",e,t))(e,ee);Object.assign(ce,t);const o=O(e,{varName:ee,media:J,pathToVar:ce}),{recipeNodes:n,selectors:r}=ue("effects",null!==(k=ve.ruleSets)&&void 0!==k?k:{},t);le.effects={variableNodes:o,recipeNodes:n,selectors:r}}const pe=s.subsystems.borders;if(pe){const e=null!==(j=pe.properties)&&void 0!==j?j:{},t=((e,t)=>y("borders",e,t))(e,ee);Object.assign(ce,t);const o=((e,t)=>b("borders",e,t,{formatRoot:(e,t)=>r(t)}))(e,{varName:ee,media:J}),{recipeNodes:n,selectors:s}=ue("borders",null!==(N=pe.ruleSets)&&void 0!==N?N:{},ce);le.borders={variableNodes:o,recipeNodes:n,selectors:s}}const me=s.subsystems.layout;if(me){const e=null!==(S=me.properties)&&void 0!==S?S:{},t=((e,t)=>{const{regular:o,config:n}=w(e),r=y("layout",o,t);for(const e of R){const o=`layout.${e}`;o in r||(r[o]=t(o))}for(const e of Object.keys(n))r[`layout.${e}`]=t(`layout.${e}`);return r})(e,ee);Object.assign(ce,t);const{regular:o,config:n}=w(e),r=[...E(o,{varName:ee,media:J}),...T(n,{varName:ee,pathToVar:t})],s=[],a={};for(const[e,o]of Object.entries(null!==(q=me.ruleSets)&&void 0!==q?q:{})){const n=t=>`.${Z.className("recipe","layout",e,t)}`,r="container"===e?V:W,{nodes:l,variants:c}=r(o,{media:J,selectorBuilder:n,pathToVar:t,containers:i.containers});s.push(...l),a[e]=c}le.layout={variableNodes:r,recipeNodes:s,selectors:a}}const be=s.subsystems.animation;if(be){const e=null!==(P=be.properties)&&void 0!==P?P:{},t=((e,t)=>y("animation",e,t))(e,ee);Object.assign(ce,t);const o=x(e,{varName:ee,media:J}),n=null!==(X=be.keyframes)&&void 0!==X?X:{},r=((e,t)=>{const o=[];for(const[n,r]of Object.entries(e)){const e=r.steps.map(e=>({stop:e.stop,declarations:Object.entries(e.declarations).map(([e,o])=>({property:e,value:A(o,t)}))}));o.push({kind:"keyframes",name:n,steps:e})}return o})(n,ce),s=new Set(Object.keys(n)),a=[...r],l={};for(const[e,t]of Object.entries(null!==(I=be.ruleSets)&&void 0!==I?I:{})){const{nodes:o,variants:n}=H(t,{media:J,selectorBuilder:t=>`.${Z.className("recipe","animation",e,t)}`,pathToVar:ce,keyframeNames:s,containers:i.containers});a.push(...o),l[e]=n}le.animation={variableNodes:o,recipeNodes:a,selectors:l}}const he={},ye=s.subsystems.components;if(ye){const e=[],t={},o=e=>{var t,o;const n=ae(e);if(!n)return;const r=null===(o=null===(t=le[n.subsystem])||void 0===t?void 0:t.selectors[n.group])||void 0===o?void 0:o[n.variant];return null==r?void 0:r.replace(/^\./,"")};for(const[n,r]of Object.entries(null!==(G=ye.ruleSets)&&void 0!==G?G:{})){const{nodes:s,variants:a}=W(r,{media:J,selectorBuilder:e=>`.${Z.className("recipe","components",n,e)}`,pathToVar:ce,containers:i.containers});e.push(...s),t[n]=a,he[n]={};for(const[e,t]of Object.entries(r)){const r=a[e].replace(/^\./,""),s=[...(null!==(z=t.references)&&void 0!==z?z:[]).map(o).filter(e=>void 0!==e),r];he[n][e]={className:s.join(" "),classList:s}}}le.components={variableNodes:[],recipeNodes:e,selectors:t}}const ge=s.subsystems.globals;if(ge){const e=((e,t,o,n)=>{var r;const s=[];for(const i of Object.values(e))for(const e of Object.values(i))if("globals"===e.kind){const i=e.selector;if(!i)continue;M(s,i,e.declarations,e.overrides,t,o,n);for(const[a,l]of Object.entries(null!==(r=e.variants)&&void 0!==r?r:{})){const e=C(i,`.${a}`);M(s,e,l.declarations,l.overrides,t,o,n)}}else s.push(...B(e,t));return s})(null!==(L=ge.ruleSets)&&void 0!==L?L:{},ce,J,i.containers);le.globals={variableNodes:[],recipeNodes:e,selectors:{}}}const $e=e=>Z.className("container","containers","context",e),ke=((e,t)=>{const o=[];for(const[n,r]of Object.entries(null!=e?e:{}))o.push({kind:"rule",selector:`.${t(n)}`,declarations:[{property:"container-type",value:r.type},{property:"container-name",value:n}]});return o})(s.containers,$e),je=()=>{const e=[];le.globals&&e.push(...le.globals.recipeNodes),e.push(...ke);for(const t of Object.keys(s.subsystems)){if("globals"===t)continue;const o=le[t];o&&e.push(...o.variableNodes,...o.recipeNodes)}return ie(e),e},Oe=!0===n.layer?"refract":"string"==typeof n.layer&&n.layer||void 0,Ne=null!==(Y=n.reducedMotion)&&void 0!==Y&&Y,xe=e=>{let t=e;if(Oe){const o=e.trimEnd().split("\n").map(e=>e?` ${e}`:e).join("\n");t=`@layer ${Oe} {\n${o}\n}\n`}return Ne&&(t=`${t.trimEnd()}\n\n@media (prefers-reduced-motion: reduce) {\n *, *::before, *::after {\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n transition-duration: 0.01ms !important;\n scroll-behavior: auto !important;\n }\n}\n`),t},Se=e=>{if(!K)return D(e);const t=se(e),o=e=>{if("string"!=typeof e.value)return{property:e.property,value:e.value};const o=e.value.replace(/var\((--[^)]+)\)/g,(e,o)=>{const n=t.get(o);return void 0!==n?String(n):e});return{property:e.property,value:o}},n=[];for(const t of e)"rule"===t.kind?n.push({...t,declarations:t.declarations.map(o)}):"keyframes"===t.kind&&n.push({...t,steps:t.steps.map(e=>({stop:e.stop,declarations:e.declarations.map(o)}))});return D(n)},we=()=>{const e={};for(const[t,o]of Object.entries(le)){if("globals"===t)continue;if("components"===t){e[t]=he;continue}const n={};for(const[e,t]of Object.entries(o.selectors))n[e]=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,t.replace(/^\./,"")]));e[t]=n}if(s.containers&&Object.keys(s.containers).length){const t={};for(const e of Object.keys(s.containers))t[e]=$e(e);e.containers={context:t}}return e},Ee=(e,t,o)=>{var n,r;return null===(r=null===(n=le[e])||void 0===n?void 0:n.selectors[t])||void 0===r?void 0:r[o]},Re=(e,t,o)=>{var n,r;const s=null===(r=null===(n=we()[e])||void 0===n?void 0:n[t])||void 0===r?void 0:r[o];if(void 0!==s)return"string"==typeof s?s:s.className},Te=(e,t,o)=>{const n=le[e],r=Ee(e,t,o);if(!n||!r)return"";const s=n.recipeNodes.filter(e=>"rule"===e.kind&&((e,t)=>e===t||e.startsWith(`${t}:`)||e.startsWith(`${t}[`))(e.selector,r));return Se(s)};return{recipeName(e,t,o){var n;return(null!==(n=Ee(e,t,o))&&void 0!==n?n:"").replace(/^\./,"")},renderRecipe:Te,renderVariables(e){var t,o;return D(null!==(o=null===(t=le[e])||void 0===t?void 0:t.variableNodes)&&void 0!==o?o:[])},join:e=>e.filter(Boolean).join("\n\n"),renderAllVariables:()=>oe(je()),renderAllRecipes:()=>ne(je()),renderAll:()=>xe(Se(je())),describeUsage(){var e;const t=[];for(const[o,n]of Object.entries(s.subsystems))for(const[r,s]of Object.entries(null!==(e=n.ruleSets)&&void 0!==e?e:{}))for(const e of Object.keys(s)){const n=Re(o,r,e);n&&t.push({subsystem:o,group:r,variant:e,name:n})}return{format:"css",summary:["Import the stylesheet once, then apply the recipe class names below to your elements.",'Example: `import "./theme.css";` then `<button class="<class>">`.',"Values are CSS custom properties (`var(--…)`), so runtime theming = override the variables under a selector or `[data-theme]`."],recipes:t}},describePreview(e,t){const o=new Set(t),n=(...e)=>e.filter(e=>"string"==typeof e&&o.has(e)),r=t=>"components"!==e.type||"components"===t.subsystem,i=e=>{var t,o,n;return null===(n=null===(o=null===(t=s.subsystems[e.subsystem])||void 0===t?void 0:t.ruleSets)||void 0===o?void 0:o[e.group])||void 0===n?void 0:n[e.variant]},a="rfp-s-",l={markup:t=>{var o;if(!r(t))return;const n="components"===e.type?(null!==(o=Ee(t.subsystem,t.group,t.variant))&&void 0!==o?o:"").replace(/^\./,""):Re(t.subsystem,t.group,t.variant);return n?{attrs:{class:n}}:void 0},modeAttribute:"data-theme",tokenName:e=>ce[e],states:e=>{var t,o;if(!r(e))return[];const n=new Set((null!==(o=null===(t=i(e))||void 0===t?void 0:t.overrides)&&void 0!==o?o:[]).map(e=>e.state).filter(e=>"string"==typeof e));return F.filter(e=>n.has(e))},statePinClass:e=>_[e]?`${a}${e}`:void 0,statePinCss:(()=>{var e;je();const t=[];for(const o of Object.values(le))for(const n of null!==(e=null==o?void 0:o.recipeNodes)&&void 0!==e?e:[])if("rule"===n.kind)for(const[e,o]of Object.entries(_))if(n.selector.includes(o)){t.push({...n,selector:n.selector.split(o).join(`.${a}${e}`)});break}return t.length?D(t):""})(),composition:e=>{var t,o,n,r;const s=null===(o=null===(t=we()[e.subsystem])||void 0===t?void 0:t[e.group])||void 0===o?void 0:o[e.variant];if(!s||"string"==typeof s)return;const a=s.classList;if(!a||a.length<2)return;const l=null!==(r=null===(n=i(e))||void 0===n?void 0:n.references)&&void 0!==r?r:[];return a.map((e,t)=>{const o=l[t]?ae(l[t]):void 0;return{className:e,from:o?`${o.subsystem}.${o.group}.${o.variant}`:void 0}})}};switch(e.type){case"single":return{...l,stylesheets:n(e.file)};case"split":return{...l,stylesheets:n(e.variables,e.file)};case"subsystem":{const t=Object.keys(s.subsystems);return{...l,stylesheets:[...n(...t.map(t=>e.filename(t,"variables"))),...n(...t.map(t=>e.filename(t,"styles")))],groupBy:e=>e.subsystem}}case"components":{const o=t=>e.filename({group:t.group,variant:t.variant}),s=!1===e.variables?[]:n(e.variables),i=t.filter(e=>!s.includes(e));return{...l,stylesheets:[...s,...i],groupBy:e=>r(e)?o(e):"not emitted in components mode",notes:!1===e.variables&&!1===e.inline?["This target emits component rules that reference CSS variables but no variables file (`variables: false`), so the preview renders them undefined — supply the variables yourself in the consuming app."]:void 0}}}},extend:()=>({media:J,renderRecipe:Te,getClass:Re,varName:e=>ce[e],get css(){return xe(Se(je()))},get variablesCss(){return oe(je())},get recipesCss(){return ne(je())},get nodes(){return je()},get classes(){return we()}}),emit(t){var o,n,r,a,l,c,u,d,f;const v=null!==(o=null==t?void 0:t.type)&&void 0!==o?o:"single";if((Oe||Ne)&&"single"!==v){const e=Oe?"layer":"reducedMotion";throw new Error(`The \`${e}\` option is only supported with single-file emit (got "${v}"). Emit one file, or drop \`${e}\` for split/subsystem/components.`)}if("single"===v){const e="single"===(null==t?void 0:t.type)?t.file:"theme.css";return{files:{[e]:xe(Se(je()))}}}if(K&&("split"===v||"subsystem"===v))throw new Error(`css adapter: emit mode '${v}' cannot be combined with the global inline option (inline bakes values, leaving no variables file)`);if("split"===(null==t?void 0:t.type)){const e=je();return{files:{[t.file]:ne(e),[t.variables]:oe(e)}}}if("subsystem"===(null==t?void 0:t.type)){je();const e={};for(const o of Object.keys(s.subsystems)){const n=le[o];if(!n)continue;const r=oe(n.variableNodes),s=ne(n.recipeNodes);r&&(e[t.filename(o,"variables")]=r),s&&(e[t.filename(o,"styles")]=s)}return{files:e}}if("components"===(null==t?void 0:t.type)){const o=null!==(r=null===(n=s.subsystems.components)||void 0===n?void 0:n.ruleSets)&&void 0!==r?r:{},v=[];for(const e of Object.keys(s.subsystems)){const t=le[e];t&&v.push(...t.variableNodes)}if(!1===t.inline){const n={},r=[],u=new Set;for(const[d,f]of Object.entries(o))for(const o of Object.keys(f)){const f=e.mergeComponentRuleSet(s,d,o),v=null===(l=null===(a=le.components)||void 0===a?void 0:a.selectors[d])||void 0===l?void 0:l[o];if(!v)continue;const p=U(f,{selector:v,media:J,pathToVar:ce,containers:i.containers}),m=t.filename({group:d,variant:o});(null!==(c=n[m])&&void 0!==c?c:n[m]=[]).push(D(p));for(const e of f.referencedPaths){const t=ce[e];t&&!u.has(t)&&(u.add(t),r.push(t))}}const d={};for(const[e,t]of Object.entries(n))d[e]=t.join("\n\n");if(!1!==t.variables){const e=se(v.filter(e=>!e.media)),o={};for(const t of r){const n=e.get(t);void 0!==n&&(o[t]=n)}const n=[{kind:"variables",selector:":root",variables:o}];for(const e of v){if(!e.media||":root"!==e.selector)continue;const t={};for(const[o,n]of Object.entries(e.variables))u.has(o)&&(t[o]=n);Object.keys(t).length&&n.push({kind:"variables",selector:e.selector,media:e.media,variables:t})}const s=oe(n);s&&(d[t.variables]=s)}return{files:d}}const p={};for(const[n,r]of Object.entries(o))for(const o of Object.keys(r)){const r=e.mergeComponentRuleSet(s,n,o),a=null===(d=null===(u=le.components)||void 0===u?void 0:u.selectors[n])||void 0===d?void 0:d[o];if(!a)continue;const l=U(r,{selector:a,media:J,pathToVar:ce,containers:i.containers});ie([...v,...l]);const c=l.map(e=>({...e,declarations:e.declarations.map(e=>{const t=void 0!==e.resolved?e.resolved:e.value;if("string"==typeof t&&t.includes("var("))throw new Error(`css adapter: emit mode 'components' (inline): '${e.property}' on '${a}' has an unresolved token reference (${t}) — no baked value`);return{property:e.property,value:t}})})),m=t.filename({group:n,variant:o});(null!==(f=p[m])&&void 0!==f?f:p[m]=[]).push(D(c))}const m={};for(const[e,t]of Object.entries(p))m[e]=t.join("\n\n");return{files:m}}throw new Error(`css adapter: emit mode '${v}' not yet implemented`)}}}};return e.defineAdapter(s)};
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|