efficient-shell 7.23.0 → 7.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +2 -1
  2. package/dist/{Browser-GSPJTRX3.js → Browser-HIIDBE2D.js} +14 -14
  3. package/dist/{Documents-LUEBMB23.js → Documents-CFH4ENOI.js} +18 -18
  4. package/dist/{Files-SPFE23UK.js → Files-2F5T5CZU.js} +20 -20
  5. package/dist/{Notepad-D3QV7R6T.js → Notepad-Y3PL4VKL.js} +10 -10
  6. package/dist/PdfViewer-BPQHIBZ7.js +1 -0
  7. package/dist/{PomodoroTimer-F7BGUOY2.js → PomodoroTimer-66WV5HAK.js} +7 -7
  8. package/dist/{Preview-5JLBKQWH.js → Preview-KHXSZUUE.js} +22 -22
  9. package/dist/{Spreadsheet-3F5P5SC2.js → Spreadsheet-DQAMNCMR.js} +11 -11
  10. package/dist/apps/index.js +1 -1
  11. package/dist/bin/ui-check.js +1 -1
  12. package/dist/chunk-2CD2LZHH.js +1 -0
  13. package/dist/{chunk-NKMK6WRI.js → chunk-5MEIPKOX.js} +1 -1
  14. package/dist/{chunk-VKCLCFEE.js → chunk-5WYTOXIO.js} +2 -2
  15. package/dist/{chunk-EEXHZUG5.js → chunk-C3CWQVGM.js} +2 -2
  16. package/dist/{chunk-W77WLTTH.js → chunk-H3S7GHXR.js} +1 -1
  17. package/dist/chunk-LVCFIIAB.js +1 -0
  18. package/dist/{chunk-E64SHLPT.js → chunk-QYTG62Y2.js} +2 -2
  19. package/dist/{chunk-MMHI7WBL.js → chunk-SRQXRDTA.js} +11 -11
  20. package/dist/{chunk-CZZYMC7P.js → chunk-WGUFMSMA.js} +3 -3
  21. package/dist/{index-91i1XDHz.d.ts → index-Bz_SKBsS.d.ts} +27 -2
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +1 -1
  24. package/dist/pdf/index.js +1 -1
  25. package/dist/telemetry/index.js +1 -1
  26. package/dist/ui/index.d.ts +1 -1
  27. package/dist/ui/index.js +1 -1
  28. package/package.json +1 -1
  29. package/dist/PdfViewer-2OHHAS7B.js +0 -1
  30. package/dist/chunk-43KURNHH.js +0 -1
  31. package/dist/chunk-G6LV5Z2W.js +0 -1
