efficient-shell 12.40.1 → 12.43.0

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.
Files changed (60) hide show
  1. package/README.md +80 -24
  2. package/dist/{Browser-2KAKTRNM.js → Browser-NZTDWV5B.js} +16 -16
  3. package/dist/{Files-TDFKJDFL.js → Files-EWEQJLO4.js} +130 -130
  4. package/dist/{Notepad-AP35IJOS.js → Notepad-3UID4FA5.js} +9 -9
  5. package/dist/{Preview-MWTFD5UE.js → Preview-XZYKED2Z.js} +13 -13
  6. package/dist/ai/index.d.ts +1 -1
  7. package/dist/apps/index.js +1 -1
  8. package/dist/bin/media-host-check.js +1 -1
  9. package/dist/bin/ui-check.js +1 -1
  10. package/dist/chunk-2HCV3KM3.js +2 -0
  11. package/dist/{chunk-VNROPHRY.js → chunk-53GA6ZWG.js} +2 -2
  12. package/dist/{chunk-JTMR3EH3.js → chunk-JZY2RBPX.js} +6 -6
  13. package/dist/chunk-KHVMKTOL.js +2 -0
  14. package/dist/{chunk-GFM6O57V.js → chunk-KY4YVFL5.js} +1 -1
  15. package/dist/{chunk-HNBMBC77.js → chunk-L2OPI4MY.js} +1 -1
  16. package/dist/chunk-NKDDKXJF.js +2 -0
  17. package/dist/{chunk-E6PDAYBR.js → chunk-O5UD3ZWM.js} +4 -4
  18. package/dist/chunk-OB2ZVMGR.js +1 -0
  19. package/dist/chunk-RHI37D5L.js +1 -0
  20. package/dist/{chunk-DSOV33XA.js → chunk-S7CWKKNP.js} +1 -1
  21. package/dist/{chunk-EUKTGRUD.js → chunk-SAYI67HY.js} +1 -1
  22. package/dist/data/Gantt.js +1 -1
  23. package/dist/forms/BrandAssetEditor.js +1 -1
  24. package/dist/forms/MediaLibrary.js +1 -1
  25. package/dist/forms/Select.d.ts +1 -1
  26. package/dist/forms/TextToolbar.d.ts +1 -1
  27. package/dist/forms/textAlign.d.ts +1 -1
  28. package/dist/icons/efficient-glyphs.d.ts +1 -0
  29. package/dist/icons/efficient-glyphs.js +1 -1
  30. package/dist/icons/efficient-looks.d.ts +2 -0
  31. package/dist/icons/efficient-looks.js +1 -1
  32. package/dist/icons/efficient-meanings.d.ts +1 -0
  33. package/dist/icons/efficient-meanings.js +1 -1
  34. package/dist/icons/efficient.d.ts +1 -0
  35. package/dist/icons/efficient.js +1 -1
  36. package/dist/icons/glyphs/IconAboveTextIcon.d.ts +8 -0
  37. package/dist/icons/glyphs/IconAboveTextIcon.js +1 -0
  38. package/dist/icons/index.d.ts +2 -2
  39. package/dist/icons/index.js +1 -1
  40. package/dist/icons/looks/IconAboveTextMiniIcon.d.ts +8 -0
  41. package/dist/icons/looks/IconAboveTextMiniIcon.js +1 -0
  42. package/dist/icons/looks/IconAboveTextSolidIcon.d.ts +8 -0
  43. package/dist/icons/looks/IconAboveTextSolidIcon.js +1 -0
  44. package/dist/icons/looks/map.js +1 -1
  45. package/dist/icons/sets.js +1 -1
  46. package/dist/index.d.ts +1 -1
  47. package/dist/index.js +142 -142
  48. package/dist/{names-BNKpHeTy.d.ts → names-F-LVocCZ.d.ts} +1 -1
  49. package/dist/shell/LanguageSelect.js +1 -1
  50. package/dist/shell/Markdown.d.ts +1 -1
  51. package/dist/shell/SettingRow.js +1 -1
  52. package/dist/telemetry/index.js +1 -1
  53. package/dist/tokens/colour.d.ts +2 -2
  54. package/dist/ui/index.d.ts +1 -1
  55. package/dist/ui/index.js +1 -1
  56. package/dist/version.js +1 -1
  57. package/package.json +1 -1
  58. package/dist/chunk-IESNUXYH.js +0 -1
  59. package/dist/chunk-YGWFOKBT.js +0 -1
  60. /package/dist/{chunk-VT7QZPIO.js → chunk-S7PTLTWK.js} +0 -0
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{execFileSync as e}from"child_process";import{createRequire as t}from"module";import{join as n}from"path";import{existsSync as i,readFileSync as o,writeFileSync as s,lstatSync as r,readdirSync as a}from"fs";var l=["button","input","range","textarea","select","dialog","title","portal","native","dark","hex","radius","spacing","font-size","z-index","shadow","kit","icon","svg","kit-dep","chart","chart-dep","ellipsis-label","colour","gutter-literal","view-line-literal","route-literal","root-zone-literal","phone-query","sizes-literal","money-cents","local-helper","deprecated-undated"],c=e=>"string"==typeof e&&l.includes(e),d=["kit-dep","chart-dep"],u=e=>d.includes(e),h=l.filter(e=>!u(e)),f=["gutter-literal","view-line-literal","route-literal","root-zone-literal","phone-query","sizes-literal","money-cents","local-helper","deprecated-undated"],p=e=>f.includes(e),m={button:{counts:"a raw <button>",instead:"Button or IconButton from efficient-shell/ui"},input:{counts:"a raw <input> (not hidden, not a range)",instead:"Input, InputNumber, Checkbox, Radio or Switch from efficient-shell/ui"},range:{counts:'a raw <input type="range">',instead:"Slider from efficient-shell/ui"},textarea:{counts:"a raw <textarea>",instead:"Textarea from efficient-shell/ui"},select:{counts:"a raw <select>",instead:"Select or SearchableSelect from efficient-shell/ui"},dialog:{counts:'a raw <dialog>, or role="dialog" / role="alertdialog" on a raw element',instead:"Dialog or Modal from efficient-shell"},title:{counts:"a title= on a raw element (the browser's own tooltip)",instead:"Tooltip from efficient-shell/ui (harness UI-17)"},portal:{counts:"a createPortal(…) call (a layer the file floats itself)",instead:"Popover, PopupMenu, DropdownMenu, Tooltip or Dialog from efficient-shell/ui"},native:{counts:"window.confirm / alert / prompt, or a bare call that resolves to one",instead:"confirm, confirmDestructive, prompt or toast from efficient-shell (harness UI-20)"},dark:{counts:"a dark: variant in a class string",instead:"the light Tailwind class alone; the shell remaps it in dark mode (harness UI-7)"},hex:{counts:"a hex colour literal in a .tsx string",instead:"a colour role from efficient-shell: its utility or var(--role), COLOUR_ROLES lists them (harness FT-1; the colour kind counts palette classes too)"},radius:{counts:"a literal corner radius (an arbitrary-value radius class, or an inline borderRadius)",instead:"a radius utility from the scale or a role token such as rounded-(--radius-control); the theme sets how round they are (harness UI-7)"},spacing:{counts:"a padding, margin or gap off the scale (6px, 10px, 14px …) or written as a literal length (an arbitrary-value class, an inline style)",instead:"a step of the scale 2/4/8/12/16/20/24/32/40/48 — a Tailwind step, or a role such as var(--space-control-x) (owner ruling 2026-10-12)"},"font-size":{counts:"a literal font size (an arbitrary-value text class, an inline fontSize)",instead:"a type step 9/11/12/14/16/18/20/24/30 — Tailwind's 3xs … 3xl text steps (owner ruling 2026-10-12)"},"z-index":{counts:"a stack order above 30 written as a number (a z utility, an arbitrary value, an inline zIndex)",instead:"a named layer: Z_LAYERS (efficient-shell/ui) in code, its --z-* custom property in markup"},shadow:{counts:"a literal shadow, or a shadow size that is not an elevation level (md, 2xl, xs)",instead:"an elevation: the sm / lg / xl utilities, or var(--elevation-panel) and its siblings (owner ruling 2026-10-12)"},kit:{counts:"an import of a second UI kit",instead:"the component from efficient-shell/ui, or fold it into the shell (harness FT-3)"},icon:{counts:"an import of an icon package",instead:"<Icon name> from efficient-shell/icons, drawn by the one set (harness UI-24)"},svg:{counts:"an <svg> element written in JSX: an icon drawn in place",instead:"<Icon name> from efficient-shell/icons, drawn by the one set (harness UI-24). A chart, an illustration or a mark a host supplies stays on the baseline"},"kit-dep":{counts:"a UI kit or icon package declared in package.json (not one the shell entries imported here need)",instead:"remove the dependency once nothing imports it (harness FT-3)"},chart:{counts:"an import of a second chart library",instead:"a chart from efficient-shell/ui (ChartFrame, TimeSeriesChart, ColumnChart, RankedBars, PieChart, FunnelChart, ScatterChart, …), or add the chart there: one chart system (harness FT-3)"},"chart-dep":{counts:"a chart library declared in package.json",instead:"remove the dependency once nothing imports it (harness FT-3)"},"ellipsis-label":{counts:'a button, link or menu label that ends in "…" or "..."',instead:'the label without the dots, saying what it does ("Extend trial"): "…" means only "the words are cut" (owner ruling 2026-10-14)'},colour:{counts:"a literal colour, in a script string or a stylesheet: a hex, an rgb() / hsl() / oklch() value, a Tailwind palette class (a hue and a step, or white / black), a --color-<hue>-<step> variable, or a named colour in a colour property — a var() fallback included",instead:"a colour role from efficient-shell: its utility (the text, background or border utility of ink, ink-faint, surface, line, accent-fill, accent-text, danger-text, status-danger-line …) or var(--role); COLOUR_ROLES lists them. A merchant site reads the site theme (owner ruling 2026-10-23)"},"gutter-literal":{counts:"the site gutter typed with its own fallback, var(--sf-site-gutter, 40px), in script source (stylesheets are not read)",instead:"SITE_GUTTER_CLASS from efficient-web-builder (lib/content/page-width): the whole class, because Tailwind reads only whole literals; SITE_GUTTER_CAP for the number"},"view-line-literal":{counts:"the 960px written as a length in script source (a max-/min- variant, a media query; a sizes string counts here too)",instead:"the view-lines table in efficient-web-builder (lib/content/view-lines, lib/content/box-stack-line)"},"route-literal":{counts:"a page path typed by hand before a slug: /wheels/, /journal/, /tyres/",instead:"pagePath, postPath or wheelPath from efficient-web-builder (lib/links/page-link-rules), tyrePagePath from efficient-storefront-blocks (render/lib/tyres/tyre-page-path)"},"root-zone-literal":{counts:'the easel root zone key typed as a string ("root:default-zone")',instead:"ROOT_ZONE from efficient-easel (screen/lib/document/content-tree)"},"phone-query":{counts:"the app phone line typed as a media query in script source: (max-width: 767px)",instead:"useIsMobile from efficient-shell: ask the hook, do not write the query"},"sizes-literal":{counts:"a hand-written responsive sizes string (a sizes attribute or sizes: entry with a media condition)",instead:"a named sizes shape from efficient-web-builder (lib/sized-image), built from the view lines"},"money-cents":{counts:"a money amount (amount, price, total, cents, fee, cost, balance) multiplied or divided by 100 by hand",instead:"createMoneyFormatter / useCurrency from efficient-storefront-blocks (render/components/CurrencyContext) for a shopper; formatMoney / currencyDecimals from efficient-shell for the ERP"},"local-helper":{counts:"a local definition (function or const) of a helper a package exports, by name: escapeHtml, deepEqual, timeAgo, formatBytes, hexToRgb and the rest of LOCAL_HELPERS",instead:"import the helper from its home (LOCAL_HELPERS in efficient-shell src/ui-check/kinds.ts names each one)"},"deprecated-undated":{counts:'a @deprecated note (a block comment, or a run of whole-line comments) that does not say "delete by YYYY-MM-DD" with a real day from today to 6 months out, or that still says "next major"',instead:'write the day the thing goes ("Delete by 2026-12-15, after <the move>") and a backlog line that owns the move; on that day delete it, or set a new day with the reason'}},g={escapeHtml:"efficient-shell (utils/escapeHtml)",deepEqual:"efficient-easel (data)",draftsEqual:"efficient-easel deepEqual (data)",timeAgo:"efficient-shell (format)",formatBytes:"efficient-shell (format)",formatFileSize:"efficient-shell formatBytes (format)",fileSize:"efficient-shell formatBytes (format)",humanSize:"efficient-shell formatBytes (format)",hexToRgb:"efficient-shell (forms/color)",parseHex:"efficient-shell parseHexColor (forms/color)",parseHexColor:"efficient-shell (forms/color)",hexOf:"efficient-shell parseHexColor (forms/color)",withAlpha:"efficient-shell hexWithAlpha (forms/colorMix)",isDarkInk:"efficient-shell readableInk (forms/color)",relativeLuminance:"efficient-shell (forms/color)",contrastRatio:"efficient-shell (forms/color)"},w=["@headlessui/","@radix-ui/","@mui/","@chakra-ui/","@mantine/","@floating-ui/","antd","react-aria","react-aria-","react-bootstrap","react-select","react-colorful","react-tooltip","react-hot-toast","react-toastify","sonner","efficient-shell-checker"],x=["@heroicons/","@tabler/icons","@tabler/icons-","@phosphor-icons/","@fortawesome/","@iconify/","@radix-ui/react-icons","@mui/icons-material","lucide","lucide-react","simple-icons","react-icons","react-feather"],k=["recharts","chart.js","react-chartjs-2","d3","d3-","@nivo/","victory","victory-","echarts","echarts-for-react","apexcharts","react-apexcharts","@visx/","highcharts","highcharts-react-official","plotly.js","plotly.js-dist","react-plotly.js","lightweight-charts","@antv/g2","@antv/g2plot","chartist","billboard.js","c3","uplot"],b={"efficient-shell":["@headlessui/react"]};function y(e,t){return t.some(t=>t.endsWith("/")||t.endsWith("-")?e.startsWith(t):e===t||e.startsWith(`${t}/`))}function $(e){return y(e,x)?"icon":y(e,w)?"kit":y(e,k)?"chart":null}function v(e){const t=$(e);return"kit"===t||"icon"===t?"kit-dep":"chart"===t?"chart-dep":null}var S=/[.+^$()|[\]\\]/g;function z(e){let t="",n=0;for(let i=0;i<e.length;i++){const o=e[i];"*"===o?"*"===e[i+1]?"/"===e[i+2]?(t+="(?:[^/]+/)*",i+=2):(t+=".*",i+=1):t+="[^/]*":"?"===o?t+="[^/]":"{"===o?(t+="(?:",n+=1):"}"===o&&n>0?(t+=")",n-=1):t+=","===o&&n>0?"|":o.replace(S,"\\$&")}if(0!==n)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${t}$`)}function E(e){const t=e.map(z);return e=>t.some(t=>t.test(e))}var I=new Set(["node_modules",".git"]),j=new Set(["dist","coverage",".next",".turbo"]);function C(e){const t=e.search(/[*?{]/),n=-1===t?e:e.slice(0,t),i=n.lastIndexOf("/");return-1===i?"":n.slice(0,i)}function A(e,t){const i=E(t),o=[...new Set(t.map(C))].sort(),s=o.filter(e=>!o.some(t=>t!==e&&(""===t||e.startsWith(`${t}/`)))),r=new Set,l=t=>{let o;try{o=a(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?I.has(e.name)||""===t&&j.has(e.name)||l(n):e.isFile()&&i(n)&&r.add(n)}};for(const e of s)l(e);return[...r].sort(L)}var L=(e,t)=>e<t?-1:e>t?1:0,T=class extends Error{},R=(e,t)=>`${e}:${t}`;function M(e){const t=e.lastIndexOf(":");return{file:e.slice(0,t),kind:e.slice(t+1)}}var D=e=>l.indexOf(e);function B(e,t){const n=M(e),i=M(t);return L(n.file,i.file)||D(n.kind)-D(i.kind)}function P(e,t="ui-kit.baseline.json"){let n;try{n=JSON.parse(e)}catch(e){throw new T(`${t} is not valid JSON: ${e.message}`)}const i=e=>{throw new T(`${t}: ${e}. The tool writes this file; do not edit it by hand.`)};if("object"!=typeof n||null===n||Array.isArray(n))return i("must be a JSON object");const o=n;if(1!==o.schema)return i("number"==typeof o.schema&&o.schema>1?`"schema": ${o.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');if(!Array.isArray(o.kinds)||o.kinds.some(e=>"string"!=typeof e))return i('"kinds" must be a list');const s=o.kinds.filter(c);if("object"!=typeof o.counts||null===o.counts||Array.isArray(o.counts))return i('"counts" must be an object');const r=new Map;for(const[e,t]of Object.entries(o.counts)){const{file:n,kind:o}=M(e);if(!n||!o)return i(`"${e}" is not "<file>:<kind>"`);if("number"!=typeof t||!Number.isInteger(t)||t<1)return i(`"${e}" must be a whole number, 1 or more (a line that reaches 0 is deleted)`);c(o)&&r.set(e,t)}return{kinds:s,counts:r}}function O(e){const t=l.filter(t=>e.kinds.includes(t)),n=[...e.counts.keys()].filter(t=>(e.counts.get(t)??0)>0).sort(B).map(t=>` ${JSON.stringify(t)}: ${e.counts.get(t)}`);return["{",' "schema": 1,',` "kinds": [${t.map(e=>JSON.stringify(e)).join(", ")}],`,n.length?` "counts": {\n${n.join(",\n")}\n }`:' "counts": {}',"}",""].join("\n")}function N(e){const t={};for(const[n,i]of e){const{kind:e}=M(n);c(e)&&(t[e]=(t[e]??0)+i)}return t}var F=class extends Error{},J=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),U=new Set(["$schema","schema","kinds","include","exclude","includeImporting","output","includeCopies","allow"]);function q(e,t="ui-kit.config.json"){const n=[],i=e=>{n.push(e)},o=(e,t,{required:n=!1}={})=>{if(void 0===e&&!n)return[];if(!Array.isArray(e)||e.some(e=>"string"!=typeof e||""===e))return i(`${t} must be a list of non-empty strings`),[];n&&0===e.length&&i(`${t} must name at least one entry`);for(const n of e)(n.startsWith("/")||n.startsWith("./")||n.includes("\\")||n.split("/").includes(".."))&&i(`${t}: "${n}" must be a path from the repository root, written with / (no ./, .. or \\)`);return e},s=(e,t)=>"string"!=typeof e||e.trim().length<10?(i(`${t} needs a "reason" a reviewer can read (a sentence, not a word)`),""):e,r=(e,t)=>void 0===e?[]:!Array.isArray(e)||e.some(e=>!J(e))?(i(`${t} must be a list of objects`),[]):e;if(!J(e))throw new F(`${t}: must be a JSON object`);for(const t of Object.keys(e))U.has(t)||i(`unknown key "${t}"`);1!==e.schema&&i("number"==typeof e.schema&&e.schema>1?`"schema": ${e.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');const a=[];if(Array.isArray(e.kinds)&&0!==e.kinds.length)for(const t of e.kinds)c(t)?a.includes(t)?i(`"kinds": "${t}" is listed twice`):a.push(t):i(`"kinds": unknown kind ${JSON.stringify(t)} (this efficient-shell knows: ${l.join(", ")})`);else i(`"kinds" must list the kinds this repository checks, from: ${l.join(", ")}`);const d=o(e.include,'"include"'),u=o(e.exclude,'"exclude"'),h=r(e.includeImporting,'"includeImporting"').map((e,t)=>({files:o(e.files,`"includeImporting"[${t}].files`,{required:!0}),modules:o(e.modules,`"includeImporting"[${t}].modules`,{required:!0}),reason:s(e.reason,`"includeImporting"[${t}]`)}));0===d.length&&0===h.length&&i('"include" must name the files that are operator UI (for example ["src/**/*.tsx"])');const m=r(e.output,'"output"').map((e,t)=>({files:o(e.files,`"output"[${t}].files`,{required:!0}),reason:s(e.reason,`"output"[${t}]`)})),g=o(e.includeCopies,'"includeCopies"');g.length&&!a.some(p)&&i(`"includeCopies" is read only by the copied-value kinds (${f.join(", ")}), and "kinds" names none of them`);const w=[],x=new Set;if(r(e.allow,'"allow"').forEach((e,t)=>{const n=`"allow"[${t}]`,[r]=o([e.file],`${n}.file`),d=s(e.reason,n);if(!c(e.kind))return void i(`${n}.kind must be one of: ${l.join(", ")}`);if(a.includes(e.kind)||i(`${n}: kind "${e.kind}" is not in "kinds"`),"number"!=typeof e.count||!Number.isInteger(e.count)||e.count<1)return void i(`${n}.count must be a whole number, 1 or more`);if(!r)return;const u=`${r}:${e.kind}`;x.has(u)&&i(`${n}: ${r} already has an allow entry for "${e.kind}"`),x.add(u),w.push({file:r,kind:e.kind,count:e.count,reason:d})}),n.length)throw new F(`${t}:\n - ${n.join("\n - ")}`);return{schema:1,kinds:l.filter(e=>a.includes(e)),include:d,exclude:u,includeImporting:h,output:m,includeCopies:g,allow:w}}var W="package.json",_=[2,4,8,12,16,20,24,32,40,48];function Y(e){if("0"===e||"px"===e)return!0;const t=Number(e);return!!Number.isFinite(t)&&_.includes(4*t)}var H=e=>String(e).padStart(2,"0"),K=/^(\d{4})-(\d{2})-(\d{2})$/;function G(e){return`${function(e){return`${e.getFullYear()}-${H(e.getMonth()+1)}`}(e)}-${H(e.getDate())}`}function Z(e){const t="string"==typeof e?K.exec(e):null;if(!t)return null;const n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return G(n)===e?n:null}var V=new Set(["iframe","frame","object","embed"]),Q=new Set(["href","xlinkHref","to","id","key","htmlFor"]),X=/(?<![&\w])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,ee=/(?<![\w-])rounded(?:-(?:[trblse]|tl|tr|br|bl|ss|se|ee|es))?-\[([^\]]*)\]/g,te=/^border(?:(?:Top|Bottom)(?:Left|Right)|(?:Start|End)(?:Start|End))?Radius$/,ne=/^(?:inherit|initial|unset|revert)$|var\(|^(?:50|100)%$|^(?:999|9999)(?:px)?$/,ie=/(?<![\w-])-?(?:p|px|py|pt|pr|pb|pl|ps|pe|m|mx|my|mt|mr|mb|ml|ms|me|gap|gap-x|gap-y|space-x|space-y)-(\d+(?:\.\d+)?|px|\[[^\]]*\])(?![\w.[/-])/g,oe=/(?<![\w-])text-\[(?:length:)?(\d*\.?\d+(?:px|rem|em|%))\]/g,se=/(?<![\w-])z-(\d+|\[[^\]]*\])(?![\w.[/-])/g,re=/(?<![\w-])shadow-(xs|2xs|md|2xl|\[[^\]]*\])(?![\w.[/-])/g,ae=/var\(|^(?:inherit|initial|unset|revert|revert-layer|none|auto)$/,le=/^(?:(?:padding|margin)(?:Top|Right|Bottom|Left|Inline|Block|InlineStart|InlineEnd|BlockStart|BlockEnd)?|gap|rowGap|columnGap)$/,ce=new Set([0,..._]),de=/var\(\s*--sf-site-gutter\s*,\s*-?\d/g,ue=/(?<![\w.-])960px(?![\w-])/g,he=/(?:^|[^\w-])\/(?:wheels|journal|tyres)\/$/,fe=/root:default-zone/g,pe=/max-width:\s*767px(?![\w-])/g,me=/\((?:max|min)-width/,ge=/(?:^|[a-z0-9_])(?:amount|price|total|subtotal|cents|fee|fees|cost|balance)$|(?:Amount|Price|Total|Subtotal|Cents|Fee|Fees|Cost|Balance)$/,we=/(?<![\w-])dark:(?=[\w[\-!@*(])/g,xe="slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose",ke="(?:50|[1-9]00|950)",be=new RegExp(`(?<![\\w-])(?:bg|text|border(?:-[xytrblse])?|ring(?:-offset)?|inset-ring|outline|divide|fill|stroke|from|via|to|shadow|inset-shadow|drop-shadow|accent|caret|decoration|placeholder)-(?:(?:${xe})-${ke}|white|black)(?:\\/[\\w.]+)?(?![\\w-])`,"g"),ye=new RegExp(`--color-(?:(?:${xe})-${ke}|white|black)(?![\\w-])`,"g"),$e=/(?<![\w-])(?:rgba?|hsla?|hwb|oklch|oklab|lab|lch)\(\s*[\d.]/g,ve=/(?<![\w-])(?:white|black|red|green|blue|yellow|orange|purple|pink|gray|grey|silver|maroon|navy|teal|olive|lime|aqua|fuchsia|brown|gold|beige|ivory|tan|crimson|coral|salmon|indigo|violet)(?![\w-])/gi,Se=/^(?:color|background(?:Color)?|border(?:Top|Right|Bottom|Left|Inline|Block)?(?:Color)?|outline(?:Color)?|fill|stroke|caretColor|accentColor|textDecorationColor|boxShadow|textShadow)$/,ze=/(?<![&a-zA-Z0-9])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,Ee=e=>[...e.matchAll(ze)].length+[...e.matchAll($e)].length+[...e.matchAll(be)].length+[...e.matchAll(ye)].length,Ie=new Set(["button","a","option","Button","IconButton","SplitButton","Link","NavLink","PopupMenuItem","PopupMenuLabel","DropdownMenuItem","MenuItem","ContextMenuItem"]),je=/(?:…|\.\.\.|&hellip;)\s*$/,Ce=new RegExp("\\p{L}","u"),Ae=new RegExp("\\p{L}[\\p{L}-]*","u"),Le={busy:{words:["Accepting","Adding","Applying","Approving","Arranging","Asking","Assigning","Booking","Building","Calculating","Cancelling","Capturing","Changing","Checking","Choosing","Closing","Combining","Comparing","Completing","Confirming","Connecting","Converting","Copying","Correcting","Counting","Creating","Deleting","Detaching","Downloading","Drawing","Duplicating","Emailing","Ending","Exporting","Fetching","Filing","Finding","Flushing","Generating","Grouping","Importing","Linking","Loading","Locating","Looking","Making","Marking","Matching","Measuring","Merging","Moving","Opening","Ordering","Paying","Pending","Posting","Preparing","Previewing","Pricing","Processing","Provisioning","Publishing","Purging","Pushing","Queued","Queuing","Quoting","Re-booking","Re-importing","Re-opening","Reading","Rebooting","Rebuilding","Receiving","Reconciling","Reconnecting","Recording","Refreshing","Refunding","Regenerating","Registering","Reinstating","Rejecting","Removing","Reopening","Requesting","Resending","Resetting","Resolving","Restarting","Restoring","Resuming","Retrying","Reversing","Reverting","Running","Saving","Searching","Sending","Setting","Settling","Sharing","Signing","Splitting","Starting","Submitting","Suggesting","Switching","Syncing","Taking","Testing","Transferring","Typing","Updating","Uploading","Verifying","Waiting","Withdrawing","Working"],zhStarts:["正在"],zhEnds:["中"]},placeholder:{},prompt:{}},Te=new Set((Le.busy?.words??[]).map(e=>e.toLowerCase())),Re=new Set(["label","aria-label",...Le.placeholder?[]:["placeholder","searchPlaceholder","emptyOptionLabel","blankLabel"]]),Me=(e,t)=>{if(!je.test(t)||!Ce.test(e))return!1;const n=e.match(Ae)?.[0]?.toLowerCase();if(n&&Te.has(n))return!1;const i=e.replace(je,"").trim(),o=Le.busy;return!(o&&(o.zhStarts.some(e=>i.startsWith(e))||o.zhEnds.some(e=>i.endsWith(e))))},De=new Set(["confirm","alert","prompt"]),Be=new Set(["window","globalThis","self"]);var Pe=e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"),Oe=e=>/\.(?:css|scss)$/.test(e),Ne=/^(?:color|background(?:-color)?|border(?:-(?:top|right|bottom|left|inline|block)(?:-(?:start|end))?)?(?:-color)?|outline(?:-color)?|fill|stroke|caret-color|accent-color|text-decoration(?:-color)?|box-shadow|text-shadow|column-rule(?:-color)?)$/;function Fe(e,t){if(!t.includes("colour"))return{};const n=e.replace(/\/\*[\s\S]*?\*\//g,e=>e.replace(/[^\n]/g," ")),i=[],o=e=>n.slice(0,e).split("\n").length;let s=0,r=0;for(let e=0;e<n.length;e++){const t=n[e];if("{"===t||"}"===t||";"===t){const a=n.slice(r,e);if("{"!==t&&s>0){const e=r+(a.length-a.trimStart().length),t=a.trim(),n=t.indexOf(":");if(t.startsWith("@apply"))for(let n=[...t.matchAll(be)].length;n>0;n--)i.push(o(e));else if(n>0){const s=t.slice(0,n).trim().toLowerCase(),r=t.slice(n+1);if(!/^(?:-webkit-)?mask/.test(s)){const t=Ee(r)+(Ne.test(s)?[...r.matchAll(ve)].length:0);for(let n=0;n<t;n++)i.push(o(e))}}}"{"===t?s++:"}"===t&&(s=Math.max(0,s-1)),r=e+1}}return i.length?{colour:i}:{}}function Je(e,t,n,i,o){const s=new Set(i),r=e.createSourceFile(t,n,e.ScriptTarget.Latest,!0,function(e,t){return t.endsWith(".tsx")?e.ScriptKind.TSX:t.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(t)?e.ScriptKind.JS:e.ScriptKind.TS}(e,t)),a={},l=/\.[jt]sx$/.test(t),c=e=>r.getLineAndCharacterOfPosition(e).line+1,d=(e,t)=>{s.has(e)&&(a[e]??=[]).push(c(t.getStart(r)))},u=(t,n)=>t.attributes.properties.find(t=>e.isJsxAttribute(t)&&t.name.getText(r)===n),h=t=>{const n=t?.initializer;if(n)return e.isStringLiteral(n)?n.text:e.isJsxExpression(n)&&n.expression&&e.isStringLiteralLike(n.expression)?n.expression.text:void 0},f=new Set;if(s.has("native")){const t=n=>{if(n)if(e.isIdentifier(n))De.has(n.text)&&f.add(n.text);else if(e.isObjectBindingPattern(n)||e.isArrayBindingPattern(n))for(const i of n.elements)e.isBindingElement(i)&&t(i.name)},n=i=>{(e.isImportClause(i)||e.isImportSpecifier(i)||e.isNamespaceImport(i)||e.isVariableDeclaration(i)||e.isParameter(i)||e.isFunctionDeclaration(i))&&t(i.name),e.forEachChild(i,n)};n(r)}const p=t=>t&&e.isStringLiteralLike(t)?t.text:void 0,m=(e,t)=>{e&&("efficient-shell"===e||e.startsWith("efficient-shell/"))&&o?.add(e);const n=e?$(e):null;n&&d(n,t)},w=(e,t,n)=>{if(s.has("dark"))for(const n of e.matchAll(we))d("dark",t);if(s.has("radius"))for(const n of e.matchAll(ee))ne.test(n[1].trim())||d("radius",t);if(n&&l&&s.has("hex"))for(const n of e.matchAll(X))d("hex",t);if(n&&s.has("colour"))for(let n=Ee(e);n>0;n--)d("colour",t);if(s.has("spacing"))for(const n of e.matchAll(ie)){const e=n[1];(e.startsWith("[")?ae.test(e.slice(1,-1).trim()):Y(e))||d("spacing",t)}if(s.has("font-size"))for(const n of e.matchAll(oe))d("font-size",t);if(s.has("z-index"))for(const n of e.matchAll(se)){const e=n[1].startsWith("[")?n[1].slice(1,-1).trim():n[1];/^\d+$/.test(e)&&Number(e)>30&&d("z-index",t)}if(s.has("shadow"))for(const n of e.matchAll(re))n[1].startsWith("[")&&ae.test(n[1].slice(1,-1).trim())||d("shadow",t);if(s.has("gutter-literal"))for(const n of e.matchAll(de))d("gutter-literal",t);if(s.has("view-line-literal"))for(const n of e.matchAll(ue))d("view-line-literal",t);if(s.has("route-literal")&&he.test(e)&&d("route-literal",t),s.has("root-zone-literal"))for(const n of e.matchAll(fe))d("root-zone-literal",t);if(s.has("phone-query"))for(const n of e.matchAll(pe))d("phone-query",t)},x=t=>{if(t)return e.isJsxExpression(t)?x(t.expression):e.isStringLiteralLike(t)?t.text:e.isTemplateExpression(t)?[t.head.text,...t.templateSpans.map(e=>e.literal.text)].join(" "):void 0},k=t=>e.isNumericLiteral(t)&&100===Number(t.text),b=(t,n,i)=>{const o=e.isStringLiteralLike(n)?n.text.trim():void 0;if(s.has("colour")&&void 0!==o&&Se.test(t))for(const e of o.matchAll(ve))d("colour",i);if(s.has("spacing")&&le.test(t))e.isNumericLiteral(n)?ce.has(Number(n.text))||d("spacing",i):void 0!==o&&!ae.test(o)&&(e=>[...e.matchAll(/(-?\d*\.?\d+)(px|rem|em)\b/g)].map(e=>Math.abs(Number(e[1]))*("px"===e[2]?1:16)))(o).some(e=>!ce.has(e))&&d("spacing",i);else if(s.has("font-size")&&"fontSize"===t)(e.isNumericLiteral(n)||void 0!==o&&!ae.test(o)&&!/^(?:smaller|larger)$/.test(o))&&d("font-size",i);else if(s.has("z-index")&&"zIndex"===t){const t=[],o=n=>{e.isNumericLiteral(n)||e.isStringLiteralLike(n)&&/^\d+$/.test(n.text.trim())?t.push(Number(n.text)):e.forEachChild(n,o)};o(n);for(const e of t)e>30&&d("z-index",i)}else s.has("shadow")&&"boxShadow"===t&&(void 0===o||""===o||ae.test(o)||d("shadow",i))},y=(t,n)=>{if(e.isJsxOpeningElement(t)||e.isJsxSelfClosingElement(t)){const e=t.tagName.getText(r);if(s.has("sizes-literal")){const e=x(u(t,"sizes")?.initializer);void 0!==e&&me.test(e)&&d("sizes-literal",t)}if(/^[a-z]/.test(e)){const n=h(u(t,"type"));"svg"===e&&d("svg",t),"button"===e?d("button",t):"select"===e?d("select",t):"textarea"===e?d("textarea",t):"input"===e&&("range"===n?d("range",t):"hidden"!==n&&d("input",t));const i=h(u(t,"role"));"dialog"!==e&&"dialog"!==i&&"alertdialog"!==i||d("dialog",t),!V.has(e)&&u(t,"title")&&d("title",t)}}else if(e.isCallExpression(t)){const n=t.expression;e.isIdentifier(n)?"createPortal"===n.text?d("portal",t):De.has(n.text)&&!f.has(n.text)?d("native",t):"require"===n.text&&m(p(t.arguments[0]),t):e.isPropertyAccessExpression(n)?"createPortal"===n.name.text?d("portal",t):De.has(n.name.text)&&e.isIdentifier(n.expression)&&Be.has(n.expression.text)&&d("native",t):n.kind===e.SyntaxKind.ImportKeyword&&m(p(t.arguments[0]),t)}else{if(e.isImportDeclaration(t)||e.isExportDeclaration(t))return void m(p(t.moduleSpecifier),t);if(e.isPropertyAssignment(t)){const n=e.isIdentifier(t.name)||e.isStringLiteralLike(t.name)?t.name.text:"",i=t.initializer;if(b(n,i,t),s.has("sizes-literal")&&"sizes"===n){const e=x(i);void 0!==e&&me.test(e)&&d("sizes-literal",t)}s.has("radius")&&te.test(n)&&(e.isNumericLiteral(i)?ne.test(i.text)||d("radius",t):e.isStringLiteralLike(i)&&!ne.test(i.text.trim())&&d("radius",t))}else if(e.isBinaryExpression(t)){const n=t.operatorToken.kind;if(s.has("money-cents")&&(n===e.SyntaxKind.AsteriskToken||n===e.SyntaxKind.SlashToken)){const i=k(t.right)?t.left:k(t.left)&&n===e.SyntaxKind.AsteriskToken?t.right:void 0,o=i&&(t=>{let n=t;for(;e.isParenthesizedExpression(n)||e.isNonNullExpression(n)||e.isAsExpression(n);)n=n.expression;return e.isCallExpression(n)&&(n=n.expression),e.isIdentifier(n)?n.text:e.isPropertyAccessExpression(n)?n.name.text:e.isElementAccessExpression(n)&&e.isStringLiteralLike(n.argumentExpression)?n.argumentExpression.text:void 0})(i);o&&ge.test(o)&&d("money-cents",t)}}else if(s.has("local-helper")&&(e.isFunctionDeclaration(t)||e.isVariableDeclaration(t))&&t.name&&e.isIdentifier(t.name)&&Object.prototype.hasOwnProperty.call(g,t.name.text)&&(e.isFunctionDeclaration(t)?void 0!==t.body:void 0!==t.initializer&&(e.isArrowFunction(t.initializer)||e.isFunctionExpression(t.initializer))))d("local-helper",t);else if(e.isStringLiteralLike(t))w(t.text,t,n);else if(e.isTemplateExpression(t)){w(t.head.text,t.head,n);for(const e of t.templateSpans)w(e.literal.text,e.literal,n)}}e.isJsxAttribute(t)&&Q.has(t.name.getText(r))?e.forEachChild(t,e=>y(e,!1)):e.forEachChild(t,e=>y(e,n))};if(y(r,!0),s.has("ellipsis-label")&&function(e,t,n){const i=new Set,o=(e,t)=>{i.has(e)||(i.add(e),n(t))},s=n=>{if(n)if(e.isStringLiteralLike(n))Me(n.text,n.text)&&o(n,n.getStart(t));else if(e.isTemplateExpression(n)){const e=[n.head.text,...n.templateSpans.map(e=>e.literal.text)];Me(e.join(" "),e[e.length-1])&&o(n,n.getStart(t))}else e.isConditionalExpression(n)?(s(n.whenTrue),s(n.whenFalse)):e.isBinaryExpression(n)?(s(n.left),s(n.right)):e.isParenthesizedExpression(n)||e.isAsExpression(n)||e.isJsxExpression(n)?s(n.expression):e.isCallExpression(n)&&Ye.has(He(n.expression))&&n.arguments[0]&&s(n.arguments[0])},r=n=>{for(const i of n)if(e.isJsxText(i)){const e=i.getText(t);Me(e,e)&&o(i,i.getStart(t)+(e.length-e.trimStart().length))}else e.isJsxExpression(i)?s(i.expression):(e.isJsxElement(i)||e.isJsxFragment(i))&&r(i.children)},a=(n,i)=>{const o=n.attributes.properties.find(n=>e.isJsxAttribute(n)&&n.name.getText(t)===i),s=o?.initializer;return s&&e.isStringLiteral(s)?s.text:s&&e.isJsxExpression(s)&&s.expression&&e.isStringLiteralLike(s.expression)?s.expression.text:void 0},l=t=>t.properties.some(t=>e.isPropertyAssignment(t)&&(e.isIdentifier(t.name)||e.isStringLiteralLike(t.name))&&"value"===t.name.text&&e.isStringLiteralLike(t.initializer)&&""===t.initializer.text),c=n=>{if(e.isJsxElement(n)){const e=n.openingElement,i=e.tagName.getText(t),o="option"===i&&Le.prompt&&""===a(e,"value");Ie.has(i)&&!o&&r(n.children)}else if(e.isJsxAttribute(n))Re.has(n.name.getText(t))&&s(n.initializer);else if(e.isPropertyAssignment(n)){const t=e.isIdentifier(n.name)||e.isStringLiteralLike(n.name)?n.name.text:"",i=Le.prompt&&e.isObjectLiteralExpression(n.parent)&&l(n.parent);Re.has(t)&&!i&&s(n.initializer)}e.forEachChild(n,c)};c(t)}(e,r,e=>(a["ellipsis-label"]??=[]).push(c(e))),s.has("deprecated-undated")){const t=G(new Date);for(const n of function(e,t){const n=t.text,i=new Map,o=e=>e?.forEach(e=>i.set(e.pos,e)),s=t=>{o(e.getLeadingCommentRanges(n,t.pos)),o(e.getTrailingCommentRanges(n,t.end)),e.forEachChild(t,s)};s(t),o(e.getLeadingCommentRanges(n,t.endOfFileToken.pos));const r=[],a=e=>/^[ \t]*$/.test(n.slice(n.lastIndexOf("\n",e-1)+1,e));for(const t of[...i.values()].sort((e,t)=>e.pos-t.pos)){const i=n.slice(t.pos,t.end);if(t.kind===e.SyntaxKind.MultiLineCommentTrivia){r.push({pos:t.pos,text:i,end:t.end,run:!1});continue}const o=a(t.pos),s=r[r.length-1];o&&s?.run&&/^[ \t]*\r?\n[ \t]*$/.test(n.slice(s.end,t.pos))?(s.text+="\n"+i,s.end=t.end):r.push({pos:t.pos,text:i,end:t.end,run:o})}return r}(e,r)){const e=n.text.indexOf("@deprecated");e>=0&&_e(n.text,t)&&(a["deprecated-undated"]??=[]).push(c(n.pos+e))}}return a}var Ue=/\b(?:delete|deleted|remove|removed|goes|go)\s+(?:[\w`'.-]+\s+){0,2}?by\s+(\d{4}-\d{2}-\d{2})\b/i,qe=/next\s+major|major\s+after/i,We=6;function _e(e,t){const n=e.replace(/^\s*(?:\/\*\*?|\*\/|\*|\/\/)\s?/gm,"");if(qe.test(n))return'it still says "next major": the delete day is the only promise';const i=Ue.exec(n);if(!i)return'no delete day ("delete by YYYY-MM-DD")';const o=Z(i[1]);if(!o)return`${i[1]} is not a day`;const s=Z(t);if(!s)throw new Error(`today must be YYYY-MM-DD, got ${t}`);if(o<s)return`its delete day ${i[1]} is past`;const r=function(e,t){const n=new Date(e.getFullYear(),e.getMonth()+t,1),i=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return new Date(n.getFullYear(),n.getMonth(),Math.min(e.getDate(),i))}(s,We);return o>r?`its delete day ${i[1]} is more than ${We} months out (last ${G(r)})`:void 0}var Ye=new Set(["say","t"]),He=e=>{const t=e.getText();return t.slice(t.lastIndexOf(".")+1)};function Ke(e){const t={};for(const[n,i]of Object.entries(e))i.length&&(t[n]=i.length);return t}var Ge=(e,t,n,i)=>function(e,t,n){const i=e.createSourceFile(t,n,e.ScriptTarget.Latest,!1),o=[];for(const t of i.statements)(e.isImportDeclaration(t)||e.isExportDeclaration(t))&&t.moduleSpecifier&&e.isStringLiteralLike(t.moduleSpecifier)&&o.push(t.moduleSpecifier.text);return o}(e,t,n).some(e=>i.some(t=>t.endsWith("/*")?e.startsWith(t.slice(0,-1)):e===t));var Ze=e=>new Map(e.allow.map(e=>[R(e.file,e.kind),e.count]));function Ve(e,t){return e.kinds.filter(e=>t.kinds.includes(e))}var Qe=(e,t,n)=>{if("kit-dep"===n)return` (${e.kitDeps.join(", ")})`;if("chart-dep"===n)return` (${e.chartDeps.join(", ")})`;const i=e.hits.get(t)?.[n]??[];if(0===i.length)return"";const o=i.slice(0,12).join(", ");return` (line${1===i.length?"":"s"} ${o}${i.length>12?", …":""})`};function Xe(e,t,n){const i=Ze(e),o=new Map;for(const[e,s]of t.counts){const{kind:t}=M(e);if(!c(t)||!n.includes(t))continue;const r=s-(i.get(e)??0);r>0&&o.set(e,r)}return{kinds:l.filter(e=>n.includes(e)),counts:o}}function et(e,t){let n=0;for(const i of new Set([...e.keys(),...t.keys()]))(e.get(i)??0)!==(t.get(i)??0)&&(n+=1);return n}var tt="\n// <button> in a comment is not a button, and <svg> in one is not a drawing\n/* nor is <input title=\"x\"> in this one, or dark:bg-black, or #fff */\nimport { createPortal } from 'react-dom';\nimport { Dialog } from '@headlessui/react';\nimport { TrashIcon } from '@heroicons/react/24/outline';\nimport type { Icon } from 'lucide-react';\nimport { Button, confirm } from 'efficient-shell';\nexport { Slot } from '@radix-ui/react-slot';\nexport { CheckIcon } from '@radix-ui/react-icons';\nimport { LineChart } from 'recharts';\nimport 'd3-scale';\nexport { VictoryPie } from 'victory';\nimport { BarChart } from '@mui/x-charts';\nimport Tree from 'react-d3-tree';\nimport { TimeSeriesChart } from 'efficient-shell/ui';\n// import 'chart.js' in a comment is not an import, and 'echarts' in a string is not one either\nconst chartLabel = 'd3-array';\n\nconst a = <button title=\"Says what it does\">x</button>;\nconst b = <input type=\"range\" />;\nconst c = <input type=\"text\" />;\nconst c2 = <input type={\"hidden\"} name=\"csrf\" />;\nconst c3 = <input type=\"hidden\" />;\nconst c4 = <input type={kind} />;\nconst d = <select />;\nconst d2 = <textarea />;\nconst e = <div role=\"dialog\" />;\nconst e2 = <dialog open />;\nconst e3 = <section role={'alertdialog'} />;\nconst f = <iframe title=\"Preview\" />;\nconst f2 = <object title=\"Chart\" />;\nconst g = <Button title=\"a prop, not a tooltip\" role=\"dialog\" />;\nconst g2 = (\n <button\n type=\"button\"\n title={hint}\n >\n y\n </button>\n);\nconst h = ReactDOM.createPortal(a, document.body);\nconst i = createPortal(a, document.body);\n\nasync function leave() {\n if (window.confirm('Sure?')) return;\n globalThis.alert('No');\n alert('native: nothing binds the name');\n prompt('native too');\n await confirm('the shell: the import binds it');\n record.confirm('a method, not the popup');\n}\n\nconst j = <div className=\"bg-white dark:bg-black dark:hover:text-white is-dark:no\" />;\nconst k = clsx('text-gray-900', on && 'dark:text-gray-100');\nconst l = <span style={{ color: '#fff', background: \"#12ab34\" }} className={`border-[#0a0b0c80] ${x}`} />;\nconst m = <a href=\"#faded\" id=\"#bad\" key=\"#abc\" to=\"#face\">skip</a>;\nconst n = <label htmlFor={'#dead'}>skip</label>;\nconst o = <span>&#1234; and BG#00340 and #12345 and #added are not colours</span>;\nconst p = 'entity &#x1f; ref BG#00340';\nconst q = <use xlinkHref=\"#abc\" fill=\"url(#fed)\" />;\nconst t = <div className=\"rounded-[4px] rounded-t-[0.5rem] hover:rounded-[2px] rounded-lg rounded-(--radius-card) rounded-[inherit] rounded-[var(--r)]\" />;\nconst u = <div style={{ borderRadius: 6, borderTopLeftRadius: '3px', borderBottomRightRadius: '50%', borderEndEndRadius: 'var(--radius-card)' }} />;\nconst v = <i style={{ borderRadius: 9999 }} />;\nconst w = <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 4h16\" /></svg>;\nconst w2 = <Svg viewBox=\"0 0 24 24\" />;\nconst w3 = '<svg viewBox=\"0 0 1 1\"></svg> in a string is not an element';\nconst r = lazy(() => import('@mui/material'));\nconst s = require('react-select');\nconst s2 = require('chart.js/auto');\nconst s3 = import('@nivo/line');\n",nt={button:2,input:2,range:1,textarea:1,select:1,dialog:3,title:2,portal:2,native:4,dark:3,hex:3,radius:5,kit:5,icon:3,svg:1,chart:5,colour:8},it={kit:1,dark:1,portal:1,radius:2,chart:1,colour:2},ot=(...e)=>e.join("-"),st=`\nconst s1 = <i className="${[ot("px","2.5"),ot("py","1.5"),"md:"+ot("gap","1.5"),"-"+ot("mt","1.5"),ot("p","[10px]")].join(" ")}" />;\nconst s2 = <i className="${[ot("p","0"),ot("px","px"),ot("p","0.5"),ot("p","3"),ot("gap-x","4"),ot("p","12"),ot("p","(--space-12)"),ot("p","[var(--space-12)]"),ot("space-x","reverse"),ot("top","1.5")].join(" ")}" />;\nconst s3 = <i style={{ padding: 6, marginTop: '10px', gap: 8, margin: '0 auto', paddingInline: 'var(--space-12)' }} />;\nconst f1 = <i className="${[ot("text","[11px]"),ot("text","[0.8rem]"),ot("text","xs"),ot("text","[#fff]"),ot("text","(--text-2xs)")].join(" ")}" />;\nconst f2 = <i style={{ fontSize: 12 }} />;\nconst f3 = { fontSize: 'var(--x)', font: 'inherit' };\nconst z1 = <i className="${[ot("z","[9999]"),ot("z","50"),ot("z","10"),ot("z","30"),"-"+ot("z","10"),ot("z","auto"),ot("z","(--z-popup)"),ot("z","[var(--z-popup)]")].join(" ")}" />;\nconst z2 = { zIndex: on ? 2020 : 2010 };\nconst z3 = { zIndex: Z_LAYERS.popup, top: 9999 };\nconst h1 = <i className="${[ot("shadow","[0_1px_2px_#000]"),ot("shadow","md"),"shadow",ot("shadow","lg"),ot("shadow","(--elevation-panel)"),ot("shadow","black/20"),ot("drop-shadow","md")].join(" ")}" />;\nconst h2 = { boxShadow: '0 1px 2px rgba(0,0,0,.1)' };\nconst h3 = { boxShadow: 'none', outline: 'var(--elevation-raised)' };\n`,rt={spacing:7,"font-size":3,"z-index":4,shadow:3,hex:1,colour:4},at={colour:4},lt={"ellipsis-label":9},ct=`\n// "root:default-zone" and \`/wheels/\${slug}\` in a comment are not copies\nimport { escapeHtml } from 'efficient-shell/format';\nconst c1 = "${ot("pl","[var(--sf-site-gutter,40px)]")}";\nconst c2 = "var(--sf-site-gutter)";\nconst c3 = <i className="${ot("max","[960px]")}:hidden" />;\nconst c4 = "1960px";\nconst c5 = \`/wheels/\${slug}\`;\nconst c6 = "/tyres/" + slug;\nconst c7 = wheelPath(slug);\nconst c8 = { zone: "root:default-zone" };\nconst c9 = "(max-width: 767px)";\nconst c10 = <img sizes="(max-width: 800px) 100vw, 50vw" />;\nconst c11 = <img sizes={CONTENT_SIZES} />;\nconst c12 = Math.round(price * 100) / 100;\nconst c13 = ratio * 100;\nfunction escapeHtml(s: string) { return s; }\nconst c14 = timeAgo(when);\n/** @deprecated Remove at the next major. */\nconst c15 = 1;\nconst c16 = "@deprecated in a string";\n`,dt={"gutter-literal":1,"view-line-literal":1,"route-literal":2,"root-zone-literal":1,"phone-query":1,"sizes-literal":1,"money-cents":1,"local-helper":1,"deprecated-undated":1},ut=e=>l.filter(t=>e[t]).map(t=>`${t} ${e[t]}`).join(", ")||"nothing";var ht="ui-kit.config.json",ft="ui-kit.baseline.json",pt="efficient-shell-ui-check",mt=`${pt}: every surface a person operates takes its UI from efficient-shell (harness UI-24).\n\n ${pt} check this repository against ${ft}\n ${pt} --print print today's counts as a baseline, and change nothing\n ${pt} --summary print totals per kind and per folder, as Markdown\n ${pt} --json print the result as JSON\n ${pt} --update lower the lines whose counts fell, and delete the ones at zero\n ${pt} --update --allow-move also follow a renamed or split file (no total may rise)\n ${pt} --init write the first ${ft}\n ${pt} --init --kind <kind> take the baseline for a kind just added to "kinds"\n ${pt} --no-base do not compare with the base branch (refused on a pull request)\n\nKinds: ${l.join(", ")}\nReads ${ht} in the current directory.`;var gt=(e,t)=>`${e} ${t}${1===e?"":"s"}`,wt=(e,t)=>{const n=N(e);return t.map(e=>`${e} ${n[e]??0}`).join(" · ")};function xt(e,t,i,o,s){const a=e.env.GITHUB_BASE_REF;if(!a)return{problems:[],note:""};const l=e.git(["rev-parse","--show-prefix"]);if(null===l)return{problems:[],note:"not a git checkout; the base branch was not compared"};const d=`origin/${a}`;if(null===e.git(["rev-parse","--verify","--quiet",`${d}^{commit}`])&&(e.git(["fetch","--no-tags","--depth=1","origin",`+refs/heads/${a}:refs/remotes/origin/${a}`]),null===e.git(["rev-parse","--verify","--quiet",`${d}^{commit}`])))return{problems:[],note:`${d} could not be fetched; the base branch was not compared`};const u=e.git(["show",`${d}:${l.trim()}${ft}`]);if(null===u)return{problems:[],note:`${d} has no ${ft} yet (adoption)`};let h;try{h=P(u,`${d}:${ft}`)}catch{return{problems:[],note:`${d}'s ${ft} could not be read; the base branch was not compared`}}const f=t=>e.git(["show",`${d}:${l.trim()}${t}`]);let g=null;try{const e=f(ht);null!==e&&(g=q(JSON.parse(e),`${d}:${ht}`))}catch{g=null}const w=[],x=new Set(o.kinds.filter(e=>i.kinds.includes(e)));for(const e of h.kinds)x.has(e)||w.push(`"${e}" is checked on ${d}, and not here ("kinds" in ${ht}, or ${ft}). Its lines would never be counted again: keep the kind.`);const k=t=>{const i=t.split("/");for(let t=1;t<=i.length;t++)try{if(r(n(e.cwd,...i.slice(0,t))).isSymbolicLink())return!0}catch{return!1}return!1},b=new Set(s.copyOnly),y=new Set(s.files.filter(e=>!b.has(e))),$=new Set([...h.counts.keys()].map(e=>M(e)).filter(({file:e,kind:t})=>e!==W&&!((e,t)=>y.has(e)||b.has(e)&&c(t)&&p(t))(e,t)).map(({file:e})=>e));for(const e of $)k(e)&&w.push(`${e} is under a symbolic link now (the file or a folder above it), and ${d} counted it. The walk does not follow it for every kind counted there, so those lines would never be counted again: keep the real file here.`);if(g){const n=E(g.exclude),i=g.kinds.includes("colour"),r=e=>(Pe(e)||i&&Oe(e))&&!n(e),a=t=>A(e.cwd,[t]).some(r),l="keep the line; delete it only when the files it matches are gone.",c=(e,t,n)=>t.filter(e=>!n.includes(e)&&a(e)).map(t=>`"${e}" drops "${t}", which ${d} reads. Those files would never be counted again: ${l}`),u=(e,t,n)=>n.filter(e=>!t.includes(e)&&a(e)).map(t=>`"${e}" adds "${t}", which takes files ${d} reads out of the check. Those files would never be counted again.`),h=e=>e.flatMap(e=>e.files.flatMap(t=>e.modules.map(e=>({glob:t,module:e})))),p=new Set(h(o.includeImporting).map(({glob:e,module:t})=>`${e}\n${t}`));w.push(...c("include",g.include,o.include),...h(g.includeImporting).filter(({glob:e,module:t})=>!p.has(`${e}\n${t}`)&&a(e)).map(({glob:e,module:t})=>`"includeImporting" drops "${e}" (${t}), which ${d} reads. Those files would never be counted again: ${l}`),...c("includeCopies",g.includeCopies,o.includeCopies),...u("exclude",g.exclude,o.exclude),...u("output",g.output.flatMap(e=>e.files),o.output.flatMap(e=>e.files)));const m=new Set(s.copyOnly),x=new Set(s.files.filter(e=>!m.has(e))),k=E(g.include),b=E(g.output.flatMap(e=>e.files)),y=new Set;for(const i of g.includeImporting)for(const o of A(e.cwd,i.files)){if(!Pe(o)||n(o)||b(o)||k(o))continue;if(x.has(o)||y.has(o))continue;const e=f(o);null!==e&&Ge(t,o,e,i.modules)&&(y.add(o),w.push(`${o} no longer imports ${i.modules.join(", ")}, so "includeImporting" stops reading it, and ${d} reads it. Keep the import, or read the file with "include".`))}}const v=o.kinds.filter(p),S=[],z={};if(g&&v.length){const e=E(g.exclude),n=E(g.include),i=E(g.output.flatMap(e=>e.files)),r=E(g.includeImporting.flatMap(e=>e.files)),a=E(g.includeCopies),l=t=>!e(t)&&(n(t)&&!i(t)||r(t)||a(t)),c=new Map(o.allow.map(e=>[`${e.file}:${e.kind}`,e.count]));for(const e of s.copyOnly){if(l(e))continue;S.push(e);const n=f(e);if(null===n)continue;const i=Je(t,e,n,v);for(const t of v){const n=(i[t]?.length??0)-(c.get(`${e}:${t}`)??0);n>0&&(z[t]=(z[t]??0)+n)}}}const I=N(h.counts),j=N(i.counts);w.push(...o.kinds.filter(e=>h.kinds.includes(e)&&(j[e]??0)>(I[e]??0)+(z[e]??0)).map(e=>`${ft} holds ${j[e]??0} of "${e}", and ${d} holds ${I[e]??0}${S.length&&p(e)?` (and ${z[e]??0} in the files new to "includeCopies")`:""}. The baseline only goes down: use ${m[e].instead}. A count that is meant to stay goes in "allow" in ${ht}, with its reason.`));const C=[`compared with ${d}`];return null===g&&C.push(`${d}'s ${ht} could not be read, so every line was compared and no scope was checked for shrinking`),S.length&&C.push(`"includeCopies" changed: ${S.length} file${1===S.length?"":"s"} new to "includeCopies", so ${1===S.length?"its":"their"} ${v.join(", ")} lines may hold what ${1===S.length?"it":"they"} held on ${d}`),{problems:w,note:C.join("; ")}}process.exitCode=function(e,t){const r=function(e){const t={print:!1,summary:!1,json:!1,update:!1,allowMove:!1,init:!1,noBase:!1,help:!1,version:!1,kinds:[]};for(let n=0;n<e.length;n++){const i=e[n];if("--print"===i)t.print=!0;else if("--summary"===i)t.summary=!0;else if("--json"===i)t.json=!0;else if("--update"===i)t.update=!0;else if("--allow-move"===i)t.allowMove=!0;else if("--init"===i)t.init=!0;else if("--no-base"===i)t.noBase=!0;else if("--help"===i||"-h"===i)t.help=!0;else if("--version"===i||"-v"===i)t.version=!0;else if("--kind"===i){const i=e[++n];if(!i)return"--kind needs a kind after it";t.kinds.push(...i.split(","))}else{if(!i.startsWith("--kind="))return`unknown argument "${i}"`;t.kinds.push(...i.slice(7).split(","))}}return t.allowMove&&!t.update?"--allow-move goes with --update":t.kinds.length&&!t.init?"--kind goes with --init":[t.print,t.summary,t.update,t.init].filter(Boolean).length>1?"choose one of --print, --summary, --update and --init":t}(e);if("string"==typeof r)return t.err(`${pt}: ${r}\n\n${mt}`),2;if(r.help)return t.out(mt),0;if(r.version)return t.out(t.version),0;const a=e=>(r.json?t.out(JSON.stringify({tool:pt,version:t.version,ok:!1,failures:[e]},null,2)):t.err(`${pt}: ${e}`),1);if(r.noBase&&t.env.GITHUB_BASE_REF)return a("--no-base is refused on a pull request (GITHUB_BASE_REF is set): the base-branch comparison is what stops a pull request lowering its own baseline.");const l=n(t.cwd,ht);if(!i(l))return a(`no ${ht} in ${t.cwd}. Run it from the repository root; the harness has the template.`);let d,f;try{d=q(JSON.parse(o(l,"utf8")),ht)}catch(e){return a(e instanceof F?e.message:`${ht} is not valid JSON: ${e.message}`)}try{f=t.loadTypeScript()}catch{return a('this check reads the TypeScript AST and found no "typescript" package here. Install it as a devDependency.')}const g=function(e){const t=[],n=h,i=[["fixture.tsx",tt,nt],["fixture.ts","\nimport { toast } from 'sonner';\nimport { extent } from 'd3-array';\nexport const tone = { warn: '#f59e0b' };\nexport const cls = 'ring-1 dark:ring-white rounded-[3px]';\nexport const box = { borderRadius: '0.25rem', radius: 4 };\nexport function ask(confirm: (message: string) => boolean) {\n return confirm('a parameter binds the name');\n}\nexport const mount = (node: unknown) => ReactDOM.createPortal(node, document.body);\n",it],["tokens.tsx",st,rt],["labels.tsx","\n// <Button>Save…</Button> in a comment is not a label\nconst l1 = <Button>Extend trial…</Button>;\nconst l2 = <PopupMenuItem onClick={go}><span>Read from a PDF...</span></PopupMenuItem>;\nconst l3 = <Button>{busy ? 'Saving…' : 'Duplicate site…'}</Button>;\nconst l4 = <Item label=\"Translate…\" aria-label={'More…'} />;\nconst l5 = [{ label: 'Reject…' }, { value: CUSTOM, label: 'Custom…' }];\nconst l6 = <option value={CUSTOM}>Different address…</option>;\nconst l7 = <PopupMenuLabel>{say(\"Duplicate to page…\")}</PopupMenuLabel>;\nconst n7 = <Button>{t('team:menu.remove')}</Button>;\nconst n1 = <Button>{`${name.slice(0, 9)}…`}</Button>;\nconst n2 = <p>Loading weather…</p>;\nconst n3 = <Input placeholder=\"Search…\" />;\nconst n4 = <option value=\"\">Pick a carrier…</option>;\nconst n5 = [{ value: '', label: 'Select…' }];\nconst n6 = <Button>Extend trial</Button>;\n",lt],["copies.tsx",ct,dt]];for(const[o,s,r]of i){const i=Ke(Je(e,o,s,n));n.some(e=>(i[e]??0)!==(r[e]??0))&&t.push(`${o}: read ${ut(i)}; it holds ${ut(r)}`)}const o=Ke(Fe('\n/* #fff in a comment */\n.a:hover { color: #111; border: 1px solid white; }\n[data-x="#fff"] { mask-image: linear-gradient(#000, transparent); color: var(--ink); }\n.b { --mine: rgb(0 0 0 / .5); background: var(--surface, #fff); }\n',n));n.some(e=>(o[e]??0)!==(at[e]??0))&&t.push(`style.css: read ${ut(o)}; it holds ${ut(at)}`);const s=Ke(Je(e,"fixture.tsx",tt,["button"]));return"button"!==Object.keys(s).join()&&t.push(`asked for button alone, the reader reported ${ut(s)}`),t}(f);if(g.length)return a(`the reader misread its own fixtures with typescript ${f.version}, so nothing it says about this repository can be trusted:\n - `+g.join("\n - "));const w=function(e,t,s){const r=[],a=E(s.exclude),l=E(s.output.flatMap(e=>e.files)),c=new Map,d=e=>{let i=c.get(e);return void 0===i&&c.set(e,i=o(n(t,e),"utf8")),i},h=(e,n)=>{for(const i of e)0===A(t,[i]).length&&r.push(`${n}: "${i}" matches no file. Delete the line, or fix the path.`)};h(s.include,'"include"'),s.output.forEach((e,t)=>h(e.files,`"output"[${t}]`)),s.includeImporting.forEach((e,t)=>h(e.files,`"includeImporting"[${t}]`)),h(s.includeCopies,'"includeCopies"');const f=new Set,m=s.kinds.includes("colour"),g=e=>(Pe(e)||m&&Oe(e))&&!a(e)&&!l(e);for(const e of A(t,s.include))g(e)&&f.add(e);for(const n of s.includeImporting)for(const i of A(t,n.files))g(i)&&Pe(i)&&!f.has(i)&&Ge(e,i,d(i),n.modules)&&f.add(i);const w=s.kinds.filter(p),x=new Set;if(w.length)for(const e of A(t,s.includeCopies))!Pe(e)||a(e)||f.has(e)||x.add(e);const k=[...f,...x].sort(),y=s.kinds.filter(e=>!u(e)),$=new Map,S=new Map,z=new Set;for(const t of k){const n=x.has(t),i=n?w:y,o=Oe(t)?Fe(d(t),i):Je(e,t,d(t),i,n?void 0:z);let s=!1;for(const e of i){const n=o[e]?.length??0;n&&(S.set(R(t,e),n),s=!0)}s&&$.set(t,o)}let I=[],j=[],C=[];const L=s.kinds.filter(u);if(L.length){const e=n(t,W);if(i(e)){const t=JSON.parse(o(e,"utf8")),n=["dependencies","peerDependencies","optionalDependencies"].flatMap(e=>Object.keys(t[e]??{})),i=new Set([...z].flatMap(e=>b[e]??[])),r=[...new Set(n)].sort();if(s.kinds.includes("kit-dep")){const e=r.filter(e=>"kit-dep"===v(e));I=e.filter(e=>!i.has(e)),j=e.filter(e=>i.has(e)),I.length&&S.set(R(W,"kit-dep"),I.length)}s.kinds.includes("chart-dep")&&(C=r.filter(e=>"chart-dep"===v(e)),C.length&&S.set(R(W,"chart-dep"),C.length))}else for(const e of L)r.push(`"kinds" includes "${e}", and there is no ${W} here to read.`)}for(const e of s.allow)(u(e.kind)?e.file===W:f.has(e.file)||p(e.kind)&&x.has(e.file))||r.push(`"allow": ${e.file} (${e.kind}) is not a file this check reads. Delete the entry, or fix the path.`);return{files:k,copyOnly:[...x].sort(),hits:$,counts:S,kitDeps:I,shellPeers:j,chartDeps:C,problems:r}}(f,t.cwd,d);if(0===w.files.length)return a(`read no files. "include" in ${ht} matches nothing, so a pass would mean nothing.`);const x=n(t.cwd,ft),k=r.json,y=e=>{k||t.out(e)};if(r.print)return t.out(O(Xe(d,w,d.kinds)).trimEnd()),0;if(r.summary){for(const e of function(e,t){const n=new Map,i=new Map;for(const[e,o]of t.counts){const{file:t,kind:s}=M(e);if(!c(s))continue;const r=n.get(s)??{count:0,files:new Set};r.count+=o,r.files.add(t),n.set(s,r);const a=t.split("/"),l=a.length>2?a.slice(0,2).join("/"):2===a.length?a[0]:".",d=i.get(l)??{};d[s]=(d[s]??0)+o,i.set(l,d)}const o=e.kinds.filter(e=>n.has(e)),s=[`**UI kit check (harness UI-24):** ${new Set([...t.counts.keys()].map(e=>M(e).file)).size} of ${gt(t.files.length,"file")} still draw UI of their own.`,"","| Kind | Count | Files | The shell has |","|---|---:|---:|---|",...e.kinds.map(e=>{const t=n.get(e);return`| \`${e}\` | ${t?.count??0} | ${t?.files.size??0} | ${m[e].instead} |`})];if(o.length&&i.size){const e=e=>o.reduce((t,n)=>t+(e[n]??0),0),t=[...i].sort((t,n)=>e(n[1])-e(t[1])||(t[0]<n[0]?-1:1));s.push("",`| Folder | ${o.map(e=>`\`${e}\``).join(" | ")} | Total |`,`|---|${o.map(()=>"---:").join("|")}|---:|`,...t.map(([t,n])=>`| \`${t}\` | ${o.map(e=>n[e]??0).join(" | ")} | ${e(n)} |`))}return s}(d,w))t.out(e);return 0}let $=null;if(i(x))try{$=P(o(x,"utf8"),ft)}catch(e){return a(e instanceof T?e.message:String(e))}if(r.init){const e=r.kinds.filter(e=>!c(e)||!d.kinds.includes(e));if(e.length)return a(`--kind ${e.join(", ")}: not in "kinds" in ${ht}. Add it there first.`);const t=r.kinds;if($){if(0===t.length)return a(`${ft} already exists, and --init would overwrite what it holds. It is for the adoption pull request only. To start checking a kind, add it to "kinds" and run --init --kind <kind>.`);const e=t.filter(e=>$.kinds.includes(e));if(e.length)return a(`the baseline was already taken for ${e.join(", ")}. Its lines only go down; use --update.`);const n=Xe(d,w,t);$={kinds:[...$.kinds,...t],counts:new Map([...$.counts,...n.counts])}}else{if(t.length)return a(`there is no ${ft} yet. Run --init on its own first.`);$=Xe(d,w,d.kinds)}s(x,O($)),y(`${pt}: wrote ${ft} (${gt($.counts.size,"line")}: ${wt($.counts,$.kinds)})`)}if(!$)return a(`no ${ft}. This repository has not adopted the check yet: run ${pt} --init, and commit the file.`);if(r.update){const e=function(e,t,n,{allowMove:i=!1}={}){const o=Ve(e,t),s=Xe(e,n,o),r=new Map([...t.counts].filter(([e])=>o.includes(M(e).kind)));if(i){const e=N(r),n=N(s.counts),i=o.filter(t=>(n[t]??0)>(e[t]??0)).map(t=>`${t}: ${n[t]??0} across the repository, and the baseline holds ${e[t]??0}`);return i.length?{baseline:t,lowered:0,refused:i}:{baseline:s,lowered:et(r,s.counts),refused:[]}}const a=new Map;for(const[e,t]of r){const n=Math.min(t,s.counts.get(e)??0);n>0&&a.set(e,n)}return{baseline:{kinds:o,counts:a},lowered:et(r,a),refused:[]}}(d,$,w,{allowMove:r.allowMove});if(e.refused.length)return a(`--allow-move follows code that moved, and this is more of it than before:\n - ${e.refused.join("\n - ")}\nNothing was written.`);$=e.baseline,s(x,O($)),y(`${pt}: ${e.lowered?`changed ${gt(e.lowered,"line")} in`:"nothing to change in"} ${ft}`)}const S=function(e,t,n){const i=[],o=[],s=[...n.problems],r=Ze(e),a=new Set(Ve(e,t)),l=e.kinds.filter(e=>!t.kinds.includes(e));l.length&&s.push(`"kinds" names ${l.map(e=>`"${e}"`).join(", ")}, and the baseline was never taken for ${1===l.length?"it":"them"}. Run: efficient-shell-ui-check --init ${l.map(e=>`--kind ${e}`).join(" ")}`);const d=t.kinds.filter(t=>!e.kinds.includes(t));d.length&&o.push(`the baseline still carries ${d.map(e=>`"${e}"`).join(", ")}, which "kinds" no longer names`);const u=new Set([...n.counts.keys(),...t.counts.keys(),...r.keys()]);for(const e of[...u].sort(B)){const{file:l,kind:d}=M(e);if(!c(d)||!a.has(d))continue;const u=n.counts.get(e)??0,h=r.get(e)??0,f=t.counts.get(e)??0;u>h+f?i.push(`${l}: ${d} ${u}, and its line allows ${h+f}${Qe(n,l,d)}. ${m[d].counts} is counted; use ${m[d].instead}.`):u<h?s.push(`${l}: ${d} ${u}, and "allow" in ui-kit.config.json says ${h}. ${0===u?"Delete the entry":`Lower its count to ${u}`}: an exception does not outlive what it excused.`):u<h+f&&o.push(`${l}: ${d} ${u}, and its line says ${h+f}`)}return{grown:i,shrunk:o,other:s,updateFixes:0===i.length&&0===s.length&&o.length>0}}(d,$,w),z=r.noBase?{problems:[],note:""}:xt(t,f,$,d,w),I=d.kinds.filter(e=>$.kinds.includes(e)),j=`${pt} --update`,C=[...S.other,...S.grown,...S.shrunk.map(e=>`${e}. Run: ${j}`),...z.problems],L=0===C.length;if(r.json){const e=new Map(d.allow.map(e=>[`${e.file}:${e.kind}`,e.count]));return t.out(JSON.stringify({tool:pt,version:t.version,ok:L,schema:d.schema,kinds:d.kinds,files:w.files.length,counts:N(w.counts),baseline:N($.counts),allowed:N(e),kitDeps:w.kitDeps,shellPeers:w.shellPeers,chartDeps:w.chartDeps,failures:C},null,2)),L?0:1}t.out(`UI kit check (harness UI-24), efficient-shell ${t.version}\n`);const D=(e,n,i="")=>{if(0===n.length)return t.out(` ok ${e}`);t.err(` FAIL ${e}`);for(const e of n)t.err(` ${e}`);i&&t.err(` ${i}`)};t.out(` ok the reader reads its own fixtures (typescript ${f.version})`),t.out(` ok read ${gt(w.files.length,"file")}`),D(`${ht} and ${ft} describe this repository`,S.other),D("no file draws more of its own UI than its line allows",S.grown),D("every line is exact: a count that fell is a line to lower",S.shrunk,`Run: ${j}${S.updateFixes?"":" (after the failures above are fixed)"}`),z.note&&D(`the baseline is no higher than the base branch (${z.note})`,z.problems);const J=new Set([...w.counts.keys()].map(e=>M(e).file));return t.out(` ok PROGRESS: ${J.size} of ${gt(w.files.length,"file")} still draw UI of their own: `+wt(w.counts,I)),t.out(""),L?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${gt(C.length,"problem")})`),L?0:1}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>function(e){for(const i of[n(process.cwd(),"package.json"),e])try{return t(i)("typescript")}catch{}throw new Error("typescript is not installed")}(import.meta.url),git:function(t){try{return e("git",t,{cwd:process.cwd(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:6e4,maxBuffer:67108864})}catch{return null}},version:"12.40.1"});
2
+ import{execFileSync as e}from"child_process";import{createRequire as t}from"module";import{join as n}from"path";import{existsSync as i,readFileSync as o,writeFileSync as s,lstatSync as r,readdirSync as a}from"fs";var l=["button","input","range","textarea","select","dialog","title","portal","native","dark","hex","radius","spacing","font-size","z-index","shadow","kit","icon","svg","kit-dep","chart","chart-dep","ellipsis-label","colour","gutter-literal","view-line-literal","route-literal","root-zone-literal","phone-query","sizes-literal","money-cents","local-helper","deprecated-undated"],c=e=>"string"==typeof e&&l.includes(e),d=["kit-dep","chart-dep"],u=e=>d.includes(e),h=l.filter(e=>!u(e)),f=["gutter-literal","view-line-literal","route-literal","root-zone-literal","phone-query","sizes-literal","money-cents","local-helper","deprecated-undated"],p=e=>f.includes(e),m={button:{counts:"a raw <button>",instead:"Button or IconButton from efficient-shell/ui"},input:{counts:"a raw <input> (not hidden, not a range)",instead:"Input, InputNumber, Checkbox, Radio or Switch from efficient-shell/ui"},range:{counts:'a raw <input type="range">',instead:"Slider from efficient-shell/ui"},textarea:{counts:"a raw <textarea>",instead:"Textarea from efficient-shell/ui"},select:{counts:"a raw <select>",instead:"Select or SearchableSelect from efficient-shell/ui"},dialog:{counts:'a raw <dialog>, or role="dialog" / role="alertdialog" on a raw element',instead:"Dialog or Modal from efficient-shell"},title:{counts:"a title= on a raw element (the browser's own tooltip)",instead:"Tooltip from efficient-shell/ui (harness UI-17)"},portal:{counts:"a createPortal(…) call (a layer the file floats itself)",instead:"Popover, PopupMenu, DropdownMenu, Tooltip or Dialog from efficient-shell/ui"},native:{counts:"window.confirm / alert / prompt, or a bare call that resolves to one",instead:"confirm, confirmDestructive, prompt or toast from efficient-shell (harness UI-20)"},dark:{counts:"a dark: variant in a class string",instead:"the light Tailwind class alone; the shell remaps it in dark mode (harness UI-7)"},hex:{counts:"a hex colour literal in a .tsx string",instead:"a colour role from efficient-shell: its utility or var(--role), COLOUR_ROLES lists them (harness FT-1; the colour kind counts palette classes too)"},radius:{counts:"a literal corner radius (an arbitrary-value radius class, or an inline borderRadius)",instead:"a radius utility from the scale or a role token such as rounded-(--radius-control); the theme sets how round they are (harness UI-7)"},spacing:{counts:"a padding, margin or gap off the scale (6px, 10px, 14px …) or written as a literal length (an arbitrary-value class, an inline style)",instead:"a step of the scale 2/4/8/12/16/20/24/32/40/48 — a Tailwind step, or a role such as var(--space-control-x) (owner ruling 2026-10-12)"},"font-size":{counts:"a literal font size (an arbitrary-value text class, an inline fontSize)",instead:"a type step 9/11/12/14/16/18/20/24/30 — Tailwind's 3xs … 3xl text steps (owner ruling 2026-10-12)"},"z-index":{counts:"a stack order above 30 written as a number (a z utility, an arbitrary value, an inline zIndex)",instead:"a named layer: Z_LAYERS (efficient-shell/ui) in code, its --z-* custom property in markup"},shadow:{counts:"a literal shadow, or a shadow size that is not an elevation level (md, 2xl, xs)",instead:"an elevation: the sm / lg / xl utilities, or var(--elevation-panel) and its siblings (owner ruling 2026-10-12)"},kit:{counts:"an import of a second UI kit",instead:"the component from efficient-shell/ui, or fold it into the shell (harness FT-3)"},icon:{counts:"an import of an icon package",instead:"<Icon name> from efficient-shell/icons, drawn by the one set (harness UI-24)"},svg:{counts:"an <svg> element written in JSX: an icon drawn in place",instead:"<Icon name> from efficient-shell/icons, drawn by the one set (harness UI-24). A chart, an illustration or a mark a host supplies stays on the baseline"},"kit-dep":{counts:"a UI kit or icon package declared in package.json (not one the shell entries imported here need)",instead:"remove the dependency once nothing imports it (harness FT-3)"},chart:{counts:"an import of a second chart library",instead:"a chart from efficient-shell/ui (ChartFrame, TimeSeriesChart, ColumnChart, RankedBars, PieChart, FunnelChart, ScatterChart, …), or add the chart there: one chart system (harness FT-3)"},"chart-dep":{counts:"a chart library declared in package.json",instead:"remove the dependency once nothing imports it (harness FT-3)"},"ellipsis-label":{counts:'a button, link or menu label that ends in "…" or "..."',instead:'the label without the dots, saying what it does ("Extend trial"): "…" means only "the words are cut" (owner ruling 2026-10-14)'},colour:{counts:"a literal colour, in a script string or a stylesheet: a hex, an rgb() / hsl() / oklch() value, a Tailwind palette class (a hue and a step, or white / black), a --color-<hue>-<step> variable, or a named colour in a colour property — a var() fallback included",instead:"a colour role from efficient-shell: its utility (the text, background or border utility of ink, ink-faint, surface, line, accent-fill, accent-text, danger-text, status-danger-line …) or var(--role); COLOUR_ROLES lists them. A merchant site reads the site theme (owner ruling 2026-10-23)"},"gutter-literal":{counts:"the site gutter typed with its own fallback, var(--sf-site-gutter, 40px), in script source (stylesheets are not read)",instead:"SITE_GUTTER_CLASS from efficient-web-builder (lib/content/page-width): the whole class, because Tailwind reads only whole literals; SITE_GUTTER_CAP for the number"},"view-line-literal":{counts:"the 960px written as a length in script source (a max-/min- variant, a media query; a sizes string counts here too)",instead:"the view-lines table in efficient-web-builder (lib/content/view-lines, lib/content/box-stack-line)"},"route-literal":{counts:"a page path typed by hand before a slug: /wheels/, /journal/, /tyres/",instead:"pagePath, postPath or wheelPath from efficient-web-builder (lib/links/page-link-rules), tyrePagePath from efficient-storefront-blocks (render/lib/tyres/tyre-page-path)"},"root-zone-literal":{counts:'the easel root zone key typed as a string ("root:default-zone")',instead:"ROOT_ZONE from efficient-easel (screen/lib/document/content-tree)"},"phone-query":{counts:"the app phone line typed as a media query in script source: (max-width: 767px)",instead:"useIsMobile from efficient-shell: ask the hook, do not write the query"},"sizes-literal":{counts:"a hand-written responsive sizes string (a sizes attribute or sizes: entry with a media condition)",instead:"a named sizes shape from efficient-web-builder (lib/sized-image), built from the view lines"},"money-cents":{counts:"a money amount (amount, price, total, cents, fee, cost, balance) multiplied or divided by 100 by hand",instead:"createMoneyFormatter / useCurrency from efficient-storefront-blocks (render/components/CurrencyContext) for a shopper; formatMoney / currencyDecimals from efficient-shell for the ERP"},"local-helper":{counts:"a local definition (function or const) of a helper a package exports, by name: escapeHtml, deepEqual, timeAgo, formatBytes, hexToRgb and the rest of LOCAL_HELPERS",instead:"import the helper from its home (LOCAL_HELPERS in efficient-shell src/ui-check/kinds.ts names each one)"},"deprecated-undated":{counts:'a @deprecated note (a block comment, or a run of whole-line comments) that does not say "delete by YYYY-MM-DD" with a real day from today to 6 months out, or that still says "next major"',instead:'write the day the thing goes ("Delete by 2026-12-15, after <the move>") and a backlog line that owns the move; on that day delete it, or set a new day with the reason'}},g={escapeHtml:"efficient-shell (utils/escapeHtml)",deepEqual:"efficient-easel (data)",draftsEqual:"efficient-easel deepEqual (data)",timeAgo:"efficient-shell (format)",formatBytes:"efficient-shell (format)",formatFileSize:"efficient-shell formatBytes (format)",fileSize:"efficient-shell formatBytes (format)",humanSize:"efficient-shell formatBytes (format)",hexToRgb:"efficient-shell (forms/color)",parseHex:"efficient-shell parseHexColor (forms/color)",parseHexColor:"efficient-shell (forms/color)",hexOf:"efficient-shell parseHexColor (forms/color)",withAlpha:"efficient-shell hexWithAlpha (forms/colorMix)",isDarkInk:"efficient-shell readableInk (forms/color)",relativeLuminance:"efficient-shell (forms/color)",contrastRatio:"efficient-shell (forms/color)"},w=["@headlessui/","@radix-ui/","@mui/","@chakra-ui/","@mantine/","@floating-ui/","antd","react-aria","react-aria-","react-bootstrap","react-select","react-colorful","react-tooltip","react-hot-toast","react-toastify","sonner","efficient-shell-checker"],k=["@heroicons/","@tabler/icons","@tabler/icons-","@phosphor-icons/","@fortawesome/","@iconify/","@radix-ui/react-icons","@mui/icons-material","lucide","lucide-react","simple-icons","react-icons","react-feather"],$=["recharts","chart.js","react-chartjs-2","d3","d3-","@nivo/","victory","victory-","echarts","echarts-for-react","apexcharts","react-apexcharts","@visx/","highcharts","highcharts-react-official","plotly.js","plotly.js-dist","react-plotly.js","lightweight-charts","@antv/g2","@antv/g2plot","chartist","billboard.js","c3","uplot"],b={"efficient-shell":["@headlessui/react"]};function x(e,t){return t.some(t=>t.endsWith("/")||t.endsWith("-")?e.startsWith(t):e===t||e.startsWith(`${t}/`))}function y(e){return x(e,k)?"icon":x(e,w)?"kit":x(e,$)?"chart":null}function v(e){const t=y(e);return"kit"===t||"icon"===t?"kit-dep":"chart"===t?"chart-dep":null}var S=/[.+^$()|[\]\\]/g;function E(e){let t="",n=0;for(let i=0;i<e.length;i++){const o=e[i];"*"===o?"*"===e[i+1]?"/"===e[i+2]?(t+="(?:[^/]+/)*",i+=2):(t+=".*",i+=1):t+="[^/]*":"?"===o?t+="[^/]":"{"===o?(t+="(?:",n+=1):"}"===o&&n>0?(t+=")",n-=1):t+=","===o&&n>0?"|":o.replace(S,"\\$&")}if(0!==n)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${t}$`)}function z(e){const t=e.map(E);return e=>t.some(t=>t.test(e))}var I=new Set(["node_modules",".git"]),j=new Set(["dist","coverage",".next",".turbo"]);function C(e){const t=e.search(/[*?{]/),n=-1===t?e:e.slice(0,t),i=n.lastIndexOf("/");return-1===i?"":n.slice(0,i)}function T(e,t){const i=z(t),o=[...new Set(t.map(C))].sort(),s=o.filter(e=>!o.some(t=>t!==e&&(""===t||e.startsWith(`${t}/`)))),r=new Set,l=t=>{let o;try{o=a(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?I.has(e.name)||""===t&&j.has(e.name)||l(n):e.isFile()&&i(n)&&r.add(n)}};for(const e of s)l(e);return[...r].sort(A)}var A=(e,t)=>e<t?-1:e>t?1:0,L=class extends Error{},R=(e,t)=>`${e}:${t}`;function M(e){const t=e.lastIndexOf(":");return{file:e.slice(0,t),kind:e.slice(t+1)}}var B=e=>l.indexOf(e);function D(e,t){const n=M(e),i=M(t);return A(n.file,i.file)||B(n.kind)-B(i.kind)}function O(e,t="ui-kit.baseline.json"){let n;try{n=JSON.parse(e)}catch(e){throw new L(`${t} is not valid JSON: ${e.message}`)}const i=e=>{throw new L(`${t}: ${e}. The tool writes this file; do not edit it by hand.`)};if("object"!=typeof n||null===n||Array.isArray(n))return i("must be a JSON object");const o=n;if(1!==o.schema)return i("number"==typeof o.schema&&o.schema>1?`"schema": ${o.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');if(!Array.isArray(o.kinds)||o.kinds.some(e=>"string"!=typeof e))return i('"kinds" must be a list');const s=o.kinds.filter(c);if("object"!=typeof o.counts||null===o.counts||Array.isArray(o.counts))return i('"counts" must be an object');const r=new Map;for(const[e,t]of Object.entries(o.counts)){const{file:n,kind:o}=M(e);if(!n||!o)return i(`"${e}" is not "<file>:<kind>"`);if("number"!=typeof t||!Number.isInteger(t)||t<1)return i(`"${e}" must be a whole number, 1 or more (a line that reaches 0 is deleted)`);c(o)&&r.set(e,t)}return{kinds:s,counts:r}}function P(e){const t=l.filter(t=>e.kinds.includes(t)),n=[...e.counts.keys()].filter(t=>(e.counts.get(t)??0)>0).sort(D).map(t=>` ${JSON.stringify(t)}: ${e.counts.get(t)}`);return["{",' "schema": 1,',` "kinds": [${t.map(e=>JSON.stringify(e)).join(", ")}],`,n.length?` "counts": {\n${n.join(",\n")}\n }`:' "counts": {}',"}",""].join("\n")}function N(e){const t={};for(const[n,i]of e){const{kind:e}=M(n);c(e)&&(t[e]=(t[e]??0)+i)}return t}var F=class extends Error{},U=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),J=new Set(["$schema","schema","kinds","include","exclude","includeImporting","output","includeCopies","allow"]);function q(e,t="ui-kit.config.json"){const n=[],i=e=>{n.push(e)},o=(e,t,{required:n=!1}={})=>{if(void 0===e&&!n)return[];if(!Array.isArray(e)||e.some(e=>"string"!=typeof e||""===e))return i(`${t} must be a list of non-empty strings`),[];n&&0===e.length&&i(`${t} must name at least one entry`);for(const n of e)(n.startsWith("/")||n.startsWith("./")||n.includes("\\")||n.split("/").includes(".."))&&i(`${t}: "${n}" must be a path from the repository root, written with / (no ./, .. or \\)`);return e},s=(e,t)=>"string"!=typeof e||e.trim().length<10?(i(`${t} needs a "reason" a reviewer can read (a sentence, not a word)`),""):e,r=(e,t)=>void 0===e?[]:!Array.isArray(e)||e.some(e=>!U(e))?(i(`${t} must be a list of objects`),[]):e;if(!U(e))throw new F(`${t}: must be a JSON object`);for(const t of Object.keys(e))J.has(t)||i(`unknown key "${t}"`);1!==e.schema&&i("number"==typeof e.schema&&e.schema>1?`"schema": ${e.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');const a=[];if(Array.isArray(e.kinds)&&0!==e.kinds.length)for(const t of e.kinds)c(t)?a.includes(t)?i(`"kinds": "${t}" is listed twice`):a.push(t):i(`"kinds": unknown kind ${JSON.stringify(t)} (this efficient-shell knows: ${l.join(", ")})`);else i(`"kinds" must list the kinds this repository checks, from: ${l.join(", ")}`);const d=o(e.include,'"include"'),u=o(e.exclude,'"exclude"'),h=r(e.includeImporting,'"includeImporting"').map((e,t)=>({files:o(e.files,`"includeImporting"[${t}].files`,{required:!0}),modules:o(e.modules,`"includeImporting"[${t}].modules`,{required:!0}),reason:s(e.reason,`"includeImporting"[${t}]`)}));0===d.length&&0===h.length&&i('"include" must name the files that are operator UI (for example ["src/**/*.tsx"])');const m=r(e.output,'"output"').map((e,t)=>({files:o(e.files,`"output"[${t}].files`,{required:!0}),reason:s(e.reason,`"output"[${t}]`)})),g=o(e.includeCopies,'"includeCopies"');g.length&&!a.some(p)&&i(`"includeCopies" is read only by the copied-value kinds (${f.join(", ")}), and "kinds" names none of them`);const w=[],k=new Set;if(r(e.allow,'"allow"').forEach((e,t)=>{const n=`"allow"[${t}]`,[r]=o([e.file],`${n}.file`),d=s(e.reason,n);if(!c(e.kind))return void i(`${n}.kind must be one of: ${l.join(", ")}`);if(a.includes(e.kind)||i(`${n}: kind "${e.kind}" is not in "kinds"`),"number"!=typeof e.count||!Number.isInteger(e.count)||e.count<1)return void i(`${n}.count must be a whole number, 1 or more`);if(!r)return;const u=`${r}:${e.kind}`;k.has(u)&&i(`${n}: ${r} already has an allow entry for "${e.kind}"`),k.add(u),w.push({file:r,kind:e.kind,count:e.count,reason:d})}),n.length)throw new F(`${t}:\n - ${n.join("\n - ")}`);return{schema:1,kinds:l.filter(e=>a.includes(e)),include:d,exclude:u,includeImporting:h,output:m,includeCopies:g,allow:w}}var _="package.json",W=[2,4,8,12,16,20,24,32,40,48];function H(e){if("0"===e||"px"===e)return!0;const t=Number(e);return!!Number.isFinite(t)&&W.includes(4*t)}var Y=e=>String(e).padStart(2,"0"),G=/^(\d{4})-(\d{2})-(\d{2})$/;function K(e){return`${function(e){return`${e.getFullYear()}-${Y(e.getMonth()+1)}`}(e)}-${Y(e.getDate())}`}function V(e){const t="string"==typeof e?G.exec(e):null;if(!t)return null;const n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return K(n)===e?n:null}var Z=new Set(["iframe","frame","object","embed"]),Q=new Set(["href","xlinkHref","to","id","key","htmlFor"]),X=/(?<![&\w])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,ee=/(?<![\w-])rounded(?:-(?:[trblse]|tl|tr|br|bl|ss|se|ee|es))?-\[([^\]]*)\]/g,te=/^border(?:(?:Top|Bottom)(?:Left|Right)|(?:Start|End)(?:Start|End))?Radius$/,ne=/^(?:inherit|initial|unset|revert)$|var\(|^(?:50|100)%$|^(?:999|9999)(?:px)?$/,ie=/(?<![\w-])-?(?:p|px|py|pt|pr|pb|pl|ps|pe|m|mx|my|mt|mr|mb|ml|ms|me|gap|gap-x|gap-y|space-x|space-y)-(\d+(?:\.\d+)?|px|\[[^\]]*\])(?![\w.[/-])/g,oe=/(?<![\w-])text-\[(?:length:)?(\d*\.?\d+(?:px|rem|em|%))\]/g,se=/(?<![\w-])z-(\d+|\[[^\]]*\])(?![\w.[/-])/g,re=/(?<![\w-])shadow-(xs|2xs|md|2xl|\[[^\]]*\])(?![\w.[/-])/g,ae=/var\(|^(?:inherit|initial|unset|revert|revert-layer|none|auto)$/,le=/^(?:(?:padding|margin)(?:Top|Right|Bottom|Left|Inline|Block|InlineStart|InlineEnd|BlockStart|BlockEnd)?|gap|rowGap|columnGap)$/,ce=new Set([0,...W]),de=/var\(\s*--sf-site-gutter\s*,\s*-?\d/g,ue=/(?<![\w.-])960px(?![\w-])/g,he=/(?:^|[^\w-])\/(?:wheels|journal|tyres)\/$/,fe=/root:default-zone/g,pe=/max-width:\s*767px(?![\w-])/g,me=/\((?:max|min)-width/,ge=/(?:^|[a-z0-9_])(?:amount|price|total|subtotal|cents|fee|fees|cost|balance)$|(?:Amount|Price|Total|Subtotal|Cents|Fee|Fees|Cost|Balance)$/,we=/(?<![\w-])dark:(?=[\w[\-!@*(])/g,ke="slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose",$e="(?:50|[1-9]00|950)",be=new RegExp(`(?<![\\w-])(?:bg|text|border(?:-[xytrblse])?|ring(?:-offset)?|inset-ring|outline|divide|fill|stroke|from|via|to|shadow|inset-shadow|drop-shadow|accent|caret|decoration|placeholder)-(?:(?:${ke})-${$e}|white|black)(?:\\/[\\w.]+)?(?![\\w-])`,"g"),xe=new RegExp(`--color-(?:(?:${ke})-${$e}|white|black)(?![\\w-])`,"g"),ye=/(?<![\w-])(?:rgba?|hsla?|hwb|oklch|oklab|lab|lch)\(\s*[\d.]/g,ve=/(?<![\w-])(?:white|black|red|green|blue|yellow|orange|purple|pink|gray|grey|silver|maroon|navy|teal|olive|lime|aqua|fuchsia|brown|gold|beige|ivory|tan|crimson|coral|salmon|indigo|violet)(?![\w-])/gi,Se=/^(?:color|background(?:Color)?|border(?:Top|Right|Bottom|Left|Inline|Block)?(?:Color)?|outline(?:Color)?|fill|stroke|caretColor|accentColor|textDecorationColor|boxShadow|textShadow)$/,Ee=/(?<![&a-zA-Z0-9])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,ze=e=>[...e.matchAll(Ee)].length+[...e.matchAll(ye)].length+[...e.matchAll(be)].length+[...e.matchAll(xe)].length,Ie=new Set(["button","a","option","Button","IconButton","SplitButton","Link","NavLink","PopupMenuItem","PopupMenuLabel","DropdownMenuItem","MenuItem","ContextMenuItem"]),je=/(?:…|\.\.\.|&hellip;)\s*$/,Ce=new RegExp("\\p{L}","u"),Te=new RegExp("\\p{L}[\\p{L}-]*","u"),Ae={busy:{words:["Accepting","Adding","Applying","Approving","Arranging","Asking","Assigning","Booking","Building","Calculating","Cancelling","Capturing","Changing","Checking","Choosing","Closing","Combining","Comparing","Completing","Confirming","Connecting","Converting","Copying","Correcting","Counting","Creating","Deleting","Detaching","Downloading","Drawing","Duplicating","Emailing","Ending","Exporting","Fetching","Filing","Finding","Flushing","Generating","Grouping","Importing","Linking","Loading","Locating","Looking","Making","Marking","Matching","Measuring","Merging","Moving","Opening","Ordering","Paying","Pending","Posting","Preparing","Previewing","Pricing","Processing","Provisioning","Publishing","Purging","Pushing","Queued","Queuing","Quoting","Re-booking","Re-importing","Re-opening","Reading","Rebooting","Rebuilding","Receiving","Reconciling","Reconnecting","Recording","Refreshing","Refunding","Regenerating","Registering","Reinstating","Rejecting","Removing","Reopening","Requesting","Resending","Resetting","Resolving","Restarting","Restoring","Resuming","Retrying","Reversing","Reverting","Running","Saving","Searching","Sending","Setting","Settling","Sharing","Signing","Splitting","Starting","Submitting","Suggesting","Switching","Syncing","Taking","Testing","Transferring","Typing","Updating","Uploading","Verifying","Waiting","Withdrawing","Working"],zhStarts:["正在"],zhEnds:["中"]},placeholder:{},prompt:{}},Le=new Set((Ae.busy?.words??[]).map(e=>e.toLowerCase())),Re=new Set(["label","aria-label",...Ae.placeholder?[]:["placeholder","searchPlaceholder","emptyOptionLabel","blankLabel"]]),Me=(e,t)=>{if(!je.test(t)||!Ce.test(e))return!1;const n=e.match(Te)?.[0]?.toLowerCase();if(n&&Le.has(n))return!1;const i=e.replace(je,"").trim(),o=Ae.busy;return!(o&&(o.zhStarts.some(e=>i.startsWith(e))||o.zhEnds.some(e=>i.endsWith(e))))},Be=new Set(["confirm","alert","prompt"]),De=new Set(["window","globalThis","self"]);var Oe=e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"),Pe=e=>/\.(?:css|scss)$/.test(e),Ne=/^(?:color|background(?:-color)?|border(?:-(?:top|right|bottom|left|inline|block)(?:-(?:start|end))?)?(?:-color)?|outline(?:-color)?|fill|stroke|caret-color|accent-color|text-decoration(?:-color)?|box-shadow|text-shadow|column-rule(?:-color)?)$/;function Fe(e,t){if(!t.includes("colour"))return{};const n=e.replace(/\/\*[\s\S]*?\*\//g,e=>e.replace(/[^\n]/g," ")),i=[],o=e=>n.slice(0,e).split("\n").length;let s=0,r=0;for(let e=0;e<n.length;e++){const t=n[e];if("{"===t||"}"===t||";"===t){const a=n.slice(r,e);if("{"!==t&&s>0){const e=r+(a.length-a.trimStart().length),t=a.trim(),n=t.indexOf(":");if(t.startsWith("@apply"))for(let n=[...t.matchAll(be)].length;n>0;n--)i.push(o(e));else if(n>0){const s=t.slice(0,n).trim().toLowerCase(),r=t.slice(n+1);if(!/^(?:-webkit-)?mask/.test(s)){const t=ze(r)+(Ne.test(s)?[...r.matchAll(ve)].length:0);for(let n=0;n<t;n++)i.push(o(e))}}}"{"===t?s++:"}"===t&&(s=Math.max(0,s-1)),r=e+1}}return i.length?{colour:i}:{}}function Ue(e,t,n,i,o){const s=new Set(i),r=e.createSourceFile(t,n,e.ScriptTarget.Latest,!0,function(e,t){return t.endsWith(".tsx")?e.ScriptKind.TSX:t.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(t)?e.ScriptKind.JS:e.ScriptKind.TS}(e,t)),a={},l=/\.[jt]sx$/.test(t),c=e=>r.getLineAndCharacterOfPosition(e).line+1,d=(e,t)=>{s.has(e)&&(a[e]??=[]).push(c(t.getStart(r)))},u=(t,n)=>t.attributes.properties.find(t=>e.isJsxAttribute(t)&&t.name.getText(r)===n),h=t=>{const n=t?.initializer;if(n)return e.isStringLiteral(n)?n.text:e.isJsxExpression(n)&&n.expression&&e.isStringLiteralLike(n.expression)?n.expression.text:void 0},f=new Set;if(s.has("native")){const t=n=>{if(n)if(e.isIdentifier(n))Be.has(n.text)&&f.add(n.text);else if(e.isObjectBindingPattern(n)||e.isArrayBindingPattern(n))for(const i of n.elements)e.isBindingElement(i)&&t(i.name)},n=i=>{(e.isImportClause(i)||e.isImportSpecifier(i)||e.isNamespaceImport(i)||e.isVariableDeclaration(i)||e.isParameter(i)||e.isFunctionDeclaration(i))&&t(i.name),e.forEachChild(i,n)};n(r)}const p=t=>t&&e.isStringLiteralLike(t)?t.text:void 0,m=(e,t)=>{e&&("efficient-shell"===e||e.startsWith("efficient-shell/"))&&o?.add(e);const n=e?y(e):null;n&&d(n,t)},w=(e,t,n)=>{if(s.has("dark"))for(const n of e.matchAll(we))d("dark",t);if(s.has("radius"))for(const n of e.matchAll(ee))ne.test(n[1].trim())||d("radius",t);if(n&&l&&s.has("hex"))for(const n of e.matchAll(X))d("hex",t);if(n&&s.has("colour"))for(let n=ze(e);n>0;n--)d("colour",t);if(s.has("spacing"))for(const n of e.matchAll(ie)){const e=n[1];(e.startsWith("[")?ae.test(e.slice(1,-1).trim()):H(e))||d("spacing",t)}if(s.has("font-size"))for(const n of e.matchAll(oe))d("font-size",t);if(s.has("z-index"))for(const n of e.matchAll(se)){const e=n[1].startsWith("[")?n[1].slice(1,-1).trim():n[1];/^\d+$/.test(e)&&Number(e)>30&&d("z-index",t)}if(s.has("shadow"))for(const n of e.matchAll(re))n[1].startsWith("[")&&ae.test(n[1].slice(1,-1).trim())||d("shadow",t);if(s.has("gutter-literal"))for(const n of e.matchAll(de))d("gutter-literal",t);if(s.has("view-line-literal"))for(const n of e.matchAll(ue))d("view-line-literal",t);if(s.has("route-literal")&&he.test(e)&&d("route-literal",t),s.has("root-zone-literal"))for(const n of e.matchAll(fe))d("root-zone-literal",t);if(s.has("phone-query"))for(const n of e.matchAll(pe))d("phone-query",t)},k=t=>{if(t)return e.isJsxExpression(t)?k(t.expression):e.isStringLiteralLike(t)?t.text:e.isTemplateExpression(t)?[t.head.text,...t.templateSpans.map(e=>e.literal.text)].join(" "):void 0},$=t=>e.isNumericLiteral(t)&&100===Number(t.text),b=(t,n,i)=>{const o=e.isStringLiteralLike(n)?n.text.trim():void 0;if(s.has("colour")&&void 0!==o&&Se.test(t))for(const e of o.matchAll(ve))d("colour",i);if(s.has("spacing")&&le.test(t))e.isNumericLiteral(n)?ce.has(Number(n.text))||d("spacing",i):void 0!==o&&!ae.test(o)&&(e=>[...e.matchAll(/(-?\d*\.?\d+)(px|rem|em)\b/g)].map(e=>Math.abs(Number(e[1]))*("px"===e[2]?1:16)))(o).some(e=>!ce.has(e))&&d("spacing",i);else if(s.has("font-size")&&"fontSize"===t)(e.isNumericLiteral(n)||void 0!==o&&!ae.test(o)&&!/^(?:smaller|larger)$/.test(o))&&d("font-size",i);else if(s.has("z-index")&&"zIndex"===t){const t=[],o=n=>{e.isNumericLiteral(n)||e.isStringLiteralLike(n)&&/^\d+$/.test(n.text.trim())?t.push(Number(n.text)):e.forEachChild(n,o)};o(n);for(const e of t)e>30&&d("z-index",i)}else s.has("shadow")&&"boxShadow"===t&&(void 0===o||""===o||ae.test(o)||d("shadow",i))},x=(t,n)=>{if(e.isJsxOpeningElement(t)||e.isJsxSelfClosingElement(t)){const e=t.tagName.getText(r);if(s.has("sizes-literal")){const e=k(u(t,"sizes")?.initializer);void 0!==e&&me.test(e)&&d("sizes-literal",t)}if(/^[a-z]/.test(e)){const n=h(u(t,"type"));"svg"===e&&d("svg",t),"button"===e?d("button",t):"select"===e?d("select",t):"textarea"===e?d("textarea",t):"input"===e&&("range"===n?d("range",t):"hidden"!==n&&d("input",t));const i=h(u(t,"role"));"dialog"!==e&&"dialog"!==i&&"alertdialog"!==i||d("dialog",t),!Z.has(e)&&u(t,"title")&&d("title",t)}}else if(e.isCallExpression(t)){const n=t.expression;e.isIdentifier(n)?"createPortal"===n.text?d("portal",t):Be.has(n.text)&&!f.has(n.text)?d("native",t):"require"===n.text&&m(p(t.arguments[0]),t):e.isPropertyAccessExpression(n)?"createPortal"===n.name.text?d("portal",t):Be.has(n.name.text)&&e.isIdentifier(n.expression)&&De.has(n.expression.text)&&d("native",t):n.kind===e.SyntaxKind.ImportKeyword&&m(p(t.arguments[0]),t)}else{if(e.isImportDeclaration(t)||e.isExportDeclaration(t))return void m(p(t.moduleSpecifier),t);if(e.isPropertyAssignment(t)){const n=e.isIdentifier(t.name)||e.isStringLiteralLike(t.name)?t.name.text:"",i=t.initializer;if(b(n,i,t),s.has("sizes-literal")&&"sizes"===n){const e=k(i);void 0!==e&&me.test(e)&&d("sizes-literal",t)}s.has("radius")&&te.test(n)&&(e.isNumericLiteral(i)?ne.test(i.text)||d("radius",t):e.isStringLiteralLike(i)&&!ne.test(i.text.trim())&&d("radius",t))}else if(e.isBinaryExpression(t)){const n=t.operatorToken.kind;if(s.has("money-cents")&&(n===e.SyntaxKind.AsteriskToken||n===e.SyntaxKind.SlashToken)){const i=$(t.right)?t.left:$(t.left)&&n===e.SyntaxKind.AsteriskToken?t.right:void 0,o=i&&(t=>{let n=t;for(;e.isParenthesizedExpression(n)||e.isNonNullExpression(n)||e.isAsExpression(n);)n=n.expression;return e.isCallExpression(n)&&(n=n.expression),e.isIdentifier(n)?n.text:e.isPropertyAccessExpression(n)?n.name.text:e.isElementAccessExpression(n)&&e.isStringLiteralLike(n.argumentExpression)?n.argumentExpression.text:void 0})(i);o&&ge.test(o)&&d("money-cents",t)}}else if(s.has("local-helper")&&(e.isFunctionDeclaration(t)||e.isVariableDeclaration(t))&&t.name&&e.isIdentifier(t.name)&&Object.prototype.hasOwnProperty.call(g,t.name.text)&&(e.isFunctionDeclaration(t)?void 0!==t.body:void 0!==t.initializer&&(e.isArrowFunction(t.initializer)||e.isFunctionExpression(t.initializer))))d("local-helper",t);else if(e.isStringLiteralLike(t))w(t.text,t,n);else if(e.isTemplateExpression(t)){w(t.head.text,t.head,n);for(const e of t.templateSpans)w(e.literal.text,e.literal,n)}}e.isJsxAttribute(t)&&Q.has(t.name.getText(r))?e.forEachChild(t,e=>x(e,!1)):e.forEachChild(t,e=>x(e,n))};if(x(r,!0),s.has("ellipsis-label")&&function(e,t,n){const i=new Set,o=(e,t)=>{i.has(e)||(i.add(e),n(t))},s=n=>{if(n)if(e.isStringLiteralLike(n))Me(n.text,n.text)&&o(n,n.getStart(t));else if(e.isTemplateExpression(n)){const e=[n.head.text,...n.templateSpans.map(e=>e.literal.text)];Me(e.join(" "),e[e.length-1])&&o(n,n.getStart(t))}else e.isConditionalExpression(n)?(s(n.whenTrue),s(n.whenFalse)):e.isBinaryExpression(n)?(s(n.left),s(n.right)):e.isParenthesizedExpression(n)||e.isAsExpression(n)||e.isJsxExpression(n)?s(n.expression):e.isCallExpression(n)&&He.has(Ye(n.expression))&&n.arguments[0]&&s(n.arguments[0])},r=n=>{for(const i of n)if(e.isJsxText(i)){const e=i.getText(t);Me(e,e)&&o(i,i.getStart(t)+(e.length-e.trimStart().length))}else e.isJsxExpression(i)?s(i.expression):(e.isJsxElement(i)||e.isJsxFragment(i))&&r(i.children)},a=(n,i)=>{const o=n.attributes.properties.find(n=>e.isJsxAttribute(n)&&n.name.getText(t)===i),s=o?.initializer;return s&&e.isStringLiteral(s)?s.text:s&&e.isJsxExpression(s)&&s.expression&&e.isStringLiteralLike(s.expression)?s.expression.text:void 0},l=t=>t.properties.some(t=>e.isPropertyAssignment(t)&&(e.isIdentifier(t.name)||e.isStringLiteralLike(t.name))&&"value"===t.name.text&&e.isStringLiteralLike(t.initializer)&&""===t.initializer.text),c=n=>{if(e.isJsxElement(n)){const e=n.openingElement,i=e.tagName.getText(t),o="option"===i&&Ae.prompt&&""===a(e,"value");Ie.has(i)&&!o&&r(n.children)}else if(e.isJsxAttribute(n))Re.has(n.name.getText(t))&&s(n.initializer);else if(e.isPropertyAssignment(n)){const t=e.isIdentifier(n.name)||e.isStringLiteralLike(n.name)?n.name.text:"",i=Ae.prompt&&e.isObjectLiteralExpression(n.parent)&&l(n.parent);Re.has(t)&&!i&&s(n.initializer)}e.forEachChild(n,c)};c(t)}(e,r,e=>(a["ellipsis-label"]??=[]).push(c(e))),s.has("deprecated-undated")){const t=K(new Date);for(const n of function(e,t){const n=t.text,i=new Map,o=e=>e?.forEach(e=>i.set(e.pos,e)),s=t=>{o(e.getLeadingCommentRanges(n,t.pos)),o(e.getTrailingCommentRanges(n,t.end)),e.forEachChild(t,s)};s(t),o(e.getLeadingCommentRanges(n,t.endOfFileToken.pos));const r=[],a=e=>/^[ \t]*$/.test(n.slice(n.lastIndexOf("\n",e-1)+1,e));for(const t of[...i.values()].sort((e,t)=>e.pos-t.pos)){const i=n.slice(t.pos,t.end);if(t.kind===e.SyntaxKind.MultiLineCommentTrivia){r.push({pos:t.pos,text:i,end:t.end,run:!1});continue}const o=a(t.pos),s=r[r.length-1];o&&s?.run&&/^[ \t]*\r?\n[ \t]*$/.test(n.slice(s.end,t.pos))?(s.text+="\n"+i,s.end=t.end):r.push({pos:t.pos,text:i,end:t.end,run:o})}return r}(e,r)){const e=n.text.indexOf("@deprecated");e>=0&&We(n.text,t)&&(a["deprecated-undated"]??=[]).push(c(n.pos+e))}}return a}var Je=/\b(?:delete|deleted|remove|removed|goes|go)\s+(?:[\w`'.-]+\s+){0,2}?by\s+(\d{4}-\d{2}-\d{2})\b/i,qe=/next\s+major|major\s+after/i,_e=6;function We(e,t){const n=e.replace(/^\s*(?:\/\*\*?|\*\/|\*|\/\/)\s?/gm,"");if(qe.test(n))return'it still says "next major": the delete day is the only promise';const i=Je.exec(n);if(!i)return'no delete day ("delete by YYYY-MM-DD")';const o=V(i[1]);if(!o)return`${i[1]} is not a day`;const s=V(t);if(!s)throw new Error(`today must be YYYY-MM-DD, got ${t}`);if(o<s)return`its delete day ${i[1]} is past`;const r=function(e,t){const n=new Date(e.getFullYear(),e.getMonth()+t,1),i=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return new Date(n.getFullYear(),n.getMonth(),Math.min(e.getDate(),i))}(s,_e);return o>r?`its delete day ${i[1]} is more than ${_e} months out (last ${K(r)})`:void 0}var He=new Set(["say","t"]),Ye=e=>{const t=e.getText();return t.slice(t.lastIndexOf(".")+1)};function Ge(e){const t={};for(const[n,i]of Object.entries(e))i.length&&(t[n]=i.length);return t}var Ke=(e,t,n,i)=>function(e,t,n){const i=e.createSourceFile(t,n,e.ScriptTarget.Latest,!1),o=[];for(const t of i.statements)(e.isImportDeclaration(t)||e.isExportDeclaration(t))&&t.moduleSpecifier&&e.isStringLiteralLike(t.moduleSpecifier)&&o.push(t.moduleSpecifier.text);return o}(e,t,n).some(e=>i.some(t=>t.endsWith("/*")?e.startsWith(t.slice(0,-1)):e===t));var Ve=e=>new Map(e.allow.map(e=>[R(e.file,e.kind),e.count]));function Ze(e,t){return e.kinds.filter(e=>t.kinds.includes(e))}var Qe=(e,t,n)=>{if("kit-dep"===n)return` (${e.kitDeps.join(", ")})`;if("chart-dep"===n)return` (${e.chartDeps.join(", ")})`;const i=e.hits.get(t)?.[n]??[];if(0===i.length)return"";const o=i.slice(0,12).join(", ");return` (line${1===i.length?"":"s"} ${o}${i.length>12?", …":""})`};function Xe(e,t,n){const i=Ve(e),o=new Map;for(const[e,s]of t.counts){const{kind:t}=M(e);if(!c(t)||!n.includes(t))continue;const r=s-(i.get(e)??0);r>0&&o.set(e,r)}return{kinds:l.filter(e=>n.includes(e)),counts:o}}function et(e,t){let n=0;for(const i of new Set([...e.keys(),...t.keys()]))(e.get(i)??0)!==(t.get(i)??0)&&(n+=1);return n}var tt="\n// <button> in a comment is not a button, and <svg> in one is not a drawing\n/* nor is <input title=\"x\"> in this one, or dark:bg-black, or #fff */\nimport { createPortal } from 'react-dom';\nimport { Dialog } from '@headlessui/react';\nimport { TrashIcon } from '@heroicons/react/24/outline';\nimport type { Icon } from 'lucide-react';\nimport { Button, confirm } from 'efficient-shell';\nexport { Slot } from '@radix-ui/react-slot';\nexport { CheckIcon } from '@radix-ui/react-icons';\nimport { LineChart } from 'recharts';\nimport 'd3-scale';\nexport { VictoryPie } from 'victory';\nimport { BarChart } from '@mui/x-charts';\nimport Tree from 'react-d3-tree';\nimport { TimeSeriesChart } from 'efficient-shell/ui';\n// import 'chart.js' in a comment is not an import, and 'echarts' in a string is not one either\nconst chartLabel = 'd3-array';\n\nconst a = <button title=\"Says what it does\">x</button>;\nconst b = <input type=\"range\" />;\nconst c = <input type=\"text\" />;\nconst c2 = <input type={\"hidden\"} name=\"csrf\" />;\nconst c3 = <input type=\"hidden\" />;\nconst c4 = <input type={kind} />;\nconst d = <select />;\nconst d2 = <textarea />;\nconst e = <div role=\"dialog\" />;\nconst e2 = <dialog open />;\nconst e3 = <section role={'alertdialog'} />;\nconst f = <iframe title=\"Preview\" />;\nconst f2 = <object title=\"Chart\" />;\nconst g = <Button title=\"a prop, not a tooltip\" role=\"dialog\" />;\nconst g2 = (\n <button\n type=\"button\"\n title={hint}\n >\n y\n </button>\n);\nconst h = ReactDOM.createPortal(a, document.body);\nconst i = createPortal(a, document.body);\n\nasync function leave() {\n if (window.confirm('Sure?')) return;\n globalThis.alert('No');\n alert('native: nothing binds the name');\n prompt('native too');\n await confirm('the shell: the import binds it');\n record.confirm('a method, not the popup');\n}\n\nconst j = <div className=\"bg-white dark:bg-black dark:hover:text-white is-dark:no\" />;\nconst k = clsx('text-gray-900', on && 'dark:text-gray-100');\nconst l = <span style={{ color: '#fff', background: \"#12ab34\" }} className={`border-[#0a0b0c80] ${x}`} />;\nconst m = <a href=\"#faded\" id=\"#bad\" key=\"#abc\" to=\"#face\">skip</a>;\nconst n = <label htmlFor={'#dead'}>skip</label>;\nconst o = <span>&#1234; and BG#00340 and #12345 and #added are not colours</span>;\nconst p = 'entity &#x1f; ref BG#00340';\nconst q = <use xlinkHref=\"#abc\" fill=\"url(#fed)\" />;\nconst t = <div className=\"rounded-[4px] rounded-t-[0.5rem] hover:rounded-[2px] rounded-lg rounded-(--radius-card) rounded-[inherit] rounded-[var(--r)]\" />;\nconst u = <div style={{ borderRadius: 6, borderTopLeftRadius: '3px', borderBottomRightRadius: '50%', borderEndEndRadius: 'var(--radius-card)' }} />;\nconst v = <i style={{ borderRadius: 9999 }} />;\nconst w = <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 4h16\" /></svg>;\nconst w2 = <Svg viewBox=\"0 0 24 24\" />;\nconst w3 = '<svg viewBox=\"0 0 1 1\"></svg> in a string is not an element';\nconst r = lazy(() => import('@mui/material'));\nconst s = require('react-select');\nconst s2 = require('chart.js/auto');\nconst s3 = import('@nivo/line');\n",nt={button:2,input:2,range:1,textarea:1,select:1,dialog:3,title:2,portal:2,native:4,dark:3,hex:3,radius:5,kit:5,icon:3,svg:1,chart:5,colour:8},it={kit:1,dark:1,portal:1,radius:2,chart:1,colour:2},ot=(...e)=>e.join("-"),st=`\nconst s1 = <i className="${[ot("px","2.5"),ot("py","1.5"),"md:"+ot("gap","1.5"),"-"+ot("mt","1.5"),ot("p","[10px]")].join(" ")}" />;\nconst s2 = <i className="${[ot("p","0"),ot("px","px"),ot("p","0.5"),ot("p","3"),ot("gap-x","4"),ot("p","12"),ot("p","(--space-12)"),ot("p","[var(--space-12)]"),ot("space-x","reverse"),ot("top","1.5")].join(" ")}" />;\nconst s3 = <i style={{ padding: 6, marginTop: '10px', gap: 8, margin: '0 auto', paddingInline: 'var(--space-12)' }} />;\nconst f1 = <i className="${[ot("text","[11px]"),ot("text","[0.8rem]"),ot("text","xs"),ot("text","[#fff]"),ot("text","(--text-2xs)")].join(" ")}" />;\nconst f2 = <i style={{ fontSize: 12 }} />;\nconst f3 = { fontSize: 'var(--x)', font: 'inherit' };\nconst z1 = <i className="${[ot("z","[9999]"),ot("z","50"),ot("z","10"),ot("z","30"),"-"+ot("z","10"),ot("z","auto"),ot("z","(--z-popup)"),ot("z","[var(--z-popup)]")].join(" ")}" />;\nconst z2 = { zIndex: on ? 2020 : 2010 };\nconst z3 = { zIndex: Z_LAYERS.popup, top: 9999 };\nconst h1 = <i className="${[ot("shadow","[0_1px_2px_#000]"),ot("shadow","md"),"shadow",ot("shadow","lg"),ot("shadow","(--elevation-panel)"),ot("shadow","black/20"),ot("drop-shadow","md")].join(" ")}" />;\nconst h2 = { boxShadow: '0 1px 2px rgba(0,0,0,.1)' };\nconst h3 = { boxShadow: 'none', outline: 'var(--elevation-raised)' };\n`,rt={spacing:7,"font-size":3,"z-index":4,shadow:3,hex:1,colour:4},at={colour:4},lt={"ellipsis-label":9},ct=`\n// "root:default-zone" and \`/wheels/\${slug}\` in a comment are not copies\nimport { escapeHtml } from 'efficient-shell/format';\nconst c1 = "${ot("pl","[var(--sf-site-gutter,40px)]")}";\nconst c2 = "var(--sf-site-gutter)";\nconst c3 = <i className="${ot("max","[960px]")}:hidden" />;\nconst c4 = "1960px";\nconst c5 = \`/wheels/\${slug}\`;\nconst c6 = "/tyres/" + slug;\nconst c7 = wheelPath(slug);\nconst c8 = { zone: "root:default-zone" };\nconst c9 = "(max-width: 767px)";\nconst c10 = <img sizes="(max-width: 800px) 100vw, 50vw" />;\nconst c11 = <img sizes={CONTENT_SIZES} />;\nconst c12 = Math.round(price * 100) / 100;\nconst c13 = ratio * 100;\nfunction escapeHtml(s: string) { return s; }\nconst c14 = timeAgo(when);\n/** @deprecated Remove at the next major. */\nconst c15 = 1;\nconst c16 = "@deprecated in a string";\n`,dt={"gutter-literal":1,"view-line-literal":1,"route-literal":2,"root-zone-literal":1,"phone-query":1,"sizes-literal":1,"money-cents":1,"local-helper":1,"deprecated-undated":1},ut=e=>l.filter(t=>e[t]).map(t=>`${t} ${e[t]}`).join(", ")||"nothing";var ht="ui-kit.config.json",ft="ui-kit.baseline.json",pt="efficient-shell-ui-check",mt=`${pt}: every surface a person operates takes its UI from efficient-shell (harness UI-24).\n\n ${pt} check this repository against ${ft}\n ${pt} --print print today's counts as a baseline, and change nothing\n ${pt} --summary print totals per kind and per folder, as Markdown\n ${pt} --json print the result as JSON\n ${pt} --update lower the lines whose counts fell, and delete the ones at zero\n ${pt} --update --allow-move also follow a renamed or split file (no total may rise)\n ${pt} --init write the first ${ft}\n ${pt} --init --kind <kind> take the baseline for a kind just added to "kinds"\n ${pt} --no-base do not compare with the base branch (refused on a pull request)\n ${pt} --base-lock run only on a release with the base-branch lock (an older one fails on the flag)\n\nKinds: ${l.join(", ")}\nReads ${ht} in the current directory.`;var gt=(e,t)=>`${e} ${t}${1===e?"":"s"}`,wt=(e,t)=>{const n=N(e);return t.map(e=>`${e} ${n[e]??0}`).join(" · ")};function kt(e,t,s,a,l){const d=e.env.GITHUB_BASE_REF,u=!d&&"push"===e.env.GITHUB_EVENT_NAME;if(!d&&!u)return{problems:[],note:"",warnings:[]};const h=d?`GITHUB_BASE_REF is "${d}"`:'GITHUB_EVENT_NAME is "push"',f=(e,t)=>({problems:[e],note:t,warnings:[]}),g=e.git(["rev-parse","--show-prefix"]);if(null===g)return f(`${h}, and git could not read this checkout, so the base branch could not be compared. The comparison is the lock: run the check in the git checkout, with git installed and the folder trusted (git config --global --add safe.directory <path>).`,"git could not read this checkout");const w=d?`origin/${d}`:"HEAD^1";if(null===e.git(["rev-parse","--verify","--quiet",`${w}^{commit}`])&&(e.git(d?["fetch","--no-tags","--depth=1","origin",`+refs/heads/${d}:refs/remotes/origin/${d}`]:["fetch","--no-tags","--deepen=1"]),null===e.git(["rev-parse","--verify","--quiet",`${w}^{commit}`])))return f(d?`${h}, and ${w} could not be fetched, so the base branch could not be compared. On a pull request the comparison is the lock: give the job the base branch (git fetch origin ${d}).`:`${h}, and ${w} (the commit before this one) could not be read, so it could not be compared. On a push the comparison is the lock: give the job that commit (fetch-depth: 2).`,`${w} could not be fetched`);const k=g.trim(),$=n(e.cwd,...k.split("/").filter(Boolean).map(()=>"..")),b=[],x=e.git(["show",`${w}:${k}${ft}`]);if(null===x){const t=e.git(["ls-tree","-r","--full-tree","--name-only","-z",w]);if(null===t)return f(`${w} has no ${ft} in this folder, and git could not list ${w}'s files, so a check that moved here cannot be told from an adoption.`,"adoption not confirmed");const o=t.split("\0").filter(e=>(e===ft||e.endsWith(`/${ft}`))&&!i(n($,e)));return o.length?f(`${o.join(", ")} ${1===o.length?"is":"are"} on ${w} and gone here, and ${w} has no ${ft} in this folder (${k||"the repository root"}): the check moved. Its lines would be taken as an adoption and never compared: keep the config and the baseline in the folder they were in.`,"the check moved"):{problems:[],note:`${w} has no ${ft} yet (adoption)`,warnings:b}}const y=e=>`${w}'s ${e} could not be parsed, and this change replaces it with one that parses, so ${e===ft?"the base branch was not compared":"no scope was checked for shrinking"}. The next change is compared against it as usual.`;let v;try{v=O(x,`${w}:${ft}`)}catch{return{problems:[],note:`${w}'s ${ft} could not be read; the base branch was not compared`,warnings:[y(ft)]}}const S=new Map,E=t=>(S.has(t)||S.set(t,e.git(["show",`${w}:${k}${t}`])),S.get(t)??null);let I=null;try{const e=E(ht);null!==e&&(I=q(JSON.parse(e),`${w}:${ht}`))}catch{I=null}null===I&&b.push(y(ht));const j=[],C=new Set(a.kinds.filter(e=>s.kinds.includes(e)));for(const e of v.kinds)C.has(e)||j.push(`"${e}" is checked on ${w}, and not here ("kinds" in ${ht}, or ${ft}). Its lines would never be counted again: keep the kind.`);const A=t=>{const i=t.split("/");for(let t=1;t<=i.length;t++)try{if(r(n(e.cwd,...i.slice(0,t))).isSymbolicLink())return!0}catch{return!1}return!1},L=new Set(l.copyOnly),B=new Set(l.files.filter(e=>!L.has(e))),D=(e,t)=>B.has(e)||L.has(e)&&c(t)&&p(t),P=new Set([...v.counts.keys()].map(e=>M(e)).filter(({file:e,kind:t})=>e!==_&&!D(e,t)).map(({file:e})=>e));for(const e of P)A(e)&&j.push(`${e} is under a symbolic link now (the file or a folder above it), and ${w} counted it. The walk does not follow it for every kind counted there, so those lines would never be counted again: keep the real file here.`);const F=Ve(a),U=I?Ve(I):F,J=e=>(v.counts.get(e)??0)+(U.get(e)??0),W=new Map;for(const e of new Set([...v.counts.keys(),...U.keys()])){const{file:t,kind:n}=M(e);t!==_&&0!==J(e)&&((W.get(t)??[]).includes(n)||W.set(t,[...W.get(t)??[],n]))}const H=e=>(W.get(e)??[]).filter(t=>{return n=`${e}:${t}`,(s.counts.get(n)??0)+(F.get(n)??0)<J(`${e}:${t}`);var n}),Y=[...W.keys()].filter(t=>!i(n(e.cwd,t))&&!A(t)),G=[...W.keys()].filter(e=>!Y.includes(e)&&!A(e)&&H(e).length>0),K=[...Y,...G];if(K.length){const i=e.git(["diff","-M30%","-C30%","--find-copies-harder","-l0","--no-relative","--name-status","-z",w]);if(null===i)j.push(`${gt(K.length,"file")} that ${w} counted ${1===K.length?"is":"are"} gone or count less (${K.slice(0,3).join(", ")}${K.length>3?", …":""}), and git could not list the renames, so a move out of the check cannot be told from a delete.`);else{const e=new Map,s=i.split("\0");for(let t=0;t<s.length;){const n=s[t]??"";if(n.startsWith("R")||n.startsWith("C")){const[n,i]=[s[t+1],s[t+2]];n&&i&&e.set(n,[...e.get(n)??[],i]),t+=3}else t+=n?2:1}const r=(e,i,s)=>{const r=s.filter(c),a=Pe(e)&&Pe(i);if(!Oe(e)&&!a)return r;let l;try{l=o(n($,e),"utf8")}catch{return r}if(a){const e=Fe(l,r);return r.filter(t=>(e[t]?.length??0)>0)}const d=Ue(t,e,l,r),u=Ue(t,i,l,r);return r.filter(e=>(d[e]?.length??0)+(u[e]?.length??0)>0)};for(const t of K){const n=Y.includes(t)?"moved to":"counts less, and git lists a copy of it at";for(const i of e.get(`${k}${t}`)??[]){const e=r(i,t,Y.includes(t)?W.get(t)??[]:H(t));if(!e.length)continue;if(!i.startsWith(k)){j.push(`${t} ${n} ${i}, outside the folder the check runs in, and it holds ${e.map(e=>`"${e}"`).join(", ")} that ${w} counted. Those lines would never be counted again: keep it in this folder, in a scope.`);continue}const o=i.slice(k.length),s=e.filter(e=>!D(o,e));s.length&&j.push(`${t} ${n} ${o}, and no scope reads it there for ${s.map(e=>`"${e}"`).join(", ")}. ${w} counted it, so those lines would never be counted again: move it into a scope, or widen one to it.`)}}}}if(I){const n=z(I.exclude),i=I.kinds.includes("colour"),o=e=>(Oe(e)||i&&Pe(e))&&!n(e),s=t=>T(e.cwd,[t]).some(o),r="keep the line; delete it only when the files it matches are gone.",c=(e,t,n)=>t.filter(e=>!n.includes(e)&&s(e)).map(t=>`"${e}" drops "${t}", which ${w} reads. Those files would never be counted again: ${r}`),d=(e,t,n)=>n.filter(e=>!t.includes(e)&&s(e)).map(t=>`"${e}" adds "${t}", which takes files ${w} reads out of the check. Those files would never be counted again.`),u=e=>e.flatMap(e=>e.files.flatMap(t=>e.modules.map(e=>({glob:t,module:e})))),h=new Set(u(a.includeImporting).map(({glob:e,module:t})=>`${e}\n${t}`));j.push(...c("include",I.include,a.include),...u(I.includeImporting).filter(({glob:e,module:t})=>!h.has(`${e}\n${t}`)&&s(e)).map(({glob:e,module:t})=>`"includeImporting" drops "${e}" (${t}), which ${w} reads. Those files would never be counted again: ${r}`),...c("includeCopies",I.includeCopies,a.includeCopies),...d("exclude",I.exclude,a.exclude),...d("output",I.output.flatMap(e=>e.files),a.output.flatMap(e=>e.files)));const f=new Set(l.copyOnly),p=new Set(l.files.filter(e=>!f.has(e))),m=z(I.include),g=z(I.output.flatMap(e=>e.files)),k=new Set;for(const i of I.includeImporting)for(const o of T(e.cwd,i.files)){if(!Oe(o)||n(o)||g(o)||m(o))continue;if(p.has(o)||k.has(o))continue;const e=E(o);null!==e&&Ke(t,o,e,i.modules)&&(k.add(o),j.push(`${o} no longer imports ${i.modules.join(", ")}, so "includeImporting" stops reading it, and ${w} reads it. Keep the import, or read the file with "include".`))}}const V=a.kinds.filter(p),Z=[],Q=new Set,X={};if(I){const e=z(I.exclude),n=z(I.include),i=z(I.output.flatMap(e=>e.files)),o=z(I.includeCopies),s=I.includeImporting.map(e=>({files:z(e.files),modules:e.modules})),r=o=>{if(e(o))return!1;if(n(o)&&!i(o))return!0;const r=s.filter(e=>e.files(o));if(!r.length||!Oe(o))return!1;const a=E(o);return null!==a&&r.some(e=>Ke(t,o,a,e.modules))};for(const n of l.files){if(r(n))continue;const i=L.has(n)?V:a.kinds,s=!e(n)&&o(n),c=i.filter(e=>!(s&&p(e)));if(!c.length)continue;Z.push(n);for(const e of c)Q.add(e);if(!Oe(n))continue;const d=E(n);if(null===d)continue;const u=Ue(t,n,d,c);for(const e of c){const t=Math.min(u[e]?.length??0,l.counts.get(`${n}:${e}`)??0);t>0&&(X[e]=(X[e]??0)+t)}}}const ee=N(v.counts),te=N(s.counts),ne=N(F),ie=N(U),oe=(e,t,n)=>(e[n]??0)+(t[n]??0);if(j.push(...a.kinds.filter(e=>v.kinds.includes(e)&&oe(te,ne,e)>oe(ee,ie,e)+(X[e]??0)).map(e=>{const t=(ne[e]??0)||(ie[e]??0),n=n=>t?` (and ${n[e]??0} in "allow")`:"";return`${ft} holds ${te[e]??0} of "${e}"${n(ne)}, and ${w} holds ${ee[e]??0}${n(ie)}${Z.length?` (and ${X[e]??0} in the files new to a scope)`:""}. The baseline only goes down, and "allow" with it: use ${m[e].instead}. A count that must stay goes in "allow" in ${ht}, with its reason, and the same count of that kind is burned down in this change.`})),I)for(const e of a.allow){const t=U.get(R(e.file,e.kind));void 0!==t&&e.count<=t||b.push(`"allow" in ${ht} ${void 0===t?"adds":`raises from ${t}`} ${e.file} (${e.kind}) at ${e.count}: ${e.reason}`)}const se=[`compared with ${w}`];return null===I&&se.push(`${w}'s ${ht} could not be read, so every line was compared and no scope was checked for shrinking`),Z.length&&se.push(`${[...Q].every(p)?'"includeCopies" changed: ':""}${Z.length} file${1===Z.length?"":"s"} new to a scope, so ${1===Z.length?"its":"their"} ${a.kinds.filter(e=>Q.has(e)).join(", ")} lines may hold what ${1===Z.length?"it":"they"} held on ${w}`),{problems:j,note:se.join("; "),warnings:b}}process.exitCode=function(e,t){const r=function(e){const t={print:!1,summary:!1,json:!1,update:!1,allowMove:!1,init:!1,noBase:!1,help:!1,version:!1,kinds:[]};for(let n=0;n<e.length;n++){const i=e[n];if("--print"===i)t.print=!0;else if("--summary"===i)t.summary=!0;else if("--json"===i)t.json=!0;else if("--update"===i)t.update=!0;else if("--allow-move"===i)t.allowMove=!0;else if("--init"===i)t.init=!0;else if("--no-base"===i)t.noBase=!0;else{if("--base-lock"===i)continue;if("--help"===i||"-h"===i)t.help=!0;else if("--version"===i||"-v"===i)t.version=!0;else if("--kind"===i){const i=e[++n];if(!i)return"--kind needs a kind after it";t.kinds.push(...i.split(","))}else{if(!i.startsWith("--kind="))return`unknown argument "${i}"`;t.kinds.push(...i.slice(7).split(","))}}}return t.allowMove&&!t.update?"--allow-move goes with --update":t.kinds.length&&!t.init?"--kind goes with --init":[t.print,t.summary,t.update,t.init].filter(Boolean).length>1?"choose one of --print, --summary, --update and --init":t}(e);if("string"==typeof r)return t.err(`${pt}: ${r}\n\n${mt}`),2;if(r.help)return t.out(mt),0;if(r.version)return t.out(t.version),0;const a=e=>(r.json?t.out(JSON.stringify({tool:pt,version:t.version,ok:!1,failures:[e]},null,2)):t.err(`${pt}: ${e}`),1);if(r.noBase&&t.env.GITHUB_BASE_REF)return a("--no-base is refused on a pull request (GITHUB_BASE_REF is set): the base-branch comparison is what stops a pull request lowering its own baseline.");const l=n(t.cwd,ht);if(!i(l))return a(`no ${ht} in ${t.cwd}. Run it from the repository root; the harness has the template.`);let d,f;try{d=q(JSON.parse(o(l,"utf8")),ht)}catch(e){return a(e instanceof F?e.message:`${ht} is not valid JSON: ${e.message}`)}try{f=t.loadTypeScript()}catch{return a('this check reads the TypeScript AST and found no "typescript" package here. Install it as a devDependency.')}const g=function(e){const t=[],n=h,i=[["fixture.tsx",tt,nt],["fixture.ts","\nimport { toast } from 'sonner';\nimport { extent } from 'd3-array';\nexport const tone = { warn: '#f59e0b' };\nexport const cls = 'ring-1 dark:ring-white rounded-[3px]';\nexport const box = { borderRadius: '0.25rem', radius: 4 };\nexport function ask(confirm: (message: string) => boolean) {\n return confirm('a parameter binds the name');\n}\nexport const mount = (node: unknown) => ReactDOM.createPortal(node, document.body);\n",it],["tokens.tsx",st,rt],["labels.tsx","\n// <Button>Save…</Button> in a comment is not a label\nconst l1 = <Button>Extend trial…</Button>;\nconst l2 = <PopupMenuItem onClick={go}><span>Read from a PDF...</span></PopupMenuItem>;\nconst l3 = <Button>{busy ? 'Saving…' : 'Duplicate site…'}</Button>;\nconst l4 = <Item label=\"Translate…\" aria-label={'More…'} />;\nconst l5 = [{ label: 'Reject…' }, { value: CUSTOM, label: 'Custom…' }];\nconst l6 = <option value={CUSTOM}>Different address…</option>;\nconst l7 = <PopupMenuLabel>{say(\"Duplicate to page…\")}</PopupMenuLabel>;\nconst n7 = <Button>{t('team:menu.remove')}</Button>;\nconst n1 = <Button>{`${name.slice(0, 9)}…`}</Button>;\nconst n2 = <p>Loading weather…</p>;\nconst n3 = <Input placeholder=\"Search…\" />;\nconst n4 = <option value=\"\">Pick a carrier…</option>;\nconst n5 = [{ value: '', label: 'Select…' }];\nconst n6 = <Button>Extend trial</Button>;\n",lt],["copies.tsx",ct,dt]];for(const[o,s,r]of i){const i=Ge(Ue(e,o,s,n));n.some(e=>(i[e]??0)!==(r[e]??0))&&t.push(`${o}: read ${ut(i)}; it holds ${ut(r)}`)}const o=Ge(Fe('\n/* #fff in a comment */\n.a:hover { color: #111; border: 1px solid white; }\n[data-x="#fff"] { mask-image: linear-gradient(#000, transparent); color: var(--ink); }\n.b { --mine: rgb(0 0 0 / .5); background: var(--surface, #fff); }\n',n));n.some(e=>(o[e]??0)!==(at[e]??0))&&t.push(`style.css: read ${ut(o)}; it holds ${ut(at)}`);const s=Ge(Ue(e,"fixture.tsx",tt,["button"]));return"button"!==Object.keys(s).join()&&t.push(`asked for button alone, the reader reported ${ut(s)}`),t}(f);if(g.length)return a(`the reader misread its own fixtures with typescript ${f.version}, so nothing it says about this repository can be trusted:\n - `+g.join("\n - "));const w=function(e,t,s){const r=[],a=z(s.exclude),l=z(s.output.flatMap(e=>e.files)),c=new Map,d=e=>{let i=c.get(e);return void 0===i&&c.set(e,i=o(n(t,e),"utf8")),i},h=(e,n)=>{for(const i of e)0===T(t,[i]).length&&r.push(`${n}: "${i}" matches no file. Delete the line, or fix the path.`)};h(s.include,'"include"'),s.output.forEach((e,t)=>h(e.files,`"output"[${t}]`)),s.includeImporting.forEach((e,t)=>h(e.files,`"includeImporting"[${t}]`)),h(s.includeCopies,'"includeCopies"');const f=new Set,m=s.kinds.includes("colour"),g=e=>(Oe(e)||m&&Pe(e))&&!a(e)&&!l(e);for(const e of T(t,s.include))g(e)&&f.add(e);for(const n of s.includeImporting)for(const i of T(t,n.files))g(i)&&Oe(i)&&!f.has(i)&&Ke(e,i,d(i),n.modules)&&f.add(i);const w=s.kinds.filter(p),k=new Set;if(w.length)for(const e of T(t,s.includeCopies))!Oe(e)||a(e)||f.has(e)||k.add(e);const $=[...f,...k].sort(),x=s.kinds.filter(e=>!u(e)),y=new Map,S=new Map,E=new Set;for(const t of $){const n=k.has(t),i=n?w:x,o=Pe(t)?Fe(d(t),i):Ue(e,t,d(t),i,n?void 0:E);let s=!1;for(const e of i){const n=o[e]?.length??0;n&&(S.set(R(t,e),n),s=!0)}s&&y.set(t,o)}let I=[],j=[],C=[];const A=s.kinds.filter(u);if(A.length){const e=n(t,_);if(i(e)){const t=JSON.parse(o(e,"utf8")),n=["dependencies","peerDependencies","optionalDependencies"].flatMap(e=>Object.keys(t[e]??{})),i=new Set([...E].flatMap(e=>b[e]??[])),r=[...new Set(n)].sort();if(s.kinds.includes("kit-dep")){const e=r.filter(e=>"kit-dep"===v(e));I=e.filter(e=>!i.has(e)),j=e.filter(e=>i.has(e)),I.length&&S.set(R(_,"kit-dep"),I.length)}s.kinds.includes("chart-dep")&&(C=r.filter(e=>"chart-dep"===v(e)),C.length&&S.set(R(_,"chart-dep"),C.length))}else for(const e of A)r.push(`"kinds" includes "${e}", and there is no ${_} here to read.`)}for(const e of s.allow)(u(e.kind)?e.file===_:f.has(e.file)||p(e.kind)&&k.has(e.file))||r.push(`"allow": ${e.file} (${e.kind}) is not a file this check reads. Delete the entry, or fix the path.`);return{files:$,copyOnly:[...k].sort(),hits:y,counts:S,kitDeps:I,shellPeers:j,chartDeps:C,problems:r}}(f,t.cwd,d);if(0===w.files.length)return a(`read no files. "include" in ${ht} matches nothing, so a pass would mean nothing.`);const k=n(t.cwd,ft),$=r.json,x=e=>{$||t.out(e)};if(r.print)return t.out(P(Xe(d,w,d.kinds)).trimEnd()),0;if(r.summary){for(const e of function(e,t){const n=new Map,i=new Map;for(const[e,o]of t.counts){const{file:t,kind:s}=M(e);if(!c(s))continue;const r=n.get(s)??{count:0,files:new Set};r.count+=o,r.files.add(t),n.set(s,r);const a=t.split("/"),l=a.length>2?a.slice(0,2).join("/"):2===a.length?a[0]:".",d=i.get(l)??{};d[s]=(d[s]??0)+o,i.set(l,d)}const o=e.kinds.filter(e=>n.has(e)),s=[`**UI kit check (harness UI-24):** ${new Set([...t.counts.keys()].map(e=>M(e).file)).size} of ${gt(t.files.length,"file")} still draw UI of their own.`,"","| Kind | Count | Files | The shell has |","|---|---:|---:|---|",...e.kinds.map(e=>{const t=n.get(e);return`| \`${e}\` | ${t?.count??0} | ${t?.files.size??0} | ${m[e].instead} |`})];if(o.length&&i.size){const e=e=>o.reduce((t,n)=>t+(e[n]??0),0),t=[...i].sort((t,n)=>e(n[1])-e(t[1])||(t[0]<n[0]?-1:1));s.push("",`| Folder | ${o.map(e=>`\`${e}\``).join(" | ")} | Total |`,`|---|${o.map(()=>"---:").join("|")}|---:|`,...t.map(([t,n])=>`| \`${t}\` | ${o.map(e=>n[e]??0).join(" | ")} | ${e(n)} |`))}return s}(d,w))t.out(e);return 0}let y=null;if(i(k))try{y=O(o(k,"utf8"),ft)}catch(e){return a(e instanceof L?e.message:String(e))}if(r.init){const e=r.kinds.filter(e=>!c(e)||!d.kinds.includes(e));if(e.length)return a(`--kind ${e.join(", ")}: not in "kinds" in ${ht}. Add it there first.`);const t=r.kinds;if(y){if(0===t.length)return a(`${ft} already exists, and --init would overwrite what it holds. It is for the adoption pull request only. To start checking a kind, add it to "kinds" and run --init --kind <kind>.`);const e=t.filter(e=>y.kinds.includes(e));if(e.length)return a(`the baseline was already taken for ${e.join(", ")}. Its lines only go down; use --update.`);const n=Xe(d,w,t);y={kinds:[...y.kinds,...t],counts:new Map([...y.counts,...n.counts])}}else{if(t.length)return a(`there is no ${ft} yet. Run --init on its own first.`);y=Xe(d,w,d.kinds)}s(k,P(y)),x(`${pt}: wrote ${ft} (${gt(y.counts.size,"line")}: ${wt(y.counts,y.kinds)})`)}if(!y)return a(`no ${ft}. This repository has not adopted the check yet: run ${pt} --init, and commit the file.`);if(r.update){const e=function(e,t,n,{allowMove:i=!1}={}){const o=Ze(e,t),s=Xe(e,n,o),r=new Map([...t.counts].filter(([e])=>o.includes(M(e).kind)));if(i){const e=N(r),n=N(s.counts),i=o.filter(t=>(n[t]??0)>(e[t]??0)).map(t=>`${t}: ${n[t]??0} across the repository, and the baseline holds ${e[t]??0}`);return i.length?{baseline:t,lowered:0,refused:i}:{baseline:s,lowered:et(r,s.counts),refused:[]}}const a=new Map;for(const[e,t]of r){const n=Math.min(t,s.counts.get(e)??0);n>0&&a.set(e,n)}return{baseline:{kinds:o,counts:a},lowered:et(r,a),refused:[]}}(d,y,w,{allowMove:r.allowMove});if(e.refused.length)return a(`--allow-move follows code that moved, and this is more of it than before:\n - ${e.refused.join("\n - ")}\nNothing was written.`);y=e.baseline,s(k,P(y)),x(`${pt}: ${e.lowered?`changed ${gt(e.lowered,"line")} in`:"nothing to change in"} ${ft}`)}const S=function(e,t,n){const i=[],o=[],s=[...n.problems],r=Ve(e),a=new Set(Ze(e,t)),l=e.kinds.filter(e=>!t.kinds.includes(e));l.length&&s.push(`"kinds" names ${l.map(e=>`"${e}"`).join(", ")}, and the baseline was never taken for ${1===l.length?"it":"them"}. Run: efficient-shell-ui-check --init ${l.map(e=>`--kind ${e}`).join(" ")}`);const d=t.kinds.filter(t=>!e.kinds.includes(t));d.length&&o.push(`the baseline still carries ${d.map(e=>`"${e}"`).join(", ")}, which "kinds" no longer names`);const u=new Set([...n.counts.keys(),...t.counts.keys(),...r.keys()]);for(const e of[...u].sort(D)){const{file:l,kind:d}=M(e);if(!c(d)||!a.has(d))continue;const u=n.counts.get(e)??0,h=r.get(e)??0,f=t.counts.get(e)??0;u>h+f?i.push(`${l}: ${d} ${u}, and its line allows ${h+f}${Qe(n,l,d)}. ${m[d].counts} is counted; use ${m[d].instead}.`):u<h?s.push(`${l}: ${d} ${u}, and "allow" in ui-kit.config.json says ${h}. ${0===u?"Delete the entry":`Lower its count to ${u}`}: an exception does not outlive what it excused.`):u<h+f&&o.push(`${l}: ${d} ${u}, and its line says ${h+f}`)}return{grown:i,shrunk:o,other:s,updateFixes:0===i.length&&0===s.length&&o.length>0}}(d,y,w),E=r.noBase?{problems:[],note:"",warnings:[]}:kt(t,f,y,d,w),I=d.kinds.filter(e=>y.kinds.includes(e)),j=`${pt} --update`,C=[...S.other,...S.grown,...S.shrunk.map(e=>`${e}. Run: ${j}`),...E.problems],A=0===C.length;if(r.json){const e=Ve(d);return t.out(JSON.stringify({tool:pt,version:t.version,ok:A,schema:d.schema,kinds:d.kinds,files:w.files.length,counts:N(w.counts),baseline:N(y.counts),allowed:N(e),kitDeps:w.kitDeps,shellPeers:w.shellPeers,chartDeps:w.chartDeps,failures:C,warnings:E.warnings},null,2)),A?0:1}t.out(`UI kit check (harness UI-24), efficient-shell ${t.version}\n`);const B=(e,n,i="")=>{if(0===n.length)return t.out(` ok ${e}`);t.err(` FAIL ${e}`);for(const e of n)t.err(` ${e}`);i&&t.err(` ${i}`)};t.out(` ok the reader reads its own fixtures (typescript ${f.version})`),t.out(` ok read ${gt(w.files.length,"file")}`),B(`${ht} and ${ft} describe this repository`,S.other),B("no file draws more of its own UI than its line allows",S.grown),B("every line is exact: a count that fell is a line to lower",S.shrunk,`Run: ${j}${S.updateFixes?"":" (after the failures above are fixed)"}`),E.note&&B(`the baseline is no higher than the base branch (${E.note})`,E.problems);for(const e of E.warnings)t.err(`::warning title=${pt}::${e}`);const U=new Set([...w.counts.keys()].map(e=>M(e).file));return t.out(` ok PROGRESS: ${U.size} of ${gt(w.files.length,"file")} still draw UI of their own: `+wt(w.counts,I)),t.out(""),A?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${gt(C.length,"problem")})`),A?0:1}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>function(e){for(const i of[n(process.cwd(),"package.json"),e])try{return t(i)("typescript")}catch{}throw new Error("typescript is not installed")}(import.meta.url),git:function(t){try{return e("git",t,{cwd:process.cwd(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:6e4,maxBuffer:67108864})}catch{return null}},version:"12.43.0"});
@@ -0,0 +1,2 @@
1
+ import{jsx as r}from"react/jsx-runtime";function e({size:e=18,...t}){/* @__PURE__ */
2
+ return r("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:/* @__PURE__ */r("path",{d:"M12 5.25L12.6 6.9L14.25 7.5L12.6 8.1L12 9.75L11.4 8.1L9.75 7.5L11.4 6.9ZM7.5 14.25L16.5 14.25M9.375 18.75L14.625 18.75"})})}export{e as IconAboveTextIcon};
@@ -1,7 +1,7 @@
1
- import{Segmented as e}from"./chunk-HNIIDDLJ.js";import{toDateKey as t,fromDateKey as n}from"./chunk-3HU63I3K.js";import{calendarNames as r,formatDate as a}from"./chunk-Y3JW2GW5.js";import{LoadingSpinner as o}from"./chunk-R2VKEMZH.js";import{useBrowserLayoutEffect as i}from"./chunk-D65T4H6J.js";import{useShellStrings as s,useShellLocale as l}from"./chunk-DEJIH3ZQ.js";import{useState as d,useRef as c,useId as u,useMemo as h}from"react";import{jsx as m,Fragment as f,jsxs as p}from"react/jsx-runtime";var b=864e5,g={day:32,week:16,month:4},y=44;function w(e){const t="string"==typeof e?n(e.slice(0,10)):null;return t?Math.round(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/b):null}function x(e){return new Date(e*b).toISOString().slice(0,10)}function v(e){return new Date(e*b)}function k(e){return((e+3)%7+7)%7}function N(e){return e-k(e)}function D(e){const t=v(e);return Math.round(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1)/b)}function M(e){const t=v(e);return Math.round(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1)/b)}function C(e){return Math.round(Date.UTC(v(e).getUTCFullYear(),0,1)/b)}function $(e){return Math.round(Date.UTC(v(e).getUTCFullYear()+1,0,1)/b)}var T={day:3,week:7,month:14},U={day:28,week:84,month:182};function j(e,t,n){return(e-t.startDay)*g[n]}function I(e,t,n){return j(e,t,n)+g[n]/2}function P(e,t,n,r){const a=[];let o=e.startDay;if(n(o)!==o){const n=Math.min(r(o),e.endDay);a.push({startDay:o,endDay:n,x:j(o,e,t),width:(n-o)*g[t]}),o=n}for(;o<e.endDay;){const n=Math.min(r(o),e.endDay);a.push({startDay:o,endDay:n,x:j(o,e,t),width:(n-o)*g[t]}),o=n}return a}function S(e,t,n,r){if(null===e&&null===t)return{kind:"none"};if(null===e)return{kind:"milestone",day:t,cx:j(t,n,r)+g[r]/2};const a=null===t?e:Math.min(e,t),o=null===t?e:Math.max(e,t);return{kind:"bar",startDay:a,endDay:o,x:j(a,n,r),width:(o-a+1)*g[r]}}function X(e){return"bar"===e.kind?{inX:e.x,outX:e.x+e.width}:"milestone"===e.kind?{inX:e.cx-9,outX:e.cx+9}:null}function z(e,t,n,r,a=44,o=10){let i;if(n-e>=2*o){const a=e+o;i=[[e,t],[a,t],[a,r],[n,r]]}else{const s=t+(r>=t?1:-1)*a/2,l=e+o,d=n-o;i=[[e,t],[l,t],[l,s],[d,s],[d,r],[n,r]]}return i.filter((e,t)=>0===t||e[0]!==i[t-1][0]||e[1]!==i[t-1][1])}function R(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e} ${t}`).join(" ")}function Y(e,t,n=5){return`${e},${t} ${e-n},${t-n} ${e-n},${t+n}`}function H(e,t,n,r){if("move"===e)return{start:null===t?null:t+r,end:null===n?null:n+r};if("start"===e){if(null===t)return{start:t,end:n};const e=t+r;return{start:null===n?e:Math.min(e,n),end:n}}if(null===n)return{start:t,end:n};const a=n+r;return{start:t,end:null===t?a:Math.max(a,t)}}var F=24;function L({rows:n,groups:b=[],dependencies:j=[],scale:L,onScaleChange:W,onRowClick:A,onRowChange:K,readOnly:Q=!1,today:E,isLoading:J=!1,emptyState:O,labelHeader:Z,labelWidth:G=240,className:V=""}){const q=s().gantt,B=l(),_=r(B),ee=!!K&&!Q,[te,ne]=d(null),re=c(!1),ae=c(null),oe=u(),ie=w(E)??w(t(/* @__PURE__ */new Date)),se=h(()=>{const e=/* @__PURE__ */new Map;for(const t of n){const n=w(t.start),r=w(t.end);e.set(t.id,te&&te.id===t.id?H(te.mode,te.start,te.end,te.delta):{start:n,end:r})}return e},[n,te]),le=h(()=>{const e=[ie];for(const t of n){const n=w(t.start),r=w(t.end);null!==n&&e.push(n),null!==r&&e.push(r)}return function(e,t){const n=e.filter(e=>Number.isFinite(e)),r=n.length?Math.min(...n):0,a=n.length?Math.max(...n):0;let o=r-T[t],i=a+1+T[t];const s=U[t]-(i-o);return s>0&&(o-=Math.floor(s/2),i+=Math.ceil(s/2)),"week"===t?(o=N(o),i=N(i-1)+7):"month"===t&&(o=D(o),i=M(i-1)),{startDay:o,endDay:i}}(e,L)},[n,L,ie]),de=h(()=>function(e,t){return"day"===t?{major:P(e,t,D,M),minor:P(e,t,e=>e,e=>e+1)}:"week"===t?{major:P(e,t,D,M),minor:P(e,t,N,e=>N(e)+7)}:{major:P(e,t,C,$),minor:P(e,t,D,M)}}(le,L),[le,L]),ce=function(e,t){return(e.endDay-e.startDay)*g[t]}(le,L),ue=h(()=>function(e,t){const n=new Set(t.map(e=>e.id)),r=/* @__PURE__ */new Map,a=[];for(const t of e)if(null!=t.groupId&&n.has(t.groupId)){const e=r.get(t.groupId)??[];e.push(t),r.set(t.groupId,e)}else a.push(t);const o=a.map(e=>({kind:"row",row:e}));for(const e of t){o.push({kind:"group",group:e});for(const t of r.get(e.id)??[])o.push({kind:"row",row:t})}return o}(n,b),[n,b]),he=h(()=>{const e=/* @__PURE__ */new Map;return ue.forEach((t,n)=>{if("row"!==t.kind)return;const r=se.get(t.row.id);e.set(t.row.id,{shape:S(r.start,r.end,le,L),line:n})}),e},[ue,se,le,L]),me=h(()=>{const e=[];for(const t of j){const n=he.get(t.from),r=he.get(t.to);if(!n||!r)continue;const a=X(n.shape),o=X(r.shape);if(!a||!o)continue;const i=n.line*y+22,s=r.line*y+22,l=z(a.outX,i,o.inX,s);e.push({key:`${t.from}>${t.to}`,d:R(l),head:Y(o.inX,s)})}return e},[j,he]),fe=!J&&(n.length>0||b.length>0);i(()=>{const e=ae.current;if(!e)return;const t=e.clientWidth-G;e.scrollLeft=Math.max(0,I(ie,le,L)-t/4)},[L,fe]);if(J)/* @__PURE__ */return m(o,{size:"sm",padding:"p-4",label:q.loading});if(!fe)/* @__PURE__ */return m(f,{children:O??/* @__PURE__ */m("div",{className:"text-sm text-ink-faint p-4",children:q.empty})});const pe=(e,t,n)=>{K?.(e.id,{start:null===t?null:x(t),end:null===n?null:x(n)})},be=(e,t,n)=>{if(re.current=!1,ee&&0===e.button){e.stopPropagation();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}ne({id:t.id,mode:n,originX:e.clientX,start:w(t.start),end:w(t.end),delta:0})}},ge=e=>{if(!te)return;const t=function(e,t){const n=Math.round(e/g[t]);return 0===n?0:n}(e.clientX-te.originX,L);t!==te.delta&&ne({...te,delta:t})},ye=e=>{if(te){if(0!==te.delta){const t=H(te.mode,te.start,te.end,te.delta);re.current=!0,pe(e,t.start,t.end)}ne(null)}},we=(e,t)=>{if("Enter"===e.key||" "===e.key)return e.preventDefault(),void A?.(t);if(!ee||"ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();const n="ArrowRight"===e.key?1:-1,r=H(e.shiftKey?"end":"move",w(t.start),w(t.end),n);pe(t,r.start,r.end)},xe=e=>{re.current?re.current=!1:A?.(e)},ve=e=>a(x(e),{locale:B}),ke=(e,t)=>{const n=v(e.startDay),r=n.getUTCFullYear(),a=n.getUTCMonth();return"major"===t?"month"===L?String(r):"week"===L?_.shortMonthYear(r,a):_.monthYear(r,a):"month"===L?_.monthsShort[a]:String(n.getUTCDate())},Ne=ue.length*y,De=I(ie,le,L),Me=De>=0&&De<=ce,Ce=de.minor.find(e=>e.startDay<=ie&&ie<e.endDay),$e=Ce?De-Ce.x:0,Te=!!Ce&&$e<=Ce.width/2;/* @__PURE__ */
1
+ import{toDateKey as e,fromDateKey as t}from"./chunk-3HU63I3K.js";import{Segmented as n}from"./chunk-HNIIDDLJ.js";import{calendarNames as r,formatDate as a}from"./chunk-Y3JW2GW5.js";import{LoadingSpinner as o}from"./chunk-R2VKEMZH.js";import{useBrowserLayoutEffect as i}from"./chunk-D65T4H6J.js";import{useShellStrings as s,useShellLocale as l}from"./chunk-DEJIH3ZQ.js";import{useState as d,useRef as c,useId as u,useMemo as h}from"react";import{jsx as m,Fragment as f,jsxs as p}from"react/jsx-runtime";var b=864e5,g={day:32,week:16,month:4},y=44;function w(e){const n="string"==typeof e?t(e.slice(0,10)):null;return n?Math.round(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate())/b):null}function x(e){return new Date(e*b).toISOString().slice(0,10)}function v(e){return new Date(e*b)}function k(e){return((e+3)%7+7)%7}function N(e){return e-k(e)}function D(e){const t=v(e);return Math.round(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1)/b)}function M(e){const t=v(e);return Math.round(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1)/b)}function C(e){return Math.round(Date.UTC(v(e).getUTCFullYear(),0,1)/b)}function $(e){return Math.round(Date.UTC(v(e).getUTCFullYear()+1,0,1)/b)}var T={day:3,week:7,month:14},U={day:28,week:84,month:182};function j(e,t,n){return(e-t.startDay)*g[n]}function I(e,t,n){return j(e,t,n)+g[n]/2}function P(e,t,n,r){const a=[];let o=e.startDay;if(n(o)!==o){const n=Math.min(r(o),e.endDay);a.push({startDay:o,endDay:n,x:j(o,e,t),width:(n-o)*g[t]}),o=n}for(;o<e.endDay;){const n=Math.min(r(o),e.endDay);a.push({startDay:o,endDay:n,x:j(o,e,t),width:(n-o)*g[t]}),o=n}return a}function S(e,t,n,r){if(null===e&&null===t)return{kind:"none"};if(null===e)return{kind:"milestone",day:t,cx:j(t,n,r)+g[r]/2};const a=null===t?e:Math.min(e,t),o=null===t?e:Math.max(e,t);return{kind:"bar",startDay:a,endDay:o,x:j(a,n,r),width:(o-a+1)*g[r]}}function X(e){return"bar"===e.kind?{inX:e.x,outX:e.x+e.width}:"milestone"===e.kind?{inX:e.cx-9,outX:e.cx+9}:null}function z(e,t,n,r,a=44,o=10){let i;if(n-e>=2*o){const a=e+o;i=[[e,t],[a,t],[a,r],[n,r]]}else{const s=t+(r>=t?1:-1)*a/2,l=e+o,d=n-o;i=[[e,t],[l,t],[l,s],[d,s],[d,r],[n,r]]}return i.filter((e,t)=>0===t||e[0]!==i[t-1][0]||e[1]!==i[t-1][1])}function R(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e} ${t}`).join(" ")}function Y(e,t,n=5){return`${e},${t} ${e-n},${t-n} ${e-n},${t+n}`}function H(e,t,n,r){if("move"===e)return{start:null===t?null:t+r,end:null===n?null:n+r};if("start"===e){if(null===t)return{start:t,end:n};const e=t+r;return{start:null===n?e:Math.min(e,n),end:n}}if(null===n)return{start:t,end:n};const a=n+r;return{start:t,end:null===t?a:Math.max(a,t)}}var F=24;function L({rows:t,groups:b=[],dependencies:j=[],scale:L,onScaleChange:W,onRowClick:A,onRowChange:K,readOnly:Q=!1,today:E,isLoading:J=!1,emptyState:O,labelHeader:Z,labelWidth:G=240,className:V=""}){const q=s().gantt,B=l(),_=r(B),ee=!!K&&!Q,[te,ne]=d(null),re=c(!1),ae=c(null),oe=u(),ie=w(E)??w(e(/* @__PURE__ */new Date)),se=h(()=>{const e=/* @__PURE__ */new Map;for(const n of t){const t=w(n.start),r=w(n.end);e.set(n.id,te&&te.id===n.id?H(te.mode,te.start,te.end,te.delta):{start:t,end:r})}return e},[t,te]),le=h(()=>{const e=[ie];for(const n of t){const t=w(n.start),r=w(n.end);null!==t&&e.push(t),null!==r&&e.push(r)}return function(e,t){const n=e.filter(e=>Number.isFinite(e)),r=n.length?Math.min(...n):0,a=n.length?Math.max(...n):0;let o=r-T[t],i=a+1+T[t];const s=U[t]-(i-o);return s>0&&(o-=Math.floor(s/2),i+=Math.ceil(s/2)),"week"===t?(o=N(o),i=N(i-1)+7):"month"===t&&(o=D(o),i=M(i-1)),{startDay:o,endDay:i}}(e,L)},[t,L,ie]),de=h(()=>function(e,t){return"day"===t?{major:P(e,t,D,M),minor:P(e,t,e=>e,e=>e+1)}:"week"===t?{major:P(e,t,D,M),minor:P(e,t,N,e=>N(e)+7)}:{major:P(e,t,C,$),minor:P(e,t,D,M)}}(le,L),[le,L]),ce=function(e,t){return(e.endDay-e.startDay)*g[t]}(le,L),ue=h(()=>function(e,t){const n=new Set(t.map(e=>e.id)),r=/* @__PURE__ */new Map,a=[];for(const t of e)if(null!=t.groupId&&n.has(t.groupId)){const e=r.get(t.groupId)??[];e.push(t),r.set(t.groupId,e)}else a.push(t);const o=a.map(e=>({kind:"row",row:e}));for(const e of t){o.push({kind:"group",group:e});for(const t of r.get(e.id)??[])o.push({kind:"row",row:t})}return o}(t,b),[t,b]),he=h(()=>{const e=/* @__PURE__ */new Map;return ue.forEach((t,n)=>{if("row"!==t.kind)return;const r=se.get(t.row.id);e.set(t.row.id,{shape:S(r.start,r.end,le,L),line:n})}),e},[ue,se,le,L]),me=h(()=>{const e=[];for(const t of j){const n=he.get(t.from),r=he.get(t.to);if(!n||!r)continue;const a=X(n.shape),o=X(r.shape);if(!a||!o)continue;const i=n.line*y+22,s=r.line*y+22,l=z(a.outX,i,o.inX,s);e.push({key:`${t.from}>${t.to}`,d:R(l),head:Y(o.inX,s)})}return e},[j,he]),fe=!J&&(t.length>0||b.length>0);i(()=>{const e=ae.current;if(!e)return;const t=e.clientWidth-G;e.scrollLeft=Math.max(0,I(ie,le,L)-t/4)},[L,fe]);if(J)/* @__PURE__ */return m(o,{size:"sm",padding:"p-4",label:q.loading});if(!fe)/* @__PURE__ */return m(f,{children:O??/* @__PURE__ */m("div",{className:"text-sm text-ink-faint p-4",children:q.empty})});const pe=(e,t,n)=>{K?.(e.id,{start:null===t?null:x(t),end:null===n?null:x(n)})},be=(e,t,n)=>{if(re.current=!1,ee&&0===e.button){e.stopPropagation();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}ne({id:t.id,mode:n,originX:e.clientX,start:w(t.start),end:w(t.end),delta:0})}},ge=e=>{if(!te)return;const t=function(e,t){const n=Math.round(e/g[t]);return 0===n?0:n}(e.clientX-te.originX,L);t!==te.delta&&ne({...te,delta:t})},ye=e=>{if(te){if(0!==te.delta){const t=H(te.mode,te.start,te.end,te.delta);re.current=!0,pe(e,t.start,t.end)}ne(null)}},we=(e,t)=>{if("Enter"===e.key||" "===e.key)return e.preventDefault(),void A?.(t);if(!ee||"ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();const n="ArrowRight"===e.key?1:-1,r=H(e.shiftKey?"end":"move",w(t.start),w(t.end),n);pe(t,r.start,r.end)},xe=e=>{re.current?re.current=!1:A?.(e)},ve=e=>a(x(e),{locale:B}),ke=(e,t)=>{const n=v(e.startDay),r=n.getUTCFullYear(),a=n.getUTCMonth();return"major"===t?"month"===L?String(r):"week"===L?_.shortMonthYear(r,a):_.monthYear(r,a):"month"===L?_.monthsShort[a]:String(n.getUTCDate())},Ne=ue.length*y,De=I(ie,le,L),Me=De>=0&&De<=ce,Ce=de.minor.find(e=>e.startDay<=ie&&ie<e.endDay),$e=Ce?De-Ce.x:0,Te=!!Ce&&$e<=Ce.width/2;/* @__PURE__ */
2
2
  return p("div",{className:`flex min-h-0 flex-col ${V}`,children:[
3
3
  /* @__PURE__ */p("div",{className:"flex items-center justify-end gap-2 pb-2",children:[
4
- /* @__PURE__ */m("button",{type:"button",onClick:()=>{const e=ae.current;if(!e)return;const t=e.clientWidth-G;e.scrollTo?.({left:Math.max(0,I(ie,le,L)-t/4),behavior:"smooth"})},className:"min-h-8 rounded-(--radius-control) border border-line bg-surface px-3 text-xs font-medium text-ink hover:bg-row-hover",children:q.today}),W&&/* @__PURE__ */m(e,{size:"sm",label:q.scale,value:L,onChange:W,options:[{value:"day",label:q.day},{value:"week",label:q.week},{value:"month",label:q.month}]})]}),
4
+ /* @__PURE__ */m("button",{type:"button",onClick:()=>{const e=ae.current;if(!e)return;const t=e.clientWidth-G;e.scrollTo?.({left:Math.max(0,I(ie,le,L)-t/4),behavior:"smooth"})},className:"min-h-8 rounded-(--radius-control) border border-line bg-surface px-3 text-xs font-medium text-ink hover:bg-row-hover",children:q.today}),W&&/* @__PURE__ */m(n,{size:"sm",label:q.scale,value:L,onChange:W,options:[{value:"day",label:q.day},{value:"week",label:q.week},{value:"month",label:q.month}]})]}),
5
5
  /* @__PURE__ */m("div",{ref:ae,"data-gantt-scroller":"",className:"relative min-h-0 flex-1 overflow-auto grid-scroll rounded-(--radius-card) border border-line bg-surface",children:/* @__PURE__ */p("div",{className:"relative",style:{width:G+ce,minHeight:48+Ne},children:[
6
6
  /* @__PURE__ */p("div",{className:"sticky top-0 z-20 flex border-b border-line bg-surface",style:{height:48},children:[
7
7
  /* @__PURE__ */m("div",{className:"sticky left-0 z-10 flex shrink-0 items-end border-r border-line bg-surface px-3 pb-1 text-xs font-medium text-ink-muted",style:{width:G},children:Z??q.task}),
@@ -1,20 +1,20 @@
1
- import{Tree as e,TreeRow as n,TreeGroup as l}from"./chunk-FCWBO7I3.js";import{ImageLightbox as r}from"./chunk-HWJQLLJA.js";import{MarqueeBox as a}from"./chunk-IC72MGON.js";import{EmptyState as i}from"./chunk-3TCGXYUC.js";import{DescriptionList as t}from"./chunk-SACUSHVN.js";import{Drawer as o}from"./chunk-3RX5KCUH.js";import{Breadcrumbs as d}from"./chunk-YM7AWNMY.js";import{ROOT_KEY as s,mediaLibraryMenu as c}from"./chunk-3YCU6V3U.js";import{useMediaMoveItems as u}from"./chunk-JWUNK2PW.js";import{RenameField as m}from"./chunk-QIPO4EVJ.js";import{NativeSelect as p}from"./chunk-KITSIQCV.js";import{MediaUploadGrid as h}from"./chunk-BNPJHOAC.js";import{MediaUsedInList as f}from"./chunk-ZDDMFFQK.js";import{useGridSelection as g}from"./chunk-VLKDWKVR.js";import{useMarquee as v}from"./chunk-OLFYNMTD.js";import{Segmented as k}from"./chunk-HNIIDDLJ.js";import{copyToClipboard as y}from"./chunk-HTHNDX32.js";import{Checkbox_default as b}from"./chunk-CGZBDI6C.js";import{useContextMenu as w,ContextMenu as C}from"./chunk-QMBMK6PP.js";import{Banner as x}from"./chunk-ID35S5Y6.js";import{Input_default as I}from"./chunk-PT4GMPUB.js";import{DropdownMenu as N}from"./chunk-3DSGJIC7.js";import{IconButton_default as D}from"./chunk-SV5RRBVA.js";import{useFileIntake as S,FileIntakeAlert as j}from"./chunk-ITEOA45V.js";import{setModalDragAside as T,modalIdHolding as z}from"./chunk-EIFNESXS.js";import{ColoredBadge as F}from"./chunk-ZGIAMYTI.js";import{Button_default as L}from"./chunk-EVYD6UFQ.js";import{Icon as O}from"./chunk-ISVODSRP.js";import{Tooltip as E}from"./chunk-SOZCWT6I.js";import{buttonClasses as P}from"./chunk-UQYNPYF4.js";import{usePlotWidth as A}from"./chunk-MAFUXCPZ.js";import{useShellStrings as M}from"./chunk-DEJIH3ZQ.js";import{useRef as U,useMemo as R,useCallback as K,useState as B,useEffect as V}from"react";import{jsxs as J,Fragment as H,jsx as W}from"react/jsx-runtime";var Y="application/x-efficient-media-files",Q="application/x-efficient-media-folder",G="application/x-efficient-media-file";function $(e){if(!e||!Array.from(e.types).includes(G))return null;try{const n=JSON.parse(e.getData(G));if(n&&"string"==typeof n.id&&"string"==typeof n.url&&"string"==typeof n.name&&("image"===n.kind||"video"===n.kind))return{id:n.id,url:n.url,kind:n.kind,name:n.name}}catch{}return null}var Z={type:"all",use:"any",sort:"newest"},X={lock:/* @__PURE__ */W(O,{name:"lock","aria-hidden":"true",className:"h-4 w-4"}),folder:/* @__PURE__ */W(O,{name:"folder","aria-hidden":"true",className:"h-4 w-4"}),folderOpen:/* @__PURE__ */W(O,{name:"folder-open","aria-hidden":"true",className:"h-4 w-4"}),folderPlus:/* @__PURE__ */W(O,{name:"folder-plus","aria-hidden":"true",className:"h-4 w-4"}),trash:/* @__PURE__ */W(O,{name:"trash","aria-hidden":"true",className:"h-4 w-4"}),upload:/* @__PURE__ */W(O,{name:"upload","aria-hidden":"true",className:"h-4 w-4"}),search:/* @__PURE__ */W(O,{name:"search","aria-hidden":"true",className:"h-4 w-4"}),grid:/* @__PURE__ */W(O,{name:"grid","aria-hidden":"true",className:"h-4 w-4"}),list:/* @__PURE__ */W(O,{name:"list","aria-hidden":"true",className:"h-4 w-4"}),more:/* @__PURE__ */W(O,{name:"more","aria-hidden":"true",className:"h-4 w-4"}),copy:/* @__PURE__ */W(O,{name:"copy","aria-hidden":"true",className:"h-4 w-4"}),edit:/* @__PURE__ */W(O,{name:"edit","aria-hidden":"true",className:"h-4 w-4"}),swap:/* @__PURE__ */W(O,{name:"swap","aria-hidden":"true",className:"h-4 w-4"}),crop:/* @__PURE__ */W(O,{name:"crop","aria-hidden":"true",className:"h-4 w-4"}),external:/* @__PURE__ */W(O,{name:"external","aria-hidden":"true",className:"h-4 w-4"}),undo:/* @__PURE__ */W(O,{name:"undo","aria-hidden":"true",className:"h-4 w-4"})},q={link:/* @__PURE__ */W(O,{name:"link","aria-hidden":"true",className:"h-3 w-3"}),email:/* @__PURE__ */W(O,{name:"email","aria-hidden":"true",className:"h-3 w-3"}),lock:/* @__PURE__ */W(O,{name:"lock","aria-hidden":"true",className:"h-3 w-3"}),clock:/* @__PURE__ */W(O,{name:"clock","aria-hidden":"true",className:"h-3 w-3"})};function _(O){const{mode:$="manage",layout:_="auto",location:ee,onLocationChange:ne,folders:le,products:re,allFilesCount:ae,trashCount:ie,files:te,query:oe,onQueryChange:de,filters:se=Z,onFiltersChange:ce,extraFilters:ue,view:me="grid",onViewChange:pe,selectedIds:he,onSelectionChange:fe,usedIn:ge,denied:ve={},accept:ke="image/*,video/*",maxSizeBytes:ye,busy:be,progress:we,onUpload:Ce,onNewFolder:xe,onRename:Ie,onMove:Ne,onTrash:De,onDeleteFolder:Se,onRestore:je,onDeleteForever:Te,onEmptyTrash:ze,onReplace:Fe,onCropEdit:Le,onOpenInDesign:Oe,onChoose:Ee,onCancel:Pe,pickNote:Ae,onDragOut:Me,className:Ue=""}=O,Re=M().mediaLibrary,Ke=M().media,Be="pick"===$,Ve=!Be,Je=U(null),He=A(Je,"phone"===_?343:1200),We="phone"===_||"auto"===_&&He<640,Ye=R(()=>function(e=[]){const n=/* @__PURE__ */new Map,l=(e,r)=>{for(const a of e){const e=[...r,a];n.set(a.id,{node:a,path:e}),a.children&&l(a.children,e)}};return l(e,[]),n}(re),[re]),Qe=R(()=>new Map(le.map(e=>[e.id,e])),[le]),Ge=R(()=>{const e=/* @__PURE__ */new Map;for(const n of le){const l=n.parentId&&Qe.has(n.parentId)?n.parentId:null;e.set(l,[...e.get(l)??[],n])}return e},[le,Qe]),$e=K(e=>{const n=[];for(let l=e?Qe.get(e):void 0;l&&(n.unshift(l),!(n.length>le.length));l=l.parentId?Qe.get(l.parentId):void 0);return n},[Qe,le.length]),Ze=K((e,n)=>$e(e).some(e=>e.id===n),[$e]),[Xe,qe]=B(()=>/* @__PURE__ */new Set(["@files"])),_e=e=>qe(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l}),en=K(e=>{qe(n=>e.every(e=>n.has(e))?n:/* @__PURE__ */new Set([...n,...e]))},[]),nn="files"===(ln=ee).place?`files:${ln.folderId??""}`:"products"===ln.place?`products:${ln.nodeId??""}`:"trash";var ln;V(()=>{if("files"===ee.place)en(["@files",...$e(ee.folderId).slice(0,-1).map(e=>e.id)]);else if("products"===ee.place){const e=ee.nodeId?Ye.get(ee.nodeId)?.path??[]:[];en(["@products",...e.slice(0,-1).map(e=>`p:${e.id}`)])}},[nn]);const rn="products"===ee.place,an="trash"===ee.place,tn="files"===ee.place,on=tn?ee.folderId:null,dn=rn&&ee.nodeId?Ye.get(ee.nodeId)?.path[0]:void 0,sn=e=>e?.sharedFrom?`${Re.readOnly} ${Re.editedAtHq(e.sharedFrom)}`:Re.readOnly,cn=R(()=>te.map(e=>e.id),[te]),un=R(()=>new Map(te.map(e=>[e.id,e])),[te]),mn=g(cn),pn=R(()=>cn.filter(e=>mn.selected.has(e)),[cn,mn.selected]),hn=1===pn.length?un.get(pn[0]):void 0,fn=U(!0);V(()=>{fn.current?fn.current=!1:mn.clear()},[nn]);const gn=he?.join("\0");V(()=>{he&&mn.setSelection(he)},[gn]);const vn=U(gn??""),kn=pn.join("\0");V(()=>{vn.current!==kn&&(vn.current=kn,fe?.(pn))},[kn]);const yn=(e,n={})=>{Be?mn.select(e):mn.select(e,{ctrl:!(!n.ctrlKey&&!n.metaKey),shift:!!n.shiftKey})},[bn,wn]=B(null),Cn=e=>{const n=bn;if(wn(null),!n||null==e)return;e!==("folder"===n.kind?Qe.get(n.id)?.name:un.get(n.id)?.name)&&Ie?.(n,e)},xn=async e=>{if(!xe)return;const n=await xe(e);en(["@files",...e?[e]:[]]),"string"==typeof n&&wn({kind:"folder",id:n})},In=K(e=>{const n=[],l=n=>{if("files"===e.kind)return n===on&&tn?Re.alreadyHere:void 0;const l=Qe.get(e.id);return n===e.id||n&&Ze(n,e.id)?Re.notIntoItself:(l?.parentId??null)===n?Re.folderAlreadyHere:void 0};n.push({key:s,label:Re.allFiles,disabledReason:l(null)});const r=(e,a)=>{for(const i of Ge.get(e)??[])n.push({key:i.id,label:i.name,depth:a,disabledReason:l(i.id)}),r(i.id,a+1)};return r(null,1),n},[Ge,Qe,tn,Ze,on,Re]),Nn=K(e=>{const n=new Set(e.map(e=>un.get(e)?.kind??"image"));return 1===n.size?[...n][0]:"file"},[un]),[Dn,Sn]=B(null),jn={words:Re,media:Ke,denied:ve,moveTargets:In,kindOf:Nn,urlOf:e=>un.get(e)?.url,newSubfolder:xe&&Ve?e=>{xn(e)}:void 0,rename:Ie&&Ve?e=>{"file"!==e.kind||mn.isSelected(e.id)||mn.select(e.id),wn(e)}:void 0,move:Ne&&Ve?Ne:void 0,trash:De&&Ve?De:void 0,deleteFolder:Se&&Ve?Se:void 0,folderNotEmpty:e=>!!Qe.get(e)?.notEmpty,replace:Fe&&Ve?Fe:void 0,copyUrl:e=>{const n=un.get(e)?.url;n&&y(Re.urlLabel,n)},openInDesign:Oe,restore:je,deleteForever:Te},Tn=e=>c(e,jn),zn=w(),Fn=(e,n)=>{Be||(mn.isSelected(e)||mn.select(e),zn.open(n,(e=>{const n=mn.isSelected(e)?pn:[e];return rn?{kind:"render",id:e}:an?{kind:"trashed",ids:n}:{kind:"files",ids:n}})(e)))},[Ln,On]=B(null),[En,Pn]=B(null),[An,Mn]=B(null);V(()=>{if(!En&&!Ln)return;const e=()=>{Pn(null),On(null)};return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[En,Ln]);const Un=(e,n)=>Array.from(e.dataTransfer?.types??[]).includes(n),Rn=(e,n)=>!(!Ne||ve.move||Be)&&(!!Un(e,Y)||!(!Un(e,Q)||!An)&&(n!==An&&!(n&&Ze(n,An)))),Kn=(e,n)=>({onDragEnter:l=>{Rn(l,n)&&(l.preventDefault(),On(e))},onDragOver:l=>{Rn(l,n)&&(l.preventDefault(),l.dataTransfer.dropEffect="move",Ln!==e&&On(e))},onDragLeave:n=>{const l=n.relatedTarget;l&&n.currentTarget.contains(l)||On(n=>n===e?null:n)},onDrop:e=>{if(Rn(e,n))if(e.preventDefault(),On(null),Un(e,Y)){let l;try{l=JSON.parse(e.dataTransfer.getData(Y))}catch{l=null}Array.isArray(l)&&l.length&&Ne({kind:"files",ids:l.map(String)},n)}else An&&(Ne({kind:"folder",id:An},n),Mn(null))}}),Bn=e=>{const n=e=>Un(e,Y)||Un(e,Q)||Un(e,"Files");return{onDragEnter:l=>{n(l)&&Pn(e)},onDragOver:l=>{n(l)&&En!==e&&Pn(e)},onDragLeave:n=>{const l=n.relatedTarget;l&&n.currentTarget.contains(l)||Pn(n=>n===e?null:n)}}},Vn=(e,n,l)=>/* @__PURE__ */W(E,{side:"right",content:En===e?Re.noDropProducts:sn(l),open:En===e||!En&&void 0,children:/* @__PURE__ */W("span",{children:n})}),Jn=e=>({onContextMenu:n=>{zn.open(n,e)}}),Hn=(e,r,a)=>e.map(e=>{const i=`p:${e.id}`,t=a??e,o=Xe.has(i),d=e.children?.length?e.children:null;/* @__PURE__ */
1
+ import{Tree as e,TreeRow as n,TreeGroup as l}from"./chunk-FCWBO7I3.js";import{ImageLightbox as r}from"./chunk-HWJQLLJA.js";import{MarqueeBox as a}from"./chunk-IC72MGON.js";import{EmptyState as i}from"./chunk-3TCGXYUC.js";import{DescriptionList as t}from"./chunk-SACUSHVN.js";import{Drawer as o}from"./chunk-3RX5KCUH.js";import{Breadcrumbs as d}from"./chunk-YM7AWNMY.js";import{useGridSelection as s}from"./chunk-VLKDWKVR.js";import{useMarquee as c}from"./chunk-OLFYNMTD.js";import{ROOT_KEY as u,mediaLibraryMenu as m}from"./chunk-3YCU6V3U.js";import{useMediaMoveItems as p}from"./chunk-JWUNK2PW.js";import{RenameField as h}from"./chunk-QIPO4EVJ.js";import{NativeSelect as f}from"./chunk-KITSIQCV.js";import{MediaUploadGrid as g}from"./chunk-BNPJHOAC.js";import{MediaUsedInList as v}from"./chunk-ZDDMFFQK.js";import{Segmented as k}from"./chunk-HNIIDDLJ.js";import{copyToClipboard as y}from"./chunk-HTHNDX32.js";import{Checkbox_default as b}from"./chunk-CGZBDI6C.js";import{useContextMenu as w,ContextMenu as C}from"./chunk-QMBMK6PP.js";import{Banner as x}from"./chunk-ID35S5Y6.js";import{Input_default as I}from"./chunk-PT4GMPUB.js";import{DropdownMenu as N}from"./chunk-3DSGJIC7.js";import{IconButton_default as D}from"./chunk-SV5RRBVA.js";import{useFileIntake as S,FileIntakeAlert as j}from"./chunk-ITEOA45V.js";import{setModalDragAside as T,modalIdHolding as z}from"./chunk-EIFNESXS.js";import{ColoredBadge as F}from"./chunk-ZGIAMYTI.js";import{Button_default as L}from"./chunk-EVYD6UFQ.js";import{Icon as O}from"./chunk-ISVODSRP.js";import{Tooltip as E}from"./chunk-SOZCWT6I.js";import{buttonClasses as P}from"./chunk-UQYNPYF4.js";import{usePlotWidth as A}from"./chunk-MAFUXCPZ.js";import{useShellStrings as M}from"./chunk-DEJIH3ZQ.js";import{useRef as U,useMemo as R,useCallback as K,useState as B,useEffect as V}from"react";import{jsxs as J,Fragment as H,jsx as W}from"react/jsx-runtime";var Y="application/x-efficient-media-files",Q="application/x-efficient-media-folder",G="application/x-efficient-media-file";function $(e){if(!e||!Array.from(e.types).includes(G))return null;try{const n=JSON.parse(e.getData(G));if(n&&"string"==typeof n.id&&"string"==typeof n.url&&"string"==typeof n.name&&("image"===n.kind||"video"===n.kind))return{id:n.id,url:n.url,kind:n.kind,name:n.name}}catch{}return null}var Z={type:"all",use:"any",sort:"newest"},X={lock:/* @__PURE__ */W(O,{name:"lock","aria-hidden":"true",className:"h-4 w-4"}),folder:/* @__PURE__ */W(O,{name:"folder","aria-hidden":"true",className:"h-4 w-4"}),folderOpen:/* @__PURE__ */W(O,{name:"folder-open","aria-hidden":"true",className:"h-4 w-4"}),folderPlus:/* @__PURE__ */W(O,{name:"folder-plus","aria-hidden":"true",className:"h-4 w-4"}),trash:/* @__PURE__ */W(O,{name:"trash","aria-hidden":"true",className:"h-4 w-4"}),upload:/* @__PURE__ */W(O,{name:"upload","aria-hidden":"true",className:"h-4 w-4"}),search:/* @__PURE__ */W(O,{name:"search","aria-hidden":"true",className:"h-4 w-4"}),grid:/* @__PURE__ */W(O,{name:"grid","aria-hidden":"true",className:"h-4 w-4"}),list:/* @__PURE__ */W(O,{name:"list","aria-hidden":"true",className:"h-4 w-4"}),more:/* @__PURE__ */W(O,{name:"more","aria-hidden":"true",className:"h-4 w-4"}),copy:/* @__PURE__ */W(O,{name:"copy","aria-hidden":"true",className:"h-4 w-4"}),edit:/* @__PURE__ */W(O,{name:"edit","aria-hidden":"true",className:"h-4 w-4"}),swap:/* @__PURE__ */W(O,{name:"swap","aria-hidden":"true",className:"h-4 w-4"}),crop:/* @__PURE__ */W(O,{name:"crop","aria-hidden":"true",className:"h-4 w-4"}),external:/* @__PURE__ */W(O,{name:"external","aria-hidden":"true",className:"h-4 w-4"}),undo:/* @__PURE__ */W(O,{name:"undo","aria-hidden":"true",className:"h-4 w-4"})},q={link:/* @__PURE__ */W(O,{name:"link","aria-hidden":"true",className:"h-3 w-3"}),email:/* @__PURE__ */W(O,{name:"email","aria-hidden":"true",className:"h-3 w-3"}),lock:/* @__PURE__ */W(O,{name:"lock","aria-hidden":"true",className:"h-3 w-3"}),clock:/* @__PURE__ */W(O,{name:"clock","aria-hidden":"true",className:"h-3 w-3"})};function _(O){const{mode:$="manage",layout:_="auto",location:ee,onLocationChange:ne,folders:le,products:re,allFilesCount:ae,trashCount:ie,files:te,query:oe,onQueryChange:de,filters:se=Z,onFiltersChange:ce,extraFilters:ue,view:me="grid",onViewChange:pe,selectedIds:he,onSelectionChange:fe,usedIn:ge,denied:ve={},accept:ke="image/*,video/*",maxSizeBytes:ye,busy:be,progress:we,onUpload:Ce,onNewFolder:xe,onRename:Ie,onMove:Ne,onTrash:De,onDeleteFolder:Se,onRestore:je,onDeleteForever:Te,onEmptyTrash:ze,onReplace:Fe,onCropEdit:Le,onOpenInDesign:Oe,onChoose:Ee,onCancel:Pe,pickNote:Ae,onDragOut:Me,className:Ue=""}=O,Re=M().mediaLibrary,Ke=M().media,Be="pick"===$,Ve=!Be,Je=U(null),He=A(Je,"phone"===_?343:1200),We="phone"===_||"auto"===_&&He<640,Ye=R(()=>function(e=[]){const n=/* @__PURE__ */new Map,l=(e,r)=>{for(const a of e){const e=[...r,a];n.set(a.id,{node:a,path:e}),a.children&&l(a.children,e)}};return l(e,[]),n}(re),[re]),Qe=R(()=>new Map(le.map(e=>[e.id,e])),[le]),Ge=R(()=>{const e=/* @__PURE__ */new Map;for(const n of le){const l=n.parentId&&Qe.has(n.parentId)?n.parentId:null;e.set(l,[...e.get(l)??[],n])}return e},[le,Qe]),$e=K(e=>{const n=[];for(let l=e?Qe.get(e):void 0;l&&(n.unshift(l),!(n.length>le.length));l=l.parentId?Qe.get(l.parentId):void 0);return n},[Qe,le.length]),Ze=K((e,n)=>$e(e).some(e=>e.id===n),[$e]),[Xe,qe]=B(()=>/* @__PURE__ */new Set(["@files"])),_e=e=>qe(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l}),en=K(e=>{qe(n=>e.every(e=>n.has(e))?n:/* @__PURE__ */new Set([...n,...e]))},[]),nn="files"===(ln=ee).place?`files:${ln.folderId??""}`:"products"===ln.place?`products:${ln.nodeId??""}`:"trash";var ln;V(()=>{if("files"===ee.place)en(["@files",...$e(ee.folderId).slice(0,-1).map(e=>e.id)]);else if("products"===ee.place){const e=ee.nodeId?Ye.get(ee.nodeId)?.path??[]:[];en(["@products",...e.slice(0,-1).map(e=>`p:${e.id}`)])}},[nn]);const rn="products"===ee.place,an="trash"===ee.place,tn="files"===ee.place,on=tn?ee.folderId:null,dn=rn&&ee.nodeId?Ye.get(ee.nodeId)?.path[0]:void 0,sn=e=>e?.sharedFrom?`${Re.readOnly} ${Re.editedAtHq(e.sharedFrom)}`:Re.readOnly,cn=R(()=>te.map(e=>e.id),[te]),un=R(()=>new Map(te.map(e=>[e.id,e])),[te]),mn=s(cn),pn=R(()=>cn.filter(e=>mn.selected.has(e)),[cn,mn.selected]),hn=1===pn.length?un.get(pn[0]):void 0,fn=U(!0);V(()=>{fn.current?fn.current=!1:mn.clear()},[nn]);const gn=he?.join("\0");V(()=>{he&&mn.setSelection(he)},[gn]);const vn=U(gn??""),kn=pn.join("\0");V(()=>{vn.current!==kn&&(vn.current=kn,fe?.(pn))},[kn]);const yn=(e,n={})=>{Be?mn.select(e):mn.select(e,{ctrl:!(!n.ctrlKey&&!n.metaKey),shift:!!n.shiftKey})},[bn,wn]=B(null),Cn=e=>{const n=bn;if(wn(null),!n||null==e)return;e!==("folder"===n.kind?Qe.get(n.id)?.name:un.get(n.id)?.name)&&Ie?.(n,e)},xn=async e=>{if(!xe)return;const n=await xe(e);en(["@files",...e?[e]:[]]),"string"==typeof n&&wn({kind:"folder",id:n})},In=K(e=>{const n=[],l=n=>{if("files"===e.kind)return n===on&&tn?Re.alreadyHere:void 0;const l=Qe.get(e.id);return n===e.id||n&&Ze(n,e.id)?Re.notIntoItself:(l?.parentId??null)===n?Re.folderAlreadyHere:void 0};n.push({key:u,label:Re.allFiles,disabledReason:l(null)});const r=(e,a)=>{for(const i of Ge.get(e)??[])n.push({key:i.id,label:i.name,depth:a,disabledReason:l(i.id)}),r(i.id,a+1)};return r(null,1),n},[Ge,Qe,tn,Ze,on,Re]),Nn=K(e=>{const n=new Set(e.map(e=>un.get(e)?.kind??"image"));return 1===n.size?[...n][0]:"file"},[un]),[Dn,Sn]=B(null),jn={words:Re,media:Ke,denied:ve,moveTargets:In,kindOf:Nn,urlOf:e=>un.get(e)?.url,newSubfolder:xe&&Ve?e=>{xn(e)}:void 0,rename:Ie&&Ve?e=>{"file"!==e.kind||mn.isSelected(e.id)||mn.select(e.id),wn(e)}:void 0,move:Ne&&Ve?Ne:void 0,trash:De&&Ve?De:void 0,deleteFolder:Se&&Ve?Se:void 0,folderNotEmpty:e=>!!Qe.get(e)?.notEmpty,replace:Fe&&Ve?Fe:void 0,copyUrl:e=>{const n=un.get(e)?.url;n&&y(Re.urlLabel,n)},openInDesign:Oe,restore:je,deleteForever:Te},Tn=e=>m(e,jn),zn=w(),Fn=(e,n)=>{Be||(mn.isSelected(e)||mn.select(e),zn.open(n,(e=>{const n=mn.isSelected(e)?pn:[e];return rn?{kind:"render",id:e}:an?{kind:"trashed",ids:n}:{kind:"files",ids:n}})(e)))},[Ln,On]=B(null),[En,Pn]=B(null),[An,Mn]=B(null);V(()=>{if(!En&&!Ln)return;const e=()=>{Pn(null),On(null)};return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[En,Ln]);const Un=(e,n)=>Array.from(e.dataTransfer?.types??[]).includes(n),Rn=(e,n)=>!(!Ne||ve.move||Be)&&(!!Un(e,Y)||!(!Un(e,Q)||!An)&&(n!==An&&!(n&&Ze(n,An)))),Kn=(e,n)=>({onDragEnter:l=>{Rn(l,n)&&(l.preventDefault(),On(e))},onDragOver:l=>{Rn(l,n)&&(l.preventDefault(),l.dataTransfer.dropEffect="move",Ln!==e&&On(e))},onDragLeave:n=>{const l=n.relatedTarget;l&&n.currentTarget.contains(l)||On(n=>n===e?null:n)},onDrop:e=>{if(Rn(e,n))if(e.preventDefault(),On(null),Un(e,Y)){let l;try{l=JSON.parse(e.dataTransfer.getData(Y))}catch{l=null}Array.isArray(l)&&l.length&&Ne({kind:"files",ids:l.map(String)},n)}else An&&(Ne({kind:"folder",id:An},n),Mn(null))}}),Bn=e=>{const n=e=>Un(e,Y)||Un(e,Q)||Un(e,"Files");return{onDragEnter:l=>{n(l)&&Pn(e)},onDragOver:l=>{n(l)&&En!==e&&Pn(e)},onDragLeave:n=>{const l=n.relatedTarget;l&&n.currentTarget.contains(l)||Pn(n=>n===e?null:n)}}},Vn=(e,n,l)=>/* @__PURE__ */W(E,{side:"right",content:En===e?Re.noDropProducts:sn(l),open:En===e||!En&&void 0,children:/* @__PURE__ */W("span",{children:n})}),Jn=e=>({onContextMenu:n=>{zn.open(n,e)}}),Hn=(e,r,a)=>e.map(e=>{const i=`p:${e.id}`,t=a??e,o=Xe.has(i),d=e.children?.length?e.children:null;/* @__PURE__ */
2
2
  return J("div",{role:"none",className:"contents",children:[
3
3
  /* @__PURE__ */W(n,{label:Vn(i,e.name,t),level:r,icon:d&&o?X.folderOpen:X.folder,count:e.count,countLabel:null!=e.count?e.countLabel??Re.fileCount(e.count):void 0,selected:rn&&ee.nodeId===e.id,expanded:d?o:void 0,onToggle:d?()=>_e(i):void 0,onSelect:()=>ne({place:"products",nodeId:e.id}),rowProps:{"data-media-row":i,...Bn(i),...Ve?Jn({kind:"product-node",id:e.id}):{}}}),d&&o&&/* @__PURE__ */W(l,{children:Hn(d,r+1,t)})]},e.id)}),Wn=(e,r)=>(Ge.get(e)??[]).map(e=>{const a=Ge.get(e.id),i=Xe.has(e.id),t="folder"===bn?.kind&&bn.id===e.id,o=Tn({kind:"folder",id:e.id});/* @__PURE__ */
4
4
  return J("div",{role:"none",className:"contents",children:[
5
- /* @__PURE__ */W(n,{label:e.name,level:r,icon:a&&i?X.folderOpen:X.folder,count:e.count,countLabel:null!=e.count?e.countLabel??Re.fileCount(e.count):void 0,selected:t||tn&&ee.folderId===e.id,expanded:a?i:void 0,onToggle:a?()=>_e(e.id):void 0,onSelect:()=>ne({place:"files",folderId:e.id}),drop:Ln===e.id?"into":void 0,dragging:An===e.id,draggable:Ve&&!!Ne&&!ve.move,rename:t?/* @__PURE__ */W(m,{value:e.name,label:Re.folderName,onDone:Cn}):void 0,actions:Ve&&o.length?/* @__PURE__ */W(N,{align:"end","aria-label":Re.folderActions,trigger:X.more,items:o}):void 0,rowProps:{"data-media-row":e.id,...Kn(e.id,e.id),...Ve?Jn({kind:"folder",id:e.id}):{},...Ve&&Ne&&!ve.move?{draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed="move",n.dataTransfer.setData(Q,e.id),Mn(e.id)},onDragEnd:()=>{Mn(null),On(null)}}:{}}}),a&&i&&/* @__PURE__ */W(l,{children:Wn(e.id,r+1)})]},e.id)}),Yn=Xe.has("@files"),Qn=Xe.has("@products"),Gn=/* @__PURE__ */J(e,{"aria-label":Re.folders,children:[re&&/* @__PURE__ */J(H,{children:[
5
+ /* @__PURE__ */W(n,{label:e.name,level:r,icon:a&&i?X.folderOpen:X.folder,count:e.count,countLabel:null!=e.count?e.countLabel??Re.fileCount(e.count):void 0,selected:t||tn&&ee.folderId===e.id,expanded:a?i:void 0,onToggle:a?()=>_e(e.id):void 0,onSelect:()=>ne({place:"files",folderId:e.id}),drop:Ln===e.id?"into":void 0,dragging:An===e.id,draggable:Ve&&!!Ne&&!ve.move,rename:t?/* @__PURE__ */W(h,{value:e.name,label:Re.folderName,onDone:Cn}):void 0,actions:Ve&&o.length?/* @__PURE__ */W(N,{align:"end","aria-label":Re.folderActions,trigger:X.more,items:o}):void 0,rowProps:{"data-media-row":e.id,...Kn(e.id,e.id),...Ve?Jn({kind:"folder",id:e.id}):{},...Ve&&Ne&&!ve.move?{draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed="move",n.dataTransfer.setData(Q,e.id),Mn(e.id)},onDragEnd:()=>{Mn(null),On(null)}}:{}}}),a&&i&&/* @__PURE__ */W(l,{children:Wn(e.id,r+1)})]},e.id)}),Yn=Xe.has("@files"),Qn=Xe.has("@products"),Gn=/* @__PURE__ */J(e,{"aria-label":Re.folders,children:[re&&/* @__PURE__ */J(H,{children:[
6
6
  /* @__PURE__ */W(n,{label:Vn("@products",Re.products),level:1,icon:X.lock,badge:{label:Re.readOnlyBadge,tone:"neutral"},expanded:re.length?Qn:void 0,onToggle:()=>_e("@products"),selected:rn&&null==ee.nodeId,onSelect:()=>ne({place:"products",nodeId:null}),rowProps:{"data-media-row":"@products",...Bn("@products")}}),Qn&&re.length>0&&/* @__PURE__ */W(l,{children:Hn(re,2)})]}),
7
- /* @__PURE__ */W(n,{label:Re.allFiles,level:1,icon:Yn?X.folderOpen:X.folder,count:ae,countLabel:null!=ae?Re.fileCount(ae):void 0,expanded:Ge.get(null)?.length?Yn:void 0,onToggle:()=>_e("@files"),selected:tn&&null==ee.folderId,onSelect:()=>ne({place:"files",folderId:null}),drop:"@files"===Ln?"into":void 0,rowProps:{"data-media-row":"@files",...Kn("@files",null)}}),Yn&&(Ge.get(null)?.length??0)>0&&/* @__PURE__ */W(l,{children:Wn(null,2)}),Ve&&/* @__PURE__ */W(n,{label:Re.trash,level:1,icon:X.trash,count:ie,countLabel:null!=ie?Re.fileCount(ie):void 0,selected:an,onSelect:()=>ne({place:"trash"}),rowProps:{"data-media-row":"@trash"}})]}),$n=(()=>{if(an)return[{label:Re.trash}];if(rn){const e=ee.nodeId?Ye.get(ee.nodeId)?.path??[]:[];return[{label:Re.products,onClick:e.length?()=>ne({place:"products",nodeId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>ne({place:"products",nodeId:n.id}):void 0}))]}const e=$e(on);return[{label:Re.allFiles,onClick:e.length?()=>ne({place:"files",folderId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>ne({place:"files",folderId:n.id}):void 0}))]})(),Zn=rn?Re.readOnly:ve.upload,Xn=!!Ce&&!an&&!Zn,qn=S({accept:ke,maxSizeBytes:ye,multiple:!0,disabled:!Xn,onAccept:e=>Ce?.(e,on)}),_n=rn?Re.noProductFolder:ve.newFolder,el=e=>e?{"aria-disabled":!0,disabledReason:e}:{},nl=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[Ve&&xe&&!an&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.folderPlus,onClick:()=>{xn(on)},...el(_n),children:Re.newFolder}),Ce&&!an&&/* @__PURE__ */W(L,{variant:"primary",size:"sm",leftIcon:X.upload,onClick:()=>qn.open(),...el(Zn),children:Re.upload}),Ve&&an&&ze&&te.length>0&&/* @__PURE__ */W(L,{variant:"danger",size:"sm",onClick:ze,...el(ve.deleteForever),children:Re.emptyTrash})]}),ll=(e,n,l,r,a)=>/* @__PURE__ */W("div",{style:{width:We?void 0:a,flex:We?"1 1 120px":"0 0 auto",minWidth:0},children:/* @__PURE__ */W(p,{size:"sm","aria-label":e,value:n,onChange:r,options:l})},e),rl=e=>n=>ce?.({...se,[e]:n}),al=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[de&&/* @__PURE__ */W("div",{style:{flex:"1 1 200px",minWidth:0},children:/* @__PURE__ */W(I,{size:"sm",type:"search",leftIcon:X.search,placeholder:rn?Re.searchProducts:Re.search,"aria-label":rn?Re.searchProducts:Re.search,value:oe??"",onChange:e=>de(e.target.value)})}),ce&&ll(Re.mediaType,se.type,[{value:"all",label:Re.allTypes},{value:"image",label:Re.images},{value:"video",label:Re.videos},{value:"svg",label:"SVG"},{value:"gif",label:"GIF"}],rl("type"),130),ce&&!rn&&!an&&ll(Re.use,se.use,[{value:"any",label:Re.anyUse},{value:"email",label:Re.emailOnly},{value:"website",label:Re.websiteOnly},{value:"unused",label:Re.notUsed}],rl("use"),130),ce&&Ve&&ll(Re.sort,se.sort,[{value:"newest",label:Re.newest},{value:"name",label:Re.byName},{value:"size",label:Re.bySize}],rl("sort"),110),ue?.map(e=>ll(e.label,e.value,e.options,e.onChange,120)),pe&&/* @__PURE__ */W(k,{size:"sm",label:Re.view,value:me,onChange:pe,options:[{value:"grid",label:Re.grid,icon:X.grid},{value:"list",label:Re.list,icon:X.list}]})]}),il=e=>{const n=[];return null!=e.trashedDaysAgo&&n.push({key:"t",label:Re.daysAgo(e.trashedDaysAgo),count:e.trashedDaysAgo,icon:q.clock,tone:"neutral"}),e.usedCount&&n.push({key:"u",label:Re.used(e.usedCount),count:e.usedCount,icon:q.link,tone:"active"}),e.email&&n.push({key:"e",label:Re.email,icon:q.email,tone:"queued"}),e.private&&n.push({key:"p",label:Re.private,icon:q.lock,tone:"neutral"}),n},tl=e=>il(e).map(e=>/* @__PURE__ */W(F,{tone:e.tone,size:"xs",children:e.label},e.key)),ol=Ve&&tn&&!!Ne&&!ve.move,dl=!!Me&&!an,sl=U(""),cl=U(null),ul=()=>cl.current?.dropped?"dropped":"cancelled",ml=U(Me);ml.current=Me;const pl=K(e=>{const n=cl.current;n&&(cl.current=null,n.stop(),T(sl.current,!1),e&&ml.current?.(e))},[]),hl=K(e=>{pl(ul());const n=Je.current?.ownerDocument;if(!n)return;sl.current=z(Je.current);const l=Je.current?.closest("[data-modal-panel]"),r=e=>{sl.current&&!l?.contains(e.target)&&T(sl.current,!0)},a=()=>!!e&&!e.isConnected,i=()=>{const e=cl.current;if(e){if(a())return pl("dropped");e.dropped=!0,T(sl.current,!1)}},t=e=>{const n=e.dataTransfer?.dropEffect;pl(n&&"none"!==n?"dropped":a()?ul():"cancelled")},o=()=>{a()&&pl(ul())},d=["pointermove","pointerdown","mousemove","mousedown"];n.addEventListener("dragover",r,!0),n.addEventListener("drop",i,!0),n.addEventListener("dragend",t,!0);for(const e of d)n.addEventListener(e,o,!0);cl.current={dropped:!1,stop:()=>{n.removeEventListener("dragover",r,!0),n.removeEventListener("drop",i,!0),n.removeEventListener("dragend",t,!0);for(const e of d)n.removeEventListener(e,o,!0)}}},[pl]);V(()=>()=>pl(ul()),[pl]);const fl=(e,n,l)=>{if("start"!==e)return;const r=un.get(n);r&&gl(r)&&(hl(l??null),Me(e))},gl=e=>!dl||e.private||e.pickDisabledReason?void 0:JSON.stringify({id:e.id,url:e.url,kind:"video"===e.kind?"video":"image",name:e.name}),vl=te.map(e=>({id:e.id,url:e.thumbUrl??e.url,name:e.name,kind:e.kind,caption:e.name,badges:il(e),dragData:ol?JSON.stringify(mn.isSelected(e.id)?pn:[e.id]):gl(e),...ol&&gl(e)?{dragAlso:{[G]:gl(e)}}:{}})),kl=We?Math.max(72,Math.floor((He-24-16-1)/3)):112,yl=U(null),bl=v({containerRef:yl,enabled:Ve&&!We&&te.length>0,selected:mn.selected,setSelection:e=>mn.setSelection(e),clearSelection:mn.clear}),wl=e=>{if(Be){const n=un.get(e);return void(!n||n.private||n.pickDisabledReason||Ee?.(n))}const n=cn.indexOf(e);n>=0&&Sn(n)},Cl=te.length?null:oe?/* @__PURE__ */W(i,{variant:"dashed",title:Re.noMatches}):rn?/* @__PURE__ */W(i,{variant:"dashed",title:Re.emptyProducts,description:sn(dn)}):an?/* @__PURE__ */W(i,{variant:"dashed",title:Re.trashEmpty}):!Xn||Be?/* @__PURE__ */W(i,{variant:"dashed",title:Re.emptyFolder}):null,xl="list"===me&&te.length>0,Il=Cl??(xl?/* @__PURE__ */W("ul",{role:"listbox","aria-multiselectable":Ve||void 0,"aria-label":Re.folders,className:"flex flex-col gap-1",children:te.map(e=>/* @__PURE__ */J("li",{role:"option","aria-selected":mn.isSelected(e.id),tabIndex:0,"data-grid-item":"","data-grid-id":e.id,onClick:n=>yn(e.id,n),onDoubleClick:()=>wl(e.id),onContextMenu:n=>Fn(e.id,n),draggable:!!gl(e)||void 0,onDragStart:gl(e)?n=>{n.dataTransfer.effectAllowed="link",n.dataTransfer.setData(G,gl(e)),fl("start",e.id,n.currentTarget)}:void 0,onKeyDown:n=>{"Enter"!==n.key&&" "!==n.key||(n.preventDefault(),yn(e.id,n))},className:"flex h-12 cursor-pointer items-center gap-3 rounded-md px-2 text-sm rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)] "+(mn.isSelected(e.id)?"bg-accent-tint text-blue-700":"text-ink hover:bg-gray-100"),children:[
7
+ /* @__PURE__ */W(n,{label:Re.allFiles,level:1,icon:Yn?X.folderOpen:X.folder,count:ae,countLabel:null!=ae?Re.fileCount(ae):void 0,expanded:Ge.get(null)?.length?Yn:void 0,onToggle:()=>_e("@files"),selected:tn&&null==ee.folderId,onSelect:()=>ne({place:"files",folderId:null}),drop:"@files"===Ln?"into":void 0,rowProps:{"data-media-row":"@files",...Kn("@files",null)}}),Yn&&(Ge.get(null)?.length??0)>0&&/* @__PURE__ */W(l,{children:Wn(null,2)}),Ve&&/* @__PURE__ */W(n,{label:Re.trash,level:1,icon:X.trash,count:ie,countLabel:null!=ie?Re.fileCount(ie):void 0,selected:an,onSelect:()=>ne({place:"trash"}),rowProps:{"data-media-row":"@trash"}})]}),$n=(()=>{if(an)return[{label:Re.trash}];if(rn){const e=ee.nodeId?Ye.get(ee.nodeId)?.path??[]:[];return[{label:Re.products,onClick:e.length?()=>ne({place:"products",nodeId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>ne({place:"products",nodeId:n.id}):void 0}))]}const e=$e(on);return[{label:Re.allFiles,onClick:e.length?()=>ne({place:"files",folderId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>ne({place:"files",folderId:n.id}):void 0}))]})(),Zn=rn?Re.readOnly:ve.upload,Xn=!!Ce&&!an&&!Zn,qn=S({accept:ke,maxSizeBytes:ye,multiple:!0,disabled:!Xn,onAccept:e=>Ce?.(e,on)}),_n=rn?Re.noProductFolder:ve.newFolder,el=e=>e?{"aria-disabled":!0,disabledReason:e}:{},nl=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[Ve&&xe&&!an&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.folderPlus,onClick:()=>{xn(on)},...el(_n),children:Re.newFolder}),Ce&&!an&&/* @__PURE__ */W(L,{variant:"primary",size:"sm",leftIcon:X.upload,onClick:()=>qn.open(),...el(Zn),children:Re.upload}),Ve&&an&&ze&&te.length>0&&/* @__PURE__ */W(L,{variant:"danger",size:"sm",onClick:ze,...el(ve.deleteForever),children:Re.emptyTrash})]}),ll=(e,n,l,r,a)=>/* @__PURE__ */W("div",{style:{width:We?void 0:a,flex:We?"1 1 120px":"0 0 auto",minWidth:0},children:/* @__PURE__ */W(f,{size:"sm","aria-label":e,value:n,onChange:r,options:l})},e),rl=e=>n=>ce?.({...se,[e]:n}),al=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[de&&/* @__PURE__ */W("div",{style:{flex:"1 1 200px",minWidth:0},children:/* @__PURE__ */W(I,{size:"sm",type:"search",leftIcon:X.search,placeholder:rn?Re.searchProducts:Re.search,"aria-label":rn?Re.searchProducts:Re.search,value:oe??"",onChange:e=>de(e.target.value)})}),ce&&ll(Re.mediaType,se.type,[{value:"all",label:Re.allTypes},{value:"image",label:Re.images},{value:"video",label:Re.videos},{value:"svg",label:"SVG"},{value:"gif",label:"GIF"}],rl("type"),130),ce&&!rn&&!an&&ll(Re.use,se.use,[{value:"any",label:Re.anyUse},{value:"email",label:Re.emailOnly},{value:"website",label:Re.websiteOnly},{value:"unused",label:Re.notUsed}],rl("use"),130),ce&&Ve&&ll(Re.sort,se.sort,[{value:"newest",label:Re.newest},{value:"name",label:Re.byName},{value:"size",label:Re.bySize}],rl("sort"),110),ue?.map(e=>ll(e.label,e.value,e.options,e.onChange,120)),pe&&/* @__PURE__ */W(k,{size:"sm",label:Re.view,value:me,onChange:pe,options:[{value:"grid",label:Re.grid,icon:X.grid},{value:"list",label:Re.list,icon:X.list}]})]}),il=e=>{const n=[];return null!=e.trashedDaysAgo&&n.push({key:"t",label:Re.daysAgo(e.trashedDaysAgo),count:e.trashedDaysAgo,icon:q.clock,tone:"neutral"}),e.usedCount&&n.push({key:"u",label:Re.used(e.usedCount),count:e.usedCount,icon:q.link,tone:"active"}),e.email&&n.push({key:"e",label:Re.email,icon:q.email,tone:"queued"}),e.private&&n.push({key:"p",label:Re.private,icon:q.lock,tone:"neutral"}),n},tl=e=>il(e).map(e=>/* @__PURE__ */W(F,{tone:e.tone,size:"xs",children:e.label},e.key)),ol=Ve&&tn&&!!Ne&&!ve.move,dl=!!Me&&!an,sl=U(""),cl=U(null),ul=()=>cl.current?.dropped?"dropped":"cancelled",ml=U(Me);ml.current=Me;const pl=K(e=>{const n=cl.current;n&&(cl.current=null,n.stop(),T(sl.current,!1),e&&ml.current?.(e))},[]),hl=K(e=>{pl(ul());const n=Je.current?.ownerDocument;if(!n)return;sl.current=z(Je.current);const l=Je.current?.closest("[data-modal-panel]"),r=e=>{sl.current&&!l?.contains(e.target)&&T(sl.current,!0)},a=()=>!!e&&!e.isConnected,i=()=>{const e=cl.current;if(e){if(a())return pl("dropped");e.dropped=!0,T(sl.current,!1)}},t=e=>{const n=e.dataTransfer?.dropEffect;pl(n&&"none"!==n?"dropped":a()?ul():"cancelled")},o=()=>{a()&&pl(ul())},d=["pointermove","pointerdown","mousemove","mousedown"];n.addEventListener("dragover",r,!0),n.addEventListener("drop",i,!0),n.addEventListener("dragend",t,!0);for(const e of d)n.addEventListener(e,o,!0);cl.current={dropped:!1,stop:()=>{n.removeEventListener("dragover",r,!0),n.removeEventListener("drop",i,!0),n.removeEventListener("dragend",t,!0);for(const e of d)n.removeEventListener(e,o,!0)}}},[pl]);V(()=>()=>pl(ul()),[pl]);const fl=(e,n,l)=>{if("start"!==e)return;const r=un.get(n);r&&gl(r)&&(hl(l??null),Me(e))},gl=e=>!dl||e.private||e.pickDisabledReason?void 0:JSON.stringify({id:e.id,url:e.url,kind:"video"===e.kind?"video":"image",name:e.name}),vl=te.map(e=>({id:e.id,url:e.thumbUrl??e.url,name:e.name,kind:e.kind,caption:e.name,badges:il(e),dragData:ol?JSON.stringify(mn.isSelected(e.id)?pn:[e.id]):gl(e),...ol&&gl(e)?{dragAlso:{[G]:gl(e)}}:{}})),kl=We?Math.max(72,Math.floor((He-24-16-1)/3)):112,yl=U(null),bl=c({containerRef:yl,enabled:Ve&&!We&&te.length>0,selected:mn.selected,setSelection:e=>mn.setSelection(e),clearSelection:mn.clear}),wl=e=>{if(Be){const n=un.get(e);return void(!n||n.private||n.pickDisabledReason||Ee?.(n))}const n=cn.indexOf(e);n>=0&&Sn(n)},Cl=te.length?null:oe?/* @__PURE__ */W(i,{variant:"dashed",title:Re.noMatches}):rn?/* @__PURE__ */W(i,{variant:"dashed",title:Re.emptyProducts,description:sn(dn)}):an?/* @__PURE__ */W(i,{variant:"dashed",title:Re.trashEmpty}):!Xn||Be?/* @__PURE__ */W(i,{variant:"dashed",title:Re.emptyFolder}):null,xl="list"===me&&te.length>0,Il=Cl??(xl?/* @__PURE__ */W("ul",{role:"listbox","aria-multiselectable":Ve||void 0,"aria-label":Re.folders,className:"flex flex-col gap-1",children:te.map(e=>/* @__PURE__ */J("li",{role:"option","aria-selected":mn.isSelected(e.id),tabIndex:0,"data-grid-item":"","data-grid-id":e.id,onClick:n=>yn(e.id,n),onDoubleClick:()=>wl(e.id),onContextMenu:n=>Fn(e.id,n),draggable:!!gl(e)||void 0,onDragStart:gl(e)?n=>{n.dataTransfer.effectAllowed="link",n.dataTransfer.setData(G,gl(e)),fl("start",e.id,n.currentTarget)}:void 0,onKeyDown:n=>{"Enter"!==n.key&&" "!==n.key||(n.preventDefault(),yn(e.id,n))},className:"flex h-12 cursor-pointer items-center gap-3 rounded-md px-2 text-sm rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)] "+(mn.isSelected(e.id)?"bg-accent-tint text-blue-700":"text-ink hover:bg-gray-100"),children:[
8
8
  /* @__PURE__ */W("img",{src:e.thumbUrl??e.url,alt:"",className:"h-10 w-10 shrink-0 rounded bg-gray-100 object-contain"}),
9
9
  /* @__PURE__ */W("span",{className:"min-w-0 flex-1 truncate",children:e.name}),
10
- /* @__PURE__ */W("span",{className:"flex shrink-0 items-center gap-1",children:tl(e)}),e.sizeLabel&&/* @__PURE__ */W("span",{className:"w-16 shrink-0 text-right text-xs text-ink-faint",children:e.sizeLabel})]},e.id))}):/* @__PURE__ */W(h,{items:vl,readOnly:!Xn||Be,onFiles:Xn&&!Be?e=>Ce(e,on):void 0,accept:ke,maxSizeBytes:ye,busy:be,progress:we,fit:"contain",thumbSize:kl,dragType:ol?Y:dl?G:void 0,onDragOutChange:dl?(e,n,l)=>fl(e,n,l):void 0,selected:mn.selected,onItemClick:yn,onItemDoubleClick:wl,onItemContextMenu:Ve?Fn:void 0,menuOnMedia:Ve})),Nl=u({count:pn.length,kind:Nn(pn),targets:In({kind:"files",ids:pn}),onPick:e=>Ne?.({kind:"files",ids:pn},e.key===s?null:e.key)}),Dl=P({variant:"secondary",size:"sm"}),Sl=/* @__PURE__ */W(N,{align:"start",triggerClassName:Dl,trigger:/* @__PURE__ */J(H,{children:[X.folder,Re.moveTo]}),items:Nl,disabled:!!ve.move}),jl=Ve&&pn.length>1&&!rn?/* @__PURE__ */J("div",{"data-media-bulk":"",className:"flex flex-wrap items-center gap-2 rounded-lg border border-line px-3 py-2",children:[
10
+ /* @__PURE__ */W("span",{className:"flex shrink-0 items-center gap-1",children:tl(e)}),e.sizeLabel&&/* @__PURE__ */W("span",{className:"w-16 shrink-0 text-right text-xs text-ink-faint",children:e.sizeLabel})]},e.id))}):/* @__PURE__ */W(g,{items:vl,readOnly:!Xn||Be,onFiles:Xn&&!Be?e=>Ce(e,on):void 0,accept:ke,maxSizeBytes:ye,busy:be,progress:we,fit:"contain",thumbSize:kl,dragType:ol?Y:dl?G:void 0,onDragOutChange:dl?(e,n,l)=>fl(e,n,l):void 0,selected:mn.selected,onItemClick:yn,onItemDoubleClick:wl,onItemContextMenu:Ve?Fn:void 0,menuOnMedia:Ve})),Nl=p({count:pn.length,kind:Nn(pn),targets:In({kind:"files",ids:pn}),onPick:e=>Ne?.({kind:"files",ids:pn},e.key===u?null:e.key)}),Dl=P({variant:"secondary",size:"sm"}),Sl=/* @__PURE__ */W(N,{align:"start",triggerClassName:Dl,trigger:/* @__PURE__ */J(H,{children:[X.folder,Re.moveTo]}),items:Nl,disabled:!!ve.move}),jl=Ve&&pn.length>1&&!rn?/* @__PURE__ */J("div",{"data-media-bulk":"",className:"flex flex-wrap items-center gap-2 rounded-lg border border-line px-3 py-2",children:[
11
11
  /* @__PURE__ */W(b,{checked:pn.length===te.length,indeterminate:pn.length<te.length,onChange:e=>e?mn.selectAll():mn.clear(),label:Re.selected(pn.length)}),/* @__PURE__ */J(H,an?{children:[je&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.undo,onClick:()=>je(pn),...el(ve.restore),children:Re.restore}),Te&&/* @__PURE__ */W(L,{variant:"secondary-danger",size:"sm",onClick:()=>Te(pn),...el(ve.deleteForever),children:Re.deleteForever})]}:{children:[Ne&&Sl,Ie&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.edit,disabled:!0,children:Re.rename}),De&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.trash,onClick:()=>De({kind:"files",ids:pn}),...el(ve.trash),children:Re.moveFilesToTrash(pn.length)})]}),
12
- /* @__PURE__ */W(L,{variant:"ghost",size:"sm",onClick:mn.clear,children:Re.clearSelection})]}):null,Tl=e=>{const n=[],l=(e,l,r)=>{null!=r&&""!==r&&n.push({key:e,label:l,value:r})},r="file"===bn?.kind&&bn.id===e.id;l("name",Re.name,r?/* @__PURE__ */W(m,{value:e.name,label:Re.fileName,onDone:Cn}):e.name),l("type",Re.type,e.typeLabel),l("size",Re.size,e.sizeLabel),l("resolution",Re.resolution,e.resolution),rn?(l("design",Re.design,e.design),l("finish",Re.finish,e.finish),l("angle",Re.angleLug,e.angleLug),l("owner",Re.owner,e.owner)):(l("added",Re.addedBy,e.addedBy),l("folder",Re.folder,e.folderPath)),l("used",Re.usedIn,null!=e.usedCount?Re.places(e.usedCount):void 0);const a=c({kind:"files",ids:[e.id]},jn).find(e=>"submenu"===e.type);/* @__PURE__ */
12
+ /* @__PURE__ */W(L,{variant:"ghost",size:"sm",onClick:mn.clear,children:Re.clearSelection})]}):null,Tl=e=>{const n=[],l=(e,l,r)=>{null!=r&&""!==r&&n.push({key:e,label:l,value:r})},r="file"===bn?.kind&&bn.id===e.id;l("name",Re.name,r?/* @__PURE__ */W(h,{value:e.name,label:Re.fileName,onDone:Cn}):e.name),l("type",Re.type,e.typeLabel),l("size",Re.size,e.sizeLabel),l("resolution",Re.resolution,e.resolution),rn?(l("design",Re.design,e.design),l("finish",Re.finish,e.finish),l("angle",Re.angleLug,e.angleLug),l("owner",Re.owner,e.owner)):(l("added",Re.addedBy,e.addedBy),l("folder",Re.folder,e.folderPath)),l("used",Re.usedIn,null!=e.usedCount?Re.places(e.usedCount):void 0);const a=m({kind:"files",ids:[e.id]},jn).find(e=>"submenu"===e.type);/* @__PURE__ */
13
13
  return J("div",{"data-media-details":"",className:"flex flex-col gap-3",children:[
14
14
  /* @__PURE__ */W("img",{src:e.url,alt:e.name,className:"aspect-square w-full rounded-lg bg-gray-100 object-contain"}),rn&&/* @__PURE__ */W(x,{tone:"neutral",title:Re.readOnlyBadge,children:sn(dn)}),
15
15
  /* @__PURE__ */W(t,{size:"sm",columns:1,items:n}),!an&&/* @__PURE__ */J("div",{className:"flex gap-2",children:[
16
16
  /* @__PURE__ */W("div",{style:{flex:"1 1 0",minWidth:0},children:/* @__PURE__ */W(I,{size:"sm",readOnly:!0,value:e.url,"aria-label":Re.fileUrl,onFocus:e=>e.currentTarget.select()})}),
17
- /* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.copy,onClick:()=>jn.copyUrl(e.id),children:Re.copyUrl})]}),tn&&Ve&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[Fe&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.swap,onClick:()=>Fe(e.id),...el(ve.replace),children:Re.replace}),Le&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.crop,onClick:()=>Le(e.id),children:Re.cropEdit}),Ne&&"submenu"===a?.type&&/* @__PURE__ */W(N,{align:"start",triggerClassName:Dl,trigger:/* @__PURE__ */J(H,{children:[X.folder,Re.moveTo]}),items:a.items,disabled:!!ve.move}),Ie&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.edit,onClick:()=>wn({kind:"file",id:e.id}),...el(ve.rename),children:Re.rename}),De&&/* @__PURE__ */W(D,{"aria-label":Re.moveToTrash,size:"sm",onClick:()=>De({kind:"files",ids:[e.id]}),disabledReason:ve.trash,"aria-disabled":!!ve.trash||void 0,children:X.trash})]}),an&&Ve&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[je&&/* @__PURE__ */W(L,{variant:"primary",size:"sm",leftIcon:X.undo,onClick:()=>je([e.id]),...el(ve.restore),children:Re.restore}),Te&&/* @__PURE__ */W(L,{variant:"danger",size:"sm",onClick:()=>Te([e.id]),...el(ve.deleteForever),children:Re.deleteForever})]}),rn&&Oe&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.external,onClick:()=>Oe({kind:"render",id:e.id}),children:Re.openInDesign}),ge&&/* @__PURE__ */W(f,{items:ge})]})},zl=hn?hn.private?Re.privateNoPick:hn.pickDisabledReason:void 0,Fl=Be?/* @__PURE__ */J("div",{"data-media-picker-footer":"",className:"flex flex-wrap items-center justify-between gap-2 border-t border-line px-3 py-2",children:[
17
+ /* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.copy,onClick:()=>jn.copyUrl(e.id),children:Re.copyUrl})]}),tn&&Ve&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[Fe&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.swap,onClick:()=>Fe(e.id),...el(ve.replace),children:Re.replace}),Le&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.crop,onClick:()=>Le(e.id),children:Re.cropEdit}),Ne&&"submenu"===a?.type&&/* @__PURE__ */W(N,{align:"start",triggerClassName:Dl,trigger:/* @__PURE__ */J(H,{children:[X.folder,Re.moveTo]}),items:a.items,disabled:!!ve.move}),Ie&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.edit,onClick:()=>wn({kind:"file",id:e.id}),...el(ve.rename),children:Re.rename}),De&&/* @__PURE__ */W(D,{"aria-label":Re.moveToTrash,size:"sm",onClick:()=>De({kind:"files",ids:[e.id]}),disabledReason:ve.trash,"aria-disabled":!!ve.trash||void 0,children:X.trash})]}),an&&Ve&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[je&&/* @__PURE__ */W(L,{variant:"primary",size:"sm",leftIcon:X.undo,onClick:()=>je([e.id]),...el(ve.restore),children:Re.restore}),Te&&/* @__PURE__ */W(L,{variant:"danger",size:"sm",onClick:()=>Te([e.id]),...el(ve.deleteForever),children:Re.deleteForever})]}),rn&&Oe&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",leftIcon:X.external,onClick:()=>Oe({kind:"render",id:e.id}),children:Re.openInDesign}),ge&&/* @__PURE__ */W(v,{items:ge})]})},zl=hn?hn.private?Re.privateNoPick:hn.pickDisabledReason:void 0,Fl=Be?/* @__PURE__ */J("div",{"data-media-picker-footer":"",className:"flex flex-wrap items-center justify-between gap-2 border-t border-line px-3 py-2",children:[
18
18
  /* @__PURE__ */W("span",{className:"min-w-0 truncate text-sm text-ink-faint",children:hn?Re.oneChosen(hn.name):Re.noneChosen}),
19
19
  /* @__PURE__ */J("div",{className:"flex gap-2",children:[Pe&&/* @__PURE__ */W(L,{variant:"secondary",size:"sm",onClick:Pe,children:Re.cancel}),
20
20
  /* @__PURE__ */W(L,{variant:"primary",size:"sm",disabled:!hn,...el(zl),onClick:()=>{hn&&!zl&&Ee?.(hn)},children:Re.chooseImage})]})]}):null,Ll=Ve&&!!hn,Ol=/* @__PURE__ */J("div",{className:"flex min-w-0 flex-col gap-3",children:[Ae&&/* @__PURE__ */W(x,{tone:"neutral",children:Ae}),
@@ -0,0 +1,2 @@
1
+ import{jsx as e}from"react/jsx-runtime";function i({size:i=18,...r}){/* @__PURE__ */
2
+ return e("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",...r,children:/* @__PURE__ */e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 4.5L12.8 6.7L15 7.5L12.8 8.3L12 10.5L11.2 8.3L9 7.5L11.2 6.7ZM7.5 13.5h9a0.75 0.75 0 0 1 0 1.5h-9a0.75 0.75 0 0 1 0 -1.5ZM9.375 18h5.25a0.75 0.75 0 0 1 0 1.5h-5.25a0.75 0.75 0 0 1 0 -1.5Z"})})}export{i as IconAboveTextSolidIcon};