efficient-shell 12.4.0 → 12.5.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.
- package/dist/{Browser-Z4Q2NDFT.js → Browser-FQUSLYYL.js} +16 -16
- package/dist/{Files-EX6JA4CJ.js → Files-A5ULCW3Q.js} +107 -107
- package/dist/{Notepad-U4OSPCX3.js → Notepad-7FEHOFEE.js} +9 -9
- package/dist/{Preview-JGRBT3EM.js → Preview-XJ3PGGRE.js} +9 -9
- package/dist/apps/index.js +1 -1
- package/dist/bin/media-host-check.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/{chunk-LCC3NXQX.js → chunk-34SPT4I6.js} +6 -6
- package/dist/chunk-4XSE5PV2.js +1 -0
- package/dist/{chunk-KQDSAN75.js → chunk-5FDS6KVH.js} +1 -1
- package/dist/{chunk-WUGQAZMC.js → chunk-EZPSNUYR.js} +4 -4
- package/dist/{chunk-6C4T3HRB.js → chunk-J4KYZGHQ.js} +2 -2
- package/dist/{chunk-I5CSYOOZ.js → chunk-JI756ABJ.js} +6 -6
- package/dist/{chunk-BQ5CRQYR.js → chunk-KSOMKQ5U.js} +1 -1
- package/dist/{chunk-ZB2H2JJ2.js → chunk-NC36LJCA.js} +4 -4
- package/dist/{chunk-CURXYF2R.js → chunk-PM4Y2FMQ.js} +3 -3
- package/dist/chunk-TX5FZBPQ.js +4 -0
- package/dist/chunk-UVGEOQI4.js +13 -0
- package/dist/data/EntityList.d.ts +4 -0
- package/dist/data/EntityList.js +1 -1
- package/dist/data/ListFooter.d.ts +7 -12
- package/dist/data/ListFooter.js +1 -1
- package/dist/format/index.js +1 -1
- package/dist/forms/BrandAssetEditor.js +1 -1
- package/dist/forms/LinkPicker.js +1 -1
- package/dist/forms/MediaLibrary.js +1 -1
- package/dist/forms/MediaUploadField.js +1 -1
- package/dist/index.js +91 -91
- package/dist/page-tabs/index.js +5 -5
- package/dist/shell/LanguageSelect.js +1 -1
- package/dist/shell/SettingRow.js +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4H5NTMOF.js +0 -4
- package/dist/chunk-RJ3J4BLH.js +0 -1
- package/dist/chunk-VIOILTE4.js +0 -13
package/dist/bin/ui-check.js
CHANGED
|
@@ -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","spacing","font-size","z-index","shadow","kit","icon","svg","kit-dep","chart","chart-dep","ellipsis-label","colour"],l=e=>"string"==typeof e&&a.includes(e),c=["kit-dep","chart-dep"],d=e=>c.includes(e),u=a.filter(e=>!d(e)),h={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)"}},p=["@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"],f=["@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"],g=["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"],m={"efficient-shell":["@headlessui/react"]};function w(e,t){return t.some(t=>t.endsWith("/")||t.endsWith("-")?e.startsWith(t):e===t||e.startsWith(`${t}/`))}function k(e){return w(e,f)?"icon":w(e,p)?"kit":w(e,g)?"chart":null}function x(e){const t=k(e);return"kit"===t||"icon"===t?"kit-dep":"chart"===t?"chart-dep":null}var b=/[.+^$()|[\]\\]/g;function $(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(b,"\\$&")}if(0!==n)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${t}$`)}function y(e){const t=e.map($);return e=>t.some(t=>t.test(e))}var v=new Set(["node_modules",".git"]),S=new Set(["dist","coverage",".next",".turbo"]);function j(e){const t=e.search(/[*?{]/),n=-1===t?e:e.slice(0,t),i=n.lastIndexOf("/");return-1===i?"":n.slice(0,i)}function I(e,t){const i=y(t),o=[...new Set(t.map(j))].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()?v.has(e.name)||""===t&&S.has(e.name)||l(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)l(e);return[...a].sort(L)}var L=(e,t)=>e<t?-1:e>t?1:0,R=class extends Error{},A=(e,t)=>`${e}:${t}`;function z(e){const t=e.lastIndexOf(":");return{file:e.slice(0,t),kind:e.slice(t+1)}}var E=e=>a.indexOf(e);function C(e,t){const n=z(e),i=z(t);return L(n.file,i.file)||E(n.kind)-E(i.kind)}function T(e,t="ui-kit.baseline.json"){let n;try{n=JSON.parse(e)}catch(e){throw new R(`${t} is not valid JSON: ${e.message}`)}const i=e=>{throw new R(`${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}=z(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 M(e){const t=a.filter(t=>e.kinds.includes(t)),n=[...e.counts.keys()].filter(t=>(e.counts.get(t)??0)>0).sort(C).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 B(e){const t={};for(const[n,i]of e){const{kind:e}=z(n);l(e)&&(t[e]=(t[e]??0)+i)}return t}var P=class extends Error{},O=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),D=new Set(["$schema","schema","kinds","include","exclude","includeImporting","output","allow"]);var N="package.json",F=[2,4,8,12,16,20,24,32,40,48];function J(e){if("0"===e||"px"===e)return!0;const t=Number(e);return!!Number.isFinite(t)&&F.includes(4*t)}var U=new Set(["iframe","frame","object","embed"]),W=new Set(["href","xlinkHref","to","id","key","htmlFor"]),q=/(?<![&\w])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,_=/(?<![\w-])rounded(?:-(?:[trblse]|tl|tr|br|bl|ss|se|ee|es))?-\[([^\]]*)\]/g,G=/^border(?:(?:Top|Bottom)(?:Left|Right)|(?:Start|End)(?:Start|End))?Radius$/,K=/^(?:inherit|initial|unset|revert)$|var\(|^(?:50|100)%$|^(?:999|9999)(?:px)?$/,H=/(?<![\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,Q=/(?<![\w-])text-\[(?:length:)?(\d*\.?\d+(?:px|rem|em|%))\]/g,V=/(?<![\w-])z-(\d+|\[[^\]]*\])(?![\w.[/-])/g,X=/(?<![\w-])shadow-(xs|2xs|md|2xl|\[[^\]]*\])(?![\w.[/-])/g,Z=/var\(|^(?:inherit|initial|unset|revert|revert-layer|none|auto)$/,Y=/^(?:(?:padding|margin)(?:Top|Right|Bottom|Left|Inline|Block|InlineStart|InlineEnd|BlockStart|BlockEnd)?|gap|rowGap|columnGap)$/,ee=new Set([0,...F]),te=/(?<![\w-])dark:(?=[\w[\-!@*(])/g,ne="slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose",ie="(?:50|[1-9]00|950)",oe=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)-(?:(?:${ne})-${ie}|white|black)(?:\\/[\\w.]+)?(?![\\w-])`,"g"),se=new RegExp(`--color-(?:(?:${ne})-${ie}|white|black)(?![\\w-])`,"g"),re=/(?<![\w-])(?:rgba?|hsla?|hwb|oklch|oklab|lab|lch)\(\s*[\d.]/g,ae=/(?<![\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,le=/^(?:color|background(?:Color)?|border(?:Top|Right|Bottom|Left|Inline|Block)?(?:Color)?|outline(?:Color)?|fill|stroke|caretColor|accentColor|textDecorationColor|boxShadow|textShadow)$/,ce=/(?<![&a-zA-Z0-9])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,de=e=>[...e.matchAll(ce)].length+[...e.matchAll(re)].length+[...e.matchAll(oe)].length+[...e.matchAll(se)].length,ue=new Set(["button","a","option","Button","IconButton","SplitButton","Link","NavLink","PopupMenuItem","PopupMenuLabel","DropdownMenuItem","MenuItem","ContextMenuItem"]),he=/(?:…|\.\.\.|…)\s*$/,pe=new RegExp("\\p{L}","u"),fe=new RegExp("\\p{L}[\\p{L}-]*","u"),ge={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:{}},me=new Set((ge.busy?.words??[]).map(e=>e.toLowerCase())),we=new Set(["label","aria-label",...ge.placeholder?[]:["placeholder","searchPlaceholder","emptyOptionLabel","blankLabel"]]),ke=(e,t)=>{if(!he.test(t)||!pe.test(e))return!1;const n=e.match(fe)?.[0]?.toLowerCase();if(n&&me.has(n))return!1;const i=e.replace(he,"").trim(),o=ge.busy;return!(o&&(o.zhStarts.some(e=>i.startsWith(e))||o.zhEnds.some(e=>i.endsWith(e))))},xe=new Set(["confirm","alert","prompt"]),be=new Set(["window","globalThis","self"]);var $e=e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"),ye=e=>/\.(?:css|scss)$/.test(e),ve=/^(?: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 Se(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(oe)].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=de(r)+(ve.test(s)?[...r.matchAll(ae)].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},p=new Set;if(s.has("native")){const t=n=>{if(n)if(e.isIdentifier(n))xe.has(n.text)&&p.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 f=t=>t&&e.isStringLiteralLike(t)?t.text:void 0,g=(e,t)=>{e&&("efficient-shell"===e||e.startsWith("efficient-shell/"))&&o?.add(e);const n=e?k(e):null;n&&d(n,t)},m=(e,t,n)=>{if(s.has("dark"))for(const n of e.matchAll(te))d("dark",t);if(s.has("radius"))for(const n of e.matchAll(_))K.test(n[1].trim())||d("radius",t);if(n&&l&&s.has("hex"))for(const n of e.matchAll(q))d("hex",t);if(n&&s.has("colour"))for(let n=de(e);n>0;n--)d("colour",t);if(s.has("spacing"))for(const n of e.matchAll(H)){const e=n[1];(e.startsWith("[")?Z.test(e.slice(1,-1).trim()):J(e))||d("spacing",t)}if(s.has("font-size"))for(const n of e.matchAll(Q))d("font-size",t);if(s.has("z-index"))for(const n of e.matchAll(V)){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(X))n[1].startsWith("[")&&Z.test(n[1].slice(1,-1).trim())||d("shadow",t)},w=(t,n,i)=>{const o=e.isStringLiteralLike(n)?n.text.trim():void 0;if(s.has("colour")&&void 0!==o&&le.test(t))for(const e of o.matchAll(ae))d("colour",i);if(s.has("spacing")&&Y.test(t))e.isNumericLiteral(n)?ee.has(Number(n.text))||d("spacing",i):void 0!==o&&!Z.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=>!ee.has(e))&&d("spacing",i);else if(s.has("font-size")&&"fontSize"===t)(e.isNumericLiteral(n)||void 0!==o&&!Z.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||Z.test(o)||d("shadow",i))},x=(t,n)=>{if(e.isJsxOpeningElement(t)||e.isJsxSelfClosingElement(t)){const e=t.tagName.getText(r);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),!U.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):xe.has(n.text)&&!p.has(n.text)?d("native",t):"require"===n.text&&g(f(t.arguments[0]),t):e.isPropertyAccessExpression(n)?"createPortal"===n.name.text?d("portal",t):xe.has(n.name.text)&&e.isIdentifier(n.expression)&&be.has(n.expression.text)&&d("native",t):n.kind===e.SyntaxKind.ImportKeyword&&g(f(t.arguments[0]),t)}else{if(e.isImportDeclaration(t)||e.isExportDeclaration(t))return void g(f(t.moduleSpecifier),t);if(e.isPropertyAssignment(t)){const n=e.isIdentifier(t.name)||e.isStringLiteralLike(t.name)?t.name.text:"",i=t.initializer;w(n,i,t),s.has("radius")&&G.test(n)&&(e.isNumericLiteral(i)?K.test(i.text)||d("radius",t):e.isStringLiteralLike(i)&&!K.test(i.text.trim())&&d("radius",t))}else if(e.isStringLiteralLike(t))m(t.text,t,n);else if(e.isTemplateExpression(t)){m(t.head.text,t.head,n);for(const e of t.templateSpans)m(e.literal.text,e.literal,n)}}e.isJsxAttribute(t)&&W.has(t.name.getText(r))?e.forEachChild(t,e=>x(e,!1)):e.forEachChild(t,e=>x(e,n))};return 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))ke(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)];ke(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)&&Ie.has(Le(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);ke(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&&ge.prompt&&""===a(e,"value");ue.has(i)&&!o&&r(n.children)}else if(e.isJsxAttribute(n))we.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=ge.prompt&&e.isObjectLiteralExpression(n.parent)&&l(n.parent);we.has(t)&&!i&&s(n.initializer)}e.forEachChild(n,c)};c(t)}(e,r,e=>(a["ellipsis-label"]??=[]).push(c(e))),a}var Ie=new Set(["say","t"]),Le=e=>{const t=e.getText();return t.slice(t.lastIndexOf(".")+1)};function Re(e){const t={};for(const[n,i]of Object.entries(e))i.length&&(t[n]=i.length);return t}function Ae(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 ze=(e,t)=>e.some(e=>t.some(t=>t.endsWith("/*")?e.startsWith(t.slice(0,-1)):e===t));var Ee=e=>new Map(e.allow.map(e=>[A(e.file,e.kind),e.count]));function Ce(e,t){return e.kinds.filter(e=>t.kinds.includes(e))}var Te=(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 Me(e,t,n){const i=Ee(e),o=new Map;for(const[e,s]of t.counts){const{kind:t}=z(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 Be(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 Pe="\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>Ӓ and BG#00340 and #12345 and #added are not colours</span>;\nconst p = 'entity  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",Oe={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},De={kit:1,dark:1,portal:1,radius:2,chart:1,colour:2},Ne=(...e)=>e.join("-"),Fe=`\nconst s1 = <i className="${[Ne("px","2.5"),Ne("py","1.5"),"md:"+Ne("gap","1.5"),"-"+Ne("mt","1.5"),Ne("p","[10px]")].join(" ")}" />;\nconst s2 = <i className="${[Ne("p","0"),Ne("px","px"),Ne("p","0.5"),Ne("p","3"),Ne("gap-x","4"),Ne("p","12"),Ne("p","(--space-12)"),Ne("p","[var(--space-12)]"),Ne("space-x","reverse"),Ne("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="${[Ne("text","[11px]"),Ne("text","[0.8rem]"),Ne("text","xs"),Ne("text","[#fff]"),Ne("text","(--text-2xs)")].join(" ")}" />;\nconst f2 = <i style={{ fontSize: 12 }} />;\nconst f3 = { fontSize: 'var(--x)', font: 'inherit' };\nconst z1 = <i className="${[Ne("z","[9999]"),Ne("z","50"),Ne("z","10"),Ne("z","30"),"-"+Ne("z","10"),Ne("z","auto"),Ne("z","(--z-popup)"),Ne("z","[var(--z-popup)]")].join(" ")}" />;\nconst z2 = { zIndex: on ? 2020 : 2010 };\nconst z3 = { zIndex: Z_LAYERS.popup, top: 9999 };\nconst h1 = <i className="${[Ne("shadow","[0_1px_2px_#000]"),Ne("shadow","md"),"shadow",Ne("shadow","lg"),Ne("shadow","(--elevation-panel)"),Ne("shadow","black/20"),Ne("drop-shadow","md")].join(" ")}" />;\nconst h2 = { boxShadow: '0 1px 2px rgba(0,0,0,.1)' };\nconst h3 = { boxShadow: 'none', outline: 'var(--elevation-raised)' };\n`,Je={spacing:7,"font-size":3,"z-index":4,shadow:3,hex:1,colour:4},Ue={colour:4},We={"ellipsis-label":9},qe=e=>a.filter(t=>e[t]).map(t=>`${t} ${e[t]}`).join(", ")||"nothing";var _e="ui-kit.config.json",Ge="ui-kit.baseline.json",Ke="efficient-shell-ui-check",He=`${Ke}: every surface a person operates takes its UI from efficient-shell (harness UI-24).\n\n ${Ke} check this repository against ${Ge}\n ${Ke} --print print today's counts as a baseline, and change nothing\n ${Ke} --summary print totals per kind and per folder, as Markdown\n ${Ke} --json print the result as JSON\n ${Ke} --update lower the lines whose counts fell, and delete the ones at zero\n ${Ke} --update --allow-move also follow a renamed or split file (no total may rise)\n ${Ke} --init write the first ${Ge}\n ${Ke} --init --kind <kind> take the baseline for a kind just added to "kinds"\n ${Ke} --no-base do not compare with the pull request's base branch\n\nKinds: ${a.join(", ")}\nReads ${_e} in the current directory.`;var Qe=(e,t)=>`${e} ${t}${1===e?"":"s"}`,Ve=(e,t)=>{const n=B(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(`${Ke}: ${r}\n\n${He}`),2;if(r.help)return t.out(He),0;if(r.version)return t.out(t.version),0;const c=e=>(r.json?t.out(JSON.stringify({tool:Ke,version:t.version,ok:!1,failures:[e]},null,2)):t.err(`${Ke}: ${e}`),1),p=n(t.cwd,_e);if(!i(p))return c(`no ${_e} in ${t.cwd}. Run it from the repository root; the harness has the template.`);let f,g;try{f=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=>!O(e))?(i(`${t} must be a list of objects`),[]):e;if(!O(e))throw new P(`${t}: must be a JSON object`);for(const t of Object.keys(e))D.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"'),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 p=r(e.output,'"output"').map((e,t)=>({files:o(e.files,`"output"[${t}].files`,{required:!0}),reason:s(e.reason,`"output"[${t}]`)})),f=[],g=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}`;g.has(u)&&i(`${n}: ${r} already has an allow entry for "${e.kind}"`),g.add(u),f.push({file:r,kind:e.kind,count:e.count,reason:d})}),n.length)throw new P(`${t}:\n - ${n.join("\n - ")}`);return{schema:1,kinds:a.filter(e=>c.includes(e)),include:d,exclude:u,includeImporting:h,output:p,allow:f}}(JSON.parse(o(p,"utf8")),_e)}catch(e){return c(e instanceof P?e.message:`${_e} is not valid JSON: ${e.message}`)}try{g=t.loadTypeScript()}catch{return c('this check reads the TypeScript AST and found no "typescript" package here. Install it as a devDependency.')}const w=function(e){const t=[],n=u,i=[["fixture.tsx",Pe,Oe],["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",De],["tokens.tsx",Fe,Je],["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",We]];for(const[o,s,r]of i){const i=Re(je(e,o,s,n));n.some(e=>(i[e]??0)!==(r[e]??0))&&t.push(`${o}: read ${qe(i)}; it holds ${qe(r)}`)}const o=Re(Se('\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)!==(Ue[e]??0))&&t.push(`style.css: read ${qe(o)}; it holds ${qe(Ue)}`);const s=Re(je(e,"fixture.tsx",Pe,["button"]));return"button"!==Object.keys(s).join()&&t.push(`asked for button alone, the reader reported ${qe(s)}`),t}(g);if(w.length)return c(`the reader misread its own fixtures with typescript ${g.version}, so nothing it says about this repository can be trusted:\n - `+w.join("\n - "));const k=function(e,t,s){const r=[],a=y(s.exclude),l=y(s.output.flatMap(e=>e.files)),c=new Map,u=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===I(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}]`));const p=new Set,f=s.kinds.includes("colour"),g=e=>($e(e)||f&&ye(e))&&!a(e)&&!l(e);for(const e of I(t,s.include))g(e)&&p.add(e);for(const n of s.includeImporting)for(const i of I(t,n.files))g(i)&&$e(i)&&!p.has(i)&&ze(Ae(e,i,u(i)),n.modules)&&p.add(i);const w=[...p].sort(),k=s.kinds.filter(e=>!d(e)),b=new Map,$=new Map,v=new Set;for(const t of w){const n=ye(t)?Se(u(t),k):je(e,t,u(t),k,v);let i=!1;for(const e of k){const o=n[e]?.length??0;o&&($.set(A(t,e),o),i=!0)}i&&b.set(t,n)}let S=[],j=[],L=[];const R=s.kinds.filter(d);if(R.length){const e=n(t,N);if(i(e)){const t=JSON.parse(o(e,"utf8")),n=["dependencies","peerDependencies","optionalDependencies"].flatMap(e=>Object.keys(t[e]??{})),i=new Set([...v].flatMap(e=>m[e]??[])),r=[...new Set(n)].sort();if(s.kinds.includes("kit-dep")){const e=r.filter(e=>"kit-dep"===x(e));S=e.filter(e=>!i.has(e)),j=e.filter(e=>i.has(e)),S.length&&$.set(A(N,"kit-dep"),S.length)}s.kinds.includes("chart-dep")&&(L=r.filter(e=>"chart-dep"===x(e)),L.length&&$.set(A(N,"chart-dep"),L.length))}else for(const e of R)r.push(`"kinds" includes "${e}", and there is no ${N} here to read.`)}for(const e of s.allow)(d(e.kind)?e.file===N:p.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:w,hits:b,counts:$,kitDeps:S,shellPeers:j,chartDeps:L,problems:r}}(g,t.cwd,f);if(0===k.files.length)return c(`read no files. "include" in ${_e} matches nothing, so a pass would mean nothing.`);const b=n(t.cwd,Ge),$=r.json,v=e=>{$||t.out(e)};if(r.print)return t.out(M(Me(f,k,f.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}=z(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=>z(e).file)).size} of ${Qe(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} | ${h[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}(f,k))t.out(e);return 0}let S=null;if(i(b))try{S=T(o(b,"utf8"),Ge)}catch(e){return c(e instanceof R?e.message:String(e))}if(r.init){const e=r.kinds.filter(e=>!l(e)||!f.kinds.includes(e));if(e.length)return c(`--kind ${e.join(", ")}: not in "kinds" in ${_e}. Add it there first.`);const t=r.kinds;if(S){if(0===t.length)return c(`${Ge} 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=>S.kinds.includes(e));if(e.length)return c(`the baseline was already taken for ${e.join(", ")}. Its lines only go down; use --update.`);const n=Me(f,k,t);S={kinds:[...S.kinds,...t],counts:new Map([...S.counts,...n.counts])}}else{if(t.length)return c(`there is no ${Ge} yet. Run --init on its own first.`);S=Me(f,k,f.kinds)}s(b,M(S)),v(`${Ke}: wrote ${Ge} (${Qe(S.counts.size,"line")}: ${Ve(S.counts,S.kinds)})`)}if(!S)return c(`no ${Ge}. This repository has not adopted the check yet: run ${Ke} --init, and commit the file.`);if(r.update){const e=function(e,t,n,{allowMove:i=!1}={}){const o=Ce(e,t),s=Me(e,n,o),r=new Map([...t.counts].filter(([e])=>o.includes(z(e).kind)));if(i){const e=B(r),n=B(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:Be(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:Be(r,a),refused:[]}}(f,S,k,{allowMove:r.allowMove});if(e.refused.length)return c(`--allow-move follows code that moved, and this is more of it than before:\n - ${e.refused.join("\n - ")}\nNothing was written.`);S=e.baseline,s(b,M(S)),v(`${Ke}: ${e.lowered?`changed ${Qe(e.lowered,"line")} in`:"nothing to change in"} ${Ge}`)}const j=function(e,t,n){const i=[],o=[],s=[...n.problems],r=Ee(e),a=new Set(Ce(e,t)),c=e.kinds.filter(e=>!t.kinds.includes(e));c.length&&s.push(`"kinds" names ${c.map(e=>`"${e}"`).join(", ")}, and the baseline was never taken for ${1===c.length?"it":"them"}. Run: efficient-shell-ui-check --init ${c.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(C)){const{file:c,kind:d}=z(e);if(!l(d)||!a.has(d))continue;const u=n.counts.get(e)??0,p=r.get(e)??0,f=t.counts.get(e)??0;u>p+f?i.push(`${c}: ${d} ${u}, and its line allows ${p+f}${Te(n,c,d)}. ${h[d].counts} is counted; use ${h[d].instead}.`):u<p?s.push(`${c}: ${d} ${u}, and "allow" in ui-kit.config.json says ${p}. ${0===u?"Delete the entry":`Lower its count to ${u}`}: an exception does not outlive what it excused.`):u<p+f&&o.push(`${c}: ${d} ${u}, and its line says ${p+f}`)}return{grown:i,shrunk:o,other:s,updateFixes:0===i.length&&0===s.length&&o.length>0}}(f,S,k),L=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()}${Ge}`]);if(null===r)return{problems:[],note:`${s} has no ${Ge} yet (adoption)`};let a;try{a=T(r,`${s}:${Ge}`)}catch{return{problems:[],note:`${s}'s ${Ge} could not be read; the base branch was not compared`}}const l=B(a.counts),c=B(t.counts);return{problems:n.filter(e=>a.kinds.includes(e)&&(c[e]??0)>(l[e]??0)).map(e=>`${Ge} holds ${c[e]??0} of "${e}", and ${s} holds ${l[e]??0}. The baseline only goes down: use ${h[e].instead}. A count that is meant to stay goes in "allow" in ${_e}, with its reason.`),note:`compared with ${s}`}}(t,S,f.kinds),E=f.kinds.filter(e=>S.kinds.includes(e)),F=`${Ke} --update`,J=[...j.other,...j.grown,...j.shrunk.map(e=>`${e}. Run: ${F}`),...L.problems],U=0===J.length;if(r.json){const e=new Map(f.allow.map(e=>[`${e.file}:${e.kind}`,e.count]));return t.out(JSON.stringify({tool:Ke,version:t.version,ok:U,schema:f.schema,kinds:f.kinds,files:k.files.length,counts:B(k.counts),baseline:B(S.counts),allowed:B(e),kitDeps:k.kitDeps,shellPeers:k.shellPeers,chartDeps:k.chartDeps,failures:J},null,2)),U?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 ${g.version})`),t.out(` ok read ${Qe(k.files.length,"file")}`),W(`${_e} and ${Ge} describe this repository`,j.other),W("no file draws more of its own UI than its line allows",j.grown),W("every line is exact: a count that fell is a line to lower",j.shrunk,`Run: ${F}${j.updateFixes?"":" (after the failures above are fixed)"}`),L.note&&W(`the baseline is no higher than the base branch (${L.note})`,L.problems);const q=new Set([...k.counts.keys()].map(e=>z(e).file));return t.out(` ok PROGRESS: ${q.size} of ${Qe(k.files.length,"file")} still draw UI of their own: `+Ve(k.counts,E)),t.out(""),U?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${Qe(J.length,"problem")})`),U?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.4.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","spacing","font-size","z-index","shadow","kit","icon","svg","kit-dep","chart","chart-dep","ellipsis-label","colour"],l=e=>"string"==typeof e&&a.includes(e),c=["kit-dep","chart-dep"],d=e=>c.includes(e),u=a.filter(e=>!d(e)),h={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)"}},p=["@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"],f=["@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"],g=["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"],m={"efficient-shell":["@headlessui/react"]};function w(e,t){return t.some(t=>t.endsWith("/")||t.endsWith("-")?e.startsWith(t):e===t||e.startsWith(`${t}/`))}function k(e){return w(e,f)?"icon":w(e,p)?"kit":w(e,g)?"chart":null}function x(e){const t=k(e);return"kit"===t||"icon"===t?"kit-dep":"chart"===t?"chart-dep":null}var b=/[.+^$()|[\]\\]/g;function $(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(b,"\\$&")}if(0!==n)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${t}$`)}function y(e){const t=e.map($);return e=>t.some(t=>t.test(e))}var v=new Set(["node_modules",".git"]),S=new Set(["dist","coverage",".next",".turbo"]);function j(e){const t=e.search(/[*?{]/),n=-1===t?e:e.slice(0,t),i=n.lastIndexOf("/");return-1===i?"":n.slice(0,i)}function I(e,t){const i=y(t),o=[...new Set(t.map(j))].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()?v.has(e.name)||""===t&&S.has(e.name)||l(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)l(e);return[...a].sort(L)}var L=(e,t)=>e<t?-1:e>t?1:0,R=class extends Error{},A=(e,t)=>`${e}:${t}`;function z(e){const t=e.lastIndexOf(":");return{file:e.slice(0,t),kind:e.slice(t+1)}}var E=e=>a.indexOf(e);function C(e,t){const n=z(e),i=z(t);return L(n.file,i.file)||E(n.kind)-E(i.kind)}function T(e,t="ui-kit.baseline.json"){let n;try{n=JSON.parse(e)}catch(e){throw new R(`${t} is not valid JSON: ${e.message}`)}const i=e=>{throw new R(`${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}=z(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 M(e){const t=a.filter(t=>e.kinds.includes(t)),n=[...e.counts.keys()].filter(t=>(e.counts.get(t)??0)>0).sort(C).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 B(e){const t={};for(const[n,i]of e){const{kind:e}=z(n);l(e)&&(t[e]=(t[e]??0)+i)}return t}var P=class extends Error{},O=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),D=new Set(["$schema","schema","kinds","include","exclude","includeImporting","output","allow"]);var N="package.json",F=[2,4,8,12,16,20,24,32,40,48];function J(e){if("0"===e||"px"===e)return!0;const t=Number(e);return!!Number.isFinite(t)&&F.includes(4*t)}var U=new Set(["iframe","frame","object","embed"]),W=new Set(["href","xlinkHref","to","id","key","htmlFor"]),q=/(?<![&\w])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,_=/(?<![\w-])rounded(?:-(?:[trblse]|tl|tr|br|bl|ss|se|ee|es))?-\[([^\]]*)\]/g,G=/^border(?:(?:Top|Bottom)(?:Left|Right)|(?:Start|End)(?:Start|End))?Radius$/,K=/^(?:inherit|initial|unset|revert)$|var\(|^(?:50|100)%$|^(?:999|9999)(?:px)?$/,H=/(?<![\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,Q=/(?<![\w-])text-\[(?:length:)?(\d*\.?\d+(?:px|rem|em|%))\]/g,V=/(?<![\w-])z-(\d+|\[[^\]]*\])(?![\w.[/-])/g,X=/(?<![\w-])shadow-(xs|2xs|md|2xl|\[[^\]]*\])(?![\w.[/-])/g,Z=/var\(|^(?:inherit|initial|unset|revert|revert-layer|none|auto)$/,Y=/^(?:(?:padding|margin)(?:Top|Right|Bottom|Left|Inline|Block|InlineStart|InlineEnd|BlockStart|BlockEnd)?|gap|rowGap|columnGap)$/,ee=new Set([0,...F]),te=/(?<![\w-])dark:(?=[\w[\-!@*(])/g,ne="slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose",ie="(?:50|[1-9]00|950)",oe=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)-(?:(?:${ne})-${ie}|white|black)(?:\\/[\\w.]+)?(?![\\w-])`,"g"),se=new RegExp(`--color-(?:(?:${ne})-${ie}|white|black)(?![\\w-])`,"g"),re=/(?<![\w-])(?:rgba?|hsla?|hwb|oklch|oklab|lab|lch)\(\s*[\d.]/g,ae=/(?<![\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,le=/^(?:color|background(?:Color)?|border(?:Top|Right|Bottom|Left|Inline|Block)?(?:Color)?|outline(?:Color)?|fill|stroke|caretColor|accentColor|textDecorationColor|boxShadow|textShadow)$/,ce=/(?<![&a-zA-Z0-9])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,de=e=>[...e.matchAll(ce)].length+[...e.matchAll(re)].length+[...e.matchAll(oe)].length+[...e.matchAll(se)].length,ue=new Set(["button","a","option","Button","IconButton","SplitButton","Link","NavLink","PopupMenuItem","PopupMenuLabel","DropdownMenuItem","MenuItem","ContextMenuItem"]),he=/(?:…|\.\.\.|…)\s*$/,pe=new RegExp("\\p{L}","u"),fe=new RegExp("\\p{L}[\\p{L}-]*","u"),ge={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:{}},me=new Set((ge.busy?.words??[]).map(e=>e.toLowerCase())),we=new Set(["label","aria-label",...ge.placeholder?[]:["placeholder","searchPlaceholder","emptyOptionLabel","blankLabel"]]),ke=(e,t)=>{if(!he.test(t)||!pe.test(e))return!1;const n=e.match(fe)?.[0]?.toLowerCase();if(n&&me.has(n))return!1;const i=e.replace(he,"").trim(),o=ge.busy;return!(o&&(o.zhStarts.some(e=>i.startsWith(e))||o.zhEnds.some(e=>i.endsWith(e))))},xe=new Set(["confirm","alert","prompt"]),be=new Set(["window","globalThis","self"]);var $e=e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"),ye=e=>/\.(?:css|scss)$/.test(e),ve=/^(?: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 Se(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(oe)].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=de(r)+(ve.test(s)?[...r.matchAll(ae)].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},p=new Set;if(s.has("native")){const t=n=>{if(n)if(e.isIdentifier(n))xe.has(n.text)&&p.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 f=t=>t&&e.isStringLiteralLike(t)?t.text:void 0,g=(e,t)=>{e&&("efficient-shell"===e||e.startsWith("efficient-shell/"))&&o?.add(e);const n=e?k(e):null;n&&d(n,t)},m=(e,t,n)=>{if(s.has("dark"))for(const n of e.matchAll(te))d("dark",t);if(s.has("radius"))for(const n of e.matchAll(_))K.test(n[1].trim())||d("radius",t);if(n&&l&&s.has("hex"))for(const n of e.matchAll(q))d("hex",t);if(n&&s.has("colour"))for(let n=de(e);n>0;n--)d("colour",t);if(s.has("spacing"))for(const n of e.matchAll(H)){const e=n[1];(e.startsWith("[")?Z.test(e.slice(1,-1).trim()):J(e))||d("spacing",t)}if(s.has("font-size"))for(const n of e.matchAll(Q))d("font-size",t);if(s.has("z-index"))for(const n of e.matchAll(V)){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(X))n[1].startsWith("[")&&Z.test(n[1].slice(1,-1).trim())||d("shadow",t)},w=(t,n,i)=>{const o=e.isStringLiteralLike(n)?n.text.trim():void 0;if(s.has("colour")&&void 0!==o&&le.test(t))for(const e of o.matchAll(ae))d("colour",i);if(s.has("spacing")&&Y.test(t))e.isNumericLiteral(n)?ee.has(Number(n.text))||d("spacing",i):void 0!==o&&!Z.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=>!ee.has(e))&&d("spacing",i);else if(s.has("font-size")&&"fontSize"===t)(e.isNumericLiteral(n)||void 0!==o&&!Z.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||Z.test(o)||d("shadow",i))},x=(t,n)=>{if(e.isJsxOpeningElement(t)||e.isJsxSelfClosingElement(t)){const e=t.tagName.getText(r);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),!U.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):xe.has(n.text)&&!p.has(n.text)?d("native",t):"require"===n.text&&g(f(t.arguments[0]),t):e.isPropertyAccessExpression(n)?"createPortal"===n.name.text?d("portal",t):xe.has(n.name.text)&&e.isIdentifier(n.expression)&&be.has(n.expression.text)&&d("native",t):n.kind===e.SyntaxKind.ImportKeyword&&g(f(t.arguments[0]),t)}else{if(e.isImportDeclaration(t)||e.isExportDeclaration(t))return void g(f(t.moduleSpecifier),t);if(e.isPropertyAssignment(t)){const n=e.isIdentifier(t.name)||e.isStringLiteralLike(t.name)?t.name.text:"",i=t.initializer;w(n,i,t),s.has("radius")&&G.test(n)&&(e.isNumericLiteral(i)?K.test(i.text)||d("radius",t):e.isStringLiteralLike(i)&&!K.test(i.text.trim())&&d("radius",t))}else if(e.isStringLiteralLike(t))m(t.text,t,n);else if(e.isTemplateExpression(t)){m(t.head.text,t.head,n);for(const e of t.templateSpans)m(e.literal.text,e.literal,n)}}e.isJsxAttribute(t)&&W.has(t.name.getText(r))?e.forEachChild(t,e=>x(e,!1)):e.forEachChild(t,e=>x(e,n))};return 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))ke(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)];ke(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)&&Ie.has(Le(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);ke(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&&ge.prompt&&""===a(e,"value");ue.has(i)&&!o&&r(n.children)}else if(e.isJsxAttribute(n))we.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=ge.prompt&&e.isObjectLiteralExpression(n.parent)&&l(n.parent);we.has(t)&&!i&&s(n.initializer)}e.forEachChild(n,c)};c(t)}(e,r,e=>(a["ellipsis-label"]??=[]).push(c(e))),a}var Ie=new Set(["say","t"]),Le=e=>{const t=e.getText();return t.slice(t.lastIndexOf(".")+1)};function Re(e){const t={};for(const[n,i]of Object.entries(e))i.length&&(t[n]=i.length);return t}function Ae(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 ze=(e,t)=>e.some(e=>t.some(t=>t.endsWith("/*")?e.startsWith(t.slice(0,-1)):e===t));var Ee=e=>new Map(e.allow.map(e=>[A(e.file,e.kind),e.count]));function Ce(e,t){return e.kinds.filter(e=>t.kinds.includes(e))}var Te=(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 Me(e,t,n){const i=Ee(e),o=new Map;for(const[e,s]of t.counts){const{kind:t}=z(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 Be(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 Pe="\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>Ӓ and BG#00340 and #12345 and #added are not colours</span>;\nconst p = 'entity  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",Oe={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},De={kit:1,dark:1,portal:1,radius:2,chart:1,colour:2},Ne=(...e)=>e.join("-"),Fe=`\nconst s1 = <i className="${[Ne("px","2.5"),Ne("py","1.5"),"md:"+Ne("gap","1.5"),"-"+Ne("mt","1.5"),Ne("p","[10px]")].join(" ")}" />;\nconst s2 = <i className="${[Ne("p","0"),Ne("px","px"),Ne("p","0.5"),Ne("p","3"),Ne("gap-x","4"),Ne("p","12"),Ne("p","(--space-12)"),Ne("p","[var(--space-12)]"),Ne("space-x","reverse"),Ne("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="${[Ne("text","[11px]"),Ne("text","[0.8rem]"),Ne("text","xs"),Ne("text","[#fff]"),Ne("text","(--text-2xs)")].join(" ")}" />;\nconst f2 = <i style={{ fontSize: 12 }} />;\nconst f3 = { fontSize: 'var(--x)', font: 'inherit' };\nconst z1 = <i className="${[Ne("z","[9999]"),Ne("z","50"),Ne("z","10"),Ne("z","30"),"-"+Ne("z","10"),Ne("z","auto"),Ne("z","(--z-popup)"),Ne("z","[var(--z-popup)]")].join(" ")}" />;\nconst z2 = { zIndex: on ? 2020 : 2010 };\nconst z3 = { zIndex: Z_LAYERS.popup, top: 9999 };\nconst h1 = <i className="${[Ne("shadow","[0_1px_2px_#000]"),Ne("shadow","md"),"shadow",Ne("shadow","lg"),Ne("shadow","(--elevation-panel)"),Ne("shadow","black/20"),Ne("drop-shadow","md")].join(" ")}" />;\nconst h2 = { boxShadow: '0 1px 2px rgba(0,0,0,.1)' };\nconst h3 = { boxShadow: 'none', outline: 'var(--elevation-raised)' };\n`,Je={spacing:7,"font-size":3,"z-index":4,shadow:3,hex:1,colour:4},Ue={colour:4},We={"ellipsis-label":9},qe=e=>a.filter(t=>e[t]).map(t=>`${t} ${e[t]}`).join(", ")||"nothing";var _e="ui-kit.config.json",Ge="ui-kit.baseline.json",Ke="efficient-shell-ui-check",He=`${Ke}: every surface a person operates takes its UI from efficient-shell (harness UI-24).\n\n ${Ke} check this repository against ${Ge}\n ${Ke} --print print today's counts as a baseline, and change nothing\n ${Ke} --summary print totals per kind and per folder, as Markdown\n ${Ke} --json print the result as JSON\n ${Ke} --update lower the lines whose counts fell, and delete the ones at zero\n ${Ke} --update --allow-move also follow a renamed or split file (no total may rise)\n ${Ke} --init write the first ${Ge}\n ${Ke} --init --kind <kind> take the baseline for a kind just added to "kinds"\n ${Ke} --no-base do not compare with the pull request's base branch\n\nKinds: ${a.join(", ")}\nReads ${_e} in the current directory.`;var Qe=(e,t)=>`${e} ${t}${1===e?"":"s"}`,Ve=(e,t)=>{const n=B(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(`${Ke}: ${r}\n\n${He}`),2;if(r.help)return t.out(He),0;if(r.version)return t.out(t.version),0;const c=e=>(r.json?t.out(JSON.stringify({tool:Ke,version:t.version,ok:!1,failures:[e]},null,2)):t.err(`${Ke}: ${e}`),1),p=n(t.cwd,_e);if(!i(p))return c(`no ${_e} in ${t.cwd}. Run it from the repository root; the harness has the template.`);let f,g;try{f=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=>!O(e))?(i(`${t} must be a list of objects`),[]):e;if(!O(e))throw new P(`${t}: must be a JSON object`);for(const t of Object.keys(e))D.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"'),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 p=r(e.output,'"output"').map((e,t)=>({files:o(e.files,`"output"[${t}].files`,{required:!0}),reason:s(e.reason,`"output"[${t}]`)})),f=[],g=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}`;g.has(u)&&i(`${n}: ${r} already has an allow entry for "${e.kind}"`),g.add(u),f.push({file:r,kind:e.kind,count:e.count,reason:d})}),n.length)throw new P(`${t}:\n - ${n.join("\n - ")}`);return{schema:1,kinds:a.filter(e=>c.includes(e)),include:d,exclude:u,includeImporting:h,output:p,allow:f}}(JSON.parse(o(p,"utf8")),_e)}catch(e){return c(e instanceof P?e.message:`${_e} is not valid JSON: ${e.message}`)}try{g=t.loadTypeScript()}catch{return c('this check reads the TypeScript AST and found no "typescript" package here. Install it as a devDependency.')}const w=function(e){const t=[],n=u,i=[["fixture.tsx",Pe,Oe],["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",De],["tokens.tsx",Fe,Je],["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",We]];for(const[o,s,r]of i){const i=Re(je(e,o,s,n));n.some(e=>(i[e]??0)!==(r[e]??0))&&t.push(`${o}: read ${qe(i)}; it holds ${qe(r)}`)}const o=Re(Se('\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)!==(Ue[e]??0))&&t.push(`style.css: read ${qe(o)}; it holds ${qe(Ue)}`);const s=Re(je(e,"fixture.tsx",Pe,["button"]));return"button"!==Object.keys(s).join()&&t.push(`asked for button alone, the reader reported ${qe(s)}`),t}(g);if(w.length)return c(`the reader misread its own fixtures with typescript ${g.version}, so nothing it says about this repository can be trusted:\n - `+w.join("\n - "));const k=function(e,t,s){const r=[],a=y(s.exclude),l=y(s.output.flatMap(e=>e.files)),c=new Map,u=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===I(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}]`));const p=new Set,f=s.kinds.includes("colour"),g=e=>($e(e)||f&&ye(e))&&!a(e)&&!l(e);for(const e of I(t,s.include))g(e)&&p.add(e);for(const n of s.includeImporting)for(const i of I(t,n.files))g(i)&&$e(i)&&!p.has(i)&&ze(Ae(e,i,u(i)),n.modules)&&p.add(i);const w=[...p].sort(),k=s.kinds.filter(e=>!d(e)),b=new Map,$=new Map,v=new Set;for(const t of w){const n=ye(t)?Se(u(t),k):je(e,t,u(t),k,v);let i=!1;for(const e of k){const o=n[e]?.length??0;o&&($.set(A(t,e),o),i=!0)}i&&b.set(t,n)}let S=[],j=[],L=[];const R=s.kinds.filter(d);if(R.length){const e=n(t,N);if(i(e)){const t=JSON.parse(o(e,"utf8")),n=["dependencies","peerDependencies","optionalDependencies"].flatMap(e=>Object.keys(t[e]??{})),i=new Set([...v].flatMap(e=>m[e]??[])),r=[...new Set(n)].sort();if(s.kinds.includes("kit-dep")){const e=r.filter(e=>"kit-dep"===x(e));S=e.filter(e=>!i.has(e)),j=e.filter(e=>i.has(e)),S.length&&$.set(A(N,"kit-dep"),S.length)}s.kinds.includes("chart-dep")&&(L=r.filter(e=>"chart-dep"===x(e)),L.length&&$.set(A(N,"chart-dep"),L.length))}else for(const e of R)r.push(`"kinds" includes "${e}", and there is no ${N} here to read.`)}for(const e of s.allow)(d(e.kind)?e.file===N:p.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:w,hits:b,counts:$,kitDeps:S,shellPeers:j,chartDeps:L,problems:r}}(g,t.cwd,f);if(0===k.files.length)return c(`read no files. "include" in ${_e} matches nothing, so a pass would mean nothing.`);const b=n(t.cwd,Ge),$=r.json,v=e=>{$||t.out(e)};if(r.print)return t.out(M(Me(f,k,f.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}=z(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=>z(e).file)).size} of ${Qe(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} | ${h[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}(f,k))t.out(e);return 0}let S=null;if(i(b))try{S=T(o(b,"utf8"),Ge)}catch(e){return c(e instanceof R?e.message:String(e))}if(r.init){const e=r.kinds.filter(e=>!l(e)||!f.kinds.includes(e));if(e.length)return c(`--kind ${e.join(", ")}: not in "kinds" in ${_e}. Add it there first.`);const t=r.kinds;if(S){if(0===t.length)return c(`${Ge} 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=>S.kinds.includes(e));if(e.length)return c(`the baseline was already taken for ${e.join(", ")}. Its lines only go down; use --update.`);const n=Me(f,k,t);S={kinds:[...S.kinds,...t],counts:new Map([...S.counts,...n.counts])}}else{if(t.length)return c(`there is no ${Ge} yet. Run --init on its own first.`);S=Me(f,k,f.kinds)}s(b,M(S)),v(`${Ke}: wrote ${Ge} (${Qe(S.counts.size,"line")}: ${Ve(S.counts,S.kinds)})`)}if(!S)return c(`no ${Ge}. This repository has not adopted the check yet: run ${Ke} --init, and commit the file.`);if(r.update){const e=function(e,t,n,{allowMove:i=!1}={}){const o=Ce(e,t),s=Me(e,n,o),r=new Map([...t.counts].filter(([e])=>o.includes(z(e).kind)));if(i){const e=B(r),n=B(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:Be(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:Be(r,a),refused:[]}}(f,S,k,{allowMove:r.allowMove});if(e.refused.length)return c(`--allow-move follows code that moved, and this is more of it than before:\n - ${e.refused.join("\n - ")}\nNothing was written.`);S=e.baseline,s(b,M(S)),v(`${Ke}: ${e.lowered?`changed ${Qe(e.lowered,"line")} in`:"nothing to change in"} ${Ge}`)}const j=function(e,t,n){const i=[],o=[],s=[...n.problems],r=Ee(e),a=new Set(Ce(e,t)),c=e.kinds.filter(e=>!t.kinds.includes(e));c.length&&s.push(`"kinds" names ${c.map(e=>`"${e}"`).join(", ")}, and the baseline was never taken for ${1===c.length?"it":"them"}. Run: efficient-shell-ui-check --init ${c.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(C)){const{file:c,kind:d}=z(e);if(!l(d)||!a.has(d))continue;const u=n.counts.get(e)??0,p=r.get(e)??0,f=t.counts.get(e)??0;u>p+f?i.push(`${c}: ${d} ${u}, and its line allows ${p+f}${Te(n,c,d)}. ${h[d].counts} is counted; use ${h[d].instead}.`):u<p?s.push(`${c}: ${d} ${u}, and "allow" in ui-kit.config.json says ${p}. ${0===u?"Delete the entry":`Lower its count to ${u}`}: an exception does not outlive what it excused.`):u<p+f&&o.push(`${c}: ${d} ${u}, and its line says ${p+f}`)}return{grown:i,shrunk:o,other:s,updateFixes:0===i.length&&0===s.length&&o.length>0}}(f,S,k),L=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()}${Ge}`]);if(null===r)return{problems:[],note:`${s} has no ${Ge} yet (adoption)`};let a;try{a=T(r,`${s}:${Ge}`)}catch{return{problems:[],note:`${s}'s ${Ge} could not be read; the base branch was not compared`}}const l=B(a.counts),c=B(t.counts);return{problems:n.filter(e=>a.kinds.includes(e)&&(c[e]??0)>(l[e]??0)).map(e=>`${Ge} holds ${c[e]??0} of "${e}", and ${s} holds ${l[e]??0}. The baseline only goes down: use ${h[e].instead}. A count that is meant to stay goes in "allow" in ${_e}, with its reason.`),note:`compared with ${s}`}}(t,S,f.kinds),E=f.kinds.filter(e=>S.kinds.includes(e)),F=`${Ke} --update`,J=[...j.other,...j.grown,...j.shrunk.map(e=>`${e}. Run: ${F}`),...L.problems],U=0===J.length;if(r.json){const e=new Map(f.allow.map(e=>[`${e.file}:${e.kind}`,e.count]));return t.out(JSON.stringify({tool:Ke,version:t.version,ok:U,schema:f.schema,kinds:f.kinds,files:k.files.length,counts:B(k.counts),baseline:B(S.counts),allowed:B(e),kitDeps:k.kitDeps,shellPeers:k.shellPeers,chartDeps:k.chartDeps,failures:J},null,2)),U?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 ${g.version})`),t.out(` ok read ${Qe(k.files.length,"file")}`),W(`${_e} and ${Ge} describe this repository`,j.other),W("no file draws more of its own UI than its line allows",j.grown),W("every line is exact: a count that fell is a line to lower",j.shrunk,`Run: ${F}${j.updateFixes?"":" (after the failures above are fixed)"}`),L.note&&W(`the baseline is no higher than the base branch (${L.note})`,L.problems);const q=new Set([...k.counts.keys()].map(e=>z(e).file));return t.out(` ok PROGRESS: ${q.size} of ${Qe(k.files.length,"file")} still draw UI of their own: `+Ve(k.counts,E)),t.out(""),U?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${Qe(J.length,"problem")})`),U?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.5.0"});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{MediaUploadField as e}from"./chunk-
|
|
2
|
-
return n("section",{"aria-label":
|
|
1
|
+
import{MediaUploadField as e}from"./chunk-PM4Y2FMQ.js";import{BrandMark as r}from"./chunk-MI67DI3H.js";import{Button_default as a}from"./chunk-UJJXWLHE.js";import{useShellStrings as t}from"./chunk-43MCNASD.js";import{useRef as i,useState as l,useEffect as s}from"react";import{jsxs as n,jsx as c}from"react/jsx-runtime";function d({committedUrl:d,committedHasAlpha:o=null,committedIsLight:m=null,fallbackUrl:g,fallbackHasAlpha:h=null,fallbackIsLight:u=null,subjectName:b,assetName:p,onSave:x,onRemove:f,accept:v="image/png,image/x-icon,image/vnd.microsoft.icon,.ico,image/svg+xml,image/jpeg,image/webp",acceptHint:y="PNG · ICO · SVG · JPG · WEBP",maxBytes:N=5242880,previews:w=[],disabled:k=!1}){const j=i(null),[L,U]=l(null),[R,C]=l(""),[H,A]=l(""),[F,I]=l(!1),[E,M]=l(!1),O=function(e){return e.trim().toLocaleLowerCase().split(/\s+/).at(-1)||"image"}(p),P=t().brandAsset,S=R||d||g||"",B=L?null:d?o:h,G=L?null:d?m:u;s(()=>()=>{j.current&&URL.revokeObjectURL(j.current)},[]);const J=()=>{j.current&&(URL.revokeObjectURL(j.current),j.current=null)};/* @__PURE__ */
|
|
2
|
+
return n("section",{"aria-label":P.region(p,b),className:"grid gap-4 lg:grid-cols-2",children:[
|
|
3
3
|
/* @__PURE__ */n("div",{className:"rounded-lg border border-gray-200 bg-white p-4",children:[
|
|
4
|
-
/* @__PURE__ */c(e,{value:
|
|
4
|
+
/* @__PURE__ */c(e,{value:S,onChange:()=>{},onFile:e=>{if(k)return;J();const r=URL.createObjectURL(e);j.current=r,U(e),C(r),A("")},label:p,hint:H||P.usedFor(b),error:H||void 0,accept:v,acceptHint:y,maxSizeBytes:N,fit:"contain",height:180,allowRemove:!1,busy:F||E,disabled:k}),
|
|
5
5
|
/* @__PURE__ */n("div",{className:"mt-3 flex flex-wrap gap-2",children:[
|
|
6
|
-
/* @__PURE__ */c(a,{onClick:async()=>{if(L&&!k&&!F){I(!0),A("");try{await x(L)
|
|
7
|
-
/* @__PURE__ */c("h3",{className:"text-sm font-semibold text-gray-900",children:
|
|
8
|
-
/* @__PURE__ */c("div",{className:"mt-3 grid gap-3",children:w.map(e=>{const a=/* @__PURE__ */c(r,{src:
|
|
6
|
+
/* @__PURE__ */c(a,{onClick:async()=>{if(L&&!k&&!F){I(!0),A("");try{await x(L),J(),U(null),C("")}catch(e){A(e instanceof Error?e.message:P.saveFailed(O,p))}finally{I(!1)}}},disabled:!L||k,loading:F,children:P.save(O,p)}),(L||d)&&/* @__PURE__ */c(a,{variant:"ghost-danger",onClick:async()=>{if(!k&&!E){if(L)return J(),U(null),C(""),void A("");if(d){M(!0),A("");try{await f()}catch(e){A(e instanceof Error?e.message:P.removeFailed(O,p))}finally{M(!1)}}}},disabled:k,loading:E,children:L?P.discard:P.remove(O,p)})]})]}),w.length>0&&/* @__PURE__ */n("div",{className:"rounded-lg border border-gray-200 bg-white p-4","aria-label":P.previews(p),children:[
|
|
7
|
+
/* @__PURE__ */c("h3",{className:"text-sm font-semibold text-gray-900",children:P.preview}),
|
|
8
|
+
/* @__PURE__ */c("div",{className:"mt-3 grid gap-3",children:w.map(e=>{const a=/* @__PURE__ */c(r,{src:S,alt:P.alt(b,p),slot:e.slot,surface:e.surface,adaptive:!0,hasAlpha:B,isLight:G,size:"browser-tab"===e.kind?16:void 0});/* @__PURE__ */
|
|
9
9
|
return n("div",{"data-brand-preview":!0,className:"dark"===e.surface?"text-white":"text-gray-900",children:[
|
|
10
10
|
/* @__PURE__ */c("div",{className:"mb-2 text-xs font-medium text-gray-500",children:e.label}),"browser-tab"===e.kind?/* @__PURE__ */n("div",{className:"flex items-end gap-1 border-b border-gray-200",children:[
|
|
11
11
|
/* @__PURE__ */n("div",{className:"flex max-w-[220px] items-center gap-2 rounded-t-lg border border-b-0 border-gray-200 bg-white px-3 py-2",children:[a,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r="12.5.0",a=r;export{a as APP_VERSION,r as VERSION};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setBoundaryErrorReporter as e}from"./chunk-KNUR2UEG.js";import{VERSION as t}from"./chunk-RJ3J4BLH.js";var n=-1,i=()=>n,a=e=>{addEventListener("pageshow",t=>{t.persisted&&(n=t.timeStamp,e(t))},!0)},r=(e,t,n,i)=>{let a,r;return o=>{var s,c;t.value>=0&&(o||i)&&(r=t.value-(a??0),(r||void 0===a)&&(a=t.value,t.delta=r,t.rating=(s=t.value)>(c=n)[1]?"poor":s>c[0]?"needs-improvement":"good",e(t)))}},o=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},s=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},c=()=>s()?.activationStart??0,d=-1,l=/* @__PURE__ */new Set,u=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,f=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of l)e();isFinite(d)||(d="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",f,!0))}},h=(e=!1)=>{if(e&&(d=1/0),d<0){const e=c(),t=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e)?.startTime;d=t??u(),addEventListener("visibilitychange",f,!0),addEventListener("prerenderingchange",f,!0),a(()=>{setTimeout(()=>{d=u()})})}return{get firstHiddenTime(){return d},onHidden(e){l.add(e)}}},g=(e,t=-1,n,a=0,r,o,d)=>{const l=s(),u=l?.navigationId||0;let f="navigate";return n?f=n:i()>=0?f="back-forward-cache":l&&(document.prerendering||c()>0?f="prerender":document.wasDiscarded?f="restore":l.type&&(f=l.type.replace(/_/g,"-"))),{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:f,navigationId:a||u,navigationInteractionId:r,navigationURL:o||l?.name,navigationStartTime:d||0}},v=/* @__PURE__ */new WeakMap;function p(e,t){let n=v.get(t);return n||(n=/* @__PURE__ */new WeakMap,v.set(t,n)),n.get(e)||n.set(e,new t),n.get(e)}var m,y=class{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const t=this.o[0],n=this.o.at(-1);this.i&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}},T=(e,t,n={})=>{try{const i=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(i.length>0){const e=new PerformanceObserver(e=>{queueMicrotask(()=>{const n=e.getEntries();i.length>1&&n.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(n)})});for(const t of i)e.observe({type:t,buffered:!0,...n});return e}}catch{}},w=e=>globalThis.PerformanceObserver?.supportedEntryTypes?.includes("soft-navigation")&&"function"==typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint&&e&&e.reportSoftNavs,I=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const t=e.keys().next().value;void 0!==t&&e.delete(t)}},b=e=>{let t=!1;return()=>{t||(e(),t=!0)}},C=class{l},E=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},L=[1800,3e3],P=(e,t={})=>{const n=w(t);E(()=>{const s=p(t,C),d=h();let l,u=g("FCP");const f=T(["paint"],e=>{for(const t of e)"first-contentful-paint"===t.name&&(f.disconnect(),t.startTime<d.firstHiddenTime&&(u.value=Math.max(t.startTime-c(),0),u.entries.push(t),u.navigationId=t.navigationId||u.navigationId,l(!0)))});f&&(l=r(e,u,L,t.reportAllChanges),a(n=>{u=g("FCP",-1,"back-forward-cache",u.navigationId,u.navigationInteractionId,u.navigationURL,i()),l=r(e,u,L,t.reportAllChanges),o(()=>{u.value=performance.now()-n.timeStamp,l(!0)})})),n&&T(["soft-navigation"],n=>{n.forEach(n=>{s.l&&n.navigationId&&I(s.l,n);const i=Math.max((n.presentationTime||n.paintTime||0)-n.startTime,0);u=g("FCP",i,"soft-navigation",n.navigationId,n.interactionId,n.name,n.startTime),l=r(e,u,L,t.reportAllChanges),l(!0)})},t)})},A=[.1,.25],k=0,S=1/0,z=0,M=e=>{for(const t of e)t.interactionId&&(S=Math.min(S,t.interactionId),z=Math.max(z,t.interactionId),k=z?(z-S)/7+1:0)},$=()=>m?k:performance.interactionCount??0,_=class{u=0;v=[];m=/* @__PURE__ */new Map;p;T;_(){return $()-this.u}M(){this.u=$(),this.v.length=0,this.m.clear()}L(e){const t=this._(),n=Math.min(this.v.length-1,Math.floor(t/50));return!t||-1!==n||"soft-navigation"!==e&&"back-forward-cache"!==e?this.v[n]:{P:8,id:-1,entries:[]}}h(e){if(this.p?.(e),!e.interactionId)return;const t=this.v.at(-1);let n=this.m.get(e.interactionId);if(n||this.v.length<10||e.duration>t.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.m.set(n.id,n),this.v.push(n)),this.v.sort((e,t)=>t.P-e.P),this.v.length>10){const e=this.v.splice(10);for(const t of e)this.m.delete(t.id)}this.T?.(n)}}},R=e=>{const t="requestIdleCallback"in globalThis?1e3:0,n=globalThis.requestIdleCallback||setTimeout,i=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else{const a=b(e);let r=-1;const o=()=>{i(r),a()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),r=n(()=>{removeEventListener("visibilitychange",o,{capture:!0}),a()},{timeout:t})}},Z=[200,500],F=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const n=h();E(()=>{"interactionCount"in performance||m||(m=T(["event"],M,{durationThreshold:0}));let o,s=g("INP");const c=p(t,_),d=(n,i,a,d,l)=>{c.M(),s=g("INP",-1,n,i,a,d,l),o=r(e,s,Z,t.reportAllChanges)},l=()=>{const e=c.L(s.navigationType);e&&e.P!==s.value&&(s.value=e.P,s.entries=e.entries,o())},u=e=>{l(),o(!0),d("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},f=(e,t=!1)=>{R(()=>{for(const t of e)"soft-navigation"!==t.entryType?c.h(t):u(t);l(),t&&o(!0)})},h=["event","first-input"];w(t)&&h.push("soft-navigation");const v=T(h,f,{...t,durationThreshold:t.durationThreshold??40});o=r(e,s,Z,t.reportAllChanges),v&&(n.onHidden(()=>{f(v.takeRecords(),!0)}),a(()=>{d("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,i())}))})},j=class{p;l;h(e){this.p?.(e)}},x=[2500,4e3],B=[800,1800],N=e=>{document.prerendering?E(()=>N(e)):"complete"!==document.readyState?addEventListener("load",()=>N(e),!0):setTimeout(e)};var U=/^[A-Za-z0-9/_:.\-[\]{}*@~]+$/,H=/^[A-Za-z_$][A-Za-z0-9_$.]*$/,O=/^[A-Za-z0-9][A-Za-z0-9.+_-]*$/;var J=class{constructor(e){this.head=e}head;events=[];waiting=/* @__PURE__ */new Map;seen=/* @__PURE__ */new Set;get size(){return this.events.length}addVital(e){this.events.push(e)}addError(e){const t=function(e){return e.frames.length?`${e.name}|${e.frames.join("|")}`:`${e.name}|${e.message.replace(/\d/g,"0")}`}(e),n=this.waiting.get(t);return n?(n.count=Math.min(1e3,n.count+e.count),!0):!(this.seen.has(t)||this.seen.size>=20)&&(this.seen.add(t),this.waiting.set(t,e),this.events.push(e),!0)}drain(){const e=this.events;this.events=[],this.waiting.clear();const t=[],n=JSON.stringify({...this.head,events:[]}).length;let i=[],a=n;for(const r of e){const e=JSON.stringify(r).length+1;n+e>30720||((50===i.length||a+e>30720)&&(t.push({...this.head,events:i}),i=[],a=n),i.push(r),a+=e)}return i.length&&t.push({...this.head,events:i}),t}},q=/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,K=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]*)?|\b[Bb]earer\s+[A-Za-z0-9._~+/=-]{8,}/g,V=/\b[a-z][a-z0-9+.-]*:\/\/\S+/gi,W=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi,D=/\d{4,}/g,G=/(^|[/:])(?:\d+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{16,})(?=$|[/:])/gi,Q=/^[a-z][a-z0-9+.-]*:\/\/[^/]*/i,X=/(?:\(|@|\bat\s+)?((?:[a-z][a-z0-9+.-]*:\/\/|\/)[^\s()@]*?):(\d+):(\d+)\)?\s*$/i;function Y(e,t,n){const i=e.replace(Q,"").split(/[?#]/,1)[0];return i?`${i}:${t}:${n}`.slice(0,256):null}function ee(e){if("string"!=typeof e)return[];const t=[];for(const n of e.split("\n")){const e=X.exec(n.trim()),i=e&&Y(e[1],e[2],e[3]);if(i&&t.push(i),5===t.length)break}return t}function te(e){const t=e instanceof Error?e.name:void 0;return"string"==typeof t&&t.length<=64&&H.test(t)?t:"Error"}function ne(e){if("string"!=typeof e)return"unknown";const t=e.trim().replace(Q,"").split(/[?#]/,1)[0].replace(G,(e,t)=>":"===t?":id":`${t}:id`);return t&&t.length<=128&&!t.includes("//")&&U.test(t)?t:"unknown"}var ie={flush(){},reportError(){},stop(){}},ae=null,re=/* @__PURE__ */new Set(["LCP","FCP","TTFB"]);function oe(e,t,n){const i=function(e){if(e.anonymous)return{credentials:"omit",headers:{"Content-Type":"application/json"}};const t=e.getAccessToken();return t?{credentials:"same-origin",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}}:null}(t);if(!i)return;const a=t.anonymous?"/api/storefront-analytics/web-vitals/":"/api/client-telemetry/web-batches/";n(t.endpoint??a,{...i,method:"POST",keepalive:!0,body:JSON.stringify(e)}).catch(e=>{console.debug("[efficient-shell] client telemetry batch dropped:",e)})}function se(e){((e,t={})=>{let n=!1;const s=w(t);E(()=>{let d,l=h(),u=g("LCP");const f=p(t,j),v=(i,a,o,s,c)=>{u=g("LCP",-1,i,a,o,s,c),d=r(e,u,x,t.reportAllChanges),n=!1,"soft-navigation"===i&&(l=h(!0))},m=e=>{f.l&&e.navigationId&&I(f.l,e),n||d(!0),v("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime);const t=e.getLargestInteractionContentfulPaint?.();t&&y([t])},y=e=>{t.reportAllChanges||s||(e=e.slice(-1));for(const t of e){if(!t)continue;if("soft-navigation"===t.entryType){m(t);continue}let e=0,n=[],i=t.startTime;if("largest-contentful-paint"===t.entryType)e=Math.max(t.startTime-c(),0),f.h(t),n=[t];else if("interaction-contentful-paint"===t.entryType){const a=t;if(!u.navigationId)continue;if("interactionId"in a&&a.interactionId!=u.navigationInteractionId)continue;i=a.largestContentfulPaint?.renderTime||0,e=Math.max(i-t.startTime,0),a.largestContentfulPaint&&(f.h(a.largestContentfulPaint),n=[a.largestContentfulPaint])}i<l.firstHiddenTime&&(u.value=e,u.entries=n,d())}},w=["largest-contentful-paint"];s&&w.push("interaction-contentful-paint","soft-navigation");const b=T(w,y);if(b){d=r(e,u,x,t.reportAllChanges);const c=["keydown","click","visibilitychange"],l=e=>{if(e.isTrusted&&!n){const e=u.id;R(()=>{if(!n){if(!s){b.disconnect();for(const e of c)removeEventListener(e,l,{capture:!0})}e===u.id&&(n=!0,d(!0))}})}};for(const e of c)addEventListener(e,l,{capture:!0});a(a=>{v("back-forward-cache",u.navigationId,u.navigationInteractionId,u.navigationURL,i()),d=r(e,u,x,t.reportAllChanges),o(()=>{u.value=performance.now()-a.timeStamp,n=!0,d(!0)})})}})})(e),F(e),((e,t={})=>{const n=h();P(b(()=>{let s,c=g("CLS",0);const d=p(t,y),l=(n,i,a,o,l)=>{c=g("CLS",0,n,i,a,o,l),d.i=0,s=r(e,c,A,t.reportAllChanges)},u=(e=!1)=>{d.i>c.value&&(c.value=d.i,c.entries=d.o),s(e)},f=e=>{u(!0),l("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},h=e=>{for(const t of e)"soft-navigation"!==t.entryType?d.h(t):f(t);u()},v=["layout-shift"];w(t)&&v.push("soft-navigation");const m=T(v,h);m&&(s=r(e,c,A,t.reportAllChanges),n.onHidden(()=>{h(m.takeRecords()),s(!0)}),a(()=>{l("back-forward-cache",c.navigationId,c.navigationInteractionId,c.navigationURL,i()),o(s)}),setTimeout(s))}))})(e),P(e),((e,t={})=>{const n=w(t);let o=g("TTFB"),d=r(e,o,B,t.reportAllChanges);N(()=>{const l=s();if(l){const s=l.responseStart;o.value=Math.max(s-c(),0),o.entries=[l],d(!0),a(()=>{o=g("TTFB",0,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,i()),d=r(e,o,B,t.reportAllChanges),d(!0)}),n&&T(["soft-navigation"],n=>{n.forEach(n=>{n.navigationId&&(o=g("TTFB",0,"soft-navigation",n.navigationId,n.interactionId,n.name,n.startTime),o.entries=[n],d=r(e,o,B,t.reportAllChanges),d(!0))})},t)}})})(e)}function ce(n){if(ae?.stop(),ae=null,!1===n.enabled||"undefined"==typeof window||"undefined"==typeof document)return ie;if(!function(e){const t="string"==typeof e.app&&O.test(e.app),n="string"==typeof e.release&&O.test(e.release);return t&&n||console.warn("[efficient-shell] client telemetry not started: `app` and `release` must be version-like strings."),t&&n}(n))return ie;const i=function(e){const t=e.vitalsSampleRate??1;return t>0&&(t>=1||(e.random??Math.random)()<t)}(n);if(n.anonymous&&!i)return ie;const a=n.fetch??window.fetch.bind(window),r=new J({app:n.app,release:n.release,shell_version:O.test(t)?t:""}),o=ne(n.routeKey()),s=function(e=("undefined"==typeof window?void 0:window)){if(!e)return"desktop";const t="function"==typeof e.matchMedia&&e.matchMedia("(pointer: coarse)").matches,n=e.innerWidth;return n<600?"mobile":t&&n<1280?"tablet":"desktop"}(window);let c=!1;const d=()=>{for(const e of r.drain())oe(e,n,a)},l=e=>{c||n.anonymous||(r.addError(e),r.size>=50&&d())},u=(e,t)=>{return{type:"error",source:t,name:te(e),message:(a=e,i=a instanceof Error?a.message:"string"==typeof a?a:a&&"object"==typeof a&&"string"==typeof a.message?a.message:"",i.slice(0,640).replace(q,"[redacted]").replace(K,"[redacted]").replace(V,"[url]").replace(W,"[id]").replace(D,"[n]").replace(/\s+/g," ").trim().slice(0,160)),frames:ee(e instanceof Error?e.stack:void 0),route:ne(n.routeKey()),count:1};var i,a};i&&(n.observeVitals??se)(e=>{c||(r.addVital(function(e,t,n,i){return{type:"vital",name:e.name,value:e.value,route:re.has(e.name)?t:n(),navigation:e.navigationType??"navigate",device:i}}(e,o,()=>ne(n.routeKey()),s)),r.size>=50&&d())});const f=n.anonymous?()=>{}:function(t,n){const i=e=>{const{error:i,message:a,filename:r,lineno:o,colno:s}=e;if(null!=i)return void t(n(i,"onerror"));const c=r?ee(`at ${r}:${o??0}:${s??0}`):[];t({...n(a??"","onerror"),frames:c})},a=e=>t(n(e.reason,"unhandledrejection"));window.addEventListener("error",i),window.addEventListener("unhandledrejection",a);const r=e(e=>t(n(e,"boundary")));return()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",a),r()}}(l,u),h=()=>{"hidden"===document.visibilityState&&d()};document.addEventListener("visibilitychange",h),window.addEventListener("pagehide",d);const g=window.setInterval(d,n.flushIntervalMs??6e4),v={flush:d,reportError:e=>l(u(e,"boundary")),stop(){c||(d(),c=!0,f(),document.removeEventListener("visibilitychange",h),window.removeEventListener("pagehide",d),window.clearInterval(g),ae===v&&(ae=null))}};return ae=v,v}export{ce as startClientTelemetry};
|
|
1
|
+
import{setBoundaryErrorReporter as e}from"./chunk-KNUR2UEG.js";import{VERSION as t}from"./chunk-4XSE5PV2.js";var n=-1,i=()=>n,a=e=>{addEventListener("pageshow",t=>{t.persisted&&(n=t.timeStamp,e(t))},!0)},r=(e,t,n,i)=>{let a,r;return o=>{var s,c;t.value>=0&&(o||i)&&(r=t.value-(a??0),(r||void 0===a)&&(a=t.value,t.delta=r,t.rating=(s=t.value)>(c=n)[1]?"poor":s>c[0]?"needs-improvement":"good",e(t)))}},o=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},s=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},c=()=>s()?.activationStart??0,d=-1,l=/* @__PURE__ */new Set,u=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,f=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of l)e();isFinite(d)||(d="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",f,!0))}},h=(e=!1)=>{if(e&&(d=1/0),d<0){const e=c(),t=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e)?.startTime;d=t??u(),addEventListener("visibilitychange",f,!0),addEventListener("prerenderingchange",f,!0),a(()=>{setTimeout(()=>{d=u()})})}return{get firstHiddenTime(){return d},onHidden(e){l.add(e)}}},g=(e,t=-1,n,a=0,r,o,d)=>{const l=s(),u=l?.navigationId||0;let f="navigate";return n?f=n:i()>=0?f="back-forward-cache":l&&(document.prerendering||c()>0?f="prerender":document.wasDiscarded?f="restore":l.type&&(f=l.type.replace(/_/g,"-"))),{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:f,navigationId:a||u,navigationInteractionId:r,navigationURL:o||l?.name,navigationStartTime:d||0}},v=/* @__PURE__ */new WeakMap;function p(e,t){let n=v.get(t);return n||(n=/* @__PURE__ */new WeakMap,v.set(t,n)),n.get(e)||n.set(e,new t),n.get(e)}var m,y=class{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const t=this.o[0],n=this.o.at(-1);this.i&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}},T=(e,t,n={})=>{try{const i=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(i.length>0){const e=new PerformanceObserver(e=>{queueMicrotask(()=>{const n=e.getEntries();i.length>1&&n.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(n)})});for(const t of i)e.observe({type:t,buffered:!0,...n});return e}}catch{}},w=e=>globalThis.PerformanceObserver?.supportedEntryTypes?.includes("soft-navigation")&&"function"==typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint&&e&&e.reportSoftNavs,I=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const t=e.keys().next().value;void 0!==t&&e.delete(t)}},b=e=>{let t=!1;return()=>{t||(e(),t=!0)}},E=class{l},C=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},L=[1800,3e3],P=(e,t={})=>{const n=w(t);C(()=>{const s=p(t,E),d=h();let l,u=g("FCP");const f=T(["paint"],e=>{for(const t of e)"first-contentful-paint"===t.name&&(f.disconnect(),t.startTime<d.firstHiddenTime&&(u.value=Math.max(t.startTime-c(),0),u.entries.push(t),u.navigationId=t.navigationId||u.navigationId,l(!0)))});f&&(l=r(e,u,L,t.reportAllChanges),a(n=>{u=g("FCP",-1,"back-forward-cache",u.navigationId,u.navigationInteractionId,u.navigationURL,i()),l=r(e,u,L,t.reportAllChanges),o(()=>{u.value=performance.now()-n.timeStamp,l(!0)})})),n&&T(["soft-navigation"],n=>{n.forEach(n=>{s.l&&n.navigationId&&I(s.l,n);const i=Math.max((n.presentationTime||n.paintTime||0)-n.startTime,0);u=g("FCP",i,"soft-navigation",n.navigationId,n.interactionId,n.name,n.startTime),l=r(e,u,L,t.reportAllChanges),l(!0)})},t)})},A=[.1,.25],k=0,S=1/0,z=0,M=e=>{for(const t of e)t.interactionId&&(S=Math.min(S,t.interactionId),z=Math.max(z,t.interactionId),k=z?(z-S)/7+1:0)},$=()=>m?k:performance.interactionCount??0,_=class{u=0;v=[];m=/* @__PURE__ */new Map;p;T;_(){return $()-this.u}M(){this.u=$(),this.v.length=0,this.m.clear()}L(e){const t=this._(),n=Math.min(this.v.length-1,Math.floor(t/50));return!t||-1!==n||"soft-navigation"!==e&&"back-forward-cache"!==e?this.v[n]:{P:8,id:-1,entries:[]}}h(e){if(this.p?.(e),!e.interactionId)return;const t=this.v.at(-1);let n=this.m.get(e.interactionId);if(n||this.v.length<10||e.duration>t.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.m.set(n.id,n),this.v.push(n)),this.v.sort((e,t)=>t.P-e.P),this.v.length>10){const e=this.v.splice(10);for(const t of e)this.m.delete(t.id)}this.T?.(n)}}},Z=e=>{const t="requestIdleCallback"in globalThis?1e3:0,n=globalThis.requestIdleCallback||setTimeout,i=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else{const a=b(e);let r=-1;const o=()=>{i(r),a()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),r=n(()=>{removeEventListener("visibilitychange",o,{capture:!0}),a()},{timeout:t})}},F=[200,500],R=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const n=h();C(()=>{"interactionCount"in performance||m||(m=T(["event"],M,{durationThreshold:0}));let o,s=g("INP");const c=p(t,_),d=(n,i,a,d,l)=>{c.M(),s=g("INP",-1,n,i,a,d,l),o=r(e,s,F,t.reportAllChanges)},l=()=>{const e=c.L(s.navigationType);e&&e.P!==s.value&&(s.value=e.P,s.entries=e.entries,o())},u=e=>{l(),o(!0),d("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},f=(e,t=!1)=>{Z(()=>{for(const t of e)"soft-navigation"!==t.entryType?c.h(t):u(t);l(),t&&o(!0)})},h=["event","first-input"];w(t)&&h.push("soft-navigation");const v=T(h,f,{...t,durationThreshold:t.durationThreshold??40});o=r(e,s,F,t.reportAllChanges),v&&(n.onHidden(()=>{f(v.takeRecords(),!0)}),a(()=>{d("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,i())}))})},j=class{p;l;h(e){this.p?.(e)}},x=[2500,4e3],B=[800,1800],N=e=>{document.prerendering?C(()=>N(e)):"complete"!==document.readyState?addEventListener("load",()=>N(e),!0):setTimeout(e)};var U=/^[A-Za-z0-9/_:.\-[\]{}*@~]+$/,O=/^[A-Za-z_$][A-Za-z0-9_$.]*$/,H=/^[A-Za-z0-9][A-Za-z0-9.+_-]*$/;var q=class{constructor(e){this.head=e}head;events=[];waiting=/* @__PURE__ */new Map;seen=/* @__PURE__ */new Set;get size(){return this.events.length}addVital(e){this.events.push(e)}addError(e){const t=function(e){return e.frames.length?`${e.name}|${e.frames.join("|")}`:`${e.name}|${e.message.replace(/\d/g,"0")}`}(e),n=this.waiting.get(t);return n?(n.count=Math.min(1e3,n.count+e.count),!0):!(this.seen.has(t)||this.seen.size>=20)&&(this.seen.add(t),this.waiting.set(t,e),this.events.push(e),!0)}drain(){const e=this.events;this.events=[],this.waiting.clear();const t=[],n=JSON.stringify({...this.head,events:[]}).length;let i=[],a=n;for(const r of e){const e=JSON.stringify(r).length+1;n+e>30720||((50===i.length||a+e>30720)&&(t.push({...this.head,events:i}),i=[],a=n),i.push(r),a+=e)}return i.length&&t.push({...this.head,events:i}),t}},J=/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,K=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]*)?|\b[Bb]earer\s+[A-Za-z0-9._~+/=-]{8,}/g,V=/\b[a-z][a-z0-9+.-]*:\/\/\S+/gi,W=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi,D=/\d{4,}/g,G=/(^|[/:])(?:\d+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{16,})(?=$|[/:])/gi,X=/^[a-z][a-z0-9+.-]*:\/\/[^/]*/i,Q=/(?:\(|@|\bat\s+)?((?:[a-z][a-z0-9+.-]*:\/\/|\/)[^\s()@]*?):(\d+):(\d+)\)?\s*$/i;function Y(e,t,n){const i=e.replace(X,"").split(/[?#]/,1)[0];return i?`${i}:${t}:${n}`.slice(0,256):null}function ee(e){if("string"!=typeof e)return[];const t=[];for(const n of e.split("\n")){const e=Q.exec(n.trim()),i=e&&Y(e[1],e[2],e[3]);if(i&&t.push(i),5===t.length)break}return t}function te(e){const t=e instanceof Error?e.name:void 0;return"string"==typeof t&&t.length<=64&&O.test(t)?t:"Error"}function ne(e){if("string"!=typeof e)return"unknown";const t=e.trim().replace(X,"").split(/[?#]/,1)[0].replace(G,(e,t)=>":"===t?":id":`${t}:id`);return t&&t.length<=128&&!t.includes("//")&&U.test(t)?t:"unknown"}var ie={flush(){},reportError(){},stop(){}},ae=null,re=/* @__PURE__ */new Set(["LCP","FCP","TTFB"]);function oe(e,t,n){const i=function(e){if(e.anonymous)return{credentials:"omit",headers:{"Content-Type":"application/json"}};const t=e.getAccessToken();return t?{credentials:"same-origin",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}}:null}(t);if(!i)return;const a=t.anonymous?"/api/storefront-analytics/web-vitals/":"/api/client-telemetry/web-batches/";n(t.endpoint??a,{...i,method:"POST",keepalive:!0,body:JSON.stringify(e)}).catch(e=>{console.debug("[efficient-shell] client telemetry batch dropped:",e)})}function se(e){((e,t={})=>{let n=!1;const s=w(t);C(()=>{let d,l=h(),u=g("LCP");const f=p(t,j),v=(i,a,o,s,c)=>{u=g("LCP",-1,i,a,o,s,c),d=r(e,u,x,t.reportAllChanges),n=!1,"soft-navigation"===i&&(l=h(!0))},m=e=>{f.l&&e.navigationId&&I(f.l,e),n||d(!0),v("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime);const t=e.getLargestInteractionContentfulPaint?.();t&&y([t])},y=e=>{t.reportAllChanges||s||(e=e.slice(-1));for(const t of e){if(!t)continue;if("soft-navigation"===t.entryType){m(t);continue}let e=0,n=[],i=t.startTime;if("largest-contentful-paint"===t.entryType)e=Math.max(t.startTime-c(),0),f.h(t),n=[t];else if("interaction-contentful-paint"===t.entryType){const a=t;if(!u.navigationId)continue;if("interactionId"in a&&a.interactionId!=u.navigationInteractionId)continue;i=a.largestContentfulPaint?.renderTime||0,e=Math.max(i-t.startTime,0),a.largestContentfulPaint&&(f.h(a.largestContentfulPaint),n=[a.largestContentfulPaint])}i<l.firstHiddenTime&&(u.value=e,u.entries=n,d())}},w=["largest-contentful-paint"];s&&w.push("interaction-contentful-paint","soft-navigation");const b=T(w,y);if(b){d=r(e,u,x,t.reportAllChanges);const c=["keydown","click","visibilitychange"],l=e=>{if(e.isTrusted&&!n){const e=u.id;Z(()=>{if(!n){if(!s){b.disconnect();for(const e of c)removeEventListener(e,l,{capture:!0})}e===u.id&&(n=!0,d(!0))}})}};for(const e of c)addEventListener(e,l,{capture:!0});a(a=>{v("back-forward-cache",u.navigationId,u.navigationInteractionId,u.navigationURL,i()),d=r(e,u,x,t.reportAllChanges),o(()=>{u.value=performance.now()-a.timeStamp,n=!0,d(!0)})})}})})(e),R(e),((e,t={})=>{const n=h();P(b(()=>{let s,c=g("CLS",0);const d=p(t,y),l=(n,i,a,o,l)=>{c=g("CLS",0,n,i,a,o,l),d.i=0,s=r(e,c,A,t.reportAllChanges)},u=(e=!1)=>{d.i>c.value&&(c.value=d.i,c.entries=d.o),s(e)},f=e=>{u(!0),l("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},h=e=>{for(const t of e)"soft-navigation"!==t.entryType?d.h(t):f(t);u()},v=["layout-shift"];w(t)&&v.push("soft-navigation");const m=T(v,h);m&&(s=r(e,c,A,t.reportAllChanges),n.onHidden(()=>{h(m.takeRecords()),s(!0)}),a(()=>{l("back-forward-cache",c.navigationId,c.navigationInteractionId,c.navigationURL,i()),o(s)}),setTimeout(s))}))})(e),P(e),((e,t={})=>{const n=w(t);let o=g("TTFB"),d=r(e,o,B,t.reportAllChanges);N(()=>{const l=s();if(l){const s=l.responseStart;o.value=Math.max(s-c(),0),o.entries=[l],d(!0),a(()=>{o=g("TTFB",0,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,i()),d=r(e,o,B,t.reportAllChanges),d(!0)}),n&&T(["soft-navigation"],n=>{n.forEach(n=>{n.navigationId&&(o=g("TTFB",0,"soft-navigation",n.navigationId,n.interactionId,n.name,n.startTime),o.entries=[n],d=r(e,o,B,t.reportAllChanges),d(!0))})},t)}})})(e)}function ce(n){if(ae?.stop(),ae=null,!1===n.enabled||"undefined"==typeof window||"undefined"==typeof document)return ie;if(!function(e){const t="string"==typeof e.app&&H.test(e.app),n="string"==typeof e.release&&H.test(e.release);return t&&n||console.warn("[efficient-shell] client telemetry not started: `app` and `release` must be version-like strings."),t&&n}(n))return ie;const i=function(e){const t=e.vitalsSampleRate??1;return t>0&&(t>=1||(e.random??Math.random)()<t)}(n);if(n.anonymous&&!i)return ie;const a=n.fetch??window.fetch.bind(window),r=new q({app:n.app,release:n.release,shell_version:H.test(t)?t:""}),o=ne(n.routeKey()),s=function(e=("undefined"==typeof window?void 0:window)){if(!e)return"desktop";const t="function"==typeof e.matchMedia&&e.matchMedia("(pointer: coarse)").matches,n=e.innerWidth;return n<600?"mobile":t&&n<1280?"tablet":"desktop"}(window);let c=!1;const d=()=>{for(const e of r.drain())oe(e,n,a)},l=e=>{c||n.anonymous||(r.addError(e),r.size>=50&&d())},u=(e,t)=>{return{type:"error",source:t,name:te(e),message:(a=e,i=a instanceof Error?a.message:"string"==typeof a?a:a&&"object"==typeof a&&"string"==typeof a.message?a.message:"",i.slice(0,640).replace(J,"[redacted]").replace(K,"[redacted]").replace(V,"[url]").replace(W,"[id]").replace(D,"[n]").replace(/\s+/g," ").trim().slice(0,160)),frames:ee(e instanceof Error?e.stack:void 0),route:ne(n.routeKey()),count:1};var i,a};i&&(n.observeVitals??se)(e=>{c||(r.addVital(function(e,t,n,i){return{type:"vital",name:e.name,value:e.value,route:re.has(e.name)?t:n(),navigation:e.navigationType??"navigate",device:i}}(e,o,()=>ne(n.routeKey()),s)),r.size>=50&&d())});const f=n.anonymous?()=>{}:function(t,n){const i=e=>{const{error:i,message:a,filename:r,lineno:o,colno:s}=e;if(null!=i)return void t(n(i,"onerror"));const c=r?ee(`at ${r}:${o??0}:${s??0}`):[];t({...n(a??"","onerror"),frames:c})},a=e=>t(n(e.reason,"unhandledrejection"));window.addEventListener("error",i),window.addEventListener("unhandledrejection",a);const r=e(e=>t(n(e,"boundary")));return()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",a),r()}}(l,u),h=()=>{"hidden"===document.visibilityState&&d()};document.addEventListener("visibilitychange",h),window.addEventListener("pagehide",d);const g=window.setInterval(d,n.flushIntervalMs??6e4),v={flush:d,reportError:e=>l(u(e,"boundary")),stop(){c||(d(),c=!0,f(),document.removeEventListener("visibilitychange",h),window.removeEventListener("pagehide",d),window.clearInterval(g),ae===v&&(ae=null))}};return ae=v,v}export{ce as startClientTelemetry};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{SearchableSelect as e}from"./chunk-C57PNNAW.js";import{
|
|
2
|
-
return f(e,{"aria-label":
|
|
3
|
-
return f(
|
|
1
|
+
import{SearchableSelect as e}from"./chunk-C57PNNAW.js";import{Select_default as a}from"./chunk-UDVQORQM.js";import{labelClasses as l}from"./chunk-EQKUFYX6.js";import{isSafeLinkHref as t}from"./chunk-Q5Z3KHT2.js";import{Input_default as r}from"./chunk-GZQD6IBV.js";import{INPUT_SIZES as n}from"./chunk-AYZY3YNC.js";import{Button_default as i}from"./chunk-UJJXWLHE.js";import{Icon as o}from"./chunk-UIWGVOFH.js";import{registerModalEscapeInterceptor as s}from"./chunk-TWVUQUUD.js";import{useShellStrings as u}from"./chunk-43MCNASD.js";import{useId as d,useRef as c,useState as p,useEffect as m}from"react";import{jsx as f,jsxs as v,Fragment as g}from"react/jsx-runtime";function h(e){return"select"===e.type?e.options:"groups"===e.type?e.groups.flatMap(e=>e.options):[]}var b="address",x={kindOf:()=>b,targetOf:e=>e,readFilter:()=>null,withFilter:e=>e},k=e=>t(e.trim());function y(t){const{value:n,kinds:o,rules:y=x,filtersFor:w,label:N,readOnly:C,placeholder:F,className:O="",tidyAddress:j,addressAddon:A}=t,$=void 0!==t.onApply,D=u().link,E=y.isSafe??k,U=d(),z=c(null),Q=c(null),[T,W]=p({url:n}),H=$?T.url:n,[K,M]=p(!1),[P,V]=p(null),[Y,B]=p(null),[L,R]=p(!1),S=c(null),Z=c(()=>{});Z.current=$?t.onCancel:()=>{},m(()=>{if($)return s(e=>{const a=z.current;return!!("Escape"===e.key&&a&&e.target instanceof Node&&a.contains(e.target))&&(Z.current(),!0)},()=>z.current)},[$]),m(()=>{if(!$)return;const e=Q.current;e?(e.focus(),e.select()):z.current?.querySelector("button, input")?.focus()},[]);const G=o??[{value:b,label:D.address,target:{type:"text"}}],I=P&&P.against===H?P.kind:y.kindOf(H),J=G.filter(e=>!e.hideWhenEmpty||h(e.target).length>0||e.value===I),X=J.find(e=>"text"===e.target.type),q=J.find(e=>e.value===I)??X??J[0];if(!q)return null;const _="text"!==q.target.type,ee=_?y.targetOf(H):H,ae=h(q.target),le=ae.find(e=>e.value===ee),te=e=>({value:e,label:D.unavailable(e)}),re="select"===q.target.type&&ee&&w?w(ee):null,ne=re?y.readFilter(H):null,ie=ne?re?.find(e=>e.param===ne.param):void 0,oe=Y&&Y.against===H?Y.text:H,se=_?H:j?j(oe.trim()).trim():oe.trim(),ue=$&&j?se:oe,de=!_&&""!==ue.trim()&&!E(ue),ce=de&&(!$||K);_&&L&&R(!1);const pe=(e,a)=>{$?W({url:e,name:a}):void 0===a?t.onChange(e):t.onChange(e,a)},me=(e,a)=>{V(a=>a?{...a,against:e}:a),pe(e,a)},fe=e=>{if(!e)return me("");const a=ae.find(a=>a.value===e);me(e,a?.label)},ve=e=>{M(!1);const a=e.trim();a?E(e)?(B({text:e,against:a}),me(a)):B({text:e,against:H}):(B({text:e,against:""}),me(""))},ge=e=>{const a=e.relatedTarget;if(a&&(a===Q.current||S.current?.contains(a)))return;if(R(!1),$||!j||C)return;const l=j(oe.trim());l.trim()!==oe.trim()&&ve(l)},he=()=>{if(!$||!se)return;if(!_&&de)return void M(!0);const e=_&&T.url===se?T.name:void 0,a=t.onApply;void 0===e?a(se):a(se,e)},be=(e,a)=>a&&!e.some(e=>e.value===a)?[te(a),...e]:[...e],xe=(l,t,r,n,i)=>{const o=[];for(const e of r){const a=o[o.length-1],l={value:e.value,label:e.label};e.group?a&&"options"in a&&a.label===e.group?a.options.push(l):o.push({label:e.group,options:[l]}):o.push(l)}if(i){const a=r.some(e=>""===e.value);/* @__PURE__ */
|
|
2
|
+
return f(e,{"aria-label":l,value:t,options:o,disabled:C,clearable:a,placeholder:r.find(e=>""===e.value)?.label,onChange:n})}/* @__PURE__ */
|
|
3
|
+
return f(a,{size:"sm","aria-label":l,value:t,options:o,readOnly:C,onChange:n})};let ke;if("text"===q.target.type)ke=/* @__PURE__ */f(r,{ref:Q,id:`${U}-address`,size:"sm",type:"text",invalid:ce,"aria-label":D.address,"aria-describedby":ce?`${U}-why`:void 0,placeholder:F??D.addressPlaceholder,spellCheck:!1,autoComplete:"off",value:oe,readOnly:C,onChange:e=>ve(e.target.value),onFocus:()=>R(!0),onBlur:ge,onKeyDown:j&&!$?e=>{"Enter"===e.key&&e.currentTarget.blur()}:void 0});else{const e="groups"===q.target.type?q.target.groups.flatMap(e=>e.options.map(a=>({value:a.value,label:a.label,group:e.label}))):q.target.options.map(e=>({value:e.value,label:e.label})),a=[{value:"",label:q.target.placeholder},...be(e,ee)];ke=xe(q.label,ee,a,fe,e.length>10)}const ye=/* @__PURE__ */v(g,{children:[o&&xe(D.linkType,q.value,J.map(e=>({value:e.value,label:e.label})),e=>{B(null),M(!1);const a=J.find(a=>a.value===e);if(!a||"text"===a.target.type)return void V({kind:e,against:H});const l=h(a.target)[0];V({kind:e,against:l?l.value:""}),l?pe(l.value,l.label):pe("")},!1),ke,A&&L&&!C&&"text"===q.target.type&&/* @__PURE__ */f("div",{ref:S,onBlur:ge,children:A({url:oe,onChange:ve})}),re&&xe(D.filter,ne?.param??"",[{value:"",label:D.noFilter},...ne&&!ie?[te(ne.param)]:[],...re.map(e=>({value:e.param,label:e.label}))],e=>{if(!e)return me(ee,le?.label);const a=re?.find(a=>a.param===e),l=a?.values[0];l&&me(y.withFilter(ee,{param:e,value:l.value}),l.label)},!1),re&&ne&&xe(D.value,ne.value,be((ie?.values??[]).map(e=>({value:e.value,label:e.label})),ne.value),e=>{if(!ne)return;const a=ie?.values.find(a=>a.value===e);me(y.withFilter(ee,{param:ne.param,value:e}),a?.label)},(ie?.values.length??0)>10),ce&&/* @__PURE__ */f("p",{id:`${U}-why`,role:"alert",className:"text-2xs leading-4 text-red-600",children:D.unsafe}),q.hint&&/* @__PURE__ */f("p",{className:"text-2xs leading-4 text-ink-faintest",children:q.hint}),re&&/* @__PURE__ */f("p",{className:"text-2xs leading-4 text-ink-faintest",children:D.filterHint})]});if(!$)/* @__PURE__ */
|
|
4
4
|
return f("div",{ref:z,className:`flex min-w-0 flex-auto flex-col gap-2 ${O}`.trim(),role:N?"group":void 0,"aria-label":N,children:ye});const we=t.onRemove;/* @__PURE__ */
|
|
5
|
-
return v("div",{ref:z,role:"dialog","aria-label":N??D.title,className:`flex min-w-0 flex-col gap-2 rounded-xl border border-line bg-surface p-3 shadow-lg ${O}`.trim(),onKeyDown:e=>{"Enter"!==e.key||e.defaultPrevented||e.target instanceof Element&&e.target.closest("button")||(e.preventDefault(),he())},children:[_?/* @__PURE__ */f("span",{className:
|
|
5
|
+
return v("div",{ref:z,role:"dialog","aria-label":N??D.title,className:`flex min-w-0 flex-col gap-2 rounded-xl border border-line bg-surface p-3 shadow-lg ${O}`.trim(),onKeyDown:e=>{"Enter"!==e.key||e.defaultPrevented||e.target instanceof Element&&e.target.closest("button")||(e.preventDefault(),he())},children:[_?/* @__PURE__ */f("span",{className:l({inline:!0}),children:D.title}):/* @__PURE__ */f("label",{htmlFor:`${U}-address`,className:l({inline:!0}),children:D.title}),ye,
|
|
6
6
|
/* @__PURE__ */v("div",{className:"flex items-center justify-between gap-2",children:[we?/* @__PURE__ */f(i,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onClick:we,children:D.remove}):null,
|
|
7
7
|
/* @__PURE__ */v("span",{className:"ml-auto flex gap-1",children:[
|
|
8
8
|
/* @__PURE__ */f(i,{variant:"secondary",size:"sm","data-window-action":"cancel",onClick:()=>Z.current(),children:D.cancel}),
|
|
@@ -14,8 +14,8 @@ return y("button",{type:"button",tabIndex:-1,"aria-label":l?i:r,title:l?i:r,onCl
|
|
|
14
14
|
/* @__PURE__ */p("span",{className:`min-w-0 flex-1 overflow-hidden whitespace-nowrap [mask-image:linear-gradient(to_right,#000_calc(100%-1rem),transparent)] ${"active-full"===R&&r?"pr-4":""} ${l?r?"@max-[5rem]:sr-only":"@max-[4.5rem]:sr-only":""}`,children:[e.title,e.favorite&&
|
|
15
15
|
/* @__PURE__ */y("span",{role:"img","aria-label":L.favorite,title:L.favorite,className:"ml-1 inline-flex align-[-0.125em] text-yellow-500",children:/* @__PURE__ */y(a,{name:"star","aria-hidden":"true",className:"size-3.5",fill:"currentColor",strokeWidth:1.5})})]})]}),r&&e.actions&&/* @__PURE__ */y(_,{node:e.actions}),r&&e.copy&&/* @__PURE__ */y(z,{text:e.copy,label:L.copy(e.copy),copiedLabel:L.copied}),
|
|
16
16
|
/* @__PURE__ */p("span",{className:"mr-2 flex size-5 shrink-0 items-center justify-center "+(r?"":"@max-[6.5rem]:hidden @max-[6.5rem]:group-hover:flex"),children:[i&&/* @__PURE__ */y("span",{role:"img","aria-label":L.unsaved,className:"size-2 rounded-full bg-gray-500 group-hover:hidden"}),
|
|
17
|
-
/* @__PURE__ */y("button",{type:"button",tabIndex:-1,"aria-label":L.closeTab?.(e.title)??`${L.close} ${e.title}`,onClick:()=>j(e.key),className:"size-5 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 "+(i?"hidden group-hover:flex":r?"flex":"flex opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),children:/* @__PURE__ */y(I,{})})]})]})]},e.key)},ke=[];let be,xe=0,ve=!B;for(const r of Y){const i=Z.filter(n=>{const t=e.indexOf(n);return t>=r.start&&t<=r.end});if(ve||xe!==se||(ve=!0,ke.push(/* @__PURE__ */y(m,{children:B},"rosh-after-pinned")),be=void 0),xe+=i.length,void 0===r.group||!F){for(const e of i)ke.push(ge(e,be)),be=e;continue}be=void 0;const l=r.group,o=F(l),s=r.end-r.start+1,d=!P.has(l),c=e[r.start].key,u=i.some(e=>e.key===n);ke.push(
|
|
18
|
-
/* @__PURE__ */p("div",{role:"group","aria-label":o.label,"data-tab-group":l,className
|
|
17
|
+
/* @__PURE__ */y("button",{type:"button",tabIndex:-1,"aria-label":L.closeTab?.(e.title)??`${L.close} ${e.title}`,onClick:()=>j(e.key),className:"size-5 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 "+(i?"hidden group-hover:flex":r?"flex":"flex opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),children:/* @__PURE__ */y(I,{})})]})]})]},e.key)},ke=[];let be,xe=0,ve=!B;for(const r of Y){const i=Z.filter(n=>{const t=e.indexOf(n);return t>=r.start&&t<=r.end});if(ve||xe!==se||(ve=!0,ke.push(/* @__PURE__ */y(m,{children:B},"rosh-after-pinned")),be=void 0),xe+=i.length,void 0===r.group||!F){for(const e of i)ke.push(ge(e,be)),be=e;continue}be=void 0;const l=r.group,o=F(l),s=r.end-r.start+1,d=!P.has(l),c=e[r.start].key,u=i.some(e=>e.key===n)?"shrink-[0.01]":"shrink";ke.push(
|
|
18
|
+
/* @__PURE__ */p("div",{role:"group","aria-label":o.label,"data-tab-group":l,className:`relative mx-1 flex items-end first:ml-0 ${u}`,children:[
|
|
19
19
|
/* @__PURE__ */p("button",{type:"button",tabIndex:-1,"aria-expanded":d,title:L.groupToggle(o.label,s),onClick:()=>U(l),...re({kind:"group",key:c},c),className:`relative mb-1 mr-1 flex h-6 shrink-0 items-center gap-1 rounded-full bg-blue-100 px-2 text-xs font-medium text-blue-700 hover:bg-blue-200 ${w}`,children:[
|
|
20
20
|
/* @__PURE__ */y(a,{name:d?"chevron-down":"chevron-right","aria-hidden":"true",className:"size-3",strokeWidth:2}),o.icon&&/* @__PURE__ */y("span",{className:"flex size-3.5 items-center justify-center [&>svg]:size-3.5","aria-hidden":"true",children:o.icon}),
|
|
21
21
|
/* @__PURE__ */y("span",{className:d?"sr-only":"max-w-[12rem] truncate",children:o.label}),
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import{Tree as e,TreeRow as n,TreeGroup as l}from"./chunk-G7I255HN.js";import{MarqueeBox as a}from"./chunk-IC72MGON.js";import{ImageLightbox as i}from"./chunk-MGW7SX53.js";import{DescriptionList as r}from"./chunk-SACUSHVN.js";import{Drawer as t}from"./chunk-VWQNCYGQ.js";import{EmptyState as o}from"./chunk-NEAT7BIP.js";import{Breadcrumbs as d}from"./chunk-PT77FC5X.js";import{
|
|
1
|
+
import{Tree as e,TreeRow as n,TreeGroup as l}from"./chunk-G7I255HN.js";import{MarqueeBox as a}from"./chunk-IC72MGON.js";import{ImageLightbox as i}from"./chunk-MGW7SX53.js";import{DescriptionList as r}from"./chunk-SACUSHVN.js";import{Drawer as t}from"./chunk-VWQNCYGQ.js";import{EmptyState as o}from"./chunk-NEAT7BIP.js";import{Breadcrumbs as d}from"./chunk-PT77FC5X.js";import{ROOT_KEY as s,mediaLibraryMenu as c}from"./chunk-BGJMDP6J.js";import{useMediaMoveItems as u}from"./chunk-32WEY6O5.js";import{RenameField as m}from"./chunk-XMH2JOZ2.js";import{NativeSelect as h}from"./chunk-UDVQORQM.js";import{MediaUploadGrid as p}from"./chunk-EEVLRCMA.js";import{MediaUsedInList as f}from"./chunk-EIY6YGEZ.js";import{Segmented as g}from"./chunk-JQBVSPF5.js";import{useGridSelection as v}from"./chunk-VLKDWKVR.js";import{useMarquee as k}from"./chunk-OLFYNMTD.js";import{copyToClipboard as y}from"./chunk-PH3P54QQ.js";import{Checkbox_default as b}from"./chunk-CGZBDI6C.js";import{useContextMenu as w,ContextMenu as x}from"./chunk-QIUIP6YZ.js";import{Banner as C}from"./chunk-6JDR6T4U.js";import{Input_default as N}from"./chunk-GZQD6IBV.js";import{DropdownMenu as I}from"./chunk-YZR4T5FZ.js";import{IconButton_default as D}from"./chunk-UGOJLNYR.js";import{useFileIntake as j,FileIntakeAlert as S}from"./chunk-7KIDOIPY.js";import{ColoredBadge as z}from"./chunk-5JUG74UR.js";import{Button_default as T}from"./chunk-UJJXWLHE.js";import{Icon as F}from"./chunk-UIWGVOFH.js";import{Tooltip as O}from"./chunk-QQ2LDC6C.js";import{buttonClasses as L}from"./chunk-UQYNPYF4.js";import{usePlotWidth as P}from"./chunk-MAFUXCPZ.js";import{useShellStrings as E}from"./chunk-43MCNASD.js";import{useRef as A,useMemo as M,useCallback as U,useState as R,useEffect as G}from"react";import{jsxs as J,Fragment as Q,jsx as B}from"react/jsx-runtime";var V="application/x-efficient-media-files",Y="application/x-efficient-media-folder",K="application/x-efficient-media-file";function H(e){if(!e||!Array.from(e.types).includes(K))return null;try{const n=JSON.parse(e.getData(K));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 W={type:"all",use:"any",sort:"newest"},Z={lock:/* @__PURE__ */B(F,{name:"lock","aria-hidden":"true",className:"h-4 w-4"}),folder:/* @__PURE__ */B(F,{name:"folder","aria-hidden":"true",className:"h-4 w-4"}),folderOpen:/* @__PURE__ */B(F,{name:"folder-open","aria-hidden":"true",className:"h-4 w-4"}),folderPlus:/* @__PURE__ */B(F,{name:"folder-plus","aria-hidden":"true",className:"h-4 w-4"}),trash:/* @__PURE__ */B(F,{name:"trash","aria-hidden":"true",className:"h-4 w-4"}),upload:/* @__PURE__ */B(F,{name:"upload","aria-hidden":"true",className:"h-4 w-4"}),search:/* @__PURE__ */B(F,{name:"search","aria-hidden":"true",className:"h-4 w-4"}),grid:/* @__PURE__ */B(F,{name:"grid","aria-hidden":"true",className:"h-4 w-4"}),list:/* @__PURE__ */B(F,{name:"list","aria-hidden":"true",className:"h-4 w-4"}),more:/* @__PURE__ */B(F,{name:"more","aria-hidden":"true",className:"h-4 w-4"}),copy:/* @__PURE__ */B(F,{name:"copy","aria-hidden":"true",className:"h-4 w-4"}),edit:/* @__PURE__ */B(F,{name:"edit","aria-hidden":"true",className:"h-4 w-4"}),swap:/* @__PURE__ */B(F,{name:"swap","aria-hidden":"true",className:"h-4 w-4"}),crop:/* @__PURE__ */B(F,{name:"crop","aria-hidden":"true",className:"h-4 w-4"}),external:/* @__PURE__ */B(F,{name:"external","aria-hidden":"true",className:"h-4 w-4"}),undo:/* @__PURE__ */B(F,{name:"undo","aria-hidden":"true",className:"h-4 w-4"})},$={link:/* @__PURE__ */B(F,{name:"link","aria-hidden":"true",className:"h-3 w-3"}),email:/* @__PURE__ */B(F,{name:"email","aria-hidden":"true",className:"h-3 w-3"}),lock:/* @__PURE__ */B(F,{name:"lock","aria-hidden":"true",className:"h-3 w-3"}),clock:/* @__PURE__ */B(F,{name:"clock","aria-hidden":"true",className:"h-3 w-3"})};function X(F){const{mode:H="manage",layout:X="auto",location:q,onLocationChange:_,folders:ee,products:ne,allFilesCount:le,trashCount:ae,files:ie,query:re,onQueryChange:te,filters:oe=W,onFiltersChange:de,extraFilters:se,view:ce="grid",onViewChange:ue,selectedIds:me,onSelectionChange:he,usedIn:pe,denied:fe={},accept:ge="image/*,video/*",maxSizeBytes:ve,busy:ke,progress:ye,onUpload:be,onNewFolder:we,onRename:xe,onMove:Ce,onTrash:Ne,onDeleteFolder:Ie,onRestore:De,onDeleteForever:je,onEmptyTrash:Se,onReplace:ze,onCropEdit:Te,onOpenInDesign:Fe,onChoose:Oe,onCancel:Le,pickNote:Pe,onDragOut:Ee,className:Ae=""}=F,Me=E().mediaLibrary,Ue=E().media,Re="pick"===H,Ge=!Re,Je=A(null),Qe=P(Je,"phone"===X?343:1200),Be="phone"===X||"auto"===X&&Qe<640,Ve=M(()=>function(e=[]){const n=/* @__PURE__ */new Map,l=(e,a)=>{for(const i of e){const e=[...a,i];n.set(i.id,{node:i,path:e}),i.children&&l(i.children,e)}};return l(e,[]),n}(ne),[ne]),Ye=M(()=>new Map(ee.map(e=>[e.id,e])),[ee]),Ke=M(()=>{const e=/* @__PURE__ */new Map;for(const n of ee){const l=n.parentId&&Ye.has(n.parentId)?n.parentId:null;e.set(l,[...e.get(l)??[],n])}return e},[ee,Ye]),He=U(e=>{const n=[];for(let l=e?Ye.get(e):void 0;l&&(n.unshift(l),!(n.length>ee.length));l=l.parentId?Ye.get(l.parentId):void 0);return n},[Ye,ee.length]),We=U((e,n)=>He(e).some(e=>e.id===n),[He]),[Ze,$e]=R(()=>/* @__PURE__ */new Set(["@files"])),Xe=e=>$e(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l}),qe=U(e=>{$e(n=>e.every(e=>n.has(e))?n:/* @__PURE__ */new Set([...n,...e]))},[]),_e="files"===(en=q).place?`files:${en.folderId??""}`:"products"===en.place?`products:${en.nodeId??""}`:"trash";var en;G(()=>{if("files"===q.place)qe(["@files",...He(q.folderId).slice(0,-1).map(e=>e.id)]);else if("products"===q.place){const e=q.nodeId?Ve.get(q.nodeId)?.path??[]:[];qe(["@products",...e.slice(0,-1).map(e=>`p:${e.id}`)])}},[_e]);const nn="products"===q.place,ln="trash"===q.place,an="files"===q.place,rn=an?q.folderId:null,tn=nn&&q.nodeId?Ve.get(q.nodeId)?.path[0]:void 0,on=e=>e?.sharedFrom?`${Me.readOnly} ${Me.editedAtHq(e.sharedFrom)}`:Me.readOnly,dn=M(()=>ie.map(e=>e.id),[ie]),sn=M(()=>new Map(ie.map(e=>[e.id,e])),[ie]),cn=v(dn),un=M(()=>dn.filter(e=>cn.selected.has(e)),[dn,cn.selected]),mn=1===un.length?sn.get(un[0]):void 0,hn=A(!0);G(()=>{hn.current?hn.current=!1:cn.clear()},[_e]);const pn=me?.join("\0");G(()=>{me&&cn.setSelection(me)},[pn]);const fn=A(pn??""),gn=un.join("\0");G(()=>{fn.current!==gn&&(fn.current=gn,he?.(un))},[gn]);const vn=(e,n={})=>{Re?cn.select(e):cn.select(e,{ctrl:!(!n.ctrlKey&&!n.metaKey),shift:!!n.shiftKey})},[kn,yn]=R(null),bn=e=>{const n=kn;if(yn(null),!n||null==e)return;e!==("folder"===n.kind?Ye.get(n.id)?.name:sn.get(n.id)?.name)&&xe?.(n,e)},wn=async e=>{if(!we)return;const n=await we(e);qe(["@files",...e?[e]:[]]),"string"==typeof n&&yn({kind:"folder",id:n})},xn=U(e=>{const n=[],l=n=>{if("files"===e.kind)return n===rn&&an?Me.alreadyHere:void 0;const l=Ye.get(e.id);return n===e.id||n&&We(n,e.id)?Me.notIntoItself:(l?.parentId??null)===n?Me.folderAlreadyHere:void 0};n.push({key:s,label:Me.allFiles,disabledReason:l(null)});const a=(e,i)=>{for(const r of Ke.get(e)??[])n.push({key:r.id,label:r.name,depth:i,disabledReason:l(r.id)}),a(r.id,i+1)};return a(null,1),n},[Ke,Ye,an,We,rn,Me]),Cn=U(e=>{const n=new Set(e.map(e=>sn.get(e)?.kind??"image"));return 1===n.size?[...n][0]:"file"},[sn]),[Nn,In]=R(null),Dn={words:Me,media:Ue,denied:fe,moveTargets:xn,kindOf:Cn,urlOf:e=>sn.get(e)?.url,newSubfolder:we&&Ge?e=>{wn(e)}:void 0,rename:xe&&Ge?e=>{"file"!==e.kind||cn.isSelected(e.id)||cn.select(e.id),yn(e)}:void 0,move:Ce&&Ge?Ce:void 0,trash:Ne&&Ge?Ne:void 0,deleteFolder:Ie&&Ge?Ie:void 0,folderNotEmpty:e=>!!Ye.get(e)?.notEmpty,replace:ze&&Ge?ze:void 0,copyUrl:e=>{const n=sn.get(e)?.url;n&&y(Me.urlLabel,n)},openInDesign:Fe,restore:De,deleteForever:je},jn=e=>c(e,Dn),Sn=w(),zn=(e,n)=>{Re||(cn.isSelected(e)||cn.select(e),Sn.open(n,(e=>{const n=cn.isSelected(e)?un:[e];return nn?{kind:"render",id:e}:ln?{kind:"trashed",ids:n}:{kind:"files",ids:n}})(e)))},[Tn,Fn]=R(null),[On,Ln]=R(null),[Pn,En]=R(null);G(()=>{if(!On&&!Tn)return;const e=()=>{Ln(null),Fn(null)};return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[On,Tn]);const An=(e,n)=>Array.from(e.dataTransfer?.types??[]).includes(n),Mn=(e,n)=>!(!Ce||fe.move||Re)&&(!!An(e,V)||!(!An(e,Y)||!Pn)&&(n!==Pn&&!(n&&We(n,Pn)))),Un=(e,n)=>({onDragEnter:l=>{Mn(l,n)&&(l.preventDefault(),Fn(e))},onDragOver:l=>{Mn(l,n)&&(l.preventDefault(),l.dataTransfer.dropEffect="move",Tn!==e&&Fn(e))},onDragLeave:n=>{const l=n.relatedTarget;l&&n.currentTarget.contains(l)||Fn(n=>n===e?null:n)},onDrop:e=>{if(Mn(e,n))if(e.preventDefault(),Fn(null),An(e,V)){let l;try{l=JSON.parse(e.dataTransfer.getData(V))}catch{l=null}Array.isArray(l)&&l.length&&Ce({kind:"files",ids:l.map(String)},n)}else Pn&&(Ce({kind:"folder",id:Pn},n),En(null))}}),Rn=e=>{const n=e=>An(e,V)||An(e,Y)||An(e,"Files");return{onDragEnter:l=>{n(l)&&Ln(e)},onDragOver:l=>{n(l)&&On!==e&&Ln(e)},onDragLeave:n=>{const l=n.relatedTarget;l&&n.currentTarget.contains(l)||Ln(n=>n===e?null:n)}}},Gn=(e,n,l)=>/* @__PURE__ */B(O,{side:"right",content:On===e?Me.noDropProducts:on(l),open:On===e||!On&&void 0,children:/* @__PURE__ */B("span",{children:n})}),Jn=e=>({onContextMenu:n=>{Sn.open(n,e)}}),Qn=(e,a,i)=>e.map(e=>{const r=`p:${e.id}`,t=i??e,o=Ze.has(r),d=e.children?.length?e.children:null;/* @__PURE__ */
|
|
2
2
|
return J("div",{role:"none",className:"contents",children:[
|
|
3
3
|
/* @__PURE__ */B(n,{label:Gn(r,e.name,t),level:a,icon:d&&o?Z.folderOpen:Z.folder,count:e.count,countLabel:null!=e.count?e.countLabel??Me.fileCount(e.count):void 0,selected:nn&&q.nodeId===e.id,expanded:d?o:void 0,onToggle:d?()=>Xe(r):void 0,onSelect:()=>_({place:"products",nodeId:e.id}),rowProps:{"data-media-row":r,...Rn(r),...Ge?Jn({kind:"product-node",id:e.id}):{}}}),d&&o&&/* @__PURE__ */B(l,{children:Qn(d,a+1,t)})]},e.id)}),Bn=(e,a)=>(Ke.get(e)??[]).map(e=>{const i=Ke.get(e.id),r=Ze.has(e.id),t="folder"===kn?.kind&&kn.id===e.id,o=jn({kind:"folder",id:e.id});/* @__PURE__ */
|
|
4
4
|
return J("div",{role:"none",className:"contents",children:[
|
|
5
|
-
/* @__PURE__ */B(n,{label:e.name,level:a,icon:i&&r?Z.folderOpen:Z.folder,count:e.count,countLabel:null!=e.count?e.countLabel??Me.fileCount(e.count):void 0,selected:t||an&&q.folderId===e.id,expanded:i?r:void 0,onToggle:i?()=>Xe(e.id):void 0,onSelect:()=>_({place:"files",folderId:e.id}),drop:Tn===e.id?"into":void 0,dragging:Pn===e.id,draggable:Ge&&!!Ce&&!fe.move,rename:t?/* @__PURE__ */B(
|
|
5
|
+
/* @__PURE__ */B(n,{label:e.name,level:a,icon:i&&r?Z.folderOpen:Z.folder,count:e.count,countLabel:null!=e.count?e.countLabel??Me.fileCount(e.count):void 0,selected:t||an&&q.folderId===e.id,expanded:i?r:void 0,onToggle:i?()=>Xe(e.id):void 0,onSelect:()=>_({place:"files",folderId:e.id}),drop:Tn===e.id?"into":void 0,dragging:Pn===e.id,draggable:Ge&&!!Ce&&!fe.move,rename:t?/* @__PURE__ */B(m,{value:e.name,label:Me.folderName,onDone:bn}):void 0,actions:Ge&&o.length?/* @__PURE__ */B(I,{align:"end","aria-label":Me.folderActions,trigger:Z.more,items:o}):void 0,rowProps:{"data-media-row":e.id,...Un(e.id,e.id),...Ge?Jn({kind:"folder",id:e.id}):{},...Ge&&Ce&&!fe.move?{draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed="move",n.dataTransfer.setData(Y,e.id),En(e.id)},onDragEnd:()=>{En(null),Fn(null)}}:{}}}),i&&r&&/* @__PURE__ */B(l,{children:Bn(e.id,a+1)})]},e.id)}),Vn=Ze.has("@files"),Yn=Ze.has("@products"),Kn=/* @__PURE__ */J(e,{"aria-label":Me.folders,children:[ne&&/* @__PURE__ */J(Q,{children:[
|
|
6
6
|
/* @__PURE__ */B(n,{label:Gn("@products",Me.products),level:1,icon:Z.lock,badge:{label:Me.readOnlyBadge,tone:"neutral"},expanded:ne.length?Yn:void 0,onToggle:()=>Xe("@products"),selected:nn&&null==q.nodeId,onSelect:()=>_({place:"products",nodeId:null}),rowProps:{"data-media-row":"@products",...Rn("@products")}}),Yn&&ne.length>0&&/* @__PURE__ */B(l,{children:Qn(ne,2)})]}),
|
|
7
|
-
/* @__PURE__ */B(n,{label:Me.allFiles,level:1,icon:Vn?Z.folderOpen:Z.folder,count:le,countLabel:null!=le?Me.fileCount(le):void 0,expanded:Ke.get(null)?.length?Vn:void 0,onToggle:()=>Xe("@files"),selected:an&&null==q.folderId,onSelect:()=>_({place:"files",folderId:null}),drop:"@files"===Tn?"into":void 0,rowProps:{"data-media-row":"@files",...Un("@files",null)}}),Vn&&(Ke.get(null)?.length??0)>0&&/* @__PURE__ */B(l,{children:Bn(null,2)}),Ge&&/* @__PURE__ */B(n,{label:Me.trash,level:1,icon:Z.trash,count:ae,countLabel:null!=ae?Me.fileCount(ae):void 0,selected:ln,onSelect:()=>_({place:"trash"}),rowProps:{"data-media-row":"@trash"}})]}),Hn=(()=>{if(ln)return[{label:Me.trash}];if(nn){const e=q.nodeId?Ve.get(q.nodeId)?.path??[]:[];return[{label:Me.products,onClick:e.length?()=>_({place:"products",nodeId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>_({place:"products",nodeId:n.id}):void 0}))]}const e=He(rn);return[{label:Me.allFiles,onClick:e.length?()=>_({place:"files",folderId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>_({place:"files",folderId:n.id}):void 0}))]})(),Wn=nn?Me.readOnly:fe.upload,Zn=!!be&&!ln&&!Wn,$n=j({accept:ge,maxSizeBytes:ve,multiple:!0,disabled:!Zn,onAccept:e=>be?.(e,rn)}),Xn=nn?Me.noProductFolder:fe.newFolder,qn=e=>e?{"aria-disabled":!0,disabledReason:e}:{},_n=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[Ge&&we&&!ln&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.folderPlus,onClick:()=>{wn(rn)},...qn(Xn),children:Me.newFolder}),be&&!ln&&/* @__PURE__ */B(T,{variant:"primary",size:"sm",leftIcon:Z.upload,onClick:()=>$n.open(),...qn(Wn),children:Me.upload}),Ge&&ln&&Se&&ie.length>0&&/* @__PURE__ */B(T,{variant:"danger",size:"sm",onClick:Se,...qn(fe.deleteForever),children:Me.emptyTrash})]}),el=(e,n,l,a,i)=>/* @__PURE__ */B("div",{style:{width:Be?void 0:i,flex:Be?"1 1 120px":"0 0 auto",minWidth:0},children:/* @__PURE__ */B(
|
|
7
|
+
/* @__PURE__ */B(n,{label:Me.allFiles,level:1,icon:Vn?Z.folderOpen:Z.folder,count:le,countLabel:null!=le?Me.fileCount(le):void 0,expanded:Ke.get(null)?.length?Vn:void 0,onToggle:()=>Xe("@files"),selected:an&&null==q.folderId,onSelect:()=>_({place:"files",folderId:null}),drop:"@files"===Tn?"into":void 0,rowProps:{"data-media-row":"@files",...Un("@files",null)}}),Vn&&(Ke.get(null)?.length??0)>0&&/* @__PURE__ */B(l,{children:Bn(null,2)}),Ge&&/* @__PURE__ */B(n,{label:Me.trash,level:1,icon:Z.trash,count:ae,countLabel:null!=ae?Me.fileCount(ae):void 0,selected:ln,onSelect:()=>_({place:"trash"}),rowProps:{"data-media-row":"@trash"}})]}),Hn=(()=>{if(ln)return[{label:Me.trash}];if(nn){const e=q.nodeId?Ve.get(q.nodeId)?.path??[]:[];return[{label:Me.products,onClick:e.length?()=>_({place:"products",nodeId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>_({place:"products",nodeId:n.id}):void 0}))]}const e=He(rn);return[{label:Me.allFiles,onClick:e.length?()=>_({place:"files",folderId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>_({place:"files",folderId:n.id}):void 0}))]})(),Wn=nn?Me.readOnly:fe.upload,Zn=!!be&&!ln&&!Wn,$n=j({accept:ge,maxSizeBytes:ve,multiple:!0,disabled:!Zn,onAccept:e=>be?.(e,rn)}),Xn=nn?Me.noProductFolder:fe.newFolder,qn=e=>e?{"aria-disabled":!0,disabledReason:e}:{},_n=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[Ge&&we&&!ln&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.folderPlus,onClick:()=>{wn(rn)},...qn(Xn),children:Me.newFolder}),be&&!ln&&/* @__PURE__ */B(T,{variant:"primary",size:"sm",leftIcon:Z.upload,onClick:()=>$n.open(),...qn(Wn),children:Me.upload}),Ge&&ln&&Se&&ie.length>0&&/* @__PURE__ */B(T,{variant:"danger",size:"sm",onClick:Se,...qn(fe.deleteForever),children:Me.emptyTrash})]}),el=(e,n,l,a,i)=>/* @__PURE__ */B("div",{style:{width:Be?void 0:i,flex:Be?"1 1 120px":"0 0 auto",minWidth:0},children:/* @__PURE__ */B(h,{size:"sm","aria-label":e,value:n,onChange:a,options:l})},e),nl=e=>n=>de?.({...oe,[e]:n}),ll=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[te&&/* @__PURE__ */B("div",{style:{flex:"1 1 200px",minWidth:0},children:/* @__PURE__ */B(N,{size:"sm",type:"search",leftIcon:Z.search,placeholder:nn?Me.searchProducts:Me.search,"aria-label":nn?Me.searchProducts:Me.search,value:re??"",onChange:e=>te(e.target.value)})}),de&&el(Me.mediaType,oe.type,[{value:"all",label:Me.allTypes},{value:"image",label:Me.images},{value:"video",label:Me.videos},{value:"svg",label:"SVG"},{value:"gif",label:"GIF"}],nl("type"),130),de&&!nn&&!ln&&el(Me.use,oe.use,[{value:"any",label:Me.anyUse},{value:"email",label:Me.emailOnly},{value:"website",label:Me.websiteOnly},{value:"unused",label:Me.notUsed}],nl("use"),130),de&&Ge&&el(Me.sort,oe.sort,[{value:"newest",label:Me.newest},{value:"name",label:Me.byName},{value:"size",label:Me.bySize}],nl("sort"),110),se?.map(e=>el(e.label,e.value,e.options,e.onChange,120)),ue&&/* @__PURE__ */B(g,{size:"sm",label:Me.view,value:ce,onChange:ue,options:[{value:"grid",label:Me.grid,icon:Z.grid},{value:"list",label:Me.list,icon:Z.list}]})]}),al=e=>{const n=[];return null!=e.trashedDaysAgo&&n.push({key:"t",label:Me.daysAgo(e.trashedDaysAgo),count:e.trashedDaysAgo,icon:$.clock,tone:"neutral"}),e.usedCount&&n.push({key:"u",label:Me.used(e.usedCount),count:e.usedCount,icon:$.link,tone:"active"}),e.email&&n.push({key:"e",label:Me.email,icon:$.email,tone:"queued"}),e.private&&n.push({key:"p",label:Me.private,icon:$.lock,tone:"neutral"}),n},il=e=>al(e).map(e=>/* @__PURE__ */B(z,{tone:e.tone,size:"xs",children:e.label},e.key)),rl=Ge&&an&&!!Ce&&!fe.move,tl=!!Ee&&!ln,ol=e=>!tl||e.private||e.pickDisabledReason?void 0:JSON.stringify({id:e.id,url:e.url,kind:"video"===e.kind?"video":"image",name:e.name}),dl=ie.map(e=>({id:e.id,url:e.thumbUrl??e.url,name:e.name,kind:e.kind,caption:e.name,badges:al(e),dragData:rl?JSON.stringify(cn.isSelected(e.id)?un:[e.id]):ol(e),...rl&&ol(e)?{dragAlso:{[K]:ol(e)}}:{}})),sl=Be?Math.max(72,Math.floor((Qe-24-16-1)/3)):112,cl=A(null),ul=k({containerRef:cl,enabled:Ge&&!Be&&ie.length>0,selected:cn.selected,setSelection:e=>cn.setSelection(e),clearSelection:cn.clear}),ml=e=>{if(Re){const n=sn.get(e);return void(!n||n.private||n.pickDisabledReason||Oe?.(n))}const n=dn.indexOf(e);n>=0&&In(n)},hl=ie.length?null:re?/* @__PURE__ */B(o,{variant:"dashed",title:Me.noMatches}):nn?/* @__PURE__ */B(o,{variant:"dashed",title:Me.emptyProducts,description:on(tn)}):ln?/* @__PURE__ */B(o,{variant:"dashed",title:Me.trashEmpty}):!Zn||Re?/* @__PURE__ */B(o,{variant:"dashed",title:Me.emptyFolder}):null,pl="list"===ce&&ie.length>0,fl=hl??(pl?/* @__PURE__ */B("ul",{role:"listbox","aria-multiselectable":Ge||void 0,"aria-label":Me.folders,className:"flex flex-col gap-1",children:ie.map(e=>/* @__PURE__ */J("li",{role:"option","aria-selected":cn.isSelected(e.id),tabIndex:0,"data-grid-item":"","data-grid-id":e.id,onClick:n=>vn(e.id,n),onDoubleClick:()=>ml(e.id),onContextMenu:n=>zn(e.id,n),draggable:!!ol(e)||void 0,onDragStart:ol(e)?n=>{n.dataTransfer.effectAllowed="link",n.dataTransfer.setData(K,ol(e)),Ee("start")}:void 0,onDragEnd:ol(e)?e=>Ee("none"===e.dataTransfer.dropEffect?"cancelled":"dropped"):void 0,onKeyDown:n=>{"Enter"!==n.key&&" "!==n.key||(n.preventDefault(),vn(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)] "+(cn.isSelected(e.id)?"bg-accent-tint text-blue-700":"text-ink hover:bg-gray-100"),children:[
|
|
8
8
|
/* @__PURE__ */B("img",{src:e.thumbUrl??e.url,alt:"",className:"h-10 w-10 shrink-0 rounded bg-gray-100 object-contain"}),
|
|
9
9
|
/* @__PURE__ */B("span",{className:"min-w-0 flex-1 truncate",children:e.name}),
|
|
10
|
-
/* @__PURE__ */B("span",{className:"flex shrink-0 items-center gap-1",children:il(e)}),e.sizeLabel&&/* @__PURE__ */B("span",{className:"w-16 shrink-0 text-right text-xs text-ink-faint",children:e.sizeLabel})]},e.id))}):/* @__PURE__ */B(
|
|
10
|
+
/* @__PURE__ */B("span",{className:"flex shrink-0 items-center gap-1",children:il(e)}),e.sizeLabel&&/* @__PURE__ */B("span",{className:"w-16 shrink-0 text-right text-xs text-ink-faint",children:e.sizeLabel})]},e.id))}):/* @__PURE__ */B(p,{items:dl,readOnly:!Zn||Re,onFiles:Zn&&!Re?e=>be(e,rn):void 0,accept:ge,maxSizeBytes:ve,busy:ke,progress:ye,fit:"contain",thumbSize:sl,dragType:rl?V:tl?K:void 0,onDragOutChange:tl?e=>Ee(e):void 0,selected:cn.selected,onItemClick:vn,onItemDoubleClick:ml,onItemContextMenu:Ge?zn:void 0,menuOnMedia:Ge})),gl=u({count:un.length,kind:Cn(un),targets:xn({kind:"files",ids:un}),onPick:e=>Ce?.({kind:"files",ids:un},e.key===s?null:e.key)}),vl=L({variant:"secondary",size:"sm"}),kl=/* @__PURE__ */B(I,{align:"start",triggerClassName:vl,trigger:/* @__PURE__ */J(Q,{children:[Z.folder,Me.moveTo]}),items:gl,disabled:!!fe.move}),yl=Ge&&un.length>1&&!nn?/* @__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__ */B(b,{checked:un.length===ie.length,indeterminate:un.length<ie.length,onChange:e=>e?cn.selectAll():cn.clear(),label:Me.selected(un.length)}),/* @__PURE__ */J(Q,ln?{children:[De&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.undo,onClick:()=>De(un),...qn(fe.restore),children:Me.restore}),je&&/* @__PURE__ */B(T,{variant:"secondary-danger",size:"sm",onClick:()=>je(un),...qn(fe.deleteForever),children:Me.deleteForever})]}:{children:[Ce&&kl,xe&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.edit,disabled:!0,children:Me.rename}),Ne&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.trash,onClick:()=>Ne({kind:"files",ids:un}),...qn(fe.trash),children:Me.moveFilesToTrash(un.length)})]}),
|
|
12
|
-
/* @__PURE__ */B(T,{variant:"ghost",size:"sm",onClick:cn.clear,children:Me.clearSelection})]}):null,bl=e=>{const n=[],l=(e,l,a)=>{null!=a&&""!==a&&n.push({key:e,label:l,value:a})},a="file"===kn?.kind&&kn.id===e.id;l("name",Me.name,a?/* @__PURE__ */B(
|
|
12
|
+
/* @__PURE__ */B(T,{variant:"ghost",size:"sm",onClick:cn.clear,children:Me.clearSelection})]}):null,bl=e=>{const n=[],l=(e,l,a)=>{null!=a&&""!==a&&n.push({key:e,label:l,value:a})},a="file"===kn?.kind&&kn.id===e.id;l("name",Me.name,a?/* @__PURE__ */B(m,{value:e.name,label:Me.fileName,onDone:bn}):e.name),l("type",Me.type,e.typeLabel),l("size",Me.size,e.sizeLabel),l("resolution",Me.resolution,e.resolution),nn?(l("design",Me.design,e.design),l("finish",Me.finish,e.finish),l("angle",Me.angleLug,e.angleLug),l("owner",Me.owner,e.owner)):(l("added",Me.addedBy,e.addedBy),l("folder",Me.folder,e.folderPath)),l("used",Me.usedIn,null!=e.usedCount?Me.places(e.usedCount):void 0);const i=c({kind:"files",ids:[e.id]},Dn).find(e=>"submenu"===e.type);/* @__PURE__ */
|
|
13
13
|
return J("div",{"data-media-details":"",className:"flex flex-col gap-3",children:[
|
|
14
14
|
/* @__PURE__ */B("img",{src:e.url,alt:e.name,className:"aspect-square w-full rounded-lg bg-gray-100 object-contain"}),nn&&/* @__PURE__ */B(C,{tone:"neutral",title:Me.readOnlyBadge,children:on(tn)}),
|
|
15
15
|
/* @__PURE__ */B(r,{size:"sm",columns:1,items:n}),!ln&&/* @__PURE__ */J("div",{className:"flex gap-2",children:[
|
|
16
16
|
/* @__PURE__ */B("div",{style:{flex:"1 1 0",minWidth:0},children:/* @__PURE__ */B(N,{size:"sm",readOnly:!0,value:e.url,"aria-label":Me.fileUrl,onFocus:e=>e.currentTarget.select()})}),
|
|
17
|
-
/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.copy,onClick:()=>Dn.copyUrl(e.id),children:Me.copyUrl})]}),an&&Ge&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[ze&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.swap,onClick:()=>ze(e.id),...qn(fe.replace),children:Me.replace}),Te&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.crop,onClick:()=>Te(e.id),children:Me.cropEdit}),Ce&&"submenu"===i?.type&&/* @__PURE__ */B(I,{align:"start",triggerClassName:vl,trigger:/* @__PURE__ */J(Q,{children:[Z.folder,Me.moveTo]}),items:i.items,disabled:!!fe.move}),xe&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.edit,onClick:()=>yn({kind:"file",id:e.id}),...qn(fe.rename),children:Me.rename}),Ne&&/* @__PURE__ */B(D,{"aria-label":Me.moveToTrash,size:"sm",onClick:()=>Ne({kind:"files",ids:[e.id]}),disabledReason:fe.trash,"aria-disabled":!!fe.trash||void 0,children:Z.trash})]}),ln&&Ge&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[De&&/* @__PURE__ */B(T,{variant:"primary",size:"sm",leftIcon:Z.undo,onClick:()=>De([e.id]),...qn(fe.restore),children:Me.restore}),je&&/* @__PURE__ */B(T,{variant:"danger",size:"sm",onClick:()=>je([e.id]),...qn(fe.deleteForever),children:Me.deleteForever})]}),nn&&Fe&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.external,onClick:()=>Fe({kind:"render",id:e.id}),children:Me.openInDesign}),pe&&/* @__PURE__ */B(
|
|
17
|
+
/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.copy,onClick:()=>Dn.copyUrl(e.id),children:Me.copyUrl})]}),an&&Ge&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[ze&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.swap,onClick:()=>ze(e.id),...qn(fe.replace),children:Me.replace}),Te&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.crop,onClick:()=>Te(e.id),children:Me.cropEdit}),Ce&&"submenu"===i?.type&&/* @__PURE__ */B(I,{align:"start",triggerClassName:vl,trigger:/* @__PURE__ */J(Q,{children:[Z.folder,Me.moveTo]}),items:i.items,disabled:!!fe.move}),xe&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.edit,onClick:()=>yn({kind:"file",id:e.id}),...qn(fe.rename),children:Me.rename}),Ne&&/* @__PURE__ */B(D,{"aria-label":Me.moveToTrash,size:"sm",onClick:()=>Ne({kind:"files",ids:[e.id]}),disabledReason:fe.trash,"aria-disabled":!!fe.trash||void 0,children:Z.trash})]}),ln&&Ge&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[De&&/* @__PURE__ */B(T,{variant:"primary",size:"sm",leftIcon:Z.undo,onClick:()=>De([e.id]),...qn(fe.restore),children:Me.restore}),je&&/* @__PURE__ */B(T,{variant:"danger",size:"sm",onClick:()=>je([e.id]),...qn(fe.deleteForever),children:Me.deleteForever})]}),nn&&Fe&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",leftIcon:Z.external,onClick:()=>Fe({kind:"render",id:e.id}),children:Me.openInDesign}),pe&&/* @__PURE__ */B(f,{items:pe})]})},wl=mn?mn.private?Me.privateNoPick:mn.pickDisabledReason:void 0,xl=Re?/* @__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__ */B("span",{className:"min-w-0 truncate text-sm text-ink-faint",children:mn?Me.oneChosen(mn.name):Me.noneChosen}),
|
|
19
19
|
/* @__PURE__ */J("div",{className:"flex gap-2",children:[Le&&/* @__PURE__ */B(T,{variant:"secondary",size:"sm",onClick:Le,children:Me.cancel}),
|
|
20
20
|
/* @__PURE__ */B(T,{variant:"primary",size:"sm",disabled:!mn,...qn(wl),onClick:()=>{mn&&!wl&&Oe?.(mn)},children:Me.chooseImage})]})]}):null,Cl=Ge&&!!mn,Nl=/* @__PURE__ */J("div",{className:"flex min-w-0 flex-col gap-3",children:[Pe&&/* @__PURE__ */B(C,{tone:"neutral",children:Pe}),
|