@zeroxsolutions/zaku 0.0.3 → 0.0.4
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/rules.js +1 -1
- package/dist/zaku.mjs +1274 -209
- package/package.json +1 -1
package/dist/rules.js
CHANGED
|
@@ -1 +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);})();
|
|
1
|
+
"use strict";var zakuRulesLib=(()=>{var B=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var ve=Object.prototype.hasOwnProperty;var xe=(e,t)=>{for(var n in t)B(e,n,{get:t[n],enumerable:true})};var Ae=(e,t,n,o)=>{if(t&&typeof t==="object"||typeof t==="function"){for(let r of Oe(t))if(!ve.call(e,r)&&r!==n)B(e,r,{get:()=>t[r],enumerable:!(o=Ie(t,r))||o.enumerable})}return e};var Ce=e=>Ae(B({},"__esModule",{value:true}),e);var Ot={};xe(Ot,{REPLY_BYTES:()=>H,scopeNodes:()=>Se,zakuRules:()=>It});var W={locales:["en"],currencies:[]};var q=new Set(["characters","name","componentProperties","componentPropertyReferences","exposedInstances","reactions","transitionNodeID","transitionDuration","transitionEasing"]);var Z=new Set(["primaryAxisSizingMode","counterAxisSizingMode"]);function J(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 ee="['’]";var te=[{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${ee}s\\b`,"iu"),instead:'write the action itself, such as "Plan a trip"'},{pattern:new RegExp(`\\b(?:it${ee}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 ne={en:te};var Me=/^[\x20-\x7e]$/;var $e=new RegExp(`^[${String.fromCharCode(10,8232)}]$`);var Re=/^[\p{L}\p{M}]$/u;var ke=/^(?=\p{M})\p{Script=Inherited}$/u;var Pe=/^\p{Extended_Pictographic}$/u;var Fe=new RegExp("^[←-⇿⟰-⟿⤀-⥿⬀-⬑]$","u");var ze=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 De={Jpan:["Han","Hiragana","Katakana"],Kore:["Hangul","Han"],Hans:["Han"],Hant:["Han"],Hanb:["Han","Bopomofo"]};function Le(e,t){return e.flatMap(n=>["symbol","narrowSymbol"].flatMap(o=>new Intl.NumberFormat(n,{style:"currency",currency:t,currencyDisplay:o}).formatToParts(0).filter(r=>r.type==="currency").map(r=>r.value)))}function He(e){const t=new Set(e.locales.flatMap(n=>{const o=new Intl.Locale(n).maximize().script??"";return De[o]??[o]}));return{scripts:[...t].filter(Boolean),symbols:[...new Set(e.currencies.flatMap(n=>Le(e.locales,n)))],languages:[...new Set(e.locales.map(n=>new Intl.Locale(n).language))]}}function oe(e,t){const n="scripts"in e?e:He(e);return{scripts:n.scripts.map(o=>new RegExp(`^\\p{Script_Extensions=${o}}$`,"u")),extra:new Set([...n.symbols,...t].flatMap(o=>[...o.normalize("NFC")])),tells:n.languages.flatMap(o=>ne[o]??[])}}function _e(e,t){if(Me.test(e)||$e.test(e)||t.extra.has(e))return true;if(!Re.test(e))return false;return ke.test(e)||t.scripts.some(n=>n.test(e))}function L(e){return`U+${(e.codePointAt(0)??0).toString(16).toUpperCase().padStart(4,"0")}`}function Ge(e){const t=ze.get(e);if(t)return`${L(e)} ${t.name}: ${t.instead}`;if(Pe.test(e))return`${L(e)} emoji: write a word, or a library icon`;if(Fe.test(e))return`${L(e)} arrow: write "->" or "<-"`;return`${L(e)} is outside the locales and currencies copy names in zaku.yaml: write it in ASCII, or add its locale or currency there`}function X(e,t){const n=[];const o=new Set;for(const r of e.normalize("NFC")){if(o.has(r)||_e(r,t))continue;o.add(r);n.push({field:"characters",message:Ge(r)})}for(const r of t.tells){const a=r.pattern.exec(e);if(a)n.push({field:"tone",message:`"${a[0]}": ${r.instead}`})}return n}var O={page:"Thumbnail",frame:"Thumbnail",width:1200,height:675,bleeds:"Glow",logo:"Logo",bleed:.25,margin:72};var z="❖ ";var j="Component for Docs";var I=(e,t,n)=>({mode:"VERTICAL",padding:e,gap:t,...n?{align:n}:{}});var x=(e,t,n)=>({mode:"HORIZONTAL",padding:e,gap:t,...n?{align:n}:{}});var T=[0,0,0,0];var D=[{path:["DS/Header"],where:"components",type:"COMPONENT",at:{x:0,y:0},width:1440,sizing:{horizontal:"FIXED",vertical:"HUG"},layout:x([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:I(T,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:x(T,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:I(T,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:I([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:I([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:I([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:x(T,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:I([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:I(T,0),paint:"fill color/background"},{path:["*","*"],where:"view",type:"INSTANCE",main:"DS/Header",width:1440},{path:["*","Body"],where:"view",type:"FRAME",width:1440,layout:I([48,120,96,120],64),paint:"no fill"},{path:["*","Body","*"],where:"view",type:"FRAME",width:1200,layout:I(T,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:[x(T,24),I(T,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:I(T,0),paint:"stroke 1 color/border, radius 8"},{path:["*","Body","Matrix","Matrix","TableHeader"],where:"view",type:"FRAME",height:40,layout:x(T,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:x([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:T,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:x(T,16)},{path:["*","Body","Anatomy","Anatomy layout","Preview"],where:"view",type:"FRAME",width:744,sizing:{horizontal:"FILL",vertical:"FILL"},layout:x([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:T,gap:16,crossGap:16},paint:"one column, one Card per part"},{path:["*","Body","*","Table"],where:"view",type:"FRAME",width:1200,layout:I(T,0),paint:"stroke 1 color/border, radius 8"},{path:["*","Body","*","Table","TableHeader"],where:"view",type:"FRAME",height:40,layout:x(T,0),paint:"bottom stroke 1 color/border"},{path:["*","Body","*","Table","TableRow"],where:"view",type:"FRAME",layout:x(T,0),paint:"bottom stroke 1 color/border, none on the last"},{path:["*","Body","*","Table","TableRow","TableCell"],where:"view",type:"FRAME",layout:[I([8,8,8,8],0,["CENTER","CENTER"]),x([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:I([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:T,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:x(T,16)},{path:["*","Body","Preview","Theme Preview","Preview"],where:"view",type:"FRAME",layout:I([40,40,40,40],20),paint:"fill color/background, stroke 1 color/border, radius 14; no mode of its own"}];var Be="Icon";var Xe=["Color","Spacing","Radius"];var U="DS/Header";var ie="Body";var ce="Preview";var R=e=>({name:e,required:true});var M=e=>({name:e});var re={key:"table",label:"the table shape",sections:[R("Example"),M("Properties"),M("Specs"),R("Usage"),R("Accessibility"),R(ce)]};var je={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:[re]},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"),M("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:[re,{key:"parts",label:"the parts shape",sections:[M("Anatomy"),M("Variants"),M("Sizes"),M("Composition"),M("Properties"),R("Usage"),M("Behavior & content"),R("Accessibility"),R(ce)]}]}};var Ue=/^[0-9][0-9,.]*\s+\S/;function Ve(e){if(e===Be)return"icon set";return Xe.includes(e)?"foundation":"entry"}function se(e,t){if(!e.startsWith(z))return null;const n=e.slice(z.length);const o=Ve(n);return Object.values(je).find(r=>r.pages.includes(o)&&r.frame(n)===t)??null}var ae=e=>e.sections.map(t=>t.name).join(", ");function Ye(e,t,n){const o=[];const r=l=>t.some(d=>d.sections.some(y=>y.name===l));for(const l of n.filter((d,y)=>!r(d)&&n.indexOf(d)===y)){const d=t.length===1?ae(t[0]):`those of ${t.map(y=>`${y.label} (${ae(y)})`).join(" or of ")}`;o.push(`holds ${l}, which no ${e.noun} holds; its sections are ${d}`)}const a=n.filter(r);const c=l=>t.filter(d=>d.sections.some(y=>y.name===l));const w=a.find(l=>c(l).length===1);const f=(w?c(w)[0]:void 0)??t.find(l=>l.sections.every(d=>!d.required||a.includes(d.name)))??t[0];const h=f.sections.map(l=>l.name);let i=-1;let s="";for(const l of a){const d=h.indexOf(l);if(d===-1){o.push(`holds ${l}, a section of ${c(l)[0]?.label}, beside ${w} of ${f.label}`);continue}const y=d===i&&f.sections[d]?.repeats===true;if(d<i||d===i&&!y)o.push(`holds ${l} after ${s}; ${f.label} orders them ${h.join(", ")}`);else{i=d;s=l}}for(const l of f.sections)if(l.required&&!a.includes(l.name))o.push(`holds no ${l.name}, which ${f.label} always holds`);return o}function le(e,t,n=[]){const o=n.length>1;const r=[];const a=h=>e.filter(i=>i.parentId===h);const c=h=>{const i=[h];if(h.type!=="INSTANCE")for(const s of a(h.id))i.push(...c(s));return i};const w=(h,i)=>{for(let s=t.get(h.parentId??"");s;s=t.get(s.parentId??""))if(s===i)return true;return false};const f=(h,i)=>{const s=[];for(let l=i;l&&l!==h;l=t.get(l.parentId??""))s.unshift(l.name);return[h.name,...s].join(" / ")};for(const h of e){if(h.type!=="FRAME"||!h.page||h.parentId!==h.page.id)continue;const[i="",...s]=h.name.split(" / ");const l=o&&s.length>0&&se(h.page.name,s.join(" / "))!==null;const d=se(h.page.name,l?s.join(" / "):h.name);if(!d)continue;const y=(b,G,K=h)=>{r.push({nodeId:K.id,field:b,message:`${f(h,K)}: ${G}`})};if(l&&!n.includes(i))y("branch",`opens with ${i}, which is not a branch this file holds (${n.join(", ")})`);const g=d.kind==="component"||e.some(b=>(b.type==="COMPONENT"||b.type==="COMPONENT_SET")&&w(b,h));if(o&&!l&&g)y("branch",`names no branch; in a file holding ${n.join(" and ")}, a view drawing a component opens with its branch, as ${n[0]} / ${h.name}`);const p=a(h.id);const m=p[0];if(m&&(m.type!=="INSTANCE"||m.main!==U))y("header",`opens on ${m.name}, and a view opens on a ${U} instance`);const E=p.find(b=>b.type==="INSTANCE"&&b.main===U);const A=E?.values;if(E&&A){const b=A["Eyebrow"];if(b!==void 0&&b!==d.eyebrow)y("eyebrow",`the eyebrow reads "${String(b)}", and ${d.eyebrowOwner} reads "${d.eyebrow}"`);if(A["Show style"]===false)y("show style","the header's Show style is off, and a view's header shows its badge")}const N=E?e.find(b=>b.type==="INSTANCE"&&t.get(b.parentId??"")?.name==="Badges"&&w(b,E)):void 0;const $=N?.values?.["Label"];if(typeof $==="string"){const b=d.badge;if("reads"in b&&$!==b.reads)y("badge",`the badge reads "${$}", and ${d.badgeOwner} reads "${b.reads}"`);if("counts"in b&&!Ue.test($))y("badge",`the badge reads "${$}", and ${d.badgeOwner} counts what it shows ("${b.counts}")`)}const F=p.find(b=>b.type==="FRAME"&&b.name===ie);if(!F){y("sections",`holds no ${ie}, the frame its sections stand in`);continue}const S=a(F.id).filter(b=>b.type==="FRAME");if(d.shapes)for(const b of Ye(d,d.shapes,S.map(G=>G.name)))y("sections",b);for(const b of p.flatMap(c))if(b.modes&&Object.keys(b.modes).length>0)y("mode","sets a variable mode of its own; switch the mode on the page or the view instead",b)}return r}var C=.5;function Ke(e,t){const n=e.page;if(!n)return null;const o=n.name===j?"components":n.name.startsWith(z)?"view":null;if(o===null)return null;const r=[];for(let a=e;a;a=a.parentId?t.get(a.parentId):void 0){r.unshift(a.name);if(a.parentId===n.id){if(o==="view"&&a.type!=="FRAME")return null;return{node:e,path:r,where:o}}}return null}var de=e=>e.path.filter(t=>t!=="*").length;function We(e){const t=D.filter(n=>{if(n.where!==e.where||n.path.length!==e.path.length)return false;if(!n.path.every((r,a)=>r==="*"||r===e.path[a]))return false;const o=n.main!==void 0&&n.path.at(-1)==="*";return!o||e.node.main===n.main});return t.sort((n,o)=>de(o)-de(n))[0]??null}var pe=e=>e.replace(/\s+/g,"").toLowerCase();var k=(e,t)=>Math.abs(e-t)<=C;var ue=e=>e.join(" ");function qe(e,t){const n=[];if(e.layout!==t.mode)n.push(`layout ${e.layout}, not ${t.mode}`);if(!e.padding.every((o,r)=>k(o,t.padding[r]??0)))n.push(`padding ${ue(e.padding)}, not ${ue(t.padding)}`);if(!k(e.gap,t.gap))n.push(`gap ${e.gap}, not ${t.gap}`);if(t.crossGap!==void 0&&!k(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 Ze(e,t,n){const o=[];const r=(c,w)=>{o.push({nodeId:e.id,field:c,message:`${n}: ${w}`})};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 a=e.box;if(a){if(t.at&&(!k(a.x,t.at.x)||!k(a.y,t.at.y)))r("at",`sits at ${a.x}, ${a.y}, not ${t.at.x}, ${t.at.y}`);if(t.width!==void 0&&!k(a.width,t.width))r("width",`is ${a.width} wide, not ${t.width}`);if(t.height!==void 0&&!k(a.height,t.height))r("height",`is ${a.height} high, not ${t.height}`);for(const c of["horizontal","vertical"]){const w=t.sizing?.[c];if(w!==void 0&&a.sizing[c]!==w)r(`sizing.${c}`,`sizes ${a.sizing[c]} ${c}ly, not ${w}`)}if(t.layout){const c=Array.isArray(t.layout)?t.layout:[t.layout];const w=c.map(h=>qe(a,h));const f=[...w].sort((h,i)=>h.length-i.length)[0]??[];if(f.length>0)r("layout",f.join("; "))}}if(t.font&&e.font){const{size:c,lineHeight:w,style:f}=e.font;if(c!==t.font.size||w!==t.font.lineHeight)r("font",`is set ${c} / ${w}, not ${t.font.size} / ${t.font.lineHeight}`);if(pe(f)!==pe(t.font.weight))r("weight",`is ${f}, 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 c=e.properties.map(f=>`${f.name} ${f.type} ${String(f.default)}`).sort();const w=t.properties.map(f=>`${f.name} ${f.type} ${String(f.default)}`).sort();if(c.join("|")!==w.join("|"))r("properties",`has the properties [${c.join(", ")}], not [${w.join(", ")}]`)}return o}function fe(e,t=[]){const n=new Map(e.map(c=>[c.id,c]));const o=[];const r=e.map(c=>Ke(c,n)).filter(c=>c!==null);const a=new Map;for(const c of r){const w=We(c);const f=c.path.join(" / ");if(c.where==="components"&&c.path.length===1){a.set(c.node.name,[...a.get(c.node.name)??[],c.node]);if(!w&&(c.node.type==="COMPONENT"||c.node.type==="COMPONENT_SET"))o.push({nodeId:c.node.id,field:"name",message:`${f}: is not one of the documentation components`})}if(w)o.push(...Ze(c.node,w,f))}for(const[c,w]of a){for(const f of w.slice(1))o.push({nodeId:f.id,field:"name",message:`${c}: a second component of that name`})}for(const c of r){if(c.where!=="components"||c.path.length!==1)continue;const w=e.filter(f=>f.parentId===c.node.id);if(w.length===0)continue;for(const f of D){if(f.where!=="components"||f.path[0]!==c.node.name||f.path.length<2)continue;const h=r.some(i=>i.path.length===f.path.length&&i.path.every((s,l)=>s===f.path[l]));if(!h)o.push({nodeId:c.node.id,field:"layers",message:`${c.node.name}: holds no ${f.path.slice(1).join(" / ")}`})}}o.push(...le(e,n,t));o.push(...Je(e,n));return o}function Je(e,t){const n=new Map;const o=s=>{const l=n.get(s.id);if(l)return l;const d=t.get(s.parentId??"");if(!s.box||!d||d.type==="INSTANCE")return null;let y=s.box.x;let g=s.box.y;let p;let m=[];if(d.parentId===s.page?.id){if(d.name!==O.frame||s.name===O.bleeds)return null;p=[d.name,s.name]}else{const N=o(d);if(!N)return null;y+=N.x;g+=N.y;p=[...N.path,s.name];m=[N,...N.above]}const E=s.type==="INSTANCE"||!e.some(N=>N.parentId===s.id);const A={node:s,x:y,y:g,right:y+s.box.width,bottom:g+s.box.height,path:p,block:E,above:m};n.set(s.id,A);return A};for(const s of e)if(s.page?.name===O.page)o(s);const r=[...n.values()];const a=r.filter(s=>s.block);const c=s=>s-O.width;const w=s=>a.some(l=>Math.abs(l.x-s.x)<=C&&c(l.right)>C&&c(l.right)>=O.bleed*(l.node.box?.width??0));const f=[];const h=(s,l,d)=>{f.push({nodeId:s.node.id,field:l,message:`${s.path.join(" / ")}: ${d}`})};const i=s=>[["left",-s.x],["top",-s.y],["bottom",s.bottom-O.height]].filter(([,l])=>l>C).map(([l,d])=>`reaches ${Math.round(d)} past the cover's ${l} edge`);for(const s of r){const l=i(s);if(l.length>0&&!s.above.some(m=>i(m).length>0))h(s,"bounds",`${l.join(", ")}, which cuts it off`);const d=c(s.right);if(s.block){if(w(s))continue;const m=Math.round(s.node.box?.width??0);if(d>C)h(s,"bounds",`crosses the cover's right edge by ${Math.round(d)} of its ${m}; bleed a quarter of its width past it, or end it ${O.margin} inside`);else if(c(s.right+O.margin)>C)h(s,"bounds",`ends ${Math.round(-d)} inside the cover's right edge, within its ${O.margin} margin`);continue}if(d<=C)continue;const y=r.filter(m=>m.above.includes(s));const g=y.filter(m=>m.block&&c(m.right)>C&&w(m));const p=Math.max(O.width,...g.map(m=>m.right));if(s.right<=p+C)continue;if(y.some(m=>Math.abs(m.right-s.right)<=C))continue;h(s,"bounds",g.length>0?`reaches ${Math.round(s.right-p)} past the layers that bleed from it at the cover's right edge`:`reaches ${Math.round(d)} past the cover's right edge, and nothing in it bleeds`)}return f}var he=new Set(D.filter(e=>e.where==="components"&&e.path.length===1).map(e=>e.path[0]??""));function ge(e){if(e.type!=="TEXT"||e.characters===void 0)return false;if(e.page?.name!==j)return false;return D.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 me(e,t){const n=/^(.+?)(?: \d+)?$/.exec(t);return n!==null&&(Qe[e]??[]).includes(n[1]??"")}var ye="❖ ";var et=new Set(["Thumbnail","Component for Docs"]);var P=.01;var tt=["data-entry","navigation","feedback","data-display","layout","general"];var nt=new RegExp(`^(${tt.join("|")}) / .+$`);var ot="_components";function it(e){const t=e.page?.name;if(t===void 0)return false;if(et.has(t))return true;if(e.componentSource!==false)return false;return t.startsWith(ye)||nt.test(t)||e.frame===ot}var we=(e,t)=>e.map(n=>n.variable??"").join()===t.map(n=>n.variable??"").join();function rt(e,t){const n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x);const o=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);return n>P&&o>P}function st(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 at(e,t,n){return e.x<-P||e.y<-P||e.x+e.width>t+P||e.y+e.height>n+P}function V(e,t=W,n={}){const o=oe(t,e.flatMap(i=>i.main&&he.has(i.main)?[]:i.instance?.carried??[]));const r=[];const a=new Map(e.map(i=>[i.id,i]));const c=i=>{for(let s=a.get(a.get(i)?.parentId??"");s;s=a.get(s.parentId??"")){const l=s.type==="INSTANCE"?s.mainId:void 0;if(!l)continue;for(let d=a.get(s.parentId??"");d;d=a.get(d.parentId??""))if(d.swaps?.includes(l))return true}return false};const w=new Set(e.flatMap(i=>i.instance?.overrides.map(s=>s.nodeId)??[]));const f=i=>{if(i.page?.name!==O.page)return false;for(let s=a.get(i.parentId??"");s;s=a.get(s.parentId??""))if(s.name===O.logo)return true;return false};for(const i of e){const s=`${i.name} (${i.type.toLowerCase()})`;const l=(g,p,m,E=i.id)=>{r.push({check:g,nodeId:E,...p?{field:p}:{},...i.frame?{frame:i.frame}:{},message:m})};const d=it(i);const y=f(i);if(!y&&i.fills.some(g=>!g.bound))l("binding","fill",`${s}: fill is a raw value`);if(!y&&i.strokes.some(g=>!g.bound))l("binding","stroke",`${s}: stroke is a raw value`);if(i.type==="TEXT"&&i.textStyleId===null&&!d)l("binding","textStyle",`${s}: text has no library text style`);for(const g of d?[]:i.spacing){if(g.value>0&&!g.bound)l("binding",g.field,`${s}: ${g.field} ${g.value} is not a spacing variable`)}if((i.type==="COMPONENT"||i.type==="COMPONENT_SET")&&i.page?.name.startsWith(ye)&&i.parentId===i.page.id)l("placement",void 0,`${s}: sits on the page, outside its entry's component view`);if(i.set){const{width:g,height:p,variants:m}=i.set;m.forEach((E,A)=>{for(const N of m.slice(A+1)){if(rt(E,N))l("overlap",void 0,`${i.name}: ${E.name} overlaps ${N.name}`,E.id)}if(at(E,g,p))l("overlap",void 0,`${i.name}: ${E.name} reaches past the set, which cuts it off`,E.id)})}if(i.characters!==void 0&&!ge(i)){for(const g of X(i.characters,o))l("copy",g.field,`${s}: ${g.message}`)}if(i.instance){for(const g of i.instance.overrides){if(g.characters!==void 0){for(const p of X(g.characters,o))l("copy",p.field,`${i.name}: ${p.message}`,g.nodeId)}for(const p of g.fields){if(q.has(p))continue;if(p==="fills"&&g.picture)continue;const m=g.nodeId===i.id;if(!m&&(p==="fills"||p==="strokes")&&i.componentSource===true)continue;if(!m&&(p==="fills"||p==="strokes")&&c(g.nodeId))continue;const E=a.get(g.nodeId);if(!m&&(p==="fills"||p==="strokes")&&E?.source){if(we(E[p],E.source[p]))continue}if(m&&(p==="width"||p==="height")&&d)continue;if(m&&(p==="width"||p==="height")&&i.componentSource===true)continue;if(m&&p==="width"&&i.instance.sizing.horizontal!=="FIXED")continue;if(m&&p==="height"&&i.instance.sizing.vertical!=="FIXED")continue;if(m&&Z.has(p)&&Q(i.instance.sizing))continue;if(m&&J(p,i.box,i.instance.main))continue;l("overrides",p,`${p} overridden inside an instance of ${i.name}`,g.nodeId)}}}if(st(i))l("empty",void 0,`${i.name}: an empty frame ${Math.round(i.box?.width??0)}x${Math.round(i.box?.height??0)} that shows nothing; it holds no layer, so remove it or put in what it was made for`);if(me(i.type,i.name))l("naming",void 0,`${i.name} keeps a default name`);if(i.source){const g=["fills","strokes"].filter(p=>!we(i[p],i.source?.[p]??[]));if(g.length>0&&!w.has(i.id))l("binding",g[0]==="fills"?"fill":"stroke",`${s}: paints with another colour than the same layer in its component (${(i.source[g[0]??"fills"]??[]).map(p=>p.variable??"raw").join(", ")}), which an icon swap dropped`)}}const h=new Map(e.map(i=>[i.id,i.frame]));for(const{nodeId:i,field:s,message:l}of fe(e,n.branches)){const d=h.get(i);r.push({check:"documentation",nodeId:i,field:s,...d?{frame:d}:{},message:l})}return r}var H=18e3;function be(e){return encodeURIComponent(JSON.stringify(e)).replace(/%[0-9A-F]{2}/g,"x").length}function Y(e,t,n=H){const o={};for(const c of t)o[c.check]=(o[c.check]??0)+1;const r={checked:e,total:t.length,counts:o,findings:[],cut:false};let a=be(r);for(const c of t){a+=be(c)+1;if(a>n){r.cut=true;break}r.findings.push(c)}return r}function u(e,t){try{return e[t]}catch{return void 0}}var ct=["paddingTop","paddingRight","paddingBottom","paddingLeft","itemSpacing"];function _(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 Ee(e,t){if(e.id===t)return e;const n=u(e,"findOne");return n?n.call(e,o=>o.id===t):null}function Te(e,t){const n=t.get(e.id);if(n)return n;const o=e.parent??null;const r=o?Te(o,t):null;const a={frame:o?.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:o?.type==="INSTANCE"||(r?.insideInstance??false)};t.set(e.id,a);return a}var lt=new Set(["VECTOR","BOOLEAN_OPERATION","ELLIPSE","RECTANGLE","LINE","STAR","POLYGON"]);function dt(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 pt(e){const t=u(e,"children")??[];return{width:Number(u(e,"width")??0),height:Number(u(e,"height")??0),variants:t.map(({id:n,name:o,x:r,y:a,width:c,height:w})=>({id:n,name:o,x:r,y:a,width:c,height:w}))}}function ut(e,t){const n=u(e,"findAll");if(!n)return[];return n.call(e,o=>o.type==="TEXT"&&!t.has(o.id)).map(o=>typeof o.characters==="string"?o.characters:"")}function ft(e){const t=e?u(e,"fills"):void 0;return Array.isArray(t)&&t.some(n=>n.type==="IMAGE")}var ht=new Set(["FRAME","COMPONENT","COMPONENT_SET","INSTANCE","TEXT"]);var v=e=>typeof e==="number"?e:0;function gt(e){const t=u(e,"layoutMode");const n=typeof t==="string"?t:"NONE";const o=u(e,"children");const r=n==="GRID";return{x:v(u(e,"x")),y:v(u(e,"y")),width:v(u(e,"width")),height:v(u(e,"height")),sizing:{horizontal:String(u(e,"layoutSizingHorizontal")??"FIXED"),vertical:String(u(e,"layoutSizingVertical")??"FIXED")},layout:n,wrap:u(e,"layoutWrap")==="WRAP",padding:[v(u(e,"paddingTop")),v(u(e,"paddingRight")),v(u(e,"paddingBottom")),v(u(e,"paddingLeft"))],gap:r?v(u(e,"gridColumnGap")):v(u(e,"itemSpacing")),crossGap:r?v(u(e,"gridRowGap")):v(u(e,"counterAxisSpacing")),align:[String(u(e,"primaryAxisAlignItems")??"MIN"),String(u(e,"counterAxisAlignItems")??"MIN")],children:Array.isArray(o)?o.length:0}}function mt(e,t){const n=u(e,"fontSize");const o=u(e,"lineHeight");const r=u(e,"fontName");const a=typeof n==="number"?n:0;return{size:n===t?"mixed":a,lineHeight:o===t||typeof o!=="object"?"mixed":o.unit==="AUTO"?"auto":o.unit==="PERCENT"?a*v(o.value)/100:v(o.value),style:r===t||typeof r!=="object"?"mixed":String(r.style??"")}}function wt(e){if(e.type!=="COMPONENT_SET"&&(e.type!=="COMPONENT"||e.parent?.type==="COMPONENT_SET"))return void 0;const t=u(e,"componentPropertyDefinitions");if(!t)return void 0;return Object.entries(t).map(([n,{type:o,defaultValue:r}])=>({name:n.split("#")[0]??n,type:o,default:r}))}async function yt(e){const t=u(e,"getMainComponentAsync");return t?await t.call(e):null}function bt(e){if(!e)return null;return e.parent?.type==="COMPONENT_SET"?e.parent.name:e.name}function Et(e,t,n){const o=n.find(r=>r.id===e);if(!o?.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 Tt(e){const t=u(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 Nt(e){const t=u(e,"componentProperties");if(!t||typeof t!=="object")return void 0;const n={};for(const[o,r]of Object.entries(t)){const a=r?.value;if(typeof a==="string"||typeof a==="boolean")n[o.split("#")[0]??o]=a}return n}function St(e){const t=u(e,"explicitVariableModes");if(!t||typeof t!=="object")return void 0;const n=Object.entries(t).filter(o=>typeof o[1]==="string");return n.length>0?Object.fromEntries(n):void 0}async function Ne(e,t,n=typeof figma==="undefined"?Symbol("mixed"):figma.mixed,o=new Map,r=a=>figma.getNodeByIdAsync(a)){const a=e;const c=u(a,"textStyleId");const w=u(a,"boundVariables");const f=u(a,"overrides")??[];const h=new Set(f.filter(S=>S.overriddenFields.includes("characters")).map(S=>S.id));const i=e.type==="INSTANCE"?ut(e,h):[];const s=u(a,"layoutMode");const l=typeof s==="string"&&s!=="NONE";const d=Te(e,o);const y=lt.has(e.type)&&d.insideInstance&&!d.componentSource?dt(e.id):null;const g=y?await r(y):null;const p=e.type==="INSTANCE"?await yt(a):null;const m=e.type==="INSTANCE"?Et(e.id,p,f):null;const E=wt(a);const A=e.type==="INSTANCE"?Nt(e):void 0;const N=e.type==="INSTANCE"?Tt(e):[];const $=typeof p?.id==="string"?p.id:void 0;const F=St(e);return{id:e.id,name:e.name,type:e.type,parentId:a.parent?.id??null,frame:d.frame,created:t,fills:_(u(a,"fills")),strokes:_(u(a,"strokes")),textStyleId:e.type!=="TEXT"?null:c===n?"mixed":typeof c==="string"&&c?c:null,...e.type==="TEXT"&&!d.insideInstance?{characters:String(u(a,"characters")??"")}:{},instance:e.type==="INSTANCE"?{overrides:f.map(S=>({nodeId:S.id,fields:S.overriddenFields,...S.overriddenFields.includes("fills")&&ft(Ee(e,S.id))?{picture:true}:{},...h.has(S.id)?{characters:String(u(Ee(e,S.id),"characters")??"")}:{}})),...i.length>0?{carried:i}:{},sizing:{horizontal:String(u(a,"layoutSizingHorizontal")??"FIXED"),vertical:String(u(a,"layoutSizingVertical")??"FIXED")},...m?{main:m}:{}}:null,spacing:l?ct.map(S=>({field:S,value:Number(u(a,S)??0),bound:Boolean(w?.[S])})):[],...g?{source:{fills:_(u(g,"fills")),strokes:_(u(g,"strokes"))}}:{},page:d.page,componentSource:d.componentSource,...ht.has(e.type)?{box:gt(a)}:{},...e.type==="TEXT"?{font:mt(a,n)}:{},...E?{properties:E}:{},...e.type==="INSTANCE"?{main:bt(p)}:{},...$?{mainId:$}:{},...N.length>0?{swaps:N}:{},...A?{values:A}:{},...F?{modes:F}:{},...e.type==="COMPONENT_SET"?{set:pt(a)}:{}}}async function Se(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 o=e.root.children;const r=o.find(a=>a.id===n||a.name===n);if(!r)throw new Error(`no page ${n}; the pages are ${o.map(a=>a.name).join(", ")}`);if(r!==e.currentPage)await e.setCurrentPageAsync(r)}return e.currentPage.findAll()}async function It(e,t){const n=await Se(e,t.scope);const o=new Map;const r=await Promise.all(n.map(a=>Ne(a,false,e.mixed,o)));return Y(r.length,V(r,t.copy,{branches:t.branches??[]}))}return Ce(Ot);})();
|