efficient-shell 4.175.0 → 4.179.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 (70) hide show
  1. package/README.md +426 -6
  2. package/dist/{Browser-PZIVSYLM.js → Browser-LZMLL4CZ.js} +14 -14
  3. package/dist/Calculator-R5OEHQ67.js +29 -0
  4. package/dist/ConfirmDialog-CMNQZQA3.js +1 -0
  5. package/dist/{CurrencyConverter-4RZZ5STO.js → CurrencyConverter-AMXUOQR2.js} +7 -7
  6. package/dist/{Documents-ERSFDOCV.js → Documents-M4HKZAPJ.js} +12 -12
  7. package/dist/{Files-3J2DW6ET.js → Files-OY5GKCXA.js} +24 -24
  8. package/dist/Notepad-JLDNTMVB.js +25 -0
  9. package/dist/PdfViewer-3SC3LE4U.js +1 -0
  10. package/dist/{PomodoroTimer-D6VQJICB.js → PomodoroTimer-LE6J2KUU.js} +24 -24
  11. package/dist/Preview-2KHLL6NP.js +188 -0
  12. package/dist/{Sidebar-2BZJ2MEI.js → Sidebar-BQ4P5LBI.js} +25 -25
  13. package/dist/Spreadsheet-B5Z5MSX4.js +37 -0
  14. package/dist/{Stock-KRPM6NSB.js → Stock-GWVG2INU.js} +4 -4
  15. package/dist/{Weather-HRH4JHTF.js → Weather-APBCG4TO.js} +13 -13
  16. package/dist/{WorldClock-OUSV52XM.js → WorldClock-2LMZYKWR.js} +7 -7
  17. package/dist/apps/index.d.ts +4 -2
  18. package/dist/apps/index.js +1 -1
  19. package/dist/bin/ui-check.js +1 -1
  20. package/dist/{chunk-L3U2R7DH.js → chunk-3DGTIWZP.js} +1 -1
  21. package/dist/{chunk-6BZCJQCT.js → chunk-47VJNVB6.js} +643 -643
  22. package/dist/{chunk-KS7OSQ3Y.js → chunk-5ZDM6WIC.js} +11 -11
  23. package/dist/{chunk-E2D54MVV.js → chunk-6CFBF543.js} +2 -2
  24. package/dist/{chunk-LCTSBQBJ.js → chunk-7WZEFHPS.js} +1 -1
  25. package/dist/{chunk-PGVUO7GB.js → chunk-AA4TMQOS.js} +3 -3
  26. package/dist/chunk-AZURXTRB.js +1 -0
  27. package/dist/chunk-C3QOHMR6.js +1 -0
  28. package/dist/{chunk-YJRC6IKD.js → chunk-CIXQKCFA.js} +4 -4
  29. package/dist/chunk-CZK2VKIO.js +9 -0
  30. package/dist/{chunk-KG4NRNFS.js → chunk-FORN7LG7.js} +1 -1
  31. package/dist/chunk-J3LIIIHJ.js +1 -0
  32. package/dist/chunk-KDRAU4XQ.js +27 -0
  33. package/dist/{chunk-ZOPYAOUP.js → chunk-KVOFUFPP.js} +1 -1
  34. package/dist/{chunk-KDHXRJIX.js → chunk-LK7V32MR.js} +1 -1
  35. package/dist/{chunk-GCO3A63X.js → chunk-N6STBYXR.js} +111 -111
  36. package/dist/{chunk-54OP3M3K.js → chunk-NHIGOEZF.js} +1 -1
  37. package/dist/{chunk-EXXHI5DO.js → chunk-OGXU7QFW.js} +2 -2
  38. package/dist/{chunk-JOOXVX4A.js → chunk-PE4F4MJE.js} +4 -4
  39. package/dist/chunk-R7EBJKN2.js +69 -0
  40. package/dist/{chunk-TMQEH7WA.js → chunk-SVO3ES2E.js} +1 -1
  41. package/dist/{chunk-RKR5V4QR.js → chunk-T4CFSGSL.js} +6 -6
  42. package/dist/{chunk-D3UQLWIZ.js → chunk-UAIVAA5X.js} +11 -11
  43. package/dist/{chunk-REXHKIIJ.js → chunk-WNEO7TSP.js} +1 -1
  44. package/dist/{chunk-XJYXKO7K.js → chunk-ZAE6ROV7.js} +15 -15
  45. package/dist/file-intake/index.js +1 -1
  46. package/dist/i18n/index.d.ts +79 -0
  47. package/dist/i18n/index.js +2 -0
  48. package/dist/{index-DIaav9a1.d.ts → index-DcUj0nXY.d.ts} +39 -927
  49. package/dist/index.d.ts +3 -2
  50. package/dist/index.js +656 -656
  51. package/dist/locales/zh-Hans.d.ts +59 -0
  52. package/dist/locales/zh-Hans.js +1 -0
  53. package/dist/map/index.js +3 -3
  54. package/dist/page-tabs/index.js +5 -5
  55. package/dist/pdf/index.js +1 -1
  56. package/dist/strings-ZbotP_I6.d.ts +1292 -0
  57. package/dist/ui/index.d.ts +2 -1
  58. package/dist/ui/index.js +1 -1
  59. package/package.json +21 -1
  60. package/dist/Calculator-6BJVESFN.js +0 -29
  61. package/dist/ConfirmDialog-6PVUVYXZ.js +0 -1
  62. package/dist/Notepad-MVMFJE2F.js +0 -25
  63. package/dist/PdfViewer-RKRGO7Q2.js +0 -1
  64. package/dist/Preview-VIHMVC7B.js +0 -187
  65. package/dist/Spreadsheet-KTB6JLBV.js +0 -37
  66. package/dist/chunk-3YTHR7IC.js +0 -1
  67. package/dist/chunk-7LAPNAKS.js +0 -1
  68. package/dist/chunk-FEK5ELXS.js +0 -27
  69. package/dist/chunk-VIIBZ6DE.js +0 -69
  70. package/dist/chunk-VRLHUZSC.js +0 -9