@@ -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 s,writeFileSync as o,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"],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 shell token or a Tailwind palette class (harness FT-1)"},radius:{counts:"a literal corner radius (an arbitrary-value radius class, or an inline borderRadius)",instead:"a radius utility from the scale or a role token such as rounded-(--radius-control); the theme sets how round they are (harness UI-7)"},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)'}},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"],m=["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"],g={"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,m)?"chart":null}function x(e){const t=k(e);return"kit"===t||"icon"===t?"kit-dep":"chart"===t?"chart-dep":null}var $=/[.+^$()|[\]\\]/g;function b(e){let t="",n=0;for(let i=0;i<e.length;i++){const s=e[i];"*"===s?"*"===e[i+1]?"/"===e[i+2]?(t+="(?:[^/]+/)*",i+=2):(t+=".*",i+=1):t+="[^/]*":"?"===s?t+="[^/]":"{"===s?(t+="(?:",n+=1):"}"===s&&n>0?(t+=")",n-=1):t+=","===s&&n>0?"|":s.replace($,"\\$&")}if(0!==n)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${t}$`)}function y(e){const t=e.map(b);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),s=[...new Set(t.map(j))].sort(),o=s.filter(e=>!s.some(t=>t!==e&&(""===t||e.startsWith(`${t}/`)))),a=new Set,l=t=>{let s;try{s=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of s){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 o)l(e);return[...a].sort(L)}var L=(e,t)=>e<t?-1:e>t?1:0,z=class extends Error{},R=(e,t)=>`${e}:${t}`;function E(e){const t=e.lastIndexOf(":");return{file:e.slice(0,t),kind:e.slice(t+1)}}var T=e=>a.indexOf(e);function A(e,t){const n=E(e),i=E(t);return L(n.file,i.file)||T(n.kind)-T(i.kind)}function C(e,t="ui-kit.baseline.json"){let n;try{n=JSON.parse(e)}catch(e){throw new z(`${t} is not valid JSON: ${e.message}`)}const i=e=>{throw new z(`${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 s=n;if(1!==s.schema)return i("number"==typeof s.schema&&s.schema>1?`"schema": ${s.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');if(!Array.isArray(s.kinds)||s.kinds.some(e=>"string"!=typeof e))return i('"kinds" must be a list');const o=s.kinds.filter(l);if("object"!=typeof s.counts||null===s.counts||Array.isArray(s.counts))return i('"counts" must be an object');const r=new Map;for(const[e,t]of Object.entries(s.counts)){const{file:n,kind:s}=E(e);if(!n||!s)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(s)&&r.set(e,t)}return{kinds:o,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(A).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 P(e){const t={};for(const[n,i]of e){const{kind:e}=E(n);l(e)&&(t[e]=(t[e]??0)+i)}return t}var B=class extends Error{},N=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),D=new Set(["$schema","schema","kinds","include","exclude","includeImporting","output","allow"]);var O="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,Y=/var\(|^(?:inherit|initial|unset|revert|revert-layer|none|auto)$/,Z=/^(?:(?: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=new Set(["button","a","option","Button","IconButton","Link","NavLink","PopupMenuItem","PopupMenuLabel","DropdownMenuItem","MenuItem","ContextMenuItem"]),ie=/(?:…|\.\.\.|&hellip;)\s*$/,se=new RegExp("\\p{L}","u"),oe=new RegExp("\\p{L}[\\p{L}-]*","u"),re={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:{}},ae=new Set((re.busy?.words??[]).map(e=>e.toLowerCase())),le=new Set(["label","aria-label",...re.placeholder?[]:["placeholder","searchPlaceholder","emptyOptionLabel","blankLabel"]]),ce=(e,t)=>{if(!ie.test(t)||!se.test(e))return!1;const n=e.match(oe)?.[0]?.toLowerCase();if(n&&ae.has(n))return!1;const i=e.replace(ie,"").trim(),s=re.busy;return!(s&&(s.zhStarts.some(e=>i.startsWith(e))||s.zhEnds.some(e=>i.endsWith(e))))},de=new Set(["confirm","alert","prompt"]),ue=new Set(["window","globalThis","self"]);function he(e,t,n,i,s){const o=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)=>{o.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(o.has("native")){const t=n=>{if(n)if(e.isIdentifier(n))de.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,m=(e,t)=>{e&&("efficient-shell"===e||e.startsWith("efficient-shell/"))&&s?.add(e);const n=e?k(e):null;n&&d(n,t)},g=(e,t,n)=>{if(o.has("dark"))for(const n of e.matchAll(te))d("dark",t);if(o.has("radius"))for(const n of e.matchAll(_))K.test(n[1].trim())||d("radius",t);if(n&&l&&o.has("hex"))for(const n of e.matchAll(q))d("hex",t);if(o.has("spacing"))for(const n of e.matchAll(H)){const e=n[1];(e.startsWith("[")?Y.test(e.slice(1,-1).trim()):J(e))||d("spacing",t)}if(o.has("font-size"))for(const n of e.matchAll(Q))d("font-size",t);if(o.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(o.has("shadow"))for(const n of e.matchAll(X))n[1].startsWith("[")&&Y.test(n[1].slice(1,-1).trim())||d("shadow",t)},w=(t,n,i)=>{const s=e.isStringLiteralLike(n)?n.text.trim():void 0;if(o.has("spacing")&&Z.test(t))e.isNumericLiteral(n)?ee.has(Number(n.text))||d("spacing",i):void 0!==s&&!Y.test(s)&&(e=>[...e.matchAll(/(-?\d*\.?\d+)(px|rem|em)\b/g)].map(e=>Math.abs(Number(e[1]))*("px"===e[2]?1:16)))(s).some(e=>!ee.has(e))&&d("spacing",i);else if(o.has("font-size")&&"fontSize"===t)(e.isNumericLiteral(n)||void 0!==s&&!Y.test(s)&&!/^(?:smaller|larger)$/.test(s))&&d("font-size",i);else if(o.has("z-index")&&"zIndex"===t){const t=[],s=n=>{e.isNumericLiteral(n)||e.isStringLiteralLike(n)&&/^\d+$/.test(n.text.trim())?t.push(Number(n.text)):e.forEachChild(n,s)};s(n);for(const e of t)e>30&&d("z-index",i)}else o.has("shadow")&&"boxShadow"===t&&(void 0===s||""===s||Y.test(s)||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):de.has(n.text)&&!p.has(n.text)?d("native",t):"require"===n.text&&m(f(t.arguments[0]),t):e.isPropertyAccessExpression(n)?"createPortal"===n.name.text?d("portal",t):de.has(n.name.text)&&e.isIdentifier(n.expression)&&ue.has(n.expression.text)&&d("native",t):n.kind===e.SyntaxKind.ImportKeyword&&m(f(t.arguments[0]),t)}else{if(e.isImportDeclaration(t)||e.isExportDeclaration(t))return void m(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),o.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))g(t.text,t,n);else if(e.isTemplateExpression(t)){g(t.head.text,t.head,n);for(const e of t.templateSpans)g(e.literal.text,e.literal,n)}}e.isJsxAttribute(t)&&W.has(t.name.getText(r))?e.forEachChild(t,e=>x(e,!1)):e.forEachChild(t,e=>x(e,n))};return x(r,!0),o.has("ellipsis-label")&&function(e,t,n){const i=new Set,s=(e,t)=>{i.has(e)||(i.add(e),n(t))},o=n=>{if(n)if(e.isStringLiteralLike(n))ce(n.text,n.text)&&s(n,n.getStart(t));else if(e.isTemplateExpression(n)){const e=[n.head.text,...n.templateSpans.map(e=>e.literal.text)];ce(e.join(" "),e[e.length-1])&&s(n,n.getStart(t))}else e.isConditionalExpression(n)?(o(n.whenTrue),o(n.whenFalse)):e.isBinaryExpression(n)?(o(n.left),o(n.right)):e.isParenthesizedExpression(n)||e.isAsExpression(n)||e.isJsxExpression(n)?o(n.expression):e.isCallExpression(n)&&pe.has(fe(n.expression))&&n.arguments[0]&&o(n.arguments[0])},r=n=>{for(const i of n)if(e.isJsxText(i)){const e=i.getText(t);ce(e,e)&&s(i,i.getStart(t)+(e.length-e.trimStart().length))}else e.isJsxExpression(i)?o(i.expression):(e.isJsxElement(i)||e.isJsxFragment(i))&&r(i.children)},a=(n,i)=>{const s=n.attributes.properties.find(n=>e.isJsxAttribute(n)&&n.name.getText(t)===i),o=s?.initializer;return o&&e.isStringLiteral(o)?o.text:o&&e.isJsxExpression(o)&&o.expression&&e.isStringLiteralLike(o.expression)?o.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),s="option"===i&&re.prompt&&""===a(e,"value");ne.has(i)&&!s&&r(n.children)}else if(e.isJsxAttribute(n))le.has(n.name.getText(t))&&o(n.initializer);else if(e.isPropertyAssignment(n)){const t=e.isIdentifier(n.name)||e.isStringLiteralLike(n.name)?n.name.text:"",i=re.prompt&&e.isObjectLiteralExpression(n.parent)&&l(n.parent);le.has(t)&&!i&&o(n.initializer)}e.forEachChild(n,c)};c(t)}(e,r,e=>(a["ellipsis-label"]??=[]).push(c(e))),a}var pe=new Set(["say","t"]),fe=e=>{const t=e.getText();return t.slice(t.lastIndexOf(".")+1)};function me(e){const t={};for(const[n,i]of Object.entries(e))i.length&&(t[n]=i.length);return t}function ge(e,t,n){const i=e.createSourceFile(t,n,e.ScriptTarget.Latest,!1),s=[];for(const t of i.statements)(e.isImportDeclaration(t)||e.isExportDeclaration(t))&&t.moduleSpecifier&&e.isStringLiteralLike(t.moduleSpecifier)&&s.push(t.moduleSpecifier.text);return s}var we=(e,t)=>e.some(e=>t.some(t=>t.endsWith("/*")?e.startsWith(t.slice(0,-1)):e===t));var ke=e=>new Map(e.allow.map(e=>[R(e.file,e.kind),e.count]));function xe(e,t){return e.kinds.filter(e=>t.kinds.includes(e))}var $e=(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 s=i.slice(0,12).join(", ");return` (line${1===i.length?"":"s"} ${s}${i.length>12?", …":""})`};function be(e,t,n){const i=ke(e),s=new Map;for(const[e,o]of t.counts){const{kind:t}=E(e);if(!l(t)||!n.includes(t))continue;const r=o-(i.get(e)??0);r>0&&s.set(e,r)}return{kinds:a.filter(e=>n.includes(e)),counts:s}}function ye(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 ve="\n// <button> in a comment is not a button, and <svg> in one is not a drawing\n/* nor is <input title=\"x\"> in this one, or dark:bg-black, or #fff */\nimport { createPortal } from 'react-dom';\nimport { Dialog } from '@headlessui/react';\nimport { TrashIcon } from '@heroicons/react/24/outline';\nimport type { Icon } from 'lucide-react';\nimport { Button, confirm } from 'efficient-shell';\nexport { Slot } from '@radix-ui/react-slot';\nexport { CheckIcon } from '@radix-ui/react-icons';\nimport { LineChart } from 'recharts';\nimport 'd3-scale';\nexport { VictoryPie } from 'victory';\nimport { BarChart } from '@mui/x-charts';\nimport Tree from 'react-d3-tree';\nimport { TimeSeriesChart } from 'efficient-shell/ui';\n// import 'chart.js' in a comment is not an import, and 'echarts' in a string is not one either\nconst chartLabel = 'd3-array';\n\nconst a = <button title=\"Says what it does\">x</button>;\nconst b = <input type=\"range\" />;\nconst c = <input type=\"text\" />;\nconst c2 = <input type={\"hidden\"} name=\"csrf\" />;\nconst c3 = <input type=\"hidden\" />;\nconst c4 = <input type={kind} />;\nconst d = <select />;\nconst d2 = <textarea />;\nconst e = <div role=\"dialog\" />;\nconst e2 = <dialog open />;\nconst e3 = <section role={'alertdialog'} />;\nconst f = <iframe title=\"Preview\" />;\nconst f2 = <object title=\"Chart\" />;\nconst g = <Button title=\"a prop, not a tooltip\" role=\"dialog\" />;\nconst g2 = (\n <button\n type=\"button\"\n title={hint}\n >\n y\n </button>\n);\nconst h = ReactDOM.createPortal(a, document.body);\nconst i = createPortal(a, document.body);\n\nasync function leave() {\n if (window.confirm('Sure?')) return;\n globalThis.alert('No');\n alert('native: nothing binds the name');\n prompt('native too');\n await confirm('the shell: the import binds it');\n record.confirm('a method, not the popup');\n}\n\nconst j = <div className=\"bg-white dark:bg-black dark:hover:text-white is-dark:no\" />;\nconst k = clsx('text-gray-900', on && 'dark:text-gray-100');\nconst l = <span style={{ color: '#fff', background: \"#12ab34\" }} className={`border-[#0a0b0c80] ${x}`} />;\nconst m = <a href=\"#faded\" id=\"#bad\" key=\"#abc\" to=\"#face\">skip</a>;\nconst n = <label htmlFor={'#dead'}>skip</label>;\nconst o = <span>&#1234; and BG#00340 and #12345 and #added are not colours</span>;\nconst p = 'entity &#x1f; ref BG#00340';\nconst q = <use xlinkHref=\"#abc\" fill=\"url(#fed)\" />;\nconst t = <div className=\"rounded-[4px] rounded-t-[0.5rem] hover:rounded-[2px] rounded-lg rounded-(--radius-card) rounded-[inherit] rounded-[var(--r)]\" />;\nconst u = <div style={{ borderRadius: 6, borderTopLeftRadius: '3px', borderBottomRightRadius: '50%', borderEndEndRadius: 'var(--radius-card)' }} />;\nconst v = <i style={{ borderRadius: 9999 }} />;\nconst w = <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 4h16\" /></svg>;\nconst w2 = <Svg viewBox=\"0 0 24 24\" />;\nconst w3 = '<svg viewBox=\"0 0 1 1\"></svg> in a string is not an element';\nconst r = lazy(() => import('@mui/material'));\nconst s = require('react-select');\nconst s2 = require('chart.js/auto');\nconst s3 = import('@nivo/line');\n",Se={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},je={kit:1,dark:1,portal:1,radius:2,chart:1},Ie=(...e)=>e.join("-"),Le=`\nconst s1 = <i className="${[Ie("px","2.5"),Ie("py","1.5"),"md:"+Ie("gap","1.5"),"-"+Ie("mt","1.5"),Ie("p","[10px]")].join(" ")}" />;\nconst s2 = <i className="${[Ie("p","0"),Ie("px","px"),Ie("p","0.5"),Ie("p","3"),Ie("gap-x","4"),Ie("p","12"),Ie("p","(--space-12)"),Ie("p","[var(--space-12)]"),Ie("space-x","reverse"),Ie("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="${[Ie("text","[11px]"),Ie("text","[0.8rem]"),Ie("text","xs"),Ie("text","[#fff]"),Ie("text","(--text-2xs)")].join(" ")}" />;\nconst f2 = <i style={{ fontSize: 12 }} />;\nconst f3 = { fontSize: 'var(--x)', font: 'inherit' };\nconst z1 = <i className="${[Ie("z","[9999]"),Ie("z","50"),Ie("z","10"),Ie("z","30"),"-"+Ie("z","10"),Ie("z","auto"),Ie("z","(--z-popup)"),Ie("z","[var(--z-popup)]")].join(" ")}" />;\nconst z2 = { zIndex: on ? 2020 : 2010 };\nconst z3 = { zIndex: Z_LAYERS.popup, top: 9999 };\nconst h1 = <i className="${[Ie("shadow","[0_1px_2px_#000]"),Ie("shadow","md"),"shadow",Ie("shadow","lg"),Ie("shadow","(--elevation-panel)"),Ie("shadow","black/20"),Ie("drop-shadow","md")].join(" ")}" />;\nconst h2 = { boxShadow: '0 1px 2px rgba(0,0,0,.1)' };\nconst h3 = { boxShadow: 'none', outline: 'var(--elevation-raised)' };\n`,ze={spacing:7,"font-size":3,"z-index":4,shadow:3,hex:1},Re={"ellipsis-label":9},Ee=e=>a.filter(t=>e[t]).map(t=>`${t} ${e[t]}`).join(", ")||"nothing";var Te="ui-kit.config.json",Ae="ui-kit.baseline.json",Ce="efficient-shell-ui-check",Me=`${Ce}: every surface a person operates takes its UI from efficient-shell (harness UI-24).\n\n ${Ce} check this repository against ${Ae}\n ${Ce} --print print today's counts as a baseline, and change nothing\n ${Ce} --summary print totals per kind and per folder, as Markdown\n ${Ce} --json print the result as JSON\n ${Ce} --update lower the lines whose counts fell, and delete the ones at zero\n ${Ce} --update --allow-move also follow a renamed or split file (no total may rise)\n ${Ce} --init write the first ${Ae}\n ${Ce} --init --kind <kind> take the baseline for a kind just added to "kinds"\n ${Ce} --no-base do not compare with the pull request's base branch\n\nKinds: ${a.join(", ")}\nReads ${Te} in the current directory.`;var Pe=(e,t)=>`${e} ${t}${1===e?"":"s"}`,Be=(e,t)=>{const n=P(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(`${Ce}: ${r}\n\n${Me}`),2;if(r.help)return t.out(Me),0;if(r.version)return t.out(t.version),0;const c=e=>(r.json?t.out(JSON.stringify({tool:Ce,version:t.version,ok:!1,failures:[e]},null,2)):t.err(`${Ce}: ${e}`),1),p=n(t.cwd,Te);if(!i(p))return c(`no ${Te} in ${t.cwd}. Run it from the repository root; the harness has the template.`);let f,m;try{f=function(e,t="ui-kit.config.json"){const n=[],i=e=>{n.push(e)},s=(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},o=(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=>!N(e))?(i(`${t} must be a list of objects`),[]):e;if(!N(e))throw new B(`${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=s(e.include,'"include"'),u=s(e.exclude,'"exclude"'),h=r(e.includeImporting,'"includeImporting"').map((e,t)=>({files:s(e.files,`"includeImporting"[${t}].files`,{required:!0}),modules:s(e.modules,`"includeImporting"[${t}].modules`,{required:!0}),reason:o(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:s(e.files,`"output"[${t}].files`,{required:!0}),reason:o(e.reason,`"output"[${t}]`)})),f=[],m=new Set;if(r(e.allow,'"allow"').forEach((e,t)=>{const n=`"allow"[${t}]`,[r]=s([e.file],`${n}.file`),d=o(e.reason,n);if(!l(e.kind))return void i(`${n}.kind must be one of: ${a.join(", ")}`);if(c.includes(e.kind)||i(`${n}: kind "${e.kind}" is not in "kinds"`),"number"!=typeof e.count||!Number.isInteger(e.count)||e.count<1)return void i(`${n}.count must be a whole number, 1 or more`);if(!r)return;const u=`${r}:${e.kind}`;m.has(u)&&i(`${n}: ${r} already has an allow entry for "${e.kind}"`),m.add(u),f.push({file:r,kind:e.kind,count:e.count,reason:d})}),n.length)throw new B(`${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(s(p,"utf8")),Te)}catch(e){return c(e instanceof B?e.message:`${Te} is not valid JSON: ${e.message}`)}try{m=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",ve,Se],["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",je],["tokens.tsx",Le,ze],["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",Re]];for(const[s,o,r]of i){const i=me(he(e,s,o,n));n.some(e=>(i[e]??0)!==(r[e]??0))&&t.push(`${s}: read ${Ee(i)}; it holds ${Ee(r)}`)}const s=me(he(e,"fixture.tsx",ve,["button"]));return"button"!==Object.keys(s).join()&&t.push(`asked for button alone, the reader reported ${Ee(s)}`),t}(m);if(w.length)return c(`the reader misread its own fixtures with typescript ${m.version}, so nothing it says about this repository can be trusted:\n - `+w.join("\n - "));const k=function(e,t,o){const r=[],a=y(o.exclude),l=y(o.output.flatMap(e=>e.files)),c=new Map,u=e=>{let i=c.get(e);return void 0===i&&c.set(e,i=s(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(o.include,'"include"'),o.output.forEach((e,t)=>h(e.files,`"output"[${t}]`)),o.includeImporting.forEach((e,t)=>h(e.files,`"includeImporting"[${t}]`));const p=new Set,f=e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!a(e)&&!l(e);for(const e of I(t,o.include))f(e)&&p.add(e);for(const n of o.includeImporting)for(const i of I(t,n.files))f(i)&&!p.has(i)&&we(ge(e,i,u(i)),n.modules)&&p.add(i);const m=[...p].sort(),w=o.kinds.filter(e=>!d(e)),k=new Map,$=new Map,b=new Set;for(const t of m){const n=he(e,t,u(t),w,b);let i=!1;for(const e of w){const s=n[e]?.length??0;s&&($.set(R(t,e),s),i=!0)}i&&k.set(t,n)}let v=[],S=[],j=[];const L=o.kinds.filter(d);if(L.length){const e=n(t,O);if(i(e)){const t=JSON.parse(s(e,"utf8")),n=["dependencies","peerDependencies","optionalDependencies"].flatMap(e=>Object.keys(t[e]??{})),i=new Set([...b].flatMap(e=>g[e]??[])),r=[...new Set(n)].sort();if(o.kinds.includes("kit-dep")){const e=r.filter(e=>"kit-dep"===x(e));v=e.filter(e=>!i.has(e)),S=e.filter(e=>i.has(e)),v.length&&$.set(R(O,"kit-dep"),v.length)}o.kinds.includes("chart-dep")&&(j=r.filter(e=>"chart-dep"===x(e)),j.length&&$.set(R(O,"chart-dep"),j.length))}else for(const e of L)r.push(`"kinds" includes "${e}", and there is no ${O} here to read.`)}for(const e of o.allow)(d(e.kind)?e.file===O: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:m,hits:k,counts:$,kitDeps:v,shellPeers:S,chartDeps:j,problems:r}}(m,t.cwd,f);if(0===k.files.length)return c(`read no files. "include" in ${Te} matches nothing, so a pass would mean nothing.`);const $=n(t.cwd,Ae),b=r.json,v=e=>{b||t.out(e)};if(r.print)return t.out(M(be(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,s]of t.counts){const{file:t,kind:o}=E(e);if(!l(o))continue;const r=n.get(o)??{count:0,files:new Set};r.count+=s,r.files.add(t),n.set(o,r);const a=t.split("/"),c=a.length>2?a.slice(0,2).join("/"):2===a.length?a[0]:".",d=i.get(c)??{};d[o]=(d[o]??0)+s,i.set(c,d)}const s=e.kinds.filter(e=>n.has(e)),o=[`**UI kit check (harness UI-24):** ${new Set([...t.counts.keys()].map(e=>E(e).file)).size} of ${Pe(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(s.length&&i.size){const e=e=>s.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));o.push("",`| Folder | ${s.map(e=>`\`${e}\``).join(" | ")} | Total |`,`|---|${s.map(()=>"---:").join("|")}|---:|`,...t.map(([t,n])=>`| \`${t}\` | ${s.map(e=>n[e]??0).join(" | ")} | ${e(n)} |`))}return o}(f,k))t.out(e);return 0}let S=null;if(i($))try{S=C(s($,"utf8"),Ae)}catch(e){return c(e instanceof z?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 ${Te}. Add it there first.`);const t=r.kinds;if(S){if(0===t.length)return c(`${Ae} 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=be(f,k,t);S={kinds:[...S.kinds,...t],counts:new Map([...S.counts,...n.counts])}}else{if(t.length)return c(`there is no ${Ae} yet. Run --init on its own first.`);S=be(f,k,f.kinds)}o($,M(S)),v(`${Ce}: wrote ${Ae} (${Pe(S.counts.size,"line")}: ${Be(S.counts,S.kinds)})`)}if(!S)return c(`no ${Ae}. This repository has not adopted the check yet: run ${Ce} --init, and commit the file.`);if(r.update){const e=function(e,t,n,{allowMove:i=!1}={}){const s=xe(e,t),o=be(e,n,s),r=new Map([...t.counts].filter(([e])=>s.includes(E(e).kind)));if(i){const e=P(r),n=P(o.counts),i=s.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:o,lowered:ye(r,o.counts),refused:[]}}const a=new Map;for(const[e,t]of r){const n=Math.min(t,o.counts.get(e)??0);n>0&&a.set(e,n)}return{baseline:{kinds:s,counts:a},lowered:ye(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,o($,M(S)),v(`${Ce}: ${e.lowered?`changed ${Pe(e.lowered,"line")} in`:"nothing to change in"} ${Ae}`)}const j=function(e,t,n){const i=[],s=[],o=[...n.problems],r=ke(e),a=new Set(xe(e,t)),c=e.kinds.filter(e=>!t.kinds.includes(e));c.length&&o.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&&s.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(A)){const{file:c,kind:d}=E(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}${$e(n,c,d)}. ${h[d].counts} is counted; use ${h[d].instead}.`):u<p?o.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&&s.push(`${c}: ${d} ${u}, and its line says ${p+f}`)}return{grown:i,shrunk:s,other:o,updateFixes:0===i.length&&0===o.length&&s.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 s=e.git(["rev-parse","--show-prefix"]);if(null===s)return{problems:[],note:"not a git checkout; the base branch was not compared"};const o=`origin/${i}`;if(null===e.git(["rev-parse","--verify","--quiet",`${o}^{commit}`])&&(e.git(["fetch","--no-tags","--depth=1","origin",`+refs/heads/${i}:refs/remotes/origin/${i}`]),null===e.git(["rev-parse","--verify","--quiet",`${o}^{commit}`])))return{problems:[],note:`${o} could not be fetched; the base branch was not compared`};const r=e.git(["show",`${o}:${s.trim()}${Ae}`]);if(null===r)return{problems:[],note:`${o} has no ${Ae} yet (adoption)`};let a;try{a=C(r,`${o}:${Ae}`)}catch{return{problems:[],note:`${o}'s ${Ae} could not be read; the base branch was not compared`}}const l=P(a.counts),c=P(t.counts);return{problems:n.filter(e=>a.kinds.includes(e)&&(c[e]??0)>(l[e]??0)).map(e=>`${Ae} holds ${c[e]??0} of "${e}", and ${o} holds ${l[e]??0}. The baseline only goes down: use ${h[e].instead}. A count that is meant to stay goes in "allow" in ${Te}, with its reason.`),note:`compared with ${o}`}}(t,S,f.kinds),T=f.kinds.filter(e=>S.kinds.includes(e)),F=`${Ce} --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:Ce,version:t.version,ok:U,schema:f.schema,kinds:f.kinds,files:k.files.length,counts:P(k.counts),baseline:P(S.counts),allowed:P(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 ${m.version})`),t.out(` ok read ${Pe(k.files.length,"file")}`),W(`${Te} and ${Ae} 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=>E(e).file));return t.out(` ok PROGRESS: ${q.size} of ${Pe(k.files.length,"file")} still draw UI of their own: `+Be(k.counts,T)),t.out(""),U?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${Pe(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(){for(const e of[n(process.cwd(),"package.json"),import.meta.url])try{return t(e)("typescript")}catch{}throw new Error("typescript is not installed")},git:function(t){try{return e("git",t,{cwd:process.cwd(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:6e4,maxBuffer:67108864})}catch{return null}},version:"7.23.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 s,writeFileSync as o,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"],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 shell token or a Tailwind palette class (harness FT-1)"},radius:{counts:"a literal corner radius (an arbitrary-value radius class, or an inline borderRadius)",instead:"a radius utility from the scale or a role token such as rounded-(--radius-control); the theme sets how round they are (harness UI-7)"},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)'}},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"],m=["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"],g={"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,m)?"chart":null}function x(e){const t=k(e);return"kit"===t||"icon"===t?"kit-dep":"chart"===t?"chart-dep":null}var $=/[.+^$()|[\]\\]/g;function b(e){let t="",n=0;for(let i=0;i<e.length;i++){const s=e[i];"*"===s?"*"===e[i+1]?"/"===e[i+2]?(t+="(?:[^/]+/)*",i+=2):(t+=".*",i+=1):t+="[^/]*":"?"===s?t+="[^/]":"{"===s?(t+="(?:",n+=1):"}"===s&&n>0?(t+=")",n-=1):t+=","===s&&n>0?"|":s.replace($,"\\$&")}if(0!==n)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${t}$`)}function y(e){const t=e.map(b);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),s=[...new Set(t.map(j))].sort(),o=s.filter(e=>!s.some(t=>t!==e&&(""===t||e.startsWith(`${t}/`)))),a=new Set,l=t=>{let s;try{s=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of s){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 o)l(e);return[...a].sort(L)}var L=(e,t)=>e<t?-1:e>t?1:0,z=class extends Error{},R=(e,t)=>`${e}:${t}`;function E(e){const t=e.lastIndexOf(":");return{file:e.slice(0,t),kind:e.slice(t+1)}}var T=e=>a.indexOf(e);function A(e,t){const n=E(e),i=E(t);return L(n.file,i.file)||T(n.kind)-T(i.kind)}function C(e,t="ui-kit.baseline.json"){let n;try{n=JSON.parse(e)}catch(e){throw new z(`${t} is not valid JSON: ${e.message}`)}const i=e=>{throw new z(`${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 s=n;if(1!==s.schema)return i("number"==typeof s.schema&&s.schema>1?`"schema": ${s.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');if(!Array.isArray(s.kinds)||s.kinds.some(e=>"string"!=typeof e))return i('"kinds" must be a list');const o=s.kinds.filter(l);if("object"!=typeof s.counts||null===s.counts||Array.isArray(s.counts))return i('"counts" must be an object');const r=new Map;for(const[e,t]of Object.entries(s.counts)){const{file:n,kind:s}=E(e);if(!n||!s)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(s)&&r.set(e,t)}return{kinds:o,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(A).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 P(e){const t={};for(const[n,i]of e){const{kind:e}=E(n);l(e)&&(t[e]=(t[e]??0)+i)}return t}var B=class extends Error{},N=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),D=new Set(["$schema","schema","kinds","include","exclude","includeImporting","output","allow"]);var O="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,Y=/var\(|^(?:inherit|initial|unset|revert|revert-layer|none|auto)$/,Z=/^(?:(?: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=new Set(["button","a","option","Button","IconButton","Link","NavLink","PopupMenuItem","PopupMenuLabel","DropdownMenuItem","MenuItem","ContextMenuItem"]),ie=/(?:…|\.\.\.|&hellip;)\s*$/,se=new RegExp("\\p{L}","u"),oe=new RegExp("\\p{L}[\\p{L}-]*","u"),re={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:{}},ae=new Set((re.busy?.words??[]).map(e=>e.toLowerCase())),le=new Set(["label","aria-label",...re.placeholder?[]:["placeholder","searchPlaceholder","emptyOptionLabel","blankLabel"]]),ce=(e,t)=>{if(!ie.test(t)||!se.test(e))return!1;const n=e.match(oe)?.[0]?.toLowerCase();if(n&&ae.has(n))return!1;const i=e.replace(ie,"").trim(),s=re.busy;return!(s&&(s.zhStarts.some(e=>i.startsWith(e))||s.zhEnds.some(e=>i.endsWith(e))))},de=new Set(["confirm","alert","prompt"]),ue=new Set(["window","globalThis","self"]);function he(e,t,n,i,s){const o=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)=>{o.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(o.has("native")){const t=n=>{if(n)if(e.isIdentifier(n))de.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,m=(e,t)=>{e&&("efficient-shell"===e||e.startsWith("efficient-shell/"))&&s?.add(e);const n=e?k(e):null;n&&d(n,t)},g=(e,t,n)=>{if(o.has("dark"))for(const n of e.matchAll(te))d("dark",t);if(o.has("radius"))for(const n of e.matchAll(_))K.test(n[1].trim())||d("radius",t);if(n&&l&&o.has("hex"))for(const n of e.matchAll(q))d("hex",t);if(o.has("spacing"))for(const n of e.matchAll(H)){const e=n[1];(e.startsWith("[")?Y.test(e.slice(1,-1).trim()):J(e))||d("spacing",t)}if(o.has("font-size"))for(const n of e.matchAll(Q))d("font-size",t);if(o.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(o.has("shadow"))for(const n of e.matchAll(X))n[1].startsWith("[")&&Y.test(n[1].slice(1,-1).trim())||d("shadow",t)},w=(t,n,i)=>{const s=e.isStringLiteralLike(n)?n.text.trim():void 0;if(o.has("spacing")&&Z.test(t))e.isNumericLiteral(n)?ee.has(Number(n.text))||d("spacing",i):void 0!==s&&!Y.test(s)&&(e=>[...e.matchAll(/(-?\d*\.?\d+)(px|rem|em)\b/g)].map(e=>Math.abs(Number(e[1]))*("px"===e[2]?1:16)))(s).some(e=>!ee.has(e))&&d("spacing",i);else if(o.has("font-size")&&"fontSize"===t)(e.isNumericLiteral(n)||void 0!==s&&!Y.test(s)&&!/^(?:smaller|larger)$/.test(s))&&d("font-size",i);else if(o.has("z-index")&&"zIndex"===t){const t=[],s=n=>{e.isNumericLiteral(n)||e.isStringLiteralLike(n)&&/^\d+$/.test(n.text.trim())?t.push(Number(n.text)):e.forEachChild(n,s)};s(n);for(const e of t)e>30&&d("z-index",i)}else o.has("shadow")&&"boxShadow"===t&&(void 0===s||""===s||Y.test(s)||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):de.has(n.text)&&!p.has(n.text)?d("native",t):"require"===n.text&&m(f(t.arguments[0]),t):e.isPropertyAccessExpression(n)?"createPortal"===n.name.text?d("portal",t):de.has(n.name.text)&&e.isIdentifier(n.expression)&&ue.has(n.expression.text)&&d("native",t):n.kind===e.SyntaxKind.ImportKeyword&&m(f(t.arguments[0]),t)}else{if(e.isImportDeclaration(t)||e.isExportDeclaration(t))return void m(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),o.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))g(t.text,t,n);else if(e.isTemplateExpression(t)){g(t.head.text,t.head,n);for(const e of t.templateSpans)g(e.literal.text,e.literal,n)}}e.isJsxAttribute(t)&&W.has(t.name.getText(r))?e.forEachChild(t,e=>x(e,!1)):e.forEachChild(t,e=>x(e,n))};return x(r,!0),o.has("ellipsis-label")&&function(e,t,n){const i=new Set,s=(e,t)=>{i.has(e)||(i.add(e),n(t))},o=n=>{if(n)if(e.isStringLiteralLike(n))ce(n.text,n.text)&&s(n,n.getStart(t));else if(e.isTemplateExpression(n)){const e=[n.head.text,...n.templateSpans.map(e=>e.literal.text)];ce(e.join(" "),e[e.length-1])&&s(n,n.getStart(t))}else e.isConditionalExpression(n)?(o(n.whenTrue),o(n.whenFalse)):e.isBinaryExpression(n)?(o(n.left),o(n.right)):e.isParenthesizedExpression(n)||e.isAsExpression(n)||e.isJsxExpression(n)?o(n.expression):e.isCallExpression(n)&&pe.has(fe(n.expression))&&n.arguments[0]&&o(n.arguments[0])},r=n=>{for(const i of n)if(e.isJsxText(i)){const e=i.getText(t);ce(e,e)&&s(i,i.getStart(t)+(e.length-e.trimStart().length))}else e.isJsxExpression(i)?o(i.expression):(e.isJsxElement(i)||e.isJsxFragment(i))&&r(i.children)},a=(n,i)=>{const s=n.attributes.properties.find(n=>e.isJsxAttribute(n)&&n.name.getText(t)===i),o=s?.initializer;return o&&e.isStringLiteral(o)?o.text:o&&e.isJsxExpression(o)&&o.expression&&e.isStringLiteralLike(o.expression)?o.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),s="option"===i&&re.prompt&&""===a(e,"value");ne.has(i)&&!s&&r(n.children)}else if(e.isJsxAttribute(n))le.has(n.name.getText(t))&&o(n.initializer);else if(e.isPropertyAssignment(n)){const t=e.isIdentifier(n.name)||e.isStringLiteralLike(n.name)?n.name.text:"",i=re.prompt&&e.isObjectLiteralExpression(n.parent)&&l(n.parent);le.has(t)&&!i&&o(n.initializer)}e.forEachChild(n,c)};c(t)}(e,r,e=>(a["ellipsis-label"]??=[]).push(c(e))),a}var pe=new Set(["say","t"]),fe=e=>{const t=e.getText();return t.slice(t.lastIndexOf(".")+1)};function me(e){const t={};for(const[n,i]of Object.entries(e))i.length&&(t[n]=i.length);return t}function ge(e,t,n){const i=e.createSourceFile(t,n,e.ScriptTarget.Latest,!1),s=[];for(const t of i.statements)(e.isImportDeclaration(t)||e.isExportDeclaration(t))&&t.moduleSpecifier&&e.isStringLiteralLike(t.moduleSpecifier)&&s.push(t.moduleSpecifier.text);return s}var we=(e,t)=>e.some(e=>t.some(t=>t.endsWith("/*")?e.startsWith(t.slice(0,-1)):e===t));var ke=e=>new Map(e.allow.map(e=>[R(e.file,e.kind),e.count]));function xe(e,t){return e.kinds.filter(e=>t.kinds.includes(e))}var $e=(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 s=i.slice(0,12).join(", ");return` (line${1===i.length?"":"s"} ${s}${i.length>12?", …":""})`};function be(e,t,n){const i=ke(e),s=new Map;for(const[e,o]of t.counts){const{kind:t}=E(e);if(!l(t)||!n.includes(t))continue;const r=o-(i.get(e)??0);r>0&&s.set(e,r)}return{kinds:a.filter(e=>n.includes(e)),counts:s}}function ye(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 ve="\n// <button> in a comment is not a button, and <svg> in one is not a drawing\n/* nor is <input title=\"x\"> in this one, or dark:bg-black, or #fff */\nimport { createPortal } from 'react-dom';\nimport { Dialog } from '@headlessui/react';\nimport { TrashIcon } from '@heroicons/react/24/outline';\nimport type { Icon } from 'lucide-react';\nimport { Button, confirm } from 'efficient-shell';\nexport { Slot } from '@radix-ui/react-slot';\nexport { CheckIcon } from '@radix-ui/react-icons';\nimport { LineChart } from 'recharts';\nimport 'd3-scale';\nexport { VictoryPie } from 'victory';\nimport { BarChart } from '@mui/x-charts';\nimport Tree from 'react-d3-tree';\nimport { TimeSeriesChart } from 'efficient-shell/ui';\n// import 'chart.js' in a comment is not an import, and 'echarts' in a string is not one either\nconst chartLabel = 'd3-array';\n\nconst a = <button title=\"Says what it does\">x</button>;\nconst b = <input type=\"range\" />;\nconst c = <input type=\"text\" />;\nconst c2 = <input type={\"hidden\"} name=\"csrf\" />;\nconst c3 = <input type=\"hidden\" />;\nconst c4 = <input type={kind} />;\nconst d = <select />;\nconst d2 = <textarea />;\nconst e = <div role=\"dialog\" />;\nconst e2 = <dialog open />;\nconst e3 = <section role={'alertdialog'} />;\nconst f = <iframe title=\"Preview\" />;\nconst f2 = <object title=\"Chart\" />;\nconst g = <Button title=\"a prop, not a tooltip\" role=\"dialog\" />;\nconst g2 = (\n <button\n type=\"button\"\n title={hint}\n >\n y\n </button>\n);\nconst h = ReactDOM.createPortal(a, document.body);\nconst i = createPortal(a, document.body);\n\nasync function leave() {\n if (window.confirm('Sure?')) return;\n globalThis.alert('No');\n alert('native: nothing binds the name');\n prompt('native too');\n await confirm('the shell: the import binds it');\n record.confirm('a method, not the popup');\n}\n\nconst j = <div className=\"bg-white dark:bg-black dark:hover:text-white is-dark:no\" />;\nconst k = clsx('text-gray-900', on && 'dark:text-gray-100');\nconst l = <span style={{ color: '#fff', background: \"#12ab34\" }} className={`border-[#0a0b0c80] ${x}`} />;\nconst m = <a href=\"#faded\" id=\"#bad\" key=\"#abc\" to=\"#face\">skip</a>;\nconst n = <label htmlFor={'#dead'}>skip</label>;\nconst o = <span>&#1234; and BG#00340 and #12345 and #added are not colours</span>;\nconst p = 'entity &#x1f; ref BG#00340';\nconst q = <use xlinkHref=\"#abc\" fill=\"url(#fed)\" />;\nconst t = <div className=\"rounded-[4px] rounded-t-[0.5rem] hover:rounded-[2px] rounded-lg rounded-(--radius-card) rounded-[inherit] rounded-[var(--r)]\" />;\nconst u = <div style={{ borderRadius: 6, borderTopLeftRadius: '3px', borderBottomRightRadius: '50%', borderEndEndRadius: 'var(--radius-card)' }} />;\nconst v = <i style={{ borderRadius: 9999 }} />;\nconst w = <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 4h16\" /></svg>;\nconst w2 = <Svg viewBox=\"0 0 24 24\" />;\nconst w3 = '<svg viewBox=\"0 0 1 1\"></svg> in a string is not an element';\nconst r = lazy(() => import('@mui/material'));\nconst s = require('react-select');\nconst s2 = require('chart.js/auto');\nconst s3 = import('@nivo/line');\n",Se={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},je={kit:1,dark:1,portal:1,radius:2,chart:1},Ie=(...e)=>e.join("-"),Le=`\nconst s1 = <i className="${[Ie("px","2.5"),Ie("py","1.5"),"md:"+Ie("gap","1.5"),"-"+Ie("mt","1.5"),Ie("p","[10px]")].join(" ")}" />;\nconst s2 = <i className="${[Ie("p","0"),Ie("px","px"),Ie("p","0.5"),Ie("p","3"),Ie("gap-x","4"),Ie("p","12"),Ie("p","(--space-12)"),Ie("p","[var(--space-12)]"),Ie("space-x","reverse"),Ie("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="${[Ie("text","[11px]"),Ie("text","[0.8rem]"),Ie("text","xs"),Ie("text","[#fff]"),Ie("text","(--text-2xs)")].join(" ")}" />;\nconst f2 = <i style={{ fontSize: 12 }} />;\nconst f3 = { fontSize: 'var(--x)', font: 'inherit' };\nconst z1 = <i className="${[Ie("z","[9999]"),Ie("z","50"),Ie("z","10"),Ie("z","30"),"-"+Ie("z","10"),Ie("z","auto"),Ie("z","(--z-popup)"),Ie("z","[var(--z-popup)]")].join(" ")}" />;\nconst z2 = { zIndex: on ? 2020 : 2010 };\nconst z3 = { zIndex: Z_LAYERS.popup, top: 9999 };\nconst h1 = <i className="${[Ie("shadow","[0_1px_2px_#000]"),Ie("shadow","md"),"shadow",Ie("shadow","lg"),Ie("shadow","(--elevation-panel)"),Ie("shadow","black/20"),Ie("drop-shadow","md")].join(" ")}" />;\nconst h2 = { boxShadow: '0 1px 2px rgba(0,0,0,.1)' };\nconst h3 = { boxShadow: 'none', outline: 'var(--elevation-raised)' };\n`,ze={spacing:7,"font-size":3,"z-index":4,shadow:3,hex:1},Re={"ellipsis-label":9},Ee=e=>a.filter(t=>e[t]).map(t=>`${t} ${e[t]}`).join(", ")||"nothing";var Te="ui-kit.config.json",Ae="ui-kit.baseline.json",Ce="efficient-shell-ui-check",Me=`${Ce}: every surface a person operates takes its UI from efficient-shell (harness UI-24).\n\n ${Ce} check this repository against ${Ae}\n ${Ce} --print print today's counts as a baseline, and change nothing\n ${Ce} --summary print totals per kind and per folder, as Markdown\n ${Ce} --json print the result as JSON\n ${Ce} --update lower the lines whose counts fell, and delete the ones at zero\n ${Ce} --update --allow-move also follow a renamed or split file (no total may rise)\n ${Ce} --init write the first ${Ae}\n ${Ce} --init --kind <kind> take the baseline for a kind just added to "kinds"\n ${Ce} --no-base do not compare with the pull request's base branch\n\nKinds: ${a.join(", ")}\nReads ${Te} in the current directory.`;var Pe=(e,t)=>`${e} ${t}${1===e?"":"s"}`,Be=(e,t)=>{const n=P(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(`${Ce}: ${r}\n\n${Me}`),2;if(r.help)return t.out(Me),0;if(r.version)return t.out(t.version),0;const c=e=>(r.json?t.out(JSON.stringify({tool:Ce,version:t.version,ok:!1,failures:[e]},null,2)):t.err(`${Ce}: ${e}`),1),p=n(t.cwd,Te);if(!i(p))return c(`no ${Te} in ${t.cwd}. Run it from the repository root; the harness has the template.`);let f,m;try{f=function(e,t="ui-kit.config.json"){const n=[],i=e=>{n.push(e)},s=(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},o=(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=>!N(e))?(i(`${t} must be a list of objects`),[]):e;if(!N(e))throw new B(`${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=s(e.include,'"include"'),u=s(e.exclude,'"exclude"'),h=r(e.includeImporting,'"includeImporting"').map((e,t)=>({files:s(e.files,`"includeImporting"[${t}].files`,{required:!0}),modules:s(e.modules,`"includeImporting"[${t}].modules`,{required:!0}),reason:o(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:s(e.files,`"output"[${t}].files`,{required:!0}),reason:o(e.reason,`"output"[${t}]`)})),f=[],m=new Set;if(r(e.allow,'"allow"').forEach((e,t)=>{const n=`"allow"[${t}]`,[r]=s([e.file],`${n}.file`),d=o(e.reason,n);if(!l(e.kind))return void i(`${n}.kind must be one of: ${a.join(", ")}`);if(c.includes(e.kind)||i(`${n}: kind "${e.kind}" is not in "kinds"`),"number"!=typeof e.count||!Number.isInteger(e.count)||e.count<1)return void i(`${n}.count must be a whole number, 1 or more`);if(!r)return;const u=`${r}:${e.kind}`;m.has(u)&&i(`${n}: ${r} already has an allow entry for "${e.kind}"`),m.add(u),f.push({file:r,kind:e.kind,count:e.count,reason:d})}),n.length)throw new B(`${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(s(p,"utf8")),Te)}catch(e){return c(e instanceof B?e.message:`${Te} is not valid JSON: ${e.message}`)}try{m=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",ve,Se],["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",je],["tokens.tsx",Le,ze],["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",Re]];for(const[s,o,r]of i){const i=me(he(e,s,o,n));n.some(e=>(i[e]??0)!==(r[e]??0))&&t.push(`${s}: read ${Ee(i)}; it holds ${Ee(r)}`)}const s=me(he(e,"fixture.tsx",ve,["button"]));return"button"!==Object.keys(s).join()&&t.push(`asked for button alone, the reader reported ${Ee(s)}`),t}(m);if(w.length)return c(`the reader misread its own fixtures with typescript ${m.version}, so nothing it says about this repository can be trusted:\n - `+w.join("\n - "));const k=function(e,t,o){const r=[],a=y(o.exclude),l=y(o.output.flatMap(e=>e.files)),c=new Map,u=e=>{let i=c.get(e);return void 0===i&&c.set(e,i=s(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(o.include,'"include"'),o.output.forEach((e,t)=>h(e.files,`"output"[${t}]`)),o.includeImporting.forEach((e,t)=>h(e.files,`"includeImporting"[${t}]`));const p=new Set,f=e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!a(e)&&!l(e);for(const e of I(t,o.include))f(e)&&p.add(e);for(const n of o.includeImporting)for(const i of I(t,n.files))f(i)&&!p.has(i)&&we(ge(e,i,u(i)),n.modules)&&p.add(i);const m=[...p].sort(),w=o.kinds.filter(e=>!d(e)),k=new Map,$=new Map,b=new Set;for(const t of m){const n=he(e,t,u(t),w,b);let i=!1;for(const e of w){const s=n[e]?.length??0;s&&($.set(R(t,e),s),i=!0)}i&&k.set(t,n)}let v=[],S=[],j=[];const L=o.kinds.filter(d);if(L.length){const e=n(t,O);if(i(e)){const t=JSON.parse(s(e,"utf8")),n=["dependencies","peerDependencies","optionalDependencies"].flatMap(e=>Object.keys(t[e]??{})),i=new Set([...b].flatMap(e=>g[e]??[])),r=[...new Set(n)].sort();if(o.kinds.includes("kit-dep")){const e=r.filter(e=>"kit-dep"===x(e));v=e.filter(e=>!i.has(e)),S=e.filter(e=>i.has(e)),v.length&&$.set(R(O,"kit-dep"),v.length)}o.kinds.includes("chart-dep")&&(j=r.filter(e=>"chart-dep"===x(e)),j.length&&$.set(R(O,"chart-dep"),j.length))}else for(const e of L)r.push(`"kinds" includes "${e}", and there is no ${O} here to read.`)}for(const e of o.allow)(d(e.kind)?e.file===O: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:m,hits:k,counts:$,kitDeps:v,shellPeers:S,chartDeps:j,problems:r}}(m,t.cwd,f);if(0===k.files.length)return c(`read no files. "include" in ${Te} matches nothing, so a pass would mean nothing.`);const $=n(t.cwd,Ae),b=r.json,v=e=>{b||t.out(e)};if(r.print)return t.out(M(be(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,s]of t.counts){const{file:t,kind:o}=E(e);if(!l(o))continue;const r=n.get(o)??{count:0,files:new Set};r.count+=s,r.files.add(t),n.set(o,r);const a=t.split("/"),c=a.length>2?a.slice(0,2).join("/"):2===a.length?a[0]:".",d=i.get(c)??{};d[o]=(d[o]??0)+s,i.set(c,d)}const s=e.kinds.filter(e=>n.has(e)),o=[`**UI kit check (harness UI-24):** ${new Set([...t.counts.keys()].map(e=>E(e).file)).size} of ${Pe(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(s.length&&i.size){const e=e=>s.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));o.push("",`| Folder | ${s.map(e=>`\`${e}\``).join(" | ")} | Total |`,`|---|${s.map(()=>"---:").join("|")}|---:|`,...t.map(([t,n])=>`| \`${t}\` | ${s.map(e=>n[e]??0).join(" | ")} | ${e(n)} |`))}return o}(f,k))t.out(e);return 0}let S=null;if(i($))try{S=C(s($,"utf8"),Ae)}catch(e){return c(e instanceof z?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 ${Te}. Add it there first.`);const t=r.kinds;if(S){if(0===t.length)return c(`${Ae} 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=be(f,k,t);S={kinds:[...S.kinds,...t],counts:new Map([...S.counts,...n.counts])}}else{if(t.length)return c(`there is no ${Ae} yet. Run --init on its own first.`);S=be(f,k,f.kinds)}o($,M(S)),v(`${Ce}: wrote ${Ae} (${Pe(S.counts.size,"line")}: ${Be(S.counts,S.kinds)})`)}if(!S)return c(`no ${Ae}. This repository has not adopted the check yet: run ${Ce} --init, and commit the file.`);if(r.update){const e=function(e,t,n,{allowMove:i=!1}={}){const s=xe(e,t),o=be(e,n,s),r=new Map([...t.counts].filter(([e])=>s.includes(E(e).kind)));if(i){const e=P(r),n=P(o.counts),i=s.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:o,lowered:ye(r,o.counts),refused:[]}}const a=new Map;for(const[e,t]of r){const n=Math.min(t,o.counts.get(e)??0);n>0&&a.set(e,n)}return{baseline:{kinds:s,counts:a},lowered:ye(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,o($,M(S)),v(`${Ce}: ${e.lowered?`changed ${Pe(e.lowered,"line")} in`:"nothing to change in"} ${Ae}`)}const j=function(e,t,n){const i=[],s=[],o=[...n.problems],r=ke(e),a=new Set(xe(e,t)),c=e.kinds.filter(e=>!t.kinds.includes(e));c.length&&o.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&&s.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(A)){const{file:c,kind:d}=E(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}${$e(n,c,d)}. ${h[d].counts} is counted; use ${h[d].instead}.`):u<p?o.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&&s.push(`${c}: ${d} ${u}, and its line says ${p+f}`)}return{grown:i,shrunk:s,other:o,updateFixes:0===i.length&&0===o.length&&s.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 s=e.git(["rev-parse","--show-prefix"]);if(null===s)return{problems:[],note:"not a git checkout; the base branch was not compared"};const o=`origin/${i}`;if(null===e.git(["rev-parse","--verify","--quiet",`${o}^{commit}`])&&(e.git(["fetch","--no-tags","--depth=1","origin",`+refs/heads/${i}:refs/remotes/origin/${i}`]),null===e.git(["rev-parse","--verify","--quiet",`${o}^{commit}`])))return{problems:[],note:`${o} could not be fetched; the base branch was not compared`};const r=e.git(["show",`${o}:${s.trim()}${Ae}`]);if(null===r)return{problems:[],note:`${o} has no ${Ae} yet (adoption)`};let a;try{a=C(r,`${o}:${Ae}`)}catch{return{problems:[],note:`${o}'s ${Ae} could not be read; the base branch was not compared`}}const l=P(a.counts),c=P(t.counts);return{problems:n.filter(e=>a.kinds.includes(e)&&(c[e]??0)>(l[e]??0)).map(e=>`${Ae} holds ${c[e]??0} of "${e}", and ${o} holds ${l[e]??0}. The baseline only goes down: use ${h[e].instead}. A count that is meant to stay goes in "allow" in ${Te}, with its reason.`),note:`compared with ${o}`}}(t,S,f.kinds),T=f.kinds.filter(e=>S.kinds.includes(e)),F=`${Ce} --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:Ce,version:t.version,ok:U,schema:f.schema,kinds:f.kinds,files:k.files.length,counts:P(k.counts),baseline:P(S.counts),allowed:P(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 ${m.version})`),t.out(` ok read ${Pe(k.files.length,"file")}`),W(`${Te} and ${Ae} 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=>E(e).file));return t.out(` ok PROGRESS: ${q.size} of ${Pe(k.files.length,"file")} still draw UI of their own: `+Be(k.counts,T)),t.out(""),U?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${Pe(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(){for(const e of[n(process.cwd(),"package.json"),import.meta.url])try{return t(e)("typescript")}catch{}throw new Error("typescript is not installed")},git:function(t){try{return e("git",t,{cwd:process.cwd(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:6e4,maxBuffer:67108864})}catch{return null}},version:"7.24.0"});
@@ -0,0 +1 @@
1
+ import{buttonClasses as t}from"./chunk-K7PQXJO7.js";import{currentShellStrings as e}from"./chunk-BSCGC2HA.js";var n="http://www.w3.org/2000/svg",o={},s=/* @__PURE__ */new Map;function r(t,e){let n=document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.className=e,document.body.appendChild(n)),n}var i={success:"M5 13l4 4L19 7",error:"M6 18L18 6M6 6l12 12",warning:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",info:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",loading:"M12 3a9 9 0 019 9",bell:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"};function a(t,e){const o=document.createElementNS(n,"svg");o.setAttribute("class",e),o.setAttribute("fill","none"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("stroke","currentColor"),o.setAttribute("stroke-width","2");const s=document.createElementNS(n,"path");return s.setAttribute("stroke-linecap","round"),"loading"!==t&&s.setAttribute("stroke-linejoin","round"),s.setAttribute("d",i[t]),o.appendChild(s),o}function c(t,e){const n=document.createElement("div");return n.className=t,void 0!==e&&(n.textContent=e),n}function l(e,n,i){const l={...o,...i},d=l.placement??"top",u=l.sticky??!1,m=`${d}|${e}|${n}`;if(l.dedupe){const t=s.get(m);if(t)return t.restart(),{dismiss:t.dismiss}}"loading"!==e&&!1!==l.sound&&import("./sounds-FO772MN2.js").then(t=>{"success"===e?t.playSuccess():"error"===e?t.playError():t.playNotification()}).catch(()=>{});const p="bottom"===d?r("toast-container-bottom","fixed bottom-4 left-1/2 -translate-x-1/2 z-(--z-toast) flex flex-col-reverse gap-2 items-center pointer-events-none"):r("toast-container","fixed top-4 left-1/2 -translate-x-1/2 z-(--z-toast) flex flex-col gap-2 items-center pointer-events-none"),f="bottom"===d?"translateY(10px)":"translateY(-10px)",h=c("pointer-events-auto cursor-pointer rosh-toast");h.style.opacity="0",h.style.transform=`${f} scale(0.95)`,h.setAttribute("role","error"===e?"alert":"status"),h.setAttribute("aria-atomic","true"),h.appendChild(a(e,`h-4 w-4 rosh-tone-${e}${"loading"===e?" animate-spin":""}`));const v=document.createElement("span");if(v.textContent=n,h.appendChild(v),l.action){const{label:e,onClick:n}=l.action,o=document.createElement("button");o.type="button",o.className=t({variant:"link",size:"sm"}),o.textContent=e,o.addEventListener("click",t=>{t.stopPropagation(),g||(n(),b("action"))}),h.appendChild(o)}let y;p.appendChild(h),requestAnimationFrame(()=>{h.style.opacity="1",h.style.transform="translateY(0) scale(1)"});let g=!1;const b=t=>{g||(g=!0,y&&clearTimeout(y),s.delete(m),h.style.opacity="0",h.style.transform=`${f} scale(0.95)`,setTimeout(()=>h.remove(),300),l.onClose?.(t))},x=()=>b("dismissed"),C=l.duration??("info"===e?4500:3e3),A=()=>{y&&clearTimeout(y),u||(y=setTimeout(()=>b("timeout"),C))};return A(),h.addEventListener("mouseenter",()=>{y&&clearTimeout(y)}),h.addEventListener("mouseleave",()=>{g||A()}),h.addEventListener("click",x),s.set(m,{el:h,restart:A,dismiss:x}),{dismiss:x}}var d={success:(t,e)=>l("success",t,e),error:(t,e)=>l("error",t,e),warning:(t,e)=>l("warning",t,e),info:(t,e)=>l("info",t,e),notify:(t,n)=>function(t,n){!1!==(n?.sound??o.sound)&&import("./sounds-FO772MN2.js").then(t=>t.playNotification()).catch(()=>{});const s=r("notif-container","fixed top-4 right-4 z-(--z-toast) flex flex-col gap-3 items-end pointer-events-none"),i=c("pointer-events-auto cursor-pointer rosh-notif");i.style.opacity="0",i.style.transform="translateX(30px) scale(0.95)";const l=c("rosh-notif-badge");l.appendChild(a("bell","h-5 w-5"));const d=c("rosh-notif-body");d.append(c("rosh-notif-title",e().toast.notification),c("notif-msg rosh-notif-msg",t));const u=document.createElement("button");u.className="rosh-notif-close",u.textContent="×",i.append(l,d,u);const m=()=>{i.style.opacity="0",i.style.transform="translateX(30px) scale(0.95)",setTimeout(()=>i.remove(),300)};u.addEventListener("click",t=>{t.stopPropagation(),m()}),i.addEventListener("click",m),s.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateX(0) scale(1)"}),setTimeout(m,n?.duration??1e4)}(t,n),promise:(t,e,n)=>{const o=l("loading",e.loading,{...n,sticky:!0});return t.then(t=>{o.dismiss(),l("success","function"==typeof e.success?e.success(t):e.success,n)},t=>{o.dismiss(),l("error","function"==typeof e.error?e.error(t):e.error,n)}),t},configure:t=>{o={...t}}};export{d as toast_default};
@@ -1 +1 @@
1
- import{VERSION as e}from"./chunk-43KURNHH.js";import{setBoundaryErrorReporter as t}from"./chunk-KNUR2UEG.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)}}},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();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,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())}))})},x=class{p;l;h(e){this.p?.(e)}},N=[2500,4e3],U=[800,1800],j=e=>{document.prerendering?C(()=>j(e)):"complete"!==document.readyState?addEventListener("load",()=>j(e),!0):setTimeout(e)};var B=/^[A-Za-z0-9/_:.\-[\]{}*@~]+$/,H=/^[A-Za-z_$][A-Za-z0-9_$.]*$/,O=/^[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}},K=/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,J=/\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,W=/\b[a-z][a-z0-9+.-]*:\/\/\S+/gi,D=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi,V=/\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("//")&&B.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=t.getAccessToken();i&&n(t.endpoint??"/api/client-telemetry/web-batches/",{method:"POST",keepalive:!0,credentials:"same-origin",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify(e)}).catch(e=>{console.debug("[efficient-shell] client telemetry batch dropped:",e)})}function se(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 d=n.fetch??window.fetch.bind(window),l=new q({app:n.app,release:n.release,shell_version:O.test(e)?e:""}),u=ne(n.routeKey()),f=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 v=!1;const m=()=>{for(const e of l.drain())oe(e,n,d)},E=e=>{v||(l.addError(e),l.size>=50&&m())},L=(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(K,"[redacted]").replace(J,"[redacted]").replace(W,"[url]").replace(D,"[id]").replace(V,"[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},k=e=>{v||(l.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,u,()=>ne(n.routeKey()),f)),l.size>=50&&m())},S=n.vitalsSampleRate??1;S>0&&(S>=1||(n.random??Math.random)()<S)&&(((e,t={})=>{let n=!1;const s=w(t);C(()=>{let d,l=h(),u=g("LCP");const f=p(t,x),v=(i,a,o,s,c)=>{u=g("LCP",-1,i,a,o,s,c),d=r(e,u,N,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,N,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,N,t.reportAllChanges),o(()=>{u.value=performance.now()-a.timeStamp,n=!0,d(!0)})})}})})(k),F(k),((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))}))})(k),P(k),((e,t={})=>{const n=w(t);let o=g("TTFB"),d=r(e,o,U,t.reportAllChanges);j(()=>{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,U,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,U,t.reportAllChanges),d(!0))})},t)}})})(k));const z=e=>{const{error:t,message:n,filename:i,lineno:a,colno:r}=e;if(null!=t)return void E(L(t,"onerror"));const o=i?ee(`at ${i}:${a??0}:${r??0}`):[];E({...L(n??"","onerror"),frames:o})},M=e=>E(L(e.reason,"unhandledrejection")),$=()=>{"hidden"===document.visibilityState&&m()};window.addEventListener("error",z),window.addEventListener("unhandledrejection",M),document.addEventListener("visibilitychange",$),window.addEventListener("pagehide",m);const _=window.setInterval(m,n.flushIntervalMs??6e4),Z=t(e=>E(L(e,"boundary"))),B={flush:m,reportError:e=>E(L(e,"boundary")),stop(){v||(m(),v=!0,window.removeEventListener("error",z),window.removeEventListener("unhandledrejection",M),document.removeEventListener("visibilitychange",$),window.removeEventListener("pagehide",m),window.clearInterval(_),Z(),ae===B&&(ae=null))}};return ae=B,B}export{se as startClientTelemetry};
1
+ import{VERSION as e}from"./chunk-LVCFIIAB.js";import{setBoundaryErrorReporter as t}from"./chunk-KNUR2UEG.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{}},I=e=>globalThis.PerformanceObserver?.supportedEntryTypes?.includes("soft-navigation")&&"function"==typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint&&e&&e.reportSoftNavs,w=(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=I(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&&w(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)}}},F=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],R=(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)=>{F(()=>{for(const t of e)"soft-navigation"!==t.entryType?c.h(t):u(t);l(),t&&o(!0)})},h=["event","first-input"];I(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())}))})},x=class{p;l;h(e){this.p?.(e)}},B=[2500,4e3],j=[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/_:.\-[\]{}*@~]+$/,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,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&&O.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=t.getAccessToken();i&&n(t.endpoint??"/api/client-telemetry/web-batches/",{method:"POST",keepalive:!0,credentials:"same-origin",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify(e)}).catch(e=>{console.debug("[efficient-shell] client telemetry batch dropped:",e)})}function se(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 d=n.fetch??window.fetch.bind(window),l=new q({app:n.app,release:n.release,shell_version:H.test(e)?e:""}),u=ne(n.routeKey()),f=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 v=!1;const m=()=>{for(const e of l.drain())oe(e,n,d)},C=e=>{v||(l.addError(e),l.size>=50&&m())},L=(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},k=e=>{v||(l.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,u,()=>ne(n.routeKey()),f)),l.size>=50&&m())},S=n.vitalsSampleRate??1;S>0&&(S>=1||(n.random??Math.random)()<S)&&(((e,t={})=>{let n=!1;const s=I(t);E(()=>{let d,l=h(),u=g("LCP");const f=p(t,x),v=(i,a,o,s,c)=>{u=g("LCP",-1,i,a,o,s,c),d=r(e,u,B,t.reportAllChanges),n=!1,"soft-navigation"===i&&(l=h(!0))},m=e=>{f.l&&e.navigationId&&w(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())}},I=["largest-contentful-paint"];s&&I.push("interaction-contentful-paint","soft-navigation");const b=T(I,y);if(b){d=r(e,u,B,t.reportAllChanges);const c=["keydown","click","visibilitychange"],l=e=>{if(e.isTrusted&&!n){const e=u.id;F(()=>{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,B,t.reportAllChanges),o(()=>{u.value=performance.now()-a.timeStamp,n=!0,d(!0)})})}})})(k),R(k),((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"];I(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))}))})(k),P(k),((e,t={})=>{const n=I(t);let o=g("TTFB"),d=r(e,o,j,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,j,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,j,t.reportAllChanges),d(!0))})},t)}})})(k));const z=e=>{const{error:t,message:n,filename:i,lineno:a,colno:r}=e;if(null!=t)return void C(L(t,"onerror"));const o=i?ee(`at ${i}:${a??0}:${r??0}`):[];C({...L(n??"","onerror"),frames:o})},M=e=>C(L(e.reason,"unhandledrejection")),$=()=>{"hidden"===document.visibilityState&&m()};window.addEventListener("error",z),window.addEventListener("unhandledrejection",M),document.addEventListener("visibilitychange",$),window.addEventListener("pagehide",m);const _=window.setInterval(m,n.flushIntervalMs??6e4),Z=t(e=>C(L(e,"boundary"))),U={flush:m,reportError:e=>C(L(e,"boundary")),stop(){v||(m(),v=!0,window.removeEventListener("error",z),window.removeEventListener("unhandledrejection",M),document.removeEventListener("visibilitychange",$),window.removeEventListener("pagehide",m),window.clearInterval(_),Z(),ae===U&&(ae=null))}};return ae=U,U}export{se as startClientTelemetry};
@@ -1,4 +1,4 @@
1
- import{Breadcrumbs as e}from"./chunk-UQOFRZMX.js";import{SidebarLayout as t}from"./chunk-AW7GP54G.js";import{BrandMark as r}from"./chunk-YJRAJD27.js";import{OneLineLabel as n,TH_ONE_LINE as a}from"./chunk-RVPQRXC4.js";import{inputClasses as l,PLACEHOLDER_INK as i,FILTER_ON as o,FILTER_ON_INK as s,FILTER_OFF as c,INPUT_BASE_ON as d,INPUT_BASE as u,INPUT_SIZES as h}from"./chunk-HJQAE6SP.js";import{isSafeLinkHref as m}from"./chunk-PJPK2ADX.js";import{useShellLanguage as p}from"./chunk-ISEM2MNY.js";import{toast_default as g}from"./chunk-G6LV5Z2W.js";import{useIsMobile as f,useShortcutLabel as b,useShellPrefs as x}from"./chunk-ODGCVNYP.js";import{LoadingSpinner as y}from"./chunk-NVFKXL52.js";import{isAriaDisabled as v,swallowPress as w,describedByWith as N,OffWithReason as k,useDropdownPosition as $,MENU_MAX_HEIGHT as M,Button_default as C,Tooltip as L,popupBounds as D,VIEWPORT_MARGIN as S,placeMenu as A,followAnchor as P,POPUP_MAX_WIDTH as j,followRect as z,placeAtPoint as F}from"./chunk-SZTKBF3D.js";import{useTabLayer as E,focusableIn as B,useFocusTrap as I,useScrollLock as T,dialogA11y as O,stopAfter as R}from"./chunk-U5H3Q5JM.js";import{PopupMenu as W,MenuSemanticsContext as K,leavesContextMenuAlone as q,PopupMenuDivider as _,PopupMenuLabel as H,itemLook as U,MenuCheckMark as V}from"./chunk-GNW45MGV.js";import{useDismissPopupsOnOpen as Y}from"./chunk-UVBK6YSR.js";import{iconButtonClasses as G,buttonClasses as X}from"./chunk-K7PQXJO7.js";import{glassStyle as J,GLASS_DIVIDER as Z,solidSurfaceStyle as Q}from"./chunk-7IQ3B77H.js";import{registerModalEscapeInterceptor as ee,onOverlayOpen as te,Z_LAYERS as re}from"./chunk-FIEA5CGB.js";import{useBrowserLayoutEffect as ne,useBrowserValue as ae,useHydrated as le,useBrowserValueOnce as ie,useBrowserState as oe}from"./chunk-D65T4H6J.js";import{reportBoundaryError as se}from"./chunk-KNUR2UEG.js";import{useFileIntake as ce,humanSize as de,FileIntakeAlert as ue}from"./chunk-75BDNIYU.js";import{useShellLocale as he,useShellStrings as me,DEFAULT_SHELL_STRINGS as pe,currentShellStrings as ge,splitAround as fe}from"./chunk-BSCGC2HA.js";import{formatPlain as be,formatFixed as xe,formatPercent as ye}from"./chunk-C3QOHMR6.js";import{parseFocal as ve,formatFocal as we,nudgeFocal as Ne,focalFromRect as ke}from"./chunk-AP2QEJXQ.js";import{calendarNames as $e,firstDayOfWeek as Me,formatDate as Ce,EMPTY_VALUE as Le,toInstant as De,timeAgo as Se,formatDateTime as Ae}from"./chunk-W32SKK3D.js";import{Icon as Pe,setIconSet as je}from"./chunk-B427NVDP.js";import{forwardRef as ze,useId as Fe,useCallback as Ee,useState as Be,useRef as Ie,useMemo as Te,useEffect as Oe,createContext as Re,Children as We,isValidElement as Ke,cloneElement as qe,useContext as _e,Fragment as He,Component as Ue,useSyncExternalStore as Ve,useLayoutEffect as Ye}from"react";import{jsx as Ge,jsxs as Xe,Fragment as Je}from"react/jsx-runtime";import{createPortal as Ze}from"react-dom";var Qe=ze(function({children:e,variant:t="ghost",size:r="md",type:n="button",className:a="",pressed:l,disabledReason:i,ink:o,disabled:s,onClick:c,"aria-disabled":d,"aria-describedby":u,...h},m){const p=Fe(),g=(Boolean(s)||v(d))&&null!=i&&""!==i,f=g||v(d),b=/* @__PURE__ */Ge("button",{ref:m,type:n,className:G({variant:t,size:r,pressed:l??(!0===h["aria-pressed"]||"true"===h["aria-pressed"]),ink:o,className:a}),...h,disabled:g?void 0:s,"aria-disabled":!!f||d,"aria-describedby":N(u,g?p:void 0),onClick:f?w:c,children:e});return g?/* @__PURE__ */Ge(k,{reason:i,id:p,children:b}):b}),et=ze(function({invalid:e,leftIcon:t,rightAdornment:r,size:n,className:a="",readOnly:o,...s},c){const d=`${t?"pl-10":""} ${r?"pr-10":""}`.trim(),u=
1
+ import{Breadcrumbs as e}from"./chunk-UQOFRZMX.js";import{SidebarLayout as t}from"./chunk-AW7GP54G.js";import{BrandMark as r}from"./chunk-YJRAJD27.js";import{OneLineLabel as n,TH_ONE_LINE as a}from"./chunk-RVPQRXC4.js";import{inputClasses as l,PLACEHOLDER_INK as i,FILTER_ON as o,FILTER_ON_INK as s,FILTER_OFF as c,INPUT_BASE_ON as d,INPUT_BASE as u,INPUT_SIZES as h}from"./chunk-HJQAE6SP.js";import{isSafeLinkHref as m}from"./chunk-PJPK2ADX.js";import{useShellLanguage as p}from"./chunk-ISEM2MNY.js";import{toast_default as g}from"./chunk-2CD2LZHH.js";import{useIsMobile as f,useShortcutLabel as b,useShellPrefs as x}from"./chunk-ODGCVNYP.js";import{LoadingSpinner as y}from"./chunk-NVFKXL52.js";import{isAriaDisabled as v,swallowPress as w,describedByWith as N,OffWithReason as k,useDropdownPosition as $,MENU_MAX_HEIGHT as M,Button_default as C,Tooltip as L,popupBounds as D,VIEWPORT_MARGIN as S,placeMenu as A,followAnchor as P,POPUP_MAX_WIDTH as j,followRect as z,placeAtPoint as F}from"./chunk-SZTKBF3D.js";import{useTabLayer as E,focusableIn as B,useFocusTrap as I,useScrollLock as T,dialogA11y as O,stopAfter as R}from"./chunk-U5H3Q5JM.js";import{PopupMenu as W,MenuSemanticsContext as K,leavesContextMenuAlone as q,PopupMenuDivider as _,PopupMenuLabel as H,itemLook as U,MenuCheckMark as V}from"./chunk-GNW45MGV.js";import{useDismissPopupsOnOpen as Y}from"./chunk-UVBK6YSR.js";import{iconButtonClasses as G,buttonClasses as X}from"./chunk-K7PQXJO7.js";import{glassStyle as J,GLASS_DIVIDER as Z,solidSurfaceStyle as Q}from"./chunk-7IQ3B77H.js";import{registerModalEscapeInterceptor as ee,onOverlayOpen as te,Z_LAYERS as re}from"./chunk-FIEA5CGB.js";import{useBrowserLayoutEffect as ne,useBrowserValue as ae,useHydrated as le,useBrowserValueOnce as ie,useBrowserState as oe}from"./chunk-D65T4H6J.js";import{reportBoundaryError as se}from"./chunk-KNUR2UEG.js";import{useFileIntake as ce,humanSize as de,FileIntakeAlert as ue}from"./chunk-75BDNIYU.js";import{useShellLocale as he,useShellStrings as me,DEFAULT_SHELL_STRINGS as pe,currentShellStrings as ge,splitAround as fe}from"./chunk-BSCGC2HA.js";import{formatPlain as be,formatFixed as xe,formatPercent as ye}from"./chunk-C3QOHMR6.js";import{parseFocal as ve,formatFocal as we,nudgeFocal as Ne,focalFromRect as ke}from"./chunk-AP2QEJXQ.js";import{calendarNames as $e,firstDayOfWeek as Me,formatDate as Ce,EMPTY_VALUE as Le,toInstant as De,timeAgo as Se,formatDateTime as Ae}from"./chunk-W32SKK3D.js";import{Icon as Pe,setIconSet as je}from"./chunk-B427NVDP.js";import{forwardRef as ze,useId as Fe,useCallback as Ee,useState as Be,useRef as Ie,useMemo as Te,useEffect as Oe,createContext as Re,Children as We,isValidElement as Ke,cloneElement as qe,useContext as _e,Fragment as He,Component as Ue,useSyncExternalStore as Ve,useLayoutEffect as Ye}from"react";import{jsx as Ge,jsxs as Xe,Fragment as Je}from"react/jsx-runtime";import{createPortal as Ze}from"react-dom";var Qe=ze(function({children:e,variant:t="ghost",size:r="md",type:n="button",className:a="",pressed:l,disabledReason:i,ink:o,disabled:s,onClick:c,"aria-disabled":d,"aria-describedby":u,...h},m){const p=Fe(),g=(Boolean(s)||v(d))&&null!=i&&""!==i,f=g||v(d),b=/* @__PURE__ */Ge("button",{ref:m,type:n,className:G({variant:t,size:r,pressed:l??(!0===h["aria-pressed"]||"true"===h["aria-pressed"]),ink:o,className:a}),...h,disabled:g?void 0:s,"aria-disabled":!!f||d,"aria-describedby":N(u,g?p:void 0),onClick:f?w:c,children:e});return g?/* @__PURE__ */Ge(k,{reason:i,id:p,children:b}):b}),et=ze(function({invalid:e,leftIcon:t,rightAdornment:r,size:n,className:a="",readOnly:o,...s},c){const d=`${t?"pl-10":""} ${r?"pr-10":""}`.trim(),u=
2
2
  /* @__PURE__ */Ge("input",{ref:c,"aria-invalid":e||void 0,readOnly:o,className:l({invalid:e,size:n,readOnly:o,className:[d,a].filter(Boolean).join(" ")}),...s});return t||r?/* @__PURE__ */Xe("div",{className:"relative",children:[t&&/* @__PURE__ */Ge("span",{className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 ${i}`,children:t}),u,r&&/* @__PURE__ */Ge("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400",children:r})]}):u}),tt=ze(function({invalid:e,autoGrow:t,className:r="",onInput:n,rows:a=3,size:i,readOnly:o,...s},c){const d=Ee(e=>{if(t){const t=e.currentTarget;t.style.height="auto",t.style.height=`${t.scrollHeight}px`}n?.(e)},[t,n]);/* @__PURE__ */
3
3
  return Ge("textarea",{ref:c,"aria-invalid":e||void 0,rows:a,onInput:d,readOnly:o,className:l({invalid:e,size:i,readOnly:o,multiline:!0,className:`${t?"resize-none overflow-hidden":""} ${r}`.trim()}),...s})});function rt(e){for(let t=0;t<e.length;t++)if(!e[t].disabled)return t;return-1}function nt(e){for(let t=e.length-1;t>=0;t--)if(!e[t].disabled)return t;return-1}function at(e,t,r){let n=t+r;for(;n>=0&&n<e.length;){if(!e[n].disabled)return n;n+=r}return t>=0&&t<e.length&&!e[t].disabled?t:r>0?rt(e):nt(e)}function lt(e,t,r){const n=t.toLowerCase(),a=e.length;if(!n||0===a)return-1;for(let t=1;t<=a;t++){const l=((r+t)%a+a)%a,i=e[l];if(!i.disabled&&i.label.toLowerCase().startsWith(n))return l}return-1}var it=e=>Array.isArray(e.options);function ot(e){const t=[];for(const r of e)it(r)?t.push(...r.options):t.push(r);return t}function st(e,t){const r=[];for(const n of e){if(!it(n)){t(n)&&r.push(n);continue}const e=n.options.filter(t);e.length&&r.push({...n,options:e})}return r}function ct(e,t,r,n=""){const a=[];let l=0;return e.forEach((e,i)=>{if(!it(e))return a.push(t(e,l)),void(l+=1);const o=`${r}-group-${i}`,s=l;l+=e.options.length,a.push(
4
4
  /* @__PURE__ */Xe("div",{role:"group","aria-labelledby":o,children:[
@@ -539,7 +539,7 @@ return Xe("button",{type:"button",role:"menuitem",disabled:e.disabled,className:
539
539
  return Xe("div",{ref:b,className:`relative inline-flex ${l}`.trim(),children:[
540
540
  /* @__PURE__ */Ge("button",{ref:x,id:k,type:"button","aria-haspopup":"menu","aria-expanded":m,"aria-controls":m?w:void 0,"aria-label":a,"aria-describedby":h,disabled:d,onClick:()=>m?$(!1):S(M(0,1)),onKeyDown:e=>{"ArrowDown"===e.key||"Enter"===e.key||" "===e.key?(e.preventDefault(),S(M(0,1))):"ArrowUp"===e.key&&(e.preventDefault(),S(M(t.length-1,-1)))},className:i??"inline-flex items-center justify-center rounded-(--radius-control) text-gray-600 transition-colors not-disabled:not-aria-disabled:hover:bg-gray-100 not-disabled:not-aria-disabled:hover:text-gray-900 rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)] disabled:cursor-not-allowed disabled:opacity-60 "+(a?"h-8 min-w-8 px-0":"h-8 min-w-8 gap-2 px-3"),children:e}),m&&
541
541
  /* @__PURE__ */Ge(W,{portal:!0,className:o,style:B,children:/* @__PURE__ */Ge("div",{ref:y,id:w,role:"menu","aria-orientation":"vertical","aria-label":a,"aria-labelledby":a?void 0:k,tabIndex:-1,onKeyDown:e=>{if("ArrowDown"===e.key)e.preventDefault(),f(M(g+1,1));else if("ArrowUp"===e.key)e.preventDefault(),f(M(g-1,-1));else if("Home"===e.key)e.preventDefault(),f(M(0,1));else if("End"===e.key)e.preventDefault(),f(M(t.length-1,-1));else if("Tab"===e.key)e.preventDefault(),$(!0);else if(" "===e.key){const t=e.target;t.matches?.("a[href]")&&(e.preventDefault(),t.click())}else 1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey||(e=>{const r=Date.now(),n=e.key.toLowerCase(),a=r-v.current.at<500?v.current.text+n:n;v.current={text:a,at:r};const l=[...a].every(e=>e===a[0]),i=l?a[0]:a,o=l?g+1:Math.max(g,0),s=y.current,c=t.length;for(let r=0;r<c;r+=1){const n=((o+r)%c+c)%c;if(Vo(t[n])&&(s?.querySelector(`[data-dropdown-index="${n}"]`)?.textContent?.trim().toLowerCase()??"").startsWith(i))return e.preventDefault(),void f(n)}})(e)},children:(()=>{const e=[];for(let r=0;r<t.length;){const n=t[r];if("radio"!==n.type&&"checkbox"!==n.type){e.push(E(n,r)),r+=1;continue}const a=n.type,l=r,i=[];for(;r<t.length&&t[r].type===a;)i.push(E(t[r],r)),r+=1;const o="label"===t[l-1]?.type?`${w}-label-${l-1}`:void 0;e.push(/* @__PURE__ */Ge("div",{role:"group","aria-labelledby":o,children:i},`group:${n.key}`))}return e})()})})]})}var Go=()=>({left:0,top:0,right:window.innerWidth,bottom:window.innerHeight});function Xo({anchor:e,bounds:t,side:r="top",align:n="start","aria-label":a,children:l,className:i=""}){const o=le(),s=Ie(null),c=Ie(e);c.current=e;const d=Ie(t);d.current=t;const u=Ee(()=>{const e=s.current,t=c.current();if(!e||!t)return;const a=(d.current??Go)(),l=e.style;l.maxWidth=`${Math.max(0,a.right-a.left-2*S)}px`;const i=A({trigger:t,menu:{width:e.offsetWidth,height:e.offsetHeight},bounds:a,align:n,side:r});l.left=`${i.left}px`,l.top=`${i.top}px`,e.dataset.side=i.side},[n,r]);ne(()=>{o&&u()}),Oe(()=>{if(!o)return;const e=z(()=>c.current(),u),t=s.current;if(!t||"undefined"==typeof ResizeObserver)return e;const r=new ResizeObserver(()=>u());return r.observe(t),()=>{e(),r.disconnect()}},[o,u]);return o&&e()?Ze(
542
- /* @__PURE__ */Ge("div",{ref:s,role:"toolbar","aria-label":a,"data-floating-bar":"",onMouseDown:e=>{const t=e.target;t?.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])')||e.preventDefault()},className:`fixed rounded-(--radius-popup) p-1 ${i}`.trim(),style:{...Q(),position:"fixed",left:0,top:0,zIndex:re.popup},children:l}),document.body):null}function Jo(e){return e?[...e.querySelectorAll("button:not([disabled])")].filter(e=>!e.closest("[data-popup-submenu-panel]")):[]}function Zo({at:e,onClose:t,children:r,owner:n,"aria-label":a,minWidth:l=180,className:i="",autoFocus:o=!0}){const s=Ie(null),[c,d]=Be(null),u=Ie(t);u.current=t,ne(()=>{const t=s.current?.closest("[data-popup-menu-tree]");if(!t)return;const r={width:t.offsetWidth,height:t.offsetHeight},a=F({point:e,menu:r,bounds:D(n??null)});d(e=>e&&e.left===a.left&&e.top===a.top&&e.maxHeight===a.maxHeight?e:{left:a.left,top:a.top,maxHeight:a.maxHeight,scroll:r.height>a.maxHeight})},[e.x,e.y,n]);const h=Ie(null),m=Ie(!1);Oe(()=>(h.current=document.activeElement,()=>{const e=document.activeElement;e&&e!==document.body&&!s.current?.contains(e)||h.current?.focus?.({preventScroll:!0})}),[]),Oe(()=>{c&&!m.current&&o&&(m.current=!0,Jo(s.current)[0]?.focus({preventScroll:!0}))},[c,o]),Oe(()=>{if(o)return;const e=e=>{if(s.current?.contains(document.activeElement))return;const t=Jo(s.current),r="ArrowDown"===e.key||"Home"===e.key?t[0]:"ArrowUp"===e.key||"End"===e.key?t[t.length-1]:void 0;r&&(e.preventDefault(),r.focus({preventScroll:!0}))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o]),Oe(()=>ee(e=>"Escape"===e.key&&(u.current(),!0),()=>s.current),[]),Oe(()=>{const e=()=>u.current();return window.addEventListener("resize",e),window.addEventListener("blur",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("blur",e),window.removeEventListener("scroll",e,!0)}},[]);const p=Ee(e=>{if(e.target.closest("[data-popup-submenu-panel]"))return;if("Tab"===e.key)return e.preventDefault(),void u.current();const t=Jo(s.current);if(0===t.length)return;const r=t.indexOf(document.activeElement),n="ArrowDown"===e.key?(r+1)%t.length:"ArrowUp"===e.key?r<=0?t.length-1:r-1:"Home"===e.key?0:"End"===e.key?t.length-1:-1;n<0||(e.preventDefault(),t[n].focus())},[]),g=c?{left:c.left,top:c.top,maxHeight:c.maxHeight,...c.scroll?{overflowY:"auto"}:{}}:{left:e.x,top:e.y,visibility:"hidden"};/* @__PURE__ */
542
+ /* @__PURE__ */Ge("div",{ref:s,role:"group","aria-label":a,"data-floating-bar":"",onMouseDown:e=>{const t=e.target;t?.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])')||e.preventDefault()},className:`fixed rounded-(--radius-popup) p-1 ${i}`.trim(),style:{...Q(),position:"fixed",left:0,top:0,zIndex:re.popup},children:l}),document.body):null}function Jo(e){return e?[...e.querySelectorAll("button:not([disabled])")].filter(e=>!e.closest("[data-popup-submenu-panel]")):[]}function Zo({at:e,onClose:t,children:r,owner:n,"aria-label":a,minWidth:l=180,className:i="",autoFocus:o=!0}){const s=Ie(null),[c,d]=Be(null),u=Ie(t);u.current=t,ne(()=>{const t=s.current?.closest("[data-popup-menu-tree]");if(!t)return;const r={width:t.offsetWidth,height:t.offsetHeight},a=F({point:e,menu:r,bounds:D(n??null)});d(e=>e&&e.left===a.left&&e.top===a.top&&e.maxHeight===a.maxHeight?e:{left:a.left,top:a.top,maxHeight:a.maxHeight,scroll:r.height>a.maxHeight})},[e.x,e.y,n]);const h=Ie(null),m=Ie(!1);Oe(()=>(h.current=document.activeElement,()=>{const e=document.activeElement;e&&e!==document.body&&!s.current?.contains(e)||h.current?.focus?.({preventScroll:!0})}),[]),Oe(()=>{c&&!m.current&&o&&(m.current=!0,Jo(s.current)[0]?.focus({preventScroll:!0}))},[c,o]),Oe(()=>{if(o)return;const e=e=>{if(s.current?.contains(document.activeElement))return;const t=Jo(s.current),r="ArrowDown"===e.key||"Home"===e.key?t[0]:"ArrowUp"===e.key||"End"===e.key?t[t.length-1]:void 0;r&&(e.preventDefault(),r.focus({preventScroll:!0}))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o]),Oe(()=>ee(e=>"Escape"===e.key&&(u.current(),!0),()=>s.current),[]),Oe(()=>{const e=()=>u.current();return window.addEventListener("resize",e),window.addEventListener("blur",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("blur",e),window.removeEventListener("scroll",e,!0)}},[]);const p=Ee(e=>{if(e.target.closest("[data-popup-submenu-panel]"))return;if("Tab"===e.key)return e.preventDefault(),void u.current();const t=Jo(s.current);if(0===t.length)return;const r=t.indexOf(document.activeElement),n="ArrowDown"===e.key?(r+1)%t.length:"ArrowUp"===e.key?r<=0?t.length-1:r-1:"Home"===e.key?0:"End"===e.key?t.length-1:-1;n<0||(e.preventDefault(),t[n].focus())},[]),g=c?{left:c.left,top:c.top,maxHeight:c.maxHeight,...c.scroll?{overflowY:"auto"}:{}}:{left:e.x,top:e.y,visibility:"hidden"};/* @__PURE__ */
543
543
  return Ge(W,{portal:!0,minWidth:l,style:g,onClose:t,className:i,children:/* @__PURE__ */Ge(K.Provider,{value:!0,children:/* @__PURE__ */Ge("div",{ref:s,role:"menu","aria-label":a,"data-context-menu":"",onKeyDown:p,children:r})})})}function Qo(){const[e,t]=Be(null),r=Ee(()=>t(null),[]),n=Ee((e,r)=>{const n="nativeEvent"in e?e.nativeEvent:e;if(q(n))return!1;e.preventDefault();const a=e.target instanceof Element?e.target:null;let{clientX:l,clientY:i}=e;if(0===l&&0===i&&a){const e=a.getBoundingClientRect();l=e.left,i=e.bottom}return t({x:l,y:i,data:r,owner:a}),!0},[]),a=Ee(e=>{n(e,void 0)},[n]);return{open:n,onContextMenu:a,close:r,state:e,props:{at:{x:e?.x??0,y:e?.y??0},owner:e?.owner??null,onClose:r}}}var es="Alt+ArrowUp Alt+ArrowDown";function ts(e){return!e.altKey||e.ctrlKey||e.metaKey?null:"ArrowUp"===e.key?"up":"ArrowDown"===e.key?"down":null}var rs=/* @__PURE__ */Xe("svg",{"aria-hidden":"true",viewBox:"0 0 4 14",fill:"currentColor",className:"h-3.5 w-1",children:[
544
544
  /* @__PURE__ */Ge("circle",{cx:"2",cy:"3",r:"1.1"}),
545
545
  /* @__PURE__ */Ge("circle",{cx:"2",cy:"7",r:"1.1"}),
@@ -1,2 +1,2 @@
1
- import{toast_default as t}from"./chunk-G6LV5Z2W.js";import{useShellPrefs as e}from"./chunk-ODGCVNYP.js";import{useSyncExternalStore as n,useCallback as o,useMemo as a}from"react";var r=[{id:"bell",label:"Bell",description:"Soft bell with one harmonic"},{id:"chime",label:"Chime",description:"Two-note ascending chime"},{id:"bowl",label:"Singing Bowl",description:"Long-decay meditation tone"},{id:"wind-chimes",label:"Wind Chimes",description:"Four soft tones in succession"},{id:"off",label:"Off (silent)",description:"No sound — only desktop notification"}],i=[{id:"none",label:"None"},{id:"tick-fast",label:"Ticking Fast"},{id:"tick-slow",label:"Ticking Slow"},{id:"rain",label:"Rain"},{id:"fireplace",label:"Fireplace"},{id:"white",label:"White Noise"},{id:"pink",label:"Pink Noise"},{id:"brown",label:"Brown Noise"}],c=()=>`pomodoro-${/* @__PURE__ */(new Date).toISOString().slice(0,10)}`,l={focus:1500,short:300,long:900},s="bell",u=100,d=1,f="none",m=50,h={autoStartBreaks:!1,autoStartPomodoros:!1,longBreakInterval:4},g={running:!1,remaining:l.focus,mode:"focus",total:l.focus,streak:0,count:"undefined"!=typeof localStorage?(()=>{try{return parseInt(localStorage.getItem(c())||"0",10)||0}catch{return 0}})():0},p=null,k=/* @__PURE__ */new Set,w=t=>{g={...g,...t},k.forEach(t=>t())};function M(){return g}function S(t){return k.add(t),()=>{k.delete(t)}}function b(t){l=t,g.running||g.remaining!==g.total||w({remaining:t[g.mode],total:t[g.mode]})}function y(t){s=t}function v(t,e){u=Math.max(0,Math.min(100,Math.round(t))),d=Math.max(1,Math.min(5,Math.round(e)))}function T(t){h={autoStartBreaks:!!t.autoStartBreaks,autoStartPomodoros:!!t.autoStartPomodoros,longBreakInterval:Math.max(1,Math.min(20,Math.round(t.longBreakInterval||4)))}}function A(t,e){f=t,m=Math.max(0,Math.min(100,Math.round(e))),g.running&&"focus"===g.mode?(V(),G()):"none"!==t&&0!==m||V()}function I(){g.running||(w({running:!0}),p=setInterval(C,1e3),"focus"===g.mode&&G())}function x(){(g.running||null!==p)&&(null!==p&&(clearInterval(p),p=null),w({running:!1}),V())}function B(t){x(),w({mode:t,remaining:l[t],total:l[t]})}function C(){g.remaining<=1?function(){null!==p&&(clearInterval(p),p=null);V(),N(s,{volume:u,repeat:d});const e="focus"===g.mode?"Pomodoro complete — time for a break! 🍅":"Break's over — back to work!";if("undefined"!=typeof Notification&&"granted"===Notification.permission)try{new Notification(e)}catch{}try{t.info(e)}catch{}if("focus"===g.mode){const t=g.streak+1,e=g.count+1;(t=>{try{localStorage.setItem(c(),String(t))}catch{}})(e);const n=t%h.longBreakInterval===0?"long":"short";w({running:!1,streak:t,count:e,mode:n,remaining:l[n],total:l[n]}),h.autoStartBreaks&&setTimeout(()=>I(),50)}else w({running:!1,mode:"focus",remaining:l.focus,total:l.focus}),h.autoStartPomodoros&&setTimeout(()=>I(),50)}():w({remaining:g.remaining-1})}function N(t=s,e={}){if("off"===t)return;const n=Math.max(0,Math.min(100,e.volume??100))/100;if(0===n)return;const o=Math.max(1,Math.min(5,e.repeat??1));for(let e=0;e<o;e++)setTimeout(()=>P(t,n),2500*e)}function P(t,e){try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=(t,n,a,r=.22,i="sine")=>{const c=o.createOscillator(),l=o.createGain();c.connect(l),l.connect(o.destination),c.type=i,c.frequency.value=t;const s=o.currentTime+n;l.gain.setValueAtTime(0,s),l.gain.linearRampToValueAtTime(r*e,s+.03),l.gain.exponentialRampToValueAtTime(1e-4,s+a),c.start(s),c.stop(s+a)};let r=2;"bell"===t?(a(880,0,1.8),a(1320,0,1.4,.1),r=2):"chime"===t?(a(659.25,0,.7),a(880,.2,1.3),r=2):"bowl"===t?(a(440,0,3.4,.22),a(660,0,3,.08),a(880,.05,2.8,.05),r=4):"wind-chimes"===t&&(a(1175,0,1.1,.16),a(880,.15,1.3,.16),a(1318,.3,1.5,.16),a(1047,.5,1.7,.13),r=3),setTimeout(()=>{try{o.close()}catch{}},1e3*r+500)}catch{}}var D=null,O={none:0,white:.3,pink:.3,brown:.3,"tick-fast":.6,"tick-slow":.6,rain:.4,fireplace:.5};function _(t,e){if("none"===e)return null;const n=t.sampleRate,o="white"===e||"pink"===e||"brown"===e?2:4,a=n*o,r=t.createBuffer(1,a,n),i=r.getChannelData(0);if("white"===e)for(let t=0;t<a;t++)i[t]=.5*(2*Math.random()-1);else if("pink"===e){let t=0,e=0,n=0,o=0,r=0,c=0,l=0;for(let s=0;s<a;s++){const a=2*Math.random()-1;t=.99886*t+.0555179*a,e=.99332*e+.0750759*a,n=.969*n+.153852*a,o=.8665*o+.3104856*a,r=.55*r+.5329522*a,c=-.7616*c-.016898*a,i[s]=.11*(t+e+n+o+r+c+l+.5362*a)*.55,l=.115926*a}}else if("brown"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=3.5*t*.5}}else if("tick-fast"===e||"tick-slow"===e){const t="tick-fast"===e?.5:1,r=Math.floor(.045*n);for(let e=0;e<o;e+=t){const t=Math.floor(e*n);for(let e=0;e<r&&t+e<a;e++){const o=Math.exp(-e/n*180),a=2*Math.random()-1,r=Math.sin(2*Math.PI*1100*(e/n));i[t+e]+=(.7*a+.25*r)*o*.55}}}else if("rain"===e){let t=0;for(let e=0;e<a;e++){const o=2*Math.random()-1,a=o-.93*t;t=o;const r=.7+.3*Math.sin(e/n*2*Math.PI*.25);i[e]=a*r*.4}}else if("fireplace"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=1.6*t}let e=.4*Math.random()*n;for(;e<a;){const t=Math.floor((.012+.05*Math.random())*n),o=.35+.45*Math.random(),r=Math.floor(e);for(let e=0;e<t&&r+e<a;e++){const t=Math.exp(-e/n*90);i[r+e]+=(2*Math.random()-1)*t*o}e+=(.08+.62*Math.random())*n}}return r}function G(){if(!D&&"none"!==f&&0!==m)try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const e=new t,n=_(e,f);if(!n){try{e.close()}catch{}return}const o=e.createBufferSource();o.buffer=n,o.loop=!0;const a=e.createGain();a.gain.value=m/100*O[f],o.connect(a).connect(e.destination),o.start(),D={ctx:e,src:o,gain:a}}catch{}}function V(){if(D){try{D.src.stop()}catch{}try{D.ctx.close()}catch{}D=null}}function R(t,e){if("none"!==t&&0!==e)try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=_(o,t);if(!a){try{o.close()}catch{}return}const r=o.createBufferSource();r.buffer=a,r.loop=!0;const i=o.createGain();i.gain.value=e/100*O[t],r.connect(i).connect(o.destination),r.start(),setTimeout(()=>{try{r.stop()}catch{}try{o.close()}catch{}},3e3)}catch{}}var F="pomodoro_tasks",W="pomodoro_tasks_migrated";function j(){return Math.random().toString(36).slice(2,11)}function L(){/* @__PURE__ */
2
- return(new Date).toISOString()}var q=null,E=[],J=!1,Y=null,Z=/* @__PURE__ */new Set;function $(){for(const t of Z)t()}function z(t){E=t,$()}function H(){const t=q;return t?Y=t.list().then(e=>{q===t&&(E=e,J=!0,$())}).catch(()=>{q===t&&(J=!0,$())}).finally(()=>{Y=null}):(E=[],J=!0,$(),Promise.resolve())}function K(t){q=t,E=[],J=!1,t?H():$()}function Q(t){return Z.add(t),!q||J||Y||H(),()=>{Z.delete(t)}}function U(){return E}function X(){const t=function(){const{prefs:t,save:n}=e(),r=a(()=>{const e=t.todo_tasks;return Array.isArray(e)?e:[]},[t.todo_tasks]),i=o(t=>{n({todo_tasks:t})},[n]),c=o(t=>{const e=j(),n=L(),o={done:!1,...t,name:t.name.trim(),id:e,createdAt:n,updatedAt:n};return i([...r,o]),e},[r,i]),l=o((t,e)=>{i(r.map(n=>n.id===t?{...n,...e,id:n.id,updatedAt:L()}:n))},[r,i]),s=o(t=>{i(r.filter(e=>e.id!==t))},[r,i]),u=o(t=>{const e=r.find(e=>e.id===t);e&&l(t,{done:!e.done})},[r,l]);return{tasks:r,addTask:c,updateTask:l,removeTask:s,toggleDone:u,setAllTasks:i}}(),r=n(Q,U,U),i=o(e=>{const n=q;if(!n)return t.addTask(e);const o="tmp-"+j(),a=L(),r={done:!1,...e,name:e.name.trim(),id:o,createdAt:a,updatedAt:a};return z([...E,r]),n.create({...e,name:e.name.trim()}).then(t=>z(E.map(e=>e.id===o?{...r,...t}:e))).catch(()=>z(E.filter(t=>t.id!==o))),o},[t]),c=o((e,n)=>{const o=q;if(!o)return t.updateTask(e,n);z(E.map(t=>t.id===e?{...t,...n,id:e,updatedAt:L()}:t)),o.update(e,n).catch(()=>{H()})},[t]),l=o(e=>{const n=q;if(!n)return t.removeTask(e);const o=E;z(E.filter(t=>t.id!==e)),n.remove(e).catch(()=>z(o))},[t]),s=o(e=>{if(!q)return t.toggleDone(e);const n=E.find(t=>t.id===e);n&&c(e,{done:!n.done})},[t,c]),u=o(e=>{q||t.setAllTasks(e)},[t]);return null===q?t:{tasks:r,addTask:i,updateTask:c,removeTask:l,toggleDone:s,setAllTasks:u}}function tt(t,e){try{if(localStorage.getItem(W))return;const n=localStorage.getItem(F);if(!n)return void localStorage.setItem(W,"1");const o=JSON.parse(n);if(!Array.isArray(o)||0===o.length)return localStorage.removeItem(F),void localStorage.setItem(W,"1");const a=L(),r=o.filter(t=>"string"==typeof t?.name).map(t=>({id:t.id||j(),name:String(t.name),done:!!t.done,estimated:"number"==typeof t.estimated?t.estimated:void 0,completed:"number"==typeof t.completed?t.completed:void 0,createdAt:a,updatedAt:a})),i=new Set(t.map(t=>t.id));e([...r.filter(t=>!i.has(t.id)),...t]),localStorage.removeItem(F),localStorage.setItem(W,"1")}catch{try{localStorage.setItem(W,"1")}catch{}}}export{r as ALARM_OPTIONS,i as FOCUS_SOUND_OPTIONS,M as getPomoSnapshot,tt as migratePomodoroTasksOnce,N as playAlarm,x as pomoPause,I as pomoStart,B as pomoSwitchMode,R as previewFocusSound,y as setPomoAlarm,v as setPomoAlarmConfig,T as setPomoBehaviour,b as setPomoDurations,A as setPomoFocusSound,K as setShellTodoProvider,S as subscribePomo,X as useTodoTasks};
1
+ import{toast_default as t}from"./chunk-2CD2LZHH.js";import{useShellPrefs as e}from"./chunk-ODGCVNYP.js";import{useSyncExternalStore as n,useCallback as o,useMemo as a}from"react";var r=[{id:"bell",label:"Bell",description:"Soft bell with one harmonic"},{id:"chime",label:"Chime",description:"Two-note ascending chime"},{id:"bowl",label:"Singing Bowl",description:"Long-decay meditation tone"},{id:"wind-chimes",label:"Wind Chimes",description:"Four soft tones in succession"},{id:"off",label:"Off (silent)",description:"No sound — only desktop notification"}],i=[{id:"none",label:"None"},{id:"tick-fast",label:"Ticking Fast"},{id:"tick-slow",label:"Ticking Slow"},{id:"rain",label:"Rain"},{id:"fireplace",label:"Fireplace"},{id:"white",label:"White Noise"},{id:"pink",label:"Pink Noise"},{id:"brown",label:"Brown Noise"}],c=()=>`pomodoro-${/* @__PURE__ */(new Date).toISOString().slice(0,10)}`,l={focus:1500,short:300,long:900},s="bell",u=100,d=1,f="none",m=50,h={autoStartBreaks:!1,autoStartPomodoros:!1,longBreakInterval:4},g={running:!1,remaining:l.focus,mode:"focus",total:l.focus,streak:0,count:"undefined"!=typeof localStorage?(()=>{try{return parseInt(localStorage.getItem(c())||"0",10)||0}catch{return 0}})():0},p=null,k=/* @__PURE__ */new Set,w=t=>{g={...g,...t},k.forEach(t=>t())};function M(){return g}function S(t){return k.add(t),()=>{k.delete(t)}}function b(t){l=t,g.running||g.remaining!==g.total||w({remaining:t[g.mode],total:t[g.mode]})}function y(t){s=t}function v(t,e){u=Math.max(0,Math.min(100,Math.round(t))),d=Math.max(1,Math.min(5,Math.round(e)))}function T(t){h={autoStartBreaks:!!t.autoStartBreaks,autoStartPomodoros:!!t.autoStartPomodoros,longBreakInterval:Math.max(1,Math.min(20,Math.round(t.longBreakInterval||4)))}}function A(t,e){f=t,m=Math.max(0,Math.min(100,Math.round(e))),g.running&&"focus"===g.mode?(R(),G()):"none"!==t&&0!==m||R()}function I(){g.running||(w({running:!0}),p=setInterval(C,1e3),"focus"===g.mode&&G())}function x(){(g.running||null!==p)&&(null!==p&&(clearInterval(p),p=null),w({running:!1}),R())}function B(t){x(),w({mode:t,remaining:l[t],total:l[t]})}function C(){g.remaining<=1?function(){null!==p&&(clearInterval(p),p=null);R(),N(s,{volume:u,repeat:d});const e="focus"===g.mode?"Pomodoro complete — time for a break! 🍅":"Break's over — back to work!";if("undefined"!=typeof Notification&&"granted"===Notification.permission)try{new Notification(e)}catch{}try{t.info(e)}catch{}if("focus"===g.mode){const t=g.streak+1,e=g.count+1;(t=>{try{localStorage.setItem(c(),String(t))}catch{}})(e);const n=t%h.longBreakInterval===0?"long":"short";w({running:!1,streak:t,count:e,mode:n,remaining:l[n],total:l[n]}),h.autoStartBreaks&&setTimeout(()=>I(),50)}else w({running:!1,mode:"focus",remaining:l.focus,total:l.focus}),h.autoStartPomodoros&&setTimeout(()=>I(),50)}():w({remaining:g.remaining-1})}function N(t=s,e={}){if("off"===t)return;const n=Math.max(0,Math.min(100,e.volume??100))/100;if(0===n)return;const o=Math.max(1,Math.min(5,e.repeat??1));for(let e=0;e<o;e++)setTimeout(()=>P(t,n),2500*e)}function P(t,e){try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=(t,n,a,r=.22,i="sine")=>{const c=o.createOscillator(),l=o.createGain();c.connect(l),l.connect(o.destination),c.type=i,c.frequency.value=t;const s=o.currentTime+n;l.gain.setValueAtTime(0,s),l.gain.linearRampToValueAtTime(r*e,s+.03),l.gain.exponentialRampToValueAtTime(1e-4,s+a),c.start(s),c.stop(s+a)};let r=2;"bell"===t?(a(880,0,1.8),a(1320,0,1.4,.1),r=2):"chime"===t?(a(659.25,0,.7),a(880,.2,1.3),r=2):"bowl"===t?(a(440,0,3.4,.22),a(660,0,3,.08),a(880,.05,2.8,.05),r=4):"wind-chimes"===t&&(a(1175,0,1.1,.16),a(880,.15,1.3,.16),a(1318,.3,1.5,.16),a(1047,.5,1.7,.13),r=3),setTimeout(()=>{try{o.close()}catch{}},1e3*r+500)}catch{}}var D=null,O={none:0,white:.3,pink:.3,brown:.3,"tick-fast":.6,"tick-slow":.6,rain:.4,fireplace:.5};function _(t,e){if("none"===e)return null;const n=t.sampleRate,o="white"===e||"pink"===e||"brown"===e?2:4,a=n*o,r=t.createBuffer(1,a,n),i=r.getChannelData(0);if("white"===e)for(let t=0;t<a;t++)i[t]=.5*(2*Math.random()-1);else if("pink"===e){let t=0,e=0,n=0,o=0,r=0,c=0,l=0;for(let s=0;s<a;s++){const a=2*Math.random()-1;t=.99886*t+.0555179*a,e=.99332*e+.0750759*a,n=.969*n+.153852*a,o=.8665*o+.3104856*a,r=.55*r+.5329522*a,c=-.7616*c-.016898*a,i[s]=.11*(t+e+n+o+r+c+l+.5362*a)*.55,l=.115926*a}}else if("brown"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=3.5*t*.5}}else if("tick-fast"===e||"tick-slow"===e){const t="tick-fast"===e?.5:1,r=Math.floor(.045*n);for(let e=0;e<o;e+=t){const t=Math.floor(e*n);for(let e=0;e<r&&t+e<a;e++){const o=Math.exp(-e/n*180),a=2*Math.random()-1,r=Math.sin(2*Math.PI*1100*(e/n));i[t+e]+=(.7*a+.25*r)*o*.55}}}else if("rain"===e){let t=0;for(let e=0;e<a;e++){const o=2*Math.random()-1,a=o-.93*t;t=o;const r=.7+.3*Math.sin(e/n*2*Math.PI*.25);i[e]=a*r*.4}}else if("fireplace"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=1.6*t}let e=.4*Math.random()*n;for(;e<a;){const t=Math.floor((.012+.05*Math.random())*n),o=.35+.45*Math.random(),r=Math.floor(e);for(let e=0;e<t&&r+e<a;e++){const t=Math.exp(-e/n*90);i[r+e]+=(2*Math.random()-1)*t*o}e+=(.08+.62*Math.random())*n}}return r}function G(){if(!D&&"none"!==f&&0!==m)try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const e=new t,n=_(e,f);if(!n){try{e.close()}catch{}return}const o=e.createBufferSource();o.buffer=n,o.loop=!0;const a=e.createGain();a.gain.value=m/100*O[f],o.connect(a).connect(e.destination),o.start(),D={ctx:e,src:o,gain:a}}catch{}}function R(){if(D){try{D.src.stop()}catch{}try{D.ctx.close()}catch{}D=null}}function V(t,e){if("none"!==t&&0!==e)try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=_(o,t);if(!a){try{o.close()}catch{}return}const r=o.createBufferSource();r.buffer=a,r.loop=!0;const i=o.createGain();i.gain.value=e/100*O[t],r.connect(i).connect(o.destination),r.start(),setTimeout(()=>{try{r.stop()}catch{}try{o.close()}catch{}},3e3)}catch{}}var F="pomodoro_tasks",j="pomodoro_tasks_migrated";function H(){return Math.random().toString(36).slice(2,11)}function L(){/* @__PURE__ */
2
+ return(new Date).toISOString()}var W=null,q=[],E=!1,J=null,Y=/* @__PURE__ */new Set;function Z(){for(const t of Y)t()}function $(t){q=t,Z()}function z(){const t=W;return t?J=t.list().then(e=>{W===t&&(q=e,E=!0,Z())}).catch(()=>{W===t&&(E=!0,Z())}).finally(()=>{J=null}):(q=[],E=!0,Z(),Promise.resolve())}function K(t){W=t,q=[],E=!1,t?z():Z()}function Q(t){return Y.add(t),!W||E||J||z(),()=>{Y.delete(t)}}function U(){return q}function X(){const t=function(){const{prefs:t,save:n}=e(),r=a(()=>{const e=t.todo_tasks;return Array.isArray(e)?e:[]},[t.todo_tasks]),i=o(t=>{n({todo_tasks:t})},[n]),c=o(t=>{const e=H(),n=L(),o={done:!1,...t,name:t.name.trim(),id:e,createdAt:n,updatedAt:n};return i([...r,o]),e},[r,i]),l=o((t,e)=>{i(r.map(n=>n.id===t?{...n,...e,id:n.id,updatedAt:L()}:n))},[r,i]),s=o(t=>{i(r.filter(e=>e.id!==t))},[r,i]),u=o(t=>{const e=r.find(e=>e.id===t);e&&l(t,{done:!e.done})},[r,l]);return{tasks:r,addTask:c,updateTask:l,removeTask:s,toggleDone:u,setAllTasks:i}}(),r=n(Q,U,U),i=o(e=>{const n=W;if(!n)return t.addTask(e);const o="tmp-"+H(),a=L(),r={done:!1,...e,name:e.name.trim(),id:o,createdAt:a,updatedAt:a};return $([...q,r]),n.create({...e,name:e.name.trim()}).then(t=>$(q.map(e=>e.id===o?{...r,...t}:e))).catch(()=>$(q.filter(t=>t.id!==o))),o},[t]),c=o((e,n)=>{const o=W;if(!o)return t.updateTask(e,n);$(q.map(t=>t.id===e?{...t,...n,id:e,updatedAt:L()}:t)),o.update(e,n).catch(()=>{z()})},[t]),l=o(e=>{const n=W;if(!n)return t.removeTask(e);const o=q;$(q.filter(t=>t.id!==e)),n.remove(e).catch(()=>$(o))},[t]),s=o(e=>{if(!W)return t.toggleDone(e);const n=q.find(t=>t.id===e);n&&c(e,{done:!n.done})},[t,c]),u=o(e=>{W||t.setAllTasks(e)},[t]);return null===W?t:{tasks:r,addTask:i,updateTask:c,removeTask:l,toggleDone:s,setAllTasks:u}}function tt(t,e){try{if(localStorage.getItem(j))return;const n=localStorage.getItem(F);if(!n)return void localStorage.setItem(j,"1");const o=JSON.parse(n);if(!Array.isArray(o)||0===o.length)return localStorage.removeItem(F),void localStorage.setItem(j,"1");const a=L(),r=o.filter(t=>"string"==typeof t?.name).map(t=>({id:t.id||H(),name:String(t.name),done:!!t.done,estimated:"number"==typeof t.estimated?t.estimated:void 0,completed:"number"==typeof t.completed?t.completed:void 0,createdAt:a,updatedAt:a})),i=new Set(t.map(t=>t.id));e([...r.filter(t=>!i.has(t.id)),...t]),localStorage.removeItem(F),localStorage.setItem(j,"1")}catch{try{localStorage.setItem(j,"1")}catch{}}}export{r as ALARM_OPTIONS,i as FOCUS_SOUND_OPTIONS,M as getPomoSnapshot,tt as migratePomodoroTasksOnce,N as playAlarm,x as pomoPause,I as pomoStart,B as pomoSwitchMode,V as previewFocusSound,y as setPomoAlarm,v as setPomoAlarmConfig,T as setPomoBehaviour,b as setPomoDurations,A as setPomoFocusSound,K as setShellTodoProvider,S as subscribePomo,X as useTodoTasks};
@@ -1 +1 @@
1
- import{setPdfPreview as e}from"./chunk-ESL5TDNA.js";import{setSpreadsheetPreview as t}from"./chunk-VTVSMRFX.js";import{toast_default as n}from"./chunk-G6LV5Z2W.js";var i="react-os-shell:preview-opened";async function o(o){const{filePath:a,filename:r,kind:c,onStaged:s}=o;try{const o=await fetch(`${("undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000").replace(/\/$/,"")}/api/file?path=${encodeURIComponent(a)}`,{credentials:"include"});if(!o.ok)return n.error(`Download failed (${o.status})`),!1;const d=await o.blob();if("csv"===c){const e=await d.text();t({csv:e,filename:r}),s?.("/spreadsheet")}else{const t=URL.createObjectURL(d);e({url:t,filename:r,kind:c}),s?.("/preview")}return"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:{filePath:a,filename:r,kind:c}})),!0}catch(e){return n.error(e?.message||"Open failed"),!1}}export{i as PREVIEW_OPENED_EVENT,o as openPreviewFile};
1
+ import{setPdfPreview as e}from"./chunk-ESL5TDNA.js";import{setSpreadsheetPreview as t}from"./chunk-VTVSMRFX.js";import{toast_default as n}from"./chunk-2CD2LZHH.js";var i="react-os-shell:preview-opened";async function o(o){const{filePath:a,filename:r,kind:c,onStaged:s}=o;try{const o=await fetch(`${("undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000").replace(/\/$/,"")}/api/file?path=${encodeURIComponent(a)}`,{credentials:"include"});if(!o.ok)return n.error(`Download failed (${o.status})`),!1;const d=await o.blob();if("csv"===c){const e=await d.text();t({csv:e,filename:r}),s?.("/spreadsheet")}else{const t=URL.createObjectURL(d);e({url:t,filename:r,kind:c}),s?.("/preview")}return"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:{filePath:a,filename:r,kind:c}})),!0}catch(e){return n.error(e?.message||"Open failed"),!1}}export{i as PREVIEW_OPENED_EVENT,o as openPreviewFile};
@@ -0,0 +1 @@
1
+ var r="7.24.0",a=r;export{a as APP_VERSION,r as VERSION};
@@ -1,4 +1,4 @@
1
- import{useWindowMenuItem as e,Modal as t}from"./chunk-D5CGXUQK.js";import{navIcons as r}from"./chunk-DSSLOQDW.js";import{VERSION as s}from"./chunk-43KURNHH.js";import{DEFAULT_SHELL_STRINGS as o,useShellStrings as n,splitAround as i}from"./chunk-BSCGC2HA.js";import{Icon as a}from"./chunk-B427NVDP.js";import{useState as m,useCallback as c,isValidElement as l,cloneElement as d}from"react";import{jsx as p,jsxs as h}from"react/jsx-runtime";var u=o.aboutApp,f={spreadsheet:{name:"Spreadsheets",version:"1.1.3",route:"/spreadsheet",description:u.spreadsheet},notepad:{name:"Notepad",version:"1.0.2",route:"/notepad",description:u.notepad},documents:{name:"Documents",version:"1.1.1",route:"/documents",description:u.documents},preview:{name:"Preview",version:"1.4.3",route:"/preview",description:u.preview},files:{name:"Files",version:"1.1.3",route:"/files",description:u.files},browser:{name:"Browser",version:"1.0.2",route:"/browser",description:u.browser}},x=/* @__PURE__ */p(a,{name:"info",className:"h-4 w-4",strokeWidth:1.5}),v=/* @__PURE__ */p(a,{name:"window",className:"h-9 w-9",strokeWidth:1.5});function w({app:o}){const a=f[o],[u,w]=m(!1),N=c(()=>w(!0),[]),g=n().aboutApp,b=g.title(a.name);if(e(b,N,x),!u)return null;const y=r[a.route],k=l(y)?d(y,{className:"h-9 w-9"}):v,[j,D]=i(g.partOf);/* @__PURE__ */
1
+ import{useWindowMenuItem as e,Modal as t}from"./chunk-D5CGXUQK.js";import{navIcons as r}from"./chunk-DSSLOQDW.js";import{VERSION as s}from"./chunk-LVCFIIAB.js";import{DEFAULT_SHELL_STRINGS as o,useShellStrings as n,splitAround as i}from"./chunk-BSCGC2HA.js";import{Icon as a}from"./chunk-B427NVDP.js";import{useState as m,useCallback as c,isValidElement as l,cloneElement as d}from"react";import{jsx as p,jsxs as h}from"react/jsx-runtime";var u=o.aboutApp,f={spreadsheet:{name:"Spreadsheets",version:"1.1.3",route:"/spreadsheet",description:u.spreadsheet},notepad:{name:"Notepad",version:"1.0.2",route:"/notepad",description:u.notepad},documents:{name:"Documents",version:"1.1.1",route:"/documents",description:u.documents},preview:{name:"Preview",version:"1.4.3",route:"/preview",description:u.preview},files:{name:"Files",version:"1.1.3",route:"/files",description:u.files},browser:{name:"Browser",version:"1.0.2",route:"/browser",description:u.browser}},x=/* @__PURE__ */p(a,{name:"info",className:"h-4 w-4",strokeWidth:1.5}),v=/* @__PURE__ */p(a,{name:"window",className:"h-9 w-9",strokeWidth:1.5});function w({app:o}){const a=f[o],[u,w]=m(!1),N=c(()=>w(!0),[]),g=n().aboutApp,b=g.title(a.name);if(e(b,N,x),!u)return null;const y=r[a.route],k=l(y)?d(y,{className:"h-9 w-9"}):v,[j,C]=i(g.partOf);/* @__PURE__ */
2
2
  return p(t,{open:!0,onClose:()=>w(!1),title:b,size:"sm",compact:!0,bodyScroll:!1,autoHeight:!0,dimensions:[320,320],children:/* @__PURE__ */h("div",{className:"flex flex-col items-center text-center px-5 pt-5 pb-4",children:[
3
3
  /* @__PURE__ */p("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-gray-100 text-gray-600 shrink-0",children:k}),
4
4
  /* @__PURE__ */p("h2",{className:"mt-3 text-lg font-bold text-gray-900",children:a.name}),
@@ -6,4 +6,4 @@ return p(t,{open:!0,onClose:()=>w(!1),title:b,size:"sm",compact:!0,bodyScroll:!1
6
6
  /* @__PURE__ */p("p",{className:"mt-2 text-xs text-gray-500 leading-relaxed",children:g[o]}),
7
7
  /* @__PURE__ */h("div",{className:"mt-4 pt-3 border-t border-gray-200 w-full",children:[
8
8
  /* @__PURE__ */h("p",{className:"text-2xs text-gray-500",children:[j,
9
- /* @__PURE__ */p("span",{className:"font-medium text-gray-700",children:"efficient-shell"}),D]}),s&&/* @__PURE__ */p("p",{className:"mt-0.5 text-2xs font-mono text-gray-400",children:g.shellVersion(s)})]})]})})}export{w as AboutApp,f as BUILTIN_APP_INFO};
9
+ /* @__PURE__ */p("span",{className:"font-medium text-gray-700",children:"efficient-shell"}),C]}),s&&/* @__PURE__ */p("p",{className:"mt-0.5 text-2xs font-mono text-gray-400",children:g.shellVersion(s)})]})]})})}export{w as AboutApp,f as BUILTIN_APP_INFO};
@@ -1,23 +1,23 @@
1
- import{toast_default as e}from"./chunk-G6LV5Z2W.js";import{LoadingSpinner as t}from"./chunk-NVFKXL52.js";import{useShellStrings as n}from"./chunk-BSCGC2HA.js";import{Icon as r}from"./chunk-B427NVDP.js";import{createContext as a,useContext as o,useRef as i,useState as s,useEffect as l}from"react";import*as c from"pdfjs-dist";import{createPortal as d}from"react-dom";import{jsx as u,jsxs as m}from"react/jsx-runtime";function h(e,t,n){return new Error(`The response for ${e} is not a WebAssembly module (got ${function(e){if(0===e.length)return"an empty response";const t=Array.from(e.subarray(0,24)).map(e=>e>=32&&e<127?String.fromCharCode(e):".").join("");return`${e.length} bytes starting "${t}"`}(n)}). The bundler did not emit "${t}" as an asset, and the host answered with a fallback page instead of a 404. Serve pdfjs-dist/wasm/ yourself and point window.__REACT_OS_SHELL_PDF_WASM__ at it.`)}var p=a(null);function f({children:e}){const t=o(p);return t?d(e,t):
2
- /* @__PURE__ */u("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs",children:e})}"undefined"==typeof window||c.GlobalWorkerOptions.workerSrc||(c.GlobalWorkerOptions.workerSrc=`https://unpkg.com/pdfjs-dist@${c.version}/build/pdf.worker.min.mjs`);var g={"jbig2.wasm":new URL("pdfjs-dist/wasm/jbig2.wasm",import.meta.url).href,"openjpeg.wasm":new URL("pdfjs-dist/wasm/openjpeg.wasm",import.meta.url).href},w=class{async fetch({kind:e,filename:t}){if("wasmUrl"!==e)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const n=g[t];if(!n)throw new Error(`No bundled pdf.js wasm module for "${t}".`);const r=await fetch(n);if(!r.ok)throw new Error(`Unable to load wasm data at: ${n}`);const a=new Uint8Array(await r.arrayBuffer());if(!function(e){return e.length>=4&&0===e[0]&&97===e[1]&&115===e[2]&&109===e[3]}(a))throw h(n,t,a);return a}};function y(e){const t=e||("undefined"!=typeof window?window.__REACT_OS_SHELL_PDF_WASM__:void 0);return"string"==typeof t&&t?{wasmUrl:t.endsWith("/")?t:`${t}/`}:{BinaryDataFactory:w}}var v=[50,75,100,125,150,200,300,400];function b(e,t,n){const r=(t.width-40)/n.width,a="page"===e?Math.min(r,(t.height-40)/n.height):r;return Math.min(Math.max(a,.3),4)}function x({url:a,filename:o,fit:d="width",onDownload:h,onEmail:p,workerSrc:g,wasmUrl:w}){const x=n().pdf,k=i(null),C=i(null),N=i(null),[j,M]=s(null),[E,z]=s(1),[P,_]=s(0),[D,L]=s(1),[W,S]=s(!0),[$,A]=s(!0),T=i(x.loadFailed);T.current=x.loadFailed,l(()=>{let t=!1;return A(!0),z(1),g&&(c.GlobalWorkerOptions.workerSrc=g),c.getDocument({url:a,...y(w)}).promise.then(e=>{t||(M(e),_(e.numPages),A(!1))}).catch(()=>{t||(e.error(T.current),A(!1))}),()=>{t=!0}},[a,g,w]),l(()=>{if(!j||!W||!N.current)return;const e=()=>{const e=N.current;e&&j.getPage(E).then(t=>{if(!N.current)return;const n=t.getViewport({scale:1}),r=b(d,{width:e.clientWidth,height:e.clientHeight},{width:n.width,height:n.height});L(e=>Math.abs(e-r)<.005?e:r)})};e();const t=new ResizeObserver(e);return t.observe(N.current),()=>t.disconnect()},[j,E,W,d]),l(()=>{if(!j||!k.current)return;let e=!1,t=null,n=null;return j.getPage(E).then(r=>{if(e||!k.current)return;const a=r.getViewport({scale:D}),o=k.current;o.width=a.width,o.height=a.height,o.style.width=`${a.width}px`,o.style.height=`${a.height}px`;const i=o.getContext("2d");t=r.render({canvas:o,canvasContext:i,viewport:a}),t.promise.catch(()=>{});const s=C.current;s&&(s.replaceChildren(),s.style.setProperty("--total-scale-factor",String(a.scale)),n=new c.TextLayer({textContentSource:r.streamTextContent(),container:s,viewport:a}),n.render().then(()=>{if(e)return;const t=document.createElement("div");t.className="endOfContent",s.append(t)}).catch(()=>{}))}),()=>{e=!0,t?.cancel(),n?.cancel()}},[j,E,D]),l(()=>{const e=()=>C.current?.classList.remove("selecting");return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]);const O="page"===d?x.fitPage:x.fitWidth,H="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1";/* @__PURE__ */
1
+ import{toast_default as e}from"./chunk-2CD2LZHH.js";import{LoadingSpinner as t}from"./chunk-NVFKXL52.js";import{useShellStrings as n}from"./chunk-BSCGC2HA.js";import{Icon as r}from"./chunk-B427NVDP.js";import{createContext as a,useContext as o,useRef as i,useState as s,useEffect as l}from"react";import*as c from"pdfjs-dist";import{createPortal as d}from"react-dom";import{jsx as u,jsxs as m}from"react/jsx-runtime";function h(e,t,n){return new Error(`The response for ${e} is not a WebAssembly module (got ${function(e){if(0===e.length)return"an empty response";const t=Array.from(e.subarray(0,24)).map(e=>e>=32&&e<127?String.fromCharCode(e):".").join("");return`${e.length} bytes starting "${t}"`}(n)}). The bundler did not emit "${t}" as an asset, and the host answered with a fallback page instead of a 404. Serve pdfjs-dist/wasm/ yourself and point window.__REACT_OS_SHELL_PDF_WASM__ at it.`)}var p=a(null);function f({children:e}){const t=o(p);return t?d(e,t):
2
+ /* @__PURE__ */u("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs",children:e})}"undefined"==typeof window||c.GlobalWorkerOptions.workerSrc||(c.GlobalWorkerOptions.workerSrc=`https://unpkg.com/pdfjs-dist@${c.version}/build/pdf.worker.min.mjs`);var g={"jbig2.wasm":new URL("pdfjs-dist/wasm/jbig2.wasm",import.meta.url).href,"openjpeg.wasm":new URL("pdfjs-dist/wasm/openjpeg.wasm",import.meta.url).href},w=class{async fetch({kind:e,filename:t}){if("wasmUrl"!==e)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const n=g[t];if(!n)throw new Error(`No bundled pdf.js wasm module for "${t}".`);const r=await fetch(n);if(!r.ok)throw new Error(`Unable to load wasm data at: ${n}`);const a=new Uint8Array(await r.arrayBuffer());if(!function(e){return e.length>=4&&0===e[0]&&97===e[1]&&115===e[2]&&109===e[3]}(a))throw h(n,t,a);return a}};function y(e){const t=e||("undefined"!=typeof window?window.__REACT_OS_SHELL_PDF_WASM__:void 0);return"string"==typeof t&&t?{wasmUrl:t.endsWith("/")?t:`${t}/`}:{BinaryDataFactory:w}}var v=[50,75,100,125,150,200,300,400];function b(e,t,n){const r=(t.width-40)/n.width,a="page"===e?Math.min(r,(t.height-40)/n.height):r;return Math.min(Math.max(a,.3),4)}function x({url:a,filename:o,fit:d="width",onDownload:h,onEmail:p,workerSrc:g,wasmUrl:w}){const x=n().pdf,k=i(null),C=i(null),N=i(null),[j,M]=s(null),[E,z]=s(1),[D,P]=s(0),[_,L]=s(1),[S,W]=s(!0),[$,A]=s(!0),T=i(x.loadFailed);T.current=x.loadFailed,l(()=>{let t=!1;return A(!0),z(1),g&&(c.GlobalWorkerOptions.workerSrc=g),c.getDocument({url:a,...y(w)}).promise.then(e=>{t||(M(e),P(e.numPages),A(!1))}).catch(()=>{t||(e.error(T.current),A(!1))}),()=>{t=!0}},[a,g,w]),l(()=>{if(!j||!S||!N.current)return;const e=()=>{const e=N.current;e&&j.getPage(E).then(t=>{if(!N.current)return;const n=t.getViewport({scale:1}),r=b(d,{width:e.clientWidth,height:e.clientHeight},{width:n.width,height:n.height});L(e=>Math.abs(e-r)<.005?e:r)})};e();const t=new ResizeObserver(e);return t.observe(N.current),()=>t.disconnect()},[j,E,S,d]),l(()=>{if(!j||!k.current)return;let e=!1,t=null,n=null;return j.getPage(E).then(r=>{if(e||!k.current)return;const a=r.getViewport({scale:_}),o=k.current;o.width=a.width,o.height=a.height,o.style.width=`${a.width}px`,o.style.height=`${a.height}px`;const i=o.getContext("2d");t=r.render({canvas:o,canvasContext:i,viewport:a}),t.promise.catch(()=>{});const s=C.current;s&&(s.replaceChildren(),s.style.setProperty("--total-scale-factor",String(a.scale)),n=new c.TextLayer({textContentSource:r.streamTextContent(),container:s,viewport:a}),n.render().then(()=>{if(e)return;const t=document.createElement("div");t.className="endOfContent",s.append(t)}).catch(()=>{}))}),()=>{e=!0,t?.cancel(),n?.cancel()}},[j,E,_]),l(()=>{const e=()=>C.current?.classList.remove("selecting");return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]);const O="page"===d?x.fitPage:x.fitWidth,H="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1";/* @__PURE__ */
3
3
  return m("div",{className:"flex flex-col h-full",children:[
4
4
  /* @__PURE__ */m(f,{children:[
5
5
  /* @__PURE__ */u("button",{type:"button","aria-label":x.previousPage,onClick:()=>z(e=>Math.max(1,e-1)),disabled:E<=1,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */u(r,{name:"chevron-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
6
- /* @__PURE__ */u("span",{className:"text-gray-600 font-medium tabular-nums whitespace-nowrap",children:x.pageOf(E,P)}),
7
- /* @__PURE__ */u("button",{type:"button","aria-label":x.nextPage,onClick:()=>z(e=>Math.min(P,e+1)),disabled:E>=P,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */u(r,{name:"chevron-right",className:"h-3.5 w-3.5",strokeWidth:2})}),
6
+ /* @__PURE__ */u("span",{className:"text-gray-600 font-medium tabular-nums whitespace-nowrap",children:x.pageOf(E,D)}),
7
+ /* @__PURE__ */u("button",{type:"button","aria-label":x.nextPage,onClick:()=>z(e=>Math.min(D,e+1)),disabled:E>=D,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */u(r,{name:"chevron-right",className:"h-3.5 w-3.5",strokeWidth:2})}),
8
8
  /* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
9
- /* @__PURE__ */u("button",{type:"button","aria-label":x.zoomOut,title:x.zoomOut,onClick:()=>{S(!1),L(e=>Math.max(.3,Math.round(100*(e-.25))/100))},className:H,children:/* @__PURE__ */u("span",{"aria-hidden":"true",children:"−"})}),
10
- /* @__PURE__ */m("select",{value:W?"fit":v.includes(Math.round(100*D))?Math.round(100*D):"custom",onChange:e=>{const t=e.target.value;"fit"!==t?"custom"!==t&&(S(!1),L(Number(t)/100)):S(!0)},className:"bg-transparent hover:bg-gray-200 rounded px-1 py-1 text-gray-600 tabular-nums cursor-pointer focus:outline-none focus:ring-1 focus:ring-blue-400","aria-label":x.zoom,title:x.zoom,children:[
11
- /* @__PURE__ */u("option",{value:"fit",children:O}),!W&&!v.includes(Math.round(100*D))&&/* @__PURE__ */m("option",{value:"custom",children:[Math.round(100*D),"%"]}),v.map(e=>/* @__PURE__ */m("option",{value:e,children:[e,"%"]},e))]}),
12
- /* @__PURE__ */u("button",{type:"button","aria-label":x.zoomIn,title:x.zoomIn,onClick:()=>{S(!1),L(e=>Math.min(4,Math.round(100*(e+.25))/100))},className:H,children:/* @__PURE__ */u("span",{"aria-hidden":"true",children:"+"})}),
13
- /* @__PURE__ */u("button",{type:"button",onClick:()=>S(!0),"aria-pressed":W,className:H+(W?" bg-gray-200 text-gray-900":""),title:x.fitHint,children:x.fit}),
9
+ /* @__PURE__ */u("button",{type:"button","aria-label":x.zoomOut,title:x.zoomOut,onClick:()=>{W(!1),L(e=>Math.max(.3,Math.round(100*(e-.25))/100))},className:H,children:/* @__PURE__ */u("span",{"aria-hidden":"true",children:"−"})}),
10
+ /* @__PURE__ */m("select",{value:S?"fit":v.includes(Math.round(100*_))?Math.round(100*_):"custom",onChange:e=>{const t=e.target.value;"fit"!==t?"custom"!==t&&(W(!1),L(Number(t)/100)):W(!0)},className:"bg-transparent hover:bg-gray-200 rounded px-1 py-1 text-gray-600 tabular-nums cursor-pointer focus:outline-none focus:ring-1 focus:ring-blue-400","aria-label":x.zoom,title:x.zoom,children:[
11
+ /* @__PURE__ */u("option",{value:"fit",children:O}),!S&&!v.includes(Math.round(100*_))&&/* @__PURE__ */m("option",{value:"custom",children:[Math.round(100*_),"%"]}),v.map(e=>/* @__PURE__ */m("option",{value:e,children:[e,"%"]},e))]}),
12
+ /* @__PURE__ */u("button",{type:"button","aria-label":x.zoomIn,title:x.zoomIn,onClick:()=>{W(!1),L(e=>Math.min(4,Math.round(100*(e+.25))/100))},className:H,children:/* @__PURE__ */u("span",{"aria-hidden":"true",children:"+"})}),
13
+ /* @__PURE__ */u("button",{type:"button",onClick:()=>W(!0),"aria-pressed":S,className:H+(S?" bg-gray-200 text-gray-900":""),title:x.fitHint,children:x.fit}),
14
14
  /* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
15
- /* @__PURE__ */m("button",{type:"button",onClick:()=>{if(!j)return;const t=window.open("","_blank");if(!t)return void e.error(x.allowPopups);const n=[];for(let e=1;e<=P;e++)n.push(j.getPage(e).then(e=>{const t=e.getViewport({scale:2}),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,e.render({canvas:n,canvasContext:n.getContext("2d"),viewport:t}).promise.then(()=>n.toDataURL())}));Promise.all(n).then(e=>{var n;t.document.write(`<html><head><title>${n=o,n.replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[e]))}</title><style>@media print{body{margin:0}img{width:100%;page-break-after:always}}</style></head><body>`),t.document.write(e.map(e=>`<img src="${e}"/>`).join("")),t.document.write("</body></html>"),t.document.close(),setTimeout(()=>{t.print(),t.close()},300)})},className:H,children:[
15
+ /* @__PURE__ */m("button",{type:"button",onClick:()=>{if(!j)return;const t=window.open("","_blank");if(!t)return void e.error(x.allowPopups);const n=[];for(let e=1;e<=D;e++)n.push(j.getPage(e).then(e=>{const t=e.getViewport({scale:2}),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,e.render({canvas:n,canvasContext:n.getContext("2d"),viewport:t}).promise.then(()=>n.toDataURL())}));Promise.all(n).then(e=>{var n;t.document.write(`<html><head><title>${n=o,n.replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[e]))}</title><style>@media print{body{margin:0}img{width:100%;page-break-after:always}}</style></head><body>`),t.document.write(e.map(e=>`<img src="${e}"/>`).join("")),t.document.write("</body></html>"),t.document.close(),setTimeout(()=>{t.print(),t.close()},300)})},className:H,children:[
16
16
  /* @__PURE__ */u(r,{name:"print",className:"h-3.5 w-3.5",strokeWidth:1.5}),x.print]}),
17
17
  /* @__PURE__ */m("button",{type:"button",onClick:h??(()=>{const e=document.createElement("a");e.href=a,e.download=o,e.click()}),className:H,children:[
18
18
  /* @__PURE__ */u(r,{name:"download",className:"h-3.5 w-3.5",strokeWidth:1.5}),x.download]}),p&&/* @__PURE__ */m("button",{type:"button",onClick:p,className:H,children:[
19
19
  /* @__PURE__ */u(r,{name:"email",className:"h-3.5 w-3.5",strokeWidth:1.5}),x.email]})]}),
20
- /* @__PURE__ */u("div",{ref:N,className:"flex-1 overflow-auto bg-gray-100 outline-none",tabIndex:0,onWheel:e=>{if(!j)return;if(e.ctrlKey||e.metaKey)return;const t=N.current;if(!t)return;const n=t.scrollTop<=0,r=t.scrollTop+t.clientHeight>=t.scrollHeight-1;e.deltaY>0&&r&&E<P?(e.preventDefault(),z(e=>Math.min(P,e+1)),requestAnimationFrame(()=>{N.current&&(N.current.scrollTop=0)})):e.deltaY<0&&n&&E>1&&(e.preventDefault(),z(e=>Math.max(1,e-1)),requestAnimationFrame(()=>{N.current&&(N.current.scrollTop=N.current.scrollHeight)}))},onKeyDown:e=>{if(!j)return;const t=(document.activeElement?.tagName||"").toLowerCase();"input"===t||"textarea"===t||document.activeElement?.isContentEditable||("PageDown"===e.key||"ArrowRight"===e.key?E<P&&(e.preventDefault(),z(e=>Math.min(P,e+1))):"PageUp"===e.key||"ArrowLeft"===e.key?E>1&&(e.preventDefault(),z(e=>Math.max(1,e-1))):"Home"===e.key?(e.preventDefault(),z(1)):"End"===e.key&&(e.preventDefault(),z(P)))},children:$?/* @__PURE__ */u(t,{size:"sm",padding:"",className:"h-full",label:x.loading}):/* @__PURE__ */m("div",{className:"min-h-full flex items-center justify-center p-4",children:[
20
+ /* @__PURE__ */u("div",{ref:N,className:"flex-1 overflow-auto bg-gray-100 outline-none",tabIndex:0,onWheel:e=>{if(!j)return;if(e.ctrlKey||e.metaKey)return;const t=N.current;if(!t)return;const n=t.scrollTop<=0,r=t.scrollTop+t.clientHeight>=t.scrollHeight-1;e.deltaY>0&&r&&E<D?(e.preventDefault(),z(e=>Math.min(D,e+1)),requestAnimationFrame(()=>{N.current&&(N.current.scrollTop=0)})):e.deltaY<0&&n&&E>1&&(e.preventDefault(),z(e=>Math.max(1,e-1)),requestAnimationFrame(()=>{N.current&&(N.current.scrollTop=N.current.scrollHeight)}))},onKeyDown:e=>{if(!j)return;const t=(document.activeElement?.tagName||"").toLowerCase();"input"===t||"textarea"===t||document.activeElement?.isContentEditable||("PageDown"===e.key||"ArrowRight"===e.key?E<D&&(e.preventDefault(),z(e=>Math.min(D,e+1))):"PageUp"===e.key||"ArrowLeft"===e.key?E>1&&(e.preventDefault(),z(e=>Math.max(1,e-1))):"Home"===e.key?(e.preventDefault(),z(1)):"End"===e.key&&(e.preventDefault(),z(D)))},children:$?/* @__PURE__ */u(t,{size:"sm",padding:"",className:"h-full",label:x.loading}):/* @__PURE__ */m("div",{className:"min-h-full flex items-center justify-center p-4",children:[
21
21
  /* @__PURE__ */u("style",{children:'\n.preview-pdf-textlayer {\n position: absolute;\n inset: 0;\n overflow: clip;\n line-height: 1;\n text-align: initial;\n text-size-adjust: none;\n forced-color-adjust: none;\n transform-origin: 0 0;\n caret-color: CanvasText;\n --min-font-size: 1;\n --text-scale-factor: calc(var(--total-scale-factor, 1) * var(--min-font-size));\n --min-font-size-inv: calc(1 / var(--min-font-size));\n}\n.preview-pdf-textlayer :is(span, br) {\n color: transparent;\n position: absolute;\n white-space: pre;\n cursor: text;\n transform-origin: 0% 0%;\n}\n.preview-pdf-textlayer > :not(.markedContent),\n.preview-pdf-textlayer .markedContent span:not(.markedContent) {\n z-index: 1;\n --font-height: 0;\n font-size: calc(var(--text-scale-factor) * var(--font-height));\n --scale-x: 1;\n --rotate: 0deg;\n transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));\n}\n.preview-pdf-textlayer .markedContent {\n display: contents;\n}\n.preview-pdf-textlayer span[role="img"] {\n user-select: none;\n cursor: default;\n}\n.preview-pdf-textlayer ::selection {\n background: rgba(0, 80, 255, 0.25);\n}\n.preview-pdf-textlayer br::selection {\n background: transparent;\n}\n.preview-pdf-textlayer .endOfContent {\n display: block;\n position: absolute;\n inset: 100% 0 0;\n z-index: 0;\n cursor: default;\n user-select: none;\n}\n.preview-pdf-textlayer.selecting .endOfContent {\n top: 0;\n}\n'}),
22
22
  /* @__PURE__ */m("div",{className:"relative shadow-lg rounded",children:[
23
23
  /* @__PURE__ */u("canvas",{ref:k,className:"block rounded"}),