@hazem3500/komo 0.9.37 → 0.9.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -154,6 +154,8 @@ In Design mode, each style field of the picked element:
154
154
 
155
155
  `list()` and `resolve()` may return promises; the panel renders first and the token controls join when they resolve. `list()` is called once per theme state. A comment on a token swap records `Element color: #6b6b6b [color.text.secondary] → #1f1f1f [color.text.primary]`, followed by your `describe()` text on an `Apply:` line.
156
156
 
157
+ Returning `{ path: "tone.base" }` declares a semantic binding, including when the host renders that token as a concrete inline value. Its Before/Undo baseline follows the current theme's resolved token value; existing classes, CSS-variable references, declaration priorities and unrelated styles are preserved. Return `{ offToken: value }` for a genuine custom literal, even if it happens to equal a token. Supply current resolved values through `list(theme)` and notify subscribers after applying a theme change.
158
+
157
159
  Writing an adapter for utility classes:
158
160
 
159
161
  ```ts
@@ -274,6 +276,7 @@ initKomo({ project, design: { tokens: tailwindTokens({ tokens }, { themes: [mode
274
276
  - Previews replace table classes the new class fully covers, keep everything else in place, and stack; undoing restores the original `class` exactly. Classes outside the table, such as `text-[14px]`, are left alone.
275
277
  - `tailwindSpacing({ prefix, scale, steps })` narrows the families (`p`, `px`, `py`, `pt`, `pr`, `pb`, `pl`, `m`, `mx`, …, `gap`, `gap-x`, `gap-y`), the pixels per step (default 4), and the steps (default Tailwind's 0 to 96). Paths are `spacing.<class>`, for example `spacing.p-4`.
276
278
  - `classTheme` options take `class`, `attribute`, or both, on `target()` (default `<html>`). An option with neither is the default. With `colorScheme`, applying an option sets `color-scheme` to its `colorScheme` or id, and returning to the starting option restores the page's own value.
279
+ - Theme changes refresh semantic previews, field values, open token pickers and unsaved proposals without adding an edit. `classTheme` observes its target. Custom axes may provide `subscribe(listener): () => void` for host state changes; axes without it detect changes carried on `<html>` or `<body>` attributes. Custom literals and saved comment bodies keep their recorded values.
277
280
 
278
281
  ## Agent CLI
279
282
 
@@ -1 +1 @@
1
- var t=t=>(Array.isArray(t.class)?t.class:[t.class??""]).flatMap(t=>t.split(/\s+/)).filter(Boolean);function e(e){let o,r=e.target??(()=>document.documentElement),i=e=>t(e).length+Object.keys(e.attribute??{}).length,l=(e,o)=>t(o).every(t=>e.classList.contains(t))&&Object.entries(o.attribute??{}).every(([t,o])=>e.getAttribute(t)===o);function s(){let t,o=r();for(let r of e.options)l(o,r)&&(!t||i(r)>i(t))&&(t=r);return(t??e.options[0])?.id??""}return{id:e.id,...e.label?{label:e.label}:{},options:e.options.map(({id:t,label:e})=>({id:t,...e?{label:e}:{}})),current:s,apply(i){let l=e.options.find(t=>t.id===i);if(!l)return;let a=r(),c=a.style;o??={option:s(),colorScheme:c?.colorScheme??""};for(let o of e.options)if(o!==l){a.classList.remove(...t(o));for(let[t,e]of Object.entries(o.attribute??{}))a.getAttribute(t)===e&&!(t in(l.attribute??{}))&&a.removeAttribute(t)}a.classList.add(...t(l));for(let[t,e]of Object.entries(l.attribute??{}))a.setAttribute(t,e);e.colorScheme&&c&&(c.colorScheme=i===o.option?o.colorScheme:l.colorScheme??l.id)}}}export{e as classTheme};
1
+ var e=e=>(Array.isArray(e.class)?e.class:[e.class??""]).flatMap(e=>e.split(/\s+/)).filter(Boolean);function t(t){let o,r=t.target??(()=>document.documentElement),i=t=>e(t).length+Object.keys(t.attribute??{}).length,l=(t,o)=>e(o).every(e=>t.classList.contains(e))&&Object.entries(o.attribute??{}).every(([e,o])=>t.getAttribute(e)===o);function s(){let e,o=r();for(let r of t.options)l(o,r)&&(!e||i(r)>i(e))&&(e=r);return(e??t.options[0])?.id??""}return{id:t.id,...t.label?{label:t.label}:{},options:t.options.map(({id:e,label:t})=>({id:e,...t?{label:t}:{}})),current:s,subscribe(e){let t=s(),o=new MutationObserver(()=>{let o=s();o!==t&&(t=o,e())});return o.observe(r(),{attributes:!0}),()=>o.disconnect()},apply(i){let l=t.options.find(e=>e.id===i);if(!l)return;let n=r(),c=n.style;o??={option:s(),colorScheme:c?.colorScheme??""};for(let o of t.options)if(o!==l){n.classList.remove(...e(o));for(let[e,t]of Object.entries(o.attribute??{}))n.getAttribute(e)===t&&!(e in(l.attribute??{}))&&n.removeAttribute(e)}n.classList.add(...e(l));for(let[e,t]of Object.entries(l.attribute??{}))n.setAttribute(e,t);t.colorScheme&&c&&(c.colorScheme=i===o.option?o.colorScheme:l.colorScheme??l.id)}}}export{t as classTheme};
@@ -1 +1 @@
1
- function e(e){return e instanceof HTMLElement||e instanceof SVGElement}var t=["top","right","bottom","left"],r={padding:t.map(e=>`padding-${e}`),margin:t.map(e=>`margin-${e}`),gap:["row-gap","column-gap"],"border-radius":["top-left","top-right","bottom-right","bottom-left"].map(e=>`border-${e}-radius`),"border-width":t.map(e=>`border-${e}-width`),"border-color":t.map(e=>`border-${e}-color`)},n=e=>(Array.isArray(e)?e:[e]).flatMap(e=>e.split(/\s+/)).filter(Boolean),a=e=>e.getAttribute("class"),l=e=>e.includes(":")?null:e.replace(/^!|!$/g,"");function i(e,t={}){let r,n=0;for(let[a,l]of Object.entries(e.values??{})){let e=a.split("+");e.every(e=>{let[r,n]=e.split("=");return void 0===n?Object.values(t).includes(r):t[r]===n})&&e.length>n&&([r,n]=[l,e.length])}return r??e.value??""}function s(t,s={}){let o=t.tokens.map(e=>({token:e,classes:n(e.class),covers:new Set(e.properties.flatMap(e=>[e,...r[e]??[]]))})),p=new Map;for(let e of o)for(let t of e.classes)p.set(t,e);let g=new Map(o.map(e=>[e.token.path,e])),d=!1===s.offToken?[]:s.offToken??[...new Set(t.tokens.flatMap(e=>e.properties))],c=new WeakMap,u=e=>(e??"").split(/\s+/).flatMap(e=>{let t=l(e),r=t?p.get(t):void 0;return r?[{name:e,entry:r}]:[]});function f(e,t){if(!t.stack.length)return null===t.original?e.removeAttribute("class"):e.setAttribute("class",t.original),void c.delete(e);e.setAttribute("class",t.stack.reduce((e,t)=>function(e,t,n){let a=e.split(/\s+/).filter(Boolean),i=n.classes[0],s=-1,o=a.filter((e,a)=>{let i=l(e),o=i?p.get(i):void 0,g=!!o&&(o===n||[...o.covers].every(e=>n.covers.has(e))&&(o.covers.has(t)||(r[t]??[]).some(e=>o.covers.has(e))));return g&&s<0&&(s=a),!g}),g=a.slice(0,s<0?a.length:s).filter(e=>o.includes(e)).length;return o.splice(g,0,i),o.join(" ")}(e,t.property,t.entry),t.original??""))}return{id:"tailwind",list(e){let t=e??Object.fromEntries((s.themes??[]).map(e=>[e.id,e.current()]));return o.map(({token:e,classes:r})=>({path:e.path,type:e.type,value:i(e,t),properties:[...e.properties],ref:r[0],...e.label?{label:e.label}:{},...e.group?{group:e.group}:{},...e.description?{description:e.description}:{},...e.states?{states:[...e.states]}:{}}))},resolve(t){let n,l={},i=function(e){let t=new Map;for(let r of u(e))for(let e of r.entry.covers){let n=t.get(e);(!n||r.entry.covers.size<=n.entry.covers.size)&&t.set(e,r)}for(let[e,n]of t)r[e]?.some(e=>t.get(e)?.entry!==n.entry)&&t.delete(e);return t}(a(t));if(e(t)){for(let[e,r]of i){let n=t.style.getPropertyValue(e),a=r.name.startsWith("!")||r.name.endsWith("!");n&&(!a||"important"===t.style.getPropertyPriority(e))&&i.delete(e)}for(let[e,t]of i)r[e]?.some(e=>i.get(e)?.entry!==t.entry)&&i.delete(e)}for(let[e,t]of i)l[e]={path:t.entry.token.path};for(let e of d){if(i.has(e)||r[e]?.some(e=>i.has(e)))continue;n??=getComputedStyle(t);let a=n.getPropertyValue(e);a&&(l[e]={offToken:a})}return l},preview(t,r,n){let l=g.get(n.path);if(!l)return()=>{};let i=c.get(t)??{original:a(t),stack:[],inline:new Map};c.set(t,i),e(t)&&(i.inline.has(r)||i.inline.set(r,function(e,t){let r=e.getAttribute("style"),n=e.style.cssText,a=e.style.getPropertyValue(t),l=e.style.getPropertyPriority(t),i=getComputedStyle(e).getPropertyValue(t).trim(),s=r=>{let n=e.ownerDocument.createElement("span").style;return n.cssText=r,n.setProperty(t,""),n.cssText},o=s(n);return{value:a,priority:l,computed:i,restore(){s(e.style.cssText)===o?null===r?(e.getAttribute("style"),e.removeAttribute("style")):e.setAttribute("style",r):(e.style.setProperty(t,a,l),null===r&&!e.style.length&&function(e){e.style.length||(e.getAttribute("style"),e.removeAttribute("style"))}(e))}}}(t,r)),t.style.setProperty(r,""));let s={property:r,entry:l};return i.stack.push(s),f(t,i),()=>{let e=i.stack.indexOf(s);e<0||(i.stack.splice(e,1),f(t,i),i.stack.some(e=>e.property===r)||(i.inline.get(r)?.restore(),i.inline.delete(r)))}},describe(e,t,r,n){let l=g.get(n.path)?.classes[0]??n.ref??n.path;if("path"in r){let t=g.get(r.path),n=c.get(e)?.original??a(e),i=u(n).find(e=>e.entry===t)?.name??t?.classes[0]??r.path;return i===l?`Keep class "${l}"`:`Replace class "${i}" with "${l}"`}return`Add class "${l}"`}}}var o={p:["Padding",["padding"]],px:["Padding",["padding-left","padding-right"]],py:["Padding",["padding-top","padding-bottom"]],pt:["Padding",["padding-top"]],pr:["Padding",["padding-right"]],pb:["Padding",["padding-bottom"]],pl:["Padding",["padding-left"]],m:["Margin",["margin"]],mx:["Margin",["margin-left","margin-right"]],my:["Margin",["margin-top","margin-bottom"]],mt:["Margin",["margin-top"]],mr:["Margin",["margin-right"]],mb:["Margin",["margin-bottom"]],ml:["Margin",["margin-left"]],gap:["Gap",["gap"]],"gap-x":["Gap",["column-gap"]],"gap-y":["Gap",["row-gap"]]},p=[0,.5,1,1.5,2,2.5,3,3.5,4,5,6,7,8,9,10,11,12,14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96];function g(e={}){let t=e.scale??4,r=e.steps??p;return(e.prefix??Object.keys(o)).flatMap(e=>{let n=o[e];if(!n)throw new Error(`komo: unknown spacing prefix "${e}"`);return r.map(r=>{let a=`${e}-${r}`;return{path:`spacing.${a}`,type:"dimension",class:a,properties:n[1],value:r*t+"px",group:n[0],label:a}})})}export{p as defaultSpacingSteps,g as tailwindSpacing,s as tailwindTokens,i as tokenValue};
1
+ function e(e){return e instanceof HTMLElement||e instanceof SVGElement}var t=["top","right","bottom","left"],r={padding:t.map(e=>`padding-${e}`),margin:t.map(e=>`margin-${e}`),gap:["row-gap","column-gap"],"border-radius":["top-left","top-right","bottom-right","bottom-left"].map(e=>`border-${e}-radius`),"border-width":t.map(e=>`border-${e}-width`),"border-color":t.map(e=>`border-${e}-color`)},n=e=>(Array.isArray(e)?e:[e]).flatMap(e=>e.split(/\s+/)).filter(Boolean),a=e=>e.getAttribute("class"),l=e=>e.includes(":")?null:e.replace(/^!|!$/g,"");function i(e,t={}){let r,n=0;for(let[a,l]of Object.entries(e.values??{})){let e=a.split("+");e.every(e=>{let[r,n]=e.split("=");return void 0===n?Object.values(t).includes(r):t[r]===n})&&e.length>n&&([r,n]=[l,e.length])}return r??e.value??""}function s(t,s={}){let o=t.tokens.map(e=>({token:e,classes:n(e.class),covers:new Set(e.properties.flatMap(e=>[e,...r[e]??[]]))})),p=new Map;for(let e of o)for(let t of e.classes)p.set(t,e);let g=new Map(o.map(e=>[e.token.path,e])),d=!1===s.offToken?[]:s.offToken??[...new Set(t.tokens.flatMap(e=>e.properties))],c=new WeakMap,u=e=>(e??"").split(/\s+/).flatMap(e=>{let t=l(e),r=t?p.get(t):void 0;return r?[{name:e,entry:r}]:[]});function f(e,t){if(!t.stack.length)return null===t.original?e.removeAttribute("class"):e.setAttribute("class",t.original),void c.delete(e);e.setAttribute("class",t.stack.reduce((e,t)=>function(e,t,n){let a=e.split(/\s+/).filter(Boolean),i=n.classes[0],s=-1,o=a.filter((e,a)=>{let i=l(e),o=i?p.get(i):void 0,g=!!o&&(o===n||[...o.covers].every(e=>n.covers.has(e))&&(o.covers.has(t)||(r[t]??[]).some(e=>o.covers.has(e))));return g&&s<0&&(s=a),!g}),g=a.slice(0,s<0?a.length:s).filter(e=>o.includes(e)).length;return o.splice(g,0,i),o.join(" ")}(e,t.property,t.entry),t.original??""))}return{id:"tailwind",list(e){let t=e??Object.fromEntries((s.themes??[]).map(e=>[e.id,e.current()]));return o.map(({token:e,classes:r})=>({path:e.path,type:e.type,value:i(e,t),properties:[...e.properties],ref:r[0],...e.label?{label:e.label}:{},...e.group?{group:e.group}:{},...e.description?{description:e.description}:{},...e.states?{states:[...e.states]}:{}}))},resolve(t){let n,l={},i=function(e){let t=new Map;for(let r of u(e))for(let e of r.entry.covers){let n=t.get(e);(!n||r.entry.covers.size<=n.entry.covers.size)&&t.set(e,r)}for(let[e,n]of t)r[e]?.some(e=>t.get(e)?.entry!==n.entry)&&t.delete(e);return t}(a(t));if(e(t)){for(let[e,r]of i){let n=t.style.getPropertyValue(e),a=r.name.startsWith("!")||r.name.endsWith("!");n&&(!a||"important"===t.style.getPropertyPriority(e))&&i.delete(e)}for(let[e,t]of i)r[e]?.some(e=>i.get(e)?.entry!==t.entry)&&i.delete(e)}for(let[e,t]of i)l[e]={path:t.entry.token.path};for(let e of d){if(i.has(e)||r[e]?.some(e=>i.has(e)))continue;n??=getComputedStyle(t);let a=n.getPropertyValue(e);a&&(l[e]={offToken:a})}return l},preview(t,r,n){let l=g.get(n.path);if(!l)return()=>{};let i=c.get(t)??{original:a(t),stack:[],inline:new Map};c.set(t,i),e(t)&&(i.inline.has(r)||i.inline.set(r,function(e,t){let r=e.getAttribute("style"),n=e.style.cssText,a=e.style.getPropertyValue(t),l=e.style.getPropertyPriority(t),i=getComputedStyle(e).getPropertyValue(t).trim(),s=r=>{let n=e.ownerDocument.createElement("span").style;return n.cssText=r,n.setProperty(t,""),n.cssText},o=s(n);return{value:a,priority:l,computed:i,absent:null===r,restore(){s(e.style.cssText)===o?null===r?(e.getAttribute("style"),e.removeAttribute("style")):e.setAttribute("style",r):(e.style.setProperty(t,a,l),null===r&&!e.style.length&&function(e){e.style.length||(e.getAttribute("style"),e.removeAttribute("style"))}(e))}}}(t,r)),t.style.setProperty(r,""));let s={property:r,entry:l};return i.stack.push(s),f(t,i),()=>{let e=i.stack.indexOf(s);e<0||(i.stack.splice(e,1),f(t,i),i.stack.some(e=>e.property===r)||(i.inline.get(r)?.restore(),i.inline.delete(r)))}},describe(e,t,r,n){let l=g.get(n.path)?.classes[0]??n.ref??n.path;if("path"in r){let t=g.get(r.path),n=c.get(e)?.original??a(e),i=u(n).find(e=>e.entry===t)?.name??t?.classes[0]??r.path;return i===l?`Keep class "${l}"`:`Replace class "${i}" with "${l}"`}return`Add class "${l}"`}}}var o={p:["Padding",["padding"]],px:["Padding",["padding-left","padding-right"]],py:["Padding",["padding-top","padding-bottom"]],pt:["Padding",["padding-top"]],pr:["Padding",["padding-right"]],pb:["Padding",["padding-bottom"]],pl:["Padding",["padding-left"]],m:["Margin",["margin"]],mx:["Margin",["margin-left","margin-right"]],my:["Margin",["margin-top","margin-bottom"]],mt:["Margin",["margin-top"]],mr:["Margin",["margin-right"]],mb:["Margin",["margin-bottom"]],ml:["Margin",["margin-left"]],gap:["Gap",["gap"]],"gap-x":["Gap",["column-gap"]],"gap-y":["Gap",["row-gap"]]},p=[0,.5,1,1.5,2,2.5,3,3.5,4,5,6,7,8,9,10,11,12,14,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96];function g(e={}){let t=e.scale??4,r=e.steps??p;return(e.prefix??Object.keys(o)).flatMap(e=>{let n=o[e];if(!n)throw new Error(`komo: unknown spacing prefix "${e}"`);return r.map(r=>{let a=`${e}-${r}`;return{path:`spacing.${a}`,type:"dimension",class:a,properties:n[1],value:r*t+"px",group:n[0],label:a}})})}export{p as defaultSpacingSteps,g as tailwindSpacing,s as tailwindTokens,i as tokenValue};
@@ -0,0 +1 @@
1
+ import{e,g as t}from"./chunk-WNJLJD4A.js";import{a as r}from"./chunk-RPY7OOOR.js";var n=new Map,o=new Map,a=new WeakMap,i=new WeakMap,s=new Map,l=new WeakMap,f=!1;function u(e,t){let r=o.get(e);r?.delete(t),r?.size||o.delete(e)}function p(t,s,l,f,u){let p=a.get(t);if(p||a.set(t,p=new Map),(!p.has(s)||!n.has(t)&&!o.has(t))&&(p.set(s,l),r(t))){let r=i.get(t);r||i.set(t,r=new Map);let n=e(t,s),o=!!n.value&&$(n.value)===$(n.computed),a=r.get(s);if(a?.adapter===f)a.original=n,a.concrete=o;else{let e={adapter:f,original:n,concrete:o,style:n,token:void 0};e.style={get value(){let r=e.original;if(!e.concrete||!e.token)return r.value;let n=t.ownerDocument.createElement("span").style;return n.setProperty(s,e.token.value),n.getPropertyValue(s)||r.value},get priority(){return e.original.priority},get absent(){return e.original.absent},get computed(){return e.token?.value??e.original.computed},restore(){let r=e.original;r.restore(),e.concrete&&e.token&&$(e.token.value)!==$(r.value)&&t.style.setProperty(s,e.token.value,r.priority)}},r.set(s,e)}}return g(t,f,u),p.get(s)}function c(e,t){return e?a.get(e)?.get(t):void 0}function g(e,t,r,n){let o=n&&new Set(n);for(let[n,a]of i.get(e)??[]){if(a.adapter!==t)continue;let i=c(e,n);a.token=i&&"path"in i?r.find(e=>e.path===i.path):void 0,a.token&&o?.has(n)&&a.style.restore()}}function d(e,t,r){if(o.get(e)?.has(t))return{offToken:getComputedStyle(e).getPropertyValue(t).trim()};let n=A(e,t);return n?{path:n.path}:r}function h(e,t){if(!a.get(e)?.has(t))return;let r=o.get(e),n=r?.has(t)??!1,i=a.get(e)?.get(t),s=!!A(e,t)||!!i&&"path"in i;return r||o.set(e,r=new Set),r.add(t),{priority:"important",...!n&&s?{undo:()=>{u(e,t),f||(L(!0),L(!1))}}:{}}}function m(e,t){return i.get(e)?.get(t)?.style??n.get(e)?.find(e=>e.property===t)?.inline}function y(e){let t={};for(let r of e?.themes??[])try{t[r.id]=r.current()}catch{}return t}function v(e,t,r,n){if(n.aborted||!e?.themes?.length)return;let o=JSON.stringify(y(e)),a=()=>{let t=JSON.stringify(y(e));t===o||n.aborted||(o=t,r())},i=[],s=!1;for(let t of e.themes)try{t.subscribe?i.push(t.subscribe(a)):s=!0}catch{s=!0}let l=s?new MutationObserver(a):void 0;l?.observe(t.documentElement,{attributes:!0}),t.body&&l?.observe(t.body,{attributes:!0}),n.addEventListener("abort",()=>{l?.disconnect();for(let e of i)e()},{once:!0})}function k(e,t={}){let r=l.get(e);r||l.set(e,r=new Map);let n=JSON.stringify(Object.entries(t).sort()),o=r.get(n);return o||(o=Promise.resolve().then(()=>e.list(Object.keys(t).length?t:void 0)).then(e=>Array.isArray(e)?e.filter(e=>e&&"string"==typeof e.path):[]),o.catch(()=>r.delete(n)),r.set(n,o)),o}function b(e,t){return Promise.resolve().then(()=>e.resolve(t)).then(e=>e??{},()=>({}))}function w(e,t){return e.filter(e=>e.properties?.includes(t))}function $(e){let t,r=e.trim().toLowerCase().replace(/\s+/g," "),n=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/.exec(r)?.[1];if(n)t=(n.length<5?[...n].map(e=>e+e).join(""):n).match(/../g).map((e,t)=>parseInt(e,16)/(t>2?255:1));else{let e=/^rgba?\(([^)]*)\)$/.exec(r)?.[1].split(/\s*[,/]\s*|\s+/);e&&(3===e.length||4===e.length)&&e.every(e=>/^[\d.]+%?$/.test(e))&&(t=e.map((e,t)=>parseFloat(e)*(e.endsWith("%")?t>2?.01:2.55:1)))}if(!t)return r.replace(/\s*,\s*/g,",");let[o,a,i,s=1]=t.map((e,t)=>t>2?+e.toFixed(2):Math.round(e));return 1===s?`rgb(${o},${a},${i})`:`rgba(${o},${a},${i},${s})`}function M(e,t){let r=$(t);return r?e.find(e=>"string"==typeof e.value&&$(e.value)===r):void 0}function S(e){return e.label||e.path}function j(e,t=e.value,r){return[e.path,e.ref,t,r,e.states?.length?`States: ${e.states.join(", ")}`:"",e.description].filter(Boolean).join(" · ")}function O(){let e=document.createElement("span");return e.className="design-token-off",e.setAttribute("role","img"),e}function P(e,t,r){e.title=`Not from a token · ${t||"unset"}${r?` · matches ${S(r)}`:""}`,e.setAttribute("aria-label",e.title)}function T(n,o,a,i){let s=r(o)?e(o,a):void 0;try{r(o)&&o.style.setProperty(a,"");let e=n.preview?n.preview(o,a,i):t(o,a,i.value),l=!0;return()=>{l&&(l=!1,e?.(),s?.restore())}}catch{throw s?.restore(),new Error("This token could not be previewed.")}}function A(e,t){if(!o.get(e)?.has(t))return[...n.get(e)??[]].reverse().find(e=>e.property===t)?.token}function E(t,a,i,s,l,f){let p=n.get(a);p||n.set(a,p=[]);let c=p.find(e=>e.property===i),g=r(a)?e(a,i):void 0,d=o.get(a)?.has(i)??!1,h=T(t,a,i,s);return u(a,i),p.push({adapter:t,property:i,token:s,from:c?.from??l,fromToken:c?c.fromToken:f,undo:h,inline:g,customBefore:d}),()=>N(a)}function N(e){let t=n.get(e),r=t?.pop();if(r?.undo(),r?.customBefore){let t=o.get(e);t||o.set(e,t=new Set),t.add(r.property)}else r&&u(e,r.property);t&&!t.length&&n.delete(e)}function x(e){return!!n.get(e)?.length}function J(e){return!!o.get(e)?.size}function W(e){for(;n.has(e);)N(e);o.delete(e)}function B(){for(let e of[...n.keys()])W(e);o.clear(),s.clear()}function z(e){return[...new Set(n.get(e)?.map(e=>e.property))].filter(t=>!o.get(e)?.has(t))}function L(t){if(t!==f){f=t,t&&(s=new Map([...o].flatMap(([t,n])=>r(t)?[[t,new Map([...n].map(r=>[r,e(t,r)]))]]:[])));for(let[o,a]of n)if(t)for(let e of[...a].reverse())e.undo();else for(let t of a)t.customBefore&&t.inline?.restore(),r(o)&&(t.inline=e(o,t.property)),t.undo=T(t.adapter,o,t.property,t.token);if(!t){for(let e of s.values())for(let t of e.values())t.restore();s.clear()}}}function C(e,t){let r=f;r||L(!0);for(let r of new Set([...n.keys(),...o.keys()])){let a=[...(n.get(r)??[]).filter(t=>t.adapter===e).map(e=>e.property),...o.get(r)??[]];g(r,e,t,a)}for(let r of n.values())for(let n of r)n.adapter===e&&(n.token=t.find(e=>e.path===n.token.path)??n.token,"path"in n.from&&(n.fromToken=t.find(e=>e.path===n.from.path)));r||L(!1)}function D(e,t){try{let r=t.adapter.describe?.(e,t.property,t.from,t.token);return r?String(r).replace(/\s+/g," ").replace(/→/g,"->").trim().slice(0,300):void 0}catch{return}}function F(e){let t=[],r=new Set;for(let a of function(e){let t=new Map;for(let r of n.get(e)??[])t.set(r.property,r);return[...t.values()].filter(t=>!(o.get(e)?.has(t.property)||"path"in t.from&&t.from.path===t.token.path))}(e)){r.add(a.adapter.id);let n="path"in a.from?`${a.fromToken?.value?`${a.fromToken.value} `:""}[${a.from.path}]`:a.from.offToken||"(unset)";t.push(`Element ${a.property}: ${n} → ${a.token.value} [${a.token.path}]`);let o=D(e,a);o&&t.push(`Apply: ${o}`)}if(t.length)return["Proposed design-token changes (preview only)",...t,`Token adapter: ${[...r].join(", ")}`].join("\n")}export{p as a,c as b,g as c,d,h as e,m as f,y as g,v as h,k as i,b as j,w as k,M as l,S as m,j as n,O as o,P as p,T as q,A as r,E as s,x as t,J as u,W as v,B as w,z as x,L as y,C as z,F as A};