@zeroxsolutions/zaku 0.0.0-stage → 0.0.3
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/LICENSE +21 -0
- package/README.md +22 -2
- package/dist/rules.js +1 -0
- package/dist/zaku.mjs +58840 -0
- package/package.json +189 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zeroxsolutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zeroxsolutions/zaku
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `zaku` command: checks a product's committed design data (`docs/design`) against its code, and
|
|
4
|
+
prints the rules script a Figma write runs through Figma's MCP server. The zaku plugin in
|
|
5
|
+
[agent-plugins](https://github.com/zeroxsolutions/agent-plugins/tree/master/plugins/zaku) runs this
|
|
6
|
+
package through `npx`, pinned to one version, and so can CI or a harness without the plugin.
|
|
7
|
+
Published as `@zeroxsolutions/zaku-cli` up to 0.0.1.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx -y @zeroxsolutions/zaku check
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
| Command | What it does |
|
|
14
|
+
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `zaku check` | runs every check over the committed design files; exits 0, 1 on a finding, 2 on an error |
|
|
16
|
+
| `zaku rules script --page <page>` | prints a `use_figma` body that runs the rules over one page |
|
|
17
|
+
| `zaku rules script --page <page> --after <f>` | prints one body that runs the write in `<f>`, then the rules, answering `{ value, rules }` |
|
|
18
|
+
| `zaku check --input <answer.json>` | reads what `use_figma` returned for either body |
|
|
19
|
+
| `zaku outline`, `zaku library` | read the product file and the library over Figma's REST API (`FIGMA_TOKEN`) |
|
|
20
|
+
| `zaku tokens`, `zaku recipe` | write what the code computes, for the checks to compare |
|
|
21
|
+
| `zaku mcp` | serves `use_figma` and `get_screenshot` over stdio, through the zaku Figma plugin, when Figma's MCP server drops a call |
|
|
22
|
+
|
|
23
|
+
`zaku recipe` drives a browser and needs `playwright`, an optional peer dependency. Node 22 or later.
|
package/dist/rules.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var zakuRulesLib=(()=>{var L=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Se=(e,t)=>{for(var n in t)L(e,n,{get:t[n],enumerable:true})};var Ie=(e,t,n,s)=>{if(t&&typeof t==="object"||typeof t==="function"){for(let r of Te(t))if(!Ne.call(e,r)&&r!==n)L(e,r,{get:()=>t[r],enumerable:!(s=be(t,r))||s.enumerable})}return e};var Oe=e=>Ie(L({},"__esModule",{value:true}),e);var Nt={};Se(Nt,{REPLY_BYTES:()=>F,scopeNodes:()=>Ee,zakuRules:()=>Tt});var V={locales:["en"],currencies:[]};var Y=new Set(["characters","name","componentProperties","componentPropertyReferences","exposedInstances"]);var W=new Set(["primaryAxisSizingMode","counterAxisSizingMode"]);function K(e,t,n){if(!t||!n||e!=="width"&&e!=="height")return false;return Math.abs(t[e]-n[e])<.5}function q(e){return e.horizontal!=="FIXED"||e.vertical!=="FIXED"}var Z="['’]";var J=[{pattern:/\bdelv(?:e|es|ed|ing)\b/iu,instead:'write "look at" or "read"'},{pattern:/\bleverag(?:e|es|ed|ing)\b/iu,instead:'write "use"'},{pattern:/\butili[sz](?:e|es|ed|ing|ation)\b/iu,instead:'write "use"'},{pattern:/\brobust(?:ly|ness)?\b/iu,instead:"write what it withstands"},{pattern:/\btapestr(?:y|ies)\b/iu,instead:'write "mix", or name the parts'},{pattern:/\btestaments?\b/iu,instead:'write "proof", or the fact itself'},{pattern:/\bvibrant(?:ly)?\b/iu,instead:'write "busy", or what is there'},{pattern:/\bempower(?:s|ed|ing|ment)?\b/iu,instead:'write "let" or "allow"'},{pattern:/\bunlock(?:s|ed|ing)?\b/iu,instead:'write "get" or "open"'},{pattern:/\bunleash(?:es|ed|ing)?\b/iu,instead:'write "use" or "start"'},{pattern:/\bgame[- ]?changers?\b/iu,instead:"write what it changes"},{pattern:/\bsupercharg(?:e|es|ed|ing)\b/iu,instead:'write "speed up", with the figure'},{pattern:new RegExp(`\\blet${Z}s\\b`,"iu"),instead:'write the action itself, such as "Plan a trip"'},{pattern:new RegExp(`\\b(?:it${Z}s|it is) (?:important|worth|crucial) (?:to note|noting)\\b`,"iu"),instead:"delete it"},{pattern:/\bin order to\b/iu,instead:'write "to"'},{pattern:/\bnot (?:just|only|merely)\b[^.!?]{0,80}?\bbut\b/iu,instead:"write the second half on its own"}];var Q={en:J};var Ae=/^[\x20-\x7e]$/;var ve=new RegExp(`^[${String.fromCharCode(10,8232)}]$`);var xe=/^[\p{L}\p{M}]$/u;var Ce=/^(?=\p{M})\p{Script=Inherited}$/u;var Re=/^\p{Extended_Pictographic}$/u;var $e=new RegExp("^[←-⇿⟰-⟿⤀-⥿⬀-⬑]$","u");var Me=new Map([["—",{name:"em dash",instead:'write "-", or two sentences'}],["–",{name:"en dash",instead:'write "-", or two sentences'}],["‘",{name:"left single quotation mark",instead:"write '"}],["’",{name:"right single quotation mark",instead:"write '"}],["“",{name:"left double quotation mark",instead:'write "'}],["”",{name:"right double quotation mark",instead:'write "'}],["…",{name:"horizontal ellipsis",instead:'write "..."'}],["·",{name:"middle dot",instead:'write "-", "," or ":"'}],["•",{name:"bullet",instead:'write "-", "," or ":"'}],["→",{name:"rightwards arrow",instead:'write "->"'}],["←",{name:"leftwards arrow",instead:'write "<-"'}],["×",{name:"multiplication sign",instead:'write "x"'}],[String.fromCharCode(160),{name:"no-break space",instead:"write a space"}],[String.fromCharCode(8203),{name:"zero width space",instead:"write nothing"}],[String.fromCharCode(8204),{name:"zero width non-joiner",instead:"write nothing"}],[String.fromCharCode(8205),{name:"zero width joiner",instead:"write nothing"}],[String.fromCharCode(65279),{name:"zero width no-break space",instead:"write nothing"}]]);var ke={Jpan:["Han","Hiragana","Katakana"],Kore:["Hangul","Han"],Hans:["Han"],Hant:["Han"],Hanb:["Han","Bopomofo"]};function Pe(e,t){return e.flatMap(n=>["symbol","narrowSymbol"].flatMap(s=>new Intl.NumberFormat(n,{style:"currency",currency:t,currencyDisplay:s}).formatToParts(0).filter(r=>r.type==="currency").map(r=>r.value)))}function ze(e){const t=new Set(e.locales.flatMap(n=>{const s=new Intl.Locale(n).maximize().script??"";return ke[s]??[s]}));return{scripts:[...t].filter(Boolean),symbols:[...new Set(e.currencies.flatMap(n=>Pe(e.locales,n)))],languages:[...new Set(e.locales.map(n=>new Intl.Locale(n).language))]}}function ee(e,t){const n="scripts"in e?e:ze(e);return{scripts:n.scripts.map(s=>new RegExp(`^\\p{Script_Extensions=${s}}$`,"u")),extra:new Set([...n.symbols,...t].flatMap(s=>[...s.normalize("NFC")])),tells:n.languages.flatMap(s=>Q[s]??[])}}function Fe(e,t){if(Ae.test(e)||ve.test(e)||t.extra.has(e))return true;if(!xe.test(e))return false;return Ce.test(e)||t.scripts.some(n=>n.test(e))}function z(e){return`U+${(e.codePointAt(0)??0).toString(16).toUpperCase().padStart(4,"0")}`}function De(e){const t=Me.get(e);if(t)return`${z(e)} ${t.name}: ${t.instead}`;if(Re.test(e))return`${z(e)} emoji: write a word, or a library icon`;if($e.test(e))return`${z(e)} arrow: write "->" or "<-"`;return`${z(e)} is outside the locales and currencies copy names in zaku.yaml: write it in ASCII, or add its locale or currency there`}function H(e,t){const n=[];const s=new Set;for(const r of e.normalize("NFC")){if(s.has(r)||Fe(r,t))continue;s.add(r);n.push({field:"characters",message:De(r)})}for(const r of t.tells){const i=r.pattern.exec(e);if(i)n.push({field:"tone",message:`"${i[0]}": ${r.instead}`})}return n}var I={page:"Thumbnail",frame:"Thumbnail",width:1200,height:675,bleeds:"Glow",logo:"Logo",bleed:.25,margin:72};var k="❖ ";var _="Component for Docs";var T=(e,t,n)=>({mode:"VERTICAL",padding:e,gap:t,...n?{align:n}:{}});var v=(e,t,n)=>({mode:"HORIZONTAL",padding:e,gap:t,...n?{align:n}:{}});var b=[0,0,0,0];var P=[{path:["DS/Header"],where:"components",type:"COMPONENT",at:{x:0,y:0},width:1440,sizing:{horizontal:"FIXED",vertical:"HUG"},layout:v([48,40,40,40],48,["SPACE_BETWEEN","MAX"]),properties:[{name:"Eyebrow",type:"TEXT",default:"Components"},{name:"Component name",type:"TEXT",default:"Button"},{name:"Show style",type:"BOOLEAN",default:true},{name:"Definition",type:"TEXT",default:"Short description of the component and when to use it."}],paint:"fill color/background; bottom stroke 1 color/border"},{path:["DS/Header","Glow"],where:"components",type:"FRAME",at:{x:0,y:0},width:1440,height:193,paint:"no fill; absolute, not clipping; two radial ellipses, named and placed under the table"},{path:["DS/Header","Title block"],where:"components",type:"FRAME",sizing:{horizontal:"HUG",vertical:"HUG"},layout:T(b,12)},{path:["DS/Header","Title block","Eyebrow"],where:"components",type:"TEXT",font:{size:14,lineHeight:20,weight:"Regular"},text:"Components",paint:"color/muted-foreground"},{path:["DS/Header","Title block","Title"],where:"components",type:"TEXT",font:{size:36,lineHeight:40,weight:"ExtraBold"},text:"Button",paint:"color/foreground; tracking -2.5%"},{path:["DS/Header","Title block","Badges"],where:"components",type:"FRAME",sizing:{horizontal:"HUG",vertical:"HUG"},layout:v(b,8),paint:"no fill; holds one instance of the library's Badge, secondary, once it exists"},{path:["DS/Header","Description"],where:"components",type:"TEXT",width:480,font:{size:16,lineHeight:28,weight:"Regular"},text:"Short description of the component and when to use it.",paint:"color/muted-foreground"},{path:["DS/Section Heading"],where:"components",type:"COMPONENT",at:{x:0,y:273},width:1200,height:81,sizing:{horizontal:"FIXED",vertical:"HUG"},layout:T(b,8),properties:[{name:"Title",type:"TEXT",default:"Section title"},{name:"Description",type:"TEXT",default:"Section description."},{name:"Show description",type:"BOOLEAN",default:true}],paint:"no fill"},{path:["DS/Section Heading","h2"],where:"components",type:"FRAME",width:1200,height:45,sizing:{horizontal:"FILL",vertical:"HUG"},layout:T([0,0,8,0],0),paint:"bottom stroke 1 color/border, counted in the layout"},{path:["DS/Section Heading","h2","Title"],where:"components",type:"TEXT",font:{size:30,lineHeight:36,weight:"SemiBold"},text:"Section title",paint:"color/foreground; tracking -2.5%"},{path:["DS/Section Heading","Description"],where:"components",type:"TEXT",width:1200,sizing:{horizontal:"FILL"},font:{size:16,lineHeight:28,weight:"Regular"},text:"Section description.",paint:"color/muted-foreground; visible bound to Show description"},{path:["DS/Table Head"],where:"components",type:"COMPONENT",at:{x:0,y:418},width:200,height:40,sizing:{horizontal:"FIXED",vertical:"FIXED"},layout:T([0,8,0,8],0,["CENTER","MIN"]),properties:[{name:"Text",type:"TEXT",default:"Head"}],paint:"no fill"},{path:["DS/Table Head","Text"],where:"components",type:"TEXT",sizing:{horizontal:"FILL"},font:{size:14,lineHeight:20,weight:"Medium"},text:"Head",paint:"color/foreground"},{path:["DS/Table Cell"],where:"components",type:"COMPONENT_SET",at:{x:0,y:522},width:500,height:84,sizing:{horizontal:"FIXED",vertical:"HUG"},layout:{mode:"HORIZONTAL",padding:[24,24,24,24],gap:24,crossGap:24,wrap:true},properties:[{name:"Text",type:"TEXT",default:"Cell"},{name:"Emphasis",type:"VARIANT",default:"primary"}],paint:"radius 5; the dashed border Figma gives a set"},...["primary","muted"].flatMap((e,t)=>[{path:["DS/Table Cell",`Emphasis=${e}`],where:"components",type:"COMPONENT",at:{x:24+t*224,y:24},width:200,height:36,sizing:{horizontal:"FIXED",vertical:"HUG"},layout:T([8,8,8,8],0),paint:"no fill"},{path:["DS/Table Cell",`Emphasis=${e}`,"Text"],where:"components",type:"TEXT",sizing:{horizontal:"FILL"},font:{size:14,lineHeight:20,weight:e==="primary"?"Medium":"Regular"},text:"Cell",paint:e==="primary"?"color/foreground":"color/muted-foreground"}]),{path:["DS/List Item"],where:"components",type:"COMPONENT",at:{x:0,y:812},width:1176,height:28,sizing:{horizontal:"FIXED",vertical:"HUG"},layout:v(b,10),properties:[{name:"Text",type:"TEXT",default:"List item text."}],paint:"no fill"},{path:["DS/List Item","Bullet"],where:"components",type:"TEXT",sizing:{horizontal:"HUG"},font:{size:16,lineHeight:28,weight:"Regular"},text:"•",paint:"color/foreground"},{path:["DS/List Item","Text"],where:"components",type:"TEXT",sizing:{horizontal:"FILL"},font:{size:16,lineHeight:28,weight:"Regular"},text:"List item text.",paint:"color/foreground"},{path:["DS/Matrix Head"],where:"components",type:"COMPONENT",at:{x:0,y:988},width:120,height:40,sizing:{horizontal:"FIXED",vertical:"FIXED"},layout:T([0,8,0,8],0,["CENTER","CENTER"]),properties:[{name:"Text",type:"TEXT",default:"Prop=value"}],paint:"no fill"},{path:["DS/Matrix Head","Text"],where:"components",type:"TEXT",sizing:{horizontal:"HUG"},font:{size:12,lineHeight:16,weight:"Medium"},text:"Prop=value",paint:"color/muted-foreground"},{path:["*"],where:"view",type:"FRAME",width:1440,layout:T(b,0),paint:"fill color/background"},{path:["*","*"],where:"view",type:"INSTANCE",main:"DS/Header",width:1440},{path:["*","Body"],where:"view",type:"FRAME",width:1440,layout:T([48,120,96,120],64),paint:"no fill"},{path:["*","Body","*"],where:"view",type:"FRAME",width:1200,layout:T(b,24),paint:"no fill"},{path:["*","Body","*","Heading"],where:"view",type:"INSTANCE",main:"DS/Section Heading",width:1200},{path:["*","Body","Component","Preview"],where:"view",type:"FRAME",width:1200,layout:[v(b,24),T(b,40)],paint:"fill color/background, radius 14, no stroke; vertical for a set of text styles"},{path:["*","Body","Matrix","Matrix"],where:"view",type:"FRAME",width:1200,layout:T(b,0),paint:"stroke 1 color/border, radius 8"},{path:["*","Body","Matrix","Matrix","TableHeader"],where:"view",type:"FRAME",height:40,layout:v(b,0)},{path:["*","Body","Example","Preview"],where:"view",type:"FRAME",width:1200,layout:{mode:"HORIZONTAL",padding:[40,40,40,40],gap:48,crossGap:24,wrap:true},paint:"fill color/background, stroke 1 color/border, radius 14"},...["Variants","Sizes","Composition"].flatMap(e=>[{path:["*","Body",e,"Preview"],where:"view",type:"FRAME",width:1200,layout:v([40,40,40,40],24,["CENTER","CENTER"]),paint:"fill color/background, stroke 1 color/border, radius 14"},{path:["*","Body",e,"Preview",e],where:"view",type:"FRAME",sizing:{horizontal:"HUG",vertical:"HUG"},layout:{mode:"HORIZONTAL",padding:b,gap:12,crossGap:12,wrap:true,align:["MIN","CENTER"]},paint:"centred in the preview, hugging its row of instances"}]),{path:["*","Body","Anatomy","Anatomy layout"],where:"view",type:"FRAME",width:1200,layout:v(b,16)},{path:["*","Body","Anatomy","Anatomy layout","Preview"],where:"view",type:"FRAME",width:744,sizing:{horizontal:"FILL",vertical:"FILL"},layout:v([24,24,24,24],24,["CENTER","CENTER"]),paint:"fill color/background, stroke 1 color/border, radius 14"},{path:["*","Body","Anatomy","Anatomy layout","Cards"],where:"view",type:"FRAME",width:440,sizing:{horizontal:"FIXED",vertical:"HUG"},layout:{mode:"GRID",padding:b,gap:16,crossGap:16},paint:"one column, one Card per part"},{path:["*","Body","*","Table"],where:"view",type:"FRAME",width:1200,layout:T(b,0),paint:"stroke 1 color/border, radius 8"},{path:["*","Body","*","Table","TableHeader"],where:"view",type:"FRAME",height:40,layout:v(b,0),paint:"bottom stroke 1 color/border"},{path:["*","Body","*","Table","TableRow"],where:"view",type:"FRAME",layout:v(b,0),paint:"bottom stroke 1 color/border, none on the last"},{path:["*","Body","*","Table","TableRow","TableCell"],where:"view",type:"FRAME",layout:[T([8,8,8,8],0,["CENTER","CENTER"]),v([12,8,12,8],0,["MIN","CENTER"])],paint:"a foundation's preview cell, its column's width: vertical for a colour swatch, fill color/background, following the page's mode; horizontal for a spacing bar or a radius square, no fill"},{path:["*","Body","*","List"],where:"view",type:"FRAME",width:1200,layout:T([0,0,0,24],8)},{path:["*","Body","*","List","li"],where:"view",type:"INSTANCE",main:"DS/List Item",width:1176},{path:["*","Body","*","Cards"],where:"view",type:"FRAME",width:1200,layout:{mode:"GRID",padding:b,gap:16,crossGap:16}},{path:["*","Body","*","Cards","Card"],where:"view",type:"INSTANCE",width:592,paint:"the library's Card"},{path:["*","Body","Preview","Theme Preview"],where:"view",type:"FRAME",width:1200,layout:v(b,16)},{path:["*","Body","Preview","Theme Preview","Preview"],where:"view",type:"FRAME",layout:T([40,40,40,40],20),paint:"fill color/background, stroke 1 color/border, radius 14; no mode of its own"}];var Le="Icon";var He=["Color","Spacing","Radius"];var G="DS/Header";var te="Body";var oe="Preview";var R=e=>({name:e,required:true});var C=e=>({name:e});var ne={key:"table",label:"the table shape",sections:[R("Example"),C("Properties"),C("Specs"),R("Usage"),R("Accessibility"),R(oe)]};var _e={icons:{kind:"icons",noun:"icon set's view",pages:["icon set"],frame:()=>"Icons",eyebrow:"Foundations",eyebrowOwner:"the icon set's view's",badge:{counts:"48 icons, lucide-react"},badgeOwner:"the icon set's view's",shapes:[{label:"the icon set's view",sections:[{name:"Icons section",required:true,repeats:true}]}]},foundation:{kind:"foundation",noun:"foundation view",pages:["foundation"],frame:e=>e,eyebrow:"Foundations",eyebrowOwner:"a foundation's",badge:{counts:"31 tokens, Light and Dark"},badgeOwner:"a foundation view's",shapes:null},foundationGuidance:{kind:"foundationGuidance",noun:"foundation's guidance view",pages:["foundation","icon set"],frame:e=>`${e} / Guidance`,eyebrow:"Foundations",eyebrowOwner:"a foundation's",badge:{reads:"Guidance"},badgeOwner:"a guidance view's",shapes:[ne]},component:{kind:"component",noun:"component view",pages:["entry"],frame:e=>e,eyebrow:"Components",eyebrowOwner:"an entry's",badge:{counts:"192 variants"},badgeOwner:"a component view's",shapes:[{label:"a component view",sections:[R("Component"),C("Matrix")]}]},guidance:{kind:"guidance",noun:"guidance view",pages:["entry"],frame:e=>`${e} / Guidance`,eyebrow:"Components",eyebrowOwner:"an entry's",badge:{reads:"Guidance"},badgeOwner:"a guidance view's",shapes:[ne,{key:"parts",label:"the parts shape",sections:[C("Anatomy"),C("Variants"),C("Sizes"),C("Composition"),C("Properties"),R("Usage"),C("Behavior & content"),R("Accessibility"),R(oe)]}]}};var Ge=/^[0-9][0-9,.]*\s+\S/;function Be(e){if(e===Le)return"icon set";return He.includes(e)?"foundation":"entry"}function Xe(e,t){if(!e.startsWith(k))return null;const n=e.slice(k.length);const s=Be(n);return Object.values(_e).find(r=>r.pages.includes(s)&&r.frame(n)===t)??null}var ie=e=>e.sections.map(t=>t.name).join(", ");function je(e,t,n){const s=[];const r=d=>t.some(g=>g.sections.some(l=>l.name===d));for(const d of n.filter((g,l)=>!r(g)&&n.indexOf(g)===l)){const g=t.length===1?ie(t[0]):`those of ${t.map(l=>`${l.label} (${ie(l)})`).join(" or of ")}`;s.push(`holds ${d}, which no ${e.noun} holds; its sections are ${g}`)}const i=n.filter(r);const u=d=>t.filter(g=>g.sections.some(l=>l.name===d));const c=i.find(d=>u(d).length===1);const p=(c?u(c)[0]:void 0)??t.find(d=>d.sections.every(g=>!g.required||i.includes(g.name)))??t[0];const o=p.sections.map(d=>d.name);let h=-1;let a="";for(const d of i){const g=o.indexOf(d);if(g===-1){s.push(`holds ${d}, a section of ${u(d)[0]?.label}, beside ${c} of ${p.label}`);continue}const l=g===h&&p.sections[g]?.repeats===true;if(g<h||g===h&&!l)s.push(`holds ${d} after ${a}; ${p.label} orders them ${o.join(", ")}`);else{h=g;a=d}}for(const d of p.sections)if(d.required&&!i.includes(d.name))s.push(`holds no ${d.name}, which ${p.label} always holds`);return s}function re(e,t){const n=[];const s=c=>e.filter(p=>p.parentId===c);const r=c=>{const p=[c];if(c.type!=="INSTANCE")for(const o of s(c.id))p.push(...r(o));return p};const i=(c,p)=>{for(let o=t.get(c.parentId??"");o;o=t.get(o.parentId??""))if(o===p)return true;return false};const u=(c,p)=>{const o=[];for(let h=p;h&&h!==c;h=t.get(h.parentId??""))o.unshift(h.name);return[c.name,...o].join(" / ")};for(const c of e){if(c.type!=="FRAME"||!c.page||c.parentId!==c.page.id)continue;const p=Xe(c.page.name,c.name);if(!p)continue;const o=(w,A,N=c)=>{n.push({nodeId:N.id,field:w,message:`${u(c,N)}: ${A}`})};const h=s(c.id);const a=h[0];if(a&&(a.type!=="INSTANCE"||a.main!==G))o("header",`opens on ${a.name}, and a view opens on a ${G} instance`);const d=h.find(w=>w.type==="INSTANCE"&&w.main===G);const g=d?.values;if(d&&g){const w=g["Eyebrow"];if(w!==void 0&&w!==p.eyebrow)o("eyebrow",`the eyebrow reads "${String(w)}", and ${p.eyebrowOwner} reads "${p.eyebrow}"`);if(g["Show style"]===false)o("show style","the header's Show style is off, and a view's header shows its badge")}const l=d?e.find(w=>w.type==="INSTANCE"&&t.get(w.parentId??"")?.name==="Badges"&&i(w,d)):void 0;const f=l?.values?.["Label"];if(typeof f==="string"){const w=p.badge;if("reads"in w&&f!==w.reads)o("badge",`the badge reads "${f}", and ${p.badgeOwner} reads "${w.reads}"`);if("counts"in w&&!Ge.test(f))o("badge",`the badge reads "${f}", and ${p.badgeOwner} counts what it shows ("${w.counts}")`)}const E=h.find(w=>w.type==="FRAME"&&w.name===te);if(!E){o("sections",`holds no ${te}, the frame its sections stand in`);continue}const y=s(E.id).filter(w=>w.type==="FRAME");if(p.shapes)for(const w of je(p,p.shapes,y.map(A=>A.name)))o("sections",w);for(const w of h.flatMap(r))if(w.modes&&Object.keys(w.modes).length>0)o("mode","sets a variable mode of its own; switch the mode on the page or the view instead",w)}return n}var x=.5;function Ue(e,t){const n=e.page;if(!n)return null;const s=n.name===_?"components":n.name.startsWith(k)?"view":null;if(s===null)return null;const r=[];for(let i=e;i;i=i.parentId?t.get(i.parentId):void 0){r.unshift(i.name);if(i.parentId===n.id){if(s==="view"&&i.type!=="FRAME")return null;return{node:e,path:r,where:s}}}return null}var se=e=>e.path.filter(t=>t!=="*").length;function Ve(e){const t=P.filter(n=>{if(n.where!==e.where||n.path.length!==e.path.length)return false;if(!n.path.every((r,i)=>r==="*"||r===e.path[i]))return false;const s=n.main!==void 0&&n.path.at(-1)==="*";return!s||e.node.main===n.main});return t.sort((n,s)=>se(s)-se(n))[0]??null}var ae=e=>e.replace(/\s+/g,"").toLowerCase();var $=(e,t)=>Math.abs(e-t)<=x;var ce=e=>e.join(" ");function Ye(e,t){const n=[];if(e.layout!==t.mode)n.push(`layout ${e.layout}, not ${t.mode}`);if(!e.padding.every((s,r)=>$(s,t.padding[r]??0)))n.push(`padding ${ce(e.padding)}, not ${ce(t.padding)}`);if(!$(e.gap,t.gap))n.push(`gap ${e.gap}, not ${t.gap}`);if(t.crossGap!==void 0&&!$(e.crossGap,t.crossGap))n.push(`row gap ${e.crossGap}, not ${t.crossGap}`);if(t.wrap!==void 0&&e.wrap!==t.wrap)n.push(t.wrap?"does not wrap, and it wraps":"wraps, and it does not");if(t.align&&(e.align[0]!==t.align[0]||e.align[1]!==t.align[1]))n.push(`aligns ${e.align.join(" ")}, not ${t.align.join(" ")}`);return n}function We(e,t,n){const s=[];const r=(u,c)=>{s.push({nodeId:e.id,field:u,message:`${n}: ${c}`})};if(e.type!==t.type)r("type",`is a ${e.type}, and the documentation draws a ${t.type}`);if(t.main!==void 0&&t.path.at(-1)!=="*"&&e.main!==void 0&&e.main!==t.main)r("main",`is an instance of ${e.main??"no component"}, not of ${t.main}`);const i=e.box;if(i){if(t.at&&(!$(i.x,t.at.x)||!$(i.y,t.at.y)))r("at",`sits at ${i.x}, ${i.y}, not ${t.at.x}, ${t.at.y}`);if(t.width!==void 0&&!$(i.width,t.width))r("width",`is ${i.width} wide, not ${t.width}`);if(t.height!==void 0&&!$(i.height,t.height))r("height",`is ${i.height} high, not ${t.height}`);for(const u of["horizontal","vertical"]){const c=t.sizing?.[u];if(c!==void 0&&i.sizing[u]!==c)r(`sizing.${u}`,`sizes ${i.sizing[u]} ${u}ly, not ${c}`)}if(t.layout){const u=Array.isArray(t.layout)?t.layout:[t.layout];const c=u.map(o=>Ye(i,o));const p=[...c].sort((o,h)=>o.length-h.length)[0]??[];if(p.length>0)r("layout",p.join("; "))}}if(t.font&&e.font){const{size:u,lineHeight:c,style:p}=e.font;if(u!==t.font.size||c!==t.font.lineHeight)r("font",`is set ${u} / ${c}, not ${t.font.size} / ${t.font.lineHeight}`);if(ae(p)!==ae(t.font.weight))r("weight",`is ${p}, not ${t.font.weight}`)}if(t.text!==void 0&&e.characters!==void 0&&e.characters!==t.text)r("text",`reads "${e.characters}", not "${t.text}"`);if(t.properties&&e.properties){const u=e.properties.map(p=>`${p.name} ${p.type} ${String(p.default)}`).sort();const c=t.properties.map(p=>`${p.name} ${p.type} ${String(p.default)}`).sort();if(u.join("|")!==c.join("|"))r("properties",`has the properties [${u.join(", ")}], not [${c.join(", ")}]`)}return s}function de(e){const t=new Map(e.map(i=>[i.id,i]));const n=[];const s=e.map(i=>Ue(i,t)).filter(i=>i!==null);const r=new Map;for(const i of s){const u=Ve(i);const c=i.path.join(" / ");if(i.where==="components"&&i.path.length===1){r.set(i.node.name,[...r.get(i.node.name)??[],i.node]);if(!u&&(i.node.type==="COMPONENT"||i.node.type==="COMPONENT_SET"))n.push({nodeId:i.node.id,field:"name",message:`${c}: is not one of the documentation components`})}if(u)n.push(...We(i.node,u,c))}for(const[i,u]of r){for(const c of u.slice(1))n.push({nodeId:c.id,field:"name",message:`${i}: a second component of that name`})}for(const i of s){if(i.where!=="components"||i.path.length!==1)continue;const u=e.filter(c=>c.parentId===i.node.id);if(u.length===0)continue;for(const c of P){if(c.where!=="components"||c.path[0]!==i.node.name||c.path.length<2)continue;const p=s.some(o=>o.path.length===c.path.length&&o.path.every((h,a)=>h===c.path[a]));if(!p)n.push({nodeId:i.node.id,field:"layers",message:`${i.node.name}: holds no ${c.path.slice(1).join(" / ")}`})}}n.push(...re(e,t));n.push(...Ke(e,t));return n}function Ke(e,t){const n=new Map;const s=a=>{const d=n.get(a.id);if(d)return d;const g=t.get(a.parentId??"");if(!a.box||!g||g.type==="INSTANCE")return null;let l=a.box.x;let f=a.box.y;let E;let y=[];if(g.parentId===a.page?.id){if(g.name!==I.frame||a.name===I.bleeds)return null;E=[g.name,a.name]}else{const N=s(g);if(!N)return null;l+=N.x;f+=N.y;E=[...N.path,a.name];y=[N,...N.above]}const w=a.type==="INSTANCE"||!e.some(N=>N.parentId===a.id);const A={node:a,x:l,y:f,right:l+a.box.width,bottom:f+a.box.height,path:E,block:w,above:y};n.set(a.id,A);return A};for(const a of e)if(a.page?.name===I.page)s(a);const r=[...n.values()];const i=r.filter(a=>a.block);const u=a=>a-I.width;const c=a=>i.some(d=>Math.abs(d.x-a.x)<=x&&u(d.right)>x&&u(d.right)>=I.bleed*(d.node.box?.width??0));const p=[];const o=(a,d,g)=>{p.push({nodeId:a.node.id,field:d,message:`${a.path.join(" / ")}: ${g}`})};const h=a=>[["left",-a.x],["top",-a.y],["bottom",a.bottom-I.height]].filter(([,d])=>d>x).map(([d,g])=>`reaches ${Math.round(g)} past the cover's ${d} edge`);for(const a of r){const d=h(a);if(d.length>0&&!a.above.some(y=>h(y).length>0))o(a,"bounds",`${d.join(", ")}, which cuts it off`);const g=u(a.right);if(a.block){if(c(a))continue;const y=Math.round(a.node.box?.width??0);if(g>x)o(a,"bounds",`crosses the cover's right edge by ${Math.round(g)} of its ${y}; bleed a quarter of its width past it, or end it ${I.margin} inside`);else if(u(a.right+I.margin)>x)o(a,"bounds",`ends ${Math.round(-g)} inside the cover's right edge, within its ${I.margin} margin`);continue}if(g<=x)continue;const l=r.filter(y=>y.above.includes(a));const f=l.filter(y=>y.block&&u(y.right)>x&&c(y));const E=Math.max(I.width,...f.map(y=>y.right));if(a.right<=E+x)continue;if(l.some(y=>Math.abs(y.right-a.right)<=x))continue;o(a,"bounds",f.length>0?`reaches ${Math.round(a.right-E)} past the layers that bleed from it at the cover's right edge`:`reaches ${Math.round(g)} past the cover's right edge, and nothing in it bleeds`)}return p}var le=new Set(P.filter(e=>e.where==="components"&&e.path.length===1).map(e=>e.path[0]??""));function pe(e){if(e.type!=="TEXT"||e.characters===void 0)return false;if(e.page?.name!==_)return false;return P.some(t=>t.where==="components"&&t.type==="TEXT"&&t.text===e.characters&&t.path[0]===e.frame&&t.path.at(-1)===e.name)}var qe={FRAME:["Frame"],GROUP:["Group"],SECTION:["Section"],COMPONENT:["Component"],COMPONENT_SET:["Component"],RECTANGLE:["Rectangle"],ELLIPSE:["Ellipse"],LINE:["Line"],POLYGON:["Polygon"],STAR:["Star"],VECTOR:["Vector"],SLICE:["Slice"],BOOLEAN_OPERATION:["Union","Subtract","Intersect","Exclude"]};function ue(e,t){const n=/^(.+?)(?: \d+)?$/.exec(t);return n!==null&&(qe[e]??[]).includes(n[1]??"")}var he="❖ ";var Ze=new Set(["Thumbnail","Component for Docs"]);var M=.01;var Je=["data-entry","navigation","feedback","data-display","layout","general"];var Qe=new RegExp(`^(${Je.join("|")}) / .+$`);var et="_components";function tt(e){const t=e.page?.name;if(t===void 0)return false;if(Ze.has(t))return true;if(e.componentSource!==false)return false;return t.startsWith(he)||Qe.test(t)||e.frame===et}var fe=(e,t)=>e.map(n=>n.variable??"").join()===t.map(n=>n.variable??"").join();function nt(e,t){const n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x);const s=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);return n>M&&s>M}function it(e){const t=e.box;if(e.type!=="FRAME"||!t||t.children!==0)return false;if(e.fills.length>0||e.strokes.length>0)return false;return t.width>1&&t.height>1}function ot(e,t,n){return e.x<-M||e.y<-M||e.x+e.width>t+M||e.y+e.height>n+M}function B(e,t=V){const n=ee(t,e.flatMap(o=>o.main&&le.has(o.main)?[]:o.instance?.carried??[]));const s=[];const r=new Map(e.map(o=>[o.id,o]));const i=o=>{for(let h=r.get(r.get(o)?.parentId??"");h;h=r.get(h.parentId??"")){const a=h.type==="INSTANCE"?h.mainId:void 0;if(!a)continue;for(let d=r.get(h.parentId??"");d;d=r.get(d.parentId??""))if(d.swaps?.includes(a))return true}return false};const u=new Set(e.flatMap(o=>o.instance?.overrides.map(h=>h.nodeId)??[]));const c=o=>{if(o.page?.name!==I.page)return false;for(let h=r.get(o.parentId??"");h;h=r.get(h.parentId??""))if(h.name===I.logo)return true;return false};for(const o of e){const h=`${o.name} (${o.type.toLowerCase()})`;const a=(l,f,E,y=o.id)=>{s.push({check:l,nodeId:y,...f?{field:f}:{},...o.frame?{frame:o.frame}:{},message:E})};const d=tt(o);const g=c(o);if(!g&&o.fills.some(l=>!l.bound))a("binding","fill",`${h}: fill is a raw value`);if(!g&&o.strokes.some(l=>!l.bound))a("binding","stroke",`${h}: stroke is a raw value`);if(o.type==="TEXT"&&o.textStyleId===null&&!d)a("binding","textStyle",`${h}: text has no library text style`);for(const l of d?[]:o.spacing){if(l.value>0&&!l.bound)a("binding",l.field,`${h}: ${l.field} ${l.value} is not a spacing variable`)}if((o.type==="COMPONENT"||o.type==="COMPONENT_SET")&&o.page?.name.startsWith(he)&&o.parentId===o.page.id)a("placement",void 0,`${h}: sits on the page, outside its entry's component view`);if(o.set){const{width:l,height:f,variants:E}=o.set;E.forEach((y,w)=>{for(const A of E.slice(w+1)){if(nt(y,A))a("overlap",void 0,`${o.name}: ${y.name} overlaps ${A.name}`,y.id)}if(ot(y,l,f))a("overlap",void 0,`${o.name}: ${y.name} reaches past the set, which cuts it off`,y.id)})}if(o.characters!==void 0&&!pe(o)){for(const l of H(o.characters,n))a("copy",l.field,`${h}: ${l.message}`)}if(o.instance){for(const l of o.instance.overrides){if(l.characters!==void 0){for(const f of H(l.characters,n))a("copy",f.field,`${o.name}: ${f.message}`,l.nodeId)}for(const f of l.fields){if(Y.has(f))continue;if(f==="fills"&&l.picture)continue;const E=l.nodeId===o.id;if(!E&&(f==="fills"||f==="strokes")&&o.componentSource===true)continue;if(!E&&(f==="fills"||f==="strokes")&&i(l.nodeId))continue;const y=r.get(l.nodeId);if(!E&&(f==="fills"||f==="strokes")&&y?.source){if(fe(y[f],y.source[f]))continue}if(E&&(f==="width"||f==="height")&&d)continue;if(E&&(f==="width"||f==="height")&&o.componentSource===true)continue;if(E&&f==="width"&&o.instance.sizing.horizontal!=="FIXED")continue;if(E&&f==="height"&&o.instance.sizing.vertical!=="FIXED")continue;if(E&&W.has(f)&&q(o.instance.sizing))continue;if(E&&K(f,o.box,o.instance.main))continue;a("overrides",f,`${f} overridden inside an instance of ${o.name}`,l.nodeId)}}}if(it(o))a("empty",void 0,`${o.name}: an empty frame ${Math.round(o.box?.width??0)}x${Math.round(o.box?.height??0)} that shows nothing; it holds no layer, so remove it or put in what it was made for`);if(ue(o.type,o.name))a("naming",void 0,`${o.name} keeps a default name`);if(o.source){const l=["fills","strokes"].filter(f=>!fe(o[f],o.source?.[f]??[]));if(l.length>0&&!u.has(o.id))a("binding",l[0]==="fills"?"fill":"stroke",`${h}: paints with another colour than the same layer in its component (${(o.source[l[0]??"fills"]??[]).map(f=>f.variable??"raw").join(", ")}), which an icon swap dropped`)}}const p=new Map(e.map(o=>[o.id,o.frame]));for(const{nodeId:o,field:h,message:a}of de(e)){const d=p.get(o);s.push({check:"documentation",nodeId:o,field:h,...d?{frame:d}:{},message:a})}return s}var F=18e3;function ge(e){return encodeURIComponent(JSON.stringify(e)).replace(/%[0-9A-F]{2}/g,"x").length}function X(e,t,n=F){const s={};for(const u of t)s[u.check]=(s[u.check]??0)+1;const r={checked:e,total:t.length,counts:s,findings:[],cut:false};let i=ge(r);for(const u of t){i+=ge(u)+1;if(i>n){r.cut=true;break}r.findings.push(u)}return r}function m(e,t){try{return e[t]}catch{return void 0}}var rt=["paddingTop","paddingRight","paddingBottom","paddingLeft","itemSpacing"];function D(e){if(!Array.isArray(e))return[];return e.filter(t=>t.type==="SOLID"&&t.visible!==false&&(t.opacity??1)>0).map(t=>{const n=t.boundVariables?.color?.id;return{bound:Boolean(t.boundVariables?.color),...typeof n==="string"?{variable:n}:{}}})}function me(e,t){if(e.id===t)return e;const n=m(e,"findOne");return n?n.call(e,s=>s.id===t):null}function we(e,t){const n=t.get(e.id);if(n)return n;const s=e.parent??null;const r=s?we(s,t):null;const i={frame:s?.type==="PAGE"?e.name:r?.frame??null,page:e.type==="PAGE"?{id:e.id,name:e.name}:r?.page??null,componentSource:e.type==="COMPONENT"||e.type==="COMPONENT_SET"||(r?.componentSource??false),insideInstance:s?.type==="INSTANCE"||(r?.insideInstance??false)};t.set(e.id,i);return i}var st=new Set(["VECTOR","BOOLEAN_OPERATION","ELLIPSE","RECTANGLE","LINE","STAR","POLYGON"]);function at(e){if(!e.startsWith("I"))return null;const t=e.slice(1).split(";").slice(1);if(t.length===0)return null;return t.length===1?t[0]??null:`I${t.join(";")}`}function ct(e){const t=m(e,"children")??[];return{width:Number(m(e,"width")??0),height:Number(m(e,"height")??0),variants:t.map(({id:n,name:s,x:r,y:i,width:u,height:c})=>({id:n,name:s,x:r,y:i,width:u,height:c}))}}function dt(e,t){const n=m(e,"findAll");if(!n)return[];return n.call(e,s=>s.type==="TEXT"&&!t.has(s.id)).map(s=>typeof s.characters==="string"?s.characters:"")}function lt(e){const t=e?m(e,"fills"):void 0;return Array.isArray(t)&&t.some(n=>n.type==="IMAGE")}var pt=new Set(["FRAME","COMPONENT","COMPONENT_SET","INSTANCE","TEXT"]);var O=e=>typeof e==="number"?e:0;function ut(e){const t=m(e,"layoutMode");const n=typeof t==="string"?t:"NONE";const s=m(e,"children");const r=n==="GRID";return{x:O(m(e,"x")),y:O(m(e,"y")),width:O(m(e,"width")),height:O(m(e,"height")),sizing:{horizontal:String(m(e,"layoutSizingHorizontal")??"FIXED"),vertical:String(m(e,"layoutSizingVertical")??"FIXED")},layout:n,wrap:m(e,"layoutWrap")==="WRAP",padding:[O(m(e,"paddingTop")),O(m(e,"paddingRight")),O(m(e,"paddingBottom")),O(m(e,"paddingLeft"))],gap:r?O(m(e,"gridColumnGap")):O(m(e,"itemSpacing")),crossGap:r?O(m(e,"gridRowGap")):O(m(e,"counterAxisSpacing")),align:[String(m(e,"primaryAxisAlignItems")??"MIN"),String(m(e,"counterAxisAlignItems")??"MIN")],children:Array.isArray(s)?s.length:0}}function ft(e,t){const n=m(e,"fontSize");const s=m(e,"lineHeight");const r=m(e,"fontName");const i=typeof n==="number"?n:0;return{size:n===t?"mixed":i,lineHeight:s===t||typeof s!=="object"?"mixed":s.unit==="AUTO"?"auto":s.unit==="PERCENT"?i*O(s.value)/100:O(s.value),style:r===t||typeof r!=="object"?"mixed":String(r.style??"")}}function ht(e){if(e.type!=="COMPONENT_SET"&&(e.type!=="COMPONENT"||e.parent?.type==="COMPONENT_SET"))return void 0;const t=m(e,"componentPropertyDefinitions");if(!t)return void 0;return Object.entries(t).map(([n,{type:s,defaultValue:r}])=>({name:n.split("#")[0]??n,type:s,default:r}))}async function gt(e){const t=m(e,"getMainComponentAsync");return t?await t.call(e):null}function mt(e){if(!e)return null;return e.parent?.type==="COMPONENT_SET"?e.parent.name:e.name}function wt(e,t,n){const s=n.find(r=>r.id===e);if(!s?.overriddenFields.some(r=>r==="width"||r==="height"))return null;return typeof t?.width==="number"&&typeof t.height==="number"?{width:t.width,height:t.height}:null}function yt(e){const t=m(e,"componentProperties");if(!t||typeof t!=="object")return[];return Object.values(t).flatMap(n=>n?.type==="INSTANCE_SWAP"&&typeof n.value==="string"?[n.value]:[])}function Et(e){const t=m(e,"componentProperties");if(!t||typeof t!=="object")return void 0;const n={};for(const[s,r]of Object.entries(t)){const i=r?.value;if(typeof i==="string"||typeof i==="boolean")n[s.split("#")[0]??s]=i}return n}function bt(e){const t=m(e,"explicitVariableModes");if(!t||typeof t!=="object")return void 0;const n=Object.entries(t).filter(s=>typeof s[1]==="string");return n.length>0?Object.fromEntries(n):void 0}async function ye(e,t,n=typeof figma==="undefined"?Symbol("mixed"):figma.mixed,s=new Map,r=i=>figma.getNodeByIdAsync(i)){const i=e;const u=m(i,"textStyleId");const c=m(i,"boundVariables");const p=m(i,"overrides")??[];const o=new Set(p.filter(S=>S.overriddenFields.includes("characters")).map(S=>S.id));const h=e.type==="INSTANCE"?dt(e,o):[];const a=m(i,"layoutMode");const d=typeof a==="string"&&a!=="NONE";const g=we(e,s);const l=st.has(e.type)&&g.insideInstance&&!g.componentSource?at(e.id):null;const f=l?await r(l):null;const E=e.type==="INSTANCE"?await gt(i):null;const y=e.type==="INSTANCE"?wt(e.id,E,p):null;const w=ht(i);const A=e.type==="INSTANCE"?Et(e):void 0;const N=e.type==="INSTANCE"?yt(e):[];const j=typeof E?.id==="string"?E.id:void 0;const U=bt(e);return{id:e.id,name:e.name,type:e.type,parentId:i.parent?.id??null,frame:g.frame,created:t,fills:D(m(i,"fills")),strokes:D(m(i,"strokes")),textStyleId:e.type!=="TEXT"?null:u===n?"mixed":typeof u==="string"&&u?u:null,...e.type==="TEXT"&&!g.insideInstance?{characters:String(m(i,"characters")??"")}:{},instance:e.type==="INSTANCE"?{overrides:p.map(S=>({nodeId:S.id,fields:S.overriddenFields,...S.overriddenFields.includes("fills")&<(me(e,S.id))?{picture:true}:{},...o.has(S.id)?{characters:String(m(me(e,S.id),"characters")??"")}:{}})),...h.length>0?{carried:h}:{},sizing:{horizontal:String(m(i,"layoutSizingHorizontal")??"FIXED"),vertical:String(m(i,"layoutSizingVertical")??"FIXED")},...y?{main:y}:{}}:null,spacing:d?rt.map(S=>({field:S,value:Number(m(i,S)??0),bound:Boolean(c?.[S])})):[],...f?{source:{fills:D(m(f,"fills")),strokes:D(m(f,"strokes"))}}:{},page:g.page,componentSource:g.componentSource,...pt.has(e.type)?{box:ut(i)}:{},...e.type==="TEXT"?{font:ft(i,n)}:{},...w?{properties:w}:{},...e.type==="INSTANCE"?{main:mt(E)}:{},...j?{mainId:j}:{},...N.length>0?{swaps:N}:{},...A?{values:A}:{},...U?{modes:U}:{},...e.type==="COMPONENT_SET"?{set:ct(i)}:{}}}async function Ee(e,t){if("nodeId"in t){const n=await e.getNodeByIdAsync(t.nodeId);if(!n||n.type==="PAGE"||n.type==="DOCUMENT")return[];return"findAll"in n?[n,...n.findAll()]:[n]}if(t.page!==true){const n=t.page;const s=e.root.children;const r=s.find(i=>i.id===n||i.name===n);if(!r)throw new Error(`no page ${n}; the pages are ${s.map(i=>i.name).join(", ")}`);if(r!==e.currentPage)await e.setCurrentPageAsync(r)}return e.currentPage.findAll()}async function Tt(e,t){const n=await Ee(e,t.scope);const s=new Map;const r=await Promise.all(n.map(i=>ye(i,false,e.mixed,s)));return X(r.length,B(r,t.copy))}return Oe(Nt);})();
|