@@ -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,readdirSync as r}from"fs";var a=["button","input","range","textarea","select","dialog","title","portal","native","dark","hex","radius","kit","icon","kit-dep"],l=e=>"string"==typeof e&&a.includes(e),c={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 shell token or a Tailwind palette class (harness FT-1)"},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)"},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 set the theme chose (harness UI-24)"},"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)"}},d=["@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"],u=["@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"],f={"efficient-shell":["@headlessui/react","@heroicons/react"],"efficient-shell/apps":["@heroicons/react"],"efficient-shell/icons/heroicons":["@heroicons/react"],"efficient-shell/icons/lucide":["lucide-react"]};function h(e,t){return t.some(t=>t.endsWith("/")||t.endsWith("-")?e.startsWith(t):e===t||e.startsWith(`${t}/`))}function p(e){return h(e,u)?"icon":h(e,d)?"kit":null}var m=/[.+^$()|[\]\\]/g;function g(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(m,"\\$&")}if(0!==n)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${t}$`)}function k(e){const t=e.map(g);return e=>t.some(t=>t.test(e))}var $=new Set(["node_modules",".git"]),w=new Set(["dist","coverage",".next",".turbo"]);function b(e){const t=e.search(/[*?{]/),n=-1===t?e:e.slice(0,t),i=n.lastIndexOf("/");return-1===i?"":n.slice(0,i)}function y(e,t){const i=k(t),o=[...new Set(t.map(b))].sort(),s=o.filter(e=>!o.some(t=>t!==e&&(""===t||e.startsWith(`${t}/`)))),a=new Set,l=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?$.has(e.name)||""===t&&w.has(e.name)||l(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)l(e);return[...a].sort(x)}var x=(e,t)=>e<t?-1:e>t?1:0,v=class extends Error{},S=(e,t)=>`${e}:${t}`;function j(e){const t=e.lastIndexOf(":");return{file:e.slice(0,t),kind:e.slice(t+1)}}var I=e=>a.indexOf(e);function T(e,t){const n=j(e),i=j(t);return x(n.file,i.file)||I(n.kind)-I(i.kind)}function A(e,t="ui-kit.baseline.json"){let n;try{n=JSON.parse(e)}catch(e){throw new v(`${t} is not valid JSON: ${e.message}`)}const i=e=>{throw new v(`${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(l);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}=j(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)`);l(o)&&r.set(e,t)}return{kinds:s,counts:r}}function E(e){const t=a.filter(t=>e.kinds.includes(t)),n=[...e.counts.keys()].filter(t=>(e.counts.get(t)??0)>0).sort(T).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 M(e){const t={};for(const[n,i]of e){const{kind:e}=j(n);l(e)&&(t[e]=(t[e]??0)+i)}return t}var O=class extends Error{},D=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),N=new Set(["$schema","schema","kinds","include","exclude","includeImporting","output","allow"]);var R="package.json",L=new Set(["iframe","frame","object","embed"]),F=new Set(["href","xlinkHref","to","id","key","htmlFor"]),J=/(?<![&\w])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,P=/(?<![\w-])rounded(?:-(?:[trblse]|tl|tr|br|bl|ss|se|ee|es))?-\[([^\]]*)\]/g,U=/^border(?:(?:Top|Bottom)(?:Left|Right)|(?:Start|End)(?:Start|End))?Radius$/,B=/^(?:inherit|initial|unset|revert)$|var\(|^(?:50|100)%$|^(?:999|9999)(?:px)?$/,W=/(?<![\w-])dark:(?=[\w[\-!@*(])/g,C=new Set(["confirm","alert","prompt"]),q=new Set(["window","globalThis","self"]);function z(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,t)=>{var n;s.has(e)&&(a[e]??=[]).push((n=t.getStart(r),r.getLineAndCharacterOfPosition(n).line+1))},d=(t,n)=>t.attributes.properties.find(t=>e.isJsxAttribute(t)&&t.name.getText(r)===n),u=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))C.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 h=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?p(e):null;n&&c(n,t)},g=(e,t,n)=>{if(s.has("dark"))for(const n of e.matchAll(W))c("dark",t);if(s.has("radius"))for(const n of e.matchAll(P))B.test(n[1].trim())||c("radius",t);if(n&&l&&s.has("hex"))for(const n of e.matchAll(J))c("hex",t)},k=(t,n)=>{if(e.isJsxOpeningElement(t)||e.isJsxSelfClosingElement(t)){const e=t.tagName.getText(r);if(/^[a-z]/.test(e)){const n=u(d(t,"type"));"button"===e?c("button",t):"select"===e?c("select",t):"textarea"===e?c("textarea",t):"input"===e&&("range"===n?c("range",t):"hidden"!==n&&c("input",t));const i=u(d(t,"role"));"dialog"!==e&&"dialog"!==i&&"alertdialog"!==i||c("dialog",t),!L.has(e)&&d(t,"title")&&c("title",t)}}else if(e.isCallExpression(t)){const n=t.expression;e.isIdentifier(n)?"createPortal"===n.text?c("portal",t):C.has(n.text)&&!f.has(n.text)?c("native",t):"require"===n.text&&m(h(t.arguments[0]),t):e.isPropertyAccessExpression(n)?"createPortal"===n.name.text?c("portal",t):C.has(n.name.text)&&e.isIdentifier(n.expression)&&q.has(n.expression.text)&&c("native",t):n.kind===e.SyntaxKind.ImportKeyword&&m(h(t.arguments[0]),t)}else{if(e.isImportDeclaration(t)||e.isExportDeclaration(t))return void m(h(t.moduleSpecifier),t);if(e.isPropertyAssignment(t)&&s.has("radius")){const n=e.isIdentifier(t.name)||e.isStringLiteralLike(t.name)?t.name.text:"",i=t.initializer;U.test(n)&&(e.isNumericLiteral(i)?B.test(i.text)||c("radius",t):e.isStringLiteralLike(i)&&!B.test(i.text.trim())&&c("radius",t))}else if(e.isStringLiteralLike(t))g(t.text,t,n);else if(e.isTemplateExpression(t)){g(t.head.text,t.head,n);for(const e of t.templateSpans)g(e.literal.text,e.literal,n)}}e.isJsxAttribute(t)&&F.has(t.name.getText(r))?e.forEachChild(t,e=>k(e,!1)):e.forEachChild(t,e=>k(e,n))};return k(r,!0),a}function K(e){const t={};for(const[n,i]of Object.entries(e))i.length&&(t[n]=i.length);return t}function G(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}var _=(e,t)=>e.some(e=>t.some(t=>t.endsWith("/*")?e.startsWith(t.slice(0,-1)):e===t));var H=e=>new Map(e.allow.map(e=>[S(e.file,e.kind),e.count]));function X(e,t){return e.kinds.filter(e=>t.kinds.includes(e))}var V=(e,t,n)=>{if("kit-dep"===n)return` (${e.kitDeps.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 Q(e,t,n){const i=H(e),o=new Map;for(const[e,s]of t.counts){const{kind:t}=j(e);if(!l(t)||!n.includes(t))continue;const r=s-(i.get(e)??0);r>0&&o.set(e,r)}return{kinds:a.filter(e=>n.includes(e)),counts:o}}function Y(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 Z="\n// <button> in a comment is not a button\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';\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 r = lazy(() => import('@mui/material'));\nconst s = require('react-select');\n",ee={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:4,icon:3},te={kit:1,dark:1,portal:1,radius:2},ne=e=>a.filter(t=>e[t]).map(t=>`${t} ${e[t]}`).join(", ")||"nothing";var ie="ui-kit.config.json",oe="ui-kit.baseline.json",se="efficient-shell-ui-check",re=`${se}: every surface a person operates takes its UI from efficient-shell (harness UI-24).\n\n ${se} check this repository against ${oe}\n ${se} --print print today's counts as a baseline, and change nothing\n ${se} --summary print totals per kind and per folder, as Markdown\n ${se} --json print the result as JSON\n ${se} --update lower the lines whose counts fell, and delete the ones at zero\n ${se} --update --allow-move also follow a renamed or split file (no total may rise)\n ${se} --init write the first ${oe}\n ${se} --init --kind <kind> take the baseline for a kind just added to "kinds"\n ${se} --no-base do not compare with the pull request's base branch\n\nKinds: ${a.join(", ")}\nReads ${ie} in the current directory.`;var ae=(e,t)=>`${e} ${t}${1===e?"":"s"}`,le=(e,t)=>{const n=M(e);return t.map(e=>`${e} ${n[e]??0}`).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(`${se}: ${r}\n\n${re}`),2;if(r.help)return t.out(re),0;if(r.version)return t.out(t.version),0;const d=e=>(r.json?t.out(JSON.stringify({tool:se,version:t.version,ok:!1,failures:[e]},null,2)):t.err(`${se}: ${e}`),1),u=n(t.cwd,ie);if(!i(u))return d(`no ${ie} in ${t.cwd}. Run it from the repository root; the harness has the template.`);let h,m;try{h=function(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=>!D(e))?(i(`${t} must be a list of objects`),[]):e;if(!D(e))throw new O(`${t}: must be a JSON object`);for(const t of Object.keys(e))N.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 c=[];if(Array.isArray(e.kinds)&&0!==e.kinds.length)for(const t of e.kinds)l(t)?c.includes(t)?i(`"kinds": "${t}" is listed twice`):c.push(t):i(`"kinds": unknown kind ${JSON.stringify(t)} (this efficient-shell knows: ${a.join(", ")})`);else i(`"kinds" must list the kinds this repository checks, from: ${a.join(", ")}`);const d=o(e.include,'"include"'),u=o(e.exclude,'"exclude"'),f=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===f.length&&i('"include" must name the files that are operator UI (for example ["src/**/*.tsx"])');const h=r(e.output,'"output"').map((e,t)=>({files:o(e.files,`"output"[${t}].files`,{required:!0}),reason:s(e.reason,`"output"[${t}]`)})),p=[],m=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(!l(e.kind))return void i(`${n}.kind must be one of: ${a.join(", ")}`);if(c.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}`;m.has(u)&&i(`${n}: ${r} already has an allow entry for "${e.kind}"`),m.add(u),p.push({file:r,kind:e.kind,count:e.count,reason:d})}),n.length)throw new O(`${t}:\n - ${n.join("\n - ")}`);return{schema:1,kinds:a.filter(e=>c.includes(e)),include:d,exclude:u,includeImporting:f,output:h,allow:p}}(JSON.parse(o(u,"utf8")),ie)}catch(e){return d(e instanceof O?e.message:`${ie} is not valid JSON: ${e.message}`)}try{m=t.loadTypeScript()}catch{return d('this check reads the TypeScript AST and found no "typescript" package here. Install it as a devDependency.')}const g=function(e){const t=[],n=a.filter(e=>"kit-dep"!==e),i=[["fixture.tsx",Z,ee],["fixture.ts","\nimport { toast } from 'sonner';\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",te]];for(const[o,s,r]of i){const i=K(z(e,o,s,n));n.some(e=>(i[e]??0)!==(r[e]??0))&&t.push(`${o}: read ${ne(i)}; it holds ${ne(r)}`)}const o=K(z(e,"fixture.tsx",Z,["button"]));return"button"!==Object.keys(o).join()&&t.push(`asked for button alone, the reader reported ${ne(o)}`),t}(m);if(g.length)return d(`the reader misread its own fixtures with typescript ${m.version}, so nothing it says about this repository can be trusted:\n - `+g.join("\n - "));const $=function(e,t,s){const r=[],a=k(s.exclude),l=k(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},u=(e,n)=>{for(const i of e)0===y(t,[i]).length&&r.push(`${n}: "${i}" matches no file. Delete the line, or fix the path.`)};u(s.include,'"include"'),s.output.forEach((e,t)=>u(e.files,`"output"[${t}]`)),s.includeImporting.forEach((e,t)=>u(e.files,`"includeImporting"[${t}]`));const h=new Set,m=e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!a(e)&&!l(e);for(const e of y(t,s.include))m(e)&&h.add(e);for(const n of s.includeImporting)for(const i of y(t,n.files))m(i)&&!h.has(i)&&_(G(e,i,d(i)),n.modules)&&h.add(i);const g=[...h].sort(),$=s.kinds.filter(e=>"kit-dep"!==e),w=new Map,b=new Map,x=new Set;for(const t of g){const n=z(e,t,d(t),$,x);let i=!1;for(const e of $){const o=n[e]?.length??0;o&&(b.set(S(t,e),o),i=!0)}i&&w.set(t,n)}let v=[],j=[];if(s.kinds.includes("kit-dep")){const e=n(t,R);if(i(e)){const t=JSON.parse(o(e,"utf8")),n=["dependencies","peerDependencies","optionalDependencies"].flatMap(e=>Object.keys(t[e]??{})),i=new Set([...x].flatMap(e=>f[e]??[])),s=[...new Set(n)].filter(e=>null!==p(e)).sort();v=s.filter(e=>!i.has(e)),j=s.filter(e=>i.has(e)),v.length&&b.set(S(R,"kit-dep"),v.length)}else r.push(`"kinds" includes "kit-dep", and there is no ${R} here to read.`)}for(const e of s.allow)("kit-dep"===e.kind?e.file===R:h.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:g,hits:w,counts:b,kitDeps:v,shellPeers:j,problems:r}}(m,t.cwd,h);if(0===$.files.length)return d(`read no files. "include" in ${ie} matches nothing, so a pass would mean nothing.`);const w=n(t.cwd,oe),b=r.json,x=e=>{b||t.out(e)};if(r.print)return t.out(E(Q(h,$,h.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}=j(e);if(!l(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("/"),c=a.length>2?a.slice(0,2).join("/"):2===a.length?a[0]:".",d=i.get(c)??{};d[s]=(d[s]??0)+o,i.set(c,d)}const o=e.kinds.filter(e=>n.has(e)),s=[`**UI kit check (harness UI-24):** ${new Set([...t.counts.keys()].map(e=>j(e).file)).size} of ${ae(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} | ${c[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}(h,$))t.out(e);return 0}let I=null;if(i(w))try{I=A(o(w,"utf8"),oe)}catch(e){return d(e instanceof v?e.message:String(e))}if(r.init){const e=r.kinds.filter(e=>!l(e)||!h.kinds.includes(e));if(e.length)return d(`--kind ${e.join(", ")}: not in "kinds" in ${ie}. Add it there first.`);const t=r.kinds;if(I){if(0===t.length)return d(`${oe} 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=>I.kinds.includes(e));if(e.length)return d(`the baseline was already taken for ${e.join(", ")}. Its lines only go down; use --update.`);const n=Q(h,$,t);I={kinds:[...I.kinds,...t],counts:new Map([...I.counts,...n.counts])}}else{if(t.length)return d(`there is no ${oe} yet. Run --init on its own first.`);I=Q(h,$,h.kinds)}s(w,E(I)),x(`${se}: wrote ${oe} (${ae(I.counts.size,"line")}: ${le(I.counts,I.kinds)})`)}if(!I)return d(`no ${oe}. This repository has not adopted the check yet: run ${se} --init, and commit the file.`);if(r.update){const e=function(e,t,n,{allowMove:i=!1}={}){const o=X(e,t),s=Q(e,n,o),r=new Map([...t.counts].filter(([e])=>o.includes(j(e).kind)));if(i){const e=M(r),n=M(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:Y(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:Y(r,a),refused:[]}}(h,I,$,{allowMove:r.allowMove});if(e.refused.length)return d(`--allow-move follows code that moved, and this is more of it than before:\n - ${e.refused.join("\n - ")}\nNothing was written.`);I=e.baseline,s(w,E(I)),x(`${se}: ${e.lowered?`changed ${ae(e.lowered,"line")} in`:"nothing to change in"} ${oe}`)}const L=function(e,t,n){const i=[],o=[],s=[...n.problems],r=H(e),a=new Set(X(e,t)),d=e.kinds.filter(e=>!t.kinds.includes(e));d.length&&s.push(`"kinds" names ${d.map(e=>`"${e}"`).join(", ")}, and the baseline was never taken for ${1===d.length?"it":"them"}. Run: efficient-shell-ui-check --init ${d.map(e=>`--kind ${e}`).join(" ")}`);const u=t.kinds.filter(t=>!e.kinds.includes(t));u.length&&o.push(`the baseline still carries ${u.map(e=>`"${e}"`).join(", ")}, which "kinds" no longer names`);const f=new Set([...n.counts.keys(),...t.counts.keys(),...r.keys()]);for(const e of[...f].sort(T)){const{file:d,kind:u}=j(e);if(!l(u)||!a.has(u))continue;const f=n.counts.get(e)??0,h=r.get(e)??0,p=t.counts.get(e)??0;f>h+p?i.push(`${d}: ${u} ${f}, and its line allows ${h+p}${V(n,d,u)}. ${c[u].counts} is counted; use ${c[u].instead}.`):f<h?s.push(`${d}: ${u} ${f}, and "allow" in ui-kit.config.json says ${h}. ${0===f?"Delete the entry":`Lower its count to ${f}`}: an exception does not outlive what it excused.`):f<h+p&&o.push(`${d}: ${u} ${f}, and its line says ${h+p}`)}return{grown:i,shrunk:o,other:s,updateFixes:0===i.length&&0===s.length&&o.length>0}}(h,I,$),F=r.noBase?{problems:[],note:""}:function(e,t,n){const i=e.env.GITHUB_BASE_REF;if(!i)return{problems:[],note:""};const o=e.git(["rev-parse","--show-prefix"]);if(null===o)return{problems:[],note:"not a git checkout; the base branch was not compared"};const s=`origin/${i}`;if(null===e.git(["rev-parse","--verify","--quiet",`${s}^{commit}`])&&(e.git(["fetch","--no-tags","--depth=1","origin",`+refs/heads/${i}:refs/remotes/origin/${i}`]),null===e.git(["rev-parse","--verify","--quiet",`${s}^{commit}`])))return{problems:[],note:`${s} could not be fetched; the base branch was not compared`};const r=e.git(["show",`${s}:${o.trim()}${oe}`]);if(null===r)return{problems:[],note:`${s} has no ${oe} yet (adoption)`};let a;try{a=A(r,`${s}:${oe}`)}catch{return{problems:[],note:`${s}'s ${oe} could not be read; the base branch was not compared`}}const l=M(a.counts),d=M(t.counts);return{problems:n.filter(e=>a.kinds.includes(e)&&(d[e]??0)>(l[e]??0)).map(e=>`${oe} holds ${d[e]??0} of "${e}", and ${s} holds ${l[e]??0}. The baseline only goes down: use ${c[e].instead}. A count that is meant to stay goes in "allow" in ${ie}, with its reason.`),note:`compared with ${s}`}}(t,I,h.kinds),J=h.kinds.filter(e=>I.kinds.includes(e)),P=`${se} --update`,U=[...L.other,...L.grown,...L.shrunk.map(e=>`${e}. Run: ${P}`),...F.problems],B=0===U.length;if(r.json){const e=new Map(h.allow.map(e=>[`${e.file}:${e.kind}`,e.count]));return t.out(JSON.stringify({tool:se,version:t.version,ok:B,schema:h.schema,kinds:h.kinds,files:$.files.length,counts:M($.counts),baseline:M(I.counts),allowed:M(e),kitDeps:$.kitDeps,shellPeers:$.shellPeers,failures:U},null,2)),B?0:1}t.out(`UI kit check (harness UI-24), efficient-shell ${t.version}\n`);const W=(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 ${m.version})`),t.out(` ok read ${ae($.files.length,"file")}`),W(`${ie} and ${oe} describe this repository`,L.other),W("no file draws more of its own UI than its line allows",L.grown),W("every line is exact: a count that fell is a line to lower",L.shrunk,`Run: ${P}${L.updateFixes?"":" (after the failures above are fixed)"}`),F.note&&W(`the baseline is no higher than the base branch (${F.note})`,F.problems);const C=new Set([...$.counts.keys()].map(e=>j(e).file));return t.out(` ok PROGRESS: ${C.size} of ${ae($.files.length,"file")} still draw UI of their own: `+le($.counts,J)),t.out(""),B?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${ae(U.length,"problem")})`),B?0:1}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:function(){for(const e of[n(process.cwd(),"package.json"),import.meta.url])try{return t(e)("typescript")}catch{}throw new Error("typescript is not installed")},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:"4.175.0"});
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,readdirSync as r}from"fs";var a=["button","input","range","textarea","select","dialog","title","portal","native","dark","hex","radius","kit","icon","kit-dep"],l=e=>"string"==typeof e&&a.includes(e),c={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 shell token or a Tailwind palette class (harness FT-1)"},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)"},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 set the theme chose (harness UI-24)"},"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)"}},d=["@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"],u=["@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"],f={"efficient-shell":["@headlessui/react","@heroicons/react"],"efficient-shell/apps":["@heroicons/react"],"efficient-shell/icons/heroicons":["@heroicons/react"],"efficient-shell/icons/lucide":["lucide-react"]};function h(e,t){return t.some(t=>t.endsWith("/")||t.endsWith("-")?e.startsWith(t):e===t||e.startsWith(`${t}/`))}function p(e){return h(e,u)?"icon":h(e,d)?"kit":null}var m=/[.+^$()|[\]\\]/g;function g(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(m,"\\$&")}if(0!==n)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${t}$`)}function k(e){const t=e.map(g);return e=>t.some(t=>t.test(e))}var $=new Set(["node_modules",".git"]),w=new Set(["dist","coverage",".next",".turbo"]);function b(e){const t=e.search(/[*?{]/),n=-1===t?e:e.slice(0,t),i=n.lastIndexOf("/");return-1===i?"":n.slice(0,i)}function y(e,t){const i=k(t),o=[...new Set(t.map(b))].sort(),s=o.filter(e=>!o.some(t=>t!==e&&(""===t||e.startsWith(`${t}/`)))),a=new Set,l=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?$.has(e.name)||""===t&&w.has(e.name)||l(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)l(e);return[...a].sort(x)}var x=(e,t)=>e<t?-1:e>t?1:0,v=class extends Error{},S=(e,t)=>`${e}:${t}`;function j(e){const t=e.lastIndexOf(":");return{file:e.slice(0,t),kind:e.slice(t+1)}}var I=e=>a.indexOf(e);function T(e,t){const n=j(e),i=j(t);return x(n.file,i.file)||I(n.kind)-I(i.kind)}function A(e,t="ui-kit.baseline.json"){let n;try{n=JSON.parse(e)}catch(e){throw new v(`${t} is not valid JSON: ${e.message}`)}const i=e=>{throw new v(`${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(l);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}=j(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)`);l(o)&&r.set(e,t)}return{kinds:s,counts:r}}function E(e){const t=a.filter(t=>e.kinds.includes(t)),n=[...e.counts.keys()].filter(t=>(e.counts.get(t)??0)>0).sort(T).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 M(e){const t={};for(const[n,i]of e){const{kind:e}=j(n);l(e)&&(t[e]=(t[e]??0)+i)}return t}var O=class extends Error{},D=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),N=new Set(["$schema","schema","kinds","include","exclude","includeImporting","output","allow"]);var R="package.json",L=new Set(["iframe","frame","object","embed"]),F=new Set(["href","xlinkHref","to","id","key","htmlFor"]),J=/(?<![&\w])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,P=/(?<![\w-])rounded(?:-(?:[trblse]|tl|tr|br|bl|ss|se|ee|es))?-\[([^\]]*)\]/g,U=/^border(?:(?:Top|Bottom)(?:Left|Right)|(?:Start|End)(?:Start|End))?Radius$/,B=/^(?:inherit|initial|unset|revert)$|var\(|^(?:50|100)%$|^(?:999|9999)(?:px)?$/,W=/(?<![\w-])dark:(?=[\w[\-!@*(])/g,C=new Set(["confirm","alert","prompt"]),q=new Set(["window","globalThis","self"]);function z(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,t)=>{var n;s.has(e)&&(a[e]??=[]).push((n=t.getStart(r),r.getLineAndCharacterOfPosition(n).line+1))},d=(t,n)=>t.attributes.properties.find(t=>e.isJsxAttribute(t)&&t.name.getText(r)===n),u=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))C.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 h=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?p(e):null;n&&c(n,t)},g=(e,t,n)=>{if(s.has("dark"))for(const n of e.matchAll(W))c("dark",t);if(s.has("radius"))for(const n of e.matchAll(P))B.test(n[1].trim())||c("radius",t);if(n&&l&&s.has("hex"))for(const n of e.matchAll(J))c("hex",t)},k=(t,n)=>{if(e.isJsxOpeningElement(t)||e.isJsxSelfClosingElement(t)){const e=t.tagName.getText(r);if(/^[a-z]/.test(e)){const n=u(d(t,"type"));"button"===e?c("button",t):"select"===e?c("select",t):"textarea"===e?c("textarea",t):"input"===e&&("range"===n?c("range",t):"hidden"!==n&&c("input",t));const i=u(d(t,"role"));"dialog"!==e&&"dialog"!==i&&"alertdialog"!==i||c("dialog",t),!L.has(e)&&d(t,"title")&&c("title",t)}}else if(e.isCallExpression(t)){const n=t.expression;e.isIdentifier(n)?"createPortal"===n.text?c("portal",t):C.has(n.text)&&!f.has(n.text)?c("native",t):"require"===n.text&&m(h(t.arguments[0]),t):e.isPropertyAccessExpression(n)?"createPortal"===n.name.text?c("portal",t):C.has(n.name.text)&&e.isIdentifier(n.expression)&&q.has(n.expression.text)&&c("native",t):n.kind===e.SyntaxKind.ImportKeyword&&m(h(t.arguments[0]),t)}else{if(e.isImportDeclaration(t)||e.isExportDeclaration(t))return void m(h(t.moduleSpecifier),t);if(e.isPropertyAssignment(t)&&s.has("radius")){const n=e.isIdentifier(t.name)||e.isStringLiteralLike(t.name)?t.name.text:"",i=t.initializer;U.test(n)&&(e.isNumericLiteral(i)?B.test(i.text)||c("radius",t):e.isStringLiteralLike(i)&&!B.test(i.text.trim())&&c("radius",t))}else if(e.isStringLiteralLike(t))g(t.text,t,n);else if(e.isTemplateExpression(t)){g(t.head.text,t.head,n);for(const e of t.templateSpans)g(e.literal.text,e.literal,n)}}e.isJsxAttribute(t)&&F.has(t.name.getText(r))?e.forEachChild(t,e=>k(e,!1)):e.forEachChild(t,e=>k(e,n))};return k(r,!0),a}function K(e){const t={};for(const[n,i]of Object.entries(e))i.length&&(t[n]=i.length);return t}function G(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}var _=(e,t)=>e.some(e=>t.some(t=>t.endsWith("/*")?e.startsWith(t.slice(0,-1)):e===t));var H=e=>new Map(e.allow.map(e=>[S(e.file,e.kind),e.count]));function X(e,t){return e.kinds.filter(e=>t.kinds.includes(e))}var V=(e,t,n)=>{if("kit-dep"===n)return` (${e.kitDeps.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 Q(e,t,n){const i=H(e),o=new Map;for(const[e,s]of t.counts){const{kind:t}=j(e);if(!l(t)||!n.includes(t))continue;const r=s-(i.get(e)??0);r>0&&o.set(e,r)}return{kinds:a.filter(e=>n.includes(e)),counts:o}}function Y(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 Z="\n// <button> in a comment is not a button\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';\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 r = lazy(() => import('@mui/material'));\nconst s = require('react-select');\n",ee={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:4,icon:3},te={kit:1,dark:1,portal:1,radius:2},ne=e=>a.filter(t=>e[t]).map(t=>`${t} ${e[t]}`).join(", ")||"nothing";var ie="ui-kit.config.json",oe="ui-kit.baseline.json",se="efficient-shell-ui-check",re=`${se}: every surface a person operates takes its UI from efficient-shell (harness UI-24).\n\n ${se} check this repository against ${oe}\n ${se} --print print today's counts as a baseline, and change nothing\n ${se} --summary print totals per kind and per folder, as Markdown\n ${se} --json print the result as JSON\n ${se} --update lower the lines whose counts fell, and delete the ones at zero\n ${se} --update --allow-move also follow a renamed or split file (no total may rise)\n ${se} --init write the first ${oe}\n ${se} --init --kind <kind> take the baseline for a kind just added to "kinds"\n ${se} --no-base do not compare with the pull request's base branch\n\nKinds: ${a.join(", ")}\nReads ${ie} in the current directory.`;var ae=(e,t)=>`${e} ${t}${1===e?"":"s"}`,le=(e,t)=>{const n=M(e);return t.map(e=>`${e} ${n[e]??0}`).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(`${se}: ${r}\n\n${re}`),2;if(r.help)return t.out(re),0;if(r.version)return t.out(t.version),0;const d=e=>(r.json?t.out(JSON.stringify({tool:se,version:t.version,ok:!1,failures:[e]},null,2)):t.err(`${se}: ${e}`),1),u=n(t.cwd,ie);if(!i(u))return d(`no ${ie} in ${t.cwd}. Run it from the repository root; the harness has the template.`);let h,m;try{h=function(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=>!D(e))?(i(`${t} must be a list of objects`),[]):e;if(!D(e))throw new O(`${t}: must be a JSON object`);for(const t of Object.keys(e))N.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 c=[];if(Array.isArray(e.kinds)&&0!==e.kinds.length)for(const t of e.kinds)l(t)?c.includes(t)?i(`"kinds": "${t}" is listed twice`):c.push(t):i(`"kinds": unknown kind ${JSON.stringify(t)} (this efficient-shell knows: ${a.join(", ")})`);else i(`"kinds" must list the kinds this repository checks, from: ${a.join(", ")}`);const d=o(e.include,'"include"'),u=o(e.exclude,'"exclude"'),f=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===f.length&&i('"include" must name the files that are operator UI (for example ["src/**/*.tsx"])');const h=r(e.output,'"output"').map((e,t)=>({files:o(e.files,`"output"[${t}].files`,{required:!0}),reason:s(e.reason,`"output"[${t}]`)})),p=[],m=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(!l(e.kind))return void i(`${n}.kind must be one of: ${a.join(", ")}`);if(c.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}`;m.has(u)&&i(`${n}: ${r} already has an allow entry for "${e.kind}"`),m.add(u),p.push({file:r,kind:e.kind,count:e.count,reason:d})}),n.length)throw new O(`${t}:\n - ${n.join("\n - ")}`);return{schema:1,kinds:a.filter(e=>c.includes(e)),include:d,exclude:u,includeImporting:f,output:h,allow:p}}(JSON.parse(o(u,"utf8")),ie)}catch(e){return d(e instanceof O?e.message:`${ie} is not valid JSON: ${e.message}`)}try{m=t.loadTypeScript()}catch{return d('this check reads the TypeScript AST and found no "typescript" package here. Install it as a devDependency.')}const g=function(e){const t=[],n=a.filter(e=>"kit-dep"!==e),i=[["fixture.tsx",Z,ee],["fixture.ts","\nimport { toast } from 'sonner';\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",te]];for(const[o,s,r]of i){const i=K(z(e,o,s,n));n.some(e=>(i[e]??0)!==(r[e]??0))&&t.push(`${o}: read ${ne(i)}; it holds ${ne(r)}`)}const o=K(z(e,"fixture.tsx",Z,["button"]));return"button"!==Object.keys(o).join()&&t.push(`asked for button alone, the reader reported ${ne(o)}`),t}(m);if(g.length)return d(`the reader misread its own fixtures with typescript ${m.version}, so nothing it says about this repository can be trusted:\n - `+g.join("\n - "));const $=function(e,t,s){const r=[],a=k(s.exclude),l=k(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},u=(e,n)=>{for(const i of e)0===y(t,[i]).length&&r.push(`${n}: "${i}" matches no file. Delete the line, or fix the path.`)};u(s.include,'"include"'),s.output.forEach((e,t)=>u(e.files,`"output"[${t}]`)),s.includeImporting.forEach((e,t)=>u(e.files,`"includeImporting"[${t}]`));const h=new Set,m=e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!a(e)&&!l(e);for(const e of y(t,s.include))m(e)&&h.add(e);for(const n of s.includeImporting)for(const i of y(t,n.files))m(i)&&!h.has(i)&&_(G(e,i,d(i)),n.modules)&&h.add(i);const g=[...h].sort(),$=s.kinds.filter(e=>"kit-dep"!==e),w=new Map,b=new Map,x=new Set;for(const t of g){const n=z(e,t,d(t),$,x);let i=!1;for(const e of $){const o=n[e]?.length??0;o&&(b.set(S(t,e),o),i=!0)}i&&w.set(t,n)}let v=[],j=[];if(s.kinds.includes("kit-dep")){const e=n(t,R);if(i(e)){const t=JSON.parse(o(e,"utf8")),n=["dependencies","peerDependencies","optionalDependencies"].flatMap(e=>Object.keys(t[e]??{})),i=new Set([...x].flatMap(e=>f[e]??[])),s=[...new Set(n)].filter(e=>null!==p(e)).sort();v=s.filter(e=>!i.has(e)),j=s.filter(e=>i.has(e)),v.length&&b.set(S(R,"kit-dep"),v.length)}else r.push(`"kinds" includes "kit-dep", and there is no ${R} here to read.`)}for(const e of s.allow)("kit-dep"===e.kind?e.file===R:h.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:g,hits:w,counts:b,kitDeps:v,shellPeers:j,problems:r}}(m,t.cwd,h);if(0===$.files.length)return d(`read no files. "include" in ${ie} matches nothing, so a pass would mean nothing.`);const w=n(t.cwd,oe),b=r.json,x=e=>{b||t.out(e)};if(r.print)return t.out(E(Q(h,$,h.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}=j(e);if(!l(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("/"),c=a.length>2?a.slice(0,2).join("/"):2===a.length?a[0]:".",d=i.get(c)??{};d[s]=(d[s]??0)+o,i.set(c,d)}const o=e.kinds.filter(e=>n.has(e)),s=[`**UI kit check (harness UI-24):** ${new Set([...t.counts.keys()].map(e=>j(e).file)).size} of ${ae(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} | ${c[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}(h,$))t.out(e);return 0}let I=null;if(i(w))try{I=A(o(w,"utf8"),oe)}catch(e){return d(e instanceof v?e.message:String(e))}if(r.init){const e=r.kinds.filter(e=>!l(e)||!h.kinds.includes(e));if(e.length)return d(`--kind ${e.join(", ")}: not in "kinds" in ${ie}. Add it there first.`);const t=r.kinds;if(I){if(0===t.length)return d(`${oe} 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=>I.kinds.includes(e));if(e.length)return d(`the baseline was already taken for ${e.join(", ")}. Its lines only go down; use --update.`);const n=Q(h,$,t);I={kinds:[...I.kinds,...t],counts:new Map([...I.counts,...n.counts])}}else{if(t.length)return d(`there is no ${oe} yet. Run --init on its own first.`);I=Q(h,$,h.kinds)}s(w,E(I)),x(`${se}: wrote ${oe} (${ae(I.counts.size,"line")}: ${le(I.counts,I.kinds)})`)}if(!I)return d(`no ${oe}. This repository has not adopted the check yet: run ${se} --init, and commit the file.`);if(r.update){const e=function(e,t,n,{allowMove:i=!1}={}){const o=X(e,t),s=Q(e,n,o),r=new Map([...t.counts].filter(([e])=>o.includes(j(e).kind)));if(i){const e=M(r),n=M(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:Y(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:Y(r,a),refused:[]}}(h,I,$,{allowMove:r.allowMove});if(e.refused.length)return d(`--allow-move follows code that moved, and this is more of it than before:\n - ${e.refused.join("\n - ")}\nNothing was written.`);I=e.baseline,s(w,E(I)),x(`${se}: ${e.lowered?`changed ${ae(e.lowered,"line")} in`:"nothing to change in"} ${oe}`)}const L=function(e,t,n){const i=[],o=[],s=[...n.problems],r=H(e),a=new Set(X(e,t)),d=e.kinds.filter(e=>!t.kinds.includes(e));d.length&&s.push(`"kinds" names ${d.map(e=>`"${e}"`).join(", ")}, and the baseline was never taken for ${1===d.length?"it":"them"}. Run: efficient-shell-ui-check --init ${d.map(e=>`--kind ${e}`).join(" ")}`);const u=t.kinds.filter(t=>!e.kinds.includes(t));u.length&&o.push(`the baseline still carries ${u.map(e=>`"${e}"`).join(", ")}, which "kinds" no longer names`);const f=new Set([...n.counts.keys(),...t.counts.keys(),...r.keys()]);for(const e of[...f].sort(T)){const{file:d,kind:u}=j(e);if(!l(u)||!a.has(u))continue;const f=n.counts.get(e)??0,h=r.get(e)??0,p=t.counts.get(e)??0;f>h+p?i.push(`${d}: ${u} ${f}, and its line allows ${h+p}${V(n,d,u)}. ${c[u].counts} is counted; use ${c[u].instead}.`):f<h?s.push(`${d}: ${u} ${f}, and "allow" in ui-kit.config.json says ${h}. ${0===f?"Delete the entry":`Lower its count to ${f}`}: an exception does not outlive what it excused.`):f<h+p&&o.push(`${d}: ${u} ${f}, and its line says ${h+p}`)}return{grown:i,shrunk:o,other:s,updateFixes:0===i.length&&0===s.length&&o.length>0}}(h,I,$),F=r.noBase?{problems:[],note:""}:function(e,t,n){const i=e.env.GITHUB_BASE_REF;if(!i)return{problems:[],note:""};const o=e.git(["rev-parse","--show-prefix"]);if(null===o)return{problems:[],note:"not a git checkout; the base branch was not compared"};const s=`origin/${i}`;if(null===e.git(["rev-parse","--verify","--quiet",`${s}^{commit}`])&&(e.git(["fetch","--no-tags","--depth=1","origin",`+refs/heads/${i}:refs/remotes/origin/${i}`]),null===e.git(["rev-parse","--verify","--quiet",`${s}^{commit}`])))return{problems:[],note:`${s} could not be fetched; the base branch was not compared`};const r=e.git(["show",`${s}:${o.trim()}${oe}`]);if(null===r)return{problems:[],note:`${s} has no ${oe} yet (adoption)`};let a;try{a=A(r,`${s}:${oe}`)}catch{return{problems:[],note:`${s}'s ${oe} could not be read; the base branch was not compared`}}const l=M(a.counts),d=M(t.counts);return{problems:n.filter(e=>a.kinds.includes(e)&&(d[e]??0)>(l[e]??0)).map(e=>`${oe} holds ${d[e]??0} of "${e}", and ${s} holds ${l[e]??0}. The baseline only goes down: use ${c[e].instead}. A count that is meant to stay goes in "allow" in ${ie}, with its reason.`),note:`compared with ${s}`}}(t,I,h.kinds),J=h.kinds.filter(e=>I.kinds.includes(e)),P=`${se} --update`,U=[...L.other,...L.grown,...L.shrunk.map(e=>`${e}. Run: ${P}`),...F.problems],B=0===U.length;if(r.json){const e=new Map(h.allow.map(e=>[`${e.file}:${e.kind}`,e.count]));return t.out(JSON.stringify({tool:se,version:t.version,ok:B,schema:h.schema,kinds:h.kinds,files:$.files.length,counts:M($.counts),baseline:M(I.counts),allowed:M(e),kitDeps:$.kitDeps,shellPeers:$.shellPeers,failures:U},null,2)),B?0:1}t.out(`UI kit check (harness UI-24), efficient-shell ${t.version}\n`);const W=(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 ${m.version})`),t.out(` ok read ${ae($.files.length,"file")}`),W(`${ie} and ${oe} describe this repository`,L.other),W("no file draws more of its own UI than its line allows",L.grown),W("every line is exact: a count that fell is a line to lower",L.shrunk,`Run: ${P}${L.updateFixes?"":" (after the failures above are fixed)"}`),F.note&&W(`the baseline is no higher than the base branch (${F.note})`,F.problems);const C=new Set([...$.counts.keys()].map(e=>j(e).file));return t.out(` ok PROGRESS: ${C.size} of ${ae($.files.length,"file")} still draw UI of their own: `+le($.counts,J)),t.out(""),B?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${ae(U.length,"problem")})`),B?0:1}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:function(){for(const e of[n(process.cwd(),"package.json"),import.meta.url])try{return t(e)("typescript")}catch{}throw new Error("typescript is not installed")},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:"4.179.0"});
@@ -1 +1 @@
1
- import{currentShellStrings as t}from"./chunk-3YTHR7IC.js";var e="http://www.w3.org/2000/svg",n={},o=/* @__PURE__ */new Map;function s(t,e){let n=document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.className=e,document.body.appendChild(n)),n}var r={success:"M5 13l4 4L19 7",error:"M6 18L18 6M6 6l12 12",warning:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",info:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",loading:"M12 3a9 9 0 019 9",bell:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"};function i(t,n){const o=document.createElementNS(e,"svg");o.setAttribute("class",n),o.setAttribute("fill","none"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("stroke","currentColor"),o.setAttribute("stroke-width","2");const s=document.createElementNS(e,"path");return s.setAttribute("stroke-linecap","round"),"loading"!==t&&s.setAttribute("stroke-linejoin","round"),s.setAttribute("d",r[t]),o.appendChild(s),o}function a(t,e){const n=document.createElement("div");return n.className=t,void 0!==e&&(n.textContent=e),n}function c(t,e,r){const c={...n,...r},l=c.placement??"top",d=c.sticky??!1,u=`${l}|${t}|${e}`;if(c.dedupe){const t=o.get(u);if(t)return t.restart(),{dismiss:t.dismiss}}"loading"!==t&&!1!==c.sound&&import("./sounds-FO772MN2.js").then(e=>{"success"===t?e.playSuccess():"error"===t?e.playError():e.playNotification()}).catch(()=>{});const m="bottom"===l?s("toast-container-bottom","fixed bottom-4 left-1/2 -translate-x-1/2 z-[9999] flex flex-col-reverse gap-2 items-center pointer-events-none"):s("toast-container","fixed top-4 left-1/2 -translate-x-1/2 z-[9999] flex flex-col gap-2 items-center pointer-events-none"),p="bottom"===l?"translateY(10px)":"translateY(-10px)",f=a("pointer-events-auto cursor-pointer rosh-toast");f.style.opacity="0",f.style.transform=`${p} scale(0.95)`,f.setAttribute("role","error"===t?"alert":"status"),f.setAttribute("aria-atomic","true"),f.appendChild(i(t,`h-4 w-4 rosh-tone-${t}${"loading"===t?" animate-spin":""}`));const h=document.createElement("span");let y;h.textContent=e,f.appendChild(h),m.appendChild(f),requestAnimationFrame(()=>{f.style.opacity="1",f.style.transform="translateY(0) scale(1)"});let v=!1;const g=()=>{v||(v=!0,y&&clearTimeout(y),o.delete(u),f.style.opacity="0",f.style.transform=`${p} scale(0.95)`,setTimeout(()=>f.remove(),300))},b=c.duration??("info"===t?4500:3e3),x=()=>{y&&clearTimeout(y),d||(y=setTimeout(g,b))};return x(),f.addEventListener("mouseenter",()=>{y&&clearTimeout(y)}),f.addEventListener("mouseleave",()=>{v||x()}),f.addEventListener("click",g),o.set(u,{el:f,restart:x,dismiss:g}),{dismiss:g}}var l={success:(t,e)=>c("success",t,e),error:(t,e)=>c("error",t,e),warning:(t,e)=>c("warning",t,e),info:(t,e)=>c("info",t,e),notify:(e,o)=>function(e,o){!1!==(o?.sound??n.sound)&&import("./sounds-FO772MN2.js").then(t=>t.playNotification()).catch(()=>{});const r=s("notif-container","fixed top-4 right-4 z-[9999] flex flex-col gap-3 items-end pointer-events-none"),c=a("pointer-events-auto cursor-pointer rosh-notif");c.style.opacity="0",c.style.transform="translateX(30px) scale(0.95)";const l=a("rosh-notif-badge");l.appendChild(i("bell","h-5 w-5"));const d=a("rosh-notif-body");d.append(a("rosh-notif-title",t().toast.notification),a("notif-msg rosh-notif-msg",e));const u=document.createElement("button");u.className="rosh-notif-close",u.textContent="×",c.append(l,d,u);const m=()=>{c.style.opacity="0",c.style.transform="translateX(30px) scale(0.95)",setTimeout(()=>c.remove(),300)};u.addEventListener("click",t=>{t.stopPropagation(),m()}),c.addEventListener("click",m),r.appendChild(c),requestAnimationFrame(()=>{c.style.opacity="1",c.style.transform="translateX(0) scale(1)"}),setTimeout(m,o?.duration??1e4)}(e,o),promise:(t,e,n)=>{const o=c("loading",e.loading,{...n,sticky:!0});return t.then(t=>{o.dismiss(),c("success","function"==typeof e.success?e.success(t):e.success,n)},t=>{o.dismiss(),c("error","function"==typeof e.error?e.error(t):e.error,n)}),t},configure:t=>{n={...t}}};export{l as toast_default};
1
+ import{currentShellStrings as t}from"./chunk-J3LIIIHJ.js";var e="http://www.w3.org/2000/svg",n={},o=/* @__PURE__ */new Map;function s(t,e){let n=document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.className=e,document.body.appendChild(n)),n}var r={success:"M5 13l4 4L19 7",error:"M6 18L18 6M6 6l12 12",warning:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",info:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",loading:"M12 3a9 9 0 019 9",bell:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"};function i(t,n){const o=document.createElementNS(e,"svg");o.setAttribute("class",n),o.setAttribute("fill","none"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("stroke","currentColor"),o.setAttribute("stroke-width","2");const s=document.createElementNS(e,"path");return s.setAttribute("stroke-linecap","round"),"loading"!==t&&s.setAttribute("stroke-linejoin","round"),s.setAttribute("d",r[t]),o.appendChild(s),o}function a(t,e){const n=document.createElement("div");return n.className=t,void 0!==e&&(n.textContent=e),n}function c(t,e,r){const c={...n,...r},l=c.placement??"top",d=c.sticky??!1,u=`${l}|${t}|${e}`;if(c.dedupe){const t=o.get(u);if(t)return t.restart(),{dismiss:t.dismiss}}"loading"!==t&&!1!==c.sound&&import("./sounds-FO772MN2.js").then(e=>{"success"===t?e.playSuccess():"error"===t?e.playError():e.playNotification()}).catch(()=>{});const m="bottom"===l?s("toast-container-bottom","fixed bottom-4 left-1/2 -translate-x-1/2 z-[9999] flex flex-col-reverse gap-2 items-center pointer-events-none"):s("toast-container","fixed top-4 left-1/2 -translate-x-1/2 z-[9999] flex flex-col gap-2 items-center pointer-events-none"),p="bottom"===l?"translateY(10px)":"translateY(-10px)",f=a("pointer-events-auto cursor-pointer rosh-toast");f.style.opacity="0",f.style.transform=`${p} scale(0.95)`,f.setAttribute("role","error"===t?"alert":"status"),f.setAttribute("aria-atomic","true"),f.appendChild(i(t,`h-4 w-4 rosh-tone-${t}${"loading"===t?" animate-spin":""}`));const h=document.createElement("span");let y;h.textContent=e,f.appendChild(h),m.appendChild(f),requestAnimationFrame(()=>{f.style.opacity="1",f.style.transform="translateY(0) scale(1)"});let v=!1;const g=()=>{v||(v=!0,y&&clearTimeout(y),o.delete(u),f.style.opacity="0",f.style.transform=`${p} scale(0.95)`,setTimeout(()=>f.remove(),300))},b=c.duration??("info"===t?4500:3e3),x=()=>{y&&clearTimeout(y),d||(y=setTimeout(g,b))};return x(),f.addEventListener("mouseenter",()=>{y&&clearTimeout(y)}),f.addEventListener("mouseleave",()=>{v||x()}),f.addEventListener("click",g),o.set(u,{el:f,restart:x,dismiss:g}),{dismiss:g}}var l={success:(t,e)=>c("success",t,e),error:(t,e)=>c("error",t,e),warning:(t,e)=>c("warning",t,e),info:(t,e)=>c("info",t,e),notify:(e,o)=>function(e,o){!1!==(o?.sound??n.sound)&&import("./sounds-FO772MN2.js").then(t=>t.playNotification()).catch(()=>{});const r=s("notif-container","fixed top-4 right-4 z-[9999] flex flex-col gap-3 items-end pointer-events-none"),c=a("pointer-events-auto cursor-pointer rosh-notif");c.style.opacity="0",c.style.transform="translateX(30px) scale(0.95)";const l=a("rosh-notif-badge");l.appendChild(i("bell","h-5 w-5"));const d=a("rosh-notif-body");d.append(a("rosh-notif-title",t().toast.notification),a("notif-msg rosh-notif-msg",e));const u=document.createElement("button");u.className="rosh-notif-close",u.textContent="×",c.append(l,d,u);const m=()=>{c.style.opacity="0",c.style.transform="translateX(30px) scale(0.95)",setTimeout(()=>c.remove(),300)};u.addEventListener("click",t=>{t.stopPropagation(),m()}),c.addEventListener("click",m),r.appendChild(c),requestAnimationFrame(()=>{c.style.opacity="1",c.style.transform="translateX(0) scale(1)"}),setTimeout(m,o?.duration??1e4)}(e,o),promise:(t,e,n)=>{const o=c("loading",e.loading,{...n,sticky:!0});return t.then(t=>{o.dismiss(),c("success","function"==typeof e.success?e.success(t):e.success,n)},t=>{o.dismiss(),c("error","function"==typeof e.error?e.error(t):e.error,n)}),t},configure:t=>{n={...t}}};export{l as toast_default};