efficient-shell 8.31.0 → 8.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ai/index.js CHANGED
@@ -1,38 +1,39 @@
1
1
  "use client";
2
2
  import{StepChain as e,StepChainItem as t}from"../chunk-SAKHGHF5.js";import{Markdown as n}from"../chunk-37JDUDCO.js";import{Textarea_default as r}from"../chunk-AWY3F6PV.js";import"../chunk-UJUTS6LJ.js";import"../chunk-PJPK2ADX.js";import{useContextMenu as o,ContextMenu as a}from"../chunk-AX7KPMDV.js";import{Banner as s}from"../chunk-WTY3SXO7.js";import"../chunk-B55IXYDR.js";import{IconButton_default as l}from"../chunk-4CANQ3B3.js";import"../chunk-JFSYWEHD.js";import{parseChartSpec as i}from"../chunk-CR7T435F.js";import{SpecChart as c}from"../chunk-TFMC2WAS.js";import"../chunk-X2S2XDZI.js";import"../chunk-5OTS2G3M.js";import"../chunk-36BRD5J3.js";import"../chunk-OSA24YH6.js";import"../chunk-CK2YOGUS.js";import"../chunk-BRHIRE4D.js";import"../chunk-VFC6QUEN.js";import"../chunk-W5M6P4DZ.js";import"../chunk-465RRWBY.js";import{ChartSkeleton as u}from"../chunk-Y4MI6NRI.js";import"../chunk-CNYAHYE6.js";import"../chunk-PJCVNFWM.js";import"../chunk-QR4RM7PO.js";import"../chunk-5QFPTDQF.js";import{Button_default as p}from"../chunk-4IU5BSVE.js";import"../chunk-K7U4RWXJ.js";import"../chunk-VH6GB73Q.js";import{Icon as d}from"../chunk-KIBL6M3T.js";import"../chunk-J75ZT2JQ.js";import{SpinnerRing as m}from"../chunk-Q5MD3VY6.js";import"../chunk-MRJKZWWV.js";import"../chunk-6KO5VTL7.js";import"../chunk-22S6LG6D.js";import"../chunk-PGN5ME7B.js";import"../chunk-62LW225J.js";import"../chunk-GLUJS42B.js";import"../chunk-D65T4H6J.js";import"../chunk-P5BOTIJU.js";import"../chunk-DTJRIWFR.js";import"../chunk-RSO67DWS.js";import"../chunk-MG7A3R75.js";import"../chunk-2JWPNR2U.js";import"../chunk-MAFUXCPZ.js";import"../chunk-TWVUQUUD.js";import"../chunk-EYKUKN32.js";import"../chunk-TZFACUMR.js";import"../chunk-E6UCGCOC.js";import"../chunk-C3QOHMR6.js";import{useRef as h,useState as g,useEffect as f,useId as v,useCallback as b,useMemo as y}from"react";import{jsx as k,jsxs as w}from"react/jsx-runtime";import{isToolUIPart as x,getToolName as N,DefaultChatTransport as C,lastAssistantMessageIsCompleteWithApprovalResponses as j}from"ai";import{useChat as A}from"@ai-sdk/react";function S({labels:e,placeholder:t,busy:n,focusWhen:o,onSend:a,onStop:s,onNewChat:i,actions:c}){const[u,m]=g(""),v=h(null);f(()=>{o&&v.current?.focus()},[o]);const b=()=>{!n&&u.trim()&&(a(u),m(""))};/* @__PURE__ */
3
3
  return w("form",{className:"flex items-end gap-2 border-t border-gray-200 p-3",onSubmit:e=>{e.preventDefault(),b()},children:[i&&/* @__PURE__ */k(l,{type:"button",variant:"ghost","aria-label":e.newChat,title:e.newChat,onClick:i,children:/* @__PURE__ */k(d,{name:"add"})}),
4
- /* @__PURE__ */k("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */k(r,{ref:v,"aria-label":e.inputLabel,placeholder:t,rows:1,autoGrow:!0,value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),b())},className:"max-h-32"})}),c?.map(e=>e.icon?/* @__PURE__ */k(l,{type:"button",variant:"ghost","aria-label":e.label,title:e.label,disabled:!u.trim(),onClick:()=>e.onSelect(u.trim()),children:/* @__PURE__ */k(d,{name:e.icon})},e.key):/* @__PURE__ */k(p,{type:"button",variant:"ghost",disabled:!u.trim(),onClick:()=>e.onSelect(u.trim()),children:e.label},e.key)),/* @__PURE__ */k(p,n?{type:"button",variant:"secondary",onClick:s,children:e.stop}:{type:"submit",disabled:!u.trim(),children:e.send})]})}function $(e){if(!x(e))return null;const t=e;return{toolName:N(e),toolCallId:t.toolCallId,state:t.state,input:t.input,output:t.output,errorText:t.errorText,approvalId:t.approval?.id,approved:t.approval?.approved}}function T(e){const t=/* @__PURE__ */new Map;for(const n of e.parts){if("data-tool-summary"!==n.type)continue;const e=n.data;e&&"string"==typeof e.tool_call_id&&Array.isArray(e.rows)&&e.rows.length>0&&t.set(e.tool_call_id,e)}return t}function _(e){return e.parts.map(e=>"text"===e.type?e.text:"").join("")}function I(e,t){const n=e[e.length-1];if(!n)throw new Error("assistant chat: no message to send");if("user"===n.role){const e=_(n).trim();if(!e)throw new Error("assistant chat: empty message");return{conversation_id:t,text:e,approvals:[]}}const r=function(e){const t=[];for(const n of e.parts){if(!x(n))continue;const e=n;if("approval-responded"!==e.state||!e.approval||"boolean"!=typeof e.approval.approved)continue;const r={approval_id:e.approval.id,approved:e.approval.approved};e.approval.reason&&(r.reason=e.approval.reason),t.push(r)}return t}(n);if(0===r.length)throw new Error("assistant chat: no approval decision to send");return{conversation_id:t,text:null,approvals:r}}var R=/* @__PURE__ */new Set(["proposed","approved","running"]);function M(e){return R.has(e.status)}function O(e){const t=[];for(const n of e.parts)"data-plan"===n.type&&t.push(n.data);return t}function D(e){const t=/* @__PURE__ */new Map;for(const n of e)for(const e of O(n))t.delete(e.id),t.set(e.id,e);return t}function L(e){const t=[...D(e).values()],n=t[t.length-1];if(!n)return null;if(M(n))return n;const r=e[e.length-1];return r&&"assistant"===r.role&&O(r).some(e=>e.id===n.id)?n:null}function U(e){const t=e.messages.filter(e=>e.text).map(e=>({id:e.id,role:e.role,parts:[{type:"text",text:e.text}],...e.source&&e.source!==e.role?{metadata:{source:e.source}}:{}})),n=(e.plans??[]).filter(M);return(e.pending_approvals.length>0||n.length>0)&&t.push({id:`pending-approvals-${e.id}`,role:"assistant",parts:[...n.map(e=>({type:"data-plan",id:e.id,data:e})),...e.pending_approvals.map(e=>({type:`tool-${e.tool_name}`,toolCallId:e.tool_call_id??e.approval_id,state:"approval-requested",input:e.input,approval:{id:e.approval_id}}))]}),t}function E(e,t){const n=e?.message?.trim();if(!n)return t;if(n.startsWith("{")){try{const e=JSON.parse(n);for(const t of["detail","errorText","message","title","error"]){const n=e[t];if("string"==typeof n&&n.trim())return n.trim()}}catch{return t}return t}return n.startsWith("<")||n.length>400?t:n}function J(e){const t=e.replace(/^tool-/,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-.]+/g," ").trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}var P={propose_plan:{label:"Plan the changes",running:"Planning the changes",done:"Planned the changes"}};function W(e,t){const n=t?.[e]??P[e];return"string"==typeof n?{label:n}:n??{label:J(e)}}function F(e,t){return W(e,t).label}function B(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function H(e,t,n){const r=W(e,n).describe;if(!r)return"";try{return r(B(t))?.trim()??""}catch{return""}}function z(e,t){return null==e?"":"boolean"==typeof e?e?"Yes":"No":"object"!=typeof e?String(e):Array.isArray(e)?e.map(e=>z(e,t+1)).filter(Boolean).join(", "):t>=3?"…":Object.entries(e).map(([e,n])=>{const r=z(n,t+1);return r?`${J(e)}: ${r}`:""}).filter(Boolean).join("; ")}function K(e){const t=B(e),n=[];for(const[e,r]of Object.entries(t)){const t=z(r,0);t&&n.push({label:J(e),value:t})}return 0===n.length&&null!=e&&"object"!=typeof e&&n.push({label:"Value",value:z(e,0)}),n}var Y={proposed:"planProposed",approved:"planApproved",running:"planRunning",completed:"planCompleted",failed:"planFailed",denied:"planDenied",expired:"planExpired"},G={pending:"pending",running:"active",done:"complete",failed:"failed",skipped:"skipped"};function Q(e,t){const n=H(e.tool_name,e.input,t);return`${F(e.tool_name,t)}${n?` ${n}`:""}`}function q(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e)}function V(e,t){const n=e.steps.filter(e=>"done"===e.status).length;return`${q(t.planSummary,{done:n,total:e.steps.length})} · ${t[Y[e.status]]}`}function X({plan:n,labels:r}){/* @__PURE__ */
5
- return k("section",{"aria-label":r.plan,className:"border-t border-gray-200 bg-white px-3 py-2",children:/* @__PURE__ */k(e,{summary:V(n,r),busy:M(n),label:r.plan,children:n.steps.map(e=>/* @__PURE__ */k(t,{label:e.title,status:G[e.status],description:"done"!==e.status&&e.result_summary?e.result_summary:void 0},e.id))})})}function Z({approvalId:e,plan:t,input:n,labels:r,toolLabels:o,onApprove:a}){const s=function(e,t){if(e)return e.steps.map(e=>({key:e.id,title:e.title,tool_name:e.tool_name,input:e.input}));const n=t?.steps;return Array.isArray(n)?n.map((e,t)=>{const n=e??{};return{key:String(t),title:"string"==typeof n.title?n.title:"",tool_name:"string"==typeof n.tool?n.tool:"",input:n.args}}):[]}(t,n),l=q(r.planApprovalHeading,{count:s.length});/* @__PURE__ */
4
+ /* @__PURE__ */k("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */k(r,{ref:v,"aria-label":e.inputLabel,placeholder:t,rows:1,autoGrow:!0,value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),b())},className:"max-h-32"})}),c?.map(e=>e.icon?/* @__PURE__ */k(l,{type:"button",variant:"ghost","aria-label":e.label,title:e.label,disabled:!u.trim(),onClick:()=>e.onSelect(u.trim()),children:/* @__PURE__ */k(d,{name:e.icon})},e.key):/* @__PURE__ */k(p,{type:"button",variant:"ghost",disabled:!u.trim(),onClick:()=>e.onSelect(u.trim()),children:e.label},e.key)),/* @__PURE__ */k(p,n?{type:"button",variant:"secondary",onClick:s,children:e.stop}:{type:"submit",disabled:!u.trim(),children:e.send})]})}function $(e){if(!x(e))return null;const t=e;return{toolName:N(e),toolCallId:t.toolCallId,state:t.state,input:t.input,output:t.output,errorText:t.errorText,approvalId:t.approval?.id,approved:t.approval?.approved}}function R(e){const t=/* @__PURE__ */new Map;for(const n of e.parts){if("data-tool-summary"!==n.type)continue;const e=n.data;e&&"string"==typeof e.tool_call_id&&Array.isArray(e.rows)&&e.rows.length>0&&t.set(e.tool_call_id,e)}return t}function T(e){return e.parts.map(e=>"text"===e.type?e.text:"").join("")}function _(e,t){const n=e[e.length-1];if(!n)throw new Error("assistant chat: no message to send");if("user"===n.role){const e=T(n).trim();if(!e)throw new Error("assistant chat: empty message");return{conversation_id:t,text:e,approvals:[]}}const r=function(e){const t=[];for(const n of e.parts){if(!x(n))continue;const e=n;if("approval-responded"!==e.state||!e.approval||"boolean"!=typeof e.approval.approved)continue;const r={approval_id:e.approval.id,approved:e.approval.approved};e.approval.reason&&(r.reason=e.approval.reason),t.push(r)}return t}(n);if(0===r.length)throw new Error("assistant chat: no approval decision to send");return{conversation_id:t,text:null,approvals:r}}var I=/* @__PURE__ */new Set(["proposed","approved","running"]);function D(e){return I.has(e.status)}function M(e){const t=[];for(const n of e.parts)"data-plan"===n.type&&t.push(n.data);return t}function O(e){const t=/* @__PURE__ */new Map;for(const n of e)for(const e of M(n))t.delete(e.id),t.set(e.id,e);return t}function L(e){const t=[...O(e).values()],n=t[t.length-1];if(!n)return null;if(D(n))return n;const r=e[e.length-1];return r&&"assistant"===r.role&&M(r).some(e=>e.id===n.id)?n:null}function U(e){const t=e.messages.filter(e=>e.text).map(e=>({id:e.id,role:e.role,parts:[{type:"text",text:e.text}],...e.source&&e.source!==e.role?{metadata:{source:e.source}}:{}})),n=(e.plans??[]).filter(D);return(e.pending_approvals.length>0||n.length>0)&&t.push({id:`pending-approvals-${e.id}`,role:"assistant",parts:[...n.map(e=>({type:"data-plan",id:e.id,data:e})),...e.pending_approvals.map(e=>({type:`tool-${e.tool_name}`,toolCallId:e.tool_call_id??e.approval_id,state:"approval-requested",input:e.input,approval:{id:e.approval_id}}))]}),t}function E(e,t){const n=e?.message?.trim();if(!n)return t;if(n.startsWith("{")){try{const e=JSON.parse(n);for(const t of["detail","errorText","message","title","error"]){const n=e[t];if("string"==typeof n&&n.trim())return n.trim()}}catch{return t}return t}return n.startsWith("<")||n.length>400?t:n}var J=/^(load failed|failed to fetch|network ?error( when attempting to fetch resource)?|(the )?network connection was lost|error in input stream|terminated)\.?$/i;function P(e){return!(!e||"AbortError"===e.name)&&J.test(e.message?.trim()??"")}var W=/* @__PURE__ */new Set(["budget_reached","not_permitted"]);function F(e,t,n){return P(e)?{text:n.connectionDropped,retryable:!0}:{text:E(e,n.genericError),retryable:!(t&&W.has(t))}}function B(e){const t=e[e.length-1];if(!t)return!1;if("user"===t.role)return""!==T(t).trim();const n=e[e.length-2];return!(!n||"user"!==n.role||!T(n).trim())&&!t.parts.some(e=>void 0!==$(e)?.approvalId)}function H(e){const t=e.replace(/^tool-/,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-.]+/g," ").trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}var z={propose_plan:{label:"Plan the changes",running:"Planning the changes",done:"Planned the changes"}};function Y(e,t){const n=t?.[e]??z[e];return"string"==typeof n?{label:n}:n??{label:H(e)}}function K(e,t){return Y(e,t).label}function q(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function G(e,t,n){const r=Y(e,n).describe;if(!r)return"";try{return r(q(t))?.trim()??""}catch{return""}}function Q(e,t){return null==e?"":"boolean"==typeof e?e?"Yes":"No":"object"!=typeof e?String(e):Array.isArray(e)?e.map(e=>Q(e,t+1)).filter(Boolean).join(", "):t>=3?"…":Object.entries(e).map(([e,n])=>{const r=Q(n,t+1);return r?`${H(e)}: ${r}`:""}).filter(Boolean).join("; ")}function V(e){const t=q(e),n=[];for(const[e,r]of Object.entries(t)){const t=Q(r,0);t&&n.push({label:H(e),value:t})}return 0===n.length&&null!=e&&"object"!=typeof e&&n.push({label:"Value",value:Q(e,0)}),n}var X={proposed:"planProposed",approved:"planApproved",running:"planRunning",completed:"planCompleted",failed:"planFailed",denied:"planDenied",expired:"planExpired"},Z={pending:"pending",running:"active",done:"complete",failed:"failed",skipped:"skipped"};function ee(e,t){const n=G(e.tool_name,e.input,t);return`${K(e.tool_name,t)}${n?` ${n}`:""}`}function te(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e)}function ne(e,t){const n=e.steps.filter(e=>"done"===e.status).length;return`${te(t.planSummary,{done:n,total:e.steps.length})} · ${t[X[e.status]]}`}function re({plan:n,labels:r}){/* @__PURE__ */
5
+ return k("section",{"aria-label":r.plan,className:"border-t border-gray-200 bg-white px-3 py-2",children:/* @__PURE__ */k(e,{summary:ne(n,r),busy:D(n),label:r.plan,children:n.steps.map(e=>/* @__PURE__ */k(t,{label:e.title,status:Z[e.status],description:"done"!==e.status&&e.result_summary?e.result_summary:void 0},e.id))})})}function oe({approvalId:e,plan:t,input:n,labels:r,toolLabels:o,onApprove:a}){const s=function(e,t){if(e)return e.steps.map(e=>({key:e.id,title:e.title,tool_name:e.tool_name,input:e.input}));const n=t?.steps;return Array.isArray(n)?n.map((e,t)=>{const n=e??{};return{key:String(t),title:"string"==typeof n.title?n.title:"",tool_name:"string"==typeof n.tool?n.tool:"",input:n.args}}):[]}(t,n),l=te(r.planApprovalHeading,{count:s.length});/* @__PURE__ */
6
6
  return w("div",{role:"group","aria-label":l,className:"rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm",children:[
7
7
  /* @__PURE__ */k("div",{className:"font-medium text-gray-900",children:l}),
8
- /* @__PURE__ */k("ol",{className:"mt-2 list-decimal space-y-2 pl-5",children:s.map(e=>{const t=K(e.input);/* @__PURE__ */
8
+ /* @__PURE__ */k("ol",{className:"mt-2 list-decimal space-y-2 pl-5",children:s.map(e=>{const t=V(e.input);/* @__PURE__ */
9
9
  return w("li",{children:[
10
- /* @__PURE__ */k("div",{className:"font-medium text-gray-900",children:Q(e,o)}),e.title&&/* @__PURE__ */k("div",{className:"text-xs text-gray-600",children:e.title}),t.length>0&&/* @__PURE__ */k("dl",{className:"mt-1 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:t.map(e=>/* @__PURE__ */w("div",{className:"contents",children:[
10
+ /* @__PURE__ */k("div",{className:"font-medium text-gray-900",children:ee(e,o)}),e.title&&/* @__PURE__ */k("div",{className:"text-xs text-gray-600",children:e.title}),t.length>0&&/* @__PURE__ */k("dl",{className:"mt-1 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:t.map(e=>/* @__PURE__ */w("div",{className:"contents",children:[
11
11
  /* @__PURE__ */k("dt",{className:"text-gray-500",children:e.label}),
12
12
  /* @__PURE__ */k("dd",{className:"min-w-0 break-words text-gray-800",children:e.value})]},e.label))})]},e.key)})}),
13
13
  /* @__PURE__ */w("div",{className:"mt-3 flex gap-2",children:[
14
14
  /* @__PURE__ */k(p,{size:"sm",onClick:()=>a(e,!0),children:r.approvePlan}),
15
- /* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>a(e,!1),children:r.deny})]})]})}function ee({questions:e,label:t,onAsk:n}){return 0===e.length?null:/* @__PURE__ */k("div",{role:"group","aria-label":t,className:"flex flex-wrap gap-2 pl-1",children:e.map(e=>/* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function te({rows:e,label:t}){/* @__PURE__ */
15
+ /* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>a(e,!1),children:r.deny})]})]})}function ae({questions:e,label:t,onAsk:n}){return 0===e.length?null:/* @__PURE__ */k("div",{role:"group","aria-label":t,className:"flex flex-wrap gap-2 pl-1",children:e.map(e=>/* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function se({rows:e,label:t}){/* @__PURE__ */
16
16
  return k("dl",{"aria-label":t,className:"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:e.map((e,t)=>/* @__PURE__ */w("div",{className:"contents",children:[
17
17
  /* @__PURE__ */k("dt",{className:"text-gray-500",children:e.label}),
18
- /* @__PURE__ */k("dd",{className:"min-w-0 break-words "+(e.warn?"font-medium text-amber-700":"text-gray-800"),children:e.value})]},`${e.label}-${t}`))})}function ne({tool:e,toolLabels:t,labels:n,onApprove:r}){const o=H(e.toolName,e.input,t),a=K(e.input),s=e.approvalId,l=`${n.approvalNeeded}: ${F(e.toolName,t)}${o?` ${o}`:""}`;/* @__PURE__ */
18
+ /* @__PURE__ */k("dd",{className:"min-w-0 break-words "+(e.warn?"font-medium text-amber-700":"text-gray-800"),children:e.value})]},`${e.label}-${t}`))})}function le({tool:e,toolLabels:t,labels:n,onApprove:r}){const o=G(e.toolName,e.input,t),a=V(e.input),s=e.approvalId,l=`${n.approvalNeeded}: ${K(e.toolName,t)}${o?` ${o}`:""}`;/* @__PURE__ */
19
19
  return w("div",{role:"group","aria-label":l,className:"rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm",children:[
20
- /* @__PURE__ */k("div",{className:"font-medium text-gray-900",children:l}),a.length>0&&/* @__PURE__ */k("div",{className:"mt-2",children:/* @__PURE__ */k(te,{rows:a})}),
20
+ /* @__PURE__ */k("div",{className:"font-medium text-gray-900",children:l}),a.length>0&&/* @__PURE__ */k("div",{className:"mt-2",children:/* @__PURE__ */k(se,{rows:a})}),
21
21
  /* @__PURE__ */w("div",{className:"mt-3 flex gap-2",children:[
22
22
  /* @__PURE__ */k(p,{size:"sm",onClick:()=>r(s,!0),children:n.approve}),
23
- /* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>r(s,!1),children:n.deny})]})]})}var re={running:"active",done:"complete",failed:"failed",declined:"stopped",waiting:"waiting"};function oe(e,t,n){return function(e,t,n,r,o,a){const s=W(n,o),l=H(n,r,o),i=(e,t)=>({kind:e,base:t,subject:l,text:l?`${t} ${l}`:t});switch(e){case"output-available":return i("done",s.done??s.label);case"output-error":return i("failed",`${s.label} ${a.toolFailed}`);case"output-denied":return i("declined",`${s.label} ${a.toolDeclined}`);case"approval-requested":return i("waiting",`${a.approvalNeeded}: ${s.label}`);case"approval-responded":return!1===t?i("declined",`${s.label} — ${a.declined}`):i("running",`${a.approved}: ${s.running??s.label}`);default:return i("running",s.running??s.label)}}(e.state,e.approved,e.toolName,e.input,t,n)}function ae({tool:e,summary:n,toolLabels:r,labels:o,showOutput:a}){const s=oe(e,r,o),l=K(e.input),i=a&&"output-available"===e.state?K(e.output):[],c=a&&"output-error"===e.state&&e.errorText?e.errorText:"",u="output-available"===e.state&&n?n.rows:[];let p=null;return(l.length>0||i.length>0||c)&&(p=/* @__PURE__ */w("details",{className:u.length>0?"mt-1":void 0,children:[
23
+ /* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>r(s,!1),children:n.deny})]})]})}var ie={running:"active",done:"complete",failed:"failed",declined:"stopped",waiting:"waiting"};function ce(e,t,n){return function(e,t,n,r,o,a){const s=Y(n,o),l=G(n,r,o),i=(e,t)=>({kind:e,base:t,subject:l,text:l?`${t} ${l}`:t});switch(e){case"output-available":return i("done",s.done??s.label);case"output-error":return i("failed",`${s.label} ${a.toolFailed}`);case"output-denied":return i("declined",`${s.label} ${a.toolDeclined}`);case"approval-requested":return i("waiting",`${a.approvalNeeded}: ${s.label}`);case"approval-responded":return!1===t?i("declined",`${s.label} — ${a.declined}`):i("running",`${a.approved}: ${s.running??s.label}`);default:return i("running",s.running??s.label)}}(e.state,e.approved,e.toolName,e.input,t,n)}function ue({tool:e,summary:n,toolLabels:r,labels:o,showOutput:a}){const s=ce(e,r,o),l=V(e.input),i=a&&"output-available"===e.state?V(e.output):[],c=a&&"output-error"===e.state&&e.errorText?e.errorText:"",u="output-available"===e.state&&n?n.rows:[];let p=null;return(l.length>0||i.length>0||c)&&(p=/* @__PURE__ */w("details",{className:u.length>0?"mt-1":void 0,children:[
24
24
  /* @__PURE__ */k("summary",{className:"cursor-pointer select-none",children:o.details}),
25
- /* @__PURE__ */w("div",{className:"mt-1 space-y-2",children:[l.length>0&&/* @__PURE__ */k(te,{rows:l}),i.length>0&&/* @__PURE__ */k(te,{rows:i}),c&&/* @__PURE__ */k("div",{className:"text-red-600",children:c})]})]})),/* @__PURE__ */w(t,{label:s.base,description:s.subject||void 0,status:re[s.kind],children:[u.length>0&&/* @__PURE__ */k(te,{rows:u,label:o.stepSources}),p]})}function se(e,t){return e>0&&t>=100?e/(t/1e3):null}function le(e){return Math.ceil(e.length/4)}var ie=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e),ce=e=>Math.round(e).toLocaleString();function ue(e,t){const n=se(e.output_tokens,e.generation_ms);return null===n?ie(t.replyTokens,{tokens:ce(e.output_tokens)}):ie(t.replyStats,{tokens:ce(e.output_tokens),seconds:(e.generation_ms/1e3).toFixed(1),rate:ce(n)})}function pe(e,t,n){const r=t>=1e3?se(le(e),t):null;return null===r?n.streaming:ie(n.streamingRate,{rate:ce(r)})}function de(e){if("chart"!==e.lang)return null;if(!e.closed)/* @__PURE__ */return k(u,{height:200});const t=i(e.code);return t?/* @__PURE__ */k(c,{spec:t}):null}function me(e,t){return"approval-responded"===e.state&&t.some(t=>{return t.toolName===e.toolName&&"approval-requested"!==t.state&&(t.toolCallId===e.toolCallId||(n=t.input,r=e.input,JSON.stringify(n)===JSON.stringify(r)));var n,r})}function he(e,t,n,r){const o=e.flatMap(e=>"tool"===e.kind?[oe(e.tool,n,r)]:[]);if(t){const e=o.find(e=>"running"===e.kind);return e?e.base:r.working}const a=[...new Set(o.map(e=>e.base))];return a.length>0?a.join(" · "):r.reasoning}function ge({message:e,live:t,labels:n}){const r=_(e),o=r.length>0,a=h(null),[s,l]=g(0);f(()=>{if(!t)return;null===a.current&&(a.current=performance.now());const e=setInterval(()=>l(performance.now()-(a.current??performance.now())),500);return()=>clearInterval(e)},[t]);const i=e.metadata?.usage;let c=null;return t?c=o?pe(r,s,n):null:i&&(c=ue(i,n)),c?/* @__PURE__ */k("div",{className:"px-1 text-xs tabular-nums text-gray-500",children:c}):null}function fe({text:e,actions:t}){const n=o(),r=/* @__PURE__ */k("div",{className:"max-w-[85%] whitespace-pre-wrap break-words rounded-2xl bg-blue-600 px-3 py-2 text-sm text-white",children:e});return t?.length?/* @__PURE__ */w("div",{className:"flex justify-end",onContextMenu:e=>n.open(e,void 0),children:[r,n.state&&/* @__PURE__ */k(a,{...n.props,"aria-label":e,items:t.map(t=>({key:t.key,label:t.label,onSelect:()=>t.onSelect(e)}))})]}):/* @__PURE__ */k("div",{className:"flex justify-end",children:r})}function ve({message:r,toolLabels:o,labels:a,showReasoning:s,showToolOutput:l,showUsage:i,live:c,onApprove:u,plans:p,userActions:d,tableActions:m,onLinkClick:h}){const g=r.metadata?.source;if("system"===g){const e=_(r);return e?/* @__PURE__ */k("div",{className:"text-center text-xs text-gray-500",children:e}):null}if("user"===r.role){const e=_(r);return e?/* @__PURE__ */k(fe,{text:e,actions:d}):null}const f=r.parts.map($),v=T(r),b=[],y=[];let x=-1;const N=e=>{x<0&&(x=b.push(null)-1),y.push(e)};if(r.parts.forEach((e,t)=>{if("text"===e.type)return void(e.text.trim()&&b.push(
26
- /* @__PURE__ */k(n,{renderFence:de,tableActions:c?void 0:m,onLinkClick:h,children:e.text},t)));if("reasoning"===e.type)return void(s&&e.text.trim()&&N({kind:"reasoning",key:`r${t}`,text:e.text}));const r=f[t];r&&(me(r,f.slice(t+1).filter(e=>null!==e))||("approval-requested"===r.state&&r.approvalId&&"propose_plan"===r.toolName?b.push(
27
- /* @__PURE__ */k(Z,{approvalId:r.approvalId,plan:p?.get(r.approvalId),input:r.input,labels:a,toolLabels:o,onApprove:u},r.toolCallId)):"approval-requested"===r.state&&r.approvalId?b.push(
28
- /* @__PURE__ */k(ne,{tool:r,toolLabels:o,labels:a,onApprove:u},r.toolCallId)):N({kind:"tool",key:r.toolCallId,tool:r})))}),x>=0&&(b[x]=/* @__PURE__ */k(e,{summary:he(y,c,o,a),busy:c,label:a.steps,children:y.map(e=>"tool"===e.kind?/* @__PURE__ */k(ae,{tool:e.tool,summary:v.get(e.tool.toolCallId),toolLabels:o,labels:a,showOutput:l},e.key):/* @__PURE__ */k(t,{status:"complete",label:/* @__PURE__ */w("details",{children:[
25
+ /* @__PURE__ */w("div",{className:"mt-1 space-y-2",children:[l.length>0&&/* @__PURE__ */k(se,{rows:l}),i.length>0&&/* @__PURE__ */k(se,{rows:i}),c&&/* @__PURE__ */k("div",{className:"text-red-600",children:c})]})]})),/* @__PURE__ */w(t,{label:s.base,description:s.subject||void 0,status:ie[s.kind],children:[u.length>0&&/* @__PURE__ */k(se,{rows:u,label:o.stepSources}),p]})}function pe(e,t){return e>0&&t>=100?e/(t/1e3):null}function de(e){return Math.ceil(e.length/4)}var me=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e),he=e=>Math.round(e).toLocaleString();function ge(e,t){const n=pe(e.output_tokens,e.generation_ms);return null===n?me(t.replyTokens,{tokens:he(e.output_tokens)}):me(t.replyStats,{tokens:he(e.output_tokens),seconds:(e.generation_ms/1e3).toFixed(1),rate:he(n)})}function fe(e,t,n){const r=t>=1e3?pe(de(e),t):null;return null===r?n.streaming:me(n.streamingRate,{rate:he(r)})}function ve(e){if("chart"!==e.lang)return null;if(!e.closed)/* @__PURE__ */return k(u,{height:200});const t=i(e.code);return t?/* @__PURE__ */k(c,{spec:t}):null}function be(e,t){return"approval-responded"===e.state&&t.some(t=>{return t.toolName===e.toolName&&"approval-requested"!==t.state&&(t.toolCallId===e.toolCallId||(n=t.input,r=e.input,JSON.stringify(n)===JSON.stringify(r)));var n,r})}function ye(e,t,n,r){const o=e.flatMap(e=>"tool"===e.kind?[ce(e.tool,n,r)]:[]);if(t){const e=o.find(e=>"running"===e.kind);return e?e.base:r.working}const a=[...new Set(o.map(e=>e.base))];return a.length>0?a.join(" · "):r.reasoning}function ke({message:e,live:t,labels:n}){const r=T(e),o=r.length>0,a=h(null),[s,l]=g(0);f(()=>{if(!t)return;null===a.current&&(a.current=performance.now());const e=setInterval(()=>l(performance.now()-(a.current??performance.now())),500);return()=>clearInterval(e)},[t]);const i=e.metadata?.usage;let c=null;return t?c=o?fe(r,s,n):null:i&&(c=ge(i,n)),c?/* @__PURE__ */k("div",{className:"px-1 text-xs tabular-nums text-gray-500",children:c}):null}function we({text:e,actions:t}){const n=o(),r=/* @__PURE__ */k("div",{className:"max-w-[85%] whitespace-pre-wrap break-words rounded-2xl bg-blue-600 px-3 py-2 text-sm text-white",children:e});return t?.length?/* @__PURE__ */w("div",{className:"flex justify-end",onContextMenu:e=>n.open(e,void 0),children:[r,n.state&&/* @__PURE__ */k(a,{...n.props,"aria-label":e,items:t.map(t=>({key:t.key,label:t.label,onSelect:()=>t.onSelect(e)}))})]}):/* @__PURE__ */k("div",{className:"flex justify-end",children:r})}function xe({message:r,toolLabels:o,labels:a,showReasoning:s,showToolOutput:l,showUsage:i,live:c,onApprove:u,plans:p,userActions:d,tableActions:m,onLinkClick:h}){const g=r.metadata?.source;if("system"===g){const e=T(r);return e?/* @__PURE__ */k("div",{className:"text-center text-xs text-gray-500",children:e}):null}if("user"===r.role){const e=T(r);return e?/* @__PURE__ */k(we,{text:e,actions:d}):null}const f=r.parts.map($),v=R(r),b=[],y=[];let x=-1;const N=e=>{x<0&&(x=b.push(null)-1),y.push(e)};if(r.parts.forEach((e,t)=>{if("text"===e.type)return void(e.text.trim()&&b.push(
26
+ /* @__PURE__ */k(n,{renderFence:ve,tableActions:c?void 0:m,onLinkClick:h,children:e.text},t)));if("reasoning"===e.type)return void(s&&e.text.trim()&&N({kind:"reasoning",key:`r${t}`,text:e.text}));const r=f[t];r&&(be(r,f.slice(t+1).filter(e=>null!==e))||("approval-requested"===r.state&&r.approvalId&&"propose_plan"===r.toolName?b.push(
27
+ /* @__PURE__ */k(oe,{approvalId:r.approvalId,plan:p?.get(r.approvalId),input:r.input,labels:a,toolLabels:o,onApprove:u},r.toolCallId)):"approval-requested"===r.state&&r.approvalId?b.push(
28
+ /* @__PURE__ */k(le,{tool:r,toolLabels:o,labels:a,onApprove:u},r.toolCallId)):N({kind:"tool",key:r.toolCallId,tool:r})))}),x>=0&&(b[x]=/* @__PURE__ */k(e,{summary:ye(y,c,o,a),busy:c,label:a.steps,children:y.map(e=>"tool"===e.kind?/* @__PURE__ */k(ue,{tool:e.tool,summary:v.get(e.tool.toolCallId),toolLabels:o,labels:a,showOutput:l},e.key):/* @__PURE__ */k(t,{status:"complete",label:/* @__PURE__ */w("details",{children:[
29
29
  /* @__PURE__ */k("summary",{className:"cursor-pointer select-none",children:a.reasoning}),
30
30
  /* @__PURE__ */k("div",{className:"mt-1 whitespace-pre-wrap text-gray-500",children:e.text})]})},e.key))},"chain")),0===b.length)return null;const C=/* @__PURE__ */w("div",{className:"max-w-[92%] min-w-0 space-y-2 rounded-2xl bg-white px-3 py-2 text-gray-800 shadow-sm",children:["staff"===g&&/* @__PURE__ */k("div",{className:"text-xs font-medium text-blue-600",children:a.teamName}),b]});return!i||g?/* @__PURE__ */k("div",{className:"flex justify-start",children:C}):/* @__PURE__ */w("div",{className:"flex flex-col items-start gap-1",children:[C,
31
- /* @__PURE__ */k(ge,{message:r,live:c,labels:a})]})}function be(e){const{messages:t,status:n,error:r,history:o,labels:a}=e,l=h(null),i=y(()=>function(e){const t=/* @__PURE__ */new Map;for(const n of D(e).values())t.set(n.approval_id,n);return t}(t),[t]),c=t[t.length-1],u="ready"!==n||r||e.handedOver||"assistant"!==c?.role||!e.onAsk?[]:e.followups??[];return f(()=>{const e=l.current;e&&(e.scrollTop=e.scrollHeight)},[t,n]),/* @__PURE__ */w("div",{ref:l,role:"log","aria-label":e.title,"aria-live":"polite","aria-busy":"submitted"===n||"streaming"===n,className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto bg-gray-50 p-3",children:["loading"===o&&/* @__PURE__ */w("div",{role:"status",className:"flex items-center gap-2 text-xs text-gray-500",children:[
32
- /* @__PURE__ */k(m,{className:"h-3 w-3"}),a.loadingHistory]}),"failed"===o&&/* @__PURE__ */k(s,{tone:"warning",children:a.historyFailed}),0===t.length&&"idle"===o&&/* @__PURE__ */k("p",{className:"m-auto text-center text-sm text-gray-500",children:a.emptyState}),t.map((r,o)=>/* @__PURE__ */k(ve,{live:o===t.length-1&&("submitted"===n||"streaming"===n),message:r,toolLabels:e.toolLabels,labels:a,showReasoning:e.showReasoning,showToolOutput:e.showToolOutput,showUsage:e.showUsage,tableActions:e.tableActions,onApprove:e.onApprove,onLinkClick:e.onLinkClick,plans:i,userActions:e.userMessageActions},r.id)),e.onAsk&&/* @__PURE__ */k(ee,{questions:u,label:a.followups,onAsk:e.onAsk}),e.handedOver&&/* @__PURE__ */k("div",{role:"status",className:"text-center text-xs text-gray-500",children:a.teamJoined}),"submitted"===n&&/* @__PURE__ */w("div",{role:"status",className:"flex items-center gap-2 text-xs text-gray-500",children:[
33
- /* @__PURE__ */k(m,{className:"h-3 w-3"}),a.thinking]}),r&&/* @__PURE__ */k("div",{role:"alert",children:/* @__PURE__ */k(s,{tone:"danger",children:E(r,a.genericError)})})]})}var ye={title:"Assistant",placeholder:"Ask a question…",inputLabel:"Message to the assistant",send:"Send",stop:"Stop",newChat:"New chat",open:"Open assistant",close:"Close assistant",thinking:"Thinking",loadingHistory:"Loading the conversation",historyFailed:"The earlier conversation could not be loaded.",emptyState:"Ask me anything to get started.",approvalNeeded:"Approval needed",approve:"Approve",deny:"Deny",approved:"Approved",declined:"Declined",toolFailed:"did not complete",toolDeclined:"was not approved",details:"Details",stepSources:"Where these figures came from",reasoning:"Reasoning",genericError:"Something went wrong. Please try again.",working:"Working",steps:"Steps",teamName:"Team",teamJoined:"A team member has joined",plan:"Plan",planSummary:"Plan: {done} of {total} done",planProposed:"waiting for your approval",planApproved:"approved, starting",planRunning:"in progress",planCompleted:"finished",planFailed:"stopped — not every step ran",planDenied:"not approved — nothing was changed",planExpired:"expired — nothing was changed",planApprovalHeading:"Approve this plan of {count} steps",approvePlan:"Approve plan",replyStats:"{tokens} tokens · {seconds} s · {rate} tok/s",replyTokens:"{tokens} tokens",streaming:"Streaming",streamingRate:"Streaming · ~{rate} tok/s",followups:"Suggested follow-up questions"},ke=(e,t)=>`${e.replace(/\/+$/,"")}/${t}`;function we(e){return ke(e,"assistant/chat/")}function xe(e,t){return ke(e,`assistant/chat/${encodeURIComponent(t)}/`)}function Ne(e){const t=h(e);t.current=e;const n=h(e.conversationId?{id:e.conversationId}:null),[r,o]=g("idle"),[a,s]=g(!1),[l,i]=g([]),[c,u]=g(n.current),p=b(e=>{n.current=e,u(e)},[]),d=b((e,n)=>(t.current.fetch??fetch)(e,n),[]),m=y(()=>new C({api:we(e.apiBase),fetch:d,prepareSendMessagesRequest:async({messages:e})=>{const{apiBase:r,getHeaders:o,credentials:a}=t.current;return{api:we(r),body:I(e,n.current?.id??null),headers:await(o?.())??{},...a?{credentials:a}:{}}}}),[d]),v=A({transport:m,sendAutomaticallyWhen:j,onData:e=>{if("data-followups"===e.type)return void i(function(e){const t=e?.questions;if(!Array.isArray(t))return[];const n=[];for(const e of t){if("string"!=typeof e)continue;const t=e.trim();!t||t.includes("\n")||n.includes(t)||n.push(t)}return n.slice(0,3)}(e.data));if("data-conversation"!==e.type)return;const{id:r,guest_token:o}=e.data,a=n.current,s=o??(a?.id===r?a.guestToken:void 0);a&&a.id===r&&a.guestToken===s||(p(s?{id:r,guestToken:s}:{id:r}),t.current.onConversation?.(n.current))}}),{setMessages:k,stop:w}=v,x=b(async(e,n)=>{const{apiBase:r,getHeaders:a,credentials:l,onConversation:c}=t.current;o("loading"),i([]);try{const t=await d(xe(r,e),{method:"GET",headers:await(a?.())??{},...l?{credentials:l}:{},signal:n});if(n.aborted)return;if(404===t.status)return p(null),c?.(null),void o("idle");if(!t.ok)throw new Error(`history ${t.status}`);const i=await t.json();if(n.aborted)return;s(!0===i.handed_over),k(e=>e.length>0?e:U(i)),o("idle")}catch{n.aborted||o("failed")}},[d,k,p]),N=e.conversationId??null;f(()=>{if(N===(n.current?.id??null)&&v.messages.length>0)return;if(null===N)return n.current&&(p(null),w(),k([]),i([])),void o("idle");n.current?.id===N||p({id:N});const e=new AbortController;return x(N,e.signal),()=>e.abort()},[N,x,k,w,p]);const S=b(async e=>{const r=n.current?.id;if(r)try{const{apiBase:o,getHeaders:a,credentials:l}=t.current,i=await d(xe(o,r),{method:"GET",headers:await(a?.())??{},...l?{credentials:l}:{},...e?{signal:e}:{}});if(!i.ok||e?.aborted||n.current?.id!==r)return;const c=await i.json();s(!0===c.handed_over);const u=U(c).filter(e=>e.metadata?.source);if(0===u.length)return;k(e=>{const t=new Set(e.map(e=>e.id)),n=u.filter(e=>!t.has(e.id));return n.length>0?[...e,...n]:e})}catch{}},[d,k]),$=h(S);$.current=S;const{status:T}=v,_="submitted"===T||"streaming"===T,R=h(!1),M=h(!1),O=!!e.subscribe;f(()=>{const e=R.current&&!_;if(R.current=_,!e)return;if(O&&!M.current)return;M.current=!1;const t=new AbortController;return $.current(t.signal),()=>t.abort()},[_,O]);const D=h(_);D.current=_;const L=c?.id,E=c?.guestToken;f(()=>{const e=n.current,r=t.current.subscribe;if(e&&r)return r(e,()=>{D.current?M.current=!0:$.current()})??void 0},[L,E]);const J=b(e=>{const t=e.trim();t&&(i([]),v.sendMessage({text:t}))},[v]),P=b((e,t)=>{i([]),v.addToolApprovalResponse({id:e,approved:t})},[v]),W=b(()=>{w(),p(null),k([]),o("idle"),s(!1),i([]),t.current.onConversation?.(null)},[k,w,p]);return{messages:v.messages,status:v.status,error:v.error,historyState:r,handedOver:a,followups:l,send:J,stop:w,approve:P,reset:W}}function Ce(e){const t={...ye,...e.labels},n=e.variant??"panel",r=Ne(e),o="submitted"===r.status||"streaming"===r.status,a=h(e.onBusyChange);a.current=e.onBusyChange,f(()=>{a.current?.(o)},[o]);const s="window"===n,i=e.showHeader??"window"!==n,c=e.title??t.title,u=L(r.messages),m=h(!1),{send:g}=r;return f(()=>{m.current||e.conversationId||!e.initialQuestion?.trim()||(m.current=!0,g(e.initialQuestion))},[]),/* @__PURE__ */w("section",{"aria-label":c,className:`flex h-full min-h-0 flex-col bg-white text-gray-900 ${e.className??""}`.trim(),children:[i&&/* @__PURE__ */w("header",{className:"flex items-center gap-2 border-b border-gray-200 px-3 py-2",children:[
31
+ /* @__PURE__ */k(ke,{message:r,live:c,labels:a})]})}function Ne(e){const{messages:t,status:n,error:r,history:o,labels:a}=e,l=h(null),i=y(()=>function(e){const t=/* @__PURE__ */new Map;for(const n of O(e).values())t.set(n.approval_id,n);return t}(t),[t]),c=r?F(r,e.errorCode??null,a):null,u=t[t.length-1],d="ready"!==n||r||e.handedOver||"assistant"!==u?.role||!e.onAsk?[]:e.followups??[];return f(()=>{const e=l.current;e&&(e.scrollTop=e.scrollHeight)},[t,n]),/* @__PURE__ */w("div",{ref:l,role:"log","aria-label":e.title,"aria-live":"polite","aria-busy":"submitted"===n||"streaming"===n,className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto bg-gray-50 p-3",children:["loading"===o&&/* @__PURE__ */w("div",{role:"status",className:"flex items-center gap-2 text-xs text-gray-500",children:[
32
+ /* @__PURE__ */k(m,{className:"h-3 w-3"}),a.loadingHistory]}),"failed"===o&&/* @__PURE__ */k(s,{tone:"warning",children:a.historyFailed}),0===t.length&&"idle"===o&&/* @__PURE__ */k("p",{className:"m-auto text-center text-sm text-gray-500",children:a.emptyState}),t.map((r,o)=>/* @__PURE__ */k(xe,{live:o===t.length-1&&("submitted"===n||"streaming"===n),message:r,toolLabels:e.toolLabels,labels:a,showReasoning:e.showReasoning,showToolOutput:e.showToolOutput,showUsage:e.showUsage,tableActions:e.tableActions,onApprove:e.onApprove,onLinkClick:e.onLinkClick,plans:i,userActions:e.userMessageActions},r.id)),e.onAsk&&/* @__PURE__ */k(ae,{questions:d,label:a.followups,onAsk:e.onAsk}),e.handedOver&&/* @__PURE__ */k("div",{role:"status",className:"text-center text-xs text-gray-500",children:a.teamJoined}),"submitted"===n&&/* @__PURE__ */w("div",{role:"status",className:"flex items-center gap-2 text-xs text-gray-500",children:[
33
+ /* @__PURE__ */k(m,{className:"h-3 w-3"}),a.thinking]}),c&&/* @__PURE__ */w("div",{role:"alert",className:"flex flex-col items-start gap-2",children:[
34
+ /* @__PURE__ */k(s,{tone:"danger",children:c.text}),c.retryable&&e.onRetry&&"error"===n&&/* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:e.onRetry,children:a.retry})]})]})}var Ce={title:"Assistant",placeholder:"Ask a question…",inputLabel:"Message to the assistant",send:"Send",stop:"Stop",newChat:"New chat",open:"Open assistant",close:"Close assistant",thinking:"Thinking",loadingHistory:"Loading the conversation",historyFailed:"The earlier conversation could not be loaded.",emptyState:"Ask me anything to get started.",approvalNeeded:"Approval needed",approve:"Approve",deny:"Deny",approved:"Approved",declined:"Declined",toolFailed:"did not complete",toolDeclined:"was not approved",details:"Details",stepSources:"Where these figures came from",reasoning:"Reasoning",genericError:"Something went wrong. Please try again.",connectionDropped:"The connection dropped. Your question may still be answering; reopen the chat in a moment.",retry:"Retry",working:"Working",steps:"Steps",teamName:"Team",teamJoined:"A team member has joined",plan:"Plan",planSummary:"Plan: {done} of {total} done",planProposed:"waiting for your approval",planApproved:"approved, starting",planRunning:"in progress",planCompleted:"finished",planFailed:"stopped — not every step ran",planDenied:"not approved — nothing was changed",planExpired:"expired — nothing was changed",planApprovalHeading:"Approve this plan of {count} steps",approvePlan:"Approve plan",replyStats:"{tokens} tokens · {seconds} s · {rate} tok/s",replyTokens:"{tokens} tokens",streaming:"Streaming",streamingRate:"Streaming · ~{rate} tok/s",followups:"Suggested follow-up questions"},je=(e,t)=>`${e.replace(/\/+$/,"")}/${t}`;function Ae(e){return je(e,"assistant/chat/")}function Se(e,t){return je(e,`assistant/chat/${encodeURIComponent(t)}/`)}function $e(e){const t=h(e);t.current=e;const n=h(e.conversationId?{id:e.conversationId}:null),[r,o]=g("idle"),[a,s]=g(!1),[l,i]=g(null),[c,u]=g([]),[p,d]=g(n.current),m=b(e=>{n.current=e,d(e)},[]),v=b((e,n)=>(t.current.fetch??fetch)(e,n),[]),k=y(()=>new C({api:Ae(e.apiBase),fetch:v,prepareSendMessagesRequest:async({messages:e})=>{const{apiBase:r,getHeaders:o,credentials:a}=t.current;return{api:Ae(r),body:_(e,n.current?.id??null),headers:await(o?.())??{},...a?{credentials:a}:{}}}}),[v]),w=A({transport:k,sendAutomaticallyWhen:j,onData:e=>{if("data-error"===e.type)return void i(e.data.code);if("data-followups"===e.type)return void u(function(e){const t=e?.questions;if(!Array.isArray(t))return[];const n=[];for(const e of t){if("string"!=typeof e)continue;const t=e.trim();!t||t.includes("\n")||n.includes(t)||n.push(t)}return n.slice(0,3)}(e.data));if("data-conversation"!==e.type)return;const{id:r,guest_token:o}=e.data,a=n.current,s=o??(a?.id===r?a.guestToken:void 0);a&&a.id===r&&a.guestToken===s||(m(s?{id:r,guestToken:s}:{id:r}),t.current.onConversation?.(n.current))}}),{setMessages:x,stop:N}=w,S=b(async(e,n)=>{const{apiBase:r,getHeaders:a,credentials:l,onConversation:i}=t.current;o("loading"),u([]);try{const t=await v(Se(r,e),{method:"GET",headers:await(a?.())??{},...l?{credentials:l}:{},signal:n});if(n.aborted)return;if(404===t.status)return m(null),i?.(null),void o("idle");if(!t.ok)throw new Error(`history ${t.status}`);const c=await t.json();if(n.aborted)return;s(!0===c.handed_over),x(e=>e.length>0?e:U(c)),o("idle")}catch{n.aborted||o("failed")}},[v,x,m]),$=e.conversationId??null;f(()=>{if($===(n.current?.id??null)&&w.messages.length>0)return;if(null===$)return n.current&&(m(null),N(),x([]),u([])),void o("idle");n.current?.id===$||m({id:$});const e=new AbortController;return S($,e.signal),()=>e.abort()},[$,S,x,N,m]);const R=b(async e=>{const r=n.current?.id;if(r)try{const{apiBase:o,getHeaders:a,credentials:l}=t.current,i=await v(Se(o,r),{method:"GET",headers:await(a?.())??{},...l?{credentials:l}:{},...e?{signal:e}:{}});if(!i.ok||e?.aborted||n.current?.id!==r)return;const c=await i.json();s(!0===c.handed_over);const u=U(c).filter(e=>e.metadata?.source);if(0===u.length)return;x(e=>{const t=new Set(e.map(e=>e.id)),n=u.filter(e=>!t.has(e.id));return n.length>0?[...e,...n]:e})}catch{}},[v,x]),T=h(R);T.current=R;const{status:I}=w,D="submitted"===I||"streaming"===I,M=h(!1),O=h(!1),L=!!e.subscribe;f(()=>{const e=M.current&&!D;if(M.current=D,!e)return;if(L&&!O.current)return;O.current=!1;const t=new AbortController;return T.current(t.signal),()=>t.abort()},[D,L]);const E=h(D);E.current=D;const J=p?.id,P=p?.guestToken;f(()=>{const e=n.current,r=t.current.subscribe;if(e&&r)return r(e,()=>{E.current?O.current=!0:T.current()})??void 0},[J,P]);const W=b(e=>{const t=e.trim();t&&(i(null),u([]),w.sendMessage({text:t}))},[w]),F=b(()=>{B(w.messages)&&(i(null),u([]),w.regenerate())},[w]),H=b((e,t)=>{i(null),u([]),w.addToolApprovalResponse({id:e,approved:t})},[w]),z=b(()=>{N(),m(null),x([]),o("idle"),s(!1),i(null),u([]),t.current.onConversation?.(null)},[x,N,m]);return{messages:w.messages,status:w.status,error:w.error,errorCode:l,canRetry:B(w.messages),retry:F,historyState:r,handedOver:a,followups:c,send:W,stop:N,approve:H,reset:z}}function Re(e){const t={...Ce,...e.labels},n=e.variant??"panel",r=$e(e),o="submitted"===r.status||"streaming"===r.status,a=h(e.onBusyChange);a.current=e.onBusyChange,f(()=>{a.current?.(o)},[o]);const s="window"===n,i=e.showHeader??"window"!==n,c=e.title??t.title,u=L(r.messages),m=h(!1),{send:g}=r;return f(()=>{m.current||e.conversationId||!e.initialQuestion?.trim()||(m.current=!0,g(e.initialQuestion))},[]),/* @__PURE__ */w("section",{"aria-label":c,className:`flex h-full min-h-0 flex-col bg-white text-gray-900 ${e.className??""}`.trim(),children:[i&&/* @__PURE__ */w("header",{className:"flex items-center gap-2 border-b border-gray-200 px-3 py-2",children:[
34
35
  /* @__PURE__ */k("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:c}),r.messages.length>0&&/* @__PURE__ */k(p,{size:"sm",variant:"ghost",onClick:r.reset,children:t.newChat}),e.onClose&&/* @__PURE__ */k(l,{size:"sm","aria-label":t.close,onClick:e.onClose,children:/* @__PURE__ */k(d,{name:"close"})})]}),
35
- /* @__PURE__ */k(be,{messages:r.messages,status:r.status,error:r.error,history:r.historyState,handedOver:r.handedOver,labels:t,title:c,toolLabels:e.toolLabels,showReasoning:s&&!0===e.showReasoning,showToolOutput:s,showUsage:s&&!0===e.showUsage,tableActions:e.tableActions,onApprove:r.approve,onLinkClick:e.onLinkClick,userMessageActions:e.userMessageActions,followups:r.followups,onAsk:r.send}),u&&/* @__PURE__ */k(X,{plan:u,labels:t},u.id),
36
- /* @__PURE__ */k(S,{labels:t,placeholder:e.placeholder??t.placeholder,busy:o,focusWhen:e.focusComposer,onSend:r.send,onStop:r.stop,onNewChat:!i&&!1!==e.showNewChat&&r.messages.length>0?r.reset:void 0,actions:e.composerActions})]})}function je(e){const t={...ye,...e.labels},[n,r]=g(e.defaultOpen??!1),o=v(),a=h(null),s=h(n),l=t=>{r(t),e.onOpenChange?.(t)};return f(()=>{s.current&&!n&&a.current?.focus(),s.current=n},[n]),/* @__PURE__ */w("div",{className:"rosh-assistant",style:{display:"contents"},children:[n&&/* @__PURE__ */k("div",{id:o,role:"dialog","aria-label":e.title??t.title,onKeyDown:e=>{"Escape"===e.key&&l(!1)},className:"fixed inset-x-2 bottom-20 z-[var(--z-window,1000)] h-[min(34rem,calc(100dvh-6rem))] overflow-hidden rounded-xl border border-gray-200 shadow-xl sm:inset-x-auto sm:right-4 sm:w-96",children:/* @__PURE__ */k(Ce,{...e,onClose:()=>l(!1),focusComposer:!0})}),
37
- /* @__PURE__ */k("button",{ref:a,type:"button","aria-expanded":n,"aria-controls":n?o:void 0,"aria-label":n?t.close:t.open,onClick:()=>l(!n),className:"fixed bottom-4 right-4 z-[var(--z-window,1000)] flex h-12 w-12 items-center justify-center rounded-full shadow-lg bg-[var(--assistant-launcher-bg,var(--color-blue-600))] text-[var(--assistant-launcher-ink,var(--color-white))] hover:bg-[var(--assistant-launcher-bg-hover,var(--color-blue-700))] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--assistant-launcher-bg,var(--color-blue-600))]",children:/* @__PURE__ */k(d,n?{name:"close",size:20}:{name:"chat-bubble-left-right",size:22})})]})}function Ae(e){if("bubble"===e.variant)/* @__PURE__ */return k(je,{...e});const t="window"!==e.variant;/* @__PURE__ */
38
- return k(Ce,{...e,className:`${t?"border-l border-gray-200":""} ${e.className??""}`.trim()})}export{ne as ApprovalCard,Ae as AssistantChat,ve as AssistantMessage,ye as DEFAULT_ASSISTANT_CHAT_LABELS,Z as PlanApprovalCard,X as PlanChecklist,ae as ToolStep,I as buildRequestBody,le as estimateTokens,ue as finishedStats,pe as liveStats,U as messagesFromHistory,L as pinnedPlan,D as plansOf,se as tokensPerSecond,T as toolSummariesOf};
36
+ /* @__PURE__ */k(Ne,{messages:r.messages,status:r.status,error:r.error,errorCode:r.errorCode,onRetry:r.canRetry?r.retry:void 0,history:r.historyState,handedOver:r.handedOver,labels:t,title:c,toolLabels:e.toolLabels,showReasoning:s&&!0===e.showReasoning,showToolOutput:s,showUsage:s&&!0===e.showUsage,tableActions:e.tableActions,onApprove:r.approve,onLinkClick:e.onLinkClick,userMessageActions:e.userMessageActions,followups:r.followups,onAsk:r.send}),u&&/* @__PURE__ */k(re,{plan:u,labels:t},u.id),
37
+ /* @__PURE__ */k(S,{labels:t,placeholder:e.placeholder??t.placeholder,busy:o,focusWhen:e.focusComposer,onSend:r.send,onStop:r.stop,onNewChat:!i&&!1!==e.showNewChat&&r.messages.length>0?r.reset:void 0,actions:e.composerActions})]})}function Te(e){const t={...Ce,...e.labels},[n,r]=g(e.defaultOpen??!1),o=v(),a=h(null),s=h(n),l=t=>{r(t),e.onOpenChange?.(t)};return f(()=>{s.current&&!n&&a.current?.focus(),s.current=n},[n]),/* @__PURE__ */w("div",{className:"rosh-assistant",style:{display:"contents"},children:[n&&/* @__PURE__ */k("div",{id:o,role:"dialog","aria-label":e.title??t.title,onKeyDown:e=>{"Escape"===e.key&&l(!1)},className:"fixed inset-x-2 bottom-20 z-[var(--z-window,1000)] h-[min(34rem,calc(100dvh-6rem))] overflow-hidden rounded-xl border border-gray-200 shadow-xl sm:inset-x-auto sm:right-4 sm:w-96",children:/* @__PURE__ */k(Re,{...e,onClose:()=>l(!1),focusComposer:!0})}),
38
+ /* @__PURE__ */k("button",{ref:a,type:"button","aria-expanded":n,"aria-controls":n?o:void 0,"aria-label":n?t.close:t.open,onClick:()=>l(!n),className:"fixed bottom-4 right-4 z-[var(--z-window,1000)] flex h-12 w-12 items-center justify-center rounded-full shadow-lg bg-[var(--assistant-launcher-bg,var(--color-blue-600))] text-[var(--assistant-launcher-ink,var(--color-white))] hover:bg-[var(--assistant-launcher-bg-hover,var(--color-blue-700))] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--assistant-launcher-bg,var(--color-blue-600))]",children:/* @__PURE__ */k(d,n?{name:"close",size:20}:{name:"chat-bubble-left-right",size:22})})]})}function _e(e){if("bubble"===e.variant)/* @__PURE__ */return k(Te,{...e});const t="window"!==e.variant;/* @__PURE__ */
39
+ return k(Re,{...e,className:`${t?"border-l border-gray-200":""} ${e.className??""}`.trim()})}export{le as ApprovalCard,_e as AssistantChat,xe as AssistantMessage,Ce as DEFAULT_ASSISTANT_CHAT_LABELS,oe as PlanApprovalCard,re as PlanChecklist,ue as ToolStep,_ as buildRequestBody,de as estimateTokens,F as failureView,ge as finishedStats,P as isDroppedConnection,fe as liveStats,U as messagesFromHistory,L as pinnedPlan,O as plansOf,pe as tokensPerSecond,R as toolSummariesOf};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{openFilesInTrashMode,setFilesDemoTree}from"../chunk-IAQC775L.js";export{setBrowserStartUrl}from"../chunk-LWLCNQY7.js";export{BUILTIN_APP_INFO}from"../chunk-Z7BZBDOI.js";import"../chunk-RAAUW5OZ.js";import{setPdfPreview as e}from"../chunk-ESL5TDNA.js";export{setPdfPreview}from"../chunk-ESL5TDNA.js";import{setSpreadsheetPreview as t}from"../chunk-VTVSMRFX.js";export{setSpreadsheetPreview}from"../chunk-VTVSMRFX.js";import"../chunk-L3NYH4QV.js";import"../chunk-CY5N5OA3.js";import"../chunk-AW7TOB6N.js";import"../chunk-KNUR2UEG.js";import"../chunk-JDCM2VHG.js";import"../chunk-HVX37PKU.js";import"../chunk-5A7MWTXX.js";import"../chunk-Y53KNQKL.js";import"../chunk-FL2PUQX7.js";import"../chunk-ZN3O2KJ7.js";import"../chunk-YCQVEJOT.js";import"../chunk-KC3EX26K.js";import"../chunk-VWGWZY7A.js";import"../chunk-PKXQDCNR.js";import{toast_default as o}from"../chunk-4NXMMWL6.js";import"../chunk-UGTRSRIW.js";import"../chunk-XWLWG4HS.js";import"../chunk-CDAJKLGL.js";import"../chunk-D323R2FT.js";import"../chunk-2NRQJ3SC.js";import"../chunk-PJCVNFWM.js";import"../chunk-QR4RM7PO.js";import"../chunk-5QFPTDQF.js";import"../chunk-4IU5BSVE.js";import"../chunk-K7U4RWXJ.js";import"../chunk-VH6GB73Q.js";import"../chunk-KIBL6M3T.js";import"../chunk-J75ZT2JQ.js";import"../chunk-Q5MD3VY6.js";import"../chunk-MRJKZWWV.js";import"../chunk-6KO5VTL7.js";import"../chunk-22S6LG6D.js";import"../chunk-PGN5ME7B.js";import"../chunk-62LW225J.js";import"../chunk-GLUJS42B.js";import"../chunk-D65T4H6J.js";import"../chunk-DTJRIWFR.js";import"../chunk-TWVUQUUD.js";import{currentShellStrings as r}from"../chunk-E6UCGCOC.js";import"../chunk-C3QOHMR6.js";import{lazy as n}from"react";function i(e){const t=/\.([a-z0-9]+)(?:[?#].*)?$/i.exec((e||"").trim());return t?t[1].toLowerCase():""}var s=/* @__PURE__ */new Set(["csv","tsv"]),c=/* @__PURE__ */new Set(["xlsx","xls","xlsm","ods"]),m=/* @__PURE__ */new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif"]),p=/* @__PURE__ */new Set(["step","stp","stl","obj","gltf","glb","3mf","iges","igs"]);function l(e){const t=i(e);return"pdf"===t?"pdf":"dxf"===t?"dxf":s.has(t)?"csv":m.has(t)?"image":p.has(t)?"3d":null}function a(e){window.open(e,"_blank","noopener,noreferrer")}async function u(e,t,o){if(t.fetchBlob)return(await t.fetchBlob(o)).text();const r=await fetch(e);if(!r.ok)throw new Error(`fetch failed: ${r.status}`);return r.text()}function h(e,t){return(e instanceof Error?e.message:"")||t}async function j(n,s,m={}){const p=r().attachment,j=n?.url||"",k=n?.filename||p.fallbackName;if(!j&&!m.fetchBlob)return void o.error(p.noLink);const d=l(k)??l(j);if("csv"===d){try{t({csv:await u(j,m,n),filename:k}),s("/spreadsheet")}catch{o.error(p.spreadsheetFailed),j&&a(j)}return}if(c.has(i(k)||i(j)))return o.error(p.workbookUnavailable),void(j&&a(j));if(!d)return j?(o.info(p.noViewer),void a(j)):void o.error(p.noLink);if(!m.fetchBlob)return e({url:j,filename:k,kind:d}),void s("/preview");const f=e({filename:k,kind:d,converting:!0,convertingMessage:m.loadingMessage||p.loading});s("/preview");try{const e=await m.fetchBlob(n);f.update({url:URL.createObjectURL(e),filename:k,kind:d})}catch(e){f.update({filename:k,kind:d,converting:!1,convertingMessage:h(e,p.loadFailed)})}}var k=n(()=>import("../Calculator-4JDJKSA7.js")),d=n(()=>import("../Spreadsheet-XWQZBPUS.js")),f=n(()=>import("../Weather-DS4YZ6SH.js")),w=n(()=>import("../CurrencyConverter-S7LG5PMX.js")),S=n(()=>import("../PomodoroTimer-ZR2VLO6G.js")),g=n(()=>import("../Notepad-63WDR4UZ.js")),v=n(()=>import("../WorldClock-7S4TITSF.js")),L=n(()=>import("../Stock-VNFYS73L.js")),b=n(()=>import("../Preview-GC4TXEJ5.js")),T=n(()=>import("../PdfViewer-67VBUIRD.js")),C=n(()=>import("../Documents-OHA5LY2W.js")),W=n(()=>import("../Files-7QHP4BLV.js")),P=n(()=>import("../Browser-CFASYHEO.js")),V={"/calculator":{component:k,label:"Calculator",size:"sm",allowPinOnTop:!0,utility:!0,widget:!0,dimensions:[280,420]},"/spreadsheet":{component:d,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0},"/notepad":{component:g,label:"Notepad",size:"lg",allowPinOnTop:!0,flushBody:!0},"/weather":{component:f,label:"Weather",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,400]},"/currency":{component:w,label:"Currency Converter",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/pomodoro":{component:S,label:"Pomodoro Timer",size:"sm",utility:!0,widget:!0,dimensions:[320,600]},"/world-clock":{component:v,label:"World Clock",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/stock":{component:L,label:"Stocks",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,360]}},B={"/preview":{component:b,label:"Preview",size:"2xl",appStyle:!0,multiInstance:!0},"/documents":{component:C,label:"Documents",size:"xl",appStyle:!0,multiInstance:!0},"/files":{component:W,label:"Files",size:"xl",appStyle:!0}},R={"/browser":{component:P,label:"Browser",size:"2xl",appStyle:!0,multiInstance:!0}},U={...V,...B,...R};export{P as Browser,k as Calculator,w as CurrencyConverter,C as Documents,W as Files,g as Notepad,T as PdfViewer,S as PomodoroTimer,b as Preview,d as Spreadsheet,L as Stock,f as Weather,v as WorldClock,l as attachmentKind,U as bundledApps,B as documentApps,j as openAttachment,V as utilityApps,R as webApps};
2
+ export{openFilesInTrashMode,setFilesDemoTree}from"../chunk-IAQC775L.js";export{setBrowserStartUrl}from"../chunk-LWLCNQY7.js";export{BUILTIN_APP_INFO}from"../chunk-3ZVRB3CV.js";import"../chunk-RAAUW5OZ.js";import{setPdfPreview as e}from"../chunk-ESL5TDNA.js";export{setPdfPreview}from"../chunk-ESL5TDNA.js";import{setSpreadsheetPreview as t}from"../chunk-VTVSMRFX.js";export{setSpreadsheetPreview}from"../chunk-VTVSMRFX.js";import"../chunk-L3NYH4QV.js";import"../chunk-CY5N5OA3.js";import"../chunk-AW7TOB6N.js";import"../chunk-KNUR2UEG.js";import"../chunk-JDCM2VHG.js";import"../chunk-HVX37PKU.js";import"../chunk-5A7MWTXX.js";import"../chunk-Y53KNQKL.js";import"../chunk-FL2PUQX7.js";import"../chunk-ZN3O2KJ7.js";import"../chunk-YCQVEJOT.js";import"../chunk-KC3EX26K.js";import"../chunk-VWGWZY7A.js";import"../chunk-PKXQDCNR.js";import{toast_default as o}from"../chunk-4NXMMWL6.js";import"../chunk-UGTRSRIW.js";import"../chunk-XWLWG4HS.js";import"../chunk-CDAJKLGL.js";import"../chunk-D323R2FT.js";import"../chunk-L2OSJ2YC.js";import"../chunk-PJCVNFWM.js";import"../chunk-QR4RM7PO.js";import"../chunk-5QFPTDQF.js";import"../chunk-4IU5BSVE.js";import"../chunk-K7U4RWXJ.js";import"../chunk-VH6GB73Q.js";import"../chunk-KIBL6M3T.js";import"../chunk-J75ZT2JQ.js";import"../chunk-Q5MD3VY6.js";import"../chunk-MRJKZWWV.js";import"../chunk-6KO5VTL7.js";import"../chunk-22S6LG6D.js";import"../chunk-PGN5ME7B.js";import"../chunk-62LW225J.js";import"../chunk-GLUJS42B.js";import"../chunk-D65T4H6J.js";import"../chunk-DTJRIWFR.js";import"../chunk-TWVUQUUD.js";import{currentShellStrings as r}from"../chunk-E6UCGCOC.js";import"../chunk-C3QOHMR6.js";import{lazy as n}from"react";function i(e){const t=/\.([a-z0-9]+)(?:[?#].*)?$/i.exec((e||"").trim());return t?t[1].toLowerCase():""}var s=/* @__PURE__ */new Set(["csv","tsv"]),c=/* @__PURE__ */new Set(["xlsx","xls","xlsm","ods"]),m=/* @__PURE__ */new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif"]),p=/* @__PURE__ */new Set(["step","stp","stl","obj","gltf","glb","3mf","iges","igs"]);function l(e){const t=i(e);return"pdf"===t?"pdf":"dxf"===t?"dxf":s.has(t)?"csv":m.has(t)?"image":p.has(t)?"3d":null}function a(e){window.open(e,"_blank","noopener,noreferrer")}async function u(e,t,o){if(t.fetchBlob)return(await t.fetchBlob(o)).text();const r=await fetch(e);if(!r.ok)throw new Error(`fetch failed: ${r.status}`);return r.text()}function h(e,t){return(e instanceof Error?e.message:"")||t}async function j(n,s,m={}){const p=r().attachment,j=n?.url||"",k=n?.filename||p.fallbackName;if(!j&&!m.fetchBlob)return void o.error(p.noLink);const d=l(k)??l(j);if("csv"===d){try{t({csv:await u(j,m,n),filename:k}),s("/spreadsheet")}catch{o.error(p.spreadsheetFailed),j&&a(j)}return}if(c.has(i(k)||i(j)))return o.error(p.workbookUnavailable),void(j&&a(j));if(!d)return j?(o.info(p.noViewer),void a(j)):void o.error(p.noLink);if(!m.fetchBlob)return e({url:j,filename:k,kind:d}),void s("/preview");const f=e({filename:k,kind:d,converting:!0,convertingMessage:m.loadingMessage||p.loading});s("/preview");try{const e=await m.fetchBlob(n);f.update({url:URL.createObjectURL(e),filename:k,kind:d})}catch(e){f.update({filename:k,kind:d,converting:!1,convertingMessage:h(e,p.loadFailed)})}}var k=n(()=>import("../Calculator-4JDJKSA7.js")),d=n(()=>import("../Spreadsheet-UWD62JIM.js")),f=n(()=>import("../Weather-DS4YZ6SH.js")),w=n(()=>import("../CurrencyConverter-S7LG5PMX.js")),S=n(()=>import("../PomodoroTimer-ZR2VLO6G.js")),g=n(()=>import("../Notepad-ZJ7N4TZM.js")),v=n(()=>import("../WorldClock-7S4TITSF.js")),b=n(()=>import("../Stock-VNFYS73L.js")),L=n(()=>import("../Preview-AZQSMBW5.js")),T=n(()=>import("../PdfViewer-67VBUIRD.js")),V=n(()=>import("../Documents-SP25WN7V.js")),C=n(()=>import("../Files-SEGSJMVA.js")),W=n(()=>import("../Browser-Y335UIBR.js")),M={"/calculator":{component:k,label:"Calculator",size:"sm",allowPinOnTop:!0,utility:!0,widget:!0,dimensions:[280,420]},"/spreadsheet":{component:d,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0},"/notepad":{component:g,label:"Notepad",size:"lg",allowPinOnTop:!0,flushBody:!0},"/weather":{component:f,label:"Weather",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,400]},"/currency":{component:w,label:"Currency Converter",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/pomodoro":{component:S,label:"Pomodoro Timer",size:"sm",utility:!0,widget:!0,dimensions:[320,600]},"/world-clock":{component:v,label:"World Clock",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/stock":{component:b,label:"Stocks",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,360]}},N={"/preview":{component:L,label:"Preview",size:"2xl",appStyle:!0,multiInstance:!0},"/documents":{component:V,label:"Documents",size:"xl",appStyle:!0,multiInstance:!0},"/files":{component:C,label:"Files",size:"xl",appStyle:!0}},P={"/browser":{component:W,label:"Browser",size:"2xl",appStyle:!0,multiInstance:!0}},R={...M,...N,...P};export{W as Browser,k as Calculator,w as CurrencyConverter,V as Documents,C as Files,g as Notepad,T as PdfViewer,S as PomodoroTimer,L as Preview,d as Spreadsheet,b as Stock,f as Weather,v as WorldClock,l as attachmentKind,R as bundledApps,N as documentApps,j as openAttachment,M as utilityApps,P as webApps};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"module";import{join as n}from"path";import{existsSync as t,readFileSync as i,readdirSync as r}from"fs";var o=/[.+^$()|[\]\\]/g;function s(e){let n="",t=0;for(let i=0;i<e.length;i++){const r=e[i];"*"===r?"*"===e[i+1]?"/"===e[i+2]?(n+="(?:[^/]+/)*",i+=2):(n+=".*",i+=1):n+="[^/]*":"?"===r?n+="[^/]":"{"===r?(n+="(?:",t+=1):"}"===r&&t>0?(n+=")",t-=1):n+=","===r&&t>0?"|":r.replace(o,"\\$&")}if(0!==t)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${n}$`)}function a(e){const n=e.map(s);return e=>n.some(n=>n.test(e))}var c=new Set(["node_modules",".git"]),g=new Set(["dist","coverage",".next",".turbo"]);function l(e){const n=e.search(/[*?{]/),t=-1===n?e:e.slice(0,n),i=t.lastIndexOf("/");return-1===i?"":t.slice(0,i)}function u(e,t){const i=a(t),o=[...new Set(t.map(l))].sort(),s=o.filter(e=>!o.some(n=>n!==e&&(""===n||e.startsWith(`${n}/`)))),u=new Set,d=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?c.has(e.name)||""===t&&g.has(e.name)||d(n):e.isFile()&&i(n)&&u.add(n)}};for(const e of s)d(e);return[...u].sort(h)}var h=(e,n)=>e<n?-1:e>n?1:0,d={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"]}};new Set((d.busy?.words??[]).map(e=>e.toLowerCase()));var f=class extends Error{},m=new Set(["$schema","schema","include","exclude","allow"]),p=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),w=e=>"string"==typeof e&&""!==e.trim();var y="d3as2htf4hwbtr.cloudfront.net",S={dealer:{bucket:"inovit-dealer-portal-assets",hosts:["d201q0i87q901p.cloudfront.net"],key_pattern:"^marketing/"},media:{bucket:"regis-media-production",hosts:["media.regis.design","d21nnr9ivf9hcc.cloudfront.net"],key_pattern:"^[a-z0-9_]+/storefront/(?!uploads/thumbs/)"},site:{bucket:"inovit-ecommerce-media",hosts:["cdn.inovit.com","dhxlibd8r3td0.cloudfront.net"],key_pattern:"^images/"}},$=Object.values(S),R=Object.freeze([...new Set([...$.flatMap(e=>e.hosts),y,...$.map(e=>e.bucket)])].sort()),b=new RegExp([...R.map(e=>{return`(?<![\\w-])${n=e,n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w-])`;var n}),"(?<![\\w-])[a-z0-9]+\\.cloudfront\\.net(?![\\w-])","(?<![\\w-])(?:[a-z0-9-]+\\.)*s3(?:[.-][a-z0-9-]+)*\\.amazonaws\\.com(?![\\w-])","s3://"].join("|"),"gi");function k(e,n,t){const i=e.createSourceFile(n,t,e.ScriptTarget.Latest,!0,function(e,n){return n.endsWith(".tsx")?e.ScriptKind.TSX:n.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(n)?e.ScriptKind.JS:e.ScriptKind.TS}(e,n)),r=[],o=(e,n)=>{const t=i.getLineAndCharacterOfPosition(e.getStart(i)).line+1;for(const e of function(e){return[...e.matchAll(b)].map(e=>({match:e[0],index:e.index??0}))}(n)){const i=n.slice(0,e.index);r.push({line:t+(i.match(/\n/g)?.length??0),match:e.match})}},s=n=>{e.isStringLiteral(n)||e.isNoSubstitutionTemplateLiteral(n)||e.isTemplateHead(n)||e.isTemplateMiddle(n)||e.isTemplateTail(n)?o(n,n.text):e.isRegularExpressionLiteral(n)&&o(n,n.text.replace(/\\(.)/g,"$1")),e.forEachChild(n,s)};return s(i),r}var v="media-host-check.config.json",x="efficient-shell-media-host-check",C=`${x}: no code writes a media origin; files are reached through the storage backend, the API's URL, media() or imageCopyUrl() (harness API-15, SSOT-2).\n\n ${x} check this repository; exits 1 on a finding\n ${x} --json print the result as JSON\n\nRefused in any string, template or regular expression: every host and bucket in\nthe image-copies contract, any *.cloudfront.net host, any S3 endpoint, and s3://.\nReads ${v} in the current directory.`;function A(e,t,r){const o=[],s=a(r.exclude);for(const e of r.include)0===u(t,[e]).length&&o.push(`include "${e}" matches no file; delete it`);const c=u(t,r.include).filter(e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!s(e)),g=[];for(const r of c)for(const o of k(e,r,i(n(t,r),"utf8")))g.push({file:r,...o});const l=(e,n)=>e.toLowerCase()===n.toLowerCase();for(const e of r.allow)g.some(n=>n.file===e.file&&l(e.match,n.match))||o.push(`allow ${e.file} "${e.match}" matches nothing any more; delete it`);return{files:c.length,findings:g.filter(e=>!(e=>r.allow.some(n=>n.file===e.file&&l(n.match,e.match)))(e)),problems:o}}process.exitCode=function(e,r){let o=!1;for(const n of e){if("--help"===n||"-h"===n)return r.out(C),0;if("--version"===n||"-v"===n)return r.out(r.version),0;if("--json"!==n)return r.err(`${x}: unknown argument "${n}"\n\n${C}`),2;o=!0}const s=n(r.cwd,v);if(!t(s))return r.err(`${x}: no ${v} in ${r.cwd}. Run it from the repository root.`),2;let a;try{const e=function(e,n="media-host-check.config.json"){const t=[];if(!p(e))throw new f(`${n}: expected an object`);for(const n of Object.keys(e))m.has(n)||t.push(`unknown key "${n}"`);1!==e.schema&&t.push('"schema" must be 1');const i=(n,i)=>{const r=e[n];return void 0!==r||i?!Array.isArray(r)||!r.every(w)||i&&0===r.length?(t.push(`"${n}" must be ${i?"a non-empty":"an"} array of globs`),[]):r:[]},r=i("include",!0),o=i("exclude",!1),s=[];void 0===e.allow||Array.isArray(e.allow)||t.push('"allow" must be an array');for(const[n,i]of(Array.isArray(e.allow)?e.allow:[]).entries()){if(!(p(i)&&w(i.file)&&w(i.match)&&w(i.reason))){t.push(`allow[${n}] needs "file", "match" and "reason", each a non-empty string`);continue}const e=Object.keys(i).filter(e=>!["file","match","reason"].includes(e));e.length&&t.push(`allow[${n}] has unknown keys: ${e.join(", ")}`),s.push({file:i.file,match:i.match,reason:i.reason})}if(t.length)throw new f(`${n}:\n ${t.join("\n ")}`);return{schema:1,include:r,exclude:o,allow:s}}(JSON.parse(i(s,"utf8")),v);a=A(r.loadTypeScript(),r.cwd,e)}catch(e){return r.err(`${x}: ${e instanceof f||e instanceof SyntaxError?e.message:String(e)}`),2}const c=a.findings.length>0||a.problems.length>0;if(o)return r.out(JSON.stringify({ok:!c,...a},null,2)),c?1:0;if(!c)return r.out(`${x}: ${a.files} files, no media origin written in code (harness API-15, SSOT-2).`),0;for(const e of a.findings)r.err(`${e.file}:${e.line} "${e.match}" is a media origin written in code.`);for(const e of a.problems)r.err(`${v}: ${e}`);return a.findings.length&&r.err(`\nReach the file through the storage backend, the URL the API returns, media() or imageCopyUrl() (harness API-15, SSOT-2). An origin that must stay goes in "allow" in ${v}, with its reason.`),1}(process.argv.slice(2),{cwd:process.cwd(),out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>function(t){for(const i of[n(process.cwd(),"package.json"),t])try{return e(i)("typescript")}catch{}throw new Error("typescript is not installed")}(import.meta.url),version:"8.31.0"});
2
+ import{createRequire as e}from"module";import{join as n}from"path";import{existsSync as t,readFileSync as i,readdirSync as r}from"fs";var o=/[.+^$()|[\]\\]/g;function s(e){let n="",t=0;for(let i=0;i<e.length;i++){const r=e[i];"*"===r?"*"===e[i+1]?"/"===e[i+2]?(n+="(?:[^/]+/)*",i+=2):(n+=".*",i+=1):n+="[^/]*":"?"===r?n+="[^/]":"{"===r?(n+="(?:",t+=1):"}"===r&&t>0?(n+=")",t-=1):n+=","===r&&t>0?"|":r.replace(o,"\\$&")}if(0!==t)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${n}$`)}function a(e){const n=e.map(s);return e=>n.some(n=>n.test(e))}var c=new Set(["node_modules",".git"]),g=new Set(["dist","coverage",".next",".turbo"]);function l(e){const n=e.search(/[*?{]/),t=-1===n?e:e.slice(0,n),i=t.lastIndexOf("/");return-1===i?"":t.slice(0,i)}function u(e,t){const i=a(t),o=[...new Set(t.map(l))].sort(),s=o.filter(e=>!o.some(n=>n!==e&&(""===n||e.startsWith(`${n}/`)))),u=new Set,d=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?c.has(e.name)||""===t&&g.has(e.name)||d(n):e.isFile()&&i(n)&&u.add(n)}};for(const e of s)d(e);return[...u].sort(h)}var h=(e,n)=>e<n?-1:e>n?1:0,d={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"]}};new Set((d.busy?.words??[]).map(e=>e.toLowerCase()));var f=class extends Error{},m=new Set(["$schema","schema","include","exclude","allow"]),p=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),w=e=>"string"==typeof e&&""!==e.trim();var y="d3as2htf4hwbtr.cloudfront.net",S={dealer:{bucket:"inovit-dealer-portal-assets",hosts:["d201q0i87q901p.cloudfront.net"],key_pattern:"^marketing/"},media:{bucket:"regis-media-production",hosts:["media.regis.design","d21nnr9ivf9hcc.cloudfront.net"],key_pattern:"^[a-z0-9_]+/storefront/(?!uploads/thumbs/)"},site:{bucket:"inovit-ecommerce-media",hosts:["cdn.inovit.com","dhxlibd8r3td0.cloudfront.net"],key_pattern:"^images/"}},$=Object.values(S),R=Object.freeze([...new Set([...$.flatMap(e=>e.hosts),y,...$.map(e=>e.bucket)])].sort()),b=new RegExp([...R.map(e=>{return`(?<![\\w-])${n=e,n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w-])`;var n}),"(?<![\\w-])[a-z0-9]+\\.cloudfront\\.net(?![\\w-])","(?<![\\w-])(?:[a-z0-9-]+\\.)*s3(?:[.-][a-z0-9-]+)*\\.amazonaws\\.com(?![\\w-])","s3://"].join("|"),"gi");function k(e,n,t){const i=e.createSourceFile(n,t,e.ScriptTarget.Latest,!0,function(e,n){return n.endsWith(".tsx")?e.ScriptKind.TSX:n.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(n)?e.ScriptKind.JS:e.ScriptKind.TS}(e,n)),r=[],o=(e,n)=>{const t=i.getLineAndCharacterOfPosition(e.getStart(i)).line+1;for(const e of function(e){return[...e.matchAll(b)].map(e=>({match:e[0],index:e.index??0}))}(n)){const i=n.slice(0,e.index);r.push({line:t+(i.match(/\n/g)?.length??0),match:e.match})}},s=n=>{e.isStringLiteral(n)||e.isNoSubstitutionTemplateLiteral(n)||e.isTemplateHead(n)||e.isTemplateMiddle(n)||e.isTemplateTail(n)?o(n,n.text):e.isRegularExpressionLiteral(n)&&o(n,n.text.replace(/\\(.)/g,"$1")),e.forEachChild(n,s)};return s(i),r}var v="media-host-check.config.json",x="efficient-shell-media-host-check",C=`${x}: no code writes a media origin; files are reached through the storage backend, the API's URL, media() or imageCopyUrl() (harness API-15, SSOT-2).\n\n ${x} check this repository; exits 1 on a finding\n ${x} --json print the result as JSON\n\nRefused in any string, template or regular expression: every host and bucket in\nthe image-copies contract, any *.cloudfront.net host, any S3 endpoint, and s3://.\nReads ${v} in the current directory.`;function A(e,t,r){const o=[],s=a(r.exclude);for(const e of r.include)0===u(t,[e]).length&&o.push(`include "${e}" matches no file; delete it`);const c=u(t,r.include).filter(e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!s(e)),g=[];for(const r of c)for(const o of k(e,r,i(n(t,r),"utf8")))g.push({file:r,...o});const l=(e,n)=>e.toLowerCase()===n.toLowerCase();for(const e of r.allow)g.some(n=>n.file===e.file&&l(e.match,n.match))||o.push(`allow ${e.file} "${e.match}" matches nothing any more; delete it`);return{files:c.length,findings:g.filter(e=>!(e=>r.allow.some(n=>n.file===e.file&&l(n.match,e.match)))(e)),problems:o}}process.exitCode=function(e,r){let o=!1;for(const n of e){if("--help"===n||"-h"===n)return r.out(C),0;if("--version"===n||"-v"===n)return r.out(r.version),0;if("--json"!==n)return r.err(`${x}: unknown argument "${n}"\n\n${C}`),2;o=!0}const s=n(r.cwd,v);if(!t(s))return r.err(`${x}: no ${v} in ${r.cwd}. Run it from the repository root.`),2;let a;try{const e=function(e,n="media-host-check.config.json"){const t=[];if(!p(e))throw new f(`${n}: expected an object`);for(const n of Object.keys(e))m.has(n)||t.push(`unknown key "${n}"`);1!==e.schema&&t.push('"schema" must be 1');const i=(n,i)=>{const r=e[n];return void 0!==r||i?!Array.isArray(r)||!r.every(w)||i&&0===r.length?(t.push(`"${n}" must be ${i?"a non-empty":"an"} array of globs`),[]):r:[]},r=i("include",!0),o=i("exclude",!1),s=[];void 0===e.allow||Array.isArray(e.allow)||t.push('"allow" must be an array');for(const[n,i]of(Array.isArray(e.allow)?e.allow:[]).entries()){if(!(p(i)&&w(i.file)&&w(i.match)&&w(i.reason))){t.push(`allow[${n}] needs "file", "match" and "reason", each a non-empty string`);continue}const e=Object.keys(i).filter(e=>!["file","match","reason"].includes(e));e.length&&t.push(`allow[${n}] has unknown keys: ${e.join(", ")}`),s.push({file:i.file,match:i.match,reason:i.reason})}if(t.length)throw new f(`${n}:\n ${t.join("\n ")}`);return{schema:1,include:r,exclude:o,allow:s}}(JSON.parse(i(s,"utf8")),v);a=A(r.loadTypeScript(),r.cwd,e)}catch(e){return r.err(`${x}: ${e instanceof f||e instanceof SyntaxError?e.message:String(e)}`),2}const c=a.findings.length>0||a.problems.length>0;if(o)return r.out(JSON.stringify({ok:!c,...a},null,2)),c?1:0;if(!c)return r.out(`${x}: ${a.files} files, no media origin written in code (harness API-15, SSOT-2).`),0;for(const e of a.findings)r.err(`${e.file}:${e.line} "${e.match}" is a media origin written in code.`);for(const e of a.problems)r.err(`${v}: ${e}`);return a.findings.length&&r.err(`\nReach the file through the storage backend, the URL the API returns, media() or imageCopyUrl() (harness API-15, SSOT-2). An origin that must stay goes in "allow" in ${v}, with its reason.`),1}(process.argv.slice(2),{cwd:process.cwd(),out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>function(t){for(const i of[n(process.cwd(),"package.json"),t])try{return e(i)("typescript")}catch{}throw new Error("typescript is not installed")}(import.meta.url),version:"8.32.0"});
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{execFileSync as e}from"child_process";import{createRequire as t}from"module";import{join as n}from"path";import{existsSync as i,readFileSync as 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 B(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 P=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","SplitButton","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 Be=(e,t)=>`${e} ${t}${1===e?"":"s"}`,Pe=(e,t)=>{const n=B(e);return t.map(e=>`${e} ${n[e]??0}`).join(" · ")};process.exitCode=function(e,t){const r=function(e){const t={print:!1,summary:!1,json:!1,update:!1,allowMove:!1,init:!1,noBase:!1,help:!1,version:!1,kinds:[]};for(let n=0;n<e.length;n++){const i=e[n];if("--print"===i)t.print=!0;else if("--summary"===i)t.summary=!0;else if("--json"===i)t.json=!0;else if("--update"===i)t.update=!0;else if("--allow-move"===i)t.allowMove=!0;else if("--init"===i)t.init=!0;else if("--no-base"===i)t.noBase=!0;else if("--help"===i||"-h"===i)t.help=!0;else if("--version"===i||"-v"===i)t.version=!0;else if("--kind"===i){const i=e[++n];if(!i)return"--kind needs a kind after it";t.kinds.push(...i.split(","))}else{if(!i.startsWith("--kind="))return`unknown argument "${i}"`;t.kinds.push(...i.slice(7).split(","))}}return t.allowMove&&!t.update?"--allow-move goes with --update":t.kinds.length&&!t.init?"--kind goes with --init":[t.print,t.summary,t.update,t.init].filter(Boolean).length>1?"choose one of --print, --summary, --update and --init":t}(e);if("string"==typeof r)return t.err(`${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 P(`${t}: must be a JSON object`);for(const t of Object.keys(e))D.has(t)||i(`unknown key "${t}"`);1!==e.schema&&i("number"==typeof e.schema&&e.schema>1?`"schema": ${e.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');const c=[];if(Array.isArray(e.kinds)&&0!==e.kinds.length)for(const t of e.kinds)l(t)?c.includes(t)?i(`"kinds": "${t}" is listed twice`):c.push(t):i(`"kinds": unknown kind ${JSON.stringify(t)} (this efficient-shell knows: ${a.join(", ")})`);else i(`"kinds" must list the kinds this repository checks, from: ${a.join(", ")}`);const d=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 P(`${t}:\n - ${n.join("\n - ")}`);return{schema:1,kinds:a.filter(e=>c.includes(e)),include:d,exclude:u,includeImporting:h,output:p,allow:f}}(JSON.parse(s(p,"utf8")),Te)}catch(e){return c(e instanceof P?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 ${Be(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} (${Be(S.counts.size,"line")}: ${Pe(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=B(r),n=B(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 ${Be(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=B(a.counts),c=B(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:B(k.counts),baseline:B(S.counts),allowed:B(e),kitDeps:k.kitDeps,shellPeers:k.shellPeers,chartDeps:k.chartDeps,failures:J},null,2)),U?0:1}t.out(`UI kit check (harness UI-24), efficient-shell ${t.version}\n`);const W=(e,n,i="")=>{if(0===n.length)return t.out(` ok ${e}`);t.err(` FAIL ${e}`);for(const e of n)t.err(` ${e}`);i&&t.err(` ${i}`)};t.out(` ok the reader reads its own fixtures (typescript ${m.version})`),t.out(` ok read ${Be(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 ${Be(k.files.length,"file")} still draw UI of their own: `+Pe(k.counts,T)),t.out(""),U?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${Be(J.length,"problem")})`),U?0:1}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>function(e){for(const i of[n(process.cwd(),"package.json"),e])try{return t(i)("typescript")}catch{}throw new Error("typescript is not installed")}(import.meta.url),git:function(t){try{return e("git",t,{cwd:process.cwd(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:6e4,maxBuffer:67108864})}catch{return null}},version:"8.31.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 B(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 P=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","SplitButton","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 Be=(e,t)=>`${e} ${t}${1===e?"":"s"}`,Pe=(e,t)=>{const n=B(e);return t.map(e=>`${e} ${n[e]??0}`).join(" · ")};process.exitCode=function(e,t){const r=function(e){const t={print:!1,summary:!1,json:!1,update:!1,allowMove:!1,init:!1,noBase:!1,help:!1,version:!1,kinds:[]};for(let n=0;n<e.length;n++){const i=e[n];if("--print"===i)t.print=!0;else if("--summary"===i)t.summary=!0;else if("--json"===i)t.json=!0;else if("--update"===i)t.update=!0;else if("--allow-move"===i)t.allowMove=!0;else if("--init"===i)t.init=!0;else if("--no-base"===i)t.noBase=!0;else if("--help"===i||"-h"===i)t.help=!0;else if("--version"===i||"-v"===i)t.version=!0;else if("--kind"===i){const i=e[++n];if(!i)return"--kind needs a kind after it";t.kinds.push(...i.split(","))}else{if(!i.startsWith("--kind="))return`unknown argument "${i}"`;t.kinds.push(...i.slice(7).split(","))}}return t.allowMove&&!t.update?"--allow-move goes with --update":t.kinds.length&&!t.init?"--kind goes with --init":[t.print,t.summary,t.update,t.init].filter(Boolean).length>1?"choose one of --print, --summary, --update and --init":t}(e);if("string"==typeof r)return t.err(`${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 P(`${t}: must be a JSON object`);for(const t of Object.keys(e))D.has(t)||i(`unknown key "${t}"`);1!==e.schema&&i("number"==typeof e.schema&&e.schema>1?`"schema": ${e.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');const c=[];if(Array.isArray(e.kinds)&&0!==e.kinds.length)for(const t of e.kinds)l(t)?c.includes(t)?i(`"kinds": "${t}" is listed twice`):c.push(t):i(`"kinds": unknown kind ${JSON.stringify(t)} (this efficient-shell knows: ${a.join(", ")})`);else i(`"kinds" must list the kinds this repository checks, from: ${a.join(", ")}`);const d=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 P(`${t}:\n - ${n.join("\n - ")}`);return{schema:1,kinds:a.filter(e=>c.includes(e)),include:d,exclude:u,includeImporting:h,output:p,allow:f}}(JSON.parse(s(p,"utf8")),Te)}catch(e){return c(e instanceof P?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 ${Be(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} (${Be(S.counts.size,"line")}: ${Pe(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=B(r),n=B(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 ${Be(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=B(a.counts),c=B(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:B(k.counts),baseline:B(S.counts),allowed:B(e),kitDeps:k.kitDeps,shellPeers:k.shellPeers,chartDeps:k.chartDeps,failures:J},null,2)),U?0:1}t.out(`UI kit check (harness UI-24), efficient-shell ${t.version}\n`);const W=(e,n,i="")=>{if(0===n.length)return t.out(` ok ${e}`);t.err(` FAIL ${e}`);for(const e of n)t.err(` ${e}`);i&&t.err(` ${i}`)};t.out(` ok the reader reads its own fixtures (typescript ${m.version})`),t.out(` ok read ${Be(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 ${Be(k.files.length,"file")} still draw UI of their own: `+Pe(k.counts,T)),t.out(""),U?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${Be(J.length,"problem")})`),U?0:1}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>function(e){for(const i of[n(process.cwd(),"package.json"),e])try{return t(i)("typescript")}catch{}throw new Error("typescript is not installed")}(import.meta.url),git:function(t){try{return e("git",t,{cwd:process.cwd(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:6e4,maxBuffer:67108864})}catch{return null}},version:"8.32.0"});